From 133fb9f5c4dfbc6a2ec23d032235ffbe38baacd3 Mon Sep 17 00:00:00 2001 From: Alex Florisca Date: Tue, 17 Oct 2023 15:07:30 +0100 Subject: [PATCH 1/9] Move radio-control to packages/components and update paths --- .../components/cart-checkout/local-pickup-select/index.tsx | 6 ++++-- .../shipping-rates-control-package/package-rates.tsx | 5 +++-- assets/js/base/components/index.ts | 1 - assets/js/base/components/radio-control-accordion/index.tsx | 2 +- .../payment-methods/saved-payment-method-options.tsx | 6 ++++-- .../inner-blocks/checkout-pickup-options-block/block.tsx | 2 +- .../components/order-local-pickup-packages/index.tsx | 2 +- packages/components/index.js | 5 +++++ .../js/base => packages}/components/radio-control/index.tsx | 0 .../components/radio-control/option-layout.tsx | 0 .../base => packages}/components/radio-control/option.tsx | 0 .../base => packages}/components/radio-control/style.scss | 0 .../js/base => packages}/components/radio-control/types.ts | 0 13 files changed, 19 insertions(+), 10 deletions(-) rename {assets/js/base => packages}/components/radio-control/index.tsx (100%) rename {assets/js/base => packages}/components/radio-control/option-layout.tsx (100%) rename {assets/js/base => packages}/components/radio-control/option.tsx (100%) rename {assets/js/base => packages}/components/radio-control/style.scss (100%) rename {assets/js/base => packages}/components/radio-control/types.ts (100%) diff --git a/assets/js/base/components/cart-checkout/local-pickup-select/index.tsx b/assets/js/base/components/cart-checkout/local-pickup-select/index.tsx index 3a4d42ba6cc..a1b6c3f5894 100644 --- a/assets/js/base/components/cart-checkout/local-pickup-select/index.tsx +++ b/assets/js/base/components/cart-checkout/local-pickup-select/index.tsx @@ -1,12 +1,14 @@ /** * External dependencies */ -import { RadioControlOption } from '@woocommerce/base-components/radio-control/types'; +import { + RadioControl, + RadioControlOption, +} from '@woocommerce/blocks-components'; import { CartShippingPackageShippingRate } from '@woocommerce/types'; /** * Internal dependencies */ -import RadioControl from '../../radio-control'; interface LocalPickupSelectProps { title?: string | undefined; diff --git a/assets/js/base/components/cart-checkout/shipping-rates-control-package/package-rates.tsx b/assets/js/base/components/cart-checkout/shipping-rates-control-package/package-rates.tsx index 8ea650b608b..31778fba701 100644 --- a/assets/js/base/components/cart-checkout/shipping-rates-control-package/package-rates.tsx +++ b/assets/js/base/components/cart-checkout/shipping-rates-control-package/package-rates.tsx @@ -2,9 +2,10 @@ * External dependencies */ import { useState, useEffect } from '@wordpress/element'; -import RadioControl, { +import { + RadioControl, RadioControlOptionLayout, -} from '@woocommerce/base-components/radio-control'; +} from '@woocommerce/blocks-components'; import type { CartShippingPackageShippingRate } from '@woocommerce/types'; import { usePrevious } from '@woocommerce/base-hooks'; diff --git a/assets/js/base/components/index.ts b/assets/js/base/components/index.ts index 203121ebbbb..3288f814334 100644 --- a/assets/js/base/components/index.ts +++ b/assets/js/base/components/index.ts @@ -24,7 +24,6 @@ export * from './product-name'; export * from './product-price'; export * from './product-rating'; export * from './quantity-selector'; -export * from './radio-control'; export * from './radio-control-accordion'; export * from './read-more'; export * from './reviews'; diff --git a/assets/js/base/components/radio-control-accordion/index.tsx b/assets/js/base/components/radio-control-accordion/index.tsx index d55cf315bd3..f8a743a60c9 100644 --- a/assets/js/base/components/radio-control-accordion/index.tsx +++ b/assets/js/base/components/radio-control-accordion/index.tsx @@ -3,11 +3,11 @@ */ import classnames from 'classnames'; import { withInstanceId } from '@wordpress/compose'; +import { RadioControlOption } from '@woocommerce/blocks-components'; /** * Internal dependencies */ -import RadioControlOption from '../radio-control/option'; interface RadioControlAccordionProps { className?: string; diff --git a/assets/js/blocks/cart-checkout-shared/payment-methods/saved-payment-method-options.tsx b/assets/js/blocks/cart-checkout-shared/payment-methods/saved-payment-method-options.tsx index c90ab0406db..b70a25a22c5 100644 --- a/assets/js/blocks/cart-checkout-shared/payment-methods/saved-payment-method-options.tsx +++ b/assets/js/blocks/cart-checkout-shared/payment-methods/saved-payment-method-options.tsx @@ -4,7 +4,10 @@ import { useMemo, cloneElement } from '@wordpress/element'; import { __, sprintf } from '@wordpress/i18n'; import { noticeContexts } from '@woocommerce/base-context'; -import RadioControl from '@woocommerce/base-components/radio-control'; +import { + RadioControl, + RadioControlOption, +} from '@woocommerce/blocks-components'; import { usePaymentMethodInterface, useStoreEvents, @@ -13,7 +16,6 @@ import { PAYMENT_STORE_KEY } from '@woocommerce/block-data'; import { useDispatch, useSelect } from '@wordpress/data'; import { getPaymentMethods } from '@woocommerce/blocks-registry'; import { isNull } from '@woocommerce/types'; -import { RadioControlOption } from '@woocommerce/base-components/radio-control/types'; /** * Internal dependencies diff --git a/assets/js/blocks/checkout/inner-blocks/checkout-pickup-options-block/block.tsx b/assets/js/blocks/checkout/inner-blocks/checkout-pickup-options-block/block.tsx index 91771f5109e..e7c7ca7dd6b 100644 --- a/assets/js/blocks/checkout/inner-blocks/checkout-pickup-options-block/block.tsx +++ b/assets/js/blocks/checkout/inner-blocks/checkout-pickup-options-block/block.tsx @@ -14,7 +14,7 @@ import FormattedMonetaryAmount from '@woocommerce/base-components/formatted-mone import { decodeEntities } from '@wordpress/html-entities'; import { getSetting } from '@woocommerce/settings'; import { Icon, mapMarker } from '@wordpress/icons'; -import type { RadioControlOption } from '@woocommerce/base-components/radio-control/types'; +import type { RadioControlOption } from '@woocommerce/blocks-components'; import { CartShippingPackageShippingRate } from '@woocommerce/types'; import { isPackageRateCollectable, diff --git a/packages/checkout/components/order-local-pickup-packages/index.tsx b/packages/checkout/components/order-local-pickup-packages/index.tsx index ef07b6d5fb0..af403b21b58 100644 --- a/packages/checkout/components/order-local-pickup-packages/index.tsx +++ b/packages/checkout/components/order-local-pickup-packages/index.tsx @@ -7,7 +7,7 @@ import { CartShippingPackageShippingRate, } from '@woocommerce/type-defs/cart'; import { Component } from '@wordpress/element'; -import { RadioControlOption } from '@woocommerce/base-components/radio-control/types'; +import { RadioControlOption } from '@woocommerce/blocks-components'; /** * Internal dependencies diff --git a/packages/components/index.js b/packages/components/index.js index 4293e92612b..85e491fdb1d 100644 --- a/packages/components/index.js +++ b/packages/components/index.js @@ -1 +1,6 @@ export { default as CheckboxList } from './checkbox-list'; +export { + default as RadioControl, + RadioControlOption, + RadioControlOptionLayout, +} from './radio-control'; diff --git a/assets/js/base/components/radio-control/index.tsx b/packages/components/radio-control/index.tsx similarity index 100% rename from assets/js/base/components/radio-control/index.tsx rename to packages/components/radio-control/index.tsx diff --git a/assets/js/base/components/radio-control/option-layout.tsx b/packages/components/radio-control/option-layout.tsx similarity index 100% rename from assets/js/base/components/radio-control/option-layout.tsx rename to packages/components/radio-control/option-layout.tsx diff --git a/assets/js/base/components/radio-control/option.tsx b/packages/components/radio-control/option.tsx similarity index 100% rename from assets/js/base/components/radio-control/option.tsx rename to packages/components/radio-control/option.tsx diff --git a/assets/js/base/components/radio-control/style.scss b/packages/components/radio-control/style.scss similarity index 100% rename from assets/js/base/components/radio-control/style.scss rename to packages/components/radio-control/style.scss diff --git a/assets/js/base/components/radio-control/types.ts b/packages/components/radio-control/types.ts similarity index 100% rename from assets/js/base/components/radio-control/types.ts rename to packages/components/radio-control/types.ts From 8b3fa366d11ca0df672d4dda5e8b9335e53bfc98 Mon Sep 17 00:00:00 2001 From: Alex Florisca Date: Tue, 17 Oct 2023 15:21:53 +0100 Subject: [PATCH 2/9] Update paths to RadioControlOptionType --- .../components/cart-checkout/local-pickup-select/index.tsx | 4 ++-- .../payment-methods/saved-payment-method-options.tsx | 4 ++-- .../inner-blocks/checkout-pickup-options-block/block.tsx | 4 ++-- .../checkout/components/order-local-pickup-packages/index.tsx | 4 ++-- packages/components/{index.js => index.ts} | 1 + packages/components/radio-control/index.tsx | 1 + 6 files changed, 10 insertions(+), 8 deletions(-) rename packages/components/{index.js => index.ts} (84%) diff --git a/assets/js/base/components/cart-checkout/local-pickup-select/index.tsx b/assets/js/base/components/cart-checkout/local-pickup-select/index.tsx index a1b6c3f5894..78e8fefc266 100644 --- a/assets/js/base/components/cart-checkout/local-pickup-select/index.tsx +++ b/assets/js/base/components/cart-checkout/local-pickup-select/index.tsx @@ -3,7 +3,7 @@ */ import { RadioControl, - RadioControlOption, + type RadioControlOptionType, } from '@woocommerce/blocks-components'; import { CartShippingPackageShippingRate } from '@woocommerce/types'; /** @@ -19,7 +19,7 @@ interface LocalPickupSelectProps { renderPickupLocation: ( location: CartShippingPackageShippingRate, pickupLocationsCount: number - ) => RadioControlOption; + ) => RadioControlOptionType; packageCount: number; } /** diff --git a/assets/js/blocks/cart-checkout-shared/payment-methods/saved-payment-method-options.tsx b/assets/js/blocks/cart-checkout-shared/payment-methods/saved-payment-method-options.tsx index b70a25a22c5..1cf07cfc1de 100644 --- a/assets/js/blocks/cart-checkout-shared/payment-methods/saved-payment-method-options.tsx +++ b/assets/js/blocks/cart-checkout-shared/payment-methods/saved-payment-method-options.tsx @@ -6,7 +6,7 @@ import { __, sprintf } from '@wordpress/i18n'; import { noticeContexts } from '@woocommerce/base-context'; import { RadioControl, - RadioControlOption, + type RadioControlOptionType, } from '@woocommerce/blocks-components'; import { usePaymentMethodInterface, @@ -89,7 +89,7 @@ const SavedPaymentMethodOptions = () => { const { removeNotice } = useDispatch( 'core/notices' ); const { dispatchCheckoutEvent } = useStoreEvents(); - const options = useMemo< RadioControlOption[] >( () => { + const options = useMemo< RadioControlOptionType[] >( () => { const types = Object.keys( savedPaymentMethods ); // Get individual payment methods from saved payment methods and put them into a unique array. diff --git a/assets/js/blocks/checkout/inner-blocks/checkout-pickup-options-block/block.tsx b/assets/js/blocks/checkout/inner-blocks/checkout-pickup-options-block/block.tsx index e7c7ca7dd6b..2bddc1cc414 100644 --- a/assets/js/blocks/checkout/inner-blocks/checkout-pickup-options-block/block.tsx +++ b/assets/js/blocks/checkout/inner-blocks/checkout-pickup-options-block/block.tsx @@ -14,7 +14,7 @@ import FormattedMonetaryAmount from '@woocommerce/base-components/formatted-mone import { decodeEntities } from '@wordpress/html-entities'; import { getSetting } from '@woocommerce/settings'; import { Icon, mapMarker } from '@wordpress/icons'; -import type { RadioControlOption } from '@woocommerce/blocks-components'; +import { type RadioControlOptionType } from '@woocommerce/blocks-components'; import { CartShippingPackageShippingRate } from '@woocommerce/types'; import { isPackageRateCollectable, @@ -67,7 +67,7 @@ const getPickupDetails = ( const renderPickupLocation = ( option: CartShippingPackageShippingRate, packageCount: number -): RadioControlOption => { +): RadioControlOptionType => { const priceWithTaxes = getSetting( 'displayCartPricesIncludingTax', false ) ? parseInt( option.price, 10 ) + parseInt( option.taxes, 10 ) : option.price; diff --git a/packages/checkout/components/order-local-pickup-packages/index.tsx b/packages/checkout/components/order-local-pickup-packages/index.tsx index af403b21b58..37455e5a720 100644 --- a/packages/checkout/components/order-local-pickup-packages/index.tsx +++ b/packages/checkout/components/order-local-pickup-packages/index.tsx @@ -7,7 +7,7 @@ import { CartShippingPackageShippingRate, } from '@woocommerce/type-defs/cart'; import { Component } from '@wordpress/element'; -import { RadioControlOption } from '@woocommerce/blocks-components'; +import { type RadioControlOptionType } from '@woocommerce/blocks-components'; /** * Internal dependencies @@ -28,7 +28,7 @@ interface ExperimentalOrderLocalPickupPackagesProps { renderPickupLocation: ( option: CartShippingPackageShippingRate, packageCount: number - ) => RadioControlOption; + ) => RadioControlOptionType; } const Slot = ( { extensions, diff --git a/packages/components/index.js b/packages/components/index.ts similarity index 84% rename from packages/components/index.js rename to packages/components/index.ts index 85e491fdb1d..e4c080de17e 100644 --- a/packages/components/index.js +++ b/packages/components/index.ts @@ -3,4 +3,5 @@ export { default as RadioControl, RadioControlOption, RadioControlOptionLayout, + type RadioControlOptionType, } from './radio-control'; diff --git a/packages/components/radio-control/index.tsx b/packages/components/radio-control/index.tsx index 1b0f18952d0..643e2472b02 100644 --- a/packages/components/radio-control/index.tsx +++ b/packages/components/radio-control/index.tsx @@ -53,4 +53,5 @@ const RadioControl = ( { export default RadioControl; export { default as RadioControlOption } from './option'; +export { type RadioControlOption as RadioControlOptionType } from './types'; export { default as RadioControlOptionLayout } from './option-layout'; From 2037114eefa88f25312a6675422a41c0c8069142 Mon Sep 17 00:00:00 2001 From: Alex Florisca Date: Wed, 18 Oct 2023 10:32:36 +0100 Subject: [PATCH 3/9] Fix webpack entries for ts --- bin/webpack-entries.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/webpack-entries.js b/bin/webpack-entries.js index 8dcb49987a8..c0c8412b6c9 100644 --- a/bin/webpack-entries.js +++ b/bin/webpack-entries.js @@ -166,7 +166,7 @@ const getBlockEntries = ( relativePath ) => { const entries = { styling: { // Packages styles - 'packages-style': glob.sync( './packages/**/index.js' ), + 'packages-style': glob.sync( './packages/**/index.{t,j}s' ), // Shared blocks code 'wc-blocks': './assets/js/index.js', @@ -195,7 +195,7 @@ const entries = { wcBlocksSharedHocs: './assets/js/shared/hocs/index.js', priceFormat: './packages/prices/index.js', blocksCheckout: './packages/checkout/index.js', - blocksComponents: './packages/components/index.js', + blocksComponents: './packages/components/index.ts', }, main: { // Shared blocks code From 585654983d239f646f36e4612c954678c1752bbc Mon Sep 17 00:00:00 2001 From: Alex Florisca Date: Wed, 18 Oct 2023 10:39:37 +0100 Subject: [PATCH 4/9] Move RadioControlAccordion --- .../payment-methods/payment-method-options.js | 2 +- packages/components/index.ts | 2 ++ .../components/radio-control-accordion/index.tsx | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) rename {assets/js/base => packages}/components/radio-control-accordion/index.tsx (96%) diff --git a/assets/js/blocks/cart-checkout-shared/payment-methods/payment-method-options.js b/assets/js/blocks/cart-checkout-shared/payment-methods/payment-method-options.js index ec80578572b..fb151538dc4 100644 --- a/assets/js/blocks/cart-checkout-shared/payment-methods/payment-method-options.js +++ b/assets/js/blocks/cart-checkout-shared/payment-methods/payment-method-options.js @@ -8,7 +8,7 @@ import { import { cloneElement, useCallback } from '@wordpress/element'; import { useEditorContext } from '@woocommerce/base-context'; import classNames from 'classnames'; -import RadioControlAccordion from '@woocommerce/base-components/radio-control-accordion'; +import { RadioControlAccordion } from '@woocommerce/blocks-components'; import { useDispatch, useSelect } from '@wordpress/data'; import { getPaymentMethods } from '@woocommerce/blocks-registry'; diff --git a/packages/components/index.ts b/packages/components/index.ts index e4c080de17e..1a67e8514a2 100644 --- a/packages/components/index.ts +++ b/packages/components/index.ts @@ -5,3 +5,5 @@ export { RadioControlOptionLayout, type RadioControlOptionType, } from './radio-control'; + +export { default as RadioControlAccordion } from './radio-control-accordion'; diff --git a/assets/js/base/components/radio-control-accordion/index.tsx b/packages/components/radio-control-accordion/index.tsx similarity index 96% rename from assets/js/base/components/radio-control-accordion/index.tsx rename to packages/components/radio-control-accordion/index.tsx index f8a743a60c9..723a6ff74f9 100644 --- a/assets/js/base/components/radio-control-accordion/index.tsx +++ b/packages/components/radio-control-accordion/index.tsx @@ -3,11 +3,11 @@ */ import classnames from 'classnames'; import { withInstanceId } from '@wordpress/compose'; -import { RadioControlOption } from '@woocommerce/blocks-components'; /** * Internal dependencies */ +import { RadioControlOption } from '../radio-control'; interface RadioControlAccordionProps { className?: string; From ed9cbd7931b11cf4c5c48b032dc5236bc1270aa0 Mon Sep 17 00:00:00 2001 From: Alex Florisca Date: Wed, 18 Oct 2023 15:52:29 +0100 Subject: [PATCH 5/9] Import types from relative path to fix unit tests --- .../local-pickup-select/index.tsx | 8 ++--- .../saved-payment-method-options.tsx | 8 ++--- .../payment-methods/test/payment-methods.js | 31 +++++++++++-------- .../checkout-pickup-options-block/block.tsx | 4 +-- .../order-local-pickup-packages/index.tsx | 4 +-- packages/components/index.ts | 1 - 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/assets/js/base/components/cart-checkout/local-pickup-select/index.tsx b/assets/js/base/components/cart-checkout/local-pickup-select/index.tsx index 78e8fefc266..2404e4f5be4 100644 --- a/assets/js/base/components/cart-checkout/local-pickup-select/index.tsx +++ b/assets/js/base/components/cart-checkout/local-pickup-select/index.tsx @@ -1,14 +1,12 @@ /** * External dependencies */ -import { - RadioControl, - type RadioControlOptionType, -} from '@woocommerce/blocks-components'; +import { RadioControl } from '@woocommerce/blocks-components'; import { CartShippingPackageShippingRate } from '@woocommerce/types'; /** * Internal dependencies */ +import type { RadioControlOption } from '../../../../../../packages/components/radio-control/types'; interface LocalPickupSelectProps { title?: string | undefined; @@ -19,7 +17,7 @@ interface LocalPickupSelectProps { renderPickupLocation: ( location: CartShippingPackageShippingRate, pickupLocationsCount: number - ) => RadioControlOptionType; + ) => RadioControlOption; packageCount: number; } /** diff --git a/assets/js/blocks/cart-checkout-shared/payment-methods/saved-payment-method-options.tsx b/assets/js/blocks/cart-checkout-shared/payment-methods/saved-payment-method-options.tsx index 1cf07cfc1de..a50974a2e84 100644 --- a/assets/js/blocks/cart-checkout-shared/payment-methods/saved-payment-method-options.tsx +++ b/assets/js/blocks/cart-checkout-shared/payment-methods/saved-payment-method-options.tsx @@ -4,10 +4,7 @@ import { useMemo, cloneElement } from '@wordpress/element'; import { __, sprintf } from '@wordpress/i18n'; import { noticeContexts } from '@woocommerce/base-context'; -import { - RadioControl, - type RadioControlOptionType, -} from '@woocommerce/blocks-components'; +import { RadioControl } from '@woocommerce/blocks-components'; import { usePaymentMethodInterface, useStoreEvents, @@ -22,6 +19,7 @@ import { isNull } from '@woocommerce/types'; */ import { getCanMakePaymentArg } from '../../../data/payment/utils/check-payment-methods'; import { CustomerPaymentMethodConfiguration } from '../../../data/payment/types'; +import type { RadioControlOption } from '../../../../../packages/components/radio-control/types'; /** * Returns the option object for a cc or echeck saved payment method token. @@ -89,7 +87,7 @@ const SavedPaymentMethodOptions = () => { const { removeNotice } = useDispatch( 'core/notices' ); const { dispatchCheckoutEvent } = useStoreEvents(); - const options = useMemo< RadioControlOptionType[] >( () => { + const options = useMemo< RadioControlOption[] >( () => { const types = Object.keys( savedPaymentMethods ); // Get individual payment methods from saved payment methods and put them into a unique array. diff --git a/assets/js/blocks/cart-checkout-shared/payment-methods/test/payment-methods.js b/assets/js/blocks/cart-checkout-shared/payment-methods/test/payment-methods.js index e426f7f20cc..aac922b2e25 100644 --- a/assets/js/blocks/cart-checkout-shared/payment-methods/test/payment-methods.js +++ b/assets/js/blocks/cart-checkout-shared/payment-methods/test/payment-methods.js @@ -27,19 +27,24 @@ jest.mock( '../saved-payment-method-options', () => ( { onChange } ) => { ); } ); -jest.mock( - '@woocommerce/base-components/radio-control-accordion', - () => - ( { onChange } ) => - ( - <> - Payment method options - - - ) -); +jest.mock( '@woocommerce/blocks-components', () => { + const originalModule = jest.requireActual( + '@woocommerce/blocks-components' + ); + + return { + __esModule: true, + ...originalModule, + RadioControlAccordion: ( { onChange } ) => ( + <> + Payment method options + + + ), + }; +} ); const originalSelect = jest.requireActual( '@wordpress/data' ).select; const selectMock = jest diff --git a/assets/js/blocks/checkout/inner-blocks/checkout-pickup-options-block/block.tsx b/assets/js/blocks/checkout/inner-blocks/checkout-pickup-options-block/block.tsx index 2bddc1cc414..dfd0907fc17 100644 --- a/assets/js/blocks/checkout/inner-blocks/checkout-pickup-options-block/block.tsx +++ b/assets/js/blocks/checkout/inner-blocks/checkout-pickup-options-block/block.tsx @@ -14,7 +14,6 @@ import FormattedMonetaryAmount from '@woocommerce/base-components/formatted-mone import { decodeEntities } from '@wordpress/html-entities'; import { getSetting } from '@woocommerce/settings'; import { Icon, mapMarker } from '@wordpress/icons'; -import { type RadioControlOptionType } from '@woocommerce/blocks-components'; import { CartShippingPackageShippingRate } from '@woocommerce/types'; import { isPackageRateCollectable, @@ -27,6 +26,7 @@ import { LocalPickupSelect } from '@woocommerce/base-components/cart-checkout/lo * Internal dependencies */ import ShippingRatesControlPackage from '../../../../base/components/cart-checkout/shipping-rates-control-package'; +import type { RadioControlOption } from '../../../../../../packages/components/radio-control/types'; const getPickupLocation = ( option: CartShippingPackageShippingRate @@ -67,7 +67,7 @@ const getPickupDetails = ( const renderPickupLocation = ( option: CartShippingPackageShippingRate, packageCount: number -): RadioControlOptionType => { +): RadioControlOption => { const priceWithTaxes = getSetting( 'displayCartPricesIncludingTax', false ) ? parseInt( option.price, 10 ) + parseInt( option.taxes, 10 ) : option.price; diff --git a/packages/checkout/components/order-local-pickup-packages/index.tsx b/packages/checkout/components/order-local-pickup-packages/index.tsx index 37455e5a720..9f7b3eba123 100644 --- a/packages/checkout/components/order-local-pickup-packages/index.tsx +++ b/packages/checkout/components/order-local-pickup-packages/index.tsx @@ -7,12 +7,12 @@ import { CartShippingPackageShippingRate, } from '@woocommerce/type-defs/cart'; import { Component } from '@wordpress/element'; -import { type RadioControlOptionType } from '@woocommerce/blocks-components'; /** * Internal dependencies */ import { createSlotFill } from '../../slot'; +import type { RadioControlOption } from '../../../../packages/components/radio-control/types'; const slotName = '__experimentalOrderLocalPickupPackages'; const { @@ -28,7 +28,7 @@ interface ExperimentalOrderLocalPickupPackagesProps { renderPickupLocation: ( option: CartShippingPackageShippingRate, packageCount: number - ) => RadioControlOptionType; + ) => RadioControlOption; } const Slot = ( { extensions, diff --git a/packages/components/index.ts b/packages/components/index.ts index 1a67e8514a2..15cdbbe2a33 100644 --- a/packages/components/index.ts +++ b/packages/components/index.ts @@ -3,7 +3,6 @@ export { default as RadioControl, RadioControlOption, RadioControlOptionLayout, - type RadioControlOptionType, } from './radio-control'; export { default as RadioControlAccordion } from './radio-control-accordion'; From f218721a6bd0660a9a087cc573f0133d0640aa12 Mon Sep 17 00:00:00 2001 From: Alex Florisca Date: Wed, 18 Oct 2023 16:01:14 +0100 Subject: [PATCH 6/9] Remove type export --- packages/components/radio-control/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/components/radio-control/index.tsx b/packages/components/radio-control/index.tsx index 643e2472b02..1b0f18952d0 100644 --- a/packages/components/radio-control/index.tsx +++ b/packages/components/radio-control/index.tsx @@ -53,5 +53,4 @@ const RadioControl = ( { export default RadioControl; export { default as RadioControlOption } from './option'; -export { type RadioControlOption as RadioControlOptionType } from './types'; export { default as RadioControlOptionLayout } from './option-layout'; From 0e6ff91fba5a2b4efbb20dfe65aab3bf674f4068 Mon Sep 17 00:00:00 2001 From: Alex Florisca Date: Wed, 18 Oct 2023 16:27:19 +0100 Subject: [PATCH 7/9] Fix ts errors --- assets/js/base/components/index.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/assets/js/base/components/index.ts b/assets/js/base/components/index.ts index 08fa8fa252c..533a464d895 100644 --- a/assets/js/base/components/index.ts +++ b/assets/js/base/components/index.ts @@ -10,7 +10,6 @@ export * from './filter-reset-button'; export * from './filter-submit-button'; export * from './form'; export * from './form-token-field'; -export * from './formatted-monetary-amount'; export * from './label'; export * from './load-more-button'; export * from './loading-mask'; @@ -23,7 +22,6 @@ export * from './product-name'; export * from './product-price'; export * from './product-rating'; export * from './quantity-selector'; -export * from './radio-control-accordion'; export * from './read-more'; export * from './reviews'; export * from './sidebar-layout'; From 2c93a407be56c666230a992fab6bf3404dbe9192 Mon Sep 17 00:00:00 2001 From: Thomas Roberts Date: Mon, 23 Oct 2023 12:17:28 +0100 Subject: [PATCH 8/9] Rename RadioControlOption type to RadioControlOptionType --- .../cart-checkout/local-pickup-select/index.tsx | 11 +++++------ .../payment-methods/saved-payment-method-options.tsx | 10 ++++++---- .../checkout-pickup-options-block/block.tsx | 8 +++++--- packages/components/index.ts | 1 + 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/assets/js/base/components/cart-checkout/local-pickup-select/index.tsx b/assets/js/base/components/cart-checkout/local-pickup-select/index.tsx index 2404e4f5be4..696db0fefae 100644 --- a/assets/js/base/components/cart-checkout/local-pickup-select/index.tsx +++ b/assets/js/base/components/cart-checkout/local-pickup-select/index.tsx @@ -1,12 +1,11 @@ /** * External dependencies */ -import { RadioControl } from '@woocommerce/blocks-components'; +import { + RadioControl, + RadioControlOptionType, +} from '@woocommerce/blocks-components'; import { CartShippingPackageShippingRate } from '@woocommerce/types'; -/** - * Internal dependencies - */ -import type { RadioControlOption } from '../../../../../../packages/components/radio-control/types'; interface LocalPickupSelectProps { title?: string | undefined; @@ -17,7 +16,7 @@ interface LocalPickupSelectProps { renderPickupLocation: ( location: CartShippingPackageShippingRate, pickupLocationsCount: number - ) => RadioControlOption; + ) => RadioControlOptionType; packageCount: number; } /** diff --git a/assets/js/blocks/cart-checkout-shared/payment-methods/saved-payment-method-options.tsx b/assets/js/blocks/cart-checkout-shared/payment-methods/saved-payment-method-options.tsx index a50974a2e84..c6a11c25aec 100644 --- a/assets/js/blocks/cart-checkout-shared/payment-methods/saved-payment-method-options.tsx +++ b/assets/js/blocks/cart-checkout-shared/payment-methods/saved-payment-method-options.tsx @@ -4,7 +4,10 @@ import { useMemo, cloneElement } from '@wordpress/element'; import { __, sprintf } from '@wordpress/i18n'; import { noticeContexts } from '@woocommerce/base-context'; -import { RadioControl } from '@woocommerce/blocks-components'; +import { + RadioControl, + RadioControlOptionType, +} from '@woocommerce/blocks-components'; import { usePaymentMethodInterface, useStoreEvents, @@ -19,7 +22,6 @@ import { isNull } from '@woocommerce/types'; */ import { getCanMakePaymentArg } from '../../../data/payment/utils/check-payment-methods'; import { CustomerPaymentMethodConfiguration } from '../../../data/payment/types'; -import type { RadioControlOption } from '../../../../../packages/components/radio-control/types'; /** * Returns the option object for a cc or echeck saved payment method token. @@ -87,7 +89,7 @@ const SavedPaymentMethodOptions = () => { const { removeNotice } = useDispatch( 'core/notices' ); const { dispatchCheckoutEvent } = useStoreEvents(); - const options = useMemo< RadioControlOption[] >( () => { + const options = useMemo< RadioControlOptionType[] >( () => { const types = Object.keys( savedPaymentMethods ); // Get individual payment methods from saved payment methods and put them into a unique array. @@ -145,7 +147,7 @@ const SavedPaymentMethodOptions = () => { } ); return mappedOptions.filter( ( option ) => typeof option !== 'undefined' - ) as RadioControlOption[]; + ) as RadioControlOptionType[]; }, [ savedPaymentMethods, paymentMethods, diff --git a/assets/js/blocks/checkout/inner-blocks/checkout-pickup-options-block/block.tsx b/assets/js/blocks/checkout/inner-blocks/checkout-pickup-options-block/block.tsx index 454a4b4b7af..68b3f8a0105 100644 --- a/assets/js/blocks/checkout/inner-blocks/checkout-pickup-options-block/block.tsx +++ b/assets/js/blocks/checkout/inner-blocks/checkout-pickup-options-block/block.tsx @@ -10,7 +10,10 @@ import { } from '@wordpress/element'; import { useShippingData, useStoreCart } from '@woocommerce/base-context/hooks'; import { getCurrencyFromPriceResponse } from '@woocommerce/price-format'; -import { FormattedMonetaryAmount } from '@woocommerce/blocks-components'; +import { + FormattedMonetaryAmount, + RadioControlOptionType, +} from '@woocommerce/blocks-components'; import { decodeEntities } from '@wordpress/html-entities'; import { getSetting } from '@woocommerce/settings'; import { Icon, mapMarker } from '@wordpress/icons'; @@ -26,7 +29,6 @@ import { LocalPickupSelect } from '@woocommerce/base-components/cart-checkout/lo * Internal dependencies */ import ShippingRatesControlPackage from '../../../../base/components/cart-checkout/shipping-rates-control-package'; -import type { RadioControlOption } from '../../../../../../packages/components/radio-control/types'; const getPickupLocation = ( option: CartShippingPackageShippingRate @@ -67,7 +69,7 @@ const getPickupDetails = ( const renderPickupLocation = ( option: CartShippingPackageShippingRate, packageCount: number -): RadioControlOption => { +): RadioControlOptionType => { const priceWithTaxes = getSetting( 'displayCartPricesIncludingTax', false ) ? parseInt( option.price, 10 ) + parseInt( option.taxes, 10 ) : option.price; diff --git a/packages/components/index.ts b/packages/components/index.ts index 255e6d1f6b6..83a10c64f8c 100644 --- a/packages/components/index.ts +++ b/packages/components/index.ts @@ -4,6 +4,7 @@ export { RadioControlOption, RadioControlOptionLayout, } from './radio-control'; +export type { RadioControlOption as RadioControlOptionType } from './radio-control/types'; export { default as FormattedMonetaryAmount } from './formatted-monetary-amount'; export { Chip, RemovableChip } from './chip'; export { default as RadioControlAccordion } from './radio-control-accordion'; From 686c36c1631136dc1737c7a3a79d762f38cd2581 Mon Sep 17 00:00:00 2001 From: Alex Florisca Date: Mon, 23 Oct 2023 15:29:29 +0100 Subject: [PATCH 9/9] Delete index.js --- packages/components/index.js | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 packages/components/index.js diff --git a/packages/components/index.js b/packages/components/index.js deleted file mode 100644 index 43f4a9ecf1f..00000000000 --- a/packages/components/index.js +++ /dev/null @@ -1,5 +0,0 @@ -export { default as CheckboxList } from './checkbox-list'; -export { default as Label } from './label'; -export { default as FormattedMonetaryAmount } from './formatted-monetary-amount'; -export { Chip, RemovableChip } from './chip'; -export { default as Spinner } from './spinner';