Version Description
- 2022-01-17 =
Enhancements
- Add support for the global style for the Price Filter block. (5559)
- Hold stock for 60 mins if the order is pending payment. (5546)
- Allow users to reinsert the WooCommerce Legacy Template block. (5545)
- Add support for the global style for the Stock Indicator block. (5525)
- Add support for the global style for the Summary Product block. (5524)
- Add support for the global style for the Product Title block. (5515)
- Fix duplicated checkout error notices. (5476)
- Store API: Throw errors when attempting to pay with a non-available payment method. (5440)
- Add support for the wide and full alignment for the legacy template block. (5433)
- Store API and Cart block now support defining a quantity stepper and a minimum quantity. (5406)
- Added controls to product grid blocks for filtering by stock levels. (4943)
Bug Fixes
- Use consistent HTML code for all rating sections, so that screen readers pronounce the rating correctly. (5552)
- All Products block displays thumbnails. (5551)
- Fixed a styling issue in the Checkout block when an order has multiple shipping packages. (5529)
- Fixed a visual bug (#5152) with the points and rewards plugin. (5430)
- Filter Products By Price block: Don't allow to insert negative values on inputs. (5123)
technical debt
- Remove invalid
$wpdb->prepare()
statement in Featured Category Block. (5471) - Remove Stripe Payment Method Integration (which is now part of the Stripe Payment Method extension itself). (5449)
Various
- Update the block theme folders to latest Gutenberg convention (i.e.
templates
andparts
). (5464)
Download this release
Release Info
Developer | automattic |
Plugin | WooCommerce Gutenberg Products Block |
Version | 6.8.0 |
Comparing to | |
See all releases |
Code changes from version 6.7.1 to 6.8.0
- assets/css/style.scss +2 -1
- assets/js/atomic/blocks/product-elements/add-to-cart/product-types/simple.js +2 -0
- assets/js/atomic/blocks/product-elements/add-to-cart/product-types/variable/index.js +2 -0
- assets/js/atomic/blocks/product-elements/add-to-cart/shared/quantity-input.js +47 -1
- assets/js/atomic/blocks/product-elements/rating/block.js +26 -2
- assets/js/atomic/blocks/product-elements/stock-indicator/block.js +10 -1
- assets/js/atomic/blocks/product-elements/stock-indicator/edit.js +4 -2
- assets/js/atomic/blocks/product-elements/stock-indicator/index.js +6 -0
- assets/js/atomic/blocks/product-elements/stock-indicator/save.tsx +21 -0
- assets/js/atomic/blocks/product-elements/stock-indicator/style.scss +0 -11
- assets/js/atomic/blocks/product-elements/stock-indicator/supports.js +18 -0
- assets/js/atomic/blocks/product-elements/summary/block.js +15 -1
- assets/js/atomic/blocks/product-elements/summary/edit.js +8 -1
- assets/js/atomic/blocks/product-elements/summary/editor.scss +5 -0
- assets/js/atomic/blocks/product-elements/summary/index.js +5 -0
- assets/js/atomic/blocks/product-elements/summary/save.tsx +21 -0
- assets/js/atomic/blocks/product-elements/summary/supports.js +18 -0
- assets/js/atomic/blocks/product-elements/title/block.tsx +36 -29
- assets/js/atomic/blocks/product-elements/title/edit.tsx +1 -0
- assets/js/atomic/blocks/product-elements/title/editor.scss +13 -0
- assets/js/atomic/blocks/product-elements/title/index.ts +28 -10
- assets/js/atomic/blocks/product-elements/title/save.tsx +21 -0
- assets/js/atomic/blocks/product-elements/title/style.scss +14 -3
- assets/js/base/components/cart-checkout/shipping-rates-control-package/style.scss +11 -0
- assets/js/base/components/formatted-monetary-amount/index.tsx +2 -0
- assets/js/base/components/price-slider/index.tsx +29 -0
- assets/js/base/components/price-slider/utils.ts +41 -0
- assets/js/base/components/quantity-selector/index.tsx +79 -19
- assets/js/base/components/quantity-selector/style.scss +4 -2
- assets/js/base/components/reviews/review-list-item/index.js +11 -1
- assets/js/base/components/reviews/review-list-item/style.scss +1 -1
- assets/js/base/components/summary/index.tsx +10 -1
- assets/js/base/context/providers/add-to-cart-form/form-state/constants.js +1 -1
- assets/js/base/context/providers/add-to-cart-form/form-state/index.js +5 -3
- assets/js/base/context/providers/cart-checkout/payment-methods/test/payment-method-data-context.js +13 -13
- assets/js/base/context/providers/cart-checkout/payment-methods/use-payment-method-registration.ts +2 -3
- assets/js/blocks/cart-checkout/cart/cart-line-items-table/cart-line-item-row.tsx +27 -14
- assets/js/blocks/cart-checkout/cart/style.scss +0 -7
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/block.tsx +1 -9
- assets/js/blocks/cart-checkout/mini-cart-contents/edit.tsx +1 -3
- assets/js/blocks/cart-checkout/mini-cart-contents/editor.scss +20 -3
- assets/js/blocks/cart-checkout/mini-cart-contents/index.tsx +0 -1
- assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/empty-mini-cart-contents-block/edit.tsx +34 -25
- assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/filled-mini-cart-contents-block/edit.tsx +1 -1
- assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/index.tsx +1 -0
- assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-footer-block/edit.tsx +4 -0
- assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-footer-block/index.tsx +2 -1
- assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-items-block/block.json +26 -0
- assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-items-block/edit.tsx +35 -0
- assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-items-block/frontend.tsx +5 -0
- assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-items-block/index.tsx +24 -0
- assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-products-table-block/block.json +2 -2
- assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-products-table-block/block.tsx +1 -1
- assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-products-table-block/edit.tsx +4 -0
- assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-products-table-block/index.tsx +2 -1
- assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-title-block/edit.tsx +4 -0
- assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-title-block/index.tsx +2 -1
- assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/register-components.ts +10 -0
- assets/js/blocks/cart-checkout/mini-cart/index.tsx +1 -0
- assets/js/blocks/cart-checkout/mini-cart/quantity-badge/style.scss +4 -4
- assets/js/blocks/cart-checkout/mini-cart/style.scss +12 -3
- assets/js/blocks/cart-checkout/payment-methods/no-payment-methods/index.js +1 -1
- assets/js/blocks/cart-checkout/payment-methods/test/payment-methods.js +5 -5
- assets/js/blocks/cart-checkout/shared/use-view-switcher.tsx +25 -7
- assets/js/blocks/legacy-template/constants.ts +10 -5
- assets/js/blocks/legacy-template/editor.scss +5 -0
- assets/js/blocks/legacy-template/index.tsx +103 -49
- assets/js/blocks/legacy-template/test/utils.ts +30 -0
- assets/js/blocks/legacy-template/types.ts +4 -0
- assets/js/blocks/legacy-template/utils.ts +24 -0
- assets/js/blocks/price-filter/block.js +1 -0
- assets/js/blocks/price-filter/edit.js +7 -12
- assets/js/blocks/price-filter/editor.scss +15 -9
- assets/js/blocks/price-filter/index.js +17 -1
- assets/js/blocks/price-filter/style.scss +25 -0
- assets/js/blocks/product-category/block.js +14 -0
- assets/js/blocks/product-new/block.js +14 -0
- assets/js/blocks/product-on-sale/block.js +14 -0
- assets/js/blocks/product-tag/block.js +14 -0
- assets/js/blocks/product-tag/index.js +8 -0
- assets/js/blocks/product-top-rated/block.js +14 -0
- assets/js/blocks/products-by-attribute/block.js +14 -0
- assets/js/blocks/products-by-attribute/index.js +8 -0
- assets/js/blocks/products/base-utils.js +1 -1
- assets/js/editor-components/feedback-prompt/index.js +10 -0
- assets/js/editor-components/product-stock-control/index.tsx +102 -0
- assets/js/hooks/style-attributes.ts +82 -0
- assets/js/payment-method-extensions/payment-methods/stripe/credit-card/constants.js +0 -1
- assets/js/payment-method-extensions/payment-methods/stripe/credit-card/elements.js +0 -161
- assets/js/payment-method-extensions/payment-methods/stripe/credit-card/index.js +0 -65
- assets/js/payment-method-extensions/payment-methods/stripe/credit-card/payment-method.js +0 -92
- assets/js/payment-method-extensions/payment-methods/stripe/credit-card/use-checkout-subscriptions.js +0 -97
- assets/js/payment-method-extensions/payment-methods/stripe/credit-card/use-element-options.js +0 -115
- assets/js/payment-method-extensions/payment-methods/stripe/credit-card/use-payment-intents.js +0 -104
- assets/js/payment-method-extensions/payment-methods/stripe/credit-card/use-payment-processing.js +0 -166
- assets/js/payment-method-extensions/payment-methods/stripe/index.js +0 -22
- assets/js/payment-method-extensions/payment-methods/stripe/payment-request/apple-pay-preview.js +0 -2
- assets/js/payment-method-extensions/payment-methods/stripe/payment-request/constants.js +0 -7
- assets/js/payment-method-extensions/payment-methods/stripe/payment-request/index.js +0 -76
- assets/js/payment-method-extensions/payment-methods/stripe/payment-request/payment-request-express.js +0 -113
- assets/js/payment-method-extensions/payment-methods/stripe/payment-request/use-checkout-subscriptions.js +0 -241
- assets/js/payment-method-extensions/payment-methods/stripe/payment-request/use-event-handlers.js +0 -48
- assets/js/payment-method-extensions/payment-methods/stripe/payment-request/use-initialization.js +0 -251
- assets/js/payment-method-extensions/payment-methods/stripe/stripe-utils/constants.js +0 -28
- assets/js/payment-method-extensions/payment-methods/stripe/stripe-utils/index.js +0 -3
- assets/js/payment-method-extensions/payment-methods/stripe/stripe-utils/load-stripe.js +0 -22
- assets/js/payment-method-extensions/payment-methods/stripe/stripe-utils/normalize.js +0 -176
- assets/js/payment-method-extensions/payment-methods/stripe/stripe-utils/type-defs.js +0 -324
- assets/js/payment-method-extensions/payment-methods/stripe/stripe-utils/utils.js +0 -281
- assets/js/previews/saved-payment-methods.js +1 -1
- assets/js/shared/context/product-data-context.js +3 -1
- assets/js/types/type-defs/cart-response.ts +2 -31
- assets/js/types/type-defs/cart.ts +6 -1
- assets/js/types/type-defs/payments.ts +1 -1
- assets/js/types/type-defs/product-response.ts +3 -1
- assets/js/utils/global-style.js +8 -0
- assets/js/utils/shared-attributes.js +8 -0
- build/active-filters-frontend.asset.php +1 -1
- build/active-filters-frontend.js +3 -3
- build/active-filters.asset.php +1 -1
- build/active-filters.js +5 -5
- build/all-products-frontend.asset.php +1 -1
- build/all-products-frontend.js +2 -2
- build/all-products.asset.php +1 -1
- build/all-products.js +18 -16
- build/all-reviews.asset.php +1 -1
- build/all-reviews.js +5 -3
- build/atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/image---8f355022.js +1 -0
- build/atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/image---a7e2bb9b.js +2 -2
- build/atomic-block-components/add-to-cart--atomic-block-components/button.js +1 -1
- build/atomic-block-components/add-to-cart-frontend.js +2 -2
- build/atomic-block-components/add-to-cart.js +2 -2
- build/atomic-block-components/button-frontend.js +1 -1
- build/atomic-block-components/button.js +2 -2
- build/atomic-block-components/category-list-frontend.js +1 -1
- build/atomic-block-components/category-list.js +1 -1
- build/atomic-block-components/image-frontend.js +1 -1
- build/atomic-block-components/image.js +2 -2
- build/atomic-block-components/price-frontend.js +2 -2
- build/atomic-block-components/price.js +2 -2
- build/atomic-block-components/rating-frontend.js +4 -2
- build/atomic-block-components/rating.js +4 -2
- build/atomic-block-components/sale-badge-frontend.js +1 -1
- build/atomic-block-components/sale-badge.js +1 -1
- build/atomic-block-components/sku-frontend.js +1 -1
- build/atomic-block-components/sku.js +1 -1
- build/atomic-block-components/stock-indicator--atomic-block-components/summary--atomic-block-components/title.js +1 -0
- build/atomic-block-components/stock-indicator-frontend.js +2 -2
- build/atomic-block-components/stock-indicator.js +2 -2
- build/atomic-block-components/summary-frontend.js +1 -1
- build/atomic-block-components/summary.js +1 -1
- build/atomic-block-components/tag-list-frontend.js +1 -1
- build/atomic-block-components/tag-list.js +1 -1
- build/atomic-block-components/title-frontend.js +1 -1
- build/atomic-block-components/title.js +1 -1
- build/attribute-filter-frontend.asset.php +1 -1
- build/attribute-filter-frontend.js +7 -7
- build/attribute-filter.asset.php +1 -1
- build/attribute-filter.js +11 -12
assets/css/style.scss
CHANGED
@@ -22,7 +22,8 @@
|
|
22 |
|
23 |
img {
|
24 |
height: auto;
|
25 |
-
width:
|
|
|
26 |
|
27 |
&[hidden] {
|
28 |
display: none;
|
22 |
|
23 |
img {
|
24 |
height: auto;
|
25 |
+
width: auto;
|
26 |
+
max-width: 100%;
|
27 |
|
28 |
&[hidden] {
|
29 |
display: none;
|
assets/js/atomic/blocks/product-elements/add-to-cart/product-types/simple.js
CHANGED
@@ -18,6 +18,7 @@ const Simple = () => {
|
|
18 |
quantity,
|
19 |
minQuantity,
|
20 |
maxQuantity,
|
|
|
21 |
dispatchActions,
|
22 |
isDisabled,
|
23 |
} = useAddToCartFormContext();
|
@@ -43,6 +44,7 @@ const Simple = () => {
|
|
43 |
value={ quantity }
|
44 |
min={ minQuantity }
|
45 |
max={ maxQuantity }
|
|
|
46 |
disabled={ isDisabled }
|
47 |
onChange={ dispatchActions.setQuantity }
|
48 |
/>
|
18 |
quantity,
|
19 |
minQuantity,
|
20 |
maxQuantity,
|
21 |
+
multipleOf,
|
22 |
dispatchActions,
|
23 |
isDisabled,
|
24 |
} = useAddToCartFormContext();
|
44 |
value={ quantity }
|
45 |
min={ minQuantity }
|
46 |
max={ maxQuantity }
|
47 |
+
step={ multipleOf }
|
48 |
disabled={ isDisabled }
|
49 |
onChange={ dispatchActions.setQuantity }
|
50 |
/>
|
assets/js/atomic/blocks/product-elements/add-to-cart/product-types/variable/index.js
CHANGED
@@ -23,6 +23,7 @@ const Variable = () => {
|
|
23 |
quantity,
|
24 |
minQuantity,
|
25 |
maxQuantity,
|
|
|
26 |
dispatchActions,
|
27 |
isDisabled,
|
28 |
} = useAddToCartFormContext();
|
@@ -52,6 +53,7 @@ const Variable = () => {
|
|
52 |
value={ quantity }
|
53 |
min={ minQuantity }
|
54 |
max={ maxQuantity }
|
|
|
55 |
disabled={ isDisabled }
|
56 |
onChange={ dispatchActions.setQuantity }
|
57 |
/>
|
23 |
quantity,
|
24 |
minQuantity,
|
25 |
maxQuantity,
|
26 |
+
multipleOf,
|
27 |
dispatchActions,
|
28 |
isDisabled,
|
29 |
} = useAddToCartFormContext();
|
53 |
value={ quantity }
|
54 |
min={ minQuantity }
|
55 |
max={ maxQuantity }
|
56 |
+
step={ multipleOf }
|
57 |
disabled={ isDisabled }
|
58 |
onChange={ dispatchActions.setQuantity }
|
59 |
/>
|
assets/js/atomic/blocks/product-elements/add-to-cart/shared/quantity-input.js
CHANGED
@@ -1,3 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
1 |
/**
|
2 |
* Quantity Input Component.
|
3 |
*
|
@@ -5,10 +10,49 @@
|
|
5 |
* @param {boolean} props.disabled Whether input is disabled or not.
|
6 |
* @param {number} props.min Minimum value for input.
|
7 |
* @param {number} props.max Maximum value for input.
|
|
|
8 |
* @param {number} props.value Value for input.
|
9 |
* @param {function():any} props.onChange Function to call on input change event.
|
10 |
*/
|
11 |
-
const QuantityInput = ( { disabled, min, max, value, onChange } ) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
return (
|
13 |
<input
|
14 |
className="wc-block-components-product-add-to-cart-quantity"
|
@@ -16,10 +60,12 @@ const QuantityInput = ( { disabled, min, max, value, onChange } ) => {
|
|
16 |
value={ value }
|
17 |
min={ min }
|
18 |
max={ max }
|
|
|
19 |
hidden={ max === 1 }
|
20 |
disabled={ disabled }
|
21 |
onChange={ ( e ) => {
|
22 |
onChange( e.target.value );
|
|
|
23 |
} }
|
24 |
/>
|
25 |
);
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { useDebouncedCallback } from 'use-debounce';
|
5 |
+
|
6 |
/**
|
7 |
* Quantity Input Component.
|
8 |
*
|
10 |
* @param {boolean} props.disabled Whether input is disabled or not.
|
11 |
* @param {number} props.min Minimum value for input.
|
12 |
* @param {number} props.max Maximum value for input.
|
13 |
+
* @param {number} props.step Step attribute for input.
|
14 |
* @param {number} props.value Value for input.
|
15 |
* @param {function():any} props.onChange Function to call on input change event.
|
16 |
*/
|
17 |
+
const QuantityInput = ( { disabled, min, max, step = 1, value, onChange } ) => {
|
18 |
+
const hasMaximum = typeof max !== 'undefined';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* The goal of this function is to normalize what was inserted,
|
22 |
+
* but after the customer has stopped typing.
|
23 |
+
*
|
24 |
+
* It's important to wait before normalizing or we end up with
|
25 |
+
* a frustrating experience, for example, if the minimum is 2 and
|
26 |
+
* the customer is trying to type "10", premature normalizing would
|
27 |
+
* always kick in at "1" and turn that into 2.
|
28 |
+
*
|
29 |
+
* Copied from <QuantitySelector>
|
30 |
+
*/
|
31 |
+
const normalizeQuantity = useDebouncedCallback( ( initialValue ) => {
|
32 |
+
// We copy the starting value.
|
33 |
+
let newValue = initialValue;
|
34 |
+
|
35 |
+
// We check if we have a maximum value, and select the lowest between what was inserted and the maximum.
|
36 |
+
if ( hasMaximum ) {
|
37 |
+
newValue = Math.min(
|
38 |
+
newValue,
|
39 |
+
// the maximum possible value in step increments.
|
40 |
+
Math.floor( max / step ) * step
|
41 |
+
);
|
42 |
+
}
|
43 |
+
|
44 |
+
// Select the biggest between what's inserted, the the minimum value in steps.
|
45 |
+
newValue = Math.max( newValue, Math.ceil( min / step ) * step );
|
46 |
+
|
47 |
+
// We round off the value to our steps.
|
48 |
+
newValue = Math.floor( newValue / step ) * step;
|
49 |
+
|
50 |
+
// Only commit if the value has changed
|
51 |
+
if ( newValue !== initialValue ) {
|
52 |
+
onChange( newValue );
|
53 |
+
}
|
54 |
+
}, 300 );
|
55 |
+
|
56 |
return (
|
57 |
<input
|
58 |
className="wc-block-components-product-add-to-cart-quantity"
|
60 |
value={ value }
|
61 |
min={ min }
|
62 |
max={ max }
|
63 |
+
step={ step }
|
64 |
hidden={ max === 1 }
|
65 |
disabled={ disabled }
|
66 |
onChange={ ( e ) => {
|
67 |
onChange( e.target.value );
|
68 |
+
normalizeQuantity( e.target.value );
|
69 |
} }
|
70 |
/>
|
71 |
);
|
assets/js/atomic/blocks/product-elements/rating/block.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import PropTypes from 'prop-types';
|
5 |
-
import { __, sprintf } from '@wordpress/i18n';
|
6 |
import classnames from 'classnames';
|
7 |
import {
|
8 |
useInnerBlockLayoutContext,
|
@@ -41,6 +41,21 @@ const Block = ( { className } ) => {
|
|
41 |
rating
|
42 |
);
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
return (
|
45 |
<div
|
46 |
className={ classnames(
|
@@ -59,7 +74,10 @@ const Block = ( { className } ) => {
|
|
59 |
role="img"
|
60 |
aria-label={ ratingText }
|
61 |
>
|
62 |
-
<span
|
|
|
|
|
|
|
63 |
</div>
|
64 |
</div>
|
65 |
);
|
@@ -71,6 +89,12 @@ const getAverageRating = ( product ) => {
|
|
71 |
return Number.isFinite( rating ) && rating > 0 ? rating : 0;
|
72 |
};
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
Block.propTypes = {
|
75 |
className: PropTypes.string,
|
76 |
};
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import PropTypes from 'prop-types';
|
5 |
+
import { __, _n, sprintf } from '@wordpress/i18n';
|
6 |
import classnames from 'classnames';
|
7 |
import {
|
8 |
useInnerBlockLayoutContext,
|
41 |
rating
|
42 |
);
|
43 |
|
44 |
+
const reviews = getRatingCount( product );
|
45 |
+
const ratingHTML = {
|
46 |
+
__html: sprintf(
|
47 |
+
/* translators: %1$s is referring to the average rating value, %2$s is referring to the number of ratings */
|
48 |
+
_n(
|
49 |
+
'Rated %1$s out of 5 based on %2$s customer rating',
|
50 |
+
'Rated %1$s out of 5 based on %2$s customer ratings',
|
51 |
+
reviews,
|
52 |
+
'woo-gutenberg-products-block'
|
53 |
+
),
|
54 |
+
sprintf( '<strong class="rating">%f</strong>', rating ),
|
55 |
+
sprintf( '<span class="rating">%d</span>', reviews )
|
56 |
+
),
|
57 |
+
};
|
58 |
+
|
59 |
return (
|
60 |
<div
|
61 |
className={ classnames(
|
74 |
role="img"
|
75 |
aria-label={ ratingText }
|
76 |
>
|
77 |
+
<span
|
78 |
+
style={ starStyle }
|
79 |
+
dangerouslySetInnerHTML={ ratingHTML }
|
80 |
+
/>
|
81 |
</div>
|
82 |
</div>
|
83 |
);
|
89 |
return Number.isFinite( rating ) && rating > 0 ? rating : 0;
|
90 |
};
|
91 |
|
92 |
+
const getRatingCount = ( product ) => {
|
93 |
+
const count = parseInt( product.review_count, 10 );
|
94 |
+
|
95 |
+
return Number.isFinite( count ) && count > 0 ? count : 0;
|
96 |
+
};
|
97 |
+
|
98 |
Block.propTypes = {
|
99 |
className: PropTypes.string,
|
100 |
};
|
assets/js/atomic/blocks/product-elements/stock-indicator/block.js
CHANGED
@@ -14,6 +14,10 @@ import { withProductDataContext } from '@woocommerce/shared-hocs';
|
|
14 |
* Internal dependencies
|
15 |
*/
|
16 |
import './style.scss';
|
|
|
|
|
|
|
|
|
17 |
|
18 |
/**
|
19 |
* Product Stock Indicator Block Component.
|
@@ -22,9 +26,12 @@ import './style.scss';
|
|
22 |
* @param {string} [props.className] CSS Class name for the component.
|
23 |
* @return {*} The component.
|
24 |
*/
|
25 |
-
const Block = (
|
|
|
26 |
const { parentClassName } = useInnerBlockLayoutContext();
|
27 |
const { product } = useProductDataContext();
|
|
|
|
|
28 |
|
29 |
if ( ! product.id || ! product.is_purchasable ) {
|
30 |
return null;
|
@@ -38,6 +45,7 @@ const Block = ( { className } ) => {
|
|
38 |
<div
|
39 |
className={ classnames(
|
40 |
className,
|
|
|
41 |
'wc-block-components-product-stock-indicator',
|
42 |
{
|
43 |
[ `${ parentClassName }__stock-indicator` ]: parentClassName,
|
@@ -47,6 +55,7 @@ const Block = ( { className } ) => {
|
|
47 |
'wc-block-components-product-stock-indicator--available-on-backorder': !! isBackordered,
|
48 |
}
|
49 |
) }
|
|
|
50 |
>
|
51 |
{ lowStock
|
52 |
? lowStockText( lowStock )
|
14 |
* Internal dependencies
|
15 |
*/
|
16 |
import './style.scss';
|
17 |
+
import {
|
18 |
+
useColorProps,
|
19 |
+
useTypographyProps,
|
20 |
+
} from '../../../../hooks/style-attributes';
|
21 |
|
22 |
/**
|
23 |
* Product Stock Indicator Block Component.
|
26 |
* @param {string} [props.className] CSS Class name for the component.
|
27 |
* @return {*} The component.
|
28 |
*/
|
29 |
+
const Block = ( props ) => {
|
30 |
+
const { className } = props;
|
31 |
const { parentClassName } = useInnerBlockLayoutContext();
|
32 |
const { product } = useProductDataContext();
|
33 |
+
const colorProps = useColorProps( props );
|
34 |
+
const typographyProps = useTypographyProps( props );
|
35 |
|
36 |
if ( ! product.id || ! product.is_purchasable ) {
|
37 |
return null;
|
45 |
<div
|
46 |
className={ classnames(
|
47 |
className,
|
48 |
+
colorProps.className,
|
49 |
'wc-block-components-product-stock-indicator',
|
50 |
{
|
51 |
[ `${ parentClassName }__stock-indicator` ]: parentClassName,
|
55 |
'wc-block-components-product-stock-indicator--available-on-backorder': !! isBackordered,
|
56 |
}
|
57 |
) }
|
58 |
+
style={ { ...colorProps.style, ...typographyProps.style } }
|
59 |
>
|
60 |
{ lowStock
|
61 |
? lowStockText( lowStock )
|
assets/js/atomic/blocks/product-elements/stock-indicator/edit.js
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
*/
|
4 |
import { __ } from '@wordpress/i18n';
|
5 |
import EditProductLink from '@woocommerce/editor-components/edit-product-link';
|
|
|
6 |
|
7 |
/**
|
8 |
* Internal dependencies
|
@@ -12,11 +13,12 @@ import withProductSelector from '../shared/with-product-selector';
|
|
12 |
import { BLOCK_TITLE, BLOCK_ICON } from './constants';
|
13 |
|
14 |
const Edit = ( { attributes } ) => {
|
|
|
15 |
return (
|
16 |
-
|
17 |
<EditProductLink />
|
18 |
<Block { ...attributes } />
|
19 |
-
|
20 |
);
|
21 |
};
|
22 |
|
3 |
*/
|
4 |
import { __ } from '@wordpress/i18n';
|
5 |
import EditProductLink from '@woocommerce/editor-components/edit-product-link';
|
6 |
+
import { useBlockProps } from '@wordpress/block-editor';
|
7 |
|
8 |
/**
|
9 |
* Internal dependencies
|
13 |
import { BLOCK_TITLE, BLOCK_ICON } from './constants';
|
14 |
|
15 |
const Edit = ( { attributes } ) => {
|
16 |
+
const blockProps = useBlockProps();
|
17 |
return (
|
18 |
+
<div { ...blockProps }>
|
19 |
<EditProductLink />
|
20 |
<Block { ...attributes } />
|
21 |
+
</div>
|
22 |
);
|
23 |
};
|
24 |
|
assets/js/atomic/blocks/product-elements/stock-indicator/index.js
CHANGED
@@ -9,6 +9,9 @@ import { registerExperimentalBlockType } from '@woocommerce/block-settings';
|
|
9 |
import sharedConfig from '../shared/config';
|
10 |
import attributes from './attributes';
|
11 |
import edit from './edit';
|
|
|
|
|
|
|
12 |
import {
|
13 |
BLOCK_TITLE as title,
|
14 |
BLOCK_ICON as icon,
|
@@ -16,11 +19,14 @@ import {
|
|
16 |
} from './constants';
|
17 |
|
18 |
const blockConfig = {
|
|
|
19 |
title,
|
20 |
description,
|
21 |
icon: { src: icon },
|
22 |
attributes,
|
|
|
23 |
edit,
|
|
|
24 |
};
|
25 |
|
26 |
registerExperimentalBlockType( 'woocommerce/product-stock-indicator', {
|
9 |
import sharedConfig from '../shared/config';
|
10 |
import attributes from './attributes';
|
11 |
import edit from './edit';
|
12 |
+
import { Save } from './save';
|
13 |
+
import { supports } from './supports';
|
14 |
+
|
15 |
import {
|
16 |
BLOCK_TITLE as title,
|
17 |
BLOCK_ICON as icon,
|
19 |
} from './constants';
|
20 |
|
21 |
const blockConfig = {
|
22 |
+
apiVersion: 2,
|
23 |
title,
|
24 |
description,
|
25 |
icon: { src: icon },
|
26 |
attributes,
|
27 |
+
supports,
|
28 |
edit,
|
29 |
+
save: Save,
|
30 |
};
|
31 |
|
32 |
registerExperimentalBlockType( 'woocommerce/product-stock-indicator', {
|
assets/js/atomic/blocks/product-elements/stock-indicator/save.tsx
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { useBlockProps } from '@wordpress/block-editor';
|
5 |
+
import classnames from 'classnames';
|
6 |
+
|
7 |
+
type Props = {
|
8 |
+
attributes: Record< string, unknown > & {
|
9 |
+
className?: string;
|
10 |
+
};
|
11 |
+
};
|
12 |
+
|
13 |
+
export const Save = ( { attributes }: Props ): JSX.Element => {
|
14 |
+
return (
|
15 |
+
<div
|
16 |
+
{ ...useBlockProps.save( {
|
17 |
+
className: classnames( 'is-loading', attributes.className ),
|
18 |
+
} ) }
|
19 |
+
/>
|
20 |
+
);
|
21 |
+
};
|
assets/js/atomic/blocks/product-elements/stock-indicator/style.scss
CHANGED
@@ -3,15 +3,4 @@
|
|
3 |
margin-bottom: em($gap-small);
|
4 |
display: block;
|
5 |
@include font-size(small);
|
6 |
-
|
7 |
-
&--in-stock {
|
8 |
-
color: $in-stock-color;
|
9 |
-
}
|
10 |
-
&--out-of-stock {
|
11 |
-
color: $no-stock-color;
|
12 |
-
}
|
13 |
-
&--low-stock,
|
14 |
-
&--available-on-backorder {
|
15 |
-
color: $low-stock-color;
|
16 |
-
}
|
17 |
}
|
3 |
margin-bottom: em($gap-small);
|
4 |
display: block;
|
5 |
@include font-size(small);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
}
|
assets/js/atomic/blocks/product-elements/stock-indicator/supports.js
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { isFeaturePluginBuild } from '@woocommerce/block-settings';
|
5 |
+
|
6 |
+
export const supports = {
|
7 |
+
...( isFeaturePluginBuild() && {
|
8 |
+
color: {
|
9 |
+
text: true,
|
10 |
+
background: false,
|
11 |
+
link: false,
|
12 |
+
},
|
13 |
+
typography: {
|
14 |
+
fontSize: true,
|
15 |
+
},
|
16 |
+
__experimentalSelector: '.wc-block-components-product-stock-indicator',
|
17 |
+
} ),
|
18 |
+
};
|
assets/js/atomic/blocks/product-elements/summary/block.js
CHANGED
@@ -5,6 +5,7 @@ import PropTypes from 'prop-types';
|
|
5 |
import classnames from 'classnames';
|
6 |
import Summary from '@woocommerce/base-components/summary';
|
7 |
import { blocksConfig } from '@woocommerce/block-settings';
|
|
|
8 |
import {
|
9 |
useInnerBlockLayoutContext,
|
10 |
useProductDataContext,
|
@@ -15,6 +16,10 @@ import { withProductDataContext } from '@woocommerce/shared-hocs';
|
|
15 |
* Internal dependencies
|
16 |
*/
|
17 |
import './style.scss';
|
|
|
|
|
|
|
|
|
18 |
|
19 |
/**
|
20 |
* Product Summary Block Component.
|
@@ -23,9 +28,13 @@ import './style.scss';
|
|
23 |
* @param {string} [props.className] CSS Class name for the component.
|
24 |
* @return {*} The component.
|
25 |
*/
|
26 |
-
const Block = (
|
|
|
|
|
27 |
const { parentClassName } = useInnerBlockLayoutContext();
|
28 |
const { product } = useProductDataContext();
|
|
|
|
|
29 |
|
30 |
if ( ! product ) {
|
31 |
return (
|
@@ -53,6 +62,7 @@ const Block = ( { className } ) => {
|
|
53 |
<Summary
|
54 |
className={ classnames(
|
55 |
className,
|
|
|
56 |
`wc-block-components-product-summary`,
|
57 |
{
|
58 |
[ `${ parentClassName }__product-summary` ]: parentClassName,
|
@@ -61,6 +71,10 @@ const Block = ( { className } ) => {
|
|
61 |
source={ source }
|
62 |
maxLength={ 150 }
|
63 |
countType={ blocksConfig.wordCountType || 'words' }
|
|
|
|
|
|
|
|
|
64 |
/>
|
65 |
);
|
66 |
};
|
5 |
import classnames from 'classnames';
|
6 |
import Summary from '@woocommerce/base-components/summary';
|
7 |
import { blocksConfig } from '@woocommerce/block-settings';
|
8 |
+
|
9 |
import {
|
10 |
useInnerBlockLayoutContext,
|
11 |
useProductDataContext,
|
16 |
* Internal dependencies
|
17 |
*/
|
18 |
import './style.scss';
|
19 |
+
import {
|
20 |
+
useColorProps,
|
21 |
+
useTypographyProps,
|
22 |
+
} from '../../../../hooks/style-attributes';
|
23 |
|
24 |
/**
|
25 |
* Product Summary Block Component.
|
28 |
* @param {string} [props.className] CSS Class name for the component.
|
29 |
* @return {*} The component.
|
30 |
*/
|
31 |
+
const Block = ( props ) => {
|
32 |
+
const { className } = props;
|
33 |
+
|
34 |
const { parentClassName } = useInnerBlockLayoutContext();
|
35 |
const { product } = useProductDataContext();
|
36 |
+
const colorProps = useColorProps( props );
|
37 |
+
const typographyProps = useTypographyProps( props );
|
38 |
|
39 |
if ( ! product ) {
|
40 |
return (
|
62 |
<Summary
|
63 |
className={ classnames(
|
64 |
className,
|
65 |
+
colorProps.className,
|
66 |
`wc-block-components-product-summary`,
|
67 |
{
|
68 |
[ `${ parentClassName }__product-summary` ]: parentClassName,
|
71 |
source={ source }
|
72 |
maxLength={ 150 }
|
73 |
countType={ blocksConfig.wordCountType || 'words' }
|
74 |
+
style={ {
|
75 |
+
...colorProps.style,
|
76 |
+
...typographyProps.style,
|
77 |
+
} }
|
78 |
/>
|
79 |
);
|
80 |
};
|
assets/js/atomic/blocks/product-elements/summary/edit.js
CHANGED
@@ -2,6 +2,7 @@
|
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { __ } from '@wordpress/i18n';
|
|
|
5 |
|
6 |
/**
|
7 |
* Internal dependencies
|
@@ -9,9 +10,15 @@ import { __ } from '@wordpress/i18n';
|
|
9 |
import Block from './block';
|
10 |
import withProductSelector from '../shared/with-product-selector';
|
11 |
import { BLOCK_TITLE, BLOCK_ICON } from './constants';
|
|
|
12 |
|
13 |
const Edit = ( { attributes } ) => {
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
15 |
};
|
16 |
|
17 |
export default withProductSelector( {
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { __ } from '@wordpress/i18n';
|
5 |
+
import { useBlockProps } from '@wordpress/block-editor';
|
6 |
|
7 |
/**
|
8 |
* Internal dependencies
|
10 |
import Block from './block';
|
11 |
import withProductSelector from '../shared/with-product-selector';
|
12 |
import { BLOCK_TITLE, BLOCK_ICON } from './constants';
|
13 |
+
import './editor.scss';
|
14 |
|
15 |
const Edit = ( { attributes } ) => {
|
16 |
+
const blockProps = useBlockProps();
|
17 |
+
return (
|
18 |
+
<div { ...blockProps }>
|
19 |
+
<Block { ...attributes } />
|
20 |
+
</div>
|
21 |
+
);
|
22 |
};
|
23 |
|
24 |
export default withProductSelector( {
|
assets/js/atomic/blocks/product-elements/summary/editor.scss
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.wc-block-components-product-summary {
|
2 |
+
p {
|
3 |
+
font-size: inherit;
|
4 |
+
}
|
5 |
+
}
|
assets/js/atomic/blocks/product-elements/summary/index.js
CHANGED
@@ -9,18 +9,23 @@ import { registerBlockType } from '@wordpress/blocks';
|
|
9 |
import sharedConfig from '../shared/config';
|
10 |
import attributes from './attributes';
|
11 |
import edit from './edit';
|
|
|
12 |
import {
|
13 |
BLOCK_TITLE as title,
|
14 |
BLOCK_ICON as icon,
|
15 |
BLOCK_DESCRIPTION as description,
|
16 |
} from './constants';
|
|
|
17 |
|
18 |
const blockConfig = {
|
|
|
19 |
title,
|
20 |
description,
|
21 |
icon: { src: icon },
|
22 |
attributes,
|
|
|
23 |
edit,
|
|
|
24 |
};
|
25 |
|
26 |
registerBlockType( 'woocommerce/product-summary', {
|
9 |
import sharedConfig from '../shared/config';
|
10 |
import attributes from './attributes';
|
11 |
import edit from './edit';
|
12 |
+
import { supports } from './supports';
|
13 |
import {
|
14 |
BLOCK_TITLE as title,
|
15 |
BLOCK_ICON as icon,
|
16 |
BLOCK_DESCRIPTION as description,
|
17 |
} from './constants';
|
18 |
+
import { Save } from './save';
|
19 |
|
20 |
const blockConfig = {
|
21 |
+
apiVersion: 2,
|
22 |
title,
|
23 |
description,
|
24 |
icon: { src: icon },
|
25 |
attributes,
|
26 |
+
supports,
|
27 |
edit,
|
28 |
+
save: Save,
|
29 |
};
|
30 |
|
31 |
registerBlockType( 'woocommerce/product-summary', {
|
assets/js/atomic/blocks/product-elements/summary/save.tsx
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { useBlockProps } from '@wordpress/block-editor';
|
5 |
+
import classnames from 'classnames';
|
6 |
+
|
7 |
+
type Props = {
|
8 |
+
attributes: Record< string, unknown > & {
|
9 |
+
className?: string;
|
10 |
+
};
|
11 |
+
};
|
12 |
+
|
13 |
+
export const Save = ( { attributes }: Props ): JSX.Element => {
|
14 |
+
return (
|
15 |
+
<div
|
16 |
+
{ ...useBlockProps.save( {
|
17 |
+
className: classnames( 'is-loading', attributes.className ),
|
18 |
+
} ) }
|
19 |
+
/>
|
20 |
+
);
|
21 |
+
};
|
assets/js/atomic/blocks/product-elements/summary/supports.js
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { isFeaturePluginBuild } from '@woocommerce/block-settings';
|
5 |
+
|
6 |
+
export const supports = {
|
7 |
+
...( isFeaturePluginBuild() && {
|
8 |
+
color: {
|
9 |
+
text: true,
|
10 |
+
background: false,
|
11 |
+
link: false,
|
12 |
+
},
|
13 |
+
typography: {
|
14 |
+
fontSize: true,
|
15 |
+
},
|
16 |
+
__experimentalSelector: '.wc-block-components-product-summary',
|
17 |
+
} ),
|
18 |
+
};
|
assets/js/atomic/blocks/product-elements/title/block.tsx
CHANGED
@@ -7,7 +7,6 @@ import {
|
|
7 |
useInnerBlockLayoutContext,
|
8 |
useProductDataContext,
|
9 |
} from '@woocommerce/shared-context';
|
10 |
-
import { getColorClassName, getFontSizeClass } from '@wordpress/block-editor';
|
11 |
import { isFeaturePluginBuild } from '@woocommerce/block-settings';
|
12 |
import { withProductDataContext } from '@woocommerce/shared-hocs';
|
13 |
import ProductName from '@woocommerce/base-components/product-name';
|
@@ -18,6 +17,11 @@ import { useStoreEvents } from '@woocommerce/base-context/hooks';
|
|
18 |
*/
|
19 |
import './style.scss';
|
20 |
import { Attributes } from './types';
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
type Props = Attributes & HTMLAttributes< HTMLDivElement >;
|
23 |
|
@@ -49,33 +53,21 @@ const TagName = ( {
|
|
49 |
* will be used if this is not provided.
|
50 |
* @return {*} The component.
|
51 |
*/
|
52 |
-
export const Block = ( {
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
}: Props ): JSX.Element => {
|
61 |
const { parentClassName } = useInnerBlockLayoutContext();
|
62 |
const { product } = useProductDataContext();
|
63 |
const { dispatchStoreEvent } = useStoreEvents();
|
64 |
|
65 |
-
const
|
66 |
-
const
|
67 |
-
const
|
68 |
-
'has-text-color': textColor || style?.color?.text || style?.color,
|
69 |
-
[ `has-font-size` ]:
|
70 |
-
fontSize || style?.typography?.fontSize || style?.fontSize,
|
71 |
-
[ colorClass ]: colorClass,
|
72 |
-
[ fontSizeClass ]: fontSizeClass,
|
73 |
-
} );
|
74 |
-
|
75 |
-
const titleStyle = {
|
76 |
-
fontSize: style?.fontSize || style?.typography?.fontSize,
|
77 |
-
color: style?.color?.text || style?.color,
|
78 |
-
};
|
79 |
|
80 |
if ( ! product.id ) {
|
81 |
return (
|
@@ -83,14 +75,23 @@ export const Block = ( {
|
|
83 |
headingLevel={ headingLevel }
|
84 |
className={ classnames(
|
85 |
className,
|
|
|
86 |
'wc-block-components-product-title',
|
87 |
{
|
88 |
[ `${ parentClassName }__product-title` ]: parentClassName,
|
89 |
[ `wc-block-components-product-title--align-${ align }` ]:
|
90 |
align && isFeaturePluginBuild(),
|
91 |
-
[ titleClasses ]: isFeaturePluginBuild(),
|
92 |
}
|
93 |
) }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
/>
|
95 |
);
|
96 |
}
|
@@ -100,6 +101,7 @@ export const Block = ( {
|
|
100 |
headingLevel={ headingLevel }
|
101 |
className={ classnames(
|
102 |
className,
|
|
|
103 |
'wc-block-components-product-title',
|
104 |
{
|
105 |
[ `${ parentClassName }__product-title` ]: parentClassName,
|
@@ -107,11 +109,17 @@ export const Block = ( {
|
|
107 |
align && isFeaturePluginBuild(),
|
108 |
}
|
109 |
) }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
>
|
111 |
<ProductName
|
112 |
-
className={ classnames( {
|
113 |
-
[ titleClasses ]: isFeaturePluginBuild(),
|
114 |
-
} ) }
|
115 |
disabled={ ! showProductLink }
|
116 |
name={ product.name }
|
117 |
permalink={ product.permalink }
|
@@ -121,7 +129,6 @@ export const Block = ( {
|
|
121 |
product,
|
122 |
} );
|
123 |
} }
|
124 |
-
style={ isFeaturePluginBuild() ? titleStyle : {} }
|
125 |
/>
|
126 |
</TagName>
|
127 |
);
|
7 |
useInnerBlockLayoutContext,
|
8 |
useProductDataContext,
|
9 |
} from '@woocommerce/shared-context';
|
|
|
10 |
import { isFeaturePluginBuild } from '@woocommerce/block-settings';
|
11 |
import { withProductDataContext } from '@woocommerce/shared-hocs';
|
12 |
import ProductName from '@woocommerce/base-components/product-name';
|
17 |
*/
|
18 |
import './style.scss';
|
19 |
import { Attributes } from './types';
|
20 |
+
import {
|
21 |
+
useSpacingProps,
|
22 |
+
useTypographyProps,
|
23 |
+
useColorProps,
|
24 |
+
} from '../../../../hooks/style-attributes';
|
25 |
|
26 |
type Props = Attributes & HTMLAttributes< HTMLDivElement >;
|
27 |
|
53 |
* will be used if this is not provided.
|
54 |
* @return {*} The component.
|
55 |
*/
|
56 |
+
export const Block = ( props: Props ): JSX.Element => {
|
57 |
+
const {
|
58 |
+
className,
|
59 |
+
headingLevel = 2,
|
60 |
+
showProductLink = true,
|
61 |
+
align,
|
62 |
+
} = props;
|
63 |
+
|
|
|
64 |
const { parentClassName } = useInnerBlockLayoutContext();
|
65 |
const { product } = useProductDataContext();
|
66 |
const { dispatchStoreEvent } = useStoreEvents();
|
67 |
|
68 |
+
const colorProps = useColorProps( props );
|
69 |
+
const spacingProps = useSpacingProps( props );
|
70 |
+
const typographyProps = useTypographyProps( props );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
if ( ! product.id ) {
|
73 |
return (
|
75 |
headingLevel={ headingLevel }
|
76 |
className={ classnames(
|
77 |
className,
|
78 |
+
colorProps.className,
|
79 |
'wc-block-components-product-title',
|
80 |
{
|
81 |
[ `${ parentClassName }__product-title` ]: parentClassName,
|
82 |
[ `wc-block-components-product-title--align-${ align }` ]:
|
83 |
align && isFeaturePluginBuild(),
|
|
|
84 |
}
|
85 |
) }
|
86 |
+
style={
|
87 |
+
isFeaturePluginBuild()
|
88 |
+
? {
|
89 |
+
...spacingProps.style,
|
90 |
+
...typographyProps.style,
|
91 |
+
...colorProps.style,
|
92 |
+
}
|
93 |
+
: {}
|
94 |
+
}
|
95 |
/>
|
96 |
);
|
97 |
}
|
101 |
headingLevel={ headingLevel }
|
102 |
className={ classnames(
|
103 |
className,
|
104 |
+
colorProps.className,
|
105 |
'wc-block-components-product-title',
|
106 |
{
|
107 |
[ `${ parentClassName }__product-title` ]: parentClassName,
|
109 |
align && isFeaturePluginBuild(),
|
110 |
}
|
111 |
) }
|
112 |
+
style={
|
113 |
+
isFeaturePluginBuild()
|
114 |
+
? {
|
115 |
+
...spacingProps.style,
|
116 |
+
...typographyProps.style,
|
117 |
+
...colorProps.style,
|
118 |
+
}
|
119 |
+
: {}
|
120 |
+
}
|
121 |
>
|
122 |
<ProductName
|
|
|
|
|
|
|
123 |
disabled={ ! showProductLink }
|
124 |
name={ product.name }
|
125 |
permalink={ product.permalink }
|
129 |
product,
|
130 |
} );
|
131 |
} }
|
|
|
132 |
/>
|
133 |
</TagName>
|
134 |
);
|
assets/js/atomic/blocks/product-elements/title/edit.tsx
CHANGED
@@ -20,6 +20,7 @@ import Block from './block';
|
|
20 |
import withProductSelector from '../shared/with-product-selector';
|
21 |
import { BLOCK_TITLE, BLOCK_ICON } from './constants';
|
22 |
import { Attributes } from './types';
|
|
|
23 |
|
24 |
interface Props {
|
25 |
attributes: Attributes;
|
20 |
import withProductSelector from '../shared/with-product-selector';
|
21 |
import { BLOCK_TITLE, BLOCK_ICON } from './constants';
|
22 |
import { Attributes } from './types';
|
23 |
+
import './editor.scss';
|
24 |
|
25 |
interface Props {
|
26 |
attributes: Attributes;
|
assets/js/atomic/blocks/product-elements/title/editor.scss
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.editor-styles-wrapper a.wc-block-components-product-name {
|
2 |
+
color: inherit;
|
3 |
+
}
|
4 |
+
|
5 |
+
.editor-styles-wrapper .wc-block-components-product-title {
|
6 |
+
margin-top: 0;
|
7 |
+
margin-bottom: $gap-small;
|
8 |
+
line-height: 1.5;
|
9 |
+
font-weight: 700;
|
10 |
+
padding: 0;
|
11 |
+
display: block;
|
12 |
+
font-size: inherit;
|
13 |
+
}
|
assets/js/atomic/blocks/product-elements/title/index.ts
CHANGED
@@ -15,6 +15,8 @@ import {
|
|
15 |
BLOCK_ICON as icon,
|
16 |
BLOCK_DESCRIPTION as description,
|
17 |
} from './constants';
|
|
|
|
|
18 |
|
19 |
const blockConfig: BlockConfiguration = {
|
20 |
...sharedConfig,
|
@@ -24,17 +26,33 @@ const blockConfig: BlockConfiguration = {
|
|
24 |
icon: { src: icon },
|
25 |
attributes,
|
26 |
edit,
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
},
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
: sharedConfig.supports,
|
38 |
};
|
39 |
|
40 |
registerBlockType( 'woocommerce/product-title', blockConfig );
|
15 |
BLOCK_ICON as icon,
|
16 |
BLOCK_DESCRIPTION as description,
|
17 |
} from './constants';
|
18 |
+
import { Save } from './save';
|
19 |
+
import { hasSpacingStyleSupport } from '../../../../utils/global-style';
|
20 |
|
21 |
const blockConfig: BlockConfiguration = {
|
22 |
...sharedConfig,
|
26 |
icon: { src: icon },
|
27 |
attributes,
|
28 |
edit,
|
29 |
+
save: Save,
|
30 |
+
supports: {
|
31 |
+
...sharedConfig.supports,
|
32 |
+
...( isFeaturePluginBuild() && {
|
33 |
+
typography: {
|
34 |
+
fontSize: true,
|
35 |
+
lineHeight: true,
|
36 |
+
__experimentalFontWeight: true,
|
37 |
+
__experimentalTextTransform: true,
|
38 |
+
__experimentalFontFamily: true,
|
39 |
+
},
|
40 |
+
color: {
|
41 |
+
text: true,
|
42 |
+
background: true,
|
43 |
+
link: false,
|
44 |
+
gradients: true,
|
45 |
+
__experimentalSkipSerialization: true,
|
46 |
+
},
|
47 |
+
...( hasSpacingStyleSupport() && {
|
48 |
+
spacing: {
|
49 |
+
margin: true,
|
50 |
+
__experimentalSkipSerialization: true,
|
51 |
},
|
52 |
+
} ),
|
53 |
+
__experimentalSelector: '.wc-block-components-product-title',
|
54 |
+
} ),
|
55 |
+
},
|
|
|
56 |
};
|
57 |
|
58 |
registerBlockType( 'woocommerce/product-title', blockConfig );
|
assets/js/atomic/blocks/product-elements/title/save.tsx
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { useBlockProps } from '@wordpress/block-editor';
|
5 |
+
import classnames from 'classnames';
|
6 |
+
|
7 |
+
type Props = {
|
8 |
+
attributes: Record< string, unknown > & {
|
9 |
+
className?: string;
|
10 |
+
};
|
11 |
+
};
|
12 |
+
|
13 |
+
export const Save = ( { attributes }: Props ): JSX.Element => {
|
14 |
+
return (
|
15 |
+
<div
|
16 |
+
{ ...useBlockProps.save( {
|
17 |
+
className: classnames( 'is-loading', attributes.className ),
|
18 |
+
} ) }
|
19 |
+
/>
|
20 |
+
);
|
21 |
+
};
|
assets/js/atomic/blocks/product-elements/title/style.scss
CHANGED
@@ -1,15 +1,26 @@
|
|
1 |
.wc-block-components-product-title {
|
2 |
margin-top: 0;
|
3 |
margin-bottom: $gap-small;
|
4 |
-
}
|
5 |
-
.wc-block-grid .wc-block-components-product-title {
|
6 |
line-height: 1.5;
|
7 |
font-weight: 700;
|
8 |
padding: 0;
|
9 |
-
|
10 |
font-size: inherit;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
display: block;
|
12 |
}
|
|
|
13 |
.is-loading {
|
14 |
.wc-block-components-product-title::before {
|
15 |
@include placeholder();
|
1 |
.wc-block-components-product-title {
|
2 |
margin-top: 0;
|
3 |
margin-bottom: $gap-small;
|
|
|
|
|
4 |
line-height: 1.5;
|
5 |
font-weight: 700;
|
6 |
padding: 0;
|
7 |
+
display: block;
|
8 |
font-size: inherit;
|
9 |
+
|
10 |
+
a {
|
11 |
+
color: inherit;
|
12 |
+
font-size: inherit;
|
13 |
+
}
|
14 |
+
|
15 |
+
}
|
16 |
+
|
17 |
+
.wc-block-grid {
|
18 |
+
line-height: 1.5;
|
19 |
+
font-weight: 700;
|
20 |
+
padding: 0;
|
21 |
display: block;
|
22 |
}
|
23 |
+
|
24 |
.is-loading {
|
25 |
.wc-block-components-product-title::before {
|
26 |
@include placeholder();
|
assets/js/base/components/cart-checkout/shipping-rates-control-package/style.scss
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
.wc-block-components-shipping-rates-control__package {
|
|
|
2 |
.wc-block-components-panel__button {
|
3 |
margin-bottom: 0;
|
4 |
margin-top: 0;
|
@@ -41,3 +42,13 @@
|
|
41 |
content: ", ";
|
42 |
white-space: pre;
|
43 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
.wc-block-components-shipping-rates-control__package {
|
2 |
+
|
3 |
.wc-block-components-panel__button {
|
4 |
margin-bottom: 0;
|
5 |
margin-top: 0;
|
42 |
content: ", ";
|
43 |
white-space: pre;
|
44 |
}
|
45 |
+
|
46 |
+
// Target the shipping selection in checkout only, the Cart block has enough spacing because of the buttons on the panel.
|
47 |
+
.wc-block-checkout .wc-block-components-shipping-rates-control__package {
|
48 |
+
margin-bottom: em($gap-large);
|
49 |
+
|
50 |
+
&:last-of-type {
|
51 |
+
margin-bottom: 0;
|
52 |
+
}
|
53 |
+
|
54 |
+
}
|
assets/js/base/components/formatted-monetary-amount/index.tsx
CHANGED
@@ -18,6 +18,8 @@ interface FormattedMonetaryAmountProps
|
|
18 |
extends Omit< NumberFormatProps, 'onValueChange' > {
|
19 |
className?: string;
|
20 |
displayType?: NumberFormatProps[ 'displayType' ];
|
|
|
|
|
21 |
value: number | string; // Value of money amount.
|
22 |
currency: Currency | Record< string, never >; // Currency configuration object.
|
23 |
onValueChange?: ( unit: number ) => void; // Function to call when value changes.
|
18 |
extends Omit< NumberFormatProps, 'onValueChange' > {
|
19 |
className?: string;
|
20 |
displayType?: NumberFormatProps[ 'displayType' ];
|
21 |
+
allowNegative?: boolean;
|
22 |
+
isAllowed?: ( formattedValue: NumberFormatValues ) => boolean;
|
23 |
value: number | string; // Value of money amount.
|
24 |
currency: Currency | Record< string, never >; // Currency configuration object.
|
25 |
onValueChange?: ( unit: number ) => void; // Function to call when value changes.
|
assets/js/base/components/price-slider/index.tsx
CHANGED
@@ -19,6 +19,7 @@ import { Currency, isObject } from '@woocommerce/types';
|
|
19 |
import './style.scss';
|
20 |
import { constrainRangeSliderValues } from './constrain-range-slider-values';
|
21 |
import FilterSubmitButton from '../filter-submit-button';
|
|
|
22 |
|
23 |
export interface PriceSliderProps {
|
24 |
/**
|
@@ -240,9 +241,27 @@ const PriceSlider = ( {
|
|
240 |
) {
|
241 |
return;
|
242 |
}
|
|
|
243 |
const isMin = event.target.classList.contains(
|
244 |
'wc-block-price-filter__amount--min'
|
245 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
const values = constrainRangeSliderValues(
|
247 |
[ minPriceInput, maxPriceInput ],
|
248 |
null,
|
@@ -351,6 +370,12 @@ const PriceSlider = ( {
|
|
351 |
'Filter products by minimum price',
|
352 |
'woo-gutenberg-products-block'
|
353 |
) }
|
|
|
|
|
|
|
|
|
|
|
|
|
354 |
onValueChange={ ( value ) => {
|
355 |
if ( value === minPriceInput ) {
|
356 |
return;
|
@@ -369,6 +394,10 @@ const PriceSlider = ( {
|
|
369 |
'Filter products by maximum price',
|
370 |
'woo-gutenberg-products-block'
|
371 |
) }
|
|
|
|
|
|
|
|
|
372 |
onValueChange={ ( value ) => {
|
373 |
if ( value === maxPriceInput ) {
|
374 |
return;
|
19 |
import './style.scss';
|
20 |
import { constrainRangeSliderValues } from './constrain-range-slider-values';
|
21 |
import FilterSubmitButton from '../filter-submit-button';
|
22 |
+
import { isValidMaxValue, isValidMinValue } from './utils';
|
23 |
|
24 |
export interface PriceSliderProps {
|
25 |
/**
|
241 |
) {
|
242 |
return;
|
243 |
}
|
244 |
+
|
245 |
const isMin = event.target.classList.contains(
|
246 |
'wc-block-price-filter__amount--min'
|
247 |
);
|
248 |
+
|
249 |
+
// When the user inserts in the max price input a value less or equal than the current minimum price,
|
250 |
+
// we set to 0 the minimum price.
|
251 |
+
if ( minPriceInput >= maxPriceInput ) {
|
252 |
+
const values = constrainRangeSliderValues(
|
253 |
+
[ 0, maxPriceInput ],
|
254 |
+
null,
|
255 |
+
null,
|
256 |
+
stepValue,
|
257 |
+
isMin
|
258 |
+
);
|
259 |
+
return onChange( [
|
260 |
+
parseInt( values[ 0 ], 10 ),
|
261 |
+
parseInt( values[ 1 ], 10 ),
|
262 |
+
] );
|
263 |
+
}
|
264 |
+
|
265 |
const values = constrainRangeSliderValues(
|
266 |
[ minPriceInput, maxPriceInput ],
|
267 |
null,
|
370 |
'Filter products by minimum price',
|
371 |
'woo-gutenberg-products-block'
|
372 |
) }
|
373 |
+
allowNegative={ false }
|
374 |
+
isAllowed={ isValidMinValue( {
|
375 |
+
minConstraint,
|
376 |
+
minorUnit: currency.minorUnit,
|
377 |
+
currentMaxValue: maxPriceInput,
|
378 |
+
} ) }
|
379 |
onValueChange={ ( value ) => {
|
380 |
if ( value === minPriceInput ) {
|
381 |
return;
|
394 |
'Filter products by maximum price',
|
395 |
'woo-gutenberg-products-block'
|
396 |
) }
|
397 |
+
isAllowed={ isValidMaxValue( {
|
398 |
+
maxConstraint,
|
399 |
+
minorUnit: currency.minorUnit,
|
400 |
+
} ) }
|
401 |
onValueChange={ ( value ) => {
|
402 |
if ( value === maxPriceInput ) {
|
403 |
return;
|
assets/js/base/components/price-slider/utils.ts
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { NumberFormatValues } from 'react-number-format';
|
5 |
+
|
6 |
+
/**
|
7 |
+
Check if that the value is minor than the max price and greater than 0.
|
8 |
+
*/
|
9 |
+
export const isValidMaxValue = ( {
|
10 |
+
maxConstraint,
|
11 |
+
minorUnit,
|
12 |
+
}: {
|
13 |
+
maxConstraint: number;
|
14 |
+
minorUnit: number;
|
15 |
+
} ) => ( { floatValue }: NumberFormatValues ): boolean => {
|
16 |
+
const maxPrice = maxConstraint / 10 ** minorUnit;
|
17 |
+
|
18 |
+
return floatValue !== undefined && floatValue <= maxPrice && floatValue > 0;
|
19 |
+
};
|
20 |
+
|
21 |
+
/**
|
22 |
+
Check if that the value is minor than the max price and greater than 0.
|
23 |
+
*/
|
24 |
+
export const isValidMinValue = ( {
|
25 |
+
minConstraint,
|
26 |
+
currentMaxValue,
|
27 |
+
minorUnit,
|
28 |
+
}: {
|
29 |
+
minConstraint: number;
|
30 |
+
currentMaxValue: number;
|
31 |
+
minorUnit: number;
|
32 |
+
} ) => ( { floatValue }: NumberFormatValues ): boolean => {
|
33 |
+
const minPrice = minConstraint / 10 ** minorUnit;
|
34 |
+
const currentMaxPrice = currentMaxValue / 10 ** minorUnit;
|
35 |
+
|
36 |
+
return (
|
37 |
+
floatValue !== undefined &&
|
38 |
+
floatValue >= minPrice &&
|
39 |
+
floatValue < currentMaxPrice
|
40 |
+
);
|
41 |
+
};
|
assets/js/base/components/quantity-selector/index.tsx
CHANGED
@@ -4,8 +4,9 @@
|
|
4 |
import { __, sprintf } from '@wordpress/i18n';
|
5 |
import { speak } from '@wordpress/a11y';
|
6 |
import classNames from 'classnames';
|
7 |
-
import { useCallback } from '@wordpress/element';
|
8 |
import { DOWN, UP } from '@wordpress/keycodes';
|
|
|
9 |
|
10 |
/**
|
11 |
* Internal dependencies
|
@@ -31,6 +32,10 @@ export interface QuantitySelectorProps {
|
|
31 |
* Maximum quantity
|
32 |
*/
|
33 |
maximum: number;
|
|
|
|
|
|
|
|
|
34 |
/**
|
35 |
* Event handler triggered when the quantity is changed
|
36 |
*/
|
@@ -53,6 +58,7 @@ const QuantitySelector = ( {
|
|
53 |
minimum = 1,
|
54 |
maximum,
|
55 |
onChange = () => void 0,
|
|
|
56 |
itemName = '',
|
57 |
disabled,
|
58 |
}: QuantitySelectorProps ): JSX.Element => {
|
@@ -62,8 +68,59 @@ const QuantitySelector = ( {
|
|
62 |
);
|
63 |
|
64 |
const hasMaximum = typeof maximum !== 'undefined';
|
65 |
-
const canDecrease = quantity
|
66 |
-
const canIncrease = ! hasMaximum || quantity
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
/**
|
69 |
* Handles keyboard up and down keys to change quantity value.
|
@@ -83,15 +140,15 @@ const QuantitySelector = ( {
|
|
83 |
|
84 |
if ( isArrowDown && canDecrease ) {
|
85 |
event.preventDefault();
|
86 |
-
onChange( quantity -
|
87 |
}
|
88 |
|
89 |
if ( isArrowUp && canIncrease ) {
|
90 |
event.preventDefault();
|
91 |
-
onChange( quantity +
|
92 |
}
|
93 |
},
|
94 |
-
[ quantity, onChange, canIncrease, canDecrease ]
|
95 |
);
|
96 |
|
97 |
return (
|
@@ -100,22 +157,23 @@ const QuantitySelector = ( {
|
|
100 |
className="wc-block-components-quantity-selector__input"
|
101 |
disabled={ disabled }
|
102 |
type="number"
|
103 |
-
step=
|
104 |
-
min=
|
|
|
105 |
value={ quantity }
|
106 |
onKeyDown={ quantityInputOnKeyDown }
|
107 |
onChange={ ( event ) => {
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
value = Math.min( value, maximum );
|
115 |
-
}
|
116 |
-
value = Math.max( value, minimum );
|
117 |
if ( value !== quantity ) {
|
|
|
118 |
onChange( value );
|
|
|
|
|
119 |
}
|
120 |
} }
|
121 |
aria-label={ sprintf(
|
@@ -135,7 +193,7 @@ const QuantitySelector = ( {
|
|
135 |
className="wc-block-components-quantity-selector__button wc-block-components-quantity-selector__button--minus"
|
136 |
disabled={ disabled || ! canDecrease }
|
137 |
onClick={ () => {
|
138 |
-
const newQuantity = quantity -
|
139 |
onChange( newQuantity );
|
140 |
speak(
|
141 |
sprintf(
|
@@ -147,6 +205,7 @@ const QuantitySelector = ( {
|
|
147 |
newQuantity
|
148 |
)
|
149 |
);
|
|
|
150 |
} }
|
151 |
>
|
152 |
-
|
@@ -159,7 +218,7 @@ const QuantitySelector = ( {
|
|
159 |
disabled={ disabled || ! canIncrease }
|
160 |
className="wc-block-components-quantity-selector__button wc-block-components-quantity-selector__button--plus"
|
161 |
onClick={ () => {
|
162 |
-
const newQuantity = quantity +
|
163 |
onChange( newQuantity );
|
164 |
speak(
|
165 |
sprintf(
|
@@ -171,6 +230,7 @@ const QuantitySelector = ( {
|
|
171 |
newQuantity
|
172 |
)
|
173 |
);
|
|
|
174 |
} }
|
175 |
>
|
176 |
+
|
4 |
import { __, sprintf } from '@wordpress/i18n';
|
5 |
import { speak } from '@wordpress/a11y';
|
6 |
import classNames from 'classnames';
|
7 |
+
import { useCallback, useLayoutEffect } from '@wordpress/element';
|
8 |
import { DOWN, UP } from '@wordpress/keycodes';
|
9 |
+
import { useDebouncedCallback } from 'use-debounce';
|
10 |
|
11 |
/**
|
12 |
* Internal dependencies
|
32 |
* Maximum quantity
|
33 |
*/
|
34 |
maximum: number;
|
35 |
+
/**
|
36 |
+
* Input step attribute.
|
37 |
+
*/
|
38 |
+
step?: number;
|
39 |
/**
|
40 |
* Event handler triggered when the quantity is changed
|
41 |
*/
|
58 |
minimum = 1,
|
59 |
maximum,
|
60 |
onChange = () => void 0,
|
61 |
+
step = 1,
|
62 |
itemName = '',
|
63 |
disabled,
|
64 |
}: QuantitySelectorProps ): JSX.Element => {
|
68 |
);
|
69 |
|
70 |
const hasMaximum = typeof maximum !== 'undefined';
|
71 |
+
const canDecrease = quantity - step >= minimum;
|
72 |
+
const canIncrease = ! hasMaximum || quantity + step <= maximum;
|
73 |
+
|
74 |
+
/**
|
75 |
+
* The goal of this function is to normalize what was inserted,
|
76 |
+
* but after the customer has stopped typing.
|
77 |
+
*/
|
78 |
+
const normalizeQuantity = useCallback(
|
79 |
+
( initialValue: number ) => {
|
80 |
+
// We copy the starting value.
|
81 |
+
let value = initialValue;
|
82 |
+
|
83 |
+
// We check if we have a maximum value, and select the lowest between what was inserted and the maximum.
|
84 |
+
if ( hasMaximum ) {
|
85 |
+
value = Math.min(
|
86 |
+
value,
|
87 |
+
// the maximum possible value in step increments.
|
88 |
+
Math.floor( maximum / step ) * step
|
89 |
+
);
|
90 |
+
}
|
91 |
+
|
92 |
+
// Select the biggest between what's inserted, the the minimum value in steps.
|
93 |
+
value = Math.max( value, Math.ceil( minimum / step ) * step );
|
94 |
+
|
95 |
+
// We round off the value to our steps.
|
96 |
+
value = Math.floor( value / step ) * step;
|
97 |
+
|
98 |
+
// Only commit if the value has changed
|
99 |
+
if ( value !== initialValue ) {
|
100 |
+
onChange( value );
|
101 |
+
}
|
102 |
+
},
|
103 |
+
[ hasMaximum, maximum, minimum, onChange, step ]
|
104 |
+
);
|
105 |
+
|
106 |
+
/*
|
107 |
+
* It's important to wait before normalizing or we end up with
|
108 |
+
* a frustrating experience, for example, if the minimum is 2 and
|
109 |
+
* the customer is trying to type "10", premature normalizing would
|
110 |
+
* always kick in at "1" and turn that into 2.
|
111 |
+
*/
|
112 |
+
const debouncedNormalizeQuantity = useDebouncedCallback(
|
113 |
+
normalizeQuantity,
|
114 |
+
// This value is deliberately smaller than what's in useStoreCartItemQuantity so we don't end up with two requests.
|
115 |
+
300
|
116 |
+
);
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Normalize qty on mount before render.
|
120 |
+
*/
|
121 |
+
useLayoutEffect( () => {
|
122 |
+
normalizeQuantity( quantity );
|
123 |
+
}, [ quantity, normalizeQuantity ] );
|
124 |
|
125 |
/**
|
126 |
* Handles keyboard up and down keys to change quantity value.
|
140 |
|
141 |
if ( isArrowDown && canDecrease ) {
|
142 |
event.preventDefault();
|
143 |
+
onChange( quantity - step );
|
144 |
}
|
145 |
|
146 |
if ( isArrowUp && canIncrease ) {
|
147 |
event.preventDefault();
|
148 |
+
onChange( quantity + step );
|
149 |
}
|
150 |
},
|
151 |
+
[ quantity, onChange, canIncrease, canDecrease, step ]
|
152 |
);
|
153 |
|
154 |
return (
|
157 |
className="wc-block-components-quantity-selector__input"
|
158 |
disabled={ disabled }
|
159 |
type="number"
|
160 |
+
step={ step }
|
161 |
+
min={ minimum }
|
162 |
+
max={ maximum }
|
163 |
value={ quantity }
|
164 |
onKeyDown={ quantityInputOnKeyDown }
|
165 |
onChange={ ( event ) => {
|
166 |
+
// Inputs values are strings, we parse them here.
|
167 |
+
let value = parseInt( event.target.value, 10 );
|
168 |
+
// parseInt would throw NaN for anything not a number,
|
169 |
+
// so we revert value to the quantity value.
|
170 |
+
value = isNaN( value ) ? quantity : value;
|
171 |
+
|
|
|
|
|
|
|
172 |
if ( value !== quantity ) {
|
173 |
+
// we commit this value immediately.
|
174 |
onChange( value );
|
175 |
+
// but once the customer has stopped typing, we make sure his value is respecting the bounds (maximum value, minimum value, step value), and commit the normalized value.
|
176 |
+
debouncedNormalizeQuantity( value );
|
177 |
}
|
178 |
} }
|
179 |
aria-label={ sprintf(
|
193 |
className="wc-block-components-quantity-selector__button wc-block-components-quantity-selector__button--minus"
|
194 |
disabled={ disabled || ! canDecrease }
|
195 |
onClick={ () => {
|
196 |
+
const newQuantity = quantity - step;
|
197 |
onChange( newQuantity );
|
198 |
speak(
|
199 |
sprintf(
|
205 |
newQuantity
|
206 |
)
|
207 |
);
|
208 |
+
normalizeQuantity( newQuantity );
|
209 |
} }
|
210 |
>
|
211 |
-
|
218 |
disabled={ disabled || ! canIncrease }
|
219 |
className="wc-block-components-quantity-selector__button wc-block-components-quantity-selector__button--plus"
|
220 |
onClick={ () => {
|
221 |
+
const newQuantity = quantity + step;
|
222 |
onChange( newQuantity );
|
223 |
speak(
|
224 |
sprintf(
|
230 |
newQuantity
|
231 |
)
|
232 |
);
|
233 |
+
normalizeQuantity( newQuantity );
|
234 |
} }
|
235 |
>
|
236 |
+
|
assets/js/base/components/quantity-selector/style.scss
CHANGED
@@ -41,6 +41,7 @@
|
|
41 |
line-height: 1;
|
42 |
vertical-align: middle;
|
43 |
-moz-appearance: textfield;
|
|
|
44 |
|
45 |
&:focus {
|
46 |
background: $gray-100;
|
@@ -70,11 +71,12 @@
|
|
70 |
|
71 |
.wc-block-components-quantity-selector__button {
|
72 |
@include reset-button;
|
73 |
-
@include font-size(regular);
|
74 |
min-width: 30px;
|
75 |
cursor: pointer;
|
76 |
-
color: $gray-
|
77 |
font-style: normal;
|
|
|
78 |
text-align: center;
|
79 |
text-decoration: none;
|
80 |
|
41 |
line-height: 1;
|
42 |
vertical-align: middle;
|
43 |
-moz-appearance: textfield;
|
44 |
+
font-weight: 600;
|
45 |
|
46 |
&:focus {
|
47 |
background: $gray-100;
|
71 |
|
72 |
.wc-block-components-quantity-selector__button {
|
73 |
@include reset-button;
|
74 |
+
@include font-size(regular, 0.9em);
|
75 |
min-width: 30px;
|
76 |
cursor: pointer;
|
77 |
+
color: $gray-600;
|
78 |
font-style: normal;
|
79 |
+
font-weight: normal;
|
80 |
text-align: center;
|
81 |
text-decoration: none;
|
82 |
|
assets/js/base/components/reviews/review-list-item/index.js
CHANGED
@@ -124,6 +124,13 @@ function getReviewRating( review ) {
|
|
124 |
__( 'Rated %f out of 5', 'woo-gutenberg-products-block' ),
|
125 |
rating
|
126 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
return (
|
128 |
<div className="wc-block-review-list-item__rating wc-block-components-review-list-item__rating">
|
129 |
<div
|
@@ -131,7 +138,10 @@ function getReviewRating( review ) {
|
|
131 |
role="img"
|
132 |
aria-label={ ratingText }
|
133 |
>
|
134 |
-
<span
|
|
|
|
|
|
|
135 |
</div>
|
136 |
</div>
|
137 |
);
|
124 |
__( 'Rated %f out of 5', 'woo-gutenberg-products-block' ),
|
125 |
rating
|
126 |
);
|
127 |
+
const ratingHTML = {
|
128 |
+
__html: sprintf(
|
129 |
+
/* translators: %s is referring to the average rating value */
|
130 |
+
__( 'Rated %s out of 5', 'woo-gutenberg-products-block' ),
|
131 |
+
sprintf( '<strong class="rating">%f</strong>', rating )
|
132 |
+
),
|
133 |
+
};
|
134 |
return (
|
135 |
<div className="wc-block-review-list-item__rating wc-block-components-review-list-item__rating">
|
136 |
<div
|
138 |
role="img"
|
139 |
aria-label={ ratingText }
|
140 |
>
|
141 |
+
<span
|
142 |
+
style={ starStyle }
|
143 |
+
dangerouslySetInnerHTML={ ratingHTML }
|
144 |
+
/>
|
145 |
</div>
|
146 |
</div>
|
147 |
);
|
assets/js/base/components/reviews/review-list-item/style.scss
CHANGED
@@ -140,7 +140,7 @@
|
|
140 |
}
|
141 |
|
142 |
.wc-block-components-review-list-item__product + .wc-block-components-review-list-item__author + .wc-block-components-review-list-item__published-date {
|
143 |
-
padding-left: $gap
|
144 |
position: relative;
|
145 |
|
146 |
&::before {
|
140 |
}
|
141 |
|
142 |
.wc-block-components-review-list-item__product + .wc-block-components-review-list-item__author + .wc-block-components-review-list-item__published-date {
|
143 |
+
padding-left: $gap*0.5;
|
144 |
position: relative;
|
145 |
|
146 |
&::before {
|
assets/js/base/components/summary/index.tsx
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
*/
|
4 |
import { RawHTML, useMemo } from '@wordpress/element';
|
5 |
import { WordCountType } from '@woocommerce/block-settings';
|
|
|
6 |
|
7 |
/**
|
8 |
* Internal dependencies
|
@@ -14,6 +15,7 @@ interface SummaryProps {
|
|
14 |
source: string;
|
15 |
maxLength?: number;
|
16 |
countType?: WordCountType;
|
|
|
17 |
}
|
18 |
/**
|
19 |
* Summary component.
|
@@ -23,18 +25,25 @@ interface SummaryProps {
|
|
23 |
* @param {number} props.maxLength Max length of the summary, using countType.
|
24 |
* @param {string} props.countType One of words, characters_excluding_spaces, or characters_including_spaces.
|
25 |
* @param {string} props.className Class name for rendered component.
|
|
|
|
|
26 |
*/
|
27 |
export const Summary = ( {
|
28 |
source,
|
29 |
maxLength = 15,
|
30 |
countType = 'words',
|
31 |
className = '',
|
|
|
32 |
}: SummaryProps ): JSX.Element => {
|
33 |
const summaryText = useMemo( () => {
|
34 |
return generateSummary( source, maxLength, countType );
|
35 |
}, [ source, maxLength, countType ] );
|
36 |
|
37 |
-
return
|
|
|
|
|
|
|
|
|
38 |
};
|
39 |
|
40 |
export default Summary;
|
3 |
*/
|
4 |
import { RawHTML, useMemo } from '@wordpress/element';
|
5 |
import { WordCountType } from '@woocommerce/block-settings';
|
6 |
+
import { CSSProperties } from 'react';
|
7 |
|
8 |
/**
|
9 |
* Internal dependencies
|
15 |
source: string;
|
16 |
maxLength?: number;
|
17 |
countType?: WordCountType;
|
18 |
+
style?: CSSProperties;
|
19 |
}
|
20 |
/**
|
21 |
* Summary component.
|
25 |
* @param {number} props.maxLength Max length of the summary, using countType.
|
26 |
* @param {string} props.countType One of words, characters_excluding_spaces, or characters_including_spaces.
|
27 |
* @param {string} props.className Class name for rendered component.
|
28 |
+
* @param {CSSProperties} props.style Style Object for rendered component.
|
29 |
+
*
|
30 |
*/
|
31 |
export const Summary = ( {
|
32 |
source,
|
33 |
maxLength = 15,
|
34 |
countType = 'words',
|
35 |
className = '',
|
36 |
+
style = {},
|
37 |
}: SummaryProps ): JSX.Element => {
|
38 |
const summaryText = useMemo( () => {
|
39 |
return generateSummary( source, maxLength, countType );
|
40 |
}, [ source, maxLength, countType ] );
|
41 |
|
42 |
+
return (
|
43 |
+
<RawHTML style={ style } className={ className }>
|
44 |
+
{ summaryText }
|
45 |
+
</RawHTML>
|
46 |
+
);
|
47 |
};
|
48 |
|
49 |
export default Summary;
|
assets/js/base/context/providers/add-to-cart-form/form-state/constants.js
CHANGED
@@ -13,7 +13,7 @@ export const STATUS = {
|
|
13 |
export const DEFAULT_STATE = {
|
14 |
status: STATUS.PRISTINE,
|
15 |
hasError: false,
|
16 |
-
quantity:
|
17 |
processingResponse: null,
|
18 |
requestParams: {},
|
19 |
};
|
13 |
export const DEFAULT_STATE = {
|
14 |
status: STATUS.PRISTINE,
|
15 |
hasError: false,
|
16 |
+
quantity: 0,
|
17 |
processingResponse: null,
|
18 |
requestParams: {},
|
19 |
};
|
assets/js/base/context/providers/add-to-cart-form/form-state/index.js
CHANGED
@@ -296,9 +296,11 @@ export const AddToCartFormStateContextProvider = ( {
|
|
296 |
productHasOptions: product.has_options || false,
|
297 |
supportsFormElements,
|
298 |
showFormElements: showFormElements && supportsFormElements,
|
299 |
-
quantity:
|
300 |
-
|
301 |
-
|
|
|
|
|
302 |
requestParams: addToCartFormState.requestParams,
|
303 |
isIdle: addToCartFormState.status === STATUS.IDLE,
|
304 |
isDisabled: addToCartFormState.status === STATUS.DISABLED,
|
296 |
productHasOptions: product.has_options || false,
|
297 |
supportsFormElements,
|
298 |
showFormElements: showFormElements && supportsFormElements,
|
299 |
+
quantity:
|
300 |
+
addToCartFormState.quantity || product?.add_to_cart?.minimum || 1,
|
301 |
+
minQuantity: product?.add_to_cart?.minimum || 1,
|
302 |
+
maxQuantity: product?.add_to_cart?.maximum || 99,
|
303 |
+
multipleOf: product?.add_to_cart?.multiple_of || 1,
|
304 |
requestParams: addToCartFormState.requestParams,
|
305 |
isIdle: addToCartFormState.status === STATUS.IDLE,
|
306 |
isDisabled: addToCartFormState.status === STATUS.DISABLED,
|
assets/js/base/context/providers/cart-checkout/payment-methods/test/payment-method-data-context.js
CHANGED
@@ -44,7 +44,7 @@ jest.mock( '@woocommerce/settings', () => {
|
|
44 |
cc: [
|
45 |
{
|
46 |
method: {
|
47 |
-
gateway: '
|
48 |
last4: '4242',
|
49 |
brand: 'Visa',
|
50 |
},
|
@@ -75,7 +75,7 @@ const registerMockPaymentMethods = ( savedCards = true ) => {
|
|
75 |
ariaLabel: name,
|
76 |
} );
|
77 |
} );
|
78 |
-
[ '
|
79 |
registerPaymentMethod( {
|
80 |
name,
|
81 |
label: name,
|
@@ -121,7 +121,7 @@ const registerMockPaymentMethods = ( savedCards = true ) => {
|
|
121 |
};
|
122 |
|
123 |
const resetMockPaymentMethods = () => {
|
124 |
-
[ 'cheque', 'bacs', '
|
125 |
__experimentalDeRegisterPaymentMethod( name );
|
126 |
} );
|
127 |
[ 'express-payment' ].forEach( ( name ) => {
|
@@ -255,8 +255,8 @@ describe( 'Testing Payment Method Data Context Provider with saved cards turned
|
|
255 |
<CheckoutExpressPayment />
|
256 |
<SavedPaymentMethodOptions onChange={ () => void null } />
|
257 |
{ 'Active Payment Method: ' + activePaymentMethod }
|
258 |
-
{ paymentMethodData[ 'wc-
|
259 |
-
<span>
|
260 |
) }
|
261 |
</>
|
262 |
);
|
@@ -276,11 +276,11 @@ describe( 'Testing Payment Method Data Context Provider with saved cards turned
|
|
276 |
// Should initialize by default the default saved payment method.
|
277 |
await waitFor( () => {
|
278 |
const activePaymentMethod = screen.queryByText(
|
279 |
-
/Active Payment Method:
|
280 |
);
|
281 |
-
const
|
282 |
expect( activePaymentMethod ).not.toBeNull();
|
283 |
-
expect(
|
284 |
} );
|
285 |
|
286 |
act( () => {
|
@@ -294,9 +294,9 @@ describe( 'Testing Payment Method Data Context Provider with saved cards turned
|
|
294 |
const activePaymentMethod = screen.queryByText(
|
295 |
/Active Payment Method: express-payment/
|
296 |
);
|
297 |
-
const
|
298 |
expect( activePaymentMethod ).not.toBeNull();
|
299 |
-
expect(
|
300 |
} );
|
301 |
|
302 |
act( () => {
|
@@ -310,11 +310,11 @@ describe( 'Testing Payment Method Data Context Provider with saved cards turned
|
|
310 |
|
311 |
await waitFor( () => {
|
312 |
const activePaymentMethod = screen.queryByText(
|
313 |
-
/Active Payment Method:
|
314 |
);
|
315 |
-
const
|
316 |
expect( activePaymentMethod ).not.toBeNull();
|
317 |
-
expect(
|
318 |
} );
|
319 |
} );
|
320 |
} );
|
44 |
cc: [
|
45 |
{
|
46 |
method: {
|
47 |
+
gateway: 'credit-card',
|
48 |
last4: '4242',
|
49 |
brand: 'Visa',
|
50 |
},
|
75 |
ariaLabel: name,
|
76 |
} );
|
77 |
} );
|
78 |
+
[ 'credit-card' ].forEach( ( name ) => {
|
79 |
registerPaymentMethod( {
|
80 |
name,
|
81 |
label: name,
|
121 |
};
|
122 |
|
123 |
const resetMockPaymentMethods = () => {
|
124 |
+
[ 'cheque', 'bacs', 'credit-card' ].forEach( ( name ) => {
|
125 |
__experimentalDeRegisterPaymentMethod( name );
|
126 |
} );
|
127 |
[ 'express-payment' ].forEach( ( name ) => {
|
255 |
<CheckoutExpressPayment />
|
256 |
<SavedPaymentMethodOptions onChange={ () => void null } />
|
257 |
{ 'Active Payment Method: ' + activePaymentMethod }
|
258 |
+
{ paymentMethodData[ 'wc-credit-card-payment-token' ] && (
|
259 |
+
<span>credit-card token</span>
|
260 |
) }
|
261 |
</>
|
262 |
);
|
276 |
// Should initialize by default the default saved payment method.
|
277 |
await waitFor( () => {
|
278 |
const activePaymentMethod = screen.queryByText(
|
279 |
+
/Active Payment Method: credit-card/
|
280 |
);
|
281 |
+
const creditCardToken = screen.queryByText( /credit-card token/ );
|
282 |
expect( activePaymentMethod ).not.toBeNull();
|
283 |
+
expect( creditCardToken ).not.toBeNull();
|
284 |
} );
|
285 |
|
286 |
act( () => {
|
294 |
const activePaymentMethod = screen.queryByText(
|
295 |
/Active Payment Method: express-payment/
|
296 |
);
|
297 |
+
const creditCardToken = screen.queryByText( /credit-card token/ );
|
298 |
expect( activePaymentMethod ).not.toBeNull();
|
299 |
+
expect( creditCardToken ).toBeNull();
|
300 |
} );
|
301 |
|
302 |
act( () => {
|
310 |
|
311 |
await waitFor( () => {
|
312 |
const activePaymentMethod = screen.queryByText(
|
313 |
+
/Active Payment Method: credit-card/
|
314 |
);
|
315 |
+
const creditCardToken = screen.queryByText( /credit-card token/ );
|
316 |
expect( activePaymentMethod ).not.toBeNull();
|
317 |
+
expect( creditCardToken ).not.toBeNull();
|
318 |
} );
|
319 |
} );
|
320 |
} );
|
assets/js/base/context/providers/cart-checkout/payment-methods/use-payment-method-registration.ts
CHANGED
@@ -135,7 +135,7 @@ const usePaymentMethodRegistration = (
|
|
135 |
} catch ( e ) {
|
136 |
if ( CURRENT_USER_IS_ADMIN || isEditor ) {
|
137 |
const errorText = sprintf(
|
138 |
-
/* translators: %s the id of the payment method being registered (bank transfer,
|
139 |
__(
|
140 |
`There was an error registering the payment method with id '%s': `,
|
141 |
'woo-gutenberg-products-block'
|
@@ -153,8 +153,7 @@ const usePaymentMethodRegistration = (
|
|
153 |
// Re-dispatch available payment methods to store.
|
154 |
dispatcher( availablePaymentMethods );
|
155 |
|
156 |
-
// Note:
|
157 |
-
// Example: Stripe CC, Stripe Payment Request.
|
158 |
// That's why we track "is initialized" state here.
|
159 |
setIsInitialized( true );
|
160 |
}, [
|
135 |
} catch ( e ) {
|
136 |
if ( CURRENT_USER_IS_ADMIN || isEditor ) {
|
137 |
const errorText = sprintf(
|
138 |
+
/* translators: %s the id of the payment method being registered (bank transfer, cheque...) */
|
139 |
__(
|
140 |
`There was an error registering the payment method with id '%s': `,
|
141 |
'woo-gutenberg-products-block'
|
153 |
// Re-dispatch available payment methods to store.
|
154 |
dispatcher( availablePaymentMethods );
|
155 |
|
156 |
+
// Note: Some 4rd party payment methods use the `canMakePayment` callback to initialize / setup.
|
|
|
157 |
// That's why we track "is initialized" state here.
|
158 |
setIsInitialized( true );
|
159 |
}, [
|
assets/js/blocks/cart-checkout/cart/cart-line-items-table/cart-line-item-row.tsx
CHANGED
@@ -70,7 +70,13 @@ const CartLineItemRow = forwardRef< HTMLTableRowElement, CartLineItemRowProps >(
|
|
70 |
description: fullDescription = '',
|
71 |
low_stock_remaining: lowStockRemaining = null,
|
72 |
show_backorder_badge: showBackorderBadge = false,
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
permalink = '',
|
75 |
images = [],
|
76 |
variation = [],
|
@@ -278,19 +284,26 @@ const CartLineItemRow = forwardRef< HTMLTableRowElement, CartLineItemRowProps >(
|
|
278 |
/>
|
279 |
|
280 |
<div className="wc-block-cart-item__quantity">
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
294 |
<button
|
295 |
className="wc-block-cart-item__remove-link"
|
296 |
onClick={ () => {
|
70 |
description: fullDescription = '',
|
71 |
low_stock_remaining: lowStockRemaining = null,
|
72 |
show_backorder_badge: showBackorderBadge = false,
|
73 |
+
quantity_limits: quantityLimits = {
|
74 |
+
minimum: 1,
|
75 |
+
maximum: 99,
|
76 |
+
multiple_of: 1,
|
77 |
+
editable: true,
|
78 |
+
},
|
79 |
+
sold_individually: soldIndividually = false,
|
80 |
permalink = '',
|
81 |
images = [],
|
82 |
variation = [],
|
284 |
/>
|
285 |
|
286 |
<div className="wc-block-cart-item__quantity">
|
287 |
+
{ ! soldIndividually && !! quantityLimits.editable && (
|
288 |
+
<QuantitySelector
|
289 |
+
disabled={ isPendingDelete }
|
290 |
+
quantity={ quantity }
|
291 |
+
minimum={ quantityLimits.minimum }
|
292 |
+
maximum={ quantityLimits.maximum }
|
293 |
+
step={ quantityLimits.multiple_of }
|
294 |
+
onChange={ ( newQuantity ) => {
|
295 |
+
setItemQuantity( newQuantity );
|
296 |
+
dispatchStoreEvent(
|
297 |
+
'cart-set-item-quantity',
|
298 |
+
{
|
299 |
+
product: lineItem,
|
300 |
+
quantity: newQuantity,
|
301 |
+
}
|
302 |
+
);
|
303 |
+
} }
|
304 |
+
itemName={ name }
|
305 |
+
/>
|
306 |
+
) }
|
307 |
<button
|
308 |
className="wc-block-cart-item__remove-link"
|
309 |
onClick={ () => {
|
assets/js/blocks/cart-checkout/cart/style.scss
CHANGED
@@ -238,13 +238,6 @@ table.wc-block-cart-items {
|
|
238 |
}
|
239 |
}
|
240 |
|
241 |
-
.wc-block-cart__sidebar {
|
242 |
-
& > div:not(.wc-block-components-totals-wrapper) {
|
243 |
-
margin-left: $gap;
|
244 |
-
margin-right: $gap;
|
245 |
-
}
|
246 |
-
}
|
247 |
-
|
248 |
.wc-block-components-radio-control__input {
|
249 |
left: 0;
|
250 |
}
|
238 |
}
|
239 |
}
|
240 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
.wc-block-components-radio-control__input {
|
242 |
left: 0;
|
243 |
}
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/block.tsx
CHANGED
@@ -1,8 +1,6 @@
|
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
-
import { StoreNoticesProvider } from '@woocommerce/base-context';
|
5 |
-
import { useEmitResponse } from '@woocommerce/base-context/hooks';
|
6 |
|
7 |
/**
|
8 |
* Internal dependencies
|
@@ -10,13 +8,7 @@ import { useEmitResponse } from '@woocommerce/base-context/hooks';
|
|
10 |
import { PaymentMethods } from '../../../payment-methods';
|
11 |
|
12 |
const Block = (): JSX.Element | null => {
|
13 |
-
|
14 |
-
|
15 |
-
return (
|
16 |
-
<StoreNoticesProvider context={ noticeContexts.PAYMENTS }>
|
17 |
-
<PaymentMethods />
|
18 |
-
</StoreNoticesProvider>
|
19 |
-
);
|
20 |
};
|
21 |
|
22 |
export default Block;
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
|
|
|
|
4 |
|
5 |
/**
|
6 |
* Internal dependencies
|
8 |
import { PaymentMethods } from '../../../payment-methods';
|
9 |
|
10 |
const Block = (): JSX.Element | null => {
|
11 |
+
return <PaymentMethods />;
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
};
|
13 |
|
14 |
export default Block;
|
assets/js/blocks/cart-checkout/mini-cart-contents/edit.tsx
CHANGED
@@ -63,9 +63,7 @@ const Edit = ( { clientId }: Props ): ReactElement => {
|
|
63 |
return (
|
64 |
<div { ...blockProps }>
|
65 |
<EditorProvider currentView={ currentView }>
|
66 |
-
<BlockControls
|
67 |
-
{ ViewSwitcherComponent }
|
68 |
-
</BlockControls>
|
69 |
<InnerBlocks
|
70 |
allowedBlocks={ ALLOWED_BLOCKS }
|
71 |
template={ defaultTemplate }
|
63 |
return (
|
64 |
<div { ...blockProps }>
|
65 |
<EditorProvider currentView={ currentView }>
|
66 |
+
<BlockControls>{ ViewSwitcherComponent }</BlockControls>
|
|
|
|
|
67 |
<InnerBlocks
|
68 |
allowedBlocks={ ALLOWED_BLOCKS }
|
69 |
template={ defaultTemplate }
|
assets/js/blocks/cart-checkout/mini-cart-contents/editor.scss
CHANGED
@@ -5,14 +5,31 @@
|
|
5 |
margin: 0 auto !important;
|
6 |
}
|
7 |
|
8 |
-
.wp-block-woocommerce-filled-mini-cart-contents-block {
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
display: flex;
|
11 |
flex-direction: column;
|
12 |
-
|
13 |
}
|
14 |
}
|
15 |
|
16 |
.wp-block-woocommerce-mini-cart-products-table-block {
|
17 |
margin-bottom: auto;
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
5 |
margin: 0 auto !important;
|
6 |
}
|
7 |
|
8 |
+
.wp-block-woocommerce-filled-mini-cart-contents-block > .block-editor-inner-blocks > .block-editor-block-list__layout {
|
9 |
+
display: flex;
|
10 |
+
flex-direction: column;
|
11 |
+
min-height: 100vh;
|
12 |
+
}
|
13 |
+
|
14 |
+
.wp-block-woocommerce-mini-cart-items-block {
|
15 |
+
display: grid;
|
16 |
+
flex-grow: 1;
|
17 |
+
margin-bottom: $gap;
|
18 |
+
padding: 0 $gap;
|
19 |
+
|
20 |
+
> .block-editor-inner-blocks > .block-editor-block-list__layout {
|
21 |
display: flex;
|
22 |
flex-direction: column;
|
23 |
+
height: 100%;
|
24 |
}
|
25 |
}
|
26 |
|
27 |
.wp-block-woocommerce-mini-cart-products-table-block {
|
28 |
margin-bottom: auto;
|
29 |
+
margin-top: $gap;
|
30 |
+
}
|
31 |
+
|
32 |
+
.editor-styles-wrapper h2.wc-block-mini-cart__title {
|
33 |
+
@include font-size(larger);
|
34 |
+
margin: $gap-largest $gap 0;
|
35 |
}
|
assets/js/blocks/cart-checkout/mini-cart-contents/index.tsx
CHANGED
@@ -35,7 +35,6 @@ const settings = {
|
|
35 |
multiple: false,
|
36 |
reusable: false,
|
37 |
inserter: false,
|
38 |
-
__experimentalExposeControlsToChildren: true,
|
39 |
color: {
|
40 |
text: false,
|
41 |
},
|
35 |
multiple: false,
|
36 |
reusable: false,
|
37 |
inserter: false,
|
|
|
38 |
color: {
|
39 |
text: false,
|
40 |
},
|
assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/empty-mini-cart-contents-block/edit.tsx
CHANGED
@@ -1,40 +1,50 @@
|
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
-
import { __ } from '@wordpress/i18n';
|
5 |
import { useBlockProps, InnerBlocks } from '@wordpress/block-editor';
|
6 |
-
import { innerBlockAreas } from '@woocommerce/blocks-checkout';
|
7 |
-
import type { TemplateArray } from '@wordpress/blocks';
|
8 |
import { useEditorContext } from '@woocommerce/base-context';
|
|
|
9 |
|
10 |
/**
|
11 |
* Internal dependencies
|
12 |
*/
|
13 |
-
import { useForcedLayout, getAllowedBlocks } from '../../../shared';
|
14 |
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
const blockProps = useBlockProps();
|
17 |
-
const allowedBlocks = getAllowedBlocks( innerBlockAreas.EMPTY_MINI_CART );
|
18 |
const { currentView } = useEditorContext();
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
},
|
30 |
-
],
|
31 |
-
].filter( Boolean ) as unknown ) as TemplateArray;
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
defaultTemplate,
|
37 |
-
} );
|
38 |
|
39 |
return (
|
40 |
<div
|
@@ -44,8 +54,7 @@ export const Edit = ( { clientId }: { clientId: string } ): JSX.Element => {
|
|
44 |
}
|
45 |
>
|
46 |
<InnerBlocks
|
47 |
-
|
48 |
-
templateLock={ false }
|
49 |
renderAppender={ InnerBlocks.ButtonBlockAppender }
|
50 |
/>
|
51 |
</div>
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
|
|
4 |
import { useBlockProps, InnerBlocks } from '@wordpress/block-editor';
|
|
|
|
|
5 |
import { useEditorContext } from '@woocommerce/base-context';
|
6 |
+
import { getBlockTypes } from '@wordpress/blocks';
|
7 |
|
8 |
/**
|
9 |
* Internal dependencies
|
10 |
*/
|
|
|
11 |
|
12 |
+
const EXCLUDED_BLOCKS: readonly string[] = [
|
13 |
+
'woocommerce/mini-cart',
|
14 |
+
'woocommerce/single-product',
|
15 |
+
'core/post-template',
|
16 |
+
'core/comment-template',
|
17 |
+
'core/query-pagination',
|
18 |
+
'core/comments-query-loop',
|
19 |
+
'core/post-comments-form',
|
20 |
+
'core/post-comments-link',
|
21 |
+
'core/post-comments-count',
|
22 |
+
'core/comments-pagination',
|
23 |
+
'core/post-navigation-link',
|
24 |
+
];
|
25 |
+
|
26 |
+
export const Edit = (): JSX.Element => {
|
27 |
const blockProps = useBlockProps();
|
|
|
28 |
const { currentView } = useEditorContext();
|
29 |
+
const allowedBlocks = getBlockTypes()
|
30 |
+
.filter( ( block ) => {
|
31 |
+
if ( EXCLUDED_BLOCKS.includes( block.name ) ) {
|
32 |
+
return false;
|
33 |
+
}
|
34 |
|
35 |
+
// Exclude child blocks of EXCLUDED_BLOCKS.
|
36 |
+
if (
|
37 |
+
block.parent &&
|
38 |
+
block.parent.filter( ( value ) =>
|
39 |
+
EXCLUDED_BLOCKS.includes( value )
|
40 |
+
).length > 0
|
41 |
+
) {
|
42 |
+
return false;
|
43 |
+
}
|
|
|
|
|
|
|
44 |
|
45 |
+
return true;
|
46 |
+
} )
|
47 |
+
.map( ( { name } ) => name );
|
|
|
|
|
48 |
|
49 |
return (
|
50 |
<div
|
54 |
}
|
55 |
>
|
56 |
<InnerBlocks
|
57 |
+
allowedBlocks={ allowedBlocks }
|
|
|
58 |
renderAppender={ InnerBlocks.ButtonBlockAppender }
|
59 |
/>
|
60 |
</div>
|
assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/filled-mini-cart-contents-block/edit.tsx
CHANGED
@@ -19,7 +19,7 @@ export const Edit = ( { clientId }: { clientId: string } ): JSX.Element => {
|
|
19 |
|
20 |
const defaultTemplate = ( [
|
21 |
[ 'woocommerce/mini-cart-title-block', {} ],
|
22 |
-
[ 'woocommerce/mini-cart-
|
23 |
[ 'woocommerce/mini-cart-footer-block', {} ],
|
24 |
].filter( Boolean ) as unknown ) as TemplateArray;
|
25 |
|
19 |
|
20 |
const defaultTemplate = ( [
|
21 |
[ 'woocommerce/mini-cart-title-block', {} ],
|
22 |
+
[ 'woocommerce/mini-cart-items-block', {} ],
|
23 |
[ 'woocommerce/mini-cart-footer-block', {} ],
|
24 |
].filter( Boolean ) as unknown ) as TemplateArray;
|
25 |
|
assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/index.tsx
CHANGED
@@ -4,5 +4,6 @@
|
|
4 |
import './empty-mini-cart-contents-block';
|
5 |
import './filled-mini-cart-contents-block';
|
6 |
import './mini-cart-title-block';
|
|
|
7 |
import './mini-cart-products-table-block';
|
8 |
import './mini-cart-footer-block';
|
4 |
import './empty-mini-cart-contents-block';
|
5 |
import './filled-mini-cart-contents-block';
|
6 |
import './mini-cart-title-block';
|
7 |
+
import './mini-cart-items-block';
|
8 |
import './mini-cart-products-table-block';
|
9 |
import './mini-cart-footer-block';
|
assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-footer-block/edit.tsx
CHANGED
@@ -20,3 +20,7 @@ export const Edit = (): JSX.Element => {
|
|
20 |
</div>
|
21 |
);
|
22 |
};
|
|
|
|
|
|
|
|
20 |
</div>
|
21 |
);
|
22 |
};
|
23 |
+
|
24 |
+
export const Save = (): JSX.Element => {
|
25 |
+
return <div { ...useBlockProps.save() }></div>;
|
26 |
+
};
|
assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-footer-block/index.tsx
CHANGED
@@ -7,7 +7,7 @@ import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
|
7 |
/**
|
8 |
* Internal dependencies
|
9 |
*/
|
10 |
-
import { Edit } from './edit';
|
11 |
import metadata from './block.json';
|
12 |
|
13 |
registerFeaturePluginBlockType( metadata, {
|
@@ -20,4 +20,5 @@ registerFeaturePluginBlockType( metadata, {
|
|
20 |
),
|
21 |
},
|
22 |
edit: Edit,
|
|
|
23 |
} );
|
7 |
/**
|
8 |
* Internal dependencies
|
9 |
*/
|
10 |
+
import { Edit, Save } from './edit';
|
11 |
import metadata from './block.json';
|
12 |
|
13 |
registerFeaturePluginBlockType( metadata, {
|
20 |
),
|
21 |
},
|
22 |
edit: Edit,
|
23 |
+
save: Save,
|
24 |
} );
|
assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-items-block/block.json
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "woocommerce/mini-cart-items-block",
|
3 |
+
"version": "1.0.0",
|
4 |
+
"title": "Mini Cart Items",
|
5 |
+
"description": "Contains the products table and other custom blocks of filled mini cart.",
|
6 |
+
"category": "woocommerce",
|
7 |
+
"supports": {
|
8 |
+
"align": false,
|
9 |
+
"html": false,
|
10 |
+
"multiple": false,
|
11 |
+
"reusable": false,
|
12 |
+
"inserter": false
|
13 |
+
},
|
14 |
+
"attributes": {
|
15 |
+
"lock": {
|
16 |
+
"type": "object",
|
17 |
+
"default": {
|
18 |
+
"remove": true,
|
19 |
+
"move": true
|
20 |
+
}
|
21 |
+
}
|
22 |
+
},
|
23 |
+
"parent": [ "woocommerce/filled-mini-cart-contents-block" ],
|
24 |
+
"textdomain": "woo-gutenberg-products-block",
|
25 |
+
"apiVersion": 2
|
26 |
+
}
|
assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-items-block/edit.tsx
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { useBlockProps, InnerBlocks } from '@wordpress/block-editor';
|
5 |
+
import type { TemplateArray } from '@wordpress/blocks';
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Internal dependencies
|
9 |
+
*/
|
10 |
+
|
11 |
+
export const Edit = (): JSX.Element => {
|
12 |
+
const blockProps = useBlockProps();
|
13 |
+
|
14 |
+
const defaultTemplate = ( [
|
15 |
+
[ 'woocommerce/mini-cart-products-table-block', {} ],
|
16 |
+
].filter( Boolean ) as unknown ) as TemplateArray;
|
17 |
+
|
18 |
+
return (
|
19 |
+
<div { ...blockProps }>
|
20 |
+
<InnerBlocks
|
21 |
+
template={ defaultTemplate }
|
22 |
+
renderAppender={ InnerBlocks.ButtonBlockAppender }
|
23 |
+
templateLock={ false }
|
24 |
+
/>
|
25 |
+
</div>
|
26 |
+
);
|
27 |
+
};
|
28 |
+
|
29 |
+
export const Save = (): JSX.Element => {
|
30 |
+
return (
|
31 |
+
<div { ...useBlockProps.save() }>
|
32 |
+
<InnerBlocks.Content />
|
33 |
+
</div>
|
34 |
+
);
|
35 |
+
};
|
assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-items-block/frontend.tsx
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const Block = ( { children }: { children: JSX.Element } ): JSX.Element => {
|
2 |
+
return <div className="wc-block-mini-cart__items">{ children }</div>;
|
3 |
+
};
|
4 |
+
|
5 |
+
export default Block;
|
assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-items-block/index.tsx
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { Icon, grid } from '@woocommerce/icons';
|
5 |
+
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Internal dependencies
|
9 |
+
*/
|
10 |
+
import { Edit, Save } from './edit';
|
11 |
+
import metadata from './block.json';
|
12 |
+
|
13 |
+
registerFeaturePluginBlockType( metadata, {
|
14 |
+
icon: {
|
15 |
+
src: (
|
16 |
+
<Icon
|
17 |
+
srcElement={ grid }
|
18 |
+
className="wc-block-editor-components-block-icon"
|
19 |
+
/>
|
20 |
+
),
|
21 |
+
},
|
22 |
+
edit: Edit,
|
23 |
+
save: Save,
|
24 |
+
} );
|
assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-products-table-block/block.json
CHANGED
@@ -16,11 +16,11 @@
|
|
16 |
"type": "object",
|
17 |
"default": {
|
18 |
"remove": true,
|
19 |
-
"move":
|
20 |
}
|
21 |
}
|
22 |
},
|
23 |
-
"parent": [ "woocommerce/
|
24 |
"textdomain": "woo-gutenberg-products-block",
|
25 |
"apiVersion": 2
|
26 |
}
|
16 |
"type": "object",
|
17 |
"default": {
|
18 |
"remove": true,
|
19 |
+
"move": false
|
20 |
}
|
21 |
}
|
22 |
},
|
23 |
+
"parent": [ "woocommerce/mini-cart-items-block" ],
|
24 |
"textdomain": "woo-gutenberg-products-block",
|
25 |
"apiVersion": 2
|
26 |
}
|
assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-products-table-block/block.tsx
CHANGED
@@ -11,7 +11,7 @@ import CartLineItemsTable from '../../../cart/cart-line-items-table';
|
|
11 |
const Block = (): JSX.Element => {
|
12 |
const { cartItems, cartIsLoading } = useStoreCart();
|
13 |
return (
|
14 |
-
<div className="wc-block-mini-
|
15 |
<CartLineItemsTable
|
16 |
lineItems={ cartItems }
|
17 |
isLoading={ cartIsLoading }
|
11 |
const Block = (): JSX.Element => {
|
12 |
const { cartItems, cartIsLoading } = useStoreCart();
|
13 |
return (
|
14 |
+
<div className="wc-block-mini-cart__products-table">
|
15 |
<CartLineItemsTable
|
16 |
lineItems={ cartItems }
|
17 |
isLoading={ cartIsLoading }
|
assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-products-table-block/edit.tsx
CHANGED
@@ -20,3 +20,7 @@ export const Edit = (): JSX.Element => {
|
|
20 |
</div>
|
21 |
);
|
22 |
};
|
|
|
|
|
|
|
|
20 |
</div>
|
21 |
);
|
22 |
};
|
23 |
+
|
24 |
+
export const Save = (): JSX.Element => {
|
25 |
+
return <div { ...useBlockProps.save() }></div>;
|
26 |
+
};
|
assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-products-table-block/index.tsx
CHANGED
@@ -7,7 +7,7 @@ import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
|
7 |
/**
|
8 |
* Internal dependencies
|
9 |
*/
|
10 |
-
import { Edit } from './edit';
|
11 |
import metadata from './block.json';
|
12 |
|
13 |
registerFeaturePluginBlockType( metadata, {
|
@@ -18,4 +18,5 @@ registerFeaturePluginBlockType( metadata, {
|
|
18 |
/>
|
19 |
),
|
20 |
edit: Edit,
|
|
|
21 |
} );
|
7 |
/**
|
8 |
* Internal dependencies
|
9 |
*/
|
10 |
+
import { Edit, Save } from './edit';
|
11 |
import metadata from './block.json';
|
12 |
|
13 |
registerFeaturePluginBlockType( metadata, {
|
18 |
/>
|
19 |
),
|
20 |
edit: Edit,
|
21 |
+
save: Save,
|
22 |
} );
|
assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-title-block/edit.tsx
CHANGED
@@ -17,3 +17,7 @@ export const Edit = (): JSX.Element => {
|
|
17 |
</div>
|
18 |
);
|
19 |
};
|
|
|
|
|
|
|
|
17 |
</div>
|
18 |
);
|
19 |
};
|
20 |
+
|
21 |
+
export const Save = (): JSX.Element => {
|
22 |
+
return <div { ...useBlockProps.save() }></div>;
|
23 |
+
};
|
assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/mini-cart-title-block/index.tsx
CHANGED
@@ -7,7 +7,7 @@ import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
|
7 |
/**
|
8 |
* Internal dependencies
|
9 |
*/
|
10 |
-
import { Edit } from './edit';
|
11 |
import metadata from './block.json';
|
12 |
|
13 |
registerFeaturePluginBlockType( metadata, {
|
@@ -20,4 +20,5 @@ registerFeaturePluginBlockType( metadata, {
|
|
20 |
),
|
21 |
},
|
22 |
edit: Edit,
|
|
|
23 |
} );
|
7 |
/**
|
8 |
* Internal dependencies
|
9 |
*/
|
10 |
+
import { Edit, Save } from './edit';
|
11 |
import metadata from './block.json';
|
12 |
|
13 |
registerFeaturePluginBlockType( metadata, {
|
20 |
),
|
21 |
},
|
22 |
edit: Edit,
|
23 |
+
save: Save,
|
24 |
} );
|
assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/register-components.ts
CHANGED
@@ -12,6 +12,7 @@ import filledMiniCartMetadata from './filled-mini-cart-contents-block/block.json
|
|
12 |
import miniCartTitleMetadata from './mini-cart-title-block/block.json';
|
13 |
import miniCartProductsTableMetadata from './mini-cart-products-table-block/block.json';
|
14 |
import miniCartFooterMetadata from './mini-cart-footer-block/block.json';
|
|
|
15 |
|
16 |
// Modify webpack publicPath at runtime based on location of WordPress Plugin.
|
17 |
// eslint-disable-next-line no-undef,camelcase
|
@@ -44,6 +45,15 @@ registerCheckoutBlock( {
|
|
44 |
),
|
45 |
} );
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
registerCheckoutBlock( {
|
48 |
metadata: miniCartProductsTableMetadata,
|
49 |
component: lazy( () =>
|
12 |
import miniCartTitleMetadata from './mini-cart-title-block/block.json';
|
13 |
import miniCartProductsTableMetadata from './mini-cart-products-table-block/block.json';
|
14 |
import miniCartFooterMetadata from './mini-cart-footer-block/block.json';
|
15 |
+
import miniCartItemsMetadata from './mini-cart-items-block/block.json';
|
16 |
|
17 |
// Modify webpack publicPath at runtime based on location of WordPress Plugin.
|
18 |
// eslint-disable-next-line no-undef,camelcase
|
45 |
),
|
46 |
} );
|
47 |
|
48 |
+
registerCheckoutBlock( {
|
49 |
+
metadata: miniCartItemsMetadata,
|
50 |
+
component: lazy( () =>
|
51 |
+
import(
|
52 |
+
/* webpackChunkName: "mini-cart-contents-block/items" */ './mini-cart-items-block/frontend'
|
53 |
+
)
|
54 |
+
),
|
55 |
+
} );
|
56 |
+
|
57 |
registerCheckoutBlock( {
|
58 |
metadata: miniCartProductsTableMetadata,
|
59 |
component: lazy( () =>
|
assets/js/blocks/cart-checkout/mini-cart/index.tsx
CHANGED
@@ -36,6 +36,7 @@ const settings = {
|
|
36 |
* to add color classes and style to the wrapper.
|
37 |
*/
|
38 |
__experimentalSkipSerialization: true,
|
|
|
39 |
},
|
40 |
/**
|
41 |
* We need this experimental flag because we don't want to style the
|
36 |
* to add color classes and style to the wrapper.
|
37 |
*/
|
38 |
__experimentalSkipSerialization: true,
|
39 |
+
background: true,
|
40 |
},
|
41 |
/**
|
42 |
* We need this experimental flag because we don't want to style the
|
assets/js/blocks/cart-checkout/mini-cart/quantity-badge/style.scss
CHANGED
@@ -9,14 +9,14 @@
|
|
9 |
border: 0.15em solid;
|
10 |
border-radius: 1em;
|
11 |
box-sizing: border-box;
|
12 |
-
color:
|
13 |
display: flex;
|
14 |
font-size: 0.875em;
|
15 |
font-weight: 600;
|
16 |
-
height: em(20px)
|
17 |
justify-content: center;
|
18 |
-
margin-left: em(-10px)
|
19 |
-
min-width: em(20px)
|
20 |
padding: 0 em($gap-smallest);
|
21 |
transform: translateY(-50%);
|
22 |
white-space: nowrap;
|
9 |
border: 0.15em solid;
|
10 |
border-radius: 1em;
|
11 |
box-sizing: border-box;
|
12 |
+
color: inherit;
|
13 |
display: flex;
|
14 |
font-size: 0.875em;
|
15 |
font-weight: 600;
|
16 |
+
height: math.div(em(20px), 0.875);
|
17 |
justify-content: center;
|
18 |
+
margin-left: math.div(em(-10px), 0.875);
|
19 |
+
min-width: math.div(em(20px), 0.875);
|
20 |
padding: 0 em($gap-smallest);
|
21 |
transform: translateY(-50%);
|
22 |
white-space: nowrap;
|
assets/js/blocks/cart-checkout/mini-cart/style.scss
CHANGED
@@ -65,9 +65,18 @@
|
|
65 |
}
|
66 |
|
67 |
.wc-block-mini-cart__items {
|
|
|
|
|
68 |
flex-grow: 1;
|
69 |
-
overflow-y:
|
70 |
padding: 0 $gap;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
.wc-block-cart-items__row:last-child::after {
|
73 |
content: none;
|
@@ -86,8 +95,8 @@
|
|
86 |
justify-content: center;
|
87 |
}
|
88 |
|
89 |
-
.wc-block-mini-cart__title {
|
90 |
-
@include font-size(
|
91 |
margin: $gap-largest $gap 0;
|
92 |
}
|
93 |
|
65 |
}
|
66 |
|
67 |
.wc-block-mini-cart__items {
|
68 |
+
display: flex;
|
69 |
+
flex-direction: column;
|
70 |
flex-grow: 1;
|
71 |
+
overflow-y: hidden;
|
72 |
padding: 0 $gap;
|
73 |
+
}
|
74 |
+
|
75 |
+
.wc-block-mini-cart__products-table {
|
76 |
+
margin-bottom: auto;
|
77 |
+
margin-right: -$gap;
|
78 |
+
overflow-y: auto;
|
79 |
+
padding-right: $gap;
|
80 |
|
81 |
.wc-block-cart-items__row:last-child::after {
|
82 |
content: none;
|
95 |
justify-content: center;
|
96 |
}
|
97 |
|
98 |
+
h2.wc-block-mini-cart__title {
|
99 |
+
@include font-size(larger);
|
100 |
margin: $gap-largest $gap 0;
|
101 |
}
|
102 |
|
assets/js/blocks/cart-checkout/payment-methods/no-payment-methods/index.js
CHANGED
@@ -38,7 +38,7 @@ const NoPaymentMethodsPlaceholder = () => {
|
|
38 |
>
|
39 |
<span className="wc-block-checkout__no-payment-methods-placeholder-description">
|
40 |
{ __(
|
41 |
-
'Your store does not have any payment methods configured that support the checkout block. Once you have configured a compatible payment method
|
42 |
'woo-gutenberg-products-block'
|
43 |
) }
|
44 |
</span>
|
38 |
>
|
39 |
<span className="wc-block-checkout__no-payment-methods-placeholder-description">
|
40 |
{ __(
|
41 |
+
'Your store does not have any payment methods configured that support the checkout block. Once you have configured a compatible payment method it will be shown here.',
|
42 |
'woo-gutenberg-products-block'
|
43 |
) }
|
44 |
</span>
|
assets/js/blocks/cart-checkout/payment-methods/test/payment-methods.js
CHANGED
@@ -35,7 +35,7 @@ jest.mock(
|
|
35 |
() => ( { onChange } ) => (
|
36 |
<>
|
37 |
<span>Payment method options</span>
|
38 |
-
<button onClick={ () => onChange( '
|
39 |
Select new payment
|
40 |
</button>
|
41 |
</>
|
@@ -43,7 +43,7 @@ jest.mock(
|
|
43 |
);
|
44 |
|
45 |
const registerMockPaymentMethods = () => {
|
46 |
-
[ '
|
47 |
registerPaymentMethod( {
|
48 |
name,
|
49 |
label: name,
|
@@ -62,7 +62,7 @@ const registerMockPaymentMethods = () => {
|
|
62 |
};
|
63 |
|
64 |
const resetMockPaymentMethods = () => {
|
65 |
-
[ '
|
66 |
__experimentalDeRegisterPaymentMethod( name );
|
67 |
} );
|
68 |
};
|
@@ -137,7 +137,7 @@ describe( 'PaymentMethods', () => {
|
|
137 |
expect( savedPaymentMethodOptions ).not.toBeNull();
|
138 |
expect( paymentMethodOptions ).not.toBeNull();
|
139 |
const savedToken = screen.queryByText(
|
140 |
-
/Active Payment Method:
|
141 |
);
|
142 |
expect( savedToken ).toBeNull();
|
143 |
} );
|
@@ -146,7 +146,7 @@ describe( 'PaymentMethods', () => {
|
|
146 |
|
147 |
await waitFor( () => {
|
148 |
const activePaymentMethod = screen.queryByText(
|
149 |
-
/Active Payment Method:
|
150 |
);
|
151 |
expect( activePaymentMethod ).not.toBeNull();
|
152 |
} );
|
35 |
() => ( { onChange } ) => (
|
36 |
<>
|
37 |
<span>Payment method options</span>
|
38 |
+
<button onClick={ () => onChange( 'credit-card' ) }>
|
39 |
Select new payment
|
40 |
</button>
|
41 |
</>
|
43 |
);
|
44 |
|
45 |
const registerMockPaymentMethods = () => {
|
46 |
+
[ 'credit-card' ].forEach( ( name ) => {
|
47 |
registerPaymentMethod( {
|
48 |
name,
|
49 |
label: name,
|
62 |
};
|
63 |
|
64 |
const resetMockPaymentMethods = () => {
|
65 |
+
[ 'credit-card' ].forEach( ( name ) => {
|
66 |
__experimentalDeRegisterPaymentMethod( name );
|
67 |
} );
|
68 |
};
|
137 |
expect( savedPaymentMethodOptions ).not.toBeNull();
|
138 |
expect( paymentMethodOptions ).not.toBeNull();
|
139 |
const savedToken = screen.queryByText(
|
140 |
+
/Active Payment Method: credit-card/
|
141 |
);
|
142 |
expect( savedToken ).toBeNull();
|
143 |
} );
|
146 |
|
147 |
await waitFor( () => {
|
148 |
const activePaymentMethod = screen.queryByText(
|
149 |
+
/Active Payment Method: credit-card/
|
150 |
);
|
151 |
expect( activePaymentMethod ).not.toBeNull();
|
152 |
} );
|
assets/js/blocks/cart-checkout/shared/use-view-switcher.tsx
CHANGED
@@ -14,6 +14,10 @@ interface View {
|
|
14 |
icon: string | JSX.Element;
|
15 |
}
|
16 |
|
|
|
|
|
|
|
|
|
17 |
export const useViewSwitcher = (
|
18 |
clientId: string,
|
19 |
views: View[]
|
@@ -32,7 +36,25 @@ export const useViewSwitcher = (
|
|
32 |
const selectedBlockClientId = getSelectedBlockClientId();
|
33 |
|
34 |
useEffect( () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
const viewNames = views.map( ( { view } ) => view );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
const parentBlockIds = getBlockParentsByBlockName(
|
37 |
selectedBlockClientId,
|
38 |
viewNames
|
@@ -47,15 +69,11 @@ export const useViewSwitcher = (
|
|
47 |
return;
|
48 |
}
|
49 |
|
50 |
-
const
|
51 |
-
( { view } ) => view === parentBlock.name
|
52 |
-
);
|
53 |
|
54 |
-
if (
|
55 |
-
|
56 |
}
|
57 |
-
|
58 |
-
setCurrentView( filteredViews[ 0 ] );
|
59 |
}, [
|
60 |
getBlockParentsByBlockName,
|
61 |
selectedBlockClientId,
|
14 |
icon: string | JSX.Element;
|
15 |
}
|
16 |
|
17 |
+
function getView( viewName: string, views: View[] ) {
|
18 |
+
return views.find( ( view ) => view.view === viewName );
|
19 |
+
}
|
20 |
+
|
21 |
export const useViewSwitcher = (
|
22 |
clientId: string,
|
23 |
views: View[]
|
36 |
const selectedBlockClientId = getSelectedBlockClientId();
|
37 |
|
38 |
useEffect( () => {
|
39 |
+
const selectedBlock = getBlock( selectedBlockClientId );
|
40 |
+
|
41 |
+
if ( ! selectedBlock ) {
|
42 |
+
return;
|
43 |
+
}
|
44 |
+
|
45 |
+
if ( currentView.view === selectedBlock.name ) {
|
46 |
+
return;
|
47 |
+
}
|
48 |
+
|
49 |
const viewNames = views.map( ( { view } ) => view );
|
50 |
+
|
51 |
+
if ( viewNames.includes( selectedBlock.name ) ) {
|
52 |
+
const newView = getView( selectedBlock.name, views );
|
53 |
+
if ( newView ) {
|
54 |
+
return setCurrentView( newView );
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
const parentBlockIds = getBlockParentsByBlockName(
|
59 |
selectedBlockClientId,
|
60 |
viewNames
|
69 |
return;
|
70 |
}
|
71 |
|
72 |
+
const newView = getView( parentBlock.name, views );
|
|
|
|
|
73 |
|
74 |
+
if ( newView ) {
|
75 |
+
setCurrentView( newView );
|
76 |
}
|
|
|
|
|
77 |
}, [
|
78 |
getBlockParentsByBlockName,
|
79 |
selectedBlockClientId,
|
assets/js/blocks/legacy-template/constants.ts
CHANGED
@@ -3,31 +3,36 @@
|
|
3 |
*/
|
4 |
import { __ } from '@wordpress/i18n';
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
7 |
'single-product': {
|
8 |
title: __(
|
9 |
-
'WooCommerce Single Product
|
10 |
'woo-gutenberg-products-block'
|
11 |
),
|
12 |
placeholder: 'single-product',
|
13 |
},
|
14 |
'archive-product': {
|
15 |
title: __(
|
16 |
-
'WooCommerce Product
|
17 |
'woo-gutenberg-products-block'
|
18 |
),
|
19 |
placeholder: 'archive-product',
|
20 |
},
|
21 |
'taxonomy-product_cat': {
|
22 |
title: __(
|
23 |
-
'WooCommerce Product Taxonomy
|
24 |
'woo-gutenberg-products-block'
|
25 |
),
|
26 |
placeholder: 'archive-product',
|
27 |
},
|
28 |
'taxonomy-product_tag': {
|
29 |
title: __(
|
30 |
-
'WooCommerce Product Tag
|
31 |
'woo-gutenberg-products-block'
|
32 |
),
|
33 |
placeholder: 'archive-product',
|
3 |
*/
|
4 |
import { __ } from '@wordpress/i18n';
|
5 |
|
6 |
+
/**
|
7 |
+
* Internal dependencies
|
8 |
+
*/
|
9 |
+
import { TemplateAttributes } from './types';
|
10 |
+
|
11 |
+
export const TEMPLATES: Record< string, TemplateAttributes > = {
|
12 |
'single-product': {
|
13 |
title: __(
|
14 |
+
'WooCommerce Single Product Block',
|
15 |
'woo-gutenberg-products-block'
|
16 |
),
|
17 |
placeholder: 'single-product',
|
18 |
},
|
19 |
'archive-product': {
|
20 |
title: __(
|
21 |
+
'WooCommerce Product Grid Block',
|
22 |
'woo-gutenberg-products-block'
|
23 |
),
|
24 |
placeholder: 'archive-product',
|
25 |
},
|
26 |
'taxonomy-product_cat': {
|
27 |
title: __(
|
28 |
+
'WooCommerce Product Taxonomy Block',
|
29 |
'woo-gutenberg-products-block'
|
30 |
),
|
31 |
placeholder: 'archive-product',
|
32 |
},
|
33 |
'taxonomy-product_tag': {
|
34 |
title: __(
|
35 |
+
'WooCommerce Product Tag Block',
|
36 |
'woo-gutenberg-products-block'
|
37 |
),
|
38 |
placeholder: 'archive-product',
|
assets/js/blocks/legacy-template/editor.scss
CHANGED
@@ -3,6 +3,11 @@
|
|
3 |
margin-bottom: 30px;
|
4 |
}
|
5 |
|
|
|
|
|
|
|
|
|
|
|
6 |
.wp-block-woocommerce-legacy-template__placeholder-wireframe {
|
7 |
width: 100%;
|
8 |
height: 250px;
|
3 |
margin-bottom: 30px;
|
4 |
}
|
5 |
|
6 |
+
.wp-block-woocommerce-legacy-template__placeholder-warning {
|
7 |
+
border-left: 5px solid #2181d2;
|
8 |
+
padding-left: em(40px);
|
9 |
+
}
|
10 |
+
|
11 |
.wp-block-woocommerce-legacy-template__placeholder-wireframe {
|
12 |
width: 100%;
|
13 |
height: 250px;
|
assets/js/blocks/legacy-template/index.tsx
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
|
|
4 |
import { registerBlockType } from '@wordpress/blocks';
|
5 |
import { WC_BLOCKS_IMAGE_URL } from '@woocommerce/block-settings';
|
6 |
import { useBlockProps } from '@wordpress/block-editor';
|
@@ -13,41 +14,56 @@ import { box, Icon } from '@wordpress/icons';
|
|
13 |
*/
|
14 |
import './editor.scss';
|
15 |
import { TEMPLATES } from './constants';
|
|
|
16 |
|
17 |
interface Props {
|
18 |
attributes: {
|
19 |
template: string;
|
|
|
|
|
20 |
};
|
21 |
}
|
22 |
|
23 |
const Edit = ( { attributes }: Props ) => {
|
24 |
const blockProps = useBlockProps();
|
25 |
-
const
|
26 |
-
|
27 |
-
const templatePlaceholder =
|
28 |
-
TEMPLATES[ attributes.template ]?.placeholder ?? 'fallback';
|
29 |
return (
|
30 |
<div { ...blockProps }>
|
31 |
<Placeholder
|
32 |
icon={ box }
|
33 |
-
label={
|
34 |
className="wp-block-woocommerce-legacy-template__placeholder"
|
35 |
>
|
36 |
<div className="wp-block-woocommerce-legacy-template__placeholder-copy">
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
41 |
'woo-gutenberg-products-block'
|
42 |
-
)
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
</div>
|
46 |
<div className="wp-block-woocommerce-legacy-template__placeholder-wireframe">
|
47 |
<img
|
48 |
className="wp-block-woocommerce-legacy-template__placeholder-image"
|
49 |
-
src={ `${ WC_BLOCKS_IMAGE_URL }template-placeholders/${
|
50 |
-
alt={
|
51 |
/>
|
52 |
</div>
|
53 |
</Placeholder>
|
@@ -55,39 +71,77 @@ const Edit = ( { attributes }: Props ) => {
|
|
55 |
);
|
56 |
};
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
)
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
} );
|
1 |
/**
|
2 |
* External dependencies
|
3 |
*/
|
4 |
+
import { select, subscribe } from '@wordpress/data';
|
5 |
import { registerBlockType } from '@wordpress/blocks';
|
6 |
import { WC_BLOCKS_IMAGE_URL } from '@woocommerce/block-settings';
|
7 |
import { useBlockProps } from '@wordpress/block-editor';
|
14 |
*/
|
15 |
import './editor.scss';
|
16 |
import { TEMPLATES } from './constants';
|
17 |
+
import { getMatchingTemplateData } from './utils';
|
18 |
|
19 |
interface Props {
|
20 |
attributes: {
|
21 |
template: string;
|
22 |
+
title: string;
|
23 |
+
placeholder: string;
|
24 |
};
|
25 |
}
|
26 |
|
27 |
const Edit = ( { attributes }: Props ) => {
|
28 |
const blockProps = useBlockProps();
|
29 |
+
const { title, placeholder } = attributes;
|
30 |
+
|
|
|
|
|
31 |
return (
|
32 |
<div { ...blockProps }>
|
33 |
<Placeholder
|
34 |
icon={ box }
|
35 |
+
label={ title }
|
36 |
className="wp-block-woocommerce-legacy-template__placeholder"
|
37 |
>
|
38 |
<div className="wp-block-woocommerce-legacy-template__placeholder-copy">
|
39 |
+
<p className="wp-block-woocommerce-legacy-template__placeholder-warning">
|
40 |
+
<strong>
|
41 |
+
{ __(
|
42 |
+
'Attention: Do not remove this block!',
|
43 |
+
'woo-gutenberg-products-block'
|
44 |
+
) }
|
45 |
+
</strong>{ ' ' }
|
46 |
+
{ __(
|
47 |
+
'Removal will cause unintended effects on your store.',
|
48 |
'woo-gutenberg-products-block'
|
49 |
+
) }
|
50 |
+
</p>
|
51 |
+
<p>
|
52 |
+
{ sprintf(
|
53 |
+
/* translators: %s is the template title */
|
54 |
+
__(
|
55 |
+
'This is an editor placeholder for the %s. On your store this will be replaced by the template and display with your product image(s), title, price, etc. You can move this placeholder around and add further blocks around it to extend the template.',
|
56 |
+
'woo-gutenberg-products-block'
|
57 |
+
),
|
58 |
+
title
|
59 |
+
) }
|
60 |
+
</p>
|
61 |
</div>
|
62 |
<div className="wp-block-woocommerce-legacy-template__placeholder-wireframe">
|
63 |
<img
|
64 |
className="wp-block-woocommerce-legacy-template__placeholder-image"
|
65 |
+
src={ `${ WC_BLOCKS_IMAGE_URL }template-placeholders/${ placeholder }.svg` }
|
66 |
+
alt={ title }
|
67 |
/>
|
68 |
</div>
|
69 |
</Placeholder>
|
71 |
);
|
72 |
};
|
73 |
|
74 |
+
let templateId: string | undefined;
|
75 |
+
|
76 |
+
const unsubscribe = subscribe( () => {
|
77 |
+
const store = select( 'core/edit-site' );
|
78 |
+
|
79 |
+
if ( ! store ) {
|
80 |
+
// The store will only exist in the Site Editor so we need to unsubscribe and early return for Posts / Pages.
|
81 |
+
unsubscribe();
|
82 |
+
return;
|
83 |
+
}
|
84 |
+
|
85 |
+
templateId = store?.getEditedPostId();
|
86 |
+
|
87 |
+
if ( templateId ) {
|
88 |
+
unsubscribe();
|
89 |
+
const currentTemplateSlug = templateId?.split( '//' )[ 1 ];
|
90 |
+
const templateData = getMatchingTemplateData(
|
91 |
+
TEMPLATES,
|
92 |
+
currentTemplateSlug
|
93 |
+
);
|
94 |
+
// We only want this block to be available for use in specified WooCommerce templates.
|
95 |
+
const eligibleForInserter = templateData !== null;
|
96 |
+
const title = templateData?.title ?? currentTemplateSlug;
|
97 |
+
const placeholder = templateData?.placeholder ?? 'fallback';
|
98 |
+
|
99 |
+
registerBlockType( 'woocommerce/legacy-template', {
|
100 |
+
title,
|
101 |
+
icon: (
|
102 |
+
<Icon
|
103 |
+
icon={ box }
|
104 |
+
className="wc-block-editor-components-block-icon"
|
105 |
+
/>
|
106 |
+
),
|
107 |
+
category: 'woocommerce',
|
108 |
+
apiVersion: 2,
|
109 |
+
keywords: [ __( 'WooCommerce', 'woo-gutenberg-products-block' ) ],
|
110 |
+
description: __(
|
111 |
+
'Renders legacy WooCommerce PHP templates.',
|
112 |
+
'woo-gutenberg-products-block'
|
113 |
+
),
|
114 |
+
supports: {
|
115 |
+
align: [ 'wide', 'full' ],
|
116 |
+
html: false,
|
117 |
+
multiple: false,
|
118 |
+
reusable: false,
|
119 |
+
inserter: eligibleForInserter,
|
120 |
+
},
|
121 |
+
example: {
|
122 |
+
attributes: {
|
123 |
+
isPreview: true,
|
124 |
+
},
|
125 |
+
},
|
126 |
+
attributes: {
|
127 |
+
/**
|
128 |
+
* Template attribute is used to determine which core PHP template gets rendered.
|
129 |
+
*/
|
130 |
+
template: {
|
131 |
+
type: 'string',
|
132 |
+
default: currentTemplateSlug,
|
133 |
+
},
|
134 |
+
title: {
|
135 |
+
type: 'string',
|
136 |
+
default: title,
|
137 |
+
},
|
138 |
+
placeholder: {
|
139 |
+
type: 'string',
|
140 |
+
default: placeholder,
|
141 |
+
},
|
142 |
+
},
|
143 |
+
edit: Edit,
|
144 |
+
save: () => null,
|
145 |
+
} );
|
146 |
+
}
|
147 |
} );
|
assets/js/blocks/legacy-template/test/utils.ts
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Internal dependencies
|
3 |
+
*/
|
4 |
+
import { getMatchingTemplateData } from '../utils';
|
5 |
+
import { TEMPLATES } from '../constants';
|
6 |
+
|
7 |
+
describe( 'getMatchingTemplateData', () => {
|
8 |
+
it( 'should return template data if a correct match has been found', () => {
|
9 |
+
expect(
|
10 |
+
getMatchingTemplateData(
|
11 |
+
TEMPLATES,
|
12 |
+
'taxonomy-product_cat-winter-collection'
|
13 |
+
)
|
14 |
+
).toBe( TEMPLATES[ 'taxonomy-product_cat' ] );
|
15 |
+
|
16 |
+
expect( getMatchingTemplateData( TEMPLATES, 'single-product' ) ).toBe(
|
17 |
+
TEMPLATES[ 'single-product' ]
|
18 |
+
);
|
19 |
+
|
20 |
+
expect(
|
21 |
+
getMatchingTemplateData( TEMPLATES, 'taxonomy-product_tag' )
|
22 |
+
).toBe( TEMPLATES[ 'taxonomy-product_tag' ] );
|
23 |
+
} );
|
24 |
+
|
25 |
+
it( 'should return null if given template slug does not match any of the expected options', () => {
|
26 |
+
expect(
|
27 |
+
getMatchingTemplateData( TEMPLATES, 'slug-does-not-match' )
|
28 |
+
).toBe( null );
|
29 |
+
} );
|
30 |
+
} );
|
assets/js/blocks/legacy-template/types.ts
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
export type TemplateAttributes = {
|
2 |
+
title: string;
|
3 |
+
placeholder: string;
|
4 |
+
};
|
assets/js/blocks/legacy-template/utils.ts
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Internal dependencies
|
3 |
+
*/
|
4 |
+
import { TemplateAttributes } from './types';
|
5 |
+
|
6 |
+
export function beginsWith( needle: string, haystack: string ): boolean {
|
7 |
+
return haystack.substr( 0, needle.length ) === needle;
|
8 |
+
}
|
9 |
+
|
10 |
+
export function getMatchingTemplateData(
|
11 |
+
templates: Record< string, TemplateAttributes >,
|
12 |
+
slug: string
|
13 |
+
): TemplateAttributes | null {
|
14 |
+
const templateSlugs = Object.keys( templates );
|
15 |
+
const matchingSlugs = templateSlugs.filter( ( templateSlug ) =>
|
16 |
+
slug.startsWith( templateSlug )
|
17 |
+
);
|
18 |
+
|
19 |
+
if ( matchingSlugs.length === 0 ) {
|
20 |
+
return null;
|
21 |
+
}
|
22 |
+
|
23 |
+
return templates[ matchingSlugs[ 0 ] ];
|
24 |
+
}
|
assets/js/blocks/price-filter/block.js
CHANGED
@@ -17,6 +17,7 @@ import { getCurrencyFromPriceResponse } from '@woocommerce/price-format';
|
|
17 |
* Internal dependencies
|
18 |
*/
|
19 |
import usePriceConstraints from './use-price-constraints.js';
|
|
|
20 |
|
21 |
/**
|
22 |
* Component displaying a price filter.
|
17 |
* Internal dependencies
|
18 |
*/
|
19 |
import usePriceConstraints from './use-price-constraints.js';
|
20 |
+
import './style.scss';
|
21 |
|
22 |
/**
|
23 |
* Component displaying a price filter.
|
assets/js/blocks/price-filter/edit.js
CHANGED
@@ -2,8 +2,7 @@
|
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { __ } from '@wordpress/i18n';
|
5 |
-
import
|
6 |
-
import { InspectorControls } from '@wordpress/block-editor';
|
7 |
import {
|
8 |
Placeholder,
|
9 |
Disabled,
|
@@ -26,13 +25,14 @@ import './editor.scss';
|
|
26 |
|
27 |
export default function ( { attributes, setAttributes } ) {
|
28 |
const {
|
29 |
-
className,
|
30 |
heading,
|
31 |
headingLevel,
|
32 |
showInputFields,
|
33 |
showFilterButton,
|
34 |
} = attributes;
|
35 |
|
|
|
|
|
36 |
const getInspectorControls = () => {
|
37 |
return (
|
38 |
<InspectorControls key="inspector">
|
@@ -152,16 +152,11 @@ export default function ( { attributes, setAttributes } ) {
|
|
152 |
);
|
153 |
|
154 |
return (
|
155 |
-
|
156 |
{ blocksConfig.productCount === 0 ? (
|
157 |
noProductsPlaceholder()
|
158 |
) : (
|
159 |
-
|
160 |
-
className={ classNames(
|
161 |
-
className,
|
162 |
-
'wp-block-woocommerce-price-filter'
|
163 |
-
) }
|
164 |
-
>
|
165 |
{ getInspectorControls() }
|
166 |
<BlockTitle
|
167 |
className="wc-block-price-filter__title"
|
@@ -174,8 +169,8 @@ export default function ( { attributes, setAttributes } ) {
|
|
174 |
<Disabled>
|
175 |
<Block attributes={ attributes } isEditor={ true } />
|
176 |
</Disabled>
|
177 |
-
|
178 |
) }
|
179 |
-
|
180 |
);
|
181 |
}
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { __ } from '@wordpress/i18n';
|
5 |
+
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
|
|
|
6 |
import {
|
7 |
Placeholder,
|
8 |
Disabled,
|
25 |
|
26 |
export default function ( { attributes, setAttributes } ) {
|
27 |
const {
|
|
|
28 |
heading,
|
29 |
headingLevel,
|
30 |
showInputFields,
|
31 |
showFilterButton,
|
32 |
} = attributes;
|
33 |
|
34 |
+
const blockProps = useBlockProps();
|
35 |
+
|
36 |
const getInspectorControls = () => {
|
37 |
return (
|
38 |
<InspectorControls key="inspector">
|
152 |
);
|
153 |
|
154 |
return (
|
155 |
+
<div { ...blockProps }>
|
156 |
{ blocksConfig.productCount === 0 ? (
|
157 |
noProductsPlaceholder()
|
158 |
) : (
|
159 |
+
<>
|
|
|
|
|
|
|
|
|
|
|
160 |
{ getInspectorControls() }
|
161 |
<BlockTitle
|
162 |
className="wc-block-price-filter__title"
|
169 |
<Disabled>
|
170 |
<Block attributes={ attributes } isEditor={ true } />
|
171 |
</Disabled>
|
172 |
+
</>
|
173 |
) }
|
174 |
+
</div>
|
175 |
);
|
176 |
}
|
assets/js/blocks/price-filter/editor.scss
CHANGED
@@ -1,14 +1,20 @@
|
|
1 |
-
.
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
10 |
}
|
11 |
}
|
|
|
12 |
.wc-block-price-slider {
|
13 |
.components-placeholder__instructions {
|
14 |
border-bottom: 1px solid #e0e2e6;
|
1 |
+
.wp-block-woocommerce-price-filter .components-disabled {
|
2 |
+
border-radius: inherit;
|
3 |
+
border-color: inherit;
|
4 |
+
|
5 |
+
.wc-block-price-filter__range-input-wrapper .wc-block-price-filter__range-input {
|
6 |
+
&::-webkit-slider-thumb {
|
7 |
+
pointer-events: none;
|
8 |
+
}
|
9 |
+
&::-moz-range-thumb {
|
10 |
+
pointer-events: none;
|
11 |
+
}
|
12 |
+
&::-ms-thumb {
|
13 |
+
pointer-events: none;
|
14 |
+
}
|
15 |
}
|
16 |
}
|
17 |
+
|
18 |
.wc-block-price-slider {
|
19 |
.components-placeholder__instructions {
|
20 |
border-bottom: 1px solid #e0e2e6;
|
assets/js/blocks/price-filter/index.js
CHANGED
@@ -5,6 +5,8 @@ import { __ } from '@wordpress/i18n';
|
|
5 |
import { registerBlockType } from '@wordpress/blocks';
|
6 |
import classNames from 'classnames';
|
7 |
import { Icon, bill } from '@woocommerce/icons';
|
|
|
|
|
8 |
|
9 |
/**
|
10 |
* Internal dependencies
|
@@ -12,6 +14,7 @@ import { Icon, bill } from '@woocommerce/icons';
|
|
12 |
import edit from './edit.js';
|
13 |
|
14 |
registerBlockType( 'woocommerce/price-filter', {
|
|
|
15 |
title: __( 'Filter Products by Price', 'woo-gutenberg-products-block' ),
|
16 |
icon: {
|
17 |
src: (
|
@@ -30,6 +33,17 @@ registerBlockType( 'woocommerce/price-filter', {
|
|
30 |
supports: {
|
31 |
html: false,
|
32 |
multiple: false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
},
|
34 |
example: {},
|
35 |
attributes: {
|
@@ -70,7 +84,9 @@ registerBlockType( 'woocommerce/price-filter', {
|
|
70 |
};
|
71 |
return (
|
72 |
<div
|
73 |
-
|
|
|
|
|
74 |
{ ...data }
|
75 |
>
|
76 |
<span
|
5 |
import { registerBlockType } from '@wordpress/blocks';
|
6 |
import classNames from 'classnames';
|
7 |
import { Icon, bill } from '@woocommerce/icons';
|
8 |
+
import { isFeaturePluginBuild } from '@woocommerce/block-settings';
|
9 |
+
import { useBlockProps } from '@wordpress/block-editor';
|
10 |
|
11 |
/**
|
12 |
* Internal dependencies
|
14 |
import edit from './edit.js';
|
15 |
|
16 |
registerBlockType( 'woocommerce/price-filter', {
|
17 |
+
apiVersion: 2,
|
18 |
title: __( 'Filter Products by Price', 'woo-gutenberg-products-block' ),
|
19 |
icon: {
|
20 |
src: (
|
33 |
supports: {
|
34 |
html: false,
|
35 |
multiple: false,
|
36 |
+
color: {
|
37 |
+
text: true,
|
38 |
+
background: false,
|
39 |
+
},
|
40 |
+
...( isFeaturePluginBuild() && {
|
41 |
+
__experimentalBorder: {
|
42 |
+
radius: true,
|
43 |
+
color: true,
|
44 |
+
width: false,
|
45 |
+
},
|
46 |
+
} ),
|
47 |
},
|
48 |
example: {},
|
49 |
attributes: {
|
84 |
};
|
85 |
return (
|
86 |
<div
|
87 |
+
{ ...useBlockProps.save( {
|
88 |
+
className: classNames( 'is-loading', className ),
|
89 |
+
} ) }
|
90 |
{ ...data }
|
91 |
>
|
92 |
<span
|
assets/js/blocks/price-filter/style.scss
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.wp-block-woocommerce-price-filter {
|
2 |
+
border-style: none !important;
|
3 |
+
}
|
4 |
+
|
5 |
+
.wc-block-price-slider {
|
6 |
+
border-radius: inherit;
|
7 |
+
border-color: inherit;
|
8 |
+
}
|
9 |
+
|
10 |
+
.wc-block-price-filter {
|
11 |
+
border-radius: inherit;
|
12 |
+
border-color: inherit;
|
13 |
+
}
|
14 |
+
|
15 |
+
|
16 |
+
.wc-block-price-filter__controls {
|
17 |
+
border-radius: inherit;
|
18 |
+
border-color: inherit;
|
19 |
+
|
20 |
+
input {
|
21 |
+
border-radius: inherit !important;
|
22 |
+
border-color: inherit !important;
|
23 |
+
border-style: solid;
|
24 |
+
}
|
25 |
+
}
|
assets/js/blocks/product-category/block.js
CHANGED
@@ -18,6 +18,7 @@ import GridContentControl from '@woocommerce/editor-components/grid-content-cont
|
|
18 |
import GridLayoutControl from '@woocommerce/editor-components/grid-layout-control';
|
19 |
import ProductCategoryControl from '@woocommerce/editor-components/product-category-control';
|
20 |
import ProductOrderbyControl from '@woocommerce/editor-components/product-orderby-control';
|
|
|
21 |
import { gridBlockPreview } from '@woocommerce/resource-previews';
|
22 |
import { Icon, folder } from '@woocommerce/icons';
|
23 |
import { getSetting } from '@woocommerce/settings';
|
@@ -119,6 +120,7 @@ class ProductByCategoryBlock extends Component {
|
|
119 |
orderby,
|
120 |
rows,
|
121 |
alignButtons,
|
|
|
122 |
} = attributes;
|
123 |
|
124 |
return (
|
@@ -186,6 +188,18 @@ class ProductByCategoryBlock extends Component {
|
|
186 |
value={ orderby }
|
187 |
/>
|
188 |
</PanelBody>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
</InspectorControls>
|
190 |
);
|
191 |
}
|
18 |
import GridLayoutControl from '@woocommerce/editor-components/grid-layout-control';
|
19 |
import ProductCategoryControl from '@woocommerce/editor-components/product-category-control';
|
20 |
import ProductOrderbyControl from '@woocommerce/editor-components/product-orderby-control';
|
21 |
+
import ProductStockControl from '@woocommerce/editor-components/product-stock-control';
|
22 |
import { gridBlockPreview } from '@woocommerce/resource-previews';
|
23 |
import { Icon, folder } from '@woocommerce/icons';
|
24 |
import { getSetting } from '@woocommerce/settings';
|
120 |
orderby,
|
121 |
rows,
|
122 |
alignButtons,
|
123 |
+
stockStatus,
|
124 |
} = attributes;
|
125 |
|
126 |
return (
|
188 |
value={ orderby }
|
189 |
/>
|
190 |
</PanelBody>
|
191 |
+
<PanelBody
|
192 |
+
title={ __(
|
193 |
+
'Filter by stock status',
|
194 |
+
'woo-gutenberg-products-block'
|
195 |
+
) }
|
196 |
+
initialOpen={ false }
|
197 |
+
>
|
198 |
+
<ProductStockControl
|
199 |
+
setAttributes={ setAttributes }
|
200 |
+
value={ stockStatus }
|
201 |
+
/>
|
202 |
+
</PanelBody>
|
203 |
</InspectorControls>
|
204 |
);
|
205 |
}
|
assets/js/blocks/product-new/block.js
CHANGED
@@ -10,6 +10,7 @@ import PropTypes from 'prop-types';
|
|
10 |
import GridContentControl from '@woocommerce/editor-components/grid-content-control';
|
11 |
import GridLayoutControl from '@woocommerce/editor-components/grid-layout-control';
|
12 |
import ProductCategoryControl from '@woocommerce/editor-components/product-category-control';
|
|
|
13 |
import { gridBlockPreview } from '@woocommerce/resource-previews';
|
14 |
import { getSetting } from '@woocommerce/settings';
|
15 |
|
@@ -26,6 +27,7 @@ class ProductNewestBlock extends Component {
|
|
26 |
contentVisibility,
|
27 |
rows,
|
28 |
alignButtons,
|
|
|
29 |
} = attributes;
|
30 |
|
31 |
return (
|
@@ -56,6 +58,18 @@ class ProductNewestBlock extends Component {
|
|
56 |
}
|
57 |
/>
|
58 |
</PanelBody>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
<PanelBody
|
60 |
title={ __(
|
61 |
'Filter by Product Category',
|
10 |
import GridContentControl from '@woocommerce/editor-components/grid-content-control';
|
11 |
import GridLayoutControl from '@woocommerce/editor-components/grid-layout-control';
|
12 |
import ProductCategoryControl from '@woocommerce/editor-components/product-category-control';
|
13 |
+
import ProductStockControl from '@woocommerce/editor-components/product-stock-control';
|
14 |
import { gridBlockPreview } from '@woocommerce/resource-previews';
|
15 |
import { getSetting } from '@woocommerce/settings';
|
16 |
|
27 |
contentVisibility,
|
28 |
rows,
|
29 |
alignButtons,
|
30 |
+
stockStatus,
|
31 |
} = attributes;
|
32 |
|
33 |
return (
|
58 |
}
|
59 |
/>
|
60 |
</PanelBody>
|
61 |
+
<PanelBody
|
62 |
+
title={ __(
|
63 |
+
'Filter by stock status',
|
64 |
+
'woo-gutenberg-products-block'
|
65 |
+
) }
|
66 |
+
initialOpen={ false }
|
67 |
+
>
|
68 |
+
<ProductStockControl
|
69 |
+
setAttributes={ setAttributes }
|
70 |
+
value={ stockStatus }
|
71 |
+
/>
|
72 |
+
</PanelBody>
|
73 |
<PanelBody
|
74 |
title={ __(
|
75 |
'Filter by Product Category',
|
assets/js/blocks/product-on-sale/block.js
CHANGED
@@ -11,6 +11,7 @@ import GridContentControl from '@woocommerce/editor-components/grid-content-cont
|
|
11 |
import GridLayoutControl from '@woocommerce/editor-components/grid-layout-control';
|
12 |
import ProductCategoryControl from '@woocommerce/editor-components/product-category-control';
|
13 |
import ProductOrderbyControl from '@woocommerce/editor-components/product-orderby-control';
|
|
|
14 |
import { gridBlockPreview } from '@woocommerce/resource-previews';
|
15 |
import { Icon, tag } from '@woocommerce/icons';
|
16 |
import { getSetting } from '@woocommerce/settings';
|
@@ -42,6 +43,7 @@ class ProductOnSaleBlock extends Component {
|
|
42 |
rows,
|
43 |
orderby,
|
44 |
alignButtons,
|
|
|
45 |
} = attributes;
|
46 |
|
47 |
return (
|
@@ -100,6 +102,18 @@ class ProductOnSaleBlock extends Component {
|
|
100 |
}
|
101 |
/>
|
102 |
</PanelBody>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
</InspectorControls>
|
104 |
);
|
105 |
}
|
11 |
import GridLayoutControl from '@woocommerce/editor-components/grid-layout-control';
|
12 |
import ProductCategoryControl from '@woocommerce/editor-components/product-category-control';
|
13 |
import ProductOrderbyControl from '@woocommerce/editor-components/product-orderby-control';
|
14 |
+
import ProductStockControl from '@woocommerce/editor-components/product-stock-control';
|
15 |
import { gridBlockPreview } from '@woocommerce/resource-previews';
|
16 |
import { Icon, tag } from '@woocommerce/icons';
|
17 |
import { getSetting } from '@woocommerce/settings';
|
43 |
rows,
|
44 |
orderby,
|
45 |
alignButtons,
|
46 |
+
stockStatus,
|
47 |
} = attributes;
|
48 |
|
49 |
return (
|
102 |
}
|
103 |
/>
|
104 |
</PanelBody>
|
105 |
+
<PanelBody
|
106 |
+
title={ __(
|
107 |
+
'Filter by stock status',
|
108 |
+
'woo-gutenberg-products-block'
|
109 |
+
) }
|
110 |
+
initialOpen={ false }
|
111 |
+
>
|
112 |
+
<ProductStockControl
|
113 |
+
setAttributes={ setAttributes }
|
114 |
+
value={ stockStatus }
|
115 |
+
/>
|
116 |
+
</PanelBody>
|
117 |
</InspectorControls>
|
118 |
);
|
119 |
}
|
assets/js/blocks/product-tag/block.js
CHANGED
@@ -18,6 +18,7 @@ import GridContentControl from '@woocommerce/editor-components/grid-content-cont
|
|
18 |
import GridLayoutControl from '@woocommerce/editor-components/grid-layout-control';
|
19 |
import ProductTagControl from '@woocommerce/editor-components/product-tag-control';
|
20 |
import ProductOrderbyControl from '@woocommerce/editor-components/product-orderby-control';
|
|
|
21 |
import { Icon, more } from '@woocommerce/icons';
|
22 |
import { gridBlockPreview } from '@woocommerce/resource-previews';
|
23 |
import { getSetting } from '@woocommerce/settings';
|
@@ -91,6 +92,7 @@ class ProductsByTagBlock extends Component {
|
|
91 |
orderby,
|
92 |
rows,
|
93 |
alignButtons,
|
|
|
94 |
} = attributes;
|
95 |
|
96 |
return (
|
@@ -150,6 +152,18 @@ class ProductsByTagBlock extends Component {
|
|
150 |
value={ orderby }
|
151 |
/>
|
152 |
</PanelBody>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
</InspectorControls>
|
154 |
);
|
155 |
}
|
18 |
import GridLayoutControl from '@woocommerce/editor-components/grid-layout-control';
|
19 |
import ProductTagControl from '@woocommerce/editor-components/product-tag-control';
|
20 |
import ProductOrderbyControl from '@woocommerce/editor-components/product-orderby-control';
|
21 |
+
import ProductStockControl from '@woocommerce/editor-components/product-stock-control';
|
22 |
import { Icon, more } from '@woocommerce/icons';
|
23 |
import { gridBlockPreview } from '@woocommerce/resource-previews';
|
24 |
import { getSetting } from '@woocommerce/settings';
|
92 |
orderby,
|
93 |
rows,
|
94 |
alignButtons,
|
95 |
+
stockStatus,
|
96 |
} = attributes;
|
97 |
|
98 |
return (
|
152 |
value={ orderby }
|
153 |
/>
|
154 |
</PanelBody>
|
155 |
+
<PanelBody
|
156 |
+
title={ __(
|
157 |
+
'Filter by stock status',
|
158 |
+
'woo-gutenberg-products-block'
|
159 |
+
) }
|
160 |
+
initialOpen={ false }
|
161 |
+
>
|
162 |
+
<ProductStockControl
|
163 |
+
setAttributes={ setAttributes }
|
164 |
+
value={ stockStatus }
|
165 |
+
/>
|
166 |
+
</PanelBody>
|
167 |
</InspectorControls>
|
168 |
);
|
169 |
}
|
assets/js/blocks/product-tag/index.js
CHANGED
@@ -109,6 +109,14 @@ registerBlockType( 'woocommerce/product-tag', {
|
|
109 |
type: 'boolean',
|
110 |
default: false,
|
111 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
},
|
113 |
|
114 |
/**
|
109 |
type: 'boolean',
|
110 |
default: false,
|
111 |
},
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Whether to display in stock, out of stock or backorder products.
|
115 |
+
*/
|
116 |
+
stockStatus: {
|
117 |
+
type: 'array',
|
118 |
+
default: Object.keys( getSetting( 'stockStatusOptions', [] ) ),
|
119 |
+
},
|
120 |
},
|
121 |
|
122 |
/**
|
assets/js/blocks/product-top-rated/block.js
CHANGED
@@ -10,6 +10,7 @@ import PropTypes from 'prop-types';
|
|
10 |
import GridContentControl from '@woocommerce/editor-components/grid-content-control';
|
11 |
import GridLayoutControl from '@woocommerce/editor-components/grid-layout-control';
|
12 |
import ProductCategoryControl from '@woocommerce/editor-components/product-category-control';
|
|
|
13 |
import { gridBlockPreview } from '@woocommerce/resource-previews';
|
14 |
import { getSetting } from '@woocommerce/settings';
|
15 |
|
@@ -26,6 +27,7 @@ class ProductTopRatedBlock extends Component {
|
|
26 |
contentVisibility,
|
27 |
rows,
|
28 |
alignButtons,
|
|
|
29 |
} = attributes;
|
30 |
|
31 |
return (
|
@@ -75,6 +77,18 @@ class ProductTopRatedBlock extends Component {
|
|
75 |
}
|
76 |
/>
|
77 |
</PanelBody>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
</InspectorControls>
|
79 |
);
|
80 |
}
|
10 |
import GridContentControl from '@woocommerce/editor-components/grid-content-control';
|
11 |
import GridLayoutControl from '@woocommerce/editor-components/grid-layout-control';
|
12 |
import ProductCategoryControl from '@woocommerce/editor-components/product-category-control';
|
13 |
+
import ProductStockControl from '@woocommerce/editor-components/product-stock-control';
|
14 |
import { gridBlockPreview } from '@woocommerce/resource-previews';
|
15 |
import { getSetting } from '@woocommerce/settings';
|
16 |
|
27 |
contentVisibility,
|
28 |
rows,
|
29 |
alignButtons,
|
30 |
+
stockStatus,
|
31 |
} = attributes;
|
32 |
|
33 |
return (
|
77 |
}
|
78 |
/>
|
79 |
</PanelBody>
|
80 |
+
<PanelBody
|
81 |
+
title={ __(
|
82 |
+
'Filter by stock status',
|
83 |
+
'woo-gutenberg-products-block'
|
84 |
+
) }
|
85 |
+
initialOpen={ false }
|
86 |
+
>
|
87 |
+
<ProductStockControl
|
88 |
+
setAttributes={ setAttributes }
|
89 |
+
value={ stockStatus }
|
90 |
+
/>
|
91 |
+
</PanelBody>
|
92 |
</InspectorControls>
|
93 |
);
|
94 |
}
|
assets/js/blocks/products-by-attribute/block.js
CHANGED
@@ -19,6 +19,7 @@ import GridContentControl from '@woocommerce/editor-components/grid-content-cont
|
|
19 |
import GridLayoutControl from '@woocommerce/editor-components/grid-layout-control';
|
20 |
import ProductAttributeTermControl from '@woocommerce/editor-components/product-attribute-term-control';
|
21 |
import ProductOrderbyControl from '@woocommerce/editor-components/product-orderby-control';
|
|
|
22 |
import { gridBlockPreview } from '@woocommerce/resource-previews';
|
23 |
import { getSetting } from '@woocommerce/settings';
|
24 |
|
@@ -36,6 +37,7 @@ class ProductsByAttributeBlock extends Component {
|
|
36 |
orderby,
|
37 |
rows,
|
38 |
alignButtons,
|
|
|
39 |
} = this.props.attributes;
|
40 |
|
41 |
return (
|
@@ -100,6 +102,18 @@ class ProductsByAttributeBlock extends Component {
|
|
100 |
value={ orderby }
|
101 |
/>
|
102 |
</PanelBody>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
</InspectorControls>
|
104 |
);
|
105 |
}
|
19 |
import GridLayoutControl from '@woocommerce/editor-components/grid-layout-control';
|
20 |
import ProductAttributeTermControl from '@woocommerce/editor-components/product-attribute-term-control';
|
21 |
import ProductOrderbyControl from '@woocommerce/editor-components/product-orderby-control';
|
22 |
+
import ProductStockControl from '@woocommerce/editor-components/product-stock-control';
|
23 |
import { gridBlockPreview } from '@woocommerce/resource-previews';
|
24 |
import { getSetting } from '@woocommerce/settings';
|
25 |
|
37 |
orderby,
|
38 |
rows,
|
39 |
alignButtons,
|
40 |
+
stockStatus,
|
41 |
} = this.props.attributes;
|
42 |
|
43 |
return (
|
102 |
value={ orderby }
|
103 |
/>
|
104 |
</PanelBody>
|
105 |
+
<PanelBody
|
106 |
+
title={ __(
|
107 |
+
'Filter by stock status',
|
108 |
+
'woo-gutenberg-products-block'
|
109 |
+
) }
|
110 |
+
initialOpen={ false }
|
111 |
+
>
|
112 |
+
<ProductStockControl
|
113 |
+
setAttributes={ setAttributes }
|
114 |
+
value={ stockStatus }
|
115 |
+
/>
|
116 |
+
</PanelBody>
|
117 |
</InspectorControls>
|
118 |
);
|
119 |
}
|
assets/js/blocks/products-by-attribute/index.js
CHANGED
@@ -116,6 +116,14 @@ registerBlockType( blockTypeName, {
|
|
116 |
type: 'boolean',
|
117 |
default: false,
|
118 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
},
|
120 |
|
121 |
/**
|
116 |
type: 'boolean',
|
117 |
default: false,
|
118 |
},
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Whether to display in stock, out of stock or backorder products.
|
122 |
+
*/
|
123 |
+
stockStatus: {
|
124 |
+
type: 'array',
|
125 |
+
default: Object.keys( getSetting( 'stockStatusOptions', [] ) ),
|
126 |
+
},
|
127 |
},
|
128 |
|
129 |
/**
|
assets/js/blocks/products/base-utils.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
* The default layout built from the default template.
|
3 |
*/
|
4 |
export const DEFAULT_PRODUCT_LIST_LAYOUT = [
|
5 |
-
[ 'woocommerce/product-image' ],
|
6 |
[ 'woocommerce/product-title' ],
|
7 |
[ 'woocommerce/product-price' ],
|
8 |
[ 'woocommerce/product-rating' ],
|
2 |
* The default layout built from the default template.
|
3 |
*/
|
4 |
export const DEFAULT_PRODUCT_LIST_LAYOUT = [
|
5 |
+
[ 'woocommerce/product-image', { imageSizing: 'cropped' } ],
|
6 |
[ 'woocommerce/product-title' ],
|
7 |
[ 'woocommerce/product-price' ],
|
8 |
[ 'woocommerce/product-rating' ],
|
assets/js/editor-components/feedback-prompt/index.js
CHANGED
@@ -60,3 +60,13 @@ export const CartCheckoutFeedbackPrompt = () => (
|
|
60 |
url="https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues/new?template=--cart-checkout-feedback.md"
|
61 |
/>
|
62 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
url="https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues/new?template=--cart-checkout-feedback.md"
|
61 |
/>
|
62 |
);
|
63 |
+
|
64 |
+
export const LegacyFeedbackPrompt = () => (
|
65 |
+
<FeedbackPrompt
|
66 |
+
text={ __(
|
67 |
+
'We are working on a better editing experience that will replace legacy blocks. Keep an eye out for updates!',
|
68 |
+
'woo-gutenberg-products-block'
|
69 |
+
) }
|
70 |
+
url="https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues/new?template=--legacy-block-feedback.md"
|
71 |
+
/>
|
72 |
+
);
|
assets/js/editor-components/product-stock-control/index.tsx
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* External dependencies
|
3 |
+
*/
|
4 |
+
import { __, sprintf } from '@wordpress/i18n';
|
5 |
+
import { getSetting } from '@woocommerce/settings';
|
6 |
+
import { useCallback, useState, useEffect } from '@wordpress/element';
|
7 |
+
import { ToggleControl } from '@wordpress/components';
|
8 |
+
|
9 |
+
export interface ProductStockControlProps {
|
10 |
+
value: Array< string >;
|
11 |
+
setAttributes: ( attributes: Record< string, unknown > ) => void;
|
12 |
+
}
|
13 |
+
|
14 |
+
// Look up whether or not out of stock items should be hidden globally.
|
15 |
+
const hideOutOfStockItems = getSetting( 'hideOutOfStockItems', false );
|
16 |
+
|
17 |
+
// Get the stock status options.
|
18 |
+
const allStockStatusOptions = getSetting( 'stockStatusOptions', {} );
|
19 |
+
|
20 |
+
/**
|
21 |
+
* A pre-configured SelectControl for product stock settings.
|
22 |
+
*/
|
23 |
+
const ProductStockControl = ( {
|
24 |
+
value,
|
25 |
+
setAttributes,
|
26 |
+
}: ProductStockControlProps ): JSX.Element => {
|
27 |
+
// Determine whether or not to use the out of stock status.
|
28 |
+
const { outofstock, ...otherStockStatusOptions } = allStockStatusOptions;
|
29 |
+
const stockStatusOptions = hideOutOfStockItems
|
30 |
+
? otherStockStatusOptions
|
31 |
+
: allStockStatusOptions;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Valid options must be in an array of [ 'value' : 'mystatus', 'label' : 'My label' ] format.
|
35 |
+
* stockStatusOptions are returned as [ 'mystatus' : 'My label' ].
|
36 |
+
* Formatting is corrected here.
|
37 |
+
*/
|
38 |
+
const displayOptions = Object.entries( stockStatusOptions )
|
39 |
+
.map( ( [ slug, name ] ) => ( { value: slug, label: name } ) )
|
40 |
+
.filter( ( status ) => !! status.label );
|
41 |
+
|
42 |
+
// Set the initial state to the default or saved value.
|
43 |
+
const [ checkedOptions, setChecked ] = useState( value );
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Set attributes when checked items change.
|
47 |
+
* Note: The blank stock status prevents all results returning when all options are unchecked.
|
48 |
+
*/
|
49 |
+
useEffect( () => {
|
50 |
+
setAttributes( {
|
51 |
+
stockStatus: [ '', ...checkedOptions ],
|
52 |
+
} );
|
53 |
+
}, [ checkedOptions, setAttributes ] );
|
54 |
+
|
55 |
+
/**
|
56 |
+
* When a checkbox in the list changes, update state.
|
57 |
+
*/
|
58 |
+
const onChange = useCallback(
|
59 |
+
( checkedValue: string ) => {
|
60 |
+
const previouslyChecked = checkedOptions.includes( checkedValue );
|
61 |
+
|
62 |
+
const newChecked = checkedOptions.filter(
|
63 |
+
( filteredValue ) => filteredValue !== checkedValue
|
64 |
+
);
|
65 |
+
|
66 |
+
if ( ! previouslyChecked ) {
|
67 |
+
newChecked.push( checkedValue );
|
68 |
+
newChecked.sort();
|
69 |
+
}
|
70 |
+
|
71 |
+
setChecked( newChecked );
|
72 |
+
},
|
73 |
+
[ checkedOptions ]
|
74 |
+
);
|
75 |
+
|
76 |
+
return (
|
77 |
+
<>
|
78 |
+
{ displayOptions.map( ( option ) => {
|
79 |
+
const helpText = checkedOptions.includes( option.value )
|
80 |
+
? /* translators: %s stock status. */ __(
|
81 |
+
'Stock status "%s" visible.',
|
82 |
+
'woo-gutenberg-products-block'
|
83 |
+
)
|
84 |
+
: /* translators: %s stock status. */ __(
|
85 |
+
'Stock status "%s" hidden.',
|
86 |
+
'woo-gutenberg-products-block'
|
87 |
+
);
|
88 |
+
return (
|
89 |
+
<ToggleControl
|
90 |
+
label={ option.label }
|
91 |
+
key={ option.value }
|
92 |
+
help={ sprintf( helpText, option.label ) }
|
93 |
+
checked={ checkedOptions.includes( option.value ) }
|
94 |
+
onChange={ () => onChange( option.value ) }
|
95 |
+
/>
|
96 |
+
);
|
97 |
+
} ) }
|
98 |
+
</>
|
99 |
+
);
|
100 |
+
};
|
101 |
+
|
102 |
+
export default ProductStockControl;
|
assets/js/hooks/style-attributes.ts
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* eslint-disable @wordpress/no-unsafe-wp-apis */
|
2 |
+
/**
|
3 |
+
* External dependencies
|
4 |
+
*/
|
5 |
+
import {
|
6 |
+
__experimentalUseColorProps,
|
7 |
+
__experimentalGetSpacingClassesAndStyles,
|
8 |
+
} from '@wordpress/block-editor';
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Internal dependencies
|
12 |
+
*/
|
13 |
+
import { isFeaturePluginBuild } from '../settings/blocks/feature-flags';
|
14 |
+
import { isString, isObject } from '../types/type-guards';
|
15 |
+
import { hasSpacingStyleSupport } from '../utils/global-style';
|
16 |
+
|
17 |
+
type WithClass = {
|
18 |
+
className: string;
|
19 |
+
};
|
20 |
+
|
21 |
+
type WithStyle = {
|
22 |
+
style: Record< string, unknown >;
|
23 |
+
};
|
24 |
+
|
25 |
+
const parseStyle = ( style: unknown ): Record< string, unknown > => {
|
26 |
+
if ( isString( style ) ) {
|
27 |
+
return JSON.parse( style ) || {};
|
28 |
+
}
|
29 |
+
|
30 |
+
if ( isObject( style ) ) {
|
31 |
+
return style;
|
32 |
+
}
|
33 |
+
|
34 |
+
return {};
|
35 |
+
};
|
36 |
+
|
37 |
+
export const useSpacingProps = ( attributes: unknown ): WithStyle => {
|
38 |
+
if ( ! isFeaturePluginBuild() || ! hasSpacingStyleSupport() ) {
|
39 |
+
return {
|
40 |
+
style: {},
|
41 |
+
};
|
42 |
+
}
|
43 |
+
const attributesObject = isObject( attributes ) ? attributes : {};
|
44 |
+
const style = parseStyle( attributesObject.style );
|
45 |
+
|
46 |
+
return __experimentalGetSpacingClassesAndStyles( {
|
47 |
+
...attributesObject,
|
48 |
+
style,
|
49 |
+
} );
|
50 |
+
};
|
51 |
+
|
52 |
+
export const useTypographyProps = ( attributes: unknown ): WithStyle => {
|
53 |
+
const attributesObject = isObject( attributes ) ? attributes : {};
|
54 |
+
const style = parseStyle( attributesObject.style );
|
55 |
+
const typography = isObject( style.typography )
|
56 |
+
? ( style.typography as Record< string, unknown > )
|
57 |
+
: {};
|
58 |
+
|
59 |
+
return {
|
60 |
+
style: {
|
61 |
+
fontSize: attributesObject.fontSize || typography.fontSize,
|
62 |
+
lineHeight: typography.lineHeight,
|
63 |
+
fontWeight: typography.fontWeight,
|
64 |
+
textTransform: typography.textTransform,
|
65 |
+
fontFamily: attributesObject.fontFamily,
|
66 |
+
},
|
67 |
+
};
|
68 |
+
};
|
69 |
+
|
70 |
+
export const useColorProps = ( attributes: unknown ): WithStyle & WithClass => {
|
71 |
+
if ( ! isFeaturePluginBuild() ) {
|
72 |
+
return {
|
73 |
+
className: '',
|
74 |
+
style: {},
|
75 |
+
};
|
76 |
+
}
|
77 |
+
|
78 |
+
const attributesObject = isObject( attributes ) ? attributes : {};
|
79 |
+
const style = parseStyle( attributesObject.style );
|
80 |
+
|
81 |
+
return __experimentalUseColorProps( { ...attributesObject, style } );
|
82 |
+
};
|
assets/js/payment-method-extensions/payment-methods/stripe/credit-card/constants.js
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
export const PAYMENT_METHOD_NAME = 'stripe';
|
|
assets/js/payment-method-extensions/payment-methods/stripe/credit-card/elements.js
DELETED
@@ -1,161 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* External dependencies
|
3 |
-
*/
|
4 |
-
import { useState } from '@wordpress/element';
|
5 |
-
import { __ } from '@wordpress/i18n';
|
6 |
-
import {
|
7 |
-
CardElement,
|
8 |
-
CardNumberElement,
|
9 |
-
CardExpiryElement,
|
10 |
-
CardCvcElement,
|
11 |
-
} from '@stripe/react-stripe-js';
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Internal dependencies
|
15 |
-
*/
|
16 |
-
import { useElementOptions } from './use-element-options';
|
17 |
-
|
18 |
-
/** @typedef {import('react')} React */
|
19 |
-
|
20 |
-
const baseTextInputStyles = 'wc-block-gateway-input';
|
21 |
-
|
22 |
-
/**
|
23 |
-
* InlineCard component
|
24 |
-
*
|
25 |
-
* @param {Object} props Incoming props for the component.
|
26 |
-
* @param {React.ReactElement} props.inputErrorComponent
|
27 |
-
* @param {function(any):any} props.onChange
|
28 |
-
*/
|
29 |
-
export const InlineCard = ( {
|
30 |
-
inputErrorComponent: ValidationInputError,
|
31 |
-
onChange,
|
32 |
-
} ) => {
|
33 |
-
const [ isEmpty, setIsEmpty ] = useState( true );
|
34 |
-
const { options, onActive, error, setError } = useElementOptions( {
|
35 |
-
hidePostalCode: true,
|
36 |
-
} );
|
37 |
-
const errorCallback = ( event ) => {
|
38 |
-
if ( event.error ) {
|
39 |
-
setError( event.error.message );
|
40 |
-
} else {
|
41 |
-
setError( '' );
|
42 |
-
}
|
43 |
-
setIsEmpty( event.empty );
|
44 |
-
onChange( event );
|
45 |
-
};
|
46 |
-
return (
|
47 |
-
<>
|
48 |
-
<div className="wc-block-gateway-container wc-inline-card-element">
|
49 |
-
<CardElement
|
50 |
-
id="wc-stripe-inline-card-element"
|
51 |
-
className={ baseTextInputStyles }
|
52 |
-
options={ options }
|
53 |
-
onBlur={ () => onActive( isEmpty ) }
|
54 |
-
onFocus={ () => onActive( isEmpty ) }
|
55 |
-
onChange={ errorCallback }
|
56 |
-
/>
|
57 |
-
<label htmlFor="wc-stripe-inline-card-element">
|
58 |
-
{ __(
|
59 |
-
'Credit Card Information',
|
60 |
-
'woo-gutenberg-products-block'
|
61 |
-
) }
|
62 |
-
</label>
|
63 |
-
</div>
|
64 |
-
<ValidationInputError errorMessage={ error } />
|
65 |
-
</>
|
66 |
-
);
|
67 |
-
};
|
68 |
-
|
69 |
-
/**
|
70 |
-
* CardElements component.
|
71 |
-
*
|
72 |
-
* @param {Object} props
|
73 |
-
* @param {function(any):any} props.onChange
|
74 |
-
* @param {React.ReactElement} props.inputErrorComponent
|
75 |
-
*/
|
76 |
-
export const CardElements = ( {
|
77 |
-
onChange,
|
78 |
-
inputErrorComponent: ValidationInputError,
|
79 |
-
} ) => {
|
80 |
-
const [ isEmpty, setIsEmpty ] = useState( {
|
81 |
-
cardNumber: true,
|
82 |
-
cardExpiry: true,
|
83 |
-
cardCvc: true,
|
84 |
-
} );
|
85 |
-
const {
|
86 |
-
options: cardNumOptions,
|
87 |
-
onActive: cardNumOnActive,
|
88 |
-
error: cardNumError,
|
89 |
-
setError: cardNumSetError,
|
90 |
-
} = useElementOptions( { showIcon: false } );
|
91 |
-
const {
|
92 |
-
options: cardExpiryOptions,
|
93 |
-
onActive: cardExpiryOnActive,
|
94 |
-
error: cardExpiryError,
|
95 |
-
setError: cardExpirySetError,
|
96 |
-
} = useElementOptions();
|
97 |
-
const {
|
98 |
-
options: cardCvcOptions,
|
99 |
-
onActive: cardCvcOnActive,
|
100 |
-
error: cardCvcError,
|
101 |
-
setError: cardCvcSetError,
|
102 |
-
} = useElementOptions();
|
103 |
-
const errorCallback = ( errorSetter, elementId ) => ( event ) => {
|
104 |
-
if ( event.error ) {
|
105 |
-
errorSetter( event.error.message );
|
106 |
-
} else {
|
107 |
-
errorSetter( '' );
|
108 |
-
}
|
109 |
-
setIsEmpty( { ...isEmpty, [ elementId ]: event.empty } );
|
110 |
-
onChange( event );
|
111 |
-
};
|
112 |
-
return (
|
113 |
-
<div className="wc-block-card-elements">
|
114 |
-
<div className="wc-block-gateway-container wc-card-number-element">
|
115 |
-
<CardNumberElement
|
116 |
-
onChange={ errorCallback( cardNumSetError, 'cardNumber' ) }
|
117 |
-
options={ cardNumOptions }
|
118 |
-
className={ baseTextInputStyles }
|
119 |
-
id="wc-stripe-card-number-element"
|
120 |
-
onFocus={ () => cardNumOnActive( isEmpty.cardNumber ) }
|
121 |
-
onBlur={ () => cardNumOnActive( isEmpty.cardNumber ) }
|
122 |
-
/>
|
123 |
-
<label htmlFor="wc-stripe-card-number-element">
|
124 |
-
{ __( 'Card Number', 'woo-gutenberg-products-block' ) }
|
125 |
-
</label>
|
126 |
-
<ValidationInputError errorMessage={ cardNumError } />
|
127 |
-
</div>
|
128 |
-
<div className="wc-block-gateway-container wc-card-expiry-element">
|
129 |
-
<CardExpiryElement
|
130 |
-
onChange={ errorCallback(
|
131 |
-
cardExpirySetError,
|
132 |
-
'cardExpiry'
|
133 |
-
) }
|
134 |
-
options={ cardExpiryOptions }
|
135 |
-
className={ baseTextInputStyles }
|
136 |
-
onFocus={ () => cardExpiryOnActive( isEmpty.cardExpiry ) }
|
137 |
-
onBlur={ () => cardExpiryOnActive( isEmpty.cardExpiry ) }
|
138 |
-
id="wc-stripe-card-expiry-element"
|
139 |
-
/>
|
140 |
-
<label htmlFor="wc-stripe-card-expiry-element">
|
141 |
-
{ __( 'Expiry Date', 'woo-gutenberg-products-block' ) }
|
142 |
-
</label>
|
143 |
-
<ValidationInputError errorMessage={ cardExpiryError } />
|
144 |
-
</div>
|
145 |
-
<div className="wc-block-gateway-container wc-card-cvc-element">
|
146 |
-
<CardCvcElement
|
147 |
-
onChange={ errorCallback( cardCvcSetError, 'cardCvc' ) }
|
148 |
-
options={ cardCvcOptions }
|
149 |
-
className={ baseTextInputStyles }
|
150 |
-
onFocus={ () => cardCvcOnActive( isEmpty.cardCvc ) }
|
151 |
-
onBlur={ () => cardCvcOnActive( isEmpty.cardCvc ) }
|
152 |
-
id="wc-stripe-card-code-element"
|
153 |
-
/>
|
154 |
-
<label htmlFor="wc-stripe-card-code-element">
|
155 |
-
{ __( 'CVV/CVC', 'woo-gutenberg-products-block' ) }
|
156 |
-
</label>
|
157 |
-
<ValidationInputError errorMessage={ cardCvcError } />
|
158 |
-
</div>
|
159 |
-
</div>
|
160 |
-
);
|
161 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/payment-method-extensions/payment-methods/stripe/credit-card/index.js
DELETED
@@ -1,65 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* External dependencies
|
3 |
-
*/
|
4 |
-
import { __ } from '@wordpress/i18n';
|
5 |
-
import { useEffect, useState } from '@wordpress/element';
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Internal dependencies
|
9 |
-
*/
|
10 |
-
import { getStripeServerData, loadStripe } from '../stripe-utils';
|
11 |
-
import { StripeCreditCard, getStripeCreditCardIcons } from './payment-method';
|
12 |
-
import { PAYMENT_METHOD_NAME } from './constants';
|
13 |
-
|
14 |
-
const stripePromise = loadStripe();
|
15 |
-
|
16 |
-
const StripeComponent = ( props ) => {
|
17 |
-
const [ errorMessage, setErrorMessage ] = useState( '' );
|
18 |
-
|
19 |
-
useEffect( () => {
|
20 |
-
Promise.resolve( stripePromise ).then( ( { error } ) => {
|
21 |
-
if ( error ) {
|
22 |
-
setErrorMessage( error.message );
|
23 |
-
}
|
24 |
-
} );
|
25 |
-
}, [ setErrorMessage ] );
|
26 |
-
|
27 |
-
useEffect( () => {
|
28 |
-
if ( errorMessage ) {
|
29 |
-
throw new Error( errorMessage );
|
30 |
-
}
|
31 |
-
}, [ errorMessage ] );
|
32 |
-
|
33 |
-
return <StripeCreditCard stripe={ stripePromise } { ...props } />;
|
34 |
-
};
|
35 |
-
|
36 |
-
const StripeLabel = ( props ) => {
|
37 |
-
const { PaymentMethodLabel } = props.components;
|
38 |
-
|
39 |
-
const labelText = getStripeServerData().title
|
40 |
-
? getStripeServerData().title
|
41 |
-
: __( 'Credit / Debit Card', 'woo-gutenberg-products-block' );
|
42 |
-
|
43 |
-
return <PaymentMethodLabel text={ labelText } />;
|
44 |
-
};
|
45 |
-
|
46 |
-
const cardIcons = getStripeCreditCardIcons();
|
47 |
-
const stripeCcPaymentMethod = {
|
48 |
-
name: PAYMENT_METHOD_NAME,
|
49 |
-
label: <StripeLabel />,
|
50 |
-
content: <StripeComponent />,
|
51 |
-
edit: <StripeComponent />,
|
52 |
-
icons: cardIcons,
|
53 |
-
canMakePayment: () => stripePromise,
|
54 |
-
ariaLabel: __(
|
55 |
-
'Stripe Credit Card payment method',
|
56 |
-
'woo-gutenberg-products-block'
|
57 |
-
),
|
58 |
-
supports: {
|
59 |
-
showSavedCards: getStripeServerData().showSavedCards,
|
60 |
-
showSaveOption: getStripeServerData().showSaveOption,
|
61 |
-
features: getStripeServerData()?.supports ?? [],
|
62 |
-
},
|
63 |
-
};
|
64 |
-
|
65 |
-
export default stripeCcPaymentMethod;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/payment-method-extensions/payment-methods/stripe/credit-card/payment-method.js
DELETED
@@ -1,92 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* External dependencies
|
3 |
-
*/
|
4 |
-
import { Elements, useStripe } from '@stripe/react-stripe-js';
|
5 |
-
import { useState } from '@wordpress/element';
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Internal dependencies
|
9 |
-
*/
|
10 |
-
import { getStripeServerData } from '../stripe-utils';
|
11 |
-
import { useCheckoutSubscriptions } from './use-checkout-subscriptions';
|
12 |
-
import { InlineCard, CardElements } from './elements';
|
13 |
-
|
14 |
-
/**
|
15 |
-
* @typedef {import('../stripe-utils/type-defs').Stripe} Stripe
|
16 |
-
* @typedef {import('../stripe-utils/type-defs').StripePaymentRequest} StripePaymentRequest
|
17 |
-
* @typedef {import('@woocommerce/type-defs/payment-method-interface').PaymentMethodInterface} RegisteredPaymentMethodProps
|
18 |
-
*/
|
19 |
-
|
20 |
-
export const getStripeCreditCardIcons = () => {
|
21 |
-
return Object.entries( getStripeServerData().icons ).map(
|
22 |
-
( [ id, { src, alt } ] ) => {
|
23 |
-
return {
|
24 |
-
id,
|
25 |
-
src,
|
26 |
-
alt,
|
27 |
-
};
|
28 |
-
}
|
29 |
-
);
|
30 |
-
};
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Stripe Credit Card component
|
34 |
-
*
|
35 |
-
* @param {RegisteredPaymentMethodProps} props Incoming props
|
36 |
-
*/
|
37 |
-
const CreditCardComponent = ( {
|
38 |
-
billing,
|
39 |
-
eventRegistration,
|
40 |
-
emitResponse,
|
41 |
-
components,
|
42 |
-
} ) => {
|
43 |
-
const { ValidationInputError, PaymentMethodIcons } = components;
|
44 |
-
const [ sourceId, setSourceId ] = useState( '' );
|
45 |
-
const stripe = useStripe();
|
46 |
-
const onStripeError = useCheckoutSubscriptions(
|
47 |
-
eventRegistration,
|
48 |
-
billing,
|
49 |
-
sourceId,
|
50 |
-
setSourceId,
|
51 |
-
emitResponse,
|
52 |
-
stripe
|
53 |
-
);
|
54 |
-
const onChange = ( paymentEvent ) => {
|
55 |
-
if ( paymentEvent.error ) {
|
56 |
-
onStripeError( paymentEvent );
|
57 |
-
}
|
58 |
-
setSourceId( '0' );
|
59 |
-
};
|
60 |
-
const cardIcons = getStripeCreditCardIcons();
|
61 |
-
|
62 |
-
const renderedCardElement = getStripeServerData().inline_cc_form ? (
|
63 |
-
<InlineCard
|
64 |
-
onChange={ onChange }
|
65 |
-
inputErrorComponent={ ValidationInputError }
|
66 |
-
/>
|
67 |
-
) : (
|
68 |
-
<CardElements
|
69 |
-
onChange={ onChange }
|
70 |
-
inputErrorComponent={ ValidationInputError }
|
71 |
-
/>
|
72 |
-
);
|
73 |
-
return (
|
74 |
-
<>
|
75 |
-
{ renderedCardElement }
|
76 |
-
{ PaymentMethodIcons && cardIcons.length && (
|
77 |
-
<PaymentMethodIcons icons={ cardIcons } align="left" />
|
78 |
-
) }
|
79 |
-
</>
|
80 |
-
);
|
81 |
-
};
|
82 |
-
|
83 |
-
export const StripeCreditCard = ( props ) => {
|
84 |
-
const { locale } = getStripeServerData().button;
|
85 |
-
const { stripe } = props;
|
86 |
-
|
87 |
-
return (
|
88 |
-
<Elements stripe={ stripe } locale={ locale }>
|
89 |
-
<CreditCardComponent { ...props } />
|
90 |
-
</Elements>
|
91 |
-
);
|
92 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/payment-method-extensions/payment-methods/stripe/credit-card/use-checkout-subscriptions.js
DELETED
@@ -1,97 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* External dependencies
|
3 |
-
*/
|
4 |
-
import { useEffect, useCallback, useState } from '@wordpress/element';
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Internal dependencies
|
8 |
-
*/
|
9 |
-
import { getErrorMessageForTypeAndCode } from '../stripe-utils';
|
10 |
-
import { usePaymentIntents } from './use-payment-intents';
|
11 |
-
import { usePaymentProcessing } from './use-payment-processing';
|
12 |
-
|
13 |
-
/**
|
14 |
-
* @typedef {import('@woocommerce/type-defs/payment-method-interface').EventRegistrationProps} EventRegistrationProps
|
15 |
-
* @typedef {import('@woocommerce/type-defs/payment-method-interface').BillingDataProps} BillingDataProps
|
16 |
-
* @typedef {import('@woocommerce/type-defs/payment-method-interface').EmitResponseProps} EmitResponseProps
|
17 |
-
* @typedef {import('../stripe-utils/type-defs').Stripe} Stripe
|
18 |
-
* @typedef {import('react').Dispatch<string>} SourceIdDispatch
|
19 |
-
*/
|
20 |
-
|
21 |
-
/**
|
22 |
-
* A custom hook for the Stripe processing and event observer logic.
|
23 |
-
*
|
24 |
-
* @param {EventRegistrationProps} eventRegistration Event registration functions.
|
25 |
-
* @param {BillingDataProps} billing Various billing data items.
|
26 |
-
* @param {string} sourceId Current set stripe source id.
|
27 |
-
* @param {SourceIdDispatch} setSourceId Setter for stripe source id.
|
28 |
-
* @param {EmitResponseProps} emitResponse Various helpers for usage with observer
|
29 |
-
* response objects.
|
30 |
-
* @param {Stripe} stripe The stripe.js object.
|
31 |
-
*
|
32 |
-
* @return {function(Object):Object} Returns a function for handling stripe error.
|
33 |
-
*/
|
34 |
-
export const useCheckoutSubscriptions = (
|
35 |
-
eventRegistration,
|
36 |
-
billing,
|
37 |
-
sourceId,
|
38 |
-
setSourceId,
|
39 |
-
emitResponse,
|
40 |
-
stripe
|
41 |
-
) => {
|
42 |
-
const [ error, setError ] = useState( '' );
|
43 |
-
const onStripeError = useCallback( ( event ) => {
|
44 |
-
const type = event.error.type;
|
45 |
-
const code = event.error.code || '';
|
46 |
-
const message =
|
47 |
-
getErrorMessageForTypeAndCode( type, code ) ?? event.error.message;
|
48 |
-
setError( message );
|
49 |
-
return message;
|
50 |
-
}, [] );
|
51 |
-
const {
|
52 |
-
onCheckoutAfterProcessingWithSuccess,
|
53 |
-
onPaymentProcessing,
|
54 |
-
onCheckoutAfterProcessingWithError,
|
55 |
-
} = eventRegistration;
|
56 |
-
usePaymentIntents(
|
57 |
-
stripe,
|
58 |
-
onCheckoutAfterProcessingWithSuccess,
|
59 |
-
setSourceId,
|
60 |
-
emitResponse
|
61 |
-
);
|
62 |
-
usePaymentProcessing(
|
63 |
-
onStripeError,
|
64 |
-
error,
|
65 |
-
stripe,
|
66 |
-
billing,
|
67 |
-
emitResponse,
|
68 |
-
sourceId,
|
69 |
-
setSourceId,
|
70 |
-
onPaymentProcessing
|
71 |
-
);
|
72 |
-
// hook into and register callbacks for events.
|
73 |
-
useEffect( () => {
|
74 |
-
const onError = ( { processingResponse } ) => {
|
75 |
-
if ( processingResponse?.paymentDetails?.errorMessage ) {
|
76 |
-
return {
|
77 |
-
type: emitResponse.responseTypes.ERROR,
|
78 |
-
message: processingResponse.paymentDetails.errorMessage,
|
79 |
-
messageContext: emitResponse.noticeContexts.PAYMENTS,
|
80 |
-
};
|
81 |
-
}
|
82 |
-
// so we don't break the observers.
|
83 |
-
return true;
|
84 |
-
};
|
85 |
-
const unsubscribeAfterProcessing = onCheckoutAfterProcessingWithError(
|
86 |
-
onError
|
87 |
-
);
|
88 |
-
return () => {
|
89 |
-
unsubscribeAfterProcessing();
|
90 |
-
};
|
91 |
-
}, [
|
92 |
-
onCheckoutAfterProcessingWithError,
|
93 |
-
emitResponse.noticeContexts.PAYMENTS,
|
94 |
-
emitResponse.responseTypes.ERROR,
|
95 |
-
] );
|
96 |
-
return onStripeError;
|
97 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/payment-method-extensions/payment-methods/stripe/credit-card/use-element-options.js
DELETED
@@ -1,115 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* External dependencies
|
3 |
-
*/
|
4 |
-
import { useState, useEffect, useCallback } from '@wordpress/element';
|
5 |
-
|
6 |
-
/**
|
7 |
-
* @typedef {import('../stripe-utils/type-defs').StripeElementOptions} StripeElementOptions
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Returns the value of a specific CSS property for the element matched by the provided selector.
|
12 |
-
*
|
13 |
-
* @param {string} selector CSS selector that matches the element to query.
|
14 |
-
* @param {string} property Name of the property to retrieve the style
|
15 |
-
* value from.
|
16 |
-
* @param {string} defaultValue Fallback value if the value for the property
|
17 |
-
* could not be retrieved.
|
18 |
-
*
|
19 |
-
* @return {string} The style value of that property in the document element.
|
20 |
-
*/
|
21 |
-
const getComputedStyle = ( selector, property, defaultValue ) => {
|
22 |
-
let elementStyle = {};
|
23 |
-
|
24 |
-
if (
|
25 |
-
typeof document === 'object' &&
|
26 |
-
typeof document.querySelector === 'function' &&
|
27 |
-
typeof window.getComputedStyle === 'function'
|
28 |
-
) {
|
29 |
-
const element = document.querySelector( selector );
|
30 |
-
if ( element ) {
|
31 |
-
elementStyle = window.getComputedStyle( element );
|
32 |
-
}
|
33 |
-
}
|
34 |
-
|
35 |
-
return elementStyle[ property ] || defaultValue;
|
36 |
-
};
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Default options for the stripe elements.
|
40 |
-
*/
|
41 |
-
const elementOptions = {
|
42 |
-
style: {
|
43 |
-
base: {
|
44 |
-
iconColor: '#666EE8',
|
45 |
-
color: '#31325F',
|
46 |
-
fontSize: getComputedStyle(
|
47 |
-
'.wc-block-checkout',
|
48 |
-
'fontSize',
|
49 |
-
'16px'
|
50 |
-
),
|
51 |
-
lineHeight: 1.375, // With a font-size of 16px, line-height will be 22px.
|
52 |
-
'::placeholder': {
|
53 |
-
color: '#fff',
|
54 |
-
},
|
55 |
-
},
|
56 |
-
},
|
57 |
-
classes: {
|
58 |
-
focus: 'focused',
|
59 |
-
empty: 'empty',
|
60 |
-
invalid: 'has-error',
|
61 |
-
},
|
62 |
-
};
|
63 |
-
|
64 |
-
/**
|
65 |
-
* A custom hook handling options implemented on the stripe elements.
|
66 |
-
*
|
67 |
-
* @param {Object} [overloadedOptions] An array of extra options to merge with
|
68 |
-
* the options provided for the element.
|
69 |
-
*
|
70 |
-
* @return {StripeElementOptions} The stripe element options interface
|
71 |
-
*/
|
72 |
-
export const useElementOptions = ( overloadedOptions ) => {
|
73 |
-
const [ isActive, setIsActive ] = useState( false );
|
74 |
-
const [ options, setOptions ] = useState( {
|
75 |
-
...elementOptions,
|
76 |
-
...overloadedOptions,
|
77 |
-
} );
|
78 |
-
const [ error, setError ] = useState( '' );
|
79 |
-
|
80 |
-
useEffect( () => {
|
81 |
-
const color = isActive ? '#CFD7E0' : '#fff';
|
82 |
-
|
83 |
-
setOptions( ( prevOptions ) => {
|
84 |
-
const showIcon =
|
85 |
-
typeof prevOptions.showIcon !== 'undefined'
|
86 |
-
? { showIcon: isActive }
|
87 |
-
: {};
|
88 |
-
return {
|
89 |
-
...prevOptions,
|
90 |
-
style: {
|
91 |
-
...prevOptions.style,
|
92 |
-
base: {
|
93 |
-
...prevOptions.style.base,
|
94 |
-
'::placeholder': {
|
95 |
-
color,
|
96 |
-
},
|
97 |
-
},
|
98 |
-
},
|
99 |
-
...showIcon,
|
100 |
-
};
|
101 |
-
} );
|
102 |
-
}, [ isActive ] );
|
103 |
-
|
104 |
-
const onActive = useCallback(
|
105 |
-
( isEmpty ) => {
|
106 |
-
if ( ! isEmpty ) {
|
107 |
-
setIsActive( true );
|
108 |
-
} else {
|
109 |
-
setIsActive( ( prevActive ) => ! prevActive );
|
110 |
-
}
|
111 |
-
},
|
112 |
-
[ setIsActive ]
|
113 |
-
);
|
114 |
-
return { options, onActive, error, setError };
|
115 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/payment-method-extensions/payment-methods/stripe/credit-card/use-payment-intents.js
DELETED
@@ -1,104 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* External dependencies
|
3 |
-
*/
|
4 |
-
import { useEffect } from '@wordpress/element';
|
5 |
-
|
6 |
-
/**
|
7 |
-
* @typedef {import('@woocommerce/type-defs/payment-method-interface').EmitResponseProps} EmitResponseProps
|
8 |
-
* @typedef {import('../stripe-utils/type-defs').Stripe} Stripe
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Opens the modal for PaymentIntent authorizations.
|
13 |
-
*
|
14 |
-
* @param {Object} params Params object.
|
15 |
-
* @param {Stripe} params.stripe The stripe object.
|
16 |
-
* @param {Object} params.paymentDetails The payment details from the
|
17 |
-
* server after checkout processing.
|
18 |
-
* @param {string} params.errorContext Context where errors will be added.
|
19 |
-
* @param {string} params.errorType Type of error responses.
|
20 |
-
* @param {string} params.successType Type of success responses.
|
21 |
-
*/
|
22 |
-
const openIntentModal = ( {
|
23 |
-
stripe,
|
24 |
-
paymentDetails,
|
25 |
-
errorContext,
|
26 |
-
errorType,
|
27 |
-
successType,
|
28 |
-
} ) => {
|
29 |
-
const checkoutResponse = { type: successType };
|
30 |
-
if (
|
31 |
-
! paymentDetails.setup_intent &&
|
32 |
-
! paymentDetails.payment_intent_secret
|
33 |
-
) {
|
34 |
-
return checkoutResponse;
|
35 |
-
}
|
36 |
-
const isSetupIntent = !! paymentDetails.setupIntent;
|
37 |
-
const verificationUrl = paymentDetails.verification_endpoint;
|
38 |
-
const intentSecret = isSetupIntent
|
39 |
-
? paymentDetails.setup_intent
|
40 |
-
: paymentDetails.payment_intent_secret;
|
41 |
-
return stripe[ isSetupIntent ? 'confirmCardSetup' : 'confirmCardPayment' ](
|
42 |
-
intentSecret
|
43 |
-
)
|
44 |
-
.then( function ( response ) {
|
45 |
-
if ( response.error ) {
|
46 |
-
throw response.error;
|
47 |
-
}
|
48 |
-
const intent =
|
49 |
-
response[ isSetupIntent ? 'setupIntent' : 'paymentIntent' ];
|
50 |
-
if (
|
51 |
-
intent.status !== 'requires_capture' &&
|
52 |
-
intent.status !== 'succeeded'
|
53 |
-
) {
|
54 |
-
return checkoutResponse;
|
55 |
-
}
|
56 |
-
checkoutResponse.redirectUrl = verificationUrl;
|
57 |
-
return checkoutResponse;
|
58 |
-
} )
|
59 |
-
.catch( function ( error ) {
|
60 |
-
checkoutResponse.type = errorType;
|
61 |
-
checkoutResponse.message = error.message;
|
62 |
-
checkoutResponse.retry = true;
|
63 |
-
checkoutResponse.messageContext = errorContext;
|
64 |
-
// Reports back to the server.
|
65 |
-
window.fetch( verificationUrl + '&is_ajax' );
|
66 |
-
return checkoutResponse;
|
67 |
-
} );
|
68 |
-
};
|
69 |
-
|
70 |
-
export const usePaymentIntents = (
|
71 |
-
stripe,
|
72 |
-
subscriber,
|
73 |
-
setSourceId,
|
74 |
-
emitResponse
|
75 |
-
) => {
|
76 |
-
useEffect( () => {
|
77 |
-
const unsubscribe = subscriber( async ( { processingResponse } ) => {
|
78 |
-
const paymentDetails = processingResponse.paymentDetails || {};
|
79 |
-
const response = await openIntentModal( {
|
80 |
-
stripe,
|
81 |
-
paymentDetails,
|
82 |
-
errorContext: emitResponse.noticeContexts.PAYMENTS,
|
83 |
-
errorType: emitResponse.responseTypes.ERROR,
|
84 |
-
successType: emitResponse.responseTypes.SUCCESS,
|
85 |
-
} );
|
86 |
-
if (
|
87 |
-
response.type === emitResponse.responseTypes.ERROR &&
|
88 |
-
response.retry
|
89 |
-
) {
|
90 |
-
setSourceId( '0' );
|
91 |
-
}
|
92 |
-
|
93 |
-
return response;
|
94 |
-
} );
|
95 |
-
return () => unsubscribe();
|
96 |
-
}, [
|
97 |
-
subscriber,
|
98 |
-
emitResponse.noticeContexts.PAYMENTS,
|
99 |
-
emitResponse.responseTypes.ERROR,
|
100 |
-
emitResponse.responseTypes.SUCCESS,
|
101 |
-
setSourceId,
|
102 |
-
stripe,
|
103 |
-
] );
|
104 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/payment-method-extensions/payment-methods/stripe/credit-card/use-payment-processing.js
DELETED
@@ -1,166 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* External dependencies
|
3 |
-
*/
|
4 |
-
import { useEffect } from '@wordpress/element';
|
5 |
-
import {
|
6 |
-
CardElement,
|
7 |
-
CardNumberElement,
|
8 |
-
useElements,
|
9 |
-
} from '@stripe/react-stripe-js';
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Internal dependencies
|
13 |
-
*/
|
14 |
-
import { PAYMENT_METHOD_NAME } from './constants';
|
15 |
-
import {
|
16 |
-
getStripeServerData,
|
17 |
-
getErrorMessageForTypeAndCode,
|
18 |
-
} from '../stripe-utils';
|
19 |
-
import { errorTypes } from '../stripe-utils/constants';
|
20 |
-
|
21 |
-
/**
|
22 |
-
* @typedef {import('@stripe/stripe-js').Stripe} Stripe
|
23 |
-
* @typedef {import('@woocommerce/type-defs/payment-method-interface').EventRegistrationProps} EventRegistrationProps
|
24 |
-
* @typedef {import('@woocommerce/type-defs/payment-method-interface').BillingDataProps} BillingDataProps
|
25 |
-
* @typedef {import('@woocommerce/type-defs/payment-method-interface').EmitResponseProps} EmitResponseProps
|
26 |
-
* @typedef {import('react').Dispatch<string>} SourceIdDispatch
|
27 |
-
*/
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @typedef {function(function():any):function():void} EventRegistration
|
31 |
-
*/
|
32 |
-
|
33 |
-
/**
|
34 |
-
* A custom hook that registers stripe payment processing with the
|
35 |
-
* onPaymentProcessing event from checkout.
|
36 |
-
*
|
37 |
-
* @param {function(any):string} onStripeError Sets an error for stripe.
|
38 |
-
* @param {string} error Any set error message (an empty string if no
|
39 |
-
* error).
|
40 |
-
* @param {Stripe} stripe The stripe utility
|
41 |
-
* @param {BillingDataProps} billing Various billing data items.
|
42 |
-
* @param {EmitResponseProps} emitResponse Various helpers for usage with observer
|
43 |
-
* response objects.
|
44 |
-
* @param {string} sourceId Current set stripe source id.
|
45 |
-
* @param {SourceIdDispatch} setSourceId Setter for stripe source id.
|
46 |
-
* @param {EventRegistration} onPaymentProcessing The event emitter for processing payment.
|
47 |
-
*/
|
48 |
-
export const usePaymentProcessing = (
|
49 |
-
onStripeError,
|
50 |
-
error,
|
51 |
-
stripe,
|
52 |
-
billing,
|
53 |
-
emitResponse,
|
54 |
-
sourceId,
|
55 |
-
setSourceId,
|
56 |
-
onPaymentProcessing
|
57 |
-
) => {
|
58 |
-
const elements = useElements();
|
59 |
-
// hook into and register callbacks for events
|
60 |
-
useEffect( () => {
|
61 |
-
const createSource = async ( ownerInfo ) => {
|
62 |
-
const elementToGet = getStripeServerData().inline_cc_form
|
63 |
-
? CardElement
|
64 |
-
: CardNumberElement;
|
65 |
-
return await stripe.createSource(
|
66 |
-
// @ts-ignore
|
67 |
-
elements?.getElement( elementToGet ),
|
68 |
-
{
|
69 |
-
type: 'card',
|
70 |
-
owner: ownerInfo,
|
71 |
-
}
|
72 |
-
);
|
73 |
-
};
|
74 |
-
const onSubmit = async () => {
|
75 |
-
try {
|
76 |
-
const billingData = billing.billingData;
|
77 |
-
// if there's an error return that.
|
78 |
-
if ( error ) {
|
79 |
-
return {
|
80 |
-
type: emitResponse.responseTypes.ERROR,
|
81 |
-
message: error,
|
82 |
-
};
|
83 |
-
}
|
84 |
-
// use token if it's set.
|
85 |
-
if ( sourceId !== '' && sourceId !== '0' ) {
|
86 |
-
return {
|
87 |
-
type: emitResponse.responseTypes.SUCCESS,
|
88 |
-
meta: {
|
89 |
-
paymentMethodData: {
|
90 |
-
paymentMethod: PAYMENT_METHOD_NAME,
|
91 |
-
paymentRequestType: 'cc',
|
92 |
-
stripe_source: sourceId,
|
93 |
-
},
|
94 |
-
billingData,
|
95 |
-
},
|
96 |
-
};
|
97 |
-
}
|
98 |
-
const ownerInfo = {
|
99 |
-
address: {
|
100 |
-
line1: billingData.address_1,
|
101 |
-
line2: billingData.address_2,
|
102 |
-
city: billingData.city,
|
103 |
-
state: billingData.state,
|
104 |
-
postal_code: billingData.postcode,
|
105 |
-
country: billingData.country,
|
106 |
-
},
|
107 |
-
};
|
108 |
-
if ( billingData.phone ) {
|
109 |
-
ownerInfo.phone = billingData.phone;
|
110 |
-
}
|
111 |
-
if ( billingData.email ) {
|
112 |
-
ownerInfo.email = billingData.email;
|
113 |
-
}
|
114 |
-
if ( billingData.first_name || billingData.last_name ) {
|
115 |
-
ownerInfo.name = `${ billingData.first_name } ${ billingData.last_name }`;
|
116 |
-
}
|
117 |
-
|
118 |
-
const response = await createSource( ownerInfo );
|
119 |
-
if ( response.error ) {
|
120 |
-
return {
|
121 |
-
type: emitResponse.responseTypes.ERROR,
|
122 |
-
message: onStripeError( response ),
|
123 |
-
};
|
124 |
-
}
|
125 |
-
if ( ! response.source || ! response.source.id ) {
|
126 |
-
throw new Error(
|
127 |
-
getErrorMessageForTypeAndCode( errorTypes.API_ERROR )
|
128 |
-
);
|
129 |
-
}
|
130 |
-
setSourceId( response.source.id );
|
131 |
-
return {
|
132 |
-
type: emitResponse.responseTypes.SUCCESS,
|
133 |
-
meta: {
|
134 |
-
paymentMethodData: {
|
135 |
-
stripe_source: response.source.id,
|
136 |
-
paymentMethod: PAYMENT_METHOD_NAME,
|
137 |
-
paymentRequestType: 'cc',
|
138 |
-
},
|
139 |
-
billingData,
|
140 |
-
},
|
141 |
-
};
|
142 |
-
} catch ( e ) {
|
143 |
-
return {
|
144 |
-
type: emitResponse.responseTypes.ERROR,
|
145 |
-
message: e,
|
146 |
-
};
|
147 |
-
}
|
148 |
-
};
|
149 |
-
const unsubscribeProcessing = onPaymentProcessing( onSubmit );
|
150 |
-
return () => {
|
151 |
-
unsubscribeProcessing();
|
152 |
-
};
|
153 |
-
}, [
|
154 |
-
onPaymentProcessing,
|
155 |
-
billing.billingData,
|
156 |
-
stripe,
|
157 |
-
sourceId,
|
158 |
-
setSourceId,
|
159 |
-
onStripeError,
|
160 |
-
error,
|
161 |
-
emitResponse.noticeContexts.PAYMENTS,
|
162 |
-
emitResponse.responseTypes.ERROR,
|
163 |
-
emitResponse.responseTypes.SUCCESS,
|
164 |
-
elements,
|
165 |
-
] );
|
166 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/payment-method-extensions/payment-methods/stripe/index.js
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* External dependencies
|
3 |
-
*/
|
4 |
-
import {
|
5 |
-
registerPaymentMethod,
|
6 |
-
registerExpressPaymentMethod,
|
7 |
-
} from '@woocommerce/blocks-registry';
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Internal dependencies
|
11 |
-
*/
|
12 |
-
import stripeCcPaymentMethod from './credit-card';
|
13 |
-
import paymentRequestPaymentMethod from './payment-request';
|
14 |
-
import { getStripeServerData } from './stripe-utils';
|
15 |
-
|
16 |
-
// Register Stripe Credit Card.
|
17 |
-
registerPaymentMethod( stripeCcPaymentMethod );
|
18 |
-
|
19 |
-
// Register Stripe Payment Request (Apple/Chrome Pay) if enabled.
|
20 |
-
if ( getStripeServerData().allowPaymentRequest ) {
|
21 |
-
registerExpressPaymentMethod( paymentRequestPaymentMethod );
|
22 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/payment-method-extensions/payment-methods/stripe/payment-request/apple-pay-preview.js
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
export const applePayImage =
|
2 |
-
"data:image/svg+xml,%3Csvg width='264' height='48' viewBox='0 0 264 48' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='264' height='48' rx='3' fill='black'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M125.114 16.6407C125.682 15.93 126.067 14.9756 125.966 14C125.135 14.0415 124.121 14.549 123.533 15.2602C123.006 15.8693 122.539 16.8641 122.661 17.7983C123.594 17.8797 124.526 17.3317 125.114 16.6407Z' fill='white'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M125.955 17.982C124.601 17.9011 123.448 18.7518 122.801 18.7518C122.154 18.7518 121.163 18.0224 120.092 18.0421C118.696 18.0629 117.402 18.8524 116.694 20.1079C115.238 22.6196 116.31 26.3453 117.726 28.3909C118.414 29.4028 119.242 30.5174 120.334 30.4769C121.366 30.4365 121.77 29.8087 123.024 29.8087C124.277 29.8087 124.641 30.4769 125.733 30.4567C126.865 30.4365 127.573 29.4443 128.261 28.4313C129.049 27.2779 129.373 26.1639 129.393 26.1027C129.373 26.0825 127.209 25.2515 127.189 22.7606C127.169 20.6751 128.888 19.6834 128.969 19.6217C127.998 18.1847 126.481 18.0224 125.955 17.982Z' fill='white'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M136.131 23.1804H138.834C140.886 23.1804 142.053 22.0752 142.053 20.1592C142.053 18.2432 140.886 17.1478 138.845 17.1478H136.131V23.1804ZM139.466 15.1582C142.411 15.1582 144.461 17.1903 144.461 20.1483C144.461 23.1172 142.369 25.1596 139.392 25.1596H136.131V30.3498H133.775V15.1582H139.466Z' fill='white'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152.198 26.224V25.3712L149.579 25.5397C148.106 25.6341 147.339 26.182 147.339 27.14C147.339 28.0664 148.138 28.6667 149.39 28.6667C150.988 28.6667 152.198 27.6449 152.198 26.224ZM145.046 27.2032C145.046 25.2551 146.529 24.1395 149.263 23.971L152.198 23.7922V22.9498C152.198 21.7181 151.388 21.0442 149.947 21.0442C148.758 21.0442 147.896 21.6548 147.717 22.5916H145.592C145.656 20.6232 147.507 19.1914 150.01 19.1914C152.703 19.1914 154.459 20.602 154.459 22.7917V30.351H152.282V28.5298H152.229C151.609 29.719 150.241 30.4666 148.758 30.4666C146.571 30.4666 145.046 29.1612 145.046 27.2032Z' fill='white'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M156.461 34.4145V32.5934C156.608 32.6141 156.965 32.6354 157.155 32.6354C158.196 32.6354 158.785 32.1932 159.142 31.0564L159.353 30.3824L155.366 19.3281H157.827L160.604 28.298H160.657L163.434 19.3281H165.832L161.698 30.9402C160.752 33.6038 159.668 34.4778 157.376 34.4778C157.197 34.4778 156.618 34.4565 156.461 34.4145Z' fill='white'/%3E%3C/svg%3E%0A";
|
|
|
|
assets/js/payment-method-extensions/payment-methods/stripe/payment-request/constants.js
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
export const PAYMENT_METHOD_NAME = 'payment_request';
|
2 |
-
|
3 |
-
export const DEFAULT_STRIPE_EVENT_HANDLERS = {
|
4 |
-
shippingAddressChange: null,
|
5 |
-
shippingOptionChange: null,
|
6 |
-
source: null,
|
7 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/payment-method-extensions/payment-methods/stripe/payment-request/index.js
DELETED
@@ -1,76 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* External dependencies
|
3 |
-
*/
|
4 |
-
import { getSetting } from '@woocommerce/settings';
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Internal dependencies
|
8 |
-
*/
|
9 |
-
import { PAYMENT_METHOD_NAME } from './constants';
|
10 |
-
import { PaymentRequestExpress } from './payment-request-express';
|
11 |
-
import { applePayImage } from './apple-pay-preview';
|
12 |
-
import { getStripeServerData, loadStripe } from '../stripe-utils';
|
13 |
-
|
14 |
-
const ApplePayPreview = () => <img src={ applePayImage } alt="" />;
|
15 |
-
|
16 |
-
const canPayStripePromise = loadStripe();
|
17 |
-
const componentStripePromise = loadStripe();
|
18 |
-
|
19 |
-
let isStripeInitialized = false,
|
20 |
-
canPay = false;
|
21 |
-
|
22 |
-
// Initialise stripe API client and determine if payment method can be used
|
23 |
-
// in current environment (e.g. geo + shopper has payment settings configured).
|
24 |
-
function paymentRequestAvailable( { currencyCode, totalPrice } ) {
|
25 |
-
// Stripe only supports carts of greater value than 30 cents.
|
26 |
-
if ( totalPrice < 30 ) {
|
27 |
-
return false;
|
28 |
-
}
|
29 |
-
|
30 |
-
// If we've already initialised, return the cached results.
|
31 |
-
if ( isStripeInitialized ) {
|
32 |
-
return canPay;
|
33 |
-
}
|
34 |
-
|
35 |
-
return canPayStripePromise.then( ( stripe ) => {
|
36 |
-
if ( stripe === null ) {
|
37 |
-
isStripeInitialized = true;
|
38 |
-
return canPay;
|
39 |
-
}
|
40 |
-
if ( stripe.error && stripe.error instanceof Error ) {
|
41 |
-
throw stripe.error;
|
42 |
-
}
|
43 |
-
// Do a test payment to confirm if payment method is available.
|
44 |
-
const paymentRequest = stripe.paymentRequest( {
|
45 |
-
total: {
|
46 |
-
label: 'Total',
|
47 |
-
amount: totalPrice,
|
48 |
-
pending: true,
|
49 |
-
},
|
50 |
-
country: getSetting( 'baseLocation', {} )?.country,
|
51 |
-
currency: currencyCode,
|
52 |
-
} );
|
53 |
-
return paymentRequest.canMakePayment().then( ( result ) => {
|
54 |
-
canPay = !! result;
|
55 |
-
isStripeInitialized = true;
|
56 |
-
return canPay;
|
57 |
-
} );
|
58 |
-
} );
|
59 |
-
}
|
60 |
-
|
61 |
-
const paymentRequestPaymentMethod = {
|
62 |
-
name: PAYMENT_METHOD_NAME,
|
63 |
-
content: <PaymentRequestExpress stripe={ componentStripePromise } />,
|
64 |
-
edit: <ApplePayPreview />,
|
65 |
-
canMakePayment: ( cartData ) =>
|
66 |
-
paymentRequestAvailable( {
|
67 |
-
currencyCode: cartData?.cartTotals?.currency_code?.toLowerCase(),
|
68 |
-
totalPrice: parseInt( cartData?.cartTotals?.total_price || 0, 10 ),
|
69 |
-
} ),
|
70 |
-
paymentMethodId: 'stripe',
|
71 |
-
supports: {
|
72 |
-
features: getStripeServerData()?.supports ?? [],
|
73 |
-
},
|
74 |
-
};
|
75 |
-
|
76 |
-
export default paymentRequestPaymentMethod;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/payment-method-extensions/payment-methods/stripe/payment-request/payment-request-express.js
DELETED
@@ -1,113 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* External dependencies
|
3 |
-
*/
|
4 |
-
import { Elements, PaymentRequestButtonElement } from '@stripe/react-stripe-js';
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Internal dependencies
|
8 |
-
*/
|
9 |
-
import { getStripeServerData } from '../stripe-utils';
|
10 |
-
import { useInitialization } from './use-initialization';
|
11 |
-
import { useCheckoutSubscriptions } from './use-checkout-subscriptions';
|
12 |
-
|
13 |
-
/**
|
14 |
-
* @typedef {import('../stripe-utils/type-defs').Stripe} Stripe
|
15 |
-
* @typedef {import('../stripe-utils/type-defs').StripePaymentRequest} StripePaymentRequest
|
16 |
-
* @typedef {import('@woocommerce/type-defs/payment-method-interface').PaymentMethodInterface} RegisteredPaymentMethodProps
|
17 |
-
*/
|
18 |
-
|
19 |
-
/**
|
20 |
-
* @typedef {Object} WithStripe
|
21 |
-
*
|
22 |
-
* @property {Stripe} [stripe] Stripe api (might not be present)
|
23 |
-
*/
|
24 |
-
|
25 |
-
/**
|
26 |
-
* @typedef {RegisteredPaymentMethodProps & WithStripe} StripeRegisteredPaymentMethodProps
|
27 |
-
*/
|
28 |
-
|
29 |
-
/**
|
30 |
-
* PaymentRequestExpressComponent
|
31 |
-
*
|
32 |
-
* @param {StripeRegisteredPaymentMethodProps} props Incoming props
|
33 |
-
*/
|
34 |
-
const PaymentRequestExpressComponent = ( {
|
35 |
-
shippingData,
|
36 |
-
billing,
|
37 |
-
eventRegistration,
|
38 |
-
onSubmit,
|
39 |
-
setExpressPaymentError,
|
40 |
-
emitResponse,
|
41 |
-
onClick,
|
42 |
-
onClose,
|
43 |
-
} ) => {
|
44 |
-
const {
|
45 |
-
paymentRequest,
|
46 |
-
paymentRequestEventHandlers,
|
47 |
-
clearPaymentRequestEventHandler,
|
48 |
-
isProcessing,
|
49 |
-
canMakePayment,
|
50 |
-
onButtonClick,
|
51 |
-
abortPayment,
|
52 |
-
completePayment,
|
53 |
-
paymentRequestType,
|
54 |
-
} = useInitialization( {
|
55 |
-
billing,
|
56 |
-
shippingData,
|
57 |
-
setExpressPaymentError,
|
58 |
-
onClick,
|
59 |
-
onClose,
|
60 |
-
onSubmit,
|
61 |
-
} );
|
62 |
-
useCheckoutSubscriptions( {
|
63 |
-
canMakePayment,
|
64 |
-
isProcessing,
|
65 |
-
eventRegistration,
|
66 |
-
paymentRequestEventHandlers,
|
67 |
-
clearPaymentRequestEventHandler,
|
68 |
-
billing,
|
69 |
-
shippingData,
|
70 |
-
emitResponse,
|
71 |
-
paymentRequestType,
|
72 |
-
completePayment,
|
73 |
-
abortPayment,
|
74 |
-
} );
|
75 |
-
|
76 |
-
// locale is not a valid value for the paymentRequestButton style.
|
77 |
-
const { theme } = getStripeServerData().button;
|
78 |
-
|
79 |
-
const paymentRequestButtonStyle = {
|
80 |
-
paymentRequestButton: {
|
81 |
-
type: 'default',
|
82 |
-
theme,
|
83 |
-
height: '48px',
|
84 |
-
},
|
85 |
-
};
|
86 |
-
|
87 |
-
return canMakePayment && paymentRequest ? (
|
88 |
-
<PaymentRequestButtonElement
|
89 |
-
onClick={ onButtonClick }
|
90 |
-
options={ {
|
91 |
-
// @ts-ignore
|
92 |
-
style: paymentRequestButtonStyle,
|
93 |
-
// @ts-ignore
|
94 |
-
paymentRequest,
|
95 |
-
} }
|
96 |
-
/>
|
97 |
-
) : null;
|
98 |
-
};
|
99 |
-
|
100 |
-
/**
|
101 |
-
* PaymentRequestExpress with stripe provider
|
102 |
-
*
|
103 |
-
* @param {StripeRegisteredPaymentMethodProps} props
|
104 |
-
*/
|
105 |
-
export const PaymentRequestExpress = ( props ) => {
|
106 |
-
const { locale } = getStripeServerData().button;
|
107 |
-
const { stripe } = props;
|
108 |
-
return (
|
109 |
-
<Elements stripe={ stripe } locale={ locale }>
|
110 |
-
<PaymentRequestExpressComponent { ...props } />
|
111 |
-
</Elements>
|
112 |
-
);
|
113 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/payment-method-extensions/payment-methods/stripe/payment-request/use-checkout-subscriptions.js
DELETED
@@ -1,241 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* External dependencies
|
3 |
-
*/
|
4 |
-
import { useEffect, useRef } from '@wordpress/element';
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Internal dependencies
|
8 |
-
*/
|
9 |
-
import {
|
10 |
-
normalizeShippingOptions,
|
11 |
-
getTotalPaymentItem,
|
12 |
-
normalizeLineItems,
|
13 |
-
getBillingData,
|
14 |
-
getPaymentMethodData,
|
15 |
-
getShippingData,
|
16 |
-
} from '../stripe-utils';
|
17 |
-
|
18 |
-
/**
|
19 |
-
* @typedef {import('@woocommerce/type-defs/payment-method-interface').EventRegistrationProps} EventRegistrationProps
|
20 |
-
* @typedef {import('@woocommerce/type-defs/payment-method-interface').BillingDataProps} BillingDataProps
|
21 |
-
* @typedef {import('@woocommerce/type-defs/payment-method-interface').ShippingDataProps} ShippingDataProps
|
22 |
-
* @typedef {import('@woocommerce/type-defs/payment-method-interface').EmitResponseProps} EmitResponseProps
|
23 |
-
*/
|
24 |
-
|
25 |
-
/**
|
26 |
-
* @param {Object} props
|
27 |
-
*
|
28 |
-
* @param {boolean} props.canMakePayment Whether the payment request
|
29 |
-
* can make payment or not.
|
30 |
-
* @param {boolean} props.isProcessing Whether the express payment
|
31 |
-
* method is processing or not.
|
32 |
-
* @param {EventRegistrationProps} props.eventRegistration Various functions for
|
33 |
-
* registering observers to
|
34 |
-
* events.
|
35 |
-
* @param {Object} props.paymentRequestEventHandlers Cached handlers registered
|
36 |
-
* for paymentRequest events.
|
37 |
-
* @param {function(string):void} props.clearPaymentRequestEventHandler Clears the cached payment
|
38 |
-
* request event handler.
|
39 |
-
* @param {BillingDataProps} props.billing
|
40 |
-
* @param {ShippingDataProps} props.shippingData
|
41 |
-
* @param {EmitResponseProps} props.emitResponse
|
42 |
-
* @param {string} props.paymentRequestType The derived payment request
|
43 |
-
* type for the express
|
44 |
-
* payment being processed.
|
45 |
-
* @param {function(any):void} props.completePayment This is a callback
|
46 |
-
* receiving the source event
|
47 |
-
* and setting it to
|
48 |
-
* successful payment.
|
49 |
-
* @param {function(any,string):any} props.abortPayment This is a callback
|
50 |
-
* receiving the source
|
51 |
-
* event and setting it to
|
52 |
-
* failed payment.
|
53 |
-
*/
|
54 |
-
export const useCheckoutSubscriptions = ( {
|
55 |
-
canMakePayment,
|
56 |
-
isProcessing,
|
57 |
-
eventRegistration,
|
58 |
-
paymentRequestEventHandlers,
|
59 |
-
clearPaymentRequestEventHandler,
|
60 |
-
billing,
|
61 |
-
shippingData,
|
62 |
-
emitResponse,
|
63 |
-
paymentRequestType,
|
64 |
-
completePayment,
|
65 |
-
abortPayment,
|
66 |
-
} ) => {
|
67 |
-
const {
|
68 |
-
onShippingRateSuccess,
|
69 |
-
onShippingRateFail,
|
70 |
-
onShippingRateSelectSuccess,
|
71 |
-
onShippingRateSelectFail,
|
72 |
-
onPaymentProcessing,
|
73 |
-
onCheckoutAfterProcessingWithSuccess,
|
74 |
-
onCheckoutAfterProcessingWithError,
|
75 |
-
} = eventRegistration;
|
76 |
-
const { noticeContexts, responseTypes } = emitResponse;
|
77 |
-
const eventHandlers = useRef( paymentRequestEventHandlers );
|
78 |
-
const currentBilling = useRef( billing );
|
79 |
-
const currentShipping = useRef( shippingData );
|
80 |
-
const currentPaymentRequestType = useRef( paymentRequestType );
|
81 |
-
|
82 |
-
useEffect( () => {
|
83 |
-
eventHandlers.current = paymentRequestEventHandlers;
|
84 |
-
currentBilling.current = billing;
|
85 |
-
currentShipping.current = shippingData;
|
86 |
-
currentPaymentRequestType.current = paymentRequestType;
|
87 |
-
}, [
|
88 |
-
paymentRequestEventHandlers,
|
89 |
-
billing,
|
90 |
-
shippingData,
|
91 |
-
paymentRequestType,
|
92 |
-
] );
|
93 |
-
|
94 |
-
// subscribe to events.
|
95 |
-
useEffect( () => {
|
96 |
-
const onShippingRatesEvent = ( shippingRates ) => {
|
97 |
-
const handlers = eventHandlers.current;
|
98 |
-
const billingData = currentBilling.current;
|
99 |
-
if ( handlers.shippingAddressChange && isProcessing ) {
|
100 |
-
handlers.shippingAddressChange.updateWith( {
|
101 |
-
status: 'success',
|
102 |
-
shippingOptions: normalizeShippingOptions( shippingRates ),
|
103 |
-
total: getTotalPaymentItem( billingData.cartTotal ),
|
104 |
-
displayItems: normalizeLineItems(
|
105 |
-
billingData.cartTotalItems
|
106 |
-
),
|
107 |
-
} );
|
108 |
-
clearPaymentRequestEventHandler( 'shippingAddressChange' );
|
109 |
-
}
|
110 |
-
};
|
111 |
-
const onShippingRatesEventFail = ( currentErrorStatus ) => {
|
112 |
-
const handlers = eventHandlers.current;
|
113 |
-
if ( handlers.shippingAddressChange && isProcessing ) {
|
114 |
-
handlers.shippingAddressChange.updateWith( {
|
115 |
-
status: currentErrorStatus.hasInvalidAddress
|
116 |
-
? 'invalid_shipping_address'
|
117 |
-
: 'fail',
|
118 |
-
shippingOptions: [],
|
119 |
-
} );
|
120 |
-
}
|
121 |
-
clearPaymentRequestEventHandler( 'shippingAddressChange' );
|
122 |
-
};
|
123 |
-
const onShippingSelectedRate = ( forSuccess = true ) => () => {
|
124 |
-
const handlers = eventHandlers.current;
|
125 |
-
const shipping = currentShipping.current;
|
126 |
-
const billingData = currentBilling.current;
|
127 |
-
if (
|
128 |
-
handlers.shippingOptionChange &&
|
129 |
-
! shipping.isSelectingRate &&
|
130 |
-
isProcessing
|
131 |
-
) {
|
132 |
-
const updateObject = forSuccess
|
133 |
-
? {
|
134 |
-
status: 'success',
|
135 |
-
total: getTotalPaymentItem( billingData.cartTotal ),
|
136 |
-
displayItems: normalizeLineItems(
|
137 |
-
billingData.cartTotalItems
|
138 |
-
),
|
139 |
-
}
|
140 |
-
: {
|
141 |
-
status: 'fail',
|
142 |
-
};
|
143 |
-
handlers.shippingOptionChange.updateWith( updateObject );
|
144 |
-
clearPaymentRequestEventHandler( 'shippingOptionChange' );
|
145 |
-
}
|
146 |
-
};
|
147 |
-
const onProcessingPayment = () => {
|
148 |
-
const handlers = eventHandlers.current;
|
149 |
-
if ( handlers.sourceEvent && isProcessing ) {
|
150 |
-
const response = {
|
151 |
-
type: responseTypes.SUCCESS,
|
152 |
-
meta: {
|
153 |
-
billingData: getBillingData( handlers.sourceEvent ),
|
154 |
-
paymentMethodData: getPaymentMethodData(
|
155 |
-
handlers.sourceEvent,
|
156 |
-
currentPaymentRequestType.current
|
157 |
-
),
|
158 |
-
shippingData: getShippingData( handlers.sourceEvent ),
|
159 |
-
},
|
160 |
-
};
|
161 |
-
return response;
|
162 |
-
}
|
163 |
-
return { type: responseTypes.SUCCESS };
|
164 |
-
};
|
165 |
-
const onCheckoutComplete = ( checkoutResponse ) => {
|
166 |
-
const handlers = eventHandlers.current;
|
167 |
-
let response = { type: responseTypes.SUCCESS };
|
168 |
-
if ( handlers.sourceEvent && isProcessing ) {
|
169 |
-
const {
|
170 |
-
paymentStatus,
|
171 |
-
paymentDetails,
|
172 |
-
} = checkoutResponse.processingResponse;
|
173 |
-
if ( paymentStatus === responseTypes.SUCCESS ) {
|
174 |
-
completePayment( handlers.sourceEvent );
|
175 |
-
}
|
176 |
-
if (
|
177 |
-
paymentStatus === responseTypes.ERROR ||
|
178 |
-
paymentStatus === responseTypes.FAIL
|
179 |
-
) {
|
180 |
-
abortPayment( handlers.sourceEvent );
|
181 |
-
response = {
|
182 |
-
type: responseTypes.ERROR,
|
183 |
-
message: paymentDetails?.errorMessage,
|
184 |
-
messageContext: noticeContexts.EXPRESS_PAYMENTS,
|
185 |
-
retry: true,
|
186 |
-
};
|
187 |
-
}
|
188 |
-
clearPaymentRequestEventHandler( 'sourceEvent' );
|
189 |
-
}
|
190 |
-
return response;
|
191 |
-
};
|
192 |
-
if ( canMakePayment && isProcessing ) {
|
193 |
-
const unsubscribeShippingRateSuccess = onShippingRateSuccess(
|
194 |
-
onShippingRatesEvent
|
195 |
-
);
|
196 |
-
const unsubscribeShippingRateFail = onShippingRateFail(
|
197 |
-
onShippingRatesEventFail
|
198 |
-
);
|
199 |
-
const unsubscribeShippingRateSelectSuccess = onShippingRateSelectSuccess(
|
200 |
-
onShippingSelectedRate()
|
201 |
-
);
|
202 |
-
const unsubscribeShippingRateSelectFail = onShippingRateSelectFail(
|
203 |
-
onShippingRatesEventFail
|
204 |
-
);
|
205 |
-
const unsubscribePaymentProcessing = onPaymentProcessing(
|
206 |
-
onProcessingPayment
|
207 |
-
);
|
208 |
-
const unsubscribeCheckoutCompleteSuccess = onCheckoutAfterProcessingWithSuccess(
|
209 |
-
onCheckoutComplete
|
210 |
-
);
|
211 |
-
const unsubscribeCheckoutCompleteFail = onCheckoutAfterProcessingWithError(
|
212 |
-
onCheckoutComplete
|
213 |
-
);
|
214 |
-
return () => {
|
215 |
-
unsubscribeCheckoutCompleteFail();
|
216 |
-
unsubscribeCheckoutCompleteSuccess();
|
217 |
-
unsubscribePaymentProcessing();
|
218 |
-
unsubscribeShippingRateFail();
|
219 |
-
unsubscribeShippingRateSuccess();
|
220 |
-
unsubscribeShippingRateSelectSuccess();
|
221 |
-
unsubscribeShippingRateSelectFail();
|
222 |
-
};
|
223 |
-
}
|
224 |
-
return undefined;
|
225 |
-
}, [
|
226 |
-
canMakePayment,
|
227 |
-
isProcessing,
|
228 |
-
onShippingRateSuccess,
|
229 |
-
onShippingRateFail,
|
230 |
-
onShippingRateSelectSuccess,
|
231 |
-
onShippingRateSelectFail,
|
232 |
-
onPaymentProcessing,
|
233 |
-
onCheckoutAfterProcessingWithSuccess,
|
234 |
-
onCheckoutAfterProcessingWithError,
|
235 |
-
responseTypes,
|
236 |
-
noticeContexts,
|
237 |
-
completePayment,
|
238 |
-
abortPayment,
|
239 |
-
clearPaymentRequestEventHandler,
|
240 |
-
] );
|
241 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/payment-method-extensions/payment-methods/stripe/payment-request/use-event-handlers.js
DELETED
@@ -1,48 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* External dependencies
|
3 |
-
*/
|
4 |
-
import { useState, useCallback } from '@wordpress/element';
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Internal dependencies
|
8 |
-
*/
|
9 |
-
import { DEFAULT_STRIPE_EVENT_HANDLERS } from './constants';
|
10 |
-
|
11 |
-
/**
|
12 |
-
* A utility hook for maintaining an event handler cache.
|
13 |
-
*/
|
14 |
-
export const useEventHandlers = () => {
|
15 |
-
const [ paymentRequestEventHandlers, setEventHandlers ] = useState(
|
16 |
-
DEFAULT_STRIPE_EVENT_HANDLERS
|
17 |
-
);
|
18 |
-
|
19 |
-
const setPaymentRequestEventHandler = useCallback(
|
20 |
-
( eventName, handler ) => {
|
21 |
-
setEventHandlers( ( prevEventHandlers ) => {
|
22 |
-
return {
|
23 |
-
...prevEventHandlers,
|
24 |
-
[ eventName ]: handler,
|
25 |
-
};
|
26 |
-
} );
|
27 |
-
},
|
28 |
-
[ setEventHandlers ]
|
29 |
-
);
|
30 |
-
|
31 |
-
const clearPaymentRequestEventHandler = useCallback(
|
32 |
-
( eventName ) => {
|
33 |
-
// @ts-ignore
|
34 |
-
setEventHandlers( ( prevEventHandlers ) => {
|
35 |
-
// @ts-ignore
|
36 |
-
// eslint-disable-next-line no-unused-vars
|
37 |
-
const { [ eventName ]: __, ...newHandlers } = prevEventHandlers;
|
38 |
-
return newHandlers;
|
39 |
-
} );
|
40 |
-
},
|
41 |
-
[ setEventHandlers ]
|
42 |
-
);
|
43 |
-
return {
|
44 |
-
paymentRequestEventHandlers,
|
45 |
-
setPaymentRequestEventHandler,
|
46 |
-
clearPaymentRequestEventHandler,
|
47 |
-
};
|
48 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/payment-method-extensions/payment-methods/stripe/payment-request/use-initialization.js
DELETED
@@ -1,251 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* External dependencies
|
3 |
-
*/
|
4 |
-
import { useEffect, useState, useRef, useCallback } from '@wordpress/element';
|
5 |
-
import { useStripe } from '@stripe/react-stripe-js';
|
6 |
-
import { getSetting } from '@woocommerce/settings';
|
7 |
-
import { __ } from '@wordpress/i18n';
|
8 |
-
import isShallowEqual from '@wordpress/is-shallow-equal';
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Internal dependencies
|
12 |
-
*/
|
13 |
-
import {
|
14 |
-
getPaymentRequest,
|
15 |
-
updatePaymentRequest,
|
16 |
-
canDoPaymentRequest,
|
17 |
-
normalizeShippingAddressForCheckout,
|
18 |
-
normalizeShippingOptionSelectionsForCheckout,
|
19 |
-
getStripeServerData,
|
20 |
-
pluckAddress,
|
21 |
-
normalizeShippingOptions,
|
22 |
-
} from '../stripe-utils';
|
23 |
-
import { useEventHandlers } from './use-event-handlers';
|
24 |
-
|
25 |
-
/**
|
26 |
-
* @typedef {import('../stripe-utils/type-defs').StripePaymentRequest} StripePaymentRequest
|
27 |
-
*/
|
28 |
-
|
29 |
-
export const useInitialization = ( {
|
30 |
-
billing,
|
31 |
-
shippingData,
|
32 |
-
setExpressPaymentError,
|
33 |
-
onClick,
|
34 |
-
onClose,
|
35 |
-
onSubmit,
|
36 |
-
} ) => {
|
37 |
-
const stripe = useStripe();
|
38 |
-
/**
|
39 |
-
* @type {[ StripePaymentRequest|null, function( StripePaymentRequest ):void]}
|
40 |
-
*/
|
41 |
-
// @ts-ignore
|
42 |
-
const [ paymentRequest, setPaymentRequest ] = useState( null );
|
43 |
-
const [ isFinished, setIsFinished ] = useState( false );
|
44 |
-
const [ isProcessing, setIsProcessing ] = useState( false );
|
45 |
-
const [ canMakePayment, setCanMakePayment ] = useState( false );
|
46 |
-
const [ paymentRequestType, setPaymentRequestType ] = useState( '' );
|
47 |
-
const currentShipping = useRef( shippingData );
|
48 |
-
const {
|
49 |
-
paymentRequestEventHandlers,
|
50 |
-
clearPaymentRequestEventHandler,
|
51 |
-
setPaymentRequestEventHandler,
|
52 |
-
} = useEventHandlers();
|
53 |
-
|
54 |
-
// Update refs when any change.
|
55 |
-
useEffect( () => {
|
56 |
-
currentShipping.current = shippingData;
|
57 |
-
}, [ shippingData ] );
|
58 |
-
|
59 |
-
// Create the initial paymentRequest object. Note, we can't do anything if stripe isn't available yet or we have zero total.
|
60 |
-
useEffect( () => {
|
61 |
-
if (
|
62 |
-
! stripe ||
|
63 |
-
! billing.cartTotal.value ||
|
64 |
-
isFinished ||
|
65 |
-
isProcessing ||
|
66 |
-
paymentRequest
|
67 |
-
) {
|
68 |
-
return;
|
69 |
-
}
|
70 |
-
const pr = getPaymentRequest( {
|
71 |
-
total: billing.cartTotal,
|
72 |
-
currencyCode: billing.currency.code.toLowerCase(),
|
73 |
-
countryCode: getSetting( 'baseLocation', {} )?.country,
|
74 |
-
shippingRequired: shippingData.needsShipping,
|
75 |
-
cartTotalItems: billing.cartTotalItems,
|
76 |
-
stripe,
|
77 |
-
} );
|
78 |
-
canDoPaymentRequest( pr ).then( ( result ) => {
|
79 |
-
setPaymentRequest( pr );
|
80 |
-
setPaymentRequestType( result.requestType || '' );
|
81 |
-
setCanMakePayment( result.canPay );
|
82 |
-
} );
|
83 |
-
}, [
|
84 |
-
billing.cartTotal,
|
85 |
-
billing.currency.code,
|
86 |
-
shippingData.needsShipping,
|
87 |
-
billing.cartTotalItems,
|
88 |
-
stripe,
|
89 |
-
isProcessing,
|
90 |
-
isFinished,
|
91 |
-
paymentRequest,
|
92 |
-
] );
|
93 |
-
|
94 |
-
// When the payment button is clicked, update the request and show it.
|
95 |
-
const onButtonClick = useCallback( () => {
|
96 |
-
setIsProcessing( true );
|
97 |
-
setIsFinished( false );
|
98 |
-
setExpressPaymentError( '' );
|
99 |
-
updatePaymentRequest( {
|
100 |
-
// @ts-ignore
|
101 |
-
paymentRequest,
|
102 |
-
total: billing.cartTotal,
|
103 |
-
currencyCode: billing.currency.code.toLowerCase(),
|
104 |
-
cartTotalItems: billing.cartTotalItems,
|
105 |
-
} );
|
106 |
-
onClick();
|
107 |
-
}, [
|
108 |
-
onClick,
|
109 |
-
paymentRequest,
|
110 |
-
setExpressPaymentError,
|
111 |
-
billing.cartTotal,
|
112 |
-
billing.currency.code,
|
113 |
-
billing.cartTotalItems,
|
114 |
-
] );
|
115 |
-
|
116 |
-
const abortPayment = useCallback( ( paymentMethod ) => {
|
117 |
-
paymentMethod.complete( 'fail' );
|
118 |
-
setIsProcessing( false );
|
119 |
-
setIsFinished( true );
|
120 |
-
}, [] );
|
121 |
-
|
122 |
-
const completePayment = useCallback( ( paymentMethod ) => {
|
123 |
-
paymentMethod.complete( 'success' );
|
124 |
-
setIsFinished( true );
|
125 |
-
setIsProcessing( false );
|
126 |
-
}, [] );
|
127 |
-
|
128 |
-
// whenever paymentRequest changes, hook in event listeners.
|
129 |
-
useEffect( () => {
|
130 |
-
const noop = { removeAllListeners: () => void null };
|
131 |
-
let shippingAddressChangeEvent = noop,
|
132 |
-
shippingOptionChangeEvent = noop,
|
133 |
-
sourceChangeEvent = noop,
|
134 |
-
cancelChangeEvent = noop;
|
135 |
-
|
136 |
-
if ( paymentRequest ) {
|
137 |
-
const cancelHandler = () => {
|
138 |
-
setIsFinished( false );
|
139 |
-
setIsProcessing( false );
|
140 |
-
setPaymentRequest( null );
|
141 |
-
onClose();
|
142 |
-
};
|
143 |
-
|
144 |
-
const shippingAddressChangeHandler = ( event ) => {
|
145 |
-
const newShippingAddress = normalizeShippingAddressForCheckout(
|
146 |
-
event.shippingAddress
|
147 |
-
);
|
148 |
-
if (
|
149 |
-
isShallowEqual(
|
150 |
-
pluckAddress( newShippingAddress ),
|
151 |
-
pluckAddress( currentShipping.current.shippingAddress )
|
152 |
-
)
|
153 |
-
) {
|
154 |
-
// the address is the same so no change needed.
|
155 |
-
event.updateWith( {
|
156 |
-
status: 'success',
|
157 |
-
shippingOptions: normalizeShippingOptions(
|
158 |
-
currentShipping.current.shippingRates
|
159 |
-
),
|
160 |
-
} );
|
161 |
-
} else {
|
162 |
-
// the address is different so let's set the new address and
|
163 |
-
// register the handler to be picked up by the shipping rate
|
164 |
-
// change event.
|
165 |
-
currentShipping.current.setShippingAddress(
|
166 |
-
normalizeShippingAddressForCheckout(
|
167 |
-
event.shippingAddress
|
168 |
-
)
|
169 |
-
);
|
170 |
-
setPaymentRequestEventHandler(
|
171 |
-
'shippingAddressChange',
|
172 |
-
event
|
173 |
-
);
|
174 |
-
}
|
175 |
-
};
|
176 |
-
|
177 |
-
const shippingOptionChangeHandler = ( event ) => {
|
178 |
-
currentShipping.current.setSelectedRates(
|
179 |
-
normalizeShippingOptionSelectionsForCheckout(
|
180 |
-
event.shippingOption
|
181 |
-
)
|
182 |
-
);
|
183 |
-
setPaymentRequestEventHandler( 'shippingOptionChange', event );
|
184 |
-
};
|
185 |
-
|
186 |
-
const sourceHandler = ( paymentMethod ) => {
|
187 |
-
if (
|
188 |
-
// eslint-disable-next-line no-undef
|
189 |
-
! getStripeServerData().allowPrepaidCard &&
|
190 |
-
paymentMethod.source.card.funding
|
191 |
-
) {
|
192 |
-
setExpressPaymentError(
|
193 |
-
/* eslint-disable-next-line @wordpress/i18n-text-domain */
|
194 |
-
__(
|
195 |
-
"Sorry, we're not accepting prepaid cards at this time.",
|
196 |
-
'woocommerce-gateway-stripe'
|
197 |
-
)
|
198 |
-
);
|
199 |
-
return;
|
200 |
-
}
|
201 |
-
setPaymentRequestEventHandler( 'sourceEvent', paymentMethod );
|
202 |
-
// kick off checkout processing step.
|
203 |
-
onSubmit();
|
204 |
-
};
|
205 |
-
|
206 |
-
// @ts-ignore
|
207 |
-
shippingAddressChangeEvent = paymentRequest.on(
|
208 |
-
'shippingaddresschange',
|
209 |
-
shippingAddressChangeHandler
|
210 |
-
);
|
211 |
-
// @ts-ignore
|
212 |
-
shippingOptionChangeEvent = paymentRequest.on(
|
213 |
-
'shippingoptionchange',
|
214 |
-
shippingOptionChangeHandler
|
215 |
-
);
|
216 |
-
// @ts-ignore
|
217 |
-
sourceChangeEvent = paymentRequest.on( 'source', sourceHandler );
|
218 |
-
// @ts-ignore
|
219 |
-
cancelChangeEvent = paymentRequest.on( 'cancel', cancelHandler );
|
220 |
-
}
|
221 |
-
|
222 |
-
return () => {
|
223 |
-
if ( paymentRequest ) {
|
224 |
-
shippingAddressChangeEvent.removeAllListeners();
|
225 |
-
shippingOptionChangeEvent.removeAllListeners();
|
226 |
-
sourceChangeEvent.removeAllListeners();
|
227 |
-
cancelChangeEvent.removeAllListeners();
|
228 |
-
}
|
229 |
-
};
|
230 |
-
}, [
|
231 |
-
paymentRequest,
|
232 |
-
canMakePayment,
|
233 |
-
isProcessing,
|
234 |
-
setPaymentRequestEventHandler,
|
235 |
-
setExpressPaymentError,
|
236 |
-
onSubmit,
|
237 |
-
onClose,
|
238 |
-
] );
|
239 |
-
|
240 |
-
return {
|
241 |
-
paymentRequest,
|
242 |
-
paymentRequestEventHandlers,
|
243 |
-
clearPaymentRequestEventHandler,
|
244 |
-
isProcessing,
|
245 |
-
canMakePayment,
|
246 |
-
onButtonClick,
|
247 |
-
abortPayment,
|
248 |
-
completePayment,
|
249 |
-
paymentRequestType,
|
250 |
-
};
|
251 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/payment-method-extensions/payment-methods/stripe/stripe-utils/constants.js
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
export const errorTypes = {
|
2 |
-
INVALID_EMAIL: 'email_invalid',
|
3 |
-
INVALID_REQUEST: 'invalid_request_error',
|
4 |
-
API_CONNECTION: 'api_connection_error',
|
5 |
-
API_ERROR: 'api_error',
|
6 |
-
AUTHENTICATION_ERROR: 'authentication_error',
|
7 |
-
RATE_LIMIT_ERROR: 'rate_limit_error',
|
8 |
-
CARD_ERROR: 'card_error',
|
9 |
-
VALIDATION_ERROR: 'validation_error',
|
10 |
-
};
|
11 |
-
|
12 |
-
export const errorCodes = {
|
13 |
-
INVALID_NUMBER: 'invalid_number',
|
14 |
-
INVALID_EXPIRY_MONTH: 'invalid_expiry_month',
|
15 |
-
INVALID_EXPIRY_YEAR: 'invalid_expiry_year',
|
16 |
-
INVALID_CVC: 'invalid_cvc',
|
17 |
-
INCORRECT_NUMBER: 'incorrect_number',
|
18 |
-
INCOMPLETE_NUMBER: 'incomplete_number',
|
19 |
-
INCOMPLETE_CVC: 'incomplete_cvc',
|
20 |
-
INCOMPLETE_EXPIRY: 'incomplete_expiry',
|
21 |
-
EXPIRED_CARD: 'expired_card',
|
22 |
-
INCORRECT_CVC: 'incorrect_cvc',
|
23 |
-
INCORRECT_ZIP: 'incorrect_zip',
|
24 |
-
INVALID_EXPIRY_YEAR_PAST: 'invalid_expiry_year_past',
|
25 |
-
CARD_DECLINED: 'card_declined',
|
26 |
-
MISSING: 'missing',
|
27 |
-
PROCESSING_ERROR: 'processing_error',
|
28 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/payment-method-extensions/payment-methods/stripe/stripe-utils/index.js
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
export * from './normalize';
|
2 |
-
export * from './utils';
|
3 |
-
export * from './load-stripe';
|
|
|
|
|
|
assets/js/payment-method-extensions/payment-methods/stripe/stripe-utils/load-stripe.js
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* External dependencies
|
3 |
-
*/
|
4 |
-
import { loadStripe } from '@stripe/stripe-js';
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Internal dependencies
|
8 |
-
*/
|
9 |
-
import { getApiKey } from './utils';
|
10 |
-
|
11 |
-
const stripePromise = () =>
|
12 |
-
new Promise( ( resolve ) => {
|
13 |
-
try {
|
14 |
-
resolve( loadStripe( getApiKey() ) );
|
15 |
-
} catch ( error ) {
|
16 |
-
// In order to avoid showing console error publicly to users,
|
17 |
-
// we resolve instead of rejecting when there is an error.
|
18 |
-
resolve( { error } );
|
19 |
-
}
|
20 |
-
} );
|
21 |
-
|
22 |
-
export { stripePromise as loadStripe };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/payment-method-extensions/payment-methods/stripe/stripe-utils/normalize.js
DELETED
@@ -1,176 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* @typedef {import('./type-defs').StripePaymentItem} StripePaymentItem
|
3 |
-
* @typedef {import('./type-defs').StripeShippingOption} StripeShippingOption
|
4 |
-
* @typedef {import('./type-defs').StripeShippingAddress} StripeShippingAddress
|
5 |
-
* @typedef {import('./type-defs').StripePaymentResponse} StripePaymentResponse
|
6 |
-
* @typedef {import('@woocommerce/type-defs/payment-method-interface').PreparedCartTotalItem} CartTotalItem
|
7 |
-
* @typedef {import('@woocommerce/type-defs/cart').CartShippingOption} CartShippingOption
|
8 |
-
* @typedef {import('@woocommerce/type-defs/shipping').ShippingAddress} CartShippingAddress
|
9 |
-
* @typedef {import('@woocommerce/type-defs/billing').BillingData} CartBillingAddress
|
10 |
-
*/
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Normalizes incoming cart total items for use as a displayItems with the
|
14 |
-
* Stripe api.
|
15 |
-
*
|
16 |
-
* @param {CartTotalItem[]} cartTotalItems CartTotalItems to normalize
|
17 |
-
* @param {boolean} pending Whether to mark items as pending or
|
18 |
-
* not
|
19 |
-
*
|
20 |
-
* @return {StripePaymentItem[]} An array of PaymentItems
|
21 |
-
*/
|
22 |
-
const normalizeLineItems = ( cartTotalItems, pending = false ) => {
|
23 |
-
return cartTotalItems
|
24 |
-
.map( ( cartTotalItem ) => {
|
25 |
-
return cartTotalItem.value
|
26 |
-
? {
|
27 |
-
amount: cartTotalItem.value,
|
28 |
-
label: cartTotalItem.label,
|
29 |
-
pending,
|
30 |
-
}
|
31 |
-
: false;
|
32 |
-
} )
|
33 |
-
.filter( Boolean );
|
34 |
-
};
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Normalizes incoming cart shipping option items for use as shipping options
|
38 |
-
* with the Stripe api.
|
39 |
-
*
|
40 |
-
* @param {CartShippingOption[]} shippingOptions An array of CartShippingOption items.
|
41 |
-
*
|
42 |
-
* @return {StripeShippingOption[]} An array of Stripe shipping option items.
|
43 |
-
*/
|
44 |
-
const normalizeShippingOptions = ( shippingOptions ) => {
|
45 |
-
const rates = shippingOptions[ 0 ].shipping_rates;
|
46 |
-
return rates.map( ( rate ) => {
|
47 |
-
return {
|
48 |
-
id: rate.rate_id,
|
49 |
-
label: rate.name,
|
50 |
-
detail: rate.description,
|
51 |
-
amount: parseInt( rate.price, 10 ),
|
52 |
-
};
|
53 |
-
} );
|
54 |
-
};
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Normalize shipping address information from stripe's address object to
|
58 |
-
* the cart shipping address object shape.
|
59 |
-
*
|
60 |
-
* @param {StripeShippingAddress} shippingAddress Stripe's shipping address item
|
61 |
-
*
|
62 |
-
* @return {CartShippingAddress} The shipping address in the shape expected by
|
63 |
-
* the cart.
|
64 |
-
*/
|
65 |
-
const normalizeShippingAddressForCheckout = ( shippingAddress ) => {
|
66 |
-
const address = {
|
67 |
-
first_name: shippingAddress.recipient
|
68 |
-
.split( ' ' )
|
69 |
-
.slice( 0, 1 )
|
70 |
-
.join( ' ' ),
|
71 |
-
last_name: shippingAddress.recipient
|
72 |
-
.split( ' ' )
|
73 |
-
.slice( 1 )
|
74 |
-
.join( ' ' ),
|
75 |
-
company: '',
|
76 |
-
address_1:
|
77 |
-
typeof shippingAddress.addressLine[ 0 ] === 'undefined'
|
78 |
-
? ''
|
79 |
-
: shippingAddress.addressLine[ 0 ],
|
80 |
-
address_2:
|
81 |
-
typeof shippingAddress.addressLine[ 1 ] === 'undefined'
|
82 |
-
? ''
|
83 |
-
: shippingAddress.addressLine[ 1 ],
|
84 |
-
city: shippingAddress.city,
|
85 |
-
state: shippingAddress.region,
|
86 |
-
country: shippingAddress.country,
|
87 |
-
postcode: shippingAddress.postalCode.replace( ' ', '' ),
|
88 |
-
};
|
89 |
-
return address;
|
90 |
-
};
|
91 |
-
|
92 |
-
/**
|
93 |
-
* Normalizes shipping option shape selection from Stripe's shipping option
|
94 |
-
* object to the expected shape for cart shipping option selections.
|
95 |
-
*
|
96 |
-
* @param {StripeShippingOption} shippingOption The customer's selected shipping
|
97 |
-
* option.
|
98 |
-
*
|
99 |
-
* @return {string[]} An array of ids (in this case will just be one)
|
100 |
-
*/
|
101 |
-
const normalizeShippingOptionSelectionsForCheckout = ( shippingOption ) => {
|
102 |
-
return shippingOption.id;
|
103 |
-
};
|
104 |
-
|
105 |
-
/**
|
106 |
-
* Returns the billing data extracted from the stripe payment response to the
|
107 |
-
* CartBillingData shape.
|
108 |
-
*
|
109 |
-
* @param {StripePaymentResponse} paymentResponse Stripe's payment response
|
110 |
-
* object.
|
111 |
-
*
|
112 |
-
* @return {CartBillingAddress} The cart billing data
|
113 |
-
*/
|
114 |
-
const getBillingData = ( paymentResponse ) => {
|
115 |
-
const source = paymentResponse.source;
|
116 |
-
const name = source && source.owner.name;
|
117 |
-
const billing = source && source.owner.address;
|
118 |
-
const payerEmail = paymentResponse.payerEmail || '';
|
119 |
-
const payerPhone = paymentResponse.payerPhone || '';
|
120 |
-
return {
|
121 |
-
first_name: name ? name.split( ' ' ).slice( 0, 1 ).join( ' ' ) : '',
|
122 |
-
last_name: name ? name.split( ' ' ).slice( 1 ).join( ' ' ) : '',
|
123 |
-
email: ( source && source.owner.email ) || payerEmail,
|
124 |
-
phone:
|
125 |
-
( source && source.owner.phone ) ||
|
126 |
-
payerPhone.replace( '/[() -]/g', '' ),
|
127 |
-
country: ( billing && billing.country ) || '',
|
128 |
-
address_1: ( billing && billing.line1 ) || '',
|
129 |
-
address_2: ( billing && billing.line2 ) || '',
|
130 |
-
city: ( billing && billing.city ) || '',
|
131 |
-
state: ( billing && billing.state ) || '',
|
132 |
-
postcode: ( billing && billing.postal_code ) || '',
|
133 |
-
company: '',
|
134 |
-
};
|
135 |
-
};
|
136 |
-
|
137 |
-
/**
|
138 |
-
* This returns extra payment method data to add to the payment method update
|
139 |
-
* request made by the checkout processor.
|
140 |
-
*
|
141 |
-
* @param {StripePaymentResponse} paymentResponse A stripe payment response
|
142 |
-
* object.
|
143 |
-
* @param {string} paymentRequestType The payment request type
|
144 |
-
* used for payment.
|
145 |
-
*
|
146 |
-
* @return {Object} An object with the extra payment data.
|
147 |
-
*/
|
148 |
-
const getPaymentMethodData = ( paymentResponse, paymentRequestType ) => {
|
149 |
-
return {
|
150 |
-
payment_method: 'stripe',
|
151 |
-
stripe_source: paymentResponse.source
|
152 |
-
? paymentResponse.source.id
|
153 |
-
: null,
|
154 |
-
payment_request_type: paymentRequestType,
|
155 |
-
};
|
156 |
-
};
|
157 |
-
|
158 |
-
const getShippingData = ( paymentResponse ) => {
|
159 |
-
return paymentResponse.shippingAddress
|
160 |
-
? {
|
161 |
-
address: normalizeShippingAddressForCheckout(
|
162 |
-
paymentResponse.shippingAddress
|
163 |
-
),
|
164 |
-
}
|
165 |
-
: null;
|
166 |
-
};
|
167 |
-
|
168 |
-
export {
|
169 |
-
normalizeLineItems,
|
170 |
-
normalizeShippingOptions,
|
171 |
-
normalizeShippingAddressForCheckout,
|
172 |
-
normalizeShippingOptionSelectionsForCheckout,
|
173 |
-
getBillingData,
|
174 |
-
getPaymentMethodData,
|
175 |
-
getShippingData,
|
176 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/payment-method-extensions/payment-methods/stripe/stripe-utils/type-defs.js
DELETED
@@ -1,324 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* Stripe PaymentItem object
|
3 |
-
*
|
4 |
-
* @typedef {Object} StripePaymentItem
|
5 |
-
*
|
6 |
-
* @property {string} label The label for the payment item.
|
7 |
-
* @property {number} amount The amount for the payment item (in subunits)
|
8 |
-
* @property {boolean} [pending] Whether or not the amount is pending update on
|
9 |
-
* recalculation.
|
10 |
-
*/
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Stripe ShippingOption object
|
14 |
-
*
|
15 |
-
* @typedef {Object} StripeShippingOption
|
16 |
-
*
|
17 |
-
* @property {string} id A unique ID for the shipping option.
|
18 |
-
* @property {string} label A short label for the shipping option.
|
19 |
-
* @property {string} detail A longer description for the shipping option.
|
20 |
-
* @property {number} amount The amount to show for the shipping option
|
21 |
-
* (in subunits)
|
22 |
-
*/
|
23 |
-
|
24 |
-
/**
|
25 |
-
* @typedef {Object} StripeShippingAddress
|
26 |
-
*
|
27 |
-
* @property {string} country Two letter country code, capitalized
|
28 |
-
* (ISO3166 alpha-2).
|
29 |
-
* @property {Array} addressLine An array of address line items.
|
30 |
-
* @property {string} region The most coarse subdivision of a
|
31 |
-
* country. (state etc)
|
32 |
-
* @property {string} city The name of a city, town, village etc.
|
33 |
-
* @property {string} postalCode The postal or ZIP code.
|
34 |
-
* @property {string} recipient The name of the recipient.
|
35 |
-
* @property {string} phone The phone number of the recipient.
|
36 |
-
* @property {string} [sortingCode] The sorting code as used in France.
|
37 |
-
* Not present on Apple platforms.
|
38 |
-
* @property {string} [dependentLocality] A logical subdivision of a city.
|
39 |
-
* Not present on Apple platforms.
|
40 |
-
*/
|
41 |
-
|
42 |
-
/**
|
43 |
-
* @typedef {Object} StripeBillingDetails
|
44 |
-
*
|
45 |
-
* @property {Object} address The billing address
|
46 |
-
* @property {string} address.city The billing address city
|
47 |
-
* @property {string} address.country The billing address country
|
48 |
-
* @property {string} address.line1 The first line for the address
|
49 |
-
* @property {string} address.line2 The second line fro the address
|
50 |
-
* @property {string} address.postal_code The postal/zip code
|
51 |
-
* @property {string} address.state The state
|
52 |
-
* @property {string} email The billing email
|
53 |
-
* @property {string} name The billing name
|
54 |
-
* @property {string} phone The billing phone
|
55 |
-
* @property {Object} [verified_address] The verified address of the owner.
|
56 |
-
* @property {string} [verified_email] Provided by the payment provider.
|
57 |
-
* @property {string} [verified_phone] Provided by the payment provider.
|
58 |
-
* @property {string} [verified_name] Provided by the payment provider.
|
59 |
-
*/
|
60 |
-
|
61 |
-
/**
|
62 |
-
* @typedef {Object} StripeBillingCard
|
63 |
-
*
|
64 |
-
* @property {string} brand The card brand
|
65 |
-
* @property {Object} checks Various security checks
|
66 |
-
* @property {string} checks.address_line1_check If an address line1 was
|
67 |
-
* provided, results of the
|
68 |
-
* check.
|
69 |
-
* @property {string} checks.address_postal_code_check If a postal code was
|
70 |
-
* provided, results of the
|
71 |
-
* check.
|
72 |
-
* @property {string} checks.cvc_check If CVC provided, results
|
73 |
-
* of the check.
|
74 |
-
* @property {string} country Two-letter ISO code for
|
75 |
-
* the country on the card.
|
76 |
-
* @property {number} exp_month Two-digit number for
|
77 |
-
* card expiry month.
|
78 |
-
* @property {number} exp_year Two-digit number for
|
79 |
-
* card expiry year.
|
80 |
-
* @property {string} fingerprint Uniquely identifies this
|
81 |
-
* particular card number
|
82 |
-
* @property {string} funding The card funding type
|
83 |
-
* @property {Object} generated_from Details of the original
|
84 |
-
* PaymentMethod that
|
85 |
-
* created this object.
|
86 |
-
* @property {string} last4 The last 4 digits of the
|
87 |
-
* card
|
88 |
-
* @property {Object} three_d_secure_usage Contains details on how
|
89 |
-
* this card may be used for
|
90 |
-
* 3d secure
|
91 |
-
* @property {Object} wallet If this card is part of a
|
92 |
-
* card wallet, this
|
93 |
-
* contains the details of
|
94 |
-
* the card wallet.
|
95 |
-
*/
|
96 |
-
|
97 |
-
/**
|
98 |
-
* @typedef {Object} StripePaymentMethod
|
99 |
-
*
|
100 |
-
* @property {string} id Unique identifier for the
|
101 |
-
* object
|
102 |
-
* @property {StripeBillingDetails} billing_details The billing details for the
|
103 |
-
* payment method
|
104 |
-
* @property {StripeBillingCard} card Details on the card used to
|
105 |
-
* pay
|
106 |
-
* @property {string} customer The ID of the customer to
|
107 |
-
* which this payment method
|
108 |
-
* is saved.
|
109 |
-
* @property {Object} metadata Set of key-value pairs that
|
110 |
-
* can be attached to the
|
111 |
-
* object.
|
112 |
-
* @property {string} type Type of payment method
|
113 |
-
* @property {string} object The type of object. Always
|
114 |
-
* 'payment_method'. Can use
|
115 |
-
* to validate!
|
116 |
-
* @property {Object} card_present If this is a card present
|
117 |
-
* payment method, contains
|
118 |
-
* details about that card
|
119 |
-
* @property {number} created The timestamp for when the
|
120 |
-
* card was created.
|
121 |
-
* @property {Object} fpx If this is an fpx payment
|
122 |
-
* method, contains details
|
123 |
-
* about it.
|
124 |
-
* @property {Object} ideal If this is an ideal payment
|
125 |
-
* method, contains details
|
126 |
-
* about it.
|
127 |
-
* @property {boolean} livemode True if the object exists
|
128 |
-
* in live mode or if in test
|
129 |
-
* mode.
|
130 |
-
* @property {Object} sepa_debit If this is a sepa_debit
|
131 |
-
* payment method, contains
|
132 |
-
* details about it.
|
133 |
-
*/
|
134 |
-
|
135 |
-
/**
|
136 |
-
* @typedef {Object} StripeSource
|
137 |
-
*
|
138 |
-
* @property {string} id Unique identifier for
|
139 |
-
* object
|
140 |
-
* @property {number} amount A positive number in
|
141 |
-
* the smallest currency
|
142 |
-
* unit.
|
143 |
-
* @property {string} currency The three-letter ISO
|
144 |
-
* code for the currency
|
145 |
-
* @property {string} customer The ID of the customer
|
146 |
-
* to which this source
|
147 |
-
* is attached.
|
148 |
-
* @property {Object} metadata Arbitrary key-value
|
149 |
-
* pairs that can be
|
150 |
-
* attached.
|
151 |
-
* @property {StripeBillingDetails} owner Information about the
|
152 |
-
* owner of the payment
|
153 |
-
* made.
|
154 |
-
* @property {Object} [redirect] Information related to
|
155 |
-
* the redirect flow
|
156 |
-
* (present if the source
|
157 |
-
* is authenticated by
|
158 |
-
* redirect)
|
159 |
-
* @property {string} statement_descriptor Extra information
|
160 |
-
* about a source (will
|
161 |
-
* appear on customer's
|
162 |
-
* statement)
|
163 |
-
* @property {string} status The status of the
|
164 |
-
* source.
|
165 |
-
* @property {string} type The type of the source
|
166 |
-
* (it is a payment
|
167 |
-
* method type)
|
168 |
-
* @property {string} object Value is "source" can
|
169 |
-
* be used to validate.
|
170 |
-
* @property {string} client_secret The client secret of
|
171 |
-
* the source. Used for
|
172 |
-
* client-side retrieval
|
173 |
-
* using a publishable
|
174 |
-
* key.
|
175 |
-
* @property {Object} [code_verification] Information related to
|
176 |
-
* the code verification
|
177 |
-
* flow.
|
178 |
-
* @property {number} created When the source object
|
179 |
-
* was instantiated
|
180 |
-
* (timestamp).
|
181 |
-
* @property {string} flow The authentication
|
182 |
-
* flow of the source.
|
183 |
-
* @property {boolean} livemode If true then payment
|
184 |
-
* is made in live mode
|
185 |
-
* otherwise test mode.
|
186 |
-
* @property {Object} [receiver] Information related to
|
187 |
-
* the receiver flow.
|
188 |
-
* @property {Object} source_order Information about the
|
189 |
-
* items and shipping
|
190 |
-
* associated with the
|
191 |
-
* source.
|
192 |
-
* @property {string} usage Whether source should
|
193 |
-
* be reusable or not.
|
194 |
-
*/
|
195 |
-
|
196 |
-
/**
|
197 |
-
* @typedef {Object} StripePaymentResponse
|
198 |
-
*
|
199 |
-
* @property {Object} token A stripe token object
|
200 |
-
* @property {StripePaymentMethod} paymentMethod The stripe payment method
|
201 |
-
* object
|
202 |
-
* @property {?StripeSource} source Present if this was the
|
203 |
-
* result of a source event
|
204 |
-
* listener
|
205 |
-
* @property {Function} complete Call this when the token
|
206 |
-
* data has been processed.
|
207 |
-
* @property {string} [payerName] The customer's name.
|
208 |
-
* @property {string} [payerEmail] The customer's email.
|
209 |
-
* @property {string} [payerPhone] The customer's phone.
|
210 |
-
* @property {StripeShippingAddress} [shippingAddress] The final shipping
|
211 |
-
* address the customer
|
212 |
-
* indicated
|
213 |
-
* @property {StripeShippingOption} [shippingOption] The final shipping
|
214 |
-
* option the customer
|
215 |
-
* selected.
|
216 |
-
* @property {string} methodName The unique name of the
|
217 |
-
* payment handler the
|
218 |
-
* customer chose to
|
219 |
-
* authorize payment
|
220 |
-
*/
|
221 |
-
|
222 |
-
/**
|
223 |
-
* @typedef {Object} StripePaymentRequestOptions The configuration of stripe
|
224 |
-
* payment request options to
|
225 |
-
* pass in.
|
226 |
-
*
|
227 |
-
* @property {string} country Two-letter (ISO)
|
228 |
-
* country code.
|
229 |
-
* @property {string} currency Three letter currency
|
230 |
-
* code.
|
231 |
-
* @property {StripePaymentItem} total Shown to the customer.
|
232 |
-
* @property {StripePaymentItem[]} displayItems Line items shown to the
|
233 |
-
* customer.
|
234 |
-
* @property {boolean} requestPayerName Whether or not to
|
235 |
-
* collect the payer's
|
236 |
-
* name.
|
237 |
-
* @property {boolean} requestPayerEmail Whether or not to
|
238 |
-
* collect the payer's
|
239 |
-
* email.
|
240 |
-
* @property {boolean} requestPayerPhone Whether or not to
|
241 |
-
* collect the payer's
|
242 |
-
* phone.
|
243 |
-
* @property {boolean} requestShipping Whether to collect
|
244 |
-
* shipping address.
|
245 |
-
* @property {StripeShippingOption[]} shippingOptions Available shipping
|
246 |
-
* options.
|
247 |
-
*/
|
248 |
-
|
249 |
-
/**
|
250 |
-
* @typedef {Object} StripePaymentRequest Stripe payment request object.
|
251 |
-
*
|
252 |
-
* @property {function():Promise} canMakePayment Returns a promise that resolves
|
253 |
-
* with an object detailing if a
|
254 |
-
* browser payment API is
|
255 |
-
* available.
|
256 |
-
* @property {function()} show Shows the browser's payment
|
257 |
-
* interface (called automatically
|
258 |
-
* if payment request button in
|
259 |
-
* use)
|
260 |
-
* @property {function()} update Used to update a PaymentRequest
|
261 |
-
* object.
|
262 |
-
* @property {function()} on For registering callbacks on
|
263 |
-
* payment request events.
|
264 |
-
*/
|
265 |
-
|
266 |
-
/**
|
267 |
-
* @typedef {Object} Stripe Stripe api object.
|
268 |
-
* @property {any} api Various api properties
|
269 |
-
*/
|
270 |
-
|
271 |
-
/**
|
272 |
-
* @typedef {Object} CreditCardIcon
|
273 |
-
*
|
274 |
-
* @property {string} url Url to icon.
|
275 |
-
* @property {string} alt Alt text for icon.
|
276 |
-
*/
|
277 |
-
|
278 |
-
/* eslint-disable jsdoc/valid-types */
|
279 |
-
// [k:string]:CreditCardIcon triggers the above rule even though VSCode interprets it fine.
|
280 |
-
/**
|
281 |
-
* @typedef {Object} StripeServerData
|
282 |
-
*
|
283 |
-
* @property {string} stripeTotalLabel The string used for payment
|
284 |
-
* descriptor.
|
285 |
-
* @property {string} publicKey The public api key for stripe
|
286 |
-
* requests.
|
287 |
-
* @property {boolean} allowPrepaidCard True means that prepaid cards
|
288 |
-
* can be used for payment.
|
289 |
-
* @property {Object} button Contains button styles
|
290 |
-
* @property {string} button.type The type of button.
|
291 |
-
* @property {string} button.theme The theme for the button.
|
292 |
-
* @property {string} button.height The height (in pixels) for
|
293 |
-
* the button.
|
294 |
-
* @property {string} button.locale The locale to use for stripe
|
295 |
-
* elements.
|
296 |
-
* @property {boolean} inline_cc_form Whether stripe cc should use
|
297 |
-
* inline cc
|
298 |
-
* form or separate inputs.
|
299 |
-
* @property {{[k:string]:CreditCardIcon}} icons Contains supported cc icons.
|
300 |
-
* @property {boolean} showSavedCards Used to indicate whether saved cards
|
301 |
-
* can be used.
|
302 |
-
* @property {boolean} showSaveOption Used to indicate whether the option to
|
303 |
-
* save card can be displayed.
|
304 |
-
* @property {boolean} allowPaymentRequest True if merchant has enabled payment
|
305 |
-
* request (Chrome/Apple Pay).
|
306 |
-
* @property {Object} supports List of features supported by the payment gateway
|
307 |
-
*/
|
308 |
-
/* eslint-enable jsdoc/valid-types */
|
309 |
-
|
310 |
-
/**
|
311 |
-
* @typedef {Object} StripeElementOptions
|
312 |
-
*
|
313 |
-
* @property {Object} options The configuration object for stripe
|
314 |
-
* elements.
|
315 |
-
* @property {function(boolean)} onActive A callback for setting whether an
|
316 |
-
* element is active or not. "Active"
|
317 |
-
* means it's not empty.
|
318 |
-
* @property {string} error Any error message from the stripe
|
319 |
-
* element.
|
320 |
-
* @property {function(string)} setError A callback for setting an error
|
321 |
-
* message.
|
322 |
-
*/
|
323 |
-
|
324 |
-
export {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/payment-method-extensions/payment-methods/stripe/stripe-utils/utils.js
DELETED
@@ -1,281 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* External dependencies
|
3 |
-
*/
|
4 |
-
import { getSetting } from '@woocommerce/settings';
|
5 |
-
import { __ } from '@wordpress/i18n';
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Internal dependencies
|
9 |
-
*/
|
10 |
-
import { normalizeLineItems } from './normalize';
|
11 |
-
import { errorTypes, errorCodes } from './constants';
|
12 |
-
|
13 |
-
/**
|
14 |
-
* @typedef {import('./type-defs').StripeServerData} StripeServerData
|
15 |
-
* @typedef {import('./type-defs').StripePaymentItem} StripePaymentItem
|
16 |
-
* @typedef {import('./type-defs').StripePaymentRequest} StripePaymentRequest
|
17 |
-
* @typedef {import('@woocommerce/type-defs/payment-method-interface').PreparedCartTotalItem} CartTotalItem
|
18 |
-
*/
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Stripe data comes form the server passed on a global object.
|
22 |
-
*
|
23 |
-
* @return {StripeServerData} Stripe server data.
|
24 |
-
*/
|
25 |
-
const getStripeServerData = () => {
|
26 |
-
const stripeServerData = getSetting( 'stripe_data', null );
|
27 |
-
if ( ! stripeServerData ) {
|
28 |
-
throw new Error( 'Stripe initialization data is not available' );
|
29 |
-
}
|
30 |
-
return stripeServerData;
|
31 |
-
};
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Returns the public api key for the stripe payment method
|
35 |
-
*
|
36 |
-
* @throws Error
|
37 |
-
* @return {string} The public api key for the stripe payment method.
|
38 |
-
*/
|
39 |
-
const getApiKey = () => {
|
40 |
-
const apiKey = getStripeServerData().publicKey;
|
41 |
-
if ( ! apiKey ) {
|
42 |
-
throw new Error(
|
43 |
-
'There is no api key available for stripe. Make sure it is available on the wc.stripe_data.stripe.key property.'
|
44 |
-
);
|
45 |
-
}
|
46 |
-
return apiKey;
|
47 |
-
};
|
48 |
-
|
49 |
-
/**
|
50 |
-
* The total PaymentItem object used for the stripe PaymentRequest object.
|
51 |
-
*
|
52 |
-
* @param {CartTotalItem} total The total amount.
|
53 |
-
*
|
54 |
-
* @return {StripePaymentItem} The PaymentItem object used for stripe.
|
55 |
-
*/
|
56 |
-
const getTotalPaymentItem = ( total ) => {
|
57 |
-
return {
|
58 |
-
label:
|
59 |
-
getStripeServerData().stripeTotalLabel ||
|
60 |
-
__( 'Total', 'woo-gutenberg-products-block' ),
|
61 |
-
amount: total.value,
|
62 |
-
};
|
63 |
-
};
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Returns a stripe payment request object
|
67 |
-
*
|
68 |
-
* @param {Object} config A configuration object for
|
69 |
-
* getting the payment request.
|
70 |
-
* @param {Object} config.stripe The stripe api.
|
71 |
-
* @param {CartTotalItem} config.total The amount for the total
|
72 |
-
* (in subunits) provided by
|
73 |
-
* checkout/cart.
|
74 |
-
* @param {string} config.currencyCode The currency code provided
|
75 |
-
* by checkout/cart.
|
76 |
-
* @param {string} config.countryCode The country code provided by
|
77 |
-
* checkout/cart.
|
78 |
-
* @param {boolean} config.shippingRequired Whether or not shipping is
|
79 |
-
* required.
|
80 |
-
* @param {CartTotalItem[]} config.cartTotalItems Array of line items provided
|
81 |
-
* by checkout/cart.
|
82 |
-
*
|
83 |
-
* @return {StripePaymentRequest} A stripe payment request object
|
84 |
-
*/
|
85 |
-
const getPaymentRequest = ( {
|
86 |
-
stripe,
|
87 |
-
total,
|
88 |
-
currencyCode,
|
89 |
-
countryCode,
|
90 |
-
shippingRequired,
|
91 |
-
cartTotalItems,
|
92 |
-
} ) => {
|
93 |
-
const options = {
|
94 |
-
total: getTotalPaymentItem( total ),
|
95 |
-
currency: currencyCode,
|
96 |
-
country: countryCode || 'US',
|
97 |
-
requestPayerName: true,
|
98 |
-
requestPayerEmail: true,
|
99 |
-
requestPayerPhone: true,
|
100 |
-
requestShipping: shippingRequired,
|
101 |
-
displayItems: normalizeLineItems( cartTotalItems ),
|
102 |
-
};
|
103 |
-
return stripe.paymentRequest( options );
|
104 |
-
};
|
105 |
-
|
106 |
-
/**
|
107 |
-
* Utility function for updating the Stripe PaymentRequest object
|
108 |
-
*
|
109 |
-
* @param {Object} update An object containing the
|
110 |
-
* things needed for the
|
111 |
-
* update
|
112 |
-
* @param {StripePaymentRequest} update.paymentRequest A Stripe payment request
|
113 |
-
* object
|
114 |
-
* @param {CartTotalItem} update.total A total line item.
|
115 |
-
* @param {string} update.currencyCode The currency code for the
|
116 |
-
* amount provided.
|
117 |
-
* @param {CartTotalItem[]} update.cartTotalItems An array of line items
|
118 |
-
* provided by the
|
119 |
-
* cart/checkout.
|
120 |
-
*/
|
121 |
-
const updatePaymentRequest = ( {
|
122 |
-
paymentRequest,
|
123 |
-
total,
|
124 |
-
currencyCode,
|
125 |
-
cartTotalItems,
|
126 |
-
} ) => {
|
127 |
-
paymentRequest.update( {
|
128 |
-
total: getTotalPaymentItem( total ),
|
129 |
-
currency: currencyCode,
|
130 |
-
displayItems: normalizeLineItems( cartTotalItems ),
|
131 |
-
} );
|
132 |
-
};
|
133 |
-
|
134 |
-
/**
|
135 |
-
* Returns whether or not the current session can do apple pay.
|
136 |
-
*
|
137 |
-
* @param {StripePaymentRequest} paymentRequest A Stripe PaymentRequest instance.
|
138 |
-
*
|
139 |
-
* @return {Promise<Object>} True means apple pay can be done.
|
140 |
-
*/
|
141 |
-
const canDoPaymentRequest = ( paymentRequest ) => {
|
142 |
-
return new Promise( ( resolve ) => {
|
143 |
-
paymentRequest.canMakePayment().then( ( result ) => {
|
144 |
-
if ( result ) {
|
145 |
-
const paymentRequestType = result.applePay
|
146 |
-
? 'apple_pay'
|
147 |
-
: 'payment_request_api';
|
148 |
-
resolve( { canPay: true, requestType: paymentRequestType } );
|
149 |
-
return;
|
150 |
-
}
|
151 |
-
resolve( { canPay: false } );
|
152 |
-
} );
|
153 |
-
} );
|
154 |
-
};
|
155 |
-
|
156 |
-
const isNonFriendlyError = ( type ) =>
|
157 |
-
[
|
158 |
-
errorTypes.INVALID_REQUEST,
|
159 |
-
errorTypes.API_CONNECTION,
|
160 |
-
errorTypes.API_ERROR,
|
161 |
-
errorTypes.AUTHENTICATION_ERROR,
|
162 |
-
errorTypes.RATE_LIMIT_ERROR,
|
163 |
-
].includes( type );
|
164 |
-
|
165 |
-
const getErrorMessageForCode = ( code ) => {
|
166 |
-
const messages = {
|
167 |
-
/* eslint-disable @wordpress/i18n-text-domain */
|
168 |
-
[ errorCodes.INVALID_NUMBER ]: __(
|
169 |
-
'The card number is not a valid credit card number.',
|
170 |
-
'woocommerce-gateway-stripe'
|
171 |
-
),
|
172 |
-
[ errorCodes.INVALID_EXPIRY_MONTH ]: __(
|
173 |
-
'The card expiration month is invalid.',
|
174 |
-
'woocommerce-gateway-stripe'
|
175 |
-
),
|
176 |
-
[ errorCodes.INVALID_EXPIRY_YEAR ]: __(
|
177 |
-
'The card expiration year is invalid.',
|
178 |
-
'woocommerce-gateway-stripe'
|
179 |
-
),
|
180 |
-
[ errorCodes.INVALID_CVC ]: __(
|
181 |
-
'The card security code is invalid.',
|
182 |
-
'woocommerce-gateway-stripe'
|
183 |
-
),
|
184 |
-
[ errorCodes.INCORRECT_NUMBER ]: __(
|
185 |
-
'The card number is incorrect.',
|
186 |
-
'woocommerce-gateway-stripe'
|
187 |
-
),
|
188 |
-
[ errorCodes.INCOMPLETE_NUMBER ]: __(
|
189 |
-
'The card number is incomplete.',
|
190 |
-
'woocommerce-gateway-stripe'
|
191 |
-
),
|
192 |
-
[ errorCodes.INCOMPLETE_CVC ]: __(
|
193 |
-
'The card security code is incomplete.',
|
194 |
-
'woocommerce-gateway-stripe'
|
195 |
-
),
|
196 |
-
[ errorCodes.INCOMPLETE_EXPIRY ]: __(
|
197 |
-
'The card expiration date is incomplete.',
|
198 |
-
'woocommerce-gateway-stripe'
|
199 |
-
),
|
200 |
-
[ errorCodes.EXPIRED_CARD ]: __(
|
201 |
-
'The card has expired.',
|
202 |
-
'woocommerce-gateway-stripe'
|
203 |
-
),
|
204 |
-
[ errorCodes.INCORRECT_CVC ]: __(
|
205 |
-
'The card security code is incorrect.',
|
206 |
-
'woocommerce-gateway-stripe'
|
207 |
-
),
|
208 |
-
[ errorCodes.INCORRECT_ZIP ]: __(
|
209 |
-
'The card zip code failed validation.',
|
210 |
-
'woocommerce-gateway-stripe'
|
211 |
-
),
|
212 |
-
[ errorCodes.INVALID_EXPIRY_YEAR_PAST ]: __(
|
213 |
-
'The card expiration year is in the past',
|
214 |
-
'woocommerce-gateway-stripe'
|
215 |
-
),
|
216 |
-
[ errorCodes.CARD_DECLINED ]: __(
|
217 |
-
'The card was declined.',
|
218 |
-
'woocommerce-gateway-stripe'
|
219 |
-
),
|
220 |
-
[ errorCodes.MISSING ]: __(
|
221 |
-
'There is no card on a customer that is being charged.',
|
222 |
-
'woocommerce-gateway-stripe'
|
223 |
-
),
|
224 |
-
[ errorCodes.PROCESSING_ERROR ]: __(
|
225 |
-
'An error occurred while processing the card.',
|
226 |
-
'woocommerce-gateway-stripe'
|
227 |
-
),
|
228 |
-
/* eslint-enable @wordpress/i18n-text-domain */
|
229 |
-
};
|
230 |
-
return messages[ code ] || null;
|
231 |
-
};
|
232 |
-
|
233 |
-
const getErrorMessageForTypeAndCode = ( type, code = '' ) => {
|
234 |
-
switch ( type ) {
|
235 |
-
case errorTypes.INVALID_EMAIL:
|
236 |
-
return __(
|
237 |
-
'Invalid email address, please correct and try again.',
|
238 |
-
'woo-gutenberg-products-block'
|
239 |
-
);
|
240 |
-
case isNonFriendlyError( type ):
|
241 |
-
return __(
|
242 |
-
'Unable to process this payment, please try again or use alternative method.',
|
243 |
-
'woo-gutenberg-products-block'
|
244 |
-
);
|
245 |
-
case errorTypes.CARD_ERROR:
|
246 |
-
return getErrorMessageForCode( code );
|
247 |
-
case errorTypes.VALIDATION_ERROR:
|
248 |
-
return ''; // These are shown inline.
|
249 |
-
}
|
250 |
-
return null;
|
251 |
-
};
|
252 |
-
|
253 |
-
/**
|
254 |
-
* pluckAddress takes a full address object and returns relevant fields for calculating
|
255 |
-
* shipping, so we can track when one of them change to update rates.
|
256 |
-
*
|
257 |
-
* @param {Object} address An object containing all address information
|
258 |
-
* @param {string} address.country
|
259 |
-
* @param {string} address.state
|
260 |
-
* @param {string} address.city
|
261 |
-
* @param {string} address.postcode
|
262 |
-
*
|
263 |
-
* @return {Object} pluckedAddress An object containing shipping address that are needed to fetch an address.
|
264 |
-
*/
|
265 |
-
const pluckAddress = ( { country, state, city, postcode } ) => ( {
|
266 |
-
country,
|
267 |
-
state,
|
268 |
-
city,
|
269 |
-
postcode: postcode.replace( ' ', '' ).toUpperCase(),
|
270 |
-
} );
|
271 |
-
|
272 |
-
export {
|
273 |
-
getStripeServerData,
|
274 |
-
getApiKey,
|
275 |
-
getTotalPaymentItem,
|
276 |
-
getPaymentRequest,
|
277 |
-
updatePaymentRequest,
|
278 |
-
canDoPaymentRequest,
|
279 |
-
getErrorMessageForTypeAndCode,
|
280 |
-
pluckAddress,
|
281 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/previews/saved-payment-methods.js
CHANGED
@@ -2,7 +2,7 @@ export const previewSavedPaymentMethods = {
|
|
2 |
cc: [
|
3 |
{
|
4 |
method: {
|
5 |
-
gateway: '
|
6 |
last4: '5678',
|
7 |
brand: 'Visa',
|
8 |
},
|
2 |
cc: [
|
3 |
{
|
4 |
method: {
|
5 |
+
gateway: 'credit-card',
|
6 |
last4: '5678',
|
7 |
brand: 'Visa',
|
8 |
},
|
assets/js/shared/context/product-data-context.js
CHANGED
@@ -45,11 +45,13 @@ const defaultProductData = {
|
|
45 |
is_on_backorder: false,
|
46 |
low_stock_remaining: null,
|
47 |
sold_individually: false,
|
48 |
-
quantity_limit: 99,
|
49 |
add_to_cart: {
|
50 |
text: 'Add to cart',
|
51 |
description: 'Add to cart',
|
52 |
url: '',
|
|
|
|
|
|
|
53 |
},
|
54 |
};
|
55 |
|
45 |
is_on_backorder: false,
|
46 |
low_stock_remaining: null,
|
47 |
sold_individually: false,
|
|
|
48 |
add_to_cart: {
|
49 |
text: 'Add to cart',
|
50 |
description: 'Add to cart',
|
51 |
url: '',
|
52 |
+
minimum: 1,
|
53 |
+
maximum: 99,
|
54 |
+
multiple_of: 1,
|
55 |
},
|
56 |
};
|
57 |
|
assets/js/types/type-defs/cart-response.ts
CHANGED
@@ -2,13 +2,7 @@
|
|
2 |
* Internal dependencies
|
3 |
*/
|
4 |
import { CurrencyResponse } from './currency';
|
5 |
-
import {
|
6 |
-
CartImageItem,
|
7 |
-
CartItemPrices,
|
8 |
-
CartItemTotals,
|
9 |
-
CartVariationItem,
|
10 |
-
CatalogVisibility,
|
11 |
-
} from './cart';
|
12 |
|
13 |
export interface CartResponseTotalsItem extends CurrencyResponse {
|
14 |
total_discount: string;
|
@@ -127,30 +121,7 @@ export interface CartResponseItemTotals extends CurrencyResponse {
|
|
127 |
line_total_tax: string;
|
128 |
}
|
129 |
|
130 |
-
export
|
131 |
-
key: string;
|
132 |
-
id: number;
|
133 |
-
quantity: number;
|
134 |
-
catalog_visibility: CatalogVisibility;
|
135 |
-
quantity_limit: number;
|
136 |
-
name: string;
|
137 |
-
summary: string;
|
138 |
-
short_description: string;
|
139 |
-
description: string;
|
140 |
-
sku: string;
|
141 |
-
low_stock_remaining: null | number;
|
142 |
-
backorders_allowed: boolean;
|
143 |
-
show_backorder_badge: boolean;
|
144 |
-
sold_individually: boolean;
|
145 |
-
permalink: string;
|
146 |
-
images: Array< CartImageItem >;
|
147 |
-
variation: Array< CartVariationItem >;
|
148 |
-
prices: CartItemPrices;
|
149 |
-
totals: CartItemTotals;
|
150 |
-
extensions: ExtensionsData;
|
151 |
-
item_data: Record< string, unknown >[];
|
152 |
-
}
|
153 |
-
|
154 |
export interface CartResponseTotalsTaxLineItem {
|
155 |
name: string;
|
156 |
price: string;
|
2 |
* Internal dependencies
|
3 |
*/
|
4 |
import { CurrencyResponse } from './currency';
|
5 |
+
import { CartItem } from './cart';
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
export interface CartResponseTotalsItem extends CurrencyResponse {
|
8 |
total_discount: string;
|
121 |
line_total_tax: string;
|
122 |
}
|
123 |
|
124 |
+
export type CartResponseItem = CartItem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
export interface CartResponseTotalsTaxLineItem {
|
126 |
name: string;
|
127 |
price: string;
|
assets/js/types/type-defs/cart.ts
CHANGED
@@ -117,7 +117,12 @@ export interface CartItem {
|
|
117 |
id: number;
|
118 |
quantity: number;
|
119 |
catalog_visibility: CatalogVisibility;
|
120 |
-
|
|
|
|
|
|
|
|
|
|
|
121 |
name: string;
|
122 |
summary: string;
|
123 |
short_description: string;
|
117 |
id: number;
|
118 |
quantity: number;
|
119 |
catalog_visibility: CatalogVisibility;
|
120 |
+
quantity_limits: {
|
121 |
+
minimum: number;
|
122 |
+
maximum: number;
|
123 |
+
multiple_of: number;
|
124 |
+
editable: boolean;
|
125 |
+
};
|
126 |
name: string;
|
127 |
summary: string;
|
128 |
short_description: string;
|
assets/js/types/type-defs/payments.ts
CHANGED
@@ -69,7 +69,7 @@ export interface PaymentMethodConfiguration {
|
|
69 |
paymentMethodId?: string;
|
70 |
// Object that describes various features provided by the payment method.
|
71 |
supports: SupportsConfiguration;
|
72 |
-
// Array of card types (brands) supported by the payment method.
|
73 |
icons?: null | PaymentMethodIcons;
|
74 |
// A react node that will be used as a label for the payment method in the checkout.
|
75 |
label: ReactNode;
|
69 |
paymentMethodId?: string;
|
70 |
// Object that describes various features provided by the payment method.
|
71 |
supports: SupportsConfiguration;
|
72 |
+
// Array of card types (brands) supported by the payment method.
|
73 |
icons?: null | PaymentMethodIcons;
|
74 |
// A react node that will be used as a label for the payment method in the checkout.
|
75 |
label: ReactNode;
|
assets/js/types/type-defs/product-response.ts
CHANGED
@@ -86,10 +86,12 @@ export interface ProductResponseItem {
|
|
86 |
is_on_backorder: boolean;
|
87 |
low_stock_remaining: null | number;
|
88 |
sold_individually: boolean;
|
89 |
-
quantity_limit: number;
|
90 |
add_to_cart: {
|
91 |
text: string;
|
92 |
description: string;
|
93 |
url: string;
|
|
|
|
|
|
|
94 |
};
|
95 |
}
|
86 |
is_on_backorder: boolean;
|
87 |
low_stock_remaining: null | number;
|
88 |
sold_individually: boolean;
|
|
|
89 |
add_to_cart: {
|
90 |
text: string;
|
91 |
description: string;
|
92 |
url: string;
|
93 |
+
minimum: number;
|
94 |
+
maximum: number;
|
95 |
+
multiple_of: number;
|
96 |
};
|
97 |
}
|
assets/js/utils/global-style.js
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* eslint-disable @wordpress/no-unsafe-wp-apis */
|
2 |
+
/**
|
3 |
+
* External dependencies
|
4 |
+
*/
|
5 |
+
import { __experimentalGetSpacingClassesAndStyles } from '@wordpress/block-editor';
|
6 |
+
|
7 |
+
export const hasSpacingStyleSupport = () =>
|
8 |
+
typeof __experimentalGetSpacingClassesAndStyles === 'function';
|
assets/js/utils/shared-attributes.js
CHANGED
@@ -72,4 +72,12 @@ export default {
|
|
72 |
type: 'boolean',
|
73 |
default: false,
|
74 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
};
|
72 |
type: 'boolean',
|
73 |
default: false,
|
74 |
},
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Whether to display in stock, out of stock or backorder products.
|
78 |
+
*/
|
79 |
+
stockStatus: {
|
80 |
+
type: 'array',
|
81 |
+
default: Object.keys( getSetting( 'stockStatusOptions', [] ) ),
|
82 |
+
},
|
83 |
};
|
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'), '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'), 'version' => 'df25a2ebd227f813cec2ea6dcd08a337');
|
build/active-filters-frontend.js
CHANGED
@@ -1,8 +1,8 @@
|
|
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: Remove chip. */
|
3 |
Object(l.__)("Remove","woo-gutenberg-products-block"):Object(l.sprintf)(
|
4 |
/* translators: %s text of the chip to remove. */
|
5 |
-
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:{},_=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"},_),Object(o.createElement)(i.a,{className:"wc-block-components-chip__remove-icon",srcElement:u.a,size:16})))}},17:function(e,t,r){"use strict";r.d(t,"a",(function(){return s}));var n=r(0),c=r(11),o=r.n(c);function s(e){const t=Object(n.useRef)(e);return o()(e,t.current)||(t.current=e),t.current}},
|
6 |
/* translators: %1$s min price, %2$s max price */
|
7 |
Object(o.__)("Between %1$s and %2$s","woo-gutenberg-products-block"),Object(p.formatPrice)(e),Object(p.formatPrice)(t)):Number.isFinite(e)?Object(o.sprintf)(
|
8 |
/* translators: %s min price */
|
@@ -10,4 +10,4 @@ Object(o.__)("From %s","woo-gutenberg-products-block"),Object(p.formatPrice)(e))
|
|
10 |
/* translators: %s max price */
|
11 |
Object(o.__)("Up to %s","woo-gutenberg-products-block"),Object(p.formatPrice)(t)),f=e=>{let{type:t,name:r,prefix:n,removeCallback:s=(()=>{}),showLabel:a=!0,displayStyle:l}=e;const i=n?Object(c.createElement)(c.Fragment,null,n," ",r):r,b=Object(o.sprintf)(
|
12 |
/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */
|
13 |
-
Object(o.__)("Remove %s filter","woo-gutenberg-products-block"),r);return Object(c.createElement)("li",{className:"wc-block-active-filters__list-item",key:t+":"+r},a&&Object(c.createElement)("span",{className:"wc-block-active-filters__list-item-type"},t+": "),"chips"===l?Object(c.createElement)(d.a,{element:"span",text:i,onRemove:s,radius:"large",ariaLabel:b}):Object(c.createElement)("span",{className:"wc-block-active-filters__list-item-name"},i,Object(c.createElement)("button",{className:"wc-block-active-filters__list-item-remove",onClick:s},Object(c.createElement)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Object(c.createElement)("ellipse",{cx:"8",cy:"8",rx:"8",ry:"8",transform:"rotate(-180 8 8)",fill:"currentColor",fillOpacity:"0.7"}),Object(c.createElement)("rect",{x:"10.636",y:"3.94983",width:"2",height:"9.9466",transform:"rotate(45 10.636 3.94983)",fill:"white"}),Object(c.createElement)("rect",{x:"12.0503",y:"11.0209",width:"2",height:"9.9466",transform:"rotate(135 12.0503 11.0209)",fill:"white"})),Object(c.createElement)(u.a,{screenReaderLabel:b}))))};var g=r(64),O=r(19),j=r(105),_=e=>{let{attributeObject:t={},slugs:r=[],operator:n="in",displayStyle:a}=e;const{results:l,isLoading:i}=Object(g.a)({namespace:"/wc/store",resourceName:"products/attributes/terms",resourceValues:[t.id]}),[u,b]=Object(s.b)("attributes",[]);if(i)return null;const p=t.label;return Object(c.createElement)("li",null,Object(c.createElement)("span",{className:"wc-block-active-filters__list-item-type"},p,":"),Object(c.createElement)("ul",null,r.map((e,r)=>{const s=l.find(t=>t.slug===e);if(!s)return null;let i="";return r>0&&"and"===n&&(i=Object(c.createElement)("span",{className:"wc-block-active-filters__list-item-operator"},Object(o.__)("and","woo-gutenberg-products-block"))),f({type:p,name:Object(O.decodeEntities)(s.name||e),prefix:i,removeCallback:()=>{Object(j.a)(u,b,t,e)},showLabel:!1,displayStyle:a})})))};Object(n.a)({selector:".wp-block-woocommerce-active-filters",Block:e=>{let{attributes:t,isEditor:r=!1}=e;const[n,l]=Object(s.b)("attributes",[]),[p,d]=Object(s.b)("stock_status",[]),[g,O]=Object(s.b)("min_price"),[j,y]=Object(s.b)("max_price"),w=Object(a.getSetting)("stockStatusOptions",[]),E=Object(c.useMemo)(()=>{if(p.length>0)return p.map(e=>f({type:Object(o.__)("Stock Status","woo-gutenberg-products-block"),name:w[e],removeCallback:()=>{const t=p.filter(t=>t!==e);d(t)},displayStyle:t.displayStyle}))},[w,p,d,t.displayStyle]),h=Object(c.useMemo)(()=>Number.isFinite(g)||Number.isFinite(j)?f({type:Object(o.__)("Price","woo-gutenberg-products-block"),name:m(g,j),removeCallback:()=>{O(void 0),y(void 0)},displayStyle:t.displayStyle}):null,[g,j,t.displayStyle,O,y]),v=Object(c.useMemo)(()=>n.map(e=>{const r=Object(b.b)(e.attribute);return Object(c.createElement)(_,{attributeObject:r,displayStyle:t.displayStyle,slugs:e.slug,key:e.attribute,operator:e.operator})}),[n,t.displayStyle]);if(!(n.length>0||p.length>0||Number.isFinite(g)||Number.isFinite(j)||r))return null;const k="h"+t.headingLevel,S=i()("wc-block-active-filters__list",{"wc-block-active-filters__list--chips":"chips"===t.displayStyle});return Object(c.createElement)(c.Fragment,null,!r&&t.heading&&Object(c.createElement)(k,{className:"wc-block-active-filters__title"},t.heading),Object(c.createElement)("div",{className:"wc-block-active-filters"},Object(c.createElement)("ul",{className:S},r?Object(c.createElement)(c.Fragment,null,f({type:Object(o.__)("Size","woo-gutenberg-products-block"),name:Object(o.__)("Small","woo-gutenberg-products-block"),displayStyle:t.displayStyle}),f({type:Object(o.__)("Color","woo-gutenberg-products-block"),name:Object(o.__)("Blue","woo-gutenberg-products-block"),displayStyle:t.displayStyle})):Object(c.createElement)(c.Fragment,null,h,E,v)),Object(c.createElement)("button",{className:"wc-block-active-filters__clear-all",onClick:()=>{O(void 0),y(void 0),l([]),d([])}},Object(c.createElement)(u.a,{label:Object(o.__)("Clear All","woo-gutenberg-products-block"),screenReaderLabel:Object(o.__)("Clear All Filters","woo-gutenberg-products-block")}))))},getProps:e=>({attributes:{displayStyle:e.dataset.displayStyle,heading:e.dataset.heading,headingLevel:e.dataset.headingLevel||3},isEditor:!1})})},21: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: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))}},24:function(e,t){e.exports=window.wp.primitives},25: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},3:function(e,t){e.exports=window.React},37:function(e,t){},39: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(6),c=r(9),o=r(0),s=r(11),a=r.n(s),l=r(17),i=r(62),u=r(25);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),m=Object(o.useRef)(!1);return Object(o.useEffect)(()=>{a()(d,p)||(c(Object.assign({},s,p)),m.current=!0)},[s,p,d,c]),m.current?[n,c]:[e,c]}},4: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)}()},40:function(e,t){e.exports=window.wc.priceFormat},42:function(e,t,r){"use strict";var n=r(43);function c(){}function o(){}o.resetWarningCache=c,e.exports=function(){function e(e,t,r,c,o,s){if(s!==n){var a=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function t(){return e}e.isRequired=e;var r={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:c};return r.PropTypes=r,r}},43:function(e,t,r){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},5:function(e,t){e.exports=window.lodash},53:function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(10),c=r.n(n),o=r(0),s=r(16);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})})})}},54: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})},[])}},6:function(e,t){e.exports=window.wc.wcBlocksData},62:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(3);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}},64:function(e,t,r){"use strict";r.d(t,"a",(function(){return l}));var n=r(6),c=r(9),o=r(0),s=r(17),a=r(54);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),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],s=c.getCollectionError(...o);return s&&m(s),{results:c.getCollection(...o),isLoading:!c.hasFinishedResolution("getCollection",o)}},[t,r,d,p,u]);return null!==f&&(b.current=f),b.current}},66: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 m})),r.d(t,"g",(function(){return f})),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),m=c.STORE_PAGES.myaccount.permalink?c.STORE_PAGES.myaccount.permalink:Object(c.getSetting)("wpLoginUrl","/wp-login.php"),f=Object(c.getSetting)("shippingCountries",{}),g=Object(c.getSetting)("allowedCountries",{}),O=Object(c.getSetting)("shippingStates",{}),j=Object(c.getSetting)("allowedStates",{})},8:function(e,t,r){e.exports=r(42)()},9:function(e,t){e.exports=window.wp.data},98:function(e,t,r){"use strict";var n=r(0);t.a=function(e){let{srcElement:t,size:r=24,...c}=e;return Object(n.isValidElement)(t)?Object(n.cloneElement)(t,{width:r,height:r,...c}):null}}});
|
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=188)}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},10: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.default=e.exports,e.exports.__esModule=!0,r.apply(this,arguments)}e.exports=r,e.exports.default=e.exports,e.exports.__esModule=!0},104: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.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)}},105:function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r.d(t,"b",(function(){return o}));var n=r(5);const c=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>{},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&&void 0!==arguments[1]?arguments[1]:()=>{},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";const s=e.filter(e=>e.attribute!==r.taxonomy);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")))}},11:function(e,t){e.exports=window.wp.isShallowEqual},112:function(e,t){},15: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.default=e.exports,e.exports.__esModule=!0},16:function(e,t,r){"use strict";var n=r(15),c=r.n(n),o=r(0),s=r(3),a=r(1),l=r(65),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}=e;return 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)))};r(37);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,text:n,errorMessagePrefix:c,renderError:s,button:a}=this.props,{errorMessage:l,hasError:u}=this.state;return u?"function"==typeof s?s({errorMessage:l}):Object(o.createElement)(i,{errorMessage:r?l:null,header:e,imageUrl:t,text:n,errorMessagePrefix:c,button:a}):this.props.children}}t.a=u},165:function(e,t,r){"use strict";var n=r(10),c=r.n(n),o=r(0),s=r(24);const a=Object(o.createElement)(e=>{let{className:t,size:r,...n}=e;return Object(o.createElement)(s.SVG,c()({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",className:t,width:r,height:r},n),Object(o.createElement)("path",{d:"M14.95 6.46L11.41 10l3.54 3.54-1.41 1.41L10 11.42l-3.53 3.53-1.42-1.42L8.58 10 5.05 6.47l1.42-1.42L10 8.58l3.54-3.53z"}))},null);t.a=a},168:function(e,t,r){"use strict";var n=r(10),c=r.n(n),o=r(0),s=r(4),a=r.n(s),l=r(1),i=r(98),u=r(165);r(112);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: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(l.__)("Remove","woo-gutenberg-products-block"):Object(l.sprintf)(
|
4 |
/* translators: %s text of the chip to remove. */
|
5 |
+
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:{},_=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"},_),Object(o.createElement)(i.a,{className:"wc-block-components-chip__remove-icon",srcElement:u.a,size:16})))}},17:function(e,t,r){"use strict";r.d(t,"a",(function(){return s}));var n=r(0),c=r(11),o=r.n(c);function s(e){const t=Object(n.useRef)(e);return o()(e,t.current)||(t.current=e),t.current}},188:function(e,t,r){e.exports=r(209)},189:function(e,t){},19:function(e,t){e.exports=window.wp.htmlEntities},2:function(e,t){e.exports=window.wc.wcSettings},209:function(e,t,r){"use strict";r.r(t);var n=r(53),c=r(0),o=r(1),s=r(39),a=r(2),l=r(4),i=r.n(l),u=(r(8),r(21)),b=(r(189),r(104)),p=r(40),d=r(168);const m=(e,t)=>Number.isFinite(e)&&Number.isFinite(t)?Object(o.sprintf)(
|
6 |
/* translators: %1$s min price, %2$s max price */
|
7 |
Object(o.__)("Between %1$s and %2$s","woo-gutenberg-products-block"),Object(p.formatPrice)(e),Object(p.formatPrice)(t)):Number.isFinite(e)?Object(o.sprintf)(
|
8 |
/* translators: %s min price */
|
10 |
/* translators: %s max price */
|
11 |
Object(o.__)("Up to %s","woo-gutenberg-products-block"),Object(p.formatPrice)(t)),f=e=>{let{type:t,name:r,prefix:n,removeCallback:s=(()=>{}),showLabel:a=!0,displayStyle:l}=e;const i=n?Object(c.createElement)(c.Fragment,null,n," ",r):r,b=Object(o.sprintf)(
|
12 |
/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */
|
13 |
+
Object(o.__)("Remove %s filter","woo-gutenberg-products-block"),r);return Object(c.createElement)("li",{className:"wc-block-active-filters__list-item",key:t+":"+r},a&&Object(c.createElement)("span",{className:"wc-block-active-filters__list-item-type"},t+": "),"chips"===l?Object(c.createElement)(d.a,{element:"span",text:i,onRemove:s,radius:"large",ariaLabel:b}):Object(c.createElement)("span",{className:"wc-block-active-filters__list-item-name"},i,Object(c.createElement)("button",{className:"wc-block-active-filters__list-item-remove",onClick:s},Object(c.createElement)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Object(c.createElement)("ellipse",{cx:"8",cy:"8",rx:"8",ry:"8",transform:"rotate(-180 8 8)",fill:"currentColor",fillOpacity:"0.7"}),Object(c.createElement)("rect",{x:"10.636",y:"3.94983",width:"2",height:"9.9466",transform:"rotate(45 10.636 3.94983)",fill:"white"}),Object(c.createElement)("rect",{x:"12.0503",y:"11.0209",width:"2",height:"9.9466",transform:"rotate(135 12.0503 11.0209)",fill:"white"})),Object(c.createElement)(u.a,{screenReaderLabel:b}))))};var g=r(64),O=r(19),j=r(105),_=e=>{let{attributeObject:t={},slugs:r=[],operator:n="in",displayStyle:a}=e;const{results:l,isLoading:i}=Object(g.a)({namespace:"/wc/store",resourceName:"products/attributes/terms",resourceValues:[t.id]}),[u,b]=Object(s.b)("attributes",[]);if(i)return null;const p=t.label;return Object(c.createElement)("li",null,Object(c.createElement)("span",{className:"wc-block-active-filters__list-item-type"},p,":"),Object(c.createElement)("ul",null,r.map((e,r)=>{const s=l.find(t=>t.slug===e);if(!s)return null;let i="";return r>0&&"and"===n&&(i=Object(c.createElement)("span",{className:"wc-block-active-filters__list-item-operator"},Object(o.__)("and","woo-gutenberg-products-block"))),f({type:p,name:Object(O.decodeEntities)(s.name||e),prefix:i,removeCallback:()=>{Object(j.a)(u,b,t,e)},showLabel:!1,displayStyle:a})})))};Object(n.a)({selector:".wp-block-woocommerce-active-filters",Block:e=>{let{attributes:t,isEditor:r=!1}=e;const[n,l]=Object(s.b)("attributes",[]),[p,d]=Object(s.b)("stock_status",[]),[g,O]=Object(s.b)("min_price"),[j,y]=Object(s.b)("max_price"),w=Object(a.getSetting)("stockStatusOptions",[]),E=Object(c.useMemo)(()=>{if(p.length>0)return p.map(e=>f({type:Object(o.__)("Stock Status","woo-gutenberg-products-block"),name:w[e],removeCallback:()=>{const t=p.filter(t=>t!==e);d(t)},displayStyle:t.displayStyle}))},[w,p,d,t.displayStyle]),h=Object(c.useMemo)(()=>Number.isFinite(g)||Number.isFinite(j)?f({type:Object(o.__)("Price","woo-gutenberg-products-block"),name:m(g,j),removeCallback:()=>{O(void 0),y(void 0)},displayStyle:t.displayStyle}):null,[g,j,t.displayStyle,O,y]),v=Object(c.useMemo)(()=>n.map(e=>{const r=Object(b.b)(e.attribute);return Object(c.createElement)(_,{attributeObject:r,displayStyle:t.displayStyle,slugs:e.slug,key:e.attribute,operator:e.operator})}),[n,t.displayStyle]);if(!(n.length>0||p.length>0||Number.isFinite(g)||Number.isFinite(j)||r))return null;const k="h"+t.headingLevel,S=i()("wc-block-active-filters__list",{"wc-block-active-filters__list--chips":"chips"===t.displayStyle});return Object(c.createElement)(c.Fragment,null,!r&&t.heading&&Object(c.createElement)(k,{className:"wc-block-active-filters__title"},t.heading),Object(c.createElement)("div",{className:"wc-block-active-filters"},Object(c.createElement)("ul",{className:S},r?Object(c.createElement)(c.Fragment,null,f({type:Object(o.__)("Size","woo-gutenberg-products-block"),name:Object(o.__)("Small","woo-gutenberg-products-block"),displayStyle:t.displayStyle}),f({type:Object(o.__)("Color","woo-gutenberg-products-block"),name:Object(o.__)("Blue","woo-gutenberg-products-block"),displayStyle:t.displayStyle})):Object(c.createElement)(c.Fragment,null,h,E,v)),Object(c.createElement)("button",{className:"wc-block-active-filters__clear-all",onClick:()=>{O(void 0),y(void 0),l([]),d([])}},Object(c.createElement)(u.a,{label:Object(o.__)("Clear All","woo-gutenberg-products-block"),screenReaderLabel:Object(o.__)("Clear All Filters","woo-gutenberg-products-block")}))))},getProps:e=>({attributes:{displayStyle:e.dataset.displayStyle,heading:e.dataset.heading,headingLevel:e.dataset.headingLevel||3},isEditor:!1})})},21: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: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))}},24:function(e,t){e.exports=window.wp.primitives},25: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},3:function(e,t){e.exports=window.React},37:function(e,t){},39: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(6),c=r(9),o=r(0),s=r(11),a=r.n(s),l=r(17),i=r(62),u=r(25);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),m=Object(o.useRef)(!1);return Object(o.useEffect)(()=>{a()(d,p)||(c(Object.assign({},s,p)),m.current=!0)},[s,p,d,c]),m.current?[n,c]:[e,c]}},4: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)}()},40:function(e,t){e.exports=window.wc.priceFormat},42:function(e,t,r){"use strict";var n=r(43);function c(){}function o(){}o.resetWarningCache=c,e.exports=function(){function e(e,t,r,c,o,s){if(s!==n){var a=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function t(){return e}e.isRequired=e;var r={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:c};return r.PropTypes=r,r}},43:function(e,t,r){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},5:function(e,t){e.exports=window.lodash},53:function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(10),c=r.n(n),o=r(0),s=r(16);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})})})}},54: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})},[])}},6:function(e,t){e.exports=window.wc.wcBlocksData},62:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(3);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}},64:function(e,t,r){"use strict";r.d(t,"a",(function(){return l}));var n=r(6),c=r(9),o=r(0),s=r(17),a=r(54);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),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],s=c.getCollectionError(...o);return s&&m(s),{results:c.getCollection(...o),isLoading:!c.hasFinishedResolution("getCollection",o)}},[t,r,d,p,u]);return null!==f&&(b.current=f),b.current}},65: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 m})),r.d(t,"g",(function(){return f})),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),m=c.STORE_PAGES.myaccount.permalink?c.STORE_PAGES.myaccount.permalink:Object(c.getSetting)("wpLoginUrl","/wp-login.php"),f=Object(c.getSetting)("shippingCountries",{}),g=Object(c.getSetting)("allowedCountries",{}),O=Object(c.getSetting)("shippingStates",{}),j=Object(c.getSetting)("allowedStates",{})},8:function(e,t,r){e.exports=r(42)()},9:function(e,t){e.exports=window.wp.data},98:function(e,t,r){"use strict";var n=r(0);t.a=function(e){let{srcElement:t,size:r=24,...c}=e;return Object(n.isValidElement)(t)?Object(n.cloneElement)(t,{width:r,height:r,...c}):null}}});
|
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'), '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'), 'version' => '9fdde02f04329baf3176e79fd1bc8c70');
|
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,o,a=t[0],s=t[1],i=t[2],b=0,p=[];b<a.length;b++)o=a[b],Object.prototype.hasOwnProperty.call(r,o)&&r[o]&&p.push(r[o][0]),r[o]=0;for(n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n]);for(u&&u(t);p.length;)p.shift()();return l.push.apply(l,i||[]),c()}function c(){for(var e,t=0;t<l.length;t++){for(var c=l[t],n=!0,a=1;a<c.length;a++){var s=c[a];0!==r[s]&&(n=!1)}n&&(l.splice(t--,1),e=o(o.s=c[0]))}return e}var n={},r={
|
2 |
/* translators: Remove chip. */
|
3 |
Object(s.__)("Remove","woo-gutenberg-products-block"):Object(s.sprintf)(
|
4 |
/* translators: %s text of the chip to remove. */
|
5 |
-
Object(s.__)('Remove "%s"',"woo-gutenberg-products-block"),e)}const g={"aria-label":t,disabled:n,onClick:o,onKeyDown:e=>{"Backspace"!==e.key&&"Delete"!==e.key||o()}},j=p?g:{},v=p?{"aria-hidden":!0}:g;return Object(l.createElement)(b,r()({},h,j,{className:a()(c,"is-removable"),element:p?"button":h.element,screenReaderText:d,text:m}),Object(l.createElement)(O,r()({className:"wc-block-components-chip__remove"},v),Object(l.createElement)(i.a,{className:"wc-block-components-chip__remove-icon",srcElement:u.a,size:16})))}},2:function(e,t){e.exports=window.wc.wcSettings},
|
6 |
/* translators: %1$s min price, %2$s max price */
|
7 |
Object(o.__)("Between %1$s and %2$s","woo-gutenberg-products-block"),Object(_.formatPrice)(e),Object(_.formatPrice)(t)):Number.isFinite(e)?Object(o.sprintf)(
|
8 |
/* translators: %s min price */
|
@@ -10,8 +10,8 @@ Object(o.__)("From %s","woo-gutenberg-products-block"),Object(_.formatPrice)(e))
|
|
10 |
/* translators: %s max price */
|
11 |
Object(o.__)("Up to %s","woo-gutenberg-products-block"),Object(_.formatPrice)(t)),k=e=>{let{type:t,name:c,prefix:n,removeCallback:r=(()=>{}),showLabel:a=!0,displayStyle:s}=e;const i=n?Object(l.createElement)(l.Fragment,null,n," ",c):c,u=Object(o.sprintf)(
|
12 |
/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */
|
13 |
-
Object(o.__)("Remove %s filter","woo-gutenberg-products-block"),c);return Object(l.createElement)("li",{className:"wc-block-active-filters__list-item",key:t+":"+c},a&&Object(l.createElement)("span",{className:"wc-block-active-filters__list-item-type"},t+": "),"chips"===s?Object(l.createElement)(y.a,{element:"span",text:i,onRemove:r,radius:"large",ariaLabel:u}):Object(l.createElement)("span",{className:"wc-block-active-filters__list-item-name"},i,Object(l.createElement)("button",{className:"wc-block-active-filters__list-item-remove",onClick:r},Object(l.createElement)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Object(l.createElement)("ellipse",{cx:"8",cy:"8",rx:"8",ry:"8",transform:"rotate(-180 8 8)",fill:"currentColor",fillOpacity:"0.7"}),Object(l.createElement)("rect",{x:"10.636",y:"3.94983",width:"2",height:"9.9466",transform:"rotate(45 10.636 3.94983)",fill:"white"}),Object(l.createElement)("rect",{x:"12.0503",y:"11.0209",width:"2",height:"9.9466",transform:"rotate(135 12.0503 11.0209)",fill:"white"})),Object(l.createElement)(f.a,{screenReaderLabel:u}))))};var x=c(
|
14 |
/* translators: "Chips" is a tag-like display style for chosen attributes. */
|
15 |
-
label:Object(o.__)("Chips","woo-gutenberg-products-block"),value:"chips"}],onChange:e=>c({displayStyle:e})}),Object(l.createElement)("p",null,Object(o.__)("Heading Level","woo-gutenberg-products-block")),Object(l.createElement)(h.a,{isCollapsed:!1,minLevel:2,maxLevel:7,selectedLevel:s,onChange:e=>c({headingLevel:e})}))),Object(l.createElement)(O.a,{className:"wc-block-active-filters__title",headingLevel:s,heading:a,onChange:e=>c({heading:e})}),Object(l.createElement)(d.Disabled,null,Object(l.createElement)(L,{attributes:t,isEditor:!0})))});Object(a.registerBlockType)("woocommerce/active-filters",{apiVersion:2,title:Object(o.__)("Active Product Filters","woo-gutenberg-products-block"),icon:{src:Object(l.createElement)(s.a,{srcElement:u,className:"wc-block-editor-components-block-icon"})},category:"woocommerce",keywords:[Object(o.__)("WooCommerce","woo-gutenberg-products-block")],description:Object(o.__)("Show the currently active product filters. Works in combination with the All Products and filters blocks.","woo-gutenberg-products-block"),supports:{html:!1,multiple:!1,color:{text:!0,background:!1}},example:{attributes:{}},attributes:{displayStyle:{type:"string",default:"list"},heading:{type:"string",default:Object(o.__)("Active filters","woo-gutenberg-products-block")},headingLevel:{type:"number",default:3}},edit:V,save(e){let{attributes:t}=e;const{className:c,displayStyle:n,heading:o,headingLevel:a}=t,s={"data-display-style":n,"data-heading":o,"data-heading-level":a};return Object(l.createElement)("div",r()({},m.useBlockProps.save({className:p()("is-loading",c)}),s),Object(l.createElement)("span",{"aria-hidden":!0,className:"wc-block-active-product-filters__placeholder"}))}})},48:function(e,t,c){"use strict";c.d(t,"a",(function(){return l}));var n=c(0);const r=Object(n.createContext)("page"),l=()=>Object(n.useContext)(r);r.Provider},55:function(e,t,c){"use strict";var n=c(5),r=c.n(n),l=c(0),o=c(6),a=c(4),s=c.n(a),i=c(3),u=c(9);c(
|
16 |
/* translators: %s: heading level e.g: "2", "3", "4" */
|
17 |
-
Object(l.__)("Heading %d","woo-gutenberg-products-block"),e),isActive:r,onClick:()=>c(e)}}render(){const{isCollapsed:e=!0,minLevel:t,maxLevel:c,selectedLevel:l,onChange:s}=this.props;return Object(n.createElement)(o.ToolbarGroup,{isCollapsed:e,icon:Object(n.createElement)(a,{level:l}),controls:Object(r.range)(t,c).map(e=>this.createLevelControl(e,l,s))})}}t.a=s},
|
1 |
+
this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["active-filters"]=function(e){function t(t){for(var n,o,a=t[0],s=t[1],i=t[2],b=0,p=[];b<a.length;b++)o=a[b],Object.prototype.hasOwnProperty.call(r,o)&&r[o]&&p.push(r[o][0]),r[o]=0;for(n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n]);for(u&&u(t);p.length;)p.shift()();return l.push.apply(l,i||[]),c()}function c(){for(var e,t=0;t<l.length;t++){for(var c=l[t],n=!0,a=1;a<c.length;a++){var s=c[a];0!==r[s]&&(n=!1)}n&&(l.splice(t--,1),e=o(o.s=c[0]))}return e}var n={},r={6:0},l=[];function o(t){if(n[t])return n[t].exports;var c=n[t]={i:t,l:!1,exports:{}};return e[t].call(c.exports,c,c.exports,o),c.l=!0,c.exports}o.m=e,o.c=n,o.d=function(e,t,c){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:c})},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 c=Object.create(null);if(o.r(c),Object.defineProperty(c,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)o.d(c,n,function(t){return e[t]}.bind(null,n));return c},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="";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 l.push([382,0]),c()}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},107:function(e,t,c){"use strict";var n=c(0),r=(c(10),c(7)),l=c(9),o=c(1);c(145),t.a=Object(l.withInstanceId)(e=>{let{className:t,headingLevel:c,onChange:l,heading:a,instanceId:s}=e;const i="h"+c;return Object(n.createElement)(i,{className:t},Object(n.createElement)("label",{className:"screen-reader-text",htmlFor:"block-title-"+s},Object(o.__)("Block title","woo-gutenberg-products-block")),Object(n.createElement)(r.PlainText,{id:"block-title-"+s,className:"wc-block-editor-components-title",value:a,onChange:l}))})},109:function(e,t,c){"use strict";c.d(t,"a",(function(){return r}));var n=c(8);function r(e,t){const c=Object(n.useRef)();return Object(n.useEffect)(()=>{c.current===e||t&&!t(e,c.current)||(c.current=e)},[e,t]),c.current}},115:function(e,t,c){"use strict";c.d(t,"a",(function(){return s}));var n=c(16),r=c(13),l=c(0),o=c(39),a=c(94);const s=e=>{const{namespace:t,resourceName:c,resourceValues:s=[],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 b=Object(l.useRef)({results:[],isLoading:!0}),p=Object(o.a)(i),m=Object(o.a)(s),d=Object(a.a)(),h=Object(r.useSelect)(e=>{if(!u)return null;const r=e(n.COLLECTIONS_STORE_KEY),l=[t,c,p,m],o=r.getCollectionError(...l);return o&&d(o),{results:r.getCollection(...l),isLoading:!r.hasFinishedResolution("getCollection",l)}},[t,c,m,p,u]);return null!==h&&(b.current=h),b.current}},12:function(e,t){e.exports=window.wp.blocks},13:function(e,t){e.exports=window.wp.data},14:function(e,t){e.exports=window.wp.htmlEntities},145:function(e,t){},146:function(e,t){},16:function(e,t){e.exports=window.wc.wcBlocksData},177:function(e,t,c){"use strict";c.d(t,"a",(function(){return l})),c.d(t,"b",(function(){return o}));var n=c(2);const r=Object(n.getSetting)("attributes",[]).reduce((e,t)=>{const c=(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 c.id&&e.push(c),e},[]),l=e=>{if(e)return r.find(t=>t.id===e)},o=e=>{if(e)return r.find(t=>t.taxonomy===e)}},178:function(e,t,c){"use strict";c.d(t,"a",(function(){return r})),c.d(t,"b",(function(){return l}));var n=c(6);const r=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>{},c=arguments.length>2?arguments[2]:void 0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";const l=e.filter(e=>e.attribute===c.taxonomy),o=l.length?l[0]:null;if(!(o&&o.slug&&Array.isArray(o.slug)&&o.slug.includes(r)))return;const a=o.slug.filter(e=>e!==r),s=e.filter(e=>e.attribute!==c.taxonomy);a.length>0&&(o.slug=a.sort(),s.push(o)),t(Object(n.sortBy)(s,"attribute"))},l=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>{},c=arguments.length>2?arguments[2]:void 0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"in";const o=e.filter(e=>e.attribute!==c.taxonomy);0===r.length?t(o):(o.push({attribute:c.taxonomy,operator:l,slug:r.map(e=>{let{slug:t}=e;return t}).sort()}),t(Object(n.sortBy)(o,"attribute")))}},18:function(e,t){e.exports=window.wp.primitives},187:function(e,t,c){"use strict";var n=c(5),r=c.n(n),l=c(0),o=c(4),a=c.n(o),s=c(1),i=c(43),u=c(211);c(146);var b=e=>{let{text:t,screenReaderText:c="",element:n="li",className:o="",radius:s="small",children:i=null,...u}=e;const b=n,p=a()(o,"wc-block-components-chip","wc-block-components-chip--radius-"+s),m=Boolean(c&&c!==t);return Object(l.createElement)(b,r()({className:p},u),Object(l.createElement)("span",{"aria-hidden":m,className:"wc-block-components-chip__text"},t),m&&Object(l.createElement)("span",{className:"screen-reader-text"},c),i)};t.a=e=>{let{ariaLabel:t="",className:c="",disabled:n=!1,onRemove:o=(()=>{}),removeOnAnyClick:p=!1,text:m,screenReaderText:d="",...h}=e;const O=p?"span":"button";if(!t){const e=d&&"string"==typeof d?d:m;t="string"!=typeof e?
|
2 |
/* translators: Remove chip. */
|
3 |
Object(s.__)("Remove","woo-gutenberg-products-block"):Object(s.sprintf)(
|
4 |
/* translators: %s text of the chip to remove. */
|
5 |
+
Object(s.__)('Remove "%s"',"woo-gutenberg-products-block"),e)}const g={"aria-label":t,disabled:n,onClick:o,onKeyDown:e=>{"Backspace"!==e.key&&"Delete"!==e.key||o()}},j=p?g:{},v=p?{"aria-hidden":!0}:g;return Object(l.createElement)(b,r()({},h,j,{className:a()(c,"is-removable"),element:p?"button":h.element,screenReaderText:d,text:m}),Object(l.createElement)(O,r()({className:"wc-block-components-chip__remove"},v),Object(l.createElement)(i.a,{className:"wc-block-components-chip__remove-icon",srcElement:u.a,size:16})))}},2:function(e,t){e.exports=window.wc.wcSettings},211:function(e,t,c){"use strict";var n=c(5),r=c.n(n),l=c(0),o=c(18);const a=Object(l.createElement)(e=>{let{className:t,size:c,...n}=e;return Object(l.createElement)(o.SVG,r()({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",className:t,width:c,height:c},n),Object(l.createElement)("path",{d:"M14.95 6.46L11.41 10l3.54 3.54-1.41 1.41L10 11.42l-3.53 3.53-1.42-1.42L8.58 10 5.05 6.47l1.42-1.42L10 8.58l3.54-3.53z"}))},null);t.a=a},26:function(e,t){e.exports=window.wp.isShallowEqual},3:function(e,t){e.exports=window.wp.components},30:function(e,t,c){"use strict";var n=c(0),r=c(4),l=c.n(r);t.a=e=>{let t,{label:c,screenReaderLabel:r,wrapperElement:o,wrapperProps:a={}}=e;const s=null!=c,i=null!=r;return!s&&i?(t=o||"span",a={...a,className:l()(a.className,"screen-reader-text")},Object(n.createElement)(t,a,r)):(t=o||n.Fragment,s&&i&&c!==r?Object(n.createElement)(t,a,Object(n.createElement)("span",{"aria-hidden":"true"},c),Object(n.createElement)("span",{className:"screen-reader-text"},r)):Object(n.createElement)(t,a,c))}},35:function(e,t){e.exports=window.wc.priceFormat},382:function(e,t,c){e.exports=c(448)},383:function(e,t){},39:function(e,t,c){"use strict";c.d(t,"a",(function(){return o}));var n=c(0),r=c(26),l=c.n(r);function o(e){const t=Object(n.useRef)(e);return l()(e,t.current)||(t.current=e),t.current}},43:function(e,t,c){"use strict";var n=c(0);t.a=function(e){let{srcElement:t,size:c=24,...r}=e;return Object(n.isValidElement)(t)?Object(n.cloneElement)(t,{width:c,height:c,...r}):null}},448:function(e,t,c){"use strict";c.r(t);var n=c(5),r=c.n(n),l=c(0),o=c(1),a=c(12),s=c(43),i=c(18),u=Object(l.createElement)(i.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(l.createElement)("path",{fill:"none",d:"M0 0h24v24H0z"}),Object(l.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"})),b=c(4),p=c.n(b),m=c(7),d=c(3),h=c(90),O=c(107),g=c(55),j=c(73),v=c(2),f=(c(10),c(30)),w=(c(383),c(177)),_=c(35),y=c(187);const E=(e,t)=>Number.isFinite(e)&&Number.isFinite(t)?Object(o.sprintf)(
|
6 |
/* translators: %1$s min price, %2$s max price */
|
7 |
Object(o.__)("Between %1$s and %2$s","woo-gutenberg-products-block"),Object(_.formatPrice)(e),Object(_.formatPrice)(t)):Number.isFinite(e)?Object(o.sprintf)(
|
8 |
/* translators: %s min price */
|
10 |
/* translators: %s max price */
|
11 |
Object(o.__)("Up to %s","woo-gutenberg-products-block"),Object(_.formatPrice)(t)),k=e=>{let{type:t,name:c,prefix:n,removeCallback:r=(()=>{}),showLabel:a=!0,displayStyle:s}=e;const i=n?Object(l.createElement)(l.Fragment,null,n," ",c):c,u=Object(o.sprintf)(
|
12 |
/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */
|
13 |
+
Object(o.__)("Remove %s filter","woo-gutenberg-products-block"),c);return Object(l.createElement)("li",{className:"wc-block-active-filters__list-item",key:t+":"+c},a&&Object(l.createElement)("span",{className:"wc-block-active-filters__list-item-type"},t+": "),"chips"===s?Object(l.createElement)(y.a,{element:"span",text:i,onRemove:r,radius:"large",ariaLabel:u}):Object(l.createElement)("span",{className:"wc-block-active-filters__list-item-name"},i,Object(l.createElement)("button",{className:"wc-block-active-filters__list-item-remove",onClick:r},Object(l.createElement)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Object(l.createElement)("ellipse",{cx:"8",cy:"8",rx:"8",ry:"8",transform:"rotate(-180 8 8)",fill:"currentColor",fillOpacity:"0.7"}),Object(l.createElement)("rect",{x:"10.636",y:"3.94983",width:"2",height:"9.9466",transform:"rotate(45 10.636 3.94983)",fill:"white"}),Object(l.createElement)("rect",{x:"12.0503",y:"11.0209",width:"2",height:"9.9466",transform:"rotate(135 12.0503 11.0209)",fill:"white"})),Object(l.createElement)(f.a,{screenReaderLabel:u}))))};var x=c(115),S=c(14),C=c(178),N=e=>{let{attributeObject:t={},slugs:c=[],operator:n="in",displayStyle:r}=e;const{results:a,isLoading:s}=Object(x.a)({namespace:"/wc/store",resourceName:"products/attributes/terms",resourceValues:[t.id]}),[i,u]=Object(j.b)("attributes",[]);if(s)return null;const b=t.label;return Object(l.createElement)("li",null,Object(l.createElement)("span",{className:"wc-block-active-filters__list-item-type"},b,":"),Object(l.createElement)("ul",null,c.map((e,c)=>{const s=a.find(t=>t.slug===e);if(!s)return null;let p="";return c>0&&"and"===n&&(p=Object(l.createElement)("span",{className:"wc-block-active-filters__list-item-operator"},Object(o.__)("and","woo-gutenberg-products-block"))),k({type:b,name:Object(S.decodeEntities)(s.name||e),prefix:p,removeCallback:()=>{Object(C.a)(i,u,t,e)},showLabel:!1,displayStyle:r})})))},L=e=>{let{attributes:t,isEditor:c=!1}=e;const[n,r]=Object(j.b)("attributes",[]),[a,s]=Object(j.b)("stock_status",[]),[i,u]=Object(j.b)("min_price"),[b,m]=Object(j.b)("max_price"),d=Object(v.getSetting)("stockStatusOptions",[]),h=Object(l.useMemo)(()=>{if(a.length>0)return a.map(e=>k({type:Object(o.__)("Stock Status","woo-gutenberg-products-block"),name:d[e],removeCallback:()=>{const t=a.filter(t=>t!==e);s(t)},displayStyle:t.displayStyle}))},[d,a,s,t.displayStyle]),O=Object(l.useMemo)(()=>Number.isFinite(i)||Number.isFinite(b)?k({type:Object(o.__)("Price","woo-gutenberg-products-block"),name:E(i,b),removeCallback:()=>{u(void 0),m(void 0)},displayStyle:t.displayStyle}):null,[i,b,t.displayStyle,u,m]),g=Object(l.useMemo)(()=>n.map(e=>{const c=Object(w.b)(e.attribute);return Object(l.createElement)(N,{attributeObject:c,displayStyle:t.displayStyle,slugs:e.slug,key:e.attribute,operator:e.operator})}),[n,t.displayStyle]);if(!(n.length>0||a.length>0||Number.isFinite(i)||Number.isFinite(b)||c))return null;const _="h"+t.headingLevel,y=p()("wc-block-active-filters__list",{"wc-block-active-filters__list--chips":"chips"===t.displayStyle});return Object(l.createElement)(l.Fragment,null,!c&&t.heading&&Object(l.createElement)(_,{className:"wc-block-active-filters__title"},t.heading),Object(l.createElement)("div",{className:"wc-block-active-filters"},Object(l.createElement)("ul",{className:y},c?Object(l.createElement)(l.Fragment,null,k({type:Object(o.__)("Size","woo-gutenberg-products-block"),name:Object(o.__)("Small","woo-gutenberg-products-block"),displayStyle:t.displayStyle}),k({type:Object(o.__)("Color","woo-gutenberg-products-block"),name:Object(o.__)("Blue","woo-gutenberg-products-block"),displayStyle:t.displayStyle})):Object(l.createElement)(l.Fragment,null,O,h,g)),Object(l.createElement)("button",{className:"wc-block-active-filters__clear-all",onClick:()=>{u(void 0),m(void 0),r([]),s([])}},Object(l.createElement)(f.a,{label:Object(o.__)("Clear All","woo-gutenberg-products-block"),screenReaderLabel:Object(o.__)("Clear All Filters","woo-gutenberg-products-block")}))))},V=Object(d.withSpokenMessages)(e=>{let{attributes:t,setAttributes:c}=e;const{className:n,displayStyle:r,heading:a,headingLevel:s}=t,i=Object(m.useBlockProps)({className:n});return Object(l.createElement)("div",i,Object(l.createElement)(m.InspectorControls,{key:"inspector"},Object(l.createElement)(d.PanelBody,{title:Object(o.__)("Block Settings","woo-gutenberg-products-block")},Object(l.createElement)(g.a,{label:Object(o.__)("Display Style","woo-gutenberg-products-block"),value:r,options:[{label:Object(o.__)("List","woo-gutenberg-products-block"),value:"list"},{
|
14 |
/* translators: "Chips" is a tag-like display style for chosen attributes. */
|
15 |
+
label:Object(o.__)("Chips","woo-gutenberg-products-block"),value:"chips"}],onChange:e=>c({displayStyle:e})}),Object(l.createElement)("p",null,Object(o.__)("Heading Level","woo-gutenberg-products-block")),Object(l.createElement)(h.a,{isCollapsed:!1,minLevel:2,maxLevel:7,selectedLevel:s,onChange:e=>c({headingLevel:e})}))),Object(l.createElement)(O.a,{className:"wc-block-active-filters__title",headingLevel:s,heading:a,onChange:e=>c({heading:e})}),Object(l.createElement)(d.Disabled,null,Object(l.createElement)(L,{attributes:t,isEditor:!0})))});Object(a.registerBlockType)("woocommerce/active-filters",{apiVersion:2,title:Object(o.__)("Active Product Filters","woo-gutenberg-products-block"),icon:{src:Object(l.createElement)(s.a,{srcElement:u,className:"wc-block-editor-components-block-icon"})},category:"woocommerce",keywords:[Object(o.__)("WooCommerce","woo-gutenberg-products-block")],description:Object(o.__)("Show the currently active product filters. Works in combination with the All Products and filters blocks.","woo-gutenberg-products-block"),supports:{html:!1,multiple:!1,color:{text:!0,background:!1}},example:{attributes:{}},attributes:{displayStyle:{type:"string",default:"list"},heading:{type:"string",default:Object(o.__)("Active filters","woo-gutenberg-products-block")},headingLevel:{type:"number",default:3}},edit:V,save(e){let{attributes:t}=e;const{className:c,displayStyle:n,heading:o,headingLevel:a}=t,s={"data-display-style":n,"data-heading":o,"data-heading-level":a};return Object(l.createElement)("div",r()({},m.useBlockProps.save({className:p()("is-loading",c)}),s),Object(l.createElement)("span",{"aria-hidden":!0,className:"wc-block-active-product-filters__placeholder"}))}})},48:function(e,t,c){"use strict";c.d(t,"a",(function(){return l}));var n=c(0);const r=Object(n.createContext)("page"),l=()=>Object(n.useContext)(r);r.Provider},55:function(e,t,c){"use strict";var n=c(5),r=c.n(n),l=c(0),o=c(6),a=c(4),s=c.n(a),i=c(3),u=c(9);c(84);class b extends l.Component{constructor(){super(...arguments),this.onClick=this.onClick.bind(this)}onClick(e){this.props.onChange&&this.props.onChange(e.target.value)}render(){const{label:e,checked:t,instanceId:c,className:n,help:a,options:u,value:b}=this.props,p="inspector-toggle-button-control-"+c;let m;return a&&(m=Object(o.isFunction)(a)?a(t):a),Object(l.createElement)(i.BaseControl,{id:p,help:m,className:s()("components-toggle-button-control",n)},Object(l.createElement)("label",{id:p+"__label",htmlFor:p,className:"components-toggle-button-control__label"},e),Object(l.createElement)(i.ButtonGroup,{"aria-labelledby":p+"__label"},u.map((t,c)=>{const n={};return b===t.value?(n.isPrimary=!0,n["aria-pressed"]=!0):(n.isSecondary=!0,n["aria-pressed"]=!1),Object(l.createElement)(i.Button,r()({key:`${t.label}-${t.value}-${c}`,value:t.value,onClick:this.onClick,"aria-label":e+": "+t.label},n),t.label)})))}}t.a=Object(u.withInstanceId)(b)},6:function(e,t){e.exports=window.lodash},7:function(e,t){e.exports=window.wp.blockEditor},73:function(e,t,c){"use strict";c.d(t,"a",(function(){return b})),c.d(t,"b",(function(){return p})),c.d(t,"c",(function(){return m}));var n=c(16),r=c(13),l=c(0),o=c(26),a=c.n(o),s=c(39),i=c(109),u=c(48);const b=e=>{const t=Object(u.a)();e=e||t;const c=Object(r.useSelect)(t=>t(n.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0),[e]),{setValueForQueryContext:o}=Object(r.useDispatch)(n.QUERY_STATE_STORE_KEY);return[c,Object(l.useCallback)(t=>{o(e,t)},[e,o])]},p=(e,t,c)=>{const o=Object(u.a)();c=c||o;const a=Object(r.useSelect)(r=>r(n.QUERY_STATE_STORE_KEY).getValueForQueryKey(c,e,t),[c,e]),{setQueryValue:s}=Object(r.useDispatch)(n.QUERY_STATE_STORE_KEY);return[a,Object(l.useCallback)(t=>{s(c,e,t)},[c,e,s])]},m=(e,t)=>{const c=Object(u.a)();t=t||c;const[n,r]=b(t),o=Object(s.a)(n),p=Object(s.a)(e),m=Object(i.a)(p),d=Object(l.useRef)(!1);return Object(l.useEffect)(()=>{a()(m,p)||(r(Object.assign({},o,p)),d.current=!0)},[o,p,m,r]),d.current?[n,r]:[e,r]}},8:function(e,t){e.exports=window.React},84:function(e,t){},9:function(e,t){e.exports=window.wp.compose},90:function(e,t,c){"use strict";var n=c(0),r=c(6),l=c(1),o=c(3);function a(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(n.createElement)(o.SVG,{width:"20",height:"20",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg"},Object(n.createElement)(o.Path,{d:c[t]})):null}class s extends n.Component{createLevelControl(e,t,c){const r=e===t;return{icon:Object(n.createElement)(a,{level:e}),title:Object(l.sprintf)(
|
16 |
/* translators: %s: heading level e.g: "2", "3", "4" */
|
17 |
+
Object(l.__)("Heading %d","woo-gutenberg-products-block"),e),isActive:r,onClick:()=>c(e)}}render(){const{isCollapsed:e=!0,minLevel:t,maxLevel:c,selectedLevel:l,onChange:s}=this.props;return Object(n.createElement)(o.ToolbarGroup,{isCollapsed:e,icon:Object(n.createElement)(a,{level:l}),controls:Object(r.range)(t,c).map(e=>this.createLevelControl(e,l,s))})}}t.a=s},94:function(e,t,c){"use strict";c.d(t,"a",(function(){return r}));var n=c(0);const r=()=>{const[,e]=Object(n.useState)();return Object(n.useCallback)(t=>{e(()=>{throw t})},[])}}});
|
build/all-products-frontend.asset.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php return array('dependencies' => array('lodash', 'react', 'wc-blocks-data-store', 'wc-blocks-registry', 'wc-blocks-shared-context', 'wc-blocks-shared-hocs', 'wc-price-format', 'wc-settings', 'wp-a11y', 'wp-api-fetch', 'wp-autop', 'wp-block-editor', 'wp-blocks', 'wp-compose', 'wp-data', 'wp-deprecated', 'wp-dom', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-polyfill', 'wp-primitives', 'wp-url', 'wp-warning', 'wp-wordcount'), 'version' => '
|
1 |
+
<?php return array('dependencies' => array('lodash', 'react', 'wc-blocks-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' => 'ac6a936bf1b5a81728568cbf8f5acf74');
|
build/all-products-frontend.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
!function(e){function t(t){for(var n,o,c=t[0],i=t[1],s=0,l=[];s<c.length;s++)o=c[s],Object.prototype.hasOwnProperty.call(r,o)&&r[o]&&l.push(r[o][0]),r[o]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(a&&a(t);l.length;)l.shift()()}var n={},r={6:0};function o(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.e=function(e){var t=[],n=r[e];if(0!==n)if(n)t.push(n[2]);else{var c=new Promise((function(t,o){n=r[e]=[t,o]}));t.push(n[2]=c);var i,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--atomic-block-components/add-to-cart--cart-blocks/order-summary--checkout-blocks/billing-ad--c5eb4dcd",1:"vendors--atomic-block-components/price--cart-blocks/line-items--cart-blocks/order-summary--checkout--8a3571de",7:"atomic-block-components/add-to-cart",8:"atomic-block-components/button",9:"atomic-block-components/category-list",10:"atomic-block-components/image",11:"atomic-block-components/price",12:"atomic-block-components/rating",13:"atomic-block-components/sale-badge",14:"atomic-block-components/sku",15:"atomic-block-components/stock-indicator",16:"atomic-block-components/summary",17:"atomic-block-components/tag-list",18:"atomic-block-components/title",49:"vendors--atomic-block-components/add-to-cart"}[e]||e)+"-frontend.js?ver="+{0:"fb983e1d9994b68edd82",1:"44e8b4583ef14d0d1fdc",7:"f132a23ade73b803522e",8:"8e7a5544870b665defb5",9:"3f8074d0e7db651febca",10:"3377f0b7213ff71a006c",11:"366351b5fd3a6b3bef95",12:"3ea20ab900682ddc917c",13:"7d43d9e8bbe815f45170",14:"ba88ee30076573191984",15:"b7623c67c2c138d83711",16:"ec17571f77dd2a656dfa",17:"c543418586f811917b3f",18:"4f17b95bae493f6caf14",49:"e30330e4d478ac79b327"}[e]}(e);var a=new Error;i=function(t){s.onerror=s.onload=null,clearTimeout(l);var n=r[e];if(0!==n){if(n){var o=t&&("load"===t.type?"missing":t.type),c=t&&t.target&&t.target.src;a.message="Loading chunk "+e+" failed.\n("+o+": "+c+")",a.name="ChunkLoadError",a.type=o,a.request=c,n[1](a)}r[e]=void 0}};var l=setTimeout((function(){i({type:"timeout",target:s})}),12e4);s.onerror=s.onload=i,document.head.appendChild(s)}return Promise.all(t)},o.m=e,o.c=n,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)o.d(n,r,function(t){return e[t]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o.oe=function(e){throw console.error(e),e};var c=window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[],i=c.push.bind(c);c.push=t,c=c.slice();for(var s=0;s<c.length;s++)t(c[s]);var a=i;o(o.s=175)}([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.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 c=typeof r;if("string"===c||"number"===c)e.push(r);else if(Array.isArray(r)){if(r.length){var i=o.apply(null,r);i&&e.push(i)}}else if("object"===c)if(r.toString===Object.prototype.toString)for(var s in r)n.call(r,s)&&r[s]&&e.push(s);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.wcBlocksData},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,n){e.exports=n(42)()},function(e,t){e.exports=window.wp.data},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.default=e.exports,e.exports.__esModule=!0,n.apply(this,arguments)}e.exports=n,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=window.wp.isShallowEqual},function(e,t){e.exports=window.wp.compose},,function(e,t){e.exports=window.wc.wcBlocksRegistry},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.default=e.exports,e.exports.__esModule=!0},function(e,t,n){"use strict";var r=n(15),o=n.n(r),c=n(0),i=n(3),s=n(1),a=n(66),l=e=>{let{imageUrl:t=a.l+"/block-error.svg",header:n=Object(s.__)("Oops!","woo-gutenberg-products-block"),text:r=Object(s.__)("There was an error loading the content.","woo-gutenberg-products-block"),errorMessage:o,errorMessagePrefix:i=Object(s.__)("Error:","woo-gutenberg-products-block"),button:l}=e;return Object(c.createElement)("div",{className:"wc-block-error wc-block-components-error"},t&&Object(c.createElement)("img",{className:"wc-block-error__image wc-block-components-error__image",src:t,alt:""}),Object(c.createElement)("div",{className:"wc-block-error__content wc-block-components-error__content"},n&&Object(c.createElement)("p",{className:"wc-block-error__header wc-block-components-error__header"},n),r&&Object(c.createElement)("p",{className:"wc-block-error__text wc-block-components-error__text"},r),o&&Object(c.createElement)("p",{className:"wc-block-error__message wc-block-components-error__message"},i?i+" ":"",o),l&&Object(c.createElement)("p",{className:"wc-block-error__button wc-block-components-error__button"},l)))};n(37);class u extends i.Component{constructor(){super(...arguments),o()(this,"state",{errorMessage:"",hasError:!1})}static getDerivedStateFromError(e){return void 0!==e.statusText&&void 0!==e.status?{errorMessage:Object(c.createElement)(c.Fragment,null,Object(c.createElement)("strong",null,e.status),": ",e.statusText),hasError:!0}:{errorMessage:e.message,hasError:!0}}render(){const{header:e,imageUrl:t,showErrorMessage:n=!0,text:r,errorMessagePrefix:o,renderError:i,button:s}=this.props,{errorMessage:a,hasError:u}=this.state;return u?"function"==typeof i?i({errorMessage:a}):Object(c.createElement)(l,{errorMessage:n?a:null,header:e,imageUrl:t,text:r,errorMessagePrefix:o,button:s}):this.props.children}}t.a=u},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(0),o=n(11),c=n.n(o);function i(e){const t=Object(r.useRef)(e);return c()(e,t.current)||(t.current=e),t.current}},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(0);n(9);const o=Object(r.createContext)({isEditor:!1,currentPostId:0,currentView:"",previewData:{},getPreviewData:()=>{}}),c=()=>Object(r.useContext)(o)},function(e,t){e.exports=window.wp.htmlEntities},,function(e,t,n){"use strict";var r=n(0),o=n(4),c=n.n(o);t.a=e=>{let t,{label:n,screenReaderLabel:o,wrapperElement:i,wrapperProps:s={}}=e;const a=null!=n,l=null!=o;return!a&&l?(t=i||"span",s={...s,className:c()(s.className,"screen-reader-text")},Object(r.createElement)(t,s,o)):(t=i||r.Fragment,a&&l&&n!==o?Object(r.createElement)(t,s,Object(r.createElement)("span",{"aria-hidden":"true"},n),Object(r.createElement)("span",{className:"screen-reader-text"},o)):Object(r.createElement)(t,s,n))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return w}));var r=n(5),o=n(0),c=n(6),i=n(9),s=n(19),a=n(70),l=n(109),u=n(18),d=n(67);const p=e=>{const t=e.detail;t&&t.preserveCartData||Object(i.dispatch)(c.CART_STORE_KEY).invalidateResolutionForStore()},b=()=>{1===window.wcBlocksStoreCartListeners.count&&window.wcBlocksStoreCartListeners.remove(),window.wcBlocksStoreCartListeners.count--},m=()=>{Object(o.useEffect)(()=>((()=>{if(window.wcBlocksStoreCartListeners||(window.wcBlocksStoreCartListeners={count:0,remove:()=>{}}),0===window.wcBlocksStoreCartListeners.count){const e=Object(d.b)("added_to_cart","wc-blocks_added_to_cart"),t=Object(d.b)("removed_from_cart","wc-blocks_removed_from_cart");document.body.addEventListener("wc-blocks_added_to_cart",p),document.body.addEventListener("wc-blocks_removed_from_cart",p),window.wcBlocksStoreCartListeners.count=0,window.wcBlocksStoreCartListeners.remove=()=>{e(),t(),document.body.removeEventListener("wc-blocks_added_to_cart",p),document.body.removeEventListener("wc-blocks_removed_from_cart",p)}}window.wcBlocksStoreCartListeners.count++})(),b),[])},f={first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:""},g={...f,email:""},h={total_items:"",total_items_tax:"",total_fees:"",total_fees_tax:"",total_discount:"",total_discount_tax:"",total_shipping:"",total_shipping_tax:"",total_price:"",total_tax:"",tax_lines:c.EMPTY_TAX_LINES,currency_code:"",currency_symbol:"",currency_minor_unit:2,currency_decimal_separator:"",currency_thousand_separator:"",currency_prefix:"",currency_suffix:""},E=e=>Object(a.a)(Object.entries(e).map(e=>{let[t,n]=e;return[t,Object(s.decodeEntities)(n)]})),O={cartCoupons:c.EMPTY_CART_COUPONS,cartItems:c.EMPTY_CART_ITEMS,cartFees:c.EMPTY_CART_FEES,cartItemsCount:0,cartItemsWeight:0,cartNeedsPayment:!0,cartNeedsShipping:!0,cartItemErrors:c.EMPTY_CART_ITEM_ERRORS,cartTotals:h,cartIsLoading:!0,cartErrors:c.EMPTY_CART_ERRORS,billingAddress:g,shippingAddress:f,shippingRates:c.EMPTY_SHIPPING_RATES,shippingRatesLoading:!1,cartHasCalculatedShipping:!1,paymentRequirements:c.EMPTY_PAYMENT_REQUIREMENTS,receiveCart:()=>{},extensions:c.EMPTY_EXTENSIONS},w=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{shouldSelect:!0};const{isEditor:t,previewData:n}=Object(u.a)(),s=null==n?void 0:n.previewCart,{shouldSelect:a}=e,d=Object(o.useRef)();m();const p=Object(i.useSelect)((e,n)=>{let{dispatch:r}=n;if(!a)return O;if(t)return{cartCoupons:s.coupons,cartItems:s.items,cartFees:s.fees,cartItemsCount:s.items_count,cartItemsWeight:s.items_weight,cartNeedsPayment:s.needs_payment,cartNeedsShipping:s.needs_shipping,cartItemErrors:c.EMPTY_CART_ITEM_ERRORS,cartTotals:s.totals,cartIsLoading:!1,cartErrors:c.EMPTY_CART_ERRORS,billingAddress:g,shippingAddress:f,extensions:c.EMPTY_EXTENSIONS,shippingRates:s.shipping_rates,shippingRatesLoading:!1,cartHasCalculatedShipping:s.has_calculated_shipping,paymentRequirements:s.paymentRequirements,receiveCart:"function"==typeof(null==s?void 0:s.receiveCart)?s.receiveCart:()=>{}};const o=e(c.CART_STORE_KEY),i=o.getCartData(),u=o.getCartErrors(),d=o.getCartTotals(),p=!o.hasFinishedResolution("getCartData"),b=o.isCustomerDataUpdating(),{receiveCart:m}=r(c.CART_STORE_KEY),h=E(i.billingAddress),w=i.needsShipping?E(i.shippingAddress):h,j=i.fees.length>0?i.fees.map(e=>E(e)):c.EMPTY_CART_FEES;return{cartCoupons:i.coupons.length>0?i.coupons.map(e=>({...e,label:e.code})):c.EMPTY_CART_COUPONS,cartItems:i.items,cartFees:j,cartItemsCount:i.itemsCount,cartItemsWeight:i.itemsWeight,cartNeedsPayment:i.needsPayment,cartNeedsShipping:i.needsShipping,cartItemErrors:i.errors,cartTotals:d,cartIsLoading:p,cartErrors:u,billingAddress:Object(l.a)(h),shippingAddress:Object(l.a)(w),extensions:i.extensions,shippingRates:i.shippingRates,shippingRatesLoading:b,cartHasCalculatedShipping:i.hasCalculatedShipping,paymentRequirements:i.paymentRequirements,receiveCart:m}},[a]);return d.current&&Object(r.isEqual)(d.current,p)||(d.current=p),d.current}},function(e,t){e.exports=window.wp.a11y},function(e,t){e.exports=window.wp.primitives},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(0);const o=Object(r.createContext)("page"),c=()=>Object(r.useContext)(o);o.Provider},function(e,t,n){"use strict";(function(e){var r=n(0);n(45);const o=Object(r.createContext)({slots:{},fills:{},registerSlot:()=>{void 0!==e&&e.env},updateSlot:()=>{},unregisterSlot:()=>{},registerFill:()=>{},unregisterFill:()=>{}});t.a=o}).call(this,n(65))},function(e,t){e.exports=window.wp.apiFetch},,,function(e,t){e.exports=window.wp.deprecated},,,,function(e,t){e.exports=window.wp.url},function(e,t,n){"use strict";n.d(t,"b",(function(){return r})),n.d(t,"d",(function(){return o})),n.d(t,"c",(function(){return c})),n.d(t,"e",(function(){return i})),n.d(t,"a",(function(){return s}));const r=e=>"number"==typeof e,o=e=>"string"==typeof e,c=e=>!(e=>null===e)(e)&&e instanceof Object&&e.constructor===Object;function i(e,t){return c(e)&&t in e}const s=e=>"boolean"==typeof e},,function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(48),o=n(0),c=n(22);const i=()=>{const e=Object(c.a)(),t=Object(o.useRef)(e);return Object(o.useEffect)(()=>{t.current=e},[e]),{dispatchStoreEvent:Object(o.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(r.doAction)("experimental__woocommerce_blocks-"+e,t)}catch(e){console.error(e)}}),[]),dispatchCheckoutEvent:Object(o.useCallback)((function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(r.doAction)("experimental__woocommerce_blocks-checkout-"+e,{...n,storeCart:t.current})}catch(e){console.error(e)}}),[])}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return d})),n.d(t,"b",(function(){return p})),n.d(t,"c",(function(){return b}));var r=n(6),o=n(9),c=n(0),i=n(11),s=n.n(i),a=n(17),l=n(62),u=n(25);const d=e=>{const t=Object(u.a)();e=e||t;const n=Object(o.useSelect)(t=>t(r.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0),[e]),{setValueForQueryContext:i}=Object(o.useDispatch)(r.QUERY_STATE_STORE_KEY);return[n,Object(c.useCallback)(t=>{i(e,t)},[e,i])]},p=(e,t,n)=>{const i=Object(u.a)();n=n||i;const s=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[s,Object(c.useCallback)(t=>{a(n,e,t)},[n,e,a])]},b=(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),b=Object(l.a)(p),m=Object(c.useRef)(!1);return Object(c.useEffect)(()=>{s()(b,p)||(o(Object.assign({},i,p)),m.current=!0)},[i,p,b,o]),m.current?[r,o]:[e,o]}},function(e,t){e.exports=window.wc.priceFormat},,function(e,t,n){"use strict";var r=n(43);function o(){}function c(){}c.resetWarningCache=o,e.exports=function(){function e(e,t,n,o,c,i){if(i!==r){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:c,resetWarningCache:o};return n.PropTypes=n,n}},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},,function(e,t){e.exports=window.wp.warning},function(e,t,n){"use strict";var r=n(7),o=n(0),c=n(24),i=function({icon:e,className:t,...n}){const c=["dashicon","dashicons","dashicons-"+e,t].filter(Boolean).join(" ");return Object(o.createElement)("span",Object(r.a)({className:c},n))};t.a=function({icon:e=null,size:t=24,...n}){if("string"==typeof e)return Object(o.createElement)(i,Object(r.a)({icon:e},n));if(Object(o.isValidElement)(e)&&i===e.type)return Object(o.cloneElement)(e,{...n});if("function"==typeof e)return e.prototype instanceof o.Component?Object(o.createElement)(e,{size:t,...n}):e({size:t,...n});if(e&&("svg"===e.type||e.type===c.SVG)){const r={width:t,height:t,...e.props,...n};return Object(o.createElement)(c.SVG,r)}return Object(o.isValidElement)(e)?Object(o.cloneElement)(e,{size:t,...n}):e}},function(e,t,n){"use strict";var r=n(4),o=n.n(r),c=n(0);t.a=Object(c.forwardRef)((function({as:e="div",className:t,...n},r){return function({as:e="div",...t}){return"function"==typeof t.children?t.children(t):Object(c.createElement)(e,t)}({as:e,className:o()("components-visually-hidden",t),...n,ref:r})}))},function(e,t){e.exports=window.wp.hooks},function(e,t){e.exports=window.wc.wcBlocksSharedContext},function(e,t,n){"use strict";var r=n(2),o=n(1),c=n(35);const i=Object(r.getSetting)("countryLocale",{}),s=e=>{const t={};return void 0!==e.label&&(t.label=e.label),void 0!==e.required&&(t.required=e.required),void 0!==e.hidden&&(t.hidden=e.hidden),void 0===e.label||e.optionalLabel||(t.optionalLabel=Object(o.sprintf)(
|
2 |
/* translators: %s Field label. */
|
3 |
-
Object(o.__)("%s (optional)","woo-gutenberg-products-block"),e.label)),e.priority&&(Object(c.b)(e.priority)&&(t.index=e.priority),Object(c.d)(e.priority)&&(t.index=parseInt(e.priority,10))),e.hidden&&(t.required=!1),t},a=Object.entries(i).map(e=>{let[t,n]=e;return[t,Object.entries(n).map(e=>{let[t,n]=e;return[t,s(n)]}).reduce((e,t)=>{let[n,r]=t;return e[n]=r,e},{})]}).reduce((e,t)=>{let[n,r]=t;return e[n]=r,e},{});t.a=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";const o=n&&void 0!==a[n]?a[n]:{};return e.map(e=>({key:e,...r.defaultAddressFields[e]||{},...o[e]||{},...t[e]||{}})).sort((e,t)=>e.index-t.index)}},,,function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(10),o=n.n(r),c=n(0),i=n(16);const s=[".wp-block-woocommerce-cart"],a=e=>{let{Block:t,containers:n,getProps:r=(()=>({})),getErrorBoundaryProps:s=(()=>({}))}=e;0!==n.length&&Array.prototype.forEach.call(n,(e,n)=>{const a=r(e,n),l=s(e,n),u={...e.dataset,...a.attributes||{}};(e=>{let{Block:t,container:n,attributes:r={},props:s={},errorBoundaryProps:a={}}=e;Object(c.render)(Object(c.createElement)(i.a,a,Object(c.createElement)(c.Suspense,{fallback:Object(c.createElement)("div",{className:"wc-block-placeholder"})},t&&Object(c.createElement)(t,o()({},s,{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(s.join(",")),{Block:n,getProps:r,getErrorBoundaryProps:o,selector:c}=e;(e=>{let{Block:t,getProps:n,getErrorBoundaryProps:r,selector:o,wrappers:c}=e;const i=document.body.querySelectorAll(o);c&&c.length>0&&Array.prototype.filter.call(i,e=>!((e,t)=>Array.prototype.some.call(t,t=>t.contains(e)&&!t.isSameNode(e)))(e,c)),a({Block:t,containers:i,getProps:n,getErrorBoundaryProps:r})})({Block:n,getProps:r,getErrorBoundaryProps:o,selector:c,wrappers:t}),Array.prototype.forEach.call(t,t=>{t.addEventListener("wc-blocks_render_blocks_frontend",()=>{(e=>{let{Block:t,getProps:n,getErrorBoundaryProps:r,selector:o,wrapper:c}=e;const i=c.querySelectorAll(o);a({Block:t,containers:i,getProps:n,getErrorBoundaryProps:r})})({...e,wrapper:t})})})}},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(7),o=n(0),c=n(4),i=n.n(c),s=n(5),a=n(30),l=n.n(a),u=n(12),d=n(60),p=n(90),b=n(1);function m(e,t,n){const{defaultView:r}=t,{frameElement:o}=r;if(!o||t===n.ownerDocument)return e;const c=o.getBoundingClientRect();return new r.DOMRect(e.left+c.left,e.top+c.top,e.width,e.height)}let f=0;function g(e){const t=document.scrollingElement||document.body;e&&(f=t.scrollTop);const n=e?"add":"remove";t.classList[n]("lockscroll"),document.documentElement.classList[n]("lockscroll"),e||(t.scrollTop=f)}let h=0;function E(){return Object(o.useEffect)(()=>(0===h&&g(!0),++h,()=>{1===h&&g(!1),--h}),[]),null}var O=n(26);function w(e){const t=Object(o.useContext)(O.a),n=t.slots[e]||{},r=t.fills[e],c=Object(o.useMemo)(()=>r||[],[r]);return{...n,updateSlot:Object(o.useCallback)(n=>{t.updateSlot(e,n)},[e,t.updateSlot]),unregisterSlot:Object(o.useCallback)(n=>{t.unregisterSlot(e,n)},[e,t.unregisterSlot]),fills:c,registerFill:Object(o.useCallback)(n=>{t.registerFill(e,n)},[e,t.registerFill]),unregisterFill:Object(o.useCallback)(n=>{t.unregisterFill(e,n)},[e,t.unregisterFill])}}var j=Object(o.createContext)({registerSlot:()=>{},unregisterSlot:()=>{},registerFill:()=>{},unregisterFill:()=>{},getSlot:()=>{},getFills:()=>{},subscribe:()=>{}});function y({name:e,children:t,registerFill:n,unregisterFill:r}){const c=(e=>{const{getSlot:t,subscribe:n}=Object(o.useContext)(j),[r,c]=Object(o.useState)(t(e));return Object(o.useEffect)(()=>(c(t(e)),n(()=>{c(t(e))})),[e]),r})(e),i=Object(o.useRef)({name:e,children:t});return Object(o.useLayoutEffect)(()=>(n(e,i.current),()=>r(e,i.current)),[]),Object(o.useLayoutEffect)(()=>{i.current.children=t,c&&c.forceUpdate()},[t]),Object(o.useLayoutEffect)(()=>{e!==i.current.name&&(r(i.current.name,i.current),i.current.name=e,n(e,i.current))},[e]),c&&c.node?(Object(s.isFunction)(t)&&(t=t(c.props.fillProps)),Object(o.createPortal)(t,c.node)):null}var v=e=>Object(o.createElement)(j.Consumer,null,({registerFill:t,unregisterFill:n})=>Object(o.createElement)(y,Object(r.a)({},e,{registerFill:t,unregisterFill:n})));class _ extends o.Component{constructor(){super(...arguments),this.isUnmounted=!1,this.bindNode=this.bindNode.bind(this)}componentDidMount(){const{registerSlot:e}=this.props;e(this.props.name,this)}componentWillUnmount(){const{unregisterSlot:e}=this.props;this.isUnmounted=!0,e(this.props.name,this)}componentDidUpdate(e){const{name:t,unregisterSlot:n,registerSlot:r}=this.props;e.name!==t&&(n(e.name),r(t,this))}bindNode(e){this.node=e}forceUpdate(){this.isUnmounted||super.forceUpdate()}render(){const{children:e,name:t,fillProps:n={},getFills:r}=this.props,c=Object(s.map)(r(t,this),e=>{const t=Object(s.isFunction)(e.children)?e.children(n):e.children;return o.Children.map(t,(e,t)=>{if(!e||Object(s.isString)(e))return e;const n=e.key||t;return Object(o.cloneElement)(e,{key:n})})}).filter(Object(s.negate)(o.isEmptyElement));return Object(o.createElement)(o.Fragment,null,Object(s.isFunction)(e)?e(c):c)}}var x=e=>Object(o.createElement)(j.Consumer,null,({registerSlot:t,unregisterSlot:n,getFills:c})=>Object(o.createElement)(_,Object(r.a)({},e,{registerSlot:t,unregisterSlot:n,getFills:c})));function k(){const[,e]=Object(o.useState)({}),t=Object(o.useRef)(!0);return Object(o.useEffect)(()=>()=>{t.current=!1},[]),()=>{t.current&&e({})}}function C({name:e,children:t}){const n=w(e),r=Object(o.useRef)({rerender:k()});return Object(o.useEffect)(()=>(n.registerFill(r),()=>{n.unregisterFill(r)}),[n.registerFill,n.unregisterFill]),n.ref&&n.ref.current?("function"==typeof t&&(t=t(n.fillProps)),Object(o.createPortal)(t,n.ref.current)):null}var S=Object(o.forwardRef)((function({name:e,fillProps:t={},as:n="div",...c},i){const s=Object(o.useContext)(O.a),a=Object(o.useRef)();return Object(o.useLayoutEffect)(()=>(s.registerSlot(e,a,t),()=>{s.unregisterSlot(e,a)}),[s.registerSlot,s.unregisterSlot,e]),Object(o.useLayoutEffect)(()=>{s.updateSlot(e,t)}),Object(o.createElement)(n,Object(r.a)({ref:Object(u.useMergeRefs)([i,a])},c))}));function N(e){return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(v,e),Object(o.createElement)(C,e))}n(11),o.Component;const P=Object(o.forwardRef)(({bubblesVirtually:e,...t},n)=>e?Object(o.createElement)(S,Object(r.a)({},t,{ref:n})):Object(o.createElement)(x,t));function R(e){return"appear"===e?"top":"left"}function T(e,t){const{paddingTop:n,paddingBottom:r,paddingLeft:o,paddingRight:c}=(i=t).ownerDocument.defaultView.getComputedStyle(i);var i;const s=n?parseInt(n,10):0,a=r?parseInt(r,10):0,l=o?parseInt(o,10):0,u=c?parseInt(c,10):0;return{x:e.left+l,y:e.top+s,width:e.width-l-u,height:e.height-s-a,left:e.left+l,right:e.right-u,top:e.top+s,bottom:e.bottom-a}}function L(e,t,n){n?e.getAttribute(t)!==n&&e.setAttribute(t,n):e.hasAttribute(t)&&e.removeAttribute(t)}function A(e,t,n=""){e.style[t]!==n&&(e.style[t]=n)}function B(e,t,n){n?e.classList.contains(t)||e.classList.add(t):e.classList.contains(t)&&e.classList.remove(t)}const M=Object(o.forwardRef)(({headerTitle:e,onClose:t,children:n,className:c,noArrow:s=!0,isAlternate:a,position:f="bottom right",range:g,focusOnMount:h="firstElement",anchorRef:O,shouldAnchorIncludePadding:j,anchorRect:y,getAnchorRect:v,expandOnMobile:_,animate:x=!0,onClickOutside:k,onFocusOutside:C,__unstableStickyBoundaryElement:S,__unstableSlotName:P="Popover",__unstableObserveElement:M,__unstableBoundaryParent:F,__unstableForcePosition:I,__unstableForceXAlignment:D,...V},W)=>{const z=Object(o.useRef)(null),H=Object(o.useRef)(null),U=Object(o.useRef)(),Y=Object(u.useViewportMatch)("medium","<"),[q,Q]=Object(o.useState)(),K=w(P),X=_&&Y,[J,Z]=Object(u.useResizeObserver)();s=X||s,Object(o.useLayoutEffect)(()=>{if(X)return B(U.current,"is-without-arrow",s),B(U.current,"is-alternate",a),L(U.current,"data-x-axis"),L(U.current,"data-y-axis"),A(U.current,"top"),A(U.current,"left"),A(H.current,"maxHeight"),void A(H.current,"maxWidth");const e=()=>{if(!U.current||!H.current)return;let e=function(e,t,n,r=!1,o,c){if(t)return t;if(n){if(!e.current)return;const t=n(e.current);return m(t,t.ownerDocument||e.current.ownerDocument,c)}if(!1!==r){if(!(r&&window.Range&&window.Element&&window.DOMRect))return;if("function"==typeof(null==r?void 0:r.cloneRange))return m(Object(d.getRectangleFromRange)(r),r.endContainer.ownerDocument,c);if("function"==typeof(null==r?void 0:r.getBoundingClientRect)){const e=m(r.getBoundingClientRect(),r.ownerDocument,c);return o?e:T(e,r)}const{top:e,bottom:t}=r,n=e.getBoundingClientRect(),i=t.getBoundingClientRect(),s=m(new window.DOMRect(n.left,n.top,n.width,i.bottom-n.top),e.ownerDocument,c);return o?s:T(s,r)}if(!e.current)return;const{parentNode:i}=e.current,s=i.getBoundingClientRect();return o?s:T(s,i)}(z,y,v,O,j,U.current);if(!e)return;const{offsetParent:t,ownerDocument:n}=U.current;let r,o=0;if(t&&t!==n.body){const n=t.getBoundingClientRect();o=n.top,e=new window.DOMRect(e.left-n.left,e.top-n.top,e.width,e.height)}var c;F&&(r=null===(c=U.current.closest(".popover-slot"))||void 0===c?void 0:c.parentNode);const i=Z.height?Z:H.current.getBoundingClientRect(),{popoverTop:l,popoverLeft:u,xAxis:p,yAxis:g,contentHeight:h,contentWidth:E}=function(e,t,n="top",r,o,c,i,s,a){const[l,u="center",d]=n.split(" "),p=function(e,t,n,r,o,c,i,s){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 b,m=n,f=null;if(!o&&!s)if("middle"===n&&u.contentHeight===a)m="middle";else if("top"===n&&d.contentHeight===a)m="top";else if("bottom"===n&&p.contentHeight===a)m="bottom";else{m=d.contentHeight>p.contentHeight?"top":"bottom";const e="top"===m?d.contentHeight:p.contentHeight;f=e!==a?e:null}return b="middle"===m?u.popoverTop:"top"===m?d.popoverTop:p.popoverTop,{yAxis:m,popoverTop:b,contentHeight:f}}(e,t,l,d,r,0,c,s);return{...function(e,t,n,r,o,c,i,s,a){const{width:l}=t;"left"===n&&Object(b.isRTL)()?n="right":"right"===n&&Object(b.isRTL)()&&(n="left"),"left"===r&&Object(b.isRTL)()?r="right":"right"===r&&Object(b.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"===c||a||(p=u);let m=e.right;"left"===r?m=e.left:"middle"===c||a||(m=u);const f={popoverLeft:p,contentWidth:p-l>0?l:p},g={popoverLeft:m,contentWidth:m+l>window.innerWidth?window.innerWidth-m:l};let h,E=n,O=null;if(!o&&!s)if("center"===n&&d.contentWidth===l)E="center";else if("left"===n&&f.contentWidth===l)E="left";else if("right"===n&&g.contentWidth===l)E="right";else{E=f.contentWidth>g.contentWidth?"left":"right";const e="left"===E?f.contentWidth:g.contentWidth;l>window.innerWidth&&(O=window.innerWidth),e!==l&&(E="center",d.popoverLeft=window.innerWidth/2)}if(h="center"===E?d.popoverLeft:"left"===E?f.popoverLeft:g.popoverLeft,i){const e=i.getBoundingClientRect();h=Math.min(h,e.right-l),Object(b.isRTL)()||(h=Math.max(h,0))}return{xAxis:E,popoverLeft:h,contentWidth:O}}(e,t,u,d,r,p.yAxis,i,s,a),...p}}(e,i,f,S,U.current,o,r,I,D);"number"==typeof l&&"number"==typeof u&&(A(U.current,"top",l+"px"),A(U.current,"left",u+"px")),B(U.current,"is-without-arrow",s||"center"===p&&"middle"===g),B(U.current,"is-alternate",a),L(U.current,"data-x-axis",p),L(U.current,"data-y-axis",g),A(H.current,"maxHeight","number"==typeof h?h+"px":""),A(H.current,"maxWidth","number"==typeof E?E+"px":""),Q(({left:"right",right:"left"}[p]||"center")+" "+({top:"bottom",bottom:"top"}[g]||"middle"))};e();const{ownerDocument:t}=U.current,{defaultView:n}=t,r=n.setInterval(e,500);let o;const c=()=>{n.cancelAnimationFrame(o),o=n.requestAnimationFrame(e)};n.addEventListener("click",c),n.addEventListener("resize",e),n.addEventListener("scroll",e,!0);const i=function(e){if(e)return e.endContainer?e.endContainer.ownerDocument:e.top?e.top.ownerDocument:e.ownerDocument}(O);let l;return i&&i!==t&&(i.defaultView.addEventListener("resize",e),i.defaultView.addEventListener("scroll",e,!0)),M&&(l=new n.MutationObserver(e),l.observe(M,{attributes:!0})),()=>{n.clearInterval(r),n.removeEventListener("resize",e),n.removeEventListener("scroll",e,!0),n.removeEventListener("click",c),n.cancelAnimationFrame(o),i&&i!==t&&(i.defaultView.removeEventListener("resize",e),i.defaultView.removeEventListener("scroll",e,!0)),l&&l.disconnect()}},[X,y,v,O,j,f,Z,S,M,F]);const $=(e,n)=>{if("focus-outside"===e&&C)C(n);else if("focus-outside"===e&&k){const e=new window.MouseEvent("click");Object.defineProperty(e,"target",{get:()=>n.relatedTarget}),l()("Popover onClickOutside prop",{since:"5.3",alternative:"onFocusOutside"}),k(e)}else t&&t()},[ee,te]=Object(u.__experimentalUseDialog)({focusOnMount:h,__unstableOnClose:$,onClose:$}),ne=Object(u.useMergeRefs)([U,ee,W]),re=Boolean(x&&q)&&function(e){if("loading"===e.type)return i()("components-animate__loading");const{type:t,origin:n=R(t)}=e;if("appear"===t){const[e,t="center"]=n.split(" ");return i()("components-animate__appear",{["is-from-"+t]:"center"!==t,["is-from-"+e]:"middle"!==e})}return"slide-in"===t?i()("components-animate__slide-in","is-from-"+n):void 0}({type:"appear",origin:q});let oe=Object(o.createElement)("div",Object(r.a)({className:i()("components-popover",c,re,{"is-expanded":X,"is-without-arrow":s,"is-alternate":a})},V,{ref:ne},te,{tabIndex:"-1"}),X&&Object(o.createElement)(E,null),X&&Object(o.createElement)("div",{className:"components-popover__header"},Object(o.createElement)("span",{className:"components-popover__header-title"},e),Object(o.createElement)(G,{className:"components-popover__close",icon:p.a,onClick:t})),Object(o.createElement)("div",{ref:H,className:"components-popover__content"},Object(o.createElement)("div",{style:{position:"relative"}},J,n)));return K.ref&&(oe=Object(o.createElement)(N,{name:P},oe)),O||y?oe:Object(o.createElement)("span",{ref:z},oe)});M.Slot=Object(o.forwardRef)((function({name:e="Popover"},t){return Object(o.createElement)(P,{bubblesVirtually:!0,name:e,className:"popover-slot",ref:t})}));var F=M,I=function({shortcut:e,className:t}){if(!e)return null;let n,r;return Object(s.isString)(e)&&(n=e),Object(s.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}),z=(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 H=function({children:e,position:t,text:n,shortcut:r}){const[c,i]=Object(o.useState)(!1),[a,l]=Object(o.useState)(!1),d=Object(u.useDebounce)(l,700),p=t=>{z(e,"onMouseDown",t),document.addEventListener("mouseup",f),i(!0)},b=t=>{z(e,"onMouseUp",t),document.removeEventListener("mouseup",f),i(!1)},m=e=>"mouseUp"===e?b:"mouseDown"===e?p:void 0,f=m("mouseUp"),g=(t,n)=>r=>{if(z(e,t,r),r.currentTarget.disabled)return;if("focus"===r.type&&c)return;d.cancel();const o=Object(s.includes)(["focus","mouseenter"],r.type);o!==a&&(n?d(o):l(o))},h=()=>{d.cancel(),document.removeEventListener("mouseup",f)};if(Object(o.useEffect)(()=>h,[]),1!==o.Children.count(e))return e;const E={onMouseEnter:g("onMouseEnter",!0),onMouseLeave:g("onMouseLeave"),onClick:g("onClick"),onFocus:g("onFocus"),onBlur:g("onBlur"),onMouseDown:m("mouseDown")},O=o.Children.only(e),{children:w,disabled:j}=O.props;return(j?V:W)({child:O,eventHandlers:E,childrenWithPopover:(({grandchildren:e,isOver:t,position:n,text:r,shortcut:c})=>Object(o.concatChildren)(e,t&&Object(o.createElement)(F,{focusOnMount:!1,position:n,className:"components-tooltip","aria-hidden":"true",animate:!1,noArrow:!0},r,Object(o.createElement)(I,{className:"components-tooltip__shortcut",shortcut:c}))))({grandchildren:w,isOver:a,position:t,text:n,shortcut:r})})},U=n(46),Y=n(47);const q=["onMouseDown","onClick"];var G=t.a=Object(o.forwardRef)((function(e,t){const{href:n,target:c,isSmall:a,isPressed:u,isBusy:d,isDestructive:p,className:b,disabled:m,icon:f,iconPosition:g="left",iconSize:h,showTooltip:E,tooltipPosition:O,shortcut:w,label:j,children:y,text:v,variant:_,__experimentalIsFocusable:x,describedBy:k,...C}=function({isDefault:e,isPrimary:t,isSecondary:n,isTertiary:r,isLink:o,variant:c,...i}){let s=c;var a,u,d,p,b;return t&&(null!==(a=s)&&void 0!==a||(s="primary")),r&&(null!==(u=s)&&void 0!==u||(s="tertiary")),n&&(null!==(d=s)&&void 0!==d||(s="secondary")),e&&(l()("Button isDefault prop",{since:"5.4",alternative:'variant="secondary"'}),null!==(p=s)&&void 0!==p||(s="secondary")),o&&(null!==(b=s)&&void 0!==b||(s="link")),{...i,variant:s}}(e),S=i()("components-button",b,{"is-secondary":"secondary"===_,"is-primary":"primary"===_,"is-small":a,"is-tertiary":"tertiary"===_,"is-pressed":u,"is-busy":d,"is-link":"link"===_,"is-destructive":p,"has-text":!!f&&!!y,"has-icon":!!f}),N=m&&!x,P=void 0===n||N?"button":"a",R="a"===P?{href:n,target:c}:{type:"button",disabled:N,"aria-pressed":u};if(m&&x){R["aria-disabled"]=!0;for(const e of q)C[e]=e=>{e.stopPropagation(),e.preventDefault()}}const T=!N&&(E&&j||w||!!j&&(!y||Object(s.isArray)(y)&&!y.length)&&!1!==E),L=k?Object(s.uniqueId)():null,A=C["aria-describedby"]||L,B=Object(o.createElement)(P,Object(r.a)({},R,C,{className:S,"aria-label":C["aria-label"]||j,"aria-describedby":A,ref:t}),f&&"left"===g&&Object(o.createElement)(U.a,{icon:f,size:h}),v&&Object(o.createElement)(o.Fragment,null,v),f&&"right"===g&&Object(o.createElement)(U.a,{icon:f,size:h}),y);return T?Object(o.createElement)(o.Fragment,null,Object(o.createElement)(H,{text:k||j,shortcut:w,position:O},B),k&&Object(o.createElement)(Y.a,null,Object(o.createElement)("span",{id:L},k))):Object(o.createElement)(o.Fragment,null,B,k&&Object(o.createElement)(Y.a,null,Object(o.createElement)("span",{id:L},k)))}))},,,,function(e,t){e.exports=window.wp.dom},,function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(3);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";n.d(t,"a",(function(){return a}));var r=n(6),o=n(9),c=n(0),i=n(17),s=n(54);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(c.useRef)({results:[],isLoading:!0}),p=Object(i.a)(l),b=Object(i.a)(a),m=Object(s.a)(),f=Object(o.useSelect)(e=>{if(!u)return null;const o=e(r.COLLECTIONS_STORE_KEY),c=[t,n,p,b],i=o.getCollectionError(...c);return i&&m(i),{results:o.getCollection(...c),isLoading:!o.hasFinishedResolution("getCollection",c)}},[t,n,b,p,u]);return null!==f&&(d.current=f),d.current}},function(e,t){var n,r,o=e.exports={};function c(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function s(e){if(n===setTimeout)return setTimeout(e,0);if((n===c||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:c}catch(e){n=c}try{r="function"==typeof clearTimeout?clearTimeout:i}catch(e){r=i}}();var a,l=[],u=!1,d=-1;function p(){u&&a&&(u=!1,a.length?l=a.concat(l):d=-1,l.length&&b())}function b(){if(!u){var e=s(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 m(e,t){this.fun=e,this.array=t}function f(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];l.push(new m(e,t)),1!==l.length||u||s(b)},m.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=f,o.addListener=f,o.once=f,o.off=f,o.removeListener=f,o.removeAllListeners=f,o.emit=f,o.prependListener=f,o.prependOnceListener=f,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,n){"use strict";n.d(t,"n",(function(){return c})),n.d(t,"l",(function(){return i})),n.d(t,"k",(function(){return s})),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 b})),n.d(t,"e",(function(){return m})),n.d(t,"g",(function(){return f})),n.d(t,"a",(function(){return g})),n.d(t,"h",(function(){return h})),n.d(t,"b",(function(){return E}));var r,o=n(2);const c=Object(o.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),i=c.pluginUrl+"images/",s=c.pluginUrl+"build/",a=c.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),b=(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"),f=Object(o.getSetting)("shippingCountries",{}),g=Object(o.getSetting)("allowedCountries",{}),h=Object(o.getSetting)("shippingStates",{}),E=Object(o.getSetting)("allowedStates",{})},function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"c",(function(){return i})),n.d(t,"b",(function(){return s}));const r=window.CustomEvent||null,o=(e,t)=>{let{bubbles:n=!1,cancelable:o=!1,element:c,detail:i={}}=t;if(!r)return;c||(c=document.body);const s=new r(e,{bubbles:n,cancelable:o,detail:i});c.dispatchEvent(s)};let c;const i=()=>{c&&clearTimeout(c),c=setTimeout(()=>{o("wc_fragment_refresh",{bubbles:!0,cancelable:!0})},50)},s=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("function"!=typeof jQuery)return()=>{};const c=()=>{o(t,{bubbles:n,cancelable:r})};return jQuery(document).on(e,c),()=>jQuery(document).off(e,c)}},,,function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));const r=e=>e.reduce((e,t)=>{let[n,r]=t;return e[n]=r,e},{})},function(e,t,n){"use strict";var r=n(10),o=n.n(r),c=n(0);n(101);const i=e=>{if(!e)return;const t=e.getBoundingClientRect().bottom;t>=0&&t<=window.innerHeight||e.scrollIntoView()};t.a=e=>t=>{const n=Object(c.useRef)(null);return Object(c.createElement)(c.Fragment,null,Object(c.createElement)("div",{className:"with-scroll-to-top__scroll-point",ref:n,"aria-hidden":!0}),Object(c.createElement)(e,o()({},t,{scrollToTop:e=>{null!==n.current&&((e,t)=>{const{focusableSelector:n}=t||{};window&&Number.isFinite(window.innerHeight)&&(n?((e,t)=>{var n;const r=(null===(n=e.parentElement)||void 0===n?void 0:n.querySelectorAll(t))||[];if(r.length){const e=r[0];i(e),null==e||e.focus()}else i(e)})(e,n):i(e))})(n.current,e)}})))}},,,function(e,t){},,,,,,,,,,,,,function(e,t,n){"use strict";n.d(t,"b",(function(){return f})),n.d(t,"a",(function(){return g}));var r=n(0),o=(n(8),n(9)),c=n(38),i=n(18),s=n(10),a=n.n(s),l=n(4),u=n.n(l),d=n(116);n(74);const p=e=>{let{status:t="default"}=e;switch(t){case"error":return"woocommerce-error";case"success":return"woocommerce-message";case"info":case"warning":return"woocommerce-info"}return""};var b=e=>{let{className:t,notices:n,removeNotice:o}=e;const c=n.filter(e=>"snackbar"!==e.type);if(!c.length)return null;const i=u()(t,"wc-block-components-notices");return Object(r.createElement)("div",{className:i},c.map(e=>Object(r.createElement)(d.a,a()({key:"store-notice-"+e.id},e,{className:u()("wc-block-components-notices__notice",p(e)),onRemove:()=>{e.isDismissible&&o(e.id)}}),e.content)))};const m=Object(r.createContext)({notices:[],createNotice:(e,t,n)=>{},removeNotice:(e,t)=>{},setIsSuppressed:e=>{},context:"wc/core"}),f=()=>Object(r.useContext)(m),g=e=>{let{children:t,className:n="",createNoticeContainer:s=!0,context:a="wc/core"}=e;const{createNotice:l,removeNotice:u}=Object(o.useDispatch)("core/notices"),[d,p]=Object(r.useState)(!1),{dispatchStoreEvent:f}=Object(c.a)(),{isEditor:g}=Object(i.a)(),h=Object(r.useCallback)((function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};l(e,t,{...n,context:n.context||a}),f("store-notice-create",{status:e,content:t,options:n})}),[l,f,a]),E=Object(r.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a;u(e,t)}),[u,a]),{notices:O}=Object(o.useSelect)(e=>({notices:e("core/notices").getNotices(a)}),[a]),w={notices:O,createNotice:h,removeNotice:E,context:a,setIsSuppressed:p},j=d?null:Object(r.createElement)(b,{className:n,notices:w.notices,removeNotice:w.removeNotice,isEditor:g});return Object(r.createElement)(m.Provider,{value:w},s&&j,t)}},,,function(e,t,n){"use strict";var r=n(0),o=n(24);const c=Object(r.createElement)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(r.createElement)(o.Path,{d:"M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"}));t.a=c},,,,,,,,function(e,t,n){"use strict";var r=n(0);t.a=function(e){let{srcElement:t,size:n=24,...o}=e;return Object(r.isValidElement)(t)?Object(r.cloneElement)(t,{width:n,height:n,...o}):null}},,,function(e,t){},,function(e,t,n){"use strict";var r=n(0),o=(n(8),n(4)),c=n.n(o),i=n(21),s=n(12);n(115),t.a=Object(s.withInstanceId)(e=>{let{className:t,instanceId:n,label:o,onChange:s,options:a,screenReaderLabel:l,readOnly:u,value:d}=e;const p="wc-block-components-sort-select__select-"+n;return Object(r.createElement)("div",{className:c()("wc-block-sort-select","wc-block-components-sort-select",t)},Object(r.createElement)(i.a,{label:o,screenReaderLabel:l,wrapperElement:"label",wrapperProps:{className:"wc-block-sort-select__label wc-block-components-sort-select__label",htmlFor:p}}),Object(r.createElement)("select",{id:p,className:"wc-block-sort-select__select wc-block-components-sort-select__select",onChange:s,readOnly:u,value:d},a.map(e=>Object(r.createElement)("option",{key:e.key,value:e.key},e.label))))})},,,,,,function(e,t,n){"use strict";n.d(t,"b",(function(){return i})),n.d(t,"c",(function(){return s})),n.d(t,"a",(function(){return a}));var r=n(2),o=n(50),c=n(34);const i=e=>{let{country:t="",state:n="",city:r="",postcode:o=""}=e;return{country:t.trim(),state:n.trim(),city:r.trim(),postcode:o?o.replace(" ","").toUpperCase():""}},s=e=>{let{email:t=""}=e;return Object(c.isEmail)(t)?t.trim():""},a=e=>{const t=Object.keys(r.defaultAddressFields),n=Object(o.a)(t,{},e.country),c=Object.assign({},e);return n.forEach(t=>{let{key:n="",hidden:r=!1}=t;r&&((e,t)=>e in t)(n,e)&&(c[n]="")}),c}},function(e,t){e.exports=window.wc.wcBlocksSharedHocs},,,function(e,t){e.exports=window.wp.wordcount},function(e,t){e.exports=window.wp.autop},function(e,t){},function(e,t,n){"use strict";var r=n(0),o=n(5),c=n(4),i=n.n(c),s=n(1),a=n(23),l=n(90),u=n(56);function d(e){switch(e){case"success":case"warning":case"info":return"polite";case"error":default:return"assertive"}}t.a=function({className:e,status:t="info",children:n,spokenMessage:c=n,onRemove:p=o.noop,isDismissible:b=!0,actions:m=[],politeness:f=d(t),__unstableHTML:g,onDismiss:h=o.noop}){!function(e,t){const n="string"==typeof e?e:Object(r.renderToString)(e);Object(r.useEffect)(()=>{n&&Object(a.speak)(n,t)},[n,t])}(c,f);const E=i()(e,"components-notice","is-"+t,{"is-dismissible":b});return g&&(n=Object(r.createElement)(r.RawHTML,null,n)),Object(r.createElement)("div",{className:E},Object(r.createElement)("div",{className:"components-notice__content"},n,Object(r.createElement)("div",{className:"components-notice__actions"},m.map(({className:e,label:t,isPrimary:n,variant:o,noDefaultClasses:c=!1,onClick:s,url:a},l)=>{let d=o;return"primary"===o||c||(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:s,className:i()("components-notice__action",e)},t)}))),b&&Object(r.createElement)(u.a,{className:"components-notice__dismiss",icon:l.a,label:Object(s.__)("Dismiss this notice"),onClick:e=>{var t;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),h(),p()},showTooltip:!1}))}},,,,,,,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(14),o=n(0),c=n(66);n.p=c.k,Object(r.registerBlockComponent)({blockName:"woocommerce/product-price",component:Object(o.lazy)(()=>Promise.all([n.e(1),n.e(11)]).then(n.bind(null,362)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-image",component:Object(o.lazy)(()=>n.e(10).then(n.bind(null,395)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-title",component:Object(o.lazy)(()=>n.e(18).then(n.bind(null,396)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-rating",component:Object(o.lazy)(()=>n.e(12).then(n.bind(null,363)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-button",component:Object(o.lazy)(()=>n.e(8).then(n.bind(null,364)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-summary",component:Object(o.lazy)(()=>n.e(16).then(n.bind(null,365)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-sale-badge",component:Object(o.lazy)(()=>n.e(13).then(n.bind(null,285)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-sku",component:Object(o.lazy)(()=>n.e(14).then(n.bind(null,366)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-category-list",component:Object(o.lazy)(()=>n.e(9).then(n.bind(null,367)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-tag-list",component:Object(o.lazy)(()=>n.e(17).then(n.bind(null,368)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-stock-indicator",component:Object(o.lazy)(()=>n.e(15).then(n.bind(null,369)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-add-to-cart",component:Object(o.lazy)(()=>Promise.all([n.e(0),n.e(49),n.e(7)]).then(n.bind(null,382)))});const i=e=>Object(r.getRegisteredBlockComponents)(e)},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t){e.exports=window.wp.blockEditor},function(e,t){e.exports=window.wp.blocks},,,,,,,,,function(e,t,n){e.exports=n(199)},function(e,t){},function(e,t){},function(e,t){},,,,,,,,,,,,,,,,,,,,,function(e,t,n){"use strict";n.r(t);var r=n(0),o=n(87),c=n(53),i=n(3),s=(n(8),n(1)),a=n(5),l=n(4),u=n.n(l),d=n(21);n(178);const p=e=>{let{currentPage:t,displayFirstAndLastPages:n,displayNextAndPreviousArrows:o,pagesToDisplay:c,onPageChange:i,totalPages:a}=e,{minIndex:l,maxIndex:p}=((e,t,n)=>{if(n<=2)return{minIndex:null,maxIndex:null};const r=e-1,o=Math.max(Math.floor(t-r/2),2),c=Math.min(Math.ceil(t+(r-(t-o))),n-1);return{minIndex:Math.max(Math.floor(t-(r-(c-t))),2),maxIndex:c}})(c,t,a);const b=n&&Boolean(1!==l),m=n&&Boolean(p!==a),f=n&&Boolean(l>3),g=n&&Boolean(p<a-2);b&&3===l&&(l-=1),m&&p===a-2&&(p+=1);const h=[];if(l&&p)for(let e=l;e<=p;e++)h.push(e);return Object(r.createElement)("div",{className:"wc-block-pagination wc-block-components-pagination"},Object(r.createElement)(d.a,{screenReaderLabel:Object(s.__)("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:()=>i(t-1),title:Object(s.__)("Previous page","woo-gutenberg-products-block"),disabled:t<=1},Object(r.createElement)(d.a,{label:"←",screenReaderLabel:Object(s.__)("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:()=>i(1),disabled:1===t},Object(r.createElement)(d.a,{label:1,screenReaderLabel:Object(s.sprintf)(
|
4 |
/* translators: %d is the page number (1, 2, 3...). */
|
5 |
Object(s.__)("Page %d","woo-gutenberg-products-block"),1)})),f&&Object(r.createElement)("span",{className:"wc-block-pagination-ellipsis wc-block-components-pagination__ellipsis","aria-hidden":"true"},Object(s.__)("…","woo-gutenberg-products-block")),h.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?null:()=>i(e),disabled:t===e},Object(r.createElement)(d.a,{label:e,screenReaderLabel:Object(s.sprintf)(
|
6 |
/* translators: %d is the page number (1, 2, 3...). */
|
1 |
+
!function(e){function t(t){for(var n,o,c=t[0],i=t[1],s=0,l=[];s<c.length;s++)o=c[s],Object.prototype.hasOwnProperty.call(r,o)&&r[o]&&l.push(r[o][0]),r[o]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(a&&a(t);l.length;)l.shift()()}var n={},r={6:0};function o(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.e=function(e){var t=[],n=r[e];if(0!==n)if(n)t.push(n[2]);else{var c=new Promise((function(t,o){n=r[e]=[t,o]}));t.push(n[2]=c);var i,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--atomic-block-components/add-to-cart--cart-blocks/order-summary--checkout-blocks/billing-ad--c5eb4dcd",1:"vendors--atomic-block-components/price--cart-blocks/line-items--cart-blocks/order-summary--checkout--8a3571de",7:"atomic-block-components/add-to-cart",8:"atomic-block-components/button",9:"atomic-block-components/category-list",10:"atomic-block-components/image",11:"atomic-block-components/price",12:"atomic-block-components/rating",13:"atomic-block-components/sale-badge",14:"atomic-block-components/sku",15:"atomic-block-components/stock-indicator",16:"atomic-block-components/summary",17:"atomic-block-components/tag-list",18:"atomic-block-components/title",49:"vendors--atomic-block-components/add-to-cart"}[e]||e)+"-frontend.js?ver="+{0:"9f3f7160cea9fec6b729",1:"44e8b4583ef14d0d1fdc",7:"ee5feb020130d6d54f2f",8:"8422937830a5bcfcf69f",9:"1f06fe341fd8f54234c7",10:"74c8be03232e12b30df4",11:"48d5274d5fb14e493def",12:"46e4dc4d3ef4a90e2519",13:"85bf4bdec9cccca4d188",14:"72dec6d824d90bf826ee",15:"b4f088842ec47e5f7541",16:"527832cf95951e3b83f1",17:"7d00ba6a20aee45636d8",18:"57ed80fcace38dd7c8c0",49:"7fb4a4043fde41ff7bfe"}[e]}(e);var a=new Error;i=function(t){s.onerror=s.onload=null,clearTimeout(l);var n=r[e];if(0!==n){if(n){var o=t&&("load"===t.type?"missing":t.type),c=t&&t.target&&t.target.src;a.message="Loading chunk "+e+" failed.\n("+o+": "+c+")",a.name="ChunkLoadError",a.type=o,a.request=c,n[1](a)}r[e]=void 0}};var l=setTimeout((function(){i({type:"timeout",target:s})}),12e4);s.onerror=s.onload=i,document.head.appendChild(s)}return Promise.all(t)},o.m=e,o.c=n,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)o.d(n,r,function(t){return e[t]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o.oe=function(e){throw console.error(e),e};var c=window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[],i=c.push.bind(c);c.push=t,c=c.slice();for(var s=0;s<c.length;s++)t(c[s]);var a=i;o(o.s=175)}([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.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 c=typeof r;if("string"===c||"number"===c)e.push(r);else if(Array.isArray(r)){if(r.length){var i=o.apply(null,r);i&&e.push(i)}}else if("object"===c)if(r.toString===Object.prototype.toString)for(var s in r)n.call(r,s)&&r[s]&&e.push(s);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.wcBlocksData},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,n){e.exports=n(42)()},function(e,t){e.exports=window.wp.data},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.default=e.exports,e.exports.__esModule=!0,n.apply(this,arguments)}e.exports=n,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=window.wp.isShallowEqual},function(e,t){e.exports=window.wp.compose},,function(e,t){e.exports=window.wc.wcBlocksRegistry},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.default=e.exports,e.exports.__esModule=!0},function(e,t,n){"use strict";var r=n(15),o=n.n(r),c=n(0),i=n(3),s=n(1),a=n(65),l=e=>{let{imageUrl:t=a.l+"/block-error.svg",header:n=Object(s.__)("Oops!","woo-gutenberg-products-block"),text:r=Object(s.__)("There was an error loading the content.","woo-gutenberg-products-block"),errorMessage:o,errorMessagePrefix:i=Object(s.__)("Error:","woo-gutenberg-products-block"),button:l}=e;return Object(c.createElement)("div",{className:"wc-block-error wc-block-components-error"},t&&Object(c.createElement)("img",{className:"wc-block-error__image wc-block-components-error__image",src:t,alt:""}),Object(c.createElement)("div",{className:"wc-block-error__content wc-block-components-error__content"},n&&Object(c.createElement)("p",{className:"wc-block-error__header wc-block-components-error__header"},n),r&&Object(c.createElement)("p",{className:"wc-block-error__text wc-block-components-error__text"},r),o&&Object(c.createElement)("p",{className:"wc-block-error__message wc-block-components-error__message"},i?i+" ":"",o),l&&Object(c.createElement)("p",{className:"wc-block-error__button wc-block-components-error__button"},l)))};n(37);class u extends i.Component{constructor(){super(...arguments),o()(this,"state",{errorMessage:"",hasError:!1})}static getDerivedStateFromError(e){return void 0!==e.statusText&&void 0!==e.status?{errorMessage:Object(c.createElement)(c.Fragment,null,Object(c.createElement)("strong",null,e.status),": ",e.statusText),hasError:!0}:{errorMessage:e.message,hasError:!0}}render(){const{header:e,imageUrl:t,showErrorMessage:n=!0,text:r,errorMessagePrefix:o,renderError:i,button:s}=this.props,{errorMessage:a,hasError:u}=this.state;return u?"function"==typeof i?i({errorMessage:a}):Object(c.createElement)(l,{errorMessage:n?a:null,header:e,imageUrl:t,text:r,errorMessagePrefix:o,button:s}):this.props.children}}t.a=u},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(0),o=n(11),c=n.n(o);function i(e){const t=Object(r.useRef)(e);return c()(e,t.current)||(t.current=e),t.current}},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(0);n(9);const o=Object(r.createContext)({isEditor:!1,currentPostId:0,currentView:"",previewData:{},getPreviewData:()=>{}}),c=()=>Object(r.useContext)(o)},function(e,t){e.exports=window.wp.htmlEntities},,function(e,t,n){"use strict";var r=n(0),o=n(4),c=n.n(o);t.a=e=>{let t,{label:n,screenReaderLabel:o,wrapperElement:i,wrapperProps:s={}}=e;const a=null!=n,l=null!=o;return!a&&l?(t=i||"span",s={...s,className:c()(s.className,"screen-reader-text")},Object(r.createElement)(t,s,o)):(t=i||r.Fragment,a&&l&&n!==o?Object(r.createElement)(t,s,Object(r.createElement)("span",{"aria-hidden":"true"},n),Object(r.createElement)("span",{className:"screen-reader-text"},o)):Object(r.createElement)(t,s,n))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return w}));var r=n(5),o=n(0),c=n(6),i=n(9),s=n(19),a=n(70),l=n(109),u=n(18),d=n(67);const p=e=>{const t=e.detail;t&&t.preserveCartData||Object(i.dispatch)(c.CART_STORE_KEY).invalidateResolutionForStore()},b=()=>{1===window.wcBlocksStoreCartListeners.count&&window.wcBlocksStoreCartListeners.remove(),window.wcBlocksStoreCartListeners.count--},m=()=>{Object(o.useEffect)(()=>((()=>{if(window.wcBlocksStoreCartListeners||(window.wcBlocksStoreCartListeners={count:0,remove:()=>{}}),0===window.wcBlocksStoreCartListeners.count){const e=Object(d.b)("added_to_cart","wc-blocks_added_to_cart"),t=Object(d.b)("removed_from_cart","wc-blocks_removed_from_cart");document.body.addEventListener("wc-blocks_added_to_cart",p),document.body.addEventListener("wc-blocks_removed_from_cart",p),window.wcBlocksStoreCartListeners.count=0,window.wcBlocksStoreCartListeners.remove=()=>{e(),t(),document.body.removeEventListener("wc-blocks_added_to_cart",p),document.body.removeEventListener("wc-blocks_removed_from_cart",p)}}window.wcBlocksStoreCartListeners.count++})(),b),[])},f={first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:""},g={...f,email:""},h={total_items:"",total_items_tax:"",total_fees:"",total_fees_tax:"",total_discount:"",total_discount_tax:"",total_shipping:"",total_shipping_tax:"",total_price:"",total_tax:"",tax_lines:c.EMPTY_TAX_LINES,currency_code:"",currency_symbol:"",currency_minor_unit:2,currency_decimal_separator:"",currency_thousand_separator:"",currency_prefix:"",currency_suffix:""},E=e=>Object(a.a)(Object.entries(e).map(e=>{let[t,n]=e;return[t,Object(s.decodeEntities)(n)]})),O={cartCoupons:c.EMPTY_CART_COUPONS,cartItems:c.EMPTY_CART_ITEMS,cartFees:c.EMPTY_CART_FEES,cartItemsCount:0,cartItemsWeight:0,cartNeedsPayment:!0,cartNeedsShipping:!0,cartItemErrors:c.EMPTY_CART_ITEM_ERRORS,cartTotals:h,cartIsLoading:!0,cartErrors:c.EMPTY_CART_ERRORS,billingAddress:g,shippingAddress:f,shippingRates:c.EMPTY_SHIPPING_RATES,shippingRatesLoading:!1,cartHasCalculatedShipping:!1,paymentRequirements:c.EMPTY_PAYMENT_REQUIREMENTS,receiveCart:()=>{},extensions:c.EMPTY_EXTENSIONS},w=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{shouldSelect:!0};const{isEditor:t,previewData:n}=Object(u.a)(),s=null==n?void 0:n.previewCart,{shouldSelect:a}=e,d=Object(o.useRef)();m();const p=Object(i.useSelect)((e,n)=>{let{dispatch:r}=n;if(!a)return O;if(t)return{cartCoupons:s.coupons,cartItems:s.items,cartFees:s.fees,cartItemsCount:s.items_count,cartItemsWeight:s.items_weight,cartNeedsPayment:s.needs_payment,cartNeedsShipping:s.needs_shipping,cartItemErrors:c.EMPTY_CART_ITEM_ERRORS,cartTotals:s.totals,cartIsLoading:!1,cartErrors:c.EMPTY_CART_ERRORS,billingAddress:g,shippingAddress:f,extensions:c.EMPTY_EXTENSIONS,shippingRates:s.shipping_rates,shippingRatesLoading:!1,cartHasCalculatedShipping:s.has_calculated_shipping,paymentRequirements:s.paymentRequirements,receiveCart:"function"==typeof(null==s?void 0:s.receiveCart)?s.receiveCart:()=>{}};const o=e(c.CART_STORE_KEY),i=o.getCartData(),u=o.getCartErrors(),d=o.getCartTotals(),p=!o.hasFinishedResolution("getCartData"),b=o.isCustomerDataUpdating(),{receiveCart:m}=r(c.CART_STORE_KEY),h=E(i.billingAddress),w=i.needsShipping?E(i.shippingAddress):h,j=i.fees.length>0?i.fees.map(e=>E(e)):c.EMPTY_CART_FEES;return{cartCoupons:i.coupons.length>0?i.coupons.map(e=>({...e,label:e.code})):c.EMPTY_CART_COUPONS,cartItems:i.items,cartFees:j,cartItemsCount:i.itemsCount,cartItemsWeight:i.itemsWeight,cartNeedsPayment:i.needsPayment,cartNeedsShipping:i.needsShipping,cartItemErrors:i.errors,cartTotals:d,cartIsLoading:p,cartErrors:u,billingAddress:Object(l.a)(h),shippingAddress:Object(l.a)(w),extensions:i.extensions,shippingRates:i.shippingRates,shippingRatesLoading:b,cartHasCalculatedShipping:i.hasCalculatedShipping,paymentRequirements:i.paymentRequirements,receiveCart:m}},[a]);return d.current&&Object(r.isEqual)(d.current,p)||(d.current=p),d.current}},function(e,t){e.exports=window.wp.a11y},function(e,t){e.exports=window.wp.primitives},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(0);const o=Object(r.createContext)("page"),c=()=>Object(r.useContext)(o);o.Provider},function(e,t,n){"use strict";(function(e){var r=n(0);n(45);const o=Object(r.createContext)({slots:{},fills:{},registerSlot:()=>{void 0!==e&&e.env},updateSlot:()=>{},unregisterSlot:()=>{},registerFill:()=>{},unregisterFill:()=>{}});t.a=o}).call(this,n(66))},function(e,t){e.exports=window.wp.apiFetch},,,function(e,t){e.exports=window.wp.deprecated},,,,function(e,t){e.exports=window.wp.url},function(e,t,n){"use strict";n.d(t,"b",(function(){return r})),n.d(t,"d",(function(){return o})),n.d(t,"c",(function(){return c})),n.d(t,"e",(function(){return i})),n.d(t,"a",(function(){return s}));const r=e=>"number"==typeof e,o=e=>"string"==typeof e,c=e=>!(e=>null===e)(e)&&e instanceof Object&&e.constructor===Object;function i(e,t){return c(e)&&t in e}const s=e=>"boolean"==typeof e},,function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(48),o=n(0),c=n(22);const i=()=>{const e=Object(c.a)(),t=Object(o.useRef)(e);return Object(o.useEffect)(()=>{t.current=e},[e]),{dispatchStoreEvent:Object(o.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(r.doAction)("experimental__woocommerce_blocks-"+e,t)}catch(e){console.error(e)}}),[]),dispatchCheckoutEvent:Object(o.useCallback)((function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(r.doAction)("experimental__woocommerce_blocks-checkout-"+e,{...n,storeCart:t.current})}catch(e){console.error(e)}}),[])}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return d})),n.d(t,"b",(function(){return p})),n.d(t,"c",(function(){return b}));var r=n(6),o=n(9),c=n(0),i=n(11),s=n.n(i),a=n(17),l=n(62),u=n(25);const d=e=>{const t=Object(u.a)();e=e||t;const n=Object(o.useSelect)(t=>t(r.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0),[e]),{setValueForQueryContext:i}=Object(o.useDispatch)(r.QUERY_STATE_STORE_KEY);return[n,Object(c.useCallback)(t=>{i(e,t)},[e,i])]},p=(e,t,n)=>{const i=Object(u.a)();n=n||i;const s=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[s,Object(c.useCallback)(t=>{a(n,e,t)},[n,e,a])]},b=(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),b=Object(l.a)(p),m=Object(c.useRef)(!1);return Object(c.useEffect)(()=>{s()(b,p)||(o(Object.assign({},i,p)),m.current=!0)},[i,p,b,o]),m.current?[r,o]:[e,o]}},function(e,t){e.exports=window.wc.priceFormat},,function(e,t,n){"use strict";var r=n(43);function o(){}function c(){}c.resetWarningCache=o,e.exports=function(){function e(e,t,n,o,c,i){if(i!==r){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:c,resetWarningCache:o};return n.PropTypes=n,n}},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},,function(e,t){e.exports=window.wp.warning},function(e,t,n){"use strict";var r=n(7),o=n(0),c=n(24),i=function({icon:e,className:t,...n}){const c=["dashicon","dashicons","dashicons-"+e,t].filter(Boolean).join(" ");return Object(o.createElement)("span",Object(r.a)({className:c},n))};t.a=function({icon:e=null,size:t=24,...n}){if("string"==typeof e)return Object(o.createElement)(i,Object(r.a)({icon:e},n));if(Object(o.isValidElement)(e)&&i===e.type)return Object(o.cloneElement)(e,{...n});if("function"==typeof e)return e.prototype instanceof o.Component?Object(o.createElement)(e,{size:t,...n}):e({size:t,...n});if(e&&("svg"===e.type||e.type===c.SVG)){const r={width:t,height:t,...e.props,...n};return Object(o.createElement)(c.SVG,r)}return Object(o.isValidElement)(e)?Object(o.cloneElement)(e,{size:t,...n}):e}},function(e,t,n){"use strict";var r=n(4),o=n.n(r),c=n(0);t.a=Object(c.forwardRef)((function({as:e="div",className:t,...n},r){return function({as:e="div",...t}){return"function"==typeof t.children?t.children(t):Object(c.createElement)(e,t)}({as:e,className:o()("components-visually-hidden",t),...n,ref:r})}))},function(e,t){e.exports=window.wp.hooks},function(e,t){e.exports=window.wc.wcBlocksSharedContext},function(e,t,n){"use strict";var r=n(2),o=n(1),c=n(35);const i=Object(r.getSetting)("countryLocale",{}),s=e=>{const t={};return void 0!==e.label&&(t.label=e.label),void 0!==e.required&&(t.required=e.required),void 0!==e.hidden&&(t.hidden=e.hidden),void 0===e.label||e.optionalLabel||(t.optionalLabel=Object(o.sprintf)(
|
2 |
/* translators: %s Field label. */
|
3 |
+
Object(o.__)("%s (optional)","woo-gutenberg-products-block"),e.label)),e.priority&&(Object(c.b)(e.priority)&&(t.index=e.priority),Object(c.d)(e.priority)&&(t.index=parseInt(e.priority,10))),e.hidden&&(t.required=!1),t},a=Object.entries(i).map(e=>{let[t,n]=e;return[t,Object.entries(n).map(e=>{let[t,n]=e;return[t,s(n)]}).reduce((e,t)=>{let[n,r]=t;return e[n]=r,e},{})]}).reduce((e,t)=>{let[n,r]=t;return e[n]=r,e},{});t.a=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";const o=n&&void 0!==a[n]?a[n]:{};return e.map(e=>({key:e,...r.defaultAddressFields[e]||{},...o[e]||{},...t[e]||{}})).sort((e,t)=>e.index-t.index)}},,,function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(10),o=n.n(r),c=n(0),i=n(16);const s=[".wp-block-woocommerce-cart"],a=e=>{let{Block:t,containers:n,getProps:r=(()=>({})),getErrorBoundaryProps:s=(()=>({}))}=e;0!==n.length&&Array.prototype.forEach.call(n,(e,n)=>{const a=r(e,n),l=s(e,n),u={...e.dataset,...a.attributes||{}};(e=>{let{Block:t,container:n,attributes:r={},props:s={},errorBoundaryProps:a={}}=e;Object(c.render)(Object(c.createElement)(i.a,a,Object(c.createElement)(c.Suspense,{fallback:Object(c.createElement)("div",{className:"wc-block-placeholder"})},t&&Object(c.createElement)(t,o()({},s,{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(s.join(",")),{Block:n,getProps:r,getErrorBoundaryProps:o,selector:c}=e;(e=>{let{Block:t,getProps:n,getErrorBoundaryProps:r,selector:o,wrappers:c}=e;const i=document.body.querySelectorAll(o);c&&c.length>0&&Array.prototype.filter.call(i,e=>!((e,t)=>Array.prototype.some.call(t,t=>t.contains(e)&&!t.isSameNode(e)))(e,c)),a({Block:t,containers:i,getProps:n,getErrorBoundaryProps:r})})({Block:n,getProps:r,getErrorBoundaryProps:o,selector:c,wrappers:t}),Array.prototype.forEach.call(t,t=>{t.addEventListener("wc-blocks_render_blocks_frontend",()=>{(e=>{let{Block:t,getProps:n,getErrorBoundaryProps:r,selector:o,wrapper:c}=e;const i=c.querySelectorAll(o);a({Block:t,containers:i,getProps:n,getErrorBoundaryProps:r})})({...e,wrapper:t})})})}},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(7),o=n(0),c=n(4),i=n.n(c),s=n(5),a=n(30),l=n.n(a),u=n(12),d=n(60),p=n(90),b=n(1);function m(e,t,n){const{defaultView:r}=t,{frameElement:o}=r;if(!o||t===n.ownerDocument)return e;const c=o.getBoundingClientRect();return new r.DOMRect(e.left+c.left,e.top+c.top,e.width,e.height)}let f=0;function g(e){const t=document.scrollingElement||document.body;e&&(f=t.scrollTop);const n=e?"add":"remove";t.classList[n]("lockscroll"),document.documentElement.classList[n]("lockscroll"),e||(t.scrollTop=f)}let h=0;function E(){return Object(o.useEffect)(()=>(0===h&&g(!0),++h,()=>{1===h&&g(!1),--h}),[]),null}var O=n(26);function w(e){const t=Object(o.useContext)(O.a),n=t.slots[e]||{},r=t.fills[e],c=Object(o.useMemo)(()=>r||[],[r]);return{...n,updateSlot:Object(o.useCallback)(n=>{t.updateSlot(e,n)},[e,t.updateSlot]),unregisterSlot:Object(o.useCallback)(n=>{t.unregisterSlot(e,n)},[e,t.unregisterSlot]),fills:c,registerFill:Object(o.useCallback)(n=>{t.registerFill(e,n)},[e,t.registerFill]),unregisterFill:Object(o.useCallback)(n=>{t.unregisterFill(e,n)},[e,t.unregisterFill])}}var j=Object(o.createContext)({registerSlot:()=>{},unregisterSlot:()=>{},registerFill:()=>{},unregisterFill:()=>{},getSlot:()=>{},getFills:()=>{},subscribe:()=>{}});function y({name:e,children:t,registerFill:n,unregisterFill:r}){const c=(e=>{const{getSlot:t,subscribe:n}=Object(o.useContext)(j),[r,c]=Object(o.useState)(t(e));return Object(o.useEffect)(()=>(c(t(e)),n(()=>{c(t(e))})),[e]),r})(e),i=Object(o.useRef)({name:e,children:t});return Object(o.useLayoutEffect)(()=>(n(e,i.current),()=>r(e,i.current)),[]),Object(o.useLayoutEffect)(()=>{i.current.children=t,c&&c.forceUpdate()},[t]),Object(o.useLayoutEffect)(()=>{e!==i.current.name&&(r(i.current.name,i.current),i.current.name=e,n(e,i.current))},[e]),c&&c.node?(Object(s.isFunction)(t)&&(t=t(c.props.fillProps)),Object(o.createPortal)(t,c.node)):null}var v=e=>Object(o.createElement)(j.Consumer,null,({registerFill:t,unregisterFill:n})=>Object(o.createElement)(y,Object(r.a)({},e,{registerFill:t,unregisterFill:n})));class _ extends o.Component{constructor(){super(...arguments),this.isUnmounted=!1,this.bindNode=this.bindNode.bind(this)}componentDidMount(){const{registerSlot:e}=this.props;e(this.props.name,this)}componentWillUnmount(){const{unregisterSlot:e}=this.props;this.isUnmounted=!0,e(this.props.name,this)}componentDidUpdate(e){const{name:t,unregisterSlot:n,registerSlot:r}=this.props;e.name!==t&&(n(e.name),r(t,this))}bindNode(e){this.node=e}forceUpdate(){this.isUnmounted||super.forceUpdate()}render(){const{children:e,name:t,fillProps:n={},getFills:r}=this.props,c=Object(s.map)(r(t,this),e=>{const t=Object(s.isFunction)(e.children)?e.children(n):e.children;return o.Children.map(t,(e,t)=>{if(!e||Object(s.isString)(e))return e;const n=e.key||t;return Object(o.cloneElement)(e,{key:n})})}).filter(Object(s.negate)(o.isEmptyElement));return Object(o.createElement)(o.Fragment,null,Object(s.isFunction)(e)?e(c):c)}}var x=e=>Object(o.createElement)(j.Consumer,null,({registerSlot:t,unregisterSlot:n,getFills:c})=>Object(o.createElement)(_,Object(r.a)({},e,{registerSlot:t,unregisterSlot:n,getFills:c})));function k(){const[,e]=Object(o.useState)({}),t=Object(o.useRef)(!0);return Object(o.useEffect)(()=>()=>{t.current=!1},[]),()=>{t.current&&e({})}}function C({name:e,children:t}){const n=w(e),r=Object(o.useRef)({rerender:k()});return Object(o.useEffect)(()=>(n.registerFill(r),()=>{n.unregisterFill(r)}),[n.registerFill,n.unregisterFill]),n.ref&&n.ref.current?("function"==typeof t&&(t=t(n.fillProps)),Object(o.createPortal)(t,n.ref.current)):null}var S=Object(o.forwardRef)((function({name:e,fillProps:t={},as:n="div",...c},i){const s=Object(o.useContext)(O.a),a=Object(o.useRef)();return Object(o.useLayoutEffect)(()=>(s.registerSlot(e,a,t),()=>{s.unregisterSlot(e,a)}),[s.registerSlot,s.unregisterSlot,e]),Object(o.useLayoutEffect)(()=>{s.updateSlot(e,t)}),Object(o.createElement)(n,Object(r.a)({ref:Object(u.useMergeRefs)([i,a])},c))}));function N(e){return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(v,e),Object(o.createElement)(C,e))}n(11),o.Component;const P=Object(o.forwardRef)(({bubblesVirtually:e,...t},n)=>e?Object(o.createElement)(S,Object(r.a)({},t,{ref:n})):Object(o.createElement)(x,t));function R(e){return"appear"===e?"top":"left"}function T(e,t){const{paddingTop:n,paddingBottom:r,paddingLeft:o,paddingRight:c}=(i=t).ownerDocument.defaultView.getComputedStyle(i);var i;const s=n?parseInt(n,10):0,a=r?parseInt(r,10):0,l=o?parseInt(o,10):0,u=c?parseInt(c,10):0;return{x:e.left+l,y:e.top+s,width:e.width-l-u,height:e.height-s-a,left:e.left+l,right:e.right-u,top:e.top+s,bottom:e.bottom-a}}function L(e,t,n){n?e.getAttribute(t)!==n&&e.setAttribute(t,n):e.hasAttribute(t)&&e.removeAttribute(t)}function A(e,t,n=""){e.style[t]!==n&&(e.style[t]=n)}function B(e,t,n){n?e.classList.contains(t)||e.classList.add(t):e.classList.contains(t)&&e.classList.remove(t)}const M=Object(o.forwardRef)(({headerTitle:e,onClose:t,children:n,className:c,noArrow:s=!0,isAlternate:a,position:f="bottom right",range:g,focusOnMount:h="firstElement",anchorRef:O,shouldAnchorIncludePadding:j,anchorRect:y,getAnchorRect:v,expandOnMobile:_,animate:x=!0,onClickOutside:k,onFocusOutside:C,__unstableStickyBoundaryElement:S,__unstableSlotName:P="Popover",__unstableObserveElement:M,__unstableBoundaryParent:F,__unstableForcePosition:I,__unstableForceXAlignment:D,...V},W)=>{const z=Object(o.useRef)(null),H=Object(o.useRef)(null),U=Object(o.useRef)(),Y=Object(u.useViewportMatch)("medium","<"),[q,Q]=Object(o.useState)(),K=w(P),X=_&&Y,[J,Z]=Object(u.useResizeObserver)();s=X||s,Object(o.useLayoutEffect)(()=>{if(X)return B(U.current,"is-without-arrow",s),B(U.current,"is-alternate",a),L(U.current,"data-x-axis"),L(U.current,"data-y-axis"),A(U.current,"top"),A(U.current,"left"),A(H.current,"maxHeight"),void A(H.current,"maxWidth");const e=()=>{if(!U.current||!H.current)return;let e=function(e,t,n,r=!1,o,c){if(t)return t;if(n){if(!e.current)return;const t=n(e.current);return m(t,t.ownerDocument||e.current.ownerDocument,c)}if(!1!==r){if(!(r&&window.Range&&window.Element&&window.DOMRect))return;if("function"==typeof(null==r?void 0:r.cloneRange))return m(Object(d.getRectangleFromRange)(r),r.endContainer.ownerDocument,c);if("function"==typeof(null==r?void 0:r.getBoundingClientRect)){const e=m(r.getBoundingClientRect(),r.ownerDocument,c);return o?e:T(e,r)}const{top:e,bottom:t}=r,n=e.getBoundingClientRect(),i=t.getBoundingClientRect(),s=m(new window.DOMRect(n.left,n.top,n.width,i.bottom-n.top),e.ownerDocument,c);return o?s:T(s,r)}if(!e.current)return;const{parentNode:i}=e.current,s=i.getBoundingClientRect();return o?s:T(s,i)}(z,y,v,O,j,U.current);if(!e)return;const{offsetParent:t,ownerDocument:n}=U.current;let r,o=0;if(t&&t!==n.body){const n=t.getBoundingClientRect();o=n.top,e=new window.DOMRect(e.left-n.left,e.top-n.top,e.width,e.height)}var c;F&&(r=null===(c=U.current.closest(".popover-slot"))||void 0===c?void 0:c.parentNode);const i=Z.height?Z:H.current.getBoundingClientRect(),{popoverTop:l,popoverLeft:u,xAxis:p,yAxis:g,contentHeight:h,contentWidth:E}=function(e,t,n="top",r,o,c,i,s,a){const[l,u="center",d]=n.split(" "),p=function(e,t,n,r,o,c,i,s){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 b,m=n,f=null;if(!o&&!s)if("middle"===n&&u.contentHeight===a)m="middle";else if("top"===n&&d.contentHeight===a)m="top";else if("bottom"===n&&p.contentHeight===a)m="bottom";else{m=d.contentHeight>p.contentHeight?"top":"bottom";const e="top"===m?d.contentHeight:p.contentHeight;f=e!==a?e:null}return b="middle"===m?u.popoverTop:"top"===m?d.popoverTop:p.popoverTop,{yAxis:m,popoverTop:b,contentHeight:f}}(e,t,l,d,r,0,c,s);return{...function(e,t,n,r,o,c,i,s,a){const{width:l}=t;"left"===n&&Object(b.isRTL)()?n="right":"right"===n&&Object(b.isRTL)()&&(n="left"),"left"===r&&Object(b.isRTL)()?r="right":"right"===r&&Object(b.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"===c||a||(p=u);let m=e.right;"left"===r?m=e.left:"middle"===c||a||(m=u);const f={popoverLeft:p,contentWidth:p-l>0?l:p},g={popoverLeft:m,contentWidth:m+l>window.innerWidth?window.innerWidth-m:l};let h,E=n,O=null;if(!o&&!s)if("center"===n&&d.contentWidth===l)E="center";else if("left"===n&&f.contentWidth===l)E="left";else if("right"===n&&g.contentWidth===l)E="right";else{E=f.contentWidth>g.contentWidth?"left":"right";const e="left"===E?f.contentWidth:g.contentWidth;l>window.innerWidth&&(O=window.innerWidth),e!==l&&(E="center",d.popoverLeft=window.innerWidth/2)}if(h="center"===E?d.popoverLeft:"left"===E?f.popoverLeft:g.popoverLeft,i){const e=i.getBoundingClientRect();h=Math.min(h,e.right-l),Object(b.isRTL)()||(h=Math.max(h,0))}return{xAxis:E,popoverLeft:h,contentWidth:O}}(e,t,u,d,r,p.yAxis,i,s,a),...p}}(e,i,f,S,U.current,o,r,I,D);"number"==typeof l&&"number"==typeof u&&(A(U.current,"top",l+"px"),A(U.current,"left",u+"px")),B(U.current,"is-without-arrow",s||"center"===p&&"middle"===g),B(U.current,"is-alternate",a),L(U.current,"data-x-axis",p),L(U.current,"data-y-axis",g),A(H.current,"maxHeight","number"==typeof h?h+"px":""),A(H.current,"maxWidth","number"==typeof E?E+"px":""),Q(({left:"right",right:"left"}[p]||"center")+" "+({top:"bottom",bottom:"top"}[g]||"middle"))};e();const{ownerDocument:t}=U.current,{defaultView:n}=t,r=n.setInterval(e,500);let o;const c=()=>{n.cancelAnimationFrame(o),o=n.requestAnimationFrame(e)};n.addEventListener("click",c),n.addEventListener("resize",e),n.addEventListener("scroll",e,!0);const i=function(e){if(e)return e.endContainer?e.endContainer.ownerDocument:e.top?e.top.ownerDocument:e.ownerDocument}(O);let l;return i&&i!==t&&(i.defaultView.addEventListener("resize",e),i.defaultView.addEventListener("scroll",e,!0)),M&&(l=new n.MutationObserver(e),l.observe(M,{attributes:!0})),()=>{n.clearInterval(r),n.removeEventListener("resize",e),n.removeEventListener("scroll",e,!0),n.removeEventListener("click",c),n.cancelAnimationFrame(o),i&&i!==t&&(i.defaultView.removeEventListener("resize",e),i.defaultView.removeEventListener("scroll",e,!0)),l&&l.disconnect()}},[X,y,v,O,j,f,Z,S,M,F]);const $=(e,n)=>{if("focus-outside"===e&&C)C(n);else if("focus-outside"===e&&k){const e=new window.MouseEvent("click");Object.defineProperty(e,"target",{get:()=>n.relatedTarget}),l()("Popover onClickOutside prop",{since:"5.3",alternative:"onFocusOutside"}),k(e)}else t&&t()},[ee,te]=Object(u.__experimentalUseDialog)({focusOnMount:h,__unstableOnClose:$,onClose:$}),ne=Object(u.useMergeRefs)([U,ee,W]),re=Boolean(x&&q)&&function(e){if("loading"===e.type)return i()("components-animate__loading");const{type:t,origin:n=R(t)}=e;if("appear"===t){const[e,t="center"]=n.split(" ");return i()("components-animate__appear",{["is-from-"+t]:"center"!==t,["is-from-"+e]:"middle"!==e})}return"slide-in"===t?i()("components-animate__slide-in","is-from-"+n):void 0}({type:"appear",origin:q});let oe=Object(o.createElement)("div",Object(r.a)({className:i()("components-popover",c,re,{"is-expanded":X,"is-without-arrow":s,"is-alternate":a})},V,{ref:ne},te,{tabIndex:"-1"}),X&&Object(o.createElement)(E,null),X&&Object(o.createElement)("div",{className:"components-popover__header"},Object(o.createElement)("span",{className:"components-popover__header-title"},e),Object(o.createElement)(G,{className:"components-popover__close",icon:p.a,onClick:t})),Object(o.createElement)("div",{ref:H,className:"components-popover__content"},Object(o.createElement)("div",{style:{position:"relative"}},J,n)));return K.ref&&(oe=Object(o.createElement)(N,{name:P},oe)),O||y?oe:Object(o.createElement)("span",{ref:z},oe)});M.Slot=Object(o.forwardRef)((function({name:e="Popover"},t){return Object(o.createElement)(P,{bubblesVirtually:!0,name:e,className:"popover-slot",ref:t})}));var F=M,I=function({shortcut:e,className:t}){if(!e)return null;let n,r;return Object(s.isString)(e)&&(n=e),Object(s.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}),z=(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 H=function({children:e,position:t,text:n,shortcut:r}){const[c,i]=Object(o.useState)(!1),[a,l]=Object(o.useState)(!1),d=Object(u.useDebounce)(l,700),p=t=>{z(e,"onMouseDown",t),document.addEventListener("mouseup",f),i(!0)},b=t=>{z(e,"onMouseUp",t),document.removeEventListener("mouseup",f),i(!1)},m=e=>"mouseUp"===e?b:"mouseDown"===e?p:void 0,f=m("mouseUp"),g=(t,n)=>r=>{if(z(e,t,r),r.currentTarget.disabled)return;if("focus"===r.type&&c)return;d.cancel();const o=Object(s.includes)(["focus","mouseenter"],r.type);o!==a&&(n?d(o):l(o))},h=()=>{d.cancel(),document.removeEventListener("mouseup",f)};if(Object(o.useEffect)(()=>h,[]),1!==o.Children.count(e))return e;const E={onMouseEnter:g("onMouseEnter",!0),onMouseLeave:g("onMouseLeave"),onClick:g("onClick"),onFocus:g("onFocus"),onBlur:g("onBlur"),onMouseDown:m("mouseDown")},O=o.Children.only(e),{children:w,disabled:j}=O.props;return(j?V:W)({child:O,eventHandlers:E,childrenWithPopover:(({grandchildren:e,isOver:t,position:n,text:r,shortcut:c})=>Object(o.concatChildren)(e,t&&Object(o.createElement)(F,{focusOnMount:!1,position:n,className:"components-tooltip","aria-hidden":"true",animate:!1,noArrow:!0},r,Object(o.createElement)(I,{className:"components-tooltip__shortcut",shortcut:c}))))({grandchildren:w,isOver:a,position:t,text:n,shortcut:r})})},U=n(46),Y=n(47);const q=["onMouseDown","onClick"];var G=t.a=Object(o.forwardRef)((function(e,t){const{href:n,target:c,isSmall:a,isPressed:u,isBusy:d,isDestructive:p,className:b,disabled:m,icon:f,iconPosition:g="left",iconSize:h,showTooltip:E,tooltipPosition:O,shortcut:w,label:j,children:y,text:v,variant:_,__experimentalIsFocusable:x,describedBy:k,...C}=function({isDefault:e,isPrimary:t,isSecondary:n,isTertiary:r,isLink:o,variant:c,...i}){let s=c;var a,u,d,p,b;return t&&(null!==(a=s)&&void 0!==a||(s="primary")),r&&(null!==(u=s)&&void 0!==u||(s="tertiary")),n&&(null!==(d=s)&&void 0!==d||(s="secondary")),e&&(l()("Button isDefault prop",{since:"5.4",alternative:'variant="secondary"'}),null!==(p=s)&&void 0!==p||(s="secondary")),o&&(null!==(b=s)&&void 0!==b||(s="link")),{...i,variant:s}}(e),S=i()("components-button",b,{"is-secondary":"secondary"===_,"is-primary":"primary"===_,"is-small":a,"is-tertiary":"tertiary"===_,"is-pressed":u,"is-busy":d,"is-link":"link"===_,"is-destructive":p,"has-text":!!f&&!!y,"has-icon":!!f}),N=m&&!x,P=void 0===n||N?"button":"a",R="a"===P?{href:n,target:c}:{type:"button",disabled:N,"aria-pressed":u};if(m&&x){R["aria-disabled"]=!0;for(const e of q)C[e]=e=>{e.stopPropagation(),e.preventDefault()}}const T=!N&&(E&&j||w||!!j&&(!y||Object(s.isArray)(y)&&!y.length)&&!1!==E),L=k?Object(s.uniqueId)():null,A=C["aria-describedby"]||L,B=Object(o.createElement)(P,Object(r.a)({},R,C,{className:S,"aria-label":C["aria-label"]||j,"aria-describedby":A,ref:t}),f&&"left"===g&&Object(o.createElement)(U.a,{icon:f,size:h}),v&&Object(o.createElement)(o.Fragment,null,v),f&&"right"===g&&Object(o.createElement)(U.a,{icon:f,size:h}),y);return T?Object(o.createElement)(o.Fragment,null,Object(o.createElement)(H,{text:k||j,shortcut:w,position:O},B),k&&Object(o.createElement)(Y.a,null,Object(o.createElement)("span",{id:L},k))):Object(o.createElement)(o.Fragment,null,B,k&&Object(o.createElement)(Y.a,null,Object(o.createElement)("span",{id:L},k)))}))},,,,function(e,t){e.exports=window.wp.dom},,function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(3);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";n.d(t,"a",(function(){return a}));var r=n(6),o=n(9),c=n(0),i=n(17),s=n(54);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(c.useRef)({results:[],isLoading:!0}),p=Object(i.a)(l),b=Object(i.a)(a),m=Object(s.a)(),f=Object(o.useSelect)(e=>{if(!u)return null;const o=e(r.COLLECTIONS_STORE_KEY),c=[t,n,p,b],i=o.getCollectionError(...c);return i&&m(i),{results:o.getCollection(...c),isLoading:!o.hasFinishedResolution("getCollection",c)}},[t,n,b,p,u]);return null!==f&&(d.current=f),d.current}},function(e,t,n){"use strict";n.d(t,"n",(function(){return c})),n.d(t,"l",(function(){return i})),n.d(t,"k",(function(){return s})),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 b})),n.d(t,"e",(function(){return m})),n.d(t,"g",(function(){return f})),n.d(t,"a",(function(){return g})),n.d(t,"h",(function(){return h})),n.d(t,"b",(function(){return E}));var r,o=n(2);const c=Object(o.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),i=c.pluginUrl+"images/",s=c.pluginUrl+"build/",a=c.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),b=(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"),f=Object(o.getSetting)("shippingCountries",{}),g=Object(o.getSetting)("allowedCountries",{}),h=Object(o.getSetting)("shippingStates",{}),E=Object(o.getSetting)("allowedStates",{})},function(e,t){var n,r,o=e.exports={};function c(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function s(e){if(n===setTimeout)return setTimeout(e,0);if((n===c||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:c}catch(e){n=c}try{r="function"==typeof clearTimeout?clearTimeout:i}catch(e){r=i}}();var a,l=[],u=!1,d=-1;function p(){u&&a&&(u=!1,a.length?l=a.concat(l):d=-1,l.length&&b())}function b(){if(!u){var e=s(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 m(e,t){this.fun=e,this.array=t}function f(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];l.push(new m(e,t)),1!==l.length||u||s(b)},m.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=f,o.addListener=f,o.once=f,o.off=f,o.removeListener=f,o.removeAllListeners=f,o.emit=f,o.prependListener=f,o.prependOnceListener=f,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"c",(function(){return i})),n.d(t,"b",(function(){return s}));const r=window.CustomEvent||null,o=(e,t)=>{let{bubbles:n=!1,cancelable:o=!1,element:c,detail:i={}}=t;if(!r)return;c||(c=document.body);const s=new r(e,{bubbles:n,cancelable:o,detail:i});c.dispatchEvent(s)};let c;const i=()=>{c&&clearTimeout(c),c=setTimeout(()=>{o("wc_fragment_refresh",{bubbles:!0,cancelable:!0})},50)},s=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("function"!=typeof jQuery)return()=>{};const c=()=>{o(t,{bubbles:n,cancelable:r})};return jQuery(document).on(e,c),()=>jQuery(document).off(e,c)}},,,function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));const r=e=>e.reduce((e,t)=>{let[n,r]=t;return e[n]=r,e},{})},function(e,t,n){"use strict";var r=n(10),o=n.n(r),c=n(0);n(101);const i=e=>{if(!e)return;const t=e.getBoundingClientRect().bottom;t>=0&&t<=window.innerHeight||e.scrollIntoView()};t.a=e=>t=>{const n=Object(c.useRef)(null);return Object(c.createElement)(c.Fragment,null,Object(c.createElement)("div",{className:"with-scroll-to-top__scroll-point",ref:n,"aria-hidden":!0}),Object(c.createElement)(e,o()({},t,{scrollToTop:e=>{null!==n.current&&((e,t)=>{const{focusableSelector:n}=t||{};window&&Number.isFinite(window.innerHeight)&&(n?((e,t)=>{var n;const r=(null===(n=e.parentElement)||void 0===n?void 0:n.querySelectorAll(t))||[];if(r.length){const e=r[0];i(e),null==e||e.focus()}else i(e)})(e,n):i(e))})(n.current,e)}})))}},,,function(e,t){},,,,,,,,,,,,,function(e,t,n){"use strict";n.d(t,"b",(function(){return f})),n.d(t,"a",(function(){return g}));var r=n(0),o=(n(8),n(9)),c=n(38),i=n(18),s=n(10),a=n.n(s),l=n(4),u=n.n(l),d=n(116);n(74);const p=e=>{let{status:t="default"}=e;switch(t){case"error":return"woocommerce-error";case"success":return"woocommerce-message";case"info":case"warning":return"woocommerce-info"}return""};var b=e=>{let{className:t,notices:n,removeNotice:o}=e;const c=n.filter(e=>"snackbar"!==e.type);if(!c.length)return null;const i=u()(t,"wc-block-components-notices");return Object(r.createElement)("div",{className:i},c.map(e=>Object(r.createElement)(d.a,a()({key:"store-notice-"+e.id},e,{className:u()("wc-block-components-notices__notice",p(e)),onRemove:()=>{e.isDismissible&&o(e.id)}}),e.content)))};const m=Object(r.createContext)({notices:[],createNotice:(e,t,n)=>{},removeNotice:(e,t)=>{},setIsSuppressed:e=>{},context:"wc/core"}),f=()=>Object(r.useContext)(m),g=e=>{let{children:t,className:n="",createNoticeContainer:s=!0,context:a="wc/core"}=e;const{createNotice:l,removeNotice:u}=Object(o.useDispatch)("core/notices"),[d,p]=Object(r.useState)(!1),{dispatchStoreEvent:f}=Object(c.a)(),{isEditor:g}=Object(i.a)(),h=Object(r.useCallback)((function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};l(e,t,{...n,context:n.context||a}),f("store-notice-create",{status:e,content:t,options:n})}),[l,f,a]),E=Object(r.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a;u(e,t)}),[u,a]),{notices:O}=Object(o.useSelect)(e=>({notices:e("core/notices").getNotices(a)}),[a]),w={notices:O,createNotice:h,removeNotice:E,context:a,setIsSuppressed:p},j=d?null:Object(r.createElement)(b,{className:n,notices:w.notices,removeNotice:w.removeNotice,isEditor:g});return Object(r.createElement)(m.Provider,{value:w},s&&j,t)}},,,function(e,t,n){"use strict";var r=n(0),o=n(24);const c=Object(r.createElement)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(r.createElement)(o.Path,{d:"M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"}));t.a=c},,,,,,,,function(e,t,n){"use strict";var r=n(0);t.a=function(e){let{srcElement:t,size:n=24,...o}=e;return Object(r.isValidElement)(t)?Object(r.cloneElement)(t,{width:n,height:n,...o}):null}},,,function(e,t){},,function(e,t,n){"use strict";var r=n(0),o=(n(8),n(4)),c=n.n(o),i=n(21),s=n(12);n(115),t.a=Object(s.withInstanceId)(e=>{let{className:t,instanceId:n,label:o,onChange:s,options:a,screenReaderLabel:l,readOnly:u,value:d}=e;const p="wc-block-components-sort-select__select-"+n;return Object(r.createElement)("div",{className:c()("wc-block-sort-select","wc-block-components-sort-select",t)},Object(r.createElement)(i.a,{label:o,screenReaderLabel:l,wrapperElement:"label",wrapperProps:{className:"wc-block-sort-select__label wc-block-components-sort-select__label",htmlFor:p}}),Object(r.createElement)("select",{id:p,className:"wc-block-sort-select__select wc-block-components-sort-select__select",onChange:s,readOnly:u,value:d},a.map(e=>Object(r.createElement)("option",{key:e.key,value:e.key},e.label))))})},,,,,,function(e,t,n){"use strict";n.d(t,"b",(function(){return i})),n.d(t,"c",(function(){return s})),n.d(t,"a",(function(){return a}));var r=n(2),o=n(50),c=n(34);const i=e=>{let{country:t="",state:n="",city:r="",postcode:o=""}=e;return{country:t.trim(),state:n.trim(),city:r.trim(),postcode:o?o.replace(" ","").toUpperCase():""}},s=e=>{let{email:t=""}=e;return Object(c.isEmail)(t)?t.trim():""},a=e=>{const t=Object.keys(r.defaultAddressFields),n=Object(o.a)(t,{},e.country),c=Object.assign({},e);return n.forEach(t=>{let{key:n="",hidden:r=!1}=t;r&&((e,t)=>e in t)(n,e)&&(c[n]="")}),c}},function(e,t){e.exports=window.wc.wcBlocksSharedHocs},,,function(e,t){e.exports=window.wp.wordcount},function(e,t){e.exports=window.wp.autop},function(e,t){},function(e,t,n){"use strict";var r=n(0),o=n(5),c=n(4),i=n.n(c),s=n(1),a=n(23),l=n(90),u=n(56);function d(e){switch(e){case"success":case"warning":case"info":return"polite";case"error":default:return"assertive"}}t.a=function({className:e,status:t="info",children:n,spokenMessage:c=n,onRemove:p=o.noop,isDismissible:b=!0,actions:m=[],politeness:f=d(t),__unstableHTML:g,onDismiss:h=o.noop}){!function(e,t){const n="string"==typeof e?e:Object(r.renderToString)(e);Object(r.useEffect)(()=>{n&&Object(a.speak)(n,t)},[n,t])}(c,f);const E=i()(e,"components-notice","is-"+t,{"is-dismissible":b});return g&&(n=Object(r.createElement)(r.RawHTML,null,n)),Object(r.createElement)("div",{className:E},Object(r.createElement)("div",{className:"components-notice__content"},n,Object(r.createElement)("div",{className:"components-notice__actions"},m.map(({className:e,label:t,isPrimary:n,variant:o,noDefaultClasses:c=!1,onClick:s,url:a},l)=>{let d=o;return"primary"===o||c||(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:s,className:i()("components-notice__action",e)},t)}))),b&&Object(r.createElement)(u.a,{className:"components-notice__dismiss",icon:l.a,label:Object(s.__)("Dismiss this notice"),onClick:e=>{var t;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),h(),p()},showTooltip:!1}))}},,,,,,,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(14),o=n(0),c=n(65);n.p=c.k,Object(r.registerBlockComponent)({blockName:"woocommerce/product-price",component:Object(o.lazy)(()=>Promise.all([n.e(1),n.e(11)]).then(n.bind(null,364)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-image",component:Object(o.lazy)(()=>n.e(10).then(n.bind(null,397)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-title",component:Object(o.lazy)(()=>n.e(18).then(n.bind(null,398)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-rating",component:Object(o.lazy)(()=>n.e(12).then(n.bind(null,365)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-button",component:Object(o.lazy)(()=>n.e(8).then(n.bind(null,366)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-summary",component:Object(o.lazy)(()=>n.e(16).then(n.bind(null,367)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-sale-badge",component:Object(o.lazy)(()=>n.e(13).then(n.bind(null,288)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-sku",component:Object(o.lazy)(()=>n.e(14).then(n.bind(null,368)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-category-list",component:Object(o.lazy)(()=>n.e(9).then(n.bind(null,369)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-tag-list",component:Object(o.lazy)(()=>n.e(17).then(n.bind(null,370)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-stock-indicator",component:Object(o.lazy)(()=>n.e(15).then(n.bind(null,371)))}),Object(r.registerBlockComponent)({blockName:"woocommerce/product-add-to-cart",component:Object(o.lazy)(()=>Promise.all([n.e(0),n.e(49),n.e(7)]).then(n.bind(null,384)))});const i=e=>Object(r.getRegisteredBlockComponents)(e)},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t){e.exports=window.wp.blockEditor},function(e,t){e.exports=window.wp.blocks},,,,,,,,,,,,function(e,t,n){e.exports=n(200)},function(e,t){},function(e,t){},function(e,t){},,,,,,,,,,,,,,,,,,,,,,function(e,t,n){"use strict";n.r(t);var r=n(0),o=n(87),c=n(53),i=n(3),s=(n(8),n(1)),a=n(5),l=n(4),u=n.n(l),d=n(21);n(178);const p=e=>{let{currentPage:t,displayFirstAndLastPages:n,displayNextAndPreviousArrows:o,pagesToDisplay:c,onPageChange:i,totalPages:a}=e,{minIndex:l,maxIndex:p}=((e,t,n)=>{if(n<=2)return{minIndex:null,maxIndex:null};const r=e-1,o=Math.max(Math.floor(t-r/2),2),c=Math.min(Math.ceil(t+(r-(t-o))),n-1);return{minIndex:Math.max(Math.floor(t-(r-(c-t))),2),maxIndex:c}})(c,t,a);const b=n&&Boolean(1!==l),m=n&&Boolean(p!==a),f=n&&Boolean(l>3),g=n&&Boolean(p<a-2);b&&3===l&&(l-=1),m&&p===a-2&&(p+=1);const h=[];if(l&&p)for(let e=l;e<=p;e++)h.push(e);return Object(r.createElement)("div",{className:"wc-block-pagination wc-block-components-pagination"},Object(r.createElement)(d.a,{screenReaderLabel:Object(s.__)("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:()=>i(t-1),title:Object(s.__)("Previous page","woo-gutenberg-products-block"),disabled:t<=1},Object(r.createElement)(d.a,{label:"←",screenReaderLabel:Object(s.__)("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:()=>i(1),disabled:1===t},Object(r.createElement)(d.a,{label:1,screenReaderLabel:Object(s.sprintf)(
|
4 |
/* translators: %d is the page number (1, 2, 3...). */
|
5 |
Object(s.__)("Page %d","woo-gutenberg-products-block"),1)})),f&&Object(r.createElement)("span",{className:"wc-block-pagination-ellipsis wc-block-components-pagination__ellipsis","aria-hidden":"true"},Object(s.__)("…","woo-gutenberg-products-block")),h.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?null:()=>i(e),disabled:t===e},Object(r.createElement)(d.a,{label:e,screenReaderLabel:Object(s.sprintf)(
|
6 |
/* translators: %d is the page number (1, 2, 3...). */
|
build/all-products.asset.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php return array('dependencies' => array('lodash', 'react', 'wc-blocks-data-store', 'wc-blocks-registry', 'wc-blocks-shared-context', 'wc-blocks-shared-hocs', 'wc-price-format', 'wc-settings', 'wp-a11y', 'wp-api-fetch', 'wp-autop', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-deprecated', 'wp-dom', 'wp-element', 'wp-escape-html', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-polyfill', 'wp-primitives', 'wp-url', 'wp-warning', 'wp-wordcount'), 'version' => '
|
1 |
+
<?php return array('dependencies' => array('lodash', 'react', 'wc-blocks-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' => 'ed1e2f826ee5e12308a6847c617fa53b');
|
build/all-products.js
CHANGED
@@ -1,34 +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 o,a,s=t[0],l=t[1],i=t[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(r.groupBy)(e,"parent"),o=Object(r.keyBy)(t,"id"),n=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e.parent)return e.name?[e.name]:[];const t=n(o[e.parent]);return[...t,e.name]},a=e=>e.map(e=>{const t=c[e.id];return delete c[e.id],{...e,breadcrumbs:n(o[e.parent]),children:t&&t.length?a(t):[]}}),s=a(c[0]||[]);return delete c[0],Object(r.forEach)(c,e=>{s.push(...a(e||[]))}),s},l=(e,t,c)=>{if(!t)return c?s(e):e;const o=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),r=e.map(e=>!!o.test(e.name)&&e).filter(Boolean);return c?s(r,e):r},i=(e,t)=>{if(!t)return e;const c=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"ig");return e.split(c).map((e,c)=>0===c?e:Object(o.createElement)(o.Fragment,{key:c},Object(o.createElement)("strong",null,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){e.exports=window.wp.primitives},,,,,,,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 h})),c.d(t,"i",(function(){return j})),c.d(t,"b",(function(){return E}));var o,r=c(2);const n=Object(r.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),a=n.pluginUrl+"images/",s=n.pluginUrl+"build/",l=n.buildPhase,i=null===(o=r.STORE_PAGES.shop)||void 0===o?void 0:o.permalink,u=r.STORE_PAGES.checkout.id,d=r.STORE_PAGES.checkout.permalink,b=r.STORE_PAGES.privacy.permalink,p=(r.STORE_PAGES.privacy.title,r.STORE_PAGES.terms.permalink),m=(r.STORE_PAGES.terms.title,r.STORE_PAGES.cart.id),g=r.STORE_PAGES.cart.permalink,O=(r.STORE_PAGES.myaccount.permalink?r.STORE_PAGES.myaccount.permalink:Object(r.getSetting)("wpLoginUrl","/wp-login.php"),Object(r.getSetting)("shippingCountries",{})),h=Object(r.getSetting)("allowedCountries",{}),j=Object(r.getSetting)("shippingStates",{}),E=Object(r.getSetting)("allowedStates",{})},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 h}));var o=c(15),r=c(11),n=c.n(r),a=c(6),s=c(2),l=c(25);const i=e=>{let{selected:t=[],search:c="",queryArgs:r={}}=e;const s=(e=>{let{selected:t=[],search:c="",queryArgs:r={}}=e;const n=l.o.productCount>100,a={per_page:n?100:0,catalog_visibility:"any",search:c,orderby:"title",order:"asc"},s=[Object(o.addQueryArgs)("/wc/store/products",{...a,...r})];return n&&t.length&&s.push(Object(o.addQueryArgs)("/wc/store/products",{catalog_visibility:"any",include:t,per_page:0})),s})({selected:t,search:c,queryArgs:r});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/products/"+e}),d=()=>n()({path:"wc/store/products/attributes"}),b=e=>n()({path:`wc/store/products/attributes/${e}/terms`}),p=e=>{let{selected:t=[],search:c}=e;const r=(e=>{let{selected:t=[],search:c}=e;const r=Object(s.getSetting)("limitTags",!1),n=[Object(o.addQueryArgs)("wc/store/products/tags",{per_page:r?100:0,orderby:r?"count":"name",order:r?"desc":"asc",search:c})];return r&&t.length&&n.push(Object(o.addQueryArgs)("wc/store/products/tags",{include:t})),n})({selected:t,search:c});return Promise.all(r.map(e=>n()({path:e}))).then(e=>Object(a.uniqBy)(Object(a.flatten)(e),"id"))},m=e=>n()({path:Object(o.addQueryArgs)("wc/store/products/categories",{per_page:0,...e})}),g=e=>n()({path:"wc/store/products/categories/"+e}),O=e=>n()({path:Object(o.addQueryArgs)("wc/store/products",{per_page:0,type:"variation",parent:e})}),h=(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";c.d(t,"a",(function(){return r})),c.d(t,"b",(function(){return n}));var o=c(1);const r=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"}},n=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?void 0:e.message)||Object(o.__)("Something went wrong. Please contact us to get assistance.","woo-gutenberg-products-block")}},function(e,t){e.exports=window.wc.wcBlocksSharedContext},function(e,t,c){"use strict";var o=c(0),r=c(4),n=c.n(r);t.a=e=>{let t,{label:c,screenReaderLabel:r,wrapperElement:a,wrapperProps:s={}}=e;const l=null!=c,i=null!=r;return!l&&i?(t=a||"span",s={...s,className:n()(s.className,"screen-reader-text")},Object(o.createElement)(t,s,r)):(t=a||o.Fragment,l&&i&&c!==r?Object(o.createElement)(t,s,Object(o.createElement)("span",{"aria-hidden":"true"},c),Object(o.createElement)("span",{className:"screen-reader-text"},r)):Object(o.createElement)(t,s,c))}},function(e,t){e.exports=window.wp.escapeHtml},function(e,t,c){"use strict";var o=c(0),r=c(1),n=c(31);t.a=e=>{let{error:t}=e;return Object(o.createElement)("div",{className:"wc-block-error-message"},(e=>{let{message:t,type:c}=e;return t?"general"===c?Object(o.createElement)("span",null,Object(r.__)("The following error was returned","woo-gutenberg-products-block"),Object(o.createElement)("br",null),Object(o.createElement)("code",null,Object(n.escapeHTML)(t))):"api"===c?Object(o.createElement)("span",null,Object(r.__)("The following error was returned from the API","woo-gutenberg-products-block"),Object(o.createElement)("br",null),Object(o.createElement)("code",null,Object(n.escapeHTML)(t))):t:Object(r.__)("An unknown error occurred which prevented the block from being updated.","woo-gutenberg-products-block")})(t))}},,function(e,t,c){"use strict";c.d(t,"a",(function(){return s}));var o=c(5),r=c.n(o),n=c(0),a=c(17);const s=e=>{let{countLabel:t,className:c,depth:o=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-"+o),u&&g.push("is-radio-button"),m&&g.push("has-count");const O=l.breadcrumbs&&l.breadcrumbs.length,h=p.name||"search-list-item-"+s,j=`${h}-${l.id}`;return Object(n.createElement)("label",{htmlFor:j,className:g.join(" ")},u?Object(n.createElement)("input",r()({type:"radio",id:j,name:h,value:l.value,onChange:d(l),checked:i,className:"woocommerce-search-list__item-input"},p)):Object(n.createElement)("input",r()({type:"checkbox",id:j,name:h,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){e.exports=window.wc.priceFormat},function(e,t,c){"use strict";c.d(t,"a",(function(){return w}));var o=c(6),r=c(0),n=c(16),a=c(13),s=c(14),l=c(149),i=c(248),u=c(49),d=c(247);const b=e=>{const t=e.detail;t&&t.preserveCartData||Object(a.dispatch)(n.CART_STORE_KEY).invalidateResolutionForStore()},p=()=>{1===window.wcBlocksStoreCartListeners.count&&window.wcBlocksStoreCartListeners.remove(),window.wcBlocksStoreCartListeners.count--},m=()=>{Object(r.useEffect)(()=>((()=>{if(window.wcBlocksStoreCartListeners||(window.wcBlocksStoreCartListeners={count:0,remove:()=>{}}),0===window.wcBlocksStoreCartListeners.count){const e=Object(d.a)("added_to_cart","wc-blocks_added_to_cart"),t=Object(d.a)("removed_from_cart","wc-blocks_removed_from_cart");document.body.addEventListener("wc-blocks_added_to_cart",b),document.body.addEventListener("wc-blocks_removed_from_cart",b),window.wcBlocksStoreCartListeners.count=0,window.wcBlocksStoreCartListeners.remove=()=>{e(),t(),document.body.removeEventListener("wc-blocks_added_to_cart",b),document.body.removeEventListener("wc-blocks_removed_from_cart",b)}}window.wcBlocksStoreCartListeners.count++})(),p),[])},g={first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:""},O={...g,email:""},h={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(l.a)(Object.entries(e).map(e=>{let[t,c]=e;return[t,Object(s.decodeEntities)(c)]})),E={cartCoupons:n.EMPTY_CART_COUPONS,cartItems:n.EMPTY_CART_ITEMS,cartFees:n.EMPTY_CART_FEES,cartItemsCount:0,cartItemsWeight:0,cartNeedsPayment:!0,cartNeedsShipping:!0,cartItemErrors:n.EMPTY_CART_ITEM_ERRORS,cartTotals:h,cartIsLoading:!0,cartErrors:n.EMPTY_CART_ERRORS,billingAddress:O,shippingAddress:g,shippingRates:n.EMPTY_SHIPPING_RATES,shippingRatesLoading:!1,cartHasCalculatedShipping:!1,paymentRequirements:n.EMPTY_PAYMENT_REQUIREMENTS,receiveCart:()=>{},extensions:n.EMPTY_EXTENSIONS},w=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{shouldSelect:!0};const{isEditor:t,previewData:c}=Object(u.b)(),s=null==c?void 0:c.previewCart,{shouldSelect:l}=e,d=Object(r.useRef)();m();const b=Object(a.useSelect)((e,c)=>{let{dispatch:o}=c;if(!l)return E;if(t)return{cartCoupons:s.coupons,cartItems:s.items,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,billingAddress:O,shippingAddress:g,extensions:n.EMPTY_EXTENSIONS,shippingRates:s.shipping_rates,shippingRatesLoading:!1,cartHasCalculatedShipping:s.has_calculated_shipping,paymentRequirements:s.paymentRequirements,receiveCart:"function"==typeof(null==s?void 0:s.receiveCart)?s.receiveCart:()=>{}};const r=e(n.CART_STORE_KEY),a=r.getCartData(),u=r.getCartErrors(),d=r.getCartTotals(),b=!r.hasFinishedResolution("getCartData"),p=r.isCustomerDataUpdating(),{receiveCart:m}=o(n.CART_STORE_KEY),h=j(a.billingAddress),w=a.needsShipping?j(a.shippingAddress):h,_=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,cartFees:_,cartItemsCount:a.itemsCount,cartItemsWeight:a.itemsWeight,cartNeedsPayment:a.needsPayment,cartNeedsShipping:a.needsShipping,cartItemErrors:a.errors,cartTotals:d,cartIsLoading:b,cartErrors:u,billingAddress:Object(i.a)(h),shippingAddress:Object(i.a)(w),extensions:a.extensions,shippingRates:a.shippingRates,shippingRatesLoading:p,cartHasCalculatedShipping:a.hasCalculatedShipping,paymentRequirements:a.paymentRequirements,receiveCart:m}},[l]);return d.current&&Object(o.isEqual)(d.current,b)||(d.current=b),d.current}},,,function(e,t){e.exports=window.wc.wcBlocksRegistry},function(e,t,c){"use strict";c.d(t,"a",(function(){return a}));var o=c(0),r=c(26),n=c.n(r);function a(e){const t=Object(o.useRef)(e);return n()(e,t.current)||(t.current=e),t.current}},function(e,t,c){"use strict";var o=c(5),r=c.n(o),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:o,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**o.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(o),value:void 0,currency:void 0,onValueChange:void 0},O=s?e=>{const t=+e.value*10**o.minorUnit;s(t)}:()=>{};return Object(n.createElement)(a.a,r()({className:m,displayType:u},g,{value:p,onValueChange:O}))}},,function(e,t,c){"use strict";var o=c(0);t.a=function(e){let{srcElement:t,size:c=24,...r}=e;return Object(o.isValidElement)(t)?Object(o.cloneElement)(t,{width:c,height:c,...r}):null}},function(e,t,c){"use strict";c.d(t,"a",(function(){return l})),c.d(t,"b",(function(){return i})),c.d(t,"c",(function(){return d}));var o=c(85);let r,n;!function(e){e.SUCCESS="success",e.FAIL="failure",e.ERROR="error"}(r||(r={})),function(e){e.PAYMENTS="wc/payment-area",e.EXPRESS_PAYMENTS="wc/express-payment-area"}(n||(n={}));const a=(e,t)=>Object(o.b)(e)&&"type"in e&&e.type===t,s=e=>a(e,r.SUCCESS),l=e=>a(e,r.ERROR),i=e=>a(e,r.FAIL),u=e=>!Object(o.b)(e)||void 0===e.retry||!0===e.retry,d=()=>({responseTypes:r,noticeContexts:n,shouldRetry:u,isSuccessResponse:s,isErrorResponse:l,isFailResponse:i})},,function(e,t){e.exports=window.wp.a11y},function(e,t,c){"use strict";c.d(t,"a",(function(){return n}));var o=c(0),r=c(128);const n=()=>{const{notices:e,createNotice:t,removeNotice:c,setIsSuppressed:n}=Object(r.b)(),a=Object(o.useRef)(e);Object(o.useEffect)(()=>{a.current=e},[e]);const s=Object(o.useMemo)(()=>({hasNoticesOfType:e=>a.current.some(t=>t.type===e),removeNotices:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;a.current.forEach(t=>{null!==e&&t.status!==e||c(t.id)})},removeNotice:c}),[c]),l=Object(o.useMemo)(()=>({addDefaultNotice:function(e){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("default",e,{...c})},addErrorNotice:function(e){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("error",e,{...c})},addWarningNotice:function(e){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("warning",e,{...c})},addInfoNotice:function(e){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("info",e,{...c})},addSuccessNotice:function(e){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("success",e,{...c})}}),[t]);return{notices:e,...s,...l,setIsSuppressed:n}}},function(e,t,c){"use strict";c.d(t,"a",(function(){return n}));var o=c(0);const r=Object(o.createContext)("page"),n=()=>Object(o.useContext)(r);r.Provider},function(e,t,c){"use strict";c.d(t,"b",(function(){return a})),c.d(t,"a",(function(){return s}));var o=c(0),r=c(13);const n=Object(o.createContext)({isEditor:!1,currentPostId:0,currentView:"",previewData:{},getPreviewData:()=>{}}),a=()=>Object(o.useContext)(n),s=e=>{let{children:t,currentPostId:c=0,currentView:a="",previewData:s={}}=e;const l=Object(r.useSelect)(e=>c||e("core/editor").getCurrentPostId(),[c]),i=Object(o.useCallback)(e=>e in s?s[e]:{},[s]),u={isEditor:!0,currentPostId:l,currentView:a,previewData:s,getPreviewData:i};return Object(o.createElement)(n.Provider,{value:u},t)}},,,,,function(e,t){e.exports=window.wc.wcBlocksSharedHocs},function(e,t,c){"use strict";var o=c(5),r=c.n(o),n=c(0),a=c(6),s=c(4),l=c.n(s),i=c(3),u=c(9);c(82);class d extends n.Component{constructor(){super(...arguments),this.onClick=this.onClick.bind(this)}onClick(e){this.props.onChange&&this.props.onChange(e.target.value)}render(){const{label:e,checked:t,instanceId:c,className:o,help:s,options:u,value:d}=this.props,b="inspector-toggle-button-control-"+c;let p;return s&&(p=Object(a.isFunction)(s)?s(t):s),Object(n.createElement)(i.BaseControl,{id:b,help:p,className:l()("components-toggle-button-control",o)},Object(n.createElement)("label",{id:b+"__label",htmlFor:b,className:"components-toggle-button-control__label"},e),Object(n.createElement)(i.ButtonGroup,{"aria-labelledby":b+"__label"},u.map((t,c)=>{const o={};return d===t.value?(o.isPrimary=!0,o["aria-pressed"]=!0):(o.isSecondary=!0,o["aria-pressed"]=!1),Object(n.createElement)(i.Button,r()({key:`${t.label}-${t.value}-${c}`,value:t.value,onClick:this.onClick,"aria-label":e+": "+t.label},o),t.label)})))}}t.a=Object(u.withInstanceId)(d)},,,,function(e,t,c){"use strict";var o=c(0),r=c(1),n=c(6),a=(c(10),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(o.createElement)(o.Fragment,null,Object(o.createElement)(a.RangeControl,{label:Object(r.__)("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(o.createElement)(a.RangeControl,{label:Object(r.__)("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(o.createElement)(a.ToggleControl,{label:Object(r.__)("Align Last Block","woo-gutenberg-products-block"),help:l?Object(r.__)("The last inner block will be aligned vertically.","woo-gutenberg-products-block"):Object(r.__)("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 o=c(61),r=c(0),n=c(36);const a=()=>{const e=Object(n.a)(),t=Object(r.useRef)(e);return Object(r.useEffect)(()=>{t.current=e},[e]),{dispatchStoreEvent:Object(r.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(o.doAction)("experimental__woocommerce_blocks-"+e,t)}catch(e){console.error(e)}}),[]),dispatchCheckoutEvent:Object(r.useCallback)((function(e){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(o.doAction)("experimental__woocommerce_blocks-checkout-"+e,{...c,storeCart:t.current})}catch(e){console.error(e)}}),[])}}},function(e,t){e.exports=window.wp.hooks},,,,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 o=c(16),r=c(13),n=c(0),a=c(26),s=c.n(a),l=c(40),i=c(108),u=c(48);const d=e=>{const t=Object(u.a)();e=e||t;const c=Object(r.useSelect)(t=>t(o.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0),[e]),{setValueForQueryContext:a}=Object(r.useDispatch)(o.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(r.useSelect)(r=>r(o.QUERY_STATE_STORE_KEY).getValueForQueryKey(c,e,t),[c,e]),{setQueryValue:l}=Object(r.useDispatch)(o.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[o,r]=d(t),a=Object(l.a)(o),b=Object(l.a)(e),p=Object(i.a)(b),m=Object(n.useRef)(!1);return Object(n.useEffect)(()=>{s()(p,b)||(r(Object.assign({},a,b)),m.current=!0)},[a,b,p,r]),m.current?[o,r]:[e,r]}},,function(e,t){e.exports=window.wp.autop},,,function(e,t,c){"use strict";var o=c(5),r=c.n(o),n=c(0),a=c(137),s=c(4),l=c.n(s),i=c(99);c(158),t.a=e=>{let{className:t,showSpinner:c=!1,children:o,...s}=e;const u=l()("wc-block-components-button",t,{"wc-block-components-button--loading":c});return Object(n.createElement)(a.a,r()({className:u},s),c&&Object(n.createElement)(i.a,null),Object(n.createElement)("span",{className:"wc-block-components-button__text"},o))}},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 o=c(12),r=c(25);const n=(e,t)=>{if(r.n>2)return Object(o.registerBlockType)(e,t)},a=(e,t)=>{if(r.n>1)return Object(o.registerBlockType)(e,t)},s=()=>r.n>2,l=()=>r.n>1},,,function(e,t){e.exports=window.wp.dom},,function(e,t){},,,function(e,t,c){"use strict";c.d(t,"a",(function(){return o})),c.d(t,"c",(function(){return r})),c.d(t,"b",(function(){return n})),c.d(t,"d",(function(){return a}));const o=e=>"number"==typeof e,r=e=>"string"==typeof e,n=e=>!(e=>null===e)(e)&&e instanceof Object&&e.constructor===Object;function a(e,t){return n(e)&&t in e}},function(e,t,c){"use strict";c.d(t,"a",(function(){return v}));var o=c(5),r=c.n(o),n=c(0),a=c(1),s=c(3),l=c(478),i=c(480),u=c(4),d=c.n(u),b=c(9),p=c(17),m=c(34),g=c(479),O=c(14);const h=e=>{let{id:t,label:c,popoverContents:o,remove:r,screenReaderLabel:i,className:u=""}=e;const[p,m]=Object(n.useState)(!1),j=Object(b.useInstanceId)(h);if(i=i||c,!c)return null;c=Object(O.decodeEntities)(c);const E=d()("woocommerce-tag",u,{"has-remove":!!r}),w="woocommerce-tag__label-"+j,_=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:E},o?Object(n.createElement)(s.Button,{className:"woocommerce-tag__text",id:w,onClick:()=>m(!0)},_):Object(n.createElement)("span",{className:"woocommerce-tag__text",id:w},_),o&&p&&Object(n.createElement)(s.Popover,{onClose:()=>m(!1)},o),r&&Object(n.createElement)(s.Button,{className:"woocommerce-tag__remove",onClick:r(t),label:Object(a.sprintf)(// Translators: %s label.
|
6 |
-
Object(a.__)("Remove %s","woo-gutenberg-products-block"),c),"aria-describedby":
|
7 |
/* translators: %s: heading level e.g: "2", "3", "4" */
|
8 |
-
Object(n.__)("Heading %d","woo-gutenberg-products-block"),e),isActive:r,onClick:()=>c(e)}}render(){const{isCollapsed:e=!0,minLevel:t,maxLevel:c,selectedLevel:n,onChange:l}=this.props;return Object(o.createElement)(a.ToolbarGroup,{isCollapsed:e,icon:Object(o.createElement)(s,{level:n}),controls:Object(r.range)(t,c).map(e=>this.createLevelControl(e,n,l))})}}t.a=l},,function(e,t){e.exports=window.wp.warning},function(e,t,c){"use strict";var o=c(0),r=c(1),n=c(43),a=c(
|
9 |
/* translators: %s Field label. */
|
10 |
-
Object(r.__)("%s (optional)","woo-gutenberg-products-block"),e.label)),e.priority&&(Object(n.a)(e.priority)&&(t.index=e.priority),Object(n.c)(e.priority)&&(t.index=parseInt(e.priority,10))),e.hidden&&(t.required=!1),t},l=Object.entries(a).map(e=>{let[t,c]=e;return[t,Object.entries(c).map(e=>{let[t,c]=e;return[t,s(c)]}).reduce((e,t)=>{let[c,o]=t;return e[c]=o,e},{})]}).reduce((e,t)=>{let[c,o]=t;return e[c]=o,e},{});t.a=function(e,t){let c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";const r=c&&void 0!==l[c]?l[c]:{};return e.map(e=>({key:e,...o.defaultAddressFields[e]||{},...r[e]||{},...t[e]||{}})).sort((e,t)=>e.index-t.index)}},function(e,t,c){"use strict";var o=c(0);c(
|
11 |
/* translators: %1$d is the number of variations of a product product. */
|
12 |
Object(a.__)("%1$d variations","woo-gutenberg-products-block"),t.variations.length):null,name:"products-"+o,"aria-label":Object(a.sprintf)(
|
13 |
/* translators: %1$s is the product name, %2$d is the number of variations of that product. */
|
14 |
-
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,r()({},g,{className:
|
15 |
/* translators: %1$s min price, %2$s max price */
|
16 |
-
Object(r.__)("Price between %1$s and %2$s","woo-gutenberg-products-block"),Object(l.formatPrice)(a),Object(l.formatPrice)(c))),Object(o.createElement)("span",{"aria-hidden":!0},Object(o.createElement)(n.a,{className:s()("wc-block-components-product-price__value",i),currency:t,value:a,style:u})," — ",Object(o.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(o.createElement)(o.Fragment,null,Object(o.createElement)("span",{className:"screen-reader-text"},Object(r.__)("Previous price:","woo-gutenberg-products-block")),Object(o.createElement)(n.a,{currency:t,renderText:e=>Object(o.createElement)("del",{className:s()("wc-block-components-product-price__regular",c),style:a},e),value:l}),Object(o.createElement)("span",{className:"screen-reader-text"},Object(r.__)("Discounted price:","woo-gutenberg-products-block")),Object(o.createElement)(n.a,{currency:t,renderText:e=>Object(o.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:r,format:a="<price/>",maxPrice:l,minPrice:d,price:b,priceClassName:p,priceStyle:m,regularPrice:g,regularPriceClassName:O,regularPriceStyle:h}=e;const j=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 E=g&&b!==g;let w=Object(o.createElement)("span",{className:s()("wc-block-components-product-price__value",p)});return E?w=Object(o.createElement)(u,{currency:r,price:b,priceClassName:p,priceStyle:m,regularPrice:g,regularPriceClassName:O,regularPriceStyle:h}):void 0!==d&&void 0!==l?w=Object(o.createElement)(i,{currency:r,maxPrice:l,minPrice:d,priceClassName:p,priceStyle:m}):b&&(w=Object(o.createElement)(n.a,{className:s()("wc-block-components-product-price__value",p),currency:r,value:b,style:m})),Object(o.createElement)("span",{className:j},Object(o.createInterpolateElement)(a,{price:w}))}},,function(e,t,c){"use strict";c.d(t,"a",(function(){return n})),c.d(t,"b",(function(){return s}));var o=c(6);let r;!function(e){e.ADD_EVENT_CALLBACK="add_event_callback",e.REMOVE_EVENT_CALLBACK="remove_event_callback"}(r||(r={}));const n={addEventCallback:function(e,t){let c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10;return{id:Object(o.uniqueId)(),type:r.ADD_EVENT_CALLBACK,eventType:e,callback:t,priority:c}},removeEventCallback:(e,t)=>({id:t,type:r.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:o,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 r.ADD_EVENT_CALLBACK:return l.set(o,{priority:s,callback:n}),{...e,[c]:l};case r.REMOVE_EVENT_CALLBACK:return l.delete(o),{...e,[c]:l}}}},function(e,t,c){"use strict";c.d(t,"a",(function(){return r}));var o=c(8);function r(e,t){const c=Object(o.useRef)();return Object(o.useEffect)(()=>{c.current===e||t&&!t(e,c.current)||(c.current=e)},[e,t]),c.current}},,,,function(e,t,c){"use strict";c.d(t,"b",(function(){return l})),c.d(t,"a",(function(){return i}));var o=c(0),r=c(6),n=c(26),a=c.n(n);const s=Object(o.createContext)({getValidationError:()=>"",setValidationErrors:e=>{},clearValidationError:e=>{},clearAllValidationErrors:()=>{},hideValidationError:()=>{},showValidationError:()=>{},showAllValidationErrors:()=>{},hasValidationErrors:!1,getValidationErrorId:e=>e}),l=()=>Object(o.useContext)(s),i=e=>{let{children:t}=e;const[c,n]=Object(o.useState)({}),l=Object(o.useCallback)(e=>c[e],[c]),i=Object(o.useCallback)(e=>{const t=c[e];return!t||t.hidden?"":"validate-error-"+e},[c]),u=Object(o.useCallback)(e=>{n(t=>{if(!t[e])return t;const{[e]:c,...o}=t;return o})},[]),d=Object(o.useCallback)(()=>{n({})},[]),b=Object(o.useCallback)(e=>{e&&n(t=>(e=Object(r.pickBy)(e,(e,c)=>!("string"!=typeof e.message||t.hasOwnProperty(c)&&a()(t[c],e))),0===Object.values(e).length?t:{...t,...e}))},[]),p=Object(o.useCallback)((e,t)=>{n(c=>{if(!c.hasOwnProperty(e))return c;const o={...c[e],...t};return a()(c[e],o)?c:{...c,[e]:o}})},[]),m={getValidationError:l,setValidationErrors:b,clearValidationError:u,clearAllValidationErrors:d,hideValidationError:Object(o.useCallback)(e=>{p(e,{hidden:!0})},[p]),showValidationError:Object(o.useCallback)(e=>{p(e,{hidden:!1})},[p]),showAllValidationErrors:Object(o.useCallback)(()=>{n(e=>{const t={};return Object.keys(e).forEach(c=>{e[c].hidden&&(t[c]={...e[c],hidden:!1})}),0===Object.values(t).length?e:{...e,...t}})},[]),hasValidationErrors:Object.keys(c).length>0,getValidationErrorId:i};return Object(o.createElement)(s.Provider,{value:m},t)}},function(e,t,c){"use strict";c.d(t,"a",(function(){return l}));var o=c(16),r=c(13),n=c(0),a=c(40),s=c(93);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(r.useSelect)(e=>{if(!u)return null;const r=e(o.COLLECTIONS_STORE_KEY),n=[t,c,b,p],a=r.getCollectionError(...n);return a&&m(a),{results:r.getCollection(...n),isLoading:!r.hasFinishedResolution("getCollection",n)}},[t,c,p,b,u]);return null!==g&&(d.current=g),d.current}},,,,,,,function(e,t,c){"use strict";var o=c(0),r=c(18);const n=Object(o.createElement)(r.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(o.createElement)("mask",{id:"external-mask",width:"24",height:"24",x:"0",y:"0",maskUnits:"userSpaceOnUse"},Object(o.createElement)("path",{fill:"#fff",d:"M6.3431 6.3431v1.994l7.8984.0072-8.6055 8.6054 1.4142 1.4143 8.6055-8.6055.0071 7.8984h1.994V6.3431H6.3431z"})),Object(o.createElement)("g",{mask:"url(#external-mask)"},Object(o.createElement)("path",{d:"M0 0h24v24H0z"})));t.a=n},,,,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return r}));var o=c(0);const r=Object(o.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 230 250",style:{width:"100%"}},Object(o.createElement)("title",null,"Grid Block Preview"),Object(o.createElement)("rect",{width:"65.374",height:"65.374",x:".162",y:".779",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(o.createElement)("rect",{width:"62.8",height:"15",x:"1.565",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(o.createElement)("rect",{width:"65.374",height:"65.374",x:".162",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(o.createElement)("rect",{width:"62.8",height:"15",x:"1.565",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(o.createElement)("rect",{width:"65.374",height:"65.374",x:"82.478",y:".779",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(o.createElement)("rect",{width:"62.8",height:"15",x:"83.882",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(o.createElement)("rect",{width:"65.374",height:"65.374",x:"82.478",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(o.createElement)("rect",{width:"62.8",height:"15",x:"83.882",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(o.createElement)("rect",{width:"65.374",height:"65.374",x:"164.788",y:".779",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(o.createElement)("rect",{width:"62.8",height:"15",x:"166.192",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(o.createElement)("rect",{width:"65.374",height:"65.374",x:"164.788",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(o.createElement)("rect",{width:"62.8",height:"15",x:"166.192",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.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 o=c(5),r=c.n(o),n=c(0),a=c(14),s=c(4),l=c.n(s);c(155),t.a=e=>{let{className:t="",disabled:c=!1,name:o,permalink:s="",rel:i,style:u,onClick:d,...b}=e;const p=l()("wc-block-components-product-name",t);if(c){const e=b;return Object(n.createElement)("span",r()({className:p},e,{dangerouslySetInnerHTML:{__html:Object(a.decodeEntities)(o)}}))}return Object(n.createElement)("a",r()({className:p,href:s,rel:i},b,{dangerouslySetInnerHTML:{__html:Object(a.decodeEntities)(o)},style:u}))}},function(e,t,c){"use strict";c.d(t,"b",(function(){return g})),c.d(t,"a",(function(){return O}));var o=c(0),r=(c(10),c(13)),n=c(60),a=c(49),s=c(5),l=c.n(s),i=c(4),u=c.n(i),d=c(481);c(157);const b=e=>{let{status:t="default"}=e;switch(t){case"error":return"woocommerce-error";case"success":return"woocommerce-message";case"info":case"warning":return"woocommerce-info"}return""};var p=e=>{let{className:t,notices:c,removeNotice:r}=e;const n=c.filter(e=>"snackbar"!==e.type);if(!n.length)return null;const a=u()(t,"wc-block-components-notices");return Object(o.createElement)("div",{className:a},n.map(e=>Object(o.createElement)(d.a,l()({key:"store-notice-"+e.id},e,{className:u()("wc-block-components-notices__notice",b(e)),onRemove:()=>{e.isDismissible&&r(e.id)}}),e.content)))};const m=Object(o.createContext)({notices:[],createNotice:(e,t,c)=>{},removeNotice:(e,t)=>{},setIsSuppressed:e=>{},context:"wc/core"}),g=()=>Object(o.useContext)(m),O=e=>{let{children:t,className:c="",createNoticeContainer:s=!0,context:l="wc/core"}=e;const{createNotice:i,removeNotice:u}=Object(r.useDispatch)("core/notices"),[d,b]=Object(o.useState)(!1),{dispatchStoreEvent:g}=Object(n.a)(),{isEditor:O}=Object(a.b)(),h=Object(o.useCallback)((function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};i(e,t,{...c,context:c.context||l}),g("store-notice-create",{status:e,content:t,options:c})}),[i,g,l]),j=Object(o.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:l;u(e,t)}),[u,l]),{notices:E}=Object(r.useSelect)(e=>({notices:e("core/notices").getNotices(l)}),[l]),w={notices:E,createNotice:h,removeNotice:j,context:l,setIsSuppressed:b},_=d?null:Object(o.createElement)(p,{className:c,notices:w.notices,removeNotice:w.removeNotice,isEditor:O});return Object(o.createElement)(m.Provider,{value:w},s&&_,t)}},function(e,t,c){"use strict";var o=c(0),r=c(100),n=c(73);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 o=s(e),r=o.split(" ").splice(0,t).join(" ");return Object(n.autop)(l(r,c))},u=function(e,t){let c=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"…";const r=s(e),a=r.slice(0,t);if(c)return Object(n.autop)(l(a,o));const i=a.match(/([\s]+)/g),u=i?i.length:0,d=r.slice(0,t+u);return Object(n.autop)(l(d,o))};t.a=e=>{let{source:t,maxLength:c=15,countType:s="words",className:l=""}=e;const d=Object(o.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 o=Object(n.autop)(e),s=Object(r.count)(o,c);if(s<=t)return o;const l=a(o),d=Object(r.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(o.createElement)(o.RawHTML,{className:l},d)}},,,,,,,,,function(e,t){},,function(e,t){},,function(e,t){},,,,,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return o}));const o=e=>e.reduce((e,t)=>{let[c,o]=t;return e[c]=o,e},{})},,,,,,function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t,c){"use strict";var o=c(5),r=c.n(o),n=c(0),a=c(25),s=c(27),l=c(116),i=c(28);t.a=e=>t=>{let{selected:c,...o}=t;const[u,d]=Object(n.useState)(!0),[b,p]=Object(n.useState)(null),[m,g]=Object(n.useState)([]),O=a.o.productCount>100,h=async e=>{const t=await Object(i.a)(e);p(t),d(!1)},j=Object(n.useRef)(c);Object(n.useEffect)(()=>{Object(s.h)({selected:j.current}).then(e=>{g(e),d(!1)}).catch(h)},[j]);const E=Object(l.a)(e=>{Object(s.h)({selected:c,search:e}).then(e=>{g(e),d(!1)}).catch(h)},400),w=Object(n.useCallback)(e=>{d(!0),E(e)},[d,E]);return Object(n.createElement)(e,r()({},o,{selected:c,error:b,products:m,isLoading:u,onSearch:O?w:null}))}},function(e,t,c){"use strict";c.r(t);var o=c(0),r=(c(10),c(1)),n=c(4),a=c.n(n),s=c(30),l=c(29),i=c(54);c(298),t.default=Object(i.withProductDataContext)(e=>{let{className:t,align:c}=e;const{parentClassName:n}=Object(l.useInnerBlockLayoutContext)(),{product:i}=Object(l.useProductDataContext)();if(!i.id||!i.on_sale)return null;const u="string"==typeof c?"wc-block-components-product-sale-badge--align-"+c:"";return Object(o.createElement)("div",{className:a()("wc-block-components-product-sale-badge",t,u,{[n+"__product-onsale"]:n})},Object(o.createElement)(s.a,{label:Object(r.__)("Sale","woo-gutenberg-products-block"),screenReaderLabel:Object(r.__)("Product on sale","woo-gutenberg-products-block")}))})},function(e,t,c){"use strict";c.d(t,"a",(function(){return n}));var o=c(0),r=(c(10),c(112));c(160);const n=e=>{let{errorMessage:t="",propertyName:c="",elementId:n=""}=e;const{getValidationError:a,getValidationErrorId:s}=Object(r.b)();if(!t||"string"!=typeof t){const e=a(c)||{};if(!e.message||e.hidden)return null;t=e.message}return Object(o.createElement)("div",{className:"wc-block-components-validation-error",role:"alert"},Object(o.createElement)("p",{id:s(n)},t))}},,,,,,,,,,,,function(e,t,c){"use strict";var o=c(0),r=c(18);const n=Object(o.createElement)(r.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(o.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(o.createElement)("path",{d:"M11 17h2v-1h1c.55 0 1-.45 1-1v-3c0-.55-.45-1-1-1h-3v-1h4V8h-2V7h-2v1h-1c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h3v1H9v2h2v1zm9-13H4c-1.11 0-1.99.89-1.99 2L2 18c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V6c0-1.11-.89-2-2-2zm0 14H4V6h16v12z"}));t.a=n},function(e,t,c){"use strict";var o=c(0),r=c(18);const n=Object(o.createElement)(r.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(o.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(o.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){},function(e,t,c){"use strict";var o=c(77);let r={headingLevel:{type:"number",default:2},showProductLink:{type:"boolean",default:!0},productId:{type:"number",default:0}};Object(o.b)()&&(r={...r,align:{type:"string"},color:{type:"string"},customColor:{type:"string"},fontSize:{type:"string"},customFontSize:{type:"number"}}),t.a=r},function(e,t,c){"use strict";var o=c(0),r=c(4),n=c.n(r),a=c(29),s=c(7),l=c(77),i=c(54),u=c(127),d=c(60);c(297);const b=e=>{let{children:t,headingLevel:c,elementType:r="h"+c,...n}=e;return Object(o.createElement)(r,n,t)};t.a=Object(i.withProductDataContext)(e=>{var t,c,r,i;let{className:p,headingLevel:m=2,showProductLink:g=!0,align:O,textColor:h,fontSize:j,style:E}=e;const{parentClassName:w}=Object(a.useInnerBlockLayoutContext)(),{product:_}=Object(a.useProductDataContext)(),{dispatchStoreEvent:f}=Object(d.a)(),v=Object(s.getColorClassName)("color",h),k=Object(s.getFontSizeClass)(j),y=n()("wp-block-woocommerce-product-title",{"has-text-color":h||(null==E||null===(t=E.color)||void 0===t?void 0:t.text)||(null==E?void 0:E.color),"has-font-size":j||(null==E||null===(c=E.typography)||void 0===c?void 0:c.fontSize)||(null==E?void 0:E.fontSize),[v]:v,[k]:k}),C={fontSize:(null==E?void 0:E.fontSize)||(null==E||null===(r=E.typography)||void 0===r?void 0:r.fontSize),color:(null==E||null===(i=E.color)||void 0===i?void 0:i.text)||(null==E?void 0:E.color)};return _.id?Object(o.createElement)(b,{headingLevel:m,className:n()(p,"wc-block-components-product-title",{[w+"__product-title"]:w,["wc-block-components-product-title--align-"+O]:O&&Object(l.b)()})},Object(o.createElement)(u.a,{className:n()({[y]:Object(l.b)()}),disabled:!g,name:_.name,permalink:_.permalink,rel:g?"nofollow":"",onClick:()=>{f("product-view-link",{product:_})},style:Object(l.b)()?C:{}})):Object(o.createElement)(b,{headingLevel:m,className:n()(p,"wc-block-components-product-title",{[w+"__product-title"]:w,["wc-block-components-product-title--align-"+O]:O&&Object(l.b)(),[y]:Object(l.b)()})})})},function(e,t,c){"use strict";c.d(t,"b",(function(){return a})),c.d(t,"a",(function(){return s}));const o=window.CustomEvent||null,r=(e,t)=>{let{bubbles:c=!1,cancelable:r=!1,element:n,detail:a={}}=t;if(!o)return;n||(n=document.body);const s=new o(e,{bubbles:c,cancelable:r,detail:a});n.dispatchEvent(s)};let n;const a=()=>{n&&clearTimeout(n),n=setTimeout(()=>{r("wc_fragment_refresh",{bubbles:!0,cancelable:!0})},50)},s=function(e,t){let c=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("function"!=typeof jQuery)return()=>{};const n=()=>{r(t,{bubbles:c,cancelable:o})};return jQuery(document).on(e,n),()=>jQuery(document).off(e,n)}},function(e,t,c){"use strict";c.d(t,"b",(function(){return a})),c.d(t,"c",(function(){return s})),c.d(t,"a",(function(){return l}));var o=c(2),r=c(98),n=c(15);const a=e=>{let{country:t="",state:c="",city:o="",postcode:r=""}=e;return{country:t.trim(),state:c.trim(),city:o.trim(),postcode:r?r.replace(" ","").toUpperCase():""}},s=e=>{let{email:t=""}=e;return Object(n.isEmail)(t)?t.trim():""},l=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:o=!1}=t;o&&((e,t)=>e in t)(c,e)&&(n[c]="")}),n}},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}}},function(e,t,c){"use strict";var o=c(5),r=c.n(o),n=c(0),a=(c(10),c(1)),s=c(4),l=c.n(s),i=c(2),u=c(29),d=c(54),b=c(60),p=c(192);c(299);const m=()=>Object(n.createElement)("img",{src:i.PLACEHOLDER_IMG_SRC,alt:"",width:500,height:500}),g=e=>{let{image:t,onLoad:c,loaded:o,showFullSize:a,fallbackAlt:s}=e;const{thumbnail:l,src:i,srcset:u,sizes:d,alt:b}=t||{},p={alt:b||s,onLoad:c,hidden:!o,src:l,...a&&{src:i,srcSet:u,sizes:d}};return Object(n.createElement)(n.Fragment,null,p.src&&Object(n.createElement)("img",r()({"data-testid":"product-image"},p)),!o&&Object(n.createElement)(m,null))};t.a=Object(d.withProductDataContext)(e=>{let{className:t,imageSizing:c="full-size",showProductLink:o=!0,showSaleBadge:r,saleBadgeAlign:s="right"}=e;const{parentClassName:i}=Object(u.useInnerBlockLayoutContext)(),{product:d}=Object(u.useProductDataContext)(),[O,h]=Object(n.useState)(!1),{dispatchStoreEvent:j}=Object(b.a)();if(!d.id)return Object(n.createElement)("div",{className:l()(t,"wc-block-components-product-image","wc-block-components-product-image--placeholder",{[i+"__product-image"]:i})},Object(n.createElement)(m,null));const E=!!d.images.length,w=E?d.images[0]:null,_=o?"a":n.Fragment,f=Object(a.sprintf)(
|
17 |
/* translators: %s is referring to the product name */
|
18 |
-
Object(a.__)("Link to %s","woo-gutenberg-products-block"),
|
19 |
/* translators: %s number of products in cart. */
|
20 |
-
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(o.createElement)(ie.a,{srcElement:ue.a,alt:Object(a.__)("Done","woo-gutenberg-products-block")}))};var ge=()=>{const{showFormElements:e,productIsPurchasable:t,productHasOptions:c,product:r,productType:n,isDisabled:s,isProcessing:l,eventRegistration:i,hasError:u,dispatchActions:
|
21 |
/* translators: %f is referring to the average rating value */
|
22 |
-
Object(r.__)("Rated %f out of 5","woo-gutenberg-products-block"),l)
|
|
|
|
|
23 |
/* translators: %s number of products in cart. */
|
24 |
-
Object(l._n)("%d in cart","%d in cart",O,"woo-gutenberg-products-block"),O):Object(
|
25 |
/* translators: %d stock amount (number of items in stock for product) */
|
26 |
-
Object(r.__)("%d left in stock","woo-gutenberg-products-block"),e))(i):((e,t)=>t?Object(r.__)("Available on backorder","woo-gutenberg-products-block"):e?Object(r.__)("In Stock","woo-gutenberg-products-block"):Object(r.__)("Out of Stock","woo-gutenberg-products-block"))(l,u))})},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,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){},function(e,t){},function(e,t){},function(e,t,c){"use strict";var o=c(0),r=c(18);const n=Object(o.createElement)(r.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(o.createElement)("path",{fill:"none",d:"M0 0h24v24H0z"}),Object(o.createElement)("path",{d:"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"}));t.a=n},,,,,,,,,,,,,,,,function(e,t,c){"use strict";var o=c(0),r=c(18);const n=Object(o.createElement)(r.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(o.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(o.createElement)("path",{d:"M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z"}));t.a=n},,,,,,,function(e,t,c){"use strict";var o=c(0),r=c(18);const n=Object(o.createElement)(r.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(o.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(o.createElement)("path",{d:"M21.41 11.58l-9-9C12.05 2.22 11.55 2 11 2H4c-1.1 0-2 .9-2 2v7c0 .55.22 1.05.59 1.42l9 9c.36.36.86.58 1.41.58s1.05-.22 1.41-.59l7-7c.37-.36.59-.86.59-1.41s-.23-1.06-.59-1.42zM13 20.01L4 11V4h7v-.01l9 9-7 7.02z"}),Object(o.createElement)("circle",{cx:"6.5",cy:"6.5",r:"1.5"}),Object(o.createElement)("path",{d:"M8.9 12.55c0 .57.23 1.07.6 1.45l3.5 3.5 3.5-3.5c.37-.37.6-.89.6-1.45 0-1.13-.92-2.05-2.05-2.05-.57 0-1.08.23-1.45.6l-.6.6-.6-.59c-.37-.38-.89-.61-1.45-.61-1.13 0-2.05.92-2.05 2.05z"}));t.a=n},,,,,,,,function(e,t,c){"use strict";var o=c(0),r=c(18);const n=Object(o.createElement)(r.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(o.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(o.createElement)("path",{d:"M22 9.24l-7.19-.62L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.63-7.03L22 9.24zM12 15.4l-3.76 2.27 1-4.28-3.32-2.88 4.38-.38L12 6.1l1.71 4.04 4.38.38-3.32 2.88 1 4.28L12 15.4z"}));t.a=n},function(e,t,c){"use strict";c.d(t,"a",(function(){return n}));var o=c(1),r=c(25);const n=[{id:1,name:"WordPress Pennant",variation:"",permalink:"https://example.org",sku:"wp-pennant",short_description:Object(o.__)("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:r.m+"previews/pennant.jpg",thumbnail:r.m+"previews/pennant.jpg",name:"pennant-1.jpg",alt:"WordPress Pennant",srcset:"",sizes:""}],average_rating:5,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(o.__)("Add to cart","woo-gutenberg-products-block"),description:Object(o.__)("Add to cart","woo-gutenberg-products-block")},has_options:!1,is_purchasable:!0,is_in_stock:!0,on_sale:!0}]},,,,,function(e,t,c){"use strict";var o=c(0),r=c(18);const n=Object(o.createElement)(r.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(o.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(o.createElement)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"}));t.a=n},,,,,,,function(e,t,c){e.exports=c(434)},function(e,t){},function(e,t){},function(e,t,c){"use strict";c.d(t,"a",(function(){return u}));var o=c(0),r=c(13),n=c(16),a=c(14),s=c(36),l=c(47);const i=(e,t)=>{const c=e.find(e=>{let{id:c}=e;return c===t});return c?c.quantity:0},u=e=>{const{addItemToCart:t}=Object(r.useDispatch)(n.CART_STORE_KEY),{cartItems:c,cartIsLoading:u}=Object(s.a)(),{addErrorNotice:d,removeNotice:b}=Object(l.a)(),[p,m]=Object(o.useState)(!1),g=Object(o.useRef)(i(c,e));return Object(o.useEffect)(()=>{const t=i(c,e);t!==g.current&&(g.current=t)},[c,e]),{cartQuantity:Number.isFinite(g.current)?g.current:0,addingToCart:p,cartIsLoading:u,addToCart:function(){let c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return m(!0),t(e,c).then(()=>{b("add-to-cart")}).catch(e=>{d(Object(a.decodeEntities)(e.message),{context:"wc/all-products",id:"add-to-cart",isDismissible:!0})}).finally(()=>{m(!1)})}}}},function(e,t,c){"use strict";var o=c(0),r=c(18);const n=Object(o.createElement)(r.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16"},Object(o.createElement)("g",{fill:"none",fillRule:"evenodd"},Object(o.createElement)("path",{stroke:"currentColor",strokeWidth:"1.5",d:"M2 .75h12c.69 0 1.25.56 1.25 1.25v12c0 .69-.56 1.25-1.25 1.25H2c-.69 0-1.25-.56-1.25-1.25V2C.75 1.31 1.31.75 2 .75z"}),Object(o.createElement)("path",{fill:"currentColor",d:"M12 6H4V4.75h8zM12 9H4V7.75h8zM10 12H4v-1.25h6z"})));t.a=n},,,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,"blockSettings",(function(){return It}));var o=c(5),r=c.n(o),n=c(0),a=c(1),s=c(7),l=c(12),i=c(43),u=c(18),d=Object(n.createElement)(u.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(n.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(n.createElement)("path",{d:"M4 8h4V4H4v4zm6 12h4v-4h-4v4zm-6 0h4v-4H4v4zm0-6h4v-4H4v4zm6 0h4v-4h-4v4zm6-10v4h4V4h-4zm-6 4h4V4h-4v4zm6 6h4v-4h-4v4zm0 6h4v-4h-4v4z"})),b=c(77),p=c(4),m=c.n(p),g={category:"woocommerce-product-elements",keywords:[Object(a.__)("WooCommerce","woo-gutenberg-products-block")],icon:{src:Object(n.createElement)(i.a,{srcElement:d,className:"wc-block-editor-components-block-icon"})},supports:{html:!1},parent:Object(b.a)()?void 0:["@woocommerce/all-products","@woocommerce/single-product"],save:e=>{let{attributes:t}=e;return Object(n.createElement)("div",{className:m()("is-loading",t.className)})},deprecated:[{attributes:{},save:()=>null}]},O=c(245),h=c(3),j=c(9),E=c(89),w=c(246),_=c(101);c(354);var f=function(e){let{className:t="",...c}=e;const o=m()("wc-block-text-toolbar-button",t);return Object(n.createElement)(h.Button,r()({className:o},c))},v=c(29);c(353);var k=e=>t=>c=>{const o=Object(v.useProductDataContext)(),{attributes:r,setAttributes:l}=c,{productId:i}=r,[u,d]=Object(n.useState)(!i);return o.hasContext?Object(n.createElement)(t,c):Object(n.createElement)(n.Fragment,null,u?Object(n.createElement)(h.Placeholder,{icon:e.icon||"",label:e.label||"",className:"wc-atomic-blocks-product"},!!e.description&&Object(n.createElement)("div",null,e.description),Object(n.createElement)("div",{className:"wc-atomic-blocks-product__selection"},Object(n.createElement)(_.a,{selected:i||0,showVariations:!0,onChange:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];l({productId:e[0]?e[0].id:0})}}),Object(n.createElement)(h.Button,{isSecondary:!0,disabled:!i,onClick:()=>{d(!1)}},Object(a.__)("Done","woo-gutenberg-products-block")))):Object(n.createElement)(n.Fragment,null,Object(n.createElement)(s.BlockControls,null,Object(n.createElement)(h.ToolbarGroup,null,Object(n.createElement)(f,{onClick:()=>d(!0)},Object(a.__)("Switch product…","woo-gutenberg-products-block")))),Object(n.createElement)(t,c)))},y=Object(n.createElement)(u.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 3H7a2 2 0 00-2 2v16l7-3 7 3V5a2 2 0 00-2-2z"}));const C=Object(a.__)("Product Title","woo-gutenberg-products-block"),S=Object(n.createElement)(i.a,{srcElement:y,className:"wc-block-editor-components-block-icon"}),x=Object(a.__)("Display the title of a product.","woo-gutenberg-products-block"),N=e=>{let{attributes:t,setAttributes:c}=e;const o=Object(s.useBlockProps)(),{headingLevel:r,showProductLink:l,align:i}=t;return Object(n.createElement)("div",o,Object(n.createElement)(s.BlockControls,null,Object(n.createElement)(E.a,{isCollapsed:!0,minLevel:1,maxLevel:7,selectedLevel:r,onChange:e=>c({headingLevel:e})}),Object(b.b)()&&Object(n.createElement)(s.AlignmentToolbar,{value:i,onChange:e=>{c({align:e})}})),Object(n.createElement)(s.InspectorControls,null,Object(n.createElement)(h.PanelBody,{title:Object(a.__)("Content","woo-gutenberg-products-block")},Object(n.createElement)(h.ToggleControl,{label:Object(a.__)("Link to Product Page","woo-gutenberg-products-block"),help:Object(a.__)("Links the image to the single product listing.","woo-gutenberg-products-block"),checked:l,onChange:()=>c({showProductLink:!l})}))),Object(n.createElement)(h.Disabled,null,Object(n.createElement)(w.a,t)))};var P=Object(b.b)()?Object(j.compose)([k({icon:S,label:C,description:Object(a.__)("Choose a product to display its title.","woo-gutenberg-products-block")})])(N):N;const T={...g,apiVersion:2,title:C,description:x,icon:{src:S},attributes:O.a,edit:P,supports:Object(b.b)()?{html:!1,color:{background:!1},typography:{fontSize:!0}}:g.supports};Object(l.registerBlockType)("woocommerce/product-title",T);var R=c(259),I=c(205);const A=Object(a.__)("Product Price","woo-gutenberg-products-block"),B=Object(n.createElement)(i.a,{srcElement:I.a,className:"wc-block-editor-components-block-icon"}),L=Object(a.__)("Display the price of a product.","woo-gutenberg-products-block"),V=e=>{let{fontSize:t,setFontSize:c,color:o,setColor:r,colorLabel:l}=e;return Object(n.createElement)(n.Fragment,null,Object(n.createElement)(s.FontSizePicker,{value:t.size,onChange:c}),Object(n.createElement)(h.BaseControl,{label:l},Object(n.createElement)(s.ColorPalette,{value:o.color,onChange:r,label:Object(a.__)("Color","woo-gutenberg-products-block")})))},z=e=>{let{fontSize:t,saleFontSize:c,setFontSize:o,setSaleFontSize:r,color:l,saleColor:i,setColor:u,setSaleColor:d,attributes:p,setAttributes:m}=e;const{align:g}=p;return Object(n.createElement)(n.Fragment,null,Object(b.b)()&&Object(n.createElement)(s.BlockControls,null,Object(n.createElement)(s.AlignmentToolbar,{value:g,onChange:e=>{m({align:e})}})),Object(n.createElement)(s.InspectorControls,null,Object(b.b)()&&Object(n.createElement)(n.Fragment,null,Object(n.createElement)(h.PanelBody,{title:Object(a.__)("Price","woo-gutenberg-products-block")},Object(n.createElement)(V,{color:l,setColor:u,fontSize:t,setFontSize:o,colorLabel:Object(a.__)("Color","woo-gutenberg-products-block")})),Object(n.createElement)(h.PanelBody,{title:Object(a.__)("Sale price","woo-gutenberg-products-block")},Object(n.createElement)(V,{color:i,setColor:d,fontSize:c,setFontSize:r,colorLabel:Object(a.__)("Color","woo-gutenberg-products-block")})))),Object(n.createElement)(R.default,p))};var D=Object(b.b)()?Object(j.compose)([Object(s.withFontSizes)("fontSize"),Object(s.withFontSizes)("saleFontSize"),Object(s.withFontSizes)("originalFontSize"),Object(s.withColors)("color",{textColor:"color"}),Object(s.withColors)("saleColor",{textColor:"saleColor"}),Object(s.withColors)("originalColor",{textColor:"originalColor"}),k({icon:B,label:A,description:Object(a.__)("Choose a product to display its price.","woo-gutenberg-products-block")})])(z):z;let F={productId:{type:"number",default:0}};Object(b.b)()&&(F={...F,align:{type:"string"},fontSize:{type:"string"},customFontSize:{type:"number"},saleFontSize:{type:"string"},customSaleFontSize:{type:"number"},color:{type:"string"},saleColor:{type:"string"},customColor:{type:"string"},customSaleColor:{type:"string"}});const M={title:A,description:L,icon:{src:B},attributes:F,edit:D};Object(l.registerBlockType)("woocommerce/product-price",{...g,...M});var H=c(249),G=c(55),q=c(2),Q=c(250),Y=Object(n.createElement)(u.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(n.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(n.createElement)("path",{d:"M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-4.86 8.86l-3 3.87L9 13.14 6 17h12l-3.86-5.14z"}));const U=Object(a.__)("Product Image","woo-gutenberg-products-block"),W=Object(n.createElement)(i.a,{srcElement:Y,className:"wc-block-editor-components-block-icon"}),$=Object(a.__)("Display the main product image","woo-gutenberg-products-block");var K=k({icon:W,label:U,description:Object(a.__)("Choose a product to display its image.","woo-gutenberg-products-block")})(e=>{let{attributes:t,setAttributes:c}=e;const{showProductLink:o,imageSizing:r,showSaleBadge:l,saleBadgeAlign:i}=t;return Object(n.createElement)(n.Fragment,null,Object(n.createElement)(s.InspectorControls,null,Object(n.createElement)(h.PanelBody,{title:Object(a.__)("Content","woo-gutenberg-products-block")},Object(n.createElement)(h.ToggleControl,{label:Object(a.__)("Link to Product Page","woo-gutenberg-products-block"),help:Object(a.__)("Links the image to the single product listing.","woo-gutenberg-products-block"),checked:o,onChange:()=>c({showProductLink:!o})}),Object(n.createElement)(h.ToggleControl,{label:Object(a.__)("Show On-Sale Badge","woo-gutenberg-products-block"),help:Object(a.__)('Overlay a "sale" badge if the product is on-sale.',"woo-gutenberg-products-block"),checked:l,onChange:()=>c({showSaleBadge:!l})}),l&&Object(n.createElement)(G.a,{label:Object(a.__)("Sale Badge Alignment","woo-gutenberg-products-block"),value:i,options:[{label:Object(a.__)("Left","woo-gutenberg-products-block"),value:"left"},{label:Object(a.__)("Center","woo-gutenberg-products-block"),value:"center"},{label:Object(a.__)("Right","woo-gutenberg-products-block"),value:"right"}],onChange:e=>c({saleBadgeAlign:e})}),Object(n.createElement)(G.a,{label:Object(a.__)("Image Sizing","woo-gutenberg-products-block"),help:Object(n.createInterpolateElement)(Object(a.__)("Product image cropping can be modified in the <a>Customizer</a>.","woo-gutenberg-products-block"),{a:Object(n.createElement)("a",{href:Object(q.getAdminLink)("customize.php")+"?autofocus[panel]=woocommerce&autofocus[section]=woocommerce_product_images",target:"_blank",rel:"noopener noreferrer"})}),value:r,options:[{label:Object(a.__)("Full Size","woo-gutenberg-products-block"),value:"full-size"},{label:Object(a.__)("Cropped","woo-gutenberg-products-block"),value:"cropped"}],onChange:e=>c({imageSizing:e})}))),Object(n.createElement)(h.Disabled,null,Object(n.createElement)(Q.a,t)))});const J={title:U,description:$,icon:{src:W},attributes:H.a,edit:K};Object(l.registerBlockType)("woocommerce/product-image",{...g,...J});var X=c(260),Z=c(339);const ee=Object(a.__)("Product Rating","woo-gutenberg-products-block"),te=Object(n.createElement)(i.a,{srcElement:Z.a,className:"wc-block-editor-components-block-icon"}),ce={title:ee,description:Object(a.__)("Display the average rating of a product.","woo-gutenberg-products-block"),icon:{src:te},attributes:{productId:{type:"number",default:0}},edit:k({icon:te,label:ee,description:Object(a.__)("Choose a product to display its rating.","woo-gutenberg-products-block")})(e=>{let{attributes:t}=e;return Object(n.createElement)(X.default,t)})};Object(l.registerBlockType)("woocommerce/product-rating",{...g,...ce});var oe=c(261),re=c(206);const ne=Object(a.__)("Add to Cart Button","woo-gutenberg-products-block"),ae=Object(n.createElement)(i.a,{srcElement:re.a,className:"wc-block-editor-components-block-icon"}),se={title:ne,description:Object(a.__)("Display a call to action button which either adds the product to the cart, or links to the product page.","woo-gutenberg-products-block"),icon:{src:ae},attributes:{productId:{type:"number",default:0}},edit:k({icon:ae,label:ne,description:Object(a.__)("Choose a product to display its add to cart button.","woo-gutenberg-products-block")})(e=>{let{attributes:t}=e;return Object(n.createElement)(h.Disabled,null,Object(n.createElement)(oe.default,t))})};Object(l.registerBlockType)("woocommerce/product-button",{...g,...se});var le=c(262),ie=c(356);const ue=Object(a.__)("Product Summary","woo-gutenberg-products-block"),de=Object(n.createElement)(i.a,{srcElement:ie.a,className:"wc-block-editor-components-block-icon"}),be={title:ue,description:Object(a.__)("Display a short description about a product.","woo-gutenberg-products-block"),icon:{src:de},attributes:{productId:{type:"number",default:0}},edit:k({icon:de,label:ue,description:Object(a.__)("Choose a product to display its short description.","woo-gutenberg-products-block")})(e=>{let{attributes:t}=e;return Object(n.createElement)(le.default,t)})};Object(l.registerBlockType)("woocommerce/product-summary",{...g,...be});var pe=c(192),me=c(331);const ge=Object(a.__)("On-Sale Badge","woo-gutenberg-products-block"),Oe=Object(n.createElement)(i.a,{srcElement:me.a,className:"wc-block-editor-components-block-icon"}),he={title:ge,description:Object(a.__)("Displays an on-sale badge if the product is on-sale.","woo-gutenberg-products-block"),icon:{src:Oe},supports:{html:!1},attributes:{productId:{type:"number",default:0}},edit:k({icon:Oe,label:ge,description:Object(a.__)("Choose a product to display its sale-badge.","woo-gutenberg-products-block")})(e=>{let{attributes:t}=e;return Object(n.createElement)(pe.default,t)})};Object(l.registerBlockType)("woocommerce/product-sale-badge",{...g,...he});var je=c(92),Ee=c(263),we=Object(n.createElement)(u.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(n.createElement)("path",{d:"M2 6h2v12H2V6m3 0h1v12H5V6m2 0h3v12H7V6m4 0h1v12h-1V6m3 0h2v12h-2V6m3 0h3v12h-3V6m4 0h1v12h-1V6z"}));const _e=Object(a.__)("Product SKU","woo-gutenberg-products-block"),fe=Object(n.createElement)(i.a,{srcElement:we,className:"wc-block-editor-components-block-icon"}),ve={title:_e,description:Object(a.__)("Display the SKU of a product.","woo-gutenberg-products-block"),icon:{src:fe},attributes:{productId:{type:"number",default:0}},edit:k({icon:fe,label:_e,description:Object(a.__)("Choose a product to display its SKU.","woo-gutenberg-products-block")})(e=>{let{attributes:t}=e;return Object(n.createElement)(n.Fragment,null,Object(n.createElement)(je.a,null),Object(n.createElement)(Ee.default,t))})};Object(b.c)("woocommerce/product-sku",{...g,...ve});var ke=c(264),ye=c(324);const Ce=Object(a.__)("Product Category List","woo-gutenberg-products-block"),Se=Object(n.createElement)(i.a,{srcElement:ye.a,className:"wc-block-editor-components-block-icon"}),xe=Object(a.__)("Display a list of categories belonging to a product.","woo-gutenberg-products-block");var Ne=k({icon:Se,label:Ce,description:Object(a.__)("Choose a product to display its categories.","woo-gutenberg-products-block")})(e=>{let{attributes:t}=e;return Object(n.createElement)(n.Fragment,null,Object(n.createElement)(je.a,null),Object(n.createElement)(h.Disabled,null,Object(n.createElement)(ke.default,t)))});const Pe={...g,title:Ce,description:xe,icon:{src:Se},attributes:{productId:{type:"number",default:0}},edit:Ne};Object(b.c)("woocommerce/product-category-list",Pe);var Te=c(265);const Re=Object(a.__)("Product Tag List","woo-gutenberg-products-block"),Ie=Object(n.createElement)(i.a,{srcElement:me.a,className:"wc-block-editor-components-block-icon"}),Ae={title:Re,description:Object(a.__)("Display a list of tags belonging to a product.","woo-gutenberg-products-block"),icon:{src:Ie},attributes:{productId:{type:"number",default:0}},edit:k({icon:Ie,label:Re,description:Object(a.__)("Choose a product to display its tags.","woo-gutenberg-products-block")})(e=>{let{attributes:t}=e;return Object(n.createElement)(n.Fragment,null,Object(n.createElement)(je.a,null),Object(n.createElement)(h.Disabled,null,Object(n.createElement)(Te.default,t)))})};Object(b.c)("woocommerce/product-tag-list",{...g,...Ae});var Be=c(266),Le=Object(n.createElement)(u.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(n.createElement)("g",{fillRule:"evenodd"},Object(n.createElement)("path",{d:"M0 0h24v24H0z",fill:"none"}),Object(n.createElement)("path",{fillRule:"nonzero",d:"M20.5 5.2l-1.4-1.7C19 3.3 18.5 3 18 3H6c-.5 0-.9.2-1.2.5L3.5 5.3A2 2 0 003 6.5V19c0 1.1.9 2 2 2h14a2 2 0 002-2V6.5c0-.5-.2-1-.5-1.3zM6.2 5h11.6l.8 1H5.4l.8-1zM5 19V8h14v11H5z"})));const Ve=Object(a.__)("Product Stock Indicator","woo-gutenberg-products-block"),ze=Object(n.createElement)(i.a,{srcElement:Le,className:"wc-block-editor-components-block-icon"}),De={title:Ve,description:Object(a.__)("Display product stock status.","woo-gutenberg-products-block"),icon:{src:ze},attributes:{productId:{type:"number",default:0}},edit:k({icon:ze,label:Ve,description:Object(a.__)("Choose a product to display its stock.","woo-gutenberg-products-block")})(e=>{let{attributes:t}=e;return Object(n.createElement)(n.Fragment,null,Object(n.createElement)(je.a,null),Object(n.createElement)(Be.default,t))})};Object(b.c)("woocommerce/product-stock-indicator",{...g,...De});var Fe=c(471),Me=(c(244),c(253));const He=Object(a.__)("Add to Cart","woo-gutenberg-products-block"),Ge=Object(n.createElement)(i.a,{srcElement:re.a,className:"wc-block-editor-components-block-icon"}),qe={title:He,description:Object(a.__)("Displays an add to cart button. Optionally displays other add to cart form elements.","woo-gutenberg-products-block"),icon:{src:Ge},edit:k({icon:Ge,label:He,description:Object(a.__)("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(v.useProductDataContext)(),{className:r,showFormElements:l}=t;return Object(n.createElement)("div",{className:m()(r,"wc-block-components-product-add-to-cart")},Object(n.createElement)(je.a,{productId:o.id}),Object(n.createElement)(s.InspectorControls,null,Object(n.createElement)(h.PanelBody,{title:Object(a.__)("Layout","woo-gutenberg-products-block")},Object(Fe.b)(o)?Object(n.createElement)(h.ToggleControl,{label:Object(a.__)("Display form elements","woo-gutenberg-products-block"),help:Object(a.__)("Depending on product type, allow customers to select a quantity, variations etc.","woo-gutenberg-products-block"),checked:l,onChange:()=>c({showFormElements:!l})}):Object(n.createElement)(h.Notice,{className:"wc-block-components-product-add-to-cart-notice",isDismissible:!1,status:"info"},Object(a.__)("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(n.createElement)(h.Disabled,null,Object(n.createElement)(Me.a,t)))}),attributes:c(252).a};Object(b.c)("woocommerce/product-add-to-cart",{...g,...qe});var Qe=c(24),Ye=c.n(Qe),Ue=c(13),We=(c(10),c(59)),$e=c(462),Ke=c(340),Je=c(25);const Xe=(e,t)=>{const{className:c,contentVisibility:o}=t;return m()(e,c,{"has-image":o&&o.image,"has-title":o&&o.title,"has-rating":o&&o.rating,"has-price":o&&o.price,"has-button":o&&o.button})};var Ze=c(120);const et=[["woocommerce/product-image"],["woocommerce/product-title"],["woocommerce/product-price"],["woocommerce/product-rating"],["woocommerce/product-button"]],tt=e=>e&&0!==e.length?e.map(e=>[e.name,{...e.attributes,product:void 0,children:e.innerBlocks.length>0?tt(e.innerBlocks):[]}]):[];var ct=c(8),ot=c(6),rt=c(30);c(362);const nt=e=>{let{currentPage:t,displayFirstAndLastPages:c,displayNextAndPreviousArrows:o,pagesToDisplay:r,onPageChange:s,totalPages:l}=e,{minIndex:i,maxIndex:u}=((e,t,c)=>{if(c<=2)return{minIndex:null,maxIndex:null};const o=e-1,r=Math.max(Math.floor(t-o/2),2),n=Math.min(Math.ceil(t+(o-(t-r))),c-1);return{minIndex:Math.max(Math.floor(t-(o-(n-t))),2),maxIndex:n}})(r,t,l);const d=c&&Boolean(1!==i),b=c&&Boolean(u!==l),p=c&&Boolean(i>3),g=c&&Boolean(u<l-2);d&&3===i&&(i-=1),b&&u===l-2&&(u+=1);const O=[];if(i&&u)for(let e=i;e<=u;e++)O.push(e);return Object(n.createElement)("div",{className:"wc-block-pagination wc-block-components-pagination"},Object(n.createElement)(rt.a,{screenReaderLabel:Object(a.__)("Navigate to another page","woo-gutenberg-products-block")}),o&&Object(n.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(n.createElement)(rt.a,{label:"←",screenReaderLabel:Object(a.__)("Previous page","woo-gutenberg-products-block")})),d&&Object(n.createElement)("button",{className:m()("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(n.createElement)(rt.a,{label:1,screenReaderLabel:Object(a.sprintf)(
|
27 |
/* translators: %d is the page number (1, 2, 3...). */
|
28 |
-
Object(a.__)("Page %d","woo-gutenberg-products-block"),1)})),
|
29 |
/* translators: %d is the page number (1, 2, 3...). */
|
30 |
-
Object(a.__)("Page %d","woo-gutenberg-products-block"),e)}))),g&&Object(n.createElement)("span",{className:"wc-block-pagination-ellipsis wc-block-components-pagination__ellipsis","aria-hidden":"true"},Object(a.__)("…","woo-gutenberg-products-block")),
|
31 |
/* translators: %d is the page number (1, 2, 3...). */
|
32 |
-
Object(a.__)("Page %d","woo-gutenberg-products-block"),l)})),o&&Object(n.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(n.createElement)(
|
33 |
/* translators: %s is an integer higher than 0 (1, 2, 3...) */
|
34 |
-
Object(a._n)("%d product found","%d products found",e,"woo-gutenberg-products-block"),e)))})(w))},[null==S?void 0:S.totalQuery,w,o,y]);const{contentVisibility:x}=t,N=t.columns*t.rows,P=!Number.isFinite(w)&&Number.isFinite(null==S?void 0:S.totalProducts)&&Object(ot.isEqual)(y,null==S?void 0:S.totalQuery)?Math.ceil(S.totalProducts/N):Math.ceil(w/N),T=E.length?E:Array.from({length:N}),R=0!==E.length||_,I=i.length>0||d.length>0||Number.isFinite(p)||Number.isFinite(O);return Object(n.createElement)("div",{className:(()=>{const{columns:e,rows:c,alignButtons:o,align:r}=t,n=void 0!==r?"align"+r:"";return m()(f,n,"has-"+e+"-columns",{"has-multiple-rows":c>1,"has-aligned-buttons":o})})()},x.orderBy&&R&&Object(n.createElement)(wt,{onChange:r,value:s}),!R&&I&&Object(n.createElement)(jt,{resetCallback:()=>{u([]),b([]),g(null),h(null)}}),!R&&!I&&Object(n.createElement)(Ot,null),R&&Object(n.createElement)("ul",{className:f+"__products"},T.map((function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},c=arguments.length>1?arguments[1]:void 0;return Object(n.createElement)(ft,{key:e.id||c,attributes:t,product:e})}))),P>1&&Object(n.createElement)(at,{currentPage:c,onPageChange:e=>{l({focusableSelector:"a, button"}),o(e)},totalPages:P}))},e=>{const t=Object(n.useRef)(null);return Object(n.createElement)(n.Fragment,null,Object(n.createElement)("div",{className:"with-scroll-to-top__scroll-point",ref:t,"aria-hidden":!0}),Object(n.createElement)(kt,r()({},e,{scrollToTop:e=>{null!==t.current&&((e,t)=>{const{focusableSelector:c}=t||{};window&&Number.isFinite(window.innerHeight)&&(c?((e,t)=>{var c;const o=(null===(c=e.parentElement)||void 0===c?void 0:c.querySelectorAll(t))||[];if(o.length){const e=o[0];pt(e),null==e||e.focus()}else pt(e)})(e,c):pt(e))})(t.current,e)}})))}),Ct=e=>{let{attributes:t}=e;const[c,o]=Object(n.useState)(1),[r,a]=Object(n.useState)(t.orderby);return Object(n.useEffect)(()=>{a(t.orderby)},[t.orderby]),Object(n.createElement)(yt,{attributes:t,currentPage:c,onPageChange:e=>{o(e)},onSortChange:e=>{const t=e.target.value;a(t),o(1)},sortValue:r})},St=c(126);class xt extends ct.Component{render(){const{attributes:e,urlParameterSuffix:t}=this.props;return e.isPreview?St.a:Object(n.createElement)(v.InnerBlockLayoutContextProvider,{parentName:"woocommerce/all-products",parentClassName:"wc-block-grid"},Object(n.createElement)(Ct,{attributes:e,urlParameterSuffix:t}))}}var Nt=xt;c(359);class Pt extends n.Component{constructor(){super(...arguments),Ye()(this,"state",{isEditing:!1,innerBlocks:[]}),Ye()(this,"blockMap",Object($e.a)("woocommerce/all-products")),Ye()(this,"componentDidMount",()=>{const{block:e}=this.props;this.setState({innerBlocks:e.innerBlocks})}),Ye()(this,"getTitle",()=>Object(a.__)("All Products","woo-gutenberg-products-block")),Ye()(this,"getIcon",()=>Object(n.createElement)(i.a,{srcElement:d})),Ye()(this,"togglePreview",()=>{const{debouncedSpeak:e}=this.props;this.setState({isEditing:!this.state.isEditing}),this.state.isEditing||e(Object(a.__)("Showing All Products block preview.","woo-gutenberg-products-block"))}),Ye()(this,"getInspectorControls",()=>{const{attributes:e,setAttributes:t}=this.props,{columns:c,rows:o,alignButtons:r}=e;return Object(n.createElement)(s.InspectorControls,{key:"inspector"},Object(n.createElement)(h.PanelBody,{title:Object(a.__)("Layout Settings","woo-gutenberg-products-block"),initialOpen:!0},Object(n.createElement)(We.a,{columns:c,rows:o,alignButtons:r,setAttributes:t,minColumns:Object(q.getSetting)("min_columns",1),maxColumns:Object(q.getSetting)("max_columns",6),minRows:Object(q.getSetting)("min_rows",1),maxRows:Object(q.getSetting)("max_rows",6)})),Object(n.createElement)(h.PanelBody,{title:Object(a.__)("Content Settings","woo-gutenberg-products-block")},((e,t)=>{const{contentVisibility:c}=e;return Object(n.createElement)(h.ToggleControl,{label:Object(a.__)("Show Sorting Dropdown","woo-gutenberg-products-block"),checked:c.orderBy,onChange:()=>t({contentVisibility:{...c,orderBy:!c.orderBy}})})})(e,t),((e,t)=>Object(n.createElement)(h.SelectControl,{label:Object(a.__)("Order Products By","woo-gutenberg-products-block"),value:e.orderby,options:[{label:Object(a.__)("Default sorting (menu order)","woo-gutenberg-products-block"),value:"menu_order"},{label:Object(a.__)("Popularity","woo-gutenberg-products-block"),value:"popularity"},{label:Object(a.__)("Average rating","woo-gutenberg-products-block"),value:"rating"},{label:Object(a.__)("Latest","woo-gutenberg-products-block"),value:"date"},{label:Object(a.__)("Price: low to high","woo-gutenberg-products-block"),value:"price"},{label:Object(a.__)("Price: high to low","woo-gutenberg-products-block"),value:"price-desc"}],onChange:e=>t({orderby:e})}))(e,t)))}),Ye()(this,"getBlockControls",()=>{const{isEditing:e}=this.state;return Object(n.createElement)(s.BlockControls,null,Object(n.createElement)(h.ToolbarGroup,{controls:[{icon:"edit",title:Object(a.__)("Edit inner product layout","woo-gutenberg-products-block"),onClick:()=>this.togglePreview(),isActive:e}]}))}),Ye()(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(n.createElement)(h.Placeholder,{icon:this.getIcon(),label:this.getTitle()},Object(a.__)("Display all products from your store as a grid.","woo-gutenberg-products-block"),Object(n.createElement)("div",{className:"wc-block-all-products-grid-item-template"},Object(n.createElement)(h.Tip,null,Object(a.__)("Edit the blocks inside the preview below to change the content displayed for each product within the product grid.","woo-gutenberg-products-block")),Object(n.createElement)(v.InnerBlockLayoutContextProvider,{parentName:"woocommerce/all-products",parentClassName:"wc-block-grid"},Object(n.createElement)("div",{className:"wc-block-grid wc-block-layout has-1-columns"},Object(n.createElement)("ul",{className:"wc-block-grid__products"},Object(n.createElement)("li",{className:"wc-block-grid__product"},Object(n.createElement)(v.ProductDataContextProvider,{product:Ke.a[0]},Object(n.createElement)(s.InnerBlocks,e)))))),Object(n.createElement)("div",{className:"wc-block-all-products__actions"},Object(n.createElement)(h.Button,{className:"wc-block-all-products__done-button",isPrimary:!0,onClick:()=>{const{block:e,setAttributes:t}=this.props;t({layoutConfig:tt(e.innerBlocks)}),this.setState({innerBlocks:e.innerBlocks}),this.togglePreview()}},Object(a.__)("Done","woo-gutenberg-products-block")),Object(n.createElement)(h.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(a.__)("Cancel","woo-gutenberg-products-block")),Object(n.createElement)(h.Button,{className:"wc-block-all-products__reset-button",icon:Object(n.createElement)(i.a,{srcElement:d}),label:Object(a.__)("Reset layout to default","woo-gutenberg-products-block"),onClick:()=>{const{block:e,replaceInnerBlocks:t}=this.props,c=[];et.map(e=>{let[t,o]=e;return c.push(Object(l.createBlock)(t,o)),!0}),t(e.clientId,c,!1),this.setState({innerBlocks:e.innerBlocks})}},Object(a.__)("Reset Layout","woo-gutenberg-products-block")))))}),Ye()(this,"renderViewMode",()=>{const{attributes:e}=this.props,{layoutConfig:t}=e,c=t&&0!==t.length,o=this.getTitle(),r=this.getIcon();return c?Object(n.createElement)(h.Disabled,null,Object(n.createElement)(Nt,{attributes:e})):((e,t)=>Object(n.createElement)(h.Placeholder,{className:"wc-block-products",icon:t,label:e},Object(a.__)("The content for this block is hidden due to block settings.","woo-gutenberg-products-block")))(o,r)}),Ye()(this,"render",()=>{const{attributes:e}=this.props,{isEditing:t}=this.state,c=this.getTitle(),o=this.getIcon();return 0===Je.o.productCount?((e,t)=>Object(n.createElement)(h.Placeholder,{className:"wc-block-products",icon:t,label:e},Object(n.createElement)("p",null,Object(a.__)("You haven't published any products to list here yet.","woo-gutenberg-products-block")),Object(n.createElement)(h.Button,{className:"wc-block-products__add-product-button",isSecondary:!0,href:q.ADMIN_URL+"post-new.php?post_type=product"},Object(a.__)("Add new product","woo-gutenberg-products-block")+" ",Object(n.createElement)(i.a,{srcElement:Ze.a})),Object(n.createElement)(h.Button,{className:"wc-block-products__read_more_button",isTertiary:!0,href:"https://docs.woocommerce.com/document/managing-products/"},Object(a.__)("Learn more","woo-gutenberg-products-block"))))(c,o):Object(n.createElement)("div",{className:Xe("wc-block-all-products",e)},this.getBlockControls(),this.getInspectorControls(),t?this.renderEditMode():this.renderViewMode())})}}var Tt=Object(j.compose)(h.withSpokenMessages,Object(Ue.withSelect)((e,t)=>{let{clientId:c}=t;const{getBlock:o}=e("core/block-editor");return{block:o(c)}}),Object(Ue.withDispatch)(e=>{const{replaceInnerBlocks:t}=e("core/block-editor");return{replaceInnerBlocks:t}}))(Pt);const Rt={columns:Object(q.getSetting)("default_columns",3),rows:Object(q.getSetting)("default_rows",3),alignButtons:!1,contentVisibility:{orderBy:!0},orderby:"date",layoutConfig:et,isPreview:!1},It={title:Object(a.__)("All Products","woo-gutenberg-products-block"),icon:{src:Object(n.createElement)(i.a,{srcElement:d,className:"wc-block-editor-components-block-icon"})},category:"woocommerce",keywords:[Object(a.__)("WooCommerce","woo-gutenberg-products-block")],description:Object(a.__)("Display products from your store in a grid layout.","woo-gutenberg-products-block"),supports:{align:["wide","full"],html:!1,multiple:!1},example:{attributes:{isPreview:!0}},attributes:{columns:{type:"number"},rows:{type:"number"},alignButtons:{type:"boolean"},contentVisibility:{type:"object"},orderby:{type:"string"},layoutConfig:{type:"array"},isPreview:{type:"boolean",default:!1}},defaults:Rt,edit:e=>Object(n.createElement)(Tt,e),save(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(n.createElement)("div",r()({className:Xe("wc-block-all-products",t)},o),Object(n.createElement)(s.InnerBlocks.Content,null))}};Object(l.registerBlockType)("woocommerce/all-products",{...It,deprecated:[{attributes:Object.assign({},It.attributes,{rows:{type:"number",default:1}}),save(e){let{attributes:t}=e;const c={"data-attributes":JSON.stringify(t)};return Object(n.createElement)("div",r()({className:Xe("wc-block-all-products",t)},c),Object(n.createElement)(s.InnerBlocks.Content,null))}}]})},,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return a}));var o=c(39),r=c(0),n=c(25);c.p=n.l,Object(o.registerBlockComponent)({blockName:"woocommerce/product-price",component:Object(r.lazy)(()=>Promise.all([c.e(0),c.e(11)]).then(c.bind(null,259)))}),Object(o.registerBlockComponent)({blockName:"woocommerce/product-image",component:Object(r.lazy)(()=>Promise.all([c.e(1),c.e(3),c.e(10)]).then(c.bind(null,495)))}),Object(o.registerBlockComponent)({blockName:"woocommerce/product-title",component:Object(r.lazy)(()=>Promise.all([c.e(1),c.e(17)]).then(c.bind(null,496)))}),Object(o.registerBlockComponent)({blockName:"woocommerce/product-rating",component:Object(r.lazy)(()=>c.e(12).then(c.bind(null,260)))}),Object(o.registerBlockComponent)({blockName:"woocommerce/product-button",component:Object(r.lazy)(()=>Promise.all([c.e(0),c.e(1),c.e(2),c.e(8)]).then(c.bind(null,261)))}),Object(o.registerBlockComponent)({blockName:"woocommerce/product-summary",component:Object(r.lazy)(()=>c.e(15).then(c.bind(null,262)))}),Object(o.registerBlockComponent)({blockName:"woocommerce/product-sale-badge",component:Object(r.lazy)(()=>c.e(3).then(c.bind(null,192)))}),Object(o.registerBlockComponent)({blockName:"woocommerce/product-sku",component:Object(r.lazy)(()=>c.e(13).then(c.bind(null,263)))}),Object(o.registerBlockComponent)({blockName:"woocommerce/product-category-list",component:Object(r.lazy)(()=>c.e(9).then(c.bind(null,264)))}),Object(o.registerBlockComponent)({blockName:"woocommerce/product-tag-list",component:Object(r.lazy)(()=>c.e(16).then(c.bind(null,265)))}),Object(o.registerBlockComponent)({blockName:"woocommerce/product-stock-indicator",component:Object(r.lazy)(()=>c.e(14).then(c.bind(null,266)))}),Object(o.registerBlockComponent)({blockName:"woocommerce/product-add-to-cart",component:Object(r.lazy)(()=>Promise.all([c.e(0),c.e(1),c.e(2),c.e(7)]).then(c.bind(null,497)))});const a=e=>Object(o.getRegisteredBlockComponents)(e)},,,,,,,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return o})),c.d(t,"b",(function(){return r}));const o=e=>e.is_purchasable||!1,r=e=>["simple","variable"].includes(e.type||"simple")}]);
|
1 |
+
this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["all-products"]=function(e){function t(t){for(var o,a,s=t[0],l=t[1],i=t[2],b=0,d=[];b<s.length;b++)a=s[b],Object.prototype.hasOwnProperty.call(r,a)&&r[a]&&d.push(r[a][0]),r[a]=0;for(o in l)Object.prototype.hasOwnProperty.call(l,o)&&(e[o]=l[o]);for(u&&u(t);d.length;)d.shift()();return n.push.apply(n,i||[]),c()}function c(){for(var e,t=0;t<n.length;t++){for(var c=n[t],o=!0,s=1;s<c.length;s++){var l=c[s];0!==r[l]&&(o=!1)}o&&(n.splice(t--,1),e=a(a.s=c[0]))}return e}var o={},r={7:0,1:0,2:0,3:0,4:0,5:0,10:0,11:0,13:0,14:0,15:0,16:0,17:0,18:0},n=[];function a(t){if(o[t])return o[t].exports;var c=o[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=r[e];if(0!==c)if(c)t.push(c[2]);else{var o=new Promise((function(t,o){c=r[e]=[t,o]}));t.push(c[2]=o);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:"atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/image---8f355022",2:"atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/image---a7e2bb9b",3:"atomic-block-components/stock-indicator--atomic-block-components/summary--atomic-block-components/title",4:"atomic-block-components/add-to-cart--atomic-block-components/button",5:"atomic-block-components/sale-badge",9:"atomic-block-components/add-to-cart",10:"atomic-block-components/button",11:"atomic-block-components/category-list",12:"atomic-block-components/image",13:"atomic-block-components/price",14:"atomic-block-components/rating",15:"atomic-block-components/sku",16:"atomic-block-components/stock-indicator",17:"atomic-block-components/summary",18:"atomic-block-components/tag-list",19:"atomic-block-components/title"}[e]||e)+".js?ver="+{1:"f50e847d1ee621be60aa",2:"41f5c036459bcad44a7d",3:"5237971cb311f02de6cb",4:"d2dd37558d14f3d7266d",5:"456da5ad7931015df375",9:"67c959d8fb701b720b0a",10:"3ea49eb9eaed51ed672d",11:"d6e38aa04ac0aaa7b451",12:"f9b09372c56e1ee55df0",13:"fb8b6e9b4354d94e9a2e",14:"9d4c32fcf70f153c5781",15:"be02edf8d29542f0b7c6",16:"f1b33ab4dbf4f6cff131",17:"03cbae0c226b3072d661",18:"b6375f8334cf0aa02bf4",19:"244f2823473b15acc568"}[e]}(e);var l=new Error;n=function(t){s.onerror=s.onload=null,clearTimeout(i);var c=r[e];if(0!==c){if(c){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,c[1](l)}r[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=o,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 o in e)a.d(c,o,function(t){return e[t]}.bind(null,o));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([355,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.lodash},function(e,t){e.exports=window.wp.blockEditor},function(e,t){e.exports=window.React},function(e,t){e.exports=window.wp.compose},,function(e,t){e.exports=window.wp.apiFetch},function(e,t){e.exports=window.wp.blocks},function(e,t){e.exports=window.wp.data},function(e,t){e.exports=window.wp.htmlEntities},function(e,t){e.exports=window.wp.url},function(e,t){e.exports=window.wc.wcBlocksData},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 o=c(0),r=c(6),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(r.groupBy)(e,"parent"),o=Object(r.keyBy)(t,"id"),n=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e.parent)return e.name?[e.name]:[];const t=n(o[e.parent]);return[...t,e.name]},a=e=>e.map(e=>{const t=c[e.id];return delete c[e.id],{...e,breadcrumbs:n(o[e.parent]),children:t&&t.length?a(t):[]}}),s=a(c[0]||[]);return delete c[0],Object(r.forEach)(c,e=>{s.push(...a(e||[]))}),s},l=(e,t,c)=>{if(!t)return c?s(e):e;const o=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),r=e.map(e=>!!o.test(e.name)&&e).filter(Boolean);return c?s(r,e):r},i=(e,t)=>{if(!t)return e;const c=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"ig");return e.split(c).map((e,c)=>0===c?e:Object(o.createElement)(o.Fragment,{key:c},Object(o.createElement)("strong",null,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){e.exports=window.wp.primitives},,,,,,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 b})),c.d(t,"g",(function(){return d})),c.d(t,"k",(function(){return m})),c.d(t,"c",(function(){return p})),c.d(t,"d",(function(){return g})),c.d(t,"h",(function(){return O})),c.d(t,"a",(function(){return h})),c.d(t,"i",(function(){return j})),c.d(t,"b",(function(){return E}));var o,r=c(2);const n=Object(r.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),a=n.pluginUrl+"images/",s=n.pluginUrl+"build/",l=n.buildPhase,i=null===(o=r.STORE_PAGES.shop)||void 0===o?void 0:o.permalink,u=r.STORE_PAGES.checkout.id,b=r.STORE_PAGES.checkout.permalink,d=r.STORE_PAGES.privacy.permalink,m=(r.STORE_PAGES.privacy.title,r.STORE_PAGES.terms.permalink),p=(r.STORE_PAGES.terms.title,r.STORE_PAGES.cart.id),g=r.STORE_PAGES.cart.permalink,O=(r.STORE_PAGES.myaccount.permalink?r.STORE_PAGES.myaccount.permalink:Object(r.getSetting)("wpLoginUrl","/wp-login.php"),Object(r.getSetting)("shippingCountries",{})),h=Object(r.getSetting)("allowedCountries",{}),j=Object(r.getSetting)("shippingStates",{}),E=Object(r.getSetting)("allowedStates",{})},,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 b})),c.d(t,"i",(function(){return d})),c.d(t,"f",(function(){return m})),c.d(t,"c",(function(){return p})),c.d(t,"d",(function(){return g})),c.d(t,"g",(function(){return O})),c.d(t,"a",(function(){return h}));var o=c(15),r=c(11),n=c.n(r),a=c(6),s=c(2),l=c(24);const i=e=>{let{selected:t=[],search:c="",queryArgs:r={}}=e;const s=(e=>{let{selected:t=[],search:c="",queryArgs:r={}}=e;const n=l.o.productCount>100,a={per_page:n?100:0,catalog_visibility:"any",search:c,orderby:"title",order:"asc"},s=[Object(o.addQueryArgs)("/wc/store/products",{...a,...r})];return n&&t.length&&s.push(Object(o.addQueryArgs)("/wc/store/products",{catalog_visibility:"any",include:t,per_page:0})),s})({selected:t,search:c,queryArgs:r});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/products/"+e}),b=()=>n()({path:"wc/store/products/attributes"}),d=e=>n()({path:`wc/store/products/attributes/${e}/terms`}),m=e=>{let{selected:t=[],search:c}=e;const r=(e=>{let{selected:t=[],search:c}=e;const r=Object(s.getSetting)("limitTags",!1),n=[Object(o.addQueryArgs)("wc/store/products/tags",{per_page:r?100:0,orderby:r?"count":"name",order:r?"desc":"asc",search:c})];return r&&t.length&&n.push(Object(o.addQueryArgs)("wc/store/products/tags",{include:t})),n})({selected:t,search:c});return Promise.all(r.map(e=>n()({path:e}))).then(e=>Object(a.uniqBy)(Object(a.flatten)(e),"id"))},p=e=>n()({path:Object(o.addQueryArgs)("wc/store/products/categories",{per_page:0,...e})}),g=e=>n()({path:"wc/store/products/categories/"+e}),O=e=>n()({path:Object(o.addQueryArgs)("wc/store/products",{per_page:0,type:"variation",parent:e})}),h=(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";c.d(t,"a",(function(){return r})),c.d(t,"b",(function(){return n}));var o=c(1);const r=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"}},n=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?void 0:e.message)||Object(o.__)("Something went wrong. Please contact us to get assistance.","woo-gutenberg-products-block")}},function(e,t){e.exports=window.wc.wcBlocksSharedContext},function(e,t,c){"use strict";var o=c(0),r=c(4),n=c.n(r);t.a=e=>{let t,{label:c,screenReaderLabel:r,wrapperElement:a,wrapperProps:s={}}=e;const l=null!=c,i=null!=r;return!l&&i?(t=a||"span",s={...s,className:n()(s.className,"screen-reader-text")},Object(o.createElement)(t,s,r)):(t=a||o.Fragment,l&&i&&c!==r?Object(o.createElement)(t,s,Object(o.createElement)("span",{"aria-hidden":"true"},c),Object(o.createElement)("span",{className:"screen-reader-text"},r)):Object(o.createElement)(t,s,c))}},function(e,t){e.exports=window.wp.escapeHtml},function(e,t,c){"use strict";var o=c(0),r=c(1),n=c(31);t.a=e=>{let{error:t}=e;return Object(o.createElement)("div",{className:"wc-block-error-message"},(e=>{let{message:t,type:c}=e;return t?"general"===c?Object(o.createElement)("span",null,Object(r.__)("The following error was returned","woo-gutenberg-products-block"),Object(o.createElement)("br",null),Object(o.createElement)("code",null,Object(n.escapeHTML)(t))):"api"===c?Object(o.createElement)("span",null,Object(r.__)("The following error was returned from the API","woo-gutenberg-products-block"),Object(o.createElement)("br",null),Object(o.createElement)("code",null,Object(n.escapeHTML)(t))):t:Object(r.__)("An unknown error occurred which prevented the block from being updated.","woo-gutenberg-products-block")})(t))}},function(e,t,c){"use strict";c.d(t,"a",(function(){return s}));var o=c(5),r=c.n(o),n=c(0),a=c(17);const s=e=>{let{countLabel:t,className:c,depth:o=0,controlId:s="",item:l,isSelected:i,isSingle:u,onSelect:b,search:d="",...m}=e;const p=null!=t&&void 0!==l.count&&null!==l.count,g=[c,"woocommerce-search-list__item"];g.push("depth-"+o),u&&g.push("is-radio-button"),p&&g.push("has-count");const O=l.breadcrumbs&&l.breadcrumbs.length,h=m.name||"search-list-item-"+s,j=`${h}-${l.id}`;return Object(n.createElement)("label",{htmlFor:j,className:g.join(" ")},u?Object(n.createElement)("input",r()({type:"radio",id:j,name:h,value:l.value,onChange:b(l),checked:i,className:"woocommerce-search-list__item-input"},m)):Object(n.createElement)("input",r()({type:"checkbox",id:j,name:h,value:l.value,onChange:b(l),checked:i,className:"woocommerce-search-list__item-input"},m)),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,d))),!!p&&Object(n.createElement)("span",{className:"woocommerce-search-list__item-count"},t||l.count))};t.b=s},,function(e,t){e.exports=window.wc.priceFormat},function(e,t,c){"use strict";c.d(t,"a",(function(){return _}));var o=c(6),r=c(0),n=c(16),a=c(13),s=c(14),l=c(151),i=c(251),u=c(49),b=c(250);const d=e=>{const t=e.detail;t&&t.preserveCartData||Object(a.dispatch)(n.CART_STORE_KEY).invalidateResolutionForStore()},m=()=>{1===window.wcBlocksStoreCartListeners.count&&window.wcBlocksStoreCartListeners.remove(),window.wcBlocksStoreCartListeners.count--},p=()=>{Object(r.useEffect)(()=>((()=>{if(window.wcBlocksStoreCartListeners||(window.wcBlocksStoreCartListeners={count:0,remove:()=>{}}),0===window.wcBlocksStoreCartListeners.count){const e=Object(b.a)("added_to_cart","wc-blocks_added_to_cart"),t=Object(b.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++})(),m),[])},g={first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:""},O={...g,email:""},h={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(l.a)(Object.entries(e).map(e=>{let[t,c]=e;return[t,Object(s.decodeEntities)(c)]})),E={cartCoupons:n.EMPTY_CART_COUPONS,cartItems:n.EMPTY_CART_ITEMS,cartFees:n.EMPTY_CART_FEES,cartItemsCount:0,cartItemsWeight:0,cartNeedsPayment:!0,cartNeedsShipping:!0,cartItemErrors:n.EMPTY_CART_ITEM_ERRORS,cartTotals:h,cartIsLoading:!0,cartErrors:n.EMPTY_CART_ERRORS,billingAddress:O,shippingAddress:g,shippingRates:n.EMPTY_SHIPPING_RATES,shippingRatesLoading:!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(u.b)(),s=null==c?void 0:c.previewCart,{shouldSelect:l}=e,b=Object(r.useRef)();p();const d=Object(a.useSelect)((e,c)=>{let{dispatch:o}=c;if(!l)return E;if(t)return{cartCoupons:s.coupons,cartItems:s.items,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,billingAddress:O,shippingAddress:g,extensions:n.EMPTY_EXTENSIONS,shippingRates:s.shipping_rates,shippingRatesLoading:!1,cartHasCalculatedShipping:s.has_calculated_shipping,paymentRequirements:s.paymentRequirements,receiveCart:"function"==typeof(null==s?void 0:s.receiveCart)?s.receiveCart:()=>{}};const r=e(n.CART_STORE_KEY),a=r.getCartData(),u=r.getCartErrors(),b=r.getCartTotals(),d=!r.hasFinishedResolution("getCartData"),m=r.isCustomerDataUpdating(),{receiveCart:p}=o(n.CART_STORE_KEY),h=j(a.billingAddress),_=a.needsShipping?j(a.shippingAddress):h,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,cartFees:w,cartItemsCount:a.itemsCount,cartItemsWeight:a.itemsWeight,cartNeedsPayment:a.needsPayment,cartNeedsShipping:a.needsShipping,cartItemErrors:a.errors,cartTotals:b,cartIsLoading:d,cartErrors:u,billingAddress:Object(i.a)(h),shippingAddress:Object(i.a)(_),extensions:a.extensions,shippingRates:a.shippingRates,shippingRatesLoading:m,cartHasCalculatedShipping:a.hasCalculatedShipping,paymentRequirements:a.paymentRequirements,receiveCart:p}},[l]);return b.current&&Object(o.isEqual)(b.current,d)||(b.current=d),b.current}},,function(e,t){e.exports=window.wc.wcBlocksRegistry},function(e,t,c){"use strict";c.d(t,"a",(function(){return a}));var o=c(0),r=c(26),n=c.n(r);function a(e){const t=Object(o.useRef)(e);return n()(e,t.current)||(t.current=e),t.current}},,function(e,t,c){"use strict";var o=c(5),r=c.n(o),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:o,onValueChange:s,displayType:u="text",...b}=e;const d="string"==typeof c?parseInt(c,10):c;if(!Number.isFinite(d))return null;const m=d/10**o.minorUnit;if(!Number.isFinite(m))return null;const p=l()("wc-block-formatted-money-amount","wc-block-components-formatted-money-amount",t),g={...b,...i(o),value:void 0,currency:void 0,onValueChange:void 0},O=s?e=>{const t=+e.value*10**o.minorUnit;s(t)}:()=>{};return Object(n.createElement)(a.a,r()({className:p,displayType:u},g,{value:m,onValueChange:O}))}},,function(e,t,c){"use strict";var o=c(0);t.a=function(e){let{srcElement:t,size:c=24,...r}=e;return Object(o.isValidElement)(t)?Object(o.cloneElement)(t,{width:c,height:c,...r}):null}},function(e,t,c){"use strict";c.d(t,"a",(function(){return l})),c.d(t,"b",(function(){return i})),c.d(t,"c",(function(){return b}));var o=c(64);let r,n;!function(e){e.SUCCESS="success",e.FAIL="failure",e.ERROR="error"}(r||(r={})),function(e){e.PAYMENTS="wc/payment-area",e.EXPRESS_PAYMENTS="wc/express-payment-area"}(n||(n={}));const a=(e,t)=>Object(o.b)(e)&&"type"in e&&e.type===t,s=e=>a(e,r.SUCCESS),l=e=>a(e,r.ERROR),i=e=>a(e,r.FAIL),u=e=>!Object(o.b)(e)||void 0===e.retry||!0===e.retry,b=()=>({responseTypes:r,noticeContexts:n,shouldRetry:u,isSuccessResponse:s,isErrorResponse:l,isFailResponse:i})},,function(e,t){e.exports=window.wp.a11y},function(e,t,c){"use strict";c.d(t,"a",(function(){return n}));var o=c(0),r=c(130);const n=()=>{const{notices:e,createNotice:t,removeNotice:c,setIsSuppressed:n}=Object(r.b)(),a=Object(o.useRef)(e);Object(o.useEffect)(()=>{a.current=e},[e]);const s=Object(o.useMemo)(()=>({hasNoticesOfType:e=>a.current.some(t=>t.type===e),removeNotices:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;a.current.forEach(t=>{null!==e&&t.status!==e||c(t.id)})},removeNotice:c}),[c]),l=Object(o.useMemo)(()=>({addDefaultNotice:function(e){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("default",e,{...c})},addErrorNotice:function(e){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("error",e,{...c})},addWarningNotice:function(e){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("warning",e,{...c})},addInfoNotice:function(e){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("info",e,{...c})},addSuccessNotice:function(e){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("success",e,{...c})}}),[t]);return{notices:e,...s,...l,setIsSuppressed:n}}},function(e,t,c){"use strict";c.d(t,"a",(function(){return n}));var o=c(0);const r=Object(o.createContext)("page"),n=()=>Object(o.useContext)(r);r.Provider},function(e,t,c){"use strict";c.d(t,"b",(function(){return a})),c.d(t,"a",(function(){return s}));var o=c(0),r=c(13);const n=Object(o.createContext)({isEditor:!1,currentPostId:0,currentView:"",previewData:{},getPreviewData:()=>{}}),a=()=>Object(o.useContext)(n),s=e=>{let{children:t,currentPostId:c=0,currentView:a="",previewData:s={}}=e;const l=Object(r.useSelect)(e=>c||e("core/editor").getCurrentPostId(),[c]),i=Object(o.useCallback)(e=>e in s?s[e]:{},[s]),u={isEditor:!0,currentPostId:l,currentView:a,previewData:s,getPreviewData:i};return Object(o.createElement)(n.Provider,{value:u},t)}},,,,,function(e,t){e.exports=window.wc.wcBlocksSharedHocs},function(e,t,c){"use strict";var o=c(5),r=c.n(o),n=c(0),a=c(6),s=c(4),l=c.n(s),i=c(3),u=c(9);c(84);class b extends n.Component{constructor(){super(...arguments),this.onClick=this.onClick.bind(this)}onClick(e){this.props.onChange&&this.props.onChange(e.target.value)}render(){const{label:e,checked:t,instanceId:c,className:o,help:s,options:u,value:b}=this.props,d="inspector-toggle-button-control-"+c;let m;return s&&(m=Object(a.isFunction)(s)?s(t):s),Object(n.createElement)(i.BaseControl,{id:d,help:m,className:l()("components-toggle-button-control",o)},Object(n.createElement)("label",{id:d+"__label",htmlFor:d,className:"components-toggle-button-control__label"},e),Object(n.createElement)(i.ButtonGroup,{"aria-labelledby":d+"__label"},u.map((t,c)=>{const o={};return b===t.value?(o.isPrimary=!0,o["aria-pressed"]=!0):(o.isSecondary=!0,o["aria-pressed"]=!1),Object(n.createElement)(i.Button,r()({key:`${t.label}-${t.value}-${c}`,value:t.value,onClick:this.onClick,"aria-label":e+": "+t.label},o),t.label)})))}}t.a=Object(u.withInstanceId)(b)},,,,function(e,t,c){"use strict";var o=c(0),r=c(1),n=c(6),a=(c(10),c(3));t.a=e=>{let{columns:t,rows:c,setAttributes:s,alignButtons:l,minColumns:i=1,maxColumns:u=6,minRows:b=1,maxRows:d=6}=e;return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(a.RangeControl,{label:Object(r.__)("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(o.createElement)(a.RangeControl,{label:Object(r.__)("Rows","woo-gutenberg-products-block"),value:c,onChange:e=>{const t=Object(n.clamp)(e,b,d);s({rows:Number.isNaN(t)?"":t})},min:b,max:d}),Object(o.createElement)(a.ToggleControl,{label:Object(r.__)("Align Last Block","woo-gutenberg-products-block"),help:l?Object(r.__)("The last inner block will be aligned vertically.","woo-gutenberg-products-block"):Object(r.__)("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 o=c(61),r=c(0),n=c(36);const a=()=>{const e=Object(n.a)(),t=Object(r.useRef)(e);return Object(r.useEffect)(()=>{t.current=e},[e]),{dispatchStoreEvent:Object(r.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(o.doAction)("experimental__woocommerce_blocks-"+e,t)}catch(e){console.error(e)}}),[]),dispatchCheckoutEvent:Object(r.useCallback)((function(e){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(o.doAction)("experimental__woocommerce_blocks-checkout-"+e,{...c,storeCart:t.current})}catch(e){console.error(e)}}),[])}}},function(e,t){e.exports=window.wp.hooks},,,function(e,t,c){"use strict";c.d(t,"a",(function(){return o})),c.d(t,"c",(function(){return r})),c.d(t,"b",(function(){return n})),c.d(t,"d",(function(){return a}));const o=e=>"number"==typeof e,r=e=>"string"==typeof e,n=e=>!(e=>null===e)(e)&&e instanceof Object&&e.constructor===Object;function a(e,t){return n(e)&&t in e}},,function(e,t){e.exports=window.wp.deprecated},,,,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 o=c(12),r=c(24);const n=(e,t)=>{if(r.n>2)return Object(o.registerBlockType)(e,t)},a=(e,t)=>{if(r.n>1)return Object(o.registerBlockType)(e,t)},s=()=>r.n>2,l=()=>r.n>1},,,function(e,t,c){"use strict";c.d(t,"a",(function(){return b})),c.d(t,"b",(function(){return d})),c.d(t,"c",(function(){return m}));var o=c(16),r=c(13),n=c(0),a=c(26),s=c.n(a),l=c(39),i=c(109),u=c(48);const b=e=>{const t=Object(u.a)();e=e||t;const c=Object(r.useSelect)(t=>t(o.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0),[e]),{setValueForQueryContext:a}=Object(r.useDispatch)(o.QUERY_STATE_STORE_KEY);return[c,Object(n.useCallback)(t=>{a(e,t)},[e,a])]},d=(e,t,c)=>{const a=Object(u.a)();c=c||a;const s=Object(r.useSelect)(r=>r(o.QUERY_STATE_STORE_KEY).getValueForQueryKey(c,e,t),[c,e]),{setQueryValue:l}=Object(r.useDispatch)(o.QUERY_STATE_STORE_KEY);return[s,Object(n.useCallback)(t=>{l(c,e,t)},[c,e,l])]},m=(e,t)=>{const c=Object(u.a)();t=t||c;const[o,r]=b(t),a=Object(l.a)(o),d=Object(l.a)(e),m=Object(i.a)(d),p=Object(n.useRef)(!1);return Object(n.useEffect)(()=>{s()(m,d)||(r(Object.assign({},a,d)),p.current=!0)},[a,d,m,r]),p.current?[o,r]:[e,r]}},,,function(e,t){e.exports=window.wp.autop},,,,function(e,t,c){"use strict";var o=c(5),r=c.n(o),n=c(0),a=c(139),s=c(4),l=c.n(s),i=c(100);c(160),t.a=e=>{let{className:t,showSpinner:c=!1,children:o,...s}=e;const u=l()("wc-block-components-button",t,{"wc-block-components-button--loading":c});return Object(n.createElement)(a.a,r()({className:u},s),c&&Object(n.createElement)(i.a,null),Object(n.createElement)("span",{className:"wc-block-components-button__text"},o))}},,function(e,t){e.exports=window.wp.dom},,function(e,t){},,,function(e,t,c){"use strict";c.d(t,"a",(function(){return k}));var o=c(5),r=c.n(o),n=c(0),a=c(1),s=c(3),l=c(484),i=c(486),u=c(4),b=c.n(u),d=c(9),m=c(17),p=c(33),g=c(485),O=c(14);const h=e=>{let{id:t,label:c,popoverContents:o,remove:r,screenReaderLabel:i,className:u=""}=e;const[m,p]=Object(n.useState)(!1),j=Object(d.useInstanceId)(h);if(i=i||c,!c)return null;c=Object(O.decodeEntities)(c);const E=b()("woocommerce-tag",u,{"has-remove":!!r}),_="woocommerce-tag__label-"+j,w=Object(n.createElement)(n.Fragment,null,Object(n.createElement)("span",{className:"screen-reader-text"},i),Object(n.createElement)("span",{"aria-hidden":"true"},c));return Object(n.createElement)("span",{className:E},o?Object(n.createElement)(s.Button,{className:"woocommerce-tag__text",id:_,onClick:()=>p(!0)},w):Object(n.createElement)("span",{className:"woocommerce-tag__text",id:_},w),o&&m&&Object(n.createElement)(s.Popover,{onClose:()=>p(!1)},o),r&&Object(n.createElement)(s.Button,{className:"woocommerce-tag__remove",onClick:r(t),label:Object(a.sprintf)(// Translators: %s label.
|
6 |
+
Object(a.__)("Remove %s","woo-gutenberg-products-block"),c),"aria-describedby":_},Object(n.createElement)(l.a,{icon:g.a,size:20,className:"clear-icon"})))};var j=h;const E=e=>Object(n.createElement)(p.b,e),_=e=>{const{list:t,selected:c,renderItem:o,depth:a=0,onSelect:s,instanceId:l,isSingle:i,search:u}=e;return t?Object(n.createElement)(n.Fragment,null,t.map(t=>{const b=-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,o({item:t,isSelected:b,onSelect:s,isSingle:i,search:u,depth:a,controlId:l})),Object(n.createElement)(_,r()({},e,{list:t.children,depth:a+1})))})):null},w=e=>{let{isLoading:t,isSingle:c,selected:o,messages:r,onChange:l,onRemove:i}=e;if(t||c||!o)return null;const u=o.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,r.selected(u)),u>0?Object(n.createElement)(s.Button,{isLink:!0,isDestructive:!0,onClick:()=>l([]),"aria-label":r.clear},Object(a.__)("Clear all","woo-gutenberg-products-block")):null),u>0?Object(n.createElement)("ul",null,o.map((e,t)=>Object(n.createElement)("li",{key:t},Object(n.createElement)(j,{label:e.name,id:e.id,remove:i})))):null)},f=e=>{let{filteredList:t,search:c,onSelect:o,instanceId:r,...s}=e;const{messages:u,renderItem:b,selected:d,isSingle:m}=s,p=b||E;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)(_,{list:t,selected:d,renderItem:p,onSelect:o,instanceId:r,isSingle:m,search:c}))},k=e=>{const{className:t="",isCompact:c,isHierarchical:o,isLoading:a,isSingle:l,list:i,messages:u=m.a,onChange:p,onSearch:g,selected:O,debouncedSpeak:h}=e,[j,E]=Object(n.useState)(""),_=Object(d.useInstanceId)(k),v=Object(n.useMemo)(()=>({...m.a,...u}),[u]),y=Object(n.useMemo)(()=>Object(m.c)(i,j,o),[i,j,o]);Object(n.useEffect)(()=>{h&&h(v.updated)},[h,v]),Object(n.useEffect)(()=>{"function"==typeof g&&g(j)},[j,g]);const S=Object(n.useCallback)(e=>()=>{l&&p([]);const t=O.findIndex(t=>{let{id:c}=t;return c===e});p([...O.slice(0,t),...O.slice(t+1)])},[l,O,p]),C=Object(n.useCallback)(e=>()=>{-1===O.findIndex(t=>{let{id:c}=t;return c===e.id})?p(l?[e]:[...O,e]):S(e.id)()},[l,S,p,O]);return Object(n.createElement)("div",{className:b()("woocommerce-search-list",t,{"is-compact":c})},Object(n.createElement)(w,r()({},e,{onRemove:S,messages:v})),Object(n.createElement)("div",{className:"woocommerce-search-list__search"},Object(n.createElement)(s.TextControl,{label:v.search,type:"search",value:j,onChange:e=>E(e)})),a?Object(n.createElement)("div",{className:"woocommerce-search-list__list is-loading"},Object(n.createElement)(s.Spinner,null)):Object(n.createElement)(f,r()({},e,{search:j,filteredList:y,messages:v,onSelect:C,instanceId:_})))};Object(s.withSpokenMessages)(k)},,function(e,t,c){"use strict";var o=c(5),r=c.n(o),n=c(0),a=c(33),s=c(3),l=c(4),i=c.n(l);t.a=e=>{let{className:t,item:c,isSelected:o,isLoading:l,onSelect:u,disabled:b,...d}=e;return Object(n.createElement)(n.Fragment,null,Object(n.createElement)(a.a,r()({},d,{key:c.id,className:t,isSelected:o,item:c,onSelect:u,isSingle:!0,disabled:b})),o&&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";var o=c(0),r=c(6),n=c(1),a=c(3);function s(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(o.createElement)(a.SVG,{width:"20",height:"20",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg"},Object(o.createElement)(a.Path,{d:c[t]})):null}class l extends o.Component{createLevelControl(e,t,c){const r=e===t;return{icon:Object(o.createElement)(s,{level:e}),title:Object(n.sprintf)(
|
7 |
/* translators: %s: heading level e.g: "2", "3", "4" */
|
8 |
+
Object(n.__)("Heading %d","woo-gutenberg-products-block"),e),isActive:r,onClick:()=>c(e)}}render(){const{isCollapsed:e=!0,minLevel:t,maxLevel:c,selectedLevel:n,onChange:l}=this.props;return Object(o.createElement)(a.ToolbarGroup,{isCollapsed:e,icon:Object(o.createElement)(s,{level:n}),controls:Object(r.range)(t,c).map(e=>this.createLevelControl(e,n,l))})}}t.a=l},,function(e,t){e.exports=window.wp.warning},function(e,t,c){"use strict";var o=c(0),r=c(1),n=c(43),a=c(122),s=c(2),l=c(7),i=c(29);t.a=e=>{const t=(Object(i.useProductDataContext)().product||{}).id||e.productId||0;return t?Object(o.createElement)(l.InspectorControls,null,Object(o.createElement)("div",{className:"wc-block-single-product__edit-card"},Object(o.createElement)("div",{className:"wc-block-single-product__edit-card-title"},Object(o.createElement)("a",{href:`${s.ADMIN_URL}post.php?post=${t}&action=edit`,target:"_blank",rel:"noopener noreferrer"},Object(r.__)("Edit this product's details","woo-gutenberg-products-block"),Object(o.createElement)(n.a,{srcElement:a.a,size:16}))),Object(o.createElement)("div",{className:"wc-block-single-product__edit-card-description"},Object(r.__)("Edit details such as title, price, description and more.","woo-gutenberg-products-block")))):null}},function(e,t,c){"use strict";c.d(t,"a",(function(){return r}));var o=c(0);const r=()=>{const[,e]=Object(o.useState)();return Object(o.useCallback)(t=>{e(()=>{throw t})},[])}},,,,,function(e,t,c){"use strict";var o=c(2),r=c(1),n=c(64);const a=Object(o.getSetting)("countryLocale",{}),s=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(r.sprintf)(
|
9 |
/* translators: %s Field label. */
|
10 |
+
Object(r.__)("%s (optional)","woo-gutenberg-products-block"),e.label)),e.priority&&(Object(n.a)(e.priority)&&(t.index=e.priority),Object(n.c)(e.priority)&&(t.index=parseInt(e.priority,10))),e.hidden&&(t.required=!1),t},l=Object.entries(a).map(e=>{let[t,c]=e;return[t,Object.entries(c).map(e=>{let[t,c]=e;return[t,s(c)]}).reduce((e,t)=>{let[c,o]=t;return e[c]=o,e},{})]}).reduce((e,t)=>{let[c,o]=t;return e[c]=o,e},{});t.a=function(e,t){let c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";const r=c&&void 0!==l[c]?l[c]:{};return e.map(e=>({key:e,...o.defaultAddressFields[e]||{},...r[e]||{},...t[e]||{}})).sort((e,t)=>e.index-t.index)}},function(e,t,c){"use strict";var o=c(0);c(161),t.a=()=>Object(o.createElement)("span",{className:"wc-block-components-spinner","aria-hidden":"true"})},function(e,t){e.exports=window.wp.wordcount},function(e,t,c){"use strict";var o=c(5),r=c.n(o),n=c(0),a=c(1),s=c(6),l=(c(10),c(33)),i=c(87),u=c(9),b=Object(u.createHigherOrderComponent)(e=>{class t extends n.Component{render(){const{selected:t}=this.props,c=null==t;return Object(n.createElement)(e,r()({},this.props,{selected:c?[]:[t]}))}}return t.defaultProps={selected:null},t},"withTransformSingleSelectToMultipleSelect"),d=c(193),m=c(25),p=c.n(m),g=c(26),O=c.n(g),h=c(27),j=c(28),E=Object(u.createHigherOrderComponent)(e=>{class t extends n.Component{constructor(){super(...arguments),p()(this,"state",{error:null,loading:!1,variations:{}}),p()(this,"loadVariations",()=>{const{products:e}=this.props,{loading:t,variations:c}=this.state;if(t)return;const o=this.getExpandedProduct();if(!o||c[o])return;const r=e.find(e=>e.id===o);r.variations&&0!==r.variations.length?(this.setState({loading:!0}),Object(h.g)(o).then(e=>{const t=e.map(e=>({...e,parent:o}));this.setState({variations:{...this.state.variations,[o]:t},loading:!1,error:null})}).catch(async e=>{const t=await Object(j.a)(e);this.setState({variations:{...this.state.variations,[o]:null},loading:!1,error:t})})):this.setState({variations:{...this.state.variations,[o]: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:o}=this.props;o&&(!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){const{products:t}=this.props;return t.filter(t=>t.variations&&t.variations.find(t=>{let{id:c}=t;return c===e}))[0].id}getExpandedProduct(){const{isLoading:e,selected:t,showVariations:c}=this.props;if(!c)return null;let o=t&&t.length?t[0]:null;return o?this.prevSelectedItem=o:this.prevSelectedItem&&(e||this.isProductId(this.prevSelectedItem)||(o=this.prevSelectedItem)),!e&&o?this.isProductId(o)?o:this.findParentProduct(o):null}render(){const{error:t,isLoading:c}=this.props,{error:o,loading:a,variations:s}=this.state;return Object(n.createElement)(e,r()({},this.props,{error:o||t,expandedProduct:this.getExpandedProduct(),isLoading:c,variations:s,variationsLoading:a}))}}return p()(t,"defaultProps",{selected:[],showVariations:!1}),t},"withProductVariations"),_=c(32),w=c(4),f=c.n(w),k=c(89);c(142);const v={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")},y=e=>{let{expandedProduct:t,error:c,instanceId:o,isCompact:u,isLoading:b,onChange:d,onSearch:m,products:p,renderItem:g,selected:O,showVariations:h,variations:j,variationsLoading:E}=e;if(c)return Object(n.createElement)(_.a,{error:c});const w=[...p,...j&&j[t]?j[t]:[]];return Object(n.createElement)(i.a,{className:"woocommerce-products",list:w,isCompact:u,isLoading:b,isSingle:!0,selected:w.filter(e=>{let{id:t}=e;return O.includes(t)}),onChange:d,renderItem:g||(h?e=>{const{item:t,search:c,depth:i=0,isSelected:u,onSelect:d}=e,m=t.variations&&Array.isArray(t.variations)?t.variations.length:0,p=f()("woocommerce-search-product__item","woocommerce-search-list__item","depth-"+i,"has-count",{"is-searching":c.length>0,"is-skip-level":0===i&&0!==t.parent,"is-variable":m>0});if(!t.breadcrumbs.length)return Object(n.createElement)(k.a,r()({},e,{className:f()(p,{"is-selected":u}),isSelected:u,item:t,onSelect:()=>()=>{d(t)()},isLoading:b||E,countLabel:t.variations.length>0?Object(a.sprintf)(
|
11 |
/* translators: %1$d is the number of variations of a product product. */
|
12 |
Object(a.__)("%1$d variations","woo-gutenberg-products-block"),t.variations.length):null,name:"products-"+o,"aria-label":Object(a.sprintf)(
|
13 |
/* translators: %1$s is the product name, %2$d is the number of variations of that product. */
|
14 |
+
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,r()({},g,{className:p,name:"variations-"+o}))}:null),onSearch:m,messages:v,isHierarchical:!0})};y.defaultProps={isCompact:!1,expandedProduct:null,selected:[],showVariations:!1},t.a=b(Object(d.a)(E(Object(u.withInstanceId)(y))))},function(e,t,c){"use strict";var o=c(0),r=c(18);const n=Object(o.createElement)(r.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(o.createElement)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"}));t.a=n},,function(e,t,c){"use strict";var o=c(0),r=(c(10),c(4)),n=c.n(r),a=c(30),s=c(9);c(144),t.a=Object(s.withInstanceId)(e=>{let{className:t,instanceId:c,label:r,onChange:s,options:l,screenReaderLabel:i,readOnly:u,value:b}=e;const d="wc-block-components-sort-select__select-"+c;return Object(o.createElement)("div",{className:n()("wc-block-sort-select","wc-block-components-sort-select",t)},Object(o.createElement)(a.a,{label:r,screenReaderLabel:i,wrapperElement:"label",wrapperProps:{className:"wc-block-sort-select__label wc-block-components-sort-select__label",htmlFor:d}}),Object(o.createElement)("select",{id:d,className:"wc-block-sort-select__select wc-block-components-sort-select__select",onChange:s,readOnly:u,value:b},l.map(e=>Object(o.createElement)("option",{key:e.key,value:e.key},e.label))))})},function(e,t,c){"use strict";var o=c(0),r=c(1),n=c(41),a=c(4),s=c.n(a),l=c(35);c(158);const i=e=>{let{currency:t,maxPrice:c,minPrice:a,priceClassName:i,priceStyle:u={}}=e;return Object(o.createElement)(o.Fragment,null,Object(o.createElement)("span",{className:"screen-reader-text"},Object(r.sprintf)(
|
15 |
/* translators: %1$s min price, %2$s max price */
|
16 |
+
Object(r.__)("Price between %1$s and %2$s","woo-gutenberg-products-block"),Object(l.formatPrice)(a),Object(l.formatPrice)(c))),Object(o.createElement)("span",{"aria-hidden":!0},Object(o.createElement)(n.a,{className:s()("wc-block-components-product-price__value",i),currency:t,value:a,style:u})," — ",Object(o.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:b}=e;return Object(o.createElement)(o.Fragment,null,Object(o.createElement)("span",{className:"screen-reader-text"},Object(r.__)("Previous price:","woo-gutenberg-products-block")),Object(o.createElement)(n.a,{currency:t,renderText:e=>Object(o.createElement)("del",{className:s()("wc-block-components-product-price__regular",c),style:a},e),value:l}),Object(o.createElement)("span",{className:"screen-reader-text"},Object(r.__)("Discounted price:","woo-gutenberg-products-block")),Object(o.createElement)(n.a,{currency:t,renderText:e=>Object(o.createElement)("ins",{className:s()("wc-block-components-product-price__value","is-discounted",i),style:u},e),value:b}))};t.a=e=>{let{align:t,className:c,currency:r,format:a="<price/>",maxPrice:l,minPrice:b,price:d,priceClassName:m,priceStyle:p,regularPrice:g,regularPriceClassName:O,regularPriceStyle:h}=e;const j=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 E=g&&d!==g;let _=Object(o.createElement)("span",{className:s()("wc-block-components-product-price__value",m)});return E?_=Object(o.createElement)(u,{currency:r,price:d,priceClassName:m,priceStyle:p,regularPrice:g,regularPriceClassName:O,regularPriceStyle:h}):void 0!==b&&void 0!==l?_=Object(o.createElement)(i,{currency:r,maxPrice:l,minPrice:b,priceClassName:m,priceStyle:p}):d&&(_=Object(o.createElement)(n.a,{className:s()("wc-block-components-product-price__value",m),currency:r,value:d,style:p})),Object(o.createElement)("span",{className:j},Object(o.createInterpolateElement)(a,{price:_}))}},,function(e,t,c){"use strict";c.d(t,"a",(function(){return n})),c.d(t,"b",(function(){return s}));var o=c(6);let r;!function(e){e.ADD_EVENT_CALLBACK="add_event_callback",e.REMOVE_EVENT_CALLBACK="remove_event_callback"}(r||(r={}));const n={addEventCallback:function(e,t){let c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10;return{id:Object(o.uniqueId)(),type:r.ADD_EVENT_CALLBACK,eventType:e,callback:t,priority:c}},removeEventCallback:(e,t)=>({id:t,type:r.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:o,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 r.ADD_EVENT_CALLBACK:return l.set(o,{priority:s,callback:n}),{...e,[c]:l};case r.REMOVE_EVENT_CALLBACK:return l.delete(o),{...e,[c]:l}}}},function(e,t,c){"use strict";c.d(t,"a",(function(){return r}));var o=c(8);function r(e,t){const c=Object(o.useRef)();return Object(o.useEffect)(()=>{c.current===e||t&&!t(e,c.current)||(c.current=e)},[e,t]),c.current}},,,,function(e,t,c){"use strict";c.d(t,"b",(function(){return l})),c.d(t,"c",(function(){return i})),c.d(t,"a",(function(){return u}));var o=c(7),r=c(70),n=c(64),a=c(194);const s=e=>Object(n.c)(e)?JSON.parse(e)||{}:Object(n.b)(e)?e:{},l=e=>{if(!Object(r.b)()||!Object(a.a)())return{style:{}};const t=Object(n.b)(e)?e:{},c=s(t.style);return Object(o.__experimentalGetSpacingClassesAndStyles)({...t,style:c})},i=e=>{const t=Object(n.b)(e)?e:{},c=s(t.style),o=Object(n.b)(c.typography)?c.typography:{};return{style:{fontSize:t.fontSize||o.fontSize,lineHeight:o.lineHeight,fontWeight:o.fontWeight,textTransform:o.textTransform,fontFamily:t.fontFamily}}},u=e=>{if(!Object(r.b)())return{className:"",style:{}};const t=Object(n.b)(e)?e:{},c=s(t.style);return Object(o.__experimentalUseColorProps)({...t,style:c})}},function(e,t,c){"use strict";c.d(t,"b",(function(){return l})),c.d(t,"a",(function(){return i}));var o=c(0),r=c(6),n=c(26),a=c.n(n);const s=Object(o.createContext)({getValidationError:()=>"",setValidationErrors:e=>{},clearValidationError:e=>{},clearAllValidationErrors:()=>{},hideValidationError:()=>{},showValidationError:()=>{},showAllValidationErrors:()=>{},hasValidationErrors:!1,getValidationErrorId:e=>e}),l=()=>Object(o.useContext)(s),i=e=>{let{children:t}=e;const[c,n]=Object(o.useState)({}),l=Object(o.useCallback)(e=>c[e],[c]),i=Object(o.useCallback)(e=>{const t=c[e];return!t||t.hidden?"":"validate-error-"+e},[c]),u=Object(o.useCallback)(e=>{n(t=>{if(!t[e])return t;const{[e]:c,...o}=t;return o})},[]),b=Object(o.useCallback)(()=>{n({})},[]),d=Object(o.useCallback)(e=>{e&&n(t=>(e=Object(r.pickBy)(e,(e,c)=>!("string"!=typeof e.message||t.hasOwnProperty(c)&&a()(t[c],e))),0===Object.values(e).length?t:{...t,...e}))},[]),m=Object(o.useCallback)((e,t)=>{n(c=>{if(!c.hasOwnProperty(e))return c;const o={...c[e],...t};return a()(c[e],o)?c:{...c,[e]:o}})},[]),p={getValidationError:l,setValidationErrors:d,clearValidationError:u,clearAllValidationErrors:b,hideValidationError:Object(o.useCallback)(e=>{m(e,{hidden:!0})},[m]),showValidationError:Object(o.useCallback)(e=>{m(e,{hidden:!1})},[m]),showAllValidationErrors:Object(o.useCallback)(()=>{n(e=>{const t={};return Object.keys(e).forEach(c=>{e[c].hidden&&(t[c]={...e[c],hidden:!1})}),0===Object.values(t).length?e:{...e,...t}})},[]),hasValidationErrors:Object.keys(c).length>0,getValidationErrorId:i};return Object(o.createElement)(s.Provider,{value:p},t)}},function(e,t,c){"use strict";c.d(t,"a",(function(){return l}));var o=c(16),r=c(13),n=c(0),a=c(39),s=c(94);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 b=Object(n.useRef)({results:[],isLoading:!0}),d=Object(a.a)(i),m=Object(a.a)(l),p=Object(s.a)(),g=Object(r.useSelect)(e=>{if(!u)return null;const r=e(o.COLLECTIONS_STORE_KEY),n=[t,c,d,m],a=r.getCollectionError(...n);return a&&p(a),{results:r.getCollection(...n),isLoading:!r.hasFinishedResolution("getCollection",n)}},[t,c,m,d,u]);return null!==g&&(b.current=g),b.current}},,,,,,,function(e,t,c){"use strict";var o=c(0),r=c(18);const n=Object(o.createElement)(r.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(o.createElement)("mask",{id:"external-mask",width:"24",height:"24",x:"0",y:"0",maskUnits:"userSpaceOnUse"},Object(o.createElement)("path",{fill:"#fff",d:"M6.3431 6.3431v1.994l7.8984.0072-8.6055 8.6054 1.4142 1.4143 8.6055-8.6055.0071 7.8984h1.994V6.3431H6.3431z"})),Object(o.createElement)("g",{mask:"url(#external-mask)"},Object(o.createElement)("path",{d:"M0 0h24v24H0z"})));t.a=n},,,,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return r}));var o=c(0);const r=Object(o.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 230 250",style:{width:"100%"}},Object(o.createElement)("title",null,"Grid Block Preview"),Object(o.createElement)("rect",{width:"65.374",height:"65.374",x:".162",y:".779",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(o.createElement)("rect",{width:"62.8",height:"15",x:"1.565",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(o.createElement)("rect",{width:"65.374",height:"65.374",x:".162",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(o.createElement)("rect",{width:"62.8",height:"15",x:"1.565",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(o.createElement)("rect",{width:"65.374",height:"65.374",x:"82.478",y:".779",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(o.createElement)("rect",{width:"62.8",height:"15",x:"83.882",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(o.createElement)("rect",{width:"65.374",height:"65.374",x:"82.478",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(o.createElement)("rect",{width:"62.8",height:"15",x:"83.882",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(o.createElement)("rect",{width:"65.374",height:"65.374",x:"164.788",y:".779",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(o.createElement)("rect",{width:"62.8",height:"15",x:"166.192",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(o.createElement)("rect",{width:"65.374",height:"65.374",x:"164.788",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(o.createElement)("rect",{width:"62.8",height:"15",x:"166.192",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.createElement)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(o.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 o=c(5),r=c.n(o),n=c(0),a=c(14),s=c(4),l=c.n(s);c(157),t.a=e=>{let{className:t="",disabled:c=!1,name:o,permalink:s="",rel:i,style:u,onClick:b,...d}=e;const m=l()("wc-block-components-product-name",t);if(c){const e=d;return Object(n.createElement)("span",r()({className:m},e,{dangerouslySetInnerHTML:{__html:Object(a.decodeEntities)(o)}}))}return Object(n.createElement)("a",r()({className:m,href:s,rel:i},d,{dangerouslySetInnerHTML:{__html:Object(a.decodeEntities)(o)},style:u}))}},function(e,t,c){"use strict";c.d(t,"b",(function(){return g})),c.d(t,"a",(function(){return O}));var o=c(0),r=(c(10),c(13)),n=c(60),a=c(49),s=c(5),l=c.n(s),i=c(4),u=c.n(i),b=c(487);c(159);const d=e=>{let{status:t="default"}=e;switch(t){case"error":return"woocommerce-error";case"success":return"woocommerce-message";case"info":case"warning":return"woocommerce-info"}return""};var m=e=>{let{className:t,notices:c,removeNotice:r}=e;const n=c.filter(e=>"snackbar"!==e.type);if(!n.length)return null;const a=u()(t,"wc-block-components-notices");return Object(o.createElement)("div",{className:a},n.map(e=>Object(o.createElement)(b.a,l()({key:"store-notice-"+e.id},e,{className:u()("wc-block-components-notices__notice",d(e)),onRemove:()=>{e.isDismissible&&r(e.id)}}),e.content)))};const p=Object(o.createContext)({notices:[],createNotice:(e,t,c)=>{},removeNotice:(e,t)=>{},setIsSuppressed:e=>{},context:"wc/core"}),g=()=>Object(o.useContext)(p),O=e=>{let{children:t,className:c="",createNoticeContainer:s=!0,context:l="wc/core"}=e;const{createNotice:i,removeNotice:u}=Object(r.useDispatch)("core/notices"),[b,d]=Object(o.useState)(!1),{dispatchStoreEvent:g}=Object(n.a)(),{isEditor:O}=Object(a.b)(),h=Object(o.useCallback)((function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};i(e,t,{...c,context:c.context||l}),g("store-notice-create",{status:e,content:t,options:c})}),[i,g,l]),j=Object(o.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:l;u(e,t)}),[u,l]),{notices:E}=Object(r.useSelect)(e=>({notices:e("core/notices").getNotices(l)}),[l]),_={notices:E,createNotice:h,removeNotice:j,context:l,setIsSuppressed:d},w=b?null:Object(o.createElement)(m,{className:c,notices:_.notices,removeNotice:_.removeNotice,isEditor:O});return Object(o.createElement)(p.Provider,{value:_},s&&w,t)}},function(e,t,c){"use strict";var o=c(0),r=c(101),n=c(76);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 o=s(e),r=o.split(" ").splice(0,t).join(" ");return Object(n.autop)(l(r,c))},u=function(e,t){let c=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"…";const r=s(e),a=r.slice(0,t);if(c)return Object(n.autop)(l(a,o));const i=a.match(/([\s]+)/g),u=i?i.length:0,b=r.slice(0,t+u);return Object(n.autop)(l(b,o))};t.a=e=>{let{source:t,maxLength:c=15,countType:s="words",className:l="",style:b={}}=e;const d=Object(o.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 o=Object(n.autop)(e),s=Object(r.count)(o,c);if(s<=t)return o;const l=a(o),b=Object(r.count)(l,c);return b<=t?l:"words"===c?i(l,t):u(l,t,"characters_including_spaces"===c)}(t,c,s),[t,c,s]);return Object(o.createElement)(o.RawHTML,{style:b,className:l},d)}},,,,,,,,,function(e,t){},,function(e,t){},,function(e,t){},,,,,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return o}));const o=e=>e.reduce((e,t)=>{let[c,o]=t;return e[c]=o,e},{})},,,,,,function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t,c){"use strict";var o=c(5),r=c.n(o),n=c(0),a=c(24),s=c(27),l=c(118),i=c(28);t.a=e=>t=>{let{selected:c,...o}=t;const[u,b]=Object(n.useState)(!0),[d,m]=Object(n.useState)(null),[p,g]=Object(n.useState)([]),O=a.o.productCount>100,h=async e=>{const t=await Object(i.a)(e);m(t),b(!1)},j=Object(n.useRef)(c);Object(n.useEffect)(()=>{Object(s.h)({selected:j.current}).then(e=>{g(e),b(!1)}).catch(h)},[j]);const E=Object(l.a)(e=>{Object(s.h)({selected:c,search:e}).then(e=>{g(e),b(!1)}).catch(h)},400),_=Object(n.useCallback)(e=>{b(!0),E(e)},[b,E]);return Object(n.createElement)(e,r()({},o,{selected:c,error:d,products:p,isLoading:u,onSearch:O?_:null}))}},function(e,t,c){"use strict";c.d(t,"a",(function(){return r}));var o=c(7);const r=()=>"function"==typeof o.__experimentalGetSpacingClassesAndStyles},function(e,t,c){"use strict";c.r(t);var o=c(0),r=(c(10),c(1)),n=c(4),a=c.n(n),s=c(30),l=c(29),i=c(54);c(301),t.default=Object(i.withProductDataContext)(e=>{let{className:t,align:c}=e;const{parentClassName:n}=Object(l.useInnerBlockLayoutContext)(),{product:i}=Object(l.useProductDataContext)();if(!i.id||!i.on_sale)return null;const u="string"==typeof c?"wc-block-components-product-sale-badge--align-"+c:"";return Object(o.createElement)("div",{className:a()("wc-block-components-product-sale-badge",t,u,{[n+"__product-onsale"]:n})},Object(o.createElement)(s.a,{label:Object(r.__)("Sale","woo-gutenberg-products-block"),screenReaderLabel:Object(r.__)("Product on sale","woo-gutenberg-products-block")}))})},function(e,t,c){"use strict";c.d(t,"a",(function(){return n}));var o=c(0),r=(c(10),c(114));c(162);const n=e=>{let{errorMessage:t="",propertyName:c="",elementId:n=""}=e;const{getValidationError:a,getValidationErrorId:s}=Object(r.b)();if(!t||"string"!=typeof t){const e=a(c)||{};if(!e.message||e.hidden)return null;t=e.message}return Object(o.createElement)("div",{className:"wc-block-components-validation-error",role:"alert"},Object(o.createElement)("p",{id:s(n)},t))}},,,,,,,,,,,,function(e,t,c){"use strict";var o=c(0),r=c(18);const n=Object(o.createElement)(r.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(o.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(o.createElement)("path",{d:"M11 17h2v-1h1c.55 0 1-.45 1-1v-3c0-.55-.45-1-1-1h-3v-1h4V8h-2V7h-2v1h-1c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h3v1H9v2h2v1zm9-13H4c-1.11 0-1.99.89-1.99 2L2 18c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V6c0-1.11-.89-2-2-2zm0 14H4V6h16v12z"}));t.a=n},function(e,t,c){"use strict";var o=c(0),r=c(18);const n=Object(o.createElement)(r.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(o.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(o.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){},function(e,t,c){"use strict";var o=c(70);let r={headingLevel:{type:"number",default:2},showProductLink:{type:"boolean",default:!0},productId:{type:"number",default:0}};Object(o.b)()&&(r={...r,align:{type:"string"},color:{type:"string"},customColor:{type:"string"},fontSize:{type:"string"},customFontSize:{type:"number"}}),t.a=r},function(e,t,c){"use strict";var o=c(0),r=c(4),n=c.n(r),a=c(29),s=c(70),l=c(54),i=c(129),u=c(60),b=(c(300),c(113));const d=e=>{let{children:t,headingLevel:c,elementType:r="h"+c,...n}=e;return Object(o.createElement)(r,n,t)};t.a=Object(l.withProductDataContext)(e=>{const{className:t,headingLevel:c=2,showProductLink:r=!0,align:l}=e,{parentClassName:m}=Object(a.useInnerBlockLayoutContext)(),{product:p}=Object(a.useProductDataContext)(),{dispatchStoreEvent:g}=Object(u.a)(),O=Object(b.a)(e),h=Object(b.b)(e),j=Object(b.c)(e);return p.id?Object(o.createElement)(d,{headingLevel:c,className:n()(t,O.className,"wc-block-components-product-title",{[m+"__product-title"]:m,["wc-block-components-product-title--align-"+l]:l&&Object(s.b)()}),style:Object(s.b)()?{...h.style,...j.style,...O.style}:{}},Object(o.createElement)(i.a,{disabled:!r,name:p.name,permalink:p.permalink,rel:r?"nofollow":"",onClick:()=>{g("product-view-link",{product:p})}})):Object(o.createElement)(d,{headingLevel:c,className:n()(t,O.className,"wc-block-components-product-title",{[m+"__product-title"]:m,["wc-block-components-product-title--align-"+l]:l&&Object(s.b)()}),style:Object(s.b)()?{...h.style,...j.style,...O.style}:{}})})},function(e,t,c){"use strict";c.d(t,"b",(function(){return a})),c.d(t,"a",(function(){return s}));const o=window.CustomEvent||null,r=(e,t)=>{let{bubbles:c=!1,cancelable:r=!1,element:n,detail:a={}}=t;if(!o)return;n||(n=document.body);const s=new o(e,{bubbles:c,cancelable:r,detail:a});n.dispatchEvent(s)};let n;const a=()=>{n&&clearTimeout(n),n=setTimeout(()=>{r("wc_fragment_refresh",{bubbles:!0,cancelable:!0})},50)},s=function(e,t){let c=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("function"!=typeof jQuery)return()=>{};const n=()=>{r(t,{bubbles:c,cancelable:o})};return jQuery(document).on(e,n),()=>jQuery(document).off(e,n)}},function(e,t,c){"use strict";c.d(t,"b",(function(){return a})),c.d(t,"c",(function(){return s})),c.d(t,"a",(function(){return l}));var o=c(2),r=c(99),n=c(15);const a=e=>{let{country:t="",state:c="",city:o="",postcode:r=""}=e;return{country:t.trim(),state:c.trim(),city:o.trim(),postcode:r?r.replace(" ","").toUpperCase():""}},s=e=>{let{email:t=""}=e;return Object(n.isEmail)(t)?t.trim():""},l=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:o=!1}=t;o&&((e,t)=>e in t)(c,e)&&(n[c]="")}),n}},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}}},function(e,t,c){"use strict";var o=c(5),r=c.n(o),n=c(0),a=(c(10),c(1)),s=c(4),l=c.n(s),i=c(2),u=c(29),b=c(54),d=c(60),m=c(195);c(302);const p=()=>Object(n.createElement)("img",{src:i.PLACEHOLDER_IMG_SRC,alt:"",width:500,height:500}),g=e=>{let{image:t,onLoad:c,loaded:o,showFullSize:a,fallbackAlt:s}=e;const{thumbnail:l,src:i,srcset:u,sizes:b,alt:d}=t||{},m={alt:d||s,onLoad:c,hidden:!o,src:l,...a&&{src:i,srcSet:u,sizes:b}};return Object(n.createElement)(n.Fragment,null,m.src&&Object(n.createElement)("img",r()({"data-testid":"product-image"},m)),!o&&Object(n.createElement)(p,null))};t.a=Object(b.withProductDataContext)(e=>{let{className:t,imageSizing:c="full-size",showProductLink:o=!0,showSaleBadge:r,saleBadgeAlign:s="right"}=e;const{parentClassName:i}=Object(u.useInnerBlockLayoutContext)(),{product:b}=Object(u.useProductDataContext)(),[O,h]=Object(n.useState)(!1),{dispatchStoreEvent:j}=Object(d.a)();if(!b.id)return Object(n.createElement)("div",{className:l()(t,"wc-block-components-product-image","wc-block-components-product-image--placeholder",{[i+"__product-image"]:i})},Object(n.createElement)(p,null));const E=!!b.images.length,_=E?b.images[0]:null,w=o?"a":n.Fragment,f=Object(a.sprintf)(
|
17 |
/* translators: %s is referring to the product name */
|
18 |
+
Object(a.__)("Link to %s","woo-gutenberg-products-block"),b.name),k={href:b.permalink,rel:"nofollow",...!E&&{"aria-label":f},onClick:()=>{j("product-view-link",{product:b})}};return Object(n.createElement)("div",{className:l()(t,"wc-block-components-product-image",{[i+"__product-image"]:i})},Object(n.createElement)(w,o&&k,!!r&&Object(n.createElement)(m.default,{align:s,product:b}),Object(n.createElement)(g,{fallbackAlt:b.name,image:_,onLoad:()=>h(!0),loaded:O,showFullSize:"cropped"!==c})))})},function(e,t,c){"use strict";c.d(t,"a",(function(){return r}));var o=c(108);const r=(e,t)=>function(c){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;const n=o.a.addEventCallback(e,c,r);return t(n),()=>{t(o.a.removeEventCallback(e,n.id))}}},function(e,t,c){"use strict";t.a={showFormElements:{type:"boolean",default:!1},productId:{type:"number",default:0}}},function(e,t,c){"use strict";var o=c(0),r=(c(10),c(4)),n=c.n(r),a=c(1),s=c(39),l=c(477);const i={PRISTINE:"pristine",IDLE:"idle",DISABLED:"disabled",PROCESSING:"processing",BEFORE_PROCESSING:"before_processing",AFTER_PROCESSING:"after_processing"},u={status:i.PRISTINE,hasError:!1,quantity:0,processingResponse:null,requestParams:{}},b={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:d,SET_IDLE:m,SET_DISABLED:p,SET_PROCESSING:g,SET_BEFORE_PROCESSING:O,SET_AFTER_PROCESSING:h,SET_PROCESSING_RESPONSE:j,SET_HAS_ERROR:E,SET_NO_ERROR:_,SET_QUANTITY:w,SET_REQUEST_PARAMS:f}=b,k=()=>({type:m}),v=function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const t=e?E:_;return{type:t}},{SET_PRISTINE:y,SET_IDLE:S,SET_DISABLED:C,SET_PROCESSING:x,SET_BEFORE_PROCESSING:N,SET_AFTER_PROCESSING:P,SET_PROCESSING_RESPONSE:T,SET_HAS_ERROR:R,SET_NO_ERROR:I,SET_QUANTITY:A,SET_REQUEST_PARAMS:B}=b,{PRISTINE:L,IDLE:V,DISABLED:z,PROCESSING:D,BEFORE_PROCESSING:F,AFTER_PROCESSING:M}=i,H=function(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:u,{quantity:c,type:o,data:r}=arguments.length>1?arguments[1]:void 0;switch(o){case y:e=u;break;case S:e=t.status!==V?{...t,status:V}:t;break;case C:e=t.status!==z?{...t,status:z}:t;break;case A:e=c!==t.quantity?{...t,quantity:c}:t;break;case B:e={...t,requestParams:{...t.requestParams,...r}};break;case T:e={...t,processingResponse:r};break;case x:e=t.status!==D?{...t,status:D,hasError:!1}:t,e=!1===e.hasError?e:{...e,hasError:!1};break;case N:e=t.status!==F?{...t,status:F,hasError:!1}:t;break;case P:e=t.status!==M?{...t,status:M}:t;break;case R:e=t.hasError?t:{...t,hasError:!0},e=t.status===D||t.status===F?{...e,status:V}:e;break;case I:e=t.hasError?{...t,hasError:!1}:t}return e!==t&&o!==y&&e.status===L&&(e.status=V),e};var G=c(108),q=c(254);const Q=e=>({onAddToCartAfterProcessingWithSuccess:Object(q.a)("add_to_cart_after_processing_with_success",e),onAddToCartProcessingWithError:Object(q.a)("add_to_cart_after_processing_with_error",e),onAddToCartBeforeProcessing:Object(q.a)("add_to_cart_before_processing",e)});var Y=c(257),U=c(114),$=c(47),W=c(44);const K=Object(o.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(o.useContext)(K),X=e=>{var t,c,r,n;let{children:b,product:m,showFormElements:E}=e;const[_,y]=Object(o.useReducer)(H,u),[S,C]=Object(o.useReducer)(G.b,{}),x=Object(s.a)(S),{addErrorNotice:N,removeNotices:P}=Object($.a)(),{setValidationErrors:T}=Object(U.b)(),{isSuccessResponse:R,isErrorResponse:I,isFailResponse:A}=Object(W.c)(),B=Object(o.useMemo)(()=>({onAddToCartAfterProcessingWithSuccess:Q(C).onAddToCartAfterProcessingWithSuccess,onAddToCartAfterProcessingWithError:Q(C).onAddToCartAfterProcessingWithError,onAddToCartBeforeProcessing:Q(C).onAddToCartBeforeProcessing}),[C]),L=Object(o.useMemo)(()=>({resetForm:()=>{y({type:d})},submitForm:()=>{y({type:O})},setQuantity:e=>{y((e=>({type:w,quantity:e}))(e))},setHasError:e=>{y(v(e))},setRequestParams:e=>{y((e=>({type:f,data:e}))(e))},setAfterProcessing:e=>{y({type:j,data:e}),y({type:h})}}),[]);Object(o.useEffect)(()=>{const e=_.status,t=!m.id||!Object(l.a)(m);e!==i.DISABLED||t?e!==i.DISABLED&&t&&y({type:p}):y(k())},[_.status,m,y]),Object(o.useEffect)(()=>{_.status===i.BEFORE_PROCESSING&&(P("error"),Object(Y.a)(x,"add_to_cart_before_processing",{}).then(e=>{!0!==e?(Array.isArray(e)&&e.forEach(e=>{let{errorMessage:t,validationErrors:c}=e;t&&N(t),c&&T(c)}),y(k())):y({type:g})}))},[_.status,T,N,P,y,x]),Object(o.useEffect)(()=>{if(_.status===i.AFTER_PROCESSING){const e={processingResponse:_.processingResponse},t=e=>{let t=!1;return e.forEach(e=>{const{message:c,messageContext:o}=e;(I(e)||A(e))&&c&&(t=!0,N(c,o?{context:o}:void 0))}),t};if(_.hasError)return void Object(Y.b)(x,"add_to_cart_after_processing_with_error",e).then(c=>{if(!t(c)){var o;const t=(null===(o=e.processingResponse)||void 0===o?void 0:o.message)||Object(a.__)("Something went wrong. Please contact us to get assistance.","woo-gutenberg-products-block");N(t,{id:"add-to-cart"})}y(k())});Object(Y.b)(x,"add_to_cart_after_processing_with_success",e).then(e=>{t(e)?y(v(!0)):y(k())})}},[_.status,_.hasError,_.processingResponse,L,N,I,A,R,x]);const V=Object(l.b)(m),z={product:m,productType:m.type||"simple",productIsPurchasable:Object(l.a)(m),productHasOptions:m.has_options||!1,supportsFormElements:V,showFormElements:E&&V,quantity:_.quantity||(null==m||null===(t=m.add_to_cart)||void 0===t?void 0:t.minimum)||1,minQuantity:(null==m||null===(c=m.add_to_cart)||void 0===c?void 0:c.minimum)||1,maxQuantity:(null==m||null===(r=m.add_to_cart)||void 0===r?void 0:r.maximum)||99,multipleOf:(null==m||null===(n=m.add_to_cart)||void 0===n?void 0:n.multiple_of)||1,requestParams:_.requestParams,isIdle:_.status===i.IDLE,isDisabled:_.status===i.DISABLED,isProcessing:_.status===i.PROCESSING,isBeforeProcessing:_.status===i.BEFORE_PROCESSING,isAfterProcessing:_.status===i.AFTER_PROCESSING,hasError:_.hasError,eventRegistration:B,dispatchActions:L};return Object(o.createElement)(K.Provider,{value:z},b)};var Z=c(11),ee=c.n(Z),te=c(14),ce=c(36),oe=()=>{const{dispatchActions:e,product:t,quantity:c,eventRegistration:r,hasError:n,isProcessing:s,requestParams:l}=J(),{hasValidationErrors:i,showAllValidationErrors:u}=Object(U.b)(),{addErrorNotice:b,removeNotice:d}=Object($.a)(),{receiveCart:m}=Object(ce.a)(),[p,g]=Object(o.useState)(!1),O=!n&&s,h=Object(o.useCallback)(()=>!i||(u(),{type:"error"}),[i,u]);Object(o.useEffect)(()=>{const e=r.onAddToCartBeforeProcessing(h,0);return()=>{e()}},[r,h]);const j=Object(o.useCallback)(()=>{g(!0),d("add-to-cart");const o={id:t.id||0,quantity:c,...l};ee()({path:"/wc/store/cart/add-item",method:"POST",data:o,cache:"no-store",parse:!1}).then(t=>{ee.a.setNonce(t.headers),t.json().then((function(c){t.ok?m(c):(c.body&&c.body.message?b(Object(te.decodeEntities)(c.body.message),{id:"add-to-cart"}):b(Object(a.__)("Something went wrong. Please contact us to get assistance.","woo-gutenberg-products-block"),{id:"add-to-cart"}),e.setHasError()),e.setAfterProcessing(c),g(!1)}))}).catch(t=>{t.json().then((function(t){var c;null!==(c=t.data)&&void 0!==c&&c.cart&&m(t.data.cart),e.setHasError(),e.setAfterProcessing(t),g(!1)}))})},[t,b,d,m,e,c,l]);return Object(o.useEffect)(()=>{O&&!p&&j()},[O,j,p]),null};const re=e=>{let{children:t,product:c,showFormElements:r}=e;return Object(o.createElement)(U.a,null,Object(o.createElement)(X,{product:c,showFormElements:r},t,Object(o.createElement)(oe,null)))};var ne=c(29),ae=c(6),se=c(54),le=(c(247),c(80)),ie=c(43),ue=c(311),be=c(60),de=c(359);const me=e=>{let{className:t,href:c,text:r,onClick:n}=e;return Object(o.createElement)(le.a,{className:t,href:c,onClick:n,rel:"nofollow"},r)},pe=e=>{let{className:t,quantityInCart:c,isProcessing:r,isDisabled:n,isDone:s,onClick:l}=e;return Object(o.createElement)(le.a,{className:t,disabled:n,showSpinner:r,onClick:l},s&&c>0?Object(a.sprintf)(
|
19 |
/* translators: %s number of products in cart. */
|
20 |
+
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(o.createElement)(ie.a,{srcElement:ue.a,alt:Object(a.__)("Done","woo-gutenberg-products-block")}))};var ge=()=>{const{showFormElements:e,productIsPurchasable:t,productHasOptions:c,product:r,productType:n,isDisabled:s,isProcessing:l,eventRegistration:i,hasError:u,dispatchActions:b}=J(),{parentName:d}=Object(ne.useInnerBlockLayoutContext)(),{dispatchStoreEvent:m}=Object(be.a)(),{cartQuantity:p}=Object(de.a)(r.id||0),[g,O]=Object(o.useState)(!1),h=r.add_to_cart||{url:"",text:""};return Object(o.useEffect)(()=>{const e=i.onAddToCartAfterProcessingWithSuccess(()=>(u||O(!0),!0),0);return()=>{e()}},[i,u]),(e||!c&&"simple"===n)&&t?Object(o.createElement)(pe,{className:"wc-block-components-product-add-to-cart-button",quantityInCart:p,isDisabled:s,isProcessing:l,isDone:g,onClick:()=>{b.submitForm(),m("cart-add-item",{product:r,listName:d})}}):Object(o.createElement)(me,{className:"wc-block-components-product-add-to-cart-button",href:h.url,text:h.text||Object(a.__)("View Product","woo-gutenberg-products-block"),onClick:()=>{m("product-view-link",{product:r,listName:d})}})},Oe=c(118),he=e=>{let{disabled:t,min:c,max:r,step:n=1,value:a,onChange:s}=e;const l=void 0!==r,i=Object(Oe.a)(e=>{let t=e;l&&(t=Math.min(t,Math.floor(r/n)*n)),t=Math.max(t,Math.ceil(c/n)*n),t=Math.floor(t/n)*n,t!==e&&s(t)},300);return Object(o.createElement)("input",{className:"wc-block-components-product-add-to-cart-quantity",type:"number",value:a,min:c,max:r,step:n,hidden:1===r,disabled:t,onChange:e=>{s(e.target.value),i(e.target.value)}})},je=e=>{let{reason:t=Object(a.__)("Sorry, this product cannot be purchased.","woo-gutenberg-products-block")}=e;return Object(o.createElement)("div",{className:"wc-block-components-product-add-to-cart-unavailable"},t)},Ee=()=>{const{product:e,quantity:t,minQuantity:c,maxQuantity:r,multipleOf:n,dispatchActions:s,isDisabled:l}=J();return e.id&&!e.is_purchasable?Object(o.createElement)(je,null):e.id&&!e.is_in_stock?Object(o.createElement)(je,{reason:Object(a.__)("This product is currently out of stock and cannot be purchased.","woo-gutenberg-products-block")}):Object(o.createElement)(o.Fragment,null,Object(o.createElement)(he,{value:t,min:c,max:r,step:n,disabled:l,onChange:s.setQuantity}),Object(o.createElement)(ge,null))},_e=(c(310),c(498)),we=c(8),fe=c(196);const ke={value:"",label:Object(a.__)("Select an option","woo-gutenberg-products-block")};var ve=e=>{let{attributeName:t,options:c=[],value:r="",onChange:s=(()=>{}),errorMessage:l=Object(a.__)("Please select a value.","woo-gutenberg-products-block")}=e;const{getValidationError:i,setValidationErrors:u,clearValidationError:b}=Object(U.b)(),d=t,m=i(d)||{};return Object(we.useEffect)(()=>{r?b(d):u({[d]:{message:l,hidden:!0}})},[r,d,l,b,u]),Object(we.useEffect)(()=>()=>{b(d)},[d,b]),Object(o.createElement)("div",{className:"wc-block-components-product-add-to-cart-attribute-picker__container"},Object(o.createElement)(_e.a,{label:Object(te.decodeEntities)(t),value:r||"",options:[ke,...c],onChange:s,required:!0,className:n()("wc-block-components-product-add-to-cart-attribute-picker__select",{"has-error":m.message&&!m.hidden})}),Object(o.createElement)(fe.a,{propertyName:d,elementId:d}))},ye=c(64);const Se=(e,t,c)=>{const o=Object.values(t).map(e=>{let{id:t}=e;return t});if(Object.values(c).every(e=>""===e))return o;const r=Object.keys(e);return o.filter(e=>r.every(o=>{const r=c[o]||"",n=t["id:"+e].attributes[o];return""===r||null===n||n===r}))};var Ce=e=>{let{attributes:t,variationAttributes:c,setRequestParams:r}=e;const n=Object(s.a)(t),a=Object(s.a)(c),[l,i]=Object(o.useState)(0),[u,b]=Object(o.useState)({}),[d,m]=Object(o.useState)(!1),p=Object(o.useMemo)(()=>((e,t,c)=>{const o={},r=Object.keys(e),n=Object.values(c).filter(Boolean).length>0;return r.forEach(r=>{const a=e[r],s={...c,[r]:null},l=n?Se(e,t,s):null,i=null!==l?l.map(e=>t["id:"+e].attributes[r]):null;o[r]=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return Object.values(e).map(e=>{let{name:c,slug:o}=e;return null===t||t.includes(null)||t.includes(o)?{value:o,label:Object(te.decodeEntities)(c)}:null}).filter(Boolean)}(a.terms,i)}),o})(n,a,u),[u,n,a]);return Object(o.useEffect)(()=>{if(!d){const e=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!Object(ye.b)(e))return{};const t=Object.keys(e),c={};return 0===t.length||t.forEach(t=>{const o=e[t],r=o.terms.filter(e=>e.default);var n;r.length>0&&(c[o.name]=null===(n=r[0])||void 0===n?void 0:n.slug)}),c}(t);e&&b({...e}),m(!0)}},[u,t,d]),Object(o.useEffect)(()=>{Object.values(u).filter(e=>""!==e).length===Object.keys(n).length?i(((e,t,c)=>Se(e,t,c)[0]||0)(n,a,u)):l>0&&i(0)},[u,l,n,a]),Object(o.useEffect)(()=>{r({id:l,variation:Object.keys(u).map(e=>({attribute:e,value:u[e]}))})},[r,l,u]),Object(o.createElement)("div",{className:"wc-block-components-product-add-to-cart-attribute-picker"},Object.keys(n).map(e=>Object(o.createElement)(ve,{key:e,attributeName:e,options:p[e],value:u[e],onChange:t=>{b({...u,[e]:t})}})))},xe=e=>{let{product:t,dispatchers:c}=e;const r=(e=>e?Object(ae.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:o}=e;t["id:"+c]={id:c,attributes:o.reduce((e,t)=>{let{name:c,value:o}=t;return e[c]=o,e},{})}}),t})(t.variations);return 0===Object.keys(r).length||0===n.length?null:Object(o.createElement)(Ce,{attributes:r,variationAttributes:n,setRequestParams:c.setRequestParams})},Ne=()=>{const{product:e,quantity:t,minQuantity:c,maxQuantity:r,multipleOf:n,dispatchActions:s,isDisabled:l}=J();return e.id&&!e.is_purchasable?Object(o.createElement)(je,null):e.id&&!e.is_in_stock?Object(o.createElement)(je,{reason:Object(a.__)("This product is currently out of stock and cannot be purchased.","woo-gutenberg-products-block")}):Object(o.createElement)(o.Fragment,null,Object(o.createElement)(xe,{product:e,dispatchers:s}),Object(o.createElement)(he,{value:t,min:c,max:r,step:n,disabled:l,onChange:s.setQuantity}),Object(o.createElement)(ge,null))},Pe=()=>Object(o.createElement)(ge,null),Te=c(489),Re=()=>Object(o.createElement)(Te.a,{className:"wc-block-components-product-add-to-cart-group-list"},"This is a placeholder for the grouped products form element."),Ie=()=>Object(o.createElement)(Re,null);const Ae=()=>{const{showFormElements:e,productType:t}=J();return e?"variable"===t?Object(o.createElement)(Ne,null):"grouped"===t?Object(o.createElement)(Ie,null):"external"===t?Object(o.createElement)(Pe,null):"simple"===t||"variation"===t?Object(o.createElement)(Ee,null):null:Object(o.createElement)(ge,null)};t.a=Object(se.withProductDataContext)(e=>{let{className:t,showFormElements:c}=e;const{product:r}=Object(ne.useProductDataContext)(),a=n()(t,"wc-block-components-product-add-to-cart",{"wc-block-components-product-add-to-cart--placeholder":Object(ae.isEmpty)(r)});return Object(o.createElement)(re,{product:r,showFormElements:c},Object(o.createElement)("div",{className:a},Object(o.createElement)(Ae,null)))})},function(e,t,c){"use strict";c.d(t,"a",(function(){return n})),c.d(t,"b",(function(){return a}));const o=(e,t)=>e[t]?Array.from(e[t].values()).sort((e,t)=>e.priority-t.priority):[];var r=c(44);const n=async(e,t,c)=>{const r=o(e,t),n=[];for(const e of r)try{const t=await Promise.resolve(e.callback(c));"object"==typeof t&&n.push(t)}catch(e){console.error(e)}return!n.length||n},a=async(e,t,c)=>{const n=[],a=o(e,t);for(const e of a)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.a)(t)||Object(r.b)(t))return n.push(t),n;n.push(t)}catch(e){return console.error(e),n.push({type:"error"}),n}return n}},,,,,function(e,t,c){"use strict";c.r(t);var o=c(0),r=(c(10),c(4)),n=c.n(r),a=c(106),s=c(35),l=c(29),i=c(7),u=c(70),b=c(54);t.default=Object(b.withProductDataContext)(e=>{var t,c;let{className:r,align:b,fontSize:d,customFontSize:m,saleFontSize:p,customSaleFontSize:g,color:O,customColor:h,saleColor:j,customSaleColor:E}=e;const{parentClassName:_}=Object(l.useInnerBlockLayoutContext)(),{product:w}=Object(l.useProductDataContext)(),f=n()(r,{[_+"__product-price"]:_});if(!w.id)return Object(o.createElement)(a.a,{align:b,className:f});const k=Object(i.getColorClassName)("color",O),v=Object(i.getFontSizeClass)(d),y=Object(i.getColorClassName)("color",j),S=Object(i.getFontSizeClass)(p),C=n()({"has-text-color":O||h,"has-font-size":d||m,[k]:k,[v]:v}),x=n()({"has-text-color":j||E,"has-font-size":p||g,[y]:y,[S]:S}),N={color:h,fontSize:m},P={color:E,fontSize:g},T=w.prices,R=Object(s.getCurrencyFromPriceResponse)(T),I=T.price!==T.regular_price,A=I?n()({[_+"__product-price__value"]:_,[x]:Object(u.b)()}):n()({[_+"__product-price__value"]:_,[C]:Object(u.b)()}),B=I?P:N;return Object(o.createElement)(a.a,{align:b,className:f,currency:R,price:T.price,priceClassName:A,priceStyle:Object(u.b)()?B:{},minPrice:null==T||null===(t=T.price_range)||void 0===t?void 0:t.min_amount,maxPrice:null==T||null===(c=T.price_range)||void 0===c?void 0:c.max_amount,regularPrice:T.regular_price,regularPriceClassName:n()({[_+"__product-price__regular"]:_,[C]:Object(u.b)()}),regularPriceStyle:Object(u.b)()?N:{}})})},function(e,t,c){"use strict";c.r(t);var o=c(0),r=(c(10),c(1)),n=c(4),a=c.n(n),s=c(29),l=c(54);c(303);t.default=Object(l.withProductDataContext)(e=>{let{className:t}=e;const{parentClassName:c}=Object(s.useInnerBlockLayoutContext)(),{product:n}=Object(s.useProductDataContext)(),l=(e=>{const t=parseFloat(e.average_rating);return Number.isFinite(t)&&t>0?t:0})(n);if(!l)return null;const i={width:l/5*100+"%"},u=Object(r.sprintf)(
|
21 |
/* translators: %f is referring to the average rating value */
|
22 |
+
Object(r.__)("Rated %f out of 5","woo-gutenberg-products-block"),l),b=(e=>{const t=parseInt(e.review_count,10);return Number.isFinite(t)&&t>0?t:0})(n),d={__html:Object(r.sprintf)(
|
23 |
+
/* translators: %1$s is referring to the average rating value, %2$s is referring to the number of ratings */
|
24 |
+
Object(r._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",b,"woo-gutenberg-products-block"),Object(r.sprintf)('<strong class="rating">%f</strong>',l),Object(r.sprintf)('<span class="rating">%d</span>',b))};return Object(o.createElement)("div",{className:a()(t,"wc-block-components-product-rating",{[c+"__product-rating"]:c})},Object(o.createElement)("div",{className:a()("wc-block-components-product-rating__stars",c+"__product-rating__stars"),role:"img","aria-label":u},Object(o.createElement)("span",{style:i,dangerouslySetInnerHTML:d})))})},function(e,t,c){"use strict";c.r(t);var o=c(5),r=c.n(o),n=c(0),a=(c(10),c(4)),s=c.n(a),l=c(1),i=c(60),u=c(359),b=c(14),d=c(29),m=c(54);c(304);const p=e=>{let{product:t}=e;const{id:c,permalink:o,add_to_cart:a,has_options:d,is_purchasable:m,is_in_stock:p}=t,{dispatchStoreEvent:g}=Object(i.a)(),{cartQuantity:O,addingToCart:h,addToCart:j}=Object(u.a)(c),E=Number.isFinite(O)&&O>0,_=!d&&m&&p,w=Object(b.decodeEntities)((null==a?void 0:a.description)||""),f=E?Object(l.sprintf)(
|
25 |
/* translators: %s number of products in cart. */
|
26 |
+
Object(l._n)("%d in cart","%d in cart",O,"woo-gutenberg-products-block"),O):Object(b.decodeEntities)((null==a?void 0:a.text)||Object(l.__)("Add to cart","woo-gutenberg-products-block")),k=_?"button":"a",v={};return _?v.onClick=()=>{j(),g("cart-add-item",{product:t})}:(v.href=o,v.rel="nofollow",v.onClick=()=>{g("product-view-link",{product:t})}),Object(n.createElement)(k,r()({"aria-label":w,className:s()("wp-block-button__link","add_to_cart_button","wc-block-components-product-button__button",{loading:h,added:E}),disabled:h},v),f)},g=()=>Object(n.createElement)("button",{className:s()("wp-block-button__link","add_to_cart_button","wc-block-components-product-button__button","wc-block-components-product-button__button--placeholder"),disabled:!0});t.default=Object(m.withProductDataContext)(e=>{let{className:t}=e;const{parentClassName:c}=Object(d.useInnerBlockLayoutContext)(),{product:o}=Object(d.useProductDataContext)();return Object(n.createElement)("div",{className:s()(t,"wp-block-button","wc-block-components-product-button",{[c+"__product-add-to-cart"]:c})},o.id?Object(n.createElement)(p,{product:o}):Object(n.createElement)(g,null))})},function(e,t,c){"use strict";c.r(t);var o=c(0),r=(c(10),c(4)),n=c.n(r),a=c(131),s=c(24),l=c(29),i=c(54),u=(c(305),c(113));t.default=Object(i.withProductDataContext)(e=>{const{className:t}=e,{parentClassName:c}=Object(l.useInnerBlockLayoutContext)(),{product:r}=Object(l.useProductDataContext)(),i=Object(u.a)(e),b=Object(u.c)(e);if(!r)return Object(o.createElement)("div",{className:n()(t,"wc-block-components-product-summary",{[c+"__product-summary"]:c})});const d=r.short_description?r.short_description:r.description;return d?Object(o.createElement)(a.a,{className:n()(t,i.className,"wc-block-components-product-summary",{[c+"__product-summary"]:c}),source:d,maxLength:150,countType:s.o.wordCountType||"words",style:{...i.style,...b.style}}):null})},function(e,t,c){"use strict";c.r(t);var o=c(0),r=c(1),n=(c(10),c(4)),a=c.n(n),s=c(29),l=c(54);c(306),t.default=Object(l.withProductDataContext)(e=>{let{className:t}=e;const{parentClassName:c}=Object(s.useInnerBlockLayoutContext)(),{product:n}=Object(s.useProductDataContext)(),l=n.sku;return l?Object(o.createElement)("div",{className:a()(t,"wc-block-components-product-sku",{[c+"__product-sku"]:c})},Object(r.__)("SKU:","woo-gutenberg-products-block")," ",Object(o.createElement)("strong",null,l)):null})},function(e,t,c){"use strict";c.r(t);var o=c(0),r=c(1),n=c(4),a=c.n(n),s=c(29),l=c(6),i=c(54);c(307),t.default=Object(i.withProductDataContext)(e=>{let{className:t}=e;const{parentClassName:c}=Object(s.useInnerBlockLayoutContext)(),{product:n}=Object(s.useProductDataContext)();return Object(l.isEmpty)(n.categories)?null:Object(o.createElement)("div",{className:a()(t,"wc-block-components-product-category-list",{[c+"__product-category-list"]:c})},Object(r.__)("Categories:","woo-gutenberg-products-block")," ",Object(o.createElement)("ul",null,Object.values(n.categories).map(e=>{let{name:t,link:c,slug:r}=e;return Object(o.createElement)("li",{key:"category-list-item-"+r},Object(o.createElement)("a",{href:c},t))})))})},function(e,t,c){"use strict";c.r(t);var o=c(0),r=c(1),n=(c(10),c(4)),a=c.n(n),s=c(29),l=c(6),i=c(54);c(308),t.default=Object(i.withProductDataContext)(e=>{let{className:t}=e;const{parentClassName:c}=Object(s.useInnerBlockLayoutContext)(),{product:n}=Object(s.useProductDataContext)();return Object(l.isEmpty)(n.tags)?null:Object(o.createElement)("div",{className:a()(t,"wc-block-components-product-tag-list",{[c+"__product-tag-list"]:c})},Object(r.__)("Tags:","woo-gutenberg-products-block")," ",Object(o.createElement)("ul",null,Object.values(n.tags).map(e=>{let{name:t,link:c,slug:r}=e;return Object(o.createElement)("li",{key:"tag-list-item-"+r},Object(o.createElement)("a",{href:c},t))})))})},function(e,t,c){"use strict";c.r(t);var o=c(0),r=c(1),n=(c(10),c(4)),a=c.n(n),s=c(29),l=c(54),i=(c(309),c(113));t.default=Object(l.withProductDataContext)(e=>{const{className:t}=e,{parentClassName:c}=Object(s.useInnerBlockLayoutContext)(),{product:n}=Object(s.useProductDataContext)(),l=Object(i.a)(e),u=Object(i.c)(e);if(!n.id||!n.is_purchasable)return null;const b=!!n.is_in_stock,d=n.low_stock_remaining,m=n.is_on_backorder;return Object(o.createElement)("div",{className:a()(t,l.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":!!d,"wc-block-components-product-stock-indicator--available-on-backorder":!!m}),style:{...l.style,...u.style}},d?(e=>Object(r.sprintf)(
|
27 |
/* translators: %d stock amount (number of items in stock for product) */
|
28 |
+
Object(r.__)("%d left in stock","woo-gutenberg-products-block"),e))(d):((e,t)=>t?Object(r.__)("Available on backorder","woo-gutenberg-products-block"):e?Object(r.__)("In Stock","woo-gutenberg-products-block"):Object(r.__)("Out of Stock","woo-gutenberg-products-block"))(b,m))})},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,c){"use strict";var o=c(0),r=c(18);const n=Object(o.createElement)(r.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(o.createElement)("path",{fill:"none",d:"M0 0h24v24H0z"}),Object(o.createElement)("path",{d:"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"}));t.a=n},,,,,,,,,,,,,,,,function(e,t,c){"use strict";var o=c(0),r=c(18);const n=Object(o.createElement)(r.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(o.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(o.createElement)("path",{d:"M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z"}));t.a=n},,,,,,,function(e,t,c){"use strict";var o=c(0),r=c(18);const n=Object(o.createElement)(r.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(o.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(o.createElement)("path",{d:"M21.41 11.58l-9-9C12.05 2.22 11.55 2 11 2H4c-1.1 0-2 .9-2 2v7c0 .55.22 1.05.59 1.42l9 9c.36.36.86.58 1.41.58s1.05-.22 1.41-.59l7-7c.37-.36.59-.86.59-1.41s-.23-1.06-.59-1.42zM13 20.01L4 11V4h7v-.01l9 9-7 7.02z"}),Object(o.createElement)("circle",{cx:"6.5",cy:"6.5",r:"1.5"}),Object(o.createElement)("path",{d:"M8.9 12.55c0 .57.23 1.07.6 1.45l3.5 3.5 3.5-3.5c.37-.37.6-.89.6-1.45 0-1.13-.92-2.05-2.05-2.05-.57 0-1.08.23-1.45.6l-.6.6-.6-.59c-.37-.38-.89-.61-1.45-.61-1.13 0-2.05.92-2.05 2.05z"}));t.a=n},,,,,,,,function(e,t,c){"use strict";var o=c(0),r=c(18);const n=Object(o.createElement)(r.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(o.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(o.createElement)("path",{d:"M22 9.24l-7.19-.62L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.63-7.03L22 9.24zM12 15.4l-3.76 2.27 1-4.28-3.32-2.88 4.38-.38L12 6.1l1.71 4.04 4.38.38-3.32 2.88 1 4.28L12 15.4z"}));t.a=n},function(e,t,c){"use strict";c.d(t,"a",(function(){return n}));var o=c(1),r=c(24);const n=[{id:1,name:"WordPress Pennant",variation:"",permalink:"https://example.org",sku:"wp-pennant",short_description:Object(o.__)("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:r.m+"previews/pennant.jpg",thumbnail:r.m+"previews/pennant.jpg",name:"pennant-1.jpg",alt:"WordPress Pennant",srcset:"",sizes:""}],average_rating:5,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(o.__)("Add to cart","woo-gutenberg-products-block"),description:Object(o.__)("Add to cart","woo-gutenberg-products-block")},has_options:!1,is_purchasable:!0,is_in_stock:!0,on_sale:!0}]},,,,,function(e,t,c){"use strict";var o=c(0),r=c(18);const n=Object(o.createElement)(r.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(o.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(o.createElement)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"}));t.a=n},,,,,,,function(e,t,c){e.exports=c(439)},function(e,t){},function(e,t){},function(e,t){},function(e,t,c){"use strict";c.d(t,"a",(function(){return u}));var o=c(0),r=c(13),n=c(16),a=c(14),s=c(36),l=c(47);const i=(e,t)=>{const c=e.find(e=>{let{id:c}=e;return c===t});return c?c.quantity:0},u=e=>{const{addItemToCart:t}=Object(r.useDispatch)(n.CART_STORE_KEY),{cartItems:c,cartIsLoading:u}=Object(s.a)(),{addErrorNotice:b,removeNotice:d}=Object(l.a)(),[m,p]=Object(o.useState)(!1),g=Object(o.useRef)(i(c,e));return Object(o.useEffect)(()=>{const t=i(c,e);t!==g.current&&(g.current=t)},[c,e]),{cartQuantity:Number.isFinite(g.current)?g.current:0,addingToCart:m,cartIsLoading:u,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=>{b(Object(a.decodeEntities)(e.message),{context:"wc/all-products",id:"add-to-cart",isDismissible:!0})}).finally(()=>{p(!1)})}}}},function(e,t,c){"use strict";var o=c(0),r=c(18);const n=Object(o.createElement)(r.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16"},Object(o.createElement)("g",{fill:"none",fillRule:"evenodd"},Object(o.createElement)("path",{stroke:"currentColor",strokeWidth:"1.5",d:"M2 .75h12c.69 0 1.25.56 1.25 1.25v12c0 .69-.56 1.25-1.25 1.25H2c-.69 0-1.25-.56-1.25-1.25V2C.75 1.31 1.31.75 2 .75z"}),Object(o.createElement)("path",{fill:"currentColor",d:"M12 6H4V4.75h8zM12 9H4V7.75h8zM10 12H4v-1.25h6z"})));t.a=n},function(e,t){},,,function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t,c){"use strict";c.r(t),c.d(t,"blockSettings",(function(){return zt}));var o=c(5),r=c.n(o),n=c(0),a=c(1),s=c(7),l=c(12),i=c(43),u=c(18),b=Object(n.createElement)(u.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(n.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(n.createElement)("path",{d:"M4 8h4V4H4v4zm6 12h4v-4h-4v4zm-6 0h4v-4H4v4zm0-6h4v-4H4v4zm6 0h4v-4h-4v4zm6-10v4h4V4h-4zm-6 4h4V4h-4v4zm6 6h4v-4h-4v4zm0 6h4v-4h-4v4z"})),d=c(70),m=c(4),p=c.n(m),g={category:"woocommerce-product-elements",keywords:[Object(a.__)("WooCommerce","woo-gutenberg-products-block")],icon:{src:Object(n.createElement)(i.a,{srcElement:b,className:"wc-block-editor-components-block-icon"})},supports:{html:!1},parent:Object(d.a)()?void 0:["@woocommerce/all-products","@woocommerce/single-product"],save:e=>{let{attributes:t}=e;return Object(n.createElement)("div",{className:p()("is-loading",t.className)})},deprecated:[{attributes:{},save:()=>null}]},O=c(248),h=c(3),j=c(9),E=c(90),_=c(249),w=c(102);c(357);var f=function(e){let{className:t="",...c}=e;const o=p()("wc-block-text-toolbar-button",t);return Object(n.createElement)(h.Button,r()({className:o},c))},k=c(29);c(356);var v=e=>t=>c=>{const o=Object(k.useProductDataContext)(),{attributes:r,setAttributes:l}=c,{productId:i}=r,[u,b]=Object(n.useState)(!i);return o.hasContext?Object(n.createElement)(t,c):Object(n.createElement)(n.Fragment,null,u?Object(n.createElement)(h.Placeholder,{icon:e.icon||"",label:e.label||"",className:"wc-atomic-blocks-product"},!!e.description&&Object(n.createElement)("div",null,e.description),Object(n.createElement)("div",{className:"wc-atomic-blocks-product__selection"},Object(n.createElement)(w.a,{selected:i||0,showVariations:!0,onChange:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];l({productId:e[0]?e[0].id:0})}}),Object(n.createElement)(h.Button,{isSecondary:!0,disabled:!i,onClick:()=>{b(!1)}},Object(a.__)("Done","woo-gutenberg-products-block")))):Object(n.createElement)(n.Fragment,null,Object(n.createElement)(s.BlockControls,null,Object(n.createElement)(h.ToolbarGroup,null,Object(n.createElement)(f,{onClick:()=>b(!0)},Object(a.__)("Switch product…","woo-gutenberg-products-block")))),Object(n.createElement)(t,c)))},y=Object(n.createElement)(u.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 3H7a2 2 0 00-2 2v16l7-3 7 3V5a2 2 0 00-2-2z"}));const S=Object(a.__)("Product Title","woo-gutenberg-products-block"),C=Object(n.createElement)(i.a,{srcElement:y,className:"wc-block-editor-components-block-icon"}),x=Object(a.__)("Display the title of a product.","woo-gutenberg-products-block");c(358);const N=e=>{let{attributes:t,setAttributes:c}=e;const o=Object(s.useBlockProps)(),{headingLevel:r,showProductLink:l,align:i}=t;return Object(n.createElement)("div",o,Object(n.createElement)(s.BlockControls,null,Object(n.createElement)(E.a,{isCollapsed:!0,minLevel:1,maxLevel:7,selectedLevel:r,onChange:e=>c({headingLevel:e})}),Object(d.b)()&&Object(n.createElement)(s.AlignmentToolbar,{value:i,onChange:e=>{c({align:e})}})),Object(n.createElement)(s.InspectorControls,null,Object(n.createElement)(h.PanelBody,{title:Object(a.__)("Content","woo-gutenberg-products-block")},Object(n.createElement)(h.ToggleControl,{label:Object(a.__)("Link to Product Page","woo-gutenberg-products-block"),help:Object(a.__)("Links the image to the single product listing.","woo-gutenberg-products-block"),checked:l,onChange:()=>c({showProductLink:!l})}))),Object(n.createElement)(h.Disabled,null,Object(n.createElement)(_.a,t)))};var P=Object(d.b)()?Object(j.compose)([v({icon:C,label:S,description:Object(a.__)("Choose a product to display its title.","woo-gutenberg-products-block")})])(N):N,T=c(194);const R={...g,apiVersion:2,title:S,description:x,icon:{src:C},attributes:O.a,edit:P,save:e=>{let{attributes:t}=e;return Object(n.createElement)("div",s.useBlockProps.save({className:p()("is-loading",t.className)}))},supports:{...g.supports,...Object(d.b)()&&{typography:{fontSize:!0,lineHeight:!0,__experimentalFontWeight:!0,__experimentalTextTransform:!0,__experimentalFontFamily:!0},color:{text:!0,background:!0,link:!1,gradients:!0,__experimentalSkipSerialization:!0},...Object(T.a)()&&{spacing:{margin:!0,__experimentalSkipSerialization:!0}},__experimentalSelector:".wc-block-components-product-title"}}};Object(l.registerBlockType)("woocommerce/product-title",R);var I=c(262),A=c(208);const B=Object(a.__)("Product Price","woo-gutenberg-products-block"),L=Object(n.createElement)(i.a,{srcElement:A.a,className:"wc-block-editor-components-block-icon"}),V=Object(a.__)("Display the price of a product.","woo-gutenberg-products-block"),z=e=>{let{fontSize:t,setFontSize:c,color:o,setColor:r,colorLabel:l}=e;return Object(n.createElement)(n.Fragment,null,Object(n.createElement)(s.FontSizePicker,{value:t.size,onChange:c}),Object(n.createElement)(h.BaseControl,{label:l},Object(n.createElement)(s.ColorPalette,{value:o.color,onChange:r,label:Object(a.__)("Color","woo-gutenberg-products-block")})))},D=e=>{let{fontSize:t,saleFontSize:c,setFontSize:o,setSaleFontSize:r,color:l,saleColor:i,setColor:u,setSaleColor:b,attributes:m,setAttributes:p}=e;const{align:g}=m;return Object(n.createElement)(n.Fragment,null,Object(d.b)()&&Object(n.createElement)(s.BlockControls,null,Object(n.createElement)(s.AlignmentToolbar,{value:g,onChange:e=>{p({align:e})}})),Object(n.createElement)(s.InspectorControls,null,Object(d.b)()&&Object(n.createElement)(n.Fragment,null,Object(n.createElement)(h.PanelBody,{title:Object(a.__)("Price","woo-gutenberg-products-block")},Object(n.createElement)(z,{color:l,setColor:u,fontSize:t,setFontSize:o,colorLabel:Object(a.__)("Color","woo-gutenberg-products-block")})),Object(n.createElement)(h.PanelBody,{title:Object(a.__)("Sale price","woo-gutenberg-products-block")},Object(n.createElement)(z,{color:i,setColor:b,fontSize:c,setFontSize:r,colorLabel:Object(a.__)("Color","woo-gutenberg-products-block")})))),Object(n.createElement)(I.default,m))};var F=Object(d.b)()?Object(j.compose)([Object(s.withFontSizes)("fontSize"),Object(s.withFontSizes)("saleFontSize"),Object(s.withFontSizes)("originalFontSize"),Object(s.withColors)("color",{textColor:"color"}),Object(s.withColors)("saleColor",{textColor:"saleColor"}),Object(s.withColors)("originalColor",{textColor:"originalColor"}),v({icon:L,label:B,description:Object(a.__)("Choose a product to display its price.","woo-gutenberg-products-block")})])(D):D;let M={productId:{type:"number",default:0}};Object(d.b)()&&(M={...M,align:{type:"string"},fontSize:{type:"string"},customFontSize:{type:"number"},saleFontSize:{type:"string"},customSaleFontSize:{type:"number"},color:{type:"string"},saleColor:{type:"string"},customColor:{type:"string"},customSaleColor:{type:"string"}});const H={title:B,description:V,icon:{src:L},attributes:M,edit:F};Object(l.registerBlockType)("woocommerce/product-price",{...g,...H});var G=c(252),q=c(55),Q=c(2),Y=c(253),U=Object(n.createElement)(u.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(n.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(n.createElement)("path",{d:"M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-4.86 8.86l-3 3.87L9 13.14 6 17h12l-3.86-5.14z"}));const $=Object(a.__)("Product Image","woo-gutenberg-products-block"),W=Object(n.createElement)(i.a,{srcElement:U,className:"wc-block-editor-components-block-icon"}),K=Object(a.__)("Display the main product image","woo-gutenberg-products-block");var J=v({icon:W,label:$,description:Object(a.__)("Choose a product to display its image.","woo-gutenberg-products-block")})(e=>{let{attributes:t,setAttributes:c}=e;const{showProductLink:o,imageSizing:r,showSaleBadge:l,saleBadgeAlign:i}=t;return Object(n.createElement)(n.Fragment,null,Object(n.createElement)(s.InspectorControls,null,Object(n.createElement)(h.PanelBody,{title:Object(a.__)("Content","woo-gutenberg-products-block")},Object(n.createElement)(h.ToggleControl,{label:Object(a.__)("Link to Product Page","woo-gutenberg-products-block"),help:Object(a.__)("Links the image to the single product listing.","woo-gutenberg-products-block"),checked:o,onChange:()=>c({showProductLink:!o})}),Object(n.createElement)(h.ToggleControl,{label:Object(a.__)("Show On-Sale Badge","woo-gutenberg-products-block"),help:Object(a.__)('Overlay a "sale" badge if the product is on-sale.',"woo-gutenberg-products-block"),checked:l,onChange:()=>c({showSaleBadge:!l})}),l&&Object(n.createElement)(q.a,{label:Object(a.__)("Sale Badge Alignment","woo-gutenberg-products-block"),value:i,options:[{label:Object(a.__)("Left","woo-gutenberg-products-block"),value:"left"},{label:Object(a.__)("Center","woo-gutenberg-products-block"),value:"center"},{label:Object(a.__)("Right","woo-gutenberg-products-block"),value:"right"}],onChange:e=>c({saleBadgeAlign:e})}),Object(n.createElement)(q.a,{label:Object(a.__)("Image Sizing","woo-gutenberg-products-block"),help:Object(n.createInterpolateElement)(Object(a.__)("Product image cropping can be modified in the <a>Customizer</a>.","woo-gutenberg-products-block"),{a:Object(n.createElement)("a",{href:Object(Q.getAdminLink)("customize.php")+"?autofocus[panel]=woocommerce&autofocus[section]=woocommerce_product_images",target:"_blank",rel:"noopener noreferrer"})}),value:r,options:[{label:Object(a.__)("Full Size","woo-gutenberg-products-block"),value:"full-size"},{label:Object(a.__)("Cropped","woo-gutenberg-products-block"),value:"cropped"}],onChange:e=>c({imageSizing:e})}))),Object(n.createElement)(h.Disabled,null,Object(n.createElement)(Y.a,t)))});const X={title:$,description:K,icon:{src:W},attributes:G.a,edit:J};Object(l.registerBlockType)("woocommerce/product-image",{...g,...X});var Z=c(263),ee=c(342);const te=Object(a.__)("Product Rating","woo-gutenberg-products-block"),ce=Object(n.createElement)(i.a,{srcElement:ee.a,className:"wc-block-editor-components-block-icon"}),oe={title:te,description:Object(a.__)("Display the average rating of a product.","woo-gutenberg-products-block"),icon:{src:ce},attributes:{productId:{type:"number",default:0}},edit:v({icon:ce,label:te,description:Object(a.__)("Choose a product to display its rating.","woo-gutenberg-products-block")})(e=>{let{attributes:t}=e;return Object(n.createElement)(Z.default,t)})};Object(l.registerBlockType)("woocommerce/product-rating",{...g,...oe});var re=c(264),ne=c(209);const ae=Object(a.__)("Add to Cart Button","woo-gutenberg-products-block"),se=Object(n.createElement)(i.a,{srcElement:ne.a,className:"wc-block-editor-components-block-icon"}),le={title:ae,description:Object(a.__)("Display a call to action button which either adds the product to the cart, or links to the product page.","woo-gutenberg-products-block"),icon:{src:se},attributes:{productId:{type:"number",default:0}},edit:v({icon:se,label:ae,description:Object(a.__)("Choose a product to display its add to cart button.","woo-gutenberg-products-block")})(e=>{let{attributes:t}=e;return Object(n.createElement)(h.Disabled,null,Object(n.createElement)(re.default,t))})};Object(l.registerBlockType)("woocommerce/product-button",{...g,...le});var ie=c(265),ue=c(360);const be=Object(a.__)("Product Summary","woo-gutenberg-products-block"),de=Object(n.createElement)(i.a,{srcElement:ue.a,className:"wc-block-editor-components-block-icon"}),me=Object(a.__)("Display a short description about a product.","woo-gutenberg-products-block");c(361);var pe=v({icon:de,label:be,description:Object(a.__)("Choose a product to display its short description.","woo-gutenberg-products-block")})(e=>{let{attributes:t}=e;const c=Object(s.useBlockProps)();return Object(n.createElement)("div",c,Object(n.createElement)(ie.default,t))});const ge={apiVersion:2,title:be,description:me,icon:{src:de},attributes:{productId:{type:"number",default:0}},supports:{...Object(d.b)()&&{color:{text:!0,background:!1,link:!1},typography:{fontSize:!0},__experimentalSelector:".wc-block-components-product-summary"}},edit:pe,save:e=>{let{attributes:t}=e;return Object(n.createElement)("div",s.useBlockProps.save({className:p()("is-loading",t.className)}))}};Object(l.registerBlockType)("woocommerce/product-summary",{...g,...ge});var Oe=c(195),he=c(334);const je=Object(a.__)("On-Sale Badge","woo-gutenberg-products-block"),Ee=Object(n.createElement)(i.a,{srcElement:he.a,className:"wc-block-editor-components-block-icon"}),_e={title:je,description:Object(a.__)("Displays an on-sale badge if the product is on-sale.","woo-gutenberg-products-block"),icon:{src:Ee},supports:{html:!1},attributes:{productId:{type:"number",default:0}},edit:v({icon:Ee,label:je,description:Object(a.__)("Choose a product to display its sale-badge.","woo-gutenberg-products-block")})(e=>{let{attributes:t}=e;return Object(n.createElement)(Oe.default,t)})};Object(l.registerBlockType)("woocommerce/product-sale-badge",{...g,..._e});var we=c(93),fe=c(266),ke=Object(n.createElement)(u.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(n.createElement)("path",{d:"M2 6h2v12H2V6m3 0h1v12H5V6m2 0h3v12H7V6m4 0h1v12h-1V6m3 0h2v12h-2V6m3 0h3v12h-3V6m4 0h1v12h-1V6z"}));const ve=Object(a.__)("Product SKU","woo-gutenberg-products-block"),ye=Object(n.createElement)(i.a,{srcElement:ke,className:"wc-block-editor-components-block-icon"}),Se={title:ve,description:Object(a.__)("Display the SKU of a product.","woo-gutenberg-products-block"),icon:{src:ye},attributes:{productId:{type:"number",default:0}},edit:v({icon:ye,label:ve,description:Object(a.__)("Choose a product to display its SKU.","woo-gutenberg-products-block")})(e=>{let{attributes:t}=e;return Object(n.createElement)(n.Fragment,null,Object(n.createElement)(we.a,null),Object(n.createElement)(fe.default,t))})};Object(d.c)("woocommerce/product-sku",{...g,...Se});var Ce=c(267),xe=c(327);const Ne=Object(a.__)("Product Category List","woo-gutenberg-products-block"),Pe=Object(n.createElement)(i.a,{srcElement:xe.a,className:"wc-block-editor-components-block-icon"}),Te=Object(a.__)("Display a list of categories belonging to a product.","woo-gutenberg-products-block");var Re=v({icon:Pe,label:Ne,description:Object(a.__)("Choose a product to display its categories.","woo-gutenberg-products-block")})(e=>{let{attributes:t}=e;return Object(n.createElement)(n.Fragment,null,Object(n.createElement)(we.a,null),Object(n.createElement)(h.Disabled,null,Object(n.createElement)(Ce.default,t)))});const Ie={...g,title:Ne,description:Te,icon:{src:Pe},attributes:{productId:{type:"number",default:0}},edit:Re};Object(d.c)("woocommerce/product-category-list",Ie);var Ae=c(268);const Be=Object(a.__)("Product Tag List","woo-gutenberg-products-block"),Le=Object(n.createElement)(i.a,{srcElement:he.a,className:"wc-block-editor-components-block-icon"}),Ve={title:Be,description:Object(a.__)("Display a list of tags belonging to a product.","woo-gutenberg-products-block"),icon:{src:Le},attributes:{productId:{type:"number",default:0}},edit:v({icon:Le,label:Be,description:Object(a.__)("Choose a product to display its tags.","woo-gutenberg-products-block")})(e=>{let{attributes:t}=e;return Object(n.createElement)(n.Fragment,null,Object(n.createElement)(we.a,null),Object(n.createElement)(h.Disabled,null,Object(n.createElement)(Ae.default,t)))})};Object(d.c)("woocommerce/product-tag-list",{...g,...Ve});var ze=c(269),De=Object(n.createElement)(u.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(n.createElement)("g",{fillRule:"evenodd"},Object(n.createElement)("path",{d:"M0 0h24v24H0z",fill:"none"}),Object(n.createElement)("path",{fillRule:"nonzero",d:"M20.5 5.2l-1.4-1.7C19 3.3 18.5 3 18 3H6c-.5 0-.9.2-1.2.5L3.5 5.3A2 2 0 003 6.5V19c0 1.1.9 2 2 2h14a2 2 0 002-2V6.5c0-.5-.2-1-.5-1.3zM6.2 5h11.6l.8 1H5.4l.8-1zM5 19V8h14v11H5z"})));const Fe=Object(a.__)("Product Stock Indicator","woo-gutenberg-products-block"),Me=Object(n.createElement)(i.a,{srcElement:De,className:"wc-block-editor-components-block-icon"}),He=Object(a.__)("Display product stock status.","woo-gutenberg-products-block");var Ge=v({icon:Me,label:Fe,description:Object(a.__)("Choose a product to display its stock.","woo-gutenberg-products-block")})(e=>{let{attributes:t}=e;const c=Object(s.useBlockProps)();return Object(n.createElement)("div",c,Object(n.createElement)(we.a,null),Object(n.createElement)(ze.default,t))});const qe={apiVersion:2,title:Fe,description:He,icon:{src:Me},attributes:{productId:{type:"number",default:0}},supports:{...Object(d.b)()&&{color:{text:!0,background:!1,link:!1},typography:{fontSize:!0},__experimentalSelector:".wc-block-components-product-stock-indicator"}},edit:Ge,save:e=>{let{attributes:t}=e;return Object(n.createElement)("div",s.useBlockProps.save({className:p()("is-loading",t.className)}))}};Object(d.c)("woocommerce/product-stock-indicator",{...g,...qe});var Qe=c(477),Ye=(c(247),c(256));const Ue=Object(a.__)("Add to Cart","woo-gutenberg-products-block"),$e=Object(n.createElement)(i.a,{srcElement:ne.a,className:"wc-block-editor-components-block-icon"}),We={title:Ue,description:Object(a.__)("Displays an add to cart button. Optionally displays other add to cart form elements.","woo-gutenberg-products-block"),icon:{src:$e},edit:v({icon:$e,label:Ue,description:Object(a.__)("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(k.useProductDataContext)(),{className:r,showFormElements:l}=t;return Object(n.createElement)("div",{className:p()(r,"wc-block-components-product-add-to-cart")},Object(n.createElement)(we.a,{productId:o.id}),Object(n.createElement)(s.InspectorControls,null,Object(n.createElement)(h.PanelBody,{title:Object(a.__)("Layout","woo-gutenberg-products-block")},Object(Qe.b)(o)?Object(n.createElement)(h.ToggleControl,{label:Object(a.__)("Display form elements","woo-gutenberg-products-block"),help:Object(a.__)("Depending on product type, allow customers to select a quantity, variations etc.","woo-gutenberg-products-block"),checked:l,onChange:()=>c({showFormElements:!l})}):Object(n.createElement)(h.Notice,{className:"wc-block-components-product-add-to-cart-notice",isDismissible:!1,status:"info"},Object(a.__)("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(n.createElement)(h.Disabled,null,Object(n.createElement)(Ye.a,t)))}),attributes:c(255).a};Object(d.c)("woocommerce/product-add-to-cart",{...g,...We});var Ke=c(25),Je=c.n(Ke),Xe=c(13),Ze=(c(10),c(59)),et=c(468),tt=c(343),ct=c(24);const ot=(e,t)=>{const{className:c,contentVisibility:o}=t;return p()(e,c,{"has-image":o&&o.image,"has-title":o&&o.title,"has-rating":o&&o.rating,"has-price":o&&o.price,"has-button":o&&o.button})};var rt=c(122);const nt=[["woocommerce/product-image",{imageSizing:"cropped"}],["woocommerce/product-title"],["woocommerce/product-price"],["woocommerce/product-rating"],["woocommerce/product-button"]],at=e=>e&&0!==e.length?e.map(e=>[e.name,{...e.attributes,product:void 0,children:e.innerBlocks.length>0?at(e.innerBlocks):[]}]):[];var st=c(8),lt=c(6),it=c(30);c(367);const ut=e=>{let{currentPage:t,displayFirstAndLastPages:c,displayNextAndPreviousArrows:o,pagesToDisplay:r,onPageChange:s,totalPages:l}=e,{minIndex:i,maxIndex:u}=((e,t,c)=>{if(c<=2)return{minIndex:null,maxIndex:null};const o=e-1,r=Math.max(Math.floor(t-o/2),2),n=Math.min(Math.ceil(t+(o-(t-r))),c-1);return{minIndex:Math.max(Math.floor(t-(o-(n-t))),2),maxIndex:n}})(r,t,l);const b=c&&Boolean(1!==i),d=c&&Boolean(u!==l),m=c&&Boolean(i>3),g=c&&Boolean(u<l-2);b&&3===i&&(i-=1),d&&u===l-2&&(u+=1);const O=[];if(i&&u)for(let e=i;e<=u;e++)O.push(e);return Object(n.createElement)("div",{className:"wc-block-pagination wc-block-components-pagination"},Object(n.createElement)(it.a,{screenReaderLabel:Object(a.__)("Navigate to another page","woo-gutenberg-products-block")}),o&&Object(n.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(n.createElement)(it.a,{label:"←",screenReaderLabel:Object(a.__)("Previous page","woo-gutenberg-products-block")})),b&&Object(n.createElement)("button",{className:p()("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(n.createElement)(it.a,{label:1,screenReaderLabel:Object(a.sprintf)(
|
29 |
/* translators: %d is the page number (1, 2, 3...). */
|
30 |
+
Object(a.__)("Page %d","woo-gutenberg-products-block"),1)})),m&&Object(n.createElement)("span",{className:"wc-block-pagination-ellipsis wc-block-components-pagination__ellipsis","aria-hidden":"true"},Object(a.__)("…","woo-gutenberg-products-block")),O.map(e=>Object(n.createElement)("button",{key:e,className:p()("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?null:()=>s(e),disabled:t===e},Object(n.createElement)(it.a,{label:e,screenReaderLabel:Object(a.sprintf)(
|
31 |
/* translators: %d is the page number (1, 2, 3...). */
|
32 |
+
Object(a.__)("Page %d","woo-gutenberg-products-block"),e)}))),g&&Object(n.createElement)("span",{className:"wc-block-pagination-ellipsis wc-block-components-pagination__ellipsis","aria-hidden":"true"},Object(a.__)("…","woo-gutenberg-products-block")),d&&Object(n.createElement)("button",{className:p()("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(n.createElement)(it.a,{label:l,screenReaderLabel:Object(a.sprintf)(
|
33 |
/* translators: %d is the page number (1, 2, 3...). */
|
34 |
+
Object(a.__)("Page %d","woo-gutenberg-products-block"),l)})),o&&Object(n.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(n.createElement)(it.a,{label:"→",screenReaderLabel:Object(a.__)("Next page","woo-gutenberg-products-block")})))};ut.defaultProps={displayFirstAndLastPages:!0,displayNextAndPreviousArrows:!0,pagesToDisplay:3};var bt=ut,dt=c(109),mt=c(73),pt=c(115),gt=c(16),Ot=c(39);var ht=c(60);c(368);const jt=e=>{if(!e)return;const t=e.getBoundingClientRect().bottom;t>=0&&t<=window.innerHeight||e.scrollIntoView()};var Et=c(46),_t=c(103),wt=()=>{const{parentClassName:e}=Object(k.useInnerBlockLayoutContext)();return Object(n.createElement)("div",{className:e+"__no-products"},Object(n.createElement)(i.a,{className:e+"__no-products-image",alt:"",srcElement:_t.a,size:100}),Object(n.createElement)("strong",{className:e+"__no-products-title"},Object(a.__)("No products","woo-gutenberg-products-block")),Object(n.createElement)("p",{className:e+"__no-products-description"},Object(a.__)("There are currently no products available to display.","woo-gutenberg-products-block")))},ft=c(348),kt=e=>{let{resetCallback:t=(()=>{})}=e;const{parentClassName:c}=Object(k.useInnerBlockLayoutContext)();return Object(n.createElement)("div",{className:c+"__no-products"},Object(n.createElement)(i.a,{className:c+"__no-products-image",alt:"",srcElement:ft.a,size:100}),Object(n.createElement)("strong",{className:c+"__no-products-title"},Object(a.__)("No products found","woo-gutenberg-products-block")),Object(n.createElement)("p",{className:c+"__no-products-description"},Object(a.__)("We were unable to find any results based on your search.","woo-gutenberg-products-block")),Object(n.createElement)("button",{onClick:t},Object(a.__)("Reset Search","woo-gutenberg-products-block")))},vt=c(105);c(366);var yt=e=>{let{onChange:t,readOnly:c,value:o}=e;return Object(n.createElement)(vt.a,{className:"wc-block-product-sort-select wc-block-components-product-sort-select",name:"orderby",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")}],readOnly:c,screenReaderLabel:Object(a.__)("Order products by","woo-gutenberg-products-block"),value:o})};const St=(e,t,c,o)=>{if(!c)return;const a=Object(et.a)(e);return c.map((c,s)=>{let[l,i={}]=c,u=[];i.children&&i.children.length>0&&(u=St(e,t,i.children,o));const b=a[l];if(!b)return null;const d=t.id||0,m=["layout",l,s,o,d];return Object(n.createElement)(n.Suspense,{key:m.join("_"),fallback:Object(n.createElement)("div",{className:"wc-block-placeholder"})},Object(n.createElement)(b,r()({},i,{children:u,product:t})))})};var Ct=Object(j.withInstanceId)(e=>{let{product:t,attributes:c,instanceId:o}=e;const{layoutConfig:r}=c,{parentClassName:a,parentName:s}=Object(k.useInnerBlockLayoutContext)(),l=0===Object.keys(t).length,i=p()(a+"__product","wc-block-layout",{"is-loading":l});return Object(n.createElement)("li",{className:i,"aria-hidden":l},St(s,t,r,o))});c(365);const xt=function(e){let{totalQuery:t,totalProducts:c}=e,{totalQuery:o}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return!Object(lt.isEqual)(t,o)&&Number.isFinite(c)};var Nt,Pt=(Nt=e=>{let{attributes:t,currentPage:c,onPageChange:o,onSortChange:r,sortValue:s,scrollToTop:l}=e;const[i,u]=Object(mt.b)("attributes",[]),[b,d]=Object(mt.b)("stock_status",[]),[m,g]=Object(mt.b)("min_price"),[O,h]=Object(mt.b)("max_price"),[j]=Object(mt.c)((e=>{let{sortValue:t,currentPage:c,attributes:o}=e;const{columns:r,rows:n}=o;return{...(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"}}})(t),catalog_visibility:"catalog",per_page:r*n,page:c}})({attributes:t,sortValue:s,currentPage:c})),{products:E,totalProducts:_,productsLoading:w}=(e=>{const t={namespace:"/wc/store",resourceName:"products"},{results:c,isLoading:o}=Object(pt.a)({...t,query:e}),{value:r}=((e,t)=>{const{namespace:c,resourceName:o,resourceValues:r=[],query:n={}}=t;if(!c||!o)throw new Error("The options object must have valid values for the namespace and the resource name properties.");const a=Object(Ot.a)(n),s=Object(Ot.a)(r),{value:l,isLoading:i=!0}=Object(Xe.useSelect)(e=>{const t=e(gt.COLLECTIONS_STORE_KEY),r=["x-wp-total",c,o,a,s];return{value:t.getCollectionHeader(...r),isLoading:t.hasFinishedResolution("getCollectionHeader",r)}},["x-wp-total",c,o,s,a]);return{value:l,isLoading:i}})(0,{...t,query:e});return{products:c,totalProducts:parseInt(r,10),productsLoading:o}})(j),{parentClassName:f,parentName:v}=Object(k.useInnerBlockLayoutContext)(),y=(e=>{const{order:t,orderby:c,page:o,per_page:r,...n}=e;return n||{}})(j),{dispatchStoreEvent:S}=Object(ht.a)(),C=Object(dt.a)({totalQuery:y,totalProducts:_},xt);Object(n.useEffect)(()=>{S("product-list-render",{products:E,listName:v})},[E,v,S]),Object(n.useEffect)(()=>{Object(lt.isEqual)(y,null==C?void 0:C.totalQuery)||(o(1),null!=C&&C.totalQuery&&(e=>{Number.isFinite(e)&&(0===e?Object(Et.speak)(Object(a.__)("No products found","woo-gutenberg-products-block")):Object(Et.speak)(Object(a.sprintf)(
|
35 |
/* translators: %s is an integer higher than 0 (1, 2, 3...) */
|
36 |
+
Object(a._n)("%d product found","%d products found",e,"woo-gutenberg-products-block"),e)))})(_))},[null==C?void 0:C.totalQuery,_,o,y]);const{contentVisibility:x}=t,N=t.columns*t.rows,P=!Number.isFinite(_)&&Number.isFinite(null==C?void 0:C.totalProducts)&&Object(lt.isEqual)(y,null==C?void 0:C.totalQuery)?Math.ceil(C.totalProducts/N):Math.ceil(_/N),T=E.length?E:Array.from({length:N}),R=0!==E.length||w,I=i.length>0||b.length>0||Number.isFinite(m)||Number.isFinite(O);return Object(n.createElement)("div",{className:(()=>{const{columns:e,rows:c,alignButtons:o,align:r}=t,n=void 0!==r?"align"+r:"";return p()(f,n,"has-"+e+"-columns",{"has-multiple-rows":c>1,"has-aligned-buttons":o})})()},x.orderBy&&R&&Object(n.createElement)(yt,{onChange:r,value:s}),!R&&I&&Object(n.createElement)(kt,{resetCallback:()=>{u([]),d([]),g(null),h(null)}}),!R&&!I&&Object(n.createElement)(wt,null),R&&Object(n.createElement)("ul",{className:f+"__products"},T.map((function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},c=arguments.length>1?arguments[1]:void 0;return Object(n.createElement)(Ct,{key:e.id||c,attributes:t,product:e})}))),P>1&&Object(n.createElement)(bt,{currentPage:c,onPageChange:e=>{l({focusableSelector:"a, button"}),o(e)},totalPages:P}))},e=>{const t=Object(n.useRef)(null);return Object(n.createElement)(n.Fragment,null,Object(n.createElement)("div",{className:"with-scroll-to-top__scroll-point",ref:t,"aria-hidden":!0}),Object(n.createElement)(Nt,r()({},e,{scrollToTop:e=>{null!==t.current&&((e,t)=>{const{focusableSelector:c}=t||{};window&&Number.isFinite(window.innerHeight)&&(c?((e,t)=>{var c;const o=(null===(c=e.parentElement)||void 0===c?void 0:c.querySelectorAll(t))||[];if(o.length){const e=o[0];jt(e),null==e||e.focus()}else jt(e)})(e,c):jt(e))})(t.current,e)}})))}),Tt=e=>{let{attributes:t}=e;const[c,o]=Object(n.useState)(1),[r,a]=Object(n.useState)(t.orderby);return Object(n.useEffect)(()=>{a(t.orderby)},[t.orderby]),Object(n.createElement)(Pt,{attributes:t,currentPage:c,onPageChange:e=>{o(e)},onSortChange:e=>{const t=e.target.value;a(t),o(1)},sortValue:r})},Rt=c(128);class It extends st.Component{render(){const{attributes:e,urlParameterSuffix:t}=this.props;return e.isPreview?Rt.a:Object(n.createElement)(k.InnerBlockLayoutContextProvider,{parentName:"woocommerce/all-products",parentClassName:"wc-block-grid"},Object(n.createElement)(Tt,{attributes:e,urlParameterSuffix:t}))}}var At=It;c(364);class Bt extends n.Component{constructor(){super(...arguments),Je()(this,"state",{isEditing:!1,innerBlocks:[]}),Je()(this,"blockMap",Object(et.a)("woocommerce/all-products")),Je()(this,"componentDidMount",()=>{const{block:e}=this.props;this.setState({innerBlocks:e.innerBlocks})}),Je()(this,"getTitle",()=>Object(a.__)("All Products","woo-gutenberg-products-block")),Je()(this,"getIcon",()=>Object(n.createElement)(i.a,{srcElement:b})),Je()(this,"togglePreview",()=>{const{debouncedSpeak:e}=this.props;this.setState({isEditing:!this.state.isEditing}),this.state.isEditing||e(Object(a.__)("Showing All Products block preview.","woo-gutenberg-products-block"))}),Je()(this,"getInspectorControls",()=>{const{attributes:e,setAttributes:t}=this.props,{columns:c,rows:o,alignButtons:r}=e;return Object(n.createElement)(s.InspectorControls,{key:"inspector"},Object(n.createElement)(h.PanelBody,{title:Object(a.__)("Layout Settings","woo-gutenberg-products-block"),initialOpen:!0},Object(n.createElement)(Ze.a,{columns:c,rows:o,alignButtons:r,setAttributes:t,minColumns:Object(Q.getSetting)("min_columns",1),maxColumns:Object(Q.getSetting)("max_columns",6),minRows:Object(Q.getSetting)("min_rows",1),maxRows:Object(Q.getSetting)("max_rows",6)})),Object(n.createElement)(h.PanelBody,{title:Object(a.__)("Content Settings","woo-gutenberg-products-block")},((e,t)=>{const{contentVisibility:c}=e;return Object(n.createElement)(h.ToggleControl,{label:Object(a.__)("Show Sorting Dropdown","woo-gutenberg-products-block"),checked:c.orderBy,onChange:()=>t({contentVisibility:{...c,orderBy:!c.orderBy}})})})(e,t),((e,t)=>Object(n.createElement)(h.SelectControl,{label:Object(a.__)("Order Products By","woo-gutenberg-products-block"),value:e.orderby,options:[{label:Object(a.__)("Default sorting (menu order)","woo-gutenberg-products-block"),value:"menu_order"},{label:Object(a.__)("Popularity","woo-gutenberg-products-block"),value:"popularity"},{label:Object(a.__)("Average rating","woo-gutenberg-products-block"),value:"rating"},{label:Object(a.__)("Latest","woo-gutenberg-products-block"),value:"date"},{label:Object(a.__)("Price: low to high","woo-gutenberg-products-block"),value:"price"},{label:Object(a.__)("Price: high to low","woo-gutenberg-products-block"),value:"price-desc"}],onChange:e=>t({orderby:e})}))(e,t)))}),Je()(this,"getBlockControls",()=>{const{isEditing:e}=this.state;return Object(n.createElement)(s.BlockControls,null,Object(n.createElement)(h.ToolbarGroup,{controls:[{icon:"edit",title:Object(a.__)("Edit inner product layout","woo-gutenberg-products-block"),onClick:()=>this.togglePreview(),isActive:e}]}))}),Je()(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(n.createElement)(h.Placeholder,{icon:this.getIcon(),label:this.getTitle()},Object(a.__)("Display all products from your store as a grid.","woo-gutenberg-products-block"),Object(n.createElement)("div",{className:"wc-block-all-products-grid-item-template"},Object(n.createElement)(h.Tip,null,Object(a.__)("Edit the blocks inside the preview below to change the content displayed for each product within the product grid.","woo-gutenberg-products-block")),Object(n.createElement)(k.InnerBlockLayoutContextProvider,{parentName:"woocommerce/all-products",parentClassName:"wc-block-grid"},Object(n.createElement)("div",{className:"wc-block-grid wc-block-layout has-1-columns"},Object(n.createElement)("ul",{className:"wc-block-grid__products"},Object(n.createElement)("li",{className:"wc-block-grid__product"},Object(n.createElement)(k.ProductDataContextProvider,{product:tt.a[0]},Object(n.createElement)(s.InnerBlocks,e)))))),Object(n.createElement)("div",{className:"wc-block-all-products__actions"},Object(n.createElement)(h.Button,{className:"wc-block-all-products__done-button",isPrimary:!0,onClick:()=>{const{block:e,setAttributes:t}=this.props;t({layoutConfig:at(e.innerBlocks)}),this.setState({innerBlocks:e.innerBlocks}),this.togglePreview()}},Object(a.__)("Done","woo-gutenberg-products-block")),Object(n.createElement)(h.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(a.__)("Cancel","woo-gutenberg-products-block")),Object(n.createElement)(h.Button,{className:"wc-block-all-products__reset-button",icon:Object(n.createElement)(i.a,{srcElement:b}),label:Object(a.__)("Reset layout to default","woo-gutenberg-products-block"),onClick:()=>{const{block:e,replaceInnerBlocks:t}=this.props,c=[];nt.map(e=>{let[t,o]=e;return c.push(Object(l.createBlock)(t,o)),!0}),t(e.clientId,c,!1),this.setState({innerBlocks:e.innerBlocks})}},Object(a.__)("Reset Layout","woo-gutenberg-products-block")))))}),Je()(this,"renderViewMode",()=>{const{attributes:e}=this.props,{layoutConfig:t}=e,c=t&&0!==t.length,o=this.getTitle(),r=this.getIcon();return c?Object(n.createElement)(h.Disabled,null,Object(n.createElement)(At,{attributes:e})):((e,t)=>Object(n.createElement)(h.Placeholder,{className:"wc-block-products",icon:t,label:e},Object(a.__)("The content for this block is hidden due to block settings.","woo-gutenberg-products-block")))(o,r)}),Je()(this,"render",()=>{const{attributes:e}=this.props,{isEditing:t}=this.state,c=this.getTitle(),o=this.getIcon();return 0===ct.o.productCount?((e,t)=>Object(n.createElement)(h.Placeholder,{className:"wc-block-products",icon:t,label:e},Object(n.createElement)("p",null,Object(a.__)("You haven't published any products to list here yet.","woo-gutenberg-products-block")),Object(n.createElement)(h.Button,{className:"wc-block-products__add-product-button",isSecondary:!0,href:Q.ADMIN_URL+"post-new.php?post_type=product"},Object(a.__)("Add new product","woo-gutenberg-products-block")+" ",Object(n.createElement)(i.a,{srcElement:rt.a})),Object(n.createElement)(h.Button,{className:"wc-block-products__read_more_button",isTertiary:!0,href:"https://docs.woocommerce.com/document/managing-products/"},Object(a.__)("Learn more","woo-gutenberg-products-block"))))(c,o):Object(n.createElement)("div",{className:ot("wc-block-all-products",e)},this.getBlockControls(),this.getInspectorControls(),t?this.renderEditMode():this.renderViewMode())})}}var Lt=Object(j.compose)(h.withSpokenMessages,Object(Xe.withSelect)((e,t)=>{let{clientId:c}=t;const{getBlock:o}=e("core/block-editor");return{block:o(c)}}),Object(Xe.withDispatch)(e=>{const{replaceInnerBlocks:t}=e("core/block-editor");return{replaceInnerBlocks:t}}))(Bt);const Vt={columns:Object(Q.getSetting)("default_columns",3),rows:Object(Q.getSetting)("default_rows",3),alignButtons:!1,contentVisibility:{orderBy:!0},orderby:"date",layoutConfig:nt,isPreview:!1},zt={title:Object(a.__)("All Products","woo-gutenberg-products-block"),icon:{src:Object(n.createElement)(i.a,{srcElement:b,className:"wc-block-editor-components-block-icon"})},category:"woocommerce",keywords:[Object(a.__)("WooCommerce","woo-gutenberg-products-block")],description:Object(a.__)("Display products from your store in a grid layout.","woo-gutenberg-products-block"),supports:{align:["wide","full"],html:!1,multiple:!1},example:{attributes:{isPreview:!0}},attributes:{columns:{type:"number"},rows:{type:"number"},alignButtons:{type:"boolean"},contentVisibility:{type:"object"},orderby:{type:"string"},layoutConfig:{type:"array"},isPreview:{type:"boolean",default:!1}},defaults:Vt,edit:e=>Object(n.createElement)(Lt,e),save(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(n.createElement)("div",r()({className:ot("wc-block-all-products",t)},o),Object(n.createElement)(s.InnerBlocks.Content,null))}};Object(l.registerBlockType)("woocommerce/all-products",{...zt,deprecated:[{attributes:Object.assign({},zt.attributes,{rows:{type:"number",default:1}}),save(e){let{attributes:t}=e;const c={"data-attributes":JSON.stringify(t)};return Object(n.createElement)("div",r()({className:ot("wc-block-all-products",t)},c),Object(n.createElement)(s.InnerBlocks.Content,null))}}]})},,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return a}));var o=c(38),r=c(0),n=c(24);c.p=n.l,Object(o.registerBlockComponent)({blockName:"woocommerce/product-price",component:Object(r.lazy)(()=>Promise.all([c.e(0),c.e(13)]).then(c.bind(null,262)))}),Object(o.registerBlockComponent)({blockName:"woocommerce/product-image",component:Object(r.lazy)(()=>Promise.all([c.e(1),c.e(2),c.e(5),c.e(12)]).then(c.bind(null,501)))}),Object(o.registerBlockComponent)({blockName:"woocommerce/product-title",component:Object(r.lazy)(()=>Promise.all([c.e(1),c.e(2),c.e(3),c.e(19)]).then(c.bind(null,502)))}),Object(o.registerBlockComponent)({blockName:"woocommerce/product-rating",component:Object(r.lazy)(()=>c.e(14).then(c.bind(null,263)))}),Object(o.registerBlockComponent)({blockName:"woocommerce/product-button",component:Object(r.lazy)(()=>Promise.all([c.e(0),c.e(1),c.e(2),c.e(4),c.e(10)]).then(c.bind(null,264)))}),Object(o.registerBlockComponent)({blockName:"woocommerce/product-summary",component:Object(r.lazy)(()=>Promise.all([c.e(1),c.e(3),c.e(17)]).then(c.bind(null,265)))}),Object(o.registerBlockComponent)({blockName:"woocommerce/product-sale-badge",component:Object(r.lazy)(()=>c.e(5).then(c.bind(null,195)))}),Object(o.registerBlockComponent)({blockName:"woocommerce/product-sku",component:Object(r.lazy)(()=>c.e(15).then(c.bind(null,266)))}),Object(o.registerBlockComponent)({blockName:"woocommerce/product-category-list",component:Object(r.lazy)(()=>c.e(11).then(c.bind(null,267)))}),Object(o.registerBlockComponent)({blockName:"woocommerce/product-tag-list",component:Object(r.lazy)(()=>c.e(18).then(c.bind(null,268)))}),Object(o.registerBlockComponent)({blockName:"woocommerce/product-stock-indicator",component:Object(r.lazy)(()=>Promise.all([c.e(1),c.e(3),c.e(16)]).then(c.bind(null,269)))}),Object(o.registerBlockComponent)({blockName:"woocommerce/product-add-to-cart",component:Object(r.lazy)(()=>Promise.all([c.e(0),c.e(1),c.e(2),c.e(4),c.e(9)]).then(c.bind(null,503)))});const a=e=>Object(o.getRegisteredBlockComponents)(e)},,,,,,,,,function(e,t,c){"use strict";c.d(t,"a",(function(){return o})),c.d(t,"b",(function(){return r}));const o=e=>e.is_purchasable||!1,r=e=>["simple","variable"].includes(e.type||"simple")}]);
|
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-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-i18n', 'wp-is-shallow-equal', 'wp-polyfill', 'wp-primitives'), 'version' => '62f29d808552d29f8dddb76f857db8fd');
|
build/all-reviews.js
CHANGED
@@ -1,7 +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,s=t[0],i=t[1],l=t[2],u=0,b=[];u<s.length;u++)a=s[u],Object.prototype.hasOwnProperty.call(n,a)&&n[a]&&b.push(n[a][0]),n[a]=0;for(o in i)Object.prototype.hasOwnProperty.call(i,o)&&(e[o]=i[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,s=1;s<r.length;s++){var i=r[s];0!==n[i]&&(o=!1)}o&&(c.splice(t--,1),e=a(a.s=r[0]))}return e}var o={},n={
|
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}]}}},12:function(e,t){e.exports=window.wp.blocks},
|
6 |
/* translators: %f is referring to the average rating value */
|
7 |
-
Object(n.__)("Rated %f out of 5","woo-gutenberg-products-block"),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},c)))}(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),s&&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)(C,{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(165);var P=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,s=c&&t.showReviewRating,i={...t,showReviewImage:a,showReviewRating:s};return Object(o.createElement)("ul",{className:"wc-block-review-list wc-block-components-review-list"},0===r.length?Object(o.createElement)(S,{attributes:i}):r.map((e,t)=>Object(o.createElement)(S,{key:e.id||t,attributes:i,review:e})))},N=r(5),T=r.n(N),L=r(26),x=r.n(L),A=r(53),M=r(28);class I extends i.Component{render(){const{attributes:e,error:t,isLoading:r,noReviewsPlaceholder:c,reviews:s,totalReviews:i}=this.props;if(t)return Object(o.createElement)(d.a,{className:"wc-block-featured-product-error",error:t,isLoading:r});if(0===s.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)(P,{attributes:e,reviews:s}),e.showLoadMore&&i>s.length&&Object(o.createElement)(w,{screenReaderLabel:Object(n.__)("Load more reviews","woo-gutenberg-products-block")}))}}var D=(e=>{class t extends i.Component{constructor(){super(...arguments),O()(this,"isPreview",!!this.props.attributes.previewReviews),O()(this,"delayedAppendReviews",this.props.delayFunction(this.appendReviews)),O()(this,"isMounted",!1),O()(this,"state",{error:null,loading:!0,reviews:this.isPreview?this.props.attributes.previewReviews:[],totalReviews:this.isPreview?this.props.attributes.previewReviews.length:0}),O()(this,"setError",async e=>{if(!this.isMounted)return;const{onReviewsLoadError:t}=this.props,r=await Object(M.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||!x()(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};return t&&t.length&&(a.category_id=Array.isArray(t)?t.join(","):t),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(A.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,T()({},this.props,{error:r,isLoading:n,reviews:c.slice(0,t),totalReviews:a}))}}O()(t,"defaultProps",{delayFunction:e=>e,onReviewsAppended:()=>{},onReviewsLoadError:()=>{},onReviewsReplaced:()=>{}});const{displayName:r=e.name||"Component"}=e;return t.displayName=`WithReviews( ${r} )`,t})(I);t.a=e=>{let{attributes:t,icon:r,name:i,noReviewsPlaceholder:l}=e;const{categoryIds:d,productId:u,reviewsOnPageLoad:b,showProductName:w,showReviewDate:m,showReviewerName:p,showReviewContent:g,showReviewImage:h,showReviewRating:v}=t,{order:O,orderby:_}=Object(A.d)(t.orderby),j=!(g||v||m||p||h||w),f=Object(s.useBlockProps)({className:Object(A.a)(t)});return j?Object(o.createElement)(a.Placeholder,{icon:r,label:i},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)(D,{attributes:t,categoryIds:d,delayFunction:e=>Object(c.debounce)(e,400),noReviewsPlaceholder:l,orderby:_,order:O,productId:u,reviewsToDisplay:b}))}},141:function(e,t){},142:function(e,t){},164:function(e,t){},165:function(e,t){},166:function(e,t){},167:function(e,t){},18:function(e,t){e.exports=window.wp.primitives},2:function(e,t){e.exports=window.wc.wcSettings},25: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 s})),r.d(t,"n",(function(){return i})),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 m})),r.d(t,"d",(function(){return p})),r.d(t,"h",(function(){return g})),r.d(t,"a",(function(){return h})),r.d(t,"i",(function(){return v})),r.d(t,"b",(function(){return O}));var o,n=r(2);const c=Object(n.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),a=c.pluginUrl+"images/",s=c.pluginUrl+"build/",i=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),m=(n.STORE_PAGES.terms.title,n.STORE_PAGES.cart.id),p=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",{})),h=Object(n.getSetting)("allowedCountries",{}),v=Object(n.getSetting)("shippingStates",{}),O=Object(n.getSetting)("allowedStates",{})},26:function(e,t){e.exports=window.wp.isShallowEqual},28:function(e,t,r){"use strict";r.d(t,"a",(function(){return n})),r.d(t,"b",(function(){return c}));var o=r(1);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"}},c=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?void 0: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},30: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:s={}}=e;const i=null!=r,l=null!=n;return!i&&l?(t=a||"span",s={...s,className:c()(s.className,"screen-reader-text")},Object(o.createElement)(t,s,n)):(t=a||o.Fragment,i&&l&&r!==n?Object(o.createElement)(t,s,Object(o.createElement)("span",{"aria-hidden":"true"},r),Object(o.createElement)("span",{className:"screen-reader-text"},n)):Object(o.createElement)(t,s,r))}},31:function(e,t){e.exports=window.wp.escapeHtml},32:function(e,t,r){"use strict";var o=r(0),n=r(1),c=r(31);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 unknown error occurred which prevented the block from being updated.","woo-gutenberg-products-block")})(t))}},341:function(e,t,r){e.exports=r(447)},43:function(e,t,r){"use strict";var o=r(0);t.a=function(e){let{srcElement:t,size:r=24,...n}=e;return Object(o.isValidElement)(t)?Object(o.cloneElement)(t,{width:r,height:r,...n}):null}},447:function(e,t,r){"use strict";r.r(t);var o=r(0),n=r(1),c=r(12),a=r(43),s=r(18),i=Object(o.createElement)(s.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(o.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(o.createElement)("path",{d:"M15 4v7H5.17l-.59.59-.58.58V4h11m1-2H3c-.55 0-1 .45-1 1v14l4-4h10c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm5 4h-2v9H6v2c0 .55.45 1 1 1h11l4 4V7c0-.55-.45-1-1-1z"})),l=(r(141),r(7)),d=r(3),u=(r(10),r(134)),b=()=>Object(o.createElement)(d.Placeholder,{className:"wc-block-all-reviews",icon:Object(o.createElement)(a.a,{srcElement:i,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")),w=r(94),m=r(130),p=r(131),g=r(110);Object(c.registerBlockType)("woocommerce/all-reviews",{apiVersion:2,title:Object(n.__)("All Reviews","woo-gutenberg-products-block"),icon:{src:Object(o.createElement)(a.a,{srcElement:i,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:{...g.a,attributes:{...g.a.attributes,showProductName:!0}},attributes:{...m.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)(l.InspectorControls,{key:"inspector"},Object(o.createElement)(d.PanelBody,{title:Object(n.__)("Content","woo-gutenberg-products-block")},Object(o.createElement)(d.ToggleControl,{label:Object(n.__)("Product name","woo-gutenberg-products-block"),checked:t.showProductName,onChange:()=>r({showProductName:!t.showProductName})}),Object(w.b)(t,r)),Object(o.createElement)(d.PanelBody,{title:Object(n.__)("List Settings","woo-gutenberg-products-block")},Object(w.c)(t,r))),Object(o.createElement)(u.a,{attributes:t,icon:Object(o.createElement)(a.a,{icon:i,className:"block-editor-block-icon"}),name:Object(n.__)("All Reviews","woo-gutenberg-products-block"),noReviewsPlaceholder:b}))},save:p.a})},53:function(e,t,r){"use strict";r.d(t,"d",(function(){return i})),r.d(t,"c",(function(){return l})),r.d(t,"a",(function(){return d})),r.d(t,"b",(function(){return u}));var o=r(11),n=r.n(o),c=r(4),a=r.n(c),s=r(2);const i=e=>{if(Object(s.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/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:s,showProductName:i,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":s,"has-product-name":i})},u=e=>{const{categoryIds:t,imageType:r,orderby:o,productId:n,reviewsOnPageLoad:c,reviewsOnLoadMore:a,showLoadMore:s,showOrderby:i}=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":s,"data-show-orderby":i};return n&&(l["data-product-id"]=n),Array.isArray(t)&&(l["data-category-ids"]=t.join(",")),l}},55:function(e,t,r){"use strict";var o=r(5),n=r.n(o),c=r(0),a=r(6),s=r(4),i=r.n(s),l=r(3),d=r(9);r(82);class u extends c.Component{constructor(){super(...arguments),this.onClick=this.onClick.bind(this)}onClick(e){this.props.onChange&&this.props.onChange(e.target.value)}render(){const{label:e,checked:t,instanceId:r,className:o,help:s,options:d,value:u}=this.props,b="inspector-toggle-button-control-"+r;let w;return s&&(w=Object(a.isFunction)(s)?s(t):s),Object(c.createElement)(l.BaseControl,{id:b,help:w,className:i()("components-toggle-button-control",o)},Object(c.createElement)("label",{id:b+"__label",htmlFor:b,className:"components-toggle-button-control__label"},e),Object(c.createElement)(l.ButtonGroup,{"aria-labelledby":b+"__label"},d.map((t,r)=>{const o={};return u===t.value?(o.isPrimary=!0,o["aria-pressed"]=!0):(o.isSecondary=!0,o["aria-pressed"]=!1),Object(c.createElement)(l.Button,n()({key:`${t.label}-${t.value}-${r}`,value:t.value,onClick:this.onClick,"aria-label":e+": "+t.label},o),t.label)})))}}t.a=Object(d.withInstanceId)(u)},6:function(e,t){e.exports=window.lodash},69:function(e,t,r){"use strict";var o=r(0),n=r(1),c=r(43),a=r(102),s=r(4),i=r.n(s),l=r(3),d=r(32);r(103),t.a=e=>{let{className:t,error:r,isLoading:s=!1,onRetry:u}=e;return Object(o.createElement)(l.Placeholder,{icon:Object(o.createElement)(c.a,{srcElement:a.a}),label:Object(n.__)("Sorry, an error occurred","woo-gutenberg-products-block"),className:i()("wc-block-api-error",t)},Object(o.createElement)(d.a,{error:r}),u&&Object(o.createElement)(o.Fragment,null,s?Object(o.createElement)(l.Spinner,null):Object(o.createElement)(l.Button,{isSecondary:!0,onClick:u},Object(n.__)("Retry","woo-gutenberg-products-block"))))}},7:function(e,t){e.exports=window.wp.blockEditor},8:function(e,t){e.exports=window.React},82:function(e,t){},9:function(e,t){e.exports=window.wp.compose},94:function(e,t,r){"use strict";r.d(t,"a",(function(){return l})),r.d(t,"b",(function(){return d})),r.d(t,"c",(function(){return u}));var o=r(0),n=r(1),c=r(3),a=r(7),s=r(2),i=r(55);const l=(e,t,r)=>Object(o.createElement)(a.BlockControls,null,Object(o.createElement)(c.ToolbarGroup,{controls:[{icon:"edit",title:r,onClick:()=>t({editMode:!e}),isActive:e}]})),d=(e,t)=>{const r=Object(s.getSetting)("showAvatars",!0),a=Object(s.getSetting)("reviewRatingsEnabled",!0);return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(c.ToggleControl,{label:Object(n.__)("Product rating","woo-gutenberg-products-block"),checked:e.showReviewRating,onChange:()=>t({showReviewRating:!e.showReviewRating})}),e.showReviewRating&&!a&&Object(o.createElement)(c.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(s.getAdminLink)("admin.php?page=wc-settings&tab=products"),target:"_blank",rel:"noopener noreferrer"})})),Object(o.createElement)(c.ToggleControl,{label:Object(n.__)("Reviewer name","woo-gutenberg-products-block"),checked:e.showReviewerName,onChange:()=>t({showReviewerName:!e.showReviewerName})}),Object(o.createElement)(c.ToggleControl,{label:Object(n.__)("Image","woo-gutenberg-products-block"),checked:e.showReviewImage,onChange:()=>t({showReviewImage:!e.showReviewImage})}),Object(o.createElement)(c.ToggleControl,{label:Object(n.__)("Review date","woo-gutenberg-products-block"),checked:e.showReviewDate,onChange:()=>t({showReviewDate:!e.showReviewDate})}),Object(o.createElement)(c.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.a,{label:Object(n.__)("Review image","woo-gutenberg-products-block"),value:e.imageType,options:[{label:Object(n.__)("Reviewer photo","woo-gutenberg-products-block"),value:"reviewer"},{label:Object(n.__)("Product","woo-gutenberg-products-block"),value:"product"}],onChange:e=>t({imageType:e})}),"reviewer"===e.imageType&&!r&&Object(o.createElement)(c.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(s.getAdminLink)("options-discussion.php"),target:"_blank",rel:"noopener noreferrer"})}))))},u=(e,t)=>Object(o.createElement)(o.Fragment,null,Object(o.createElement)(c.ToggleControl,{label:Object(n.__)("Order by","woo-gutenberg-products-block"),checked:e.showOrderby,onChange:()=>t({showOrderby:!e.showOrderby})}),Object(o.createElement)(c.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)(c.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)(c.ToggleControl,{label:Object(n.__)("Load more","woo-gutenberg-products-block"),checked:e.showLoadMore,onChange:()=>t({showLoadMore:!e.showLoadMore})}),e.showLoadMore&&Object(o.createElement)(c.RangeControl,{label:Object(n.__)("Load More Reviews","woo-gutenberg-products-block"),value:e.reviewsOnLoadMore,onChange:e=>t({reviewsOnLoadMore:e}),max:20,min:1}))}});
|
|
|
|
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,s=t[0],i=t[1],l=t[2],u=0,b=[];u<s.length;u++)a=s[u],Object.prototype.hasOwnProperty.call(n,a)&&n[a]&&b.push(n[a][0]),n[a]=0;for(o in i)Object.prototype.hasOwnProperty.call(i,o)&&(e[o]=i[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,s=1;s<r.length;s++){var i=r[s];0!==n[i]&&(o=!1)}o&&(c.splice(t--,1),e=a(a.s=r[0]))}return e}var o={},n={8: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 s=window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[],i=s.push.bind(s);s.push=t,s=s.slice();for(var l=0;l<s.length;l++)t(s[l]);var d=i;return c.push([344,0]),r()}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},103:function(e,t,r){"use strict";var o=r(0),n=r(18);const c=Object(o.createElement)(n.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(o.createElement)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"}));t.a=c},104:function(e,t){},105:function(e,t,r){"use strict";var o=r(0),n=(r(10),r(4)),c=r.n(n),a=r(30),s=r(9);r(144),t.a=Object(s.withInstanceId)(e=>{let{className:t,instanceId:r,label:n,onChange:s,options:i,screenReaderLabel:l,readOnly:d,value:u}=e;const b="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:b}}),Object(o.createElement)("select",{id:b,className:"wc-block-sort-select__select wc-block-components-sort-select__select",onChange:s,readOnly:d,value:u},i.map(e=>Object(o.createElement)("option",{key:e.key,value:e.key},e.label))))})},11:function(e,t){e.exports=window.wp.apiFetch},111:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var o=r(1),n=r(24);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}]}}},12:function(e,t){e.exports=window.wp.blocks},132: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}}},133:function(e,t,r){"use strict";var o=r(5),n=r.n(o),c=r(0),a=r(7),s=(r(143),r(53));t.a=e=>{let{attributes:t}=e;return Object(c.createElement)("div",n()({},a.useBlockProps.save({className:Object(s.a)(t)}),Object(s.b)(t)))}},136:function(e,t,r){"use strict";var o=r(0),n=r(1),c=(r(10),r(6)),a=r(3),s=r(7),i=r(8),l=r(2),d=r(71),u=r(30);r(169);const b=e=>{let{onClick:t,label:r,screenReaderLabel:n}=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:n})))};b.defaultProps={label:Object(n.__)("Load more","woo-gutenberg-products-block")};var w=b,p=r(105);r(166);var m=e=>{let{onChange:t,readOnly:r,value:c}=e;return Object(o.createElement)(p.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})},g=r(4),h=r.n(g),v=r(25),O=r.n(v),_=r(153),j=r.n(_);const f=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"...";const o=j()(e,{suffix:r,limit:t});return o.html},k=(e,t,r)=>(t<=r?e.start=e.middle+1:e.end=e.middle-1,e),y=(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=f(e,o.middle),o=k(o,t.clientHeight,r);return o.middle})(e,t,r);return f(e,n-o.length,o)},E={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 i.Component{constructor(e){super(e),this.state={isExpanded:!1,clampEnabled:null,content:e.children,summary:"."},this.reviewContent=Object(i.createRef)(),this.reviewSummary=Object(i.createRef)(),this.getButton=this.getButton.bind(this),this.onClick=this.onClick.bind(this)}componentDidMount(){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:y(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}}O()(R,"defaultProps",E);var C=R;r(168);var S=e=>{let{attributes:t,review:r={}}=e;const{imageType:c,showReviewDate:a,showReviewerName:s,showReviewImage:i,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:h()("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":i}),"aria-hidden":w},(u||a||s||i||p)&&Object(o.createElement)("div",{className:"wc-block-review-list-item__info wc-block-components-review-list-item__info"},i&&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||s||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),s&&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)(C,{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(167);var P=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,s=c&&t.showReviewRating,i={...t,showReviewImage:a,showReviewRating:s};return Object(o.createElement)("ul",{className:"wc-block-review-list wc-block-components-review-list"},0===r.length?Object(o.createElement)(S,{attributes:i}):r.map((e,t)=>Object(o.createElement)(S,{key:e.id||t,attributes:i,review:e})))},N=r(5),T=r.n(N),L=r(26),x=r.n(L),M=r(53),A=r(28);class I extends i.Component{render(){const{attributes:e,error:t,isLoading:r,noReviewsPlaceholder:c,reviews:s,totalReviews:i}=this.props;if(t)return Object(o.createElement)(d.a,{className:"wc-block-featured-product-error",error:t,isLoading:r});if(0===s.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)(m,{readOnly:!0,value:e.orderby}),Object(o.createElement)(P,{attributes:e,reviews:s}),e.showLoadMore&&i>s.length&&Object(o.createElement)(w,{screenReaderLabel:Object(n.__)("Load more reviews","woo-gutenberg-products-block")}))}}var D=(e=>{class t extends i.Component{constructor(){super(...arguments),O()(this,"isPreview",!!this.props.attributes.previewReviews),O()(this,"delayedAppendReviews",this.props.delayFunction(this.appendReviews)),O()(this,"isMounted",!1),O()(this,"state",{error:null,loading:!0,reviews:this.isPreview?this.props.attributes.previewReviews:[],totalReviews:this.isPreview?this.props.attributes.previewReviews.length:0}),O()(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||!x()(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};return t&&t.length&&(a.category_id=Array.isArray(t)?t.join(","):t),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(M.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,T()({},this.props,{error:r,isLoading:n,reviews:c.slice(0,t),totalReviews:a}))}}O()(t,"defaultProps",{delayFunction:e=>e,onReviewsAppended:()=>{},onReviewsLoadError:()=>{},onReviewsReplaced:()=>{}});const{displayName:r=e.name||"Component"}=e;return t.displayName=`WithReviews( ${r} )`,t})(I);t.a=e=>{let{attributes:t,icon:r,name:i,noReviewsPlaceholder:l}=e;const{categoryIds:d,productId:u,reviewsOnPageLoad:b,showProductName:w,showReviewDate:p,showReviewerName:m,showReviewContent:g,showReviewImage:h,showReviewRating:v}=t,{order:O,orderby:_}=Object(M.d)(t.orderby),j=!(g||v||p||m||h||w),f=Object(s.useBlockProps)({className:Object(M.a)(t)});return j?Object(o.createElement)(a.Placeholder,{icon:r,label:i},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)(D,{attributes:t,categoryIds:d,delayFunction:e=>Object(c.debounce)(e,400),noReviewsPlaceholder:l,orderby:_,order:O,productId:u,reviewsToDisplay:b}))}},143:function(e,t){},144:function(e,t){},166:function(e,t){},167:function(e,t){},168:function(e,t){},169:function(e,t){},18:function(e,t){e.exports=window.wp.primitives},2:function(e,t){e.exports=window.wc.wcSettings},24: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 s})),r.d(t,"n",(function(){return i})),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 h})),r.d(t,"i",(function(){return v})),r.d(t,"b",(function(){return O}));var o,n=r(2);const c=Object(n.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),a=c.pluginUrl+"images/",s=c.pluginUrl+"build/",i=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",{})),h=Object(n.getSetting)("allowedCountries",{}),v=Object(n.getSetting)("shippingStates",{}),O=Object(n.getSetting)("allowedStates",{})},26:function(e,t){e.exports=window.wp.isShallowEqual},28:function(e,t,r){"use strict";r.d(t,"a",(function(){return n})),r.d(t,"b",(function(){return c}));var o=r(1);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"}},c=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?void 0: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},30: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:s={}}=e;const i=null!=r,l=null!=n;return!i&&l?(t=a||"span",s={...s,className:c()(s.className,"screen-reader-text")},Object(o.createElement)(t,s,n)):(t=a||o.Fragment,i&&l&&r!==n?Object(o.createElement)(t,s,Object(o.createElement)("span",{"aria-hidden":"true"},r),Object(o.createElement)("span",{className:"screen-reader-text"},n)):Object(o.createElement)(t,s,r))}},31:function(e,t){e.exports=window.wp.escapeHtml},32:function(e,t,r){"use strict";var o=r(0),n=r(1),c=r(31);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 unknown error occurred which prevented the block from being updated.","woo-gutenberg-products-block")})(t))}},344:function(e,t,r){e.exports=r(453)},43:function(e,t,r){"use strict";var o=r(0);t.a=function(e){let{srcElement:t,size:r=24,...n}=e;return Object(o.isValidElement)(t)?Object(o.cloneElement)(t,{width:r,height:r,...n}):null}},453:function(e,t,r){"use strict";r.r(t);var o=r(0),n=r(1),c=r(12),a=r(43),s=r(18),i=Object(o.createElement)(s.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(o.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(o.createElement)("path",{d:"M15 4v7H5.17l-.59.59-.58.58V4h11m1-2H3c-.55 0-1 .45-1 1v14l4-4h10c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm5 4h-2v9H6v2c0 .55.45 1 1 1h11l4 4V7c0-.55-.45-1-1-1z"})),l=(r(143),r(7)),d=r(3),u=(r(10),r(136)),b=()=>Object(o.createElement)(d.Placeholder,{className:"wc-block-all-reviews",icon:Object(o.createElement)(a.a,{srcElement:i,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")),w=r(95),p=r(132),m=r(133),g=r(111);Object(c.registerBlockType)("woocommerce/all-reviews",{apiVersion:2,title:Object(n.__)("All Reviews","woo-gutenberg-products-block"),icon:{src:Object(o.createElement)(a.a,{srcElement:i,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:{...g.a,attributes:{...g.a.attributes,showProductName:!0}},attributes:{...p.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)(l.InspectorControls,{key:"inspector"},Object(o.createElement)(d.PanelBody,{title:Object(n.__)("Content","woo-gutenberg-products-block")},Object(o.createElement)(d.ToggleControl,{label:Object(n.__)("Product name","woo-gutenberg-products-block"),checked:t.showProductName,onChange:()=>r({showProductName:!t.showProductName})}),Object(w.b)(t,r)),Object(o.createElement)(d.PanelBody,{title:Object(n.__)("List Settings","woo-gutenberg-products-block")},Object(w.c)(t,r))),Object(o.createElement)(u.a,{attributes:t,icon:Object(o.createElement)(a.a,{icon:i,className:"block-editor-block-icon"}),name:Object(n.__)("All Reviews","woo-gutenberg-products-block"),noReviewsPlaceholder:b}))},save:m.a})},53:function(e,t,r){"use strict";r.d(t,"d",(function(){return i})),r.d(t,"c",(function(){return l})),r.d(t,"a",(function(){return d})),r.d(t,"b",(function(){return u}));var o=r(11),n=r.n(o),c=r(4),a=r.n(c),s=r(2);const i=e=>{if(Object(s.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/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:s,showProductName:i,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":s,"has-product-name":i})},u=e=>{const{categoryIds:t,imageType:r,orderby:o,productId:n,reviewsOnPageLoad:c,reviewsOnLoadMore:a,showLoadMore:s,showOrderby:i}=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":s,"data-show-orderby":i};return n&&(l["data-product-id"]=n),Array.isArray(t)&&(l["data-category-ids"]=t.join(",")),l}},55:function(e,t,r){"use strict";var o=r(5),n=r.n(o),c=r(0),a=r(6),s=r(4),i=r.n(s),l=r(3),d=r(9);r(84);class u extends c.Component{constructor(){super(...arguments),this.onClick=this.onClick.bind(this)}onClick(e){this.props.onChange&&this.props.onChange(e.target.value)}render(){const{label:e,checked:t,instanceId:r,className:o,help:s,options:d,value:u}=this.props,b="inspector-toggle-button-control-"+r;let w;return s&&(w=Object(a.isFunction)(s)?s(t):s),Object(c.createElement)(l.BaseControl,{id:b,help:w,className:i()("components-toggle-button-control",o)},Object(c.createElement)("label",{id:b+"__label",htmlFor:b,className:"components-toggle-button-control__label"},e),Object(c.createElement)(l.ButtonGroup,{"aria-labelledby":b+"__label"},d.map((t,r)=>{const o={};return u===t.value?(o.isPrimary=!0,o["aria-pressed"]=!0):(o.isSecondary=!0,o["aria-pressed"]=!1),Object(c.createElement)(l.Button,n()({key:`${t.label}-${t.value}-${r}`,value:t.value,onClick:this.onClick,"aria-label":e+": "+t.label},o),t.label)})))}}t.a=Object(d.withInstanceId)(u)},6:function(e,t){e.exports=window.lodash},7:function(e,t){e.exports=window.wp.blockEditor},71:function(e,t,r){"use strict";var o=r(0),n=r(1),c=r(43),a=r(103),s=r(4),i=r.n(s),l=r(3),d=r(32);r(104),t.a=e=>{let{className:t,error:r,isLoading:s=!1,onRetry:u}=e;return Object(o.createElement)(l.Placeholder,{icon:Object(o.createElement)(c.a,{srcElement:a.a}),label:Object(n.__)("Sorry, an error occurred","woo-gutenberg-products-block"),className:i()("wc-block-api-error",t)},Object(o.createElement)(d.a,{error:r}),u&&Object(o.createElement)(o.Fragment,null,s?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.React},84:function(e,t){},9:function(e,t){e.exports=window.wp.compose},95:function(e,t,r){"use strict";r.d(t,"a",(function(){return l})),r.d(t,"b",(function(){return d})),r.d(t,"c",(function(){return u}));var o=r(0),n=r(1),c=r(3),a=r(7),s=r(2),i=r(55);const l=(e,t,r)=>Object(o.createElement)(a.BlockControls,null,Object(o.createElement)(c.ToolbarGroup,{controls:[{icon:"edit",title:r,onClick:()=>t({editMode:!e}),isActive:e}]})),d=(e,t)=>{const r=Object(s.getSetting)("showAvatars",!0),a=Object(s.getSetting)("reviewRatingsEnabled",!0);return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(c.ToggleControl,{label:Object(n.__)("Product rating","woo-gutenberg-products-block"),checked:e.showReviewRating,onChange:()=>t({showReviewRating:!e.showReviewRating})}),e.showReviewRating&&!a&&Object(o.createElement)(c.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(s.getAdminLink)("admin.php?page=wc-settings&tab=products"),target:"_blank",rel:"noopener noreferrer"})})),Object(o.createElement)(c.ToggleControl,{label:Object(n.__)("Reviewer name","woo-gutenberg-products-block"),checked:e.showReviewerName,onChange:()=>t({showReviewerName:!e.showReviewerName})}),Object(o.createElement)(c.ToggleControl,{label:Object(n.__)("Image","woo-gutenberg-products-block"),checked:e.showReviewImage,onChange:()=>t({showReviewImage:!e.showReviewImage})}),Object(o.createElement)(c.ToggleControl,{label:Object(n.__)("Review date","woo-gutenberg-products-block"),checked:e.showReviewDate,onChange:()=>t({showReviewDate:!e.showReviewDate})}),Object(o.createElement)(c.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.a,{label:Object(n.__)("Review image","woo-gutenberg-products-block"),value:e.imageType,options:[{label:Object(n.__)("Reviewer photo","woo-gutenberg-products-block"),value:"reviewer"},{label:Object(n.__)("Product","woo-gutenberg-products-block"),value:"product"}],onChange:e=>t({imageType:e})}),"reviewer"===e.imageType&&!r&&Object(o.createElement)(c.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(s.getAdminLink)("options-discussion.php"),target:"_blank",rel:"noopener noreferrer"})}))))},u=(e,t)=>Object(o.createElement)(o.Fragment,null,Object(o.createElement)(c.ToggleControl,{label:Object(n.__)("Order by","woo-gutenberg-products-block"),checked:e.showOrderby,onChange:()=>t({showOrderby:!e.showOrderby})}),Object(o.createElement)(c.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)(c.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)(c.ToggleControl,{label:Object(n.__)("Load more","woo-gutenberg-products-block"),checked:e.showLoadMore,onChange:()=>t({showLoadMore:!e.showLoadMore})}),e.showLoadMore&&Object(o.createElement)(c.RangeControl,{label:Object(n.__)("Load More Reviews","woo-gutenberg-products-block"),value:e.reviewsOnLoadMore,onChange:e=>t({reviewsOnLoadMore:e}),max:20,min:1}))}});
|
build/atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/image---8f355022.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[1],{64:function(n,t,c){"use strict";c.d(t,"a",(function(){return o})),c.d(t,"c",(function(){return u})),c.d(t,"b",(function(){return r})),c.d(t,"d",(function(){return e}));const o=n=>"number"==typeof n,u=n=>"string"==typeof n,r=n=>!(n=>null===n)(n)&&n instanceof Object&&n.constructor===Object;function e(n,t){return r(n)&&t in n}}}]);
|
build/atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/image---a7e2bb9b.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[
|
2 |
/* translators: %s Field label. */
|
3 |
-
Object(c.__)("%s (optional)","woo-gutenberg-products-block"),e.label)),e.priority&&(Object(
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[2],{151:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));const n=e=>e.reduce((e,t)=>{let[r,n]=t;return e[r]=n,e},{})},250:function(e,t,r){"use strict";r.d(t,"b",(function(){return o})),r.d(t,"a",(function(){return i}));const n=window.CustomEvent||null,c=(e,t)=>{let{bubbles:r=!1,cancelable:c=!1,element:s,detail:o={}}=t;if(!n)return;s||(s=document.body);const i=new n(e,{bubbles:r,cancelable:c,detail:o});s.dispatchEvent(i)};let s;const o=()=>{s&&clearTimeout(s),s=setTimeout(()=>{c("wc_fragment_refresh",{bubbles:!0,cancelable:!0})},50)},i=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("function"!=typeof jQuery)return()=>{};const s=()=>{c(t,{bubbles:r,cancelable:n})};return jQuery(document).on(e,s),()=>jQuery(document).off(e,s)}},251:function(e,t,r){"use strict";r.d(t,"b",(function(){return o})),r.d(t,"c",(function(){return i})),r.d(t,"a",(function(){return a}));var n=r(2),c=r(99),s=r(15);const o=e=>{let{country:t="",state:r="",city:n="",postcode:c=""}=e;return{country:t.trim(),state:r.trim(),city:n.trim(),postcode:c?c.replace(" ","").toUpperCase():""}},i=e=>{let{email:t=""}=e;return Object(s.isEmail)(t)?t.trim():""},a=e=>{const t=Object.keys(n.defaultAddressFields),r=Object(c.a)(t,{},e.country),s=Object.assign({},e);return r.forEach(t=>{let{key:r="",hidden:n=!1}=t;n&&((e,t)=>e in t)(r,e)&&(s[r]="")}),s}},36:function(e,t,r){"use strict";r.d(t,"a",(function(){return w}));var n=r(6),c=r(0),s=r(16),o=r(13),i=r(14),a=r(151),d=r(251),u=r(49),l=r(250);const p=e=>{const t=e.detail;t&&t.preserveCartData||Object(o.dispatch)(s.CART_STORE_KEY).invalidateResolutionForStore()},_=()=>{1===window.wcBlocksStoreCartListeners.count&&window.wcBlocksStoreCartListeners.remove(),window.wcBlocksStoreCartListeners.count--},b=()=>{Object(c.useEffect)(()=>((()=>{if(window.wcBlocksStoreCartListeners||(window.wcBlocksStoreCartListeners={count:0,remove:()=>{}}),0===window.wcBlocksStoreCartListeners.count){const e=Object(l.a)("added_to_cart","wc-blocks_added_to_cart"),t=Object(l.a)("removed_from_cart","wc-blocks_removed_from_cart");document.body.addEventListener("wc-blocks_added_to_cart",p),document.body.addEventListener("wc-blocks_removed_from_cart",p),window.wcBlocksStoreCartListeners.count=0,window.wcBlocksStoreCartListeners.remove=()=>{e(),t(),document.body.removeEventListener("wc-blocks_added_to_cart",p),document.body.removeEventListener("wc-blocks_removed_from_cart",p)}}window.wcBlocksStoreCartListeners.count++})(),_),[])},m={first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:""},E={...m,email:""},h={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:s.EMPTY_TAX_LINES,currency_code:"",currency_symbol:"",currency_minor_unit:2,currency_decimal_separator:"",currency_thousand_separator:"",currency_prefix:"",currency_suffix:""},g=e=>Object(a.a)(Object.entries(e).map(e=>{let[t,r]=e;return[t,Object(i.decodeEntities)(r)]})),f={cartCoupons:s.EMPTY_CART_COUPONS,cartItems:s.EMPTY_CART_ITEMS,cartFees:s.EMPTY_CART_FEES,cartItemsCount:0,cartItemsWeight:0,cartNeedsPayment:!0,cartNeedsShipping:!0,cartItemErrors:s.EMPTY_CART_ITEM_ERRORS,cartTotals:h,cartIsLoading:!0,cartErrors:s.EMPTY_CART_ERRORS,billingAddress:E,shippingAddress:m,shippingRates:s.EMPTY_SHIPPING_RATES,shippingRatesLoading:!1,cartHasCalculatedShipping:!1,paymentRequirements:s.EMPTY_PAYMENT_REQUIREMENTS,receiveCart:()=>{},extensions:s.EMPTY_EXTENSIONS},w=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{shouldSelect:!0};const{isEditor:t,previewData:r}=Object(u.b)(),i=null==r?void 0:r.previewCart,{shouldSelect:a}=e,l=Object(c.useRef)();b();const p=Object(o.useSelect)((e,r)=>{let{dispatch:n}=r;if(!a)return f;if(t)return{cartCoupons:i.coupons,cartItems:i.items,cartFees:i.fees,cartItemsCount:i.items_count,cartItemsWeight:i.items_weight,cartNeedsPayment:i.needs_payment,cartNeedsShipping:i.needs_shipping,cartItemErrors:s.EMPTY_CART_ITEM_ERRORS,cartTotals:i.totals,cartIsLoading:!1,cartErrors:s.EMPTY_CART_ERRORS,billingAddress:E,shippingAddress:m,extensions:s.EMPTY_EXTENSIONS,shippingRates:i.shipping_rates,shippingRatesLoading:!1,cartHasCalculatedShipping:i.has_calculated_shipping,paymentRequirements:i.paymentRequirements,receiveCart:"function"==typeof(null==i?void 0:i.receiveCart)?i.receiveCart:()=>{}};const c=e(s.CART_STORE_KEY),o=c.getCartData(),u=c.getCartErrors(),l=c.getCartTotals(),p=!c.hasFinishedResolution("getCartData"),_=c.isCustomerDataUpdating(),{receiveCart:b}=n(s.CART_STORE_KEY),h=g(o.billingAddress),w=o.needsShipping?g(o.shippingAddress):h,C=o.fees.length>0?o.fees.map(e=>g(e)):s.EMPTY_CART_FEES;return{cartCoupons:o.coupons.length>0?o.coupons.map(e=>({...e,label:e.code})):s.EMPTY_CART_COUPONS,cartItems:o.items,cartFees:C,cartItemsCount:o.itemsCount,cartItemsWeight:o.itemsWeight,cartNeedsPayment:o.needsPayment,cartNeedsShipping:o.needsShipping,cartItemErrors:o.errors,cartTotals:l,cartIsLoading:p,cartErrors:u,billingAddress:Object(d.a)(h),shippingAddress:Object(d.a)(w),extensions:o.extensions,shippingRates:o.shippingRates,shippingRatesLoading:_,cartHasCalculatedShipping:o.hasCalculatedShipping,paymentRequirements:o.paymentRequirements,receiveCart:b}},[a]);return l.current&&Object(n.isEqual)(l.current,p)||(l.current=p),l.current}},49:function(e,t,r){"use strict";r.d(t,"b",(function(){return o})),r.d(t,"a",(function(){return i}));var n=r(0),c=r(13);const s=Object(n.createContext)({isEditor:!1,currentPostId:0,currentView:"",previewData:{},getPreviewData:()=>{}}),o=()=>Object(n.useContext)(s),i=e=>{let{children:t,currentPostId:r=0,currentView:o="",previewData:i={}}=e;const a=Object(c.useSelect)(e=>r||e("core/editor").getCurrentPostId(),[r]),d=Object(n.useCallback)(e=>e in i?i[e]:{},[i]),u={isEditor:!0,currentPostId:a,currentView:o,previewData:i,getPreviewData:d};return Object(n.createElement)(s.Provider,{value:u},t)}},60:function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(61),c=r(0),s=r(36);const o=()=>{const e=Object(s.a)(),t=Object(c.useRef)(e);return Object(c.useEffect)(()=>{t.current=e},[e]),{dispatchStoreEvent:Object(c.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(n.doAction)("experimental__woocommerce_blocks-"+e,t)}catch(e){console.error(e)}}),[]),dispatchCheckoutEvent:Object(c.useCallback)((function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(n.doAction)("experimental__woocommerce_blocks-checkout-"+e,{...r,storeCart:t.current})}catch(e){console.error(e)}}),[])}}},99:function(e,t,r){"use strict";var n=r(2),c=r(1),s=r(64);const o=Object(n.getSetting)("countryLocale",{}),i=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(c.sprintf)(
|
2 |
/* translators: %s Field label. */
|
3 |
+
Object(c.__)("%s (optional)","woo-gutenberg-products-block"),e.label)),e.priority&&(Object(s.a)(e.priority)&&(t.index=e.priority),Object(s.c)(e.priority)&&(t.index=parseInt(e.priority,10))),e.hidden&&(t.required=!1),t},a=Object.entries(o).map(e=>{let[t,r]=e;return[t,Object.entries(r).map(e=>{let[t,r]=e;return[t,i(r)]}).reduce((e,t)=>{let[r,n]=t;return e[r]=n,e},{})]}).reduce((e,t)=>{let[r,n]=t;return e[r]=n,e},{});t.a=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";const c=r&&void 0!==a[r]?a[r]:{};return e.map(e=>({key:e,...n.defaultAddressFields[e]||{},...c[e]||{},...t[e]||{}})).sort((e,t)=>e.index-t.index)}}}]);
|
build/atomic-block-components/add-to-cart--atomic-block-components/button.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[4],{130:function(e,t,c){"use strict";c.d(t,"b",(function(){return v})),c.d(t,"a",(function(){return N}));var o=c(0),n=(c(10),c(13)),s=c(60),r=c(49),i=c(5),a=c.n(i),u=c(4),l=c.n(u),d=c(487);c(159);const m=e=>{let{status:t="default"}=e;switch(t){case"error":return"woocommerce-error";case"success":return"woocommerce-message";case"info":case"warning":return"woocommerce-info"}return""};var b=e=>{let{className:t,notices:c,removeNotice:n}=e;const s=c.filter(e=>"snackbar"!==e.type);if(!s.length)return null;const r=l()(t,"wc-block-components-notices");return Object(o.createElement)("div",{className:r},s.map(e=>Object(o.createElement)(d.a,a()({key:"store-notice-"+e.id},e,{className:l()("wc-block-components-notices__notice",m(e)),onRemove:()=>{e.isDismissible&&n(e.id)}}),e.content)))};const f=Object(o.createContext)({notices:[],createNotice:(e,t,c)=>{},removeNotice:(e,t)=>{},setIsSuppressed:e=>{},context:"wc/core"}),v=()=>Object(o.useContext)(f),N=e=>{let{children:t,className:c="",createNoticeContainer:i=!0,context:a="wc/core"}=e;const{createNotice:u,removeNotice:l}=Object(n.useDispatch)("core/notices"),[d,m]=Object(o.useState)(!1),{dispatchStoreEvent:v}=Object(s.a)(),{isEditor:N}=Object(r.b)(),O=Object(o.useCallback)((function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};u(e,t,{...c,context:c.context||a}),v("store-notice-create",{status:e,content:t,options:c})}),[u,v,a]),j=Object(o.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a;l(e,t)}),[l,a]),{notices:p}=Object(n.useSelect)(e=>({notices:e("core/notices").getNotices(a)}),[a]),h={notices:p,createNotice:O,removeNotice:j,context:a,setIsSuppressed:m},g=d?null:Object(o.createElement)(b,{className:c,notices:h.notices,removeNotice:h.removeNotice,isEditor:N});return Object(o.createElement)(f.Provider,{value:h},i&&g,t)}},159:function(e,t){},359:function(e,t,c){"use strict";c.d(t,"a",(function(){return l}));var o=c(0),n=c(13),s=c(16),r=c(14),i=c(36),a=c(47);const u=(e,t)=>{const c=e.find(e=>{let{id:c}=e;return c===t});return c?c.quantity:0},l=e=>{const{addItemToCart:t}=Object(n.useDispatch)(s.CART_STORE_KEY),{cartItems:c,cartIsLoading:l}=Object(i.a)(),{addErrorNotice:d,removeNotice:m}=Object(a.a)(),[b,f]=Object(o.useState)(!1),v=Object(o.useRef)(u(c,e));return Object(o.useEffect)(()=>{const t=u(c,e);t!==v.current&&(v.current=t)},[c,e]),{cartQuantity:Number.isFinite(v.current)?v.current:0,addingToCart:b,cartIsLoading:l,addToCart:function(){let c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return f(!0),t(e,c).then(()=>{m("add-to-cart")}).catch(e=>{d(Object(r.decodeEntities)(e.message),{context:"wc/all-products",id:"add-to-cart",isDismissible:!0})}).finally(()=>{f(!1)})}}}},47:function(e,t,c){"use strict";c.d(t,"a",(function(){return s}));var o=c(0),n=c(130);const s=()=>{const{notices:e,createNotice:t,removeNotice:c,setIsSuppressed:s}=Object(n.b)(),r=Object(o.useRef)(e);Object(o.useEffect)(()=>{r.current=e},[e]);const i=Object(o.useMemo)(()=>({hasNoticesOfType:e=>r.current.some(t=>t.type===e),removeNotices:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;r.current.forEach(t=>{null!==e&&t.status!==e||c(t.id)})},removeNotice:c}),[c]),a=Object(o.useMemo)(()=>({addDefaultNotice:function(e){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("default",e,{...c})},addErrorNotice:function(e){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("error",e,{...c})},addWarningNotice:function(e){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("warning",e,{...c})},addInfoNotice:function(e){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("info",e,{...c})},addSuccessNotice:function(e){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("success",e,{...c})}}),[t]);return{notices:e,...i,...a,setIsSuppressed:s}}}}]);
|
build/atomic-block-components/add-to-cart-frontend.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[7],{130:function(e,t,r){"use strict";var s=r(0);r(157),t.a=()=>Object(s.createElement)("span",{className:"wc-block-components-spinner","aria-hidden":"true"})},157:function(e,t){},160:function(e,t,r){"use strict";r.d(t,"b",(function(){return i})),r.d(t,"a",(function(){return u}));var s=r(0),c=r(5),n=r(11),a=r.n(n);const o=Object(s.createContext)({getValidationError:()=>"",setValidationErrors:e=>{},clearValidationError:e=>{},clearAllValidationErrors:()=>{},hideValidationError:()=>{},showValidationError:()=>{},showAllValidationErrors:()=>{},hasValidationErrors:!1,getValidationErrorId:e=>e}),i=()=>Object(s.useContext)(o),u=e=>{let{children:t}=e;const[r,n]=Object(s.useState)({}),i=Object(s.useCallback)(e=>r[e],[r]),u=Object(s.useCallback)(e=>{const t=r[e];return!t||t.hidden?"":"validate-error-"+e},[r]),l=Object(s.useCallback)(e=>{n(t=>{if(!t[e])return t;const{[e]:r,...s}=t;return s})},[]),d=Object(s.useCallback)(()=>{n({})},[]),b=Object(s.useCallback)(e=>{e&&n(t=>(e=Object(c.pickBy)(e,(e,r)=>!("string"!=typeof e.message||t.hasOwnProperty(r)&&a()(t[r],e))),0===Object.values(e).length?t:{...t,...e}))},[]),E=Object(s.useCallback)((e,t)=>{n(r=>{if(!r.hasOwnProperty(e))return r;const s={...r[e],...t};return a()(r[e],s)?r:{...r,[e]:s}})},[]),p={getValidationError:i,setValidationErrors:b,clearValidationError:l,clearAllValidationErrors:d,hideValidationError:Object(s.useCallback)(e=>{E(e,{hidden:!0})},[E]),showValidationError:Object(s.useCallback)(e=>{E(e,{hidden:!1})},[E]),showAllValidationErrors:Object(s.useCallback)(()=>{n(e=>{const t={};return Object.keys(e).forEach(r=>{e[r].hidden&&(t[r]={...e[r],hidden:!1})}),0===Object.values(t).length?e:{...e,...t}})},[]),hasValidationErrors:Object.keys(r).length>0,getValidationErrorId:u};return Object(s.createElement)(o.Provider,{value:p},t)}},169:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var s=r(89);const c=(e,t)=>function(r){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;const n=s.a.addEventCallback(e,r,c);return t(n),()=>{t(s.a.removeEventCallback(e,n.id))}}},17:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var s=r(0),c=r(11),n=r.n(c);function a(e){const t=Object(s.useRef)(e);return n()(e,t.current)||(t.current=e),t.current}},170:function(e,t,r){"use strict";r.d(t,"a",(function(){return n})),r.d(t,"b",(function(){return a}));const s=(e,t)=>e[t]?Array.from(e[t].values()).sort((e,t)=>e.priority-t.priority):[];var c=r(29);const n=async(e,t,r)=>{const c=s(e,t),n=[];for(const e of c)try{const t=await Promise.resolve(e.callback(r));"object"==typeof t&&n.push(t)}catch(e){console.error(e)}return!n.length||n},a=async(e,t,r)=>{const n=[],a=s(e,t);for(const e of a)try{const t=await Promise.resolve(e.callback(r));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(c.a)(t)||Object(c.b)(t))return n.push(t),n;n.push(t)}catch(e){return console.error(e),n.push({type:"error"}),n}return n}},221:function(e,t){},227:function(e,t,r){"use strict";var s=r(10),c=r.n(s),n=r(0),a=r(56),o=r(4),i=r.n(o),u=r(130);r(230),t.a=e=>{let{className:t,showSpinner:r=!1,children:s,...o}=e;const l=i()("wc-block-components-button",t,{"wc-block-components-button--loading":r});return Object(n.createElement)(a.a,c()({className:l},o),r&&Object(n.createElement)(u.a,null),Object(n.createElement)("span",{className:"wc-block-components-button__text"},s))}},230:function(e,t){},235:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));var s=r(0),c=(r(8),r(160));r(221);const n=e=>{let{errorMessage:t="",propertyName:r="",elementId:n=""}=e;const{getValidationError:a,getValidationErrorId:o}=Object(c.b)();if(!t||"string"!=typeof t){const e=a(r)||{};if(!e.message||e.hidden)return null;t=e.message}return Object(s.createElement)("div",{className:"wc-block-components-validation-error",role:"alert"},Object(s.createElement)("p",{id:o(n)},t))}},29:function(e,t,r){"use strict";r.d(t,"a",(function(){return i})),r.d(t,"b",(function(){return u})),r.d(t,"c",(function(){return d}));var s=r(35);let c,n;!function(e){e.SUCCESS="success",e.FAIL="failure",e.ERROR="error"}(c||(c={})),function(e){e.PAYMENTS="wc/payment-area",e.EXPRESS_PAYMENTS="wc/express-payment-area"}(n||(n={}));const a=(e,t)=>Object(s.c)(e)&&"type"in e&&e.type===t,o=e=>a(e,c.SUCCESS),i=e=>a(e,c.ERROR),u=e=>a(e,c.FAIL),l=e=>!Object(s.c)(e)||void 0===e.retry||!0===e.retry,d=()=>({responseTypes:c,noticeContexts:n,shouldRetry:l,isSuccessResponse:o,isErrorResponse:i,isFailResponse:u})},316:function(e,t,r){"use strict";r.d(t,"a",(function(){return l}));var s=r(0),c=r(9),n=r(6),a=r(19),o=r(22),i=r(32);const u=(e,t)=>{const r=e.find(e=>{let{id:r}=e;return r===t});return r?r.quantity:0},l=e=>{const{addItemToCart:t}=Object(c.useDispatch)(n.CART_STORE_KEY),{cartItems:r,cartIsLoading:l}=Object(o.a)(),{addErrorNotice:d,removeNotice:b}=Object(i.a)(),[E,p]=Object(s.useState)(!1),m=Object(s.useRef)(u(r,e));return Object(s.useEffect)(()=>{const t=u(r,e);t!==m.current&&(m.current=t)},[r,e]),{cartQuantity:Number.isFinite(m.current)?m.current:0,addingToCart:E,cartIsLoading:l,addToCart:function(){let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return p(!0),t(e,r).then(()=>{b("add-to-cart")}).catch(e=>{d(Object(a.decodeEntities)(e.message),{context:"wc/all-products",id:"add-to-cart",isDismissible:!0})}).finally(()=>{p(!1)})}}}},32:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));var s=r(0),c=r(87);const n=()=>{const{notices:e,createNotice:t,removeNotice:r,setIsSuppressed:n}=Object(c.b)(),a=Object(s.useRef)(e);Object(s.useEffect)(()=>{a.current=e},[e]);const o=Object(s.useMemo)(()=>({hasNoticesOfType:e=>a.current.some(t=>t.type===e),removeNotices:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;a.current.forEach(t=>{null!==e&&t.status!==e||r(t.id)})},removeNotice:r}),[r]),i=Object(s.useMemo)(()=>({addDefaultNotice:function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("default",e,{...r})},addErrorNotice:function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("error",e,{...r})},addWarningNotice:function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("warning",e,{...r})},addInfoNotice:function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("info",e,{...r})},addSuccessNotice:function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("success",e,{...r})}}),[t]);return{notices:e,...o,...i,setIsSuppressed:n}}},322:function(e,t){},323:function(e,t,r){"use strict";var s=r(0),c=r(24);const n=Object(s.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(s.createElement)("path",{fill:"none",d:"M0 0h24v24H0z"}),Object(s.createElement)("path",{d:"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"}));t.a=n},324:function(e,t){},382:function(e,t,r){"use strict";r.r(t);var s=r(110),c=r(0),n=(r(8),r(4)),a=r.n(n),o=r(1),i=r(17);const u=e=>e.is_purchasable||!1,l={PRISTINE:"pristine",IDLE:"idle",DISABLED:"disabled",PROCESSING:"processing",BEFORE_PROCESSING:"before_processing",AFTER_PROCESSING:"after_processing"},d={status:l.PRISTINE,hasError:!1,quantity:1,processingResponse:null,requestParams:{}},b={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:E,SET_IDLE:p,SET_DISABLED:m,SET_PROCESSING:O,SET_BEFORE_PROCESSING:h,SET_AFTER_PROCESSING:f,SET_PROCESSING_RESPONSE:j,SET_HAS_ERROR:_,SET_NO_ERROR:g,SET_QUANTITY:S,SET_REQUEST_PARAMS:v}=b,y=()=>({type:p}),R=function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const t=e?_:g;return{type:t}},{SET_PRISTINE:C,SET_IDLE:P,SET_DISABLED:T,SET_PROCESSING:A,SET_BEFORE_PROCESSING:k,SET_AFTER_PROCESSING:N,SET_PROCESSING_RESPONSE:w,SET_HAS_ERROR:I,SET_NO_ERROR:D,SET_QUANTITY:F,SET_REQUEST_PARAMS:V}=b,{PRISTINE:B,IDLE:L,DISABLED:q,PROCESSING:x,BEFORE_PROCESSING:G,AFTER_PROCESSING:M}=l,Q=function(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d,{quantity:r,type:s,data:c}=arguments.length>1?arguments[1]:void 0;switch(s){case C:e=d;break;case P:e=t.status!==L?{...t,status:L}:t;break;case T:e=t.status!==q?{...t,status:q}:t;break;case F:e=r!==t.quantity?{...t,quantity:r}:t;break;case V:e={...t,requestParams:{...t.requestParams,...c}};break;case w:e={...t,processingResponse:c};break;case A:e=t.status!==x?{...t,status:x,hasError:!1}:t,e=!1===e.hasError?e:{...e,hasError:!1};break;case k:e=t.status!==G?{...t,status:G,hasError:!1}:t;break;case N:e=t.status!==M?{...t,status:M}:t;break;case I:e=t.hasError?t:{...t,hasError:!0},e=t.status===x||t.status===G?{...e,status:L}:e;break;case D:e=t.hasError?{...t,hasError:!1}:t}return e!==t&&s!==C&&e.status===B&&(e.status=L),e};var W=r(89),H=r(169);const U=e=>({onAddToCartAfterProcessingWithSuccess:Object(H.a)("add_to_cart_after_processing_with_success",e),onAddToCartProcessingWithError:Object(H.a)("add_to_cart_after_processing_with_error",e),onAddToCartBeforeProcessing:Object(H.a)("add_to_cart_before_processing",e)});var K=r(170),Y=r(160),z=r(32),J=r(29);const X=Object(c.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(c.useContext)(X),$=e=>{let{children:t,product:r,showFormElements:s}=e;const[n,a]=Object(c.useReducer)(Q,d),[b,p]=Object(c.useReducer)(W.b,{}),_=Object(i.a)(b),{addErrorNotice:g,removeNotices:C}=Object(z.a)(),{setValidationErrors:P}=Object(Y.b)(),{isSuccessResponse:T,isErrorResponse:A,isFailResponse:k}=Object(J.c)(),N=Object(c.useMemo)(()=>({onAddToCartAfterProcessingWithSuccess:U(p).onAddToCartAfterProcessingWithSuccess,onAddToCartAfterProcessingWithError:U(p).onAddToCartAfterProcessingWithError,onAddToCartBeforeProcessing:U(p).onAddToCartBeforeProcessing}),[p]),w=Object(c.useMemo)(()=>({resetForm:()=>{a({type:E})},submitForm:()=>{a({type:h})},setQuantity:e=>{a((e=>({type:S,quantity:e}))(e))},setHasError:e=>{a(R(e))},setRequestParams:e=>{a((e=>({type:v,data:e}))(e))},setAfterProcessing:e=>{a({type:j,data:e}),a({type:f})}}),[]);Object(c.useEffect)(()=>{const e=n.status,t=!r.id||!u(r);e!==l.DISABLED||t?e!==l.DISABLED&&t&&a({type:m}):a(y())},[n.status,r,a]),Object(c.useEffect)(()=>{n.status===l.BEFORE_PROCESSING&&(C("error"),Object(K.a)(_,"add_to_cart_before_processing",{}).then(e=>{!0!==e?(Array.isArray(e)&&e.forEach(e=>{let{errorMessage:t,validationErrors:r}=e;t&&g(t),r&&P(r)}),a(y())):a({type:O})}))},[n.status,P,g,C,a,_]),Object(c.useEffect)(()=>{if(n.status===l.AFTER_PROCESSING){const e={processingResponse:n.processingResponse},t=e=>{let t=!1;return e.forEach(e=>{const{message:r,messageContext:s}=e;(A(e)||k(e))&&r&&(t=!0,g(r,s?{context:s}:void 0))}),t};if(n.hasError)return void Object(K.b)(_,"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(o.__)("Something went wrong. Please contact us to get assistance.","woo-gutenberg-products-block");g(t,{id:"add-to-cart"})}a(y())});Object(K.b)(_,"add_to_cart_after_processing_with_success",e).then(e=>{t(e)?a(R(!0)):a(y())})}},[n.status,n.hasError,n.processingResponse,w,g,A,k,T,_]);const I=(e=>["simple","variable"].includes(e.type||"simple"))(r),D={product:r,productType:r.type||"simple",productIsPurchasable:u(r),productHasOptions:r.has_options||!1,supportsFormElements:I,showFormElements:s&&I,quantity:n.quantity,minQuantity:1,maxQuantity:r.quantity_limit||99,requestParams:n.requestParams,isIdle:n.status===l.IDLE,isDisabled:n.status===l.DISABLED,isProcessing:n.status===l.PROCESSING,isBeforeProcessing:n.status===l.BEFORE_PROCESSING,isAfterProcessing:n.status===l.AFTER_PROCESSING,hasError:n.hasError,eventRegistration:N,dispatchActions:w};return Object(c.createElement)(X.Provider,{value:D},t)};var ee=r(27),te=r.n(ee),re=r(19),se=r(22),ce=()=>{const{dispatchActions:e,product:t,quantity:r,eventRegistration:s,hasError:n,isProcessing:a,requestParams:i}=Z(),{hasValidationErrors:u,showAllValidationErrors:l}=Object(Y.b)(),{addErrorNotice:d,removeNotice:b}=Object(z.a)(),{receiveCart:E}=Object(se.a)(),[p,m]=Object(c.useState)(!1),O=!n&&a,h=Object(c.useCallback)(()=>!u||(l(),{type:"error"}),[u,l]);Object(c.useEffect)(()=>{const e=s.onAddToCartBeforeProcessing(h,0);return()=>{e()}},[s,h]);const f=Object(c.useCallback)(()=>{m(!0),b("add-to-cart");const s={id:t.id||0,quantity:r,...i};te()({path:"/wc/store/cart/add-item",method:"POST",data:s,cache:"no-store",parse:!1}).then(t=>{te.a.setNonce(t.headers),t.json().then((function(r){t.ok?E(r):(r.body&&r.body.message?d(Object(re.decodeEntities)(r.body.message),{id:"add-to-cart"}):d(Object(o.__)("Something went wrong. Please contact us to get assistance.","woo-gutenberg-products-block"),{id:"add-to-cart"}),e.setHasError()),e.setAfterProcessing(r),m(!1)}))}).catch(t=>{t.json().then((function(t){var r;null!==(r=t.data)&&void 0!==r&&r.cart&&E(t.data.cart),e.setHasError(),e.setAfterProcessing(t),m(!1)}))})},[t,d,b,E,e,r,i]);return Object(c.useEffect)(()=>{O&&!p&&f()},[O,f,p]),null};const ne=e=>{let{children:t,product:r,showFormElements:s}=e;return Object(c.createElement)(Y.a,null,Object(c.createElement)($,{product:r,showFormElements:s},t,Object(c.createElement)(ce,null)))};var ae=r(49),oe=r(5),ie=(r(322),r(227)),ue=r(98),le=r(323),de=r(38),be=r(316);const Ee=e=>{let{className:t,href:r,text:s,onClick:n}=e;return Object(c.createElement)(ie.a,{className:t,href:r,onClick:n,rel:"nofollow"},s)},pe=e=>{let{className:t,quantityInCart:r,isProcessing:s,isDisabled:n,isDone:a,onClick:i}=e;return Object(c.createElement)(ie.a,{className:t,disabled:n,showSpinner:s,onClick:i},a&&r>0?Object(o.sprintf)(
|
2 |
/* translators: %s number of products in cart. */
|
3 |
-
Object(o._n)("%d in cart","%d in cart",r,"woo-gutenberg-products-block"),r):Object(o.__)("Add to cart","woo-gutenberg-products-block"),!!a&&Object(
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[7],{130:function(e,t,r){"use strict";var s=r(0);r(157),t.a=()=>Object(s.createElement)("span",{className:"wc-block-components-spinner","aria-hidden":"true"})},157:function(e,t){},160:function(e,t,r){"use strict";r.d(t,"b",(function(){return i})),r.d(t,"a",(function(){return l}));var s=r(0),n=r(5),c=r(11),a=r.n(c);const o=Object(s.createContext)({getValidationError:()=>"",setValidationErrors:e=>{},clearValidationError:e=>{},clearAllValidationErrors:()=>{},hideValidationError:()=>{},showValidationError:()=>{},showAllValidationErrors:()=>{},hasValidationErrors:!1,getValidationErrorId:e=>e}),i=()=>Object(s.useContext)(o),l=e=>{let{children:t}=e;const[r,c]=Object(s.useState)({}),i=Object(s.useCallback)(e=>r[e],[r]),l=Object(s.useCallback)(e=>{const t=r[e];return!t||t.hidden?"":"validate-error-"+e},[r]),u=Object(s.useCallback)(e=>{c(t=>{if(!t[e])return t;const{[e]:r,...s}=t;return s})},[]),d=Object(s.useCallback)(()=>{c({})},[]),b=Object(s.useCallback)(e=>{e&&c(t=>(e=Object(n.pickBy)(e,(e,r)=>!("string"!=typeof e.message||t.hasOwnProperty(r)&&a()(t[r],e))),0===Object.values(e).length?t:{...t,...e}))},[]),E=Object(s.useCallback)((e,t)=>{c(r=>{if(!r.hasOwnProperty(e))return r;const s={...r[e],...t};return a()(r[e],s)?r:{...r,[e]:s}})},[]),p={getValidationError:i,setValidationErrors:b,clearValidationError:u,clearAllValidationErrors:d,hideValidationError:Object(s.useCallback)(e=>{E(e,{hidden:!0})},[E]),showValidationError:Object(s.useCallback)(e=>{E(e,{hidden:!1})},[E]),showAllValidationErrors:Object(s.useCallback)(()=>{c(e=>{const t={};return Object.keys(e).forEach(r=>{e[r].hidden&&(t[r]={...e[r],hidden:!1})}),0===Object.values(t).length?e:{...e,...t}})},[]),hasValidationErrors:Object.keys(r).length>0,getValidationErrorId:l};return Object(s.createElement)(o.Provider,{value:p},t)}},169:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));var s=r(89);const n=(e,t)=>function(r){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;const c=s.a.addEventCallback(e,r,n);return t(c),()=>{t(s.a.removeEventCallback(e,c.id))}}},17:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var s=r(0),n=r(11),c=r.n(n);function a(e){const t=Object(s.useRef)(e);return c()(e,t.current)||(t.current=e),t.current}},170:function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r.d(t,"b",(function(){return a}));const s=(e,t)=>e[t]?Array.from(e[t].values()).sort((e,t)=>e.priority-t.priority):[];var n=r(29);const c=async(e,t,r)=>{const n=s(e,t),c=[];for(const e of n)try{const t=await Promise.resolve(e.callback(r));"object"==typeof t&&c.push(t)}catch(e){console.error(e)}return!c.length||c},a=async(e,t,r)=>{const c=[],a=s(e,t);for(const e of a)try{const t=await Promise.resolve(e.callback(r));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(n.a)(t)||Object(n.b)(t))return c.push(t),c;c.push(t)}catch(e){return console.error(e),c.push({type:"error"}),c}return c}},222:function(e,t){},228:function(e,t,r){"use strict";var s=r(10),n=r.n(s),c=r(0),a=r(56),o=r(4),i=r.n(o),l=r(130);r(231),t.a=e=>{let{className:t,showSpinner:r=!1,children:s,...o}=e;const u=i()("wc-block-components-button",t,{"wc-block-components-button--loading":r});return Object(c.createElement)(a.a,n()({className:u},o),r&&Object(c.createElement)(l.a,null),Object(c.createElement)("span",{className:"wc-block-components-button__text"},s))}},231:function(e,t){},236:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var s=r(0),n=(r(8),r(160));r(222);const c=e=>{let{errorMessage:t="",propertyName:r="",elementId:c=""}=e;const{getValidationError:a,getValidationErrorId:o}=Object(n.b)();if(!t||"string"!=typeof t){const e=a(r)||{};if(!e.message||e.hidden)return null;t=e.message}return Object(s.createElement)("div",{className:"wc-block-components-validation-error",role:"alert"},Object(s.createElement)("p",{id:o(c)},t))}},29:function(e,t,r){"use strict";r.d(t,"a",(function(){return i})),r.d(t,"b",(function(){return l})),r.d(t,"c",(function(){return d}));var s=r(35);let n,c;!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"}(c||(c={}));const a=(e,t)=>Object(s.c)(e)&&"type"in e&&e.type===t,o=e=>a(e,n.SUCCESS),i=e=>a(e,n.ERROR),l=e=>a(e,n.FAIL),u=e=>!Object(s.c)(e)||void 0===e.retry||!0===e.retry,d=()=>({responseTypes:n,noticeContexts:c,shouldRetry:u,isSuccessResponse:o,isErrorResponse:i,isFailResponse:l})},318:function(e,t,r){"use strict";r.d(t,"a",(function(){return u}));var s=r(0),n=r(9),c=r(6),a=r(19),o=r(22),i=r(32);const l=(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(n.useDispatch)(c.CART_STORE_KEY),{cartItems:r,cartIsLoading:u}=Object(o.a)(),{addErrorNotice:d,removeNotice:b}=Object(i.a)(),[E,p]=Object(s.useState)(!1),m=Object(s.useRef)(l(r,e));return Object(s.useEffect)(()=>{const t=l(r,e);t!==m.current&&(m.current=t)},[r,e]),{cartQuantity:Number.isFinite(m.current)?m.current:0,addingToCart:E,cartIsLoading:u,addToCart:function(){let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return p(!0),t(e,r).then(()=>{b("add-to-cart")}).catch(e=>{d(Object(a.decodeEntities)(e.message),{context:"wc/all-products",id:"add-to-cart",isDismissible:!0})}).finally(()=>{p(!1)})}}}},32:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var s=r(0),n=r(87);const c=()=>{const{notices:e,createNotice:t,removeNotice:r,setIsSuppressed:c}=Object(n.b)(),a=Object(s.useRef)(e);Object(s.useEffect)(()=>{a.current=e},[e]);const o=Object(s.useMemo)(()=>({hasNoticesOfType:e=>a.current.some(t=>t.type===e),removeNotices:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;a.current.forEach(t=>{null!==e&&t.status!==e||r(t.id)})},removeNotice:r}),[r]),i=Object(s.useMemo)(()=>({addDefaultNotice:function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("default",e,{...r})},addErrorNotice:function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("error",e,{...r})},addWarningNotice:function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("warning",e,{...r})},addInfoNotice:function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("info",e,{...r})},addSuccessNotice:function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t("success",e,{...r})}}),[t]);return{notices:e,...o,...i,setIsSuppressed:c}}},324:function(e,t){},325:function(e,t,r){"use strict";var s=r(0),n=r(24);const c=Object(s.createElement)(n.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(s.createElement)("path",{fill:"none",d:"M0 0h24v24H0z"}),Object(s.createElement)("path",{d:"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"}));t.a=c},326:function(e,t){},384:function(e,t,r){"use strict";r.r(t);var s=r(110),n=r(0),c=(r(8),r(4)),a=r.n(c),o=r(1),i=r(17);const l=e=>e.is_purchasable||!1,u={PRISTINE:"pristine",IDLE:"idle",DISABLED:"disabled",PROCESSING:"processing",BEFORE_PROCESSING:"before_processing",AFTER_PROCESSING:"after_processing"},d={status:u.PRISTINE,hasError:!1,quantity:0,processingResponse:null,requestParams:{}},b={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:E,SET_IDLE:p,SET_DISABLED:m,SET_PROCESSING:O,SET_BEFORE_PROCESSING:h,SET_AFTER_PROCESSING:f,SET_PROCESSING_RESPONSE:_,SET_HAS_ERROR:j,SET_NO_ERROR:g,SET_QUANTITY:S,SET_REQUEST_PARAMS:v}=b,y=()=>({type:p}),R=function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const t=e?j:g;return{type:t}},{SET_PRISTINE:C,SET_IDLE:P,SET_DISABLED:T,SET_PROCESSING:A,SET_BEFORE_PROCESSING:k,SET_AFTER_PROCESSING:N,SET_PROCESSING_RESPONSE:w,SET_HAS_ERROR:I,SET_NO_ERROR:D,SET_QUANTITY:F,SET_REQUEST_PARAMS:V}=b,{PRISTINE:B,IDLE:L,DISABLED:q,PROCESSING:x,BEFORE_PROCESSING:G,AFTER_PROCESSING:M}=u,Q=function(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d,{quantity:r,type:s,data:n}=arguments.length>1?arguments[1]:void 0;switch(s){case C:e=d;break;case P:e=t.status!==L?{...t,status:L}:t;break;case T:e=t.status!==q?{...t,status:q}:t;break;case F:e=r!==t.quantity?{...t,quantity:r}:t;break;case V:e={...t,requestParams:{...t.requestParams,...n}};break;case w:e={...t,processingResponse:n};break;case A:e=t.status!==x?{...t,status:x,hasError:!1}:t,e=!1===e.hasError?e:{...e,hasError:!1};break;case k:e=t.status!==G?{...t,status:G,hasError:!1}:t;break;case N:e=t.status!==M?{...t,status:M}:t;break;case I:e=t.hasError?t:{...t,hasError:!0},e=t.status===x||t.status===G?{...e,status:L}:e;break;case D:e=t.hasError?{...t,hasError:!1}:t}return e!==t&&s!==C&&e.status===B&&(e.status=L),e};var W=r(89),H=r(169);const U=e=>({onAddToCartAfterProcessingWithSuccess:Object(H.a)("add_to_cart_after_processing_with_success",e),onAddToCartProcessingWithError:Object(H.a)("add_to_cart_after_processing_with_error",e),onAddToCartBeforeProcessing:Object(H.a)("add_to_cart_before_processing",e)});var K=r(170),Y=r(160),z=r(32),J=r(29);const X=Object(n.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(n.useContext)(X),$=e=>{var t,r,s,c;let{children:a,product:b,showFormElements:p}=e;const[j,g]=Object(n.useReducer)(Q,d),[C,P]=Object(n.useReducer)(W.b,{}),T=Object(i.a)(C),{addErrorNotice:A,removeNotices:k}=Object(z.a)(),{setValidationErrors:N}=Object(Y.b)(),{isSuccessResponse:w,isErrorResponse:I,isFailResponse:D}=Object(J.c)(),F=Object(n.useMemo)(()=>({onAddToCartAfterProcessingWithSuccess:U(P).onAddToCartAfterProcessingWithSuccess,onAddToCartAfterProcessingWithError:U(P).onAddToCartAfterProcessingWithError,onAddToCartBeforeProcessing:U(P).onAddToCartBeforeProcessing}),[P]),V=Object(n.useMemo)(()=>({resetForm:()=>{g({type:E})},submitForm:()=>{g({type:h})},setQuantity:e=>{g((e=>({type:S,quantity:e}))(e))},setHasError:e=>{g(R(e))},setRequestParams:e=>{g((e=>({type:v,data:e}))(e))},setAfterProcessing:e=>{g({type:_,data:e}),g({type:f})}}),[]);Object(n.useEffect)(()=>{const e=j.status,t=!b.id||!l(b);e!==u.DISABLED||t?e!==u.DISABLED&&t&&g({type:m}):g(y())},[j.status,b,g]),Object(n.useEffect)(()=>{j.status===u.BEFORE_PROCESSING&&(k("error"),Object(K.a)(T,"add_to_cart_before_processing",{}).then(e=>{!0!==e?(Array.isArray(e)&&e.forEach(e=>{let{errorMessage:t,validationErrors:r}=e;t&&A(t),r&&N(r)}),g(y())):g({type:O})}))},[j.status,N,A,k,g,T]),Object(n.useEffect)(()=>{if(j.status===u.AFTER_PROCESSING){const e={processingResponse:j.processingResponse},t=e=>{let t=!1;return e.forEach(e=>{const{message:r,messageContext:s}=e;(I(e)||D(e))&&r&&(t=!0,A(r,s?{context:s}:void 0))}),t};if(j.hasError)return void Object(K.b)(T,"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(o.__)("Something went wrong. Please contact us to get assistance.","woo-gutenberg-products-block");A(t,{id:"add-to-cart"})}g(y())});Object(K.b)(T,"add_to_cart_after_processing_with_success",e).then(e=>{t(e)?g(R(!0)):g(y())})}},[j.status,j.hasError,j.processingResponse,V,A,I,D,w,T]);const B=(e=>["simple","variable"].includes(e.type||"simple"))(b),L={product:b,productType:b.type||"simple",productIsPurchasable:l(b),productHasOptions:b.has_options||!1,supportsFormElements:B,showFormElements:p&&B,quantity:j.quantity||(null==b||null===(t=b.add_to_cart)||void 0===t?void 0:t.minimum)||1,minQuantity:(null==b||null===(r=b.add_to_cart)||void 0===r?void 0:r.minimum)||1,maxQuantity:(null==b||null===(s=b.add_to_cart)||void 0===s?void 0:s.maximum)||99,multipleOf:(null==b||null===(c=b.add_to_cart)||void 0===c?void 0:c.multiple_of)||1,requestParams:j.requestParams,isIdle:j.status===u.IDLE,isDisabled:j.status===u.DISABLED,isProcessing:j.status===u.PROCESSING,isBeforeProcessing:j.status===u.BEFORE_PROCESSING,isAfterProcessing:j.status===u.AFTER_PROCESSING,hasError:j.hasError,eventRegistration:F,dispatchActions:V};return Object(n.createElement)(X.Provider,{value:L},a)};var ee=r(27),te=r.n(ee),re=r(19),se=r(22),ne=()=>{const{dispatchActions:e,product:t,quantity:r,eventRegistration:s,hasError:c,isProcessing:a,requestParams:i}=Z(),{hasValidationErrors:l,showAllValidationErrors:u}=Object(Y.b)(),{addErrorNotice:d,removeNotice:b}=Object(z.a)(),{receiveCart:E}=Object(se.a)(),[p,m]=Object(n.useState)(!1),O=!c&&a,h=Object(n.useCallback)(()=>!l||(u(),{type:"error"}),[l,u]);Object(n.useEffect)(()=>{const e=s.onAddToCartBeforeProcessing(h,0);return()=>{e()}},[s,h]);const f=Object(n.useCallback)(()=>{m(!0),b("add-to-cart");const s={id:t.id||0,quantity:r,...i};te()({path:"/wc/store/cart/add-item",method:"POST",data:s,cache:"no-store",parse:!1}).then(t=>{te.a.setNonce(t.headers),t.json().then((function(r){t.ok?E(r):(r.body&&r.body.message?d(Object(re.decodeEntities)(r.body.message),{id:"add-to-cart"}):d(Object(o.__)("Something went wrong. Please contact us to get assistance.","woo-gutenberg-products-block"),{id:"add-to-cart"}),e.setHasError()),e.setAfterProcessing(r),m(!1)}))}).catch(t=>{t.json().then((function(t){var r;null!==(r=t.data)&&void 0!==r&&r.cart&&E(t.data.cart),e.setHasError(),e.setAfterProcessing(t),m(!1)}))})},[t,d,b,E,e,r,i]);return Object(n.useEffect)(()=>{O&&!p&&f()},[O,f,p]),null};const ce=e=>{let{children:t,product:r,showFormElements:s}=e;return Object(n.createElement)(Y.a,null,Object(n.createElement)($,{product:r,showFormElements:s},t,Object(n.createElement)(ne,null)))};var ae=r(49),oe=r(5),ie=(r(324),r(228)),le=r(98),ue=r(325),de=r(38),be=r(318);const Ee=e=>{let{className:t,href:r,text:s,onClick:c}=e;return Object(n.createElement)(ie.a,{className:t,href:r,onClick:c,rel:"nofollow"},s)},pe=e=>{let{className:t,quantityInCart:r,isProcessing:s,isDisabled:c,isDone:a,onClick:i}=e;return Object(n.createElement)(ie.a,{className:t,disabled:c,showSpinner:s,onClick:i},a&&r>0?Object(o.sprintf)(
|
2 |
/* translators: %s number of products in cart. */
|
3 |
+
Object(o._n)("%d in cart","%d in cart",r,"woo-gutenberg-products-block"),r):Object(o.__)("Add to cart","woo-gutenberg-products-block"),!!a&&Object(n.createElement)(le.a,{srcElement:ue.a,alt:Object(o.__)("Done","woo-gutenberg-products-block")}))};var me=()=>{const{showFormElements:e,productIsPurchasable:t,productHasOptions:r,product:s,productType:c,isDisabled:a,isProcessing:i,eventRegistration:l,hasError:u,dispatchActions:d}=Z(),{parentName:b}=Object(ae.useInnerBlockLayoutContext)(),{dispatchStoreEvent:E}=Object(de.a)(),{cartQuantity:p}=Object(be.a)(s.id||0),[m,O]=Object(n.useState)(!1),h=s.add_to_cart||{url:"",text:""};return Object(n.useEffect)(()=>{const e=l.onAddToCartAfterProcessingWithSuccess(()=>(u||O(!0),!0),0);return()=>{e()}},[l,u]),(e||!r&&"simple"===c)&&t?Object(n.createElement)(pe,{className:"wc-block-components-product-add-to-cart-button",quantityInCart:p,isDisabled:a,isProcessing:i,isDone:m,onClick:()=>{d.submitForm(),E("cart-add-item",{product:s,listName:b})}}):Object(n.createElement)(Ee,{className:"wc-block-components-product-add-to-cart-button",href:h.url,text:h.text||Object(o.__)("View Product","woo-gutenberg-products-block"),onClick:()=>{E("product-view-link",{product:s,listName:b})}})},Oe=r(52),he=e=>{let{disabled:t,min:r,max:s,step:c=1,value:a,onChange:o}=e;const i=void 0!==s,l=Object(Oe.a)(e=>{let t=e;i&&(t=Math.min(t,Math.floor(s/c)*c)),t=Math.max(t,Math.ceil(r/c)*c),t=Math.floor(t/c)*c,t!==e&&o(t)},300);return Object(n.createElement)("input",{className:"wc-block-components-product-add-to-cart-quantity",type:"number",value:a,min:r,max:s,step:c,hidden:1===s,disabled:t,onChange:e=>{o(e.target.value),l(e.target.value)}})},fe=e=>{let{reason:t=Object(o.__)("Sorry, this product cannot be purchased.","woo-gutenberg-products-block")}=e;return Object(n.createElement)("div",{className:"wc-block-components-product-add-to-cart-unavailable"},t)},_e=()=>{const{product:e,quantity:t,minQuantity:r,maxQuantity:s,multipleOf:c,dispatchActions:a,isDisabled:i}=Z();return e.id&&!e.is_purchasable?Object(n.createElement)(fe,null):e.id&&!e.is_in_stock?Object(n.createElement)(fe,{reason:Object(o.__)("This product is currently out of stock and cannot be purchased.","woo-gutenberg-products-block")}):Object(n.createElement)(n.Fragment,null,Object(n.createElement)(he,{value:t,min:r,max:s,step:c,disabled:i,onChange:a.setQuantity}),Object(n.createElement)(me,null))},je=(r(326),r(385)),ge=r(3),Se=r(236);const ve={value:"",label:Object(o.__)("Select an option","woo-gutenberg-products-block")};var ye=e=>{let{attributeName:t,options:r=[],value:s="",onChange:c=(()=>{}),errorMessage:i=Object(o.__)("Please select a value.","woo-gutenberg-products-block")}=e;const{getValidationError:l,setValidationErrors:u,clearValidationError:d}=Object(Y.b)(),b=t,E=l(b)||{};return Object(ge.useEffect)(()=>{s?d(b):u({[b]:{message:i,hidden:!0}})},[s,b,i,d,u]),Object(ge.useEffect)(()=>()=>{d(b)},[b,d]),Object(n.createElement)("div",{className:"wc-block-components-product-add-to-cart-attribute-picker__container"},Object(n.createElement)(je.a,{label:Object(re.decodeEntities)(t),value:s||"",options:[ve,...r],onChange:c,required:!0,className:a()("wc-block-components-product-add-to-cart-attribute-picker__select",{"has-error":E.message&&!E.hidden})}),Object(n.createElement)(Se.a,{propertyName:b,elementId:b}))},Re=r(35);const Ce=(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 n=Object.keys(e);return s.filter(e=>n.every(s=>{const n=r[s]||"",c=t["id:"+e].attributes[s];return""===n||null===c||c===n}))};var Pe=e=>{let{attributes:t,variationAttributes:r,setRequestParams:s}=e;const c=Object(i.a)(t),a=Object(i.a)(r),[o,l]=Object(n.useState)(0),[u,d]=Object(n.useState)({}),[b,E]=Object(n.useState)(!1),p=Object(n.useMemo)(()=>((e,t,r)=>{const s={},n=Object.keys(e),c=Object.values(r).filter(Boolean).length>0;return n.forEach(n=>{const a=e[n],o={...r,[n]:null},i=c?Ce(e,t,o):null,l=null!==i?i.map(e=>t["id:"+e].attributes[n]):null;s[n]=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,l)}),s})(c,a,u),[u,c,a]);return Object(n.useEffect)(()=>{if(!b){const e=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!Object(Re.c)(e))return{};const t=Object.keys(e),r={};return 0===t.length||t.forEach(t=>{const s=e[t],n=s.terms.filter(e=>e.default);var c;n.length>0&&(r[s.name]=null===(c=n[0])||void 0===c?void 0:c.slug)}),r}(t);e&&d({...e}),E(!0)}},[u,t,b]),Object(n.useEffect)(()=>{Object.values(u).filter(e=>""!==e).length===Object.keys(c).length?l(((e,t,r)=>Ce(e,t,r)[0]||0)(c,a,u)):o>0&&l(0)},[u,o,c,a]),Object(n.useEffect)(()=>{s({id:o,variation:Object.keys(u).map(e=>({attribute:e,value:u[e]}))})},[s,o,u]),Object(n.createElement)("div",{className:"wc-block-components-product-add-to-cart-attribute-picker"},Object.keys(c).map(e=>Object(n.createElement)(ye,{key:e,attributeName:e,options:p[e],value:u[e],onChange:t=>{d({...u,[e]:t})}})))},Te=e=>{let{product:t,dispatchers:r}=e;const s=(e=>e?Object(oe.keyBy)(Object.values(e).filter(e=>{let{has_variations:t}=e;return t}),"name"):{})(t.attributes),c=(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(s).length||0===c.length?null:Object(n.createElement)(Pe,{attributes:s,variationAttributes:c,setRequestParams:r.setRequestParams})},Ae=()=>{const{product:e,quantity:t,minQuantity:r,maxQuantity:s,multipleOf:c,dispatchActions:a,isDisabled:i}=Z();return e.id&&!e.is_purchasable?Object(n.createElement)(fe,null):e.id&&!e.is_in_stock?Object(n.createElement)(fe,{reason:Object(o.__)("This product is currently out of stock and cannot be purchased.","woo-gutenberg-products-block")}):Object(n.createElement)(n.Fragment,null,Object(n.createElement)(Te,{product:e,dispatchers:a}),Object(n.createElement)(he,{value:t,min:r,max:s,step:c,disabled:i,onChange:a.setQuantity}),Object(n.createElement)(me,null))},ke=()=>Object(n.createElement)(me,null),Ne=r(297),we=()=>Object(n.createElement)(Ne.a,{className:"wc-block-components-product-add-to-cart-group-list"},"This is a placeholder for the grouped products form element."),Ie=()=>Object(n.createElement)(we,null);const De=()=>{const{showFormElements:e,productType:t}=Z();return e?"variable"===t?Object(n.createElement)(Ae,null):"grouped"===t?Object(n.createElement)(Ie,null):"external"===t?Object(n.createElement)(ke,null):"simple"===t||"variation"===t?Object(n.createElement)(_e,null):null:Object(n.createElement)(me,null)};var Fe=Object(s.withProductDataContext)(e=>{let{className:t,showFormElements:r}=e;const{product:s}=Object(ae.useProductDataContext)(),c=a()(t,"wc-block-components-product-add-to-cart",{"wc-block-components-product-add-to-cart--placeholder":Object(oe.isEmpty)(s)});return Object(n.createElement)(ce,{product:s,showFormElements:r},Object(n.createElement)("div",{className:c},Object(n.createElement)(De,null)))});t.default=Object(s.withFilteredAttributes)({showFormElements:{type:"boolean",default:!1},productId:{type:"number",default:0}})(Fe)},89:function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r.d(t,"b",(function(){return o}));var s=r(5);let n;!function(e){e.ADD_EVENT_CALLBACK="add_event_callback",e.REMOVE_EVENT_CALLBACK="remove_event_callback"}(n||(n={}));const c={addEventCallback:function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10;return{id:Object(s.uniqueId)(),type:n.ADD_EVENT_CALLBACK,eventType:e,callback:t,priority:r}},removeEventCallback:(e,t)=>({id:t,type:n.REMOVE_EVENT_CALLBACK,eventType:e})},a={},o=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:a,{type:t,eventType:r,id:s,callback:c,priority:o}=arguments.length>1?arguments[1]:void 0;const i=e.hasOwnProperty(r)?new Map(e[r]):new Map;switch(t){case n.ADD_EVENT_CALLBACK:return i.set(s,{priority:o,callback:c}),{...e,[r]:i};case n.REMOVE_EVENT_CALLBACK:return i.delete(s),{...e,[r]:i}}}}}]);
|
build/atomic-block-components/add-to-cart.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[7],{107:function(e,t,r){"use strict";r.d(t,"a",(function(){return a})),r.d(t,"b",(function(){return o}));var s=r(6);let n;!function(e){e.ADD_EVENT_CALLBACK="add_event_callback",e.REMOVE_EVENT_CALLBACK="remove_event_callback"}(n||(n={}));const a={addEventCallback:function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10;return{id:Object(s.uniqueId)(),type:n.ADD_EVENT_CALLBACK,eventType:e,callback:t,priority:r}},removeEventCallback:(e,t)=>({id:t,type:n.REMOVE_EVENT_CALLBACK,eventType:e})},c={},o=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:c,{type:t,eventType:r,id:s,callback:a,priority:o}=arguments.length>1?arguments[1]:void 0;const i=e.hasOwnProperty(r)?new Map(e[r]):new Map;switch(t){case n.ADD_EVENT_CALLBACK:return i.set(s,{priority:o,callback:a}),{...e,[r]:i};case n.REMOVE_EVENT_CALLBACK:return i.delete(s),{...e,[r]:i}}}},112:function(e,t,r){"use strict";r.d(t,"b",(function(){return i})),r.d(t,"a",(function(){return l}));var s=r(0),n=r(6),a=r(26),c=r.n(a);const o=Object(s.createContext)({getValidationError:()=>"",setValidationErrors:e=>{},clearValidationError:e=>{},clearAllValidationErrors:()=>{},hideValidationError:()=>{},showValidationError:()=>{},showAllValidationErrors:()=>{},hasValidationErrors:!1,getValidationErrorId:e=>e}),i=()=>Object(s.useContext)(o),l=e=>{let{children:t}=e;const[r,a]=Object(s.useState)({}),i=Object(s.useCallback)(e=>r[e],[r]),l=Object(s.useCallback)(e=>{const t=r[e];return!t||t.hidden?"":"validate-error-"+e},[r]),u=Object(s.useCallback)(e=>{a(t=>{if(!t[e])return t;const{[e]:r,...s}=t;return s})},[]),d=Object(s.useCallback)(()=>{a({})},[]),b=Object(s.useCallback)(e=>{e&&a(t=>(e=Object(n.pickBy)(e,(e,r)=>!("string"!=typeof e.message||t.hasOwnProperty(r)&&c()(t[r],e))),0===Object.values(e).length?t:{...t,...e}))},[]),E=Object(s.useCallback)((e,t)=>{a(r=>{if(!r.hasOwnProperty(e))return r;const s={...r[e],...t};return c()(r[e],s)?r:{...r,[e]:s}})},[]),p={getValidationError:i,setValidationErrors:b,clearValidationError:u,clearAllValidationErrors:d,hideValidationError:Object(s.useCallback)(e=>{E(e,{hidden:!0})},[E]),showValidationError:Object(s.useCallback)(e=>{E(e,{hidden:!1})},[E]),showAllValidationErrors:Object(s.useCallback)(()=>{a(e=>{const t={};return Object.keys(e).forEach(r=>{e[r].hidden&&(t[r]={...e[r],hidden:!1})}),0===Object.values(t).length?e:{...e,...t}})},[]),hasValidationErrors:Object.keys(r).length>0,getValidationErrorId:l};return Object(s.createElement)(o.Provider,{value:p},t)}},158:function(e,t){},159:function(e,t){},160:function(e,t){},193:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var s=r(0),n=(r(10),r(112));r(160);const a=e=>{let{errorMessage:t="",propertyName:r="",elementId:a=""}=e;const{getValidationError:c,getValidationErrorId:o}=Object(n.b)();if(!t||"string"!=typeof t){const e=c(r)||{};if(!e.message||e.hidden)return null;t=e.message}return Object(s.createElement)("div",{className:"wc-block-components-validation-error",role:"alert"},Object(s.createElement)("p",{id:o(a)},t))}},244:function(e,t){},251:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));var s=r(107);const n=(e,t)=>function(r){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;const a=s.a.addEventCallback(e,r,n);return t(a),()=>{t(s.a.removeEventCallback(e,a.id))}}},252:function(e,t,r){"use strict";t.a={showFormElements:{type:"boolean",default:!1},productId:{type:"number",default:0}}},253:function(e,t,r){"use strict";var s=r(0),n=(r(10),r(4)),a=r.n(n),c=r(1),o=r(40),i=r(471);const l={PRISTINE:"pristine",IDLE:"idle",DISABLED:"disabled",PROCESSING:"processing",BEFORE_PROCESSING:"before_processing",AFTER_PROCESSING:"after_processing"},u={status:l.PRISTINE,hasError:!1,quantity:1,processingResponse:null,requestParams:{}},d={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:b,SET_IDLE:E,SET_DISABLED:p,SET_PROCESSING:m,SET_BEFORE_PROCESSING:O,SET_AFTER_PROCESSING:_,SET_PROCESSING_RESPONSE:h,SET_HAS_ERROR:j,SET_NO_ERROR:f,SET_QUANTITY:S,SET_REQUEST_PARAMS:g}=d,y=()=>({type:E}),v=function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const t=e?j:f;return{type:t}},{SET_PRISTINE:R,SET_IDLE:P,SET_DISABLED:C,SET_PROCESSING:A,SET_BEFORE_PROCESSING:k,SET_AFTER_PROCESSING:T,SET_PROCESSING_RESPONSE:w,SET_HAS_ERROR:N,SET_NO_ERROR:I,SET_QUANTITY:D,SET_REQUEST_PARAMS:F}=d,{PRISTINE:V,IDLE:B,DISABLED:q,PROCESSING:L,BEFORE_PROCESSING:x,AFTER_PROCESSING:G}=l,Q=function(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:u,{quantity:r,type:s,data:n}=arguments.length>1?arguments[1]:void 0;switch(s){case R:e=u;break;case P:e=t.status!==B?{...t,status:B}:t;break;case C:e=t.status!==q?{...t,status:q}:t;break;case D:e=r!==t.quantity?{...t,quantity:r}:t;break;case F:e={...t,requestParams:{...t.requestParams,...n}};break;case w:e={...t,processingResponse:n};break;case A:e=t.status!==L?{...t,status:L,hasError:!1}:t,e=!1===e.hasError?e:{...e,hasError:!1};break;case k:e=t.status!==x?{...t,status:x,hasError:!1}:t;break;case T:e=t.status!==G?{...t,status:G}:t;break;case N:e=t.hasError?t:{...t,hasError:!0},e=t.status===L||t.status===x?{...e,status:B}:e;break;case I:e=t.hasError?{...t,hasError:!1}:t}return e!==t&&s!==R&&e.status===V&&(e.status=B),e};var M=r(107),H=r(251);const W=e=>({onAddToCartAfterProcessingWithSuccess:Object(H.a)("add_to_cart_after_processing_with_success",e),onAddToCartProcessingWithError:Object(H.a)("add_to_cart_after_processing_with_error",e),onAddToCartBeforeProcessing:Object(H.a)("add_to_cart_before_processing",e)});var U=r(254),K=r(112),Y=r(47),z=r(44);const J=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=>{}}}),X=()=>Object(s.useContext)(J),Z=e=>{let{children:t,product:r,showFormElements:n}=e;const[a,d]=Object(s.useReducer)(Q,u),[E,j]=Object(s.useReducer)(M.b,{}),f=Object(o.a)(E),{addErrorNotice:R,removeNotices:P}=Object(Y.a)(),{setValidationErrors:C}=Object(K.b)(),{isSuccessResponse:A,isErrorResponse:k,isFailResponse:T}=Object(z.c)(),w=Object(s.useMemo)(()=>({onAddToCartAfterProcessingWithSuccess:W(j).onAddToCartAfterProcessingWithSuccess,onAddToCartAfterProcessingWithError:W(j).onAddToCartAfterProcessingWithError,onAddToCartBeforeProcessing:W(j).onAddToCartBeforeProcessing}),[j]),N=Object(s.useMemo)(()=>({resetForm:()=>{d({type:b})},submitForm:()=>{d({type:O})},setQuantity:e=>{d((e=>({type:S,quantity:e}))(e))},setHasError:e=>{d(v(e))},setRequestParams:e=>{d((e=>({type:g,data:e}))(e))},setAfterProcessing:e=>{d({type:h,data:e}),d({type:_})}}),[]);Object(s.useEffect)(()=>{const e=a.status,t=!r.id||!Object(i.a)(r);e!==l.DISABLED||t?e!==l.DISABLED&&t&&d({type:p}):d(y())},[a.status,r,d]),Object(s.useEffect)(()=>{a.status===l.BEFORE_PROCESSING&&(P("error"),Object(U.a)(f,"add_to_cart_before_processing",{}).then(e=>{!0!==e?(Array.isArray(e)&&e.forEach(e=>{let{errorMessage:t,validationErrors:r}=e;t&&R(t),r&&C(r)}),d(y())):d({type:m})}))},[a.status,C,R,P,d,f]),Object(s.useEffect)(()=>{if(a.status===l.AFTER_PROCESSING){const e={processingResponse:a.processingResponse},t=e=>{let t=!1;return e.forEach(e=>{const{message:r,messageContext:s}=e;(k(e)||T(e))&&r&&(t=!0,R(r,s?{context:s}:void 0))}),t};if(a.hasError)return void Object(U.b)(f,"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(c.__)("Something went wrong. Please contact us to get assistance.","woo-gutenberg-products-block");R(t,{id:"add-to-cart"})}d(y())});Object(U.b)(f,"add_to_cart_after_processing_with_success",e).then(e=>{t(e)?d(v(!0)):d(y())})}},[a.status,a.hasError,a.processingResponse,N,R,k,T,A,f]);const I=Object(i.b)(r),D={product:r,productType:r.type||"simple",productIsPurchasable:Object(i.a)(r),productHasOptions:r.has_options||!1,supportsFormElements:I,showFormElements:n&&I,quantity:a.quantity,minQuantity:1,maxQuantity:r.quantity_limit||99,requestParams:a.requestParams,isIdle:a.status===l.IDLE,isDisabled:a.status===l.DISABLED,isProcessing:a.status===l.PROCESSING,isBeforeProcessing:a.status===l.BEFORE_PROCESSING,isAfterProcessing:a.status===l.AFTER_PROCESSING,hasError:a.hasError,eventRegistration:w,dispatchActions:N};return Object(s.createElement)(J.Provider,{value:D},t)};var $=r(11),ee=r.n($),te=r(14),re=r(36),se=()=>{const{dispatchActions:e,product:t,quantity:r,eventRegistration:n,hasError:a,isProcessing:o,requestParams:i}=X(),{hasValidationErrors:l,showAllValidationErrors:u}=Object(K.b)(),{addErrorNotice:d,removeNotice:b}=Object(Y.a)(),{receiveCart:E}=Object(re.a)(),[p,m]=Object(s.useState)(!1),O=!a&&o,_=Object(s.useCallback)(()=>!l||(u(),{type:"error"}),[l,u]);Object(s.useEffect)(()=>{const e=n.onAddToCartBeforeProcessing(_,0);return()=>{e()}},[n,_]);const h=Object(s.useCallback)(()=>{m(!0),b("add-to-cart");const s={id:t.id||0,quantity:r,...i};ee()({path:"/wc/store/cart/add-item",method:"POST",data:s,cache:"no-store",parse:!1}).then(t=>{ee.a.setNonce(t.headers),t.json().then((function(r){t.ok?E(r):(r.body&&r.body.message?d(Object(te.decodeEntities)(r.body.message),{id:"add-to-cart"}):d(Object(c.__)("Something went wrong. Please contact us to get assistance.","woo-gutenberg-products-block"),{id:"add-to-cart"}),e.setHasError()),e.setAfterProcessing(r),m(!1)}))}).catch(t=>{t.json().then((function(t){var r;null!==(r=t.data)&&void 0!==r&&r.cart&&E(t.data.cart),e.setHasError(),e.setAfterProcessing(t),m(!1)}))})},[t,d,b,E,e,r,i]);return Object(s.useEffect)(()=>{O&&!p&&h()},[O,h,p]),null};const ne=e=>{let{children:t,product:r,showFormElements:n}=e;return Object(s.createElement)(K.a,null,Object(s.createElement)(Z,{product:r,showFormElements:n},t,Object(s.createElement)(se,null)))};var ae=r(29),ce=r(6),oe=r(54),ie=(r(244),r(76)),le=r(43),ue=r(308),de=r(60),be=r(355);const Ee=e=>{let{className:t,href:r,text:n,onClick:a}=e;return Object(s.createElement)(ie.a,{className:t,href:r,onClick:a,rel:"nofollow"},n)},pe=e=>{let{className:t,quantityInCart:r,isProcessing:n,isDisabled:a,isDone:o,onClick:i}=e;return Object(s.createElement)(ie.a,{className:t,disabled:a,showSpinner:n,onClick:i},o&&r>0?Object(c.sprintf)(
|
2 |
/* translators: %s number of products in cart. */
|
3 |
-
Object(c._n)("%d in cart","%d in cart",r,"woo-gutenberg-products-block"),r):Object(c.__)("Add to cart","woo-gutenberg-products-block"),!!o&&Object(s.createElement)(le.a,{srcElement:ue.a,alt:Object(c.__)("Done","woo-gutenberg-products-block")}))};var me=()=>{const{showFormElements:e,productIsPurchasable:t,productHasOptions:r,product:
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[9],{100:function(e,t,r){"use strict";var s=r(0);r(161),t.a=()=>Object(s.createElement)("span",{className:"wc-block-components-spinner","aria-hidden":"true"})},108:function(e,t,r){"use strict";r.d(t,"a",(function(){return n})),r.d(t,"b",(function(){return o}));var s=r(6);let a;!function(e){e.ADD_EVENT_CALLBACK="add_event_callback",e.REMOVE_EVENT_CALLBACK="remove_event_callback"}(a||(a={}));const n={addEventCallback:function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10;return{id:Object(s.uniqueId)(),type:a.ADD_EVENT_CALLBACK,eventType:e,callback:t,priority:r}},removeEventCallback:(e,t)=>({id:t,type:a.REMOVE_EVENT_CALLBACK,eventType:e})},c={},o=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:c,{type:t,eventType:r,id:s,callback:n,priority:o}=arguments.length>1?arguments[1]:void 0;const i=e.hasOwnProperty(r)?new Map(e[r]):new Map;switch(t){case a.ADD_EVENT_CALLBACK:return i.set(s,{priority:o,callback:n}),{...e,[r]:i};case a.REMOVE_EVENT_CALLBACK:return i.delete(s),{...e,[r]:i}}}},114:function(e,t,r){"use strict";r.d(t,"b",(function(){return i})),r.d(t,"a",(function(){return l}));var s=r(0),a=r(6),n=r(26),c=r.n(n);const o=Object(s.createContext)({getValidationError:()=>"",setValidationErrors:e=>{},clearValidationError:e=>{},clearAllValidationErrors:()=>{},hideValidationError:()=>{},showValidationError:()=>{},showAllValidationErrors:()=>{},hasValidationErrors:!1,getValidationErrorId:e=>e}),i=()=>Object(s.useContext)(o),l=e=>{let{children:t}=e;const[r,n]=Object(s.useState)({}),i=Object(s.useCallback)(e=>r[e],[r]),l=Object(s.useCallback)(e=>{const t=r[e];return!t||t.hidden?"":"validate-error-"+e},[r]),u=Object(s.useCallback)(e=>{n(t=>{if(!t[e])return t;const{[e]:r,...s}=t;return s})},[]),d=Object(s.useCallback)(()=>{n({})},[]),b=Object(s.useCallback)(e=>{e&&n(t=>(e=Object(a.pickBy)(e,(e,r)=>!("string"!=typeof e.message||t.hasOwnProperty(r)&&c()(t[r],e))),0===Object.values(e).length?t:{...t,...e}))},[]),E=Object(s.useCallback)((e,t)=>{n(r=>{if(!r.hasOwnProperty(e))return r;const s={...r[e],...t};return c()(r[e],s)?r:{...r,[e]:s}})},[]),p={getValidationError:i,setValidationErrors:b,clearValidationError:u,clearAllValidationErrors:d,hideValidationError:Object(s.useCallback)(e=>{E(e,{hidden:!0})},[E]),showValidationError:Object(s.useCallback)(e=>{E(e,{hidden:!1})},[E]),showAllValidationErrors:Object(s.useCallback)(()=>{n(e=>{const t={};return Object.keys(e).forEach(r=>{e[r].hidden&&(t[r]={...e[r],hidden:!1})}),0===Object.values(t).length?e:{...e,...t}})},[]),hasValidationErrors:Object.keys(r).length>0,getValidationErrorId:l};return Object(s.createElement)(o.Provider,{value:p},t)}},160:function(e,t){},161:function(e,t){},162:function(e,t){},196:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));var s=r(0),a=(r(10),r(114));r(162);const n=e=>{let{errorMessage:t="",propertyName:r="",elementId:n=""}=e;const{getValidationError:c,getValidationErrorId:o}=Object(a.b)();if(!t||"string"!=typeof t){const e=c(r)||{};if(!e.message||e.hidden)return null;t=e.message}return Object(s.createElement)("div",{className:"wc-block-components-validation-error",role:"alert"},Object(s.createElement)("p",{id:o(n)},t))}},247:function(e,t){},254:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var s=r(108);const a=(e,t)=>function(r){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;const n=s.a.addEventCallback(e,r,a);return t(n),()=>{t(s.a.removeEventCallback(e,n.id))}}},255:function(e,t,r){"use strict";t.a={showFormElements:{type:"boolean",default:!1},productId:{type:"number",default:0}}},256:function(e,t,r){"use strict";var s=r(0),a=(r(10),r(4)),n=r.n(a),c=r(1),o=r(39),i=r(477);const l={PRISTINE:"pristine",IDLE:"idle",DISABLED:"disabled",PROCESSING:"processing",BEFORE_PROCESSING:"before_processing",AFTER_PROCESSING:"after_processing"},u={status:l.PRISTINE,hasError:!1,quantity:0,processingResponse:null,requestParams:{}},d={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:b,SET_IDLE:E,SET_DISABLED:p,SET_PROCESSING:m,SET_BEFORE_PROCESSING:O,SET_AFTER_PROCESSING:_,SET_PROCESSING_RESPONSE:h,SET_HAS_ERROR:j,SET_NO_ERROR:f,SET_QUANTITY:S,SET_REQUEST_PARAMS:g}=d,v=()=>({type:E}),y=function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const t=e?j:f;return{type:t}},{SET_PRISTINE:R,SET_IDLE:P,SET_DISABLED:C,SET_PROCESSING:A,SET_BEFORE_PROCESSING:k,SET_AFTER_PROCESSING:T,SET_PROCESSING_RESPONSE:w,SET_HAS_ERROR:N,SET_NO_ERROR:I,SET_QUANTITY:D,SET_REQUEST_PARAMS:F}=d,{PRISTINE:V,IDLE:B,DISABLED:L,PROCESSING:q,BEFORE_PROCESSING:x,AFTER_PROCESSING:G}=l,M=function(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:u,{quantity:r,type:s,data:a}=arguments.length>1?arguments[1]:void 0;switch(s){case R:e=u;break;case P:e=t.status!==B?{...t,status:B}:t;break;case C:e=t.status!==L?{...t,status:L}:t;break;case D:e=r!==t.quantity?{...t,quantity:r}:t;break;case F:e={...t,requestParams:{...t.requestParams,...a}};break;case w:e={...t,processingResponse:a};break;case A:e=t.status!==q?{...t,status:q,hasError:!1}:t,e=!1===e.hasError?e:{...e,hasError:!1};break;case k:e=t.status!==x?{...t,status:x,hasError:!1}:t;break;case T:e=t.status!==G?{...t,status:G}:t;break;case N:e=t.hasError?t:{...t,hasError:!0},e=t.status===q||t.status===x?{...e,status:B}:e;break;case I:e=t.hasError?{...t,hasError:!1}:t}return e!==t&&s!==R&&e.status===V&&(e.status=B),e};var Q=r(108),H=r(254);const W=e=>({onAddToCartAfterProcessingWithSuccess:Object(H.a)("add_to_cart_after_processing_with_success",e),onAddToCartProcessingWithError:Object(H.a)("add_to_cart_after_processing_with_error",e),onAddToCartBeforeProcessing:Object(H.a)("add_to_cart_before_processing",e)});var U=r(257),K=r(114),Y=r(47),z=r(44);const J=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=>{}}}),X=()=>Object(s.useContext)(J),Z=e=>{var t,r,a,n;let{children:d,product:E,showFormElements:j}=e;const[f,R]=Object(s.useReducer)(M,u),[P,C]=Object(s.useReducer)(Q.b,{}),A=Object(o.a)(P),{addErrorNotice:k,removeNotices:T}=Object(Y.a)(),{setValidationErrors:w}=Object(K.b)(),{isSuccessResponse:N,isErrorResponse:I,isFailResponse:D}=Object(z.c)(),F=Object(s.useMemo)(()=>({onAddToCartAfterProcessingWithSuccess:W(C).onAddToCartAfterProcessingWithSuccess,onAddToCartAfterProcessingWithError:W(C).onAddToCartAfterProcessingWithError,onAddToCartBeforeProcessing:W(C).onAddToCartBeforeProcessing}),[C]),V=Object(s.useMemo)(()=>({resetForm:()=>{R({type:b})},submitForm:()=>{R({type:O})},setQuantity:e=>{R((e=>({type:S,quantity:e}))(e))},setHasError:e=>{R(y(e))},setRequestParams:e=>{R((e=>({type:g,data:e}))(e))},setAfterProcessing:e=>{R({type:h,data:e}),R({type:_})}}),[]);Object(s.useEffect)(()=>{const e=f.status,t=!E.id||!Object(i.a)(E);e!==l.DISABLED||t?e!==l.DISABLED&&t&&R({type:p}):R(v())},[f.status,E,R]),Object(s.useEffect)(()=>{f.status===l.BEFORE_PROCESSING&&(T("error"),Object(U.a)(A,"add_to_cart_before_processing",{}).then(e=>{!0!==e?(Array.isArray(e)&&e.forEach(e=>{let{errorMessage:t,validationErrors:r}=e;t&&k(t),r&&w(r)}),R(v())):R({type:m})}))},[f.status,w,k,T,R,A]),Object(s.useEffect)(()=>{if(f.status===l.AFTER_PROCESSING){const e={processingResponse:f.processingResponse},t=e=>{let t=!1;return e.forEach(e=>{const{message:r,messageContext:s}=e;(I(e)||D(e))&&r&&(t=!0,k(r,s?{context:s}:void 0))}),t};if(f.hasError)return void Object(U.b)(A,"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(c.__)("Something went wrong. Please contact us to get assistance.","woo-gutenberg-products-block");k(t,{id:"add-to-cart"})}R(v())});Object(U.b)(A,"add_to_cart_after_processing_with_success",e).then(e=>{t(e)?R(y(!0)):R(v())})}},[f.status,f.hasError,f.processingResponse,V,k,I,D,N,A]);const B=Object(i.b)(E),L={product:E,productType:E.type||"simple",productIsPurchasable:Object(i.a)(E),productHasOptions:E.has_options||!1,supportsFormElements:B,showFormElements:j&&B,quantity:f.quantity||(null==E||null===(t=E.add_to_cart)||void 0===t?void 0:t.minimum)||1,minQuantity:(null==E||null===(r=E.add_to_cart)||void 0===r?void 0:r.minimum)||1,maxQuantity:(null==E||null===(a=E.add_to_cart)||void 0===a?void 0:a.maximum)||99,multipleOf:(null==E||null===(n=E.add_to_cart)||void 0===n?void 0:n.multiple_of)||1,requestParams:f.requestParams,isIdle:f.status===l.IDLE,isDisabled:f.status===l.DISABLED,isProcessing:f.status===l.PROCESSING,isBeforeProcessing:f.status===l.BEFORE_PROCESSING,isAfterProcessing:f.status===l.AFTER_PROCESSING,hasError:f.hasError,eventRegistration:F,dispatchActions:V};return Object(s.createElement)(J.Provider,{value:L},d)};var $=r(11),ee=r.n($),te=r(14),re=r(36),se=()=>{const{dispatchActions:e,product:t,quantity:r,eventRegistration:a,hasError:n,isProcessing:o,requestParams:i}=X(),{hasValidationErrors:l,showAllValidationErrors:u}=Object(K.b)(),{addErrorNotice:d,removeNotice:b}=Object(Y.a)(),{receiveCart:E}=Object(re.a)(),[p,m]=Object(s.useState)(!1),O=!n&&o,_=Object(s.useCallback)(()=>!l||(u(),{type:"error"}),[l,u]);Object(s.useEffect)(()=>{const e=a.onAddToCartBeforeProcessing(_,0);return()=>{e()}},[a,_]);const h=Object(s.useCallback)(()=>{m(!0),b("add-to-cart");const s={id:t.id||0,quantity:r,...i};ee()({path:"/wc/store/cart/add-item",method:"POST",data:s,cache:"no-store",parse:!1}).then(t=>{ee.a.setNonce(t.headers),t.json().then((function(r){t.ok?E(r):(r.body&&r.body.message?d(Object(te.decodeEntities)(r.body.message),{id:"add-to-cart"}):d(Object(c.__)("Something went wrong. Please contact us to get assistance.","woo-gutenberg-products-block"),{id:"add-to-cart"}),e.setHasError()),e.setAfterProcessing(r),m(!1)}))}).catch(t=>{t.json().then((function(t){var r;null!==(r=t.data)&&void 0!==r&&r.cart&&E(t.data.cart),e.setHasError(),e.setAfterProcessing(t),m(!1)}))})},[t,d,b,E,e,r,i]);return Object(s.useEffect)(()=>{O&&!p&&h()},[O,h,p]),null};const ae=e=>{let{children:t,product:r,showFormElements:a}=e;return Object(s.createElement)(K.a,null,Object(s.createElement)(Z,{product:r,showFormElements:a},t,Object(s.createElement)(se,null)))};var ne=r(29),ce=r(6),oe=r(54),ie=(r(247),r(80)),le=r(43),ue=r(311),de=r(60),be=r(359);const Ee=e=>{let{className:t,href:r,text:a,onClick:n}=e;return Object(s.createElement)(ie.a,{className:t,href:r,onClick:n,rel:"nofollow"},a)},pe=e=>{let{className:t,quantityInCart:r,isProcessing:a,isDisabled:n,isDone:o,onClick:i}=e;return Object(s.createElement)(ie.a,{className:t,disabled:n,showSpinner:a,onClick:i},o&&r>0?Object(c.sprintf)(
|
2 |
/* translators: %s number of products in cart. */
|
3 |
+
Object(c._n)("%d in cart","%d in cart",r,"woo-gutenberg-products-block"),r):Object(c.__)("Add to cart","woo-gutenberg-products-block"),!!o&&Object(s.createElement)(le.a,{srcElement:ue.a,alt:Object(c.__)("Done","woo-gutenberg-products-block")}))};var me=()=>{const{showFormElements:e,productIsPurchasable:t,productHasOptions:r,product:a,productType:n,isDisabled:o,isProcessing:i,eventRegistration:l,hasError:u,dispatchActions:d}=X(),{parentName:b}=Object(ne.useInnerBlockLayoutContext)(),{dispatchStoreEvent:E}=Object(de.a)(),{cartQuantity:p}=Object(be.a)(a.id||0),[m,O]=Object(s.useState)(!1),_=a.add_to_cart||{url:"",text:""};return Object(s.useEffect)(()=>{const e=l.onAddToCartAfterProcessingWithSuccess(()=>(u||O(!0),!0),0);return()=>{e()}},[l,u]),(e||!r&&"simple"===n)&&t?Object(s.createElement)(pe,{className:"wc-block-components-product-add-to-cart-button",quantityInCart:p,isDisabled:o,isProcessing:i,isDone:m,onClick:()=>{d.submitForm(),E("cart-add-item",{product:a,listName:b})}}):Object(s.createElement)(Ee,{className:"wc-block-components-product-add-to-cart-button",href:_.url,text:_.text||Object(c.__)("View Product","woo-gutenberg-products-block"),onClick:()=>{E("product-view-link",{product:a,listName:b})}})},Oe=r(118),_e=e=>{let{disabled:t,min:r,max:a,step:n=1,value:c,onChange:o}=e;const i=void 0!==a,l=Object(Oe.a)(e=>{let t=e;i&&(t=Math.min(t,Math.floor(a/n)*n)),t=Math.max(t,Math.ceil(r/n)*n),t=Math.floor(t/n)*n,t!==e&&o(t)},300);return Object(s.createElement)("input",{className:"wc-block-components-product-add-to-cart-quantity",type:"number",value:c,min:r,max:a,step:n,hidden:1===a,disabled:t,onChange:e=>{o(e.target.value),l(e.target.value)}})},he=e=>{let{reason:t=Object(c.__)("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)},je=()=>{const{product:e,quantity:t,minQuantity:r,maxQuantity:a,multipleOf:n,dispatchActions:o,isDisabled:i}=X();return e.id&&!e.is_purchasable?Object(s.createElement)(he,null):e.id&&!e.is_in_stock?Object(s.createElement)(he,{reason:Object(c.__)("This product is currently out of stock and cannot be purchased.","woo-gutenberg-products-block")}):Object(s.createElement)(s.Fragment,null,Object(s.createElement)(_e,{value:t,min:r,max:a,step:n,disabled:i,onChange:o.setQuantity}),Object(s.createElement)(me,null))},fe=(r(310),r(498)),Se=r(8),ge=r(196);const ve={value:"",label:Object(c.__)("Select an option","woo-gutenberg-products-block")};var ye=e=>{let{attributeName:t,options:r=[],value:a="",onChange:o=(()=>{}),errorMessage:i=Object(c.__)("Please select a value.","woo-gutenberg-products-block")}=e;const{getValidationError:l,setValidationErrors:u,clearValidationError:d}=Object(K.b)(),b=t,E=l(b)||{};return Object(Se.useEffect)(()=>{a?d(b):u({[b]:{message:i,hidden:!0}})},[a,b,i,d,u]),Object(Se.useEffect)(()=>()=>{d(b)},[b,d]),Object(s.createElement)("div",{className:"wc-block-components-product-add-to-cart-attribute-picker__container"},Object(s.createElement)(fe.a,{label:Object(te.decodeEntities)(t),value:a||"",options:[ve,...r],onChange:o,required:!0,className:n()("wc-block-components-product-add-to-cart-attribute-picker__select",{"has-error":E.message&&!E.hidden})}),Object(s.createElement)(ge.a,{propertyName:b,elementId:b}))},Re=r(64);const Pe=(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 a=Object.keys(e);return s.filter(e=>a.every(s=>{const a=r[s]||"",n=t["id:"+e].attributes[s];return""===a||null===n||n===a}))};var Ce=e=>{let{attributes:t,variationAttributes:r,setRequestParams:a}=e;const n=Object(o.a)(t),c=Object(o.a)(r),[i,l]=Object(s.useState)(0),[u,d]=Object(s.useState)({}),[b,E]=Object(s.useState)(!1),p=Object(s.useMemo)(()=>((e,t,r)=>{const s={},a=Object.keys(e),n=Object.values(r).filter(Boolean).length>0;return a.forEach(a=>{const c=e[a],o={...r,[a]:null},i=n?Pe(e,t,o):null,l=null!==i?i.map(e=>t["id:"+e].attributes[a]):null;s[a]=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(te.decodeEntities)(r)}:null}).filter(Boolean)}(c.terms,l)}),s})(n,c,u),[u,n,c]);return Object(s.useEffect)(()=>{if(!b){const e=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!Object(Re.b)(e))return{};const t=Object.keys(e),r={};return 0===t.length||t.forEach(t=>{const s=e[t],a=s.terms.filter(e=>e.default);var n;a.length>0&&(r[s.name]=null===(n=a[0])||void 0===n?void 0:n.slug)}),r}(t);e&&d({...e}),E(!0)}},[u,t,b]),Object(s.useEffect)(()=>{Object.values(u).filter(e=>""!==e).length===Object.keys(n).length?l(((e,t,r)=>Pe(e,t,r)[0]||0)(n,c,u)):i>0&&l(0)},[u,i,n,c]),Object(s.useEffect)(()=>{a({id:i,variation:Object.keys(u).map(e=>({attribute:e,value:u[e]}))})},[a,i,u]),Object(s.createElement)("div",{className:"wc-block-components-product-add-to-cart-attribute-picker"},Object.keys(n).map(e=>Object(s.createElement)(ye,{key:e,attributeName:e,options:p[e],value:u[e],onChange:t=>{d({...u,[e]:t})}})))},Ae=e=>{let{product:t,dispatchers:r}=e;const a=(e=>e?Object(ce.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: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(a).length||0===n.length?null:Object(s.createElement)(Ce,{attributes:a,variationAttributes:n,setRequestParams:r.setRequestParams})},ke=()=>{const{product:e,quantity:t,minQuantity:r,maxQuantity:a,multipleOf:n,dispatchActions:o,isDisabled:i}=X();return e.id&&!e.is_purchasable?Object(s.createElement)(he,null):e.id&&!e.is_in_stock?Object(s.createElement)(he,{reason:Object(c.__)("This product is currently out of stock and cannot be purchased.","woo-gutenberg-products-block")}):Object(s.createElement)(s.Fragment,null,Object(s.createElement)(Ae,{product:e,dispatchers:o}),Object(s.createElement)(_e,{value:t,min:r,max:a,step:n,disabled:i,onChange:o.setQuantity}),Object(s.createElement)(me,null))},Te=()=>Object(s.createElement)(me,null),we=r(489),Ne=()=>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."),Ie=()=>Object(s.createElement)(Ne,null);const De=()=>{const{showFormElements:e,productType:t}=X();return e?"variable"===t?Object(s.createElement)(ke,null):"grouped"===t?Object(s.createElement)(Ie,null):"external"===t?Object(s.createElement)(Te,null):"simple"===t||"variation"===t?Object(s.createElement)(je,null):null:Object(s.createElement)(me,null)};t.a=Object(oe.withProductDataContext)(e=>{let{className:t,showFormElements:r}=e;const{product:a}=Object(ne.useProductDataContext)(),c=n()(t,"wc-block-components-product-add-to-cart",{"wc-block-components-product-add-to-cart--placeholder":Object(ce.isEmpty)(a)});return Object(s.createElement)(ae,{product:a,showFormElements:r},Object(s.createElement)("div",{className:c},Object(s.createElement)(De,null)))})},257:function(e,t,r){"use strict";r.d(t,"a",(function(){return n})),r.d(t,"b",(function(){return c}));const s=(e,t)=>e[t]?Array.from(e[t].values()).sort((e,t)=>e.priority-t.priority):[];var a=r(44);const n=async(e,t,r)=>{const a=s(e,t),n=[];for(const e of a)try{const t=await Promise.resolve(e.callback(r));"object"==typeof t&&n.push(t)}catch(e){console.error(e)}return!n.length||n},c=async(e,t,r)=>{const n=[],c=s(e,t);for(const e of c)try{const t=await Promise.resolve(e.callback(r));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(a.a)(t)||Object(a.b)(t))return n.push(t),n;n.push(t)}catch(e){return console.error(e),n.push({type:"error"}),n}return n}},310:function(e,t){},311:function(e,t,r){"use strict";var s=r(0),a=r(18);const n=Object(s.createElement)(a.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(s.createElement)("path",{fill:"none",d:"M0 0h24v24H0z"}),Object(s.createElement)("path",{d:"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"}));t.a=n},39:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var s=r(0),a=r(26),n=r.n(a);function c(e){const t=Object(s.useRef)(e);return n()(e,t.current)||(t.current=e),t.current}},44:function(e,t,r){"use strict";r.d(t,"a",(function(){return i})),r.d(t,"b",(function(){return l})),r.d(t,"c",(function(){return d}));var s=r(64);let a,n;!function(e){e.SUCCESS="success",e.FAIL="failure",e.ERROR="error"}(a||(a={})),function(e){e.PAYMENTS="wc/payment-area",e.EXPRESS_PAYMENTS="wc/express-payment-area"}(n||(n={}));const c=(e,t)=>Object(s.b)(e)&&"type"in e&&e.type===t,o=e=>c(e,a.SUCCESS),i=e=>c(e,a.ERROR),l=e=>c(e,a.FAIL),u=e=>!Object(s.b)(e)||void 0===e.retry||!0===e.retry,d=()=>({responseTypes:a,noticeContexts:n,shouldRetry:u,isSuccessResponse:o,isErrorResponse:i,isFailResponse:l})},477:function(e,t,r){"use strict";r.d(t,"a",(function(){return s})),r.d(t,"b",(function(){return a}));const s=e=>e.is_purchasable||!1,a=e=>["simple","variable"].includes(e.type||"simple")},503:function(e,t,r){"use strict";r.r(t);var s=r(54),a=r(256),n=r(255);t.default=Object(s.withFilteredAttributes)(n.a)(a.a)},80:function(e,t,r){"use strict";var s=r(5),a=r.n(s),n=r(0),c=r(139),o=r(4),i=r.n(o),l=r(100);r(160),t.a=e=>{let{className:t,showSpinner:r=!1,children:s,...o}=e;const u=i()("wc-block-components-button",t,{"wc-block-components-button--loading":r});return Object(n.createElement)(c.a,a()({className:u},o),r&&Object(n.createElement)(l.a,null),Object(n.createElement)("span",{className:"wc-block-components-button__text"},s))}}}]);
|
build/atomic-block-components/button-frontend.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[8],{
|
2 |
/* translators: %s number of products in cart. */
|
3 |
Object(i._n)("%d in cart","%d in cart",O,"woo-gutenberg-products-block"),O):Object(l.decodeEntities)((null==a?void 0:a.text)||Object(i.__)("Add to cart","woo-gutenberg-products-block")),v=w?"button":"a",N={};return w?N.onClick=()=>{j(),m("cart-add-item",{product:e})}:(N.href=o,N.rel="nofollow",N.onClick=()=>{m("product-view-link",{product:e})}),Object(r.createElement)(v,n()({"aria-label":g,className:d()("wp-block-button__link","add_to_cart_button","wc-block-components-product-button__button",{loading:_,added:k}),disabled:_},N),h)},m=()=>Object(r.createElement)("button",{className:d()("wp-block-button__link","add_to_cart_button","wc-block-components-product-button__button","wc-block-components-product-button__button--placeholder"),disabled:!0});e.default=Object(p.withProductDataContext)(t=>{let{className:e}=t;const{parentClassName:c}=Object(b.useInnerBlockLayoutContext)(),{product:o}=Object(b.useProductDataContext)();return Object(r.createElement)("div",{className:d()(e,"wp-block-button","wc-block-components-product-button",{[c+"__product-add-to-cart"]:c})},o.id?Object(r.createElement)(f,{product:o}):Object(r.createElement)(m,null))})}}]);
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[8],{317:function(t,e){},318:function(t,e,c){"use strict";c.d(e,"a",(function(){return u}));var o=c(0),n=c(9),r=c(6),a=c(19),d=c(22),i=c(32);const s=(t,e)=>{const c=t.find(t=>{let{id:c}=t;return c===e});return c?c.quantity:0},u=t=>{const{addItemToCart:e}=Object(n.useDispatch)(r.CART_STORE_KEY),{cartItems:c,cartIsLoading:u}=Object(d.a)(),{addErrorNotice:l,removeNotice:b}=Object(i.a)(),[p,f]=Object(o.useState)(!1),m=Object(o.useRef)(s(c,t));return Object(o.useEffect)(()=>{const e=s(c,t);e!==m.current&&(m.current=e)},[c,t]),{cartQuantity:Number.isFinite(m.current)?m.current:0,addingToCart:p,cartIsLoading:u,addToCart:function(){let c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return f(!0),e(t,c).then(()=>{b("add-to-cart")}).catch(t=>{l(Object(a.decodeEntities)(t.message),{context:"wc/all-products",id:"add-to-cart",isDismissible:!0})}).finally(()=>{f(!1)})}}}},32:function(t,e,c){"use strict";c.d(e,"a",(function(){return r}));var o=c(0),n=c(87);const r=()=>{const{notices:t,createNotice:e,removeNotice:c,setIsSuppressed:r}=Object(n.b)(),a=Object(o.useRef)(t);Object(o.useEffect)(()=>{a.current=t},[t]);const d=Object(o.useMemo)(()=>({hasNoticesOfType:t=>a.current.some(e=>e.type===t),removeNotices:function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;a.current.forEach(e=>{null!==t&&e.status!==t||c(e.id)})},removeNotice:c}),[c]),i=Object(o.useMemo)(()=>({addDefaultNotice:function(t){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e("default",t,{...c})},addErrorNotice:function(t){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e("error",t,{...c})},addWarningNotice:function(t){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e("warning",t,{...c})},addInfoNotice:function(t){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e("info",t,{...c})},addSuccessNotice:function(t){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e("success",t,{...c})}}),[e]);return{notices:t,...d,...i,setIsSuppressed:r}}},366:function(t,e,c){"use strict";c.r(e);var o=c(10),n=c.n(o),r=c(0),a=(c(8),c(4)),d=c.n(a),i=c(1),s=c(38),u=c(318),l=c(19),b=c(49),p=c(110);c(317);const f=t=>{let{product:e}=t;const{id:c,permalink:o,add_to_cart:a,has_options:b,is_purchasable:p,is_in_stock:f}=e,{dispatchStoreEvent:m}=Object(s.a)(),{cartQuantity:O,addingToCart:_,addToCart:j}=Object(u.a)(c),k=Number.isFinite(O)&&O>0,w=!b&&p&&f,g=Object(l.decodeEntities)((null==a?void 0:a.description)||""),h=k?Object(i.sprintf)(
|
2 |
/* translators: %s number of products in cart. */
|
3 |
Object(i._n)("%d in cart","%d in cart",O,"woo-gutenberg-products-block"),O):Object(l.decodeEntities)((null==a?void 0:a.text)||Object(i.__)("Add to cart","woo-gutenberg-products-block")),v=w?"button":"a",N={};return w?N.onClick=()=>{j(),m("cart-add-item",{product:e})}:(N.href=o,N.rel="nofollow",N.onClick=()=>{m("product-view-link",{product:e})}),Object(r.createElement)(v,n()({"aria-label":g,className:d()("wp-block-button__link","add_to_cart_button","wc-block-components-product-button__button",{loading:_,added:k}),disabled:_},N),h)},m=()=>Object(r.createElement)("button",{className:d()("wp-block-button__link","add_to_cart_button","wc-block-components-product-button__button","wc-block-components-product-button__button--placeholder"),disabled:!0});e.default=Object(p.withProductDataContext)(t=>{let{className:e}=t;const{parentClassName:c}=Object(b.useInnerBlockLayoutContext)(),{product:o}=Object(b.useProductDataContext)();return Object(r.createElement)("div",{className:d()(e,"wp-block-button","wc-block-components-product-button",{[c+"__product-add-to-cart"]:c})},o.id?Object(r.createElement)(f,{product:o}):Object(r.createElement)(m,null))})}}]);
|
build/atomic-block-components/button.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[
|
2 |
/* translators: %s number of products in cart. */
|
3 |
-
Object(l._n)("%d in cart","%d in cart",w,"woo-gutenberg-products-block"),w):Object(i.decodeEntities)((null==d?void 0:d.text)||Object(l.__)("Add to cart","woo-gutenberg-products-block")),f=C?"button":"a",g={};return C?g.onClick=()=>{j(),k("cart-add-item",{product:o})}:(g.href=e,g.rel="nofollow",g.onClick=()=>{k("product-view-link",{product:o})}),Object(a.createElement)(f,n()({"aria-label":E,className:r()("wp-block-button__link","add_to_cart_button","wc-block-components-product-button__button",{loading:m,added:O}),disabled:m},g),h)},k=()=>Object(a.createElement)("button",{className:r()("wp-block-button__link","add_to_cart_button","wc-block-components-product-button__button","wc-block-components-product-button__button--placeholder"),disabled:!0});o.default=Object(p.withProductDataContext)(t=>{let{className:o}=t;const{parentClassName:c}=Object(s.useInnerBlockLayoutContext)(),{product:e}=Object(s.useProductDataContext)();return Object(a.createElement)("div",{className:r()(o,"wp-block-button","wc-block-components-product-button",{[c+"__product-add-to-cart"]:c})},e.id?Object(a.createElement)(_,{product:e}):Object(a.createElement)(k,null))})},
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[10],{264:function(t,o,c){"use strict";c.r(o);var e=c(5),n=c.n(e),a=c(0),d=(c(10),c(4)),r=c.n(d),l=c(1),b=c(60),u=c(359),i=c(14),s=c(29),p=c(54);c(304);const _=t=>{let{product:o}=t;const{id:c,permalink:e,add_to_cart:d,has_options:s,is_purchasable:p,is_in_stock:_}=o,{dispatchStoreEvent:k}=Object(b.a)(),{cartQuantity:w,addingToCart:m,addToCart:j}=Object(u.a)(c),O=Number.isFinite(w)&&w>0,C=!s&&p&&_,E=Object(i.decodeEntities)((null==d?void 0:d.description)||""),h=O?Object(l.sprintf)(
|
2 |
/* translators: %s number of products in cart. */
|
3 |
+
Object(l._n)("%d in cart","%d in cart",w,"woo-gutenberg-products-block"),w):Object(i.decodeEntities)((null==d?void 0:d.text)||Object(l.__)("Add to cart","woo-gutenberg-products-block")),f=C?"button":"a",g={};return C?g.onClick=()=>{j(),k("cart-add-item",{product:o})}:(g.href=e,g.rel="nofollow",g.onClick=()=>{k("product-view-link",{product:o})}),Object(a.createElement)(f,n()({"aria-label":E,className:r()("wp-block-button__link","add_to_cart_button","wc-block-components-product-button__button",{loading:m,added:O}),disabled:m},g),h)},k=()=>Object(a.createElement)("button",{className:r()("wp-block-button__link","add_to_cart_button","wc-block-components-product-button__button","wc-block-components-product-button__button--placeholder"),disabled:!0});o.default=Object(p.withProductDataContext)(t=>{let{className:o}=t;const{parentClassName:c}=Object(s.useInnerBlockLayoutContext)(),{product:e}=Object(s.useProductDataContext)();return Object(a.createElement)("div",{className:r()(o,"wp-block-button","wc-block-components-product-button",{[c+"__product-add-to-cart"]:c})},e.id?Object(a.createElement)(_,{product:e}):Object(a.createElement)(k,null))})},304:function(t,o){}}]);
|
build/atomic-block-components/category-list-frontend.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[9],{
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[9],{321:function(e,t){},369:function(e,t,c){"use strict";c.r(t);var o=c(0),a=c(1),n=c(4),l=c.n(n),r=c(49),s=c(5),u=c(110);c(321),t.default=Object(u.withProductDataContext)(e=>{let{className:t}=e;const{parentClassName:c}=Object(r.useInnerBlockLayoutContext)(),{product:n}=Object(r.useProductDataContext)();return Object(s.isEmpty)(n.categories)?null:Object(o.createElement)("div",{className:l()(t,"wc-block-components-product-category-list",{[c+"__product-category-list"]:c})},Object(a.__)("Categories:","woo-gutenberg-products-block")," ",Object(o.createElement)("ul",null,Object.values(n.categories).map(e=>{let{name:t,link:c,slug:a}=e;return Object(o.createElement)("li",{key:"category-list-item-"+a},Object(o.createElement)("a",{href:c},t))})))})}}]);
|
build/atomic-block-components/category-list.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[11],{267:function(e,t,c){"use strict";c.r(t);var o=c(0),a=c(1),n=c(4),l=c.n(n),r=c(29),s=c(6),u=c(54);c(307),t.default=Object(u.withProductDataContext)(e=>{let{className:t}=e;const{parentClassName:c}=Object(r.useInnerBlockLayoutContext)(),{product:n}=Object(r.useProductDataContext)();return Object(s.isEmpty)(n.categories)?null:Object(o.createElement)("div",{className:l()(t,"wc-block-components-product-category-list",{[c+"__product-category-list"]:c})},Object(a.__)("Categories:","woo-gutenberg-products-block")," ",Object(o.createElement)("ul",null,Object.values(n.categories).map(e=>{let{name:t,link:c,slug:a}=e;return Object(o.createElement)("li",{key:"category-list-item-"+a},Object(o.createElement)("a",{href:c},t))})))})},307:function(e,t){}}]);
|
build/atomic-block-components/image-frontend.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[10,13],{21:function(e,t,a){"use strict";var c=a(0),n=a(4),l=a.n(n);t.a=e=>{let t,{label:a,screenReaderLabel:n,wrapperElement:r,wrapperProps:o={}}=e;const s=null!=a,i=null!=n;return!s&&i?(t=r||"span",o={...o,className:l()(o.className,"screen-reader-text")},Object(c.createElement)(t,o,n)):(t=r||c.Fragment,s&&i&&a!==n?Object(c.createElement)(t,o,Object(c.createElement)("span",{"aria-hidden":"true"},a),Object(c.createElement)("span",{className:"screen-reader-text"},n)):Object(c.createElement)(t,o,a))}},
|
2 |
/* translators: %s is referring to the product name */
|
3 |
Object(o.__)("Link to %s","woo-gutenberg-products-block"),u.name),_={href:u.permalink,rel:"nofollow",...!f&&{"aria-label":E},onClick:()=>{w("product-view-link",{product:u})}};return Object(r.createElement)("div",{className:i()(t,"wc-block-components-product-image",{[s+"__product-image"]:s})},Object(r.createElement)(k,c&&_,!!n&&Object(r.createElement)(m.default,{align:l,product:u}),Object(r.createElement)(g,{fallbackAlt:u.name,image:h,onLoad:()=>j(!0),loaded:O,showFullSize:"cropped"!==a})))});t.default=Object(c.withFilteredAttributes)({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}})(O)}}]);
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[10,13],{21:function(e,t,a){"use strict";var c=a(0),n=a(4),l=a.n(n);t.a=e=>{let t,{label:a,screenReaderLabel:n,wrapperElement:r,wrapperProps:o={}}=e;const s=null!=a,i=null!=n;return!s&&i?(t=r||"span",o={...o,className:l()(o.className,"screen-reader-text")},Object(c.createElement)(t,o,n)):(t=r||c.Fragment,s&&i&&a!==n?Object(c.createElement)(t,o,Object(c.createElement)("span",{"aria-hidden":"true"},a),Object(c.createElement)("span",{className:"screen-reader-text"},n)):Object(c.createElement)(t,o,a))}},270:function(e,t){},288:function(e,t,a){"use strict";a.r(t);var c=a(0),n=(a(8),a(1)),l=a(4),r=a.n(l),o=a(21),s=a(49),i=a(110);a(270),t.default=Object(i.withProductDataContext)(e=>{let{className:t,align:a}=e;const{parentClassName:l}=Object(s.useInnerBlockLayoutContext)(),{product:i}=Object(s.useProductDataContext)();if(!i.id||!i.on_sale)return null;const u="string"==typeof a?"wc-block-components-product-sale-badge--align-"+a:"";return Object(c.createElement)("div",{className:r()("wc-block-components-product-sale-badge",t,u,{[l+"__product-onsale"]:l})},Object(c.createElement)(o.a,{label:Object(n.__)("Sale","woo-gutenberg-products-block"),screenReaderLabel:Object(n.__)("Product on sale","woo-gutenberg-products-block")}))})},314:function(e,t){},397:function(e,t,a){"use strict";a.r(t);var c=a(110),n=a(10),l=a.n(n),r=a(0),o=(a(8),a(1)),s=a(4),i=a.n(s),u=a(2),d=a(49),b=a(38),m=a(288);a(314);const p=()=>Object(r.createElement)("img",{src:u.PLACEHOLDER_IMG_SRC,alt:"",width:500,height:500}),g=e=>{let{image:t,onLoad:a,loaded:c,showFullSize:n,fallbackAlt:o}=e;const{thumbnail:s,src:i,srcset:u,sizes:d,alt:b}=t||{},m={alt:b||o,onLoad:a,hidden:!c,src:s,...n&&{src:i,srcSet:u,sizes:d}};return Object(r.createElement)(r.Fragment,null,m.src&&Object(r.createElement)("img",l()({"data-testid":"product-image"},m)),!c&&Object(r.createElement)(p,null))};var O=Object(c.withProductDataContext)(e=>{let{className:t,imageSizing:a="full-size",showProductLink:c=!0,showSaleBadge:n,saleBadgeAlign:l="right"}=e;const{parentClassName:s}=Object(d.useInnerBlockLayoutContext)(),{product:u}=Object(d.useProductDataContext)(),[O,j]=Object(r.useState)(!1),{dispatchStoreEvent:w}=Object(b.a)();if(!u.id)return Object(r.createElement)("div",{className:i()(t,"wc-block-components-product-image","wc-block-components-product-image--placeholder",{[s+"__product-image"]:s})},Object(r.createElement)(p,null));const f=!!u.images.length,h=f?u.images[0]:null,k=c?"a":r.Fragment,E=Object(o.sprintf)(
|
2 |
/* translators: %s is referring to the product name */
|
3 |
Object(o.__)("Link to %s","woo-gutenberg-products-block"),u.name),_={href:u.permalink,rel:"nofollow",...!f&&{"aria-label":E},onClick:()=>{w("product-view-link",{product:u})}};return Object(r.createElement)("div",{className:i()(t,"wc-block-components-product-image",{[s+"__product-image"]:s})},Object(r.createElement)(k,c&&_,!!n&&Object(r.createElement)(m.default,{align:l,product:u}),Object(r.createElement)(g,{fallbackAlt:u.name,image:h,onLoad:()=>j(!0),loaded:O,showFullSize:"cropped"!==a})))});t.default=Object(c.withFilteredAttributes)({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}})(O)}}]);
|
build/atomic-block-components/image.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[
|
2 |
/* translators: %s is referring to the product name */
|
3 |
-
Object(o.__)("Link to %s","woo-gutenberg-products-block"),d.name),S={href:d.permalink,rel:"nofollow",...!O&&{"aria-label":E},onClick:()=>{f("product-view-link",{product:d})}};return Object(n.createElement)("div",{className:i()(t,"wc-block-components-product-image",{[s+"__product-image"]:s})},Object(n.createElement)(k,c&&S,!!l&&Object(n.createElement)(b.default,{align:r,product:d}),Object(n.createElement)(p,{fallbackAlt:d.name,image:j,onLoad:()=>h(!0),loaded:w,showFullSize:"cropped"!==a})))})},
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[12],{252:function(e,t,a){"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}}},253:function(e,t,a){"use strict";var c=a(5),l=a.n(c),n=a(0),o=(a(10),a(1)),r=a(4),i=a.n(r),s=a(2),u=a(29),d=a(54),m=a(60),b=a(195);a(302);const g=()=>Object(n.createElement)("img",{src:s.PLACEHOLDER_IMG_SRC,alt:"",width:500,height:500}),p=e=>{let{image:t,onLoad:a,loaded:c,showFullSize:o,fallbackAlt:r}=e;const{thumbnail:i,src:s,srcset:u,sizes:d,alt:m}=t||{},b={alt:m||r,onLoad:a,hidden:!c,src:i,...o&&{src:s,srcSet:u,sizes:d}};return Object(n.createElement)(n.Fragment,null,b.src&&Object(n.createElement)("img",l()({"data-testid":"product-image"},b)),!c&&Object(n.createElement)(g,null))};t.a=Object(d.withProductDataContext)(e=>{let{className:t,imageSizing:a="full-size",showProductLink:c=!0,showSaleBadge:l,saleBadgeAlign:r="right"}=e;const{parentClassName:s}=Object(u.useInnerBlockLayoutContext)(),{product:d}=Object(u.useProductDataContext)(),[w,h]=Object(n.useState)(!1),{dispatchStoreEvent:f}=Object(m.a)();if(!d.id)return Object(n.createElement)("div",{className:i()(t,"wc-block-components-product-image","wc-block-components-product-image--placeholder",{[s+"__product-image"]:s})},Object(n.createElement)(g,null));const O=!!d.images.length,j=O?d.images[0]:null,k=c?"a":n.Fragment,E=Object(o.sprintf)(
|
2 |
/* translators: %s is referring to the product name */
|
3 |
+
Object(o.__)("Link to %s","woo-gutenberg-products-block"),d.name),S={href:d.permalink,rel:"nofollow",...!O&&{"aria-label":E},onClick:()=>{f("product-view-link",{product:d})}};return Object(n.createElement)("div",{className:i()(t,"wc-block-components-product-image",{[s+"__product-image"]:s})},Object(n.createElement)(k,c&&S,!!l&&Object(n.createElement)(b.default,{align:r,product:d}),Object(n.createElement)(p,{fallbackAlt:d.name,image:j,onLoad:()=>h(!0),loaded:w,showFullSize:"cropped"!==a})))})},302:function(e,t){},501:function(e,t,a){"use strict";a.r(t);var c=a(54),l=a(253),n=a(252);t.default=Object(c.withFilteredAttributes)(n.a)(l.a)}}]);
|
build/atomic-block-components/price-frontend.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[11],{159:function(e,c){},
|
2 |
/* translators: %1$s min price, %2$s max price */
|
3 |
-
Object(a.__)("Price between %1$s and %2$s","woo-gutenberg-products-block"),Object(i.formatPrice)(l),Object(i.formatPrice)(r))),Object(t.createElement)("span",{"aria-hidden":!0},Object(t.createElement)(n.a,{className:o()("wc-block-components-product-price__value",s),currency:c,value:l,style:u})," — ",Object(t.createElement)(n.a,{className:o()("wc-block-components-product-price__value",s),currency:c,value:r,style:u})))},u=e=>{let{currency:c,regularPriceClassName:r,regularPriceStyle:l,regularPrice:i,priceClassName:s,priceStyle:u,price:m}=e;return Object(t.createElement)(t.Fragment,null,Object(t.createElement)("span",{className:"screen-reader-text"},Object(a.__)("Previous price:","woo-gutenberg-products-block")),Object(t.createElement)(n.a,{currency:c,renderText:e=>Object(t.createElement)("del",{className:o()("wc-block-components-product-price__regular",r),style:l},e),value:i}),Object(t.createElement)("span",{className:"screen-reader-text"},Object(a.__)("Discounted price:","woo-gutenberg-products-block")),Object(t.createElement)(n.a,{currency:c,renderText:e=>Object(t.createElement)("ins",{className:o()("wc-block-components-product-price__value","is-discounted",s),style:u},e),value:m}))};c.a=e=>{let{align:c,className:r,currency:a,format:l="<price/>",maxPrice:i,minPrice:m,price:p,priceClassName:b,priceStyle:d,regularPrice:g,regularPriceClassName:j,regularPriceStyle:O}=e;const _=o()(r,"price","wc-block-components-product-price",{["wc-block-components-product-price--align-"+c]:c});l.includes("<price/>")||(l="<price/>",console.error("Price formats need to include the `<price/>` tag."));const y=g&&p!==g;let N=Object(t.createElement)("span",{className:o()("wc-block-components-product-price__value",b)});return y?N=Object(t.createElement)(u,{currency:a,price:p,priceClassName:b,priceStyle:d,regularPrice:g,regularPriceClassName:j,regularPriceStyle:O}):void 0!==m&&void 0!==i?N=Object(t.createElement)(s,{currency:a,maxPrice:i,minPrice:m,priceClassName:b,priceStyle:d}):p&&(N=Object(t.createElement)(n.a,{className:o()("wc-block-components-product-price__value",b),currency:a,value:p,style:d})),Object(t.createElement)("span",{className:_},Object(t.createInterpolateElement)(l,{price:N}))}},
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[11],{159:function(e,c){},243:function(e,c,r){"use strict";r.d(c,"a",(function(){return a})),r(163);var t=r(65);const a=()=>t.m>1},247:function(e,c,r){"use strict";var t=r(0),a=r(1),n=r(96),l=r(4),o=r.n(l),i=r(40);r(248);const s=e=>{let{currency:c,maxPrice:r,minPrice:l,priceClassName:s,priceStyle:u={}}=e;return Object(t.createElement)(t.Fragment,null,Object(t.createElement)("span",{className:"screen-reader-text"},Object(a.sprintf)(
|
2 |
/* translators: %1$s min price, %2$s max price */
|
3 |
+
Object(a.__)("Price between %1$s and %2$s","woo-gutenberg-products-block"),Object(i.formatPrice)(l),Object(i.formatPrice)(r))),Object(t.createElement)("span",{"aria-hidden":!0},Object(t.createElement)(n.a,{className:o()("wc-block-components-product-price__value",s),currency:c,value:l,style:u})," — ",Object(t.createElement)(n.a,{className:o()("wc-block-components-product-price__value",s),currency:c,value:r,style:u})))},u=e=>{let{currency:c,regularPriceClassName:r,regularPriceStyle:l,regularPrice:i,priceClassName:s,priceStyle:u,price:m}=e;return Object(t.createElement)(t.Fragment,null,Object(t.createElement)("span",{className:"screen-reader-text"},Object(a.__)("Previous price:","woo-gutenberg-products-block")),Object(t.createElement)(n.a,{currency:c,renderText:e=>Object(t.createElement)("del",{className:o()("wc-block-components-product-price__regular",r),style:l},e),value:i}),Object(t.createElement)("span",{className:"screen-reader-text"},Object(a.__)("Discounted price:","woo-gutenberg-products-block")),Object(t.createElement)(n.a,{currency:c,renderText:e=>Object(t.createElement)("ins",{className:o()("wc-block-components-product-price__value","is-discounted",s),style:u},e),value:m}))};c.a=e=>{let{align:c,className:r,currency:a,format:l="<price/>",maxPrice:i,minPrice:m,price:p,priceClassName:b,priceStyle:d,regularPrice:g,regularPriceClassName:j,regularPriceStyle:O}=e;const _=o()(r,"price","wc-block-components-product-price",{["wc-block-components-product-price--align-"+c]:c});l.includes("<price/>")||(l="<price/>",console.error("Price formats need to include the `<price/>` tag."));const y=g&&p!==g;let N=Object(t.createElement)("span",{className:o()("wc-block-components-product-price__value",b)});return y?N=Object(t.createElement)(u,{currency:a,price:p,priceClassName:b,priceStyle:d,regularPrice:g,regularPriceClassName:j,regularPriceStyle:O}):void 0!==m&&void 0!==i?N=Object(t.createElement)(s,{currency:a,maxPrice:i,minPrice:m,priceClassName:b,priceStyle:d}):p&&(N=Object(t.createElement)(n.a,{className:o()("wc-block-components-product-price__value",b),currency:a,value:p,style:d})),Object(t.createElement)("span",{className:_},Object(t.createInterpolateElement)(l,{price:N}))}},248:function(e,c){},364:function(e,c,r){"use strict";r.r(c);var t=r(0),a=(r(8),r(4)),n=r.n(a),l=r(247),o=r(40),i=r(49),s=r(162),u=r(243),m=r(110);c.default=Object(m.withProductDataContext)(e=>{var c,r;let{className:a,align:m,fontSize:p,customFontSize:b,saleFontSize:d,customSaleFontSize:g,color:j,customColor:O,saleColor:_,customSaleColor:y}=e;const{parentClassName:N}=Object(i.useInnerBlockLayoutContext)(),{product:f}=Object(i.useProductDataContext)(),v=n()(a,{[N+"__product-price"]:N});if(!f.id)return Object(t.createElement)(l.a,{align:m,className:v});const P=Object(s.getColorClassName)("color",j),C=Object(s.getFontSizeClass)(p),S=Object(s.getColorClassName)("color",_),w=Object(s.getFontSizeClass)(d),x=n()({"has-text-color":j||O,"has-font-size":p||b,[P]:P,[C]:C}),E=n()({"has-text-color":_||y,"has-font-size":d||g,[S]:S,[w]:w}),k={color:O,fontSize:b},h={color:y,fontSize:g},z=f.prices,F=Object(o.getCurrencyFromPriceResponse)(z),D=z.price!==z.regular_price,T=D?n()({[N+"__product-price__value"]:N,[E]:Object(u.a)()}):n()({[N+"__product-price__value"]:N,[x]:Object(u.a)()}),B=D?h:k;return Object(t.createElement)(l.a,{align:m,className:v,currency:F,price:z.price,priceClassName:T,priceStyle:Object(u.a)()?B:{},minPrice:null==z||null===(c=z.price_range)||void 0===c?void 0:c.min_amount,maxPrice:null==z||null===(r=z.price_range)||void 0===r?void 0:r.max_amount,regularPrice:z.regular_price,regularPriceClassName:n()({[N+"__product-price__regular"]:N,[x]:Object(u.a)()}),regularPriceStyle:Object(u.a)()?k:{}})})},96:function(e,c,r){"use strict";var t=r(10),a=r.n(t),n=r(0),l=r(131),o=r(4),i=r.n(o);r(159);const s=e=>({thousandSeparator:e.thousandSeparator,decimalSeparator:e.decimalSeparator,decimalScale:e.minorUnit,fixedDecimalScale:!0,prefix:e.prefix,suffix:e.suffix,isNumericString:!0});c.a=e=>{let{className:c,value:r,currency:t,onValueChange:o,displayType:u="text",...m}=e;const p="string"==typeof r?parseInt(r,10):r;if(!Number.isFinite(p))return null;const b=p/10**t.minorUnit;if(!Number.isFinite(b))return null;const d=i()("wc-block-formatted-money-amount","wc-block-components-formatted-money-amount",c),g={...m,...s(t),value:void 0,currency:void 0,onValueChange:void 0},j=o?e=>{const c=+e.value*10**t.minorUnit;o(c)}:()=>{};return Object(n.createElement)(l.a,a()({className:d,displayType:u},g,{value:b,onValueChange:j}))}}}]);
|
build/atomic-block-components/price.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[
|
2 |
/* translators: %1$s min price, %2$s max price */
|
3 |
-
Object(a.__)("Price between %1$s and %2$s","woo-gutenberg-products-block"),Object(i.formatPrice)(l),Object(i.formatPrice)(r))),Object(t.createElement)("span",{"aria-hidden":!0},Object(t.createElement)(n.a,{className:o()("wc-block-components-product-price__value",s),currency:c,value:l,style:u})," — ",Object(t.createElement)(n.a,{className:o()("wc-block-components-product-price__value",s),currency:c,value:r,style:u})))},u=e=>{let{currency:c,regularPriceClassName:r,regularPriceStyle:l,regularPrice:i,priceClassName:s,priceStyle:u,price:m}=e;return Object(t.createElement)(t.Fragment,null,Object(t.createElement)("span",{className:"screen-reader-text"},Object(a.__)("Previous price:","woo-gutenberg-products-block")),Object(t.createElement)(n.a,{currency:c,renderText:e=>Object(t.createElement)("del",{className:o()("wc-block-components-product-price__regular",r),style:l},e),value:i}),Object(t.createElement)("span",{className:"screen-reader-text"},Object(a.__)("Discounted price:","woo-gutenberg-products-block")),Object(t.createElement)(n.a,{currency:c,renderText:e=>Object(t.createElement)("ins",{className:o()("wc-block-components-product-price__value","is-discounted",s),style:u},e),value:m}))};c.a=e=>{let{align:c,className:r,currency:a,format:l="<price/>",maxPrice:i,minPrice:m,price:p,priceClassName:b,priceStyle:d,regularPrice:g,regularPriceClassName:j,regularPriceStyle:O}=e;const _=o()(r,"price","wc-block-components-product-price",{["wc-block-components-product-price--align-"+c]:c});l.includes("<price/>")||(l="<price/>",console.error("Price formats need to include the `<price/>` tag."));const y=g&&p!==g;let N=Object(t.createElement)("span",{className:o()("wc-block-components-product-price__value",b)});return y?N=Object(t.createElement)(u,{currency:a,price:p,priceClassName:b,priceStyle:d,regularPrice:g,regularPriceClassName:j,regularPriceStyle:O}):void 0!==m&&void 0!==i?N=Object(t.createElement)(s,{currency:a,maxPrice:i,minPrice:m,priceClassName:b,priceStyle:d}):p&&(N=Object(t.createElement)(n.a,{className:o()("wc-block-components-product-price__value",b),currency:a,value:p,style:d})),Object(t.createElement)("span",{className:_},Object(t.createInterpolateElement)(l,{price:N}))}},
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[13],{106:function(e,c,r){"use strict";var t=r(0),a=r(1),n=r(41),l=r(4),o=r.n(l),i=r(35);r(158);const s=e=>{let{currency:c,maxPrice:r,minPrice:l,priceClassName:s,priceStyle:u={}}=e;return Object(t.createElement)(t.Fragment,null,Object(t.createElement)("span",{className:"screen-reader-text"},Object(a.sprintf)(
|
2 |
/* translators: %1$s min price, %2$s max price */
|
3 |
+
Object(a.__)("Price between %1$s and %2$s","woo-gutenberg-products-block"),Object(i.formatPrice)(l),Object(i.formatPrice)(r))),Object(t.createElement)("span",{"aria-hidden":!0},Object(t.createElement)(n.a,{className:o()("wc-block-components-product-price__value",s),currency:c,value:l,style:u})," — ",Object(t.createElement)(n.a,{className:o()("wc-block-components-product-price__value",s),currency:c,value:r,style:u})))},u=e=>{let{currency:c,regularPriceClassName:r,regularPriceStyle:l,regularPrice:i,priceClassName:s,priceStyle:u,price:m}=e;return Object(t.createElement)(t.Fragment,null,Object(t.createElement)("span",{className:"screen-reader-text"},Object(a.__)("Previous price:","woo-gutenberg-products-block")),Object(t.createElement)(n.a,{currency:c,renderText:e=>Object(t.createElement)("del",{className:o()("wc-block-components-product-price__regular",r),style:l},e),value:i}),Object(t.createElement)("span",{className:"screen-reader-text"},Object(a.__)("Discounted price:","woo-gutenberg-products-block")),Object(t.createElement)(n.a,{currency:c,renderText:e=>Object(t.createElement)("ins",{className:o()("wc-block-components-product-price__value","is-discounted",s),style:u},e),value:m}))};c.a=e=>{let{align:c,className:r,currency:a,format:l="<price/>",maxPrice:i,minPrice:m,price:p,priceClassName:b,priceStyle:d,regularPrice:g,regularPriceClassName:j,regularPriceStyle:O}=e;const _=o()(r,"price","wc-block-components-product-price",{["wc-block-components-product-price--align-"+c]:c});l.includes("<price/>")||(l="<price/>",console.error("Price formats need to include the `<price/>` tag."));const y=g&&p!==g;let N=Object(t.createElement)("span",{className:o()("wc-block-components-product-price__value",b)});return y?N=Object(t.createElement)(u,{currency:a,price:p,priceClassName:b,priceStyle:d,regularPrice:g,regularPriceClassName:j,regularPriceStyle:O}):void 0!==m&&void 0!==i?N=Object(t.createElement)(s,{currency:a,maxPrice:i,minPrice:m,priceClassName:b,priceStyle:d}):p&&(N=Object(t.createElement)(n.a,{className:o()("wc-block-components-product-price__value",b),currency:a,value:p,style:d})),Object(t.createElement)("span",{className:_},Object(t.createInterpolateElement)(l,{price:N}))}},140:function(e,c){},158:function(e,c){},262:function(e,c,r){"use strict";r.r(c);var t=r(0),a=(r(10),r(4)),n=r.n(a),l=r(106),o=r(35),i=r(29),s=r(7),u=r(70),m=r(54);c.default=Object(m.withProductDataContext)(e=>{var c,r;let{className:a,align:m,fontSize:p,customFontSize:b,saleFontSize:d,customSaleFontSize:g,color:j,customColor:O,saleColor:_,customSaleColor:y}=e;const{parentClassName:N}=Object(i.useInnerBlockLayoutContext)(),{product:v}=Object(i.useProductDataContext)(),f=n()(a,{[N+"__product-price"]:N});if(!v.id)return Object(t.createElement)(l.a,{align:m,className:f});const P=Object(s.getColorClassName)("color",j),C=Object(s.getFontSizeClass)(p),S=Object(s.getColorClassName)("color",_),w=Object(s.getFontSizeClass)(d),x=n()({"has-text-color":j||O,"has-font-size":p||b,[P]:P,[C]:C}),E=n()({"has-text-color":_||y,"has-font-size":d||g,[S]:S,[w]:w}),k={color:O,fontSize:b},h={color:y,fontSize:g},z=v.prices,F=Object(o.getCurrencyFromPriceResponse)(z),D=z.price!==z.regular_price,T=D?n()({[N+"__product-price__value"]:N,[E]:Object(u.b)()}):n()({[N+"__product-price__value"]:N,[x]:Object(u.b)()}),B=D?h:k;return Object(t.createElement)(l.a,{align:m,className:f,currency:F,price:z.price,priceClassName:T,priceStyle:Object(u.b)()?B:{},minPrice:null==z||null===(c=z.price_range)||void 0===c?void 0:c.min_amount,maxPrice:null==z||null===(r=z.price_range)||void 0===r?void 0:r.max_amount,regularPrice:z.regular_price,regularPriceClassName:n()({[N+"__product-price__regular"]:N,[x]:Object(u.b)()}),regularPriceStyle:Object(u.b)()?k:{}})})},41:function(e,c,r){"use strict";var t=r(5),a=r.n(t),n=r(0),l=r(134),o=r(4),i=r.n(o);r(140);const s=e=>({thousandSeparator:e.thousandSeparator,decimalSeparator:e.decimalSeparator,decimalScale:e.minorUnit,fixedDecimalScale:!0,prefix:e.prefix,suffix:e.suffix,isNumericString:!0});c.a=e=>{let{className:c,value:r,currency:t,onValueChange:o,displayType:u="text",...m}=e;const p="string"==typeof r?parseInt(r,10):r;if(!Number.isFinite(p))return null;const b=p/10**t.minorUnit;if(!Number.isFinite(b))return null;const d=i()("wc-block-formatted-money-amount","wc-block-components-formatted-money-amount",c),g={...m,...s(t),value:void 0,currency:void 0,onValueChange:void 0},j=o?e=>{const c=+e.value*10**t.minorUnit;o(c)}:()=>{};return Object(n.createElement)(l.a,a()({className:d,displayType:u},g,{value:b,onValueChange:j}))}}}]);
|
build/atomic-block-components/rating-frontend.js
CHANGED
@@ -1,3 +1,5 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[12],{
|
2 |
/* translators: %f is referring to the average rating value */
|
3 |
-
Object(
|
|
|
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[12],{316:function(t,e){},365:function(t,e,n){"use strict";n.r(e);var s=n(0),r=(n(8),n(1)),c=n(4),o=n.n(c),a=n(49),u=n(110);n(316);e.default=Object(u.withProductDataContext)(t=>{let{className:e}=t;const{parentClassName:n}=Object(a.useInnerBlockLayoutContext)(),{product:c}=Object(a.useProductDataContext)(),u=(t=>{const e=parseFloat(t.average_rating);return Number.isFinite(e)&&e>0?e:0})(c);if(!u)return null;const i={width:u/5*100+"%"},l=Object(r.sprintf)(
|
2 |
/* translators: %f is referring to the average rating value */
|
3 |
+
Object(r.__)("Rated %f out of 5","woo-gutenberg-products-block"),u),b=(t=>{const e=parseInt(t.review_count,10);return Number.isFinite(e)&&e>0?e:0})(c),p={__html:Object(r.sprintf)(
|
4 |
+
/* translators: %1$s is referring to the average rating value, %2$s is referring to the number of ratings */
|
5 |
+
Object(r._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",b,"woo-gutenberg-products-block"),Object(r.sprintf)('<strong class="rating">%f</strong>',u),Object(r.sprintf)('<span class="rating">%d</span>',b))};return Object(s.createElement)("div",{className:o()(e,"wc-block-components-product-rating",{[n+"__product-rating"]:n})},Object(s.createElement)("div",{className:o()("wc-block-components-product-rating__stars",n+"__product-rating__stars"),role:"img","aria-label":l},Object(s.createElement)("span",{style:i,dangerouslySetInnerHTML:p})))})}}]);
|
build/atomic-block-components/rating.js
CHANGED
@@ -1,3 +1,5 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[
|
2 |
/* translators: %f is referring to the average rating value */
|
3 |
-
Object(
|
|
|
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[14],{263:function(t,e,n){"use strict";n.r(e);var s=n(0),r=(n(10),n(1)),c=n(4),o=n.n(c),a=n(29),u=n(54);n(303);e.default=Object(u.withProductDataContext)(t=>{let{className:e}=t;const{parentClassName:n}=Object(a.useInnerBlockLayoutContext)(),{product:c}=Object(a.useProductDataContext)(),u=(t=>{const e=parseFloat(t.average_rating);return Number.isFinite(e)&&e>0?e:0})(c);if(!u)return null;const i={width:u/5*100+"%"},l=Object(r.sprintf)(
|
2 |
/* translators: %f is referring to the average rating value */
|
3 |
+
Object(r.__)("Rated %f out of 5","woo-gutenberg-products-block"),u),b=(t=>{const e=parseInt(t.review_count,10);return Number.isFinite(e)&&e>0?e:0})(c),p={__html:Object(r.sprintf)(
|
4 |
+
/* translators: %1$s is referring to the average rating value, %2$s is referring to the number of ratings */
|
5 |
+
Object(r._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",b,"woo-gutenberg-products-block"),Object(r.sprintf)('<strong class="rating">%f</strong>',u),Object(r.sprintf)('<span class="rating">%d</span>',b))};return Object(s.createElement)("div",{className:o()(e,"wc-block-components-product-rating",{[n+"__product-rating"]:n})},Object(s.createElement)("div",{className:o()("wc-block-components-product-rating__stars",n+"__product-rating__stars"),role:"img","aria-label":l},Object(s.createElement)("span",{style:i,dangerouslySetInnerHTML:p})))})},303:function(t,e){}}]);
|
build/atomic-block-components/sale-badge-frontend.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[13],{21:function(e,t,c){"use strict";var a=c(0),n=c(4),r=c.n(n);t.a=e=>{let t,{label:c,screenReaderLabel:n,wrapperElement:l,wrapperProps:s={}}=e;const o=null!=c,u=null!=n;return!o&&u?(t=l||"span",s={...s,className:r()(s.className,"screen-reader-text")},Object(a.createElement)(t,s,n)):(t=l||a.Fragment,o&&u&&c!==n?Object(a.createElement)(t,s,Object(a.createElement)("span",{"aria-hidden":"true"},c),Object(a.createElement)("span",{className:"screen-reader-text"},n)):Object(a.createElement)(t,s,c))}},
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[13],{21:function(e,t,c){"use strict";var a=c(0),n=c(4),r=c.n(n);t.a=e=>{let t,{label:c,screenReaderLabel:n,wrapperElement:l,wrapperProps:s={}}=e;const o=null!=c,u=null!=n;return!o&&u?(t=l||"span",s={...s,className:r()(s.className,"screen-reader-text")},Object(a.createElement)(t,s,n)):(t=l||a.Fragment,o&&u&&c!==n?Object(a.createElement)(t,s,Object(a.createElement)("span",{"aria-hidden":"true"},c),Object(a.createElement)("span",{className:"screen-reader-text"},n)):Object(a.createElement)(t,s,c))}},270:function(e,t){},288:function(e,t,c){"use strict";c.r(t);var a=c(0),n=(c(8),c(1)),r=c(4),l=c.n(r),s=c(21),o=c(49),u=c(110);c(270),t.default=Object(u.withProductDataContext)(e=>{let{className:t,align:c}=e;const{parentClassName:r}=Object(o.useInnerBlockLayoutContext)(),{product:u}=Object(o.useProductDataContext)();if(!u.id||!u.on_sale)return null;const b="string"==typeof c?"wc-block-components-product-sale-badge--align-"+c:"";return Object(a.createElement)("div",{className:l()("wc-block-components-product-sale-badge",t,b,{[r+"__product-onsale"]:r})},Object(a.createElement)(s.a,{label:Object(n.__)("Sale","woo-gutenberg-products-block"),screenReaderLabel:Object(n.__)("Product on sale","woo-gutenberg-products-block")}))})}}]);
|
build/atomic-block-components/sale-badge.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[5],{195:function(e,t,c){"use strict";c.r(t);var a=c(0),n=(c(10),c(1)),r=c(4),l=c.n(r),s=c(30),o=c(29),u=c(54);c(301),t.default=Object(u.withProductDataContext)(e=>{let{className:t,align:c}=e;const{parentClassName:r}=Object(o.useInnerBlockLayoutContext)(),{product:u}=Object(o.useProductDataContext)();if(!u.id||!u.on_sale)return null;const b="string"==typeof c?"wc-block-components-product-sale-badge--align-"+c:"";return Object(a.createElement)("div",{className:l()("wc-block-components-product-sale-badge",t,b,{[r+"__product-onsale"]:r})},Object(a.createElement)(s.a,{label:Object(n.__)("Sale","woo-gutenberg-products-block"),screenReaderLabel:Object(n.__)("Product on sale","woo-gutenberg-products-block")}))})},30:function(e,t,c){"use strict";var a=c(0),n=c(4),r=c.n(n);t.a=e=>{let t,{label:c,screenReaderLabel:n,wrapperElement:l,wrapperProps:s={}}=e;const o=null!=c,u=null!=n;return!o&&u?(t=l||"span",s={...s,className:r()(s.className,"screen-reader-text")},Object(a.createElement)(t,s,n)):(t=l||a.Fragment,o&&u&&c!==n?Object(a.createElement)(t,s,Object(a.createElement)("span",{"aria-hidden":"true"},c),Object(a.createElement)("span",{className:"screen-reader-text"},n)):Object(a.createElement)(t,s,c))}},301:function(e,t){}}]);
|
build/atomic-block-components/sku-frontend.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[14],{
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[14],{320:function(t,e){},368:function(t,e,c){"use strict";c.r(e);var o=c(0),n=c(1),s=(c(8),c(4)),u=c.n(s),a=c(49),r=c(110);c(320),e.default=Object(r.withProductDataContext)(t=>{let{className:e}=t;const{parentClassName:c}=Object(a.useInnerBlockLayoutContext)(),{product:s}=Object(a.useProductDataContext)(),r=s.sku;return r?Object(o.createElement)("div",{className:u()(e,"wc-block-components-product-sku",{[c+"__product-sku"]:c})},Object(n.__)("SKU:","woo-gutenberg-products-block")," ",Object(o.createElement)("strong",null,r)):null})}}]);
|
build/atomic-block-components/sku.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[15],{266:function(t,e,c){"use strict";c.r(e);var o=c(0),n=c(1),s=(c(10),c(4)),u=c.n(s),a=c(29),r=c(54);c(306),e.default=Object(r.withProductDataContext)(t=>{let{className:e}=t;const{parentClassName:c}=Object(a.useInnerBlockLayoutContext)(),{product:s}=Object(a.useProductDataContext)(),r=s.sku;return r?Object(o.createElement)("div",{className:u()(e,"wc-block-components-product-sku",{[c+"__product-sku"]:c})},Object(n.__)("SKU:","woo-gutenberg-products-block")," ",Object(o.createElement)("strong",null,r)):null})},306:function(t,e){}}]);
|
build/atomic-block-components/stock-indicator--atomic-block-components/summary--atomic-block-components/title.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[3],{113:function(t,e,n){"use strict";n.d(e,"b",(function(){return a})),n.d(e,"c",(function(){return l})),n.d(e,"a",(function(){return b}));var s=n(7),c=n(70),r=n(64),o=n(194);const i=t=>Object(r.c)(t)?JSON.parse(t)||{}:Object(r.b)(t)?t:{},a=t=>{if(!Object(c.b)()||!Object(o.a)())return{style:{}};const e=Object(r.b)(t)?t:{},n=i(e.style);return Object(s.__experimentalGetSpacingClassesAndStyles)({...e,style:n})},l=t=>{const e=Object(r.b)(t)?t:{},n=i(e.style),s=Object(r.b)(n.typography)?n.typography:{};return{style:{fontSize:e.fontSize||s.fontSize,lineHeight:s.lineHeight,fontWeight:s.fontWeight,textTransform:s.textTransform,fontFamily:e.fontFamily}}},b=t=>{if(!Object(c.b)())return{className:"",style:{}};const e=Object(r.b)(t)?t:{},n=i(e.style);return Object(s.__experimentalUseColorProps)({...e,style:n})}},194:function(t,e,n){"use strict";n.d(e,"a",(function(){return c}));var s=n(7);const c=()=>"function"==typeof s.__experimentalGetSpacingClassesAndStyles}}]);
|
build/atomic-block-components/stock-indicator-frontend.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[15],{
|
2 |
/* translators: %d stock amount (number of items in stock for product) */
|
3 |
-
Object(n.__)("%d left in stock","woo-gutenberg-products-block"),
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[15],{243:function(t,c,e){"use strict";e.d(c,"a",(function(){return n})),e(163);var o=e(65);const n=()=>o.m>1},260:function(t,c,e){"use strict";e.d(c,"b",(function(){return a})),e.d(c,"c",(function(){return i})),e.d(c,"a",(function(){return l}));var o=e(162),n=e(243),s=e(35);const r=t=>Object(s.d)(t)?JSON.parse(t)||{}:Object(s.c)(t)?t:{},a=t=>{if(!Object(n.a)()||"function"!=typeof o.__experimentalGetSpacingClassesAndStyles)return{style:{}};const c=Object(s.c)(t)?t:{},e=r(c.style);return Object(o.__experimentalGetSpacingClassesAndStyles)({...c,style:e})},i=t=>{const c=Object(s.c)(t)?t:{},e=r(c.style),o=Object(s.c)(e.typography)?e.typography:{};return{style:{fontSize:c.fontSize||o.fontSize,lineHeight:o.lineHeight,fontWeight:o.fontWeight,textTransform:o.textTransform,fontFamily:c.fontFamily}}},l=t=>{if(!Object(n.a)())return{className:"",style:{}};const c=Object(s.c)(t)?t:{},e=r(c.style);return Object(o.__experimentalUseColorProps)({...c,style:e})}},323:function(t,c){},371:function(t,c,e){"use strict";e.r(c);var o=e(0),n=e(1),s=(e(8),e(4)),r=e.n(s),a=e(49),i=e(110),l=(e(323),e(260));c.default=Object(i.withProductDataContext)(t=>{const{className:c}=t,{parentClassName:e}=Object(a.useInnerBlockLayoutContext)(),{product:s}=Object(a.useProductDataContext)(),i=Object(l.a)(t),u=Object(l.c)(t);if(!s.id||!s.is_purchasable)return null;const b=!!s.is_in_stock,p=s.low_stock_remaining,d=s.is_on_backorder;return Object(o.createElement)("div",{className:r()(c,i.className,"wc-block-components-product-stock-indicator",{[e+"__stock-indicator"]:e,"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":!!d}),style:{...i.style,...u.style}},p?(t=>Object(n.sprintf)(
|
2 |
/* translators: %d stock amount (number of items in stock for product) */
|
3 |
+
Object(n.__)("%d left in stock","woo-gutenberg-products-block"),t))(p):((t,c)=>c?Object(n.__)("Available on backorder","woo-gutenberg-products-block"):t?Object(n.__)("In Stock","woo-gutenberg-products-block"):Object(n.__)("Out of Stock","woo-gutenberg-products-block"))(b,d))})}}]);
|
build/atomic-block-components/stock-indicator.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[
|
2 |
/* translators: %d stock amount (number of items in stock for product) */
|
3 |
-
Object(n.__)("%d left in stock","woo-gutenberg-products-block"),o))(
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[16],{269:function(o,c,t){"use strict";t.r(c);var e=t(0),n=t(1),s=(t(10),t(4)),r=t.n(s),a=t(29),b=t(54),i=(t(309),t(113));c.default=Object(b.withProductDataContext)(o=>{const{className:c}=o,{parentClassName:t}=Object(a.useInnerBlockLayoutContext)(),{product:s}=Object(a.useProductDataContext)(),b=Object(i.a)(o),k=Object(i.c)(o);if(!s.id||!s.is_purchasable)return null;const l=!!s.is_in_stock,u=s.low_stock_remaining,d=s.is_on_backorder;return Object(e.createElement)("div",{className:r()(c,b.className,"wc-block-components-product-stock-indicator",{[t+"__stock-indicator"]:t,"wc-block-components-product-stock-indicator--in-stock":l,"wc-block-components-product-stock-indicator--out-of-stock":!l,"wc-block-components-product-stock-indicator--low-stock":!!u,"wc-block-components-product-stock-indicator--available-on-backorder":!!d}),style:{...b.style,...k.style}},u?(o=>Object(n.sprintf)(
|
2 |
/* translators: %d stock amount (number of items in stock for product) */
|
3 |
+
Object(n.__)("%d left in stock","woo-gutenberg-products-block"),o))(u):((o,c)=>c?Object(n.__)("Available on backorder","woo-gutenberg-products-block"):o?Object(n.__)("In Stock","woo-gutenberg-products-block"):Object(n.__)("Out of Stock","woo-gutenberg-products-block"))(l,d))})},309:function(o,c){}}]);
|
build/atomic-block-components/summary-frontend.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[16],{
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[16],{243:function(t,e,n){"use strict";n.d(e,"a",(function(){return s})),n(163);var c=n(65);const s=()=>c.m>1},260:function(t,e,n){"use strict";n.d(e,"b",(function(){return a})),n.d(e,"c",(function(){return u})),n.d(e,"a",(function(){return i}));var c=n(162),s=n(243),o=n(35);const r=t=>Object(o.d)(t)?JSON.parse(t)||{}:Object(o.c)(t)?t:{},a=t=>{if(!Object(s.a)()||"function"!=typeof c.__experimentalGetSpacingClassesAndStyles)return{style:{}};const e=Object(o.c)(t)?t:{},n=r(e.style);return Object(c.__experimentalGetSpacingClassesAndStyles)({...e,style:n})},u=t=>{const e=Object(o.c)(t)?t:{},n=r(e.style),c=Object(o.c)(n.typography)?n.typography:{};return{style:{fontSize:e.fontSize||c.fontSize,lineHeight:c.lineHeight,fontWeight:c.fontWeight,textTransform:c.textTransform,fontFamily:e.fontFamily}}},i=t=>{if(!Object(s.a)())return{className:"",style:{}};const e=Object(o.c)(t)?t:{},n=r(e.style);return Object(c.__experimentalUseColorProps)({...e,style:n})}},261:function(t,e,n){"use strict";var c=n(0),s=n(113),o=n(114);const r=t=>{const e=t.indexOf("</p>");return-1===e?t:t.substr(0,e+4)},a=t=>t.replace(/<\/?[a-z][^>]*?>/gi,""),u=(t,e)=>t.replace(/[\s|\.\,]+$/i,"")+e,i=function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"…";const c=a(t),s=c.split(" ").splice(0,e).join(" ");return Object(o.autop)(u(s,n))},l=function(t,e){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"…";const s=a(t),r=s.slice(0,e);if(n)return Object(o.autop)(u(r,c));const i=r.match(/([\s]+)/g),l=i?i.length:0,p=s.slice(0,e+l);return Object(o.autop)(u(p,c))};e.a=t=>{let{source:e,maxLength:n=15,countType:a="words",className:u="",style:p={}}=t;const d=Object(c.useMemo)(()=>function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:15,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"words";const c=Object(o.autop)(t),a=Object(s.count)(c,n);if(a<=e)return c;const u=r(c),p=Object(s.count)(u,n);return p<=e?u:"words"===n?i(u,e):l(u,e,"characters_including_spaces"===n)}(e,n,a),[e,n,a]);return Object(c.createElement)(c.RawHTML,{style:p,className:u},d)}},319:function(t,e){},367:function(t,e,n){"use strict";n.r(e);var c=n(0),s=(n(8),n(4)),o=n.n(s),r=n(261),a=n(65),u=n(49),i=n(110),l=(n(319),n(260));e.default=Object(i.withProductDataContext)(t=>{const{className:e}=t,{parentClassName:n}=Object(u.useInnerBlockLayoutContext)(),{product:s}=Object(u.useProductDataContext)(),i=Object(l.a)(t),p=Object(l.c)(t);if(!s)return Object(c.createElement)("div",{className:o()(e,"wc-block-components-product-summary",{[n+"__product-summary"]:n})});const d=s.short_description?s.short_description:s.description;return d?Object(c.createElement)(r.a,{className:o()(e,i.className,"wc-block-components-product-summary",{[n+"__product-summary"]:n}),source:d,maxLength:150,countType:a.n.wordCountType||"words",style:{...i.style,...p.style}}):null})}}]);
|
build/atomic-block-components/summary.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[17],{131:function(t,e,c){"use strict";var n=c(0),o=c(101),s=c(76);const r=t=>{const e=t.indexOf("</p>");return-1===e?t:t.substr(0,e+4)},a=t=>t.replace(/<\/?[a-z][^>]*?>/gi,""),u=(t,e)=>t.replace(/[\s|\.\,]+$/i,"")+e,l=function(t,e){let c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"…";const n=a(t),o=n.split(" ").splice(0,e).join(" ");return Object(s.autop)(u(o,c))},i=function(t,e){let c=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"…";const o=a(t),r=o.slice(0,e);if(c)return Object(s.autop)(u(r,n));const l=r.match(/([\s]+)/g),i=l?l.length:0,p=o.slice(0,e+i);return Object(s.autop)(u(p,n))};e.a=t=>{let{source:e,maxLength:c=15,countType:a="words",className:u="",style:p={}}=t;const d=Object(n.useMemo)(()=>function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:15,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"words";const n=Object(s.autop)(t),a=Object(o.count)(n,c);if(a<=e)return n;const u=r(n),p=Object(o.count)(u,c);return p<=e?u:"words"===c?l(u,e):i(u,e,"characters_including_spaces"===c)}(e,c,a),[e,c,a]);return Object(n.createElement)(n.RawHTML,{style:p,className:u},d)}},265:function(t,e,c){"use strict";c.r(e);var n=c(0),o=(c(10),c(4)),s=c.n(o),r=c(131),a=c(24),u=c(29),l=c(54),i=(c(305),c(113));e.default=Object(l.withProductDataContext)(t=>{const{className:e}=t,{parentClassName:c}=Object(u.useInnerBlockLayoutContext)(),{product:o}=Object(u.useProductDataContext)(),l=Object(i.a)(t),p=Object(i.c)(t);if(!o)return Object(n.createElement)("div",{className:s()(e,"wc-block-components-product-summary",{[c+"__product-summary"]:c})});const d=o.short_description?o.short_description:o.description;return d?Object(n.createElement)(r.a,{className:s()(e,l.className,"wc-block-components-product-summary",{[c+"__product-summary"]:c}),source:d,maxLength:150,countType:a.o.wordCountType||"words",style:{...l.style,...p.style}}):null})},305:function(t,e){}}]);
|
build/atomic-block-components/tag-list-frontend.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[17],{
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[17],{322:function(t,e){},370:function(t,e,c){"use strict";c.r(e);var a=c(0),n=c(1),l=(c(8),c(4)),s=c.n(l),o=c(49),u=c(5),r=c(110);c(322),e.default=Object(r.withProductDataContext)(t=>{let{className:e}=t;const{parentClassName:c}=Object(o.useInnerBlockLayoutContext)(),{product:l}=Object(o.useProductDataContext)();return Object(u.isEmpty)(l.tags)?null:Object(a.createElement)("div",{className:s()(e,"wc-block-components-product-tag-list",{[c+"__product-tag-list"]:c})},Object(n.__)("Tags:","woo-gutenberg-products-block")," ",Object(a.createElement)("ul",null,Object.values(l.tags).map(t=>{let{name:e,link:c,slug:n}=t;return Object(a.createElement)("li",{key:"tag-list-item-"+n},Object(a.createElement)("a",{href:c},e))})))})}}]);
|
build/atomic-block-components/tag-list.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[18],{268:function(t,e,c){"use strict";c.r(e);var a=c(0),n=c(1),l=(c(10),c(4)),s=c.n(l),o=c(29),u=c(6),r=c(54);c(308),e.default=Object(r.withProductDataContext)(t=>{let{className:e}=t;const{parentClassName:c}=Object(o.useInnerBlockLayoutContext)(),{product:l}=Object(o.useProductDataContext)();return Object(u.isEmpty)(l.tags)?null:Object(a.createElement)("div",{className:s()(e,"wc-block-components-product-tag-list",{[c+"__product-tag-list"]:c})},Object(n.__)("Tags:","woo-gutenberg-products-block")," ",Object(a.createElement)("ul",null,Object.values(l.tags).map(t=>{let{name:e,link:c,slug:n}=t;return Object(a.createElement)("li",{key:"tag-list-item-"+n},Object(a.createElement)("a",{href:c},e))})))})},308:function(t,e){}}]);
|
build/atomic-block-components/title-frontend.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[18],{
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[18],{243:function(e,t,n){"use strict";n.d(t,"a",(function(){return l})),n(163);var c=n(65);const l=()=>c.m>1},249:function(e,t,n){"use strict";var c=n(10),l=n.n(c),o=n(0),s=n(19),r=n(4),a=n.n(r);n(250),t.a=e=>{let{className:t="",disabled:n=!1,name:c,permalink:r="",rel:i,style:u,onClick:d,...p}=e;const b=a()("wc-block-components-product-name",t);if(n){const e=p;return Object(o.createElement)("span",l()({className:b},e,{dangerouslySetInnerHTML:{__html:Object(s.decodeEntities)(c)}}))}return Object(o.createElement)("a",l()({className:b,href:r,rel:i},p,{dangerouslySetInnerHTML:{__html:Object(s.decodeEntities)(c)},style:u}))}},250:function(e,t){},260:function(e,t,n){"use strict";n.d(t,"b",(function(){return r})),n.d(t,"c",(function(){return a})),n.d(t,"a",(function(){return i}));var c=n(162),l=n(243),o=n(35);const s=e=>Object(o.d)(e)?JSON.parse(e)||{}:Object(o.c)(e)?e:{},r=e=>{if(!Object(l.a)()||"function"!=typeof c.__experimentalGetSpacingClassesAndStyles)return{style:{}};const t=Object(o.c)(e)?e:{},n=s(t.style);return Object(c.__experimentalGetSpacingClassesAndStyles)({...t,style:n})},a=e=>{const t=Object(o.c)(e)?e:{},n=s(t.style),c=Object(o.c)(n.typography)?n.typography:{};return{style:{fontSize:t.fontSize||c.fontSize,lineHeight:c.lineHeight,fontWeight:c.fontWeight,textTransform:c.textTransform,fontFamily:t.fontFamily}}},i=e=>{if(!Object(l.a)())return{className:"",style:{}};const t=Object(o.c)(e)?e:{},n=s(t.style);return Object(c.__experimentalUseColorProps)({...t,style:n})}},315:function(e,t){},398:function(e,t,n){"use strict";n.r(t);var c=n(110),l=n(0),o=n(4),s=n.n(o),r=n(49),a=n(243),i=n(249),u=n(38),d=(n(315),n(260));const p=e=>{let{children:t,headingLevel:n,elementType:c="h"+n,...o}=e;return Object(l.createElement)(c,o,t)};var b=Object(c.withProductDataContext)(e=>{const{className:t,headingLevel:n=2,showProductLink:c=!0,align:o}=e,{parentClassName:b}=Object(r.useInnerBlockLayoutContext)(),{product:m}=Object(r.useProductDataContext)(),{dispatchStoreEvent:y}=Object(u.a)(),O=Object(d.a)(e),f=Object(d.b)(e),j=Object(d.c)(e);return m.id?Object(l.createElement)(p,{headingLevel:n,className:s()(t,O.className,"wc-block-components-product-title",{[b+"__product-title"]:b,["wc-block-components-product-title--align-"+o]:o&&Object(a.a)()}),style:Object(a.a)()?{...f.style,...j.style,...O.style}:{}},Object(l.createElement)(i.a,{disabled:!c,name:m.name,permalink:m.permalink,rel:c?"nofollow":"",onClick:()=>{y("product-view-link",{product:m})}})):Object(l.createElement)(p,{headingLevel:n,className:s()(t,O.className,"wc-block-components-product-title",{[b+"__product-title"]:b,["wc-block-components-product-title--align-"+o]:o&&Object(a.a)()}),style:Object(a.a)()?{...f.style,...j.style,...O.style}:{}})});let m={headingLevel:{type:"number",default:2},showProductLink:{type:"boolean",default:!0},productId:{type:"number",default:0}};Object(a.a)()&&(m={...m,align:{type:"string"},color:{type:"string"},customColor:{type:"string"},fontSize:{type:"string"},customFontSize:{type:"number"}});var y=m;t.default=Object(c.withFilteredAttributes)(y)(b)}}]);
|
build/atomic-block-components/title.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[
|
1 |
+
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[19],{129:function(e,t,c){"use strict";var n=c(5),l=c.n(n),o=c(0),a=c(14),s=c(4),r=c.n(s);c(157),t.a=e=>{let{className:t="",disabled:c=!1,name:n,permalink:s="",rel:i,style:u,onClick:b,...d}=e;const p=r()("wc-block-components-product-name",t);if(c){const e=d;return Object(o.createElement)("span",l()({className:p},e,{dangerouslySetInnerHTML:{__html:Object(a.decodeEntities)(n)}}))}return Object(o.createElement)("a",l()({className:p,href:s,rel:i},d,{dangerouslySetInnerHTML:{__html:Object(a.decodeEntities)(n)},style:u}))}},157:function(e,t){},248:function(e,t,c){"use strict";var n=c(70);let l={headingLevel:{type:"number",default:2},showProductLink:{type:"boolean",default:!0},productId:{type:"number",default:0}};Object(n.b)()&&(l={...l,align:{type:"string"},color:{type:"string"},customColor:{type:"string"},fontSize:{type:"string"},customFontSize:{type:"number"}}),t.a=l},249:function(e,t,c){"use strict";var n=c(0),l=c(4),o=c.n(l),a=c(29),s=c(70),r=c(54),i=c(129),u=c(60),b=(c(300),c(113));const d=e=>{let{children:t,headingLevel:c,elementType:l="h"+c,...o}=e;return Object(n.createElement)(l,o,t)};t.a=Object(r.withProductDataContext)(e=>{const{className:t,headingLevel:c=2,showProductLink:l=!0,align:r}=e,{parentClassName:p}=Object(a.useInnerBlockLayoutContext)(),{product:m}=Object(a.useProductDataContext)(),{dispatchStoreEvent:y}=Object(u.a)(),j=Object(b.a)(e),O=Object(b.b)(e),k=Object(b.c)(e);return m.id?Object(n.createElement)(d,{headingLevel:c,className:o()(t,j.className,"wc-block-components-product-title",{[p+"__product-title"]:p,["wc-block-components-product-title--align-"+r]:r&&Object(s.b)()}),style:Object(s.b)()?{...O.style,...k.style,...j.style}:{}},Object(n.createElement)(i.a,{disabled:!l,name:m.name,permalink:m.permalink,rel:l?"nofollow":"",onClick:()=>{y("product-view-link",{product:m})}})):Object(n.createElement)(d,{headingLevel:c,className:o()(t,j.className,"wc-block-components-product-title",{[p+"__product-title"]:p,["wc-block-components-product-title--align-"+r]:r&&Object(s.b)()}),style:Object(s.b)()?{...O.style,...k.style,...j.style}:{}})})},300:function(e,t){},502:function(e,t,c){"use strict";c.r(t);var n=c(54),l=c(249),o=c(248);t.default=Object(n.withFilteredAttributes)(o.a)(l.a)}}]);
|
build/attribute-filter-frontend.asset.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php return array('dependencies' => array('lodash', 'react', 'wc-blocks-data-store', 'wc-settings', 'wp-a11y', 'wp-components', 'wp-data', 'wp-element', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-polyfill', 'wp-primitives'), 'version' => '
|
1 |
+
<?php return array('dependencies' => array('lodash', 'react', 'wc-blocks-data-store', 'wc-settings', 'wp-a11y', 'wp-components', 'wp-data', 'wp-element', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-polyfill', 'wp-primitives'), 'version' => '5841fbf7cdb14aec8d00aa521dfa5ac1');
|
build/attribute-filter-frontend.js
CHANGED
@@ -1,26 +1,26 @@
|
|
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=181)}([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.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 i=typeof r;if("string"===i||"number"===i)e.push(r);else if(Array.isArray(r)){if(r.length){var a=o.apply(null,r);a&&e.push(a)}}else if("object"===i)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.wcBlocksData},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,n){e.exports=n(42)()},function(e,t){e.exports=window.wp.data},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.default=e.exports,e.exports.__esModule=!0,n.apply(this,arguments)}e.exports=n,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=window.wp.isShallowEqual},,,,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.default=e.exports,e.exports.__esModule=!0},function(e,t,n){"use strict";var r=n(15),o=n.n(r),i=n(0),a=n(3),c=n(1),s=n(66),u=e=>{let{imageUrl:t=s.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:a=Object(c.__)("Error:","woo-gutenberg-products-block"),button:u}=e;return Object(i.createElement)("div",{className:"wc-block-error wc-block-components-error"},t&&Object(i.createElement)("img",{className:"wc-block-error__image wc-block-components-error__image",src:t,alt:""}),Object(i.createElement)("div",{className:"wc-block-error__content wc-block-components-error__content"},n&&Object(i.createElement)("p",{className:"wc-block-error__header wc-block-components-error__header"},n),r&&Object(i.createElement)("p",{className:"wc-block-error__text wc-block-components-error__text"},r),o&&Object(i.createElement)("p",{className:"wc-block-error__message wc-block-components-error__message"},a?a+" ":"",o),u&&Object(i.createElement)("p",{className:"wc-block-error__button wc-block-components-error__button"},u)))};n(37);class l 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(i.createElement)(i.Fragment,null,Object(i.createElement)("strong",null,e.status),": ",e.statusText),hasError:!0}:{errorMessage:e.message,hasError:!0}}render(){const{header:e,imageUrl:t,showErrorMessage:n=!0,text:r,errorMessagePrefix:o,renderError:a,button:c}=this.props,{errorMessage:s,hasError:l}=this.state;return l?"function"==typeof a?a({errorMessage:s}):Object(i.createElement)(u,{errorMessage:n?s:null,header:e,imageUrl:t,text:r,errorMessagePrefix:o,button:c}):this.props.children}}t.a=l},function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(0),o=n(11),i=n.n(o);function a(e){const t=Object(r.useRef)(e);return i()(e,t.current)||(t.current=e),t.current}},,function(e,t){e.exports=window.wp.htmlEntities},,function(e,t,n){"use strict";var r=n(0),o=n(4),i=n.n(o);t.a=e=>{let t,{label:n,screenReaderLabel:o,wrapperElement:a,wrapperProps:c={}}=e;const s=null!=n,u=null!=o;return!s&&u?(t=a||"span",c={...c,className:i()(c.className,"screen-reader-text")},Object(r.createElement)(t,c,o)):(t=a||r.Fragment,s&&u&&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){e.exports=window.wp.a11y},function(e,t){e.exports=window.wp.primitives},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(0);const o=Object(r.createContext)("page"),i=()=>Object(r.useContext)(o);o.Provider},,,,,,,,,,,,function(e,t){},,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(6),o=n(9),i=n(0),a=n(11),c=n.n(a),s=n(17),u=n(62),l=n(25);const d=e=>{const t=Object(l.a)();e=e||t;const n=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[n,Object(i.useCallback)(t=>{a(e,t)},[e,a])]},p=(e,t,n)=>{const a=Object(l.a)();n=n||a;const c=Object(o.useSelect)(o=>o(r.QUERY_STATE_STORE_KEY).getValueForQueryKey(n,e,t),[n,e]),{setQueryValue:s}=Object(o.useDispatch)(r.QUERY_STATE_STORE_KEY);return[c,Object(i.useCallback)(t=>{s(n,e,t)},[n,e,s])]},f=(e,t)=>{const n=Object(l.a)();t=t||n;const[r,o]=d(t),a=Object(s.a)(r),p=Object(s.a)(e),f=Object(u.a)(p),m=Object(i.useRef)(!1);return Object(i.useEffect)(()=>{c()(f,p)||(o(Object.assign({},a,p)),m.current=!0)},[a,p,f,o]),m.current?[r,o]:[e,o]}},,,function(e,t,n){"use strict";var r=n(43);function o(){}function i(){}i.resetWarningCache=o,e.exports=function(){function e(e,t,n,o,i,a){if(a!==r){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:o};return n.PropTypes=n,n}},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},,,,,,,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(3);function o(e,t,n){var o=this,i=Object(r.useRef)(null),a=Object(r.useRef)(0),c=Object(r.useRef)(null),s=Object(r.useRef)([]),u=Object(r.useRef)(),l=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 m=!!(n=n||{}).leading,b=!("trailing"in n)||!!n.trailing,g="maxWait"in n,h=g?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=s.current,n=u.current;return s.current=u.current=null,a.current=e,l.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-i.current,r=e-a.current;return!i.current||n>=t||n<0||g&&r>=h},v=function(t){return c.current=null,b&&s.current?e(t):(s.current=u.current=null,l.current)},y=function(){var e=Date.now();if(r(e))return v(e);if(p.current){var o=e-i.current,c=e-a.current,s=t-o,u=g?Math.min(s,h-c):s;n(y,u)}},O=function(){for(var d=[],f=0;f<arguments.length;f++)d[f]=arguments[f];var b=Date.now(),h=r(b);if(s.current=d,u.current=o,i.current=b,h){if(!c.current&&p.current)return a.current=i.current,n(y,t),m?e(i.current):l.current;if(g)return n(y,t),e(i.current)}return c.current||n(y,t),l.current};return O.cancel=function(){c.current&&(f?cancelAnimationFrame(c.current):clearTimeout(c.current)),a.current=0,s.current=i.current=u.current=c.current=null},O.isPending=function(){return!!c.current},O.flush=function(){return c.current?v(Date.now()):l.current},O}),[m,g,t,h,b,f])}},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(10),o=n.n(r),i=n(0),a=n(16);const c=[".wp-block-woocommerce-cart"],s=e=>{let{Block:t,containers:n,getProps:r=(()=>({})),getErrorBoundaryProps:c=(()=>({}))}=e;0!==n.length&&Array.prototype.forEach.call(n,(e,n)=>{const s=r(e,n),u=c(e,n),l={...e.dataset,...s.attributes||{}};(e=>{let{Block:t,container:n,attributes:r={},props:c={},errorBoundaryProps:s={}}=e;Object(i.render)(Object(i.createElement)(a.a,s,Object(i.createElement)(i.Suspense,{fallback:Object(i.createElement)("div",{className:"wc-block-placeholder"})},t&&Object(i.createElement)(t,o()({},c,{attributes:r})))),n,()=>{n.classList&&n.classList.remove("is-loading")})})({Block:t,container:e,props:s,attributes:l,errorBoundaryProps:u})})},u=e=>{const t=document.body.querySelectorAll(c.join(",")),{Block:n,getProps:r,getErrorBoundaryProps:o,selector:i}=e;(e=>{let{Block:t,getProps:n,getErrorBoundaryProps:r,selector:o,wrappers:i}=e;const a=document.body.querySelectorAll(o);i&&i.length>0&&Array.prototype.filter.call(a,e=>!((e,t)=>Array.prototype.some.call(t,t=>t.contains(e)&&!t.isSameNode(e)))(e,i)),s({Block:t,containers:a,getProps:n,getErrorBoundaryProps:r})})({Block:n,getProps:r,getErrorBoundaryProps:o,selector:i,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:i}=e;const a=i.querySelectorAll(o);s({Block:t,containers:a,getProps:n,getErrorBoundaryProps:r})})({...e,wrapper:t})})})}},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),i=n(21);n(117),t.a=e=>{let{name:t,count:n}=e;return Object(r.createElement)(r.Fragment,null,t,Number.isFinite(n)&&Object(r.createElement)(i.a,{label:n,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";n.d(t,"a",(function(){return o}));var r=n(3);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";n.d(t,"a",(function(){return s}));var r=n(6),o=n(9),i=n(0),a=n(17),c=n(54);const s=e=>{const{namespace:t,resourceName:n,resourceValues:s=[],query:u={},shouldSelect:l=!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(i.useRef)({results:[],isLoading:!0}),p=Object(a.a)(u),f=Object(a.a)(s),m=Object(c.a)(),b=Object(o.useSelect)(e=>{if(!l)return null;const o=e(r.COLLECTIONS_STORE_KEY),i=[t,n,p,f],a=o.getCollectionError(...i);return a&&m(a),{results:o.getCollection(...i),isLoading:!o.hasFinishedResolution("getCollection",i)}},[t,n,f,p,l]);return null!==b&&(d.current=b),d.current}}
|
4 |
/* translators: Submit button text for filters. */
|
5 |
i=Object(o.__)("Go","woo-gutenberg-products-block"),onClick:s,screenReaderLabel:u=Object(o.__)("Apply filter","woo-gutenberg-products-block")}=e;return Object(r.createElement)("button",{type:"submit",className:a()("wc-block-filter-submit-button","wc-block-components-filter-submit-button",t),disabled:n,onClick:s},Object(r.createElement)(c.a,{label:i,screenReaderLabel:u}))};s.defaultProps={disabled:!1},t.a=s},,,,,,,,,,,,,,,,,,,,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(3),o=n(52);function i(e,t){return e===t}function a(e){return"function"==typeof e?function(){return e}:e}function c(e,t,n){var c=n&&n.equalityFn||i,s=function(e){var t=Object(r.useState)(a(e)),n=t[0],o=t[1];return[n,Object(r.useCallback)((function(e){return o(a(e))}),[])]}(e),u=s[0],l=s[1],d=Object(o.a)(Object(r.useCallback)((function(e){return l(e)}),[l]),t,n),p=Object(r.useRef)(e);return c(p.current,e)||(d(e),p.current=e),[u,d]}},function(e,t){e.exports=window.wp.components},,,function(e,t,n){"use strict";var r=n(0);t.a=function(e){let{srcElement:t,size:n=24,...o}=e;return Object(r.isValidElement)(t)?Object(r.cloneElement)(t,{width:n,height:n,...o}):null}},,,,function(e,t){},,function(e,t,n){"use strict";n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return a}));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.id&&e.push(n),e},[]),i=e=>{if(e)return o.find(t=>t.id===e)},a=e=>{if(e)return o.find(t=>t.taxonomy===e)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return i}));var r=n(5);const o=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>{},n=arguments.length>2?arguments[2]:void 0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";const i=e.filter(e=>e.attribute===n.taxonomy),a=i.length?i[0]:null;if(!(a&&a.slug&&Array.isArray(a.slug)&&a.slug.includes(o)))return;const c=a.slug.filter(e=>e!==o),s=e.filter(e=>e.attribute!==n.taxonomy);c.length>0&&(a.slug=c.sort(),s.push(a)),t(Object(r.sortBy)(s,"attribute"))},i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>{},n=arguments.length>2?arguments[2]:void 0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"in";const a=e.filter(e=>e.attribute!==n.taxonomy);0===o.length?t(a):(a.push({attribute:n.taxonomy,operator:i,slug:o.map(e=>{let{slug:t}=e;return t}).sort()}),t(Object(r.sortBy)(a,"attribute")))}},function(e,t,n){"use strict";var r=n(0),o=n(1),i=n(4),a=n.n(i);n(118),t.a=e=>{let{className:t,onChange:n=(()=>{}),options:i=[],checked:c=[],isLoading:s=!1,isDisabled:u=!1,limit:l=10}=e;const[d,p]=Object(r.useState)(!1),f=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=i.length-l;return!d&&Object(r.createElement)("li",{key:"show-more",className:"show-more"},Object(r.createElement)("button",{onClick:()=>{p(!0)},"aria-expanded":!1,"aria-label":Object(o.sprintf)(
|
6 |
/* translators: %s is referring the remaining count of options */
|
7 |
Object(o._n)("Show %s more option","Show %s more options",e,"woo-gutenberg-products-block"),e)},Object(o.sprintf)(
|
8 |
/* translators: %s number of options to reveal. */
|
9 |
-
Object(o._n)("Show %s more","Show %s more",e,"woo-gutenberg-products-block"),e)))},[i,l,d]),b=Object(r.useMemo)(()=>d&&Object(r.createElement)("li",{key:"show-less",className:"show-less"},Object(r.createElement)("button",{onClick:()=>{p(!1)},"aria-expanded":!0,"aria-label":Object(o.__)("Show less options","woo-gutenberg-products-block")},Object(o.__)("Show less","woo-gutenberg-products-block"))),[d]),g=Object(r.useMemo)(()=>{const e=i.length>l+5;return Object(r.createElement)(r.Fragment,null,i.map((t,o)=>Object(r.createElement)(r.Fragment,{key:t.value},Object(r.createElement)("li",e&&!d&&o>=l&&{hidden:!0},Object(r.createElement)("input",{type:"checkbox",id:t.value,value:t.value,onChange:e=>{n(e.target.value)},checked:c.includes(t.value),disabled:u}),Object(r.createElement)("label",{htmlFor:t.value},t.label)),e&&o===l-1&&m)),e&&b)},[i,n,c,d,l,b,m,u]),h=a()("wc-block-checkbox-list","wc-block-components-checkbox-list",{"is-loading":s},t);return Object(r.createElement)("ul",{className:h},s?f:g)}},,,,,,function(e,t){},,,,,function(e,t){},function(e,t){},,,,,,,,function(e,t,n){"use strict";e.exports=n(
|
10 |
/* translators: Remove chip. */
|
11 |
Object(s.__)("Remove","woo-gutenberg-products-block"):Object(s.sprintf)(
|
12 |
/* translators: %s text of the chip to remove. */
|
13 |
-
Object(s.__)('Remove "%s"',"woo-gutenberg-products-block"),e)}const h={"aria-label":t,disabled:r,onClick:a,onKeyDown:e=>{"Backspace"!==e.key&&"Delete"!==e.key||a()}},v=p?h:{},y=p?{"aria-hidden":!0}:h;return Object(i.createElement)(d,o()({},b,v,{className:c()(n,"is-removable"),element:p?"button":b.element,screenReaderText:m,text:f}),Object(i.createElement)(g,o()({className:"wc-block-components-chip__remove"},y),Object(i.createElement)(u.a,{className:"wc-block-components-chip__remove-icon",srcElement:l.a,size:16})))}},,,,,,,,,,,,,function(e,t,n){e.exports=n(200)},function(e,t){},function(e,t){},function(e,t,n){"use strict";var r=60103,o=60106,i=60107,a=60108,c=60114,s=60109,u=60110,l=60112,d=60113,p=60120,f=60115,m=60116,b=60121,g=60122,h=60117,v=60129,y=60131;if("function"==typeof Symbol&&Symbol.for){var O=Symbol.for;r=O("react.element"),o=O("react.portal"),i=O("react.fragment"),a=O("react.strict_mode"),c=O("react.profiler"),s=O("react.provider"),u=O("react.context"),l=O("react.forward_ref"),d=O("react.suspense"),p=O("react.suspense_list"),f=O("react.memo"),m=O("react.lazy"),b=O("react.block"),g=O("react.server.block"),h=O("react.fundamental"),v=O("react.debug_trace_mode"),y=O("react.legacy_hidden")}function w(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case r:switch(e=e.type){case i:case c:case a:case d:case p:return e;default:switch(e=e&&e.$$typeof){case u:case l:case m:case f:case s:return e;default:return t}}case o:return t}}}var j=s,E=r,I=l,_=i,S=m,k=f,x=o,C=c,P=a,R=d;t.ContextConsumer=u,t.ContextProvider=j,t.Element=E,t.ForwardRef=I,t.Fragment=_,t.Lazy=S,t.Memo=k,t.Portal=x,t.Profiler=C,t.StrictMode=P,t.Suspense=R,t.isAsyncMode=function(){return!1},t.isConcurrentMode=function(){return!1},t.isContextConsumer=function(e){return w(e)===u},t.isContextProvider=function(e){return w(e)===s},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r},t.isForwardRef=function(e){return w(e)===l},t.isFragment=function(e){return w(e)===i},t.isLazy=function(e){return w(e)===m},t.isMemo=function(e){return w(e)===f},t.isPortal=function(e){return w(e)===o},t.isProfiler=function(e){return w(e)===c},t.isStrictMode=function(e){return w(e)===a},t.isSuspense=function(e){return w(e)===d},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===i||e===c||e===v||e===a||e===d||e===p||e===y||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===f||e.$$typeof===s||e.$$typeof===u||e.$$typeof===l||e.$$typeof===h||e.$$typeof===b||e[0]===g)},t.typeOf=w},,,,,,,,,,,,,,,,function(e,t,n){"use strict";n.r(t);var r=n(53),o=n(0),i=n(1),a=n(23),c=n(17),s=n(62),u=n(39),l=n(64),d=n(133),p=n(106),f=n(8),m=n.n(f),b=n(4),g=n.n(b);function h(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}var v=n(7);function y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function O(e,t){return(O=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var w=n(3);function j(e){return"object"==typeof e&&null!=e&&1===e.nodeType}function E(e,t){return(!t||"hidden"!==e)&&"visible"!==e&&"clip"!==e}function I(e,t){if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){var n=getComputedStyle(e,null);return E(n.overflowY,t)||E(n.overflowX,t)||function(e){var t=function(e){if(!e.ownerDocument||!e.ownerDocument.defaultView)return null;try{return e.ownerDocument.defaultView.frameElement}catch(e){return null}}(e);return!!t&&(t.clientHeight<e.scrollHeight||t.clientWidth<e.scrollWidth)}(e)}return!1}function _(e,t,n,r,o,i,a,c){return i<e&&a>t||i>e&&a<t?0:i<=e&&c<=n||a>=t&&c>=n?i-e-r:a>t&&c<n||i<e&&c>n?a-t+o:0}n(126);var S=function(){return(S=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};Object.create,Object.create;var k=0;function x(e){return"function"==typeof e?e:C}function C(){}function P(e,t){e&&function(e,t){var n=window,r=t.scrollMode,o=t.block,i=t.inline,a=t.boundary,c=t.skipOverflowHiddenElements,s="function"==typeof a?a:function(e){return e!==a};if(!j(e))throw new TypeError("Invalid target");for(var u=document.scrollingElement||document.documentElement,l=[],d=e;j(d)&&s(d);){if((d=d.parentElement)===u){l.push(d);break}null!=d&&d===document.body&&I(d)&&!I(document.documentElement)||null!=d&&I(d,c)&&l.push(d)}for(var p=n.visualViewport?n.visualViewport.width:innerWidth,f=n.visualViewport?n.visualViewport.height:innerHeight,m=window.scrollX||pageXOffset,b=window.scrollY||pageYOffset,g=e.getBoundingClientRect(),h=g.height,v=g.width,y=g.top,O=g.right,w=g.bottom,E=g.left,S="start"===o||"nearest"===o?y:"end"===o?w:y+h/2,k="center"===i?E+v/2:"end"===i?O:E,x=[],C=0;C<l.length;C++){var P=l[C],R=P.getBoundingClientRect(),T=R.height,M=R.width,A=R.top,D=R.right,N=R.bottom,H=R.left;if("if-needed"===r&&y>=0&&E>=0&&w<=f&&O<=p&&y>=A&&w<=N&&E>=H&&O<=D)return x;var B=getComputedStyle(P),L=parseInt(B.borderLeftWidth,10),V=parseInt(B.borderTopWidth,10),F=parseInt(B.borderRightWidth,10),K=parseInt(B.borderBottomWidth,10),q=0,U=0,$="offsetWidth"in P?P.offsetWidth-P.clientWidth-L-F:0,W="offsetHeight"in P?P.offsetHeight-P.clientHeight-V-K:0;if(u===P)q="start"===o?S:"end"===o?S-f:"nearest"===o?_(b,b+f,f,V,K,b+S,b+S+h,h):S-f/2,U="start"===i?k:"center"===i?k-p/2:"end"===i?k-p:_(m,m+p,p,L,F,m+k,m+k+v,v),q=Math.max(0,q+b),U=Math.max(0,U+m);else{q="start"===o?S-A-V:"end"===o?S-N+K+W:"nearest"===o?_(A,N,T,V,K+W,S,S+h,h):S-(A+T/2)+W/2,U="start"===i?k-H-L:"center"===i?k-(H+M/2)+$/2:"end"===i?k-D+F+$:_(H,D,M,L,F+$,k,k+v,v);var G=P.scrollLeft,Y=P.scrollTop;S+=Y-(q=Math.max(0,Math.min(Y+q,P.scrollHeight-T+W))),k+=G-(U=Math.max(0,Math.min(G+U,P.scrollWidth-M+$)))}x.push({el:P,top:q,left:U})}return x}(e,{boundary:t,block:"nearest",scrollMode:"if-needed"}).forEach((function(e){var t=e.el,n=e.top,r=e.left;t.scrollTop=n,t.scrollLeft=r}))}function R(e,t,n){return e===t||t instanceof n.Node&&e.contains&&e.contains(t)}function T(e,t){var n;function r(){n&&clearTimeout(n)}function o(){for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];r(),n=setTimeout((function(){n=null,e.apply(void 0,i)}),t)}return o.cancel=r,o}function M(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return t.some((function(t){return t&&t.apply(void 0,[e].concat(r)),e.preventDownshiftDefault||e.hasOwnProperty("nativeEvent")&&e.nativeEvent.preventDownshiftDefault}))}}function A(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){t.forEach((function(t){"function"==typeof t?t(e):t&&(t.current=e)}))}}function D(e){var t=e.isOpen,n=e.resultCount,r=e.previousResultCount;return t?n?n!==r?n+" result"+(1===n?" is":"s are")+" available, use up and down arrow keys to navigate. Press Enter key to select.":"":"No results are available.":""}function N(e,t){return!(e=Array.isArray(e)?e[0]:e)&&t?t:e}var H=["highlightedIndex","inputValue","isOpen","selectedItem","type"];function B(e){void 0===e&&(e={});var t={};return H.forEach((function(n){e.hasOwnProperty(n)&&(t[n]=e[n])})),t}function L(e,t){return void 0!==e[t]}function V(e){var t=e.key,n=e.keyCode;return n>=37&&n<=40&&0!==t.indexOf("Arrow")?"Arrow"+t:t}function F(e,t,n,r,o){if(void 0===o&&(o=!0),0===n)return-1;var i=n-1;("number"!=typeof t||t<0||t>=n)&&(t=e>0?-1:i+1);var a=t+e;a<0?a=o?i:0:a>i&&(a=o?0:i);var c=K(e,a,n,r,o);return-1===c?t>=n?-1:t:c}function K(e,t,n,r,o){var i=r(t);if(!i||!i.hasAttribute("disabled"))return t;if(e>0){for(var a=t+1;a<n;a++)if(!r(a).hasAttribute("disabled"))return a}else for(var c=t-1;c>=0;c--)if(!r(c).hasAttribute("disabled"))return c;return o?e>0?K(1,0,n,r,!1):K(-1,n-1,n,r,!1):-1}function q(e,t,n,r){return void 0===r&&(r=!0),t.some((function(t){return t&&(R(t,e,n)||r&&R(t,n.document.activeElement,n))}))}var U=T((function(e){W(e).textContent=""}),500);function $(e,t){var n=W(t);e&&(n.textContent=e,U(t))}function W(e){void 0===e&&(e=document);var t=e.getElementById("a11y-status-message");return t||((t=e.createElement("div")).setAttribute("id","a11y-status-message"),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-relevant","additions text"),Object.assign(t.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px"}),e.body.appendChild(t),t)}var G=Object.freeze({__proto__:null,unknown:0,mouseUp:1,itemMouseEnter:2,keyDownArrowUp:3,keyDownArrowDown:4,keyDownEscape:5,keyDownEnter:6,keyDownHome:7,keyDownEnd:8,clickItem:9,blurInput:10,changeInput:11,keyDownSpaceButton:12,clickButton:13,blurButton:14,controlledPropUpdatedSelectedItem:15,touchEnd:16}),Y=["refKey","ref"],z=["onClick","onPress","onKeyDown","onKeyUp","onBlur"],Q=["onKeyDown","onBlur","onChange","onInput","onChangeText"],X=["refKey","ref"],J=["onMouseMove","onMouseDown","onClick","onPress","index","item"],Z=function(){var e=function(e){var t,n;function r(t){var n;(n=e.call(this,t)||this).id=n.props.id||"downshift-"+String(k++),n.menuId=n.props.menuId||n.id+"-menu",n.labelId=n.props.labelId||n.id+"-label",n.inputId=n.props.inputId||n.id+"-input",n.getItemId=n.props.getItemId||function(e){return n.id+"-item-"+e},n.input=null,n.items=[],n.itemCount=null,n.previousResultCount=0,n.timeoutIds=[],n.internalSetTimeout=function(e,t){var r=setTimeout((function(){n.timeoutIds=n.timeoutIds.filter((function(e){return e!==r})),e()}),t);n.timeoutIds.push(r)},n.setItemCount=function(e){n.itemCount=e},n.unsetItemCount=function(){n.itemCount=null},n.setHighlightedIndex=function(e,t){void 0===e&&(e=n.props.defaultHighlightedIndex),void 0===t&&(t={}),t=B(t),n.internalSetState(Object(v.a)({highlightedIndex:e},t))},n.clearSelection=function(e){n.internalSetState({selectedItem:null,inputValue:"",highlightedIndex:n.props.defaultHighlightedIndex,isOpen:n.props.defaultIsOpen},e)},n.selectItem=function(e,t,r){t=B(t),n.internalSetState(Object(v.a)({isOpen:n.props.defaultIsOpen,highlightedIndex:n.props.defaultHighlightedIndex,selectedItem:e,inputValue:n.props.itemToString(e)},t),r)},n.selectItemAtIndex=function(e,t,r){var o=n.items[e];null!=o&&n.selectItem(o,t,r)},n.selectHighlightedItem=function(e,t){return n.selectItemAtIndex(n.getState().highlightedIndex,e,t)},n.internalSetState=function(e,t){var r,o,i={},a="function"==typeof e;return!a&&e.hasOwnProperty("inputValue")&&n.props.onInputValueChange(e.inputValue,Object(v.a)({},n.getStateAndHelpers(),e)),n.setState((function(t){t=n.getState(t);var c=a?e(t):e;c=n.props.stateReducer(t,c),r=c.hasOwnProperty("selectedItem");var s={},u={};return r&&c.selectedItem!==t.selectedItem&&(o=c.selectedItem),c.type=c.type||0,Object.keys(c).forEach((function(e){t[e]!==c[e]&&(i[e]=c[e]),"type"!==e&&(u[e]=c[e],L(n.props,e)||(s[e]=c[e]))})),a&&c.hasOwnProperty("inputValue")&&n.props.onInputValueChange(c.inputValue,Object(v.a)({},n.getStateAndHelpers(),c)),s}),(function(){x(t)(),Object.keys(i).length>1&&n.props.onStateChange(i,n.getStateAndHelpers()),r&&n.props.onSelect(e.selectedItem,n.getStateAndHelpers()),void 0!==o&&n.props.onChange(o,n.getStateAndHelpers()),n.props.onUserAction(i,n.getStateAndHelpers())}))},n.rootRef=function(e){return n._rootNode=e},n.getRootProps=function(e,t){var r,o=void 0===e?{}:e,i=o.refKey,a=void 0===i?"ref":i,c=o.ref,s=h(o,Y),u=(void 0===t?{}:t).suppressRefError,l=void 0!==u&&u;n.getRootProps.called=!0,n.getRootProps.refKey=a,n.getRootProps.suppressRefError=l;var d=n.getState().isOpen;return Object(v.a)(((r={})[a]=A(c,n.rootRef),r.role="combobox",r["aria-expanded"]=d,r["aria-haspopup"]="listbox",r["aria-owns"]=d?n.menuId:null,r["aria-labelledby"]=n.labelId,r),s)},n.keyDownHandlers={ArrowDown:function(e){var t=this;if(e.preventDefault(),this.getState().isOpen){var n=e.shiftKey?5:1;this.moveHighlightedIndex(n,{type:4})}else this.internalSetState({isOpen:!0,type:4},(function(){var e=t.getItemCount();if(e>0){var n=F(1,t.getState().highlightedIndex,e,(function(e){return t.getItemNodeFromIndex(e)}));t.setHighlightedIndex(n,{type:4})}}))},ArrowUp:function(e){var t=this;if(e.preventDefault(),this.getState().isOpen){var n=e.shiftKey?-5:-1;this.moveHighlightedIndex(n,{type:3})}else this.internalSetState({isOpen:!0,type:3},(function(){var e=t.getItemCount();if(e>0){var n=F(-1,t.getState().highlightedIndex,e,(function(e){return t.getItemNodeFromIndex(e)}));t.setHighlightedIndex(n,{type:3})}}))},Enter:function(e){if(229!==e.which){var t=this.getState(),n=t.isOpen,r=t.highlightedIndex;if(n&&null!=r){e.preventDefault();var o=this.items[r],i=this.getItemNodeFromIndex(r);if(null==o||i&&i.hasAttribute("disabled"))return;this.selectHighlightedItem({type:6})}}},Escape:function(e){e.preventDefault(),this.reset(Object(v.a)({type:5},!this.state.isOpen&&{selectedItem:null,inputValue:""}))}},n.buttonKeyDownHandlers=Object(v.a)({},n.keyDownHandlers,{" ":function(e){e.preventDefault(),this.toggleMenu({type:12})}}),n.inputKeyDownHandlers=Object(v.a)({},n.keyDownHandlers,{Home:function(e){var t=this,n=this.getState().isOpen;if(n){e.preventDefault();var r=this.getItemCount();if(!(r<=0)&&n){var o=K(1,0,r,(function(e){return t.getItemNodeFromIndex(e)}),!1);this.setHighlightedIndex(o,{type:7})}}},End:function(e){var t=this,n=this.getState().isOpen;if(n){e.preventDefault();var r=this.getItemCount();if(!(r<=0)&&n){var o=K(-1,r-1,r,(function(e){return t.getItemNodeFromIndex(e)}),!1);this.setHighlightedIndex(o,{type:8})}}}}),n.getToggleButtonProps=function(e){var t=void 0===e?{}:e,r=t.onClick;t.onPress;var o=t.onKeyDown,i=t.onKeyUp,a=t.onBlur,c=h(t,z),s=n.getState().isOpen,u={onClick:M(r,n.buttonHandleClick),onKeyDown:M(o,n.buttonHandleKeyDown),onKeyUp:M(i,n.buttonHandleKeyUp),onBlur:M(a,n.buttonHandleBlur)},l=c.disabled?{}:u;return Object(v.a)({type:"button",role:"button","aria-label":s?"close menu":"open menu","aria-haspopup":!0,"data-toggle":!0},l,c)},n.buttonHandleKeyUp=function(e){e.preventDefault()},n.buttonHandleKeyDown=function(e){var t=V(e);n.buttonKeyDownHandlers[t]&&n.buttonKeyDownHandlers[t].call(y(n),e)},n.buttonHandleClick=function(e){e.preventDefault(),n.props.environment.document.activeElement===n.props.environment.document.body&&e.target.focus(),n.internalSetTimeout((function(){return n.toggleMenu({type:13})}))},n.buttonHandleBlur=function(e){var t=e.target;n.internalSetTimeout((function(){n.isMouseDown||null!=n.props.environment.document.activeElement&&n.props.environment.document.activeElement.id===n.inputId||n.props.environment.document.activeElement===t||n.reset({type:14})}))},n.getLabelProps=function(e){return Object(v.a)({htmlFor:n.inputId,id:n.labelId},e)},n.getInputProps=function(e){var t=void 0===e?{}:e,r=t.onKeyDown,o=t.onBlur,i=t.onChange,a=t.onInput;t.onChangeText;var c,s=h(t,Q),u={},l=n.getState(),d=l.inputValue,p=l.isOpen,f=l.highlightedIndex;return s.disabled||((c={}).onChange=M(i,a,n.inputHandleChange),c.onKeyDown=M(r,n.inputHandleKeyDown),c.onBlur=M(o,n.inputHandleBlur),u=c),Object(v.a)({"aria-autocomplete":"list","aria-activedescendant":p&&"number"==typeof f&&f>=0?n.getItemId(f):null,"aria-controls":p?n.menuId:null,"aria-labelledby":n.labelId,autoComplete:"off",value:d,id:n.inputId},u,s)},n.inputHandleKeyDown=function(e){var t=V(e);t&&n.inputKeyDownHandlers[t]&&n.inputKeyDownHandlers[t].call(y(n),e)},n.inputHandleChange=function(e){n.internalSetState({type:11,isOpen:!0,inputValue:e.target.value,highlightedIndex:n.props.defaultHighlightedIndex})},n.inputHandleBlur=function(){n.internalSetTimeout((function(){var e=n.props.environment.document&&!!n.props.environment.document.activeElement&&!!n.props.environment.document.activeElement.dataset&&n.props.environment.document.activeElement.dataset.toggle&&n._rootNode&&n._rootNode.contains(n.props.environment.document.activeElement);n.isMouseDown||e||n.reset({type:10})}))},n.menuRef=function(e){n._menuNode=e},n.getMenuProps=function(e,t){var r,o=void 0===e?{}:e,i=o.refKey,a=void 0===i?"ref":i,c=o.ref,s=h(o,X),u=(void 0===t?{}:t).suppressRefError,l=void 0!==u&&u;return n.getMenuProps.called=!0,n.getMenuProps.refKey=a,n.getMenuProps.suppressRefError=l,Object(v.a)(((r={})[a]=A(c,n.menuRef),r.role="listbox",r["aria-labelledby"]=s&&s["aria-label"]?null:n.labelId,r.id=n.menuId,r),s)},n.getItemProps=function(e){var t,r=void 0===e?{}:e,o=r.onMouseMove,i=r.onMouseDown,a=r.onClick;r.onPress;var c=r.index,s=r.item,u=void 0===s?void 0:s,l=h(r,J);void 0===c?(n.items.push(u),c=n.items.indexOf(u)):n.items[c]=u;var d=a,p=((t={onMouseMove:M(o,(function(){c!==n.getState().highlightedIndex&&(n.setHighlightedIndex(c,{type:2}),n.avoidScrolling=!0,n.internalSetTimeout((function(){return n.avoidScrolling=!1}),250))})),onMouseDown:M(i,(function(e){e.preventDefault()}))}).onClick=M(d,(function(){n.selectItemAtIndex(c,{type:9})})),t),f=l.disabled?{onMouseDown:p.onMouseDown}:p;return Object(v.a)({id:n.getItemId(c),role:"option","aria-selected":n.getState().highlightedIndex===c},f,l)},n.clearItems=function(){n.items=[]},n.reset=function(e,t){void 0===e&&(e={}),e=B(e),n.internalSetState((function(t){var r=t.selectedItem;return Object(v.a)({isOpen:n.props.defaultIsOpen,highlightedIndex:n.props.defaultHighlightedIndex,inputValue:n.props.itemToString(r)},e)}),t)},n.toggleMenu=function(e,t){void 0===e&&(e={}),e=B(e),n.internalSetState((function(t){var r=t.isOpen;return Object(v.a)({isOpen:!r},r&&{highlightedIndex:n.props.defaultHighlightedIndex},e)}),(function(){var r=n.getState(),o=r.isOpen,i=r.highlightedIndex;o&&n.getItemCount()>0&&"number"==typeof i&&n.setHighlightedIndex(i,e),x(t)()}))},n.openMenu=function(e){n.internalSetState({isOpen:!0},e)},n.closeMenu=function(e){n.internalSetState({isOpen:!1},e)},n.updateStatus=T((function(){var e=n.getState(),t=n.items[e.highlightedIndex],r=n.getItemCount(),o=n.props.getA11yStatusMessage(Object(v.a)({itemToString:n.props.itemToString,previousResultCount:n.previousResultCount,resultCount:r,highlightedItem:t},e));n.previousResultCount=r,$(o,n.props.environment.document)}),200);var r=n.props,o=r.defaultHighlightedIndex,i=r.initialHighlightedIndex,a=void 0===i?o:i,c=r.defaultIsOpen,s=r.initialIsOpen,u=void 0===s?c:s,l=r.initialInputValue,d=void 0===l?"":l,p=r.initialSelectedItem,f=void 0===p?null:p,m=n.getState({highlightedIndex:a,isOpen:u,inputValue:d,selectedItem:f});return null!=m.selectedItem&&void 0===n.props.initialInputValue&&(m.inputValue=n.props.itemToString(m.selectedItem)),n.state=m,n}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,O(t,n);var o=r.prototype;return o.internalClearTimeouts=function(){this.timeoutIds.forEach((function(e){clearTimeout(e)})),this.timeoutIds=[]},o.getState=function(e){return void 0===e&&(e=this.state),t=e,n=this.props,Object.keys(t).reduce((function(e,r){return e[r]=L(n,r)?n[r]:t[r],e}),{});var t,n},o.getItemCount=function(){var e=this.items.length;return null!=this.itemCount?e=this.itemCount:void 0!==this.props.itemCount&&(e=this.props.itemCount),e},o.getItemNodeFromIndex=function(e){return this.props.environment.document.getElementById(this.getItemId(e))},o.scrollHighlightedItemIntoView=function(){var e=this.getItemNodeFromIndex(this.getState().highlightedIndex);this.props.scrollIntoView(e,this._menuNode)},o.moveHighlightedIndex=function(e,t){var n=this,r=this.getItemCount(),o=this.getState().highlightedIndex;if(r>0){var i=F(e,o,r,(function(e){return n.getItemNodeFromIndex(e)}));this.setHighlightedIndex(i,t)}},o.getStateAndHelpers=function(){var e=this.getState(),t=e.highlightedIndex,n=e.inputValue,r=e.selectedItem,o=e.isOpen,i=this.props.itemToString,a=this.id,c=this.getRootProps,s=this.getToggleButtonProps,u=this.getLabelProps,l=this.getMenuProps,d=this.getInputProps,p=this.getItemProps,f=this.openMenu,m=this.closeMenu,b=this.toggleMenu,g=this.selectItem,h=this.selectItemAtIndex,v=this.selectHighlightedItem,y=this.setHighlightedIndex,O=this.clearSelection,w=this.clearItems;return{getRootProps:c,getToggleButtonProps:s,getLabelProps:u,getMenuProps:l,getInputProps:d,getItemProps:p,reset:this.reset,openMenu:f,closeMenu:m,toggleMenu:b,selectItem:g,selectItemAtIndex:h,selectHighlightedItem:v,setHighlightedIndex:y,clearSelection:O,clearItems:w,setItemCount:this.setItemCount,unsetItemCount:this.unsetItemCount,setState:this.internalSetState,itemToString:i,id:a,highlightedIndex:t,inputValue:n,isOpen:o,selectedItem:r}},o.componentDidMount=function(){var e=this,t=function(){e.isMouseDown=!0},n=function(t){e.isMouseDown=!1,!q(t.target,[e._rootNode,e._menuNode],e.props.environment)&&e.getState().isOpen&&e.reset({type:1},(function(){return e.props.onOuterClick(e.getStateAndHelpers())}))},r=function(){e.isTouchMove=!1},o=function(){e.isTouchMove=!0},i=function(t){var n=q(t.target,[e._rootNode,e._menuNode],e.props.environment,!1);e.isTouchMove||n||!e.getState().isOpen||e.reset({type:16},(function(){return e.props.onOuterClick(e.getStateAndHelpers())}))},a=this.props.environment;a.addEventListener("mousedown",t),a.addEventListener("mouseup",n),a.addEventListener("touchstart",r),a.addEventListener("touchmove",o),a.addEventListener("touchend",i),this.cleanup=function(){e.internalClearTimeouts(),e.updateStatus.cancel(),a.removeEventListener("mousedown",t),a.removeEventListener("mouseup",n),a.removeEventListener("touchstart",r),a.removeEventListener("touchmove",o),a.removeEventListener("touchend",i)}},o.shouldScroll=function(e,t){var n=(void 0===this.props.highlightedIndex?this.getState():this.props).highlightedIndex,r=(void 0===t.highlightedIndex?e:t).highlightedIndex;return n&&this.getState().isOpen&&!e.isOpen||n!==r},o.componentDidUpdate=function(e,t){L(this.props,"selectedItem")&&this.props.selectedItemChanged(e.selectedItem,this.props.selectedItem)&&this.internalSetState({type:15,inputValue:this.props.itemToString(this.props.selectedItem)}),!this.avoidScrolling&&this.shouldScroll(t,e)&&this.scrollHighlightedItemIntoView(),this.updateStatus()},o.componentWillUnmount=function(){this.cleanup()},o.render=function(){var e=N(this.props.children,C);this.clearItems(),this.getRootProps.called=!1,this.getRootProps.refKey=void 0,this.getRootProps.suppressRefError=void 0,this.getMenuProps.called=!1,this.getMenuProps.refKey=void 0,this.getMenuProps.suppressRefError=void 0,this.getLabelProps.called=!1,this.getInputProps.called=!1;var t=N(e(this.getStateAndHelpers()));return t?this.getRootProps.called||this.props.suppressRefError?t:function(e){return"string"==typeof e.type}(t)?Object(w.cloneElement)(t,this.getRootProps(function(e){return e.props}(t))):void 0:null},r}(w.Component);return e.defaultProps={defaultHighlightedIndex:null,defaultIsOpen:!1,getA11yStatusMessage:D,itemToString:function(e){return null==e?"":String(e)},onStateChange:C,onInputValueChange:C,onUserAction:C,onChange:C,onSelect:C,onOuterClick:C,selectedItemChanged:function(e,t){return e!==t},environment:"undefined"==typeof window?{}:window,stateReducer:function(e,t){return t},suppressRefError:!1,scrollIntoView:P},e.stateChangeTypes=G,e}();T((function(e,t){$(e(),t)}),200),"undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?w.useLayoutEffect:w.useEffect;var ee={itemToString:function(e){return e?String(e):""},stateReducer:function(e,t){return t.changes},getA11ySelectionMessage:function(e){var t=e.selectedItem,n=e.itemToString;return t?n(t)+" has been selected.":""},scrollIntoView:P,circularNavigation:!1,environment:"undefined"==typeof window?{}:window};m.a.array.isRequired,m.a.func,m.a.func,m.a.func,m.a.bool,m.a.number,m.a.number,m.a.number,m.a.bool,m.a.bool,m.a.bool,m.a.any,m.a.any,m.a.any,m.a.string,m.a.string,m.a.string,m.a.func,m.a.string,m.a.func,m.a.func,m.a.func,m.a.func,m.a.func,m.a.shape({addEventListener:m.a.func,removeEventListener:m.a.func,document:m.a.shape({getElementById:m.a.func,activeElement:m.a.any,body:m.a.any})}),S(S({},ee),{getA11yStatusMessage:function(e){var t=e.isOpen,n=e.resultCount,r=e.previousResultCount;return t?n?n!==r?n+" result"+(1===n?" is":"s are")+" available, use up and down arrow keys to navigate. Press Enter or Space Bar keys to select.":"":"No results are available.":""}}),m.a.array.isRequired,m.a.func,m.a.func,m.a.func,m.a.bool,m.a.number,m.a.number,m.a.number,m.a.bool,m.a.bool,m.a.bool,m.a.any,m.a.any,m.a.any,m.a.string,m.a.string,m.a.string,m.a.string,m.a.string,m.a.string,m.a.func,m.a.string,m.a.string,m.a.func,m.a.func,m.a.func,m.a.func,m.a.func,m.a.func,m.a.shape({addEventListener:m.a.func,removeEventListener:m.a.func,document:m.a.shape({getElementById:m.a.func,activeElement:m.a.any,body:m.a.any})}),Object(v.a)({},ee,{getA11yStatusMessage:D,circularNavigation:!0}),m.a.array,m.a.array,m.a.array,m.a.func,m.a.func,m.a.func,m.a.number,m.a.number,m.a.number,m.a.func,m.a.func,m.a.string,m.a.string,m.a.shape({addEventListener:m.a.func,removeEventListener:m.a.func,document:m.a.shape({getElementById:m.a.func,activeElement:m.a.any,body:m.a.any})});var te=e=>{let{checked:t,getInputProps:n,inputRef:r,isDisabled:i,onFocus:a,onRemoveItem:c,placeholder:s,tabIndex:u,value:l}=e;return Object(o.createElement)("input",n({ref:r,className:"wc-block-dropdown-selector__input wc-block-components-dropdown-selector__input",disabled:i,onFocus:a,onKeyDown(e){"Backspace"===e.key&&!l&&t.length>0&&c(t[t.length-1])},placeholder:s,tabIndex:u}))},ne=e=>{let{children:t,onClick:n}=e;return Object(o.createElement)("div",{className:"wc-block-dropdown-selector__input-wrapper wc-block-components-dropdown-selector__input-wrapper",onClick:n},t)},re=e=>{let{checked:t,getItemProps:n,getMenuProps:r,highlightedIndex:a,options:c}=e;return Object(o.createElement)("ul",r({className:"wc-block-dropdown-selector__list wc-block-components-dropdown-selector__list"}),c.map((e,r)=>{const c=t.includes(e.value);return Object(o.createElement)("li",n({key:e.value,className:g()("wc-block-dropdown-selector__list-item","wc-block-components-dropdown-selector__list-item",{"is-selected":c,"is-highlighted":a===r}),index:r,item:e.value,"aria-label":c?Object(i.sprintf)(
|
14 |
/* translators: %s is referring to the filter option being removed. */
|
15 |
Object(i.__)("Remove %s filter","woo-gutenberg-products-block"),e.name):null}),e.label)}))},oe=n(168),ie=e=>{let{onRemoveItem:t,option:n}=e;return Object(o.createElement)(oe.a,{className:"wc-block-dropdown-selector__selected-chip wc-block-components-dropdown-selector__selected-chip",removeOnAnyClick:!0,onRemove:()=>{t(n.value)},ariaLabel:Object(i.sprintf)(
|
16 |
/* translators: %s is referring to the filter option being removed. */
|
17 |
-
Object(i.__)("Remove %s filter","woo-gutenberg-products-block"),n.name),text:n.label,radius:"large"})},ae=n(98),ce=n(
|
18 |
/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */
|
19 |
Object(i.__)("Replace current %s filter","woo-gutenberg-products-block"),r.name)},r.label),Object(o.createElement)("button",{className:"wc-block-dropdown-selector__selected-value__remove wc-block-components-dropdown-selector__selected-value__remove",onClick:()=>{n(r.value)},onKeyDown:e=>{"Backspace"!==e.key&&"Delete"!==e.key||n(r.value)},"aria-label":Object(i.sprintf)(
|
20 |
/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */
|
21 |
-
Object(i.__)("Remove %s filter","woo-gutenberg-products-block"),r.name)},Object(o.createElement)(ae.a,{srcElement:ce.a,size:16})))};n(
|
22 |
/* translators: %s attribute name. */
|
23 |
-
Object(i.__)("Any %s","woo-gutenberg-products-block"),t),tabIndex:!u&&r.length>0?"-1":"0",value:v})),y&&!c&&Object(o.createElement)(re,{checked:r,getItemProps:s,getMenuProps:b,highlightedIndex:h,options:d.filter(e=>!v||e.value.startsWith(v))}))})},le=n(55),de=n(72),pe=n(11),fe=n.n(pe),me=n(19),be=n(95),ge=n(104),he=n(105);const ve=[{value:"preview-1",name:"Blue",label:Object(o.createElement)(le.a,{name:"Blue",count:3})},{value:"preview-2",name:"Green",label:Object(o.createElement)(le.a,{name:"Green",count:3})},{value:"preview-3",name:"Red",label:Object(o.createElement)(le.a,{name:"Red",count:2})}],ye={id:0,name:"preview",taxonomy:"preview",label:"Preview"};n(
|
24 |
/* translators: %1$s and %2$s are attribute terms (for example: 'red', 'blue', 'large'...). */
|
25 |
Object(i.__)("%1$s filter replaced with %2$s.","woo-gutenberg-products-block"),o,c)):o?Object(a.speak)(Object(i.sprintf)(
|
26 |
/* translators: %s attribute term (for example: 'red', 'blue', 'large'...) */
|
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=182)}([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.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 i=typeof r;if("string"===i||"number"===i)e.push(r);else if(Array.isArray(r)){if(r.length){var a=o.apply(null,r);a&&e.push(a)}}else if("object"===i)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.wcBlocksData},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,n){e.exports=n(42)()},function(e,t){e.exports=window.wp.data},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.default=e.exports,e.exports.__esModule=!0,n.apply(this,arguments)}e.exports=n,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=window.wp.isShallowEqual},,,,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.default=e.exports,e.exports.__esModule=!0},function(e,t,n){"use strict";var r=n(15),o=n.n(r),i=n(0),a=n(3),c=n(1),s=n(65),u=e=>{let{imageUrl:t=s.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:a=Object(c.__)("Error:","woo-gutenberg-products-block"),button:u}=e;return Object(i.createElement)("div",{className:"wc-block-error wc-block-components-error"},t&&Object(i.createElement)("img",{className:"wc-block-error__image wc-block-components-error__image",src:t,alt:""}),Object(i.createElement)("div",{className:"wc-block-error__content wc-block-components-error__content"},n&&Object(i.createElement)("p",{className:"wc-block-error__header wc-block-components-error__header"},n),r&&Object(i.createElement)("p",{className:"wc-block-error__text wc-block-components-error__text"},r),o&&Object(i.createElement)("p",{className:"wc-block-error__message wc-block-components-error__message"},a?a+" ":"",o),u&&Object(i.createElement)("p",{className:"wc-block-error__button wc-block-components-error__button"},u)))};n(37);class l 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(i.createElement)(i.Fragment,null,Object(i.createElement)("strong",null,e.status),": ",e.statusText),hasError:!0}:{errorMessage:e.message,hasError:!0}}render(){const{header:e,imageUrl:t,showErrorMessage:n=!0,text:r,errorMessagePrefix:o,renderError:a,button:c}=this.props,{errorMessage:s,hasError:l}=this.state;return l?"function"==typeof a?a({errorMessage:s}):Object(i.createElement)(u,{errorMessage:n?s:null,header:e,imageUrl:t,text:r,errorMessagePrefix:o,button:c}):this.props.children}}t.a=l},function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(0),o=n(11),i=n.n(o);function a(e){const t=Object(r.useRef)(e);return i()(e,t.current)||(t.current=e),t.current}},,function(e,t){e.exports=window.wp.htmlEntities},,function(e,t,n){"use strict";var r=n(0),o=n(4),i=n.n(o);t.a=e=>{let t,{label:n,screenReaderLabel:o,wrapperElement:a,wrapperProps:c={}}=e;const s=null!=n,u=null!=o;return!s&&u?(t=a||"span",c={...c,className:i()(c.className,"screen-reader-text")},Object(r.createElement)(t,c,o)):(t=a||r.Fragment,s&&u&&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){e.exports=window.wp.a11y},function(e,t){e.exports=window.wp.primitives},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(0);const o=Object(r.createContext)("page"),i=()=>Object(r.useContext)(o);o.Provider},,,,,,,,,,,,function(e,t){},,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(6),o=n(9),i=n(0),a=n(11),c=n.n(a),s=n(17),u=n(62),l=n(25);const d=e=>{const t=Object(l.a)();e=e||t;const n=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[n,Object(i.useCallback)(t=>{a(e,t)},[e,a])]},p=(e,t,n)=>{const a=Object(l.a)();n=n||a;const c=Object(o.useSelect)(o=>o(r.QUERY_STATE_STORE_KEY).getValueForQueryKey(n,e,t),[n,e]),{setQueryValue:s}=Object(o.useDispatch)(r.QUERY_STATE_STORE_KEY);return[c,Object(i.useCallback)(t=>{s(n,e,t)},[n,e,s])]},f=(e,t)=>{const n=Object(l.a)();t=t||n;const[r,o]=d(t),a=Object(s.a)(r),p=Object(s.a)(e),f=Object(u.a)(p),m=Object(i.useRef)(!1);return Object(i.useEffect)(()=>{c()(f,p)||(o(Object.assign({},a,p)),m.current=!0)},[a,p,f,o]),m.current?[r,o]:[e,o]}},,,function(e,t,n){"use strict";var r=n(43);function o(){}function i(){}i.resetWarningCache=o,e.exports=function(){function e(e,t,n,o,i,a){if(a!==r){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:o};return n.PropTypes=n,n}},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},,,,,,,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(3);function o(e,t,n){var o=this,i=Object(r.useRef)(null),a=Object(r.useRef)(0),c=Object(r.useRef)(null),s=Object(r.useRef)([]),u=Object(r.useRef)(),l=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 m=!!(n=n||{}).leading,b=!("trailing"in n)||!!n.trailing,g="maxWait"in n,h=g?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=s.current,n=u.current;return s.current=u.current=null,a.current=e,l.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-i.current,r=e-a.current;return!i.current||n>=t||n<0||g&&r>=h},v=function(t){return c.current=null,b&&s.current?e(t):(s.current=u.current=null,l.current)},y=function(){var e=Date.now();if(r(e))return v(e);if(p.current){var o=e-i.current,c=e-a.current,s=t-o,u=g?Math.min(s,h-c):s;n(y,u)}},O=function(){for(var d=[],f=0;f<arguments.length;f++)d[f]=arguments[f];var b=Date.now(),h=r(b);if(s.current=d,u.current=o,i.current=b,h){if(!c.current&&p.current)return a.current=i.current,n(y,t),m?e(i.current):l.current;if(g)return n(y,t),e(i.current)}return c.current||n(y,t),l.current};return O.cancel=function(){c.current&&(f?cancelAnimationFrame(c.current):clearTimeout(c.current)),a.current=0,s.current=i.current=u.current=c.current=null},O.isPending=function(){return!!c.current},O.flush=function(){return c.current?v(Date.now()):l.current},O}),[m,g,t,h,b,f])}},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(10),o=n.n(r),i=n(0),a=n(16);const c=[".wp-block-woocommerce-cart"],s=e=>{let{Block:t,containers:n,getProps:r=(()=>({})),getErrorBoundaryProps:c=(()=>({}))}=e;0!==n.length&&Array.prototype.forEach.call(n,(e,n)=>{const s=r(e,n),u=c(e,n),l={...e.dataset,...s.attributes||{}};(e=>{let{Block:t,container:n,attributes:r={},props:c={},errorBoundaryProps:s={}}=e;Object(i.render)(Object(i.createElement)(a.a,s,Object(i.createElement)(i.Suspense,{fallback:Object(i.createElement)("div",{className:"wc-block-placeholder"})},t&&Object(i.createElement)(t,o()({},c,{attributes:r})))),n,()=>{n.classList&&n.classList.remove("is-loading")})})({Block:t,container:e,props:s,attributes:l,errorBoundaryProps:u})})},u=e=>{const t=document.body.querySelectorAll(c.join(",")),{Block:n,getProps:r,getErrorBoundaryProps:o,selector:i}=e;(e=>{let{Block:t,getProps:n,getErrorBoundaryProps:r,selector:o,wrappers:i}=e;const a=document.body.querySelectorAll(o);i&&i.length>0&&Array.prototype.filter.call(a,e=>!((e,t)=>Array.prototype.some.call(t,t=>t.contains(e)&&!t.isSameNode(e)))(e,i)),s({Block:t,containers:a,getProps:n,getErrorBoundaryProps:r})})({Block:n,getProps:r,getErrorBoundaryProps:o,selector:i,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:i}=e;const a=i.querySelectorAll(o);s({Block:t,containers:a,getProps:n,getErrorBoundaryProps:r})})({...e,wrapper:t})})})}},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),i=n(21);n(117),t.a=e=>{let{name:t,count:n}=e;return Object(r.createElement)(r.Fragment,null,t,Number.isFinite(n)&&Object(r.createElement)(i.a,{label:n,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";n.d(t,"a",(function(){return o}));var r=n(3);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";n.d(t,"a",(function(){return s}));var r=n(6),o=n(9),i=n(0),a=n(17),c=n(54);const s=e=>{const{namespace:t,resourceName:n,resourceValues:s=[],query:u={},shouldSelect:l=!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(i.useRef)({results:[],isLoading:!0}),p=Object(a.a)(u),f=Object(a.a)(s),m=Object(c.a)(),b=Object(o.useSelect)(e=>{if(!l)return null;const o=e(r.COLLECTIONS_STORE_KEY),i=[t,n,p,f],a=o.getCollectionError(...i);return a&&m(a),{results:o.getCollection(...i),isLoading:!o.hasFinishedResolution("getCollection",i)}},[t,n,f,p,l]);return null!==b&&(d.current=b),d.current}},function(e,t,n){"use strict";n.d(t,"n",(function(){return i})),n.d(t,"l",(function(){return a})),n.d(t,"k",(function(){return c})),n.d(t,"m",(function(){return s})),n.d(t,"i",(function(){return u})),n.d(t,"d",(function(){return l})),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 m})),n.d(t,"g",(function(){return b})),n.d(t,"a",(function(){return g})),n.d(t,"h",(function(){return h})),n.d(t,"b",(function(){return v}));var r,o=n(2);const i=Object(o.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),a=i.pluginUrl+"images/",c=i.pluginUrl+"build/",s=i.buildPhase,u=null===(r=o.STORE_PAGES.shop)||void 0===r?void 0:r.permalink,l=(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),m=o.STORE_PAGES.myaccount.permalink?o.STORE_PAGES.myaccount.permalink:Object(o.getSetting)("wpLoginUrl","/wp-login.php"),b=Object(o.getSetting)("shippingCountries",{}),g=Object(o.getSetting)("allowedCountries",{}),h=Object(o.getSetting)("shippingStates",{}),v=Object(o.getSetting)("allowedStates",{})},,,,,,,function(e,t,n){"use strict";var r=n(0),o=n(1),i=(n(8),n(4)),a=n.n(i),c=n(21);n(102);const s=e=>{let{className:t,disabled:n,label:
|
4 |
/* translators: Submit button text for filters. */
|
5 |
i=Object(o.__)("Go","woo-gutenberg-products-block"),onClick:s,screenReaderLabel:u=Object(o.__)("Apply filter","woo-gutenberg-products-block")}=e;return Object(r.createElement)("button",{type:"submit",className:a()("wc-block-filter-submit-button","wc-block-components-filter-submit-button",t),disabled:n,onClick:s},Object(r.createElement)(c.a,{label:i,screenReaderLabel:u}))};s.defaultProps={disabled:!1},t.a=s},,,,,,,,,,,,,,,,,,,,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(3),o=n(52);function i(e,t){return e===t}function a(e){return"function"==typeof e?function(){return e}:e}function c(e,t,n){var c=n&&n.equalityFn||i,s=function(e){var t=Object(r.useState)(a(e)),n=t[0],o=t[1];return[n,Object(r.useCallback)((function(e){return o(a(e))}),[])]}(e),u=s[0],l=s[1],d=Object(o.a)(Object(r.useCallback)((function(e){return l(e)}),[l]),t,n),p=Object(r.useRef)(e);return c(p.current,e)||(d(e),p.current=e),[u,d]}},function(e,t){e.exports=window.wp.components},,,function(e,t,n){"use strict";var r=n(0);t.a=function(e){let{srcElement:t,size:n=24,...o}=e;return Object(r.isValidElement)(t)?Object(r.cloneElement)(t,{width:n,height:n,...o}):null}},,,,function(e,t){},,function(e,t,n){"use strict";n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return a}));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.id&&e.push(n),e},[]),i=e=>{if(e)return o.find(t=>t.id===e)},a=e=>{if(e)return o.find(t=>t.taxonomy===e)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return i}));var r=n(5);const o=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>{},n=arguments.length>2?arguments[2]:void 0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";const i=e.filter(e=>e.attribute===n.taxonomy),a=i.length?i[0]:null;if(!(a&&a.slug&&Array.isArray(a.slug)&&a.slug.includes(o)))return;const c=a.slug.filter(e=>e!==o),s=e.filter(e=>e.attribute!==n.taxonomy);c.length>0&&(a.slug=c.sort(),s.push(a)),t(Object(r.sortBy)(s,"attribute"))},i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>{},n=arguments.length>2?arguments[2]:void 0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"in";const a=e.filter(e=>e.attribute!==n.taxonomy);0===o.length?t(a):(a.push({attribute:n.taxonomy,operator:i,slug:o.map(e=>{let{slug:t}=e;return t}).sort()}),t(Object(r.sortBy)(a,"attribute")))}},function(e,t,n){"use strict";var r=n(0),o=n(1),i=n(4),a=n.n(i);n(118),t.a=e=>{let{className:t,onChange:n=(()=>{}),options:i=[],checked:c=[],isLoading:s=!1,isDisabled:u=!1,limit:l=10}=e;const[d,p]=Object(r.useState)(!1),f=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=i.length-l;return!d&&Object(r.createElement)("li",{key:"show-more",className:"show-more"},Object(r.createElement)("button",{onClick:()=>{p(!0)},"aria-expanded":!1,"aria-label":Object(o.sprintf)(
|
6 |
/* translators: %s is referring the remaining count of options */
|
7 |
Object(o._n)("Show %s more option","Show %s more options",e,"woo-gutenberg-products-block"),e)},Object(o.sprintf)(
|
8 |
/* translators: %s number of options to reveal. */
|
9 |
+
Object(o._n)("Show %s more","Show %s more",e,"woo-gutenberg-products-block"),e)))},[i,l,d]),b=Object(r.useMemo)(()=>d&&Object(r.createElement)("li",{key:"show-less",className:"show-less"},Object(r.createElement)("button",{onClick:()=>{p(!1)},"aria-expanded":!0,"aria-label":Object(o.__)("Show less options","woo-gutenberg-products-block")},Object(o.__)("Show less","woo-gutenberg-products-block"))),[d]),g=Object(r.useMemo)(()=>{const e=i.length>l+5;return Object(r.createElement)(r.Fragment,null,i.map((t,o)=>Object(r.createElement)(r.Fragment,{key:t.value},Object(r.createElement)("li",e&&!d&&o>=l&&{hidden:!0},Object(r.createElement)("input",{type:"checkbox",id:t.value,value:t.value,onChange:e=>{n(e.target.value)},checked:c.includes(t.value),disabled:u}),Object(r.createElement)("label",{htmlFor:t.value},t.label)),e&&o===l-1&&m)),e&&b)},[i,n,c,d,l,b,m,u]),h=a()("wc-block-checkbox-list","wc-block-components-checkbox-list",{"is-loading":s},t);return Object(r.createElement)("ul",{className:h},s?f:g)}},,,,,,function(e,t){},,,,,function(e,t){},function(e,t){},,,,,,,,function(e,t,n){"use strict";e.exports=n(185)},,,,,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(0),o=n(94),i=n(5),a=n(17),c=n(39),s=n(64),u=n(25);const l=e=>{let{queryAttribute:t,queryPrices:n,queryStock:l,queryState:d}=e,p=Object(u.a)();p+="-collection-data";const[f]=Object(c.a)(p),[m,b]=Object(c.b)("calculate_attribute_counts",[],p),[g,h]=Object(c.b)("calculate_price_range",null,p),[v,y]=Object(c.b)("calculate_stock_status_counts",null,p),O=Object(a.a)(t||{}),w=Object(a.a)(n),j=Object(a.a)(l);Object(r.useEffect)(()=>{"object"==typeof O&&Object.keys(O).length&&(m.find(e=>e.taxonomy===O.taxonomy)||b([...m,O]))},[O,m,b]),Object(r.useEffect)(()=>{g!==w&&void 0!==w&&h(w)},[w,h,g]),Object(r.useEffect)(()=>{v!==j&&void 0!==j&&y(j)},[j,y,v]);const[E,I]=Object(r.useState)(!1),[_]=Object(o.a)(E,200);E||I(!0);const S=Object(r.useMemo)(()=>(e=>{const t=e;return e.calculate_attribute_counts&&(t.calculate_attribute_counts=Object(i.sortBy)(e.calculate_attribute_counts.map(e=>{let{taxonomy:t,queryType:n}=e;return{taxonomy:t,query_type:n}}),["taxonomy","query_type"])),t})(f),[f]);return Object(s.a)({namespace:"/wc/store",resourceName:"products/collection-data",query:{...d,page:void 0,per_page:void 0,orderby:void 0,order:void 0,...S},shouldSelect:_})}},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t,n){"use strict";var r=n(10),o=n.n(r),i=n(0),a=n(24);const c=Object(i.createElement)(e=>{let{className:t,size:n,...r}=e;return Object(i.createElement)(a.SVG,o()({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",className:t,width:n,height:n},r),Object(i.createElement)("path",{d:"M14.95 6.46L11.41 10l3.54 3.54-1.41 1.41L10 11.42l-3.53 3.53-1.42-1.42L8.58 10 5.05 6.47l1.42-1.42L10 8.58l3.54-3.53z"}))},null);t.a=c},,,function(e,t,n){"use strict";var r=n(10),o=n.n(r),i=n(0),a=n(4),c=n.n(a),s=n(1),u=n(98),l=n(165);n(112);var d=e=>{let{text:t,screenReaderText:n="",element:r="li",className:a="",radius:s="small",children:u=null,...l}=e;const d=r,p=c()(a,"wc-block-components-chip","wc-block-components-chip--radius-"+s),f=Boolean(n&&n!==t);return Object(i.createElement)(d,o()({className:p},l),Object(i.createElement)("span",{"aria-hidden":f,className:"wc-block-components-chip__text"},t),f&&Object(i.createElement)("span",{className:"screen-reader-text"},n),u)};t.a=e=>{let{ariaLabel:t="",className:n="",disabled:r=!1,onRemove:a=(()=>{}),removeOnAnyClick:p=!1,text:f,screenReaderText:m="",...b}=e;const g=p?"span":"button";if(!t){const e=m&&"string"==typeof m?m:f;t="string"!=typeof e?
|
10 |
/* translators: Remove chip. */
|
11 |
Object(s.__)("Remove","woo-gutenberg-products-block"):Object(s.sprintf)(
|
12 |
/* translators: %s text of the chip to remove. */
|
13 |
+
Object(s.__)('Remove "%s"',"woo-gutenberg-products-block"),e)}const h={"aria-label":t,disabled:r,onClick:a,onKeyDown:e=>{"Backspace"!==e.key&&"Delete"!==e.key||a()}},v=p?h:{},y=p?{"aria-hidden":!0}:h;return Object(i.createElement)(d,o()({},b,v,{className:c()(n,"is-removable"),element:p?"button":b.element,screenReaderText:m,text:f}),Object(i.createElement)(g,o()({className:"wc-block-components-chip__remove"},y),Object(i.createElement)(u.a,{className:"wc-block-components-chip__remove-icon",srcElement:l.a,size:16})))}},,,,,,,,,,,,,,function(e,t,n){e.exports=n(201)},function(e,t){},function(e,t){},function(e,t,n){"use strict";var r=60103,o=60106,i=60107,a=60108,c=60114,s=60109,u=60110,l=60112,d=60113,p=60120,f=60115,m=60116,b=60121,g=60122,h=60117,v=60129,y=60131;if("function"==typeof Symbol&&Symbol.for){var O=Symbol.for;r=O("react.element"),o=O("react.portal"),i=O("react.fragment"),a=O("react.strict_mode"),c=O("react.profiler"),s=O("react.provider"),u=O("react.context"),l=O("react.forward_ref"),d=O("react.suspense"),p=O("react.suspense_list"),f=O("react.memo"),m=O("react.lazy"),b=O("react.block"),g=O("react.server.block"),h=O("react.fundamental"),v=O("react.debug_trace_mode"),y=O("react.legacy_hidden")}function w(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case r:switch(e=e.type){case i:case c:case a:case d:case p:return e;default:switch(e=e&&e.$$typeof){case u:case l:case m:case f:case s:return e;default:return t}}case o:return t}}}var j=s,E=r,I=l,_=i,S=m,k=f,x=o,C=c,P=a,R=d;t.ContextConsumer=u,t.ContextProvider=j,t.Element=E,t.ForwardRef=I,t.Fragment=_,t.Lazy=S,t.Memo=k,t.Portal=x,t.Profiler=C,t.StrictMode=P,t.Suspense=R,t.isAsyncMode=function(){return!1},t.isConcurrentMode=function(){return!1},t.isContextConsumer=function(e){return w(e)===u},t.isContextProvider=function(e){return w(e)===s},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r},t.isForwardRef=function(e){return w(e)===l},t.isFragment=function(e){return w(e)===i},t.isLazy=function(e){return w(e)===m},t.isMemo=function(e){return w(e)===f},t.isPortal=function(e){return w(e)===o},t.isProfiler=function(e){return w(e)===c},t.isStrictMode=function(e){return w(e)===a},t.isSuspense=function(e){return w(e)===d},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===i||e===c||e===v||e===a||e===d||e===p||e===y||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===f||e.$$typeof===s||e.$$typeof===u||e.$$typeof===l||e.$$typeof===h||e.$$typeof===b||e[0]===g)},t.typeOf=w},,,,,,,,,,,,,,,,function(e,t,n){"use strict";n.r(t);var r=n(53),o=n(0),i=n(1),a=n(23),c=n(17),s=n(62),u=n(39),l=n(64),d=n(133),p=n(106),f=n(8),m=n.n(f),b=n(4),g=n.n(b);function h(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}var v=n(7);function y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function O(e,t){return(O=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var w=n(3);function j(e){return"object"==typeof e&&null!=e&&1===e.nodeType}function E(e,t){return(!t||"hidden"!==e)&&"visible"!==e&&"clip"!==e}function I(e,t){if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){var n=getComputedStyle(e,null);return E(n.overflowY,t)||E(n.overflowX,t)||function(e){var t=function(e){if(!e.ownerDocument||!e.ownerDocument.defaultView)return null;try{return e.ownerDocument.defaultView.frameElement}catch(e){return null}}(e);return!!t&&(t.clientHeight<e.scrollHeight||t.clientWidth<e.scrollWidth)}(e)}return!1}function _(e,t,n,r,o,i,a,c){return i<e&&a>t||i>e&&a<t?0:i<=e&&c<=n||a>=t&&c>=n?i-e-r:a>t&&c<n||i<e&&c>n?a-t+o:0}n(126);var S=function(){return(S=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};Object.create,Object.create;var k=0;function x(e){return"function"==typeof e?e:C}function C(){}function P(e,t){e&&function(e,t){var n=window,r=t.scrollMode,o=t.block,i=t.inline,a=t.boundary,c=t.skipOverflowHiddenElements,s="function"==typeof a?a:function(e){return e!==a};if(!j(e))throw new TypeError("Invalid target");for(var u=document.scrollingElement||document.documentElement,l=[],d=e;j(d)&&s(d);){if((d=d.parentElement)===u){l.push(d);break}null!=d&&d===document.body&&I(d)&&!I(document.documentElement)||null!=d&&I(d,c)&&l.push(d)}for(var p=n.visualViewport?n.visualViewport.width:innerWidth,f=n.visualViewport?n.visualViewport.height:innerHeight,m=window.scrollX||pageXOffset,b=window.scrollY||pageYOffset,g=e.getBoundingClientRect(),h=g.height,v=g.width,y=g.top,O=g.right,w=g.bottom,E=g.left,S="start"===o||"nearest"===o?y:"end"===o?w:y+h/2,k="center"===i?E+v/2:"end"===i?O:E,x=[],C=0;C<l.length;C++){var P=l[C],R=P.getBoundingClientRect(),T=R.height,M=R.width,A=R.top,D=R.right,N=R.bottom,H=R.left;if("if-needed"===r&&y>=0&&E>=0&&w<=f&&O<=p&&y>=A&&w<=N&&E>=H&&O<=D)return x;var B=getComputedStyle(P),L=parseInt(B.borderLeftWidth,10),V=parseInt(B.borderTopWidth,10),F=parseInt(B.borderRightWidth,10),K=parseInt(B.borderBottomWidth,10),q=0,U=0,$="offsetWidth"in P?P.offsetWidth-P.clientWidth-L-F:0,W="offsetHeight"in P?P.offsetHeight-P.clientHeight-V-K:0;if(u===P)q="start"===o?S:"end"===o?S-f:"nearest"===o?_(b,b+f,f,V,K,b+S,b+S+h,h):S-f/2,U="start"===i?k:"center"===i?k-p/2:"end"===i?k-p:_(m,m+p,p,L,F,m+k,m+k+v,v),q=Math.max(0,q+b),U=Math.max(0,U+m);else{q="start"===o?S-A-V:"end"===o?S-N+K+W:"nearest"===o?_(A,N,T,V,K+W,S,S+h,h):S-(A+T/2)+W/2,U="start"===i?k-H-L:"center"===i?k-(H+M/2)+$/2:"end"===i?k-D+F+$:_(H,D,M,L,F+$,k,k+v,v);var G=P.scrollLeft,Y=P.scrollTop;S+=Y-(q=Math.max(0,Math.min(Y+q,P.scrollHeight-T+W))),k+=G-(U=Math.max(0,Math.min(G+U,P.scrollWidth-M+$)))}x.push({el:P,top:q,left:U})}return x}(e,{boundary:t,block:"nearest",scrollMode:"if-needed"}).forEach((function(e){var t=e.el,n=e.top,r=e.left;t.scrollTop=n,t.scrollLeft=r}))}function R(e,t,n){return e===t||t instanceof n.Node&&e.contains&&e.contains(t)}function T(e,t){var n;function r(){n&&clearTimeout(n)}function o(){for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];r(),n=setTimeout((function(){n=null,e.apply(void 0,i)}),t)}return o.cancel=r,o}function M(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return t.some((function(t){return t&&t.apply(void 0,[e].concat(r)),e.preventDownshiftDefault||e.hasOwnProperty("nativeEvent")&&e.nativeEvent.preventDownshiftDefault}))}}function A(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){t.forEach((function(t){"function"==typeof t?t(e):t&&(t.current=e)}))}}function D(e){var t=e.isOpen,n=e.resultCount,r=e.previousResultCount;return t?n?n!==r?n+" result"+(1===n?" is":"s are")+" available, use up and down arrow keys to navigate. Press Enter key to select.":"":"No results are available.":""}function N(e,t){return!(e=Array.isArray(e)?e[0]:e)&&t?t:e}var H=["highlightedIndex","inputValue","isOpen","selectedItem","type"];function B(e){void 0===e&&(e={});var t={};return H.forEach((function(n){e.hasOwnProperty(n)&&(t[n]=e[n])})),t}function L(e,t){return void 0!==e[t]}function V(e){var t=e.key,n=e.keyCode;return n>=37&&n<=40&&0!==t.indexOf("Arrow")?"Arrow"+t:t}function F(e,t,n,r,o){if(void 0===o&&(o=!0),0===n)return-1;var i=n-1;("number"!=typeof t||t<0||t>=n)&&(t=e>0?-1:i+1);var a=t+e;a<0?a=o?i:0:a>i&&(a=o?0:i);var c=K(e,a,n,r,o);return-1===c?t>=n?-1:t:c}function K(e,t,n,r,o){var i=r(t);if(!i||!i.hasAttribute("disabled"))return t;if(e>0){for(var a=t+1;a<n;a++)if(!r(a).hasAttribute("disabled"))return a}else for(var c=t-1;c>=0;c--)if(!r(c).hasAttribute("disabled"))return c;return o?e>0?K(1,0,n,r,!1):K(-1,n-1,n,r,!1):-1}function q(e,t,n,r){return void 0===r&&(r=!0),t.some((function(t){return t&&(R(t,e,n)||r&&R(t,n.document.activeElement,n))}))}var U=T((function(e){W(e).textContent=""}),500);function $(e,t){var n=W(t);e&&(n.textContent=e,U(t))}function W(e){void 0===e&&(e=document);var t=e.getElementById("a11y-status-message");return t||((t=e.createElement("div")).setAttribute("id","a11y-status-message"),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-relevant","additions text"),Object.assign(t.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px"}),e.body.appendChild(t),t)}var G=Object.freeze({__proto__:null,unknown:0,mouseUp:1,itemMouseEnter:2,keyDownArrowUp:3,keyDownArrowDown:4,keyDownEscape:5,keyDownEnter:6,keyDownHome:7,keyDownEnd:8,clickItem:9,blurInput:10,changeInput:11,keyDownSpaceButton:12,clickButton:13,blurButton:14,controlledPropUpdatedSelectedItem:15,touchEnd:16}),Y=["refKey","ref"],z=["onClick","onPress","onKeyDown","onKeyUp","onBlur"],Q=["onKeyDown","onBlur","onChange","onInput","onChangeText"],X=["refKey","ref"],J=["onMouseMove","onMouseDown","onClick","onPress","index","item"],Z=function(){var e=function(e){var t,n;function r(t){var n;(n=e.call(this,t)||this).id=n.props.id||"downshift-"+String(k++),n.menuId=n.props.menuId||n.id+"-menu",n.labelId=n.props.labelId||n.id+"-label",n.inputId=n.props.inputId||n.id+"-input",n.getItemId=n.props.getItemId||function(e){return n.id+"-item-"+e},n.input=null,n.items=[],n.itemCount=null,n.previousResultCount=0,n.timeoutIds=[],n.internalSetTimeout=function(e,t){var r=setTimeout((function(){n.timeoutIds=n.timeoutIds.filter((function(e){return e!==r})),e()}),t);n.timeoutIds.push(r)},n.setItemCount=function(e){n.itemCount=e},n.unsetItemCount=function(){n.itemCount=null},n.setHighlightedIndex=function(e,t){void 0===e&&(e=n.props.defaultHighlightedIndex),void 0===t&&(t={}),t=B(t),n.internalSetState(Object(v.a)({highlightedIndex:e},t))},n.clearSelection=function(e){n.internalSetState({selectedItem:null,inputValue:"",highlightedIndex:n.props.defaultHighlightedIndex,isOpen:n.props.defaultIsOpen},e)},n.selectItem=function(e,t,r){t=B(t),n.internalSetState(Object(v.a)({isOpen:n.props.defaultIsOpen,highlightedIndex:n.props.defaultHighlightedIndex,selectedItem:e,inputValue:n.props.itemToString(e)},t),r)},n.selectItemAtIndex=function(e,t,r){var o=n.items[e];null!=o&&n.selectItem(o,t,r)},n.selectHighlightedItem=function(e,t){return n.selectItemAtIndex(n.getState().highlightedIndex,e,t)},n.internalSetState=function(e,t){var r,o,i={},a="function"==typeof e;return!a&&e.hasOwnProperty("inputValue")&&n.props.onInputValueChange(e.inputValue,Object(v.a)({},n.getStateAndHelpers(),e)),n.setState((function(t){t=n.getState(t);var c=a?e(t):e;c=n.props.stateReducer(t,c),r=c.hasOwnProperty("selectedItem");var s={},u={};return r&&c.selectedItem!==t.selectedItem&&(o=c.selectedItem),c.type=c.type||0,Object.keys(c).forEach((function(e){t[e]!==c[e]&&(i[e]=c[e]),"type"!==e&&(u[e]=c[e],L(n.props,e)||(s[e]=c[e]))})),a&&c.hasOwnProperty("inputValue")&&n.props.onInputValueChange(c.inputValue,Object(v.a)({},n.getStateAndHelpers(),c)),s}),(function(){x(t)(),Object.keys(i).length>1&&n.props.onStateChange(i,n.getStateAndHelpers()),r&&n.props.onSelect(e.selectedItem,n.getStateAndHelpers()),void 0!==o&&n.props.onChange(o,n.getStateAndHelpers()),n.props.onUserAction(i,n.getStateAndHelpers())}))},n.rootRef=function(e){return n._rootNode=e},n.getRootProps=function(e,t){var r,o=void 0===e?{}:e,i=o.refKey,a=void 0===i?"ref":i,c=o.ref,s=h(o,Y),u=(void 0===t?{}:t).suppressRefError,l=void 0!==u&&u;n.getRootProps.called=!0,n.getRootProps.refKey=a,n.getRootProps.suppressRefError=l;var d=n.getState().isOpen;return Object(v.a)(((r={})[a]=A(c,n.rootRef),r.role="combobox",r["aria-expanded"]=d,r["aria-haspopup"]="listbox",r["aria-owns"]=d?n.menuId:null,r["aria-labelledby"]=n.labelId,r),s)},n.keyDownHandlers={ArrowDown:function(e){var t=this;if(e.preventDefault(),this.getState().isOpen){var n=e.shiftKey?5:1;this.moveHighlightedIndex(n,{type:4})}else this.internalSetState({isOpen:!0,type:4},(function(){var e=t.getItemCount();if(e>0){var n=F(1,t.getState().highlightedIndex,e,(function(e){return t.getItemNodeFromIndex(e)}));t.setHighlightedIndex(n,{type:4})}}))},ArrowUp:function(e){var t=this;if(e.preventDefault(),this.getState().isOpen){var n=e.shiftKey?-5:-1;this.moveHighlightedIndex(n,{type:3})}else this.internalSetState({isOpen:!0,type:3},(function(){var e=t.getItemCount();if(e>0){var n=F(-1,t.getState().highlightedIndex,e,(function(e){return t.getItemNodeFromIndex(e)}));t.setHighlightedIndex(n,{type:3})}}))},Enter:function(e){if(229!==e.which){var t=this.getState(),n=t.isOpen,r=t.highlightedIndex;if(n&&null!=r){e.preventDefault();var o=this.items[r],i=this.getItemNodeFromIndex(r);if(null==o||i&&i.hasAttribute("disabled"))return;this.selectHighlightedItem({type:6})}}},Escape:function(e){e.preventDefault(),this.reset(Object(v.a)({type:5},!this.state.isOpen&&{selectedItem:null,inputValue:""}))}},n.buttonKeyDownHandlers=Object(v.a)({},n.keyDownHandlers,{" ":function(e){e.preventDefault(),this.toggleMenu({type:12})}}),n.inputKeyDownHandlers=Object(v.a)({},n.keyDownHandlers,{Home:function(e){var t=this,n=this.getState().isOpen;if(n){e.preventDefault();var r=this.getItemCount();if(!(r<=0)&&n){var o=K(1,0,r,(function(e){return t.getItemNodeFromIndex(e)}),!1);this.setHighlightedIndex(o,{type:7})}}},End:function(e){var t=this,n=this.getState().isOpen;if(n){e.preventDefault();var r=this.getItemCount();if(!(r<=0)&&n){var o=K(-1,r-1,r,(function(e){return t.getItemNodeFromIndex(e)}),!1);this.setHighlightedIndex(o,{type:8})}}}}),n.getToggleButtonProps=function(e){var t=void 0===e?{}:e,r=t.onClick;t.onPress;var o=t.onKeyDown,i=t.onKeyUp,a=t.onBlur,c=h(t,z),s=n.getState().isOpen,u={onClick:M(r,n.buttonHandleClick),onKeyDown:M(o,n.buttonHandleKeyDown),onKeyUp:M(i,n.buttonHandleKeyUp),onBlur:M(a,n.buttonHandleBlur)},l=c.disabled?{}:u;return Object(v.a)({type:"button",role:"button","aria-label":s?"close menu":"open menu","aria-haspopup":!0,"data-toggle":!0},l,c)},n.buttonHandleKeyUp=function(e){e.preventDefault()},n.buttonHandleKeyDown=function(e){var t=V(e);n.buttonKeyDownHandlers[t]&&n.buttonKeyDownHandlers[t].call(y(n),e)},n.buttonHandleClick=function(e){e.preventDefault(),n.props.environment.document.activeElement===n.props.environment.document.body&&e.target.focus(),n.internalSetTimeout((function(){return n.toggleMenu({type:13})}))},n.buttonHandleBlur=function(e){var t=e.target;n.internalSetTimeout((function(){n.isMouseDown||null!=n.props.environment.document.activeElement&&n.props.environment.document.activeElement.id===n.inputId||n.props.environment.document.activeElement===t||n.reset({type:14})}))},n.getLabelProps=function(e){return Object(v.a)({htmlFor:n.inputId,id:n.labelId},e)},n.getInputProps=function(e){var t=void 0===e?{}:e,r=t.onKeyDown,o=t.onBlur,i=t.onChange,a=t.onInput;t.onChangeText;var c,s=h(t,Q),u={},l=n.getState(),d=l.inputValue,p=l.isOpen,f=l.highlightedIndex;return s.disabled||((c={}).onChange=M(i,a,n.inputHandleChange),c.onKeyDown=M(r,n.inputHandleKeyDown),c.onBlur=M(o,n.inputHandleBlur),u=c),Object(v.a)({"aria-autocomplete":"list","aria-activedescendant":p&&"number"==typeof f&&f>=0?n.getItemId(f):null,"aria-controls":p?n.menuId:null,"aria-labelledby":n.labelId,autoComplete:"off",value:d,id:n.inputId},u,s)},n.inputHandleKeyDown=function(e){var t=V(e);t&&n.inputKeyDownHandlers[t]&&n.inputKeyDownHandlers[t].call(y(n),e)},n.inputHandleChange=function(e){n.internalSetState({type:11,isOpen:!0,inputValue:e.target.value,highlightedIndex:n.props.defaultHighlightedIndex})},n.inputHandleBlur=function(){n.internalSetTimeout((function(){var e=n.props.environment.document&&!!n.props.environment.document.activeElement&&!!n.props.environment.document.activeElement.dataset&&n.props.environment.document.activeElement.dataset.toggle&&n._rootNode&&n._rootNode.contains(n.props.environment.document.activeElement);n.isMouseDown||e||n.reset({type:10})}))},n.menuRef=function(e){n._menuNode=e},n.getMenuProps=function(e,t){var r,o=void 0===e?{}:e,i=o.refKey,a=void 0===i?"ref":i,c=o.ref,s=h(o,X),u=(void 0===t?{}:t).suppressRefError,l=void 0!==u&&u;return n.getMenuProps.called=!0,n.getMenuProps.refKey=a,n.getMenuProps.suppressRefError=l,Object(v.a)(((r={})[a]=A(c,n.menuRef),r.role="listbox",r["aria-labelledby"]=s&&s["aria-label"]?null:n.labelId,r.id=n.menuId,r),s)},n.getItemProps=function(e){var t,r=void 0===e?{}:e,o=r.onMouseMove,i=r.onMouseDown,a=r.onClick;r.onPress;var c=r.index,s=r.item,u=void 0===s?void 0:s,l=h(r,J);void 0===c?(n.items.push(u),c=n.items.indexOf(u)):n.items[c]=u;var d=a,p=((t={onMouseMove:M(o,(function(){c!==n.getState().highlightedIndex&&(n.setHighlightedIndex(c,{type:2}),n.avoidScrolling=!0,n.internalSetTimeout((function(){return n.avoidScrolling=!1}),250))})),onMouseDown:M(i,(function(e){e.preventDefault()}))}).onClick=M(d,(function(){n.selectItemAtIndex(c,{type:9})})),t),f=l.disabled?{onMouseDown:p.onMouseDown}:p;return Object(v.a)({id:n.getItemId(c),role:"option","aria-selected":n.getState().highlightedIndex===c},f,l)},n.clearItems=function(){n.items=[]},n.reset=function(e,t){void 0===e&&(e={}),e=B(e),n.internalSetState((function(t){var r=t.selectedItem;return Object(v.a)({isOpen:n.props.defaultIsOpen,highlightedIndex:n.props.defaultHighlightedIndex,inputValue:n.props.itemToString(r)},e)}),t)},n.toggleMenu=function(e,t){void 0===e&&(e={}),e=B(e),n.internalSetState((function(t){var r=t.isOpen;return Object(v.a)({isOpen:!r},r&&{highlightedIndex:n.props.defaultHighlightedIndex},e)}),(function(){var r=n.getState(),o=r.isOpen,i=r.highlightedIndex;o&&n.getItemCount()>0&&"number"==typeof i&&n.setHighlightedIndex(i,e),x(t)()}))},n.openMenu=function(e){n.internalSetState({isOpen:!0},e)},n.closeMenu=function(e){n.internalSetState({isOpen:!1},e)},n.updateStatus=T((function(){var e=n.getState(),t=n.items[e.highlightedIndex],r=n.getItemCount(),o=n.props.getA11yStatusMessage(Object(v.a)({itemToString:n.props.itemToString,previousResultCount:n.previousResultCount,resultCount:r,highlightedItem:t},e));n.previousResultCount=r,$(o,n.props.environment.document)}),200);var r=n.props,o=r.defaultHighlightedIndex,i=r.initialHighlightedIndex,a=void 0===i?o:i,c=r.defaultIsOpen,s=r.initialIsOpen,u=void 0===s?c:s,l=r.initialInputValue,d=void 0===l?"":l,p=r.initialSelectedItem,f=void 0===p?null:p,m=n.getState({highlightedIndex:a,isOpen:u,inputValue:d,selectedItem:f});return null!=m.selectedItem&&void 0===n.props.initialInputValue&&(m.inputValue=n.props.itemToString(m.selectedItem)),n.state=m,n}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,O(t,n);var o=r.prototype;return o.internalClearTimeouts=function(){this.timeoutIds.forEach((function(e){clearTimeout(e)})),this.timeoutIds=[]},o.getState=function(e){return void 0===e&&(e=this.state),t=e,n=this.props,Object.keys(t).reduce((function(e,r){return e[r]=L(n,r)?n[r]:t[r],e}),{});var t,n},o.getItemCount=function(){var e=this.items.length;return null!=this.itemCount?e=this.itemCount:void 0!==this.props.itemCount&&(e=this.props.itemCount),e},o.getItemNodeFromIndex=function(e){return this.props.environment.document.getElementById(this.getItemId(e))},o.scrollHighlightedItemIntoView=function(){var e=this.getItemNodeFromIndex(this.getState().highlightedIndex);this.props.scrollIntoView(e,this._menuNode)},o.moveHighlightedIndex=function(e,t){var n=this,r=this.getItemCount(),o=this.getState().highlightedIndex;if(r>0){var i=F(e,o,r,(function(e){return n.getItemNodeFromIndex(e)}));this.setHighlightedIndex(i,t)}},o.getStateAndHelpers=function(){var e=this.getState(),t=e.highlightedIndex,n=e.inputValue,r=e.selectedItem,o=e.isOpen,i=this.props.itemToString,a=this.id,c=this.getRootProps,s=this.getToggleButtonProps,u=this.getLabelProps,l=this.getMenuProps,d=this.getInputProps,p=this.getItemProps,f=this.openMenu,m=this.closeMenu,b=this.toggleMenu,g=this.selectItem,h=this.selectItemAtIndex,v=this.selectHighlightedItem,y=this.setHighlightedIndex,O=this.clearSelection,w=this.clearItems;return{getRootProps:c,getToggleButtonProps:s,getLabelProps:u,getMenuProps:l,getInputProps:d,getItemProps:p,reset:this.reset,openMenu:f,closeMenu:m,toggleMenu:b,selectItem:g,selectItemAtIndex:h,selectHighlightedItem:v,setHighlightedIndex:y,clearSelection:O,clearItems:w,setItemCount:this.setItemCount,unsetItemCount:this.unsetItemCount,setState:this.internalSetState,itemToString:i,id:a,highlightedIndex:t,inputValue:n,isOpen:o,selectedItem:r}},o.componentDidMount=function(){var e=this,t=function(){e.isMouseDown=!0},n=function(t){e.isMouseDown=!1,!q(t.target,[e._rootNode,e._menuNode],e.props.environment)&&e.getState().isOpen&&e.reset({type:1},(function(){return e.props.onOuterClick(e.getStateAndHelpers())}))},r=function(){e.isTouchMove=!1},o=function(){e.isTouchMove=!0},i=function(t){var n=q(t.target,[e._rootNode,e._menuNode],e.props.environment,!1);e.isTouchMove||n||!e.getState().isOpen||e.reset({type:16},(function(){return e.props.onOuterClick(e.getStateAndHelpers())}))},a=this.props.environment;a.addEventListener("mousedown",t),a.addEventListener("mouseup",n),a.addEventListener("touchstart",r),a.addEventListener("touchmove",o),a.addEventListener("touchend",i),this.cleanup=function(){e.internalClearTimeouts(),e.updateStatus.cancel(),a.removeEventListener("mousedown",t),a.removeEventListener("mouseup",n),a.removeEventListener("touchstart",r),a.removeEventListener("touchmove",o),a.removeEventListener("touchend",i)}},o.shouldScroll=function(e,t){var n=(void 0===this.props.highlightedIndex?this.getState():this.props).highlightedIndex,r=(void 0===t.highlightedIndex?e:t).highlightedIndex;return n&&this.getState().isOpen&&!e.isOpen||n!==r},o.componentDidUpdate=function(e,t){L(this.props,"selectedItem")&&this.props.selectedItemChanged(e.selectedItem,this.props.selectedItem)&&this.internalSetState({type:15,inputValue:this.props.itemToString(this.props.selectedItem)}),!this.avoidScrolling&&this.shouldScroll(t,e)&&this.scrollHighlightedItemIntoView(),this.updateStatus()},o.componentWillUnmount=function(){this.cleanup()},o.render=function(){var e=N(this.props.children,C);this.clearItems(),this.getRootProps.called=!1,this.getRootProps.refKey=void 0,this.getRootProps.suppressRefError=void 0,this.getMenuProps.called=!1,this.getMenuProps.refKey=void 0,this.getMenuProps.suppressRefError=void 0,this.getLabelProps.called=!1,this.getInputProps.called=!1;var t=N(e(this.getStateAndHelpers()));return t?this.getRootProps.called||this.props.suppressRefError?t:function(e){return"string"==typeof e.type}(t)?Object(w.cloneElement)(t,this.getRootProps(function(e){return e.props}(t))):void 0:null},r}(w.Component);return e.defaultProps={defaultHighlightedIndex:null,defaultIsOpen:!1,getA11yStatusMessage:D,itemToString:function(e){return null==e?"":String(e)},onStateChange:C,onInputValueChange:C,onUserAction:C,onChange:C,onSelect:C,onOuterClick:C,selectedItemChanged:function(e,t){return e!==t},environment:"undefined"==typeof window?{}:window,stateReducer:function(e,t){return t},suppressRefError:!1,scrollIntoView:P},e.stateChangeTypes=G,e}();T((function(e,t){$(e(),t)}),200),"undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?w.useLayoutEffect:w.useEffect;var ee={itemToString:function(e){return e?String(e):""},stateReducer:function(e,t){return t.changes},getA11ySelectionMessage:function(e){var t=e.selectedItem,n=e.itemToString;return t?n(t)+" has been selected.":""},scrollIntoView:P,circularNavigation:!1,environment:"undefined"==typeof window?{}:window};m.a.array.isRequired,m.a.func,m.a.func,m.a.func,m.a.bool,m.a.number,m.a.number,m.a.number,m.a.bool,m.a.bool,m.a.bool,m.a.any,m.a.any,m.a.any,m.a.string,m.a.string,m.a.string,m.a.func,m.a.string,m.a.func,m.a.func,m.a.func,m.a.func,m.a.func,m.a.shape({addEventListener:m.a.func,removeEventListener:m.a.func,document:m.a.shape({getElementById:m.a.func,activeElement:m.a.any,body:m.a.any})}),S(S({},ee),{getA11yStatusMessage:function(e){var t=e.isOpen,n=e.resultCount,r=e.previousResultCount;return t?n?n!==r?n+" result"+(1===n?" is":"s are")+" available, use up and down arrow keys to navigate. Press Enter or Space Bar keys to select.":"":"No results are available.":""}}),m.a.array.isRequired,m.a.func,m.a.func,m.a.func,m.a.bool,m.a.number,m.a.number,m.a.number,m.a.bool,m.a.bool,m.a.bool,m.a.any,m.a.any,m.a.any,m.a.string,m.a.string,m.a.string,m.a.string,m.a.string,m.a.string,m.a.func,m.a.string,m.a.string,m.a.func,m.a.func,m.a.func,m.a.func,m.a.func,m.a.func,m.a.shape({addEventListener:m.a.func,removeEventListener:m.a.func,document:m.a.shape({getElementById:m.a.func,activeElement:m.a.any,body:m.a.any})}),Object(v.a)({},ee,{getA11yStatusMessage:D,circularNavigation:!0}),m.a.array,m.a.array,m.a.array,m.a.func,m.a.func,m.a.func,m.a.number,m.a.number,m.a.number,m.a.func,m.a.func,m.a.string,m.a.string,m.a.shape({addEventListener:m.a.func,removeEventListener:m.a.func,document:m.a.shape({getElementById:m.a.func,activeElement:m.a.any,body:m.a.any})});var te=e=>{let{checked:t,getInputProps:n,inputRef:r,isDisabled:i,onFocus:a,onRemoveItem:c,placeholder:s,tabIndex:u,value:l}=e;return Object(o.createElement)("input",n({ref:r,className:"wc-block-dropdown-selector__input wc-block-components-dropdown-selector__input",disabled:i,onFocus:a,onKeyDown(e){"Backspace"===e.key&&!l&&t.length>0&&c(t[t.length-1])},placeholder:s,tabIndex:u}))},ne=e=>{let{children:t,onClick:n}=e;return Object(o.createElement)("div",{className:"wc-block-dropdown-selector__input-wrapper wc-block-components-dropdown-selector__input-wrapper",onClick:n},t)},re=e=>{let{checked:t,getItemProps:n,getMenuProps:r,highlightedIndex:a,options:c}=e;return Object(o.createElement)("ul",r({className:"wc-block-dropdown-selector__list wc-block-components-dropdown-selector__list"}),c.map((e,r)=>{const c=t.includes(e.value);return Object(o.createElement)("li",n({key:e.value,className:g()("wc-block-dropdown-selector__list-item","wc-block-components-dropdown-selector__list-item",{"is-selected":c,"is-highlighted":a===r}),index:r,item:e.value,"aria-label":c?Object(i.sprintf)(
|
14 |
/* translators: %s is referring to the filter option being removed. */
|
15 |
Object(i.__)("Remove %s filter","woo-gutenberg-products-block"),e.name):null}),e.label)}))},oe=n(168),ie=e=>{let{onRemoveItem:t,option:n}=e;return Object(o.createElement)(oe.a,{className:"wc-block-dropdown-selector__selected-chip wc-block-components-dropdown-selector__selected-chip",removeOnAnyClick:!0,onRemove:()=>{t(n.value)},ariaLabel:Object(i.sprintf)(
|
16 |
/* translators: %s is referring to the filter option being removed. */
|
17 |
+
Object(i.__)("Remove %s filter","woo-gutenberg-products-block"),n.name),text:n.label,radius:"large"})},ae=n(98),ce=n(165),se=e=>{let{onClick:t,onRemoveItem:n,option:r}=e;const a=Object(o.useRef)(null);return Object(o.useEffect)(()=>{a.current.focus()},[a]),Object(o.createElement)("div",{className:"wc-block-dropdown-selector__selected-value wc-block-components-dropdown-selector__selected-value"},Object(o.createElement)("button",{ref:a,className:"wc-block-dropdown-selector__selected-value__label wc-block-components-dropdown-selector__selected-value__label",onClick:e=>{e.stopPropagation(),t(r.value)},"aria-label":Object(i.sprintf)(
|
18 |
/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */
|
19 |
Object(i.__)("Replace current %s filter","woo-gutenberg-products-block"),r.name)},r.label),Object(o.createElement)("button",{className:"wc-block-dropdown-selector__selected-value__remove wc-block-components-dropdown-selector__selected-value__remove",onClick:()=>{n(r.value)},onKeyDown:e=>{"Backspace"!==e.key&&"Delete"!==e.key||n(r.value)},"aria-label":Object(i.sprintf)(
|
20 |
/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */
|
21 |
+
Object(i.__)("Remove %s filter","woo-gutenberg-products-block"),r.name)},Object(o.createElement)(ae.a,{srcElement:ce.a,size:16})))};n(184);var ue=e=>{let{attributeLabel:t="",className:n,checked:r=[],inputLabel:a="",isDisabled:c=!1,isLoading:s=!1,multiple:u=!1,onChange:l=(()=>{}),options:d=[]}=e;const p=Object(o.useRef)(null),f=g()(n,"wc-block-dropdown-selector","wc-block-components-dropdown-selector",{"is-disabled":c,"is-loading":s}),m=Object(o.useCallback)((e,t)=>{switch(t.type){case Z.stateChangeTypes.keyDownEnter:case Z.stateChangeTypes.clickItem:return{...t,highlightedIndex:e.highlightedIndex,isOpen:u,inputValue:""};case Z.stateChangeTypes.blurInput:case Z.stateChangeTypes.mouseUp:return{...t,inputValue:e.inputValue};default:return t}},[u]);return Object(o.createElement)(Z,{onChange:l,selectedItem:null,stateReducer:m},e=>{let{getInputProps:n,getItemProps:s,getLabelProps:m,getMenuProps:b,highlightedIndex:h,inputValue:v,isOpen:y,openMenu:O}=e;return Object(o.createElement)("div",{className:g()(f,{"is-multiple":u,"is-single":!u,"has-checked":r.length>0,"is-open":y})},Object(o.createElement)("label",m({className:"screen-reader-text"}),a),Object(o.createElement)(ne,{isOpen:y,onClick:()=>p.current.focus()},r.map(e=>{const t=d.find(t=>t.value===e),n=e=>{l(e),p.current.focus()};return u?Object(o.createElement)(ie,{key:e,onRemoveItem:n,option:t}):Object(o.createElement)(se,{key:e,onClick:()=>p.current.focus(),onRemoveItem:n,option:t})}),Object(o.createElement)(te,{checked:r,getInputProps:n,inputRef:p,isDisabled:c,onFocus:O,onRemoveItem:e=>{l(e),p.current.focus()},placeholder:r.length>0&&u?null:Object(i.sprintf)(
|
22 |
/* translators: %s attribute name. */
|
23 |
+
Object(i.__)("Any %s","woo-gutenberg-products-block"),t),tabIndex:!u&&r.length>0?"-1":"0",value:v})),y&&!c&&Object(o.createElement)(re,{checked:r,getItemProps:s,getMenuProps:b,highlightedIndex:h,options:d.filter(e=>!v||e.value.startsWith(v))}))})},le=n(55),de=n(72),pe=n(11),fe=n.n(pe),me=n(19),be=n(95),ge=n(104),he=n(105);const ve=[{value:"preview-1",name:"Blue",label:Object(o.createElement)(le.a,{name:"Blue",count:3})},{value:"preview-2",name:"Green",label:Object(o.createElement)(le.a,{name:"Green",count:3})},{value:"preview-3",name:"Red",label:Object(o.createElement)(le.a,{name:"Red",count:2})}],ye={id:0,name:"preview",taxonomy:"preview",label:"Preview"};n(183);Object(r.a)({selector:".wp-block-woocommerce-attribute-filter",Block:e=>{let{attributes:t,isEditor:n=!1}=e;const r=t.isPreview&&!t.attributeId?ye:Object(ge.a)(t.attributeId),[f,m]=Object(o.useState)([]),[b,g]=Object(o.useState)(t.isPreview&&!t.attributeId?ve:[]),[h]=Object(u.a)(),[v,y]=Object(u.b)("attributes",[]),{results:O,isLoading:w}=Object(l.a)({namespace:"/wc/store",resourceName:"products/attributes/terms",resourceValues:[(null==r?void 0:r.id)||0],shouldSelect:t.attributeId>0}),j="dropdown"!==t.displayStyle&&"and"===t.queryType,{results:E,isLoading:I}=Object(d.a)({queryAttribute:{taxonomy:null==r?void 0:r.taxonomy,queryType:t.queryType},queryState:{...h,attributes:j?h.attributes:null}}),_=Object(o.useCallback)(e=>E.attribute_counts?E.attribute_counts.find(t=>{let{term:n}=t;return n===e}):null,[E]);Object(o.useEffect)(()=>{if(w||I)return;const e=O.map(e=>{const n=_(e.id);if(!(n||f.includes(e.slug)||(i=e.slug,null!=h&&h.attributes&&h.attributes.some(e=>{let{attribute:t,slug:n=[]}=e;return t===r.taxonomy&&n.includes(i)}))))return null;var i;const a=n?n.count:0;return{value:e.slug,name:Object(me.decodeEntities)(e.name),label:Object(o.createElement)(le.a,{name:Object(me.decodeEntities)(e.name),count:t.showCounts?a:null})}}).filter(Boolean);g(e)},[null==r?void 0:r.taxonomy,O,w,t.showCounts,I,_,f,h.attributes]);const S=Object(o.useCallback)(e=>O.reduce((t,n)=>(e.includes(n.slug)&&t.push(n),t),[]),[O]),k=Object(o.useCallback)(e=>{n||Object(he.b)(v,y,r,S(e),"or"===t.queryType?"in":"and")},[n,v,y,r,S,t.queryType]),x=Object(o.useMemo)(()=>v.filter(e=>{let{attribute:t}=e;return t===(null==r?void 0:r.taxonomy)}).flatMap(e=>{let{slug:t}=e;return t}),[v,null==r?void 0:r.taxonomy]),C=Object(c.a)(x),P=Object(s.a)(C);Object(o.useEffect)(()=>{fe()(P,C)||fe()(f,C)||(m(C),t.showFilterButton||k(C))},[f,C,P,k,t.showFilterButton]);const R="dropdown"!==t.displayStyle||"or"===t.queryType,T=Object(o.useCallback)(e=>{const n=e=>{const{name:t}=b.find(t=>t.value===e);return t},r=e=>{let{filterAdded:t,filterRemoved:r}=e;const o=t?n(t):null,c=r?n(r):null;o&&c?Object(a.speak)(Object(i.sprintf)(
|
24 |
/* translators: %1$s and %2$s are attribute terms (for example: 'red', 'blue', 'large'...). */
|
25 |
Object(i.__)("%1$s filter replaced with %2$s.","woo-gutenberg-products-block"),o,c)):o?Object(a.speak)(Object(i.sprintf)(
|
26 |
/* translators: %s attribute term (for example: 'red', 'blue', 'large'...) */
|
build/attribute-filter.asset.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php return array('dependencies' => array('lodash', 'react', 'wc-blocks-data-store', 'wc-settings', 'wp-a11y', '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'), 'version' => '
|
1 |
+
<?php return array('dependencies' => array('lodash', 'react', 'wc-blocks-data-store', 'wc-settings', 'wp-a11y', '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'), 'version' => '8066f6a75764536689d28c186d23689b');
|
build/attribute-filter.js
CHANGED
@@ -1,40 +1,40 @@
|
|
1 |
-
this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["attribute-filter"]=function(e){function t(t){for(var n,l,a=t[0],s=t[1],i=t[2],b=0,d=[];b<a.length;b++)l=a[b],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&d.push(o[l][0]),o[l]=0;for(n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n]);for(u&&u(t);d.length;)d.shift()();return r.push.apply(r,i||[]),c()}function c(){for(var e,t=0;t<r.length;t++){for(var c=r[t],n=!0,a=1;a<c.length;a++){var s=c[a];0!==o[s]&&(n=!1)}n&&(r.splice(t--,1),e=l(l.s=c[0]))}return e}var n={},o={
|
2 |
/* translators: Submit button text for filters. */
|
3 |
-
r=Object(o.__)("Go","woo-gutenberg-products-block"),onClick:s,screenReaderLabel:i=Object(o.__)("Apply filter","woo-gutenberg-products-block")}=e;return Object(n.createElement)("button",{type:"submit",className:l()("wc-block-filter-submit-button","wc-block-components-filter-submit-button",t),disabled:c,onClick:s},Object(n.createElement)(a.a,{label:r,screenReaderLabel:i}))};s.defaultProps={disabled:!1},t.a=s},14:function(e,t){e.exports=window.wp.htmlEntities},
|
4 |
/* Translators: %s search term */
|
5 |
noResults:Object(r.__)("No results for %s","woo-gutenberg-products-block"),search:Object(r.__)("Search for items","woo-gutenberg-products-block"),selected:e=>Object(r.sprintf)(
|
6 |
/* translators: Number of items selected from list. */
|
7 |
-
Object(r._n)("%d item selected","%d items selected",e,"woo-gutenberg-products-block"),e),updated:Object(r.__)("Search results updated.","woo-gutenberg-products-block")},a=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;const c=Object(o.groupBy)(e,"parent"),n=Object(o.keyBy)(t,"id"),r=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e.parent)return e.name?[e.name]:[];const t=r(n[e.parent]);return[...t,e.name]},l=e=>e.map(e=>{const t=c[e.id];return delete c[e.id],{...e,breadcrumbs:r(n[e.parent]),children:t&&t.length?l(t):[]}}),a=l(c[0]||[]);return delete c[0],Object(o.forEach)(c,e=>{a.push(...l(e||[]))}),a},s=(e,t,c)=>{if(!t)return c?a(e):e;const n=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),o=e.map(e=>!!n.test(e.name)&&e).filter(Boolean);return c?a(o,e):o},i=(e,t)=>{if(!t)return e;const c=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"ig");return e.split(c).map((e,c)=>0===c?e:Object(n.createElement)(n.Fragment,{key:c},Object(n.createElement)("strong",null,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()},
|
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)))},[r,u,b]),g=Object(n.useMemo)(()=>b&&Object(n.createElement)("li",{key:"show-less",className:"show-less"},Object(n.createElement)("button",{onClick:()=>{d(!1)},"aria-expanded":!0,"aria-label":Object(o.__)("Show less options","woo-gutenberg-products-block")},Object(o.__)("Show less","woo-gutenberg-products-block"))),[b]),O=Object(n.useMemo)(()=>{const e=r.length>u+5;return Object(n.createElement)(n.Fragment,null,r.map((t,o)=>Object(n.createElement)(n.Fragment,{key:t.value},Object(n.createElement)("li",e&&!b&&o>=u&&{hidden:!0},Object(n.createElement)("input",{type:"checkbox",id:t.value,value:t.value,onChange:e=>{c(e.target.value)},checked:a.includes(t.value),disabled:i}),Object(n.createElement)("label",{htmlFor:t.value},t.label)),e&&o===u-1&&p)),e&&g)},[r,c,a,b,u,g,p,i]),h=l()("wc-block-checkbox-list","wc-block-components-checkbox-list",{"is-loading":s},t);return Object(n.createElement)("ul",{className:h},s?m:O)}},18:function(e,t){e.exports=window.wp.primitives},
|
12 |
/* translators: Remove chip. */
|
13 |
Object(s.__)("Remove","woo-gutenberg-products-block"):Object(s.sprintf)(
|
14 |
/* translators: %s text of the chip to remove. */
|
15 |
-
Object(s.__)('Remove "%s"',"woo-gutenberg-products-block"),e)}const h={"aria-label":t,disabled:n,onClick:l,onKeyDown:e=>{"Backspace"!==e.key&&"Delete"!==e.key||l()}},j=d?h:{},w=d?{"aria-hidden":!0}:h;return Object(r.createElement)(b,o()({},g,j,{className:a()(c,"is-removable"),element:d?"button":g.element,screenReaderText:p,text:m}),Object(r.createElement)(O,o()({className:"wc-block-components-chip__remove"},w),Object(r.createElement)(i.a,{className:"wc-block-components-chip__remove-icon",srcElement:u.a,size:16})))}},2:function(e,t){e.exports=window.wc.wcSettings},
|
16 |
/* translators: %s is referring to the filter option being removed. */
|
17 |
-
Object(l.__)("Remove %s filter","woo-gutenberg-products-block"),e.name):null}),e.label)}))},R=c(
|
18 |
/* translators: %s is referring to the filter option being removed. */
|
19 |
-
Object(l.__)("Remove %s filter","woo-gutenberg-products-block"),c.name),text:c.label,radius:"large"})},B=c(
|
20 |
/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */
|
21 |
Object(l.__)("Replace current %s filter","woo-gutenberg-products-block"),n.name)},n.label),Object(r.createElement)("button",{className:"wc-block-dropdown-selector__selected-value__remove wc-block-components-dropdown-selector__selected-value__remove",onClick:()=>{c(n.value)},onKeyDown:e=>{"Backspace"!==e.key&&"Delete"!==e.key||c(n.value)},"aria-label":Object(l.sprintf)(
|
22 |
/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */
|
23 |
-
Object(l.__)("Remove %s filter","woo-gutenberg-products-block"),n.name)},Object(r.createElement)(s.a,{srcElement:B.a,size:16})))};c(
|
24 |
/* translators: %s attribute name. */
|
25 |
-
Object(l.__)("Any %s","woo-gutenberg-products-block"),t),tabIndex:!i&&n.length>0?"-1":"0",value:j})),w&&!a&&Object(r.createElement)(P,{checked:n,getItemProps:s,getMenuProps:O,highlightedIndex:h,options:d.filter(e=>!j||e.value.startsWith(j))}))})},M=c(
|
26 |
/* translators: %1$s and %2$s are attribute terms (for example: 'red', 'blue', 'large'...). */
|
27 |
Object(l.__)("%1$s filter replaced with %2$s.","woo-gutenberg-products-block"),o,r)):o?Object(f.speak)(Object(l.sprintf)(
|
28 |
/* translators: %s attribute term (for example: 'red', 'blue', 'large'...) */
|
29 |
Object(l.__)("%s filter added.","woo-gutenberg-products-block"),o)):r&&Object(f.speak)(Object(l.sprintf)(
|
30 |
/* translators: %s attribute term (for example: 'red', 'blue', 'large'...) */
|
31 |
-
Object(l.__)("%s filter removed.","woo-gutenberg-products-block"),r))},r=o.includes(e);let i;R?(i=o.filter(t=>t!==e),r?n({filterRemoved:e}):(i.push(e),i.sort(),n({filterAdded:e}))):(i=r?[]:[e],n({filterAdded:r?null:e,filterRemoved:1===o.length?o[0]:null})),a(i),t.showFilterButton||S(i)},[o,s,R,S,t.showFilterButton]);if(!n)return c?Object(r.createElement)(m.Notice,{status:"warning",isDismissible:!1},Object(r.createElement)("p",null,Object(l.__)("Please select an attribute to use this filter!","woo-gutenberg-products-block"))):null;if(0===s.length&&!g)return c?Object(r.createElement)(m.Notice,{status:"warning",isDismissible:!1},Object(r.createElement)("p",null,Object(l.__)("The selected attribute does not have any term assigned to products.","woo-gutenberg-products-block"))):null;const B="h"+t.headingLevel,T=!t.isPreview&&g,A=!t.isPreview&&j;return Object(r.createElement)(r.Fragment,null,!c&&t.heading&&s.length>0&&Object(r.createElement)(B,{className:"wc-block-attribute-filter__title"},t.heading),Object(r.createElement)("div",{className:"wc-block-attribute-filter style-"+t.displayStyle},"dropdown"===t.displayStyle?Object(r.createElement)(F,{attributeLabel:n.label,checked:o,className:"wc-block-attribute-filter-dropdown",inputLabel:t.heading,isLoading:T,multiple:R,onChange:L,options:s}):Object(r.createElement)(x.a,{className:"wc-block-attribute-filter-list",options:s,checked:o,onChange:L,isLoading:T,isDisabled:A}),t.showFilterButton&&Object(r.createElement)(V.a,{className:"wc-block-attribute-filter__button",disabled:T||A,onClick:()=>S(o)})))};c(
|
32 |
/* translators: %s attribute name. */
|
33 |
Object(l.__)("Filter by %s","woo-gutenberg-products-block"),r)})},I=e=>{let{isCompact:t}=e;const c={clear:Object(l.__)("Clear selected attribute","woo-gutenberg-products-block"),list:Object(l.__)("Product Attributes","woo-gutenberg-products-block"),noItems:Object(l.__)("Your store doesn't have any product attributes.","woo-gutenberg-products-block"),search:Object(l.__)("Search for a product attribute:","woo-gutenberg-products-block"),selected:e=>Object(l.sprintf)(
|
34 |
/* translators: %d is the number of attributes selected. */
|
35 |
-
Object(l._n)("%d attribute selected","%d attributes selected",e,"woo-gutenberg-products-block"),e),updated:Object(l.__)("Product attribute search results updated.","woo-gutenberg-products-block")},n=Object(O.sortBy)(Object(O.toArray)(Object(O.mapValues)(K,e=>({id:parseInt(e.attribute_id,10),name:e.attribute_label}))),"name");return Object(r.createElement)(g.a,{className:"woocommerce-product-attributes",list:n,selected:n.filter(e=>{let{id:t}=e;return t===o}),onChange:N,messages:c,isSingle:!0,isCompact:t})};return 0===Object.keys(K).length?Object(r.createElement)(m.Placeholder,{className:"wc-block-attribute-filter",icon:Object(r.createElement)(s.a,{srcElement:i.a}),label:Object(l.__)("Filter Products by Attribute","woo-gutenberg-products-block"),instructions:Object(l.__)("Display a list of filters based on a chosen attribute.","woo-gutenberg-products-block")},Object(r.createElement)("p",null,Object(l.__)("Attributes are needed for filtering your products. You haven't created any attributes yet.","woo-gutenberg-products-block")),Object(r.createElement)(m.Button,{className:"wc-block-attribute-filter__add-attribute-button",isSecondary:!0,href:Object(h.getAdminLink)("edit.php?post_type=product&page=product_attributes")},Object(l.__)("Add new attribute","woo-gutenberg-products-block")+" ",Object(r.createElement)(s.a,{srcElement:p.a})),Object(r.createElement)(m.Button,{className:"wc-block-attribute-filter__read_more_button",isTertiary:!0,href:"https://docs.woocommerce.com/document/managing-product-taxonomies/"},Object(l.__)("Learn more","woo-gutenberg-products-block"))):Object(r.createElement)(r.Fragment,null,Object(r.createElement)(d.BlockControls,null,Object(r.createElement)(m.ToolbarGroup,{controls:[{icon:"edit",title:Object(l.__)("Edit","woo-gutenberg-products-block"),onClick:()=>S(!x),isActive:x}]})),Object(r.createElement)(d.InspectorControls,{key:"inspector"},Object(r.createElement)(m.PanelBody,{title:Object(l.__)("Content","woo-gutenberg-products-block")},Object(r.createElement)(m.ToggleControl,{label:Object(l.__)("Product count","woo-gutenberg-products-block"),help:y?Object(l.__)("Product count is visible.","woo-gutenberg-products-block"):Object(l.__)("Product count is hidden.","woo-gutenberg-products-block"),checked:y,onChange:()=>c({showCounts:!y})}),Object(r.createElement)("p",null,Object(l.__)("Heading Level","woo-gutenberg-products-block")),Object(r.createElement)(j.a,{isCollapsed:!1,minLevel:2,maxLevel:7,selectedLevel:v,onChange:e=>c({headingLevel:e})})),Object(r.createElement)(m.PanelBody,{title:Object(l.__)("Block Settings","woo-gutenberg-products-block")},Object(r.createElement)(_.a,{label:Object(l.__)("Query Type","woo-gutenberg-products-block"),help:"and"===E?Object(l.__)("Products that have all of the selected attributes will be shown.","woo-gutenberg-products-block"):Object(l.__)("Products that have any of the selected attributes will be shown.","woo-gutenberg-products-block"),value:E,options:[{label:Object(l.__)("And","woo-gutenberg-products-block"),value:"and"},{label:Object(l.__)("Or","woo-gutenberg-products-block"),value:"or"}],onChange:e=>c({queryType:e})}),Object(r.createElement)(_.a,{label:Object(l.__)("Display Style","woo-gutenberg-products-block"),value:u,options:[{label:Object(l.__)("List","woo-gutenberg-products-block"),value:"list"},{label:Object(l.__)("Dropdown","woo-gutenberg-products-block"),value:"dropdown"}],onChange:e=>c({displayStyle:e})}),Object(r.createElement)(m.ToggleControl,{label:Object(l.__)("Filter button","woo-gutenberg-products-block"),help:C?Object(l.__)("Products will only update when the button is pressed.","woo-gutenberg-products-block"):Object(l.__)("Products will update as options are selected.","woo-gutenberg-products-block"),checked:C,onChange:e=>c({showFilterButton:e})})),Object(r.createElement)(m.PanelBody,{title:Object(l.__)("Filter Products by Attribute","woo-gutenberg-products-block"),initialOpen:!1},I({isCompact:!0}))),x?Object(r.createElement)(m.Placeholder,{className:"wc-block-attribute-filter",icon:Object(r.createElement)(s.a,{srcElement:i.a}),label:Object(l.__)("Filter Products by Attribute","woo-gutenberg-products-block"),instructions:Object(l.__)("Display a list of filters based on a chosen attribute.","woo-gutenberg-products-block")},Object(r.createElement)("div",{className:"wc-block-attribute-filter__selection"},I({isCompact:!1}),Object(r.createElement)(m.Button,{isPrimary:!0,onClick:()=>{S(!1),n(Object(l.__)("Showing Filter Products by Attribute block preview.","woo-gutenberg-products-block"))}},Object(l.__)("Done","woo-gutenberg-products-block")))):Object(r.createElement)("div",{className:b()(a,"wc-block-attribute-filter")},Object(r.createElement)(w.a,{className:"wc-block-attribute-filter__title",headingLevel:v,heading:f,onChange:e=>c({heading:e})}),Object(r.createElement)(m.Disabled,null,Object(r.createElement)($,{attributes:t,isEditor:!0}))))});Object(a.registerBlockType)("woocommerce/attribute-filter",{title:Object(l.__)("Filter Products by Attribute","woo-gutenberg-products-block"),icon:{src:Object(r.createElement)(s.a,{srcElement:i.a,className:"wc-block-editor-components-block-icon"})},category:"woocommerce",keywords:[Object(l.__)("WooCommerce","woo-gutenberg-products-block")],description:Object(l.__)("Allow customers to filter the grid by product attribute, such as color. Works in combination with the All Products block.","woo-gutenberg-products-block"),supports:{html:!1},example:{attributes:{isPreview:!0}},attributes:{attributeId:{type:"number",default:0},showCounts:{type:"boolean",default:!0},queryType:{type:"string",default:"or"},heading:{type:"string",default:Object(l.__)("Filter by attribute","woo-gutenberg-products-block")},headingLevel:{type:"number",default:3},displayStyle:{type:"string",default:"list"},showFilterButton:{type:"boolean",default:!1},isPreview:{type:"boolean",default:!1}},edit:Q,save(e){let{attributes:t}=e;const{className:c,showCounts:n,queryType:l,attributeId:a,heading:s,headingLevel:i,displayStyle:u,showFilterButton:d}=t,m={"data-attribute-id":a,"data-show-counts":n,"data-query-type":l,"data-heading":s,"data-heading-level":i};return"list"!==u&&(m["data-display-style"]=u),d&&(m["data-show-filter-button"]=d),Object(r.createElement)("div",o()({className:b()("is-loading",c)},m),Object(r.createElement)("span",{"aria-hidden":!0,className:"wc-block-product-attribute-filter__placeholder"}))}})},46:function(e,t){e.exports=window.wp.a11y},48:function(e,t,c){"use strict";c.d(t,"a",(function(){return r}));var n=c(0);const o=Object(n.createContext)("page"),r=()=>Object(n.useContext)(o
|
36 |
-
Object(l.__)("Remove %s","woo-gutenberg-products-block"),c),"aria-describedby":_},Object(r.createElement)(s.a,{icon:g.a,size:20,className:"clear-icon"})))};var j=h;const w=e=>Object(r.createElement)(p.b,e),_=e=>{const{list:t,selected:c,renderItem:n,depth:l=0,onSelect:a,instanceId:s,isSingle:i,search:u}=e;return t?Object(r.createElement)(r.Fragment,null,t.map(t=>{const b=-1!==c.findIndex(e=>{let{id:c}=e;return c===t.id});return Object(r.createElement)(r.Fragment,{key:t.id},Object(r.createElement)("li",null,n({item:t,isSelected:b,onSelect:a,isSingle:i,search:u,depth:l,controlId:s})),Object(r.createElement)(_,o()({},e,{list:t.children,depth:l+1})))})):null},f=e=>{let{isLoading:t,isSingle:c,selected:n,messages:o,onChange:s,onRemove:i}=e;if(t||c||!n)return null;const u=n.length;return Object(r.createElement)("div",{className:"woocommerce-search-list__selected"},Object(r.createElement)("div",{className:"woocommerce-search-list__selected-header"},Object(r.createElement)("strong",null,o.selected(u)),u>0?Object(r.createElement)(a.Button,{isLink:!0,isDestructive:!0,onClick:()=>s([]),"aria-label":o.clear},Object(l.__)("Clear all","woo-gutenberg-products-block")):null),u>0?Object(r.createElement)("ul",null,n.map((e,t)=>Object(r.createElement)("li",{key:t},Object(r.createElement)(j,{label:e.name,id:e.id,remove:i})))):null)},v=e=>{let{filteredList:t,search:c,onSelect:n,instanceId:o,...a}=e;const{messages:u,renderItem:b,selected:d,isSingle:m}=a,p=b||w;return 0===t.length?Object(r.createElement)("div",{className:"woocommerce-search-list__list is-not-found"},Object(r.createElement)("span",{className:"woocommerce-search-list__not-found-icon"},Object(r.createElement)(s.a,{icon:i.a})),Object(r.createElement)("span",{className:"woocommerce-search-list__not-found-text"},c?Object(l.sprintf)(u.noResults,c):u.noItems)):Object(r.createElement)("ul",{className:"woocommerce-search-list__list"},Object(r.createElement)(_,{list:t,selected:d,renderItem:p,onSelect:n,instanceId:o,isSingle:m,search:c}))},k=e=>{const{className:t="",isCompact:c,isHierarchical:n,isLoading:l,isSingle:s,list:i,messages:u=m.a,onChange:p,onSearch:g,selected:O,debouncedSpeak:h}=e,[j,w]=Object(r.useState)(""),_=Object(d.useInstanceId)(k),E=Object(r.useMemo)(()=>({...m.a,...u}),[u]),y=Object(r.useMemo)(()=>Object(m.c)(i,j,n),[i,j,n]);Object(r.useEffect)(()=>{h&&h(E.updated)},[h,E]),Object(r.useEffect)(()=>{"function"==typeof g&&g(j)},[j,g]);const C=Object(r.useCallback)(e=>()=>{s&&p([]);const t=O.findIndex(t=>{let{id:c}=t;return c===e});p([...O.slice(0,t),...O.slice(t+1)])},[s,O,p]),x=Object(r.useCallback)(e=>()=>{-1===O.findIndex(t=>{let{id:c}=t;return c===e.id})?p(s?[e]:[...O,e]):C(e.id)()},[s,C,p,O]);return Object(r.createElement)("div",{className:b()("woocommerce-search-list",t,{"is-compact":c})},Object(r.createElement)(f,o()({},e,{onRemove:C,messages:E})),Object(r.createElement)("div",{className:"woocommerce-search-list__search"},Object(r.createElement)(a.TextControl,{label:E.search,type:"search",value:j,onChange:e=>w(e)})),l?Object(r.createElement)("div",{className:"woocommerce-search-list__list is-loading"},Object(r.createElement)(a.Spinner,null)):Object(r.createElement)(v,o()({},e,{search:j,filteredList:y,messages:E,onSelect:x,instanceId:_})))};Object(a.withSpokenMessages)(k)},89:function(e,t,c){"use strict";var n=c(0),o=c(6),r=c(1),l=c(3);function a(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(n.createElement)(l.SVG,{width:"20",height:"20",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg"},Object(n.createElement)(l.Path,{d:c[t]})):null}class s extends n.Component{createLevelControl(e,t,c){const o=e===t;return{icon:Object(n.createElement)(a,{level:e}),title:Object(r.sprintf)(
|
1 |
+
this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["attribute-filter"]=function(e){function t(t){for(var n,l,a=t[0],s=t[1],i=t[2],b=0,d=[];b<a.length;b++)l=a[b],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&d.push(o[l][0]),o[l]=0;for(n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n]);for(u&&u(t);d.length;)d.shift()();return r.push.apply(r,i||[]),c()}function c(){for(var e,t=0;t<r.length;t++){for(var c=r[t],n=!0,a=1;a<c.length;a++){var s=c[a];0!==o[s]&&(n=!1)}n&&(r.splice(t--,1),e=l(l.s=c[0]))}return e}var n={},o={20:0},r=[];function l(t){if(n[t])return n[t].exports;var c=n[t]={i:t,l:!1,exports:{}};return e[t].call(c.exports,c,c.exports,l),c.l=!0,c.exports}l.m=e,l.c=n,l.d=function(e,t,c){l.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:c})},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 c=Object.create(null);if(l.r(c),Object.defineProperty(c,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)l.d(c,n,function(t){return e[t]}.bind(null,n));return c},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 r.push([373,0]),c()}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},107:function(e,t,c){"use strict";var n=c(0),o=(c(10),c(7)),r=c(9),l=c(1);c(145),t.a=Object(r.withInstanceId)(e=>{let{className:t,headingLevel:c,onChange:r,heading:a,instanceId:s}=e;const i="h"+c;return Object(n.createElement)(i,{className:t},Object(n.createElement)("label",{className:"screen-reader-text",htmlFor:"block-title-"+s},Object(l.__)("Block title","woo-gutenberg-products-block")),Object(n.createElement)(o.PlainText,{id:"block-title-"+s,className:"wc-block-editor-components-title",value:a,onChange:r}))})},109:function(e,t,c){"use strict";c.d(t,"a",(function(){return o}));var n=c(8);function o(e,t){const c=Object(n.useRef)();return Object(n.useEffect)(()=>{c.current===e||t&&!t(e,c.current)||(c.current=e)},[e,t]),c.current}},115:function(e,t,c){"use strict";c.d(t,"a",(function(){return s}));var n=c(16),o=c(13),r=c(0),l=c(39),a=c(94);const s=e=>{const{namespace:t,resourceName:c,resourceValues:s=[],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 b=Object(r.useRef)({results:[],isLoading:!0}),d=Object(l.a)(i),m=Object(l.a)(s),p=Object(a.a)(),g=Object(o.useSelect)(e=>{if(!u)return null;const o=e(n.COLLECTIONS_STORE_KEY),r=[t,c,d,m],l=o.getCollectionError(...r);return l&&p(l),{results:o.getCollection(...r),isLoading:!o.hasFinishedResolution("getCollection",r)}},[t,c,m,d,u]);return null!==g&&(b.current=g),b.current}},12:function(e,t){e.exports=window.wp.blocks},122:function(e,t,c){"use strict";var n=c(0),o=c(18);const r=Object(n.createElement)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(n.createElement)("mask",{id:"external-mask",width:"24",height:"24",x:"0",y:"0",maskUnits:"userSpaceOnUse"},Object(n.createElement)("path",{fill:"#fff",d:"M6.3431 6.3431v1.994l7.8984.0072-8.6055 8.6054 1.4142 1.4143 8.6055-8.6055.0071 7.8984h1.994V6.3431H6.3431z"})),Object(n.createElement)("g",{mask:"url(#external-mask)"},Object(n.createElement)("path",{d:"M0 0h24v24H0z"})));t.a=r},13:function(e,t){e.exports=window.wp.data},135:function(e,t,c){"use strict";var n=c(0),o=c(1),r=(c(10),c(4)),l=c.n(r),a=c(30);c(171);const s=e=>{let{className:t,disabled:c,label:
|
2 |
/* translators: Submit button text for filters. */
|
3 |
+
r=Object(o.__)("Go","woo-gutenberg-products-block"),onClick:s,screenReaderLabel:i=Object(o.__)("Apply filter","woo-gutenberg-products-block")}=e;return Object(n.createElement)("button",{type:"submit",className:l()("wc-block-filter-submit-button","wc-block-components-filter-submit-button",t),disabled:c,onClick:s},Object(n.createElement)(a.a,{label:r,screenReaderLabel:i}))};s.defaultProps={disabled:!1},t.a=s},14:function(e,t){e.exports=window.wp.htmlEntities},145:function(e,t){},146:function(e,t){},16:function(e,t){e.exports=window.wc.wcBlocksData},17:function(e,t,c){"use strict";c.d(t,"a",(function(){return l})),c.d(t,"c",(function(){return s})),c.d(t,"d",(function(){return i})),c.d(t,"b",(function(){return u}));var n=c(0),o=c(6),r=c(1);const l={clear:Object(r.__)("Clear all selected items","woo-gutenberg-products-block"),noItems:Object(r.__)("No items found.","woo-gutenberg-products-block"),
|
4 |
/* Translators: %s search term */
|
5 |
noResults:Object(r.__)("No results for %s","woo-gutenberg-products-block"),search:Object(r.__)("Search for items","woo-gutenberg-products-block"),selected:e=>Object(r.sprintf)(
|
6 |
/* translators: Number of items selected from list. */
|
7 |
+
Object(r._n)("%d item selected","%d items selected",e,"woo-gutenberg-products-block"),e),updated:Object(r.__)("Search results updated.","woo-gutenberg-products-block")},a=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;const c=Object(o.groupBy)(e,"parent"),n=Object(o.keyBy)(t,"id"),r=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e.parent)return e.name?[e.name]:[];const t=r(n[e.parent]);return[...t,e.name]},l=e=>e.map(e=>{const t=c[e.id];return delete c[e.id],{...e,breadcrumbs:r(n[e.parent]),children:t&&t.length?l(t):[]}}),a=l(c[0]||[]);return delete c[0],Object(o.forEach)(c,e=>{a.push(...l(e||[]))}),a},s=(e,t,c)=>{if(!t)return c?a(e):e;const n=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),o=e.map(e=>!!n.test(e.name)&&e).filter(Boolean);return c?a(o,e):o},i=(e,t)=>{if(!t)return e;const c=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"ig");return e.split(c).map((e,c)=>0===c?e:Object(n.createElement)(n.Fragment,{key:c},Object(n.createElement)("strong",null,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()},171:function(e,t){},177:function(e,t,c){"use strict";c.d(t,"a",(function(){return r})),c.d(t,"b",(function(){return l}));var n=c(2);const o=Object(n.getSetting)("attributes",[]).reduce((e,t)=>{const c=(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 c.id&&e.push(c),e},[]),r=e=>{if(e)return o.find(t=>t.id===e)},l=e=>{if(e)return o.find(t=>t.taxonomy===e)}},178:function(e,t,c){"use strict";c.d(t,"a",(function(){return o})),c.d(t,"b",(function(){return r}));var n=c(6);const o=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>{},c=arguments.length>2?arguments[2]:void 0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";const r=e.filter(e=>e.attribute===c.taxonomy),l=r.length?r[0]:null;if(!(l&&l.slug&&Array.isArray(l.slug)&&l.slug.includes(o)))return;const a=l.slug.filter(e=>e!==o),s=e.filter(e=>e.attribute!==c.taxonomy);a.length>0&&(l.slug=a.sort(),s.push(l)),t(Object(n.sortBy)(s,"attribute"))},r=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>{},c=arguments.length>2?arguments[2]:void 0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"in";const l=e.filter(e=>e.attribute!==c.taxonomy);0===o.length?t(l):(l.push({attribute:c.taxonomy,operator:r,slug:o.map(e=>{let{slug:t}=e;return t}).sort()}),t(Object(n.sortBy)(l,"attribute")))}},179:function(e,t,c){"use strict";var n=c(0),o=c(1),r=c(4),l=c.n(r);c(212),t.a=e=>{let{className:t,onChange:c=(()=>{}),options:r=[],checked:a=[],isLoading:s=!1,isDisabled:i=!1,limit:u=10}=e;const[b,d]=Object(n.useState)(!1),m=Object(n.useMemo)(()=>[...Array(5)].map((e,t)=>Object(n.createElement)("li",{key:t,style:{width:Math.floor(75*Math.random())+25+"%"}})),[]),p=Object(n.useMemo)(()=>{const e=r.length-u;return!b&&Object(n.createElement)("li",{key:"show-more",className:"show-more"},Object(n.createElement)("button",{onClick:()=>{d(!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)))},[r,u,b]),g=Object(n.useMemo)(()=>b&&Object(n.createElement)("li",{key:"show-less",className:"show-less"},Object(n.createElement)("button",{onClick:()=>{d(!1)},"aria-expanded":!0,"aria-label":Object(o.__)("Show less options","woo-gutenberg-products-block")},Object(o.__)("Show less","woo-gutenberg-products-block"))),[b]),O=Object(n.useMemo)(()=>{const e=r.length>u+5;return Object(n.createElement)(n.Fragment,null,r.map((t,o)=>Object(n.createElement)(n.Fragment,{key:t.value},Object(n.createElement)("li",e&&!b&&o>=u&&{hidden:!0},Object(n.createElement)("input",{type:"checkbox",id:t.value,value:t.value,onChange:e=>{c(e.target.value)},checked:a.includes(t.value),disabled:i}),Object(n.createElement)("label",{htmlFor:t.value},t.label)),e&&o===u-1&&p)),e&&g)},[r,c,a,b,u,g,p,i]),h=l()("wc-block-checkbox-list","wc-block-components-checkbox-list",{"is-loading":s},t);return Object(n.createElement)("ul",{className:h},s?m:O)}},18:function(e,t){e.exports=window.wp.primitives},187:function(e,t,c){"use strict";var n=c(5),o=c.n(n),r=c(0),l=c(4),a=c.n(l),s=c(1),i=c(43),u=c(211);c(146);var b=e=>{let{text:t,screenReaderText:c="",element:n="li",className:l="",radius:s="small",children:i=null,...u}=e;const b=n,d=a()(l,"wc-block-components-chip","wc-block-components-chip--radius-"+s),m=Boolean(c&&c!==t);return Object(r.createElement)(b,o()({className:d},u),Object(r.createElement)("span",{"aria-hidden":m,className:"wc-block-components-chip__text"},t),m&&Object(r.createElement)("span",{className:"screen-reader-text"},c),i)};t.a=e=>{let{ariaLabel:t="",className:c="",disabled:n=!1,onRemove:l=(()=>{}),removeOnAnyClick:d=!1,text:m,screenReaderText:p="",...g}=e;const O=d?"span":"button";if(!t){const e=p&&"string"==typeof p?p:m;t="string"!=typeof e?
|
12 |
/* translators: Remove chip. */
|
13 |
Object(s.__)("Remove","woo-gutenberg-products-block"):Object(s.sprintf)(
|
14 |
/* translators: %s text of the chip to remove. */
|
15 |
+
Object(s.__)('Remove "%s"',"woo-gutenberg-products-block"),e)}const h={"aria-label":t,disabled:n,onClick:l,onKeyDown:e=>{"Backspace"!==e.key&&"Delete"!==e.key||l()}},j=d?h:{},w=d?{"aria-hidden":!0}:h;return Object(r.createElement)(b,o()({},g,j,{className:a()(c,"is-removable"),element:d?"button":g.element,screenReaderText:p,text:m}),Object(r.createElement)(O,o()({className:"wc-block-components-chip__remove"},w),Object(r.createElement)(i.a,{className:"wc-block-components-chip__remove-icon",srcElement:u.a,size:16})))}},2:function(e,t){e.exports=window.wc.wcSettings},210:function(e,t){},211:function(e,t,c){"use strict";var n=c(5),o=c.n(n),r=c(0),l=c(18);const a=Object(r.createElement)(e=>{let{className:t,size:c,...n}=e;return Object(r.createElement)(l.SVG,o()({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",className:t,width:c,height:c},n),Object(r.createElement)("path",{d:"M14.95 6.46L11.41 10l3.54 3.54-1.41 1.41L10 11.42l-3.53 3.53-1.42-1.42L8.58 10 5.05 6.47l1.42-1.42L10 8.58l3.54-3.53z"}))},null);t.a=a},212:function(e,t){},26:function(e,t){e.exports=window.wp.isShallowEqual},270:function(e,t,c){"use strict";c.d(t,"a",(function(){return u}));var n=c(0),o=c(246),r=c(6),l=c(39),a=c(73),s=c(115),i=c(48);const u=e=>{let{queryAttribute:t,queryPrices:c,queryStock:u,queryState:b}=e,d=Object(i.a)();d+="-collection-data";const[m]=Object(a.a)(d),[p,g]=Object(a.b)("calculate_attribute_counts",[],d),[O,h]=Object(a.b)("calculate_price_range",null,d),[j,w]=Object(a.b)("calculate_stock_status_counts",null,d),_=Object(l.a)(t||{}),f=Object(l.a)(c),v=Object(l.a)(u);Object(n.useEffect)(()=>{"object"==typeof _&&Object.keys(_).length&&(p.find(e=>e.taxonomy===_.taxonomy)||g([...p,_]))},[_,p,g]),Object(n.useEffect)(()=>{O!==f&&void 0!==f&&h(f)},[f,h,O]),Object(n.useEffect)(()=>{j!==v&&void 0!==v&&w(v)},[v,w,j]);const[k,E]=Object(n.useState)(!1),[y]=Object(o.a)(k,200);k||E(!0);const C=Object(n.useMemo)(()=>(e=>{const t=e;return e.calculate_attribute_counts&&(t.calculate_attribute_counts=Object(r.sortBy)(e.calculate_attribute_counts.map(e=>{let{taxonomy:t,queryType:c}=e;return{taxonomy:t,query_type:c}}),["taxonomy","query_type"])),t})(m),[m]);return Object(s.a)({namespace:"/wc/store",resourceName:"products/collection-data",query:{...b,page:void 0,per_page:void 0,orderby:void 0,order:void 0,...C},shouldSelect:y})}},3:function(e,t){e.exports=window.wp.components},30:function(e,t,c){"use strict";var n=c(0),o=c(4),r=c.n(o);t.a=e=>{let t,{label:c,screenReaderLabel:o,wrapperElement:l,wrapperProps:a={}}=e;const s=null!=c,i=null!=o;return!s&&i?(t=l||"span",a={...a,className:r()(a.className,"screen-reader-text")},Object(n.createElement)(t,a,o)):(t=l||n.Fragment,s&&i&&c!==o?Object(n.createElement)(t,a,Object(n.createElement)("span",{"aria-hidden":"true"},c),Object(n.createElement)("span",{className:"screen-reader-text"},o)):Object(n.createElement)(t,a,c))}},33:function(e,t,c){"use strict";c.d(t,"a",(function(){return a}));var n=c(5),o=c.n(n),r=c(0),l=c(17);const a=e=>{let{countLabel:t,className:c,depth:n=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=[c,"woocommerce-search-list__item"];g.push("depth-"+n),u&&g.push("is-radio-button"),p&&g.push("has-count");const O=s.breadcrumbs&&s.breadcrumbs.length,h=m.name||"search-list-item-"+a,j=`${h}-${s.id}`;return Object(r.createElement)("label",{htmlFor:j,className:g.join(" ")},u?Object(r.createElement)("input",o()({type:"radio",id:j,name:h,value:s.value,onChange:b(s),checked:i,className:"woocommerce-search-list__item-input"},m)):Object(r.createElement)("input",o()({type:"checkbox",id:j,name:h,value:s.value,onChange:b(s),checked:i,className:"woocommerce-search-list__item-input"},m)),Object(r.createElement)("span",{className:"woocommerce-search-list__item-label"},O?Object(r.createElement)("span",{className:"woocommerce-search-list__item-prefix"},Object(l.b)(s.breadcrumbs)):null,Object(r.createElement)("span",{className:"woocommerce-search-list__item-name"},Object(l.d)(s.name,d))),!!p&&Object(r.createElement)("span",{className:"woocommerce-search-list__item-count"},t||s.count))};t.b=a},373:function(e,t,c){e.exports=c(443)},374:function(e,t,c){"use strict";var n=c(0),o=c(18);const r=Object(n.createElement)(o.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(n.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(n.createElement)("path",{d:"M19 15v4H5v-4h14m1-2H4c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h16c.55 0 1-.45 1-1v-6c0-.55-.45-1-1-1zM7 18.5c-.82 0-1.5-.67-1.5-1.5s.68-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zM19 5v4H5V5h14m1-2H4c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h16c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1zM7 8.5c-.82 0-1.5-.67-1.5-1.5S6.18 5.5 7 5.5s1.5.68 1.5 1.5S7.83 8.5 7 8.5z"}));t.a=r},375:function(e,t){},376:function(e,t){},377:function(e,t){},39:function(e,t,c){"use strict";c.d(t,"a",(function(){return l}));var n=c(0),o=c(26),r=c.n(o);function l(e){const t=Object(n.useRef)(e);return r()(e,t.current)||(t.current=e),t.current}},43:function(e,t,c){"use strict";var n=c(0);t.a=function(e){let{srcElement:t,size:c=24,...o}=e;return Object(n.isValidElement)(t)?Object(n.cloneElement)(t,{width:c,height:c,...o}):null}},443:function(e,t,c){"use strict";c.r(t);var n=c(5),o=c.n(n),r=c(0),l=c(1),a=c(12),s=c(43),i=c(374),u=c(4),b=c.n(u),d=c(7),m=c(3),p=c(122),g=c(87),O=c(6),h=c(2),j=c(90),w=c(107),_=c(55),f=c(46),v=c(39),k=c(109),E=c(73),y=c(115),C=c(270),x=c(179),S=(c(10),c(156)),N=e=>{let{checked:t,getInputProps:c,inputRef:n,isDisabled:o,onFocus:l,onRemoveItem:a,placeholder:s,tabIndex:i,value:u}=e;return Object(r.createElement)("input",c({ref:n,className:"wc-block-dropdown-selector__input wc-block-components-dropdown-selector__input",disabled:o,onFocus:l,onKeyDown(e){"Backspace"===e.key&&!u&&t.length>0&&a(t[t.length-1])},placeholder:s,tabIndex:i}))},I=e=>{let{children:t,onClick:c}=e;return Object(r.createElement)("div",{className:"wc-block-dropdown-selector__input-wrapper wc-block-components-dropdown-selector__input-wrapper",onClick:c},t)},P=e=>{let{checked:t,getItemProps:c,getMenuProps:n,highlightedIndex:o,options:a}=e;return Object(r.createElement)("ul",n({className:"wc-block-dropdown-selector__list wc-block-components-dropdown-selector__list"}),a.map((e,n)=>{const a=t.includes(e.value);return Object(r.createElement)("li",c({key:e.value,className:b()("wc-block-dropdown-selector__list-item","wc-block-components-dropdown-selector__list-item",{"is-selected":a,"is-highlighted":o===n}),index:n,item:e.value,"aria-label":a?Object(l.sprintf)(
|
16 |
/* translators: %s is referring to the filter option being removed. */
|
17 |
+
Object(l.__)("Remove %s filter","woo-gutenberg-products-block"),e.name):null}),e.label)}))},R=c(187),L=e=>{let{onRemoveItem:t,option:c}=e;return Object(r.createElement)(R.a,{className:"wc-block-dropdown-selector__selected-chip wc-block-components-dropdown-selector__selected-chip",removeOnAnyClick:!0,onRemove:()=>{t(c.value)},ariaLabel:Object(l.sprintf)(
|
18 |
/* translators: %s is referring to the filter option being removed. */
|
19 |
+
Object(l.__)("Remove %s filter","woo-gutenberg-products-block"),c.name),text:c.label,radius:"large"})},B=c(211),T=e=>{let{onClick:t,onRemoveItem:c,option:n}=e;const o=Object(r.useRef)(null);return Object(r.useEffect)(()=>{o.current.focus()},[o]),Object(r.createElement)("div",{className:"wc-block-dropdown-selector__selected-value wc-block-components-dropdown-selector__selected-value"},Object(r.createElement)("button",{ref:o,className:"wc-block-dropdown-selector__selected-value__label wc-block-components-dropdown-selector__selected-value__label",onClick:e=>{e.stopPropagation(),t(n.value)},"aria-label":Object(l.sprintf)(
|
20 |
/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */
|
21 |
Object(l.__)("Replace current %s filter","woo-gutenberg-products-block"),n.name)},n.label),Object(r.createElement)("button",{className:"wc-block-dropdown-selector__selected-value__remove wc-block-components-dropdown-selector__selected-value__remove",onClick:()=>{c(n.value)},onKeyDown:e=>{"Backspace"!==e.key&&"Delete"!==e.key||c(n.value)},"aria-label":Object(l.sprintf)(
|
22 |
/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */
|
23 |
+
Object(l.__)("Remove %s filter","woo-gutenberg-products-block"),n.name)},Object(r.createElement)(s.a,{srcElement:B.a,size:16})))};c(377);var F=e=>{let{attributeLabel:t="",className:c,checked:n=[],inputLabel:o="",isDisabled:a=!1,isLoading:s=!1,multiple:i=!1,onChange:u=(()=>{}),options:d=[]}=e;const m=Object(r.useRef)(null),p=b()(c,"wc-block-dropdown-selector","wc-block-components-dropdown-selector",{"is-disabled":a,"is-loading":s}),g=Object(r.useCallback)((e,t)=>{switch(t.type){case S.a.stateChangeTypes.keyDownEnter:case S.a.stateChangeTypes.clickItem:return{...t,highlightedIndex:e.highlightedIndex,isOpen:i,inputValue:""};case S.a.stateChangeTypes.blurInput:case S.a.stateChangeTypes.mouseUp:return{...t,inputValue:e.inputValue};default:return t}},[i]);return Object(r.createElement)(S.a,{onChange:u,selectedItem:null,stateReducer:g},e=>{let{getInputProps:c,getItemProps:s,getLabelProps:g,getMenuProps:O,highlightedIndex:h,inputValue:j,isOpen:w,openMenu:_}=e;return Object(r.createElement)("div",{className:b()(p,{"is-multiple":i,"is-single":!i,"has-checked":n.length>0,"is-open":w})},Object(r.createElement)("label",g({className:"screen-reader-text"}),o),Object(r.createElement)(I,{isOpen:w,onClick:()=>m.current.focus()},n.map(e=>{const t=d.find(t=>t.value===e),c=e=>{u(e),m.current.focus()};return i?Object(r.createElement)(L,{key:e,onRemoveItem:c,option:t}):Object(r.createElement)(T,{key:e,onClick:()=>m.current.focus(),onRemoveItem:c,option:t})}),Object(r.createElement)(N,{checked:n,getInputProps:c,inputRef:m,isDisabled:a,onFocus:_,onRemoveItem:e=>{u(e),m.current.focus()},placeholder:n.length>0&&i?null:Object(l.sprintf)(
|
24 |
/* translators: %s attribute name. */
|
25 |
+
Object(l.__)("Any %s","woo-gutenberg-products-block"),t),tabIndex:!i&&n.length>0?"-1":"0",value:j})),w&&!a&&Object(r.createElement)(P,{checked:n,getItemProps:s,getMenuProps:O,highlightedIndex:h,options:d.filter(e=>!j||e.value.startsWith(j))}))})},M=c(96),V=c(135),A=c(26),H=c.n(A),z=c(14),q=c(177),D=c(178);const G=[{value:"preview-1",name:"Blue",label:Object(r.createElement)(M.a,{name:"Blue",count:3})},{value:"preview-2",name:"Green",label:Object(r.createElement)(M.a,{name:"Green",count:3})},{value:"preview-3",name:"Red",label:Object(r.createElement)(M.a,{name:"Red",count:2})}],Y={id:0,name:"preview",taxonomy:"preview",label:"Preview"};c(376);var $=e=>{let{attributes:t,isEditor:c=!1}=e;const n=t.isPreview&&!t.attributeId?Y:Object(q.a)(t.attributeId),[o,a]=Object(r.useState)([]),[s,i]=Object(r.useState)(t.isPreview&&!t.attributeId?G:[]),[u]=Object(E.a)(),[b,d]=Object(E.b)("attributes",[]),{results:p,isLoading:g}=Object(y.a)({namespace:"/wc/store",resourceName:"products/attributes/terms",resourceValues:[(null==n?void 0:n.id)||0],shouldSelect:t.attributeId>0}),O="dropdown"!==t.displayStyle&&"and"===t.queryType,{results:h,isLoading:j}=Object(C.a)({queryAttribute:{taxonomy:null==n?void 0:n.taxonomy,queryType:t.queryType},queryState:{...u,attributes:O?u.attributes:null}}),w=Object(r.useCallback)(e=>h.attribute_counts?h.attribute_counts.find(t=>{let{term:c}=t;return c===e}):null,[h]);Object(r.useEffect)(()=>{if(g||j)return;const e=p.map(e=>{const c=w(e.id);if(!(c||o.includes(e.slug)||(l=e.slug,null!=u&&u.attributes&&u.attributes.some(e=>{let{attribute:t,slug:c=[]}=e;return t===n.taxonomy&&c.includes(l)}))))return null;var l;const a=c?c.count:0;return{value:e.slug,name:Object(z.decodeEntities)(e.name),label:Object(r.createElement)(M.a,{name:Object(z.decodeEntities)(e.name),count:t.showCounts?a:null})}}).filter(Boolean);i(e)},[null==n?void 0:n.taxonomy,p,g,t.showCounts,j,w,o,u.attributes]);const _=Object(r.useCallback)(e=>p.reduce((t,c)=>(e.includes(c.slug)&&t.push(c),t),[]),[p]),S=Object(r.useCallback)(e=>{c||Object(D.b)(b,d,n,_(e),"or"===t.queryType?"in":"and")},[c,b,d,n,_,t.queryType]),N=Object(r.useMemo)(()=>b.filter(e=>{let{attribute:t}=e;return t===(null==n?void 0:n.taxonomy)}).flatMap(e=>{let{slug:t}=e;return t}),[b,null==n?void 0:n.taxonomy]),I=Object(v.a)(N),P=Object(k.a)(I);Object(r.useEffect)(()=>{H()(P,I)||H()(o,I)||(a(I),t.showFilterButton||S(I))},[o,I,P,S,t.showFilterButton]);const R="dropdown"!==t.displayStyle||"or"===t.queryType,L=Object(r.useCallback)(e=>{const c=e=>{const{name:t}=s.find(t=>t.value===e);return t},n=e=>{let{filterAdded:t,filterRemoved:n}=e;const o=t?c(t):null,r=n?c(n):null;o&&r?Object(f.speak)(Object(l.sprintf)(
|
26 |
/* translators: %1$s and %2$s are attribute terms (for example: 'red', 'blue', 'large'...). */
|
27 |
Object(l.__)("%1$s filter replaced with %2$s.","woo-gutenberg-products-block"),o,r)):o?Object(f.speak)(Object(l.sprintf)(
|
28 |
/* translators: %s attribute term (for example: 'red', 'blue', 'large'...) */
|
29 |
Object(l.__)("%s filter added.","woo-gutenberg-products-block"),o)):r&&Object(f.speak)(Object(l.sprintf)(
|
30 |
/* translators: %s attribute term (for example: 'red', 'blue', 'large'...) */
|
31 |
+
Object(l.__)("%s filter removed.","woo-gutenberg-products-block"),r))},r=o.includes(e);let i;R?(i=o.filter(t=>t!==e),r?n({filterRemoved:e}):(i.push(e),i.sort(),n({filterAdded:e}))):(i=r?[]:[e],n({filterAdded:r?null:e,filterRemoved:1===o.length?o[0]:null})),a(i),t.showFilterButton||S(i)},[o,s,R,S,t.showFilterButton]);if(!n)return c?Object(r.createElement)(m.Notice,{status:"warning",isDismissible:!1},Object(r.createElement)("p",null,Object(l.__)("Please select an attribute to use this filter!","woo-gutenberg-products-block"))):null;if(0===s.length&&!g)return c?Object(r.createElement)(m.Notice,{status:"warning",isDismissible:!1},Object(r.createElement)("p",null,Object(l.__)("The selected attribute does not have any term assigned to products.","woo-gutenberg-products-block"))):null;const B="h"+t.headingLevel,T=!t.isPreview&&g,A=!t.isPreview&&j;return Object(r.createElement)(r.Fragment,null,!c&&t.heading&&s.length>0&&Object(r.createElement)(B,{className:"wc-block-attribute-filter__title"},t.heading),Object(r.createElement)("div",{className:"wc-block-attribute-filter style-"+t.displayStyle},"dropdown"===t.displayStyle?Object(r.createElement)(F,{attributeLabel:n.label,checked:o,className:"wc-block-attribute-filter-dropdown",inputLabel:t.heading,isLoading:T,multiple:R,onChange:L,options:s}):Object(r.createElement)(x.a,{className:"wc-block-attribute-filter-list",options:s,checked:o,onChange:L,isLoading:T,isDisabled:A}),t.showFilterButton&&Object(r.createElement)(V.a,{className:"wc-block-attribute-filter__button",disabled:T||A,onClick:()=>S(o)})))};c(375);const K=Object(h.getSetting)("attributes",[]);var Q=Object(m.withSpokenMessages)(e=>{let{attributes:t,setAttributes:c,debouncedSpeak:n}=e;const{attributeId:o,className:a,displayStyle:u,heading:f,headingLevel:v,isPreview:k,queryType:E,showCounts:y,showFilterButton:C}=t,[x,S]=Object(r.useState)(!o&&!k),N=e=>{if(!e||!e.length)return;const t=e[0].id,n=K.find(e=>e.attribute_id===t.toString());if(!n||o===t)return;const r=n.attribute_label;c({attributeId:t,heading:Object(l.sprintf)(
|
32 |
/* translators: %s attribute name. */
|
33 |
Object(l.__)("Filter by %s","woo-gutenberg-products-block"),r)})},I=e=>{let{isCompact:t}=e;const c={clear:Object(l.__)("Clear selected attribute","woo-gutenberg-products-block"),list:Object(l.__)("Product Attributes","woo-gutenberg-products-block"),noItems:Object(l.__)("Your store doesn't have any product attributes.","woo-gutenberg-products-block"),search:Object(l.__)("Search for a product attribute:","woo-gutenberg-products-block"),selected:e=>Object(l.sprintf)(
|
34 |
/* translators: %d is the number of attributes selected. */
|
35 |
+
Object(l._n)("%d attribute selected","%d attributes selected",e,"woo-gutenberg-products-block"),e),updated:Object(l.__)("Product attribute search results updated.","woo-gutenberg-products-block")},n=Object(O.sortBy)(Object(O.toArray)(Object(O.mapValues)(K,e=>({id:parseInt(e.attribute_id,10),name:e.attribute_label}))),"name");return Object(r.createElement)(g.a,{className:"woocommerce-product-attributes",list:n,selected:n.filter(e=>{let{id:t}=e;return t===o}),onChange:N,messages:c,isSingle:!0,isCompact:t})};return 0===Object.keys(K).length?Object(r.createElement)(m.Placeholder,{className:"wc-block-attribute-filter",icon:Object(r.createElement)(s.a,{srcElement:i.a}),label:Object(l.__)("Filter Products by Attribute","woo-gutenberg-products-block"),instructions:Object(l.__)("Display a list of filters based on a chosen attribute.","woo-gutenberg-products-block")},Object(r.createElement)("p",null,Object(l.__)("Attributes are needed for filtering your products. You haven't created any attributes yet.","woo-gutenberg-products-block")),Object(r.createElement)(m.Button,{className:"wc-block-attribute-filter__add-attribute-button",isSecondary:!0,href:Object(h.getAdminLink)("edit.php?post_type=product&page=product_attributes")},Object(l.__)("Add new attribute","woo-gutenberg-products-block")+" ",Object(r.createElement)(s.a,{srcElement:p.a})),Object(r.createElement)(m.Button,{className:"wc-block-attribute-filter__read_more_button",isTertiary:!0,href:"https://docs.woocommerce.com/document/managing-product-taxonomies/"},Object(l.__)("Learn more","woo-gutenberg-products-block"))):Object(r.createElement)(r.Fragment,null,Object(r.createElement)(d.BlockControls,null,Object(r.createElement)(m.ToolbarGroup,{controls:[{icon:"edit",title:Object(l.__)("Edit","woo-gutenberg-products-block"),onClick:()=>S(!x),isActive:x}]})),Object(r.createElement)(d.InspectorControls,{key:"inspector"},Object(r.createElement)(m.PanelBody,{title:Object(l.__)("Content","woo-gutenberg-products-block")},Object(r.createElement)(m.ToggleControl,{label:Object(l.__)("Product count","woo-gutenberg-products-block"),help:y?Object(l.__)("Product count is visible.","woo-gutenberg-products-block"):Object(l.__)("Product count is hidden.","woo-gutenberg-products-block"),checked:y,onChange:()=>c({showCounts:!y})}),Object(r.createElement)("p",null,Object(l.__)("Heading Level","woo-gutenberg-products-block")),Object(r.createElement)(j.a,{isCollapsed:!1,minLevel:2,maxLevel:7,selectedLevel:v,onChange:e=>c({headingLevel:e})})),Object(r.createElement)(m.PanelBody,{title:Object(l.__)("Block Settings","woo-gutenberg-products-block")},Object(r.createElement)(_.a,{label:Object(l.__)("Query Type","woo-gutenberg-products-block"),help:"and"===E?Object(l.__)("Products that have all of the selected attributes will be shown.","woo-gutenberg-products-block"):Object(l.__)("Products that have any of the selected attributes will be shown.","woo-gutenberg-products-block"),value:E,options:[{label:Object(l.__)("And","woo-gutenberg-products-block"),value:"and"},{label:Object(l.__)("Or","woo-gutenberg-products-block"),value:"or"}],onChange:e=>c({queryType:e})}),Object(r.createElement)(_.a,{label:Object(l.__)("Display Style","woo-gutenberg-products-block"),value:u,options:[{label:Object(l.__)("List","woo-gutenberg-products-block"),value:"list"},{label:Object(l.__)("Dropdown","woo-gutenberg-products-block"),value:"dropdown"}],onChange:e=>c({displayStyle:e})}),Object(r.createElement)(m.ToggleControl,{label:Object(l.__)("Filter button","woo-gutenberg-products-block"),help:C?Object(l.__)("Products will only update when the button is pressed.","woo-gutenberg-products-block"):Object(l.__)("Products will update as options are selected.","woo-gutenberg-products-block"),checked:C,onChange:e=>c({showFilterButton:e})})),Object(r.createElement)(m.PanelBody,{title:Object(l.__)("Filter Products by Attribute","woo-gutenberg-products-block"),initialOpen:!1},I({isCompact:!0}))),x?Object(r.createElement)(m.Placeholder,{className:"wc-block-attribute-filter",icon:Object(r.createElement)(s.a,{srcElement:i.a}),label:Object(l.__)("Filter Products by Attribute","woo-gutenberg-products-block"),instructions:Object(l.__)("Display a list of filters based on a chosen attribute.","woo-gutenberg-products-block")},Object(r.createElement)("div",{className:"wc-block-attribute-filter__selection"},I({isCompact:!1}),Object(r.createElement)(m.Button,{isPrimary:!0,onClick:()=>{S(!1),n(Object(l.__)("Showing Filter Products by Attribute block preview.","woo-gutenberg-products-block"))}},Object(l.__)("Done","woo-gutenberg-products-block")))):Object(r.createElement)("div",{className:b()(a,"wc-block-attribute-filter")},Object(r.createElement)(w.a,{className:"wc-block-attribute-filter__title",headingLevel:v,heading:f,onChange:e=>c({heading:e})}),Object(r.createElement)(m.Disabled,null,Object(r.createElement)($,{attributes:t,isEditor:!0}))))});Object(a.registerBlockType)("woocommerce/attribute-filter",{title:Object(l.__)("Filter Products by Attribute","woo-gutenberg-products-block"),icon:{src:Object(r.createElement)(s.a,{srcElement:i.a,className:"wc-block-editor-components-block-icon"})},category:"woocommerce",keywords:[Object(l.__)("WooCommerce","woo-gutenberg-products-block")],description:Object(l.__)("Allow customers to filter the grid by product attribute, such as color. Works in combination with the All Products block.","woo-gutenberg-products-block"),supports:{html:!1},example:{attributes:{isPreview:!0}},attributes:{attributeId:{type:"number",default:0},showCounts:{type:"boolean",default:!0},queryType:{type:"string",default:"or"},heading:{type:"string",default:Object(l.__)("Filter by attribute","woo-gutenberg-products-block")},headingLevel:{type:"number",default:3},displayStyle:{type:"string",default:"list"},showFilterButton:{type:"boolean",default:!1},isPreview:{type:"boolean",default:!1}},edit:Q,save(e){let{attributes:t}=e;const{className:c,showCounts:n,queryType:l,attributeId:a,heading:s,headingLevel:i,displayStyle:u,showFilterButton:d}=t,m={"data-attribute-id":a,"data-show-counts":n,"data-query-type":l,"data-heading":s,"data-heading-level":i};return"list"!==u&&(m["data-display-style"]=u),d&&(m["data-show-filter-button"]=d),Object(r.createElement)("div",o()({className:b()("is-loading",c)},m),Object(r.createElement)("span",{"aria-hidden":!0,className:"wc-block-product-attribute-filter__placeholder"}))}})},46:function(e,t){e.exports=window.wp.a11y},48:function(e,t,c){"use strict";c.d(t,"a",(function(){return r}));var n=c(0);const o=Object(n.createContext)("page"),r=()=>Object(n.useContext)(o
|
|