Version Description
- 2022-12-06 =
Enhancements
- The "WooCommerce Alternating Image and Text" block pattern has been added. This design can be used by adding two attention-grabbing images, customizing the text to match your needs and customizing the button block to be linked to any page. (7827)
- Add to Cart Button: Add support for the alignment setting. (7816)
- Products block: Make the block available to the users of the feature plugin. (7815)
- The "WooCommerce Product Hero 2 Column 2 Row" block pattern has been added. It is a straightforward hero design that can be used by adding two attention-grabbing images, some custom product description text and customizing the button block to be linked to any page. (7814)
- The "Just Arrived Full Hero" block pattern has been added. It is a straightforward hero design that can be used with an attention-grabber image some simple callout text, and a button block that can be linked to any page. (7812)
- Product Rating: Add support for the alignment setting. (7790)
- Rename Active Product Filters block to Active Filters. (7753)
- Product Query: Add support for filtering by attributes within the block. (7743)
- Align the font-sizes in filters. (7707)
Bug Fixes
- Mini Cart block: Load
wc-blocks-registry
package at the page's load instead of lazy load it. (7813) - Hide the shipping address form from Checkout Block in Editor and rename the Billing Address label when "Force shipping to the customer billing address" is enabled. (7800)
- Product Price: Fix the alignment setting. (7795)
- Fix: Show tax label in Cart and Checkout block. (7785)
- Make Footer and Header patterns available in pattern chooser. (7699)
- Fix: Product Query editor preview with Stock Status setting. (7682)
technical debt
- Clean up unused CSS code. (7751)
Download this release
Release Info
Developer | automattic |
Plugin | WooCommerce Gutenberg Products Block |
Version | 9.1.0 |
Comparing to | |
See all releases |
Code changes from version 9.0.0 to 9.1.0
- assets/css/abstracts/_colors.scss +0 -5
- assets/css/abstracts/_mixins.scss +1 -1
- assets/css/abstracts/_variables.scss +0 -3
- assets/css/editor.scss +0 -25
- assets/css/style.scss +0 -9
- assets/js/atomic/blocks/product-elements/button/attributes.js +4 -0
- assets/js/atomic/blocks/product-elements/button/block.js +10 -1
- assets/js/atomic/blocks/product-elements/button/edit.js +22 -6
- assets/js/atomic/blocks/product-elements/button/style.scss +0 -3
- assets/js/atomic/blocks/product-elements/price/attributes.js +4 -10
- assets/js/atomic/blocks/product-elements/price/block.js +1 -0
- assets/js/atomic/blocks/product-elements/price/edit.js +1 -2
- assets/js/atomic/blocks/product-elements/price/style.scss +3 -0
- assets/js/atomic/blocks/product-elements/rating/attributes.ts +4 -0
- assets/js/atomic/blocks/product-elements/rating/block.tsx +7 -0
- assets/js/atomic/blocks/product-elements/rating/edit.tsx +20 -4
- assets/js/atomic/blocks/product-elements/rating/types.ts +1 -0
- assets/js/atomic/blocks/product-elements/sale-badge/attributes.ts +4 -0
- assets/js/atomic/blocks/product-elements/sale-badge/edit.tsx +21 -6
- assets/js/atomic/blocks/product-elements/sale-badge/index.ts +6 -2
- assets/js/atomic/blocks/product-elements/sale-badge/types.ts +1 -0
- assets/js/atomic/blocks/product-elements/sku/index.ts +2 -2
- assets/js/atomic/blocks/product-elements/stock-indicator/attributes.ts +15 -7
- assets/js/atomic/blocks/product-elements/stock-indicator/edit.tsx +21 -6
- assets/js/atomic/blocks/product-elements/stock-indicator/index.ts +8 -4
- assets/js/atomic/blocks/product-elements/stock-indicator/types.ts +1 -0
- assets/js/base/components/cart-checkout/totals/footer-item/index.tsx +33 -16
- assets/js/base/components/cart-checkout/totals/footer-item/stories/index.tsx +37 -2
- assets/js/base/components/cart-checkout/totals/footer-item/test/__snapshots__/index.tsx.snap +56 -0
- assets/js/base/components/cart-checkout/totals/footer-item/test/index.tsx +33 -3
- assets/js/base/components/chip/style.scss +1 -0
- assets/js/base/components/filter-reset-button/style.scss +1 -0
- assets/js/base/components/price-slider/style.scss +6 -0
- assets/js/base/context/hooks/payment-methods/use-payment-method-interface.ts +10 -4
- assets/js/base/context/hooks/use-checkout-address.ts +2 -2
- assets/js/base/context/hooks/use-checkout-extension-data.ts +3 -3
- assets/js/base/context/providers/cart-checkout/checkout-events/index.tsx +53 -27
- assets/js/base/context/providers/cart-checkout/checkout-processor.js +11 -3
- assets/js/base/context/providers/cart-checkout/checkout-provider.js +14 -17
- assets/js/base/context/providers/cart-checkout/customer/constants.ts +0 -31
- assets/js/base/context/providers/cart-checkout/customer/index.tsx +0 -42
- assets/js/base/context/providers/cart-checkout/index.js +0 -1
- assets/js/base/utils/lazy-load-script.ts +15 -4
- assets/js/base/utils/preload-script.ts +6 -3
- assets/js/blocks/active-filters/block.json +2 -2
- assets/js/blocks/active-filters/index.tsx +1 -1
- assets/js/blocks/active-filters/style.scss +2 -0
- assets/js/blocks/attribute-filter/style.scss +14 -3
- assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/attributes.tsx +6 -7
- assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/block.tsx +28 -2
- assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/constants.tsx +22 -0
- assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/edit.tsx +16 -4
- assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/frontend.tsx +9 -1
- assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/index.tsx +0 -1
- assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/utils.tsx +38 -0
- assets/js/blocks/checkout/inner-blocks/checkout-contact-information-block/block.tsx +7 -3
- assets/js/blocks/checkout/inner-blocks/checkout-shipping-address-block/edit.tsx +6 -2
- assets/js/blocks/filter-wrapper/index.tsx +2 -5
- assets/js/blocks/product-query/constants.ts +23 -4
- assets/js/blocks/product-query/index.tsx +11 -6
- assets/js/blocks/product-query/inspector-controls.tsx +36 -13
- assets/js/blocks/product-query/inspector-controls/attributes-filter.tsx +156 -0
- assets/js/blocks/product-query/inspector-controls/popular-presets.tsx +66 -0
- assets/js/blocks/product-query/style.scss +5 -0
- assets/js/blocks/product-query/types.ts +27 -3
- assets/js/blocks/product-query/useProductAttributes.ts +62 -0
- assets/js/blocks/product-query/utils.tsx +4 -7
- assets/js/blocks/product-query/variations/elements/product-summary.tsx +26 -0
- assets/js/blocks/product-query/variations/elements/product-title.tsx +26 -0
- assets/js/blocks/product-query/variations/elements/utils.tsx +31 -0
- assets/js/blocks/product-query/variations/product-query.tsx +25 -14
- assets/js/blocks/product-query/variations/products-on-sale.tsx +9 -10
- assets/js/blocks/rating-filter/style.scss +1 -0
- assets/js/blocks/stock-filter/style.scss +1 -0
- assets/js/data/checkout/selectors.ts +24 -2
- assets/js/data/checkout/thunks.ts +5 -6
- assets/js/data/payment/utils/check-payment-methods.ts +5 -8
- assets/js/editor-components/feedback-prompt/index.js +15 -4
- assets/js/editor-components/search-list-control/style.scss +3 -0
- assets/js/icons/index.js +1 -0
- assets/js/icons/library/stacks.tsx +16 -0
- build/active-filters-frontend.asset.php +1 -1
- build/active-filters-frontend.js +4 -4
- build/active-filters-wrapper-frontend.js +5 -5
- build/active-filters.asset.php +1 -1
- build/active-filters.js +4 -4
- build/active-filters/block.json +2 -2
- build/all-products-frontend.asset.php +1 -1
- build/all-products-frontend.js +4 -4
- build/all-products.asset.php +1 -1
- build/all-products.js +17 -17
- 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 +8 -8
- build/cart-blocks/cart-accepted-payment-methods-frontend.js +1 -1
- build/cart-blocks/cart-cross-sells-products--product-add-to-cart-frontend.js +1 -1
- build/cart-blocks/cart-cross-sells-products-frontend.js +6 -6
- build/cart-blocks/cart-express-payment--checkout-blocks/express-payment-frontend.js +2 -2
- build/cart-blocks/cart-express-payment-frontend.js +1 -1
- build/cart-blocks/cart-line-items--mini-cart-contents-block/products-table-frontend.js +3 -3
assets/css/abstracts/_colors.scss
CHANGED
@@ -2,15 +2,10 @@
|
|
2 |
@import "node_modules/@automattic/color-studio/dist/color-variables";
|
3 |
|
4 |
// Bright colors
|
5 |
-
$no-stock-color: $alert-red;
|
6 |
-
$low-stock-color: $alert-yellow;
|
7 |
-
$in-stock-color: $alert-green;
|
8 |
$discount-color: $alert-green;
|
9 |
|
10 |
-
$placeholder-color: var(--global--color-primary, $gray-200);
|
11 |
$input-border-gray: #50575e;
|
12 |
$input-border-dark: rgba(255, 255, 255, 0.4);
|
13 |
-
$input-disabled-dark: rgba(255, 255, 255, 0.3);
|
14 |
$controls-border-dark: rgba(255, 255, 255, 0.6);
|
15 |
$input-text-active: #2b2d2f;
|
16 |
$input-placeholder-dark: rgba(255, 255, 255, 0.6);
|
2 |
@import "node_modules/@automattic/color-studio/dist/color-variables";
|
3 |
|
4 |
// Bright colors
|
|
|
|
|
|
|
5 |
$discount-color: $alert-green;
|
6 |
|
|
|
7 |
$input-border-gray: #50575e;
|
8 |
$input-border-dark: rgba(255, 255, 255, 0.4);
|
|
|
9 |
$controls-border-dark: rgba(255, 255, 255, 0.6);
|
10 |
$input-text-active: #2b2d2f;
|
11 |
$input-placeholder-dark: rgba(255, 255, 255, 0.6);
|
assets/css/abstracts/_mixins.scss
CHANGED
@@ -192,7 +192,7 @@ $fontSizes: (
|
|
192 |
}
|
193 |
|
194 |
// Add support for content alignment classes
|
195 |
-
@mixin with-alignment {
|
196 |
// Apply max-width to floated items that have no intrinsic width
|
197 |
&.alignleft,
|
198 |
&.alignright {
|
192 |
}
|
193 |
|
194 |
// Add support for content alignment classes
|
195 |
+
@mixin with-alignment() {
|
196 |
// Apply max-width to floated items that have no intrinsic width
|
197 |
&.alignleft,
|
198 |
&.alignright {
|
assets/css/abstracts/_variables.scss
CHANGED
@@ -7,6 +7,3 @@ $gap: $grid-unit-20;
|
|
7 |
$gap-small: $grid-unit-15;
|
8 |
$gap-smaller: $grid-unit-10;
|
9 |
$gap-smallest: $grid-unit-05;
|
10 |
-
|
11 |
-
// Cart block
|
12 |
-
$cart-image-width: 5rem;
|
7 |
$gap-small: $grid-unit-15;
|
8 |
$gap-smaller: $grid-unit-10;
|
9 |
$gap-smallest: $grid-unit-05;
|
|
|
|
|
|
assets/css/editor.scss
CHANGED
@@ -1,15 +1,3 @@
|
|
1 |
-
// Hack to hide preview overflow.
|
2 |
-
.editor-block-preview__content {
|
3 |
-
overflow: hidden;
|
4 |
-
}
|
5 |
-
|
6 |
-
// Align the block icons in edit mode
|
7 |
-
.components-placeholder__label .gridicon,
|
8 |
-
.components-placeholder__label .material-icon {
|
9 |
-
margin-right: 1ch;
|
10 |
-
fill: currentColor;
|
11 |
-
}
|
12 |
-
|
13 |
// Remove the list styling, which is added back by core GB styles.
|
14 |
.editor-styles-wrapper {
|
15 |
.wc-block-grid {
|
@@ -61,19 +49,6 @@ svg.wc-block-editor-components-block-icon--sparkles path {
|
|
61 |
}
|
62 |
}
|
63 |
|
64 |
-
// Selectors with extra specificity to override some editor styles.
|
65 |
-
.woocommerce-search-list__list.woocommerce-search-list__list {
|
66 |
-
box-sizing: border-box;
|
67 |
-
margin: 0;
|
68 |
-
padding: 0;
|
69 |
-
}
|
70 |
-
|
71 |
-
.woocommerce-search-list__selected.woocommerce-search-list__selected > ul {
|
72 |
-
list-style: none;
|
73 |
-
margin: 0;
|
74 |
-
padding: 0;
|
75 |
-
}
|
76 |
-
|
77 |
.theme-twentytwenty {
|
78 |
.wp-block {
|
79 |
.wc-block-grid__product-title,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
// Remove the list styling, which is added back by core GB styles.
|
2 |
.editor-styles-wrapper {
|
3 |
.wc-block-grid {
|
49 |
}
|
50 |
}
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
.theme-twentytwenty {
|
53 |
.wp-block {
|
54 |
.wc-block-grid__product-title,
|
assets/css/style.scss
CHANGED
@@ -1,12 +1,3 @@
|
|
1 |
-
.wc-block-link-button {
|
2 |
-
@include link-button();
|
3 |
-
}
|
4 |
-
|
5 |
-
.wc-block-suspense-placeholder {
|
6 |
-
@include placeholder();
|
7 |
-
@include force-content();
|
8 |
-
}
|
9 |
-
|
10 |
// These styles are for the server side rendered product grid blocks.
|
11 |
.wc-block-grid__products .wc-block-grid__product-image {
|
12 |
text-decoration: none;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
// These styles are for the server side rendered product grid blocks.
|
2 |
.wc-block-grid__products .wc-block-grid__product-image {
|
3 |
text-decoration: none;
|
assets/js/atomic/blocks/product-elements/button/attributes.js
CHANGED
@@ -7,6 +7,10 @@ export const blockAttributes = {
|
|
7 |
type: 'boolean',
|
8 |
default: false,
|
9 |
},
|
|
|
|
|
|
|
|
|
10 |
};
|
11 |
|
12 |
export default blockAttributes;
|
7 |
type: 'boolean',
|
8 |
default: false,
|
9 |
},
|
10 |
+
textAlign: {
|
11 |
+
type: 'string',
|
12 |
+
default: '',
|
13 |
+
},
|
14 |
};
|
15 |
|
16 |
export default blockAttributes;
|
assets/js/atomic/blocks/product-elements/button/block.js
CHANGED
@@ -33,17 +33,18 @@ import './style.scss';
|
|
33 |
*
|
34 |
* @param {Object} props Incoming props.
|
35 |
* @param {string} [props.className] CSS Class name for the component.
|
|
|
36 |
* @return {*} The component.
|
37 |
*/
|
38 |
export const Block = ( props ) => {
|
39 |
const { className } = props;
|
40 |
-
|
41 |
const { parentClassName } = useInnerBlockLayoutContext();
|
42 |
const { product } = useProductDataContext();
|
43 |
const colorProps = useColorProps( props );
|
44 |
const borderProps = useBorderProps( props );
|
45 |
const typographyProps = useTypographyProps( props );
|
46 |
const spacingProps = useSpacingProps( props );
|
|
|
47 |
|
48 |
return (
|
49 |
<div
|
@@ -54,6 +55,9 @@ export const Block = ( props ) => {
|
|
54 |
{
|
55 |
[ `${ parentClassName }__product-add-to-cart` ]:
|
56 |
parentClassName,
|
|
|
|
|
|
|
57 |
}
|
58 |
) }
|
59 |
>
|
@@ -86,6 +90,7 @@ export const Block = ( props ) => {
|
|
86 |
* @param {Object} [props.borderStyles] Object contains CSS class and CSS style for border.
|
87 |
* @param {Object} [props.typographyStyles] Object contains CSS class and CSS style for typography.
|
88 |
* @param {Object} [props.spacingStyles] Object contains CSS style for spacing.
|
|
|
89 |
*
|
90 |
* @return {*} The component.
|
91 |
*/
|
@@ -95,6 +100,7 @@ const AddToCartButton = ( {
|
|
95 |
borderStyles,
|
96 |
typographyStyles,
|
97 |
spacingStyles,
|
|
|
98 |
} ) => {
|
99 |
const {
|
100 |
id,
|
@@ -170,6 +176,9 @@ const AddToCartButton = ( {
|
|
170 |
{
|
171 |
loading: addingToCart,
|
172 |
added: addedToCart,
|
|
|
|
|
|
|
173 |
}
|
174 |
) }
|
175 |
style={ {
|
33 |
*
|
34 |
* @param {Object} props Incoming props.
|
35 |
* @param {string} [props.className] CSS Class name for the component.
|
36 |
+
* @param {string} [props.textAlign] Text alignment.
|
37 |
* @return {*} The component.
|
38 |
*/
|
39 |
export const Block = ( props ) => {
|
40 |
const { className } = props;
|
|
|
41 |
const { parentClassName } = useInnerBlockLayoutContext();
|
42 |
const { product } = useProductDataContext();
|
43 |
const colorProps = useColorProps( props );
|
44 |
const borderProps = useBorderProps( props );
|
45 |
const typographyProps = useTypographyProps( props );
|
46 |
const spacingProps = useSpacingProps( props );
|
47 |
+
const { textAlign } = props;
|
48 |
|
49 |
return (
|
50 |
<div
|
55 |
{
|
56 |
[ `${ parentClassName }__product-add-to-cart` ]:
|
57 |
parentClassName,
|
58 |
+
},
|
59 |
+
{
|
60 |
+
[ `has-text-align-${ textAlign }` ]: textAlign,
|
61 |
}
|
62 |
) }
|
63 |
>
|
90 |
* @param {Object} [props.borderStyles] Object contains CSS class and CSS style for border.
|
91 |
* @param {Object} [props.typographyStyles] Object contains CSS class and CSS style for typography.
|
92 |
* @param {Object} [props.spacingStyles] Object contains CSS style for spacing.
|
93 |
+
* @param {Object} [props.textAlign] Text alignment.
|
94 |
*
|
95 |
* @return {*} The component.
|
96 |
*/
|
100 |
borderStyles,
|
101 |
typographyStyles,
|
102 |
spacingStyles,
|
103 |
+
textAlign,
|
104 |
} ) => {
|
105 |
const {
|
106 |
id,
|
176 |
{
|
177 |
loading: addingToCart,
|
178 |
added: addedToCart,
|
179 |
+
},
|
180 |
+
{
|
181 |
+
[ `has-text-align-${ textAlign }` ]: textAlign,
|
182 |
}
|
183 |
) }
|
184 |
style={ {
|
assets/js/atomic/blocks/product-elements/button/edit.js
CHANGED
@@ -2,7 +2,11 @@
|
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { Disabled } from '@wordpress/components';
|
5 |
-
import {
|
|
|
|
|
|
|
|
|
6 |
import { useEffect } from '@wordpress/element';
|
7 |
|
8 |
/**
|
@@ -19,11 +23,23 @@ const Edit = ( { attributes, setAttributes, context } ) => {
|
|
19 |
[ setAttributes, isDescendentOfQueryLoop ]
|
20 |
);
|
21 |
return (
|
22 |
-
|
23 |
-
<
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
);
|
28 |
};
|
29 |
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { Disabled } from '@wordpress/components';
|
5 |
+
import {
|
6 |
+
AlignmentToolbar,
|
7 |
+
BlockControls,
|
8 |
+
useBlockProps,
|
9 |
+
} from '@wordpress/block-editor';
|
10 |
import { useEffect } from '@wordpress/element';
|
11 |
|
12 |
/**
|
23 |
[ setAttributes, isDescendentOfQueryLoop ]
|
24 |
);
|
25 |
return (
|
26 |
+
<>
|
27 |
+
<BlockControls>
|
28 |
+
{ isDescendentOfQueryLoop && (
|
29 |
+
<AlignmentToolbar
|
30 |
+
value={ attributes.textAlign }
|
31 |
+
onChange={ ( newAlign ) => {
|
32 |
+
setAttributes( { textAlign: newAlign || '' } );
|
33 |
+
} }
|
34 |
+
/>
|
35 |
+
) }
|
36 |
+
</BlockControls>
|
37 |
+
<div { ...blockProps }>
|
38 |
+
<Disabled>
|
39 |
+
<Block { ...{ ...attributes, ...context } } />
|
40 |
+
</Disabled>
|
41 |
+
</div>
|
42 |
+
</>
|
43 |
);
|
44 |
};
|
45 |
|
assets/js/atomic/blocks/product-elements/button/style.scss
CHANGED
@@ -37,6 +37,3 @@
|
|
37 |
}
|
38 |
}
|
39 |
|
40 |
-
.wp-block-button.wc-block-components-product-button[data-is-descendent-of-query-loop="true"] {
|
41 |
-
text-align: center;
|
42 |
-
}
|
37 |
}
|
38 |
}
|
39 |
|
|
|
|
|
|
assets/js/atomic/blocks/product-elements/price/attributes.js
CHANGED
@@ -1,9 +1,8 @@
|
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
-
import { isFeaturePluginBuild } from '@woocommerce/block-settings';
|
5 |
|
6 |
-
|
7 |
productId: {
|
8 |
type: 'number',
|
9 |
default: 0,
|
@@ -12,14 +11,9 @@ let blockAttributes = {
|
|
12 |
type: 'boolean',
|
13 |
default: false,
|
14 |
},
|
|
|
|
|
|
|
15 |
};
|
16 |
|
17 |
-
if ( isFeaturePluginBuild() ) {
|
18 |
-
blockAttributes = {
|
19 |
-
...blockAttributes,
|
20 |
-
textAlign: {
|
21 |
-
type: 'string',
|
22 |
-
},
|
23 |
-
};
|
24 |
-
}
|
25 |
export default blockAttributes;
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
|
|
4 |
|
5 |
+
export const blockAttributes = {
|
6 |
productId: {
|
7 |
type: 'number',
|
8 |
default: 0,
|
11 |
type: 'boolean',
|
12 |
default: false,
|
13 |
},
|
14 |
+
textAlign: {
|
15 |
+
type: 'string',
|
16 |
+
},
|
17 |
};
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
export default blockAttributes;
|
assets/js/atomic/blocks/product-elements/price/block.js
CHANGED
@@ -15,6 +15,7 @@ import { withProductDataContext } from '@woocommerce/shared-hocs';
|
|
15 |
/**
|
16 |
* Internal dependencies
|
17 |
*/
|
|
|
18 |
|
19 |
/**
|
20 |
* Product Price Block Component.
|
15 |
/**
|
16 |
* Internal dependencies
|
17 |
*/
|
18 |
+
import './style.scss';
|
19 |
|
20 |
/**
|
21 |
* Product Price Block Component.
|
assets/js/atomic/blocks/product-elements/price/edit.js
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
-
import { isFeaturePluginBuild } from '@woocommerce/block-settings';
|
5 |
import {
|
6 |
AlignmentToolbar,
|
7 |
BlockControls,
|
@@ -33,7 +32,7 @@ const PriceEdit = ( { attributes, setAttributes, context } ) => {
|
|
33 |
return (
|
34 |
<>
|
35 |
<BlockControls>
|
36 |
-
{
|
37 |
<AlignmentToolbar
|
38 |
value={ attributes.textAlign }
|
39 |
onChange={ ( newAlign ) => {
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
|
|
4 |
import {
|
5 |
AlignmentToolbar,
|
6 |
BlockControls,
|
32 |
return (
|
33 |
<>
|
34 |
<BlockControls>
|
35 |
+
{ isDescendentOfQueryLoop && (
|
36 |
<AlignmentToolbar
|
37 |
value={ attributes.textAlign }
|
38 |
onChange={ ( newAlign ) => {
|
assets/js/atomic/blocks/product-elements/price/style.scss
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
.wc-block-components-product-price {
|
2 |
+
margin-bottom: $gap-small;
|
3 |
+
}
|
assets/js/atomic/blocks/product-elements/rating/attributes.ts
CHANGED
@@ -7,6 +7,10 @@ export const blockAttributes = {
|
|
7 |
type: 'boolean',
|
8 |
default: false,
|
9 |
},
|
|
|
|
|
|
|
|
|
10 |
};
|
11 |
|
12 |
export default blockAttributes;
|
7 |
type: 'boolean',
|
8 |
default: false,
|
9 |
},
|
10 |
+
textAlign: {
|
11 |
+
type: 'string',
|
12 |
+
default: '',
|
13 |
+
},
|
14 |
};
|
15 |
|
16 |
export default blockAttributes;
|
assets/js/atomic/blocks/product-elements/rating/block.tsx
CHANGED
@@ -21,6 +21,7 @@ import { isNumber, ProductResponseItem } from '@woocommerce/types';
|
|
21 |
import './style.scss';
|
22 |
|
23 |
type Props = {
|
|
|
24 |
className?: string;
|
25 |
};
|
26 |
|
@@ -47,9 +48,12 @@ const getRatingCount = ( product: ProductResponseItem ) => {
|
|
47 |
*
|
48 |
* @param {Object} props Incoming props.
|
49 |
* @param {string} [props.className] CSS Class name for the component.
|
|
|
|
|
50 |
* @return {*} The component.
|
51 |
*/
|
52 |
export const Block = ( props: Props ): JSX.Element | null => {
|
|
|
53 |
const { parentClassName } = useInnerBlockLayoutContext();
|
54 |
const { product } = useProductDataContext();
|
55 |
const rating = getAverageRating( product );
|
@@ -93,6 +97,9 @@ export const Block = ( props: Props ): JSX.Element | null => {
|
|
93 |
'wc-block-components-product-rating',
|
94 |
{
|
95 |
[ `${ parentClassName }__product-rating` ]: parentClassName,
|
|
|
|
|
|
|
96 |
}
|
97 |
) }
|
98 |
style={ {
|
21 |
import './style.scss';
|
22 |
|
23 |
type Props = {
|
24 |
+
textAlign?: string;
|
25 |
className?: string;
|
26 |
};
|
27 |
|
48 |
*
|
49 |
* @param {Object} props Incoming props.
|
50 |
* @param {string} [props.className] CSS Class name for the component.
|
51 |
+
* @param {string} [props.textAlign] Text alignment.
|
52 |
+
*
|
53 |
* @return {*} The component.
|
54 |
*/
|
55 |
export const Block = ( props: Props ): JSX.Element | null => {
|
56 |
+
const { textAlign } = props;
|
57 |
const { parentClassName } = useInnerBlockLayoutContext();
|
58 |
const { product } = useProductDataContext();
|
59 |
const rating = getAverageRating( product );
|
97 |
'wc-block-components-product-rating',
|
98 |
{
|
99 |
[ `${ parentClassName }__product-rating` ]: parentClassName,
|
100 |
+
},
|
101 |
+
{
|
102 |
+
[ `has-text-align-${ textAlign }` ]: textAlign,
|
103 |
}
|
104 |
) }
|
105 |
style={ {
|
assets/js/atomic/blocks/product-elements/rating/edit.tsx
CHANGED
@@ -2,7 +2,11 @@
|
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { __ } from '@wordpress/i18n';
|
5 |
-
import {
|
|
|
|
|
|
|
|
|
6 |
import type { BlockEditProps } from '@wordpress/blocks';
|
7 |
import { useEffect } from 'react';
|
8 |
import { ProductQueryContext as Context } from '@woocommerce/blocks/product-query/types';
|
@@ -35,9 +39,21 @@ const Edit = ( {
|
|
35 |
);
|
36 |
|
37 |
return (
|
38 |
-
|
39 |
-
<
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
);
|
42 |
};
|
43 |
export default withProductSelector( {
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { __ } from '@wordpress/i18n';
|
5 |
+
import {
|
6 |
+
AlignmentToolbar,
|
7 |
+
BlockControls,
|
8 |
+
useBlockProps,
|
9 |
+
} from '@wordpress/block-editor';
|
10 |
import type { BlockEditProps } from '@wordpress/blocks';
|
11 |
import { useEffect } from 'react';
|
12 |
import { ProductQueryContext as Context } from '@woocommerce/blocks/product-query/types';
|
39 |
);
|
40 |
|
41 |
return (
|
42 |
+
<>
|
43 |
+
<BlockControls>
|
44 |
+
{ isDescendentOfQueryLoop && (
|
45 |
+
<AlignmentToolbar
|
46 |
+
value={ attributes.textAlign }
|
47 |
+
onChange={ ( newAlign ) => {
|
48 |
+
setAttributes( { textAlign: newAlign || '' } );
|
49 |
+
} }
|
50 |
+
/>
|
51 |
+
) }
|
52 |
+
</BlockControls>
|
53 |
+
<div { ...blockProps }>
|
54 |
+
<Block { ...blockAttrs } />
|
55 |
+
</div>
|
56 |
+
</>
|
57 |
);
|
58 |
};
|
59 |
export default withProductSelector( {
|
assets/js/atomic/blocks/product-elements/rating/types.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
export interface Attributes {
|
2 |
productId: number;
|
3 |
isDescendentOfQueryLoop: boolean;
|
|
|
4 |
}
|
1 |
export interface Attributes {
|
2 |
productId: number;
|
3 |
isDescendentOfQueryLoop: boolean;
|
4 |
+
textAlign: string;
|
5 |
}
|
assets/js/atomic/blocks/product-elements/sale-badge/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/sale-badge/edit.tsx
CHANGED
@@ -2,6 +2,9 @@
|
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { useBlockProps } from '@wordpress/block-editor';
|
|
|
|
|
|
|
5 |
|
6 |
/**
|
7 |
* Internal dependencies
|
@@ -15,15 +18,27 @@ import {
|
|
15 |
} from './constants';
|
16 |
import type { BlockAttributes } from './types';
|
17 |
|
18 |
-
|
19 |
-
attributes
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
const blockProps = useBlockProps();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
return (
|
25 |
<div { ...blockProps }>
|
26 |
-
<Block { ...
|
27 |
</div>
|
28 |
);
|
29 |
};
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { useBlockProps } from '@wordpress/block-editor';
|
5 |
+
import type { BlockEditProps } from '@wordpress/blocks';
|
6 |
+
import { ProductQueryContext as Context } from '@woocommerce/blocks/product-query/types';
|
7 |
+
import { useEffect } from 'react';
|
8 |
|
9 |
/**
|
10 |
* Internal dependencies
|
18 |
} from './constants';
|
19 |
import type { BlockAttributes } from './types';
|
20 |
|
21 |
+
const Edit = ( {
|
22 |
+
attributes,
|
23 |
+
setAttributes,
|
24 |
+
context,
|
25 |
+
}: BlockEditProps< BlockAttributes > & { context: Context } ): JSX.Element => {
|
26 |
const blockProps = useBlockProps();
|
27 |
+
|
28 |
+
const blockAttrs = {
|
29 |
+
...attributes,
|
30 |
+
...context,
|
31 |
+
};
|
32 |
+
const isDescendentOfQueryLoop = Number.isFinite( context.queryId );
|
33 |
+
|
34 |
+
useEffect(
|
35 |
+
() => setAttributes( { isDescendentOfQueryLoop } ),
|
36 |
+
[ setAttributes, isDescendentOfQueryLoop ]
|
37 |
+
);
|
38 |
+
|
39 |
return (
|
40 |
<div { ...blockProps }>
|
41 |
+
<Block { ...blockAttrs } />
|
42 |
</div>
|
43 |
);
|
44 |
};
|
assets/js/atomic/blocks/product-elements/sale-badge/index.ts
CHANGED
@@ -15,7 +15,6 @@ import {
|
|
15 |
BLOCK_ICON as icon,
|
16 |
BLOCK_DESCRIPTION as description,
|
17 |
} from './constants';
|
18 |
-
import { Save } from './save';
|
19 |
import { supports } from './support';
|
20 |
|
21 |
const blockConfig: BlockConfiguration = {
|
@@ -27,7 +26,12 @@ const blockConfig: BlockConfiguration = {
|
|
27 |
supports,
|
28 |
attributes,
|
29 |
edit,
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
31 |
};
|
32 |
|
33 |
registerBlockType( 'woocommerce/product-sale-badge', { ...blockConfig } );
|
15 |
BLOCK_ICON as icon,
|
16 |
BLOCK_DESCRIPTION as description,
|
17 |
} from './constants';
|
|
|
18 |
import { supports } from './support';
|
19 |
|
20 |
const blockConfig: BlockConfiguration = {
|
26 |
supports,
|
27 |
attributes,
|
28 |
edit,
|
29 |
+
usesContext: [ 'query', 'queryId', 'postId' ],
|
30 |
+
ancestor: [
|
31 |
+
'@woocommerce/all-products',
|
32 |
+
'@woocommerce/single-product',
|
33 |
+
'core/post-template',
|
34 |
+
],
|
35 |
};
|
36 |
|
37 |
registerBlockType( 'woocommerce/product-sale-badge', { ...blockConfig } );
|
assets/js/atomic/blocks/product-elements/sale-badge/types.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
export interface BlockAttributes {
|
2 |
productId: number;
|
3 |
align: 'left' | 'center' | 'right';
|
|
|
4 |
}
|
1 |
export interface BlockAttributes {
|
2 |
productId: number;
|
3 |
align: 'left' | 'center' | 'right';
|
4 |
+
isDescendentOfQueryLoop: boolean;
|
5 |
}
|
assets/js/atomic/blocks/product-elements/sku/index.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
-
import {
|
5 |
import type { BlockConfiguration } from '@wordpress/blocks';
|
6 |
|
7 |
/**
|
@@ -31,7 +31,7 @@ const blockConfig: BlockConfiguration = {
|
|
31 |
edit,
|
32 |
};
|
33 |
|
34 |
-
|
35 |
...sharedConfig,
|
36 |
...blockConfig,
|
37 |
} );
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
+
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
5 |
import type { BlockConfiguration } from '@wordpress/blocks';
|
6 |
|
7 |
/**
|
31 |
edit,
|
32 |
};
|
33 |
|
34 |
+
registerFeaturePluginBlockType( 'woocommerce/product-sku', {
|
35 |
...sharedConfig,
|
36 |
...blockConfig,
|
37 |
} );
|
assets/js/atomic/blocks/product-elements/stock-indicator/attributes.ts
CHANGED
@@ -1,15 +1,23 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
};
|
6 |
-
}
|
7 |
|
8 |
-
export const blockAttributes:
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
productId: {
|
10 |
type: 'number',
|
11 |
default: 0,
|
12 |
},
|
|
|
|
|
|
|
|
|
13 |
};
|
14 |
|
15 |
export default blockAttributes;
|
1 |
+
/**
|
2 |
+
* Internal dependencies
|
3 |
+
*/
|
4 |
+
import { BlockAttributes } from './types';
|
|
|
|
|
5 |
|
6 |
+
export const blockAttributes: Record<
|
7 |
+
keyof BlockAttributes,
|
8 |
+
{
|
9 |
+
type: string;
|
10 |
+
default: unknown;
|
11 |
+
}
|
12 |
+
> = {
|
13 |
productId: {
|
14 |
type: 'number',
|
15 |
default: 0,
|
16 |
},
|
17 |
+
isDescendentOfQueryLoop: {
|
18 |
+
type: 'boolean',
|
19 |
+
default: false,
|
20 |
+
},
|
21 |
};
|
22 |
|
23 |
export default blockAttributes;
|
assets/js/atomic/blocks/product-elements/stock-indicator/edit.tsx
CHANGED
@@ -3,6 +3,9 @@
|
|
3 |
*/
|
4 |
import EditProductLink from '@woocommerce/editor-components/edit-product-link';
|
5 |
import { useBlockProps } from '@wordpress/block-editor';
|
|
|
|
|
|
|
6 |
|
7 |
/**
|
8 |
* Internal dependencies
|
@@ -16,16 +19,28 @@ import {
|
|
16 |
} from './constants';
|
17 |
import type { BlockAttributes } from './types';
|
18 |
|
19 |
-
|
20 |
-
attributes
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
const blockProps = useBlockProps();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
return (
|
26 |
<div { ...blockProps }>
|
27 |
<EditProductLink />
|
28 |
-
<Block { ...
|
29 |
</div>
|
30 |
);
|
31 |
};
|
3 |
*/
|
4 |
import EditProductLink from '@woocommerce/editor-components/edit-product-link';
|
5 |
import { useBlockProps } from '@wordpress/block-editor';
|
6 |
+
import type { BlockEditProps } from '@wordpress/blocks';
|
7 |
+
import { ProductQueryContext as Context } from '@woocommerce/blocks/product-query/types';
|
8 |
+
import { useEffect } from 'react';
|
9 |
|
10 |
/**
|
11 |
* Internal dependencies
|
19 |
} from './constants';
|
20 |
import type { BlockAttributes } from './types';
|
21 |
|
22 |
+
const Edit = ( {
|
23 |
+
attributes,
|
24 |
+
setAttributes,
|
25 |
+
context,
|
26 |
+
}: BlockEditProps< BlockAttributes > & { context: Context } ): JSX.Element => {
|
27 |
const blockProps = useBlockProps();
|
28 |
+
|
29 |
+
const blockAttrs = {
|
30 |
+
...attributes,
|
31 |
+
...context,
|
32 |
+
};
|
33 |
+
const isDescendentOfQueryLoop = Number.isFinite( context.queryId );
|
34 |
+
|
35 |
+
useEffect(
|
36 |
+
() => setAttributes( { isDescendentOfQueryLoop } ),
|
37 |
+
[ setAttributes, isDescendentOfQueryLoop ]
|
38 |
+
);
|
39 |
+
|
40 |
return (
|
41 |
<div { ...blockProps }>
|
42 |
<EditProductLink />
|
43 |
+
<Block { ...blockAttrs } />
|
44 |
</div>
|
45 |
);
|
46 |
};
|
assets/js/atomic/blocks/product-elements/stock-indicator/index.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
-
import {
|
5 |
import type { BlockConfiguration } from '@wordpress/blocks';
|
6 |
|
7 |
/**
|
@@ -10,7 +10,6 @@ import type { BlockConfiguration } from '@wordpress/blocks';
|
|
10 |
import sharedConfig from '../shared/config';
|
11 |
import attributes from './attributes';
|
12 |
import edit from './edit';
|
13 |
-
import { Save } from './save';
|
14 |
import { supports } from './supports';
|
15 |
|
16 |
import {
|
@@ -28,9 +27,14 @@ const blockConfig: BlockConfiguration = {
|
|
28 |
attributes,
|
29 |
supports,
|
30 |
edit,
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
32 |
};
|
33 |
|
34 |
-
|
35 |
...blockConfig,
|
36 |
} );
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
+
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
5 |
import type { BlockConfiguration } from '@wordpress/blocks';
|
6 |
|
7 |
/**
|
10 |
import sharedConfig from '../shared/config';
|
11 |
import attributes from './attributes';
|
12 |
import edit from './edit';
|
|
|
13 |
import { supports } from './supports';
|
14 |
|
15 |
import {
|
27 |
attributes,
|
28 |
supports,
|
29 |
edit,
|
30 |
+
usesContext: [ 'query', 'queryId', 'postId' ],
|
31 |
+
ancestor: [
|
32 |
+
'@woocommerce/all-products',
|
33 |
+
'@woocommerce/single-product',
|
34 |
+
'core/post-template',
|
35 |
+
],
|
36 |
};
|
37 |
|
38 |
+
registerFeaturePluginBlockType( 'woocommerce/product-stock-indicator', {
|
39 |
...blockConfig,
|
40 |
} );
|
assets/js/atomic/blocks/product-elements/stock-indicator/types.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
export interface BlockAttributes {
|
2 |
productId: number;
|
|
|
3 |
}
|
1 |
export interface BlockAttributes {
|
2 |
productId: number;
|
3 |
+
isDescendentOfQueryLoop: boolean;
|
4 |
}
|
assets/js/base/components/cart-checkout/totals/footer-item/index.tsx
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
-
import { __ } from '@wordpress/i18n';
|
5 |
import classNames from 'classnames';
|
6 |
import { createInterpolateElement } from '@wordpress/element';
|
7 |
import FormattedMonetaryAmount from '@woocommerce/base-components/formatted-monetary-amount';
|
@@ -13,6 +13,7 @@ import { useStoreCart } from '@woocommerce/base-context/hooks';
|
|
13 |
import { getSetting } from '@woocommerce/settings';
|
14 |
import { CartResponseTotals, Currency } from '@woocommerce/types';
|
15 |
import { LooselyMustHave } from '@woocommerce/type-defs/utils';
|
|
|
16 |
|
17 |
/**
|
18 |
* Internal dependencies
|
@@ -50,7 +51,11 @@ const TotalsFooterItem = ( {
|
|
50 |
getSetting< boolean >( 'taxesEnabled', true ) &&
|
51 |
getSetting< boolean >( 'displayCartPricesIncludingTax', false );
|
52 |
|
53 |
-
const {
|
|
|
|
|
|
|
|
|
54 |
|
55 |
// Prepare props to pass to the __experimentalApplyCheckoutFilter filter.
|
56 |
// We need to pluck out receiveCart.
|
@@ -64,6 +69,24 @@ const TotalsFooterItem = ( {
|
|
64 |
} );
|
65 |
|
66 |
const parsedTaxValue = parseInt( totalTax, 10 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
return (
|
69 |
<TotalsItem
|
@@ -78,21 +101,15 @@ const TotalsFooterItem = ( {
|
|
78 |
SHOW_TAXES &&
|
79 |
parsedTaxValue !== 0 && (
|
80 |
<p className="wc-block-components-totals-footer-item-tax">
|
81 |
-
{ createInterpolateElement(
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
85 |
),
|
86 |
-
|
87 |
-
TaxAmount: (
|
88 |
-
<FormattedMonetaryAmount
|
89 |
-
className="wc-block-components-totals-footer-item-tax-value"
|
90 |
-
currency={ currency }
|
91 |
-
value={ parsedTaxValue }
|
92 |
-
/>
|
93 |
-
),
|
94 |
-
}
|
95 |
-
) }
|
96 |
</p>
|
97 |
)
|
98 |
}
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
+
import { __, sprintf } from '@wordpress/i18n';
|
5 |
import classNames from 'classnames';
|
6 |
import { createInterpolateElement } from '@wordpress/element';
|
7 |
import FormattedMonetaryAmount from '@woocommerce/base-components/formatted-monetary-amount';
|
13 |
import { getSetting } from '@woocommerce/settings';
|
14 |
import { CartResponseTotals, Currency } from '@woocommerce/types';
|
15 |
import { LooselyMustHave } from '@woocommerce/type-defs/utils';
|
16 |
+
import { formatPrice } from '@woocommerce/price-format';
|
17 |
|
18 |
/**
|
19 |
* Internal dependencies
|
51 |
getSetting< boolean >( 'taxesEnabled', true ) &&
|
52 |
getSetting< boolean >( 'displayCartPricesIncludingTax', false );
|
53 |
|
54 |
+
const {
|
55 |
+
total_price: totalPrice,
|
56 |
+
total_tax: totalTax,
|
57 |
+
tax_lines: taxLines,
|
58 |
+
} = values;
|
59 |
|
60 |
// Prepare props to pass to the __experimentalApplyCheckoutFilter filter.
|
61 |
// We need to pluck out receiveCart.
|
69 |
} );
|
70 |
|
71 |
const parsedTaxValue = parseInt( totalTax, 10 );
|
72 |
+
const description =
|
73 |
+
taxLines && taxLines.length > 0
|
74 |
+
? sprintf(
|
75 |
+
/* translators: %s is a list of tax rates */
|
76 |
+
__( 'Including %s', 'woo-gutenberg-products-block' ),
|
77 |
+
taxLines
|
78 |
+
.map( ( { name, price } ) => {
|
79 |
+
return `${ formatPrice(
|
80 |
+
price,
|
81 |
+
currency
|
82 |
+
) } ${ name }`;
|
83 |
+
} )
|
84 |
+
.join( ', ' )
|
85 |
+
)
|
86 |
+
: __(
|
87 |
+
'Including <TaxAmount/> in taxes',
|
88 |
+
'woo-gutenberg-products-block'
|
89 |
+
);
|
90 |
|
91 |
return (
|
92 |
<TotalsItem
|
101 |
SHOW_TAXES &&
|
102 |
parsedTaxValue !== 0 && (
|
103 |
<p className="wc-block-components-totals-footer-item-tax">
|
104 |
+
{ createInterpolateElement( description, {
|
105 |
+
TaxAmount: (
|
106 |
+
<FormattedMonetaryAmount
|
107 |
+
className="wc-block-components-totals-footer-item-tax-value"
|
108 |
+
currency={ currency }
|
109 |
+
value={ parsedTaxValue }
|
110 |
+
/>
|
111 |
),
|
112 |
+
} ) }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
</p>
|
114 |
)
|
115 |
}
|
assets/js/base/components/cart-checkout/totals/footer-item/stories/index.tsx
CHANGED
@@ -42,8 +42,43 @@ Default.decorators = [
|
|
42 |
},
|
43 |
];
|
44 |
|
45 |
-
export const
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
( StoryComponent ) => {
|
48 |
allSettings.displayCartPricesIncludingTax = true;
|
49 |
|
42 |
},
|
43 |
];
|
44 |
|
45 |
+
export const NoTaxLabel = Template.bind( {} );
|
46 |
+
NoTaxLabel.decorators = [
|
47 |
+
( StoryComponent ) => {
|
48 |
+
allSettings.displayCartPricesIncludingTax = true;
|
49 |
+
|
50 |
+
return <StoryComponent />;
|
51 |
+
},
|
52 |
+
];
|
53 |
+
|
54 |
+
export const SingleTaxLabel = Template.bind( {} );
|
55 |
+
SingleTaxLabel.args = {
|
56 |
+
values: {
|
57 |
+
total_price: '2500',
|
58 |
+
total_tax: '550',
|
59 |
+
tax_lines: [ { name: '10% VAT', price: '550', rate: '10.00' } ],
|
60 |
+
},
|
61 |
+
};
|
62 |
+
SingleTaxLabel.decorators = [
|
63 |
+
( StoryComponent ) => {
|
64 |
+
allSettings.displayCartPricesIncludingTax = true;
|
65 |
+
|
66 |
+
return <StoryComponent />;
|
67 |
+
},
|
68 |
+
];
|
69 |
+
|
70 |
+
export const MultipleTaxLabels = Template.bind( {} );
|
71 |
+
MultipleTaxLabels.args = {
|
72 |
+
values: {
|
73 |
+
total_price: '2500',
|
74 |
+
total_tax: '550',
|
75 |
+
tax_lines: [
|
76 |
+
{ name: '10% VAT', price: '300', rate: '10.00' },
|
77 |
+
{ name: '5% VAT', price: '250', rate: '5.00' },
|
78 |
+
],
|
79 |
+
},
|
80 |
+
};
|
81 |
+
MultipleTaxLabels.decorators = [
|
82 |
( StoryComponent ) => {
|
83 |
allSettings.displayCartPricesIncludingTax = true;
|
84 |
|
assets/js/base/components/cart-checkout/totals/footer-item/test/__snapshots__/index.tsx.snap
CHANGED
@@ -44,6 +44,62 @@ exports[`TotalsFooterItem Does not show the "including %s of tax" line if tax is
|
|
44 |
</div>
|
45 |
`;
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
exports[`TotalsFooterItem Shows the "including %s of tax" line if tax is greater than 0 1`] = `
|
48 |
<div>
|
49 |
<div
|
44 |
</div>
|
45 |
`;
|
46 |
|
47 |
+
exports[`TotalsFooterItem Shows the "including %s TAX LABEL" line with single tax label 1`] = `
|
48 |
+
<div>
|
49 |
+
<div
|
50 |
+
class="wc-block-components-totals-item wc-block-components-totals-footer-item"
|
51 |
+
>
|
52 |
+
<span
|
53 |
+
class="wc-block-components-totals-item__label"
|
54 |
+
>
|
55 |
+
Total
|
56 |
+
</span>
|
57 |
+
<span
|
58 |
+
class="wc-block-formatted-money-amount wc-block-components-formatted-money-amount wc-block-components-totals-item__value"
|
59 |
+
>
|
60 |
+
£85.00
|
61 |
+
</span>
|
62 |
+
<div
|
63 |
+
class="wc-block-components-totals-item__description"
|
64 |
+
>
|
65 |
+
<p
|
66 |
+
class="wc-block-components-totals-footer-item-tax"
|
67 |
+
>
|
68 |
+
Including £1.00 10% VAT
|
69 |
+
</p>
|
70 |
+
</div>
|
71 |
+
</div>
|
72 |
+
</div>
|
73 |
+
`;
|
74 |
+
|
75 |
+
exports[`TotalsFooterItem Shows the "including %s TAX LABELS" line with multiple tax labels 1`] = `
|
76 |
+
<div>
|
77 |
+
<div
|
78 |
+
class="wc-block-components-totals-item wc-block-components-totals-footer-item"
|
79 |
+
>
|
80 |
+
<span
|
81 |
+
class="wc-block-components-totals-item__label"
|
82 |
+
>
|
83 |
+
Total
|
84 |
+
</span>
|
85 |
+
<span
|
86 |
+
class="wc-block-formatted-money-amount wc-block-components-formatted-money-amount wc-block-components-totals-item__value"
|
87 |
+
>
|
88 |
+
£85.00
|
89 |
+
</span>
|
90 |
+
<div
|
91 |
+
class="wc-block-components-totals-item__description"
|
92 |
+
>
|
93 |
+
<p
|
94 |
+
class="wc-block-components-totals-footer-item-tax"
|
95 |
+
>
|
96 |
+
Including £0.50 10% VAT, £0.50 5% VAT
|
97 |
+
</p>
|
98 |
+
</div>
|
99 |
+
</div>
|
100 |
+
</div>
|
101 |
+
`;
|
102 |
+
|
103 |
exports[`TotalsFooterItem Shows the "including %s of tax" line if tax is greater than 0 1`] = `
|
104 |
<div>
|
105 |
<div
|
assets/js/base/components/cart-checkout/totals/footer-item/test/index.tsx
CHANGED
@@ -3,6 +3,8 @@
|
|
3 |
*/
|
4 |
import { render } from '@testing-library/react';
|
5 |
import { allSettings } from '@woocommerce/settings';
|
|
|
|
|
6 |
|
7 |
/**
|
8 |
* Internal dependencies
|
@@ -14,7 +16,7 @@ describe( 'TotalsFooterItem', () => {
|
|
14 |
allSettings.taxesEnabled = true;
|
15 |
allSettings.displayCartPricesIncludingTax = true;
|
16 |
} );
|
17 |
-
const currency = {
|
18 |
code: 'GBP',
|
19 |
decimalSeparator: '.',
|
20 |
minorUnit: 2,
|
@@ -24,7 +26,7 @@ describe( 'TotalsFooterItem', () => {
|
|
24 |
thousandSeparator: ',',
|
25 |
};
|
26 |
|
27 |
-
const values = {
|
28 |
currency_code: 'GBP',
|
29 |
currency_decimal_separator: '.',
|
30 |
currency_minor_unit: 2,
|
@@ -33,7 +35,6 @@ describe( 'TotalsFooterItem', () => {
|
|
33 |
currency_symbol: '£',
|
34 |
currency_thousand_separator: ',',
|
35 |
tax_lines: [],
|
36 |
-
length: 2,
|
37 |
total_discount: '0',
|
38 |
total_discount_tax: '0',
|
39 |
total_fees: '0',
|
@@ -78,4 +79,33 @@ describe( 'TotalsFooterItem', () => {
|
|
78 |
);
|
79 |
expect( container ).toMatchSnapshot();
|
80 |
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
} );
|
3 |
*/
|
4 |
import { render } from '@testing-library/react';
|
5 |
import { allSettings } from '@woocommerce/settings';
|
6 |
+
import { Currency } from '@woocommerce/types';
|
7 |
+
import { CartResponseTotals } from '@woocommerce/type-defs/cart-response';
|
8 |
|
9 |
/**
|
10 |
* Internal dependencies
|
16 |
allSettings.taxesEnabled = true;
|
17 |
allSettings.displayCartPricesIncludingTax = true;
|
18 |
} );
|
19 |
+
const currency: Currency = {
|
20 |
code: 'GBP',
|
21 |
decimalSeparator: '.',
|
22 |
minorUnit: 2,
|
26 |
thousandSeparator: ',',
|
27 |
};
|
28 |
|
29 |
+
const values: CartResponseTotals = {
|
30 |
currency_code: 'GBP',
|
31 |
currency_decimal_separator: '.',
|
32 |
currency_minor_unit: 2,
|
35 |
currency_symbol: '£',
|
36 |
currency_thousand_separator: ',',
|
37 |
tax_lines: [],
|
|
|
38 |
total_discount: '0',
|
39 |
total_discount_tax: '0',
|
40 |
total_fees: '0',
|
79 |
);
|
80 |
expect( container ).toMatchSnapshot();
|
81 |
} );
|
82 |
+
|
83 |
+
it( 'Shows the "including %s TAX LABEL" line with single tax label', () => {
|
84 |
+
const valuesWithTax = {
|
85 |
+
...values,
|
86 |
+
total_tax: '100',
|
87 |
+
total_items_tax: '100',
|
88 |
+
tax_lines: [ { name: '10% VAT', price: '100', rate: '10.000' } ],
|
89 |
+
};
|
90 |
+
const { container } = render(
|
91 |
+
<TotalsFooterItem currency={ currency } values={ valuesWithTax } />
|
92 |
+
);
|
93 |
+
expect( container ).toMatchSnapshot();
|
94 |
+
} );
|
95 |
+
|
96 |
+
it( 'Shows the "including %s TAX LABELS" line with multiple tax labels', () => {
|
97 |
+
const valuesWithTax = {
|
98 |
+
...values,
|
99 |
+
total_tax: '100',
|
100 |
+
total_items_tax: '100',
|
101 |
+
tax_lines: [
|
102 |
+
{ name: '10% VAT', price: '50', rate: '10.000' },
|
103 |
+
{ name: '5% VAT', price: '50', rate: '5.000' },
|
104 |
+
],
|
105 |
+
};
|
106 |
+
const { container } = render(
|
107 |
+
<TotalsFooterItem currency={ currency } values={ valuesWithTax } />
|
108 |
+
);
|
109 |
+
expect( container ).toMatchSnapshot();
|
110 |
+
} );
|
111 |
} );
|
assets/js/base/components/chip/style.scss
CHANGED
@@ -32,6 +32,7 @@
|
|
32 |
}
|
33 |
.wc-block-components-chip__text {
|
34 |
flex-grow: 1;
|
|
|
35 |
}
|
36 |
&.is-removable .wc-block-components-chip__text {
|
37 |
padding-right: 0.5em;
|
32 |
}
|
33 |
.wc-block-components-chip__text {
|
34 |
flex-grow: 1;
|
35 |
+
@include font-size(small);
|
36 |
}
|
37 |
&.is-removable .wc-block-components-chip__text {
|
38 |
padding-right: 0.5em;
|
assets/js/base/components/filter-reset-button/style.scss
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
.wc-block-components-filter-reset-button {
|
2 |
@include filter-link-button();
|
|
|
3 |
cursor: pointer;
|
4 |
|
5 |
&[disabled] {
|
1 |
.wc-block-components-filter-reset-button {
|
2 |
@include filter-link-button();
|
3 |
+
@include font-size(small);
|
4 |
cursor: pointer;
|
5 |
|
6 |
&[disabled] {
|
assets/js/base/components/price-slider/style.scss
CHANGED
@@ -128,6 +128,7 @@
|
|
128 |
max-width: 80px;
|
129 |
min-width: 0;
|
130 |
padding: $gap-smaller;
|
|
|
131 |
.wc-block-components-price-slider--is-input-inline & {
|
132 |
max-width: 60px;
|
133 |
}
|
@@ -144,6 +145,10 @@
|
|
144 |
display: flex;
|
145 |
justify-content: space-between;
|
146 |
margin: $gap-large 0;
|
|
|
|
|
|
|
|
|
147 |
}
|
148 |
|
149 |
.wc-block-components-price-slider__actions {
|
@@ -155,6 +160,7 @@
|
|
155 |
button[type="submit"]:not(.wp-block-search__button).wc-block-components-filter-submit-button {
|
156 |
margin-top: 0;
|
157 |
margin-left: 0;
|
|
|
158 |
}
|
159 |
}
|
160 |
|
128 |
max-width: 80px;
|
129 |
min-width: 0;
|
130 |
padding: $gap-smaller;
|
131 |
+
@include font-size(small);
|
132 |
.wc-block-components-price-slider--is-input-inline & {
|
133 |
max-width: 60px;
|
134 |
}
|
145 |
display: flex;
|
146 |
justify-content: space-between;
|
147 |
margin: $gap-large 0;
|
148 |
+
|
149 |
+
.wc-block-components-formatted-money-amount {
|
150 |
+
@include font-size(small);
|
151 |
+
}
|
152 |
}
|
153 |
|
154 |
.wc-block-components-price-slider__actions {
|
160 |
button[type="submit"]:not(.wp-block-search__button).wc-block-components-filter-submit-button {
|
161 |
margin-top: 0;
|
162 |
margin-left: 0;
|
163 |
+
@include font-size(small);
|
164 |
}
|
165 |
}
|
166 |
|
assets/js/base/context/hooks/payment-methods/use-payment-method-interface.ts
CHANGED
@@ -11,7 +11,11 @@ import deprecated from '@wordpress/deprecated';
|
|
11 |
import LoadingMask from '@woocommerce/base-components/loading-mask';
|
12 |
import type { PaymentMethodInterface } from '@woocommerce/types';
|
13 |
import { useSelect, useDispatch } from '@wordpress/data';
|
14 |
-
import {
|
|
|
|
|
|
|
|
|
15 |
import { ValidationInputError } from '@woocommerce/blocks-checkout';
|
16 |
|
17 |
/**
|
@@ -23,7 +27,6 @@ import { noticeContexts, responseTypes } from '../../event-emit';
|
|
23 |
import { useCheckoutEventsContext } from '../../providers/cart-checkout/checkout-events';
|
24 |
import { usePaymentEventsContext } from '../../providers/cart-checkout/payment-events';
|
25 |
import { useShippingDataContext } from '../../providers/cart-checkout/shipping';
|
26 |
-
import { useCustomerDataContext } from '../../providers/cart-checkout/customer';
|
27 |
import { prepareTotalItems } from './utils';
|
28 |
import { useShippingData } from '../shipping/use-shipping-data';
|
29 |
|
@@ -92,8 +95,11 @@ export const usePaymentMethodInterface = (): PaymentMethodInterface => {
|
|
92 |
selectShippingRate,
|
93 |
needsShipping,
|
94 |
} = useShippingData();
|
95 |
-
|
96 |
-
|
|
|
|
|
|
|
97 |
const { cartItems, cartFees, cartTotals, extensions } = useStoreCart();
|
98 |
const { appliedCoupons } = useStoreCartCoupons();
|
99 |
const currentCartTotals = useRef(
|
11 |
import LoadingMask from '@woocommerce/base-components/loading-mask';
|
12 |
import type { PaymentMethodInterface } from '@woocommerce/types';
|
13 |
import { useSelect, useDispatch } from '@wordpress/data';
|
14 |
+
import {
|
15 |
+
CHECKOUT_STORE_KEY,
|
16 |
+
PAYMENT_STORE_KEY,
|
17 |
+
CART_STORE_KEY,
|
18 |
+
} from '@woocommerce/block-data';
|
19 |
import { ValidationInputError } from '@woocommerce/blocks-checkout';
|
20 |
|
21 |
/**
|
27 |
import { useCheckoutEventsContext } from '../../providers/cart-checkout/checkout-events';
|
28 |
import { usePaymentEventsContext } from '../../providers/cart-checkout/payment-events';
|
29 |
import { useShippingDataContext } from '../../providers/cart-checkout/shipping';
|
|
|
30 |
import { prepareTotalItems } from './utils';
|
31 |
import { useShippingData } from '../shipping/use-shipping-data';
|
32 |
|
95 |
selectShippingRate,
|
96 |
needsShipping,
|
97 |
} = useShippingData();
|
98 |
+
|
99 |
+
const { billingAddress, shippingAddress } = useSelect( ( select ) =>
|
100 |
+
select( CART_STORE_KEY ).getCustomerData()
|
101 |
+
);
|
102 |
+
const { setShippingAddress } = useDispatch( CART_STORE_KEY );
|
103 |
const { cartItems, cartFees, cartTotals, extensions } = useStoreCart();
|
104 |
const { appliedCoupons } = useStoreCartCoupons();
|
105 |
const currentCartTotals = useRef(
|
assets/js/base/context/hooks/use-checkout-address.ts
CHANGED
@@ -39,8 +39,8 @@ interface CheckoutAddress {
|
|
39 |
*/
|
40 |
export const useCheckoutAddress = (): CheckoutAddress => {
|
41 |
const { needsShipping } = useShippingData();
|
42 |
-
const
|
43 |
-
select( CHECKOUT_STORE_KEY ).
|
44 |
);
|
45 |
const { __internalSetUseShippingAsBilling } =
|
46 |
useDispatch( CHECKOUT_STORE_KEY );
|
39 |
*/
|
40 |
export const useCheckoutAddress = (): CheckoutAddress => {
|
41 |
const { needsShipping } = useShippingData();
|
42 |
+
const useShippingAsBilling = useSelect( ( select ) =>
|
43 |
+
select( CHECKOUT_STORE_KEY ).getUseShippingAsBilling()
|
44 |
);
|
45 |
const { __internalSetUseShippingAsBilling } =
|
46 |
useDispatch( CHECKOUT_STORE_KEY );
|
assets/js/base/context/hooks/use-checkout-extension-data.ts
CHANGED
@@ -9,7 +9,7 @@ import { CHECKOUT_STORE_KEY } from '@woocommerce/block-data';
|
|
9 |
/**
|
10 |
* Internal dependencies
|
11 |
*/
|
12 |
-
import type { CheckoutState } from '../../../data/checkout/
|
13 |
|
14 |
/**
|
15 |
* Custom hook for setting custom checkout data which is passed to the wc/store/checkout endpoint when processing orders.
|
@@ -23,8 +23,8 @@ export const useCheckoutExtensionData = (): {
|
|
23 |
) => void;
|
24 |
} => {
|
25 |
const { __internalSetExtensionData } = useDispatch( CHECKOUT_STORE_KEY );
|
26 |
-
const
|
27 |
-
select( CHECKOUT_STORE_KEY ).
|
28 |
);
|
29 |
const extensionDataRef = useRef( extensionData );
|
30 |
|
9 |
/**
|
10 |
* Internal dependencies
|
11 |
*/
|
12 |
+
import type { CheckoutState } from '../../../data/checkout/default-state';
|
13 |
|
14 |
/**
|
15 |
* Custom hook for setting custom checkout data which is passed to the wc/store/checkout endpoint when processing orders.
|
23 |
) => void;
|
24 |
} => {
|
25 |
const { __internalSetExtensionData } = useDispatch( CHECKOUT_STORE_KEY );
|
26 |
+
const extensionData = useSelect( ( select ) =>
|
27 |
+
select( CHECKOUT_STORE_KEY ).getExtensionData()
|
28 |
);
|
29 |
const extensionDataRef = useRef( extensionData );
|
30 |
|
assets/js/base/context/providers/cart-checkout/checkout-events/index.tsx
CHANGED
@@ -25,10 +25,8 @@ import {
|
|
25 |
*/
|
26 |
import { useEventEmitters, reducer as emitReducer } from './event-emit';
|
27 |
import type { emitterCallback } from '../../../event-emit';
|
28 |
-
import { STATUS } from '../../../../../data/checkout/constants';
|
29 |
import { useStoreEvents } from '../../../hooks/use-store-events';
|
30 |
import { useCheckoutNotices } from '../../../hooks/use-checkout-notices';
|
31 |
-
import { CheckoutState } from '../../../../../data/checkout/default-state';
|
32 |
import {
|
33 |
getExpressPaymentMethods,
|
34 |
getPaymentMethods,
|
@@ -101,13 +99,38 @@ export const CheckoutEventsProvider = ( {
|
|
101 |
__internalUpdateAvailablePaymentMethods,
|
102 |
] );
|
103 |
|
104 |
-
const
|
105 |
-
|
106 |
-
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
-
if ( redirectUrl && redirectUrl !==
|
110 |
-
|
111 |
}
|
112 |
|
113 |
const { setValidationErrors } = useDispatch( VALIDATION_STORE_KEY );
|
@@ -154,34 +177,34 @@ export const CheckoutEventsProvider = ( {
|
|
154 |
// Emit CHECKOUT_VALIDATE event and set the error state based on the response of
|
155 |
// the registered callbacks
|
156 |
useEffect( () => {
|
157 |
-
if (
|
158 |
-
|
159 |
observers: currentObservers.current,
|
160 |
setValidationErrors,
|
161 |
} );
|
162 |
}
|
163 |
}, [
|
164 |
-
|
165 |
setValidationErrors,
|
166 |
createErrorNotice,
|
167 |
-
|
168 |
] );
|
169 |
|
170 |
-
const previousStatus = usePrevious(
|
171 |
-
const previousHasError = usePrevious(
|
172 |
|
173 |
// Emit CHECKOUT_AFTER_PROCESSING_WITH_SUCCESS and CHECKOUT_AFTER_PROCESSING_WITH_ERROR events
|
174 |
// and set checkout errors according to the callback responses
|
175 |
useEffect( () => {
|
176 |
if (
|
177 |
-
|
178 |
-
|
179 |
) {
|
180 |
return;
|
181 |
}
|
182 |
|
183 |
-
if (
|
184 |
-
|
185 |
observers: currentObservers.current,
|
186 |
notices: {
|
187 |
checkoutNotices,
|
@@ -191,25 +214,28 @@ export const CheckoutEventsProvider = ( {
|
|
191 |
} );
|
192 |
}
|
193 |
}, [
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
|
|
|
|
200 |
previousStatus,
|
201 |
previousHasError,
|
202 |
createErrorNotice,
|
203 |
checkoutNotices,
|
204 |
expressPaymentNotices,
|
205 |
paymentNotices,
|
206 |
-
|
|
|
207 |
] );
|
208 |
|
209 |
const onSubmit = useCallback( () => {
|
210 |
dispatchCheckoutEvent( 'submit' );
|
211 |
-
|
212 |
-
}, [ dispatchCheckoutEvent,
|
213 |
|
214 |
const checkoutEventHandlers = {
|
215 |
onSubmit,
|
25 |
*/
|
26 |
import { useEventEmitters, reducer as emitReducer } from './event-emit';
|
27 |
import type { emitterCallback } from '../../../event-emit';
|
|
|
28 |
import { useStoreEvents } from '../../../hooks/use-store-events';
|
29 |
import { useCheckoutNotices } from '../../../hooks/use-checkout-notices';
|
|
|
30 |
import {
|
31 |
getExpressPaymentMethods,
|
32 |
getPaymentMethods,
|
99 |
__internalUpdateAvailablePaymentMethods,
|
100 |
] );
|
101 |
|
102 |
+
const {
|
103 |
+
__internalSetRedirectUrl,
|
104 |
+
__internalEmitValidateEvent,
|
105 |
+
__internalEmitAfterProcessingEvents,
|
106 |
+
__internalSetBeforeProcessing,
|
107 |
+
} = useDispatch( CHECKOUT_STORE_KEY );
|
108 |
+
|
109 |
+
const {
|
110 |
+
checkoutRedirectUrl,
|
111 |
+
checkoutStatus,
|
112 |
+
isCheckoutBeforeProcessing,
|
113 |
+
isCheckoutAfterProcessing,
|
114 |
+
checkoutHasError,
|
115 |
+
checkoutOrderId,
|
116 |
+
checkoutOrderNotes,
|
117 |
+
checkoutCustomerId,
|
118 |
+
} = useSelect( ( select ) => {
|
119 |
+
const store = select( CHECKOUT_STORE_KEY );
|
120 |
+
return {
|
121 |
+
checkoutRedirectUrl: store.getRedirectUrl(),
|
122 |
+
checkoutStatus: store.getCheckoutStatus(),
|
123 |
+
isCheckoutBeforeProcessing: store.isBeforeProcessing(),
|
124 |
+
isCheckoutAfterProcessing: store.isAfterProcessing(),
|
125 |
+
checkoutHasError: store.hasError(),
|
126 |
+
checkoutOrderId: store.getOrderId(),
|
127 |
+
checkoutOrderNotes: store.getOrderNotes(),
|
128 |
+
checkoutCustomerId: store.getCustomerId(),
|
129 |
+
};
|
130 |
+
} );
|
131 |
|
132 |
+
if ( redirectUrl && redirectUrl !== checkoutRedirectUrl ) {
|
133 |
+
__internalSetRedirectUrl( redirectUrl );
|
134 |
}
|
135 |
|
136 |
const { setValidationErrors } = useDispatch( VALIDATION_STORE_KEY );
|
177 |
// Emit CHECKOUT_VALIDATE event and set the error state based on the response of
|
178 |
// the registered callbacks
|
179 |
useEffect( () => {
|
180 |
+
if ( isCheckoutBeforeProcessing ) {
|
181 |
+
__internalEmitValidateEvent( {
|
182 |
observers: currentObservers.current,
|
183 |
setValidationErrors,
|
184 |
} );
|
185 |
}
|
186 |
}, [
|
187 |
+
isCheckoutBeforeProcessing,
|
188 |
setValidationErrors,
|
189 |
createErrorNotice,
|
190 |
+
__internalEmitValidateEvent,
|
191 |
] );
|
192 |
|
193 |
+
const previousStatus = usePrevious( checkoutStatus );
|
194 |
+
const previousHasError = usePrevious( checkoutHasError );
|
195 |
|
196 |
// Emit CHECKOUT_AFTER_PROCESSING_WITH_SUCCESS and CHECKOUT_AFTER_PROCESSING_WITH_ERROR events
|
197 |
// and set checkout errors according to the callback responses
|
198 |
useEffect( () => {
|
199 |
if (
|
200 |
+
checkoutStatus === previousStatus &&
|
201 |
+
checkoutHasError === previousHasError
|
202 |
) {
|
203 |
return;
|
204 |
}
|
205 |
|
206 |
+
if ( isCheckoutAfterProcessing ) {
|
207 |
+
__internalEmitAfterProcessingEvents( {
|
208 |
observers: currentObservers.current,
|
209 |
notices: {
|
210 |
checkoutNotices,
|
214 |
} );
|
215 |
}
|
216 |
}, [
|
217 |
+
checkoutStatus,
|
218 |
+
checkoutHasError,
|
219 |
+
checkoutRedirectUrl,
|
220 |
+
checkoutOrderId,
|
221 |
+
checkoutCustomerId,
|
222 |
+
checkoutOrderNotes,
|
223 |
+
isCheckoutAfterProcessing,
|
224 |
+
isCheckoutBeforeProcessing,
|
225 |
previousStatus,
|
226 |
previousHasError,
|
227 |
createErrorNotice,
|
228 |
checkoutNotices,
|
229 |
expressPaymentNotices,
|
230 |
paymentNotices,
|
231 |
+
__internalEmitValidateEvent,
|
232 |
+
__internalEmitAfterProcessingEvents,
|
233 |
] );
|
234 |
|
235 |
const onSubmit = useCallback( () => {
|
236 |
dispatchCheckoutEvent( 'submit' );
|
237 |
+
__internalSetBeforeProcessing();
|
238 |
+
}, [ dispatchCheckoutEvent, __internalSetBeforeProcessing ] );
|
239 |
|
240 |
const checkoutEventHandlers = {
|
241 |
onSubmit,
|
assets/js/base/context/providers/cart-checkout/checkout-processor.js
CHANGED
@@ -19,6 +19,7 @@ import {
|
|
19 |
CHECKOUT_STORE_KEY,
|
20 |
PAYMENT_STORE_KEY,
|
21 |
VALIDATION_STORE_KEY,
|
|
|
22 |
} from '@woocommerce/block-data';
|
23 |
import {
|
24 |
getPaymentMethods,
|
@@ -31,7 +32,6 @@ import {
|
|
31 |
import { preparePaymentData, processCheckoutResponseHeaders } from './utils';
|
32 |
import { useCheckoutEventsContext } from './checkout-events';
|
33 |
import { useShippingDataContext } from './shipping';
|
34 |
-
import { useCustomerDataContext } from './customer';
|
35 |
import { useStoreCart } from '../../hooks/cart/use-store-cart';
|
36 |
|
37 |
/**
|
@@ -54,10 +54,14 @@ const CheckoutProcessor = () => {
|
|
54 |
} = useSelect( ( select ) => {
|
55 |
const store = select( CHECKOUT_STORE_KEY );
|
56 |
return {
|
57 |
-
|
|
|
58 |
isProcessing: store.isProcessing(),
|
59 |
isBeforeProcessing: store.isBeforeProcessing(),
|
60 |
isComplete: store.isComplete(),
|
|
|
|
|
|
|
61 |
};
|
62 |
} );
|
63 |
|
@@ -68,7 +72,11 @@ const CheckoutProcessor = () => {
|
|
68 |
( select ) => select( VALIDATION_STORE_KEY ).hasValidationErrors
|
69 |
);
|
70 |
const { shippingErrorStatus } = useShippingDataContext();
|
71 |
-
|
|
|
|
|
|
|
|
|
72 |
const { cartNeedsPayment, cartNeedsShipping, receiveCart } = useStoreCart();
|
73 |
const { createErrorNotice, removeNotice } = useDispatch( 'core/notices' );
|
74 |
|
19 |
CHECKOUT_STORE_KEY,
|
20 |
PAYMENT_STORE_KEY,
|
21 |
VALIDATION_STORE_KEY,
|
22 |
+
CART_STORE_KEY,
|
23 |
} from '@woocommerce/block-data';
|
24 |
import {
|
25 |
getPaymentMethods,
|
32 |
import { preparePaymentData, processCheckoutResponseHeaders } from './utils';
|
33 |
import { useCheckoutEventsContext } from './checkout-events';
|
34 |
import { useShippingDataContext } from './shipping';
|
|
|
35 |
import { useStoreCart } from '../../hooks/cart/use-store-cart';
|
36 |
|
37 |
/**
|
54 |
} = useSelect( ( select ) => {
|
55 |
const store = select( CHECKOUT_STORE_KEY );
|
56 |
return {
|
57 |
+
hasError: store.hasError(),
|
58 |
+
redirectUrl: store.getRedirectUrl(),
|
59 |
isProcessing: store.isProcessing(),
|
60 |
isBeforeProcessing: store.isBeforeProcessing(),
|
61 |
isComplete: store.isComplete(),
|
62 |
+
orderNotes: store.getOrderNotes(),
|
63 |
+
shouldCreateAccount: store.getShouldCreateAccount(),
|
64 |
+
extensionData: store.getExtensionData(),
|
65 |
};
|
66 |
} );
|
67 |
|
72 |
( select ) => select( VALIDATION_STORE_KEY ).hasValidationErrors
|
73 |
);
|
74 |
const { shippingErrorStatus } = useShippingDataContext();
|
75 |
+
|
76 |
+
const { billingAddress, shippingAddress } = useSelect( ( select ) =>
|
77 |
+
select( CART_STORE_KEY ).getCustomerData()
|
78 |
+
);
|
79 |
+
|
80 |
const { cartNeedsPayment, cartNeedsShipping, receiveCart } = useStoreCart();
|
81 |
const { createErrorNotice, removeNotice } = useDispatch( 'core/notices' );
|
82 |
|
assets/js/base/context/providers/cart-checkout/checkout-provider.js
CHANGED
@@ -9,7 +9,6 @@ import BlockErrorBoundary from '@woocommerce/base-components/block-error-boundar
|
|
9 |
*/
|
10 |
import { PaymentEventsProvider } from './payment-events';
|
11 |
import { ShippingDataProvider } from './shipping';
|
12 |
-
import { CustomerDataProvider } from './customer';
|
13 |
import { CheckoutEventsProvider } from './checkout-events';
|
14 |
import CheckoutProcessor from './checkout-processor';
|
15 |
|
@@ -28,23 +27,21 @@ import CheckoutProcessor from './checkout-processor';
|
|
28 |
export const CheckoutProvider = ( { children, redirectUrl } ) => {
|
29 |
return (
|
30 |
<CheckoutEventsProvider redirectUrl={ redirectUrl }>
|
31 |
-
<
|
32 |
-
<
|
33 |
-
|
34 |
-
|
35 |
-
{ /* If the current user is an admin, we let BlockErrorBoundary render
|
36 |
the error, or we simply die silently. */ }
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
</CustomerDataProvider>
|
48 |
</CheckoutEventsProvider>
|
49 |
);
|
50 |
};
|
9 |
*/
|
10 |
import { PaymentEventsProvider } from './payment-events';
|
11 |
import { ShippingDataProvider } from './shipping';
|
|
|
12 |
import { CheckoutEventsProvider } from './checkout-events';
|
13 |
import CheckoutProcessor from './checkout-processor';
|
14 |
|
27 |
export const CheckoutProvider = ( { children, redirectUrl } ) => {
|
28 |
return (
|
29 |
<CheckoutEventsProvider redirectUrl={ redirectUrl }>
|
30 |
+
<ShippingDataProvider>
|
31 |
+
<PaymentEventsProvider>
|
32 |
+
{ children }
|
33 |
+
{ /* If the current user is an admin, we let BlockErrorBoundary render
|
|
|
34 |
the error, or we simply die silently. */ }
|
35 |
+
<BlockErrorBoundary
|
36 |
+
renderError={
|
37 |
+
CURRENT_USER_IS_ADMIN ? null : () => null
|
38 |
+
}
|
39 |
+
>
|
40 |
+
<PluginArea scope="woocommerce-checkout" />
|
41 |
+
</BlockErrorBoundary>
|
42 |
+
<CheckoutProcessor />
|
43 |
+
</PaymentEventsProvider>
|
44 |
+
</ShippingDataProvider>
|
|
|
45 |
</CheckoutEventsProvider>
|
46 |
);
|
47 |
};
|
assets/js/base/context/providers/cart-checkout/customer/constants.ts
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* Internal dependencies
|
3 |
-
*/
|
4 |
-
import type { CustomerDataType } from '../../../hooks/use-customer-data';
|
5 |
-
|
6 |
-
export const defaultBillingAddress: CustomerDataType[ 'billingAddress' ] = {
|
7 |
-
first_name: '',
|
8 |
-
last_name: '',
|
9 |
-
company: '',
|
10 |
-
address_1: '',
|
11 |
-
address_2: '',
|
12 |
-
city: '',
|
13 |
-
state: '',
|
14 |
-
postcode: '',
|
15 |
-
country: '',
|
16 |
-
email: '',
|
17 |
-
phone: '',
|
18 |
-
};
|
19 |
-
|
20 |
-
export const defaultShippingAddress: CustomerDataType[ 'shippingAddress' ] = {
|
21 |
-
first_name: '',
|
22 |
-
last_name: '',
|
23 |
-
company: '',
|
24 |
-
address_1: '',
|
25 |
-
address_2: '',
|
26 |
-
city: '',
|
27 |
-
state: '',
|
28 |
-
postcode: '',
|
29 |
-
country: '',
|
30 |
-
phone: '',
|
31 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/base/context/providers/cart-checkout/customer/index.tsx
DELETED
@@ -1,42 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* External dependencies
|
3 |
-
*/
|
4 |
-
import { createContext, useContext } from '@wordpress/element';
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Internal dependencies
|
8 |
-
*/
|
9 |
-
import { defaultBillingAddress, defaultShippingAddress } from './constants';
|
10 |
-
import {
|
11 |
-
useCustomerData,
|
12 |
-
CustomerDataType,
|
13 |
-
} from '../../../hooks/use-customer-data';
|
14 |
-
|
15 |
-
const CustomerDataContext = createContext< CustomerDataType >( {
|
16 |
-
isInitialized: false,
|
17 |
-
billingAddress: defaultBillingAddress,
|
18 |
-
shippingAddress: defaultShippingAddress,
|
19 |
-
setBillingAddress: () => void 0,
|
20 |
-
setShippingAddress: () => void 0,
|
21 |
-
} );
|
22 |
-
|
23 |
-
export const useCustomerDataContext = (): CustomerDataType => {
|
24 |
-
return useContext( CustomerDataContext );
|
25 |
-
};
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Customer Data context provider.
|
29 |
-
*/
|
30 |
-
export const CustomerDataProvider = ( {
|
31 |
-
children,
|
32 |
-
}: {
|
33 |
-
children: JSX.Element | JSX.Element[];
|
34 |
-
} ): JSX.Element => {
|
35 |
-
const contextValue = useCustomerData();
|
36 |
-
|
37 |
-
return (
|
38 |
-
<CustomerDataContext.Provider value={ contextValue }>
|
39 |
-
{ children }
|
40 |
-
</CustomerDataContext.Provider>
|
41 |
-
);
|
42 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/base/context/providers/cart-checkout/index.js
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
export * from './payment-events';
|
2 |
export * from './shipping';
|
3 |
-
export * from './customer';
|
4 |
export * from './checkout-events';
|
5 |
export * from './cart';
|
6 |
export * from './checkout-processor';
|
1 |
export * from './payment-events';
|
2 |
export * from './shipping';
|
|
|
3 |
export * from './checkout-events';
|
4 |
export * from './cart';
|
5 |
export * from './checkout-processor';
|
assets/js/base/utils/lazy-load-script.ts
CHANGED
@@ -26,8 +26,16 @@ interface AppendScriptAttributesParam {
|
|
26 |
* This function checks whether an element matching that selector exists.
|
27 |
* Useful to know if a script has already been appended to the page.
|
28 |
*/
|
29 |
-
const isScriptTagInDOM = ( scriptId: string ): boolean => {
|
30 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
return scriptElements.length > 0;
|
32 |
};
|
33 |
|
@@ -37,7 +45,10 @@ const isScriptTagInDOM = ( scriptId: string ): boolean => {
|
|
37 |
*/
|
38 |
const appendScript = ( attributes: AppendScriptAttributesParam ): void => {
|
39 |
// Abort if id is not valid or a script with the same id exists.
|
40 |
-
if (
|
|
|
|
|
|
|
41 |
return;
|
42 |
}
|
43 |
const scriptElement = document.createElement( 'script' );
|
@@ -92,7 +103,7 @@ const lazyLoadScript = ( {
|
|
92 |
translations,
|
93 |
}: LazyLoadScriptParams ): Promise< void > => {
|
94 |
return new Promise( ( resolve, reject ) => {
|
95 |
-
if ( isScriptTagInDOM( `${ handle }-js
|
96 |
resolve();
|
97 |
}
|
98 |
|
26 |
* This function checks whether an element matching that selector exists.
|
27 |
* Useful to know if a script has already been appended to the page.
|
28 |
*/
|
29 |
+
const isScriptTagInDOM = ( scriptId: string, src = '' ): boolean => {
|
30 |
+
const srcParts = src.split( '?' );
|
31 |
+
if ( srcParts?.length > 1 ) {
|
32 |
+
src = srcParts[ 0 ];
|
33 |
+
}
|
34 |
+
const selector = src
|
35 |
+
? `script#${ scriptId }, script[src*="${ src }"]`
|
36 |
+
: `script#${ scriptId }`;
|
37 |
+
const scriptElements = document.querySelectorAll( selector );
|
38 |
+
|
39 |
return scriptElements.length > 0;
|
40 |
};
|
41 |
|
45 |
*/
|
46 |
const appendScript = ( attributes: AppendScriptAttributesParam ): void => {
|
47 |
// Abort if id is not valid or a script with the same id exists.
|
48 |
+
if (
|
49 |
+
! isString( attributes.id ) ||
|
50 |
+
isScriptTagInDOM( attributes.id, attributes?.src )
|
51 |
+
) {
|
52 |
return;
|
53 |
}
|
54 |
const scriptElement = document.createElement( 'script' );
|
103 |
translations,
|
104 |
}: LazyLoadScriptParams ): Promise< void > => {
|
105 |
return new Promise( ( resolve, reject ) => {
|
106 |
+
if ( isScriptTagInDOM( `${ handle }-js`, src ) ) {
|
107 |
resolve();
|
108 |
}
|
109 |
|
assets/js/base/utils/preload-script.ts
CHANGED
@@ -13,9 +13,12 @@ const preloadScript = ( {
|
|
13 |
src,
|
14 |
version,
|
15 |
}: PreloadScriptParams ): void => {
|
16 |
-
const
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
19 |
|
20 |
if ( handleScriptElements.length === 0 ) {
|
21 |
const prefetchLink = document.createElement( 'link' );
|
13 |
src,
|
14 |
version,
|
15 |
}: PreloadScriptParams ): void => {
|
16 |
+
const srcParts = src.split( '?' );
|
17 |
+
if ( srcParts?.length > 1 ) {
|
18 |
+
src = srcParts[ 0 ];
|
19 |
+
}
|
20 |
+
const selector = `#${ handle }-js, #${ handle }-js-prefetch, script[src*="${ src }"]`;
|
21 |
+
const handleScriptElements = document.querySelectorAll( selector );
|
22 |
|
23 |
if ( handleScriptElements.length === 0 ) {
|
24 |
const prefetchLink = document.createElement( 'link' );
|
assets/js/blocks/active-filters/block.json
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
{
|
2 |
"name": "woocommerce/active-filters",
|
3 |
"version": "1.0.0",
|
4 |
-
"title": "Active
|
5 |
-
"description": "Display the currently active
|
6 |
"category": "woocommerce",
|
7 |
"keywords": [ "WooCommerce" ],
|
8 |
"supports": {
|
1 |
{
|
2 |
"name": "woocommerce/active-filters",
|
3 |
"version": "1.0.0",
|
4 |
+
"title": "Active Filters Controls",
|
5 |
+
"description": "Display the currently active filters.",
|
6 |
"category": "woocommerce",
|
7 |
"keywords": [ "WooCommerce" ],
|
8 |
"supports": {
|
assets/js/blocks/active-filters/index.tsx
CHANGED
@@ -47,7 +47,7 @@ registerBlockType( metadata, {
|
|
47 |
>
|
48 |
<span
|
49 |
aria-hidden
|
50 |
-
className="wc-block-active-
|
51 |
/>
|
52 |
</div>
|
53 |
);
|
47 |
>
|
48 |
<span
|
49 |
aria-hidden
|
50 |
+
className="wc-block-active-filters__placeholder"
|
51 |
/>
|
52 |
</div>
|
53 |
);
|
assets/js/blocks/active-filters/style.scss
CHANGED
@@ -21,6 +21,7 @@
|
|
21 |
|
22 |
.wc-block-active-filters__clear-all {
|
23 |
@include filter-link-button();
|
|
|
24 |
border: none;
|
25 |
margin-top: 15px;
|
26 |
padding: 0;
|
@@ -142,6 +143,7 @@
|
|
142 |
}
|
143 |
|
144 |
.wc-block-active-filters__list-item-name {
|
|
|
145 |
display: flex;
|
146 |
align-items: center;
|
147 |
position: relative;
|
21 |
|
22 |
.wc-block-active-filters__clear-all {
|
23 |
@include filter-link-button();
|
24 |
+
@include font-size(small);
|
25 |
border: none;
|
26 |
margin-top: 15px;
|
27 |
padding: 0;
|
143 |
}
|
144 |
|
145 |
.wc-block-active-filters__list-item-name {
|
146 |
+
@include font-size(small);
|
147 |
display: flex;
|
148 |
align-items: center;
|
149 |
position: relative;
|
assets/js/blocks/attribute-filter/style.scss
CHANGED
@@ -79,11 +79,16 @@
|
|
79 |
}
|
80 |
|
81 |
.wc-blocks-components-form-token-field-wrapper .components-form-token-field__input-container {
|
|
|
82 |
border: 0;
|
83 |
padding: $gap-smaller;
|
84 |
|
85 |
-
.components-form-token-field__input
|
86 |
-
|
|
|
|
|
|
|
|
|
87 |
}
|
88 |
|
89 |
.components-form-token-field__suggestions-list {
|
@@ -100,6 +105,11 @@
|
|
100 |
padding: $gap-small;
|
101 |
}
|
102 |
}
|
|
|
|
|
|
|
|
|
|
|
103 |
}
|
104 |
}
|
105 |
|
@@ -143,8 +153,10 @@
|
|
143 |
}
|
144 |
}
|
145 |
|
|
|
146 |
.wc-block-filter-submit-button.wc-block-components-filter-submit-button.wc-block-attribute-filter__button {
|
147 |
margin-top: 0;
|
|
|
148 |
}
|
149 |
}
|
150 |
|
@@ -191,6 +203,5 @@
|
|
191 |
padding: em($gap-smaller) em($gap);
|
192 |
@include font-size(small);
|
193 |
height: max-content;
|
194 |
-
line-height: normal;
|
195 |
width: max-content;
|
196 |
}
|
79 |
}
|
80 |
|
81 |
.wc-blocks-components-form-token-field-wrapper .components-form-token-field__input-container {
|
82 |
+
@include reset-typography();
|
83 |
border: 0;
|
84 |
padding: $gap-smaller;
|
85 |
|
86 |
+
.components-form-token-field__input {
|
87 |
+
@include font-size(small);
|
88 |
+
|
89 |
+
&::placeholder {
|
90 |
+
color: $black;
|
91 |
+
}
|
92 |
}
|
93 |
|
94 |
.components-form-token-field__suggestions-list {
|
105 |
padding: $gap-small;
|
106 |
}
|
107 |
}
|
108 |
+
|
109 |
+
.components-form-token-field__token,
|
110 |
+
.components-form-token-field__suggestion {
|
111 |
+
@include font-size(small);
|
112 |
+
}
|
113 |
}
|
114 |
}
|
115 |
|
153 |
}
|
154 |
}
|
155 |
|
156 |
+
// The specificity here is needed to overwrite the margin-top that is inherited on WC block template pages such as Shop.
|
157 |
.wc-block-filter-submit-button.wc-block-components-filter-submit-button.wc-block-attribute-filter__button {
|
158 |
margin-top: 0;
|
159 |
+
@include font-size(small);
|
160 |
}
|
161 |
}
|
162 |
|
203 |
padding: em($gap-smaller) em($gap);
|
204 |
@include font-size(small);
|
205 |
height: max-content;
|
|
|
206 |
width: max-content;
|
207 |
}
|
assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/attributes.tsx
CHANGED
@@ -1,20 +1,18 @@
|
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
-
import {
|
5 |
|
6 |
/**
|
7 |
* Internal dependencies
|
8 |
*/
|
9 |
import formStepAttributes from '../../form-step/attributes';
|
|
|
10 |
|
11 |
-
|
12 |
...formStepAttributes( {
|
13 |
-
defaultTitle:
|
14 |
-
defaultDescription:
|
15 |
-
'Enter the billing address that matches your payment method.',
|
16 |
-
'woo-gutenberg-products-block'
|
17 |
-
),
|
18 |
} ),
|
19 |
className: {
|
20 |
type: 'string',
|
@@ -28,3 +26,4 @@ export default {
|
|
28 |
},
|
29 |
},
|
30 |
};
|
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
+
import { BlockAttributes } from '@wordpress/blocks';
|
5 |
|
6 |
/**
|
7 |
* Internal dependencies
|
8 |
*/
|
9 |
import formStepAttributes from '../../form-step/attributes';
|
10 |
+
import { DEFAULT_TITLE, DEFAULT_DESCRIPTION } from './constants';
|
11 |
|
12 |
+
const attributes: BlockAttributes = {
|
13 |
...formStepAttributes( {
|
14 |
+
defaultTitle: DEFAULT_TITLE,
|
15 |
+
defaultDescription: DEFAULT_DESCRIPTION,
|
|
|
|
|
|
|
16 |
} ),
|
17 |
className: {
|
18 |
type: 'string',
|
26 |
},
|
27 |
},
|
28 |
};
|
29 |
+
export default attributes;
|
assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/block.tsx
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
-
import { useMemo, useEffect, Fragment } from '@wordpress/element';
|
5 |
import {
|
6 |
useCheckoutAddress,
|
7 |
useStoreEvents,
|
@@ -39,10 +39,11 @@ const Block = ( {
|
|
39 |
setBillingAddress,
|
40 |
setShippingAddress,
|
41 |
setBillingPhone,
|
|
|
|
|
42 |
} = useCheckoutAddress();
|
43 |
const { dispatchCheckoutEvent } = useStoreEvents();
|
44 |
const { isEditor } = useEditorContext();
|
45 |
-
const { forcedBillingAddress } = useCheckoutAddress();
|
46 |
// Clears data if fields are hidden.
|
47 |
useEffect( () => {
|
48 |
if ( ! showPhoneField ) {
|
@@ -50,6 +51,24 @@ const Block = ( {
|
|
50 |
}
|
51 |
}, [ showPhoneField, setBillingPhone ] );
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
const addressFieldsConfig = useMemo( () => {
|
54 |
return {
|
55 |
company: {
|
@@ -77,6 +96,7 @@ const Block = ( {
|
|
77 |
setBillingAddress( values );
|
78 |
if ( forcedBillingAddress ) {
|
79 |
setShippingAddress( values );
|
|
|
80 |
}
|
81 |
dispatchCheckoutEvent( 'set-billing-address' );
|
82 |
} }
|
@@ -97,6 +117,12 @@ const Block = ( {
|
|
97 |
dispatchCheckoutEvent( 'set-phone-number', {
|
98 |
step: 'billing',
|
99 |
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
} }
|
101 |
/>
|
102 |
) }
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
+
import { useMemo, useEffect, Fragment, useState } from '@wordpress/element';
|
5 |
import {
|
6 |
useCheckoutAddress,
|
7 |
useStoreEvents,
|
39 |
setBillingAddress,
|
40 |
setShippingAddress,
|
41 |
setBillingPhone,
|
42 |
+
setShippingPhone,
|
43 |
+
forcedBillingAddress,
|
44 |
} = useCheckoutAddress();
|
45 |
const { dispatchCheckoutEvent } = useStoreEvents();
|
46 |
const { isEditor } = useEditorContext();
|
|
|
47 |
// Clears data if fields are hidden.
|
48 |
useEffect( () => {
|
49 |
if ( ! showPhoneField ) {
|
51 |
}
|
52 |
}, [ showPhoneField, setBillingPhone ] );
|
53 |
|
54 |
+
const [ addressesSynced, setAddressesSynced ] = useState( false );
|
55 |
+
|
56 |
+
// Syncs shipping address with billing address if "Force shipping to the customer billing address" is enabled.
|
57 |
+
useEffect( () => {
|
58 |
+
if ( addressesSynced ) {
|
59 |
+
return;
|
60 |
+
}
|
61 |
+
if ( forcedBillingAddress ) {
|
62 |
+
setShippingAddress( billingAddress );
|
63 |
+
}
|
64 |
+
setAddressesSynced( true );
|
65 |
+
}, [
|
66 |
+
addressesSynced,
|
67 |
+
setShippingAddress,
|
68 |
+
billingAddress,
|
69 |
+
forcedBillingAddress,
|
70 |
+
] );
|
71 |
+
|
72 |
const addressFieldsConfig = useMemo( () => {
|
73 |
return {
|
74 |
company: {
|
96 |
setBillingAddress( values );
|
97 |
if ( forcedBillingAddress ) {
|
98 |
setShippingAddress( values );
|
99 |
+
dispatchCheckoutEvent( 'set-shipping-address' );
|
100 |
}
|
101 |
dispatchCheckoutEvent( 'set-billing-address' );
|
102 |
} }
|
117 |
dispatchCheckoutEvent( 'set-phone-number', {
|
118 |
step: 'billing',
|
119 |
} );
|
120 |
+
if ( forcedBillingAddress ) {
|
121 |
+
setShippingPhone( value );
|
122 |
+
dispatchCheckoutEvent( 'set-phone-number', {
|
123 |
+
step: 'shipping',
|
124 |
+
} );
|
125 |
+
}
|
126 |
} }
|
127 |
/>
|
128 |
) }
|
assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/constants.tsx
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { __ } from '@wordpress/i18n';
|
5 |
+
|
6 |
+
export const DEFAULT_TITLE = __(
|
7 |
+
'Billing address',
|
8 |
+
'woo-gutenberg-products-block'
|
9 |
+
);
|
10 |
+
export const DEFAULT_DESCRIPTION = __(
|
11 |
+
'Enter the billing address that matches your payment method.',
|
12 |
+
'woo-gutenberg-products-block'
|
13 |
+
);
|
14 |
+
|
15 |
+
export const DEFAULT_FORCED_BILLING_TITLE = __(
|
16 |
+
'Billing and shipping address',
|
17 |
+
'woo-gutenberg-products-block'
|
18 |
+
);
|
19 |
+
export const DEFAULT_FORCED_BILLING_DESCRIPTION = __(
|
20 |
+
'Enter the billing and shipping address that matches your payment method.',
|
21 |
+
'woo-gutenberg-products-block'
|
22 |
+
);
|
assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/edit.tsx
CHANGED
@@ -5,7 +5,7 @@ import classnames from 'classnames';
|
|
5 |
import { useBlockProps } from '@wordpress/block-editor';
|
6 |
import { useCheckoutAddress } from '@woocommerce/base-context/hooks';
|
7 |
import { innerBlockAreas } from '@woocommerce/blocks-checkout';
|
8 |
-
|
9 |
/**
|
10 |
* Internal dependencies
|
11 |
*/
|
@@ -19,6 +19,10 @@ import {
|
|
19 |
useCheckoutBlockControlsContext,
|
20 |
} from '../../context';
|
21 |
import Block from './block';
|
|
|
|
|
|
|
|
|
22 |
|
23 |
export const Edit = ( {
|
24 |
attributes,
|
@@ -30,7 +34,7 @@ export const Edit = ( {
|
|
30 |
showStepNumber: boolean;
|
31 |
className: string;
|
32 |
};
|
33 |
-
setAttributes: ( attributes:
|
34 |
} ): JSX.Element | null => {
|
35 |
const {
|
36 |
showCompanyField,
|
@@ -41,11 +45,19 @@ export const Edit = ( {
|
|
41 |
} = useCheckoutBlockContext();
|
42 |
const { addressFieldControls: Controls } =
|
43 |
useCheckoutBlockControlsContext();
|
44 |
-
const { showBillingFields } = useCheckoutAddress();
|
45 |
|
46 |
-
if ( ! showBillingFields ) {
|
47 |
return null;
|
48 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
return (
|
51 |
<FormStepBlock
|
5 |
import { useBlockProps } from '@wordpress/block-editor';
|
6 |
import { useCheckoutAddress } from '@woocommerce/base-context/hooks';
|
7 |
import { innerBlockAreas } from '@woocommerce/blocks-checkout';
|
8 |
+
import { BlockAttributes } from '@wordpress/blocks';
|
9 |
/**
|
10 |
* Internal dependencies
|
11 |
*/
|
19 |
useCheckoutBlockControlsContext,
|
20 |
} from '../../context';
|
21 |
import Block from './block';
|
22 |
+
import {
|
23 |
+
getBillingAddresssBlockTitle,
|
24 |
+
getBillingAddresssBlockDescription,
|
25 |
+
} from './utils';
|
26 |
|
27 |
export const Edit = ( {
|
28 |
attributes,
|
34 |
showStepNumber: boolean;
|
35 |
className: string;
|
36 |
};
|
37 |
+
setAttributes: ( attributes: BlockAttributes ) => void;
|
38 |
} ): JSX.Element | null => {
|
39 |
const {
|
40 |
showCompanyField,
|
45 |
} = useCheckoutBlockContext();
|
46 |
const { addressFieldControls: Controls } =
|
47 |
useCheckoutBlockControlsContext();
|
48 |
+
const { showBillingFields, forcedBillingAddress } = useCheckoutAddress();
|
49 |
|
50 |
+
if ( ! showBillingFields && ! forcedBillingAddress ) {
|
51 |
return null;
|
52 |
}
|
53 |
+
attributes.title = getBillingAddresssBlockTitle(
|
54 |
+
attributes.title,
|
55 |
+
forcedBillingAddress
|
56 |
+
);
|
57 |
+
attributes.description = getBillingAddresssBlockDescription(
|
58 |
+
attributes.description,
|
59 |
+
forcedBillingAddress
|
60 |
+
);
|
61 |
|
62 |
return (
|
63 |
<FormStepBlock
|
assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/frontend.tsx
CHANGED
@@ -14,6 +14,10 @@ import { CHECKOUT_STORE_KEY } from '@woocommerce/block-data';
|
|
14 |
import Block from './block';
|
15 |
import attributes from './attributes';
|
16 |
import { useCheckoutBlockContext } from '../../context';
|
|
|
|
|
|
|
|
|
17 |
|
18 |
const FrontendBlock = ( {
|
19 |
title,
|
@@ -43,7 +47,11 @@ const FrontendBlock = ( {
|
|
43 |
if ( ! showBillingFields && ! forcedBillingAddress ) {
|
44 |
return null;
|
45 |
}
|
46 |
-
|
|
|
|
|
|
|
|
|
47 |
return (
|
48 |
<FormStep
|
49 |
id="billing-fields"
|
14 |
import Block from './block';
|
15 |
import attributes from './attributes';
|
16 |
import { useCheckoutBlockContext } from '../../context';
|
17 |
+
import {
|
18 |
+
getBillingAddresssBlockTitle,
|
19 |
+
getBillingAddresssBlockDescription,
|
20 |
+
} from './utils';
|
21 |
|
22 |
const FrontendBlock = ( {
|
23 |
title,
|
47 |
if ( ! showBillingFields && ! forcedBillingAddress ) {
|
48 |
return null;
|
49 |
}
|
50 |
+
title = getBillingAddresssBlockTitle( title, forcedBillingAddress );
|
51 |
+
description = getBillingAddresssBlockDescription(
|
52 |
+
description,
|
53 |
+
forcedBillingAddress
|
54 |
+
);
|
55 |
return (
|
56 |
<FormStep
|
57 |
id="billing-fields"
|
assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/index.tsx
CHANGED
@@ -3,7 +3,6 @@
|
|
3 |
*/
|
4 |
import { Icon, mapMarker } from '@wordpress/icons';
|
5 |
import { registerBlockType } from '@wordpress/blocks';
|
6 |
-
|
7 |
/**
|
8 |
* Internal dependencies
|
9 |
*/
|
3 |
*/
|
4 |
import { Icon, mapMarker } from '@wordpress/icons';
|
5 |
import { registerBlockType } from '@wordpress/blocks';
|
|
|
6 |
/**
|
7 |
* Internal dependencies
|
8 |
*/
|
assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/utils.tsx
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Internal dependencies
|
3 |
+
*/
|
4 |
+
import {
|
5 |
+
DEFAULT_TITLE,
|
6 |
+
DEFAULT_DESCRIPTION,
|
7 |
+
DEFAULT_FORCED_BILLING_DESCRIPTION,
|
8 |
+
DEFAULT_FORCED_BILLING_TITLE,
|
9 |
+
} from './constants';
|
10 |
+
|
11 |
+
export const getBillingAddresssBlockTitle = (
|
12 |
+
title: string,
|
13 |
+
forcedBillingAddress: boolean
|
14 |
+
): string => {
|
15 |
+
if ( forcedBillingAddress ) {
|
16 |
+
// Returns default forced billing title when forced billing address is enabled and there is no title set.
|
17 |
+
return title === DEFAULT_TITLE ? DEFAULT_FORCED_BILLING_TITLE : title;
|
18 |
+
}
|
19 |
+
// Returns default title when forced billing address is disabled and there is no title set.
|
20 |
+
return title === DEFAULT_FORCED_BILLING_TITLE ? DEFAULT_TITLE : title;
|
21 |
+
};
|
22 |
+
|
23 |
+
export const getBillingAddresssBlockDescription = (
|
24 |
+
description: string,
|
25 |
+
forcedBillingAddress: boolean
|
26 |
+
): string => {
|
27 |
+
if ( forcedBillingAddress ) {
|
28 |
+
// Returns default forced billing description when forced billing address is enabled and there is no description set.
|
29 |
+
return description === DEFAULT_DESCRIPTION
|
30 |
+
? DEFAULT_FORCED_BILLING_DESCRIPTION
|
31 |
+
: description;
|
32 |
+
}
|
33 |
+
|
34 |
+
// Returns default description when forced billing address is disabled and there is no description set.
|
35 |
+
return description === DEFAULT_FORCED_BILLING_DESCRIPTION
|
36 |
+
? DEFAULT_DESCRIPTION
|
37 |
+
: description;
|
38 |
+
};
|
assets/js/blocks/checkout/inner-blocks/checkout-contact-information-block/block.tsx
CHANGED
@@ -20,9 +20,13 @@ const Block = ( {
|
|
20 |
}: {
|
21 |
allowCreateAccount: boolean;
|
22 |
} ): JSX.Element => {
|
23 |
-
const { customerId, shouldCreateAccount } = useSelect( ( select ) =>
|
24 |
-
select( CHECKOUT_STORE_KEY )
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
|
27 |
const { __internalSetShouldCreateAccount } =
|
28 |
useDispatch( CHECKOUT_STORE_KEY );
|
20 |
}: {
|
21 |
allowCreateAccount: boolean;
|
22 |
} ): JSX.Element => {
|
23 |
+
const { customerId, shouldCreateAccount } = useSelect( ( select ) => {
|
24 |
+
const store = select( CHECKOUT_STORE_KEY );
|
25 |
+
return {
|
26 |
+
customerId: store.getCustomerId(),
|
27 |
+
shouldCreateAccount: store.getShouldCreateAccount(),
|
28 |
+
};
|
29 |
+
} );
|
30 |
|
31 |
const { __internalSetShouldCreateAccount } =
|
32 |
useDispatch( CHECKOUT_STORE_KEY );
|
assets/js/blocks/checkout/inner-blocks/checkout-shipping-address-block/edit.tsx
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
import classnames from 'classnames';
|
5 |
import { useBlockProps } from '@wordpress/block-editor';
|
6 |
import { innerBlockAreas } from '@woocommerce/blocks-checkout';
|
7 |
-
|
8 |
/**
|
9 |
* Internal dependencies
|
10 |
*/
|
@@ -30,7 +30,7 @@ export const Edit = ( {
|
|
30 |
className: string;
|
31 |
};
|
32 |
setAttributes: ( attributes: Record< string, unknown > ) => void;
|
33 |
-
} ): JSX.Element => {
|
34 |
const {
|
35 |
showCompanyField,
|
36 |
showApartmentField,
|
@@ -40,6 +40,10 @@ export const Edit = ( {
|
|
40 |
} = useCheckoutBlockContext();
|
41 |
const { addressFieldControls: Controls } =
|
42 |
useCheckoutBlockControlsContext();
|
|
|
|
|
|
|
|
|
43 |
return (
|
44 |
<FormStepBlock
|
45 |
setAttributes={ setAttributes }
|
4 |
import classnames from 'classnames';
|
5 |
import { useBlockProps } from '@wordpress/block-editor';
|
6 |
import { innerBlockAreas } from '@woocommerce/blocks-checkout';
|
7 |
+
import { useCheckoutAddress } from '@woocommerce/base-context/hooks';
|
8 |
/**
|
9 |
* Internal dependencies
|
10 |
*/
|
30 |
className: string;
|
31 |
};
|
32 |
setAttributes: ( attributes: Record< string, unknown > ) => void;
|
33 |
+
} ): JSX.Element | null => {
|
34 |
const {
|
35 |
showCompanyField,
|
36 |
showApartmentField,
|
40 |
} = useCheckoutBlockContext();
|
41 |
const { addressFieldControls: Controls } =
|
42 |
useCheckoutBlockControlsContext();
|
43 |
+
const { showShippingFields } = useCheckoutAddress();
|
44 |
+
if ( ! showShippingFields ) {
|
45 |
+
return null;
|
46 |
+
}
|
47 |
return (
|
48 |
<FormStepBlock
|
49 |
setAttributes={ setAttributes }
|
assets/js/blocks/filter-wrapper/index.tsx
CHANGED
@@ -119,12 +119,9 @@ registerBlockType( metadata, {
|
|
119 |
variations: [
|
120 |
{
|
121 |
name: 'active-filters',
|
122 |
-
title: __(
|
123 |
-
'Active Product Filters',
|
124 |
-
'woo-gutenberg-products-block'
|
125 |
-
),
|
126 |
description: __(
|
127 |
-
'Display the currently active
|
128 |
'woo-gutenberg-products-block'
|
129 |
),
|
130 |
/**
|
119 |
variations: [
|
120 |
{
|
121 |
name: 'active-filters',
|
122 |
+
title: __( 'Active Filters', 'woo-gutenberg-products-block' ),
|
|
|
|
|
|
|
123 |
description: __(
|
124 |
+
'Display the currently active filters.',
|
125 |
'woo-gutenberg-products-block'
|
126 |
),
|
127 |
/**
|
assets/js/blocks/product-query/constants.ts
CHANGED
@@ -8,6 +8,7 @@ import type { InnerBlockTemplate } from '@wordpress/blocks';
|
|
8 |
* Internal dependencies
|
9 |
*/
|
10 |
import { QueryBlockAttributes } from './types';
|
|
|
11 |
|
12 |
/**
|
13 |
* Returns an object without a key.
|
@@ -20,9 +21,14 @@ function objectOmit< T, K extends keyof T >( obj: T, key: K ) {
|
|
20 |
|
21 |
export const QUERY_LOOP_ID = 'core/query';
|
22 |
|
23 |
-
export const DEFAULT_CORE_ALLOWED_CONTROLS = [ '
|
24 |
|
25 |
-
export const ALL_PRODUCT_QUERY_CONTROLS = [
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
export const DEFAULT_ALLOWED_CONTROLS = [
|
28 |
...DEFAULT_CORE_ALLOWED_CONTROLS,
|
@@ -46,7 +52,7 @@ export const QUERY_DEFAULT_ATTRIBUTES: QueryBlockAttributes = {
|
|
46 |
columns: 3,
|
47 |
},
|
48 |
query: {
|
49 |
-
perPage:
|
50 |
pages: 0,
|
51 |
offset: 0,
|
52 |
postType: 'product',
|
@@ -57,6 +63,7 @@ export const QUERY_DEFAULT_ATTRIBUTES: QueryBlockAttributes = {
|
|
57 |
exclude: [],
|
58 |
sticky: '',
|
59 |
inherit: false,
|
|
|
60 |
__woocommerceStockStatus: GLOBAL_HIDE_OUT_OF_STOCK
|
61 |
? Object.keys( objectOmit( STOCK_STATUS_OPTIONS, 'outofstock' ) )
|
62 |
: Object.keys( STOCK_STATUS_OPTIONS ),
|
@@ -72,11 +79,23 @@ export const INNER_BLOCKS_TEMPLATE: InnerBlockTemplate[] = [
|
|
72 |
[
|
73 |
'core/post-title',
|
74 |
{
|
|
|
75 |
level: 3,
|
76 |
-
fontSize: '
|
|
|
77 |
},
|
78 |
[],
|
79 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
],
|
81 |
],
|
82 |
[ 'core/query-pagination' ],
|
8 |
* Internal dependencies
|
9 |
*/
|
10 |
import { QueryBlockAttributes } from './types';
|
11 |
+
import { VARIATION_NAME as PRODUCT_TITLE_ID } from './variations/elements/product-title';
|
12 |
|
13 |
/**
|
14 |
* Returns an object without a key.
|
21 |
|
22 |
export const QUERY_LOOP_ID = 'core/query';
|
23 |
|
24 |
+
export const DEFAULT_CORE_ALLOWED_CONTROLS = [ 'taxQuery', 'search' ];
|
25 |
|
26 |
+
export const ALL_PRODUCT_QUERY_CONTROLS = [
|
27 |
+
'attributes',
|
28 |
+
'presets',
|
29 |
+
'onSale',
|
30 |
+
'stockStatus',
|
31 |
+
];
|
32 |
|
33 |
export const DEFAULT_ALLOWED_CONTROLS = [
|
34 |
...DEFAULT_CORE_ALLOWED_CONTROLS,
|
52 |
columns: 3,
|
53 |
},
|
54 |
query: {
|
55 |
+
perPage: 9,
|
56 |
pages: 0,
|
57 |
offset: 0,
|
58 |
postType: 'product',
|
63 |
exclude: [],
|
64 |
sticky: '',
|
65 |
inherit: false,
|
66 |
+
__woocommerceAttributes: [],
|
67 |
__woocommerceStockStatus: GLOBAL_HIDE_OUT_OF_STOCK
|
68 |
? Object.keys( objectOmit( STOCK_STATUS_OPTIONS, 'outofstock' ) )
|
69 |
: Object.keys( STOCK_STATUS_OPTIONS ),
|
79 |
[
|
80 |
'core/post-title',
|
81 |
{
|
82 |
+
textAlign: 'center',
|
83 |
level: 3,
|
84 |
+
fontSize: 'medium',
|
85 |
+
__woocommerceNamespace: PRODUCT_TITLE_ID,
|
86 |
},
|
87 |
[],
|
88 |
],
|
89 |
+
[
|
90 |
+
'woocommerce/product-price',
|
91 |
+
{ textAlign: 'center', fontSize: 'small' },
|
92 |
+
[],
|
93 |
+
],
|
94 |
+
[
|
95 |
+
'woocommerce/product-button',
|
96 |
+
{ textAlign: 'center', fontSize: 'small' },
|
97 |
+
[],
|
98 |
+
],
|
99 |
],
|
100 |
],
|
101 |
[ 'core/query-pagination' ],
|
assets/js/blocks/product-query/index.tsx
CHANGED
@@ -7,31 +7,36 @@ import { addFilter } from '@wordpress/hooks';
|
|
7 |
/**
|
8 |
* Internal dependencies
|
9 |
*/
|
10 |
-
import {
|
|
|
11 |
import './inspector-controls';
|
|
|
12 |
import './variations/product-query';
|
13 |
import './variations/products-on-sale';
|
14 |
|
15 |
-
|
|
|
|
|
16 |
props: Block,
|
17 |
blockName: string
|
18 |
) {
|
19 |
-
if ( blockName
|
20 |
// Gracefully handle if settings.attributes is undefined.
|
21 |
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
22 |
// @ts-ignore -- We need this because `attributes` is marked as `readonly`
|
23 |
props.attributes = {
|
24 |
...props.attributes,
|
25 |
-
|
26 |
-
type: '
|
27 |
},
|
28 |
};
|
29 |
}
|
|
|
30 |
return props;
|
31 |
}
|
32 |
|
33 |
addFilter(
|
34 |
'blocks.registerBlockType',
|
35 |
'core/custom-class-name/attribute',
|
36 |
-
|
37 |
);
|
7 |
/**
|
8 |
* Internal dependencies
|
9 |
*/
|
10 |
+
import { CORE_NAME as PRODUCT_TITLE_ID } from './variations/elements/product-title';
|
11 |
+
import { CORE_NAME as PRODUCT_SUMMARY_ID } from './variations/elements/product-summary';
|
12 |
import './inspector-controls';
|
13 |
+
import './style.scss';
|
14 |
import './variations/product-query';
|
15 |
import './variations/products-on-sale';
|
16 |
|
17 |
+
const EXTENDED_CORE_ELEMENTS = [ PRODUCT_SUMMARY_ID, PRODUCT_TITLE_ID ];
|
18 |
+
|
19 |
+
function registerProductQueryElementsNamespace(
|
20 |
props: Block,
|
21 |
blockName: string
|
22 |
) {
|
23 |
+
if ( EXTENDED_CORE_ELEMENTS.includes( blockName ) ) {
|
24 |
// Gracefully handle if settings.attributes is undefined.
|
25 |
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
26 |
// @ts-ignore -- We need this because `attributes` is marked as `readonly`
|
27 |
props.attributes = {
|
28 |
...props.attributes,
|
29 |
+
__woocommerceNamespace: {
|
30 |
+
type: 'string',
|
31 |
},
|
32 |
};
|
33 |
}
|
34 |
+
|
35 |
return props;
|
36 |
}
|
37 |
|
38 |
addFilter(
|
39 |
'blocks.registerBlockType',
|
40 |
'core/custom-class-name/attribute',
|
41 |
+
registerProductQueryElementsNamespace
|
42 |
);
|
assets/js/blocks/product-query/inspector-controls.tsx
CHANGED
@@ -6,6 +6,7 @@ import { __ } from '@wordpress/i18n';
|
|
6 |
import { InspectorControls } from '@wordpress/block-editor';
|
7 |
import { useSelect } from '@wordpress/data';
|
8 |
import { addFilter } from '@wordpress/hooks';
|
|
|
9 |
import { EditorBlock } from '@woocommerce/types';
|
10 |
import {
|
11 |
FormTokenField,
|
@@ -26,7 +27,7 @@ import {
|
|
26 |
} from './types';
|
27 |
import {
|
28 |
isWooQueryBlockVariation,
|
29 |
-
|
30 |
useAllowedControls,
|
31 |
} from './utils';
|
32 |
import {
|
@@ -34,6 +35,8 @@ import {
|
|
34 |
QUERY_LOOP_ID,
|
35 |
STOCK_STATUS_OPTIONS,
|
36 |
} from './constants';
|
|
|
|
|
37 |
|
38 |
const NAMESPACED_CONTROLS = ALL_PRODUCT_QUERY_CONTROLS.map(
|
39 |
( id ) =>
|
@@ -82,7 +85,8 @@ function getStockStatusIdByLabel( statusLabel: FormTokenField.Value ) {
|
|
82 |
)?.[ 0 ];
|
83 |
}
|
84 |
|
85 |
-
export const
|
|
|
86 |
onSale: ( props: ProductQueryBlock ) => {
|
87 |
const { query } = props.attributes;
|
88 |
|
@@ -98,7 +102,7 @@ export const INSPECTOR_CONTROLS = {
|
|
98 |
) }
|
99 |
checked={ query.__woocommerceOnSale || false }
|
100 |
onChange={ ( __woocommerceOnSale ) => {
|
101 |
-
|
102 |
__woocommerceOnSale,
|
103 |
} );
|
104 |
} }
|
@@ -124,7 +128,7 @@ export const INSPECTOR_CONTROLS = {
|
|
124 |
.map( getStockStatusIdByLabel )
|
125 |
.filter( Boolean ) as string[];
|
126 |
|
127 |
-
|
128 |
__woocommerceStockStatus,
|
129 |
} );
|
130 |
} }
|
@@ -142,6 +146,18 @@ export const INSPECTOR_CONTROLS = {
|
|
142 |
</ToolsPanelItem>
|
143 |
);
|
144 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
};
|
146 |
|
147 |
export const withProductQueryControls =
|
@@ -154,29 +170,36 @@ export const withProductQueryControls =
|
|
154 |
|
155 |
return isWooQueryBlockVariation( props ) ? (
|
156 |
<>
|
157 |
-
<BlockEdit { ...props } />
|
158 |
<InspectorControls>
|
|
|
|
|
|
|
159 |
<ToolsPanel
|
160 |
-
|
161 |
label={ __(
|
162 |
-
'
|
163 |
'woo-gutenberg-products-block'
|
164 |
) }
|
165 |
resetAll={ () => {
|
166 |
-
|
167 |
-
props,
|
168 |
-
defaultWooQueryParams
|
169 |
-
);
|
170 |
} }
|
171 |
>
|
172 |
-
{ Object.entries(
|
173 |
( [ key, Control ] ) =>
|
174 |
allowedControls?.includes( key ) ? (
|
175 |
-
<Control { ...props } />
|
176 |
) : null
|
177 |
) }
|
178 |
</ToolsPanel>
|
179 |
</InspectorControls>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
</>
|
181 |
) : (
|
182 |
<BlockEdit { ...props } />
|
6 |
import { InspectorControls } from '@wordpress/block-editor';
|
7 |
import { useSelect } from '@wordpress/data';
|
8 |
import { addFilter } from '@wordpress/hooks';
|
9 |
+
import { ProductQueryFeedbackPrompt } from '@woocommerce/editor-components/feedback-prompt';
|
10 |
import { EditorBlock } from '@woocommerce/types';
|
11 |
import {
|
12 |
FormTokenField,
|
27 |
} from './types';
|
28 |
import {
|
29 |
isWooQueryBlockVariation,
|
30 |
+
setQueryAttribute,
|
31 |
useAllowedControls,
|
32 |
} from './utils';
|
33 |
import {
|
35 |
QUERY_LOOP_ID,
|
36 |
STOCK_STATUS_OPTIONS,
|
37 |
} from './constants';
|
38 |
+
import { PopularPresets } from './inspector-controls/popular-presets';
|
39 |
+
import { AttributesFilter } from './inspector-controls/attributes-filter';
|
40 |
|
41 |
const NAMESPACED_CONTROLS = ALL_PRODUCT_QUERY_CONTROLS.map(
|
42 |
( id ) =>
|
85 |
)?.[ 0 ];
|
86 |
}
|
87 |
|
88 |
+
export const TOOLS_PANEL_CONTROLS = {
|
89 |
+
attributes: AttributesFilter,
|
90 |
onSale: ( props: ProductQueryBlock ) => {
|
91 |
const { query } = props.attributes;
|
92 |
|
102 |
) }
|
103 |
checked={ query.__woocommerceOnSale || false }
|
104 |
onChange={ ( __woocommerceOnSale ) => {
|
105 |
+
setQueryAttribute( props, {
|
106 |
__woocommerceOnSale,
|
107 |
} );
|
108 |
} }
|
128 |
.map( getStockStatusIdByLabel )
|
129 |
.filter( Boolean ) as string[];
|
130 |
|
131 |
+
setQueryAttribute( props, {
|
132 |
__woocommerceStockStatus,
|
133 |
} );
|
134 |
} }
|
146 |
</ToolsPanelItem>
|
147 |
);
|
148 |
},
|
149 |
+
wooInherit: ( props: ProductQueryBlock ) => (
|
150 |
+
<ToggleControl
|
151 |
+
label={ __(
|
152 |
+
'Woo Inherit query from template',
|
153 |
+
'woo-gutenberg-products-block'
|
154 |
+
) }
|
155 |
+
checked={ props.attributes.query.__woocommerceInherit || false }
|
156 |
+
onChange={ ( __woocommerceInherit ) => {
|
157 |
+
setQueryAttribute( props, { __woocommerceInherit } );
|
158 |
+
} }
|
159 |
+
/>
|
160 |
+
),
|
161 |
};
|
162 |
|
163 |
export const withProductQueryControls =
|
170 |
|
171 |
return isWooQueryBlockVariation( props ) ? (
|
172 |
<>
|
|
|
173 |
<InspectorControls>
|
174 |
+
{ allowedControls?.includes( 'presets' ) && (
|
175 |
+
<PopularPresets { ...props } />
|
176 |
+
) }
|
177 |
<ToolsPanel
|
178 |
+
className="woocommerce-product-query-toolspanel"
|
179 |
label={ __(
|
180 |
+
'Advanced Filters',
|
181 |
'woo-gutenberg-products-block'
|
182 |
) }
|
183 |
resetAll={ () => {
|
184 |
+
setQueryAttribute( props, defaultWooQueryParams );
|
|
|
|
|
|
|
185 |
} }
|
186 |
>
|
187 |
+
{ Object.entries( TOOLS_PANEL_CONTROLS ).map(
|
188 |
( [ key, Control ] ) =>
|
189 |
allowedControls?.includes( key ) ? (
|
190 |
+
<Control { ...props } key={ key } />
|
191 |
) : null
|
192 |
) }
|
193 |
</ToolsPanel>
|
194 |
</InspectorControls>
|
195 |
+
{
|
196 |
+
// Hacky temporary solution to display the feedback prompt
|
197 |
+
// at the bottom of the inspector controls
|
198 |
+
}
|
199 |
+
<InspectorControls __experimentalGroup="color">
|
200 |
+
<ProductQueryFeedbackPrompt />
|
201 |
+
</InspectorControls>
|
202 |
+
<BlockEdit { ...props } />
|
203 |
</>
|
204 |
) : (
|
205 |
<BlockEdit { ...props } />
|
assets/js/blocks/product-query/inspector-controls/attributes-filter.tsx
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { __ } from '@wordpress/i18n';
|
5 |
+
import {
|
6 |
+
FormTokenField,
|
7 |
+
// eslint-disable-next-line @wordpress/no-unsafe-wp-apis
|
8 |
+
__experimentalToolsPanelItem as ToolsPanelItem,
|
9 |
+
} from '@wordpress/components';
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Internal dependencies
|
13 |
+
*/
|
14 |
+
import {
|
15 |
+
AttributeMetadata,
|
16 |
+
AttributeWithTerms,
|
17 |
+
ProductQueryBlock,
|
18 |
+
} from '../types';
|
19 |
+
import useProductAttributes from '../useProductAttributes';
|
20 |
+
import { setQueryAttribute } from '../utils';
|
21 |
+
|
22 |
+
function getAttributeMetadataFromToken(
|
23 |
+
token: string,
|
24 |
+
productsAttributes: AttributeWithTerms[]
|
25 |
+
) {
|
26 |
+
const [ attributeLabel, termName ] = token.split( ': ' );
|
27 |
+
const taxonomy = productsAttributes.find(
|
28 |
+
( attribute ) => attribute.attribute_label === attributeLabel
|
29 |
+
);
|
30 |
+
|
31 |
+
if ( ! taxonomy )
|
32 |
+
throw new Error( 'Product Query Filter: Invalid attribute label' );
|
33 |
+
|
34 |
+
const term = taxonomy.terms.find(
|
35 |
+
( currentTerm ) => currentTerm.name === termName
|
36 |
+
);
|
37 |
+
|
38 |
+
if ( ! term ) throw new Error( 'Product Query Filter: Invalid term name' );
|
39 |
+
|
40 |
+
return {
|
41 |
+
taxonomy: `pa_${ taxonomy.attribute_name }`,
|
42 |
+
termId: term.id,
|
43 |
+
};
|
44 |
+
}
|
45 |
+
|
46 |
+
function getAttributeFromMetadata(
|
47 |
+
metadata: AttributeMetadata,
|
48 |
+
productsAttributes: AttributeWithTerms[]
|
49 |
+
) {
|
50 |
+
const taxonomy = productsAttributes.find(
|
51 |
+
( attribute ) =>
|
52 |
+
attribute.attribute_name === metadata.taxonomy.slice( 3 )
|
53 |
+
);
|
54 |
+
|
55 |
+
return {
|
56 |
+
taxonomy,
|
57 |
+
term: taxonomy?.terms.find( ( term ) => term.id === metadata.termId ),
|
58 |
+
};
|
59 |
+
}
|
60 |
+
|
61 |
+
function getInputValueFromQueryParam(
|
62 |
+
queryParam: AttributeMetadata[] | undefined,
|
63 |
+
productAttributes: AttributeWithTerms[]
|
64 |
+
): FormTokenField.Value[] {
|
65 |
+
return (
|
66 |
+
queryParam?.map( ( metadata ) => {
|
67 |
+
const { taxonomy, term } = getAttributeFromMetadata(
|
68 |
+
metadata,
|
69 |
+
productAttributes
|
70 |
+
);
|
71 |
+
|
72 |
+
return ! taxonomy || ! term
|
73 |
+
? {
|
74 |
+
title: __(
|
75 |
+
'Saved taxonomy was perhaps deleted or the slug was changed.',
|
76 |
+
'woo-gutenberg-products-block'
|
77 |
+
),
|
78 |
+
value: __(
|
79 |
+
`Error with saved taxonomy`,
|
80 |
+
'woo-gutenberg-products-block'
|
81 |
+
),
|
82 |
+
status: 'error',
|
83 |
+
}
|
84 |
+
: `${ taxonomy.attribute_label }: ${ term.name }`;
|
85 |
+
} ) || []
|
86 |
+
);
|
87 |
+
}
|
88 |
+
|
89 |
+
export const AttributesFilter = ( props: ProductQueryBlock ) => {
|
90 |
+
const { query } = props.attributes;
|
91 |
+
const { isLoadingAttributes, productsAttributes } =
|
92 |
+
useProductAttributes( true );
|
93 |
+
|
94 |
+
const attributesSuggestions = productsAttributes.reduce( ( acc, curr ) => {
|
95 |
+
const namespacedTerms = curr.terms.map(
|
96 |
+
( term ) => `${ curr.attribute_label }: ${ term.name }`
|
97 |
+
);
|
98 |
+
|
99 |
+
return [ ...acc, ...namespacedTerms ];
|
100 |
+
}, [] as string[] );
|
101 |
+
|
102 |
+
return (
|
103 |
+
<ToolsPanelItem
|
104 |
+
label={ __( 'Product Attributes', 'woo-gutenberg-products-block' ) }
|
105 |
+
hasValue={ () => query.__woocommerceAttributes?.length }
|
106 |
+
>
|
107 |
+
<FormTokenField
|
108 |
+
disabled={ isLoadingAttributes }
|
109 |
+
label={ __(
|
110 |
+
'Product Attributes',
|
111 |
+
'woo-gutenberg-products-block'
|
112 |
+
) }
|
113 |
+
onChange={ ( attributes ) => {
|
114 |
+
let __woocommerceAttributes;
|
115 |
+
|
116 |
+
try {
|
117 |
+
__woocommerceAttributes = attributes.map(
|
118 |
+
( attribute ) => {
|
119 |
+
attribute =
|
120 |
+
typeof attribute === 'string'
|
121 |
+
? attribute
|
122 |
+
: attribute.value;
|
123 |
+
|
124 |
+
return getAttributeMetadataFromToken(
|
125 |
+
attribute,
|
126 |
+
productsAttributes
|
127 |
+
);
|
128 |
+
}
|
129 |
+
);
|
130 |
+
|
131 |
+
setQueryAttribute( props, {
|
132 |
+
__woocommerceAttributes,
|
133 |
+
} );
|
134 |
+
} catch ( ok ) {
|
135 |
+
// Not required to do anything here
|
136 |
+
// Input validation is handled by the `validateInput`
|
137 |
+
// below, and we don't need to save anything.
|
138 |
+
}
|
139 |
+
} }
|
140 |
+
suggestions={ attributesSuggestions }
|
141 |
+
validateInput={ ( value: string ) =>
|
142 |
+
attributesSuggestions.includes( value )
|
143 |
+
}
|
144 |
+
value={
|
145 |
+
isLoadingAttributes
|
146 |
+
? [ __( 'Loading…', 'woo-gutenberg-products-block' ) ]
|
147 |
+
: getInputValueFromQueryParam(
|
148 |
+
query.__woocommerceAttributes,
|
149 |
+
productsAttributes
|
150 |
+
)
|
151 |
+
}
|
152 |
+
__experimentalExpandOnFocus={ true }
|
153 |
+
/>
|
154 |
+
</ToolsPanelItem>
|
155 |
+
);
|
156 |
+
};
|
assets/js/blocks/product-query/inspector-controls/popular-presets.tsx
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { CustomSelectControl, PanelBody } from '@wordpress/components';
|
5 |
+
import { __ } from '@wordpress/i18n';
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Internal dependencies
|
9 |
+
*/
|
10 |
+
import { ProductQueryBlock, ProductQueryBlockQuery } from '../types';
|
11 |
+
import { setQueryAttribute } from '../utils';
|
12 |
+
|
13 |
+
const PRESETS = [
|
14 |
+
{ key: 'date/desc', name: __( 'Newest', 'woo-gutenberg-products-block' ) },
|
15 |
+
{
|
16 |
+
key: 'popularity/desc',
|
17 |
+
name: __( 'Best Selling', 'woo-gutenberg-products-block' ),
|
18 |
+
},
|
19 |
+
{
|
20 |
+
key: 'rating/desc',
|
21 |
+
name: __( 'Top Rated', 'woo-gutenberg-products-block' ),
|
22 |
+
},
|
23 |
+
];
|
24 |
+
|
25 |
+
export function PopularPresets( props: ProductQueryBlock ) {
|
26 |
+
const { query } = props.attributes;
|
27 |
+
|
28 |
+
return (
|
29 |
+
<PanelBody
|
30 |
+
className="woocommerce-product-query-panel__sort"
|
31 |
+
title={ __( 'Popular Filters', 'woo-gutenberg-products-block' ) }
|
32 |
+
initialOpen={ true }
|
33 |
+
>
|
34 |
+
<p>
|
35 |
+
{ __(
|
36 |
+
'Arrange products by popular pre-sets.',
|
37 |
+
'woo-gutenberg-products-block'
|
38 |
+
) }
|
39 |
+
</p>
|
40 |
+
<CustomSelectControl
|
41 |
+
hideLabelFromVision={ true }
|
42 |
+
label={ __(
|
43 |
+
'Choose among these pre-sets',
|
44 |
+
'woo-gutenberg-products-block'
|
45 |
+
) }
|
46 |
+
onChange={ ( option ) => {
|
47 |
+
if ( ! option.selectedItem?.key ) return;
|
48 |
+
|
49 |
+
const [ orderBy, order ] = option.selectedItem?.key?.split(
|
50 |
+
'/'
|
51 |
+
) as [
|
52 |
+
ProductQueryBlockQuery[ 'orderBy' ],
|
53 |
+
ProductQueryBlockQuery[ 'order' ]
|
54 |
+
];
|
55 |
+
|
56 |
+
setQueryAttribute( props, { order, orderBy } );
|
57 |
+
} }
|
58 |
+
options={ PRESETS }
|
59 |
+
value={ PRESETS.find(
|
60 |
+
( option ) =>
|
61 |
+
option.key === `${ query.orderBy }/${ query.order }`
|
62 |
+
) }
|
63 |
+
/>
|
64 |
+
</PanelBody>
|
65 |
+
);
|
66 |
+
}
|
assets/js/blocks/product-query/style.scss
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.color-block-support-panel {
|
2 |
+
.wc-block-feedback-prompt {
|
3 |
+
grid-column: 1 / -1;
|
4 |
+
}
|
5 |
+
}
|
assets/js/blocks/product-query/types.ts
CHANGED
@@ -1,7 +1,18 @@
|
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
-
import type {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
// The interface below disables the forbidden underscores
|
7 |
// naming convention because we are namespacing our
|
@@ -9,6 +20,14 @@ import type { EditorBlock } from '@woocommerce/types';
|
|
9 |
// will help signify our intentions.
|
10 |
/* eslint-disable @typescript-eslint/naming-convention */
|
11 |
export interface ProductQueryArguments {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Display only products on sale.
|
14 |
*
|
@@ -33,6 +52,7 @@ export interface ProductQueryArguments {
|
|
33 |
* ```
|
34 |
*/
|
35 |
__woocommerceOnSale?: boolean;
|
|
|
36 |
/**
|
37 |
* Filter products by their stock status.
|
38 |
*
|
@@ -52,7 +72,11 @@ export interface ProductQueryArguments {
|
|
52 |
|
53 |
export type ProductQueryBlock = EditorBlock< QueryBlockAttributes >;
|
54 |
|
55 |
-
export type ProductQueryBlockQuery =
|
|
|
|
|
|
|
|
|
56 |
|
57 |
export interface QueryBlockAttributes {
|
58 |
allowedControls?: string[];
|
@@ -81,7 +105,7 @@ export interface QueryBlockQuery {
|
|
81 |
}
|
82 |
|
83 |
export interface ProductQueryContext {
|
84 |
-
query?:
|
85 |
queryId?: number;
|
86 |
}
|
87 |
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
+
import type {
|
5 |
+
AttributeSetting,
|
6 |
+
AttributeTerm,
|
7 |
+
EditorBlock,
|
8 |
+
} from '@woocommerce/types';
|
9 |
+
|
10 |
+
export interface AttributeMetadata {
|
11 |
+
taxonomy: string;
|
12 |
+
termId: number;
|
13 |
+
}
|
14 |
+
|
15 |
+
export type AttributeWithTerms = AttributeSetting & { terms: AttributeTerm[] };
|
16 |
|
17 |
// The interface below disables the forbidden underscores
|
18 |
// naming convention because we are namespacing our
|
20 |
// will help signify our intentions.
|
21 |
/* eslint-disable @typescript-eslint/naming-convention */
|
22 |
export interface ProductQueryArguments {
|
23 |
+
/**
|
24 |
+
* Available sorting options specific to the Product Query block
|
25 |
+
*
|
26 |
+
* Other sorting options may be possible, but we are restricting
|
27 |
+
* the choice to those.
|
28 |
+
*/
|
29 |
+
orderBy: 'date' | 'popularity';
|
30 |
+
__woocommerceAttributes?: AttributeMetadata[];
|
31 |
/**
|
32 |
* Display only products on sale.
|
33 |
*
|
52 |
* ```
|
53 |
*/
|
54 |
__woocommerceOnSale?: boolean;
|
55 |
+
__woocommerceInherit?: boolean;
|
56 |
/**
|
57 |
* Filter products by their stock status.
|
58 |
*
|
72 |
|
73 |
export type ProductQueryBlock = EditorBlock< QueryBlockAttributes >;
|
74 |
|
75 |
+
export type ProductQueryBlockQuery = Omit<
|
76 |
+
QueryBlockQuery,
|
77 |
+
keyof ProductQueryArguments
|
78 |
+
> &
|
79 |
+
ProductQueryArguments;
|
80 |
|
81 |
export interface QueryBlockAttributes {
|
82 |
allowedControls?: string[];
|
105 |
}
|
106 |
|
107 |
export interface ProductQueryContext {
|
108 |
+
query?: ProductQueryBlockQuery;
|
109 |
queryId?: number;
|
110 |
}
|
111 |
|
assets/js/blocks/product-query/useProductAttributes.ts
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { useEffect, useRef, useState } from '@wordpress/element';
|
5 |
+
import { getTerms } from '@woocommerce/editor-components/utils';
|
6 |
+
import { getSetting } from '@woocommerce/settings';
|
7 |
+
import { AttributeSetting } from '@woocommerce/types';
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Internal dependencies
|
11 |
+
*/
|
12 |
+
import { AttributeWithTerms } from './types';
|
13 |
+
|
14 |
+
export default function useProductAttributes( shouldLoadAttributes: boolean ) {
|
15 |
+
const STORE_ATTRIBUTES = getSetting< AttributeSetting[] >(
|
16 |
+
'attributes',
|
17 |
+
[]
|
18 |
+
);
|
19 |
+
const [ isLoadingAttributes, setIsLoadingAttributes ] = useState( false );
|
20 |
+
const [ productsAttributes, setProductsAttributes ] = useState<
|
21 |
+
AttributeWithTerms[]
|
22 |
+
>( [] );
|
23 |
+
const hasLoadedAttributes = useRef( false );
|
24 |
+
|
25 |
+
useEffect( () => {
|
26 |
+
if (
|
27 |
+
! shouldLoadAttributes ||
|
28 |
+
isLoadingAttributes ||
|
29 |
+
hasLoadedAttributes.current
|
30 |
+
)
|
31 |
+
return;
|
32 |
+
|
33 |
+
async function fetchTerms() {
|
34 |
+
setIsLoadingAttributes( true );
|
35 |
+
|
36 |
+
for ( const attribute of STORE_ATTRIBUTES ) {
|
37 |
+
const terms = await getTerms(
|
38 |
+
Number( attribute.attribute_id )
|
39 |
+
);
|
40 |
+
|
41 |
+
setProductsAttributes( ( oldAttributes ) => [
|
42 |
+
...oldAttributes,
|
43 |
+
{
|
44 |
+
...attribute,
|
45 |
+
terms,
|
46 |
+
},
|
47 |
+
] );
|
48 |
+
}
|
49 |
+
|
50 |
+
hasLoadedAttributes.current = true;
|
51 |
+
setIsLoadingAttributes( false );
|
52 |
+
}
|
53 |
+
|
54 |
+
fetchTerms();
|
55 |
+
|
56 |
+
return () => {
|
57 |
+
hasLoadedAttributes.current = true;
|
58 |
+
};
|
59 |
+
}, [ STORE_ATTRIBUTES, isLoadingAttributes, shouldLoadAttributes ] );
|
60 |
+
|
61 |
+
return { isLoadingAttributes, productsAttributes };
|
62 |
+
}
|
assets/js/blocks/product-query/utils.tsx
CHANGED
@@ -9,8 +9,8 @@ import { store as WP_BLOCKS_STORE } from '@wordpress/blocks';
|
|
9 |
*/
|
10 |
import { QUERY_LOOP_ID } from './constants';
|
11 |
import {
|
12 |
-
ProductQueryArguments,
|
13 |
ProductQueryBlock,
|
|
|
14 |
QueryVariation,
|
15 |
} from './types';
|
16 |
|
@@ -40,14 +40,11 @@ export function isWooQueryBlockVariation( block: ProductQueryBlock ) {
|
|
40 |
/**
|
41 |
* Sets the new query arguments of a Product Query block
|
42 |
*
|
43 |
-
*
|
44 |
-
* block, this utility function makes it easier to change just the
|
45 |
-
* options relating to our custom query, while keeping the code
|
46 |
-
* clean.
|
47 |
*/
|
48 |
-
export function
|
49 |
block: ProductQueryBlock,
|
50 |
-
queryParams: Partial<
|
51 |
) {
|
52 |
const { query } = block.attributes;
|
53 |
|
9 |
*/
|
10 |
import { QUERY_LOOP_ID } from './constants';
|
11 |
import {
|
|
|
12 |
ProductQueryBlock,
|
13 |
+
ProductQueryBlockQuery,
|
14 |
QueryVariation,
|
15 |
} from './types';
|
16 |
|
40 |
/**
|
41 |
* Sets the new query arguments of a Product Query block
|
42 |
*
|
43 |
+
* Shorthand for setting new nested query parameters.
|
|
|
|
|
|
|
44 |
*/
|
45 |
+
export function setQueryAttribute(
|
46 |
block: ProductQueryBlock,
|
47 |
+
queryParams: Partial< ProductQueryBlockQuery >
|
48 |
) {
|
49 |
const { query } = block.attributes;
|
50 |
|
assets/js/blocks/product-query/variations/elements/product-summary.tsx
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { isFeaturePluginBuild } from '@woocommerce/block-settings';
|
5 |
+
import {
|
6 |
+
BLOCK_DESCRIPTION,
|
7 |
+
BLOCK_ICON,
|
8 |
+
BLOCK_TITLE,
|
9 |
+
} from '@woocommerce/atomic-blocks/product-elements/summary/constants';
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Internal dependencies
|
13 |
+
*/
|
14 |
+
import { registerElementVariation } from './utils';
|
15 |
+
|
16 |
+
export const CORE_NAME = 'core/post-excerpt';
|
17 |
+
export const VARIATION_NAME = 'woocommerce/product-query/product-summary';
|
18 |
+
|
19 |
+
if ( isFeaturePluginBuild() ) {
|
20 |
+
registerElementVariation( CORE_NAME, {
|
21 |
+
blockDescription: BLOCK_DESCRIPTION,
|
22 |
+
blockIcon: BLOCK_ICON,
|
23 |
+
blockTitle: BLOCK_TITLE,
|
24 |
+
variationName: VARIATION_NAME,
|
25 |
+
} );
|
26 |
+
}
|
assets/js/blocks/product-query/variations/elements/product-title.tsx
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { isFeaturePluginBuild } from '@woocommerce/block-settings';
|
5 |
+
import {
|
6 |
+
BLOCK_DESCRIPTION,
|
7 |
+
BLOCK_ICON,
|
8 |
+
BLOCK_TITLE,
|
9 |
+
} from '@woocommerce/atomic-blocks/product-elements/title/constants';
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Internal dependencies
|
13 |
+
*/
|
14 |
+
import { registerElementVariation } from './utils';
|
15 |
+
|
16 |
+
export const CORE_NAME = 'core/post-title';
|
17 |
+
export const VARIATION_NAME = 'woocommerce/product-query/product-title';
|
18 |
+
|
19 |
+
if ( isFeaturePluginBuild() ) {
|
20 |
+
registerElementVariation( CORE_NAME, {
|
21 |
+
blockDescription: BLOCK_DESCRIPTION,
|
22 |
+
blockIcon: BLOCK_ICON,
|
23 |
+
blockTitle: BLOCK_TITLE,
|
24 |
+
variationName: VARIATION_NAME,
|
25 |
+
} );
|
26 |
+
}
|
assets/js/blocks/product-query/variations/elements/utils.tsx
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { registerBlockVariation } from '@wordpress/blocks';
|
5 |
+
|
6 |
+
interface VariationDetails {
|
7 |
+
blockDescription: string;
|
8 |
+
blockIcon: JSX.Element;
|
9 |
+
blockTitle: string;
|
10 |
+
variationName: string;
|
11 |
+
}
|
12 |
+
|
13 |
+
export function registerElementVariation(
|
14 |
+
coreName: string,
|
15 |
+
{ blockDescription, blockIcon, blockTitle, variationName }: VariationDetails
|
16 |
+
) {
|
17 |
+
registerBlockVariation( coreName, {
|
18 |
+
description: blockDescription,
|
19 |
+
name: variationName,
|
20 |
+
title: blockTitle,
|
21 |
+
isActive: ( blockAttributes ) =>
|
22 |
+
blockAttributes.__woocommerceNamespace === variationName,
|
23 |
+
icon: {
|
24 |
+
src: blockIcon,
|
25 |
+
},
|
26 |
+
attributes: {
|
27 |
+
__woocommerceNamespace: variationName,
|
28 |
+
},
|
29 |
+
scope: [ 'block', 'inserter' ],
|
30 |
+
} );
|
31 |
+
}
|
assets/js/blocks/product-query/variations/product-query.tsx
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
-
import {
|
5 |
import { registerBlockVariation } from '@wordpress/blocks';
|
6 |
import { Icon } from '@wordpress/components';
|
7 |
import { __ } from '@wordpress/i18n';
|
8 |
-
import {
|
9 |
|
10 |
/**
|
11 |
* Internal dependencies
|
@@ -19,20 +19,29 @@ import {
|
|
19 |
|
20 |
const VARIATION_NAME = 'woocommerce/product-query';
|
21 |
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
registerBlockVariation( QUERY_LOOP_ID, {
|
|
|
|
|
|
|
|
|
24 |
name: VARIATION_NAME,
|
25 |
-
|
|
|
26 |
isActive: ( blockAttributes ) =>
|
27 |
blockAttributes.namespace === VARIATION_NAME,
|
28 |
-
icon:
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
),
|
35 |
-
},
|
36 |
attributes: {
|
37 |
...QUERY_DEFAULT_ATTRIBUTES,
|
38 |
namespace: VARIATION_NAME,
|
@@ -41,8 +50,10 @@ if ( isExperimentalBuild() ) {
|
|
41 |
// https://github.com/WordPress/gutenberg/pull/43632
|
42 |
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
43 |
// @ts-ignore
|
44 |
-
allowedControls:
|
|
|
|
|
45 |
innerBlocks: INNER_BLOCKS_TEMPLATE,
|
46 |
-
scope: [ '
|
47 |
} );
|
48 |
}
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
+
import { isFeaturePluginBuild } from '@woocommerce/block-settings';
|
5 |
import { registerBlockVariation } from '@wordpress/blocks';
|
6 |
import { Icon } from '@wordpress/components';
|
7 |
import { __ } from '@wordpress/i18n';
|
8 |
+
import { stacks } from '@woocommerce/icons';
|
9 |
|
10 |
/**
|
11 |
* Internal dependencies
|
19 |
|
20 |
const VARIATION_NAME = 'woocommerce/product-query';
|
21 |
|
22 |
+
// This is a feature flag to enable the custom inherit Global Query implementation.
|
23 |
+
// This is not intended to be a permanent feature flag, but rather a temporary.
|
24 |
+
// It is also necessary to enable this feature flag on the PHP side: `src/BlockTypes/ProductQuery.php:49`.
|
25 |
+
// https://github.com/woocommerce/woocommerce-blocks/pull/7382
|
26 |
+
const isCustomInheritGlobalQueryImplementationEnabled = false;
|
27 |
+
|
28 |
+
if ( isFeaturePluginBuild() ) {
|
29 |
registerBlockVariation( QUERY_LOOP_ID, {
|
30 |
+
description: __(
|
31 |
+
'A block that displays a selection of products in your store.',
|
32 |
+
'woo-gutenberg-products-block'
|
33 |
+
),
|
34 |
name: VARIATION_NAME,
|
35 |
+
/* translators: “Products“ is the name of the block. */
|
36 |
+
title: __( 'Products (Beta)', 'woo-gutenberg-products-block' ),
|
37 |
isActive: ( blockAttributes ) =>
|
38 |
blockAttributes.namespace === VARIATION_NAME,
|
39 |
+
icon: (
|
40 |
+
<Icon
|
41 |
+
icon={ stacks }
|
42 |
+
className="wc-block-editor-components-block-icon wc-block-editor-components-block-icon--stacks"
|
43 |
+
/>
|
44 |
+
),
|
|
|
|
|
45 |
attributes: {
|
46 |
...QUERY_DEFAULT_ATTRIBUTES,
|
47 |
namespace: VARIATION_NAME,
|
50 |
// https://github.com/WordPress/gutenberg/pull/43632
|
51 |
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
52 |
// @ts-ignore
|
53 |
+
allowedControls: isCustomInheritGlobalQueryImplementationEnabled
|
54 |
+
? [ ...DEFAULT_ALLOWED_CONTROLS, 'wooInherit' ]
|
55 |
+
: DEFAULT_ALLOWED_CONTROLS,
|
56 |
innerBlocks: INNER_BLOCKS_TEMPLATE,
|
57 |
+
scope: [ 'inserter' ],
|
58 |
} );
|
59 |
}
|
assets/js/blocks/product-query/variations/products-on-sale.tsx
CHANGED
@@ -3,8 +3,9 @@
|
|
3 |
*/
|
4 |
import { isExperimentalBuild } from '@woocommerce/block-settings';
|
5 |
import { registerBlockVariation } from '@wordpress/blocks';
|
|
|
6 |
import { __ } from '@wordpress/i18n';
|
7 |
-
import {
|
8 |
|
9 |
/**
|
10 |
* Internal dependencies
|
@@ -27,14 +28,12 @@ if ( isExperimentalBuild() ) {
|
|
27 |
isActive: ( blockAttributes ) =>
|
28 |
blockAttributes.namespace === VARIATION_NAME ||
|
29 |
blockAttributes.query?.__woocommerceOnSale === true,
|
30 |
-
icon:
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
),
|
37 |
-
},
|
38 |
attributes: {
|
39 |
...QUERY_DEFAULT_ATTRIBUTES,
|
40 |
namespace: VARIATION_NAME,
|
@@ -52,6 +51,6 @@ if ( isExperimentalBuild() ) {
|
|
52 |
DISABLED_INSPECTOR_CONTROLS
|
53 |
),
|
54 |
innerBlocks: INNER_BLOCKS_TEMPLATE,
|
55 |
-
scope: [ '
|
56 |
} );
|
57 |
}
|
3 |
*/
|
4 |
import { isExperimentalBuild } from '@woocommerce/block-settings';
|
5 |
import { registerBlockVariation } from '@wordpress/blocks';
|
6 |
+
import { Icon } from '@wordpress/components';
|
7 |
import { __ } from '@wordpress/i18n';
|
8 |
+
import { percent } from '@wordpress/icons';
|
9 |
|
10 |
/**
|
11 |
* Internal dependencies
|
28 |
isActive: ( blockAttributes ) =>
|
29 |
blockAttributes.namespace === VARIATION_NAME ||
|
30 |
blockAttributes.query?.__woocommerceOnSale === true,
|
31 |
+
icon: (
|
32 |
+
<Icon
|
33 |
+
icon={ percent }
|
34 |
+
className="wc-block-editor-components-block-icon wc-block-editor-components-block-icon--percent"
|
35 |
+
/>
|
36 |
+
),
|
|
|
|
|
37 |
attributes: {
|
38 |
...QUERY_DEFAULT_ATTRIBUTES,
|
39 |
namespace: VARIATION_NAME,
|
51 |
DISABLED_INSPECTOR_CONTROLS
|
52 |
),
|
53 |
innerBlocks: INNER_BLOCKS_TEMPLATE,
|
54 |
+
scope: [ 'inserter' ],
|
55 |
} );
|
56 |
}
|
assets/js/blocks/rating-filter/style.scss
CHANGED
@@ -45,6 +45,7 @@
|
|
45 |
button[type="submit"]:not(.wp-block-search__button).wc-block-components-filter-submit-button {
|
46 |
margin-left: 0;
|
47 |
margin-top: 0;
|
|
|
48 |
}
|
49 |
|
50 |
.wc-block-rating-filter__button {
|
45 |
button[type="submit"]:not(.wp-block-search__button).wc-block-components-filter-submit-button {
|
46 |
margin-left: 0;
|
47 |
margin-top: 0;
|
48 |
+
@include font-size(small);
|
49 |
}
|
50 |
|
51 |
.wc-block-rating-filter__button {
|
assets/js/blocks/stock-filter/style.scss
CHANGED
@@ -46,6 +46,7 @@
|
|
46 |
button[type="submit"]:not(.wp-block-search__button).wc-block-components-filter-submit-button {
|
47 |
margin-left: 0;
|
48 |
margin-top: 0;
|
|
|
49 |
}
|
50 |
|
51 |
.wc-block-stock-filter__button {
|
46 |
button[type="submit"]:not(.wp-block-search__button).wc-block-components-filter-submit-button {
|
47 |
margin-left: 0;
|
48 |
margin-top: 0;
|
49 |
+
@include font-size(small);
|
50 |
}
|
51 |
|
52 |
.wc-block-stock-filter__button {
|
assets/js/data/checkout/selectors.ts
CHANGED
@@ -8,10 +8,34 @@ export const getCustomerId = ( state: CheckoutState ) => {
|
|
8 |
return state.customerId;
|
9 |
};
|
10 |
|
|
|
|
|
|
|
|
|
11 |
export const getOrderNotes = ( state: CheckoutState ) => {
|
12 |
return state.orderNotes;
|
13 |
};
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
export const hasError = ( state: CheckoutState ) => {
|
16 |
return state.hasError;
|
17 |
};
|
@@ -43,5 +67,3 @@ export const isProcessing = ( state: CheckoutState ) => {
|
|
43 |
export const isCalculating = ( state: CheckoutState ) => {
|
44 |
return state.calculatingCount > 0;
|
45 |
};
|
46 |
-
|
47 |
-
export const getCheckoutState = ( state: CheckoutState ) => state;
|
8 |
return state.customerId;
|
9 |
};
|
10 |
|
11 |
+
export const getOrderId = ( state: CheckoutState ) => {
|
12 |
+
return state.orderId;
|
13 |
+
};
|
14 |
+
|
15 |
export const getOrderNotes = ( state: CheckoutState ) => {
|
16 |
return state.orderNotes;
|
17 |
};
|
18 |
|
19 |
+
export const getRedirectUrl = ( state: CheckoutState ) => {
|
20 |
+
return state.redirectUrl;
|
21 |
+
};
|
22 |
+
|
23 |
+
export const getUseShippingAsBilling = ( state: CheckoutState ) => {
|
24 |
+
return state.useShippingAsBilling;
|
25 |
+
};
|
26 |
+
|
27 |
+
export const getExtensionData = ( state: CheckoutState ) => {
|
28 |
+
return state.extensionData;
|
29 |
+
};
|
30 |
+
|
31 |
+
export const getShouldCreateAccount = ( state: CheckoutState ) => {
|
32 |
+
return state.shouldCreateAccount;
|
33 |
+
};
|
34 |
+
|
35 |
+
export const getCheckoutStatus = ( state: CheckoutState ) => {
|
36 |
+
return state.status;
|
37 |
+
};
|
38 |
+
|
39 |
export const hasError = ( state: CheckoutState ) => {
|
40 |
return state.hasError;
|
41 |
};
|
67 |
export const isCalculating = ( state: CheckoutState ) => {
|
68 |
return state.calculatingCount > 0;
|
69 |
};
|
|
|
|
assets/js/data/checkout/thunks.ts
CHANGED
@@ -96,16 +96,15 @@ export const __internalEmitAfterProcessingEvents: emitAfterProcessingEventsType
|
|
96 |
( { observers, notices } ) => {
|
97 |
return ( { select, dispatch, registry } ) => {
|
98 |
const { createErrorNotice } = registry.dispatch( noticesStore );
|
99 |
-
const checkoutState = select.getCheckoutState();
|
100 |
const data = {
|
101 |
-
redirectUrl:
|
102 |
-
orderId:
|
103 |
-
customerId:
|
104 |
-
orderNotes:
|
105 |
processingResponse:
|
106 |
wpSelect( PAYMENT_STORE_KEY ).getPaymentResult(),
|
107 |
};
|
108 |
-
if (
|
109 |
// allow payment methods or other things to customize the error
|
110 |
// with a fallback if nothing customizes it.
|
111 |
emitEventWithAbort(
|
96 |
( { observers, notices } ) => {
|
97 |
return ( { select, dispatch, registry } ) => {
|
98 |
const { createErrorNotice } = registry.dispatch( noticesStore );
|
|
|
99 |
const data = {
|
100 |
+
redirectUrl: select.getRedirectUrl(),
|
101 |
+
orderId: select.getOrderId(),
|
102 |
+
customerId: select.getCustomerId(),
|
103 |
+
orderNotes: select.getOrderNotes(),
|
104 |
processingResponse:
|
105 |
wpSelect( PAYMENT_STORE_KEY ).getPaymentResult(),
|
106 |
};
|
107 |
+
if ( select.hasError() ) {
|
108 |
// allow payment methods or other things to customize the error
|
109 |
// with a fallback if nothing customizes it.
|
110 |
emitEventWithAbort(
|
assets/js/data/payment/utils/check-payment-methods.ts
CHANGED
@@ -30,11 +30,8 @@ import {
|
|
30 |
EMPTY_CART_ERRORS,
|
31 |
EMPTY_CART_ITEM_ERRORS,
|
32 |
EMPTY_EXTENSIONS,
|
33 |
-
} from '
|
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' );
|
@@ -122,9 +119,9 @@ export const checkPaymentMethodsCanPay = async ( express = false ) => {
|
|
122 |
cartTotals: previewCart.totals,
|
123 |
cartIsLoading: false,
|
124 |
cartErrors: EMPTY_CART_ERRORS,
|
125 |
-
billingData:
|
126 |
-
billingAddress:
|
127 |
-
shippingAddress:
|
128 |
extensions: EMPTY_EXTENSIONS,
|
129 |
shippingRates: previewCart.shipping_rates,
|
130 |
isLoadingRates: false,
|
30 |
EMPTY_CART_ERRORS,
|
31 |
EMPTY_CART_ITEM_ERRORS,
|
32 |
EMPTY_EXTENSIONS,
|
33 |
+
} from '../../../data/constants';
|
34 |
+
import { defaultCartState } from '../../../data/cart/default-state';
|
|
|
|
|
|
|
35 |
|
36 |
export const checkPaymentMethodsCanPay = async ( express = false ) => {
|
37 |
const isEditor = !! select( 'core/editor' );
|
119 |
cartTotals: previewCart.totals,
|
120 |
cartIsLoading: false,
|
121 |
cartErrors: EMPTY_CART_ERRORS,
|
122 |
+
billingData: defaultCartState.cartData.billingAddress,
|
123 |
+
billingAddress: defaultCartState.cartData.billingAddress,
|
124 |
+
shippingAddress: defaultCartState.cartData.shippingAddress,
|
125 |
extensions: EMPTY_EXTENSIONS,
|
126 |
shippingRates: previewCart.shipping_rates,
|
127 |
isLoadingRates: false,
|
assets/js/editor-components/feedback-prompt/index.js
CHANGED
@@ -14,12 +14,14 @@ import './style.scss';
|
|
14 |
/**
|
15 |
* Component to render a Feedback prompt in the sidebar.
|
16 |
*
|
17 |
-
* @param {Object} props
|
18 |
* @param {string} props.text
|
|
|
19 |
* @param {string} props.url
|
20 |
*/
|
21 |
const FeedbackPrompt = ( {
|
22 |
text,
|
|
|
23 |
url = 'https://ideas.woocommerce.com/forums/133476-woocommerce?category_id=384565',
|
24 |
} ) => {
|
25 |
// By returning false we ensure that this component is not entered into the InspectorControls
|
@@ -35,9 +37,7 @@ const FeedbackPrompt = ( {
|
|
35 |
isVisible && (
|
36 |
<div className="wc-block-feedback-prompt">
|
37 |
<Icon icon={ commentContent } />
|
38 |
-
<h2 className="wc-block-feedback-prompt__title">
|
39 |
-
{ __( 'Feedback?', 'woo-gutenberg-products-block' ) }
|
40 |
-
</h2>
|
41 |
<p className="wc-block-feedback-prompt__text">{ text }</p>
|
42 |
<a
|
43 |
href={ url }
|
@@ -82,3 +82,14 @@ export const LegacyFeedbackPrompt = () => (
|
|
82 |
url="https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues/new?template=--classic-block-feedback.md"
|
83 |
/>
|
84 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
/**
|
15 |
* Component to render a Feedback prompt in the sidebar.
|
16 |
*
|
17 |
+
* @param {Object} props Incoming props for the component.
|
18 |
* @param {string} props.text
|
19 |
+
* @param {string} props.title
|
20 |
* @param {string} props.url
|
21 |
*/
|
22 |
const FeedbackPrompt = ( {
|
23 |
text,
|
24 |
+
title = __( 'Feedback?', 'woo-gutenberg-products-block' ),
|
25 |
url = 'https://ideas.woocommerce.com/forums/133476-woocommerce?category_id=384565',
|
26 |
} ) => {
|
27 |
// By returning false we ensure that this component is not entered into the InspectorControls
|
37 |
isVisible && (
|
38 |
<div className="wc-block-feedback-prompt">
|
39 |
<Icon icon={ commentContent } />
|
40 |
+
<h2 className="wc-block-feedback-prompt__title">{ title }</h2>
|
|
|
|
|
41 |
<p className="wc-block-feedback-prompt__text">{ text }</p>
|
42 |
<a
|
43 |
href={ url }
|
82 |
url="https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues/new?template=--classic-block-feedback.md"
|
83 |
/>
|
84 |
);
|
85 |
+
|
86 |
+
export const ProductQueryFeedbackPrompt = () => (
|
87 |
+
<FeedbackPrompt
|
88 |
+
text={ __(
|
89 |
+
'Thanks for trying out the Products block! Help us make it better by sharing your feedback.',
|
90 |
+
'woo-gutenberg-products-block'
|
91 |
+
) }
|
92 |
+
title={ __( 'Share your feedback!', 'woo-gutenberg-products-block' ) }
|
93 |
+
url={ 'https://airtable.com/shrFX5FAqmCY6hVYI' }
|
94 |
+
/>
|
95 |
+
);
|
assets/js/editor-components/search-list-control/style.scss
CHANGED
@@ -25,6 +25,8 @@
|
|
25 |
|
26 |
ul {
|
27 |
list-style: none;
|
|
|
|
|
28 |
|
29 |
li {
|
30 |
float: left;
|
@@ -44,6 +46,7 @@
|
|
44 |
|
45 |
.woocommerce-search-list__list {
|
46 |
border: 1px solid $gray-200;
|
|
|
47 |
padding: 0;
|
48 |
max-height: 17em;
|
49 |
overflow-x: hidden;
|
25 |
|
26 |
ul {
|
27 |
list-style: none;
|
28 |
+
margin: 0;
|
29 |
+
padding: 0;
|
30 |
|
31 |
li {
|
32 |
float: left;
|
46 |
|
47 |
.woocommerce-search-list__list {
|
48 |
border: 1px solid $gray-200;
|
49 |
+
margin: 0;
|
50 |
padding: 0;
|
51 |
max-height: 17em;
|
52 |
overflow-x: hidden;
|
assets/js/icons/index.js
CHANGED
@@ -12,3 +12,4 @@ export { default as totals } from './library/totals';
|
|
12 |
export { default as woo } from './library/woo';
|
13 |
export { default as miniCart } from './library/mini-cart';
|
14 |
export { default as miniCartAlt } from './library/mini-cart-alt';
|
|
12 |
export { default as woo } from './library/woo';
|
13 |
export { default as miniCart } from './library/mini-cart';
|
14 |
export { default as miniCartAlt } from './library/mini-cart-alt';
|
15 |
+
export { default as stacks } from './library/stacks';
|
assets/js/icons/library/stacks.tsx
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { SVG } from '@wordpress/primitives';
|
5 |
+
|
6 |
+
const stacks = (
|
7 |
+
<SVG xmlns="http://www.w3.org/2000/SVG" viewBox="0 0 24 24">
|
8 |
+
<path
|
9 |
+
fillRule="evenodd"
|
10 |
+
clipRule="evenodd"
|
11 |
+
d="M4.5 19.375L4.5 7.625C4.5 7.55596 4.55596 7.5 4.625 7.5L16.375 7.5C16.444 7.5 16.5 7.55596 16.5 7.625L16.5 19.375C16.5 19.444 16.444 19.5 16.375 19.5L4.625 19.5C4.55596 19.5 4.5 19.444 4.5 19.375ZM4.625 21C3.72754 21 3 20.2725 3 19.375L3 7.625C3 6.72754 3.72754 6 4.625 6L16.375 6C17.2725 6 18 6.72754 18 7.625L18 19.375C18 20.2725 17.2725 21 16.375 21L4.625 21ZM19 3.75L8 3.75L8 2.25L19 2.25C20.5183 2.25 21.75 3.4796 21.75 4.99891L21.75 18L20.25 18L20.25 4.99891C20.25 4.30909 19.6909 3.75 19 3.75Z"
|
12 |
+
/>
|
13 |
+
</SVG>
|
14 |
+
);
|
15 |
+
|
16 |
+
export default stacks;
|
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' => 'fb6dd3113acb77961634324ba545952e');
|
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){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}},
|
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},
|
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})},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(
|
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=244)}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},105: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})}},106: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},112: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},133:function(e){e.exports=JSON.parse('{"name":"woocommerce/active-filters","version":"1.0.0","title":"Active Filters Controls","description":"Display the currently active 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},153: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(219),d=r(66),f=r(61);r(223);var m=r(112),g=r(39),O=r(55),j=r(22),y=r(106),_=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}},213:function(e,t){},219: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)},22:function(e,t){e.exports=window.wp.htmlEntities},222: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},223:function(e,t){},228: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(105),u=r(222);r(213);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},244:function(e,t,r){e.exports=r(245)},245:function(e,t,r){"use strict";r.r(t);var n=r(44),c=r(153),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(228),a=r(19),l=r(11),i=r(66),u=r(105),b=r(222),p=r(28),d=r(133);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(69);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(93),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},69: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})},[])}},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)}()},8:function(e,t){e.exports=window.lodash},93:function(e,t){}});
|
build/active-filters-wrapper-frontend.js
CHANGED
@@ -1,15 +1,15 @@
|
|
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)(
|
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()({},
|
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 */
|
11 |
Object(c.__)("From %s","woo-gutenberg-products-block"),Object(a.formatPrice)(e)):Object(c.sprintf)(
|
12 |
/* translators: %s max price */
|
13 |
-
Object(c.__)("Up to %s","woo-gutenberg-products-block"),Object(a.formatPrice)(t)),
|
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:
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[12],{105: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})}},106: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}},112: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)}},133:function(e){e.exports=JSON.parse('{"name":"woocommerce/active-filters","version":"1.0.0","title":"Active Filters Controls","description":"Display the currently active 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"}')},153: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(219),d=r(66),m=r(61);r(223);var p=r(112),O=r(39),j=r(55),g=r(22),y=r(106),_=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]}),[m,p]=Object(a.b)("attributes",[]);if(Object(n.useEffect)(()=>{o(d)},[d,o]),!Array.isArray(b)||!Object(f.b)(b)||!Object(f.a)(m))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=m.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)(m,p,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(p.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)(m.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}},210:function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r(92);var n=r(42);const c=()=>n.m>1},211: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:{}},213:function(e,t){},219: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)},222: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},223:function(e,t){},228: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(105),u=r(222);r(213);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:m="",...p}=e;const O=f?"span":"button";if(!t){const e=m&&"string"==typeof m?m: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()({},p,g,{className:s()(r,"is-removable"),element:f?"button":p.element,screenReaderText:m,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},287:function(e,t,r){"use strict";r.d(t,"a",(function(){return s}));var n=r(102),c=r(210),a=r(20),l=r(211);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),m=Object(a.useRef)(!1);return Object(a.useEffect)(()=>{s()(d,f)||(c(Object.assign({},l,f)),m.current=!0)},[l,f,d,c]),m.current?[n,c]:[e,c]}},39:function(e,t,r){"use strict";r.d(t,"b",(function(){return m})),r.d(t,"f",(function(){return p})),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(228),s=r(19),i=r(11),o=r(66),u=r(105),b=r(222),f=r(28),d=r(133);const m=(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 */
|
11 |
Object(c.__)("From %s","woo-gutenberg-products-block"),Object(a.formatPrice)(e)):Object(c.sprintf)(
|
12 |
/* translators: %s max price */
|
13 |
+
Object(c.__)("Up to %s","woo-gutenberg-products-block"),Object(a.formatPrice)(t)),p=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,m=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:m}):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:m})),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(287),a=r(28),l=r(153),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(69);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),m=Object(s.a)(),p=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");m(l)}return{results:c.getCollection(...a),isLoading:!c.hasFinishedResolution("getCollection",a)}},[t,r,d,f,u]);return null!==p&&(b.current=p),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(93),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},69: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})},[])}},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)}()},93: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' => 'f6864f2f1fe6d24ca679cafd5adb2260');
|
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})))}},
|
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([411,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},102: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)}}},103: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}},107: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(143);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},122: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"))}},123:function(e,t,r){"use strict";var n=r(0),c=r(5),o=r(11),l=r(1);r(167),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}))})},124:function(e,t,r){"use strict";var n=r(0);r(168),t.a=e=>{let{children:t}=e;return Object(n.createElement)("div",{className:"wc-block-filter-title-placeholder"},t)}},127: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},143: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},167:function(e,t){},168:function(e,t){},17:function(e,t){e.exports=window.wp.url},181: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}},183:function(e){e.exports=JSON.parse('{"name":"woocommerce/active-filters","version":"1.0.0","title":"Active Filters Controls","description":"Display the currently active 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"}')},196:function(e,t){},2:function(e,t){e.exports=window.wc.wcSettings},219: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)}},237: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(127);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)}},25:function(e,t){e.exports=window.wc.priceFormat},251: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(79),u=r(543);r(196);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})))}},26:function(e,t){e.exports=window.wp.isShallowEqual},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(26),o=r.n(c);function l(e){const t=Object(n.useRef)(e);return o()(e,t.current)||(t.current=e),t.current}},404: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)},411:function(e,t,r){e.exports=r(479)},412: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},413:function(e,t){},414:function(e,t){},47: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},479: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(412),i=r(79),s=r(4),u=r.n(s),b=r(5),p=r(1),d=r(123),m=r(3),f=r(51),g=r(2),O=r(28),j=r(127),y=r(35),w=r(404),_=r(237),h=r(124);r(414);var v=r(219),k=r(25),E=r(251),S=r(17),x=r(543),N=(r(95),r(183));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(107),F=r(15),P=r(181),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(102),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(413),r(122)),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-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(26),a=r.n(l),i=r(40),s=r(103),u=r(47);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/active-filters/block.json
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
{
|
2 |
"name": "woocommerce/active-filters",
|
3 |
"version": "1.0.0",
|
4 |
-
"title": "Active
|
5 |
-
"description": "Display the currently active
|
6 |
"category": "woocommerce",
|
7 |
"keywords": [ "WooCommerce" ],
|
8 |
"supports": {
|
1 |
{
|
2 |
"name": "woocommerce/active-filters",
|
3 |
"version": "1.0.0",
|
4 |
+
"title": "Active Filters Controls",
|
5 |
+
"description": "Display the currently active filters.",
|
6 |
"category": "woocommerce",
|
7 |
"keywords": [ "WooCommerce" ],
|
8 |
"supports": {
|
build/all-products-frontend.asset.php
CHANGED
@@ -1 +1 @@
|
|
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' => '
|
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' => 'd0596e647926d13f6755ef101aca1213');
|
build/all-products-frontend.js
CHANGED
@@ -1,11 +1,11 @@
|
|
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(
|
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(
|
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:"406cf9fc0f6b923f2af6",1:"8b219ea55d106189f317",3:"00ed75d49bfd191e9ea6",6:"d34fe0e3162e759d04fa",10:"0ae89d1b23f08eced920",67:"fc1e5b6893a8756c1607",68:"9095dc4e4fc60afa0603",69:"1fd1f832a7258cf2730b",70:"317fba08818f5820440d",71:"47a255c4046177c620f1",72:"dedbfe381a255a14f58f",73:"ef42d0eedbd531008bbc",74:"63588538833019b59381",75:"5a443c9e9808d3f5e45c",76:"43e08d11779aebc77767",77:"2e23879268e2b54d7a63",78:"fb09be2eab32fdb10bdd"}[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=234)}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},102:function(e,t){e.exports=window.wp.blockEditor},105: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},115:function(e,t){},116:function(e,t,r){"use strict";var c=r(0),o=r(7),n=r.n(o),a=r(19),s=r(15);r(131),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},122:function(e,t){e.exports=window.wp.wordcount},123:function(e,t){e.exports=window.wp.autop},126: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}},128: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},131:function(e,t){},139: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,312)))}),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)},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},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},234:function(e,t,r){e.exports=r(259)},235:function(e,t){},236:function(e,t){},237:function(e,t){},259: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(237);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(274),g=r(64),E=r(91),h=r(46),w=r(29),f=r(105),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(116);r(236);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(139);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(235);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)})})},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}},27:function(e,t){e.exports=window.wp.deprecated},274: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(126),i=r(35),u=r(83);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(85),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(69);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)}}),[])}}},69: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})},[])}},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)}()},8:function(e,t){e.exports=window.lodash},83: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)}},85: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},91:function(e,t,r){"use strict";var c=r(13),o=r.n(c),n=r(0);r(115);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)}})))}},92: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-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' => '
|
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' => 'b5bfb9aea0c9b12c9fd5fa63a1fccb01');
|
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:"f51a0c24bc28ca163eaa",2:"
|
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}))}}
|
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(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},
|
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"),
|
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",
|
23 |
/* translators: %s number of products in cart. */
|
24 |
-
Object(l._n)("%d in cart","%d in cart",
|
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)}
|
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)(
|
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)(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)}]);
|
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:"dba577235c20b75e7fa2",3:"77ceebceae14b93fb596",4:"a560c499bb0ed0608f9a",19:"cc418a712d78761bdef8",21:"e49c04b592f121ef79c4",24:"f0d266d3795d8a94e323",25:"a1f60f6d1358a6eee1c2",28:"e955c561d90659818658",30:"3205c9b0a56dc845ca46",31:"1149385580498e21eda8",33:"844b0823eb1a2786fd67",34:"55750f0717a79a6947a4",35:"d3d8cbc8faf305c03db0",37:"4078709900ccc7a57ee3",38:"04bc04864cddc29d995e"}[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([386,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.wc.priceFormat},function(e,t){e.exports=window.wp.isShallowEqual},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(134),s=c(4),l=c.n(s);c(140);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(26),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(255),i=c(80),u=c(254);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):_,f=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:f,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(26),s=c.n(a),l=c(40),i=c(103),u=c(47);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(139),s=c(4),l=c.n(s),i=c(94);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,"d",(function(){return a})),c.d(t,"a",(function(){return s})),c.d(t,"b",(function(){return l}));var r=c(9),o=c(21);const n=(e,t)=>{if(o.n>2)return Object(r.registerBlockType)(e,t)},a=(e,t)=>{if(o.n>1)return Object(r.registerBlockType)(e,t)},s=()=>o.n>2,l=()=>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(25);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(132);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(148),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(163),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(187),p=c(24),m=c.n(p),g=c(26),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),f=c(4),w=c.n(f),k=c(82);c(141);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 f=[...m,...h&&h[t]?h[t]:[]];return Object(n.createElement)(i.a,{className:"woocommerce-products",list:f,isCompact:u,isLoading:d,isSingle:!0,selected:f.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=w()("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:w()(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(132);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(79),i=c(520),u=c(4),d=c.n(u),b=c(11),p=c(19),m=c(37),g=c(519),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,f=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)},f):Object(n.createElement)("span",{className:"woocommerce-tag__text",id:E},f),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},f=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)},w=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)(f,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)(w,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(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(10),o=c(7),n=c(0),a=c(40),s=c(143);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(79),a=c(231),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";c.d(t,"c",(function(){return s})),c.d(t,"b",(function(){return l})),c.d(t,"a",(function(){return i}));var r=c(0),o=c(1),n=c(79),a=c(347);const s=Object(o.__)("Product Summary","woo-gutenberg-products-block"),l=Object(r.createElement)(n.a,{icon:a.a,className:"wc-block-editor-components-block-icon"}),i=Object(o.__)("Display a short description about a product.","woo-gutenberg-products-block")},,function(e,t,c){"use strict";c.d(t,"c",(function(){return s})),c.d(t,"b",(function(){return l})),c.d(t,"a",(function(){return i}));var r=c(0),o=c(1),n=c(79),a=c(346);const s=Object(o.__)("Product Title","woo-gutenberg-products-block"),l=Object(r.createElement)(n.a,{icon:a.a,className:"wc-block-editor-components-block-icon"}),i=Object(o.__)("Display the title of a product.","woo-gutenberg-products-block")},,,,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(165),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(128),s=c(132);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(156),u=c(98),d=c(86),b=c(133),p=c(42);c(256);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(188),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(132);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(117),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(68),d=c(98),b=c(133),p=c(86);c(257);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),f=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,...f.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,...f.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(156),p=c(133),m=c(42),g=c(68),O=c(142);c(259);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)(),f=Object(d.a)(e),w=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},w.className),style:{...f.style,...w.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},w.className),style:{...f.style,...w.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(353),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:f,SET_NO_ERROR:w,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?f:w;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:A,SET_HAS_ERROR:R,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 A: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 R: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(263);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(310),$=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:f}=e;const[w,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),A=Object(r.useMemo)(()=>({onAddToCartAfterProcessingWithSuccess:U(N).onAddToCartAfterProcessingWithSuccess,onAddToCartAfterProcessingWithError:U(N).onAddToCartAfterProcessingWithError,onAddToCartBeforeProcessing:U(N).onAddToCartBeforeProcessing}),[N]),R=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=w.status,t=!g.id||!Object(l.a)(g);e!==d.DISABLED||t?e!==d.DISABLED&&t&&C({type:O}):C(v())},[w.status,g,C]),Object(r.useEffect)(()=>{w.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})}))},[w.status,I,T,C,P,null==g?void 0:g.id]),Object(r.useEffect)(()=>{if(w.status===d.AFTER_PROCESSING){const e={processingResponse:w.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(w.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())})}},[w.status,w.hasError,w.processingResponse,R,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:f&&B,quantity:w.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:w.requestParams,isIdle:w.status===d.IDLE,isDisabled:w.status===d.DISABLED,isProcessing:w.status===d.PROCESSING,isBeforeProcessing:w.status===d.BEFORE_PROCESSING,isAfterProcessing:w.status===d.AFTER_PROCESSING,hasError:w.hasError,eventRegistration:A,dispatchActions:R};return Object(r.createElement)(K.Provider,{value:L},p)};var Z=c(14),ee=c.n(Z),te=c(15),ce=c(254),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(232),c(59)),ue=c(79),de=c(537),be=c(68),pe=c(166);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(117),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))},fe=(c(262),c(555)),we=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(we.useEffect)(()=>{o?p(d):b({[d]:{message:l,hidden:!0}})},[o,d,l,p,b]),Object(we.useEffect)(()=>()=>{p(d)},[d,p]),Object(r.createElement)("div",{className:"wc-block-components-product-add-to-cart-attribute-picker__container"},Object(r.createElement)(fe.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(539),Ae=()=>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."),Re=()=>Object(r.createElement)(Ae,null);const Be=()=>{const{showFormElements:e,productType:t}=J();return e?"variable"===t?Object(r.createElement)(Pe,null):"grouped"===t?Object(r.createElement)(Re,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(77),s=c(25),l=c(23),i=c(98),u=c(86),d=c(42);c(258);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,f=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:f,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(133),d=c(42),b=c(148);c(260);const p=e=>{const{textAlign:t}=e,{parentClassName:c}=Object(s.useInnerBlockLayoutContext)(),{product:n}=Object(s.useProductDataContext)(),d=(e=>{const t=parseFloat(e.average_rating);return Number.isFinite(t)&&t>0?t:0})(n),p=Object(l.a)(e),m=Object(i.a)(e),g=Object(u.a)(e);if(!d)return null;const O={width:d/5*100+"%"},j=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"),d),h=(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})(n),_={__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",h,"woo-gutenberg-products-block"),Object(o.sprintf)('<strong class="rating">%f</strong>',d),Object(o.sprintf)('<span class="rating">%d</span>',h))};return Object(r.createElement)("div",{className:a()(p.className,"wc-block-components-product-rating",{[c+"__product-rating"]:c},{["has-text-align-"+t]:t}),style:{...p.style,...m.style,...g.style}},Object(r.createElement)("div",{className:a()("wc-block-components-product-rating__stars",c+"__product-rating__stars"),role:"img","aria-label":j},Object(r.createElement)("span",{style:O,dangerouslySetInnerHTML:_})))};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(166),d=c(98),b=c(156),p=c(86),m=c(133),g=c(15),O=c(21),j=c(2),h=c(23),_=c(42);c(261);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),{textAlign:u}=e;return Object(n.createElement)("div",{className:s()(t,"wp-block-button","wc-block-components-product-button",{[c+"__product-add-to-cart"]:c},{["has-text-align-"+u]:u})},r.id?Object(n.createElement)(f,{product:r,colorStyles:o,borderStyles:a,typographyStyles:l,spacingStyles:i}):Object(n.createElement)(w,{colorStyles:o,borderStyles:a,typographyStyles:l,spacingStyles:i}))},f=e=>{let{product:t,colorStyles:c,borderStyles:r,typographyStyles:a,spacingStyles:d,textAlign:b}=e;const{id:p,permalink:m,add_to_cart:h,has_options:_,is_purchasable:E,is_in_stock:f}=t,{dispatchStoreEvent:w}=Object(i.a)(),{cartQuantity:k,addingToCart:y,addToCart:v}=Object(u.a)(p,"woocommerce/single-product/"+(p||0)),S=Number.isFinite(k)&&k>0,C=!_&&E&&f,x=Object(g.decodeEntities)((null==h?void 0:h.description)||""),N=S?Object(l.sprintf)(
|
23 |
/* translators: %s number of products in cart. */
|
24 |
+
Object(l._n)("%d in cart","%d in cart",k,"woo-gutenberg-products-block"),k):Object(g.decodeEntities)((null==h?void 0:h.text)||Object(l.__)("Add to cart","woo-gutenberg-products-block")),P=C?"button":"a",T={};return C?T.onClick=async()=>{await v(),w("cart-add-item",{product:t});const{cartRedirectAfterAdd:e}=Object(j.getSetting)("productsSettings");e&&(window.location.href=O.d)}:(T.href=m,T.rel="nofollow",T.onClick=()=>{w("product-view-link",{product:t})}),Object(n.createElement)(P,o()({"aria-label":x,className:s()("wp-block-button__link","wp-element-button","add_to_cart_button","wc-block-components-product-button__button",c.className,r.className,{loading:y,added:S},{["has-text-align-"+b]:b}),style:{...c.style,...r.style,...a.style,...d.style},disabled:y},T),N)},w=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(107),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){},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(119),s=c(21),l=c(23),i=c(98),u=c(86),d=c(42);c(348),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(349),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(350),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(351),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(352);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(474)},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 ot})),c.d(t,"name",(function(){return Yt}));var r=c(0),o=c(9),n=c(79),a=c(531),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(308),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=_,f=c(193),w=c(96),k=c(153),y=c(23);c(387);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)(w.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(115);c(388);const C=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)(f.b,t)))};var x=Object(s.b)()?Object(m.compose)([v({icon:S.b,label:S.c,description:Object(l.__)("Choose a product to display its title.","woo-gutenberg-products-block")})])(C):C,N=c(128);const P={...d,apiVersion:2,title:S.c,description:S.a,icon:{src:S.b},attributes:b.a,edit:x,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(N.a)()&&{spacing:{margin:!0,__experimentalSkipSerialization:!0}},__experimentalSelector:".wc-block-components-product-title"}}};Object(o.registerBlockType)("woocommerce/product-title",P);var T=c(13),I=c(206),A=c(532);const R=Object(l.__)("Product Price","woo-gutenberg-products-block"),B=Object(r.createElement)(n.a,{icon:A.a,className:"wc-block-editor-components-block-icon"}),L=Object(l.__)("Display the price of a product.","woo-gutenberg-products-block");var D=v({icon:B,label:R,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},s=Number.isFinite(o.queryId);return Object(T.useEffect)(()=>c({isDescendentOfQueryLoop:s}),[c,s]),Object(r.createElement)(r.Fragment,null,Object(r.createElement)(g.BlockControls,null,s&&Object(r.createElement)(g.AlignmentToolbar,{value:t.textAlign,onChange:e=>{c({textAlign:e})}})),Object(r.createElement)("div",n,Object(r.createElement)(I.default,a)))});const F={...d,apiVersion:2,title:R,description:L,ancestor:["@woocommerce/all-products","@woocommerce/single-product","core/post-template"],usesContext:["query","queryId","postId"],icon:{src:B},attributes:{productId:{type:"number",default:0},isDescendentOfQueryLoop:{type:"boolean",default:!1},textAlign:{type:"string"}},edit:D,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",F);var V=c(6),z=c.n(V),M=c(2),q=c(127),H=c(194),Q=c(533);const G=Object(l.__)("Product Image","woo-gutenberg-products-block"),Y=Object(r.createElement)(n.a,{icon:Q.a,className:"wc-block-editor-components-block-icon"}),U=Object(l.__)("Display the main product image.","woo-gutenberg-products-block");var W=v({icon:Y,label:G,description:U})(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(M.getSettingWithCoercion)("is_block_theme_enabled",!1,q.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(M.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)(H.b,z()({},t,o))))});const $={html:!1,...Object(s.b)()&&{__experimentalBorder:{radius:!0,__experimentalSkipSerialization:!0},typography:{fontSize:!0,__experimentalSkipSerialization:!0},...Object(N.a)()&&{spacing:{margin:!0,__experimentalSkipSerialization:!0}},__experimentalSelector:".wc-block-components-product-image"}};var K=c(309);const J={...d,apiVersion:2,name:"woocommerce/product-image",title:G,icon:{src:Y},keywords:["WooCommerce"],description:U,usesContext:["query","queryId","postId"],ancestor:["@woocommerce/all-products","@woocommerce/single-product","core/post-template"],textdomain:"woo-gutenberg-products-block",attributes:K.a,supports:$,edit:W};Object(o.registerBlockType)("woocommerce/product-image",{...J});var X=c(207),Z=c(527);const ee=Object(l.__)("Product Rating","woo-gutenberg-products-block"),te=Object(r.createElement)(n.a,{icon:Z.a,className:"wc-block-editor-components-block-icon"}),ce=Object(l.__)("Display the average rating of a product.","woo-gutenberg-products-block");var re=v({icon:te,label:ee,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(T.useEffect)(()=>c({isDescendentOfQueryLoop:s}),[c,s]),Object(r.createElement)(r.Fragment,null,Object(r.createElement)(g.BlockControls,null,s&&Object(r.createElement)(g.AlignmentToolbar,{value:t.textAlign,onChange:e=>{c({textAlign:e||""})}})),Object(r.createElement)("div",n,Object(r.createElement)(X.default,a)))});const oe={apiVersion:2,title:ee,description:ce,usesContext:["query","queryId","postId"],ancestor:["@woocommerce/all-products","@woocommerce/single-product","core/post-template"],icon:{src:te},attributes:{productId:{type:"number",default:0},isDescendentOfQueryLoop:{type:"boolean",default:!1},textAlign:{type:"string",default:""}},supports:{...Object(s.b)()&&{color:{text:!0,background:!1,link:!1,__experimentalSkipSerialization:!0},typography:{fontSize:!0,__experimentalSkipSerialization:!0},...Object(N.a)()&&{spacing:{margin:!0,__experimentalSkipSerialization:!0}},__experimentalSelector:".wc-block-components-product-rating"}},edit:re};Object(o.registerBlockType)("woocommerce/product-rating",{...d,...oe});var ne=c(208),ae=c(534);const se=Object(l.__)("Add to Cart Button","woo-gutenberg-products-block"),le=Object(r.createElement)(n.a,{icon:ae.a,className:"wc-block-editor-components-block-icon"}),ie={apiVersion:2,title:se,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:le},attributes:{productId:{type:"number",default:0},isDescendentOfQueryLoop:{type:"boolean",default:!1},textAlign:{type:"string",default:""}},supports:{...Object(s.b)()&&{color:{text:!0,background:!0,link:!1,__experimentalSkipSerialization:!0},__experimentalBorder:{radius:!0,__experimentalSkipSerialization:!0},...Object(N.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)(r.Fragment,null,Object(r.createElement)(g.BlockControls,null,a&&Object(r.createElement)(g.AlignmentToolbar,{value:t.textAlign,onChange:e=>{c({textAlign:e||""})}})),Object(r.createElement)("div",n,Object(r.createElement)(p.Disabled,null,Object(r.createElement)(ne.default,z()({},t,o)))))}};Object(o.registerBlockType)("woocommerce/product-button",{...d,...ie});var ue=c(320),de=c(113);c(389);var be=v({icon:de.b,label:de.c,description:de.a})(e=>{let{attributes:t}=e;const c=Object(g.useBlockProps)();return Object(r.createElement)("div",c,Object(r.createElement)(ue.default,t))});const pe={...Object(s.b)()&&{color:{background:!1},typography:{fontSize:!0},__experimentalSelector:".wc-block-components-product-summary"}},me={...d,apiVersion:2,title:de.c,description:de.a,icon:{src:de.b},attributes:{productId:{type:"number",default:0}},supports:pe,edit:be,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",me);var ge=c(142),Oe=c(525);const je=Object(l.__)("On-Sale Badge","woo-gutenberg-products-block"),he=Object(r.createElement)(n.a,{icon:Oe.a,className:"wc-block-editor-components-block-icon"}),_e=Object(l.__)("Displays an on-sale badge if the product is on-sale.","woo-gutenberg-products-block");var Ee=v({icon:he,label:je,description:_e})(e=>{let{attributes:t,setAttributes:c,context:o}=e;const n=Object(g.useBlockProps)(),a={...t,...o},s=Number.isFinite(o.queryId);return Object(T.useEffect)(()=>c({isDescendentOfQueryLoop:s}),[c,s]),Object(r.createElement)("div",n,Object(r.createElement)(ge.default,a))});const fe={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(N.a)()&&{spacing:{padding:!0,__experimentalSkipSerialization:!0}},__experimentalSelector:".wc-block-components-product-sale-badge"}},we={...d,title:je,description:_e,icon:{src:he},apiVersion:2,supports:fe,attributes:{productId:{type:"number",default:0},isDescendentOfQueryLoop:{type:"boolean",default:!1}},edit:Ee,usesContext:["query","queryId","postId"],ancestor:["@woocommerce/all-products","@woocommerce/single-product","core/post-template"]};Object(o.registerBlockType)("woocommerce/product-sale-badge",{...we});var ke=c(108),ye=c(321),ve=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 Se=Object(l.__)("Product SKU","woo-gutenberg-products-block"),Ce=Object(r.createElement)(n.a,{icon:ve,className:"wc-block-editor-components-block-icon"}),xe={apiVersion:2,title:Se,description:Object(l.__)("Display the SKU of a product.","woo-gutenberg-products-block"),icon:{src:Ce},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:Ce,label:Se,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(T.useEffect)(()=>c({isDescendentOfQueryLoop:a}),[c,a]),Object(r.createElement)(r.Fragment,null,Object(r.createElement)(ke.a,null),Object(r.createElement)(ye.default,n))})};Object(s.d)("woocommerce/product-sku",{...d,...xe});var Ne=c(322),Pe=c(535);const Te=Object(l.__)("Product Category List","woo-gutenberg-products-block"),Ie=Object(r.createElement)(n.a,{icon:Pe.a,className:"wc-block-editor-components-block-icon"}),Ae=Object(l.__)("Display the list of categories that are assigned to a product.","woo-gutenberg-products-block");var Re=v({icon:Ie,label:Te,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)(ke.a,null),Object(r.createElement)(p.Disabled,null,Object(r.createElement)(Ne.default,t)))});const Be={...d,apiVersion:2,title:Te,description:Ae,icon:{src:Ie},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:Re};Object(s.c)("woocommerce/product-category-list",Be);var Le=c(323),De=c(530);const Fe=Object(l.__)("Product Tag List","woo-gutenberg-products-block"),Ve=Object(r.createElement)(n.a,{icon:De.a,className:"wc-block-editor-components-block-icon"}),ze=Object(l.__)("Display the list of tags that are assigned to a product.","woo-gutenberg-products-block");var Me=v({icon:Ve,label:Fe,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)(ke.a,null),Object(r.createElement)(p.Disabled,null,Object(r.createElement)(Le.default,t)))});const qe={...Object(s.b)()&&{color:{text:!0,background:!1,link:!0},typography:{fontSize:!0},__experimentalSelector:".wc-block-components-product-tag-list"}},He={...d,apiVersion:2,title:Fe,description:ze,icon:{src:Ve},attributes:{productId:{type:"number",default:0}},supports:qe,edit:Me,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,...He});var Qe=c(324),Ge=c(536);const Ye=Object(l.__)("Product Stock Indicator","woo-gutenberg-products-block"),Ue=Object(r.createElement)(n.a,{icon:Ge.a,className:"wc-block-editor-components-block-icon"}),We=Object(l.__)("Display product stock status.","woo-gutenberg-products-block");var $e=v({icon:Ue,label:Ye,description:We})(e=>{let{attributes:t,setAttributes:c,context:o}=e;const n=Object(g.useBlockProps)(),a={...t,...o},s=Number.isFinite(o.queryId);return Object(T.useEffect)(()=>c({isDescendentOfQueryLoop:s}),[c,s]),Object(r.createElement)("div",n,Object(r.createElement)(ke.a,null),Object(r.createElement)(Qe.default,a))});const Ke={...Object(s.b)()&&{color:{text:!0,background:!1,link:!1},typography:{fontSize:!0},__experimentalSelector:".wc-block-components-product-stock-indicator"}},Je={...d,apiVersion:2,title:Ye,description:We,icon:{src:Ue},attributes:{productId:{type:"number",default:0},isDescendentOfQueryLoop:{type:"boolean",default:!1}},supports:Ke,edit:$e,usesContext:["query","queryId","postId"],ancestor:["@woocommerce/all-products","@woocommerce/single-product","core/post-template"]};Object(s.d)("woocommerce/product-stock-indicator",{...Je});var Xe=c(353),Ze=(c(232),c(205)),et=c(273);const tt=Object(l.__)("Add to Cart","woo-gutenberg-products-block"),ct=Object(r.createElement)(n.a,{icon:et.a,className:"wc-block-editor-components-block-icon"}),rt={title:tt,description:Object(l.__)("Displays an add to cart button. Optionally displays other add to cart form elements.","woo-gutenberg-products-block"),icon:{src:ct},edit:v({icon:ct,label:tt,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)(ke.a,{productId:o.id}),Object(r.createElement)(g.InspectorControls,null,Object(r.createElement)(p.PanelBody,{title:Object(l.__)("Layout","woo-gutenberg-products-block")},Object(Xe.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)(Ze.a,t)))}),attributes:c(311).a};Object(s.c)("woocommerce/product-add-to-cart",{...d,...rt});var ot=c(218);const nt=(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:at}=ot;var st=[{attributes:Object.assign({},at,{rows:{type:"number",default:1}}),save(e){let{attributes:t}=e;const c={"data-attributes":JSON.stringify(t)};return Object(r.createElement)("div",z()({className:nt("wc-block-all-products",t)},c),Object(r.createElement)(g.InnerBlocks.Content,null))}}],lt=c(24),it=c.n(lt),ut=c(7),dt=c(64),bt=c(505),pt=c(376),mt=c(21),gt=c(231);const Ot=[["woocommerce/product-image",{imageSizing:"cropped"}],["woocommerce/product-title"],["woocommerce/product-price"],["woocommerce/product-rating"],["woocommerce/product-button"]],jt=e=>e&&0!==e.length?e.map(e=>[e.name,{...e.attributes,product:void 0,children:e.innerBlocks.length>0?jt(e.innerBlocks):[]}]):[];var ht=c(28);c(395);var _t=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)(ht.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)(ht.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)(ht.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)(ht.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)(ht.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)(ht.a,{label:"→",screenReaderLabel:Object(l.__)("Next page","woo-gutenberg-products-block")})))},Et=c(103),ft=c(51),wt=c(240),kt=c(68);c(396);const yt=e=>{if(!e)return;const t=e.getBoundingClientRect().bottom;t>=0&&t<=window.innerHeight||e.scrollIntoView()};var vt=c(44),St=c(184),Ct=()=>{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:St.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")))},xt=c(529),Nt=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:xt.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")))},Pt=c(121);c(394);var Tt=e=>{let{onChange:t,value:c}=e;return Object(r.createElement)(Pt.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 It=(e,t,c,o)=>{if(!c)return;const n=Object(bt.a)(e);return c.map((c,a)=>{let[s,l={}]=c,i=[];l.children&&l.children.length>0&&(i=It(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,z()({},l,{children:i,product:t})))})};var At=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},It(s,t,n,o))});c(393);const Rt=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"}}},Bt=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 Lt,Dt=(Lt=e=>{let{attributes:t,currentPage:c,onPageChange:o,onSortChange:n,sortValue:a,scrollToTop:s}=e;const[i,d]=Object(ft.b)("attributes",[]),[b,p]=Object(ft.b)("stock_status",[]),[m,g]=Object(ft.b)("rating",[]),[j,h]=Object(ft.b)("min_price"),[_,E]=Object(ft.b)("max_price"),[f]=Object(ft.c)((e=>{let{sortValue:t,currentPage:c,attributes:r}=e;const{columns:o,rows:n}=r;return{...Rt(t),catalog_visibility:"catalog",per_page:o*n,page:c}})({attributes:t,sortValue:a,currentPage:c})),{products:w,totalProducts:k,productsLoading:v}=Object(wt.a)(f),{parentClassName:S,parentName:C}=Object(y.useInnerBlockLayoutContext)(),x=(e=>{const{order:t,orderby:c,page:r,per_page:o,...n}=e;return n||{}})(f),{dispatchStoreEvent:N}=Object(kt.a)(),P=Object(Et.a)({totalQuery:x,totalProducts:k},Bt);Object(r.useEffect)(()=>{N("product-list-render",{products:w,listName:C})},[w,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(vt.speak)(Object(l.__)("No products found","woo-gutenberg-products-block")):Object(vt.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,A=!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),R=w.length?w:Array.from({length:I}),B=0!==w.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)(Tt,{onChange:n,value:a}),!B&&L&&Object(r.createElement)(Nt,{resetCallback:()=>{d([]),p([]),g([]),h(null),E(null)}}),!B&&!L&&Object(r.createElement)(Ct,null),B&&Object(r.createElement)("ul",{className:u()(S+"__products",{"is-loading-products":v})},R.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)(At,{key:e.id||c,attributes:t,product:e})}))),A>1&&Object(r.createElement)(_t,{currentPage:c,onPageChange:e=>{s({focusableSelector:"a, button"}),o(e)},totalPages:A}))},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)(Lt,z()({},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];yt(e),null==e||e.focus()}else yt(e)})(e,c):yt(e))})(t.current,e)}})))}),Ft=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)(Dt,{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})},Vt=c(152),zt=c(16);class Mt extends T.Component{render(){const{attributes:e,urlParameterSuffix:t}=this.props;return e.isPreview?Vt.a:Object(r.createElement)(y.InnerBlockLayoutContextProvider,{parentName:"woocommerce/all-products",parentClassName:"wc-block-grid"},Object(r.createElement)(zt.StoreNoticesContainer,{context:"wc/all-products"}),Object(r.createElement)(Ft,{attributes:e,urlParameterSuffix:t}))}}var qt=Mt;c(392);class Ht extends r.Component{constructor(){super(...arguments),it()(this,"state",{isEditing:!1,innerBlocks:[]}),it()(this,"blockMap",Object(bt.a)("woocommerce/all-products")),it()(this,"componentDidMount",()=>{const{block:e}=this.props;this.setState({innerBlocks:e.innerBlocks})}),it()(this,"getTitle",()=>Object(l.__)("All Products","woo-gutenberg-products-block")),it()(this,"getIcon",()=>Object(r.createElement)(n.a,{icon:a.a})),it()(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"))}),it()(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)(dt.a,{columns:c,rows:o,alignButtons:n,setAttributes:t,minColumns:Object(M.getSetting)("min_columns",1),maxColumns:Object(M.getSetting)("max_columns",6),minRows:Object(M.getSetting)("min_rows",1),maxRows:Object(M.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)))}),it()(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}]}))}),it()(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:pt.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:jt(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=[];Ot.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")))))}),it()(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)(qt,{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)}),it()(this,"render",()=>{const{attributes:e}=this.props,{isEditing:t}=this.state,c=this.getTitle(),o=this.getIcon();return 0===mt.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:M.ADMIN_URL+"post-new.php?post_type=product"},Object(l.__)("Add new product","woo-gutenberg-products-block")+" ",Object(r.createElement)(n.a,{icon:gt.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:nt("wc-block-all-products",e)},this.getBlockControls(),this.getInspectorControls(),t?this.renderEditMode():this.renderViewMode())})}}var Qt=Object(m.compose)(p.withSpokenMessages,Object(ut.withSelect)((e,t)=>{let{clientId:c}=t;const{getBlock:r}=e("core/block-editor");return{block:r(c)}}),Object(ut.withDispatch)(e=>{const{replaceInnerBlocks:t}=e("core/block-editor");return{replaceInnerBlocks:t}}))(Ht),Gt={columns:Object(M.getSetting)("default_columns",3),rows:Object(M.getSetting)("default_rows",3),alignButtons:!1,contentVisibility:{orderBy:!0},orderby:"date",layoutConfig:Ot,isPreview:!1};const{name:Yt}=ot,Ut={icon:{src:Object(r.createElement)(n.a,{icon:a.a,className:"wc-block-editor-components-block-icon"})},edit:Qt,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",z()({className:nt("wc-block-all-products",t)},o),Object(r.createElement)(g.InnerBlocks.Content,null))},deprecated:st,defaults:Gt};Object(o.registerBlockType)(Yt,Ut)},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,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,206)))}),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,559)))}),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,560)))}),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,207)))}),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,208)))}),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,320)))}),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,142)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-sku",component:Object(o.lazy)(()=>c.e(33).then(c.bind(null,321)))}),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,322)))}),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,323)))}),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,324)))}),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,561)))});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' => 'cb2d12e733ead15bb5937f1b9c55ec6a');
|
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}]}}},
|
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}});
|
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([377,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}))},118:function(e,t){},12:function(e,t){e.exports=window.wp.primitives},121:function(e,t,r){"use strict";var o=r(0),n=r(4),c=r.n(n),a=r(28),i=r(11);r(165),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))))})},13:function(e,t){e.exports=window.React},131: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}]}}},14:function(e,t){e.exports=window.wp.apiFetch},15:function(e,t){e.exports=window.wp.htmlEntities},154: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}}},155:function(e,t,r){"use strict";var o=r(6),n=r.n(o),c=r(0),a=r(5),i=(r(164),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)))}},158: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(192);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(121);r(189);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(178),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(191);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(190);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(26),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}))}},164:function(e,t){},165:function(e,t){},189:function(e,t){},190:function(e,t){},191:function(e,t){},192: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",{})},26: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},377:function(e,t,r){e.exports=r(497)},497:function(e,t,r){"use strict";r.r(t);var o=r(0),n=r(1),c=r(9),a=r(79),i=r(528),s=(r(164),r(5)),l=r(3),d=r(158),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(154),p=r(155),m=r(131);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(79),a=r(184),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},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' => '67cb62931141b44c1a205d9fffc67e5e');
|
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=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(
|
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(
|
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}
|
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,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(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(
|
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=240)}([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(97))},,,,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(117);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(69);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(130),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(93),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(94),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(95),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(110),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(132),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(89),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(145),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(214)},,,,,,,,,function(e,t,n){"use strict";var r=n(0),o=n(1),s=n(270),i=n(26),c=n(56),a=n(30),l=n(55),u=n(129),d=n(57),p=n(62),f=n(63),b=n(12),m=n.n(b),h=n(22),g=n(276),O=n(2),v=n(11),j=n(68),w=n(28),y=n(20),E=n(219),k=n(105),_=n(279),S=n(66),x=n(8),T=n(13),C=n.n(T),L=n(281),I=n(7),A=n.n(I);n(220);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(112),N=n(106);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(218);var D=n(47),V=n(88),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(92);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(215);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(241)},function(e,t,n){"use strict";n.r(t);var r=n(44),o=n(154),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(102),o=n(210),s=n(20),i=n(211);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(132),u=n(90);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(278),f=n(90),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(143),g=n(144),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],{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,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(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}},
|
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(
|
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(
|
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},
|
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)}},
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[15],{106: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}},110:function(e,t){},112: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)}},117: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"}')},129:function(e,t,n){"use strict";n.d(t,"a",(function(){return b}));var r=n(0),c=n(89),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})}},130:function(e,t){},154:function(e,t,n){"use strict";var r=n(0),c=n(1),a=n(270),o=n(26),s=n(56),l=n(30),u=n(55),i=n(129),b=n(57),d=n(62),f=n(63),m=n(12),O=n.n(m),j=n(22),p=n(276),g=n(2),y=n(11),h=n(68),v=n(28),w=n(20),_=n(219),E=n(105),k=n(279),S=n(66),x=n(8),C=n(13),N=n.n(C),T=n(281),A=n(7),L=n.n(A);n(220);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(112),I=n(106);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(218);var Q=n(47),V=n(88),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}},210:function(e,t,n){"use strict";n.d(t,"a",(function(){return c})),n(92);var r=n(42);const c=()=>r.m>1},211: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:{}},218:function(e,t){},219: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)},220: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}},270:function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(102),c=n(210),a=n(20),o=n(211);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},287:function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(102),c=n(210),a=n(20),o=n(211);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(287),a=n(28),o=n(154),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(117);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(69);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(130),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(93),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(94),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(95),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},69: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})},[])}},88:function(e,t,n){"use strict";var r=n(0),c=n(1),a=n(7),o=n.n(a),s=n(9);n(110),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)}},93:function(e,t){},94:function(e,t){},95: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' => '14c28d3646a225396646e569d31b1902');
|
build/attribute-filter.js
CHANGED
@@ -1,18 +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 |
/* 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},
|
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}))}},
|
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}))}},
|
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},
|
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,7 +22,7 @@ Object(m.__)("%s filter removed.","woo-gutenberg-products-block"),b.label),remov
|
|
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(
|
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(
|
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)}});
|
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([401,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},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(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}},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(10),c=n(7),o=n(0),l=n(40),a=n(143);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(275),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},122: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"))}},123:function(e,t,n){"use strict";var r=n(0),c=n(5),o=n(11),l=n(1);n(167),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}))})},124:function(e,t,n){"use strict";var r=n(0);n(168),t.a=e=>{let{children:t}=e;return Object(r.createElement)("div",{className:"wc-block-filter-title-placeholder"},t)}},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,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}))}},126:function(e,t,n){"use strict";var r=n(0),c=n(1),o=n(4),l=n.n(o),a=n(28);n(170),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}))}},127: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},132: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:{}},143: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})},[])}},15:function(e,t){e.exports=window.wp.htmlEntities},150: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"}')},156: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(132);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})}},157:function(e,t,n){"use strict";var r=n(0),c=n(1),o=n(4),l=n.n(o),a=n(16);n(195),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},167:function(e,t){},168:function(e,t){},169:function(e,t){},17:function(e,t){e.exports=window.wp.url},170:function(e,t){},181: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()},195: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",{})},219: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)}},237: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(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)}},26:function(e,t){e.exports=window.wp.isShallowEqual},274:function(e,t,n){"use strict";n.d(t,"a",(function(){return b}));var r=n(0),c=n(253),o=n(8),l=n(40),a=n(35),s=n(51),i=n(107),u=n(47);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})}},275: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},40:function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(0),c=n(26),o=n.n(c);function l(e){const t=Object(r.useRef)(e);return o()(e,t.current)||(t.current=e),t.current}},401:function(e,t,n){e.exports=n(481)},402:function(e,t){},403:function(e,t){},404: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)},405:function(e,t){},44:function(e,t){e.exports=window.wp.a11y},47: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},481: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(79),u=n(526),b=n(4),d=n.n(b),m=n(1),p=n(231),g=n(99),O=n(8),j=n(2),f=n(123),w=n(3),h=n(156),_=n(40),y=n(103),k=n(51),E=n(107),v=n(274),S=n(111),C=n(125),x=n(126),N=n(26),T=n.n(N),A=n(15),R=n(540),P=n(17),B=n(127),L=n(95),I=n(35),F=n(404),q=n(542),G=n(237),M=n(557);n(405);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(219),$=n(181);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(403);var W=n(150);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(157),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)(
|
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(402),n(122));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(26),a=n.n(l),s=n(40),i=n(103),u=n(47);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,"d",(function(){return l})),n.d(t,"a",(function(){return a})),n.d(t,"b",(function(){return s}));var r=n(9),c=n(21);const o=(e,t)=>{if(c.n>2)return Object(r.registerBlockType)(e,t)},l=(e,t)=>{if(c.n>1)return Object(r.registerBlockType)(e,t)},a=()=>c.n>2,s=()=>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(79),i=n(520),u=n(4),b=n.n(u),d=n(11),m=n(19),p=n(37),g=n(519),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/cart-blocks/cart-accepted-payment-methods-frontend.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[17],{26:function(e,t,a){"use strict";a.d(t,"a",(function(){return o}));var s=a(0),n=a(12),c=a.n(n);function o(e){const t=Object(s.useRef)(e);return c()(e,t.current)||(t.current=e),t.current}},
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[17],{26:function(e,t,a){"use strict";a.d(t,"a",(function(){return o}));var s=a(0),n=a(12),c=a.n(n);function o(e){const t=Object(s.useRef)(e);return c()(e,t.current)||(t.current=e),t.current}},303:function(e,t){},308:function(e,t,a){"use strict";a.d(t,"b",(function(){return l})),a.d(t,"a",(function(){return r}));var s=a(26),n=a(17),c=a(5),o=a(3);const i=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{paymentMethodsInitialized:t,expressPaymentMethodsInitialized:a,availablePaymentMethods:i,availableExpressPaymentMethods:l}=Object(c.useSelect)(e=>{const t=e(o.PAYMENT_STORE_KEY);return{paymentMethodsInitialized:t.paymentMethodsInitialized(),expressPaymentMethodsInitialized:t.expressPaymentMethodsInitialized(),availableExpressPaymentMethods:t.getAvailableExpressPaymentMethods(),availablePaymentMethods:t.getAvailablePaymentMethods()}}),r=Object.values(i).map(e=>{let{name:t}=e;return t}),d=Object.values(l).map(e=>{let{name:t}=e;return t}),m=Object(n.getPaymentMethods)(),p=Object(n.getExpressPaymentMethods)(),u=Object.keys(m).reduce((e,t)=>(r.includes(t)&&(e[t]=m[t]),e),{}),y=Object.keys(p).reduce((e,t)=>(d.includes(t)&&(e[t]=p[t]),e),{}),h=Object(s.a)(u),b=Object(s.a)(y);return{paymentMethods:e?b:h,isInitialized:e?a:t}},l=()=>i(!1),r=()=>i(!0)},310:function(e,t,a){"use strict";var s=a(13),n=a.n(s),c=a(0),o=a(7),i=a.n(o);const l=e=>"wc-block-components-payment-method-icon wc-block-components-payment-method-icon--"+e;var r=e=>{let{id:t,src:a=null,alt:s=""}=e;return a?Object(c.createElement)("img",{className:l(t),src:a,alt:s}):null},d=a(42);const m=[{id:"alipay",alt:"Alipay",src:d.l+"payment-methods/alipay.svg"},{id:"amex",alt:"American Express",src:d.l+"payment-methods/amex.svg"},{id:"bancontact",alt:"Bancontact",src:d.l+"payment-methods/bancontact.svg"},{id:"diners",alt:"Diners Club",src:d.l+"payment-methods/diners.svg"},{id:"discover",alt:"Discover",src:d.l+"payment-methods/discover.svg"},{id:"eps",alt:"EPS",src:d.l+"payment-methods/eps.svg"},{id:"giropay",alt:"Giropay",src:d.l+"payment-methods/giropay.svg"},{id:"ideal",alt:"iDeal",src:d.l+"payment-methods/ideal.svg"},{id:"jcb",alt:"JCB",src:d.l+"payment-methods/jcb.svg"},{id:"laser",alt:"Laser",src:d.l+"payment-methods/laser.svg"},{id:"maestro",alt:"Maestro",src:d.l+"payment-methods/maestro.svg"},{id:"mastercard",alt:"Mastercard",src:d.l+"payment-methods/mastercard.svg"},{id:"multibanco",alt:"Multibanco",src:d.l+"payment-methods/multibanco.svg"},{id:"p24",alt:"Przelewy24",src:d.l+"payment-methods/p24.svg"},{id:"sepa",alt:"Sepa",src:d.l+"payment-methods/sepa.svg"},{id:"sofort",alt:"Sofort",src:d.l+"payment-methods/sofort.svg"},{id:"unionpay",alt:"Union Pay",src:d.l+"payment-methods/unionpay.svg"},{id:"visa",alt:"Visa",src:d.l+"payment-methods/visa.svg"},{id:"wechat",alt:"WeChat",src:d.l+"payment-methods/wechat.svg"}];var p=a(28);a(303),t.a=e=>{let{icons:t=[],align:a="center",className:s}=e;const o=(e=>{const t={};return e.forEach(e=>{let a={};"string"==typeof e&&(a={id:e,alt:e,src:null}),"object"==typeof e&&(a={id:e.id||"",alt:e.alt||"",src:e.src||null}),a.id&&Object(p.a)(a.id)&&!t[a.id]&&(t[a.id]=a)}),Object.values(t)})(t);if(0===o.length)return null;const l=i()("wc-block-components-payment-method-icons",{"wc-block-components-payment-method-icons--align-left":"left"===a,"wc-block-components-payment-method-icons--align-right":"right"===a},s);return Object(c.createElement)("div",{className:l},o.map(e=>{const t={...e,...(a=e.id,m.find(e=>e.id===a)||{})};var a;return Object(c.createElement)(r,n()({key:"payment-method-icon-"+e.id},t))}))}},410:function(e,t,a){"use strict";a.d(t,"a",(function(){return s}));const s=e=>Object.values(e).reduce((e,t)=>(null!==t.icons&&(e=e.concat(t.icons)),e),[])},480:function(e,t,a){"use strict";a.r(t);var s=a(0),n=a(310),c=a(308),o=a(410);t.default=e=>{let{className:t}=e;const{paymentMethods:a}=Object(c.b)();return Object(s.createElement)(n.a,{className:t,icons:Object(o.a)(a)})}}}]);
|
build/cart-blocks/cart-cross-sells-products--product-add-to-cart-frontend.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[6],{152:function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r.d(t,"b",(function(){return o}));var s=r(5);const c=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;const r=Object(s.select)("core/notices").getNotices(e);return r.some(e=>e.type===t)},o=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const r=Object(s.select)("core/notices").getNotices(),{removeNotice:c}=Object(s.dispatch)("core/notices"),o=r.filter(t=>t.status===e);o.forEach(e=>c(e.id,t))}},26:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var s=r(0),c=r(12),o=r.n(c);function a(e){const t=Object(s.useRef)(e);return o()(e,t.current)||(t.current=e),t.current}},289:function(e,t,r){"use strict";var s=r(13),c=r.n(s),o=r(0),a=r(92),n=r(7),i=r.n(n),u=r(141);r(290),t.a=e=>{let{className:t,showSpinner:r=!1,children:s,variant:n="contained",...l}=e;const d=i()("wc-block-components-button",t,n,{"wc-block-components-button--loading":r});return Object(o.createElement)(a.a,c()({className:d},l),r&&Object(o.createElement)(u.a,null),Object(o.createElement)("span",{className:"wc-block-components-button__text"},s))}},290:function(e,t){},315:function(e,t,r){"use strict";r.d(t,"a",(function(){return u}));var s=r(0),c=r(5),o=r(3),a=r(22),n=r(36);const i=(e,t)=>{const r=e.find(e=>{let{id:r}=e;return r===t});return r?r.quantity:0},u=e=>{const{addItemToCart:t}=Object(c.useDispatch)(o.CART_STORE_KEY),{cartItems:r,cartIsLoading:u}=Object(n.a)(),{createErrorNotice:l,removeNotice:d}=Object(c.useDispatch)("core/notices"),[b,E]=Object(s.useState)(!1),m=Object(s.useRef)(i(r,e));return Object(s.useEffect)(()=>{const t=i(r,e);t!==m.current&&(m.current=t)},[r,e]),{cartQuantity:Number.isFinite(m.current)?m.current:0,addingToCart:b,cartIsLoading:u,addToCart:function(){let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return E(!0),t(e,r).then(()=>{d("add-to-cart")}).catch(e=>{l(Object(a.decodeEntities)(e.message),{id:"add-to-cart",context:"wc/all-products",isDismissible:!0})}).finally(()=>{E(!1)})}}}},379:function(e,t,r){"use strict";var s=r(0),c=r(7),o=r.n(c),a=r(1),n=r(26);const i=e=>e.is_purchasable||!1;var u=r(5),l=r(3);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:{}},E={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:p,SET_DISABLED:O,SET_PROCESSING:_,SET_BEFORE_PROCESSING:h,SET_AFTER_PROCESSING:j,SET_PROCESSING_RESPONSE:S,SET_HAS_ERROR:g,SET_NO_ERROR:f,SET_QUANTITY:v,SET_REQUEST_PARAMS:R}=E,T=()=>({type:p}),P=function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const t=e?g:f;return{type:t}},{SET_PRISTINE:A,SET_IDLE:I,SET_DISABLED:N,SET_PROCESSING:y,SET_BEFORE_PROCESSING:C,SET_AFTER_PROCESSING:k,SET_PROCESSING_RESPONSE:w,SET_HAS_ERROR:D,SET_NO_ERROR:F,SET_QUANTITY:q,SET_REQUEST_PARAMS:x}=E,{PRISTINE:B,IDLE:G,DISABLED:L,PROCESSING:Q,BEFORE_PROCESSING:M,AFTER_PROCESSING:V}=d,W=function(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:b,{quantity:r,type:s,data:c}=arguments.length>1?arguments[1]:void 0;switch(s){case A:e=b;break;case I:e=t.status!==G?{...t,status:G}:t;break;case N:e=t.status!==L?{...t,status:L}:t;break;case q:e=r!==t.quantity?{...t,quantity:r}:t;break;case x:e={...t,requestParams:{...t.requestParams,...c}};break;case w:e={...t,processingResponse:c};break;case y:e=t.status!==Q?{...t,status:Q,hasError:!1}:t,e=!1===e.hasError?e:{...e,hasError:!1};break;case C:e=t.status!==M?{...t,status:M,hasError:!1}:t;break;case k:e=t.status!==V?{...t,status:V}:t;break;case D:e=t.hasError?t:{...t,hasError:!0},e=t.status===Q||t.status===M?{...e,status:G}:e;break;case F:e=t.hasError?{...t,hasError:!1}:t}return e!==t&&s!==A&&e.status===B&&(e.status=G),e};var H=r(100),Y=r(227);const K=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 U=r(230),J=r(40),z=r(152);const X=Object(s.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=>{}}}),Z=()=>Object(s.useContext)(X),$=e=>{var t,r,c,o;let{children:E,product:p,showFormElements:g}=e;const[f,A]=Object(s.useReducer)(W,b),[I,N]=Object(s.useReducer)(H.b,{}),y=Object(n.a)(I),{createErrorNotice:C}=Object(u.useDispatch)("core/notices"),{setValidationErrors:k}=Object(u.useDispatch)(l.VALIDATION_STORE_KEY),w=Object(s.useMemo)(()=>({onAddToCartAfterProcessingWithSuccess:K(N).onAddToCartAfterProcessingWithSuccess,onAddToCartAfterProcessingWithError:K(N).onAddToCartAfterProcessingWithError,onAddToCartBeforeProcessing:K(N).onAddToCartBeforeProcessing}),[N]),D=Object(s.useMemo)(()=>({resetForm:()=>{A({type:m})},submitForm:()=>{A({type:h})},setQuantity:e=>{A((e=>({type:v,quantity:e}))(e))},setHasError:e=>{A(P(e))},setRequestParams:e=>{A((e=>({type:R,data:e}))(e))},setAfterProcessing:e=>{A({type:S,data:e}),A({type:j})}}),[]);Object(s.useEffect)(()=>{const e=f.status,t=!p.id||!i(p);e!==d.DISABLED||t?e!==d.DISABLED&&t&&A({type:O}):A(T())},[f.status,p,A]),Object(s.useEffect)(()=>{f.status===d.BEFORE_PROCESSING&&(Object(z.b)("error","wc/add-to-cart"),Object(U.a)(y,"add_to_cart_before_processing",{}).then(e=>{!0!==e?(Array.isArray(e)&&e.forEach(e=>{let{errorMessage:t,validationErrors:r}=e;t&&C(t,{context:"wc/add-to-cart"}),r&&k(r)}),A(T())):A({type:_})}))},[f.status,k,C,A,y,null==p?void 0:p.id]),Object(s.useEffect)(()=>{if(f.status===d.AFTER_PROCESSING){const e={processingResponse:f.processingResponse},t=e=>{let t=!1;return e.forEach(e=>{const{message:r,messageContext:s}=e;(Object(J.b)(e)||Object(J.c)(e))&&r&&(t=!0,C(r,s?{context:s}:void 0))}),t};if(f.hasError)return void Object(U.b)(y,"add_to_cart_after_processing_with_error",e).then(r=>{if(!t(r)){var s;const t=(null===(s=e.processingResponse)||void 0===s?void 0:s.message)||Object(a.__)("Something went wrong. Please contact us for assistance.","woo-gutenberg-products-block");C(t,{id:"add-to-cart",context:"woocommerce/single-product/"+((null==p?void 0:p.id)||0)})}A(T())});Object(U.b)(y,"add_to_cart_after_processing_with_success",e).then(e=>{t(e)?A(P(!0)):A(T())})}},[f.status,f.hasError,f.processingResponse,D,C,y,null==p?void 0:p.id]);const F=(e=>["simple","variable"].includes(e.type||"simple"))(p),q={product:p,productType:p.type||"simple",productIsPurchasable:i(p),productHasOptions:p.has_options||!1,supportsFormElements:F,showFormElements:g&&F,quantity:f.quantity||(null==p||null===(t=p.add_to_cart)||void 0===t?void 0:t.minimum)||1,minQuantity:(null==p||null===(r=p.add_to_cart)||void 0===r?void 0:r.minimum)||1,maxQuantity:(null==p||null===(c=p.add_to_cart)||void 0===c?void 0:c.maximum)||99,multipleOf:(null==p||null===(o=p.add_to_cart)||void 0===o?void 0:o.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:w,dispatchActions:D};return Object(s.createElement)(X.Provider,{value:q},E)};var ee=r(32),te=r.n(ee),re=r(22),se=r(85),ce=r(36),oe=()=>{const{dispatchActions:e,product:t,quantity:r,eventRegistration:c,hasError:o,isProcessing:n,requestParams:i}=Z(),{showAllValidationErrors:d}=Object(u.useDispatch)(l.VALIDATION_STORE_KEY),b=Object(u.useSelect)(e=>e(l.VALIDATION_STORE_KEY).hasValidationErrors),{createErrorNotice:E,removeNotice:m}=Object(u.useDispatch)("core/notices"),{receiveCart:p}=Object(ce.a)(),[O,_]=Object(s.useState)(!1),h=!o&&n,j=Object(s.useCallback)(()=>!b()||(d(),{type:"error"}),[b,d]);Object(s.useEffect)(()=>{const e=c.onAddToCartBeforeProcessing(j,0);return()=>{e()}},[c,j]);const S=Object(s.useCallback)(()=>{_(!0),m("add-to-cart","woocommerce/single-product/"+((null==t?void 0:t.id)||0));const s={id:t.id||0,quantity:r,...i};te()({path:"/wc/store/v1/cart/add-item",method:"POST",data:s,cache:"no-store",parse:!1}).then(r=>{te.a.setNonce(r.headers),r.json().then((function(s){r.ok?p(s):(s.body&&s.body.message?E(Object(re.decodeEntities)(s.body.message),{id:"add-to-cart",context:"woocommerce/single-product/"+((null==t?void 0:t.id)||0)}):E(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(se.c)({preserveCartData:!0}),e.setAfterProcessing(s),_(!1)}))}).catch(t=>{t.json().then((function(t){var r;null!==(r=t.data)&&void 0!==r&&r.cart&&p(t.data.cart),e.setHasError(),e.setAfterProcessing(t),_(!1)}))})},[t,E,m,p,e,r,i]);return Object(s.useEffect)(()=>{h&&!O&&S()},[h,S,O]),null};const ae=e=>{let{children:t,product:r,showFormElements:c}=e;return Object(s.createElement)($,{product:r,showFormElements:c},t,Object(s.createElement)(oe,null))};var ne=r(46),ie=r(8),ue=r(129),le=(r(392),r(289)),de=r(107),be=r(393),Ee=r(64),me=r(315);const pe=e=>{let{className:t,href:r,text:c,onClick:o}=e;return Object(s.createElement)(le.a,{className:t,href:r,onClick:o,rel:"nofollow"},c)},Oe=e=>{let{className:t,quantityInCart:r,isProcessing:c,isDisabled:o,isDone:n,onClick:i}=e;return Object(s.createElement)(le.a,{className:t,disabled:o,showSpinner:c,onClick:i},n&&r>0?Object(a.sprintf)(
|
2 |
/* translators: %s number of products in cart. */
|
3 |
Object(a._n)("%d in cart","%d in cart",r,"woo-gutenberg-products-block"),r):Object(a.__)("Add to cart","woo-gutenberg-products-block"),!!n&&Object(s.createElement)(de.a,{icon:be.a}))};var _e=()=>{const{showFormElements:e,productIsPurchasable:t,productHasOptions:r,product:c,productType:o,isDisabled:n,isProcessing:i,eventRegistration:u,hasError:l,dispatchActions:d}=Z(),{parentName:b}=Object(ne.useInnerBlockLayoutContext)(),{dispatchStoreEvent:E}=Object(Ee.a)(),{cartQuantity:m}=Object(me.a)(c.id||0),[p,O]=Object(s.useState)(!1),_=c.add_to_cart||{url:"",text:""};return Object(s.useEffect)(()=>{const e=u.onAddToCartAfterProcessingWithSuccess(()=>(l||O(!0),!0),0);return()=>{e()}},[u,l]),(e||!r&&"simple"===o)&&t?Object(s.createElement)(Oe,{className:"wc-block-components-product-add-to-cart-button",quantityInCart:m,isDisabled:n,isProcessing:i,isDone:p,onClick:()=>{d.submitForm("woocommerce/single-product/"+((null==c?void 0:c.id)||0)),E("cart-add-item",{product:c,listName:b})}}):Object(s.createElement)(pe,{className:"wc-block-components-product-add-to-cart-button",href:_.url,text:_.text||Object(a.__)("View Product","woo-gutenberg-products-block"),onClick:()=>{E("product-view-link",{product:c,listName:b})}})},he=r(48),je=e=>{let{disabled:t,min:r,max:c,step:o=1,value:a,onChange:n}=e;const i=void 0!==c,u=Object(he.a)(e=>{let t=e;i&&(t=Math.min(t,Math.floor(c/o)*o)),t=Math.max(t,Math.ceil(r/o)*o),t=Math.floor(t/o)*o,t!==e&&n(t)},300);return Object(s.createElement)("input",{className:"wc-block-components-product-add-to-cart-quantity",type:"number",value:a,min:r,max:c,step:o,hidden:1===c,disabled:t,onChange:e=>{n(e.target.value),u(e.target.value)}})},Se=e=>{let{reason:t=Object(a.__)("Sorry, this product cannot be purchased.","woo-gutenberg-products-block")}=e;return Object(s.createElement)("div",{className:"wc-block-components-product-add-to-cart-unavailable"},t)},ge=()=>{const{product:e,quantity:t,minQuantity:r,maxQuantity:c,multipleOf:o,dispatchActions:n,isDisabled:i}=Z();return e.id&&!e.is_purchasable?Object(s.createElement)(Se,null):e.id&&!e.is_in_stock?Object(s.createElement)(Se,{reason:Object(a.__)("This product is currently out of stock and cannot be purchased.","woo-gutenberg-products-block")}):Object(s.createElement)(s.Fragment,null,Object(s.createElement)(je,{value:t,min:r,max:c,step:o,disabled:i,onChange:n.setQuantity}),Object(s.createElement)(_e,null))},fe=(r(394),r(461)),ve=r(6),Re=r(9);const Te={value:"",label:Object(a.__)("Select an option","woo-gutenberg-products-block")};var Pe=e=>{let{attributeName:t,options:r=[],value:c="",onChange:n=(()=>{}),errorMessage:i=Object(a.__)("Please select a value.","woo-gutenberg-products-block")}=e;const d=t,{setValidationErrors:b,clearValidationError:E}=Object(u.useDispatch)(l.VALIDATION_STORE_KEY),{error:m}=Object(u.useSelect)(e=>({error:e(l.VALIDATION_STORE_KEY).getValidationError(d)||{}}));return Object(ve.useEffect)(()=>{c?E(d):b({[d]:{message:i,hidden:!0}})},[c,d,i,E,b]),Object(ve.useEffect)(()=>()=>{E(d)},[d,E]),Object(s.createElement)("div",{className:"wc-block-components-product-add-to-cart-attribute-picker__container"},Object(s.createElement)(fe.a,{label:Object(re.decodeEntities)(t),value:c||"",options:[Te,...r],onChange:n,required:!0,className:o()("wc-block-components-product-add-to-cart-attribute-picker__select",{"has-error":(null==m?void 0:m.message)&&!(null!=m&&m.hidden)})}),Object(s.createElement)(Re.ValidationInputError,{propertyName:d,elementId:d}))},Ae=r(20);const Ie=(e,t,r)=>{const s=Object.values(t).map(e=>{let{id:t}=e;return t});if(Object.values(r).every(e=>""===e))return s;const c=Object.keys(e);return s.filter(e=>c.every(s=>{const c=r[s]||"",o=t["id:"+e].attributes[s];return""===c||null===o||o===c}))};var Ne=e=>{let{attributes:t,variationAttributes:r,setRequestParams:c}=e;const o=Object(n.a)(t),a=Object(n.a)(r),[i,u]=Object(s.useState)(0),[l,d]=Object(s.useState)({}),[b,E]=Object(s.useState)(!1),m=Object(s.useMemo)(()=>((e,t,r)=>{const s={},c=Object.keys(e),o=Object.values(r).filter(Boolean).length>0;return c.forEach(c=>{const a=e[c],n={...r,[c]:null},i=o?Ie(e,t,n):null,u=null!==i?i.map(e=>t["id:"+e].attributes[c]):null;s[c]=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return Object.values(e).map(e=>{let{name:r,slug:s}=e;return null===t||t.includes(null)||t.includes(s)?{value:s,label:Object(re.decodeEntities)(r)}:null}).filter(Boolean)}(a.terms,u)}),s})(o,a,l),[l,o,a]);return Object(s.useEffect)(()=>{if(!b){const e=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!Object(Ae.a)(e))return{};const t=Object.keys(e),r={};return 0===t.length||t.forEach(t=>{const s=e[t],c=s.terms.filter(e=>e.default);var o;c.length>0&&(r[s.name]=null===(o=c[0])||void 0===o?void 0:o.slug)}),r}(t);e&&d({...e}),E(!0)}},[l,t,b]),Object(s.useEffect)(()=>{Object.values(l).filter(e=>""!==e).length===Object.keys(o).length?u(((e,t,r)=>Ie(e,t,r)[0]||0)(o,a,l)):i>0&&u(0)},[l,i,o,a]),Object(s.useEffect)(()=>{c({id:i,variation:Object.keys(l).map(e=>({attribute:e,value:l[e]}))})},[c,i,l]),Object(s.createElement)("div",{className:"wc-block-components-product-add-to-cart-attribute-picker"},Object.keys(o).map(e=>Object(s.createElement)(Pe,{key:e,attributeName:e,options:m[e],value:l[e],onChange:t=>{d({...l,[e]:t})}})))},ye=e=>{let{product:t,dispatchers:r}=e;const c=(e=>e?Object(ie.keyBy)(Object.values(e).filter(e=>{let{has_variations:t}=e;return t}),"name"):{})(t.attributes),o=(e=>{if(!e)return{};const t={};return e.forEach(e=>{let{id:r,attributes:s}=e;t["id:"+r]={id:r,attributes:s.reduce((e,t)=>{let{name:r,value:s}=t;return e[r]=s,e},{})}}),t})(t.variations);return 0===Object.keys(c).length||0===o.length?null:Object(s.createElement)(Ne,{attributes:c,variationAttributes:o,setRequestParams:r.setRequestParams})},Ce=()=>{const{product:e,quantity:t,minQuantity:r,maxQuantity:c,multipleOf:o,dispatchActions:n,isDisabled:i}=Z();return e.id&&!e.is_purchasable?Object(s.createElement)(Se,null):e.id&&!e.is_in_stock?Object(s.createElement)(Se,{reason:Object(a.__)("This product is currently out of stock and cannot be purchased.","woo-gutenberg-products-block")}):Object(s.createElement)(s.Fragment,null,Object(s.createElement)(ye,{product:e,dispatchers:n}),Object(s.createElement)(je,{value:t,min:r,max:c,step:o,disabled:i,onChange:n.setQuantity}),Object(s.createElement)(_e,null))},ke=()=>Object(s.createElement)(_e,null),we=r(369),De=()=>Object(s.createElement)(we.a,{className:"wc-block-components-product-add-to-cart-group-list"},"This is a placeholder for the grouped products form element."),Fe=()=>Object(s.createElement)(De,null);const qe=()=>{const{showFormElements:e,productType:t}=Z();return e?"variable"===t?Object(s.createElement)(Ce,null):"grouped"===t?Object(s.createElement)(Fe,null):"external"===t?Object(s.createElement)(ke,null):"simple"===t||"variation"===t?Object(s.createElement)(ge,null):null:Object(s.createElement)(_e,null)};t.a=Object(ue.withProductDataContext)(e=>{let{className:t,showFormElements:r}=e;const{product:c}=Object(ne.useProductDataContext)(),a=o()(t,"wc-block-components-product-add-to-cart",{"wc-block-components-product-add-to-cart--placeholder":Object(ie.isEmpty)(c)});return Object(s.createElement)(ae,{product:c,showFormElements:r},Object(s.createElement)("div",{className:a},Object(s.createElement)(qe,null)))})},392:function(e,t){},394:function(e,t){}}]);
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[6],{151:function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r.d(t,"b",(function(){return o}));var s=r(5);const c=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;const r=Object(s.select)("core/notices").getNotices(e);return r.some(e=>e.type===t)},o=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const r=Object(s.select)("core/notices").getNotices(),{removeNotice:c}=Object(s.dispatch)("core/notices"),o=r.filter(t=>t.status===e);o.forEach(e=>c(e.id,t))}},26:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var s=r(0),c=r(12),o=r.n(c);function a(e){const t=Object(s.useRef)(e);return o()(e,t.current)||(t.current=e),t.current}},288:function(e,t,r){"use strict";var s=r(13),c=r.n(s),o=r(0),a=r(90),n=r(7),i=r.n(n),u=r(140);r(289),t.a=e=>{let{className:t,showSpinner:r=!1,children:s,variant:n="contained",...l}=e;const d=i()("wc-block-components-button",t,n,{"wc-block-components-button--loading":r});return Object(o.createElement)(a.a,c()({className:d},l),r&&Object(o.createElement)(u.a,null),Object(o.createElement)("span",{className:"wc-block-components-button__text"},s))}},289:function(e,t){},314:function(e,t,r){"use strict";r.d(t,"a",(function(){return u}));var s=r(0),c=r(5),o=r(3),a=r(22),n=r(36);const i=(e,t)=>{const r=e.find(e=>{let{id:r}=e;return r===t});return r?r.quantity:0},u=e=>{const{addItemToCart:t}=Object(c.useDispatch)(o.CART_STORE_KEY),{cartItems:r,cartIsLoading:u}=Object(n.a)(),{createErrorNotice:l,removeNotice:d}=Object(c.useDispatch)("core/notices"),[b,E]=Object(s.useState)(!1),m=Object(s.useRef)(i(r,e));return Object(s.useEffect)(()=>{const t=i(r,e);t!==m.current&&(m.current=t)},[r,e]),{cartQuantity:Number.isFinite(m.current)?m.current:0,addingToCart:b,cartIsLoading:u,addToCart:function(){let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return E(!0),t(e,r).then(()=>{d("add-to-cart")}).catch(e=>{l(Object(a.decodeEntities)(e.message),{id:"add-to-cart",context:"wc/all-products",isDismissible:!0})}).finally(()=>{E(!1)})}}}},379:function(e,t,r){"use strict";var s=r(0),c=r(7),o=r.n(c),a=r(1),n=r(26);const i=e=>e.is_purchasable||!1;var u=r(5),l=r(3);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:{}},E={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:p,SET_DISABLED:O,SET_PROCESSING:_,SET_BEFORE_PROCESSING:h,SET_AFTER_PROCESSING:j,SET_PROCESSING_RESPONSE:S,SET_HAS_ERROR:g,SET_NO_ERROR:f,SET_QUANTITY:v,SET_REQUEST_PARAMS:R}=E,T=()=>({type:p}),P=function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const t=e?g:f;return{type:t}},{SET_PRISTINE:A,SET_IDLE:I,SET_DISABLED:N,SET_PROCESSING:y,SET_BEFORE_PROCESSING:C,SET_AFTER_PROCESSING:k,SET_PROCESSING_RESPONSE:w,SET_HAS_ERROR:D,SET_NO_ERROR:F,SET_QUANTITY:q,SET_REQUEST_PARAMS:x}=E,{PRISTINE:B,IDLE:G,DISABLED:L,PROCESSING:Q,BEFORE_PROCESSING:M,AFTER_PROCESSING:V}=d,W=function(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:b,{quantity:r,type:s,data:c}=arguments.length>1?arguments[1]:void 0;switch(s){case A:e=b;break;case I:e=t.status!==G?{...t,status:G}:t;break;case N:e=t.status!==L?{...t,status:L}:t;break;case q:e=r!==t.quantity?{...t,quantity:r}:t;break;case x:e={...t,requestParams:{...t.requestParams,...c}};break;case w:e={...t,processingResponse:c};break;case y:e=t.status!==Q?{...t,status:Q,hasError:!1}:t,e=!1===e.hasError?e:{...e,hasError:!1};break;case C:e=t.status!==M?{...t,status:M,hasError:!1}:t;break;case k:e=t.status!==V?{...t,status:V}:t;break;case D:e=t.hasError?t:{...t,hasError:!0},e=t.status===Q||t.status===M?{...e,status:G}:e;break;case F:e=t.hasError?{...t,hasError:!1}:t}return e!==t&&s!==A&&e.status===B&&(e.status=G),e};var H=r(98),Y=r(226);const K=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 U=r(229),J=r(40),z=r(151);const X=Object(s.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=>{}}}),Z=()=>Object(s.useContext)(X),$=e=>{var t,r,c,o;let{children:E,product:p,showFormElements:g}=e;const[f,A]=Object(s.useReducer)(W,b),[I,N]=Object(s.useReducer)(H.b,{}),y=Object(n.a)(I),{createErrorNotice:C}=Object(u.useDispatch)("core/notices"),{setValidationErrors:k}=Object(u.useDispatch)(l.VALIDATION_STORE_KEY),w=Object(s.useMemo)(()=>({onAddToCartAfterProcessingWithSuccess:K(N).onAddToCartAfterProcessingWithSuccess,onAddToCartAfterProcessingWithError:K(N).onAddToCartAfterProcessingWithError,onAddToCartBeforeProcessing:K(N).onAddToCartBeforeProcessing}),[N]),D=Object(s.useMemo)(()=>({resetForm:()=>{A({type:m})},submitForm:()=>{A({type:h})},setQuantity:e=>{A((e=>({type:v,quantity:e}))(e))},setHasError:e=>{A(P(e))},setRequestParams:e=>{A((e=>({type:R,data:e}))(e))},setAfterProcessing:e=>{A({type:S,data:e}),A({type:j})}}),[]);Object(s.useEffect)(()=>{const e=f.status,t=!p.id||!i(p);e!==d.DISABLED||t?e!==d.DISABLED&&t&&A({type:O}):A(T())},[f.status,p,A]),Object(s.useEffect)(()=>{f.status===d.BEFORE_PROCESSING&&(Object(z.b)("error","wc/add-to-cart"),Object(U.a)(y,"add_to_cart_before_processing",{}).then(e=>{!0!==e?(Array.isArray(e)&&e.forEach(e=>{let{errorMessage:t,validationErrors:r}=e;t&&C(t,{context:"wc/add-to-cart"}),r&&k(r)}),A(T())):A({type:_})}))},[f.status,k,C,A,y,null==p?void 0:p.id]),Object(s.useEffect)(()=>{if(f.status===d.AFTER_PROCESSING){const e={processingResponse:f.processingResponse},t=e=>{let t=!1;return e.forEach(e=>{const{message:r,messageContext:s}=e;(Object(J.b)(e)||Object(J.c)(e))&&r&&(t=!0,C(r,s?{context:s}:void 0))}),t};if(f.hasError)return void Object(U.b)(y,"add_to_cart_after_processing_with_error",e).then(r=>{if(!t(r)){var s;const t=(null===(s=e.processingResponse)||void 0===s?void 0:s.message)||Object(a.__)("Something went wrong. Please contact us for assistance.","woo-gutenberg-products-block");C(t,{id:"add-to-cart",context:"woocommerce/single-product/"+((null==p?void 0:p.id)||0)})}A(T())});Object(U.b)(y,"add_to_cart_after_processing_with_success",e).then(e=>{t(e)?A(P(!0)):A(T())})}},[f.status,f.hasError,f.processingResponse,D,C,y,null==p?void 0:p.id]);const F=(e=>["simple","variable"].includes(e.type||"simple"))(p),q={product:p,productType:p.type||"simple",productIsPurchasable:i(p),productHasOptions:p.has_options||!1,supportsFormElements:F,showFormElements:g&&F,quantity:f.quantity||(null==p||null===(t=p.add_to_cart)||void 0===t?void 0:t.minimum)||1,minQuantity:(null==p||null===(r=p.add_to_cart)||void 0===r?void 0:r.minimum)||1,maxQuantity:(null==p||null===(c=p.add_to_cart)||void 0===c?void 0:c.maximum)||99,multipleOf:(null==p||null===(o=p.add_to_cart)||void 0===o?void 0:o.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:w,dispatchActions:D};return Object(s.createElement)(X.Provider,{value:q},E)};var ee=r(32),te=r.n(ee),re=r(22),se=r(83),ce=r(36),oe=()=>{const{dispatchActions:e,product:t,quantity:r,eventRegistration:c,hasError:o,isProcessing:n,requestParams:i}=Z(),{showAllValidationErrors:d}=Object(u.useDispatch)(l.VALIDATION_STORE_KEY),b=Object(u.useSelect)(e=>e(l.VALIDATION_STORE_KEY).hasValidationErrors),{createErrorNotice:E,removeNotice:m}=Object(u.useDispatch)("core/notices"),{receiveCart:p}=Object(ce.a)(),[O,_]=Object(s.useState)(!1),h=!o&&n,j=Object(s.useCallback)(()=>!b()||(d(),{type:"error"}),[b,d]);Object(s.useEffect)(()=>{const e=c.onAddToCartBeforeProcessing(j,0);return()=>{e()}},[c,j]);const S=Object(s.useCallback)(()=>{_(!0),m("add-to-cart","woocommerce/single-product/"+((null==t?void 0:t.id)||0));const s={id:t.id||0,quantity:r,...i};te()({path:"/wc/store/v1/cart/add-item",method:"POST",data:s,cache:"no-store",parse:!1}).then(r=>{te.a.setNonce(r.headers),r.json().then((function(s){r.ok?p(s):(s.body&&s.body.message?E(Object(re.decodeEntities)(s.body.message),{id:"add-to-cart",context:"woocommerce/single-product/"+((null==t?void 0:t.id)||0)}):E(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(se.c)({preserveCartData:!0}),e.setAfterProcessing(s),_(!1)}))}).catch(t=>{t.json().then((function(t){var r;null!==(r=t.data)&&void 0!==r&&r.cart&&p(t.data.cart),e.setHasError(),e.setAfterProcessing(t),_(!1)}))})},[t,E,m,p,e,r,i]);return Object(s.useEffect)(()=>{h&&!O&&S()},[h,S,O]),null};const ae=e=>{let{children:t,product:r,showFormElements:c}=e;return Object(s.createElement)($,{product:r,showFormElements:c},t,Object(s.createElement)(oe,null))};var ne=r(46),ie=r(8),ue=r(128),le=(r(392),r(288)),de=r(105),be=r(393),Ee=r(64),me=r(314);const pe=e=>{let{className:t,href:r,text:c,onClick:o}=e;return Object(s.createElement)(le.a,{className:t,href:r,onClick:o,rel:"nofollow"},c)},Oe=e=>{let{className:t,quantityInCart:r,isProcessing:c,isDisabled:o,isDone:n,onClick:i}=e;return Object(s.createElement)(le.a,{className:t,disabled:o,showSpinner:c,onClick:i},n&&r>0?Object(a.sprintf)(
|
2 |
/* translators: %s number of products in cart. */
|
3 |
Object(a._n)("%d in cart","%d in cart",r,"woo-gutenberg-products-block"),r):Object(a.__)("Add to cart","woo-gutenberg-products-block"),!!n&&Object(s.createElement)(de.a,{icon:be.a}))};var _e=()=>{const{showFormElements:e,productIsPurchasable:t,productHasOptions:r,product:c,productType:o,isDisabled:n,isProcessing:i,eventRegistration:u,hasError:l,dispatchActions:d}=Z(),{parentName:b}=Object(ne.useInnerBlockLayoutContext)(),{dispatchStoreEvent:E}=Object(Ee.a)(),{cartQuantity:m}=Object(me.a)(c.id||0),[p,O]=Object(s.useState)(!1),_=c.add_to_cart||{url:"",text:""};return Object(s.useEffect)(()=>{const e=u.onAddToCartAfterProcessingWithSuccess(()=>(l||O(!0),!0),0);return()=>{e()}},[u,l]),(e||!r&&"simple"===o)&&t?Object(s.createElement)(Oe,{className:"wc-block-components-product-add-to-cart-button",quantityInCart:m,isDisabled:n,isProcessing:i,isDone:p,onClick:()=>{d.submitForm("woocommerce/single-product/"+((null==c?void 0:c.id)||0)),E("cart-add-item",{product:c,listName:b})}}):Object(s.createElement)(pe,{className:"wc-block-components-product-add-to-cart-button",href:_.url,text:_.text||Object(a.__)("View Product","woo-gutenberg-products-block"),onClick:()=>{E("product-view-link",{product:c,listName:b})}})},he=r(48),je=e=>{let{disabled:t,min:r,max:c,step:o=1,value:a,onChange:n}=e;const i=void 0!==c,u=Object(he.a)(e=>{let t=e;i&&(t=Math.min(t,Math.floor(c/o)*o)),t=Math.max(t,Math.ceil(r/o)*o),t=Math.floor(t/o)*o,t!==e&&n(t)},300);return Object(s.createElement)("input",{className:"wc-block-components-product-add-to-cart-quantity",type:"number",value:a,min:r,max:c,step:o,hidden:1===c,disabled:t,onChange:e=>{n(e.target.value),u(e.target.value)}})},Se=e=>{let{reason:t=Object(a.__)("Sorry, this product cannot be purchased.","woo-gutenberg-products-block")}=e;return Object(s.createElement)("div",{className:"wc-block-components-product-add-to-cart-unavailable"},t)},ge=()=>{const{product:e,quantity:t,minQuantity:r,maxQuantity:c,multipleOf:o,dispatchActions:n,isDisabled:i}=Z();return e.id&&!e.is_purchasable?Object(s.createElement)(Se,null):e.id&&!e.is_in_stock?Object(s.createElement)(Se,{reason:Object(a.__)("This product is currently out of stock and cannot be purchased.","woo-gutenberg-products-block")}):Object(s.createElement)(s.Fragment,null,Object(s.createElement)(je,{value:t,min:r,max:c,step:o,disabled:i,onChange:n.setQuantity}),Object(s.createElement)(_e,null))},fe=(r(394),r(461)),ve=r(6),Re=r(9);const Te={value:"",label:Object(a.__)("Select an option","woo-gutenberg-products-block")};var Pe=e=>{let{attributeName:t,options:r=[],value:c="",onChange:n=(()=>{}),errorMessage:i=Object(a.__)("Please select a value.","woo-gutenberg-products-block")}=e;const d=t,{setValidationErrors:b,clearValidationError:E}=Object(u.useDispatch)(l.VALIDATION_STORE_KEY),{error:m}=Object(u.useSelect)(e=>({error:e(l.VALIDATION_STORE_KEY).getValidationError(d)||{}}));return Object(ve.useEffect)(()=>{c?E(d):b({[d]:{message:i,hidden:!0}})},[c,d,i,E,b]),Object(ve.useEffect)(()=>()=>{E(d)},[d,E]),Object(s.createElement)("div",{className:"wc-block-components-product-add-to-cart-attribute-picker__container"},Object(s.createElement)(fe.a,{label:Object(re.decodeEntities)(t),value:c||"",options:[Te,...r],onChange:n,required:!0,className:o()("wc-block-components-product-add-to-cart-attribute-picker__select",{"has-error":(null==m?void 0:m.message)&&!(null!=m&&m.hidden)})}),Object(s.createElement)(Re.ValidationInputError,{propertyName:d,elementId:d}))},Ae=r(20);const Ie=(e,t,r)=>{const s=Object.values(t).map(e=>{let{id:t}=e;return t});if(Object.values(r).every(e=>""===e))return s;const c=Object.keys(e);return s.filter(e=>c.every(s=>{const c=r[s]||"",o=t["id:"+e].attributes[s];return""===c||null===o||o===c}))};var Ne=e=>{let{attributes:t,variationAttributes:r,setRequestParams:c}=e;const o=Object(n.a)(t),a=Object(n.a)(r),[i,u]=Object(s.useState)(0),[l,d]=Object(s.useState)({}),[b,E]=Object(s.useState)(!1),m=Object(s.useMemo)(()=>((e,t,r)=>{const s={},c=Object.keys(e),o=Object.values(r).filter(Boolean).length>0;return c.forEach(c=>{const a=e[c],n={...r,[c]:null},i=o?Ie(e,t,n):null,u=null!==i?i.map(e=>t["id:"+e].attributes[c]):null;s[c]=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return Object.values(e).map(e=>{let{name:r,slug:s}=e;return null===t||t.includes(null)||t.includes(s)?{value:s,label:Object(re.decodeEntities)(r)}:null}).filter(Boolean)}(a.terms,u)}),s})(o,a,l),[l,o,a]);return Object(s.useEffect)(()=>{if(!b){const e=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!Object(Ae.a)(e))return{};const t=Object.keys(e),r={};return 0===t.length||t.forEach(t=>{const s=e[t],c=s.terms.filter(e=>e.default);var o;c.length>0&&(r[s.name]=null===(o=c[0])||void 0===o?void 0:o.slug)}),r}(t);e&&d({...e}),E(!0)}},[l,t,b]),Object(s.useEffect)(()=>{Object.values(l).filter(e=>""!==e).length===Object.keys(o).length?u(((e,t,r)=>Ie(e,t,r)[0]||0)(o,a,l)):i>0&&u(0)},[l,i,o,a]),Object(s.useEffect)(()=>{c({id:i,variation:Object.keys(l).map(e=>({attribute:e,value:l[e]}))})},[c,i,l]),Object(s.createElement)("div",{className:"wc-block-components-product-add-to-cart-attribute-picker"},Object.keys(o).map(e=>Object(s.createElement)(Pe,{key:e,attributeName:e,options:m[e],value:l[e],onChange:t=>{d({...l,[e]:t})}})))},ye=e=>{let{product:t,dispatchers:r}=e;const c=(e=>e?Object(ie.keyBy)(Object.values(e).filter(e=>{let{has_variations:t}=e;return t}),"name"):{})(t.attributes),o=(e=>{if(!e)return{};const t={};return e.forEach(e=>{let{id:r,attributes:s}=e;t["id:"+r]={id:r,attributes:s.reduce((e,t)=>{let{name:r,value:s}=t;return e[r]=s,e},{})}}),t})(t.variations);return 0===Object.keys(c).length||0===o.length?null:Object(s.createElement)(Ne,{attributes:c,variationAttributes:o,setRequestParams:r.setRequestParams})},Ce=()=>{const{product:e,quantity:t,minQuantity:r,maxQuantity:c,multipleOf:o,dispatchActions:n,isDisabled:i}=Z();return e.id&&!e.is_purchasable?Object(s.createElement)(Se,null):e.id&&!e.is_in_stock?Object(s.createElement)(Se,{reason:Object(a.__)("This product is currently out of stock and cannot be purchased.","woo-gutenberg-products-block")}):Object(s.createElement)(s.Fragment,null,Object(s.createElement)(ye,{product:e,dispatchers:n}),Object(s.createElement)(je,{value:t,min:r,max:c,step:o,disabled:i,onChange:n.setQuantity}),Object(s.createElement)(_e,null))},ke=()=>Object(s.createElement)(_e,null),we=r(369),De=()=>Object(s.createElement)(we.a,{className:"wc-block-components-product-add-to-cart-group-list"},"This is a placeholder for the grouped products form element."),Fe=()=>Object(s.createElement)(De,null);const qe=()=>{const{showFormElements:e,productType:t}=Z();return e?"variable"===t?Object(s.createElement)(Ce,null):"grouped"===t?Object(s.createElement)(Fe,null):"external"===t?Object(s.createElement)(ke,null):"simple"===t||"variation"===t?Object(s.createElement)(ge,null):null:Object(s.createElement)(_e,null)};t.a=Object(ue.withProductDataContext)(e=>{let{className:t,showFormElements:r}=e;const{product:c}=Object(ne.useProductDataContext)(),a=o()(t,"wc-block-components-product-add-to-cart",{"wc-block-components-product-add-to-cart--placeholder":Object(ie.isEmpty)(c)});return Object(s.createElement)(ae,{product:c,showFormElements:r},Object(s.createElement)("div",{className:a},Object(s.createElement)(qe,null)))})},392:function(e,t){},394:function(e,t){}}]);
|
build/cart-blocks/cart-cross-sells-products-frontend.js
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[19],{
|
2 |
/* translators: %1$s min price, %2$s max price */
|
3 |
-
Object(n.__)("Price between %1$s and %2$s","woo-gutenberg-products-block"),Object(o.formatPrice)(l),Object(o.formatPrice)(c))),Object(r.createElement)("span",{"aria-hidden":!0},Object(r.createElement)(a.a,{className:s()("wc-block-components-product-price__value",i),currency:t,value:l,style:u})," — ",Object(r.createElement)(a.a,{className:s()("wc-block-components-product-price__value",i),currency:t,value:c,style:u})))},u=e=>{let{currency:t,regularPriceClassName:c,regularPriceStyle:l,regularPrice:o,priceClassName:i,priceStyle:u,price:d}=e;return Object(r.createElement)(r.Fragment,null,Object(r.createElement)("span",{className:"screen-reader-text"},Object(n.__)("Previous price:","woo-gutenberg-products-block")),Object(r.createElement)(a.a,{currency:t,renderText:e=>Object(r.createElement)("del",{className:s()("wc-block-components-product-price__regular",c),style:l},e),value:o}),Object(r.createElement)("span",{className:"screen-reader-text"},Object(n.__)("Discounted price:","woo-gutenberg-products-block")),Object(r.createElement)(a.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:n,format:l="<price/>",maxPrice:o,minPrice:d,price:m,priceClassName:b,priceStyle:p,regularPrice:O,regularPriceClassName:j,regularPriceStyle:g}=e;const y=s()(c,"price","wc-block-components-product-price",{["wc-block-components-product-price--align-"+t]:t});l.includes("<price/>")||(l="<price/>",console.error("Price formats need to include the `<price/>` tag."));const _=O&&m!==O;let f=Object(r.createElement)("span",{className:s()("wc-block-components-product-price__value",b)});return _?f=Object(r.createElement)(u,{currency:n,price:m,priceClassName:b,priceStyle:p,regularPrice:O,regularPriceClassName:j,regularPriceStyle:g}):void 0!==d&&void 0!==o?f=Object(r.createElement)(i,{currency:n,maxPrice:o,minPrice:d,priceClassName:b,priceStyle:p}):m&&(f=Object(r.createElement)(a.a,{className:s()("wc-block-components-product-price__value",b),currency:n,value:m,style:p})),Object(r.createElement)("span",{className:y},Object(r.createInterpolateElement)(l,{price:f}))}},
|
4 |
/* translators: %s is referring to the product name */
|
5 |
-
Object(l.__)("Link to %s","woo-gutenberg-products-block"),p.name),C={href:p.permalink,...!v&&{"aria-label":S},onClick:()=>{f("product-view-link",{product:p})}};return Object(a.createElement)("div",{className:o()(t,"wc-block-components-product-image",{[i+"__product-image"]:i},w.className),style:{...k.style,...w.style,...N.style}},Object(a.createElement)(h,r&&C,!!n&&Object(a.createElement)(j.default,{align:s,product:p}),Object(a.createElement)(y,{fallbackAlt:p.name,image:E,loaded:!_,showFullSize:"cropped"!==c})))};t.b=Object(p.withProductDataContext)(_)},336:function(e,t){},337:function(e,t,c){"use strict";c.d(t,"a",(function(){return O}));var r=c(0),n=c(7),a=c.n(n),l=c(46),s=c(
|
6 |
/* translators: %f is referring to the average rating value */
|
7 |
-
Object(n.__)("Rated %f out of 5","woo-gutenberg-products-block"),
|
8 |
/* translators: %1$s is referring to the average rating value, %2$s is referring to the number of ratings */
|
9 |
-
Object(n._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",
|
10 |
/* translators: %s number of products in cart. */
|
11 |
-
Object(o._n)("%d in cart","%d in cart",
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[19],{105:function(e,t,c){"use strict";var r=c(0);t.a=function(e){let{icon:t,size:c=24,...n}=e;return Object(r.cloneElement)(t,{width:c,height:c,...n})}},108:function(e,t,c){"use strict";var r=c(13),n=c.n(r),a=c(0),l=c(142),s=c(7),o=c.n(s);c(208);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 m="string"==typeof c?parseInt(c,10):c;if(!Number.isFinite(m))return null;const b=m/10**r.minorUnit;if(!Number.isFinite(b))return null;const p=o()("wc-block-formatted-money-amount","wc-block-components-formatted-money-amount",t),O={...d,...i(r),value:void 0,currency:void 0,onValueChange:void 0},j=s?e=>{const t=+e.value*10**r.minorUnit;s(t)}:()=>{};return Object(a.createElement)(l.a,n()({className:p,displayType:u},O,{value:b,onValueChange:j}))}},19:function(e,t,c){"use strict";var r=c(0),n=c(7),a=c.n(n);t.a=e=>{let t,{label:c,screenReaderLabel:n,wrapperElement:l,wrapperProps:s={}}=e;const o=null!=c,i=null!=n;return!o&&i?(t=l||"span",s={...s,className:a()(s.className,"screen-reader-text")},Object(r.createElement)(t,s,n)):(t=l||r.Fragment,o&&i&&c!==n?Object(r.createElement)(t,s,Object(r.createElement)("span",{"aria-hidden":"true"},c),Object(r.createElement)("span",{className:"screen-reader-text"},n)):Object(r.createElement)(t,s,c))}},208:function(e,t){},210:function(e,t,c){"use strict";c.d(t,"a",(function(){return n})),c(92);var r=c(42);const n=()=>r.m>1},211:function(e,t,c){"use strict";c.d(t,"a",(function(){return a}));var r=c(28),n=c(20);const a=e=>Object(r.a)(e)?JSON.parse(e)||{}:Object(n.a)(e)?e:{}},270:function(e,t,c){"use strict";c.d(t,"a",(function(){return s}));var r=c(102),n=c(210),a=c(20),l=c(211);const s=e=>{if(!Object(n.a)())return{className:"",style:{}};const t=Object(a.a)(e)?e:{},c=Object(l.a)(t.style);return Object(r.__experimentalUseBorderProps)({...t,style:c})}},287:function(e,t,c){"use strict";c.d(t,"a",(function(){return s}));var r=c(102),n=c(210),a=c(20),l=c(211);const s=e=>{if(!Object(n.a)())return{className:"",style:{}};const t=Object(a.a)(e)?e:{},c=Object(l.a)(t.style);return Object(r.__experimentalUseColorProps)({...t,style:c})}},293:function(e,t,c){"use strict";c.d(t,"a",(function(){return a}));var r=c(20),n=c(211);const a=e=>{const t=Object(r.a)(e)?e:{},c=Object(n.a)(t.style),a=Object(r.a)(c.typography)?c.typography:{};return{style:{fontSize:t.fontSize?`var(--wp--preset--font-size--${t.fontSize})`:a.fontSize,lineHeight:a.lineHeight,fontWeight:a.fontWeight,textTransform:a.textTransform,fontFamily:t.fontFamily}}}},298:function(e,t,c){"use strict";var r=c(0),n=c(1),a=c(108),l=c(7),s=c.n(l),o=c(38);c(299);const i=e=>{let{currency:t,maxPrice:c,minPrice:l,priceClassName:i,priceStyle:u={}}=e;return Object(r.createElement)(r.Fragment,null,Object(r.createElement)("span",{className:"screen-reader-text"},Object(n.sprintf)(
|
2 |
/* translators: %1$s min price, %2$s max price */
|
3 |
+
Object(n.__)("Price between %1$s and %2$s","woo-gutenberg-products-block"),Object(o.formatPrice)(l),Object(o.formatPrice)(c))),Object(r.createElement)("span",{"aria-hidden":!0},Object(r.createElement)(a.a,{className:s()("wc-block-components-product-price__value",i),currency:t,value:l,style:u})," — ",Object(r.createElement)(a.a,{className:s()("wc-block-components-product-price__value",i),currency:t,value:c,style:u})))},u=e=>{let{currency:t,regularPriceClassName:c,regularPriceStyle:l,regularPrice:o,priceClassName:i,priceStyle:u,price:d}=e;return Object(r.createElement)(r.Fragment,null,Object(r.createElement)("span",{className:"screen-reader-text"},Object(n.__)("Previous price:","woo-gutenberg-products-block")),Object(r.createElement)(a.a,{currency:t,renderText:e=>Object(r.createElement)("del",{className:s()("wc-block-components-product-price__regular",c),style:l},e),value:o}),Object(r.createElement)("span",{className:"screen-reader-text"},Object(n.__)("Discounted price:","woo-gutenberg-products-block")),Object(r.createElement)(a.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:n,format:l="<price/>",maxPrice:o,minPrice:d,price:m,priceClassName:b,priceStyle:p,regularPrice:O,regularPriceClassName:j,regularPriceStyle:g}=e;const y=s()(c,"price","wc-block-components-product-price",{["wc-block-components-product-price--align-"+t]:t});l.includes("<price/>")||(l="<price/>",console.error("Price formats need to include the `<price/>` tag."));const _=O&&m!==O;let f=Object(r.createElement)("span",{className:s()("wc-block-components-product-price__value",b)});return _?f=Object(r.createElement)(u,{currency:n,price:m,priceClassName:b,priceStyle:p,regularPrice:O,regularPriceClassName:j,regularPriceStyle:g}):void 0!==d&&void 0!==o?f=Object(r.createElement)(i,{currency:n,maxPrice:o,minPrice:d,priceClassName:b,priceStyle:p}):m&&(f=Object(r.createElement)(a.a,{className:s()("wc-block-components-product-price__value",b),currency:n,value:m,style:p})),Object(r.createElement)("span",{className:y},Object(r.createInterpolateElement)(l,{price:f}))}},299:function(e,t){},300:function(e,t,c){"use strict";var r=c(13),n=c.n(r),a=c(0),l=c(22),s=c(7),o=c.n(s);c(301),t.a=e=>{let{className:t="",disabled:c=!1,name:r,permalink:s="",target:i,rel:u,style:d,onClick:m,...b}=e;const p=o()("wc-block-components-product-name",t);if(c){const e=b;return Object(a.createElement)("span",n()({className:p},e,{dangerouslySetInnerHTML:{__html:Object(l.decodeEntities)(r)}}))}return Object(a.createElement)("a",n()({className:p,href:s,target:i},b,{dangerouslySetInnerHTML:{__html:Object(l.decodeEntities)(r)},style:d}))}},301:function(e,t){},312:function(e,t,c){"use strict";c.r(t),c.d(t,"Block",(function(){return p}));var r=c(0),n=c(1),a=c(7),l=c.n(a),s=c(19),o=c(46),i=c(270),u=c(287),d=c(293),m=c(322),b=c(128);c(313);const p=e=>{const{className:t,align:c}=e,{parentClassName:a}=Object(o.useInnerBlockLayoutContext)(),{product:b}=Object(o.useProductDataContext)(),p=Object(i.a)(e),O=Object(u.a)(e),j=Object(d.a)(e),g=Object(m.a)(e);if(!b.id||!b.on_sale)return null;const y="string"==typeof c?"wc-block-components-product-sale-badge--align-"+c:"";return Object(r.createElement)("div",{className:l()("wc-block-components-product-sale-badge",t,y,{[a+"__product-onsale"]:a},O.className,p.className),style:{...O.style,...p.style,...j.style,...g.style}},Object(r.createElement)(s.a,{label:Object(n.__)("Sale","woo-gutenberg-products-block"),screenReaderLabel:Object(n.__)("Product on sale","woo-gutenberg-products-block")}))};t.default=Object(b.withProductDataContext)(p)},313:function(e,t){},322:function(e,t,c){"use strict";c.d(t,"a",(function(){return s}));var r=c(102),n=c(210),a=c(20),l=c(211);const s=e=>{if(!Object(n.a)()||"function"!=typeof r.__experimentalGetSpacingClassesAndStyles)return{style:{}};const t=Object(a.a)(e)?e:{},c=Object(l.a)(t.style);return Object(r.__experimentalGetSpacingClassesAndStyles)({...t,style:c})}},334:function(e,t){},335:function(e,t,c){"use strict";c.d(t,"a",(function(){return _}));var r=c(13),n=c.n(r),a=c(0),l=c(1),s=c(7),o=c.n(s),i=c(2),u=c(46),d=c(293),m=c(270),b=c(322),p=c(128),O=c(64),j=c(312);c(336);const g=()=>Object(a.createElement)("img",{src:i.PLACEHOLDER_IMG_SRC,alt:"",width:void 0,height:void 0}),y=e=>{let{image:t,loaded:c,showFullSize:r,fallbackAlt:l}=e;const{thumbnail:s,src:o,srcset:i,sizes:u,alt:d}=t||{},m={alt:d||l,hidden:!c,src:s,...r&&{src:o,srcSet:i,sizes:u}};return Object(a.createElement)(a.Fragment,null,m.src&&Object(a.createElement)("img",n()({"data-testid":"product-image"},m)),!t&&Object(a.createElement)(g,null))},_=e=>{const{className:t,imageSizing:c="full-size",showProductLink:r=!0,showSaleBadge:n,saleBadgeAlign:s="right"}=e,{parentClassName:i}=Object(u.useInnerBlockLayoutContext)(),{product:p,isLoading:_}=Object(u.useProductDataContext)(),{dispatchStoreEvent:f}=Object(O.a)(),k=Object(d.a)(e),w=Object(m.a)(e),N=Object(b.a)(e);if(!p.id)return Object(a.createElement)("div",{className:o()(t,"wc-block-components-product-image",{[i+"__product-image"]:i},w.className),style:{...k.style,...w.style,...N.style}},Object(a.createElement)(g,null));const v=!!p.images.length,E=v?p.images[0]:null,h=r?"a":a.Fragment,S=Object(l.sprintf)(
|
4 |
/* translators: %s is referring to the product name */
|
5 |
+
Object(l.__)("Link to %s","woo-gutenberg-products-block"),p.name),C={href:p.permalink,...!v&&{"aria-label":S},onClick:()=>{f("product-view-link",{product:p})}};return Object(a.createElement)("div",{className:o()(t,"wc-block-components-product-image",{[i+"__product-image"]:i},w.className),style:{...k.style,...w.style,...N.style}},Object(a.createElement)(h,r&&C,!!n&&Object(a.createElement)(j.default,{align:s,product:p}),Object(a.createElement)(y,{fallbackAlt:p.name,image:E,loaded:!_,showFullSize:"cropped"!==c})))};t.b=Object(p.withProductDataContext)(_)},336:function(e,t){},337:function(e,t,c){"use strict";c.d(t,"a",(function(){return O}));var r=c(0),n=c(7),a=c.n(n),l=c(46),s=c(210),o=c(128),i=c(300),u=c(64),d=c(287),m=c(322),b=c(293);c(338);const p=e=>{let{children:t,headingLevel:c,elementType:n="h"+c,...a}=e;return Object(r.createElement)(n,a,t)},O=e=>{const{className:t,headingLevel:c=2,showProductLink:n=!0,linkTarget:o,align:O}=e,{parentClassName:j}=Object(l.useInnerBlockLayoutContext)(),{product:g}=Object(l.useProductDataContext)(),{dispatchStoreEvent:y}=Object(u.a)(),_=Object(d.a)(e),f=Object(m.a)(e),k=Object(b.a)(e);return g.id?Object(r.createElement)(p,{headingLevel:c,className:a()(t,_.className,"wc-block-components-product-title",{[j+"__product-title"]:j,["wc-block-components-product-title--align-"+O]:O&&Object(s.a)()}),style:Object(s.a)()?{...f.style,...k.style,..._.style}:{}},Object(r.createElement)(i.a,{disabled:!n,name:g.name,permalink:g.permalink,target:o,onClick:()=>{y("product-view-link",{product:g})}})):Object(r.createElement)(p,{headingLevel:c,className:a()(t,_.className,"wc-block-components-product-title",{[j+"__product-title"]:j,["wc-block-components-product-title--align-"+O]:O&&Object(s.a)()}),style:Object(s.a)()?{...f.style,...k.style,..._.style}:{}})};t.b=Object(o.withProductDataContext)(O)},338:function(e,t){},339:function(e,t){},340:function(e,t){},358:function(e,t,c){"use strict";c.r(t),c.d(t,"Block",(function(){return m}));var r=c(0),n=c(7),a=c.n(n),l=c(298),s=c(38),o=c(46),i=c(287),u=c(293),d=c(128);c(334);const m=e=>{var t,c;const{className:n,textAlign:d}=e,{parentClassName:m}=Object(o.useInnerBlockLayoutContext)(),{product:b}=Object(o.useProductDataContext)(),p=Object(i.a)(e),O=Object(u.a)(e),j=a()("wc-block-components-product-price",n,p.className,{[m+"__product-price"]:m}),g={...O.style,...p.style};if(!b.id)return Object(r.createElement)(l.a,{align:d,className:j});const y=b.prices,_=Object(s.getCurrencyFromPriceResponse)(y),f=y.price!==y.regular_price,k=a()({[m+"__product-price__value"]:m,[m+"__product-price__value--on-sale"]:f});return Object(r.createElement)(l.a,{align:d,className:j,priceStyle:g,regularPriceStyle:g,priceClassName:k,currency:_,price:y.price,minPrice:null==y||null===(t=y.price_range)||void 0===t?void 0:t.min_amount,maxPrice:null==y||null===(c=y.price_range)||void 0===c?void 0:c.max_amount,regularPrice:y.regular_price,regularPriceClassName:a()({[m+"__product-price__regular"]:m})})};t.default=Object(d.withProductDataContext)(m)},359:function(e,t,c){"use strict";c.r(t),c.d(t,"Block",(function(){return b}));var r=c(0),n=c(1),a=c(7),l=c.n(a),s=c(46),o=c(287),i=c(293),u=c(322),d=c(128),m=c(85);c(339);const b=e=>{const{textAlign:t}=e,{parentClassName:c}=Object(s.useInnerBlockLayoutContext)(),{product:a}=Object(s.useProductDataContext)(),d=(e=>{const t=parseFloat(e.average_rating);return Number.isFinite(t)&&t>0?t:0})(a),b=Object(o.a)(e),p=Object(i.a)(e),O=Object(u.a)(e);if(!d)return null;const j={width:d/5*100+"%"},g=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"),d),y=(e=>{const t=Object(m.a)(e.review_count)?e.review_count:parseInt(e.review_count,10);return Number.isFinite(t)&&t>0?t:0})(a),_={__html:Object(n.sprintf)(
|
8 |
/* translators: %1$s is referring to the average rating value, %2$s is referring to the number of ratings */
|
9 |
+
Object(n._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",y,"woo-gutenberg-products-block"),Object(n.sprintf)('<strong class="rating">%f</strong>',d),Object(n.sprintf)('<span class="rating">%d</span>',y))};return Object(r.createElement)("div",{className:l()(b.className,"wc-block-components-product-rating",{[c+"__product-rating"]:c},{["has-text-align-"+t]:t}),style:{...b.style,...p.style,...O.style}},Object(r.createElement)("div",{className:l()("wc-block-components-product-rating__stars",c+"__product-rating__stars"),role:"img","aria-label":g},Object(r.createElement)("span",{style:j,dangerouslySetInnerHTML:_})))};t.default=Object(d.withProductDataContext)(b)},360:function(e,t,c){"use strict";c.r(t),c.d(t,"Block",(function(){return f}));var r=c(13),n=c.n(r),a=c(0),l=c(7),s=c.n(l),o=c(1),i=c(64),u=c(314),d=c(287),m=c(270),b=c(293),p=c(322),O=c(22),j=c(42),g=c(2),y=c(46),_=c(128);c(340);const f=e=>{const{className:t}=e,{parentClassName:c}=Object(y.useInnerBlockLayoutContext)(),{product:r}=Object(y.useProductDataContext)(),n=Object(d.a)(e),l=Object(m.a)(e),o=Object(b.a)(e),i=Object(p.a)(e),{textAlign:u}=e;return Object(a.createElement)("div",{className:s()(t,"wp-block-button","wc-block-components-product-button",{[c+"__product-add-to-cart"]:c},{["has-text-align-"+u]:u})},r.id?Object(a.createElement)(k,{product:r,colorStyles:n,borderStyles:l,typographyStyles:o,spacingStyles:i}):Object(a.createElement)(w,{colorStyles:n,borderStyles:l,typographyStyles:o,spacingStyles:i}))},k=e=>{let{product:t,colorStyles:c,borderStyles:r,typographyStyles:l,spacingStyles:d,textAlign:m}=e;const{id:b,permalink:p,add_to_cart:y,has_options:_,is_purchasable:f,is_in_stock:k}=t,{dispatchStoreEvent:w}=Object(i.a)(),{cartQuantity:N,addingToCart:v,addToCart:E}=Object(u.a)(b,"woocommerce/single-product/"+(b||0)),h=Number.isFinite(N)&&N>0,S=!_&&f&&k,C=Object(O.decodeEntities)((null==y?void 0:y.description)||""),x=h?Object(o.sprintf)(
|
10 |
/* translators: %s number of products in cart. */
|
11 |
+
Object(o._n)("%d in cart","%d in cart",N,"woo-gutenberg-products-block"),N):Object(O.decodeEntities)((null==y?void 0:y.text)||Object(o.__)("Add to cart","woo-gutenberg-products-block")),P=S?"button":"a",L={};return S?L.onClick=async()=>{await E(),w("cart-add-item",{product:t});const{cartRedirectAfterAdd:e}=Object(g.getSetting)("productsSettings");e&&(window.location.href=j.c)}:(L.href=p,L.rel="nofollow",L.onClick=()=>{w("product-view-link",{product:t})}),Object(a.createElement)(P,n()({"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:v,added:h},{["has-text-align-"+m]:m}),style:{...c.style,...r.style,...l.style,...d.style},disabled:v},L),x)},w=e=>{let{colorStyles:t,borderStyles:c,typographyStyles:r,spacingStyles:n}=e;return Object(a.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,...n.style},disabled:!0})};t.default=Object(_.withProductDataContext)(f)},466:function(e,t,c){"use strict";c.r(t);var r=c(0),n=c(36),a=c(46),l=c(335),s=c(337),o=c(359),i=c(312),u=c(358),d=c(360),m=c(379),b=e=>{let{product:t}=e;return Object(r.createElement)("div",{className:"cross-sells-product"},Object(r.createElement)(a.InnerBlockLayoutContextProvider,{parentName:"woocommerce/cart-cross-sells-block",parentClassName:"wp-block-cart-cross-sells-product"},Object(r.createElement)(a.ProductDataContextProvider,{isLoading:!1,product:t},Object(r.createElement)("div",null,Object(r.createElement)(l.a,{className:"",showSaleBadge:!1,productId:t.id,showProductLink:!1,saleBadgeAlign:"left",imageSizing:"full-size",isDescendentOfQueryLoop:!1}),Object(r.createElement)(s.a,{align:"",headingLevel:2,showProductLink:!0}),Object(r.createElement)(o.Block,null),Object(r.createElement)(i.Block,{productId:t.id,align:"left"}),Object(r.createElement)(u.Block,null)),t.is_in_stock?Object(r.createElement)(m.a,null):Object(r.createElement)(d.Block,null))))},p=e=>{let{products:t,columns:c}=e;const n=t.map((e,t)=>t>=c?null:Object(r.createElement)(b,{isLoading:!1,product:e,key:e.id}));return Object(r.createElement)("div",null,n)},O=c(158);t.default=e=>{let{className:t,columns:c}=e;const{crossSellsProducts:a}=Object(n.a)();return void 0===c&&(c=O.attributes.columns.default),Object(r.createElement)(p,{className:t,columns:c,products:a})}}}]);
|
build/cart-blocks/cart-express-payment--checkout-blocks/express-payment-frontend.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[7],{26:function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var s=n(0),o=n(12),a=n.n(o);function c(e){const t=Object(s.useRef)(e);return a()(e,t.current)||(t.current=e),t.current}},
|
2 |
/* translators: %s coupon code. */
|
3 |
Object(s.__)('Coupon code "%s" has been applied to your cart.',"woo-gutenberg-products-block"),t),{id:"coupon-form",type:"snackbar",context:e})}).catch(e=>{p({coupon:{message:Object(c.decodeEntities)(e.message),hidden:!1}}),receiveApplyingCoupon("")})},g=t=>{d(t).then(n=>{!0===n&&l("info",Object(s.sprintf)(
|
4 |
/* translators: %s coupon code. */
|
5 |
-
Object(s.__)('Coupon code "%s" has been removed from your cart.',"woo-gutenberg-products-block"),t),{id:"coupon-form",type:"snackbar",context:e})}).catch(t=>{i(t.message,{id:"coupon-form",context:e}),receiveApplyingCoupon("")})};return{appliedCoupons:t,isLoading:n,applyCoupon:b,removeCoupon:g,isApplyingCoupon:m,isRemovingCoupon:h}}},304:function(e,t){},309:function(e,t,n){"use strict";n.d(t,"b",(function(){return i})),n.d(t,"a",(function(){return l}));var s=n(26),o=n(17),a=n(5),c=n(3);const r=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{paymentMethodsInitialized:t,expressPaymentMethodsInitialized:n,availablePaymentMethods:r,availableExpressPaymentMethods:i}=Object(a.useSelect)(e=>{const t=e(c.PAYMENT_STORE_KEY);return{paymentMethodsInitialized:t.paymentMethodsInitialized(),expressPaymentMethodsInitialized:t.expressPaymentMethodsInitialized(),availableExpressPaymentMethods:t.getAvailableExpressPaymentMethods(),availablePaymentMethods:t.getAvailablePaymentMethods()}}),l=Object.values(r).map(e=>{let{name:t}=e;return t}),p=Object.values(i).map(e=>{let{name:t}=e;return t}),u=Object(o.getPaymentMethods)(),d=Object(o.getExpressPaymentMethods)(),m=Object.keys(u).reduce((e,t)=>(l.includes(t)&&(e[t]=u[t]),e),{}),h=Object.keys(d).reduce((e,t)=>(p.includes(t)&&(e[t]=d[t]),e),{}),b=Object(s.a)(m),g=Object(s.a)(h);return{paymentMethods:e?g:b,isInitialized:e?n:t}},i=()=>r(!1),l=()=>r(!0)},311:function(e,t,n){"use strict";var s=n(13),o=n.n(s),a=n(0),c=n(7),r=n.n(c);const i=e=>"wc-block-components-payment-method-icon wc-block-components-payment-method-icon--"+e;var l=e=>{let{id:t,src:n=null,alt:s=""}=e;return n?Object(a.createElement)("img",{className:i(t),src:n,alt:s}):null},p=n(42);const u=[{id:"alipay",alt:"Alipay",src:p.l+"payment-methods/alipay.svg"},{id:"amex",alt:"American Express",src:p.l+"payment-methods/amex.svg"},{id:"bancontact",alt:"Bancontact",src:p.l+"payment-methods/bancontact.svg"},{id:"diners",alt:"Diners Club",src:p.l+"payment-methods/diners.svg"},{id:"discover",alt:"Discover",src:p.l+"payment-methods/discover.svg"},{id:"eps",alt:"EPS",src:p.l+"payment-methods/eps.svg"},{id:"giropay",alt:"Giropay",src:p.l+"payment-methods/giropay.svg"},{id:"ideal",alt:"iDeal",src:p.l+"payment-methods/ideal.svg"},{id:"jcb",alt:"JCB",src:p.l+"payment-methods/jcb.svg"},{id:"laser",alt:"Laser",src:p.l+"payment-methods/laser.svg"},{id:"maestro",alt:"Maestro",src:p.l+"payment-methods/maestro.svg"},{id:"mastercard",alt:"Mastercard",src:p.l+"payment-methods/mastercard.svg"},{id:"multibanco",alt:"Multibanco",src:p.l+"payment-methods/multibanco.svg"},{id:"p24",alt:"Przelewy24",src:p.l+"payment-methods/p24.svg"},{id:"sepa",alt:"Sepa",src:p.l+"payment-methods/sepa.svg"},{id:"sofort",alt:"Sofort",src:p.l+"payment-methods/sofort.svg"},{id:"unionpay",alt:"Union Pay",src:p.l+"payment-methods/unionpay.svg"},{id:"visa",alt:"Visa",src:p.l+"payment-methods/visa.svg"},{id:"wechat",alt:"WeChat",src:p.l+"payment-methods/wechat.svg"}];var d=n(28);n(304),t.a=e=>{let{icons:t=[],align:n="center",className:s}=e;const c=(e=>{const t={};return e.forEach(e=>{let n={};"string"==typeof e&&(n={id:e,alt:e,src:null}),"object"==typeof e&&(n={id:e.id||"",alt:e.alt||"",src:e.src||null}),n.id&&Object(d.a)(n.id)&&!t[n.id]&&(t[n.id]=n)}),Object.values(t)})(t);if(0===c.length)return null;const i=r()("wc-block-components-payment-method-icons",{"wc-block-components-payment-method-icons--align-left":"left"===n,"wc-block-components-payment-method-icons--align-right":"right"===n},s);return Object(a.createElement)("div",{className:i},c.map(e=>{const t={...e,...(n=e.id,u.find(e=>e.id===n)||{})};var n;return Object(a.createElement)(l,o()({key:"payment-method-icon-"+e.id},t))}))}},348:function(e,t){},349:function(e,t,n){"use strict";var s=n(16),o=n.n(s),a=n(0),c=n(1),r=n(6),i=n(2),l=n(9),p=n(60);class u extends r.Component{constructor(){super(...arguments),o()(this,"state",{errorMessage:"",hasError:!1})}static getDerivedStateFromError(e){return{errorMessage:e.message,hasError:!0}}render(){const{hasError:e,errorMessage:t}=this.state,{isEditor:n}=this.props;if(e){let e=Object(c.__)("We are experiencing difficulties with this payment method. Please contact us for assistance.","woo-gutenberg-products-block");(n||i.CURRENT_USER_IS_ADMIN)&&(e=t||Object(c.__)("There was an error with this payment method. Please verify it's configured correctly.","woo-gutenberg-products-block"));const s=[{id:"0",content:e,isDismissible:!1,status:"error"}];return Object(a.createElement)(l.StoreNoticesContainer,{additionalNotices:s,context:p.noticeContexts.PAYMENTS})}return this.props.children}}u.defaultProps={isEditor:!1},t.a=u},374:function(e,t){},375:function(e,t,n){"use strict";var s=n(0),o=n(1),a=n(309),c=n(426),r=n(35),i=n(27),l=n.n(i),p=n(5),u=n(349),d=n(102);t.a=()=>{const{isEditor:e}=Object(r.a)(),{activePaymentMethod:t,paymentMethodData:n}=Object(p.useSelect)(e=>{const t=e(d.a);return{activePaymentMethod:t.getActivePaymentMethod(),paymentMethodData:t.getPaymentMethodData()}}),{__internalSetActivePaymentMethod:i,__internalSetPaymentStarted:m,__internalSetPaymentPristine:h,__internalSetPaymentError:b,__internalSetPaymentMethodData:g,__internalSetExpressPaymentError:y}=Object(p.useDispatch)(d.a),{paymentMethods:v}=Object(a.a)(),O=Object(c.a)(),j=Object(s.useRef)(t),E=Object(s.useRef)(n),P=Object(s.useCallback)(e=>()=>{j.current=t,E.current=n,m(),i(e)},[t,n,i,m]),S=Object(s.useCallback)(()=>{h(),i(j.current,E.current)},[i,h]),f=Object(s.useCallback)(e=>{b(),g(e),y(e),i(j.current,E.current)},[i,b,g,y]),_=Object(s.useCallback)((function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";l()("Express Payment Methods should use the provided onError handler instead.",{alternative:"onError",plugin:"woocommerce-gutenberg-products-block",link:"https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4228"}),e?f(e):y("")}),[y,f]),C=Object.entries(v),k=C.length>0?C.map(t=>{let[n,o]=t;const a=e?o.edit:o.content;return Object(s.isValidElement)(a)?Object(s.createElement)("li",{key:n,id:"express-payment-method-"+n},Object(s.cloneElement)(a,{...O,onClick:P(n),onClose:S,onError:f,setExpressPaymentError:_})):null}):Object(s.createElement)("li",{key:"noneRegistered"},Object(o.__)("No registered Payment Methods","woo-gutenberg-products-block"));return Object(s.createElement)(u.a,{isEditor:e},Object(s.createElement)("ul",{className:"wc-block-components-express-payment__event-buttons"},k))}},406:function(e,t,n){"use strict";var s=n(0),o=n(18);const a=Object(s.createElement)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(s.createElement)(o.Path,{fillRule:"evenodd",d:"M5.5 9.5v-2h13v2h-13zm0 3v4h13v-4h-13zM4 7a1 1 0 011-1h14a1 1 0 011 1v10a1 1 0 01-1 1H5a1 1 0 01-1-1V7z",clipRule:"evenodd"}));t.a=a},426:function(e,t,n){"use strict";n.d(t,"a",(function(){return z}));var s=n(1),o=n(38),a=n(0),c=n(7),r=n.n(c),i=n(18),l=Object(a.createElement)(i.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(a.createElement)("g",{fill:"none",fillRule:"evenodd"},Object(a.createElement)("path",{d:"M0 0h24v24H0z"}),Object(a.createElement)("path",{fill:"#000",fillRule:"nonzero",d:"M17.3 8v1c1 .2 1.4.9 1.4 1.7h-1c0-.6-.3-1-1-1-.8 0-1.3.4-1.3.9 0 .4.3.6 1.4 1 1 .2 2 .6 2 1.9 0 .9-.6 1.4-1.5 1.5v1H16v-1c-.9-.1-1.6-.7-1.7-1.7h1c0 .6.4 1 1.3 1 1 0 1.2-.5 1.2-.8 0-.4-.2-.8-1.3-1.1-1.3-.3-2.1-.8-2.1-1.8 0-.9.7-1.5 1.6-1.6V8h1.3zM12 10v1H6v-1h6zm2-2v1H6V8h8zM2 4v16h20V4H2zm2 14V6h16v12H4z"}),Object(a.createElement)("path",{stroke:"#000",strokeLinecap:"round",d:"M6 16c2.6 0 3.9-3 1.7-3-2 0-1 3 1.5 3 1 0 1-.8 2.8-.8"}))),p=Object(a.createElement)(i.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(a.createElement)(i.Path,{fillRule:"evenodd",d:"M18.646 9H20V8l-1-.5L12 4 5 7.5 4 8v1h14.646zm-3-1.5L12 5.677 8.354 7.5h7.292zm-7.897 9.44v-6.5h-1.5v6.5h1.5zm5-6.5v6.5h-1.5v-6.5h1.5zm5 0v6.5h-1.5v-6.5h1.5zm2.252 8.81c0 .414-.334.75-.748.75H4.752a.75.75 0 010-1.5h14.5a.75.75 0 01.749.75z",clipRule:"evenodd"})),u=Object(a.createElement)(i.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(a.createElement)(i.Path,{d:"M3.25 12a8.75 8.75 0 1117.5 0 8.75 8.75 0 01-17.5 0zM12 4.75a7.25 7.25 0 100 14.5 7.25 7.25 0 000-14.5zm-1.338 4.877c-.314.22-.412.452-.412.623 0 .171.098.403.412.623.312.218.783.377 1.338.377.825 0 1.605.233 2.198.648.59.414 1.052 1.057 1.052 1.852 0 .795-.461 1.438-1.052 1.852-.41.286-.907.486-1.448.582v.316a.75.75 0 01-1.5 0v-.316a3.64 3.64 0 01-1.448-.582c-.59-.414-1.052-1.057-1.052-1.852a.75.75 0 011.5 0c0 .171.098.403.412.623.312.218.783.377 1.338.377s1.026-.159 1.338-.377c.314-.22.412-.452.412-.623 0-.171-.098-.403-.412-.623-.312-.218-.783-.377-1.338-.377-.825 0-1.605-.233-2.198-.648-.59-.414-1.052-1.057-1.052-1.852 0-.795.461-1.438 1.052-1.852a3.64 3.64 0 011.448-.582V7.5a.75.75 0 011.5 0v.316c.54.096 1.039.296 1.448.582.59.414 1.052 1.057 1.052 1.852a.75.75 0 01-1.5 0c0-.171-.098-.403-.412-.623-.312-.218-.783-.377-1.338-.377s-1.026.159-1.338.377z"})),d=n(406),m=n(107),h=n(28),b=n(20);n(348);const g={bank:p,bill:u,card:d.a,checkPayment:l};var y=e=>{let{icon:t="",text:n=""}=e;const s=!!t,o=Object(a.useCallback)(e=>s&&Object(h.a)(e)&&Object(b.b)(g,e),[s]),c=r()("wc-block-components-payment-method-label",{"wc-block-components-payment-method-label--with-icon":s});return Object(a.createElement)("span",{className:c},o(t)?Object(a.createElement)(m.a,{icon:g[t]}):t,n)},v=n(311),O=n(2),j=n(27),E=n.n(j),P=n(142),S=n(5),f=n(3),_=n(9),C=n(36),k=n(303),w=n(40),M=n(82),x=n(115),R=n(83),A=n(84);const I=(e,t)=>{const n=[],o=(t,n)=>{const s=n+"_tax",o=Object(b.b)(e,n)&&Object(h.a)(e[n])?parseInt(e[n],10):0;return{key:n,label:t,value:o,valueWithTax:o+(Object(b.b)(e,s)&&Object(h.a)(e[s])?parseInt(e[s],10):0)}};return n.push(o(Object(s.__)("Subtotal:","woo-gutenberg-products-block"),"total_items")),n.push(o(Object(s.__)("Fees:","woo-gutenberg-products-block"),"total_fees")),n.push(o(Object(s.__)("Discount:","woo-gutenberg-products-block"),"total_discount")),n.push({key:"total_tax",label:Object(s.__)("Taxes:","woo-gutenberg-products-block"),value:parseInt(e.total_tax,10),valueWithTax:parseInt(e.total_tax,10)}),t&&n.push(o(Object(s.__)("Shipping:","woo-gutenberg-products-block"),"total_shipping")),n};var T=n(112);const z=()=>{const{onCheckoutBeforeProcessing:e,onCheckoutValidationBeforeProcessing:t,onCheckoutAfterProcessingWithSuccess:n,onCheckoutAfterProcessingWithError:c,onSubmit:r}=Object(M.b)(),{isCalculating:i,isComplete:l,isIdle:p,isProcessing:u,customerId:d}=Object(S.useSelect)(e=>{const t=e(f.CHECKOUT_STORE_KEY);return{isComplete:t.isComplete(),isIdle:t.isIdle(),isProcessing:t.isProcessing(),customerId:t.getCustomerId(),isCalculating:t.isCalculating()}}),{paymentStatus:m,activePaymentMethod:h,shouldSavePayment:b}=Object(S.useSelect)(e=>{const t=e(f.PAYMENT_STORE_KEY);return{paymentStatus:{isPristine:t.isPaymentPristine(),isStarted:t.isPaymentStarted(),isProcessing:t.isPaymentProcessing(),isFinished:t.isPaymentFinished(),hasError:t.hasPaymentError(),hasFailed:t.isPaymentFailed(),isSuccessful:t.isPaymentSuccess(),isDoingExpressPayment:t.isExpressPaymentMethodActive()},activePaymentMethod:t.getActivePaymentMethod(),shouldSavePayment:t.getShouldSavePaymentMethod()}}),{__internalSetExpressPaymentError:g}=Object(S.useDispatch)(f.PAYMENT_STORE_KEY),{onPaymentProcessing:j}=Object(x.b)(),{shippingErrorStatus:z,shippingErrorTypes:D,onShippingRateSuccess:V,onShippingRateFail:N,onShippingRateSelectSuccess:F,onShippingRateSelectFail:B}=Object(R.b)(),{shippingRates:L,isLoadingRates:Y,selectedRates:H,isSelectingRate:W,selectShippingRate:K,needsShipping:G}=Object(T.a)(),{billingAddress:U,shippingAddress:J,setShippingAddress:q}=Object(A.b)(),{cartItems:Q,cartFees:X,cartTotals:Z,extensions:$}=Object(C.a)(),{appliedCoupons:ee}=Object(k.a)(),te=Object(a.useRef)(I(Z,G)),ne=Object(a.useRef)({label:Object(s.__)("Total","woo-gutenberg-products-block"),value:parseInt(Z.total_price,10)});Object(a.useEffect)(()=>{te.current=I(Z,G),ne.current={label:Object(s.__)("Total","woo-gutenberg-products-block"),value:parseInt(Z.total_price,10)}},[Z,G]);const se=Object(a.useCallback)((function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";E()("setExpressPaymentError should only be used by Express Payment Methods (using the provided onError handler).",{alternative:"",plugin:"woocommerce-gutenberg-products-block",link:"https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4228"}),g(e)}),[g]);return{activePaymentMethod:h,billing:{appliedCoupons:ee,billingAddress:U,billingData:U,cartTotal:ne.current,cartTotalItems:te.current,currency:Object(o.getCurrencyFromPriceResponse)(Z),customerId:d,displayPricesIncludingTax:Object(O.getSetting)("displayCartPricesIncludingTax",!1)},cartData:{cartItems:Q,cartFees:X,extensions:$},checkoutStatus:{isCalculating:i,isComplete:l,isIdle:p,isProcessing:u},components:{LoadingMask:P.a,PaymentMethodIcons:v.a,PaymentMethodLabel:y,ValidationInputError:_.ValidationInputError},emitResponse:{noticeContexts:w.d,responseTypes:w.e},eventRegistration:{onCheckoutAfterProcessingWithError:c,onCheckoutAfterProcessingWithSuccess:n,onCheckoutBeforeProcessing:e,onCheckoutValidationBeforeProcessing:t,onPaymentProcessing:j,onShippingRateFail:N,onShippingRateSelectFail:B,onShippingRateSelectSuccess:F,onShippingRateSuccess:V},onSubmit:r,paymentStatus:m,setExpressPaymentError:se,shippingData:{isSelectingRate:W,needsShipping:G,selectedRates:H,setSelectedRates:K,setShippingAddress:q,shippingAddress:J,shippingRates:L,shippingRatesLoading:Y},shippingStatus:{shippingErrorStatus:z,shippingErrorTypes:D},shouldSavePayment:b}}},60:function(e,t,n){}}]);
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[7],{26:function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var s=n(0),o=n(12),a=n.n(o);function c(e){const t=Object(s.useRef)(e);return a()(e,t.current)||(t.current=e),t.current}},302:function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var s=n(1),o=n(5),a=n(3),c=n(22),r=n(36);const i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const{cartCoupons:t,cartIsLoading:n}=Object(r.a)(),{createErrorNotice:i}=Object(o.useDispatch)("core/notices"),{createNotice:l}=Object(o.useDispatch)("core/notices"),{setValidationErrors:p}=Object(o.useDispatch)(a.VALIDATION_STORE_KEY),{applyCoupon:u,removeCoupon:d,isApplyingCoupon:m,isRemovingCoupon:h}=Object(o.useSelect)((e,t)=>{let{dispatch:n}=t;const s=e(a.CART_STORE_KEY),o=n(a.CART_STORE_KEY);return{applyCoupon:o.applyCoupon,removeCoupon:o.removeCoupon,isApplyingCoupon:s.isApplyingCoupon(),isRemovingCoupon:s.isRemovingCoupon(),receiveApplyingCoupon:o.receiveApplyingCoupon}},[i,l]),b=t=>{u(t).then(n=>{!0===n&&l("info",Object(s.sprintf)(
|
2 |
/* translators: %s coupon code. */
|
3 |
Object(s.__)('Coupon code "%s" has been applied to your cart.',"woo-gutenberg-products-block"),t),{id:"coupon-form",type:"snackbar",context:e})}).catch(e=>{p({coupon:{message:Object(c.decodeEntities)(e.message),hidden:!1}}),receiveApplyingCoupon("")})},g=t=>{d(t).then(n=>{!0===n&&l("info",Object(s.sprintf)(
|
4 |
/* translators: %s coupon code. */
|
5 |
+
Object(s.__)('Coupon code "%s" has been removed from your cart.',"woo-gutenberg-products-block"),t),{id:"coupon-form",type:"snackbar",context:e})}).catch(t=>{i(t.message,{id:"coupon-form",context:e}),receiveApplyingCoupon("")})};return{appliedCoupons:t,isLoading:n,applyCoupon:b,removeCoupon:g,isApplyingCoupon:m,isRemovingCoupon:h}}},303:function(e,t){},308:function(e,t,n){"use strict";n.d(t,"b",(function(){return i})),n.d(t,"a",(function(){return l}));var s=n(26),o=n(17),a=n(5),c=n(3);const r=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{paymentMethodsInitialized:t,expressPaymentMethodsInitialized:n,availablePaymentMethods:r,availableExpressPaymentMethods:i}=Object(a.useSelect)(e=>{const t=e(c.PAYMENT_STORE_KEY);return{paymentMethodsInitialized:t.paymentMethodsInitialized(),expressPaymentMethodsInitialized:t.expressPaymentMethodsInitialized(),availableExpressPaymentMethods:t.getAvailableExpressPaymentMethods(),availablePaymentMethods:t.getAvailablePaymentMethods()}}),l=Object.values(r).map(e=>{let{name:t}=e;return t}),p=Object.values(i).map(e=>{let{name:t}=e;return t}),u=Object(o.getPaymentMethods)(),d=Object(o.getExpressPaymentMethods)(),m=Object.keys(u).reduce((e,t)=>(l.includes(t)&&(e[t]=u[t]),e),{}),h=Object.keys(d).reduce((e,t)=>(p.includes(t)&&(e[t]=d[t]),e),{}),b=Object(s.a)(m),g=Object(s.a)(h);return{paymentMethods:e?g:b,isInitialized:e?n:t}},i=()=>r(!1),l=()=>r(!0)},310:function(e,t,n){"use strict";var s=n(13),o=n.n(s),a=n(0),c=n(7),r=n.n(c);const i=e=>"wc-block-components-payment-method-icon wc-block-components-payment-method-icon--"+e;var l=e=>{let{id:t,src:n=null,alt:s=""}=e;return n?Object(a.createElement)("img",{className:i(t),src:n,alt:s}):null},p=n(42);const u=[{id:"alipay",alt:"Alipay",src:p.l+"payment-methods/alipay.svg"},{id:"amex",alt:"American Express",src:p.l+"payment-methods/amex.svg"},{id:"bancontact",alt:"Bancontact",src:p.l+"payment-methods/bancontact.svg"},{id:"diners",alt:"Diners Club",src:p.l+"payment-methods/diners.svg"},{id:"discover",alt:"Discover",src:p.l+"payment-methods/discover.svg"},{id:"eps",alt:"EPS",src:p.l+"payment-methods/eps.svg"},{id:"giropay",alt:"Giropay",src:p.l+"payment-methods/giropay.svg"},{id:"ideal",alt:"iDeal",src:p.l+"payment-methods/ideal.svg"},{id:"jcb",alt:"JCB",src:p.l+"payment-methods/jcb.svg"},{id:"laser",alt:"Laser",src:p.l+"payment-methods/laser.svg"},{id:"maestro",alt:"Maestro",src:p.l+"payment-methods/maestro.svg"},{id:"mastercard",alt:"Mastercard",src:p.l+"payment-methods/mastercard.svg"},{id:"multibanco",alt:"Multibanco",src:p.l+"payment-methods/multibanco.svg"},{id:"p24",alt:"Przelewy24",src:p.l+"payment-methods/p24.svg"},{id:"sepa",alt:"Sepa",src:p.l+"payment-methods/sepa.svg"},{id:"sofort",alt:"Sofort",src:p.l+"payment-methods/sofort.svg"},{id:"unionpay",alt:"Union Pay",src:p.l+"payment-methods/unionpay.svg"},{id:"visa",alt:"Visa",src:p.l+"payment-methods/visa.svg"},{id:"wechat",alt:"WeChat",src:p.l+"payment-methods/wechat.svg"}];var d=n(28);n(303),t.a=e=>{let{icons:t=[],align:n="center",className:s}=e;const c=(e=>{const t={};return e.forEach(e=>{let n={};"string"==typeof e&&(n={id:e,alt:e,src:null}),"object"==typeof e&&(n={id:e.id||"",alt:e.alt||"",src:e.src||null}),n.id&&Object(d.a)(n.id)&&!t[n.id]&&(t[n.id]=n)}),Object.values(t)})(t);if(0===c.length)return null;const i=r()("wc-block-components-payment-method-icons",{"wc-block-components-payment-method-icons--align-left":"left"===n,"wc-block-components-payment-method-icons--align-right":"right"===n},s);return Object(a.createElement)("div",{className:i},c.map(e=>{const t={...e,...(n=e.id,u.find(e=>e.id===n)||{})};var n;return Object(a.createElement)(l,o()({key:"payment-method-icon-"+e.id},t))}))}},348:function(e,t){},349:function(e,t,n){"use strict";var s=n(16),o=n.n(s),a=n(0),c=n(1),r=n(6),i=n(2),l=n(9),p=n(60);class u extends r.Component{constructor(){super(...arguments),o()(this,"state",{errorMessage:"",hasError:!1})}static getDerivedStateFromError(e){return{errorMessage:e.message,hasError:!0}}render(){const{hasError:e,errorMessage:t}=this.state,{isEditor:n}=this.props;if(e){let e=Object(c.__)("We are experiencing difficulties with this payment method. Please contact us for assistance.","woo-gutenberg-products-block");(n||i.CURRENT_USER_IS_ADMIN)&&(e=t||Object(c.__)("There was an error with this payment method. Please verify it's configured correctly.","woo-gutenberg-products-block"));const s=[{id:"0",content:e,isDismissible:!1,status:"error"}];return Object(a.createElement)(l.StoreNoticesContainer,{additionalNotices:s,context:p.noticeContexts.PAYMENTS})}return this.props.children}}u.defaultProps={isEditor:!1},t.a=u},374:function(e,t){},375:function(e,t,n){"use strict";var s=n(0),o=n(1),a=n(308),c=n(426),r=n(35),i=n(27),l=n.n(i),p=n(5),u=n(349),d=n(100);t.a=()=>{const{isEditor:e}=Object(r.a)(),{activePaymentMethod:t,paymentMethodData:n}=Object(p.useSelect)(e=>{const t=e(d.a);return{activePaymentMethod:t.getActivePaymentMethod(),paymentMethodData:t.getPaymentMethodData()}}),{__internalSetActivePaymentMethod:i,__internalSetPaymentStarted:m,__internalSetPaymentPristine:h,__internalSetPaymentError:b,__internalSetPaymentMethodData:g,__internalSetExpressPaymentError:y}=Object(p.useDispatch)(d.a),{paymentMethods:v}=Object(a.a)(),O=Object(c.a)(),E=Object(s.useRef)(t),j=Object(s.useRef)(n),P=Object(s.useCallback)(e=>()=>{E.current=t,j.current=n,m(),i(e)},[t,n,i,m]),S=Object(s.useCallback)(()=>{h(),i(E.current,j.current)},[i,h]),_=Object(s.useCallback)(e=>{b(),g(e),y(e),i(E.current,j.current)},[i,b,g,y]),f=Object(s.useCallback)((function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";l()("Express Payment Methods should use the provided onError handler instead.",{alternative:"onError",plugin:"woocommerce-gutenberg-products-block",link:"https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4228"}),e?_(e):y("")}),[y,_]),C=Object.entries(v),k=C.length>0?C.map(t=>{let[n,o]=t;const a=e?o.edit:o.content;return Object(s.isValidElement)(a)?Object(s.createElement)("li",{key:n,id:"express-payment-method-"+n},Object(s.cloneElement)(a,{...O,onClick:P(n),onClose:S,onError:_,setExpressPaymentError:f})):null}):Object(s.createElement)("li",{key:"noneRegistered"},Object(o.__)("No registered Payment Methods","woo-gutenberg-products-block"));return Object(s.createElement)(u.a,{isEditor:e},Object(s.createElement)("ul",{className:"wc-block-components-express-payment__event-buttons"},k))}},406:function(e,t,n){"use strict";var s=n(0),o=n(18);const a=Object(s.createElement)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(s.createElement)(o.Path,{fillRule:"evenodd",d:"M5.5 9.5v-2h13v2h-13zm0 3v4h13v-4h-13zM4 7a1 1 0 011-1h14a1 1 0 011 1v10a1 1 0 01-1 1H5a1 1 0 01-1-1V7z",clipRule:"evenodd"}));t.a=a},426:function(e,t,n){"use strict";n.d(t,"a",(function(){return T}));var s=n(1),o=n(38),a=n(0),c=n(7),r=n.n(c),i=n(18),l=Object(a.createElement)(i.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(a.createElement)("g",{fill:"none",fillRule:"evenodd"},Object(a.createElement)("path",{d:"M0 0h24v24H0z"}),Object(a.createElement)("path",{fill:"#000",fillRule:"nonzero",d:"M17.3 8v1c1 .2 1.4.9 1.4 1.7h-1c0-.6-.3-1-1-1-.8 0-1.3.4-1.3.9 0 .4.3.6 1.4 1 1 .2 2 .6 2 1.9 0 .9-.6 1.4-1.5 1.5v1H16v-1c-.9-.1-1.6-.7-1.7-1.7h1c0 .6.4 1 1.3 1 1 0 1.2-.5 1.2-.8 0-.4-.2-.8-1.3-1.1-1.3-.3-2.1-.8-2.1-1.8 0-.9.7-1.5 1.6-1.6V8h1.3zM12 10v1H6v-1h6zm2-2v1H6V8h8zM2 4v16h20V4H2zm2 14V6h16v12H4z"}),Object(a.createElement)("path",{stroke:"#000",strokeLinecap:"round",d:"M6 16c2.6 0 3.9-3 1.7-3-2 0-1 3 1.5 3 1 0 1-.8 2.8-.8"}))),p=Object(a.createElement)(i.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(a.createElement)(i.Path,{fillRule:"evenodd",d:"M18.646 9H20V8l-1-.5L12 4 5 7.5 4 8v1h14.646zm-3-1.5L12 5.677 8.354 7.5h7.292zm-7.897 9.44v-6.5h-1.5v6.5h1.5zm5-6.5v6.5h-1.5v-6.5h1.5zm5 0v6.5h-1.5v-6.5h1.5zm2.252 8.81c0 .414-.334.75-.748.75H4.752a.75.75 0 010-1.5h14.5a.75.75 0 01.749.75z",clipRule:"evenodd"})),u=Object(a.createElement)(i.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(a.createElement)(i.Path,{d:"M3.25 12a8.75 8.75 0 1117.5 0 8.75 8.75 0 01-17.5 0zM12 4.75a7.25 7.25 0 100 14.5 7.25 7.25 0 000-14.5zm-1.338 4.877c-.314.22-.412.452-.412.623 0 .171.098.403.412.623.312.218.783.377 1.338.377.825 0 1.605.233 2.198.648.59.414 1.052 1.057 1.052 1.852 0 .795-.461 1.438-1.052 1.852-.41.286-.907.486-1.448.582v.316a.75.75 0 01-1.5 0v-.316a3.64 3.64 0 01-1.448-.582c-.59-.414-1.052-1.057-1.052-1.852a.75.75 0 011.5 0c0 .171.098.403.412.623.312.218.783.377 1.338.377s1.026-.159 1.338-.377c.314-.22.412-.452.412-.623 0-.171-.098-.403-.412-.623-.312-.218-.783-.377-1.338-.377-.825 0-1.605-.233-2.198-.648-.59-.414-1.052-1.057-1.052-1.852 0-.795.461-1.438 1.052-1.852a3.64 3.64 0 011.448-.582V7.5a.75.75 0 011.5 0v.316c.54.096 1.039.296 1.448.582.59.414 1.052 1.057 1.052 1.852a.75.75 0 01-1.5 0c0-.171-.098-.403-.412-.623-.312-.218-.783-.377-1.338-.377s-1.026.159-1.338.377z"})),d=n(406),m=n(105),h=n(28),b=n(20);n(348);const g={bank:p,bill:u,card:d.a,checkPayment:l};var y=e=>{let{icon:t="",text:n=""}=e;const s=!!t,o=Object(a.useCallback)(e=>s&&Object(h.a)(e)&&Object(b.b)(g,e),[s]),c=r()("wc-block-components-payment-method-label",{"wc-block-components-payment-method-label--with-icon":s});return Object(a.createElement)("span",{className:c},o(t)?Object(a.createElement)(m.a,{icon:g[t]}):t,n)},v=n(310),O=n(2),E=n(27),j=n.n(E),P=n(141),S=n(5),_=n(3),f=n(9),C=n(36),k=n(302),w=n(40),M=n(81),R=n(114),x=n(82);const A=(e,t)=>{const n=[],o=(t,n)=>{const s=n+"_tax",o=Object(b.b)(e,n)&&Object(h.a)(e[n])?parseInt(e[n],10):0;return{key:n,label:t,value:o,valueWithTax:o+(Object(b.b)(e,s)&&Object(h.a)(e[s])?parseInt(e[s],10):0)}};return n.push(o(Object(s.__)("Subtotal:","woo-gutenberg-products-block"),"total_items")),n.push(o(Object(s.__)("Fees:","woo-gutenberg-products-block"),"total_fees")),n.push(o(Object(s.__)("Discount:","woo-gutenberg-products-block"),"total_discount")),n.push({key:"total_tax",label:Object(s.__)("Taxes:","woo-gutenberg-products-block"),value:parseInt(e.total_tax,10),valueWithTax:parseInt(e.total_tax,10)}),t&&n.push(o(Object(s.__)("Shipping:","woo-gutenberg-products-block"),"total_shipping")),n};var I=n(111);const T=()=>{const{onCheckoutBeforeProcessing:e,onCheckoutValidationBeforeProcessing:t,onCheckoutAfterProcessingWithSuccess:n,onCheckoutAfterProcessingWithError:c,onSubmit:r}=Object(M.b)(),{isCalculating:i,isComplete:l,isIdle:p,isProcessing:u,customerId:d}=Object(S.useSelect)(e=>{const t=e(_.CHECKOUT_STORE_KEY);return{isComplete:t.isComplete(),isIdle:t.isIdle(),isProcessing:t.isProcessing(),customerId:t.getCustomerId(),isCalculating:t.isCalculating()}}),{paymentStatus:m,activePaymentMethod:h,shouldSavePayment:b}=Object(S.useSelect)(e=>{const t=e(_.PAYMENT_STORE_KEY);return{paymentStatus:{isPristine:t.isPaymentPristine(),isStarted:t.isPaymentStarted(),isProcessing:t.isPaymentProcessing(),isFinished:t.isPaymentFinished(),hasError:t.hasPaymentError(),hasFailed:t.isPaymentFailed(),isSuccessful:t.isPaymentSuccess(),isDoingExpressPayment:t.isExpressPaymentMethodActive()},activePaymentMethod:t.getActivePaymentMethod(),shouldSavePayment:t.getShouldSavePaymentMethod()}}),{__internalSetExpressPaymentError:g}=Object(S.useDispatch)(_.PAYMENT_STORE_KEY),{onPaymentProcessing:E}=Object(R.b)(),{shippingErrorStatus:T,shippingErrorTypes:z,onShippingRateSuccess:D,onShippingRateFail:V,onShippingRateSelectSuccess:N,onShippingRateSelectFail:F}=Object(x.b)(),{shippingRates:Y,isLoadingRates:B,selectedRates:L,isSelectingRate:H,selectShippingRate:K,needsShipping:W}=Object(I.a)(),{billingAddress:G,shippingAddress:U}=Object(S.useSelect)(e=>e(_.CART_STORE_KEY).getCustomerData()),{setShippingAddress:J}=Object(S.useDispatch)(_.CART_STORE_KEY),{cartItems:q,cartFees:Q,cartTotals:X,extensions:Z}=Object(C.a)(),{appliedCoupons:$}=Object(k.a)(),ee=Object(a.useRef)(A(X,W)),te=Object(a.useRef)({label:Object(s.__)("Total","woo-gutenberg-products-block"),value:parseInt(X.total_price,10)});Object(a.useEffect)(()=>{ee.current=A(X,W),te.current={label:Object(s.__)("Total","woo-gutenberg-products-block"),value:parseInt(X.total_price,10)}},[X,W]);const ne=Object(a.useCallback)((function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";j()("setExpressPaymentError should only be used by Express Payment Methods (using the provided onError handler).",{alternative:"",plugin:"woocommerce-gutenberg-products-block",link:"https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4228"}),g(e)}),[g]);return{activePaymentMethod:h,billing:{appliedCoupons:$,billingAddress:G,billingData:G,cartTotal:te.current,cartTotalItems:ee.current,currency:Object(o.getCurrencyFromPriceResponse)(X),customerId:d,displayPricesIncludingTax:Object(O.getSetting)("displayCartPricesIncludingTax",!1)},cartData:{cartItems:q,cartFees:Q,extensions:Z},checkoutStatus:{isCalculating:i,isComplete:l,isIdle:p,isProcessing:u},components:{LoadingMask:P.a,PaymentMethodIcons:v.a,PaymentMethodLabel:y,ValidationInputError:f.ValidationInputError},emitResponse:{noticeContexts:w.d,responseTypes:w.e},eventRegistration:{onCheckoutAfterProcessingWithError:c,onCheckoutAfterProcessingWithSuccess:n,onCheckoutBeforeProcessing:e,onCheckoutValidationBeforeProcessing:t,onPaymentProcessing:E,onShippingRateFail:V,onShippingRateSelectFail:F,onShippingRateSelectSuccess:N,onShippingRateSuccess:D},onSubmit:r,paymentStatus:m,setExpressPaymentError:ne,shippingData:{isSelectingRate:H,needsShipping:W,selectedRates:L,setSelectedRates:K,setShippingAddress:J,shippingAddress:U,shippingRates:Y,shippingRatesLoading:B},shippingStatus:{shippingErrorStatus:T,shippingErrorTypes:z},shouldSavePayment:b}}},60:function(e,t,n){}}]);
|
build/cart-blocks/cart-express-payment-frontend.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[20],{
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[20],{105:function(e,t,c){"use strict";var s=c(0);t.a=function(e){let{icon:t,size:c=24,...n}=e;return Object(s.cloneElement)(t,{width:c,height:c,...n})}},470:function(e,t,c){"use strict";c.r(t);var s=c(0),n=c(36),r=c(7),o=c.n(r),a=c(1),i=c(308),l=c(40),m=c(9),p=c(141),u=c(5),b=c(3),E=c(375);c(374);var O=()=>{const{paymentMethods:e,isInitialized:t}=Object(i.a)(),{isCalculating:c,isProcessing:n,isAfterProcessing:r,isBeforeProcessing:o,isComplete:O,hasError:g}=Object(u.useSelect)(e=>{const t=e(b.CHECKOUT_STORE_KEY);return{isCalculating:t.isCalculating(),isProcessing:t.isProcessing(),isAfterProcessing:t.isAfterProcessing(),isBeforeProcessing:t.isBeforeProcessing(),isComplete:t.isComplete(),hasError:t.hasError()}}),j=Object(u.useSelect)(e=>e(b.PAYMENT_STORE_KEY).isExpressPaymentMethodActive());if(!t||t&&0===Object.keys(e).length)return null;const d=n||r||o||O&&!g;return Object(s.createElement)(s.Fragment,null,Object(s.createElement)(p.a,{isLoading:c||d||j},Object(s.createElement)("div",{className:"wc-block-components-express-payment wc-block-components-express-payment--cart"},Object(s.createElement)("div",{className:"wc-block-components-express-payment__content"},Object(s.createElement)(m.StoreNoticesContainer,{context:l.d.EXPRESS_PAYMENTS}),Object(s.createElement)(E.a,null)))),Object(s.createElement)("div",{className:"wc-block-components-express-payment-continue-rule wc-block-components-express-payment-continue-rule--cart"},Object(a.__)("Or","woo-gutenberg-products-block")))};t.default=e=>{let{className:t}=e;const{cartNeedsPayment:c}=Object(n.a)();return c?Object(s.createElement)("div",{className:o()("wc-block-cart__payment-options",t)},Object(s.createElement)(O,null)):null}}}]);
|
build/cart-blocks/cart-line-items--mini-cart-contents-block/products-table-frontend.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[8],{
|
2 |
/* translators: %1$s min price, %2$s max price */
|
3 |
-
Object(r.__)("Price between %1$s and %2$s","woo-gutenberg-products-block"),Object(i.formatPrice)(l),Object(i.formatPrice)(c))),Object(a.createElement)("span",{"aria-hidden":!0},Object(a.createElement)(n.a,{className:o()("wc-block-components-product-price__value",s),currency:t,value:l,style:u})," — ",Object(a.createElement)(n.a,{className:o()("wc-block-components-product-price__value",s),currency:t,value:c,style:u})))},u=e=>{let{currency:t,regularPriceClassName:c,regularPriceStyle:l,regularPrice:i,priceClassName:s,priceStyle:u,price:m}=e;return Object(a.createElement)(a.Fragment,null,Object(a.createElement)("span",{className:"screen-reader-text"},Object(r.__)("Previous price:","woo-gutenberg-products-block")),Object(a.createElement)(n.a,{currency:t,renderText:e=>Object(a.createElement)("del",{className:o()("wc-block-components-product-price__regular",c),style:l},e),value:i}),Object(a.createElement)("span",{className:"screen-reader-text"},Object(r.__)("Discounted price:","woo-gutenberg-products-block")),Object(a.createElement)(n.a,{currency:t,renderText:e=>Object(a.createElement)("ins",{className:o()("wc-block-components-product-price__value","is-discounted",s),style:u},e),value:m}))};t.a=e=>{let{align:t,className:c,currency:r,format:l="<price/>",maxPrice:i,minPrice:m,price:b,priceClassName:p,priceStyle:d,regularPrice:O,regularPriceClassName:_,regularPriceStyle:j}=e;const y=o()(c,"price","wc-block-components-product-price",{["wc-block-components-product-price--align-"+t]:t});l.includes("<price/>")||(l="<price/>",console.error("Price formats need to include the `<price/>` tag."));const g=O&&b!==O;let f=Object(a.createElement)("span",{className:o()("wc-block-components-product-price__value",p)});return g?f=Object(a.createElement)(u,{currency:r,price:b,priceClassName:p,priceStyle:d,regularPrice:O,regularPriceClassName:_,regularPriceStyle:j}):void 0!==m&&void 0!==i?f=Object(a.createElement)(s,{currency:r,maxPrice:i,minPrice:m,priceClassName:p,priceStyle:d}):b&&(f=Object(a.createElement)(n.a,{className:o()("wc-block-components-product-price__value",p),currency:r,value:b,style:d})),Object(a.createElement)("span",{className:y},Object(a.createInterpolateElement)(l,{price:f}))}},
|
4 |
/* translators: %d stock amount (number of items in stock for product) */
|
5 |
Object(r.__)("%d left in stock","woo-gutenberg-products-block"),t)):null}},381:function(e,t,c){"use strict";var a=c(0),r=c(7),n=c.n(r),l=c(1),o=c(29),i=c(54),s=c(48);c(403);var u=e=>{let{className:t,quantity:c=1,minimum:r=1,maximum:u,onChange:m=(()=>{}),step:b=1,itemName:p="",disabled:d}=e;const O=n()("wc-block-components-quantity-selector",t),_=void 0!==u,j=c-b>=r,y=!_||c+b<=u,g=Object(a.useCallback)(e=>{let t=e;_&&(t=Math.min(t,Math.floor(u/b)*b)),t=Math.max(t,Math.ceil(r/b)*b),t=Math.floor(t/b)*b,t!==e&&m(t)},[_,u,r,m,b]),f=Object(s.a)(g,300);Object(a.useLayoutEffect)(()=>{g(c)},[c,g]);const k=Object(a.useCallback)(e=>{const t=void 0!==typeof e.key?"ArrowDown"===e.key:e.keyCode===i.DOWN,a=void 0!==typeof e.key?"ArrowUp"===e.key:e.keyCode===i.UP;t&&j&&(e.preventDefault(),m(c-b)),a&&y&&(e.preventDefault(),m(c+b))},[c,m,y,j,b]);return Object(a.createElement)("div",{className:O},Object(a.createElement)("input",{className:"wc-block-components-quantity-selector__input",disabled:d,type:"number",step:b,min:r,max:u,value:c,onKeyDown:k,onChange:e=>{let t=parseInt(e.target.value,10);t=isNaN(t)?c:t,t!==c&&(m(t),f(t))},"aria-label":Object(l.sprintf)(
|
6 |
/* translators: %s refers to the item name in the cart. */
|
@@ -8,8 +8,8 @@ Object(l.__)("Quantity of %s in your cart.","woo-gutenberg-products-block"),p)})
|
|
8 |
/* translators: %s refers to the item name in the cart. */
|
9 |
Object(l.__)("Quantity reduced to %s.","woo-gutenberg-products-block"),e)),g(e)}},"-"),Object(a.createElement)("button",{"aria-label":Object(l.__)("Increase quantity","woo-gutenberg-products-block"),disabled:d||!y,className:"wc-block-components-quantity-selector__button wc-block-components-quantity-selector__button--plus",onClick:()=>{const e=c+b;m(e),Object(o.speak)(Object(l.sprintf)(
|
10 |
/* translators: %s refers to the item name in the cart. */
|
11 |
-
Object(l.__)("Quantity increased to %s.","woo-gutenberg-products-block"),e)),g(e)}},"+"))},m=c(
|
12 |
/* translators: %s will be replaced by the discount amount */
|
13 |
Object(l.__)("Save %s","woo-gutenberg-products-block"),r);return Object(a.createElement)(h.a,{className:"wc-block-components-sale-badge"},Object(a.createInterpolateElement)(n,{price:Object(a.createElement)(N.a,{currency:t,value:c})}))},C=c(383),P=c(38),I=c(9),S=c(370),q=c(2);const D=(e,t)=>e.convertPrecision(t.minorUnit).getAmount(),A=e=>Object(I.mustContain)(e,"<price/>");var R=Object(a.forwardRef)((e,t)=>{let{lineItem:c,onRemove:r=(()=>{}),tabIndex:i}=e;const{name:s="",catalog_visibility:N="visible",short_description:h="",description:R="",low_stock_remaining:T=null,show_backorder_badge:F=!1,quantity_limits:M={minimum:1,maximum:99,multiple_of:1,editable:!0},sold_individually:L=!1,permalink:U="",images:V=[],variation:Q=[],item_data:H=[],prices:$={currency_code:"USD",currency_minor_unit:2,currency_symbol:"$",currency_prefix:"$",currency_suffix:"",currency_decimal_separator:".",currency_thousand_separator:",",price:"0",regular_price:"0",sale_price:"0",price_range:null,raw_prices:{precision:6,price:"0",regular_price:"0",sale_price:"0"}},totals:K={currency_code:"USD",currency_minor_unit:2,currency_symbol:"$",currency_prefix:"$",currency_suffix:"",currency_decimal_separator:".",currency_thousand_separator:",",line_subtotal:"0",line_subtotal_tax:"0"},extensions:B}=c,{quantity:W,setItemQuantity:Y,removeItem:J,isPendingDelete:z}=(e=>{const t={key:"",quantity:1};(e=>Object(j.a)(e)&&Object(j.b)(e,"key")&&Object(j.b)(e,"quantity")&&Object(y.a)(e.key)&&Object(g.a)(e.quantity))(e)&&(t.key=e.key,t.quantity=e.quantity);const{key:c="",quantity:r=1}=t,{cartErrors:n}=Object(f.a)(),{__internalIncrementCalculating:l,__internalDecrementCalculating:o}=Object(p.useDispatch)(d.CHECKOUT_STORE_KEY),[i,s]=Object(a.useState)(r),[u]=Object(O.a)(i,400),m=Object(_.a)(u),{removeItemFromCart:b,changeCartItemQuantity:k}=Object(p.useDispatch)(d.CART_STORE_KEY);Object(a.useEffect)(()=>s(r),[r]);const E=Object(p.useSelect)(e=>{if(!c)return{quantity:!1,delete:!1};const t=e(d.CART_STORE_KEY);return{quantity:t.isItemPendingQuantity(c),delete:t.isItemPendingDelete(c)}},[c]),w=Object(a.useCallback)(()=>c?b(c):Promise.resolve(!1),[c,b]);return Object(a.useEffect)(()=>{c&&Object(g.a)(m)&&Number.isFinite(m)&&m!==u&&k(c,u)},[c,k,u,m]),Object(a.useEffect)(()=>(E.delete?l():o(),()=>{E.delete&&o()}),[o,l,E.delete]),Object(a.useEffect)(()=>(E.quantity||u!==i?l():o(),()=>{(E.quantity||u!==i)&&o()}),[l,o,E.quantity,u,i]),{isPendingDelete:E.delete,quantity:i,setItemQuantity:s,removeItem:w,cartItemQuantityErrors:n}})(c),{dispatchStoreEvent:G}=Object(k.a)(),{receiveCart:X,...Z}=Object(f.a)(),ee=Object(a.useMemo)(()=>({context:"cart",cartItem:c,cart:Z}),[c,Z]),te=Object(P.getCurrencyFromPriceResponse)($),ce=Object(I.__experimentalApplyCheckoutFilter)({filterName:"itemName",defaultValue:s,extensions:B,arg:ee}),ae=Object(S.a)({amount:parseInt($.raw_prices.regular_price,10),precision:$.raw_prices.precision}),re=Object(S.a)({amount:parseInt($.raw_prices.price,10),precision:$.raw_prices.precision}),ne=ae.subtract(re),le=ne.multiply(W),oe=Object(P.getCurrencyFromPriceResponse)(K);let ie=parseInt(K.line_subtotal,10);Object(q.getSetting)("displayCartPricesIncludingTax",!1)&&(ie+=parseInt(K.line_subtotal_tax,10));const se=Object(S.a)({amount:ie,precision:oe.minorUnit}),ue=V.length?V[0]:{},me="hidden"===N||"search"===N,be=Object(I.__experimentalApplyCheckoutFilter)({filterName:"cartItemClass",defaultValue:"",extensions:B,arg:ee}),pe=Object(I.__experimentalApplyCheckoutFilter)({filterName:"cartItemPrice",defaultValue:"<price/>",extensions:B,arg:ee,validation:A}),de=Object(I.__experimentalApplyCheckoutFilter)({filterName:"subtotalPriceFormat",defaultValue:"<price/>",extensions:B,arg:ee,validation:A}),Oe=Object(I.__experimentalApplyCheckoutFilter)({filterName:"saleBadgePriceFormat",defaultValue:"<price/>",extensions:B,arg:ee,validation:A}),_e=Object(I.__experimentalApplyCheckoutFilter)({filterName:"showRemoveItemLink",defaultValue:!0,extensions:B,arg:ee});return Object(a.createElement)("tr",{className:n()("wc-block-cart-items__row",be,{"is-disabled":z}),ref:t,tabIndex:i},Object(a.createElement)("td",{className:"wc-block-cart-item__image","aria-hidden":!Object(j.b)(ue,"alt")||!ue.alt},me?Object(a.createElement)(E.a,{image:ue,fallbackAlt:ce}):Object(a.createElement)("a",{href:U,tabIndex:-1},Object(a.createElement)(E.a,{image:ue,fallbackAlt:ce}))),Object(a.createElement)("td",{className:"wc-block-cart-item__product"},Object(a.createElement)("div",{className:"wc-block-cart-item__wrap"},Object(a.createElement)(b.a,{disabled:z||me,name:ce,permalink:U}),F?Object(a.createElement)(w.a,null):!!T&&Object(a.createElement)(v.a,{lowStockRemaining:T}),Object(a.createElement)("div",{className:"wc-block-cart-item__prices"},Object(a.createElement)(m.a,{currency:te,regularPrice:D(ae,te),price:D(re,te),format:de})),Object(a.createElement)(x,{currency:te,saleAmount:D(ne,te),format:Oe}),Object(a.createElement)(C.a,{shortDescription:h,fullDescription:R,itemData:H,variation:Q}),Object(a.createElement)("div",{className:"wc-block-cart-item__quantity"},!L&&!!M.editable&&Object(a.createElement)(u,{disabled:z,quantity:W,minimum:M.minimum,maximum:M.maximum,step:M.multiple_of,onChange:e=>{Y(e),G("cart-set-item-quantity",{product:c,quantity:e})},itemName:ce}),_e&&Object(a.createElem
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[8],{108:function(e,t,c){"use strict";var a=c(13),r=c.n(a),n=c(0),l=c(142),o=c(7),i=c.n(o);c(208);const s=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:a,onValueChange:o,displayType:u="text",...m}=e;const b="string"==typeof c?parseInt(c,10):c;if(!Number.isFinite(b))return null;const p=b/10**a.minorUnit;if(!Number.isFinite(p))return null;const d=i()("wc-block-formatted-money-amount","wc-block-components-formatted-money-amount",t),O={...m,...s(a),value:void 0,currency:void 0,onValueChange:void 0},_=o?e=>{const t=+e.value*10**a.minorUnit;o(t)}:()=>{};return Object(n.createElement)(l.a,r()({className:d,displayType:u},O,{value:p,onValueChange:_}))}},208:function(e,t){},298:function(e,t,c){"use strict";var a=c(0),r=c(1),n=c(108),l=c(7),o=c.n(l),i=c(38);c(299);const s=e=>{let{currency:t,maxPrice:c,minPrice:l,priceClassName:s,priceStyle:u={}}=e;return Object(a.createElement)(a.Fragment,null,Object(a.createElement)("span",{className:"screen-reader-text"},Object(r.sprintf)(
|
2 |
/* translators: %1$s min price, %2$s max price */
|
3 |
+
Object(r.__)("Price between %1$s and %2$s","woo-gutenberg-products-block"),Object(i.formatPrice)(l),Object(i.formatPrice)(c))),Object(a.createElement)("span",{"aria-hidden":!0},Object(a.createElement)(n.a,{className:o()("wc-block-components-product-price__value",s),currency:t,value:l,style:u})," — ",Object(a.createElement)(n.a,{className:o()("wc-block-components-product-price__value",s),currency:t,value:c,style:u})))},u=e=>{let{currency:t,regularPriceClassName:c,regularPriceStyle:l,regularPrice:i,priceClassName:s,priceStyle:u,price:m}=e;return Object(a.createElement)(a.Fragment,null,Object(a.createElement)("span",{className:"screen-reader-text"},Object(r.__)("Previous price:","woo-gutenberg-products-block")),Object(a.createElement)(n.a,{currency:t,renderText:e=>Object(a.createElement)("del",{className:o()("wc-block-components-product-price__regular",c),style:l},e),value:i}),Object(a.createElement)("span",{className:"screen-reader-text"},Object(r.__)("Discounted price:","woo-gutenberg-products-block")),Object(a.createElement)(n.a,{currency:t,renderText:e=>Object(a.createElement)("ins",{className:o()("wc-block-components-product-price__value","is-discounted",s),style:u},e),value:m}))};t.a=e=>{let{align:t,className:c,currency:r,format:l="<price/>",maxPrice:i,minPrice:m,price:b,priceClassName:p,priceStyle:d,regularPrice:O,regularPriceClassName:_,regularPriceStyle:j}=e;const y=o()(c,"price","wc-block-components-product-price",{["wc-block-components-product-price--align-"+t]:t});l.includes("<price/>")||(l="<price/>",console.error("Price formats need to include the `<price/>` tag."));const g=O&&b!==O;let f=Object(a.createElement)("span",{className:o()("wc-block-components-product-price__value",p)});return g?f=Object(a.createElement)(u,{currency:r,price:b,priceClassName:p,priceStyle:d,regularPrice:O,regularPriceClassName:_,regularPriceStyle:j}):void 0!==m&&void 0!==i?f=Object(a.createElement)(s,{currency:r,maxPrice:i,minPrice:m,priceClassName:p,priceStyle:d}):b&&(f=Object(a.createElement)(n.a,{className:o()("wc-block-components-product-price__value",p),currency:r,value:b,style:d})),Object(a.createElement)("span",{className:y},Object(a.createInterpolateElement)(l,{price:f}))}},299:function(e,t){},300:function(e,t,c){"use strict";var a=c(13),r=c.n(a),n=c(0),l=c(22),o=c(7),i=c.n(o);c(301),t.a=e=>{let{className:t="",disabled:c=!1,name:a,permalink:o="",target:s,rel:u,style:m,onClick:b,...p}=e;const d=i()("wc-block-components-product-name",t);if(c){const e=p;return Object(n.createElement)("span",r()({className:d},e,{dangerouslySetInnerHTML:{__html:Object(l.decodeEntities)(a)}}))}return Object(n.createElement)("a",r()({className:d,href:o,target:s},p,{dangerouslySetInnerHTML:{__html:Object(l.decodeEntities)(a)},style:m}))}},301:function(e,t){},307:function(e,t,c){"use strict";var a=c(0),r=c(7),n=c.n(r);c(345),t.a=e=>{let{children:t,className:c}=e;return Object(a.createElement)("div",{className:n()("wc-block-components-product-badge",c)},t)}},323:function(e,t,c){"use strict";var a=c(0),r=c(122),n=c(123);const l=e=>{const t=e.indexOf("</p>");return-1===t?e:e.substr(0,t+4)},o=e=>e.replace(/<\/?[a-z][^>]*?>/gi,""),i=(e,t)=>e.replace(/[\s|\.\,]+$/i,"")+t,s=function(e,t){let c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"…";const a=o(e),r=a.split(" ").splice(0,t).join(" ");return Object(n.autop)(i(r,c))},u=function(e,t){let c=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"…";const r=o(e),l=r.slice(0,t);if(c)return Object(n.autop)(i(l,a));const s=l.match(/([\s]+)/g),u=s?s.length:0,m=r.slice(0,t+u);return Object(n.autop)(i(m,a))};t.a=e=>{let{source:t,maxLength:c=15,countType:o="words",className:i="",style:m={}}=e;const b=Object(a.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 a=Object(n.autop)(e),o=Object(r.count)(a,c);if(o<=t)return a;const i=l(a),m=Object(r.count)(i,c);return m<=t?i:"words"===c?s(i,t):u(i,t,"characters_including_spaces"===c)}(t,c,o),[t,c,o]);return Object(a.createElement)(a.RawHTML,{style:m,className:i},b)}},344:function(e,t){},345:function(e,t){},346:function(e,t){},347:function(e,t){},371:function(e,t,c){"use strict";var a=c(13),r=c.n(a),n=c(0),l=c(22),o=c(2);c(344),t.a=e=>{let{image:t={},fallbackAlt:c=""}=e;const a=t.thumbnail?{src:t.thumbnail,alt:Object(l.decodeEntities)(t.alt)||c||"Product Image"}:{src:o.PLACEHOLDER_IMG_SRC,alt:""};return Object(n.createElement)("img",r()({className:"wc-block-components-product-image"},a,{alt:a.alt}))}},372:function(e,t,c){"use strict";var a=c(0),r=c(1),n=c(307);t.a=()=>Object(a.createElement)(n.a,{className:"wc-block-components-product-backorder-badge"},Object(r.__)("Available on backorder","woo-gutenberg-products-block"))},373:function(e,t,c){"use strict";var a=c(0),r=c(1),n=c(307);t.a=e=>{let{lowStockRemaining:t}=e;return t?Object(a.createElement)(n.a,{className:"wc-block-components-product-low-stock-badge"},Object(r.sprintf)(
|
4 |
/* translators: %d stock amount (number of items in stock for product) */
|
5 |
Object(r.__)("%d left in stock","woo-gutenberg-products-block"),t)):null}},381:function(e,t,c){"use strict";var a=c(0),r=c(7),n=c.n(r),l=c(1),o=c(29),i=c(54),s=c(48);c(403);var u=e=>{let{className:t,quantity:c=1,minimum:r=1,maximum:u,onChange:m=(()=>{}),step:b=1,itemName:p="",disabled:d}=e;const O=n()("wc-block-components-quantity-selector",t),_=void 0!==u,j=c-b>=r,y=!_||c+b<=u,g=Object(a.useCallback)(e=>{let t=e;_&&(t=Math.min(t,Math.floor(u/b)*b)),t=Math.max(t,Math.ceil(r/b)*b),t=Math.floor(t/b)*b,t!==e&&m(t)},[_,u,r,m,b]),f=Object(s.a)(g,300);Object(a.useLayoutEffect)(()=>{g(c)},[c,g]);const k=Object(a.useCallback)(e=>{const t=void 0!==typeof e.key?"ArrowDown"===e.key:e.keyCode===i.DOWN,a=void 0!==typeof e.key?"ArrowUp"===e.key:e.keyCode===i.UP;t&&j&&(e.preventDefault(),m(c-b)),a&&y&&(e.preventDefault(),m(c+b))},[c,m,y,j,b]);return Object(a.createElement)("div",{className:O},Object(a.createElement)("input",{className:"wc-block-components-quantity-selector__input",disabled:d,type:"number",step:b,min:r,max:u,value:c,onKeyDown:k,onChange:e=>{let t=parseInt(e.target.value,10);t=isNaN(t)?c:t,t!==c&&(m(t),f(t))},"aria-label":Object(l.sprintf)(
|
6 |
/* translators: %s refers to the item name in the cart. */
|
8 |
/* translators: %s refers to the item name in the cart. */
|
9 |
Object(l.__)("Quantity reduced to %s.","woo-gutenberg-products-block"),e)),g(e)}},"-"),Object(a.createElement)("button",{"aria-label":Object(l.__)("Increase quantity","woo-gutenberg-products-block"),disabled:d||!y,className:"wc-block-components-quantity-selector__button wc-block-components-quantity-selector__button--plus",onClick:()=>{const e=c+b;m(e),Object(o.speak)(Object(l.sprintf)(
|
10 |
/* translators: %s refers to the item name in the cart. */
|
11 |
+
Object(l.__)("Quantity increased to %s.","woo-gutenberg-products-block"),e)),g(e)}},"+"))},m=c(298),b=c(300),p=c(5),d=c(3),O=c(89),_=c(56),j=c(20),y=c(28),g=c(85),f=c(36);var k=c(64),E=c(371),w=c(372),v=c(373),N=c(108),h=c(307),x=e=>{let{currency:t,saleAmount:c,format:r="<price/>"}=e;if(!c||c<=0)return null;r.includes("<price/>")||(r="<price/>",console.error("Price formats need to include the `<price/>` tag."));const n=Object(l.sprintf)(
|
12 |
/* translators: %s will be replaced by the discount amount */
|
13 |
Object(l.__)("Save %s","woo-gutenberg-products-block"),r);return Object(a.createElement)(h.a,{className:"wc-block-components-sale-badge"},Object(a.createInterpolateElement)(n,{price:Object(a.createElement)(N.a,{currency:t,value:c})}))},C=c(383),P=c(38),I=c(9),S=c(370),q=c(2);const D=(e,t)=>e.convertPrecision(t.minorUnit).getAmount(),A=e=>Object(I.mustContain)(e,"<price/>");var R=Object(a.forwardRef)((e,t)=>{let{lineItem:c,onRemove:r=(()=>{}),tabIndex:i}=e;const{name:s="",catalog_visibility:N="visible",short_description:h="",description:R="",low_stock_remaining:T=null,show_backorder_badge:F=!1,quantity_limits:M={minimum:1,maximum:99,multiple_of:1,editable:!0},sold_individually:L=!1,permalink:U="",images:V=[],variation:Q=[],item_data:H=[],prices:$={currency_code:"USD",currency_minor_unit:2,currency_symbol:"$",currency_prefix:"$",currency_suffix:"",currency_decimal_separator:".",currency_thousand_separator:",",price:"0",regular_price:"0",sale_price:"0",price_range:null,raw_prices:{precision:6,price:"0",regular_price:"0",sale_price:"0"}},totals:K={currency_code:"USD",currency_minor_unit:2,currency_symbol:"$",currency_prefix:"$",currency_suffix:"",currency_decimal_separator:".",currency_thousand_separator:",",line_subtotal:"0",line_subtotal_tax:"0"},extensions:B}=c,{quantity:W,setItemQuantity:Y,removeItem:J,isPendingDelete:z}=(e=>{const t={key:"",quantity:1};(e=>Object(j.a)(e)&&Object(j.b)(e,"key")&&Object(j.b)(e,"quantity")&&Object(y.a)(e.key)&&Object(g.a)(e.quantity))(e)&&(t.key=e.key,t.quantity=e.quantity);const{key:c="",quantity:r=1}=t,{cartErrors:n}=Object(f.a)(),{__internalIncrementCalculating:l,__internalDecrementCalculating:o}=Object(p.useDispatch)(d.CHECKOUT_STORE_KEY),[i,s]=Object(a.useState)(r),[u]=Object(O.a)(i,400),m=Object(_.a)(u),{removeItemFromCart:b,changeCartItemQuantity:k}=Object(p.useDispatch)(d.CART_STORE_KEY);Object(a.useEffect)(()=>s(r),[r]);const E=Object(p.useSelect)(e=>{if(!c)return{quantity:!1,delete:!1};const t=e(d.CART_STORE_KEY);return{quantity:t.isItemPendingQuantity(c),delete:t.isItemPendingDelete(c)}},[c]),w=Object(a.useCallback)(()=>c?b(c):Promise.resolve(!1),[c,b]);return Object(a.useEffect)(()=>{c&&Object(g.a)(m)&&Number.isFinite(m)&&m!==u&&k(c,u)},[c,k,u,m]),Object(a.useEffect)(()=>(E.delete?l():o(),()=>{E.delete&&o()}),[o,l,E.delete]),Object(a.useEffect)(()=>(E.quantity||u!==i?l():o(),()=>{(E.quantity||u!==i)&&o()}),[l,o,E.quantity,u,i]),{isPendingDelete:E.delete,quantity:i,setItemQuantity:s,removeItem:w,cartItemQuantityErrors:n}})(c),{dispatchStoreEvent:G}=Object(k.a)(),{receiveCart:X,...Z}=Object(f.a)(),ee=Object(a.useMemo)(()=>({context:"cart",cartItem:c,cart:Z}),[c,Z]),te=Object(P.getCurrencyFromPriceResponse)($),ce=Object(I.__experimentalApplyCheckoutFilter)({filterName:"itemName",defaultValue:s,extensions:B,arg:ee}),ae=Object(S.a)({amount:parseInt($.raw_prices.regular_price,10),precision:$.raw_prices.precision}),re=Object(S.a)({amount:parseInt($.raw_prices.price,10),precision:$.raw_prices.precision}),ne=ae.subtract(re),le=ne.multiply(W),oe=Object(P.getCurrencyFromPriceResponse)(K);let ie=parseInt(K.line_subtotal,10);Object(q.getSetting)("displayCartPricesIncludingTax",!1)&&(ie+=parseInt(K.line_subtotal_tax,10));const se=Object(S.a)({amount:ie,precision:oe.minorUnit}),ue=V.length?V[0]:{},me="hidden"===N||"search"===N,be=Object(I.__experimentalApplyCheckoutFilter)({filterName:"cartItemClass",defaultValue:"",extensions:B,arg:ee}),pe=Object(I.__experimentalApplyCheckoutFilter)({filterName:"cartItemPrice",defaultValue:"<price/>",extensions:B,arg:ee,validation:A}),de=Object(I.__experimentalApplyCheckoutFilter)({filterName:"subtotalPriceFormat",defaultValue:"<price/>",extensions:B,arg:ee,validation:A}),Oe=Object(I.__experimentalApplyCheckoutFilter)({filterName:"saleBadgePriceFormat",defaultValue:"<price/>",extensions:B,arg:ee,validation:A}),_e=Object(I.__experimentalApplyCheckoutFilter)({filterName:"showRemoveItemLink",defaultValue:!0,extensions:B,arg:ee});return Object(a.createElement)("tr",{className:n()("wc-block-cart-items__row",be,{"is-disabled":z}),ref:t,tabIndex:i},Object(a.createElement)("td",{className:"wc-block-cart-item__image","aria-hidden":!Object(j.b)(ue,"alt")||!ue.alt},me?Object(a.createElement)(E.a,{image:ue,fallbackAlt:ce}):Object(a.createElement)("a",{href:U,tabIndex:-1},Object(a.createElement)(E.a,{image:ue,fallbackAlt:ce}))),Object(a.createElement)("td",{className:"wc-block-cart-item__product"},Object(a.createElement)("div",{className:"wc-block-cart-item__wrap"},Object(a.createElement)(b.a,{disabled:z||me,name:ce,permalink:U}),F?Object(a.createElement)(w.a,null):!!T&&Object(a.createElement)(v.a,{lowStockRemaining:T}),Object(a.createElement)("div",{className:"wc-block-cart-item__prices"},Object(a.createElement)(m.a,{currency:te,regularPrice:D(ae,te),price:D(re,te),format:de})),Object(a.createElement)(x,{currency:te,saleAmount:D(ne,te),format:Oe}),Object(a.createElement)(C.a,{shortDescription:h,fullDescription:R,itemData:H,variation:Q}),Object(a.createElement)("div",{className:"wc-block-cart-item__quantity"},!L&&!!M.editable&&Object(a.createElement)(u,{disabled:z,quantity:W,minimum:M.minimum,maximum:M.maximum,step:M.multiple_of,onChange:e=>{Y(e),G("cart-set-item-quantity",{product:c,quantity:e})},itemName:ce}),_e&&Object(a.createElem
|