Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Move RadioControland RadioControlAccordion components to components package #11312

Merged
merged 11 commits into from
Oct 23, 2023
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* External dependencies
*/
import { RadioControlOption } from '@woocommerce/base-components/radio-control/types';
import { RadioControl } from '@woocommerce/blocks-components';
import { CartShippingPackageShippingRate } from '@woocommerce/types';
/**
* Internal dependencies
*/
import RadioControl from '../../radio-control';
import type { RadioControlOption } from '../../../../../../packages/components/radio-control/types';

interface LocalPickupSelectProps {
title?: string | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
3 changes: 0 additions & 3 deletions assets/js/base/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -23,8 +22,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';
export * from './sidebar-layout';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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 } from '@woocommerce/blocks-components';
import {
usePaymentMethodInterface,
useStoreEvents,
Expand All @@ -13,13 +13,13 @@ 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
*/
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,24 @@ jest.mock( '../saved-payment-method-options', () => ( { onChange } ) => {
);
} );

jest.mock(
'@woocommerce/base-components/radio-control-accordion',
() =>
( { onChange } ) =>
(
<>
<span>Payment method options</span>
<button onClick={ () => onChange( 'credit-card' ) }>
Select new payment
</button>
</>
)
);
jest.mock( '@woocommerce/blocks-components', () => {
const originalModule = jest.requireActual(
'@woocommerce/blocks-components'
);

return {
__esModule: true,
...originalModule,
RadioControlAccordion: ( { onChange } ) => (
<>
<span>Payment method options</span>
<button onClick={ () => onChange( 'credit-card' ) }>
Select new payment
</button>
</>
),
};
} );

const originalSelect = jest.requireActual( '@wordpress/data' ).select;
const selectMock = jest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { FormattedMonetaryAmount } from '@woocommerce/blocks-components';
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 { CartShippingPackageShippingRate } from '@woocommerce/types';
import {
isPackageRateCollectable,
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions bin/webpack-entries.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice spot!


// Shared blocks code
'wc-blocks': './assets/js/index.js',
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import {
CartShippingPackageShippingRate,
} from '@woocommerce/type-defs/cart';
import { Component } from '@wordpress/element';
import { RadioControlOption } from '@woocommerce/base-components/radio-control/types';

/**
* Internal dependencies
*/
import { createSlotFill } from '../../slot';
import type { RadioControlOption } from '../../../../packages/components/radio-control/types';

const slotName = '__experimentalOrderLocalPickupPackages';
const {
Expand Down
6 changes: 6 additions & 0 deletions packages/components/index.js → packages/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
export { default as CheckboxList } from './checkbox-list';
export {
default as RadioControl,
RadioControlOption,
RadioControlOptionLayout,
} from './radio-control';
export { default as FormattedMonetaryAmount } from './formatted-monetary-amount';
export { Chip, RemovableChip } from './chip';
export { default as RadioControlAccordion } from './radio-control-accordion';
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { withInstanceId } from '@wordpress/compose';
/**
* Internal dependencies
*/
import RadioControlOption from '../radio-control/option';
import { RadioControlOption } from '../radio-control';

interface RadioControlAccordionProps {
className?: string;
Expand Down
Loading