-
Notifications
You must be signed in to change notification settings - Fork 219
Move RadioControl
and RadioControlAccordion
components to components package
#11312
Conversation
The release ZIP for this PR is accessible via:
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
🎉 🎉 This PR does not introduce new TS errors. |
Size Change: -6.88 kB (0%) Total Size: 1.53 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, so the changes look good and I know you struggled with the types yesterday, however what do you think of this? I have provided the patch file for my changes, but I can just go ahead and commit to your branch, let me know!
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 2404e4f5b..696db0fef 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 a50974a2e..c6a11c25a 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 454a4b4b7..68b3f8a01 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 255e6d1f6..83a10c64f 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';
@@ -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' ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice spot!
Thanks for the review @opr. I can't quite figure out from that diff what changes you made from what we had before? We seem to still be exporting type which didn't work before? |
@alexflorisca I can't remember exactly what we had before, but I think the main difference is that I renamed the type to |
I definitely renamed it to
|
@alexflorisca committed in 2c93a40 |
Nice one. I've rebased trunk, once the CI passes it should be good to go, just need a 👍 from you. |
What
This PR is based on #11214 (update/checkbox-component)
Move
RadioControl
andRadioControlAccordion
components to components package and update the places it is imported:Why
Testing Instructions
Please consider any edge cases this change may have, and also other areas of the product this may impact.
WooCommerce Visibility
Required:
Checklist
Required:
[type]
label or a[skip-changelog]
label.Conditional:
[skip-changelog]
label is not present).Changelog