Version Description
- 2022-11-21 =
Bug Fixes
- Fix skewed placeholder of a Product Image block. (7651)
- Fix missing translations in the inspector (editor mode) for the Cart Cross-Sells Blocks. (7616)
Enhancements
- Move paymentResult to the payment store. (7692)
- Add the
Products by Attribute
template. (7660) - Make loading placeholder colors match the current font color for the theme. (7658)
- Remove cart fragments support to improve performance in product blocks. (7644)
- Add a
clearValidationErrors
action to thewc/store/validation
data store. (7601) - Add
ValidatedTextInput
andValidationInputError
to the@woocommerce/blocks-checkout
package. (7583) - React Based Local Pickup Settings Screen. (7581)
- Convert product-elements/image to TypeScript. (7572)
- Add
StoreNoticesContainer
to the@woocommerce/blocks-checkout
package. (7558) - Convert product-elements/price to TypeScript. (7534)
- Adds the option of providing a custom class for the product details on the Cart Block. (7328)
Various
- Change action type name for use shipping as billing option. (7695)
- Block Checkout: Apply selected Local Pickup rate to entire order (all packages). (7484)
Download this release
Release Info
Developer | automattic |
Plugin | WooCommerce Gutenberg Products Block |
Version | 9.0.0 |
Comparing to | |
See all releases |
Code changes from version 8.9.1 to 9.0.0
- assets/css/abstracts/_mixins.scss +4 -3
- assets/js/atomic/blocks/product-elements/add-to-cart/product-types/variable/variation-attributes/attribute-select-control.js +1 -1
- assets/js/atomic/blocks/product-elements/image/attributes.ts +29 -1
- assets/js/atomic/blocks/product-elements/image/{block.js → block.tsx} +56 -51
- assets/js/atomic/blocks/product-elements/image/constants.tsx +17 -0
- assets/js/atomic/blocks/product-elements/image/{edit.js → edit.tsx} +29 -12
- assets/js/atomic/blocks/product-elements/image/{frontend.js → frontend.ts} +1 -1
- assets/js/atomic/blocks/product-elements/image/{index.js → index.ts} +18 -22
- assets/js/atomic/blocks/product-elements/image/test/block.test.js +78 -11
- assets/js/atomic/blocks/product-elements/image/types.ts +16 -0
- assets/js/atomic/blocks/product-elements/sku/attributes.ts +4 -0
- assets/js/atomic/blocks/product-elements/sku/block.tsx +2 -2
- assets/js/atomic/blocks/product-elements/sku/edit.tsx +20 -6
- assets/js/atomic/blocks/product-elements/sku/index.ts +6 -1
- assets/js/atomic/blocks/product-elements/sku/types.ts +3 -2
- assets/js/atomic/blocks/product-elements/stock-indicator/attributes.js +0 -8
- assets/js/atomic/blocks/product-elements/stock-indicator/attributes.ts +15 -0
- assets/js/atomic/blocks/product-elements/stock-indicator/{block.js → block.tsx} +23 -31
- assets/js/atomic/blocks/product-elements/stock-indicator/{constants.js → constants.tsx} +3 -3
- assets/js/atomic/blocks/product-elements/stock-indicator/{edit.js → edit.tsx} +12 -11
- assets/js/atomic/blocks/product-elements/stock-indicator/{index.js → index.ts} +3 -2
- assets/js/atomic/blocks/product-elements/stock-indicator/{supports.js → supports.ts} +0 -0
- assets/js/atomic/blocks/product-elements/stock-indicator/types.ts +3 -0
- assets/js/base/components/block-error-boundary/block-error.tsx +3 -0
- assets/js/base/components/cart-checkout/address-form/address-form.tsx +1 -1
- assets/js/base/components/cart-checkout/product-details/index.tsx +7 -5
- assets/js/base/components/cart-checkout/totals/coupon/index.tsx +5 -3
- assets/js/base/components/checkbox-list/index.tsx +1 -0
- assets/js/base/components/combobox/index.tsx +1 -1
- assets/js/base/components/filter-placeholder/style.scss +0 -5
- assets/js/base/components/label/index.tsx +2 -2
- assets/js/base/components/product-rating/index.tsx +2 -2
- assets/js/base/components/reviews/review-list-item/index.js +3 -0
- assets/js/base/components/state-input/state-input.tsx +1 -1
- assets/js/base/components/text-input/index.ts +0 -2
- assets/js/base/context/hooks/cart/use-store-cart-item-quantity.ts +1 -5
- assets/js/base/context/hooks/payment-methods/use-payment-method-interface.ts +14 -4
- assets/js/base/context/hooks/use-checkout-submit.js +4 -3
- assets/js/base/context/providers/cart-checkout/checkout-events/index.tsx +0 -1
- assets/js/base/context/providers/cart-checkout/checkout-processor.js +8 -10
- assets/js/base/context/providers/cart-checkout/payment-events/index.tsx +23 -28
- assets/js/base/context/providers/index.js +0 -1
- assets/js/base/context/providers/store-notices/index.js +0 -1
- assets/js/base/utils/legacy-events.ts +0 -17
- assets/js/blocks/cart-checkout-shared/payment-methods/express-payment-methods.js +12 -7
- assets/js/blocks/cart-checkout-shared/payment-methods/express-payment/cart-express-payment.js +6 -12
- assets/js/blocks/cart-checkout-shared/payment-methods/express-payment/checkout-express-payment.js +5 -8
- assets/js/blocks/cart-checkout-shared/payment-methods/payment-method-error-boundary.js +1 -1
- assets/js/blocks/cart/block.js +5 -5
- assets/js/blocks/cart/cart-cross-sells-product-list/cart-cross-sells-product.tsx +9 -1
- assets/js/blocks/cart/cart-line-items-table/cart-line-item-row.tsx +8 -9
- assets/js/blocks/cart/inner-blocks/cart-cross-sells-block/block.json +1 -0
- assets/js/blocks/cart/inner-blocks/cart-cross-sells-block/index.tsx +1 -2
- assets/js/blocks/cart/inner-blocks/cart-cross-sells-products/block.json +1 -0
- assets/js/blocks/cart/inner-blocks/cart-cross-sells-products/index.tsx +1 -2
- assets/js/blocks/checkout/block.tsx +5 -2
- assets/js/blocks/checkout/inner-blocks/checkout-contact-information-block/block.tsx +4 -2
- assets/js/blocks/checkout/inner-blocks/checkout-payment-block/frontend.tsx +1 -1
- assets/js/blocks/checkout/phone-number/index.tsx +1 -1
- assets/js/blocks/classic-template/constants.ts +7 -0
- assets/js/blocks/classic-template/test/utils.ts +4 -0
- assets/js/blocks/products/all-products/block.js +1 -1
- assets/js/blocks/single-product/block.js +1 -1
- assets/js/data/cart/action-types.ts +0 -1
- assets/js/data/cart/actions.ts +0 -15
- assets/js/data/cart/controls.js +0 -4
- assets/js/data/cart/index.ts +2 -0
- assets/js/data/checkout/action-types.ts +1 -3
- assets/js/data/checkout/actions.ts +1 -17
- assets/js/data/checkout/default-state.ts +0 -4
- assets/js/data/checkout/index.ts +0 -4
- assets/js/data/checkout/reducers.ts +1 -13
- assets/js/data/checkout/test/reducer.ts +1 -23
- assets/js/data/checkout/thunks.ts +15 -8
- assets/js/data/checkout/types.ts +2 -1
- assets/js/data/collections/index.js +4 -2
- assets/js/data/payment/action-types.ts +7 -1
- assets/js/data/payment/actions.ts +35 -16
- assets/js/data/payment/constants.ts +0 -1
- assets/js/data/payment/default-state.ts +7 -27
- assets/js/data/payment/index.ts +0 -4
- assets/js/data/payment/reducers.ts +49 -26
- assets/js/data/payment/selectors.ts +69 -24
- assets/js/data/payment/test/actions.ts +4 -8
- assets/js/data/payment/test/check-payment-methods.tsx +160 -0
- assets/js/data/payment/test/reducers.js +21 -22
- assets/js/data/payment/test/set-default-payment-method.ts +9 -4
- assets/js/data/payment/test/utils.js +0 -25
- assets/js/data/payment/thunks.ts +5 -11
- assets/js/data/payment/types.ts +0 -20
- assets/js/data/payment/{check-payment-methods.ts → utils/check-payment-methods.ts} +8 -10
- assets/js/data/payment/{utils.ts → utils/filter-active-saved-payment-methods.ts} +1 -26
- assets/js/data/payment/{set-default-payment-method.ts → utils/set-default-payment-method.ts} +2 -4
- assets/js/data/query-state/index.js +4 -2
- assets/js/data/schema/index.js +4 -2
- assets/js/data/validation/action-types.ts +1 -1
- assets/js/data/validation/actions.ts +27 -2
- assets/js/data/validation/index.ts +0 -4
- assets/js/data/validation/reducers.ts +14 -2
- assets/js/data/validation/test/reducers.ts +22 -1
- assets/js/types/type-defs/payment-method-interface.ts +11 -3
- assets/js/types/type-defs/product-response.ts +1 -0
- build/active-filters-frontend.asset.php +1 -1
- build/active-filters-frontend.js +4 -4
- build/active-filters-wrapper-frontend.js +4 -4
- build/active-filters.asset.php +1 -1
- build/active-filters.js +4 -4
- build/all-products-frontend.asset.php +1 -1
- build/all-products-frontend.js +7 -7
- build/all-products.asset.php +1 -1
- build/all-products.js +16 -16
- build/all-reviews.asset.php +1 -1
- build/all-reviews.js +3 -3
- build/attribute-filter-frontend.asset.php +1 -1
- build/attribute-filter-frontend.js +7 -7
- build/attribute-filter-wrapper-frontend.js +6 -6
- build/attribute-filter.asset.php +1 -1
- build/attribute-filter.js +9 -9
- build/blocks-checkout.asset.php +1 -1
- build/blocks-checkout.js +0 -1
assets/css/abstracts/_mixins.scss
CHANGED
@@ -32,8 +32,8 @@ $fontSizes: (
|
|
32 |
@mixin placeholder($include-border-radius: true) {
|
33 |
outline: 0 !important;
|
34 |
border: 0 !important;
|
35 |
-
background-color:
|
36 |
-
color:
|
37 |
width: 100%;
|
38 |
@if $include-border-radius == true {
|
39 |
border-radius: 0.25rem;
|
@@ -46,6 +46,7 @@ $fontSizes: (
|
|
46 |
pointer-events: none;
|
47 |
box-shadow: none;
|
48 |
z-index: 1; /* Necessary for overflow: hidden to work correctly in Safari */
|
|
|
49 |
|
50 |
// Forces direct descendants to keep layout but lose visibility.
|
51 |
> * {
|
@@ -61,7 +62,7 @@ $fontSizes: (
|
|
61 |
top: 0;
|
62 |
height: 100%;
|
63 |
background-repeat: no-repeat;
|
64 |
-
background-image: linear-gradient(90deg,
|
65 |
transform: translateX(-100%);
|
66 |
animation: loading__animation 1.5s ease-in-out infinite;
|
67 |
}
|
32 |
@mixin placeholder($include-border-radius: true) {
|
33 |
outline: 0 !important;
|
34 |
border: 0 !important;
|
35 |
+
background-color: currentColor !important;
|
36 |
+
color: currentColor !important;
|
37 |
width: 100%;
|
38 |
@if $include-border-radius == true {
|
39 |
border-radius: 0.25rem;
|
46 |
pointer-events: none;
|
47 |
box-shadow: none;
|
48 |
z-index: 1; /* Necessary for overflow: hidden to work correctly in Safari */
|
49 |
+
opacity: 0.15;
|
50 |
|
51 |
// Forces direct descendants to keep layout but lose visibility.
|
52 |
> * {
|
62 |
top: 0;
|
63 |
height: 100%;
|
64 |
background-repeat: no-repeat;
|
65 |
+
background-image: linear-gradient(90deg, currentColor, #f5f5f54d, currentColor);
|
66 |
transform: translateX(-100%);
|
67 |
animation: loading__animation 1.5s ease-in-out infinite;
|
68 |
}
|
assets/js/atomic/blocks/product-elements/add-to-cart/product-types/variable/variation-attributes/attribute-select-control.js
CHANGED
@@ -6,7 +6,7 @@ import { decodeEntities } from '@wordpress/html-entities';
|
|
6 |
import { SelectControl } from 'wordpress-components';
|
7 |
import { useEffect } from 'react';
|
8 |
import classnames from 'classnames';
|
9 |
-
import { ValidationInputError } from '@woocommerce/
|
10 |
import { VALIDATION_STORE_KEY } from '@woocommerce/block-data';
|
11 |
import { useDispatch, useSelect } from '@wordpress/data';
|
12 |
|
6 |
import { SelectControl } from 'wordpress-components';
|
7 |
import { useEffect } from 'react';
|
8 |
import classnames from 'classnames';
|
9 |
+
import { ValidationInputError } from '@woocommerce/blocks-checkout';
|
10 |
import { VALIDATION_STORE_KEY } from '@woocommerce/block-data';
|
11 |
import { useDispatch, useSelect } from '@wordpress/data';
|
12 |
|
assets/js/atomic/blocks/product-elements/image/attributes.ts
CHANGED
@@ -1,4 +1,30 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
showProductLink: {
|
3 |
type: 'boolean',
|
4 |
default: true,
|
@@ -24,3 +50,5 @@ export const attributes = {
|
|
24 |
default: false,
|
25 |
},
|
26 |
};
|
|
|
|
1 |
+
interface BlockAttributes {
|
2 |
+
productId: {
|
3 |
+
type: string;
|
4 |
+
default: number;
|
5 |
+
};
|
6 |
+
showProductLink: {
|
7 |
+
type: string;
|
8 |
+
default: boolean;
|
9 |
+
};
|
10 |
+
showSaleBadge: {
|
11 |
+
type: string;
|
12 |
+
default: boolean;
|
13 |
+
};
|
14 |
+
saleBadgeAlign: {
|
15 |
+
type: string;
|
16 |
+
default: string;
|
17 |
+
};
|
18 |
+
imageSizing: {
|
19 |
+
type: string;
|
20 |
+
default: string;
|
21 |
+
};
|
22 |
+
isDescendentOfQueryLoop: {
|
23 |
+
type: string;
|
24 |
+
default: boolean;
|
25 |
+
};
|
26 |
+
}
|
27 |
+
export const blockAttributes: BlockAttributes = {
|
28 |
showProductLink: {
|
29 |
type: 'boolean',
|
30 |
default: true,
|
50 |
default: false,
|
51 |
},
|
52 |
};
|
53 |
+
|
54 |
+
export default blockAttributes;
|
assets/js/atomic/blocks/product-elements/image/{block.js → block.tsx}
RENAMED
@@ -1,7 +1,6 @@
|
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
-
import PropTypes from 'prop-types';
|
5 |
import { Fragment } from '@wordpress/element';
|
6 |
import { __, sprintf } from '@wordpress/i18n';
|
7 |
import classnames from 'classnames';
|
@@ -17,26 +16,69 @@ import {
|
|
17 |
} from '@woocommerce/base-hooks';
|
18 |
import { withProductDataContext } from '@woocommerce/shared-hocs';
|
19 |
import { useStoreEvents } from '@woocommerce/base-context/hooks';
|
|
|
20 |
|
21 |
/**
|
22 |
* Internal dependencies
|
23 |
*/
|
24 |
import ProductSaleBadge from '../sale-badge/block';
|
25 |
import './style.scss';
|
|
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
const {
|
41 |
className,
|
42 |
imageSizing = 'full-size',
|
@@ -44,12 +86,9 @@ export const Block = ( props ) => {
|
|
44 |
showSaleBadge,
|
45 |
saleBadgeAlign = 'right',
|
46 |
} = props;
|
47 |
-
|
48 |
const { parentClassName } = useInnerBlockLayoutContext();
|
49 |
const { product, isLoading } = useProductDataContext();
|
50 |
-
|
51 |
const { dispatchStoreEvent } = useStoreEvents();
|
52 |
-
|
53 |
const typographyProps = useTypographyProps( props );
|
54 |
const borderProps = useBorderProps( props );
|
55 |
const spacingProps = useSpacingProps( props );
|
@@ -128,38 +167,4 @@ export const Block = ( props ) => {
|
|
128 |
);
|
129 |
};
|
130 |
|
131 |
-
const ImagePlaceholder = () => {
|
132 |
-
return (
|
133 |
-
<img src={ PLACEHOLDER_IMG_SRC } alt="" width={ 500 } height={ 500 } />
|
134 |
-
);
|
135 |
-
};
|
136 |
-
|
137 |
-
const Image = ( { image, loaded, showFullSize, fallbackAlt } ) => {
|
138 |
-
const { thumbnail, src, srcset, sizes, alt } = image || {};
|
139 |
-
const imageProps = {
|
140 |
-
alt: alt || fallbackAlt,
|
141 |
-
hidden: ! loaded,
|
142 |
-
src: thumbnail,
|
143 |
-
...( showFullSize && { src, srcSet: srcset, sizes } ),
|
144 |
-
};
|
145 |
-
|
146 |
-
return (
|
147 |
-
<>
|
148 |
-
{ imageProps.src && (
|
149 |
-
/* eslint-disable-next-line jsx-a11y/alt-text */
|
150 |
-
<img data-testid="product-image" { ...imageProps } />
|
151 |
-
) }
|
152 |
-
{ ! image && <ImagePlaceholder /> }
|
153 |
-
</>
|
154 |
-
);
|
155 |
-
};
|
156 |
-
|
157 |
-
Block.propTypes = {
|
158 |
-
className: PropTypes.string,
|
159 |
-
fallbackAlt: PropTypes.string,
|
160 |
-
showProductLink: PropTypes.bool,
|
161 |
-
showSaleBadge: PropTypes.bool,
|
162 |
-
saleBadgeAlign: PropTypes.string,
|
163 |
-
};
|
164 |
-
|
165 |
export default withProductDataContext( Block );
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
|
|
4 |
import { Fragment } from '@wordpress/element';
|
5 |
import { __, sprintf } from '@wordpress/i18n';
|
6 |
import classnames from 'classnames';
|
16 |
} from '@woocommerce/base-hooks';
|
17 |
import { withProductDataContext } from '@woocommerce/shared-hocs';
|
18 |
import { useStoreEvents } from '@woocommerce/base-context/hooks';
|
19 |
+
import type { HTMLAttributes } from 'react';
|
20 |
|
21 |
/**
|
22 |
* Internal dependencies
|
23 |
*/
|
24 |
import ProductSaleBadge from '../sale-badge/block';
|
25 |
import './style.scss';
|
26 |
+
import type { BlockAttributes } from './types';
|
27 |
|
28 |
+
const ImagePlaceholder = (): JSX.Element => {
|
29 |
+
return (
|
30 |
+
<img
|
31 |
+
src={ PLACEHOLDER_IMG_SRC }
|
32 |
+
alt=""
|
33 |
+
width={ undefined }
|
34 |
+
height={ undefined }
|
35 |
+
/>
|
36 |
+
);
|
37 |
+
};
|
38 |
+
|
39 |
+
interface ImageProps {
|
40 |
+
image?: null | {
|
41 |
+
alt?: string | undefined;
|
42 |
+
id: number;
|
43 |
+
name: string;
|
44 |
+
sizes?: string | undefined;
|
45 |
+
src?: string | undefined;
|
46 |
+
srcset?: string | undefined;
|
47 |
+
thumbnail?: string | undefined;
|
48 |
+
};
|
49 |
+
loaded: boolean;
|
50 |
+
showFullSize: boolean;
|
51 |
+
fallbackAlt: string;
|
52 |
+
}
|
53 |
+
|
54 |
+
const Image = ( {
|
55 |
+
image,
|
56 |
+
loaded,
|
57 |
+
showFullSize,
|
58 |
+
fallbackAlt,
|
59 |
+
}: ImageProps ): JSX.Element => {
|
60 |
+
const { thumbnail, src, srcset, sizes, alt } = image || {};
|
61 |
+
const imageProps = {
|
62 |
+
alt: alt || fallbackAlt,
|
63 |
+
hidden: ! loaded,
|
64 |
+
src: thumbnail,
|
65 |
+
...( showFullSize && { src, srcSet: srcset, sizes } ),
|
66 |
+
};
|
67 |
+
|
68 |
+
return (
|
69 |
+
<>
|
70 |
+
{ imageProps.src && (
|
71 |
+
/* eslint-disable-next-line jsx-a11y/alt-text */
|
72 |
+
<img data-testid="product-image" { ...imageProps } />
|
73 |
+
) }
|
74 |
+
{ ! image && <ImagePlaceholder /> }
|
75 |
+
</>
|
76 |
+
);
|
77 |
+
};
|
78 |
+
|
79 |
+
type Props = BlockAttributes & HTMLAttributes< HTMLDivElement >;
|
80 |
+
|
81 |
+
export const Block = ( props: Props ): JSX.Element | null => {
|
82 |
const {
|
83 |
className,
|
84 |
imageSizing = 'full-size',
|
86 |
showSaleBadge,
|
87 |
saleBadgeAlign = 'right',
|
88 |
} = props;
|
|
|
89 |
const { parentClassName } = useInnerBlockLayoutContext();
|
90 |
const { product, isLoading } = useProductDataContext();
|
|
|
91 |
const { dispatchStoreEvent } = useStoreEvents();
|
|
|
92 |
const typographyProps = useTypographyProps( props );
|
93 |
const borderProps = useBorderProps( props );
|
94 |
const spacingProps = useSpacingProps( props );
|
167 |
);
|
168 |
};
|
169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
export default withProductDataContext( Block );
|
assets/js/atomic/blocks/product-elements/image/constants.tsx
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { __ } from '@wordpress/i18n';
|
5 |
+
import { image, Icon } from '@wordpress/icons';
|
6 |
+
|
7 |
+
export const BLOCK_TITLE: string = __(
|
8 |
+
'Product Image',
|
9 |
+
'woo-gutenberg-products-block'
|
10 |
+
);
|
11 |
+
export const BLOCK_ICON: JSX.Element = (
|
12 |
+
<Icon icon={ image } className="wc-block-editor-components-block-icon" />
|
13 |
+
);
|
14 |
+
export const BLOCK_DESCRIPTION: string = __(
|
15 |
+
'Display the main product image.',
|
16 |
+
'woo-gutenberg-products-block'
|
17 |
+
);
|
assets/js/atomic/blocks/product-elements/image/{edit.js → edit.tsx}
RENAMED
@@ -6,12 +6,18 @@ import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
|
|
6 |
import { createInterpolateElement, useEffect } from '@wordpress/element';
|
7 |
import { getAdminLink, getSettingWithCoercion } from '@woocommerce/settings';
|
8 |
import { isBoolean } from '@woocommerce/types';
|
|
|
|
|
9 |
import {
|
10 |
Disabled,
|
11 |
PanelBody,
|
12 |
ToggleControl,
|
|
|
|
|
13 |
// eslint-disable-next-line @wordpress/no-unsafe-wp-apis
|
14 |
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
|
|
|
15 |
// eslint-disable-next-line @wordpress/no-unsafe-wp-apis
|
16 |
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
17 |
} from '@wordpress/components';
|
@@ -20,26 +26,37 @@ import {
|
|
20 |
* Internal dependencies
|
21 |
*/
|
22 |
import Block from './block';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
-
const Edit = ( {
|
|
|
|
|
|
|
|
|
25 |
const { showProductLink, imageSizing, showSaleBadge, saleBadgeAlign } =
|
26 |
attributes;
|
27 |
-
|
28 |
const blockProps = useBlockProps();
|
29 |
-
|
30 |
const isDescendentOfQueryLoop = Number.isFinite( context.queryId );
|
31 |
-
|
32 |
-
useEffect(
|
33 |
-
() => setAttributes( { isDescendentOfQueryLoop } ),
|
34 |
-
[ setAttributes, isDescendentOfQueryLoop ]
|
35 |
-
);
|
36 |
-
|
37 |
const isBlockThemeEnabled = getSettingWithCoercion(
|
38 |
'is_block_theme_enabled',
|
39 |
false,
|
40 |
isBoolean
|
41 |
);
|
42 |
|
|
|
|
|
|
|
|
|
|
|
43 |
useEffect( () => {
|
44 |
if ( isBlockThemeEnabled && attributes.imageSizing !== 'full-size' ) {
|
45 |
setAttributes( { imageSizing: 'full-size' } );
|
@@ -91,7 +108,7 @@ const Edit = ( { attributes, setAttributes, context } ) => {
|
|
91 |
'woo-gutenberg-products-block'
|
92 |
) }
|
93 |
value={ saleBadgeAlign }
|
94 |
-
onChange={ ( value ) =>
|
95 |
setAttributes( { saleBadgeAlign: value } )
|
96 |
}
|
97 |
>
|
@@ -143,7 +160,7 @@ const Edit = ( { attributes, setAttributes, context } ) => {
|
|
143 |
}
|
144 |
) }
|
145 |
value={ imageSizing }
|
146 |
-
onChange={ ( value ) =>
|
147 |
setAttributes( { imageSizing: value } )
|
148 |
}
|
149 |
>
|
@@ -172,4 +189,4 @@ const Edit = ( { attributes, setAttributes, context } ) => {
|
|
172 |
);
|
173 |
};
|
174 |
|
175 |
-
export default Edit;
|
6 |
import { createInterpolateElement, useEffect } from '@wordpress/element';
|
7 |
import { getAdminLink, getSettingWithCoercion } from '@woocommerce/settings';
|
8 |
import { isBoolean } from '@woocommerce/types';
|
9 |
+
import type { BlockEditProps } from '@wordpress/blocks';
|
10 |
+
import { ProductQueryContext as Context } from '@woocommerce/blocks/product-query/types';
|
11 |
import {
|
12 |
Disabled,
|
13 |
PanelBody,
|
14 |
ToggleControl,
|
15 |
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
16 |
+
// @ts-ignore - Ignoring because `__experimentalToggleGroupControl` is not yet in the type definitions.
|
17 |
// eslint-disable-next-line @wordpress/no-unsafe-wp-apis
|
18 |
__experimentalToggleGroupControl as ToggleGroupControl,
|
19 |
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
20 |
+
// @ts-ignore - Ignoring because `__experimentalToggleGroupControl` is not yet in the type definitions.
|
21 |
// eslint-disable-next-line @wordpress/no-unsafe-wp-apis
|
22 |
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
23 |
} from '@wordpress/components';
|
26 |
* Internal dependencies
|
27 |
*/
|
28 |
import Block from './block';
|
29 |
+
import withProductSelector from '../shared/with-product-selector';
|
30 |
+
import {
|
31 |
+
BLOCK_TITLE as label,
|
32 |
+
BLOCK_ICON as icon,
|
33 |
+
BLOCK_DESCRIPTION as description,
|
34 |
+
} from './constants';
|
35 |
+
import type { BlockAttributes } from './types';
|
36 |
+
|
37 |
+
type SaleBadgeAlignProps = 'left' | 'center' | 'right';
|
38 |
+
type ImageSizingProps = 'full-size' | 'cropped';
|
39 |
|
40 |
+
const Edit = ( {
|
41 |
+
attributes,
|
42 |
+
setAttributes,
|
43 |
+
context,
|
44 |
+
}: BlockEditProps< BlockAttributes > & { context: Context } ): JSX.Element => {
|
45 |
const { showProductLink, imageSizing, showSaleBadge, saleBadgeAlign } =
|
46 |
attributes;
|
|
|
47 |
const blockProps = useBlockProps();
|
|
|
48 |
const isDescendentOfQueryLoop = Number.isFinite( context.queryId );
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
const isBlockThemeEnabled = getSettingWithCoercion(
|
50 |
'is_block_theme_enabled',
|
51 |
false,
|
52 |
isBoolean
|
53 |
);
|
54 |
|
55 |
+
useEffect(
|
56 |
+
() => setAttributes( { isDescendentOfQueryLoop } ),
|
57 |
+
[ setAttributes, isDescendentOfQueryLoop ]
|
58 |
+
);
|
59 |
+
|
60 |
useEffect( () => {
|
61 |
if ( isBlockThemeEnabled && attributes.imageSizing !== 'full-size' ) {
|
62 |
setAttributes( { imageSizing: 'full-size' } );
|
108 |
'woo-gutenberg-products-block'
|
109 |
) }
|
110 |
value={ saleBadgeAlign }
|
111 |
+
onChange={ ( value: SaleBadgeAlignProps ) =>
|
112 |
setAttributes( { saleBadgeAlign: value } )
|
113 |
}
|
114 |
>
|
160 |
}
|
161 |
) }
|
162 |
value={ imageSizing }
|
163 |
+
onChange={ ( value: ImageSizingProps ) =>
|
164 |
setAttributes( { imageSizing: value } )
|
165 |
}
|
166 |
>
|
189 |
);
|
190 |
};
|
191 |
|
192 |
+
export default withProductSelector( { icon, label, description } )( Edit );
|
assets/js/atomic/blocks/product-elements/image/{frontend.js → frontend.ts}
RENAMED
@@ -7,6 +7,6 @@ import { withFilteredAttributes } from '@woocommerce/shared-hocs';
|
|
7 |
* Internal dependencies
|
8 |
*/
|
9 |
import Block from './block';
|
10 |
-
import
|
11 |
|
12 |
export default withFilteredAttributes( attributes )( Block );
|
7 |
* Internal dependencies
|
8 |
*/
|
9 |
import Block from './block';
|
10 |
+
import attributes from './attributes';
|
11 |
|
12 |
export default withFilteredAttributes( attributes )( Block );
|
assets/js/atomic/blocks/product-elements/image/{index.js → index.ts}
RENAMED
@@ -2,8 +2,7 @@
|
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { registerBlockType } from '@wordpress/blocks';
|
5 |
-
import {
|
6 |
-
import { __ } from '@wordpress/i18n';
|
7 |
|
8 |
/**
|
9 |
* Internal dependencies
|
@@ -11,28 +10,28 @@ import { __ } from '@wordpress/i18n';
|
|
11 |
import edit from './edit';
|
12 |
|
13 |
import { supports } from './supports';
|
14 |
-
import
|
15 |
import sharedConfig from '../shared/config';
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
18 |
apiVersion: 2,
|
19 |
name: 'woocommerce/product-image',
|
20 |
-
title
|
21 |
-
icon: {
|
22 |
-
src: (
|
23 |
-
<Icon
|
24 |
-
icon={ image }
|
25 |
-
className="wc-block-editor-components-block-icon"
|
26 |
-
/>
|
27 |
-
),
|
28 |
-
},
|
29 |
keywords: [ 'WooCommerce' ],
|
30 |
-
description
|
31 |
-
'Display the main product image.',
|
32 |
-
'woo-gutenberg-products-block'
|
33 |
-
),
|
34 |
usesContext: [ 'query', 'queryId', 'postId' ],
|
35 |
-
|
36 |
'@woocommerce/all-products',
|
37 |
'@woocommerce/single-product',
|
38 |
'core/post-template',
|
@@ -43,7 +42,4 @@ const blockConfig = {
|
|
43 |
edit,
|
44 |
};
|
45 |
|
46 |
-
registerBlockType( 'woocommerce/product-image', {
|
47 |
-
...sharedConfig,
|
48 |
-
...blockConfig,
|
49 |
-
} );
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { registerBlockType } from '@wordpress/blocks';
|
5 |
+
import type { BlockConfiguration } from '@wordpress/blocks';
|
|
|
6 |
|
7 |
/**
|
8 |
* Internal dependencies
|
10 |
import edit from './edit';
|
11 |
|
12 |
import { supports } from './supports';
|
13 |
+
import attributes from './attributes';
|
14 |
import sharedConfig from '../shared/config';
|
15 |
+
import {
|
16 |
+
BLOCK_TITLE as title,
|
17 |
+
BLOCK_ICON as icon,
|
18 |
+
BLOCK_DESCRIPTION as description,
|
19 |
+
} from './constants';
|
20 |
|
21 |
+
type CustomBlockConfiguration = BlockConfiguration & {
|
22 |
+
ancestor: string[];
|
23 |
+
};
|
24 |
+
|
25 |
+
const blockConfig: CustomBlockConfiguration = {
|
26 |
+
...sharedConfig,
|
27 |
apiVersion: 2,
|
28 |
name: 'woocommerce/product-image',
|
29 |
+
title,
|
30 |
+
icon: { src: icon },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
keywords: [ 'WooCommerce' ],
|
32 |
+
description,
|
|
|
|
|
|
|
33 |
usesContext: [ 'query', 'queryId', 'postId' ],
|
34 |
+
ancestor: [
|
35 |
'@woocommerce/all-products',
|
36 |
'@woocommerce/single-product',
|
37 |
'core/post-template',
|
42 |
edit,
|
43 |
};
|
44 |
|
45 |
+
registerBlockType( 'woocommerce/product-image', { ...blockConfig } );
|
|
|
|
|
|
assets/js/atomic/blocks/product-elements/image/test/block.test.js
CHANGED
@@ -62,8 +62,18 @@ describe( 'Product Image Block', () => {
|
|
62 |
describe( 'with product link', () => {
|
63 |
test( 'should render an anchor with the product image', () => {
|
64 |
const component = render(
|
65 |
-
<ProductDataContextProvider
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
</ProductDataContextProvider>
|
68 |
);
|
69 |
|
@@ -79,15 +89,25 @@ describe( 'Product Image Block', () => {
|
|
79 |
);
|
80 |
|
81 |
const anchor = productImage.closest( 'a' );
|
82 |
-
expect( anchor
|
83 |
productWithImages.permalink
|
84 |
);
|
85 |
} );
|
86 |
|
87 |
test( 'should render an anchor with the placeholder image', () => {
|
88 |
const component = render(
|
89 |
-
<ProductDataContextProvider
|
90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
</ProductDataContextProvider>
|
92 |
);
|
93 |
|
@@ -97,10 +117,10 @@ describe( 'Product Image Block', () => {
|
|
97 |
);
|
98 |
|
99 |
const anchor = placeholderImage.closest( 'a' );
|
100 |
-
expect( anchor
|
101 |
productWithoutImages.permalink
|
102 |
);
|
103 |
-
expect( anchor
|
104 |
`Link to ${ productWithoutImages.name }`
|
105 |
);
|
106 |
} );
|
@@ -109,8 +129,18 @@ describe( 'Product Image Block', () => {
|
|
109 |
describe( 'without product link', () => {
|
110 |
test( 'should render the product image without an anchor wrapper', () => {
|
111 |
const component = render(
|
112 |
-
<ProductDataContextProvider
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
</ProductDataContextProvider>
|
115 |
);
|
116 |
const image = component.getByTestId( 'product-image' );
|
@@ -129,8 +159,18 @@ describe( 'Product Image Block', () => {
|
|
129 |
|
130 |
test( 'should render the placeholder image without an anchor wrapper', () => {
|
131 |
const component = render(
|
132 |
-
<ProductDataContextProvider
|
133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
</ProductDataContextProvider>
|
135 |
);
|
136 |
|
@@ -143,4 +183,31 @@ describe( 'Product Image Block', () => {
|
|
143 |
expect( anchor ).toBe( null );
|
144 |
} );
|
145 |
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
} );
|
62 |
describe( 'with product link', () => {
|
63 |
test( 'should render an anchor with the product image', () => {
|
64 |
const component = render(
|
65 |
+
<ProductDataContextProvider
|
66 |
+
product={ productWithImages }
|
67 |
+
isLoading={ false }
|
68 |
+
>
|
69 |
+
<Block
|
70 |
+
showProductLink={ true }
|
71 |
+
productId={ productWithImages.id }
|
72 |
+
showSaleBadge={ false }
|
73 |
+
saleBadgeAlign={ 'left' }
|
74 |
+
imageSizing={ 'full-size' }
|
75 |
+
isDescendentOfQueryLoop={ false }
|
76 |
+
/>
|
77 |
</ProductDataContextProvider>
|
78 |
);
|
79 |
|
89 |
);
|
90 |
|
91 |
const anchor = productImage.closest( 'a' );
|
92 |
+
expect( anchor?.getAttribute( 'href' ) ).toBe(
|
93 |
productWithImages.permalink
|
94 |
);
|
95 |
} );
|
96 |
|
97 |
test( 'should render an anchor with the placeholder image', () => {
|
98 |
const component = render(
|
99 |
+
<ProductDataContextProvider
|
100 |
+
product={ productWithoutImages }
|
101 |
+
isLoading={ false }
|
102 |
+
>
|
103 |
+
<Block
|
104 |
+
showProductLink={ true }
|
105 |
+
productId={ productWithoutImages.id }
|
106 |
+
showSaleBadge={ false }
|
107 |
+
saleBadgeAlign={ 'left' }
|
108 |
+
imageSizing={ 'full-size' }
|
109 |
+
isDescendentOfQueryLoop={ false }
|
110 |
+
/>
|
111 |
</ProductDataContextProvider>
|
112 |
);
|
113 |
|
117 |
);
|
118 |
|
119 |
const anchor = placeholderImage.closest( 'a' );
|
120 |
+
expect( anchor?.getAttribute( 'href' ) ).toBe(
|
121 |
productWithoutImages.permalink
|
122 |
);
|
123 |
+
expect( anchor?.getAttribute( 'aria-label' ) ).toBe(
|
124 |
`Link to ${ productWithoutImages.name }`
|
125 |
);
|
126 |
} );
|
129 |
describe( 'without product link', () => {
|
130 |
test( 'should render the product image without an anchor wrapper', () => {
|
131 |
const component = render(
|
132 |
+
<ProductDataContextProvider
|
133 |
+
product={ productWithImages }
|
134 |
+
isLoading={ false }
|
135 |
+
>
|
136 |
+
<Block
|
137 |
+
showProductLink={ false }
|
138 |
+
productId={ productWithImages.id }
|
139 |
+
showSaleBadge={ false }
|
140 |
+
saleBadgeAlign={ 'left' }
|
141 |
+
imageSizing={ 'full-size' }
|
142 |
+
isDescendentOfQueryLoop={ false }
|
143 |
+
/>
|
144 |
</ProductDataContextProvider>
|
145 |
);
|
146 |
const image = component.getByTestId( 'product-image' );
|
159 |
|
160 |
test( 'should render the placeholder image without an anchor wrapper', () => {
|
161 |
const component = render(
|
162 |
+
<ProductDataContextProvider
|
163 |
+
product={ productWithoutImages }
|
164 |
+
isLoading={ false }
|
165 |
+
>
|
166 |
+
<Block
|
167 |
+
showProductLink={ false }
|
168 |
+
productId={ productWithoutImages.id }
|
169 |
+
showSaleBadge={ false }
|
170 |
+
saleBadgeAlign={ 'left' }
|
171 |
+
imageSizing={ 'full-size' }
|
172 |
+
isDescendentOfQueryLoop={ false }
|
173 |
+
/>
|
174 |
</ProductDataContextProvider>
|
175 |
);
|
176 |
|
183 |
expect( anchor ).toBe( null );
|
184 |
} );
|
185 |
} );
|
186 |
+
|
187 |
+
describe( 'without image', () => {
|
188 |
+
test( 'should render the placeholder with no inline width or height attributes', () => {
|
189 |
+
const component = render(
|
190 |
+
<ProductDataContextProvider
|
191 |
+
product={ productWithoutImages }
|
192 |
+
isLoading={ false }
|
193 |
+
>
|
194 |
+
<Block
|
195 |
+
showProductLink={ true }
|
196 |
+
productId={ productWithoutImages.id }
|
197 |
+
showSaleBadge={ false }
|
198 |
+
saleBadgeAlign={ 'left' }
|
199 |
+
imageSizing={ 'full-size' }
|
200 |
+
isDescendentOfQueryLoop={ false }
|
201 |
+
/>
|
202 |
+
</ProductDataContextProvider>
|
203 |
+
);
|
204 |
+
|
205 |
+
const placeholderImage = component.getByAltText( '' );
|
206 |
+
expect( placeholderImage.getAttribute( 'src' ) ).toBe(
|
207 |
+
'placeholder.jpg'
|
208 |
+
);
|
209 |
+
expect( placeholderImage.getAttribute( 'width' ) ).toBe( null );
|
210 |
+
expect( placeholderImage.getAttribute( 'height' ) ).toBe( null );
|
211 |
+
} );
|
212 |
+
} );
|
213 |
} );
|
assets/js/atomic/blocks/product-elements/image/types.ts
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export interface BlockAttributes {
|
2 |
+
// The product ID.
|
3 |
+
productId: number;
|
4 |
+
// CSS Class name for the component.
|
5 |
+
className?: string | undefined;
|
6 |
+
// Whether or not to display a link to the product page.
|
7 |
+
showProductLink: boolean;
|
8 |
+
// Whether or not to display the on sale badge.
|
9 |
+
showSaleBadge: boolean;
|
10 |
+
// How should the sale badge be aligned if displayed.
|
11 |
+
saleBadgeAlign: 'left' | 'center' | 'right';
|
12 |
+
// Size of image to use.
|
13 |
+
imageSizing: 'full-size' | 'cropped';
|
14 |
+
// Whether or not be a children of Query Loop Block.
|
15 |
+
isDescendentOfQueryLoop: boolean;
|
16 |
+
}
|
assets/js/atomic/blocks/product-elements/sku/attributes.ts
CHANGED
@@ -3,6 +3,10 @@ export const blockAttributes: Record< string, Record< string, unknown > > = {
|
|
3 |
type: 'number',
|
4 |
default: 0,
|
5 |
},
|
|
|
|
|
|
|
|
|
6 |
};
|
7 |
|
8 |
export default blockAttributes;
|
3 |
type: 'number',
|
4 |
default: 0,
|
5 |
},
|
6 |
+
isDescendentOfQueryLoop: {
|
7 |
+
type: 'boolean',
|
8 |
+
default: false,
|
9 |
+
},
|
10 |
};
|
11 |
|
12 |
export default blockAttributes;
|
assets/js/atomic/blocks/product-elements/sku/block.tsx
CHANGED
@@ -14,9 +14,9 @@ import type { HTMLAttributes } from 'react';
|
|
14 |
* Internal dependencies
|
15 |
*/
|
16 |
import './style.scss';
|
17 |
-
import type {
|
18 |
|
19 |
-
type Props =
|
20 |
|
21 |
const Block = ( props: Props ): JSX.Element | null => {
|
22 |
const { className } = props;
|
14 |
* Internal dependencies
|
15 |
*/
|
16 |
import './style.scss';
|
17 |
+
import type { Attributes } from './types';
|
18 |
|
19 |
+
type Props = Attributes & HTMLAttributes< HTMLDivElement >;
|
20 |
|
21 |
const Block = ( props: Props ): JSX.Element | null => {
|
22 |
const { className } = props;
|
assets/js/atomic/blocks/product-elements/sku/edit.tsx
CHANGED
@@ -2,7 +2,10 @@
|
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { __ } from '@wordpress/i18n';
|
|
|
5 |
import EditProductLink from '@woocommerce/editor-components/edit-product-link';
|
|
|
|
|
6 |
|
7 |
/**
|
8 |
* Internal dependencies
|
@@ -10,17 +13,28 @@ import EditProductLink from '@woocommerce/editor-components/edit-product-link';
|
|
10 |
import Block from './block';
|
11 |
import withProductSelector from '../shared/with-product-selector';
|
12 |
import { BLOCK_TITLE, BLOCK_ICON } from './constants';
|
13 |
-
import type {
|
14 |
|
15 |
-
|
16 |
-
attributes
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
-
const Edit = ( { attributes }: Props ): JSX.Element => {
|
20 |
return (
|
21 |
<>
|
22 |
<EditProductLink />
|
23 |
-
<Block { ...
|
24 |
</>
|
25 |
);
|
26 |
};
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { __ } from '@wordpress/i18n';
|
5 |
+
import type { BlockEditProps } from '@wordpress/blocks';
|
6 |
import EditProductLink from '@woocommerce/editor-components/edit-product-link';
|
7 |
+
import { ProductQueryContext as Context } from '@woocommerce/blocks/product-query/types';
|
8 |
+
import { useEffect } from 'react';
|
9 |
|
10 |
/**
|
11 |
* Internal dependencies
|
13 |
import Block from './block';
|
14 |
import withProductSelector from '../shared/with-product-selector';
|
15 |
import { BLOCK_TITLE, BLOCK_ICON } from './constants';
|
16 |
+
import type { Attributes } from './types';
|
17 |
|
18 |
+
const Edit = ( {
|
19 |
+
attributes,
|
20 |
+
setAttributes,
|
21 |
+
context,
|
22 |
+
}: BlockEditProps< Attributes > & { context: Context } ): JSX.Element => {
|
23 |
+
const blockAttrs = {
|
24 |
+
...attributes,
|
25 |
+
...context,
|
26 |
+
};
|
27 |
+
const isDescendentOfQueryLoop = Number.isFinite( context.queryId );
|
28 |
+
|
29 |
+
useEffect(
|
30 |
+
() => setAttributes( { isDescendentOfQueryLoop } ),
|
31 |
+
[ setAttributes, isDescendentOfQueryLoop ]
|
32 |
+
);
|
33 |
|
|
|
34 |
return (
|
35 |
<>
|
36 |
<EditProductLink />
|
37 |
+
<Block { ...blockAttrs } />
|
38 |
</>
|
39 |
);
|
40 |
};
|
assets/js/atomic/blocks/product-elements/sku/index.ts
CHANGED
@@ -17,11 +17,16 @@ import {
|
|
17 |
} from './constants';
|
18 |
|
19 |
const blockConfig: BlockConfiguration = {
|
20 |
-
...sharedConfig,
|
21 |
apiVersion: 2,
|
22 |
title,
|
23 |
description,
|
24 |
icon: { src: icon },
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
attributes,
|
26 |
edit,
|
27 |
};
|
17 |
} from './constants';
|
18 |
|
19 |
const blockConfig: BlockConfiguration = {
|
|
|
20 |
apiVersion: 2,
|
21 |
title,
|
22 |
description,
|
23 |
icon: { src: icon },
|
24 |
+
usesContext: [ 'query', 'queryId', 'postId' ],
|
25 |
+
ancestor: [
|
26 |
+
'@woocommerce/all-products',
|
27 |
+
'@woocommerce/single-product',
|
28 |
+
'core/post-template',
|
29 |
+
],
|
30 |
attributes,
|
31 |
edit,
|
32 |
};
|
assets/js/atomic/blocks/product-elements/sku/types.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
-
export interface
|
2 |
-
|
|
|
3 |
}
|
1 |
+
export interface Attributes {
|
2 |
+
productId: number;
|
3 |
+
isDescendentOfQueryLoop: boolean;
|
4 |
}
|
assets/js/atomic/blocks/product-elements/stock-indicator/attributes.js
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
export const blockAttributes = {
|
2 |
-
productId: {
|
3 |
-
type: 'number',
|
4 |
-
default: 0,
|
5 |
-
},
|
6 |
-
};
|
7 |
-
|
8 |
-
export default blockAttributes;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/atomic/blocks/product-elements/stock-indicator/attributes.ts
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
interface BlockAttributes {
|
2 |
+
productId: {
|
3 |
+
type: string;
|
4 |
+
default: number;
|
5 |
+
};
|
6 |
+
}
|
7 |
+
|
8 |
+
export const blockAttributes: BlockAttributes = {
|
9 |
+
productId: {
|
10 |
+
type: 'number',
|
11 |
+
default: 0,
|
12 |
+
},
|
13 |
+
};
|
14 |
+
|
15 |
+
export default blockAttributes;
|
assets/js/atomic/blocks/product-elements/stock-indicator/{block.js → block.tsx}
RENAMED
@@ -2,7 +2,6 @@
|
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { __, sprintf } from '@wordpress/i18n';
|
5 |
-
import PropTypes from 'prop-types';
|
6 |
import classnames from 'classnames';
|
7 |
import {
|
8 |
useInnerBlockLayoutContext,
|
@@ -10,20 +9,35 @@ import {
|
|
10 |
} from '@woocommerce/shared-context';
|
11 |
import { useColorProps, useTypographyProps } from '@woocommerce/base-hooks';
|
12 |
import { withProductDataContext } from '@woocommerce/shared-hocs';
|
|
|
13 |
|
14 |
/**
|
15 |
* Internal dependencies
|
16 |
*/
|
17 |
import './style.scss';
|
|
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
const { className } = props;
|
28 |
const { parentClassName } = useInnerBlockLayoutContext();
|
29 |
const { product } = useProductDataContext();
|
@@ -66,26 +80,4 @@ const Block = ( props ) => {
|
|
66 |
);
|
67 |
};
|
68 |
|
69 |
-
const lowStockText = ( lowStock ) => {
|
70 |
-
return sprintf(
|
71 |
-
/* translators: %d stock amount (number of items in stock for product) */
|
72 |
-
__( '%d left in stock', 'woo-gutenberg-products-block' ),
|
73 |
-
lowStock
|
74 |
-
);
|
75 |
-
};
|
76 |
-
|
77 |
-
const stockText = ( inStock, isBackordered ) => {
|
78 |
-
if ( isBackordered ) {
|
79 |
-
return __( 'Available on backorder', 'woo-gutenberg-products-block' );
|
80 |
-
}
|
81 |
-
|
82 |
-
return inStock
|
83 |
-
? __( 'In Stock', 'woo-gutenberg-products-block' )
|
84 |
-
: __( 'Out of Stock', 'woo-gutenberg-products-block' );
|
85 |
-
};
|
86 |
-
|
87 |
-
Block.propTypes = {
|
88 |
-
className: PropTypes.string,
|
89 |
-
};
|
90 |
-
|
91 |
export default withProductDataContext( Block );
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { __, sprintf } from '@wordpress/i18n';
|
|
|
5 |
import classnames from 'classnames';
|
6 |
import {
|
7 |
useInnerBlockLayoutContext,
|
9 |
} from '@woocommerce/shared-context';
|
10 |
import { useColorProps, useTypographyProps } from '@woocommerce/base-hooks';
|
11 |
import { withProductDataContext } from '@woocommerce/shared-hocs';
|
12 |
+
import type { HTMLAttributes } from 'react';
|
13 |
|
14 |
/**
|
15 |
* Internal dependencies
|
16 |
*/
|
17 |
import './style.scss';
|
18 |
+
import type { BlockAttributes } from './types';
|
19 |
|
20 |
+
const lowStockText = ( lowStock: string ): string => {
|
21 |
+
return sprintf(
|
22 |
+
/* translators: %d stock amount (number of items in stock for product) */
|
23 |
+
__( '%d left in stock', 'woo-gutenberg-products-block' ),
|
24 |
+
lowStock
|
25 |
+
);
|
26 |
+
};
|
27 |
+
|
28 |
+
const stockText = ( inStock: boolean, isBackordered: boolean ): string => {
|
29 |
+
if ( isBackordered ) {
|
30 |
+
return __( 'Available on backorder', 'woo-gutenberg-products-block' );
|
31 |
+
}
|
32 |
+
|
33 |
+
return inStock
|
34 |
+
? __( 'In Stock', 'woo-gutenberg-products-block' )
|
35 |
+
: __( 'Out of Stock', 'woo-gutenberg-products-block' );
|
36 |
+
};
|
37 |
+
|
38 |
+
type Props = BlockAttributes & HTMLAttributes< HTMLDivElement >;
|
39 |
+
|
40 |
+
export const Block = ( props: Props ): JSX.Element | null => {
|
41 |
const { className } = props;
|
42 |
const { parentClassName } = useInnerBlockLayoutContext();
|
43 |
const { product } = useProductDataContext();
|
80 |
);
|
81 |
};
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
export default withProductDataContext( Block );
|
assets/js/atomic/blocks/product-elements/stock-indicator/{constants.js → constants.tsx}
RENAMED
@@ -4,14 +4,14 @@
|
|
4 |
import { __ } from '@wordpress/i18n';
|
5 |
import { box, Icon } from '@wordpress/icons';
|
6 |
|
7 |
-
export const BLOCK_TITLE = __(
|
8 |
'Product Stock Indicator',
|
9 |
'woo-gutenberg-products-block'
|
10 |
);
|
11 |
-
export const BLOCK_ICON = (
|
12 |
<Icon icon={ box } className="wc-block-editor-components-block-icon" />
|
13 |
);
|
14 |
-
export const BLOCK_DESCRIPTION = __(
|
15 |
'Display product stock status.',
|
16 |
'woo-gutenberg-products-block'
|
17 |
);
|
4 |
import { __ } from '@wordpress/i18n';
|
5 |
import { box, Icon } from '@wordpress/icons';
|
6 |
|
7 |
+
export const BLOCK_TITLE: string = __(
|
8 |
'Product Stock Indicator',
|
9 |
'woo-gutenberg-products-block'
|
10 |
);
|
11 |
+
export const BLOCK_ICON: JSX.Element = (
|
12 |
<Icon icon={ box } className="wc-block-editor-components-block-icon" />
|
13 |
);
|
14 |
+
export const BLOCK_DESCRIPTION: string = __(
|
15 |
'Display product stock status.',
|
16 |
'woo-gutenberg-products-block'
|
17 |
);
|
assets/js/atomic/blocks/product-elements/stock-indicator/{edit.js → edit.tsx}
RENAMED
@@ -1,7 +1,6 @@
|
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
-
import { __ } from '@wordpress/i18n';
|
5 |
import EditProductLink from '@woocommerce/editor-components/edit-product-link';
|
6 |
import { useBlockProps } from '@wordpress/block-editor';
|
7 |
|
@@ -10,9 +9,18 @@ import { useBlockProps } from '@wordpress/block-editor';
|
|
10 |
*/
|
11 |
import Block from './block';
|
12 |
import withProductSelector from '../shared/with-product-selector';
|
13 |
-
import {
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
-
|
|
|
|
|
|
|
|
|
16 |
const blockProps = useBlockProps();
|
17 |
return (
|
18 |
<div { ...blockProps }>
|
@@ -22,11 +30,4 @@ const Edit = ( { attributes } ) => {
|
|
22 |
);
|
23 |
};
|
24 |
|
25 |
-
export default withProductSelector( {
|
26 |
-
icon: BLOCK_ICON,
|
27 |
-
label: BLOCK_TITLE,
|
28 |
-
description: __(
|
29 |
-
'Choose a product to display its stock.',
|
30 |
-
'woo-gutenberg-products-block'
|
31 |
-
),
|
32 |
-
} )( Edit );
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
|
|
4 |
import EditProductLink from '@woocommerce/editor-components/edit-product-link';
|
5 |
import { useBlockProps } from '@wordpress/block-editor';
|
6 |
|
9 |
*/
|
10 |
import Block from './block';
|
11 |
import withProductSelector from '../shared/with-product-selector';
|
12 |
+
import {
|
13 |
+
BLOCK_TITLE as label,
|
14 |
+
BLOCK_ICON as icon,
|
15 |
+
BLOCK_DESCRIPTION as description,
|
16 |
+
} from './constants';
|
17 |
+
import type { BlockAttributes } from './types';
|
18 |
|
19 |
+
interface Props {
|
20 |
+
attributes: BlockAttributes;
|
21 |
+
}
|
22 |
+
|
23 |
+
const Edit = ( { attributes }: Props ): JSX.Element => {
|
24 |
const blockProps = useBlockProps();
|
25 |
return (
|
26 |
<div { ...blockProps }>
|
30 |
);
|
31 |
};
|
32 |
|
33 |
+
export default withProductSelector( { icon, label, description } )( Edit );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/atomic/blocks/product-elements/stock-indicator/{index.js → index.ts}
RENAMED
@@ -2,6 +2,7 @@
|
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { registerExperimentalBlockType } from '@woocommerce/block-settings';
|
|
|
5 |
|
6 |
/**
|
7 |
* Internal dependencies
|
@@ -18,7 +19,8 @@ import {
|
|
18 |
BLOCK_DESCRIPTION as description,
|
19 |
} from './constants';
|
20 |
|
21 |
-
const blockConfig = {
|
|
|
22 |
apiVersion: 2,
|
23 |
title,
|
24 |
description,
|
@@ -30,6 +32,5 @@ const blockConfig = {
|
|
30 |
};
|
31 |
|
32 |
registerExperimentalBlockType( 'woocommerce/product-stock-indicator', {
|
33 |
-
...sharedConfig,
|
34 |
...blockConfig,
|
35 |
} );
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { registerExperimentalBlockType } from '@woocommerce/block-settings';
|
5 |
+
import type { BlockConfiguration } from '@wordpress/blocks';
|
6 |
|
7 |
/**
|
8 |
* Internal dependencies
|
19 |
BLOCK_DESCRIPTION as description,
|
20 |
} from './constants';
|
21 |
|
22 |
+
const blockConfig: BlockConfiguration = {
|
23 |
+
...sharedConfig,
|
24 |
apiVersion: 2,
|
25 |
title,
|
26 |
description,
|
32 |
};
|
33 |
|
34 |
registerExperimentalBlockType( 'woocommerce/product-stock-indicator', {
|
|
|
35 |
...blockConfig,
|
36 |
} );
|
assets/js/atomic/blocks/product-elements/stock-indicator/{supports.js → supports.ts}
RENAMED
File without changes
|
assets/js/atomic/blocks/product-elements/stock-indicator/types.ts
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
export interface BlockAttributes {
|
2 |
+
productId: number;
|
3 |
+
}
|
assets/js/base/components/block-error-boundary/block-error.tsx
CHANGED
@@ -23,6 +23,9 @@ const BlockError = ( {
|
|
23 |
return showErrorBlock ? (
|
24 |
<div className="wc-block-error wc-block-components-error">
|
25 |
{ imageUrl && (
|
|
|
|
|
|
|
26 |
<img
|
27 |
className="wc-block-error__image wc-block-components-error__image"
|
28 |
src={ imageUrl }
|
23 |
return showErrorBlock ? (
|
24 |
<div className="wc-block-error wc-block-components-error">
|
25 |
{ imageUrl && (
|
26 |
+
// The alt text is left empty on purpose, as it's considered a decorative image.
|
27 |
+
// More can be found here: https://www.w3.org/WAI/tutorials/images/decorative/.
|
28 |
+
// Github discussion for a context: https://github.com/woocommerce/woocommerce-blocks/pull/7651#discussion_r1019560494.
|
29 |
<img
|
30 |
className="wc-block-error__image wc-block-components-error__image"
|
31 |
src={ imageUrl }
|
assets/js/base/components/cart-checkout/address-form/address-form.tsx
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
-
import { ValidatedTextInput } from '@woocommerce/
|
5 |
import {
|
6 |
BillingCountryInput,
|
7 |
ShippingCountryInput,
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
+
import { ValidatedTextInput } from '@woocommerce/blocks-checkout';
|
5 |
import {
|
6 |
BillingCountryInput,
|
7 |
ShippingCountryInput,
|
assets/js/base/components/cart-checkout/product-details/index.tsx
CHANGED
@@ -32,11 +32,13 @@ const ProductDetails = ( {
|
|
32 |
{ details.map( ( detail ) => {
|
33 |
// Support both `key` and `name` props
|
34 |
const name = detail?.key || detail.name || '';
|
35 |
-
const className =
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
40 |
return (
|
41 |
<li
|
42 |
key={ name + ( detail.display || detail.value ) }
|
32 |
{ details.map( ( detail ) => {
|
33 |
// Support both `key` and `name` props
|
34 |
const name = detail?.key || detail.name || '';
|
35 |
+
const className =
|
36 |
+
detail?.className ||
|
37 |
+
( name
|
38 |
+
? `wc-block-components-product-details__${ kebabCase(
|
39 |
+
name
|
40 |
+
) }`
|
41 |
+
: '' );
|
42 |
return (
|
43 |
<li
|
44 |
key={ name + ( detail.display || detail.value ) }
|
assets/js/base/components/cart-checkout/totals/coupon/index.tsx
CHANGED
@@ -4,12 +4,14 @@
|
|
4 |
import { __ } from '@wordpress/i18n';
|
5 |
import { useState, useEffect, useRef } from '@wordpress/element';
|
6 |
import Button from '@woocommerce/base-components/button';
|
7 |
-
import { Panel } from '@woocommerce/blocks-checkout';
|
8 |
import Label from '@woocommerce/base-components/label';
|
9 |
import LoadingMask from '@woocommerce/base-components/loading-mask';
|
10 |
import { withInstanceId } from '@wordpress/compose';
|
11 |
-
import {
|
12 |
-
|
|
|
|
|
|
|
13 |
import { useSelect } from '@wordpress/data';
|
14 |
import { VALIDATION_STORE_KEY } from '@woocommerce/block-data';
|
15 |
|
4 |
import { __ } from '@wordpress/i18n';
|
5 |
import { useState, useEffect, useRef } from '@wordpress/element';
|
6 |
import Button from '@woocommerce/base-components/button';
|
|
|
7 |
import Label from '@woocommerce/base-components/label';
|
8 |
import LoadingMask from '@woocommerce/base-components/loading-mask';
|
9 |
import { withInstanceId } from '@wordpress/compose';
|
10 |
+
import {
|
11 |
+
Panel,
|
12 |
+
ValidatedTextInput,
|
13 |
+
ValidationInputError,
|
14 |
+
} from '@woocommerce/blocks-checkout';
|
15 |
import { useSelect } from '@wordpress/data';
|
16 |
import { VALIDATION_STORE_KEY } from '@woocommerce/block-data';
|
17 |
|
assets/js/base/components/checkbox-list/index.tsx
CHANGED
@@ -141,6 +141,7 @@ const CheckboxList = ( {
|
|
141 |
onChange={ () => {
|
142 |
onChange( option.value );
|
143 |
} }
|
|
|
144 |
/>
|
145 |
</li>
|
146 |
{ shouldTruncateOptions &&
|
141 |
onChange={ () => {
|
142 |
onChange( option.value );
|
143 |
} }
|
144 |
+
disabled={ isDisabled }
|
145 |
/>
|
146 |
</li>
|
147 |
{ shouldTruncateOptions &&
|
assets/js/base/components/combobox/index.tsx
CHANGED
@@ -6,7 +6,7 @@ import { __ } from '@wordpress/i18n';
|
|
6 |
import { useEffect, useRef } from '@wordpress/element';
|
7 |
import { withInstanceId } from '@wordpress/compose';
|
8 |
import { ComboboxControl } from 'wordpress-components';
|
9 |
-
import { ValidationInputError } from '@woocommerce/
|
10 |
import { isObject } from '@woocommerce/types';
|
11 |
import { useDispatch, useSelect } from '@wordpress/data';
|
12 |
import { VALIDATION_STORE_KEY } from '@woocommerce/block-data';
|
6 |
import { useEffect, useRef } from '@wordpress/element';
|
7 |
import { withInstanceId } from '@wordpress/compose';
|
8 |
import { ComboboxControl } from 'wordpress-components';
|
9 |
+
import { ValidationInputError } from '@woocommerce/blocks-checkout';
|
10 |
import { isObject } from '@woocommerce/types';
|
11 |
import { useDispatch, useSelect } from '@wordpress/data';
|
12 |
import { VALIDATION_STORE_KEY } from '@woocommerce/block-data';
|
assets/js/base/components/filter-placeholder/style.scss
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
.wc-block-filter-title-placeholder {
|
2 |
@include placeholder();
|
3 |
-
background-color: $gray-400 !important;
|
4 |
border-radius: em(26px);
|
5 |
box-shadow: none;
|
6 |
min-width: 80px;
|
@@ -8,10 +7,6 @@
|
|
8 |
margin-bottom: $gap-small;
|
9 |
max-width: max-content !important;
|
10 |
|
11 |
-
&::after {
|
12 |
-
background-image: linear-gradient(90deg, $gray-400, $gray-200, $gray-400);
|
13 |
-
}
|
14 |
-
|
15 |
.wc-block-stock-filter__title,
|
16 |
.wc-block-price-filter__title,
|
17 |
.wc-block-active-filters__title,
|
1 |
.wc-block-filter-title-placeholder {
|
2 |
@include placeholder();
|
|
|
3 |
border-radius: em(26px);
|
4 |
box-shadow: none;
|
5 |
min-width: 80px;
|
7 |
margin-bottom: $gap-small;
|
8 |
max-width: max-content !important;
|
9 |
|
|
|
|
|
|
|
|
|
10 |
.wc-block-stock-filter__title,
|
11 |
.wc-block-price-filter__title,
|
12 |
.wc-block-active-filters__title,
|
assets/js/base/components/label/index.tsx
CHANGED
@@ -6,8 +6,8 @@ import classNames from 'classnames';
|
|
6 |
import type { ReactElement, HTMLProps } from 'react';
|
7 |
|
8 |
interface LabelProps extends HTMLProps< HTMLElement > {
|
9 |
-
label?: string;
|
10 |
-
screenReaderLabel?: string;
|
11 |
wrapperElement?: string;
|
12 |
wrapperProps?: HTMLProps< HTMLElement >;
|
13 |
}
|
6 |
import type { ReactElement, HTMLProps } from 'react';
|
7 |
|
8 |
interface LabelProps extends HTMLProps< HTMLElement > {
|
9 |
+
label?: string | undefined;
|
10 |
+
screenReaderLabel?: string | undefined;
|
11 |
wrapperElement?: string;
|
12 |
wrapperProps?: HTMLProps< HTMLElement >;
|
13 |
}
|
assets/js/base/components/product-rating/index.tsx
CHANGED
@@ -32,8 +32,8 @@ const Rating = ( {
|
|
32 |
|
33 |
const ratingHTML = {
|
34 |
__html: sprintf(
|
35 |
-
/* translators: %
|
36 |
-
__( 'Rated %
|
37 |
sprintf( '<strong class="rating">%f</strong>', rating )
|
38 |
),
|
39 |
};
|
32 |
|
33 |
const ratingHTML = {
|
34 |
__html: sprintf(
|
35 |
+
/* translators: %s is the rating value wrapped in HTML strong tags. */
|
36 |
+
__( 'Rated %s out of 5', 'woo-gutenberg-products-block' ),
|
37 |
sprintf( '<strong class="rating">%f</strong>', rating )
|
38 |
),
|
39 |
};
|
assets/js/base/components/reviews/review-list-item/index.js
CHANGED
@@ -27,6 +27,9 @@ function getReviewImage( review, imageType, isLoading ) {
|
|
27 |
src={ review.product_image?.thumbnail || '' }
|
28 |
/>
|
29 |
) : (
|
|
|
|
|
|
|
30 |
<img
|
31 |
aria-hidden="true"
|
32 |
alt=""
|
27 |
src={ review.product_image?.thumbnail || '' }
|
28 |
/>
|
29 |
) : (
|
30 |
+
// The alt text is left empty on purpose, as it's considered a decorative image.
|
31 |
+
// More can be found here: https://www.w3.org/WAI/tutorials/images/decorative/.
|
32 |
+
// Github discussion for a context: https://github.com/woocommerce/woocommerce-blocks/pull/7651#discussion_r1019560494.
|
33 |
<img
|
34 |
aria-hidden="true"
|
35 |
alt=""
|
assets/js/base/components/state-input/state-input.tsx
CHANGED
@@ -5,7 +5,7 @@ import { __ } from '@wordpress/i18n';
|
|
5 |
import { decodeEntities } from '@wordpress/html-entities';
|
6 |
import { useCallback, useMemo, useEffect, useRef } from '@wordpress/element';
|
7 |
import classnames from 'classnames';
|
8 |
-
import { ValidatedTextInput } from '@woocommerce/
|
9 |
|
10 |
/**
|
11 |
* Internal dependencies
|
5 |
import { decodeEntities } from '@wordpress/html-entities';
|
6 |
import { useCallback, useMemo, useEffect, useRef } from '@wordpress/element';
|
7 |
import classnames from 'classnames';
|
8 |
+
import { ValidatedTextInput } from '@woocommerce/blocks-checkout';
|
9 |
|
10 |
/**
|
11 |
* Internal dependencies
|
assets/js/base/components/text-input/index.ts
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
export { default as TextInput } from './text-input';
|
2 |
-
export { default as ValidatedTextInput } from './validated-text-input';
|
|
|
|
assets/js/base/context/hooks/cart/use-store-cart-item-quantity.ts
CHANGED
@@ -6,7 +6,6 @@ import { useCallback, useState, useEffect } from '@wordpress/element';
|
|
6 |
import { CART_STORE_KEY, CHECKOUT_STORE_KEY } from '@woocommerce/block-data';
|
7 |
import { useDebounce } from 'use-debounce';
|
8 |
import { usePrevious } from '@woocommerce/base-hooks';
|
9 |
-
import { triggerFragmentRefresh } from '@woocommerce/base-utils';
|
10 |
import {
|
11 |
CartItem,
|
12 |
StoreCartItemQuantity,
|
@@ -86,10 +85,7 @@ export const useStoreCartItemQuantity = (
|
|
86 |
|
87 |
const removeItem = useCallback( () => {
|
88 |
return cartItemKey
|
89 |
-
? removeItemFromCart( cartItemKey )
|
90 |
-
triggerFragmentRefresh();
|
91 |
-
return true;
|
92 |
-
} )
|
93 |
: Promise.resolve( false );
|
94 |
}, [ cartItemKey, removeItemFromCart ] );
|
95 |
|
6 |
import { CART_STORE_KEY, CHECKOUT_STORE_KEY } from '@woocommerce/block-data';
|
7 |
import { useDebounce } from 'use-debounce';
|
8 |
import { usePrevious } from '@woocommerce/base-hooks';
|
|
|
9 |
import {
|
10 |
CartItem,
|
11 |
StoreCartItemQuantity,
|
85 |
|
86 |
const removeItem = useCallback( () => {
|
87 |
return cartItemKey
|
88 |
+
? removeItemFromCart( cartItemKey )
|
|
|
|
|
|
|
89 |
: Promise.resolve( false );
|
90 |
}, [ cartItemKey, removeItemFromCart ] );
|
91 |
|
assets/js/base/context/hooks/payment-methods/use-payment-method-interface.ts
CHANGED
@@ -12,7 +12,7 @@ import LoadingMask from '@woocommerce/base-components/loading-mask';
|
|
12 |
import type { PaymentMethodInterface } from '@woocommerce/types';
|
13 |
import { useSelect, useDispatch } from '@wordpress/data';
|
14 |
import { CHECKOUT_STORE_KEY, PAYMENT_STORE_KEY } from '@woocommerce/block-data';
|
15 |
-
import { ValidationInputError } from '@woocommerce/
|
16 |
|
17 |
/**
|
18 |
* Internal dependencies
|
@@ -50,12 +50,22 @@ export const usePaymentMethodInterface = (): PaymentMethodInterface => {
|
|
50 |
isCalculating: store.isCalculating(),
|
51 |
};
|
52 |
} );
|
53 |
-
const {
|
54 |
( select ) => {
|
55 |
const store = select( PAYMENT_STORE_KEY );
|
56 |
|
57 |
return {
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
activePaymentMethod: store.getActivePaymentMethod(),
|
60 |
shouldSavePayment: store.getShouldSavePaymentMethod(),
|
61 |
};
|
@@ -168,7 +178,7 @@ export const usePaymentMethodInterface = (): PaymentMethodInterface => {
|
|
168 |
onShippingRateSuccess,
|
169 |
},
|
170 |
onSubmit,
|
171 |
-
paymentStatus
|
172 |
setExpressPaymentError: deprecatedSetExpressPaymentError,
|
173 |
shippingData: {
|
174 |
isSelectingRate,
|
12 |
import type { PaymentMethodInterface } from '@woocommerce/types';
|
13 |
import { useSelect, useDispatch } from '@wordpress/data';
|
14 |
import { CHECKOUT_STORE_KEY, PAYMENT_STORE_KEY } from '@woocommerce/block-data';
|
15 |
+
import { ValidationInputError } from '@woocommerce/blocks-checkout';
|
16 |
|
17 |
/**
|
18 |
* Internal dependencies
|
50 |
isCalculating: store.isCalculating(),
|
51 |
};
|
52 |
} );
|
53 |
+
const { paymentStatus, activePaymentMethod, shouldSavePayment } = useSelect(
|
54 |
( select ) => {
|
55 |
const store = select( PAYMENT_STORE_KEY );
|
56 |
|
57 |
return {
|
58 |
+
// The paymentStatus is exposed to third parties via the payment method interface so the API must not be changed
|
59 |
+
paymentStatus: {
|
60 |
+
isPristine: store.isPaymentPristine(),
|
61 |
+
isStarted: store.isPaymentStarted(),
|
62 |
+
isProcessing: store.isPaymentProcessing(),
|
63 |
+
isFinished: store.isPaymentFinished(),
|
64 |
+
hasError: store.hasPaymentError(),
|
65 |
+
hasFailed: store.isPaymentFailed(),
|
66 |
+
isSuccessful: store.isPaymentSuccess(),
|
67 |
+
isDoingExpressPayment: store.isExpressPaymentMethodActive(),
|
68 |
+
},
|
69 |
activePaymentMethod: store.getActivePaymentMethod(),
|
70 |
shouldSavePayment: store.getShouldSavePaymentMethod(),
|
71 |
};
|
178 |
onShippingRateSuccess,
|
179 |
},
|
180 |
onSubmit,
|
181 |
+
paymentStatus,
|
182 |
setExpressPaymentError: deprecatedSetExpressPaymentError,
|
183 |
shippingData: {
|
184 |
isSelectingRate,
|
assets/js/base/context/hooks/use-checkout-submit.js
CHANGED
@@ -35,13 +35,14 @@ export const useCheckoutSubmit = () => {
|
|
35 |
hasError: store.hasError(),
|
36 |
};
|
37 |
} );
|
38 |
-
const {
|
39 |
( select ) => {
|
40 |
const store = select( PAYMENT_STORE_KEY );
|
41 |
|
42 |
return {
|
43 |
-
currentStatus: store.getCurrentStatus(),
|
44 |
activePaymentMethod: store.getActivePaymentMethod(),
|
|
|
|
|
45 |
};
|
46 |
}
|
47 |
);
|
@@ -65,7 +66,7 @@ export const useCheckoutSubmit = () => {
|
|
65 |
submitButtonText: label,
|
66 |
onSubmit,
|
67 |
isCalculating,
|
68 |
-
isDisabled: isProcessing ||
|
69 |
waitingForProcessing,
|
70 |
waitingForRedirect,
|
71 |
};
|
35 |
hasError: store.hasError(),
|
36 |
};
|
37 |
} );
|
38 |
+
const { activePaymentMethod, isExpressPaymentMethodActive } = useSelect(
|
39 |
( select ) => {
|
40 |
const store = select( PAYMENT_STORE_KEY );
|
41 |
|
42 |
return {
|
|
|
43 |
activePaymentMethod: store.getActivePaymentMethod(),
|
44 |
+
isExpressPaymentMethodActive:
|
45 |
+
store.isExpressPaymentMethodActive(),
|
46 |
};
|
47 |
}
|
48 |
);
|
66 |
submitButtonText: label,
|
67 |
onSubmit,
|
68 |
isCalculating,
|
69 |
+
isDisabled: isProcessing || isExpressPaymentMethodActive,
|
70 |
waitingForProcessing,
|
71 |
waitingForRedirect,
|
72 |
};
|
assets/js/base/context/providers/cart-checkout/checkout-events/index.tsx
CHANGED
@@ -197,7 +197,6 @@ export const CheckoutEventsProvider = ( {
|
|
197 |
checkoutState.orderId,
|
198 |
checkoutState.customerId,
|
199 |
checkoutState.orderNotes,
|
200 |
-
checkoutState.paymentResult,
|
201 |
previousStatus,
|
202 |
previousHasError,
|
203 |
createErrorNotice,
|
197 |
checkoutState.orderId,
|
198 |
checkoutState.customerId,
|
199 |
checkoutState.orderNotes,
|
|
|
200 |
previousStatus,
|
201 |
previousHasError,
|
202 |
createErrorNotice,
|
assets/js/base/context/providers/cart-checkout/checkout-processor.js
CHANGED
@@ -76,7 +76,8 @@ const CheckoutProcessor = () => {
|
|
76 |
activePaymentMethod,
|
77 |
paymentMethodData,
|
78 |
isExpressPaymentMethodActive,
|
79 |
-
|
|
|
80 |
shouldSavePayment,
|
81 |
} = useSelect( ( select ) => {
|
82 |
const store = select( PAYMENT_STORE_KEY );
|
@@ -85,7 +86,8 @@ const CheckoutProcessor = () => {
|
|
85 |
activePaymentMethod: store.getActivePaymentMethod(),
|
86 |
paymentMethodData: store.getPaymentMethodData(),
|
87 |
isExpressPaymentMethodActive: store.isExpressPaymentMethodActive(),
|
88 |
-
|
|
|
89 |
shouldSavePayment: store.getShouldSavePaymentMethod(),
|
90 |
};
|
91 |
}, [] );
|
@@ -107,13 +109,13 @@ const CheckoutProcessor = () => {
|
|
107 |
|
108 |
const checkoutWillHaveError =
|
109 |
( hasValidationErrors() && ! isExpressPaymentMethodActive ) ||
|
110 |
-
|
111 |
shippingErrorStatus.hasError;
|
112 |
|
113 |
const paidAndWithoutErrors =
|
114 |
! checkoutHasError &&
|
115 |
! checkoutWillHaveError &&
|
116 |
-
(
|
117 |
checkoutIsProcessing;
|
118 |
|
119 |
// Determine if checkout has an error.
|
@@ -145,7 +147,7 @@ const CheckoutProcessor = () => {
|
|
145 |
if ( hasValidationErrors() ) {
|
146 |
return false;
|
147 |
}
|
148 |
-
if (
|
149 |
return {
|
150 |
errorMessage: __(
|
151 |
'There was a problem with your payment option.',
|
@@ -163,11 +165,7 @@ const CheckoutProcessor = () => {
|
|
163 |
}
|
164 |
|
165 |
return true;
|
166 |
-
}, [
|
167 |
-
hasValidationErrors,
|
168 |
-
currentPaymentStatus.hasError,
|
169 |
-
shippingErrorStatus.hasError,
|
170 |
-
] );
|
171 |
|
172 |
// Validate the checkout using the CHECKOUT_VALIDATION_BEFORE_PROCESSING event
|
173 |
useEffect( () => {
|
76 |
activePaymentMethod,
|
77 |
paymentMethodData,
|
78 |
isExpressPaymentMethodActive,
|
79 |
+
hasPaymentError,
|
80 |
+
isPaymentSuccess,
|
81 |
shouldSavePayment,
|
82 |
} = useSelect( ( select ) => {
|
83 |
const store = select( PAYMENT_STORE_KEY );
|
86 |
activePaymentMethod: store.getActivePaymentMethod(),
|
87 |
paymentMethodData: store.getPaymentMethodData(),
|
88 |
isExpressPaymentMethodActive: store.isExpressPaymentMethodActive(),
|
89 |
+
hasPaymentError: store.hasPaymentError(),
|
90 |
+
isPaymentSuccess: store.isPaymentSuccess(),
|
91 |
shouldSavePayment: store.getShouldSavePaymentMethod(),
|
92 |
};
|
93 |
}, [] );
|
109 |
|
110 |
const checkoutWillHaveError =
|
111 |
( hasValidationErrors() && ! isExpressPaymentMethodActive ) ||
|
112 |
+
hasPaymentError ||
|
113 |
shippingErrorStatus.hasError;
|
114 |
|
115 |
const paidAndWithoutErrors =
|
116 |
! checkoutHasError &&
|
117 |
! checkoutWillHaveError &&
|
118 |
+
( isPaymentSuccess || ! cartNeedsPayment ) &&
|
119 |
checkoutIsProcessing;
|
120 |
|
121 |
// Determine if checkout has an error.
|
147 |
if ( hasValidationErrors() ) {
|
148 |
return false;
|
149 |
}
|
150 |
+
if ( hasPaymentError ) {
|
151 |
return {
|
152 |
errorMessage: __(
|
153 |
'There was a problem with your payment option.',
|
165 |
}
|
166 |
|
167 |
return true;
|
168 |
+
}, [ hasValidationErrors, hasPaymentError, shippingErrorStatus.hasError ] );
|
|
|
|
|
|
|
|
|
169 |
|
170 |
// Validate the checkout using the CHECKOUT_VALIDATION_BEFORE_PROCESSING event
|
171 |
useEffect( () => {
|
assets/js/base/context/providers/cart-checkout/payment-events/index.tsx
CHANGED
@@ -62,13 +62,16 @@ export const PaymentEventsProvider = ( {
|
|
62 |
isCalculating: store.isCalculating(),
|
63 |
};
|
64 |
} );
|
65 |
-
const {
|
66 |
-
|
|
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
72 |
|
73 |
const { createErrorNotice, removeNotice } = useDispatch( 'core/notices' );
|
74 |
const { setValidationErrors } = useDispatch( VALIDATION_STORE_KEY );
|
@@ -82,7 +85,8 @@ export const PaymentEventsProvider = ( {
|
|
82 |
}, [ observers ] );
|
83 |
|
84 |
const {
|
85 |
-
|
|
|
86 |
__internalSetPaymentMethodData,
|
87 |
__internalEmitPaymentProcessingEvent,
|
88 |
} = useDispatch( PAYMENT_STORE_KEY );
|
@@ -94,39 +98,31 @@ export const PaymentEventsProvider = ( {
|
|
94 |
checkoutIsProcessing &&
|
95 |
! checkoutHasError &&
|
96 |
! checkoutIsCalculating &&
|
97 |
-
!
|
98 |
) {
|
99 |
-
|
100 |
}
|
101 |
}, [
|
102 |
checkoutIsProcessing,
|
103 |
checkoutHasError,
|
104 |
checkoutIsCalculating,
|
105 |
-
|
106 |
-
|
107 |
] );
|
108 |
|
109 |
// When checkout is returned to idle, set payment status to pristine but only if payment status is already not finished.
|
110 |
useEffect( () => {
|
111 |
-
if ( checkoutIsIdle && !
|
112 |
-
|
113 |
}
|
114 |
-
}, [
|
115 |
-
checkoutIsIdle,
|
116 |
-
currentStatus.isSuccessful,
|
117 |
-
__internalSetPaymentStatus,
|
118 |
-
] );
|
119 |
|
120 |
// if checkout has an error sync payment status back to pristine.
|
121 |
useEffect( () => {
|
122 |
-
if ( checkoutHasError &&
|
123 |
-
|
124 |
}
|
125 |
-
}, [
|
126 |
-
checkoutHasError,
|
127 |
-
currentStatus.isSuccessful,
|
128 |
-
__internalSetPaymentStatus,
|
129 |
-
] );
|
130 |
|
131 |
// Emit the payment processing event
|
132 |
useEffect( () => {
|
@@ -134,16 +130,15 @@ export const PaymentEventsProvider = ( {
|
|
134 |
// observer that returns a response that !== true. However, this still
|
135 |
// allows for other observers that return true for continuing through
|
136 |
// to the next observer (or bailing if there's a problem).
|
137 |
-
if (
|
138 |
__internalEmitPaymentProcessingEvent(
|
139 |
currentObservers.current,
|
140 |
setValidationErrors
|
141 |
);
|
142 |
}
|
143 |
}, [
|
144 |
-
|
145 |
setValidationErrors,
|
146 |
-
__internalSetPaymentStatus,
|
147 |
removeNotice,
|
148 |
createErrorNotice,
|
149 |
setBillingAddress,
|
62 |
isCalculating: store.isCalculating(),
|
63 |
};
|
64 |
} );
|
65 |
+
const { isPaymentSuccess, isPaymentFinished, isPaymentProcessing } =
|
66 |
+
useSelect( ( select ) => {
|
67 |
+
const store = select( PAYMENT_STORE_KEY );
|
68 |
|
69 |
+
return {
|
70 |
+
isPaymentSuccess: store.isPaymentSuccess(),
|
71 |
+
isPaymentFinished: store.isPaymentFinished(),
|
72 |
+
isPaymentProcessing: store.isPaymentProcessing(),
|
73 |
+
};
|
74 |
+
} );
|
75 |
|
76 |
const { createErrorNotice, removeNotice } = useDispatch( 'core/notices' );
|
77 |
const { setValidationErrors } = useDispatch( VALIDATION_STORE_KEY );
|
85 |
}, [ observers ] );
|
86 |
|
87 |
const {
|
88 |
+
__internalSetPaymentProcessing,
|
89 |
+
__internalSetPaymentPristine,
|
90 |
__internalSetPaymentMethodData,
|
91 |
__internalEmitPaymentProcessingEvent,
|
92 |
} = useDispatch( PAYMENT_STORE_KEY );
|
98 |
checkoutIsProcessing &&
|
99 |
! checkoutHasError &&
|
100 |
! checkoutIsCalculating &&
|
101 |
+
! isPaymentFinished
|
102 |
) {
|
103 |
+
__internalSetPaymentProcessing();
|
104 |
}
|
105 |
}, [
|
106 |
checkoutIsProcessing,
|
107 |
checkoutHasError,
|
108 |
checkoutIsCalculating,
|
109 |
+
isPaymentFinished,
|
110 |
+
__internalSetPaymentProcessing,
|
111 |
] );
|
112 |
|
113 |
// When checkout is returned to idle, set payment status to pristine but only if payment status is already not finished.
|
114 |
useEffect( () => {
|
115 |
+
if ( checkoutIsIdle && ! isPaymentSuccess ) {
|
116 |
+
__internalSetPaymentPristine();
|
117 |
}
|
118 |
+
}, [ checkoutIsIdle, isPaymentSuccess, __internalSetPaymentPristine ] );
|
|
|
|
|
|
|
|
|
119 |
|
120 |
// if checkout has an error sync payment status back to pristine.
|
121 |
useEffect( () => {
|
122 |
+
if ( checkoutHasError && isPaymentSuccess ) {
|
123 |
+
__internalSetPaymentPristine();
|
124 |
}
|
125 |
+
}, [ checkoutHasError, isPaymentSuccess, __internalSetPaymentPristine ] );
|
|
|
|
|
|
|
|
|
126 |
|
127 |
// Emit the payment processing event
|
128 |
useEffect( () => {
|
130 |
// observer that returns a response that !== true. However, this still
|
131 |
// allows for other observers that return true for continuing through
|
132 |
// to the next observer (or bailing if there's a problem).
|
133 |
+
if ( isPaymentProcessing ) {
|
134 |
__internalEmitPaymentProcessingEvent(
|
135 |
currentObservers.current,
|
136 |
setValidationErrors
|
137 |
);
|
138 |
}
|
139 |
}, [
|
140 |
+
isPaymentProcessing,
|
141 |
setValidationErrors,
|
|
|
142 |
removeNotice,
|
143 |
createErrorNotice,
|
144 |
setBillingAddress,
|
assets/js/base/context/providers/index.js
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
export * from './editor-context';
|
2 |
export * from './add-to-cart-form';
|
3 |
export * from './cart-checkout';
|
4 |
-
export * from './store-notices';
|
5 |
export * from './store-snackbar-notices';
|
6 |
export * from './container-width-context';
|
7 |
export * from './editor-context';
|
1 |
export * from './editor-context';
|
2 |
export * from './add-to-cart-form';
|
3 |
export * from './cart-checkout';
|
|
|
4 |
export * from './store-snackbar-notices';
|
5 |
export * from './container-width-context';
|
6 |
export * from './editor-context';
|
assets/js/base/context/providers/store-notices/index.js
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
export * from './components/store-notices-container';
|
|
assets/js/base/utils/legacy-events.ts
CHANGED
@@ -42,23 +42,6 @@ export const dispatchEvent = (
|
|
42 |
element.dispatchEvent( event );
|
43 |
};
|
44 |
|
45 |
-
let fragmentRequestTimeoutId: ReturnType< typeof setTimeout >;
|
46 |
-
|
47 |
-
// This is a hack to trigger cart updates till we migrate to block based cart
|
48 |
-
// that relies on the store, see
|
49 |
-
// https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues/1247
|
50 |
-
export const triggerFragmentRefresh = (): void => {
|
51 |
-
if ( fragmentRequestTimeoutId ) {
|
52 |
-
clearTimeout( fragmentRequestTimeoutId );
|
53 |
-
}
|
54 |
-
fragmentRequestTimeoutId = setTimeout( () => {
|
55 |
-
dispatchEvent( 'wc_fragment_refresh', {
|
56 |
-
bubbles: true,
|
57 |
-
cancelable: true,
|
58 |
-
} );
|
59 |
-
}, 50 );
|
60 |
-
};
|
61 |
-
|
62 |
export const triggerAddingToCartEvent = (): void => {
|
63 |
dispatchEvent( 'wc-blocks_adding_to_cart', {
|
64 |
bubbles: true,
|
42 |
element.dispatchEvent( event );
|
43 |
};
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
export const triggerAddingToCartEvent = (): void => {
|
46 |
dispatchEvent( 'wc-blocks_adding_to_cart', {
|
47 |
bubbles: true,
|
assets/js/blocks/cart-checkout-shared/payment-methods/express-payment-methods.js
CHANGED
@@ -36,7 +36,10 @@ const ExpressPaymentMethods = () => {
|
|
36 |
);
|
37 |
const {
|
38 |
__internalSetActivePaymentMethod,
|
39 |
-
|
|
|
|
|
|
|
40 |
__internalSetExpressPaymentError,
|
41 |
} = useDispatch( PAYMENT_STORE_KEY );
|
42 |
const { paymentMethods } = useExpressPaymentMethods();
|
@@ -55,14 +58,14 @@ const ExpressPaymentMethods = () => {
|
|
55 |
( paymentMethodId ) => () => {
|
56 |
previousActivePaymentMethod.current = activePaymentMethod;
|
57 |
previousPaymentMethodData.current = paymentMethodData;
|
58 |
-
|
59 |
__internalSetActivePaymentMethod( paymentMethodId );
|
60 |
},
|
61 |
[
|
62 |
activePaymentMethod,
|
63 |
paymentMethodData,
|
64 |
__internalSetActivePaymentMethod,
|
65 |
-
|
66 |
]
|
67 |
);
|
68 |
|
@@ -72,12 +75,12 @@ const ExpressPaymentMethods = () => {
|
|
72 |
* This restores the active method and returns the state to pristine.
|
73 |
*/
|
74 |
const onExpressPaymentClose = useCallback( () => {
|
75 |
-
|
76 |
__internalSetActivePaymentMethod(
|
77 |
previousActivePaymentMethod.current,
|
78 |
previousPaymentMethodData.current
|
79 |
);
|
80 |
-
}, [ __internalSetActivePaymentMethod,
|
81 |
|
82 |
/**
|
83 |
* onExpressPaymentError should be triggered when the express payment process errors.
|
@@ -86,7 +89,8 @@ const ExpressPaymentMethods = () => {
|
|
86 |
*/
|
87 |
const onExpressPaymentError = useCallback(
|
88 |
( errorMessage ) => {
|
89 |
-
|
|
|
90 |
__internalSetExpressPaymentError( errorMessage );
|
91 |
__internalSetActivePaymentMethod(
|
92 |
previousActivePaymentMethod.current,
|
@@ -95,7 +99,8 @@ const ExpressPaymentMethods = () => {
|
|
95 |
},
|
96 |
[
|
97 |
__internalSetActivePaymentMethod,
|
98 |
-
|
|
|
99 |
__internalSetExpressPaymentError,
|
100 |
]
|
101 |
);
|
36 |
);
|
37 |
const {
|
38 |
__internalSetActivePaymentMethod,
|
39 |
+
__internalSetPaymentStarted,
|
40 |
+
__internalSetPaymentPristine,
|
41 |
+
__internalSetPaymentError,
|
42 |
+
__internalSetPaymentMethodData,
|
43 |
__internalSetExpressPaymentError,
|
44 |
} = useDispatch( PAYMENT_STORE_KEY );
|
45 |
const { paymentMethods } = useExpressPaymentMethods();
|
58 |
( paymentMethodId ) => () => {
|
59 |
previousActivePaymentMethod.current = activePaymentMethod;
|
60 |
previousPaymentMethodData.current = paymentMethodData;
|
61 |
+
__internalSetPaymentStarted();
|
62 |
__internalSetActivePaymentMethod( paymentMethodId );
|
63 |
},
|
64 |
[
|
65 |
activePaymentMethod,
|
66 |
paymentMethodData,
|
67 |
__internalSetActivePaymentMethod,
|
68 |
+
__internalSetPaymentStarted,
|
69 |
]
|
70 |
);
|
71 |
|
75 |
* This restores the active method and returns the state to pristine.
|
76 |
*/
|
77 |
const onExpressPaymentClose = useCallback( () => {
|
78 |
+
__internalSetPaymentPristine();
|
79 |
__internalSetActivePaymentMethod(
|
80 |
previousActivePaymentMethod.current,
|
81 |
previousPaymentMethodData.current
|
82 |
);
|
83 |
+
}, [ __internalSetActivePaymentMethod, __internalSetPaymentPristine ] );
|
84 |
|
85 |
/**
|
86 |
* onExpressPaymentError should be triggered when the express payment process errors.
|
89 |
*/
|
90 |
const onExpressPaymentError = useCallback(
|
91 |
( errorMessage ) => {
|
92 |
+
__internalSetPaymentError();
|
93 |
+
__internalSetPaymentMethodData( errorMessage );
|
94 |
__internalSetExpressPaymentError( errorMessage );
|
95 |
__internalSetActivePaymentMethod(
|
96 |
previousActivePaymentMethod.current,
|
99 |
},
|
100 |
[
|
101 |
__internalSetActivePaymentMethod,
|
102 |
+
__internalSetPaymentError,
|
103 |
+
__internalSetPaymentMethodData,
|
104 |
__internalSetExpressPaymentError,
|
105 |
]
|
106 |
);
|
assets/js/blocks/cart-checkout-shared/payment-methods/express-payment/cart-express-payment.js
CHANGED
@@ -3,10 +3,8 @@
|
|
3 |
*/
|
4 |
import { __ } from '@wordpress/i18n';
|
5 |
import { useExpressPaymentMethods } from '@woocommerce/base-context/hooks';
|
6 |
-
import {
|
7 |
-
|
8 |
-
noticeContexts,
|
9 |
-
} from '@woocommerce/base-context';
|
10 |
import LoadingMask from '@woocommerce/base-components/loading-mask';
|
11 |
import { useSelect } from '@wordpress/data';
|
12 |
import { CHECKOUT_STORE_KEY, PAYMENT_STORE_KEY } from '@woocommerce/block-data';
|
@@ -37,13 +35,9 @@ const CartExpressPayment = () => {
|
|
37 |
hasError: store.hasError(),
|
38 |
};
|
39 |
} );
|
40 |
-
const
|
41 |
-
|
42 |
-
|
43 |
-
return {
|
44 |
-
paymentStatus: store.getCurrentStatus(),
|
45 |
-
};
|
46 |
-
} );
|
47 |
|
48 |
if (
|
49 |
! isInitialized ||
|
@@ -65,7 +59,7 @@ const CartExpressPayment = () => {
|
|
65 |
isLoading={
|
66 |
isCalculating ||
|
67 |
checkoutProcessing ||
|
68 |
-
|
69 |
}
|
70 |
>
|
71 |
<div className="wc-block-components-express-payment wc-block-components-express-payment--cart">
|
3 |
*/
|
4 |
import { __ } from '@wordpress/i18n';
|
5 |
import { useExpressPaymentMethods } from '@woocommerce/base-context/hooks';
|
6 |
+
import { noticeContexts } from '@woocommerce/base-context';
|
7 |
+
import { StoreNoticesContainer } from '@woocommerce/blocks-checkout';
|
|
|
|
|
8 |
import LoadingMask from '@woocommerce/base-components/loading-mask';
|
9 |
import { useSelect } from '@wordpress/data';
|
10 |
import { CHECKOUT_STORE_KEY, PAYMENT_STORE_KEY } from '@woocommerce/block-data';
|
35 |
hasError: store.hasError(),
|
36 |
};
|
37 |
} );
|
38 |
+
const isExpressPaymentMethodActive = useSelect( ( select ) =>
|
39 |
+
select( PAYMENT_STORE_KEY ).isExpressPaymentMethodActive()
|
40 |
+
);
|
|
|
|
|
|
|
|
|
41 |
|
42 |
if (
|
43 |
! isInitialized ||
|
59 |
isLoading={
|
60 |
isCalculating ||
|
61 |
checkoutProcessing ||
|
62 |
+
isExpressPaymentMethodActive
|
63 |
}
|
64 |
>
|
65 |
<div className="wc-block-components-express-payment wc-block-components-express-payment--cart">
|
assets/js/blocks/cart-checkout-shared/payment-methods/express-payment/checkout-express-payment.js
CHANGED
@@ -2,11 +2,8 @@
|
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { __ } from '@wordpress/i18n';
|
5 |
-
import {
|
6 |
-
|
7 |
-
useEditorContext,
|
8 |
-
noticeContexts,
|
9 |
-
} from '@woocommerce/base-context';
|
10 |
import Title from '@woocommerce/base-components/title';
|
11 |
import LoadingMask from '@woocommerce/base-components/loading-mask';
|
12 |
import { CURRENT_USER_IS_ADMIN } from '@woocommerce/settings';
|
@@ -41,7 +38,7 @@ const CheckoutExpressPayment = () => {
|
|
41 |
const {
|
42 |
availableExpressPaymentMethods,
|
43 |
expressPaymentMethodsInitialized,
|
44 |
-
|
45 |
} = useSelect( ( select ) => {
|
46 |
const store = select( PAYMENT_STORE_KEY );
|
47 |
return {
|
@@ -49,7 +46,7 @@ const CheckoutExpressPayment = () => {
|
|
49 |
store.getAvailableExpressPaymentMethods(),
|
50 |
expressPaymentMethodsInitialized:
|
51 |
store.expressPaymentMethodsInitialized(),
|
52 |
-
|
53 |
};
|
54 |
} );
|
55 |
const { isEditor } = useEditorContext();
|
@@ -84,7 +81,7 @@ const CheckoutExpressPayment = () => {
|
|
84 |
isLoading={
|
85 |
isCalculating ||
|
86 |
checkoutProcessing ||
|
87 |
-
|
88 |
}
|
89 |
>
|
90 |
<div className="wc-block-components-express-payment wc-block-components-express-payment--checkout">
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { __ } from '@wordpress/i18n';
|
5 |
+
import { useEditorContext, noticeContexts } from '@woocommerce/base-context';
|
6 |
+
import { StoreNoticesContainer } from '@woocommerce/blocks-checkout';
|
|
|
|
|
|
|
7 |
import Title from '@woocommerce/base-components/title';
|
8 |
import LoadingMask from '@woocommerce/base-components/loading-mask';
|
9 |
import { CURRENT_USER_IS_ADMIN } from '@woocommerce/settings';
|
38 |
const {
|
39 |
availableExpressPaymentMethods,
|
40 |
expressPaymentMethodsInitialized,
|
41 |
+
isExpressPaymentMethodActive,
|
42 |
} = useSelect( ( select ) => {
|
43 |
const store = select( PAYMENT_STORE_KEY );
|
44 |
return {
|
46 |
store.getAvailableExpressPaymentMethods(),
|
47 |
expressPaymentMethodsInitialized:
|
48 |
store.expressPaymentMethodsInitialized(),
|
49 |
+
isExpressPaymentMethodActive: store.isExpressPaymentMethodActive(),
|
50 |
};
|
51 |
} );
|
52 |
const { isEditor } = useEditorContext();
|
81 |
isLoading={
|
82 |
isCalculating ||
|
83 |
checkoutProcessing ||
|
84 |
+
isExpressPaymentMethodActive
|
85 |
}
|
86 |
>
|
87 |
<div className="wc-block-components-express-payment wc-block-components-express-payment--checkout">
|
assets/js/blocks/cart-checkout-shared/payment-methods/payment-method-error-boundary.js
CHANGED
@@ -5,7 +5,7 @@ import { __ } from '@wordpress/i18n';
|
|
5 |
import { Component } from 'react';
|
6 |
import PropTypes from 'prop-types';
|
7 |
import { CURRENT_USER_IS_ADMIN } from '@woocommerce/settings';
|
8 |
-
import { StoreNoticesContainer } from '@woocommerce/
|
9 |
import { noticeContexts } from '@woocommerce/base-context/hooks';
|
10 |
|
11 |
class PaymentMethodErrorBoundary extends Component {
|
5 |
import { Component } from 'react';
|
6 |
import PropTypes from 'prop-types';
|
7 |
import { CURRENT_USER_IS_ADMIN } from '@woocommerce/settings';
|
8 |
+
import { StoreNoticesContainer } from '@woocommerce/blocks-checkout';
|
9 |
import { noticeContexts } from '@woocommerce/base-context/hooks';
|
10 |
|
11 |
class PaymentMethodErrorBoundary extends Component {
|
assets/js/blocks/cart/block.js
CHANGED
@@ -5,16 +5,16 @@ import { __ } from '@wordpress/i18n';
|
|
5 |
import { useStoreCart } from '@woocommerce/base-context/hooks';
|
6 |
import { useEffect } from '@wordpress/element';
|
7 |
import LoadingMask from '@woocommerce/base-components/loading-mask';
|
8 |
-
import {
|
9 |
-
StoreNoticesContainer,
|
10 |
-
SnackbarNoticesContainer,
|
11 |
-
} from '@woocommerce/base-context';
|
12 |
import { CURRENT_USER_IS_ADMIN } from '@woocommerce/settings';
|
13 |
import BlockErrorBoundary from '@woocommerce/base-components/block-error-boundary';
|
14 |
import { translateJQueryEventToNative } from '@woocommerce/base-utils';
|
15 |
import withScrollToTop from '@woocommerce/base-hocs/with-scroll-to-top';
|
16 |
import { CartProvider } from '@woocommerce/base-context/providers';
|
17 |
-
import {
|
|
|
|
|
|
|
18 |
|
19 |
/**
|
20 |
* Internal dependencies
|
5 |
import { useStoreCart } from '@woocommerce/base-context/hooks';
|
6 |
import { useEffect } from '@wordpress/element';
|
7 |
import LoadingMask from '@woocommerce/base-components/loading-mask';
|
8 |
+
import { SnackbarNoticesContainer } from '@woocommerce/base-context';
|
|
|
|
|
|
|
9 |
import { CURRENT_USER_IS_ADMIN } from '@woocommerce/settings';
|
10 |
import BlockErrorBoundary from '@woocommerce/base-components/block-error-boundary';
|
11 |
import { translateJQueryEventToNative } from '@woocommerce/base-utils';
|
12 |
import withScrollToTop from '@woocommerce/base-hocs/with-scroll-to-top';
|
13 |
import { CartProvider } from '@woocommerce/base-context/providers';
|
14 |
+
import {
|
15 |
+
SlotFillProvider,
|
16 |
+
StoreNoticesContainer,
|
17 |
+
} from '@woocommerce/blocks-checkout';
|
18 |
|
19 |
/**
|
20 |
* Internal dependencies
|
assets/js/blocks/cart/cart-cross-sells-product-list/cart-cross-sells-product.tsx
CHANGED
@@ -41,6 +41,11 @@ const CartCrossSellsProduct = ( {
|
|
41 |
<ProductImage
|
42 |
className={ '' }
|
43 |
showSaleBadge={ false }
|
|
|
|
|
|
|
|
|
|
|
44 |
/>
|
45 |
<ProductName
|
46 |
align={ '' }
|
@@ -48,7 +53,10 @@ const CartCrossSellsProduct = ( {
|
|
48 |
showProductLink={ true }
|
49 |
/>
|
50 |
<ProductRating />
|
51 |
-
<ProductSaleBadge
|
|
|
|
|
|
|
52 |
<ProductPrice />
|
53 |
</div>
|
54 |
{ product.is_in_stock ? (
|
41 |
<ProductImage
|
42 |
className={ '' }
|
43 |
showSaleBadge={ false }
|
44 |
+
productId={ product.id }
|
45 |
+
showProductLink={ false }
|
46 |
+
saleBadgeAlign={ 'left' }
|
47 |
+
imageSizing={ 'full-size' }
|
48 |
+
isDescendentOfQueryLoop={ false }
|
49 |
/>
|
50 |
<ProductName
|
51 |
align={ '' }
|
53 |
showProductLink={ true }
|
54 |
/>
|
55 |
<ProductRating />
|
56 |
+
<ProductSaleBadge
|
57 |
+
productId={ product.id }
|
58 |
+
align={ 'left' }
|
59 |
+
/>
|
60 |
<ProductPrice />
|
61 |
</div>
|
62 |
{ product.is_in_stock ? (
|
assets/js/blocks/cart/cart-line-items-table/cart-line-item-row.tsx
CHANGED
@@ -19,10 +19,7 @@ import {
|
|
19 |
ProductMetadata,
|
20 |
ProductSaleBadge,
|
21 |
} from '@woocommerce/base-components/cart-checkout';
|
22 |
-
import {
|
23 |
-
getCurrencyFromPriceResponse,
|
24 |
-
Currency,
|
25 |
-
} from '@woocommerce/price-format';
|
26 |
import {
|
27 |
__experimentalApplyCheckoutFilter,
|
28 |
mustContain,
|
@@ -30,7 +27,7 @@ import {
|
|
30 |
import Dinero from 'dinero.js';
|
31 |
import { forwardRef, useMemo } from '@wordpress/element';
|
32 |
import type { CartItem } from '@woocommerce/type-defs/cart';
|
33 |
-
import { objectHasProp } from '@woocommerce/types';
|
34 |
import { getSetting } from '@woocommerce/settings';
|
35 |
|
36 |
/**
|
@@ -47,7 +44,8 @@ const getAmountFromRawPrice = (
|
|
47 |
return priceObject.convertPrecision( currency.minorUnit ).getAmount();
|
48 |
};
|
49 |
|
50 |
-
const productPriceValidation = ( value ) =>
|
|
|
51 |
|
52 |
interface CartLineItemRowProps {
|
53 |
lineItem: CartItem | Record< string, never >;
|
@@ -58,9 +56,11 @@ interface CartLineItemRowProps {
|
|
58 |
/**
|
59 |
* Cart line item table row component.
|
60 |
*/
|
61 |
-
const CartLineItemRow
|
|
|
|
|
62 |
(
|
63 |
-
{ lineItem, onRemove = () => void null, tabIndex
|
64 |
ref
|
65 |
): JSX.Element => {
|
66 |
const {
|
@@ -367,5 +367,4 @@ const CartLineItemRow = forwardRef< HTMLTableRowElement, CartLineItemRowProps >(
|
|
367 |
);
|
368 |
}
|
369 |
);
|
370 |
-
|
371 |
export default CartLineItemRow;
|
19 |
ProductMetadata,
|
20 |
ProductSaleBadge,
|
21 |
} from '@woocommerce/base-components/cart-checkout';
|
22 |
+
import { getCurrencyFromPriceResponse } from '@woocommerce/price-format';
|
|
|
|
|
|
|
23 |
import {
|
24 |
__experimentalApplyCheckoutFilter,
|
25 |
mustContain,
|
27 |
import Dinero from 'dinero.js';
|
28 |
import { forwardRef, useMemo } from '@wordpress/element';
|
29 |
import type { CartItem } from '@woocommerce/type-defs/cart';
|
30 |
+
import { objectHasProp, Currency } from '@woocommerce/types';
|
31 |
import { getSetting } from '@woocommerce/settings';
|
32 |
|
33 |
/**
|
44 |
return priceObject.convertPrecision( currency.minorUnit ).getAmount();
|
45 |
};
|
46 |
|
47 |
+
const productPriceValidation = ( value: string ) =>
|
48 |
+
mustContain( value, '<price/>' );
|
49 |
|
50 |
interface CartLineItemRowProps {
|
51 |
lineItem: CartItem | Record< string, never >;
|
56 |
/**
|
57 |
* Cart line item table row component.
|
58 |
*/
|
59 |
+
const CartLineItemRow: React.ForwardRefExoticComponent<
|
60 |
+
CartLineItemRowProps & React.RefAttributes< HTMLTableRowElement >
|
61 |
+
> = forwardRef< HTMLTableRowElement, CartLineItemRowProps >(
|
62 |
(
|
63 |
+
{ lineItem, onRemove = () => void null, tabIndex },
|
64 |
ref
|
65 |
): JSX.Element => {
|
66 |
const {
|
367 |
);
|
368 |
}
|
369 |
);
|
|
|
370 |
export default CartLineItemRow;
|
assets/js/blocks/cart/inner-blocks/cart-cross-sells-block/block.json
CHANGED
@@ -13,5 +13,6 @@
|
|
13 |
},
|
14 |
"parent": [ "woocommerce/cart-items-block" ],
|
15 |
"textdomain": "woo-gutenberg-products-block",
|
|
|
16 |
"apiVersion": 2
|
17 |
}
|
13 |
},
|
14 |
"parent": [ "woocommerce/cart-items-block" ],
|
15 |
"textdomain": "woo-gutenberg-products-block",
|
16 |
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
17 |
"apiVersion": 2
|
18 |
}
|
assets/js/blocks/cart/inner-blocks/cart-cross-sells-block/index.tsx
CHANGED
@@ -8,9 +8,8 @@ import { registerBlockType } from '@wordpress/blocks';
|
|
8 |
* Internal dependencies
|
9 |
*/
|
10 |
import { Edit, Save } from './edit';
|
11 |
-
import metadata from './block.json';
|
12 |
|
13 |
-
registerBlockType(
|
14 |
icon: {
|
15 |
src: (
|
16 |
<Icon
|
8 |
* Internal dependencies
|
9 |
*/
|
10 |
import { Edit, Save } from './edit';
|
|
|
11 |
|
12 |
+
registerBlockType( 'woocommerce/cart-cross-sells-block', {
|
13 |
icon: {
|
14 |
src: (
|
15 |
<Icon
|
assets/js/blocks/cart/inner-blocks/cart-cross-sells-products/block.json
CHANGED
@@ -27,5 +27,6 @@
|
|
27 |
},
|
28 |
"parent": [ "woocommerce/cart-cross-sells-block" ],
|
29 |
"textdomain": "woo-gutenberg-products-block",
|
|
|
30 |
"apiVersion": 2
|
31 |
}
|
27 |
},
|
28 |
"parent": [ "woocommerce/cart-cross-sells-block" ],
|
29 |
"textdomain": "woo-gutenberg-products-block",
|
30 |
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
31 |
"apiVersion": 2
|
32 |
}
|
assets/js/blocks/cart/inner-blocks/cart-cross-sells-products/index.tsx
CHANGED
@@ -8,9 +8,8 @@ import { registerBlockType } from '@wordpress/blocks';
|
|
8 |
* Internal dependencies
|
9 |
*/
|
10 |
import { Edit, Save } from './edit';
|
11 |
-
import metadata from './block.json';
|
12 |
|
13 |
-
registerBlockType(
|
14 |
icon: {
|
15 |
src: (
|
16 |
<Icon
|
8 |
* Internal dependencies
|
9 |
*/
|
10 |
import { Edit, Save } from './edit';
|
|
|
11 |
|
12 |
+
registerBlockType( 'woocommerce/cart-cross-sells-products-block', {
|
13 |
icon: {
|
14 |
src: (
|
15 |
<Icon
|
assets/js/blocks/checkout/block.tsx
CHANGED
@@ -9,11 +9,14 @@ import {
|
|
9 |
CheckoutProvider,
|
10 |
SnackbarNoticesContainer,
|
11 |
} from '@woocommerce/base-context';
|
12 |
-
|
13 |
import BlockErrorBoundary from '@woocommerce/base-components/block-error-boundary';
|
14 |
import { SidebarLayout } from '@woocommerce/base-components/sidebar-layout';
|
15 |
import { CURRENT_USER_IS_ADMIN, getSetting } from '@woocommerce/settings';
|
16 |
-
import {
|
|
|
|
|
|
|
17 |
import withScrollToTop from '@woocommerce/base-hocs/with-scroll-to-top';
|
18 |
import { useDispatch, useSelect } from '@wordpress/data';
|
19 |
import {
|
9 |
CheckoutProvider,
|
10 |
SnackbarNoticesContainer,
|
11 |
} from '@woocommerce/base-context';
|
12 |
+
|
13 |
import BlockErrorBoundary from '@woocommerce/base-components/block-error-boundary';
|
14 |
import { SidebarLayout } from '@woocommerce/base-components/sidebar-layout';
|
15 |
import { CURRENT_USER_IS_ADMIN, getSetting } from '@woocommerce/settings';
|
16 |
+
import {
|
17 |
+
SlotFillProvider,
|
18 |
+
StoreNoticesContainer,
|
19 |
+
} from '@woocommerce/blocks-checkout';
|
20 |
import withScrollToTop from '@woocommerce/base-hocs/with-scroll-to-top';
|
21 |
import { useDispatch, useSelect } from '@wordpress/data';
|
22 |
import {
|
assets/js/blocks/checkout/inner-blocks/checkout-contact-information-block/block.tsx
CHANGED
@@ -2,10 +2,12 @@
|
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { __ } from '@wordpress/i18n';
|
5 |
-
import { ValidatedTextInput } from '@woocommerce/base-components/text-input';
|
6 |
import { useCheckoutAddress, useStoreEvents } from '@woocommerce/base-context';
|
7 |
import { getSetting } from '@woocommerce/settings';
|
8 |
-
import {
|
|
|
|
|
|
|
9 |
import { useDispatch, useSelect } from '@wordpress/data';
|
10 |
import { CHECKOUT_STORE_KEY } from '@woocommerce/block-data';
|
11 |
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { __ } from '@wordpress/i18n';
|
|
|
5 |
import { useCheckoutAddress, useStoreEvents } from '@woocommerce/base-context';
|
6 |
import { getSetting } from '@woocommerce/settings';
|
7 |
+
import {
|
8 |
+
CheckboxControl,
|
9 |
+
ValidatedTextInput,
|
10 |
+
} from '@woocommerce/blocks-checkout';
|
11 |
import { useDispatch, useSelect } from '@wordpress/data';
|
12 |
import { CHECKOUT_STORE_KEY } from '@woocommerce/block-data';
|
13 |
|
assets/js/blocks/checkout/inner-blocks/checkout-payment-block/frontend.tsx
CHANGED
@@ -7,13 +7,13 @@ import { withFilteredAttributes } from '@woocommerce/shared-hocs';
|
|
7 |
import { FormStep } from '@woocommerce/base-components/cart-checkout';
|
8 |
import { useSelect } from '@wordpress/data';
|
9 |
import { CHECKOUT_STORE_KEY } from '@woocommerce/block-data';
|
|
|
10 |
|
11 |
/**
|
12 |
* Internal dependencies
|
13 |
*/
|
14 |
import Block from './block';
|
15 |
import attributes from './attributes';
|
16 |
-
import { StoreNoticesContainer } from '../../../../base/context/providers';
|
17 |
import { noticeContexts } from '../../../../base/context/event-emit';
|
18 |
|
19 |
const FrontendBlock = ( {
|
7 |
import { FormStep } from '@woocommerce/base-components/cart-checkout';
|
8 |
import { useSelect } from '@wordpress/data';
|
9 |
import { CHECKOUT_STORE_KEY } from '@woocommerce/block-data';
|
10 |
+
import { StoreNoticesContainer } from '@woocommerce/blocks-checkout';
|
11 |
|
12 |
/**
|
13 |
* Internal dependencies
|
14 |
*/
|
15 |
import Block from './block';
|
16 |
import attributes from './attributes';
|
|
|
17 |
import { noticeContexts } from '../../../../base/context/event-emit';
|
18 |
|
19 |
const FrontendBlock = ( {
|
assets/js/blocks/checkout/phone-number/index.tsx
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { __ } from '@wordpress/i18n';
|
5 |
-
import { ValidatedTextInput } from '@woocommerce/
|
6 |
|
7 |
/**
|
8 |
* Renders a phone number input.
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { __ } from '@wordpress/i18n';
|
5 |
+
import { ValidatedTextInput } from '@woocommerce/blocks-checkout';
|
6 |
|
7 |
/**
|
8 |
* Renders a phone number input.
|
assets/js/blocks/classic-template/constants.ts
CHANGED
@@ -38,6 +38,13 @@ export const TEMPLATES: TemplateDetails = {
|
|
38 |
),
|
39 |
placeholder: 'archive-product',
|
40 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
'product-search-results': {
|
42 |
title: __(
|
43 |
'WooCommerce Product Search Results Block',
|
38 |
),
|
39 |
placeholder: 'archive-product',
|
40 |
},
|
41 |
+
'taxonomy-product_attribute': {
|
42 |
+
title: __(
|
43 |
+
'WooCommerce Product Attribute Block',
|
44 |
+
'woo-gutenberg-products-block'
|
45 |
+
),
|
46 |
+
placeholder: 'archive-product',
|
47 |
+
},
|
48 |
'product-search-results': {
|
49 |
title: __(
|
50 |
'WooCommerce Product Search Results Block',
|
assets/js/blocks/classic-template/test/utils.ts
CHANGED
@@ -20,6 +20,10 @@ const TEMPLATES = {
|
|
20 |
title: 'Product Taxonomy Title',
|
21 |
placeholder: 'Product Taxonomy Placeholder',
|
22 |
},
|
|
|
|
|
|
|
|
|
23 |
};
|
24 |
|
25 |
describe( 'getTemplateDetailsBySlug', function () {
|
20 |
title: 'Product Taxonomy Title',
|
21 |
placeholder: 'Product Taxonomy Placeholder',
|
22 |
},
|
23 |
+
'taxonomy-product_attribute': {
|
24 |
+
title: 'Product Attribute Title',
|
25 |
+
placeholder: 'Product Attribute Placeholder',
|
26 |
+
},
|
27 |
};
|
28 |
|
29 |
describe( 'getTemplateDetailsBySlug', function () {
|
assets/js/blocks/products/all-products/block.js
CHANGED
@@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
|
|
6 |
import { ProductListContainer } from '@woocommerce/base-components/product-list';
|
7 |
import { InnerBlockLayoutContextProvider } from '@woocommerce/shared-context';
|
8 |
import { gridBlockPreview } from '@woocommerce/resource-previews';
|
9 |
-
import { StoreNoticesContainer } from '@woocommerce/
|
10 |
|
11 |
/**
|
12 |
* The All Products Block.
|
6 |
import { ProductListContainer } from '@woocommerce/base-components/product-list';
|
7 |
import { InnerBlockLayoutContextProvider } from '@woocommerce/shared-context';
|
8 |
import { gridBlockPreview } from '@woocommerce/resource-previews';
|
9 |
+
import { StoreNoticesContainer } from '@woocommerce/blocks-checkout';
|
10 |
|
11 |
/**
|
12 |
* The All Products Block.
|
assets/js/blocks/single-product/block.js
CHANGED
@@ -7,7 +7,7 @@ import {
|
|
7 |
InnerBlockLayoutContextProvider,
|
8 |
ProductDataContextProvider,
|
9 |
} from '@woocommerce/shared-context';
|
10 |
-
import { StoreNoticesContainer } from '@woocommerce/
|
11 |
import { useStoreEvents } from '@woocommerce/base-context/hooks';
|
12 |
|
13 |
/**
|
7 |
InnerBlockLayoutContextProvider,
|
8 |
ProductDataContextProvider,
|
9 |
} from '@woocommerce/shared-context';
|
10 |
+
import { StoreNoticesContainer } from '@woocommerce/blocks-checkout';
|
11 |
import { useStoreEvents } from '@woocommerce/base-context/hooks';
|
12 |
|
13 |
/**
|
assets/js/data/cart/action-types.ts
CHANGED
@@ -12,7 +12,6 @@ export const ACTION_TYPES = {
|
|
12 |
SET_BILLING_ADDRESS: 'SET_BILLING_ADDRESS',
|
13 |
SET_SHIPPING_ADDRESS: 'SET_SHIPPING_ADDRESS',
|
14 |
UPDATING_SELECTED_SHIPPING_RATE: 'UPDATING_SELECTED_SHIPPING_RATE',
|
15 |
-
UPDATE_LEGACY_CART_FRAGMENTS: 'UPDATE_LEGACY_CART_FRAGMENTS',
|
16 |
TRIGGER_ADDING_TO_CART_EVENT: 'TRIGGER_ADDING_TO_CART_EVENT',
|
17 |
TRIGGER_ADDED_TO_CART_EVENT: 'TRIGGER_ADDED_TO_CART_EVENT',
|
18 |
} as const;
|
12 |
SET_BILLING_ADDRESS: 'SET_BILLING_ADDRESS',
|
13 |
SET_SHIPPING_ADDRESS: 'SET_SHIPPING_ADDRESS',
|
14 |
UPDATING_SELECTED_SHIPPING_RATE: 'UPDATING_SELECTED_SHIPPING_RATE',
|
|
|
15 |
TRIGGER_ADDING_TO_CART_EVENT: 'TRIGGER_ADDING_TO_CART_EVENT',
|
16 |
TRIGGER_ADDED_TO_CART_EVENT: 'TRIGGER_ADDED_TO_CART_EVENT',
|
17 |
} as const;
|
assets/js/data/cart/actions.ts
CHANGED
@@ -184,14 +184,6 @@ export const shippingRatesBeingSelected = ( isResolving: boolean ) =>
|
|
184 |
isResolving,
|
185 |
} as const );
|
186 |
|
187 |
-
/**
|
188 |
-
* Returns an action object for updating legacy cart fragments.
|
189 |
-
*/
|
190 |
-
export const updateCartFragments = () =>
|
191 |
-
( {
|
192 |
-
type: types.UPDATE_LEGACY_CART_FRAGMENTS,
|
193 |
-
} as const );
|
194 |
-
|
195 |
/**
|
196 |
* Triggers an adding to cart event so other blocks can update accordingly.
|
197 |
*/
|
@@ -227,7 +219,6 @@ export function* applyExtensionCartUpdate(
|
|
227 |
cache: 'no-store',
|
228 |
} );
|
229 |
yield receiveCart( response );
|
230 |
-
yield updateCartFragments();
|
231 |
return response;
|
232 |
} catch ( error ) {
|
233 |
yield receiveError( error );
|
@@ -265,7 +256,6 @@ export function* applyCoupon(
|
|
265 |
|
266 |
yield receiveCart( response );
|
267 |
yield receiveApplyingCoupon( '' );
|
268 |
-
yield updateCartFragments();
|
269 |
} catch ( error ) {
|
270 |
yield receiveError( error );
|
271 |
yield receiveApplyingCoupon( '' );
|
@@ -306,7 +296,6 @@ export function* removeCoupon(
|
|
306 |
|
307 |
yield receiveCart( response );
|
308 |
yield receiveRemovingCoupon( '' );
|
309 |
-
yield updateCartFragments();
|
310 |
} catch ( error ) {
|
311 |
yield receiveError( error );
|
312 |
yield receiveRemovingCoupon( '' );
|
@@ -351,7 +340,6 @@ export function* addItemToCart(
|
|
351 |
|
352 |
yield receiveCart( response );
|
353 |
yield triggerAddedToCartEvent( { preserveCartData: true } );
|
354 |
-
yield updateCartFragments();
|
355 |
} catch ( error ) {
|
356 |
yield receiveError( error );
|
357 |
|
@@ -390,7 +378,6 @@ export function* removeItemFromCart(
|
|
390 |
} );
|
391 |
|
392 |
yield receiveCart( response );
|
393 |
-
yield updateCartFragments();
|
394 |
} catch ( error ) {
|
395 |
yield receiveError( error );
|
396 |
|
@@ -437,7 +424,6 @@ export function* changeCartItemQuantity(
|
|
437 |
} );
|
438 |
|
439 |
yield receiveCart( response );
|
440 |
-
yield updateCartFragments();
|
441 |
} catch ( error ) {
|
442 |
yield receiveError( error );
|
443 |
|
@@ -559,5 +545,4 @@ export type CartAction = ReturnOrGeneratorYieldUnion<
|
|
559 |
| typeof removeItemFromCart
|
560 |
| typeof changeCartItemQuantity
|
561 |
| typeof addItemToCart
|
562 |
-
| typeof updateCartFragments
|
563 |
>;
|
184 |
isResolving,
|
185 |
} as const );
|
186 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
/**
|
188 |
* Triggers an adding to cart event so other blocks can update accordingly.
|
189 |
*/
|
219 |
cache: 'no-store',
|
220 |
} );
|
221 |
yield receiveCart( response );
|
|
|
222 |
return response;
|
223 |
} catch ( error ) {
|
224 |
yield receiveError( error );
|
256 |
|
257 |
yield receiveCart( response );
|
258 |
yield receiveApplyingCoupon( '' );
|
|
|
259 |
} catch ( error ) {
|
260 |
yield receiveError( error );
|
261 |
yield receiveApplyingCoupon( '' );
|
296 |
|
297 |
yield receiveCart( response );
|
298 |
yield receiveRemovingCoupon( '' );
|
|
|
299 |
} catch ( error ) {
|
300 |
yield receiveError( error );
|
301 |
yield receiveRemovingCoupon( '' );
|
340 |
|
341 |
yield receiveCart( response );
|
342 |
yield triggerAddedToCartEvent( { preserveCartData: true } );
|
|
|
343 |
} catch ( error ) {
|
344 |
yield receiveError( error );
|
345 |
|
378 |
} );
|
379 |
|
380 |
yield receiveCart( response );
|
|
|
381 |
} catch ( error ) {
|
382 |
yield receiveError( error );
|
383 |
|
424 |
} );
|
425 |
|
426 |
yield receiveCart( response );
|
|
|
427 |
} catch ( error ) {
|
428 |
yield receiveError( error );
|
429 |
|
545 |
| typeof removeItemFromCart
|
546 |
| typeof changeCartItemQuantity
|
547 |
| typeof addItemToCart
|
|
|
548 |
>;
|
assets/js/data/cart/controls.js
CHANGED
@@ -2,7 +2,6 @@
|
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import {
|
5 |
-
triggerFragmentRefresh,
|
6 |
triggerAddedToCartEvent,
|
7 |
triggerAddingToCartEvent,
|
8 |
} from '@woocommerce/base-utils';
|
@@ -13,9 +12,6 @@ import {
|
|
13 |
* @return {Object} An object with the controls to register with the store on the controls property of the registration object.
|
14 |
*/
|
15 |
export const controls = {
|
16 |
-
UPDATE_LEGACY_CART_FRAGMENTS() {
|
17 |
-
triggerFragmentRefresh();
|
18 |
-
},
|
19 |
TRIGGER_ADDING_TO_CART_EVENT() {
|
20 |
triggerAddingToCartEvent();
|
21 |
},
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import {
|
|
|
5 |
triggerAddedToCartEvent,
|
6 |
triggerAddingToCartEvent,
|
7 |
} from '@woocommerce/base-utils';
|
12 |
* @return {Object} An object with the controls to register with the store on the controls property of the registration object.
|
13 |
*/
|
14 |
export const controls = {
|
|
|
|
|
|
|
15 |
TRIGGER_ADDING_TO_CART_EVENT() {
|
16 |
triggerAddingToCartEvent();
|
17 |
},
|
assets/js/data/cart/index.ts
CHANGED
@@ -21,6 +21,8 @@ import {
|
|
21 |
debouncedUpdatePaymentMethods,
|
22 |
} from './update-payment-methods';
|
23 |
|
|
|
|
|
24 |
const registeredStore = registerStore< State >( STORE_KEY, {
|
25 |
reducer,
|
26 |
actions,
|
21 |
debouncedUpdatePaymentMethods,
|
22 |
} from './update-payment-methods';
|
23 |
|
24 |
+
// Please update from deprecated "registerStore" to "createReduxStore" when this PR is merged:
|
25 |
+
// https://github.com/WordPress/gutenberg/pull/45513
|
26 |
const registeredStore = registerStore< State >( STORE_KEY, {
|
27 |
reducer,
|
28 |
actions,
|
assets/js/data/checkout/action-types.ts
CHANGED
@@ -4,15 +4,13 @@ export const ACTION_TYPES = {
|
|
4 |
SET_COMPLETE: 'SET_CHECKOUT_COMPLETE',
|
5 |
SET_BEFORE_PROCESSING: 'SET_BEFORE_PROCESSING',
|
6 |
SET_AFTER_PROCESSING: 'SET_AFTER_PROCESSING',
|
7 |
-
SET_PAYMENT_RESULT: 'SET_PAYMENT_RESULT',
|
8 |
SET_PROCESSING: 'SET_CHECKOUT_IS_PROCESSING',
|
9 |
SET_HAS_ERROR: 'SET_CHECKOUT_HAS_ERROR',
|
10 |
SET_CUSTOMER_ID: 'SET_CHECKOUT_CUSTOMER_ID',
|
11 |
SET_ORDER_NOTES: 'SET_CHECKOUT_ORDER_NOTES',
|
12 |
INCREMENT_CALCULATING: 'INCREMENT_CALCULATING',
|
13 |
DECREMENT_CALCULATING: 'DECREMENT_CALCULATING',
|
14 |
-
|
15 |
-
'SET_SHIPPING_ADDRESS_AS_BILLING_ADDRESS',
|
16 |
SET_SHOULD_CREATE_ACCOUNT: 'SET_SHOULD_CREATE_ACCOUNT',
|
17 |
SET_EXTENSION_DATA: 'SET_EXTENSION_DATA',
|
18 |
SET_IS_CART: 'SET_IS_CART',
|
4 |
SET_COMPLETE: 'SET_CHECKOUT_COMPLETE',
|
5 |
SET_BEFORE_PROCESSING: 'SET_BEFORE_PROCESSING',
|
6 |
SET_AFTER_PROCESSING: 'SET_AFTER_PROCESSING',
|
|
|
7 |
SET_PROCESSING: 'SET_CHECKOUT_IS_PROCESSING',
|
8 |
SET_HAS_ERROR: 'SET_CHECKOUT_HAS_ERROR',
|
9 |
SET_CUSTOMER_ID: 'SET_CHECKOUT_CUSTOMER_ID',
|
10 |
SET_ORDER_NOTES: 'SET_CHECKOUT_ORDER_NOTES',
|
11 |
INCREMENT_CALCULATING: 'INCREMENT_CALCULATING',
|
12 |
DECREMENT_CALCULATING: 'DECREMENT_CALCULATING',
|
13 |
+
SET_USE_SHIPPING_AS_BILLING: 'SET_USE_SHIPPING_AS_BILLING',
|
|
|
14 |
SET_SHOULD_CREATE_ACCOUNT: 'SET_SHOULD_CREATE_ACCOUNT',
|
15 |
SET_EXTENSION_DATA: 'SET_EXTENSION_DATA',
|
16 |
SET_IS_CART: 'SET_IS_CART',
|
assets/js/data/checkout/actions.ts
CHANGED
@@ -1,8 +1,3 @@
|
|
1 |
-
/**
|
2 |
-
* External dependencies
|
3 |
-
*/
|
4 |
-
import { PaymentResult } from '@woocommerce/types';
|
5 |
-
|
6 |
/**
|
7 |
* Internal dependencies
|
8 |
*/
|
@@ -60,16 +55,6 @@ export const __internalSetRedirectUrl = ( redirectUrl: string ) => ( {
|
|
60 |
redirectUrl,
|
61 |
} );
|
62 |
|
63 |
-
/**
|
64 |
-
* Store the result of the payment attempt from the /checkout StoreApi call
|
65 |
-
*
|
66 |
-
* @param data The result of the payment attempt through the StoreApi /checkout endpoints
|
67 |
-
*/
|
68 |
-
export const __internalSetPaymentResult = ( data: PaymentResult ) => ( {
|
69 |
-
type: types.SET_PAYMENT_RESULT,
|
70 |
-
data,
|
71 |
-
} );
|
72 |
-
|
73 |
/**
|
74 |
* Set whether the checkout has an error or not
|
75 |
*
|
@@ -114,7 +99,7 @@ export const __internalSetCustomerId = ( customerId: number ) => ( {
|
|
114 |
export const __internalSetUseShippingAsBilling = (
|
115 |
useShippingAsBilling: boolean
|
116 |
) => ( {
|
117 |
-
type: types.
|
118 |
useShippingAsBilling,
|
119 |
} );
|
120 |
|
@@ -157,7 +142,6 @@ export type CheckoutAction =
|
|
157 |
| typeof __internalSetIdle
|
158 |
| typeof __internalSetComplete
|
159 |
| typeof __internalSetProcessing
|
160 |
-
| typeof __internalSetPaymentResult
|
161 |
| typeof __internalSetBeforeProcessing
|
162 |
| typeof __internalSetAfterProcessing
|
163 |
| typeof __internalSetRedirectUrl
|
|
|
|
|
|
|
|
|
|
|
1 |
/**
|
2 |
* Internal dependencies
|
3 |
*/
|
55 |
redirectUrl,
|
56 |
} );
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
/**
|
59 |
* Set whether the checkout has an error or not
|
60 |
*
|
99 |
export const __internalSetUseShippingAsBilling = (
|
100 |
useShippingAsBilling: boolean
|
101 |
) => ( {
|
102 |
+
type: types.SET_USE_SHIPPING_AS_BILLING,
|
103 |
useShippingAsBilling,
|
104 |
} );
|
105 |
|
142 |
| typeof __internalSetIdle
|
143 |
| typeof __internalSetComplete
|
144 |
| typeof __internalSetProcessing
|
|
|
145 |
| typeof __internalSetBeforeProcessing
|
146 |
| typeof __internalSetAfterProcessing
|
147 |
| typeof __internalSetRedirectUrl
|
assets/js/data/checkout/default-state.ts
CHANGED
@@ -2,7 +2,6 @@
|
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { isSameAddress } from '@woocommerce/base-utils';
|
5 |
-
import { PaymentResult } from '@woocommerce/types';
|
6 |
|
7 |
/**
|
8 |
* Internal dependencies
|
@@ -14,8 +13,6 @@ export type CheckoutState = {
|
|
14 |
status: STATUS;
|
15 |
// If any of the totals, taxes, shipping, etc need to be calculated, the count will be increased here
|
16 |
calculatingCount: number;
|
17 |
-
// The result of the payment processing
|
18 |
-
paymentResult: PaymentResult | null;
|
19 |
// True when the checkout is in an error state. Whatever caused the error (validation/payment method) will likely have triggered a notice.
|
20 |
hasError: boolean;
|
21 |
// This is the url that checkout will redirect to when it's ready.
|
@@ -47,6 +44,5 @@ export const defaultState: CheckoutState = {
|
|
47 |
checkoutData.shipping_address
|
48 |
),
|
49 |
shouldCreateAccount: false,
|
50 |
-
paymentResult: null,
|
51 |
extensionData: {},
|
52 |
};
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { isSameAddress } from '@woocommerce/base-utils';
|
|
|
5 |
|
6 |
/**
|
7 |
* Internal dependencies
|
13 |
status: STATUS;
|
14 |
// If any of the totals, taxes, shipping, etc need to be calculated, the count will be increased here
|
15 |
calculatingCount: number;
|
|
|
|
|
16 |
// True when the checkout is in an error state. Whatever caused the error (validation/payment method) will likely have triggered a notice.
|
17 |
hasError: boolean;
|
18 |
// This is the url that checkout will redirect to when it's ready.
|
44 |
checkoutData.shipping_address
|
45 |
),
|
46 |
shouldCreateAccount: false,
|
|
|
47 |
extensionData: {},
|
48 |
};
|
assets/js/data/checkout/index.ts
CHANGED
@@ -16,10 +16,6 @@ export const config = {
|
|
16 |
reducer,
|
17 |
selectors,
|
18 |
actions,
|
19 |
-
// TODO: Gutenberg with Thunks was released in WP 6.0. Once 6.1 is released, remove the experimental flag here
|
20 |
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
21 |
-
// @ts-ignore We pass this in case there is an older version of Gutenberg running.
|
22 |
-
__experimentalUseThunks: true,
|
23 |
};
|
24 |
|
25 |
const store = createReduxStore( STORE_KEY, config );
|
16 |
reducer,
|
17 |
selectors,
|
18 |
actions,
|
|
|
|
|
|
|
|
|
19 |
};
|
20 |
|
21 |
const store = createReduxStore( STORE_KEY, config );
|
assets/js/data/checkout/reducers.ts
CHANGED
@@ -1,8 +1,3 @@
|
|
1 |
-
/**
|
2 |
-
* External dependencies
|
3 |
-
*/
|
4 |
-
import { PaymentResult } from '@woocommerce/types';
|
5 |
-
|
6 |
/**
|
7 |
* Internal dependencies
|
8 |
*/
|
@@ -35,13 +30,6 @@ const reducer = ( state = defaultState, action: CheckoutAction ) => {
|
|
35 |
: state;
|
36 |
break;
|
37 |
|
38 |
-
case types.SET_PAYMENT_RESULT:
|
39 |
-
newState = {
|
40 |
-
...state,
|
41 |
-
paymentResult: action.data as PaymentResult,
|
42 |
-
};
|
43 |
-
break;
|
44 |
-
|
45 |
case types.SET_COMPLETE:
|
46 |
newState = {
|
47 |
...state,
|
@@ -110,7 +98,7 @@ const reducer = ( state = defaultState, action: CheckoutAction ) => {
|
|
110 |
}
|
111 |
break;
|
112 |
|
113 |
-
case types.
|
114 |
if (
|
115 |
action.useShippingAsBilling !== undefined &&
|
116 |
action.useShippingAsBilling !== state.useShippingAsBilling
|
|
|
|
|
|
|
|
|
|
|
1 |
/**
|
2 |
* Internal dependencies
|
3 |
*/
|
30 |
: state;
|
31 |
break;
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
case types.SET_COMPLETE:
|
34 |
newState = {
|
35 |
...state,
|
98 |
}
|
99 |
break;
|
100 |
|
101 |
+
case types.SET_USE_SHIPPING_AS_BILLING:
|
102 |
if (
|
103 |
action.useShippingAsBilling !== undefined &&
|
104 |
action.useShippingAsBilling !== state.useShippingAsBilling
|
assets/js/data/checkout/test/reducer.ts
CHANGED
@@ -37,28 +37,6 @@ describe.only( 'Checkout Store Reducer', () => {
|
|
37 |
).toEqual( expectedState );
|
38 |
} );
|
39 |
|
40 |
-
it( 'should handle SET_PAYMENT_RESULT', () => {
|
41 |
-
const mockResponse = {
|
42 |
-
message: 'success',
|
43 |
-
redirectUrl: 'https://example.com',
|
44 |
-
paymentStatus: 'not set' as const,
|
45 |
-
paymentDetails: {},
|
46 |
-
};
|
47 |
-
|
48 |
-
const expectedState = {
|
49 |
-
...defaultState,
|
50 |
-
status: STATUS.IDLE,
|
51 |
-
paymentResult: mockResponse,
|
52 |
-
};
|
53 |
-
|
54 |
-
expect(
|
55 |
-
reducer(
|
56 |
-
defaultState,
|
57 |
-
actions.__internalSetPaymentResult( mockResponse )
|
58 |
-
)
|
59 |
-
).toEqual( expectedState );
|
60 |
-
} );
|
61 |
-
|
62 |
it( 'should handle SET_COMPLETE', () => {
|
63 |
const expectedState = {
|
64 |
...defaultState,
|
@@ -195,7 +173,7 @@ describe.only( 'Checkout Store Reducer', () => {
|
|
195 |
).toEqual( expectedState );
|
196 |
} );
|
197 |
|
198 |
-
it( 'should handle
|
199 |
const expectedState = {
|
200 |
...defaultState,
|
201 |
status: STATUS.IDLE,
|
37 |
).toEqual( expectedState );
|
38 |
} );
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
it( 'should handle SET_COMPLETE', () => {
|
41 |
const expectedState = {
|
42 |
...defaultState,
|
173 |
).toEqual( expectedState );
|
174 |
} );
|
175 |
|
176 |
+
it( 'should handle SET_USE_SHIPPING_AS_BILLING', () => {
|
177 |
const expectedState = {
|
178 |
...defaultState,
|
179 |
status: STATUS.IDLE,
|
assets/js/data/checkout/thunks.ts
CHANGED
@@ -3,10 +3,12 @@
|
|
3 |
*/
|
4 |
import type { CheckoutResponse } from '@woocommerce/types';
|
5 |
import { store as noticesStore } from '@wordpress/notices';
|
|
|
6 |
|
7 |
/**
|
8 |
* Internal dependencies
|
9 |
*/
|
|
|
10 |
import { removeNoticesByStatus } from '../../utils/notices';
|
11 |
import {
|
12 |
getPaymentResultFromCheckoutResponse,
|
@@ -40,7 +42,11 @@ export const __internalProcessCheckoutResponse = (
|
|
40 |
} ) => {
|
41 |
const paymentResult = getPaymentResultFromCheckoutResponse( response );
|
42 |
dispatch.__internalSetRedirectUrl( paymentResult?.redirectUrl || '' );
|
43 |
-
dispatch.
|
|
|
|
|
|
|
|
|
44 |
dispatch.__internalSetAfterProcessing();
|
45 |
};
|
46 |
};
|
@@ -90,15 +96,16 @@ export const __internalEmitAfterProcessingEvents: emitAfterProcessingEventsType
|
|
90 |
( { observers, notices } ) => {
|
91 |
return ( { select, dispatch, registry } ) => {
|
92 |
const { createErrorNotice } = registry.dispatch( noticesStore );
|
93 |
-
const
|
94 |
const data = {
|
95 |
-
redirectUrl:
|
96 |
-
orderId:
|
97 |
-
customerId:
|
98 |
-
orderNotes:
|
99 |
-
processingResponse:
|
|
|
100 |
};
|
101 |
-
if (
|
102 |
// allow payment methods or other things to customize the error
|
103 |
// with a fallback if nothing customizes it.
|
104 |
emitEventWithAbort(
|
3 |
*/
|
4 |
import type { CheckoutResponse } from '@woocommerce/types';
|
5 |
import { store as noticesStore } from '@wordpress/notices';
|
6 |
+
import { dispatch as wpDispatch, select as wpSelect } from '@wordpress/data';
|
7 |
|
8 |
/**
|
9 |
* Internal dependencies
|
10 |
*/
|
11 |
+
import { STORE_KEY as PAYMENT_STORE_KEY } from '../payment/constants';
|
12 |
import { removeNoticesByStatus } from '../../utils/notices';
|
13 |
import {
|
14 |
getPaymentResultFromCheckoutResponse,
|
42 |
} ) => {
|
43 |
const paymentResult = getPaymentResultFromCheckoutResponse( response );
|
44 |
dispatch.__internalSetRedirectUrl( paymentResult?.redirectUrl || '' );
|
45 |
+
// The local `dispatch` here is bound to the actions of the data store. We need to use the global dispatch here
|
46 |
+
// to dispatch an action on a different store.
|
47 |
+
wpDispatch( PAYMENT_STORE_KEY ).__internalSetPaymentResult(
|
48 |
+
paymentResult
|
49 |
+
);
|
50 |
dispatch.__internalSetAfterProcessing();
|
51 |
};
|
52 |
};
|
96 |
( { observers, notices } ) => {
|
97 |
return ( { select, dispatch, registry } ) => {
|
98 |
const { createErrorNotice } = registry.dispatch( noticesStore );
|
99 |
+
const checkoutState = select.getCheckoutState();
|
100 |
const data = {
|
101 |
+
redirectUrl: checkoutState.redirectUrl,
|
102 |
+
orderId: checkoutState.orderId,
|
103 |
+
customerId: checkoutState.customerId,
|
104 |
+
orderNotes: checkoutState.orderNotes,
|
105 |
+
processingResponse:
|
106 |
+
wpSelect( PAYMENT_STORE_KEY ).getPaymentResult(),
|
107 |
};
|
108 |
+
if ( checkoutState.hasError ) {
|
109 |
// allow payment methods or other things to customize the error
|
110 |
// with a fallback if nothing customizes it.
|
111 |
emitEventWithAbort(
|
assets/js/data/checkout/types.ts
CHANGED
@@ -9,6 +9,7 @@ import { DataRegistry } from '@wordpress/data';
|
|
9 |
*/
|
10 |
import type { EventObserversType } from '../../base/context/event-emit/types';
|
11 |
import type { CheckoutState } from './default-state';
|
|
|
12 |
import type { DispatchFromMap, SelectFromMap } from '../mapped-types';
|
13 |
import * as selectors from './selectors';
|
14 |
import * as actions from './actions';
|
@@ -19,7 +20,7 @@ export type CheckoutAfterProcessingWithErrorEventData = {
|
|
19 |
orderId: CheckoutState[ 'orderId' ];
|
20 |
customerId: CheckoutState[ 'customerId' ];
|
21 |
orderNotes: CheckoutState[ 'orderNotes' ];
|
22 |
-
processingResponse:
|
23 |
};
|
24 |
export type CheckoutAndPaymentNotices = {
|
25 |
checkoutNotices: Notice[];
|
9 |
*/
|
10 |
import type { EventObserversType } from '../../base/context/event-emit/types';
|
11 |
import type { CheckoutState } from './default-state';
|
12 |
+
import type { PaymentState } from '../payment/default-state';
|
13 |
import type { DispatchFromMap, SelectFromMap } from '../mapped-types';
|
14 |
import * as selectors from './selectors';
|
15 |
import * as actions from './actions';
|
20 |
orderId: CheckoutState[ 'orderId' ];
|
21 |
customerId: CheckoutState[ 'customerId' ];
|
22 |
orderNotes: CheckoutState[ 'orderNotes' ];
|
23 |
+
processingResponse: PaymentState[ 'paymentResult' ];
|
24 |
};
|
25 |
export type CheckoutAndPaymentNotices = {
|
26 |
checkoutNotices: Notice[];
|
assets/js/data/collections/index.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
-
import {
|
5 |
import { controls as dataControls } from '@wordpress/data-controls';
|
6 |
|
7 |
/**
|
@@ -14,7 +14,7 @@ import * as resolvers from './resolvers';
|
|
14 |
import reducer from './reducers';
|
15 |
import { controls } from '../shared-controls';
|
16 |
|
17 |
-
|
18 |
reducer,
|
19 |
actions,
|
20 |
controls: { ...dataControls, ...controls },
|
@@ -22,4 +22,6 @@ registerStore( STORE_KEY, {
|
|
22 |
resolvers,
|
23 |
} );
|
24 |
|
|
|
|
|
25 |
export const COLLECTIONS_STORE_KEY = STORE_KEY;
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
+
import { register, createReduxStore } from '@wordpress/data';
|
5 |
import { controls as dataControls } from '@wordpress/data-controls';
|
6 |
|
7 |
/**
|
14 |
import reducer from './reducers';
|
15 |
import { controls } from '../shared-controls';
|
16 |
|
17 |
+
const store = createReduxStore( STORE_KEY, {
|
18 |
reducer,
|
19 |
actions,
|
20 |
controls: { ...dataControls, ...controls },
|
22 |
resolvers,
|
23 |
} );
|
24 |
|
25 |
+
register( store );
|
26 |
+
|
27 |
export const COLLECTIONS_STORE_KEY = STORE_KEY;
|
assets/js/data/payment/action-types.ts
CHANGED
@@ -1,4 +1,10 @@
|
|
1 |
export enum ACTION_TYPES {
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
SET_PAYMENT_METHODS_INITIALIZED = 'SET_PAYMENT_METHODS_INITIALIZED',
|
3 |
SET_EXPRESS_PAYMENT_METHODS_INITIALIZED = 'SET_EXPRESS_PAYMENT_METHODS_INITIALIZED',
|
4 |
SET_ACTIVE_PAYMENT_METHOD = 'SET_ACTIVE_PAYMENT_METHOD',
|
@@ -7,7 +13,7 @@ export enum ACTION_TYPES {
|
|
7 |
SET_AVAILABLE_EXPRESS_PAYMENT_METHODS = 'SET_AVAILABLE_EXPRESS_PAYMENT_METHODS',
|
8 |
REMOVE_AVAILABLE_PAYMENT_METHOD = 'REMOVE_AVAILABLE_PAYMENT_METHOD',
|
9 |
REMOVE_AVAILABLE_EXPRESS_PAYMENT_METHOD = 'REMOVE_AVAILABLE_EXPRESS_PAYMENT_METHOD',
|
10 |
-
SET_PAYMENT_STATUS = 'SET_PAYMENT_STATUS',
|
11 |
INITIALIZE_PAYMENT_METHODS = 'INITIALIZE_PAYMENT_METHODS',
|
12 |
SET_PAYMENT_METHOD_DATA = 'SET_PAYMENT_METHOD_DATA',
|
|
|
13 |
}
|
1 |
export enum ACTION_TYPES {
|
2 |
+
SET_PAYMENT_PRISTINE = 'SET_PAYMENT_PRISTINE',
|
3 |
+
SET_PAYMENT_STARTED = 'SET_PAYMENT_STARTED',
|
4 |
+
SET_PAYMENT_PROCESSING = 'SET_PAYMENT_PROCESSING',
|
5 |
+
SET_PAYMENT_FAILED = 'SET_PAYMENT_FAILED',
|
6 |
+
SET_PAYMENT_ERROR = 'SET_PAYMENT_ERROR',
|
7 |
+
SET_PAYMENT_SUCCESS = 'SET_PAYMENT_SUCCESS',
|
8 |
SET_PAYMENT_METHODS_INITIALIZED = 'SET_PAYMENT_METHODS_INITIALIZED',
|
9 |
SET_EXPRESS_PAYMENT_METHODS_INITIALIZED = 'SET_EXPRESS_PAYMENT_METHODS_INITIALIZED',
|
10 |
SET_ACTIVE_PAYMENT_METHOD = 'SET_ACTIVE_PAYMENT_METHOD',
|
13 |
SET_AVAILABLE_EXPRESS_PAYMENT_METHODS = 'SET_AVAILABLE_EXPRESS_PAYMENT_METHODS',
|
14 |
REMOVE_AVAILABLE_PAYMENT_METHOD = 'REMOVE_AVAILABLE_PAYMENT_METHOD',
|
15 |
REMOVE_AVAILABLE_EXPRESS_PAYMENT_METHOD = 'REMOVE_AVAILABLE_EXPRESS_PAYMENT_METHOD',
|
|
|
16 |
INITIALIZE_PAYMENT_METHODS = 'INITIALIZE_PAYMENT_METHODS',
|
17 |
SET_PAYMENT_METHOD_DATA = 'SET_PAYMENT_METHOD_DATA',
|
18 |
+
SET_PAYMENT_RESULT = 'SET_PAYMENT_RESULT',
|
19 |
}
|
assets/js/data/payment/actions.ts
CHANGED
@@ -5,31 +5,40 @@ import {
|
|
5 |
PlainPaymentMethods,
|
6 |
PlainExpressPaymentMethods,
|
7 |
} from '@woocommerce/type-defs/payments';
|
|
|
8 |
|
9 |
/**
|
10 |
* Internal dependencies
|
11 |
*/
|
12 |
import { ACTION_TYPES } from './action-types';
|
13 |
-
import { checkPaymentMethodsCanPay } from './check-payment-methods';
|
14 |
-
import { setDefaultPaymentMethod } from './set-default-payment-method';
|
15 |
-
import { PaymentStatus } from './types';
|
16 |
|
17 |
// `Thunks are functions that can be dispatched, similar to actions creators
|
18 |
export * from './thunks';
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
} );
|
34 |
|
35 |
/**
|
@@ -104,6 +113,16 @@ export const __internalSetPaymentMethodData = (
|
|
104 |
paymentMethodData,
|
105 |
} );
|
106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
/**
|
108 |
* Set the available payment methods.
|
109 |
* An available payment method is one that has been validated and can make a payment.
|
5 |
PlainPaymentMethods,
|
6 |
PlainExpressPaymentMethods,
|
7 |
} from '@woocommerce/type-defs/payments';
|
8 |
+
import type { PaymentResult } from '@woocommerce/types';
|
9 |
|
10 |
/**
|
11 |
* Internal dependencies
|
12 |
*/
|
13 |
import { ACTION_TYPES } from './action-types';
|
14 |
+
import { checkPaymentMethodsCanPay } from './utils/check-payment-methods';
|
15 |
+
import { setDefaultPaymentMethod } from './utils/set-default-payment-method';
|
|
|
16 |
|
17 |
// `Thunks are functions that can be dispatched, similar to actions creators
|
18 |
export * from './thunks';
|
19 |
|
20 |
+
export const __internalSetPaymentPristine = () => ( {
|
21 |
+
type: ACTION_TYPES.SET_PAYMENT_PRISTINE,
|
22 |
+
} );
|
23 |
+
|
24 |
+
export const __internalSetPaymentStarted = () => ( {
|
25 |
+
type: ACTION_TYPES.SET_PAYMENT_STARTED,
|
26 |
+
} );
|
27 |
+
|
28 |
+
export const __internalSetPaymentProcessing = () => ( {
|
29 |
+
type: ACTION_TYPES.SET_PAYMENT_PROCESSING,
|
30 |
+
} );
|
31 |
+
|
32 |
+
export const __internalSetPaymentFailed = () => ( {
|
33 |
+
type: ACTION_TYPES.SET_PAYMENT_FAILED,
|
34 |
+
} );
|
35 |
+
|
36 |
+
export const __internalSetPaymentError = () => ( {
|
37 |
+
type: ACTION_TYPES.SET_PAYMENT_ERROR,
|
38 |
+
} );
|
39 |
+
|
40 |
+
export const __internalSetPaymentSuccess = () => ( {
|
41 |
+
type: ACTION_TYPES.SET_PAYMENT_SUCCESS,
|
42 |
} );
|
43 |
|
44 |
/**
|
113 |
paymentMethodData,
|
114 |
} );
|
115 |
|
116 |
+
/**
|
117 |
+
* Store the result of the payment attempt from the /checkout StoreApi call
|
118 |
+
*
|
119 |
+
* @param data The result of the payment attempt through the StoreApi /checkout endpoints
|
120 |
+
*/
|
121 |
+
export const __internalSetPaymentResult = ( data: PaymentResult ) => ( {
|
122 |
+
type: ACTION_TYPES.SET_PAYMENT_RESULT,
|
123 |
+
data,
|
124 |
+
} );
|
125 |
+
|
126 |
/**
|
127 |
* Set the available payment methods.
|
128 |
* An available payment method is one that has been validated and can make a payment.
|
assets/js/data/payment/constants.ts
CHANGED
@@ -7,5 +7,4 @@ export enum STATUS {
|
|
7 |
ERROR = 'has_error',
|
8 |
FAILED = 'failed',
|
9 |
SUCCESS = 'success',
|
10 |
-
COMPLETE = 'complete',
|
11 |
}
|
7 |
ERROR = 'has_error',
|
8 |
FAILED = 'failed',
|
9 |
SUCCESS = 'success',
|
|
|
10 |
}
|
assets/js/data/payment/default-state.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
-
import type { EmptyObjectType } from '@woocommerce/types';
|
5 |
import { getSetting } from '@woocommerce/settings';
|
6 |
import {
|
7 |
PlainPaymentMethods,
|
@@ -14,18 +14,8 @@ import {
|
|
14 |
import { SavedPaymentMethod } from './types';
|
15 |
import { STATUS as PAYMENT_STATUS } from './constants';
|
16 |
|
17 |
-
export interface
|
18 |
-
|
19 |
-
currentStatus: {
|
20 |
-
isPristine: boolean;
|
21 |
-
isStarted: boolean;
|
22 |
-
isProcessing: boolean;
|
23 |
-
isFinished: boolean;
|
24 |
-
hasError: boolean;
|
25 |
-
hasFailed: boolean;
|
26 |
-
isSuccessful: boolean;
|
27 |
-
isDoingExpressPayment: boolean;
|
28 |
-
};
|
29 |
activePaymentMethod: string;
|
30 |
activeSavedToken: string;
|
31 |
// Avilable payment methods are payment methods which have been validated and can make payment
|
@@ -35,23 +25,13 @@ export interface PaymentMethodDataState {
|
|
35 |
| Record< string, SavedPaymentMethod[] >
|
36 |
| EmptyObjectType;
|
37 |
paymentMethodData: Record< string, unknown >;
|
|
|
38 |
paymentMethodsInitialized: boolean;
|
39 |
expressPaymentMethodsInitialized: boolean;
|
40 |
shouldSavePaymentMethod: boolean;
|
41 |
-
isExpressPaymentMethodActive: boolean;
|
42 |
}
|
43 |
-
export const
|
44 |
-
|
45 |
-
currentStatus: {
|
46 |
-
isPristine: true,
|
47 |
-
isStarted: false,
|
48 |
-
isProcessing: false,
|
49 |
-
isFinished: false,
|
50 |
-
hasError: false,
|
51 |
-
hasFailed: false,
|
52 |
-
isSuccessful: false,
|
53 |
-
isDoingExpressPayment: false,
|
54 |
-
},
|
55 |
activePaymentMethod: '',
|
56 |
activeSavedToken: '',
|
57 |
availablePaymentMethods: {},
|
@@ -60,8 +40,8 @@ export const defaultPaymentMethodDataState: PaymentMethodDataState = {
|
|
60 |
Record< string, SavedPaymentMethod[] > | EmptyObjectType
|
61 |
>( 'customerPaymentMethods', {} ),
|
62 |
paymentMethodData: {},
|
|
|
63 |
paymentMethodsInitialized: false,
|
64 |
expressPaymentMethodsInitialized: false,
|
65 |
shouldSavePaymentMethod: false,
|
66 |
-
isExpressPaymentMethodActive: false,
|
67 |
};
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
+
import type { EmptyObjectType, PaymentResult } from '@woocommerce/types';
|
5 |
import { getSetting } from '@woocommerce/settings';
|
6 |
import {
|
7 |
PlainPaymentMethods,
|
14 |
import { SavedPaymentMethod } from './types';
|
15 |
import { STATUS as PAYMENT_STATUS } from './constants';
|
16 |
|
17 |
+
export interface PaymentState {
|
18 |
+
status: string;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
activePaymentMethod: string;
|
20 |
activeSavedToken: string;
|
21 |
// Avilable payment methods are payment methods which have been validated and can make payment
|
25 |
| Record< string, SavedPaymentMethod[] >
|
26 |
| EmptyObjectType;
|
27 |
paymentMethodData: Record< string, unknown >;
|
28 |
+
paymentResult: PaymentResult | null;
|
29 |
paymentMethodsInitialized: boolean;
|
30 |
expressPaymentMethodsInitialized: boolean;
|
31 |
shouldSavePaymentMethod: boolean;
|
|
|
32 |
}
|
33 |
+
export const defaultPaymentState: PaymentState = {
|
34 |
+
status: PAYMENT_STATUS.PRISTINE,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
activePaymentMethod: '',
|
36 |
activeSavedToken: '',
|
37 |
availablePaymentMethods: {},
|
40 |
Record< string, SavedPaymentMethod[] > | EmptyObjectType
|
41 |
>( 'customerPaymentMethods', {} ),
|
42 |
paymentMethodData: {},
|
43 |
+
paymentResult: null,
|
44 |
paymentMethodsInitialized: false,
|
45 |
expressPaymentMethodsInitialized: false,
|
46 |
shouldSavePaymentMethod: false,
|
|
|
47 |
};
|
assets/js/data/payment/index.ts
CHANGED
@@ -20,10 +20,6 @@ export const config = {
|
|
20 |
actions,
|
21 |
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
22 |
controls: { ...dataControls, ...sharedControls } as any,
|
23 |
-
// TODO: Gutenberg with Thunks was released in WP 6.0. Once 6.1 is released, remove the experimental flag here
|
24 |
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
25 |
-
// @ts-ignore We pass this in case there is an older version of Gutenberg running.
|
26 |
-
__experimentalUseThunks: true,
|
27 |
};
|
28 |
|
29 |
const store = createReduxStore( STORE_KEY, config );
|
20 |
actions,
|
21 |
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
22 |
controls: { ...dataControls, ...sharedControls } as any,
|
|
|
|
|
|
|
|
|
23 |
};
|
24 |
|
25 |
const store = createReduxStore( STORE_KEY, config );
|
assets/js/data/payment/reducers.ts
CHANGED
@@ -2,23 +2,63 @@
|
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import type { Reducer } from 'redux';
|
5 |
-
import { objectHasProp } from '@woocommerce/types';
|
6 |
|
7 |
/**
|
8 |
* Internal dependencies
|
9 |
*/
|
10 |
-
import {
|
11 |
-
defaultPaymentMethodDataState,
|
12 |
-
PaymentMethodDataState,
|
13 |
-
} from './default-state';
|
14 |
import { ACTION_TYPES } from './action-types';
|
|
|
15 |
|
16 |
-
const reducer: Reducer<
|
17 |
-
state =
|
18 |
action
|
19 |
) => {
|
20 |
let newState = state;
|
21 |
switch ( action.type ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
case ACTION_TYPES.SET_SHOULD_SAVE_PAYMENT_METHOD:
|
23 |
newState = {
|
24 |
...state,
|
@@ -33,27 +73,10 @@ const reducer: Reducer< PaymentMethodDataState > = (
|
|
33 |
};
|
34 |
break;
|
35 |
|
36 |
-
case ACTION_TYPES.
|
37 |
newState = {
|
38 |
...state,
|
39 |
-
|
40 |
-
// When the status is changed to pristine, we need to reset the currentStatus properties
|
41 |
-
// to their default initial values
|
42 |
-
...( action.status?.isPristine === true
|
43 |
-
? defaultPaymentMethodDataState.currentStatus
|
44 |
-
: state.currentStatus ),
|
45 |
-
...action.status,
|
46 |
-
isFinished:
|
47 |
-
action.status.hasError ||
|
48 |
-
action.status.hasFailed ||
|
49 |
-
action.status.isSuccessful,
|
50 |
-
isDoingExpressPayment:
|
51 |
-
! action.status.isPristine &&
|
52 |
-
! state.currentStatus.isPristine &&
|
53 |
-
state.isExpressPaymentMethodActive,
|
54 |
-
},
|
55 |
-
paymentMethodData:
|
56 |
-
action.paymentMethodData || state.paymentMethodData,
|
57 |
};
|
58 |
break;
|
59 |
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import type { Reducer } from 'redux';
|
5 |
+
import { objectHasProp, PaymentResult } from '@woocommerce/types';
|
6 |
|
7 |
/**
|
8 |
* Internal dependencies
|
9 |
*/
|
10 |
+
import { defaultPaymentState, PaymentState } from './default-state';
|
|
|
|
|
|
|
11 |
import { ACTION_TYPES } from './action-types';
|
12 |
+
import { STATUS } from './constants';
|
13 |
|
14 |
+
const reducer: Reducer< PaymentState > = (
|
15 |
+
state = defaultPaymentState,
|
16 |
action
|
17 |
) => {
|
18 |
let newState = state;
|
19 |
switch ( action.type ) {
|
20 |
+
case ACTION_TYPES.SET_PAYMENT_PRISTINE:
|
21 |
+
newState = {
|
22 |
+
...state,
|
23 |
+
status: STATUS.PRISTINE,
|
24 |
+
};
|
25 |
+
break;
|
26 |
+
|
27 |
+
case ACTION_TYPES.SET_PAYMENT_STARTED:
|
28 |
+
newState = {
|
29 |
+
...state,
|
30 |
+
status: STATUS.STARTED,
|
31 |
+
};
|
32 |
+
break;
|
33 |
+
|
34 |
+
case ACTION_TYPES.SET_PAYMENT_PROCESSING:
|
35 |
+
newState = {
|
36 |
+
...state,
|
37 |
+
status: STATUS.PROCESSING,
|
38 |
+
};
|
39 |
+
break;
|
40 |
+
|
41 |
+
case ACTION_TYPES.SET_PAYMENT_FAILED:
|
42 |
+
newState = {
|
43 |
+
...state,
|
44 |
+
status: STATUS.FAILED,
|
45 |
+
};
|
46 |
+
break;
|
47 |
+
|
48 |
+
case ACTION_TYPES.SET_PAYMENT_ERROR:
|
49 |
+
newState = {
|
50 |
+
...state,
|
51 |
+
status: STATUS.ERROR,
|
52 |
+
};
|
53 |
+
break;
|
54 |
+
|
55 |
+
case ACTION_TYPES.SET_PAYMENT_SUCCESS:
|
56 |
+
newState = {
|
57 |
+
...state,
|
58 |
+
status: STATUS.SUCCESS,
|
59 |
+
};
|
60 |
+
break;
|
61 |
+
|
62 |
case ACTION_TYPES.SET_SHOULD_SAVE_PAYMENT_METHOD:
|
63 |
newState = {
|
64 |
...state,
|
73 |
};
|
74 |
break;
|
75 |
|
76 |
+
case ACTION_TYPES.SET_PAYMENT_RESULT:
|
77 |
newState = {
|
78 |
...state,
|
79 |
+
paymentResult: action.data as PaymentResult,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
};
|
81 |
break;
|
82 |
|
assets/js/data/payment/selectors.ts
CHANGED
@@ -2,47 +2,71 @@
|
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { objectHasProp } from '@woocommerce/types';
|
|
|
5 |
|
6 |
/**
|
7 |
* Internal dependencies
|
8 |
*/
|
9 |
-
import {
|
10 |
-
import { filterActiveSavedPaymentMethods } from './utils';
|
|
|
11 |
|
12 |
-
export const
|
13 |
-
state
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
return Object.keys( state.availableExpressPaymentMethods ).includes(
|
16 |
state.activePaymentMethod
|
17 |
);
|
18 |
};
|
19 |
|
20 |
-
export const getActiveSavedToken = ( state:
|
21 |
return typeof state.paymentMethodData === 'object' &&
|
22 |
objectHasProp( state.paymentMethodData, 'token' )
|
23 |
? state.paymentMethodData.token + ''
|
24 |
: '';
|
25 |
};
|
26 |
|
27 |
-
export const getActivePaymentMethod = ( state:
|
28 |
return state.activePaymentMethod;
|
29 |
};
|
30 |
|
31 |
-
export const getAvailablePaymentMethods = ( state:
|
32 |
return state.availablePaymentMethods;
|
33 |
};
|
34 |
|
35 |
-
export const getAvailableExpressPaymentMethods = (
|
36 |
-
state: PaymentMethodDataState
|
37 |
-
) => {
|
38 |
return state.availableExpressPaymentMethods;
|
39 |
};
|
40 |
|
41 |
-
export const getPaymentMethodData = ( state:
|
42 |
return state.paymentMethodData;
|
43 |
};
|
44 |
|
45 |
-
export const getSavedPaymentMethods = ( state:
|
46 |
return state.savedPaymentMethods;
|
47 |
};
|
48 |
|
@@ -50,9 +74,7 @@ export const getSavedPaymentMethods = ( state: PaymentMethodDataState ) => {
|
|
50 |
* Filters the list of saved payment methods and returns only the ones which
|
51 |
* are active and supported by the payment gateway
|
52 |
*/
|
53 |
-
export const getActiveSavedPaymentMethods = (
|
54 |
-
state: PaymentMethodDataState
|
55 |
-
) => {
|
56 |
const availablePaymentMethodKeys = Object.keys(
|
57 |
state.availablePaymentMethods
|
58 |
);
|
@@ -63,24 +85,47 @@ export const getActiveSavedPaymentMethods = (
|
|
63 |
);
|
64 |
};
|
65 |
|
66 |
-
export const paymentMethodsInitialized = ( state:
|
67 |
return state.paymentMethodsInitialized;
|
68 |
};
|
69 |
|
70 |
-
export const expressPaymentMethodsInitialized = (
|
71 |
-
state: PaymentMethodDataState
|
72 |
-
) => {
|
73 |
return state.expressPaymentMethodsInitialized;
|
74 |
};
|
75 |
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
};
|
79 |
|
80 |
-
export const getShouldSavePaymentMethod = ( state:
|
81 |
return state.shouldSavePaymentMethod;
|
82 |
};
|
83 |
|
84 |
-
export const
|
|
|
|
|
|
|
|
|
85 |
return state;
|
86 |
};
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { objectHasProp } from '@woocommerce/types';
|
5 |
+
import deprecated from '@wordpress/deprecated';
|
6 |
|
7 |
/**
|
8 |
* Internal dependencies
|
9 |
*/
|
10 |
+
import { PaymentState } from './default-state';
|
11 |
+
import { filterActiveSavedPaymentMethods } from './utils/filter-active-saved-payment-methods';
|
12 |
+
import { STATUS as PAYMENT_STATUS } from './constants';
|
13 |
|
14 |
+
export const isPaymentPristine = ( state: PaymentState ) =>
|
15 |
+
state.status === PAYMENT_STATUS.PRISTINE;
|
16 |
+
|
17 |
+
export const isPaymentStarted = ( state: PaymentState ) =>
|
18 |
+
state.status === PAYMENT_STATUS.STARTED;
|
19 |
+
|
20 |
+
export const isPaymentProcessing = ( state: PaymentState ) =>
|
21 |
+
state.status === PAYMENT_STATUS.PROCESSING;
|
22 |
+
|
23 |
+
export const isPaymentSuccess = ( state: PaymentState ) =>
|
24 |
+
state.status === PAYMENT_STATUS.SUCCESS;
|
25 |
+
|
26 |
+
export const hasPaymentError = ( state: PaymentState ) =>
|
27 |
+
state.status === PAYMENT_STATUS.ERROR;
|
28 |
+
|
29 |
+
export const isPaymentFailed = ( state: PaymentState ) =>
|
30 |
+
state.status === PAYMENT_STATUS.FAILED;
|
31 |
+
|
32 |
+
export const isPaymentFinished = ( state: PaymentState ) => {
|
33 |
+
return (
|
34 |
+
state.status === PAYMENT_STATUS.SUCCESS ||
|
35 |
+
state.status === PAYMENT_STATUS.ERROR ||
|
36 |
+
state.status === PAYMENT_STATUS.FAILED
|
37 |
+
);
|
38 |
+
};
|
39 |
+
|
40 |
+
export const isExpressPaymentMethodActive = ( state: PaymentState ) => {
|
41 |
return Object.keys( state.availableExpressPaymentMethods ).includes(
|
42 |
state.activePaymentMethod
|
43 |
);
|
44 |
};
|
45 |
|
46 |
+
export const getActiveSavedToken = ( state: PaymentState ) => {
|
47 |
return typeof state.paymentMethodData === 'object' &&
|
48 |
objectHasProp( state.paymentMethodData, 'token' )
|
49 |
? state.paymentMethodData.token + ''
|
50 |
: '';
|
51 |
};
|
52 |
|
53 |
+
export const getActivePaymentMethod = ( state: PaymentState ) => {
|
54 |
return state.activePaymentMethod;
|
55 |
};
|
56 |
|
57 |
+
export const getAvailablePaymentMethods = ( state: PaymentState ) => {
|
58 |
return state.availablePaymentMethods;
|
59 |
};
|
60 |
|
61 |
+
export const getAvailableExpressPaymentMethods = ( state: PaymentState ) => {
|
|
|
|
|
62 |
return state.availableExpressPaymentMethods;
|
63 |
};
|
64 |
|
65 |
+
export const getPaymentMethodData = ( state: PaymentState ) => {
|
66 |
return state.paymentMethodData;
|
67 |
};
|
68 |
|
69 |
+
export const getSavedPaymentMethods = ( state: PaymentState ) => {
|
70 |
return state.savedPaymentMethods;
|
71 |
};
|
72 |
|
74 |
* Filters the list of saved payment methods and returns only the ones which
|
75 |
* are active and supported by the payment gateway
|
76 |
*/
|
77 |
+
export const getActiveSavedPaymentMethods = ( state: PaymentState ) => {
|
|
|
|
|
78 |
const availablePaymentMethodKeys = Object.keys(
|
79 |
state.availablePaymentMethods
|
80 |
);
|
85 |
);
|
86 |
};
|
87 |
|
88 |
+
export const paymentMethodsInitialized = ( state: PaymentState ) => {
|
89 |
return state.paymentMethodsInitialized;
|
90 |
};
|
91 |
|
92 |
+
export const expressPaymentMethodsInitialized = ( state: PaymentState ) => {
|
|
|
|
|
93 |
return state.expressPaymentMethodsInitialized;
|
94 |
};
|
95 |
|
96 |
+
/**
|
97 |
+
* @deprecated - use these selectors instead: isPaymentPristine, isPaymentStarted, isPaymentProcessing,
|
98 |
+
* isPaymentFinished, hasPaymentError, isPaymentSuccess, isPaymentFailed
|
99 |
+
*/
|
100 |
+
export const getCurrentStatus = ( state: PaymentState ) => {
|
101 |
+
deprecated( 'getCurrentStatus', {
|
102 |
+
since: '8.9.0',
|
103 |
+
alternative:
|
104 |
+
'isPaymentPristine, isPaymentStarted, isPaymentProcessing, isPaymentFinished, hasPaymentError, isPaymentSuccess, isPaymentFailed',
|
105 |
+
plugin: 'WooCommerce Blocks',
|
106 |
+
link: 'https://github.com/woocommerce/woocommerce-blocks/pull/7666',
|
107 |
+
} );
|
108 |
+
|
109 |
+
return {
|
110 |
+
isPristine: isPaymentPristine( state ),
|
111 |
+
isStarted: isPaymentStarted( state ),
|
112 |
+
isProcessing: isPaymentProcessing( state ),
|
113 |
+
isFinished: isPaymentFinished( state ),
|
114 |
+
hasError: hasPaymentError( state ),
|
115 |
+
hasFailed: isPaymentFailed( state ),
|
116 |
+
isSuccessful: isPaymentSuccess( state ),
|
117 |
+
isDoingExpressPayment: isExpressPaymentMethodActive( state ),
|
118 |
+
};
|
119 |
};
|
120 |
|
121 |
+
export const getShouldSavePaymentMethod = ( state: PaymentState ) => {
|
122 |
return state.shouldSavePaymentMethod;
|
123 |
};
|
124 |
|
125 |
+
export const getPaymentResult = ( state: PaymentState ) => {
|
126 |
+
return state.paymentResult;
|
127 |
+
};
|
128 |
+
|
129 |
+
export const getState = ( state: PaymentState ) => {
|
130 |
return state;
|
131 |
};
|
assets/js/data/payment/test/actions.ts
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
/**
|
2 |
* Internal dependencies
|
3 |
*/
|
4 |
-
import
|
5 |
import { PAYMENT_STORE_KEY } from '..';
|
6 |
import { PlainPaymentMethods } from '../../../types';
|
7 |
|
8 |
const originalDispatch = jest.requireActual( '@wordpress/data' ).dispatch;
|
9 |
|
10 |
-
jest.mock( '../set-default-payment-method', () => ( {
|
11 |
setDefaultPaymentMethod: jest.fn(),
|
12 |
} ) );
|
13 |
|
@@ -28,9 +28,7 @@ describe( 'payment data store actions', () => {
|
|
28 |
Object.keys( paymentMethods )[ 0 ]
|
29 |
);
|
30 |
actions.__internalSetAvailablePaymentMethods( paymentMethods );
|
31 |
-
expect(
|
32 |
-
setDefaultPaymentMethodFunctions.setDefaultPaymentMethod
|
33 |
-
).not.toBeCalled();
|
34 |
} );
|
35 |
|
36 |
it( 'Resets the default gateway if the current method is no longer available', () => {
|
@@ -41,9 +39,7 @@ describe( 'payment data store actions', () => {
|
|
41 |
actions.__internalSetAvailablePaymentMethods( [
|
42 |
paymentMethods[ Object.keys( paymentMethods )[ 0 ] ],
|
43 |
] );
|
44 |
-
expect(
|
45 |
-
setDefaultPaymentMethodFunctions.setDefaultPaymentMethod
|
46 |
-
).toBeCalled();
|
47 |
} );
|
48 |
} );
|
49 |
} );
|
1 |
/**
|
2 |
* Internal dependencies
|
3 |
*/
|
4 |
+
import { setDefaultPaymentMethod as setDefaultPaymentMethodOriginal } from '../utils/set-default-payment-method';
|
5 |
import { PAYMENT_STORE_KEY } from '..';
|
6 |
import { PlainPaymentMethods } from '../../../types';
|
7 |
|
8 |
const originalDispatch = jest.requireActual( '@wordpress/data' ).dispatch;
|
9 |
|
10 |
+
jest.mock( '../utils/set-default-payment-method', () => ( {
|
11 |
setDefaultPaymentMethod: jest.fn(),
|
12 |
} ) );
|
13 |
|
28 |
Object.keys( paymentMethods )[ 0 ]
|
29 |
);
|
30 |
actions.__internalSetAvailablePaymentMethods( paymentMethods );
|
31 |
+
expect( setDefaultPaymentMethodOriginal ).not.toBeCalled();
|
|
|
|
|
32 |
} );
|
33 |
|
34 |
it( 'Resets the default gateway if the current method is no longer available', () => {
|
39 |
actions.__internalSetAvailablePaymentMethods( [
|
40 |
paymentMethods[ Object.keys( paymentMethods )[ 0 ] ],
|
41 |
] );
|
42 |
+
expect( setDefaultPaymentMethodOriginal ).toBeCalled();
|
|
|
|
|
43 |
} );
|
44 |
} );
|
45 |
} );
|
assets/js/data/payment/test/check-payment-methods.tsx
ADDED
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import * as wpDataFunctions from '@wordpress/data';
|
5 |
+
import { PAYMENT_STORE_KEY } from '@woocommerce/block-data';
|
6 |
+
import {
|
7 |
+
registerPaymentMethod,
|
8 |
+
registerExpressPaymentMethod,
|
9 |
+
__experimentalDeRegisterPaymentMethod,
|
10 |
+
__experimentalDeRegisterExpressPaymentMethod,
|
11 |
+
} from '@woocommerce/blocks-registry';
|
12 |
+
import { CanMakePaymentArgument } from '@woocommerce/type-defs/payments';
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Internal dependencies
|
16 |
+
*/
|
17 |
+
import { checkPaymentMethodsCanPay } from '../utils/check-payment-methods';
|
18 |
+
|
19 |
+
const requiredKeyCheck = ( args: CanMakePaymentArgument ) => {
|
20 |
+
const requiredKeys = [
|
21 |
+
'billingData',
|
22 |
+
'billingAddress',
|
23 |
+
'cart',
|
24 |
+
'cartNeedsShipping',
|
25 |
+
'cartTotals',
|
26 |
+
'paymentRequirements',
|
27 |
+
'selectedShippingMethods',
|
28 |
+
'shippingAddress',
|
29 |
+
];
|
30 |
+
const argKeys = Object.keys( args );
|
31 |
+
|
32 |
+
const requiredCartKeys = [
|
33 |
+
'cartCoupons',
|
34 |
+
'cartItems',
|
35 |
+
'crossSellsProducts',
|
36 |
+
'cartFees',
|
37 |
+
'cartItemsCount',
|
38 |
+
'cartItemsWeight',
|
39 |
+
'cartNeedsPayment',
|
40 |
+
'cartNeedsShipping',
|
41 |
+
'cartItemErrors',
|
42 |
+
'cartTotals',
|
43 |
+
'cartIsLoading',
|
44 |
+
'cartErrors',
|
45 |
+
'billingData',
|
46 |
+
'billingAddress',
|
47 |
+
'shippingAddress',
|
48 |
+
'extensions',
|
49 |
+
'shippingRates',
|
50 |
+
'isLoadingRates',
|
51 |
+
'cartHasCalculatedShipping',
|
52 |
+
'paymentRequirements',
|
53 |
+
'receiveCart',
|
54 |
+
];
|
55 |
+
const cartKeys = Object.keys( args.cart );
|
56 |
+
const requiredTotalsKeys = [
|
57 |
+
'total_items',
|
58 |
+
'total_items_tax',
|
59 |
+
'total_fees',
|
60 |
+
'total_fees_tax',
|
61 |
+
'total_discount',
|
62 |
+
'total_discount_tax',
|
63 |
+
'total_shipping',
|
64 |
+
'total_shipping_tax',
|
65 |
+
'total_price',
|
66 |
+
'total_tax',
|
67 |
+
'tax_lines',
|
68 |
+
'currency_code',
|
69 |
+
'currency_symbol',
|
70 |
+
'currency_minor_unit',
|
71 |
+
'currency_decimal_separator',
|
72 |
+
'currency_thousand_separator',
|
73 |
+
'currency_prefix',
|
74 |
+
'currency_suffix',
|
75 |
+
];
|
76 |
+
const totalsKeys = Object.keys( args.cartTotals );
|
77 |
+
return (
|
78 |
+
requiredKeys.every( ( key ) => argKeys.includes( key ) ) &&
|
79 |
+
requiredTotalsKeys.every( ( key ) => totalsKeys.includes( key ) ) &&
|
80 |
+
requiredCartKeys.every( ( key ) => cartKeys.includes( key ) )
|
81 |
+
);
|
82 |
+
};
|
83 |
+
|
84 |
+
const mockedCanMakePayment = jest.fn().mockImplementation( requiredKeyCheck );
|
85 |
+
const mockedExpressCanMakePayment = jest
|
86 |
+
.fn()
|
87 |
+
.mockImplementation( requiredKeyCheck );
|
88 |
+
|
89 |
+
const registerMockPaymentMethods = ( savedCards = true ) => {
|
90 |
+
[ 'credit-card' ].forEach( ( name ) => {
|
91 |
+
registerPaymentMethod( {
|
92 |
+
name,
|
93 |
+
label: name,
|
94 |
+
content: <div>A payment method</div>,
|
95 |
+
edit: <div>A payment method</div>,
|
96 |
+
icons: null,
|
97 |
+
canMakePayment: mockedCanMakePayment,
|
98 |
+
supports: {
|
99 |
+
showSavedCards: savedCards,
|
100 |
+
showSaveOption: true,
|
101 |
+
features: [ 'products' ],
|
102 |
+
},
|
103 |
+
ariaLabel: name,
|
104 |
+
} );
|
105 |
+
} );
|
106 |
+
[ 'express-payment' ].forEach( ( name ) => {
|
107 |
+
const Content = ( {
|
108 |
+
onClose = () => void null,
|
109 |
+
onClick = () => void null,
|
110 |
+
} ) => {
|
111 |
+
return (
|
112 |
+
<>
|
113 |
+
<button onClick={ onClick }>
|
114 |
+
{ name + ' express payment method' }
|
115 |
+
</button>
|
116 |
+
<button onClick={ onClose }>
|
117 |
+
{ name + ' express payment method close' }
|
118 |
+
</button>
|
119 |
+
</>
|
120 |
+
);
|
121 |
+
};
|
122 |
+
registerExpressPaymentMethod( {
|
123 |
+
name,
|
124 |
+
content: <Content />,
|
125 |
+
edit: <div>An express payment method</div>,
|
126 |
+
canMakePayment: mockedExpressCanMakePayment,
|
127 |
+
paymentMethodId: name,
|
128 |
+
supports: {
|
129 |
+
features: [ 'products' ],
|
130 |
+
},
|
131 |
+
} );
|
132 |
+
} );
|
133 |
+
wpDataFunctions
|
134 |
+
.dispatch( PAYMENT_STORE_KEY )
|
135 |
+
.__internalUpdateAvailablePaymentMethods();
|
136 |
+
};
|
137 |
+
|
138 |
+
const resetMockPaymentMethods = () => {
|
139 |
+
[ 'cheque', 'bacs', 'credit-card' ].forEach( ( name ) => {
|
140 |
+
__experimentalDeRegisterPaymentMethod( name );
|
141 |
+
} );
|
142 |
+
[ 'express-payment' ].forEach( ( name ) => {
|
143 |
+
__experimentalDeRegisterExpressPaymentMethod( name );
|
144 |
+
} );
|
145 |
+
};
|
146 |
+
|
147 |
+
describe( 'checkPaymentMethods', () => {
|
148 |
+
beforeEach( registerMockPaymentMethods );
|
149 |
+
afterEach( resetMockPaymentMethods );
|
150 |
+
|
151 |
+
it( `Sends correct arguments to regular payment methods' canMakePayment functions`, async () => {
|
152 |
+
await checkPaymentMethodsCanPay();
|
153 |
+
expect( mockedCanMakePayment ).toHaveReturnedWith( true );
|
154 |
+
} );
|
155 |
+
|
156 |
+
it( `Sends correct arguments to express payment methods' canMakePayment functions`, async () => {
|
157 |
+
await checkPaymentMethodsCanPay( true );
|
158 |
+
expect( mockedExpressCanMakePayment ).toHaveReturnedWith( true );
|
159 |
+
} );
|
160 |
+
} );
|
assets/js/data/payment/test/reducers.js
CHANGED
@@ -6,13 +6,11 @@ import deepFreeze from 'deep-freeze';
|
|
6 |
/**
|
7 |
* Internal dependencies
|
8 |
*/
|
9 |
-
import { STATUS as PAYMENT_STATUS } from '../constants';
|
10 |
import reducer from '../reducers';
|
11 |
import { ACTION_TYPES } from '../action-types';
|
12 |
|
13 |
describe( 'paymentMethodDataReducer', () => {
|
14 |
const originalState = deepFreeze( {
|
15 |
-
paymentStatuses: PAYMENT_STATUS,
|
16 |
currentStatus: {
|
17 |
isPristine: true,
|
18 |
isStarted: false,
|
@@ -21,14 +19,12 @@ describe( 'paymentMethodDataReducer', () => {
|
|
21 |
hasError: false,
|
22 |
hasFailed: false,
|
23 |
isSuccessful: false,
|
24 |
-
isDoingExpressPayment: false,
|
25 |
},
|
26 |
availablePaymentMethods: {},
|
27 |
availableExpressPaymentMethods: {},
|
28 |
paymentMethodData: {},
|
29 |
paymentMethodsInitialized: false,
|
30 |
expressPaymentMethodsInitialized: false,
|
31 |
-
isExpressPaymentMethodActive: false,
|
32 |
shouldSavePaymentMethod: false,
|
33 |
errorMessage: '',
|
34 |
activePaymentMethod: '',
|
@@ -41,7 +37,6 @@ describe( 'paymentMethodDataReducer', () => {
|
|
41 |
paymentMethods: { 'my-new-method': { express: false } },
|
42 |
} );
|
43 |
expect( nextState ).toEqual( {
|
44 |
-
paymentStatuses: PAYMENT_STATUS,
|
45 |
currentStatus: {
|
46 |
isPristine: true,
|
47 |
isStarted: false,
|
@@ -50,14 +45,12 @@ describe( 'paymentMethodDataReducer', () => {
|
|
50 |
hasError: false,
|
51 |
hasFailed: false,
|
52 |
isSuccessful: false,
|
53 |
-
isDoingExpressPayment: false,
|
54 |
},
|
55 |
availablePaymentMethods: { 'my-new-method': { express: false } },
|
56 |
availableExpressPaymentMethods: {},
|
57 |
paymentMethodData: {},
|
58 |
paymentMethodsInitialized: false,
|
59 |
expressPaymentMethodsInitialized: false,
|
60 |
-
isExpressPaymentMethodActive: false,
|
61 |
shouldSavePaymentMethod: false,
|
62 |
errorMessage: '',
|
63 |
activePaymentMethod: '',
|
@@ -67,7 +60,6 @@ describe( 'paymentMethodDataReducer', () => {
|
|
67 |
|
68 |
it( 'sets state as expected when removing a payment method', () => {
|
69 |
const stateWithRegisteredMethod = deepFreeze( {
|
70 |
-
paymentStatuses: PAYMENT_STATUS,
|
71 |
currentStatus: {
|
72 |
isPristine: true,
|
73 |
isStarted: false,
|
@@ -76,14 +68,12 @@ describe( 'paymentMethodDataReducer', () => {
|
|
76 |
hasError: false,
|
77 |
hasFailed: false,
|
78 |
isSuccessful: false,
|
79 |
-
isDoingExpressPayment: false,
|
80 |
},
|
81 |
availablePaymentMethods: { 'my-new-method': { express: false } },
|
82 |
availableExpressPaymentMethods: {},
|
83 |
paymentMethodData: {},
|
84 |
paymentMethodsInitialized: false,
|
85 |
expressPaymentMethodsInitialized: false,
|
86 |
-
isExpressPaymentMethodActive: false,
|
87 |
shouldSavePaymentMethod: false,
|
88 |
errorMessage: '',
|
89 |
activePaymentMethod: '',
|
@@ -94,7 +84,6 @@ describe( 'paymentMethodDataReducer', () => {
|
|
94 |
name: 'my-new-method',
|
95 |
} );
|
96 |
expect( nextState ).toEqual( {
|
97 |
-
paymentStatuses: PAYMENT_STATUS,
|
98 |
currentStatus: {
|
99 |
isPristine: true,
|
100 |
isStarted: false,
|
@@ -103,14 +92,12 @@ describe( 'paymentMethodDataReducer', () => {
|
|
103 |
hasError: false,
|
104 |
hasFailed: false,
|
105 |
isSuccessful: false,
|
106 |
-
isDoingExpressPayment: false,
|
107 |
},
|
108 |
availablePaymentMethods: {},
|
109 |
availableExpressPaymentMethods: {},
|
110 |
paymentMethodData: {},
|
111 |
paymentMethodsInitialized: false,
|
112 |
expressPaymentMethodsInitialized: false,
|
113 |
-
isExpressPaymentMethodActive: false,
|
114 |
shouldSavePaymentMethod: false,
|
115 |
errorMessage: '',
|
116 |
activePaymentMethod: '',
|
@@ -124,7 +111,6 @@ describe( 'paymentMethodDataReducer', () => {
|
|
124 |
paymentMethods: { 'my-new-method': { express: true } },
|
125 |
} );
|
126 |
expect( nextState ).toEqual( {
|
127 |
-
paymentStatuses: PAYMENT_STATUS,
|
128 |
currentStatus: {
|
129 |
isPristine: true,
|
130 |
isStarted: false,
|
@@ -133,7 +119,6 @@ describe( 'paymentMethodDataReducer', () => {
|
|
133 |
hasError: false,
|
134 |
hasFailed: false,
|
135 |
isSuccessful: false,
|
136 |
-
isDoingExpressPayment: false,
|
137 |
},
|
138 |
availablePaymentMethods: {},
|
139 |
availableExpressPaymentMethods: {
|
@@ -142,7 +127,6 @@ describe( 'paymentMethodDataReducer', () => {
|
|
142 |
paymentMethodData: {},
|
143 |
paymentMethodsInitialized: false,
|
144 |
expressPaymentMethodsInitialized: false,
|
145 |
-
isExpressPaymentMethodActive: false,
|
146 |
shouldSavePaymentMethod: false,
|
147 |
errorMessage: '',
|
148 |
activePaymentMethod: '',
|
@@ -152,7 +136,6 @@ describe( 'paymentMethodDataReducer', () => {
|
|
152 |
|
153 |
it( 'sets state as expected when removing an express payment method', () => {
|
154 |
const stateWithRegisteredMethod = deepFreeze( {
|
155 |
-
paymentStatuses: PAYMENT_STATUS,
|
156 |
currentStatus: {
|
157 |
isPristine: true,
|
158 |
isStarted: false,
|
@@ -161,14 +144,12 @@ describe( 'paymentMethodDataReducer', () => {
|
|
161 |
hasError: false,
|
162 |
hasFailed: false,
|
163 |
isSuccessful: false,
|
164 |
-
isDoingExpressPayment: false,
|
165 |
},
|
166 |
availablePaymentMethods: {},
|
167 |
availableExpressPaymentMethods: [ 'my-new-method' ],
|
168 |
paymentMethodData: {},
|
169 |
paymentMethodsInitialized: false,
|
170 |
expressPaymentMethodsInitialized: false,
|
171 |
-
isExpressPaymentMethodActive: false,
|
172 |
shouldSavePaymentMethod: false,
|
173 |
errorMessage: '',
|
174 |
activePaymentMethod: '',
|
@@ -179,7 +160,6 @@ describe( 'paymentMethodDataReducer', () => {
|
|
179 |
name: 'my-new-method',
|
180 |
} );
|
181 |
expect( nextState ).toEqual( {
|
182 |
-
paymentStatuses: PAYMENT_STATUS,
|
183 |
currentStatus: {
|
184 |
isPristine: true,
|
185 |
isStarted: false,
|
@@ -188,18 +168,37 @@ describe( 'paymentMethodDataReducer', () => {
|
|
188 |
hasError: false,
|
189 |
hasFailed: false,
|
190 |
isSuccessful: false,
|
191 |
-
isDoingExpressPayment: false,
|
192 |
},
|
193 |
availablePaymentMethods: {},
|
194 |
availableExpressPaymentMethods: {},
|
195 |
paymentMethodData: {},
|
196 |
paymentMethodsInitialized: false,
|
197 |
expressPaymentMethodsInitialized: false,
|
198 |
-
isExpressPaymentMethodActive: false,
|
199 |
shouldSavePaymentMethod: false,
|
200 |
errorMessage: '',
|
201 |
activePaymentMethod: '',
|
202 |
activeSavedToken: '',
|
203 |
} );
|
204 |
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
} );
|
6 |
/**
|
7 |
* Internal dependencies
|
8 |
*/
|
|
|
9 |
import reducer from '../reducers';
|
10 |
import { ACTION_TYPES } from '../action-types';
|
11 |
|
12 |
describe( 'paymentMethodDataReducer', () => {
|
13 |
const originalState = deepFreeze( {
|
|
|
14 |
currentStatus: {
|
15 |
isPristine: true,
|
16 |
isStarted: false,
|
19 |
hasError: false,
|
20 |
hasFailed: false,
|
21 |
isSuccessful: false,
|
|
|
22 |
},
|
23 |
availablePaymentMethods: {},
|
24 |
availableExpressPaymentMethods: {},
|
25 |
paymentMethodData: {},
|
26 |
paymentMethodsInitialized: false,
|
27 |
expressPaymentMethodsInitialized: false,
|
|
|
28 |
shouldSavePaymentMethod: false,
|
29 |
errorMessage: '',
|
30 |
activePaymentMethod: '',
|
37 |
paymentMethods: { 'my-new-method': { express: false } },
|
38 |
} );
|
39 |
expect( nextState ).toEqual( {
|
|
|
40 |
currentStatus: {
|
41 |
isPristine: true,
|
42 |
isStarted: false,
|
45 |
hasError: false,
|
46 |
hasFailed: false,
|
47 |
isSuccessful: false,
|
|
|
48 |
},
|
49 |
availablePaymentMethods: { 'my-new-method': { express: false } },
|
50 |
availableExpressPaymentMethods: {},
|
51 |
paymentMethodData: {},
|
52 |
paymentMethodsInitialized: false,
|
53 |
expressPaymentMethodsInitialized: false,
|
|
|
54 |
shouldSavePaymentMethod: false,
|
55 |
errorMessage: '',
|
56 |
activePaymentMethod: '',
|
60 |
|
61 |
it( 'sets state as expected when removing a payment method', () => {
|
62 |
const stateWithRegisteredMethod = deepFreeze( {
|
|
|
63 |
currentStatus: {
|
64 |
isPristine: true,
|
65 |
isStarted: false,
|
68 |
hasError: false,
|
69 |
hasFailed: false,
|
70 |
isSuccessful: false,
|
|
|
71 |
},
|
72 |
availablePaymentMethods: { 'my-new-method': { express: false } },
|
73 |
availableExpressPaymentMethods: {},
|
74 |
paymentMethodData: {},
|
75 |
paymentMethodsInitialized: false,
|
76 |
expressPaymentMethodsInitialized: false,
|
|
|
77 |
shouldSavePaymentMethod: false,
|
78 |
errorMessage: '',
|
79 |
activePaymentMethod: '',
|
84 |
name: 'my-new-method',
|
85 |
} );
|
86 |
expect( nextState ).toEqual( {
|
|
|
87 |
currentStatus: {
|
88 |
isPristine: true,
|
89 |
isStarted: false,
|
92 |
hasError: false,
|
93 |
hasFailed: false,
|
94 |
isSuccessful: false,
|
|
|
95 |
},
|
96 |
availablePaymentMethods: {},
|
97 |
availableExpressPaymentMethods: {},
|
98 |
paymentMethodData: {},
|
99 |
paymentMethodsInitialized: false,
|
100 |
expressPaymentMethodsInitialized: false,
|
|
|
101 |
shouldSavePaymentMethod: false,
|
102 |
errorMessage: '',
|
103 |
activePaymentMethod: '',
|
111 |
paymentMethods: { 'my-new-method': { express: true } },
|
112 |
} );
|
113 |
expect( nextState ).toEqual( {
|
|
|
114 |
currentStatus: {
|
115 |
isPristine: true,
|
116 |
isStarted: false,
|
119 |
hasError: false,
|
120 |
hasFailed: false,
|
121 |
isSuccessful: false,
|
|
|
122 |
},
|
123 |
availablePaymentMethods: {},
|
124 |
availableExpressPaymentMethods: {
|
127 |
paymentMethodData: {},
|
128 |
paymentMethodsInitialized: false,
|
129 |
expressPaymentMethodsInitialized: false,
|
|
|
130 |
shouldSavePaymentMethod: false,
|
131 |
errorMessage: '',
|
132 |
activePaymentMethod: '',
|
136 |
|
137 |
it( 'sets state as expected when removing an express payment method', () => {
|
138 |
const stateWithRegisteredMethod = deepFreeze( {
|
|
|
139 |
currentStatus: {
|
140 |
isPristine: true,
|
141 |
isStarted: false,
|
144 |
hasError: false,
|
145 |
hasFailed: false,
|
146 |
isSuccessful: false,
|
|
|
147 |
},
|
148 |
availablePaymentMethods: {},
|
149 |
availableExpressPaymentMethods: [ 'my-new-method' ],
|
150 |
paymentMethodData: {},
|
151 |
paymentMethodsInitialized: false,
|
152 |
expressPaymentMethodsInitialized: false,
|
|
|
153 |
shouldSavePaymentMethod: false,
|
154 |
errorMessage: '',
|
155 |
activePaymentMethod: '',
|
160 |
name: 'my-new-method',
|
161 |
} );
|
162 |
expect( nextState ).toEqual( {
|
|
|
163 |
currentStatus: {
|
164 |
isPristine: true,
|
165 |
isStarted: false,
|
168 |
hasError: false,
|
169 |
hasFailed: false,
|
170 |
isSuccessful: false,
|
|
|
171 |
},
|
172 |
availablePaymentMethods: {},
|
173 |
availableExpressPaymentMethods: {},
|
174 |
paymentMethodData: {},
|
175 |
paymentMethodsInitialized: false,
|
176 |
expressPaymentMethodsInitialized: false,
|
|
|
177 |
shouldSavePaymentMethod: false,
|
178 |
errorMessage: '',
|
179 |
activePaymentMethod: '',
|
180 |
activeSavedToken: '',
|
181 |
} );
|
182 |
} );
|
183 |
+
|
184 |
+
it( 'should handle SET_PAYMENT_RESULT', () => {
|
185 |
+
const mockResponse = {
|
186 |
+
message: 'success',
|
187 |
+
redirectUrl: 'https://example.com',
|
188 |
+
paymentStatus: 'not set',
|
189 |
+
paymentDetails: {},
|
190 |
+
};
|
191 |
+
|
192 |
+
const expectedState = {
|
193 |
+
...originalState,
|
194 |
+
paymentResult: mockResponse,
|
195 |
+
};
|
196 |
+
|
197 |
+
expect(
|
198 |
+
reducer( originalState, {
|
199 |
+
type: ACTION_TYPES.SET_PAYMENT_RESULT,
|
200 |
+
data: mockResponse,
|
201 |
+
} )
|
202 |
+
).toEqual( expectedState );
|
203 |
+
} );
|
204 |
} );
|
assets/js/data/payment/test/set-default-payment-method.ts
CHANGED
@@ -7,7 +7,7 @@ import * as wpDataFunctions from '@wordpress/data';
|
|
7 |
/**
|
8 |
* Internal dependencies
|
9 |
*/
|
10 |
-
import { setDefaultPaymentMethod } from '../set-default-payment-method';
|
11 |
import { PlainPaymentMethods } from '../../../types';
|
12 |
import { PAYMENT_STORE_KEY } from '..';
|
13 |
|
@@ -28,7 +28,7 @@ describe( 'setDefaultPaymentMethod', () => {
|
|
28 |
},
|
29 |
};
|
30 |
|
31 |
-
it( '
|
32 |
jest.spyOn( wpDataFunctions, 'select' ).mockImplementation(
|
33 |
( storeName ) => {
|
34 |
const originalStore = originalSelect( storeName );
|
@@ -72,7 +72,7 @@ describe( 'setDefaultPaymentMethod', () => {
|
|
72 |
'wc-payment-gateway-1'
|
73 |
);
|
74 |
} );
|
75 |
-
it( '
|
76 |
jest.spyOn( wpDataFunctions, 'select' ).mockImplementation(
|
77 |
( storeName ) => {
|
78 |
const originalStore = originalSelect( storeName );
|
@@ -125,7 +125,12 @@ describe( 'setDefaultPaymentMethod', () => {
|
|
125 |
...originalStore,
|
126 |
__internalSetActivePaymentMethod:
|
127 |
setActivePaymentMethodMock,
|
128 |
-
|
|
|
|
|
|
|
|
|
|
|
129 |
};
|
130 |
}
|
131 |
return originalStore;
|
7 |
/**
|
8 |
* Internal dependencies
|
9 |
*/
|
10 |
+
import { setDefaultPaymentMethod } from '../utils/set-default-payment-method';
|
11 |
import { PlainPaymentMethods } from '../../../types';
|
12 |
import { PAYMENT_STORE_KEY } from '..';
|
13 |
|
28 |
},
|
29 |
};
|
30 |
|
31 |
+
it( 'correctly sets the first payment method in the list of available payment methods', async () => {
|
32 |
jest.spyOn( wpDataFunctions, 'select' ).mockImplementation(
|
33 |
( storeName ) => {
|
34 |
const originalStore = originalSelect( storeName );
|
72 |
'wc-payment-gateway-1'
|
73 |
);
|
74 |
} );
|
75 |
+
it( 'correctly sets the saved payment method if one is available', async () => {
|
76 |
jest.spyOn( wpDataFunctions, 'select' ).mockImplementation(
|
77 |
( storeName ) => {
|
78 |
const originalStore = originalSelect( storeName );
|
125 |
...originalStore,
|
126 |
__internalSetActivePaymentMethod:
|
127 |
setActivePaymentMethodMock,
|
128 |
+
__internalSetPaymentError: () => void 0,
|
129 |
+
__internalSetPaymentFailed: () => void 0,
|
130 |
+
__internalSetPaymentSuccess: () => void 0,
|
131 |
+
__internalSetPaymentPristine: () => void 0,
|
132 |
+
__internalSetPaymentStarted: () => void 0,
|
133 |
+
__internalSetPaymentProcessing: () => void 0,
|
134 |
};
|
135 |
}
|
136 |
return originalStore;
|
assets/js/data/payment/test/utils.js
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* Internal dependencies
|
3 |
-
*/
|
4 |
-
import { orderPaymentMethods } from '../utils';
|
5 |
-
|
6 |
-
describe( 'orderPaymentMethods', () => {
|
7 |
-
it( 'orders methods correctly', () => {
|
8 |
-
const order = [ 'cheque', 'cod', 'bacs', 'stripe' ];
|
9 |
-
const methods = [ 'cod', 'bacs', 'stripe', 'cheque' ];
|
10 |
-
const orderedMethods = orderPaymentMethods( order, methods );
|
11 |
-
expect( orderedMethods ).toStrictEqual( order );
|
12 |
-
} );
|
13 |
-
it( 'orders methods correctly and appends missing ones', () => {
|
14 |
-
const order = [ 'cheque', 'cod', 'bacs', 'stripe' ];
|
15 |
-
const methods = [ 'cod', 'paypal', 'bacs', 'stripe', 'cheque' ];
|
16 |
-
const orderedMethods = orderPaymentMethods( order, methods );
|
17 |
-
expect( orderedMethods ).toStrictEqual( [
|
18 |
-
'cheque',
|
19 |
-
'cod',
|
20 |
-
'bacs',
|
21 |
-
'stripe',
|
22 |
-
'paypal',
|
23 |
-
] );
|
24 |
-
} );
|
25 |
-
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/data/payment/thunks.ts
CHANGED
@@ -85,9 +85,7 @@ export const __internalEmitPaymentProcessingEvent: emitProcessingEventType = (
|
|
85 |
);
|
86 |
}
|
87 |
dispatch.__internalSetPaymentMethodData( paymentMethodData );
|
88 |
-
dispatch.
|
89 |
-
isSuccessful: true,
|
90 |
-
} );
|
91 |
} else if ( errorResponse && isFailResponse( errorResponse ) ) {
|
92 |
if ( errorResponse.message && errorResponse.message.length ) {
|
93 |
createErrorNotice( errorResponse.message, {
|
@@ -105,10 +103,8 @@ export const __internalEmitPaymentProcessingEvent: emitProcessingEventType = (
|
|
105 |
if ( billingAddress ) {
|
106 |
setBillingAddress( billingAddress );
|
107 |
}
|
108 |
-
dispatch.
|
109 |
-
|
110 |
-
paymentMethodData
|
111 |
-
);
|
112 |
} else if ( errorResponse ) {
|
113 |
if ( errorResponse.message && errorResponse.message.length ) {
|
114 |
createErrorNotice( errorResponse.message, {
|
@@ -120,14 +116,12 @@ export const __internalEmitPaymentProcessingEvent: emitProcessingEventType = (
|
|
120 |
} );
|
121 |
}
|
122 |
|
123 |
-
dispatch.
|
124 |
setValidationErrors( errorResponse?.validationErrors );
|
125 |
} else {
|
126 |
// otherwise there are no payment methods doing anything so
|
127 |
// just consider success
|
128 |
-
dispatch.
|
129 |
-
isSuccessful: true,
|
130 |
-
} );
|
131 |
}
|
132 |
} );
|
133 |
};
|
85 |
);
|
86 |
}
|
87 |
dispatch.__internalSetPaymentMethodData( paymentMethodData );
|
88 |
+
dispatch.__internalSetPaymentSuccess();
|
|
|
|
|
89 |
} else if ( errorResponse && isFailResponse( errorResponse ) ) {
|
90 |
if ( errorResponse.message && errorResponse.message.length ) {
|
91 |
createErrorNotice( errorResponse.message, {
|
103 |
if ( billingAddress ) {
|
104 |
setBillingAddress( billingAddress );
|
105 |
}
|
106 |
+
dispatch.__internalSetPaymentFailed();
|
107 |
+
dispatch.__internalSetPaymentMethodData( paymentMethodData );
|
|
|
|
|
108 |
} else if ( errorResponse ) {
|
109 |
if ( errorResponse.message && errorResponse.message.length ) {
|
110 |
createErrorNotice( errorResponse.message, {
|
116 |
} );
|
117 |
}
|
118 |
|
119 |
+
dispatch.__internalSetPaymentError();
|
120 |
setValidationErrors( errorResponse?.validationErrors );
|
121 |
} else {
|
122 |
// otherwise there are no payment methods doing anything so
|
123 |
// just consider success
|
124 |
+
dispatch.__internalSetPaymentSuccess();
|
|
|
|
|
125 |
}
|
126 |
} );
|
127 |
};
|
assets/js/data/payment/types.ts
CHANGED
@@ -65,25 +65,6 @@ export interface PaymentStatusDispatchers {
|
|
65 |
) => void;
|
66 |
}
|
67 |
|
68 |
-
export type PaymentMethodCurrentStatusType = {
|
69 |
-
// If true then the payment method state in checkout is pristine.
|
70 |
-
isPristine: boolean;
|
71 |
-
// If true then the payment method has been initialized and has started.
|
72 |
-
isStarted: boolean;
|
73 |
-
// If true then the payment method is processing payment.
|
74 |
-
isProcessing: boolean;
|
75 |
-
// If true then the payment method is in a finished state (which may mean it's status is either error, failed, or success).
|
76 |
-
isFinished: boolean;
|
77 |
-
// If true then the payment method is in an error state.
|
78 |
-
hasError: boolean;
|
79 |
-
// If true then the payment method has failed (usually indicates a problem with the payment method used, not logic error).
|
80 |
-
hasFailed: boolean;
|
81 |
-
// If true then the payment method has completed it's processing successfully.
|
82 |
-
isSuccessful: boolean;
|
83 |
-
// If true, an express payment is in progress.
|
84 |
-
isDoingExpressPayment: boolean;
|
85 |
-
};
|
86 |
-
|
87 |
export type PaymentMethodsDispatcherType = (
|
88 |
paymentMethods: PlainPaymentMethods
|
89 |
) => undefined | void;
|
@@ -112,5 +93,4 @@ export interface PaymentStatus {
|
|
112 |
hasError?: boolean;
|
113 |
hasFailed?: boolean;
|
114 |
isSuccessful?: boolean;
|
115 |
-
isDoingExpressPayment?: boolean;
|
116 |
}
|
65 |
) => void;
|
66 |
}
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
export type PaymentMethodsDispatcherType = (
|
69 |
paymentMethods: PlainPaymentMethods
|
70 |
) => undefined | void;
|
93 |
hasError?: boolean;
|
94 |
hasFailed?: boolean;
|
95 |
isSuccessful?: boolean;
|
|
|
96 |
}
|
assets/js/data/payment/{check-payment-methods.ts → utils/check-payment-methods.ts}
RENAMED
@@ -23,18 +23,18 @@ import { previewCart } from '@woocommerce/resource-previews';
|
|
23 |
/**
|
24 |
* Internal dependencies
|
25 |
*/
|
26 |
-
import { STORE_KEY as CART_STORE_KEY } from '
|
27 |
-
import { STORE_KEY as PAYMENT_STORE_KEY } from '
|
28 |
-
import { noticeContexts } from '
|
29 |
import {
|
30 |
EMPTY_CART_ERRORS,
|
31 |
EMPTY_CART_ITEM_ERRORS,
|
32 |
EMPTY_EXTENSIONS,
|
33 |
-
} from '../../
|
34 |
import {
|
35 |
defaultBillingAddress,
|
36 |
defaultShippingAddress,
|
37 |
-
} from '
|
38 |
|
39 |
export const checkPaymentMethodsCanPay = async ( express = false ) => {
|
40 |
const isEditor = !! select( 'core/editor' );
|
@@ -129,11 +129,8 @@ export const checkPaymentMethodsCanPay = async ( express = false ) => {
|
|
129 |
shippingRates: previewCart.shipping_rates,
|
130 |
isLoadingRates: false,
|
131 |
cartHasCalculatedShipping: previewCart.has_calculated_shipping,
|
132 |
-
paymentRequirements: previewCart.
|
133 |
-
receiveCart:
|
134 |
-
typeof previewCart?.receiveCart === 'function'
|
135 |
-
? previewCart.receiveCart
|
136 |
-
: () => undefined,
|
137 |
};
|
138 |
canPayArgument = {
|
139 |
cart: cartForCanPayArgument,
|
@@ -149,6 +146,7 @@ export const checkPaymentMethodsCanPay = async ( express = false ) => {
|
|
149 |
};
|
150 |
}
|
151 |
|
|
|
152 |
let paymentMethodsOrder;
|
153 |
if ( express ) {
|
154 |
paymentMethodsOrder = Object.keys( paymentMethods );
|
23 |
/**
|
24 |
* Internal dependencies
|
25 |
*/
|
26 |
+
import { STORE_KEY as CART_STORE_KEY } from '../../cart/constants';
|
27 |
+
import { STORE_KEY as PAYMENT_STORE_KEY } from '../constants';
|
28 |
+
import { noticeContexts } from '../../../base/context/event-emit';
|
29 |
import {
|
30 |
EMPTY_CART_ERRORS,
|
31 |
EMPTY_CART_ITEM_ERRORS,
|
32 |
EMPTY_EXTENSIONS,
|
33 |
+
} from '../../constants';
|
34 |
import {
|
35 |
defaultBillingAddress,
|
36 |
defaultShippingAddress,
|
37 |
+
} from '../../../base/context/providers/cart-checkout/customer/constants';
|
38 |
|
39 |
export const checkPaymentMethodsCanPay = async ( express = false ) => {
|
40 |
const isEditor = !! select( 'core/editor' );
|
129 |
shippingRates: previewCart.shipping_rates,
|
130 |
isLoadingRates: false,
|
131 |
cartHasCalculatedShipping: previewCart.has_calculated_shipping,
|
132 |
+
paymentRequirements: previewCart.payment_requirements,
|
133 |
+
receiveCart: () => undefined,
|
|
|
|
|
|
|
134 |
};
|
135 |
canPayArgument = {
|
136 |
cart: cartForCanPayArgument,
|
146 |
};
|
147 |
}
|
148 |
|
149 |
+
// Order payment methods
|
150 |
let paymentMethodsOrder;
|
151 |
if ( express ) {
|
152 |
paymentMethodsOrder = Object.keys( paymentMethods );
|
assets/js/data/payment/{utils.ts → utils/filter-active-saved-payment-methods.ts}
RENAMED
@@ -6,7 +6,7 @@ import { getPaymentMethods } from '@woocommerce/blocks-registry';
|
|
6 |
/**
|
7 |
* Internal dependencies
|
8 |
*/
|
9 |
-
import type { SavedPaymentMethods } from '
|
10 |
|
11 |
/**
|
12 |
* Gets the payment methods saved for the current user after filtering out disabled ones.
|
@@ -47,28 +47,3 @@ export const filterActiveSavedPaymentMethods = (
|
|
47 |
} );
|
48 |
return activeSavedPaymentMethods;
|
49 |
};
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Given the order of methods from WooCommerce -> Payments, this method takes that order and sorts the list of available
|
53 |
-
* payment methods to match it. This is required to ensure the payment methods show up in the correct order in the
|
54 |
-
* Checkout
|
55 |
-
*
|
56 |
-
* @param order The order of payment methods from WooCommerce -> Settings -> Payments.
|
57 |
-
* @param methods The list of payment method names to add to the state as available.
|
58 |
-
*
|
59 |
-
* @return string[] The list of available methods in their correct order.
|
60 |
-
*/
|
61 |
-
export const orderPaymentMethods = ( order: string[], methods: string[] ) => {
|
62 |
-
const orderedMethods: string[] = [];
|
63 |
-
order.forEach( ( paymentMethodName ) => {
|
64 |
-
if ( methods.includes( paymentMethodName ) ) {
|
65 |
-
orderedMethods.push( paymentMethodName );
|
66 |
-
}
|
67 |
-
} );
|
68 |
-
// Now find any methods in `methods` that were not added to `orderedMethods` and append them to `orderedMethods`
|
69 |
-
methods
|
70 |
-
.filter( ( methodName ) => ! orderedMethods.includes( methodName ) )
|
71 |
-
.forEach( ( methodName ) => orderedMethods.push( methodName ) );
|
72 |
-
|
73 |
-
return orderedMethods;
|
74 |
-
};
|
6 |
/**
|
7 |
* Internal dependencies
|
8 |
*/
|
9 |
+
import type { SavedPaymentMethods } from '../types';
|
10 |
|
11 |
/**
|
12 |
* Gets the payment methods saved for the current user after filtering out disabled ones.
|
47 |
} );
|
48 |
return activeSavedPaymentMethods;
|
49 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/data/payment/{set-default-payment-method.ts → utils/set-default-payment-method.ts}
RENAMED
@@ -7,7 +7,7 @@ import { PlainPaymentMethods } from '@woocommerce/type-defs/payments';
|
|
7 |
/**
|
8 |
* Internal dependencies
|
9 |
*/
|
10 |
-
import { STORE_KEY as PAYMENT_STORE_KEY } from '
|
11 |
|
12 |
export const setDefaultPaymentMethod = async (
|
13 |
paymentMethods: PlainPaymentMethods
|
@@ -60,9 +60,7 @@ export const setDefaultPaymentMethod = async (
|
|
60 |
return;
|
61 |
}
|
62 |
|
63 |
-
dispatch( PAYMENT_STORE_KEY ).
|
64 |
-
isPristine: true,
|
65 |
-
} );
|
66 |
|
67 |
dispatch( PAYMENT_STORE_KEY ).__internalSetActivePaymentMethod(
|
68 |
paymentMethodKeys[ 0 ]
|
7 |
/**
|
8 |
* Internal dependencies
|
9 |
*/
|
10 |
+
import { STORE_KEY as PAYMENT_STORE_KEY } from '../constants';
|
11 |
|
12 |
export const setDefaultPaymentMethod = async (
|
13 |
paymentMethods: PlainPaymentMethods
|
60 |
return;
|
61 |
}
|
62 |
|
63 |
+
dispatch( PAYMENT_STORE_KEY ).__internalSetPaymentPristine();
|
|
|
|
|
64 |
|
65 |
dispatch( PAYMENT_STORE_KEY ).__internalSetActivePaymentMethod(
|
66 |
paymentMethodKeys[ 0 ]
|
assets/js/data/query-state/index.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
-
import {
|
5 |
|
6 |
/**
|
7 |
* Internal dependencies
|
@@ -11,10 +11,12 @@ import * as selectors from './selectors';
|
|
11 |
import * as actions from './actions';
|
12 |
import reducer from './reducers';
|
13 |
|
14 |
-
|
15 |
reducer,
|
16 |
actions,
|
17 |
selectors,
|
18 |
} );
|
19 |
|
|
|
|
|
20 |
export const QUERY_STATE_STORE_KEY = STORE_KEY;
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
+
import { register, createReduxStore } from '@wordpress/data';
|
5 |
|
6 |
/**
|
7 |
* Internal dependencies
|
11 |
import * as actions from './actions';
|
12 |
import reducer from './reducers';
|
13 |
|
14 |
+
const store = createReduxStore( STORE_KEY, {
|
15 |
reducer,
|
16 |
actions,
|
17 |
selectors,
|
18 |
} );
|
19 |
|
20 |
+
register( store );
|
21 |
+
|
22 |
export const QUERY_STATE_STORE_KEY = STORE_KEY;
|
assets/js/data/schema/index.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
-
import {
|
5 |
import { controls } from '@wordpress/data-controls';
|
6 |
|
7 |
/**
|
@@ -13,7 +13,7 @@ import * as actions from './actions';
|
|
13 |
import * as resolvers from './resolvers';
|
14 |
import reducer from './reducers';
|
15 |
|
16 |
-
|
17 |
reducer,
|
18 |
actions,
|
19 |
controls,
|
@@ -21,4 +21,6 @@ registerStore( STORE_KEY, {
|
|
21 |
resolvers,
|
22 |
} );
|
23 |
|
|
|
|
|
24 |
export const SCHEMA_STORE_KEY = STORE_KEY;
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
+
import { register, createReduxStore } from '@wordpress/data';
|
5 |
import { controls } from '@wordpress/data-controls';
|
6 |
|
7 |
/**
|
13 |
import * as resolvers from './resolvers';
|
14 |
import reducer from './reducers';
|
15 |
|
16 |
+
const store = createReduxStore( STORE_KEY, {
|
17 |
reducer,
|
18 |
actions,
|
19 |
controls,
|
21 |
resolvers,
|
22 |
} );
|
23 |
|
24 |
+
register( store );
|
25 |
+
|
26 |
export const SCHEMA_STORE_KEY = STORE_KEY;
|
assets/js/data/validation/action-types.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
export const ACTION_TYPES = {
|
2 |
SET_VALIDATION_ERRORS: 'SET_VALIDATION_ERRORS',
|
3 |
-
CLEAR_ALL_VALIDATION_ERRORS: 'CLEAR_ALL_VALIDATION_ERRORS',
|
4 |
CLEAR_VALIDATION_ERROR: 'CLEAR_VALIDATION_ERROR',
|
|
|
5 |
HIDE_VALIDATION_ERROR: 'HIDE_VALIDATION_ERROR',
|
6 |
SHOW_VALIDATION_ERROR: 'SHOW_VALIDATION_ERROR',
|
7 |
SHOW_ALL_VALIDATION_ERRORS: 'SHOW_ALL_VALIDATION_ERRORS',
|
1 |
export const ACTION_TYPES = {
|
2 |
SET_VALIDATION_ERRORS: 'SET_VALIDATION_ERRORS',
|
|
|
3 |
CLEAR_VALIDATION_ERROR: 'CLEAR_VALIDATION_ERROR',
|
4 |
+
CLEAR_VALIDATION_ERRORS: 'CLEAR_VALIDATION_ERRORS',
|
5 |
HIDE_VALIDATION_ERROR: 'HIDE_VALIDATION_ERROR',
|
6 |
SHOW_VALIDATION_ERROR: 'SHOW_VALIDATION_ERROR',
|
7 |
SHOW_ALL_VALIDATION_ERRORS: 'SHOW_ALL_VALIDATION_ERRORS',
|
assets/js/data/validation/actions.ts
CHANGED
@@ -1,3 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
1 |
/**
|
2 |
* Internal dependencies
|
3 |
*/
|
@@ -12,10 +17,29 @@ export const setValidationErrors = (
|
|
12 |
errors,
|
13 |
} );
|
14 |
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
} );
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
export const clearValidationError = ( error: string ) => ( {
|
20 |
type: types.CLEAR_VALIDATION_ERROR,
|
21 |
error,
|
@@ -39,6 +63,7 @@ export type ValidationAction = ReturnOrGeneratorYieldUnion<
|
|
39 |
| typeof setValidationErrors
|
40 |
| typeof clearAllValidationErrors
|
41 |
| typeof clearValidationError
|
|
|
42 |
| typeof hideValidationError
|
43 |
| typeof showValidationError
|
44 |
| typeof showAllValidationErrors
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import deprecated from '@wordpress/deprecated';
|
5 |
+
|
6 |
/**
|
7 |
* Internal dependencies
|
8 |
*/
|
17 |
errors,
|
18 |
} );
|
19 |
|
20 |
+
/**
|
21 |
+
* Clears validation errors for the given ids.
|
22 |
+
*
|
23 |
+
* @param errors Array of error ids to clear.
|
24 |
+
*/
|
25 |
+
export const clearValidationErrors = ( errors?: string[] | undefined ) => ( {
|
26 |
+
type: types.CLEAR_VALIDATION_ERRORS,
|
27 |
+
errors,
|
28 |
} );
|
29 |
|
30 |
+
export const clearAllValidationErrors = () => {
|
31 |
+
deprecated( 'clearAllValidationErrors', {
|
32 |
+
version: '9.0.0',
|
33 |
+
alternative: 'clearValidationErrors',
|
34 |
+
plugin: 'WooCommerce Blocks',
|
35 |
+
link: 'https://github.com/woocommerce/woocommerce-blocks/pull/7601',
|
36 |
+
hint: 'Calling `clearValidationErrors` with no arguments will clear all validation errors.',
|
37 |
+
} );
|
38 |
+
|
39 |
+
// Return clearValidationErrors which will clear all errors by defaults if no error ids are passed.
|
40 |
+
return clearValidationErrors();
|
41 |
+
};
|
42 |
+
|
43 |
export const clearValidationError = ( error: string ) => ( {
|
44 |
type: types.CLEAR_VALIDATION_ERROR,
|
45 |
error,
|
63 |
| typeof setValidationErrors
|
64 |
| typeof clearAllValidationErrors
|
65 |
| typeof clearValidationError
|
66 |
+
| typeof clearValidationErrors
|
67 |
| typeof hideValidationError
|
68 |
| typeof showValidationError
|
69 |
| typeof showAllValidationErrors
|
assets/js/data/validation/index.ts
CHANGED
@@ -16,10 +16,6 @@ export const config = {
|
|
16 |
reducer,
|
17 |
selectors,
|
18 |
actions,
|
19 |
-
// TODO: Gutenberg with Thunks was released in WP 6.0. Once 6.1 is released, remove the experimental flag here
|
20 |
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
21 |
-
// @ts-ignore We pass this in case there is an older version of Gutenberg running.
|
22 |
-
__experimentalUseThunks: true,
|
23 |
};
|
24 |
|
25 |
const store = createReduxStore( STORE_KEY, config );
|
16 |
reducer,
|
17 |
selectors,
|
18 |
actions,
|
|
|
|
|
|
|
|
|
19 |
};
|
20 |
|
21 |
const store = createReduxStore( STORE_KEY, config );
|
assets/js/data/validation/reducers.ts
CHANGED
@@ -33,8 +33,6 @@ const reducer: Reducer< Record< string, FieldValidationStatus > > = (
|
|
33 |
return state;
|
34 |
}
|
35 |
return { ...state, ...action.errors };
|
36 |
-
case types.CLEAR_ALL_VALIDATION_ERRORS:
|
37 |
-
return {};
|
38 |
|
39 |
case types.CLEAR_VALIDATION_ERROR:
|
40 |
if (
|
@@ -45,6 +43,20 @@ const reducer: Reducer< Record< string, FieldValidationStatus > > = (
|
|
45 |
}
|
46 |
delete newState[ action.error ];
|
47 |
return newState;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
case types.HIDE_VALIDATION_ERROR:
|
49 |
if (
|
50 |
! isString( action.error ) ||
|
33 |
return state;
|
34 |
}
|
35 |
return { ...state, ...action.errors };
|
|
|
|
|
36 |
|
37 |
case types.CLEAR_VALIDATION_ERROR:
|
38 |
if (
|
43 |
}
|
44 |
delete newState[ action.error ];
|
45 |
return newState;
|
46 |
+
case types.CLEAR_VALIDATION_ERRORS:
|
47 |
+
const { errors } = action;
|
48 |
+
if ( typeof errors === 'undefined' ) {
|
49 |
+
return {};
|
50 |
+
}
|
51 |
+
if ( ! Array.isArray( errors ) ) {
|
52 |
+
return newState;
|
53 |
+
}
|
54 |
+
errors.forEach( ( error ) => {
|
55 |
+
if ( newState.hasOwnProperty( error ) ) {
|
56 |
+
delete newState[ error ];
|
57 |
+
}
|
58 |
+
} );
|
59 |
+
return newState;
|
60 |
case types.HIDE_VALIDATION_ERROR:
|
61 |
if (
|
62 |
! isString( action.error ) ||
|
assets/js/data/validation/test/reducers.ts
CHANGED
@@ -129,7 +129,8 @@ describe( 'Validation reducer', () => {
|
|
129 |
},
|
130 |
};
|
131 |
const clearAllErrors: ValidationAction = {
|
132 |
-
type: types.
|
|
|
133 |
};
|
134 |
const nextState = reducer( state, clearAllErrors );
|
135 |
expect( nextState ).toEqual( {} );
|
@@ -155,6 +156,26 @@ describe( 'Validation reducer', () => {
|
|
155 |
expect( nextState ).toHaveProperty( 'testError' );
|
156 |
} );
|
157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
it( 'Hides a single validation error', () => {
|
159 |
const state: Record< string, FieldValidationStatus > = {
|
160 |
existingError: {
|
129 |
},
|
130 |
};
|
131 |
const clearAllErrors: ValidationAction = {
|
132 |
+
type: types.CLEAR_VALIDATION_ERRORS,
|
133 |
+
errors: undefined,
|
134 |
};
|
135 |
const nextState = reducer( state, clearAllErrors );
|
136 |
expect( nextState ).toEqual( {} );
|
156 |
expect( nextState ).toHaveProperty( 'testError' );
|
157 |
} );
|
158 |
|
159 |
+
it( 'Clears multiple validation errors', () => {
|
160 |
+
const state: Record< string, FieldValidationStatus > = {
|
161 |
+
existingError: {
|
162 |
+
message: 'This is an existing error message',
|
163 |
+
hidden: false,
|
164 |
+
},
|
165 |
+
testError: {
|
166 |
+
message: 'This is error should also be removed',
|
167 |
+
hidden: false,
|
168 |
+
},
|
169 |
+
};
|
170 |
+
const clearError: ValidationAction = {
|
171 |
+
type: types.CLEAR_VALIDATION_ERRORS,
|
172 |
+
errors: [ 'existingError', 'testError' ],
|
173 |
+
};
|
174 |
+
const nextState = reducer( state, clearError );
|
175 |
+
expect( nextState ).not.toHaveProperty( 'existingError' );
|
176 |
+
expect( nextState ).not.toHaveProperty( 'testError' );
|
177 |
+
} );
|
178 |
+
|
179 |
it( 'Hides a single validation error', () => {
|
180 |
const state: Record< string, FieldValidationStatus > = {
|
181 |
existingError: {
|
assets/js/types/type-defs/payment-method-interface.ts
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
import type PaymentMethodLabel from '@woocommerce/base-components/cart-checkout/payment-method-label';
|
6 |
import type PaymentMethodIcons from '@woocommerce/base-components/cart-checkout/payment-method-icons';
|
7 |
import type LoadingMask from '@woocommerce/base-components/loading-mask';
|
8 |
-
import
|
9 |
|
10 |
/**
|
11 |
* Internal dependencies
|
@@ -17,7 +17,6 @@ import type {
|
|
17 |
responseTypes,
|
18 |
noticeContexts,
|
19 |
} from '../../base/context/event-emit';
|
20 |
-
import type { PaymentMethodCurrentStatusType } from '../../base/context/providers/cart-checkout/payment-events/types';
|
21 |
import type {
|
22 |
CartResponseShippingAddress,
|
23 |
CartResponseCouponItem,
|
@@ -165,7 +164,16 @@ export type PaymentMethodInterface = {
|
|
165 |
// Used to trigger checkout processing.
|
166 |
onSubmit: () => void;
|
167 |
// Various payment status helpers.
|
168 |
-
paymentStatus:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
// Deprecated. For setting an error (error message string) for express payment methods. Does not change payment status.
|
170 |
setExpressPaymentError: ( errorMessage?: string ) => void;
|
171 |
// Various data related to shipping.
|
5 |
import type PaymentMethodLabel from '@woocommerce/base-components/cart-checkout/payment-method-label';
|
6 |
import type PaymentMethodIcons from '@woocommerce/base-components/cart-checkout/payment-method-icons';
|
7 |
import type LoadingMask from '@woocommerce/base-components/loading-mask';
|
8 |
+
import { ValidationInputError } from '@woocommerce/blocks-checkout';
|
9 |
|
10 |
/**
|
11 |
* Internal dependencies
|
17 |
responseTypes,
|
18 |
noticeContexts,
|
19 |
} from '../../base/context/event-emit';
|
|
|
20 |
import type {
|
21 |
CartResponseShippingAddress,
|
22 |
CartResponseCouponItem,
|
164 |
// Used to trigger checkout processing.
|
165 |
onSubmit: () => void;
|
166 |
// Various payment status helpers.
|
167 |
+
paymentStatus: {
|
168 |
+
isPristine: boolean;
|
169 |
+
isStarted: boolean;
|
170 |
+
isProcessing: boolean;
|
171 |
+
isFinished: boolean;
|
172 |
+
hasError: boolean;
|
173 |
+
hasFailed: boolean;
|
174 |
+
isSuccessful: boolean;
|
175 |
+
isDoingExpressPayment: boolean;
|
176 |
+
};
|
177 |
// Deprecated. For setting an error (error message string) for express payment methods. Does not change payment status.
|
178 |
setExpressPaymentError: ( errorMessage?: string ) => void;
|
179 |
// Various data related to shipping.
|
assets/js/types/type-defs/product-response.ts
CHANGED
@@ -20,6 +20,7 @@ export interface ProductResponseItemBaseData {
|
|
20 |
value: string;
|
21 |
display?: string;
|
22 |
hidden?: boolean;
|
|
|
23 |
}
|
24 |
|
25 |
export type ProductResponseItemData = ProductResponseItemBaseData &
|
20 |
value: string;
|
21 |
display?: string;
|
22 |
hidden?: boolean;
|
23 |
+
className?: string;
|
24 |
}
|
25 |
|
26 |
export type ProductResponseItemData = ProductResponseItemBaseData &
|
build/active-filters-frontend.asset.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php return array('dependencies' => array('lodash', 'react', 'wc-blocks-data-store', 'wc-price-format', 'wc-settings', 'wp-data', 'wp-element', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-polyfill', 'wp-primitives', 'wp-url'), 'version' => '
|
1 |
+
<?php return array('dependencies' => array('lodash', 'react', 'wc-blocks-data-store', 'wc-price-format', 'wc-settings', 'wp-data', 'wp-element', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-polyfill', 'wp-primitives', 'wp-url'), 'version' => '0b5e82e008d22aa0f108129efa4539dd');
|
build/active-filters-frontend.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
-
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var c=t[n]={i:n,l:!1,exports:{}};return e[n].call(c.exports,c,c.exports,r),c.l=!0,c.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var c in e)r.d(n,c,function(t){return e[t]}.bind(null,c));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=
|
2 |
/* translators: %s is referring to the average rating value */
|
3 |
-
Object(c.__)("Rated %s out of 5","woo-gutenberg-products-block"),e),removeCallback:()=>{if(Object(g.e)({rating_filter:e}),!j){const t=T.filter(t=>t!==e);L(t)}},showLabel:!1,displayStyle:t.displayStyle}))))},[v,T,L,t.displayStyle,j]);if(!v&&!(k.length>0||x.length>0||T.length>0||Number.isFinite(P)||Number.isFinite(C))&&!r)return a(!1),null;const Y="h"+t.headingLevel,q=Object(n.createElement)(Y,{className:"wc-block-active-filters__title"},t.heading),V=v?Object(n.createElement)(f.a,null,q):q;if(!Object(s.getSettingWithCoercion)("has_filterable_products",!1,u.a))return a(!1),null;a(!0);const D=l()("wc-block-active-filters__list",{"wc-block-active-filters__list--chips":"chips"===t.displayStyle,"wc-block-active-filters--loading":v});return Object(n.createElement)(n.Fragment,null,!r&&t.heading&&V,Object(n.createElement)("div",{className:"wc-block-active-filters"},Object(n.createElement)("ul",{className:D},r?Object(n.createElement)(n.Fragment,null,Object(g.f)({type:Object(c.__)("Size","woo-gutenberg-products-block"),name:Object(c.__)("Small","woo-gutenberg-products-block"),displayStyle:t.displayStyle}),Object(g.f)({type:Object(c.__)("Color","woo-gutenberg-products-block"),name:Object(c.__)("Blue","woo-gutenberg-products-block"),displayStyle:t.displayStyle})):Object(n.createElement)(n.Fragment,null,Object(n.createElement)(w,{isLoading:v,displayStyle:t.displayStyle}),Q,M,G,U)),v?Object(n.createElement)("span",{className:"wc-block-active-filters__clear-all-placeholder"}):Object(n.createElement)("button",{className:"wc-block-active-filters__clear-all",onClick:()=>{Object(g.a)(),j||(N(void 0),R(void 0),S([]),A([]),L([]))}},Object(n.createElement)(i.a,{label:Object(c.__)("Clear All","woo-gutenberg-products-block"),screenReaderLabel:Object(c.__)("Clear All Filters","woo-gutenberg-products-block")}))))}},16:function(e,t
|
4 |
/* translators: Remove chip. */
|
5 |
Object(l.__)("Remove","woo-gutenberg-products-block"):Object(l.sprintf)(
|
6 |
/* translators: %s text of the chip to remove. */
|
7 |
-
Object(l.__)('Remove "%s"',"woo-gutenberg-products-block"),e)}const O={"aria-label":t,disabled:n,onClick:s,onKeyDown:e=>{"Backspace"!==e.key&&"Delete"!==e.key||s()}},j=p?O:{},y=p?{"aria-hidden":!0}:O;return Object(o.createElement)(b,c()({},m,j,{className:a()(r,"is-removable"),element:p?"button":m.element,screenReaderText:f,text:d}),Object(o.createElement)(g,c()({className:"wc-block-components-chip__remove"},y),Object(o.createElement)(i.a,{className:"wc-block-components-chip__remove-icon",icon:u.a,size:16})))}},
|
8 |
/* translators: %1$s min price, %2$s max price */
|
9 |
Object(c.__)("Between %1$s and %2$s","woo-gutenberg-products-block"),Object(o.formatPrice)(e),Object(o.formatPrice)(t)):Number.isFinite(e)?Object(c.sprintf)(
|
10 |
/* translators: %s min price */
|
@@ -12,4 +12,4 @@ Object(c.__)("From %s","woo-gutenberg-products-block"),Object(o.formatPrice)(e))
|
|
12 |
/* translators: %s max price */
|
13 |
Object(c.__)("Up to %s","woo-gutenberg-products-block"),Object(o.formatPrice)(t)),m=e=>{let{type:t,name:r,prefix:o="",removeCallback:l=(()=>null),showLabel:i=!0,displayStyle:p}=e;const d=o?Object(n.createElement)(n.Fragment,null,o," ",r):r,f=Object(c.sprintf)(
|
14 |
/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */
|
15 |
-
Object(c.__)("Remove %s filter","woo-gutenberg-products-block"),r);return Object(n.createElement)("li",{className:"wc-block-active-filters__list-item",key:t+":"+r},i&&Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-type"},t+": "),"chips"===p?Object(n.createElement)(s.a,{element:"span",text:d,onRemove:l,radius:"large",ariaLabel:f}):Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-name"},Object(n.createElement)("button",{className:"wc-block-active-filters__list-item-remove",onClick:l},Object(n.createElement)(u.a,{className:"wc-block-components-chip__remove-icon",icon:b.a,size:16}),Object(n.createElement)(a.a,{screenReaderLabel:f})),d))},g=function(){if(!window)return;const e=window.location.href,t=Object(l.getQueryArgs)(e),r=Object(l.removeQueryArgs)(e,...Object.keys(t));for(var n=arguments.length,c=new Array(n),o=0;o<n;o++)c[o]=arguments[o];c.forEach(e=>{if("string"==typeof e)return delete t[e];if("object"==typeof e){const r=Object.keys(e)[0],n=t[r].toString().split(",");t[r]=n.filter(t=>t!==e[r]).join(",")}});const s=Object.fromEntries(Object.entries(t).filter(e=>{let[,t]=e;return t})),a=Object(l.addQueryArgs)(r,s);Object(i.c)(a)},O=["min_price","max_price","rating_filter","filter_","query_type_"],j=e=>{let t=!1;for(let r=0;O.length>r;r++){const n=O[r];if(n===e.substring(0,n.length)){t=!0;break}}return t},y=()=>{if(!window)return;const e=window.location.href,t=Object(l.getQueryArgs)(e),r=Object(l.removeQueryArgs)(e,...Object.keys(t)),n=Object.fromEntries(Object.keys(t).filter(e=>!j(e)).map(e=>[e,t[e]])),c=Object(l.addQueryArgs)(r,n);Object(i.c)(c)},_=()=>{if(!window)return!1;const e=window.location.href,t=Object(l.getQueryArgs)(e),r=Object.keys(t);let n=!1;for(let e=0;r.length>e;e++){const t=r[e];if(j(t)){n=!0;break}}return n},w=e=>{if(!window)return!1;const t=e.map(e=>"filter_"+e.attribute_name),r=window.location.href,n=Object(l.getQueryArgs)(r),c=Object.keys(n);let o=!1;for(let e=0;c.length>e;e++){const r=c[e];if(t.includes(r)){o=!0;break}}return o},h=e=>({heading:Object(p.a)(null==e?void 0:e.heading)?e.heading:"",headingLevel:Object(p.a)(null==e?void 0:e.headingLevel)&&parseInt(e.headingLevel,10)||d.attributes.headingLevel.default,displayStyle:Object(p.a)(null==e?void 0:e.displayStyle)&&e.displayStyle||d.attributes.displayStyle.default})},
|
1 |
+
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var c=t[n]={i:n,l:!1,exports:{}};return e[n].call(c.exports,c,c.exports,r),c.l=!0,c.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var c in e)r.d(n,c,function(t){return e[t]}.bind(null,c));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=245)}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},107:function(e,t,r){"use strict";var n=r(0);t.a=function(e){let{icon:t,size:r=24,...c}=e;return Object(n.cloneElement)(t,{width:r,height:r,...c})}},108:function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r.d(t,"b",(function(){return o}));var n=r(8);const c=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";const o=e.filter(e=>e.attribute===r.taxonomy),s=o.length?o[0]:null;if(!(s&&s.slug&&Array.isArray(s.slug)&&s.slug.includes(c)))return;const a=s.slug.filter(e=>e!==c),l=e.filter(e=>e.attribute!==r.taxonomy);a.length>0&&(s.slug=a.sort(),l.push(s)),t(Object(n.sortBy)(l,"attribute"))},o=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"in";if(!r||!r.taxonomy)return[];const s=e.filter(e=>e.attribute!==r.taxonomy);return 0===c.length?t(s):(s.push({attribute:r.taxonomy,operator:o,slug:c.map(e=>{let{slug:t}=e;return t}).sort()}),t(Object(n.sortBy)(s,"attribute"))),s}},11:function(e,t){e.exports=window.wp.url},113:function(e,t,r){"use strict";r.d(t,"a",(function(){return o})),r.d(t,"b",(function(){return s}));var n=r(2);const c=Object(n.getSetting)("attributes",[]).reduce((e,t)=>{const r=(n=t)&&n.attribute_name?{id:parseInt(n.attribute_id,10),name:n.attribute_name,taxonomy:"pa_"+n.attribute_name,label:n.attribute_label}:null;var n;return r&&r.id&&e.push(r),e},[]),o=e=>{if(e)return c.find(t=>t.id===e)},s=e=>{if(e)return c.find(t=>t.taxonomy===e)}},12:function(e,t){e.exports=window.wp.isShallowEqual},13:function(e,t){function r(){return e.exports=r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},e.exports.__esModule=!0,e.exports.default=e.exports,r.apply(this,arguments)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports},134:function(e){e.exports=JSON.parse('{"name":"woocommerce/active-filters","version":"1.0.0","title":"Active Product Filters Controls","description":"Display the currently active product filters.","category":"woocommerce","keywords":["WooCommerce"],"supports":{"html":false,"multiple":false,"inserter":false,"color":{"text":true,"background":false},"lock":false},"attributes":{"displayStyle":{"type":"string","default":"list"},"headingLevel":{"type":"number","default":3}},"textdomain":"woo-gutenberg-products-block","apiVersion":2,"$schema":"https://schemas.wp.org/trunk/block.json"}')},14:function(e,t,r){"use strict";var n=r(16),c=r.n(n),o=r(0),s=r(6),a=r(1),l=r(42),i=e=>{let{imageUrl:t=l.l+"/block-error.svg",header:r=Object(a.__)("Oops!","woo-gutenberg-products-block"),text:n=Object(a.__)("There was an error loading the content.","woo-gutenberg-products-block"),errorMessage:c,errorMessagePrefix:s=Object(a.__)("Error:","woo-gutenberg-products-block"),button:i,showErrorBlock:u=!0}=e;return u?Object(o.createElement)("div",{className:"wc-block-error wc-block-components-error"},t&&Object(o.createElement)("img",{className:"wc-block-error__image wc-block-components-error__image",src:t,alt:""}),Object(o.createElement)("div",{className:"wc-block-error__content wc-block-components-error__content"},r&&Object(o.createElement)("p",{className:"wc-block-error__header wc-block-components-error__header"},r),n&&Object(o.createElement)("p",{className:"wc-block-error__text wc-block-components-error__text"},n),c&&Object(o.createElement)("p",{className:"wc-block-error__message wc-block-components-error__message"},s?s+" ":"",c),i&&Object(o.createElement)("p",{className:"wc-block-error__button wc-block-components-error__button"},i))):null};r(34);class u extends s.Component{constructor(){super(...arguments),c()(this,"state",{errorMessage:"",hasError:!1})}static getDerivedStateFromError(e){return void 0!==e.statusText&&void 0!==e.status?{errorMessage:Object(o.createElement)(o.Fragment,null,Object(o.createElement)("strong",null,e.status),": ",e.statusText),hasError:!0}:{errorMessage:e.message,hasError:!0}}render(){const{header:e,imageUrl:t,showErrorMessage:r=!0,showErrorBlock:n=!0,text:c,errorMessagePrefix:s,renderError:a,button:l}=this.props,{errorMessage:u,hasError:b}=this.state;return b?"function"==typeof a?a({errorMessage:u}):Object(o.createElement)(i,{showErrorBlock:n,errorMessage:r?u:null,header:e,imageUrl:t,text:c,errorMessagePrefix:s,button:l}):this.props.children}}t.a=u},154:function(e,t,r){"use strict";var n=r(0),c=r(1),o=r(30),s=r(2),a=r(7),l=r.n(a),i=r(19),u=r(68),b=r(20),p=r(220),d=r(66),f=r(61);r(224);var m=r(113),g=r(39),O=r(55),j=r(22),y=r(108),_=e=>{let{attributeObject:t,slugs:r=[],operator:a="in",displayStyle:l,isLoadingCallback:i}=e;const{results:b,isLoading:d}=Object(O.a)({namespace:"/wc/store/v1",resourceName:"products/attributes/terms",resourceValues:[t.id]}),[f,m]=Object(o.b)("attributes",[]);if(Object(n.useEffect)(()=>{i(d)},[d,i]),!Array.isArray(b)||!Object(p.b)(b)||!Object(p.a)(f))return null;const _=t.label,w=Object(s.getSettingWithCoercion)("is_rendering_php_template",!1,u.a);return Object(n.createElement)("li",null,Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-type"},_,":"),Object(n.createElement)("ul",null,r.map((e,r)=>{const o=b.find(t=>t.slug===e);if(!o)return null;let s="";return r>0&&"and"===a&&(s=Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-operator"},Object(c.__)("All","woo-gutenberg-products-block"))),Object(g.f)({type:_,name:Object(j.decodeEntities)(o.name||e),prefix:s,isLoading:d,removeCallback:()=>{const r=f.find(e=>{let{attribute:r}=e;return r==="pa_"+t.name});1===(null==r?void 0:r.slug.length)?Object(g.e)("query_type_"+t.name,"filter_"+t.name):Object(g.e)({["filter_"+t.name]:e}),w||Object(y.a)(f,m,t,e)},showLabel:!1,displayStyle:l})})))},w=e=>{let{displayStyle:t,isLoading:r}=e;return r?Object(n.createElement)(n.Fragment,null,[...Array("list"===t?2:3)].map((e,r)=>Object(n.createElement)("li",{className:"list"===t?"show-loading-state-list":"show-loading-state-chips",key:r},Object(n.createElement)("span",{className:"show-loading-state__inner"})))):null},h=r(41);t.a=e=>{let{attributes:t,isEditor:r=!1}=e;const a=Object(h.b)(),O=function(){const e=Object(n.useRef)(!1);return Object(n.useEffect)(()=>(e.current=!0,()=>{e.current=!1}),[]),Object(n.useCallback)(()=>e.current,[])}()(),j=Object(s.getSettingWithCoercion)("is_rendering_php_template",!1,u.a),[y,E]=Object(n.useState)(!0),v=Object(g.c)()&&!r&&y,[k,S]=Object(o.b)("attributes",[]),[x,A]=Object(o.b)("stock_status",[]),[P,N]=Object(o.b)("min_price"),[C,R]=Object(o.b)("max_price"),[T,L]=Object(o.b)("rating"),B=Object(s.getSetting)("stockStatusOptions",[]),F=Object(s.getSetting)("attributes",[]),M=Object(n.useMemo)(()=>{if(v||0===x.length||(e=x,!Array.isArray(e)||!e.every(e=>["instock","outofstock","onbackorder"].includes(e)))||!(e=>Object(b.a)(e)&&Object.keys(e).every(e=>["instock","outofstock","onbackorder"].includes(e)))(B))return null;var e;const r=Object(c.__)("Stock Status","woo-gutenberg-products-block");return Object(n.createElement)("li",null,Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-type"},r,":"),Object(n.createElement)("ul",null,x.map(e=>Object(g.f)({type:r,name:B[e],removeCallback:()=>{if(Object(g.e)({filter_stock_status:e}),!j){const t=x.filter(t=>t!==e);A(t)}},showLabel:!1,displayStyle:t.displayStyle}))))},[v,B,x,A,t.displayStyle,j]),Q=Object(n.useMemo)(()=>v||!Number.isFinite(P)&&!Number.isFinite(C)?null:Object(g.f)({type:Object(c.__)("Price","woo-gutenberg-products-block"),name:Object(g.b)(P,C),removeCallback:()=>{Object(g.e)("max_price","min_price"),j||(N(void 0),R(void 0))},displayStyle:t.displayStyle}),[v,P,C,t.displayStyle,N,R,j]),G=Object(n.useMemo)(()=>!Object(p.a)(k)&&O||!k.length&&!Object(g.g)(F)?(y&&E(!1),null):k.map(e=>{const r=Object(m.b)(e.attribute);return r?Object(n.createElement)(_,{attributeObject:r,displayStyle:t.displayStyle,slugs:e.slug,key:e.attribute,operator:e.operator,isLoadingCallback:E}):(y&&E(!1),null)}),[k,O,F,y,t.displayStyle]);Object(n.useEffect)(()=>{var e;if(!j)return;if(T.length&&T.length>0)return;const t=null===(e=Object(d.d)("rating_filter"))||void 0===e?void 0:e.toString();t&&L(t.split(","))},[j,T,L]);const U=Object(n.useMemo)(()=>{if(v||0===T.length||(e=T,!Array.isArray(e)||!e.every(e=>["1","2","3","4","5"].includes(e))))return null;var e;const r=Object(c.__)("Rating","woo-gutenberg-products-block");return Object(n.createElement)("li",null,Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-type"},r,":"),Object(n.createElement)("ul",null,T.map(e=>Object(g.f)({type:r,name:Object(c.sprintf)(
|
2 |
/* translators: %s is referring to the average rating value */
|
3 |
+
Object(c.__)("Rated %s out of 5","woo-gutenberg-products-block"),e),removeCallback:()=>{if(Object(g.e)({rating_filter:e}),!j){const t=T.filter(t=>t!==e);L(t)}},showLabel:!1,displayStyle:t.displayStyle}))))},[v,T,L,t.displayStyle,j]);if(!v&&!(k.length>0||x.length>0||T.length>0||Number.isFinite(P)||Number.isFinite(C))&&!r)return a(!1),null;const Y="h"+t.headingLevel,q=Object(n.createElement)(Y,{className:"wc-block-active-filters__title"},t.heading),V=v?Object(n.createElement)(f.a,null,q):q;if(!Object(s.getSettingWithCoercion)("has_filterable_products",!1,u.a))return a(!1),null;a(!0);const D=l()("wc-block-active-filters__list",{"wc-block-active-filters__list--chips":"chips"===t.displayStyle,"wc-block-active-filters--loading":v});return Object(n.createElement)(n.Fragment,null,!r&&t.heading&&V,Object(n.createElement)("div",{className:"wc-block-active-filters"},Object(n.createElement)("ul",{className:D},r?Object(n.createElement)(n.Fragment,null,Object(g.f)({type:Object(c.__)("Size","woo-gutenberg-products-block"),name:Object(c.__)("Small","woo-gutenberg-products-block"),displayStyle:t.displayStyle}),Object(g.f)({type:Object(c.__)("Color","woo-gutenberg-products-block"),name:Object(c.__)("Blue","woo-gutenberg-products-block"),displayStyle:t.displayStyle})):Object(n.createElement)(n.Fragment,null,Object(n.createElement)(w,{isLoading:v,displayStyle:t.displayStyle}),Q,M,G,U)),v?Object(n.createElement)("span",{className:"wc-block-active-filters__clear-all-placeholder"}):Object(n.createElement)("button",{className:"wc-block-active-filters__clear-all",onClick:()=>{Object(g.a)(),j||(N(void 0),R(void 0),S([]),A([]),L([]))}},Object(n.createElement)(i.a,{label:Object(c.__)("Clear All","woo-gutenberg-products-block"),screenReaderLabel:Object(c.__)("Clear All Filters","woo-gutenberg-products-block")}))))}},16:function(e,t){e.exports=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.__esModule=!0,e.exports.default=e.exports},18:function(e,t){e.exports=window.wp.primitives},19:function(e,t,r){"use strict";var n=r(0),c=r(7),o=r.n(c);t.a=e=>{let t,{label:r,screenReaderLabel:c,wrapperElement:s,wrapperProps:a={}}=e;const l=null!=r,i=null!=c;return!l&&i?(t=s||"span",a={...a,className:o()(a.className,"screen-reader-text")},Object(n.createElement)(t,a,c)):(t=s||n.Fragment,l&&i&&r!==c?Object(n.createElement)(t,a,Object(n.createElement)("span",{"aria-hidden":"true"},r),Object(n.createElement)("span",{className:"screen-reader-text"},c)):Object(n.createElement)(t,a,r))}},2:function(e,t){e.exports=window.wc.wcSettings},20:function(e,t,r){"use strict";r.d(t,"a",(function(){return n})),r.d(t,"b",(function(){return c}));const n=e=>!(e=>null===e)(e)&&e instanceof Object&&e.constructor===Object;function c(e,t){return n(e)&&t in e}},214:function(e,t){},22:function(e,t){e.exports=window.wp.htmlEntities},220:function(e,t,r){"use strict";r.d(t,"b",(function(){return o})),r.d(t,"a",(function(){return a}));var n=r(20);const c=e=>Object(n.b)(e,"count")&&Object(n.b)(e,"description")&&Object(n.b)(e,"id")&&Object(n.b)(e,"name")&&Object(n.b)(e,"parent")&&Object(n.b)(e,"slug")&&"number"==typeof e.count&&"string"==typeof e.description&&"number"==typeof e.id&&"string"==typeof e.name&&"number"==typeof e.parent&&"string"==typeof e.slug,o=e=>Array.isArray(e)&&e.every(c),s=e=>Object(n.b)(e,"attribute")&&Object(n.b)(e,"operator")&&Object(n.b)(e,"slug")&&"string"==typeof e.attribute&&"string"==typeof e.operator&&Array.isArray(e.slug)&&e.slug.every(e=>"string"==typeof e),a=e=>Array.isArray(e)&&e.every(s)},223:function(e,t,r){"use strict";var n=r(0),c=r(18);const o=Object(n.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(n.createElement)(c.Path,{d:"M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"}));t.a=o},224:function(e,t){},229:function(e,t,r){"use strict";var n=r(13),c=r.n(n),o=r(0),s=r(7),a=r.n(s),l=r(1),i=r(107),u=r(223);r(214);var b=e=>{let{text:t,screenReaderText:r="",element:n="li",className:s="",radius:l="small",children:i=null,...u}=e;const b=n,p=a()(s,"wc-block-components-chip","wc-block-components-chip--radius-"+l),d=Boolean(r&&r!==t);return Object(o.createElement)(b,c()({className:p},u),Object(o.createElement)("span",{"aria-hidden":d,className:"wc-block-components-chip__text"},t),d&&Object(o.createElement)("span",{className:"screen-reader-text"},r),i)};t.a=e=>{let{ariaLabel:t="",className:r="",disabled:n=!1,onRemove:s=(()=>{}),removeOnAnyClick:p=!1,text:d,screenReaderText:f="",...m}=e;const g=p?"span":"button";if(!t){const e=f&&"string"==typeof f?f:d;t="string"!=typeof e?
|
4 |
/* translators: Remove chip. */
|
5 |
Object(l.__)("Remove","woo-gutenberg-products-block"):Object(l.sprintf)(
|
6 |
/* translators: %s text of the chip to remove. */
|
7 |
+
Object(l.__)('Remove "%s"',"woo-gutenberg-products-block"),e)}const O={"aria-label":t,disabled:n,onClick:s,onKeyDown:e=>{"Backspace"!==e.key&&"Delete"!==e.key||s()}},j=p?O:{},y=p?{"aria-hidden":!0}:O;return Object(o.createElement)(b,c()({},m,j,{className:a()(r,"is-removable"),element:p?"button":m.element,screenReaderText:f,text:d}),Object(o.createElement)(g,c()({className:"wc-block-components-chip__remove"},y),Object(o.createElement)(i.a,{className:"wc-block-components-chip__remove-icon",icon:u.a,size:16})))}},23:function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(0);const c=Object(n.createContext)("page"),o=()=>Object(n.useContext)(c);c.Provider},245:function(e,t,r){e.exports=r(246)},246:function(e,t,r){"use strict";r.r(t);var n=r(44),c=r(154),o=r(39);Object(n.a)({selector:".wp-block-woocommerce-active-filters",Block:c.a,getProps:e=>({attributes:Object(o.d)(e.dataset),isEditor:!1})})},26:function(e,t,r){"use strict";r.d(t,"a",(function(){return s}));var n=r(0),c=r(12),o=r.n(c);function s(e){const t=Object(n.useRef)(e);return o()(e,t.current)||(t.current=e),t.current}},28:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));const n=e=>"string"==typeof e},3:function(e,t){e.exports=window.wc.wcBlocksData},30:function(e,t,r){"use strict";r.d(t,"a",(function(){return b})),r.d(t,"b",(function(){return p})),r.d(t,"c",(function(){return d}));var n=r(3),c=r(5),o=r(0),s=r(12),a=r.n(s),l=r(26),i=r(56),u=r(23);const b=e=>{const t=Object(u.a)();e=e||t;const r=Object(c.useSelect)(t=>t(n.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0),[e]),{setValueForQueryContext:s}=Object(c.useDispatch)(n.QUERY_STATE_STORE_KEY);return[r,Object(o.useCallback)(t=>{s(e,t)},[e,s])]},p=(e,t,r)=>{const s=Object(u.a)();r=r||s;const a=Object(c.useSelect)(c=>c(n.QUERY_STATE_STORE_KEY).getValueForQueryKey(r,e,t),[r,e]),{setQueryValue:l}=Object(c.useDispatch)(n.QUERY_STATE_STORE_KEY);return[a,Object(o.useCallback)(t=>{l(r,e,t)},[r,e,l])]},d=(e,t)=>{const r=Object(u.a)();t=t||r;const[n,c]=b(t),s=Object(l.a)(n),p=Object(l.a)(e),d=Object(i.a)(p),f=Object(o.useRef)(!1);return Object(o.useEffect)(()=>{a()(d,p)||(c(Object.assign({},s,p)),f.current=!0)},[s,p,d,c]),f.current?[n,c]:[e,c]}},34:function(e,t){},38:function(e,t){e.exports=window.wc.priceFormat},39:function(e,t,r){"use strict";r.d(t,"b",(function(){return f})),r.d(t,"f",(function(){return m})),r.d(t,"e",(function(){return g})),r.d(t,"a",(function(){return y})),r.d(t,"c",(function(){return _})),r.d(t,"g",(function(){return w})),r.d(t,"d",(function(){return h}));var n=r(0),c=r(1),o=r(38),s=r(229),a=r(19),l=r(11),i=r(66),u=r(107),b=r(223),p=r(28),d=r(134);const f=(e,t)=>Number.isFinite(e)&&Number.isFinite(t)?Object(c.sprintf)(
|
8 |
/* translators: %1$s min price, %2$s max price */
|
9 |
Object(c.__)("Between %1$s and %2$s","woo-gutenberg-products-block"),Object(o.formatPrice)(e),Object(o.formatPrice)(t)):Number.isFinite(e)?Object(c.sprintf)(
|
10 |
/* translators: %s min price */
|
12 |
/* translators: %s max price */
|
13 |
Object(c.__)("Up to %s","woo-gutenberg-products-block"),Object(o.formatPrice)(t)),m=e=>{let{type:t,name:r,prefix:o="",removeCallback:l=(()=>null),showLabel:i=!0,displayStyle:p}=e;const d=o?Object(n.createElement)(n.Fragment,null,o," ",r):r,f=Object(c.sprintf)(
|
14 |
/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */
|
15 |
+
Object(c.__)("Remove %s filter","woo-gutenberg-products-block"),r);return Object(n.createElement)("li",{className:"wc-block-active-filters__list-item",key:t+":"+r},i&&Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-type"},t+": "),"chips"===p?Object(n.createElement)(s.a,{element:"span",text:d,onRemove:l,radius:"large",ariaLabel:f}):Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-name"},Object(n.createElement)("button",{className:"wc-block-active-filters__list-item-remove",onClick:l},Object(n.createElement)(u.a,{className:"wc-block-components-chip__remove-icon",icon:b.a,size:16}),Object(n.createElement)(a.a,{screenReaderLabel:f})),d))},g=function(){if(!window)return;const e=window.location.href,t=Object(l.getQueryArgs)(e),r=Object(l.removeQueryArgs)(e,...Object.keys(t));for(var n=arguments.length,c=new Array(n),o=0;o<n;o++)c[o]=arguments[o];c.forEach(e=>{if("string"==typeof e)return delete t[e];if("object"==typeof e){const r=Object.keys(e)[0],n=t[r].toString().split(",");t[r]=n.filter(t=>t!==e[r]).join(",")}});const s=Object.fromEntries(Object.entries(t).filter(e=>{let[,t]=e;return t})),a=Object(l.addQueryArgs)(r,s);Object(i.c)(a)},O=["min_price","max_price","rating_filter","filter_","query_type_"],j=e=>{let t=!1;for(let r=0;O.length>r;r++){const n=O[r];if(n===e.substring(0,n.length)){t=!0;break}}return t},y=()=>{if(!window)return;const e=window.location.href,t=Object(l.getQueryArgs)(e),r=Object(l.removeQueryArgs)(e,...Object.keys(t)),n=Object.fromEntries(Object.keys(t).filter(e=>!j(e)).map(e=>[e,t[e]])),c=Object(l.addQueryArgs)(r,n);Object(i.c)(c)},_=()=>{if(!window)return!1;const e=window.location.href,t=Object(l.getQueryArgs)(e),r=Object.keys(t);let n=!1;for(let e=0;r.length>e;e++){const t=r[e];if(j(t)){n=!0;break}}return n},w=e=>{if(!window)return!1;const t=e.map(e=>"filter_"+e.attribute_name),r=window.location.href,n=Object(l.getQueryArgs)(r),c=Object.keys(n);let o=!1;for(let e=0;c.length>e;e++){const r=c[e];if(t.includes(r)){o=!0;break}}return o},h=e=>({heading:Object(p.a)(null==e?void 0:e.heading)?e.heading:"",headingLevel:Object(p.a)(null==e?void 0:e.headingLevel)&&parseInt(e.headingLevel,10)||d.attributes.headingLevel.default,displayStyle:Object(p.a)(null==e?void 0:e.displayStyle)&&e.displayStyle||d.attributes.displayStyle.default})},41:function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r.d(t,"b",(function(){return o}));var n=r(0);const c=Object(n.createContext)({}),o=()=>{const{wrapper:e}=Object(n.useContext)(c);return t=>{e&&e.current&&(e.current.hidden=!t)}}},42:function(e,t,r){"use strict";r.d(t,"n",(function(){return o})),r.d(t,"l",(function(){return s})),r.d(t,"k",(function(){return a})),r.d(t,"m",(function(){return l})),r.d(t,"i",(function(){return i})),r.d(t,"d",(function(){return u})),r.d(t,"f",(function(){return b})),r.d(t,"j",(function(){return p})),r.d(t,"c",(function(){return d})),r.d(t,"e",(function(){return f})),r.d(t,"g",(function(){return m})),r.d(t,"a",(function(){return g})),r.d(t,"h",(function(){return O})),r.d(t,"b",(function(){return j}));var n,c=r(2);const o=Object(c.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),s=o.pluginUrl+"images/",a=o.pluginUrl+"build/",l=o.buildPhase,i=null===(n=c.STORE_PAGES.shop)||void 0===n?void 0:n.permalink,u=(c.STORE_PAGES.checkout.id,c.STORE_PAGES.checkout.permalink),b=c.STORE_PAGES.privacy.permalink,p=(c.STORE_PAGES.privacy.title,c.STORE_PAGES.terms.permalink),d=(c.STORE_PAGES.terms.title,c.STORE_PAGES.cart.id,c.STORE_PAGES.cart.permalink),f=c.STORE_PAGES.myaccount.permalink?c.STORE_PAGES.myaccount.permalink:Object(c.getSetting)("wpLoginUrl","/wp-login.php"),m=Object(c.getSetting)("shippingCountries",{}),g=Object(c.getSetting)("allowedCountries",{}),O=Object(c.getSetting)("shippingStates",{}),j=Object(c.getSetting)("allowedStates",{})},44:function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(13),c=r.n(n),o=r(0),s=r(14);const a=[".wp-block-woocommerce-cart"],l=e=>{let{Block:t,containers:r,getProps:n=(()=>({})),getErrorBoundaryProps:a=(()=>({}))}=e;0!==r.length&&Array.prototype.forEach.call(r,(e,r)=>{const l=n(e,r),i=a(e,r),u={...e.dataset,...l.attributes||{}};(e=>{let{Block:t,container:r,attributes:n={},props:a={},errorBoundaryProps:l={}}=e;Object(o.render)(Object(o.createElement)(s.a,l,Object(o.createElement)(o.Suspense,{fallback:Object(o.createElement)("div",{className:"wc-block-placeholder"})},t&&Object(o.createElement)(t,c()({},a,{attributes:n})))),r,()=>{r.classList&&r.classList.remove("is-loading")})})({Block:t,container:e,props:l,attributes:u,errorBoundaryProps:i})})},i=e=>{const t=document.body.querySelectorAll(a.join(",")),{Block:r,getProps:n,getErrorBoundaryProps:c,selector:o}=e;(e=>{let{Block:t,getProps:r,getErrorBoundaryProps:n,selector:c,wrappers:o}=e;const s=document.body.querySelectorAll(c);o&&o.length>0&&Array.prototype.filter.call(s,e=>!((e,t)=>Array.prototype.some.call(t,t=>t.contains(e)&&!t.isSameNode(e)))(e,o)),l({Block:t,containers:s,getProps:r,getErrorBoundaryProps:n})})({Block:r,getProps:n,getErrorBoundaryProps:c,selector:o,wrappers:t}),Array.prototype.forEach.call(t,t=>{t.addEventListener("wc-blocks_render_blocks_frontend",()=>{(e=>{let{Block:t,getProps:r,getErrorBoundaryProps:n,selector:c,wrapper:o}=e;const s=o.querySelectorAll(c);l({Block:t,containers:s,getProps:r,getErrorBoundaryProps:n})})({...e,wrapper:t})})})}},5:function(e,t){e.exports=window.wp.data},55:function(e,t,r){"use strict";r.d(t,"a",(function(){return l}));var n=r(3),c=r(5),o=r(0),s=r(26),a=r(70);const l=e=>{const{namespace:t,resourceName:r,resourceValues:l=[],query:i={},shouldSelect:u=!0}=e;if(!t||!r)throw new Error("The options object must have valid values for the namespace and the resource properties.");const b=Object(o.useRef)({results:[],isLoading:!0}),p=Object(s.a)(i),d=Object(s.a)(l),f=Object(a.a)(),m=Object(c.useSelect)(e=>{if(!u)return null;const c=e(n.COLLECTIONS_STORE_KEY),o=[t,r,p,d],s=c.getCollectionError(...o);if(s){if(!(s instanceof Error))throw new Error("TypeError: `error` object is not an instance of Error constructor");f(s)}return{results:c.getCollection(...o),isLoading:!c.hasFinishedResolution("getCollection",o)}},[t,r,d,p,u]);return null!==m&&(b.current=m),b.current}},56:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(6);function c(e,t){const r=Object(n.useRef)();return Object(n.useEffect)(()=>{r.current===e||t&&!t(e,r.current)||(r.current=e)},[e,t]),r.current}},6:function(e,t){e.exports=window.React},61:function(e,t,r){"use strict";var n=r(0);r(95),t.a=e=>{let{children:t}=e;return Object(n.createElement)("div",{className:"wc-block-filter-title-placeholder"},t)}},66:function(e,t,r){"use strict";r.d(t,"b",(function(){return a})),r.d(t,"a",(function(){return l})),r.d(t,"d",(function(){return i})),r.d(t,"c",(function(){return u}));var n=r(11),c=r(2),o=r(68);const s=Object(c.getSettingWithCoercion)("is_rendering_php_template",!1,o.a),a="query_type_",l="filter_";function i(e){return window?Object(n.getQueryArg)(window.location.href,e):null}function u(e){s?window.location.href=e:window.history.replaceState({},"",e)}},68:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));const n=e=>"boolean"==typeof e},7:function(e,t,r){var n;!function(){"use strict";var r={}.hasOwnProperty;function c(){for(var e=[],t=0;t<arguments.length;t++){var n=arguments[t];if(n){var o=typeof n;if("string"===o||"number"===o)e.push(n);else if(Array.isArray(n)){if(n.length){var s=c.apply(null,n);s&&e.push(s)}}else if("object"===o)if(n.toString===Object.prototype.toString)for(var a in n)r.call(n,a)&&n[a]&&e.push(a);else e.push(n.toString())}}return e.join(" ")}e.exports?(c.default=c,e.exports=c):void 0===(n=function(){return c}.apply(t,[]))||(e.exports=n)}()},70:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(0);const c=()=>{const[,e]=Object(n.useState)();return Object(n.useCallback)(t=>{e(()=>{throw t})},[])}},8:function(e,t){e.exports=window.lodash},95:function(e,t){}});
|
build/active-filters-wrapper-frontend.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[12],{
|
2 |
/* translators: %s is referring to the average rating value */
|
3 |
-
Object(c.__)("Rated %s out of 5","woo-gutenberg-products-block"),e),removeCallback:()=>{if(Object(O.e)({rating_filter:e}),!g){const t=F.filter(t=>t!==e);T(t)}},showLabel:!1,displayStyle:t.displayStyle}))))},[k,F,T,t.displayStyle,g]);if(!k&&!(E.length>0||N.length>0||F.length>0||Number.isFinite(A)||Number.isFinite(L))&&!r)return s(!1),null;const W="h"+t.headingLevel,U=Object(n.createElement)(W,{className:"wc-block-active-filters__title"},t.heading),z=k?Object(n.createElement)(p.a,null,U):U;if(!Object(l.getSettingWithCoercion)("has_filterable_products",!1,u.a))return s(!1),null;s(!0);const D=i()("wc-block-active-filters__list",{"wc-block-active-filters__list--chips":"chips"===t.displayStyle,"wc-block-active-filters--loading":k});return Object(n.createElement)(n.Fragment,null,!r&&t.heading&&z,Object(n.createElement)("div",{className:"wc-block-active-filters"},Object(n.createElement)("ul",{className:D},r?Object(n.createElement)(n.Fragment,null,Object(O.f)({type:Object(c.__)("Size","woo-gutenberg-products-block"),name:Object(c.__)("Small","woo-gutenberg-products-block"),displayStyle:t.displayStyle}),Object(O.f)({type:Object(c.__)("Color","woo-gutenberg-products-block"),name:Object(c.__)("Blue","woo-gutenberg-products-block"),displayStyle:t.displayStyle})):Object(n.createElement)(n.Fragment,null,Object(n.createElement)(v,{isLoading:k,displayStyle:t.displayStyle}),Y,B,V,K)),k?Object(n.createElement)("span",{className:"wc-block-active-filters__clear-all-placeholder"}):Object(n.createElement)("button",{className:"wc-block-active-filters__clear-all",onClick:()=>{Object(O.a)(),g||(C(void 0),R(void 0),S([]),x([]),T([]))}},Object(n.createElement)(o.a,{label:Object(c.__)("Clear All","woo-gutenberg-products-block"),screenReaderLabel:Object(c.__)("Clear All Filters","woo-gutenberg-products-block")}))))}},19:function(e,t,r){"use strict";var n=r(0),c=r(
|
4 |
/* translators: Remove chip. */
|
5 |
Object(i.__)("Remove","woo-gutenberg-products-block"):Object(i.sprintf)(
|
6 |
/* translators: %s text of the chip to remove. */
|
7 |
-
Object(i.__)('Remove "%s"',"woo-gutenberg-products-block"),e)}const j={"aria-label":t,disabled:n,onClick:l,onKeyDown:e=>{"Backspace"!==e.key&&"Delete"!==e.key||l()}},g=f?j:{},y=f?{"aria-hidden":!0}:j;return Object(a.createElement)(b,c()({},m,g,{className:s()(r,"is-removable"),element:f?"button":m.element,screenReaderText:p,text:d}),Object(a.createElement)(O,c()({className:"wc-block-components-chip__remove"},y),Object(a.createElement)(o.a,{className:"wc-block-components-chip__remove-icon",icon:u.a,size:16})))}},
|
8 |
/* translators: %1$s min price, %2$s max price */
|
9 |
Object(c.__)("Between %1$s and %2$s","woo-gutenberg-products-block"),Object(a.formatPrice)(e),Object(a.formatPrice)(t)):Number.isFinite(e)?Object(c.sprintf)(
|
10 |
/* translators: %s min price */
|
@@ -12,4 +12,4 @@ Object(c.__)("From %s","woo-gutenberg-products-block"),Object(a.formatPrice)(e))
|
|
12 |
/* translators: %s max price */
|
13 |
Object(c.__)("Up to %s","woo-gutenberg-products-block"),Object(a.formatPrice)(t)),m=e=>{let{type:t,name:r,prefix:a="",removeCallback:i=(()=>null),showLabel:o=!0,displayStyle:f}=e;const d=a?Object(n.createElement)(n.Fragment,null,a," ",r):r,p=Object(c.sprintf)(
|
14 |
/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */
|
15 |
-
Object(c.__)("Remove %s filter","woo-gutenberg-products-block"),r);return Object(n.createElement)("li",{className:"wc-block-active-filters__list-item",key:t+":"+r},o&&Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-type"},t+": "),"chips"===f?Object(n.createElement)(l.a,{element:"span",text:d,onRemove:i,radius:"large",ariaLabel:p}):Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-name"},Object(n.createElement)("button",{className:"wc-block-active-filters__list-item-remove",onClick:i},Object(n.createElement)(u.a,{className:"wc-block-components-chip__remove-icon",icon:b.a,size:16}),Object(n.createElement)(s.a,{screenReaderLabel:p})),d))},O=function(){if(!window)return;const e=window.location.href,t=Object(i.getQueryArgs)(e),r=Object(i.removeQueryArgs)(e,...Object.keys(t));for(var n=arguments.length,c=new Array(n),a=0;a<n;a++)c[a]=arguments[a];c.forEach(e=>{if("string"==typeof e)return delete t[e];if("object"==typeof e){const r=Object.keys(e)[0],n=t[r].toString().split(",");t[r]=n.filter(t=>t!==e[r]).join(",")}});const l=Object.fromEntries(Object.entries(t).filter(e=>{let[,t]=e;return t})),s=Object(i.addQueryArgs)(r,l);Object(o.c)(s)},j=["min_price","max_price","rating_filter","filter_","query_type_"],g=e=>{let t=!1;for(let r=0;j.length>r;r++){const n=j[r];if(n===e.substring(0,n.length)){t=!0;break}}return t},y=()=>{if(!window)return;const e=window.location.href,t=Object(i.getQueryArgs)(e),r=Object(i.removeQueryArgs)(e,...Object.keys(t)),n=Object.fromEntries(Object.keys(t).filter(e=>!g(e)).map(e=>[e,t[e]])),c=Object(i.addQueryArgs)(r,n);Object(o.c)(c)},_=()=>{if(!window)return!1;const e=window.location.href,t=Object(i.getQueryArgs)(e),r=Object.keys(t);let n=!1;for(let e=0;r.length>e;e++){const t=r[e];if(g(t)){n=!0;break}}return n},v=e=>{if(!window)return!1;const t=e.map(e=>"filter_"+e.attribute_name),r=window.location.href,n=Object(i.getQueryArgs)(r),c=Object.keys(n);let a=!1;for(let e=0;c.length>e;e++){const r=c[e];if(t.includes(r)){a=!0;break}}return a},h=e=>({heading:Object(f.a)(null==e?void 0:e.heading)?e.heading:"",headingLevel:Object(f.a)(null==e?void 0:e.headingLevel)&&parseInt(e.headingLevel,10)||d.attributes.headingLevel.default,displayStyle:Object(f.a)(null==e?void 0:e.displayStyle)&&e.displayStyle||d.attributes.displayStyle.default})},
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[12],{107:function(e,t,r){"use strict";var n=r(0);t.a=function(e){let{icon:t,size:r=24,...c}=e;return Object(n.cloneElement)(t,{width:r,height:r,...c})}},108:function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r.d(t,"b",(function(){return a}));var n=r(8);const c=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";const a=e.filter(e=>e.attribute===r.taxonomy),l=a.length?a[0]:null;if(!(l&&l.slug&&Array.isArray(l.slug)&&l.slug.includes(c)))return;const s=l.slug.filter(e=>e!==c),i=e.filter(e=>e.attribute!==r.taxonomy);s.length>0&&(l.slug=s.sort(),i.push(l)),t(Object(n.sortBy)(i,"attribute"))},a=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"in";if(!r||!r.taxonomy)return[];const l=e.filter(e=>e.attribute!==r.taxonomy);return 0===c.length?t(l):(l.push({attribute:r.taxonomy,operator:a,slug:c.map(e=>{let{slug:t}=e;return t}).sort()}),t(Object(n.sortBy)(l,"attribute"))),l}},113:function(e,t,r){"use strict";r.d(t,"a",(function(){return a})),r.d(t,"b",(function(){return l}));var n=r(2);const c=Object(n.getSetting)("attributes",[]).reduce((e,t)=>{const r=(n=t)&&n.attribute_name?{id:parseInt(n.attribute_id,10),name:n.attribute_name,taxonomy:"pa_"+n.attribute_name,label:n.attribute_label}:null;var n;return r&&r.id&&e.push(r),e},[]),a=e=>{if(e)return c.find(t=>t.id===e)},l=e=>{if(e)return c.find(t=>t.taxonomy===e)}},134:function(e){e.exports=JSON.parse('{"name":"woocommerce/active-filters","version":"1.0.0","title":"Active Product Filters Controls","description":"Display the currently active product filters.","category":"woocommerce","keywords":["WooCommerce"],"supports":{"html":false,"multiple":false,"inserter":false,"color":{"text":true,"background":false},"lock":false},"attributes":{"displayStyle":{"type":"string","default":"list"},"headingLevel":{"type":"number","default":3}},"textdomain":"woo-gutenberg-products-block","apiVersion":2,"$schema":"https://schemas.wp.org/trunk/block.json"}')},154:function(e,t,r){"use strict";var n=r(0),c=r(1),a=r(30),l=r(2),s=r(7),i=r.n(s),o=r(19),u=r(68),b=r(20),f=r(220),d=r(66),p=r(61);r(224);var m=r(113),O=r(39),j=r(55),g=r(22),y=r(108),_=e=>{let{attributeObject:t,slugs:r=[],operator:s="in",displayStyle:i,isLoadingCallback:o}=e;const{results:b,isLoading:d}=Object(j.a)({namespace:"/wc/store/v1",resourceName:"products/attributes/terms",resourceValues:[t.id]}),[p,m]=Object(a.b)("attributes",[]);if(Object(n.useEffect)(()=>{o(d)},[d,o]),!Array.isArray(b)||!Object(f.b)(b)||!Object(f.a)(p))return null;const _=t.label,v=Object(l.getSettingWithCoercion)("is_rendering_php_template",!1,u.a);return Object(n.createElement)("li",null,Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-type"},_,":"),Object(n.createElement)("ul",null,r.map((e,r)=>{const a=b.find(t=>t.slug===e);if(!a)return null;let l="";return r>0&&"and"===s&&(l=Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-operator"},Object(c.__)("All","woo-gutenberg-products-block"))),Object(O.f)({type:_,name:Object(g.decodeEntities)(a.name||e),prefix:l,isLoading:d,removeCallback:()=>{const r=p.find(e=>{let{attribute:r}=e;return r==="pa_"+t.name});1===(null==r?void 0:r.slug.length)?Object(O.e)("query_type_"+t.name,"filter_"+t.name):Object(O.e)({["filter_"+t.name]:e}),v||Object(y.a)(p,m,t,e)},showLabel:!1,displayStyle:i})})))},v=e=>{let{displayStyle:t,isLoading:r}=e;return r?Object(n.createElement)(n.Fragment,null,[...Array("list"===t?2:3)].map((e,r)=>Object(n.createElement)("li",{className:"list"===t?"show-loading-state-list":"show-loading-state-chips",key:r},Object(n.createElement)("span",{className:"show-loading-state__inner"})))):null},h=r(41);t.a=e=>{let{attributes:t,isEditor:r=!1}=e;const s=Object(h.b)(),j=function(){const e=Object(n.useRef)(!1);return Object(n.useEffect)(()=>(e.current=!0,()=>{e.current=!1}),[]),Object(n.useCallback)(()=>e.current,[])}()(),g=Object(l.getSettingWithCoercion)("is_rendering_php_template",!1,u.a),[y,w]=Object(n.useState)(!0),k=Object(O.c)()&&!r&&y,[E,S]=Object(a.b)("attributes",[]),[N,x]=Object(a.b)("stock_status",[]),[A,C]=Object(a.b)("min_price"),[L,R]=Object(a.b)("max_price"),[F,T]=Object(a.b)("rating"),Q=Object(l.getSetting)("stockStatusOptions",[]),P=Object(l.getSetting)("attributes",[]),B=Object(n.useMemo)(()=>{if(k||0===N.length||(e=N,!Array.isArray(e)||!e.every(e=>["instock","outofstock","onbackorder"].includes(e)))||!(e=>Object(b.a)(e)&&Object.keys(e).every(e=>["instock","outofstock","onbackorder"].includes(e)))(Q))return null;var e;const r=Object(c.__)("Stock Status","woo-gutenberg-products-block");return Object(n.createElement)("li",null,Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-type"},r,":"),Object(n.createElement)("ul",null,N.map(e=>Object(O.f)({type:r,name:Q[e],removeCallback:()=>{if(Object(O.e)({filter_stock_status:e}),!g){const t=N.filter(t=>t!==e);x(t)}},showLabel:!1,displayStyle:t.displayStyle}))))},[k,Q,N,x,t.displayStyle,g]),Y=Object(n.useMemo)(()=>k||!Number.isFinite(A)&&!Number.isFinite(L)?null:Object(O.f)({type:Object(c.__)("Price","woo-gutenberg-products-block"),name:Object(O.b)(A,L),removeCallback:()=>{Object(O.e)("max_price","min_price"),g||(C(void 0),R(void 0))},displayStyle:t.displayStyle}),[k,A,L,t.displayStyle,C,R,g]),V=Object(n.useMemo)(()=>!Object(f.a)(E)&&j||!E.length&&!Object(O.g)(P)?(y&&w(!1),null):E.map(e=>{const r=Object(m.b)(e.attribute);return r?Object(n.createElement)(_,{attributeObject:r,displayStyle:t.displayStyle,slugs:e.slug,key:e.attribute,operator:e.operator,isLoadingCallback:w}):(y&&w(!1),null)}),[E,j,P,y,t.displayStyle]);Object(n.useEffect)(()=>{var e;if(!g)return;if(F.length&&F.length>0)return;const t=null===(e=Object(d.d)("rating_filter"))||void 0===e?void 0:e.toString();t&&T(t.split(","))},[g,F,T]);const K=Object(n.useMemo)(()=>{if(k||0===F.length||(e=F,!Array.isArray(e)||!e.every(e=>["1","2","3","4","5"].includes(e))))return null;var e;const r=Object(c.__)("Rating","woo-gutenberg-products-block");return Object(n.createElement)("li",null,Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-type"},r,":"),Object(n.createElement)("ul",null,F.map(e=>Object(O.f)({type:r,name:Object(c.sprintf)(
|
2 |
/* translators: %s is referring to the average rating value */
|
3 |
+
Object(c.__)("Rated %s out of 5","woo-gutenberg-products-block"),e),removeCallback:()=>{if(Object(O.e)({rating_filter:e}),!g){const t=F.filter(t=>t!==e);T(t)}},showLabel:!1,displayStyle:t.displayStyle}))))},[k,F,T,t.displayStyle,g]);if(!k&&!(E.length>0||N.length>0||F.length>0||Number.isFinite(A)||Number.isFinite(L))&&!r)return s(!1),null;const W="h"+t.headingLevel,U=Object(n.createElement)(W,{className:"wc-block-active-filters__title"},t.heading),z=k?Object(n.createElement)(p.a,null,U):U;if(!Object(l.getSettingWithCoercion)("has_filterable_products",!1,u.a))return s(!1),null;s(!0);const D=i()("wc-block-active-filters__list",{"wc-block-active-filters__list--chips":"chips"===t.displayStyle,"wc-block-active-filters--loading":k});return Object(n.createElement)(n.Fragment,null,!r&&t.heading&&z,Object(n.createElement)("div",{className:"wc-block-active-filters"},Object(n.createElement)("ul",{className:D},r?Object(n.createElement)(n.Fragment,null,Object(O.f)({type:Object(c.__)("Size","woo-gutenberg-products-block"),name:Object(c.__)("Small","woo-gutenberg-products-block"),displayStyle:t.displayStyle}),Object(O.f)({type:Object(c.__)("Color","woo-gutenberg-products-block"),name:Object(c.__)("Blue","woo-gutenberg-products-block"),displayStyle:t.displayStyle})):Object(n.createElement)(n.Fragment,null,Object(n.createElement)(v,{isLoading:k,displayStyle:t.displayStyle}),Y,B,V,K)),k?Object(n.createElement)("span",{className:"wc-block-active-filters__clear-all-placeholder"}):Object(n.createElement)("button",{className:"wc-block-active-filters__clear-all",onClick:()=>{Object(O.a)(),g||(C(void 0),R(void 0),S([]),x([]),T([]))}},Object(n.createElement)(o.a,{label:Object(c.__)("Clear All","woo-gutenberg-products-block"),screenReaderLabel:Object(c.__)("Clear All Filters","woo-gutenberg-products-block")}))))}},19:function(e,t,r){"use strict";var n=r(0),c=r(7),a=r.n(c);t.a=e=>{let t,{label:r,screenReaderLabel:c,wrapperElement:l,wrapperProps:s={}}=e;const i=null!=r,o=null!=c;return!i&&o?(t=l||"span",s={...s,className:a()(s.className,"screen-reader-text")},Object(n.createElement)(t,s,c)):(t=l||n.Fragment,i&&o&&r!==c?Object(n.createElement)(t,s,Object(n.createElement)("span",{"aria-hidden":"true"},r),Object(n.createElement)("span",{className:"screen-reader-text"},c)):Object(n.createElement)(t,s,r))}},20:function(e,t,r){"use strict";r.d(t,"a",(function(){return n})),r.d(t,"b",(function(){return c}));const n=e=>!(e=>null===e)(e)&&e instanceof Object&&e.constructor===Object;function c(e,t){return n(e)&&t in e}},211:function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r(94);var n=r(42);const c=()=>n.m>1},212:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(28),c=r(20);const a=e=>Object(n.a)(e)?JSON.parse(e)||{}:Object(c.a)(e)?e:{}},214:function(e,t){},220:function(e,t,r){"use strict";r.d(t,"b",(function(){return a})),r.d(t,"a",(function(){return s}));var n=r(20);const c=e=>Object(n.b)(e,"count")&&Object(n.b)(e,"description")&&Object(n.b)(e,"id")&&Object(n.b)(e,"name")&&Object(n.b)(e,"parent")&&Object(n.b)(e,"slug")&&"number"==typeof e.count&&"string"==typeof e.description&&"number"==typeof e.id&&"string"==typeof e.name&&"number"==typeof e.parent&&"string"==typeof e.slug,a=e=>Array.isArray(e)&&e.every(c),l=e=>Object(n.b)(e,"attribute")&&Object(n.b)(e,"operator")&&Object(n.b)(e,"slug")&&"string"==typeof e.attribute&&"string"==typeof e.operator&&Array.isArray(e.slug)&&e.slug.every(e=>"string"==typeof e),s=e=>Array.isArray(e)&&e.every(l)},223:function(e,t,r){"use strict";var n=r(0),c=r(18);const a=Object(n.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(n.createElement)(c.Path,{d:"M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"}));t.a=a},224:function(e,t){},229:function(e,t,r){"use strict";var n=r(13),c=r.n(n),a=r(0),l=r(7),s=r.n(l),i=r(1),o=r(107),u=r(223);r(214);var b=e=>{let{text:t,screenReaderText:r="",element:n="li",className:l="",radius:i="small",children:o=null,...u}=e;const b=n,f=s()(l,"wc-block-components-chip","wc-block-components-chip--radius-"+i),d=Boolean(r&&r!==t);return Object(a.createElement)(b,c()({className:f},u),Object(a.createElement)("span",{"aria-hidden":d,className:"wc-block-components-chip__text"},t),d&&Object(a.createElement)("span",{className:"screen-reader-text"},r),o)};t.a=e=>{let{ariaLabel:t="",className:r="",disabled:n=!1,onRemove:l=(()=>{}),removeOnAnyClick:f=!1,text:d,screenReaderText:p="",...m}=e;const O=f?"span":"button";if(!t){const e=p&&"string"==typeof p?p:d;t="string"!=typeof e?
|
4 |
/* translators: Remove chip. */
|
5 |
Object(i.__)("Remove","woo-gutenberg-products-block"):Object(i.sprintf)(
|
6 |
/* translators: %s text of the chip to remove. */
|
7 |
+
Object(i.__)('Remove "%s"',"woo-gutenberg-products-block"),e)}const j={"aria-label":t,disabled:n,onClick:l,onKeyDown:e=>{"Backspace"!==e.key&&"Delete"!==e.key||l()}},g=f?j:{},y=f?{"aria-hidden":!0}:j;return Object(a.createElement)(b,c()({},m,g,{className:s()(r,"is-removable"),element:f?"button":m.element,screenReaderText:p,text:d}),Object(a.createElement)(O,c()({className:"wc-block-components-chip__remove"},y),Object(a.createElement)(o.a,{className:"wc-block-components-chip__remove-icon",icon:u.a,size:16})))}},23:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(0);const c=Object(n.createContext)("page"),a=()=>Object(n.useContext)(c);c.Provider},26:function(e,t,r){"use strict";r.d(t,"a",(function(){return l}));var n=r(0),c=r(12),a=r.n(c);function l(e){const t=Object(n.useRef)(e);return a()(e,t.current)||(t.current=e),t.current}},28:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));const n=e=>"string"==typeof e},288:function(e,t,r){"use strict";r.d(t,"a",(function(){return s}));var n=r(104),c=r(211),a=r(20),l=r(212);const s=e=>{if(!Object(c.a)())return{className:"",style:{}};const t=Object(a.a)(e)?e:{},r=Object(l.a)(t.style);return Object(n.__experimentalUseColorProps)({...t,style:r})}},30:function(e,t,r){"use strict";r.d(t,"a",(function(){return b})),r.d(t,"b",(function(){return f})),r.d(t,"c",(function(){return d}));var n=r(3),c=r(5),a=r(0),l=r(12),s=r.n(l),i=r(26),o=r(56),u=r(23);const b=e=>{const t=Object(u.a)();e=e||t;const r=Object(c.useSelect)(t=>t(n.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0),[e]),{setValueForQueryContext:l}=Object(c.useDispatch)(n.QUERY_STATE_STORE_KEY);return[r,Object(a.useCallback)(t=>{l(e,t)},[e,l])]},f=(e,t,r)=>{const l=Object(u.a)();r=r||l;const s=Object(c.useSelect)(c=>c(n.QUERY_STATE_STORE_KEY).getValueForQueryKey(r,e,t),[r,e]),{setQueryValue:i}=Object(c.useDispatch)(n.QUERY_STATE_STORE_KEY);return[s,Object(a.useCallback)(t=>{i(r,e,t)},[r,e,i])]},d=(e,t)=>{const r=Object(u.a)();t=t||r;const[n,c]=b(t),l=Object(i.a)(n),f=Object(i.a)(e),d=Object(o.a)(f),p=Object(a.useRef)(!1);return Object(a.useEffect)(()=>{s()(d,f)||(c(Object.assign({},l,f)),p.current=!0)},[l,f,d,c]),p.current?[n,c]:[e,c]}},39:function(e,t,r){"use strict";r.d(t,"b",(function(){return p})),r.d(t,"f",(function(){return m})),r.d(t,"e",(function(){return O})),r.d(t,"a",(function(){return y})),r.d(t,"c",(function(){return _})),r.d(t,"g",(function(){return v})),r.d(t,"d",(function(){return h}));var n=r(0),c=r(1),a=r(38),l=r(229),s=r(19),i=r(11),o=r(66),u=r(107),b=r(223),f=r(28),d=r(134);const p=(e,t)=>Number.isFinite(e)&&Number.isFinite(t)?Object(c.sprintf)(
|
8 |
/* translators: %1$s min price, %2$s max price */
|
9 |
Object(c.__)("Between %1$s and %2$s","woo-gutenberg-products-block"),Object(a.formatPrice)(e),Object(a.formatPrice)(t)):Number.isFinite(e)?Object(c.sprintf)(
|
10 |
/* translators: %s min price */
|
12 |
/* translators: %s max price */
|
13 |
Object(c.__)("Up to %s","woo-gutenberg-products-block"),Object(a.formatPrice)(t)),m=e=>{let{type:t,name:r,prefix:a="",removeCallback:i=(()=>null),showLabel:o=!0,displayStyle:f}=e;const d=a?Object(n.createElement)(n.Fragment,null,a," ",r):r,p=Object(c.sprintf)(
|
14 |
/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */
|
15 |
+
Object(c.__)("Remove %s filter","woo-gutenberg-products-block"),r);return Object(n.createElement)("li",{className:"wc-block-active-filters__list-item",key:t+":"+r},o&&Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-type"},t+": "),"chips"===f?Object(n.createElement)(l.a,{element:"span",text:d,onRemove:i,radius:"large",ariaLabel:p}):Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-name"},Object(n.createElement)("button",{className:"wc-block-active-filters__list-item-remove",onClick:i},Object(n.createElement)(u.a,{className:"wc-block-components-chip__remove-icon",icon:b.a,size:16}),Object(n.createElement)(s.a,{screenReaderLabel:p})),d))},O=function(){if(!window)return;const e=window.location.href,t=Object(i.getQueryArgs)(e),r=Object(i.removeQueryArgs)(e,...Object.keys(t));for(var n=arguments.length,c=new Array(n),a=0;a<n;a++)c[a]=arguments[a];c.forEach(e=>{if("string"==typeof e)return delete t[e];if("object"==typeof e){const r=Object.keys(e)[0],n=t[r].toString().split(",");t[r]=n.filter(t=>t!==e[r]).join(",")}});const l=Object.fromEntries(Object.entries(t).filter(e=>{let[,t]=e;return t})),s=Object(i.addQueryArgs)(r,l);Object(o.c)(s)},j=["min_price","max_price","rating_filter","filter_","query_type_"],g=e=>{let t=!1;for(let r=0;j.length>r;r++){const n=j[r];if(n===e.substring(0,n.length)){t=!0;break}}return t},y=()=>{if(!window)return;const e=window.location.href,t=Object(i.getQueryArgs)(e),r=Object(i.removeQueryArgs)(e,...Object.keys(t)),n=Object.fromEntries(Object.keys(t).filter(e=>!g(e)).map(e=>[e,t[e]])),c=Object(i.addQueryArgs)(r,n);Object(o.c)(c)},_=()=>{if(!window)return!1;const e=window.location.href,t=Object(i.getQueryArgs)(e),r=Object.keys(t);let n=!1;for(let e=0;r.length>e;e++){const t=r[e];if(g(t)){n=!0;break}}return n},v=e=>{if(!window)return!1;const t=e.map(e=>"filter_"+e.attribute_name),r=window.location.href,n=Object(i.getQueryArgs)(r),c=Object.keys(n);let a=!1;for(let e=0;c.length>e;e++){const r=c[e];if(t.includes(r)){a=!0;break}}return a},h=e=>({heading:Object(f.a)(null==e?void 0:e.heading)?e.heading:"",headingLevel:Object(f.a)(null==e?void 0:e.headingLevel)&&parseInt(e.headingLevel,10)||d.attributes.headingLevel.default,displayStyle:Object(f.a)(null==e?void 0:e.displayStyle)&&e.displayStyle||d.attributes.displayStyle.default})},449:function(e,t,r){"use strict";r.r(t);var n=r(0),c=r(288),a=r(28),l=r(154),s=r(39);t.default=e=>{const t=Object(c.a)(e);return Object(n.createElement)("div",{className:Object(a.a)(e.className)?e.className:"",style:{...t.style}},Object(n.createElement)(l.a,{isEditor:!1,attributes:Object(s.d)(e)}))}},55:function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(3),c=r(5),a=r(0),l=r(26),s=r(70);const i=e=>{const{namespace:t,resourceName:r,resourceValues:i=[],query:o={},shouldSelect:u=!0}=e;if(!t||!r)throw new Error("The options object must have valid values for the namespace and the resource properties.");const b=Object(a.useRef)({results:[],isLoading:!0}),f=Object(l.a)(o),d=Object(l.a)(i),p=Object(s.a)(),m=Object(c.useSelect)(e=>{if(!u)return null;const c=e(n.COLLECTIONS_STORE_KEY),a=[t,r,f,d],l=c.getCollectionError(...a);if(l){if(!(l instanceof Error))throw new Error("TypeError: `error` object is not an instance of Error constructor");p(l)}return{results:c.getCollection(...a),isLoading:!c.hasFinishedResolution("getCollection",a)}},[t,r,d,f,u]);return null!==m&&(b.current=m),b.current}},56:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(6);function c(e,t){const r=Object(n.useRef)();return Object(n.useEffect)(()=>{r.current===e||t&&!t(e,r.current)||(r.current=e)},[e,t]),r.current}},61:function(e,t,r){"use strict";var n=r(0);r(95),t.a=e=>{let{children:t}=e;return Object(n.createElement)("div",{className:"wc-block-filter-title-placeholder"},t)}},66:function(e,t,r){"use strict";r.d(t,"b",(function(){return s})),r.d(t,"a",(function(){return i})),r.d(t,"d",(function(){return o})),r.d(t,"c",(function(){return u}));var n=r(11),c=r(2),a=r(68);const l=Object(c.getSettingWithCoercion)("is_rendering_php_template",!1,a.a),s="query_type_",i="filter_";function o(e){return window?Object(n.getQueryArg)(window.location.href,e):null}function u(e){l?window.location.href=e:window.history.replaceState({},"",e)}},68:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));const n=e=>"boolean"==typeof e},7:function(e,t,r){var n;!function(){"use strict";var r={}.hasOwnProperty;function c(){for(var e=[],t=0;t<arguments.length;t++){var n=arguments[t];if(n){var a=typeof n;if("string"===a||"number"===a)e.push(n);else if(Array.isArray(n)){if(n.length){var l=c.apply(null,n);l&&e.push(l)}}else if("object"===a)if(n.toString===Object.prototype.toString)for(var s in n)r.call(n,s)&&n[s]&&e.push(s);else e.push(n.toString())}}return e.join(" ")}e.exports?(c.default=c,e.exports=c):void 0===(n=function(){return c}.apply(t,[]))||(e.exports=n)}()},70:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(0);const c=()=>{const[,e]=Object(n.useState)();return Object(n.useCallback)(t=>{e(()=>{throw t})},[])}},95:function(e,t){}}]);
|
build/active-filters.asset.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php return array('dependencies' => array('lodash', 'react', 'wc-blocks-data-store', 'wc-price-format', 'wc-settings', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-polyfill', 'wp-primitives', 'wp-url'), 'version' => '
|
1 |
+
<?php return array('dependencies' => array('lodash', 'react', 'wc-blocks-data-store', 'wc-price-format', 'wc-settings', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-polyfill', 'wp-primitives', 'wp-url'), 'version' => 'a509912e977a86c103bb9f8e97df1d5a');
|
build/active-filters.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["active-filters"]=function(e){function t(t){for(var n,l,a=t[0],i=t[1],s=t[2],b=0,p=[];b<a.length;b++)l=a[b],Object.prototype.hasOwnProperty.call(c,l)&&c[l]&&p.push(c[l][0]),c[l]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(u&&u(t);p.length;)p.shift()();return o.push.apply(o,s||[]),r()}function r(){for(var e,t=0;t<o.length;t++){for(var r=o[t],n=!0,a=1;a<r.length;a++){var i=r[a];0!==c[i]&&(n=!1)}n&&(o.splice(t--,1),e=l(l.s=r[0]))}return e}var n={},c={5:0,1:0},o=[];function l(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,l),r.l=!0,r.exports}l.m=e,l.c=n,l.d=function(e,t,r){l.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,t){if(1&t&&(e=l(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(l.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)l.d(r,n,function(t){return e[t]}.bind(null,n));return r},l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,"a",t),t},l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.p="";var a=window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[],i=a.push.bind(a);a.push=t,a=a.slice();for(var s=0;s<a.length;s++)t(a[s]);var u=i;return o.push([
|
2 |
/* translators: Remove chip. */
|
3 |
Object(i.__)("Remove","woo-gutenberg-products-block"):Object(i.sprintf)(
|
4 |
/* translators: %s text of the chip to remove. */
|
5 |
-
Object(i.__)('Remove "%s"',"woo-gutenberg-products-block"),e)}const O={"aria-label":t,disabled:n,onClick:l,onKeyDown:e=>{"Backspace"!==e.key&&"Delete"!==e.key||l()}},j=p?O:{},y=p?{"aria-hidden":!0}:O;return Object(o.createElement)(b,c()({},f,j,{className:a()(r,"is-removable"),element:p?"button":f.element,screenReaderText:m,text:d}),Object(o.createElement)(g,c()({className:"wc-block-components-chip__remove"},y),Object(o.createElement)(s.a,{className:"wc-block-components-chip__remove-icon",icon:u.a,size:16})))}},26:function(e,t){e.exports=window.wc.priceFormat},28:function(e,t,r){"use strict";var n=r(0),c=r(4),o=r.n(c);t.a=e=>{let t,{label:r,screenReaderLabel:c,wrapperElement:l,wrapperProps:a={}}=e;const i=null!=r,s=null!=c;return!i&&s?(t=l||"span",a={...a,className:o()(a.className,"screen-reader-text")},Object(n.createElement)(t,a,c)):(t=l||n.Fragment,i&&s&&r!==c?Object(n.createElement)(t,a,Object(n.createElement)("span",{"aria-hidden":"true"},r),Object(n.createElement)("span",{className:"screen-reader-text"},c)):Object(n.createElement)(t,a,r))}},3:function(e,t){e.exports=window.wp.components},35:function(e,t,r){"use strict";r.d(t,"a",(function(){return n})),r.d(t,"b",(function(){return c}));const n=e=>!(e=>null===e)(e)&&e instanceof Object&&e.constructor===Object;function c(e,t){return n(e)&&t in e}},40:function(e,t,r){"use strict";r.d(t,"a",(function(){return l}));var n=r(0),c=r(25),o=r.n(c);function l(e){const t=Object(n.useRef)(e);return o()(e,t.current)||(t.current=e),t.current}},
|
6 |
/* translators: %1$s min price, %2$s max price */
|
7 |
Object(p.__)("Between %1$s and %2$s","woo-gutenberg-products-block"),Object(k.formatPrice)(e),Object(k.formatPrice)(t)):Number.isFinite(e)?Object(p.sprintf)(
|
8 |
/* translators: %s min price */
|
@@ -10,6 +10,6 @@ Object(p.__)("From %s","woo-gutenberg-products-block"),Object(k.formatPrice)(e))
|
|
10 |
/* translators: %s max price */
|
11 |
Object(p.__)("Up to %s","woo-gutenberg-products-block"),Object(k.formatPrice)(t)),A=e=>{let{type:t,name:r,prefix:n="",removeCallback:c=(()=>null),showLabel:l=!0,displayStyle:a}=e;const s=n?Object(o.createElement)(o.Fragment,null,n," ",r):r,u=Object(p.sprintf)(
|
12 |
/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */
|
13 |
-
Object(p.__)("Remove %s filter","woo-gutenberg-products-block"),r);return Object(o.createElement)("li",{className:"wc-block-active-filters__list-item",key:t+":"+r},l&&Object(o.createElement)("span",{className:"wc-block-active-filters__list-item-type"},t+": "),"chips"===a?Object(o.createElement)(E.a,{element:"span",text:s,onRemove:c,radius:"large",ariaLabel:u}):Object(o.createElement)("span",{className:"wc-block-active-filters__list-item-name"},Object(o.createElement)("button",{className:"wc-block-active-filters__list-item-remove",onClick:c},Object(o.createElement)(i.a,{className:"wc-block-components-chip__remove-icon",icon:x.a,size:16}),Object(o.createElement)(O.a,{screenReaderLabel:u})),s))},R=function(){if(!window)return;const e=window.location.href,t=Object(S.getQueryArgs)(e),r=Object(S.removeQueryArgs)(e,...Object.keys(t));for(var n=arguments.length,c=new Array(n),o=0;o<n;o++)c[o]=arguments[o];c.forEach(e=>{if("string"==typeof e)return delete t[e];if("object"==typeof e){const r=Object.keys(e)[0],n=t[r].toString().split(",");t[r]=n.filter(t=>t!==e[r]).join(",")}});const l=Object.fromEntries(Object.entries(t).filter(e=>{let[,t]=e;return t})),a=Object(S.addQueryArgs)(r,l);Object(_.c)(a)},T=["min_price","max_price","rating_filter","filter_","query_type_"],L=e=>{let t=!1;for(let r=0;T.length>r;r++){const n=T[r];if(n===e.substring(0,n.length)){t=!0;break}}return t};var B=r(
|
14 |
/* translators: %s is referring to the average rating value */
|
15 |
-
Object(p.__)("Rated %s out of 5","woo-gutenberg-products-block"),e),removeCallback:()=>{if(R({rating_filter:e}),!l){const t=B.filter(t=>t!==e);F(t)}},showLabel:!1,displayStyle:t.displayStyle}))))},[s,B,F,t.displayStyle,l]);if(!s&&!(b.length>0||m.length>0||B.length>0||Number.isFinite(E)||Number.isFinite(N))&&!r)return n(!1),null;const K="h"+t.headingLevel,U=Object(o.createElement)(K,{className:"wc-block-active-filters__title"},t.heading),q=s?Object(o.createElement)(h.a,null,U):U;if(!Object(g.getSettingWithCoercion)("has_filterable_products",!1,j.a))return n(!1),null;n(!0);const G=u()("wc-block-active-filters__list",{"wc-block-active-filters__list--chips":"chips"===t.displayStyle,"wc-block-active-filters--loading":s});return Object(o.createElement)(o.Fragment,null,!r&&t.heading&&q,Object(o.createElement)("div",{className:"wc-block-active-filters"},Object(o.createElement)("ul",{className:G},r?Object(o.createElement)(o.Fragment,null,A({type:Object(p.__)("Size","woo-gutenberg-products-block"),name:Object(p.__)("Small","woo-gutenberg-products-block"),displayStyle:t.displayStyle}),A({type:Object(p.__)("Color","woo-gutenberg-products-block"),name:Object(p.__)("Blue","woo-gutenberg-products-block"),displayStyle:t.displayStyle})):Object(o.createElement)(o.Fragment,null,Object(o.createElement)(M,{isLoading:s,displayStyle:t.displayStyle}),W,V,Y,z)),s?Object(o.createElement)("span",{className:"wc-block-active-filters__clear-all-placeholder"}):Object(o.createElement)("button",{className:"wc-block-active-filters__clear-all",onClick:()=>{(()=>{if(!window)return;const e=window.location.href,t=Object(S.getQueryArgs)(e),r=Object(S.removeQueryArgs)(e,...Object.keys(t)),n=Object.fromEntries(Object.keys(t).filter(e=>!L(e)).map(e=>[e,t[e]])),c=Object(S.addQueryArgs)(r,n);Object(_.c)(c)})(),l||(x(void 0),T(void 0),d([]),k([]),F([]))}},Object(o.createElement)(O.a,{label:Object(p.__)("Clear All","woo-gutenberg-products-block"),screenReaderLabel:Object(p.__)("Clear All Filters","woo-gutenberg-products-block")}))))},V=(r(
|
1 |
+
this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["active-filters"]=function(e){function t(t){for(var n,l,a=t[0],i=t[1],s=t[2],b=0,p=[];b<a.length;b++)l=a[b],Object.prototype.hasOwnProperty.call(c,l)&&c[l]&&p.push(c[l][0]),c[l]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(u&&u(t);p.length;)p.shift()();return o.push.apply(o,s||[]),r()}function r(){for(var e,t=0;t<o.length;t++){for(var r=o[t],n=!0,a=1;a<r.length;a++){var i=r[a];0!==c[i]&&(n=!1)}n&&(o.splice(t--,1),e=l(l.s=r[0]))}return e}var n={},c={5:0,1:0},o=[];function l(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,l),r.l=!0,r.exports}l.m=e,l.c=n,l.d=function(e,t,r){l.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,t){if(1&t&&(e=l(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(l.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)l.d(r,n,function(t){return e[t]}.bind(null,n));return r},l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,"a",t),t},l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.p="";var a=window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[],i=a.push.bind(a);a.push=t,a=a.slice();for(var s=0;s<a.length;s++)t(a[s]);var u=i;return o.push([407,0]),r()}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},10:function(e,t){e.exports=window.wc.wcBlocksData},101:function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(0);const c=Object(n.createContext)({}),o=()=>{const{wrapper:e}=Object(n.useContext)(c);return t=>{e&&e.current&&(e.current.hidden=!t)}}},102:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(13);function c(e,t){const r=Object(n.useRef)();return Object(n.useEffect)(()=>{r.current===e||t&&!t(e,r.current)||(r.current=e)},[e,t]),r.current}},106:function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(10),c=r(7),o=r(0),l=r(40),a=r(141);const i=e=>{const{namespace:t,resourceName:r,resourceValues:i=[],query:s={},shouldSelect:u=!0}=e;if(!t||!r)throw new Error("The options object must have valid values for the namespace and the resource properties.");const b=Object(o.useRef)({results:[],isLoading:!0}),p=Object(l.a)(s),d=Object(l.a)(i),m=Object(a.a)(),f=Object(c.useSelect)(e=>{if(!u)return null;const c=e(n.COLLECTIONS_STORE_KEY),o=[t,r,p,d],l=c.getCollectionError(...o);if(l){if(!(l instanceof Error))throw new Error("TypeError: `error` object is not an instance of Error constructor");m(l)}return{results:c.getCollection(...o),isLoading:!c.hasFinishedResolution("getCollection",o)}},[t,r,d,p,u]);return null!==f&&(b.current=f),b.current}},11:function(e,t){e.exports=window.wp.compose},12:function(e,t){e.exports=window.wp.primitives},121:function(e,t,r){"use strict";r.d(t,"a",(function(){return s}));var n=r(0),c=r(1),o=r(9),l=r(7),a=r(3),i=r(5);const s=e=>{let{clientId:t,setAttributes:r,filterType:s,attributes:u}=e;const{replaceBlock:b}=Object(l.useDispatch)("core/block-editor"),{heading:p,headingLevel:d}=u;if(Object(l.useSelect)(e=>{const{getBlockParentsByBlockName:r}=e("core/block-editor");return r(t,"woocommerce/filter-wrapper").length>0},[t])||!s)return null;const m=[Object(n.createElement)(a.Button,{key:"convert",onClick:()=>{const e=[Object(o.createBlock)("woocommerce/"+s,{...u,heading:""})];p&&""!==p&&e.unshift(Object(o.createBlock)("core/heading",{content:p,level:null!=d?d:2})),b(t,Object(o.createBlock)("woocommerce/filter-wrapper",{heading:p,filterType:s},[...e])),r({heading:"",lock:{remove:!0}})},variant:"primary"},Object(c.__)("Upgrade block","woo-gutenberg-products-block"))];return Object(n.createElement)(i.Warning,{actions:m},Object(c.__)("Filter block: We have improved this block to make styling easier. Upgrade it using the button below.","woo-gutenberg-products-block"))}},122:function(e,t,r){"use strict";var n=r(0),c=r(5),o=r(11),l=r(1);r(166),t.a=Object(o.withInstanceId)(e=>{let{className:t,headingLevel:r,onChange:o,heading:a,instanceId:i}=e;const s="h"+r;return Object(n.createElement)(s,{className:t},Object(n.createElement)("label",{className:"screen-reader-text",htmlFor:"block-title-"+i},Object(l.__)("Block title","woo-gutenberg-products-block")),Object(n.createElement)(c.PlainText,{id:"block-title-"+i,className:"wc-block-editor-components-title",value:a,onChange:o}))})},123:function(e,t,r){"use strict";var n=r(0);r(167),t.a=e=>{let{children:t}=e;return Object(n.createElement)("div",{className:"wc-block-filter-title-placeholder"},t)}},126:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));const n=e=>"boolean"==typeof e},13:function(e,t){e.exports=window.React},141:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(0);const c=()=>{const[,e]=Object(n.useState)();return Object(n.useCallback)(t=>{e(()=>{throw t})},[])}},15:function(e,t){e.exports=window.wp.htmlEntities},166:function(e,t){},167:function(e,t){},17:function(e,t){e.exports=window.wp.url},180:function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r.d(t,"b",(function(){return o}));var n=r(8);const c=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";const o=e.filter(e=>e.attribute===r.taxonomy),l=o.length?o[0]:null;if(!(l&&l.slug&&Array.isArray(l.slug)&&l.slug.includes(c)))return;const a=l.slug.filter(e=>e!==c),i=e.filter(e=>e.attribute!==r.taxonomy);a.length>0&&(l.slug=a.sort(),i.push(l)),t(Object(n.sortBy)(i,"attribute"))},o=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"in";if(!r||!r.taxonomy)return[];const l=e.filter(e=>e.attribute!==r.taxonomy);return 0===c.length?t(l):(l.push({attribute:r.taxonomy,operator:o,slug:c.map(e=>{let{slug:t}=e;return t}).sort()}),t(Object(n.sortBy)(l,"attribute"))),l}},182:function(e){e.exports=JSON.parse('{"name":"woocommerce/active-filters","version":"1.0.0","title":"Active Product Filters Controls","description":"Display the currently active product filters.","category":"woocommerce","keywords":["WooCommerce"],"supports":{"html":false,"multiple":false,"inserter":false,"color":{"text":true,"background":false},"lock":false},"attributes":{"displayStyle":{"type":"string","default":"list"},"headingLevel":{"type":"number","default":3}},"textdomain":"woo-gutenberg-products-block","apiVersion":2,"$schema":"https://schemas.wp.org/trunk/block.json"}')},195:function(e,t){},2:function(e,t){e.exports=window.wc.wcSettings},217:function(e,t,r){"use strict";r.d(t,"a",(function(){return o})),r.d(t,"b",(function(){return l}));var n=r(2);const c=Object(n.getSetting)("attributes",[]).reduce((e,t)=>{const r=(n=t)&&n.attribute_name?{id:parseInt(n.attribute_id,10),name:n.attribute_name,taxonomy:"pa_"+n.attribute_name,label:n.attribute_label}:null;var n;return r&&r.id&&e.push(r),e},[]),o=e=>{if(e)return c.find(t=>t.id===e)},l=e=>{if(e)return c.find(t=>t.taxonomy===e)}},234:function(e,t,r){"use strict";r.d(t,"b",(function(){return a})),r.d(t,"a",(function(){return i})),r.d(t,"d",(function(){return s})),r.d(t,"c",(function(){return u}));var n=r(17),c=r(2),o=r(126);const l=Object(c.getSettingWithCoercion)("is_rendering_php_template",!1,o.a),a="query_type_",i="filter_";function s(e){return window?Object(n.getQueryArg)(window.location.href,e):null}function u(e){l?window.location.href=e:window.history.replaceState({},"",e)}},248:function(e,t,r){"use strict";var n=r(6),c=r.n(n),o=r(0),l=r(4),a=r.n(l),i=r(1),s=r(116),u=r(540);r(195);var b=e=>{let{text:t,screenReaderText:r="",element:n="li",className:l="",radius:i="small",children:s=null,...u}=e;const b=n,p=a()(l,"wc-block-components-chip","wc-block-components-chip--radius-"+i),d=Boolean(r&&r!==t);return Object(o.createElement)(b,c()({className:p},u),Object(o.createElement)("span",{"aria-hidden":d,className:"wc-block-components-chip__text"},t),d&&Object(o.createElement)("span",{className:"screen-reader-text"},r),s)};t.a=e=>{let{ariaLabel:t="",className:r="",disabled:n=!1,onRemove:l=(()=>{}),removeOnAnyClick:p=!1,text:d,screenReaderText:m="",...f}=e;const g=p?"span":"button";if(!t){const e=m&&"string"==typeof m?m:d;t="string"!=typeof e?
|
2 |
/* translators: Remove chip. */
|
3 |
Object(i.__)("Remove","woo-gutenberg-products-block"):Object(i.sprintf)(
|
4 |
/* translators: %s text of the chip to remove. */
|
5 |
+
Object(i.__)('Remove "%s"',"woo-gutenberg-products-block"),e)}const O={"aria-label":t,disabled:n,onClick:l,onKeyDown:e=>{"Backspace"!==e.key&&"Delete"!==e.key||l()}},j=p?O:{},y=p?{"aria-hidden":!0}:O;return Object(o.createElement)(b,c()({},f,j,{className:a()(r,"is-removable"),element:p?"button":f.element,screenReaderText:m,text:d}),Object(o.createElement)(g,c()({className:"wc-block-components-chip__remove"},y),Object(o.createElement)(s.a,{className:"wc-block-components-chip__remove-icon",icon:u.a,size:16})))}},25:function(e,t){e.exports=window.wp.isShallowEqual},26:function(e,t){e.exports=window.wc.priceFormat},28:function(e,t,r){"use strict";var n=r(0),c=r(4),o=r.n(c);t.a=e=>{let t,{label:r,screenReaderLabel:c,wrapperElement:l,wrapperProps:a={}}=e;const i=null!=r,s=null!=c;return!i&&s?(t=l||"span",a={...a,className:o()(a.className,"screen-reader-text")},Object(n.createElement)(t,a,c)):(t=l||n.Fragment,i&&s&&r!==c?Object(n.createElement)(t,a,Object(n.createElement)("span",{"aria-hidden":"true"},r),Object(n.createElement)("span",{className:"screen-reader-text"},c)):Object(n.createElement)(t,a,r))}},3:function(e,t){e.exports=window.wp.components},35:function(e,t,r){"use strict";r.d(t,"a",(function(){return n})),r.d(t,"b",(function(){return c}));const n=e=>!(e=>null===e)(e)&&e instanceof Object&&e.constructor===Object;function c(e,t){return n(e)&&t in e}},40:function(e,t,r){"use strict";r.d(t,"a",(function(){return l}));var n=r(0),c=r(25),o=r.n(c);function l(e){const t=Object(n.useRef)(e);return o()(e,t.current)||(t.current=e),t.current}},400:function(e,t,r){"use strict";r.d(t,"b",(function(){return o})),r.d(t,"a",(function(){return a}));var n=r(35);const c=e=>Object(n.b)(e,"count")&&Object(n.b)(e,"description")&&Object(n.b)(e,"id")&&Object(n.b)(e,"name")&&Object(n.b)(e,"parent")&&Object(n.b)(e,"slug")&&"number"==typeof e.count&&"string"==typeof e.description&&"number"==typeof e.id&&"string"==typeof e.name&&"number"==typeof e.parent&&"string"==typeof e.slug,o=e=>Array.isArray(e)&&e.every(c),l=e=>Object(n.b)(e,"attribute")&&Object(n.b)(e,"operator")&&Object(n.b)(e,"slug")&&"string"==typeof e.attribute&&"string"==typeof e.operator&&Array.isArray(e.slug)&&e.slug.every(e=>"string"==typeof e),a=e=>Array.isArray(e)&&e.every(l)},407:function(e,t,r){e.exports=r(473)},408:function(e,t,r){"use strict";var n=r(0),c=r(12);const o=Object(n.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(n.createElement)("path",{fill:"none",d:"M0 0h24v24H0z"}),Object(n.createElement)("path",{d:"M17 6H7c-3.31 0-6 2.69-6 6s2.69 6 6 6h10c3.31 0 6-2.69 6-6s-2.69-6-6-6zm0 10H7c-2.21 0-4-1.79-4-4s1.79-4 4-4h10c2.21 0 4 1.79 4 4s-1.79 4-4 4zm0-7c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"}));t.a=o},409:function(e,t){},410:function(e,t){},46:function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(0);const c=Object(n.createContext)("page"),o=()=>Object(n.useContext)(c);c.Provider},473:function(e,t,r){"use strict";r.r(t);var n=r(6),c=r.n(n),o=r(0),l=r(9),a=r(408),i=r(116),s=r(4),u=r.n(s),b=r(5),p=r(1),d=r(122),m=r(3),f=r(51),g=r(2),O=r(28),j=r(126),y=r(35),w=r(400),_=r(234),h=r(123);r(410);var v=r(217),k=r(26),E=r(248),S=r(17),x=r(540),N=(r(95),r(182));const C=(e,t)=>Number.isFinite(e)&&Number.isFinite(t)?Object(p.sprintf)(
|
6 |
/* translators: %1$s min price, %2$s max price */
|
7 |
Object(p.__)("Between %1$s and %2$s","woo-gutenberg-products-block"),Object(k.formatPrice)(e),Object(k.formatPrice)(t)):Number.isFinite(e)?Object(p.sprintf)(
|
8 |
/* translators: %s min price */
|
10 |
/* translators: %s max price */
|
11 |
Object(p.__)("Up to %s","woo-gutenberg-products-block"),Object(k.formatPrice)(t)),A=e=>{let{type:t,name:r,prefix:n="",removeCallback:c=(()=>null),showLabel:l=!0,displayStyle:a}=e;const s=n?Object(o.createElement)(o.Fragment,null,n," ",r):r,u=Object(p.sprintf)(
|
12 |
/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */
|
13 |
+
Object(p.__)("Remove %s filter","woo-gutenberg-products-block"),r);return Object(o.createElement)("li",{className:"wc-block-active-filters__list-item",key:t+":"+r},l&&Object(o.createElement)("span",{className:"wc-block-active-filters__list-item-type"},t+": "),"chips"===a?Object(o.createElement)(E.a,{element:"span",text:s,onRemove:c,radius:"large",ariaLabel:u}):Object(o.createElement)("span",{className:"wc-block-active-filters__list-item-name"},Object(o.createElement)("button",{className:"wc-block-active-filters__list-item-remove",onClick:c},Object(o.createElement)(i.a,{className:"wc-block-components-chip__remove-icon",icon:x.a,size:16}),Object(o.createElement)(O.a,{screenReaderLabel:u})),s))},R=function(){if(!window)return;const e=window.location.href,t=Object(S.getQueryArgs)(e),r=Object(S.removeQueryArgs)(e,...Object.keys(t));for(var n=arguments.length,c=new Array(n),o=0;o<n;o++)c[o]=arguments[o];c.forEach(e=>{if("string"==typeof e)return delete t[e];if("object"==typeof e){const r=Object.keys(e)[0],n=t[r].toString().split(",");t[r]=n.filter(t=>t!==e[r]).join(",")}});const l=Object.fromEntries(Object.entries(t).filter(e=>{let[,t]=e;return t})),a=Object(S.addQueryArgs)(r,l);Object(_.c)(a)},T=["min_price","max_price","rating_filter","filter_","query_type_"],L=e=>{let t=!1;for(let r=0;T.length>r;r++){const n=T[r];if(n===e.substring(0,n.length)){t=!0;break}}return t};var B=r(106),F=r(15),P=r(180),Q=e=>{let{attributeObject:t,slugs:r=[],operator:n="in",displayStyle:c,isLoadingCallback:l}=e;const{results:a,isLoading:i}=Object(B.a)({namespace:"/wc/store/v1",resourceName:"products/attributes/terms",resourceValues:[t.id]}),[s,u]=Object(f.b)("attributes",[]);if(Object(o.useEffect)(()=>{l(i)},[i,l]),!Array.isArray(a)||!Object(w.b)(a)||!Object(w.a)(s))return null;const b=t.label,d=Object(g.getSettingWithCoercion)("is_rendering_php_template",!1,j.a);return Object(o.createElement)("li",null,Object(o.createElement)("span",{className:"wc-block-active-filters__list-item-type"},b,":"),Object(o.createElement)("ul",null,r.map((e,r)=>{const l=a.find(t=>t.slug===e);if(!l)return null;let m="";return r>0&&"and"===n&&(m=Object(o.createElement)("span",{className:"wc-block-active-filters__list-item-operator"},Object(p.__)("All","woo-gutenberg-products-block"))),A({type:b,name:Object(F.decodeEntities)(l.name||e),prefix:m,isLoading:i,removeCallback:()=>{const r=s.find(e=>{let{attribute:r}=e;return r==="pa_"+t.name});1===(null==r?void 0:r.slug.length)?R("query_type_"+t.name,"filter_"+t.name):R({["filter_"+t.name]:e}),d||Object(P.a)(s,u,t,e)},showLabel:!1,displayStyle:c})})))},M=e=>{let{displayStyle:t,isLoading:r}=e;return r?Object(o.createElement)(o.Fragment,null,[...Array("list"===t?2:3)].map((e,r)=>Object(o.createElement)("li",{className:"list"===t?"show-loading-state-list":"show-loading-state-chips",key:r},Object(o.createElement)("span",{className:"show-loading-state__inner"})))):null},D=r(101),I=e=>{let{attributes:t,isEditor:r=!1}=e;const n=Object(D.a)(),c=function(){const e=Object(o.useRef)(!1);return Object(o.useEffect)(()=>(e.current=!0,()=>{e.current=!1}),[]),Object(o.useCallback)(()=>e.current,[])}()(),l=Object(g.getSettingWithCoercion)("is_rendering_php_template",!1,j.a),[a,i]=Object(o.useState)(!0),s=(()=>{if(!window)return!1;const e=window.location.href,t=Object(S.getQueryArgs)(e),r=Object.keys(t);let n=!1;for(let e=0;r.length>e;e++){const t=r[e];if(L(t)){n=!0;break}}return n})()&&!r&&a,[b,d]=Object(f.b)("attributes",[]),[m,k]=Object(f.b)("stock_status",[]),[E,x]=Object(f.b)("min_price"),[N,T]=Object(f.b)("max_price"),[B,F]=Object(f.b)("rating"),P=Object(g.getSetting)("stockStatusOptions",[]),I=Object(g.getSetting)("attributes",[]),V=Object(o.useMemo)(()=>{if(s||0===m.length||(e=m,!Array.isArray(e)||!e.every(e=>["instock","outofstock","onbackorder"].includes(e)))||!(e=>Object(y.a)(e)&&Object.keys(e).every(e=>["instock","outofstock","onbackorder"].includes(e)))(P))return null;var e;const r=Object(p.__)("Stock Status","woo-gutenberg-products-block");return Object(o.createElement)("li",null,Object(o.createElement)("span",{className:"wc-block-active-filters__list-item-type"},r,":"),Object(o.createElement)("ul",null,m.map(e=>A({type:r,name:P[e],removeCallback:()=>{if(R({filter_stock_status:e}),!l){const t=m.filter(t=>t!==e);k(t)}},showLabel:!1,displayStyle:t.displayStyle}))))},[s,P,m,k,t.displayStyle,l]),W=Object(o.useMemo)(()=>s||!Number.isFinite(E)&&!Number.isFinite(N)?null:A({type:Object(p.__)("Price","woo-gutenberg-products-block"),name:C(E,N),removeCallback:()=>{R("max_price","min_price"),l||(x(void 0),T(void 0))},displayStyle:t.displayStyle}),[s,E,N,t.displayStyle,x,T,l]),Y=Object(o.useMemo)(()=>!Object(w.a)(b)&&c||!b.length&&!(e=>{if(!window)return!1;const t=e.map(e=>"filter_"+e.attribute_name),r=window.location.href,n=Object(S.getQueryArgs)(r),c=Object.keys(n);let o=!1;for(let e=0;c.length>e;e++){const r=c[e];if(t.includes(r)){o=!0;break}}return o})(I)?(a&&i(!1),null):b.map(e=>{const r=Object(v.b)(e.attribute);return r?Object(o.createElement)(Q,{attributeObject:r,displayStyle:t.displayStyle,slugs:e.slug,key:e.attribute,operator:e.operator,isLoadingCallback:i}):(a&&i(!1),null)}),[b,c,I,a,t.displayStyle]);Object(o.useEffect)(()=>{var e;if(!l)return;if(B.length&&B.length>0)return;const t=null===(e=Object(_.d)("rating_filter"))||void 0===e?void 0:e.toString();t&&F(t.split(","))},[l,B,F]);const z=Object(o.useMemo)(()=>{if(s||0===B.length||(e=B,!Array.isArray(e)||!e.every(e=>["1","2","3","4","5"].includes(e))))return null;var e;const r=Object(p.__)("Rating","woo-gutenberg-products-block");return Object(o.createElement)("li",null,Object(o.createElement)("span",{className:"wc-block-active-filters__list-item-type"},r,":"),Object(o.createElement)("ul",null,B.map(e=>A({type:r,name:Object(p.sprintf)(
|
14 |
/* translators: %s is referring to the average rating value */
|
15 |
+
Object(p.__)("Rated %s out of 5","woo-gutenberg-products-block"),e),removeCallback:()=>{if(R({rating_filter:e}),!l){const t=B.filter(t=>t!==e);F(t)}},showLabel:!1,displayStyle:t.displayStyle}))))},[s,B,F,t.displayStyle,l]);if(!s&&!(b.length>0||m.length>0||B.length>0||Number.isFinite(E)||Number.isFinite(N))&&!r)return n(!1),null;const K="h"+t.headingLevel,U=Object(o.createElement)(K,{className:"wc-block-active-filters__title"},t.heading),q=s?Object(o.createElement)(h.a,null,U):U;if(!Object(g.getSettingWithCoercion)("has_filterable_products",!1,j.a))return n(!1),null;n(!0);const G=u()("wc-block-active-filters__list",{"wc-block-active-filters__list--chips":"chips"===t.displayStyle,"wc-block-active-filters--loading":s});return Object(o.createElement)(o.Fragment,null,!r&&t.heading&&q,Object(o.createElement)("div",{className:"wc-block-active-filters"},Object(o.createElement)("ul",{className:G},r?Object(o.createElement)(o.Fragment,null,A({type:Object(p.__)("Size","woo-gutenberg-products-block"),name:Object(p.__)("Small","woo-gutenberg-products-block"),displayStyle:t.displayStyle}),A({type:Object(p.__)("Color","woo-gutenberg-products-block"),name:Object(p.__)("Blue","woo-gutenberg-products-block"),displayStyle:t.displayStyle})):Object(o.createElement)(o.Fragment,null,Object(o.createElement)(M,{isLoading:s,displayStyle:t.displayStyle}),W,V,Y,z)),s?Object(o.createElement)("span",{className:"wc-block-active-filters__clear-all-placeholder"}):Object(o.createElement)("button",{className:"wc-block-active-filters__clear-all",onClick:()=>{(()=>{if(!window)return;const e=window.location.href,t=Object(S.getQueryArgs)(e),r=Object(S.removeQueryArgs)(e,...Object.keys(t)),n=Object.fromEntries(Object.keys(t).filter(e=>!L(e)).map(e=>[e,t[e]])),c=Object(S.addQueryArgs)(r,n);Object(_.c)(c)})(),l||(x(void 0),T(void 0),d([]),k([]),F([]))}},Object(o.createElement)(O.a,{label:Object(p.__)("Clear All","woo-gutenberg-products-block"),screenReaderLabel:Object(p.__)("Clear All Filters","woo-gutenberg-products-block")}))))},V=(r(409),r(121)),W=Object(m.withSpokenMessages)(e=>{let{attributes:t,setAttributes:r,clientId:n}=e;const{className:c,displayStyle:l,heading:a,headingLevel:i}=t,s=Object(b.useBlockProps)({className:c});return Object(o.createElement)("div",s,Object(o.createElement)(b.InspectorControls,{key:"inspector"},Object(o.createElement)(m.PanelBody,{title:Object(p.__)("Display Settings","woo-gutenberg-products-block")},Object(o.createElement)(m.__experimentalToggleGroupControl,{label:Object(p.__)("Display Style","woo-gutenberg-products-block"),value:l,onChange:e=>r({displayStyle:e}),className:"wc-block-active-filter__style-toggle"},Object(o.createElement)(m.__experimentalToggleGroupControlOption,{value:"list",label:Object(p.__)("List","woo-gutenberg-products-block")}),Object(o.createElement)(m.__experimentalToggleGroupControlOption,{value:"chips",label:Object(p.__)("Chips","woo-gutenberg-products-block")})))),Object(o.createElement)(V.a,{attributes:t,clientId:n,setAttributes:r,filterType:"active-filters"}),a&&Object(o.createElement)(d.a,{className:"wc-block-active-filters__title",headingLevel:i,heading:a,onChange:e=>r({heading:e})}),Object(o.createElement)(m.Disabled,null,Object(o.createElement)(I,{attributes:t,isEditor:!0})))});const Y={heading:{type:"string",default:Object(p.__)("Active filters","woo-gutenberg-products-block")}};Object(l.registerBlockType)(N,{icon:{src:Object(o.createElement)(i.a,{icon:a.a,className:"wc-block-editor-components-block-icon"})},attributes:{...N.attributes,...Y},edit:W,save(e){let{attributes:t}=e;const{className:r,displayStyle:n,heading:l,headingLevel:a}=t,i={"data-display-style":n,"data-heading":l,"data-heading-level":a};return Object(o.createElement)("div",c()({},b.useBlockProps.save({className:u()("is-loading",r)}),i),Object(o.createElement)("span",{"aria-hidden":!0,className:"wc-block-active-product-filters__placeholder"}))}})},5:function(e,t){e.exports=window.wp.blockEditor},51:function(e,t,r){"use strict";r.d(t,"a",(function(){return b})),r.d(t,"b",(function(){return p})),r.d(t,"c",(function(){return d}));var n=r(10),c=r(7),o=r(0),l=r(25),a=r.n(l),i=r(40),s=r(102),u=r(46);const b=e=>{const t=Object(u.a)();e=e||t;const r=Object(c.useSelect)(t=>t(n.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0),[e]),{setValueForQueryContext:l}=Object(c.useDispatch)(n.QUERY_STATE_STORE_KEY);return[r,Object(o.useCallback)(t=>{l(e,t)},[e,l])]},p=(e,t,r)=>{const l=Object(u.a)();r=r||l;const a=Object(c.useSelect)(c=>c(n.QUERY_STATE_STORE_KEY).getValueForQueryKey(r,e,t),[r,e]),{setQueryValue:i}=Object(c.useDispatch)(n.QUERY_STATE_STORE_KEY);return[a,Object(o.useCallback)(t=>{i(r,e,t)},[r,e,i])]},d=(e,t)=>{const r=Object(u.a)();t=t||r;const[n,c]=b(t),l=Object(i.a)(n),p=Object(i.a)(e),d=Object(s.a)(p),m=Object(o.useRef)(!1);return Object(o.useEffect)(()=>{a()(d,p)||(c(Object.assign({},l,p)),m.current=!0)},[l,p,d,c]),m.current?[n,c]:[e,c]}},7:function(e,t){e.exports=window.wp.data},8:function(e,t){e.exports=window.lodash},9:function(e,t){e.exports=window.wp.blocks},95:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));const n=e=>"string"==typeof e}});
|
build/all-products-frontend.asset.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php return array('dependencies' => array('lodash', 'react', 'wc-blocks-data-store', 'wc-blocks-registry', 'wc-blocks-shared-context', 'wc-blocks-shared-hocs', 'wc-price-format', 'wc-settings', 'wp-a11y', 'wp-api-fetch', 'wp-autop', 'wp-block-editor', 'wp-blocks', 'wp-compose', 'wp-data', 'wp-deprecated', 'wp-dom', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-polyfill', 'wp-primitives', 'wp-url', 'wp-warning', 'wp-wordcount'), 'version' => '
|
1 |
+
<?php return array('dependencies' => array('lodash', 'react', 'wc-blocks-checkout', 'wc-blocks-data-store', 'wc-blocks-registry', 'wc-blocks-shared-context', 'wc-blocks-shared-hocs', 'wc-price-format', 'wc-settings', 'wp-a11y', 'wp-api-fetch', 'wp-autop', 'wp-block-editor', 'wp-blocks', 'wp-compose', 'wp-data', 'wp-deprecated', 'wp-dom', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-polyfill', 'wp-primitives', 'wp-url', 'wp-warning', 'wp-wordcount'), 'version' => '197c37d0e81d53abf575d525ad5e8e3b');
|
build/all-products-frontend.js
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
-
!function(e){function t(t){for(var n,o,c=t[0],i=t[1],a=0,s=[];a<c.length;a++)o=c[a],Object.prototype.hasOwnProperty.call(r,o)&&r[o]&&s.push(r[o][0]),r[o]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(l&&l(t);s.length;)s.shift()()}var n={},r={13:0,9:0};function o(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.e=function(e){var t=[],n=r[e];if(0!==n)if(n)t.push(n[2]);else{var c=new Promise((function(t,o){n=r[e]=[t,o]}));t.push(n[2]=c);var i,a=document.createElement("script");a.charset="utf-8",a.timeout=120,o.nc&&a.setAttribute("nonce",o.nc),a.src=function(e){return o.p+""+({0:"vendors--cart-blocks/cart-cross-sells-products--cart-blocks/cart-line-items--cart-blocks/cart-order--671ca56f",1:"vendors--cart-blocks/cart-cross-sells-products--cart-blocks/order-summary-shipping--checkout-blocks--18f9376a",4:"cart-blocks/cart-cross-sells-products--product-add-to-cart",10:"vendors--cart-blocks/cart-cross-sells-products--product-add-to-cart",67:"product-add-to-cart",68:"product-button",69:"product-category-list",70:"product-image",71:"product-price",72:"product-rating",73:"product-sale-badge",74:"product-sku",75:"product-stock-indicator",76:"product-summary",77:"product-tag-list",78:"product-title"}[e]||e)+"-frontend.js?ver="+{0:"d38c6dddd58bd116a27a",1:"172dd05b733f3cf7e0f0",4:"edd29eaf8eb414b44d37",10:"1385be0e7f5b0ac9dc33",67:"30f53871d262bf5de4a8",68:"6b31eaffc66765be34e6",69:"b335d159ae43782d862b",70:"7c15541aa901b93c10cc",71:"e1886d800436704391dc",72:"8e6cb2ff14b931721f4c",73:"098e8192d8a029f2816a",74:"f5130e1bd26eb4aa53e8",75:"1c0cab4661457cee7eac",76:"5e89f434aa10c21946f5",77:"515ce3629df4e5aba922",78:"614fd023e0506f2d347d"}[e]}(e);var l=new Error;i=function(t){a.onerror=a.onload=null,clearTimeout(s);var n=r[e];if(0!==n){if(n){var o=t&&("load"===t.type?"missing":t.type),c=t&&t.target&&t.target.src;l.message="Loading chunk "+e+" failed.\n("+o+": "+c+")",l.name="ChunkLoadError",l.type=o,l.request=c,n[1](l)}r[e]=void 0}};var s=setTimeout((function(){i({type:"timeout",target:a})}),12e4);a.onerror=a.onload=i,document.head.appendChild(a)}return Promise.all(t)},o.m=e,o.c=n,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)o.d(n,r,function(t){return e[t]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o.oe=function(e){throw console.error(e),e};var c=window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[],i=c.push.bind(c);c.push=t,c=c.slice();for(var a=0;a<c.length;a++)t(c[a]);var l=i;o(o.s=241)}([function(e,t){e.exports=window.wp.element},function(e,t){e.exports=window.wp.i18n},function(e,t){e.exports=window.wc.wcSettings},function(e,t){e.exports=window.wc.wcBlocksData},function(e,t,n){var r;!function(){"use strict";var n={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var c=typeof r;if("string"===c||"number"===c)e.push(r);else if(Array.isArray(r)){if(r.length){var i=o.apply(null,r);i&&e.push(i)}}else if("object"===c)if(r.toString===Object.prototype.toString)for(var a in r)n.call(r,a)&&r[a]&&e.push(a);else e.push(r.toString())}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(r=function(){return o}.apply(t,[]))||(e.exports=r)}()},function(e,t){e.exports=window.lodash},function(e,t){e.exports=window.wp.data},,function(e,t){e.exports=window.React},function(e,t,n){"use strict";function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}n.d(t,"a",(function(){return r}))},,function(e,t){e.exports=window.wp.compose},function(e,t){function n(){return e.exports=n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},e.exports.__esModule=!0,e.exports.default=e.exports,n.apply(this,arguments)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=window.wp.isShallowEqual},function(e,t){e.exports=window.wp.url},function(e,t){e.exports=window.wp.primitives},function(e,t,n){"use strict";var r=n(17),o=n.n(r),c=n(0),i=n(8),a=n(1),l=n(46),s=e=>{let{imageUrl:t=l.l+"/block-error.svg",header:n=Object(a.__)("Oops!","woo-gutenberg-products-block"),text:r=Object(a.__)("There was an error loading the content.","woo-gutenberg-products-block"),errorMessage:o,errorMessagePrefix:i=Object(a.__)("Error:","woo-gutenberg-products-block"),button:s,showErrorBlock:u=!0}=e;return u?Object(c.createElement)("div",{className:"wc-block-error wc-block-components-error"},t&&Object(c.createElement)("img",{className:"wc-block-error__image wc-block-components-error__image",src:t,alt:""}),Object(c.createElement)("div",{className:"wc-block-error__content wc-block-components-error__content"},n&&Object(c.createElement)("p",{className:"wc-block-error__header wc-block-components-error__header"},n),r&&Object(c.createElement)("p",{className:"wc-block-error__text wc-block-components-error__text"},r),o&&Object(c.createElement)("p",{className:"wc-block-error__message wc-block-components-error__message"},i?i+" ":"",o),s&&Object(c.createElement)("p",{className:"wc-block-error__button wc-block-components-error__button"},s))):null};n(35);class u extends i.Component{constructor(){super(...arguments),o()(this,"state",{errorMessage:"",hasError:!1})}static getDerivedStateFromError(e){return void 0!==e.statusText&&void 0!==e.status?{errorMessage:Object(c.createElement)(c.Fragment,null,Object(c.createElement)("strong",null,e.status),": ",e.statusText),hasError:!0}:{errorMessage:e.message,hasError:!0}}render(){const{header:e,imageUrl:t,showErrorMessage:n=!0,showErrorBlock:r=!0,text:o,errorMessagePrefix:i,renderError:a,button:l}=this.props,{errorMessage:u,hasError:d}=this.state;return d?"function"==typeof a?a({errorMessage:u}):Object(c.createElement)(s,{showErrorBlock:r,errorMessage:n?u:null,header:e,imageUrl:t,text:o,errorMessagePrefix:i,button:l}):this.props.children}}t.a=u},function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=window.wc.wcBlocksRegistry},function(e,t,n){"use strict";var r=n(0),o=n(4),c=n.n(o);t.a=e=>{let t,{label:n,screenReaderLabel:o,wrapperElement:i,wrapperProps:a={}}=e;const l=null!=n,s=null!=o;return!l&&s?(t=i||"span",a={...a,className:c()(a.className,"screen-reader-text")},Object(r.createElement)(t,a,o)):(t=i||r.Fragment,l&&s&&n!==o?Object(r.createElement)(t,a,Object(r.createElement)("span",{"aria-hidden":"true"},n),Object(r.createElement)("span",{className:"screen-reader-text"},o)):Object(r.createElement)(t,a,n))}},,function(e,t){e.exports=window.wp.deprecated},,function(e,t){e.exports=window.wp.htmlEntities},function(e,t){e.exports=window.wp.a11y},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(0);const o=Object(r.createContext)("page"),c=()=>Object(r.useContext)(o);o.Provider},function(e,t,n){"use strict";(function(e){var r=n(0);n(39);const o=Object(r.createContext)({slots:{},fills:{},registerSlot:()=>{void 0!==e&&e.env},updateSlot:()=>{},unregisterSlot:()=>{},registerFill:()=>{},unregisterFill:()=>{}});t.a=o}).call(this,n(66))},,,function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(0),o=n(13),c=n.n(o);function i(e){const t=Object(r.useRef)(e);return c()(e,t.current)||(t.current=e),t.current}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));const r=e=>"string"==typeof e},function(e,t,n){"use strict";n.d(t,"a",(function(){return d})),n.d(t,"b",(function(){return p})),n.d(t,"c",(function(){return m}));var r=n(3),o=n(6),c=n(0),i=n(13),a=n.n(i),l=n(29),s=n(62),u=n(25);const d=e=>{const t=Object(u.a)();e=e||t;const n=Object(o.useSelect)(t=>t(r.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0),[e]),{setValueForQueryContext:i}=Object(o.useDispatch)(r.QUERY_STATE_STORE_KEY);return[n,Object(c.useCallback)(t=>{i(e,t)},[e,i])]},p=(e,t,n)=>{const i=Object(u.a)();n=n||i;const a=Object(o.useSelect)(o=>o(r.QUERY_STATE_STORE_KEY).getValueForQueryKey(n,e,t),[n,e]),{setQueryValue:l}=Object(o.useDispatch)(r.QUERY_STATE_STORE_KEY);return[a,Object(c.useCallback)(t=>{l(n,e,t)},[n,e,l])]},m=(e,t)=>{const n=Object(u.a)();t=t||n;const[r,o]=d(t),i=Object(l.a)(r),p=Object(l.a)(e),m=Object(s.a)(p),b=Object(c.useRef)(!1);return Object(c.useEffect)(()=>{a()(m,p)||(o(Object.assign({},i,p)),b.current=!0)},[i,p,m,o]),b.current?[r,o]:[e,o]}},,function(e,t){e.exports=window.wp.apiFetch},,function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(0);n(6);const o=Object(r.createContext)({isEditor:!1,currentPostId:0,currentView:"",previewData:{},getPreviewData:()=>{}}),c=()=>Object(r.useContext)(o)},function(e,t,n){"use strict";var r=n(4),o=n.n(r),c=n(0);t.a=Object(c.forwardRef)((function({as:e="div",className:t,...n},r){return function({as:e="div",...t}){return"function"==typeof t.children?t.children(t):Object(c.createElement)(e,t)}({as:e,className:o()("components-visually-hidden",t),...n,ref:r})}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return O}));var r=n(5),o=n(0),c=n(3),i=n(6),a=n(23),l=n(132),s=n(36),u=n(91);const d=e=>{const t=e.detail;t&&t.preserveCartData||Object(i.dispatch)(c.CART_STORE_KEY).invalidateResolutionForStore()},p=()=>{1===window.wcBlocksStoreCartListeners.count&&window.wcBlocksStoreCartListeners.remove(),window.wcBlocksStoreCartListeners.count--},m=()=>{Object(o.useEffect)(()=>((()=>{if(window.wcBlocksStoreCartListeners||(window.wcBlocksStoreCartListeners={count:0,remove:()=>{}}),0===window.wcBlocksStoreCartListeners.count){const e=Object(u.b)("added_to_cart","wc-blocks_added_to_cart"),t=Object(u.b)("removed_from_cart","wc-blocks_removed_from_cart");document.body.addEventListener("wc-blocks_added_to_cart",d),document.body.addEventListener("wc-blocks_removed_from_cart",d),window.wcBlocksStoreCartListeners.count=0,window.wcBlocksStoreCartListeners.remove=()=>{e(),t(),document.body.removeEventListener("wc-blocks_added_to_cart",d),document.body.removeEventListener("wc-blocks_removed_from_cart",d)}}window.wcBlocksStoreCartListeners.count++})(),p),[])},b={first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:""},f={...b,email:""},g={total_items:"",total_items_tax:"",total_fees:"",total_fees_tax:"",total_discount:"",total_discount_tax:"",total_shipping:"",total_shipping_tax:"",total_price:"",total_tax:"",tax_lines:c.EMPTY_TAX_LINES,currency_code:"",currency_symbol:"",currency_minor_unit:2,currency_decimal_separator:"",currency_thousand_separator:"",currency_prefix:"",currency_suffix:""},h=e=>Object.fromEntries(Object.entries(e).map(e=>{let[t,n]=e;return[t,Object(a.decodeEntities)(n)]})),E={cartCoupons:c.EMPTY_CART_COUPONS,cartItems:c.EMPTY_CART_ITEMS,cartFees:c.EMPTY_CART_FEES,cartItemsCount:0,cartItemsWeight:0,crossSellsProducts:c.EMPTY_CART_CROSS_SELLS,cartNeedsPayment:!0,cartNeedsShipping:!0,cartItemErrors:c.EMPTY_CART_ITEM_ERRORS,cartTotals:g,cartIsLoading:!0,cartErrors:c.EMPTY_CART_ERRORS,billingAddress:f,shippingAddress:b,shippingRates:c.EMPTY_SHIPPING_RATES,isLoadingRates:!1,cartHasCalculatedShipping:!1,paymentRequirements:c.EMPTY_PAYMENT_REQUIREMENTS,receiveCart:()=>{},extensions:c.EMPTY_EXTENSIONS},O=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{shouldSelect:!0};const{isEditor:t,previewData:n}=Object(s.a)(),a=null==n?void 0:n.previewCart,{shouldSelect:u}=e,d=Object(o.useRef)();m();const p=Object(i.useSelect)((e,n)=>{let{dispatch:r}=n;if(!u)return E;if(t)return{cartCoupons:a.coupons,cartItems:a.items,crossSellsProducts:a.cross_sells,cartFees:a.fees,cartItemsCount:a.items_count,cartItemsWeight:a.items_weight,cartNeedsPayment:a.needs_payment,cartNeedsShipping:a.needs_shipping,cartItemErrors:c.EMPTY_CART_ITEM_ERRORS,cartTotals:a.totals,cartIsLoading:!1,cartErrors:c.EMPTY_CART_ERRORS,billingData:f,billingAddress:f,shippingAddress:b,extensions:c.EMPTY_EXTENSIONS,shippingRates:a.shipping_rates,isLoadingRates:!1,cartHasCalculatedShipping:a.has_calculated_shipping,paymentRequirements:a.paymentRequirements,receiveCart:"function"==typeof(null==a?void 0:a.receiveCart)?a.receiveCart:()=>{}};const o=e(c.CART_STORE_KEY),i=o.getCartData(),s=o.getCartErrors(),d=o.getCartTotals(),p=!o.hasFinishedResolution("getCartData"),m=o.isCustomerDataUpdating(),{receiveCart:g}=r(c.CART_STORE_KEY),O=h(i.billingAddress),w=i.needsShipping?h(i.shippingAddress):O,y=i.fees.length>0?i.fees.map(e=>h(e)):c.EMPTY_CART_FEES;return{cartCoupons:i.coupons.length>0?i.coupons.map(e=>({...e,label:e.code})):c.EMPTY_CART_COUPONS,cartItems:i.items,crossSellsProducts:i.crossSells,cartFees:y,cartItemsCount:i.itemsCount,cartItemsWeight:i.itemsWeight,cartNeedsPayment:i.needsPayment,cartNeedsShipping:i.needsShipping,cartItemErrors:i.errors,cartTotals:d,cartIsLoading:p,cartErrors:s,billingData:Object(l.a)(O),billingAddress:Object(l.a)(O),shippingAddress:Object(l.a)(w),extensions:i.extensions,shippingRates:i.shippingRates,isLoadingRates:m,cartHasCalculatedShipping:i.hasCalculatedShipping,paymentRequirements:i.paymentRequirements,receiveCart:g}},[u]);return d.current&&Object(r.isEqual)(d.current,p)||(d.current=p),d.current}},function(e,t){e.exports=window.wp.warning},function(e,t){e.exports=window.wc.priceFormat},function(e,t,n){"use strict";var r=n(9),o=n(0),c=n(15),i=function({icon:e,className:t,...n}){const c=["dashicon","dashicons","dashicons-"+e,t].filter(Boolean).join(" ");return Object(o.createElement)("span",Object(r.a)({className:c},n))};t.a=function({icon:e=null,size:t=24,...n}){if("string"==typeof e)return Object(o.createElement)(i,Object(r.a)({icon:e},n));if(Object(o.isValidElement)(e)&&i===e.type)return Object(o.cloneElement)(e,{...n});if("function"==typeof e)return e.prototype instanceof o.Component?Object(o.createElement)(e,{size:t,...n}):e({size:t,...n});if(e&&("svg"===e.type||e.type===c.SVG)){const r={width:t,height:t,...e.props,...n};return Object(o.createElement)(c.SVG,r)}return Object(o.isValidElement)(e)?Object(o.cloneElement)(e,{size:t,...n}):e}},,,function(e,t,n){"use strict";var r=n(9),o=n(0),c=n(4),i=n.n(c),a=n(5),l=n(21),s=n.n(l),u=n(11),d=n(47),p=n(92),m=n(1);function b(e,t,n){const{defaultView:r}=t,{frameElement:o}=r;if(!o||t===n.ownerDocument)return e;const c=o.getBoundingClientRect();return new r.DOMRect(e.left+c.left,e.top+c.top,e.width,e.height)}let f=0;function g(e){const t=document.scrollingElement||document.body;e&&(f=t.scrollTop);const n=e?"add":"remove";t.classList[n]("lockscroll"),document.documentElement.classList[n]("lockscroll"),e||(t.scrollTop=f)}let h=0;function E(){return Object(o.useEffect)(()=>(0===h&&g(!0),++h,()=>{1===h&&g(!1),--h}),[]),null}var O=n(26);function w(e){const t=Object(o.useContext)(O.a),n=t.slots[e]||{},r=t.fills[e],c=Object(o.useMemo)(()=>r||[],[r]);return{...n,updateSlot:Object(o.useCallback)(n=>{t.updateSlot(e,n)},[e,t.updateSlot]),unregisterSlot:Object(o.useCallback)(n=>{t.unregisterSlot(e,n)},[e,t.unregisterSlot]),fills:c,registerFill:Object(o.useCallback)(n=>{t.registerFill(e,n)},[e,t.registerFill]),unregisterFill:Object(o.useCallback)(n=>{t.unregisterFill(e,n)},[e,t.unregisterFill])}}var y=Object(o.createContext)({registerSlot:()=>{},unregisterSlot:()=>{},registerFill:()=>{},unregisterFill:()=>{},getSlot:()=>{},getFills:()=>{},subscribe:()=>{}});function v({name:e,children:t,registerFill:n,unregisterFill:r}){const c=(e=>{const{getSlot:t,subscribe:n}=Object(o.useContext)(y),[r,c]=Object(o.useState)(t(e));return Object(o.useEffect)(()=>(c(t(e)),n(()=>{c(t(e))})),[e]),r})(e),i=Object(o.useRef)({name:e,children:t});return Object(o.useLayoutEffect)(()=>(n(e,i.current),()=>r(e,i.current)),[]),Object(o.useLayoutEffect)(()=>{i.current.children=t,c&&c.forceUpdate()},[t]),Object(o.useLayoutEffect)(()=>{e!==i.current.name&&(r(i.current.name,i.current),i.current.name=e,n(e,i.current))},[e]),c&&c.node?(Object(a.isFunction)(t)&&(t=t(c.props.fillProps)),Object(o.createPortal)(t,c.node)):null}var j=e=>Object(o.createElement)(y.Consumer,null,({registerFill:t,unregisterFill:n})=>Object(o.createElement)(v,Object(r.a)({},e,{registerFill:t,unregisterFill:n})));class _ extends o.Component{constructor(){super(...arguments),this.isUnmounted=!1,this.bindNode=this.bindNode.bind(this)}componentDidMount(){const{registerSlot:e}=this.props;e(this.props.name,this)}componentWillUnmount(){const{unregisterSlot:e}=this.props;this.isUnmounted=!0,e(this.props.name,this)}componentDidUpdate(e){const{name:t,unregisterSlot:n,registerSlot:r}=this.props;e.name!==t&&(n(e.name),r(t,this))}bindNode(e){this.node=e}forceUpdate(){this.isUnmounted||super.forceUpdate()}render(){const{children:e,name:t,fillProps:n={},getFills:r}=this.props,c=Object(a.map)(r(t,this),e=>{const t=Object(a.isFunction)(e.children)?e.children(n):e.children;return o.Children.map(t,(e,t)=>{if(!e||Object(a.isString)(e))return e;const n=e.key||t;return Object(o.cloneElement)(e,{key:n})})}).filter(Object(a.negate)(o.isEmptyElement));return Object(o.createElement)(o.Fragment,null,Object(a.isFunction)(e)?e(c):c)}}var x=e=>Object(o.createElement)(y.Consumer,null,({registerSlot:t,unregisterSlot:n,getFills:c})=>Object(o.createElement)(_,Object(r.a)({},e,{registerSlot:t,unregisterSlot:n,getFills:c})));function k(){const[,e]=Object(o.useState)({}),t=Object(o.useRef)(!0);return Object(o.useEffect)(()=>()=>{t.current=!1},[]),()=>{t.current&&e({})}}function S({name:e,children:t}){const n=w(e),r=Object(o.useRef)({rerender:k()});return Object(o.useEffect)(()=>(n.registerFill(r),()=>{n.unregisterFill(r)}),[n.registerFill,n.unregisterFill]),n.ref&&n.ref.current?("function"==typeof t&&(t=t(n.fillProps)),Object(o.createPortal)(t,n.ref.current)):null}var T=Object(o.forwardRef)((function({name:e,fillProps:t={},as:n="div",...c},i){const a=Object(o.useContext)(O.a),l=Object(o.useRef)();return Object(o.useLayoutEffect)(()=>(a.registerSlot(e,l,t),()=>{a.unregisterSlot(e,l)}),[a.registerSlot,a.unregisterSlot,e]),Object(o.useLayoutEffect)(()=>{a.updateSlot(e,t)}),Object(o.createElement)(n,Object(r.a)({ref:Object(u.useMergeRefs)([i,l])},c))}));function N(e){return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(j,e),Object(o.createElement)(S,e))}n(13),o.Component;const C=Object(o.forwardRef)(({bubblesVirtually:e,...t},n)=>e?Object(o.createElement)(T,Object(r.a)({},t,{ref:n})):Object(o.createElement)(x,t));function R(e){return"appear"===e?"top":"left"}function A(e,t){const{paddingTop:n,paddingBottom:r,paddingLeft:o,paddingRight:c}=(i=t).ownerDocument.defaultView.getComputedStyle(i);var i;const a=n?parseInt(n,10):0,l=r?parseInt(r,10):0,s=o?parseInt(o,10):0,u=c?parseInt(c,10):0;return{x:e.left+s,y:e.top+a,width:e.width-s-u,height:e.height-a-l,left:e.left+s,right:e.right-u,top:e.top+a,bottom:e.bottom-l}}function L(e,t,n){n?e.getAttribute(t)!==n&&e.setAttribute(t,n):e.hasAttribute(t)&&e.removeAttribute(t)}function P(e,t,n=""){e.style[t]!==n&&(e.style[t]=n)}function M(e,t,n){n?e.classList.contains(t)||e.classList.add(t):e.classList.contains(t)&&e.classList.remove(t)}const D=Object(o.forwardRef)(({headerTitle:e,onClose:t,children:n,className:c,noArrow:a=!0,isAlternate:l,position:f="bottom right",range:g,focusOnMount:h="firstElement",anchorRef:O,shouldAnchorIncludePadding:y,anchorRect:v,getAnchorRect:j,expandOnMobile:_,animate:x=!0,onClickOutside:k,onFocusOutside:S,__unstableStickyBoundaryElement:T,__unstableSlotName:C="Popover",__unstableObserveElement:D,__unstableBoundaryParent:F,__unstableForcePosition:B,__unstableForceXAlignment:I,...H},z)=>{const U=Object(o.useRef)(null),W=Object(o.useRef)(null),G=Object(o.useRef)(),Y=Object(u.useViewportMatch)("medium","<"),[V,Q]=Object(o.useState)(),K=w(C),X=_&&Y,[$,J]=Object(u.useResizeObserver)();a=X||a,Object(o.useLayoutEffect)(()=>{if(X)return M(G.current,"is-without-arrow",a),M(G.current,"is-alternate",l),L(G.current,"data-x-axis"),L(G.current,"data-y-axis"),P(G.current,"top"),P(G.current,"left"),P(W.current,"maxHeight"),void P(W.current,"maxWidth");const e=()=>{if(!G.current||!W.current)return;let e=function(e,t,n,r=!1,o,c){if(t)return t;if(n){if(!e.current)return;const t=n(e.current);return b(t,t.ownerDocument||e.current.ownerDocument,c)}if(!1!==r){if(!(r&&window.Range&&window.Element&&window.DOMRect))return;if("function"==typeof(null==r?void 0:r.cloneRange))return b(Object(d.getRectangleFromRange)(r),r.endContainer.ownerDocument,c);if("function"==typeof(null==r?void 0:r.getBoundingClientRect)){const e=b(r.getBoundingClientRect(),r.ownerDocument,c);return o?e:A(e,r)}const{top:e,bottom:t}=r,n=e.getBoundingClientRect(),i=t.getBoundingClientRect(),a=b(new window.DOMRect(n.left,n.top,n.width,i.bottom-n.top),e.ownerDocument,c);return o?a:A(a,r)}if(!e.current)return;const{parentNode:i}=e.current,a=i.getBoundingClientRect();return o?a:A(a,i)}(U,v,j,O,y,G.current);if(!e)return;const{offsetParent:t,ownerDocument:n}=G.current;let r,o=0;if(t&&t!==n.body){const n=t.getBoundingClientRect();o=n.top,e=new window.DOMRect(e.left-n.left,e.top-n.top,e.width,e.height)}var c;F&&(r=null===(c=G.current.closest(".popover-slot"))||void 0===c?void 0:c.parentNode);const i=J.height?J:W.current.getBoundingClientRect(),{popoverTop:s,popoverLeft:u,xAxis:p,yAxis:g,contentHeight:h,contentWidth:E}=function(e,t,n="top",r,o,c,i,a,l){const[s,u="center",d]=n.split(" "),p=function(e,t,n,r,o,c,i,a){const{height:l}=t;if(o){const t=o.getBoundingClientRect().top+l-i;if(e.top<=t)return{yAxis:n,popoverTop:Math.min(e.bottom,t)}}let s=e.top+e.height/2;"bottom"===r?s=e.bottom:"top"===r&&(s=e.top);const u={popoverTop:s,contentHeight:(s-l/2>0?l/2:s)+(s+l/2>window.innerHeight?window.innerHeight-s:l/2)},d={popoverTop:e.top,contentHeight:e.top-10-l>0?l:e.top-10},p={popoverTop:e.bottom,contentHeight:e.bottom+10+l>window.innerHeight?window.innerHeight-10-e.bottom:l};let m,b=n,f=null;if(!o&&!a)if("middle"===n&&u.contentHeight===l)b="middle";else if("top"===n&&d.contentHeight===l)b="top";else if("bottom"===n&&p.contentHeight===l)b="bottom";else{b=d.contentHeight>p.contentHeight?"top":"bottom";const e="top"===b?d.contentHeight:p.contentHeight;f=e!==l?e:null}return m="middle"===b?u.popoverTop:"top"===b?d.popoverTop:p.popoverTop,{yAxis:b,popoverTop:m,contentHeight:f}}(e,t,s,d,r,0,c,a);return{...function(e,t,n,r,o,c,i,a,l){const{width:s}=t;"left"===n&&Object(m.isRTL)()?n="right":"right"===n&&Object(m.isRTL)()&&(n="left"),"left"===r&&Object(m.isRTL)()?r="right":"right"===r&&Object(m.isRTL)()&&(r="left");const u=Math.round(e.left+e.width/2),d={popoverLeft:u,contentWidth:(u-s/2>0?s/2:u)+(u+s/2>window.innerWidth?window.innerWidth-u:s/2)};let p=e.left;"right"===r?p=e.right:"middle"===c||l||(p=u);let b=e.right;"left"===r?b=e.left:"middle"===c||l||(b=u);const f={popoverLeft:p,contentWidth:p-s>0?s:p},g={popoverLeft:b,contentWidth:b+s>window.innerWidth?window.innerWidth-b:s};let h,E=n,O=null;if(!o&&!a)if("center"===n&&d.contentWidth===s)E="center";else if("left"===n&&f.contentWidth===s)E="left";else if("right"===n&&g.contentWidth===s)E="right";else{E=f.contentWidth>g.contentWidth?"left":"right";const e="left"===E?f.contentWidth:g.contentWidth;s>window.innerWidth&&(O=window.innerWidth),e!==s&&(E="center",d.popoverLeft=window.innerWidth/2)}if(h="center"===E?d.popoverLeft:"left"===E?f.popoverLeft:g.popoverLeft,i){const e=i.getBoundingClientRect();h=Math.min(h,e.right-s),Object(m.isRTL)()||(h=Math.max(h,0))}return{xAxis:E,popoverLeft:h,contentWidth:O}}(e,t,u,d,r,p.yAxis,i,a,l),...p}}(e,i,f,T,G.current,o,r,B,I);"number"==typeof s&&"number"==typeof u&&(P(G.current,"top",s+"px"),P(G.current,"left",u+"px")),M(G.current,"is-without-arrow",a||"center"===p&&"middle"===g),M(G.current,"is-alternate",l),L(G.current,"data-x-axis",p),L(G.current,"data-y-axis",g),P(W.current,"maxHeight","number"==typeof h?h+"px":""),P(W.current,"maxWidth","number"==typeof E?E+"px":""),Q(({left:"right",right:"left"}[p]||"center")+" "+({top:"bottom",bottom:"top"}[g]||"middle"))};e();const{ownerDocument:t}=G.current,{defaultView:n}=t,r=n.setInterval(e,500);let o;const c=()=>{n.cancelAnimationFrame(o),o=n.requestAnimationFrame(e)};n.addEventListener("click",c),n.addEventListener("resize",e),n.addEventListener("scroll",e,!0);const i=function(e){if(e)return e.endContainer?e.endContainer.ownerDocument:e.top?e.top.ownerDocument:e.ownerDocument}(O);let s;return i&&i!==t&&(i.defaultView.addEventListener("resize",e),i.defaultView.addEventListener("scroll",e,!0)),D&&(s=new n.MutationObserver(e),s.observe(D,{attributes:!0})),()=>{n.clearInterval(r),n.removeEventListener("resize",e),n.removeEventListener("scroll",e,!0),n.removeEventListener("click",c),n.cancelAnimationFrame(o),i&&i!==t&&(i.defaultView.removeEventListener("resize",e),i.defaultView.removeEventListener("scroll",e,!0)),s&&s.disconnect()}},[X,v,j,O,y,f,J,T,D,F]);const Z=(e,n)=>{if("focus-outside"===e&&S)S(n);else if("focus-outside"===e&&k){const e=new window.MouseEvent("click");Object.defineProperty(e,"target",{get:()=>n.relatedTarget}),s()("Popover onClickOutside prop",{since:"5.3",alternative:"onFocusOutside"}),k(e)}else t&&t()},[ee,te]=Object(u.__experimentalUseDialog)({focusOnMount:h,__unstableOnClose:Z,onClose:Z}),ne=Object(u.useMergeRefs)([G,ee,z]),re=Boolean(x&&V)&&function(e){if("loading"===e.type)return i()("components-animate__loading");const{type:t,origin:n=R(t)}=e;if("appear"===t){const[e,t="center"]=n.split(" ");return i()("components-animate__appear",{["is-from-"+t]:"center"!==t,["is-from-"+e]:"middle"!==e})}return"slide-in"===t?i()("components-animate__slide-in","is-from-"+n):void 0}({type:"appear",origin:V});let oe=Object(o.createElement)("div",Object(r.a)({className:i()("components-popover",c,re,{"is-expanded":X,"is-without-arrow":a,"is-alternate":l})},H,{ref:ne},te,{tabIndex:"-1"}),X&&Object(o.createElement)(E,null),X&&Object(o.createElement)("div",{className:"components-popover__header"},Object(o.createElement)("span",{className:"components-popover__header-title"},e),Object(o.createElement)(q,{className:"components-popover__close",icon:p.a,onClick:t})),Object(o.createElement)("div",{ref:W,className:"components-popover__content"},Object(o.createElement)("div",{style:{position:"relative"}},$,n)));return K.ref&&(oe=Object(o.createElement)(N,{name:C},oe)),O||v?oe:Object(o.createElement)("span",{ref:U},oe)});D.Slot=Object(o.forwardRef)((function({name:e="Popover"},t){return Object(o.createElement)(C,{bubblesVirtually:!0,name:e,className:"popover-slot",ref:t})}));var F=D,B=function({shortcut:e,className:t}){if(!e)return null;let n,r;return Object(a.isString)(e)&&(n=e),Object(a.isObject)(e)&&(n=e.display,r=e.ariaLabel),Object(o.createElement)("span",{className:t,"aria-label":r},n)};const I=Object(o.createElement)("div",{className:"event-catcher"}),H=({eventHandlers:e,child:t,childrenWithPopover:n})=>Object(o.cloneElement)(Object(o.createElement)("span",{className:"disabled-element-wrapper"},Object(o.cloneElement)(I,e),Object(o.cloneElement)(t,{children:n}),","),e),z=({child:e,eventHandlers:t,childrenWithPopover:n})=>Object(o.cloneElement)(e,{...t,children:n}),U=(e,t,n)=>{if(1!==o.Children.count(e))return;const r=o.Children.only(e);"function"==typeof r.props[t]&&r.props[t](n)};var W=function({children:e,position:t,text:n,shortcut:r}){const[c,i]=Object(o.useState)(!1),[l,s]=Object(o.useState)(!1),d=Object(u.useDebounce)(s,700),p=t=>{U(e,"onMouseDown",t),document.addEventListener("mouseup",f),i(!0)},m=t=>{U(e,"onMouseUp",t),document.removeEventListener("mouseup",f),i(!1)},b=e=>"mouseUp"===e?m:"mouseDown"===e?p:void 0,f=b("mouseUp"),g=(t,n)=>r=>{if(U(e,t,r),r.currentTarget.disabled)return;if("focus"===r.type&&c)return;d.cancel();const o=Object(a.includes)(["focus","mouseenter"],r.type);o!==l&&(n?d(o):s(o))},h=()=>{d.cancel(),document.removeEventListener("mouseup",f)};if(Object(o.useEffect)(()=>h,[]),1!==o.Children.count(e))return e;const E={onMouseEnter:g("onMouseEnter",!0),onMouseLeave:g("onMouseLeave"),onClick:g("onClick"),onFocus:g("onFocus"),onBlur:g("onBlur"),onMouseDown:b("mouseDown")},O=o.Children.only(e),{children:w,disabled:y}=O.props;return(y?H:z)({child:O,eventHandlers:E,childrenWithPopover:(({grandchildren:e,isOver:t,position:n,text:r,shortcut:c})=>Object(o.concatChildren)(e,t&&Object(o.createElement)(F,{focusOnMount:!1,position:n,className:"components-tooltip","aria-hidden":"true",animate:!1,noArrow:!0},r,Object(o.createElement)(B,{className:"components-tooltip__shortcut",shortcut:c}))))({grandchildren:w,isOver:l,position:t,text:n,shortcut:r})})},G=n(41),Y=n(37);const V=["onMouseDown","onClick"];var q=t.a=Object(o.forwardRef)((function(e,t){const{href:n,target:c,isSmall:l,isPressed:u,isBusy:d,isDestructive:p,className:m,disabled:b,icon:f,iconPosition:g="left",iconSize:h,showTooltip:E,tooltipPosition:O,shortcut:w,label:y,children:v,text:j,variant:_,__experimentalIsFocusable:x,describedBy:k,...S}=function({isDefault:e,isPrimary:t,isSecondary:n,isTertiary:r,isLink:o,variant:c,...i}){let a=c;var l,u,d,p,m;return t&&(null!==(l=a)&&void 0!==l||(a="primary")),r&&(null!==(u=a)&&void 0!==u||(a="tertiary")),n&&(null!==(d=a)&&void 0!==d||(a="secondary")),e&&(s()("Button isDefault prop",{since:"5.4",alternative:'variant="secondary"'}),null!==(p=a)&&void 0!==p||(a="secondary")),o&&(null!==(m=a)&&void 0!==m||(a="link")),{...i,variant:a}}(e),T=i()("components-button",m,{"is-secondary":"secondary"===_,"is-primary":"primary"===_,"is-small":l,"is-tertiary":"tertiary"===_,"is-pressed":u,"is-busy":d,"is-link":"link"===_,"is-destructive":p,"has-text":!!f&&!!v,"has-icon":!!f}),N=b&&!x,C=void 0===n||N?"button":"a",R="a"===C?{href:n,target:c}:{type:"button",disabled:N,"aria-pressed":u};if(b&&x){R["aria-disabled"]=!0;for(const e of V)S[e]=e=>{e.stopPropagation(),e.preventDefault()}}const A=!N&&(E&&y||w||!!y&&(!v||Object(a.isArray)(v)&&!v.length)&&!1!==E),L=k?Object(a.uniqueId)():null,P=S["aria-describedby"]||L,M=Object(o.createElement)(C,Object(r.a)({},R,S,{className:T,"aria-label":S["aria-label"]||y,"aria-describedby":P,ref:t}),f&&"left"===g&&Object(o.createElement)(G.a,{icon:f,size:h}),j&&Object(o.createElement)(o.Fragment,null,j),f&&"right"===g&&Object(o.createElement)(G.a,{icon:f,size:h}),v);return A?Object(o.createElement)(o.Fragment,null,Object(o.createElement)(W,{text:k||y,shortcut:w,position:O},M),k&&Object(o.createElement)(Y.a,null,Object(o.createElement)("span",{id:L},k))):Object(o.createElement)(o.Fragment,null,M,k&&Object(o.createElement)(Y.a,null,Object(o.createElement)("span",{id:L},k)))}))},,function(e,t,n){"use strict";n.d(t,"n",(function(){return c})),n.d(t,"l",(function(){return i})),n.d(t,"k",(function(){return a})),n.d(t,"m",(function(){return l})),n.d(t,"i",(function(){return s})),n.d(t,"d",(function(){return u})),n.d(t,"f",(function(){return d})),n.d(t,"j",(function(){return p})),n.d(t,"c",(function(){return m})),n.d(t,"e",(function(){return b})),n.d(t,"g",(function(){return f})),n.d(t,"a",(function(){return g})),n.d(t,"h",(function(){return h})),n.d(t,"b",(function(){return E}));var r,o=n(2);const c=Object(o.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),i=c.pluginUrl+"images/",a=c.pluginUrl+"build/",l=c.buildPhase,s=null===(r=o.STORE_PAGES.shop)||void 0===r?void 0:r.permalink,u=(o.STORE_PAGES.checkout.id,o.STORE_PAGES.checkout.permalink),d=o.STORE_PAGES.privacy.permalink,p=(o.STORE_PAGES.privacy.title,o.STORE_PAGES.terms.permalink),m=(o.STORE_PAGES.terms.title,o.STORE_PAGES.cart.id,o.STORE_PAGES.cart.permalink),b=o.STORE_PAGES.myaccount.permalink?o.STORE_PAGES.myaccount.permalink:Object(o.getSetting)("wpLoginUrl","/wp-login.php"),f=Object(o.getSetting)("shippingCountries",{}),g=Object(o.getSetting)("allowedCountries",{}),h=Object(o.getSetting)("shippingStates",{}),E=Object(o.getSetting)("allowedStates",{})},function(e,t){e.exports=window.wp.dom},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(12),o=n.n(r),c=n(0),i=n(16);const a=[".wp-block-woocommerce-cart"],l=e=>{let{Block:t,containers:n,getProps:r=(()=>({})),getErrorBoundaryProps:a=(()=>({}))}=e;0!==n.length&&Array.prototype.forEach.call(n,(e,n)=>{const l=r(e,n),s=a(e,n),u={...e.dataset,...l.attributes||{}};(e=>{let{Block:t,container:n,attributes:r={},props:a={},errorBoundaryProps:l={}}=e;Object(c.render)(Object(c.createElement)(i.a,l,Object(c.createElement)(c.Suspense,{fallback:Object(c.createElement)("div",{className:"wc-block-placeholder"})},t&&Object(c.createElement)(t,o()({},a,{attributes:r})))),n,()=>{n.classList&&n.classList.remove("is-loading")})})({Block:t,container:e,props:l,attributes:u,errorBoundaryProps:s})})},s=e=>{const t=document.body.querySelectorAll(a.join(",")),{Block:n,getProps:r,getErrorBoundaryProps:o,selector:c}=e;(e=>{let{Block:t,getProps:n,getErrorBoundaryProps:r,selector:o,wrappers:c}=e;const i=document.body.querySelectorAll(o);c&&c.length>0&&Array.prototype.filter.call(i,e=>!((e,t)=>Array.prototype.some.call(t,t=>t.contains(e)&&!t.isSameNode(e)))(e,c)),l({Block:t,containers:i,getProps:n,getErrorBoundaryProps:r})})({Block:n,getProps:r,getErrorBoundaryProps:o,selector:c,wrappers:t}),Array.prototype.forEach.call(t,t=>{t.addEventListener("wc-blocks_render_blocks_frontend",()=>{(e=>{let{Block:t,getProps:n,getErrorBoundaryProps:r,selector:o,wrapper:c}=e;const i=c.querySelectorAll(o);l({Block:t,containers:i,getProps:n,getErrorBoundaryProps:r})})({...e,wrapper:t})})})}},function(e,t){e.exports=window.wp.hooks},function(e,t){e.exports=window.wc.wcBlocksSharedContext},,,,,,,function(e,t,n){"use strict";var r=n(2),o=n(1),c=n(94),i=n(30);const a=Object(r.getSetting)("countryLocale",{}),l=e=>{const t={};return void 0!==e.label&&(t.label=e.label),void 0!==e.required&&(t.required=e.required),void 0!==e.hidden&&(t.hidden=e.hidden),void 0===e.label||e.optionalLabel||(t.optionalLabel=Object(o.sprintf)(
|
2 |
-
/* translators: %s Field label. */
|
3 |
-
Object(o.__)("%s (optional)","woo-gutenberg-products-block"),e.label)),e.priority&&(Object(c.a)(e.priority)&&(t.index=e.priority),Object(i.a)(e.priority)&&(t.index=parseInt(e.priority,10))),e.hidden&&(t.required=!1),t},s=Object.entries(a).map(e=>{let[t,n]=e;return[t,Object.entries(n).map(e=>{let[t,n]=e;return[t,l(n)]}).reduce((e,t)=>{let[n,r]=t;return e[n]=r,e},{})]}).reduce((e,t)=>{let[n,r]=t;return e[n]=r,e},{});t.a=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";const o=n&&void 0!==s[n]?s[n]:{};return e.map(e=>({key:e,...r.defaultAddressFields[e]||{},...o[e]||{},...t[e]||{}})).sort((e,t)=>e.index-t.index)}},,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(3),o=n(6),c=n(0),i=n(29),a=n(76);const l=e=>{const{namespace:t,resourceName:n,resourceValues:l=[],query:s={},shouldSelect:u=!0}=e;if(!t||!n)throw new Error("The options object must have valid values for the namespace and the resource properties.");const d=Object(c.useRef)({results:[],isLoading:!0}),p=Object(i.a)(s),m=Object(i.a)(l),b=Object(a.a)(),f=Object(o.useSelect)(e=>{if(!u)return null;const o=e(r.COLLECTIONS_STORE_KEY),c=[t,n,p,m],i=o.getCollectionError(...c);if(i){if(!(i instanceof Error))throw new Error("TypeError: `error` object is not an instance of Error constructor");b(i)}return{results:o.getCollection(...c),isLoading:!o.hasFinishedResolution("getCollection",c)}},[t,n,m,p,u]);return null!==f&&(d.current=f),d.current}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(8);function o(e,t){const n=Object(r.useRef)();return Object(r.useEffect)(()=>{n.current===e||t&&!t(e,n.current)||(n.current=e)},[e,t]),n.current}},,,,function(e,t){var n,r,o=e.exports={};function c(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===c||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:c}catch(e){n=c}try{r="function"==typeof clearTimeout?clearTimeout:i}catch(e){r=i}}();var l,s=[],u=!1,d=-1;function p(){u&&l&&(u=!1,l.length?s=l.concat(s):d=-1,s.length&&m())}function m(){if(!u){var e=a(p);u=!0;for(var t=s.length;t;){for(l=s,s=[];++d<t;)l&&l[d].run();d=-1,t=s.length}l=null,u=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===i||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function b(e,t){this.fun=e,this.array=t}function f(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];s.push(new b(e,t)),1!==s.length||u||a(m)},b.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=f,o.addListener=f,o.once=f,o.off=f,o.removeListener=f,o.removeAllListeners=f,o.emit=f,o.prependListener=f,o.prependOnceListener=f,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(49),o=n(0),c=n(38);const i=()=>{const e=Object(c.a)(),t=Object(o.useRef)(e);return Object(o.useEffect)(()=>{t.current=e},[e]),{dispatchStoreEvent:Object(o.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(r.doAction)("experimental__woocommerce_blocks-"+e,t)}catch(e){console.error(e)}}),[]),dispatchCheckoutEvent:Object(o.useCallback)((function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(r.doAction)("experimental__woocommerce_blocks-checkout-"+e,{...n,storeCart:t.current})}catch(e){console.error(e)}}),[])}}},,function(e,t,n){e.exports=function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,n){return(t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,n)}function n(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function r(e,o,c){return(r=n()?Reflect.construct:function(e,n,r){var o=[null];o.push.apply(o,n);var c=new(Function.bind.apply(e,o));return r&&t(c,r.prototype),c}).apply(null,arguments)}function o(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return c(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(e,void 0):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var i=Object.hasOwnProperty,a=Object.setPrototypeOf,l=Object.isFrozen,s=Object.getPrototypeOf,u=Object.getOwnPropertyDescriptor,d=Object.freeze,p=Object.seal,m=Object.create,b="undefined"!=typeof Reflect&&Reflect,f=b.apply,g=b.construct;f||(f=function(e,t,n){return e.apply(t,n)}),d||(d=function(e){return e}),p||(p=function(e){return e}),g||(g=function(e,t){return r(e,o(t))});var h,E=T(Array.prototype.forEach),O=T(Array.prototype.pop),w=T(Array.prototype.push),y=T(String.prototype.toLowerCase),v=T(String.prototype.match),j=T(String.prototype.replace),_=T(String.prototype.indexOf),x=T(String.prototype.trim),k=T(RegExp.prototype.test),S=(h=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return g(h,t)});function T(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return f(e,t,r)}}function N(e,t,n){n=n||y,a&&a(e,null);for(var r=t.length;r--;){var o=t[r];if("string"==typeof o){var c=n(o);c!==o&&(l(t)||(t[r]=c),o=c)}e[o]=!0}return e}function C(e){var t,n=m(null);for(t in e)f(i,e,[t])&&(n[t]=e[t]);return n}function R(e,t){for(;null!==e;){var n=u(e,t);if(n){if(n.get)return T(n.get);if("function"==typeof n.value)return T(n.value)}e=s(e)}return function(e){return console.warn("fallback value for",e),null}}var A=d(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),L=d(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),P=d(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),M=d(["animate","color-profile","cursor","discard","fedropshadow","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),D=d(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"]),F=d(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),B=d(["#text"]),I=d(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),H=d(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),z=d(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),U=d(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),W=p(/\{\{[\w\W]*|[\w\W]*\}\}/gm),G=p(/<%[\w\W]*|[\w\W]*%>/gm),Y=p(/^data-[\-\w.\u00B7-\uFFFF]/),V=p(/^aria-[\-\w]+$/),q=p(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Q=p(/^(?:\w+script|data):/i),K=p(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),X=p(/^html$/i),$=function(){return"undefined"==typeof window?null:window},J=function(t,n){if("object"!==e(t)||"function"!=typeof t.createPolicy)return null;var r=null;n.currentScript&&n.currentScript.hasAttribute("data-tt-policy-suffix")&&(r=n.currentScript.getAttribute("data-tt-policy-suffix"));var o="dompurify"+(r?"#"+r:"");try{return t.createPolicy(o,{createHTML:function(e){return e},createScriptURL:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+o+" could not be created."),null}};return function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:$(),r=function(e){return t(e)};if(r.version="2.4.0",r.removed=[],!n||!n.document||9!==n.document.nodeType)return r.isSupported=!1,r;var c=n.document,i=n.document,a=n.DocumentFragment,l=n.HTMLTemplateElement,s=n.Node,u=n.Element,p=n.NodeFilter,m=n.NamedNodeMap,b=void 0===m?n.NamedNodeMap||n.MozNamedAttrMap:m,f=n.HTMLFormElement,g=n.DOMParser,h=n.trustedTypes,T=u.prototype,Z=R(T,"cloneNode"),ee=R(T,"nextSibling"),te=R(T,"childNodes"),ne=R(T,"parentNode");if("function"==typeof l){var re=i.createElement("template");re.content&&re.content.ownerDocument&&(i=re.content.ownerDocument)}var oe=J(h,c),ce=oe?oe.createHTML(""):"",ie=i,ae=ie.implementation,le=ie.createNodeIterator,se=ie.createDocumentFragment,ue=ie.getElementsByTagName,de=c.importNode,pe={};try{pe=C(i).documentMode?i.documentMode:{}}catch(e){}var me={};r.isSupported="function"==typeof ne&&ae&&void 0!==ae.createHTMLDocument&&9!==pe;var be,fe,ge=W,he=G,Ee=Y,Oe=V,we=Q,ye=K,ve=q,je=null,_e=N({},[].concat(o(A),o(L),o(P),o(D),o(B))),xe=null,ke=N({},[].concat(o(I),o(H),o(z),o(U))),Se=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Te=null,Ne=null,Ce=!0,Re=!0,Ae=!1,Le=!1,Pe=!1,Me=!1,De=!1,Fe=!1,Be=!1,Ie=!1,He=!0,ze=!1,Ue="user-content-",We=!0,Ge=!1,Ye={},Ve=null,qe=N({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),Qe=null,Ke=N({},["audio","video","img","source","image","track"]),Xe=null,$e=N({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Je="http://www.w3.org/1998/Math/MathML",Ze="http://www.w3.org/2000/svg",et="http://www.w3.org/1999/xhtml",tt=et,nt=!1,rt=["application/xhtml+xml","text/html"],ot="text/html",ct=null,it=i.createElement("form"),at=function(e){return e instanceof RegExp||e instanceof Function},lt=function(t){ct&&ct===t||(t&&"object"===e(t)||(t={}),t=C(t),be=be=-1===rt.indexOf(t.PARSER_MEDIA_TYPE)?ot:t.PARSER_MEDIA_TYPE,fe="application/xhtml+xml"===be?function(e){return e}:y,je="ALLOWED_TAGS"in t?N({},t.ALLOWED_TAGS,fe):_e,xe="ALLOWED_ATTR"in t?N({},t.ALLOWED_ATTR,fe):ke,Xe="ADD_URI_SAFE_ATTR"in t?N(C($e),t.ADD_URI_SAFE_ATTR,fe):$e,Qe="ADD_DATA_URI_TAGS"in t?N(C(Ke),t.ADD_DATA_URI_TAGS,fe):Ke,Ve="FORBID_CONTENTS"in t?N({},t.FORBID_CONTENTS,fe):qe,Te="FORBID_TAGS"in t?N({},t.FORBID_TAGS,fe):{},Ne="FORBID_ATTR"in t?N({},t.FORBID_ATTR,fe):{},Ye="USE_PROFILES"in t&&t.USE_PROFILES,Ce=!1!==t.ALLOW_ARIA_ATTR,Re=!1!==t.ALLOW_DATA_ATTR,Ae=t.ALLOW_UNKNOWN_PROTOCOLS||!1,Le=t.SAFE_FOR_TEMPLATES||!1,Pe=t.WHOLE_DOCUMENT||!1,Fe=t.RETURN_DOM||!1,Be=t.RETURN_DOM_FRAGMENT||!1,Ie=t.RETURN_TRUSTED_TYPE||!1,De=t.FORCE_BODY||!1,He=!1!==t.SANITIZE_DOM,ze=t.SANITIZE_NAMED_PROPS||!1,We=!1!==t.KEEP_CONTENT,Ge=t.IN_PLACE||!1,ve=t.ALLOWED_URI_REGEXP||ve,tt=t.NAMESPACE||et,t.CUSTOM_ELEMENT_HANDLING&&at(t.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Se.tagNameCheck=t.CUSTOM_ELEMENT_HANDLING.tagNameCheck),t.CUSTOM_ELEMENT_HANDLING&&at(t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Se.attributeNameCheck=t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),t.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Se.allowCustomizedBuiltInElements=t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Le&&(Re=!1),Be&&(Fe=!0),Ye&&(je=N({},o(B)),xe=[],!0===Ye.html&&(N(je,A),N(xe,I)),!0===Ye.svg&&(N(je,L),N(xe,H),N(xe,U)),!0===Ye.svgFilters&&(N(je,P),N(xe,H),N(xe,U)),!0===Ye.mathMl&&(N(je,D),N(xe,z),N(xe,U))),t.ADD_TAGS&&(je===_e&&(je=C(je)),N(je,t.ADD_TAGS,fe)),t.ADD_ATTR&&(xe===ke&&(xe=C(xe)),N(xe,t.ADD_ATTR,fe)),t.ADD_URI_SAFE_ATTR&&N(Xe,t.ADD_URI_SAFE_ATTR,fe),t.FORBID_CONTENTS&&(Ve===qe&&(Ve=C(Ve)),N(Ve,t.FORBID_CONTENTS,fe)),We&&(je["#text"]=!0),Pe&&N(je,["html","head","body"]),je.table&&(N(je,["tbody"]),delete Te.tbody),d&&d(t),ct=t)},st=N({},["mi","mo","mn","ms","mtext"]),ut=N({},["foreignobject","desc","title","annotation-xml"]),dt=N({},["title","style","font","a","script"]),pt=N({},L);N(pt,P),N(pt,M);var mt=N({},D);N(mt,F);var bt=function(e){var t=ne(e);t&&t.tagName||(t={namespaceURI:et,tagName:"template"});var n=y(e.tagName),r=y(t.tagName);return e.namespaceURI===Ze?t.namespaceURI===et?"svg"===n:t.namespaceURI===Je?"svg"===n&&("annotation-xml"===r||st[r]):Boolean(pt[n]):e.namespaceURI===Je?t.namespaceURI===et?"math"===n:t.namespaceURI===Ze?"math"===n&&ut[r]:Boolean(mt[n]):e.namespaceURI===et&&!(t.namespaceURI===Ze&&!ut[r])&&!(t.namespaceURI===Je&&!st[r])&&!mt[n]&&(dt[n]||!pt[n])},ft=function(e){w(r.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=ce}catch(t){e.remove()}}},gt=function(e,t){try{w(r.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){w(r.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!xe[e])if(Fe||Be)try{ft(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},ht=function(e){var t,n;if(De)e="<remove></remove>"+e;else{var r=v(e,/^[\r\n\t ]+/);n=r&&r[0]}"application/xhtml+xml"===be&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");var o=oe?oe.createHTML(e):e;if(tt===et)try{t=(new g).parseFromString(o,be)}catch(e){}if(!t||!t.documentElement){t=ae.createDocument(tt,"template",null);try{t.documentElement.innerHTML=nt?"":o}catch(e){}}var c=t.body||t.documentElement;return e&&n&&c.insertBefore(i.createTextNode(n),c.childNodes[0]||null),tt===et?ue.call(t,Pe?"html":"body")[0]:Pe?t.documentElement:c},Et=function(e){return le.call(e.ownerDocument||e,e,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT,null,!1)},Ot=function(e){return e instanceof f&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof b)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore)},wt=function(t){return"object"===e(s)?t instanceof s:t&&"object"===e(t)&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName},yt=function(e,t,n){me[e]&&E(me[e],(function(e){e.call(r,t,n,ct)}))},vt=function(e){var t;if(yt("beforeSanitizeElements",e,null),Ot(e))return ft(e),!0;if(k(/[\u0080-\uFFFF]/,e.nodeName))return ft(e),!0;var n=fe(e.nodeName);if(yt("uponSanitizeElement",e,{tagName:n,allowedTags:je}),e.hasChildNodes()&&!wt(e.firstElementChild)&&(!wt(e.content)||!wt(e.content.firstElementChild))&&k(/<[/\w]/g,e.innerHTML)&&k(/<[/\w]/g,e.textContent))return ft(e),!0;if("select"===n&&k(/<template/i,e.innerHTML))return ft(e),!0;if(!je[n]||Te[n]){if(!Te[n]&&_t(n)){if(Se.tagNameCheck instanceof RegExp&&k(Se.tagNameCheck,n))return!1;if(Se.tagNameCheck instanceof Function&&Se.tagNameCheck(n))return!1}if(We&&!Ve[n]){var o=ne(e)||e.parentNode,c=te(e)||e.childNodes;if(c&&o)for(var i=c.length-1;i>=0;--i)o.insertBefore(Z(c[i],!0),ee(e))}return ft(e),!0}return e instanceof u&&!bt(e)?(ft(e),!0):"noscript"!==n&&"noembed"!==n||!k(/<\/no(script|embed)/i,e.innerHTML)?(Le&&3===e.nodeType&&(t=e.textContent,t=j(t,ge," "),t=j(t,he," "),e.textContent!==t&&(w(r.removed,{element:e.cloneNode()}),e.textContent=t)),yt("afterSanitizeElements",e,null),!1):(ft(e),!0)},jt=function(e,t,n){if(He&&("id"===t||"name"===t)&&(n in i||n in it))return!1;if(Re&&!Ne[t]&&k(Ee,t));else if(Ce&&k(Oe,t));else if(!xe[t]||Ne[t]){if(!(_t(e)&&(Se.tagNameCheck instanceof RegExp&&k(Se.tagNameCheck,e)||Se.tagNameCheck instanceof Function&&Se.tagNameCheck(e))&&(Se.attributeNameCheck instanceof RegExp&&k(Se.attributeNameCheck,t)||Se.attributeNameCheck instanceof Function&&Se.attributeNameCheck(t))||"is"===t&&Se.allowCustomizedBuiltInElements&&(Se.tagNameCheck instanceof RegExp&&k(Se.tagNameCheck,n)||Se.tagNameCheck instanceof Function&&Se.tagNameCheck(n))))return!1}else if(Xe[t]);else if(k(ve,j(n,ye,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==_(n,"data:")||!Qe[e])if(Ae&&!k(we,j(n,ye,"")));else if(n)return!1;return!0},_t=function(e){return e.indexOf("-")>0},xt=function(t){var n,o,c,i;yt("beforeSanitizeAttributes",t,null);var a=t.attributes;if(a){var l={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:xe};for(i=a.length;i--;){var s=n=a[i],u=s.name,d=s.namespaceURI;if(o="value"===u?n.value:x(n.value),c=fe(u),l.attrName=c,l.attrValue=o,l.keepAttr=!0,l.forceKeepAttr=void 0,yt("uponSanitizeAttribute",t,l),o=l.attrValue,!l.forceKeepAttr&&(gt(u,t),l.keepAttr))if(k(/\/>/i,o))gt(u,t);else{Le&&(o=j(o,ge," "),o=j(o,he," "));var p=fe(t.nodeName);if(jt(p,c,o)){if(!ze||"id"!==c&&"name"!==c||(gt(u,t),o=Ue+o),oe&&"object"===e(h)&&"function"==typeof h.getAttributeType)if(d);else switch(h.getAttributeType(p,c)){case"TrustedHTML":o=oe.createHTML(o);break;case"TrustedScriptURL":o=oe.createScriptURL(o)}try{d?t.setAttributeNS(d,u,o):t.setAttribute(u,o),O(r.removed)}catch(e){}}}}yt("afterSanitizeAttributes",t,null)}},kt=function e(t){var n,r=Et(t);for(yt("beforeSanitizeShadowDOM",t,null);n=r.nextNode();)yt("uponSanitizeShadowNode",n,null),vt(n)||(n.content instanceof a&&e(n.content),xt(n));yt("afterSanitizeShadowDOM",t,null)};return r.sanitize=function(t){var o,i,l,u,d,p=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if((nt=!t)&&(t="\x3c!--\x3e"),"string"!=typeof t&&!wt(t)){if("function"!=typeof t.toString)throw S("toString is not a function");if("string"!=typeof(t=t.toString()))throw S("dirty is not a string, aborting")}if(!r.isSupported){if("object"===e(n.toStaticHTML)||"function"==typeof n.toStaticHTML){if("string"==typeof t)return n.toStaticHTML(t);if(wt(t))return n.toStaticHTML(t.outerHTML)}return t}if(Me||lt(p),r.removed=[],"string"==typeof t&&(Ge=!1),Ge){if(t.nodeName){var m=fe(t.nodeName);if(!je[m]||Te[m])throw S("root node is forbidden and cannot be sanitized in-place")}}else if(t instanceof s)1===(i=(o=ht("\x3c!----\x3e")).ownerDocument.importNode(t,!0)).nodeType&&"BODY"===i.nodeName||"HTML"===i.nodeName?o=i:o.appendChild(i);else{if(!Fe&&!Le&&!Pe&&-1===t.indexOf("<"))return oe&&Ie?oe.createHTML(t):t;if(!(o=ht(t)))return Fe?null:Ie?ce:""}o&&De&&ft(o.firstChild);for(var b=Et(Ge?t:o);l=b.nextNode();)3===l.nodeType&&l===u||vt(l)||(l.content instanceof a&&kt(l.content),xt(l),u=l);if(u=null,Ge)return t;if(Fe){if(Be)for(d=se.call(o.ownerDocument);o.firstChild;)d.appendChild(o.firstChild);else d=o;return xe.shadowroot&&(d=de.call(c,d,!0)),d}var f=Pe?o.outerHTML:o.innerHTML;return Pe&&je["!doctype"]&&o.ownerDocument&&o.ownerDocument.doctype&&o.ownerDocument.doctype.name&&k(X,o.ownerDocument.doctype.name)&&(f="<!DOCTYPE "+o.ownerDocument.doctype.name+">\n"+f),Le&&(f=j(f,ge," "),f=j(f,he," ")),oe&&Ie?oe.createHTML(f):f},r.setConfig=function(e){lt(e),Me=!0},r.clearConfig=function(){ct=null,Me=!1},r.isValidAttribute=function(e,t,n){ct||lt({});var r=fe(e),o=fe(t);return jt(r,o,n)},r.addHook=function(e,t){"function"==typeof t&&(me[e]=me[e]||[],w(me[e],t))},r.removeHook=function(e){if(me[e])return O(me[e])},r.removeHooks=function(e){me[e]&&(me[e]=[])},r.removeAllHooks=function(){me={}},r}()}()},,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(0);const o=()=>{const[,e]=Object(r.useState)();return Object(r.useCallback)(t=>{e(()=>{throw t})},[])}},,,,,,,,,,,,,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"d",(function(){return i})),n.d(t,"c",(function(){return a})),n.d(t,"b",(function(){return l}));const r=window.CustomEvent||null,o=(e,t)=>{let{bubbles:n=!1,cancelable:o=!1,element:c,detail:i={}}=t;if(!r)return;c||(c=document.body);const a=new r(e,{bubbles:n,cancelable:o,detail:i});c.dispatchEvent(a)};let c;const i=()=>{c&&clearTimeout(c),c=setTimeout(()=>{o("wc_fragment_refresh",{bubbles:!0,cancelable:!0})},50)},a=e=>{let{preserveCartData:t=!1}=e;o("wc-blocks_added_to_cart",{bubbles:!0,cancelable:!0,detail:{preserveCartData:t}})},l=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("function"!=typeof jQuery)return()=>{};const c=()=>{o(t,{bubbles:n,cancelable:r})};return jQuery(document).on(e,c),()=>jQuery(document).off(e,c)}},function(e,t,n){"use strict";var r=n(0),o=n(15);const c=Object(r.createElement)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(r.createElement)(o.Path,{d:"M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"}));t.a=c},,function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));const r=e=>"number"==typeof e},,,,function(e,t,n){"use strict";var r=n(0),o=n(5),c=n(4),i=n.n(c),a=n(1),l=n(24),s=n(92),u=n(44);function d(e){switch(e){case"success":case"warning":case"info":return"polite";case"error":default:return"assertive"}}t.a=function({className:e,status:t="info",children:n,spokenMessage:c=n,onRemove:p=o.noop,isDismissible:m=!0,actions:b=[],politeness:f=d(t),__unstableHTML:g,onDismiss:h=o.noop}){!function(e,t){const n="string"==typeof e?e:Object(r.renderToString)(e);Object(r.useEffect)(()=>{n&&Object(l.speak)(n,t)},[n,t])}(c,f);const E=i()(e,"components-notice","is-"+t,{"is-dismissible":m});return g&&(n=Object(r.createElement)(r.RawHTML,null,n)),Object(r.createElement)("div",{className:E},Object(r.createElement)("div",{className:"components-notice__content"},n,Object(r.createElement)("div",{className:"components-notice__actions"},b.map(({className:e,label:t,isPrimary:n,variant:o,noDefaultClasses:c=!1,onClick:a,url:l},s)=>{let d=o;return"primary"===o||c||(d=l?"link":"secondary"),void 0===d&&n&&(d="primary"),Object(r.createElement)(u.a,{key:s,href:l,variant:d,onClick:l?void 0:a,className:i()("components-notice__action",e)},t)}))),m&&Object(r.createElement)(u.a,{className:"components-notice__dismiss",icon:s.a,label:Object(a.__)("Dismiss this notice"),onClick:e=>{var t;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),h(),p()},showTooltip:!1}))}},function(e,t,n){"use strict";var r=n(12),o=n.n(r),c=n(0);n(123);const i=e=>{if(!e)return;const t=e.getBoundingClientRect().bottom;t>=0&&t<=window.innerHeight||e.scrollIntoView()};t.a=e=>t=>{const n=Object(c.useRef)(null);return Object(c.createElement)(c.Fragment,null,Object(c.createElement)("div",{className:"with-scroll-to-top__scroll-point",ref:n,"aria-hidden":!0}),Object(c.createElement)(e,o()({},t,{scrollToTop:e=>{null!==n.current&&((e,t)=>{const{focusableSelector:n}=t||{};window&&Number.isFinite(window.innerHeight)&&(n?((e,t)=>{var n;const r=(null===(n=e.parentElement)||void 0===n?void 0:n.querySelectorAll(t))||[];if(r.length){const e=r[0];i(e),null==e||e.focus()}else i(e)})(e,n):i(e))})(n.current,e)}})))}},function(e,t){e.exports=window.wp.blocks},,,,,function(e,t){},,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(72),o=n.n(r);const c=["a","b","em","i","strong","p","br"],i=["target","href","rel","name","download"],a=(e,t)=>{const n=(null==t?void 0:t.tags)||c,r=(null==t?void 0:t.attr)||i;return o.a.sanitize(e,{ALLOWED_TAGS:n,ALLOWED_ATTR:r})}},,function(e,t){e.exports=window.wp.blockEditor},,,function(e,t,n){"use strict";var r=n(0);t.a=function(e){let{icon:t,size:n=24,...o}=e;return Object(r.cloneElement)(t,{width:n,height:n,...o})}},,,,,,,,,function(e,t){},function(e,t,n){"use strict";var r=n(0),o=n(4),c=n.n(o),i=n(19),a=n(11);n(137),t.a=Object(a.withInstanceId)(e=>{let{className:t,instanceId:n,label:o="",onChange:a,options:l,screenReaderLabel:s,value:u=""}=e;const d="wc-block-components-sort-select__select-"+n;return Object(r.createElement)("div",{className:c()("wc-block-sort-select","wc-block-components-sort-select",t)},Object(r.createElement)(i.a,{label:o,screenReaderLabel:s,wrapperElement:"label",wrapperProps:{className:"wc-block-sort-select__label wc-block-components-sort-select__label",htmlFor:d}}),Object(r.createElement)("select",{id:d,className:"wc-block-sort-select__select wc-block-components-sort-select__select",onChange:a,value:u},l&&l.map(e=>Object(r.createElement)("option",{key:e.key,value:e.key},e.label))))})},,,,function(e,t){e.exports=window.wp.wordcount},function(e,t){e.exports=window.wp.autop},,,function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(57),o=(n(14),n(2));const c=e=>{const t=Object.keys(o.defaultAddressFields),n=Object(r.a)(t,{},e.country),c=Object.assign({},e);return n.forEach(t=>{let{key:n="",hidden:r=!1}=t;r&&((e,t)=>e in t)(n,e)&&(c[n]="")}),c}},,function(e,t){e.exports=window.wc.wcBlocksSharedHocs},,,function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return m}));var r=n(12),o=n.n(r),c=n(0),i=n(4),a=n.n(i),l=n(98),s=n(109),u=n(6),d=n(3);n(105);const p=e=>{let{status:t="default"}=e;switch(t){case"error":return"woocommerce-error";case"success":return"woocommerce-message";case"info":case"warning":return"woocommerce-info"}return""},m=e=>{let{className:t,context:n="default",additionalNotices:r=[]}=e;const i=Object(u.useSelect)(e=>e(d.PAYMENT_STORE_KEY).isExpressPaymentMethodActive()),{notices:m}=Object(u.useSelect)(e=>({notices:e("core/notices").getNotices(n)})),{removeNotice:b}=Object(u.useDispatch)("core/notices"),f=m.filter(e=>"snackbar"!==e.type).concat(r);if(!f.length)return null;const g=a()(t,"wc-block-components-notices");return i?null:Object(c.createElement)("div",{className:g},f.map(e=>Object(c.createElement)(l.a,o()({key:"store-notice-"+e.id},e,{className:a()("wc-block-components-notices__notice",p(e)),onRemove:()=>{e.isDismissible&&b(e.id,n)}}),Object(s.a)(e.content))))}},,,,,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(18),o=n(0),c=n(46);n.p=c.k,Object(r.registerBlockComponent)({blockName:"woocommerce/product-price",component:Object(o.lazy)(()=>Promise.all([n.e(0),n.e(71)]).then(n.bind(null,361)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-image",component:Object(o.lazy)(()=>n.e(70).then(n.bind(null,502)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-title",component:Object(o.lazy)(()=>n.e(78).then(n.bind(null,503)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-rating",component:Object(o.lazy)(()=>n.e(72).then(n.bind(null,362)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-button",component:Object(o.lazy)(()=>n.e(68).then(n.bind(null,363)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-summary",component:Object(o.lazy)(()=>n.e(76).then(n.bind(null,438)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-sale-badge",component:Object(o.lazy)(()=>n.e(73).then(n.bind(null,319)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-sku",component:Object(o.lazy)(()=>n.e(74).then(n.bind(null,439)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-category-list",component:Object(o.lazy)(()=>n.e(69).then(n.bind(null,440)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-tag-list",component:Object(o.lazy)(()=>n.e(77).then(n.bind(null,441)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-stock-indicator",component:Object(o.lazy)(()=>n.e(75).then(n.bind(null,442)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-add-to-cart",component:Object(o.lazy)(()=>Promise.all([n.e(1),n.e(10),n.e(4),n.e(67)]).then(n.bind(null,504)))});const i=e=>Object(r.getRegisteredBlockComponents)(e)},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t,n){e.exports=n(266)},function(e,t){},function(e,t){},function(e,t){},,,,,,,,,,,,,,,,,,,,,,function(e,t,n){"use strict";n.r(t);var r=n(0),o=n(48),c=n(8),i=n(1),a=n(5),l=n(4),s=n.n(l),u=n(19);n(244);var d=e=>{let{currentPage:t,displayFirstAndLastPages:n=!0,displayNextAndPreviousArrows:o=!0,pagesToDisplay:c=3,onPageChange:a,totalPages:l}=e,{minIndex:d,maxIndex:p}=((e,t,n)=>{if(n<=2)return{minIndex:null,maxIndex:null};const r=e-1,o=Math.max(Math.floor(t-r/2),2),c=Math.min(Math.ceil(t+(r-(t-o))),n-1);return{minIndex:Math.max(Math.floor(t-(r-(c-t))),2),maxIndex:c}})(c,t,l);const m=n&&Boolean(1!==d),b=n&&Boolean(p!==l),f=n&&Boolean(d&&d>3),g=n&&Boolean(p&&p<l-2);m&&3===d&&(d-=1),b&&p===l-2&&(p+=1);const h=[];if(d&&p)for(let e=d;e<=p;e++)h.push(e);return Object(r.createElement)("div",{className:"wc-block-pagination wc-block-components-pagination"},Object(r.createElement)(u.a,{screenReaderLabel:Object(i.__)("Navigate to another page","woo-gutenberg-products-block")}),o&&Object(r.createElement)("button",{className:"wc-block-pagination-page wc-block-components-pagination__page wc-block-components-pagination-page--arrow",onClick:()=>a(t-1),title:Object(i.__)("Previous page","woo-gutenberg-products-block"),disabled:t<=1},Object(r.createElement)(u.a,{label:"←",screenReaderLabel:Object(i.__)("Previous page","woo-gutenberg-products-block")})),m&&Object(r.createElement)("button",{className:s()("wc-block-pagination-page","wc-block-components-pagination__page",{"wc-block-pagination-page--active":1===t,"wc-block-components-pagination__page--active":1===t}),onClick:()=>a(1),disabled:1===t},Object(r.createElement)(u.a,{label:"1",screenReaderLabel:Object(i.sprintf)(
|
4 |
/* translators: %d is the page number (1, 2, 3...). */
|
5 |
-
Object(
|
6 |
/* translators: %d is the page number (1, 2, 3...). */
|
7 |
-
Object(
|
8 |
/* translators: %d is the page number (1, 2, 3...). */
|
9 |
-
Object(
|
10 |
/* translators: %s is an integer higher than 0 (1, 2, 3...) */
|
11 |
-
Object(i._n)("%d product found","%d products found",e,"woo-gutenberg-products-block"),e)))})(D))},[null==U?void 0:U.totalQuery,D,o,H]);const{contentVisibility:W}=t,G=t.columns*t.rows,Y=!Number.isFinite(D)&&Number.isFinite(null==U?void 0:U.totalProducts)&&Object(a.isEqual)(H,null==U?void 0:U.totalQuery)?Math.ceil(((null==U?void 0:U.totalProducts)||0)/G):Math.ceil(D/G),V=M.length?M:Array.from({length:G}),q=0!==M.length||F,Q=g.length>0||w.length>0||j.length>0||Number.isFinite(S)||Number.isFinite(N);return Object(r.createElement)("div",{className:(()=>{const{columns:e,rows:n,alignButtons:r,align:o}=t,c=void 0!==o?"align"+o:"";return s()(B,c,"has-"+e+"-columns",{"has-multiple-rows":n>1,"has-aligned-buttons":r})})()},(null==W?void 0:W.orderBy)&&q&&Object(r.createElement)(k,{onChange:c,value:l}),!q&&Q&&Object(r.createElement)(_,{resetCallback:()=>{O([]),y([]),x([]),T(null),C(null)}}),!q&&!Q&&Object(r.createElement)(v,null),q&&Object(r.createElement)("ul",{className:s()(B+"__products",{"is-loading-products":F})},V.map((function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;return Object(r.createElement)(A,{key:e.id||n,attributes:t,product:e})}))),Y>1&&Object(r.createElement)(d,{currentPage:n,onPageChange:e=>{u({focusableSelector:"a, button"}),o(e)},totalPages:Y}))}),D=e=>{let{attributes:t}=e;const[n,o]=Object(r.useState)(1),[c,i]=Object(r.useState)(t.orderby);return Object(r.useEffect)(()=>{i(t.orderby)},[t.orderby]),Object(r.createElement)(M,{attributes:t,currentPage:n,onPageChange:e=>{o(e)},onSortChange:e=>{var t;const n=null==e||null===(t=e.target)||void 0===t?void 0:t.value;i(n),o(1)},sortValue:c})};const F=Object(r.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 230 250",style:{width:"100%"}},Object(r.createElement)("title",null,"Grid Block Preview"),Object(r.createElement)("rect",{width:"65.374",height:"65.374",x:".162",y:".779",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(r.createElement)("rect",{width:"62.8",height:"15",x:"1.565",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(r.createElement)("rect",{width:"65.374",height:"65.374",x:".162",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(r.createElement)("rect",{width:"62.8",height:"15",x:"1.565",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(r.createElement)("rect",{width:"65.374",height:"65.374",x:"82.478",y:".779",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(r.createElement)("rect",{width:"62.8",height:"15",x:"83.882",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(r.createElement)("rect",{width:"65.374",height:"65.374",x:"82.478",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(r.createElement)("rect",{width:"62.8",height:"15",x:"83.882",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(r.createElement)("rect",{width:"65.374",height:"65.374",x:"164.788",y:".779",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(r.createElement)("rect",{width:"62.8",height:"15",x:"166.192",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(r.createElement)("rect",{width:"65.374",height:"65.374",x:"164.788",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(r.createElement)("rect",{width:"62.8",height:"15",x:"166.192",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"221.798",fill:"#E1E3E6",rx:"3"}));var B=n(138);class I extends c.Component{render(){const{attributes:e,urlParameterSuffix:t}=this.props;return e.isPreview?F:Object(r.createElement)(h.InnerBlockLayoutContextProvider,{parentName:"woocommerce/all-products",parentClassName:"wc-block-grid"},Object(r.createElement)(B.a,{context:"wc/all-products"}),Object(r.createElement)(D,{attributes:e,urlParameterSuffix:t}))}}var H=I;Object(o.a)({selector:".wp-block-woocommerce-all-products",Block:e=>Object(r.createElement)(H,e),getProps:e=>({attributes:JSON.parse(e.dataset.attributes)})})},,,,,,,,,,,,,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(61),o=n(3),c=n(6),i=n(29);const a=e=>{const t={namespace:"/wc/store/v1",resourceName:"products"},{results:n,isLoading:a}=Object(r.a)({...t,query:e}),{value:l}=((e,t)=>{const{namespace:n,resourceName:r,resourceValues:a=[],query:l={}}=t;if(!n||!r)throw new Error("The options object must have valid values for the namespace and the resource name properties.");const s=Object(i.a)(l),u=Object(i.a)(a),{value:d,isLoading:p=!0}=Object(c.useSelect)(e=>{const t=e(o.COLLECTIONS_STORE_KEY),c=["x-wp-total",n,r,s,u];return{value:t.getCollectionHeader(...c),isLoading:t.hasFinishedResolution("getCollectionHeader",c)}},["x-wp-total",n,r,u,s]);return{value:d,isLoading:p}})(0,{...t,query:e});return{products:n,totalProducts:parseInt(l,10),productsLoading:a}}}]);
|
|
|
|
1 |
+
!function(e){function t(t){for(var r,o,n=t[0],a=t[1],s=0,i=[];s<n.length;s++)o=n[s],Object.prototype.hasOwnProperty.call(c,o)&&c[o]&&i.push(c[o][0]),c[o]=0;for(r in a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r]);for(l&&l(t);i.length;)i.shift()()}var r={},c={13:0};function o(t){if(r[t])return r[t].exports;var c=r[t]={i:t,l:!1,exports:{}};return e[t].call(c.exports,c,c.exports,o),c.l=!0,c.exports}o.e=function(e){var t=[],r=c[e];if(0!==r)if(r)t.push(r[2]);else{var n=new Promise((function(t,o){r=c[e]=[t,o]}));t.push(r[2]=n);var a,s=document.createElement("script");s.charset="utf-8",s.timeout=120,o.nc&&s.setAttribute("nonce",o.nc),s.src=function(e){return o.p+""+({0:"vendors--cart-blocks/cart-cross-sells-products--cart-blocks/cart-line-items--cart-blocks/cart-order--671ca56f",1:"vendors--cart-blocks/cart-cross-sells-products--cart-blocks/order-summary-shipping--checkout-blocks--18f9376a",3:"vendors--attribute-filter-wrapper--mini-cart-contents-block/footer--product-add-to-cart",6:"cart-blocks/cart-cross-sells-products--product-add-to-cart",10:"vendors--cart-blocks/cart-cross-sells-products--product-add-to-cart",67:"product-add-to-cart",68:"product-button",69:"product-category-list",70:"product-image",71:"product-price",72:"product-rating",73:"product-sale-badge",74:"product-sku",75:"product-stock-indicator",76:"product-summary",77:"product-tag-list",78:"product-title"}[e]||e)+"-frontend.js?ver="+{0:"776637c8278cafeb3ce2",1:"96158db379b3a7e18181",3:"1f03cc30eabe1c8f2e05",6:"593391647e2d050389df",10:"095861022639fc170f4c",67:"34741dd066e0d5b5cc33",68:"fc7996708b52e463828d",69:"111929c9feb613799515",70:"35a929601c753222d001",71:"0d3793324623a0a996fc",72:"35781291512da46144d2",73:"7415516531314b5614d1",74:"db22eacc473429db01c3",75:"4bfb194a29d19b4467e5",76:"c3ed0888f2420c316c36",77:"e93dbb6b4be634d9d619",78:"7abd23cfab64363edce3"}[e]}(e);var l=new Error;a=function(t){s.onerror=s.onload=null,clearTimeout(i);var r=c[e];if(0!==r){if(r){var o=t&&("load"===t.type?"missing":t.type),n=t&&t.target&&t.target.src;l.message="Loading chunk "+e+" failed.\n("+o+": "+n+")",l.name="ChunkLoadError",l.type=o,l.request=n,r[1](l)}c[e]=void 0}};var i=setTimeout((function(){a({type:"timeout",target:s})}),12e4);s.onerror=s.onload=a,document.head.appendChild(s)}return Promise.all(t)},o.m=e,o.c=r,o.d=function(e,t,r){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var c in e)o.d(r,c,function(t){return e[t]}.bind(null,c));return r},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o.oe=function(e){throw console.error(e),e};var n=window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[],a=n.push.bind(n);n.push=t,n=n.slice();for(var s=0;s<n.length;s++)t(n[s]);var l=a;o(o.s=235)}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},104:function(e,t){e.exports=window.wp.blockEditor},107:function(e,t,r){"use strict";var c=r(0);t.a=function(e){let{icon:t,size:r=24,...o}=e;return Object(c.cloneElement)(t,{width:r,height:r,...o})}},11:function(e,t){e.exports=window.wp.url},116:function(e,t){},117:function(e,t,r){"use strict";var c=r(0),o=r(7),n=r.n(o),a=r(19),s=r(15);r(132),t.a=Object(s.withInstanceId)(e=>{let{className:t,instanceId:r,label:o="",onChange:s,options:l,screenReaderLabel:i,value:u=""}=e;const d="wc-block-components-sort-select__select-"+r;return Object(c.createElement)("div",{className:n()("wc-block-sort-select","wc-block-components-sort-select",t)},Object(c.createElement)(a.a,{label:o,screenReaderLabel:i,wrapperElement:"label",wrapperProps:{className:"wc-block-sort-select__label wc-block-components-sort-select__label",htmlFor:d}}),Object(c.createElement)("select",{id:d,className:"wc-block-sort-select__select wc-block-components-sort-select__select",onChange:s,value:u},l&&l.map(e=>Object(c.createElement)("option",{key:e.key,value:e.key},e.label))))})},12:function(e,t){e.exports=window.wp.isShallowEqual},123:function(e,t){e.exports=window.wp.wordcount},124:function(e,t){e.exports=window.wp.autop},127:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));var c=r(51),o=(r(11),r(2));const n=e=>{const t=Object.keys(o.defaultAddressFields),r=Object(c.a)(t,{},e.country),n=Object.assign({},e);return r.forEach(t=>{let{key:r="",hidden:c=!1}=t;c&&((e,t)=>e in t)(r,e)&&(n[r]="")}),n}},129:function(e,t){e.exports=window.wc.wcBlocksSharedHocs},13:function(e,t){function r(){return e.exports=r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var c in r)Object.prototype.hasOwnProperty.call(r,c)&&(e[c]=r[c])}return e},e.exports.__esModule=!0,e.exports.default=e.exports,r.apply(this,arguments)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports},132:function(e,t){},14:function(e,t,r){"use strict";var c=r(16),o=r.n(c),n=r(0),a=r(6),s=r(1),l=r(42),i=e=>{let{imageUrl:t=l.l+"/block-error.svg",header:r=Object(s.__)("Oops!","woo-gutenberg-products-block"),text:c=Object(s.__)("There was an error loading the content.","woo-gutenberg-products-block"),errorMessage:o,errorMessagePrefix:a=Object(s.__)("Error:","woo-gutenberg-products-block"),button:i,showErrorBlock:u=!0}=e;return u?Object(n.createElement)("div",{className:"wc-block-error wc-block-components-error"},t&&Object(n.createElement)("img",{className:"wc-block-error__image wc-block-components-error__image",src:t,alt:""}),Object(n.createElement)("div",{className:"wc-block-error__content wc-block-components-error__content"},r&&Object(n.createElement)("p",{className:"wc-block-error__header wc-block-components-error__header"},r),c&&Object(n.createElement)("p",{className:"wc-block-error__text wc-block-components-error__text"},c),o&&Object(n.createElement)("p",{className:"wc-block-error__message wc-block-components-error__message"},a?a+" ":"",o),i&&Object(n.createElement)("p",{className:"wc-block-error__button wc-block-components-error__button"},i))):null};r(34);class u extends a.Component{constructor(){super(...arguments),o()(this,"state",{errorMessage:"",hasError:!1})}static getDerivedStateFromError(e){return void 0!==e.statusText&&void 0!==e.status?{errorMessage:Object(n.createElement)(n.Fragment,null,Object(n.createElement)("strong",null,e.status),": ",e.statusText),hasError:!0}:{errorMessage:e.message,hasError:!0}}render(){const{header:e,imageUrl:t,showErrorMessage:r=!0,showErrorBlock:c=!0,text:o,errorMessagePrefix:a,renderError:s,button:l}=this.props,{errorMessage:u,hasError:d}=this.state;return d?"function"==typeof s?s({errorMessage:u}):Object(n.createElement)(i,{showErrorBlock:c,errorMessage:r?u:null,header:e,imageUrl:t,text:o,errorMessagePrefix:a,button:l}):this.props.children}}t.a=u},140:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var c=r(17),o=r(0),n=r(42);r.p=n.k,Object(c.registerBlockComponent)({blockName:"woocommerce/product-price",component:Object(o.lazy)(()=>Promise.all([r.e(0),r.e(71)]).then(r.bind(null,358)))}),Object(c.registerBlockComponent)({blockName:"woocommerce/product-image",component:Object(o.lazy)(()=>r.e(70).then(r.bind(null,494)))}),Object(c.registerBlockComponent)({blockName:"woocommerce/product-title",component:Object(o.lazy)(()=>r.e(78).then(r.bind(null,495)))}),Object(c.registerBlockComponent)({blockName:"woocommerce/product-rating",component:Object(o.lazy)(()=>r.e(72).then(r.bind(null,359)))}),Object(c.registerBlockComponent)({blockName:"woocommerce/product-button",component:Object(o.lazy)(()=>r.e(68).then(r.bind(null,360)))}),Object(c.registerBlockComponent)({blockName:"woocommerce/product-summary",component:Object(o.lazy)(()=>r.e(76).then(r.bind(null,431)))}),Object(c.registerBlockComponent)({blockName:"woocommerce/product-sale-badge",component:Object(o.lazy)(()=>r.e(73).then(r.bind(null,313)))}),Object(c.registerBlockComponent)({blockName:"woocommerce/product-sku",component:Object(o.lazy)(()=>r.e(74).then(r.bind(null,432)))}),Object(c.registerBlockComponent)({blockName:"woocommerce/product-category-list",component:Object(o.lazy)(()=>r.e(69).then(r.bind(null,433)))}),Object(c.registerBlockComponent)({blockName:"woocommerce/product-tag-list",component:Object(o.lazy)(()=>r.e(77).then(r.bind(null,434)))}),Object(c.registerBlockComponent)({blockName:"woocommerce/product-stock-indicator",component:Object(o.lazy)(()=>r.e(75).then(r.bind(null,435)))}),Object(c.registerBlockComponent)({blockName:"woocommerce/product-add-to-cart",component:Object(o.lazy)(()=>Promise.all([r.e(1),r.e(3),r.e(10),r.e(6),r.e(67)]).then(r.bind(null,496)))});const a=e=>Object(c.getRegisteredBlockComponents)(e)},15:function(e,t){e.exports=window.wp.compose},16:function(e,t){e.exports=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.__esModule=!0,e.exports.default=e.exports},17:function(e,t){e.exports=window.wc.wcBlocksRegistry},18:function(e,t){e.exports=window.wp.primitives},19:function(e,t,r){"use strict";var c=r(0),o=r(7),n=r.n(o);t.a=e=>{let t,{label:r,screenReaderLabel:o,wrapperElement:a,wrapperProps:s={}}=e;const l=null!=r,i=null!=o;return!l&&i?(t=a||"span",s={...s,className:n()(s.className,"screen-reader-text")},Object(c.createElement)(t,s,o)):(t=a||c.Fragment,l&&i&&r!==o?Object(c.createElement)(t,s,Object(c.createElement)("span",{"aria-hidden":"true"},r),Object(c.createElement)("span",{className:"screen-reader-text"},o)):Object(c.createElement)(t,s,r))}},2:function(e,t){e.exports=window.wc.wcSettings},22:function(e,t){e.exports=window.wp.htmlEntities},23:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));var c=r(0);const o=Object(c.createContext)("page"),n=()=>Object(c.useContext)(o);o.Provider},235:function(e,t,r){e.exports=r(260)},236:function(e,t){},237:function(e,t){},238:function(e,t){},26:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var c=r(0),o=r(12),n=r.n(o);function a(e){const t=Object(c.useRef)(e);return n()(e,t.current)||(t.current=e),t.current}},260:function(e,t,r){"use strict";r.r(t);var c=r(0),o=r(44),n=r(6),a=r(1),s=r(8),l=r(7),i=r.n(l),u=r(19);r(238);var d=e=>{let{currentPage:t,displayFirstAndLastPages:r=!0,displayNextAndPreviousArrows:o=!0,pagesToDisplay:n=3,onPageChange:s,totalPages:l}=e,{minIndex:d,maxIndex:b}=((e,t,r)=>{if(r<=2)return{minIndex:null,maxIndex:null};const c=e-1,o=Math.max(Math.floor(t-c/2),2),n=Math.min(Math.ceil(t+(c-(t-o))),r-1);return{minIndex:Math.max(Math.floor(t-(c-(n-t))),2),maxIndex:n}})(n,t,l);const p=r&&Boolean(1!==d),m=r&&Boolean(b!==l),g=r&&Boolean(d&&d>3),E=r&&Boolean(b&&b<l-2);p&&3===d&&(d-=1),m&&b===l-2&&(b+=1);const h=[];if(d&&b)for(let e=d;e<=b;e++)h.push(e);return Object(c.createElement)("div",{className:"wc-block-pagination wc-block-components-pagination"},Object(c.createElement)(u.a,{screenReaderLabel:Object(a.__)("Navigate to another page","woo-gutenberg-products-block")}),o&&Object(c.createElement)("button",{className:"wc-block-pagination-page wc-block-components-pagination__page wc-block-components-pagination-page--arrow",onClick:()=>s(t-1),title:Object(a.__)("Previous page","woo-gutenberg-products-block"),disabled:t<=1},Object(c.createElement)(u.a,{label:"←",screenReaderLabel:Object(a.__)("Previous page","woo-gutenberg-products-block")})),p&&Object(c.createElement)("button",{className:i()("wc-block-pagination-page","wc-block-components-pagination__page",{"wc-block-pagination-page--active":1===t,"wc-block-components-pagination__page--active":1===t}),onClick:()=>s(1),disabled:1===t},Object(c.createElement)(u.a,{label:"1",screenReaderLabel:Object(a.sprintf)(
|
|
|
|
|
2 |
/* translators: %d is the page number (1, 2, 3...). */
|
3 |
+
Object(a.__)("Page %d","woo-gutenberg-products-block"),1)})),g&&Object(c.createElement)("span",{className:"wc-block-pagination-ellipsis wc-block-components-pagination__ellipsis","aria-hidden":"true"},Object(a.__)("…","woo-gutenberg-products-block")),h.map(e=>Object(c.createElement)("button",{key:e,className:i()("wc-block-pagination-page","wc-block-components-pagination__page",{"wc-block-pagination-page--active":t===e,"wc-block-components-pagination__page--active":t===e}),onClick:t===e?void 0:()=>s(e),disabled:t===e},Object(c.createElement)(u.a,{label:e.toString(),screenReaderLabel:Object(a.sprintf)(
|
4 |
/* translators: %d is the page number (1, 2, 3...). */
|
5 |
+
Object(a.__)("Page %d","woo-gutenberg-products-block"),e)}))),E&&Object(c.createElement)("span",{className:"wc-block-pagination-ellipsis wc-block-components-pagination__ellipsis","aria-hidden":"true"},Object(a.__)("…","woo-gutenberg-products-block")),m&&Object(c.createElement)("button",{className:i()("wc-block-pagination-page","wc-block-components-pagination__page",{"wc-block-pagination-page--active":t===l,"wc-block-components-pagination__page--active":t===l}),onClick:()=>s(l),disabled:t===l},Object(c.createElement)(u.a,{label:l.toString(),screenReaderLabel:Object(a.sprintf)(
|
6 |
/* translators: %d is the page number (1, 2, 3...). */
|
7 |
+
Object(a.__)("Page %d","woo-gutenberg-products-block"),l)})),o&&Object(c.createElement)("button",{className:"wc-block-pagination-page wc-block-components-pagination__page wc-block-components-pagination-page--arrow",onClick:()=>s(t+1),title:Object(a.__)("Next page","woo-gutenberg-products-block"),disabled:t>=l},Object(c.createElement)(u.a,{label:"→",screenReaderLabel:Object(a.__)("Next page","woo-gutenberg-products-block")})))},b=r(56),p=r(30),m=r(275),g=r(64),E=r(93),h=r(46),w=r(29),f=r(107),O=r(18),j=Object(c.createElement)(O.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"-2 -2 24 24"},Object(c.createElement)(O.Path,{d:"M10 2c4.42 0 8 3.58 8 8s-3.58 8-8 8-8-3.58-8-8 3.58-8 8-8zm1.13 9.38l.35-6.46H8.52l.35 6.46h2.26zm-.09 3.36c.24-.23.37-.55.37-.96 0-.42-.12-.74-.36-.97s-.59-.35-1.06-.35-.82.12-1.07.35-.37.55-.37.97c0 .41.13.73.38.96.26.23.61.34 1.06.34s.8-.11 1.05-.34z"})),_=()=>{const{parentClassName:e}=Object(h.useInnerBlockLayoutContext)();return Object(c.createElement)("div",{className:e+"__no-products"},Object(c.createElement)(f.a,{className:e+"__no-products-image",icon:j,size:100}),Object(c.createElement)("strong",{className:e+"__no-products-title"},Object(a.__)("No products","woo-gutenberg-products-block")),Object(c.createElement)("p",{className:e+"__no-products-description"},Object(a.__)("There are currently no products available to display.","woo-gutenberg-products-block")))},y=Object(c.createElement)(O.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(c.createElement)(O.Path,{d:"M13.5 6C10.5 6 8 8.5 8 11.5c0 1.1.3 2.1.9 3l-3.4 3 1 1.1 3.4-2.9c1 .9 2.2 1.4 3.6 1.4 3 0 5.5-2.5 5.5-5.5C19 8.5 16.5 6 13.5 6zm0 9.5c-2.2 0-4-1.8-4-4s1.8-4 4-4 4 1.8 4 4-1.8 4-4 4z"})),k=e=>{let{resetCallback:t=(()=>{})}=e;const{parentClassName:r}=Object(h.useInnerBlockLayoutContext)();return Object(c.createElement)("div",{className:r+"__no-products"},Object(c.createElement)(f.a,{className:r+"__no-products-image",icon:y,size:100}),Object(c.createElement)("strong",{className:r+"__no-products-title"},Object(a.__)("No products found","woo-gutenberg-products-block")),Object(c.createElement)("p",{className:r+"__no-products-description"},Object(a.__)("We were unable to find any results based on your search.","woo-gutenberg-products-block")),Object(c.createElement)("button",{onClick:t},Object(a.__)("Reset Search","woo-gutenberg-products-block")))},x=r(117);r(237);var v=e=>{let{onChange:t,value:r}=e;return Object(c.createElement)(x.a,{className:"wc-block-product-sort-select wc-block-components-product-sort-select",onChange:t,options:[{key:"menu_order",label:Object(a.__)("Default sorting","woo-gutenberg-products-block")},{key:"popularity",label:Object(a.__)("Popularity","woo-gutenberg-products-block")},{key:"rating",label:Object(a.__)("Average rating","woo-gutenberg-products-block")},{key:"date",label:Object(a.__)("Latest","woo-gutenberg-products-block")},{key:"price",label:Object(a.__)("Price: low to high","woo-gutenberg-products-block")},{key:"price-desc",label:Object(a.__)("Price: high to low","woo-gutenberg-products-block")}],screenReaderLabel:Object(a.__)("Order products by","woo-gutenberg-products-block"),value:r})},S=r(15),C=r(13),P=r.n(C),N=r(140);const R=(e,t,r,o)=>{if(!r)return;const n=Object(N.a)(e);return r.map((r,a)=>{let[s,l={}]=r,i=[];l.children&&l.children.length>0&&(i=R(e,t,l.children,o));const u=n[s];if(!u)return null;const d=t.id||0,b=["layout",s,a,o,d];return Object(c.createElement)(c.Suspense,{key:b.join("_"),fallback:Object(c.createElement)("div",{className:"wc-block-placeholder"})},Object(c.createElement)(u,P()({},l,{children:i,product:t})))})};var T=Object(S.withInstanceId)(e=>{let{product:t={},attributes:r,instanceId:o}=e;const{layoutConfig:n}=r,{parentClassName:a,parentName:s}=Object(h.useInnerBlockLayoutContext)(),l=0===Object.keys(t).length,u=i()(a+"__product","wc-block-layout",{"is-loading":l});return Object(c.createElement)("li",{className:u,"aria-hidden":l},R(s,t,n,o))});r(236);const B=e=>{switch(e){case"menu_order":case"popularity":case"rating":case"price":return{orderby:e,order:"asc"};case"price-desc":return{orderby:"price",order:"desc"};case"date":return{orderby:"date",order:"desc"}}},A=function(e){let{totalQuery:t,totalProducts:r}=e,{totalQuery:c}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return!Object(s.isEqual)(t,c)&&Number.isFinite(r)};var L=Object(E.a)(e=>{let{attributes:t,currentPage:r,onPageChange:o,onSortChange:n,sortValue:l,scrollToTop:u}=e;const[E,f]=Object(p.b)("attributes",[]),[O,j]=Object(p.b)("stock_status",[]),[y,x]=Object(p.b)("rating",[]),[S,C]=Object(p.b)("min_price"),[P,N]=Object(p.b)("max_price"),[R]=Object(p.c)((e=>{let{sortValue:t,currentPage:r,attributes:c}=e;const{columns:o,rows:n}=c;return{...B(t),catalog_visibility:"catalog",per_page:o*n,page:r}})({attributes:t,sortValue:l,currentPage:r})),{products:L,totalProducts:M,productsLoading:I}=Object(m.a)(R),{parentClassName:F,parentName:Y}=Object(h.useInnerBlockLayoutContext)(),q=(e=>{const{order:t,orderby:r,page:c,per_page:o,...n}=e;return n||{}})(R),{dispatchStoreEvent:z}=Object(g.a)(),Q=Object(b.a)({totalQuery:q,totalProducts:M},A);Object(c.useEffect)(()=>{z("product-list-render",{products:L,listName:Y})},[L,Y,z]),Object(c.useEffect)(()=>{Object(s.isEqual)(q,null==Q?void 0:Q.totalQuery)||(o(1),null!=Q&&Q.totalQuery&&(e=>{Number.isFinite(e)&&(0===e?Object(w.speak)(Object(a.__)("No products found","woo-gutenberg-products-block")):Object(w.speak)(Object(a.sprintf)(
|
8 |
/* translators: %s is an integer higher than 0 (1, 2, 3...) */
|
9 |
+
Object(a._n)("%d product found","%d products found",e,"woo-gutenberg-products-block"),e)))})(M))},[null==Q?void 0:Q.totalQuery,M,o,q]);const{contentVisibility:D}=t,G=t.columns*t.rows,U=!Number.isFinite(M)&&Number.isFinite(null==Q?void 0:Q.totalProducts)&&Object(s.isEqual)(q,null==Q?void 0:Q.totalQuery)?Math.ceil(((null==Q?void 0:Q.totalProducts)||0)/G):Math.ceil(M/G),V=L.length?L:Array.from({length:G}),H=0!==L.length||I,K=E.length>0||O.length>0||y.length>0||Number.isFinite(S)||Number.isFinite(P);return Object(c.createElement)("div",{className:(()=>{const{columns:e,rows:r,alignButtons:c,align:o}=t,n=void 0!==o?"align"+o:"";return i()(F,n,"has-"+e+"-columns",{"has-multiple-rows":r>1,"has-aligned-buttons":c})})()},(null==D?void 0:D.orderBy)&&H&&Object(c.createElement)(v,{onChange:n,value:l}),!H&&K&&Object(c.createElement)(k,{resetCallback:()=>{f([]),j([]),x([]),C(null),N(null)}}),!H&&!K&&Object(c.createElement)(_,null),H&&Object(c.createElement)("ul",{className:i()(F+"__products",{"is-loading-products":I})},V.map((function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;return Object(c.createElement)(T,{key:e.id||r,attributes:t,product:e})}))),U>1&&Object(c.createElement)(d,{currentPage:r,onPageChange:e=>{u({focusableSelector:"a, button"}),o(e)},totalPages:U}))}),M=e=>{let{attributes:t}=e;const[r,o]=Object(c.useState)(1),[n,a]=Object(c.useState)(t.orderby);return Object(c.useEffect)(()=>{a(t.orderby)},[t.orderby]),Object(c.createElement)(L,{attributes:t,currentPage:r,onPageChange:e=>{o(e)},onSortChange:e=>{var t;const r=null==e||null===(t=e.target)||void 0===t?void 0:t.value;a(r),o(1)},sortValue:n})};const I=Object(c.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 230 250",style:{width:"100%"}},Object(c.createElement)("title",null,"Grid Block Preview"),Object(c.createElement)("rect",{width:"65.374",height:"65.374",x:".162",y:".779",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(c.createElement)("rect",{width:"62.8",height:"15",x:"1.565",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(c.createElement)("rect",{width:"65.374",height:"65.374",x:".162",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(c.createElement)("rect",{width:"62.8",height:"15",x:"1.565",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(c.createElement)("rect",{width:"65.374",height:"65.374",x:"82.478",y:".779",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(c.createElement)("rect",{width:"62.8",height:"15",x:"83.882",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(c.createElement)("rect",{width:"65.374",height:"65.374",x:"82.478",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(c.createElement)("rect",{width:"62.8",height:"15",x:"83.882",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(c.createElement)("rect",{width:"65.374",height:"65.374",x:"164.788",y:".779",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(c.createElement)("rect",{width:"62.8",height:"15",x:"166.192",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(c.createElement)("rect",{width:"65.374",height:"65.374",x:"164.788",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(c.createElement)("rect",{width:"62.8",height:"15",x:"166.192",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(c.createElement)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"221.798",fill:"#E1E3E6",rx:"3"}));var F=r(9);class Y extends n.Component{render(){const{attributes:e,urlParameterSuffix:t}=this.props;return e.isPreview?I:Object(c.createElement)(h.InnerBlockLayoutContextProvider,{parentName:"woocommerce/all-products",parentClassName:"wc-block-grid"},Object(c.createElement)(F.StoreNoticesContainer,{context:"wc/all-products"}),Object(c.createElement)(M,{attributes:e,urlParameterSuffix:t}))}}var q=Y;Object(o.a)({selector:".wp-block-woocommerce-all-products",Block:e=>Object(c.createElement)(q,e),getProps:e=>({attributes:JSON.parse(e.dataset.attributes)})})},27:function(e,t){e.exports=window.wp.deprecated},275:function(e,t,r){"use strict";r.d(t,"a",(function(){return s}));var c=r(55),o=r(3),n=r(5),a=r(26);const s=e=>{const t={namespace:"/wc/store/v1",resourceName:"products"},{results:r,isLoading:s}=Object(c.a)({...t,query:e}),{value:l}=((e,t)=>{const{namespace:r,resourceName:c,resourceValues:s=[],query:l={}}=t;if(!r||!c)throw new Error("The options object must have valid values for the namespace and the resource name properties.");const i=Object(a.a)(l),u=Object(a.a)(s),{value:d,isLoading:b=!0}=Object(n.useSelect)(e=>{const t=e(o.COLLECTIONS_STORE_KEY),n=["x-wp-total",r,c,i,u];return{value:t.getCollectionHeader(...n),isLoading:t.hasFinishedResolution("getCollectionHeader",n)}},["x-wp-total",r,c,u,i]);return{value:d,isLoading:b}})(0,{...t,query:e});return{products:r,totalProducts:parseInt(l,10),productsLoading:s}}},28:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));const c=e=>"string"==typeof e},29:function(e,t){e.exports=window.wp.a11y},3:function(e,t){e.exports=window.wc.wcBlocksData},30:function(e,t,r){"use strict";r.d(t,"a",(function(){return d})),r.d(t,"b",(function(){return b})),r.d(t,"c",(function(){return p}));var c=r(3),o=r(5),n=r(0),a=r(12),s=r.n(a),l=r(26),i=r(56),u=r(23);const d=e=>{const t=Object(u.a)();e=e||t;const r=Object(o.useSelect)(t=>t(c.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0),[e]),{setValueForQueryContext:a}=Object(o.useDispatch)(c.QUERY_STATE_STORE_KEY);return[r,Object(n.useCallback)(t=>{a(e,t)},[e,a])]},b=(e,t,r)=>{const a=Object(u.a)();r=r||a;const s=Object(o.useSelect)(o=>o(c.QUERY_STATE_STORE_KEY).getValueForQueryKey(r,e,t),[r,e]),{setQueryValue:l}=Object(o.useDispatch)(c.QUERY_STATE_STORE_KEY);return[s,Object(n.useCallback)(t=>{l(r,e,t)},[r,e,l])]},p=(e,t)=>{const r=Object(u.a)();t=t||r;const[c,o]=d(t),a=Object(l.a)(c),b=Object(l.a)(e),p=Object(i.a)(b),m=Object(n.useRef)(!1);return Object(n.useEffect)(()=>{s()(p,b)||(o(Object.assign({},a,b)),m.current=!0)},[a,b,p,o]),m.current?[c,o]:[e,o]}},32:function(e,t){e.exports=window.wp.apiFetch},34:function(e,t){},35:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));var c=r(0);r(5);const o=Object(c.createContext)({isEditor:!1,currentPostId:0,currentView:"",previewData:{},getPreviewData:()=>{}}),n=()=>Object(c.useContext)(o)},36:function(e,t,r){"use strict";r.d(t,"a",(function(){return f}));var c=r(8),o=r(0),n=r(3),a=r(5),s=r(22),l=r(127),i=r(35),u=r(85);const d=e=>{const t=e.detail;t&&t.preserveCartData||Object(a.dispatch)(n.CART_STORE_KEY).invalidateResolutionForStore()},b=()=>{1===window.wcBlocksStoreCartListeners.count&&window.wcBlocksStoreCartListeners.remove(),window.wcBlocksStoreCartListeners.count--},p=()=>{Object(o.useEffect)(()=>((()=>{if(window.wcBlocksStoreCartListeners||(window.wcBlocksStoreCartListeners={count:0,remove:()=>{}}),0===window.wcBlocksStoreCartListeners.count){const e=Object(u.b)("added_to_cart","wc-blocks_added_to_cart"),t=Object(u.b)("removed_from_cart","wc-blocks_removed_from_cart");document.body.addEventListener("wc-blocks_added_to_cart",d),document.body.addEventListener("wc-blocks_removed_from_cart",d),window.wcBlocksStoreCartListeners.count=0,window.wcBlocksStoreCartListeners.remove=()=>{e(),t(),document.body.removeEventListener("wc-blocks_added_to_cart",d),document.body.removeEventListener("wc-blocks_removed_from_cart",d)}}window.wcBlocksStoreCartListeners.count++})(),b),[])},m={first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:""},g={...m,email:""},E={total_items:"",total_items_tax:"",total_fees:"",total_fees_tax:"",total_discount:"",total_discount_tax:"",total_shipping:"",total_shipping_tax:"",total_price:"",total_tax:"",tax_lines:n.EMPTY_TAX_LINES,currency_code:"",currency_symbol:"",currency_minor_unit:2,currency_decimal_separator:"",currency_thousand_separator:"",currency_prefix:"",currency_suffix:""},h=e=>Object.fromEntries(Object.entries(e).map(e=>{let[t,r]=e;return[t,Object(s.decodeEntities)(r)]})),w={cartCoupons:n.EMPTY_CART_COUPONS,cartItems:n.EMPTY_CART_ITEMS,cartFees:n.EMPTY_CART_FEES,cartItemsCount:0,cartItemsWeight:0,crossSellsProducts:n.EMPTY_CART_CROSS_SELLS,cartNeedsPayment:!0,cartNeedsShipping:!0,cartItemErrors:n.EMPTY_CART_ITEM_ERRORS,cartTotals:E,cartIsLoading:!0,cartErrors:n.EMPTY_CART_ERRORS,billingAddress:g,shippingAddress:m,shippingRates:n.EMPTY_SHIPPING_RATES,isLoadingRates:!1,cartHasCalculatedShipping:!1,paymentRequirements:n.EMPTY_PAYMENT_REQUIREMENTS,receiveCart:()=>{},extensions:n.EMPTY_EXTENSIONS},f=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{shouldSelect:!0};const{isEditor:t,previewData:r}=Object(i.a)(),s=null==r?void 0:r.previewCart,{shouldSelect:u}=e,d=Object(o.useRef)();p();const b=Object(a.useSelect)((e,r)=>{let{dispatch:c}=r;if(!u)return w;if(t)return{cartCoupons:s.coupons,cartItems:s.items,crossSellsProducts:s.cross_sells,cartFees:s.fees,cartItemsCount:s.items_count,cartItemsWeight:s.items_weight,cartNeedsPayment:s.needs_payment,cartNeedsShipping:s.needs_shipping,cartItemErrors:n.EMPTY_CART_ITEM_ERRORS,cartTotals:s.totals,cartIsLoading:!1,cartErrors:n.EMPTY_CART_ERRORS,billingData:g,billingAddress:g,shippingAddress:m,extensions:n.EMPTY_EXTENSIONS,shippingRates:s.shipping_rates,isLoadingRates:!1,cartHasCalculatedShipping:s.has_calculated_shipping,paymentRequirements:s.paymentRequirements,receiveCart:"function"==typeof(null==s?void 0:s.receiveCart)?s.receiveCart:()=>{}};const o=e(n.CART_STORE_KEY),a=o.getCartData(),i=o.getCartErrors(),d=o.getCartTotals(),b=!o.hasFinishedResolution("getCartData"),p=o.isCustomerDataUpdating(),{receiveCart:E}=c(n.CART_STORE_KEY),f=h(a.billingAddress),O=a.needsShipping?h(a.shippingAddress):f,j=a.fees.length>0?a.fees.map(e=>h(e)):n.EMPTY_CART_FEES;return{cartCoupons:a.coupons.length>0?a.coupons.map(e=>({...e,label:e.code})):n.EMPTY_CART_COUPONS,cartItems:a.items,crossSellsProducts:a.crossSells,cartFees:j,cartItemsCount:a.itemsCount,cartItemsWeight:a.itemsWeight,cartNeedsPayment:a.needsPayment,cartNeedsShipping:a.needsShipping,cartItemErrors:a.errors,cartTotals:d,cartIsLoading:b,cartErrors:i,billingData:Object(l.a)(f),billingAddress:Object(l.a)(f),shippingAddress:Object(l.a)(O),extensions:a.extensions,shippingRates:a.shippingRates,isLoadingRates:p,cartHasCalculatedShipping:a.hasCalculatedShipping,paymentRequirements:a.paymentRequirements,receiveCart:E}},[u]);return d.current&&Object(c.isEqual)(d.current,b)||(d.current=b),d.current}},38:function(e,t){e.exports=window.wc.priceFormat},42:function(e,t,r){"use strict";r.d(t,"n",(function(){return n})),r.d(t,"l",(function(){return a})),r.d(t,"k",(function(){return s})),r.d(t,"m",(function(){return l})),r.d(t,"i",(function(){return i})),r.d(t,"d",(function(){return u})),r.d(t,"f",(function(){return d})),r.d(t,"j",(function(){return b})),r.d(t,"c",(function(){return p})),r.d(t,"e",(function(){return m})),r.d(t,"g",(function(){return g})),r.d(t,"a",(function(){return E})),r.d(t,"h",(function(){return h})),r.d(t,"b",(function(){return w}));var c,o=r(2);const n=Object(o.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),a=n.pluginUrl+"images/",s=n.pluginUrl+"build/",l=n.buildPhase,i=null===(c=o.STORE_PAGES.shop)||void 0===c?void 0:c.permalink,u=(o.STORE_PAGES.checkout.id,o.STORE_PAGES.checkout.permalink),d=o.STORE_PAGES.privacy.permalink,b=(o.STORE_PAGES.privacy.title,o.STORE_PAGES.terms.permalink),p=(o.STORE_PAGES.terms.title,o.STORE_PAGES.cart.id,o.STORE_PAGES.cart.permalink),m=o.STORE_PAGES.myaccount.permalink?o.STORE_PAGES.myaccount.permalink:Object(o.getSetting)("wpLoginUrl","/wp-login.php"),g=Object(o.getSetting)("shippingCountries",{}),E=Object(o.getSetting)("allowedCountries",{}),h=Object(o.getSetting)("shippingStates",{}),w=Object(o.getSetting)("allowedStates",{})},43:function(e,t){e.exports=window.wp.warning},44:function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var c=r(13),o=r.n(c),n=r(0),a=r(14);const s=[".wp-block-woocommerce-cart"],l=e=>{let{Block:t,containers:r,getProps:c=(()=>({})),getErrorBoundaryProps:s=(()=>({}))}=e;0!==r.length&&Array.prototype.forEach.call(r,(e,r)=>{const l=c(e,r),i=s(e,r),u={...e.dataset,...l.attributes||{}};(e=>{let{Block:t,container:r,attributes:c={},props:s={},errorBoundaryProps:l={}}=e;Object(n.render)(Object(n.createElement)(a.a,l,Object(n.createElement)(n.Suspense,{fallback:Object(n.createElement)("div",{className:"wc-block-placeholder"})},t&&Object(n.createElement)(t,o()({},s,{attributes:c})))),r,()=>{r.classList&&r.classList.remove("is-loading")})})({Block:t,container:e,props:l,attributes:u,errorBoundaryProps:i})})},i=e=>{const t=document.body.querySelectorAll(s.join(",")),{Block:r,getProps:c,getErrorBoundaryProps:o,selector:n}=e;(e=>{let{Block:t,getProps:r,getErrorBoundaryProps:c,selector:o,wrappers:n}=e;const a=document.body.querySelectorAll(o);n&&n.length>0&&Array.prototype.filter.call(a,e=>!((e,t)=>Array.prototype.some.call(t,t=>t.contains(e)&&!t.isSameNode(e)))(e,n)),l({Block:t,containers:a,getProps:r,getErrorBoundaryProps:c})})({Block:r,getProps:c,getErrorBoundaryProps:o,selector:n,wrappers:t}),Array.prototype.forEach.call(t,t=>{t.addEventListener("wc-blocks_render_blocks_frontend",()=>{(e=>{let{Block:t,getProps:r,getErrorBoundaryProps:c,selector:o,wrapper:n}=e;const a=n.querySelectorAll(o);l({Block:t,containers:a,getProps:r,getErrorBoundaryProps:c})})({...e,wrapper:t})})})}},45:function(e,t){e.exports=window.wp.hooks},46:function(e,t){e.exports=window.wc.wcBlocksSharedContext},5:function(e,t){e.exports=window.wp.data},51:function(e,t,r){"use strict";var c=r(2),o=r(1),n=r(87),a=r(28);const s=Object(c.getSetting)("countryLocale",{}),l=e=>{const t={};return void 0!==e.label&&(t.label=e.label),void 0!==e.required&&(t.required=e.required),void 0!==e.hidden&&(t.hidden=e.hidden),void 0===e.label||e.optionalLabel||(t.optionalLabel=Object(o.sprintf)(
|
10 |
+
/* translators: %s Field label. */
|
11 |
+
Object(o.__)("%s (optional)","woo-gutenberg-products-block"),e.label)),e.priority&&(Object(n.a)(e.priority)&&(t.index=e.priority),Object(a.a)(e.priority)&&(t.index=parseInt(e.priority,10))),e.hidden&&(t.required=!1),t},i=Object.entries(s).map(e=>{let[t,r]=e;return[t,Object.entries(r).map(e=>{let[t,r]=e;return[t,l(r)]}).reduce((e,t)=>{let[r,c]=t;return e[r]=c,e},{})]}).reduce((e,t)=>{let[r,c]=t;return e[r]=c,e},{});t.a=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";const o=r&&void 0!==i[r]?i[r]:{};return e.map(e=>({key:e,...c.defaultAddressFields[e]||{},...o[e]||{},...t[e]||{}})).sort((e,t)=>e.index-t.index)}},55:function(e,t,r){"use strict";r.d(t,"a",(function(){return l}));var c=r(3),o=r(5),n=r(0),a=r(26),s=r(70);const l=e=>{const{namespace:t,resourceName:r,resourceValues:l=[],query:i={},shouldSelect:u=!0}=e;if(!t||!r)throw new Error("The options object must have valid values for the namespace and the resource properties.");const d=Object(n.useRef)({results:[],isLoading:!0}),b=Object(a.a)(i),p=Object(a.a)(l),m=Object(s.a)(),g=Object(o.useSelect)(e=>{if(!u)return null;const o=e(c.COLLECTIONS_STORE_KEY),n=[t,r,b,p],a=o.getCollectionError(...n);if(a){if(!(a instanceof Error))throw new Error("TypeError: `error` object is not an instance of Error constructor");m(a)}return{results:o.getCollection(...n),isLoading:!o.hasFinishedResolution("getCollection",n)}},[t,r,p,b,u]);return null!==g&&(d.current=g),d.current}},56:function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var c=r(6);function o(e,t){const r=Object(c.useRef)();return Object(c.useEffect)(()=>{r.current===e||t&&!t(e,r.current)||(r.current=e)},[e,t]),r.current}},59:function(e,t){e.exports=window.wp.dom},6:function(e,t){e.exports=window.React},64:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var c=r(45),o=r(0),n=r(36);const a=()=>{const e=Object(n.a)(),t=Object(o.useRef)(e);return Object(o.useEffect)(()=>{t.current=e},[e]),{dispatchStoreEvent:Object(o.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(c.doAction)("experimental__woocommerce_blocks-"+e,t)}catch(e){console.error(e)}}),[]),dispatchCheckoutEvent:Object(o.useCallback)((function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(c.doAction)("experimental__woocommerce_blocks-checkout-"+e,{...r,storeCart:t.current})}catch(e){console.error(e)}}),[])}}},7:function(e,t,r){var c;!function(){"use strict";var r={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var c=arguments[t];if(c){var n=typeof c;if("string"===n||"number"===n)e.push(c);else if(Array.isArray(c)){if(c.length){var a=o.apply(null,c);a&&e.push(a)}}else if("object"===n)if(c.toString===Object.prototype.toString)for(var s in c)r.call(c,s)&&c[s]&&e.push(s);else e.push(c.toString())}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(c=function(){return o}.apply(t,[]))||(e.exports=c)}()},70:function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var c=r(0);const o=()=>{const[,e]=Object(c.useState)();return Object(c.useCallback)(t=>{e(()=>{throw t})},[])}},8:function(e,t){e.exports=window.lodash},85:function(e,t,r){"use strict";r.d(t,"a",(function(){return o})),r.d(t,"c",(function(){return n})),r.d(t,"b",(function(){return a}));const c=window.CustomEvent||null,o=(e,t)=>{let{bubbles:r=!1,cancelable:o=!1,element:n,detail:a={}}=t;if(!c)return;n||(n=document.body);const s=new c(e,{bubbles:r,cancelable:o,detail:a});n.dispatchEvent(s)},n=e=>{let{preserveCartData:t=!1}=e;o("wc-blocks_added_to_cart",{bubbles:!0,cancelable:!0,detail:{preserveCartData:t}})},a=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],c=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("function"!=typeof jQuery)return()=>{};const n=()=>{o(t,{bubbles:r,cancelable:c})};return jQuery(document).on(e,n),()=>jQuery(document).off(e,n)}},87:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));const c=e=>"number"==typeof e},9:function(e,t){e.exports=window.wc.blocksCheckout},93:function(e,t,r){"use strict";var c=r(13),o=r.n(c),n=r(0);r(116);const a=e=>{if(!e)return;const t=e.getBoundingClientRect().bottom;t>=0&&t<=window.innerHeight||e.scrollIntoView()};t.a=e=>t=>{const r=Object(n.useRef)(null);return Object(n.createElement)(n.Fragment,null,Object(n.createElement)("div",{className:"with-scroll-to-top__scroll-point",ref:r,"aria-hidden":!0}),Object(n.createElement)(e,o()({},t,{scrollToTop:e=>{null!==r.current&&((e,t)=>{const{focusableSelector:r}=t||{};window&&Number.isFinite(window.innerHeight)&&(r?((e,t)=>{var r;const c=(null===(r=e.parentElement)||void 0===r?void 0:r.querySelectorAll(t))||[];if(c.length){const e=c[0];a(e),null==e||e.focus()}else a(e)})(e,r):a(e))})(r.current,e)}})))}},94:function(e,t){e.exports=window.wp.blocks}});
|
build/all-products.asset.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php return array('dependencies' => array('lodash', 'react', 'wc-blocks-data-store', 'wc-blocks-registry', 'wc-blocks-shared-context', 'wc-blocks-shared-hocs', 'wc-price-format', 'wc-settings', 'wp-a11y', 'wp-api-fetch', 'wp-autop', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-deprecated', 'wp-dom', 'wp-element', 'wp-escape-html', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-polyfill', 'wp-primitives', 'wp-url', 'wp-warning', 'wp-wordcount'), 'version' => '
|
1 |
+
<?php return array('dependencies' => array('lodash', 'react', 'wc-blocks-checkout', 'wc-blocks-data-store', 'wc-blocks-registry', 'wc-blocks-shared-context', 'wc-blocks-shared-hocs', 'wc-price-format', 'wc-settings', 'wp-a11y', 'wp-api-fetch', 'wp-autop', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-deprecated', 'wp-dom', 'wp-element', 'wp-escape-html', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-polyfill', 'wp-primitives', 'wp-url', 'wp-warning', 'wp-wordcount'), 'version' => '6d2b5ee5774ede8100c03077d20f55a1');
|
build/all-products.js
CHANGED
@@ -1,36 +1,36 @@
|
|
1 |
-
this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["all-products"]=function(e){function t(t){for(var r,a,s=t[0],l=t[1],i=t[2],d=0,b=[];d<s.length;d++)a=s[d],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&b.push(o[a][0]),o[a]=0;for(r in l)Object.prototype.hasOwnProperty.call(l,r)&&(e[r]=l[r]);for(u&&u(t);b.length;)b.shift()();return n.push.apply(n,i||[]),c()}function c(){for(var e,t=0;t<n.length;t++){for(var c=n[t],r=!0,s=1;s<c.length;s++){var l=c[s];0!==o[l]&&(r=!1)}r&&(n.splice(t--,1),e=a(a.s=c[0]))}return e}var r={},o={6:0,1:0,2:0,3:0,4:0,21:0,24:0,28:0,30:0,31:0,33:0,34:0,35:0,37:0},n=[];function a(t){if(r[t])return r[t].exports;var c=r[t]={i:t,l:!1,exports:{}};return e[t].call(c.exports,c,c.exports,a),c.l=!0,c.exports}a.e=function(e){var t=[],c=o[e];if(0!==c)if(c)t.push(c[2]);else{var r=new Promise((function(t,r){c=o[e]=[t,r]}));t.push(c[2]=r);var n,s=document.createElement("script");s.charset="utf-8",s.timeout=120,a.nc&&s.setAttribute("nonce",a.nc),s.src=function(e){return a.p+""+({1:"product-add-to-cart--product-button--product-category-list--product-image--product-price--product-r--a0326d00",2:"product-button--product-category-list--product-image--product-price--product-rating--product-sale-b--e17c7c01",3:"product-add-to-cart--product-button--product-image--product-rating--product-title",4:"product-button--product-image--product-rating--product-sale-badge--product-title",19:"product-add-to-cart",21:"product-button",24:"product-category-list",25:"product-image",28:"product-price",30:"product-rating",31:"product-sale-badge",33:"product-sku",34:"product-stock-indicator",35:"product-summary",37:"product-tag-list",38:"product-title"}[e]||e)+".js?ver="+{1:"
|
2 |
/* Translators: %s search term */
|
3 |
noResults:Object(n.__)("No results for %s","woo-gutenberg-products-block"),search:Object(n.__)("Search for items","woo-gutenberg-products-block"),selected:e=>Object(n.sprintf)(
|
4 |
/* translators: Number of items selected from list. */
|
5 |
-
Object(n._n)("%d item selected","%d items selected",e,"woo-gutenberg-products-block"),e),updated:Object(n.__)("Search results updated.","woo-gutenberg-products-block")},s=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;const c=Object(o.groupBy)(e,"parent"),r=Object(o.keyBy)(t,"id"),n=["0"],a=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e.parent)return e.name?[e.name]:[];const t=a(r[e.parent]);return[...t,e.name]},s=e=>e.map(e=>{const t=c[e.id];return n.push(""+e.id),{...e,breadcrumbs:a(r[e.parent]),children:t&&t.length?s(t):[]}}),l=s(c[0]||[]);return Object.entries(c).forEach(e=>{let[t,c]=e;n.includes(t)||l.push(...s(c||[]))}),l},l=(e,t,c)=>{if(!t)return c?s(e):e;const r=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),o=e.map(e=>!!r.test(e.name)&&e).filter(Boolean);return c?s(o,e):o},i=(e,t)=>{if(!t)return e;const c=new RegExp(`(${t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")})`,"ig");return e.split(c).map((e,t)=>c.test(e)?Object(r.createElement)("strong",{key:t},e):Object(r.createElement)(r.Fragment,{key:t},e))},u=e=>1===e.length?e.slice(0,1).toString():2===e.length?e.slice(0,1).toString()+" › "+e.slice(-1).toString():e.slice(0,1).toString()+" … "+e.slice(-1).toString()},,,function(e,t,c){"use strict";c.d(t,"o",(function(){return n})),c.d(t,"m",(function(){return a})),c.d(t,"l",(function(){return s})),c.d(t,"n",(function(){return l})),c.d(t,"j",(function(){return i})),c.d(t,"e",(function(){return u})),c.d(t,"f",(function(){return d})),c.d(t,"g",(function(){return b})),c.d(t,"k",(function(){return p})),c.d(t,"c",(function(){return m})),c.d(t,"d",(function(){return g})),c.d(t,"h",(function(){return O})),c.d(t,"a",(function(){return j})),c.d(t,"i",(function(){return h})),c.d(t,"b",(function(){return _}));var r,o=c(2);const n=Object(o.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),a=n.pluginUrl+"images/",s=n.pluginUrl+"build/",l=n.buildPhase,i=null===(r=o.STORE_PAGES.shop)||void 0===r?void 0:r.permalink,u=o.STORE_PAGES.checkout.id,d=o.STORE_PAGES.checkout.permalink,b=o.STORE_PAGES.privacy.permalink,p=(o.STORE_PAGES.privacy.title,o.STORE_PAGES.terms.permalink),m=(o.STORE_PAGES.terms.title,o.STORE_PAGES.cart.id),g=o.STORE_PAGES.cart.permalink,O=(o.STORE_PAGES.myaccount.permalink?o.STORE_PAGES.myaccount.permalink:Object(o.getSetting)("wpLoginUrl","/wp-login.php"),Object(o.getSetting)("shippingCountries",{})),j=Object(o.getSetting)("allowedCountries",{}),h=Object(o.getSetting)("shippingStates",{}),_=Object(o.getSetting)("allowedStates",{})},function(e,t){e.exports=window.wc.wcBlocksSharedContext},,function(e,t){e.exports=window.wp.isShallowEqual},function(e,t){e.exports=window.wc.priceFormat},function(e,t,c){"use strict";c.d(t,"h",(function(){return i})),c.d(t,"e",(function(){return u})),c.d(t,"b",(function(){return d})),c.d(t,"i",(function(){return b})),c.d(t,"f",(function(){return p})),c.d(t,"c",(function(){return m})),c.d(t,"d",(function(){return g})),c.d(t,"g",(function(){return O})),c.d(t,"a",(function(){return j}));var r=c(16),o=c(14),n=c.n(o),a=c(8),s=c(2),l=c(22);const i=e=>{let{selected:t=[],search:c="",queryArgs:o={}}=e;const s=(e=>{let{selected:t=[],search:c="",queryArgs:o={}}=e;const n=l.o.productCount>100,a={per_page:n?100:0,catalog_visibility:"any",search:c,orderby:"title",order:"asc"},s=[Object(r.addQueryArgs)("/wc/store/v1/products",{...a,...o})];return n&&t.length&&s.push(Object(r.addQueryArgs)("/wc/store/v1/products",{catalog_visibility:"any",include:t,per_page:0})),s})({selected:t,search:c,queryArgs:o});return Promise.all(s.map(e=>n()({path:e}))).then(e=>Object(a.uniqBy)(Object(a.flatten)(e),"id").map(e=>({...e,parent:0}))).catch(e=>{throw e})},u=e=>n()({path:"/wc/store/v1/products/"+e}),d=()=>n()({path:"wc/store/v1/products/attributes"}),b=e=>n()({path:`wc/store/v1/products/attributes/${e}/terms`}),p=e=>{let{selected:t=[],search:c}=e;const o=(e=>{let{selected:t=[],search:c}=e;const o=Object(s.getSetting)("limitTags",!1),n=[Object(r.addQueryArgs)("wc/store/v1/products/tags",{per_page:o?100:0,orderby:o?"count":"name",order:o?"desc":"asc",search:c})];return o&&t.length&&n.push(Object(r.addQueryArgs)("wc/store/v1/products/tags",{include:t})),n})({selected:t,search:c});return Promise.all(o.map(e=>n()({path:e}))).then(e=>Object(a.uniqBy)(Object(a.flatten)(e),"id"))},m=e=>n()({path:Object(r.addQueryArgs)("wc/store/v1/products/categories",{per_page:0,...e})}),g=e=>n()({path:"wc/store/v1/products/categories/"+e}),O=e=>n()({path:Object(r.addQueryArgs)("wc/store/v1/products",{per_page:0,type:"variation",parent:e})}),j=(e,t)=>{if(!e.title.raw)return e.slug;const c=1===t.filter(t=>t.title.raw===e.title.raw).length;return e.title.raw+(c?"":" - "+e.slug)}},function(e,t,c){"use strict";var r=c(0),o=c(4),n=c.n(o);t.a=e=>{let t,{label:c,screenReaderLabel:o,wrapperElement:a,wrapperProps:s={}}=e;const l=null!=c,i=null!=o;return!l&&i?(t=a||"span",s={...s,className:n()(s.className,"screen-reader-text")},Object(r.createElement)(t,s,o)):(t=a||r.Fragment,l&&i&&c!==o?Object(r.createElement)(t,s,Object(r.createElement)("span",{"aria-hidden":"true"},c),Object(r.createElement)("span",{className:"screen-reader-text"},o)):Object(r.createElement)(t,s,c))}},function(e,t,c){"use strict";c.d(t,"a",(function(){return n})),c.d(t,"b",(function(){return a}));var r=c(1),o=c(15);const n=async e=>{if("function"==typeof e.json)try{const t=await e.json();return{message:t.message,type:t.type||"api"}}catch(e){return{message:e.message,type:"general"}}return{message:e.message,type:e.type||"general"}},a=e=>{if(e.data&&"rest_invalid_param"===e.code){const t=Object.values(e.data.params);if(t[0])return t[0]}return null!=e&&e.message?Object(o.decodeEntities)(e.message):Object(r.__)("Something went wrong. Please contact us to get assistance.","woo-gutenberg-products-block")}},,,,function(e,t,c){"use strict";var r=c(0),o=c(1),n=c(34);t.a=e=>{let{error:t}=e;return Object(r.createElement)("div",{className:"wc-block-error-message"},(e=>{let{message:t,type:c}=e;return t?"general"===c?Object(r.createElement)("span",null,Object(o.__)("The following error was returned","woo-gutenberg-products-block"),Object(r.createElement)("br",null),Object(r.createElement)("code",null,Object(n.escapeHTML)(t))):"api"===c?Object(r.createElement)("span",null,Object(o.__)("The following error was returned from the API","woo-gutenberg-products-block"),Object(r.createElement)("br",null),Object(r.createElement)("code",null,Object(n.escapeHTML)(t))):t:Object(o.__)("An error has prevented the block from being updated.","woo-gutenberg-products-block")})(t))}},function(e,t){e.exports=window.wp.escapeHtml},function(e,t,c){"use strict";c.d(t,"a",(function(){return r})),c.d(t,"b",(function(){return o}));const r=e=>!(e=>null===e)(e)&&e instanceof Object&&e.constructor===Object;function o(e,t){return r(e)&&t in e}},function(e,t){e.exports=window.wc.wcBlocksRegistry},function(e,t,c){"use strict";c.d(t,"a",(function(){return s}));var r=c(6),o=c.n(r),n=c(0),a=c(19);const s=e=>{let{countLabel:t,className:c,depth:r=0,controlId:s="",item:l,isSelected:i,isSingle:u,onSelect:d,search:b="",...p}=e;const m=null!=t&&void 0!==l.count&&null!==l.count,g=[c,"woocommerce-search-list__item"];g.push("depth-"+r),u&&g.push("is-radio-button"),m&&g.push("has-count");const O=l.breadcrumbs&&l.breadcrumbs.length,j=p.name||"search-list-item-"+s,h=`${j}-${l.id}`;return Object(n.createElement)("label",{htmlFor:h,className:g.join(" ")},u?Object(n.createElement)("input",o()({type:"radio",id:h,name:j,value:l.value,onChange:d(l),checked:i,className:"woocommerce-search-list__item-input"},p)):Object(n.createElement)("input",o()({type:"checkbox",id:h,name:j,value:l.value,onChange:d(l),checked:i,className:"woocommerce-search-list__item-input"},p)),Object(n.createElement)("span",{className:"woocommerce-search-list__item-label"},O?Object(n.createElement)("span",{className:"woocommerce-search-list__item-prefix"},Object(a.b)(l.breadcrumbs)):null,Object(n.createElement)("span",{className:"woocommerce-search-list__item-name"},Object(a.d)(l.name,b))),!!m&&Object(n.createElement)("span",{className:"woocommerce-search-list__item-count"},t||l.count))};t.b=s},function(e,t,c){"use strict";var r=c(6),o=c.n(r),n=c(0),a=c(133),s=c(4),l=c.n(s);c(139);const i=e=>({thousandSeparator:e.thousandSeparator,decimalSeparator:e.decimalSeparator,decimalScale:e.minorUnit,fixedDecimalScale:!0,prefix:e.prefix,suffix:e.suffix,isNumericString:!0});t.a=e=>{let{className:t,value:c,currency:r,onValueChange:s,displayType:u="text",...d}=e;const b="string"==typeof c?parseInt(c,10):c;if(!Number.isFinite(b))return null;const p=b/10**r.minorUnit;if(!Number.isFinite(p))return null;const m=l()("wc-block-formatted-money-amount","wc-block-components-formatted-money-amount",t),g={...d,...i(r),value:void 0,currency:void 0,onValueChange:void 0},O=s?e=>{const t=+e.value*10**r.minorUnit;s(t)}:()=>{};return Object(n.createElement)(a.a,o()({className:m,displayType:u},g,{value:p,onValueChange:O}))}},,function(e,t,c){"use strict";c.d(t,"a",(function(){return a}));var r=c(0),o=c(25),n=c.n(o);function a(e){const t=Object(r.useRef)(e);return n()(e,t.current)||(t.current=e),t.current}},function(e,t,c){"use strict";c.d(t,"a",(function(){return _}));var r=c(8),o=c(0),n=c(9),a=c(7),s=c(15),l=c(261),i=c(82),u=c(260);const d=e=>{const t=e.detail;t&&t.preserveCartData||Object(a.dispatch)(n.CART_STORE_KEY).invalidateResolutionForStore()},b=()=>{1===window.wcBlocksStoreCartListeners.count&&window.wcBlocksStoreCartListeners.remove(),window.wcBlocksStoreCartListeners.count--},p=()=>{Object(o.useEffect)(()=>((()=>{if(window.wcBlocksStoreCartListeners||(window.wcBlocksStoreCartListeners={count:0,remove:()=>{}}),0===window.wcBlocksStoreCartListeners.count){const e=Object(u.a)("added_to_cart","wc-blocks_added_to_cart"),t=Object(u.a)("removed_from_cart","wc-blocks_removed_from_cart");document.body.addEventListener("wc-blocks_added_to_cart",d),document.body.addEventListener("wc-blocks_removed_from_cart",d),window.wcBlocksStoreCartListeners.count=0,window.wcBlocksStoreCartListeners.remove=()=>{e(),t(),document.body.removeEventListener("wc-blocks_added_to_cart",d),document.body.removeEventListener("wc-blocks_removed_from_cart",d)}}window.wcBlocksStoreCartListeners.count++})(),b),[])},m={first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:""},g={...m,email:""},O={total_items:"",total_items_tax:"",total_fees:"",total_fees_tax:"",total_discount:"",total_discount_tax:"",total_shipping:"",total_shipping_tax:"",total_price:"",total_tax:"",tax_lines:n.EMPTY_TAX_LINES,currency_code:"",currency_symbol:"",currency_minor_unit:2,currency_decimal_separator:"",currency_thousand_separator:"",currency_prefix:"",currency_suffix:""},j=e=>Object.fromEntries(Object.entries(e).map(e=>{let[t,c]=e;return[t,Object(s.decodeEntities)(c)]})),h={cartCoupons:n.EMPTY_CART_COUPONS,cartItems:n.EMPTY_CART_ITEMS,cartFees:n.EMPTY_CART_FEES,cartItemsCount:0,cartItemsWeight:0,crossSellsProducts:n.EMPTY_CART_CROSS_SELLS,cartNeedsPayment:!0,cartNeedsShipping:!0,cartItemErrors:n.EMPTY_CART_ITEM_ERRORS,cartTotals:O,cartIsLoading:!0,cartErrors:n.EMPTY_CART_ERRORS,billingAddress:g,shippingAddress:m,shippingRates:n.EMPTY_SHIPPING_RATES,isLoadingRates:!1,cartHasCalculatedShipping:!1,paymentRequirements:n.EMPTY_PAYMENT_REQUIREMENTS,receiveCart:()=>{},extensions:n.EMPTY_EXTENSIONS},_=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{shouldSelect:!0};const{isEditor:t,previewData:c}=Object(i.b)(),s=null==c?void 0:c.previewCart,{shouldSelect:u}=e,d=Object(o.useRef)();p();const b=Object(a.useSelect)((e,c)=>{let{dispatch:r}=c;if(!u)return h;if(t)return{cartCoupons:s.coupons,cartItems:s.items,crossSellsProducts:s.cross_sells,cartFees:s.fees,cartItemsCount:s.items_count,cartItemsWeight:s.items_weight,cartNeedsPayment:s.needs_payment,cartNeedsShipping:s.needs_shipping,cartItemErrors:n.EMPTY_CART_ITEM_ERRORS,cartTotals:s.totals,cartIsLoading:!1,cartErrors:n.EMPTY_CART_ERRORS,billingData:g,billingAddress:g,shippingAddress:m,extensions:n.EMPTY_EXTENSIONS,shippingRates:s.shipping_rates,isLoadingRates:!1,cartHasCalculatedShipping:s.has_calculated_shipping,paymentRequirements:s.paymentRequirements,receiveCart:"function"==typeof(null==s?void 0:s.receiveCart)?s.receiveCart:()=>{}};const o=e(n.CART_STORE_KEY),a=o.getCartData(),i=o.getCartErrors(),d=o.getCartTotals(),b=!o.hasFinishedResolution("getCartData"),p=o.isCustomerDataUpdating(),{receiveCart:O}=r(n.CART_STORE_KEY),_=j(a.billingAddress),E=a.needsShipping?j(a.shippingAddress):_,w=a.fees.length>0?a.fees.map(e=>j(e)):n.EMPTY_CART_FEES;return{cartCoupons:a.coupons.length>0?a.coupons.map(e=>({...e,label:e.code})):n.EMPTY_CART_COUPONS,cartItems:a.items,crossSellsProducts:a.crossSells,cartFees:w,cartItemsCount:a.itemsCount,cartItemsWeight:a.itemsWeight,cartNeedsPayment:a.needsPayment,cartNeedsShipping:a.needsShipping,cartItemErrors:a.errors,cartTotals:d,cartIsLoading:b,cartErrors:i,billingData:Object(l.a)(_),billingAddress:Object(l.a)(_),shippingAddress:Object(l.a)(E),extensions:a.extensions,shippingRates:a.shippingRates,isLoadingRates:p,cartHasCalculatedShipping:a.hasCalculatedShipping,paymentRequirements:a.paymentRequirements,receiveCart:O}},[u]);return d.current&&Object(r.isEqual)(d.current,b)||(d.current=b),d.current}},function(e,t){e.exports=window.wc.wcBlocksSharedHocs},,function(e,t){e.exports=window.wp.a11y},function(e,t){e.exports=window.wp.hooks},function(e,t,c){"use strict";c.d(t,"a",(function(){return n}));var r=c(0);const o=Object(r.createContext)("page"),n=()=>Object(r.useContext)(o);o.Provider},,,,,function(e,t){e.exports=window.wp.deprecated},function(e,t,c){"use strict";c.d(t,"a",(function(){return d})),c.d(t,"b",(function(){return b})),c.d(t,"c",(function(){return p}));var r=c(9),o=c(7),n=c(0),a=c(25),s=c.n(a),l=c(40),i=c(103),u=c(46);const d=e=>{const t=Object(u.a)();e=e||t;const c=Object(o.useSelect)(t=>t(r.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0),[e]),{setValueForQueryContext:a}=Object(o.useDispatch)(r.QUERY_STATE_STORE_KEY);return[c,Object(n.useCallback)(t=>{a(e,t)},[e,a])]},b=(e,t,c)=>{const a=Object(u.a)();c=c||a;const s=Object(o.useSelect)(o=>o(r.QUERY_STATE_STORE_KEY).getValueForQueryKey(c,e,t),[c,e]),{setQueryValue:l}=Object(o.useDispatch)(r.QUERY_STATE_STORE_KEY);return[s,Object(n.useCallback)(t=>{l(c,e,t)},[c,e,l])]},p=(e,t)=>{const c=Object(u.a)();t=t||c;const[r,o]=d(t),a=Object(l.a)(r),b=Object(l.a)(e),p=Object(i.a)(b),m=Object(n.useRef)(!1);return Object(n.useEffect)(()=>{s()(p,b)||(o(Object.assign({},a,b)),m.current=!0)},[a,b,p,o]),m.current?[r,o]:[e,o]}},,,,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return o})),c.d(t,"e",(function(){return n})),c.d(t,"d",(function(){return a})),c.d(t,"b",(function(){return l})),c.d(t,"c",(function(){return i}));var r=c(35);const o=(e,t)=>e[t]?Array.from(e[t].values()).sort((e,t)=>e.priority-t.priority):[];let n,a;!function(e){e.SUCCESS="success",e.FAIL="failure",e.ERROR="error"}(n||(n={})),function(e){e.PAYMENTS="wc/payment-area",e.EXPRESS_PAYMENTS="wc/express-payment-area"}(a||(a={}));const s=(e,t)=>Object(r.a)(e)&&"type"in e&&e.type===t,l=e=>s(e,n.ERROR),i=e=>s(e,n.FAIL)},function(e,t,c){"use strict";var r=c(6),o=c.n(r),n=c(0),a=c(138),s=c(4),l=c.n(s),i=c(95);c(162),t.a=e=>{let{className:t,showSpinner:c=!1,children:r,variant:s="contained",...u}=e;const d=l()("wc-block-components-button",t,s,{"wc-block-components-button--loading":c});return Object(n.createElement)(a.a,o()({className:d},u),c&&Object(n.createElement)(i.a,null),Object(n.createElement)("span",{className:"wc-block-components-button__text"},r))}},function(e,t){e.exports=window.wp.autop},function(e,t,c){"use strict";c.d(t,"c",(function(){return n})),c.d(t,"a",(function(){return a})),c.d(t,"b",(function(){return s}));var r=c(10),o=c(22);const n=(e,t)=>{if(o.n>2)return Object(r.registerBlockType)(e,t)},a=()=>o.n>2,s=()=>o.n>1},,,function(e,t,c){"use strict";var r=c(0),o=c(1),n=c(8),a=c(3);t.a=e=>{let{columns:t,rows:c,setAttributes:s,alignButtons:l,minColumns:i=1,maxColumns:u=6,minRows:d=1,maxRows:b=6}=e;return Object(r.createElement)(r.Fragment,null,Object(r.createElement)(a.RangeControl,{label:Object(o.__)("Columns","woo-gutenberg-products-block"),value:t,onChange:e=>{const t=Object(n.clamp)(e,i,u);s({columns:Number.isNaN(t)?"":t})},min:i,max:u}),Object(r.createElement)(a.RangeControl,{label:Object(o.__)("Rows","woo-gutenberg-products-block"),value:c,onChange:e=>{const t=Object(n.clamp)(e,d,b);s({rows:Number.isNaN(t)?"":t})},min:d,max:b}),Object(r.createElement)(a.ToggleControl,{label:Object(o.__)("Align the last block to the bottom","woo-gutenberg-products-block"),help:l?Object(o.__)("Align the last block to the bottom.","woo-gutenberg-products-block"):Object(o.__)("The last inner block will follow other content.","woo-gutenberg-products-block"),checked:l,onChange:()=>s({alignButtons:!l})}))}},,,function(e,t,c){"use strict";c.d(t,"a",(function(){return a}));var r=c(0),o=c(7),n=c(9);c(187);const a=e=>{let{errorMessage:t="",propertyName:c="",elementId:a=""}=e;const{validationError:s,validationErrorId:l}=Object(o.useSelect)(e=>{const t=e(n.VALIDATION_STORE_KEY);return{validationError:t.getValidationError(c),validationErrorId:t.getValidationErrorId(a)}});if(!t||"string"!=typeof t){if(null==s||!s.message||null!=s&&s.hidden)return null;t=s.message}return Object(r.createElement)("div",{className:"wc-block-components-validation-error",role:"alert"},Object(r.createElement)("p",{id:l},t))};t.b=a},,,function(e,t,c){"use strict";c.d(t,"a",(function(){return a}));var r=c(45),o=c(0),n=c(41);const a=()=>{const e=Object(n.a)(),t=Object(o.useRef)(e);return Object(o.useEffect)(()=>{t.current=e},[e]),{dispatchStoreEvent:Object(o.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(r.doAction)("experimental__woocommerce_blocks-"+e,t)}catch(e){console.error(e)}}),[]),dispatchCheckoutEvent:Object(o.useCallback)((function(e){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(r.doAction)("experimental__woocommerce_blocks-checkout-"+e,{...c,storeCart:t.current})}catch(e){console.error(e)}}),[])}}},,,function(e,t){e.exports=window.wp.dom},,,,,,,function(e,t,c){"use strict";var r=c(0),o=c(1),n=c(38),a=c(4),s=c.n(a),l=c(26);c(161);const i=e=>{let{currency:t,maxPrice:c,minPrice:a,priceClassName:i,priceStyle:u={}}=e;return Object(r.createElement)(r.Fragment,null,Object(r.createElement)("span",{className:"screen-reader-text"},Object(o.sprintf)(
|
6 |
/* translators: %1$s min price, %2$s max price */
|
7 |
-
Object(o.__)("Price between %1$s and %2$s","woo-gutenberg-products-block"),Object(l.formatPrice)(a),Object(l.formatPrice)(c))),Object(r.createElement)("span",{"aria-hidden":!0},Object(r.createElement)(n.a,{className:s()("wc-block-components-product-price__value",i),currency:t,value:a,style:u})," — ",Object(r.createElement)(n.a,{className:s()("wc-block-components-product-price__value",i),currency:t,value:c,style:u})))},u=e=>{let{currency:t,regularPriceClassName:c,regularPriceStyle:a,regularPrice:l,priceClassName:i,priceStyle:u,price:d}=e;return Object(r.createElement)(r.Fragment,null,Object(r.createElement)("span",{className:"screen-reader-text"},Object(o.__)("Previous price:","woo-gutenberg-products-block")),Object(r.createElement)(n.a,{currency:t,renderText:e=>Object(r.createElement)("del",{className:s()("wc-block-components-product-price__regular",c),style:a},e),value:l}),Object(r.createElement)("span",{className:"screen-reader-text"},Object(o.__)("Discounted price:","woo-gutenberg-products-block")),Object(r.createElement)(n.a,{currency:t,renderText:e=>Object(r.createElement)("ins",{className:s()("wc-block-components-product-price__value","is-discounted",i),style:u},e),value:d}))};t.a=e=>{let{align:t,className:c,currency:o,format:a="<price/>",maxPrice:l,minPrice:d,price:b,priceClassName:p,priceStyle:m,regularPrice:g,regularPriceClassName:O,regularPriceStyle:j}=e;const h=s()(c,"price","wc-block-components-product-price",{["wc-block-components-product-price--align-"+t]:t});a.includes("<price/>")||(a="<price/>",console.error("Price formats need to include the `<price/>` tag."));const _=g&&b!==g;let E=Object(r.createElement)("span",{className:s()("wc-block-components-product-price__value",p)});return _?E=Object(r.createElement)(u,{currency:o,price:b,priceClassName:p,priceStyle:m,regularPrice:g,regularPriceClassName:O,regularPriceStyle:j}):void 0!==d&&void 0!==l?E=Object(r.createElement)(i,{currency:o,maxPrice:l,minPrice:d,priceClassName:p,priceStyle:m}):b&&(E=Object(r.createElement)(n.a,{className:s()("wc-block-components-product-price__value",p),currency:o,value:b,style:m})),Object(r.createElement)("span",{className:h},Object(r.createInterpolateElement)(a,{price:E}))}},,function(e,t,c){"use strict";c.d(t,"b",(function(){return a})),c.d(t,"a",(function(){return s}));var r=c(0),o=c(7);const n=Object(r.createContext)({isEditor:!1,currentPostId:0,currentView:"",previewData:{},getPreviewData:()=>{}}),a=()=>Object(r.useContext)(n),s=e=>{let{children:t,currentPostId:c=0,currentView:a="",previewData:s={}}=e;const l=Object(o.useSelect)(e=>c||e("core/editor").getCurrentPostId(),[c]),i=Object(r.useCallback)(e=>e in s?s[e]:{},[s]),u={isEditor:!0,currentPostId:l,currentView:a,previewData:s,getPreviewData:i};return Object(r.createElement)(n.Provider,{value:u},t)}},,function(e,t,c){"use strict";var r=c(6),o=c.n(r),n=c(0),a=c(37),s=c(3),l=c(4),i=c.n(l);t.a=e=>{let{className:t,item:c,isSelected:r,isLoading:l,onSelect:u,disabled:d,...b}=e;return Object(n.createElement)(n.Fragment,null,Object(n.createElement)(a.a,o()({},b,{key:c.id,className:t,isSelected:r,item:c,onSelect:u,isSingle:!0,disabled:d})),r&&l&&Object(n.createElement)("div",{key:"loading",className:i()("woocommerce-search-list__item","woocommerce-product-attributes__item","depth-1","is-loading","is-not-active")},Object(n.createElement)(s.Spinner,null)))}},,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return n}));var r=c(35),o=c(
|
8 |
/* translators: %s Field label. */
|
9 |
-
Object(o.__)("%s (optional)","woo-gutenberg-products-block"),e.label)),e.priority&&(Object(n.a)(e.priority)&&(t.index=e.priority),Object(a.a)(e.priority)&&(t.index=parseInt(e.priority,10))),e.hidden&&(t.required=!1),t},i=Object.entries(s).map(e=>{let[t,c]=e;return[t,Object.entries(c).map(e=>{let[t,c]=e;return[t,l(c)]}).reduce((e,t)=>{let[c,r]=t;return e[c]=r,e},{})]}).reduce((e,t)=>{let[c,r]=t;return e[c]=r,e},{});t.a=function(e,t){let c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";const o=c&&void 0!==i[c]?i[c]:{};return e.map(e=>({key:e,...r.defaultAddressFields[e]||{},...o[e]||{},...t[e]||{}})).sort((e,t)=>e.index-t.index)}},,function(e,t,c){"use strict";var r=c(0);c(
|
10 |
/* translators: %1$d is the number of variations of a product product. */
|
11 |
Object(a.__)("%1$d variations","woo-gutenberg-products-block"),t.variations.length):null,name:"products-"+r,"aria-label":Object(a.sprintf)(
|
12 |
/* translators: %1$s is the product name, %2$d is the number of variations of that product. */
|
13 |
-
Object(a._n)("%1$s, has %2$d variation","%1$s, has %2$d variations",t.variations.length,"woo-gutenberg-products-block"),t.name,t.variations.length)}));const g=Object(s.isEmpty)(t.variation)?e:{...e,item:{...e.item,name:t.variation},"aria-label":`${t.breadcrumbs[0]}: ${t.variation}`};return Object(n.createElement)(l.a,o()({},g,{className:m,name:"variations-"+r}))}:null),onSearch:p,messages:y,isHierarchical:!0})};v.defaultProps={isCompact:!1,expandedProduct:null,selected:[],showVariations:!1},t.a=d(Object(b.a)(_(Object(u.withInstanceId)(v))))},function(e,t,c){"use strict";c.d(t,"a",(function(){return n})),c.d(t,"b",(function(){return s}));var r=c(8);let o;!function(e){e.ADD_EVENT_CALLBACK="add_event_callback",e.REMOVE_EVENT_CALLBACK="remove_event_callback"}(o||(o={}));const n={addEventCallback:function(e,t){let c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10;return{id:Object(r.uniqueId)(),type:o.ADD_EVENT_CALLBACK,eventType:e,callback:t,priority:c}},removeEventCallback:(e,t)=>({id:t,type:o.REMOVE_EVENT_CALLBACK,eventType:e})},a={},s=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:a,{type:t,eventType:c,id:r,callback:n,priority:s}=arguments.length>1?arguments[1]:void 0;const l=e.hasOwnProperty(c)?new Map(e[c]):new Map;switch(t){case o.ADD_EVENT_CALLBACK:return l.set(r,{priority:s,callback:n}),{...e,[c]:l};case o.REMOVE_EVENT_CALLBACK:return l.delete(r),{...e,[c]:l}}}},function(e,t,c){"use strict";c.d(t,"a",(function(){return s}));var r=c(5),o=c(61),n=c(35),a=c(
|
14 |
-
Object(a.__)("Remove %s","woo-gutenberg-products-block"),c),"aria-describedby":E},Object(n.createElement)(l.a,{icon:g.a,size:20,className:"clear-icon"})))};var h=j;const _=e=>Object(n.createElement)(m.b,e),E=e=>{const{list:t,selected:c,renderItem:r,depth:a=0,onSelect:s,instanceId:l,isSingle:i,search:u}=e;return t?Object(n.createElement)(n.Fragment,null,t.map(t=>{const d=-1!==c.findIndex(e=>{let{id:c}=e;return c===t.id});return Object(n.createElement)(n.Fragment,{key:t.id},Object(n.createElement)("li",null,r({item:t,isSelected:d,onSelect:s,isSingle:i,search:u,depth:a,controlId:l})),Object(n.createElement)(E,o()({},e,{list:t.children,depth:a+1})))})):null},w=e=>{let{isLoading:t,isSingle:c,selected:r,messages:o,onChange:l,onRemove:i}=e;if(t||c||!r)return null;const u=r.length;return Object(n.createElement)("div",{className:"woocommerce-search-list__selected"},Object(n.createElement)("div",{className:"woocommerce-search-list__selected-header"},Object(n.createElement)("strong",null,o.selected(u)),u>0?Object(n.createElement)(s.Button,{isLink:!0,isDestructive:!0,onClick:()=>l([]),"aria-label":o.clear},Object(a.__)("Clear all","woo-gutenberg-products-block")):null),u>0?Object(n.createElement)("ul",null,r.map((e,t)=>Object(n.createElement)("li",{key:t},Object(n.createElement)(h,{label:e.name,id:e.id,remove:i})))):null)},f=e=>{let{filteredList:t,search:c,onSelect:r,instanceId:o,...s}=e;const{messages:u,renderItem:d,selected:b,isSingle:p}=s,m=d||_;return 0===t.length?Object(n.createElement)("div",{className:"woocommerce-search-list__list is-not-found"},Object(n.createElement)("span",{className:"woocommerce-search-list__not-found-icon"},Object(n.createElement)(l.a,{icon:i.a})),Object(n.createElement)("span",{className:"woocommerce-search-list__not-found-text"},c?Object(a.sprintf)(u.noResults,c):u.noItems)):Object(n.createElement)("ul",{className:"woocommerce-search-list__list"},Object(n.createElement)(E,{list:t,selected:b,renderItem:m,onSelect:r,instanceId:o,isSingle:p,search:c}))},k=e=>{const{className:t="",isCompact:c,isHierarchical:r,isLoading:a,isSingle:l,list:i,messages:u=p.a,onChange:m,onSearch:g,selected:O,debouncedSpeak:j}=e,[h,_]=Object(n.useState)(""),E=Object(b.useInstanceId)(k),y=Object(n.useMemo)(()=>({...p.a,...u}),[u]),v=Object(n.useMemo)(()=>Object(p.c)(i,h,r),[i,h,r]);Object(n.useEffect)(()=>{j&&j(y.updated)},[j,y]),Object(n.useEffect)(()=>{"function"==typeof g&&g(h)},[h,g]);const S=Object(n.useCallback)(e=>()=>{l&&m([]);const t=O.findIndex(t=>{let{id:c}=t;return c===e});m([...O.slice(0,t),...O.slice(t+1)])},[l,O,m]),C=Object(n.useCallback)(e=>()=>{-1===O.findIndex(t=>{let{id:c}=t;return c===e.id})?m(l?[e]:[...O,e]):S(e.id)()},[l,S,m,O]);return Object(n.createElement)("div",{className:d()("woocommerce-search-list",t,{"is-compact":c})},Object(n.createElement)(w,o()({},e,{onRemove:S,messages:y})),Object(n.createElement)("div",{className:"woocommerce-search-list__search"},Object(n.createElement)(s.TextControl,{label:y.search,type:"search",value:h,onChange:e=>_(e)})),a?Object(n.createElement)("div",{className:"woocommerce-search-list__list is-loading"},Object(n.createElement)(s.Spinner,null)):Object(n.createElement)(f,o()({},e,{search:h,filteredList:v,messages:y,onSelect:C,instanceId:E})))};Object(s.withSpokenMessages)(k)},,,function(e,t,c){"use strict";c.d(t,"a",(function(){return o}));var r=c(12);function o(e,t){const c=Object(r.useRef)();return Object(r.useEffect)(()=>{c.current===e||t&&!t(e,c.current)||(c.current=e)},[e,t]),c.current}},,function(e,t,c){"use strict";var r=c(6),o=c.n(r),n=c(0),a=c(15),s=c(4),l=c.n(s);c(160),t.a=e=>{let{className:t="",disabled:c=!1,name:r,permalink:s="",target:i,rel:u,style:d,onClick:b,...p}=e;const m=l()("wc-block-components-product-name",t);if(c){const e=p;return Object(n.createElement)("span",o()({className:m},e,{dangerouslySetInnerHTML:{__html:Object(a.decodeEntities)(r)}}))}return Object(n.createElement)("a",o()({className:m,href:s,target:i},p,{dangerouslySetInnerHTML:{__html:Object(a.decodeEntities)(r)},style:d}))}},function(e,t){e.exports=window.wp.warning},function(e,t,c){"use strict";c.d(t,"a",(function(){return l}));var r=c(9),o=c(7),n=c(0),a=c(40),s=c(142);const l=e=>{const{namespace:t,resourceName:c,resourceValues:l=[],query:i={},shouldSelect:u=!0}=e;if(!t||!c)throw new Error("The options object must have valid values for the namespace and the resource properties.");const d=Object(n.useRef)({results:[],isLoading:!0}),b=Object(a.a)(i),p=Object(a.a)(l),m=Object(s.a)(),g=Object(o.useSelect)(e=>{if(!u)return null;const o=e(r.COLLECTIONS_STORE_KEY),n=[t,c,b,p],a=o.getCollectionError(...n);if(a){if(!(a instanceof Error))throw new Error("TypeError: `error` object is not an instance of Error constructor");m(a)}return{results:o.getCollection(...n),isLoading:!o.hasFinishedResolution("getCollection",n)}},[t,c,p,b,u]);return null!==g&&(d.current=g),d.current}},function(e,t,c){"use strict";var r=c(0),o=c(1),n=c(117),a=c(258),s=c(2),l=c(5),i=c(23);t.a=e=>{const t=(Object(i.useProductDataContext)().product||{}).id||e.productId||0;return t?Object(r.createElement)(l.InspectorControls,null,Object(r.createElement)("div",{className:"wc-block-single-product__edit-card"},Object(r.createElement)("div",{className:"wc-block-single-product__edit-card-title"},Object(r.createElement)("a",{href:`${s.ADMIN_URL}post.php?post=${t}&action=edit`,target:"_blank",rel:"noopener noreferrer"},Object(o.__)("Edit this product's details","woo-gutenberg-products-block"),Object(r.createElement)(n.a,{icon:a.a,size:16}))),Object(r.createElement)("div",{className:"wc-block-single-product__edit-card-description"},Object(o.__)("Edit details such as title, price, description and more.","woo-gutenberg-products-block")))):null}},,,,,,,,,,,function(e,t,c){"use strict";var r=c(0),o=c(90),n=c(60);const a=e=>{const t=e.indexOf("</p>");return-1===t?e:e.substr(0,t+4)},s=e=>e.replace(/<\/?[a-z][^>]*?>/gi,""),l=(e,t)=>e.replace(/[\s|\.\,]+$/i,"")+t,i=function(e,t){let c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"…";const r=s(e),o=r.split(" ").splice(0,t).join(" ");return Object(n.autop)(l(o,c))},u=function(e,t){let c=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"…";const o=s(e),a=o.slice(0,t);if(c)return Object(n.autop)(l(a,r));const i=a.match(/([\s]+)/g),u=i?i.length:0,d=o.slice(0,t+u);return Object(n.autop)(l(d,r))};t.a=e=>{let{source:t,maxLength:c=15,countType:s="words",className:l="",style:d={}}=e;const b=Object(r.useMemo)(()=>function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:15,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"words";const r=Object(n.autop)(e),s=Object(o.count)(r,c);if(s<=t)return r;const l=a(r),d=Object(o.count)(l,c);return d<=t?l:"words"===c?i(l,t):u(l,t,"characters_including_spaces"===c)}(t,c,s),[t,c,s]);return Object(r.createElement)(r.RawHTML,{style:d,className:l},b)}},,function(e,t,c){"use strict";var r=c(0),o=c(4),n=c.n(o),a=c(28),s=c(11);c(166),t.a=Object(s.withInstanceId)(e=>{let{className:t,instanceId:c,label:o="",onChange:s,options:l,screenReaderLabel:i,value:u=""}=e;const d="wc-block-components-sort-select__select-"+c;return Object(r.createElement)("div",{className:n()("wc-block-sort-select","wc-block-components-sort-select",t)},Object(r.createElement)(a.a,{label:o,screenReaderLabel:i,wrapperElement:"label",wrapperProps:{className:"wc-block-sort-select__label wc-block-components-sort-select__label",htmlFor:d}}),Object(r.createElement)("select",{id:d,className:"wc-block-sort-select__select wc-block-components-sort-select__select",onChange:s,value:u},l&&l.map(e=>Object(r.createElement)("option",{key:e.key,value:e.key},e.label))))})},,,,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return r}));const r=e=>"boolean"==typeof e},function(e,t,c){"use strict";c.d(t,"a",(function(){return o}));var r=c(5);const o=()=>"function"==typeof r.__experimentalGetSpacingClassesAndStyles},,,function(e,t,c){"use strict";c.d(t,"a",(function(){return n}));var r=c(96),o=c(35);const n=e=>Object(r.a)(e)?JSON.parse(e)||{}:Object(o.a)(e)?e:{}},function(e,t,c){"use strict";c.d(t,"a",(function(){return l}));var r=c(5),o=c(61),n=c(35),a=c(128),s=c(131);const l=e=>{if(!Object(o.b)()||!Object(a.a)())return{style:{}};const t=Object(n.a)(e)?e:{},c=Object(s.a)(t.style);return Object(r.__experimentalGetSpacingClassesAndStyles)({...t,style:c})}},,,,,,,function(e,t){},function(e,t){},function(e,t,c){"use strict";c.r(t),c.d(t,"Block",(function(){return m}));var r=c(0),o=c(1),n=c(4),a=c.n(n),s=c(28),l=c(23),i=c(155),u=c(99),d=c(88),b=c(132),p=c(42);c(262);const m=e=>{const{className:t,align:c}=e,{parentClassName:n}=Object(l.useInnerBlockLayoutContext)(),{product:p}=Object(l.useProductDataContext)(),m=Object(i.a)(e),g=Object(u.a)(e),O=Object(d.a)(e),j=Object(b.a)(e);if(!p.id||!p.on_sale)return null;const h="string"==typeof c?"wc-block-components-product-sale-badge--align-"+c:"";return Object(r.createElement)("div",{className:a()("wc-block-components-product-sale-badge",t,h,{[n+"__product-onsale"]:n},g.className,m.className),style:{...g.style,...m.style,...O.style,...j.style}},Object(r.createElement)(s.a,{label:Object(o.__)("Sale","woo-gutenberg-products-block"),screenReaderLabel:Object(o.__)("Product on sale","woo-gutenberg-products-block")}))};t.default=Object(p.withProductDataContext)(m)},function(e,t,c){"use strict";c.d(t,"a",(function(){return o}));var r=c(0);const o=()=>{const[,e]=Object(r.useState)();return Object(r.useCallback)(t=>{e(()=>{throw t})},[])}},,,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return r}));const r=e=>"number"==typeof e},,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return o}));var r=c(0);const o=Object(r.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 230 250",style:{width:"100%"}},Object(r.createElement)("title",null,"Grid Block Preview"),Object(r.createElement)("rect",{width:"65.374",height:"65.374",x:".162",y:".779",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(r.createElement)("rect",{width:"62.8",height:"15",x:"1.565",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(r.createElement)("rect",{width:"65.374",height:"65.374",x:".162",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(r.createElement)("rect",{width:"62.8",height:"15",x:"1.565",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(r.createElement)("rect",{width:"65.374",height:"65.374",x:"82.478",y:".779",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(r.createElement)("rect",{width:"62.8",height:"15",x:"83.882",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(r.createElement)("rect",{width:"65.374",height:"65.374",x:"82.478",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(r.createElement)("rect",{width:"62.8",height:"15",x:"83.882",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(r.createElement)("rect",{width:"65.374",height:"65.374",x:"164.788",y:".779",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(r.createElement)("rect",{width:"62.8",height:"15",x:"166.192",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(r.createElement)("rect",{width:"65.374",height:"65.374",x:"164.788",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(r.createElement)("rect",{width:"62.8",height:"15",x:"166.192",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"221.798",fill:"#E1E3E6",rx:"3"}))},function(e,t,c){"use strict";var r=c(6),o=c.n(r),n=c(0),a=c(3),s=c(4),l=c.n(s);c(191),t.a=function(e){let{className:t="",...c}=e;const r=l()("wc-block-text-toolbar-button",t);return Object(n.createElement)(a.Button,o()({className:r},c))}},,,function(e,t,c){"use strict";c.d(t,"a",(function(){return s}));var r=c(5),o=c(61),n=c(35),a=c(131);const s=e=>{if(!Object(o.b)())return{className:"",style:{}};const t=Object(n.a)(e)?e:{},c=Object(a.a)(t.style);return Object(r.__experimentalUseBorderProps)({...t,style:c})}},,,,,function(e,t){},function(e,t){},function(e,t){},function(e,t){},,,function(e,t){},function(e,t,c){"use strict";c.d(t,"a",(function(){return i}));var r=c(0),o=c(7),n=c(9),a=c(15),s=c(41);const l=(e,t)=>{const c=e.find(e=>{let{id:c}=e;return c===t});return c?c.quantity:0},i=e=>{const{addItemToCart:t}=Object(o.useDispatch)(n.CART_STORE_KEY),{cartItems:c,cartIsLoading:i}=Object(s.a)(),{createErrorNotice:u,removeNotice:d}=Object(o.useDispatch)("core/notices"),[b,p]=Object(r.useState)(!1),m=Object(r.useRef)(l(c,e));return Object(r.useEffect)(()=>{const t=l(c,e);t!==m.current&&(m.current=t)},[c,e]),{cartQuantity:Number.isFinite(m.current)?m.current:0,addingToCart:b,cartIsLoading:i,addToCart:function(){let c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return p(!0),t(e,c).then(()=>{d("add-to-cart")}).catch(e=>{u(Object(a.decodeEntities)(e.message),{id:"add-to-cart",context:"wc/all-products",isDismissible:!0})}).finally(()=>{p(!1)})}}}},,,,,,,,,,,,,,,,,,,,function(e,t){},,,function(e,t,c){"use strict";var r=c(6),o=c.n(r),n=c(0),a=c(22),s=c(27),l=c(116),i=c(29);t.a=e=>t=>{let{selected:c,...r}=t;const[u,d]=Object(n.useState)(!0),[b,p]=Object(n.useState)(null),[m,g]=Object(n.useState)([]),O=a.o.productCount>100,j=async e=>{const t=await Object(i.a)(e);p(t),d(!1)},h=Object(n.useRef)(c);Object(n.useEffect)(()=>{Object(s.h)({selected:h.current}).then(e=>{g(e),d(!1)}).catch(j)},[h]);const _=Object(l.a)(e=>{Object(s.h)({selected:c,search:e}).then(e=>{g(e),d(!1)}).catch(j)},400),E=Object(n.useCallback)(e=>{d(!0),_(e)},[d,_]);return Object(n.createElement)(e,o()({},r,{selected:c,error:b,products:m,isLoading:u,onSearch:O?E:null}))}},function(e,t){},,,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return g}));var r=c(0),o=c(4),n=c.n(o),a=c(23),s=c(61),l=c(42),i=c(105),u=c(70),d=c(99),b=c(132),p=c(88);c(263);const m=e=>{let{children:t,headingLevel:c,elementType:o="h"+c,...n}=e;return Object(r.createElement)(o,n,t)},g=e=>{const{className:t,headingLevel:c=2,showProductLink:o=!0,linkTarget:l,align:g}=e,{parentClassName:O}=Object(a.useInnerBlockLayoutContext)(),{product:j}=Object(a.useProductDataContext)(),{dispatchStoreEvent:h}=Object(u.a)(),_=Object(d.a)(e),E=Object(b.a)(e),w=Object(p.a)(e);return j.id?Object(r.createElement)(m,{headingLevel:c,className:n()(t,_.className,"wc-block-components-product-title",{[O+"__product-title"]:O,["wc-block-components-product-title--align-"+g]:g&&Object(s.b)()}),style:Object(s.b)()?{...E.style,...w.style,..._.style}:{}},Object(r.createElement)(i.a,{disabled:!o,name:j.name,permalink:j.permalink,target:l,onClick:()=>{h("product-view-link",{product:j})}})):Object(r.createElement)(m,{headingLevel:c,className:n()(t,_.className,"wc-block-components-product-title",{[O+"__product-title"]:O,["wc-block-components-product-title--align-"+g]:g&&Object(s.b)()}),style:Object(s.b)()?{...E.style,...w.style,..._.style}:{}})};t.b=Object(l.withProductDataContext)(g)},function(e,t,c){"use strict";c.d(t,"a",(function(){return j}));var r=c(6),o=c.n(r),n=c(0),a=c(1),s=c(4),l=c.n(s),i=c(2),u=c(23),d=c(88),b=c(155),p=c(132),m=c(42),g=c(70),O=c(141);c(264);const j=e=>{const{className:t,imageSizing:c="full-size",showProductLink:r=!0,showSaleBadge:o,saleBadgeAlign:s="right"}=e,{parentClassName:i}=Object(u.useInnerBlockLayoutContext)(),{product:m,isLoading:j}=Object(u.useProductDataContext)(),{dispatchStoreEvent:E}=Object(g.a)(),w=Object(d.a)(e),f=Object(b.a)(e),k=Object(p.a)(e);if(!m.id)return Object(n.createElement)("div",{className:l()(t,"wc-block-components-product-image",{[i+"__product-image"]:i},f.className),style:{...w.style,...f.style,...k.style}},Object(n.createElement)(h,null));const y=!!m.images.length,v=y?m.images[0]:null,S=r?"a":n.Fragment,C=Object(a.sprintf)(
|
15 |
/* translators: %s is referring to the product name */
|
16 |
-
Object(a.__)("Link to %s","woo-gutenberg-products-block"),m.name),x={href:m.permalink,...!y&&{"aria-label":C},onClick:()=>{E("product-view-link",{product:m})}};return Object(n.createElement)("div",{className:l()(t,"wc-block-components-product-image",{[i+"__product-image"]:i},f.className),style:{...w.style,...f.style,...k.style}},Object(n.createElement)(S,r&&x,!!o&&Object(n.createElement)(O.default,{align:s,product:m}),Object(n.createElement)(
|
17 |
/* translators: %s number of products in cart. */
|
18 |
-
Object(a._n)("%d in cart","%d in cart",c,"woo-gutenberg-products-block"),c):Object(a.__)("Add to cart","woo-gutenberg-products-block"),!!s&&Object(r.createElement)(ue.a,{icon:de.a}))};var Oe=()=>{const{showFormElements:e,productIsPurchasable:t,productHasOptions:c,product:o,productType:n,isDisabled:s,isProcessing:l,eventRegistration:i,hasError:u,dispatchActions:d}=J(),{parentName:b}=Object(ae.useInnerBlockLayoutContext)(),{dispatchStoreEvent:p}=Object(be.a)(),{cartQuantity:m}=Object(pe.a)(o.id||0),[g,O]=Object(r.useState)(!1),j=o.add_to_cart||{url:"",text:""};return Object(r.useEffect)(()=>{const e=i.onAddToCartAfterProcessingWithSuccess(()=>(u||O(!0),!0),0);return()=>{e()}},[i,u]),(e||!c&&"simple"===n)&&t?Object(r.createElement)(ge,{className:"wc-block-components-product-add-to-cart-button",quantityInCart:m,isDisabled:s,isProcessing:l,isDone:g,onClick:()=>{d.submitForm("woocommerce/single-product/"+((null==o?void 0:o.id)||0)),p("cart-add-item",{product:o,listName:b})}}):Object(r.createElement)(me,{className:"wc-block-components-product-add-to-cart-button",href:j.url,text:j.text||Object(a.__)("View Product","woo-gutenberg-products-block"),onClick:()=>{p("product-view-link",{product:o,listName:b})}})},je=c(
|
19 |
/* translators: %f is referring to the average rating value */
|
20 |
Object(o.__)("Rated %f out of 5","woo-gutenberg-products-block"),n),j=(e=>{const t=Object(b.a)(e.review_count)?e.review_count:parseInt(e.review_count,10);return Number.isFinite(t)&&t>0?t:0})(c),h={__html:Object(o.sprintf)(
|
21 |
/* translators: %1$s is referring to the average rating value, %2$s is referring to the number of ratings */
|
22 |
-
Object(o._n)("Rated %1$s out of 5 based on %2$s customer rating","Rated %1$s out of 5 based on %2$s customer ratings",j,"woo-gutenberg-products-block"),Object(o.sprintf)('<strong class="rating">%f</strong>',n),Object(o.sprintf)('<span class="rating">%d</span>',j))};return Object(r.createElement)("div",{className:a()(d.className,"wc-block-components-product-rating",{[t+"__product-rating"]:t}),style:{...d.style,...p.style,...m.style}},Object(r.createElement)("div",{className:a()("wc-block-components-product-rating__stars",t+"__product-rating__stars"),role:"img","aria-label":O},Object(r.createElement)("span",{style:g,dangerouslySetInnerHTML:h})))};t.default=Object(d.withProductDataContext)(p)},function(e,t,c){"use strict";c.r(t),c.d(t,"Block",(function(){return E}));var r=c(6),o=c.n(r),n=c(0),a=c(4),s=c.n(a),l=c(1),i=c(
|
23 |
/* translators: %s number of products in cart. */
|
24 |
-
Object(l._n)("%d in cart","%d in cart",f,"woo-gutenberg-products-block"),f):Object(g.decodeEntities)((null==m?void 0:m.text)||Object(l.__)("Add to cart","woo-gutenberg-products-block")),N=S?"button":"a",P={};return S?P.onClick=async()=>{await y(),w("cart-add-item",{product:t});const{cartRedirectAfterAdd:e}=Object(j.getSetting)("productsSettings");e&&(window.location.href=O.d)}:(P.href=p,P.rel="nofollow",P.onClick=()=>{w("product-view-link",{product:t})}),Object(n.createElement)(N,o()({"aria-label":C,className:s()("wp-block-button__link","wp-element-button","add_to_cart_button","wc-block-components-product-button__button",c.className,r.className,{loading:k,added:v}),style:{...c.style,...r.style,...a.style,...d.style},disabled:k},P),x)},f=e=>{let{colorStyles:t,borderStyles:c,typographyStyles:r,spacingStyles:o}=e;return Object(n.createElement)("button",{className:s()("wp-block-button__link","wp-element-button","add_to_cart_button","wc-block-components-product-button__button","wc-block-components-product-button__button--placeholder",t.className,c.className),style:{...t.style,...c.style,...r.style,...o.style},disabled:!0})};t.default=Object(_.withProductDataContext)(E)},,,,,,,,,,function(e){e.exports=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":1,"textdomain":"woo-gutenberg-products-block","name":"woocommerce/all-products","title":"All Products","category":"woocommerce","keywords":["WooCommerce"],"description":"Display products from your store in a grid layout.","supports":{"align":["wide","full"],"html":false,"multiple":false},"example":{"attributes":{"isPreview":true}},"attributes":{"columns":{"type":"number"},"rows":{"type":"number"},"alignButtons":{"type":"boolean"},"contentVisibility":{"type":"object"},"orderby":{"type":"string"},"layoutConfig":{"type":"array"},"isPreview":{"type":"boolean","default":false}}}')},,,,,,,,,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return s}));var r=c(182),o=c.n(r);const n=["a","b","em","i","strong","p","br"],a=["target","href","rel","name","download"],s=(e,t)=>{const c=(null==t?void 0:t.tags)||n,r=(null==t?void 0:t.attr)||a;return o.a.sanitize(e,{ALLOWED_TAGS:c,ALLOWED_ATTR:r})}},,,function(e,t){},,,,,,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return s}));var r=c(107),o=c(9),n=c(7),a=c(40);const s=e=>{const t={namespace:"/wc/store/v1",resourceName:"products"},{results:c,isLoading:s}=Object(r.a)({...t,query:e}),{value:l}=((e,t)=>{const{namespace:c,resourceName:r,resourceValues:s=[],query:l={}}=t;if(!c||!r)throw new Error("The options object must have valid values for the namespace and the resource name properties.");const i=Object(a.a)(l),u=Object(a.a)(s),{value:d,isLoading:b=!0}=Object(n.useSelect)(e=>{const t=e(o.COLLECTIONS_STORE_KEY),n=["x-wp-total",c,r,i,u];return{value:t.getCollectionHeader(...n),isLoading:t.hasFinishedResolution("getCollectionHeader",n)}},["x-wp-total",c,r,u,i]);return{value:d,isLoading:b}})(0,{...t,query:e});return{products:c,totalProducts:parseInt(l,10),productsLoading:s}}},,,,,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return p}));var r=c(6),o=c.n(r),n=c(0),a=c(4),s=c.n(a),l=c(314),i=c(233),u=c(7),d=c(9);c(198);const b=e=>{let{status:t="default"}=e;switch(t){case"error":return"woocommerce-error";case"success":return"woocommerce-message";case"info":case"warning":return"woocommerce-info"}return""},p=e=>{let{className:t,context:c="default",additionalNotices:r=[]}=e;const a=Object(u.useSelect)(e=>e(d.PAYMENT_STORE_KEY).isExpressPaymentMethodActive()),{notices:p}=Object(u.useSelect)(e=>({notices:e("core/notices").getNotices(c)})),{removeNotice:m}=Object(u.useDispatch)("core/notices"),g=p.filter(e=>"snackbar"!==e.type).concat(r);if(!g.length)return null;const O=s()(t,"wc-block-components-notices");return a?null:Object(n.createElement)("div",{className:O},g.map(e=>Object(n.createElement)(l.a,o()({key:"store-notice-"+e.id},e,{className:s()("wc-block-components-notices__notice",b(e)),onRemove:()=>{e.isDismissible&&m(e.id,c)}}),Object(i.a)(e.content))))}},,,,,,,,,function(e,t,c){"use strict";c.d(t,"c",(function(){return a})),c.d(t,"b",(function(){return s})),c.d(t,"a",(function(){return l}));const r=window.CustomEvent||null,o=(e,t)=>{let{bubbles:c=!1,cancelable:o=!1,element:n,detail:a={}}=t;if(!r)return;n||(n=document.body);const s=new r(e,{bubbles:c,cancelable:o,detail:a});n.dispatchEvent(s)};let n;const a=()=>{n&&clearTimeout(n),n=setTimeout(()=>{o("wc_fragment_refresh",{bubbles:!0,cancelable:!0})},50)},s=e=>{let{preserveCartData:t=!1}=e;o("wc-blocks_added_to_cart",{bubbles:!0,cancelable:!0,detail:{preserveCartData:t}})},l=function(e,t){let c=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("function"!=typeof jQuery)return()=>{};const n=()=>{o(t,{bubbles:c,cancelable:r})};return jQuery(document).on(e,n),()=>jQuery(document).off(e,n)}},function(e,t,c){"use strict";c.d(t,"a",(function(){return n}));var r=c(93),o=(c(16),c(2));const n=e=>{const t=Object.keys(o.defaultAddressFields),c=Object(r.a)(t,{},e.country),n=Object.assign({},e);return c.forEach(t=>{let{key:c="",hidden:r=!1}=t;r&&((e,t)=>e in t)(c,e)&&(n[c]="")}),n}},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,c){"use strict";c.d(t,"a",(function(){return o}));var r=c(98);const o=(e,t)=>function(c){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;const n=r.a.addEventCallback(e,c,o);return t(n),()=>{t(r.a.removeEventCallback(e,n.id))}}},,,,,,,,,,function(e,t,c){"use strict";var r=c(0),o=c(13);const n=Object(r.createElement)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(r.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(r.createElement)("path",{d:"M15.55 13c.75 0 1.41-.41 1.75-1.03l3.58-6.49c.37-.66-.11-1.48-.87-1.48H5.21l-.94-2H1v2h2l3.6 7.59-1.35 2.44C4.52 15.37 5.48 17 7 17h12v-2H7l1.1-2h7.45zM6.16 6h12.15l-2.76 5H8.53L6.16 6zM7 18c-1.1 0-1.99.9-1.99 2S5.9 22 7 22s2-.9 2-2-.9-2-2-2zm10 0c-1.1 0-1.99.9-1.99 2s.89 2 1.99 2 2-.9 2-2-.9-2-2-2z"}));t.a=n},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t,c){"use strict";var r=c(61);let o={headingLevel:{type:"number",default:2},showProductLink:{type:"boolean",default:!0},linkTarget:{type:"string"},productId:{type:"number",default:0}};Object(r.b)()&&(o={...o,align:{type:"string"}}),t.a=o},function(e,t,c){"use strict";c.d(t,"a",(function(){return r}));const r={showProductLink:{type:"boolean",default:!0},showSaleBadge:{type:"boolean",default:!0},saleBadgeAlign:{type:"string",default:"right"},imageSizing:{type:"string",default:"full-size"},productId:{type:"number",default:0},isDescendentOfQueryLoop:{type:"boolean",default:!1}}},function(e,t,c){"use strict";c.d(t,"a",(function(){return o})),c.d(t,"b",(function(){return n}));var r=c(58);const o=async(e,t,c)=>{const o=Object(r.a)(e,t),n=[];for(const e of o)try{const t=await Promise.resolve(e.callback(c));"object"==typeof t&&n.push(t)}catch(e){console.error(e)}return!n.length||n},n=async(e,t,c)=>{const o=[],n=Object(r.a)(e,t);for(const e of n)try{const t=await Promise.resolve(e.callback(c));if("object"!=typeof t||null===t)continue;if(!t.hasOwnProperty("type"))throw new Error("Returned objects from event emitter observers must return an object with a type property");if(Object(r.b)(t)||Object(r.c)(t))return o.push(t),o;o.push(t)}catch(e){return console.error(e),o.push({type:"error"}),o}return o}},function(e,t,c){"use strict";t.a={showFormElements:{type:"boolean",default:!1},productId:{type:"number",default:0}}},,,,,,,,,function(e,t,c){"use strict";c.r(t);var r=c(0),o=c(4),n=c.n(o),a=c(119),s=c(22),l=c(23),i=c(99),u=c(88),d=c(42);c(354),t.default=Object(d.withProductDataContext)(e=>{const{className:t}=e,{parentClassName:c}=Object(l.useInnerBlockLayoutContext)(),{product:o}=Object(l.useProductDataContext)(),d=Object(i.a)(e),b=Object(u.a)(e);if(!o)return Object(r.createElement)("div",{className:n()(t,"wc-block-components-product-summary",{[c+"__product-summary"]:c})});const p=o.short_description?o.short_description:o.description;return p?Object(r.createElement)(a.a,{className:n()(t,d.className,"wc-block-components-product-summary",{[c+"__product-summary"]:c}),source:p,maxLength:150,countType:s.o.wordCountType||"words",style:{...d.style,...b.style}}):null})},function(e,t,c){"use strict";c.r(t);var r=c(0),o=c(1),n=c(4),a=c.n(n),s=c(23),l=c(42);c(355),t.default=Object(l.withProductDataContext)(e=>{const{className:t}=e,{parentClassName:c}=Object(s.useInnerBlockLayoutContext)(),{product:n}=Object(s.useProductDataContext)(),l=n.sku;return l?Object(r.createElement)("div",{className:a()(t,"wc-block-components-product-sku",{[c+"__product-sku"]:c})},Object(o.__)("SKU:","woo-gutenberg-products-block")," ",Object(r.createElement)("strong",null,l)):null})},function(e,t,c){"use strict";c.r(t);var r=c(0),o=c(1),n=c(4),a=c.n(n),s=c(23),l=c(99),i=c(88),u=c(8),d=c(42);c(356),t.default=Object(d.withProductDataContext)(e=>{const{className:t}=e,{parentClassName:c}=Object(s.useInnerBlockLayoutContext)(),{product:n}=Object(s.useProductDataContext)(),d=Object(l.a)(e),b=Object(i.a)(e);return Object(u.isEmpty)(n.categories)?null:Object(r.createElement)("div",{className:a()(t,"wc-block-components-product-category-list",d.className,{[c+"__product-category-list"]:c}),style:{...d.style,...b.style}},Object(o.__)("Categories:","woo-gutenberg-products-block")," ",Object(r.createElement)("ul",null,Object.values(n.categories).map(e=>{let{name:t,link:c,slug:o}=e;return Object(r.createElement)("li",{key:"category-list-item-"+o},Object(r.createElement)("a",{href:c},t))})))})},function(e,t,c){"use strict";c.r(t);var r=c(0),o=c(1),n=c(4),a=c.n(n),s=c(23),l=c(99),i=c(88),u=c(8),d=c(42);c(357),t.default=Object(d.withProductDataContext)(e=>{const{className:t}=e,{parentClassName:c}=Object(s.useInnerBlockLayoutContext)(),{product:n}=Object(s.useProductDataContext)(),d=Object(l.a)(e),b=Object(i.a)(e);return Object(u.isEmpty)(n.tags)?null:Object(r.createElement)("div",{className:a()(t,d.className,"wc-block-components-product-tag-list",{[c+"__product-tag-list"]:c}),style:{...d.style,...b.style}},Object(o.__)("Tags:","woo-gutenberg-products-block")," ",Object(r.createElement)("ul",null,Object.values(n.tags).map(e=>{let{name:t,link:c,slug:o}=e;return Object(r.createElement)("li",{key:"tag-list-item-"+o},Object(r.createElement)("a",{href:c},t))})))})},function(e,t,c){"use strict";c.r(t);var r=c(0),o=c(1),n=c(4),a=c.n(n),s=c(23),l=c(99),i=c(88),u=c(42);c(358);t.default=Object(u.withProductDataContext)(e=>{const{className:t}=e,{parentClassName:c}=Object(s.useInnerBlockLayoutContext)(),{product:n}=Object(s.useProductDataContext)(),u=Object(l.a)(e),d=Object(i.a)(e);if(!n.id||!n.is_purchasable)return null;const b=!!n.is_in_stock,p=n.low_stock_remaining,m=n.is_on_backorder;return Object(r.createElement)("div",{className:a()(t,u.className,"wc-block-components-product-stock-indicator",{[c+"__stock-indicator"]:c,"wc-block-components-product-stock-indicator--in-stock":b,"wc-block-components-product-stock-indicator--out-of-stock":!b,"wc-block-components-product-stock-indicator--low-stock":!!p,"wc-block-components-product-stock-indicator--available-on-backorder":!!m}),style:{...u.style,...d.style}},p?(e=>Object(o.sprintf)(
|
25 |
/* translators: %d stock amount (number of items in stock for product) */
|
26 |
-
Object(o.__)("%d left in stock","woo-gutenberg-products-block"),e))(p):((e,t)=>t?Object(o.__)("Available on backorder","woo-gutenberg-products-block"):e?Object(o.__)("In Stock","woo-gutenberg-products-block"):Object(o.__)("Out of Stock","woo-gutenberg-products-block"))(b,m))})},,,,,,,,,,,,,,,,,,,,,,,function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,c){"use strict";c.d(t,"a",(function(){return r})),c.d(t,"b",(function(){return o}));const r=e=>e.is_purchasable||!1,o=e=>["simple","variable"].includes(e.type||"simple")},,,,,,,,,,,,,,,,,,,,,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return n}));var r=c(1),o=c(
|
27 |
/* translators: %s: heading level e.g: "2", "3", "4" */
|
28 |
-
Object(l.__)("Heading %d","woo-gutenberg-products-block"),e),isActive:o,onClick:()=>c(e)}}render(){const{isCollapsed:e=!0,minLevel:t,maxLevel:c,selectedLevel:o,onChange:n}=this.props;return Object(r.createElement)(p.ToolbarGroup,{isCollapsed:e,icon:Object(r.createElement)(h,{level:o}),controls:Object(O.range)(t,c).map(e=>this.createLevelControl(e,o,n))})}}var E=_,w=c(196),f=c(97),k=c(152),y=c(23);c(393);var v=e=>t=>c=>{var o;const n=Object(y.useProductDataContext)(),{attributes:a,setAttributes:s}=c,{productId:i}=a,[u,d]=Object(r.useState)(!i);return n.hasContext||Number.isFinite(null===(o=c.context)||void 0===o?void 0:o.queryId)?Object(r.createElement)(t,c):Object(r.createElement)(r.Fragment,null,u?Object(r.createElement)(p.Placeholder,{icon:e.icon||"",label:e.label||"",className:"wc-atomic-blocks-product"},!!e.description&&Object(r.createElement)("div",null,e.description),Object(r.createElement)("div",{className:"wc-atomic-blocks-product__selection"},Object(r.createElement)(f.a,{selected:i||0,showVariations:!0,onChange:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];s({productId:e[0]?e[0].id:0})}}),Object(r.createElement)(p.Button,{isSecondary:!0,disabled:!i,onClick:()=>{d(!1)}},Object(l.__)("Done","woo-gutenberg-products-block")))):Object(r.createElement)(r.Fragment,null,Object(r.createElement)(g.BlockControls,null,Object(r.createElement)(p.ToolbarGroup,null,Object(r.createElement)(k.a,{onClick:()=>d(!0)},Object(l.__)("Switch product…","woo-gutenberg-products-block")))),Object(r.createElement)(t,c)))},S=c(536);const C=Object(l.__)("Product Title","woo-gutenberg-products-block"),x=Object(r.createElement)(n.a,{icon:S.a,className:"wc-block-editor-components-block-icon"}),N=Object(l.__)("Display the title of a product.","woo-gutenberg-products-block");c(394);const P=e=>{let{attributes:t,setAttributes:c}=e;const o=Object(g.useBlockProps)(),{headingLevel:n,showProductLink:a,align:i,linkTarget:u}=t;return Object(r.createElement)("div",o,Object(r.createElement)(g.BlockControls,null,Object(r.createElement)(E,{isCollapsed:!0,minLevel:1,maxLevel:7,selectedLevel:n,onChange:e=>c({headingLevel:e})}),Object(s.b)()&&Object(r.createElement)(g.AlignmentToolbar,{value:i,onChange:e=>{c({align:e})}})),Object(r.createElement)(g.InspectorControls,null,Object(r.createElement)(p.PanelBody,{title:Object(l.__)("Link settings","woo-gutenberg-products-block")},Object(r.createElement)(p.ToggleControl,{label:Object(l.__)("Make title a link","woo-gutenberg-products-block"),checked:a,onChange:()=>c({showProductLink:!a})}),a&&Object(r.createElement)(r.Fragment,null,Object(r.createElement)(p.ToggleControl,{label:Object(l.__)("Open in new tab","woo-gutenberg-products-block"),onChange:e=>c({linkTarget:e?"_blank":"_self"}),checked:"_blank"===u})))),Object(r.createElement)(p.Disabled,null,Object(r.createElement)(w.b,t)))};var T=Object(s.b)()?Object(m.compose)([v({icon:x,label:C,description:Object(l.__)("Choose a product to display its title.","woo-gutenberg-products-block")})])(P):P,I=c(128);const R={...d,apiVersion:2,title:C,description:N,icon:{src:x},attributes:b.a,edit:T,save:e=>{let{attributes:t}=e;return Object(r.createElement)("div",g.useBlockProps.save({className:u()("is-loading",t.className)}))},supports:{...d.supports,...Object(s.b)()&&{typography:{fontSize:!0,lineHeight:!0,__experimentalFontWeight:!0,__experimentalTextTransform:!0,__experimentalFontFamily:!0},color:{text:!0,background:!0,link:!1,gradients:!0,__experimentalSkipSerialization:!0},...Object(I.a)()&&{spacing:{margin:!0,__experimentalSkipSerialization:!0}},__experimentalSelector:".wc-block-components-product-title"}}};Object(o.registerBlockType)("woocommerce/product-title",R);var A=c(12),B=c(210),L=c(537);const D=Object(l.__)("Product Price","woo-gutenberg-products-block"),F=Object(r.createElement)(n.a,{icon:L.a,className:"wc-block-editor-components-block-icon"}),V=Object(l.__)("Display the price of a product.","woo-gutenberg-products-block");var z=v({icon:F,label:D,description:Object(l.__)("Choose a product to display its price.","woo-gutenberg-products-block")})(e=>{let{attributes:t,setAttributes:c,context:o}=e;const n=Object(g.useBlockProps)(),a={...t,...o},l=Number.isFinite(o.queryId);return Object(A.useEffect)(()=>c({isDescendentOfQueryLoop:l}),[c,l]),Object(r.createElement)(r.Fragment,null,Object(r.createElement)(g.BlockControls,null,Object(s.b)()&&Object(r.createElement)(g.AlignmentToolbar,{value:t.textAlign,onChange:e=>{c({textAlign:e})}})),Object(r.createElement)("div",n,Object(r.createElement)(B.default,a)))});let M={productId:{type:"number",default:0},isDescendentOfQueryLoop:{type:"boolean",default:!1}};Object(s.b)()&&(M={...M,textAlign:{type:"string"}});var q=M;const H={...d,apiVersion:2,title:D,description:V,ancestor:["@woocommerce/all-products","@woocommerce/single-product","core/post-template"],usesContext:["query","queryId","postId"],icon:{src:F},attributes:q,edit:z,supports:{...d.supports,...Object(s.b)()&&{color:{text:!0,background:!1,link:!1,__experimentalSkipSerialization:!0},typography:{fontSize:!0,__experimentalFontWeight:!0,__experimentalFontStyle:!0,__experimentalSkipSerialization:!0},__experimentalSelector:".wc-block-components-product-price"}}};Object(o.registerBlockType)("woocommerce/product-price",H);var Q=c(538),G=c(6),Y=c.n(G),U=c(2),W=c(127),K=c(197);const $={html:!1,...Object(s.b)()&&{__experimentalBorder:{radius:!0,__experimentalSkipSerialization:!0},typography:{fontSize:!0,__experimentalSkipSerialization:!0},...Object(I.a)()&&{spacing:{margin:!0,__experimentalSkipSerialization:!0}},__experimentalSelector:".wc-block-components-product-image"}};var J=c(316);const X={apiVersion:2,name:"woocommerce/product-image",title:Object(l.__)("Product Image","woo-gutenberg-products-block"),icon:{src:Object(r.createElement)(n.a,{icon:Q.a,className:"wc-block-editor-components-block-icon"})},keywords:["WooCommerce"],description:Object(l.__)("Display the main product image.","woo-gutenberg-products-block"),usesContext:["query","queryId","postId"],parent:["@woocommerce/all-products","@woocommerce/single-product","core/post-template"],textdomain:"woo-gutenberg-products-block",attributes:J.a,supports:$,edit:e=>{let{attributes:t,setAttributes:c,context:o}=e;const{showProductLink:n,imageSizing:a,showSaleBadge:s,saleBadgeAlign:i}=t,u=Object(g.useBlockProps)(),d=Number.isFinite(o.queryId);Object(r.useEffect)(()=>c({isDescendentOfQueryLoop:d}),[c,d]);const b=Object(U.getSettingWithCoercion)("is_block_theme_enabled",!1,W.a);return Object(r.useEffect)(()=>{b&&"full-size"!==t.imageSizing&&c({imageSizing:"full-size"})},[t.imageSizing,b,c]),Object(r.createElement)("div",u,Object(r.createElement)(g.InspectorControls,null,Object(r.createElement)(p.PanelBody,{title:Object(l.__)("Content","woo-gutenberg-products-block")},Object(r.createElement)(p.ToggleControl,{label:Object(l.__)("Link to Product Page","woo-gutenberg-products-block"),help:Object(l.__)("Links the image to the single product listing.","woo-gutenberg-products-block"),checked:n,onChange:()=>c({showProductLink:!n})}),Object(r.createElement)(p.ToggleControl,{label:Object(l.__)("Show On-Sale Badge","woo-gutenberg-products-block"),help:Object(l.__)("Display a “sale” badge if the product is on-sale.","woo-gutenberg-products-block"),checked:s,onChange:()=>c({showSaleBadge:!s})}),s&&Object(r.createElement)(p.__experimentalToggleGroupControl,{label:Object(l.__)("Sale Badge Alignment","woo-gutenberg-products-block"),value:i,onChange:e=>c({saleBadgeAlign:e})},Object(r.createElement)(p.__experimentalToggleGroupControlOption,{value:"left",label:Object(l.__)("Left","woo-gutenberg-products-block")}),Object(r.createElement)(p.__experimentalToggleGroupControlOption,{value:"center",label:Object(l.__)("Center","woo-gutenberg-products-block")}),Object(r.createElement)(p.__experimentalToggleGroupControlOption,{value:"right",label:Object(l.__)("Right","woo-gutenberg-products-block")})),!b&&Object(r.createElement)(p.__experimentalToggleGroupControl,{label:Object(l.__)("Image Sizing","woo-gutenberg-products-block"),help:Object(r.createInterpolateElement)(Object(l.__)("Product image cropping can be modified in the <a>Customizer</a>.","woo-gutenberg-products-block"),{a:Object(r.createElement)("a",{href:Object(U.getAdminLink)("customize.php")+"?autofocus[panel]=woocommerce&autofocus[section]=woocommerce_product_images",target:"_blank",rel:"noopener noreferrer"})}),value:a,onChange:e=>c({imageSizing:e})},Object(r.createElement)(p.__experimentalToggleGroupControlOption,{value:"full-size",label:Object(l.__)("Full Size","woo-gutenberg-products-block")}),Object(r.createElement)(p.__experimentalToggleGroupControlOption,{value:"cropped",label:Object(l.__)("Cropped","woo-gutenberg-products-block")})))),Object(r.createElement)(p.Disabled,null,Object(r.createElement)(K.b,Y()({},t,o))))}};Object(o.registerBlockType)("woocommerce/product-image",{...d,...X});var Z=c(211),ee=c(531);const te=Object(l.__)("Product Rating","woo-gutenberg-products-block"),ce=Object(r.createElement)(n.a,{icon:ee.a,className:"wc-block-editor-components-block-icon"}),re=Object(l.__)("Display the average rating of a product.","woo-gutenberg-products-block");var oe=v({icon:ce,label:te,description:Object(l.__)("Choose a product to display its rating.","woo-gutenberg-products-block")})(e=>{let{attributes:t,setAttributes:c,context:o}=e;const n=Object(g.useBlockProps)({className:"wp-block-woocommerce-product-rating"}),a={...t,...o},s=Number.isFinite(o.queryId);return Object(A.useEffect)(()=>c({isDescendentOfQueryLoop:s}),[c,s]),Object(r.createElement)("div",n,Object(r.createElement)(Z.default,a))});const ne={apiVersion:2,title:te,description:re,usesContext:["query","queryId","postId"],ancestor:["@woocommerce/all-products","@woocommerce/single-product","core/post-template"],icon:{src:ce},attributes:{productId:{type:"number",default:0},isDescendentOfQueryLoop:{type:"boolean",default:!1}},supports:{...Object(s.b)()&&{color:{text:!0,background:!1,link:!1,__experimentalSkipSerialization:!0},typography:{fontSize:!0,__experimentalSkipSerialization:!0},...Object(I.a)()&&{spacing:{margin:!0,__experimentalSkipSerialization:!0}},__experimentalSelector:".wc-block-components-product-rating"}},edit:oe};Object(o.registerBlockType)("woocommerce/product-rating",{...d,...ne});var ae=c(212),se=c(539);const le=Object(l.__)("Add to Cart Button","woo-gutenberg-products-block"),ie=Object(r.createElement)(n.a,{icon:se.a,className:"wc-block-editor-components-block-icon"}),ue={apiVersion:2,title:le,description:Object(l.__)("Display a call to action button which either adds the product to the cart, or links to the product page.","woo-gutenberg-products-block"),ancestor:["@woocommerce/all-products","@woocommerce/single-product","core/post-template"],usesContext:["query","queryId","postId"],icon:{src:ie},attributes:{productId:{type:"number",default:0},isDescendentOfQueryLoop:{type:"boolean",default:!1}},supports:{...Object(s.b)()&&{color:{text:!0,background:!0,link:!1,__experimentalSkipSerialization:!0},__experimentalBorder:{radius:!0,__experimentalSkipSerialization:!0},...Object(I.a)()&&{spacing:{padding:!0,__experimentalSkipSerialization:!0}},typography:{fontSize:!0,__experimentalFontWeight:!0,__experimentalSkipSerialization:!0},__experimentalSelector:".wp-block-button.wc-block-components-product-button .wc-block-components-product-button__button"}},edit:e=>{let{attributes:t,setAttributes:c,context:o}=e;const n=Object(g.useBlockProps)(),a=Number.isFinite(o.queryId);return Object(r.useEffect)(()=>c({isDescendentOfQueryLoop:a}),[c,a]),Object(r.createElement)("div",n,Object(r.createElement)(p.Disabled,null,Object(r.createElement)(ae.default,Y()({},t,o))))}};Object(o.registerBlockType)("woocommerce/product-button",{...d,...ue});var de=c(327),be=c(540);const pe=Object(l.__)("Product Summary","woo-gutenberg-products-block"),me=Object(r.createElement)(n.a,{icon:be.a,className:"wc-block-editor-components-block-icon"}),ge=Object(l.__)("Display a short description about a product.","woo-gutenberg-products-block");c(395);var Oe=v({icon:me,label:pe,description:ge})(e=>{let{attributes:t}=e;const c=Object(g.useBlockProps)();return Object(r.createElement)("div",c,Object(r.createElement)(de.default,t))});const je={...Object(s.b)()&&{color:{background:!1},typography:{fontSize:!0},__experimentalSelector:".wc-block-components-product-summary"}},he={...d,apiVersion:2,title:pe,description:ge,icon:{src:me},attributes:{productId:{type:"number",default:0}},supports:je,edit:Oe,save:e=>{let{attributes:t}=e;return Object(r.createElement)("div",g.useBlockProps.save({className:u()("is-loading",t.className)}))}};Object(o.registerBlockType)("woocommerce/product-summary",he);var _e=c(141),Ee=c(529);const we=Object(l.__)("On-Sale Badge","woo-gutenberg-products-block"),fe=Object(r.createElement)(n.a,{icon:Ee.a,className:"wc-block-editor-components-block-icon"}),ke=Object(l.__)("Displays an on-sale badge if the product is on-sale.","woo-gutenberg-products-block");var ye=v({icon:fe,label:we,description:ke})(e=>{let{attributes:t}=e;const c=Object(g.useBlockProps)();return Object(r.createElement)("div",c,Object(r.createElement)(_e.default,t))});const ve={html:!1,...Object(s.b)()&&{color:{gradients:!0,background:!0,link:!1,__experimentalSkipSerialization:!0},typography:{fontSize:!0,__experimentalSkipSerialization:!0},__experimentalBorder:{color:!0,radius:!0,width:!0,__experimentalSkipSerialization:!0},...Object(I.a)()&&{spacing:{padding:!0,__experimentalSkipSerialization:!0}},__experimentalSelector:".wc-block-components-product-sale-badge"}},Se={...d,title:we,description:ke,icon:{src:fe},apiVersion:2,supports:ve,attributes:{productId:{type:"number",default:0}},edit:ye,save:e=>{let{attributes:t}=e;return Object(r.createElement)("div",g.useBlockProps.save({className:u()("is-loading",t.className)}))}};Object(o.registerBlockType)("woocommerce/product-sale-badge",{...Se});var Ce=c(108),xe=c(328),Ne=Object(r.createElement)(j.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(r.createElement)("path",{d:"M2 6h2v12H2V6m3 0h1v12H5V6m2 0h3v12H7V6m4 0h1v12h-1V6m3 0h2v12h-2V6m3 0h3v12h-3V6m4 0h1v12h-1V6z"}));const Pe=Object(l.__)("Product SKU","woo-gutenberg-products-block"),Te=Object(r.createElement)(n.a,{icon:Ne,className:"wc-block-editor-components-block-icon"}),Ie=Object(l.__)("Display the SKU of a product.","woo-gutenberg-products-block");var Re=v({icon:Te,label:Pe,description:Object(l.__)("Choose a product to display its SKU.","woo-gutenberg-products-block")})(e=>{let{attributes:t}=e;return Object(r.createElement)(r.Fragment,null,Object(r.createElement)(Ce.a,null),Object(r.createElement)(xe.default,t))});const Ae={...d,apiVersion:2,title:Pe,description:Ie,icon:{src:Te},attributes:{productId:{type:"number",default:0}},edit:Re};Object(s.c)("woocommerce/product-sku",{...d,...Ae});var Be=c(329),Le=c(541);const De=Object(l.__)("Product Category List","woo-gutenberg-products-block"),Fe=Object(r.createElement)(n.a,{icon:Le.a,className:"wc-block-editor-components-block-icon"}),Ve=Object(l.__)("Display the list of categories that are assigned to a product.","woo-gutenberg-products-block");var ze=v({icon:Fe,label:De,description:Object(l.__)("Choose a product to display its categories.","woo-gutenberg-products-block")})(e=>{let{attributes:t}=e;const c=Object(g.useBlockProps)();return Object(r.createElement)("div",c,Object(r.createElement)(Ce.a,null),Object(r.createElement)(p.Disabled,null,Object(r.createElement)(Be.default,t)))});const Me={...d,apiVersion:2,title:De,description:Ve,icon:{src:Fe},attributes:{productId:{type:"number",default:0}},supports:{...Object(s.b)()&&{color:{text:!0,link:!0,background:!1,__experimentalSkipSerialization:!0},typography:{fontSize:!0,lineHeight:!0,__experimentalFontStyle:!0,__experimentalFontWeight:!0,__experimentalSkipSerialization:!0},__experimentalSelector:".wc-block-components-product-category-list"}},save:e=>{let{attributes:t}=e;return Object(r.createElement)("div",g.useBlockProps.save({className:u()("is-loading",t.className)}))},edit:ze};Object(s.c)("woocommerce/product-category-list",Me);var qe=c(330),He=c(534);const Qe=Object(l.__)("Product Tag List","woo-gutenberg-products-block"),Ge=Object(r.createElement)(n.a,{icon:He.a,className:"wc-block-editor-components-block-icon"}),Ye=Object(l.__)("Display the list of tags that are assigned to a product.","woo-gutenberg-products-block");var Ue=v({icon:Ge,label:Qe,description:Object(l.__)("Choose a product to display its tags.","woo-gutenberg-products-block")})(e=>{let{attributes:t}=e;const c=Object(g.useBlockProps)();return Object(r.createElement)("div",c,Object(r.createElement)(Ce.a,null),Object(r.createElement)(p.Disabled,null,Object(r.createElement)(qe.default,t)))});const We={...Object(s.b)()&&{color:{text:!0,background:!1,link:!0},typography:{fontSize:!0},__experimentalSelector:".wc-block-components-product-tag-list"}},Ke={...d,apiVersion:2,title:Qe,description:Ye,icon:{src:Ge},attributes:{productId:{type:"number",default:0}},supports:We,edit:Ue,save:e=>{let{attributes:t}=e;return Object(r.createElement)("div",g.useBlockProps.save({className:u()("is-loading",t.className)}))}};Object(s.c)("woocommerce/product-tag-list",{...d,...Ke});var $e=c(331),Je=c(542);const Xe=Object(l.__)("Product Stock Indicator","woo-gutenberg-products-block"),Ze=Object(r.createElement)(n.a,{icon:Je.a,className:"wc-block-editor-components-block-icon"}),et=Object(l.__)("Display product stock status.","woo-gutenberg-products-block");var tt=v({icon:Ze,label:Xe,description:Object(l.__)("Choose a product to display its stock.","woo-gutenberg-products-block")})(e=>{let{attributes:t}=e;const c=Object(g.useBlockProps)();return Object(r.createElement)("div",c,Object(r.createElement)(Ce.a,null),Object(r.createElement)($e.default,t))});const ct={apiVersion:2,title:Xe,description:et,icon:{src:Ze},attributes:{productId:{type:"number",default:0}},supports:{...Object(s.b)()&&{color:{text:!0,background:!1,link:!1},typography:{fontSize:!0},__experimentalSelector:".wc-block-components-product-stock-indicator"}},edit:tt,save:e=>{let{attributes:t}=e;return Object(r.createElement)("div",g.useBlockProps.save({className:u()("is-loading",t.className)}))}};Object(s.c)("woocommerce/product-stock-indicator",{...d,...ct});var rt=c(359),ot=(c(236),c(209)),nt=c(278);const at=Object(l.__)("Add to Cart","woo-gutenberg-products-block"),st=Object(r.createElement)(n.a,{icon:nt.a,className:"wc-block-editor-components-block-icon"}),lt={title:at,description:Object(l.__)("Displays an add to cart button. Optionally displays other add to cart form elements.","woo-gutenberg-products-block"),icon:{src:st},edit:v({icon:st,label:at,description:Object(l.__)("Choose a product to display its add to cart form.","woo-gutenberg-products-block")})(e=>{let{attributes:t,setAttributes:c}=e;const{product:o}=Object(y.useProductDataContext)(),{className:n,showFormElements:a}=t;return Object(r.createElement)("div",{className:u()(n,"wc-block-components-product-add-to-cart")},Object(r.createElement)(Ce.a,{productId:o.id}),Object(r.createElement)(g.InspectorControls,null,Object(r.createElement)(p.PanelBody,{title:Object(l.__)("Layout","woo-gutenberg-products-block")},Object(rt.b)(o)?Object(r.createElement)(p.ToggleControl,{label:Object(l.__)("Display form elements","woo-gutenberg-products-block"),help:Object(l.__)("Depending on product type, allow customers to select a quantity, variations etc.","woo-gutenberg-products-block"),checked:a,onChange:()=>c({showFormElements:!a})}):Object(r.createElement)(p.Notice,{className:"wc-block-components-product-add-to-cart-notice",isDismissible:!1,status:"info"},Object(l.__)("This product does not support the block based add to cart form. A link to the product page will be shown instead.","woo-gutenberg-products-block")))),Object(r.createElement)(p.Disabled,null,Object(r.createElement)(ot.a,t)))}),attributes:c(318).a};Object(s.c)("woocommerce/product-add-to-cart",{...d,...lt});var it=c(222);const ut=(e,t)=>{const{className:c,contentVisibility:r}=t;return u()(e,c,{"has-image":r&&r.image,"has-title":r&&r.title,"has-rating":r&&r.rating,"has-price":r&&r.price,"has-button":r&&r.button})},{attributes:dt}=it;var bt=[{attributes:Object.assign({},dt,{rows:{type:"number",default:1}}),save(e){let{attributes:t}=e;const c={"data-attributes":JSON.stringify(t)};return Object(r.createElement)("div",Y()({className:ut("wc-block-all-products",t)},c),Object(r.createElement)(g.InnerBlocks.Content,null))}}],pt=c(24),mt=c.n(pt),gt=c(7),Ot=c(64),jt=c(509),ht=c(382),_t=c(22),Et=c(258);const wt=[["woocommerce/product-image",{imageSizing:"cropped"}],["woocommerce/product-title"],["woocommerce/product-price"],["woocommerce/product-rating"],["woocommerce/product-button"]],ft=e=>e&&0!==e.length?e.map(e=>[e.name,{...e.attributes,product:void 0,children:e.innerBlocks.length>0?ft(e.innerBlocks):[]}]):[];var kt=c(28);c(401);var yt=e=>{let{currentPage:t,displayFirstAndLastPages:c=!0,displayNextAndPreviousArrows:o=!0,pagesToDisplay:n=3,onPageChange:a,totalPages:s}=e,{minIndex:i,maxIndex:d}=((e,t,c)=>{if(c<=2)return{minIndex:null,maxIndex:null};const r=e-1,o=Math.max(Math.floor(t-r/2),2),n=Math.min(Math.ceil(t+(r-(t-o))),c-1);return{minIndex:Math.max(Math.floor(t-(r-(n-t))),2),maxIndex:n}})(n,t,s);const b=c&&Boolean(1!==i),p=c&&Boolean(d!==s),m=c&&Boolean(i&&i>3),g=c&&Boolean(d&&d<s-2);b&&3===i&&(i-=1),p&&d===s-2&&(d+=1);const O=[];if(i&&d)for(let e=i;e<=d;e++)O.push(e);return Object(r.createElement)("div",{className:"wc-block-pagination wc-block-components-pagination"},Object(r.createElement)(kt.a,{screenReaderLabel:Object(l.__)("Navigate to another page","woo-gutenberg-products-block")}),o&&Object(r.createElement)("button",{className:"wc-block-pagination-page wc-block-components-pagination__page wc-block-components-pagination-page--arrow",onClick:()=>a(t-1),title:Object(l.__)("Previous page","woo-gutenberg-products-block"),disabled:t<=1},Object(r.createElement)(kt.a,{label:"←",screenReaderLabel:Object(l.__)("Previous page","woo-gutenberg-products-block")})),b&&Object(r.createElement)("button",{className:u()("wc-block-pagination-page","wc-block-components-pagination__page",{"wc-block-pagination-page--active":1===t,"wc-block-components-pagination__page--active":1===t}),onClick:()=>a(1),disabled:1===t},Object(r.createElement)(kt.a,{label:"1",screenReaderLabel:Object(l.sprintf)(
|
29 |
/* translators: %d is the page number (1, 2, 3...). */
|
30 |
-
Object(l.__)("Page %d","woo-gutenberg-products-block"),1)})),m&&Object(r.createElement)("span",{className:"wc-block-pagination-ellipsis wc-block-components-pagination__ellipsis","aria-hidden":"true"},Object(l.__)("…","woo-gutenberg-products-block")),O.map(e=>Object(r.createElement)("button",{key:e,className:u()("wc-block-pagination-page","wc-block-components-pagination__page",{"wc-block-pagination-page--active":t===e,"wc-block-components-pagination__page--active":t===e}),onClick:t===e?void 0:()=>a(e),disabled:t===e},Object(r.createElement)(
|
31 |
/* translators: %d is the page number (1, 2, 3...). */
|
32 |
-
Object(l.__)("Page %d","woo-gutenberg-products-block"),e)}))),g&&Object(r.createElement)("span",{className:"wc-block-pagination-ellipsis wc-block-components-pagination__ellipsis","aria-hidden":"true"},Object(l.__)("…","woo-gutenberg-products-block")),p&&Object(r.createElement)("button",{className:u()("wc-block-pagination-page","wc-block-components-pagination__page",{"wc-block-pagination-page--active":t===s,"wc-block-components-pagination__page--active":t===s}),onClick:()=>a(s),disabled:t===s},Object(r.createElement)(
|
33 |
/* translators: %d is the page number (1, 2, 3...). */
|
34 |
-
Object(l.__)("Page %d","woo-gutenberg-products-block"),s)})),o&&Object(r.createElement)("button",{className:"wc-block-pagination-page wc-block-components-pagination__page wc-block-components-pagination-page--arrow",onClick:()=>a(t+1),title:Object(l.__)("Next page","woo-gutenberg-products-block"),disabled:t>=s},Object(r.createElement)(
|
35 |
/* translators: %s is an integer higher than 0 (1, 2, 3...) */
|
36 |
-
Object(l._n)("%d product found","%d products found",e,"woo-gutenberg-products-block"),e)))})(k))},[null==P?void 0:P.totalQuery,k,o,x]);const{contentVisibility:T}=t,I=t.columns*t.rows,R=!Number.isFinite(k)&&Number.isFinite(null==P?void 0:P.totalProducts)&&Object(O.isEqual)(x,null==P?void 0:P.totalQuery)?Math.ceil(((null==P?void 0:P.totalProducts)||0)/I):Math.ceil(k/I),A=f.length?f:Array.from({length:I}),B=0!==f.length||v,L=i.length>0||b.length>0||m.length>0||Number.isFinite(j)||Number.isFinite(_);return Object(r.createElement)("div",{className:(()=>{const{columns:e,rows:c,alignButtons:r,align:o}=t,n=void 0!==o?"align"+o:"";return u()(S,n,"has-"+e+"-columns",{"has-multiple-rows":c>1,"has-aligned-buttons":r})})()},(null==T?void 0:T.orderBy)&&B&&Object(r.createElement)(Lt,{onChange:n,value:a}),!B&&L&&Object(r.createElement)(At,{resetCallback:()=>{d([]),p([]),g([]),h(null),E(null)}}),!B&&!L&&Object(r.createElement)(It,null),B&&Object(r.createElement)("ul",{className:u()(S+"__products",{"is-loading-products":v})},A.map((function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},c=arguments.length>1?arguments[1]:void 0;return Object(r.createElement)(Ft,{key:e.id||c,attributes:t,product:e})}))),R>1&&Object(r.createElement)(yt,{currentPage:c,onPageChange:e=>{s({focusableSelector:"a, button"}),o(e)},totalPages:R}))},e=>{const t=Object(r.useRef)(null);return Object(r.createElement)(r.Fragment,null,Object(r.createElement)("div",{className:"with-scroll-to-top__scroll-point",ref:t,"aria-hidden":!0}),Object(r.createElement)(Mt,Y()({},e,{scrollToTop:e=>{null!==t.current&&((e,t)=>{const{focusableSelector:c}=t||{};window&&Number.isFinite(window.innerHeight)&&(c?((e,t)=>{var c;const r=(null===(c=e.parentElement)||void 0===c?void 0:c.querySelectorAll(t))||[];if(r.length){const e=r[0];Nt(e),null==e||e.focus()}else Nt(e)})(e,c):Nt(e))})(t.current,e)}})))}),Ht=e=>{let{attributes:t}=e;const[c,o]=Object(r.useState)(1),[n,a]=Object(r.useState)(t.orderby);return Object(r.useEffect)(()=>{a(t.orderby)},[t.orderby]),Object(r.createElement)(qt,{attributes:t,currentPage:c,onPageChange:e=>{o(e)},onSortChange:e=>{var t;const c=null==e||null===(t=e.target)||void 0===t?void 0:t.value;a(c),o(1)},sortValue:n})},Qt=c(151),Gt=c(251);class Yt extends A.Component{render(){const{attributes:e,urlParameterSuffix:t}=this.props;return e.isPreview?Qt.a:Object(r.createElement)(y.InnerBlockLayoutContextProvider,{parentName:"woocommerce/all-products",parentClassName:"wc-block-grid"},Object(r.createElement)(Gt.a,{context:"wc/all-products"}),Object(r.createElement)(Ht,{attributes:e,urlParameterSuffix:t}))}}var Ut=Yt;c(398);class Wt extends r.Component{constructor(){super(...arguments),mt()(this,"state",{isEditing:!1,innerBlocks:[]}),mt()(this,"blockMap",Object(jt.a)("woocommerce/all-products")),mt()(this,"componentDidMount",()=>{const{block:e}=this.props;this.setState({innerBlocks:e.innerBlocks})}),mt()(this,"getTitle",()=>Object(l.__)("All Products","woo-gutenberg-products-block")),mt()(this,"getIcon",()=>Object(r.createElement)(n.a,{icon:a.a})),mt()(this,"togglePreview",()=>{const{debouncedSpeak:e}=this.props;this.setState({isEditing:!this.state.isEditing}),this.state.isEditing||e(Object(l.__)("Showing All Products block preview.","woo-gutenberg-products-block"))}),mt()(this,"getInspectorControls",()=>{const{attributes:e,setAttributes:t}=this.props,{columns:c,rows:o,alignButtons:n}=e;return Object(r.createElement)(g.InspectorControls,{key:"inspector"},Object(r.createElement)(p.PanelBody,{title:Object(l.__)("Layout Settings","woo-gutenberg-products-block"),initialOpen:!0},Object(r.createElement)(Ot.a,{columns:c,rows:o,alignButtons:n,setAttributes:t,minColumns:Object(U.getSetting)("min_columns",1),maxColumns:Object(U.getSetting)("max_columns",6),minRows:Object(U.getSetting)("min_rows",1),maxRows:Object(U.getSetting)("max_rows",6)})),Object(r.createElement)(p.PanelBody,{title:Object(l.__)("Content Settings","woo-gutenberg-products-block")},((e,t)=>{const{contentVisibility:c}=e;return Object(r.createElement)(p.ToggleControl,{label:Object(l.__)("Show Sorting Dropdown","woo-gutenberg-products-block"),checked:c.orderBy,onChange:()=>t({contentVisibility:{...c,orderBy:!c.orderBy}})})})(e,t),((e,t)=>Object(r.createElement)(p.SelectControl,{label:Object(l.__)("Order Products By","woo-gutenberg-products-block"),value:e.orderby,options:[{label:Object(l.__)("Default sorting (menu order)","woo-gutenberg-products-block"),value:"menu_order"},{label:Object(l.__)("Popularity","woo-gutenberg-products-block"),value:"popularity"},{label:Object(l.__)("Average rating","woo-gutenberg-products-block"),value:"rating"},{label:Object(l.__)("Latest","woo-gutenberg-products-block"),value:"date"},{label:Object(l.__)("Price: low to high","woo-gutenberg-products-block"),value:"price"},{label:Object(l.__)("Price: high to low","woo-gutenberg-products-block"),value:"price-desc"}],onChange:e=>t({orderby:e})}))(e,t)))}),mt()(this,"getBlockControls",()=>{const{isEditing:e}=this.state;return Object(r.createElement)(g.BlockControls,null,Object(r.createElement)(p.ToolbarGroup,{controls:[{icon:"edit",title:Object(l.__)("Edit the layout of each product","woo-gutenberg-products-block"),onClick:()=>this.togglePreview(),isActive:e}]}))}),mt()(this,"renderEditMode",()=>{const e={template:this.props.attributes.layoutConfig,templateLock:!1,allowedBlocks:Object.keys(this.blockMap)};return 0!==this.props.attributes.layoutConfig.length&&(e.renderAppender=!1),Object(r.createElement)(p.Placeholder,{icon:this.getIcon(),label:this.getTitle()},Object(l.__)("Display all products from your store as a grid.","woo-gutenberg-products-block"),Object(r.createElement)("div",{className:"wc-block-all-products-grid-item-template"},Object(r.createElement)(p.Tip,null,Object(l.__)("Edit the blocks inside the example below to change the content displayed for all products within the product grid.","woo-gutenberg-products-block")),Object(r.createElement)(y.InnerBlockLayoutContextProvider,{parentName:"woocommerce/all-products",parentClassName:"wc-block-grid"},Object(r.createElement)("div",{className:"wc-block-grid wc-block-layout has-1-columns"},Object(r.createElement)("ul",{className:"wc-block-grid__products"},Object(r.createElement)("li",{className:"wc-block-grid__product"},Object(r.createElement)(y.ProductDataContextProvider,{product:ht.a[0]},Object(r.createElement)(g.InnerBlocks,e)))))),Object(r.createElement)("div",{className:"wc-block-all-products__actions"},Object(r.createElement)(p.Button,{className:"wc-block-all-products__done-button",isPrimary:!0,onClick:()=>{const{block:e,setAttributes:t}=this.props;t({layoutConfig:ft(e.innerBlocks)}),this.setState({innerBlocks:e.innerBlocks}),this.togglePreview()}},Object(l.__)("Done","woo-gutenberg-products-block")),Object(r.createElement)(p.Button,{className:"wc-block-all-products__cancel-button",isTertiary:!0,onClick:()=>{const{block:e,replaceInnerBlocks:t}=this.props,{innerBlocks:c}=this.state;t(e.clientId,c,!1),this.togglePreview()}},Object(l.__)("Cancel","woo-gutenberg-products-block")),Object(r.createElement)(p.Button,{className:"wc-block-all-products__reset-button",icon:Object(r.createElement)(n.a,{icon:a.a}),label:Object(l.__)("Reset layout to default","woo-gutenberg-products-block"),onClick:()=>{const{block:e,replaceInnerBlocks:t}=this.props,c=[];wt.map(e=>{let[t,r]=e;return c.push(Object(o.createBlock)(t,r)),!0}),t(e.clientId,c,!1),this.setState({innerBlocks:e.innerBlocks})}},Object(l.__)("Reset Layout","woo-gutenberg-products-block")))))}),mt()(this,"renderViewMode",()=>{const{attributes:e}=this.props,{layoutConfig:t}=e,c=t&&0!==t.length,o=this.getTitle(),n=this.getIcon();return c?Object(r.createElement)(p.Disabled,null,Object(r.createElement)(Ut,{attributes:e})):((e,t)=>Object(r.createElement)(p.Placeholder,{className:"wc-block-products",icon:t,label:e},Object(l.__)("The content for this block is hidden due to block settings.","woo-gutenberg-products-block")))(o,n)}),mt()(this,"render",()=>{const{attributes:e}=this.props,{isEditing:t}=this.state,c=this.getTitle(),o=this.getIcon();return 0===_t.o.productCount?((e,t)=>Object(r.createElement)(p.Placeholder,{className:"wc-block-products",icon:t,label:e},Object(r.createElement)("p",null,Object(l.__)("You haven't published any products to list here yet.","woo-gutenberg-products-block")),Object(r.createElement)(p.Button,{className:"wc-block-products__add-product-button",isSecondary:!0,href:U.ADMIN_URL+"post-new.php?post_type=product"},Object(l.__)("Add new product","woo-gutenberg-products-block")+" ",Object(r.createElement)(n.a,{icon:Et.a})),Object(r.createElement)(p.Button,{className:"wc-block-products__read_more_button",isTertiary:!0,href:"https://docs.woocommerce.com/document/managing-products/"},Object(l.__)("Learn more","woo-gutenberg-products-block"))))(c,o):Object(r.createElement)("div",{className:ut("wc-block-all-products",e)},this.getBlockControls(),this.getInspectorControls(),t?this.renderEditMode():this.renderViewMode())})}}var Kt=Object(m.compose)(p.withSpokenMessages,Object(gt.withSelect)((e,t)=>{let{clientId:c}=t;const{getBlock:r}=e("core/block-editor");return{block:r(c)}}),Object(gt.withDispatch)(e=>{const{replaceInnerBlocks:t}=e("core/block-editor");return{replaceInnerBlocks:t}}))(Wt),$t={columns:Object(U.getSetting)("default_columns",3),rows:Object(U.getSetting)("default_rows",3),alignButtons:!1,contentVisibility:{orderBy:!0},orderby:"date",layoutConfig:wt,isPreview:!1};const{name:Jt}=it,Xt={icon:{src:Object(r.createElement)(n.a,{icon:a.a,className:"wc-block-editor-components-block-icon"})},edit:Kt,save:function(e){let{attributes:t}=e;const c={};Object.keys(t).sort().forEach(e=>{c[e]=t[e]});const o={"data-attributes":JSON.stringify(c)};return Object(r.createElement)("div",Y()({className:ut("wc-block-all-products",t)},o),Object(r.createElement)(g.InnerBlocks.Content,null))},deprecated:bt,defaults:$t};Object(o.registerBlockType)(Jt,Xt)},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return a}));var r=c(36),o=c(0),n=c(22);c.p=n.l,Object(r.registerBlockComponent)({blockName:"woocommerce/product-price",component:Object(o.lazy)(()=>Promise.all([c.e(0),c.e(1),c.e(2),c.e(28)]).then(c.bind(null,210)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-image",component:Object(o.lazy)(()=>Promise.all([c.e(1),c.e(2),c.e(4),c.e(3),c.e(25)]).then(c.bind(null,564)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-title",component:Object(o.lazy)(()=>Promise.all([c.e(1),c.e(2),c.e(4),c.e(3),c.e(38)]).then(c.bind(null,565)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-rating",component:Object(o.lazy)(()=>Promise.all([c.e(1),c.e(2),c.e(4),c.e(3),c.e(30)]).then(c.bind(null,211)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-button",component:Object(o.lazy)(()=>Promise.all([c.e(1),c.e(2),c.e(4),c.e(3),c.e(21)]).then(c.bind(null,212)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-summary",component:Object(o.lazy)(()=>Promise.all([c.e(1),c.e(2),c.e(35)]).then(c.bind(null,327)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-sale-badge",component:Object(o.lazy)(()=>Promise.all([c.e(1),c.e(2),c.e(4),c.e(31)]).then(c.bind(null,141)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-sku",component:Object(o.lazy)(()=>c.e(33).then(c.bind(null,328)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-category-list",component:Object(o.lazy)(()=>Promise.all([c.e(1),c.e(2),c.e(24)]).then(c.bind(null,329)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-tag-list",component:Object(o.lazy)(()=>Promise.all([c.e(1),c.e(2),c.e(37)]).then(c.bind(null,330)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-stock-indicator",component:Object(o.lazy)(()=>Promise.all([c.e(1),c.e(2),c.e(34)]).then(c.bind(null,331)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-add-to-cart",component:Object(o.lazy)(()=>Promise.all([c.e(0),c.e(1),c.e(3),c.e(19)]).then(c.bind(null,566)))});const a=e=>Object(r.getRegisteredBlockComponents)(e)}]);
|
1 |
+
this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["all-products"]=function(e){function t(t){for(var r,a,s=t[0],l=t[1],i=t[2],d=0,b=[];d<s.length;d++)a=s[d],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&b.push(o[a][0]),o[a]=0;for(r in l)Object.prototype.hasOwnProperty.call(l,r)&&(e[r]=l[r]);for(u&&u(t);b.length;)b.shift()();return n.push.apply(n,i||[]),c()}function c(){for(var e,t=0;t<n.length;t++){for(var c=n[t],r=!0,s=1;s<c.length;s++){var l=c[s];0!==o[l]&&(r=!1)}r&&(n.splice(t--,1),e=a(a.s=c[0]))}return e}var r={},o={6:0,1:0,2:0,3:0,4:0,21:0,24:0,28:0,30:0,31:0,33:0,34:0,35:0,37:0},n=[];function a(t){if(r[t])return r[t].exports;var c=r[t]={i:t,l:!1,exports:{}};return e[t].call(c.exports,c,c.exports,a),c.l=!0,c.exports}a.e=function(e){var t=[],c=o[e];if(0!==c)if(c)t.push(c[2]);else{var r=new Promise((function(t,r){c=o[e]=[t,r]}));t.push(c[2]=r);var n,s=document.createElement("script");s.charset="utf-8",s.timeout=120,a.nc&&s.setAttribute("nonce",a.nc),s.src=function(e){return a.p+""+({1:"product-add-to-cart--product-button--product-category-list--product-image--product-price--product-r--a0326d00",2:"product-button--product-category-list--product-image--product-price--product-rating--product-sale-b--e17c7c01",3:"product-add-to-cart--product-button--product-image--product-rating--product-title",4:"product-button--product-image--product-rating--product-sale-badge--product-title",19:"product-add-to-cart",21:"product-button",24:"product-category-list",25:"product-image",28:"product-price",30:"product-rating",31:"product-sale-badge",33:"product-sku",34:"product-stock-indicator",35:"product-summary",37:"product-tag-list",38:"product-title"}[e]||e)+".js?ver="+{1:"f51a0c24bc28ca163eaa",2:"940deb39870f1b128dc3",3:"9bdbf32fcaf83d6afa64",4:"c39d74f9b0eb33a42891",19:"4d8541c7863a3da6079d",21:"99b019b83cbdccca2b6a",24:"d32a34494a95d82420e5",25:"a4d4fc674b44205ca72a",28:"0a2fa1be5ae6d3af95b6",30:"f5fe2cddb2f6f5a622f4",31:"37711eded4c462911a61",33:"3890987eb879aac1499a",34:"6198127f545593c440a8",35:"b5a8be4602e13047e835",37:"558fc0e1925bb3243378",38:"b63b22807d592c1a36ad"}[e]}(e);var l=new Error;n=function(t){s.onerror=s.onload=null,clearTimeout(i);var c=o[e];if(0!==c){if(c){var r=t&&("load"===t.type?"missing":t.type),n=t&&t.target&&t.target.src;l.message="Loading chunk "+e+" failed.\n("+r+": "+n+")",l.name="ChunkLoadError",l.type=r,l.request=n,c[1](l)}o[e]=void 0}};var i=setTimeout((function(){n({type:"timeout",target:s})}),12e4);s.onerror=s.onload=n,document.head.appendChild(s)}return Promise.all(t)},a.m=e,a.c=r,a.d=function(e,t,c){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:c})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var c=Object.create(null);if(a.r(c),Object.defineProperty(c,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)a.d(c,r,function(t){return e[t]}.bind(null,r));return c},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a.oe=function(e){throw console.error(e),e};var s=window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[],l=s.push.bind(s);s.push=t,s=s.slice();for(var i=0;i<s.length;i++)t(s[i]);var u=l;return n.push([382,0]),c()}([function(e,t){e.exports=window.wp.element},function(e,t){e.exports=window.wp.i18n},function(e,t){e.exports=window.wc.wcSettings},function(e,t){e.exports=window.wp.components},,function(e,t){e.exports=window.wp.blockEditor},,function(e,t){e.exports=window.wp.data},function(e,t){e.exports=window.lodash},function(e,t){e.exports=window.wp.blocks},function(e,t){e.exports=window.wc.wcBlocksData},function(e,t){e.exports=window.wp.compose},function(e,t){e.exports=window.wp.primitives},function(e,t){e.exports=window.React},function(e,t){e.exports=window.wp.apiFetch},function(e,t){e.exports=window.wp.htmlEntities},function(e,t){e.exports=window.wc.blocksCheckout},function(e,t){e.exports=window.wp.url},,function(e,t,c){"use strict";c.d(t,"a",(function(){return a})),c.d(t,"c",(function(){return l})),c.d(t,"d",(function(){return i})),c.d(t,"b",(function(){return u}));var r=c(0),o=c(8),n=c(1);const a={clear:Object(n.__)("Clear all selected items","woo-gutenberg-products-block"),noItems:Object(n.__)("No items found.","woo-gutenberg-products-block"),
|
2 |
/* Translators: %s search term */
|
3 |
noResults:Object(n.__)("No results for %s","woo-gutenberg-products-block"),search:Object(n.__)("Search for items","woo-gutenberg-products-block"),selected:e=>Object(n.sprintf)(
|
4 |
/* translators: Number of items selected from list. */
|
5 |
+
Object(n._n)("%d item selected","%d items selected",e,"woo-gutenberg-products-block"),e),updated:Object(n.__)("Search results updated.","woo-gutenberg-products-block")},s=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;const c=Object(o.groupBy)(e,"parent"),r=Object(o.keyBy)(t,"id"),n=["0"],a=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e.parent)return e.name?[e.name]:[];const t=a(r[e.parent]);return[...t,e.name]},s=e=>e.map(e=>{const t=c[e.id];return n.push(""+e.id),{...e,breadcrumbs:a(r[e.parent]),children:t&&t.length?s(t):[]}}),l=s(c[0]||[]);return Object.entries(c).forEach(e=>{let[t,c]=e;n.includes(t)||l.push(...s(c||[]))}),l},l=(e,t,c)=>{if(!t)return c?s(e):e;const r=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),o=e.map(e=>!!r.test(e.name)&&e).filter(Boolean);return c?s(o,e):o},i=(e,t)=>{if(!t)return e;const c=new RegExp(`(${t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")})`,"ig");return e.split(c).map((e,t)=>c.test(e)?Object(r.createElement)("strong",{key:t},e):Object(r.createElement)(r.Fragment,{key:t},e))},u=e=>1===e.length?e.slice(0,1).toString():2===e.length?e.slice(0,1).toString()+" › "+e.slice(-1).toString():e.slice(0,1).toString()+" … "+e.slice(-1).toString()},,function(e,t,c){"use strict";c.d(t,"o",(function(){return n})),c.d(t,"m",(function(){return a})),c.d(t,"l",(function(){return s})),c.d(t,"n",(function(){return l})),c.d(t,"j",(function(){return i})),c.d(t,"e",(function(){return u})),c.d(t,"f",(function(){return d})),c.d(t,"g",(function(){return b})),c.d(t,"k",(function(){return p})),c.d(t,"c",(function(){return m})),c.d(t,"d",(function(){return g})),c.d(t,"h",(function(){return O})),c.d(t,"a",(function(){return j})),c.d(t,"i",(function(){return h})),c.d(t,"b",(function(){return _}));var r,o=c(2);const n=Object(o.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),a=n.pluginUrl+"images/",s=n.pluginUrl+"build/",l=n.buildPhase,i=null===(r=o.STORE_PAGES.shop)||void 0===r?void 0:r.permalink,u=o.STORE_PAGES.checkout.id,d=o.STORE_PAGES.checkout.permalink,b=o.STORE_PAGES.privacy.permalink,p=(o.STORE_PAGES.privacy.title,o.STORE_PAGES.terms.permalink),m=(o.STORE_PAGES.terms.title,o.STORE_PAGES.cart.id),g=o.STORE_PAGES.cart.permalink,O=(o.STORE_PAGES.myaccount.permalink?o.STORE_PAGES.myaccount.permalink:Object(o.getSetting)("wpLoginUrl","/wp-login.php"),Object(o.getSetting)("shippingCountries",{})),j=Object(o.getSetting)("allowedCountries",{}),h=Object(o.getSetting)("shippingStates",{}),_=Object(o.getSetting)("allowedStates",{})},,function(e,t){e.exports=window.wc.wcBlocksSharedContext},,function(e,t){e.exports=window.wp.isShallowEqual},function(e,t){e.exports=window.wc.priceFormat},function(e,t,c){"use strict";c.d(t,"h",(function(){return i})),c.d(t,"e",(function(){return u})),c.d(t,"b",(function(){return d})),c.d(t,"i",(function(){return b})),c.d(t,"f",(function(){return p})),c.d(t,"c",(function(){return m})),c.d(t,"d",(function(){return g})),c.d(t,"g",(function(){return O})),c.d(t,"a",(function(){return j}));var r=c(17),o=c(14),n=c.n(o),a=c(8),s=c(2),l=c(21);const i=e=>{let{selected:t=[],search:c="",queryArgs:o={}}=e;const s=(e=>{let{selected:t=[],search:c="",queryArgs:o={}}=e;const n=l.o.productCount>100,a={per_page:n?100:0,catalog_visibility:"any",search:c,orderby:"title",order:"asc"},s=[Object(r.addQueryArgs)("/wc/store/v1/products",{...a,...o})];return n&&t.length&&s.push(Object(r.addQueryArgs)("/wc/store/v1/products",{catalog_visibility:"any",include:t,per_page:0})),s})({selected:t,search:c,queryArgs:o});return Promise.all(s.map(e=>n()({path:e}))).then(e=>Object(a.uniqBy)(Object(a.flatten)(e),"id").map(e=>({...e,parent:0}))).catch(e=>{throw e})},u=e=>n()({path:"/wc/store/v1/products/"+e}),d=()=>n()({path:"wc/store/v1/products/attributes"}),b=e=>n()({path:`wc/store/v1/products/attributes/${e}/terms`}),p=e=>{let{selected:t=[],search:c}=e;const o=(e=>{let{selected:t=[],search:c}=e;const o=Object(s.getSetting)("limitTags",!1),n=[Object(r.addQueryArgs)("wc/store/v1/products/tags",{per_page:o?100:0,orderby:o?"count":"name",order:o?"desc":"asc",search:c})];return o&&t.length&&n.push(Object(r.addQueryArgs)("wc/store/v1/products/tags",{include:t})),n})({selected:t,search:c});return Promise.all(o.map(e=>n()({path:e}))).then(e=>Object(a.uniqBy)(Object(a.flatten)(e),"id"))},m=e=>n()({path:Object(r.addQueryArgs)("wc/store/v1/products/categories",{per_page:0,...e})}),g=e=>n()({path:"wc/store/v1/products/categories/"+e}),O=e=>n()({path:Object(r.addQueryArgs)("wc/store/v1/products",{per_page:0,type:"variation",parent:e})}),j=(e,t)=>{if(!e.title.raw)return e.slug;const c=1===t.filter(t=>t.title.raw===e.title.raw).length;return e.title.raw+(c?"":" - "+e.slug)}},function(e,t,c){"use strict";var r=c(0),o=c(4),n=c.n(o);t.a=e=>{let t,{label:c,screenReaderLabel:o,wrapperElement:a,wrapperProps:s={}}=e;const l=null!=c,i=null!=o;return!l&&i?(t=a||"span",s={...s,className:n()(s.className,"screen-reader-text")},Object(r.createElement)(t,s,o)):(t=a||r.Fragment,l&&i&&c!==o?Object(r.createElement)(t,s,Object(r.createElement)("span",{"aria-hidden":"true"},c),Object(r.createElement)("span",{className:"screen-reader-text"},o)):Object(r.createElement)(t,s,c))}},function(e,t,c){"use strict";c.d(t,"a",(function(){return n})),c.d(t,"b",(function(){return a}));var r=c(1),o=c(15);const n=async e=>{if("function"==typeof e.json)try{const t=await e.json();return{message:t.message,type:t.type||"api"}}catch(e){return{message:e.message,type:"general"}}return{message:e.message,type:e.type||"general"}},a=e=>{if(e.data&&"rest_invalid_param"===e.code){const t=Object.values(e.data.params);if(t[0])return t[0]}return null!=e&&e.message?Object(o.decodeEntities)(e.message):Object(r.__)("Something went wrong. Please contact us to get assistance.","woo-gutenberg-products-block")}},,,,function(e,t,c){"use strict";var r=c(0),o=c(1),n=c(34);t.a=e=>{let{error:t}=e;return Object(r.createElement)("div",{className:"wc-block-error-message"},(e=>{let{message:t,type:c}=e;return t?"general"===c?Object(r.createElement)("span",null,Object(o.__)("The following error was returned","woo-gutenberg-products-block"),Object(r.createElement)("br",null),Object(r.createElement)("code",null,Object(n.escapeHTML)(t))):"api"===c?Object(r.createElement)("span",null,Object(o.__)("The following error was returned from the API","woo-gutenberg-products-block"),Object(r.createElement)("br",null),Object(r.createElement)("code",null,Object(n.escapeHTML)(t))):t:Object(o.__)("An error has prevented the block from being updated.","woo-gutenberg-products-block")})(t))}},function(e,t){e.exports=window.wp.escapeHtml},function(e,t,c){"use strict";c.d(t,"a",(function(){return r})),c.d(t,"b",(function(){return o}));const r=e=>!(e=>null===e)(e)&&e instanceof Object&&e.constructor===Object;function o(e,t){return r(e)&&t in e}},function(e,t){e.exports=window.wc.wcBlocksRegistry},function(e,t,c){"use strict";c.d(t,"a",(function(){return s}));var r=c(6),o=c.n(r),n=c(0),a=c(19);const s=e=>{let{countLabel:t,className:c,depth:r=0,controlId:s="",item:l,isSelected:i,isSingle:u,onSelect:d,search:b="",...p}=e;const m=null!=t&&void 0!==l.count&&null!==l.count,g=[c,"woocommerce-search-list__item"];g.push("depth-"+r),u&&g.push("is-radio-button"),m&&g.push("has-count");const O=l.breadcrumbs&&l.breadcrumbs.length,j=p.name||"search-list-item-"+s,h=`${j}-${l.id}`;return Object(n.createElement)("label",{htmlFor:h,className:g.join(" ")},u?Object(n.createElement)("input",o()({type:"radio",id:h,name:j,value:l.value,onChange:d(l),checked:i,className:"woocommerce-search-list__item-input"},p)):Object(n.createElement)("input",o()({type:"checkbox",id:h,name:j,value:l.value,onChange:d(l),checked:i,className:"woocommerce-search-list__item-input"},p)),Object(n.createElement)("span",{className:"woocommerce-search-list__item-label"},O?Object(n.createElement)("span",{className:"woocommerce-search-list__item-prefix"},Object(a.b)(l.breadcrumbs)):null,Object(n.createElement)("span",{className:"woocommerce-search-list__item-name"},Object(a.d)(l.name,b))),!!m&&Object(n.createElement)("span",{className:"woocommerce-search-list__item-count"},t||l.count))};t.b=s},function(e,t,c){"use strict";var r=c(6),o=c.n(r),n=c(0),a=c(132),s=c(4),l=c.n(s);c(138);const i=e=>({thousandSeparator:e.thousandSeparator,decimalSeparator:e.decimalSeparator,decimalScale:e.minorUnit,fixedDecimalScale:!0,prefix:e.prefix,suffix:e.suffix,isNumericString:!0});t.a=e=>{let{className:t,value:c,currency:r,onValueChange:s,displayType:u="text",...d}=e;const b="string"==typeof c?parseInt(c,10):c;if(!Number.isFinite(b))return null;const p=b/10**r.minorUnit;if(!Number.isFinite(p))return null;const m=l()("wc-block-formatted-money-amount","wc-block-components-formatted-money-amount",t),g={...d,...i(r),value:void 0,currency:void 0,onValueChange:void 0},O=s?e=>{const t=+e.value*10**r.minorUnit;s(t)}:()=>{};return Object(n.createElement)(a.a,o()({className:m,displayType:u},g,{value:p,onValueChange:O}))}},,function(e,t,c){"use strict";c.d(t,"a",(function(){return a}));var r=c(0),o=c(25),n=c.n(o);function a(e){const t=Object(r.useRef)(e);return n()(e,t.current)||(t.current=e),t.current}},function(e,t,c){"use strict";c.d(t,"a",(function(){return _}));var r=c(8),o=c(0),n=c(10),a=c(7),s=c(15),l=c(253),i=c(80),u=c(252);const d=e=>{const t=e.detail;t&&t.preserveCartData||Object(a.dispatch)(n.CART_STORE_KEY).invalidateResolutionForStore()},b=()=>{1===window.wcBlocksStoreCartListeners.count&&window.wcBlocksStoreCartListeners.remove(),window.wcBlocksStoreCartListeners.count--},p=()=>{Object(o.useEffect)(()=>((()=>{if(window.wcBlocksStoreCartListeners||(window.wcBlocksStoreCartListeners={count:0,remove:()=>{}}),0===window.wcBlocksStoreCartListeners.count){const e=Object(u.a)("added_to_cart","wc-blocks_added_to_cart"),t=Object(u.a)("removed_from_cart","wc-blocks_removed_from_cart");document.body.addEventListener("wc-blocks_added_to_cart",d),document.body.addEventListener("wc-blocks_removed_from_cart",d),window.wcBlocksStoreCartListeners.count=0,window.wcBlocksStoreCartListeners.remove=()=>{e(),t(),document.body.removeEventListener("wc-blocks_added_to_cart",d),document.body.removeEventListener("wc-blocks_removed_from_cart",d)}}window.wcBlocksStoreCartListeners.count++})(),b),[])},m={first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:""},g={...m,email:""},O={total_items:"",total_items_tax:"",total_fees:"",total_fees_tax:"",total_discount:"",total_discount_tax:"",total_shipping:"",total_shipping_tax:"",total_price:"",total_tax:"",tax_lines:n.EMPTY_TAX_LINES,currency_code:"",currency_symbol:"",currency_minor_unit:2,currency_decimal_separator:"",currency_thousand_separator:"",currency_prefix:"",currency_suffix:""},j=e=>Object.fromEntries(Object.entries(e).map(e=>{let[t,c]=e;return[t,Object(s.decodeEntities)(c)]})),h={cartCoupons:n.EMPTY_CART_COUPONS,cartItems:n.EMPTY_CART_ITEMS,cartFees:n.EMPTY_CART_FEES,cartItemsCount:0,cartItemsWeight:0,crossSellsProducts:n.EMPTY_CART_CROSS_SELLS,cartNeedsPayment:!0,cartNeedsShipping:!0,cartItemErrors:n.EMPTY_CART_ITEM_ERRORS,cartTotals:O,cartIsLoading:!0,cartErrors:n.EMPTY_CART_ERRORS,billingAddress:g,shippingAddress:m,shippingRates:n.EMPTY_SHIPPING_RATES,isLoadingRates:!1,cartHasCalculatedShipping:!1,paymentRequirements:n.EMPTY_PAYMENT_REQUIREMENTS,receiveCart:()=>{},extensions:n.EMPTY_EXTENSIONS},_=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{shouldSelect:!0};const{isEditor:t,previewData:c}=Object(i.b)(),s=null==c?void 0:c.previewCart,{shouldSelect:u}=e,d=Object(o.useRef)();p();const b=Object(a.useSelect)((e,c)=>{let{dispatch:r}=c;if(!u)return h;if(t)return{cartCoupons:s.coupons,cartItems:s.items,crossSellsProducts:s.cross_sells,cartFees:s.fees,cartItemsCount:s.items_count,cartItemsWeight:s.items_weight,cartNeedsPayment:s.needs_payment,cartNeedsShipping:s.needs_shipping,cartItemErrors:n.EMPTY_CART_ITEM_ERRORS,cartTotals:s.totals,cartIsLoading:!1,cartErrors:n.EMPTY_CART_ERRORS,billingData:g,billingAddress:g,shippingAddress:m,extensions:n.EMPTY_EXTENSIONS,shippingRates:s.shipping_rates,isLoadingRates:!1,cartHasCalculatedShipping:s.has_calculated_shipping,paymentRequirements:s.paymentRequirements,receiveCart:"function"==typeof(null==s?void 0:s.receiveCart)?s.receiveCart:()=>{}};const o=e(n.CART_STORE_KEY),a=o.getCartData(),i=o.getCartErrors(),d=o.getCartTotals(),b=!o.hasFinishedResolution("getCartData"),p=o.isCustomerDataUpdating(),{receiveCart:O}=r(n.CART_STORE_KEY),_=j(a.billingAddress),E=a.needsShipping?j(a.shippingAddress):_,w=a.fees.length>0?a.fees.map(e=>j(e)):n.EMPTY_CART_FEES;return{cartCoupons:a.coupons.length>0?a.coupons.map(e=>({...e,label:e.code})):n.EMPTY_CART_COUPONS,cartItems:a.items,crossSellsProducts:a.crossSells,cartFees:w,cartItemsCount:a.itemsCount,cartItemsWeight:a.itemsWeight,cartNeedsPayment:a.needsPayment,cartNeedsShipping:a.needsShipping,cartItemErrors:a.errors,cartTotals:d,cartIsLoading:b,cartErrors:i,billingData:Object(l.a)(_),billingAddress:Object(l.a)(_),shippingAddress:Object(l.a)(E),extensions:a.extensions,shippingRates:a.shippingRates,isLoadingRates:p,cartHasCalculatedShipping:a.hasCalculatedShipping,paymentRequirements:a.paymentRequirements,receiveCart:O}},[u]);return d.current&&Object(r.isEqual)(d.current,b)||(d.current=b),d.current}},function(e,t){e.exports=window.wc.wcBlocksSharedHocs},,function(e,t){e.exports=window.wp.a11y},function(e,t){e.exports=window.wp.hooks},function(e,t,c){"use strict";c.d(t,"a",(function(){return n}));var r=c(0);const o=Object(r.createContext)("page"),n=()=>Object(r.useContext)(o);o.Provider},,,,function(e,t){e.exports=window.wp.deprecated},function(e,t,c){"use strict";c.d(t,"a",(function(){return d})),c.d(t,"b",(function(){return b})),c.d(t,"c",(function(){return p}));var r=c(10),o=c(7),n=c(0),a=c(25),s=c.n(a),l=c(40),i=c(102),u=c(46);const d=e=>{const t=Object(u.a)();e=e||t;const c=Object(o.useSelect)(t=>t(r.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0),[e]),{setValueForQueryContext:a}=Object(o.useDispatch)(r.QUERY_STATE_STORE_KEY);return[c,Object(n.useCallback)(t=>{a(e,t)},[e,a])]},b=(e,t,c)=>{const a=Object(u.a)();c=c||a;const s=Object(o.useSelect)(o=>o(r.QUERY_STATE_STORE_KEY).getValueForQueryKey(c,e,t),[c,e]),{setQueryValue:l}=Object(o.useDispatch)(r.QUERY_STATE_STORE_KEY);return[s,Object(n.useCallback)(t=>{l(c,e,t)},[c,e,l])]},p=(e,t)=>{const c=Object(u.a)();t=t||c;const[r,o]=d(t),a=Object(l.a)(r),b=Object(l.a)(e),p=Object(i.a)(b),m=Object(n.useRef)(!1);return Object(n.useEffect)(()=>{s()(p,b)||(o(Object.assign({},a,b)),m.current=!0)},[a,b,p,o]),m.current?[r,o]:[e,o]}},,,,,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return o})),c.d(t,"e",(function(){return n})),c.d(t,"d",(function(){return a})),c.d(t,"b",(function(){return l})),c.d(t,"c",(function(){return i}));var r=c(35);const o=(e,t)=>e[t]?Array.from(e[t].values()).sort((e,t)=>e.priority-t.priority):[];let n,a;!function(e){e.SUCCESS="success",e.FAIL="failure",e.ERROR="error"}(n||(n={})),function(e){e.PAYMENTS="wc/payment-area",e.EXPRESS_PAYMENTS="wc/express-payment-area"}(a||(a={}));const s=(e,t)=>Object(r.a)(e)&&"type"in e&&e.type===t,l=e=>s(e,n.ERROR),i=e=>s(e,n.FAIL)},function(e,t,c){"use strict";var r=c(6),o=c.n(r),n=c(0),a=c(137),s=c(4),l=c.n(s),i=c(94);c(161),t.a=e=>{let{className:t,showSpinner:c=!1,children:r,variant:s="contained",...u}=e;const d=l()("wc-block-components-button",t,s,{"wc-block-components-button--loading":c});return Object(n.createElement)(a.a,o()({className:d},u),c&&Object(n.createElement)(i.a,null),Object(n.createElement)("span",{className:"wc-block-components-button__text"},r))}},function(e,t){e.exports=window.wp.autop},function(e,t,c){"use strict";c.d(t,"c",(function(){return n})),c.d(t,"a",(function(){return a})),c.d(t,"b",(function(){return s}));var r=c(9),o=c(21);const n=(e,t)=>{if(o.n>2)return Object(r.registerBlockType)(e,t)},a=()=>o.n>2,s=()=>o.n>1},,,function(e,t,c){"use strict";var r=c(0),o=c(1),n=c(8),a=c(3);t.a=e=>{let{columns:t,rows:c,setAttributes:s,alignButtons:l,minColumns:i=1,maxColumns:u=6,minRows:d=1,maxRows:b=6}=e;return Object(r.createElement)(r.Fragment,null,Object(r.createElement)(a.RangeControl,{label:Object(o.__)("Columns","woo-gutenberg-products-block"),value:t,onChange:e=>{const t=Object(n.clamp)(e,i,u);s({columns:Number.isNaN(t)?"":t})},min:i,max:u}),Object(r.createElement)(a.RangeControl,{label:Object(o.__)("Rows","woo-gutenberg-products-block"),value:c,onChange:e=>{const t=Object(n.clamp)(e,d,b);s({rows:Number.isNaN(t)?"":t})},min:d,max:b}),Object(r.createElement)(a.ToggleControl,{label:Object(o.__)("Align the last block to the bottom","woo-gutenberg-products-block"),help:l?Object(o.__)("Align the last block to the bottom.","woo-gutenberg-products-block"):Object(o.__)("The last inner block will follow other content.","woo-gutenberg-products-block"),checked:l,onChange:()=>s({alignButtons:!l})}))}},,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return a}));var r=c(45),o=c(0),n=c(41);const a=()=>{const e=Object(n.a)(),t=Object(o.useRef)(e);return Object(o.useEffect)(()=>{t.current=e},[e]),{dispatchStoreEvent:Object(o.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(r.doAction)("experimental__woocommerce_blocks-"+e,t)}catch(e){console.error(e)}}),[]),dispatchCheckoutEvent:Object(o.useCallback)((function(e){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(r.doAction)("experimental__woocommerce_blocks-checkout-"+e,{...c,storeCart:t.current})}catch(e){console.error(e)}}),[])}}},,,function(e,t){e.exports=window.wp.dom},,,,,,,function(e,t,c){"use strict";var r=c(0),o=c(1),n=c(38),a=c(4),s=c.n(a),l=c(26);c(160);const i=e=>{let{currency:t,maxPrice:c,minPrice:a,priceClassName:i,priceStyle:u={}}=e;return Object(r.createElement)(r.Fragment,null,Object(r.createElement)("span",{className:"screen-reader-text"},Object(o.sprintf)(
|
6 |
/* translators: %1$s min price, %2$s max price */
|
7 |
+
Object(o.__)("Price between %1$s and %2$s","woo-gutenberg-products-block"),Object(l.formatPrice)(a),Object(l.formatPrice)(c))),Object(r.createElement)("span",{"aria-hidden":!0},Object(r.createElement)(n.a,{className:s()("wc-block-components-product-price__value",i),currency:t,value:a,style:u})," — ",Object(r.createElement)(n.a,{className:s()("wc-block-components-product-price__value",i),currency:t,value:c,style:u})))},u=e=>{let{currency:t,regularPriceClassName:c,regularPriceStyle:a,regularPrice:l,priceClassName:i,priceStyle:u,price:d}=e;return Object(r.createElement)(r.Fragment,null,Object(r.createElement)("span",{className:"screen-reader-text"},Object(o.__)("Previous price:","woo-gutenberg-products-block")),Object(r.createElement)(n.a,{currency:t,renderText:e=>Object(r.createElement)("del",{className:s()("wc-block-components-product-price__regular",c),style:a},e),value:l}),Object(r.createElement)("span",{className:"screen-reader-text"},Object(o.__)("Discounted price:","woo-gutenberg-products-block")),Object(r.createElement)(n.a,{currency:t,renderText:e=>Object(r.createElement)("ins",{className:s()("wc-block-components-product-price__value","is-discounted",i),style:u},e),value:d}))};t.a=e=>{let{align:t,className:c,currency:o,format:a="<price/>",maxPrice:l,minPrice:d,price:b,priceClassName:p,priceStyle:m,regularPrice:g,regularPriceClassName:O,regularPriceStyle:j}=e;const h=s()(c,"price","wc-block-components-product-price",{["wc-block-components-product-price--align-"+t]:t});a.includes("<price/>")||(a="<price/>",console.error("Price formats need to include the `<price/>` tag."));const _=g&&b!==g;let E=Object(r.createElement)("span",{className:s()("wc-block-components-product-price__value",p)});return _?E=Object(r.createElement)(u,{currency:o,price:b,priceClassName:p,priceStyle:m,regularPrice:g,regularPriceClassName:O,regularPriceStyle:j}):void 0!==d&&void 0!==l?E=Object(r.createElement)(i,{currency:o,maxPrice:l,minPrice:d,priceClassName:p,priceStyle:m}):b&&(E=Object(r.createElement)(n.a,{className:s()("wc-block-components-product-price__value",p),currency:o,value:b,style:m})),Object(r.createElement)("span",{className:h},Object(r.createInterpolateElement)(a,{price:E}))}},,function(e,t,c){"use strict";c.d(t,"b",(function(){return a})),c.d(t,"a",(function(){return s}));var r=c(0),o=c(7);const n=Object(r.createContext)({isEditor:!1,currentPostId:0,currentView:"",previewData:{},getPreviewData:()=>{}}),a=()=>Object(r.useContext)(n),s=e=>{let{children:t,currentPostId:c=0,currentView:a="",previewData:s={}}=e;const l=Object(o.useSelect)(e=>c||e("core/editor").getCurrentPostId(),[c]),i=Object(r.useCallback)(e=>e in s?s[e]:{},[s]),u={isEditor:!0,currentPostId:l,currentView:a,previewData:s,getPreviewData:i};return Object(r.createElement)(n.Provider,{value:u},t)}},,function(e,t,c){"use strict";var r=c(6),o=c.n(r),n=c(0),a=c(37),s=c(3),l=c(4),i=c.n(l);t.a=e=>{let{className:t,item:c,isSelected:r,isLoading:l,onSelect:u,disabled:d,...b}=e;return Object(n.createElement)(n.Fragment,null,Object(n.createElement)(a.a,o()({},b,{key:c.id,className:t,isSelected:r,item:c,onSelect:u,isSingle:!0,disabled:d})),r&&l&&Object(n.createElement)("div",{key:"loading",className:i()("woocommerce-search-list__item","woocommerce-product-attributes__item","depth-1","is-loading","is-not-active")},Object(n.createElement)(s.Spinner,null)))}},,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return n}));var r=c(35),o=c(130);const n=e=>{const t=Object(r.a)(e)?e:{},c=Object(o.a)(t.style),n=Object(r.a)(c.typography)?c.typography:{};return{style:{fontSize:t.fontSize?`var(--wp--preset--font-size--${t.fontSize})`:n.fontSize,lineHeight:n.lineHeight,fontWeight:n.fontWeight,textTransform:n.textTransform,fontFamily:t.fontFamily}}}},,,function(e,t){e.exports=window.wp.wordcount},,,function(e,t,c){"use strict";var r=c(2),o=c(1),n=c(146),a=c(95);const s=Object(r.getSetting)("countryLocale",{}),l=e=>{const t={};return void 0!==e.label&&(t.label=e.label),void 0!==e.required&&(t.required=e.required),void 0!==e.hidden&&(t.hidden=e.hidden),void 0===e.label||e.optionalLabel||(t.optionalLabel=Object(o.sprintf)(
|
8 |
/* translators: %s Field label. */
|
9 |
+
Object(o.__)("%s (optional)","woo-gutenberg-products-block"),e.label)),e.priority&&(Object(n.a)(e.priority)&&(t.index=e.priority),Object(a.a)(e.priority)&&(t.index=parseInt(e.priority,10))),e.hidden&&(t.required=!1),t},i=Object.entries(s).map(e=>{let[t,c]=e;return[t,Object.entries(c).map(e=>{let[t,c]=e;return[t,l(c)]}).reduce((e,t)=>{let[c,r]=t;return e[c]=r,e},{})]}).reduce((e,t)=>{let[c,r]=t;return e[c]=r,e},{});t.a=function(e,t){let c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";const o=c&&void 0!==i[c]?i[c]:{};return e.map(e=>({key:e,...r.defaultAddressFields[e]||{},...o[e]||{},...t[e]||{}})).sort((e,t)=>e.index-t.index)}},,function(e,t,c){"use strict";var r=c(0);c(162),t.a=()=>Object(r.createElement)("span",{className:"wc-block-components-spinner","aria-hidden":"true"})},function(e,t,c){"use strict";c.d(t,"a",(function(){return r}));const r=e=>"string"==typeof e},function(e,t,c){"use strict";var r=c(6),o=c.n(r),n=c(0),a=c(1),s=c(8),l=c(37),i=c(99),u=c(11),d=Object(u.createHigherOrderComponent)(e=>{class t extends n.Component{render(){const{selected:t}=this.props,c=null==t;return Array.isArray(t)?Object(n.createElement)(e,this.props):Object(n.createElement)(e,o()({},this.props,{selected:c?[]:[t]}))}}return t.defaultProps={selected:null},t},"withTransformSingleSelectToMultipleSelect"),b=c(186),p=c(24),m=c.n(p),g=c(25),O=c.n(g),j=c(27),h=c(29),_=Object(u.createHigherOrderComponent)(e=>{class t extends n.Component{constructor(){super(...arguments),m()(this,"state",{error:null,loading:!1,variations:{}}),m()(this,"loadVariations",()=>{const{products:e}=this.props,{loading:t,variations:c}=this.state;if(t)return;const r=this.getExpandedProduct();if(!r||c[r])return;const o=e.find(e=>e.id===r);o.variations&&0!==o.variations.length?(this.setState({loading:!0}),Object(j.g)(r).then(e=>{const t=e.map(e=>({...e,parent:r}));this.setState({variations:{...this.state.variations,[r]:t},loading:!1,error:null})}).catch(async e=>{const t=await Object(h.a)(e);this.setState({variations:{...this.state.variations,[r]:null},loading:!1,error:t})})):this.setState({variations:{...this.state.variations,[r]:null},loading:!1,error:null})})}componentDidMount(){const{selected:e,showVariations:t}=this.props;e&&t&&this.loadVariations()}componentDidUpdate(e){const{isLoading:t,selected:c,showVariations:r}=this.props;r&&(!O()(e.selected,c)||e.isLoading&&!t)&&this.loadVariations()}isProductId(e){const{products:t}=this.props;return t.some(t=>t.id===e)}findParentProduct(e){var t;const{products:c}=this.props;return null===(t=c.filter(t=>t.variations&&t.variations.find(t=>{let{id:c}=t;return c===e}))[0])||void 0===t?void 0:t.id}getExpandedProduct(){const{isLoading:e,selected:t,showVariations:c}=this.props;if(!c)return null;let r=t&&t.length?t[0]:null;return r?this.prevSelectedItem=r:this.prevSelectedItem&&(e||this.isProductId(this.prevSelectedItem)||(r=this.prevSelectedItem)),!e&&r?this.isProductId(r)?r:this.findParentProduct(r):null}render(){const{error:t,isLoading:c}=this.props,{error:r,loading:a,variations:s}=this.state;return Object(n.createElement)(e,o()({},this.props,{error:r||t,expandedProduct:this.getExpandedProduct(),isLoading:c,variations:s,variationsLoading:a}))}}return m()(t,"defaultProps",{selected:[],showVariations:!1}),t},"withProductVariations"),E=c(33),w=c(4),f=c.n(w),k=c(82);c(139);const y={list:Object(a.__)("Products","woo-gutenberg-products-block"),noItems:Object(a.__)("Your store doesn't have any products.","woo-gutenberg-products-block"),search:Object(a.__)("Search for a product to display","woo-gutenberg-products-block"),updated:Object(a.__)("Product search results updated.","woo-gutenberg-products-block")},v=e=>{let{expandedProduct:t,error:c,instanceId:r,isCompact:u,isLoading:d,onChange:b,onSearch:p,products:m,renderItem:g,selected:O,showVariations:j,variations:h,variationsLoading:_}=e;if(c)return Object(n.createElement)(E.a,{error:c});const w=[...m,...h&&h[t]?h[t]:[]];return Object(n.createElement)(i.a,{className:"woocommerce-products",list:w,isCompact:u,isLoading:d,isSingle:!0,selected:w.filter(e=>{let{id:t}=e;return O.includes(t)}),onChange:b,renderItem:g||(j?e=>{const{item:t,search:c,depth:i=0,isSelected:u,onSelect:b}=e,p=t.variations&&Array.isArray(t.variations)?t.variations.length:0,m=f()("woocommerce-search-product__item","woocommerce-search-list__item","depth-"+i,"has-count",{"is-searching":c.length>0,"is-skip-level":0===i&&0!==t.parent,"is-variable":p>0});if(!t.breadcrumbs.length)return Object(n.createElement)(k.a,o()({},e,{className:f()(m,{"is-selected":u}),isSelected:u,item:t,onSelect:()=>()=>{b(t)()},isLoading:d||_,countLabel:t.variations.length>0?Object(a.sprintf)(
|
10 |
/* translators: %1$d is the number of variations of a product product. */
|
11 |
Object(a.__)("%1$d variations","woo-gutenberg-products-block"),t.variations.length):null,name:"products-"+r,"aria-label":Object(a.sprintf)(
|
12 |
/* translators: %1$s is the product name, %2$d is the number of variations of that product. */
|
13 |
+
Object(a._n)("%1$s, has %2$d variation","%1$s, has %2$d variations",t.variations.length,"woo-gutenberg-products-block"),t.name,t.variations.length)}));const g=Object(s.isEmpty)(t.variation)?e:{...e,item:{...e.item,name:t.variation},"aria-label":`${t.breadcrumbs[0]}: ${t.variation}`};return Object(n.createElement)(l.a,o()({},g,{className:m,name:"variations-"+r}))}:null),onSearch:p,messages:y,isHierarchical:!0})};v.defaultProps={isCompact:!1,expandedProduct:null,selected:[],showVariations:!1},t.a=d(Object(b.a)(_(Object(u.withInstanceId)(v))))},function(e,t,c){"use strict";c.d(t,"a",(function(){return n})),c.d(t,"b",(function(){return s}));var r=c(8);let o;!function(e){e.ADD_EVENT_CALLBACK="add_event_callback",e.REMOVE_EVENT_CALLBACK="remove_event_callback"}(o||(o={}));const n={addEventCallback:function(e,t){let c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10;return{id:Object(r.uniqueId)(),type:o.ADD_EVENT_CALLBACK,eventType:e,callback:t,priority:c}},removeEventCallback:(e,t)=>({id:t,type:o.REMOVE_EVENT_CALLBACK,eventType:e})},a={},s=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:a,{type:t,eventType:c,id:r,callback:n,priority:s}=arguments.length>1?arguments[1]:void 0;const l=e.hasOwnProperty(c)?new Map(e[c]):new Map;switch(t){case o.ADD_EVENT_CALLBACK:return l.set(r,{priority:s,callback:n}),{...e,[c]:l};case o.REMOVE_EVENT_CALLBACK:return l.delete(r),{...e,[c]:l}}}},function(e,t,c){"use strict";c.d(t,"a",(function(){return s}));var r=c(5),o=c(61),n=c(35),a=c(130);const s=e=>{if(!Object(o.b)())return{className:"",style:{}};const t=Object(n.a)(e)?e:{},c=Object(a.a)(t.style);return Object(r.__experimentalUseColorProps)({...t,style:c})}},function(e,t,c){"use strict";c.d(t,"a",(function(){return k}));var r=c(6),o=c.n(r),n=c(0),a=c(1),s=c(3),l=c(116),i=c(515),u=c(4),d=c.n(u),b=c(11),p=c(19),m=c(37),g=c(514),O=c(15);const j=e=>{let{id:t,label:c,popoverContents:r,remove:o,screenReaderLabel:i,className:u=""}=e;const[p,m]=Object(n.useState)(!1),h=Object(b.useInstanceId)(j);if(i=i||c,!c)return null;c=Object(O.decodeEntities)(c);const _=d()("woocommerce-tag",u,{"has-remove":!!o}),E="woocommerce-tag__label-"+h,w=Object(n.createElement)(n.Fragment,null,Object(n.createElement)("span",{className:"screen-reader-text"},i),Object(n.createElement)("span",{"aria-hidden":"true"},c));return Object(n.createElement)("span",{className:_},r?Object(n.createElement)(s.Button,{className:"woocommerce-tag__text",id:E,onClick:()=>m(!0)},w):Object(n.createElement)("span",{className:"woocommerce-tag__text",id:E},w),r&&p&&Object(n.createElement)(s.Popover,{onClose:()=>m(!1)},r),o&&Object(n.createElement)(s.Button,{className:"woocommerce-tag__remove",onClick:o(t),label:Object(a.sprintf)(// Translators: %s label.
|
14 |
+
Object(a.__)("Remove %s","woo-gutenberg-products-block"),c),"aria-describedby":E},Object(n.createElement)(l.a,{icon:g.a,size:20,className:"clear-icon"})))};var h=j;const _=e=>Object(n.createElement)(m.b,e),E=e=>{const{list:t,selected:c,renderItem:r,depth:a=0,onSelect:s,instanceId:l,isSingle:i,search:u}=e;return t?Object(n.createElement)(n.Fragment,null,t.map(t=>{const d=-1!==c.findIndex(e=>{let{id:c}=e;return c===t.id});return Object(n.createElement)(n.Fragment,{key:t.id},Object(n.createElement)("li",null,r({item:t,isSelected:d,onSelect:s,isSingle:i,search:u,depth:a,controlId:l})),Object(n.createElement)(E,o()({},e,{list:t.children,depth:a+1})))})):null},w=e=>{let{isLoading:t,isSingle:c,selected:r,messages:o,onChange:l,onRemove:i}=e;if(t||c||!r)return null;const u=r.length;return Object(n.createElement)("div",{className:"woocommerce-search-list__selected"},Object(n.createElement)("div",{className:"woocommerce-search-list__selected-header"},Object(n.createElement)("strong",null,o.selected(u)),u>0?Object(n.createElement)(s.Button,{isLink:!0,isDestructive:!0,onClick:()=>l([]),"aria-label":o.clear},Object(a.__)("Clear all","woo-gutenberg-products-block")):null),u>0?Object(n.createElement)("ul",null,r.map((e,t)=>Object(n.createElement)("li",{key:t},Object(n.createElement)(h,{label:e.name,id:e.id,remove:i})))):null)},f=e=>{let{filteredList:t,search:c,onSelect:r,instanceId:o,...s}=e;const{messages:u,renderItem:d,selected:b,isSingle:p}=s,m=d||_;return 0===t.length?Object(n.createElement)("div",{className:"woocommerce-search-list__list is-not-found"},Object(n.createElement)("span",{className:"woocommerce-search-list__not-found-icon"},Object(n.createElement)(l.a,{icon:i.a})),Object(n.createElement)("span",{className:"woocommerce-search-list__not-found-text"},c?Object(a.sprintf)(u.noResults,c):u.noItems)):Object(n.createElement)("ul",{className:"woocommerce-search-list__list"},Object(n.createElement)(E,{list:t,selected:b,renderItem:m,onSelect:r,instanceId:o,isSingle:p,search:c}))},k=e=>{const{className:t="",isCompact:c,isHierarchical:r,isLoading:a,isSingle:l,list:i,messages:u=p.a,onChange:m,onSearch:g,selected:O,debouncedSpeak:j}=e,[h,_]=Object(n.useState)(""),E=Object(b.useInstanceId)(k),y=Object(n.useMemo)(()=>({...p.a,...u}),[u]),v=Object(n.useMemo)(()=>Object(p.c)(i,h,r),[i,h,r]);Object(n.useEffect)(()=>{j&&j(y.updated)},[j,y]),Object(n.useEffect)(()=>{"function"==typeof g&&g(h)},[h,g]);const S=Object(n.useCallback)(e=>()=>{l&&m([]);const t=O.findIndex(t=>{let{id:c}=t;return c===e});m([...O.slice(0,t),...O.slice(t+1)])},[l,O,m]),C=Object(n.useCallback)(e=>()=>{-1===O.findIndex(t=>{let{id:c}=t;return c===e.id})?m(l?[e]:[...O,e]):S(e.id)()},[l,S,m,O]);return Object(n.createElement)("div",{className:d()("woocommerce-search-list",t,{"is-compact":c})},Object(n.createElement)(w,o()({},e,{onRemove:S,messages:y})),Object(n.createElement)("div",{className:"woocommerce-search-list__search"},Object(n.createElement)(s.TextControl,{label:y.search,type:"search",value:h,onChange:e=>_(e)})),a?Object(n.createElement)("div",{className:"woocommerce-search-list__list is-loading"},Object(n.createElement)(s.Spinner,null)):Object(n.createElement)(f,o()({},e,{search:h,filteredList:v,messages:y,onSelect:C,instanceId:E})))};Object(s.withSpokenMessages)(k)},,,function(e,t,c){"use strict";c.d(t,"a",(function(){return o}));var r=c(13);function o(e,t){const c=Object(r.useRef)();return Object(r.useEffect)(()=>{c.current===e||t&&!t(e,c.current)||(c.current=e)},[e,t]),c.current}},,function(e,t,c){"use strict";var r=c(6),o=c.n(r),n=c(0),a=c(15),s=c(4),l=c.n(s);c(159),t.a=e=>{let{className:t="",disabled:c=!1,name:r,permalink:s="",target:i,rel:u,style:d,onClick:b,...p}=e;const m=l()("wc-block-components-product-name",t);if(c){const e=p;return Object(n.createElement)("span",o()({className:m},e,{dangerouslySetInnerHTML:{__html:Object(a.decodeEntities)(r)}}))}return Object(n.createElement)("a",o()({className:m,href:s,target:i},p,{dangerouslySetInnerHTML:{__html:Object(a.decodeEntities)(r)},style:d}))}},function(e,t){e.exports=window.wp.warning},function(e,t,c){"use strict";c.d(t,"a",(function(){return l}));var r=c(10),o=c(7),n=c(0),a=c(40),s=c(141);const l=e=>{const{namespace:t,resourceName:c,resourceValues:l=[],query:i={},shouldSelect:u=!0}=e;if(!t||!c)throw new Error("The options object must have valid values for the namespace and the resource properties.");const d=Object(n.useRef)({results:[],isLoading:!0}),b=Object(a.a)(i),p=Object(a.a)(l),m=Object(s.a)(),g=Object(o.useSelect)(e=>{if(!u)return null;const o=e(r.COLLECTIONS_STORE_KEY),n=[t,c,b,p],a=o.getCollectionError(...n);if(a){if(!(a instanceof Error))throw new Error("TypeError: `error` object is not an instance of Error constructor");m(a)}return{results:o.getCollection(...n),isLoading:!o.hasFinishedResolution("getCollection",n)}},[t,c,p,b,u]);return null!==g&&(d.current=g),d.current}},function(e,t,c){"use strict";var r=c(0),o=c(1),n=c(116),a=c(250),s=c(2),l=c(5),i=c(23);t.a=e=>{const t=(Object(i.useProductDataContext)().product||{}).id||e.productId||0;return t?Object(r.createElement)(l.InspectorControls,null,Object(r.createElement)("div",{className:"wc-block-single-product__edit-card"},Object(r.createElement)("div",{className:"wc-block-single-product__edit-card-title"},Object(r.createElement)("a",{href:`${s.ADMIN_URL}post.php?post=${t}&action=edit`,target:"_blank",rel:"noopener noreferrer"},Object(o.__)("Edit this product's details","woo-gutenberg-products-block"),Object(r.createElement)(n.a,{icon:a.a,size:16}))),Object(r.createElement)("div",{className:"wc-block-single-product__edit-card-description"},Object(o.__)("Edit details such as title, price, description and more.","woo-gutenberg-products-block")))):null}},,,,,,,,,,,function(e,t,c){"use strict";var r=c(0),o=c(89),n=c(60);const a=e=>{const t=e.indexOf("</p>");return-1===t?e:e.substr(0,t+4)},s=e=>e.replace(/<\/?[a-z][^>]*?>/gi,""),l=(e,t)=>e.replace(/[\s|\.\,]+$/i,"")+t,i=function(e,t){let c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"…";const r=s(e),o=r.split(" ").splice(0,t).join(" ");return Object(n.autop)(l(o,c))},u=function(e,t){let c=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"…";const o=s(e),a=o.slice(0,t);if(c)return Object(n.autop)(l(a,r));const i=a.match(/([\s]+)/g),u=i?i.length:0,d=o.slice(0,t+u);return Object(n.autop)(l(d,r))};t.a=e=>{let{source:t,maxLength:c=15,countType:s="words",className:l="",style:d={}}=e;const b=Object(r.useMemo)(()=>function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:15,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"words";const r=Object(n.autop)(e),s=Object(o.count)(r,c);if(s<=t)return r;const l=a(r),d=Object(o.count)(l,c);return d<=t?l:"words"===c?i(l,t):u(l,t,"characters_including_spaces"===c)}(t,c,s),[t,c,s]);return Object(r.createElement)(r.RawHTML,{style:d,className:l},b)}},,function(e,t,c){"use strict";var r=c(0),o=c(4),n=c.n(o),a=c(28),s=c(11);c(164),t.a=Object(s.withInstanceId)(e=>{let{className:t,instanceId:c,label:o="",onChange:s,options:l,screenReaderLabel:i,value:u=""}=e;const d="wc-block-components-sort-select__select-"+c;return Object(r.createElement)("div",{className:n()("wc-block-sort-select","wc-block-components-sort-select",t)},Object(r.createElement)(a.a,{label:o,screenReaderLabel:i,wrapperElement:"label",wrapperProps:{className:"wc-block-sort-select__label wc-block-components-sort-select__label",htmlFor:d}}),Object(r.createElement)("select",{id:d,className:"wc-block-sort-select__select wc-block-components-sort-select__select",onChange:s,value:u},l&&l.map(e=>Object(r.createElement)("option",{key:e.key,value:e.key},e.label))))})},,,,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return r}));const r=e=>"boolean"==typeof e},function(e,t,c){"use strict";c.d(t,"a",(function(){return o}));var r=c(5);const o=()=>"function"==typeof r.__experimentalGetSpacingClassesAndStyles},,,function(e,t,c){"use strict";c.d(t,"a",(function(){return n}));var r=c(95),o=c(35);const n=e=>Object(r.a)(e)?JSON.parse(e)||{}:Object(o.a)(e)?e:{}},function(e,t,c){"use strict";c.d(t,"a",(function(){return l}));var r=c(5),o=c(61),n=c(35),a=c(127),s=c(130);const l=e=>{if(!Object(o.b)()||!Object(a.a)())return{style:{}};const t=Object(n.a)(e)?e:{},c=Object(s.a)(t.style);return Object(r.__experimentalGetSpacingClassesAndStyles)({...t,style:c})}},,,,,,,function(e,t){},function(e,t){},function(e,t,c){"use strict";c.r(t),c.d(t,"Block",(function(){return m}));var r=c(0),o=c(1),n=c(4),a=c.n(n),s=c(28),l=c(23),i=c(154),u=c(98),d=c(86),b=c(131),p=c(42);c(254);const m=e=>{const{className:t,align:c}=e,{parentClassName:n}=Object(l.useInnerBlockLayoutContext)(),{product:p}=Object(l.useProductDataContext)(),m=Object(i.a)(e),g=Object(u.a)(e),O=Object(d.a)(e),j=Object(b.a)(e);if(!p.id||!p.on_sale)return null;const h="string"==typeof c?"wc-block-components-product-sale-badge--align-"+c:"";return Object(r.createElement)("div",{className:a()("wc-block-components-product-sale-badge",t,h,{[n+"__product-onsale"]:n},g.className,m.className),style:{...g.style,...m.style,...O.style,...j.style}},Object(r.createElement)(s.a,{label:Object(o.__)("Sale","woo-gutenberg-products-block"),screenReaderLabel:Object(o.__)("Product on sale","woo-gutenberg-products-block")}))};t.default=Object(p.withProductDataContext)(m)},function(e,t,c){"use strict";c.d(t,"a",(function(){return o}));var r=c(0);const o=()=>{const[,e]=Object(r.useState)();return Object(r.useCallback)(t=>{e(()=>{throw t})},[])}},,,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return r}));const r=e=>"number"==typeof e},,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return o}));var r=c(0);const o=Object(r.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 230 250",style:{width:"100%"}},Object(r.createElement)("title",null,"Grid Block Preview"),Object(r.createElement)("rect",{width:"65.374",height:"65.374",x:".162",y:".779",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(r.createElement)("rect",{width:"62.8",height:"15",x:"1.565",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(r.createElement)("rect",{width:"65.374",height:"65.374",x:".162",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(r.createElement)("rect",{width:"62.8",height:"15",x:"1.565",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(r.createElement)("rect",{width:"65.374",height:"65.374",x:"82.478",y:".779",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(r.createElement)("rect",{width:"62.8",height:"15",x:"83.882",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(r.createElement)("rect",{width:"65.374",height:"65.374",x:"82.478",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(r.createElement)("rect",{width:"62.8",height:"15",x:"83.882",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(r.createElement)("rect",{width:"65.374",height:"65.374",x:"164.788",y:".779",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(r.createElement)("rect",{width:"62.8",height:"15",x:"166.192",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(r.createElement)("rect",{width:"65.374",height:"65.374",x:"164.788",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(r.createElement)("rect",{width:"62.8",height:"15",x:"166.192",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(r.createElement)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"221.798",fill:"#E1E3E6",rx:"3"}))},function(e,t,c){"use strict";var r=c(6),o=c.n(r),n=c(0),a=c(3),s=c(4),l=c.n(s);c(187),t.a=function(e){let{className:t="",...c}=e;const r=l()("wc-block-text-toolbar-button",t);return Object(n.createElement)(a.Button,o()({className:r},c))}},,,function(e,t,c){"use strict";c.d(t,"a",(function(){return s}));var r=c(5),o=c(61),n=c(35),a=c(130);const s=e=>{if(!Object(o.b)())return{className:"",style:{}};const t=Object(n.a)(e)?e:{},c=Object(a.a)(t.style);return Object(r.__experimentalUseBorderProps)({...t,style:c})}},,,,,function(e,t){},function(e,t){},function(e,t){},function(e,t){},,function(e,t){},function(e,t,c){"use strict";c.d(t,"a",(function(){return i}));var r=c(0),o=c(7),n=c(10),a=c(15),s=c(41);const l=(e,t)=>{const c=e.find(e=>{let{id:c}=e;return c===t});return c?c.quantity:0},i=e=>{const{addItemToCart:t}=Object(o.useDispatch)(n.CART_STORE_KEY),{cartItems:c,cartIsLoading:i}=Object(s.a)(),{createErrorNotice:u,removeNotice:d}=Object(o.useDispatch)("core/notices"),[b,p]=Object(r.useState)(!1),m=Object(r.useRef)(l(c,e));return Object(r.useEffect)(()=>{const t=l(c,e);t!==m.current&&(m.current=t)},[c,e]),{cartQuantity:Number.isFinite(m.current)?m.current:0,addingToCart:b,cartIsLoading:i,addToCart:function(){let c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return p(!0),t(e,c).then(()=>{d("add-to-cart")}).catch(e=>{u(Object(a.decodeEntities)(e.message),{id:"add-to-cart",context:"wc/all-products",isDismissible:!0})}).finally(()=>{p(!1)})}}}},,,,,,,,,,,,,,,,,,,,,function(e,t,c){"use strict";var r=c(6),o=c.n(r),n=c(0),a=c(21),s=c(27),l=c(115),i=c(29);t.a=e=>t=>{let{selected:c,...r}=t;const[u,d]=Object(n.useState)(!0),[b,p]=Object(n.useState)(null),[m,g]=Object(n.useState)([]),O=a.o.productCount>100,j=async e=>{const t=await Object(i.a)(e);p(t),d(!1)},h=Object(n.useRef)(c);Object(n.useEffect)(()=>{Object(s.h)({selected:h.current}).then(e=>{g(e),d(!1)}).catch(j)},[h]);const _=Object(l.a)(e=>{Object(s.h)({selected:c,search:e}).then(e=>{g(e),d(!1)}).catch(j)},400),E=Object(n.useCallback)(e=>{d(!0),_(e)},[d,_]);return Object(n.createElement)(e,o()({},r,{selected:c,error:b,products:m,isLoading:u,onSearch:O?E:null}))}},function(e,t){},,,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return g}));var r=c(0),o=c(4),n=c.n(o),a=c(23),s=c(61),l=c(42),i=c(104),u=c(68),d=c(98),b=c(131),p=c(86);c(255);const m=e=>{let{children:t,headingLevel:c,elementType:o="h"+c,...n}=e;return Object(r.createElement)(o,n,t)},g=e=>{const{className:t,headingLevel:c=2,showProductLink:o=!0,linkTarget:l,align:g}=e,{parentClassName:O}=Object(a.useInnerBlockLayoutContext)(),{product:j}=Object(a.useProductDataContext)(),{dispatchStoreEvent:h}=Object(u.a)(),_=Object(d.a)(e),E=Object(b.a)(e),w=Object(p.a)(e);return j.id?Object(r.createElement)(m,{headingLevel:c,className:n()(t,_.className,"wc-block-components-product-title",{[O+"__product-title"]:O,["wc-block-components-product-title--align-"+g]:g&&Object(s.b)()}),style:Object(s.b)()?{...E.style,...w.style,..._.style}:{}},Object(r.createElement)(i.a,{disabled:!o,name:j.name,permalink:j.permalink,target:l,onClick:()=>{h("product-view-link",{product:j})}})):Object(r.createElement)(m,{headingLevel:c,className:n()(t,_.className,"wc-block-components-product-title",{[O+"__product-title"]:O,["wc-block-components-product-title--align-"+g]:g&&Object(s.b)()}),style:Object(s.b)()?{...E.style,...w.style,..._.style}:{}})};t.b=Object(l.withProductDataContext)(g)},function(e,t,c){"use strict";c.d(t,"a",(function(){return _}));var r=c(6),o=c.n(r),n=c(0),a=c(1),s=c(4),l=c.n(s),i=c(2),u=c(23),d=c(86),b=c(154),p=c(131),m=c(42),g=c(68),O=c(140);c(256);const j=()=>Object(n.createElement)("img",{src:i.PLACEHOLDER_IMG_SRC,alt:"",width:void 0,height:void 0}),h=e=>{let{image:t,loaded:c,showFullSize:r,fallbackAlt:a}=e;const{thumbnail:s,src:l,srcset:i,sizes:u,alt:d}=t||{},b={alt:d||a,hidden:!c,src:s,...r&&{src:l,srcSet:i,sizes:u}};return Object(n.createElement)(n.Fragment,null,b.src&&Object(n.createElement)("img",o()({"data-testid":"product-image"},b)),!t&&Object(n.createElement)(j,null))},_=e=>{const{className:t,imageSizing:c="full-size",showProductLink:r=!0,showSaleBadge:o,saleBadgeAlign:s="right"}=e,{parentClassName:i}=Object(u.useInnerBlockLayoutContext)(),{product:m,isLoading:_}=Object(u.useProductDataContext)(),{dispatchStoreEvent:E}=Object(g.a)(),w=Object(d.a)(e),f=Object(b.a)(e),k=Object(p.a)(e);if(!m.id)return Object(n.createElement)("div",{className:l()(t,"wc-block-components-product-image",{[i+"__product-image"]:i},f.className),style:{...w.style,...f.style,...k.style}},Object(n.createElement)(j,null));const y=!!m.images.length,v=y?m.images[0]:null,S=r?"a":n.Fragment,C=Object(a.sprintf)(
|
15 |
/* translators: %s is referring to the product name */
|
16 |
+
Object(a.__)("Link to %s","woo-gutenberg-products-block"),m.name),x={href:m.permalink,...!y&&{"aria-label":C},onClick:()=>{E("product-view-link",{product:m})}};return Object(n.createElement)("div",{className:l()(t,"wc-block-components-product-image",{[i+"__product-image"]:i},f.className),style:{...w.style,...f.style,...k.style}},Object(n.createElement)(S,r&&x,!!o&&Object(n.createElement)(O.default,{align:s,product:m}),Object(n.createElement)(h,{fallbackAlt:m.name,image:v,loaded:!_,showFullSize:"cropped"!==c})))};t.b=Object(m.withProductDataContext)(_)},,,,,,,,,,function(e,t,c){"use strict";var r=c(0),o=c(4),n=c.n(o),a=c(1),s=c(40),l=c(349),i=c(7),u=c(10);const d={PRISTINE:"pristine",IDLE:"idle",DISABLED:"disabled",PROCESSING:"processing",BEFORE_PROCESSING:"before_processing",AFTER_PROCESSING:"after_processing"},b={status:d.PRISTINE,hasError:!1,quantity:0,processingResponse:null,requestParams:{}},p={SET_PRISTINE:"set_pristine",SET_IDLE:"set_idle",SET_DISABLED:"set_disabled",SET_PROCESSING:"set_processing",SET_BEFORE_PROCESSING:"set_before_processing",SET_AFTER_PROCESSING:"set_after_processing",SET_PROCESSING_RESPONSE:"set_processing_response",SET_HAS_ERROR:"set_has_error",SET_NO_ERROR:"set_no_error",SET_QUANTITY:"set_quantity",SET_REQUEST_PARAMS:"set_request_params"},{SET_PRISTINE:m,SET_IDLE:g,SET_DISABLED:O,SET_PROCESSING:j,SET_BEFORE_PROCESSING:h,SET_AFTER_PROCESSING:_,SET_PROCESSING_RESPONSE:E,SET_HAS_ERROR:w,SET_NO_ERROR:f,SET_QUANTITY:k,SET_REQUEST_PARAMS:y}=p,v=()=>({type:g}),S=function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const t=e?w:f;return{type:t}},{SET_PRISTINE:C,SET_IDLE:x,SET_DISABLED:N,SET_PROCESSING:P,SET_BEFORE_PROCESSING:T,SET_AFTER_PROCESSING:I,SET_PROCESSING_RESPONSE:R,SET_HAS_ERROR:A,SET_NO_ERROR:B,SET_QUANTITY:L,SET_REQUEST_PARAMS:D}=p,{PRISTINE:F,IDLE:V,DISABLED:z,PROCESSING:M,BEFORE_PROCESSING:q,AFTER_PROCESSING:H}=d,Q=function(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:b,{quantity:c,type:r,data:o}=arguments.length>1?arguments[1]:void 0;switch(r){case C:e=b;break;case x:e=t.status!==V?{...t,status:V}:t;break;case N:e=t.status!==z?{...t,status:z}:t;break;case L:e=c!==t.quantity?{...t,quantity:c}:t;break;case D:e={...t,requestParams:{...t.requestParams,...o}};break;case R:e={...t,processingResponse:o};break;case P:e=t.status!==M?{...t,status:M,hasError:!1}:t,e=!1===e.hasError?e:{...e,hasError:!1};break;case T:e=t.status!==q?{...t,status:q,hasError:!1}:t;break;case I:e=t.status!==H?{...t,status:H}:t;break;case A:e=t.hasError?t:{...t,hasError:!0},e=t.status===M||t.status===q?{...e,status:V}:e;break;case B:e=t.hasError?{...t,hasError:!1}:t}return e!==t&&r!==C&&e.status===F&&(e.status=V),e};var G=c(97),Y=c(260);const U=e=>({onAddToCartAfterProcessingWithSuccess:Object(Y.a)("add_to_cart_after_processing_with_success",e),onAddToCartProcessingWithError:Object(Y.a)("add_to_cart_after_processing_with_error",e),onAddToCartBeforeProcessing:Object(Y.a)("add_to_cart_before_processing",e)});var W=c(307),$=c(58);const K=Object(r.createContext)({product:{},productType:"simple",productIsPurchasable:!0,productHasOptions:!1,supportsFormElements:!0,showFormElements:!1,quantity:0,minQuantity:1,maxQuantity:99,requestParams:{},isIdle:!1,isDisabled:!1,isProcessing:!1,isBeforeProcessing:!1,isAfterProcessing:!1,hasError:!1,eventRegistration:{onAddToCartAfterProcessingWithSuccess:e=>{},onAddToCartAfterProcessingWithError:e=>{},onAddToCartBeforeProcessing:e=>{}},dispatchActions:{resetForm:()=>{},submitForm:()=>{},setQuantity:e=>{},setHasError:e=>{},setAfterProcessing:e=>{},setRequestParams:e=>{}}}),J=()=>Object(r.useContext)(K),X=e=>{var t,c,o,n;let{children:p,product:g,showFormElements:w}=e;const[f,C]=Object(r.useReducer)(Q,b),[x,N]=Object(r.useReducer)(G.b,{}),P=Object(s.a)(x),{createErrorNotice:T}=Object(i.useDispatch)("core/notices"),{setValidationErrors:I}=Object(i.useDispatch)(u.VALIDATION_STORE_KEY),R=Object(r.useMemo)(()=>({onAddToCartAfterProcessingWithSuccess:U(N).onAddToCartAfterProcessingWithSuccess,onAddToCartAfterProcessingWithError:U(N).onAddToCartAfterProcessingWithError,onAddToCartBeforeProcessing:U(N).onAddToCartBeforeProcessing}),[N]),A=Object(r.useMemo)(()=>({resetForm:()=>{C({type:m})},submitForm:()=>{C({type:h})},setQuantity:e=>{C((e=>({type:k,quantity:e}))(e))},setHasError:e=>{C(S(e))},setRequestParams:e=>{C((e=>({type:y,data:e}))(e))},setAfterProcessing:e=>{C({type:E,data:e}),C({type:_})}}),[]);Object(r.useEffect)(()=>{const e=f.status,t=!g.id||!Object(l.a)(g);e!==d.DISABLED||t?e!==d.DISABLED&&t&&C({type:O}):C(v())},[f.status,g,C]),Object(r.useEffect)(()=>{f.status===d.BEFORE_PROCESSING&&(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const c=Object(i.select)("core/notices").getNotices(),{removeNotice:r}=Object(i.dispatch)("core/notices"),o=c.filter(t=>t.status===e);o.forEach(e=>r(e.id,t))}("error","wc/add-to-cart"),Object(W.a)(P,"add_to_cart_before_processing",{}).then(e=>{!0!==e?(Array.isArray(e)&&e.forEach(e=>{let{errorMessage:t,validationErrors:c}=e;t&&T(t,{context:"wc/add-to-cart"}),c&&I(c)}),C(v())):C({type:j})}))},[f.status,I,T,C,P,null==g?void 0:g.id]),Object(r.useEffect)(()=>{if(f.status===d.AFTER_PROCESSING){const e={processingResponse:f.processingResponse},t=e=>{let t=!1;return e.forEach(e=>{const{message:c,messageContext:r}=e;(Object($.b)(e)||Object($.c)(e))&&c&&(t=!0,T(c,r?{context:r}:void 0))}),t};if(f.hasError)return void Object(W.b)(P,"add_to_cart_after_processing_with_error",e).then(c=>{if(!t(c)){var r;const t=(null===(r=e.processingResponse)||void 0===r?void 0:r.message)||Object(a.__)("Something went wrong. Please contact us for assistance.","woo-gutenberg-products-block");T(t,{id:"add-to-cart",context:"woocommerce/single-product/"+((null==g?void 0:g.id)||0)})}C(v())});Object(W.b)(P,"add_to_cart_after_processing_with_success",e).then(e=>{t(e)?C(S(!0)):C(v())})}},[f.status,f.hasError,f.processingResponse,A,T,P,null==g?void 0:g.id]);const B=Object(l.b)(g),L={product:g,productType:g.type||"simple",productIsPurchasable:Object(l.a)(g),productHasOptions:g.has_options||!1,supportsFormElements:B,showFormElements:w&&B,quantity:f.quantity||(null==g||null===(t=g.add_to_cart)||void 0===t?void 0:t.minimum)||1,minQuantity:(null==g||null===(c=g.add_to_cart)||void 0===c?void 0:c.minimum)||1,maxQuantity:(null==g||null===(o=g.add_to_cart)||void 0===o?void 0:o.maximum)||99,multipleOf:(null==g||null===(n=g.add_to_cart)||void 0===n?void 0:n.multiple_of)||1,requestParams:f.requestParams,isIdle:f.status===d.IDLE,isDisabled:f.status===d.DISABLED,isProcessing:f.status===d.PROCESSING,isBeforeProcessing:f.status===d.BEFORE_PROCESSING,isAfterProcessing:f.status===d.AFTER_PROCESSING,hasError:f.hasError,eventRegistration:R,dispatchActions:A};return Object(r.createElement)(K.Provider,{value:L},p)};var Z=c(14),ee=c.n(Z),te=c(15),ce=c(252),re=c(41),oe=()=>{const{dispatchActions:e,product:t,quantity:c,eventRegistration:o,hasError:n,isProcessing:s,requestParams:l}=J(),{showAllValidationErrors:d}=Object(i.useDispatch)(u.VALIDATION_STORE_KEY),b=Object(i.useSelect)(e=>e(u.VALIDATION_STORE_KEY).hasValidationErrors),{createErrorNotice:p,removeNotice:m}=Object(i.useDispatch)("core/notices"),{receiveCart:g}=Object(re.a)(),[O,j]=Object(r.useState)(!1),h=!n&&s,_=Object(r.useCallback)(()=>!b()||(d(),{type:"error"}),[b,d]);Object(r.useEffect)(()=>{const e=o.onAddToCartBeforeProcessing(_,0);return()=>{e()}},[o,_]);const E=Object(r.useCallback)(()=>{j(!0),m("add-to-cart","woocommerce/single-product/"+((null==t?void 0:t.id)||0));const r={id:t.id||0,quantity:c,...l};ee()({path:"/wc/store/v1/cart/add-item",method:"POST",data:r,cache:"no-store",parse:!1}).then(c=>{ee.a.setNonce(c.headers),c.json().then((function(r){c.ok?g(r):(r.body&&r.body.message?p(Object(te.decodeEntities)(r.body.message),{id:"add-to-cart",context:"woocommerce/single-product/"+((null==t?void 0:t.id)||0)}):p(Object(a.__)("Something went wrong. Please contact us for assistance.","woo-gutenberg-products-block"),{id:"add-to-cart",context:"woocommerce/single-product/"+((null==t?void 0:t.id)||0)}),e.setHasError()),Object(ce.b)({preserveCartData:!0}),e.setAfterProcessing(r),j(!1)}))}).catch(t=>{t.json().then((function(t){var c;null!==(c=t.data)&&void 0!==c&&c.cart&&g(t.data.cart),e.setHasError(),e.setAfterProcessing(t),j(!1)}))})},[t,p,m,g,e,c,l]);return Object(r.useEffect)(()=>{h&&!O&&E()},[h,E,O]),null};const ne=e=>{let{children:t,product:c,showFormElements:o}=e;return Object(r.createElement)(X,{product:c,showFormElements:o},t,Object(r.createElement)(oe,null))};var ae=c(23),se=c(8),le=c(42),ie=(c(229),c(59)),ue=c(116),de=c(534),be=c(68),pe=c(165);const me=e=>{let{className:t,href:c,text:o,onClick:n}=e;return Object(r.createElement)(ie.a,{className:t,href:c,onClick:n,rel:"nofollow"},o)},ge=e=>{let{className:t,quantityInCart:c,isProcessing:o,isDisabled:n,isDone:s,onClick:l}=e;return Object(r.createElement)(ie.a,{className:t,disabled:n,showSpinner:o,onClick:l},s&&c>0?Object(a.sprintf)(
|
17 |
/* translators: %s number of products in cart. */
|
18 |
+
Object(a._n)("%d in cart","%d in cart",c,"woo-gutenberg-products-block"),c):Object(a.__)("Add to cart","woo-gutenberg-products-block"),!!s&&Object(r.createElement)(ue.a,{icon:de.a}))};var Oe=()=>{const{showFormElements:e,productIsPurchasable:t,productHasOptions:c,product:o,productType:n,isDisabled:s,isProcessing:l,eventRegistration:i,hasError:u,dispatchActions:d}=J(),{parentName:b}=Object(ae.useInnerBlockLayoutContext)(),{dispatchStoreEvent:p}=Object(be.a)(),{cartQuantity:m}=Object(pe.a)(o.id||0),[g,O]=Object(r.useState)(!1),j=o.add_to_cart||{url:"",text:""};return Object(r.useEffect)(()=>{const e=i.onAddToCartAfterProcessingWithSuccess(()=>(u||O(!0),!0),0);return()=>{e()}},[i,u]),(e||!c&&"simple"===n)&&t?Object(r.createElement)(ge,{className:"wc-block-components-product-add-to-cart-button",quantityInCart:m,isDisabled:s,isProcessing:l,isDone:g,onClick:()=>{d.submitForm("woocommerce/single-product/"+((null==o?void 0:o.id)||0)),p("cart-add-item",{product:o,listName:b})}}):Object(r.createElement)(me,{className:"wc-block-components-product-add-to-cart-button",href:j.url,text:j.text||Object(a.__)("View Product","woo-gutenberg-products-block"),onClick:()=>{p("product-view-link",{product:o,listName:b})}})},je=c(115),he=e=>{let{disabled:t,min:c,max:o,step:n=1,value:a,onChange:s}=e;const l=void 0!==o,i=Object(je.a)(e=>{let t=e;l&&(t=Math.min(t,Math.floor(o/n)*n)),t=Math.max(t,Math.ceil(c/n)*n),t=Math.floor(t/n)*n,t!==e&&s(t)},300);return Object(r.createElement)("input",{className:"wc-block-components-product-add-to-cart-quantity",type:"number",value:a,min:c,max:o,step:n,hidden:1===o,disabled:t,onChange:e=>{s(e.target.value),i(e.target.value)}})},_e=e=>{let{reason:t=Object(a.__)("Sorry, this product cannot be purchased.","woo-gutenberg-products-block")}=e;return Object(r.createElement)("div",{className:"wc-block-components-product-add-to-cart-unavailable"},t)},Ee=()=>{const{product:e,quantity:t,minQuantity:c,maxQuantity:o,multipleOf:n,dispatchActions:s,isDisabled:l}=J();return e.id&&!e.is_purchasable?Object(r.createElement)(_e,null):e.id&&!e.is_in_stock?Object(r.createElement)(_e,{reason:Object(a.__)("This product is currently out of stock and cannot be purchased.","woo-gutenberg-products-block")}):Object(r.createElement)(r.Fragment,null,Object(r.createElement)(he,{value:t,min:c,max:o,step:n,disabled:l,onChange:s.setQuantity}),Object(r.createElement)(Oe,null))},we=(c(259),c(552)),fe=c(13),ke=c(16);const ye={value:"",label:Object(a.__)("Select an option","woo-gutenberg-products-block")};var ve=e=>{let{attributeName:t,options:c=[],value:o="",onChange:s=(()=>{}),errorMessage:l=Object(a.__)("Please select a value.","woo-gutenberg-products-block")}=e;const d=t,{setValidationErrors:b,clearValidationError:p}=Object(i.useDispatch)(u.VALIDATION_STORE_KEY),{error:m}=Object(i.useSelect)(e=>({error:e(u.VALIDATION_STORE_KEY).getValidationError(d)||{}}));return Object(fe.useEffect)(()=>{o?p(d):b({[d]:{message:l,hidden:!0}})},[o,d,l,p,b]),Object(fe.useEffect)(()=>()=>{p(d)},[d,p]),Object(r.createElement)("div",{className:"wc-block-components-product-add-to-cart-attribute-picker__container"},Object(r.createElement)(we.a,{label:Object(te.decodeEntities)(t),value:o||"",options:[ye,...c],onChange:s,required:!0,className:n()("wc-block-components-product-add-to-cart-attribute-picker__select",{"has-error":(null==m?void 0:m.message)&&!(null!=m&&m.hidden)})}),Object(r.createElement)(ke.ValidationInputError,{propertyName:d,elementId:d}))},Se=c(35);const Ce=(e,t,c)=>{const r=Object.values(t).map(e=>{let{id:t}=e;return t});if(Object.values(c).every(e=>""===e))return r;const o=Object.keys(e);return r.filter(e=>o.every(r=>{const o=c[r]||"",n=t["id:"+e].attributes[r];return""===o||null===n||n===o}))};var xe=e=>{let{attributes:t,variationAttributes:c,setRequestParams:o}=e;const n=Object(s.a)(t),a=Object(s.a)(c),[l,i]=Object(r.useState)(0),[u,d]=Object(r.useState)({}),[b,p]=Object(r.useState)(!1),m=Object(r.useMemo)(()=>((e,t,c)=>{const r={},o=Object.keys(e),n=Object.values(c).filter(Boolean).length>0;return o.forEach(o=>{const a=e[o],s={...c,[o]:null},l=n?Ce(e,t,s):null,i=null!==l?l.map(e=>t["id:"+e].attributes[o]):null;r[o]=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return Object.values(e).map(e=>{let{name:c,slug:r}=e;return null===t||t.includes(null)||t.includes(r)?{value:r,label:Object(te.decodeEntities)(c)}:null}).filter(Boolean)}(a.terms,i)}),r})(n,a,u),[u,n,a]);return Object(r.useEffect)(()=>{if(!b){const e=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!Object(Se.a)(e))return{};const t=Object.keys(e),c={};return 0===t.length||t.forEach(t=>{const r=e[t],o=r.terms.filter(e=>e.default);var n;o.length>0&&(c[r.name]=null===(n=o[0])||void 0===n?void 0:n.slug)}),c}(t);e&&d({...e}),p(!0)}},[u,t,b]),Object(r.useEffect)(()=>{Object.values(u).filter(e=>""!==e).length===Object.keys(n).length?i(((e,t,c)=>Ce(e,t,c)[0]||0)(n,a,u)):l>0&&i(0)},[u,l,n,a]),Object(r.useEffect)(()=>{o({id:l,variation:Object.keys(u).map(e=>({attribute:e,value:u[e]}))})},[o,l,u]),Object(r.createElement)("div",{className:"wc-block-components-product-add-to-cart-attribute-picker"},Object.keys(n).map(e=>Object(r.createElement)(ve,{key:e,attributeName:e,options:m[e],value:u[e],onChange:t=>{d({...u,[e]:t})}})))},Ne=e=>{let{product:t,dispatchers:c}=e;const o=(e=>e?Object(se.keyBy)(Object.values(e).filter(e=>{let{has_variations:t}=e;return t}),"name"):{})(t.attributes),n=(e=>{if(!e)return{};const t={};return e.forEach(e=>{let{id:c,attributes:r}=e;t["id:"+c]={id:c,attributes:r.reduce((e,t)=>{let{name:c,value:r}=t;return e[c]=r,e},{})}}),t})(t.variations);return 0===Object.keys(o).length||0===n.length?null:Object(r.createElement)(xe,{attributes:o,variationAttributes:n,setRequestParams:c.setRequestParams})},Pe=()=>{const{product:e,quantity:t,minQuantity:c,maxQuantity:o,multipleOf:n,dispatchActions:s,isDisabled:l}=J();return e.id&&!e.is_purchasable?Object(r.createElement)(_e,null):e.id&&!e.is_in_stock?Object(r.createElement)(_e,{reason:Object(a.__)("This product is currently out of stock and cannot be purchased.","woo-gutenberg-products-block")}):Object(r.createElement)(r.Fragment,null,Object(r.createElement)(Ne,{product:e,dispatchers:s}),Object(r.createElement)(he,{value:t,min:c,max:o,step:n,disabled:l,onChange:s.setQuantity}),Object(r.createElement)(Oe,null))},Te=()=>Object(r.createElement)(Oe,null),Ie=c(536),Re=()=>Object(r.createElement)(Ie.a,{className:"wc-block-components-product-add-to-cart-group-list"},"This is a placeholder for the grouped products form element."),Ae=()=>Object(r.createElement)(Re,null);const Be=()=>{const{showFormElements:e,productType:t}=J();return e?"variable"===t?Object(r.createElement)(Pe,null):"grouped"===t?Object(r.createElement)(Ae,null):"external"===t?Object(r.createElement)(Te,null):"simple"===t||"variation"===t?Object(r.createElement)(Ee,null):null:Object(r.createElement)(Oe,null)};t.a=Object(le.withProductDataContext)(e=>{let{className:t,showFormElements:c}=e;const{product:o}=Object(ae.useProductDataContext)(),a=n()(t,"wc-block-components-product-add-to-cart",{"wc-block-components-product-add-to-cart--placeholder":Object(se.isEmpty)(o)});return Object(r.createElement)(ne,{product:o,showFormElements:c},Object(r.createElement)("div",{className:a},Object(r.createElement)(Be,null)))})},function(e,t,c){"use strict";c.r(t),c.d(t,"Block",(function(){return b}));var r=c(0),o=c(4),n=c.n(o),a=c(78),s=c(26),l=c(23),i=c(98),u=c(86),d=c(42);const b=e=>{var t,c;const{className:o,textAlign:d}=e,{parentClassName:b}=Object(l.useInnerBlockLayoutContext)(),{product:p}=Object(l.useProductDataContext)(),m=Object(i.a)(e),g=Object(u.a)(e),O=n()("wc-block-components-product-price",o,m.className,{[b+"__product-price"]:b}),j={...g.style,...m.style};if(!p.id)return Object(r.createElement)(a.a,{align:d,className:O});const h=p.prices,_=Object(s.getCurrencyFromPriceResponse)(h),E=h.price!==h.regular_price,w=n()({[b+"__product-price__value"]:b,[b+"__product-price__value--on-sale"]:E});return Object(r.createElement)(a.a,{align:d,className:O,priceStyle:j,regularPriceStyle:j,priceClassName:w,currency:_,price:h.price,minPrice:null==h||null===(t=h.price_range)||void 0===t?void 0:t.min_amount,maxPrice:null==h||null===(c=h.price_range)||void 0===c?void 0:c.max_amount,regularPrice:h.regular_price,regularPriceClassName:n()({[b+"__product-price__regular"]:b})})};t.default=Object(d.withProductDataContext)(b)},function(e,t,c){"use strict";c.r(t),c.d(t,"Block",(function(){return p}));var r=c(0),o=c(1),n=c(4),a=c.n(n),s=c(23),l=c(98),i=c(86),u=c(131),d=c(42),b=c(146);c(257);const p=e=>{const{parentClassName:t}=Object(s.useInnerBlockLayoutContext)(),{product:c}=Object(s.useProductDataContext)(),n=(e=>{const t=parseFloat(e.average_rating);return Number.isFinite(t)&&t>0?t:0})(c),d=Object(l.a)(e),p=Object(i.a)(e),m=Object(u.a)(e);if(!n)return null;const g={width:n/5*100+"%"},O=Object(o.sprintf)(
|
19 |
/* translators: %f is referring to the average rating value */
|
20 |
Object(o.__)("Rated %f out of 5","woo-gutenberg-products-block"),n),j=(e=>{const t=Object(b.a)(e.review_count)?e.review_count:parseInt(e.review_count,10);return Number.isFinite(t)&&t>0?t:0})(c),h={__html:Object(o.sprintf)(
|
21 |
/* translators: %1$s is referring to the average rating value, %2$s is referring to the number of ratings */
|
22 |
+
Object(o._n)("Rated %1$s out of 5 based on %2$s customer rating","Rated %1$s out of 5 based on %2$s customer ratings",j,"woo-gutenberg-products-block"),Object(o.sprintf)('<strong class="rating">%f</strong>',n),Object(o.sprintf)('<span class="rating">%d</span>',j))};return Object(r.createElement)("div",{className:a()(d.className,"wc-block-components-product-rating",{[t+"__product-rating"]:t}),style:{...d.style,...p.style,...m.style}},Object(r.createElement)("div",{className:a()("wc-block-components-product-rating__stars",t+"__product-rating__stars"),role:"img","aria-label":O},Object(r.createElement)("span",{style:g,dangerouslySetInnerHTML:h})))};t.default=Object(d.withProductDataContext)(p)},function(e,t,c){"use strict";c.r(t),c.d(t,"Block",(function(){return E}));var r=c(6),o=c.n(r),n=c(0),a=c(4),s=c.n(a),l=c(1),i=c(68),u=c(165),d=c(98),b=c(154),p=c(86),m=c(131),g=c(15),O=c(21),j=c(2),h=c(23),_=c(42);c(258);const E=e=>{const{className:t}=e,{parentClassName:c}=Object(h.useInnerBlockLayoutContext)(),{product:r}=Object(h.useProductDataContext)(),o=Object(d.a)(e),a=Object(b.a)(e),l=Object(p.a)(e),i=Object(m.a)(e);return Object(n.createElement)("div",{className:s()(t,"wp-block-button","wc-block-components-product-button",{[c+"__product-add-to-cart"]:c})},r.id?Object(n.createElement)(w,{product:r,colorStyles:o,borderStyles:a,typographyStyles:l,spacingStyles:i}):Object(n.createElement)(f,{colorStyles:o,borderStyles:a,typographyStyles:l,spacingStyles:i}))},w=e=>{let{product:t,colorStyles:c,borderStyles:r,typographyStyles:a,spacingStyles:d}=e;const{id:b,permalink:p,add_to_cart:m,has_options:h,is_purchasable:_,is_in_stock:E}=t,{dispatchStoreEvent:w}=Object(i.a)(),{cartQuantity:f,addingToCart:k,addToCart:y}=Object(u.a)(b,"woocommerce/single-product/"+(b||0)),v=Number.isFinite(f)&&f>0,S=!h&&_&&E,C=Object(g.decodeEntities)((null==m?void 0:m.description)||""),x=v?Object(l.sprintf)(
|
23 |
/* translators: %s number of products in cart. */
|
24 |
+
Object(l._n)("%d in cart","%d in cart",f,"woo-gutenberg-products-block"),f):Object(g.decodeEntities)((null==m?void 0:m.text)||Object(l.__)("Add to cart","woo-gutenberg-products-block")),N=S?"button":"a",P={};return S?P.onClick=async()=>{await y(),w("cart-add-item",{product:t});const{cartRedirectAfterAdd:e}=Object(j.getSetting)("productsSettings");e&&(window.location.href=O.d)}:(P.href=p,P.rel="nofollow",P.onClick=()=>{w("product-view-link",{product:t})}),Object(n.createElement)(N,o()({"aria-label":C,className:s()("wp-block-button__link","wp-element-button","add_to_cart_button","wc-block-components-product-button__button",c.className,r.className,{loading:k,added:v}),style:{...c.style,...r.style,...a.style,...d.style},disabled:k},P),x)},f=e=>{let{colorStyles:t,borderStyles:c,typographyStyles:r,spacingStyles:o}=e;return Object(n.createElement)("button",{className:s()("wp-block-button__link","wp-element-button","add_to_cart_button","wc-block-components-product-button__button","wc-block-components-product-button__button--placeholder",t.className,c.className),style:{...t.style,...c.style,...r.style,...o.style},disabled:!0})};t.default=Object(_.withProductDataContext)(E)},,,,,,,,,,function(e){e.exports=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":1,"textdomain":"woo-gutenberg-products-block","name":"woocommerce/all-products","title":"All Products","category":"woocommerce","keywords":["WooCommerce"],"description":"Display products from your store in a grid layout.","supports":{"align":["wide","full"],"html":false,"multiple":false},"example":{"attributes":{"isPreview":true}},"attributes":{"columns":{"type":"number"},"rows":{"type":"number"},"alignButtons":{"type":"boolean"},"contentVisibility":{"type":"object"},"orderby":{"type":"string"},"layoutConfig":{"type":"array"},"isPreview":{"type":"boolean","default":false}}}')},,,,,,,,,,,,,function(e,t){},,,,,,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return s}));var r=c(106),o=c(10),n=c(7),a=c(40);const s=e=>{const t={namespace:"/wc/store/v1",resourceName:"products"},{results:c,isLoading:s}=Object(r.a)({...t,query:e}),{value:l}=((e,t)=>{const{namespace:c,resourceName:r,resourceValues:s=[],query:l={}}=t;if(!c||!r)throw new Error("The options object must have valid values for the namespace and the resource name properties.");const i=Object(a.a)(l),u=Object(a.a)(s),{value:d,isLoading:b=!0}=Object(n.useSelect)(e=>{const t=e(o.COLLECTIONS_STORE_KEY),n=["x-wp-total",c,r,i,u];return{value:t.getCollectionHeader(...n),isLoading:t.hasFinishedResolution("getCollectionHeader",n)}},["x-wp-total",c,r,u,i]);return{value:d,isLoading:b}})(0,{...t,query:e});return{products:c,totalProducts:parseInt(l,10),productsLoading:s}}},,,,,,,,,,,,,,,function(e,t,c){"use strict";c.d(t,"b",(function(){return n})),c.d(t,"a",(function(){return a}));const r=window.CustomEvent||null,o=(e,t)=>{let{bubbles:c=!1,cancelable:o=!1,element:n,detail:a={}}=t;if(!r)return;n||(n=document.body);const s=new r(e,{bubbles:c,cancelable:o,detail:a});n.dispatchEvent(s)},n=e=>{let{preserveCartData:t=!1}=e;o("wc-blocks_added_to_cart",{bubbles:!0,cancelable:!0,detail:{preserveCartData:t}})},a=function(e,t){let c=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("function"!=typeof jQuery)return()=>{};const n=()=>{o(t,{bubbles:c,cancelable:r})};return jQuery(document).on(e,n),()=>jQuery(document).off(e,n)}},function(e,t,c){"use strict";c.d(t,"a",(function(){return n}));var r=c(92),o=(c(17),c(2));const n=e=>{const t=Object.keys(o.defaultAddressFields),c=Object(r.a)(t,{},e.country),n=Object.assign({},e);return c.forEach(t=>{let{key:c="",hidden:r=!1}=t;r&&((e,t)=>e in t)(c,e)&&(n[c]="")}),n}},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,c){"use strict";c.d(t,"a",(function(){return o}));var r=c(97);const o=(e,t)=>function(c){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;const n=r.a.addEventCallback(e,c,o);return t(n),()=>{t(r.a.removeEventCallback(e,n.id))}}},,,,,,,,,,function(e,t,c){"use strict";var r=c(0),o=c(12);const n=Object(r.createElement)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(r.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(r.createElement)("path",{d:"M15.55 13c.75 0 1.41-.41 1.75-1.03l3.58-6.49c.37-.66-.11-1.48-.87-1.48H5.21l-.94-2H1v2h2l3.6 7.59-1.35 2.44C4.52 15.37 5.48 17 7 17h12v-2H7l1.1-2h7.45zM6.16 6h12.15l-2.76 5H8.53L6.16 6zM7 18c-1.1 0-1.99.9-1.99 2S5.9 22 7 22s2-.9 2-2-.9-2-2-2zm10 0c-1.1 0-1.99.9-1.99 2s.89 2 1.99 2 2-.9 2-2-.9-2-2-2z"}));t.a=n},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t,c){"use strict";var r=c(61);let o={headingLevel:{type:"number",default:2},showProductLink:{type:"boolean",default:!0},linkTarget:{type:"string"},productId:{type:"number",default:0}};Object(r.b)()&&(o={...o,align:{type:"string"}}),t.a=o},function(e,t,c){"use strict";t.a={showProductLink:{type:"boolean",default:!0},showSaleBadge:{type:"boolean",default:!0},saleBadgeAlign:{type:"string",default:"right"},imageSizing:{type:"string",default:"full-size"},productId:{type:"number",default:0},isDescendentOfQueryLoop:{type:"boolean",default:!1}}},function(e,t,c){"use strict";c.d(t,"a",(function(){return o})),c.d(t,"b",(function(){return n}));var r=c(58);const o=async(e,t,c)=>{const o=Object(r.a)(e,t),n=[];for(const e of o)try{const t=await Promise.resolve(e.callback(c));"object"==typeof t&&n.push(t)}catch(e){console.error(e)}return!n.length||n},n=async(e,t,c)=>{const o=[],n=Object(r.a)(e,t);for(const e of n)try{const t=await Promise.resolve(e.callback(c));if("object"!=typeof t||null===t)continue;if(!t.hasOwnProperty("type"))throw new Error("Returned objects from event emitter observers must return an object with a type property");if(Object(r.b)(t)||Object(r.c)(t))return o.push(t),o;o.push(t)}catch(e){return console.error(e),o.push({type:"error"}),o}return o}},function(e,t,c){"use strict";t.a={showFormElements:{type:"boolean",default:!1},productId:{type:"number",default:0}}},,,,,,,,,function(e,t,c){"use strict";c.r(t);var r=c(0),o=c(4),n=c.n(o),a=c(118),s=c(21),l=c(23),i=c(98),u=c(86),d=c(42);c(344),t.default=Object(d.withProductDataContext)(e=>{const{className:t}=e,{parentClassName:c}=Object(l.useInnerBlockLayoutContext)(),{product:o}=Object(l.useProductDataContext)(),d=Object(i.a)(e),b=Object(u.a)(e);if(!o)return Object(r.createElement)("div",{className:n()(t,"wc-block-components-product-summary",{[c+"__product-summary"]:c})});const p=o.short_description?o.short_description:o.description;return p?Object(r.createElement)(a.a,{className:n()(t,d.className,"wc-block-components-product-summary",{[c+"__product-summary"]:c}),source:p,maxLength:150,countType:s.o.wordCountType||"words",style:{...d.style,...b.style}}):null})},function(e,t,c){"use strict";c.r(t);var r=c(0),o=c(1),n=c(4),a=c.n(n),s=c(23),l=c(42);c(345),t.default=Object(l.withProductDataContext)(e=>{const{className:t}=e,{parentClassName:c}=Object(s.useInnerBlockLayoutContext)(),{product:n}=Object(s.useProductDataContext)(),l=n.sku;return l?Object(r.createElement)("div",{className:a()(t,"wc-block-components-product-sku",{[c+"__product-sku"]:c})},Object(o.__)("SKU:","woo-gutenberg-products-block")," ",Object(r.createElement)("strong",null,l)):null})},function(e,t,c){"use strict";c.r(t);var r=c(0),o=c(1),n=c(4),a=c.n(n),s=c(23),l=c(98),i=c(86),u=c(8),d=c(42);c(346),t.default=Object(d.withProductDataContext)(e=>{const{className:t}=e,{parentClassName:c}=Object(s.useInnerBlockLayoutContext)(),{product:n}=Object(s.useProductDataContext)(),d=Object(l.a)(e),b=Object(i.a)(e);return Object(u.isEmpty)(n.categories)?null:Object(r.createElement)("div",{className:a()(t,"wc-block-components-product-category-list",d.className,{[c+"__product-category-list"]:c}),style:{...d.style,...b.style}},Object(o.__)("Categories:","woo-gutenberg-products-block")," ",Object(r.createElement)("ul",null,Object.values(n.categories).map(e=>{let{name:t,link:c,slug:o}=e;return Object(r.createElement)("li",{key:"category-list-item-"+o},Object(r.createElement)("a",{href:c},t))})))})},function(e,t,c){"use strict";c.r(t);var r=c(0),o=c(1),n=c(4),a=c.n(n),s=c(23),l=c(98),i=c(86),u=c(8),d=c(42);c(347),t.default=Object(d.withProductDataContext)(e=>{const{className:t}=e,{parentClassName:c}=Object(s.useInnerBlockLayoutContext)(),{product:n}=Object(s.useProductDataContext)(),d=Object(l.a)(e),b=Object(i.a)(e);return Object(u.isEmpty)(n.tags)?null:Object(r.createElement)("div",{className:a()(t,d.className,"wc-block-components-product-tag-list",{[c+"__product-tag-list"]:c}),style:{...d.style,...b.style}},Object(o.__)("Tags:","woo-gutenberg-products-block")," ",Object(r.createElement)("ul",null,Object.values(n.tags).map(e=>{let{name:t,link:c,slug:o}=e;return Object(r.createElement)("li",{key:"tag-list-item-"+o},Object(r.createElement)("a",{href:c},t))})))})},function(e,t,c){"use strict";c.r(t),c.d(t,"Block",(function(){return d}));var r=c(0),o=c(1),n=c(4),a=c.n(n),s=c(23),l=c(98),i=c(86),u=c(42);c(348);const d=e=>{const{className:t}=e,{parentClassName:c}=Object(s.useInnerBlockLayoutContext)(),{product:n}=Object(s.useProductDataContext)(),u=Object(l.a)(e),d=Object(i.a)(e);if(!n.id||!n.is_purchasable)return null;const b=!!n.is_in_stock,p=n.low_stock_remaining,m=n.is_on_backorder;return Object(r.createElement)("div",{className:a()(t,u.className,"wc-block-components-product-stock-indicator",{[c+"__stock-indicator"]:c,"wc-block-components-product-stock-indicator--in-stock":b,"wc-block-components-product-stock-indicator--out-of-stock":!b,"wc-block-components-product-stock-indicator--low-stock":!!p,"wc-block-components-product-stock-indicator--available-on-backorder":!!m}),style:{...u.style,...d.style}},p?(e=>Object(o.sprintf)(
|
25 |
/* translators: %d stock amount (number of items in stock for product) */
|
26 |
+
Object(o.__)("%d left in stock","woo-gutenberg-products-block"),e))(p):((e,t)=>t?Object(o.__)("Available on backorder","woo-gutenberg-products-block"):e?Object(o.__)("In Stock","woo-gutenberg-products-block"):Object(o.__)("Out of Stock","woo-gutenberg-products-block"))(b,m))};t.default=Object(u.withProductDataContext)(d)},,,,,,,,,,,,,,,,,,,,,,,function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,c){"use strict";c.d(t,"a",(function(){return r})),c.d(t,"b",(function(){return o}));const r=e=>e.is_purchasable||!1,o=e=>["simple","variable"].includes(e.type||"simple")},,,,,,,,,,,,,,,,,,,,,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return n}));var r=c(1),o=c(21);const n=[{id:1,name:"WordPress Pennant",variation:"",permalink:"https://example.org",sku:"wp-pennant",short_description:Object(r.__)("Fly your WordPress banner with this beauty! Deck out your office space or add it to your kids walls. This banner will spruce up any space it’s hung!","woo-gutenberg-products-block"),description:"Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",price:"7.99",price_html:'<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">$</span>7.99</span>',images:[{id:1,src:o.m+"previews/pennant.jpg",thumbnail:o.m+"previews/pennant.jpg",name:"pennant-1.jpg",alt:"WordPress Pennant",srcset:"",sizes:""}],average_rating:5,categories:[{id:1,name:"Decor",slug:"decor",link:"https://example.org"}],review_count:1,prices:{currency_code:"GBP",decimal_separator:".",thousand_separator:",",decimals:2,price_prefix:"£",price_suffix:"",price:"7.99",regular_price:"9.99",sale_price:"7.99",price_range:null},add_to_cart:{text:Object(r.__)("Add to cart","woo-gutenberg-products-block"),description:Object(r.__)("Add to cart","woo-gutenberg-products-block")},has_options:!1,is_purchasable:!0,is_in_stock:!0,on_sale:!0}]},,,,,,,,,,function(e,t,c){e.exports=c(469)},function(e,t){},function(e,t){},function(e,t){},,,function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t,c){"use strict";c.r(t),c.d(t,"metadata",(function(){return bt})),c.d(t,"name",(function(){return ec}));var r=c(0),o=c(9),n=c(116),a=c(526),s=c(61),l=c(1),i=c(4),u=c.n(i),d={category:"woocommerce-product-elements",keywords:[Object(l.__)("WooCommerce","woo-gutenberg-products-block")],icon:{src:Object(r.createElement)(n.a,{icon:a.a,className:"wc-block-editor-components-block-icon"})},supports:{html:!1},ancestor:["@woocommerce/all-products","@woocommerce/single-product"],save:e=>{let{attributes:t}=e;return t.isDescendentOfQueryLoop?null:Object(r.createElement)("div",{className:u()("is-loading",t.className)})},deprecated:[{attributes:{},save:()=>null}]},b=c(305),p=c(3),m=c(11),g=c(5),O=c(8),j=c(12);function h(e){let{level:t}=e;const c={1:"M9 5h2v10H9v-4H5v4H3V5h2v4h4V5zm6.6 0c-.6.9-1.5 1.7-2.6 2v1h2v7h2V5h-1.4z",2:"M7 5h2v10H7v-4H3v4H1V5h2v4h4V5zm8 8c.5-.4.6-.6 1.1-1.1.4-.4.8-.8 1.2-1.3.3-.4.6-.8.9-1.3.2-.4.3-.8.3-1.3 0-.4-.1-.9-.3-1.3-.2-.4-.4-.7-.8-1-.3-.3-.7-.5-1.2-.6-.5-.2-1-.2-1.5-.2-.4 0-.7 0-1.1.1-.3.1-.7.2-1 .3-.3.1-.6.3-.9.5-.3.2-.6.4-.8.7l1.2 1.2c.3-.3.6-.5 1-.7.4-.2.7-.3 1.2-.3s.9.1 1.3.4c.3.3.5.7.5 1.1 0 .4-.1.8-.4 1.1-.3.5-.6.9-1 1.2-.4.4-1 .9-1.6 1.4-.6.5-1.4 1.1-2.2 1.6V15h8v-2H15z",3:"M12.1 12.2c.4.3.8.5 1.2.7.4.2.9.3 1.4.3.5 0 1-.1 1.4-.3.3-.1.5-.5.5-.8 0-.2 0-.4-.1-.6-.1-.2-.3-.3-.5-.4-.3-.1-.7-.2-1-.3-.5-.1-1-.1-1.5-.1V9.1c.7.1 1.5-.1 2.2-.4.4-.2.6-.5.6-.9 0-.3-.1-.6-.4-.8-.3-.2-.7-.3-1.1-.3-.4 0-.8.1-1.1.3-.4.2-.7.4-1.1.6l-1.2-1.4c.5-.4 1.1-.7 1.6-.9.5-.2 1.2-.3 1.8-.3.5 0 1 .1 1.6.2.4.1.8.3 1.2.5.3.2.6.5.8.8.2.3.3.7.3 1.1 0 .5-.2.9-.5 1.3-.4.4-.9.7-1.5.9v.1c.6.1 1.2.4 1.6.8.4.4.7.9.7 1.5 0 .4-.1.8-.3 1.2-.2.4-.5.7-.9.9-.4.3-.9.4-1.3.5-.5.1-1 .2-1.6.2-.8 0-1.6-.1-2.3-.4-.6-.2-1.1-.6-1.6-1l1.1-1.4zM7 9H3V5H1v10h2v-4h4v4h2V5H7v4z",4:"M9 15H7v-4H3v4H1V5h2v4h4V5h2v10zm10-2h-1v2h-2v-2h-5v-2l4-6h3v6h1v2zm-3-2V7l-2.8 4H16z",5:"M12.1 12.2c.4.3.7.5 1.1.7.4.2.9.3 1.3.3.5 0 1-.1 1.4-.4.4-.3.6-.7.6-1.1 0-.4-.2-.9-.6-1.1-.4-.3-.9-.4-1.4-.4H14c-.1 0-.3 0-.4.1l-.4.1-.5.2-1-.6.3-5h6.4v1.9h-4.3L14 8.8c.2-.1.5-.1.7-.2.2 0 .5-.1.7-.1.5 0 .9.1 1.4.2.4.1.8.3 1.1.6.3.2.6.6.8.9.2.4.3.9.3 1.4 0 .5-.1 1-.3 1.4-.2.4-.5.8-.9 1.1-.4.3-.8.5-1.3.7-.5.2-1 .3-1.5.3-.8 0-1.6-.1-2.3-.4-.6-.2-1.1-.6-1.6-1-.1-.1 1-1.5 1-1.5zM9 15H7v-4H3v4H1V5h2v4h4V5h2v10z",6:"M9 15H7v-4H3v4H1V5h2v4h4V5h2v10zm8.6-7.5c-.2-.2-.5-.4-.8-.5-.6-.2-1.3-.2-1.9 0-.3.1-.6.3-.8.5l-.6.9c-.2.5-.2.9-.2 1.4.4-.3.8-.6 1.2-.8.4-.2.8-.3 1.3-.3.4 0 .8 0 1.2.2.4.1.7.3 1 .6.3.3.5.6.7.9.2.4.3.8.3 1.3s-.1.9-.3 1.4c-.2.4-.5.7-.8 1-.4.3-.8.5-1.2.6-1 .3-2 .3-3 0-.5-.2-1-.5-1.4-.9-.4-.4-.8-.9-1-1.5-.2-.6-.3-1.3-.3-2.1s.1-1.6.4-2.3c.2-.6.6-1.2 1-1.6.4-.4.9-.7 1.4-.9.6-.3 1.1-.4 1.7-.4.7 0 1.4.1 2 .3.5.2 1 .5 1.4.8 0 .1-1.3 1.4-1.3 1.4zm-2.4 5.8c.2 0 .4 0 .6-.1.2 0 .4-.1.5-.2.1-.1.3-.3.4-.5.1-.2.1-.5.1-.7 0-.4-.1-.8-.4-1.1-.3-.2-.7-.3-1.1-.3-.3 0-.7.1-1 .2-.4.2-.7.4-1 .7 0 .3.1.7.3 1 .1.2.3.4.4.6.2.1.3.3.5.3.2.1.5.2.7.1z"};return c.hasOwnProperty(t)?Object(r.createElement)(j.SVG,{width:"20",height:"20",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg"},Object(r.createElement)(j.Path,{d:c[t]})):null}class _ extends r.Component{createLevelControl(e,t,c){const o=e===t;return{icon:Object(r.createElement)(h,{level:e}),title:Object(l.sprintf)(
|
27 |
/* translators: %s: heading level e.g: "2", "3", "4" */
|
28 |
+
Object(l.__)("Heading %d","woo-gutenberg-products-block"),e),isActive:o,onClick:()=>c(e)}}render(){const{isCollapsed:e=!0,minLevel:t,maxLevel:c,selectedLevel:o,onChange:n}=this.props;return Object(r.createElement)(p.ToolbarGroup,{isCollapsed:e,icon:Object(r.createElement)(h,{level:o}),controls:Object(O.range)(t,c).map(e=>this.createLevelControl(e,o,n))})}}var E=_,w=c(192),f=c(96),k=c(151),y=c(23);c(383);var v=e=>t=>c=>{var o;const n=Object(y.useProductDataContext)(),{attributes:a,setAttributes:s}=c,{productId:i}=a,[u,d]=Object(r.useState)(!i);return n.hasContext||Number.isFinite(null===(o=c.context)||void 0===o?void 0:o.queryId)?Object(r.createElement)(t,c):Object(r.createElement)(r.Fragment,null,u?Object(r.createElement)(p.Placeholder,{icon:e.icon||"",label:e.label||"",className:"wc-atomic-blocks-product"},!!e.description&&Object(r.createElement)("div",null,e.description),Object(r.createElement)("div",{className:"wc-atomic-blocks-product__selection"},Object(r.createElement)(f.a,{selected:i||0,showVariations:!0,onChange:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];s({productId:e[0]?e[0].id:0})}}),Object(r.createElement)(p.Button,{isSecondary:!0,disabled:!i,onClick:()=>{d(!1)}},Object(l.__)("Done","woo-gutenberg-products-block")))):Object(r.createElement)(r.Fragment,null,Object(r.createElement)(g.BlockControls,null,Object(r.createElement)(p.ToolbarGroup,null,Object(r.createElement)(k.a,{onClick:()=>d(!0)},Object(l.__)("Switch product…","woo-gutenberg-products-block")))),Object(r.createElement)(t,c)))},S=c(527);const C=Object(l.__)("Product Title","woo-gutenberg-products-block"),x=Object(r.createElement)(n.a,{icon:S.a,className:"wc-block-editor-components-block-icon"}),N=Object(l.__)("Display the title of a product.","woo-gutenberg-products-block");c(384);const P=e=>{let{attributes:t,setAttributes:c}=e;const o=Object(g.useBlockProps)(),{headingLevel:n,showProductLink:a,align:i,linkTarget:u}=t;return Object(r.createElement)("div",o,Object(r.createElement)(g.BlockControls,null,Object(r.createElement)(E,{isCollapsed:!0,minLevel:1,maxLevel:7,selectedLevel:n,onChange:e=>c({headingLevel:e})}),Object(s.b)()&&Object(r.createElement)(g.AlignmentToolbar,{value:i,onChange:e=>{c({align:e})}})),Object(r.createElement)(g.InspectorControls,null,Object(r.createElement)(p.PanelBody,{title:Object(l.__)("Link settings","woo-gutenberg-products-block")},Object(r.createElement)(p.ToggleControl,{label:Object(l.__)("Make title a link","woo-gutenberg-products-block"),checked:a,onChange:()=>c({showProductLink:!a})}),a&&Object(r.createElement)(r.Fragment,null,Object(r.createElement)(p.ToggleControl,{label:Object(l.__)("Open in new tab","woo-gutenberg-products-block"),onChange:e=>c({linkTarget:e?"_blank":"_self"}),checked:"_blank"===u})))),Object(r.createElement)(p.Disabled,null,Object(r.createElement)(w.b,t)))};var T=Object(s.b)()?Object(m.compose)([v({icon:x,label:C,description:Object(l.__)("Choose a product to display its title.","woo-gutenberg-products-block")})])(P):P,I=c(127);const R={...d,apiVersion:2,title:C,description:N,icon:{src:x},attributes:b.a,edit:T,save:e=>{let{attributes:t}=e;return Object(r.createElement)("div",g.useBlockProps.save({className:u()("is-loading",t.className)}))},supports:{...d.supports,...Object(s.b)()&&{typography:{fontSize:!0,lineHeight:!0,__experimentalFontWeight:!0,__experimentalTextTransform:!0,__experimentalFontFamily:!0},color:{text:!0,background:!0,link:!1,gradients:!0,__experimentalSkipSerialization:!0},...Object(I.a)()&&{spacing:{margin:!0,__experimentalSkipSerialization:!0}},__experimentalSelector:".wc-block-components-product-title"}}};Object(o.registerBlockType)("woocommerce/product-title",R);var A=c(13),B=c(204),L=c(528);const D=Object(l.__)("Product Price","woo-gutenberg-products-block"),F=Object(r.createElement)(n.a,{icon:L.a,className:"wc-block-editor-components-block-icon"}),V=Object(l.__)("Display the price of a product.","woo-gutenberg-products-block");var z=v({icon:F,label:D,description:Object(l.__)("Choose a product to display its price.","woo-gutenberg-products-block")})(e=>{let{attributes:t,setAttributes:c,context:o}=e;const n=Object(g.useBlockProps)(),a={...t,...o},l=Number.isFinite(o.queryId);return Object(A.useEffect)(()=>c({isDescendentOfQueryLoop:l}),[c,l]),Object(r.createElement)(r.Fragment,null,Object(r.createElement)(g.BlockControls,null,Object(s.b)()&&Object(r.createElement)(g.AlignmentToolbar,{value:t.textAlign,onChange:e=>{c({textAlign:e})}})),Object(r.createElement)("div",n,Object(r.createElement)(B.default,a)))});let M={productId:{type:"number",default:0},isDescendentOfQueryLoop:{type:"boolean",default:!1}};Object(s.b)()&&(M={...M,textAlign:{type:"string"}});var q=M;const H={...d,apiVersion:2,title:D,description:V,ancestor:["@woocommerce/all-products","@woocommerce/single-product","core/post-template"],usesContext:["query","queryId","postId"],icon:{src:F},attributes:q,edit:z,supports:{...d.supports,...Object(s.b)()&&{color:{text:!0,background:!1,link:!1,__experimentalSkipSerialization:!0},typography:{fontSize:!0,__experimentalFontWeight:!0,__experimentalFontStyle:!0,__experimentalSkipSerialization:!0},__experimentalSelector:".wc-block-components-product-price"}}};Object(o.registerBlockType)("woocommerce/product-price",H);var Q=c(6),G=c.n(Q),Y=c(2),U=c(126),W=c(193),$=c(529);const K=Object(l.__)("Product Image","woo-gutenberg-products-block"),J=Object(r.createElement)(n.a,{icon:$.a,className:"wc-block-editor-components-block-icon"}),X=Object(l.__)("Display the main product image.","woo-gutenberg-products-block");var Z=v({icon:J,label:K,description:X})(e=>{let{attributes:t,setAttributes:c,context:o}=e;const{showProductLink:n,imageSizing:a,showSaleBadge:s,saleBadgeAlign:i}=t,u=Object(g.useBlockProps)(),d=Number.isFinite(o.queryId),b=Object(Y.getSettingWithCoercion)("is_block_theme_enabled",!1,U.a);return Object(r.useEffect)(()=>c({isDescendentOfQueryLoop:d}),[c,d]),Object(r.useEffect)(()=>{b&&"full-size"!==t.imageSizing&&c({imageSizing:"full-size"})},[t.imageSizing,b,c]),Object(r.createElement)("div",u,Object(r.createElement)(g.InspectorControls,null,Object(r.createElement)(p.PanelBody,{title:Object(l.__)("Content","woo-gutenberg-products-block")},Object(r.createElement)(p.ToggleControl,{label:Object(l.__)("Link to Product Page","woo-gutenberg-products-block"),help:Object(l.__)("Links the image to the single product listing.","woo-gutenberg-products-block"),checked:n,onChange:()=>c({showProductLink:!n})}),Object(r.createElement)(p.ToggleControl,{label:Object(l.__)("Show On-Sale Badge","woo-gutenberg-products-block"),help:Object(l.__)("Display a “sale” badge if the product is on-sale.","woo-gutenberg-products-block"),checked:s,onChange:()=>c({showSaleBadge:!s})}),s&&Object(r.createElement)(p.__experimentalToggleGroupControl,{label:Object(l.__)("Sale Badge Alignment","woo-gutenberg-products-block"),value:i,onChange:e=>c({saleBadgeAlign:e})},Object(r.createElement)(p.__experimentalToggleGroupControlOption,{value:"left",label:Object(l.__)("Left","woo-gutenberg-products-block")}),Object(r.createElement)(p.__experimentalToggleGroupControlOption,{value:"center",label:Object(l.__)("Center","woo-gutenberg-products-block")}),Object(r.createElement)(p.__experimentalToggleGroupControlOption,{value:"right",label:Object(l.__)("Right","woo-gutenberg-products-block")})),!b&&Object(r.createElement)(p.__experimentalToggleGroupControl,{label:Object(l.__)("Image Sizing","woo-gutenberg-products-block"),help:Object(r.createInterpolateElement)(Object(l.__)("Product image cropping can be modified in the <a>Customizer</a>.","woo-gutenberg-products-block"),{a:Object(r.createElement)("a",{href:Object(Y.getAdminLink)("customize.php")+"?autofocus[panel]=woocommerce&autofocus[section]=woocommerce_product_images",target:"_blank",rel:"noopener noreferrer"})}),value:a,onChange:e=>c({imageSizing:e})},Object(r.createElement)(p.__experimentalToggleGroupControlOption,{value:"full-size",label:Object(l.__)("Full Size","woo-gutenberg-products-block")}),Object(r.createElement)(p.__experimentalToggleGroupControlOption,{value:"cropped",label:Object(l.__)("Cropped","woo-gutenberg-products-block")})))),Object(r.createElement)(p.Disabled,null,Object(r.createElement)(W.b,G()({},t,o))))});const ee={html:!1,...Object(s.b)()&&{__experimentalBorder:{radius:!0,__experimentalSkipSerialization:!0},typography:{fontSize:!0,__experimentalSkipSerialization:!0},...Object(I.a)()&&{spacing:{margin:!0,__experimentalSkipSerialization:!0}},__experimentalSelector:".wc-block-components-product-image"}};var te=c(306);const ce={...d,apiVersion:2,name:"woocommerce/product-image",title:K,icon:{src:J},keywords:["WooCommerce"],description:X,usesContext:["query","queryId","postId"],ancestor:["@woocommerce/all-products","@woocommerce/single-product","core/post-template"],textdomain:"woo-gutenberg-products-block",attributes:te.a,supports:ee,edit:Z};Object(o.registerBlockType)("woocommerce/product-image",{...ce});var re=c(205),oe=c(522);const ne=Object(l.__)("Product Rating","woo-gutenberg-products-block"),ae=Object(r.createElement)(n.a,{icon:oe.a,className:"wc-block-editor-components-block-icon"}),se=Object(l.__)("Display the average rating of a product.","woo-gutenberg-products-block");var le=v({icon:ae,label:ne,description:Object(l.__)("Choose a product to display its rating.","woo-gutenberg-products-block")})(e=>{let{attributes:t,setAttributes:c,context:o}=e;const n=Object(g.useBlockProps)({className:"wp-block-woocommerce-product-rating"}),a={...t,...o},s=Number.isFinite(o.queryId);return Object(A.useEffect)(()=>c({isDescendentOfQueryLoop:s}),[c,s]),Object(r.createElement)("div",n,Object(r.createElement)(re.default,a))});const ie={apiVersion:2,title:ne,description:se,usesContext:["query","queryId","postId"],ancestor:["@woocommerce/all-products","@woocommerce/single-product","core/post-template"],icon:{src:ae},attributes:{productId:{type:"number",default:0},isDescendentOfQueryLoop:{type:"boolean",default:!1}},supports:{...Object(s.b)()&&{color:{text:!0,background:!1,link:!1,__experimentalSkipSerialization:!0},typography:{fontSize:!0,__experimentalSkipSerialization:!0},...Object(I.a)()&&{spacing:{margin:!0,__experimentalSkipSerialization:!0}},__experimentalSelector:".wc-block-components-product-rating"}},edit:le};Object(o.registerBlockType)("woocommerce/product-rating",{...d,...ie});var ue=c(206),de=c(530);const be=Object(l.__)("Add to Cart Button","woo-gutenberg-products-block"),pe=Object(r.createElement)(n.a,{icon:de.a,className:"wc-block-editor-components-block-icon"}),me={apiVersion:2,title:be,description:Object(l.__)("Display a call to action button which either adds the product to the cart, or links to the product page.","woo-gutenberg-products-block"),ancestor:["@woocommerce/all-products","@woocommerce/single-product","core/post-template"],usesContext:["query","queryId","postId"],icon:{src:pe},attributes:{productId:{type:"number",default:0},isDescendentOfQueryLoop:{type:"boolean",default:!1}},supports:{...Object(s.b)()&&{color:{text:!0,background:!0,link:!1,__experimentalSkipSerialization:!0},__experimentalBorder:{radius:!0,__experimentalSkipSerialization:!0},...Object(I.a)()&&{spacing:{padding:!0,__experimentalSkipSerialization:!0}},typography:{fontSize:!0,__experimentalFontWeight:!0,__experimentalSkipSerialization:!0},__experimentalSelector:".wp-block-button.wc-block-components-product-button .wc-block-components-product-button__button"}},edit:e=>{let{attributes:t,setAttributes:c,context:o}=e;const n=Object(g.useBlockProps)(),a=Number.isFinite(o.queryId);return Object(r.useEffect)(()=>c({isDescendentOfQueryLoop:a}),[c,a]),Object(r.createElement)("div",n,Object(r.createElement)(p.Disabled,null,Object(r.createElement)(ue.default,G()({},t,o))))}};Object(o.registerBlockType)("woocommerce/product-button",{...d,...me});var ge=c(317),Oe=c(531);const je=Object(l.__)("Product Summary","woo-gutenberg-products-block"),he=Object(r.createElement)(n.a,{icon:Oe.a,className:"wc-block-editor-components-block-icon"}),_e=Object(l.__)("Display a short description about a product.","woo-gutenberg-products-block");c(385);var Ee=v({icon:he,label:je,description:_e})(e=>{let{attributes:t}=e;const c=Object(g.useBlockProps)();return Object(r.createElement)("div",c,Object(r.createElement)(ge.default,t))});const we={...Object(s.b)()&&{color:{background:!1},typography:{fontSize:!0},__experimentalSelector:".wc-block-components-product-summary"}},fe={...d,apiVersion:2,title:je,description:_e,icon:{src:he},attributes:{productId:{type:"number",default:0}},supports:we,edit:Ee,save:e=>{let{attributes:t}=e;return Object(r.createElement)("div",g.useBlockProps.save({className:u()("is-loading",t.className)}))}};Object(o.registerBlockType)("woocommerce/product-summary",fe);var ke=c(140),ye=c(520);const ve=Object(l.__)("On-Sale Badge","woo-gutenberg-products-block"),Se=Object(r.createElement)(n.a,{icon:ye.a,className:"wc-block-editor-components-block-icon"}),Ce=Object(l.__)("Displays an on-sale badge if the product is on-sale.","woo-gutenberg-products-block");var xe=v({icon:Se,label:ve,description:Ce})(e=>{let{attributes:t}=e;const c=Object(g.useBlockProps)();return Object(r.createElement)("div",c,Object(r.createElement)(ke.default,t))});const Ne={html:!1,...Object(s.b)()&&{color:{gradients:!0,background:!0,link:!1,__experimentalSkipSerialization:!0},typography:{fontSize:!0,__experimentalSkipSerialization:!0},__experimentalBorder:{color:!0,radius:!0,width:!0,__experimentalSkipSerialization:!0},...Object(I.a)()&&{spacing:{padding:!0,__experimentalSkipSerialization:!0}},__experimentalSelector:".wc-block-components-product-sale-badge"}},Pe={...d,title:ve,description:Ce,icon:{src:Se},apiVersion:2,supports:Ne,attributes:{productId:{type:"number",default:0}},edit:xe,save:e=>{let{attributes:t}=e;return Object(r.createElement)("div",g.useBlockProps.save({className:u()("is-loading",t.className)}))}};Object(o.registerBlockType)("woocommerce/product-sale-badge",{...Pe});var Te=c(107),Ie=c(318),Re=Object(r.createElement)(j.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(r.createElement)("path",{d:"M2 6h2v12H2V6m3 0h1v12H5V6m2 0h3v12H7V6m4 0h1v12h-1V6m3 0h2v12h-2V6m3 0h3v12h-3V6m4 0h1v12h-1V6z"}));const Ae=Object(l.__)("Product SKU","woo-gutenberg-products-block"),Be=Object(r.createElement)(n.a,{icon:Re,className:"wc-block-editor-components-block-icon"}),Le={apiVersion:2,title:Ae,description:Object(l.__)("Display the SKU of a product.","woo-gutenberg-products-block"),icon:{src:Be},usesContext:["query","queryId","postId"],ancestor:["@woocommerce/all-products","@woocommerce/single-product","core/post-template"],attributes:{productId:{type:"number",default:0},isDescendentOfQueryLoop:{type:"boolean",default:!1}},edit:v({icon:Be,label:Ae,description:Object(l.__)("Choose a product to display its SKU.","woo-gutenberg-products-block")})(e=>{let{attributes:t,setAttributes:c,context:o}=e;const n={...t,...o},a=Number.isFinite(o.queryId);return Object(A.useEffect)(()=>c({isDescendentOfQueryLoop:a}),[c,a]),Object(r.createElement)(r.Fragment,null,Object(r.createElement)(Te.a,null),Object(r.createElement)(Ie.default,n))})};Object(s.c)("woocommerce/product-sku",{...d,...Le});var De=c(319),Fe=c(532);const Ve=Object(l.__)("Product Category List","woo-gutenberg-products-block"),ze=Object(r.createElement)(n.a,{icon:Fe.a,className:"wc-block-editor-components-block-icon"}),Me=Object(l.__)("Display the list of categories that are assigned to a product.","woo-gutenberg-products-block");var qe=v({icon:ze,label:Ve,description:Object(l.__)("Choose a product to display its categories.","woo-gutenberg-products-block")})(e=>{let{attributes:t}=e;const c=Object(g.useBlockProps)();return Object(r.createElement)("div",c,Object(r.createElement)(Te.a,null),Object(r.createElement)(p.Disabled,null,Object(r.createElement)(De.default,t)))});const He={...d,apiVersion:2,title:Ve,description:Me,icon:{src:ze},attributes:{productId:{type:"number",default:0}},supports:{...Object(s.b)()&&{color:{text:!0,link:!0,background:!1,__experimentalSkipSerialization:!0},typography:{fontSize:!0,lineHeight:!0,__experimentalFontStyle:!0,__experimentalFontWeight:!0,__experimentalSkipSerialization:!0},__experimentalSelector:".wc-block-components-product-category-list"}},save:e=>{let{attributes:t}=e;return Object(r.createElement)("div",g.useBlockProps.save({className:u()("is-loading",t.className)}))},edit:qe};Object(s.c)("woocommerce/product-category-list",He);var Qe=c(320),Ge=c(525);const Ye=Object(l.__)("Product Tag List","woo-gutenberg-products-block"),Ue=Object(r.createElement)(n.a,{icon:Ge.a,className:"wc-block-editor-components-block-icon"}),We=Object(l.__)("Display the list of tags that are assigned to a product.","woo-gutenberg-products-block");var $e=v({icon:Ue,label:Ye,description:Object(l.__)("Choose a product to display its tags.","woo-gutenberg-products-block")})(e=>{let{attributes:t}=e;const c=Object(g.useBlockProps)();return Object(r.createElement)("div",c,Object(r.createElement)(Te.a,null),Object(r.createElement)(p.Disabled,null,Object(r.createElement)(Qe.default,t)))});const Ke={...Object(s.b)()&&{color:{text:!0,background:!1,link:!0},typography:{fontSize:!0},__experimentalSelector:".wc-block-components-product-tag-list"}},Je={...d,apiVersion:2,title:Ye,description:We,icon:{src:Ue},attributes:{productId:{type:"number",default:0}},supports:Ke,edit:$e,save:e=>{let{attributes:t}=e;return Object(r.createElement)("div",g.useBlockProps.save({className:u()("is-loading",t.className)}))}};Object(s.c)("woocommerce/product-tag-list",{...d,...Je});var Xe=c(321),Ze=c(533);const et=Object(l.__)("Product Stock Indicator","woo-gutenberg-products-block"),tt=Object(r.createElement)(n.a,{icon:Ze.a,className:"wc-block-editor-components-block-icon"}),ct=Object(l.__)("Display product stock status.","woo-gutenberg-products-block");var rt=v({icon:tt,label:et,description:ct})(e=>{let{attributes:t}=e;const c=Object(g.useBlockProps)();return Object(r.createElement)("div",c,Object(r.createElement)(Te.a,null),Object(r.createElement)(Xe.default,t))});const ot={...Object(s.b)()&&{color:{text:!0,background:!1,link:!1},typography:{fontSize:!0},__experimentalSelector:".wc-block-components-product-stock-indicator"}},nt={...d,apiVersion:2,title:et,description:ct,icon:{src:tt},attributes:{productId:{type:"number",default:0}},supports:ot,edit:rt,save:e=>{let{attributes:t}=e;return Object(r.createElement)("div",g.useBlockProps.save({className:u()("is-loading",t.className)}))}};Object(s.c)("woocommerce/product-stock-indicator",{...nt});var at=c(349),st=(c(229),c(203)),lt=c(270);const it=Object(l.__)("Add to Cart","woo-gutenberg-products-block"),ut=Object(r.createElement)(n.a,{icon:lt.a,className:"wc-block-editor-components-block-icon"}),dt={title:it,description:Object(l.__)("Displays an add to cart button. Optionally displays other add to cart form elements.","woo-gutenberg-products-block"),icon:{src:ut},edit:v({icon:ut,label:it,description:Object(l.__)("Choose a product to display its add to cart form.","woo-gutenberg-products-block")})(e=>{let{attributes:t,setAttributes:c}=e;const{product:o}=Object(y.useProductDataContext)(),{className:n,showFormElements:a}=t;return Object(r.createElement)("div",{className:u()(n,"wc-block-components-product-add-to-cart")},Object(r.createElement)(Te.a,{productId:o.id}),Object(r.createElement)(g.InspectorControls,null,Object(r.createElement)(p.PanelBody,{title:Object(l.__)("Layout","woo-gutenberg-products-block")},Object(at.b)(o)?Object(r.createElement)(p.ToggleControl,{label:Object(l.__)("Display form elements","woo-gutenberg-products-block"),help:Object(l.__)("Depending on product type, allow customers to select a quantity, variations etc.","woo-gutenberg-products-block"),checked:a,onChange:()=>c({showFormElements:!a})}):Object(r.createElement)(p.Notice,{className:"wc-block-components-product-add-to-cart-notice",isDismissible:!1,status:"info"},Object(l.__)("This product does not support the block based add to cart form. A link to the product page will be shown instead.","woo-gutenberg-products-block")))),Object(r.createElement)(p.Disabled,null,Object(r.createElement)(st.a,t)))}),attributes:c(308).a};Object(s.c)("woocommerce/product-add-to-cart",{...d,...dt});var bt=c(216);const pt=(e,t)=>{const{className:c,contentVisibility:r}=t;return u()(e,c,{"has-image":r&&r.image,"has-title":r&&r.title,"has-rating":r&&r.rating,"has-price":r&&r.price,"has-button":r&&r.button})},{attributes:mt}=bt;var gt=[{attributes:Object.assign({},mt,{rows:{type:"number",default:1}}),save(e){let{attributes:t}=e;const c={"data-attributes":JSON.stringify(t)};return Object(r.createElement)("div",G()({className:pt("wc-block-all-products",t)},c),Object(r.createElement)(g.InnerBlocks.Content,null))}}],Ot=c(24),jt=c.n(Ot),ht=c(7),_t=c(64),Et=c(500),wt=c(372),ft=c(21),kt=c(250);const yt=[["woocommerce/product-image",{imageSizing:"cropped"}],["woocommerce/product-title"],["woocommerce/product-price"],["woocommerce/product-rating"],["woocommerce/product-button"]],vt=e=>e&&0!==e.length?e.map(e=>[e.name,{...e.attributes,product:void 0,children:e.innerBlocks.length>0?vt(e.innerBlocks):[]}]):[];var St=c(28);c(391);var Ct=e=>{let{currentPage:t,displayFirstAndLastPages:c=!0,displayNextAndPreviousArrows:o=!0,pagesToDisplay:n=3,onPageChange:a,totalPages:s}=e,{minIndex:i,maxIndex:d}=((e,t,c)=>{if(c<=2)return{minIndex:null,maxIndex:null};const r=e-1,o=Math.max(Math.floor(t-r/2),2),n=Math.min(Math.ceil(t+(r-(t-o))),c-1);return{minIndex:Math.max(Math.floor(t-(r-(n-t))),2),maxIndex:n}})(n,t,s);const b=c&&Boolean(1!==i),p=c&&Boolean(d!==s),m=c&&Boolean(i&&i>3),g=c&&Boolean(d&&d<s-2);b&&3===i&&(i-=1),p&&d===s-2&&(d+=1);const O=[];if(i&&d)for(let e=i;e<=d;e++)O.push(e);return Object(r.createElement)("div",{className:"wc-block-pagination wc-block-components-pagination"},Object(r.createElement)(St.a,{screenReaderLabel:Object(l.__)("Navigate to another page","woo-gutenberg-products-block")}),o&&Object(r.createElement)("button",{className:"wc-block-pagination-page wc-block-components-pagination__page wc-block-components-pagination-page--arrow",onClick:()=>a(t-1),title:Object(l.__)("Previous page","woo-gutenberg-products-block"),disabled:t<=1},Object(r.createElement)(St.a,{label:"←",screenReaderLabel:Object(l.__)("Previous page","woo-gutenberg-products-block")})),b&&Object(r.createElement)("button",{className:u()("wc-block-pagination-page","wc-block-components-pagination__page",{"wc-block-pagination-page--active":1===t,"wc-block-components-pagination__page--active":1===t}),onClick:()=>a(1),disabled:1===t},Object(r.createElement)(St.a,{label:"1",screenReaderLabel:Object(l.sprintf)(
|
29 |
/* translators: %d is the page number (1, 2, 3...). */
|
30 |
+
Object(l.__)("Page %d","woo-gutenberg-products-block"),1)})),m&&Object(r.createElement)("span",{className:"wc-block-pagination-ellipsis wc-block-components-pagination__ellipsis","aria-hidden":"true"},Object(l.__)("…","woo-gutenberg-products-block")),O.map(e=>Object(r.createElement)("button",{key:e,className:u()("wc-block-pagination-page","wc-block-components-pagination__page",{"wc-block-pagination-page--active":t===e,"wc-block-components-pagination__page--active":t===e}),onClick:t===e?void 0:()=>a(e),disabled:t===e},Object(r.createElement)(St.a,{label:e.toString(),screenReaderLabel:Object(l.sprintf)(
|
31 |
/* translators: %d is the page number (1, 2, 3...). */
|
32 |
+
Object(l.__)("Page %d","woo-gutenberg-products-block"),e)}))),g&&Object(r.createElement)("span",{className:"wc-block-pagination-ellipsis wc-block-components-pagination__ellipsis","aria-hidden":"true"},Object(l.__)("…","woo-gutenberg-products-block")),p&&Object(r.createElement)("button",{className:u()("wc-block-pagination-page","wc-block-components-pagination__page",{"wc-block-pagination-page--active":t===s,"wc-block-components-pagination__page--active":t===s}),onClick:()=>a(s),disabled:t===s},Object(r.createElement)(St.a,{label:s.toString(),screenReaderLabel:Object(l.sprintf)(
|
33 |
/* translators: %d is the page number (1, 2, 3...). */
|
34 |
+
Object(l.__)("Page %d","woo-gutenberg-products-block"),s)})),o&&Object(r.createElement)("button",{className:"wc-block-pagination-page wc-block-components-pagination__page wc-block-components-pagination-page--arrow",onClick:()=>a(t+1),title:Object(l.__)("Next page","woo-gutenberg-products-block"),disabled:t>=s},Object(r.createElement)(St.a,{label:"→",screenReaderLabel:Object(l.__)("Next page","woo-gutenberg-products-block")})))},xt=c(102),Nt=c(51),Pt=c(237),Tt=c(68);c(392);const It=e=>{if(!e)return;const t=e.getBoundingClientRect().bottom;t>=0&&t<=window.innerHeight||e.scrollIntoView()};var Rt=c(44),At=c(183),Bt=()=>{const{parentClassName:e}=Object(y.useInnerBlockLayoutContext)();return Object(r.createElement)("div",{className:e+"__no-products"},Object(r.createElement)(n.a,{className:e+"__no-products-image",icon:At.a,size:100}),Object(r.createElement)("strong",{className:e+"__no-products-title"},Object(l.__)("No products","woo-gutenberg-products-block")),Object(r.createElement)("p",{className:e+"__no-products-description"},Object(l.__)("There are currently no products available to display.","woo-gutenberg-products-block")))},Lt=c(524),Dt=e=>{let{resetCallback:t=(()=>{})}=e;const{parentClassName:c}=Object(y.useInnerBlockLayoutContext)();return Object(r.createElement)("div",{className:c+"__no-products"},Object(r.createElement)(n.a,{className:c+"__no-products-image",icon:Lt.a,size:100}),Object(r.createElement)("strong",{className:c+"__no-products-title"},Object(l.__)("No products found","woo-gutenberg-products-block")),Object(r.createElement)("p",{className:c+"__no-products-description"},Object(l.__)("We were unable to find any results based on your search.","woo-gutenberg-products-block")),Object(r.createElement)("button",{onClick:t},Object(l.__)("Reset Search","woo-gutenberg-products-block")))},Ft=c(120);c(390);var Vt=e=>{let{onChange:t,value:c}=e;return Object(r.createElement)(Ft.a,{className:"wc-block-product-sort-select wc-block-components-product-sort-select",onChange:t,options:[{key:"menu_order",label:Object(l.__)("Default sorting","woo-gutenberg-products-block")},{key:"popularity",label:Object(l.__)("Popularity","woo-gutenberg-products-block")},{key:"rating",label:Object(l.__)("Average rating","woo-gutenberg-products-block")},{key:"date",label:Object(l.__)("Latest","woo-gutenberg-products-block")},{key:"price",label:Object(l.__)("Price: low to high","woo-gutenberg-products-block")},{key:"price-desc",label:Object(l.__)("Price: high to low","woo-gutenberg-products-block")}],screenReaderLabel:Object(l.__)("Order products by","woo-gutenberg-products-block"),value:c})};const zt=(e,t,c,o)=>{if(!c)return;const n=Object(Et.a)(e);return c.map((c,a)=>{let[s,l={}]=c,i=[];l.children&&l.children.length>0&&(i=zt(e,t,l.children,o));const u=n[s];if(!u)return null;const d=t.id||0,b=["layout",s,a,o,d];return Object(r.createElement)(r.Suspense,{key:b.join("_"),fallback:Object(r.createElement)("div",{className:"wc-block-placeholder"})},Object(r.createElement)(u,G()({},l,{children:i,product:t})))})};var Mt=Object(m.withInstanceId)(e=>{let{product:t={},attributes:c,instanceId:o}=e;const{layoutConfig:n}=c,{parentClassName:a,parentName:s}=Object(y.useInnerBlockLayoutContext)(),l=0===Object.keys(t).length,i=u()(a+"__product","wc-block-layout",{"is-loading":l});return Object(r.createElement)("li",{className:i,"aria-hidden":l},zt(s,t,n,o))});c(389);const qt=e=>{switch(e){case"menu_order":case"popularity":case"rating":case"price":return{orderby:e,order:"asc"};case"price-desc":return{orderby:"price",order:"desc"};case"date":return{orderby:"date",order:"desc"}}},Ht=function(e){let{totalQuery:t,totalProducts:c}=e,{totalQuery:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return!Object(O.isEqual)(t,r)&&Number.isFinite(c)};var Qt,Gt=(Qt=e=>{let{attributes:t,currentPage:c,onPageChange:o,onSortChange:n,sortValue:a,scrollToTop:s}=e;const[i,d]=Object(Nt.b)("attributes",[]),[b,p]=Object(Nt.b)("stock_status",[]),[m,g]=Object(Nt.b)("rating",[]),[j,h]=Object(Nt.b)("min_price"),[_,E]=Object(Nt.b)("max_price"),[w]=Object(Nt.c)((e=>{let{sortValue:t,currentPage:c,attributes:r}=e;const{columns:o,rows:n}=r;return{...qt(t),catalog_visibility:"catalog",per_page:o*n,page:c}})({attributes:t,sortValue:a,currentPage:c})),{products:f,totalProducts:k,productsLoading:v}=Object(Pt.a)(w),{parentClassName:S,parentName:C}=Object(y.useInnerBlockLayoutContext)(),x=(e=>{const{order:t,orderby:c,page:r,per_page:o,...n}=e;return n||{}})(w),{dispatchStoreEvent:N}=Object(Tt.a)(),P=Object(xt.a)({totalQuery:x,totalProducts:k},Ht);Object(r.useEffect)(()=>{N("product-list-render",{products:f,listName:C})},[f,C,N]),Object(r.useEffect)(()=>{Object(O.isEqual)(x,null==P?void 0:P.totalQuery)||(o(1),null!=P&&P.totalQuery&&(e=>{Number.isFinite(e)&&(0===e?Object(Rt.speak)(Object(l.__)("No products found","woo-gutenberg-products-block")):Object(Rt.speak)(Object(l.sprintf)(
|
35 |
/* translators: %s is an integer higher than 0 (1, 2, 3...) */
|
36 |
+
Object(l._n)("%d product found","%d products found",e,"woo-gutenberg-products-block"),e)))})(k))},[null==P?void 0:P.totalQuery,k,o,x]);const{contentVisibility:T}=t,I=t.columns*t.rows,R=!Number.isFinite(k)&&Number.isFinite(null==P?void 0:P.totalProducts)&&Object(O.isEqual)(x,null==P?void 0:P.totalQuery)?Math.ceil(((null==P?void 0:P.totalProducts)||0)/I):Math.ceil(k/I),A=f.length?f:Array.from({length:I}),B=0!==f.length||v,L=i.length>0||b.length>0||m.length>0||Number.isFinite(j)||Number.isFinite(_);return Object(r.createElement)("div",{className:(()=>{const{columns:e,rows:c,alignButtons:r,align:o}=t,n=void 0!==o?"align"+o:"";return u()(S,n,"has-"+e+"-columns",{"has-multiple-rows":c>1,"has-aligned-buttons":r})})()},(null==T?void 0:T.orderBy)&&B&&Object(r.createElement)(Vt,{onChange:n,value:a}),!B&&L&&Object(r.createElement)(Dt,{resetCallback:()=>{d([]),p([]),g([]),h(null),E(null)}}),!B&&!L&&Object(r.createElement)(Bt,null),B&&Object(r.createElement)("ul",{className:u()(S+"__products",{"is-loading-products":v})},A.map((function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},c=arguments.length>1?arguments[1]:void 0;return Object(r.createElement)(Mt,{key:e.id||c,attributes:t,product:e})}))),R>1&&Object(r.createElement)(Ct,{currentPage:c,onPageChange:e=>{s({focusableSelector:"a, button"}),o(e)},totalPages:R}))},e=>{const t=Object(r.useRef)(null);return Object(r.createElement)(r.Fragment,null,Object(r.createElement)("div",{className:"with-scroll-to-top__scroll-point",ref:t,"aria-hidden":!0}),Object(r.createElement)(Qt,G()({},e,{scrollToTop:e=>{null!==t.current&&((e,t)=>{const{focusableSelector:c}=t||{};window&&Number.isFinite(window.innerHeight)&&(c?((e,t)=>{var c;const r=(null===(c=e.parentElement)||void 0===c?void 0:c.querySelectorAll(t))||[];if(r.length){const e=r[0];It(e),null==e||e.focus()}else It(e)})(e,c):It(e))})(t.current,e)}})))}),Yt=e=>{let{attributes:t}=e;const[c,o]=Object(r.useState)(1),[n,a]=Object(r.useState)(t.orderby);return Object(r.useEffect)(()=>{a(t.orderby)},[t.orderby]),Object(r.createElement)(Gt,{attributes:t,currentPage:c,onPageChange:e=>{o(e)},onSortChange:e=>{var t;const c=null==e||null===(t=e.target)||void 0===t?void 0:t.value;a(c),o(1)},sortValue:n})},Ut=c(150),Wt=c(16);class $t extends A.Component{render(){const{attributes:e,urlParameterSuffix:t}=this.props;return e.isPreview?Ut.a:Object(r.createElement)(y.InnerBlockLayoutContextProvider,{parentName:"woocommerce/all-products",parentClassName:"wc-block-grid"},Object(r.createElement)(Wt.StoreNoticesContainer,{context:"wc/all-products"}),Object(r.createElement)(Yt,{attributes:e,urlParameterSuffix:t}))}}var Kt=$t;c(388);class Jt extends r.Component{constructor(){super(...arguments),jt()(this,"state",{isEditing:!1,innerBlocks:[]}),jt()(this,"blockMap",Object(Et.a)("woocommerce/all-products")),jt()(this,"componentDidMount",()=>{const{block:e}=this.props;this.setState({innerBlocks:e.innerBlocks})}),jt()(this,"getTitle",()=>Object(l.__)("All Products","woo-gutenberg-products-block")),jt()(this,"getIcon",()=>Object(r.createElement)(n.a,{icon:a.a})),jt()(this,"togglePreview",()=>{const{debouncedSpeak:e}=this.props;this.setState({isEditing:!this.state.isEditing}),this.state.isEditing||e(Object(l.__)("Showing All Products block preview.","woo-gutenberg-products-block"))}),jt()(this,"getInspectorControls",()=>{const{attributes:e,setAttributes:t}=this.props,{columns:c,rows:o,alignButtons:n}=e;return Object(r.createElement)(g.InspectorControls,{key:"inspector"},Object(r.createElement)(p.PanelBody,{title:Object(l.__)("Layout Settings","woo-gutenberg-products-block"),initialOpen:!0},Object(r.createElement)(_t.a,{columns:c,rows:o,alignButtons:n,setAttributes:t,minColumns:Object(Y.getSetting)("min_columns",1),maxColumns:Object(Y.getSetting)("max_columns",6),minRows:Object(Y.getSetting)("min_rows",1),maxRows:Object(Y.getSetting)("max_rows",6)})),Object(r.createElement)(p.PanelBody,{title:Object(l.__)("Content Settings","woo-gutenberg-products-block")},((e,t)=>{const{contentVisibility:c}=e;return Object(r.createElement)(p.ToggleControl,{label:Object(l.__)("Show Sorting Dropdown","woo-gutenberg-products-block"),checked:c.orderBy,onChange:()=>t({contentVisibility:{...c,orderBy:!c.orderBy}})})})(e,t),((e,t)=>Object(r.createElement)(p.SelectControl,{label:Object(l.__)("Order Products By","woo-gutenberg-products-block"),value:e.orderby,options:[{label:Object(l.__)("Default sorting (menu order)","woo-gutenberg-products-block"),value:"menu_order"},{label:Object(l.__)("Popularity","woo-gutenberg-products-block"),value:"popularity"},{label:Object(l.__)("Average rating","woo-gutenberg-products-block"),value:"rating"},{label:Object(l.__)("Latest","woo-gutenberg-products-block"),value:"date"},{label:Object(l.__)("Price: low to high","woo-gutenberg-products-block"),value:"price"},{label:Object(l.__)("Price: high to low","woo-gutenberg-products-block"),value:"price-desc"}],onChange:e=>t({orderby:e})}))(e,t)))}),jt()(this,"getBlockControls",()=>{const{isEditing:e}=this.state;return Object(r.createElement)(g.BlockControls,null,Object(r.createElement)(p.ToolbarGroup,{controls:[{icon:"edit",title:Object(l.__)("Edit the layout of each product","woo-gutenberg-products-block"),onClick:()=>this.togglePreview(),isActive:e}]}))}),jt()(this,"renderEditMode",()=>{const e={template:this.props.attributes.layoutConfig,templateLock:!1,allowedBlocks:Object.keys(this.blockMap)};return 0!==this.props.attributes.layoutConfig.length&&(e.renderAppender=!1),Object(r.createElement)(p.Placeholder,{icon:this.getIcon(),label:this.getTitle()},Object(l.__)("Display all products from your store as a grid.","woo-gutenberg-products-block"),Object(r.createElement)("div",{className:"wc-block-all-products-grid-item-template"},Object(r.createElement)(p.Tip,null,Object(l.__)("Edit the blocks inside the example below to change the content displayed for all products within the product grid.","woo-gutenberg-products-block")),Object(r.createElement)(y.InnerBlockLayoutContextProvider,{parentName:"woocommerce/all-products",parentClassName:"wc-block-grid"},Object(r.createElement)("div",{className:"wc-block-grid wc-block-layout has-1-columns"},Object(r.createElement)("ul",{className:"wc-block-grid__products"},Object(r.createElement)("li",{className:"wc-block-grid__product"},Object(r.createElement)(y.ProductDataContextProvider,{product:wt.a[0]},Object(r.createElement)(g.InnerBlocks,e)))))),Object(r.createElement)("div",{className:"wc-block-all-products__actions"},Object(r.createElement)(p.Button,{className:"wc-block-all-products__done-button",isPrimary:!0,onClick:()=>{const{block:e,setAttributes:t}=this.props;t({layoutConfig:vt(e.innerBlocks)}),this.setState({innerBlocks:e.innerBlocks}),this.togglePreview()}},Object(l.__)("Done","woo-gutenberg-products-block")),Object(r.createElement)(p.Button,{className:"wc-block-all-products__cancel-button",isTertiary:!0,onClick:()=>{const{block:e,replaceInnerBlocks:t}=this.props,{innerBlocks:c}=this.state;t(e.clientId,c,!1),this.togglePreview()}},Object(l.__)("Cancel","woo-gutenberg-products-block")),Object(r.createElement)(p.Button,{className:"wc-block-all-products__reset-button",icon:Object(r.createElement)(n.a,{icon:a.a}),label:Object(l.__)("Reset layout to default","woo-gutenberg-products-block"),onClick:()=>{const{block:e,replaceInnerBlocks:t}=this.props,c=[];yt.map(e=>{let[t,r]=e;return c.push(Object(o.createBlock)(t,r)),!0}),t(e.clientId,c,!1),this.setState({innerBlocks:e.innerBlocks})}},Object(l.__)("Reset Layout","woo-gutenberg-products-block")))))}),jt()(this,"renderViewMode",()=>{const{attributes:e}=this.props,{layoutConfig:t}=e,c=t&&0!==t.length,o=this.getTitle(),n=this.getIcon();return c?Object(r.createElement)(p.Disabled,null,Object(r.createElement)(Kt,{attributes:e})):((e,t)=>Object(r.createElement)(p.Placeholder,{className:"wc-block-products",icon:t,label:e},Object(l.__)("The content for this block is hidden due to block settings.","woo-gutenberg-products-block")))(o,n)}),jt()(this,"render",()=>{const{attributes:e}=this.props,{isEditing:t}=this.state,c=this.getTitle(),o=this.getIcon();return 0===ft.o.productCount?((e,t)=>Object(r.createElement)(p.Placeholder,{className:"wc-block-products",icon:t,label:e},Object(r.createElement)("p",null,Object(l.__)("You haven't published any products to list here yet.","woo-gutenberg-products-block")),Object(r.createElement)(p.Button,{className:"wc-block-products__add-product-button",isSecondary:!0,href:Y.ADMIN_URL+"post-new.php?post_type=product"},Object(l.__)("Add new product","woo-gutenberg-products-block")+" ",Object(r.createElement)(n.a,{icon:kt.a})),Object(r.createElement)(p.Button,{className:"wc-block-products__read_more_button",isTertiary:!0,href:"https://docs.woocommerce.com/document/managing-products/"},Object(l.__)("Learn more","woo-gutenberg-products-block"))))(c,o):Object(r.createElement)("div",{className:pt("wc-block-all-products",e)},this.getBlockControls(),this.getInspectorControls(),t?this.renderEditMode():this.renderViewMode())})}}var Xt=Object(m.compose)(p.withSpokenMessages,Object(ht.withSelect)((e,t)=>{let{clientId:c}=t;const{getBlock:r}=e("core/block-editor");return{block:r(c)}}),Object(ht.withDispatch)(e=>{const{replaceInnerBlocks:t}=e("core/block-editor");return{replaceInnerBlocks:t}}))(Jt),Zt={columns:Object(Y.getSetting)("default_columns",3),rows:Object(Y.getSetting)("default_rows",3),alignButtons:!1,contentVisibility:{orderBy:!0},orderby:"date",layoutConfig:yt,isPreview:!1};const{name:ec}=bt,tc={icon:{src:Object(r.createElement)(n.a,{icon:a.a,className:"wc-block-editor-components-block-icon"})},edit:Xt,save:function(e){let{attributes:t}=e;const c={};Object.keys(t).sort().forEach(e=>{c[e]=t[e]});const o={"data-attributes":JSON.stringify(c)};return Object(r.createElement)("div",G()({className:pt("wc-block-all-products",t)},o),Object(r.createElement)(g.InnerBlocks.Content,null))},deprecated:gt,defaults:Zt};Object(o.registerBlockType)(ec,tc)},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return a}));var r=c(36),o=c(0),n=c(21);c.p=n.l,Object(r.registerBlockComponent)({blockName:"woocommerce/product-price",component:Object(o.lazy)(()=>Promise.all([c.e(0),c.e(1),c.e(2),c.e(28)]).then(c.bind(null,204)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-image",component:Object(o.lazy)(()=>Promise.all([c.e(1),c.e(2),c.e(4),c.e(3),c.e(25)]).then(c.bind(null,556)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-title",component:Object(o.lazy)(()=>Promise.all([c.e(1),c.e(2),c.e(4),c.e(3),c.e(38)]).then(c.bind(null,557)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-rating",component:Object(o.lazy)(()=>Promise.all([c.e(1),c.e(2),c.e(4),c.e(3),c.e(30)]).then(c.bind(null,205)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-button",component:Object(o.lazy)(()=>Promise.all([c.e(1),c.e(2),c.e(4),c.e(3),c.e(21)]).then(c.bind(null,206)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-summary",component:Object(o.lazy)(()=>Promise.all([c.e(1),c.e(2),c.e(35)]).then(c.bind(null,317)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-sale-badge",component:Object(o.lazy)(()=>Promise.all([c.e(1),c.e(2),c.e(4),c.e(31)]).then(c.bind(null,140)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-sku",component:Object(o.lazy)(()=>c.e(33).then(c.bind(null,318)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-category-list",component:Object(o.lazy)(()=>Promise.all([c.e(1),c.e(2),c.e(24)]).then(c.bind(null,319)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-tag-list",component:Object(o.lazy)(()=>Promise.all([c.e(1),c.e(2),c.e(37)]).then(c.bind(null,320)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-stock-indicator",component:Object(o.lazy)(()=>Promise.all([c.e(1),c.e(2),c.e(34)]).then(c.bind(null,321)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-add-to-cart",component:Object(o.lazy)(()=>Promise.all([c.e(0),c.e(1),c.e(3),c.e(19)]).then(c.bind(null,558)))});const a=e=>Object(r.getRegisteredBlockComponents)(e)}]);
|
build/all-reviews.asset.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php return array('dependencies' => array('lodash', 'react', 'wc-settings', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-element', 'wp-escape-html', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-polyfill', 'wp-primitives'), 'version' => '
|
1 |
+
<?php return array('dependencies' => array('lodash', 'react', 'wc-settings', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-element', 'wp-escape-html', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-polyfill', 'wp-primitives'), 'version' => 'fc319aa1b549e45764642977521c678e');
|
build/all-reviews.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["all-reviews"]=function(e){function t(t){for(var o,a,i=t[0],s=t[1],l=t[2],u=0,b=[];u<i.length;u++)a=i[u],Object.prototype.hasOwnProperty.call(n,a)&&n[a]&&b.push(n[a][0]),n[a]=0;for(o in s)Object.prototype.hasOwnProperty.call(s,o)&&(e[o]=s[o]);for(d&&d(t);b.length;)b.shift()();return c.push.apply(c,l||[]),r()}function r(){for(var e,t=0;t<c.length;t++){for(var r=c[t],o=!0,i=1;i<r.length;i++){var s=r[i];0!==n[s]&&(o=!1)}o&&(c.splice(t--,1),e=a(a.s=r[0]))}return e}var o={},n={7:0},c=[];function a(t){if(o[t])return o[t].exports;var r=o[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,a),r.l=!0,r.exports}a.m=e,a.c=o,a.d=function(e,t,r){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)a.d(r,o,function(t){return e[t]}.bind(null,o));return r},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="";var i=window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[],s=i.push.bind(i);i.push=t,i=i.slice();for(var l=0;l<i.length;l++)t(i[l]);var d=s;return c.push([
|
2 |
/* translators: An example person name used for the block previews. */
|
3 |
reviewer:Object(o.__)("Alice","woo-gutenberg-products-block"),review:`<p>${Object(o.__)("I bought this product last week and I'm very happy with it.","woo-gutenberg-products-block")}</p>\n`,reviewer_avatar_urls:{48:n.o.defaultAvatar,96:n.o.defaultAvatar},rating:5,verified:!0},{id:2,date_created:"2019-07-12T12:39:39",formatted_date_created:Object(o.__)("July 12, 2019","woo-gutenberg-products-block"),date_created_gmt:"2019-07-12T10:39:39",product_id:0,product_name:Object(o.__)("WordPress Pennant","woo-gutenberg-products-block"),product_permalink:"#",
|
4 |
/* translators: An example person name used for the block previews. */
|
5 |
-
reviewer:Object(o.__)("Bob","woo-gutenberg-products-block"),review:`<p>${Object(o.__)("This product is awesome, I love it!","woo-gutenberg-products-block")}</p>\n`,reviewer_avatar_urls:{48:n.o.defaultAvatar,96:n.o.defaultAvatar},rating:null,verified:!1}]}}},14:function(e,t){e.exports=window.wp.apiFetch},15:function(e,t){e.exports=window.wp.htmlEntities},
|
6 |
/* translators: %f is referring to the average rating value */
|
7 |
Object(n.__)("Rated %f out of 5","woo-gutenberg-products-block"),t),a={__html:Object(n.sprintf)(
|
8 |
/* translators: %s is referring to the average rating value */
|
9 |
-
Object(n.__)("Rated %s out of 5","woo-gutenberg-products-block"),Object(n.sprintf)('<strong class="rating">%f</strong>',t))};return Object(o.createElement)("div",{className:"wc-block-review-list-item__rating wc-block-components-review-list-item__rating"},Object(o.createElement)("div",{className:"wc-block-review-list-item__rating__stars wc-block-components-review-list-item__rating__stars",role:"img","aria-label":c},Object(o.createElement)("span",{style:r,dangerouslySetInnerHTML:a})))}(r),u&&function(e){return Object(o.createElement)("div",{className:"wc-block-review-list-item__product wc-block-components-review-list-item__product"},Object(o.createElement)("a",{href:e.product_permalink,dangerouslySetInnerHTML:{__html:e.product_name}}))}(r),i&&function(e){const{reviewer:t=""}=e;return Object(o.createElement)("div",{className:"wc-block-review-list-item__author wc-block-components-review-list-item__author"},t)}(r),a&&function(e){const{date_created:t,formatted_date_created:r}=e;return Object(o.createElement)("time",{className:"wc-block-review-list-item__published-date wc-block-components-review-list-item__published-date",dateTime:t},r)}(r))),d&&function(e){return Object(o.createElement)(E,{maxLines:10,moreText:Object(n.__)("Read full review","woo-gutenberg-products-block"),lessText:Object(n.__)("Hide full review","woo-gutenberg-products-block"),className:"wc-block-review-list-item__text wc-block-components-review-list-item__text"},Object(o.createElement)("div",{dangerouslySetInnerHTML:{__html:e.review||""}}))}(r))};r(193);var C=e=>{let{attributes:t,reviews:r}=e;const n=Object(l.getSetting)("showAvatars",!0),c=Object(l.getSetting)("reviewRatingsEnabled",!0),a=(n||"product"===t.imageType)&&t.showReviewImage,i=c&&t.showReviewRating,s={...t,showReviewImage:a,showReviewRating:i};return Object(o.createElement)("ul",{className:"wc-block-review-list wc-block-components-review-list"},0===r.length?Object(o.createElement)(S,{attributes:s}):r.map((e,t)=>Object(o.createElement)(S,{key:e.id||t,attributes:s,review:e})))},T=r(6),P=r.n(T),N=r(25),L=r.n(N),x=r(57),A=r(29);class M extends s.Component{render(){const{attributes:e,error:t,isLoading:r,noReviewsPlaceholder:c,reviews:i,totalReviews:s}=this.props;if(t)return Object(o.createElement)(d.a,{className:"wc-block-featured-product-error",error:t,isLoading:r});if(0===i.length&&!r)return Object(o.createElement)(c,{attributes:e});const u=Object(l.getSetting)("reviewRatingsEnabled",!0);return Object(o.createElement)(a.Disabled,null,e.showOrderby&&u&&Object(o.createElement)(p,{readOnly:!0,value:e.orderby}),Object(o.createElement)(C,{attributes:e,reviews:i}),e.showLoadMore&&s>i.length&&Object(o.createElement)(b,{screenReaderLabel:Object(n.__)("Load more reviews","woo-gutenberg-products-block")}))}}var I=(e=>{class t extends s.Component{constructor(){super(...arguments),h()(this,"isPreview",!!this.props.attributes.previewReviews),h()(this,"delayedAppendReviews",this.props.delayFunction(this.appendReviews)),h()(this,"isMounted",!1),h()(this,"state",{error:null,loading:!0,reviews:this.isPreview?this.props.attributes.previewReviews:[],totalReviews:this.isPreview?this.props.attributes.previewReviews.length:0}),h()(this,"setError",async e=>{if(!this.isMounted)return;const{onReviewsLoadError:t}=this.props,r=await Object(A.a)(e);this.setState({reviews:[],loading:!1,error:r}),t(r)})}componentDidMount(){this.isMounted=!0,this.replaceReviews()}componentDidUpdate(e){e.reviewsToDisplay<this.props.reviewsToDisplay?this.delayedAppendReviews():this.shouldReplaceReviews(e,this.props)&&this.replaceReviews()}shouldReplaceReviews(e,t){return e.orderby!==t.orderby||e.order!==t.order||e.productId!==t.productId||!L()(e.categoryIds,t.categoryIds)}componentWillUnmount(){this.isMounted=!1,this.delayedAppendReviews.cancel&&this.delayedAppendReviews.cancel()}getArgs(e){const{categoryIds:t,order:r,orderby:o,productId:n,reviewsToDisplay:c}=this.props,a={order:r,orderby:o,per_page:c-e,offset:e};if(t){const e=Array.isArray(t)?t:JSON.parse(t);a.category_id=Array.isArray(e)?e.join(","):e}return n&&(a.product_id=n),a}replaceReviews(){if(this.isPreview)return;const{onReviewsReplaced:e}=this.props;this.updateListOfReviews().then(e)}appendReviews(){if(this.isPreview)return;const{onReviewsAppended:e,reviewsToDisplay:t}=this.props,{reviews:r}=this.state;t<=r.length||this.updateListOfReviews(r).then(e)}updateListOfReviews(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const{reviewsToDisplay:t}=this.props,{totalReviews:r}=this.state,o=Math.min(r,t)-e.length;return this.setState({loading:!0,reviews:e.concat(Array(o).fill({}))}),Object(x.c)(this.getArgs(e.length)).then(t=>{let{reviews:r,totalReviews:o}=t;return this.isMounted&&this.setState({reviews:e.filter(e=>Object.keys(e).length).concat(r),totalReviews:o,loading:!1,error:null}),{newReviews:r}}).catch(this.setError)}render(){const{reviewsToDisplay:t}=this.props,{error:r,loading:n,reviews:c,totalReviews:a}=this.state;return Object(o.createElement)(e,P()({},this.props,{error:r,isLoading:n,reviews:c.slice(0,t),totalReviews:a}))}}h()(t,"defaultProps",{delayFunction:e=>e,onReviewsAppended:()=>{},onReviewsLoadError:()=>{},onReviewsReplaced:()=>{}});const{displayName:r=e.name||"Component"}=e;return t.displayName=`WithReviews( ${r} )`,t})(M);t.a=e=>{let{attributes:t,icon:r,name:s,noReviewsPlaceholder:l}=e;const{categoryIds:d,productId:u,reviewsOnPageLoad:b,showProductName:w,showReviewDate:p,showReviewerName:m,showReviewContent:g,showReviewImage:v,showReviewRating:h}=t,{order:_,orderby:O}=Object(x.d)(t.orderby),j=!(g||h||p||m||v||w),f=Object(i.useBlockProps)({className:Object(x.a)(t)});return j?Object(o.createElement)(a.Placeholder,{icon:r,label:s},Object(n.__)("The content for this block is hidden due to block settings.","woo-gutenberg-products-block")):Object(o.createElement)("div",f,Object(o.createElement)(I,{attributes:t,categoryIds:d,delayFunction:e=>Object(c.debounce)(e,400),noReviewsPlaceholder:l,orderby:O,order:_,productId:u,reviewsToDisplay:b}))}},165:function(e,t){},166:function(e,t){},192:function(e,t){},193:function(e,t){},194:function(e,t){},195:function(e,t){},2:function(e,t){e.exports=window.wc.wcSettings},22:function(e,t,r){"use strict";r.d(t,"o",(function(){return c})),r.d(t,"m",(function(){return a})),r.d(t,"l",(function(){return i})),r.d(t,"n",(function(){return s})),r.d(t,"j",(function(){return l})),r.d(t,"e",(function(){return d})),r.d(t,"f",(function(){return u})),r.d(t,"g",(function(){return b})),r.d(t,"k",(function(){return w})),r.d(t,"c",(function(){return p})),r.d(t,"d",(function(){return m})),r.d(t,"h",(function(){return g})),r.d(t,"a",(function(){return v})),r.d(t,"i",(function(){return h})),r.d(t,"b",(function(){return _}));var o,n=r(2);const c=Object(n.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),a=c.pluginUrl+"images/",i=c.pluginUrl+"build/",s=c.buildPhase,l=null===(o=n.STORE_PAGES.shop)||void 0===o?void 0:o.permalink,d=n.STORE_PAGES.checkout.id,u=n.STORE_PAGES.checkout.permalink,b=n.STORE_PAGES.privacy.permalink,w=(n.STORE_PAGES.privacy.title,n.STORE_PAGES.terms.permalink),p=(n.STORE_PAGES.terms.title,n.STORE_PAGES.cart.id),m=n.STORE_PAGES.cart.permalink,g=(n.STORE_PAGES.myaccount.permalink?n.STORE_PAGES.myaccount.permalink:Object(n.getSetting)("wpLoginUrl","/wp-login.php"),Object(n.getSetting)("shippingCountries",{})),v=Object(n.getSetting)("allowedCountries",{}),h=Object(n.getSetting)("shippingStates",{}),_=Object(n.getSetting)("allowedStates",{})},25:function(e,t){e.exports=window.wp.isShallowEqual},28:function(e,t,r){"use strict";var o=r(0),n=r(4),c=r.n(n);t.a=e=>{let t,{label:r,screenReaderLabel:n,wrapperElement:a,wrapperProps:i={}}=e;const s=null!=r,l=null!=n;return!s&&l?(t=a||"span",i={...i,className:c()(i.className,"screen-reader-text")},Object(o.createElement)(t,i,n)):(t=a||o.Fragment,s&&l&&r!==n?Object(o.createElement)(t,i,Object(o.createElement)("span",{"aria-hidden":"true"},r),Object(o.createElement)("span",{className:"screen-reader-text"},n)):Object(o.createElement)(t,i,r))}},29:function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r.d(t,"b",(function(){return a}));var o=r(1),n=r(15);const c=async e=>{if("function"==typeof e.json)try{const t=await e.json();return{message:t.message,type:t.type||"api"}}catch(e){return{message:e.message,type:"general"}}return{message:e.message,type:e.type||"general"}},a=e=>{if(e.data&&"rest_invalid_param"===e.code){const t=Object.values(e.data.params);if(t[0])return t[0]}return null!=e&&e.message?Object(n.decodeEntities)(e.message):Object(o.__)("Something went wrong. Please contact us to get assistance.","woo-gutenberg-products-block")}},3:function(e,t){e.exports=window.wp.components},33:function(e,t,r){"use strict";var o=r(0),n=r(1),c=r(34);t.a=e=>{let{error:t}=e;return Object(o.createElement)("div",{className:"wc-block-error-message"},(e=>{let{message:t,type:r}=e;return t?"general"===r?Object(o.createElement)("span",null,Object(n.__)("The following error was returned","woo-gutenberg-products-block"),Object(o.createElement)("br",null),Object(o.createElement)("code",null,Object(c.escapeHTML)(t))):"api"===r?Object(o.createElement)("span",null,Object(n.__)("The following error was returned from the API","woo-gutenberg-products-block"),Object(o.createElement)("br",null),Object(o.createElement)("code",null,Object(c.escapeHTML)(t))):t:Object(n.__)("An error has prevented the block from being updated.","woo-gutenberg-products-block")})(t))}},34:function(e,t){e.exports=window.wp.escapeHtml},383:function(e,t,r){e.exports=r(501)},5:function(e,t){e.exports=window.wp.blockEditor},501:function(e,t,r){"use strict";r.r(t);var o=r(0),n=r(1),c=r(10),a=r(117),i=r(532),s=(r(165),r(5)),l=r(3),d=r(157),u=()=>Object(o.createElement)(l.Placeholder,{className:"wc-block-all-reviews",icon:Object(o.createElement)(a.a,{icon:i.a,className:"block-editor-block-icon"}),label:Object(n.__)("All Reviews","woo-gutenberg-products-block")},Object(n.__)("This block shows a list of all product reviews. Your store does not have any reviews yet, but they will show up here when it does.","woo-gutenberg-products-block")),b=r(111),w=r(153),p=r(154),m=r(130);Object(c.registerBlockType)("woocommerce/all-reviews",{apiVersion:2,title:Object(n.__)("All Reviews","woo-gutenberg-products-block"),icon:{src:Object(o.createElement)(a.a,{icon:i.a,className:"wc-block-editor-components-block-icon"})},category:"woocommerce",keywords:[Object(n.__)("WooCommerce","woo-gutenberg-products-block")],description:Object(n.__)("Show a list of all product reviews.","woo-gutenberg-products-block"),supports:{html:!1,color:{background:!1},typography:{fontSize:!0}},example:{...m.a,attributes:{...m.a.attributes,showProductName:!0}},attributes:{...w.a,showProductName:{type:"boolean",default:!0}},transforms:{from:[{type:"block",blocks:["core/legacy-widget"],isMatch:e=>{let{idBase:t,instance:r}=e;return"woocommerce_recent_reviews"===t&&!(null==r||!r.raw)},transform:e=>{let{instance:t}=e;return Object(c.createBlock)("woocommerce/all-reviews",{reviewsOnPageLoad:t.raw.number,imageType:"product",showLoadMore:!1,showOrderby:!1,showReviewDate:!1,showReviewContent:!1})}}]},edit:e=>{let{attributes:t,setAttributes:r}=e;return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(s.InspectorControls,{key:"inspector"},Object(o.createElement)(l.PanelBody,{title:Object(n.__)("Content","woo-gutenberg-products-block")},Object(o.createElement)(l.ToggleControl,{label:Object(n.__)("Product name","woo-gutenberg-products-block"),checked:t.showProductName,onChange:()=>r({showProductName:!t.showProductName})}),Object(b.b)(t,r)),Object(o.createElement)(l.PanelBody,{title:Object(n.__)("List Settings","woo-gutenberg-products-block")},Object(b.c)(t,r))),Object(o.createElement)(d.a,{attributes:t,icon:Object(o.createElement)(a.a,{icon:i.a,className:"block-editor-block-icon"}),name:Object(n.__)("All Reviews","woo-gutenberg-products-block"),noReviewsPlaceholder:u}))},save:p.a})},57:function(e,t,r){"use strict";r.d(t,"d",(function(){return s})),r.d(t,"c",(function(){return l})),r.d(t,"a",(function(){return d})),r.d(t,"b",(function(){return u}));var o=r(14),n=r.n(o),c=r(4),a=r.n(c),i=r(2);const s=e=>{if(Object(i.getSetting)("reviewRatingsEnabled",!0)){if("lowest-rating"===e)return{order:"asc",orderby:"rating"};if("highest-rating"===e)return{order:"desc",orderby:"rating"}}return{order:"desc",orderby:"date_gmt"}},l=e=>n()({path:"/wc/store/v1/products/reviews?"+Object.entries(e).map(e=>e.join("=")).join("&"),parse:!1}).then(e=>e.json().then(t=>({reviews:t,totalReviews:parseInt(e.headers.get("x-wp-total"),10)}))),d=e=>{const{className:t,categoryIds:r,productId:o,showReviewDate:n,showReviewerName:c,showReviewContent:i,showProductName:s,showReviewImage:l,showReviewRating:d}=e;let u="wc-block-all-reviews";return o&&(u="wc-block-reviews-by-product"),Array.isArray(r)&&(u="wc-block-reviews-by-category"),a()(u,t,{"has-image":l,"has-name":c,"has-date":n,"has-rating":d,"has-content":i,"has-product-name":s})},u=e=>{const{categoryIds:t,imageType:r,orderby:o,productId:n,reviewsOnPageLoad:c,reviewsOnLoadMore:a,showLoadMore:i,showOrderby:s}=e,l={"data-image-type":r,"data-orderby":o,"data-reviews-on-page-load":c,"data-reviews-on-load-more":a,"data-show-load-more":i,"data-show-orderby":s};return n&&(l["data-product-id"]=n),Array.isArray(t)&&(l["data-category-ids"]=t.join(",")),l}},75:function(e,t,r){"use strict";var o=r(0),n=r(1),c=r(117),a=r(186),i=r(4),s=r.n(i),l=r(3),d=r(33);r(118),t.a=e=>{let{className:t,error:r,isLoading:i=!1,onRetry:u}=e;return Object(o.createElement)(l.Placeholder,{icon:Object(o.createElement)(c.a,{icon:a.a}),label:Object(n.__)("Sorry, an error occurred","woo-gutenberg-products-block"),className:s()("wc-block-api-error",t)},Object(o.createElement)(d.a,{error:r}),u&&Object(o.createElement)(o.Fragment,null,i?Object(o.createElement)(l.Spinner,null):Object(o.createElement)(l.Button,{isSecondary:!0,onClick:u},Object(n.__)("Retry","woo-gutenberg-products-block"))))}},8:function(e,t){e.exports=window.lodash}});
|
1 |
+
this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["all-reviews"]=function(e){function t(t){for(var o,a,i=t[0],s=t[1],l=t[2],u=0,b=[];u<i.length;u++)a=i[u],Object.prototype.hasOwnProperty.call(n,a)&&n[a]&&b.push(n[a][0]),n[a]=0;for(o in s)Object.prototype.hasOwnProperty.call(s,o)&&(e[o]=s[o]);for(d&&d(t);b.length;)b.shift()();return c.push.apply(c,l||[]),r()}function r(){for(var e,t=0;t<c.length;t++){for(var r=c[t],o=!0,i=1;i<r.length;i++){var s=r[i];0!==n[s]&&(o=!1)}o&&(c.splice(t--,1),e=a(a.s=r[0]))}return e}var o={},n={7:0},c=[];function a(t){if(o[t])return o[t].exports;var r=o[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,a),r.l=!0,r.exports}a.m=e,a.c=o,a.d=function(e,t,r){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)a.d(r,o,function(t){return e[t]}.bind(null,o));return r},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="";var i=window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[],s=i.push.bind(i);i.push=t,i=i.slice();for(var l=0;l<i.length;l++)t(i[l]);var d=s;return c.push([373,0]),r()}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},11:function(e,t){e.exports=window.wp.compose},110:function(e,t,r){"use strict";r.d(t,"a",(function(){return s})),r.d(t,"b",(function(){return l})),r.d(t,"c",(function(){return d}));var o=r(0),n=r(1),c=r(5),a=r(2),i=r(3);const s=(e,t,r)=>Object(o.createElement)(c.BlockControls,null,Object(o.createElement)(i.ToolbarGroup,{controls:[{icon:"edit",title:r,onClick:()=>t({editMode:!e}),isActive:e}]})),l=(e,t)=>{const r=Object(a.getSetting)("showAvatars",!0),c=Object(a.getSetting)("reviewRatingsEnabled",!0);return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(i.ToggleControl,{label:Object(n.__)("Product rating","woo-gutenberg-products-block"),checked:e.showReviewRating,onChange:()=>t({showReviewRating:!e.showReviewRating})}),e.showReviewRating&&!c&&Object(o.createElement)(i.Notice,{className:"wc-block-base-control-notice",isDismissible:!1},Object(o.createInterpolateElement)(Object(n.__)("Product rating is disabled in your <a>store settings</a>.","woo-gutenberg-products-block"),{a:Object(o.createElement)("a",{href:Object(a.getAdminLink)("admin.php?page=wc-settings&tab=products"),target:"_blank",rel:"noopener noreferrer"})})),Object(o.createElement)(i.ToggleControl,{label:Object(n.__)("Reviewer name","woo-gutenberg-products-block"),checked:e.showReviewerName,onChange:()=>t({showReviewerName:!e.showReviewerName})}),Object(o.createElement)(i.ToggleControl,{label:Object(n.__)("Image","woo-gutenberg-products-block"),checked:e.showReviewImage,onChange:()=>t({showReviewImage:!e.showReviewImage})}),Object(o.createElement)(i.ToggleControl,{label:Object(n.__)("Review date","woo-gutenberg-products-block"),checked:e.showReviewDate,onChange:()=>t({showReviewDate:!e.showReviewDate})}),Object(o.createElement)(i.ToggleControl,{label:Object(n.__)("Review content","woo-gutenberg-products-block"),checked:e.showReviewContent,onChange:()=>t({showReviewContent:!e.showReviewContent})}),e.showReviewImage&&Object(o.createElement)(o.Fragment,null,Object(o.createElement)(i.__experimentalToggleGroupControl,{label:Object(n.__)("Review image","woo-gutenberg-products-block"),value:e.imageType,onChange:e=>t({imageType:e})},Object(o.createElement)(i.__experimentalToggleGroupControlOption,{value:"reviewer",label:Object(n.__)("Reviewer photo","woo-gutenberg-products-block")}),Object(o.createElement)(i.__experimentalToggleGroupControlOption,{value:"product",label:Object(n.__)("Product","woo-gutenberg-products-block")})),"reviewer"===e.imageType&&!r&&Object(o.createElement)(i.Notice,{className:"wc-block-base-control-notice",isDismissible:!1},Object(o.createInterpolateElement)(Object(n.__)("Reviewer photo is disabled in your <a>site settings</a>.","woo-gutenberg-products-block"),{a:Object(o.createElement)("a",{href:Object(a.getAdminLink)("options-discussion.php"),target:"_blank",rel:"noopener noreferrer"})}))))},d=(e,t)=>Object(o.createElement)(o.Fragment,null,Object(o.createElement)(i.ToggleControl,{label:Object(n.__)("Order by","woo-gutenberg-products-block"),checked:e.showOrderby,onChange:()=>t({showOrderby:!e.showOrderby})}),Object(o.createElement)(i.SelectControl,{label:Object(n.__)("Order Product Reviews by","woo-gutenberg-products-block"),value:e.orderby,options:[{label:"Most recent",value:"most-recent"},{label:"Highest Rating",value:"highest-rating"},{label:"Lowest Rating",value:"lowest-rating"}],onChange:e=>t({orderby:e})}),Object(o.createElement)(i.RangeControl,{label:Object(n.__)("Starting Number of Reviews","woo-gutenberg-products-block"),value:e.reviewsOnPageLoad,onChange:e=>t({reviewsOnPageLoad:e}),max:20,min:1}),Object(o.createElement)(i.ToggleControl,{label:Object(n.__)("Load more","woo-gutenberg-products-block"),checked:e.showLoadMore,onChange:()=>t({showLoadMore:!e.showLoadMore})}),e.showLoadMore&&Object(o.createElement)(i.RangeControl,{label:Object(n.__)("Load More Reviews","woo-gutenberg-products-block"),value:e.reviewsOnLoadMore,onChange:e=>t({reviewsOnLoadMore:e}),max:20,min:1}))},117:function(e,t){},12:function(e,t){e.exports=window.wp.primitives},120:function(e,t,r){"use strict";var o=r(0),n=r(4),c=r.n(n),a=r(28),i=r(11);r(164),t.a=Object(i.withInstanceId)(e=>{let{className:t,instanceId:r,label:n="",onChange:i,options:s,screenReaderLabel:l,value:d=""}=e;const u="wc-block-components-sort-select__select-"+r;return Object(o.createElement)("div",{className:c()("wc-block-sort-select","wc-block-components-sort-select",t)},Object(o.createElement)(a.a,{label:n,screenReaderLabel:l,wrapperElement:"label",wrapperProps:{className:"wc-block-sort-select__label wc-block-components-sort-select__label",htmlFor:u}}),Object(o.createElement)("select",{id:u,className:"wc-block-sort-select__select wc-block-components-sort-select__select",onChange:i,value:d},s&&s.map(e=>Object(o.createElement)("option",{key:e.key,value:e.key},e.label))))})},129:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var o=r(1),n=r(21);const c={attributes:{editMode:!1,imageType:"reviewer",orderby:"most-recent",reviewsOnLoadMore:10,reviewsOnPageLoad:10,showLoadMore:!0,showOrderby:!0,showReviewDate:!0,showReviewerName:!0,showReviewImage:!0,showReviewRating:!0,showReviewContent:!0,previewReviews:[{id:1,date_created:"2019-07-15T17:05:04",formatted_date_created:Object(o.__)("July 15, 2019","woo-gutenberg-products-block"),date_created_gmt:"2019-07-15T15:05:04",product_id:0,product_name:Object(o.__)("WordPress Pennant","woo-gutenberg-products-block"),product_permalink:"#",
|
2 |
/* translators: An example person name used for the block previews. */
|
3 |
reviewer:Object(o.__)("Alice","woo-gutenberg-products-block"),review:`<p>${Object(o.__)("I bought this product last week and I'm very happy with it.","woo-gutenberg-products-block")}</p>\n`,reviewer_avatar_urls:{48:n.o.defaultAvatar,96:n.o.defaultAvatar},rating:5,verified:!0},{id:2,date_created:"2019-07-12T12:39:39",formatted_date_created:Object(o.__)("July 12, 2019","woo-gutenberg-products-block"),date_created_gmt:"2019-07-12T10:39:39",product_id:0,product_name:Object(o.__)("WordPress Pennant","woo-gutenberg-products-block"),product_permalink:"#",
|
4 |
/* translators: An example person name used for the block previews. */
|
5 |
+
reviewer:Object(o.__)("Bob","woo-gutenberg-products-block"),review:`<p>${Object(o.__)("This product is awesome, I love it!","woo-gutenberg-products-block")}</p>\n`,reviewer_avatar_urls:{48:n.o.defaultAvatar,96:n.o.defaultAvatar},rating:null,verified:!1}]}}},13:function(e,t){e.exports=window.React},14:function(e,t){e.exports=window.wp.apiFetch},15:function(e,t){e.exports=window.wp.htmlEntities},152:function(e,t,r){"use strict";t.a={editMode:{type:"boolean",default:!0},imageType:{type:"string",default:"reviewer"},orderby:{type:"string",default:"most-recent"},reviewsOnLoadMore:{type:"number",default:10},reviewsOnPageLoad:{type:"number",default:10},showLoadMore:{type:"boolean",default:!0},showOrderby:{type:"boolean",default:!0},showReviewDate:{type:"boolean",default:!0},showReviewerName:{type:"boolean",default:!0},showReviewImage:{type:"boolean",default:!0},showReviewRating:{type:"boolean",default:!0},showReviewContent:{type:"boolean",default:!0},previewReviews:{type:"array",default:null}}},153:function(e,t,r){"use strict";var o=r(6),n=r.n(o),c=r(0),a=r(5),i=(r(163),r(57));t.a=e=>{let{attributes:t}=e;return Object(c.createElement)("div",n()({},a.useBlockProps.save({className:Object(i.a)(t)}),Object(i.b)(t)))}},156:function(e,t,r){"use strict";var o=r(0),n=r(1),c=r(8),a=r(3),i=r(5),s=r(13),l=r(2),d=r(73),u=r(28);r(191);var b=e=>{let{onClick:t,label:r=Object(n.__)("Load more","woo-gutenberg-products-block"),screenReaderLabel:c=Object(n.__)("Load more","woo-gutenberg-products-block")}=e;return Object(o.createElement)("div",{className:"wp-block-button wc-block-load-more wc-block-components-load-more"},Object(o.createElement)("button",{className:"wp-block-button__link",onClick:t},Object(o.createElement)(u.a,{label:r,screenReaderLabel:c})))},w=r(120);r(188);var p=e=>{let{onChange:t,readOnly:r,value:c}=e;return Object(o.createElement)(w.a,{className:"wc-block-review-sort-select wc-block-components-review-sort-select",label:Object(n.__)("Order by","woo-gutenberg-products-block"),onChange:t,options:[{key:"most-recent",label:Object(n.__)("Most recent","woo-gutenberg-products-block")},{key:"highest-rating",label:Object(n.__)("Highest rating","woo-gutenberg-products-block")},{key:"lowest-rating",label:Object(n.__)("Lowest rating","woo-gutenberg-products-block")}],readOnly:r,screenReaderLabel:Object(n.__)("Order reviews by","woo-gutenberg-products-block"),value:c})},m=r(4),g=r.n(m),v=r(24),h=r.n(v),_=r(177),O=r.n(_);const j=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"...";const o=O()(e,{suffix:r,limit:t});return o.html},f=(e,t,r)=>(t<=r?e.start=e.middle+1:e.end=e.middle-1,e),k=(e,t,r,o)=>{const n=((e,t,r)=>{let o={start:0,middle:0,end:e.length};for(;o.start<=o.end;)o.middle=Math.floor((o.start+o.end)/2),t.innerHTML=j(e,o.middle),o=f(o,t.clientHeight,r);return o.middle})(e,t,r);return j(e,n-o.length,o)},y={className:"read-more-content",ellipsis:"…",lessText:Object(n.__)("Read less","woo-gutenberg-products-block"),maxLines:3,moreText:Object(n.__)("Read more","woo-gutenberg-products-block")};class R extends s.Component{constructor(e){super(e),this.state={isExpanded:!1,clampEnabled:null,content:e.children,summary:"."},this.reviewContent=Object(s.createRef)(),this.reviewSummary=Object(s.createRef)(),this.getButton=this.getButton.bind(this),this.onClick=this.onClick.bind(this)}componentDidMount(){this.setSummary()}componentDidUpdate(e){e.maxLines===this.props.maxLines&&e.children===this.props.children||this.setState({clampEnabled:null,summary:"."},this.setSummary)}setSummary(){if(this.props.children){const{maxLines:e,ellipsis:t}=this.props;if(!this.reviewSummary.current||!this.reviewContent.current)return;const r=(this.reviewSummary.current.clientHeight+1)*e+1,o=this.reviewContent.current.clientHeight+1>r;this.setState({clampEnabled:o}),o&&this.setState({summary:k(this.reviewContent.current.innerHTML,this.reviewSummary.current,r,t)})}}getButton(){const{isExpanded:e}=this.state,{className:t,lessText:r,moreText:n}=this.props,c=e?r:n;if(c)return Object(o.createElement)("a",{href:"#more",className:t+"__read_more",onClick:this.onClick,"aria-expanded":!e,role:"button"},c)}onClick(e){e.preventDefault();const{isExpanded:t}=this.state;this.setState({isExpanded:!t})}render(){const{className:e}=this.props,{content:t,summary:r,clampEnabled:n,isExpanded:c}=this.state;return t?!1===n?Object(o.createElement)("div",{className:e},Object(o.createElement)("div",{ref:this.reviewContent},t)):Object(o.createElement)("div",{className:e},(!c||null===n)&&Object(o.createElement)("div",{ref:this.reviewSummary,"aria-hidden":c,dangerouslySetInnerHTML:{__html:r}}),(c||null===n)&&Object(o.createElement)("div",{ref:this.reviewContent,"aria-hidden":!c},t),this.getButton()):null}}h()(R,"defaultProps",y);var E=R;r(190);var S=e=>{let{attributes:t,review:r={}}=e;const{imageType:c,showReviewDate:a,showReviewerName:i,showReviewImage:s,showReviewRating:l,showReviewContent:d,showProductName:u}=t,{rating:b}=r,w=!Object.keys(r).length>0,p=Number.isFinite(b)&&l;return Object(o.createElement)("li",{className:g()("wc-block-review-list-item__item","wc-block-components-review-list-item__item",{"is-loading":w,"wc-block-components-review-list-item__item--has-image":s}),"aria-hidden":w},(u||a||i||s||p)&&Object(o.createElement)("div",{className:"wc-block-review-list-item__info wc-block-components-review-list-item__info"},s&&function(e,t,r){var c,a;return r||!e?Object(o.createElement)("div",{className:"wc-block-review-list-item__image wc-block-components-review-list-item__image"}):Object(o.createElement)("div",{className:"wc-block-review-list-item__image wc-block-components-review-list-item__image"},"product"===t?Object(o.createElement)("img",{"aria-hidden":"true",alt:(null===(c=e.product_image)||void 0===c?void 0:c.alt)||"",src:(null===(a=e.product_image)||void 0===a?void 0:a.thumbnail)||""}):Object(o.createElement)("img",{"aria-hidden":"true",alt:"",src:e.reviewer_avatar_urls[96]||""}),e.verified&&Object(o.createElement)("div",{className:"wc-block-review-list-item__verified wc-block-components-review-list-item__verified",title:Object(n.__)("Verified buyer","woo-gutenberg-products-block")},Object(n.__)("Verified buyer","woo-gutenberg-products-block")))}(r,c,w),(u||i||p||a)&&Object(o.createElement)("div",{className:"wc-block-review-list-item__meta wc-block-components-review-list-item__meta"},p&&function(e){const{rating:t}=e,r={width:t/5*100+"%"},c=Object(n.sprintf)(
|
6 |
/* translators: %f is referring to the average rating value */
|
7 |
Object(n.__)("Rated %f out of 5","woo-gutenberg-products-block"),t),a={__html:Object(n.sprintf)(
|
8 |
/* translators: %s is referring to the average rating value */
|
9 |
+
Object(n.__)("Rated %s out of 5","woo-gutenberg-products-block"),Object(n.sprintf)('<strong class="rating">%f</strong>',t))};return Object(o.createElement)("div",{className:"wc-block-review-list-item__rating wc-block-components-review-list-item__rating"},Object(o.createElement)("div",{className:"wc-block-review-list-item__rating__stars wc-block-components-review-list-item__rating__stars",role:"img","aria-label":c},Object(o.createElement)("span",{style:r,dangerouslySetInnerHTML:a})))}(r),u&&function(e){return Object(o.createElement)("div",{className:"wc-block-review-list-item__product wc-block-components-review-list-item__product"},Object(o.createElement)("a",{href:e.product_permalink,dangerouslySetInnerHTML:{__html:e.product_name}}))}(r),i&&function(e){const{reviewer:t=""}=e;return Object(o.createElement)("div",{className:"wc-block-review-list-item__author wc-block-components-review-list-item__author"},t)}(r),a&&function(e){const{date_created:t,formatted_date_created:r}=e;return Object(o.createElement)("time",{className:"wc-block-review-list-item__published-date wc-block-components-review-list-item__published-date",dateTime:t},r)}(r))),d&&function(e){return Object(o.createElement)(E,{maxLines:10,moreText:Object(n.__)("Read full review","woo-gutenberg-products-block"),lessText:Object(n.__)("Hide full review","woo-gutenberg-products-block"),className:"wc-block-review-list-item__text wc-block-components-review-list-item__text"},Object(o.createElement)("div",{dangerouslySetInnerHTML:{__html:e.review||""}}))}(r))};r(189);var C=e=>{let{attributes:t,reviews:r}=e;const n=Object(l.getSetting)("showAvatars",!0),c=Object(l.getSetting)("reviewRatingsEnabled",!0),a=(n||"product"===t.imageType)&&t.showReviewImage,i=c&&t.showReviewRating,s={...t,showReviewImage:a,showReviewRating:i};return Object(o.createElement)("ul",{className:"wc-block-review-list wc-block-components-review-list"},0===r.length?Object(o.createElement)(S,{attributes:s}):r.map((e,t)=>Object(o.createElement)(S,{key:e.id||t,attributes:s,review:e})))},T=r(6),P=r.n(T),N=r(25),L=r.n(N),x=r(57),A=r(29);class M extends s.Component{render(){const{attributes:e,error:t,isLoading:r,noReviewsPlaceholder:c,reviews:i,totalReviews:s}=this.props;if(t)return Object(o.createElement)(d.a,{className:"wc-block-featured-product-error",error:t,isLoading:r});if(0===i.length&&!r)return Object(o.createElement)(c,{attributes:e});const u=Object(l.getSetting)("reviewRatingsEnabled",!0);return Object(o.createElement)(a.Disabled,null,e.showOrderby&&u&&Object(o.createElement)(p,{readOnly:!0,value:e.orderby}),Object(o.createElement)(C,{attributes:e,reviews:i}),e.showLoadMore&&s>i.length&&Object(o.createElement)(b,{screenReaderLabel:Object(n.__)("Load more reviews","woo-gutenberg-products-block")}))}}var I=(e=>{class t extends s.Component{constructor(){super(...arguments),h()(this,"isPreview",!!this.props.attributes.previewReviews),h()(this,"delayedAppendReviews",this.props.delayFunction(this.appendReviews)),h()(this,"isMounted",!1),h()(this,"state",{error:null,loading:!0,reviews:this.isPreview?this.props.attributes.previewReviews:[],totalReviews:this.isPreview?this.props.attributes.previewReviews.length:0}),h()(this,"setError",async e=>{if(!this.isMounted)return;const{onReviewsLoadError:t}=this.props,r=await Object(A.a)(e);this.setState({reviews:[],loading:!1,error:r}),t(r)})}componentDidMount(){this.isMounted=!0,this.replaceReviews()}componentDidUpdate(e){e.reviewsToDisplay<this.props.reviewsToDisplay?this.delayedAppendReviews():this.shouldReplaceReviews(e,this.props)&&this.replaceReviews()}shouldReplaceReviews(e,t){return e.orderby!==t.orderby||e.order!==t.order||e.productId!==t.productId||!L()(e.categoryIds,t.categoryIds)}componentWillUnmount(){this.isMounted=!1,this.delayedAppendReviews.cancel&&this.delayedAppendReviews.cancel()}getArgs(e){const{categoryIds:t,order:r,orderby:o,productId:n,reviewsToDisplay:c}=this.props,a={order:r,orderby:o,per_page:c-e,offset:e};if(t){const e=Array.isArray(t)?t:JSON.parse(t);a.category_id=Array.isArray(e)?e.join(","):e}return n&&(a.product_id=n),a}replaceReviews(){if(this.isPreview)return;const{onReviewsReplaced:e}=this.props;this.updateListOfReviews().then(e)}appendReviews(){if(this.isPreview)return;const{onReviewsAppended:e,reviewsToDisplay:t}=this.props,{reviews:r}=this.state;t<=r.length||this.updateListOfReviews(r).then(e)}updateListOfReviews(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const{reviewsToDisplay:t}=this.props,{totalReviews:r}=this.state,o=Math.min(r,t)-e.length;return this.setState({loading:!0,reviews:e.concat(Array(o).fill({}))}),Object(x.c)(this.getArgs(e.length)).then(t=>{let{reviews:r,totalReviews:o}=t;return this.isMounted&&this.setState({reviews:e.filter(e=>Object.keys(e).length).concat(r),totalReviews:o,loading:!1,error:null}),{newReviews:r}}).catch(this.setError)}render(){const{reviewsToDisplay:t}=this.props,{error:r,loading:n,reviews:c,totalReviews:a}=this.state;return Object(o.createElement)(e,P()({},this.props,{error:r,isLoading:n,reviews:c.slice(0,t),totalReviews:a}))}}h()(t,"defaultProps",{delayFunction:e=>e,onReviewsAppended:()=>{},onReviewsLoadError:()=>{},onReviewsReplaced:()=>{}});const{displayName:r=e.name||"Component"}=e;return t.displayName=`WithReviews( ${r} )`,t})(M);t.a=e=>{let{attributes:t,icon:r,name:s,noReviewsPlaceholder:l}=e;const{categoryIds:d,productId:u,reviewsOnPageLoad:b,showProductName:w,showReviewDate:p,showReviewerName:m,showReviewContent:g,showReviewImage:v,showReviewRating:h}=t,{order:_,orderby:O}=Object(x.d)(t.orderby),j=!(g||h||p||m||v||w),f=Object(i.useBlockProps)({className:Object(x.a)(t)});return j?Object(o.createElement)(a.Placeholder,{icon:r,label:s},Object(n.__)("The content for this block is hidden due to block settings.","woo-gutenberg-products-block")):Object(o.createElement)("div",f,Object(o.createElement)(I,{attributes:t,categoryIds:d,delayFunction:e=>Object(c.debounce)(e,400),noReviewsPlaceholder:l,orderby:O,order:_,productId:u,reviewsToDisplay:b}))}},163:function(e,t){},164:function(e,t){},188:function(e,t){},189:function(e,t){},190:function(e,t){},191:function(e,t){},2:function(e,t){e.exports=window.wc.wcSettings},21:function(e,t,r){"use strict";r.d(t,"o",(function(){return c})),r.d(t,"m",(function(){return a})),r.d(t,"l",(function(){return i})),r.d(t,"n",(function(){return s})),r.d(t,"j",(function(){return l})),r.d(t,"e",(function(){return d})),r.d(t,"f",(function(){return u})),r.d(t,"g",(function(){return b})),r.d(t,"k",(function(){return w})),r.d(t,"c",(function(){return p})),r.d(t,"d",(function(){return m})),r.d(t,"h",(function(){return g})),r.d(t,"a",(function(){return v})),r.d(t,"i",(function(){return h})),r.d(t,"b",(function(){return _}));var o,n=r(2);const c=Object(n.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),a=c.pluginUrl+"images/",i=c.pluginUrl+"build/",s=c.buildPhase,l=null===(o=n.STORE_PAGES.shop)||void 0===o?void 0:o.permalink,d=n.STORE_PAGES.checkout.id,u=n.STORE_PAGES.checkout.permalink,b=n.STORE_PAGES.privacy.permalink,w=(n.STORE_PAGES.privacy.title,n.STORE_PAGES.terms.permalink),p=(n.STORE_PAGES.terms.title,n.STORE_PAGES.cart.id),m=n.STORE_PAGES.cart.permalink,g=(n.STORE_PAGES.myaccount.permalink?n.STORE_PAGES.myaccount.permalink:Object(n.getSetting)("wpLoginUrl","/wp-login.php"),Object(n.getSetting)("shippingCountries",{})),v=Object(n.getSetting)("allowedCountries",{}),h=Object(n.getSetting)("shippingStates",{}),_=Object(n.getSetting)("allowedStates",{})},25:function(e,t){e.exports=window.wp.isShallowEqual},28:function(e,t,r){"use strict";var o=r(0),n=r(4),c=r.n(n);t.a=e=>{let t,{label:r,screenReaderLabel:n,wrapperElement:a,wrapperProps:i={}}=e;const s=null!=r,l=null!=n;return!s&&l?(t=a||"span",i={...i,className:c()(i.className,"screen-reader-text")},Object(o.createElement)(t,i,n)):(t=a||o.Fragment,s&&l&&r!==n?Object(o.createElement)(t,i,Object(o.createElement)("span",{"aria-hidden":"true"},r),Object(o.createElement)("span",{className:"screen-reader-text"},n)):Object(o.createElement)(t,i,r))}},29:function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r.d(t,"b",(function(){return a}));var o=r(1),n=r(15);const c=async e=>{if("function"==typeof e.json)try{const t=await e.json();return{message:t.message,type:t.type||"api"}}catch(e){return{message:e.message,type:"general"}}return{message:e.message,type:e.type||"general"}},a=e=>{if(e.data&&"rest_invalid_param"===e.code){const t=Object.values(e.data.params);if(t[0])return t[0]}return null!=e&&e.message?Object(n.decodeEntities)(e.message):Object(o.__)("Something went wrong. Please contact us to get assistance.","woo-gutenberg-products-block")}},3:function(e,t){e.exports=window.wp.components},33:function(e,t,r){"use strict";var o=r(0),n=r(1),c=r(34);t.a=e=>{let{error:t}=e;return Object(o.createElement)("div",{className:"wc-block-error-message"},(e=>{let{message:t,type:r}=e;return t?"general"===r?Object(o.createElement)("span",null,Object(n.__)("The following error was returned","woo-gutenberg-products-block"),Object(o.createElement)("br",null),Object(o.createElement)("code",null,Object(c.escapeHTML)(t))):"api"===r?Object(o.createElement)("span",null,Object(n.__)("The following error was returned from the API","woo-gutenberg-products-block"),Object(o.createElement)("br",null),Object(o.createElement)("code",null,Object(c.escapeHTML)(t))):t:Object(n.__)("An error has prevented the block from being updated.","woo-gutenberg-products-block")})(t))}},34:function(e,t){e.exports=window.wp.escapeHtml},373:function(e,t,r){e.exports=r(492)},492:function(e,t,r){"use strict";r.r(t);var o=r(0),n=r(1),c=r(9),a=r(116),i=r(523),s=(r(163),r(5)),l=r(3),d=r(156),u=()=>Object(o.createElement)(l.Placeholder,{className:"wc-block-all-reviews",icon:Object(o.createElement)(a.a,{icon:i.a,className:"block-editor-block-icon"}),label:Object(n.__)("All Reviews","woo-gutenberg-products-block")},Object(n.__)("This block shows a list of all product reviews. Your store does not have any reviews yet, but they will show up here when it does.","woo-gutenberg-products-block")),b=r(110),w=r(152),p=r(153),m=r(129);Object(c.registerBlockType)("woocommerce/all-reviews",{apiVersion:2,title:Object(n.__)("All Reviews","woo-gutenberg-products-block"),icon:{src:Object(o.createElement)(a.a,{icon:i.a,className:"wc-block-editor-components-block-icon"})},category:"woocommerce",keywords:[Object(n.__)("WooCommerce","woo-gutenberg-products-block")],description:Object(n.__)("Show a list of all product reviews.","woo-gutenberg-products-block"),supports:{html:!1,color:{background:!1},typography:{fontSize:!0}},example:{...m.a,attributes:{...m.a.attributes,showProductName:!0}},attributes:{...w.a,showProductName:{type:"boolean",default:!0}},transforms:{from:[{type:"block",blocks:["core/legacy-widget"],isMatch:e=>{let{idBase:t,instance:r}=e;return"woocommerce_recent_reviews"===t&&!(null==r||!r.raw)},transform:e=>{let{instance:t}=e;return Object(c.createBlock)("woocommerce/all-reviews",{reviewsOnPageLoad:t.raw.number,imageType:"product",showLoadMore:!1,showOrderby:!1,showReviewDate:!1,showReviewContent:!1})}}]},edit:e=>{let{attributes:t,setAttributes:r}=e;return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(s.InspectorControls,{key:"inspector"},Object(o.createElement)(l.PanelBody,{title:Object(n.__)("Content","woo-gutenberg-products-block")},Object(o.createElement)(l.ToggleControl,{label:Object(n.__)("Product name","woo-gutenberg-products-block"),checked:t.showProductName,onChange:()=>r({showProductName:!t.showProductName})}),Object(b.b)(t,r)),Object(o.createElement)(l.PanelBody,{title:Object(n.__)("List Settings","woo-gutenberg-products-block")},Object(b.c)(t,r))),Object(o.createElement)(d.a,{attributes:t,icon:Object(o.createElement)(a.a,{icon:i.a,className:"block-editor-block-icon"}),name:Object(n.__)("All Reviews","woo-gutenberg-products-block"),noReviewsPlaceholder:u}))},save:p.a})},5:function(e,t){e.exports=window.wp.blockEditor},57:function(e,t,r){"use strict";r.d(t,"d",(function(){return s})),r.d(t,"c",(function(){return l})),r.d(t,"a",(function(){return d})),r.d(t,"b",(function(){return u}));var o=r(14),n=r.n(o),c=r(4),a=r.n(c),i=r(2);const s=e=>{if(Object(i.getSetting)("reviewRatingsEnabled",!0)){if("lowest-rating"===e)return{order:"asc",orderby:"rating"};if("highest-rating"===e)return{order:"desc",orderby:"rating"}}return{order:"desc",orderby:"date_gmt"}},l=e=>n()({path:"/wc/store/v1/products/reviews?"+Object.entries(e).map(e=>e.join("=")).join("&"),parse:!1}).then(e=>e.json().then(t=>({reviews:t,totalReviews:parseInt(e.headers.get("x-wp-total"),10)}))),d=e=>{const{className:t,categoryIds:r,productId:o,showReviewDate:n,showReviewerName:c,showReviewContent:i,showProductName:s,showReviewImage:l,showReviewRating:d}=e;let u="wc-block-all-reviews";return o&&(u="wc-block-reviews-by-product"),Array.isArray(r)&&(u="wc-block-reviews-by-category"),a()(u,t,{"has-image":l,"has-name":c,"has-date":n,"has-rating":d,"has-content":i,"has-product-name":s})},u=e=>{const{categoryIds:t,imageType:r,orderby:o,productId:n,reviewsOnPageLoad:c,reviewsOnLoadMore:a,showLoadMore:i,showOrderby:s}=e,l={"data-image-type":r,"data-orderby":o,"data-reviews-on-page-load":c,"data-reviews-on-load-more":a,"data-show-load-more":i,"data-show-orderby":s};return n&&(l["data-product-id"]=n),Array.isArray(t)&&(l["data-category-ids"]=t.join(",")),l}},73:function(e,t,r){"use strict";var o=r(0),n=r(1),c=r(116),a=r(183),i=r(4),s=r.n(i),l=r(3),d=r(33);r(117),t.a=e=>{let{className:t,error:r,isLoading:i=!1,onRetry:u}=e;return Object(o.createElement)(l.Placeholder,{icon:Object(o.createElement)(c.a,{icon:a.a}),label:Object(n.__)("Sorry, an error occurred","woo-gutenberg-products-block"),className:s()("wc-block-api-error",t)},Object(o.createElement)(d.a,{error:r}),u&&Object(o.createElement)(o.Fragment,null,i?Object(o.createElement)(l.Spinner,null):Object(o.createElement)(l.Button,{isSecondary:!0,onClick:u},Object(n.__)("Retry","woo-gutenberg-products-block"))))}},8:function(e,t){e.exports=window.lodash},9:function(e,t){e.exports=window.wp.blocks}});
|
build/attribute-filter-frontend.asset.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php return array('dependencies' => array('lodash', 'react', 'wc-blocks-checkout', 'wc-blocks-data-store', 'wc-settings', 'wp-a11y', 'wp-block-editor', 'wp-blocks', 'wp-compose', 'wp-data', 'wp-deprecated', 'wp-dom', 'wp-element', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-keycodes', 'wp-polyfill', 'wp-primitives', 'wp-url', 'wp-warning'), 'version' => '
|
1 |
+
<?php return array('dependencies' => array('lodash', 'react', 'wc-blocks-checkout', 'wc-blocks-data-store', 'wc-settings', 'wp-a11y', 'wp-block-editor', 'wp-blocks', 'wp-compose', 'wp-data', 'wp-deprecated', 'wp-dom', 'wp-element', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-keycodes', 'wp-polyfill', 'wp-primitives', 'wp-url', 'wp-warning'), 'version' => 'd2a8a3052314bf971bd6175304aa1a32');
|
build/attribute-filter-frontend.js
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
-
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=247)}([function(e,t){e.exports=window.wp.element},function(e,t){e.exports=window.wp.i18n},function(e,t){e.exports=window.wc.wcSettings},function(e,t){e.exports=window.wc.wcBlocksData},function(e,t,n){var r;!function(){"use strict";var n={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var s=typeof r;if("string"===s||"number"===s)e.push(r);else if(Array.isArray(r)){if(r.length){var i=o.apply(null,r);i&&e.push(i)}}else if("object"===s)if(r.toString===Object.prototype.toString)for(var c in r)n.call(r,c)&&r[c]&&e.push(c);else e.push(r.toString())}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(r=function(){return o}.apply(t,[]))||(e.exports=r)}()},function(e,t){e.exports=window.lodash},function(e,t){e.exports=window.wp.data},,function(e,t){e.exports=window.React},function(e,t,n){"use strict";function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}n.d(t,"a",(function(){return r}))},function(e,t){e.exports=window.wc.blocksCheckout},function(e,t){e.exports=window.wp.compose},function(e,t){function n(){return e.exports=n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},e.exports.__esModule=!0,e.exports.default=e.exports,n.apply(this,arguments)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=window.wp.isShallowEqual},function(e,t){e.exports=window.wp.url},function(e,t){e.exports=window.wp.primitives},function(e,t,n){"use strict";var r=n(17),o=n.n(r),s=n(0),i=n(8),c=n(1),a=n(46),l=e=>{let{imageUrl:t=a.l+"/block-error.svg",header:n=Object(c.__)("Oops!","woo-gutenberg-products-block"),text:r=Object(c.__)("There was an error loading the content.","woo-gutenberg-products-block"),errorMessage:o,errorMessagePrefix:i=Object(c.__)("Error:","woo-gutenberg-products-block"),button:l,showErrorBlock:u=!0}=e;return u?Object(s.createElement)("div",{className:"wc-block-error wc-block-components-error"},t&&Object(s.createElement)("img",{className:"wc-block-error__image wc-block-components-error__image",src:t,alt:""}),Object(s.createElement)("div",{className:"wc-block-error__content wc-block-components-error__content"},n&&Object(s.createElement)("p",{className:"wc-block-error__header wc-block-components-error__header"},n),r&&Object(s.createElement)("p",{className:"wc-block-error__text wc-block-components-error__text"},r),o&&Object(s.createElement)("p",{className:"wc-block-error__message wc-block-components-error__message"},i?i+" ":"",o),l&&Object(s.createElement)("p",{className:"wc-block-error__button wc-block-components-error__button"},l))):null};n(35);class u extends i.Component{constructor(){super(...arguments),o()(this,"state",{errorMessage:"",hasError:!1})}static getDerivedStateFromError(e){return void 0!==e.statusText&&void 0!==e.status?{errorMessage:Object(s.createElement)(s.Fragment,null,Object(s.createElement)("strong",null,e.status),": ",e.statusText),hasError:!0}:{errorMessage:e.message,hasError:!0}}render(){const{header:e,imageUrl:t,showErrorMessage:n=!0,showErrorBlock:r=!0,text:o,errorMessagePrefix:i,renderError:c,button:a}=this.props,{errorMessage:u,hasError:d}=this.state;return d?"function"==typeof c?c({errorMessage:u}):Object(s.createElement)(l,{showErrorBlock:r,errorMessage:n?u:null,header:e,imageUrl:t,text:o,errorMessagePrefix:i,button:a}):this.props.children}}t.a=u},function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports},,function(e,t,n){"use strict";var r=n(0),o=n(4),s=n.n(o);t.a=e=>{let t,{label:n,screenReaderLabel:o,wrapperElement:i,wrapperProps:c={}}=e;const a=null!=n,l=null!=o;return!a&&l?(t=i||"span",c={...c,className:s()(c.className,"screen-reader-text")},Object(r.createElement)(t,c,o)):(t=i||r.Fragment,a&&l&&n!==o?Object(r.createElement)(t,c,Object(r.createElement)("span",{"aria-hidden":"true"},n),Object(r.createElement)("span",{className:"screen-reader-text"},o)):Object(r.createElement)(t,c,n))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return o}));const r=e=>!(e=>null===e)(e)&&e instanceof Object&&e.constructor===Object;function o(e,t){return r(e)&&t in e}},function(e,t){e.exports=window.wp.deprecated},,function(e,t){e.exports=window.wp.htmlEntities},function(e,t){e.exports=window.wp.a11y},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(0);const o=Object(r.createContext)("page"),s=()=>Object(r.useContext)(o);o.Provider},function(e,t,n){"use strict";(function(e){var r=n(0);n(39);const o=Object(r.createContext)({slots:{},fills:{},registerSlot:()=>{void 0!==e&&e.env},updateSlot:()=>{},unregisterSlot:()=>{},registerFill:()=>{},unregisterFill:()=>{}});t.a=o}).call(this,n(66))},,,function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(0),o=n(13),s=n.n(o);function i(e){const t=Object(r.useRef)(e);return s()(e,t.current)||(t.current=e),t.current}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));const r=e=>"string"==typeof e},function(e,t,n){"use strict";n.d(t,"a",(function(){return d})),n.d(t,"b",(function(){return p})),n.d(t,"c",(function(){return f}));var r=n(3),o=n(6),s=n(0),i=n(13),c=n.n(i),a=n(29),l=n(62),u=n(25);const d=e=>{const t=Object(u.a)();e=e||t;const n=Object(o.useSelect)(t=>t(r.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0),[e]),{setValueForQueryContext:i}=Object(o.useDispatch)(r.QUERY_STATE_STORE_KEY);return[n,Object(s.useCallback)(t=>{i(e,t)},[e,i])]},p=(e,t,n)=>{const i=Object(u.a)();n=n||i;const c=Object(o.useSelect)(o=>o(r.QUERY_STATE_STORE_KEY).getValueForQueryKey(n,e,t),[n,e]),{setQueryValue:a}=Object(o.useDispatch)(r.QUERY_STATE_STORE_KEY);return[c,Object(s.useCallback)(t=>{a(n,e,t)},[n,e,a])]},f=(e,t)=>{const n=Object(u.a)();t=t||n;const[r,o]=d(t),i=Object(a.a)(r),p=Object(a.a)(e),f=Object(l.a)(p),b=Object(s.useRef)(!1);return Object(s.useEffect)(()=>{c()(f,p)||(o(Object.assign({},i,p)),b.current=!0)},[i,p,f,o]),b.current?[r,o]:[e,o]}},,,,function(e,t){},,function(e,t,n){"use strict";var r=n(4),o=n.n(r),s=n(0);t.a=Object(s.forwardRef)((function({as:e="div",className:t,...n},r){return function({as:e="div",...t}){return"function"==typeof t.children?t.children(t):Object(s.createElement)(e,t)}({as:e,className:o()("components-visually-hidden",t),...n,ref:r})}))},,function(e,t){e.exports=window.wp.warning},,function(e,t,n){"use strict";var r=n(9),o=n(0),s=n(15),i=function({icon:e,className:t,...n}){const s=["dashicon","dashicons","dashicons-"+e,t].filter(Boolean).join(" ");return Object(o.createElement)("span",Object(r.a)({className:s},n))};t.a=function({icon:e=null,size:t=24,...n}){if("string"==typeof e)return Object(o.createElement)(i,Object(r.a)({icon:e},n));if(Object(o.isValidElement)(e)&&i===e.type)return Object(o.cloneElement)(e,{...n});if("function"==typeof e)return e.prototype instanceof o.Component?Object(o.createElement)(e,{size:t,...n}):e({size:t,...n});if(e&&("svg"===e.type||e.type===s.SVG)){const r={width:t,height:t,...e.props,...n};return Object(o.createElement)(s.SVG,r)}return Object(o.isValidElement)(e)?Object(o.cloneElement)(e,{size:t,...n}):e}},,,function(e,t,n){"use strict";var r=n(9),o=n(0),s=n(4),i=n.n(s),c=n(5),a=n(21),l=n.n(a),u=n(11),d=n(47),p=n(92),f=n(1);function b(e,t,n){const{defaultView:r}=t,{frameElement:o}=r;if(!o||t===n.ownerDocument)return e;const s=o.getBoundingClientRect();return new r.DOMRect(e.left+s.left,e.top+s.top,e.width,e.height)}let m=0;function h(e){const t=document.scrollingElement||document.body;e&&(m=t.scrollTop);const n=e?"add":"remove";t.classList[n]("lockscroll"),document.documentElement.classList[n]("lockscroll"),e||(t.scrollTop=m)}let g=0;function O(){return Object(o.useEffect)(()=>(0===g&&h(!0),++g,()=>{1===g&&h(!1),--g}),[]),null}var v=n(26);function j(e){const t=Object(o.useContext)(v.a),n=t.slots[e]||{},r=t.fills[e],s=Object(o.useMemo)(()=>r||[],[r]);return{...n,updateSlot:Object(o.useCallback)(n=>{t.updateSlot(e,n)},[e,t.updateSlot]),unregisterSlot:Object(o.useCallback)(n=>{t.unregisterSlot(e,n)},[e,t.unregisterSlot]),fills:s,registerFill:Object(o.useCallback)(n=>{t.registerFill(e,n)},[e,t.registerFill]),unregisterFill:Object(o.useCallback)(n=>{t.unregisterFill(e,n)},[e,t.unregisterFill])}}var w=Object(o.createContext)({registerSlot:()=>{},unregisterSlot:()=>{},registerFill:()=>{},unregisterFill:()=>{},getSlot:()=>{},getFills:()=>{},subscribe:()=>{}});function y({name:e,children:t,registerFill:n,unregisterFill:r}){const s=(e=>{const{getSlot:t,subscribe:n}=Object(o.useContext)(w),[r,s]=Object(o.useState)(t(e));return Object(o.useEffect)(()=>(s(t(e)),n(()=>{s(t(e))})),[e]),r})(e),i=Object(o.useRef)({name:e,children:t});return Object(o.useLayoutEffect)(()=>(n(e,i.current),()=>r(e,i.current)),[]),Object(o.useLayoutEffect)(()=>{i.current.children=t,s&&s.forceUpdate()},[t]),Object(o.useLayoutEffect)(()=>{e!==i.current.name&&(r(i.current.name,i.current),i.current.name=e,n(e,i.current))},[e]),s&&s.node?(Object(c.isFunction)(t)&&(t=t(s.props.fillProps)),Object(o.createPortal)(t,s.node)):null}var E=e=>Object(o.createElement)(w.Consumer,null,({registerFill:t,unregisterFill:n})=>Object(o.createElement)(y,Object(r.a)({},e,{registerFill:t,unregisterFill:n})));class k extends o.Component{constructor(){super(...arguments),this.isUnmounted=!1,this.bindNode=this.bindNode.bind(this)}componentDidMount(){const{registerSlot:e}=this.props;e(this.props.name,this)}componentWillUnmount(){const{unregisterSlot:e}=this.props;this.isUnmounted=!0,e(this.props.name,this)}componentDidUpdate(e){const{name:t,unregisterSlot:n,registerSlot:r}=this.props;e.name!==t&&(n(e.name),r(t,this))}bindNode(e){this.node=e}forceUpdate(){this.isUnmounted||super.forceUpdate()}render(){const{children:e,name:t,fillProps:n={},getFills:r}=this.props,s=Object(c.map)(r(t,this),e=>{const t=Object(c.isFunction)(e.children)?e.children(n):e.children;return o.Children.map(t,(e,t)=>{if(!e||Object(c.isString)(e))return e;const n=e.key||t;return Object(o.cloneElement)(e,{key:n})})}).filter(Object(c.negate)(o.isEmptyElement));return Object(o.createElement)(o.Fragment,null,Object(c.isFunction)(e)?e(s):s)}}var _=e=>Object(o.createElement)(w.Consumer,null,({registerSlot:t,unregisterSlot:n,getFills:s})=>Object(o.createElement)(k,Object(r.a)({},e,{registerSlot:t,unregisterSlot:n,getFills:s})));function S(){const[,e]=Object(o.useState)({}),t=Object(o.useRef)(!0);return Object(o.useEffect)(()=>()=>{t.current=!1},[]),()=>{t.current&&e({})}}function x({name:e,children:t}){const n=j(e),r=Object(o.useRef)({rerender:S()});return Object(o.useEffect)(()=>(n.registerFill(r),()=>{n.unregisterFill(r)}),[n.registerFill,n.unregisterFill]),n.ref&&n.ref.current?("function"==typeof t&&(t=t(n.fillProps)),Object(o.createPortal)(t,n.ref.current)):null}var T=Object(o.forwardRef)((function({name:e,fillProps:t={},as:n="div",...s},i){const c=Object(o.useContext)(v.a),a=Object(o.useRef)();return Object(o.useLayoutEffect)(()=>(c.registerSlot(e,a,t),()=>{c.unregisterSlot(e,a)}),[c.registerSlot,c.unregisterSlot,e]),Object(o.useLayoutEffect)(()=>{c.updateSlot(e,t)}),Object(o.createElement)(n,Object(r.a)({ref:Object(u.useMergeRefs)([i,a])},s))}));function C(e){return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(E,e),Object(o.createElement)(x,e))}n(13),o.Component;const L=Object(o.forwardRef)(({bubblesVirtually:e,...t},n)=>e?Object(o.createElement)(T,Object(r.a)({},t,{ref:n})):Object(o.createElement)(_,t));function I(e){return"appear"===e?"top":"left"}function A(e,t){const{paddingTop:n,paddingBottom:r,paddingLeft:o,paddingRight:s}=(i=t).ownerDocument.defaultView.getComputedStyle(i);var i;const c=n?parseInt(n,10):0,a=r?parseInt(r,10):0,l=o?parseInt(o,10):0,u=s?parseInt(s,10):0;return{x:e.left+l,y:e.top+c,width:e.width-l-u,height:e.height-c-a,left:e.left+l,right:e.right-u,top:e.top+c,bottom:e.bottom-a}}function R(e,t,n){n?e.getAttribute(t)!==n&&e.setAttribute(t,n):e.hasAttribute(t)&&e.removeAttribute(t)}function F(e,t,n=""){e.style[t]!==n&&(e.style[t]=n)}function P(e,t,n){n?e.classList.contains(t)||e.classList.add(t):e.classList.contains(t)&&e.classList.remove(t)}const N=Object(o.forwardRef)(({headerTitle:e,onClose:t,children:n,className:s,noArrow:c=!0,isAlternate:a,position:m="bottom right",range:h,focusOnMount:g="firstElement",anchorRef:v,shouldAnchorIncludePadding:w,anchorRect:y,getAnchorRect:E,expandOnMobile:k,animate:_=!0,onClickOutside:S,onFocusOutside:x,__unstableStickyBoundaryElement:T,__unstableSlotName:L="Popover",__unstableObserveElement:N,__unstableBoundaryParent:M,__unstableForcePosition:B,__unstableForceXAlignment:D,...V},W)=>{const H=Object(o.useRef)(null),q=Object(o.useRef)(null),z=Object(o.useRef)(),K=Object(u.useViewportMatch)("medium","<"),[U,$]=Object(o.useState)(),Q=j(L),Y=k&&K,[J,X]=Object(u.useResizeObserver)();c=Y||c,Object(o.useLayoutEffect)(()=>{if(Y)return P(z.current,"is-without-arrow",c),P(z.current,"is-alternate",a),R(z.current,"data-x-axis"),R(z.current,"data-y-axis"),F(z.current,"top"),F(z.current,"left"),F(q.current,"maxHeight"),void F(q.current,"maxWidth");const e=()=>{if(!z.current||!q.current)return;let e=function(e,t,n,r=!1,o,s){if(t)return t;if(n){if(!e.current)return;const t=n(e.current);return b(t,t.ownerDocument||e.current.ownerDocument,s)}if(!1!==r){if(!(r&&window.Range&&window.Element&&window.DOMRect))return;if("function"==typeof(null==r?void 0:r.cloneRange))return b(Object(d.getRectangleFromRange)(r),r.endContainer.ownerDocument,s);if("function"==typeof(null==r?void 0:r.getBoundingClientRect)){const e=b(r.getBoundingClientRect(),r.ownerDocument,s);return o?e:A(e,r)}const{top:e,bottom:t}=r,n=e.getBoundingClientRect(),i=t.getBoundingClientRect(),c=b(new window.DOMRect(n.left,n.top,n.width,i.bottom-n.top),e.ownerDocument,s);return o?c:A(c,r)}if(!e.current)return;const{parentNode:i}=e.current,c=i.getBoundingClientRect();return o?c:A(c,i)}(H,y,E,v,w,z.current);if(!e)return;const{offsetParent:t,ownerDocument:n}=z.current;let r,o=0;if(t&&t!==n.body){const n=t.getBoundingClientRect();o=n.top,e=new window.DOMRect(e.left-n.left,e.top-n.top,e.width,e.height)}var s;M&&(r=null===(s=z.current.closest(".popover-slot"))||void 0===s?void 0:s.parentNode);const i=X.height?X:q.current.getBoundingClientRect(),{popoverTop:l,popoverLeft:u,xAxis:p,yAxis:h,contentHeight:g,contentWidth:O}=function(e,t,n="top",r,o,s,i,c,a){const[l,u="center",d]=n.split(" "),p=function(e,t,n,r,o,s,i,c){const{height:a}=t;if(o){const t=o.getBoundingClientRect().top+a-i;if(e.top<=t)return{yAxis:n,popoverTop:Math.min(e.bottom,t)}}let l=e.top+e.height/2;"bottom"===r?l=e.bottom:"top"===r&&(l=e.top);const u={popoverTop:l,contentHeight:(l-a/2>0?a/2:l)+(l+a/2>window.innerHeight?window.innerHeight-l:a/2)},d={popoverTop:e.top,contentHeight:e.top-10-a>0?a:e.top-10},p={popoverTop:e.bottom,contentHeight:e.bottom+10+a>window.innerHeight?window.innerHeight-10-e.bottom:a};let f,b=n,m=null;if(!o&&!c)if("middle"===n&&u.contentHeight===a)b="middle";else if("top"===n&&d.contentHeight===a)b="top";else if("bottom"===n&&p.contentHeight===a)b="bottom";else{b=d.contentHeight>p.contentHeight?"top":"bottom";const e="top"===b?d.contentHeight:p.contentHeight;m=e!==a?e:null}return f="middle"===b?u.popoverTop:"top"===b?d.popoverTop:p.popoverTop,{yAxis:b,popoverTop:f,contentHeight:m}}(e,t,l,d,r,0,s,c);return{...function(e,t,n,r,o,s,i,c,a){const{width:l}=t;"left"===n&&Object(f.isRTL)()?n="right":"right"===n&&Object(f.isRTL)()&&(n="left"),"left"===r&&Object(f.isRTL)()?r="right":"right"===r&&Object(f.isRTL)()&&(r="left");const u=Math.round(e.left+e.width/2),d={popoverLeft:u,contentWidth:(u-l/2>0?l/2:u)+(u+l/2>window.innerWidth?window.innerWidth-u:l/2)};let p=e.left;"right"===r?p=e.right:"middle"===s||a||(p=u);let b=e.right;"left"===r?b=e.left:"middle"===s||a||(b=u);const m={popoverLeft:p,contentWidth:p-l>0?l:p},h={popoverLeft:b,contentWidth:b+l>window.innerWidth?window.innerWidth-b:l};let g,O=n,v=null;if(!o&&!c)if("center"===n&&d.contentWidth===l)O="center";else if("left"===n&&m.contentWidth===l)O="left";else if("right"===n&&h.contentWidth===l)O="right";else{O=m.contentWidth>h.contentWidth?"left":"right";const e="left"===O?m.contentWidth:h.contentWidth;l>window.innerWidth&&(v=window.innerWidth),e!==l&&(O="center",d.popoverLeft=window.innerWidth/2)}if(g="center"===O?d.popoverLeft:"left"===O?m.popoverLeft:h.popoverLeft,i){const e=i.getBoundingClientRect();g=Math.min(g,e.right-l),Object(f.isRTL)()||(g=Math.max(g,0))}return{xAxis:O,popoverLeft:g,contentWidth:v}}(e,t,u,d,r,p.yAxis,i,c,a),...p}}(e,i,m,T,z.current,o,r,B,D);"number"==typeof l&&"number"==typeof u&&(F(z.current,"top",l+"px"),F(z.current,"left",u+"px")),P(z.current,"is-without-arrow",c||"center"===p&&"middle"===h),P(z.current,"is-alternate",a),R(z.current,"data-x-axis",p),R(z.current,"data-y-axis",h),F(q.current,"maxHeight","number"==typeof g?g+"px":""),F(q.current,"maxWidth","number"==typeof O?O+"px":""),$(({left:"right",right:"left"}[p]||"center")+" "+({top:"bottom",bottom:"top"}[h]||"middle"))};e();const{ownerDocument:t}=z.current,{defaultView:n}=t,r=n.setInterval(e,500);let o;const s=()=>{n.cancelAnimationFrame(o),o=n.requestAnimationFrame(e)};n.addEventListener("click",s),n.addEventListener("resize",e),n.addEventListener("scroll",e,!0);const i=function(e){if(e)return e.endContainer?e.endContainer.ownerDocument:e.top?e.top.ownerDocument:e.ownerDocument}(v);let l;return i&&i!==t&&(i.defaultView.addEventListener("resize",e),i.defaultView.addEventListener("scroll",e,!0)),N&&(l=new n.MutationObserver(e),l.observe(N,{attributes:!0})),()=>{n.clearInterval(r),n.removeEventListener("resize",e),n.removeEventListener("scroll",e,!0),n.removeEventListener("click",s),n.cancelAnimationFrame(o),i&&i!==t&&(i.defaultView.removeEventListener("resize",e),i.defaultView.removeEventListener("scroll",e,!0)),l&&l.disconnect()}},[Y,y,E,v,w,m,X,T,N,M]);const Z=(e,n)=>{if("focus-outside"===e&&x)x(n);else if("focus-outside"===e&&S){const e=new window.MouseEvent("click");Object.defineProperty(e,"target",{get:()=>n.relatedTarget}),l()("Popover onClickOutside prop",{since:"5.3",alternative:"onFocusOutside"}),S(e)}else t&&t()},[ee,te]=Object(u.__experimentalUseDialog)({focusOnMount:g,__unstableOnClose:Z,onClose:Z}),ne=Object(u.useMergeRefs)([z,ee,W]),re=Boolean(_&&U)&&function(e){if("loading"===e.type)return i()("components-animate__loading");const{type:t,origin:n=I(t)}=e;if("appear"===t){const[e,t="center"]=n.split(" ");return i()("components-animate__appear",{["is-from-"+t]:"center"!==t,["is-from-"+e]:"middle"!==e})}return"slide-in"===t?i()("components-animate__slide-in","is-from-"+n):void 0}({type:"appear",origin:U});let oe=Object(o.createElement)("div",Object(r.a)({className:i()("components-popover",s,re,{"is-expanded":Y,"is-without-arrow":c,"is-alternate":a})},V,{ref:ne},te,{tabIndex:"-1"}),Y&&Object(o.createElement)(O,null),Y&&Object(o.createElement)("div",{className:"components-popover__header"},Object(o.createElement)("span",{className:"components-popover__header-title"},e),Object(o.createElement)(G,{className:"components-popover__close",icon:p.a,onClick:t})),Object(o.createElement)("div",{ref:q,className:"components-popover__content"},Object(o.createElement)("div",{style:{position:"relative"}},J,n)));return Q.ref&&(oe=Object(o.createElement)(C,{name:L},oe)),v||y?oe:Object(o.createElement)("span",{ref:H},oe)});N.Slot=Object(o.forwardRef)((function({name:e="Popover"},t){return Object(o.createElement)(L,{bubblesVirtually:!0,name:e,className:"popover-slot",ref:t})}));var M=N,B=function({shortcut:e,className:t}){if(!e)return null;let n,r;return Object(c.isString)(e)&&(n=e),Object(c.isObject)(e)&&(n=e.display,r=e.ariaLabel),Object(o.createElement)("span",{className:t,"aria-label":r},n)};const D=Object(o.createElement)("div",{className:"event-catcher"}),V=({eventHandlers:e,child:t,childrenWithPopover:n})=>Object(o.cloneElement)(Object(o.createElement)("span",{className:"disabled-element-wrapper"},Object(o.cloneElement)(D,e),Object(o.cloneElement)(t,{children:n}),","),e),W=({child:e,eventHandlers:t,childrenWithPopover:n})=>Object(o.cloneElement)(e,{...t,children:n}),H=(e,t,n)=>{if(1!==o.Children.count(e))return;const r=o.Children.only(e);"function"==typeof r.props[t]&&r.props[t](n)};var q=function({children:e,position:t,text:n,shortcut:r}){const[s,i]=Object(o.useState)(!1),[a,l]=Object(o.useState)(!1),d=Object(u.useDebounce)(l,700),p=t=>{H(e,"onMouseDown",t),document.addEventListener("mouseup",m),i(!0)},f=t=>{H(e,"onMouseUp",t),document.removeEventListener("mouseup",m),i(!1)},b=e=>"mouseUp"===e?f:"mouseDown"===e?p:void 0,m=b("mouseUp"),h=(t,n)=>r=>{if(H(e,t,r),r.currentTarget.disabled)return;if("focus"===r.type&&s)return;d.cancel();const o=Object(c.includes)(["focus","mouseenter"],r.type);o!==a&&(n?d(o):l(o))},g=()=>{d.cancel(),document.removeEventListener("mouseup",m)};if(Object(o.useEffect)(()=>g,[]),1!==o.Children.count(e))return e;const O={onMouseEnter:h("onMouseEnter",!0),onMouseLeave:h("onMouseLeave"),onClick:h("onClick"),onFocus:h("onFocus"),onBlur:h("onBlur"),onMouseDown:b("mouseDown")},v=o.Children.only(e),{children:j,disabled:w}=v.props;return(w?V:W)({child:v,eventHandlers:O,childrenWithPopover:(({grandchildren:e,isOver:t,position:n,text:r,shortcut:s})=>Object(o.concatChildren)(e,t&&Object(o.createElement)(M,{focusOnMount:!1,position:n,className:"components-tooltip","aria-hidden":"true",animate:!1,noArrow:!0},r,Object(o.createElement)(B,{className:"components-tooltip__shortcut",shortcut:s}))))({grandchildren:j,isOver:a,position:t,text:n,shortcut:r})})},z=n(41),K=n(37);const U=["onMouseDown","onClick"];var G=t.a=Object(o.forwardRef)((function(e,t){const{href:n,target:s,isSmall:a,isPressed:u,isBusy:d,isDestructive:p,className:f,disabled:b,icon:m,iconPosition:h="left",iconSize:g,showTooltip:O,tooltipPosition:v,shortcut:j,label:w,children:y,text:E,variant:k,__experimentalIsFocusable:_,describedBy:S,...x}=function({isDefault:e,isPrimary:t,isSecondary:n,isTertiary:r,isLink:o,variant:s,...i}){let c=s;var a,u,d,p,f;return t&&(null!==(a=c)&&void 0!==a||(c="primary")),r&&(null!==(u=c)&&void 0!==u||(c="tertiary")),n&&(null!==(d=c)&&void 0!==d||(c="secondary")),e&&(l()("Button isDefault prop",{since:"5.4",alternative:'variant="secondary"'}),null!==(p=c)&&void 0!==p||(c="secondary")),o&&(null!==(f=c)&&void 0!==f||(c="link")),{...i,variant:c}}(e),T=i()("components-button",f,{"is-secondary":"secondary"===k,"is-primary":"primary"===k,"is-small":a,"is-tertiary":"tertiary"===k,"is-pressed":u,"is-busy":d,"is-link":"link"===k,"is-destructive":p,"has-text":!!m&&!!y,"has-icon":!!m}),C=b&&!_,L=void 0===n||C?"button":"a",I="a"===L?{href:n,target:s}:{type:"button",disabled:C,"aria-pressed":u};if(b&&_){I["aria-disabled"]=!0;for(const e of U)x[e]=e=>{e.stopPropagation(),e.preventDefault()}}const A=!C&&(O&&w||j||!!w&&(!y||Object(c.isArray)(y)&&!y.length)&&!1!==O),R=S?Object(c.uniqueId)():null,F=x["aria-describedby"]||R,P=Object(o.createElement)(L,Object(r.a)({},I,x,{className:T,"aria-label":x["aria-label"]||w,"aria-describedby":F,ref:t}),m&&"left"===h&&Object(o.createElement)(z.a,{icon:m,size:g}),E&&Object(o.createElement)(o.Fragment,null,E),m&&"right"===h&&Object(o.createElement)(z.a,{icon:m,size:g}),y);return A?Object(o.createElement)(o.Fragment,null,Object(o.createElement)(q,{text:S||w,shortcut:j,position:v},P),S&&Object(o.createElement)(K.a,null,Object(o.createElement)("span",{id:R},S))):Object(o.createElement)(o.Fragment,null,P,S&&Object(o.createElement)(K.a,null,Object(o.createElement)("span",{id:R},S)))}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return s}));var r=n(0);const o=Object(r.createContext)({}),s=()=>{const{wrapper:e}=Object(r.useContext)(o);return t=>{e&&e.current&&(e.current.hidden=!t)}}},function(e,t,n){"use strict";n.d(t,"n",(function(){return s})),n.d(t,"l",(function(){return i})),n.d(t,"k",(function(){return c})),n.d(t,"m",(function(){return a})),n.d(t,"i",(function(){return l})),n.d(t,"d",(function(){return u})),n.d(t,"f",(function(){return d})),n.d(t,"j",(function(){return p})),n.d(t,"c",(function(){return f})),n.d(t,"e",(function(){return b})),n.d(t,"g",(function(){return m})),n.d(t,"a",(function(){return h})),n.d(t,"h",(function(){return g})),n.d(t,"b",(function(){return O}));var r,o=n(2);const s=Object(o.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),i=s.pluginUrl+"images/",c=s.pluginUrl+"build/",a=s.buildPhase,l=null===(r=o.STORE_PAGES.shop)||void 0===r?void 0:r.permalink,u=(o.STORE_PAGES.checkout.id,o.STORE_PAGES.checkout.permalink),d=o.STORE_PAGES.privacy.permalink,p=(o.STORE_PAGES.privacy.title,o.STORE_PAGES.terms.permalink),f=(o.STORE_PAGES.terms.title,o.STORE_PAGES.cart.id,o.STORE_PAGES.cart.permalink),b=o.STORE_PAGES.myaccount.permalink?o.STORE_PAGES.myaccount.permalink:Object(o.getSetting)("wpLoginUrl","/wp-login.php"),m=Object(o.getSetting)("shippingCountries",{}),h=Object(o.getSetting)("allowedCountries",{}),g=Object(o.getSetting)("shippingStates",{}),O=Object(o.getSetting)("allowedStates",{})},function(e,t){e.exports=window.wp.dom},function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(12),o=n.n(r),s=n(0),i=n(16);const c=[".wp-block-woocommerce-cart"],a=e=>{let{Block:t,containers:n,getProps:r=(()=>({})),getErrorBoundaryProps:c=(()=>({}))}=e;0!==n.length&&Array.prototype.forEach.call(n,(e,n)=>{const a=r(e,n),l=c(e,n),u={...e.dataset,...a.attributes||{}};(e=>{let{Block:t,container:n,attributes:r={},props:c={},errorBoundaryProps:a={}}=e;Object(s.render)(Object(s.createElement)(i.a,a,Object(s.createElement)(s.Suspense,{fallback:Object(s.createElement)("div",{className:"wc-block-placeholder"})},t&&Object(s.createElement)(t,o()({},c,{attributes:r})))),n,()=>{n.classList&&n.classList.remove("is-loading")})})({Block:t,container:e,props:a,attributes:u,errorBoundaryProps:l})})},l=e=>{const t=document.body.querySelectorAll(c.join(",")),{Block:n,getProps:r,getErrorBoundaryProps:o,selector:s}=e;(e=>{let{Block:t,getProps:n,getErrorBoundaryProps:r,selector:o,wrappers:s}=e;const i=document.body.querySelectorAll(o);s&&s.length>0&&Array.prototype.filter.call(i,e=>!((e,t)=>Array.prototype.some.call(t,t=>t.contains(e)&&!t.isSameNode(e)))(e,s)),a({Block:t,containers:i,getProps:n,getErrorBoundaryProps:r})})({Block:n,getProps:r,getErrorBoundaryProps:o,selector:s,wrappers:t}),Array.prototype.forEach.call(t,t=>{t.addEventListener("wc-blocks_render_blocks_frontend",()=>{(e=>{let{Block:t,getProps:n,getErrorBoundaryProps:r,selector:o,wrapper:s}=e;const i=s.querySelectorAll(o);a({Block:t,containers:i,getProps:n,getErrorBoundaryProps:r})})({...e,wrapper:t})})})}},,,function(e,t,n){"use strict";n.d(t,"d",(function(){return c})),n.d(t,"h",(function(){return a})),n.d(t,"b",(function(){return l})),n.d(t,"a",(function(){return u})),n.d(t,"e",(function(){return d})),n.d(t,"f",(function(){return p})),n.d(t,"c",(function(){return f})),n.d(t,"g",(function(){return b}));var r=n(14),o=n(71),s=n(30),i=n(125);function c(){return Math.floor(Math.random()*Date.now())}const a=e=>e.replace("pa_",""),l=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const n={};t.forEach(e=>{const{attribute:t,slug:r,operator:s}=e,i=a(t),c=r.join(","),l=`${o.b}${i}`,u="in"===s?"or":"and";n[`${o.a}${i}`]=c,n[l]=u});const s=Object(r.removeQueryArgs)(e,...Object.keys(n));return Object(r.addQueryArgs)(s,n)},u=e=>{let{currentCheckedFilters:t,hasSetFilterDefaultsFromUrl:n}=e;return n&&0===t.length},d=e=>{if(e){const t=Object(o.d)("filter_"+e.name);return"string"==typeof t?t.split(","):[]}return[]},p=(e,t)=>{const n=Object.entries(t).reduce((e,t)=>{let[n,r]=t;return n.includes("query_type")?e:{...e,[n]:r}},{});return Object.entries(n).reduce((t,n)=>{let[r,o]=n;return e[r]===o&&t},!0)},f=e=>e.trim().replace(/\s/g,"-").replace(/_/g,"-").replace(/-+/g,"-").replace(/[^a-zA-Z0-9-]/g,""),b=e=>({className:Object(s.a)(null==e?void 0:e.className)?e.className:"",attributeId:parseInt(Object(s.a)(null==e?void 0:e.attributeId)?e.attributeId:"0",10),showCounts:"false"!==(null==e?void 0:e.showCounts),queryType:Object(s.a)(null==e?void 0:e.queryType)&&e.queryType||i.attributes.queryType.default,heading:Object(s.a)(null==e?void 0:e.heading)?e.heading:"",headingLevel:Object(s.a)(null==e?void 0:e.headingLevel)&&parseInt(e.headingLevel,10)||i.attributes.headingLevel.default,displayStyle:Object(s.a)(null==e?void 0:e.displayStyle)&&e.displayStyle||i.attributes.displayStyle.default,showFilterButton:"true"===(null==e?void 0:e.showFilterButton),selectType:Object(s.a)(null==e?void 0:e.selectType)&&e.selectType||i.attributes.selectType.default,isPreview:!1})},,,function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(8);function o(e,t,n){var o=this,s=Object(r.useRef)(null),i=Object(r.useRef)(0),c=Object(r.useRef)(null),a=Object(r.useRef)([]),l=Object(r.useRef)(),u=Object(r.useRef)(),d=Object(r.useRef)(e),p=Object(r.useRef)(!0);d.current=e;var f=!t&&0!==t&&"undefined"!=typeof window;if("function"!=typeof e)throw new TypeError("Expected a function");t=+t||0;var b=!!(n=n||{}).leading,m=!("trailing"in n)||!!n.trailing,h="maxWait"in n,g=h?Math.max(+n.maxWait||0,t):null;return Object(r.useEffect)((function(){return p.current=!0,function(){p.current=!1}}),[]),Object(r.useMemo)((function(){var e=function(e){var t=a.current,n=l.current;return a.current=l.current=null,i.current=e,u.current=d.current.apply(n,t)},n=function(e,t){f&&cancelAnimationFrame(c.current),c.current=f?requestAnimationFrame(e):setTimeout(e,t)},r=function(e){if(!p.current)return!1;var n=e-s.current,r=e-i.current;return!s.current||n>=t||n<0||h&&r>=g},O=function(t){return c.current=null,m&&a.current?e(t):(a.current=l.current=null,u.current)},v=function(){var e=Date.now();if(r(e))return O(e);if(p.current){var o=e-s.current,c=e-i.current,a=t-o,l=h?Math.min(a,g-c):a;n(v,l)}},j=function(){for(var d=[],f=0;f<arguments.length;f++)d[f]=arguments[f];var m=Date.now(),g=r(m);if(a.current=d,l.current=o,s.current=m,g){if(!c.current&&p.current)return i.current=s.current,n(v,t),b?e(s.current):u.current;if(h)return n(v,t),e(s.current)}return c.current||n(v,t),u.current};return j.cancel=function(){c.current&&(f?cancelAnimationFrame(c.current):clearTimeout(c.current)),i.current=0,a.current=s.current=l.current=c.current=null},j.isPending=function(){return!!c.current},j.flush=function(){return c.current?O(Date.now()):u.current},j}),[b,h,t,g,m,f])}},,,,,,function(e,t){e.exports=window.wp.keycodes},function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(3),o=n(6),s=n(0),i=n(29),c=n(76);const a=e=>{const{namespace:t,resourceName:n,resourceValues:a=[],query:l={},shouldSelect:u=!0}=e;if(!t||!n)throw new Error("The options object must have valid values for the namespace and the resource properties.");const d=Object(s.useRef)({results:[],isLoading:!0}),p=Object(i.a)(l),f=Object(i.a)(a),b=Object(c.a)(),m=Object(o.useSelect)(e=>{if(!u)return null;const o=e(r.COLLECTIONS_STORE_KEY),s=[t,n,p,f],i=o.getCollectionError(...s);if(i){if(!(i instanceof Error))throw new Error("TypeError: `error` object is not an instance of Error constructor");b(i)}return{results:o.getCollection(...s),isLoading:!o.hasFinishedResolution("getCollection",s)}},[t,n,f,p,u]);return null!==m&&(d.current=m),d.current}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(8);function o(e,t){const n=Object(r.useRef)();return Object(r.useEffect)(()=>{n.current===e||t&&!t(e,n.current)||(n.current=e)},[e,t]),n.current}},function(e,t,n){"use strict";var r=n(0),o=n(1),s=n(19);n(136),t.a=e=>{let{name:t,count:n}=e;return Object(r.createElement)(r.Fragment,null,t,null!==n&&Number.isFinite(n)&&Object(r.createElement)(s.a,{label:n.toString(),screenReaderLabel:Object(o.sprintf)(
|
2 |
/* translators: %s number of products. */
|
3 |
-
Object(o._n)("%s product","%s products",n,"woo-gutenberg-products-block"),n),wrapperElement:"span",wrapperProps:{className:"wc-filter-element-label-list-count"}}))}}
|
4 |
/* translators: Reset button text for filters. */
|
5 |
-
n=Object(o.__)("Reset","woo-gutenberg-products-block"),onClick:s,screenReaderLabel:a=Object(o.__)("Reset filter","woo-gutenberg-products-block")}=e;return Object(r.createElement)("button",{className:i()("wc-block-components-filter-reset-button",t),onClick:s},Object(r.createElement)(c.a,{label:n,screenReaderLabel:a}))}},function(e,t,n){"use strict";var r=n(0),o=n(1),s=n(
|
6 |
/* translators: Submit button text for filters. */
|
7 |
-
a=Object(o.__)("Apply","woo-gutenberg-products-block"),onClick:l,screenReaderLabel:u=Object(o.__)("Apply filter","woo-gutenberg-products-block")}=e;return Object(r.createElement)("button",{type:"submit",className:i()("wp-block-button__link","wc-block-filter-submit-button","wc-block-components-filter-submit-button",{"is-loading":n},t),disabled:s,onClick:l},Object(r.createElement)(c.a,{label:a,screenReaderLabel:u}))}},,function(e,t,n){"use strict";n.d(t,"b",(function(){return c})),n.d(t,"a",(function(){return a})),n.d(t,"d",(function(){return l})),n.d(t,"c",(function(){return u}));var r=n(
|
8 |
/* translators: %s is referring the remaining count of options */
|
9 |
Object(o._n)("Show %s more option","Show %s more options",e,"woo-gutenberg-products-block"),e)},Object(o.sprintf)(
|
10 |
/* translators: %s number of options to reveal. */
|
11 |
-
Object(o._n)("Show %s more","Show %s more",e,"woo-gutenberg-products-block"),e)))},[s,d,p]),h=Object(r.useMemo)(()=>p&&Object(r.createElement)("li",{key:"show-less",className:"show-less"},Object(r.createElement)("button",{onClick:()=>{f(!1)},"aria-expanded":!0,"aria-label":Object(o.__)("Show less options","woo-gutenberg-products-block")},Object(o.__)("Show less","woo-gutenberg-products-block"))),[p]),g=Object(r.useMemo)(()=>{const e=s.length>d+5;return Object(r.createElement)(r.Fragment,null,s.map((t,o)=>Object(r.createElement)(r.Fragment,{key:t.value},Object(r.createElement)("li",e&&!p&&o>=d&&{hidden:!0},Object(r.createElement)(c.CheckboxControl,{id:t.value,className:"wc-block-checkbox-list__checkbox",label:t.label,checked:a.includes(t.value),onChange:()=>{n(t.value)}})),e&&o===d-1&&m)),e&&h)},[s,n,a,p,d,h,m,u]),O=i()("wc-block-checkbox-list","wc-block-components-checkbox-list",{"is-loading":l},t);return Object(r.createElement)("ul",{className:O},l?b:g)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(8),o=n(54);function s(e,t){return e===t}function i(e){return"function"==typeof e?function(){return e}:e}function c(e,t,n){var c=n&&n.equalityFn||s,a=function(e){var t=Object(r.useState)(i(e)),n=t[0],o=t[1];return[n,Object(r.useCallback)((function(e){return o(i(e))}),[])]}(e),l=a[0],u=a[1],d=Object(o.a)(Object(r.useCallback)((function(e){return u(e)}),[u]),t,n),p=Object(r.useRef)(e);return c(p.current,e)||(d(e),p.current=e),[l,d]}},function(e,t,n){"use strict";var r=n(0),o=n(5),s=n(4),i=n.n(s),c=n(1),a=n(24),l=n(92),u=n(44);function d(e){switch(e){case"success":case"warning":case"info":return"polite";case"error":default:return"assertive"}}t.a=function({className:e,status:t="info",children:n,spokenMessage:s=n,onRemove:p=o.noop,isDismissible:f=!0,actions:b=[],politeness:m=d(t),__unstableHTML:h,onDismiss:g=o.noop}){!function(e,t){const n="string"==typeof e?e:Object(r.renderToString)(e);Object(r.useEffect)(()=>{n&&Object(a.speak)(n,t)},[n,t])}(s,m);const O=i()(e,"components-notice","is-"+t,{"is-dismissible":f});return h&&(n=Object(r.createElement)(r.RawHTML,null,n)),Object(r.createElement)("div",{className:O},Object(r.createElement)("div",{className:"components-notice__content"},n,Object(r.createElement)("div",{className:"components-notice__actions"},b.map(({className:e,label:t,isPrimary:n,variant:o,noDefaultClasses:s=!1,onClick:c,url:a},l)=>{let d=o;return"primary"===o||s||(d=a?"link":"secondary"),void 0===d&&n&&(d="primary"),Object(r.createElement)(u.a,{key:l,href:a,variant:d,onClick:a?void 0:c,className:i()("components-notice__action",e)},t)}))),f&&Object(r.createElement)(u.a,{className:"components-notice__dismiss",icon:l.a,label:Object(c.__)("Dismiss this notice"),onClick:e=>{var t;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),g(),p()},showTooltip:!1}))}},,function(e,t){e.exports=window.wp.blocks},function(e,t){},function(e,t){},function(e,t){},,,,,,,,function(e,t){e.exports=window.wp.blockEditor},,,function(e,t,n){"use strict";var r=n(0);t.a=function(e){let{icon:t,size:n=24,...o}=e;return Object(r.cloneElement)(t,{width:n,height:n,...o})}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return s}));var r=n(5);const o=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";const s=e.filter(e=>e.attribute===n.taxonomy),i=s.length?s[0]:null;if(!(i&&i.slug&&Array.isArray(i.slug)&&i.slug.includes(o)))return;const c=i.slug.filter(e=>e!==o),a=e.filter(e=>e.attribute!==n.taxonomy);c.length>0&&(i.slug=c.sort(),a.push(i)),t(Object(r.sortBy)(a,"attribute"))},s=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"in";if(!n||!n.taxonomy)return[];const i=e.filter(e=>e.attribute!==n.taxonomy);return 0===o.length?t(i):(i.push({attribute:n.taxonomy,operator:s,slug:o.map(e=>{let{slug:t}=e;return t}).sort()}),t(Object(r.sortBy)(i,"attribute"))),i}},,,function(e,t){},,function(e,t,n){"use strict";n.d(t,"a",(function(){return s})),n.d(t,"b",(function(){return i}));var r=n(2);const o=Object(r.getSetting)("attributes",[]).reduce((e,t)=>{const n=(r=t)&&r.attribute_name?{id:parseInt(r.attribute_id,10),name:r.attribute_name,taxonomy:"pa_"+r.attribute_name,label:r.attribute_label}:null;var r;return n&&n.id&&e.push(n),e},[]),s=e=>{if(e)return o.find(t=>t.id===e)},i=e=>{if(e)return o.find(t=>t.taxonomy===e)}},,,,,function(e){e.exports=JSON.parse('{"name":"woocommerce/attribute-filter","version":"1.0.0","title":"Filter by Attribute Controls","description":"Enable customers to filter the product grid by selecting one or more attributes, such as color.","category":"woocommerce","keywords":["WooCommerce"],"supports":{"html":false,"color":{"text":true,"background":false},"inserter":false,"lock":false},"example":{"attributes":{"isPreview":true}},"attributes":{"className":{"type":"string","default":""},"attributeId":{"type":"number","default":0},"showCounts":{"type":"boolean","default":true},"queryType":{"type":"string","default":"or"},"headingLevel":{"type":"number","default":3},"displayStyle":{"type":"string","default":"list"},"showFilterButton":{"type":"boolean","default":false},"selectType":{"type":"string","default":"multiple"},"isPreview":{"type":"boolean","default":false}},"textdomain":"woo-gutenberg-products-block","apiVersion":2,"$schema":"https://schemas.wp.org/trunk/block.json"}')},,,,,,,,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return d}));var r=n(0),o=n(97),s=n(5),i=n(29),c=n(20),a=n(31),l=n(61),u=n(25);const d=e=>{let{queryAttribute:t,queryPrices:n,queryStock:d,queryRating:p,queryState:f,productIds:b}=e,m=Object(u.a)();m+="-collection-data";const[h]=Object(a.a)(m),[g,O]=Object(a.b)("calculate_attribute_counts",[],m),[v,j]=Object(a.b)("calculate_price_range",null,m),[w,y]=Object(a.b)("calculate_stock_status_counts",null,m),[E,k]=Object(a.b)("calculate_rating_counts",null,m),_=Object(i.a)(t||{}),S=Object(i.a)(n),x=Object(i.a)(d),T=Object(i.a)(p);Object(r.useEffect)(()=>{"object"==typeof _&&Object.keys(_).length&&(g.find(e=>Object(c.b)(_,"taxonomy")&&e.taxonomy===_.taxonomy)||O([...g,_]))},[_,g,O]),Object(r.useEffect)(()=>{v!==S&&void 0!==S&&j(S)},[S,j,v]),Object(r.useEffect)(()=>{w!==x&&void 0!==x&&y(x)},[x,y,w]),Object(r.useEffect)(()=>{E!==T&&void 0!==T&&k(T)},[T,k,E]);const[C,L]=Object(r.useState)(!1),[I]=Object(o.a)(C,200);C||L(!0);const A=Object(r.useMemo)(()=>(e=>{const t=e;return Array.isArray(e.calculate_attribute_counts)&&(t.calculate_attribute_counts=Object(s.sortBy)(e.calculate_attribute_counts.map(e=>{let{taxonomy:t,queryType:n}=e;return{taxonomy:t,query_type:n}}),["taxonomy","query_type"])),t})(h),[h]);return Object(l.a)({namespace:"/wc/store/v1",resourceName:"products/collection-data",query:{...f,page:void 0,per_page:void 0,orderby:void 0,order:void 0,...!Object(s.isEmpty)(b)&&{include:b},...A},shouldSelect:I})}},function(e,t){},,,,,,,,,,,,,function(e,t,n){"use strict";var r=n(9),o=n(0),s=n(4),i=n.n(s);class c extends o.Component{constructor(){super(...arguments),this.onChange=this.onChange.bind(this),this.bindInput=this.bindInput.bind(this)}focus(){this.input.focus()}hasFocus(){return this.input===this.input.ownerDocument.activeElement}bindInput(e){this.input=e}onChange(e){this.props.onChange({value:e.target.value})}render(){const{value:e,isExpanded:t,instanceId:n,selectedSuggestionIndex:s,className:c,...a}=this.props,l=e?e.length+1:0;return Object(o.createElement)("input",Object(r.a)({ref:this.bindInput,id:"components-form-token-input-"+n,type:"text"},a,{value:e||"",onChange:this.onChange,size:l,className:i()(c,"components-form-token-field__input"),autoComplete:"off",role:"combobox","aria-expanded":t,"aria-autocomplete":"list","aria-owns":t?"components-form-token-suggestions-"+n:void 0,"aria-activedescendant":-1!==s?`components-form-token-suggestions-${n}-${s}`:void 0,"aria-describedby":"components-form-token-suggestions-howto-"+n}))}}t.a=c},function(e,t,n){"use strict";var r=n(0),o=n(5),s=n(151),i=n.n(s),c=n(4),a=n.n(c),l=n(11);class u extends r.Component{constructor(){super(...arguments),this.handleMouseDown=this.handleMouseDown.bind(this),this.bindList=this.bindList.bind(this)}componentDidUpdate(){this.props.selectedIndex>-1&&this.props.scrollIntoView&&this.list.children[this.props.selectedIndex]&&(this.scrollingIntoView=!0,i()(this.list.children[this.props.selectedIndex],this.list,{onlyScrollIfNeeded:!0}),this.props.setTimeout(()=>{this.scrollingIntoView=!1},100))}bindList(e){this.list=e}handleHover(e){return()=>{this.scrollingIntoView||this.props.onHover(e)}}handleClick(e){return()=>{this.props.onSelect(e)}}handleMouseDown(e){e.preventDefault()}computeSuggestionMatch(e){const t=this.props.displayTransform(this.props.match||"").toLocaleLowerCase();if(0===t.length)return null;const n=(e=this.props.displayTransform(e)).toLocaleLowerCase().indexOf(t);return{suggestionBeforeMatch:e.substring(0,n),suggestionMatch:e.substring(n,n+t.length),suggestionAfterMatch:e.substring(n+t.length)}}render(){return Object(r.createElement)("ul",{ref:this.bindList,className:"components-form-token-field__suggestions-list",id:"components-form-token-suggestions-"+this.props.instanceId,role:"listbox"},Object(o.map)(this.props.suggestions,(e,t)=>{const n=this.computeSuggestionMatch(e),o=a()("components-form-token-field__suggestion",{"is-selected":t===this.props.selectedIndex});return Object(r.createElement)("li",{id:`components-form-token-suggestions-${this.props.instanceId}-${t}`,role:"option",className:o,key:null!=e&&e.value?e.value:this.props.displayTransform(e),onMouseDown:this.handleMouseDown,onClick:this.handleClick(e),onMouseEnter:this.handleHover(e),"aria-selected":t===this.props.selectedIndex},n?Object(r.createElement)("span",{"aria-label":this.props.displayTransform(e)},n.suggestionBeforeMatch,Object(r.createElement)("strong",{className:"components-form-token-field__suggestion-match"},n.suggestionMatch),n.suggestionAfterMatch):this.props.displayTransform(e))}))}}u.defaultProps={match:"",onHover:()=>{},onSelect:()=>{},suggestions:Object.freeze([])},t.a=Object(l.withSafeTimeout)(u)},function(e,t,n){"use strict";e.exports=n(220)},,,,,,,,,function(e,t,n){"use strict";var r=n(0),o=n(1),s=n(277),i=n(29),c=n(62),a=n(31),l=n(61),u=n(135),d=n(63),p=n(68),f=n(69),b=n(13),m=n.n(b),h=n(23),g=n(98),O=n(2),v=n(14),j=n(74),w=n(30),y=n(20),E=n(226),k=n(114),_=n(284),S=n(71),x=n(5),T=n(12),C=n.n(T),L=n(286),I=n(4),A=n.n(I);n(227);var R=e=>{let{className:t,style:n,suggestions:o,multiple:s=!0,saveTransform:i=(e=>e.trim().replace(/\s/g,"-")),messages:c={},validateInput:a=(e=>o.includes(e)),label:l="",...u}=e;return Object(r.createElement)("div",{className:A()("wc-blocks-components-form-token-field-wrapper",t,{"single-selection":!s}),style:n},Object(r.createElement)(L.a,C()({label:l,__experimentalExpandOnFocus:!0,__experimentalShowHowTo:!1,__experimentalValidateInput:a,saveTransform:i,maxLength:s?void 0:1,suggestions:o,messages:c},u)))},F=n(67),P=n(120),N=n(115);const M=[{value:"preview-1",formattedValue:"preview-1",name:"Blue",label:Object(r.createElement)(d.a,{name:"Blue",count:3}),textLabel:"Blue (3)"},{value:"preview-2",formattedValue:"preview-2",name:"Green",label:Object(r.createElement)(d.a,{name:"Green",count:3}),textLabel:"Green (3)"},{value:"preview-3",formattedValue:"preview-3",name:"Red",label:Object(r.createElement)(d.a,{name:"Red",count:2}),textLabel:"Red (2)"}],B={id:0,name:"preview",taxonomy:"preview",label:"Preview"};n(225);var D=n(51),V=n(96),W=e=>{let{isLoading:t=!1,options:n,checked:o,onChange:s}=e;return t?Object(r.createElement)(r.Fragment,null,Object(r.createElement)("span",{className:"is-loading"}),Object(r.createElement)("span",{className:"is-loading"})):Object(r.createElement)(V.a,{className:"wc-block-attribute-filter-list",options:n,checked:o,onChange:s,isLoading:t,isDisabled:t})},H=n(45);t.a=e=>{let{attributes:t,isEditor:n=!1}=e;const b=Object(O.getSettingWithCoercion)("has_filterable_products",!1,j.a),T=Object(O.getSettingWithCoercion)("is_rendering_php_template",!1,j.a),C=Object(O.getSettingWithCoercion)("page_url",window.location.href,w.a),L=n?[]:Object(O.getSettingWithCoercion)("product_ids",[],Array.isArray),[I,V]=Object(r.useState)(!1),q=t.isPreview&&!t.attributeId?B:Object(P.a)(t.attributeId),z=Object(r.useMemo)(()=>Object(D.e)(q),[q]),[K,U]=Object(r.useState)(z),[G,$]=Object(r.useState)(Object(D.d)()),[Q,Y]=Object(r.useState)(t.isPreview&&!t.attributeId?M:[]),J=Object(s.a)(t),[X]=Object(a.a)(),[Z,ee]=Object(a.b)("attributes",[]),{results:te,isLoading:ne}=Object(l.a)({namespace:"/wc/store/v1",resourceName:"products/attributes/terms",resourceValues:[(null==q?void 0:q.id)||0],shouldSelect:t.attributeId>0}),re="dropdown"!==t.displayStyle&&"and"===t.queryType,{results:oe,isLoading:se}=Object(u.a)({queryAttribute:{taxonomy:(null==q?void 0:q.taxonomy)||"",queryType:t.queryType},queryState:{...X,attributes:re?X.attributes:null},productIds:L}),ie=Object(r.useCallback)(e=>Object(y.b)(oe,"attribute_counts")&&Array.isArray(oe.attribute_counts)?oe.attribute_counts.find(t=>{let{term:n}=t;return n===e}):null,[oe]);Object(r.useEffect)(()=>{if(ne||se)return;if(!Array.isArray(te))return;const e=te.map(e=>{const n=ie(e.id);if(!(n||K.includes(e.slug)||(o=e.slug,null!=X&&X.attributes&&X.attributes.some(e=>{let{attribute:t,slug:n=[]}=e;return t===(null==q?void 0:q.taxonomy)&&n.includes(o)}))))return null;var o;const s=n?n.count:0;return{formattedValue:Object(D.c)(e.slug),value:e.slug,name:Object(h.decodeEntities)(e.name),label:Object(r.createElement)(d.a,{name:Object(h.decodeEntities)(e.name),count:t.showCounts?s:null}),textLabel:t.showCounts?`${Object(h.decodeEntities)(e.name)} (${s})`:Object(h.decodeEntities)(e.name)}}).filter(e=>!!e);Y(e),$(Object(D.d)())},[null==q?void 0:q.taxonomy,te,ne,t.showCounts,se,ie,K,X.attributes]);const ce=Object(r.useCallback)(e=>Array.isArray(te)?te.reduce((t,n)=>(e.includes(n.slug)&&t.push(n),t),[]):[],[te]),ae=Object(r.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(t){if(null==q||!q.taxonomy)return;const t=Object.keys(Object(v.getQueryArgs)(window.location.href)),n=Object(D.h)(q.taxonomy),r=t.reduce((e,t)=>t.includes(S.b+n)||t.includes(S.a+n)?Object(v.removeQueryArgs)(e,t):e,window.location.href),o=Object(D.b)(r,e);Object(S.c)(o)}else{const t=Object(D.b)(C,e),n=Object(v.getQueryArgs)(window.location.href),r=Object(v.getQueryArgs)(t);Object(D.f)(n,r)||Object(S.c)(t)}}),[C,null==q?void 0:q.taxonomy]),le=e=>{const n=Object(N.b)(Z,ee,q,ce(e),"or"===t.queryType?"in":"and");ae(n,0===e.length)},ue=Object(r.useCallback)((function(e){let r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];n||(U(e),!r&&t.showFilterButton||Object(N.b)(Z,ee,q,ce(e),"or"===t.queryType?"in":"and"))}),[n,U,Z,ee,q,ce,t.queryType,t.showFilterButton]),de=Object(r.useMemo)(()=>Object(E.a)(Z)?Z.filter(e=>{let{attribute:t}=e;return t===(null==q?void 0:q.taxonomy)}).flatMap(e=>{let{slug:t}=e;return t}):[],[Z,null==q?void 0:q.taxonomy]),pe=Object(i.a)(de),fe=Object(c.a)(pe);Object(r.useEffect)(()=>{!fe||m()(fe,pe)||m()(K,pe)||ue(pe)},[K,pe,fe,ue]);const be="single"!==t.selectType,me=Object(r.useCallback)(e=>{const t=K.includes(e);let n;be?(n=K.filter(t=>t!==e),t||(n.push(e),n.sort())):n=t?[]:[e],ue(n)},[K,be,ue]);Object(r.useEffect)(()=>{q&&!t.showFilterButton&&(Object(D.a)({currentCheckedFilters:K,hasSetFilterDefaultsFromUrl:I})?ae(Z,!0):ae(Z,!1))},[I,ae,Z,q,K,t.showFilterButton]),Object(r.useEffect)(()=>{if(!I&&!ne)return z.length>0?(V(!0),void ue(z,!0)):void(T||V(!0))},[q,I,ne,ue,z,T]);const he=Object(H.b)();if(!b)return he(!1),null;if(!q)return n?Object(r.createElement)(g.a,{status:"warning",isDismissible:!1},Object(r.createElement)("p",null,Object(o.__)("Please select an attribute to use this filter!","woo-gutenberg-products-block"))):(he(!1),null);if(0===Q.length&&!ne&&n)return Object(r.createElement)(g.a,{status:"warning",isDismissible:!1},Object(r.createElement)("p",null,Object(o.__)("There are no products with the selected attributes.","woo-gutenberg-products-block")));const ge="h"+t.headingLevel,Oe=!t.isPreview&&ne,ve=!t.isPreview&&se,je=(Oe||ve)&&0===Q.length;if(!je&&0===Q.length)return he(!1),null;const we=Object(r.createElement)(ge,{className:"wc-block-attribute-filter__title"},t.heading),ye=je?Object(r.createElement)(F.a,null,we):we;return he(!0),Object(r.createElement)(r.Fragment,null,!n&&t.heading&&ye,Object(r.createElement)("div",{className:A()("wc-block-attribute-filter","style-"+t.displayStyle)},"dropdown"===t.displayStyle?Object(r.createElement)(r.Fragment,null,Object(r.createElement)(R,{key:G,className:A()(J.className,{"single-selection":!be,"is-loading":je}),style:{...J.style,borderStyle:"none"},suggestions:Q.filter(e=>!K.includes(e.value)).map(e=>e.formattedValue),disabled:je,placeholder:Object(o.sprintf)(
|
12 |
/* translators: %s attribute name. */
|
13 |
Object(o.__)("Select %s","woo-gutenberg-products-block"),q.label),onChange:e=>{!be&&e.length>1&&(e=[e[e.length-1]]),e=e.map(e=>{const t=Q.find(t=>t.formattedValue===e);return t?t.value:e});const t=Object(x.difference)(e,K);if(1===t.length)return me(t[0]);const n=Object(x.difference)(K,e);1===n.length&&me(n[0])},value:K,displayTransform:e=>{const t=Q.find(t=>[t.value,t.formattedValue].includes(e));return t?t.textLabel:e},saveTransform:D.c,messages:{added:Object(o.sprintf)(
|
14 |
/* translators: %s is the attribute label. */
|
@@ -18,8 +18,8 @@ Object(o.__)("%s filter removed.","woo-gutenberg-products-block"),q.label),remov
|
|
18 |
/* translators: %s is the attribute label. */
|
19 |
Object(o.__)("Remove %s filter.","woo-gutenberg-products-block"),q.label.toLocaleLowerCase()),__experimentalInvalid:Object(o.sprintf)(
|
20 |
/* translators: %s is the attribute label. */
|
21 |
-
Object(o.__)("Invalid %s filter.","woo-gutenberg-products-block"),q.label.toLocaleLowerCase())}}),be&&Object(r.createElement)(k.a,{icon:_.a,size:30})):Object(r.createElement)(W,{options:Q,checked:K,onChange:me,isLoading:je,isDisabled:je})),Object(r.createElement)("div",{className:"wc-block-attribute-filter__actions"},K.length>0&&!je&&Object(r.createElement)(p.a,{onClick:()=>{U([]),$(Object(D.d)()),I&&le([])},screenReaderLabel:Object(o.__)("Reset attribute filter","woo-gutenberg-products-block")}),t.showFilterButton&&Object(r.createElement)(f.a,{className:"wc-block-attribute-filter__button",isLoading:je,disabled:(()=>{if(Oe||ve)return!0;const e=Object(D.e)(q);return e.length===K.length&&K.every(t=>e.includes(t))})(),onClick:()=>le(K)})))}},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n(100);var r=n(46);const o=()=>r.m>1},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(30),o=n(20);const s=e=>Object(r.a)(e)?JSON.parse(e)||{}:Object(o.a)(e)?e:{}},,,function(e,t,n){"use strict";var r=n(221);e.exports=function(e,t,n){n=n||{},9===t.nodeType&&(t=r.getWindow(t));var o=n.allowHorizontalScroll,s=n.onlyScrollIfNeeded,i=n.alignWithTop,c=n.alignWithLeft,a=n.offsetTop||0,l=n.offsetLeft||0,u=n.offsetBottom||0,d=n.offsetRight||0;o=void 0===o||o;var p=r.isWindow(t),f=r.offset(e),b=r.outerHeight(e),m=r.outerWidth(e),h=void 0,g=void 0,O=void 0,v=void 0,j=void 0,w=void 0,y=void 0,E=void 0,k=void 0,_=void 0;p?(y=t,_=r.height(y),k=r.width(y),E={left:r.scrollLeft(y),top:r.scrollTop(y)},j={left:f.left-E.left-l,top:f.top-E.top-a},w={left:f.left+m-(E.left+k)+d,top:f.top+b-(E.top+_)+u},v=E):(h=r.offset(t),g=t.clientHeight,O=t.clientWidth,v={left:t.scrollLeft,top:t.scrollTop},j={left:f.left-(h.left+(parseFloat(r.css(t,"borderLeftWidth"))||0))-l,top:f.top-(h.top+(parseFloat(r.css(t,"borderTopWidth"))||0))-a},w={left:f.left+m-(h.left+O+(parseFloat(r.css(t,"borderRightWidth"))||0))+d,top:f.top+b-(h.top+g+(parseFloat(r.css(t,"borderBottomWidth"))||0))+u}),j.top<0||w.top>0?!0===i?r.scrollTop(t,v.top+j.top):!1===i?r.scrollTop(t,v.top+w.top):j.top<0?r.scrollTop(t,v.top+j.top):r.scrollTop(t,v.top+w.top):s||((i=void 0===i||!!i)?r.scrollTop(t,v.top+j.top):r.scrollTop(t,v.top+w.top)),o&&(j.left<0||w.left>0?!0===c?r.scrollLeft(t,v.left+j.left):!1===c?r.scrollLeft(t,v.left+w.left):j.left<0?r.scrollLeft(t,v.left+j.left):r.scrollLeft(t,v.left+w.left):s||((c=void 0===c||!!c)?r.scrollLeft(t,v.left+j.left):r.scrollLeft(t,v.left+w.left)))}},function(e,t,n){"use strict";var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};function s(e,t){var n=e["page"+(t?"Y":"X")+"Offset"],r="scroll"+(t?"Top":"Left");if("number"!=typeof n){var o=e.document;"number"!=typeof(n=o.documentElement[r])&&(n=o.body[r])}return n}function i(e){return s(e)}function c(e){return s(e,!0)}function a(e){var t=function(e){var t,n=void 0,r=void 0,o=e.ownerDocument,s=o.body,i=o&&o.documentElement;return n=(t=e.getBoundingClientRect()).left,r=t.top,{left:n-=i.clientLeft||s.clientLeft||0,top:r-=i.clientTop||s.clientTop||0}}(e),n=e.ownerDocument,r=n.defaultView||n.parentWindow;return t.left+=i(r),t.top+=c(r),t}var l=new RegExp("^("+/[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source+")(?!px)[a-z%]+$","i"),u=/^(top|right|bottom|left)$/,d="left",p=void 0;function f(e,t){for(var n=0;n<e.length;n++)t(e[n])}function b(e){return"border-box"===p(e,"boxSizing")}"undefined"!=typeof window&&(p=window.getComputedStyle?function(e,t,n){var r="",o=e.ownerDocument,s=n||o.defaultView.getComputedStyle(e,null);return s&&(r=s.getPropertyValue(t)||s[t]),r}:function(e,t){var n=e.currentStyle&&e.currentStyle[t];if(l.test(n)&&!u.test(t)){var r=e.style,o=r[d],s=e.runtimeStyle[d];e.runtimeStyle[d]=e.currentStyle[d],r[d]="fontSize"===t?"1em":n||0,n=r.pixelLeft+"px",r[d]=o,e.runtimeStyle[d]=s}return""===n?"auto":n});var m=["margin","border","padding"];function h(e,t,n){var r={},o=e.style,s=void 0;for(s in t)t.hasOwnProperty(s)&&(r[s]=o[s],o[s]=t[s]);for(s in n.call(e),t)t.hasOwnProperty(s)&&(o[s]=r[s])}function g(e,t,n){var r=0,o=void 0,s=void 0,i=void 0;for(s=0;s<t.length;s++)if(o=t[s])for(i=0;i<n.length;i++){var c;c="border"===o?o+n[i]+"Width":o+n[i],r+=parseFloat(p(e,c))||0}return r}function O(e){return null!=e&&e==e.window}var v={};function j(e,t,n){if(O(e))return"width"===t?v.viewportWidth(e):v.viewportHeight(e);if(9===e.nodeType)return"width"===t?v.docWidth(e):v.docHeight(e);var r="width"===t?["Left","Right"]:["Top","Bottom"],o="width"===t?e.offsetWidth:e.offsetHeight,s=(p(e),b(e)),i=0;(null==o||o<=0)&&(o=void 0,(null==(i=p(e,t))||Number(i)<0)&&(i=e.style[t]||0),i=parseFloat(i)||0),void 0===n&&(n=s?1:-1);var c=void 0!==o||s,a=o||i;if(-1===n)return c?a-g(e,["border","padding"],r):i;if(c){var l=2===n?-g(e,["border"],r):g(e,["margin"],r);return a+(1===n?0:l)}return i+g(e,m.slice(n),r)}f(["Width","Height"],(function(e){v["doc"+e]=function(t){var n=t.document;return Math.max(n.documentElement["scroll"+e],n.body["scroll"+e],v["viewport"+e](n))},v["viewport"+e]=function(t){var n="client"+e,r=t.document,o=r.body,s=r.documentElement[n];return"CSS1Compat"===r.compatMode&&s||o&&o[n]||s}}));var w={position:"absolute",visibility:"hidden",display:"block"};function y(e){var t=void 0,n=arguments;return 0!==e.offsetWidth?t=j.apply(void 0,n):h(e,w,(function(){t=j.apply(void 0,n)})),t}function E(e,t,n){var r=n;if("object"!==(void 0===t?"undefined":o(t)))return void 0!==r?("number"==typeof r&&(r+="px"),void(e.style[t]=r)):p(e,t);for(var s in t)t.hasOwnProperty(s)&&E(e,s,t[s])}f(["width","height"],(function(e){var t=e.charAt(0).toUpperCase()+e.slice(1);v["outer"+t]=function(t,n){return t&&y(t,e,n?0:1)};var n="width"===e?["Left","Right"]:["Top","Bottom"];v[e]=function(t,r){return void 0===r?t&&y(t,e,-1):t?(p(t),b(t)&&(r+=g(t,["padding","border"],n)),E(t,e,r)):void 0}})),e.exports=r({getWindow:function(e){var t=e.ownerDocument||e;return t.defaultView||t.parentWindow},offset:function(e,t){if(void 0===t)return a(e);!function(e,t){"static"===E(e,"position")&&(e.style.position="relative");var n=a(e),r={},o=void 0,s=void 0;for(s in t)t.hasOwnProperty(s)&&(o=parseFloat(E(e,s))||0,r[s]=o+t[s]-n[s]);E(e,r)}(e,t)},isWindow:O,each:f,css:E,clone:function(e){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);if(e.overflow)for(var n in e)e.hasOwnProperty(n)&&(t.overflow[n]=e.overflow[n]);return t},scrollLeft:function(e,t){if(O(e)){if(void 0===t)return i(e);window.scrollTo(t,c(e))}else{if(void 0===t)return e.scrollLeft;e.scrollLeft=t}},scrollTop:function(e,t){if(O(e)){if(void 0===t)return c(e);window.scrollTo(i(e),t)}else{if(void 0===t)return e.scrollTop;e.scrollTop=t}},viewportWidth:0,viewportHeight:0},v)},,,,function(e,t){},function(e,t,n){"use strict";n.d(t,"b",(function(){return s})),n.d(t,"a",(function(){return c}));var r=n(20);const o=e=>Object(r.b)(e,"count")&&Object(r.b)(e,"description")&&Object(r.b)(e,"id")&&Object(r.b)(e,"name")&&Object(r.b)(e,"parent")&&Object(r.b)(e,"slug")&&"number"==typeof e.count&&"string"==typeof e.description&&"number"==typeof e.id&&"string"==typeof e.name&&"number"==typeof e.parent&&"string"==typeof e.slug,s=e=>Array.isArray(e)&&e.every(o),i=e=>Object(r.b)(e,"attribute")&&Object(r.b)(e,"operator")&&Object(r.b)(e,"slug")&&"string"==typeof e.attribute&&"string"==typeof e.operator&&Array.isArray(e.slug)&&e.slug.every(e=>"string"==typeof e),c=e=>Array.isArray(e)&&e.every(i)},function(e,t){},,,,,,,,,,,,,,,,,,,,function(e,t,n){e.exports=n(248)},function(e,t,n){"use strict";n.r(t);var r=n(48),o=n(160),s=n(51);Object(r.a)({selector:".wp-block-woocommerce-attribute-filter",Block:o.a,getProps:e=>({isEditor:!1,attributes:Object(s.g)(e.dataset)})})},,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(111),o=n(216),s=n(20),i=n(217);const c=e=>{if(!Object(o.a)())return{className:"",style:{}};const t=Object(s.a)(e)?e:{},n=Object(i.a)(t.style);return Object(r.__experimentalUseBorderProps)({...t,style:n})}},,,,,,function(e,t,n){"use strict";var r=n(0),o=n(15);const s=Object(r.createElement)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(r.createElement)(o.Path,{d:"M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"}));t.a=s},function(e,t,n){"use strict";var r=n(0),o=n(15);const s=Object(r.createElement)(o.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},Object(r.createElement)(o.Path,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"}));t.a=s},,function(e,t,n){"use strict";var r=n(0),o=n(5),s=n(4),i=n.n(s),c=n(1),a=n(11),l=n(60),u=n(13),d=n.n(u),p=n(283),f=n(44),b=n(37);function m({value:e,status:t,title:n,displayTransform:s,isBorderless:l=!1,disabled:u=!1,onClickRemove:d=o.noop,onMouseEnter:h,onMouseLeave:g,messages:O,termPosition:v,termsCount:j}){const w=Object(a.useInstanceId)(m),y=i()("components-form-token-field__token",{"is-error":"error"===t,"is-success":"success"===t,"is-validating":"validating"===t,"is-borderless":l,"is-disabled":u}),E=s(e),k=Object(c.sprintf)(
|
22 |
/* translators: 1: term name, 2: term position in a set of terms, 3: total term set count. */
|
23 |
-
Object(c.__)("%1$s (%2$s of %3$s)"),E,v,j);return Object(r.createElement)("span",{className:y,onMouseEnter:h,onMouseLeave:g,title:n},Object(r.createElement)("span",{className:"components-form-token-field__token-text",id:"components-form-token-field__token-text-"+w},Object(r.createElement)(b.a,{as:"span"},k),Object(r.createElement)("span",{"aria-hidden":"true"},E)),Object(r.createElement)(f.a,{className:"components-form-token-field__remove-token",icon:p.a,onClick:!u&&(()=>d({value:e})),label:O.remove,"aria-describedby":"components-form-token-field__token-text-"+w}))}var h=n(
|
24 |
/* translators: %d: number of results. */
|
25 |
Object(c._n)("%d result found, use up and down arrow keys to navigate.","%d results found, use up and down arrow keys to navigate.",o.length),o.length):Object(c.__)("No results."),"assertive")}}renderTokensAndInput(){const e=Object(o.map)(this.props.value,this.renderToken);return e.splice(this.getIndexOfInput(),0,this.renderInput()),e}renderToken(e,t,n){const o=this.getTokenValue(e),s=e.status?e.status:void 0,i=t+1,c=n.length;return Object(r.createElement)(m,{key:"token-"+o,value:o,status:s,title:e.title,displayTransform:this.props.displayTransform,onClickRemove:this.onTokenClickRemove,isBorderless:e.isBorderless||this.props.isBorderless,onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave,disabled:"error"!==s&&this.props.disabled,messages:this.props.messages,termsCount:c,termPosition:i})}renderInput(){const{autoCapitalize:e,autoComplete:t,maxLength:n,placeholder:o,value:s,instanceId:i}=this.props;let c={instanceId:i,autoCapitalize:e,autoComplete:t,placeholder:0===s.length?o:"",ref:this.bindInput,key:"input",disabled:this.props.disabled,value:this.state.incompleteTokenValue,onBlur:this.onBlur,isExpanded:this.state.isExpanded,selectedSuggestionIndex:this.state.selectedSuggestionIndex};return n&&s.length>=n||(c={...c,onChange:this.onInputChange}),Object(r.createElement)(h.a,c)}render(){const{disabled:e,label:t=Object(c.__)("Add item"),instanceId:n,className:o,__experimentalShowHowTo:s}=this.props,{isExpanded:a}=this.state,l=i()(o,"components-form-token-field__input-container",{"is-active":this.state.isActive,"is-disabled":e});let u={className:"components-form-token-field",tabIndex:"-1"};const d=this.getMatchingSuggestions();return e||(u=Object.assign({},u,{onKeyDown:this.onKeyDown,onKeyPress:this.onKeyPress,onFocus:this.onFocus})),Object(r.createElement)("div",u,Object(r.createElement)("label",{htmlFor:"components-form-token-input-"+n,className:"components-form-token-field__label"},t),Object(r.createElement)("div",{ref:this.bindTokensAndInput,className:l,tabIndex:"-1",onMouseDown:this.onContainerTouched,onTouchStart:this.onContainerTouched},this.renderTokensAndInput(),a&&Object(r.createElement)(g.a,{instanceId:n,match:this.props.saveTransform(this.state.incompleteTokenValue),displayTransform:this.props.displayTransform,suggestions:d,selectedIndex:this.state.selectedSuggestionIndex,scrollIntoView:this.state.selectedSuggestionScroll,onHover:this.onSuggestionHovered,onSelect:this.onSuggestionSelected})),s&&Object(r.createElement)("p",{id:"components-form-token-suggestions-howto-"+n,className:"components-form-token-field__help"},this.props.tokenizeOnSpace?Object(c.__)("Separate with commas, spaces, or the Enter key."):Object(c.__)("Separate with commas or the Enter key.")))}}y.defaultProps={suggestions:Object.freeze([]),maxSuggestions:100,value:Object.freeze([]),displayTransform:o.identity,saveTransform:e=>e.trim(),onChange:()=>{},onInputChange:()=>{},isBorderless:!1,disabled:!1,tokenizeOnSpace:!1,messages:{added:Object(c.__)("Item added."),removed:Object(c.__)("Item removed."),remove:Object(c.__)("Remove item"),__experimentalInvalid:Object(c.__)("Invalid item")},__experimentalExpandOnFocus:!1,__experimentalValidateInput:()=>!0,__experimentalShowHowTo:!0},t.a=j(Object(a.withInstanceId)(y))}]);
|
1 |
+
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=241)}([function(e,t){e.exports=window.wp.element},function(e,t){e.exports=window.wp.i18n},function(e,t){e.exports=window.wc.wcSettings},function(e,t){e.exports=window.wc.wcBlocksData},,function(e,t){e.exports=window.wp.data},function(e,t){e.exports=window.React},function(e,t,n){var r;!function(){"use strict";var n={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var s=typeof r;if("string"===s||"number"===s)e.push(r);else if(Array.isArray(r)){if(r.length){var i=o.apply(null,r);i&&e.push(i)}}else if("object"===s)if(r.toString===Object.prototype.toString)for(var c in r)n.call(r,c)&&r[c]&&e.push(c);else e.push(r.toString())}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(r=function(){return o}.apply(t,[]))||(e.exports=r)}()},function(e,t){e.exports=window.lodash},function(e,t){e.exports=window.wc.blocksCheckout},function(e,t,n){"use strict";function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}n.d(t,"a",(function(){return r}))},function(e,t){e.exports=window.wp.url},function(e,t){e.exports=window.wp.isShallowEqual},function(e,t){function n(){return e.exports=n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},e.exports.__esModule=!0,e.exports.default=e.exports,n.apply(this,arguments)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,n){"use strict";var r=n(16),o=n.n(r),s=n(0),i=n(6),c=n(1),a=n(42),l=e=>{let{imageUrl:t=a.l+"/block-error.svg",header:n=Object(c.__)("Oops!","woo-gutenberg-products-block"),text:r=Object(c.__)("There was an error loading the content.","woo-gutenberg-products-block"),errorMessage:o,errorMessagePrefix:i=Object(c.__)("Error:","woo-gutenberg-products-block"),button:l,showErrorBlock:u=!0}=e;return u?Object(s.createElement)("div",{className:"wc-block-error wc-block-components-error"},t&&Object(s.createElement)("img",{className:"wc-block-error__image wc-block-components-error__image",src:t,alt:""}),Object(s.createElement)("div",{className:"wc-block-error__content wc-block-components-error__content"},n&&Object(s.createElement)("p",{className:"wc-block-error__header wc-block-components-error__header"},n),r&&Object(s.createElement)("p",{className:"wc-block-error__text wc-block-components-error__text"},r),o&&Object(s.createElement)("p",{className:"wc-block-error__message wc-block-components-error__message"},i?i+" ":"",o),l&&Object(s.createElement)("p",{className:"wc-block-error__button wc-block-components-error__button"},l))):null};n(34);class u extends i.Component{constructor(){super(...arguments),o()(this,"state",{errorMessage:"",hasError:!1})}static getDerivedStateFromError(e){return void 0!==e.statusText&&void 0!==e.status?{errorMessage:Object(s.createElement)(s.Fragment,null,Object(s.createElement)("strong",null,e.status),": ",e.statusText),hasError:!0}:{errorMessage:e.message,hasError:!0}}render(){const{header:e,imageUrl:t,showErrorMessage:n=!0,showErrorBlock:r=!0,text:o,errorMessagePrefix:i,renderError:c,button:a}=this.props,{errorMessage:u,hasError:d}=this.state;return d?"function"==typeof c?c({errorMessage:u}):Object(s.createElement)(l,{showErrorBlock:r,errorMessage:n?u:null,header:e,imageUrl:t,text:o,errorMessagePrefix:i,button:a}):this.props.children}}t.a=u},function(e,t){e.exports=window.wp.compose},function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports},,function(e,t){e.exports=window.wp.primitives},function(e,t,n){"use strict";var r=n(0),o=n(7),s=n.n(o);t.a=e=>{let t,{label:n,screenReaderLabel:o,wrapperElement:i,wrapperProps:c={}}=e;const a=null!=n,l=null!=o;return!a&&l?(t=i||"span",c={...c,className:s()(c.className,"screen-reader-text")},Object(r.createElement)(t,c,o)):(t=i||r.Fragment,a&&l&&n!==o?Object(r.createElement)(t,c,Object(r.createElement)("span",{"aria-hidden":"true"},n),Object(r.createElement)("span",{className:"screen-reader-text"},o)):Object(r.createElement)(t,c,n))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return o}));const r=e=>!(e=>null===e)(e)&&e instanceof Object&&e.constructor===Object;function o(e,t){return r(e)&&t in e}},,function(e,t){e.exports=window.wp.htmlEntities},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(0);const o=Object(r.createContext)("page"),s=()=>Object(r.useContext)(o);o.Provider},,,function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(0),o=n(12),s=n.n(o);function i(e){const t=Object(r.useRef)(e);return s()(e,t.current)||(t.current=e),t.current}},function(e,t){e.exports=window.wp.deprecated},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));const r=e=>"string"==typeof e},function(e,t){e.exports=window.wp.a11y},function(e,t,n){"use strict";n.d(t,"a",(function(){return d})),n.d(t,"b",(function(){return p})),n.d(t,"c",(function(){return f}));var r=n(3),o=n(5),s=n(0),i=n(12),c=n.n(i),a=n(26),l=n(56),u=n(23);const d=e=>{const t=Object(u.a)();e=e||t;const n=Object(o.useSelect)(t=>t(r.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0),[e]),{setValueForQueryContext:i}=Object(o.useDispatch)(r.QUERY_STATE_STORE_KEY);return[n,Object(s.useCallback)(t=>{i(e,t)},[e,i])]},p=(e,t,n)=>{const i=Object(u.a)();n=n||i;const c=Object(o.useSelect)(o=>o(r.QUERY_STATE_STORE_KEY).getValueForQueryKey(n,e,t),[n,e]),{setQueryValue:a}=Object(o.useDispatch)(r.QUERY_STATE_STORE_KEY);return[c,Object(s.useCallback)(t=>{a(n,e,t)},[n,e,a])]},f=(e,t)=>{const n=Object(u.a)();t=t||n;const[r,o]=d(t),i=Object(a.a)(r),p=Object(a.a)(e),f=Object(l.a)(p),b=Object(s.useRef)(!1);return Object(s.useEffect)(()=>{c()(f,p)||(o(Object.assign({},i,p)),b.current=!0)},[i,p,f,o]),b.current?[r,o]:[e,o]}},,,,function(e,t){},,,function(e,t,n){"use strict";(function(e){var r=n(0);n(43);const o=Object(r.createContext)({slots:{},fills:{},registerSlot:()=>{void 0!==e&&e.env},updateSlot:()=>{},unregisterSlot:()=>{},registerFill:()=>{},unregisterFill:()=>{}});t.a=o}).call(this,n(99))},,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return s}));var r=n(0);const o=Object(r.createContext)({}),s=()=>{const{wrapper:e}=Object(r.useContext)(o);return t=>{e&&e.current&&(e.current.hidden=!t)}}},function(e,t,n){"use strict";n.d(t,"n",(function(){return s})),n.d(t,"l",(function(){return i})),n.d(t,"k",(function(){return c})),n.d(t,"m",(function(){return a})),n.d(t,"i",(function(){return l})),n.d(t,"d",(function(){return u})),n.d(t,"f",(function(){return d})),n.d(t,"j",(function(){return p})),n.d(t,"c",(function(){return f})),n.d(t,"e",(function(){return b})),n.d(t,"g",(function(){return m})),n.d(t,"a",(function(){return h})),n.d(t,"h",(function(){return g})),n.d(t,"b",(function(){return O}));var r,o=n(2);const s=Object(o.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),i=s.pluginUrl+"images/",c=s.pluginUrl+"build/",a=s.buildPhase,l=null===(r=o.STORE_PAGES.shop)||void 0===r?void 0:r.permalink,u=(o.STORE_PAGES.checkout.id,o.STORE_PAGES.checkout.permalink),d=o.STORE_PAGES.privacy.permalink,p=(o.STORE_PAGES.privacy.title,o.STORE_PAGES.terms.permalink),f=(o.STORE_PAGES.terms.title,o.STORE_PAGES.cart.id,o.STORE_PAGES.cart.permalink),b=o.STORE_PAGES.myaccount.permalink?o.STORE_PAGES.myaccount.permalink:Object(o.getSetting)("wpLoginUrl","/wp-login.php"),m=Object(o.getSetting)("shippingCountries",{}),h=Object(o.getSetting)("allowedCountries",{}),g=Object(o.getSetting)("shippingStates",{}),O=Object(o.getSetting)("allowedStates",{})},function(e,t){e.exports=window.wp.warning},function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(13),o=n.n(r),s=n(0),i=n(14);const c=[".wp-block-woocommerce-cart"],a=e=>{let{Block:t,containers:n,getProps:r=(()=>({})),getErrorBoundaryProps:c=(()=>({}))}=e;0!==n.length&&Array.prototype.forEach.call(n,(e,n)=>{const a=r(e,n),l=c(e,n),u={...e.dataset,...a.attributes||{}};(e=>{let{Block:t,container:n,attributes:r={},props:c={},errorBoundaryProps:a={}}=e;Object(s.render)(Object(s.createElement)(i.a,a,Object(s.createElement)(s.Suspense,{fallback:Object(s.createElement)("div",{className:"wc-block-placeholder"})},t&&Object(s.createElement)(t,o()({},c,{attributes:r})))),n,()=>{n.classList&&n.classList.remove("is-loading")})})({Block:t,container:e,props:a,attributes:u,errorBoundaryProps:l})})},l=e=>{const t=document.body.querySelectorAll(c.join(",")),{Block:n,getProps:r,getErrorBoundaryProps:o,selector:s}=e;(e=>{let{Block:t,getProps:n,getErrorBoundaryProps:r,selector:o,wrappers:s}=e;const i=document.body.querySelectorAll(o);s&&s.length>0&&Array.prototype.filter.call(i,e=>!((e,t)=>Array.prototype.some.call(t,t=>t.contains(e)&&!t.isSameNode(e)))(e,s)),a({Block:t,containers:i,getProps:n,getErrorBoundaryProps:r})})({Block:n,getProps:r,getErrorBoundaryProps:o,selector:s,wrappers:t}),Array.prototype.forEach.call(t,t=>{t.addEventListener("wc-blocks_render_blocks_frontend",()=>{(e=>{let{Block:t,getProps:n,getErrorBoundaryProps:r,selector:o,wrapper:s}=e;const i=s.querySelectorAll(o);a({Block:t,containers:i,getProps:n,getErrorBoundaryProps:r})})({...e,wrapper:t})})})}},,,function(e,t,n){"use strict";n.d(t,"d",(function(){return c})),n.d(t,"h",(function(){return a})),n.d(t,"b",(function(){return l})),n.d(t,"a",(function(){return u})),n.d(t,"e",(function(){return d})),n.d(t,"f",(function(){return p})),n.d(t,"c",(function(){return f})),n.d(t,"g",(function(){return b}));var r=n(11),o=n(66),s=n(28),i=n(118);function c(){return Math.floor(Math.random()*Date.now())}const a=e=>e.replace("pa_",""),l=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const n={};t.forEach(e=>{const{attribute:t,slug:r,operator:s}=e,i=a(t),c=r.join(","),l=`${o.b}${i}`,u="in"===s?"or":"and";n[`${o.a}${i}`]=c,n[l]=u});const s=Object(r.removeQueryArgs)(e,...Object.keys(n));return Object(r.addQueryArgs)(s,n)},u=e=>{let{currentCheckedFilters:t,hasSetFilterDefaultsFromUrl:n}=e;return n&&0===t.length},d=e=>{if(e){const t=Object(o.d)("filter_"+e.name);return"string"==typeof t?t.split(","):[]}return[]},p=(e,t)=>{const n=Object.entries(t).reduce((e,t)=>{let[n,r]=t;return n.includes("query_type")?e:{...e,[n]:r}},{});return Object.entries(n).reduce((t,n)=>{let[r,o]=n;return e[r]===o&&t},!0)},f=e=>e.trim().replace(/\s/g,"-").replace(/_/g,"-").replace(/-+/g,"-").replace(/[^a-zA-Z0-9-]/g,""),b=e=>({className:Object(s.a)(null==e?void 0:e.className)?e.className:"",attributeId:parseInt(Object(s.a)(null==e?void 0:e.attributeId)?e.attributeId:"0",10),showCounts:"false"!==(null==e?void 0:e.showCounts),queryType:Object(s.a)(null==e?void 0:e.queryType)&&e.queryType||i.attributes.queryType.default,heading:Object(s.a)(null==e?void 0:e.heading)?e.heading:"",headingLevel:Object(s.a)(null==e?void 0:e.headingLevel)&&parseInt(e.headingLevel,10)||i.attributes.headingLevel.default,displayStyle:Object(s.a)(null==e?void 0:e.displayStyle)&&e.displayStyle||i.attributes.displayStyle.default,showFilterButton:"true"===(null==e?void 0:e.showFilterButton),selectType:Object(s.a)(null==e?void 0:e.selectType)&&e.selectType||i.attributes.selectType.default,isPreview:!1})},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(6);function o(e,t,n){var o=this,s=Object(r.useRef)(null),i=Object(r.useRef)(0),c=Object(r.useRef)(null),a=Object(r.useRef)([]),l=Object(r.useRef)(),u=Object(r.useRef)(),d=Object(r.useRef)(e),p=Object(r.useRef)(!0);d.current=e;var f=!t&&0!==t&&"undefined"!=typeof window;if("function"!=typeof e)throw new TypeError("Expected a function");t=+t||0;var b=!!(n=n||{}).leading,m=!("trailing"in n)||!!n.trailing,h="maxWait"in n,g=h?Math.max(+n.maxWait||0,t):null;return Object(r.useEffect)((function(){return p.current=!0,function(){p.current=!1}}),[]),Object(r.useMemo)((function(){var e=function(e){var t=a.current,n=l.current;return a.current=l.current=null,i.current=e,u.current=d.current.apply(n,t)},n=function(e,t){f&&cancelAnimationFrame(c.current),c.current=f?requestAnimationFrame(e):setTimeout(e,t)},r=function(e){if(!p.current)return!1;var n=e-s.current,r=e-i.current;return!s.current||n>=t||n<0||h&&r>=g},O=function(t){return c.current=null,m&&a.current?e(t):(a.current=l.current=null,u.current)},v=function(){var e=Date.now();if(r(e))return O(e);if(p.current){var o=e-s.current,c=e-i.current,a=t-o,l=h?Math.min(a,g-c):a;n(v,l)}},j=function(){for(var d=[],f=0;f<arguments.length;f++)d[f]=arguments[f];var m=Date.now(),g=r(m);if(a.current=d,l.current=o,s.current=m,g){if(!c.current&&p.current)return i.current=s.current,n(v,t),b?e(s.current):u.current;if(h)return n(v,t),e(s.current)}return c.current||n(v,t),u.current};return j.cancel=function(){c.current&&(f?cancelAnimationFrame(c.current):clearTimeout(c.current)),i.current=0,a.current=s.current=l.current=c.current=null},j.isPending=function(){return!!c.current},j.flush=function(){return c.current?O(Date.now()):u.current},j}),[b,h,t,g,m,f])}},,,,,,function(e,t){e.exports=window.wp.keycodes},function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(3),o=n(5),s=n(0),i=n(26),c=n(70);const a=e=>{const{namespace:t,resourceName:n,resourceValues:a=[],query:l={},shouldSelect:u=!0}=e;if(!t||!n)throw new Error("The options object must have valid values for the namespace and the resource properties.");const d=Object(s.useRef)({results:[],isLoading:!0}),p=Object(i.a)(l),f=Object(i.a)(a),b=Object(c.a)(),m=Object(o.useSelect)(e=>{if(!u)return null;const o=e(r.COLLECTIONS_STORE_KEY),s=[t,n,p,f],i=o.getCollectionError(...s);if(i){if(!(i instanceof Error))throw new Error("TypeError: `error` object is not an instance of Error constructor");b(i)}return{results:o.getCollection(...s),isLoading:!o.hasFinishedResolution("getCollection",s)}},[t,n,f,p,u]);return null!==m&&(d.current=m),d.current}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(6);function o(e,t){const n=Object(r.useRef)();return Object(r.useEffect)(()=>{n.current===e||t&&!t(e,n.current)||(n.current=e)},[e,t]),n.current}},function(e,t,n){"use strict";var r=n(0),o=n(1),s=n(19);n(131),t.a=e=>{let{name:t,count:n}=e;return Object(r.createElement)(r.Fragment,null,t,null!==n&&Number.isFinite(n)&&Object(r.createElement)(s.a,{label:n.toString(),screenReaderLabel:Object(o.sprintf)(
|
2 |
/* translators: %s number of products. */
|
3 |
+
Object(o._n)("%s product","%s products",n,"woo-gutenberg-products-block"),n),wrapperElement:"span",wrapperProps:{className:"wc-filter-element-label-list-count"}}))}},function(e,t,n){"use strict";var r=n(7),o=n.n(r),s=n(0);t.a=Object(s.forwardRef)((function({as:e="div",className:t,...n},r){return function({as:e="div",...t}){return"function"==typeof t.children?t.children(t):Object(s.createElement)(e,t)}({as:e,className:o()("components-visually-hidden",t),...n,ref:r})}))},function(e,t){e.exports=window.wp.dom},,function(e,t,n){"use strict";var r=n(0);n(95),t.a=e=>{let{children:t}=e;return Object(r.createElement)("div",{className:"wc-block-filter-title-placeholder"},t)}},function(e,t,n){"use strict";var r=n(0),o=n(1),s=n(7),i=n.n(s),c=n(19);n(96),t.a=e=>{let{className:t,label:
|
4 |
/* translators: Reset button text for filters. */
|
5 |
+
n=Object(o.__)("Reset","woo-gutenberg-products-block"),onClick:s,screenReaderLabel:a=Object(o.__)("Reset filter","woo-gutenberg-products-block")}=e;return Object(r.createElement)("button",{className:i()("wc-block-components-filter-reset-button",t),onClick:s},Object(r.createElement)(c.a,{label:n,screenReaderLabel:a}))}},function(e,t,n){"use strict";var r=n(0),o=n(1),s=n(7),i=n.n(s),c=n(19);n(97),t.a=e=>{let{className:t,isLoading:n,disabled:s,label:
|
6 |
/* translators: Submit button text for filters. */
|
7 |
+
a=Object(o.__)("Apply","woo-gutenberg-products-block"),onClick:l,screenReaderLabel:u=Object(o.__)("Apply filter","woo-gutenberg-products-block")}=e;return Object(r.createElement)("button",{type:"submit",className:i()("wp-block-button__link","wc-block-filter-submit-button","wc-block-components-filter-submit-button",{"is-loading":n},t),disabled:s,onClick:l},Object(r.createElement)(c.a,{label:a,screenReaderLabel:u}))}},,function(e,t,n){"use strict";var r=n(10),o=n(0),s=n(18),i=function({icon:e,className:t,...n}){const s=["dashicon","dashicons","dashicons-"+e,t].filter(Boolean).join(" ");return Object(o.createElement)("span",Object(r.a)({className:s},n))};t.a=function({icon:e=null,size:t=24,...n}){if("string"==typeof e)return Object(o.createElement)(i,Object(r.a)({icon:e},n));if(Object(o.isValidElement)(e)&&i===e.type)return Object(o.cloneElement)(e,{...n});if("function"==typeof e)return e.prototype instanceof o.Component?Object(o.createElement)(e,{size:t,...n}):e({size:t,...n});if(e&&("svg"===e.type||e.type===s.SVG)){const r={width:t,height:t,...e.props,...n};return Object(o.createElement)(s.SVG,r)}return Object(o.isValidElement)(e)?Object(o.cloneElement)(e,{size:t,...n}):e}},function(e,t,n){"use strict";n.d(t,"b",(function(){return c})),n.d(t,"a",(function(){return a})),n.d(t,"d",(function(){return l})),n.d(t,"c",(function(){return u}));var r=n(11),o=n(2),s=n(68);const i=Object(o.getSettingWithCoercion)("is_rendering_php_template",!1,s.a),c="query_type_",a="filter_";function l(e){return window?Object(r.getQueryArg)(window.location.href,e):null}function u(e){i?window.location.href=e:window.history.replaceState({},"",e)}},,function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));const r=e=>"boolean"==typeof e},,function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(0);const o=()=>{const[,e]=Object(r.useState)();return Object(r.useCallback)(t=>{e(()=>{throw t})},[])}},,,,,,,,,,,,,,,,,,,,function(e,t,n){"use strict";var r=n(0),o=n(1),s=n(7),i=n.n(s),c=n(9);n(111),t.a=e=>{let{className:t,onChange:n,options:s=[],checked:a=[],isLoading:l=!1,isDisabled:u=!1,limit:d=10}=e;const[p,f]=Object(r.useState)(!1),b=Object(r.useMemo)(()=>[...Array(5)].map((e,t)=>Object(r.createElement)("li",{key:t,style:{width:Math.floor(75*Math.random())+25+"%"}})),[]),m=Object(r.useMemo)(()=>{const e=s.length-d;return!p&&Object(r.createElement)("li",{key:"show-more",className:"show-more"},Object(r.createElement)("button",{onClick:()=>{f(!0)},"aria-expanded":!1,"aria-label":Object(o.sprintf)(
|
8 |
/* translators: %s is referring the remaining count of options */
|
9 |
Object(o._n)("Show %s more option","Show %s more options",e,"woo-gutenberg-products-block"),e)},Object(o.sprintf)(
|
10 |
/* translators: %s number of options to reveal. */
|
11 |
+
Object(o._n)("Show %s more","Show %s more",e,"woo-gutenberg-products-block"),e)))},[s,d,p]),h=Object(r.useMemo)(()=>p&&Object(r.createElement)("li",{key:"show-less",className:"show-less"},Object(r.createElement)("button",{onClick:()=>{f(!1)},"aria-expanded":!0,"aria-label":Object(o.__)("Show less options","woo-gutenberg-products-block")},Object(o.__)("Show less","woo-gutenberg-products-block"))),[p]),g=Object(r.useMemo)(()=>{const e=s.length>d+5;return Object(r.createElement)(r.Fragment,null,s.map((t,o)=>Object(r.createElement)(r.Fragment,{key:t.value},Object(r.createElement)("li",e&&!p&&o>=d&&{hidden:!0},Object(r.createElement)(c.CheckboxControl,{id:t.value,className:"wc-block-checkbox-list__checkbox",label:t.label,checked:a.includes(t.value),onChange:()=>{n(t.value)},disabled:u})),e&&o===d-1&&m)),e&&h)},[s,n,a,p,d,h,m,u]),O=i()("wc-block-checkbox-list","wc-block-components-checkbox-list",{"is-loading":l},t);return Object(r.createElement)("ul",{className:O},l?b:g)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(6),o=n(48);function s(e,t){return e===t}function i(e){return"function"==typeof e?function(){return e}:e}function c(e,t,n){var c=n&&n.equalityFn||s,a=function(e){var t=Object(r.useState)(i(e)),n=t[0],o=t[1];return[n,Object(r.useCallback)((function(e){return o(i(e))}),[])]}(e),l=a[0],u=a[1],d=Object(o.a)(Object(r.useCallback)((function(e){return u(e)}),[u]),t,n),p=Object(r.useRef)(e);return c(p.current,e)||(d(e),p.current=e),[l,d]}},function(e,t,n){"use strict";var r=n(10),o=n(0),s=n(7),i=n.n(s),c=n(8),a=n(27),l=n.n(a),u=n(15),d=n(59),p=n(133),f=n(1);function b(e,t,n){const{defaultView:r}=t,{frameElement:o}=r;if(!o||t===n.ownerDocument)return e;const s=o.getBoundingClientRect();return new r.DOMRect(e.left+s.left,e.top+s.top,e.width,e.height)}let m=0;function h(e){const t=document.scrollingElement||document.body;e&&(m=t.scrollTop);const n=e?"add":"remove";t.classList[n]("lockscroll"),document.documentElement.classList[n]("lockscroll"),e||(t.scrollTop=m)}let g=0;function O(){return Object(o.useEffect)(()=>(0===g&&h(!0),++g,()=>{1===g&&h(!1),--g}),[]),null}var v=n(37);function j(e){const t=Object(o.useContext)(v.a),n=t.slots[e]||{},r=t.fills[e],s=Object(o.useMemo)(()=>r||[],[r]);return{...n,updateSlot:Object(o.useCallback)(n=>{t.updateSlot(e,n)},[e,t.updateSlot]),unregisterSlot:Object(o.useCallback)(n=>{t.unregisterSlot(e,n)},[e,t.unregisterSlot]),fills:s,registerFill:Object(o.useCallback)(n=>{t.registerFill(e,n)},[e,t.registerFill]),unregisterFill:Object(o.useCallback)(n=>{t.unregisterFill(e,n)},[e,t.unregisterFill])}}var w=Object(o.createContext)({registerSlot:()=>{},unregisterSlot:()=>{},registerFill:()=>{},unregisterFill:()=>{},getSlot:()=>{},getFills:()=>{},subscribe:()=>{}});function y({name:e,children:t,registerFill:n,unregisterFill:r}){const s=(e=>{const{getSlot:t,subscribe:n}=Object(o.useContext)(w),[r,s]=Object(o.useState)(t(e));return Object(o.useEffect)(()=>(s(t(e)),n(()=>{s(t(e))})),[e]),r})(e),i=Object(o.useRef)({name:e,children:t});return Object(o.useLayoutEffect)(()=>(n(e,i.current),()=>r(e,i.current)),[]),Object(o.useLayoutEffect)(()=>{i.current.children=t,s&&s.forceUpdate()},[t]),Object(o.useLayoutEffect)(()=>{e!==i.current.name&&(r(i.current.name,i.current),i.current.name=e,n(e,i.current))},[e]),s&&s.node?(Object(c.isFunction)(t)&&(t=t(s.props.fillProps)),Object(o.createPortal)(t,s.node)):null}var E=e=>Object(o.createElement)(w.Consumer,null,({registerFill:t,unregisterFill:n})=>Object(o.createElement)(y,Object(r.a)({},e,{registerFill:t,unregisterFill:n})));class k extends o.Component{constructor(){super(...arguments),this.isUnmounted=!1,this.bindNode=this.bindNode.bind(this)}componentDidMount(){const{registerSlot:e}=this.props;e(this.props.name,this)}componentWillUnmount(){const{unregisterSlot:e}=this.props;this.isUnmounted=!0,e(this.props.name,this)}componentDidUpdate(e){const{name:t,unregisterSlot:n,registerSlot:r}=this.props;e.name!==t&&(n(e.name),r(t,this))}bindNode(e){this.node=e}forceUpdate(){this.isUnmounted||super.forceUpdate()}render(){const{children:e,name:t,fillProps:n={},getFills:r}=this.props,s=Object(c.map)(r(t,this),e=>{const t=Object(c.isFunction)(e.children)?e.children(n):e.children;return o.Children.map(t,(e,t)=>{if(!e||Object(c.isString)(e))return e;const n=e.key||t;return Object(o.cloneElement)(e,{key:n})})}).filter(Object(c.negate)(o.isEmptyElement));return Object(o.createElement)(o.Fragment,null,Object(c.isFunction)(e)?e(s):s)}}var _=e=>Object(o.createElement)(w.Consumer,null,({registerSlot:t,unregisterSlot:n,getFills:s})=>Object(o.createElement)(k,Object(r.a)({},e,{registerSlot:t,unregisterSlot:n,getFills:s})));function S(){const[,e]=Object(o.useState)({}),t=Object(o.useRef)(!0);return Object(o.useEffect)(()=>()=>{t.current=!1},[]),()=>{t.current&&e({})}}function x({name:e,children:t}){const n=j(e),r=Object(o.useRef)({rerender:S()});return Object(o.useEffect)(()=>(n.registerFill(r),()=>{n.unregisterFill(r)}),[n.registerFill,n.unregisterFill]),n.ref&&n.ref.current?("function"==typeof t&&(t=t(n.fillProps)),Object(o.createPortal)(t,n.ref.current)):null}var T=Object(o.forwardRef)((function({name:e,fillProps:t={},as:n="div",...s},i){const c=Object(o.useContext)(v.a),a=Object(o.useRef)();return Object(o.useLayoutEffect)(()=>(c.registerSlot(e,a,t),()=>{c.unregisterSlot(e,a)}),[c.registerSlot,c.unregisterSlot,e]),Object(o.useLayoutEffect)(()=>{c.updateSlot(e,t)}),Object(o.createElement)(n,Object(r.a)({ref:Object(u.useMergeRefs)([i,a])},s))}));function C(e){return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(E,e),Object(o.createElement)(x,e))}n(12),o.Component;const L=Object(o.forwardRef)(({bubblesVirtually:e,...t},n)=>e?Object(o.createElement)(T,Object(r.a)({},t,{ref:n})):Object(o.createElement)(_,t));function I(e){return"appear"===e?"top":"left"}function A(e,t){const{paddingTop:n,paddingBottom:r,paddingLeft:o,paddingRight:s}=(i=t).ownerDocument.defaultView.getComputedStyle(i);var i;const c=n?parseInt(n,10):0,a=r?parseInt(r,10):0,l=o?parseInt(o,10):0,u=s?parseInt(s,10):0;return{x:e.left+l,y:e.top+c,width:e.width-l-u,height:e.height-c-a,left:e.left+l,right:e.right-u,top:e.top+c,bottom:e.bottom-a}}function R(e,t,n){n?e.getAttribute(t)!==n&&e.setAttribute(t,n):e.hasAttribute(t)&&e.removeAttribute(t)}function F(e,t,n=""){e.style[t]!==n&&(e.style[t]=n)}function P(e,t,n){n?e.classList.contains(t)||e.classList.add(t):e.classList.contains(t)&&e.classList.remove(t)}const N=Object(o.forwardRef)(({headerTitle:e,onClose:t,children:n,className:s,noArrow:c=!0,isAlternate:a,position:m="bottom right",range:h,focusOnMount:g="firstElement",anchorRef:v,shouldAnchorIncludePadding:w,anchorRect:y,getAnchorRect:E,expandOnMobile:k,animate:_=!0,onClickOutside:S,onFocusOutside:x,__unstableStickyBoundaryElement:T,__unstableSlotName:L="Popover",__unstableObserveElement:N,__unstableBoundaryParent:M,__unstableForcePosition:B,__unstableForceXAlignment:D,...V},W)=>{const H=Object(o.useRef)(null),q=Object(o.useRef)(null),z=Object(o.useRef)(),K=Object(u.useViewportMatch)("medium","<"),[U,$]=Object(o.useState)(),Q=j(L),Y=k&&K,[J,X]=Object(u.useResizeObserver)();c=Y||c,Object(o.useLayoutEffect)(()=>{if(Y)return P(z.current,"is-without-arrow",c),P(z.current,"is-alternate",a),R(z.current,"data-x-axis"),R(z.current,"data-y-axis"),F(z.current,"top"),F(z.current,"left"),F(q.current,"maxHeight"),void F(q.current,"maxWidth");const e=()=>{if(!z.current||!q.current)return;let e=function(e,t,n,r=!1,o,s){if(t)return t;if(n){if(!e.current)return;const t=n(e.current);return b(t,t.ownerDocument||e.current.ownerDocument,s)}if(!1!==r){if(!(r&&window.Range&&window.Element&&window.DOMRect))return;if("function"==typeof(null==r?void 0:r.cloneRange))return b(Object(d.getRectangleFromRange)(r),r.endContainer.ownerDocument,s);if("function"==typeof(null==r?void 0:r.getBoundingClientRect)){const e=b(r.getBoundingClientRect(),r.ownerDocument,s);return o?e:A(e,r)}const{top:e,bottom:t}=r,n=e.getBoundingClientRect(),i=t.getBoundingClientRect(),c=b(new window.DOMRect(n.left,n.top,n.width,i.bottom-n.top),e.ownerDocument,s);return o?c:A(c,r)}if(!e.current)return;const{parentNode:i}=e.current,c=i.getBoundingClientRect();return o?c:A(c,i)}(H,y,E,v,w,z.current);if(!e)return;const{offsetParent:t,ownerDocument:n}=z.current;let r,o=0;if(t&&t!==n.body){const n=t.getBoundingClientRect();o=n.top,e=new window.DOMRect(e.left-n.left,e.top-n.top,e.width,e.height)}var s;M&&(r=null===(s=z.current.closest(".popover-slot"))||void 0===s?void 0:s.parentNode);const i=X.height?X:q.current.getBoundingClientRect(),{popoverTop:l,popoverLeft:u,xAxis:p,yAxis:h,contentHeight:g,contentWidth:O}=function(e,t,n="top",r,o,s,i,c,a){const[l,u="center",d]=n.split(" "),p=function(e,t,n,r,o,s,i,c){const{height:a}=t;if(o){const t=o.getBoundingClientRect().top+a-i;if(e.top<=t)return{yAxis:n,popoverTop:Math.min(e.bottom,t)}}let l=e.top+e.height/2;"bottom"===r?l=e.bottom:"top"===r&&(l=e.top);const u={popoverTop:l,contentHeight:(l-a/2>0?a/2:l)+(l+a/2>window.innerHeight?window.innerHeight-l:a/2)},d={popoverTop:e.top,contentHeight:e.top-10-a>0?a:e.top-10},p={popoverTop:e.bottom,contentHeight:e.bottom+10+a>window.innerHeight?window.innerHeight-10-e.bottom:a};let f,b=n,m=null;if(!o&&!c)if("middle"===n&&u.contentHeight===a)b="middle";else if("top"===n&&d.contentHeight===a)b="top";else if("bottom"===n&&p.contentHeight===a)b="bottom";else{b=d.contentHeight>p.contentHeight?"top":"bottom";const e="top"===b?d.contentHeight:p.contentHeight;m=e!==a?e:null}return f="middle"===b?u.popoverTop:"top"===b?d.popoverTop:p.popoverTop,{yAxis:b,popoverTop:f,contentHeight:m}}(e,t,l,d,r,0,s,c);return{...function(e,t,n,r,o,s,i,c,a){const{width:l}=t;"left"===n&&Object(f.isRTL)()?n="right":"right"===n&&Object(f.isRTL)()&&(n="left"),"left"===r&&Object(f.isRTL)()?r="right":"right"===r&&Object(f.isRTL)()&&(r="left");const u=Math.round(e.left+e.width/2),d={popoverLeft:u,contentWidth:(u-l/2>0?l/2:u)+(u+l/2>window.innerWidth?window.innerWidth-u:l/2)};let p=e.left;"right"===r?p=e.right:"middle"===s||a||(p=u);let b=e.right;"left"===r?b=e.left:"middle"===s||a||(b=u);const m={popoverLeft:p,contentWidth:p-l>0?l:p},h={popoverLeft:b,contentWidth:b+l>window.innerWidth?window.innerWidth-b:l};let g,O=n,v=null;if(!o&&!c)if("center"===n&&d.contentWidth===l)O="center";else if("left"===n&&m.contentWidth===l)O="left";else if("right"===n&&h.contentWidth===l)O="right";else{O=m.contentWidth>h.contentWidth?"left":"right";const e="left"===O?m.contentWidth:h.contentWidth;l>window.innerWidth&&(v=window.innerWidth),e!==l&&(O="center",d.popoverLeft=window.innerWidth/2)}if(g="center"===O?d.popoverLeft:"left"===O?m.popoverLeft:h.popoverLeft,i){const e=i.getBoundingClientRect();g=Math.min(g,e.right-l),Object(f.isRTL)()||(g=Math.max(g,0))}return{xAxis:O,popoverLeft:g,contentWidth:v}}(e,t,u,d,r,p.yAxis,i,c,a),...p}}(e,i,m,T,z.current,o,r,B,D);"number"==typeof l&&"number"==typeof u&&(F(z.current,"top",l+"px"),F(z.current,"left",u+"px")),P(z.current,"is-without-arrow",c||"center"===p&&"middle"===h),P(z.current,"is-alternate",a),R(z.current,"data-x-axis",p),R(z.current,"data-y-axis",h),F(q.current,"maxHeight","number"==typeof g?g+"px":""),F(q.current,"maxWidth","number"==typeof O?O+"px":""),$(({left:"right",right:"left"}[p]||"center")+" "+({top:"bottom",bottom:"top"}[h]||"middle"))};e();const{ownerDocument:t}=z.current,{defaultView:n}=t,r=n.setInterval(e,500);let o;const s=()=>{n.cancelAnimationFrame(o),o=n.requestAnimationFrame(e)};n.addEventListener("click",s),n.addEventListener("resize",e),n.addEventListener("scroll",e,!0);const i=function(e){if(e)return e.endContainer?e.endContainer.ownerDocument:e.top?e.top.ownerDocument:e.ownerDocument}(v);let l;return i&&i!==t&&(i.defaultView.addEventListener("resize",e),i.defaultView.addEventListener("scroll",e,!0)),N&&(l=new n.MutationObserver(e),l.observe(N,{attributes:!0})),()=>{n.clearInterval(r),n.removeEventListener("resize",e),n.removeEventListener("scroll",e,!0),n.removeEventListener("click",s),n.cancelAnimationFrame(o),i&&i!==t&&(i.defaultView.removeEventListener("resize",e),i.defaultView.removeEventListener("scroll",e,!0)),l&&l.disconnect()}},[Y,y,E,v,w,m,X,T,N,M]);const Z=(e,n)=>{if("focus-outside"===e&&x)x(n);else if("focus-outside"===e&&S){const e=new window.MouseEvent("click");Object.defineProperty(e,"target",{get:()=>n.relatedTarget}),l()("Popover onClickOutside prop",{since:"5.3",alternative:"onFocusOutside"}),S(e)}else t&&t()},[ee,te]=Object(u.__experimentalUseDialog)({focusOnMount:g,__unstableOnClose:Z,onClose:Z}),ne=Object(u.useMergeRefs)([z,ee,W]),re=Boolean(_&&U)&&function(e){if("loading"===e.type)return i()("components-animate__loading");const{type:t,origin:n=I(t)}=e;if("appear"===t){const[e,t="center"]=n.split(" ");return i()("components-animate__appear",{["is-from-"+t]:"center"!==t,["is-from-"+e]:"middle"!==e})}return"slide-in"===t?i()("components-animate__slide-in","is-from-"+n):void 0}({type:"appear",origin:U});let oe=Object(o.createElement)("div",Object(r.a)({className:i()("components-popover",s,re,{"is-expanded":Y,"is-without-arrow":c,"is-alternate":a})},V,{ref:ne},te,{tabIndex:"-1"}),Y&&Object(o.createElement)(O,null),Y&&Object(o.createElement)("div",{className:"components-popover__header"},Object(o.createElement)("span",{className:"components-popover__header-title"},e),Object(o.createElement)(G,{className:"components-popover__close",icon:p.a,onClick:t})),Object(o.createElement)("div",{ref:q,className:"components-popover__content"},Object(o.createElement)("div",{style:{position:"relative"}},J,n)));return Q.ref&&(oe=Object(o.createElement)(C,{name:L},oe)),v||y?oe:Object(o.createElement)("span",{ref:H},oe)});N.Slot=Object(o.forwardRef)((function({name:e="Popover"},t){return Object(o.createElement)(L,{bubblesVirtually:!0,name:e,className:"popover-slot",ref:t})}));var M=N,B=function({shortcut:e,className:t}){if(!e)return null;let n,r;return Object(c.isString)(e)&&(n=e),Object(c.isObject)(e)&&(n=e.display,r=e.ariaLabel),Object(o.createElement)("span",{className:t,"aria-label":r},n)};const D=Object(o.createElement)("div",{className:"event-catcher"}),V=({eventHandlers:e,child:t,childrenWithPopover:n})=>Object(o.cloneElement)(Object(o.createElement)("span",{className:"disabled-element-wrapper"},Object(o.cloneElement)(D,e),Object(o.cloneElement)(t,{children:n}),","),e),W=({child:e,eventHandlers:t,childrenWithPopover:n})=>Object(o.cloneElement)(e,{...t,children:n}),H=(e,t,n)=>{if(1!==o.Children.count(e))return;const r=o.Children.only(e);"function"==typeof r.props[t]&&r.props[t](n)};var q=function({children:e,position:t,text:n,shortcut:r}){const[s,i]=Object(o.useState)(!1),[a,l]=Object(o.useState)(!1),d=Object(u.useDebounce)(l,700),p=t=>{H(e,"onMouseDown",t),document.addEventListener("mouseup",m),i(!0)},f=t=>{H(e,"onMouseUp",t),document.removeEventListener("mouseup",m),i(!1)},b=e=>"mouseUp"===e?f:"mouseDown"===e?p:void 0,m=b("mouseUp"),h=(t,n)=>r=>{if(H(e,t,r),r.currentTarget.disabled)return;if("focus"===r.type&&s)return;d.cancel();const o=Object(c.includes)(["focus","mouseenter"],r.type);o!==a&&(n?d(o):l(o))},g=()=>{d.cancel(),document.removeEventListener("mouseup",m)};if(Object(o.useEffect)(()=>g,[]),1!==o.Children.count(e))return e;const O={onMouseEnter:h("onMouseEnter",!0),onMouseLeave:h("onMouseLeave"),onClick:h("onClick"),onFocus:h("onFocus"),onBlur:h("onBlur"),onMouseDown:b("mouseDown")},v=o.Children.only(e),{children:j,disabled:w}=v.props;return(w?V:W)({child:v,eventHandlers:O,childrenWithPopover:(({grandchildren:e,isOver:t,position:n,text:r,shortcut:s})=>Object(o.concatChildren)(e,t&&Object(o.createElement)(M,{focusOnMount:!1,position:n,className:"components-tooltip","aria-hidden":"true",animate:!1,noArrow:!0},r,Object(o.createElement)(B,{className:"components-tooltip__shortcut",shortcut:s}))))({grandchildren:j,isOver:a,position:t,text:n,shortcut:r})})},z=n(65),K=n(58);const U=["onMouseDown","onClick"];var G=t.a=Object(o.forwardRef)((function(e,t){const{href:n,target:s,isSmall:a,isPressed:u,isBusy:d,isDestructive:p,className:f,disabled:b,icon:m,iconPosition:h="left",iconSize:g,showTooltip:O,tooltipPosition:v,shortcut:j,label:w,children:y,text:E,variant:k,__experimentalIsFocusable:_,describedBy:S,...x}=function({isDefault:e,isPrimary:t,isSecondary:n,isTertiary:r,isLink:o,variant:s,...i}){let c=s;var a,u,d,p,f;return t&&(null!==(a=c)&&void 0!==a||(c="primary")),r&&(null!==(u=c)&&void 0!==u||(c="tertiary")),n&&(null!==(d=c)&&void 0!==d||(c="secondary")),e&&(l()("Button isDefault prop",{since:"5.4",alternative:'variant="secondary"'}),null!==(p=c)&&void 0!==p||(c="secondary")),o&&(null!==(f=c)&&void 0!==f||(c="link")),{...i,variant:c}}(e),T=i()("components-button",f,{"is-secondary":"secondary"===k,"is-primary":"primary"===k,"is-small":a,"is-tertiary":"tertiary"===k,"is-pressed":u,"is-busy":d,"is-link":"link"===k,"is-destructive":p,"has-text":!!m&&!!y,"has-icon":!!m}),C=b&&!_,L=void 0===n||C?"button":"a",I="a"===L?{href:n,target:s}:{type:"button",disabled:C,"aria-pressed":u};if(b&&_){I["aria-disabled"]=!0;for(const e of U)x[e]=e=>{e.stopPropagation(),e.preventDefault()}}const A=!C&&(O&&w||j||!!w&&(!y||Object(c.isArray)(y)&&!y.length)&&!1!==O),R=S?Object(c.uniqueId)():null,F=x["aria-describedby"]||R,P=Object(o.createElement)(L,Object(r.a)({},I,x,{className:T,"aria-label":x["aria-label"]||w,"aria-describedby":F,ref:t}),m&&"left"===h&&Object(o.createElement)(z.a,{icon:m,size:g}),E&&Object(o.createElement)(o.Fragment,null,E),m&&"right"===h&&Object(o.createElement)(z.a,{icon:m,size:g}),y);return A?Object(o.createElement)(o.Fragment,null,Object(o.createElement)(q,{text:S||w,shortcut:j,position:v},P),S&&Object(o.createElement)(K.a,null,Object(o.createElement)("span",{id:R},S))):Object(o.createElement)(o.Fragment,null,P,S&&Object(o.createElement)(K.a,null,Object(o.createElement)("span",{id:R},S)))}))},,function(e,t){e.exports=window.wp.blocks},function(e,t){},function(e,t){},function(e,t){},,function(e,t){var n,r,o=e.exports={};function s(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function c(e){if(n===setTimeout)return setTimeout(e,0);if((n===s||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:s}catch(e){n=s}try{r="function"==typeof clearTimeout?clearTimeout:i}catch(e){r=i}}();var a,l=[],u=!1,d=-1;function p(){u&&a&&(u=!1,a.length?l=a.concat(l):d=-1,l.length&&f())}function f(){if(!u){var e=c(p);u=!0;for(var t=l.length;t;){for(a=l,l=[];++d<t;)a&&a[d].run();d=-1,t=l.length}a=null,u=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===i||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function b(e,t){this.fun=e,this.array=t}function m(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];l.push(new b(e,t)),1!==l.length||u||c(f)},b.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=m,o.addListener=m,o.once=m,o.off=m,o.removeListener=m,o.removeAllListeners=m,o.emit=m,o.prependListener=m,o.prependOnceListener=m,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},,,,,function(e,t){e.exports=window.wp.blockEditor},,,function(e,t,n){"use strict";var r=n(0);t.a=function(e){let{icon:t,size:n=24,...o}=e;return Object(r.cloneElement)(t,{width:n,height:n,...o})}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return s}));var r=n(8);const o=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";const s=e.filter(e=>e.attribute===n.taxonomy),i=s.length?s[0]:null;if(!(i&&i.slug&&Array.isArray(i.slug)&&i.slug.includes(o)))return;const c=i.slug.filter(e=>e!==o),a=e.filter(e=>e.attribute!==n.taxonomy);c.length>0&&(i.slug=c.sort(),a.push(i)),t(Object(r.sortBy)(a,"attribute"))},s=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"in";if(!n||!n.taxonomy)return[];const i=e.filter(e=>e.attribute!==n.taxonomy);return 0===o.length?t(i):(i.push({attribute:n.taxonomy,operator:s,slug:o.map(e=>{let{slug:t}=e;return t}).sort()}),t(Object(r.sortBy)(i,"attribute"))),i}},,,function(e,t){},,function(e,t,n){"use strict";n.d(t,"a",(function(){return s})),n.d(t,"b",(function(){return i}));var r=n(2);const o=Object(r.getSetting)("attributes",[]).reduce((e,t)=>{const n=(r=t)&&r.attribute_name?{id:parseInt(r.attribute_id,10),name:r.attribute_name,taxonomy:"pa_"+r.attribute_name,label:r.attribute_label}:null;var r;return n&&n.id&&e.push(n),e},[]),s=e=>{if(e)return o.find(t=>t.id===e)},i=e=>{if(e)return o.find(t=>t.taxonomy===e)}},,,,,function(e){e.exports=JSON.parse('{"name":"woocommerce/attribute-filter","version":"1.0.0","title":"Filter by Attribute Controls","description":"Enable customers to filter the product grid by selecting one or more attributes, such as color.","category":"woocommerce","keywords":["WooCommerce"],"supports":{"html":false,"color":{"text":true,"background":false},"inserter":false,"lock":false},"example":{"attributes":{"isPreview":true}},"attributes":{"className":{"type":"string","default":""},"attributeId":{"type":"number","default":0},"showCounts":{"type":"boolean","default":true},"queryType":{"type":"string","default":"or"},"headingLevel":{"type":"number","default":3},"displayStyle":{"type":"string","default":"list"},"showFilterButton":{"type":"boolean","default":false},"selectType":{"type":"string","default":"multiple"},"isPreview":{"type":"boolean","default":false}},"textdomain":"woo-gutenberg-products-block","apiVersion":2,"$schema":"https://schemas.wp.org/trunk/block.json"}')},,,,,,,,,,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return d}));var r=n(0),o=n(91),s=n(8),i=n(26),c=n(20),a=n(30),l=n(55),u=n(23);const d=e=>{let{queryAttribute:t,queryPrices:n,queryStock:d,queryRating:p,queryState:f,productIds:b}=e,m=Object(u.a)();m+="-collection-data";const[h]=Object(a.a)(m),[g,O]=Object(a.b)("calculate_attribute_counts",[],m),[v,j]=Object(a.b)("calculate_price_range",null,m),[w,y]=Object(a.b)("calculate_stock_status_counts",null,m),[E,k]=Object(a.b)("calculate_rating_counts",null,m),_=Object(i.a)(t||{}),S=Object(i.a)(n),x=Object(i.a)(d),T=Object(i.a)(p);Object(r.useEffect)(()=>{"object"==typeof _&&Object.keys(_).length&&(g.find(e=>Object(c.b)(_,"taxonomy")&&e.taxonomy===_.taxonomy)||O([...g,_]))},[_,g,O]),Object(r.useEffect)(()=>{v!==S&&void 0!==S&&j(S)},[S,j,v]),Object(r.useEffect)(()=>{w!==x&&void 0!==x&&y(x)},[x,y,w]),Object(r.useEffect)(()=>{E!==T&&void 0!==T&&k(T)},[T,k,E]);const[C,L]=Object(r.useState)(!1),[I]=Object(o.a)(C,200);C||L(!0);const A=Object(r.useMemo)(()=>(e=>{const t=e;return Array.isArray(e.calculate_attribute_counts)&&(t.calculate_attribute_counts=Object(s.sortBy)(e.calculate_attribute_counts.map(e=>{let{taxonomy:t,queryType:n}=e;return{taxonomy:t,query_type:n}}),["taxonomy","query_type"])),t})(h),[h]);return Object(l.a)({namespace:"/wc/store/v1",resourceName:"products/collection-data",query:{...f,page:void 0,per_page:void 0,orderby:void 0,order:void 0,...!Object(s.isEmpty)(b)&&{include:b},...A},shouldSelect:I})}},function(e,t){},,function(e,t,n){"use strict";var r=n(0),o=n(18);const s=Object(r.createElement)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(r.createElement)(o.Path,{d:"M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"}));t.a=s},,,,,,,,,,,function(e,t,n){"use strict";var r=n(10),o=n(0),s=n(7),i=n.n(s);class c extends o.Component{constructor(){super(...arguments),this.onChange=this.onChange.bind(this),this.bindInput=this.bindInput.bind(this)}focus(){this.input.focus()}hasFocus(){return this.input===this.input.ownerDocument.activeElement}bindInput(e){this.input=e}onChange(e){this.props.onChange({value:e.target.value})}render(){const{value:e,isExpanded:t,instanceId:n,selectedSuggestionIndex:s,className:c,...a}=this.props,l=e?e.length+1:0;return Object(o.createElement)("input",Object(r.a)({ref:this.bindInput,id:"components-form-token-input-"+n,type:"text"},a,{value:e||"",onChange:this.onChange,size:l,className:i()(c,"components-form-token-field__input"),autoComplete:"off",role:"combobox","aria-expanded":t,"aria-autocomplete":"list","aria-owns":t?"components-form-token-suggestions-"+n:void 0,"aria-activedescendant":-1!==s?`components-form-token-suggestions-${n}-${s}`:void 0,"aria-describedby":"components-form-token-suggestions-howto-"+n}))}}t.a=c},function(e,t,n){"use strict";var r=n(0),o=n(8),s=n(146),i=n.n(s),c=n(7),a=n.n(c),l=n(15);class u extends r.Component{constructor(){super(...arguments),this.handleMouseDown=this.handleMouseDown.bind(this),this.bindList=this.bindList.bind(this)}componentDidUpdate(){this.props.selectedIndex>-1&&this.props.scrollIntoView&&this.list.children[this.props.selectedIndex]&&(this.scrollingIntoView=!0,i()(this.list.children[this.props.selectedIndex],this.list,{onlyScrollIfNeeded:!0}),this.props.setTimeout(()=>{this.scrollingIntoView=!1},100))}bindList(e){this.list=e}handleHover(e){return()=>{this.scrollingIntoView||this.props.onHover(e)}}handleClick(e){return()=>{this.props.onSelect(e)}}handleMouseDown(e){e.preventDefault()}computeSuggestionMatch(e){const t=this.props.displayTransform(this.props.match||"").toLocaleLowerCase();if(0===t.length)return null;const n=(e=this.props.displayTransform(e)).toLocaleLowerCase().indexOf(t);return{suggestionBeforeMatch:e.substring(0,n),suggestionMatch:e.substring(n,n+t.length),suggestionAfterMatch:e.substring(n+t.length)}}render(){return Object(r.createElement)("ul",{ref:this.bindList,className:"components-form-token-field__suggestions-list",id:"components-form-token-suggestions-"+this.props.instanceId,role:"listbox"},Object(o.map)(this.props.suggestions,(e,t)=>{const n=this.computeSuggestionMatch(e),o=a()("components-form-token-field__suggestion",{"is-selected":t===this.props.selectedIndex});return Object(r.createElement)("li",{id:`components-form-token-suggestions-${this.props.instanceId}-${t}`,role:"option",className:o,key:null!=e&&e.value?e.value:this.props.displayTransform(e),onMouseDown:this.handleMouseDown,onClick:this.handleClick(e),onMouseEnter:this.handleHover(e),"aria-selected":t===this.props.selectedIndex},n?Object(r.createElement)("span",{"aria-label":this.props.displayTransform(e)},n.suggestionBeforeMatch,Object(r.createElement)("strong",{className:"components-form-token-field__suggestion-match"},n.suggestionMatch),n.suggestionAfterMatch):this.props.displayTransform(e))}))}}u.defaultProps={match:"",onHover:()=>{},onSelect:()=>{},suggestions:Object.freeze([])},t.a=Object(l.withSafeTimeout)(u)},function(e,t,n){"use strict";e.exports=n(215)},,,,,,,,,function(e,t,n){"use strict";var r=n(0),o=n(1),s=n(271),i=n(26),c=n(56),a=n(30),l=n(55),u=n(130),d=n(57),p=n(62),f=n(63),b=n(12),m=n.n(b),h=n(22),g=n(277),O=n(2),v=n(11),j=n(68),w=n(28),y=n(20),E=n(220),k=n(107),_=n(280),S=n(66),x=n(8),T=n(13),C=n.n(T),L=n(282),I=n(7),A=n.n(I);n(221);var R=e=>{let{className:t,style:n,suggestions:o,multiple:s=!0,saveTransform:i=(e=>e.trim().replace(/\s/g,"-")),messages:c={},validateInput:a=(e=>o.includes(e)),label:l="",...u}=e;return Object(r.createElement)("div",{className:A()("wc-blocks-components-form-token-field-wrapper",t,{"single-selection":!s}),style:n},Object(r.createElement)(L.a,C()({label:l,__experimentalExpandOnFocus:!0,__experimentalShowHowTo:!1,__experimentalValidateInput:a,saveTransform:i,maxLength:s?void 0:1,suggestions:o,messages:c},u)))},F=n(61),P=n(113),N=n(108);const M=[{value:"preview-1",formattedValue:"preview-1",name:"Blue",label:Object(r.createElement)(d.a,{name:"Blue",count:3}),textLabel:"Blue (3)"},{value:"preview-2",formattedValue:"preview-2",name:"Green",label:Object(r.createElement)(d.a,{name:"Green",count:3}),textLabel:"Green (3)"},{value:"preview-3",formattedValue:"preview-3",name:"Red",label:Object(r.createElement)(d.a,{name:"Red",count:2}),textLabel:"Red (2)"}],B={id:0,name:"preview",taxonomy:"preview",label:"Preview"};n(219);var D=n(47),V=n(90),W=e=>{let{isLoading:t=!1,options:n,checked:o,onChange:s}=e;return t?Object(r.createElement)(r.Fragment,null,Object(r.createElement)("span",{className:"is-loading"}),Object(r.createElement)("span",{className:"is-loading"})):Object(r.createElement)(V.a,{className:"wc-block-attribute-filter-list",options:n,checked:o,onChange:s,isLoading:t,isDisabled:t})},H=n(41);t.a=e=>{let{attributes:t,isEditor:n=!1}=e;const b=Object(O.getSettingWithCoercion)("has_filterable_products",!1,j.a),T=Object(O.getSettingWithCoercion)("is_rendering_php_template",!1,j.a),C=Object(O.getSettingWithCoercion)("page_url",window.location.href,w.a),L=n?[]:Object(O.getSettingWithCoercion)("product_ids",[],Array.isArray),[I,V]=Object(r.useState)(!1),q=t.isPreview&&!t.attributeId?B:Object(P.a)(t.attributeId),z=Object(r.useMemo)(()=>Object(D.e)(q),[q]),[K,U]=Object(r.useState)(z),[G,$]=Object(r.useState)(Object(D.d)()),[Q,Y]=Object(r.useState)(t.isPreview&&!t.attributeId?M:[]),J=Object(s.a)(t),[X]=Object(a.a)(),[Z,ee]=Object(a.b)("attributes",[]),{results:te,isLoading:ne}=Object(l.a)({namespace:"/wc/store/v1",resourceName:"products/attributes/terms",resourceValues:[(null==q?void 0:q.id)||0],shouldSelect:t.attributeId>0}),re="dropdown"!==t.displayStyle&&"and"===t.queryType,{results:oe,isLoading:se}=Object(u.a)({queryAttribute:{taxonomy:(null==q?void 0:q.taxonomy)||"",queryType:t.queryType},queryState:{...X,attributes:re?X.attributes:null},productIds:L}),ie=Object(r.useCallback)(e=>Object(y.b)(oe,"attribute_counts")&&Array.isArray(oe.attribute_counts)?oe.attribute_counts.find(t=>{let{term:n}=t;return n===e}):null,[oe]);Object(r.useEffect)(()=>{if(ne||se)return;if(!Array.isArray(te))return;const e=te.map(e=>{const n=ie(e.id);if(!(n||K.includes(e.slug)||(o=e.slug,null!=X&&X.attributes&&X.attributes.some(e=>{let{attribute:t,slug:n=[]}=e;return t===(null==q?void 0:q.taxonomy)&&n.includes(o)}))))return null;var o;const s=n?n.count:0;return{formattedValue:Object(D.c)(e.slug),value:e.slug,name:Object(h.decodeEntities)(e.name),label:Object(r.createElement)(d.a,{name:Object(h.decodeEntities)(e.name),count:t.showCounts?s:null}),textLabel:t.showCounts?`${Object(h.decodeEntities)(e.name)} (${s})`:Object(h.decodeEntities)(e.name)}}).filter(e=>!!e);Y(e),$(Object(D.d)())},[null==q?void 0:q.taxonomy,te,ne,t.showCounts,se,ie,K,X.attributes]);const ce=Object(r.useCallback)(e=>Array.isArray(te)?te.reduce((t,n)=>(e.includes(n.slug)&&t.push(n),t),[]):[],[te]),ae=Object(r.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(t){if(null==q||!q.taxonomy)return;const t=Object.keys(Object(v.getQueryArgs)(window.location.href)),n=Object(D.h)(q.taxonomy),r=t.reduce((e,t)=>t.includes(S.b+n)||t.includes(S.a+n)?Object(v.removeQueryArgs)(e,t):e,window.location.href),o=Object(D.b)(r,e);Object(S.c)(o)}else{const t=Object(D.b)(C,e),n=Object(v.getQueryArgs)(window.location.href),r=Object(v.getQueryArgs)(t);Object(D.f)(n,r)||Object(S.c)(t)}}),[C,null==q?void 0:q.taxonomy]),le=e=>{const n=Object(N.b)(Z,ee,q,ce(e),"or"===t.queryType?"in":"and");ae(n,0===e.length)},ue=Object(r.useCallback)((function(e){let r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];n||(U(e),!r&&t.showFilterButton||Object(N.b)(Z,ee,q,ce(e),"or"===t.queryType?"in":"and"))}),[n,U,Z,ee,q,ce,t.queryType,t.showFilterButton]),de=Object(r.useMemo)(()=>Object(E.a)(Z)?Z.filter(e=>{let{attribute:t}=e;return t===(null==q?void 0:q.taxonomy)}).flatMap(e=>{let{slug:t}=e;return t}):[],[Z,null==q?void 0:q.taxonomy]),pe=Object(i.a)(de),fe=Object(c.a)(pe);Object(r.useEffect)(()=>{!fe||m()(fe,pe)||m()(K,pe)||ue(pe)},[K,pe,fe,ue]);const be="single"!==t.selectType,me=Object(r.useCallback)(e=>{const t=K.includes(e);let n;be?(n=K.filter(t=>t!==e),t||(n.push(e),n.sort())):n=t?[]:[e],ue(n)},[K,be,ue]);Object(r.useEffect)(()=>{q&&!t.showFilterButton&&(Object(D.a)({currentCheckedFilters:K,hasSetFilterDefaultsFromUrl:I})?ae(Z,!0):ae(Z,!1))},[I,ae,Z,q,K,t.showFilterButton]),Object(r.useEffect)(()=>{if(!I&&!ne)return z.length>0?(V(!0),void ue(z,!0)):void(T||V(!0))},[q,I,ne,ue,z,T]);const he=Object(H.b)();if(!b)return he(!1),null;if(!q)return n?Object(r.createElement)(g.a,{status:"warning",isDismissible:!1},Object(r.createElement)("p",null,Object(o.__)("Please select an attribute to use this filter!","woo-gutenberg-products-block"))):(he(!1),null);if(0===Q.length&&!ne&&n)return Object(r.createElement)(g.a,{status:"warning",isDismissible:!1},Object(r.createElement)("p",null,Object(o.__)("There are no products with the selected attributes.","woo-gutenberg-products-block")));const ge="h"+t.headingLevel,Oe=!t.isPreview&&ne,ve=!t.isPreview&&se,je=(Oe||ve)&&0===Q.length;if(!je&&0===Q.length)return he(!1),null;const we=Object(r.createElement)(ge,{className:"wc-block-attribute-filter__title"},t.heading),ye=je?Object(r.createElement)(F.a,null,we):we;return he(!0),Object(r.createElement)(r.Fragment,null,!n&&t.heading&&ye,Object(r.createElement)("div",{className:A()("wc-block-attribute-filter","style-"+t.displayStyle)},"dropdown"===t.displayStyle?Object(r.createElement)(r.Fragment,null,Object(r.createElement)(R,{key:G,className:A()(J.className,{"single-selection":!be,"is-loading":je}),style:{...J.style,borderStyle:"none"},suggestions:Q.filter(e=>!K.includes(e.value)).map(e=>e.formattedValue),disabled:je,placeholder:Object(o.sprintf)(
|
12 |
/* translators: %s attribute name. */
|
13 |
Object(o.__)("Select %s","woo-gutenberg-products-block"),q.label),onChange:e=>{!be&&e.length>1&&(e=[e[e.length-1]]),e=e.map(e=>{const t=Q.find(t=>t.formattedValue===e);return t?t.value:e});const t=Object(x.difference)(e,K);if(1===t.length)return me(t[0]);const n=Object(x.difference)(K,e);1===n.length&&me(n[0])},value:K,displayTransform:e=>{const t=Q.find(t=>[t.value,t.formattedValue].includes(e));return t?t.textLabel:e},saveTransform:D.c,messages:{added:Object(o.sprintf)(
|
14 |
/* translators: %s is the attribute label. */
|
18 |
/* translators: %s is the attribute label. */
|
19 |
Object(o.__)("Remove %s filter.","woo-gutenberg-products-block"),q.label.toLocaleLowerCase()),__experimentalInvalid:Object(o.sprintf)(
|
20 |
/* translators: %s is the attribute label. */
|
21 |
+
Object(o.__)("Invalid %s filter.","woo-gutenberg-products-block"),q.label.toLocaleLowerCase())}}),be&&Object(r.createElement)(k.a,{icon:_.a,size:30})):Object(r.createElement)(W,{options:Q,checked:K,onChange:me,isLoading:je,isDisabled:je})),Object(r.createElement)("div",{className:"wc-block-attribute-filter__actions"},K.length>0&&!je&&Object(r.createElement)(p.a,{onClick:()=>{U([]),$(Object(D.d)()),I&&le([])},screenReaderLabel:Object(o.__)("Reset attribute filter","woo-gutenberg-products-block")}),t.showFilterButton&&Object(r.createElement)(f.a,{className:"wc-block-attribute-filter__button",isLoading:je,disabled:(()=>{if(Oe||ve)return!0;const e=Object(D.e)(q);return e.length===K.length&&K.every(t=>e.includes(t))})(),onClick:()=>le(K)})))}},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n(94);var r=n(42);const o=()=>r.m>1},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(28),o=n(20);const s=e=>Object(r.a)(e)?JSON.parse(e)||{}:Object(o.a)(e)?e:{}},,,function(e,t,n){"use strict";var r=n(216);e.exports=function(e,t,n){n=n||{},9===t.nodeType&&(t=r.getWindow(t));var o=n.allowHorizontalScroll,s=n.onlyScrollIfNeeded,i=n.alignWithTop,c=n.alignWithLeft,a=n.offsetTop||0,l=n.offsetLeft||0,u=n.offsetBottom||0,d=n.offsetRight||0;o=void 0===o||o;var p=r.isWindow(t),f=r.offset(e),b=r.outerHeight(e),m=r.outerWidth(e),h=void 0,g=void 0,O=void 0,v=void 0,j=void 0,w=void 0,y=void 0,E=void 0,k=void 0,_=void 0;p?(y=t,_=r.height(y),k=r.width(y),E={left:r.scrollLeft(y),top:r.scrollTop(y)},j={left:f.left-E.left-l,top:f.top-E.top-a},w={left:f.left+m-(E.left+k)+d,top:f.top+b-(E.top+_)+u},v=E):(h=r.offset(t),g=t.clientHeight,O=t.clientWidth,v={left:t.scrollLeft,top:t.scrollTop},j={left:f.left-(h.left+(parseFloat(r.css(t,"borderLeftWidth"))||0))-l,top:f.top-(h.top+(parseFloat(r.css(t,"borderTopWidth"))||0))-a},w={left:f.left+m-(h.left+O+(parseFloat(r.css(t,"borderRightWidth"))||0))+d,top:f.top+b-(h.top+g+(parseFloat(r.css(t,"borderBottomWidth"))||0))+u}),j.top<0||w.top>0?!0===i?r.scrollTop(t,v.top+j.top):!1===i?r.scrollTop(t,v.top+w.top):j.top<0?r.scrollTop(t,v.top+j.top):r.scrollTop(t,v.top+w.top):s||((i=void 0===i||!!i)?r.scrollTop(t,v.top+j.top):r.scrollTop(t,v.top+w.top)),o&&(j.left<0||w.left>0?!0===c?r.scrollLeft(t,v.left+j.left):!1===c?r.scrollLeft(t,v.left+w.left):j.left<0?r.scrollLeft(t,v.left+j.left):r.scrollLeft(t,v.left+w.left):s||((c=void 0===c||!!c)?r.scrollLeft(t,v.left+j.left):r.scrollLeft(t,v.left+w.left)))}},function(e,t,n){"use strict";var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};function s(e,t){var n=e["page"+(t?"Y":"X")+"Offset"],r="scroll"+(t?"Top":"Left");if("number"!=typeof n){var o=e.document;"number"!=typeof(n=o.documentElement[r])&&(n=o.body[r])}return n}function i(e){return s(e)}function c(e){return s(e,!0)}function a(e){var t=function(e){var t,n=void 0,r=void 0,o=e.ownerDocument,s=o.body,i=o&&o.documentElement;return n=(t=e.getBoundingClientRect()).left,r=t.top,{left:n-=i.clientLeft||s.clientLeft||0,top:r-=i.clientTop||s.clientTop||0}}(e),n=e.ownerDocument,r=n.defaultView||n.parentWindow;return t.left+=i(r),t.top+=c(r),t}var l=new RegExp("^("+/[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source+")(?!px)[a-z%]+$","i"),u=/^(top|right|bottom|left)$/,d="left",p=void 0;function f(e,t){for(var n=0;n<e.length;n++)t(e[n])}function b(e){return"border-box"===p(e,"boxSizing")}"undefined"!=typeof window&&(p=window.getComputedStyle?function(e,t,n){var r="",o=e.ownerDocument,s=n||o.defaultView.getComputedStyle(e,null);return s&&(r=s.getPropertyValue(t)||s[t]),r}:function(e,t){var n=e.currentStyle&&e.currentStyle[t];if(l.test(n)&&!u.test(t)){var r=e.style,o=r[d],s=e.runtimeStyle[d];e.runtimeStyle[d]=e.currentStyle[d],r[d]="fontSize"===t?"1em":n||0,n=r.pixelLeft+"px",r[d]=o,e.runtimeStyle[d]=s}return""===n?"auto":n});var m=["margin","border","padding"];function h(e,t,n){var r={},o=e.style,s=void 0;for(s in t)t.hasOwnProperty(s)&&(r[s]=o[s],o[s]=t[s]);for(s in n.call(e),t)t.hasOwnProperty(s)&&(o[s]=r[s])}function g(e,t,n){var r=0,o=void 0,s=void 0,i=void 0;for(s=0;s<t.length;s++)if(o=t[s])for(i=0;i<n.length;i++){var c;c="border"===o?o+n[i]+"Width":o+n[i],r+=parseFloat(p(e,c))||0}return r}function O(e){return null!=e&&e==e.window}var v={};function j(e,t,n){if(O(e))return"width"===t?v.viewportWidth(e):v.viewportHeight(e);if(9===e.nodeType)return"width"===t?v.docWidth(e):v.docHeight(e);var r="width"===t?["Left","Right"]:["Top","Bottom"],o="width"===t?e.offsetWidth:e.offsetHeight,s=(p(e),b(e)),i=0;(null==o||o<=0)&&(o=void 0,(null==(i=p(e,t))||Number(i)<0)&&(i=e.style[t]||0),i=parseFloat(i)||0),void 0===n&&(n=s?1:-1);var c=void 0!==o||s,a=o||i;if(-1===n)return c?a-g(e,["border","padding"],r):i;if(c){var l=2===n?-g(e,["border"],r):g(e,["margin"],r);return a+(1===n?0:l)}return i+g(e,m.slice(n),r)}f(["Width","Height"],(function(e){v["doc"+e]=function(t){var n=t.document;return Math.max(n.documentElement["scroll"+e],n.body["scroll"+e],v["viewport"+e](n))},v["viewport"+e]=function(t){var n="client"+e,r=t.document,o=r.body,s=r.documentElement[n];return"CSS1Compat"===r.compatMode&&s||o&&o[n]||s}}));var w={position:"absolute",visibility:"hidden",display:"block"};function y(e){var t=void 0,n=arguments;return 0!==e.offsetWidth?t=j.apply(void 0,n):h(e,w,(function(){t=j.apply(void 0,n)})),t}function E(e,t,n){var r=n;if("object"!==(void 0===t?"undefined":o(t)))return void 0!==r?("number"==typeof r&&(r+="px"),void(e.style[t]=r)):p(e,t);for(var s in t)t.hasOwnProperty(s)&&E(e,s,t[s])}f(["width","height"],(function(e){var t=e.charAt(0).toUpperCase()+e.slice(1);v["outer"+t]=function(t,n){return t&&y(t,e,n?0:1)};var n="width"===e?["Left","Right"]:["Top","Bottom"];v[e]=function(t,r){return void 0===r?t&&y(t,e,-1):t?(p(t),b(t)&&(r+=g(t,["padding","border"],n)),E(t,e,r)):void 0}})),e.exports=r({getWindow:function(e){var t=e.ownerDocument||e;return t.defaultView||t.parentWindow},offset:function(e,t){if(void 0===t)return a(e);!function(e,t){"static"===E(e,"position")&&(e.style.position="relative");var n=a(e),r={},o=void 0,s=void 0;for(s in t)t.hasOwnProperty(s)&&(o=parseFloat(E(e,s))||0,r[s]=o+t[s]-n[s]);E(e,r)}(e,t)},isWindow:O,each:f,css:E,clone:function(e){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);if(e.overflow)for(var n in e)e.hasOwnProperty(n)&&(t.overflow[n]=e.overflow[n]);return t},scrollLeft:function(e,t){if(O(e)){if(void 0===t)return i(e);window.scrollTo(t,c(e))}else{if(void 0===t)return e.scrollLeft;e.scrollLeft=t}},scrollTop:function(e,t){if(O(e)){if(void 0===t)return c(e);window.scrollTo(i(e),t)}else{if(void 0===t)return e.scrollTop;e.scrollTop=t}},viewportWidth:0,viewportHeight:0},v)},,,function(e,t){},function(e,t,n){"use strict";n.d(t,"b",(function(){return s})),n.d(t,"a",(function(){return c}));var r=n(20);const o=e=>Object(r.b)(e,"count")&&Object(r.b)(e,"description")&&Object(r.b)(e,"id")&&Object(r.b)(e,"name")&&Object(r.b)(e,"parent")&&Object(r.b)(e,"slug")&&"number"==typeof e.count&&"string"==typeof e.description&&"number"==typeof e.id&&"string"==typeof e.name&&"number"==typeof e.parent&&"string"==typeof e.slug,s=e=>Array.isArray(e)&&e.every(o),i=e=>Object(r.b)(e,"attribute")&&Object(r.b)(e,"operator")&&Object(r.b)(e,"slug")&&"string"==typeof e.attribute&&"string"==typeof e.operator&&Array.isArray(e.slug)&&e.slug.every(e=>"string"==typeof e),c=e=>Array.isArray(e)&&e.every(i)},function(e,t){},,,,,,,,,,,,,,,,,,,,function(e,t,n){e.exports=n(242)},function(e,t,n){"use strict";n.r(t);var r=n(44),o=n(155),s=n(47);Object(r.a)({selector:".wp-block-woocommerce-attribute-filter",Block:o.a,getProps:e=>({isEditor:!1,attributes:Object(s.g)(e.dataset)})})},,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(104),o=n(211),s=n(20),i=n(212);const c=e=>{if(!Object(o.a)())return{className:"",style:{}};const t=Object(s.a)(e)?e:{},n=Object(i.a)(t.style);return Object(r.__experimentalUseBorderProps)({...t,style:n})}},,,,,,function(e,t,n){"use strict";var r=n(0),o=n(8),s=n(7),i=n.n(s),c=n(1),a=n(29),l=n(133),u=n(92);function d(e){switch(e){case"success":case"warning":case"info":return"polite";case"error":default:return"assertive"}}t.a=function({className:e,status:t="info",children:n,spokenMessage:s=n,onRemove:p=o.noop,isDismissible:f=!0,actions:b=[],politeness:m=d(t),__unstableHTML:h,onDismiss:g=o.noop}){!function(e,t){const n="string"==typeof e?e:Object(r.renderToString)(e);Object(r.useEffect)(()=>{n&&Object(a.speak)(n,t)},[n,t])}(s,m);const O=i()(e,"components-notice","is-"+t,{"is-dismissible":f});return h&&(n=Object(r.createElement)(r.RawHTML,null,n)),Object(r.createElement)("div",{className:O},Object(r.createElement)("div",{className:"components-notice__content"},n,Object(r.createElement)("div",{className:"components-notice__actions"},b.map(({className:e,label:t,isPrimary:n,variant:o,noDefaultClasses:s=!1,onClick:c,url:a},l)=>{let d=o;return"primary"===o||s||(d=a?"link":"secondary"),void 0===d&&n&&(d="primary"),Object(r.createElement)(u.a,{key:l,href:a,variant:d,onClick:a?void 0:c,className:i()("components-notice__action",e)},t)}))),f&&Object(r.createElement)(u.a,{className:"components-notice__dismiss",icon:l.a,label:Object(c.__)("Dismiss this notice"),onClick:e=>{var t;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),g(),p()},showTooltip:!1}))}},,function(e,t,n){"use strict";var r=n(0),o=n(18);const s=Object(r.createElement)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(r.createElement)(o.Path,{d:"M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"}));t.a=s},function(e,t,n){"use strict";var r=n(0),o=n(18);const s=Object(r.createElement)(o.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},Object(r.createElement)(o.Path,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"}));t.a=s},,function(e,t,n){"use strict";var r=n(0),o=n(8),s=n(7),i=n.n(s),c=n(1),a=n(15),l=n(54),u=n(12),d=n.n(u),p=n(279),f=n(92),b=n(58);function m({value:e,status:t,title:n,displayTransform:s,isBorderless:l=!1,disabled:u=!1,onClickRemove:d=o.noop,onMouseEnter:h,onMouseLeave:g,messages:O,termPosition:v,termsCount:j}){const w=Object(a.useInstanceId)(m),y=i()("components-form-token-field__token",{"is-error":"error"===t,"is-success":"success"===t,"is-validating":"validating"===t,"is-borderless":l,"is-disabled":u}),E=s(e),k=Object(c.sprintf)(
|
22 |
/* translators: 1: term name, 2: term position in a set of terms, 3: total term set count. */
|
23 |
+
Object(c.__)("%1$s (%2$s of %3$s)"),E,v,j);return Object(r.createElement)("span",{className:y,onMouseEnter:h,onMouseLeave:g,title:n},Object(r.createElement)("span",{className:"components-form-token-field__token-text",id:"components-form-token-field__token-text-"+w},Object(r.createElement)(b.a,{as:"span"},k),Object(r.createElement)("span",{"aria-hidden":"true"},E)),Object(r.createElement)(f.a,{className:"components-form-token-field__remove-token",icon:p.a,onClick:!u&&(()=>d({value:e})),label:O.remove,"aria-describedby":"components-form-token-field__token-text-"+w}))}var h=n(144),g=n(145),O=n(10),v=n(29),j=Object(a.createHigherOrderComponent)(e=>t=>Object(r.createElement)(e,Object(O.a)({},t,{speak:v.speak,debouncedSpeak:Object(a.useDebounce)(v.speak,500)})),"withSpokenMessages");const w={incompleteTokenValue:"",inputOffsetFromEnd:0,isActive:!1,isExpanded:!1,selectedSuggestionIndex:-1,selectedSuggestionScroll:!1};class y extends r.Component{constructor(){super(...arguments),this.state=w,this.onKeyDown=this.onKeyDown.bind(this),this.onKeyPress=this.onKeyPress.bind(this),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this),this.deleteTokenBeforeInput=this.deleteTokenBeforeInput.bind(this),this.deleteTokenAfterInput=this.deleteTokenAfterInput.bind(this),this.addCurrentToken=this.addCurrentToken.bind(this),this.onContainerTouched=this.onContainerTouched.bind(this),this.renderToken=this.renderToken.bind(this),this.onTokenClickRemove=this.onTokenClickRemove.bind(this),this.onSuggestionHovered=this.onSuggestionHovered.bind(this),this.onSuggestionSelected=this.onSuggestionSelected.bind(this),this.onInputChange=this.onInputChange.bind(this),this.bindInput=this.bindInput.bind(this),this.bindTokensAndInput=this.bindTokensAndInput.bind(this),this.updateSuggestions=this.updateSuggestions.bind(this)}componentDidUpdate(e){this.state.isActive&&!this.input.hasFocus()&&this.input.focus();const{suggestions:t,value:n}=this.props,r=!d()(t,e.suggestions);(r||n!==e.value)&&this.updateSuggestions(r)}static getDerivedStateFromProps(e,t){return e.disabled&&t.isActive?{isActive:!1,incompleteTokenValue:""}:null}bindInput(e){this.input=e}bindTokensAndInput(e){this.tokensAndInput=e}onFocus(e){const{__experimentalExpandOnFocus:t}=this.props;this.input.hasFocus()||e.target===this.tokensAndInput?this.setState({isActive:!0,isExpanded:!!t||this.state.isExpanded}):this.setState({isActive:!1}),"function"==typeof this.props.onFocus&&this.props.onFocus(e)}onBlur(){this.inputHasValidValue()?this.setState({isActive:!1}):this.setState(w)}onKeyDown(e){let t=!1;switch(e.keyCode){case l.BACKSPACE:t=this.handleDeleteKey(this.deleteTokenBeforeInput);break;case l.ENTER:t=this.addCurrentToken();break;case l.LEFT:t=this.handleLeftArrowKey();break;case l.UP:t=this.handleUpArrowKey();break;case l.RIGHT:t=this.handleRightArrowKey();break;case l.DOWN:t=this.handleDownArrowKey();break;case l.DELETE:t=this.handleDeleteKey(this.deleteTokenAfterInput);break;case l.SPACE:this.props.tokenizeOnSpace&&(t=this.addCurrentToken());break;case l.ESCAPE:t=this.handleEscapeKey(e),e.stopPropagation()}t&&e.preventDefault()}onKeyPress(e){let t=!1;switch(e.charCode){case 44:t=this.handleCommaKey()}t&&e.preventDefault()}onContainerTouched(e){e.target===this.tokensAndInput&&this.state.isActive&&e.preventDefault()}onTokenClickRemove(e){this.deleteToken(e.value),this.input.focus()}onSuggestionHovered(e){const t=this.getMatchingSuggestions().indexOf(e);t>=0&&this.setState({selectedSuggestionIndex:t,selectedSuggestionScroll:!1})}onSuggestionSelected(e){this.addNewToken(e)}onInputChange(e){const t=e.value,n=this.props.tokenizeOnSpace?/[ ,\t]+/:/[,\t]+/,r=t.split(n),s=Object(o.last)(r)||"";r.length>1&&this.addNewTokens(r.slice(0,-1)),this.setState({incompleteTokenValue:s},this.updateSuggestions),this.props.onInputChange(s)}handleDeleteKey(e){let t=!1;return this.input.hasFocus()&&this.isInputEmpty()&&(e(),t=!0),t}handleLeftArrowKey(){let e=!1;return this.isInputEmpty()&&(this.moveInputBeforePreviousToken(),e=!0),e}handleRightArrowKey(){let e=!1;return this.isInputEmpty()&&(this.moveInputAfterNextToken(),e=!0),e}handleUpArrowKey(){return this.setState((e,t)=>({selectedSuggestionIndex:(0===e.selectedSuggestionIndex?this.getMatchingSuggestions(e.incompleteTokenValue,t.suggestions,t.value,t.maxSuggestions,t.saveTransform).length:e.selectedSuggestionIndex)-1,selectedSuggestionScroll:!0})),!0}handleDownArrowKey(){return this.setState((e,t)=>({selectedSuggestionIndex:(e.selectedSuggestionIndex+1)%this.getMatchingSuggestions(e.incompleteTokenValue,t.suggestions,t.value,t.maxSuggestions,t.saveTransform).length,selectedSuggestionScroll:!0})),!0}handleEscapeKey(e){return this.setState({incompleteTokenValue:e.target.value,isExpanded:!1,selectedSuggestionIndex:-1,selectedSuggestionScroll:!1}),!0}handleCommaKey(){return this.inputHasValidValue()&&this.addNewToken(this.state.incompleteTokenValue),!0}moveInputToIndex(e){this.setState((t,n)=>({inputOffsetFromEnd:n.value.length-Math.max(e,-1)-1}))}moveInputBeforePreviousToken(){this.setState((e,t)=>({inputOffsetFromEnd:Math.min(e.inputOffsetFromEnd+1,t.value.length)}))}moveInputAfterNextToken(){this.setState(e=>({inputOffsetFromEnd:Math.max(e.inputOffsetFromEnd-1,0)}))}deleteTokenBeforeInput(){const e=this.getIndexOfInput()-1;e>-1&&this.deleteToken(this.props.value[e])}deleteTokenAfterInput(){const e=this.getIndexOfInput();e<this.props.value.length&&(this.deleteToken(this.props.value[e]),this.moveInputToIndex(e))}addCurrentToken(){let e=!1;const t=this.getSelectedSuggestion();return t?(this.addNewToken(t),e=!0):this.inputHasValidValue()&&(this.addNewToken(this.state.incompleteTokenValue),e=!0),e}addNewTokens(e){const t=Object(o.uniq)(e.map(this.props.saveTransform).filter(Boolean).filter(e=>!this.valueContainsToken(e)));if(t.length>0){const e=Object(o.clone)(this.props.value);e.splice.apply(e,[this.getIndexOfInput(),0].concat(t)),this.props.onChange(e)}}addNewToken(e){const{__experimentalExpandOnFocus:t,__experimentalValidateInput:n}=this.props;n(e)?(this.addNewTokens([e]),this.props.speak(this.props.messages.added,"assertive"),this.setState({incompleteTokenValue:"",selectedSuggestionIndex:-1,selectedSuggestionScroll:!1,isExpanded:!t}),this.state.isActive&&this.input.focus()):this.props.speak(this.props.messages.__experimentalInvalid,"assertive")}deleteToken(e){const t=this.props.value.filter(t=>this.getTokenValue(t)!==this.getTokenValue(e));this.props.onChange(t),this.props.speak(this.props.messages.removed,"assertive")}getTokenValue(e){return"object"==typeof e?e.value:e}getMatchingSuggestions(e=this.state.incompleteTokenValue,t=this.props.suggestions,n=this.props.value,r=this.props.maxSuggestions,s=this.props.saveTransform){let i=s(e);const c=[],a=[];return 0===i.length?t=Object(o.difference)(t,n):(i=i.toLocaleLowerCase(),Object(o.each)(t,e=>{const t=e.toLocaleLowerCase().indexOf(i);-1===n.indexOf(e)&&(0===t?c.push(e):t>0&&a.push(e))}),t=c.concat(a)),Object(o.take)(t,r)}getSelectedSuggestion(){if(-1!==this.state.selectedSuggestionIndex)return this.getMatchingSuggestions()[this.state.selectedSuggestionIndex]}valueContainsToken(e){return Object(o.some)(this.props.value,t=>this.getTokenValue(e)===this.getTokenValue(t))}getIndexOfInput(){return this.props.value.length-this.state.inputOffsetFromEnd}isInputEmpty(){return 0===this.state.incompleteTokenValue.length}inputHasValidValue(){return this.props.saveTransform(this.state.incompleteTokenValue).length>0}updateSuggestions(e=!0){const{__experimentalExpandOnFocus:t}=this.props,{incompleteTokenValue:n}=this.state,r=n.trim().length>1,o=this.getMatchingSuggestions(n),s=o.length>0,i={isExpanded:t||r&&s};if(e&&(i.selectedSuggestionIndex=-1,i.selectedSuggestionScroll=!1),this.setState(i),r){const{debouncedSpeak:e}=this.props;e(s?Object(c.sprintf)(
|
24 |
/* translators: %d: number of results. */
|
25 |
Object(c._n)("%d result found, use up and down arrow keys to navigate.","%d results found, use up and down arrow keys to navigate.",o.length),o.length):Object(c.__)("No results."),"assertive")}}renderTokensAndInput(){const e=Object(o.map)(this.props.value,this.renderToken);return e.splice(this.getIndexOfInput(),0,this.renderInput()),e}renderToken(e,t,n){const o=this.getTokenValue(e),s=e.status?e.status:void 0,i=t+1,c=n.length;return Object(r.createElement)(m,{key:"token-"+o,value:o,status:s,title:e.title,displayTransform:this.props.displayTransform,onClickRemove:this.onTokenClickRemove,isBorderless:e.isBorderless||this.props.isBorderless,onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave,disabled:"error"!==s&&this.props.disabled,messages:this.props.messages,termsCount:c,termPosition:i})}renderInput(){const{autoCapitalize:e,autoComplete:t,maxLength:n,placeholder:o,value:s,instanceId:i}=this.props;let c={instanceId:i,autoCapitalize:e,autoComplete:t,placeholder:0===s.length?o:"",ref:this.bindInput,key:"input",disabled:this.props.disabled,value:this.state.incompleteTokenValue,onBlur:this.onBlur,isExpanded:this.state.isExpanded,selectedSuggestionIndex:this.state.selectedSuggestionIndex};return n&&s.length>=n||(c={...c,onChange:this.onInputChange}),Object(r.createElement)(h.a,c)}render(){const{disabled:e,label:t=Object(c.__)("Add item"),instanceId:n,className:o,__experimentalShowHowTo:s}=this.props,{isExpanded:a}=this.state,l=i()(o,"components-form-token-field__input-container",{"is-active":this.state.isActive,"is-disabled":e});let u={className:"components-form-token-field",tabIndex:"-1"};const d=this.getMatchingSuggestions();return e||(u=Object.assign({},u,{onKeyDown:this.onKeyDown,onKeyPress:this.onKeyPress,onFocus:this.onFocus})),Object(r.createElement)("div",u,Object(r.createElement)("label",{htmlFor:"components-form-token-input-"+n,className:"components-form-token-field__label"},t),Object(r.createElement)("div",{ref:this.bindTokensAndInput,className:l,tabIndex:"-1",onMouseDown:this.onContainerTouched,onTouchStart:this.onContainerTouched},this.renderTokensAndInput(),a&&Object(r.createElement)(g.a,{instanceId:n,match:this.props.saveTransform(this.state.incompleteTokenValue),displayTransform:this.props.displayTransform,suggestions:d,selectedIndex:this.state.selectedSuggestionIndex,scrollIntoView:this.state.selectedSuggestionScroll,onHover:this.onSuggestionHovered,onSelect:this.onSuggestionSelected})),s&&Object(r.createElement)("p",{id:"components-form-token-suggestions-howto-"+n,className:"components-form-token-field__help"},this.props.tokenizeOnSpace?Object(c.__)("Separate with commas, spaces, or the Enter key."):Object(c.__)("Separate with commas or the Enter key.")))}}y.defaultProps={suggestions:Object.freeze([]),maxSuggestions:100,value:Object.freeze([]),displayTransform:o.identity,saveTransform:e=>e.trim(),onChange:()=>{},onInputChange:()=>{},isBorderless:!1,disabled:!1,tokenizeOnSpace:!1,messages:{added:Object(c.__)("Item added."),removed:Object(c.__)("Item removed."),remove:Object(c.__)("Remove item"),__experimentalInvalid:Object(c.__)("Invalid item")},__experimentalExpandOnFocus:!1,__experimentalValidateInput:()=>!0,__experimentalShowHowTo:!0},t.a=j(Object(a.withInstanceId)(y))}]);
|
build/attribute-filter-wrapper-frontend.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[15],{101:function(e,t){},102:function(e,t){},103:function(e,t){},115:function(e,t,n){"use strict";n.d(t,"a",(function(){return c})),n.d(t,"b",(function(){return a}));var r=n(5);const c=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";const a=e.filter(e=>e.attribute===n.taxonomy),o=a.length?a[0]:null;if(!(o&&o.slug&&Array.isArray(o.slug)&&o.slug.includes(c)))return;const s=o.slug.filter(e=>e!==c),l=e.filter(e=>e.attribute!==n.taxonomy);s.length>0&&(o.slug=s.sort(),l.push(o)),t(Object(r.sortBy)(l,"attribute"))},a=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"in";if(!n||!n.taxonomy)return[];const o=e.filter(e=>e.attribute!==n.taxonomy);return 0===c.length?t(o):(o.push({attribute:n.taxonomy,operator:a,slug:c.map(e=>{let{slug:t}=e;return t}).sort()}),t(Object(r.sortBy)(o,"attribute"))),o}},118:function(e,t){},120:function(e,t,n){"use strict";n.d(t,"a",(function(){return a})),n.d(t,"b",(function(){return o}));var r=n(2);const c=Object(r.getSetting)("attributes",[]).reduce((e,t)=>{const n=(r=t)&&r.attribute_name?{id:parseInt(r.attribute_id,10),name:r.attribute_name,taxonomy:"pa_"+r.attribute_name,label:r.attribute_label}:null;var r;return n&&n.id&&e.push(n),e},[]),a=e=>{if(e)return c.find(t=>t.id===e)},o=e=>{if(e)return c.find(t=>t.taxonomy===e)}},125:function(e){e.exports=JSON.parse('{"name":"woocommerce/attribute-filter","version":"1.0.0","title":"Filter by Attribute Controls","description":"Enable customers to filter the product grid by selecting one or more attributes, such as color.","category":"woocommerce","keywords":["WooCommerce"],"supports":{"html":false,"color":{"text":true,"background":false},"inserter":false,"lock":false},"example":{"attributes":{"isPreview":true}},"attributes":{"className":{"type":"string","default":""},"attributeId":{"type":"number","default":0},"showCounts":{"type":"boolean","default":true},"queryType":{"type":"string","default":"or"},"headingLevel":{"type":"number","default":3},"displayStyle":{"type":"string","default":"list"},"showFilterButton":{"type":"boolean","default":false},"selectType":{"type":"string","default":"multiple"},"isPreview":{"type":"boolean","default":false}},"textdomain":"woo-gutenberg-products-block","apiVersion":2,"$schema":"https://schemas.wp.org/trunk/block.json"}')},135:function(e,t,n){"use strict";n.d(t,"a",(function(){return b}));var r=n(0),c=n(97),a=n(5),o=n(29),s=n(20),l=n(31),u=n(61),i=n(25);const b=e=>{let{queryAttribute:t,queryPrices:n,queryStock:b,queryRating:d,queryState:f,productIds:m}=e,O=Object(i.a)();O+="-collection-data";const[j]=Object(l.a)(O),[p,g]=Object(l.b)("calculate_attribute_counts",[],O),[y,h]=Object(l.b)("calculate_price_range",null,O),[v,w]=Object(l.b)("calculate_stock_status_counts",null,O),[_,E]=Object(l.b)("calculate_rating_counts",null,O),k=Object(o.a)(t||{}),S=Object(o.a)(n),x=Object(o.a)(b),C=Object(o.a)(d);Object(r.useEffect)(()=>{"object"==typeof k&&Object.keys(k).length&&(p.find(e=>Object(s.b)(k,"taxonomy")&&e.taxonomy===k.taxonomy)||g([...p,k]))},[k,p,g]),Object(r.useEffect)(()=>{y!==S&&void 0!==S&&h(S)},[S,h,y]),Object(r.useEffect)(()=>{v!==x&&void 0!==x&&w(x)},[x,w,v]),Object(r.useEffect)(()=>{_!==C&&void 0!==C&&E(C)},[C,E,_]);const[N,T]=Object(r.useState)(!1),[A]=Object(c.a)(N,200);N||T(!0);const L=Object(r.useMemo)(()=>(e=>{const t=e;return Array.isArray(e.calculate_attribute_counts)&&(t.calculate_attribute_counts=Object(a.sortBy)(e.calculate_attribute_counts.map(e=>{let{taxonomy:t,queryType:n}=e;return{taxonomy:t,query_type:n}}),["taxonomy","query_type"])),t})(j),[j]);return Object(u.a)({namespace:"/wc/store/v1",resourceName:"products/collection-data",query:{...f,page:void 0,per_page:void 0,orderby:void 0,order:void 0,...!Object(a.isEmpty)(m)&&{include:m},...L},shouldSelect:A})}},136:function(e,t){},160:function(e,t,n){"use strict";var r=n(0),c=n(1),a=n(277),o=n(29),s=n(62),l=n(31),u=n(61),i=n(135),b=n(63),d=n(68),f=n(69),m=n(13),O=n.n(m),j=n(23),p=n(98),g=n(2),y=n(14),h=n(74),v=n(30),w=n(20),_=n(226),E=n(114),k=n(284),S=n(71),x=n(5),C=n(12),N=n.n(C),T=n(286),A=n(4),L=n.n(A);n(227);var R=e=>{let{className:t,style:n,suggestions:c,multiple:a=!0,saveTransform:o=(e=>e.trim().replace(/\s/g,"-")),messages:s={},validateInput:l=(e=>c.includes(e)),label:u="",...i}=e;return Object(r.createElement)("div",{className:L()("wc-blocks-components-form-token-field-wrapper",t,{"single-selection":!a}),style:n},Object(r.createElement)(T.a,N()({label:u,__experimentalExpandOnFocus:!0,__experimentalShowHowTo:!1,__experimentalValidateInput:l,saveTransform:o,maxLength:a?void 0:1,suggestions:c,messages:s},i)))},F=n(67),q=n(120),I=n(115);const B=[{value:"preview-1",formattedValue:"preview-1",name:"Blue",label:Object(r.createElement)(b.a,{name:"Blue",count:3}),textLabel:"Blue (3)"},{value:"preview-2",formattedValue:"preview-2",name:"Green",label:Object(r.createElement)(b.a,{name:"Green",count:3}),textLabel:"Green (3)"},{value:"preview-3",formattedValue:"preview-3",name:"Red",label:Object(r.createElement)(b.a,{name:"Red",count:2}),textLabel:"Red (2)"}],P={id:0,name:"preview",taxonomy:"preview",label:"Preview"};n(225);var Q=n(51),V=n(96),M=e=>{let{isLoading:t=!1,options:n,checked:c,onChange:a}=e;return t?Object(r.createElement)(r.Fragment,null,Object(r.createElement)("span",{className:"is-loading"}),Object(r.createElement)("span",{className:"is-loading"})):Object(r.createElement)(V.a,{className:"wc-block-attribute-filter-list",options:n,checked:c,onChange:a,isLoading:t,isDisabled:t})},D=n(45);t.a=e=>{let{attributes:t,isEditor:n=!1}=e;const m=Object(g.getSettingWithCoercion)("has_filterable_products",!1,h.a),C=Object(g.getSettingWithCoercion)("is_rendering_php_template",!1,h.a),N=Object(g.getSettingWithCoercion)("page_url",window.location.href,v.a),T=n?[]:Object(g.getSettingWithCoercion)("product_ids",[],Array.isArray),[A,V]=Object(r.useState)(!1),Y=t.isPreview&&!t.attributeId?P:Object(q.a)(t.attributeId),U=Object(r.useMemo)(()=>Object(Q.e)(Y),[Y]),[W,$]=Object(r.useState)(U),[K,J]=Object(r.useState)(Object(Q.d)()),[G,z]=Object(r.useState)(t.isPreview&&!t.attributeId?B:[]),H=Object(a.a)(t),[Z]=Object(l.a)(),[X,ee]=Object(l.b)("attributes",[]),{results:te,isLoading:ne}=Object(u.a)({namespace:"/wc/store/v1",resourceName:"products/attributes/terms",resourceValues:[(null==Y?void 0:Y.id)||0],shouldSelect:t.attributeId>0}),re="dropdown"!==t.displayStyle&&"and"===t.queryType,{results:ce,isLoading:ae}=Object(i.a)({queryAttribute:{taxonomy:(null==Y?void 0:Y.taxonomy)||"",queryType:t.queryType},queryState:{...Z,attributes:re?Z.attributes:null},productIds:T}),oe=Object(r.useCallback)(e=>Object(w.b)(ce,"attribute_counts")&&Array.isArray(ce.attribute_counts)?ce.attribute_counts.find(t=>{let{term:n}=t;return n===e}):null,[ce]);Object(r.useEffect)(()=>{if(ne||ae)return;if(!Array.isArray(te))return;const e=te.map(e=>{const n=oe(e.id);if(!(n||W.includes(e.slug)||(c=e.slug,null!=Z&&Z.attributes&&Z.attributes.some(e=>{let{attribute:t,slug:n=[]}=e;return t===(null==Y?void 0:Y.taxonomy)&&n.includes(c)}))))return null;var c;const a=n?n.count:0;return{formattedValue:Object(Q.c)(e.slug),value:e.slug,name:Object(j.decodeEntities)(e.name),label:Object(r.createElement)(b.a,{name:Object(j.decodeEntities)(e.name),count:t.showCounts?a:null}),textLabel:t.showCounts?`${Object(j.decodeEntities)(e.name)} (${a})`:Object(j.decodeEntities)(e.name)}}).filter(e=>!!e);z(e),J(Object(Q.d)())},[null==Y?void 0:Y.taxonomy,te,ne,t.showCounts,ae,oe,W,Z.attributes]);const se=Object(r.useCallback)(e=>Array.isArray(te)?te.reduce((t,n)=>(e.includes(n.slug)&&t.push(n),t),[]):[],[te]),le=Object(r.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(t){if(null==Y||!Y.taxonomy)return;const t=Object.keys(Object(y.getQueryArgs)(window.location.href)),n=Object(Q.h)(Y.taxonomy),r=t.reduce((e,t)=>t.includes(S.b+n)||t.includes(S.a+n)?Object(y.removeQueryArgs)(e,t):e,window.location.href),c=Object(Q.b)(r,e);Object(S.c)(c)}else{const t=Object(Q.b)(N,e),n=Object(y.getQueryArgs)(window.location.href),r=Object(y.getQueryArgs)(t);Object(Q.f)(n,r)||Object(S.c)(t)}}),[N,null==Y?void 0:Y.taxonomy]),ue=e=>{const n=Object(I.b)(X,ee,Y,se(e),"or"===t.queryType?"in":"and");le(n,0===e.length)},ie=Object(r.useCallback)((function(e){let r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];n||($(e),!r&&t.showFilterButton||Object(I.b)(X,ee,Y,se(e),"or"===t.queryType?"in":"and"))}),[n,$,X,ee,Y,se,t.queryType,t.showFilterButton]),be=Object(r.useMemo)(()=>Object(_.a)(X)?X.filter(e=>{let{attribute:t}=e;return t===(null==Y?void 0:Y.taxonomy)}).flatMap(e=>{let{slug:t}=e;return t}):[],[X,null==Y?void 0:Y.taxonomy]),de=Object(o.a)(be),fe=Object(s.a)(de);Object(r.useEffect)(()=>{!fe||O()(fe,de)||O()(W,de)||ie(de)},[W,de,fe,ie]);const me="single"!==t.selectType,Oe=Object(r.useCallback)(e=>{const t=W.includes(e);let n;me?(n=W.filter(t=>t!==e),t||(n.push(e),n.sort())):n=t?[]:[e],ie(n)},[W,me,ie]);Object(r.useEffect)(()=>{Y&&!t.showFilterButton&&(Object(Q.a)({currentCheckedFilters:W,hasSetFilterDefaultsFromUrl:A})?le(X,!0):le(X,!1))},[A,le,X,Y,W,t.showFilterButton]),Object(r.useEffect)(()=>{if(!A&&!ne)return U.length>0?(V(!0),void ie(U,!0)):void(C||V(!0))},[Y,A,ne,ie,U,C]);const je=Object(D.b)();if(!m)return je(!1),null;if(!Y)return n?Object(r.createElement)(p.a,{status:"warning",isDismissible:!1},Object(r.createElement)("p",null,Object(c.__)("Please select an attribute to use this filter!","woo-gutenberg-products-block"))):(je(!1),null);if(0===G.length&&!ne&&n)return Object(r.createElement)(p.a,{status:"warning",isDismissible:!1},Object(r.createElement)("p",null,Object(c.__)("There are no products with the selected attributes.","woo-gutenberg-products-block")));const pe="h"+t.headingLevel,ge=!t.isPreview&&ne,ye=!t.isPreview&&ae,he=(ge||ye)&&0===G.length;if(!he&&0===G.length)return je(!1),null;const ve=Object(r.createElement)(pe,{className:"wc-block-attribute-filter__title"},t.heading),we=he?Object(r.createElement)(F.a,null,ve):ve;return je(!0),Object(r.createElement)(r.Fragment,null,!n&&t.heading&&we,Object(r.createElement)("div",{className:L()("wc-block-attribute-filter","style-"+t.displayStyle)},"dropdown"===t.displayStyle?Object(r.createElement)(r.Fragment,null,Object(r.createElement)(R,{key:K,className:L()(H.className,{"single-selection":!me,"is-loading":he}),style:{...H.style,borderStyle:"none"},suggestions:G.filter(e=>!W.includes(e.value)).map(e=>e.formattedValue),disabled:he,placeholder:Object(c.sprintf)(
|
2 |
/* translators: %s attribute name. */
|
3 |
Object(c.__)("Select %s","woo-gutenberg-products-block"),Y.label),onChange:e=>{!me&&e.length>1&&(e=[e[e.length-1]]),e=e.map(e=>{const t=G.find(t=>t.formattedValue===e);return t?t.value:e});const t=Object(x.difference)(e,W);if(1===t.length)return Oe(t[0]);const n=Object(x.difference)(W,e);1===n.length&&Oe(n[0])},value:W,displayTransform:e=>{const t=G.find(t=>[t.value,t.formattedValue].includes(e));return t?t.textLabel:e},saveTransform:Q.c,messages:{added:Object(c.sprintf)(
|
4 |
/* translators: %s is the attribute label. */
|
@@ -8,14 +8,14 @@ Object(c.__)("%s filter removed.","woo-gutenberg-products-block"),Y.label),remov
|
|
8 |
/* translators: %s is the attribute label. */
|
9 |
Object(c.__)("Remove %s filter.","woo-gutenberg-products-block"),Y.label.toLocaleLowerCase()),__experimentalInvalid:Object(c.sprintf)(
|
10 |
/* translators: %s is the attribute label. */
|
11 |
-
Object(c.__)("Invalid %s filter.","woo-gutenberg-products-block"),Y.label.toLocaleLowerCase())}}),me&&Object(r.createElement)(E.a,{icon:k.a,size:30})):Object(r.createElement)(M,{options:G,checked:W,onChange:Oe,isLoading:he,isDisabled:he})),Object(r.createElement)("div",{className:"wc-block-attribute-filter__actions"},W.length>0&&!he&&Object(r.createElement)(d.a,{onClick:()=>{$([]),J(Object(Q.d)()),A&&ue([])},screenReaderLabel:Object(c.__)("Reset attribute filter","woo-gutenberg-products-block")}),t.showFilterButton&&Object(r.createElement)(f.a,{className:"wc-block-attribute-filter__button",isLoading:he,disabled:(()=>{if(ge||ye)return!0;const e=Object(Q.e)(Y);return e.length===W.length&&W.every(t=>e.includes(t))})(),onClick:()=>ue(W)})))}},19:function(e,t,n){"use strict";var r=n(0),c=n(
|
12 |
/* translators: %s number of products. */
|
13 |
-
Object(c._n)("%s product","%s products",n,"woo-gutenberg-products-block"),n),wrapperElement:"span",wrapperProps:{className:"wc-filter-element-label-list-count"}}))}},
|
14 |
/* translators: Reset button text for filters. */
|
15 |
-
n=Object(c.__)("Reset","woo-gutenberg-products-block"),onClick:a,screenReaderLabel:l=Object(c.__)("Reset filter","woo-gutenberg-products-block")}=e;return Object(r.createElement)("button",{className:o()("wc-block-components-filter-reset-button",t),onClick:a},Object(r.createElement)(s.a,{label:n,screenReaderLabel:l}))}},
|
16 |
/* translators: Submit button text for filters. */
|
17 |
-
l=Object(c.__)("Apply","woo-gutenberg-products-block"),onClick:u,screenReaderLabel:i=Object(c.__)("Apply filter","woo-gutenberg-products-block")}=e;return Object(r.createElement)("button",{type:"submit",className:o()("wp-block-button__link","wc-block-filter-submit-button","wc-block-components-filter-submit-button",{"is-loading":n},t),disabled:a,onClick:u},Object(r.createElement)(s.a,{label:l,screenReaderLabel:i}))}},
|
18 |
/* translators: %s is referring the remaining count of options */
|
19 |
Object(c._n)("Show %s more option","Show %s more options",e,"woo-gutenberg-products-block"),e)},Object(c.sprintf)(
|
20 |
/* translators: %s number of options to reveal. */
|
21 |
-
Object(c._n)("Show %s more","Show %s more",e,"woo-gutenberg-products-block"),e)))},[a,b,d]),j=Object(r.useMemo)(()=>d&&Object(r.createElement)("li",{key:"show-less",className:"show-less"},Object(r.createElement)("button",{onClick:()=>{f(!1)},"aria-expanded":!0,"aria-label":Object(c.__)("Show less options","woo-gutenberg-products-block")},Object(c.__)("Show less","woo-gutenberg-products-block"))),[d]),p=Object(r.useMemo)(()=>{const e=a.length>b+5;return Object(r.createElement)(r.Fragment,null,a.map((t,c)=>Object(r.createElement)(r.Fragment,{key:t.value},Object(r.createElement)("li",e&&!d&&c>=b&&{hidden:!0},Object(r.createElement)(s.CheckboxControl,{id:t.value,className:"wc-block-checkbox-list__checkbox",label:t.label,checked:l.includes(t.value),onChange:()=>{n(t.value)}})),e&&c===b-1&&O)),e&&j)},[a,n,l,d,b,j,O,i]),g=o()("wc-block-checkbox-list","wc-block-components-checkbox-list",{"is-loading":u},t);return Object(r.createElement)("ul",{className:g},u?m:p)}}}]);
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[15],{108:function(e,t,n){"use strict";n.d(t,"a",(function(){return c})),n.d(t,"b",(function(){return a}));var r=n(8);const c=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";const a=e.filter(e=>e.attribute===n.taxonomy),o=a.length?a[0]:null;if(!(o&&o.slug&&Array.isArray(o.slug)&&o.slug.includes(c)))return;const s=o.slug.filter(e=>e!==c),l=e.filter(e=>e.attribute!==n.taxonomy);s.length>0&&(o.slug=s.sort(),l.push(o)),t(Object(r.sortBy)(l,"attribute"))},a=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"in";if(!n||!n.taxonomy)return[];const o=e.filter(e=>e.attribute!==n.taxonomy);return 0===c.length?t(o):(o.push({attribute:n.taxonomy,operator:a,slug:c.map(e=>{let{slug:t}=e;return t}).sort()}),t(Object(r.sortBy)(o,"attribute"))),o}},111:function(e,t){},113:function(e,t,n){"use strict";n.d(t,"a",(function(){return a})),n.d(t,"b",(function(){return o}));var r=n(2);const c=Object(r.getSetting)("attributes",[]).reduce((e,t)=>{const n=(r=t)&&r.attribute_name?{id:parseInt(r.attribute_id,10),name:r.attribute_name,taxonomy:"pa_"+r.attribute_name,label:r.attribute_label}:null;var r;return n&&n.id&&e.push(n),e},[]),a=e=>{if(e)return c.find(t=>t.id===e)},o=e=>{if(e)return c.find(t=>t.taxonomy===e)}},118:function(e){e.exports=JSON.parse('{"name":"woocommerce/attribute-filter","version":"1.0.0","title":"Filter by Attribute Controls","description":"Enable customers to filter the product grid by selecting one or more attributes, such as color.","category":"woocommerce","keywords":["WooCommerce"],"supports":{"html":false,"color":{"text":true,"background":false},"inserter":false,"lock":false},"example":{"attributes":{"isPreview":true}},"attributes":{"className":{"type":"string","default":""},"attributeId":{"type":"number","default":0},"showCounts":{"type":"boolean","default":true},"queryType":{"type":"string","default":"or"},"headingLevel":{"type":"number","default":3},"displayStyle":{"type":"string","default":"list"},"showFilterButton":{"type":"boolean","default":false},"selectType":{"type":"string","default":"multiple"},"isPreview":{"type":"boolean","default":false}},"textdomain":"woo-gutenberg-products-block","apiVersion":2,"$schema":"https://schemas.wp.org/trunk/block.json"}')},130:function(e,t,n){"use strict";n.d(t,"a",(function(){return b}));var r=n(0),c=n(91),a=n(8),o=n(26),s=n(20),l=n(30),u=n(55),i=n(23);const b=e=>{let{queryAttribute:t,queryPrices:n,queryStock:b,queryRating:d,queryState:f,productIds:m}=e,O=Object(i.a)();O+="-collection-data";const[j]=Object(l.a)(O),[p,g]=Object(l.b)("calculate_attribute_counts",[],O),[y,h]=Object(l.b)("calculate_price_range",null,O),[v,w]=Object(l.b)("calculate_stock_status_counts",null,O),[_,E]=Object(l.b)("calculate_rating_counts",null,O),k=Object(o.a)(t||{}),S=Object(o.a)(n),x=Object(o.a)(b),C=Object(o.a)(d);Object(r.useEffect)(()=>{"object"==typeof k&&Object.keys(k).length&&(p.find(e=>Object(s.b)(k,"taxonomy")&&e.taxonomy===k.taxonomy)||g([...p,k]))},[k,p,g]),Object(r.useEffect)(()=>{y!==S&&void 0!==S&&h(S)},[S,h,y]),Object(r.useEffect)(()=>{v!==x&&void 0!==x&&w(x)},[x,w,v]),Object(r.useEffect)(()=>{_!==C&&void 0!==C&&E(C)},[C,E,_]);const[N,T]=Object(r.useState)(!1),[A]=Object(c.a)(N,200);N||T(!0);const L=Object(r.useMemo)(()=>(e=>{const t=e;return Array.isArray(e.calculate_attribute_counts)&&(t.calculate_attribute_counts=Object(a.sortBy)(e.calculate_attribute_counts.map(e=>{let{taxonomy:t,queryType:n}=e;return{taxonomy:t,query_type:n}}),["taxonomy","query_type"])),t})(j),[j]);return Object(u.a)({namespace:"/wc/store/v1",resourceName:"products/collection-data",query:{...f,page:void 0,per_page:void 0,orderby:void 0,order:void 0,...!Object(a.isEmpty)(m)&&{include:m},...L},shouldSelect:A})}},131:function(e,t){},155:function(e,t,n){"use strict";var r=n(0),c=n(1),a=n(271),o=n(26),s=n(56),l=n(30),u=n(55),i=n(130),b=n(57),d=n(62),f=n(63),m=n(12),O=n.n(m),j=n(22),p=n(277),g=n(2),y=n(11),h=n(68),v=n(28),w=n(20),_=n(220),E=n(107),k=n(280),S=n(66),x=n(8),C=n(13),N=n.n(C),T=n(282),A=n(7),L=n.n(A);n(221);var R=e=>{let{className:t,style:n,suggestions:c,multiple:a=!0,saveTransform:o=(e=>e.trim().replace(/\s/g,"-")),messages:s={},validateInput:l=(e=>c.includes(e)),label:u="",...i}=e;return Object(r.createElement)("div",{className:L()("wc-blocks-components-form-token-field-wrapper",t,{"single-selection":!a}),style:n},Object(r.createElement)(T.a,N()({label:u,__experimentalExpandOnFocus:!0,__experimentalShowHowTo:!1,__experimentalValidateInput:l,saveTransform:o,maxLength:a?void 0:1,suggestions:c,messages:s},i)))},F=n(61),q=n(113),I=n(108);const B=[{value:"preview-1",formattedValue:"preview-1",name:"Blue",label:Object(r.createElement)(b.a,{name:"Blue",count:3}),textLabel:"Blue (3)"},{value:"preview-2",formattedValue:"preview-2",name:"Green",label:Object(r.createElement)(b.a,{name:"Green",count:3}),textLabel:"Green (3)"},{value:"preview-3",formattedValue:"preview-3",name:"Red",label:Object(r.createElement)(b.a,{name:"Red",count:2}),textLabel:"Red (2)"}],P={id:0,name:"preview",taxonomy:"preview",label:"Preview"};n(219);var Q=n(47),V=n(90),M=e=>{let{isLoading:t=!1,options:n,checked:c,onChange:a}=e;return t?Object(r.createElement)(r.Fragment,null,Object(r.createElement)("span",{className:"is-loading"}),Object(r.createElement)("span",{className:"is-loading"})):Object(r.createElement)(V.a,{className:"wc-block-attribute-filter-list",options:n,checked:c,onChange:a,isLoading:t,isDisabled:t})},D=n(41);t.a=e=>{let{attributes:t,isEditor:n=!1}=e;const m=Object(g.getSettingWithCoercion)("has_filterable_products",!1,h.a),C=Object(g.getSettingWithCoercion)("is_rendering_php_template",!1,h.a),N=Object(g.getSettingWithCoercion)("page_url",window.location.href,v.a),T=n?[]:Object(g.getSettingWithCoercion)("product_ids",[],Array.isArray),[A,V]=Object(r.useState)(!1),Y=t.isPreview&&!t.attributeId?P:Object(q.a)(t.attributeId),U=Object(r.useMemo)(()=>Object(Q.e)(Y),[Y]),[W,$]=Object(r.useState)(U),[K,J]=Object(r.useState)(Object(Q.d)()),[G,z]=Object(r.useState)(t.isPreview&&!t.attributeId?B:[]),H=Object(a.a)(t),[Z]=Object(l.a)(),[X,ee]=Object(l.b)("attributes",[]),{results:te,isLoading:ne}=Object(u.a)({namespace:"/wc/store/v1",resourceName:"products/attributes/terms",resourceValues:[(null==Y?void 0:Y.id)||0],shouldSelect:t.attributeId>0}),re="dropdown"!==t.displayStyle&&"and"===t.queryType,{results:ce,isLoading:ae}=Object(i.a)({queryAttribute:{taxonomy:(null==Y?void 0:Y.taxonomy)||"",queryType:t.queryType},queryState:{...Z,attributes:re?Z.attributes:null},productIds:T}),oe=Object(r.useCallback)(e=>Object(w.b)(ce,"attribute_counts")&&Array.isArray(ce.attribute_counts)?ce.attribute_counts.find(t=>{let{term:n}=t;return n===e}):null,[ce]);Object(r.useEffect)(()=>{if(ne||ae)return;if(!Array.isArray(te))return;const e=te.map(e=>{const n=oe(e.id);if(!(n||W.includes(e.slug)||(c=e.slug,null!=Z&&Z.attributes&&Z.attributes.some(e=>{let{attribute:t,slug:n=[]}=e;return t===(null==Y?void 0:Y.taxonomy)&&n.includes(c)}))))return null;var c;const a=n?n.count:0;return{formattedValue:Object(Q.c)(e.slug),value:e.slug,name:Object(j.decodeEntities)(e.name),label:Object(r.createElement)(b.a,{name:Object(j.decodeEntities)(e.name),count:t.showCounts?a:null}),textLabel:t.showCounts?`${Object(j.decodeEntities)(e.name)} (${a})`:Object(j.decodeEntities)(e.name)}}).filter(e=>!!e);z(e),J(Object(Q.d)())},[null==Y?void 0:Y.taxonomy,te,ne,t.showCounts,ae,oe,W,Z.attributes]);const se=Object(r.useCallback)(e=>Array.isArray(te)?te.reduce((t,n)=>(e.includes(n.slug)&&t.push(n),t),[]):[],[te]),le=Object(r.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(t){if(null==Y||!Y.taxonomy)return;const t=Object.keys(Object(y.getQueryArgs)(window.location.href)),n=Object(Q.h)(Y.taxonomy),r=t.reduce((e,t)=>t.includes(S.b+n)||t.includes(S.a+n)?Object(y.removeQueryArgs)(e,t):e,window.location.href),c=Object(Q.b)(r,e);Object(S.c)(c)}else{const t=Object(Q.b)(N,e),n=Object(y.getQueryArgs)(window.location.href),r=Object(y.getQueryArgs)(t);Object(Q.f)(n,r)||Object(S.c)(t)}}),[N,null==Y?void 0:Y.taxonomy]),ue=e=>{const n=Object(I.b)(X,ee,Y,se(e),"or"===t.queryType?"in":"and");le(n,0===e.length)},ie=Object(r.useCallback)((function(e){let r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];n||($(e),!r&&t.showFilterButton||Object(I.b)(X,ee,Y,se(e),"or"===t.queryType?"in":"and"))}),[n,$,X,ee,Y,se,t.queryType,t.showFilterButton]),be=Object(r.useMemo)(()=>Object(_.a)(X)?X.filter(e=>{let{attribute:t}=e;return t===(null==Y?void 0:Y.taxonomy)}).flatMap(e=>{let{slug:t}=e;return t}):[],[X,null==Y?void 0:Y.taxonomy]),de=Object(o.a)(be),fe=Object(s.a)(de);Object(r.useEffect)(()=>{!fe||O()(fe,de)||O()(W,de)||ie(de)},[W,de,fe,ie]);const me="single"!==t.selectType,Oe=Object(r.useCallback)(e=>{const t=W.includes(e);let n;me?(n=W.filter(t=>t!==e),t||(n.push(e),n.sort())):n=t?[]:[e],ie(n)},[W,me,ie]);Object(r.useEffect)(()=>{Y&&!t.showFilterButton&&(Object(Q.a)({currentCheckedFilters:W,hasSetFilterDefaultsFromUrl:A})?le(X,!0):le(X,!1))},[A,le,X,Y,W,t.showFilterButton]),Object(r.useEffect)(()=>{if(!A&&!ne)return U.length>0?(V(!0),void ie(U,!0)):void(C||V(!0))},[Y,A,ne,ie,U,C]);const je=Object(D.b)();if(!m)return je(!1),null;if(!Y)return n?Object(r.createElement)(p.a,{status:"warning",isDismissible:!1},Object(r.createElement)("p",null,Object(c.__)("Please select an attribute to use this filter!","woo-gutenberg-products-block"))):(je(!1),null);if(0===G.length&&!ne&&n)return Object(r.createElement)(p.a,{status:"warning",isDismissible:!1},Object(r.createElement)("p",null,Object(c.__)("There are no products with the selected attributes.","woo-gutenberg-products-block")));const pe="h"+t.headingLevel,ge=!t.isPreview&&ne,ye=!t.isPreview&&ae,he=(ge||ye)&&0===G.length;if(!he&&0===G.length)return je(!1),null;const ve=Object(r.createElement)(pe,{className:"wc-block-attribute-filter__title"},t.heading),we=he?Object(r.createElement)(F.a,null,ve):ve;return je(!0),Object(r.createElement)(r.Fragment,null,!n&&t.heading&&we,Object(r.createElement)("div",{className:L()("wc-block-attribute-filter","style-"+t.displayStyle)},"dropdown"===t.displayStyle?Object(r.createElement)(r.Fragment,null,Object(r.createElement)(R,{key:K,className:L()(H.className,{"single-selection":!me,"is-loading":he}),style:{...H.style,borderStyle:"none"},suggestions:G.filter(e=>!W.includes(e.value)).map(e=>e.formattedValue),disabled:he,placeholder:Object(c.sprintf)(
|
2 |
/* translators: %s attribute name. */
|
3 |
Object(c.__)("Select %s","woo-gutenberg-products-block"),Y.label),onChange:e=>{!me&&e.length>1&&(e=[e[e.length-1]]),e=e.map(e=>{const t=G.find(t=>t.formattedValue===e);return t?t.value:e});const t=Object(x.difference)(e,W);if(1===t.length)return Oe(t[0]);const n=Object(x.difference)(W,e);1===n.length&&Oe(n[0])},value:W,displayTransform:e=>{const t=G.find(t=>[t.value,t.formattedValue].includes(e));return t?t.textLabel:e},saveTransform:Q.c,messages:{added:Object(c.sprintf)(
|
4 |
/* translators: %s is the attribute label. */
|
8 |
/* translators: %s is the attribute label. */
|
9 |
Object(c.__)("Remove %s filter.","woo-gutenberg-products-block"),Y.label.toLocaleLowerCase()),__experimentalInvalid:Object(c.sprintf)(
|
10 |
/* translators: %s is the attribute label. */
|
11 |
+
Object(c.__)("Invalid %s filter.","woo-gutenberg-products-block"),Y.label.toLocaleLowerCase())}}),me&&Object(r.createElement)(E.a,{icon:k.a,size:30})):Object(r.createElement)(M,{options:G,checked:W,onChange:Oe,isLoading:he,isDisabled:he})),Object(r.createElement)("div",{className:"wc-block-attribute-filter__actions"},W.length>0&&!he&&Object(r.createElement)(d.a,{onClick:()=>{$([]),J(Object(Q.d)()),A&&ue([])},screenReaderLabel:Object(c.__)("Reset attribute filter","woo-gutenberg-products-block")}),t.showFilterButton&&Object(r.createElement)(f.a,{className:"wc-block-attribute-filter__button",isLoading:he,disabled:(()=>{if(ge||ye)return!0;const e=Object(Q.e)(Y);return e.length===W.length&&W.every(t=>e.includes(t))})(),onClick:()=>ue(W)})))}},19:function(e,t,n){"use strict";var r=n(0),c=n(7),a=n.n(c);t.a=e=>{let t,{label:n,screenReaderLabel:c,wrapperElement:o,wrapperProps:s={}}=e;const l=null!=n,u=null!=c;return!l&&u?(t=o||"span",s={...s,className:a()(s.className,"screen-reader-text")},Object(r.createElement)(t,s,c)):(t=o||r.Fragment,l&&u&&n!==c?Object(r.createElement)(t,s,Object(r.createElement)("span",{"aria-hidden":"true"},n),Object(r.createElement)("span",{className:"screen-reader-text"},c)):Object(r.createElement)(t,s,n))}},20:function(e,t,n){"use strict";n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return c}));const r=e=>!(e=>null===e)(e)&&e instanceof Object&&e.constructor===Object;function c(e,t){return r(e)&&t in e}},211:function(e,t,n){"use strict";n.d(t,"a",(function(){return c})),n(94);var r=n(42);const c=()=>r.m>1},212:function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(28),c=n(20);const a=e=>Object(r.a)(e)?JSON.parse(e)||{}:Object(c.a)(e)?e:{}},219:function(e,t){},220:function(e,t,n){"use strict";n.d(t,"b",(function(){return a})),n.d(t,"a",(function(){return s}));var r=n(20);const c=e=>Object(r.b)(e,"count")&&Object(r.b)(e,"description")&&Object(r.b)(e,"id")&&Object(r.b)(e,"name")&&Object(r.b)(e,"parent")&&Object(r.b)(e,"slug")&&"number"==typeof e.count&&"string"==typeof e.description&&"number"==typeof e.id&&"string"==typeof e.name&&"number"==typeof e.parent&&"string"==typeof e.slug,a=e=>Array.isArray(e)&&e.every(c),o=e=>Object(r.b)(e,"attribute")&&Object(r.b)(e,"operator")&&Object(r.b)(e,"slug")&&"string"==typeof e.attribute&&"string"==typeof e.operator&&Array.isArray(e.slug)&&e.slug.every(e=>"string"==typeof e),s=e=>Array.isArray(e)&&e.every(o)},221:function(e,t){},23:function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(0);const c=Object(r.createContext)("page"),a=()=>Object(r.useContext)(c);c.Provider},26:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(0),c=n(12),a=n.n(c);function o(e){const t=Object(r.useRef)(e);return a()(e,t.current)||(t.current=e),t.current}},271:function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(104),c=n(211),a=n(20),o=n(212);const s=e=>{if(!Object(c.a)())return{className:"",style:{}};const t=Object(a.a)(e)?e:{},n=Object(o.a)(t.style);return Object(r.__experimentalUseBorderProps)({...t,style:n})}},28:function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));const r=e=>"string"==typeof e},288:function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(104),c=n(211),a=n(20),o=n(212);const s=e=>{if(!Object(c.a)())return{className:"",style:{}};const t=Object(a.a)(e)?e:{},n=Object(o.a)(t.style);return Object(r.__experimentalUseColorProps)({...t,style:n})}},30:function(e,t,n){"use strict";n.d(t,"a",(function(){return b})),n.d(t,"b",(function(){return d})),n.d(t,"c",(function(){return f}));var r=n(3),c=n(5),a=n(0),o=n(12),s=n.n(o),l=n(26),u=n(56),i=n(23);const b=e=>{const t=Object(i.a)();e=e||t;const n=Object(c.useSelect)(t=>t(r.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0),[e]),{setValueForQueryContext:o}=Object(c.useDispatch)(r.QUERY_STATE_STORE_KEY);return[n,Object(a.useCallback)(t=>{o(e,t)},[e,o])]},d=(e,t,n)=>{const o=Object(i.a)();n=n||o;const s=Object(c.useSelect)(c=>c(r.QUERY_STATE_STORE_KEY).getValueForQueryKey(n,e,t),[n,e]),{setQueryValue:l}=Object(c.useDispatch)(r.QUERY_STATE_STORE_KEY);return[s,Object(a.useCallback)(t=>{l(n,e,t)},[n,e,l])]},f=(e,t)=>{const n=Object(i.a)();t=t||n;const[r,c]=b(t),o=Object(l.a)(r),d=Object(l.a)(e),f=Object(u.a)(d),m=Object(a.useRef)(!1);return Object(a.useEffect)(()=>{s()(f,d)||(c(Object.assign({},o,d)),m.current=!0)},[o,d,f,c]),m.current?[r,c]:[e,c]}},452:function(e,t,n){"use strict";n.r(t);var r=n(0),c=n(288),a=n(28),o=n(155),s=n(47);t.default=e=>{const t=Object(c.a)(e);return Object(r.createElement)("div",{className:Object(a.a)(e.className)?e.className:"",style:{...t.style}},Object(r.createElement)(o.a,{isEditor:!1,attributes:Object(s.g)(e)}))}},47:function(e,t,n){"use strict";n.d(t,"d",(function(){return s})),n.d(t,"h",(function(){return l})),n.d(t,"b",(function(){return u})),n.d(t,"a",(function(){return i})),n.d(t,"e",(function(){return b})),n.d(t,"f",(function(){return d})),n.d(t,"c",(function(){return f})),n.d(t,"g",(function(){return m}));var r=n(11),c=n(66),a=n(28),o=n(118);function s(){return Math.floor(Math.random()*Date.now())}const l=e=>e.replace("pa_",""),u=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const n={};t.forEach(e=>{const{attribute:t,slug:r,operator:a}=e,o=l(t),s=r.join(","),u=`${c.b}${o}`,i="in"===a?"or":"and";n[`${c.a}${o}`]=s,n[u]=i});const a=Object(r.removeQueryArgs)(e,...Object.keys(n));return Object(r.addQueryArgs)(a,n)},i=e=>{let{currentCheckedFilters:t,hasSetFilterDefaultsFromUrl:n}=e;return n&&0===t.length},b=e=>{if(e){const t=Object(c.d)("filter_"+e.name);return"string"==typeof t?t.split(","):[]}return[]},d=(e,t)=>{const n=Object.entries(t).reduce((e,t)=>{let[n,r]=t;return n.includes("query_type")?e:{...e,[n]:r}},{});return Object.entries(n).reduce((t,n)=>{let[r,c]=n;return e[r]===c&&t},!0)},f=e=>e.trim().replace(/\s/g,"-").replace(/_/g,"-").replace(/-+/g,"-").replace(/[^a-zA-Z0-9-]/g,""),m=e=>({className:Object(a.a)(null==e?void 0:e.className)?e.className:"",attributeId:parseInt(Object(a.a)(null==e?void 0:e.attributeId)?e.attributeId:"0",10),showCounts:"false"!==(null==e?void 0:e.showCounts),queryType:Object(a.a)(null==e?void 0:e.queryType)&&e.queryType||o.attributes.queryType.default,heading:Object(a.a)(null==e?void 0:e.heading)?e.heading:"",headingLevel:Object(a.a)(null==e?void 0:e.headingLevel)&&parseInt(e.headingLevel,10)||o.attributes.headingLevel.default,displayStyle:Object(a.a)(null==e?void 0:e.displayStyle)&&e.displayStyle||o.attributes.displayStyle.default,showFilterButton:"true"===(null==e?void 0:e.showFilterButton),selectType:Object(a.a)(null==e?void 0:e.selectType)&&e.selectType||o.attributes.selectType.default,isPreview:!1})},55:function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(3),c=n(5),a=n(0),o=n(26),s=n(70);const l=e=>{const{namespace:t,resourceName:n,resourceValues:l=[],query:u={},shouldSelect:i=!0}=e;if(!t||!n)throw new Error("The options object must have valid values for the namespace and the resource properties.");const b=Object(a.useRef)({results:[],isLoading:!0}),d=Object(o.a)(u),f=Object(o.a)(l),m=Object(s.a)(),O=Object(c.useSelect)(e=>{if(!i)return null;const c=e(r.COLLECTIONS_STORE_KEY),a=[t,n,d,f],o=c.getCollectionError(...a);if(o){if(!(o instanceof Error))throw new Error("TypeError: `error` object is not an instance of Error constructor");m(o)}return{results:c.getCollection(...a),isLoading:!c.hasFinishedResolution("getCollection",a)}},[t,n,f,d,i]);return null!==O&&(b.current=O),b.current}},56:function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(6);function c(e,t){const n=Object(r.useRef)();return Object(r.useEffect)(()=>{n.current===e||t&&!t(e,n.current)||(n.current=e)},[e,t]),n.current}},57:function(e,t,n){"use strict";var r=n(0),c=n(1),a=n(19);n(131),t.a=e=>{let{name:t,count:n}=e;return Object(r.createElement)(r.Fragment,null,t,null!==n&&Number.isFinite(n)&&Object(r.createElement)(a.a,{label:n.toString(),screenReaderLabel:Object(c.sprintf)(
|
12 |
/* translators: %s number of products. */
|
13 |
+
Object(c._n)("%s product","%s products",n,"woo-gutenberg-products-block"),n),wrapperElement:"span",wrapperProps:{className:"wc-filter-element-label-list-count"}}))}},61:function(e,t,n){"use strict";var r=n(0);n(95),t.a=e=>{let{children:t}=e;return Object(r.createElement)("div",{className:"wc-block-filter-title-placeholder"},t)}},62:function(e,t,n){"use strict";var r=n(0),c=n(1),a=n(7),o=n.n(a),s=n(19);n(96),t.a=e=>{let{className:t,label:
|
14 |
/* translators: Reset button text for filters. */
|
15 |
+
n=Object(c.__)("Reset","woo-gutenberg-products-block"),onClick:a,screenReaderLabel:l=Object(c.__)("Reset filter","woo-gutenberg-products-block")}=e;return Object(r.createElement)("button",{className:o()("wc-block-components-filter-reset-button",t),onClick:a},Object(r.createElement)(s.a,{label:n,screenReaderLabel:l}))}},63:function(e,t,n){"use strict";var r=n(0),c=n(1),a=n(7),o=n.n(a),s=n(19);n(97),t.a=e=>{let{className:t,isLoading:n,disabled:a,label:
|
16 |
/* translators: Submit button text for filters. */
|
17 |
+
l=Object(c.__)("Apply","woo-gutenberg-products-block"),onClick:u,screenReaderLabel:i=Object(c.__)("Apply filter","woo-gutenberg-products-block")}=e;return Object(r.createElement)("button",{type:"submit",className:o()("wp-block-button__link","wc-block-filter-submit-button","wc-block-components-filter-submit-button",{"is-loading":n},t),disabled:a,onClick:u},Object(r.createElement)(s.a,{label:l,screenReaderLabel:i}))}},66:function(e,t,n){"use strict";n.d(t,"b",(function(){return s})),n.d(t,"a",(function(){return l})),n.d(t,"d",(function(){return u})),n.d(t,"c",(function(){return i}));var r=n(11),c=n(2),a=n(68);const o=Object(c.getSettingWithCoercion)("is_rendering_php_template",!1,a.a),s="query_type_",l="filter_";function u(e){return window?Object(r.getQueryArg)(window.location.href,e):null}function i(e){o?window.location.href=e:window.history.replaceState({},"",e)}},68:function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));const r=e=>"boolean"==typeof e},70:function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(0);const c=()=>{const[,e]=Object(r.useState)();return Object(r.useCallback)(t=>{e(()=>{throw t})},[])}},90:function(e,t,n){"use strict";var r=n(0),c=n(1),a=n(7),o=n.n(a),s=n(9);n(111),t.a=e=>{let{className:t,onChange:n,options:a=[],checked:l=[],isLoading:u=!1,isDisabled:i=!1,limit:b=10}=e;const[d,f]=Object(r.useState)(!1),m=Object(r.useMemo)(()=>[...Array(5)].map((e,t)=>Object(r.createElement)("li",{key:t,style:{width:Math.floor(75*Math.random())+25+"%"}})),[]),O=Object(r.useMemo)(()=>{const e=a.length-b;return!d&&Object(r.createElement)("li",{key:"show-more",className:"show-more"},Object(r.createElement)("button",{onClick:()=>{f(!0)},"aria-expanded":!1,"aria-label":Object(c.sprintf)(
|
18 |
/* translators: %s is referring the remaining count of options */
|
19 |
Object(c._n)("Show %s more option","Show %s more options",e,"woo-gutenberg-products-block"),e)},Object(c.sprintf)(
|
20 |
/* translators: %s number of options to reveal. */
|
21 |
+
Object(c._n)("Show %s more","Show %s more",e,"woo-gutenberg-products-block"),e)))},[a,b,d]),j=Object(r.useMemo)(()=>d&&Object(r.createElement)("li",{key:"show-less",className:"show-less"},Object(r.createElement)("button",{onClick:()=>{f(!1)},"aria-expanded":!0,"aria-label":Object(c.__)("Show less options","woo-gutenberg-products-block")},Object(c.__)("Show less","woo-gutenberg-products-block"))),[d]),p=Object(r.useMemo)(()=>{const e=a.length>b+5;return Object(r.createElement)(r.Fragment,null,a.map((t,c)=>Object(r.createElement)(r.Fragment,{key:t.value},Object(r.createElement)("li",e&&!d&&c>=b&&{hidden:!0},Object(r.createElement)(s.CheckboxControl,{id:t.value,className:"wc-block-checkbox-list__checkbox",label:t.label,checked:l.includes(t.value),onChange:()=>{n(t.value)},disabled:i})),e&&c===b-1&&O)),e&&j)},[a,n,l,d,b,j,O,i]),g=o()("wc-block-checkbox-list","wc-block-components-checkbox-list",{"is-loading":u},t);return Object(r.createElement)("ul",{className:g},u?m:p)}},95:function(e,t){},96:function(e,t){},97:function(e,t){}}]);
|
build/attribute-filter.asset.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php return array('dependencies' => array('lodash', 'react', 'wc-blocks-checkout', 'wc-blocks-data-store', 'wc-settings', 'wp-a11y', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-deprecated', 'wp-dom', 'wp-element', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-keycodes', 'wp-polyfill', 'wp-primitives', 'wp-url', 'wp-warning'), 'version' => '
|
1 |
+
<?php return array('dependencies' => array('lodash', 'react', 'wc-blocks-checkout', 'wc-blocks-data-store', 'wc-settings', 'wp-a11y', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-deprecated', 'wp-dom', 'wp-element', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-keycodes', 'wp-polyfill', 'wp-primitives', 'wp-url', 'wp-warning'), 'version' => '4eb5effc1d16441a368a64c1325f8e90');
|
build/attribute-filter.js
CHANGED
@@ -1,19 +1,18 @@
|
|
1 |
-
this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["attribute-filter"]=function(e){function t(t){for(var r,l,a=t[0],s=t[1],i=t[2],b=0,d=[];b<a.length;b++)l=a[b],Object.prototype.hasOwnProperty.call(c,l)&&c[l]&&d.push(c[l][0]),c[l]=0;for(r in s)Object.prototype.hasOwnProperty.call(s,r)&&(e[r]=s[r]);for(u&&u(t);d.length;)d.shift()();return o.push.apply(o,i||[]),n()}function n(){for(var e,t=0;t<o.length;t++){for(var n=o[t],r=!0,a=1;a<n.length;a++){var s=n[a];0!==c[s]&&(r=!1)}r&&(o.splice(t--,1),e=l(l.s=n[0]))}return e}var r={},c={8:0,1:0},o=[];function l(t){if(r[t])return r[t].exports;var n=r[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,l),n.l=!0,n.exports}l.m=e,l.c=r,l.d=function(e,t,n){l.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,t){if(1&t&&(e=l(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(l.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)l.d(n,r,function(t){return e[t]}.bind(null,r));return n},l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,"a",t),t},l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.p="";var a=window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[],s=a.push.bind(a);a.push=t,a=a.slice();for(var i=0;i<a.length;i++)t(a[i]);var u=s;return o.push([
|
2 |
-
Object(l.__)("Remove %s","woo-gutenberg-products-block"),n),"aria-describedby":h},Object(o.createElement)(s.a,{icon:g.a,size:20,className:"clear-icon"})))};var f=j;const w=e=>Object(o.createElement)(p.b,e),h=e=>{const{list:t,selected:n,renderItem:r,depth:l=0,onSelect:a,instanceId:s,isSingle:i,search:u}=e;return t?Object(o.createElement)(o.Fragment,null,t.map(t=>{const b=-1!==n.findIndex(e=>{let{id:n}=e;return n===t.id});return Object(o.createElement)(o.Fragment,{key:t.id},Object(o.createElement)("li",null,r({item:t,isSelected:b,onSelect:a,isSingle:i,search:u,depth:l,controlId:s})),Object(o.createElement)(h,c()({},e,{list:t.children,depth:l+1})))})):null},_=e=>{let{isLoading:t,isSingle:n,selected:r,messages:c,onChange:s,onRemove:i}=e;if(t||n||!r)return null;const u=r.length;return Object(o.createElement)("div",{className:"woocommerce-search-list__selected"},Object(o.createElement)("div",{className:"woocommerce-search-list__selected-header"},Object(o.createElement)("strong",null,c.selected(u)),u>0?Object(o.createElement)(a.Button,{isLink:!0,isDestructive:!0,onClick:()=>s([]),"aria-label":c.clear},Object(l.__)("Clear all","woo-gutenberg-products-block")):null),u>0?Object(o.createElement)("ul",null,r.map((e,t)=>Object(o.createElement)("li",{key:t},Object(o.createElement)(f,{label:e.name,id:e.id,remove:i})))):null)},y=e=>{let{filteredList:t,search:n,onSelect:r,instanceId:c,...a}=e;const{messages:u,renderItem:b,selected:d,isSingle:m}=a,p=b||w;return 0===t.length?Object(o.createElement)("div",{className:"woocommerce-search-list__list is-not-found"},Object(o.createElement)("span",{className:"woocommerce-search-list__not-found-icon"},Object(o.createElement)(s.a,{icon:i.a})),Object(o.createElement)("span",{className:"woocommerce-search-list__not-found-text"},n?Object(l.sprintf)(u.noResults,n):u.noItems)):Object(o.createElement)("ul",{className:"woocommerce-search-list__list"},Object(o.createElement)(h,{list:t,selected:d,renderItem:p,onSelect:r,instanceId:c,isSingle:m,search:n}))},k=e=>{const{className:t="",isCompact:n,isHierarchical:r,isLoading:l,isSingle:s,list:i,messages:u=m.a,onChange:p,onSearch:g,selected:O,debouncedSpeak:j}=e,[f,w]=Object(o.useState)(""),h=Object(d.useInstanceId)(k),E=Object(o.useMemo)(()=>({...m.a,...u}),[u]),v=Object(o.useMemo)(()=>Object(m.c)(i,f,r),[i,f,r]);Object(o.useEffect)(()=>{j&&j(E.updated)},[j,E]),Object(o.useEffect)(()=>{"function"==typeof g&&g(f)},[f,g]);const S=Object(o.useCallback)(e=>()=>{s&&p([]);const t=O.findIndex(t=>{let{id:n}=t;return n===e});p([...O.slice(0,t),...O.slice(t+1)])},[s,O,p]),C=Object(o.useCallback)(e=>()=>{-1===O.findIndex(t=>{let{id:n}=t;return n===e.id})?p(s?[e]:[...O,e]):S(e.id)()},[s,S,p,O]);return Object(o.createElement)("div",{className:b()("woocommerce-search-list",t,{"is-compact":n})},Object(o.createElement)(_,c()({},e,{onRemove:S,messages:E})),Object(o.createElement)("div",{className:"woocommerce-search-list__search"},Object(o.createElement)(a.TextControl,{label:E.search,type:"search",value:f,onChange:e=>w(e)})),l?Object(o.createElement)("div",{className:"woocommerce-search-list__list is-loading"},Object(o.createElement)(a.Spinner,null)):Object(o.createElement)(y,c()({},e,{search:f,filteredList:v,messages:E,onSelect:C,instanceId:h})))};Object(a.withSpokenMessages)(k)},102:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(0);const c=Object(r.createContext)({}),o=()=>{const{wrapper:e}=Object(r.useContext)(c);return t=>{e&&e.current&&(e.current.hidden=!t)}}},103:function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(12);function c(e,t){const n=Object(r.useRef)();return Object(r.useEffect)(()=>{n.current===e||t&&!t(e,n.current)||(n.current=e)},[e,t]),n.current}},106:function(e,t){e.exports=window.wp.warning},107:function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),c=n(7),o=n(0),l=n(40),a=n(142);const s=e=>{const{namespace:t,resourceName:n,resourceValues:s=[],query:i={},shouldSelect:u=!0}=e;if(!t||!n)throw new Error("The options object must have valid values for the namespace and the resource properties.");const b=Object(o.useRef)({results:[],isLoading:!0}),d=Object(l.a)(i),m=Object(l.a)(s),p=Object(a.a)(),g=Object(c.useSelect)(e=>{if(!u)return null;const c=e(r.COLLECTIONS_STORE_KEY),o=[t,n,d,m],l=c.getCollectionError(...o);if(l){if(!(l instanceof Error))throw new Error("TypeError: `error` object is not an instance of Error constructor");p(l)}return{results:c.getCollection(...o),isLoading:!c.hasFinishedResolution("getCollection",o)}},[t,n,m,d,u]);return null!==g&&(b.current=g),b.current}},11:function(e,t){e.exports=window.wp.compose},112:function(e,t,n){"use strict";var r=n(0),c=n(1),o=n(28);n(280),t.a=e=>{let{name:t,count:n}=e;return Object(r.createElement)(r.Fragment,null,t,null!==n&&Number.isFinite(n)&&Object(r.createElement)(o.a,{label:n.toString(),screenReaderLabel:Object(c.sprintf)(
|
3 |
/* translators: %s number of products. */
|
4 |
-
Object(c._n)("%s product","%s products",n,"woo-gutenberg-products-block"),n),wrapperElement:"span",wrapperProps:{className:"wc-filter-element-label-list-count"}}))}},12:function(e,t){e.exports=window.
|
5 |
/* translators: Reset button text for filters. */
|
6 |
-
n=Object(c.__)("Reset","woo-gutenberg-products-block"),onClick:o,screenReaderLabel:s=Object(c.__)("Reset filter","woo-gutenberg-products-block")}=e;return Object(r.createElement)("button",{className:l()("wc-block-components-filter-reset-button",t),onClick:o},Object(r.createElement)(a.a,{label:n,screenReaderLabel:s}))}},
|
7 |
/* translators: Submit button text for filters. */
|
8 |
-
s=Object(c.__)("Apply","woo-gutenberg-products-block"),onClick:i,screenReaderLabel:u=Object(c.__)("Apply filter","woo-gutenberg-products-block")}=e;return Object(r.createElement)("button",{type:"submit",className:l()("wp-block-button__link","wc-block-filter-submit-button","wc-block-components-filter-submit-button",{"is-loading":n},t),disabled:o,onClick:i},Object(r.createElement)(a.a,{label:s,screenReaderLabel:u}))}},
|
9 |
/* translators: %s is referring the remaining count of options */
|
10 |
Object(c._n)("Show %s more option","Show %s more options",e,"woo-gutenberg-products-block"),e)},Object(c.sprintf)(
|
11 |
/* translators: %s number of options to reveal. */
|
12 |
-
Object(c._n)("Show %s more","Show %s more",e,"woo-gutenberg-products-block"),e)))},[o,b,d]),O=Object(r.useMemo)(()=>d&&Object(r.createElement)("li",{key:"show-less",className:"show-less"},Object(r.createElement)("button",{onClick:()=>{m(!1)},"aria-expanded":!0,"aria-label":Object(c.__)("Show less options","woo-gutenberg-products-block")},Object(c.__)("Show less","woo-gutenberg-products-block"))),[d]),j=Object(r.useMemo)(()=>{const e=o.length>b+5;return Object(r.createElement)(r.Fragment,null,o.map((t,c)=>Object(r.createElement)(r.Fragment,{key:t.value},Object(r.createElement)("li",e&&!d&&c>=b&&{hidden:!0},Object(r.createElement)(a.CheckboxControl,{id:t.value,className:"wc-block-checkbox-list__checkbox",label:t.label,checked:s.includes(t.value),onChange:()=>{n(t.value)}})),e&&c===b-1&&g)),e&&O)},[o,n,s,d,b,O,g,u]),f=l()("wc-block-checkbox-list","wc-block-components-checkbox-list",{"is-loading":i},t);return Object(r.createElement)("ul",{className:f},i?p:j)}},16:function(e,t){e.exports=window.
|
13 |
/* Translators: %s search term */
|
14 |
noResults:Object(o.__)("No results for %s","woo-gutenberg-products-block"),search:Object(o.__)("Search for items","woo-gutenberg-products-block"),selected:e=>Object(o.sprintf)(
|
15 |
/* translators: Number of items selected from list. */
|
16 |
-
Object(o._n)("%d item selected","%d items selected",e,"woo-gutenberg-products-block"),e),updated:Object(o.__)("Search results updated.","woo-gutenberg-products-block")},a=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;const n=Object(c.groupBy)(e,"parent"),r=Object(c.keyBy)(t,"id"),o=["0"],l=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e.parent)return e.name?[e.name]:[];const t=l(r[e.parent]);return[...t,e.name]},a=e=>e.map(e=>{const t=n[e.id];return o.push(""+e.id),{...e,breadcrumbs:l(r[e.parent]),children:t&&t.length?a(t):[]}}),s=a(n[0]||[]);return Object.entries(n).forEach(e=>{let[t,n]=e;o.includes(t)||s.push(...a(n||[]))}),s},s=(e,t,n)=>{if(!t)return n?a(e):e;const r=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),c=e.map(e=>!!r.test(e.name)&&e).filter(Boolean);return n?a(c,e):c},i=(e,t)=>{if(!t)return e;const n=new RegExp(`(${t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")})`,"ig");return e.split(n).map((e,t)=>n.test(e)?Object(r.createElement)("strong",{key:t},e):Object(r.createElement)(r.Fragment,{key:t},e))},u=e=>1===e.length?e.slice(0,1).toString():2===e.length?e.slice(0,1).toString()+" › "+e.slice(-1).toString():e.slice(0,1).toString()+" … "+e.slice(-1).toString()},199:function(e,t){},2:function(e,t){e.exports=window.wc.wcSettings},22:function(e,t,n){"use strict";n.d(t,"o",(function(){return o})),n.d(t,"m",(function(){return l})),n.d(t,"l",(function(){return a})),n.d(t,"n",(function(){return s})),n.d(t,"j",(function(){return i})),n.d(t,"e",(function(){return u})),n.d(t,"f",(function(){return b})),n.d(t,"g",(function(){return d})),n.d(t,"k",(function(){return m})),n.d(t,"c",(function(){return p})),n.d(t,"d",(function(){return g})),n.d(t,"h",(function(){return O})),n.d(t,"a",(function(){return j})),n.d(t,"i",(function(){return f})),n.d(t,"b",(function(){return w}));var r,c=n(2);const o=Object(c.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),l=o.pluginUrl+"images/",a=o.pluginUrl+"build/",s=o.buildPhase,i=null===(r=c.STORE_PAGES.shop)||void 0===r?void 0:r.permalink,u=c.STORE_PAGES.checkout.id,b=c.STORE_PAGES.checkout.permalink,d=c.STORE_PAGES.privacy.permalink,m=(c.STORE_PAGES.privacy.title,c.STORE_PAGES.terms.permalink),p=(c.STORE_PAGES.terms.title,c.STORE_PAGES.cart.id),g=c.STORE_PAGES.cart.permalink,O=(c.STORE_PAGES.myaccount.permalink?c.STORE_PAGES.myaccount.permalink:Object(c.getSetting)("wpLoginUrl","/wp-login.php"),Object(c.getSetting)("shippingCountries",{})),j=Object(c.getSetting)("allowedCountries",{}),f=Object(c.getSetting)("shippingStates",{}),w=Object(c.getSetting)("allowedStates",{})},223:function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return l}));var r=n(2);const c=Object(r.getSetting)("attributes",[]).reduce((e,t)=>{const n=(r=t)&&r.attribute_name?{id:parseInt(r.attribute_id,10),name:r.attribute_name,taxonomy:"pa_"+r.attribute_name,label:r.attribute_label}:null;var r;return n&&n.id&&e.push(n),e},[]),o=e=>{if(e)return c.find(t=>t.id===e)},l=e=>{if(e)return c.find(t=>t.taxonomy===e)}},241:function(e,t,n){"use strict";n.d(t,"b",(function(){return a})),n.d(t,"a",(function(){return s})),n.d(t,"d",(function(){return i})),n.d(t,"c",(function(){return u}));var r=n(16),c=n(2),o=n(127);const l=Object(c.getSettingWithCoercion)("is_rendering_php_template",!1,o.a),a="query_type_",s="filter_";function i(e){return window?Object(r.getQueryArg)(window.location.href,e):null}function u(e){l?window.location.href=e:window.history.replaceState({},"",e)}},25:function(e,t){e.exports=window.wp.isShallowEqual},279:function(e,t,n){"use strict";n.d(t,"a",(function(){return b}));var r=n(0),c=n(259),o=n(8),l=n(40),a=n(35),s=n(52),i=n(107),u=n(46);const b=e=>{let{queryAttribute:t,queryPrices:n,queryStock:b,queryRating:d,queryState:m,productIds:p}=e,g=Object(u.a)();g+="-collection-data";const[O]=Object(s.a)(g),[j,f]=Object(s.b)("calculate_attribute_counts",[],g),[w,h]=Object(s.b)("calculate_price_range",null,g),[_,y]=Object(s.b)("calculate_stock_status_counts",null,g),[k,E]=Object(s.b)("calculate_rating_counts",null,g),v=Object(l.a)(t||{}),S=Object(l.a)(n),C=Object(l.a)(b),x=Object(l.a)(d);Object(r.useEffect)(()=>{"object"==typeof v&&Object.keys(v).length&&(j.find(e=>Object(a.b)(v,"taxonomy")&&e.taxonomy===v.taxonomy)||f([...j,v]))},[v,j,f]),Object(r.useEffect)(()=>{w!==S&&void 0!==S&&h(S)},[S,h,w]),Object(r.useEffect)(()=>{_!==C&&void 0!==C&&y(C)},[C,y,_]),Object(r.useEffect)(()=>{k!==x&&void 0!==x&&E(x)},[x,E,k]);const[N,T]=Object(r.useState)(!1),[A]=Object(c.a)(N,200);N||T(!0);const R=Object(r.useMemo)(()=>(e=>{const t=e;return Array.isArray(e.calculate_attribute_counts)&&(t.calculate_attribute_counts=Object(o.sortBy)(e.calculate_attribute_counts.map(e=>{let{taxonomy:t,queryType:n}=e;return{taxonomy:t,query_type:n}}),["taxonomy","query_type"])),t})(O),[O]);return Object(i.a)({namespace:"/wc/store/v1",resourceName:"products/collection-data",query:{...m,page:void 0,per_page:void 0,orderby:void 0,order:void 0,...!Object(o.isEmpty)(p)&&{include:p},...R},shouldSelect:A})}},28:function(e,t,n){"use strict";var r=n(0),c=n(4),o=n.n(c);t.a=e=>{let t,{label:n,screenReaderLabel:c,wrapperElement:l,wrapperProps:a={}}=e;const s=null!=n,i=null!=c;return!s&&i?(t=l||"span",a={...a,className:o()(a.className,"screen-reader-text")},Object(r.createElement)(t,a,c)):(t=l||r.Fragment,s&&i&&n!==c?Object(r.createElement)(t,a,Object(r.createElement)("span",{"aria-hidden":"true"},n),Object(r.createElement)("span",{className:"screen-reader-text"},c)):Object(r.createElement)(t,a,n))}},280:function(e,t){},3:function(e,t){e.exports=window.wp.components},35:function(e,t,n){"use strict";n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return c}));const r=e=>!(e=>null===e)(e)&&e instanceof Object&&e.constructor===Object;function c(e,t){return r(e)&&t in e}},37:function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(6),c=n.n(r),o=n(0),l=n(19);const a=e=>{let{countLabel:t,className:n,depth:r=0,controlId:a="",item:s,isSelected:i,isSingle:u,onSelect:b,search:d="",...m}=e;const p=null!=t&&void 0!==s.count&&null!==s.count,g=[n,"woocommerce-search-list__item"];g.push("depth-"+r),u&&g.push("is-radio-button"),p&&g.push("has-count");const O=s.breadcrumbs&&s.breadcrumbs.length,j=m.name||"search-list-item-"+a,f=`${j}-${s.id}`;return Object(o.createElement)("label",{htmlFor:f,className:g.join(" ")},u?Object(o.createElement)("input",c()({type:"radio",id:f,name:j,value:s.value,onChange:b(s),checked:i,className:"woocommerce-search-list__item-input"},m)):Object(o.createElement)("input",c()({type:"checkbox",id:f,name:j,value:s.value,onChange:b(s),checked:i,className:"woocommerce-search-list__item-input"},m)),Object(o.createElement)("span",{className:"woocommerce-search-list__item-label"},O?Object(o.createElement)("span",{className:"woocommerce-search-list__item-prefix"},Object(l.b)(s.breadcrumbs)):null,Object(o.createElement)("span",{className:"woocommerce-search-list__item-name"},Object(l.d)(s.name,d))),!!p&&Object(o.createElement)("span",{className:"woocommerce-search-list__item-count"},t||s.count))};t.b=a},40:function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(0),c=n(25),o=n.n(c);function l(e){const t=Object(r.useRef)(e);return o()(e,t.current)||(t.current=e),t.current}},407:function(e,t,n){e.exports=n(484)},408:function(e,t){},409:function(e,t){},410:function(e,t,n){"use strict";n.d(t,"b",(function(){return o})),n.d(t,"a",(function(){return a}));var r=n(35);const c=e=>Object(r.b)(e,"count")&&Object(r.b)(e,"description")&&Object(r.b)(e,"id")&&Object(r.b)(e,"name")&&Object(r.b)(e,"parent")&&Object(r.b)(e,"slug")&&"number"==typeof e.count&&"string"==typeof e.description&&"number"==typeof e.id&&"string"==typeof e.name&&"number"==typeof e.parent&&"string"==typeof e.slug,o=e=>Array.isArray(e)&&e.every(c),l=e=>Object(r.b)(e,"attribute")&&Object(r.b)(e,"operator")&&Object(r.b)(e,"slug")&&"string"==typeof e.attribute&&"string"==typeof e.operator&&Array.isArray(e.slug)&&e.slug.every(e=>"string"==typeof e),a=e=>Array.isArray(e)&&e.every(l)},411:function(e,t){},44:function(e,t){e.exports=window.wp.a11y},46:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(0);const c=Object(r.createContext)("page"),o=()=>Object(r.useContext)(c);c.Provider},484:function(e,t,n){"use strict";n.r(t);var r=n(6),c=n.n(r),o=n(0),l=n(10),a=n(5),s=n(61),i=n(117),u=n(530),b=n(4),d=n.n(b),m=n(1),p=n(258),g=n(100),O=n(8),j=n(2),f=n(123),w=n(3),h=n(155),_=n(40),y=n(103),k=n(52),E=n(107),v=n(279),S=n(112),C=n(125),x=n(126),N=n(25),T=n.n(N),A=n(15),R=n(314),P=n(16),B=n(127),L=n(96),I=n(35),F=n(410),q=n(547),G=n(241),M=n(562);n(411);var D=e=>{let{className:t,style:n,suggestions:r,multiple:l=!0,saveTransform:a=(e=>e.trim().replace(/\s/g,"-")),messages:s={},validateInput:i=(e=>r.includes(e)),label:u="",...b}=e;return Object(o.createElement)("div",{className:d()("wc-blocks-components-form-token-field-wrapper",t,{"single-selection":!l}),style:n},Object(o.createElement)(M.a,c()({label:u,__experimentalExpandOnFocus:!0,__experimentalShowHowTo:!1,__experimentalValidateInput:i,saveTransform:a,maxLength:l?void 0:1,suggestions:r,messages:s},b)))},Q=n(124),V=n(223),$=n(183);const U=[{value:"preview-1",formattedValue:"preview-1",name:"Blue",label:Object(o.createElement)(S.a,{name:"Blue",count:3}),textLabel:"Blue (3)"},{value:"preview-2",formattedValue:"preview-2",name:"Green",label:Object(o.createElement)(S.a,{name:"Green",count:3}),textLabel:"Green (3)"},{value:"preview-3",formattedValue:"preview-3",name:"Red",label:Object(o.createElement)(S.a,{name:"Red",count:2}),textLabel:"Red (2)"}],Y={id:0,name:"preview",taxonomy:"preview",label:"Preview"};n(409);var W=n(149);function K(){return Math.floor(Math.random()*Date.now())}const J=e=>e.replace("pa_",""),z=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const n={};t.forEach(e=>{const{attribute:t,slug:r,operator:c}=e,o=J(t),l=r.join(","),a=`${G.b}${o}`,s="in"===c?"or":"and";n[`${G.a}${o}`]=l,n[a]=s});const r=Object(P.removeQueryArgs)(e,...Object.keys(n));return Object(P.addQueryArgs)(r,n)},H=e=>{if(e){const t=Object(G.d)("filter_"+e.name);return"string"==typeof t?t.split(","):[]}return[]},Z=(e,t)=>{const n=Object.entries(t).reduce((e,t)=>{let[n,r]=t;return n.includes("query_type")?e:{...e,[n]:r}},{});return Object.entries(n).reduce((t,n)=>{let[r,c]=n;return e[r]===c&&t},!0)},X=e=>e.trim().replace(/\s/g,"-").replace(/_/g,"-").replace(/-+/g,"-").replace(/[^a-zA-Z0-9-]/g,"");var ee=n(156),te=e=>{let{isLoading:t=!1,options:n,checked:r,onChange:c}=e;return t?Object(o.createElement)(o.Fragment,null,Object(o.createElement)("span",{className:"is-loading"}),Object(o.createElement)("span",{className:"is-loading"})):Object(o.createElement)(ee.a,{className:"wc-block-attribute-filter-list",options:n,checked:r,onChange:c,isLoading:t,isDisabled:t})},ne=n(102),re=e=>{let{attributes:t,isEditor:n=!1}=e;const r=Object(j.getSettingWithCoercion)("has_filterable_products",!1,B.a),c=Object(j.getSettingWithCoercion)("is_rendering_php_template",!1,B.a),l=Object(j.getSettingWithCoercion)("page_url",window.location.href,L.a),a=n?[]:Object(j.getSettingWithCoercion)("product_ids",[],Array.isArray),[s,u]=Object(o.useState)(!1),b=t.isPreview&&!t.attributeId?Y:Object(V.a)(t.attributeId),p=Object(o.useMemo)(()=>H(b),[b]),[g,f]=Object(o.useState)(p),[w,N]=Object(o.useState)(K()),[M,W]=Object(o.useState)(t.isPreview&&!t.attributeId?U:[]),ee=Object(h.a)(t),[re]=Object(k.a)(),[ce,oe]=Object(k.b)("attributes",[]),{results:le,isLoading:ae}=Object(E.a)({namespace:"/wc/store/v1",resourceName:"products/attributes/terms",resourceValues:[(null==b?void 0:b.id)||0],shouldSelect:t.attributeId>0}),se="dropdown"!==t.displayStyle&&"and"===t.queryType,{results:ie,isLoading:ue}=Object(v.a)({queryAttribute:{taxonomy:(null==b?void 0:b.taxonomy)||"",queryType:t.queryType},queryState:{...re,attributes:se?re.attributes:null},productIds:a}),be=Object(o.useCallback)(e=>Object(I.b)(ie,"attribute_counts")&&Array.isArray(ie.attribute_counts)?ie.attribute_counts.find(t=>{let{term:n}=t;return n===e}):null,[ie]);Object(o.useEffect)(()=>{if(ae||ue)return;if(!Array.isArray(le))return;const e=le.map(e=>{const n=be(e.id);if(!(n||g.includes(e.slug)||(r=e.slug,null!=re&&re.attributes&&re.attributes.some(e=>{let{attribute:t,slug:n=[]}=e;return t===(null==b?void 0:b.taxonomy)&&n.includes(r)}))))return null;var r;const c=n?n.count:0;return{formattedValue:X(e.slug),value:e.slug,name:Object(A.decodeEntities)(e.name),label:Object(o.createElement)(S.a,{name:Object(A.decodeEntities)(e.name),count:t.showCounts?c:null}),textLabel:t.showCounts?`${Object(A.decodeEntities)(e.name)} (${c})`:Object(A.decodeEntities)(e.name)}}).filter(e=>!!e);W(e),N(K())},[null==b?void 0:b.taxonomy,le,ae,t.showCounts,ue,be,g,re.attributes]);const de=Object(o.useCallback)(e=>Array.isArray(le)?le.reduce((t,n)=>(e.includes(n.slug)&&t.push(n),t),[]):[],[le]),me=Object(o.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(t){if(null==b||!b.taxonomy)return;const t=Object.keys(Object(P.getQueryArgs)(window.location.href)),n=J(b.taxonomy),r=t.reduce((e,t)=>t.includes(G.b+n)||t.includes(G.a+n)?Object(P.removeQueryArgs)(e,t):e,window.location.href),c=z(r,e);Object(G.c)(c)}else{const t=z(l,e),n=Object(P.getQueryArgs)(window.location.href),r=Object(P.getQueryArgs)(t);Z(n,r)||Object(G.c)(t)}}),[l,null==b?void 0:b.taxonomy]),pe=e=>{const n=Object($.b)(ce,oe,b,de(e),"or"===t.queryType?"in":"and");me(n,0===e.length)},ge=Object(o.useCallback)((function(e){let r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];n||(f(e),!r&&t.showFilterButton||Object($.b)(ce,oe,b,de(e),"or"===t.queryType?"in":"and"))}),[n,f,ce,oe,b,de,t.queryType,t.showFilterButton]),Oe=Object(o.useMemo)(()=>Object(F.a)(ce)?ce.filter(e=>{let{attribute:t}=e;return t===(null==b?void 0:b.taxonomy)}).flatMap(e=>{let{slug:t}=e;return t}):[],[ce,null==b?void 0:b.taxonomy]),je=Object(_.a)(Oe),fe=Object(y.a)(je);Object(o.useEffect)(()=>{!fe||T()(fe,je)||T()(g,je)||ge(je)},[g,je,fe,ge]);const we="single"!==t.selectType,he=Object(o.useCallback)(e=>{const t=g.includes(e);let n;we?(n=g.filter(t=>t!==e),t||(n.push(e),n.sort())):n=t?[]:[e],ge(n)},[g,we,ge]);Object(o.useEffect)(()=>{b&&!t.showFilterButton&&((e=>{let{currentCheckedFilters:t,hasSetFilterDefaultsFromUrl:n}=e;return n&&0===t.length})({currentCheckedFilters:g,hasSetFilterDefaultsFromUrl:s})?me(ce,!0):me(ce,!1))},[s,me,ce,b,g,t.showFilterButton]),Object(o.useEffect)(()=>{if(!s&&!ae)return p.length>0?(u(!0),void ge(p,!0)):void(c||u(!0))},[b,s,ae,ge,p,c]);const _e=Object(ne.a)();if(!r)return _e(!1),null;if(!b)return n?Object(o.createElement)(R.a,{status:"warning",isDismissible:!1},Object(o.createElement)("p",null,Object(m.__)("Please select an attribute to use this filter!","woo-gutenberg-products-block"))):(_e(!1),null);if(0===M.length&&!ae&&n)return Object(o.createElement)(R.a,{status:"warning",isDismissible:!1},Object(o.createElement)("p",null,Object(m.__)("There are no products with the selected attributes.","woo-gutenberg-products-block")));const ye="h"+t.headingLevel,ke=!t.isPreview&&ae,Ee=!t.isPreview&&ue,ve=(ke||Ee)&&0===M.length;if(!ve&&0===M.length)return _e(!1),null;const Se=Object(o.createElement)(ye,{className:"wc-block-attribute-filter__title"},t.heading),Ce=ve?Object(o.createElement)(Q.a,null,Se):Se;return _e(!0),Object(o.createElement)(o.Fragment,null,!n&&t.heading&&Ce,Object(o.createElement)("div",{className:d()("wc-block-attribute-filter","style-"+t.displayStyle)},"dropdown"===t.displayStyle?Object(o.createElement)(o.Fragment,null,Object(o.createElement)(D,{key:w,className:d()(ee.className,{"single-selection":!we,"is-loading":ve}),style:{...ee.style,borderStyle:"none"},suggestions:M.filter(e=>!g.includes(e.value)).map(e=>e.formattedValue),disabled:ve,placeholder:Object(m.sprintf)(
|
17 |
/* translators: %s attribute name. */
|
18 |
Object(m.__)("Select %s","woo-gutenberg-products-block"),b.label),onChange:e=>{!we&&e.length>1&&(e=[e[e.length-1]]),e=e.map(e=>{const t=M.find(t=>t.formattedValue===e);return t?t.value:e});const t=Object(O.difference)(e,g);if(1===t.length)return he(t[0]);const n=Object(O.difference)(g,e);1===n.length&&he(n[0])},value:g,displayTransform:e=>{const t=M.find(t=>[t.value,t.formattedValue].includes(e));return t?t.textLabel:e},saveTransform:X,messages:{added:Object(m.sprintf)(
|
19 |
/* translators: %s is the attribute label. */
|
@@ -23,6 +22,7 @@ Object(m.__)("%s filter removed.","woo-gutenberg-products-block"),b.label),remov
|
|
23 |
/* translators: %s is the attribute label. */
|
24 |
Object(m.__)("Remove %s filter.","woo-gutenberg-products-block"),b.label.toLocaleLowerCase()),__experimentalInvalid:Object(m.sprintf)(
|
25 |
/* translators: %s is the attribute label. */
|
26 |
-
Object(m.__)("Invalid %s filter.","woo-gutenberg-products-block"),b.label.toLocaleLowerCase())}}),we&&Object(o.createElement)(i.a,{icon:q.a,size:30})):Object(o.createElement)(te,{options:M,checked:g,onChange:he,isLoading:ve,isDisabled:ve})),Object(o.createElement)("div",{className:"wc-block-attribute-filter__actions"},g.length>0&&!ve&&Object(o.createElement)(C.a,{onClick:()=>{f([]),N(K()),s&&pe([])},screenReaderLabel:Object(m.__)("Reset attribute filter","woo-gutenberg-products-block")}),t.showFilterButton&&Object(o.createElement)(x.a,{className:"wc-block-attribute-filter__button",isLoading:ve,disabled:(()=>{if(ke||Ee)return!0;const e=H(b);return e.length===g.length&&g.every(t=>e.includes(t))})(),onClick:()=>pe(g)})))},ce=(n(
|
27 |
/* translators: %d is the number of attributes selected. */
|
28 |
-
Object(m._n)("%d attribute selected","%d attributes selected",e,"woo-gutenberg-products-block"),e),updated:Object(m.__)("Product attribute search results updated.","woo-gutenberg-products-block")},r=Object(O.sortBy)(oe.map(e=>({id:parseInt(e.attribute_id,10),name:e.attribute_label})),"name");return Object(o.createElement)(g.a,{className:"woocommerce-product-attributes",list:r,selected:r.filter(e=>{let{id:t}=e;return t===l}),onChange:T,messages:n,isSingle:!0,isCompact:t})};return 0===Object.keys(oe).length?Object(o.createElement)(w.Placeholder,{className:"wc-block-attribute-filter",icon:Object(o.createElement)(i.a,{icon:u.a}),label:Object(m.__)("Filter by Attribute","woo-gutenberg-products-block"),instructions:Object(m.__)("Display a list of filters based on the selected attributes.","woo-gutenberg-products-block")},Object(o.createElement)("p",null,Object(m.__)("Attributes are needed for filtering your products. You haven't created any attributes yet.","woo-gutenberg-products-block")),Object(o.createElement)(w.Button,{className:"wc-block-attribute-filter__add-attribute-button",isSecondary:!0,href:Object(j.getAdminLink)("edit.php?post_type=product&page=product_attributes")},Object(m.__)("Add new attribute","woo-gutenberg-products-block")+" ",Object(o.createElement)(i.a,{icon:p.a})),Object(o.createElement)(w.Button,{className:"wc-block-attribute-filter__read_more_button",isTertiary:!0,href:"https://docs.woocommerce.com/document/managing-product-taxonomies/"},Object(m.__)("Learn more","woo-gutenberg-products-block"))):Object(o.createElement)("div",N,Object(o.createElement)(a.BlockControls,null,Object(o.createElement)(w.ToolbarGroup,{controls:[{icon:"edit",title:Object(m.__)("Edit","woo-gutenberg-products-block"),onClick:()=>x(!C),isActive:C}]})),Object(o.createElement)(a.InspectorControls,{key:"inspector"},Object(o.createElement)(w.PanelBody,{title:Object(m.__)("Display Settings","woo-gutenberg-products-block")},Object(o.createElement)(w.ToggleControl,{label:Object(m.__)("Include product count","woo-gutenberg-products-block"),checked:E,onChange:()=>n({showCounts:!E})}),Object(o.createElement)(w.__experimentalToggleGroupControl,{label:Object(m.__)("Allow selecting multiple options?","woo-gutenberg-products-block"),value:S||"multiple",onChange:e=>n({selectType:e}),className:"wc-block-attribute-filter__multiple-toggle"},Object(o.createElement)(w.__experimentalToggleGroupControlOption,{value:"multiple",label:Object(m.__)("Multiple","woo-gutenberg-products-block")}),Object(o.createElement)(w.__experimentalToggleGroupControlOption,{value:"single",label:Object(m.__)("Single","woo-gutenberg-products-block")})),"multiple"===S&&Object(o.createElement)(w.__experimentalToggleGroupControl,{label:Object(m.__)("Filter Conditions","woo-gutenberg-products-block"),help:"and"===k?Object(m.__)("Choose to return filter results for all of the attributes selected.","woo-gutenberg-products-block"):Object(m.__)("Choose to return filter results for any of the attributes selected.","woo-gutenberg-products-block"),value:k,onChange:e=>n({queryType:e}),className:"wc-block-attribute-filter__conditions-toggle"},Object(o.createElement)(w.__experimentalToggleGroupControlOption,{value:"and",label:Object(m.__)("All","woo-gutenberg-products-block")}),Object(o.createElement)(w.__experimentalToggleGroupControlOption,{value:"or",label:Object(m.__)("Any","woo-gutenberg-products-block")})),Object(o.createElement)(w.__experimentalToggleGroupControl,{label:Object(m.__)("Display Style","woo-gutenberg-products-block"),value:b,onChange:e=>n({displayStyle:e}),className:"wc-block-attribute-filter__display-toggle"},Object(o.createElement)(w.__experimentalToggleGroupControlOption,{value:"list",label:Object(m.__)("List","woo-gutenberg-products-block")}),Object(o.createElement)(w.__experimentalToggleGroupControlOption,{value:"dropdown",label:Object(m.__)("Dropdown","woo-gutenberg-products-block")})),Object(o.createElement)(w.ToggleControl,{label:Object(m.__)("Show 'Apply filters' button","woo-gutenberg-products-block"),help:v?Object(m.__)("Products will only update when the button is clicked.","woo-gutenberg-products-block"):Object(m.__)("Products will update as soon as attributes are selected.","woo-gutenberg-products-block"),checked:v,onChange:e=>n({showFilterButton:e})})),Object(o.createElement)(w.PanelBody,{title:Object(m.__)("Content Settings","woo-gutenberg-products-block"),initialOpen:!1},A({isCompact:!0}))),Object(o.createElement)(ce.a,{clientId:c,attributes:t,setAttributes:n,filterType:"attribute-filter"}),C?Object(o.createElement)(w.Placeholder,{className:"wc-block-attribute-filter",icon:Object(o.createElement)(i.a,{icon:u.a}),label:Object(m.__)("Filter by Attribute","woo-gutenberg-products-block")},Object(o.createElement)("div",{className:"wc-block-attribute-filter__instructions"},Object(m.__)("Display a list of filters based on the selected attributes.","woo-gutenberg-products-block")),Object(o.createElement)("div",{className:"wc-block-attribute-filter__selection"},A({isCompact:!1}),Object(o.createElement)(w.Button,{isPrimary:!0,onClick:()=>{x(!1),r(Object(m.__)("Now displaying a preview of the Filter Products by Attribute block.","woo-gutenberg-products-block"))}},Object(m.__)("Done","woo-gutenberg-products-block")))):Object(o.createElement)("div",{className:d()(s,"wc-block-attribute-filter")},h&&Object(o.createElement)(f.a,{className:"wc-block-attribute-filter__title",headingLevel:_,heading:h,onChange:e=>n({heading:e})}),Object(o.createElement)(w.Disabled,null,Object(o.createElement)(re,{attributes:t,isEditor:!0}))))});const ae={heading:{type:"string",default:Object(m.__)("Filter by attribute","woo-gutenberg-products-block")}};Object(l.registerBlockType)(W,{icon:{src:Object(o.createElement)(i.a,{icon:u.a,className:"wc-block-editor-components-block-icon"})},supports:{...W.supports,...Object(s.b)()&&{__experimentalBorder:{radius:!1,color:!0,width:!1}}},attributes:{...W.attributes,...ae},edit:le,save(e){let{attributes:t}=e;const{className:n,showCounts:r,queryType:l,attributeId:s,heading:i,headingLevel:u,displayStyle:b,showFilterButton:m,selectType:p}=t,g={"data-attribute-id":s,"data-show-counts":r,"data-query-type":l,"data-heading":i,"data-heading-level":u};return"list"!==b&&(g["data-display-style"]=b),m&&(g["data-show-filter-button"]=m),"single"===p&&(g["data-select-type"]=p),Object(o.createElement)("div",c()({},a.useBlockProps.save({className:d()("is-loading",n)}),g),Object(o.createElement)("span",{"aria-hidden":!0,className:"wc-block-product-attribute-filter__placeholder"}))}})},5:function(e,t){e.exports=window.wp.blockEditor},
|
|
1 |
+
this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["attribute-filter"]=function(e){function t(t){for(var r,l,a=t[0],s=t[1],i=t[2],b=0,d=[];b<a.length;b++)l=a[b],Object.prototype.hasOwnProperty.call(c,l)&&c[l]&&d.push(c[l][0]),c[l]=0;for(r in s)Object.prototype.hasOwnProperty.call(s,r)&&(e[r]=s[r]);for(u&&u(t);d.length;)d.shift()();return o.push.apply(o,i||[]),n()}function n(){for(var e,t=0;t<o.length;t++){for(var n=o[t],r=!0,a=1;a<n.length;a++){var s=n[a];0!==c[s]&&(r=!1)}r&&(o.splice(t--,1),e=l(l.s=n[0]))}return e}var r={},c={8:0,1:0},o=[];function l(t){if(r[t])return r[t].exports;var n=r[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,l),n.l=!0,n.exports}l.m=e,l.c=r,l.d=function(e,t,n){l.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,t){if(1&t&&(e=l(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(l.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)l.d(n,r,function(t){return e[t]}.bind(null,r));return n},l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,"a",t),t},l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.p="";var a=window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[],s=a.push.bind(a);a.push=t,a=a.slice();for(var i=0;i<a.length;i++)t(a[i]);var u=s;return o.push([397,0]),n()}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},10:function(e,t){e.exports=window.wc.wcBlocksData},101:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(0);const c=Object(r.createContext)({}),o=()=>{const{wrapper:e}=Object(r.useContext)(c);return t=>{e&&e.current&&(e.current.hidden=!t)}}},102:function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(13);function c(e,t){const n=Object(r.useRef)();return Object(r.useEffect)(()=>{n.current===e||t&&!t(e,n.current)||(n.current=e)},[e,t]),n.current}},105:function(e,t){e.exports=window.wp.warning},106:function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(10),c=n(7),o=n(0),l=n(40),a=n(141);const s=e=>{const{namespace:t,resourceName:n,resourceValues:s=[],query:i={},shouldSelect:u=!0}=e;if(!t||!n)throw new Error("The options object must have valid values for the namespace and the resource properties.");const b=Object(o.useRef)({results:[],isLoading:!0}),d=Object(l.a)(i),m=Object(l.a)(s),p=Object(a.a)(),g=Object(c.useSelect)(e=>{if(!u)return null;const c=e(r.COLLECTIONS_STORE_KEY),o=[t,n,d,m],l=c.getCollectionError(...o);if(l){if(!(l instanceof Error))throw new Error("TypeError: `error` object is not an instance of Error constructor");p(l)}return{results:c.getCollection(...o),isLoading:!c.hasFinishedResolution("getCollection",o)}},[t,n,m,d,u]);return null!==g&&(b.current=g),b.current}},11:function(e,t){e.exports=window.wp.compose},111:function(e,t,n){"use strict";var r=n(0),c=n(1),o=n(28);n(272),t.a=e=>{let{name:t,count:n}=e;return Object(r.createElement)(r.Fragment,null,t,null!==n&&Number.isFinite(n)&&Object(r.createElement)(o.a,{label:n.toString(),screenReaderLabel:Object(c.sprintf)(
|
|
|
2 |
/* translators: %s number of products. */
|
3 |
+
Object(c._n)("%s product","%s products",n,"woo-gutenberg-products-block"),n),wrapperElement:"span",wrapperProps:{className:"wc-filter-element-label-list-count"}}))}},12:function(e,t){e.exports=window.wp.primitives},121:function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(0),c=n(1),o=n(9),l=n(7),a=n(3),s=n(5);const i=e=>{let{clientId:t,setAttributes:n,filterType:i,attributes:u}=e;const{replaceBlock:b}=Object(l.useDispatch)("core/block-editor"),{heading:d,headingLevel:m}=u;if(Object(l.useSelect)(e=>{const{getBlockParentsByBlockName:n}=e("core/block-editor");return n(t,"woocommerce/filter-wrapper").length>0},[t])||!i)return null;const p=[Object(r.createElement)(a.Button,{key:"convert",onClick:()=>{const e=[Object(o.createBlock)("woocommerce/"+i,{...u,heading:""})];d&&""!==d&&e.unshift(Object(o.createBlock)("core/heading",{content:d,level:null!=m?m:2})),b(t,Object(o.createBlock)("woocommerce/filter-wrapper",{heading:d,filterType:i},[...e])),n({heading:"",lock:{remove:!0}})},variant:"primary"},Object(c.__)("Upgrade block","woo-gutenberg-products-block"))];return Object(r.createElement)(s.Warning,{actions:p},Object(c.__)("Filter block: We have improved this block to make styling easier. Upgrade it using the button below.","woo-gutenberg-products-block"))}},122:function(e,t,n){"use strict";var r=n(0),c=n(5),o=n(11),l=n(1);n(166),t.a=Object(o.withInstanceId)(e=>{let{className:t,headingLevel:n,onChange:o,heading:a,instanceId:s}=e;const i="h"+n;return Object(r.createElement)(i,{className:t},Object(r.createElement)("label",{className:"screen-reader-text",htmlFor:"block-title-"+s},Object(l.__)("Block title","woo-gutenberg-products-block")),Object(r.createElement)(c.PlainText,{id:"block-title-"+s,className:"wc-block-editor-components-title",value:a,onChange:o}))})},123:function(e,t,n){"use strict";var r=n(0);n(167),t.a=e=>{let{children:t}=e;return Object(r.createElement)("div",{className:"wc-block-filter-title-placeholder"},t)}},124:function(e,t,n){"use strict";var r=n(0),c=n(1),o=n(4),l=n.n(o),a=n(28);n(168),t.a=e=>{let{className:t,label:
|
4 |
/* translators: Reset button text for filters. */
|
5 |
+
n=Object(c.__)("Reset","woo-gutenberg-products-block"),onClick:o,screenReaderLabel:s=Object(c.__)("Reset filter","woo-gutenberg-products-block")}=e;return Object(r.createElement)("button",{className:l()("wc-block-components-filter-reset-button",t),onClick:o},Object(r.createElement)(a.a,{label:n,screenReaderLabel:s}))}},125:function(e,t,n){"use strict";var r=n(0),c=n(1),o=n(4),l=n.n(o),a=n(28);n(169),t.a=e=>{let{className:t,isLoading:n,disabled:o,label:
|
6 |
/* translators: Submit button text for filters. */
|
7 |
+
s=Object(c.__)("Apply","woo-gutenberg-products-block"),onClick:i,screenReaderLabel:u=Object(c.__)("Apply filter","woo-gutenberg-products-block")}=e;return Object(r.createElement)("button",{type:"submit",className:l()("wp-block-button__link","wc-block-filter-submit-button","wc-block-components-filter-submit-button",{"is-loading":n},t),disabled:o,onClick:i},Object(r.createElement)(a.a,{label:s,screenReaderLabel:u}))}},126:function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));const r=e=>"boolean"==typeof e},13:function(e,t){e.exports=window.React},130:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(95),c=n(35);const o=e=>Object(r.a)(e)?JSON.parse(e)||{}:Object(c.a)(e)?e:{}},141:function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(0);const c=()=>{const[,e]=Object(r.useState)();return Object(r.useCallback)(t=>{e(()=>{throw t})},[])}},148:function(e){e.exports=JSON.parse('{"name":"woocommerce/attribute-filter","version":"1.0.0","title":"Filter by Attribute Controls","description":"Enable customers to filter the product grid by selecting one or more attributes, such as color.","category":"woocommerce","keywords":["WooCommerce"],"supports":{"html":false,"color":{"text":true,"background":false},"inserter":false,"lock":false},"example":{"attributes":{"isPreview":true}},"attributes":{"className":{"type":"string","default":""},"attributeId":{"type":"number","default":0},"showCounts":{"type":"boolean","default":true},"queryType":{"type":"string","default":"or"},"headingLevel":{"type":"number","default":3},"displayStyle":{"type":"string","default":"list"},"showFilterButton":{"type":"boolean","default":false},"selectType":{"type":"string","default":"multiple"},"isPreview":{"type":"boolean","default":false}},"textdomain":"woo-gutenberg-products-block","apiVersion":2,"$schema":"https://schemas.wp.org/trunk/block.json"}')},15:function(e,t){e.exports=window.wp.htmlEntities},154:function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(5),c=n(61),o=n(35),l=n(130);const a=e=>{if(!Object(c.b)())return{className:"",style:{}};const t=Object(o.a)(e)?e:{},n=Object(l.a)(t.style);return Object(r.__experimentalUseBorderProps)({...t,style:n})}},155:function(e,t,n){"use strict";var r=n(0),c=n(1),o=n(4),l=n.n(o),a=n(16);n(194),t.a=e=>{let{className:t,onChange:n,options:o=[],checked:s=[],isLoading:i=!1,isDisabled:u=!1,limit:b=10}=e;const[d,m]=Object(r.useState)(!1),p=Object(r.useMemo)(()=>[...Array(5)].map((e,t)=>Object(r.createElement)("li",{key:t,style:{width:Math.floor(75*Math.random())+25+"%"}})),[]),g=Object(r.useMemo)(()=>{const e=o.length-b;return!d&&Object(r.createElement)("li",{key:"show-more",className:"show-more"},Object(r.createElement)("button",{onClick:()=>{m(!0)},"aria-expanded":!1,"aria-label":Object(c.sprintf)(
|
8 |
/* translators: %s is referring the remaining count of options */
|
9 |
Object(c._n)("Show %s more option","Show %s more options",e,"woo-gutenberg-products-block"),e)},Object(c.sprintf)(
|
10 |
/* translators: %s number of options to reveal. */
|
11 |
+
Object(c._n)("Show %s more","Show %s more",e,"woo-gutenberg-products-block"),e)))},[o,b,d]),O=Object(r.useMemo)(()=>d&&Object(r.createElement)("li",{key:"show-less",className:"show-less"},Object(r.createElement)("button",{onClick:()=>{m(!1)},"aria-expanded":!0,"aria-label":Object(c.__)("Show less options","woo-gutenberg-products-block")},Object(c.__)("Show less","woo-gutenberg-products-block"))),[d]),j=Object(r.useMemo)(()=>{const e=o.length>b+5;return Object(r.createElement)(r.Fragment,null,o.map((t,c)=>Object(r.createElement)(r.Fragment,{key:t.value},Object(r.createElement)("li",e&&!d&&c>=b&&{hidden:!0},Object(r.createElement)(a.CheckboxControl,{id:t.value,className:"wc-block-checkbox-list__checkbox",label:t.label,checked:s.includes(t.value),onChange:()=>{n(t.value)},disabled:u})),e&&c===b-1&&g)),e&&O)},[o,n,s,d,b,O,g,u]),f=l()("wc-block-checkbox-list","wc-block-components-checkbox-list",{"is-loading":i},t);return Object(r.createElement)("ul",{className:f},i?p:j)}},16:function(e,t){e.exports=window.wc.blocksCheckout},166:function(e,t){},167:function(e,t){},168:function(e,t){},169:function(e,t){},17:function(e,t){e.exports=window.wp.url},180:function(e,t,n){"use strict";n.d(t,"a",(function(){return c})),n.d(t,"b",(function(){return o}));var r=n(8);const c=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";const o=e.filter(e=>e.attribute===n.taxonomy),l=o.length?o[0]:null;if(!(l&&l.slug&&Array.isArray(l.slug)&&l.slug.includes(c)))return;const a=l.slug.filter(e=>e!==c),s=e.filter(e=>e.attribute!==n.taxonomy);a.length>0&&(l.slug=a.sort(),s.push(l)),t(Object(r.sortBy)(s,"attribute"))},o=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"in";if(!n||!n.taxonomy)return[];const l=e.filter(e=>e.attribute!==n.taxonomy);return 0===c.length?t(l):(l.push({attribute:n.taxonomy,operator:o,slug:c.map(e=>{let{slug:t}=e;return t}).sort()}),t(Object(r.sortBy)(l,"attribute"))),l}},19:function(e,t,n){"use strict";n.d(t,"a",(function(){return l})),n.d(t,"c",(function(){return s})),n.d(t,"d",(function(){return i})),n.d(t,"b",(function(){return u}));var r=n(0),c=n(8),o=n(1);const l={clear:Object(o.__)("Clear all selected items","woo-gutenberg-products-block"),noItems:Object(o.__)("No items found.","woo-gutenberg-products-block"),
|
12 |
/* Translators: %s search term */
|
13 |
noResults:Object(o.__)("No results for %s","woo-gutenberg-products-block"),search:Object(o.__)("Search for items","woo-gutenberg-products-block"),selected:e=>Object(o.sprintf)(
|
14 |
/* translators: Number of items selected from list. */
|
15 |
+
Object(o._n)("%d item selected","%d items selected",e,"woo-gutenberg-products-block"),e),updated:Object(o.__)("Search results updated.","woo-gutenberg-products-block")},a=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;const n=Object(c.groupBy)(e,"parent"),r=Object(c.keyBy)(t,"id"),o=["0"],l=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e.parent)return e.name?[e.name]:[];const t=l(r[e.parent]);return[...t,e.name]},a=e=>e.map(e=>{const t=n[e.id];return o.push(""+e.id),{...e,breadcrumbs:l(r[e.parent]),children:t&&t.length?a(t):[]}}),s=a(n[0]||[]);return Object.entries(n).forEach(e=>{let[t,n]=e;o.includes(t)||s.push(...a(n||[]))}),s},s=(e,t,n)=>{if(!t)return n?a(e):e;const r=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),c=e.map(e=>!!r.test(e.name)&&e).filter(Boolean);return n?a(c,e):c},i=(e,t)=>{if(!t)return e;const n=new RegExp(`(${t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")})`,"ig");return e.split(n).map((e,t)=>n.test(e)?Object(r.createElement)("strong",{key:t},e):Object(r.createElement)(r.Fragment,{key:t},e))},u=e=>1===e.length?e.slice(0,1).toString():2===e.length?e.slice(0,1).toString()+" › "+e.slice(-1).toString():e.slice(0,1).toString()+" … "+e.slice(-1).toString()},194:function(e,t){},2:function(e,t){e.exports=window.wc.wcSettings},21:function(e,t,n){"use strict";n.d(t,"o",(function(){return o})),n.d(t,"m",(function(){return l})),n.d(t,"l",(function(){return a})),n.d(t,"n",(function(){return s})),n.d(t,"j",(function(){return i})),n.d(t,"e",(function(){return u})),n.d(t,"f",(function(){return b})),n.d(t,"g",(function(){return d})),n.d(t,"k",(function(){return m})),n.d(t,"c",(function(){return p})),n.d(t,"d",(function(){return g})),n.d(t,"h",(function(){return O})),n.d(t,"a",(function(){return j})),n.d(t,"i",(function(){return f})),n.d(t,"b",(function(){return w}));var r,c=n(2);const o=Object(c.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),l=o.pluginUrl+"images/",a=o.pluginUrl+"build/",s=o.buildPhase,i=null===(r=c.STORE_PAGES.shop)||void 0===r?void 0:r.permalink,u=c.STORE_PAGES.checkout.id,b=c.STORE_PAGES.checkout.permalink,d=c.STORE_PAGES.privacy.permalink,m=(c.STORE_PAGES.privacy.title,c.STORE_PAGES.terms.permalink),p=(c.STORE_PAGES.terms.title,c.STORE_PAGES.cart.id),g=c.STORE_PAGES.cart.permalink,O=(c.STORE_PAGES.myaccount.permalink?c.STORE_PAGES.myaccount.permalink:Object(c.getSetting)("wpLoginUrl","/wp-login.php"),Object(c.getSetting)("shippingCountries",{})),j=Object(c.getSetting)("allowedCountries",{}),f=Object(c.getSetting)("shippingStates",{}),w=Object(c.getSetting)("allowedStates",{})},217:function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return l}));var r=n(2);const c=Object(r.getSetting)("attributes",[]).reduce((e,t)=>{const n=(r=t)&&r.attribute_name?{id:parseInt(r.attribute_id,10),name:r.attribute_name,taxonomy:"pa_"+r.attribute_name,label:r.attribute_label}:null;var r;return n&&n.id&&e.push(n),e},[]),o=e=>{if(e)return c.find(t=>t.id===e)},l=e=>{if(e)return c.find(t=>t.taxonomy===e)}},234:function(e,t,n){"use strict";n.d(t,"b",(function(){return a})),n.d(t,"a",(function(){return s})),n.d(t,"d",(function(){return i})),n.d(t,"c",(function(){return u}));var r=n(17),c=n(2),o=n(126);const l=Object(c.getSettingWithCoercion)("is_rendering_php_template",!1,o.a),a="query_type_",s="filter_";function i(e){return window?Object(r.getQueryArg)(window.location.href,e):null}function u(e){l?window.location.href=e:window.history.replaceState({},"",e)}},25:function(e,t){e.exports=window.wp.isShallowEqual},271:function(e,t,n){"use strict";n.d(t,"a",(function(){return b}));var r=n(0),c=n(251),o=n(8),l=n(40),a=n(35),s=n(51),i=n(106),u=n(46);const b=e=>{let{queryAttribute:t,queryPrices:n,queryStock:b,queryRating:d,queryState:m,productIds:p}=e,g=Object(u.a)();g+="-collection-data";const[O]=Object(s.a)(g),[j,f]=Object(s.b)("calculate_attribute_counts",[],g),[w,h]=Object(s.b)("calculate_price_range",null,g),[_,y]=Object(s.b)("calculate_stock_status_counts",null,g),[k,E]=Object(s.b)("calculate_rating_counts",null,g),v=Object(l.a)(t||{}),S=Object(l.a)(n),C=Object(l.a)(b),x=Object(l.a)(d);Object(r.useEffect)(()=>{"object"==typeof v&&Object.keys(v).length&&(j.find(e=>Object(a.b)(v,"taxonomy")&&e.taxonomy===v.taxonomy)||f([...j,v]))},[v,j,f]),Object(r.useEffect)(()=>{w!==S&&void 0!==S&&h(S)},[S,h,w]),Object(r.useEffect)(()=>{_!==C&&void 0!==C&&y(C)},[C,y,_]),Object(r.useEffect)(()=>{k!==x&&void 0!==x&&E(x)},[x,E,k]);const[N,T]=Object(r.useState)(!1),[A]=Object(c.a)(N,200);N||T(!0);const R=Object(r.useMemo)(()=>(e=>{const t=e;return Array.isArray(e.calculate_attribute_counts)&&(t.calculate_attribute_counts=Object(o.sortBy)(e.calculate_attribute_counts.map(e=>{let{taxonomy:t,queryType:n}=e;return{taxonomy:t,query_type:n}}),["taxonomy","query_type"])),t})(O),[O]);return Object(i.a)({namespace:"/wc/store/v1",resourceName:"products/collection-data",query:{...m,page:void 0,per_page:void 0,orderby:void 0,order:void 0,...!Object(o.isEmpty)(p)&&{include:p},...R},shouldSelect:A})}},272:function(e,t){},28:function(e,t,n){"use strict";var r=n(0),c=n(4),o=n.n(c);t.a=e=>{let t,{label:n,screenReaderLabel:c,wrapperElement:l,wrapperProps:a={}}=e;const s=null!=n,i=null!=c;return!s&&i?(t=l||"span",a={...a,className:o()(a.className,"screen-reader-text")},Object(r.createElement)(t,a,c)):(t=l||r.Fragment,s&&i&&n!==c?Object(r.createElement)(t,a,Object(r.createElement)("span",{"aria-hidden":"true"},n),Object(r.createElement)("span",{className:"screen-reader-text"},c)):Object(r.createElement)(t,a,n))}},3:function(e,t){e.exports=window.wp.components},35:function(e,t,n){"use strict";n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return c}));const r=e=>!(e=>null===e)(e)&&e instanceof Object&&e.constructor===Object;function c(e,t){return r(e)&&t in e}},37:function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(6),c=n.n(r),o=n(0),l=n(19);const a=e=>{let{countLabel:t,className:n,depth:r=0,controlId:a="",item:s,isSelected:i,isSingle:u,onSelect:b,search:d="",...m}=e;const p=null!=t&&void 0!==s.count&&null!==s.count,g=[n,"woocommerce-search-list__item"];g.push("depth-"+r),u&&g.push("is-radio-button"),p&&g.push("has-count");const O=s.breadcrumbs&&s.breadcrumbs.length,j=m.name||"search-list-item-"+a,f=`${j}-${s.id}`;return Object(o.createElement)("label",{htmlFor:f,className:g.join(" ")},u?Object(o.createElement)("input",c()({type:"radio",id:f,name:j,value:s.value,onChange:b(s),checked:i,className:"woocommerce-search-list__item-input"},m)):Object(o.createElement)("input",c()({type:"checkbox",id:f,name:j,value:s.value,onChange:b(s),checked:i,className:"woocommerce-search-list__item-input"},m)),Object(o.createElement)("span",{className:"woocommerce-search-list__item-label"},O?Object(o.createElement)("span",{className:"woocommerce-search-list__item-prefix"},Object(l.b)(s.breadcrumbs)):null,Object(o.createElement)("span",{className:"woocommerce-search-list__item-name"},Object(l.d)(s.name,d))),!!p&&Object(o.createElement)("span",{className:"woocommerce-search-list__item-count"},t||s.count))};t.b=a},397:function(e,t,n){e.exports=n(475)},398:function(e,t){},399:function(e,t){},40:function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(0),c=n(25),o=n.n(c);function l(e){const t=Object(r.useRef)(e);return o()(e,t.current)||(t.current=e),t.current}},400:function(e,t,n){"use strict";n.d(t,"b",(function(){return o})),n.d(t,"a",(function(){return a}));var r=n(35);const c=e=>Object(r.b)(e,"count")&&Object(r.b)(e,"description")&&Object(r.b)(e,"id")&&Object(r.b)(e,"name")&&Object(r.b)(e,"parent")&&Object(r.b)(e,"slug")&&"number"==typeof e.count&&"string"==typeof e.description&&"number"==typeof e.id&&"string"==typeof e.name&&"number"==typeof e.parent&&"string"==typeof e.slug,o=e=>Array.isArray(e)&&e.every(c),l=e=>Object(r.b)(e,"attribute")&&Object(r.b)(e,"operator")&&Object(r.b)(e,"slug")&&"string"==typeof e.attribute&&"string"==typeof e.operator&&Array.isArray(e.slug)&&e.slug.every(e=>"string"==typeof e),a=e=>Array.isArray(e)&&e.every(l)},401:function(e,t){},44:function(e,t){e.exports=window.wp.a11y},46:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(0);const c=Object(r.createContext)("page"),o=()=>Object(r.useContext)(c);c.Provider},475:function(e,t,n){"use strict";n.r(t);var r=n(6),c=n.n(r),o=n(0),l=n(9),a=n(5),s=n(61),i=n(116),u=n(521),b=n(4),d=n.n(b),m=n(1),p=n(250),g=n(99),O=n(8),j=n(2),f=n(122),w=n(3),h=n(154),_=n(40),y=n(102),k=n(51),E=n(106),v=n(271),S=n(111),C=n(124),x=n(125),N=n(25),T=n.n(N),A=n(15),R=n(537),P=n(17),B=n(126),L=n(95),I=n(35),F=n(400),q=n(539),G=n(234),M=n(554);n(401);var D=e=>{let{className:t,style:n,suggestions:r,multiple:l=!0,saveTransform:a=(e=>e.trim().replace(/\s/g,"-")),messages:s={},validateInput:i=(e=>r.includes(e)),label:u="",...b}=e;return Object(o.createElement)("div",{className:d()("wc-blocks-components-form-token-field-wrapper",t,{"single-selection":!l}),style:n},Object(o.createElement)(M.a,c()({label:u,__experimentalExpandOnFocus:!0,__experimentalShowHowTo:!1,__experimentalValidateInput:i,saveTransform:a,maxLength:l?void 0:1,suggestions:r,messages:s},b)))},Q=n(123),V=n(217),$=n(180);const U=[{value:"preview-1",formattedValue:"preview-1",name:"Blue",label:Object(o.createElement)(S.a,{name:"Blue",count:3}),textLabel:"Blue (3)"},{value:"preview-2",formattedValue:"preview-2",name:"Green",label:Object(o.createElement)(S.a,{name:"Green",count:3}),textLabel:"Green (3)"},{value:"preview-3",formattedValue:"preview-3",name:"Red",label:Object(o.createElement)(S.a,{name:"Red",count:2}),textLabel:"Red (2)"}],Y={id:0,name:"preview",taxonomy:"preview",label:"Preview"};n(399);var W=n(148);function K(){return Math.floor(Math.random()*Date.now())}const J=e=>e.replace("pa_",""),z=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const n={};t.forEach(e=>{const{attribute:t,slug:r,operator:c}=e,o=J(t),l=r.join(","),a=`${G.b}${o}`,s="in"===c?"or":"and";n[`${G.a}${o}`]=l,n[a]=s});const r=Object(P.removeQueryArgs)(e,...Object.keys(n));return Object(P.addQueryArgs)(r,n)},H=e=>{if(e){const t=Object(G.d)("filter_"+e.name);return"string"==typeof t?t.split(","):[]}return[]},Z=(e,t)=>{const n=Object.entries(t).reduce((e,t)=>{let[n,r]=t;return n.includes("query_type")?e:{...e,[n]:r}},{});return Object.entries(n).reduce((t,n)=>{let[r,c]=n;return e[r]===c&&t},!0)},X=e=>e.trim().replace(/\s/g,"-").replace(/_/g,"-").replace(/-+/g,"-").replace(/[^a-zA-Z0-9-]/g,"");var ee=n(155),te=e=>{let{isLoading:t=!1,options:n,checked:r,onChange:c}=e;return t?Object(o.createElement)(o.Fragment,null,Object(o.createElement)("span",{className:"is-loading"}),Object(o.createElement)("span",{className:"is-loading"})):Object(o.createElement)(ee.a,{className:"wc-block-attribute-filter-list",options:n,checked:r,onChange:c,isLoading:t,isDisabled:t})},ne=n(101),re=e=>{let{attributes:t,isEditor:n=!1}=e;const r=Object(j.getSettingWithCoercion)("has_filterable_products",!1,B.a),c=Object(j.getSettingWithCoercion)("is_rendering_php_template",!1,B.a),l=Object(j.getSettingWithCoercion)("page_url",window.location.href,L.a),a=n?[]:Object(j.getSettingWithCoercion)("product_ids",[],Array.isArray),[s,u]=Object(o.useState)(!1),b=t.isPreview&&!t.attributeId?Y:Object(V.a)(t.attributeId),p=Object(o.useMemo)(()=>H(b),[b]),[g,f]=Object(o.useState)(p),[w,N]=Object(o.useState)(K()),[M,W]=Object(o.useState)(t.isPreview&&!t.attributeId?U:[]),ee=Object(h.a)(t),[re]=Object(k.a)(),[ce,oe]=Object(k.b)("attributes",[]),{results:le,isLoading:ae}=Object(E.a)({namespace:"/wc/store/v1",resourceName:"products/attributes/terms",resourceValues:[(null==b?void 0:b.id)||0],shouldSelect:t.attributeId>0}),se="dropdown"!==t.displayStyle&&"and"===t.queryType,{results:ie,isLoading:ue}=Object(v.a)({queryAttribute:{taxonomy:(null==b?void 0:b.taxonomy)||"",queryType:t.queryType},queryState:{...re,attributes:se?re.attributes:null},productIds:a}),be=Object(o.useCallback)(e=>Object(I.b)(ie,"attribute_counts")&&Array.isArray(ie.attribute_counts)?ie.attribute_counts.find(t=>{let{term:n}=t;return n===e}):null,[ie]);Object(o.useEffect)(()=>{if(ae||ue)return;if(!Array.isArray(le))return;const e=le.map(e=>{const n=be(e.id);if(!(n||g.includes(e.slug)||(r=e.slug,null!=re&&re.attributes&&re.attributes.some(e=>{let{attribute:t,slug:n=[]}=e;return t===(null==b?void 0:b.taxonomy)&&n.includes(r)}))))return null;var r;const c=n?n.count:0;return{formattedValue:X(e.slug),value:e.slug,name:Object(A.decodeEntities)(e.name),label:Object(o.createElement)(S.a,{name:Object(A.decodeEntities)(e.name),count:t.showCounts?c:null}),textLabel:t.showCounts?`${Object(A.decodeEntities)(e.name)} (${c})`:Object(A.decodeEntities)(e.name)}}).filter(e=>!!e);W(e),N(K())},[null==b?void 0:b.taxonomy,le,ae,t.showCounts,ue,be,g,re.attributes]);const de=Object(o.useCallback)(e=>Array.isArray(le)?le.reduce((t,n)=>(e.includes(n.slug)&&t.push(n),t),[]):[],[le]),me=Object(o.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(t){if(null==b||!b.taxonomy)return;const t=Object.keys(Object(P.getQueryArgs)(window.location.href)),n=J(b.taxonomy),r=t.reduce((e,t)=>t.includes(G.b+n)||t.includes(G.a+n)?Object(P.removeQueryArgs)(e,t):e,window.location.href),c=z(r,e);Object(G.c)(c)}else{const t=z(l,e),n=Object(P.getQueryArgs)(window.location.href),r=Object(P.getQueryArgs)(t);Z(n,r)||Object(G.c)(t)}}),[l,null==b?void 0:b.taxonomy]),pe=e=>{const n=Object($.b)(ce,oe,b,de(e),"or"===t.queryType?"in":"and");me(n,0===e.length)},ge=Object(o.useCallback)((function(e){let r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];n||(f(e),!r&&t.showFilterButton||Object($.b)(ce,oe,b,de(e),"or"===t.queryType?"in":"and"))}),[n,f,ce,oe,b,de,t.queryType,t.showFilterButton]),Oe=Object(o.useMemo)(()=>Object(F.a)(ce)?ce.filter(e=>{let{attribute:t}=e;return t===(null==b?void 0:b.taxonomy)}).flatMap(e=>{let{slug:t}=e;return t}):[],[ce,null==b?void 0:b.taxonomy]),je=Object(_.a)(Oe),fe=Object(y.a)(je);Object(o.useEffect)(()=>{!fe||T()(fe,je)||T()(g,je)||ge(je)},[g,je,fe,ge]);const we="single"!==t.selectType,he=Object(o.useCallback)(e=>{const t=g.includes(e);let n;we?(n=g.filter(t=>t!==e),t||(n.push(e),n.sort())):n=t?[]:[e],ge(n)},[g,we,ge]);Object(o.useEffect)(()=>{b&&!t.showFilterButton&&((e=>{let{currentCheckedFilters:t,hasSetFilterDefaultsFromUrl:n}=e;return n&&0===t.length})({currentCheckedFilters:g,hasSetFilterDefaultsFromUrl:s})?me(ce,!0):me(ce,!1))},[s,me,ce,b,g,t.showFilterButton]),Object(o.useEffect)(()=>{if(!s&&!ae)return p.length>0?(u(!0),void ge(p,!0)):void(c||u(!0))},[b,s,ae,ge,p,c]);const _e=Object(ne.a)();if(!r)return _e(!1),null;if(!b)return n?Object(o.createElement)(R.a,{status:"warning",isDismissible:!1},Object(o.createElement)("p",null,Object(m.__)("Please select an attribute to use this filter!","woo-gutenberg-products-block"))):(_e(!1),null);if(0===M.length&&!ae&&n)return Object(o.createElement)(R.a,{status:"warning",isDismissible:!1},Object(o.createElement)("p",null,Object(m.__)("There are no products with the selected attributes.","woo-gutenberg-products-block")));const ye="h"+t.headingLevel,ke=!t.isPreview&&ae,Ee=!t.isPreview&&ue,ve=(ke||Ee)&&0===M.length;if(!ve&&0===M.length)return _e(!1),null;const Se=Object(o.createElement)(ye,{className:"wc-block-attribute-filter__title"},t.heading),Ce=ve?Object(o.createElement)(Q.a,null,Se):Se;return _e(!0),Object(o.createElement)(o.Fragment,null,!n&&t.heading&&Ce,Object(o.createElement)("div",{className:d()("wc-block-attribute-filter","style-"+t.displayStyle)},"dropdown"===t.displayStyle?Object(o.createElement)(o.Fragment,null,Object(o.createElement)(D,{key:w,className:d()(ee.className,{"single-selection":!we,"is-loading":ve}),style:{...ee.style,borderStyle:"none"},suggestions:M.filter(e=>!g.includes(e.value)).map(e=>e.formattedValue),disabled:ve,placeholder:Object(m.sprintf)(
|
16 |
/* translators: %s attribute name. */
|
17 |
Object(m.__)("Select %s","woo-gutenberg-products-block"),b.label),onChange:e=>{!we&&e.length>1&&(e=[e[e.length-1]]),e=e.map(e=>{const t=M.find(t=>t.formattedValue===e);return t?t.value:e});const t=Object(O.difference)(e,g);if(1===t.length)return he(t[0]);const n=Object(O.difference)(g,e);1===n.length&&he(n[0])},value:g,displayTransform:e=>{const t=M.find(t=>[t.value,t.formattedValue].includes(e));return t?t.textLabel:e},saveTransform:X,messages:{added:Object(m.sprintf)(
|
18 |
/* translators: %s is the attribute label. */
|
22 |
/* translators: %s is the attribute label. */
|
23 |
Object(m.__)("Remove %s filter.","woo-gutenberg-products-block"),b.label.toLocaleLowerCase()),__experimentalInvalid:Object(m.sprintf)(
|
24 |
/* translators: %s is the attribute label. */
|
25 |
+
Object(m.__)("Invalid %s filter.","woo-gutenberg-products-block"),b.label.toLocaleLowerCase())}}),we&&Object(o.createElement)(i.a,{icon:q.a,size:30})):Object(o.createElement)(te,{options:M,checked:g,onChange:he,isLoading:ve,isDisabled:ve})),Object(o.createElement)("div",{className:"wc-block-attribute-filter__actions"},g.length>0&&!ve&&Object(o.createElement)(C.a,{onClick:()=>{f([]),N(K()),s&&pe([])},screenReaderLabel:Object(m.__)("Reset attribute filter","woo-gutenberg-products-block")}),t.showFilterButton&&Object(o.createElement)(x.a,{className:"wc-block-attribute-filter__button",isLoading:ve,disabled:(()=>{if(ke||Ee)return!0;const e=H(b);return e.length===g.length&&g.every(t=>e.includes(t))})(),onClick:()=>pe(g)})))},ce=(n(398),n(121));const oe=Object(j.getSetting)("attributes",[]);var le=Object(w.withSpokenMessages)(e=>{let{attributes:t,setAttributes:n,debouncedSpeak:r,clientId:c}=e;const{attributeId:l,className:s,displayStyle:b,heading:h,headingLevel:_,isPreview:y,queryType:k,showCounts:E,showFilterButton:v,selectType:S}=t,[C,x]=Object(o.useState)(!l&&!y),N=Object(a.useBlockProps)(),T=e=>{if(!e||!e.length)return;const t=e[0].id;oe.find(e=>e.attribute_id===t.toString())&&l!==t&&n({attributeId:t})},A=e=>{let{isCompact:t}=e;const n={clear:Object(m.__)("Clear selected attribute","woo-gutenberg-products-block"),list:Object(m.__)("Product Attributes","woo-gutenberg-products-block"),noItems:Object(m.__)("Your store doesn't have any product attributes.","woo-gutenberg-products-block"),search:Object(m.__)("Search for a product attribute:","woo-gutenberg-products-block"),selected:e=>Object(m.sprintf)(
|
26 |
/* translators: %d is the number of attributes selected. */
|
27 |
+
Object(m._n)("%d attribute selected","%d attributes selected",e,"woo-gutenberg-products-block"),e),updated:Object(m.__)("Product attribute search results updated.","woo-gutenberg-products-block")},r=Object(O.sortBy)(oe.map(e=>({id:parseInt(e.attribute_id,10),name:e.attribute_label})),"name");return Object(o.createElement)(g.a,{className:"woocommerce-product-attributes",list:r,selected:r.filter(e=>{let{id:t}=e;return t===l}),onChange:T,messages:n,isSingle:!0,isCompact:t})};return 0===Object.keys(oe).length?Object(o.createElement)(w.Placeholder,{className:"wc-block-attribute-filter",icon:Object(o.createElement)(i.a,{icon:u.a}),label:Object(m.__)("Filter by Attribute","woo-gutenberg-products-block"),instructions:Object(m.__)("Display a list of filters based on the selected attributes.","woo-gutenberg-products-block")},Object(o.createElement)("p",null,Object(m.__)("Attributes are needed for filtering your products. You haven't created any attributes yet.","woo-gutenberg-products-block")),Object(o.createElement)(w.Button,{className:"wc-block-attribute-filter__add-attribute-button",isSecondary:!0,href:Object(j.getAdminLink)("edit.php?post_type=product&page=product_attributes")},Object(m.__)("Add new attribute","woo-gutenberg-products-block")+" ",Object(o.createElement)(i.a,{icon:p.a})),Object(o.createElement)(w.Button,{className:"wc-block-attribute-filter__read_more_button",isTertiary:!0,href:"https://docs.woocommerce.com/document/managing-product-taxonomies/"},Object(m.__)("Learn more","woo-gutenberg-products-block"))):Object(o.createElement)("div",N,Object(o.createElement)(a.BlockControls,null,Object(o.createElement)(w.ToolbarGroup,{controls:[{icon:"edit",title:Object(m.__)("Edit","woo-gutenberg-products-block"),onClick:()=>x(!C),isActive:C}]})),Object(o.createElement)(a.InspectorControls,{key:"inspector"},Object(o.createElement)(w.PanelBody,{title:Object(m.__)("Display Settings","woo-gutenberg-products-block")},Object(o.createElement)(w.ToggleControl,{label:Object(m.__)("Include product count","woo-gutenberg-products-block"),checked:E,onChange:()=>n({showCounts:!E})}),Object(o.createElement)(w.__experimentalToggleGroupControl,{label:Object(m.__)("Allow selecting multiple options?","woo-gutenberg-products-block"),value:S||"multiple",onChange:e=>n({selectType:e}),className:"wc-block-attribute-filter__multiple-toggle"},Object(o.createElement)(w.__experimentalToggleGroupControlOption,{value:"multiple",label:Object(m.__)("Multiple","woo-gutenberg-products-block")}),Object(o.createElement)(w.__experimentalToggleGroupControlOption,{value:"single",label:Object(m.__)("Single","woo-gutenberg-products-block")})),"multiple"===S&&Object(o.createElement)(w.__experimentalToggleGroupControl,{label:Object(m.__)("Filter Conditions","woo-gutenberg-products-block"),help:"and"===k?Object(m.__)("Choose to return filter results for all of the attributes selected.","woo-gutenberg-products-block"):Object(m.__)("Choose to return filter results for any of the attributes selected.","woo-gutenberg-products-block"),value:k,onChange:e=>n({queryType:e}),className:"wc-block-attribute-filter__conditions-toggle"},Object(o.createElement)(w.__experimentalToggleGroupControlOption,{value:"and",label:Object(m.__)("All","woo-gutenberg-products-block")}),Object(o.createElement)(w.__experimentalToggleGroupControlOption,{value:"or",label:Object(m.__)("Any","woo-gutenberg-products-block")})),Object(o.createElement)(w.__experimentalToggleGroupControl,{label:Object(m.__)("Display Style","woo-gutenberg-products-block"),value:b,onChange:e=>n({displayStyle:e}),className:"wc-block-attribute-filter__display-toggle"},Object(o.createElement)(w.__experimentalToggleGroupControlOption,{value:"list",label:Object(m.__)("List","woo-gutenberg-products-block")}),Object(o.createElement)(w.__experimentalToggleGroupControlOption,{value:"dropdown",label:Object(m.__)("Dropdown","woo-gutenberg-products-block")})),Object(o.createElement)(w.ToggleControl,{label:Object(m.__)("Show 'Apply filters' button","woo-gutenberg-products-block"),help:v?Object(m.__)("Products will only update when the button is clicked.","woo-gutenberg-products-block"):Object(m.__)("Products will update as soon as attributes are selected.","woo-gutenberg-products-block"),checked:v,onChange:e=>n({showFilterButton:e})})),Object(o.createElement)(w.PanelBody,{title:Object(m.__)("Content Settings","woo-gutenberg-products-block"),initialOpen:!1},A({isCompact:!0}))),Object(o.createElement)(ce.a,{clientId:c,attributes:t,setAttributes:n,filterType:"attribute-filter"}),C?Object(o.createElement)(w.Placeholder,{className:"wc-block-attribute-filter",icon:Object(o.createElement)(i.a,{icon:u.a}),label:Object(m.__)("Filter by Attribute","woo-gutenberg-products-block")},Object(o.createElement)("div",{className:"wc-block-attribute-filter__instructions"},Object(m.__)("Display a list of filters based on the selected attributes.","woo-gutenberg-products-block")),Object(o.createElement)("div",{className:"wc-block-attribute-filter__selection"},A({isCompact:!1}),Object(o.createElement)(w.Button,{isPrimary:!0,onClick:()=>{x(!1),r(Object(m.__)("Now displaying a preview of the Filter Products by Attribute block.","woo-gutenberg-products-block"))}},Object(m.__)("Done","woo-gutenberg-products-block")))):Object(o.createElement)("div",{className:d()(s,"wc-block-attribute-filter")},h&&Object(o.createElement)(f.a,{className:"wc-block-attribute-filter__title",headingLevel:_,heading:h,onChange:e=>n({heading:e})}),Object(o.createElement)(w.Disabled,null,Object(o.createElement)(re,{attributes:t,isEditor:!0}))))});const ae={heading:{type:"string",default:Object(m.__)("Filter by attribute","woo-gutenberg-products-block")}};Object(l.registerBlockType)(W,{icon:{src:Object(o.createElement)(i.a,{icon:u.a,className:"wc-block-editor-components-block-icon"})},supports:{...W.supports,...Object(s.b)()&&{__experimentalBorder:{radius:!1,color:!0,width:!1}}},attributes:{...W.attributes,...ae},edit:le,save(e){let{attributes:t}=e;const{className:n,showCounts:r,queryType:l,attributeId:s,heading:i,headingLevel:u,displayStyle:b,showFilterButton:m,selectType:p}=t,g={"data-attribute-id":s,"data-show-counts":r,"data-query-type":l,"data-heading":i,"data-heading-level":u};return"list"!==b&&(g["data-display-style"]=b),m&&(g["data-show-filter-button"]=m),"single"===p&&(g["data-select-type"]=p),Object(o.createElement)("div",c()({},a.useBlockProps.save({className:d()("is-loading",n)}),g),Object(o.createElement)("span",{"aria-hidden":!0,className:"wc-block-product-attribute-filter__placeholder"}))}})},5:function(e,t){e.exports=window.wp.blockEditor},50:function(e,t){e.exports=window.wp.deprecated},51:function(e,t,n){"use strict";n.d(t,"a",(function(){return b})),n.d(t,"b",(function(){return d})),n.d(t,"c",(function(){return m}));var r=n(10),c=n(7),o=n(0),l=n(25),a=n.n(l),s=n(40),i=n(102),u=n(46);const b=e=>{const t=Object(u.a)();e=e||t;const n=Object(c.useSelect)(t=>t(r.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0),[e]),{setValueForQueryContext:l}=Object(c.useDispatch)(r.QUERY_STATE_STORE_KEY);return[n,Object(o.useCallback)(t=>{l(e,t)},[e,l])]},d=(e,t,n)=>{const l=Object(u.a)();n=n||l;const a=Object(c.useSelect)(c=>c(r.QUERY_STATE_STORE_KEY).getValueForQueryKey(n,e,t),[n,e]),{setQueryValue:s}=Object(c.useDispatch)(r.QUERY_STATE_STORE_KEY);return[a,Object(o.useCallback)(t=>{s(n,e,t)},[n,e,s])]},m=(e,t)=>{const n=Object(u.a)();t=t||n;const[r,c]=b(t),l=Object(s.a)(r),d=Object(s.a)(e),m=Object(i.a)(d),p=Object(o.useRef)(!1);return Object(o.useEffect)(()=>{a()(m,d)||(c(Object.assign({},l,d)),p.current=!0)},[l,d,m,c]),p.current?[r,c]:[e,c]}},54:function(e,t){e.exports=window.wp.keycodes},61:function(e,t,n){"use strict";n.d(t,"c",(function(){return o})),n.d(t,"a",(function(){return l})),n.d(t,"b",(function(){return a}));var r=n(9),c=n(21);const o=(e,t)=>{if(c.n>2)return Object(r.registerBlockType)(e,t)},l=()=>c.n>2,a=()=>c.n>1},7:function(e,t){e.exports=window.wp.data},71:function(e,t){e.exports=window.wp.dom},8:function(e,t){e.exports=window.lodash},9:function(e,t){e.exports=window.wp.blocks},95:function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));const r=e=>"string"==typeof e},99:function(e,t,n){"use strict";n.d(t,"a",(function(){return k}));var r=n(6),c=n.n(r),o=n(0),l=n(1),a=n(3),s=n(116),i=n(515),u=n(4),b=n.n(u),d=n(11),m=n(19),p=n(37),g=n(514),O=n(15);const j=e=>{let{id:t,label:n,popoverContents:r,remove:c,screenReaderLabel:i,className:u=""}=e;const[m,p]=Object(o.useState)(!1),f=Object(d.useInstanceId)(j);if(i=i||n,!n)return null;n=Object(O.decodeEntities)(n);const w=b()("woocommerce-tag",u,{"has-remove":!!c}),h="woocommerce-tag__label-"+f,_=Object(o.createElement)(o.Fragment,null,Object(o.createElement)("span",{className:"screen-reader-text"},i),Object(o.createElement)("span",{"aria-hidden":"true"},n));return Object(o.createElement)("span",{className:w},r?Object(o.createElement)(a.Button,{className:"woocommerce-tag__text",id:h,onClick:()=>p(!0)},_):Object(o.createElement)("span",{className:"woocommerce-tag__text",id:h},_),r&&m&&Object(o.createElement)(a.Popover,{onClose:()=>p(!1)},r),c&&Object(o.createElement)(a.Button,{className:"woocommerce-tag__remove",onClick:c(t),label:Object(l.sprintf)(// Translators: %s label.
|
28 |
+
Object(l.__)("Remove %s","woo-gutenberg-products-block"),n),"aria-describedby":h},Object(o.createElement)(s.a,{icon:g.a,size:20,className:"clear-icon"})))};var f=j;const w=e=>Object(o.createElement)(p.b,e),h=e=>{const{list:t,selected:n,renderItem:r,depth:l=0,onSelect:a,instanceId:s,isSingle:i,search:u}=e;return t?Object(o.createElement)(o.Fragment,null,t.map(t=>{const b=-1!==n.findIndex(e=>{let{id:n}=e;return n===t.id});return Object(o.createElement)(o.Fragment,{key:t.id},Object(o.createElement)("li",null,r({item:t,isSelected:b,onSelect:a,isSingle:i,search:u,depth:l,controlId:s})),Object(o.createElement)(h,c()({},e,{list:t.children,depth:l+1})))})):null},_=e=>{let{isLoading:t,isSingle:n,selected:r,messages:c,onChange:s,onRemove:i}=e;if(t||n||!r)return null;const u=r.length;return Object(o.createElement)("div",{className:"woocommerce-search-list__selected"},Object(o.createElement)("div",{className:"woocommerce-search-list__selected-header"},Object(o.createElement)("strong",null,c.selected(u)),u>0?Object(o.createElement)(a.Button,{isLink:!0,isDestructive:!0,onClick:()=>s([]),"aria-label":c.clear},Object(l.__)("Clear all","woo-gutenberg-products-block")):null),u>0?Object(o.createElement)("ul",null,r.map((e,t)=>Object(o.createElement)("li",{key:t},Object(o.createElement)(f,{label:e.name,id:e.id,remove:i})))):null)},y=e=>{let{filteredList:t,search:n,onSelect:r,instanceId:c,...a}=e;const{messages:u,renderItem:b,selected:d,isSingle:m}=a,p=b||w;return 0===t.length?Object(o.createElement)("div",{className:"woocommerce-search-list__list is-not-found"},Object(o.createElement)("span",{className:"woocommerce-search-list__not-found-icon"},Object(o.createElement)(s.a,{icon:i.a})),Object(o.createElement)("span",{className:"woocommerce-search-list__not-found-text"},n?Object(l.sprintf)(u.noResults,n):u.noItems)):Object(o.createElement)("ul",{className:"woocommerce-search-list__list"},Object(o.createElement)(h,{list:t,selected:d,renderItem:p,onSelect:r,instanceId:c,isSingle:m,search:n}))},k=e=>{const{className:t="",isCompact:n,isHierarchical:r,isLoading:l,isSingle:s,list:i,messages:u=m.a,onChange:p,onSearch:g,selected:O,debouncedSpeak:j}=e,[f,w]=Object(o.useState)(""),h=Object(d.useInstanceId)(k),E=Object(o.useMemo)(()=>({...m.a,...u}),[u]),v=Object(o.useMemo)(()=>Object(m.c)(i,f,r),[i,f,r]);Object(o.useEffect)(()=>{j&&j(E.updated)},[j,E]),Object(o.useEffect)(()=>{"function"==typeof g&&g(f)},[f,g]);const S=Object(o.useCallback)(e=>()=>{s&&p([]);const t=O.findIndex(t=>{let{id:n}=t;return n===e});p([...O.slice(0,t),...O.slice(t+1)])},[s,O,p]),C=Object(o.useCallback)(e=>()=>{-1===O.findIndex(t=>{let{id:n}=t;return n===e.id})?p(s?[e]:[...O,e]):S(e.id)()},[s,S,p,O]);return Object(o.createElement)("div",{className:b()("woocommerce-search-list",t,{"is-compact":n})},Object(o.createElement)(_,c()({},e,{onRemove:S,messages:E})),Object(o.createElement)("div",{className:"woocommerce-search-list__search"},Object(o.createElement)(a.TextControl,{label:E.search,type:"search",value:f,onChange:e=>w(e)})),l?Object(o.createElement)("div",{className:"woocommerce-search-list__list is-loading"},Object(o.createElement)(a.Spinner,null)):Object(o.createElement)(y,c()({},e,{search:f,filteredList:v,messages:E,onSelect:C,instanceId:h})))};Object(a.withSpokenMessages)(k)}});
|
build/blocks-checkout.asset.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php return array('dependencies' => array('lodash', 'react', 'wc-blocks-registry', 'wc-settings', 'wp-compose', 'wp-data', 'wp-deprecated', 'wp-dom', 'wp-element', 'wp-i18n', 'wp-is-shallow-equal', 'wp-polyfill', 'wp-primitives', 'wp-warning'), 'version' => '
|
1 |
+
<?php return array('dependencies' => array('lodash', 'react', 'wc-blocks-data-store', 'wc-blocks-registry', 'wc-settings', 'wp-a11y', 'wp-compose', 'wp-data', 'wp-deprecated', 'wp-dom', 'wp-element', 'wp-i18n', 'wp-is-shallow-equal', 'wp-polyfill', 'wp-primitives', 'wp-warning'), 'version' => '53b611b6f9017f43f5d280d9dd945c79');
|
build/blocks-checkout.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
this.wc=this.wc||{},this.wc.blocksCheckout=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=142)}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},10:function(e,t,n){"use strict";function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}n.d(t,"a",(function(){return r}))},11:function(e,t){function n(){return e.exports=n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},e.exports.__esModule=!0,e.exports.default=e.exports,n.apply(this,arguments)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports},12:function(e,t){e.exports=window.wp.isShallowEqual},131:function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return i}));var r=n(23);const o=e=>!Object(r.a)(e)&&e instanceof Object&&e.constructor===Object;function i(e,t){return o(e)&&t in e}},134:function(e,t){},135:function(e,t){},136:function(e,t){},137:function(e,t){},138:function(e,t){},139:function(e,t){},14:function(e,t){e.exports=window.wp.compose},140:function(e,t){},142:function(e,t,n){"use strict";n.r(t),n.d(t,"TotalsItem",(function(){return k})),n.d(t,"Subtotal",(function(){return F})),n.d(t,"TotalsTaxes",(function(){return C})),n.d(t,"TotalsFees",(function(){return T})),n.d(t,"TotalsWrapper",(function(){return P})),n.d(t,"ExperimentalOrderMeta",(function(){return me})),n.d(t,"ExperimentalDiscountsMeta",(function(){return he})),n.d(t,"ExperimentalOrderShippingPackages",(function(){return ve})),n.d(t,"Panel",(function(){return ye})),n.d(t,"Button",(function(){return Ye})),n.d(t,"Label",(function(){return Ze})),n.d(t,"CheckboxControl",(function(){return Je})),n.d(t,"mustContain",(function(){return Qe})),n.d(t,"extensionCartUpdate",(function(){return nt})),n.d(t,"hasValidFills",(function(){return ae})),n.d(t,"useSlot",(function(){return ce})),n.d(t,"createSlotFill",(function(){return le})),n.d(t,"__experimentalRegisterCheckoutFilters",(function(){return ct})),n.d(t,"__experimentalApplyCheckoutFilter",(function(){return mt})),n.d(t,"hasInnerBlocks",(function(){return ht})),n.d(t,"getRegisteredBlocks",(function(){return bt})),n.d(t,"registerCheckoutBlock",(function(){return vt})),n.d(t,"innerBlockAreas",(function(){return ft})),n.d(t,"SlotFillProvider",(function(){return te}));var r=n(0),o=n(5),i=n.n(o),s=n(11),a=n.n(s),c=n(16),l=n.n(c);function u(){}function p(e){return!!(e||"").match(/\d/)}function m(e){return null==e}function f(e){return e.replace(/[-[\]/{}()*+?.\\^$|]/g,"\\$&")}function d(e,t){void 0===t&&(t=!0);var n="-"===e[0],r=n&&t,o=(e=e.replace("-","")).split(".");return{beforeDecimal:o[0],afterDecimal:o[1]||"",hasNagation:n,addNegation:r}}function h(e,t,n){for(var r="",o=n?"0":"",i=0;i<=t-1;i++)r+=e[i]||o;return r}function b(e,t){return Array(t+1).join(e)}function g(e,t){if(e.value=e.value,null!==e){if(e.createTextRange){var n=e.createTextRange();return n.move("character",t),n.select(),!0}return e.selectionStart||0===e.selectionStart?(e.focus(),e.setSelectionRange(t,t),!0):(e.focus(),!1)}}function v(e,t,n){return Math.min(Math.max(e,t),n)}function O(e){return Math.max(e.selectionStart,e.selectionEnd)}var w={displayType:"input",decimalSeparator:".",thousandsGroupStyle:"thousand",fixedDecimalScale:!1,prefix:"",suffix:"",allowNegative:!0,allowEmptyFormatting:!1,allowLeadingZeros:!1,isNumericString:!1,type:"text",onValueChange:u,onChange:u,onKeyDown:u,onMouseUp:u,onFocus:u,onBlur:u,isAllowed:function(){return!0}},j=function(e){function t(t){e.call(this,t);var n=t.defaultValue;this.validateProps();var r=this.formatValueProp(n);this.state={value:r,numAsString:this.removeFormatting(r),mounted:!1},this.selectionBeforeInput={selectionStart:0,selectionEnd:0},this.onChange=this.onChange.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.componentDidMount=function(){this.setState({mounted:!0})},t.prototype.componentDidUpdate=function(e){this.updateValueIfRequired(e)},t.prototype.componentWillUnmount=function(){clearTimeout(this.focusTimeout),clearTimeout(this.caretPositionTimeout)},t.prototype.updateValueIfRequired=function(e){var t=this.props,n=this.state,r=this.focusedElm,o=n.value,i=n.numAsString;if(void 0===i&&(i=""),e!==t){this.validateProps();var s=this.formatNumString(i),a=m(t.value)?s:this.formatValueProp(),c=this.removeFormatting(a),l=parseFloat(c),u=parseFloat(i);(isNaN(l)&&isNaN(u)||l===u)&&s===o&&(null!==r||a===o)||this.updateValue({formattedValue:a,numAsString:c,input:r,source:"prop",event:null})}},t.prototype.getFloatString=function(e){void 0===e&&(e="");var t=this.props.decimalScale,n=this.getSeparators().decimalSeparator,r=this.getNumberRegex(!0),o="-"===e[0];o&&(e=e.replace("-","")),n&&0===t&&(e=e.split(n)[0]);var i=(e=(e.match(r)||[]).join("").replace(n,".")).indexOf(".");return-1!==i&&(e=e.substring(0,i)+"."+e.substring(i+1,e.length).replace(new RegExp(f(n),"g"),"")),o&&(e="-"+e),e},t.prototype.getNumberRegex=function(e,t){var n=this.props,r=n.format,o=n.decimalScale,i=n.customNumerals,s=this.getSeparators().decimalSeparator;return new RegExp("[0-9"+(i?i.join(""):"")+"]"+(!s||0===o||t||r?"":"|"+f(s)),e?"g":void 0)},t.prototype.getSeparators=function(){var e=this.props.decimalSeparator,t=this.props,n=t.thousandSeparator,r=t.allowedDecimalSeparators;return!0===n&&(n=","),r||(r=[e,"."]),{decimalSeparator:e,thousandSeparator:n,allowedDecimalSeparators:r}},t.prototype.getMaskAtIndex=function(e){var t=this.props.mask;return void 0===t&&(t=" "),"string"==typeof t?t:t[e]||" "},t.prototype.getValueObject=function(e,t){var n=parseFloat(t);return{formattedValue:e,value:t,floatValue:isNaN(n)?void 0:n}},t.prototype.validateProps=function(){var e=this.props.mask,t=this.getSeparators(),n=t.decimalSeparator,r=t.thousandSeparator;if(n===r)throw new Error("\n Decimal separator can't be same as thousand separator.\n thousandSeparator: "+r+' (thousandSeparator = {true} is same as thousandSeparator = ",")\n decimalSeparator: '+n+" (default value for decimalSeparator is .)\n ");if(e&&("string"===e?e:e.toString()).match(/\d/g))throw new Error("\n Mask "+e+" should not contain numeric character;\n ")},t.prototype.setPatchedCaretPosition=function(e,t,n){g(e,t),this.caretPositionTimeout=setTimeout((function(){e.value===n&&g(e,t)}),0)},t.prototype.correctCaretPosition=function(e,t,n){var r=this.props,o=r.prefix,i=r.suffix,s=r.format;if(""===e)return 0;if(t=v(t,0,e.length),!s){var a="-"===e[0];return v(t,o.length+(a?1:0),e.length-i.length)}if("function"==typeof s)return t;if("#"===s[t]&&p(e[t]))return t;if("#"===s[t-1]&&p(e[t-1]))return t;var c=s.indexOf("#");t=v(t,c,s.lastIndexOf("#")+1);for(var l=s.substring(t,s.length).indexOf("#"),u=t,m=t+(-1===l?0:l);u>c&&("#"!==s[u]||!p(e[u]));)u-=1;return!p(e[m])||"left"===n&&t!==c||t-u<m-t?p(e[u])?u+1:u:m},t.prototype.getCaretPosition=function(e,t,n){var r,o,i=this.props.format,s=this.state.value,a=this.getNumberRegex(!0),c=(e.match(a)||[]).join(""),l=(t.match(a)||[]).join("");for(r=0,o=0;o<n;o++){var u=e[o]||"",p=t[r]||"";if((u.match(a)||u===p)&&("0"!==u||!p.match(a)||"0"===p||c.length===l.length)){for(;u!==t[r]&&r<t.length;)r++;r++}}return"string"!=typeof i||s||(r=t.length),this.correctCaretPosition(t,r)},t.prototype.removePrefixAndSuffix=function(e){var t=this.props,n=t.format,r=t.prefix,o=t.suffix;if(!n&&e){var i="-"===e[0];i&&(e=e.substring(1,e.length));var s=(e=r&&0===e.indexOf(r)?e.substring(r.length,e.length):e).lastIndexOf(o);e=o&&-1!==s&&s===e.length-o.length?e.substring(0,s):e,i&&(e="-"+e)}return e},t.prototype.removePatternFormatting=function(e){for(var t=this.props.format.split("#").filter((function(e){return""!==e})),n=0,r="",o=0,i=t.length;o<=i;o++){var s=t[o]||"",a=o===i?e.length:e.indexOf(s,n);if(-1===a){r=e;break}r+=e.substring(n,a),n=a+s.length}return(r.match(this.getNumberRegex(!0))||[]).join("")},t.prototype.removeFormatting=function(e){var t=this.props,n=t.format,r=t.removeFormatting;return e?(n?e="string"==typeof n?this.removePatternFormatting(e):"function"==typeof r?r(e):(e.match(this.getNumberRegex(!0))||[]).join(""):(e=this.removePrefixAndSuffix(e),e=this.getFloatString(e)),e):e},t.prototype.formatWithPattern=function(e){for(var t=this.props.format,n=0,r=t.split(""),o=0,i=t.length;o<i;o++)"#"===t[o]&&(r[o]=e[n]||this.getMaskAtIndex(n),n+=1);return r.join("")},t.prototype.formatAsNumber=function(e){var t=this.props,n=t.decimalScale,r=t.fixedDecimalScale,o=t.prefix,i=t.suffix,s=t.allowNegative,a=t.thousandsGroupStyle,c=this.getSeparators(),l=c.thousandSeparator,u=c.decimalSeparator,p=-1!==e.indexOf(".")||n&&r,m=d(e,s),f=m.beforeDecimal,b=m.afterDecimal,g=m.addNegation;return void 0!==n&&(b=h(b,n,r)),l&&(f=function(e,t,n){var r=function(e){switch(e){case"lakh":return/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/g;case"wan":return/(\d)(?=(\d{4})+(?!\d))/g;case"thousand":default:return/(\d)(?=(\d{3})+(?!\d))/g}}(n),o=e.search(/[1-9]/);return o=-1===o?e.length:o,e.substring(0,o)+e.substring(o,e.length).replace(r,"$1"+t)}(f,l,a)),o&&(f=o+f),i&&(b+=i),g&&(f="-"+f),f+(p&&u||"")+b},t.prototype.formatNumString=function(e){void 0===e&&(e="");var t=this.props,n=t.format,r=t.allowEmptyFormatting,o=t.customNumerals,i=e;if(o&&10===o.length){var s=new RegExp("["+o.join("")+"]","g");i=e.replace(s,(function(e){return o.indexOf(e).toString()}))}return""!==e||r?"-"!==e||n?"string"==typeof n?this.formatWithPattern(i):"function"==typeof n?n(i):this.formatAsNumber(i):"-":""},t.prototype.formatValueProp=function(e){var t=this.props,n=t.format,r=t.decimalScale,o=t.fixedDecimalScale,i=t.allowEmptyFormatting,s=this.props,a=s.value,c=s.isNumericString,l=!(a=m(a)?e:a)&&0!==a;return l&&i&&(a=""),l&&!i?"":("number"==typeof a&&(a=function(e){var t="-"===(e+="")[0]?"-":"";t&&(e=e.substring(1));var n=e.split(/[eE]/g),r=n[0],o=n[1];if(!(o=Number(o)))return t+r;var i=1+o,s=(r=r.replace(".","")).length;return i<0?r="0."+b("0",Math.abs(i))+r:i>=s?r+=b("0",i-s):r=(r.substring(0,i)||"0")+"."+r.substring(i),t+r}(a),c=!0),"Infinity"===a&&c&&(a=""),c&&!n&&"number"==typeof r&&(a=function(e,t,n){if(-1!==["","-"].indexOf(e))return e;var r=-1!==e.indexOf(".")&&t,o=d(e),i=o.beforeDecimal,s=o.afterDecimal,a=o.hasNagation,c=parseFloat("0."+(s||"0")),l=(s.length<=t?"0."+s:c.toFixed(t)).split(".");return(a?"-":"")+i.split("").reverse().reduce((function(e,t,n){return e.length>n?(Number(e[0])+Number(t)).toString()+e.substring(1,e.length):t+e}),l[0])+(r?".":"")+h(l[1]||"",Math.min(t,s.length),n)}(a,r,o)),c?this.formatNumString(a):this.formatInput(a))},t.prototype.formatNegation=function(e){void 0===e&&(e="");var t=this.props.allowNegative,n=new RegExp("(-)"),r=new RegExp("(-)(.)*(-)"),o=n.test(e),i=r.test(e);return e=e.replace(/-/g,""),o&&!i&&t&&(e="-"+e),e},t.prototype.formatInput=function(e){return void 0===e&&(e=""),this.props.format||(e=this.removePrefixAndSuffix(e),e=this.formatNegation(e)),e=this.removeFormatting(e),this.formatNumString(e)},t.prototype.isCharacterAFormat=function(e,t){var n=this.props,r=n.format,o=n.prefix,i=n.suffix,s=n.decimalScale,a=n.fixedDecimalScale,c=this.getSeparators().decimalSeparator;return"string"==typeof r&&"#"!==r[e]||!(r||!(e<o.length||e>=t.length-i.length||s&&a&&t[e]===c))},t.prototype.correctInputValue=function(e,t,n){var r=this,o=this.props,i=o.format,s=o.allowNegative,a=o.prefix,c=o.suffix,l=o.decimalScale,u=this.getSeparators(),p=u.allowedDecimalSeparators,m=u.decimalSeparator,f=this.state.numAsString||"",h=this.selectionBeforeInput,b=h.selectionStart,g=h.selectionEnd,v=function(e,t){for(var n=0,r=0,o=e.length,i=t.length;e[n]===t[n]&&n<o;)n++;for(;e[o-1-r]===t[i-1-r]&&i-r>n&&o-r>n;)r++;return{start:n,end:o-r}}(t,n),O=v.start,w=v.end;if(!i&&O===w&&-1!==p.indexOf(n[b])){var j=0===l?"":m;return n.substr(0,b)+j+n.substr(b+1,n.length)}var y=i?0:a.length,E=t.length-(i?0:c.length);if(n.length>t.length||!n.length||O===w||0===b&&g===t.length||0===O&&w===t.length||b===y&&g===E)return n;var S=t.substr(O,w-O);if([].concat(S).find((function(e,n){return r.isCharacterAFormat(n+O,t)}))){var x=t.substr(O),k={},N=[];[].concat(x).forEach((function(e,n){r.isCharacterAFormat(n+O,t)?k[n]=e:n>S.length-1&&N.push(e)})),Object.keys(k).forEach((function(e){N.length>e?N.splice(e,0,k[e]):N.push(k[e])})),n=t.substr(0,O)+N.join("")}if(!i){var _=this.removeFormatting(n),F=d(_,s),C=F.beforeDecimal,T=F.afterDecimal,P=F.addNegation,R=e<n.indexOf(m)+1;if(_.length<f.length&&R&&""===C&&!parseFloat(T))return P?"-":""}return n},t.prototype.updateValue=function(e){var t=e.formattedValue,n=e.input,r=e.setCaretPosition;void 0===r&&(r=!0);var o=e.source,i=e.event,s=e.numAsString,a=e.caretPos,c=this.props.onValueChange,l=this.state.value;if(n){if(void 0===a&&r){var u=e.inputValue||n.value,p=O(n);n.value=t,a=this.getCaretPosition(u,t,p)}n.value=t,r&&this.setPatchedCaretPosition(n,a,t)}void 0===s&&(s=this.removeFormatting(t)),t!==l&&(this.setState({value:t,numAsString:s}),c(this.getValueObject(t,s),{event:i,source:o}))},t.prototype.onChange=function(e){var t=e.target,n=t.value,r=this.state,o=this.props,i=o.isAllowed,s=r.value||"",a=O(t);n=this.correctInputValue(a,s,n);var c=this.formatInput(n)||"",l=this.removeFormatting(c),u=i(this.getValueObject(c,l));u||(c=s),this.updateValue({formattedValue:c,numAsString:l,inputValue:n,input:t,event:e,source:"event"}),u&&o.onChange(e)},t.prototype.onBlur=function(e){var t=this.props,n=this.state,r=t.format,o=t.onBlur,i=t.allowLeadingZeros,s=n.numAsString,a=n.value;if(this.focusedElm=null,clearTimeout(this.focusTimeout),clearTimeout(this.caretPositionTimeout),!r){isNaN(parseFloat(s))&&(s=""),i||(s=function(e){if(!e)return e;var t="-"===e[0];t&&(e=e.substring(1,e.length));var n=e.split("."),r=n[0].replace(/^0+/,"")||"0",o=n[1]||"";return(t?"-":"")+r+(o?"."+o:"")}(s));var c=this.formatNumString(s);if(c!==a)return this.updateValue({formattedValue:c,numAsString:s,input:e.target,setCaretPosition:!1,event:e,source:"event"}),void o(e)}o(e)},t.prototype.onKeyDown=function(e){var t,n=e.target,r=e.key,o=n.selectionStart,i=n.selectionEnd,s=n.value;void 0===s&&(s="");var a=this.props,c=a.decimalScale,l=a.fixedDecimalScale,u=a.prefix,p=a.suffix,m=a.format,f=a.onKeyDown,d=void 0!==c&&l,h=this.getNumberRegex(!1,d),b=new RegExp("-"),g="string"==typeof m;if(this.selectionBeforeInput={selectionStart:o,selectionEnd:i},"ArrowLeft"===r||"Backspace"===r?t=o-1:"ArrowRight"===r?t=o+1:"Delete"===r&&(t=o),void 0!==t&&o===i){var v=t,O=g?m.indexOf("#"):u.length,w=g?m.lastIndexOf("#")+1:s.length-p.length;if("ArrowLeft"===r||"ArrowRight"===r){var j="ArrowLeft"===r?"left":"right";v=this.correctCaretPosition(s,t,j)}else if("Delete"!==r||h.test(s[t])||b.test(s[t])){if("Backspace"===r&&!h.test(s[t]))if(o<=O+1&&"-"===s[0]&&void 0===m){var y=s.substring(1);this.updateValue({formattedValue:y,caretPos:v,input:n,event:e,source:"event"})}else if(!b.test(s[t])){for(;!h.test(s[v-1])&&v>O;)v--;v=this.correctCaretPosition(s,v,"left")}}else for(;!h.test(s[v])&&v<w;)v++;(v!==t||t<O||t>w)&&(e.preventDefault(),this.setPatchedCaretPosition(n,v,s)),e.isUnitTestRun&&this.setPatchedCaretPosition(n,v,s),f(e)}else f(e)},t.prototype.onMouseUp=function(e){var t=e.target,n=t.selectionStart,r=t.selectionEnd,o=t.value;if(void 0===o&&(o=""),n===r){var i=this.correctCaretPosition(o,n);i!==n&&this.setPatchedCaretPosition(t,i,o)}this.props.onMouseUp(e)},t.prototype.onFocus=function(e){var t=this;e.persist(),this.focusedElm=e.target,this.focusTimeout=setTimeout((function(){var n=e.target,r=n.selectionStart,o=n.selectionEnd,i=n.value;void 0===i&&(i="");var s=t.correctCaretPosition(i,r);s===r||0===r&&o===i.length||t.setPatchedCaretPosition(n,s,i),t.props.onFocus(e)}),0)},t.prototype.render=function(){var e=this.props,t=e.type,n=e.displayType,r=e.customInput,o=e.renderText,i=e.getInputRef,s=e.format,a=(e.thousandSeparator,e.decimalSeparator,e.allowedDecimalSeparators,e.thousandsGroupStyle,e.decimalScale,e.fixedDecimalScale,e.prefix,e.suffix,e.removeFormatting,e.mask,e.defaultValue,e.isNumericString,e.allowNegative,e.allowEmptyFormatting,e.allowLeadingZeros,e.onValueChange,e.isAllowed,e.customNumerals,e.onChange,e.onKeyDown,e.onMouseUp,e.onFocus,e.onBlur,e.value,function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&-1===t.indexOf(r)&&(n[r]=e[r]);return n}(e,["type","displayType","customInput","renderText","getInputRef","format","thousandSeparator","decimalSeparator","allowedDecimalSeparators","thousandsGroupStyle","decimalScale","fixedDecimalScale","prefix","suffix","removeFormatting","mask","defaultValue","isNumericString","allowNegative","allowEmptyFormatting","allowLeadingZeros","onValueChange","isAllowed","customNumerals","onChange","onKeyDown","onMouseUp","onFocus","onBlur","value"])),c=this.state,u=c.value,p=c.mounted&&function(e){return e||"undefined"!=typeof navigator&&!(navigator.platform&&/iPhone|iPod/.test(navigator.platform))}(s)?"numeric":void 0,m=Object.assign({inputMode:p},a,{type:t,value:u,onChange:this.onChange,onKeyDown:this.onKeyDown,onMouseUp:this.onMouseUp,onFocus:this.onFocus,onBlur:this.onBlur});if("text"===n)return o?o(u,a)||null:l.a.createElement("span",Object.assign({},a,{ref:i}),u);if(r){var f=r;return l.a.createElement(f,Object.assign({},m,{ref:i}))}return l.a.createElement("input",Object.assign({},m,{ref:i}))},t}(l.a.Component);j.defaultProps=w;var y=j;n(135);const E=e=>({thousandSeparator:e.thousandSeparator,decimalSeparator:e.decimalSeparator,decimalScale:e.minorUnit,fixedDecimalScale:!0,prefix:e.prefix,suffix:e.suffix,isNumericString:!0});var S=e=>{let{className:t,value:n,currency:o,onValueChange:s,displayType:c="text",...l}=e;const u="string"==typeof n?parseInt(n,10):n;if(!Number.isFinite(u))return null;const p=u/10**o.minorUnit;if(!Number.isFinite(p))return null;const m=i()("wc-block-formatted-money-amount","wc-block-components-formatted-money-amount",t),f={...l,...E(o),value:void 0,currency:void 0,onValueChange:void 0},d=s?e=>{const t=+e.value*10**o.minorUnit;s(t)}:()=>{};return Object(r.createElement)(y,a()({className:m,displayType:c},f,{value:p,onValueChange:d}))};n(134);const x=e=>{let{value:t,currency:n}=e;return Object(r.isValidElement)(t)?Object(r.createElement)("div",{className:"wc-block-components-totals-item__value"},t):Number.isFinite(t)?Object(r.createElement)(S,{className:"wc-block-components-totals-item__value",currency:n||{},value:t}):null};var k=e=>{let{className:t,currency:n,label:o,value:s,description:a}=e;return Object(r.createElement)("div",{className:i()("wc-block-components-totals-item",t)},Object(r.createElement)("span",{className:"wc-block-components-totals-item__label"},o),Object(r.createElement)(x,{value:s,currency:n}),Object(r.createElement)("div",{className:"wc-block-components-totals-item__description"},a))},N=n(1),_=n(3),F=e=>{let{currency:t,values:n,className:o}=e;const{total_items:i,total_items_tax:s}=n,a=parseInt(i,10),c=parseInt(s,10);return Object(r.createElement)(k,{className:o,currency:t,label:Object(N.__)("Subtotal","woo-gutenberg-products-block"),value:Object(_.getSetting)("displayCartPricesIncludingTax",!1)?a+c:a})},C=e=>{let{currency:t,values:n,className:o,showRateAfterTaxName:s}=e;const{total_tax:a,tax_lines:c}=n;if(!Object(_.getSetting)("taxesEnabled",!0)&&parseInt(a,10)<=0)return null;const l=Object(_.getSetting)("displayItemizedTaxes",!1),u=l&&c.length>0?Object(r.createElement)(r.Fragment,null,c.map((e,n)=>{let{name:a,rate:c,price:l}=e;const u=`${a}${s?" "+c:""}`;return Object(r.createElement)(k,{key:"tax-line-"+n,className:i()("wc-block-components-totals-taxes",o),currency:t,label:u,value:parseInt(l,10)})})," "):null;return l?u:Object(r.createElement)(r.Fragment,null,Object(r.createElement)(k,{className:i()("wc-block-components-totals-taxes",o),currency:t,label:Object(N.__)("Taxes","woo-gutenberg-products-block"),value:parseInt(a,10),description:null}))},T=e=>{let{currency:t,cartFees:n,className:o}=e;return Object(r.createElement)(r.Fragment,null,n.map((e,n)=>{let{id:s,name:a,totals:c}=e;const l=parseInt(c.total,10);if(!l)return null;const u=parseInt(c.total_tax,10);return Object(r.createElement)(k,{key:s||`${n}-${a}`,className:i()("wc-block-components-totals-fees",o),currency:t,label:a||Object(N.__)("Fee","woo-gutenberg-products-block"),value:Object(_.getSetting)("displayCartPricesIncludingTax",!1)?l+u:l})}))};n(136);var P=e=>{let{children:t,slotWrapper:n=!1,className:o}=e;return c.Children.count(t)?Object(r.createElement)("div",{className:i()(o,"wc-block-components-totals-wrapper",{"slot-wrapper":n})},t):null},R=n(8),M=n.n(R),A=n(7),D=n(22);function L(e){const t=Object(r.useContext)(D.a),n=t.slots[e]||{},o=t.fills[e],i=Object(r.useMemo)(()=>o||[],[o]);return{...n,updateSlot:Object(r.useCallback)(n=>{t.updateSlot(e,n)},[e,t.updateSlot]),unregisterSlot:Object(r.useCallback)(n=>{t.unregisterSlot(e,n)},[e,t.unregisterSlot]),fills:i,registerFill:Object(r.useCallback)(n=>{t.registerFill(e,n)},[e,t.registerFill]),unregisterFill:Object(r.useCallback)(n=>{t.unregisterFill(e,n)},[e,t.unregisterFill])}}var I=n(10),V=n(4),B=Object(r.createContext)({registerSlot:()=>{},unregisterSlot:()=>{},registerFill:()=>{},unregisterFill:()=>{},getSlot:()=>{},getFills:()=>{},subscribe:()=>{}});function U({name:e,children:t,registerFill:n,unregisterFill:o}){const i=(e=>{const{getSlot:t,subscribe:n}=Object(r.useContext)(B),[o,i]=Object(r.useState)(t(e));return Object(r.useEffect)(()=>(i(t(e)),n(()=>{i(t(e))})),[e]),o})(e),s=Object(r.useRef)({name:e,children:t});return Object(r.useLayoutEffect)(()=>(n(e,s.current),()=>o(e,s.current)),[]),Object(r.useLayoutEffect)(()=>{s.current.children=t,i&&i.forceUpdate()},[t]),Object(r.useLayoutEffect)(()=>{e!==s.current.name&&(o(s.current.name,s.current),s.current.name=e,n(e,s.current))},[e]),i&&i.node?(Object(V.isFunction)(t)&&(t=t(i.props.fillProps)),Object(r.createPortal)(t,i.node)):null}var W=e=>Object(r.createElement)(B.Consumer,null,({registerFill:t,unregisterFill:n})=>Object(r.createElement)(U,Object(I.a)({},e,{registerFill:t,unregisterFill:n})));class H extends r.Component{constructor(){super(...arguments),this.isUnmounted=!1,this.bindNode=this.bindNode.bind(this)}componentDidMount(){const{registerSlot:e}=this.props;e(this.props.name,this)}componentWillUnmount(){const{unregisterSlot:e}=this.props;this.isUnmounted=!0,e(this.props.name,this)}componentDidUpdate(e){const{name:t,unregisterSlot:n,registerSlot:r}=this.props;e.name!==t&&(n(e.name),r(t,this))}bindNode(e){this.node=e}forceUpdate(){this.isUnmounted||super.forceUpdate()}render(){const{children:e,name:t,fillProps:n={},getFills:o}=this.props,i=Object(V.map)(o(t,this),e=>{const t=Object(V.isFunction)(e.children)?e.children(n):e.children;return r.Children.map(t,(e,t)=>{if(!e||Object(V.isString)(e))return e;const n=e.key||t;return Object(r.cloneElement)(e,{key:n})})}).filter(Object(V.negate)(r.isEmptyElement));return Object(r.createElement)(r.Fragment,null,Object(V.isFunction)(e)?e(i):i)}}var z=e=>Object(r.createElement)(B.Consumer,null,({registerSlot:t,unregisterSlot:n,getFills:o})=>Object(r.createElement)(H,Object(I.a)({},e,{registerSlot:t,unregisterSlot:n,getFills:o})));function $(){const[,e]=Object(r.useState)({}),t=Object(r.useRef)(!0);return Object(r.useEffect)(()=>()=>{t.current=!1},[]),()=>{t.current&&e({})}}function K({name:e,children:t}){const n=L(e),o=Object(r.useRef)({rerender:$()});return Object(r.useEffect)(()=>(n.registerFill(o),()=>{n.unregisterFill(o)}),[n.registerFill,n.unregisterFill]),n.ref&&n.ref.current?("function"==typeof t&&(t=t(n.fillProps)),Object(r.createPortal)(t,n.ref.current)):null}var G=n(14),q=Object(r.forwardRef)((function({name:e,fillProps:t={},as:n="div",...o},i){const s=Object(r.useContext)(D.a),a=Object(r.useRef)();return Object(r.useLayoutEffect)(()=>(s.registerSlot(e,a,t),()=>{s.unregisterSlot(e,a)}),[s.registerSlot,s.unregisterSlot,e]),Object(r.useLayoutEffect)(()=>{s.updateSlot(e,t)}),Object(r.createElement)(n,Object(I.a)({ref:Object(G.useMergeRefs)([i,a])},o))})),Y=n(12),Z=n.n(Y);function X({children:e}){const t=function(){const[e,t]=Object(r.useState)({}),[n,o]=Object(r.useState)({}),i=Object(r.useCallback)((e,n,r)=>{t(t=>{const o=t[e]||{};return{...t,[e]:{...o,ref:n||o.ref,fillProps:r||o.fillProps||{}}}})},[]),s=Object(r.useCallback)((e,n)=>{t(t=>{const{[e]:r,...o}=t;return(null==r?void 0:r.ref)===n?o:t})},[]),a=Object(r.useCallback)((t,r)=>{const o=e[t];if(o&&!Z()(o.fillProps,r)){o.fillProps=r;const e=n[t];e&&e.map(e=>e.current.rerender())}},[e,n]),c=Object(r.useCallback)((e,t)=>{o(n=>({...n,[e]:[...n[e]||[],t]}))},[]),l=Object(r.useCallback)((e,t)=>{o(n=>n[e]?{...n,[e]:n[e].filter(e=>e!==t)}:n)},[]);return Object(r.useMemo)(()=>({slots:e,fills:n,registerSlot:i,updateSlot:a,unregisterSlot:s,registerFill:c,unregisterFill:l}),[e,n,i,a,s,c,l])}();return Object(r.createElement)(D.a.Provider,{value:t},e)}class J extends r.Component{constructor(){super(...arguments),this.registerSlot=this.registerSlot.bind(this),this.registerFill=this.registerFill.bind(this),this.unregisterSlot=this.unregisterSlot.bind(this),this.unregisterFill=this.unregisterFill.bind(this),this.getSlot=this.getSlot.bind(this),this.getFills=this.getFills.bind(this),this.hasFills=this.hasFills.bind(this),this.subscribe=this.subscribe.bind(this),this.slots={},this.fills={},this.listeners=[],this.contextValue={registerSlot:this.registerSlot,unregisterSlot:this.unregisterSlot,registerFill:this.registerFill,unregisterFill:this.unregisterFill,getSlot:this.getSlot,getFills:this.getFills,hasFills:this.hasFills,subscribe:this.subscribe}}registerSlot(e,t){const n=this.slots[e];this.slots[e]=t,this.triggerListeners(),this.forceUpdateSlot(e),n&&n.forceUpdate()}registerFill(e,t){this.fills[e]=[...this.fills[e]||[],t],this.forceUpdateSlot(e)}unregisterSlot(e,t){this.slots[e]===t&&(delete this.slots[e],this.triggerListeners())}unregisterFill(e,t){this.fills[e]=Object(V.without)(this.fills[e],t),this.forceUpdateSlot(e)}getSlot(e){return this.slots[e]}getFills(e,t){return this.slots[e]!==t?[]:this.fills[e]}hasFills(e){return this.fills[e]&&!!this.fills[e].length}forceUpdateSlot(e){const t=this.getSlot(e);t&&t.forceUpdate()}triggerListeners(){this.listeners.forEach(e=>e())}subscribe(e){return this.listeners.push(e),()=>{this.listeners=Object(V.without)(this.listeners,e)}}render(){return Object(r.createElement)(B.Provider,{value:this.contextValue},this.props.children)}}function Q(e){return Object(r.createElement)(r.Fragment,null,Object(r.createElement)(W,e),Object(r.createElement)(K,e))}const ee=Object(r.forwardRef)(({bubblesVirtually:e,...t},n)=>e?Object(r.createElement)(q,Object(I.a)({},t,{ref:n})):Object(r.createElement)(z,t));function te({children:e,...t}){return Object(r.createElement)(J,t,Object(r.createElement)(X,null,e))}function ne(e){const t=t=>Object(r.createElement)(Q,Object(I.a)({name:e},t));t.displayName=e+"Fill";const n=t=>Object(r.createElement)(ee,Object(I.a)({name:e},t));return n.displayName=e+"Slot",n.__unstableName=e,{Fill:t,Slot:n}}var re=n(20),oe=n.n(re);class ie extends c.Component{constructor(){super(...arguments),oe()(this,"state",{errorMessage:"",hasError:!1})}static getDerivedStateFromError(e){return void 0!==e.statusText&&void 0!==e.status?{errorMessage:Object(r.createElement)(r.Fragment,null,Object(r.createElement)("strong",null,e.status),": "+e.statusText),hasError:!0}:{errorMessage:e.message,hasError:!0}}render(){const{renderError:e}=this.props,{errorMessage:t,hasError:n}=this.state;return n?"function"==typeof e?e(t):Object(r.createElement)("p",null,t):this.props.children}}var se=ie;const ae=e=>Array.isArray(e)&&e.filter(Boolean).length>0;let ce;ce=L;const le=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const{Fill:n,Slot:o}=ne(e),i=e=>{let{children:o}=e;return Object(r.createElement)(n,null,e=>r.Children.map(o,n=>Object(r.createElement)(se,{renderError:_.CURRENT_USER_IS_ADMIN?t:()=>null},Object(r.cloneElement)(n,e))))},s=e=>Object(r.createElement)(o,a()({},e,{bubblesVirtually:!0}));return{Fill:i,Slot:s}},{Fill:ue,Slot:pe}=le("__experimentalOrderMeta");ue.Slot=e=>{let{className:t,extensions:n,cart:o,context:s}=e;const{fills:a}=ce("__experimentalOrderMeta");return ae(a)&&Object(r.createElement)(P,{slotWrapper:!0},Object(r.createElement)(pe,{className:i()(t,"wc-block-components-order-meta"),fillProps:{extensions:n,cart:o,context:s}}))};var me=ue;const{Fill:fe,Slot:de}=le("__experimentalDiscountsMeta");fe.Slot=e=>{let{className:t,extensions:n,cart:o,context:s}=e;const{fills:a}=ce("__experimentalDiscountsMeta");return ae(a)&&Object(r.createElement)(P,{slotWrapper:!0},Object(r.createElement)(de,{className:i()(t,"wc-block-components-discounts-meta"),fillProps:{extensions:n,cart:o,context:s}}))};var he=fe;const{Fill:be,Slot:ge}=le("__experimentalOrderShippingPackages");be.Slot=e=>{let{className:t,collapsible:n,noResultsMessage:o,renderOption:s,extensions:a,cart:c,components:l,context:u,shippingRates:p}=e;const{fills:m}=ce("__experimentalOrderShippingPackages"),f=m.length>1||(null==p?void 0:p.length)>1;return Object(r.createElement)(ge,{className:i()("wc-block-components-shipping-rates-control",t),fillProps:{collapsible:n,collapse:f,showItems:f,noResultsMessage:o,renderOption:s,extensions:a,cart:c,components:l,context:u}})};var ve=be,Oe=function(e){let{icon:t,size:n=24,...o}=e;return Object(r.cloneElement)(t,{width:n,height:n,...o})},we=Object(r.createElement)(A.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},Object(r.createElement)(A.Path,{d:"M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z"})),je=Object(r.createElement)(A.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},Object(r.createElement)(A.Path,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"}));n(137);var ye=e=>{let{children:t,className:n,initialOpen:o=!1,hasBorder:s=!1,title:a,titleTag:c="div"}=e;const[l,u]=Object(r.useState)(o);return Object(r.createElement)("div",{className:i()(n,"wc-block-components-panel",{"has-border":s})},Object(r.createElement)(c,null,Object(r.createElement)("button",{"aria-expanded":l,className:"wc-block-components-panel__button",onClick:()=>u(!l)},Object(r.createElement)(Oe,{"aria-hidden":"true",className:"wc-block-components-panel__button-icon",icon:l?we:je}),a)),l&&Object(r.createElement)("div",{className:"wc-block-components-panel__content"},t))},Ee=n(39),Se=Object(r.createElement)(A.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(r.createElement)(A.Path,{d:"M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"}));function xe(e,t,n){const{defaultView:r}=t,{frameElement:o}=r;if(!o||t===n.ownerDocument)return e;const i=o.getBoundingClientRect();return new r.DOMRect(e.left+i.left,e.top+i.top,e.width,e.height)}let ke=0;function Ne(e){const t=document.scrollingElement||document.body;e&&(ke=t.scrollTop);const n=e?"add":"remove";t.classList[n]("lockscroll"),document.documentElement.classList[n]("lockscroll"),e||(t.scrollTop=ke)}let _e=0;function Fe(){return Object(r.useEffect)(()=>(0===_e&&Ne(!0),++_e,()=>{1===_e&&Ne(!1),--_e}),[]),null}function Ce(e){return"appear"===e?"top":"left"}function Te(e,t){const{paddingTop:n,paddingBottom:r,paddingLeft:o,paddingRight:i}=(s=t).ownerDocument.defaultView.getComputedStyle(s);var s;const a=n?parseInt(n,10):0,c=r?parseInt(r,10):0,l=o?parseInt(o,10):0,u=i?parseInt(i,10):0;return{x:e.left+l,y:e.top+a,width:e.width-l-u,height:e.height-a-c,left:e.left+l,right:e.right-u,top:e.top+a,bottom:e.bottom-c}}function Pe(e,t,n){n?e.getAttribute(t)!==n&&e.setAttribute(t,n):e.hasAttribute(t)&&e.removeAttribute(t)}function Re(e,t,n=""){e.style[t]!==n&&(e.style[t]=n)}function Me(e,t,n){n?e.classList.contains(t)||e.classList.add(t):e.classList.contains(t)&&e.classList.remove(t)}const Ae=Object(r.forwardRef)(({headerTitle:e,onClose:t,children:n,className:o,noArrow:s=!0,isAlternate:a,position:c="bottom right",range:l,focusOnMount:u="firstElement",anchorRef:p,shouldAnchorIncludePadding:m,anchorRect:f,getAnchorRect:d,expandOnMobile:h,animate:b=!0,onClickOutside:g,onFocusOutside:v,__unstableStickyBoundaryElement:O,__unstableSlotName:w="Popover",__unstableObserveElement:j,__unstableBoundaryParent:y,__unstableForcePosition:E,__unstableForceXAlignment:S,...x},k)=>{const _=Object(r.useRef)(null),F=Object(r.useRef)(null),C=Object(r.useRef)(),T=Object(G.useViewportMatch)("medium","<"),[P,R]=Object(r.useState)(),A=L(w),D=h&&T,[V,B]=Object(G.useResizeObserver)();s=D||s,Object(r.useLayoutEffect)(()=>{if(D)return Me(C.current,"is-without-arrow",s),Me(C.current,"is-alternate",a),Pe(C.current,"data-x-axis"),Pe(C.current,"data-y-axis"),Re(C.current,"top"),Re(C.current,"left"),Re(F.current,"maxHeight"),void Re(F.current,"maxWidth");const e=()=>{if(!C.current||!F.current)return;let e=function(e,t,n,r=!1,o,i){if(t)return t;if(n){if(!e.current)return;const t=n(e.current);return xe(t,t.ownerDocument||e.current.ownerDocument,i)}if(!1!==r){if(!(r&&window.Range&&window.Element&&window.DOMRect))return;if("function"==typeof(null==r?void 0:r.cloneRange))return xe(Object(Ee.getRectangleFromRange)(r),r.endContainer.ownerDocument,i);if("function"==typeof(null==r?void 0:r.getBoundingClientRect)){const e=xe(r.getBoundingClientRect(),r.ownerDocument,i);return o?e:Te(e,r)}const{top:e,bottom:t}=r,n=e.getBoundingClientRect(),s=t.getBoundingClientRect(),a=xe(new window.DOMRect(n.left,n.top,n.width,s.bottom-n.top),e.ownerDocument,i);return o?a:Te(a,r)}if(!e.current)return;const{parentNode:s}=e.current,a=s.getBoundingClientRect();return o?a:Te(a,s)}(_,f,d,p,m,C.current);if(!e)return;const{offsetParent:t,ownerDocument:n}=C.current;let r,o=0;if(t&&t!==n.body){const n=t.getBoundingClientRect();o=n.top,e=new window.DOMRect(e.left-n.left,e.top-n.top,e.width,e.height)}var i;y&&(r=null===(i=C.current.closest(".popover-slot"))||void 0===i?void 0:i.parentNode);const l=B.height?B:F.current.getBoundingClientRect(),{popoverTop:u,popoverLeft:h,xAxis:b,yAxis:g,contentHeight:v,contentWidth:w}=function(e,t,n="top",r,o,i,s,a,c){const[l,u="center",p]=n.split(" "),m=function(e,t,n,r,o,i,s,a){const{height:c}=t;if(o){const t=o.getBoundingClientRect().top+c-s;if(e.top<=t)return{yAxis:n,popoverTop:Math.min(e.bottom,t)}}let l=e.top+e.height/2;"bottom"===r?l=e.bottom:"top"===r&&(l=e.top);const u={popoverTop:l,contentHeight:(l-c/2>0?c/2:l)+(l+c/2>window.innerHeight?window.innerHeight-l:c/2)},p={popoverTop:e.top,contentHeight:e.top-10-c>0?c:e.top-10},m={popoverTop:e.bottom,contentHeight:e.bottom+10+c>window.innerHeight?window.innerHeight-10-e.bottom:c};let f,d=n,h=null;if(!o&&!a)if("middle"===n&&u.contentHeight===c)d="middle";else if("top"===n&&p.contentHeight===c)d="top";else if("bottom"===n&&m.contentHeight===c)d="bottom";else{d=p.contentHeight>m.contentHeight?"top":"bottom";const e="top"===d?p.contentHeight:m.contentHeight;h=e!==c?e:null}return f="middle"===d?u.popoverTop:"top"===d?p.popoverTop:m.popoverTop,{yAxis:d,popoverTop:f,contentHeight:h}}(e,t,l,p,r,0,i,a);return{...function(e,t,n,r,o,i,s,a,c){const{width:l}=t;"left"===n&&Object(N.isRTL)()?n="right":"right"===n&&Object(N.isRTL)()&&(n="left"),"left"===r&&Object(N.isRTL)()?r="right":"right"===r&&Object(N.isRTL)()&&(r="left");const u=Math.round(e.left+e.width/2),p={popoverLeft:u,contentWidth:(u-l/2>0?l/2:u)+(u+l/2>window.innerWidth?window.innerWidth-u:l/2)};let m=e.left;"right"===r?m=e.right:"middle"===i||c||(m=u);let f=e.right;"left"===r?f=e.left:"middle"===i||c||(f=u);const d={popoverLeft:m,contentWidth:m-l>0?l:m},h={popoverLeft:f,contentWidth:f+l>window.innerWidth?window.innerWidth-f:l};let b,g=n,v=null;if(!o&&!a)if("center"===n&&p.contentWidth===l)g="center";else if("left"===n&&d.contentWidth===l)g="left";else if("right"===n&&h.contentWidth===l)g="right";else{g=d.contentWidth>h.contentWidth?"left":"right";const e="left"===g?d.contentWidth:h.contentWidth;l>window.innerWidth&&(v=window.innerWidth),e!==l&&(g="center",p.popoverLeft=window.innerWidth/2)}if(b="center"===g?p.popoverLeft:"left"===g?d.popoverLeft:h.popoverLeft,s){const e=s.getBoundingClientRect();b=Math.min(b,e.right-l),Object(N.isRTL)()||(b=Math.max(b,0))}return{xAxis:g,popoverLeft:b,contentWidth:v}}(e,t,u,p,r,m.yAxis,s,a,c),...m}}(e,l,c,O,C.current,o,r,E,S);"number"==typeof u&&"number"==typeof h&&(Re(C.current,"top",u+"px"),Re(C.current,"left",h+"px")),Me(C.current,"is-without-arrow",s||"center"===b&&"middle"===g),Me(C.current,"is-alternate",a),Pe(C.current,"data-x-axis",b),Pe(C.current,"data-y-axis",g),Re(F.current,"maxHeight","number"==typeof v?v+"px":""),Re(F.current,"maxWidth","number"==typeof w?w+"px":""),R(({left:"right",right:"left"}[b]||"center")+" "+({top:"bottom",bottom:"top"}[g]||"middle"))};e();const{ownerDocument:t}=C.current,{defaultView:n}=t,r=n.setInterval(e,500);let o;const i=()=>{n.cancelAnimationFrame(o),o=n.requestAnimationFrame(e)};n.addEventListener("click",i),n.addEventListener("resize",e),n.addEventListener("scroll",e,!0);const l=function(e){if(e)return e.endContainer?e.endContainer.ownerDocument:e.top?e.top.ownerDocument:e.ownerDocument}(p);let u;return l&&l!==t&&(l.defaultView.addEventListener("resize",e),l.defaultView.addEventListener("scroll",e,!0)),j&&(u=new n.MutationObserver(e),u.observe(j,{attributes:!0})),()=>{n.clearInterval(r),n.removeEventListener("resize",e),n.removeEventListener("scroll",e,!0),n.removeEventListener("click",i),n.cancelAnimationFrame(o),l&&l!==t&&(l.defaultView.removeEventListener("resize",e),l.defaultView.removeEventListener("scroll",e,!0)),u&&u.disconnect()}},[D,f,d,p,m,c,B,O,j,y]);const U=(e,n)=>{if("focus-outside"===e&&v)v(n);else if("focus-outside"===e&&g){const e=new window.MouseEvent("click");Object.defineProperty(e,"target",{get:()=>n.relatedTarget}),M()("Popover onClickOutside prop",{since:"5.3",alternative:"onFocusOutside"}),g(e)}else t&&t()},[W,H]=Object(G.__experimentalUseDialog)({focusOnMount:u,__unstableOnClose:U,onClose:U}),z=Object(G.useMergeRefs)([C,W,k]),$=Boolean(b&&P)&&function(e){if("loading"===e.type)return i()("components-animate__loading");const{type:t,origin:n=Ce(t)}=e;if("appear"===t){const[e,t="center"]=n.split(" ");return i()("components-animate__appear",{["is-from-"+t]:"center"!==t,["is-from-"+e]:"middle"!==e})}return"slide-in"===t?i()("components-animate__slide-in","is-from-"+n):void 0}({type:"appear",origin:P});let K=Object(r.createElement)("div",Object(I.a)({className:i()("components-popover",o,$,{"is-expanded":D,"is-without-arrow":s,"is-alternate":a})},x,{ref:z},H,{tabIndex:"-1"}),D&&Object(r.createElement)(Fe,null),D&&Object(r.createElement)("div",{className:"components-popover__header"},Object(r.createElement)("span",{className:"components-popover__header-title"},e),Object(r.createElement)(Ge,{className:"components-popover__close",icon:Se,onClick:t})),Object(r.createElement)("div",{ref:F,className:"components-popover__content"},Object(r.createElement)("div",{style:{position:"relative"}},V,n)));return A.ref&&(K=Object(r.createElement)(Q,{name:w},K)),p||f?K:Object(r.createElement)("span",{ref:_},K)});Ae.Slot=Object(r.forwardRef)((function({name:e="Popover"},t){return Object(r.createElement)(ee,{bubblesVirtually:!0,name:e,className:"popover-slot",ref:t})}));var De=Ae,Le=function({shortcut:e,className:t}){if(!e)return null;let n,o;return Object(V.isString)(e)&&(n=e),Object(V.isObject)(e)&&(n=e.display,o=e.ariaLabel),Object(r.createElement)("span",{className:t,"aria-label":o},n)};const Ie=Object(r.createElement)("div",{className:"event-catcher"}),Ve=({eventHandlers:e,child:t,childrenWithPopover:n})=>Object(r.cloneElement)(Object(r.createElement)("span",{className:"disabled-element-wrapper"},Object(r.cloneElement)(Ie,e),Object(r.cloneElement)(t,{children:n}),","),e),Be=({child:e,eventHandlers:t,childrenWithPopover:n})=>Object(r.cloneElement)(e,{...t,children:n}),Ue=(e,t,n)=>{if(1!==r.Children.count(e))return;const o=r.Children.only(e);"function"==typeof o.props[t]&&o.props[t](n)};var We=function({children:e,position:t,text:n,shortcut:o}){const[i,s]=Object(r.useState)(!1),[a,c]=Object(r.useState)(!1),l=Object(G.useDebounce)(c,700),u=t=>{Ue(e,"onMouseDown",t),document.addEventListener("mouseup",f),s(!0)},p=t=>{Ue(e,"onMouseUp",t),document.removeEventListener("mouseup",f),s(!1)},m=e=>"mouseUp"===e?p:"mouseDown"===e?u:void 0,f=m("mouseUp"),d=(t,n)=>r=>{if(Ue(e,t,r),r.currentTarget.disabled)return;if("focus"===r.type&&i)return;l.cancel();const o=Object(V.includes)(["focus","mouseenter"],r.type);o!==a&&(n?l(o):c(o))},h=()=>{l.cancel(),document.removeEventListener("mouseup",f)};if(Object(r.useEffect)(()=>h,[]),1!==r.Children.count(e))return e;const b={onMouseEnter:d("onMouseEnter",!0),onMouseLeave:d("onMouseLeave"),onClick:d("onClick"),onFocus:d("onFocus"),onBlur:d("onBlur"),onMouseDown:m("mouseDown")},g=r.Children.only(e),{children:v,disabled:O}=g.props;return(O?Ve:Be)({child:g,eventHandlers:b,childrenWithPopover:(({grandchildren:e,isOver:t,position:n,text:o,shortcut:i})=>Object(r.concatChildren)(e,t&&Object(r.createElement)(De,{focusOnMount:!1,position:n,className:"components-tooltip","aria-hidden":"true",animate:!1,noArrow:!0},o,Object(r.createElement)(Le,{className:"components-tooltip__shortcut",shortcut:i}))))({grandchildren:v,isOver:a,position:t,text:n,shortcut:o})})},He=function({icon:e,className:t,...n}){const o=["dashicon","dashicons","dashicons-"+e,t].filter(Boolean).join(" ");return Object(r.createElement)("span",Object(I.a)({className:o},n))},ze=function({icon:e=null,size:t=24,...n}){if("string"==typeof e)return Object(r.createElement)(He,Object(I.a)({icon:e},n));if(Object(r.isValidElement)(e)&&He===e.type)return Object(r.cloneElement)(e,{...n});if("function"==typeof e)return e.prototype instanceof r.Component?Object(r.createElement)(e,{size:t,...n}):e({size:t,...n});if(e&&("svg"===e.type||e.type===A.SVG)){const o={width:t,height:t,...e.props,...n};return Object(r.createElement)(A.SVG,o)}return Object(r.isValidElement)(e)?Object(r.cloneElement)(e,{size:t,...n}):e},$e=Object(r.forwardRef)((function({as:e="div",className:t,...n},o){return function({as:e="div",...t}){return"function"==typeof t.children?t.children(t):Object(r.createElement)(e,t)}({as:e,className:i()("components-visually-hidden",t),...n,ref:o})}));const Ke=["onMouseDown","onClick"];var Ge=Object(r.forwardRef)((function(e,t){const{href:n,target:o,isSmall:s,isPressed:a,isBusy:c,isDestructive:l,className:u,disabled:p,icon:m,iconPosition:f="left",iconSize:d,showTooltip:h,tooltipPosition:b,shortcut:g,label:v,children:O,text:w,variant:j,__experimentalIsFocusable:y,describedBy:E,...S}=function({isDefault:e,isPrimary:t,isSecondary:n,isTertiary:r,isLink:o,variant:i,...s}){let a=i;var c,l,u,p,m;return t&&(null!==(c=a)&&void 0!==c||(a="primary")),r&&(null!==(l=a)&&void 0!==l||(a="tertiary")),n&&(null!==(u=a)&&void 0!==u||(a="secondary")),e&&(M()("Button isDefault prop",{since:"5.4",alternative:'variant="secondary"'}),null!==(p=a)&&void 0!==p||(a="secondary")),o&&(null!==(m=a)&&void 0!==m||(a="link")),{...s,variant:a}}(e),x=i()("components-button",u,{"is-secondary":"secondary"===j,"is-primary":"primary"===j,"is-small":s,"is-tertiary":"tertiary"===j,"is-pressed":a,"is-busy":c,"is-link":"link"===j,"is-destructive":l,"has-text":!!m&&!!O,"has-icon":!!m}),k=p&&!y,N=void 0===n||k?"button":"a",_="a"===N?{href:n,target:o}:{type:"button",disabled:k,"aria-pressed":a};if(p&&y){_["aria-disabled"]=!0;for(const e of Ke)S[e]=e=>{e.stopPropagation(),e.preventDefault()}}const F=!k&&(h&&v||g||!!v&&(!O||Object(V.isArray)(O)&&!O.length)&&!1!==h),C=E?Object(V.uniqueId)():null,T=S["aria-describedby"]||C,P=Object(r.createElement)(N,Object(I.a)({},_,S,{className:x,"aria-label":S["aria-label"]||v,"aria-describedby":T,ref:t}),m&&"left"===f&&Object(r.createElement)(ze,{icon:m,size:d}),w&&Object(r.createElement)(r.Fragment,null,w),m&&"right"===f&&Object(r.createElement)(ze,{icon:m,size:d}),O);return F?Object(r.createElement)(r.Fragment,null,Object(r.createElement)(We,{text:E||v,shortcut:g,position:b},P),E&&Object(r.createElement)($e,null,Object(r.createElement)("span",{id:C},E))):Object(r.createElement)(r.Fragment,null,P,E&&Object(r.createElement)($e,null,Object(r.createElement)("span",{id:C},E)))}));n(139);var qe=()=>Object(r.createElement)("span",{className:"wc-block-components-spinner","aria-hidden":"true"});n(138);var Ye=e=>{let{className:t,showSpinner:n=!1,children:o,variant:s="contained",...c}=e;const l=i()("wc-block-components-button",t,s,{"wc-block-components-button--loading":n});return Object(r.createElement)(Ge,a()({className:l},c),n&&Object(r.createElement)(qe,null),Object(r.createEle
|
|