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

Commit

Permalink
Experiment- external block context
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejolley committed Mar 21, 2022
1 parent ba05df8 commit 4b75668
Show file tree
Hide file tree
Showing 77 changed files with 127 additions and 139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down
5 changes: 1 addition & 4 deletions assets/js/atomic/blocks/product-elements/button/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion assets/js/atomic/blocks/product-elements/image/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion assets/js/atomic/blocks/product-elements/title/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion assets/js/base/components/product-list/product-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion assets/js/base/context/hooks/test/use-store-notices.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 5 additions & 1 deletion assets/js/base/context/hooks/use-store-snackbar-notices.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './components/snackbar-notices-container';
export * from './context';
5 changes: 1 addition & 4 deletions assets/js/blocks/active-filters/active-attribute-filters.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion assets/js/blocks/active-filters/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion assets/js/blocks/attribute-filter/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ( {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { useStoreCart } from '@woocommerce/base-context/hooks';
import { useStoreCart } from '@woocommerce/base-context';
import { useEffect, useRef } from 'react';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { useStoreCart } from '@woocommerce/base-context/hooks';
import { useStoreCart } from '@woocommerce/base-context';

type FilledMiniCartContentsBlockProps = {
children: JSX.Element;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { useStoreCart } from '@woocommerce/base-context/hooks';
import { useStoreCart } from '@woocommerce/base-context';
import classNames from 'classnames';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down
2 changes: 1 addition & 1 deletion assets/js/blocks/cart-checkout/mini-cart/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { __ } from '@wordpress/i18n';
import {
useExpressPaymentMethods,
usePaymentMethodInterface,
} from '@woocommerce/base-context/hooks';
} from '@woocommerce/base-context';
import {
cloneElement,
isValidElement,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { __ } from '@wordpress/i18n';
import {
useEmitResponse,
useExpressPaymentMethods,
} from '@woocommerce/base-context/hooks';
import {
StoreNoticesProvider,
useCheckoutContext,
usePaymentMethodDataContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { __ } from '@wordpress/i18n';
import {
useEmitResponse,
useExpressPaymentMethods,
} from '@woocommerce/base-context/hooks';
import {
StoreNoticesProvider,
useCheckoutContext,
usePaymentMethodDataContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading

0 comments on commit 4b75668

Please sign in to comment.