From 4b75668ec7eb62f065c6a488cd942a666e26204f Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Mon, 21 Mar 2022 15:33:25 +0000 Subject: [PATCH] Experiment- external block context --- .../add-to-cart/shared/add-to-cart-button.js | 4 ++-- .../blocks/product-elements/button/block.js | 5 +--- .../blocks/product-elements/image/block.js | 2 +- .../blocks/product-elements/title/block.tsx | 2 +- .../cart-checkout/address-form/test/index.js | 6 +++-- .../order-summary/order-summary-item.tsx | 2 +- .../place-order-button/index.tsx | 2 +- .../shipping-calculator/index.tsx | 2 +- .../shipping-rates-control-package/index.tsx | 2 +- .../totals/footer-item/index.tsx | 2 +- .../cart-checkout/totals/shipping/index.tsx | 2 +- .../components/product-list/product-list.tsx | 2 +- .../context/hooks/test/use-store-notices.js | 2 +- .../hooks/test/use-store-snackbar-notices.js | 2 +- .../hooks/use-store-snackbar-notices.js | 6 ++++- .../store-snackbar-notices/context.js | 2 +- .../providers/store-snackbar-notices/index.ts | 1 + .../active-attribute-filters.js | 5 +--- assets/js/blocks/active-filters/block.js | 2 +- assets/js/blocks/attribute-filter/block.js | 2 +- .../order-summary-cart-items/block.tsx | 2 +- .../order-summary-coupon-form/block.tsx | 2 +- .../order-summary-discount/block.tsx | 4 ++-- .../inner-blocks/order-summary-fee/block.tsx | 2 +- .../order-summary-shipping/block.tsx | 3 +-- .../order-summary-subtotal/block.tsx | 2 +- .../order-summary-taxes/block.tsx | 2 +- .../frontend.tsx | 2 +- .../frontend.tsx | 2 +- .../mini-cart-footer-block/block.tsx | 4 ++-- .../mini-cart-products-table-block/block.tsx | 2 +- .../mini-cart-title-block/block.tsx | 2 +- .../blocks/cart-checkout/mini-cart/block.tsx | 2 +- .../express-payment-methods.js | 2 +- .../express-payment/cart-express-payment.js | 2 -- .../checkout-express-payment.js | 2 -- .../payment-methods/payment-method-options.js | 4 +--- .../payment-methods/payment-methods.js | 6 +++-- .../saved-payment-method-options.js | 4 ++-- assets/js/blocks/cart/block.js | 14 +++++------ .../cart-line-item-row.tsx | 2 +- .../block.tsx | 2 +- .../cart-express-payment-block/block.tsx | 2 +- .../cart-express-payment-block/edit.tsx | 2 +- .../cart-line-items-block/block.tsx | 2 +- .../inner-blocks/cart-order-summary/edit.tsx | 2 +- .../cart-order-summary/frontend.tsx | 2 +- .../cart-order-summary/slotfills.tsx | 2 +- .../empty-cart-block/frontend.tsx | 2 +- .../filled-cart-block/frontend.tsx | 2 +- assets/js/blocks/checkout/block.tsx | 5 ++-- assets/js/blocks/checkout/frontend.tsx | 4 ++-- .../checkout-billing-address-block/edit.tsx | 2 +- .../frontend.tsx | 6 +++-- .../checkout-express-payment-block/block.tsx | 2 +- .../checkout-express-payment-block/edit.tsx | 2 +- .../checkout-order-note-block/block.tsx | 3 +-- .../checkout-order-summary-block/edit.tsx | 2 +- .../checkout-order-summary-block/frontend.tsx | 2 +- .../slotfills.tsx | 2 +- .../test/block.js | 6 ++--- .../checkout-payment-block/frontend.tsx | 7 +++--- .../frontend.tsx | 6 +++-- .../checkout-shipping-methods-block/block.tsx | 3 +-- .../frontend.tsx | 6 +++-- .../checkout-terms-block/frontend.tsx | 2 +- assets/js/blocks/price-filter/block.js | 2 +- assets/js/blocks/single-product/block.js | 6 +++-- assets/js/blocks/stock-filter/block.js | 2 +- assets/js/blocks/stock-filter/test/block.js | 4 ++-- bin/webpack-entries.js | 1 + bin/webpack-helpers.js | 6 ++--- docs/contributors/js-build-system.md | 24 ++++++------------- .../extensibility/checkout-flow-and-events.md | 8 +++---- src/AssetsController.php | 5 ++-- tests/js/jest.config.json | 2 +- tsconfig.base.json | 6 ----- 77 files changed, 127 insertions(+), 139 deletions(-) diff --git a/assets/js/atomic/blocks/product-elements/add-to-cart/shared/add-to-cart-button.js b/assets/js/atomic/blocks/product-elements/add-to-cart/shared/add-to-cart-button.js index c7ab4f065c6..f23e28003f1 100644 --- a/assets/js/atomic/blocks/product-elements/add-to-cart/shared/add-to-cart-button.js +++ b/assets/js/atomic/blocks/product-elements/add-to-cart/shared/add-to-cart-button.js @@ -5,11 +5,11 @@ import { __, _n, sprintf } from '@wordpress/i18n'; import Button from '@woocommerce/base-components/button'; import { Icon, check } from '@wordpress/icons'; import { useState, useEffect } from '@wordpress/element'; -import { useAddToCartFormContext } from '@woocommerce/base-context'; import { useStoreEvents, useStoreAddToCart, -} from '@woocommerce/base-context/hooks'; + useAddToCartFormContext, +} from '@woocommerce/base-context'; import { useInnerBlockLayoutContext } from '@woocommerce/shared-context'; /** diff --git a/assets/js/atomic/blocks/product-elements/button/block.js b/assets/js/atomic/blocks/product-elements/button/block.js index 9b04b616f04..c8945e2b1db 100644 --- a/assets/js/atomic/blocks/product-elements/button/block.js +++ b/assets/js/atomic/blocks/product-elements/button/block.js @@ -4,10 +4,7 @@ import PropTypes from 'prop-types'; import classnames from 'classnames'; import { __, _n, sprintf } from '@wordpress/i18n'; -import { - useStoreEvents, - useStoreAddToCart, -} from '@woocommerce/base-context/hooks'; +import { useStoreEvents, useStoreAddToCart } from '@woocommerce/base-context'; import { decodeEntities } from '@wordpress/html-entities'; import { CART_URL } from '@woocommerce/block-settings'; import { getSetting } from '@woocommerce/settings'; diff --git a/assets/js/atomic/blocks/product-elements/image/block.js b/assets/js/atomic/blocks/product-elements/image/block.js index 9855ab3d2e9..0adc3f8998b 100644 --- a/assets/js/atomic/blocks/product-elements/image/block.js +++ b/assets/js/atomic/blocks/product-elements/image/block.js @@ -11,7 +11,7 @@ import { useProductDataContext, } from '@woocommerce/shared-context'; import { withProductDataContext } from '@woocommerce/shared-hocs'; -import { useStoreEvents } from '@woocommerce/base-context/hooks'; +import { useStoreEvents } from '@woocommerce/base-context'; /** * Internal dependencies diff --git a/assets/js/atomic/blocks/product-elements/title/block.tsx b/assets/js/atomic/blocks/product-elements/title/block.tsx index c92d5f5cd4f..e40cd92cfe0 100644 --- a/assets/js/atomic/blocks/product-elements/title/block.tsx +++ b/assets/js/atomic/blocks/product-elements/title/block.tsx @@ -10,7 +10,7 @@ import { import { isFeaturePluginBuild } from '@woocommerce/block-settings'; import { withProductDataContext } from '@woocommerce/shared-hocs'; import ProductName from '@woocommerce/base-components/product-name'; -import { useStoreEvents } from '@woocommerce/base-context/hooks'; +import { useStoreEvents } from '@woocommerce/base-context'; /** * Internal dependencies diff --git a/assets/js/base/components/cart-checkout/address-form/test/index.js b/assets/js/base/components/cart-checkout/address-form/test/index.js index 200f190db75..a83e67d7af7 100644 --- a/assets/js/base/components/cart-checkout/address-form/test/index.js +++ b/assets/js/base/components/cart-checkout/address-form/test/index.js @@ -3,8 +3,10 @@ */ import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import { CheckoutProvider } from '@woocommerce/base-context'; -import { useCheckoutAddress } from '@woocommerce/base-context/hooks'; +import { + CheckoutProvider, + useCheckoutAddress, +} from '@woocommerce/base-context'; /** * Internal dependencies diff --git a/assets/js/base/components/cart-checkout/order-summary/order-summary-item.tsx b/assets/js/base/components/cart-checkout/order-summary/order-summary-item.tsx index c11a16eb2a4..78fe52dbc80 100644 --- a/assets/js/base/components/cart-checkout/order-summary/order-summary-item.tsx +++ b/assets/js/base/components/cart-checkout/order-summary/order-summary-item.tsx @@ -17,7 +17,7 @@ import { import Dinero from 'dinero.js'; import { getSetting } from '@woocommerce/settings'; import { useMemo } from '@wordpress/element'; -import { useStoreCart } from '@woocommerce/base-context/hooks'; +import { useStoreCart } from '@woocommerce/base-context'; import { CartItem, isString } from '@woocommerce/types'; /** diff --git a/assets/js/base/components/cart-checkout/place-order-button/index.tsx b/assets/js/base/components/cart-checkout/place-order-button/index.tsx index d4f3cc7fecd..409d2923614 100644 --- a/assets/js/base/components/cart-checkout/place-order-button/index.tsx +++ b/assets/js/base/components/cart-checkout/place-order-button/index.tsx @@ -1,7 +1,7 @@ /** * External dependencies */ -import { useCheckoutSubmit } from '@woocommerce/base-context/hooks'; +import { useCheckoutSubmit } from '@woocommerce/base-context'; import { Icon, check } from '@wordpress/icons'; import Button from '@woocommerce/base-components/button'; diff --git a/assets/js/base/components/cart-checkout/shipping-calculator/index.tsx b/assets/js/base/components/cart-checkout/shipping-calculator/index.tsx index e159a9eec6b..17556a31143 100644 --- a/assets/js/base/components/cart-checkout/shipping-calculator/index.tsx +++ b/assets/js/base/components/cart-checkout/shipping-calculator/index.tsx @@ -2,7 +2,7 @@ * External dependencies */ import type { EnteredAddress } from '@woocommerce/settings'; -import { useCustomerData } from '@woocommerce/base-context/hooks'; +import { useCustomerData } from '@woocommerce/base-context'; /** * Internal dependencies diff --git a/assets/js/base/components/cart-checkout/shipping-rates-control-package/index.tsx b/assets/js/base/components/cart-checkout/shipping-rates-control-package/index.tsx index 5693c58f61d..d08c0743cd8 100644 --- a/assets/js/base/components/cart-checkout/shipping-rates-control-package/index.tsx +++ b/assets/js/base/components/cart-checkout/shipping-rates-control-package/index.tsx @@ -8,7 +8,7 @@ import type { ReactElement } from 'react'; import type { PackageRateOption } from '@woocommerce/type-defs/shipping'; import { Panel } from '@woocommerce/blocks-checkout'; import Label from '@woocommerce/base-components/label'; -import { useSelectShippingRate } from '@woocommerce/base-context/hooks'; +import { useSelectShippingRate } from '@woocommerce/base-context'; import type { CartShippingPackageShippingRate } from '@woocommerce/type-defs/cart'; /** diff --git a/assets/js/base/components/cart-checkout/totals/footer-item/index.tsx b/assets/js/base/components/cart-checkout/totals/footer-item/index.tsx index ffbd1a9c54f..cedbb2c9e9b 100644 --- a/assets/js/base/components/cart-checkout/totals/footer-item/index.tsx +++ b/assets/js/base/components/cart-checkout/totals/footer-item/index.tsx @@ -9,7 +9,7 @@ import { __experimentalApplyCheckoutFilter, TotalsItem, } from '@woocommerce/blocks-checkout'; -import { useStoreCart } from '@woocommerce/base-context/hooks'; +import { useStoreCart } from '@woocommerce/base-context'; import { getSetting } from '@woocommerce/settings'; import { CartResponseTotals, Currency } from '@woocommerce/types'; import { LooselyMustHave } from '@woocommerce/type-defs/utils'; diff --git a/assets/js/base/components/cart-checkout/totals/shipping/index.tsx b/assets/js/base/components/cart-checkout/totals/shipping/index.tsx index fc98902e64d..11cc629ad43 100644 --- a/assets/js/base/components/cart-checkout/totals/shipping/index.tsx +++ b/assets/js/base/components/cart-checkout/totals/shipping/index.tsx @@ -4,7 +4,7 @@ import classnames from 'classnames'; import { __ } from '@wordpress/i18n'; import { useState } from '@wordpress/element'; -import { useStoreCart } from '@woocommerce/base-context/hooks'; +import { useStoreCart } from '@woocommerce/base-context'; import { TotalsItem } from '@woocommerce/blocks-checkout'; import type { Currency } from '@woocommerce/price-format'; import type { ReactElement } from 'react'; diff --git a/assets/js/base/components/product-list/product-list.tsx b/assets/js/base/components/product-list/product-list.tsx index e8b47a7a0c9..29fce74dbbf 100644 --- a/assets/js/base/components/product-list/product-list.tsx +++ b/assets/js/base/components/product-list/product-list.tsx @@ -12,7 +12,7 @@ import { useStoreProducts, useSynchronizedQueryState, useQueryStateByKey, -} from '@woocommerce/base-context/hooks'; +} from '@woocommerce/base-context'; import withScrollToTop from '@woocommerce/base-hocs/with-scroll-to-top'; import { useInnerBlockLayoutContext } from '@woocommerce/shared-context'; import { speak } from '@wordpress/a11y'; diff --git a/assets/js/base/context/hooks/test/use-store-notices.js b/assets/js/base/context/hooks/test/use-store-notices.js index d9353612da3..7ad7d82c504 100644 --- a/assets/js/base/context/hooks/test/use-store-notices.js +++ b/assets/js/base/context/hooks/test/use-store-notices.js @@ -2,12 +2,12 @@ * External dependencies */ import { render, act } from '@testing-library/react'; -import { StoreNoticesProvider } from '@woocommerce/base-context'; /** * Internal dependencies */ import { useStoreNotices } from '../use-store-notices'; +import { StoreNoticesProvider } from '../../providers/store-notices'; describe( 'useStoreNotices', () => { function setup() { diff --git a/assets/js/base/context/hooks/test/use-store-snackbar-notices.js b/assets/js/base/context/hooks/test/use-store-snackbar-notices.js index 493bde10f9e..ad28d501338 100644 --- a/assets/js/base/context/hooks/test/use-store-snackbar-notices.js +++ b/assets/js/base/context/hooks/test/use-store-snackbar-notices.js @@ -2,12 +2,12 @@ * External dependencies */ import { render, act } from '@testing-library/react'; -import { StoreSnackbarNoticesProvider } from '@woocommerce/base-context/providers'; /** * Internal dependencies */ import { useStoreSnackbarNotices } from '../use-store-snackbar-notices'; +import { StoreSnackbarNoticesProvider } from '../../providers/store-snackbar-notices'; describe( 'useStoreNoticesWithSnackbar', () => { function setup() { diff --git a/assets/js/base/context/hooks/use-store-snackbar-notices.js b/assets/js/base/context/hooks/use-store-snackbar-notices.js index ff07554b774..8fda8adb77d 100644 --- a/assets/js/base/context/hooks/use-store-snackbar-notices.js +++ b/assets/js/base/context/hooks/use-store-snackbar-notices.js @@ -2,7 +2,11 @@ * External dependencies */ import { useMemo, useRef, useEffect } from '@wordpress/element'; -import { useStoreSnackbarNoticesContext } from '@woocommerce/base-context/providers'; + +/** + * Internal dependencies + */ +import { useStoreSnackbarNoticesContext } from '../providers/store-snackbar-notices'; export const useStoreSnackbarNotices = () => { const { diff --git a/assets/js/base/context/providers/store-snackbar-notices/context.js b/assets/js/base/context/providers/store-snackbar-notices/context.js index 3f628f21b56..4e6c8fc292a 100644 --- a/assets/js/base/context/providers/store-snackbar-notices/context.js +++ b/assets/js/base/context/providers/store-snackbar-notices/context.js @@ -9,13 +9,13 @@ import { useState, } from '@wordpress/element'; import { useSelect, useDispatch } from '@wordpress/data'; -import SnackbarNoticesContainer from '@woocommerce/base-context/providers/store-snackbar-notices/components/snackbar-notices-container'; /** * Internal dependencies */ import { useStoreEvents } from '../../hooks/use-store-events'; import { useEditorContext } from '../editor-context'; +import SnackbarNoticesContainer from './components/snackbar-notices-container'; /** * @typedef {import('@woocommerce/type-defs/contexts').NoticeContext} NoticeContext diff --git a/assets/js/base/context/providers/store-snackbar-notices/index.ts b/assets/js/base/context/providers/store-snackbar-notices/index.ts index c38e8e82152..0a1ee45830e 100644 --- a/assets/js/base/context/providers/store-snackbar-notices/index.ts +++ b/assets/js/base/context/providers/store-snackbar-notices/index.ts @@ -1 +1,2 @@ +export * from './components/snackbar-notices-container'; export * from './context'; diff --git a/assets/js/blocks/active-filters/active-attribute-filters.js b/assets/js/blocks/active-filters/active-attribute-filters.js index 3a6ddad3cec..2fe9e5f9c0e 100644 --- a/assets/js/blocks/active-filters/active-attribute-filters.js +++ b/assets/js/blocks/active-filters/active-attribute-filters.js @@ -1,10 +1,7 @@ /** * External dependencies */ -import { - useCollection, - useQueryStateByKey, -} from '@woocommerce/base-context/hooks'; +import { useCollection, useQueryStateByKey } from '@woocommerce/base-context'; import { decodeEntities } from '@wordpress/html-entities'; import { __ } from '@wordpress/i18n'; diff --git a/assets/js/blocks/active-filters/block.js b/assets/js/blocks/active-filters/block.js index 62161897562..d3760f9b649 100644 --- a/assets/js/blocks/active-filters/block.js +++ b/assets/js/blocks/active-filters/block.js @@ -2,7 +2,7 @@ * External dependencies */ import { __ } from '@wordpress/i18n'; -import { useQueryStateByKey } from '@woocommerce/base-context/hooks'; +import { useQueryStateByKey } from '@woocommerce/base-context'; import { getSetting } from '@woocommerce/settings'; import { useMemo } from '@wordpress/element'; import classnames from 'classnames'; diff --git a/assets/js/blocks/attribute-filter/block.js b/assets/js/blocks/attribute-filter/block.js index 4d087d2335c..22e939104fb 100644 --- a/assets/js/blocks/attribute-filter/block.js +++ b/assets/js/blocks/attribute-filter/block.js @@ -9,7 +9,7 @@ import { useQueryStateByKey, useQueryStateByContext, useCollectionData, -} from '@woocommerce/base-context/hooks'; +} from '@woocommerce/base-context'; import { useCallback, useEffect, useState, useMemo } from '@wordpress/element'; import CheckboxList from '@woocommerce/base-components/checkbox-list'; import DropdownSelector from '@woocommerce/base-components/dropdown-selector'; diff --git a/assets/js/blocks/cart-checkout/inner-blocks/order-summary-cart-items/block.tsx b/assets/js/blocks/cart-checkout/inner-blocks/order-summary-cart-items/block.tsx index f7d4dc15b5d..68b906f5b50 100644 --- a/assets/js/blocks/cart-checkout/inner-blocks/order-summary-cart-items/block.tsx +++ b/assets/js/blocks/cart-checkout/inner-blocks/order-summary-cart-items/block.tsx @@ -2,7 +2,7 @@ * External dependencies */ import { OrderSummary } from '@woocommerce/base-components/cart-checkout'; -import { useStoreCart } from '@woocommerce/base-context/hooks'; +import { useStoreCart } from '@woocommerce/base-context'; const Block = ( { className }: { className: string } ): JSX.Element => { const { cartItems } = useStoreCart(); diff --git a/assets/js/blocks/cart-checkout/inner-blocks/order-summary-coupon-form/block.tsx b/assets/js/blocks/cart-checkout/inner-blocks/order-summary-coupon-form/block.tsx index 1579bf61de1..14d07d2fdcc 100644 --- a/assets/js/blocks/cart-checkout/inner-blocks/order-summary-coupon-form/block.tsx +++ b/assets/js/blocks/cart-checkout/inner-blocks/order-summary-coupon-form/block.tsx @@ -2,7 +2,7 @@ * External dependencies */ import { TotalsCoupon } from '@woocommerce/base-components/cart-checkout'; -import { useStoreCartCoupons } from '@woocommerce/base-context/hooks'; +import { useStoreCartCoupons } from '@woocommerce/base-context'; import { getSetting } from '@woocommerce/settings'; const Block = ( { className }: { className: string } ): JSX.Element | null => { diff --git a/assets/js/blocks/cart-checkout/inner-blocks/order-summary-discount/block.tsx b/assets/js/blocks/cart-checkout/inner-blocks/order-summary-discount/block.tsx index 245288458a6..99db906c177 100644 --- a/assets/js/blocks/cart-checkout/inner-blocks/order-summary-discount/block.tsx +++ b/assets/js/blocks/cart-checkout/inner-blocks/order-summary-discount/block.tsx @@ -6,9 +6,9 @@ import { getCurrencyFromPriceResponse } from '@woocommerce/price-format'; import { useStoreCartCoupons, useStoreCart, -} from '@woocommerce/base-context/hooks'; + useCheckoutContext, +} from '@woocommerce/base-context'; import { ExperimentalDiscountsMeta } from '@woocommerce/blocks-checkout'; -import { useCheckoutContext } from '@woocommerce/base-context'; const DiscountSlotFill = (): JSX.Element => { const { isCart } = useCheckoutContext(); diff --git a/assets/js/blocks/cart-checkout/inner-blocks/order-summary-fee/block.tsx b/assets/js/blocks/cart-checkout/inner-blocks/order-summary-fee/block.tsx index 0b8b68197a1..eb757f7fc11 100644 --- a/assets/js/blocks/cart-checkout/inner-blocks/order-summary-fee/block.tsx +++ b/assets/js/blocks/cart-checkout/inner-blocks/order-summary-fee/block.tsx @@ -3,7 +3,7 @@ */ import { TotalsFees } from '@woocommerce/blocks-checkout'; import { getCurrencyFromPriceResponse } from '@woocommerce/price-format'; -import { useStoreCart } from '@woocommerce/base-context/hooks'; +import { useStoreCart } from '@woocommerce/base-context'; const Block = ( { className }: { className: string } ): JSX.Element => { const { cartFees, cartTotals } = useStoreCart(); diff --git a/assets/js/blocks/cart-checkout/inner-blocks/order-summary-shipping/block.tsx b/assets/js/blocks/cart-checkout/inner-blocks/order-summary-shipping/block.tsx index 4485ed31b0d..ac899434a4c 100644 --- a/assets/js/blocks/cart-checkout/inner-blocks/order-summary-shipping/block.tsx +++ b/assets/js/blocks/cart-checkout/inner-blocks/order-summary-shipping/block.tsx @@ -3,8 +3,7 @@ */ import { TotalsShipping } from '@woocommerce/base-components/cart-checkout'; import { getCurrencyFromPriceResponse } from '@woocommerce/price-format'; -import { useStoreCart } from '@woocommerce/base-context/hooks'; -import { useCheckoutContext } from '@woocommerce/base-context'; +import { useStoreCart, useCheckoutContext } from '@woocommerce/base-context'; const Block = ( { className, diff --git a/assets/js/blocks/cart-checkout/inner-blocks/order-summary-subtotal/block.tsx b/assets/js/blocks/cart-checkout/inner-blocks/order-summary-subtotal/block.tsx index bc4d50449f5..99ff79909ee 100644 --- a/assets/js/blocks/cart-checkout/inner-blocks/order-summary-subtotal/block.tsx +++ b/assets/js/blocks/cart-checkout/inner-blocks/order-summary-subtotal/block.tsx @@ -3,7 +3,7 @@ */ import { Subtotal } from '@woocommerce/blocks-checkout'; import { getCurrencyFromPriceResponse } from '@woocommerce/price-format'; -import { useStoreCart } from '@woocommerce/base-context/hooks'; +import { useStoreCart } from '@woocommerce/base-context'; const Block = ( { className }: { className: string } ): JSX.Element => { const { cartTotals } = useStoreCart(); diff --git a/assets/js/blocks/cart-checkout/inner-blocks/order-summary-taxes/block.tsx b/assets/js/blocks/cart-checkout/inner-blocks/order-summary-taxes/block.tsx index ef3917d9b82..ab8c4b71da7 100644 --- a/assets/js/blocks/cart-checkout/inner-blocks/order-summary-taxes/block.tsx +++ b/assets/js/blocks/cart-checkout/inner-blocks/order-summary-taxes/block.tsx @@ -3,7 +3,7 @@ */ import { TotalsTaxes } from '@woocommerce/blocks-checkout'; import { getCurrencyFromPriceResponse } from '@woocommerce/price-format'; -import { useStoreCart } from '@woocommerce/base-context/hooks'; +import { useStoreCart } from '@woocommerce/base-context'; import { getSetting } from '@woocommerce/settings'; const Block = ( { diff --git a/assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/empty-mini-cart-contents-block/frontend.tsx b/assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/empty-mini-cart-contents-block/frontend.tsx index 46e82f36c4e..810c758eed2 100644 --- a/assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/empty-mini-cart-contents-block/frontend.tsx +++ b/assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/empty-mini-cart-contents-block/frontend.tsx @@ -1,7 +1,7 @@ /** * External dependencies */ -import { useStoreCart } from '@woocommerce/base-context/hooks'; +import { useStoreCart } from '@woocommerce/base-context'; import { useEffect, useRef } from 'react'; /** diff --git a/assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/filled-mini-cart-contents-block/frontend.tsx b/assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/filled-mini-cart-contents-block/frontend.tsx index 1b89e66a37b..2113791f273 100644 --- a/assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/filled-mini-cart-contents-block/frontend.tsx +++ b/assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/filled-mini-cart-contents-block/frontend.tsx @@ -1,7 +1,7 @@ /** * External dependencies */ -import { useStoreCart } from '@woocommerce/base-context/hooks'; +import { useStoreCart } from '@woocommerce/base-context'; type FilledMiniCartContentsBlockProps = { children: JSX.Element; diff --git a/assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-footer-block/block.tsx b/assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-footer-block/block.tsx index 850c7ed1299..d539b77dbdf 100644 --- a/assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-footer-block/block.tsx +++ b/assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-footer-block/block.tsx @@ -7,13 +7,13 @@ import { getCurrencyFromPriceResponse } from '@woocommerce/price-format'; import { usePaymentMethods, useStoreCart, -} from '@woocommerce/base-context/hooks'; + PaymentMethodDataProvider, +} from '@woocommerce/base-context'; import PaymentMethodIcons from '@woocommerce/base-components/cart-checkout/payment-method-icons'; import { getIconsFromPaymentMethods } from '@woocommerce/base-utils'; import { getSetting } from '@woocommerce/settings'; import { CART_URL, CHECKOUT_URL } from '@woocommerce/block-settings'; import Button from '@woocommerce/base-components/button'; -import { PaymentMethodDataProvider } from '@woocommerce/base-context'; import classNames from 'classnames'; const PaymentMethodIconsElement = (): JSX.Element => { diff --git a/assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-products-table-block/block.tsx b/assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-products-table-block/block.tsx index 7edd6fef903..1f05c1e36a5 100644 --- a/assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-products-table-block/block.tsx +++ b/assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-products-table-block/block.tsx @@ -1,7 +1,7 @@ /** * External dependencies */ -import { useStoreCart } from '@woocommerce/base-context/hooks'; +import { useStoreCart } from '@woocommerce/base-context'; import classNames from 'classnames'; /** diff --git a/assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-title-block/block.tsx b/assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-title-block/block.tsx index 9c337e29b57..02ca1781b0d 100644 --- a/assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-title-block/block.tsx +++ b/assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-title-block/block.tsx @@ -2,7 +2,7 @@ * External dependencies */ import { sprintf, _n, __ } from '@wordpress/i18n'; -import { useStoreCart } from '@woocommerce/base-context/hooks'; +import { useStoreCart } from '@woocommerce/base-context'; import classNames from 'classnames'; /** diff --git a/assets/js/blocks/cart-checkout/mini-cart/block.tsx b/assets/js/blocks/cart-checkout/mini-cart/block.tsx index 499455ace7f..a287e19e9ff 100644 --- a/assets/js/blocks/cart-checkout/mini-cart/block.tsx +++ b/assets/js/blocks/cart-checkout/mini-cart/block.tsx @@ -3,7 +3,7 @@ */ import { renderParentBlock } from '@woocommerce/atomic-utils'; import Drawer from '@woocommerce/base-components/drawer'; -import { useStoreCart } from '@woocommerce/base-context/hooks'; +import { useStoreCart } from '@woocommerce/base-context'; import { translateJQueryEventToNative } from '@woocommerce/base-utils'; import { getRegisteredBlockComponents } from '@woocommerce/blocks-registry'; import { diff --git a/assets/js/blocks/cart-checkout/payment-methods/express-payment-methods.js b/assets/js/blocks/cart-checkout/payment-methods/express-payment-methods.js index c173cc399bd..a34c0dd02d8 100644 --- a/assets/js/blocks/cart-checkout/payment-methods/express-payment-methods.js +++ b/assets/js/blocks/cart-checkout/payment-methods/express-payment-methods.js @@ -5,7 +5,7 @@ import { __ } from '@wordpress/i18n'; import { useExpressPaymentMethods, usePaymentMethodInterface, -} from '@woocommerce/base-context/hooks'; +} from '@woocommerce/base-context'; import { cloneElement, isValidElement, diff --git a/assets/js/blocks/cart-checkout/payment-methods/express-payment/cart-express-payment.js b/assets/js/blocks/cart-checkout/payment-methods/express-payment/cart-express-payment.js index e7fb6648542..b5f5b644b81 100644 --- a/assets/js/blocks/cart-checkout/payment-methods/express-payment/cart-express-payment.js +++ b/assets/js/blocks/cart-checkout/payment-methods/express-payment/cart-express-payment.js @@ -5,8 +5,6 @@ import { __ } from '@wordpress/i18n'; import { useEmitResponse, useExpressPaymentMethods, -} from '@woocommerce/base-context/hooks'; -import { StoreNoticesProvider, useCheckoutContext, usePaymentMethodDataContext, diff --git a/assets/js/blocks/cart-checkout/payment-methods/express-payment/checkout-express-payment.js b/assets/js/blocks/cart-checkout/payment-methods/express-payment/checkout-express-payment.js index 3a2748f1055..2776ee4ceef 100644 --- a/assets/js/blocks/cart-checkout/payment-methods/express-payment/checkout-express-payment.js +++ b/assets/js/blocks/cart-checkout/payment-methods/express-payment/checkout-express-payment.js @@ -5,8 +5,6 @@ import { __ } from '@wordpress/i18n'; import { useEmitResponse, useExpressPaymentMethods, -} from '@woocommerce/base-context/hooks'; -import { StoreNoticesProvider, useCheckoutContext, usePaymentMethodDataContext, diff --git a/assets/js/blocks/cart-checkout/payment-methods/payment-method-options.js b/assets/js/blocks/cart-checkout/payment-methods/payment-method-options.js index f63808fdfc4..2f1539b0956 100644 --- a/assets/js/blocks/cart-checkout/payment-methods/payment-method-options.js +++ b/assets/js/blocks/cart-checkout/payment-methods/payment-method-options.js @@ -7,12 +7,10 @@ import { useEmitResponse, useStoreNotices, useStoreEvents, -} from '@woocommerce/base-context/hooks'; -import { cloneElement, useCallback } from '@wordpress/element'; -import { useEditorContext, usePaymentMethodDataContext, } from '@woocommerce/base-context'; +import { cloneElement, useCallback } from '@wordpress/element'; import classNames from 'classnames'; import RadioControlAccordion from '@woocommerce/base-components/radio-control-accordion'; diff --git a/assets/js/blocks/cart-checkout/payment-methods/payment-methods.js b/assets/js/blocks/cart-checkout/payment-methods/payment-methods.js index 24b275040e3..f9fc7449cf4 100644 --- a/assets/js/blocks/cart-checkout/payment-methods/payment-methods.js +++ b/assets/js/blocks/cart-checkout/payment-methods/payment-methods.js @@ -1,10 +1,12 @@ /** * External dependencies */ -import { usePaymentMethods } from '@woocommerce/base-context/hooks'; +import { + usePaymentMethods, + usePaymentMethodDataContext, +} from '@woocommerce/base-context'; import { __ } from '@wordpress/i18n'; import Label from '@woocommerce/base-components/label'; -import { usePaymentMethodDataContext } from '@woocommerce/base-context'; /** * Internal dependencies diff --git a/assets/js/blocks/cart-checkout/payment-methods/saved-payment-method-options.js b/assets/js/blocks/cart-checkout/payment-methods/saved-payment-method-options.js index 8ebff3e3cca..91bb20f71ed 100644 --- a/assets/js/blocks/cart-checkout/payment-methods/saved-payment-method-options.js +++ b/assets/js/blocks/cart-checkout/payment-methods/saved-payment-method-options.js @@ -3,7 +3,6 @@ */ import { useMemo, cloneElement } from '@wordpress/element'; import { __, sprintf } from '@wordpress/i18n'; -import { usePaymentMethodDataContext } from '@woocommerce/base-context'; import RadioControl from '@woocommerce/base-components/radio-control'; import { usePaymentMethodInterface, @@ -11,7 +10,8 @@ import { useStoreNotices, useStoreEvents, useEmitResponse, -} from '@woocommerce/base-context/hooks'; + usePaymentMethodDataContext, +} from '@woocommerce/base-context'; /** * @typedef {import('@woocommerce/type-defs/contexts').CustomerPaymentMethod} CustomerPaymentMethod diff --git a/assets/js/blocks/cart/block.js b/assets/js/blocks/cart/block.js index cc6be272851..0696ebe1f30 100644 --- a/assets/js/blocks/cart/block.js +++ b/assets/js/blocks/cart/block.js @@ -2,19 +2,19 @@ * External dependencies */ import { __ } from '@wordpress/i18n'; -import { useStoreCart } from '@woocommerce/base-context/hooks'; +import { + useStoreCart, + ValidationContextProvider, + StoreNoticesProvider, + StoreSnackbarNoticesProvider, + CartProvider, +} from '@woocommerce/base-context'; import { useEffect } from '@wordpress/element'; import LoadingMask from '@woocommerce/base-components/loading-mask'; -import { ValidationContextProvider } from '@woocommerce/base-context'; import { CURRENT_USER_IS_ADMIN } from '@woocommerce/settings'; import BlockErrorBoundary from '@woocommerce/base-components/block-error-boundary'; import { translateJQueryEventToNative } from '@woocommerce/base-utils'; import withScrollToTop from '@woocommerce/base-hocs/with-scroll-to-top'; -import { - StoreNoticesProvider, - StoreSnackbarNoticesProvider, - CartProvider, -} from '@woocommerce/base-context/providers'; import { SlotFillProvider } from '@woocommerce/blocks-checkout'; /** diff --git a/assets/js/blocks/cart/cart-line-items-table/cart-line-item-row.tsx b/assets/js/blocks/cart/cart-line-items-table/cart-line-item-row.tsx index 999d299d9f0..758128c76f4 100644 --- a/assets/js/blocks/cart/cart-line-items-table/cart-line-item-row.tsx +++ b/assets/js/blocks/cart/cart-line-items-table/cart-line-item-row.tsx @@ -11,7 +11,7 @@ import { useStoreCartItemQuantity, useStoreEvents, useStoreCart, -} from '@woocommerce/base-context/hooks'; +} from '@woocommerce/base-context'; import { ProductBackorderBadge, ProductImage, diff --git a/assets/js/blocks/cart/inner-blocks/cart-accepted-payment-methods-block/block.tsx b/assets/js/blocks/cart/inner-blocks/cart-accepted-payment-methods-block/block.tsx index 9efe4577a8f..22bb1f8fcd5 100644 --- a/assets/js/blocks/cart/inner-blocks/cart-accepted-payment-methods-block/block.tsx +++ b/assets/js/blocks/cart/inner-blocks/cart-accepted-payment-methods-block/block.tsx @@ -2,7 +2,7 @@ * External dependencies */ import { PaymentMethodIcons } from '@woocommerce/base-components/cart-checkout'; -import { usePaymentMethods } from '@woocommerce/base-context/hooks'; +import { usePaymentMethods } from '@woocommerce/base-context'; import { getIconsFromPaymentMethods } from '@woocommerce/base-utils'; const Block = ( { className }: { className: string } ): JSX.Element => { diff --git a/assets/js/blocks/cart/inner-blocks/cart-express-payment-block/block.tsx b/assets/js/blocks/cart/inner-blocks/cart-express-payment-block/block.tsx index ccb0659b1a9..f3a3b4287b4 100644 --- a/assets/js/blocks/cart/inner-blocks/cart-express-payment-block/block.tsx +++ b/assets/js/blocks/cart/inner-blocks/cart-express-payment-block/block.tsx @@ -1,7 +1,7 @@ /** * External dependencies */ -import { useStoreCart } from '@woocommerce/base-context/hooks'; +import { useStoreCart } from '@woocommerce/base-context'; import classnames from 'classnames'; /** diff --git a/assets/js/blocks/cart/inner-blocks/cart-express-payment-block/edit.tsx b/assets/js/blocks/cart/inner-blocks/cart-express-payment-block/edit.tsx index 1bfbfff15f4..c455ba9a4f7 100644 --- a/assets/js/blocks/cart/inner-blocks/cart-express-payment-block/edit.tsx +++ b/assets/js/blocks/cart/inner-blocks/cart-express-payment-block/edit.tsx @@ -4,7 +4,7 @@ import { __ } from '@wordpress/i18n'; import { useBlockProps } from '@wordpress/block-editor'; import { Placeholder, Button } from 'wordpress-components'; -import { useExpressPaymentMethods } from '@woocommerce/base-context/hooks'; +import { useExpressPaymentMethods } from '@woocommerce/base-context'; import { Icon, payment } from '@wordpress/icons'; import { ADMIN_URL } from '@woocommerce/settings'; import classnames from 'classnames'; diff --git a/assets/js/blocks/cart/inner-blocks/cart-line-items-block/block.tsx b/assets/js/blocks/cart/inner-blocks/cart-line-items-block/block.tsx index 8b4f38e1287..f482c7f2f39 100644 --- a/assets/js/blocks/cart/inner-blocks/cart-line-items-block/block.tsx +++ b/assets/js/blocks/cart/inner-blocks/cart-line-items-block/block.tsx @@ -1,7 +1,7 @@ /** * External dependencies */ -import { useStoreCart } from '@woocommerce/base-context/hooks'; +import { useStoreCart } from '@woocommerce/base-context'; /** * Internal dependencies */ diff --git a/assets/js/blocks/cart/inner-blocks/cart-order-summary/edit.tsx b/assets/js/blocks/cart/inner-blocks/cart-order-summary/edit.tsx index dbbd1296c75..46973923cae 100644 --- a/assets/js/blocks/cart/inner-blocks/cart-order-summary/edit.tsx +++ b/assets/js/blocks/cart/inner-blocks/cart-order-summary/edit.tsx @@ -7,7 +7,7 @@ import { innerBlockAreas } from '@woocommerce/blocks-checkout'; import { __ } from '@wordpress/i18n'; import { TotalsFooterItem } from '@woocommerce/base-components/cart-checkout'; import { getCurrencyFromPriceResponse } from '@woocommerce/price-format'; -import { useStoreCart } from '@woocommerce/base-context/hooks'; +import { useStoreCart } from '@woocommerce/base-context'; /** * Internal dependencies diff --git a/assets/js/blocks/cart/inner-blocks/cart-order-summary/frontend.tsx b/assets/js/blocks/cart/inner-blocks/cart-order-summary/frontend.tsx index 30ae7b8b5db..36ff3e89a6d 100644 --- a/assets/js/blocks/cart/inner-blocks/cart-order-summary/frontend.tsx +++ b/assets/js/blocks/cart/inner-blocks/cart-order-summary/frontend.tsx @@ -3,7 +3,7 @@ */ import { TotalsFooterItem } from '@woocommerce/base-components/cart-checkout'; import { getCurrencyFromPriceResponse } from '@woocommerce/price-format'; -import { useStoreCart } from '@woocommerce/base-context/hooks'; +import { useStoreCart } from '@woocommerce/base-context'; /** * Internal dependencies diff --git a/assets/js/blocks/cart/inner-blocks/cart-order-summary/slotfills.tsx b/assets/js/blocks/cart/inner-blocks/cart-order-summary/slotfills.tsx index 7d571acc750..239b257f96a 100644 --- a/assets/js/blocks/cart/inner-blocks/cart-order-summary/slotfills.tsx +++ b/assets/js/blocks/cart/inner-blocks/cart-order-summary/slotfills.tsx @@ -2,7 +2,7 @@ * External dependencies */ import { ExperimentalOrderMeta } from '@woocommerce/blocks-checkout'; -import { useStoreCart } from '@woocommerce/base-context/hooks'; +import { useStoreCart } from '@woocommerce/base-context'; export const OrderMetaSlotFill = (): JSX.Element => { // Prepare props to pass to the ExperimentalOrderMeta slot fill. We need to pluck out receiveCart. diff --git a/assets/js/blocks/cart/inner-blocks/empty-cart-block/frontend.tsx b/assets/js/blocks/cart/inner-blocks/empty-cart-block/frontend.tsx index e92c59769a5..31a75737c5c 100644 --- a/assets/js/blocks/cart/inner-blocks/empty-cart-block/frontend.tsx +++ b/assets/js/blocks/cart/inner-blocks/empty-cart-block/frontend.tsx @@ -1,7 +1,7 @@ /** * External dependencies */ -import { useStoreCart } from '@woocommerce/base-context/hooks'; +import { useStoreCart } from '@woocommerce/base-context'; import { useEffect } from '@wordpress/element'; import { dispatchEvent } from '@woocommerce/base-utils'; diff --git a/assets/js/blocks/cart/inner-blocks/filled-cart-block/frontend.tsx b/assets/js/blocks/cart/inner-blocks/filled-cart-block/frontend.tsx index 97a166a7b32..dfc3c6bf7c1 100644 --- a/assets/js/blocks/cart/inner-blocks/filled-cart-block/frontend.tsx +++ b/assets/js/blocks/cart/inner-blocks/filled-cart-block/frontend.tsx @@ -3,7 +3,7 @@ */ import classnames from 'classnames'; import { SidebarLayout } from '@woocommerce/base-components/sidebar-layout'; -import { useStoreCart, useStoreNotices } from '@woocommerce/base-context/hooks'; +import { useStoreCart, useStoreNotices } from '@woocommerce/base-context'; import { useEffect } from '@wordpress/element'; import { decodeEntities } from '@wordpress/html-entities'; diff --git a/assets/js/blocks/checkout/block.tsx b/assets/js/blocks/checkout/block.tsx index f86ed2c11f4..7ad1d4df63a 100644 --- a/assets/js/blocks/checkout/block.tsx +++ b/assets/js/blocks/checkout/block.tsx @@ -4,15 +4,16 @@ import { __ } from '@wordpress/i18n'; import classnames from 'classnames'; import { createInterpolateElement, useEffect } from '@wordpress/element'; -import { useStoreCart, useStoreNotices } from '@woocommerce/base-context/hooks'; import { + useStoreCart, + useStoreNotices, useCheckoutContext, useValidationContext, ValidationContextProvider, StoreNoticesProvider, CheckoutProvider, + StoreSnackbarNoticesProvider, } from '@woocommerce/base-context'; -import { StoreSnackbarNoticesProvider } from '@woocommerce/base-context/providers'; import BlockErrorBoundary from '@woocommerce/base-components/block-error-boundary'; import { SidebarLayout } from '@woocommerce/base-components/sidebar-layout'; import { CURRENT_USER_IS_ADMIN, getSetting } from '@woocommerce/settings'; diff --git a/assets/js/blocks/checkout/frontend.tsx b/assets/js/blocks/checkout/frontend.tsx index 722b08cdf9a..5db3b62ac88 100644 --- a/assets/js/blocks/checkout/frontend.tsx +++ b/assets/js/blocks/checkout/frontend.tsx @@ -3,11 +3,11 @@ */ import { Children, cloneElement, isValidElement } from '@wordpress/element'; import { getValidBlockAttributes } from '@woocommerce/base-utils'; -import { useStoreCart } from '@woocommerce/base-context'; import { + useStoreCart, useCheckoutExtensionData, useValidation, -} from '@woocommerce/base-context/hooks'; +} from '@woocommerce/base-context'; import { getRegisteredBlockComponents } from '@woocommerce/blocks-registry'; import { renderParentBlock } from '@woocommerce/atomic-utils'; diff --git a/assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/edit.tsx b/assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/edit.tsx index 0a19dac5d6a..93d4b4922b0 100644 --- a/assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/edit.tsx +++ b/assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/edit.tsx @@ -3,7 +3,7 @@ */ import classnames from 'classnames'; import { useBlockProps } from '@wordpress/block-editor'; -import { useCheckoutAddress } from '@woocommerce/base-context/hooks'; +import { useCheckoutAddress } from '@woocommerce/base-context'; import { innerBlockAreas } from '@woocommerce/blocks-checkout'; /** diff --git a/assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/frontend.tsx b/assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/frontend.tsx index cdb8f702e99..9fc4022b4f8 100644 --- a/assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/frontend.tsx +++ b/assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/frontend.tsx @@ -4,8 +4,10 @@ import classnames from 'classnames'; import { withFilteredAttributes } from '@woocommerce/shared-hocs'; import { FormStep } from '@woocommerce/base-components/cart-checkout'; -import { useCheckoutContext } from '@woocommerce/base-context'; -import { useCheckoutAddress } from '@woocommerce/base-context/hooks'; +import { + useCheckoutContext, + useCheckoutAddress, +} from '@woocommerce/base-context'; /** * Internal dependencies diff --git a/assets/js/blocks/checkout/inner-blocks/checkout-express-payment-block/block.tsx b/assets/js/blocks/checkout/inner-blocks/checkout-express-payment-block/block.tsx index fd3c14ee4b4..68ccae2becb 100644 --- a/assets/js/blocks/checkout/inner-blocks/checkout-express-payment-block/block.tsx +++ b/assets/js/blocks/checkout/inner-blocks/checkout-express-payment-block/block.tsx @@ -1,7 +1,7 @@ /** * External dependencies */ -import { useStoreCart } from '@woocommerce/base-context/hooks'; +import { useStoreCart } from '@woocommerce/base-context'; /** * Internal dependencies diff --git a/assets/js/blocks/checkout/inner-blocks/checkout-express-payment-block/edit.tsx b/assets/js/blocks/checkout/inner-blocks/checkout-express-payment-block/edit.tsx index 94c65db9dcb..0c7c0af7ed5 100644 --- a/assets/js/blocks/checkout/inner-blocks/checkout-express-payment-block/edit.tsx +++ b/assets/js/blocks/checkout/inner-blocks/checkout-express-payment-block/edit.tsx @@ -4,7 +4,7 @@ import { __ } from '@wordpress/i18n'; import { useBlockProps } from '@wordpress/block-editor'; import { Placeholder, Button } from 'wordpress-components'; -import { useExpressPaymentMethods } from '@woocommerce/base-context/hooks'; +import { useExpressPaymentMethods } from '@woocommerce/base-context'; import { Icon, payment } from '@wordpress/icons'; import { ADMIN_URL } from '@woocommerce/settings'; import classnames from 'classnames'; diff --git a/assets/js/blocks/checkout/inner-blocks/checkout-order-note-block/block.tsx b/assets/js/blocks/checkout/inner-blocks/checkout-order-note-block/block.tsx index 9b31a5ac91f..5c424fff987 100644 --- a/assets/js/blocks/checkout/inner-blocks/checkout-order-note-block/block.tsx +++ b/assets/js/blocks/checkout/inner-blocks/checkout-order-note-block/block.tsx @@ -4,8 +4,7 @@ import classnames from 'classnames'; import { __ } from '@wordpress/i18n'; import { FormStep } from '@woocommerce/base-components/cart-checkout'; -import { useCheckoutContext } from '@woocommerce/base-context'; -import { useShippingData } from '@woocommerce/base-context/hooks'; +import { useCheckoutContext, useShippingData } from '@woocommerce/base-context'; /** * Internal dependencies diff --git a/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/edit.tsx b/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/edit.tsx index 285b898234d..293e4aebb3b 100644 --- a/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/edit.tsx +++ b/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/edit.tsx @@ -6,7 +6,7 @@ import type { TemplateArray } from '@wordpress/blocks'; import { innerBlockAreas } from '@woocommerce/blocks-checkout'; import { TotalsFooterItem } from '@woocommerce/base-components/cart-checkout'; import { getCurrencyFromPriceResponse } from '@woocommerce/price-format'; -import { useStoreCart } from '@woocommerce/base-context/hooks'; +import { useStoreCart } from '@woocommerce/base-context'; /** * Internal dependencies diff --git a/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/frontend.tsx b/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/frontend.tsx index 30ae7b8b5db..36ff3e89a6d 100644 --- a/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/frontend.tsx +++ b/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/frontend.tsx @@ -3,7 +3,7 @@ */ import { TotalsFooterItem } from '@woocommerce/base-components/cart-checkout'; import { getCurrencyFromPriceResponse } from '@woocommerce/price-format'; -import { useStoreCart } from '@woocommerce/base-context/hooks'; +import { useStoreCart } from '@woocommerce/base-context'; /** * Internal dependencies diff --git a/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/slotfills.tsx b/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/slotfills.tsx index 7efdbdd1a2d..292315e804f 100644 --- a/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/slotfills.tsx +++ b/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/slotfills.tsx @@ -2,7 +2,7 @@ * External dependencies */ import { ExperimentalOrderMeta } from '@woocommerce/blocks-checkout'; -import { useStoreCart } from '@woocommerce/base-context/hooks'; +import { useStoreCart } from '@woocommerce/base-context'; // @todo Consider deprecating OrderMetaSlotFill and DiscountSlotFill in favour of inner block areas. export const OrderMetaSlotFill = (): JSX.Element => { diff --git a/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/test/block.js b/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/test/block.js index 988fd56422d..fe7d9d0542e 100644 --- a/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/test/block.js +++ b/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/test/block.js @@ -17,7 +17,7 @@ import { textContentMatcher, textContentMatcherAcrossSiblings, } from '../../../../../../../tests/utils/find-by-text'; -const baseContextHooks = jest.requireMock( '@woocommerce/base-context/hooks' ); +const baseContextHooks = jest.requireMock( '@woocommerce/base-context' ); const woocommerceSettings = jest.requireMock( '@woocommerce/settings' ); const defaultUseStoreCartValue = { @@ -32,8 +32,8 @@ const defaultUseStoreCartValue = { cartHasCalculatedShipping: mockPreviewCart.has_calculated_shipping, }; -jest.mock( '@woocommerce/base-context/hooks', () => ( { - ...jest.requireActual( '@woocommerce/base-context/hooks' ), +jest.mock( '@woocommerce/base-context', () => ( { + ...jest.requireActual( '@woocommerce/base-context' ), /* We need to redefine this here despite the defaultUseStoreCartValue above diff --git a/assets/js/blocks/checkout/inner-blocks/checkout-payment-block/frontend.tsx b/assets/js/blocks/checkout/inner-blocks/checkout-payment-block/frontend.tsx index abca086c41c..3d11434854f 100644 --- a/assets/js/blocks/checkout/inner-blocks/checkout-payment-block/frontend.tsx +++ b/assets/js/blocks/checkout/inner-blocks/checkout-payment-block/frontend.tsx @@ -2,13 +2,14 @@ * External dependencies */ import classnames from 'classnames'; -import { useStoreCart, useEmitResponse } from '@woocommerce/base-context/hooks'; -import { withFilteredAttributes } from '@woocommerce/shared-hocs'; -import { FormStep } from '@woocommerce/base-components/cart-checkout'; import { + useStoreCart, + useEmitResponse, useCheckoutContext, StoreNoticesProvider, } from '@woocommerce/base-context'; +import { withFilteredAttributes } from '@woocommerce/shared-hocs'; +import { FormStep } from '@woocommerce/base-components/cart-checkout'; /** * Internal dependencies diff --git a/assets/js/blocks/checkout/inner-blocks/checkout-shipping-address-block/frontend.tsx b/assets/js/blocks/checkout/inner-blocks/checkout-shipping-address-block/frontend.tsx index 9756834dd9a..0afb743df80 100644 --- a/assets/js/blocks/checkout/inner-blocks/checkout-shipping-address-block/frontend.tsx +++ b/assets/js/blocks/checkout/inner-blocks/checkout-shipping-address-block/frontend.tsx @@ -4,8 +4,10 @@ import classnames from 'classnames'; import { withFilteredAttributes } from '@woocommerce/shared-hocs'; import { FormStep } from '@woocommerce/base-components/cart-checkout'; -import { useCheckoutContext } from '@woocommerce/base-context'; -import { useCheckoutAddress } from '@woocommerce/base-context/hooks'; +import { + useCheckoutContext, + useCheckoutAddress, +} from '@woocommerce/base-context'; /** * Internal dependencies diff --git a/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/block.tsx b/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/block.tsx index 266f83aecb8..4593784340e 100644 --- a/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/block.tsx +++ b/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/block.tsx @@ -2,12 +2,11 @@ * External dependencies */ import { __ } from '@wordpress/i18n'; -import { useShippingData } from '@woocommerce/base-context/hooks'; +import { useShippingData, useEditorContext } from '@woocommerce/base-context'; import { ShippingRatesControl } from '@woocommerce/base-components/cart-checkout'; import { getShippingRatesPackageCount } from '@woocommerce/base-utils'; import { getCurrencyFromPriceResponse } from '@woocommerce/price-format'; import FormattedMonetaryAmount from '@woocommerce/base-components/formatted-monetary-amount'; -import { useEditorContext } from '@woocommerce/base-context'; import { decodeEntities } from '@wordpress/html-entities'; import { Notice } from 'wordpress-components'; import classnames from 'classnames'; diff --git a/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/frontend.tsx b/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/frontend.tsx index a9c8d90f7ac..9ecfbd9a806 100644 --- a/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/frontend.tsx +++ b/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/frontend.tsx @@ -4,8 +4,10 @@ import classnames from 'classnames'; import { withFilteredAttributes } from '@woocommerce/shared-hocs'; import { FormStep } from '@woocommerce/base-components/cart-checkout'; -import { useCheckoutContext } from '@woocommerce/base-context'; -import { useCheckoutAddress } from '@woocommerce/base-context/hooks'; +import { + useCheckoutContext, + useCheckoutAddress, +} from '@woocommerce/base-context'; /** * Internal dependencies diff --git a/assets/js/blocks/checkout/inner-blocks/checkout-terms-block/frontend.tsx b/assets/js/blocks/checkout/inner-blocks/checkout-terms-block/frontend.tsx index 098f68dc5ee..6920115e0d9 100644 --- a/assets/js/blocks/checkout/inner-blocks/checkout-terms-block/frontend.tsx +++ b/assets/js/blocks/checkout/inner-blocks/checkout-terms-block/frontend.tsx @@ -5,7 +5,7 @@ import { __ } from '@wordpress/i18n'; import classnames from 'classnames'; import { useState, useEffect } from '@wordpress/element'; import { CheckboxControl } from '@woocommerce/blocks-checkout'; -import { useCheckoutSubmit } from '@woocommerce/base-context/hooks'; +import { useCheckoutSubmit } from '@woocommerce/base-context'; import { withInstanceId } from '@wordpress/compose'; import type { ValidationData } from '@woocommerce/type-defs/contexts'; /** diff --git a/assets/js/blocks/price-filter/block.js b/assets/js/blocks/price-filter/block.js index ade15338918..d246858dc05 100644 --- a/assets/js/blocks/price-filter/block.js +++ b/assets/js/blocks/price-filter/block.js @@ -6,7 +6,7 @@ import { useQueryStateByKey, useQueryStateByContext, useCollectionData, -} from '@woocommerce/base-context/hooks'; +} from '@woocommerce/base-context'; import { useCallback, useState, useEffect } from '@wordpress/element'; import PriceSlider from '@woocommerce/base-components/price-slider'; import { useDebouncedCallback } from 'use-debounce'; diff --git a/assets/js/blocks/single-product/block.js b/assets/js/blocks/single-product/block.js index f3dd756e7dc..a011a3f19c2 100644 --- a/assets/js/blocks/single-product/block.js +++ b/assets/js/blocks/single-product/block.js @@ -7,8 +7,10 @@ import { InnerBlockLayoutContextProvider, ProductDataContextProvider, } from '@woocommerce/shared-context'; -import { StoreNoticesProvider } from '@woocommerce/base-context'; -import { useStoreEvents } from '@woocommerce/base-context/hooks'; +import { + StoreNoticesProvider, + useStoreEvents, +} from '@woocommerce/base-context'; /** * Internal dependencies diff --git a/assets/js/blocks/stock-filter/block.js b/assets/js/blocks/stock-filter/block.js index a624d17d871..37f57ed06f0 100644 --- a/assets/js/blocks/stock-filter/block.js +++ b/assets/js/blocks/stock-filter/block.js @@ -8,7 +8,7 @@ import { useQueryStateByKey, useQueryStateByContext, useCollectionData, -} from '@woocommerce/base-context/hooks'; +} from '@woocommerce/base-context'; import { getSetting } from '@woocommerce/settings'; import { useCallback, useEffect, useState, useMemo } from '@wordpress/element'; import CheckboxList from '@woocommerce/base-components/checkbox-list'; diff --git a/assets/js/blocks/stock-filter/test/block.js b/assets/js/blocks/stock-filter/test/block.js index 8be12fa8a56..c1d6a22a097 100644 --- a/assets/js/blocks/stock-filter/test/block.js +++ b/assets/js/blocks/stock-filter/test/block.js @@ -22,9 +22,9 @@ const mockResults = { ], }; -jest.mock( '@woocommerce/base-context/hooks', () => { +jest.mock( '@woocommerce/base-context', () => { return { - ...jest.requireActual( '@woocommerce/base-context/hooks' ), + ...jest.requireActual( '@woocommerce/base-context' ), useCollectionData: () => ( { isLoading: false, results: mockResults } ), }; } ); diff --git a/bin/webpack-entries.js b/bin/webpack-entries.js index 13474b1d00c..aef7f30ed3c 100644 --- a/bin/webpack-entries.js +++ b/bin/webpack-entries.js @@ -118,6 +118,7 @@ const entries = { wcBlocksSharedHocs: './assets/js/shared/hocs/index.js', priceFormat: './packages/prices/index.js', blocksCheckout: './packages/checkout/index.js', + wcBaseContext: './assets/js/base/context/index.ts', }, main: { // Shared blocks code diff --git a/bin/webpack-helpers.js b/bin/webpack-helpers.js index 98695120fcb..8bb95a4ef50 100644 --- a/bin/webpack-helpers.js +++ b/bin/webpack-helpers.js @@ -20,6 +20,7 @@ const wcDepMap = { '@woocommerce/shared-hocs': [ 'wc', 'wcBlocksSharedHocs' ], '@woocommerce/price-format': [ 'wc', 'priceFormat' ], '@woocommerce/blocks-checkout': [ 'wc', 'blocksCheckout' ], + '@woocommerce/base-context': [ 'wc', 'wcBaseContext' ], }; const wcHandleMap = { @@ -31,6 +32,7 @@ const wcHandleMap = { '@woocommerce/shared-hocs': 'wc-blocks-shared-hocs', '@woocommerce/price-format': 'wc-price-format', '@woocommerce/blocks-checkout': 'wc-blocks-checkout', + '@woocommerce/base-context': 'wc-blocks-base-context', }; const getAlias = ( options = {} ) => { @@ -49,10 +51,6 @@ const getAlias = ( options = {} ) => { __dirname, `../assets/js/${ pathPart }base/components/` ), - '@woocommerce/base-context': path.resolve( - __dirname, - `../assets/js/${ pathPart }base/context/` - ), '@woocommerce/base-hocs': path.resolve( __dirname, `../assets/js/${ pathPart }base/hocs/` diff --git a/docs/contributors/js-build-system.md b/docs/contributors/js-build-system.md index 131bcf415bb..04dccfd06f1 100644 --- a/docs/contributors/js-build-system.md +++ b/docs/contributors/js-build-system.md @@ -26,16 +26,7 @@ Several scripts are loaded as externals. That means that they are imported in WC ## Aliases -There are several aliases for internal imports which make importing files across the file tree easier. Instead of having to write a long relative path, they allow writing an alias: - -```diff --import { useStoreCartCoupons } from '../../../../base/hooks'; -+import { useStoreCartCoupons } from '@woocommerce/base-context/hooks'; -``` - -Aliases also ease refactors because imports no longer depend on the exact location of the file. - -All available aliases can be found in [`webpack-helpers.js`](https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/6da64165025e7a2afc1782e4b278d72536e7b754/bin/webpack-helpers.js#L36-L91). +There are several aliases for internal imports which make importing files across the file tree easier. Instead of having to write a long relative path. All available aliases can be found in [`webpack-helpers.js`](https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/6da64165025e7a2afc1782e4b278d72536e7b754/bin/webpack-helpers.js#L36-L91). ## Styling @@ -51,16 +42,15 @@ There were legacy builds of the `MainConfig`, `FrontendConfig` and `StylingConfi Webpack config is split between several files: -- [`webpack.config.js`](https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/trunk/webpack.config.js): Top level webpack config. Includes support for legacy and main build. -- [`bin/webpack-configs.js`](https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/trunk/bin/webpack-configs.js): Code for generating each build config. This most closely resembles a classic webpack config - if you're looking for something, start here. -- [`bin/webpack-entries.js`](https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/trunk/bin/webpack-entries.js): Code for generating [webpack `entry` definitions](https://webpack.js.org/concepts/entry-points/) and mapping source files to entry points. If you're adding a new block or module to the build, start here. -- [`bin/webpack-helpers.js`](https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/trunk/bin/webpack-helpers.js): Includes utils to load external code at run time, e.g. some dependencies from Woo and WordPress core. +- [`webpack.config.js`](https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/trunk/webpack.config.js): Top level webpack config. Includes support for legacy and main build. +- [`bin/webpack-configs.js`](https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/trunk/bin/webpack-configs.js): Code for generating each build config. This most closely resembles a classic webpack config - if you're looking for something, start here. +- [`bin/webpack-entries.js`](https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/trunk/bin/webpack-entries.js): Code for generating [webpack `entry` definitions](https://webpack.js.org/concepts/entry-points/) and mapping source files to entry points. If you're adding a new block or module to the build, start here. +- [`bin/webpack-helpers.js`](https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/trunk/bin/webpack-helpers.js): Includes utils to load external code at run time, e.g. some dependencies from Woo and WordPress core. - ---- +## [We're hiring!](https://woocommerce.com/careers/) Come work with us! 🐞 Found a mistake, or have a suggestion? [Leave feedback about this document here.](https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues/new?assignees=&labels=type%3A+documentation&template=--doc-feedback.md&title=Feedback%20on%20./docs/contributors/js-build-system.md) - + diff --git a/docs/extensibility/checkout-flow-and-events.md b/docs/extensibility/checkout-flow-and-events.md index 9197501365d..ec967779658 100644 --- a/docs/extensibility/checkout-flow-and-events.md +++ b/docs/extensibility/checkout-flow-and-events.md @@ -19,6 +19,7 @@ This document gives an overview of the flow for the checkout in the WooCommerce - [`onShippingRateFail`](#onshippingratefail) - [`onShippingRateSelectSuccess`](#onshippingrateselectsuccess) - [`onShippingRateSelectFail`](#onshippingrateselectfail) +- [](#) The architecture of the Checkout Block is derived from the following principles: @@ -165,7 +166,7 @@ const MyComponent = ( { onCheckoutValidationBeforeProcessing } ) => { This internal hook contains a collection of API interfaces for event emitter related usage. It can be used by simply adding this to a component: ```jsx -import { useEmitResponse } from '@woocommerce/base-context/hooks'; +import { useEmitResponse } from '@woocommerce/base-context'; const Component = () => { const { @@ -473,11 +474,10 @@ This event emitter is fired when a shipping rate selection is not being persiste This event emitter doesn't care about any registered observer response and will simply execute all registered observers passing them the current error status in the context. - ---- +## [We're hiring!](https://woocommerce.com/careers/) Come work with us! 🐞 Found a mistake, or have a suggestion? [Leave feedback about this document here.](https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues/new?assignees=&labels=type%3A+documentation&template=--doc-feedback.md&title=Feedback%20on%20./docs/extensibility/checkout-flow-and-events.md) - + diff --git a/src/AssetsController.php b/src/AssetsController.php index 35fedcaa79d..596603e2fe3 100644 --- a/src/AssetsController.php +++ b/src/AssetsController.php @@ -58,14 +58,15 @@ public function register_assets() { $this->api->register_script( 'wc-blocks', $this->api->get_block_asset_build_path( 'wc-blocks' ), [ 'wc-blocks-vendors' ], false ); $this->api->register_script( 'wc-blocks-shared-context', 'build/wc-blocks-shared-context.js', [] ); $this->api->register_script( 'wc-blocks-shared-hocs', 'build/wc-blocks-shared-hocs.js', [], false ); + $this->api->register_script( 'wc-blocks-base-context', 'build/wc-base-context.js', [] ); // The price package is shared externally so has no blocks prefix. $this->api->register_script( 'wc-price-format', 'build/price-format.js', [], false ); - if ( Package::feature()->is_feature_plugin_build() ) { + // if ( Package::feature()->is_feature_plugin_build() ) { $this->api->register_script( 'wc-blocks-checkout-inner-blocks-frontend', 'build/checkout-inner-blocks-frontend.js', [] ); $this->api->register_script( 'wc-blocks-checkout', 'build/blocks-checkout.js', [] ); - } + // } wp_add_inline_script( 'wc-blocks-middleware', diff --git a/tests/js/jest.config.json b/tests/js/jest.config.json index 602376f99f2..99312884220 100644 --- a/tests/js/jest.config.json +++ b/tests/js/jest.config.json @@ -19,7 +19,7 @@ "@woocommerce/price-format": "packages/prices", "@woocommerce/block-hocs(.*)$": "assets/js/hocs/$1", "@woocommerce/base-components(.*)$": "assets/js/base/components/$1", - "@woocommerce/base-context(.*)$": "assets/js/base/context/$1", + "@woocommerce/base-context": "assets/js/base/context", "@woocommerce/base-hocs(.*)$": "assets/js/base/hocs/$1", "@woocommerce/base-hooks(.*)$": "assets/js/base/hooks/$1", "@woocommerce/base-utils(.*)$": "assets/js/base/utils", diff --git a/tsconfig.base.json b/tsconfig.base.json index a79f60e5154..3b076a3d0a9 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -30,12 +30,6 @@ "@woocommerce/atomic-utils": [ "assets/js/atomic/utils" ], "@woocommerce/base-components/*": [ "assets/js/base/components/*" ], "@woocommerce/base-context": [ "assets/js/base/context" ], - "@woocommerce/base-context/hooks": [ - "assets/js/base/context/hooks" - ], - "@woocommerce/base-context/components": [ - "assets/js/base/context/components" - ], "@woocommerce/base-hocs/*": [ "assets/js/base/hocs/*" ], "@woocommerce/base-hooks": [ "assets/js/base/hooks" ], "@woocommerce/base-utils": [ "assets/js/base/utils" ],