Version Description
Download this release
Release Info
| Developer | automattic |
| Plugin | |
| Version | 6.0.0 |
| Comparing to | |
| See all releases | |
Code changes from version 5.9.1 to 6.0.0
- assets/css/editor.scss +12 -0
- assets/css/style.scss +18 -2
- assets/js/atomic/utils/render-parent-block.tsx +38 -30
- assets/js/base/components/cart-checkout/form-step/style.scss +8 -0
- assets/js/base/components/cart-checkout/order-summary/order-summary-item.js +29 -4
- assets/js/base/components/cart-checkout/payment-method-icons/common-icons.ts +1 -1
- assets/js/base/components/cart-checkout/payment-method-icons/index.tsx +3 -3
- assets/js/base/components/cart-checkout/payment-method-icons/utils.ts +5 -2
- assets/js/base/components/cart-checkout/shipping-rates-control/index.tsx +1 -1
- assets/js/base/components/checkbox-control/index.tsx +6 -0
- assets/js/base/components/checkbox-control/style.scss +12 -1
- assets/js/base/components/combobox/index.tsx +1 -0
- assets/js/base/components/combobox/style.scss +4 -2
- assets/js/base/components/drawer/index.tsx +5 -0
- assets/js/base/components/reviews/review-list-item/index.js +3 -7
- assets/js/base/components/reviews/review-list-item/style.scss +22 -16
- assets/js/base/components/reviews/review-list/style.scss +2 -2
- assets/js/base/components/sort-select/style.scss +1 -0
- assets/js/base/components/state-input/state-input.tsx +43 -16
- assets/js/base/components/text-input/style.scss +4 -2
- assets/js/base/components/text-input/validated-text-input.tsx +1 -0
- assets/js/base/context/hooks/cart/use-store-cart.ts +3 -3
- assets/js/base/context/hooks/payment-methods/{use-payment-methods.js → use-payment-methods.ts} +21 -3
- assets/js/base/context/hooks/use-store-notices.ts +1 -1
- assets/js/base/context/providers/cart-checkout/payment-methods/actions.ts +8 -1
- assets/js/base/context/providers/cart-checkout/payment-methods/types.ts +14 -44
- assets/js/base/context/providers/cart-checkout/payment-methods/use-payment-method-registration.ts +27 -19
- assets/js/base/context/providers/validation/components/validation-input-error/style.scss +0 -5
- assets/js/base/utils/legacy-events.js +0 -85
- assets/js/base/utils/legacy-events.ts +106 -0
- assets/js/blocks-registry/payment-methods/{assertions.js → assertions.ts} +28 -14
- assets/js/blocks-registry/payment-methods/{express-payment-method-config.js → express-payment-method-config.ts} +34 -7
- assets/js/blocks-registry/payment-methods/extensions-config.js +0 -7
- assets/js/blocks-registry/payment-methods/extensions-config.ts +23 -0
- assets/js/blocks-registry/payment-methods/{index.js → index.ts} +0 -0
- assets/js/blocks-registry/payment-methods/payment-method-config-helper.js +0 -48
- assets/js/blocks-registry/payment-methods/payment-method-config-helper.ts +90 -0
- assets/js/blocks-registry/payment-methods/{payment-method-config.js → payment-method-config.tsx} +30 -22
- assets/js/blocks-registry/payment-methods/{registry.js → registry.ts} +33 -25
- assets/js/blocks-registry/payment-methods/test/payment-method-config-helper.ts +205 -0
- assets/js/blocks-registry/payment-methods/test/payment-method-config.tsx +61 -0
- assets/js/blocks-registry/payment-methods/test/registry.ts +97 -0
- assets/js/blocks/active-filters/block.js +3 -1
- assets/js/blocks/active-filters/edit.js +1 -0
- assets/js/blocks/attribute-filter/block.js +3 -1
- assets/js/blocks/attribute-filter/edit.js +1 -0
- assets/js/blocks/cart-checkout/cart-i2/attributes.js +29 -0
- assets/js/blocks/cart-checkout/cart-i2/block.js +103 -0
- assets/js/blocks/cart-checkout/cart-i2/checkout-button/index.tsx +101 -0
- assets/js/blocks/cart-checkout/cart-i2/checkout-button/style.scss +56 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → cart-i2}/columns/columns-block.tsx +0 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → cart-i2}/columns/index.ts +0 -0
- assets/js/blocks/cart-checkout/cart-i2/context.ts +19 -0
- assets/js/blocks/cart-checkout/cart-i2/edit.tsx +255 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → cart-i2}/editor-utils.ts +0 -0
- assets/js/blocks/cart-checkout/cart-i2/editor.scss +22 -0
- assets/js/blocks/cart-checkout/cart-i2/empty-cart-edit/icon-data-uri.js +1 -0
- assets/js/blocks/cart-checkout/cart-i2/empty-cart-edit/index.js +99 -0
- assets/js/blocks/cart-checkout/cart-i2/empty-cart-edit/style.scss +4 -0
- assets/js/blocks/cart-checkout/cart-i2/frontend.js +57 -0
- assets/js/blocks/cart-checkout/cart-i2/full-cart/cart-line-item-row.tsx +309 -0
- assets/js/blocks/cart-checkout/cart-i2/full-cart/cart-line-items-table.tsx +62 -0
- assets/js/blocks/cart-checkout/cart-i2/full-cart/cart-line-items-title.tsx +28 -0
- assets/js/blocks/cart-checkout/cart-i2/full-cart/index.tsx +212 -0
- assets/js/blocks/cart-checkout/cart-i2/full-cart/style.scss +264 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → cart-i2}/hacks.ts +58 -33
- assets/js/blocks/cart-checkout/cart-i2/index.js +44 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-express-payment-block/block.json +26 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-express-payment-block/block.tsx +25 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-express-payment-block/edit.tsx +76 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-express-payment-block/editor.scss +29 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-express-payment-block/index.tsx +20 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-items-block/block.json +26 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-items-block/edit.tsx +41 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-items-block/frontend.tsx +14 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-items-block/index.tsx +20 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-line-items-block/block.json +26 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-line-items-block/block.tsx +20 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-line-items-block/edit.tsx +23 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-line-items-block/index.tsx +20 -0
- assets/js/blocks/cart-checkout/{checkout-i2/inner-blocks/checkout-order-summary-block → cart-i2/inner-blocks/cart-order-summary-block}/attributes.tsx +0 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-order-summary-block/block.json +26 -0
- assets/js/blocks/cart-checkout/{checkout/sidebar/index.js → cart-i2/inner-blocks/cart-order-summary-block/block.tsx} +27 -23
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-order-summary-block/edit.tsx +109 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-order-summary-block/index.tsx +22 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-totals-block/block.json +33 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-totals-block/edit.tsx +42 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-totals-block/frontend.tsx +19 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-totals-block/index.tsx +20 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-totals-block/style.scss +8 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/empty-cart-block/block.json +26 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/empty-cart-block/edit.tsx +44 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/empty-cart-block/frontend.tsx +27 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/empty-cart-block/index.tsx +20 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/filled-cart-block/block.json +26 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/filled-cart-block/edit.tsx +49 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/filled-cart-block/editor.scss +23 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/filled-cart-block/frontend.tsx +43 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/filled-cart-block/index.tsx +20 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/index.tsx +11 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/proceed-to-checkout-block/attributes.tsx +13 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/proceed-to-checkout-block/block.json +25 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/proceed-to-checkout-block/block.tsx +23 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/proceed-to-checkout-block/edit.tsx +71 -0
- assets/js/blocks/cart-checkout/{checkout-i2/inner-blocks/checkout-actions-block → cart-i2/inner-blocks/proceed-to-checkout-block}/frontend.tsx +0 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/proceed-to-checkout-block/index.tsx +22 -0
- assets/js/blocks/cart-checkout/cart-i2/inner-blocks/register-components.ts +108 -0
- assets/js/blocks/cart-checkout/cart-i2/style.scss +7 -0
- assets/js/blocks/cart-checkout/cart-i2/types.ts +13 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → cart-i2}/use-forced-layout.ts +0 -0
- assets/js/blocks/cart-checkout/cart-i2/use-view-switcher.tsx +60 -0
- assets/js/blocks/cart-checkout/cart/block.js +5 -2
- assets/js/blocks/cart-checkout/cart/checkout-button/index.tsx +7 -4
- assets/js/blocks/cart-checkout/cart/full-cart/cart-line-item-row.tsx +253 -230
- assets/js/blocks/cart-checkout/cart/full-cart/cart-line-items-table.tsx +35 -2
- assets/js/blocks/cart-checkout/cart/full-cart/index.tsx +1 -1
- assets/js/blocks/cart-checkout/cart/test/__snapshots__/block.js.snap +9 -0
- assets/js/blocks/cart-checkout/checkout-i2/checkout-order-error/constants.js +0 -8
- assets/js/blocks/cart-checkout/checkout-i2/checkout-order-error/index.js +0 -136
- assets/js/blocks/cart-checkout/checkout-i2/empty-cart/index.js +0 -37
- assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-actions-block/index.tsx +0 -37
- assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-billing-address-block/index.tsx +0 -37
- assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-contact-information-block/index.tsx +0 -40
- assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-express-payment-block/index.tsx +0 -44
- assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-fields-block/index.tsx +0 -35
- assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-order-note-block/index.tsx +0 -43
- assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-order-summary-block/index.tsx +0 -37
- assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-payment-block/index.tsx +0 -37
- assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-sample-block/block.json +0 -20
- assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-sample-block/block.tsx +0 -15
- assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-sample-block/edit.tsx +0 -35
- assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-sample-block/frontend.tsx +0 -10
- assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-address-block/index.tsx +0 -37
- assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-methods-block/index.tsx +0 -37
- assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-terms-block/edit.tsx +0 -109
- assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-terms-block/index.tsx +0 -42
- assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-totals-block/index.tsx +0 -36
- assets/js/blocks/cart-checkout/checkout-i2/styles/style.scss +0 -98
- assets/js/blocks/cart-checkout/checkout/attributes.js +0 -62
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/attributes.ts +1 -1
- assets/js/blocks/cart-checkout/checkout/block.js +0 -151
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/block.tsx +0 -0
- assets/js/blocks/cart-checkout/checkout/checkout-order-error/index.js +1 -0
- assets/js/blocks/cart-checkout/checkout/checkout-order-error/style.scss +21 -0
- assets/js/blocks/cart-checkout/checkout/columns/columns-block.tsx +15 -0
- assets/js/blocks/cart-checkout/checkout/columns/index.ts +1 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/context.ts +0 -0
- assets/js/blocks/cart-checkout/checkout/edit.js +0 -399
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/edit.tsx +43 -39
- assets/js/blocks/cart-checkout/checkout/editor-utils.ts +19 -0
- assets/js/blocks/cart-checkout/checkout/editor.scss +0 -29
- assets/js/blocks/cart-checkout/checkout/empty-cart/index.js +5 -0
- assets/js/blocks/cart-checkout/checkout/empty-cart/style.scss +21 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/form-step/additional-fields.tsx +0 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/form-step/attributes.ts +0 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/form-step/editor.scss +1 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/form-step/form-step-block.tsx +6 -4
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/form-step/form-step-heading.tsx +0 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/form-step/index.tsx +0 -0
- assets/js/blocks/cart-checkout/checkout/form/billing-fields-step.js +0 -31
- assets/js/blocks/cart-checkout/checkout/form/contact-fields-step.js +0 -72
- assets/js/blocks/cart-checkout/checkout/form/index.js +0 -156
- assets/js/blocks/cart-checkout/checkout/form/login-prompt.js +0 -33
- assets/js/blocks/cart-checkout/checkout/form/no-shipping-placeholder/index.js +0 -42
- assets/js/blocks/cart-checkout/checkout/form/no-shipping-placeholder/style.scss +0 -21
- assets/js/blocks/cart-checkout/checkout/form/order-notes-step.js +0 -50
- assets/js/blocks/cart-checkout/checkout/form/payment-method-step.js +0 -51
- assets/js/blocks/cart-checkout/checkout/form/phone-number/index.js +0 -34
- assets/js/blocks/cart-checkout/checkout/form/shipping-fields-step.js +0 -48
- assets/js/blocks/cart-checkout/checkout/form/shipping-options-step.tsx +0 -120
- assets/js/blocks/cart-checkout/checkout/frontend.js +0 -95
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/frontend.tsx +1 -1
- assets/js/blocks/cart-checkout/checkout/hacks.ts +176 -0
- assets/js/blocks/cart-checkout/checkout/index.js +0 -86
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/index.tsx +17 -23
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-actions-block/attributes.tsx +0 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-actions-block/block.json +26 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-actions-block/block.tsx +0 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-actions-block/edit.tsx +2 -2
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-actions-block/frontend.tsx +12 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-actions-block/index.tsx +22 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-actions-block/style.scss +0 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-billing-address-block/attributes.tsx +0 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-billing-address-block/block.json +26 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-billing-address-block/block.tsx +0 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-billing-address-block/edit.tsx +0 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-billing-address-block/frontend.tsx +0 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-billing-address-block/index.tsx +22 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-contact-information-block/attributes.tsx +0 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-contact-information-block/block.json +26 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-contact-information-block/block.tsx +0 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-contact-information-block/edit.tsx +0 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-contact-information-block/frontend.tsx +0 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-contact-information-block/index.tsx +22 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-contact-information-block/login-prompt.js +0 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-express-payment-block/block.json +26 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-express-payment-block/block.tsx +0 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-express-payment-block/edit.tsx +1 -2
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-express-payment-block/editor.scss +0 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-express-payment-block/index.tsx +20 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/block.json +26 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-fields-block/edit.tsx +1 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-fields-block/frontend.tsx +5 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/index.tsx +20 -0
- assets/js/blocks/cart-checkout/checkout/{form → inner-blocks/checkout-fields-block}/style.scss +7 -18
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/block.json +26 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-order-note-block/block.tsx +1 -1
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-order-note-block/edit.tsx +2 -12
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-order-note-block/editor.scss +0 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/index.tsx +20 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/attributes.tsx +18 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/block.json +25 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-order-summary-block/block.tsx +0 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-order-summary-block/edit.tsx +1 -2
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/index.tsx +22 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-payment-block/attributes.tsx +0 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/block.json +26 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-payment-block/block.tsx +0 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-payment-block/edit.tsx +0 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-payment-block/frontend.tsx +0 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/index.tsx +22 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-shipping-address-block/attributes.tsx +0 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/block.json +26 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-shipping-address-block/block.tsx +0 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-shipping-address-block/edit.tsx +0 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-shipping-address-block/frontend.tsx +0 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/index.tsx +22 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-shipping-methods-block/attributes.tsx +0 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/block.json +26 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-shipping-methods-block/block.tsx +32 -19
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-shipping-methods-block/edit.tsx +0 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-shipping-methods-block/frontend.tsx +0 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/index.tsx +22 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-shipping-methods-block/no-shipping-placeholder/index.js +0 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-shipping-methods-block/no-shipping-placeholder/style.scss +0 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/style.scss +11 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/block.json +26 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-terms-block/constants.js +0 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/edit.tsx +183 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-terms-block/editor.scss +11 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-terms-block/frontend.tsx +1 -3
- assets/js/blocks/cart-checkout/{checkout-i2/inner-blocks/checkout-sample-block → checkout/inner-blocks/checkout-terms-block}/index.tsx +2 -3
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-terms-block/style.scss +0 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/block.json +27 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-totals-block/edit.tsx +1 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-totals-block/frontend.tsx +5 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/index.tsx +20 -0
- assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/style.scss +23 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/index.tsx +0 -1
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/register-components.ts +46 -44
- assets/js/blocks/cart-checkout/checkout/{form/order-notes → order-notes}/index.js +0 -0
- assets/js/blocks/cart-checkout/checkout/{form/order-notes → order-notes}/style.scss +0 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/phone-number/index.tsx +0 -0
- assets/js/blocks/cart-checkout/checkout/sidebar/test/__snapshots__/index.js.snap +0 -116
- assets/js/blocks/cart-checkout/checkout/sidebar/test/index.js +0 -27
- assets/js/blocks/cart-checkout/checkout/style.scss +0 -156
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/styles/editor.scss +22 -15
- assets/js/blocks/cart-checkout/checkout/styles/style.scss +94 -0
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/types.ts +0 -0
- assets/js/blocks/cart-checkout/checkout/use-forced-layout.ts +63 -0
- assets/js/blocks/cart-checkout/checkout/utils.js +0 -8
- assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/utils.ts +0 -0
- assets/js/blocks/cart-checkout/mini-cart/block.tsx +148 -0
- assets/js/blocks/cart-checkout/mini-cart/component-frontend.tsx +3 -118
- assets/js/blocks/cart-checkout/mini-cart/frontend.ts +3 -0
- assets/js/blocks/cart-checkout/mini-cart/index.tsx +2 -2
- assets/js/blocks/cart-checkout/payment-methods/test/payment-methods.js +10 -0
- assets/js/blocks/price-filter/block.js +3 -1
- assets/js/blocks/price-filter/edit.js +1 -0
- assets/js/blocks/product-category/block.js +14 -15
- assets/js/blocks/reviews/all-reviews/index.js +9 -13
- assets/js/blocks/reviews/editor-container-block.js +47 -50
- assets/js/blocks/reviews/reviews-by-category/edit.js +1 -37
- assets/js/blocks/reviews/reviews-by-category/index.js +7 -0
- assets/js/blocks/reviews/reviews-by-product/index.js +7 -0
- assets/js/blocks/reviews/save.js +8 -1
- assets/js/blocks/stock-filter/block.js +23 -15
- assets/js/blocks/stock-filter/edit.js +8 -1
- assets/js/blocks/stock-filter/test/__snapshots__/block.js.snap +205 -0
- assets/js/blocks/stock-filter/test/block.js +73 -0
- assets/js/data/cart/action-types.ts +2 -0
- assets/js/data/cart/actions.ts +22 -0
- assets/js/data/cart/controls.js +11 -1
- assets/js/editor-components/block-title/index.js +2 -6
- assets/js/editor-components/external-link-card/editor.scss +0 -1
- assets/js/editor-components/external-link-card/index.tsx +2 -2
- assets/js/icons/index.js +2 -0
- assets/js/icons/library/eye.js +13 -0
- assets/js/icons/library/filled-cart.js +19 -0
- assets/js/types/type-defs/cart-response.ts +2 -0
- assets/js/types/type-defs/cart.ts +1 -0
- assets/js/types/type-defs/events.ts +4 -0
- assets/js/types/type-defs/hooks.ts +2 -1
- assets/js/types/type-defs/index.ts +2 -1
- assets/js/types/type-defs/objects.ts +2 -0
- assets/js/types/type-defs/payment-method-icon.ts +0 -5
- assets/js/types/type-defs/payments.js +0 -34
- assets/js/types/type-defs/payments.ts +120 -0
- build/active-filters-frontend.asset.php +1 -1
- build/active-filters-frontend.js +5 -5
- 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 +3 -3
- build/all-products.asset.php +1 -1
- build/all-products.js +15 -15
- build/all-reviews.asset.php +1 -1
- build/all-reviews.js +4 -4
assets/css/editor.scss
CHANGED
|
@@ -60,3 +60,15 @@
|
|
| 60 |
margin: 0;
|
| 61 |
padding: 0;
|
| 62 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
margin: 0;
|
| 61 |
padding: 0;
|
| 62 |
}
|
| 63 |
+
|
| 64 |
+
.theme-twentytwenty {
|
| 65 |
+
.wp-block {
|
| 66 |
+
.wc-block-grid__product-title,
|
| 67 |
+
.wc-block-active-filters__title,
|
| 68 |
+
.wc-block-attribute-filter__title,
|
| 69 |
+
.wc-block-price-filter__title,
|
| 70 |
+
.wc-block-stock-filter__title {
|
| 71 |
+
@include font-size(regular);
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
}
|
assets/css/style.scss
CHANGED
|
@@ -217,8 +217,8 @@
|
|
| 217 |
.wc-block-grid__product-title,
|
| 218 |
.wc-block-components-product-title {
|
| 219 |
font-family: $twentytwenty-headings;
|
| 220 |
-
color:
|
| 221 |
-
font-size
|
| 222 |
}
|
| 223 |
|
| 224 |
.wp-block-columns .wc-block-components-product-title {
|
|
@@ -285,6 +285,22 @@
|
|
| 285 |
z-index: 1;
|
| 286 |
}
|
| 287 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
@media only screen and (min-width: 768px) {
|
| 289 |
.wc-block-grid__products .wc-block-grid__product-onsale {
|
| 290 |
@include font-size(small);
|
| 217 |
.wc-block-grid__product-title,
|
| 218 |
.wc-block-components-product-title {
|
| 219 |
font-family: $twentytwenty-headings;
|
| 220 |
+
color: $twentytwenty-highlights-color;
|
| 221 |
+
@include font-size(regular);
|
| 222 |
}
|
| 223 |
|
| 224 |
.wp-block-columns .wc-block-components-product-title {
|
| 285 |
z-index: 1;
|
| 286 |
}
|
| 287 |
|
| 288 |
+
.wc-block-active-filters__title,
|
| 289 |
+
.wc-block-attribute-filter__title,
|
| 290 |
+
.wc-block-price-filter__title,
|
| 291 |
+
.wc-block-stock-filter__title {
|
| 292 |
+
@include font-size(regular);
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
.wc-block-active-filters .wc-block-active-filters__clear-all {
|
| 296 |
+
@include font-size(smaller);
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
.wc-block-grid__product-add-to-cart.wp-block-button .wp-block-button__link {
|
| 300 |
+
@include font-size(smaller);
|
| 301 |
+
padding: em($gap-smaller);
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
@media only screen and (min-width: 768px) {
|
| 305 |
.wc-block-grid__products .wc-block-grid__product-onsale {
|
| 306 |
@include font-size(small);
|
assets/js/atomic/utils/render-parent-block.tsx
CHANGED
|
@@ -108,7 +108,7 @@ const renderInnerBlocks = ( {
|
|
| 108 |
// Wrapper for inner components.
|
| 109 |
blockWrapper?: React.ElementType;
|
| 110 |
// Elements from the DOM being converted to components.
|
| 111 |
-
children: HTMLCollection;
|
| 112 |
// Depth within the DOM hierarchy.
|
| 113 |
depth?: number;
|
| 114 |
} ): ( JSX.Element | null )[] | null => {
|
|
@@ -133,30 +133,41 @@ const renderInnerBlocks = ( {
|
|
| 133 |
/**
|
| 134 |
* If the component cannot be found, or blockName is missing, return the original element. This also ensures
|
| 135 |
* that children within the element are processed also, since it may be an element containing block markup.
|
|
|
|
|
|
|
| 136 |
*/
|
| 137 |
if ( ! InnerBlockComponent ) {
|
| 138 |
-
const parsedElement = parse(
|
|
|
|
|
|
|
| 139 |
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
? renderInnerBlocks( {
|
| 144 |
-
block,
|
| 145 |
-
blockMap,
|
| 146 |
-
children: element.children,
|
| 147 |
-
depth: depth + 1,
|
| 148 |
-
blockWrapper,
|
| 149 |
-
} )
|
| 150 |
-
: null;
|
| 151 |
-
return elementChildren
|
| 152 |
-
? cloneElement(
|
| 153 |
-
parsedElement,
|
| 154 |
-
componentProps,
|
| 155 |
-
elementChildren
|
| 156 |
-
)
|
| 157 |
-
: cloneElement( parsedElement, componentProps );
|
| 158 |
}
|
| 159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
}
|
| 161 |
|
| 162 |
// This will wrap inner blocks with the provided wrapper. If no wrapper is provided, we default to Fragment.
|
|
@@ -243,15 +254,12 @@ export const renderParentBlock = ( {
|
|
| 243 |
* In addition to getProps, we need to render and return the children. This adds children to props.
|
| 244 |
*/
|
| 245 |
const getPropsWithChildren = ( element: Element, i: number ) => {
|
| 246 |
-
const children =
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
blockWrapper,
|
| 253 |
-
} )
|
| 254 |
-
: null;
|
| 255 |
return { ...getProps( element, i ), children };
|
| 256 |
};
|
| 257 |
/**
|
| 108 |
// Wrapper for inner components.
|
| 109 |
blockWrapper?: React.ElementType;
|
| 110 |
// Elements from the DOM being converted to components.
|
| 111 |
+
children: HTMLCollection | NodeList;
|
| 112 |
// Depth within the DOM hierarchy.
|
| 113 |
depth?: number;
|
| 114 |
} ): ( JSX.Element | null )[] | null => {
|
| 133 |
/**
|
| 134 |
* If the component cannot be found, or blockName is missing, return the original element. This also ensures
|
| 135 |
* that children within the element are processed also, since it may be an element containing block markup.
|
| 136 |
+
*
|
| 137 |
+
* Note we use childNodes rather than children so that text nodes are also rendered.
|
| 138 |
*/
|
| 139 |
if ( ! InnerBlockComponent ) {
|
| 140 |
+
const parsedElement = parse(
|
| 141 |
+
element?.outerHTML || element?.textContent || ''
|
| 142 |
+
);
|
| 143 |
|
| 144 |
+
// Returns text nodes without manipulation.
|
| 145 |
+
if ( typeof parsedElement === 'string' && !! parsedElement ) {
|
| 146 |
+
return parsedElement;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
}
|
| 148 |
+
|
| 149 |
+
// Do not render invalid elements.
|
| 150 |
+
if ( ! isValidElement( parsedElement ) ) {
|
| 151 |
+
return null;
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
const renderedChildren = element.childNodes.length
|
| 155 |
+
? renderInnerBlocks( {
|
| 156 |
+
block,
|
| 157 |
+
blockMap,
|
| 158 |
+
children: element.childNodes,
|
| 159 |
+
depth: depth + 1,
|
| 160 |
+
blockWrapper,
|
| 161 |
+
} )
|
| 162 |
+
: undefined;
|
| 163 |
+
|
| 164 |
+
return renderedChildren
|
| 165 |
+
? cloneElement(
|
| 166 |
+
parsedElement,
|
| 167 |
+
componentProps,
|
| 168 |
+
renderedChildren
|
| 169 |
+
)
|
| 170 |
+
: cloneElement( parsedElement, componentProps );
|
| 171 |
}
|
| 172 |
|
| 173 |
// This will wrap inner blocks with the provided wrapper. If no wrapper is provided, we default to Fragment.
|
| 254 |
* In addition to getProps, we need to render and return the children. This adds children to props.
|
| 255 |
*/
|
| 256 |
const getPropsWithChildren = ( element: Element, i: number ) => {
|
| 257 |
+
const children = renderInnerBlocks( {
|
| 258 |
+
block: blockName,
|
| 259 |
+
blockMap,
|
| 260 |
+
children: element.children || [],
|
| 261 |
+
blockWrapper,
|
| 262 |
+
} );
|
|
|
|
|
|
|
|
|
|
| 263 |
return { ...getProps( element, i ), children };
|
| 264 |
};
|
| 265 |
/**
|
assets/js/base/components/cart-checkout/form-step/style.scss
CHANGED
|
@@ -119,3 +119,11 @@
|
|
| 119 |
}
|
| 120 |
}
|
| 121 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
}
|
| 120 |
}
|
| 121 |
}
|
| 122 |
+
|
| 123 |
+
.editor-styles-wrapper {
|
| 124 |
+
.wp-block h4.wc-block-components-checkout-step__title {
|
| 125 |
+
@include font-size(regular);
|
| 126 |
+
line-height: 24px;
|
| 127 |
+
margin: 0 $gap-small 0 0;
|
| 128 |
+
}
|
| 129 |
+
}
|
assets/js/base/components/cart-checkout/order-summary/order-summary-item.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
| 1 |
/**
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
-
import {
|
| 5 |
import Label from '@woocommerce/base-components/label';
|
| 6 |
import ProductPrice from '@woocommerce/base-components/product-price';
|
| 7 |
import ProductName from '@woocommerce/base-components/product-name';
|
| 8 |
-
import {
|
|
|
|
|
|
|
|
|
|
| 9 |
import {
|
| 10 |
__experimentalApplyCheckoutFilter,
|
| 11 |
mustContain,
|
|
@@ -113,7 +116,12 @@ const OrderSummaryItem = ( { cartItem } ) => {
|
|
| 113 |
label={ quantity }
|
| 114 |
screenReaderLabel={ sprintf(
|
| 115 |
/* translators: %d number of products of the same type in the cart */
|
| 116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
quantity
|
| 118 |
) }
|
| 119 |
/>
|
|
@@ -151,7 +159,24 @@ const OrderSummaryItem = ( { cartItem } ) => {
|
|
| 151 |
variation={ variation }
|
| 152 |
/>
|
| 153 |
</div>
|
| 154 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
<ProductPrice
|
| 156 |
currency={ totalsCurrency }
|
| 157 |
format={ productPriceFormat }
|
| 1 |
/**
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
+
import { sprintf, _n } from '@wordpress/i18n';
|
| 5 |
import Label from '@woocommerce/base-components/label';
|
| 6 |
import ProductPrice from '@woocommerce/base-components/product-price';
|
| 7 |
import ProductName from '@woocommerce/base-components/product-name';
|
| 8 |
+
import {
|
| 9 |
+
getCurrencyFromPriceResponse,
|
| 10 |
+
formatPrice,
|
| 11 |
+
} from '@woocommerce/price-format';
|
| 12 |
import {
|
| 13 |
__experimentalApplyCheckoutFilter,
|
| 14 |
mustContain,
|
| 116 |
label={ quantity }
|
| 117 |
screenReaderLabel={ sprintf(
|
| 118 |
/* translators: %d number of products of the same type in the cart */
|
| 119 |
+
_n(
|
| 120 |
+
'%d item',
|
| 121 |
+
'%d items',
|
| 122 |
+
quantity,
|
| 123 |
+
'woo-gutenberg-products-block'
|
| 124 |
+
),
|
| 125 |
quantity
|
| 126 |
) }
|
| 127 |
/>
|
| 159 |
variation={ variation }
|
| 160 |
/>
|
| 161 |
</div>
|
| 162 |
+
<span className="screen-reader-text">
|
| 163 |
+
{ sprintf(
|
| 164 |
+
/* translators: %1$d is the number of items, %2$s is the item name and %3$s is the total price including the currency symbol. */
|
| 165 |
+
_n(
|
| 166 |
+
'Total price for %1$d %2$s item: %3$s',
|
| 167 |
+
'Total price for %1$d %2$s items: %3$s',
|
| 168 |
+
quantity,
|
| 169 |
+
'woo-gutenberg-products-block'
|
| 170 |
+
),
|
| 171 |
+
quantity,
|
| 172 |
+
name,
|
| 173 |
+
formatPrice( subtotalPrice, totalsCurrency )
|
| 174 |
+
) }
|
| 175 |
+
</span>
|
| 176 |
+
<div
|
| 177 |
+
className="wc-block-components-order-summary-item__total-price"
|
| 178 |
+
aria-hidden="true"
|
| 179 |
+
>
|
| 180 |
<ProductPrice
|
| 181 |
currency={ totalsCurrency }
|
| 182 |
format={ productPriceFormat }
|
assets/js/base/components/cart-checkout/payment-method-icons/common-icons.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import { WC_BLOCKS_IMAGE_URL } from '@woocommerce/block-settings';
|
| 5 |
-
import type { PaymentMethodIcon } from '@woocommerce/type-defs/
|
| 6 |
|
| 7 |
/**
|
| 8 |
* Array of common assets.
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import { WC_BLOCKS_IMAGE_URL } from '@woocommerce/block-settings';
|
| 5 |
+
import type { PaymentMethodIcon } from '@woocommerce/type-defs/payments';
|
| 6 |
|
| 7 |
/**
|
| 8 |
* Array of common assets.
|
assets/js/base/components/cart-checkout/payment-method-icons/index.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import classnames from 'classnames';
|
| 5 |
-
import type {
|
| 6 |
|
| 7 |
/**
|
| 8 |
* Internal dependencies
|
|
@@ -13,8 +13,8 @@ import { normalizeIconConfig } from './utils';
|
|
| 13 |
import './style.scss';
|
| 14 |
|
| 15 |
interface PaymentMethodIconsProps {
|
| 16 |
-
icons:
|
| 17 |
-
align
|
| 18 |
}
|
| 19 |
/**
|
| 20 |
* For a given list of icons, render each as a list item, using common icons
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import classnames from 'classnames';
|
| 5 |
+
import type { PaymentMethodIcons as PaymentMethodIconsType } from '@woocommerce/type-defs/payments';
|
| 6 |
|
| 7 |
/**
|
| 8 |
* Internal dependencies
|
| 13 |
import './style.scss';
|
| 14 |
|
| 15 |
interface PaymentMethodIconsProps {
|
| 16 |
+
icons: PaymentMethodIconsType;
|
| 17 |
+
align?: 'left' | 'right' | 'center';
|
| 18 |
}
|
| 19 |
/**
|
| 20 |
* For a given list of icons, render each as a list item, using common icons
|
assets/js/base/components/cart-checkout/payment-method-icons/utils.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
| 1 |
/**
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
-
import type {
|
|
|
|
|
|
|
|
|
|
| 5 |
import { isString } from '@woocommerce/types';
|
| 6 |
|
| 7 |
/**
|
| 8 |
* For an array of icons, normalize into objects and remove duplicates.
|
| 9 |
*/
|
| 10 |
export const normalizeIconConfig = (
|
| 11 |
-
icons:
|
| 12 |
): PaymentMethodIcon[] => {
|
| 13 |
const normalizedIcons: Record< string, PaymentMethodIcon > = {};
|
| 14 |
|
| 1 |
/**
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
+
import type {
|
| 5 |
+
PaymentMethodIcon,
|
| 6 |
+
PaymentMethodIcons,
|
| 7 |
+
} from '@woocommerce/type-defs/payments';
|
| 8 |
import { isString } from '@woocommerce/types';
|
| 9 |
|
| 10 |
/**
|
| 11 |
* For an array of icons, normalize into objects and remove duplicates.
|
| 12 |
*/
|
| 13 |
export const normalizeIconConfig = (
|
| 14 |
+
icons: PaymentMethodIcons
|
| 15 |
): PaymentMethodIcon[] => {
|
| 16 |
const normalizedIcons: Record< string, PaymentMethodIcon > = {};
|
| 17 |
|
assets/js/base/components/cart-checkout/shipping-rates-control/index.tsx
CHANGED
|
@@ -150,7 +150,7 @@ const ShippingRatesControl = ( {
|
|
| 150 |
// Prepare props to pass to the ExperimentalOrderShippingPackages slot fill.
|
| 151 |
// We need to pluck out receiveCart.
|
| 152 |
// eslint-disable-next-line no-unused-vars
|
| 153 |
-
const { extensions, ...cart } = useStoreCart();
|
| 154 |
const slotFillProps = {
|
| 155 |
className,
|
| 156 |
collapsible,
|
| 150 |
// Prepare props to pass to the ExperimentalOrderShippingPackages slot fill.
|
| 151 |
// We need to pluck out receiveCart.
|
| 152 |
// eslint-disable-next-line no-unused-vars
|
| 153 |
+
const { extensions, receiveCart, ...cart } = useStoreCart();
|
| 154 |
const slotFillProps = {
|
| 155 |
className,
|
| 156 |
collapsible,
|
assets/js/base/components/checkbox-control/index.tsx
CHANGED
|
@@ -16,6 +16,7 @@ type CheckboxControlProps = {
|
|
| 16 |
instanceId: string;
|
| 17 |
onChange: ( value: boolean ) => void;
|
| 18 |
children: React.ReactChildren;
|
|
|
|
| 19 |
};
|
| 20 |
|
| 21 |
/**
|
|
@@ -28,6 +29,7 @@ const CheckboxControl = ( {
|
|
| 28 |
instanceId,
|
| 29 |
onChange,
|
| 30 |
children,
|
|
|
|
| 31 |
...rest
|
| 32 |
}: CheckboxControlProps ): JSX.Element => {
|
| 33 |
const checkboxId = id || `checkbox-control-${ instanceId }`;
|
|
@@ -36,6 +38,9 @@ const CheckboxControl = ( {
|
|
| 36 |
<label
|
| 37 |
className={ classNames(
|
| 38 |
'wc-block-components-checkbox',
|
|
|
|
|
|
|
|
|
|
| 39 |
className
|
| 40 |
) }
|
| 41 |
htmlFor={ checkboxId }
|
|
@@ -45,6 +50,7 @@ const CheckboxControl = ( {
|
|
| 45 |
className="wc-block-components-checkbox__input"
|
| 46 |
type="checkbox"
|
| 47 |
onChange={ ( event ) => onChange( event.target.checked ) }
|
|
|
|
| 48 |
{ ...rest }
|
| 49 |
/>
|
| 50 |
<svg
|
| 16 |
instanceId: string;
|
| 17 |
onChange: ( value: boolean ) => void;
|
| 18 |
children: React.ReactChildren;
|
| 19 |
+
hasError: boolean;
|
| 20 |
};
|
| 21 |
|
| 22 |
/**
|
| 29 |
instanceId,
|
| 30 |
onChange,
|
| 31 |
children,
|
| 32 |
+
hasError = false,
|
| 33 |
...rest
|
| 34 |
}: CheckboxControlProps ): JSX.Element => {
|
| 35 |
const checkboxId = id || `checkbox-control-${ instanceId }`;
|
| 38 |
<label
|
| 39 |
className={ classNames(
|
| 40 |
'wc-block-components-checkbox',
|
| 41 |
+
{
|
| 42 |
+
'has-error': hasError,
|
| 43 |
+
},
|
| 44 |
className
|
| 45 |
) }
|
| 46 |
htmlFor={ checkboxId }
|
| 50 |
className="wc-block-components-checkbox__input"
|
| 51 |
type="checkbox"
|
| 52 |
onChange={ ( event ) => onChange( event.target.checked ) }
|
| 53 |
+
aria-invalid={ hasError === true }
|
| 54 |
{ ...rest }
|
| 55 |
/>
|
| 56 |
<svg
|
assets/js/base/components/checkbox-control/style.scss
CHANGED
|
@@ -3,6 +3,7 @@
|
|
| 3 |
align-items: flex-start;
|
| 4 |
display: flex;
|
| 5 |
position: relative;
|
|
|
|
| 6 |
|
| 7 |
.wc-block-components-checkbox__input[type="checkbox"] {
|
| 8 |
font-size: 1em;
|
|
@@ -25,6 +26,11 @@
|
|
| 25 |
border-color: $input-border-gray;
|
| 26 |
}
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
&::before,
|
| 29 |
&::after {
|
| 30 |
content: "";
|
|
@@ -42,6 +48,11 @@
|
|
| 42 |
background: $input-background-dark;
|
| 43 |
border-color: $controls-border-dark;
|
| 44 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
}
|
| 46 |
}
|
| 47 |
|
|
@@ -59,7 +70,7 @@
|
|
| 59 |
border-color: $alert-red;
|
| 60 |
}
|
| 61 |
&:focus {
|
| 62 |
-
outline:
|
| 63 |
outline-offset: 2px;
|
| 64 |
}
|
| 65 |
}
|
| 3 |
align-items: flex-start;
|
| 4 |
display: flex;
|
| 5 |
position: relative;
|
| 6 |
+
margin-top: em($gap-large);
|
| 7 |
|
| 8 |
.wc-block-components-checkbox__input[type="checkbox"] {
|
| 9 |
font-size: 1em;
|
| 26 |
border-color: $input-border-gray;
|
| 27 |
}
|
| 28 |
|
| 29 |
+
&:focus {
|
| 30 |
+
outline: 2px solid $input-border-gray;
|
| 31 |
+
outline-offset: 2px;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
&::before,
|
| 35 |
&::after {
|
| 36 |
content: "";
|
| 48 |
background: $input-background-dark;
|
| 49 |
border-color: $controls-border-dark;
|
| 50 |
}
|
| 51 |
+
|
| 52 |
+
&:focus {
|
| 53 |
+
outline: 2px solid $controls-border-dark;
|
| 54 |
+
outline-offset: 2px;
|
| 55 |
+
}
|
| 56 |
}
|
| 57 |
}
|
| 58 |
|
| 70 |
border-color: $alert-red;
|
| 71 |
}
|
| 72 |
&:focus {
|
| 73 |
+
outline: 2px solid $alert-red;
|
| 74 |
outline-offset: 2px;
|
| 75 |
}
|
| 76 |
}
|
assets/js/base/components/combobox/index.tsx
CHANGED
|
@@ -142,6 +142,7 @@ const Combobox = ( {
|
|
| 142 |
value={ value || '' }
|
| 143 |
allowReset={ false }
|
| 144 |
autoComplete={ autoComplete }
|
|
|
|
| 145 |
/>
|
| 146 |
<ValidationInputError propertyName={ errorId } />
|
| 147 |
</div>
|
| 142 |
value={ value || '' }
|
| 143 |
allowReset={ false }
|
| 144 |
autoComplete={ autoComplete }
|
| 145 |
+
aria-invalid={ error.message && ! error.hidden }
|
| 146 |
/>
|
| 147 |
<ValidationInputError propertyName={ errorId } />
|
| 148 |
</div>
|
assets/js/base/components/combobox/style.scss
CHANGED
|
@@ -40,6 +40,8 @@
|
|
| 40 |
&:focus {
|
| 41 |
background-color: #fff;
|
| 42 |
color: $input-text-active;
|
|
|
|
|
|
|
| 43 |
}
|
| 44 |
|
| 45 |
&[aria-expanded="true"] {
|
|
@@ -55,6 +57,7 @@
|
|
| 55 |
&:focus {
|
| 56 |
background-color: $input-background-dark;
|
| 57 |
color: $input-text-dark;
|
|
|
|
| 58 |
}
|
| 59 |
}
|
| 60 |
}
|
|
@@ -147,8 +150,7 @@
|
|
| 147 |
border-color: $alert-red;
|
| 148 |
}
|
| 149 |
&:focus {
|
| 150 |
-
|
| 151 |
-
outline-offset: 2px;
|
| 152 |
}
|
| 153 |
}
|
| 154 |
}
|
| 40 |
&:focus {
|
| 41 |
background-color: #fff;
|
| 42 |
color: $input-text-active;
|
| 43 |
+
outline: 0;
|
| 44 |
+
box-shadow: 0 0 0 1px $input-border-gray;
|
| 45 |
}
|
| 46 |
|
| 47 |
&[aria-expanded="true"] {
|
| 57 |
&:focus {
|
| 58 |
background-color: $input-background-dark;
|
| 59 |
color: $input-text-dark;
|
| 60 |
+
box-shadow: 0 0 0 1px $input-border-dark;
|
| 61 |
}
|
| 62 |
}
|
| 63 |
}
|
| 150 |
border-color: $alert-red;
|
| 151 |
}
|
| 152 |
&:focus {
|
| 153 |
+
box-shadow: 0 0 0 1px $alert-red;
|
|
|
|
| 154 |
}
|
| 155 |
}
|
| 156 |
}
|
assets/js/base/components/drawer/index.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
/**
|
| 2 |
* External dependencies
|
| 3 |
*/
|
|
|
|
| 4 |
import { Modal } from '@wordpress/components';
|
| 5 |
import { useDebounce } from 'use-debounce';
|
| 6 |
import classNames from 'classnames';
|
|
@@ -50,6 +51,10 @@ const Drawer = ( {
|
|
| 50 |
'wc-block-components-drawer__screen-overlay--with-slide-out': slideOut,
|
| 51 |
}
|
| 52 |
) }
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
>
|
| 54 |
{ children }
|
| 55 |
</Modal>
|
| 1 |
/**
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
+
import { __ } from '@wordpress/i18n';
|
| 5 |
import { Modal } from '@wordpress/components';
|
| 6 |
import { useDebounce } from 'use-debounce';
|
| 7 |
import classNames from 'classnames';
|
| 51 |
'wc-block-components-drawer__screen-overlay--with-slide-out': slideOut,
|
| 52 |
}
|
| 53 |
) }
|
| 54 |
+
closeButtonLabel={ __(
|
| 55 |
+
'Close mini cart',
|
| 56 |
+
'woo-gutenberg-products-block'
|
| 57 |
+
) }
|
| 58 |
>
|
| 59 |
{ children }
|
| 60 |
</Modal>
|
assets/js/base/components/reviews/review-list-item/index.js
CHANGED
|
@@ -14,11 +14,7 @@ import './style.scss';
|
|
| 14 |
function getReviewImage( review, imageType, isLoading ) {
|
| 15 |
if ( isLoading || ! review ) {
|
| 16 |
return (
|
| 17 |
-
<div
|
| 18 |
-
className="wc-block-review-list-item__image wc-block-components-review-list-item__image"
|
| 19 |
-
width="48"
|
| 20 |
-
height="48"
|
| 21 |
-
/>
|
| 22 |
);
|
| 23 |
}
|
| 24 |
|
|
@@ -34,8 +30,7 @@ function getReviewImage( review, imageType, isLoading ) {
|
|
| 34 |
<img
|
| 35 |
aria-hidden="true"
|
| 36 |
alt=""
|
| 37 |
-
src={ review.reviewer_avatar_urls[ '
|
| 38 |
-
srcSet={ review.reviewer_avatar_urls[ '96' ] + ' 2x' }
|
| 39 |
/>
|
| 40 |
) }
|
| 41 |
{ review.verified && (
|
|
@@ -163,6 +158,7 @@ const ReviewListItem = ( { attributes, review = {} } ) => {
|
|
| 163 |
'wc-block-components-review-list-item__item',
|
| 164 |
{
|
| 165 |
'is-loading': isLoading,
|
|
|
|
| 166 |
}
|
| 167 |
) }
|
| 168 |
aria-hidden={ isLoading }
|
| 14 |
function getReviewImage( review, imageType, isLoading ) {
|
| 15 |
if ( isLoading || ! review ) {
|
| 16 |
return (
|
| 17 |
+
<div className="wc-block-review-list-item__image wc-block-components-review-list-item__image" />
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
);
|
| 19 |
}
|
| 20 |
|
| 30 |
<img
|
| 31 |
aria-hidden="true"
|
| 32 |
alt=""
|
| 33 |
+
src={ review.reviewer_avatar_urls[ '96' ] || '' }
|
|
|
|
| 34 |
/>
|
| 35 |
) }
|
| 36 |
{ review.verified && (
|
| 158 |
'wc-block-components-review-list-item__item',
|
| 159 |
{
|
| 160 |
'is-loading': isLoading,
|
| 161 |
+
'wc-block-components-review-list-item__item--has-image': showReviewImage,
|
| 162 |
}
|
| 163 |
) }
|
| 164 |
aria-hidden={ isLoading }
|
assets/js/base/components/reviews/review-list-item/style.scss
CHANGED
|
@@ -57,9 +57,9 @@
|
|
| 57 |
grid-row: 1;
|
| 58 |
}
|
| 59 |
|
| 60 |
-
.has-image {
|
| 61 |
.wc-block-components-review-list-item__info {
|
| 62 |
-
grid-template-columns:
|
| 63 |
}
|
| 64 |
.wc-block-components-review-list-item__meta {
|
| 65 |
grid-column: 2;
|
|
@@ -69,19 +69,17 @@
|
|
| 69 |
.wc-block-components-review-list-item__image {
|
| 70 |
align-items: center;
|
| 71 |
display: flex;
|
| 72 |
-
height:
|
| 73 |
grid-column: 1;
|
| 74 |
grid-row: 1 / 3;
|
| 75 |
justify-content: center;
|
| 76 |
position: relative;
|
| 77 |
-
width:
|
| 78 |
|
| 79 |
> img {
|
| 80 |
display: block;
|
| 81 |
-
height: auto;
|
| 82 |
max-height: 100%;
|
| 83 |
-
|
| 84 |
-
width: auto;
|
| 85 |
}
|
| 86 |
}
|
| 87 |
|
|
@@ -134,23 +132,28 @@
|
|
| 134 |
|
| 135 |
.wc-block-components-review-list-item__product + .wc-block-components-review-list-item__author {
|
| 136 |
font-weight: normal;
|
| 137 |
-
color: #808080;
|
| 138 |
order: 4;
|
| 139 |
}
|
| 140 |
|
| 141 |
.wc-block-components-review-list-item__published-date {
|
| 142 |
-
color: #808080;
|
| 143 |
order: 5;
|
| 144 |
}
|
| 145 |
|
| 146 |
-
.wc-block-components-review-list-item__author + .wc-block-components-review-list-item__published-date {
|
|
|
|
|
|
|
|
|
|
| 147 |
&::before {
|
| 148 |
content: "";
|
| 149 |
display: inline-block;
|
| 150 |
-
margin-
|
| 151 |
-
border-right: 1px solid
|
|
|
|
| 152 |
height: 1em;
|
| 153 |
vertical-align: middle;
|
|
|
|
|
|
|
|
|
|
| 154 |
}
|
| 155 |
}
|
| 156 |
|
|
@@ -166,16 +169,15 @@
|
|
| 166 |
|
| 167 |
> .wc-block-components-review-list-item__rating__stars {
|
| 168 |
@include font-size(regular);
|
| 169 |
-
display:
|
| 170 |
top: 0;
|
| 171 |
overflow: hidden;
|
| 172 |
position: relative;
|
| 173 |
-
height:
|
| 174 |
-
line-height: 1
|
| 175 |
width: 5.3em;
|
| 176 |
font-family: star; /* stylelint-disable-line */
|
| 177 |
font-weight: 400;
|
| 178 |
-
vertical-align: top;
|
| 179 |
}
|
| 180 |
|
| 181 |
> .wc-block-components-review-list-item__rating__stars::before {
|
|
@@ -204,3 +206,7 @@
|
|
| 204 |
color: #e6a237;
|
| 205 |
}
|
| 206 |
}
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
grid-row: 1;
|
| 58 |
}
|
| 59 |
|
| 60 |
+
.wc-block-components-review-list-item__item--has-image {
|
| 61 |
.wc-block-components-review-list-item__info {
|
| 62 |
+
grid-template-columns: calc(3em + #{$gap}) 1fr;
|
| 63 |
}
|
| 64 |
.wc-block-components-review-list-item__meta {
|
| 65 |
grid-column: 2;
|
| 69 |
.wc-block-components-review-list-item__image {
|
| 70 |
align-items: center;
|
| 71 |
display: flex;
|
| 72 |
+
height: 3em;
|
| 73 |
grid-column: 1;
|
| 74 |
grid-row: 1 / 3;
|
| 75 |
justify-content: center;
|
| 76 |
position: relative;
|
| 77 |
+
width: 3em;
|
| 78 |
|
| 79 |
> img {
|
| 80 |
display: block;
|
|
|
|
| 81 |
max-height: 100%;
|
| 82 |
+
object-fit: contain;
|
|
|
|
| 83 |
}
|
| 84 |
}
|
| 85 |
|
| 132 |
|
| 133 |
.wc-block-components-review-list-item__product + .wc-block-components-review-list-item__author {
|
| 134 |
font-weight: normal;
|
|
|
|
| 135 |
order: 4;
|
| 136 |
}
|
| 137 |
|
| 138 |
.wc-block-components-review-list-item__published-date {
|
|
|
|
| 139 |
order: 5;
|
| 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/2;
|
| 144 |
+
position: relative;
|
| 145 |
+
|
| 146 |
&::before {
|
| 147 |
content: "";
|
| 148 |
display: inline-block;
|
| 149 |
+
margin-left: -$gap*0.5;
|
| 150 |
+
border-right: 1px solid currentColor;
|
| 151 |
+
opacity: 0.5;
|
| 152 |
height: 1em;
|
| 153 |
vertical-align: middle;
|
| 154 |
+
position: absolute;
|
| 155 |
+
top: calc(50% + 0.1em);
|
| 156 |
+
transform: translateY(-50%);
|
| 157 |
}
|
| 158 |
}
|
| 159 |
|
| 169 |
|
| 170 |
> .wc-block-components-review-list-item__rating__stars {
|
| 171 |
@include font-size(regular);
|
| 172 |
+
display: block;
|
| 173 |
top: 0;
|
| 174 |
overflow: hidden;
|
| 175 |
position: relative;
|
| 176 |
+
height: 1em;
|
| 177 |
+
line-height: 1;
|
| 178 |
width: 5.3em;
|
| 179 |
font-family: star; /* stylelint-disable-line */
|
| 180 |
font-weight: 400;
|
|
|
|
| 181 |
}
|
| 182 |
|
| 183 |
> .wc-block-components-review-list-item__rating__stars::before {
|
| 206 |
color: #e6a237;
|
| 207 |
}
|
| 208 |
}
|
| 209 |
+
|
| 210 |
+
.wc-block-components-review-list-item__text p {
|
| 211 |
+
font-size: inherit;
|
| 212 |
+
}
|
assets/js/base/components/reviews/review-list/style.scss
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
.
|
| 2 |
-
.
|
| 3 |
margin: 0;
|
| 4 |
}
|
| 1 |
+
// Duplicate class for specificity in the editor.
|
| 2 |
+
.wc-block-components-review-list.wc-block-components-review-list {
|
| 3 |
margin: 0;
|
| 4 |
}
|
assets/js/base/components/sort-select/style.scss
CHANGED
|
@@ -9,5 +9,6 @@
|
|
| 9 |
}
|
| 10 |
|
| 11 |
.wc-block-components-sort-select__select {
|
|
|
|
| 12 |
width: max-content;
|
| 13 |
}
|
| 9 |
}
|
| 10 |
|
| 11 |
.wc-block-components-sort-select__select {
|
| 12 |
+
font-size: inherit;
|
| 13 |
width: max-content;
|
| 14 |
}
|
assets/js/base/components/state-input/state-input.tsx
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
*/
|
| 4 |
import { __ } from '@wordpress/i18n';
|
| 5 |
import { decodeEntities } from '@wordpress/html-entities';
|
| 6 |
-
import { useCallback, useMemo } from '@wordpress/element';
|
| 7 |
import classnames from 'classnames';
|
| 8 |
|
| 9 |
/**
|
|
@@ -14,6 +14,18 @@ import Combobox from '../combobox';
|
|
| 14 |
import './style.scss';
|
| 15 |
import type { StateInputWithStatesProps } from './StateInputProps';
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
const StateInput = ( {
|
| 18 |
className,
|
| 19 |
id,
|
|
@@ -39,27 +51,41 @@ const StateInput = ( {
|
|
| 39 |
|
| 40 |
/**
|
| 41 |
* Handles state selection onChange events. Finds a matching state by key or value.
|
| 42 |
-
*
|
| 43 |
-
* @param {Object} event event data.
|
| 44 |
*/
|
| 45 |
const onChangeState = useCallback(
|
| 46 |
-
( stateValue ) => {
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
(
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
option.value.toLocaleUpperCase() ===
|
| 53 |
-
stateValue.toLocaleUpperCase()
|
| 54 |
-
);
|
| 55 |
-
onChange( foundOption ? foundOption.value : '' );
|
| 56 |
-
return;
|
| 57 |
-
}
|
| 58 |
-
onChange( stateValue );
|
| 59 |
},
|
| 60 |
[ onChange, options ]
|
| 61 |
);
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
if ( options.length > 0 ) {
|
| 64 |
return (
|
| 65 |
<>
|
|
@@ -102,6 +128,7 @@ const StateInput = ( {
|
|
| 102 |
</>
|
| 103 |
);
|
| 104 |
}
|
|
|
|
| 105 |
return (
|
| 106 |
<ValidatedTextInput
|
| 107 |
className={ className }
|
| 3 |
*/
|
| 4 |
import { __ } from '@wordpress/i18n';
|
| 5 |
import { decodeEntities } from '@wordpress/html-entities';
|
| 6 |
+
import { useCallback, useMemo, useEffect, useRef } from '@wordpress/element';
|
| 7 |
import classnames from 'classnames';
|
| 8 |
|
| 9 |
/**
|
| 14 |
import './style.scss';
|
| 15 |
import type { StateInputWithStatesProps } from './StateInputProps';
|
| 16 |
|
| 17 |
+
const optionMatcher = (
|
| 18 |
+
value: string,
|
| 19 |
+
options: { label: string; value: string }[]
|
| 20 |
+
): string => {
|
| 21 |
+
const foundOption = options.find(
|
| 22 |
+
( option ) =>
|
| 23 |
+
option.label.toLocaleUpperCase() === value.toLocaleUpperCase() ||
|
| 24 |
+
option.value.toLocaleUpperCase() === value.toLocaleUpperCase()
|
| 25 |
+
);
|
| 26 |
+
return foundOption ? foundOption.value : '';
|
| 27 |
+
};
|
| 28 |
+
|
| 29 |
const StateInput = ( {
|
| 30 |
className,
|
| 31 |
id,
|
| 51 |
|
| 52 |
/**
|
| 53 |
* Handles state selection onChange events. Finds a matching state by key or value.
|
|
|
|
|
|
|
| 54 |
*/
|
| 55 |
const onChangeState = useCallback(
|
| 56 |
+
( stateValue: string ) => {
|
| 57 |
+
onChange(
|
| 58 |
+
options.length > 0
|
| 59 |
+
? optionMatcher( stateValue, options )
|
| 60 |
+
: stateValue
|
| 61 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
},
|
| 63 |
[ onChange, options ]
|
| 64 |
);
|
| 65 |
|
| 66 |
+
/**
|
| 67 |
+
* Track value changes.
|
| 68 |
+
*/
|
| 69 |
+
const valueRef = useRef< string >( value );
|
| 70 |
+
|
| 71 |
+
useEffect( () => {
|
| 72 |
+
if ( valueRef.current !== value ) {
|
| 73 |
+
valueRef.current = value;
|
| 74 |
+
}
|
| 75 |
+
}, [ value ] );
|
| 76 |
+
|
| 77 |
+
/**
|
| 78 |
+
* If given a list of options, ensure the value matches those options or trigger change.
|
| 79 |
+
*/
|
| 80 |
+
useEffect( () => {
|
| 81 |
+
if ( options.length > 0 && valueRef.current ) {
|
| 82 |
+
const match = optionMatcher( valueRef.current, options );
|
| 83 |
+
if ( match !== valueRef.current ) {
|
| 84 |
+
onChangeState( match );
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
}, [ options, onChangeState ] );
|
| 88 |
+
|
| 89 |
if ( options.length > 0 ) {
|
| 90 |
return (
|
| 91 |
<>
|
| 128 |
</>
|
| 129 |
);
|
| 130 |
}
|
| 131 |
+
|
| 132 |
return (
|
| 133 |
<ValidatedTextInput
|
| 134 |
className={ className }
|
assets/js/base/components/text-input/style.scss
CHANGED
|
@@ -59,6 +59,8 @@
|
|
| 59 |
&:focus {
|
| 60 |
background-color: #fff;
|
| 61 |
color: $input-text-active;
|
|
|
|
|
|
|
| 62 |
}
|
| 63 |
|
| 64 |
.has-dark-controls & {
|
|
@@ -69,6 +71,7 @@
|
|
| 69 |
&:focus {
|
| 70 |
background-color: $input-background-dark;
|
| 71 |
color: $input-text-dark;
|
|
|
|
| 72 |
}
|
| 73 |
}
|
| 74 |
}
|
|
@@ -99,8 +102,7 @@
|
|
| 99 |
border-color: $alert-red;
|
| 100 |
}
|
| 101 |
&:focus {
|
| 102 |
-
|
| 103 |
-
outline-offset: 2px;
|
| 104 |
}
|
| 105 |
}
|
| 106 |
|
| 59 |
&:focus {
|
| 60 |
background-color: #fff;
|
| 61 |
color: $input-text-active;
|
| 62 |
+
outline: 0;
|
| 63 |
+
box-shadow: 0 0 0 1px $input-border-gray;
|
| 64 |
}
|
| 65 |
|
| 66 |
.has-dark-controls & {
|
| 71 |
&:focus {
|
| 72 |
background-color: $input-background-dark;
|
| 73 |
color: $input-text-dark;
|
| 74 |
+
box-shadow: 0 0 0 1px $input-border-dark;
|
| 75 |
}
|
| 76 |
}
|
| 77 |
}
|
| 102 |
border-color: $alert-red;
|
| 103 |
}
|
| 104 |
&:focus {
|
| 105 |
+
box-shadow: 0 0 0 1px $alert-red;
|
|
|
|
| 106 |
}
|
| 107 |
}
|
| 108 |
|
assets/js/base/components/text-input/validated-text-input.tsx
CHANGED
|
@@ -151,6 +151,7 @@ const ValidatedTextInput = ( {
|
|
| 151 |
className={ classnames( className, {
|
| 152 |
'has-error': hasError,
|
| 153 |
} ) }
|
|
|
|
| 154 |
id={ textInputId }
|
| 155 |
onBlur={ () => {
|
| 156 |
validateInput( false );
|
| 151 |
className={ classnames( className, {
|
| 152 |
'has-error': hasError,
|
| 153 |
} ) }
|
| 154 |
+
aria-invalid={ hasError === true }
|
| 155 |
id={ textInputId }
|
| 156 |
onBlur={ () => {
|
| 157 |
validateInput( false );
|
assets/js/base/context/hooks/cart/use-store-cart.ts
CHANGED
|
@@ -26,7 +26,7 @@ import type {
|
|
| 26 |
CartResponseBillingAddress,
|
| 27 |
CartResponseShippingAddress,
|
| 28 |
CartResponseCouponItem,
|
| 29 |
-
|
| 30 |
} from '@woocommerce/types';
|
| 31 |
import {
|
| 32 |
emptyHiddenAddressFields,
|
|
@@ -129,6 +129,7 @@ export const defaultCartData: StoreCart = {
|
|
| 129 |
*
|
| 130 |
* @return {StoreCart} Object containing cart data.
|
| 131 |
*/
|
|
|
|
| 132 |
export const useStoreCart = (
|
| 133 |
options: { shouldSelect: boolean } = { shouldSelect: true }
|
| 134 |
): StoreCart => {
|
|
@@ -136,7 +137,6 @@ export const useStoreCart = (
|
|
| 136 |
const previewCart = previewData?.previewCart;
|
| 137 |
const { shouldSelect } = options;
|
| 138 |
const currentResults = useRef();
|
| 139 |
-
|
| 140 |
const results: StoreCart = useSelect(
|
| 141 |
( select, { dispatch } ) => {
|
| 142 |
if ( ! shouldSelect ) {
|
|
@@ -194,7 +194,7 @@ export const useStoreCart = (
|
|
| 194 |
// Add a text property to the coupon to allow extensions to modify
|
| 195 |
// the text used to display the coupon, without affecting the
|
| 196 |
// functionality when it comes to removing the coupon.
|
| 197 |
-
const cartCoupons:
|
| 198 |
cartData.coupons.length > 0
|
| 199 |
? cartData.coupons.map(
|
| 200 |
( coupon: CartResponseCouponItem ) => ( {
|
| 26 |
CartResponseBillingAddress,
|
| 27 |
CartResponseShippingAddress,
|
| 28 |
CartResponseCouponItem,
|
| 29 |
+
CartResponseCoupons,
|
| 30 |
} from '@woocommerce/types';
|
| 31 |
import {
|
| 32 |
emptyHiddenAddressFields,
|
| 129 |
*
|
| 130 |
* @return {StoreCart} Object containing cart data.
|
| 131 |
*/
|
| 132 |
+
|
| 133 |
export const useStoreCart = (
|
| 134 |
options: { shouldSelect: boolean } = { shouldSelect: true }
|
| 135 |
): StoreCart => {
|
| 137 |
const previewCart = previewData?.previewCart;
|
| 138 |
const { shouldSelect } = options;
|
| 139 |
const currentResults = useRef();
|
|
|
|
| 140 |
const results: StoreCart = useSelect(
|
| 141 |
( select, { dispatch } ) => {
|
| 142 |
if ( ! shouldSelect ) {
|
| 194 |
// Add a text property to the coupon to allow extensions to modify
|
| 195 |
// the text used to display the coupon, without affecting the
|
| 196 |
// functionality when it comes to removing the coupon.
|
| 197 |
+
const cartCoupons: CartResponseCoupons =
|
| 198 |
cartData.coupons.length > 0
|
| 199 |
? cartData.coupons.map(
|
| 200 |
( coupon: CartResponseCouponItem ) => ( {
|
assets/js/base/context/hooks/payment-methods/{use-payment-methods.js → use-payment-methods.ts}
RENAMED
|
@@ -2,13 +2,28 @@
|
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import { useShallowEqual } from '@woocommerce/base-hooks';
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
/**
|
| 7 |
* Internal dependencies
|
| 8 |
*/
|
| 9 |
import { usePaymentMethodDataContext } from '../../providers/cart-checkout/payment-methods';
|
| 10 |
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
const {
|
| 13 |
paymentMethods,
|
| 14 |
expressPaymentMethods,
|
|
@@ -31,5 +46,8 @@ const usePaymentMethodState = ( express = false ) => {
|
|
| 31 |
};
|
| 32 |
};
|
| 33 |
|
| 34 |
-
export const usePaymentMethods = ()
|
| 35 |
-
|
|
|
|
|
|
|
|
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import { useShallowEqual } from '@woocommerce/base-hooks';
|
| 5 |
+
import type {
|
| 6 |
+
PaymentMethods,
|
| 7 |
+
ExpressPaymentMethods,
|
| 8 |
+
} from '@woocommerce/type-defs/payments';
|
| 9 |
|
| 10 |
/**
|
| 11 |
* Internal dependencies
|
| 12 |
*/
|
| 13 |
import { usePaymentMethodDataContext } from '../../providers/cart-checkout/payment-methods';
|
| 14 |
|
| 15 |
+
interface PaymentMethodState {
|
| 16 |
+
paymentMethods: PaymentMethods;
|
| 17 |
+
isInitialized: boolean;
|
| 18 |
+
}
|
| 19 |
+
interface ExpressPaymentMethodState {
|
| 20 |
+
paymentMethods: ExpressPaymentMethods;
|
| 21 |
+
isInitialized: boolean;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
const usePaymentMethodState = (
|
| 25 |
+
express = false
|
| 26 |
+
): PaymentMethodState | ExpressPaymentMethodState => {
|
| 27 |
const {
|
| 28 |
paymentMethods,
|
| 29 |
expressPaymentMethods,
|
| 46 |
};
|
| 47 |
};
|
| 48 |
|
| 49 |
+
export const usePaymentMethods = ():
|
| 50 |
+
| PaymentMethodState
|
| 51 |
+
| ExpressPaymentMethodState => usePaymentMethodState( false );
|
| 52 |
+
export const useExpressPaymentMethods = (): ExpressPaymentMethodState =>
|
| 53 |
+
usePaymentMethodState( true );
|
assets/js/base/context/hooks/use-store-notices.ts
CHANGED
|
@@ -29,7 +29,7 @@ type WPNotice = {
|
|
| 29 |
|
| 30 |
type NoticeOptions = {
|
| 31 |
id: string;
|
| 32 |
-
type
|
| 33 |
isDismissible: boolean;
|
| 34 |
};
|
| 35 |
|
| 29 |
|
| 30 |
type NoticeOptions = {
|
| 31 |
id: string;
|
| 32 |
+
type?: string;
|
| 33 |
isDismissible: boolean;
|
| 34 |
};
|
| 35 |
|
assets/js/base/context/providers/cart-checkout/payment-methods/actions.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
/**
|
| 2 |
* Internal dependencies
|
| 3 |
*/
|
| 4 |
import { ACTION, STATUS } from './constants';
|
| 5 |
-
import type { PaymentMethods, ExpressPaymentMethods } from './types';
|
| 6 |
|
| 7 |
export interface ActionType {
|
| 8 |
type: ACTION | STATUS;
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import {
|
| 5 |
+
PaymentMethods,
|
| 6 |
+
ExpressPaymentMethods,
|
| 7 |
+
} from '@woocommerce/type-defs/payments';
|
| 8 |
+
|
| 9 |
/**
|
| 10 |
* Internal dependencies
|
| 11 |
*/
|
| 12 |
import { ACTION, STATUS } from './constants';
|
|
|
|
| 13 |
|
| 14 |
export interface ActionType {
|
| 15 |
type: ACTION | STATUS;
|
assets/js/base/context/providers/cart-checkout/payment-methods/types.ts
CHANGED
|
@@ -1,57 +1,23 @@
|
|
| 1 |
/**
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
-
import
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
/**
|
| 7 |
* Internal dependencies
|
| 8 |
*/
|
| 9 |
import type { emitterCallback } from '../../../event-emit';
|
| 10 |
import { STATUS } from './constants';
|
| 11 |
|
| 12 |
-
type ObjectType = Record< string, unknown >;
|
| 13 |
-
type EmptyObjectType = Record< string, never >;
|
| 14 |
-
|
| 15 |
-
export interface PaymentMethodConfig {
|
| 16 |
-
// A unique string to identify the payment method client side.
|
| 17 |
-
name: string;
|
| 18 |
-
// A react node for your payment method UI.
|
| 19 |
-
content: ReactNode;
|
| 20 |
-
// A react node to display a preview of your payment method in the editor.
|
| 21 |
-
edit: ReactNode;
|
| 22 |
-
// A callback to determine whether the payment method should be shown in the checkout.
|
| 23 |
-
canMakePayment: (
|
| 24 |
-
cartData: ObjectType
|
| 25 |
-
) => Promise< boolean | { error: { message: string } } >;
|
| 26 |
-
// A unique string to represent the payment method server side. If not provided, defaults to name.
|
| 27 |
-
paymentMethodId?: string;
|
| 28 |
-
// Object that describes various features provided by the payment method.
|
| 29 |
-
supports: ObjectType;
|
| 30 |
-
// Array of card types (brands) supported by the payment method. (See stripe/credit-card for example.)
|
| 31 |
-
icons: ObjectType;
|
| 32 |
-
// A react node that will be used as a label for the payment method in the checkout.
|
| 33 |
-
label: ReactNode;
|
| 34 |
-
// An accessibility label. Screen readers will output this label when the payment method is selected.
|
| 35 |
-
ariaLabel: string;
|
| 36 |
-
// Optionally customize the label text for the checkout submit (`Place Order`) button.
|
| 37 |
-
placeOrderButtonLabel?: string;
|
| 38 |
-
}
|
| 39 |
-
|
| 40 |
-
export type ExpressPaymentMethodConfig = Omit<
|
| 41 |
-
PaymentMethodConfig,
|
| 42 |
-
'icons' | 'label' | 'ariaLabel' | 'placeOrderButtonLabel'
|
| 43 |
-
>;
|
| 44 |
-
|
| 45 |
-
export type PaymentMethods =
|
| 46 |
-
| Record< string, PaymentMethodConfig >
|
| 47 |
-
| EmptyObjectType;
|
| 48 |
-
|
| 49 |
-
export type ExpressPaymentMethods =
|
| 50 |
-
| Record< string, ExpressPaymentMethodConfig >
|
| 51 |
-
| EmptyObjectType;
|
| 52 |
-
|
| 53 |
export interface CustomerPaymentMethod {
|
| 54 |
-
method:
|
| 55 |
expires: string;
|
| 56 |
is_default: boolean;
|
| 57 |
tokenId: number;
|
|
@@ -158,3 +124,7 @@ export type PaymentMethodDataContextType = {
|
|
| 158 |
// True means that the configured payment method option is saved for the customer.
|
| 159 |
shouldSavePayment: boolean;
|
| 160 |
};
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
/**
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
+
import {
|
| 5 |
+
PaymentMethodConfiguration,
|
| 6 |
+
PaymentMethods,
|
| 7 |
+
ExpressPaymentMethods,
|
| 8 |
+
} from '@woocommerce/type-defs/payments';
|
| 9 |
+
import type {
|
| 10 |
+
EmptyObjectType,
|
| 11 |
+
ObjectType,
|
| 12 |
+
} from '@woocommerce/type-defs/objects';
|
| 13 |
/**
|
| 14 |
* Internal dependencies
|
| 15 |
*/
|
| 16 |
import type { emitterCallback } from '../../../event-emit';
|
| 17 |
import { STATUS } from './constants';
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
export interface CustomerPaymentMethod {
|
| 20 |
+
method: PaymentMethodConfiguration;
|
| 21 |
expires: string;
|
| 22 |
is_default: boolean;
|
| 23 |
tokenId: number;
|
| 124 |
// True means that the configured payment method option is saved for the customer.
|
| 125 |
shouldSavePayment: boolean;
|
| 126 |
};
|
| 127 |
+
|
| 128 |
+
export type PaymentMethodsDispatcherType = (
|
| 129 |
+
paymentMethods: PaymentMethods
|
| 130 |
+
) => undefined;
|
assets/js/base/context/providers/cart-checkout/payment-methods/use-payment-method-registration.ts
CHANGED
|
@@ -9,6 +9,13 @@ import {
|
|
| 9 |
import { useState, useEffect, useRef, useCallback } from '@wordpress/element';
|
| 10 |
import { useShallowEqual } from '@woocommerce/base-hooks';
|
| 11 |
import { CURRENT_USER_IS_ADMIN, getSetting } from '@woocommerce/settings';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
/**
|
| 14 |
* Internal dependencies
|
|
@@ -16,16 +23,10 @@ import { CURRENT_USER_IS_ADMIN, getSetting } from '@woocommerce/settings';
|
|
| 16 |
import { useEditorContext } from '../../editor-context';
|
| 17 |
import { useShippingDataContext } from '../shipping';
|
| 18 |
import { useCustomerDataContext } from '../customer';
|
| 19 |
-
import type {
|
| 20 |
-
PaymentMethodsDispatcherType,
|
| 21 |
-
PaymentMethods,
|
| 22 |
-
ExpressPaymentMethods,
|
| 23 |
-
PaymentMethodConfig,
|
| 24 |
-
ExpressPaymentMethodConfig,
|
| 25 |
-
} from './types';
|
| 26 |
import { useStoreCart } from '../../../hooks/cart/use-store-cart';
|
| 27 |
import { useStoreNotices } from '../../../hooks/use-store-notices';
|
| 28 |
import { useEmitResponse } from '../../../hooks/use-emit-response';
|
|
|
|
| 29 |
|
| 30 |
/**
|
| 31 |
* This hook handles initializing registered payment methods and exposing all
|
|
@@ -51,12 +52,10 @@ const usePaymentMethodRegistration = (
|
|
| 51 |
const { billingData, shippingAddress } = useCustomerDataContext();
|
| 52 |
const selectedShippingMethods = useShallowEqual( selectedRates );
|
| 53 |
const paymentMethodsOrder = useShallowEqual( paymentMethodsSortOrder );
|
| 54 |
-
const
|
| 55 |
-
|
| 56 |
-
cartNeedsShipping,
|
| 57 |
-
paymentRequirements,
|
| 58 |
-
} = useStoreCart();
|
| 59 |
const canPayArgument = useRef( {
|
|
|
|
| 60 |
cartTotals,
|
| 61 |
cartNeedsShipping,
|
| 62 |
billingData,
|
|
@@ -68,6 +67,7 @@ const usePaymentMethodRegistration = (
|
|
| 68 |
|
| 69 |
useEffect( () => {
|
| 70 |
canPayArgument.current = {
|
|
|
|
| 71 |
cartTotals,
|
| 72 |
cartNeedsShipping,
|
| 73 |
billingData,
|
|
@@ -76,6 +76,7 @@ const usePaymentMethodRegistration = (
|
|
| 76 |
paymentRequirements,
|
| 77 |
};
|
| 78 |
}, [
|
|
|
|
| 79 |
cartTotals,
|
| 80 |
cartNeedsShipping,
|
| 81 |
billingData,
|
|
@@ -88,7 +89,9 @@ const usePaymentMethodRegistration = (
|
|
| 88 |
let availablePaymentMethods = {};
|
| 89 |
|
| 90 |
const addAvailablePaymentMethod = (
|
| 91 |
-
paymentMethod:
|
|
|
|
|
|
|
| 92 |
) => {
|
| 93 |
availablePaymentMethods = {
|
| 94 |
...availablePaymentMethods,
|
|
@@ -113,7 +116,7 @@ const usePaymentMethodRegistration = (
|
|
| 113 |
)
|
| 114 |
);
|
| 115 |
|
| 116 |
-
if (
|
| 117 |
if (
|
| 118 |
typeof canPay === 'object' &&
|
| 119 |
canPay !== null &&
|
|
@@ -158,16 +161,21 @@ const usePaymentMethodRegistration = (
|
|
| 158 |
registeredPaymentMethods,
|
| 159 |
] );
|
| 160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
// Determine which payment methods are available initially and whenever
|
| 162 |
-
// shipping methods or
|
| 163 |
// Some payment methods (e.g. COD) can be disabled for specific shipping methods.
|
| 164 |
useEffect( () => {
|
| 165 |
-
|
| 166 |
}, [
|
| 167 |
-
|
| 168 |
-
|
| 169 |
selectedShippingMethods,
|
| 170 |
-
|
| 171 |
] );
|
| 172 |
|
| 173 |
return isInitialized;
|
| 9 |
import { useState, useEffect, useRef, useCallback } from '@wordpress/element';
|
| 10 |
import { useShallowEqual } from '@woocommerce/base-hooks';
|
| 11 |
import { CURRENT_USER_IS_ADMIN, getSetting } from '@woocommerce/settings';
|
| 12 |
+
import type {
|
| 13 |
+
PaymentMethods,
|
| 14 |
+
ExpressPaymentMethods,
|
| 15 |
+
PaymentMethodConfigInstance,
|
| 16 |
+
ExpressPaymentMethodConfigInstance,
|
| 17 |
+
} from '@woocommerce/type-defs/payments';
|
| 18 |
+
import { useDebouncedCallback } from 'use-debounce';
|
| 19 |
|
| 20 |
/**
|
| 21 |
* Internal dependencies
|
| 23 |
import { useEditorContext } from '../../editor-context';
|
| 24 |
import { useShippingDataContext } from '../shipping';
|
| 25 |
import { useCustomerDataContext } from '../customer';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
import { useStoreCart } from '../../../hooks/cart/use-store-cart';
|
| 27 |
import { useStoreNotices } from '../../../hooks/use-store-notices';
|
| 28 |
import { useEmitResponse } from '../../../hooks/use-emit-response';
|
| 29 |
+
import type { PaymentMethodsDispatcherType } from './types';
|
| 30 |
|
| 31 |
/**
|
| 32 |
* This hook handles initializing registered payment methods and exposing all
|
| 52 |
const { billingData, shippingAddress } = useCustomerDataContext();
|
| 53 |
const selectedShippingMethods = useShallowEqual( selectedRates );
|
| 54 |
const paymentMethodsOrder = useShallowEqual( paymentMethodsSortOrder );
|
| 55 |
+
const cart = useStoreCart();
|
| 56 |
+
const { cartTotals, cartNeedsShipping, paymentRequirements } = cart;
|
|
|
|
|
|
|
|
|
|
| 57 |
const canPayArgument = useRef( {
|
| 58 |
+
cart,
|
| 59 |
cartTotals,
|
| 60 |
cartNeedsShipping,
|
| 61 |
billingData,
|
| 67 |
|
| 68 |
useEffect( () => {
|
| 69 |
canPayArgument.current = {
|
| 70 |
+
cart,
|
| 71 |
cartTotals,
|
| 72 |
cartNeedsShipping,
|
| 73 |
billingData,
|
| 76 |
paymentRequirements,
|
| 77 |
};
|
| 78 |
}, [
|
| 79 |
+
cart,
|
| 80 |
cartTotals,
|
| 81 |
cartNeedsShipping,
|
| 82 |
billingData,
|
| 89 |
let availablePaymentMethods = {};
|
| 90 |
|
| 91 |
const addAvailablePaymentMethod = (
|
| 92 |
+
paymentMethod:
|
| 93 |
+
| PaymentMethodConfigInstance
|
| 94 |
+
| ExpressPaymentMethodConfigInstance
|
| 95 |
) => {
|
| 96 |
availablePaymentMethods = {
|
| 97 |
...availablePaymentMethods,
|
| 116 |
)
|
| 117 |
);
|
| 118 |
|
| 119 |
+
if ( canPay ) {
|
| 120 |
if (
|
| 121 |
typeof canPay === 'object' &&
|
| 122 |
canPay !== null &&
|
| 161 |
registeredPaymentMethods,
|
| 162 |
] );
|
| 163 |
|
| 164 |
+
const [ debouncedRefreshCanMakePayments ] = useDebouncedCallback(
|
| 165 |
+
refreshCanMakePayments,
|
| 166 |
+
500
|
| 167 |
+
);
|
| 168 |
+
|
| 169 |
// Determine which payment methods are available initially and whenever
|
| 170 |
+
// shipping methods, cart or the billing data change.
|
| 171 |
// Some payment methods (e.g. COD) can be disabled for specific shipping methods.
|
| 172 |
useEffect( () => {
|
| 173 |
+
debouncedRefreshCanMakePayments();
|
| 174 |
}, [
|
| 175 |
+
debouncedRefreshCanMakePayments,
|
| 176 |
+
cart,
|
| 177 |
selectedShippingMethods,
|
| 178 |
+
billingData,
|
| 179 |
] );
|
| 180 |
|
| 181 |
return isInitialized;
|
assets/js/base/context/providers/validation/components/validation-input-error/style.scss
CHANGED
|
@@ -2,15 +2,10 @@
|
|
| 2 |
@include font-size(smaller);
|
| 3 |
color: $alert-red;
|
| 4 |
max-width: 100%;
|
| 5 |
-
position: absolute;
|
| 6 |
white-space: normal;
|
| 7 |
|
| 8 |
> p {
|
| 9 |
-
align-items: center;
|
| 10 |
-
display: flex;
|
| 11 |
-
line-height: 12px; // This allows two lines in a 24px bottom margin.
|
| 12 |
margin: 0;
|
| 13 |
-
min-height: 24px;
|
| 14 |
padding: 0;
|
| 15 |
}
|
| 16 |
}
|
| 2 |
@include font-size(smaller);
|
| 3 |
color: $alert-red;
|
| 4 |
max-width: 100%;
|
|
|
|
| 5 |
white-space: normal;
|
| 6 |
|
| 7 |
> p {
|
|
|
|
|
|
|
|
|
|
| 8 |
margin: 0;
|
|
|
|
| 9 |
padding: 0;
|
| 10 |
}
|
| 11 |
}
|
assets/js/base/utils/legacy-events.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
| 1 |
-
const Event = window.Event || null;
|
| 2 |
-
|
| 3 |
-
/** @typedef {import('window').HTMLNode} HTMLNode */
|
| 4 |
-
|
| 5 |
-
/**
|
| 6 |
-
* Wrapper function to dispatch an event so it's compatible with IE11.
|
| 7 |
-
*
|
| 8 |
-
* @param {string} name Name of the event to dispatch.
|
| 9 |
-
* @param {Object} [options] Some additional options to modify
|
| 10 |
-
* the event.
|
| 11 |
-
* @param {boolean} [options.bubbles] Whether the event bubbles.
|
| 12 |
-
* @param {boolean} [options.cancelable] Whether the event is cancelable.
|
| 13 |
-
* @param {HTMLNode} [options.element] Element that dispatches the event. By
|
| 14 |
-
* default, the body.
|
| 15 |
-
*/
|
| 16 |
-
export const dispatchEvent = (
|
| 17 |
-
name,
|
| 18 |
-
{ bubbles = false, cancelable = false, element }
|
| 19 |
-
) => {
|
| 20 |
-
if ( ! element ) {
|
| 21 |
-
element = document.body;
|
| 22 |
-
}
|
| 23 |
-
// In IE, Event is an object and can't be instantiated with `new Event()`.
|
| 24 |
-
if ( typeof Event === 'function' ) {
|
| 25 |
-
const event = new Event( name, {
|
| 26 |
-
bubbles,
|
| 27 |
-
cancelable,
|
| 28 |
-
} );
|
| 29 |
-
element.dispatchEvent( event );
|
| 30 |
-
} else {
|
| 31 |
-
const event = document.createEvent( 'Event' );
|
| 32 |
-
event.initEvent( name, bubbles, cancelable );
|
| 33 |
-
element.dispatchEvent( event );
|
| 34 |
-
}
|
| 35 |
-
};
|
| 36 |
-
|
| 37 |
-
let fragmentRequestTimeoutId;
|
| 38 |
-
|
| 39 |
-
// This is a hack to trigger cart updates till we migrate to block based cart
|
| 40 |
-
// that relies on the store, see
|
| 41 |
-
// https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues/1247
|
| 42 |
-
export const triggerFragmentRefresh = () => {
|
| 43 |
-
if ( fragmentRequestTimeoutId ) {
|
| 44 |
-
clearTimeout( fragmentRequestTimeoutId );
|
| 45 |
-
}
|
| 46 |
-
fragmentRequestTimeoutId = setTimeout( () => {
|
| 47 |
-
dispatchEvent( 'wc_fragment_refresh', {
|
| 48 |
-
bubbles: true,
|
| 49 |
-
cancelable: true,
|
| 50 |
-
} );
|
| 51 |
-
}, 50 );
|
| 52 |
-
};
|
| 53 |
-
|
| 54 |
-
/**
|
| 55 |
-
* Function that listens to a jQuery event and dispatches a native JS event.
|
| 56 |
-
* Useful to convert WC Core events into events that can be read by blocks.
|
| 57 |
-
*
|
| 58 |
-
* @param {string} jQueryEventName Name of the jQuery event to listen to.
|
| 59 |
-
* @param {string} nativeEventName Name of the native event to dispatch.
|
| 60 |
-
* @param {boolean} bubbles Whether the event bubbles.
|
| 61 |
-
* @param {boolean} cancelable Whether the event is cancelable.
|
| 62 |
-
*
|
| 63 |
-
* @return {Function} Function to remove the jQuery event handler. Ideally it
|
| 64 |
-
* should be used when the component is unmounted.
|
| 65 |
-
*/
|
| 66 |
-
export const translateJQueryEventToNative = (
|
| 67 |
-
jQueryEventName,
|
| 68 |
-
nativeEventName,
|
| 69 |
-
bubbles = false,
|
| 70 |
-
cancelable = false
|
| 71 |
-
) => {
|
| 72 |
-
// @ts-ignore -- jQuery is window global
|
| 73 |
-
if ( typeof jQuery !== 'function' ) {
|
| 74 |
-
return () => void null;
|
| 75 |
-
}
|
| 76 |
-
|
| 77 |
-
const eventDispatcher = () => {
|
| 78 |
-
dispatchEvent( nativeEventName, { bubbles, cancelable } );
|
| 79 |
-
};
|
| 80 |
-
|
| 81 |
-
// @ts-ignore -- jQuery is window global
|
| 82 |
-
jQuery( document ).on( jQueryEventName, eventDispatcher );
|
| 83 |
-
// @ts-ignore -- jQuery is window global
|
| 84 |
-
return () => jQuery( document ).off( jQueryEventName, eventDispatcher );
|
| 85 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/base/utils/legacy-events.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import type { AddToCartEventDetail } from '@woocommerce/type-defs/events';
|
| 5 |
+
|
| 6 |
+
const CustomEvent = window.CustomEvent || null;
|
| 7 |
+
|
| 8 |
+
interface DispatchedEventProperties {
|
| 9 |
+
// Whether the event bubbles.
|
| 10 |
+
bubbles?: boolean;
|
| 11 |
+
// Whether the event is cancelable.
|
| 12 |
+
cancelable?: boolean;
|
| 13 |
+
// See https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/detail
|
| 14 |
+
detail?: unknown;
|
| 15 |
+
// Element that dispatches the event. By default, the body.
|
| 16 |
+
element?: Element | null;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Wrapper function to dispatch an event.
|
| 21 |
+
*/
|
| 22 |
+
export const dispatchEvent = (
|
| 23 |
+
name: string,
|
| 24 |
+
{
|
| 25 |
+
bubbles = false,
|
| 26 |
+
cancelable = false,
|
| 27 |
+
element,
|
| 28 |
+
detail = {},
|
| 29 |
+
}: DispatchedEventProperties
|
| 30 |
+
): void => {
|
| 31 |
+
if ( ! CustomEvent ) {
|
| 32 |
+
return;
|
| 33 |
+
}
|
| 34 |
+
if ( ! element ) {
|
| 35 |
+
element = document.body;
|
| 36 |
+
}
|
| 37 |
+
const event = new CustomEvent( name, {
|
| 38 |
+
bubbles,
|
| 39 |
+
cancelable,
|
| 40 |
+
detail,
|
| 41 |
+
} );
|
| 42 |
+
element.dispatchEvent( event );
|
| 43 |
+
};
|
| 44 |
+
|
| 45 |
+
let fragmentRequestTimeoutId: ReturnType< typeof setTimeout >;
|
| 46 |
+
|
| 47 |
+
// This is a hack to trigger cart updates till we migrate to block based cart
|
| 48 |
+
// that relies on the store, see
|
| 49 |
+
// https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues/1247
|
| 50 |
+
export const triggerFragmentRefresh = (): void => {
|
| 51 |
+
if ( fragmentRequestTimeoutId ) {
|
| 52 |
+
clearTimeout( fragmentRequestTimeoutId );
|
| 53 |
+
}
|
| 54 |
+
fragmentRequestTimeoutId = setTimeout( () => {
|
| 55 |
+
dispatchEvent( 'wc_fragment_refresh', {
|
| 56 |
+
bubbles: true,
|
| 57 |
+
cancelable: true,
|
| 58 |
+
} );
|
| 59 |
+
}, 50 );
|
| 60 |
+
};
|
| 61 |
+
|
| 62 |
+
export const triggerAddingToCartEvent = (): void => {
|
| 63 |
+
dispatchEvent( 'wc-blocks_adding_to_cart', {
|
| 64 |
+
bubbles: true,
|
| 65 |
+
cancelable: true,
|
| 66 |
+
} );
|
| 67 |
+
};
|
| 68 |
+
|
| 69 |
+
export const triggerAddedToCartEvent = ( {
|
| 70 |
+
preserveCartData = false,
|
| 71 |
+
}: AddToCartEventDetail ): void => {
|
| 72 |
+
dispatchEvent( 'wc-blocks_added_to_cart', {
|
| 73 |
+
bubbles: true,
|
| 74 |
+
cancelable: true,
|
| 75 |
+
detail: { preserveCartData },
|
| 76 |
+
} );
|
| 77 |
+
};
|
| 78 |
+
|
| 79 |
+
/**
|
| 80 |
+
* Function that listens to a jQuery event and dispatches a native JS event.
|
| 81 |
+
* Useful to convert WC Core events into events that can be read by blocks.
|
| 82 |
+
*
|
| 83 |
+
* Returns a function to remove the jQuery event handler. Ideally it should be
|
| 84 |
+
* used when the component is unmounted.
|
| 85 |
+
*/
|
| 86 |
+
export const translateJQueryEventToNative = (
|
| 87 |
+
// Name of the jQuery event to listen to.
|
| 88 |
+
jQueryEventName: string,
|
| 89 |
+
// Name of the native event to dispatch.
|
| 90 |
+
nativeEventName: string,
|
| 91 |
+
// Whether the event bubbles.
|
| 92 |
+
bubbles = false,
|
| 93 |
+
// Whether the event is cancelable.
|
| 94 |
+
cancelable = false
|
| 95 |
+
): ( () => void ) => {
|
| 96 |
+
if ( typeof jQuery !== 'function' ) {
|
| 97 |
+
return () => void null;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
const eventDispatcher = () => {
|
| 101 |
+
dispatchEvent( nativeEventName, { bubbles, cancelable } );
|
| 102 |
+
};
|
| 103 |
+
|
| 104 |
+
jQuery( document ).on( jQueryEventName, eventDispatcher );
|
| 105 |
+
return () => jQuery( document ).off( jQueryEventName, eventDispatcher );
|
| 106 |
+
};
|
assets/js/blocks-registry/payment-methods/{assertions.js → assertions.ts}
RENAMED
|
@@ -2,11 +2,16 @@
|
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import { isValidElement } from '@wordpress/element';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
export const assertValidPaymentMethodComponent = (
|
| 7 |
-
component,
|
| 8 |
-
componentName
|
| 9 |
-
) => {
|
| 10 |
if ( typeof component !== 'function' ) {
|
| 11 |
throw new TypeError(
|
| 12 |
`The ${ componentName } property for the payment method must be a functional component`
|
|
@@ -14,7 +19,10 @@ export const assertValidPaymentMethodComponent = (
|
|
| 14 |
}
|
| 15 |
};
|
| 16 |
|
| 17 |
-
export const assertValidElement = (
|
|
|
|
|
|
|
|
|
|
| 18 |
if ( element !== null && ! isValidElement( element ) ) {
|
| 19 |
throw new TypeError(
|
| 20 |
`The ${ elementName } property for the payment method must be a React element or null.`
|
|
@@ -22,7 +30,10 @@ export const assertValidElement = ( element, elementName ) => {
|
|
| 22 |
}
|
| 23 |
};
|
| 24 |
|
| 25 |
-
export const assertValidElementOrString = (
|
|
|
|
|
|
|
|
|
|
| 26 |
if (
|
| 27 |
element !== null &&
|
| 28 |
! isValidElement( element ) &&
|
|
@@ -35,15 +46,18 @@ export const assertValidElementOrString = ( element, elementName ) => {
|
|
| 35 |
};
|
| 36 |
|
| 37 |
export const assertConfigHasProperties = (
|
| 38 |
-
config,
|
| 39 |
-
expectedProperties = []
|
| 40 |
-
) => {
|
| 41 |
-
const missingProperties = expectedProperties.reduce(
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
| 47 |
if ( missingProperties.length > 0 ) {
|
| 48 |
const message =
|
| 49 |
'The payment method configuration object is missing the following properties:';
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import { isValidElement } from '@wordpress/element';
|
| 5 |
+
import type { ReactNode } from 'react';
|
| 6 |
+
import type {
|
| 7 |
+
PaymentMethodConfiguration,
|
| 8 |
+
ExpressPaymentMethodConfiguration,
|
| 9 |
+
} from '@woocommerce/type-defs/payments';
|
| 10 |
|
| 11 |
export const assertValidPaymentMethodComponent = (
|
| 12 |
+
component: () => unknown,
|
| 13 |
+
componentName: string
|
| 14 |
+
): void => {
|
| 15 |
if ( typeof component !== 'function' ) {
|
| 16 |
throw new TypeError(
|
| 17 |
`The ${ componentName } property for the payment method must be a functional component`
|
| 19 |
}
|
| 20 |
};
|
| 21 |
|
| 22 |
+
export const assertValidElement = (
|
| 23 |
+
element: ReactNode,
|
| 24 |
+
elementName: string
|
| 25 |
+
): void => {
|
| 26 |
if ( element !== null && ! isValidElement( element ) ) {
|
| 27 |
throw new TypeError(
|
| 28 |
`The ${ elementName } property for the payment method must be a React element or null.`
|
| 30 |
}
|
| 31 |
};
|
| 32 |
|
| 33 |
+
export const assertValidElementOrString = (
|
| 34 |
+
element: ReactNode,
|
| 35 |
+
elementName: string
|
| 36 |
+
): void => {
|
| 37 |
if (
|
| 38 |
element !== null &&
|
| 39 |
! isValidElement( element ) &&
|
| 46 |
};
|
| 47 |
|
| 48 |
export const assertConfigHasProperties = (
|
| 49 |
+
config: ExpressPaymentMethodConfiguration | PaymentMethodConfiguration,
|
| 50 |
+
expectedProperties: string[] = []
|
| 51 |
+
): void => {
|
| 52 |
+
const missingProperties = expectedProperties.reduce(
|
| 53 |
+
( acc: string[], property: string ) => {
|
| 54 |
+
if ( ! config.hasOwnProperty( property ) ) {
|
| 55 |
+
acc.push( property );
|
| 56 |
+
}
|
| 57 |
+
return acc;
|
| 58 |
+
},
|
| 59 |
+
[]
|
| 60 |
+
);
|
| 61 |
if ( missingProperties.length > 0 ) {
|
| 62 |
const message =
|
| 63 |
'The payment method configuration object is missing the following properties:';
|
assets/js/blocks-registry/payment-methods/{express-payment-method-config.js → express-payment-method-config.ts}
RENAMED
|
@@ -1,11 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
/**
|
| 2 |
* Internal dependencies
|
| 3 |
*/
|
|
|
|
| 4 |
import { assertConfigHasProperties, assertValidElement } from './assertions';
|
| 5 |
-
import { canMakePaymentWithFeaturesCheck } from './payment-method-config-helper';
|
| 6 |
|
| 7 |
-
export default class ExpressPaymentMethodConfig
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
// validate config
|
| 10 |
ExpressPaymentMethodConfig.assertValidConfig( config );
|
| 11 |
this.name = config.name;
|
|
@@ -15,13 +34,21 @@ export default class ExpressPaymentMethodConfig {
|
|
| 15 |
this.supports = {
|
| 16 |
features: config?.supports?.features || [ 'products' ],
|
| 17 |
};
|
| 18 |
-
this.
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
);
|
| 22 |
}
|
| 23 |
|
| 24 |
-
static assertValidConfig = (
|
|
|
|
|
|
|
| 25 |
assertConfigHasProperties( config, [ 'name', 'content', 'edit' ] );
|
| 26 |
if ( typeof config.name !== 'string' ) {
|
| 27 |
throw new TypeError(
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import type { ReactNode } from 'react';
|
| 5 |
+
import type {
|
| 6 |
+
ExpressPaymentMethodConfiguration,
|
| 7 |
+
Supports,
|
| 8 |
+
CanMakePaymentCallback,
|
| 9 |
+
ExpressPaymentMethodConfigInstance,
|
| 10 |
+
} from '@woocommerce/type-defs/payments';
|
| 11 |
+
|
| 12 |
/**
|
| 13 |
* Internal dependencies
|
| 14 |
*/
|
| 15 |
+
import { getCanMakePayment } from './payment-method-config-helper';
|
| 16 |
import { assertConfigHasProperties, assertValidElement } from './assertions';
|
|
|
|
| 17 |
|
| 18 |
+
export default class ExpressPaymentMethodConfig
|
| 19 |
+
implements ExpressPaymentMethodConfigInstance {
|
| 20 |
+
public name: string;
|
| 21 |
+
public content: ReactNode;
|
| 22 |
+
public edit: ReactNode;
|
| 23 |
+
public paymentMethodId?: string;
|
| 24 |
+
public supports: Supports;
|
| 25 |
+
public canMakePaymentFromConfig: CanMakePaymentCallback;
|
| 26 |
+
|
| 27 |
+
constructor( config: ExpressPaymentMethodConfiguration ) {
|
| 28 |
// validate config
|
| 29 |
ExpressPaymentMethodConfig.assertValidConfig( config );
|
| 30 |
this.name = config.name;
|
| 34 |
this.supports = {
|
| 35 |
features: config?.supports?.features || [ 'products' ],
|
| 36 |
};
|
| 37 |
+
this.canMakePaymentFromConfig = config.canMakePayment;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
// canMakePayment is calculated each time based on data that modifies outside of the class (eg: cart data).
|
| 41 |
+
get canMakePayment(): CanMakePaymentCallback {
|
| 42 |
+
return getCanMakePayment(
|
| 43 |
+
this.canMakePaymentFromConfig,
|
| 44 |
+
this.supports.features,
|
| 45 |
+
this.name
|
| 46 |
);
|
| 47 |
}
|
| 48 |
|
| 49 |
+
static assertValidConfig = (
|
| 50 |
+
config: ExpressPaymentMethodConfiguration
|
| 51 |
+
): void => {
|
| 52 |
assertConfigHasProperties( config, [ 'name', 'content', 'edit' ] );
|
| 53 |
if ( typeof config.name !== 'string' ) {
|
| 54 |
throw new TypeError(
|
assets/js/blocks-registry/payment-methods/extensions-config.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
| 1 |
-
// Keeps callbacks registered by extensions for different payment methods
|
| 2 |
-
/* eslint prefer-const: 0 */
|
| 3 |
-
export let canMakePaymentExtensionsCallbacks = {};
|
| 4 |
-
|
| 5 |
-
export const extensionsConfig = {
|
| 6 |
-
canMakePayment: canMakePaymentExtensionsCallbacks,
|
| 7 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks-registry/payment-methods/extensions-config.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { CanMakePaymentExtensionCallback } from '@woocommerce/type-defs/payments';
|
| 5 |
+
|
| 6 |
+
type CanMakePaymentExtensionCallbacks = Record<
|
| 7 |
+
string,
|
| 8 |
+
CanMakePaymentExtensionCallback
|
| 9 |
+
>;
|
| 10 |
+
export type NamespacedCanMakePaymentExtensionsCallbacks = Record<
|
| 11 |
+
string,
|
| 12 |
+
CanMakePaymentExtensionCallbacks
|
| 13 |
+
>;
|
| 14 |
+
export type ExtensionNamespace = keyof NamespacedCanMakePaymentExtensionsCallbacks;
|
| 15 |
+
export type PaymentMethodName = keyof CanMakePaymentExtensionCallbacks;
|
| 16 |
+
|
| 17 |
+
// Keeps callbacks registered by extensions for different payment methods
|
| 18 |
+
// eslint-disable-next-line prefer-const
|
| 19 |
+
export const canMakePaymentExtensionsCallbacks: NamespacedCanMakePaymentExtensionsCallbacks = {};
|
| 20 |
+
|
| 21 |
+
export const extensionsConfig = {
|
| 22 |
+
canMakePayment: canMakePaymentExtensionsCallbacks,
|
| 23 |
+
};
|
assets/js/blocks-registry/payment-methods/{index.js → index.ts}
RENAMED
|
File without changes
|
assets/js/blocks-registry/payment-methods/payment-method-config-helper.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
| 1 |
-
// Filter out payment methods by supported features and cart requirement.
|
| 2 |
-
export const canMakePaymentWithFeaturesCheck = ( canMakePayment, features ) => (
|
| 3 |
-
canPayArgument
|
| 4 |
-
) => {
|
| 5 |
-
const requirements = canPayArgument.paymentRequirements || [];
|
| 6 |
-
const featuresSupportRequirements = requirements.every( ( requirement ) =>
|
| 7 |
-
features.includes( requirement )
|
| 8 |
-
);
|
| 9 |
-
return featuresSupportRequirements && canMakePayment( canPayArgument );
|
| 10 |
-
};
|
| 11 |
-
|
| 12 |
-
// Filter out payment methods by callbacks registered by extensions.
|
| 13 |
-
export const canMakePaymentWithExtensions = (
|
| 14 |
-
canMakePayment,
|
| 15 |
-
extensionsCallbacks,
|
| 16 |
-
paymentMethodName
|
| 17 |
-
) => ( canPayArgument ) => {
|
| 18 |
-
// Validate whether the payment method is available based on its own criteria first.
|
| 19 |
-
let canPay = canMakePayment( canPayArgument );
|
| 20 |
-
|
| 21 |
-
if ( canPay ) {
|
| 22 |
-
const namespacedCallbacks = {};
|
| 23 |
-
Object.entries( extensionsCallbacks ).forEach(
|
| 24 |
-
( [ namespace, callbacks ] ) => {
|
| 25 |
-
if ( typeof callbacks[ paymentMethodName ] === 'function' ) {
|
| 26 |
-
namespacedCallbacks[ namespace ] =
|
| 27 |
-
callbacks[ paymentMethodName ];
|
| 28 |
-
}
|
| 29 |
-
}
|
| 30 |
-
);
|
| 31 |
-
canPay = Object.keys( namespacedCallbacks ).every( ( namespace ) => {
|
| 32 |
-
try {
|
| 33 |
-
return namespacedCallbacks[ namespace ]( canPayArgument );
|
| 34 |
-
} catch ( err ) {
|
| 35 |
-
// eslint-disable-next-line no-console
|
| 36 |
-
console.error(
|
| 37 |
-
`Error when executing callback for ${ paymentMethodName } in ${ namespace }`,
|
| 38 |
-
err
|
| 39 |
-
);
|
| 40 |
-
// every expects a return value at the end of every arrow function and
|
| 41 |
-
// this ensures that the error is ignored when computing the whole result.
|
| 42 |
-
return true;
|
| 43 |
-
}
|
| 44 |
-
} );
|
| 45 |
-
}
|
| 46 |
-
|
| 47 |
-
return canPay;
|
| 48 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks-registry/payment-methods/payment-method-config-helper.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import type {
|
| 5 |
+
CanMakePaymentCallback,
|
| 6 |
+
CanMakePaymentExtensionCallback,
|
| 7 |
+
} from '@woocommerce/type-defs/payments';
|
| 8 |
+
|
| 9 |
+
/**
|
| 10 |
+
* Internal dependencies
|
| 11 |
+
*/
|
| 12 |
+
import {
|
| 13 |
+
NamespacedCanMakePaymentExtensionsCallbacks,
|
| 14 |
+
PaymentMethodName,
|
| 15 |
+
ExtensionNamespace,
|
| 16 |
+
extensionsConfig,
|
| 17 |
+
} from './extensions-config';
|
| 18 |
+
|
| 19 |
+
// Filter out payment methods by supported features and cart requirement.
|
| 20 |
+
export const canMakePaymentWithFeaturesCheck = (
|
| 21 |
+
canMakePayment: CanMakePaymentCallback,
|
| 22 |
+
features: string[]
|
| 23 |
+
): CanMakePaymentCallback => ( canPayArgument ) => {
|
| 24 |
+
const requirements = canPayArgument?.paymentRequirements || [];
|
| 25 |
+
const featuresSupportRequirements = requirements.every( ( requirement ) =>
|
| 26 |
+
features.includes( requirement )
|
| 27 |
+
);
|
| 28 |
+
return featuresSupportRequirements && canMakePayment( canPayArgument );
|
| 29 |
+
};
|
| 30 |
+
|
| 31 |
+
// Filter out payment methods by callbacks registered by extensions.
|
| 32 |
+
export const canMakePaymentWithExtensions = (
|
| 33 |
+
canMakePayment: CanMakePaymentCallback,
|
| 34 |
+
extensionsCallbacks: NamespacedCanMakePaymentExtensionsCallbacks,
|
| 35 |
+
paymentMethodName: PaymentMethodName
|
| 36 |
+
): CanMakePaymentCallback => ( canPayArgument ) => {
|
| 37 |
+
// Validate whether the payment method is available based on its own criteria first.
|
| 38 |
+
let canPay = canMakePayment( canPayArgument );
|
| 39 |
+
|
| 40 |
+
if ( canPay ) {
|
| 41 |
+
// Gather all callbacks for paymentMethodName.
|
| 42 |
+
const namespacedCallbacks: Record<
|
| 43 |
+
ExtensionNamespace,
|
| 44 |
+
CanMakePaymentExtensionCallback
|
| 45 |
+
> = {};
|
| 46 |
+
|
| 47 |
+
Object.entries( extensionsCallbacks ).forEach(
|
| 48 |
+
( [ namespace, callbacks ] ) => {
|
| 49 |
+
namespacedCallbacks[ namespace ] =
|
| 50 |
+
callbacks[ paymentMethodName ];
|
| 51 |
+
}
|
| 52 |
+
);
|
| 53 |
+
|
| 54 |
+
canPay = Object.keys( namespacedCallbacks ).every( ( namespace ) => {
|
| 55 |
+
try {
|
| 56 |
+
return namespacedCallbacks[ namespace ]( canPayArgument );
|
| 57 |
+
} catch ( err ) {
|
| 58 |
+
// eslint-disable-next-line no-console
|
| 59 |
+
console.error(
|
| 60 |
+
`Error when executing callback for ${ paymentMethodName } in ${ namespace }`,
|
| 61 |
+
err
|
| 62 |
+
);
|
| 63 |
+
// .every() expects a return value at the end of every arrow function and
|
| 64 |
+
// this ensures that the error is ignored when computing the whole result.
|
| 65 |
+
return true;
|
| 66 |
+
}
|
| 67 |
+
} );
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
return canPay;
|
| 71 |
+
};
|
| 72 |
+
|
| 73 |
+
export const getCanMakePayment = (
|
| 74 |
+
canMakePayment: CanMakePaymentCallback,
|
| 75 |
+
features: string[],
|
| 76 |
+
paymentMethodName: string
|
| 77 |
+
): CanMakePaymentCallback => {
|
| 78 |
+
const canPay = canMakePaymentWithFeaturesCheck( canMakePayment, features );
|
| 79 |
+
// Loop through all callbacks to check if there are any registered for this payment method.
|
| 80 |
+
return ( Object.values( extensionsConfig.canMakePayment ) as Record<
|
| 81 |
+
PaymentMethodName,
|
| 82 |
+
CanMakePaymentCallback
|
| 83 |
+
>[] ).some( ( callbacks ) => paymentMethodName in callbacks )
|
| 84 |
+
? canMakePaymentWithExtensions(
|
| 85 |
+
canPay,
|
| 86 |
+
extensionsConfig.canMakePayment,
|
| 87 |
+
paymentMethodName
|
| 88 |
+
)
|
| 89 |
+
: canPay;
|
| 90 |
+
};
|
assets/js/blocks-registry/payment-methods/{payment-method-config.js → payment-method-config.tsx}
RENAMED
|
@@ -2,27 +2,44 @@
|
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import deprecated from '@wordpress/deprecated';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
/**
|
| 7 |
* Internal dependencies
|
| 8 |
*/
|
|
|
|
| 9 |
import {
|
| 10 |
assertConfigHasProperties,
|
| 11 |
assertValidElement,
|
| 12 |
assertValidElementOrString,
|
| 13 |
} from './assertions';
|
| 14 |
|
| 15 |
-
import {
|
| 16 |
-
canMakePaymentWithFeaturesCheck,
|
| 17 |
-
canMakePaymentWithExtensions,
|
| 18 |
-
} from './payment-method-config-helper';
|
| 19 |
-
import { extensionsConfig } from './extensions-config';
|
| 20 |
const NullComponent = () => {
|
| 21 |
return null;
|
| 22 |
};
|
| 23 |
|
| 24 |
-
export default class PaymentMethodConfig
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
// validate config
|
| 27 |
PaymentMethodConfig.assertValidConfig( config );
|
| 28 |
this.name = config.name;
|
|
@@ -31,7 +48,7 @@ export default class PaymentMethodConfig {
|
|
| 31 |
this.ariaLabel = config.ariaLabel;
|
| 32 |
this.content = config.content;
|
| 33 |
this.savedTokenComponent = config.savedTokenComponent;
|
| 34 |
-
this.icons = config.icons;
|
| 35 |
this.edit = config.edit;
|
| 36 |
this.paymentMethodId = config.paymentMethodId || this.name;
|
| 37 |
this.supports = {
|
|
@@ -46,24 +63,15 @@ export default class PaymentMethodConfig {
|
|
| 46 |
}
|
| 47 |
|
| 48 |
// canMakePayment is calculated each time based on data that modifies outside of the class (eg: cart data).
|
| 49 |
-
get canMakePayment() {
|
| 50 |
-
|
| 51 |
this.canMakePaymentFromConfig,
|
| 52 |
-
this.supports.features
|
|
|
|
| 53 |
);
|
| 54 |
-
// Loop through all callbacks to check if there are any registered for this payment method.
|
| 55 |
-
return Object.values( extensionsConfig.canMakePayment ).some(
|
| 56 |
-
( callbacks ) => this.name in callbacks
|
| 57 |
-
)
|
| 58 |
-
? canMakePaymentWithExtensions(
|
| 59 |
-
canPay,
|
| 60 |
-
extensionsConfig.canMakePayment,
|
| 61 |
-
this.name
|
| 62 |
-
)
|
| 63 |
-
: canPay;
|
| 64 |
}
|
| 65 |
|
| 66 |
-
static assertValidConfig = ( config ) => {
|
| 67 |
// set default for optional
|
| 68 |
config.savedTokenComponent = config.savedTokenComponent || (
|
| 69 |
<NullComponent />
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import deprecated from '@wordpress/deprecated';
|
| 5 |
+
import type { ReactNode } from 'react';
|
| 6 |
+
import type {
|
| 7 |
+
PaymentMethodConfiguration,
|
| 8 |
+
Supports,
|
| 9 |
+
CanMakePaymentCallback,
|
| 10 |
+
PaymentMethodConfigInstance,
|
| 11 |
+
PaymentMethodIcons,
|
| 12 |
+
} from '@woocommerce/type-defs/payments';
|
| 13 |
|
| 14 |
/**
|
| 15 |
* Internal dependencies
|
| 16 |
*/
|
| 17 |
+
import { getCanMakePayment } from './payment-method-config-helper';
|
| 18 |
import {
|
| 19 |
assertConfigHasProperties,
|
| 20 |
assertValidElement,
|
| 21 |
assertValidElementOrString,
|
| 22 |
} from './assertions';
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
const NullComponent = () => {
|
| 25 |
return null;
|
| 26 |
};
|
| 27 |
|
| 28 |
+
export default class PaymentMethodConfig
|
| 29 |
+
implements PaymentMethodConfigInstance {
|
| 30 |
+
public name: string;
|
| 31 |
+
public content: ReactNode;
|
| 32 |
+
public edit: ReactNode;
|
| 33 |
+
public paymentMethodId?: string;
|
| 34 |
+
public supports: Supports;
|
| 35 |
+
public icons: null | PaymentMethodIcons;
|
| 36 |
+
public label: ReactNode;
|
| 37 |
+
public ariaLabel: string;
|
| 38 |
+
public placeOrderButtonLabel?: string;
|
| 39 |
+
public savedTokenComponent?: ReactNode | null;
|
| 40 |
+
public canMakePaymentFromConfig: CanMakePaymentCallback;
|
| 41 |
+
|
| 42 |
+
constructor( config: PaymentMethodConfiguration ) {
|
| 43 |
// validate config
|
| 44 |
PaymentMethodConfig.assertValidConfig( config );
|
| 45 |
this.name = config.name;
|
| 48 |
this.ariaLabel = config.ariaLabel;
|
| 49 |
this.content = config.content;
|
| 50 |
this.savedTokenComponent = config.savedTokenComponent;
|
| 51 |
+
this.icons = config.icons || null;
|
| 52 |
this.edit = config.edit;
|
| 53 |
this.paymentMethodId = config.paymentMethodId || this.name;
|
| 54 |
this.supports = {
|
| 63 |
}
|
| 64 |
|
| 65 |
// canMakePayment is calculated each time based on data that modifies outside of the class (eg: cart data).
|
| 66 |
+
get canMakePayment(): CanMakePaymentCallback {
|
| 67 |
+
return getCanMakePayment(
|
| 68 |
this.canMakePaymentFromConfig,
|
| 69 |
+
this.supports.features,
|
| 70 |
+
this.name
|
| 71 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
}
|
| 73 |
|
| 74 |
+
static assertValidConfig = ( config: PaymentMethodConfiguration ): void => {
|
| 75 |
// set default for optional
|
| 76 |
config.savedTokenComponent = config.savedTokenComponent || (
|
| 77 |
<NullComponent />
|
assets/js/blocks-registry/payment-methods/{registry.js → registry.ts}
RENAMED
|
@@ -1,12 +1,15 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* @typedef {import('@woocommerce/type-defs/payments').PaymentMethodRegistrationOptions} PaymentMethodRegistrationOptions
|
| 3 |
-
* @typedef {import('@woocommerce/type-defs/payments').ExpressPaymentMethodRegistrationOptions} ExpressPaymentMethodRegistrationOptions
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
/**
|
| 7 |
* External dependencies
|
| 8 |
*/
|
| 9 |
import deprecated from '@wordpress/deprecated';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
/**
|
| 12 |
* Internal dependencies
|
|
@@ -14,16 +17,20 @@ import deprecated from '@wordpress/deprecated';
|
|
| 14 |
import { default as PaymentMethodConfig } from './payment-method-config';
|
| 15 |
import { default as ExpressPaymentMethodConfig } from './express-payment-method-config';
|
| 16 |
import { canMakePaymentExtensionsCallbacks } from './extensions-config';
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
/**
|
| 21 |
* Register a regular payment method.
|
| 22 |
-
*
|
| 23 |
-
* @param {PaymentMethodRegistrationOptions} options Configuration options for the payment method.
|
| 24 |
*/
|
| 25 |
-
export const registerPaymentMethod = (
|
| 26 |
-
|
|
|
|
|
|
|
| 27 |
if ( typeof options === 'function' ) {
|
| 28 |
// Legacy fallback for previous API, where client passes a function:
|
| 29 |
// registerPaymentMethod( ( Config ) => new Config( options ) );
|
|
@@ -44,10 +51,12 @@ export const registerPaymentMethod = ( options ) => {
|
|
| 44 |
|
| 45 |
/**
|
| 46 |
* Register an express payment method.
|
| 47 |
-
*
|
| 48 |
-
* @param {ExpressPaymentMethodRegistrationOptions} options Configuration options for the payment method.
|
| 49 |
*/
|
| 50 |
-
export const registerExpressPaymentMethod = (
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
let paymentMethodConfig;
|
| 52 |
if ( typeof options === 'function' ) {
|
| 53 |
// Legacy fallback for previous API, where client passes a function:
|
|
@@ -69,14 +78,11 @@ export const registerExpressPaymentMethod = ( options ) => {
|
|
| 69 |
|
| 70 |
/**
|
| 71 |
* Allows extension to register callbacks for specific payment methods to determine if they can make payments
|
| 72 |
-
*
|
| 73 |
-
* @param {string} namespace A unique string to identify the extension registering payment method callbacks.
|
| 74 |
-
* @param {Record<string, function():any>} callbacks Example {stripe: () => {}, cheque: => {}}
|
| 75 |
*/
|
| 76 |
export const registerPaymentMethodExtensionCallbacks = (
|
| 77 |
-
namespace,
|
| 78 |
-
callbacks
|
| 79 |
-
) => {
|
| 80 |
if ( canMakePaymentExtensionsCallbacks[ namespace ] ) {
|
| 81 |
// eslint-disable-next-line no-console
|
| 82 |
console.error(
|
|
@@ -103,20 +109,22 @@ export const registerPaymentMethodExtensionCallbacks = (
|
|
| 103 |
}
|
| 104 |
};
|
| 105 |
|
| 106 |
-
export const __experimentalDeRegisterPaymentMethod = (
|
|
|
|
|
|
|
| 107 |
delete paymentMethods[ paymentMethodName ];
|
| 108 |
};
|
| 109 |
|
| 110 |
export const __experimentalDeRegisterExpressPaymentMethod = (
|
| 111 |
-
paymentMethodName
|
| 112 |
-
) => {
|
| 113 |
delete expressPaymentMethods[ paymentMethodName ];
|
| 114 |
};
|
| 115 |
|
| 116 |
-
export const getPaymentMethods = () => {
|
| 117 |
return paymentMethods;
|
| 118 |
};
|
| 119 |
|
| 120 |
-
export const getExpressPaymentMethods = () => {
|
| 121 |
return expressPaymentMethods;
|
| 122 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
/**
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import deprecated from '@wordpress/deprecated';
|
| 5 |
+
import type {
|
| 6 |
+
PaymentMethodConfiguration,
|
| 7 |
+
ExpressPaymentMethodConfiguration,
|
| 8 |
+
CanMakePaymentExtensionCallback,
|
| 9 |
+
PaymentMethodConfigInstance,
|
| 10 |
+
PaymentMethods,
|
| 11 |
+
ExpressPaymentMethods,
|
| 12 |
+
} from '@woocommerce/type-defs/payments';
|
| 13 |
|
| 14 |
/**
|
| 15 |
* Internal dependencies
|
| 17 |
import { default as PaymentMethodConfig } from './payment-method-config';
|
| 18 |
import { default as ExpressPaymentMethodConfig } from './express-payment-method-config';
|
| 19 |
import { canMakePaymentExtensionsCallbacks } from './extensions-config';
|
| 20 |
+
|
| 21 |
+
type LegacyRegisterPaymentMethodFunction = ( config: unknown ) => unknown;
|
| 22 |
+
type LegacyRegisterExpessPaymentMethodFunction = ( config: unknown ) => unknown;
|
| 23 |
+
|
| 24 |
+
const paymentMethods: PaymentMethods = {};
|
| 25 |
+
const expressPaymentMethods: ExpressPaymentMethods = {};
|
| 26 |
|
| 27 |
/**
|
| 28 |
* Register a regular payment method.
|
|
|
|
|
|
|
| 29 |
*/
|
| 30 |
+
export const registerPaymentMethod = (
|
| 31 |
+
options: PaymentMethodConfiguration | LegacyRegisterPaymentMethodFunction
|
| 32 |
+
): void => {
|
| 33 |
+
let paymentMethodConfig: PaymentMethodConfigInstance | unknown;
|
| 34 |
if ( typeof options === 'function' ) {
|
| 35 |
// Legacy fallback for previous API, where client passes a function:
|
| 36 |
// registerPaymentMethod( ( Config ) => new Config( options ) );
|
| 51 |
|
| 52 |
/**
|
| 53 |
* Register an express payment method.
|
|
|
|
|
|
|
| 54 |
*/
|
| 55 |
+
export const registerExpressPaymentMethod = (
|
| 56 |
+
options:
|
| 57 |
+
| ExpressPaymentMethodConfiguration
|
| 58 |
+
| LegacyRegisterExpessPaymentMethodFunction
|
| 59 |
+
): void => {
|
| 60 |
let paymentMethodConfig;
|
| 61 |
if ( typeof options === 'function' ) {
|
| 62 |
// Legacy fallback for previous API, where client passes a function:
|
| 78 |
|
| 79 |
/**
|
| 80 |
* Allows extension to register callbacks for specific payment methods to determine if they can make payments
|
|
|
|
|
|
|
|
|
|
| 81 |
*/
|
| 82 |
export const registerPaymentMethodExtensionCallbacks = (
|
| 83 |
+
namespace: string,
|
| 84 |
+
callbacks: Record< string, CanMakePaymentExtensionCallback >
|
| 85 |
+
): void => {
|
| 86 |
if ( canMakePaymentExtensionsCallbacks[ namespace ] ) {
|
| 87 |
// eslint-disable-next-line no-console
|
| 88 |
console.error(
|
| 109 |
}
|
| 110 |
};
|
| 111 |
|
| 112 |
+
export const __experimentalDeRegisterPaymentMethod = (
|
| 113 |
+
paymentMethodName: string
|
| 114 |
+
): void => {
|
| 115 |
delete paymentMethods[ paymentMethodName ];
|
| 116 |
};
|
| 117 |
|
| 118 |
export const __experimentalDeRegisterExpressPaymentMethod = (
|
| 119 |
+
paymentMethodName: string
|
| 120 |
+
): void => {
|
| 121 |
delete expressPaymentMethods[ paymentMethodName ];
|
| 122 |
};
|
| 123 |
|
| 124 |
+
export const getPaymentMethods = (): PaymentMethods => {
|
| 125 |
return paymentMethods;
|
| 126 |
};
|
| 127 |
|
| 128 |
+
export const getExpressPaymentMethods = (): ExpressPaymentMethods => {
|
| 129 |
return expressPaymentMethods;
|
| 130 |
};
|
assets/js/blocks-registry/payment-methods/test/payment-method-config-helper.ts
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { registerPaymentMethodExtensionCallbacks } from '@woocommerce/blocks-registry';
|
| 5 |
+
/**
|
| 6 |
+
* Internal dependencies
|
| 7 |
+
*/
|
| 8 |
+
import * as helpers from '../payment-method-config-helper';
|
| 9 |
+
import { canMakePaymentExtensionsCallbacks } from '../extensions-config';
|
| 10 |
+
|
| 11 |
+
const canMakePaymentArgument = {
|
| 12 |
+
cartTotals: {
|
| 13 |
+
total_items: '1488',
|
| 14 |
+
total_items_tax: '312',
|
| 15 |
+
total_fees: '0',
|
| 16 |
+
total_fees_tax: '0',
|
| 17 |
+
total_discount: '0',
|
| 18 |
+
total_discount_tax: '0',
|
| 19 |
+
total_shipping: '0',
|
| 20 |
+
total_shipping_tax: '0',
|
| 21 |
+
total_price: '1800',
|
| 22 |
+
total_tax: '312',
|
| 23 |
+
tax_lines: [
|
| 24 |
+
{
|
| 25 |
+
name: 'BTW',
|
| 26 |
+
price: '312',
|
| 27 |
+
rate: '21%',
|
| 28 |
+
},
|
| 29 |
+
],
|
| 30 |
+
currency_code: 'EUR',
|
| 31 |
+
currency_symbol: '€',
|
| 32 |
+
currency_minor_unit: 2,
|
| 33 |
+
currency_decimal_separator: ',',
|
| 34 |
+
currency_thousand_separator: '.',
|
| 35 |
+
currency_prefix: '€',
|
| 36 |
+
currency_suffix: '',
|
| 37 |
+
},
|
| 38 |
+
cartNeedsShipping: true,
|
| 39 |
+
billingData: {
|
| 40 |
+
first_name: 'name',
|
| 41 |
+
last_name: 'Name',
|
| 42 |
+
company: '',
|
| 43 |
+
address_1: 'fdsfdsfdsf',
|
| 44 |
+
address_2: '',
|
| 45 |
+
city: 'Berlin',
|
| 46 |
+
state: '',
|
| 47 |
+
postcode: 'xxxxx',
|
| 48 |
+
country: 'DE',
|
| 49 |
+
email: 'name.Name@test.com',
|
| 50 |
+
phone: '1234',
|
| 51 |
+
},
|
| 52 |
+
shippingAddress: {
|
| 53 |
+
first_name: 'name',
|
| 54 |
+
last_name: 'Name',
|
| 55 |
+
company: '',
|
| 56 |
+
address_1: 'fdsfdsfdsf',
|
| 57 |
+
address_2: '',
|
| 58 |
+
city: 'Berlin',
|
| 59 |
+
state: '',
|
| 60 |
+
postcode: 'xxxxx',
|
| 61 |
+
country: 'DE',
|
| 62 |
+
phone: '1234',
|
| 63 |
+
},
|
| 64 |
+
selectedShippingMethods: {
|
| 65 |
+
'0': 'free_shipping:1',
|
| 66 |
+
},
|
| 67 |
+
paymentRequirements: [ 'products' ],
|
| 68 |
+
};
|
| 69 |
+
describe( 'payment-method-config-helper', () => {
|
| 70 |
+
const trueCallback = jest.fn().mockReturnValue( true );
|
| 71 |
+
const falseCallback = jest.fn().mockReturnValue( false );
|
| 72 |
+
const bacsCallback = jest.fn().mockReturnValue( false );
|
| 73 |
+
const throwsCallback = jest.fn().mockImplementation( () => {
|
| 74 |
+
throw new Error();
|
| 75 |
+
} );
|
| 76 |
+
beforeAll( () => {
|
| 77 |
+
// Register extension callbacks for two payment methods.
|
| 78 |
+
registerPaymentMethodExtensionCallbacks(
|
| 79 |
+
'woocommerce-marketplace-extension',
|
| 80 |
+
{
|
| 81 |
+
// cod: one extension returns true, the other returns false.
|
| 82 |
+
cod: trueCallback,
|
| 83 |
+
// cheque: returns true only if arg.billingData.postcode is 12345.
|
| 84 |
+
cheque: ( arg ) => arg.billingData.postcode === '12345',
|
| 85 |
+
// bacs: both extensions return false.
|
| 86 |
+
bacs: bacsCallback,
|
| 87 |
+
// woopay: both extensions return true.
|
| 88 |
+
woopay: trueCallback,
|
| 89 |
+
// testpay: one callback errors, one returns true
|
| 90 |
+
testpay: throwsCallback,
|
| 91 |
+
}
|
| 92 |
+
);
|
| 93 |
+
registerPaymentMethodExtensionCallbacks(
|
| 94 |
+
'other-woocommerce-marketplace-extension',
|
| 95 |
+
{
|
| 96 |
+
cod: falseCallback,
|
| 97 |
+
woopay: trueCallback,
|
| 98 |
+
testpay: trueCallback,
|
| 99 |
+
bacs: bacsCallback,
|
| 100 |
+
}
|
| 101 |
+
);
|
| 102 |
+
} );
|
| 103 |
+
|
| 104 |
+
beforeEach( () => {
|
| 105 |
+
trueCallback.mockClear();
|
| 106 |
+
throwsCallback.mockClear();
|
| 107 |
+
falseCallback.mockClear();
|
| 108 |
+
bacsCallback.mockClear();
|
| 109 |
+
} );
|
| 110 |
+
describe( 'getCanMakePayment', () => {
|
| 111 |
+
it( 'returns callback canMakePaymentWithFeaturesCheck if no extension callback is detected', () => {
|
| 112 |
+
// Define arguments from a payment method ('missing-payment-method') with no registered extension callbacks.
|
| 113 |
+
const args = {
|
| 114 |
+
canMakePayment: jest.fn().mockImplementation( () => true ),
|
| 115 |
+
features: [ 'products' ],
|
| 116 |
+
paymentMethodName: 'missing-payment-method',
|
| 117 |
+
};
|
| 118 |
+
|
| 119 |
+
const canMakePayment = helpers.getCanMakePayment(
|
| 120 |
+
args.canMakePayment,
|
| 121 |
+
args.features,
|
| 122 |
+
args.paymentMethodName
|
| 123 |
+
)( canMakePaymentArgument );
|
| 124 |
+
|
| 125 |
+
// Expect that the result of getCanMakePayment is the result of
|
| 126 |
+
// the payment method's own canMakePayment, as no extension callbacks are called.
|
| 127 |
+
expect( canMakePayment ).toEqual( args.canMakePayment() );
|
| 128 |
+
} );
|
| 129 |
+
|
| 130 |
+
it( 'returns callbacks from the extensions when they are defined', () => {
|
| 131 |
+
// Define arguments from a payment method (bacs) with registered extension callbacks.
|
| 132 |
+
const args = {
|
| 133 |
+
canMakePaymentConfiguration: jest
|
| 134 |
+
.fn()
|
| 135 |
+
.mockImplementation( () => true ),
|
| 136 |
+
features: [ 'products' ],
|
| 137 |
+
paymentMethodName: 'bacs',
|
| 138 |
+
};
|
| 139 |
+
|
| 140 |
+
const canMakePayment = helpers.getCanMakePayment(
|
| 141 |
+
args.canMakePaymentConfiguration,
|
| 142 |
+
args.features,
|
| 143 |
+
args.paymentMethodName
|
| 144 |
+
)( canMakePaymentArgument );
|
| 145 |
+
|
| 146 |
+
// Expect that the result of getCanMakePayment is not the result of
|
| 147 |
+
// the payment method's own canMakePayment (args.canMakePaymentConfiguration),
|
| 148 |
+
// but of the registered bacsCallback.
|
| 149 |
+
expect( canMakePayment ).toBe( bacsCallback() );
|
| 150 |
+
} );
|
| 151 |
+
} );
|
| 152 |
+
|
| 153 |
+
describe( 'canMakePaymentWithExtensions', () => {
|
| 154 |
+
it( "Returns false without executing the registered callbacks, if the payment method's canMakePayment callback returns false.", () => {
|
| 155 |
+
const canMakePayment = () => false;
|
| 156 |
+
const canMakePaymentWithExtensionsResult = helpers.canMakePaymentWithExtensions(
|
| 157 |
+
canMakePayment,
|
| 158 |
+
canMakePaymentExtensionsCallbacks,
|
| 159 |
+
'cod'
|
| 160 |
+
)( canMakePaymentArgument );
|
| 161 |
+
expect( canMakePaymentWithExtensionsResult ).toBe( false );
|
| 162 |
+
expect( trueCallback ).not.toHaveBeenCalled();
|
| 163 |
+
} );
|
| 164 |
+
|
| 165 |
+
it( 'Returns early when a registered callback returns false, without executing all the registered callbacks', () => {
|
| 166 |
+
helpers.canMakePaymentWithExtensions(
|
| 167 |
+
() => true,
|
| 168 |
+
canMakePaymentExtensionsCallbacks,
|
| 169 |
+
'bacs'
|
| 170 |
+
)( canMakePaymentArgument );
|
| 171 |
+
expect( bacsCallback ).toHaveBeenCalledTimes( 1 );
|
| 172 |
+
} );
|
| 173 |
+
|
| 174 |
+
it( 'Returns true if all extension callbacks return true', () => {
|
| 175 |
+
const result = helpers.canMakePaymentWithExtensions(
|
| 176 |
+
() => true,
|
| 177 |
+
canMakePaymentExtensionsCallbacks,
|
| 178 |
+
'woopay'
|
| 179 |
+
)( canMakePaymentArgument );
|
| 180 |
+
expect( result ).toBe( true );
|
| 181 |
+
} );
|
| 182 |
+
|
| 183 |
+
it( 'Passes canPayArg to the callback', () => {
|
| 184 |
+
helpers.canMakePaymentWithExtensions(
|
| 185 |
+
() => true,
|
| 186 |
+
canMakePaymentExtensionsCallbacks,
|
| 187 |
+
'woopay'
|
| 188 |
+
)( canMakePaymentArgument );
|
| 189 |
+
expect( trueCallback ).toHaveBeenCalledWith(
|
| 190 |
+
canMakePaymentArgument
|
| 191 |
+
);
|
| 192 |
+
} );
|
| 193 |
+
|
| 194 |
+
it( 'Allows all valid callbacks to run, even if one causes an error', () => {
|
| 195 |
+
helpers.canMakePaymentWithExtensions(
|
| 196 |
+
() => true,
|
| 197 |
+
canMakePaymentExtensionsCallbacks,
|
| 198 |
+
'testpay'
|
| 199 |
+
)( canMakePaymentArgument );
|
| 200 |
+
expect( console ).toHaveErrored();
|
| 201 |
+
expect( throwsCallback ).toHaveBeenCalledTimes( 1 );
|
| 202 |
+
expect( trueCallback ).toHaveBeenCalledTimes( 1 );
|
| 203 |
+
} );
|
| 204 |
+
} );
|
| 205 |
+
} );
|
assets/js/blocks-registry/payment-methods/test/payment-method-config.tsx
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { registerPaymentMethodExtensionCallbacks } from '@woocommerce/blocks-registry';
|
| 5 |
+
import type { PaymentMethodConfigInstance } from '@woocommerce/type-defs/payments';
|
| 6 |
+
/**
|
| 7 |
+
* Internal dependencies
|
| 8 |
+
*/
|
| 9 |
+
import PaymentMethodConfig from '../payment-method-config';
|
| 10 |
+
import * as paymentMethodConfigHelpers from '../payment-method-config-helper';
|
| 11 |
+
|
| 12 |
+
describe( 'PaymentMethodConfig', () => {
|
| 13 |
+
let paymentMethod: PaymentMethodConfigInstance;
|
| 14 |
+
const extensionsCallbackSpy = jest.spyOn(
|
| 15 |
+
paymentMethodConfigHelpers,
|
| 16 |
+
'canMakePaymentWithExtensions'
|
| 17 |
+
);
|
| 18 |
+
beforeEach( () => {
|
| 19 |
+
paymentMethod = new PaymentMethodConfig( {
|
| 20 |
+
name: 'test-payment-method',
|
| 21 |
+
label: 'Test payment method',
|
| 22 |
+
ariaLabel: 'Test payment method',
|
| 23 |
+
content: <div>Test payment content</div>,
|
| 24 |
+
edit: <div>Test payment edit</div>,
|
| 25 |
+
canMakePayment: () => true,
|
| 26 |
+
supports: { features: [ 'products' ] },
|
| 27 |
+
} );
|
| 28 |
+
} );
|
| 29 |
+
|
| 30 |
+
it( 'Uses canMakePaymentWithExtensions as the canMakePayment function if an extension registers a callback', () => {
|
| 31 |
+
registerPaymentMethodExtensionCallbacks(
|
| 32 |
+
'woocommerce-marketplace-extension',
|
| 33 |
+
{
|
| 34 |
+
'unrelated-payment-method': () => true,
|
| 35 |
+
}
|
| 36 |
+
);
|
| 37 |
+
|
| 38 |
+
// At this point, since no extensions have registered a callback for
|
| 39 |
+
// test-payment-method we can expect the canMakePayment getter NOT
|
| 40 |
+
// to execute canMakePaymentWithExtensions.
|
| 41 |
+
// Disable no-unused-expressions because we just want to test the getter
|
| 42 |
+
// eslint-disable-next-line no-unused-expressions
|
| 43 |
+
paymentMethod.canMakePayment;
|
| 44 |
+
expect( extensionsCallbackSpy ).toHaveBeenCalledTimes( 0 );
|
| 45 |
+
|
| 46 |
+
registerPaymentMethodExtensionCallbacks(
|
| 47 |
+
'other-woocommerce-marketplace-extension',
|
| 48 |
+
{
|
| 49 |
+
'test-payment-method': () => true,
|
| 50 |
+
}
|
| 51 |
+
);
|
| 52 |
+
|
| 53 |
+
// Now, because an extension _has_ registered a callback for test-payment-method
|
| 54 |
+
// The getter will use canMakePaymentWithExtensions to create the
|
| 55 |
+
// canMakePayment function.
|
| 56 |
+
// Disable no-unused-expressions because we just want to test the getter
|
| 57 |
+
// eslint-disable-next-line no-unused-expressions
|
| 58 |
+
paymentMethod.canMakePayment;
|
| 59 |
+
expect( extensionsCallbackSpy ).toHaveBeenCalledTimes( 1 );
|
| 60 |
+
} );
|
| 61 |
+
} );
|
assets/js/blocks-registry/payment-methods/test/registry.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { registerPaymentMethodExtensionCallbacks } from '@woocommerce/blocks-registry';
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* Internal dependencies
|
| 8 |
+
*/
|
| 9 |
+
import { canMakePaymentExtensionsCallbacks } from '../extensions-config';
|
| 10 |
+
|
| 11 |
+
describe( 'registerPaymentMethodExtensionCallbacks', () => {
|
| 12 |
+
it( 'Logs an error to console if namespace is already registered', () => {
|
| 13 |
+
registerPaymentMethodExtensionCallbacks(
|
| 14 |
+
'woocommerce-marketplace-extension',
|
| 15 |
+
{
|
| 16 |
+
cod: () => false,
|
| 17 |
+
}
|
| 18 |
+
);
|
| 19 |
+
|
| 20 |
+
// eslint-disable-next-line no-console
|
| 21 |
+
expect( console ).not.toHaveErrored();
|
| 22 |
+
registerPaymentMethodExtensionCallbacks(
|
| 23 |
+
'woocommerce-marketplace-extension',
|
| 24 |
+
{
|
| 25 |
+
cod: () => false,
|
| 26 |
+
}
|
| 27 |
+
);
|
| 28 |
+
expect( console ).toHaveErrored();
|
| 29 |
+
|
| 30 |
+
// eslint-disable-next-line no-console
|
| 31 |
+
expect( console.error ).toHaveBeenCalledTimes( 1 );
|
| 32 |
+
} );
|
| 33 |
+
|
| 34 |
+
it( 'Does not overwrite a namespace if a second extensions tries to register with the same name', () => {
|
| 35 |
+
const firstCodCallback = jest.fn().mockReturnValue( false );
|
| 36 |
+
registerPaymentMethodExtensionCallbacks(
|
| 37 |
+
'overwrite-marketplace-extension',
|
| 38 |
+
{
|
| 39 |
+
cod: firstCodCallback,
|
| 40 |
+
}
|
| 41 |
+
);
|
| 42 |
+
|
| 43 |
+
// eslint-disable-next-line no-console
|
| 44 |
+
expect( console ).not.toHaveErrored();
|
| 45 |
+
registerPaymentMethodExtensionCallbacks(
|
| 46 |
+
'overwrite-marketplace-extension',
|
| 47 |
+
{
|
| 48 |
+
cod: () => false,
|
| 49 |
+
}
|
| 50 |
+
);
|
| 51 |
+
|
| 52 |
+
expect(
|
| 53 |
+
canMakePaymentExtensionsCallbacks[
|
| 54 |
+
'overwrite-marketplace-extension'
|
| 55 |
+
].cod
|
| 56 |
+
).toEqual( firstCodCallback );
|
| 57 |
+
} );
|
| 58 |
+
|
| 59 |
+
it( 'Logs an error if a supplied callback is not a function and does not register the callback for that method', () => {
|
| 60 |
+
registerPaymentMethodExtensionCallbacks(
|
| 61 |
+
'other-woocommerce-marketplace-extension',
|
| 62 |
+
{
|
| 63 |
+
cod: false,
|
| 64 |
+
cheque: () => true,
|
| 65 |
+
}
|
| 66 |
+
);
|
| 67 |
+
|
| 68 |
+
// eslint-disable-next-line no-console
|
| 69 |
+
expect( console ).toHaveErrored();
|
| 70 |
+
expect( canMakePaymentExtensionsCallbacks ).toHaveProperty(
|
| 71 |
+
'other-woocommerce-marketplace-extension'
|
| 72 |
+
);
|
| 73 |
+
expect(
|
| 74 |
+
canMakePaymentExtensionsCallbacks[
|
| 75 |
+
'other-woocommerce-marketplace-extension'
|
| 76 |
+
]
|
| 77 |
+
).not.toHaveProperty( 'cod' );
|
| 78 |
+
expect(
|
| 79 |
+
canMakePaymentExtensionsCallbacks[
|
| 80 |
+
'other-woocommerce-marketplace-extension'
|
| 81 |
+
]
|
| 82 |
+
).toHaveProperty( 'cheque' );
|
| 83 |
+
} );
|
| 84 |
+
|
| 85 |
+
it( 'Adds the namespace and callbacks to the canMakePaymentExtensionCallbacks object', () => {
|
| 86 |
+
// We are using a new namespace here because canMakePaymentExtensionsCallbacks cannot be reset between tests.
|
| 87 |
+
registerPaymentMethodExtensionCallbacks(
|
| 88 |
+
'third-woocommerce-marketplace-extension',
|
| 89 |
+
{
|
| 90 |
+
cod: () => false,
|
| 91 |
+
}
|
| 92 |
+
);
|
| 93 |
+
expect( canMakePaymentExtensionsCallbacks ).toHaveProperty(
|
| 94 |
+
'third-woocommerce-marketplace-extension'
|
| 95 |
+
);
|
| 96 |
+
} );
|
| 97 |
+
} );
|
assets/js/blocks/active-filters/block.js
CHANGED
|
@@ -125,7 +125,9 @@ const ActiveFiltersBlock = ( {
|
|
| 125 |
return (
|
| 126 |
<>
|
| 127 |
{ ! isEditor && blockAttributes.heading && (
|
| 128 |
-
<TagName
|
|
|
|
|
|
|
| 129 |
) }
|
| 130 |
<div className="wc-block-active-filters">
|
| 131 |
<ul className={ listClasses }>
|
| 125 |
return (
|
| 126 |
<>
|
| 127 |
{ ! isEditor && blockAttributes.heading && (
|
| 128 |
+
<TagName className="wc-block-active-filters__title">
|
| 129 |
+
{ blockAttributes.heading }
|
| 130 |
+
</TagName>
|
| 131 |
) }
|
| 132 |
<div className="wc-block-active-filters">
|
| 133 |
<ul className={ listClasses }>
|
assets/js/blocks/active-filters/edit.js
CHANGED
|
@@ -78,6 +78,7 @@ const Edit = ( { attributes, setAttributes } ) => {
|
|
| 78 |
<div className={ className }>
|
| 79 |
{ getInspectorControls() }
|
| 80 |
<BlockTitle
|
|
|
|
| 81 |
headingLevel={ headingLevel }
|
| 82 |
heading={ heading }
|
| 83 |
onChange={ ( value ) => setAttributes( { heading: value } ) }
|
| 78 |
<div className={ className }>
|
| 79 |
{ getInspectorControls() }
|
| 80 |
<BlockTitle
|
| 81 |
+
className="wc-block-active-filters__title"
|
| 82 |
headingLevel={ headingLevel }
|
| 83 |
heading={ heading }
|
| 84 |
onChange={ ( value ) => setAttributes( { heading: value } ) }
|
assets/js/blocks/attribute-filter/block.js
CHANGED
|
@@ -338,7 +338,9 @@ const AttributeFilterBlock = ( {
|
|
| 338 |
return (
|
| 339 |
<>
|
| 340 |
{ ! isEditor && blockAttributes.heading && (
|
| 341 |
-
<TagName
|
|
|
|
|
|
|
| 342 |
) }
|
| 343 |
<div className="wc-block-attribute-filter">
|
| 344 |
{ blockAttributes.displayStyle === 'dropdown' ? (
|
| 338 |
return (
|
| 339 |
<>
|
| 340 |
{ ! isEditor && blockAttributes.heading && (
|
| 341 |
+
<TagName className="wc-block-attribute-filter__title">
|
| 342 |
+
{ blockAttributes.heading }
|
| 343 |
+
</TagName>
|
| 344 |
) }
|
| 345 |
<div className="wc-block-attribute-filter">
|
| 346 |
{ blockAttributes.displayStyle === 'dropdown' ? (
|
assets/js/blocks/attribute-filter/edit.js
CHANGED
|
@@ -386,6 +386,7 @@ const Edit = ( { attributes, setAttributes, debouncedSpeak } ) => {
|
|
| 386 |
) : (
|
| 387 |
<div className={ className }>
|
| 388 |
<BlockTitle
|
|
|
|
| 389 |
headingLevel={ headingLevel }
|
| 390 |
heading={ heading }
|
| 391 |
onChange={ ( value ) =>
|
| 386 |
) : (
|
| 387 |
<div className={ className }>
|
| 388 |
<BlockTitle
|
| 389 |
+
className="wc-block-attribute-filter__title"
|
| 390 |
headingLevel={ headingLevel }
|
| 391 |
heading={ heading }
|
| 392 |
onChange={ ( value ) =>
|
assets/js/blocks/cart-checkout/cart-i2/attributes.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { getSetting } from '@woocommerce/settings';
|
| 5 |
+
|
| 6 |
+
export const blockName = 'woocommerce/cart-i2';
|
| 7 |
+
export const blockAttributes = {
|
| 8 |
+
isPreview: {
|
| 9 |
+
type: 'boolean',
|
| 10 |
+
default: false,
|
| 11 |
+
save: false,
|
| 12 |
+
},
|
| 13 |
+
isShippingCalculatorEnabled: {
|
| 14 |
+
type: 'boolean',
|
| 15 |
+
default: getSetting( 'isShippingCalculatorEnabled', true ),
|
| 16 |
+
},
|
| 17 |
+
checkoutPageId: {
|
| 18 |
+
type: 'number',
|
| 19 |
+
default: 0,
|
| 20 |
+
},
|
| 21 |
+
hasDarkControls: {
|
| 22 |
+
type: 'boolean',
|
| 23 |
+
default: getSetting( 'hasDarkEditorStyleSupport', false ),
|
| 24 |
+
},
|
| 25 |
+
showRateAfterTaxName: {
|
| 26 |
+
type: 'boolean',
|
| 27 |
+
default: true,
|
| 28 |
+
},
|
| 29 |
+
};
|
assets/js/blocks/cart-checkout/cart-i2/block.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { __ } from '@wordpress/i18n';
|
| 5 |
+
import { CART_STORE_KEY as storeKey } from '@woocommerce/block-data';
|
| 6 |
+
import { dispatch } from '@wordpress/data';
|
| 7 |
+
import { useStoreCart } from '@woocommerce/base-context/hooks';
|
| 8 |
+
import { useEffect } from '@wordpress/element';
|
| 9 |
+
import LoadingMask from '@woocommerce/base-components/loading-mask';
|
| 10 |
+
import { ValidationContextProvider } from '@woocommerce/base-context';
|
| 11 |
+
import { CURRENT_USER_IS_ADMIN } from '@woocommerce/settings';
|
| 12 |
+
import BlockErrorBoundary from '@woocommerce/base-components/block-error-boundary';
|
| 13 |
+
import { translateJQueryEventToNative } from '@woocommerce/base-utils';
|
| 14 |
+
import withScrollToTop from '@woocommerce/base-hocs/with-scroll-to-top';
|
| 15 |
+
import {
|
| 16 |
+
StoreNoticesProvider,
|
| 17 |
+
StoreSnackbarNoticesProvider,
|
| 18 |
+
CartProvider,
|
| 19 |
+
} from '@woocommerce/base-context/providers';
|
| 20 |
+
import { SlotFillProvider } from '@woocommerce/blocks-checkout';
|
| 21 |
+
|
| 22 |
+
const reloadPage = () => void window.location.reload( true );
|
| 23 |
+
|
| 24 |
+
const Cart = ( { children } ) => {
|
| 25 |
+
const { cartIsLoading } = useStoreCart();
|
| 26 |
+
|
| 27 |
+
return (
|
| 28 |
+
<LoadingMask showSpinner={ true } isLoading={ cartIsLoading }>
|
| 29 |
+
<ValidationContextProvider>{ children }</ValidationContextProvider>
|
| 30 |
+
</LoadingMask>
|
| 31 |
+
);
|
| 32 |
+
};
|
| 33 |
+
|
| 34 |
+
const ScrollOnError = ( { scrollToTop } ) => {
|
| 35 |
+
useEffect( () => {
|
| 36 |
+
const invalidateCartData = () => {
|
| 37 |
+
dispatch( storeKey ).invalidateResolutionForStore();
|
| 38 |
+
scrollToTop();
|
| 39 |
+
};
|
| 40 |
+
|
| 41 |
+
// Make it so we can read jQuery events triggered by WC Core elements.
|
| 42 |
+
const removeJQueryAddedToCartEvent = translateJQueryEventToNative(
|
| 43 |
+
'added_to_cart',
|
| 44 |
+
'wc-blocks_added_to_cart'
|
| 45 |
+
);
|
| 46 |
+
const removeJQueryRemovedFromCartEvent = translateJQueryEventToNative(
|
| 47 |
+
'removed_from_cart',
|
| 48 |
+
'wc-blocks_removed_from_cart'
|
| 49 |
+
);
|
| 50 |
+
|
| 51 |
+
document.body.addEventListener(
|
| 52 |
+
'wc-blocks_added_to_cart',
|
| 53 |
+
invalidateCartData
|
| 54 |
+
);
|
| 55 |
+
document.body.addEventListener(
|
| 56 |
+
'wc-blocks_removed_from_cart',
|
| 57 |
+
invalidateCartData
|
| 58 |
+
);
|
| 59 |
+
|
| 60 |
+
return () => {
|
| 61 |
+
removeJQueryAddedToCartEvent();
|
| 62 |
+
removeJQueryRemovedFromCartEvent();
|
| 63 |
+
|
| 64 |
+
document.body.removeEventListener(
|
| 65 |
+
'wc-blocks_added_to_cart',
|
| 66 |
+
invalidateCartData
|
| 67 |
+
);
|
| 68 |
+
document.body.removeEventListener(
|
| 69 |
+
'wc-blocks_removed_from_cart',
|
| 70 |
+
invalidateCartData
|
| 71 |
+
);
|
| 72 |
+
};
|
| 73 |
+
}, [ scrollToTop ] );
|
| 74 |
+
|
| 75 |
+
return null;
|
| 76 |
+
};
|
| 77 |
+
const Block = ( { attributes, children, scrollToTop } ) => (
|
| 78 |
+
<BlockErrorBoundary
|
| 79 |
+
header={ __( 'Something went wrong…', 'woo-gutenberg-products-block' ) }
|
| 80 |
+
text={ __(
|
| 81 |
+
'The cart has encountered an unexpected error. If the error persists, please get in touch with us for help.',
|
| 82 |
+
'woo-gutenberg-products-block'
|
| 83 |
+
) }
|
| 84 |
+
button={
|
| 85 |
+
<button className="wc-block-button" onClick={ reloadPage }>
|
| 86 |
+
{ __( 'Reload the page', 'woo-gutenberg-products-block' ) }
|
| 87 |
+
</button>
|
| 88 |
+
}
|
| 89 |
+
showErrorMessage={ CURRENT_USER_IS_ADMIN }
|
| 90 |
+
>
|
| 91 |
+
<StoreSnackbarNoticesProvider context="wc/cart">
|
| 92 |
+
<StoreNoticesProvider context="wc/cart">
|
| 93 |
+
<SlotFillProvider>
|
| 94 |
+
<CartProvider>
|
| 95 |
+
<Cart attributes={ attributes }>{ children }</Cart>
|
| 96 |
+
<ScrollOnError scrollToTop={ scrollToTop } />
|
| 97 |
+
</CartProvider>
|
| 98 |
+
</SlotFillProvider>
|
| 99 |
+
</StoreNoticesProvider>
|
| 100 |
+
</StoreSnackbarNoticesProvider>
|
| 101 |
+
</BlockErrorBoundary>
|
| 102 |
+
);
|
| 103 |
+
export default withScrollToTop( Block );
|
assets/js/blocks/cart-checkout/cart-i2/checkout-button/index.tsx
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { __ } from '@wordpress/i18n';
|
| 5 |
+
import { useState, useEffect } from '@wordpress/element';
|
| 6 |
+
import { PaymentMethodIcons } from '@woocommerce/base-components/cart-checkout';
|
| 7 |
+
import Button from '@woocommerce/base-components/button';
|
| 8 |
+
import { CHECKOUT_URL } from '@woocommerce/block-settings';
|
| 9 |
+
import { useCheckoutContext } from '@woocommerce/base-context';
|
| 10 |
+
import { usePaymentMethods } from '@woocommerce/base-context/hooks';
|
| 11 |
+
import { usePositionRelativeToViewport } from '@woocommerce/base-hooks';
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* Internal dependencies
|
| 15 |
+
*/
|
| 16 |
+
import './style.scss';
|
| 17 |
+
import type PaymentMethodConfig from '../../../../blocks-registry/payment-methods/payment-method-config';
|
| 18 |
+
|
| 19 |
+
const getIconsFromPaymentMethods = (
|
| 20 |
+
paymentMethods: PaymentMethodConfig[]
|
| 21 |
+
) => {
|
| 22 |
+
return Object.values( paymentMethods ).reduce( ( acc, paymentMethod ) => {
|
| 23 |
+
if ( paymentMethod.icons !== null ) {
|
| 24 |
+
acc = acc.concat( paymentMethod.icons );
|
| 25 |
+
}
|
| 26 |
+
return acc;
|
| 27 |
+
}, [] );
|
| 28 |
+
};
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* Checkout button rendered in the full cart page.
|
| 32 |
+
*
|
| 33 |
+
* @param {Object} props Incoming props for the component.
|
| 34 |
+
* @param {string} props.link What the button is linked to.
|
| 35 |
+
*/
|
| 36 |
+
const CheckoutButton = ( { link }: { link: string } ): JSX.Element => {
|
| 37 |
+
const { isCalculating } = useCheckoutContext();
|
| 38 |
+
const [
|
| 39 |
+
positionReferenceElement,
|
| 40 |
+
positionRelativeToViewport,
|
| 41 |
+
] = usePositionRelativeToViewport();
|
| 42 |
+
const [ showSpinner, setShowSpinner ] = useState( false );
|
| 43 |
+
const { paymentMethods } = usePaymentMethods();
|
| 44 |
+
|
| 45 |
+
useEffect( () => {
|
| 46 |
+
// Add a listener to remove the spinner on the checkout button, so the saved page snapshot does not
|
| 47 |
+
// contain the spinner class. See https://archive.is/lOEW0 for why this is needed for Safari.
|
| 48 |
+
|
| 49 |
+
if (
|
| 50 |
+
typeof global.addEventListener !== 'function' ||
|
| 51 |
+
typeof global.removeEventListener !== 'function'
|
| 52 |
+
) {
|
| 53 |
+
return;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
const hideSpinner = () => {
|
| 57 |
+
setShowSpinner( false );
|
| 58 |
+
};
|
| 59 |
+
|
| 60 |
+
global.addEventListener( 'pageshow', hideSpinner );
|
| 61 |
+
|
| 62 |
+
return () => {
|
| 63 |
+
global.removeEventListener( 'pageshow', hideSpinner );
|
| 64 |
+
};
|
| 65 |
+
}, [] );
|
| 66 |
+
|
| 67 |
+
const submitContainerContents = (
|
| 68 |
+
<>
|
| 69 |
+
<Button
|
| 70 |
+
className="wc-block-cart__submit-button"
|
| 71 |
+
href={ link || CHECKOUT_URL }
|
| 72 |
+
disabled={ isCalculating }
|
| 73 |
+
onClick={ () => setShowSpinner( true ) }
|
| 74 |
+
showSpinner={ showSpinner }
|
| 75 |
+
>
|
| 76 |
+
{ __( 'Proceed to Checkout', 'woo-gutenberg-products-block' ) }
|
| 77 |
+
</Button>
|
| 78 |
+
<PaymentMethodIcons
|
| 79 |
+
icons={ getIconsFromPaymentMethods( paymentMethods ) }
|
| 80 |
+
/>
|
| 81 |
+
</>
|
| 82 |
+
);
|
| 83 |
+
|
| 84 |
+
return (
|
| 85 |
+
<div className="wc-block-cart__submit">
|
| 86 |
+
{ positionReferenceElement }
|
| 87 |
+
{ /* The non-sticky container must always be visible because it gives height to its parent, which is required to calculate when it becomes visible in the viewport. */ }
|
| 88 |
+
<div className="wc-block-cart__submit-container">
|
| 89 |
+
{ submitContainerContents }
|
| 90 |
+
</div>
|
| 91 |
+
{ /* If the positionReferenceElement is below the viewport, display the sticky container. */ }
|
| 92 |
+
{ positionRelativeToViewport === 'below' && (
|
| 93 |
+
<div className="wc-block-cart__submit-container wc-block-cart__submit-container--sticky">
|
| 94 |
+
{ submitContainerContents }
|
| 95 |
+
</div>
|
| 96 |
+
) }
|
| 97 |
+
</div>
|
| 98 |
+
);
|
| 99 |
+
};
|
| 100 |
+
|
| 101 |
+
export default CheckoutButton;
|
assets/js/blocks/cart-checkout/cart-i2/checkout-button/style.scss
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.wc-block-cart__submit {
|
| 2 |
+
position: relative;
|
| 3 |
+
}
|
| 4 |
+
|
| 5 |
+
.wc-block-cart__submit-container {
|
| 6 |
+
padding-bottom: $gap;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
.wc-block-cart__submit-button {
|
| 10 |
+
width: 100%;
|
| 11 |
+
margin: 0 0 $gap;
|
| 12 |
+
|
| 13 |
+
&:last-child {
|
| 14 |
+
margin-bottom: 0;
|
| 15 |
+
}
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
.is-mobile,
|
| 19 |
+
.is-small,
|
| 20 |
+
.is-medium {
|
| 21 |
+
.wc-block-cart__submit-container:not(.wc-block-cart__submit-container--sticky) {
|
| 22 |
+
padding-left: 0;
|
| 23 |
+
padding-right: 0;
|
| 24 |
+
padding-top: 0;
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
@include breakpoint( ">782px" ) {
|
| 29 |
+
.wc-block-cart__submit-container--sticky {
|
| 30 |
+
display: none;
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
@include breakpoint( "<782px" ) {
|
| 35 |
+
.wc-block-cart__submit-container--sticky {
|
| 36 |
+
background: $white;
|
| 37 |
+
bottom: 0;
|
| 38 |
+
left: 0;
|
| 39 |
+
padding: $gap;
|
| 40 |
+
position: fixed;
|
| 41 |
+
width: 100%;
|
| 42 |
+
z-index: 9999;
|
| 43 |
+
|
| 44 |
+
&::before {
|
| 45 |
+
box-shadow: 0 -10px 20px 10px currentColor;
|
| 46 |
+
color: transparentize($gray-400, 0.5);
|
| 47 |
+
content: "";
|
| 48 |
+
height: 100%;
|
| 49 |
+
left: 0;
|
| 50 |
+
position: absolute;
|
| 51 |
+
right: 0;
|
| 52 |
+
top: 0;
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
|
assets/js/blocks/cart-checkout/{checkout-i2 → cart-i2}/columns/columns-block.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/{checkout-i2 → cart-i2}/columns/index.ts
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/cart-i2/context.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { createContext, useContext } from '@wordpress/element';
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* Context consumed by inner blocks.
|
| 8 |
+
*/
|
| 9 |
+
export type CartBlockContextProps = {
|
| 10 |
+
currentView: string;
|
| 11 |
+
};
|
| 12 |
+
|
| 13 |
+
export const CartBlockContext = createContext< CartBlockContextProps >( {
|
| 14 |
+
currentView: '',
|
| 15 |
+
} );
|
| 16 |
+
|
| 17 |
+
export const useCartBlockContext = (): CartBlockContextProps => {
|
| 18 |
+
return useContext( CartBlockContext );
|
| 19 |
+
};
|
assets/js/blocks/cart-checkout/cart-i2/edit.tsx
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* tslint:disable */
|
| 2 |
+
/**
|
| 3 |
+
* External dependencies
|
| 4 |
+
*/
|
| 5 |
+
import classnames from 'classnames';
|
| 6 |
+
import { __ } from '@wordpress/i18n';
|
| 7 |
+
import { CartCheckoutFeedbackPrompt } from '@woocommerce/editor-components/feedback-prompt';
|
| 8 |
+
import {
|
| 9 |
+
useBlockProps,
|
| 10 |
+
InnerBlocks,
|
| 11 |
+
InspectorControls,
|
| 12 |
+
BlockControls,
|
| 13 |
+
} from '@wordpress/block-editor';
|
| 14 |
+
import { PanelBody, ToggleControl, Notice } from '@wordpress/components';
|
| 15 |
+
import { CartCheckoutCompatibilityNotice } from '@woocommerce/editor-components/compatibility-notices';
|
| 16 |
+
import { CART_PAGE_ID } from '@woocommerce/block-settings';
|
| 17 |
+
import BlockErrorBoundary from '@woocommerce/base-components/block-error-boundary';
|
| 18 |
+
import {
|
| 19 |
+
EditorProvider,
|
| 20 |
+
useEditorContext,
|
| 21 |
+
CartProvider,
|
| 22 |
+
} from '@woocommerce/base-context';
|
| 23 |
+
import { createInterpolateElement } from '@wordpress/element';
|
| 24 |
+
import { getAdminLink, getSetting } from '@woocommerce/settings';
|
| 25 |
+
import { previewCart } from '@woocommerce/resource-previews';
|
| 26 |
+
import { Icon, filledCart, removeCart } from '@woocommerce/icons';
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* Internal dependencies
|
| 30 |
+
*/
|
| 31 |
+
import './editor.scss';
|
| 32 |
+
import { addClassToBody, useBlockPropsWithLocking } from './hacks';
|
| 33 |
+
import { useViewSwitcher } from './use-view-switcher';
|
| 34 |
+
import type { Attributes } from './types';
|
| 35 |
+
import { CartBlockContext } from './context';
|
| 36 |
+
|
| 37 |
+
// This is adds a class to body to signal if the selected block is locked
|
| 38 |
+
addClassToBody();
|
| 39 |
+
|
| 40 |
+
// Array of allowed block names.
|
| 41 |
+
const ALLOWED_BLOCKS: string[] = [
|
| 42 |
+
'woocommerce/filled-cart-block',
|
| 43 |
+
'woocommerce/empty-cart-block',
|
| 44 |
+
];
|
| 45 |
+
|
| 46 |
+
const BlockSettings = ( {
|
| 47 |
+
attributes,
|
| 48 |
+
setAttributes,
|
| 49 |
+
}: {
|
| 50 |
+
attributes: Attributes;
|
| 51 |
+
setAttributes: ( attributes: Record< string, unknown > ) => undefined;
|
| 52 |
+
} ): JSX.Element => {
|
| 53 |
+
const { isShippingCalculatorEnabled, showRateAfterTaxName } = attributes;
|
| 54 |
+
const { currentPostId } = useEditorContext();
|
| 55 |
+
return (
|
| 56 |
+
<InspectorControls>
|
| 57 |
+
{ currentPostId !== CART_PAGE_ID && (
|
| 58 |
+
<Notice
|
| 59 |
+
className="wc-block-cart__page-notice"
|
| 60 |
+
isDismissible={ false }
|
| 61 |
+
status="warning"
|
| 62 |
+
>
|
| 63 |
+
{ createInterpolateElement(
|
| 64 |
+
__(
|
| 65 |
+
'If you would like to use this block as your default cart you must update your <a>page settings in WooCommerce</a>.',
|
| 66 |
+
'woo-gutenberg-products-block'
|
| 67 |
+
),
|
| 68 |
+
{
|
| 69 |
+
a: (
|
| 70 |
+
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
| 71 |
+
<a
|
| 72 |
+
href={ getAdminLink(
|
| 73 |
+
'admin.php?page=wc-settings&tab=advanced'
|
| 74 |
+
) }
|
| 75 |
+
target="_blank"
|
| 76 |
+
rel="noopener noreferrer"
|
| 77 |
+
/>
|
| 78 |
+
),
|
| 79 |
+
}
|
| 80 |
+
) }
|
| 81 |
+
</Notice>
|
| 82 |
+
) }
|
| 83 |
+
{ getSetting( 'shippingEnabled', true ) && (
|
| 84 |
+
<PanelBody
|
| 85 |
+
title={ __(
|
| 86 |
+
'Shipping rates',
|
| 87 |
+
'woo-gutenberg-products-block'
|
| 88 |
+
) }
|
| 89 |
+
>
|
| 90 |
+
<ToggleControl
|
| 91 |
+
label={ __(
|
| 92 |
+
'Shipping calculator',
|
| 93 |
+
'woo-gutenberg-products-block'
|
| 94 |
+
) }
|
| 95 |
+
help={ __(
|
| 96 |
+
'Allow customers to estimate shipping by entering their address.',
|
| 97 |
+
'woo-gutenberg-products-block'
|
| 98 |
+
) }
|
| 99 |
+
checked={ isShippingCalculatorEnabled }
|
| 100 |
+
onChange={ () =>
|
| 101 |
+
setAttributes( {
|
| 102 |
+
isShippingCalculatorEnabled: ! isShippingCalculatorEnabled,
|
| 103 |
+
} )
|
| 104 |
+
}
|
| 105 |
+
/>
|
| 106 |
+
</PanelBody>
|
| 107 |
+
) }
|
| 108 |
+
{ getSetting( 'taxesEnabled' ) &&
|
| 109 |
+
getSetting( 'displayItemizedTaxes', false ) &&
|
| 110 |
+
! getSetting( 'displayCartPricesIncludingTax', false ) && (
|
| 111 |
+
<PanelBody
|
| 112 |
+
title={ __( 'Taxes', 'woo-gutenberg-products-block' ) }
|
| 113 |
+
>
|
| 114 |
+
<ToggleControl
|
| 115 |
+
label={ __(
|
| 116 |
+
'Show rate after tax name',
|
| 117 |
+
'woo-gutenberg-products-block'
|
| 118 |
+
) }
|
| 119 |
+
help={ __(
|
| 120 |
+
'Show the percentage rate alongside each tax line in the summary.',
|
| 121 |
+
'woo-gutenberg-products-block'
|
| 122 |
+
) }
|
| 123 |
+
checked={ showRateAfterTaxName }
|
| 124 |
+
onChange={ () =>
|
| 125 |
+
setAttributes( {
|
| 126 |
+
showRateAfterTaxName: ! showRateAfterTaxName,
|
| 127 |
+
} )
|
| 128 |
+
}
|
| 129 |
+
/>
|
| 130 |
+
</PanelBody>
|
| 131 |
+
) }
|
| 132 |
+
<CartCheckoutFeedbackPrompt />
|
| 133 |
+
</InspectorControls>
|
| 134 |
+
);
|
| 135 |
+
};
|
| 136 |
+
|
| 137 |
+
/**
|
| 138 |
+
* Component to handle edit mode of "Cart Block".
|
| 139 |
+
*/
|
| 140 |
+
export const Edit = ( {
|
| 141 |
+
className,
|
| 142 |
+
attributes,
|
| 143 |
+
setAttributes,
|
| 144 |
+
clientId,
|
| 145 |
+
}: {
|
| 146 |
+
className: string;
|
| 147 |
+
attributes: Attributes;
|
| 148 |
+
setAttributes: ( attributes: Record< string, unknown > ) => undefined;
|
| 149 |
+
clientId: string;
|
| 150 |
+
} ): JSX.Element => {
|
| 151 |
+
const { currentView, component: ViewSwitcherComponent } = useViewSwitcher(
|
| 152 |
+
clientId,
|
| 153 |
+
[
|
| 154 |
+
{
|
| 155 |
+
view: 'woocommerce/filled-cart-block',
|
| 156 |
+
label: __( 'Filled Cart', 'woo-gutenberg-products-block' ),
|
| 157 |
+
icon: <Icon srcElement={ filledCart } />,
|
| 158 |
+
},
|
| 159 |
+
{
|
| 160 |
+
view: 'woocommerce/empty-cart-block',
|
| 161 |
+
label: __( 'Empty Cart', 'woo-gutenberg-products-block' ),
|
| 162 |
+
icon: <Icon srcElement={ removeCart } />,
|
| 163 |
+
},
|
| 164 |
+
]
|
| 165 |
+
);
|
| 166 |
+
const cartClassName = classnames( {
|
| 167 |
+
'has-dark-controls': attributes.hasDarkControls,
|
| 168 |
+
} );
|
| 169 |
+
const defaultInnerBlocksTemplate = [
|
| 170 |
+
[
|
| 171 |
+
'woocommerce/filled-cart-block',
|
| 172 |
+
{},
|
| 173 |
+
[
|
| 174 |
+
[
|
| 175 |
+
'woocommerce/cart-items-block',
|
| 176 |
+
{},
|
| 177 |
+
[ [ 'woocommerce/cart-line-items-block', {}, [] ] ],
|
| 178 |
+
],
|
| 179 |
+
[
|
| 180 |
+
'woocommerce/cart-totals-block',
|
| 181 |
+
{},
|
| 182 |
+
[
|
| 183 |
+
[ 'woocommerce/cart-order-summary-block', {}, [] ],
|
| 184 |
+
[ 'woocommerce/cart-express-payment-block', {}, [] ],
|
| 185 |
+
[ 'woocommerce/proceed-to-checkout-block', {}, [] ],
|
| 186 |
+
],
|
| 187 |
+
],
|
| 188 |
+
],
|
| 189 |
+
],
|
| 190 |
+
[ 'woocommerce/empty-cart-block', {}, [] ],
|
| 191 |
+
];
|
| 192 |
+
const blockProps = useBlockPropsWithLocking( {
|
| 193 |
+
className: classnames( className, 'wp-block-woocommerce-cart', {
|
| 194 |
+
'is-editor-preview': attributes.isPreview,
|
| 195 |
+
} ),
|
| 196 |
+
} );
|
| 197 |
+
|
| 198 |
+
return (
|
| 199 |
+
<div { ...blockProps }>
|
| 200 |
+
<BlockErrorBoundary
|
| 201 |
+
header={ __(
|
| 202 |
+
'Cart Block Error',
|
| 203 |
+
'woo-gutenberg-products-block'
|
| 204 |
+
) }
|
| 205 |
+
text={ __(
|
| 206 |
+
'There was an error whilst rendering the cart block. If this problem continues, try re-creating the block.',
|
| 207 |
+
'woo-gutenberg-products-block'
|
| 208 |
+
) }
|
| 209 |
+
showErrorMessage={ true }
|
| 210 |
+
errorMessagePrefix={ __(
|
| 211 |
+
'Error message:',
|
| 212 |
+
'woo-gutenberg-products-block'
|
| 213 |
+
) }
|
| 214 |
+
>
|
| 215 |
+
<EditorProvider previewData={ { previewCart } }>
|
| 216 |
+
<BlockSettings
|
| 217 |
+
attributes={ attributes }
|
| 218 |
+
setAttributes={ setAttributes }
|
| 219 |
+
/>
|
| 220 |
+
<BlockControls __experimentalShareWithChildBlocks>
|
| 221 |
+
<ViewSwitcherComponent />
|
| 222 |
+
</BlockControls>
|
| 223 |
+
<CartBlockContext.Provider
|
| 224 |
+
value={ {
|
| 225 |
+
currentView,
|
| 226 |
+
} }
|
| 227 |
+
>
|
| 228 |
+
<CartProvider>
|
| 229 |
+
<div className={ cartClassName }>
|
| 230 |
+
<InnerBlocks
|
| 231 |
+
allowedBlocks={ ALLOWED_BLOCKS }
|
| 232 |
+
template={ defaultInnerBlocksTemplate }
|
| 233 |
+
templateLock="insert"
|
| 234 |
+
/>
|
| 235 |
+
</div>
|
| 236 |
+
</CartProvider>
|
| 237 |
+
</CartBlockContext.Provider>
|
| 238 |
+
</EditorProvider>
|
| 239 |
+
</BlockErrorBoundary>
|
| 240 |
+
<CartCheckoutCompatibilityNotice blockName="cart" />
|
| 241 |
+
</div>
|
| 242 |
+
);
|
| 243 |
+
};
|
| 244 |
+
|
| 245 |
+
export const Save = (): JSX.Element => {
|
| 246 |
+
return (
|
| 247 |
+
<div
|
| 248 |
+
{ ...useBlockProps.save( {
|
| 249 |
+
className: 'wc-block-cart is-loading',
|
| 250 |
+
} ) }
|
| 251 |
+
>
|
| 252 |
+
<InnerBlocks.Content />
|
| 253 |
+
</div>
|
| 254 |
+
);
|
| 255 |
+
};
|
assets/js/blocks/cart-checkout/{checkout-i2 → cart-i2}/editor-utils.ts
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/cart-i2/editor.scss
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.wc-block-cart__page-notice {
|
| 2 |
+
margin: 0;
|
| 3 |
+
}
|
| 4 |
+
|
| 5 |
+
body.wc-lock-selected-block--move {
|
| 6 |
+
.block-editor-block-mover__move-button-container,
|
| 7 |
+
.block-editor-block-mover {
|
| 8 |
+
display: none;
|
| 9 |
+
}
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
body.wc-lock-selected-block--remove {
|
| 13 |
+
.block-editor-block-settings-menu__popover {
|
| 14 |
+
.components-menu-group:last-child {
|
| 15 |
+
display: none;
|
| 16 |
+
}
|
| 17 |
+
.components-menu-group:nth-last-child(2) {
|
| 18 |
+
margin-bottom: -12px;
|
| 19 |
+
}
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
|
assets/js/blocks/cart-checkout/cart-i2/empty-cart-edit/icon-data-uri.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
| 1 |
+
export default 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzgiIGhlaWdodD0iMzgiIHZpZXdCb3g9IjAgMCAzOCAzOCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTE5IDBDOC41MDQwMyAwIDAgOC41MDQwMyAwIDE5QzAgMjkuNDk2IDguNTA0MDMgMzggMTkgMzhDMjkuNDk2IDM4IDM4IDI5LjQ5NiAzOCAxOUMzOCA4LjUwNDAzIDI5LjQ5NiAwIDE5IDBaTTI1LjEyOSAxMi44NzFDMjYuNDg1MSAxMi44NzEgMjcuNTgwNiAxMy45NjY1IDI3LjU4MDYgMTUuMzIyNkMyNy41ODA2IDE2LjY3ODYgMjYuNDg1MSAxNy43NzQyIDI1LjEyOSAxNy43NzQyQzIzLjc3MyAxNy43NzQyIDIyLjY3NzQgMTYuNjc4NiAyMi42Nzc0IDE1LjMyMjZDMjIuNjc3NCAxMy45NjY1IDIzLjc3MyAxMi44NzEgMjUuMTI5IDEyLjg3MVpNMTEuNjQ1MiAzMS4yNTgxQzkuNjE0OTIgMzEuMjU4MSA3Ljk2Nzc0IDI5LjY0OTIgNy45Njc3NCAyNy42NTczQzcuOTY3NzQgMjYuMTI1IDEwLjE1MTIgMjMuMDI5OCAxMS4xNTQ4IDIxLjY5NjhDMTEuNCAyMS4zNjczIDExLjg5MDMgMjEuMzY3MyAxMi4xMzU1IDIxLjY5NjhDMTMuMTM5MSAyMy4wMjk4IDE1LjMyMjYgMjYuMTI1IDE1LjMyMjYgMjcuNjU3M0MxNS4zMjI2IDI5LjY0OTIgMTMuNjc1NCAzMS4yNTgxIDExLjY0NTIgMzEuMjU4MVpNMTIuODcxIDE3Ljc3NDJDMTEuNTE0OSAxNy43NzQyIDEwLjQxOTQgMTYuNjc4NiAxMC40MTk0IDE1LjMyMjZDMTAuNDE5NCAxMy45NjY1IDExLjUxNDkgMTIuODcxIDEyLjg3MSAxMi44NzFDMTQuMjI3IDEyLjg3MSAxNS4zMjI2IDEzLjk2NjUgMTUuMzIyNiAxNS4zMjI2QzE1LjMyMjYgMTYuNjc4NiAxNC4yMjcgMTcuNzc0MiAxMi44NzEgMTcuNzc0MlpNMjUuOTEwNSAyOS41ODc5QzI0LjE5NDQgMjcuNTM0NyAyMS42NzM4IDI2LjM1NDggMTkgMjYuMzU0OEMxNy4zNzU4IDI2LjM1NDggMTcuMzc1OCAyMy45MDMyIDE5IDIzLjkwMzJDMjIuNDAxNiAyMy45MDMyIDI1LjYxMTcgMjUuNDA0OCAyNy43ODc1IDI4LjAyNUMyOC44NDQ4IDI5LjI4MTUgMjYuOTI5NCAzMC44MjE0IDI1LjkxMDUgMjkuNTg3OVoiIGZpbGw9ImJsYWNrIi8+Cjwvc3ZnPgo=';
|
assets/js/blocks/cart-checkout/cart-i2/empty-cart-edit/index.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { __, sprintf } from '@wordpress/i18n';
|
| 5 |
+
import { InnerBlocks } from '@wordpress/block-editor';
|
| 6 |
+
import { SHOP_URL } from '@woocommerce/block-settings';
|
| 7 |
+
import PropTypes from 'prop-types';
|
| 8 |
+
|
| 9 |
+
/**
|
| 10 |
+
* Internal dependencies
|
| 11 |
+
*/
|
| 12 |
+
import iconDataUri from './icon-data-uri.js';
|
| 13 |
+
import './style.scss';
|
| 14 |
+
|
| 15 |
+
const templateItemBrowseStore = SHOP_URL
|
| 16 |
+
? [
|
| 17 |
+
'core/paragraph',
|
| 18 |
+
{
|
| 19 |
+
align: 'center',
|
| 20 |
+
content: sprintf(
|
| 21 |
+
/* translators: %s is the link to the store product directory. */
|
| 22 |
+
__(
|
| 23 |
+
'<a href="%s">Browse store</a>.',
|
| 24 |
+
'woo-gutenberg-products-block'
|
| 25 |
+
),
|
| 26 |
+
SHOP_URL
|
| 27 |
+
),
|
| 28 |
+
dropCap: false,
|
| 29 |
+
},
|
| 30 |
+
]
|
| 31 |
+
: null;
|
| 32 |
+
|
| 33 |
+
const templateItems = [
|
| 34 |
+
[
|
| 35 |
+
'core/image',
|
| 36 |
+
{
|
| 37 |
+
align: 'center',
|
| 38 |
+
url: iconDataUri,
|
| 39 |
+
sizeSlug: 'small',
|
| 40 |
+
},
|
| 41 |
+
],
|
| 42 |
+
[
|
| 43 |
+
'core/heading',
|
| 44 |
+
{
|
| 45 |
+
textAlign: 'center',
|
| 46 |
+
content: __(
|
| 47 |
+
'Your cart is currently empty!',
|
| 48 |
+
'woo-gutenberg-products-block'
|
| 49 |
+
),
|
| 50 |
+
level: 2,
|
| 51 |
+
className: 'wc-block-cart__empty-cart__title',
|
| 52 |
+
},
|
| 53 |
+
],
|
| 54 |
+
templateItemBrowseStore,
|
| 55 |
+
[
|
| 56 |
+
'core/separator',
|
| 57 |
+
{
|
| 58 |
+
className: 'is-style-dots',
|
| 59 |
+
},
|
| 60 |
+
],
|
| 61 |
+
[
|
| 62 |
+
'core/heading',
|
| 63 |
+
{
|
| 64 |
+
textAlign: 'center',
|
| 65 |
+
content: __( 'New in store', 'woo-gutenberg-products-block' ),
|
| 66 |
+
level: 2,
|
| 67 |
+
},
|
| 68 |
+
],
|
| 69 |
+
[
|
| 70 |
+
'woocommerce/product-new',
|
| 71 |
+
{
|
| 72 |
+
columns: 3,
|
| 73 |
+
rows: 1,
|
| 74 |
+
},
|
| 75 |
+
],
|
| 76 |
+
].filter( Boolean );
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* Component to handle edit mode for the Cart block when cart is empty.
|
| 80 |
+
*
|
| 81 |
+
* @param {Object} props Incoming props for the component.
|
| 82 |
+
* @param {boolean} props.hidden Whether this component is hidden or not.
|
| 83 |
+
*/
|
| 84 |
+
const EmptyCartEdit = ( { hidden = false } ) => {
|
| 85 |
+
return (
|
| 86 |
+
<div hidden={ hidden }>
|
| 87 |
+
<InnerBlocks
|
| 88 |
+
templateInsertUpdatesSelection={ false }
|
| 89 |
+
template={ templateItems }
|
| 90 |
+
/>
|
| 91 |
+
</div>
|
| 92 |
+
);
|
| 93 |
+
};
|
| 94 |
+
|
| 95 |
+
EmptyCartEdit.propTypes = {
|
| 96 |
+
hidden: PropTypes.bool,
|
| 97 |
+
};
|
| 98 |
+
|
| 99 |
+
export default EmptyCartEdit;
|
assets/js/blocks/cart-checkout/cart-i2/empty-cart-edit/style.scss
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.wc-block-cart__empty-cart__title,
|
| 2 |
+
.editor-styles-wrapper .wc-block-cart__empty-cart__title {
|
| 3 |
+
font-size: inherit;
|
| 4 |
+
}
|
assets/js/blocks/cart-checkout/cart-i2/frontend.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import {
|
| 5 |
+
withStoreCartApiHydration,
|
| 6 |
+
withRestApiHydration,
|
| 7 |
+
} from '@woocommerce/block-hocs';
|
| 8 |
+
import { getValidBlockAttributes } from '@woocommerce/base-utils';
|
| 9 |
+
import { Children, cloneElement, isValidElement } from '@wordpress/element';
|
| 10 |
+
import { useStoreCart } from '@woocommerce/base-context';
|
| 11 |
+
import { useValidation } from '@woocommerce/base-context/hooks';
|
| 12 |
+
import { getRegisteredBlockComponents } from '@woocommerce/blocks-registry';
|
| 13 |
+
|
| 14 |
+
import { renderParentBlock } from '@woocommerce/atomic-utils';
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* Internal dependencies
|
| 18 |
+
*/
|
| 19 |
+
import './inner-blocks/register-components';
|
| 20 |
+
import Block from './block';
|
| 21 |
+
import { blockName, blockAttributes } from './attributes';
|
| 22 |
+
|
| 23 |
+
const getProps = ( el ) => {
|
| 24 |
+
return {
|
| 25 |
+
attributes: getValidBlockAttributes(
|
| 26 |
+
blockAttributes,
|
| 27 |
+
!! el ? el.dataset : {}
|
| 28 |
+
),
|
| 29 |
+
};
|
| 30 |
+
};
|
| 31 |
+
|
| 32 |
+
const Wrapper = ( { children } ) => {
|
| 33 |
+
// we need to pluck out receiveCart.
|
| 34 |
+
// eslint-disable-next-line no-unused-vars
|
| 35 |
+
const { extensions, receiveCart, ...cart } = useStoreCart();
|
| 36 |
+
const validation = useValidation();
|
| 37 |
+
return Children.map( children, ( child ) => {
|
| 38 |
+
if ( isValidElement( child ) ) {
|
| 39 |
+
const componentProps = {
|
| 40 |
+
extensions,
|
| 41 |
+
cart,
|
| 42 |
+
validation,
|
| 43 |
+
};
|
| 44 |
+
return cloneElement( child, componentProps );
|
| 45 |
+
}
|
| 46 |
+
return child;
|
| 47 |
+
} );
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
renderParentBlock( {
|
| 51 |
+
Block: withStoreCartApiHydration( withRestApiHydration( Block ) ),
|
| 52 |
+
blockName,
|
| 53 |
+
selector: '.wp-block-woocommerce-cart-i2',
|
| 54 |
+
getProps,
|
| 55 |
+
blockMap: getRegisteredBlockComponents( blockName ),
|
| 56 |
+
blockWrapper: Wrapper,
|
| 57 |
+
} );
|
assets/js/blocks/cart-checkout/cart-i2/full-cart/cart-line-item-row.tsx
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import classnames from 'classnames';
|
| 5 |
+
import { __ } from '@wordpress/i18n';
|
| 6 |
+
import QuantitySelector from '@woocommerce/base-components/quantity-selector';
|
| 7 |
+
import ProductPrice from '@woocommerce/base-components/product-price';
|
| 8 |
+
import ProductName from '@woocommerce/base-components/product-name';
|
| 9 |
+
import {
|
| 10 |
+
useStoreCartItemQuantity,
|
| 11 |
+
useStoreEvents,
|
| 12 |
+
useStoreCart,
|
| 13 |
+
} from '@woocommerce/base-context/hooks';
|
| 14 |
+
import {
|
| 15 |
+
ProductBackorderBadge,
|
| 16 |
+
ProductImage,
|
| 17 |
+
ProductLowStockBadge,
|
| 18 |
+
ProductMetadata,
|
| 19 |
+
ProductSaleBadge,
|
| 20 |
+
} from '@woocommerce/base-components/cart-checkout';
|
| 21 |
+
import {
|
| 22 |
+
getCurrencyFromPriceResponse,
|
| 23 |
+
Currency,
|
| 24 |
+
} from '@woocommerce/price-format';
|
| 25 |
+
import {
|
| 26 |
+
__experimentalApplyCheckoutFilter,
|
| 27 |
+
mustContain,
|
| 28 |
+
} from '@woocommerce/blocks-checkout';
|
| 29 |
+
import Dinero from 'dinero.js';
|
| 30 |
+
import { useMemo } from '@wordpress/element';
|
| 31 |
+
import type { CartItem } from '@woocommerce/type-defs/cart';
|
| 32 |
+
import { objectHasProp } from '@woocommerce/types';
|
| 33 |
+
import { getSetting } from '@woocommerce/settings';
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* Convert a Dinero object with precision to store currency minor unit.
|
| 37 |
+
*
|
| 38 |
+
* @param {Dinero} priceObject Price object to convert.
|
| 39 |
+
* @param {Object} currency Currency data.
|
| 40 |
+
* @return {number} Amount with new minor unit precision.
|
| 41 |
+
*/
|
| 42 |
+
const getAmountFromRawPrice = (
|
| 43 |
+
priceObject: Dinero.Dinero,
|
| 44 |
+
currency: Currency
|
| 45 |
+
) => {
|
| 46 |
+
return priceObject.convertPrecision( currency.minorUnit ).getAmount();
|
| 47 |
+
};
|
| 48 |
+
|
| 49 |
+
const productPriceValidation = ( value ) => mustContain( value, '<price/>' );
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* Cart line item table row component.
|
| 53 |
+
*
|
| 54 |
+
* @param {Object} props
|
| 55 |
+
* @param {CartItem|Object} props.lineItem
|
| 56 |
+
*/
|
| 57 |
+
const CartLineItemRow = ( {
|
| 58 |
+
lineItem,
|
| 59 |
+
}: {
|
| 60 |
+
lineItem: CartItem | Record< string, never >;
|
| 61 |
+
} ): JSX.Element => {
|
| 62 |
+
const {
|
| 63 |
+
name: initialName = '',
|
| 64 |
+
catalog_visibility: catalogVisibility = 'visible',
|
| 65 |
+
short_description: shortDescription = '',
|
| 66 |
+
description: fullDescription = '',
|
| 67 |
+
low_stock_remaining: lowStockRemaining = null,
|
| 68 |
+
show_backorder_badge: showBackorderBadge = false,
|
| 69 |
+
quantity_limit: quantityLimit = 99,
|
| 70 |
+
permalink = '',
|
| 71 |
+
images = [],
|
| 72 |
+
variation = [],
|
| 73 |
+
item_data: itemData = [],
|
| 74 |
+
prices = {
|
| 75 |
+
currency_code: 'USD',
|
| 76 |
+
currency_minor_unit: 2,
|
| 77 |
+
currency_symbol: '$',
|
| 78 |
+
currency_prefix: '$',
|
| 79 |
+
currency_suffix: '',
|
| 80 |
+
currency_decimal_separator: '.',
|
| 81 |
+
currency_thousand_separator: ',',
|
| 82 |
+
price: '0',
|
| 83 |
+
regular_price: '0',
|
| 84 |
+
sale_price: '0',
|
| 85 |
+
price_range: null,
|
| 86 |
+
raw_prices: {
|
| 87 |
+
precision: 6,
|
| 88 |
+
price: '0',
|
| 89 |
+
regular_price: '0',
|
| 90 |
+
sale_price: '0',
|
| 91 |
+
},
|
| 92 |
+
},
|
| 93 |
+
totals = {
|
| 94 |
+
currency_code: 'USD',
|
| 95 |
+
currency_minor_unit: 2,
|
| 96 |
+
currency_symbol: '$',
|
| 97 |
+
currency_prefix: '$',
|
| 98 |
+
currency_suffix: '',
|
| 99 |
+
currency_decimal_separator: '.',
|
| 100 |
+
currency_thousand_separator: ',',
|
| 101 |
+
line_subtotal: '0',
|
| 102 |
+
line_subtotal_tax: '0',
|
| 103 |
+
},
|
| 104 |
+
extensions,
|
| 105 |
+
} = lineItem;
|
| 106 |
+
|
| 107 |
+
const {
|
| 108 |
+
quantity,
|
| 109 |
+
setItemQuantity,
|
| 110 |
+
removeItem,
|
| 111 |
+
isPendingDelete,
|
| 112 |
+
} = useStoreCartItemQuantity( lineItem );
|
| 113 |
+
const { dispatchStoreEvent } = useStoreEvents();
|
| 114 |
+
|
| 115 |
+
// Prepare props to pass to the __experimentalApplyCheckoutFilter filter.
|
| 116 |
+
// We need to pluck out receiveCart.
|
| 117 |
+
// eslint-disable-next-line no-unused-vars
|
| 118 |
+
const { receiveCart, ...cart } = useStoreCart();
|
| 119 |
+
const arg = useMemo(
|
| 120 |
+
() => ( {
|
| 121 |
+
context: 'cart',
|
| 122 |
+
cartItem: lineItem,
|
| 123 |
+
cart,
|
| 124 |
+
} ),
|
| 125 |
+
[ lineItem, cart ]
|
| 126 |
+
);
|
| 127 |
+
const priceCurrency = getCurrencyFromPriceResponse( prices );
|
| 128 |
+
const name = __experimentalApplyCheckoutFilter( {
|
| 129 |
+
filterName: 'itemName',
|
| 130 |
+
defaultValue: initialName,
|
| 131 |
+
extensions,
|
| 132 |
+
arg,
|
| 133 |
+
} );
|
| 134 |
+
|
| 135 |
+
const regularAmountSingle = Dinero( {
|
| 136 |
+
amount: parseInt( prices.raw_prices.regular_price, 10 ),
|
| 137 |
+
precision: prices.raw_prices.precision,
|
| 138 |
+
} );
|
| 139 |
+
const purchaseAmountSingle = Dinero( {
|
| 140 |
+
amount: parseInt( prices.raw_prices.price, 10 ),
|
| 141 |
+
precision: prices.raw_prices.precision,
|
| 142 |
+
} );
|
| 143 |
+
const saleAmountSingle = regularAmountSingle.subtract(
|
| 144 |
+
purchaseAmountSingle
|
| 145 |
+
);
|
| 146 |
+
const saleAmount = saleAmountSingle.multiply( quantity );
|
| 147 |
+
const totalsCurrency = getCurrencyFromPriceResponse( totals );
|
| 148 |
+
let lineSubtotal = parseInt( totals.line_subtotal, 10 );
|
| 149 |
+
if ( getSetting( 'displayCartPricesIncludingTax', false ) ) {
|
| 150 |
+
lineSubtotal += parseInt( totals.line_subtotal_tax, 10 );
|
| 151 |
+
}
|
| 152 |
+
const subtotalPrice = Dinero( {
|
| 153 |
+
amount: lineSubtotal,
|
| 154 |
+
precision: totalsCurrency.minorUnit,
|
| 155 |
+
} );
|
| 156 |
+
|
| 157 |
+
const firstImage = images.length ? images[ 0 ] : {};
|
| 158 |
+
const isProductHiddenFromCatalog =
|
| 159 |
+
catalogVisibility === 'hidden' || catalogVisibility === 'search';
|
| 160 |
+
|
| 161 |
+
// Allow extensions to filter how the price is displayed. Ie: prepending or appending some values.
|
| 162 |
+
|
| 163 |
+
const productPriceFormat = __experimentalApplyCheckoutFilter( {
|
| 164 |
+
filterName: 'cartItemPrice',
|
| 165 |
+
defaultValue: '<price/>',
|
| 166 |
+
extensions,
|
| 167 |
+
arg,
|
| 168 |
+
validation: productPriceValidation,
|
| 169 |
+
} );
|
| 170 |
+
|
| 171 |
+
const subtotalPriceFormat = __experimentalApplyCheckoutFilter( {
|
| 172 |
+
filterName: 'subtotalPriceFormat',
|
| 173 |
+
defaultValue: '<price/>',
|
| 174 |
+
extensions,
|
| 175 |
+
arg,
|
| 176 |
+
validation: productPriceValidation,
|
| 177 |
+
} );
|
| 178 |
+
|
| 179 |
+
const saleBadgePriceFormat = __experimentalApplyCheckoutFilter( {
|
| 180 |
+
filterName: 'saleBadgePriceFormat',
|
| 181 |
+
defaultValue: '<price/>',
|
| 182 |
+
extensions,
|
| 183 |
+
arg,
|
| 184 |
+
validation: productPriceValidation,
|
| 185 |
+
} );
|
| 186 |
+
|
| 187 |
+
return (
|
| 188 |
+
<tr
|
| 189 |
+
className={ classnames( 'wc-block-cart-items__row', {
|
| 190 |
+
'is-disabled': isPendingDelete,
|
| 191 |
+
} ) }
|
| 192 |
+
>
|
| 193 |
+
{ /* If the image has no alt text, this link is unnecessary and can be hidden. */ }
|
| 194 |
+
<td
|
| 195 |
+
className="wc-block-cart-item__image"
|
| 196 |
+
aria-hidden={
|
| 197 |
+
! objectHasProp( firstImage, 'alt' ) || ! firstImage.alt
|
| 198 |
+
}
|
| 199 |
+
>
|
| 200 |
+
{ /* We don't need to make it focusable, because product name has the same link. */ }
|
| 201 |
+
{ isProductHiddenFromCatalog ? (
|
| 202 |
+
<ProductImage image={ firstImage } />
|
| 203 |
+
) : (
|
| 204 |
+
<a href={ permalink } tabIndex={ -1 }>
|
| 205 |
+
<ProductImage image={ firstImage } />
|
| 206 |
+
</a>
|
| 207 |
+
) }
|
| 208 |
+
</td>
|
| 209 |
+
<td className="wc-block-cart-item__product">
|
| 210 |
+
<ProductName
|
| 211 |
+
disabled={ isPendingDelete || isProductHiddenFromCatalog }
|
| 212 |
+
name={ name }
|
| 213 |
+
permalink={ permalink }
|
| 214 |
+
/>
|
| 215 |
+
{ showBackorderBadge ? (
|
| 216 |
+
<ProductBackorderBadge />
|
| 217 |
+
) : (
|
| 218 |
+
!! lowStockRemaining && (
|
| 219 |
+
<ProductLowStockBadge
|
| 220 |
+
lowStockRemaining={ lowStockRemaining }
|
| 221 |
+
/>
|
| 222 |
+
)
|
| 223 |
+
) }
|
| 224 |
+
|
| 225 |
+
<div className="wc-block-cart-item__prices">
|
| 226 |
+
<ProductPrice
|
| 227 |
+
currency={ priceCurrency }
|
| 228 |
+
regularPrice={ getAmountFromRawPrice(
|
| 229 |
+
regularAmountSingle,
|
| 230 |
+
priceCurrency
|
| 231 |
+
) }
|
| 232 |
+
price={ getAmountFromRawPrice(
|
| 233 |
+
purchaseAmountSingle,
|
| 234 |
+
priceCurrency
|
| 235 |
+
) }
|
| 236 |
+
format={ subtotalPriceFormat }
|
| 237 |
+
/>
|
| 238 |
+
</div>
|
| 239 |
+
|
| 240 |
+
<ProductSaleBadge
|
| 241 |
+
currency={ priceCurrency }
|
| 242 |
+
saleAmount={ getAmountFromRawPrice(
|
| 243 |
+
saleAmountSingle,
|
| 244 |
+
priceCurrency
|
| 245 |
+
) }
|
| 246 |
+
format={ saleBadgePriceFormat }
|
| 247 |
+
/>
|
| 248 |
+
|
| 249 |
+
<ProductMetadata
|
| 250 |
+
shortDescription={ shortDescription }
|
| 251 |
+
fullDescription={ fullDescription }
|
| 252 |
+
itemData={ itemData }
|
| 253 |
+
variation={ variation }
|
| 254 |
+
/>
|
| 255 |
+
|
| 256 |
+
<div className="wc-block-cart-item__quantity">
|
| 257 |
+
<QuantitySelector
|
| 258 |
+
disabled={ isPendingDelete }
|
| 259 |
+
quantity={ quantity }
|
| 260 |
+
maximum={ quantityLimit }
|
| 261 |
+
onChange={ ( newQuantity ) => {
|
| 262 |
+
setItemQuantity( newQuantity );
|
| 263 |
+
dispatchStoreEvent( 'cart-set-item-quantity', {
|
| 264 |
+
product: lineItem,
|
| 265 |
+
quantity: newQuantity,
|
| 266 |
+
} );
|
| 267 |
+
} }
|
| 268 |
+
itemName={ name }
|
| 269 |
+
/>
|
| 270 |
+
<button
|
| 271 |
+
className="wc-block-cart-item__remove-link"
|
| 272 |
+
onClick={ () => {
|
| 273 |
+
removeItem();
|
| 274 |
+
dispatchStoreEvent( 'cart-remove-item', {
|
| 275 |
+
product: lineItem,
|
| 276 |
+
quantity,
|
| 277 |
+
} );
|
| 278 |
+
} }
|
| 279 |
+
disabled={ isPendingDelete }
|
| 280 |
+
>
|
| 281 |
+
{ __( 'Remove item', 'woo-gutenberg-products-block' ) }
|
| 282 |
+
</button>
|
| 283 |
+
</div>
|
| 284 |
+
</td>
|
| 285 |
+
<td className="wc-block-cart-item__total">
|
| 286 |
+
<div className="wc-block-cart-item__total-price-and-sale-badge-wrapper">
|
| 287 |
+
<ProductPrice
|
| 288 |
+
currency={ totalsCurrency }
|
| 289 |
+
format={ productPriceFormat }
|
| 290 |
+
price={ subtotalPrice.getAmount() }
|
| 291 |
+
/>
|
| 292 |
+
|
| 293 |
+
{ quantity > 1 && (
|
| 294 |
+
<ProductSaleBadge
|
| 295 |
+
currency={ priceCurrency }
|
| 296 |
+
saleAmount={ getAmountFromRawPrice(
|
| 297 |
+
saleAmount,
|
| 298 |
+
priceCurrency
|
| 299 |
+
) }
|
| 300 |
+
format={ saleBadgePriceFormat }
|
| 301 |
+
/>
|
| 302 |
+
) }
|
| 303 |
+
</div>
|
| 304 |
+
</td>
|
| 305 |
+
</tr>
|
| 306 |
+
);
|
| 307 |
+
};
|
| 308 |
+
|
| 309 |
+
export default CartLineItemRow;
|
assets/js/blocks/cart-checkout/cart-i2/full-cart/cart-line-items-table.tsx
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { __ } from '@wordpress/i18n';
|
| 5 |
+
import { CartResponseItem } from '@woocommerce/type-defs/cart-response';
|
| 6 |
+
|
| 7 |
+
/**
|
| 8 |
+
* Internal dependencies
|
| 9 |
+
*/
|
| 10 |
+
import CartLineItemRow from './cart-line-item-row';
|
| 11 |
+
|
| 12 |
+
const placeholderRows = [ ...Array( 3 ) ].map( ( _x, i ) => (
|
| 13 |
+
<CartLineItemRow lineItem={ {} } key={ i } />
|
| 14 |
+
) );
|
| 15 |
+
|
| 16 |
+
interface CartLineItemsTableProps {
|
| 17 |
+
lineItems: CartResponseItem[];
|
| 18 |
+
isLoading: boolean;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
const CartLineItemsTable = ( {
|
| 22 |
+
lineItems = [],
|
| 23 |
+
isLoading = false,
|
| 24 |
+
}: CartLineItemsTableProps ): JSX.Element => {
|
| 25 |
+
const products = isLoading
|
| 26 |
+
? placeholderRows
|
| 27 |
+
: lineItems.map( ( lineItem ) => {
|
| 28 |
+
return (
|
| 29 |
+
<CartLineItemRow
|
| 30 |
+
key={ lineItem.key }
|
| 31 |
+
lineItem={ lineItem }
|
| 32 |
+
/>
|
| 33 |
+
);
|
| 34 |
+
} );
|
| 35 |
+
|
| 36 |
+
return (
|
| 37 |
+
<table className="wc-block-cart-items">
|
| 38 |
+
<thead>
|
| 39 |
+
<tr className="wc-block-cart-items__header">
|
| 40 |
+
<th className="wc-block-cart-items__header-image">
|
| 41 |
+
<span>
|
| 42 |
+
{ __( 'Product', 'woo-gutenberg-products-block' ) }
|
| 43 |
+
</span>
|
| 44 |
+
</th>
|
| 45 |
+
<th className="wc-block-cart-items__header-product">
|
| 46 |
+
<span>
|
| 47 |
+
{ __( 'Details', 'woo-gutenberg-products-block' ) }
|
| 48 |
+
</span>
|
| 49 |
+
</th>
|
| 50 |
+
<th className="wc-block-cart-items__header-total">
|
| 51 |
+
<span>
|
| 52 |
+
{ __( 'Total', 'woo-gutenberg-products-block' ) }
|
| 53 |
+
</span>
|
| 54 |
+
</th>
|
| 55 |
+
</tr>
|
| 56 |
+
</thead>
|
| 57 |
+
<tbody>{ products }</tbody>
|
| 58 |
+
</table>
|
| 59 |
+
);
|
| 60 |
+
};
|
| 61 |
+
|
| 62 |
+
export default CartLineItemsTable;
|
assets/js/blocks/cart-checkout/cart-i2/full-cart/cart-line-items-title.tsx
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { _n, sprintf } from '@wordpress/i18n';
|
| 5 |
+
import Title from '@woocommerce/base-components/title';
|
| 6 |
+
|
| 7 |
+
const CartLineItemsTitle = ( {
|
| 8 |
+
itemCount = 1,
|
| 9 |
+
}: {
|
| 10 |
+
itemCount: number;
|
| 11 |
+
} ): JSX.Element => {
|
| 12 |
+
return (
|
| 13 |
+
<Title headingLevel="2">
|
| 14 |
+
{ sprintf(
|
| 15 |
+
/* translators: %d is the count of items in the cart. */
|
| 16 |
+
_n(
|
| 17 |
+
'Your cart (%d item)',
|
| 18 |
+
'Your cart (%d items)',
|
| 19 |
+
itemCount,
|
| 20 |
+
'woo-gutenberg-products-block'
|
| 21 |
+
),
|
| 22 |
+
itemCount
|
| 23 |
+
) }
|
| 24 |
+
</Title>
|
| 25 |
+
);
|
| 26 |
+
};
|
| 27 |
+
|
| 28 |
+
export default CartLineItemsTitle;
|
assets/js/blocks/cart-checkout/cart-i2/full-cart/index.tsx
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { __ } from '@wordpress/i18n';
|
| 5 |
+
import {
|
| 6 |
+
TotalsCoupon,
|
| 7 |
+
TotalsDiscount,
|
| 8 |
+
TotalsFooterItem,
|
| 9 |
+
TotalsShipping,
|
| 10 |
+
} from '@woocommerce/base-components/cart-checkout';
|
| 11 |
+
import {
|
| 12 |
+
Subtotal,
|
| 13 |
+
TotalsFees,
|
| 14 |
+
TotalsTaxes,
|
| 15 |
+
TotalsWrapper,
|
| 16 |
+
ExperimentalOrderMeta,
|
| 17 |
+
ExperimentalDiscountsMeta,
|
| 18 |
+
} from '@woocommerce/blocks-checkout';
|
| 19 |
+
import { getCurrencyFromPriceResponse } from '@woocommerce/price-format';
|
| 20 |
+
import {
|
| 21 |
+
useStoreCartCoupons,
|
| 22 |
+
useStoreCart,
|
| 23 |
+
useStoreNotices,
|
| 24 |
+
} from '@woocommerce/base-context/hooks';
|
| 25 |
+
import classnames from 'classnames';
|
| 26 |
+
import {
|
| 27 |
+
Sidebar,
|
| 28 |
+
SidebarLayout,
|
| 29 |
+
Main,
|
| 30 |
+
} from '@woocommerce/base-components/sidebar-layout';
|
| 31 |
+
import Title from '@woocommerce/base-components/title';
|
| 32 |
+
import { getSetting } from '@woocommerce/settings';
|
| 33 |
+
import { useEffect } from '@wordpress/element';
|
| 34 |
+
import { decodeEntities } from '@wordpress/html-entities';
|
| 35 |
+
|
| 36 |
+
/**
|
| 37 |
+
* Internal dependencies
|
| 38 |
+
*/
|
| 39 |
+
import CheckoutButton from '../checkout-button';
|
| 40 |
+
import CartLineItemsTitle from './cart-line-items-title';
|
| 41 |
+
import CartLineItemsTable from './cart-line-items-table';
|
| 42 |
+
import { CartExpressPayment } from '../../payment-methods';
|
| 43 |
+
import './style.scss';
|
| 44 |
+
|
| 45 |
+
interface CartAttributes {
|
| 46 |
+
hasDarkControls: boolean;
|
| 47 |
+
isShippingCalculatorEnabled: boolean;
|
| 48 |
+
checkoutPageId: number;
|
| 49 |
+
isPreview: boolean;
|
| 50 |
+
showRateAfterTaxName: boolean;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
interface CartProps {
|
| 54 |
+
attributes: CartAttributes;
|
| 55 |
+
}
|
| 56 |
+
/**
|
| 57 |
+
* Component that renders the Cart block when user has something in cart aka "full".
|
| 58 |
+
*
|
| 59 |
+
* @param {Object} props Incoming props for the component.
|
| 60 |
+
* @param {Object} props.attributes Incoming attributes for block.
|
| 61 |
+
*/
|
| 62 |
+
const Cart = ( { attributes }: CartProps ): JSX.Element => {
|
| 63 |
+
const {
|
| 64 |
+
isShippingCalculatorEnabled,
|
| 65 |
+
hasDarkControls,
|
| 66 |
+
showRateAfterTaxName,
|
| 67 |
+
} = attributes;
|
| 68 |
+
|
| 69 |
+
const {
|
| 70 |
+
cartItems,
|
| 71 |
+
cartFees,
|
| 72 |
+
cartTotals,
|
| 73 |
+
cartIsLoading,
|
| 74 |
+
cartItemsCount,
|
| 75 |
+
cartItemErrors,
|
| 76 |
+
cartNeedsPayment,
|
| 77 |
+
cartNeedsShipping,
|
| 78 |
+
} = useStoreCart();
|
| 79 |
+
|
| 80 |
+
const {
|
| 81 |
+
applyCoupon,
|
| 82 |
+
removeCoupon,
|
| 83 |
+
isApplyingCoupon,
|
| 84 |
+
isRemovingCoupon,
|
| 85 |
+
appliedCoupons,
|
| 86 |
+
} = useStoreCartCoupons();
|
| 87 |
+
|
| 88 |
+
const { addErrorNotice } = useStoreNotices();
|
| 89 |
+
|
| 90 |
+
// Ensures any cart errors listed in the API response get shown.
|
| 91 |
+
useEffect( () => {
|
| 92 |
+
cartItemErrors.forEach( ( error ) => {
|
| 93 |
+
addErrorNotice( decodeEntities( error.message ), {
|
| 94 |
+
isDismissible: true,
|
| 95 |
+
id: error.code,
|
| 96 |
+
} );
|
| 97 |
+
} );
|
| 98 |
+
}, [ addErrorNotice, cartItemErrors ] );
|
| 99 |
+
|
| 100 |
+
const totalsCurrency = getCurrencyFromPriceResponse( cartTotals );
|
| 101 |
+
|
| 102 |
+
const cartClassName = classnames( 'wc-block-cart', {
|
| 103 |
+
'wc-block-cart--is-loading': cartIsLoading,
|
| 104 |
+
'has-dark-controls': hasDarkControls,
|
| 105 |
+
} );
|
| 106 |
+
|
| 107 |
+
// Prepare props to pass to the ExperimentalOrderMeta slot fill.
|
| 108 |
+
// We need to pluck out receiveCart.
|
| 109 |
+
// eslint-disable-next-line no-unused-vars
|
| 110 |
+
const { extensions, ...cart } = useStoreCart();
|
| 111 |
+
const slotFillProps = {
|
| 112 |
+
extensions,
|
| 113 |
+
cart,
|
| 114 |
+
};
|
| 115 |
+
|
| 116 |
+
const discountsSlotFillProps = {
|
| 117 |
+
extensions,
|
| 118 |
+
cart,
|
| 119 |
+
};
|
| 120 |
+
|
| 121 |
+
return (
|
| 122 |
+
<>
|
| 123 |
+
<CartLineItemsTitle itemCount={ cartItemsCount } />
|
| 124 |
+
<SidebarLayout className={ cartClassName }>
|
| 125 |
+
<Main className="wc-block-cart__main">
|
| 126 |
+
<CartLineItemsTable
|
| 127 |
+
lineItems={ cartItems }
|
| 128 |
+
isLoading={ cartIsLoading }
|
| 129 |
+
/>
|
| 130 |
+
</Main>
|
| 131 |
+
<Sidebar className="wc-block-cart__sidebar">
|
| 132 |
+
<Title
|
| 133 |
+
headingLevel="2"
|
| 134 |
+
className="wc-block-cart__totals-title"
|
| 135 |
+
>
|
| 136 |
+
{ __( 'Cart totals', 'woo-gutenberg-products-block' ) }
|
| 137 |
+
</Title>
|
| 138 |
+
<TotalsWrapper>
|
| 139 |
+
<Subtotal
|
| 140 |
+
currency={ totalsCurrency }
|
| 141 |
+
values={ cartTotals }
|
| 142 |
+
/>
|
| 143 |
+
<TotalsFees
|
| 144 |
+
currency={ totalsCurrency }
|
| 145 |
+
cartFees={ cartFees }
|
| 146 |
+
/>
|
| 147 |
+
<TotalsDiscount
|
| 148 |
+
cartCoupons={ appliedCoupons }
|
| 149 |
+
currency={ totalsCurrency }
|
| 150 |
+
isRemovingCoupon={ isRemovingCoupon }
|
| 151 |
+
removeCoupon={ removeCoupon }
|
| 152 |
+
values={ cartTotals }
|
| 153 |
+
/>
|
| 154 |
+
</TotalsWrapper>
|
| 155 |
+
{ getSetting( 'couponsEnabled', true ) && (
|
| 156 |
+
<TotalsWrapper>
|
| 157 |
+
<TotalsCoupon
|
| 158 |
+
onSubmit={ applyCoupon }
|
| 159 |
+
isLoading={ isApplyingCoupon }
|
| 160 |
+
/>
|
| 161 |
+
</TotalsWrapper>
|
| 162 |
+
) }
|
| 163 |
+
<ExperimentalDiscountsMeta.Slot
|
| 164 |
+
{ ...discountsSlotFillProps }
|
| 165 |
+
/>
|
| 166 |
+
{ cartNeedsShipping && (
|
| 167 |
+
<TotalsWrapper>
|
| 168 |
+
<TotalsShipping
|
| 169 |
+
showCalculator={ isShippingCalculatorEnabled }
|
| 170 |
+
showRateSelector={ true }
|
| 171 |
+
values={ cartTotals }
|
| 172 |
+
currency={ totalsCurrency }
|
| 173 |
+
/>
|
| 174 |
+
</TotalsWrapper>
|
| 175 |
+
) }
|
| 176 |
+
{ ! getSetting( 'displayCartPricesIncludingTax', false ) &&
|
| 177 |
+
parseInt( cartTotals.total_tax, 10 ) > 0 && (
|
| 178 |
+
<TotalsWrapper>
|
| 179 |
+
<TotalsTaxes
|
| 180 |
+
showRateAfterTaxName={
|
| 181 |
+
showRateAfterTaxName
|
| 182 |
+
}
|
| 183 |
+
currency={ totalsCurrency }
|
| 184 |
+
values={ cartTotals }
|
| 185 |
+
/>
|
| 186 |
+
</TotalsWrapper>
|
| 187 |
+
) }
|
| 188 |
+
<TotalsWrapper>
|
| 189 |
+
<TotalsFooterItem
|
| 190 |
+
currency={ totalsCurrency }
|
| 191 |
+
values={ cartTotals }
|
| 192 |
+
/>
|
| 193 |
+
</TotalsWrapper>
|
| 194 |
+
|
| 195 |
+
<ExperimentalOrderMeta.Slot { ...slotFillProps } />
|
| 196 |
+
|
| 197 |
+
<div className="wc-block-cart__payment-options">
|
| 198 |
+
{ cartNeedsPayment && <CartExpressPayment /> }
|
| 199 |
+
<CheckoutButton
|
| 200 |
+
link={ getSetting(
|
| 201 |
+
'page-' + attributes?.checkoutPageId,
|
| 202 |
+
false
|
| 203 |
+
) }
|
| 204 |
+
/>
|
| 205 |
+
</div>
|
| 206 |
+
</Sidebar>
|
| 207 |
+
</SidebarLayout>
|
| 208 |
+
</>
|
| 209 |
+
);
|
| 210 |
+
};
|
| 211 |
+
|
| 212 |
+
export default Cart;
|
assets/js/blocks/cart-checkout/cart-i2/full-cart/style.scss
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.wc-block-cart {
|
| 2 |
+
.wc-block-components-shipping-calculator {
|
| 3 |
+
white-space: nowrap;
|
| 4 |
+
}
|
| 5 |
+
|
| 6 |
+
.wc-block-components-address-form {
|
| 7 |
+
.wc-block-components-text-input,
|
| 8 |
+
.wc-block-components-country-input,
|
| 9 |
+
.wc-block-components-state-input {
|
| 10 |
+
&:first-of-type {
|
| 11 |
+
margin-top: 0;
|
| 12 |
+
}
|
| 13 |
+
}
|
| 14 |
+
}
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
table.wc-block-cart-items,
|
| 18 |
+
table.wc-block-cart-items th,
|
| 19 |
+
table.wc-block-cart-items td {
|
| 20 |
+
// Override Storefront theme gray table background.
|
| 21 |
+
background: none !important;
|
| 22 |
+
// Remove borders on default themes.
|
| 23 |
+
border: 0;
|
| 24 |
+
margin: 0;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
.editor-styles-wrapper table.wc-block-cart-items,
|
| 28 |
+
table.wc-block-cart-items {
|
| 29 |
+
width: 100%;
|
| 30 |
+
|
| 31 |
+
.wc-block-cart-items__header {
|
| 32 |
+
@include font-size(smaller);
|
| 33 |
+
text-transform: uppercase;
|
| 34 |
+
|
| 35 |
+
.wc-block-cart-items__header-image {
|
| 36 |
+
width: 100px;
|
| 37 |
+
}
|
| 38 |
+
.wc-block-cart-items__header-product {
|
| 39 |
+
visibility: hidden;
|
| 40 |
+
}
|
| 41 |
+
.wc-block-cart-items__header-total {
|
| 42 |
+
width: 100px;
|
| 43 |
+
text-align: right;
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
.wc-block-cart-items__row {
|
| 47 |
+
.wc-block-cart-item__image img {
|
| 48 |
+
width: 100%;
|
| 49 |
+
margin: 0;
|
| 50 |
+
}
|
| 51 |
+
.wc-block-cart-item__quantity {
|
| 52 |
+
.wc-block-cart-item__remove-link {
|
| 53 |
+
@include link-button;
|
| 54 |
+
@include font-size(smaller);
|
| 55 |
+
|
| 56 |
+
text-transform: none;
|
| 57 |
+
white-space: nowrap;
|
| 58 |
+
}
|
| 59 |
+
}
|
| 60 |
+
.wc-block-components-product-name {
|
| 61 |
+
display: block;
|
| 62 |
+
max-width: max-content;
|
| 63 |
+
}
|
| 64 |
+
.wc-block-cart-item__total {
|
| 65 |
+
@include font-size(regular);
|
| 66 |
+
text-align: right;
|
| 67 |
+
line-height: inherit;
|
| 68 |
+
}
|
| 69 |
+
.wc-block-components-product-metadata {
|
| 70 |
+
margin-bottom: 0.75em;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
&.is-disabled {
|
| 74 |
+
opacity: 0.5;
|
| 75 |
+
pointer-events: none;
|
| 76 |
+
transition: opacity 200ms ease;
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
.wc-block-cart {
|
| 82 |
+
.wc-block-components-totals-taxes,
|
| 83 |
+
.wc-block-components-totals-footer-item {
|
| 84 |
+
margin: 0;
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
// Loading placeholder state.
|
| 89 |
+
.wc-block-cart--is-loading,
|
| 90 |
+
.wc-block-mini-cart__drawer.is-loading {
|
| 91 |
+
th span,
|
| 92 |
+
h2 span {
|
| 93 |
+
@include placeholder();
|
| 94 |
+
@include force-content();
|
| 95 |
+
min-width: 84px;
|
| 96 |
+
display: inline-block;
|
| 97 |
+
}
|
| 98 |
+
h2 span {
|
| 99 |
+
min-width: 33%;
|
| 100 |
+
}
|
| 101 |
+
.wc-block-components-product-price,
|
| 102 |
+
.wc-block-components-product-metadata,
|
| 103 |
+
.wc-block-components-quantity-selector {
|
| 104 |
+
@include placeholder();
|
| 105 |
+
}
|
| 106 |
+
.wc-block-components-product-name {
|
| 107 |
+
@include placeholder();
|
| 108 |
+
@include force-content();
|
| 109 |
+
min-width: 84px;
|
| 110 |
+
display: inline-block;
|
| 111 |
+
}
|
| 112 |
+
.wc-block-components-product-metadata {
|
| 113 |
+
margin-top: 0.25em;
|
| 114 |
+
min-width: 8em;
|
| 115 |
+
}
|
| 116 |
+
.wc-block-cart-item__remove-link {
|
| 117 |
+
visibility: hidden;
|
| 118 |
+
}
|
| 119 |
+
.wc-block-cart-item__image > a {
|
| 120 |
+
@include placeholder();
|
| 121 |
+
display: block;
|
| 122 |
+
}
|
| 123 |
+
.wc-block-components-product-price {
|
| 124 |
+
@include force-content();
|
| 125 |
+
max-width: 3em;
|
| 126 |
+
display: block;
|
| 127 |
+
margin-top: 0.25em;
|
| 128 |
+
}
|
| 129 |
+
.wc-block-cart__sidebar .components-card {
|
| 130 |
+
@include placeholder();
|
| 131 |
+
@include force-content();
|
| 132 |
+
min-height: 460px;
|
| 133 |
+
}
|
| 134 |
+
}
|
| 135 |
+
.wc-block-components-sidebar-layout.wc-block-cart--skeleton {
|
| 136 |
+
display: none;
|
| 137 |
+
}
|
| 138 |
+
.is-loading + .wc-block-components-sidebar-layout.wc-block-cart--skeleton {
|
| 139 |
+
display: flex;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
.wc-block-cart-item__total-price-and-sale-badge-wrapper {
|
| 143 |
+
display: flex;
|
| 144 |
+
flex-direction: column;
|
| 145 |
+
align-items: flex-end;
|
| 146 |
+
|
| 147 |
+
.wc-block-components-sale-badge {
|
| 148 |
+
margin-top: $gap-smallest;
|
| 149 |
+
}
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
.is-small,
|
| 153 |
+
.is-mobile {
|
| 154 |
+
.wc-block-cart-item__total {
|
| 155 |
+
.wc-block-components-sale-badge {
|
| 156 |
+
display: none;
|
| 157 |
+
}
|
| 158 |
+
}
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
.is-medium,
|
| 162 |
+
.is-small,
|
| 163 |
+
.is-mobile {
|
| 164 |
+
&.wc-block-cart {
|
| 165 |
+
.wc-block-components-sidebar {
|
| 166 |
+
.wc-block-cart__totals-title {
|
| 167 |
+
display: none;
|
| 168 |
+
}
|
| 169 |
+
}
|
| 170 |
+
}
|
| 171 |
+
table.wc-block-cart-items {
|
| 172 |
+
td {
|
| 173 |
+
padding: 0;
|
| 174 |
+
}
|
| 175 |
+
.wc-block-cart-items__header {
|
| 176 |
+
display: none;
|
| 177 |
+
}
|
| 178 |
+
.wc-block-cart-item__remove-link {
|
| 179 |
+
display: none;
|
| 180 |
+
}
|
| 181 |
+
.wc-block-cart-items__row {
|
| 182 |
+
@include with-translucent-border(0 0 1px);
|
| 183 |
+
display: grid;
|
| 184 |
+
grid-template-columns: 80px 132px;
|
| 185 |
+
padding: $gap 0;
|
| 186 |
+
|
| 187 |
+
.wc-block-cart-item__image {
|
| 188 |
+
grid-column-start: 1;
|
| 189 |
+
grid-row-start: 1;
|
| 190 |
+
padding-right: $gap;
|
| 191 |
+
}
|
| 192 |
+
.wc-block-cart-item__product {
|
| 193 |
+
grid-column-start: 2;
|
| 194 |
+
grid-column-end: 4;
|
| 195 |
+
grid-row-start: 1;
|
| 196 |
+
justify-self: stretch;
|
| 197 |
+
padding: 0 $gap $gap 0;
|
| 198 |
+
}
|
| 199 |
+
.wc-block-cart-item__quantity {
|
| 200 |
+
grid-column-start: 1;
|
| 201 |
+
grid-row-start: 2;
|
| 202 |
+
vertical-align: bottom;
|
| 203 |
+
padding-right: $gap;
|
| 204 |
+
align-self: end;
|
| 205 |
+
padding-top: $gap;
|
| 206 |
+
}
|
| 207 |
+
.wc-block-cart-item__total {
|
| 208 |
+
grid-row-start: 1;
|
| 209 |
+
|
| 210 |
+
.wc-block-components-formatted-money-amount {
|
| 211 |
+
display: inline-block;
|
| 212 |
+
}
|
| 213 |
+
}
|
| 214 |
+
}
|
| 215 |
+
}
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
.is-large.wc-block-cart {
|
| 219 |
+
.wc-block-cart-items {
|
| 220 |
+
@include with-translucent-border(0 0 1px);
|
| 221 |
+
|
| 222 |
+
th {
|
| 223 |
+
padding: 0.25rem $gap 0.25rem 0;
|
| 224 |
+
white-space: nowrap;
|
| 225 |
+
}
|
| 226 |
+
td {
|
| 227 |
+
@include with-translucent-border(1px 0 0);
|
| 228 |
+
padding: $gap 0 $gap $gap;
|
| 229 |
+
vertical-align: top;
|
| 230 |
+
}
|
| 231 |
+
th:last-child {
|
| 232 |
+
padding-right: 0;
|
| 233 |
+
}
|
| 234 |
+
td:last-child {
|
| 235 |
+
padding-right: $gap;
|
| 236 |
+
}
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
.wc-block-components-radio-control__input {
|
| 240 |
+
left: 0;
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
.wc-block-cart__totals-title {
|
| 244 |
+
@include text-heading();
|
| 245 |
+
@include font-size(smaller);
|
| 246 |
+
display: block;
|
| 247 |
+
font-weight: 600;
|
| 248 |
+
padding: 0.25rem 0;
|
| 249 |
+
text-align: right;
|
| 250 |
+
text-transform: uppercase;
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
.wc-block-components-sidebar {
|
| 254 |
+
.wc-block-components-shipping-calculator,
|
| 255 |
+
.wc-block-components-shipping-rates-control__package:not(.wc-block-components-panel) {
|
| 256 |
+
padding-left: $gap;
|
| 257 |
+
padding-right: $gap;
|
| 258 |
+
}
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
.wc-block-cart__payment-options {
|
| 262 |
+
padding: $gap;
|
| 263 |
+
}
|
| 264 |
+
}
|
assets/js/blocks/cart-checkout/{checkout-i2 → cart-i2}/hacks.ts
RENAMED
|
@@ -17,11 +17,12 @@ import {
|
|
| 17 |
store as blockEditorStore,
|
| 18 |
} from '@wordpress/block-editor';
|
| 19 |
import { isTextField } from '@wordpress/dom';
|
| 20 |
-
import {
|
| 21 |
import { useEffect, useRef } from '@wordpress/element';
|
| 22 |
import { MutableRefObject } from 'react';
|
| 23 |
import { BACKSPACE, DELETE } from '@wordpress/keycodes';
|
| 24 |
import { hasFilter } from '@wordpress/hooks';
|
|
|
|
| 25 |
/**
|
| 26 |
* Toggle class on body.
|
| 27 |
*
|
|
@@ -73,64 +74,91 @@ export const addClassToBody = (): void => {
|
|
| 73 |
}
|
| 74 |
};
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
/**
|
| 77 |
-
* This is a hook we use in conjunction with useBlockProps. Its goal is to check if
|
| 78 |
-
*
|
| 79 |
*
|
| 80 |
-
* @todo Disable custom locking support if native support is detected.
|
| 81 |
*/
|
| 82 |
-
const
|
| 83 |
-
clientId,
|
| 84 |
ref,
|
| 85 |
-
attributes,
|
| 86 |
}: {
|
| 87 |
-
|
| 88 |
-
ref: MutableRefObject< Element | undefined >;
|
| 89 |
-
attributes: Record< string, unknown >;
|
| 90 |
} ): void => {
|
| 91 |
const lockInCore = hasFilter(
|
| 92 |
'blocks.registerBlockType',
|
| 93 |
'core/lock/addAttribute'
|
| 94 |
);
|
| 95 |
-
const { isSelected } = useSelect(
|
| 96 |
-
( select ) => {
|
| 97 |
-
return {
|
| 98 |
-
isSelected: select( blockEditorStore ).isBlockSelected(
|
| 99 |
-
clientId
|
| 100 |
-
),
|
| 101 |
-
};
|
| 102 |
-
},
|
| 103 |
-
[ clientId ]
|
| 104 |
-
);
|
| 105 |
|
| 106 |
const node = ref.current;
|
| 107 |
-
|
| 108 |
return useEffect( () => {
|
| 109 |
-
if ( !
|
| 110 |
return;
|
| 111 |
}
|
| 112 |
function onKeyDown( event: KeyboardEvent ) {
|
| 113 |
const { keyCode, target } = event;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
if ( keyCode !== BACKSPACE && keyCode !== DELETE ) {
|
| 115 |
return;
|
| 116 |
}
|
| 117 |
|
| 118 |
-
|
|
|
|
| 119 |
return;
|
| 120 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
// Prevent the keyboard event from propogating if it supports locking.
|
| 122 |
-
if (
|
| 123 |
event.preventDefault();
|
| 124 |
event.stopPropagation();
|
|
|
|
| 125 |
}
|
| 126 |
}
|
| 127 |
-
|
| 128 |
-
|
|
|
|
|
|
|
| 129 |
|
| 130 |
return () => {
|
| 131 |
-
node.removeEventListener( 'keydown', onKeyDown,
|
|
|
|
|
|
|
| 132 |
};
|
| 133 |
-
}, [ node,
|
| 134 |
};
|
| 135 |
|
| 136 |
/**
|
|
@@ -139,13 +167,10 @@ const useLockBlock = ( {
|
|
| 139 |
export const useBlockPropsWithLocking = (
|
| 140 |
props: Record< string, unknown > = {}
|
| 141 |
): Record< string, unknown > => {
|
| 142 |
-
const ref = useRef<
|
| 143 |
-
const { attributes } = props;
|
| 144 |
const blockProps = useBlockProps( { ref, ...props } );
|
| 145 |
-
|
| 146 |
ref,
|
| 147 |
-
attributes,
|
| 148 |
-
clientId: blockProps[ 'data-block' ],
|
| 149 |
} );
|
| 150 |
return blockProps;
|
| 151 |
};
|
| 17 |
store as blockEditorStore,
|
| 18 |
} from '@wordpress/block-editor';
|
| 19 |
import { isTextField } from '@wordpress/dom';
|
| 20 |
+
import { subscribe, select as _select } from '@wordpress/data';
|
| 21 |
import { useEffect, useRef } from '@wordpress/element';
|
| 22 |
import { MutableRefObject } from 'react';
|
| 23 |
import { BACKSPACE, DELETE } from '@wordpress/keycodes';
|
| 24 |
import { hasFilter } from '@wordpress/hooks';
|
| 25 |
+
import { getBlockType } from '@wordpress/blocks';
|
| 26 |
/**
|
| 27 |
* Toggle class on body.
|
| 28 |
*
|
| 74 |
}
|
| 75 |
};
|
| 76 |
|
| 77 |
+
const isBlockLocked = ( clientId: string ): boolean => {
|
| 78 |
+
if ( ! clientId ) {
|
| 79 |
+
return false;
|
| 80 |
+
}
|
| 81 |
+
const { getBlock } = _select( blockEditorStore );
|
| 82 |
+
const block = getBlock( clientId );
|
| 83 |
+
// If lock.remove is defined at the block instance (not using the default value)
|
| 84 |
+
// Then we use it.
|
| 85 |
+
if ( typeof block?.attributes?.lock?.remove === 'boolean' ) {
|
| 86 |
+
return block.attributes.lock.remove;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
// If we don't have lock on the block instance, we check the type
|
| 90 |
+
const blockType = getBlockType( block.name );
|
| 91 |
+
if ( typeof blockType?.attributes?.lock?.default?.remove === 'boolean' ) {
|
| 92 |
+
return blockType?.attributes?.lock?.default?.remove;
|
| 93 |
+
}
|
| 94 |
+
// If nothing is defined, return false
|
| 95 |
+
return false;
|
| 96 |
+
};
|
| 97 |
+
|
| 98 |
/**
|
| 99 |
+
* This is a hook we use in conjunction with useBlockProps. Its goal is to check if of the block's children is locked and being deleted.
|
| 100 |
+
* It will stop the keydown event from propagating to stop it from being deleted via the keyboard.
|
| 101 |
*
|
|
|
|
| 102 |
*/
|
| 103 |
+
const useLockedChildren = ( {
|
|
|
|
| 104 |
ref,
|
|
|
|
| 105 |
}: {
|
| 106 |
+
ref: MutableRefObject< HTMLElement | undefined >;
|
|
|
|
|
|
|
| 107 |
} ): void => {
|
| 108 |
const lockInCore = hasFilter(
|
| 109 |
'blocks.registerBlockType',
|
| 110 |
'core/lock/addAttribute'
|
| 111 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
const node = ref.current;
|
|
|
|
| 114 |
return useEffect( () => {
|
| 115 |
+
if ( ! node || lockInCore ) {
|
| 116 |
return;
|
| 117 |
}
|
| 118 |
function onKeyDown( event: KeyboardEvent ) {
|
| 119 |
const { keyCode, target } = event;
|
| 120 |
+
|
| 121 |
+
if ( ! ( target instanceof HTMLElement ) ) {
|
| 122 |
+
return;
|
| 123 |
+
}
|
| 124 |
+
// We're not trying to delete something here.
|
| 125 |
if ( keyCode !== BACKSPACE && keyCode !== DELETE ) {
|
| 126 |
return;
|
| 127 |
}
|
| 128 |
|
| 129 |
+
// We're in a field, so we should let text be deleted.
|
| 130 |
+
if ( isTextField( target ) ) {
|
| 131 |
return;
|
| 132 |
}
|
| 133 |
+
|
| 134 |
+
// Typecast to fix issue with isTextField.
|
| 135 |
+
const targetNode = target as HTMLElement;
|
| 136 |
+
|
| 137 |
+
// Our target isn't a block.
|
| 138 |
+
if ( targetNode.dataset.block === undefined ) {
|
| 139 |
+
return;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
const clientId = targetNode.dataset.block;
|
| 143 |
+
const isLocked = isBlockLocked( clientId );
|
| 144 |
// Prevent the keyboard event from propogating if it supports locking.
|
| 145 |
+
if ( isLocked ) {
|
| 146 |
event.preventDefault();
|
| 147 |
event.stopPropagation();
|
| 148 |
+
event.stopImmediatePropagation();
|
| 149 |
}
|
| 150 |
}
|
| 151 |
+
node.addEventListener( 'keydown', onKeyDown, {
|
| 152 |
+
capture: true,
|
| 153 |
+
passive: false,
|
| 154 |
+
} );
|
| 155 |
|
| 156 |
return () => {
|
| 157 |
+
node.removeEventListener( 'keydown', onKeyDown, {
|
| 158 |
+
capture: true,
|
| 159 |
+
} );
|
| 160 |
};
|
| 161 |
+
}, [ node, lockInCore ] );
|
| 162 |
};
|
| 163 |
|
| 164 |
/**
|
| 167 |
export const useBlockPropsWithLocking = (
|
| 168 |
props: Record< string, unknown > = {}
|
| 169 |
): Record< string, unknown > => {
|
| 170 |
+
const ref = useRef< HTMLElement >();
|
|
|
|
| 171 |
const blockProps = useBlockProps( { ref, ...props } );
|
| 172 |
+
useLockedChildren( {
|
| 173 |
ref,
|
|
|
|
|
|
|
| 174 |
} );
|
| 175 |
return blockProps;
|
| 176 |
};
|
assets/js/blocks/cart-checkout/cart-i2/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { __ } from '@wordpress/i18n';
|
| 5 |
+
import { Icon, cart } from '@woocommerce/icons';
|
| 6 |
+
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* Internal dependencies
|
| 10 |
+
*/
|
| 11 |
+
import { Edit, Save } from './edit';
|
| 12 |
+
import './style.scss';
|
| 13 |
+
import { blockName, blockAttributes } from './attributes';
|
| 14 |
+
import './inner-blocks';
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* Register and run the Cart block.
|
| 18 |
+
*/
|
| 19 |
+
const settings = {
|
| 20 |
+
title: __( 'Cart i2', 'woo-gutenberg-products-block' ),
|
| 21 |
+
icon: {
|
| 22 |
+
src: <Icon srcElement={ cart } />,
|
| 23 |
+
foreground: '#96588a',
|
| 24 |
+
},
|
| 25 |
+
category: 'woocommerce',
|
| 26 |
+
keywords: [ __( 'WooCommerce', 'woo-gutenberg-products-block' ) ],
|
| 27 |
+
description: __( 'Shopping cart.', 'woo-gutenberg-products-block' ),
|
| 28 |
+
supports: {
|
| 29 |
+
align: false,
|
| 30 |
+
html: false,
|
| 31 |
+
multiple: false,
|
| 32 |
+
__experimentalExposeControlsToChildren: true,
|
| 33 |
+
},
|
| 34 |
+
example: {
|
| 35 |
+
attributes: {
|
| 36 |
+
isPreview: true,
|
| 37 |
+
},
|
| 38 |
+
},
|
| 39 |
+
attributes: blockAttributes,
|
| 40 |
+
edit: Edit,
|
| 41 |
+
save: Save,
|
| 42 |
+
};
|
| 43 |
+
|
| 44 |
+
registerFeaturePluginBlockType( blockName, settings );
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-express-payment-block/block.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "woocommerce/cart-express-payment-block",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"title": "Express Checkout",
|
| 5 |
+
"description": "Provide an express payment option for your customers.",
|
| 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/cart-totals-block" ],
|
| 24 |
+
"textdomain": "woo-gutenberg-products-block",
|
| 25 |
+
"apiVersion": 2
|
| 26 |
+
}
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-express-payment-block/block.tsx
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { useStoreCart } from '@woocommerce/base-context/hooks';
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* Internal dependencies
|
| 8 |
+
*/
|
| 9 |
+
import { CartExpressPayment } from '../../../payment-methods';
|
| 10 |
+
|
| 11 |
+
const Block = (): JSX.Element | null => {
|
| 12 |
+
const { cartNeedsPayment } = useStoreCart();
|
| 13 |
+
|
| 14 |
+
if ( ! cartNeedsPayment ) {
|
| 15 |
+
return null;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
return (
|
| 19 |
+
<div className="wc-block-cart__payment-options">
|
| 20 |
+
<CartExpressPayment />
|
| 21 |
+
</div>
|
| 22 |
+
);
|
| 23 |
+
};
|
| 24 |
+
|
| 25 |
+
export default Block;
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-express-payment-block/edit.tsx
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { __ } from '@wordpress/i18n';
|
| 5 |
+
import { useBlockProps } from '@wordpress/block-editor';
|
| 6 |
+
import { Placeholder, Button } from 'wordpress-components';
|
| 7 |
+
import { useExpressPaymentMethods } from '@woocommerce/base-context/hooks';
|
| 8 |
+
import { Icon, card } from '@woocommerce/icons';
|
| 9 |
+
import { ADMIN_URL } from '@woocommerce/settings';
|
| 10 |
+
import classnames from 'classnames';
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* Internal dependencies
|
| 14 |
+
*/
|
| 15 |
+
import Block from './block';
|
| 16 |
+
import './editor.scss';
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* Renders a placeholder in the editor.
|
| 20 |
+
*/
|
| 21 |
+
const NoExpressPaymentMethodsPlaceholder = () => {
|
| 22 |
+
return (
|
| 23 |
+
<Placeholder
|
| 24 |
+
icon={ <Icon srcElement={ card } /> }
|
| 25 |
+
label={ __( 'Express Checkout', 'woo-gutenberg-products-block' ) }
|
| 26 |
+
className="wp-block-woocommerce-checkout-express-payment-block-placeholder"
|
| 27 |
+
>
|
| 28 |
+
<span className="wp-block-woocommerce-checkout-express-payment-block-placeholder__description">
|
| 29 |
+
{ __(
|
| 30 |
+
"Your store doesn't have any Payment Methods that support the Express Checkout Block. If they are added, they will be shown here.",
|
| 31 |
+
'woo-gutenberg-products-block'
|
| 32 |
+
) }
|
| 33 |
+
</span>
|
| 34 |
+
<Button
|
| 35 |
+
isPrimary
|
| 36 |
+
href={ `${ ADMIN_URL }admin.php?page=wc-settings&tab=checkout` }
|
| 37 |
+
target="_blank"
|
| 38 |
+
rel="noopener noreferrer"
|
| 39 |
+
className="wp-block-woocommerce-checkout-express-payment-block-placeholder__button"
|
| 40 |
+
>
|
| 41 |
+
{ __(
|
| 42 |
+
'Configure Payment Methods',
|
| 43 |
+
'woo-gutenberg-products-block'
|
| 44 |
+
) }
|
| 45 |
+
</Button>
|
| 46 |
+
</Placeholder>
|
| 47 |
+
);
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
export const Edit = (): JSX.Element | null => {
|
| 51 |
+
const { paymentMethods, isInitialized } = useExpressPaymentMethods();
|
| 52 |
+
const hasExpressPaymentMethods = Object.keys( paymentMethods ).length > 0;
|
| 53 |
+
const blockProps = useBlockProps( {
|
| 54 |
+
className: classnames( {
|
| 55 |
+
'wp-block-woocommerce-cart-express-payment-block--has-express-payment-methods': hasExpressPaymentMethods,
|
| 56 |
+
} ),
|
| 57 |
+
} );
|
| 58 |
+
|
| 59 |
+
if ( ! isInitialized ) {
|
| 60 |
+
return null;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
return (
|
| 64 |
+
<div { ...blockProps }>
|
| 65 |
+
{ hasExpressPaymentMethods ? (
|
| 66 |
+
<Block />
|
| 67 |
+
) : (
|
| 68 |
+
<NoExpressPaymentMethodsPlaceholder />
|
| 69 |
+
) }
|
| 70 |
+
</div>
|
| 71 |
+
);
|
| 72 |
+
};
|
| 73 |
+
|
| 74 |
+
export const Save = (): JSX.Element => {
|
| 75 |
+
return <div { ...useBlockProps.save() } />;
|
| 76 |
+
};
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-express-payment-block/editor.scss
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Adjust padding and margins in the editor to improve selected block outlines.
|
| 2 |
+
.wp-block-woocommerce-cart-express-payment-block {
|
| 3 |
+
margin: 14px 0 28px;
|
| 4 |
+
|
| 5 |
+
.components-placeholder__label svg {
|
| 6 |
+
font-size: 1em;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
.wc-block-components-express-payment-continue-rule--checkout {
|
| 10 |
+
margin-bottom: 0;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
&.wp-block-woocommerce-cart-express-payment-block--has-express-payment-methods {
|
| 14 |
+
padding: 14px 0;
|
| 15 |
+
margin: -14px 0 14px 0 !important;
|
| 16 |
+
position: relative;
|
| 17 |
+
}
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
.wp-block-woocommerce-checkout-express-payment-block-placeholder {
|
| 21 |
+
* {
|
| 22 |
+
pointer-events: all; // Overrides parent disabled component in editor context
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
.wp-block-woocommerce-checkout-express-payment-block-placeholder__description {
|
| 26 |
+
display: block;
|
| 27 |
+
margin: 0 0 1em;
|
| 28 |
+
}
|
| 29 |
+
}
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-express-payment-block/index.tsx
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { Icon, card } 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: <Icon srcElement={ card } />,
|
| 16 |
+
foreground: '#874FB9',
|
| 17 |
+
},
|
| 18 |
+
edit: Edit,
|
| 19 |
+
save: Save,
|
| 20 |
+
} );
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-items-block/block.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "woocommerce/cart-items-block",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"title": "Cart Items block",
|
| 5 |
+
"description": "Column containing cart items.",
|
| 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-cart-block" ],
|
| 24 |
+
"textdomain": "woo-gutenberg-products-block",
|
| 25 |
+
"apiVersion": 2
|
| 26 |
+
}
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-items-block/edit.tsx
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { useBlockProps, InnerBlocks } from '@wordpress/block-editor';
|
| 5 |
+
import { Main } from '@woocommerce/base-components/sidebar-layout';
|
| 6 |
+
import { innerBlockAreas } from '@woocommerce/blocks-checkout';
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* Internal dependencies
|
| 10 |
+
*/
|
| 11 |
+
import { useForcedLayout } from '../../use-forced-layout';
|
| 12 |
+
import { getAllowedBlocks } from '../../editor-utils';
|
| 13 |
+
|
| 14 |
+
export const Edit = ( { clientId }: { clientId: string } ): JSX.Element => {
|
| 15 |
+
const blockProps = useBlockProps();
|
| 16 |
+
const allowedBlocks = getAllowedBlocks( innerBlockAreas.CART_ITEMS );
|
| 17 |
+
|
| 18 |
+
useForcedLayout( {
|
| 19 |
+
clientId,
|
| 20 |
+
template: allowedBlocks,
|
| 21 |
+
} );
|
| 22 |
+
return (
|
| 23 |
+
<Main className="wc-block-cart__main">
|
| 24 |
+
<div { ...blockProps }>
|
| 25 |
+
<InnerBlocks
|
| 26 |
+
allowedBlocks={ allowedBlocks }
|
| 27 |
+
templateLock={ false }
|
| 28 |
+
renderAppender={ InnerBlocks.ButtonBlockAppender }
|
| 29 |
+
/>
|
| 30 |
+
</div>
|
| 31 |
+
</Main>
|
| 32 |
+
);
|
| 33 |
+
};
|
| 34 |
+
|
| 35 |
+
export const Save = (): JSX.Element => {
|
| 36 |
+
return (
|
| 37 |
+
<div { ...useBlockProps.save() }>
|
| 38 |
+
<InnerBlocks.Content />
|
| 39 |
+
</div>
|
| 40 |
+
);
|
| 41 |
+
};
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-items-block/frontend.tsx
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { Main } from '@woocommerce/base-components/sidebar-layout';
|
| 5 |
+
|
| 6 |
+
const FrontendBlock = ( {
|
| 7 |
+
children,
|
| 8 |
+
}: {
|
| 9 |
+
children: JSX.Element;
|
| 10 |
+
} ): JSX.Element => {
|
| 11 |
+
return <Main className="wc-block-cart__main">{ children }</Main>;
|
| 12 |
+
};
|
| 13 |
+
|
| 14 |
+
export default FrontendBlock;
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-items-block/index.tsx
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { Icon, column } from '@wordpress/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: <Icon icon={ column } />,
|
| 16 |
+
foreground: '#874FB9',
|
| 17 |
+
},
|
| 18 |
+
edit: Edit,
|
| 19 |
+
save: Save,
|
| 20 |
+
} );
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-line-items-block/block.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "woocommerce/cart-line-items-block",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"title": "Cart Line Items",
|
| 5 |
+
"description": "Block containing current line items in 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/cart-items-block" ],
|
| 24 |
+
"textdomain": "woo-gutenberg-products-block",
|
| 25 |
+
"apiVersion": 2
|
| 26 |
+
}
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-line-items-block/block.tsx
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { useStoreCart } from '@woocommerce/base-context/hooks';
|
| 5 |
+
/**
|
| 6 |
+
* Internal dependencies
|
| 7 |
+
*/
|
| 8 |
+
import CartLineItemsTable from '../../full-cart/cart-line-items-table';
|
| 9 |
+
|
| 10 |
+
const Block = (): JSX.Element => {
|
| 11 |
+
const { cartItems, cartIsLoading } = useStoreCart();
|
| 12 |
+
return (
|
| 13 |
+
<CartLineItemsTable
|
| 14 |
+
lineItems={ cartItems }
|
| 15 |
+
isLoading={ cartIsLoading }
|
| 16 |
+
/>
|
| 17 |
+
);
|
| 18 |
+
};
|
| 19 |
+
|
| 20 |
+
export default Block;
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-line-items-block/edit.tsx
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { useBlockProps } from '@wordpress/block-editor';
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* Internal dependencies
|
| 8 |
+
*/
|
| 9 |
+
import Block from './block';
|
| 10 |
+
|
| 11 |
+
export const Edit = (): JSX.Element => {
|
| 12 |
+
const blockProps = useBlockProps();
|
| 13 |
+
|
| 14 |
+
return (
|
| 15 |
+
<div { ...blockProps }>
|
| 16 |
+
<Block />
|
| 17 |
+
</div>
|
| 18 |
+
);
|
| 19 |
+
};
|
| 20 |
+
|
| 21 |
+
export const Save = (): JSX.Element => {
|
| 22 |
+
return <div { ...useBlockProps.save() } />;
|
| 23 |
+
};
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-line-items-block/index.tsx
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { Icon, column } from '@wordpress/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: <Icon icon={ column } />,
|
| 16 |
+
foreground: '#874FB9',
|
| 17 |
+
},
|
| 18 |
+
edit: Edit,
|
| 19 |
+
save: Save,
|
| 20 |
+
} );
|
assets/js/blocks/cart-checkout/{checkout-i2/inner-blocks/checkout-order-summary-block → cart-i2/inner-blocks/cart-order-summary-block}/attributes.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-order-summary-block/block.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "woocommerce/cart-order-summary-block",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"title": "Order Summary",
|
| 5 |
+
"description": "Show customers a summary of their order.",
|
| 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/cart-totals-block" ],
|
| 24 |
+
"textdomain": "woo-gutenberg-products-block",
|
| 25 |
+
"apiVersion": 2
|
| 26 |
+
}
|
assets/js/blocks/cart-checkout/{checkout/sidebar/index.js → cart-i2/inner-blocks/cart-order-summary-block/block.tsx}
RENAMED
|
@@ -1,9 +1,8 @@
|
|
| 1 |
/**
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
-
|
| 5 |
import {
|
| 6 |
-
OrderSummary,
|
| 7 |
TotalsCoupon,
|
| 8 |
TotalsDiscount,
|
| 9 |
TotalsFooterItem,
|
|
@@ -13,40 +12,45 @@ import {
|
|
| 13 |
Subtotal,
|
| 14 |
TotalsFees,
|
| 15 |
TotalsTaxes,
|
|
|
|
| 16 |
ExperimentalOrderMeta,
|
| 17 |
ExperimentalDiscountsMeta,
|
| 18 |
-
TotalsWrapper,
|
| 19 |
} from '@woocommerce/blocks-checkout';
|
| 20 |
-
|
| 21 |
import { getCurrencyFromPriceResponse } from '@woocommerce/price-format';
|
| 22 |
-
import { useShippingDataContext } from '@woocommerce/base-context';
|
| 23 |
import {
|
| 24 |
useStoreCartCoupons,
|
| 25 |
useStoreCart,
|
| 26 |
} from '@woocommerce/base-context/hooks';
|
| 27 |
import { getSetting } from '@woocommerce/settings';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
-
const
|
| 30 |
-
cartCoupons = [],
|
| 31 |
-
cartItems = [],
|
| 32 |
-
cartFees = [],
|
| 33 |
-
cartTotals = {},
|
| 34 |
showRateAfterTaxName = false,
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
const {
|
| 37 |
applyCoupon,
|
| 38 |
removeCoupon,
|
| 39 |
isApplyingCoupon,
|
| 40 |
isRemovingCoupon,
|
|
|
|
| 41 |
} = useStoreCartCoupons();
|
| 42 |
|
| 43 |
-
const { needsShipping } = useShippingDataContext();
|
| 44 |
const totalsCurrency = getCurrencyFromPriceResponse( cartTotals );
|
| 45 |
|
| 46 |
// Prepare props to pass to the ExperimentalOrderMeta slot fill.
|
| 47 |
// We need to pluck out receiveCart.
|
| 48 |
// eslint-disable-next-line no-unused-vars
|
| 49 |
-
const { extensions,
|
| 50 |
const slotFillProps = {
|
| 51 |
extensions,
|
| 52 |
cart,
|
|
@@ -59,14 +63,14 @@ const CheckoutSidebar = ( {
|
|
| 59 |
|
| 60 |
return (
|
| 61 |
<>
|
| 62 |
-
<
|
| 63 |
-
|
| 64 |
-
</
|
| 65 |
<TotalsWrapper>
|
| 66 |
<Subtotal currency={ totalsCurrency } values={ cartTotals } />
|
| 67 |
<TotalsFees currency={ totalsCurrency } cartFees={ cartFees } />
|
| 68 |
<TotalsDiscount
|
| 69 |
-
cartCoupons={
|
| 70 |
currency={ totalsCurrency }
|
| 71 |
isRemovingCoupon={ isRemovingCoupon }
|
| 72 |
removeCoupon={ removeCoupon }
|
|
@@ -77,17 +81,16 @@ const CheckoutSidebar = ( {
|
|
| 77 |
<TotalsWrapper>
|
| 78 |
<TotalsCoupon
|
| 79 |
onSubmit={ applyCoupon }
|
| 80 |
-
initialOpen={ false }
|
| 81 |
isLoading={ isApplyingCoupon }
|
| 82 |
/>
|
| 83 |
</TotalsWrapper>
|
| 84 |
) }
|
| 85 |
<ExperimentalDiscountsMeta.Slot { ...discountsSlotFillProps } />
|
| 86 |
-
{
|
| 87 |
<TotalsWrapper>
|
| 88 |
<TotalsShipping
|
| 89 |
-
showCalculator={
|
| 90 |
-
showRateSelector={
|
| 91 |
values={ cartTotals }
|
| 92 |
currency={ totalsCurrency }
|
| 93 |
/>
|
|
@@ -97,8 +100,8 @@ const CheckoutSidebar = ( {
|
|
| 97 |
parseInt( cartTotals.total_tax, 10 ) > 0 && (
|
| 98 |
<TotalsWrapper>
|
| 99 |
<TotalsTaxes
|
| 100 |
-
currency={ totalsCurrency }
|
| 101 |
showRateAfterTaxName={ showRateAfterTaxName }
|
|
|
|
| 102 |
values={ cartTotals }
|
| 103 |
/>
|
| 104 |
</TotalsWrapper>
|
|
@@ -109,9 +112,10 @@ const CheckoutSidebar = ( {
|
|
| 109 |
values={ cartTotals }
|
| 110 |
/>
|
| 111 |
</TotalsWrapper>
|
|
|
|
| 112 |
<ExperimentalOrderMeta.Slot { ...slotFillProps } />
|
| 113 |
</>
|
| 114 |
);
|
| 115 |
};
|
| 116 |
|
| 117 |
-
export default
|
| 1 |
/**
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
+
import { __ } from '@wordpress/i18n';
|
| 5 |
import {
|
|
|
|
| 6 |
TotalsCoupon,
|
| 7 |
TotalsDiscount,
|
| 8 |
TotalsFooterItem,
|
| 12 |
Subtotal,
|
| 13 |
TotalsFees,
|
| 14 |
TotalsTaxes,
|
| 15 |
+
TotalsWrapper,
|
| 16 |
ExperimentalOrderMeta,
|
| 17 |
ExperimentalDiscountsMeta,
|
|
|
|
| 18 |
} from '@woocommerce/blocks-checkout';
|
|
|
|
| 19 |
import { getCurrencyFromPriceResponse } from '@woocommerce/price-format';
|
|
|
|
| 20 |
import {
|
| 21 |
useStoreCartCoupons,
|
| 22 |
useStoreCart,
|
| 23 |
} from '@woocommerce/base-context/hooks';
|
| 24 |
import { getSetting } from '@woocommerce/settings';
|
| 25 |
+
import Title from '@woocommerce/base-components/title';
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Internal dependencies
|
| 29 |
+
*/
|
| 30 |
|
| 31 |
+
const Block = ( {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
showRateAfterTaxName = false,
|
| 33 |
+
isShippingCalculatorEnabled = true,
|
| 34 |
+
}: {
|
| 35 |
+
showRateAfterTaxName: boolean;
|
| 36 |
+
isShippingCalculatorEnabled: boolean;
|
| 37 |
+
} ): JSX.Element => {
|
| 38 |
+
const { cartFees, cartTotals, cartNeedsShipping } = useStoreCart();
|
| 39 |
+
|
| 40 |
const {
|
| 41 |
applyCoupon,
|
| 42 |
removeCoupon,
|
| 43 |
isApplyingCoupon,
|
| 44 |
isRemovingCoupon,
|
| 45 |
+
appliedCoupons,
|
| 46 |
} = useStoreCartCoupons();
|
| 47 |
|
|
|
|
| 48 |
const totalsCurrency = getCurrencyFromPriceResponse( cartTotals );
|
| 49 |
|
| 50 |
// Prepare props to pass to the ExperimentalOrderMeta slot fill.
|
| 51 |
// We need to pluck out receiveCart.
|
| 52 |
// eslint-disable-next-line no-unused-vars
|
| 53 |
+
const { extensions, ...cart } = useStoreCart();
|
| 54 |
const slotFillProps = {
|
| 55 |
extensions,
|
| 56 |
cart,
|
| 63 |
|
| 64 |
return (
|
| 65 |
<>
|
| 66 |
+
<Title headingLevel="2" className="wc-block-cart__totals-title">
|
| 67 |
+
{ __( 'Cart totals', 'woo-gutenberg-products-block' ) }
|
| 68 |
+
</Title>
|
| 69 |
<TotalsWrapper>
|
| 70 |
<Subtotal currency={ totalsCurrency } values={ cartTotals } />
|
| 71 |
<TotalsFees currency={ totalsCurrency } cartFees={ cartFees } />
|
| 72 |
<TotalsDiscount
|
| 73 |
+
cartCoupons={ appliedCoupons }
|
| 74 |
currency={ totalsCurrency }
|
| 75 |
isRemovingCoupon={ isRemovingCoupon }
|
| 76 |
removeCoupon={ removeCoupon }
|
| 81 |
<TotalsWrapper>
|
| 82 |
<TotalsCoupon
|
| 83 |
onSubmit={ applyCoupon }
|
|
|
|
| 84 |
isLoading={ isApplyingCoupon }
|
| 85 |
/>
|
| 86 |
</TotalsWrapper>
|
| 87 |
) }
|
| 88 |
<ExperimentalDiscountsMeta.Slot { ...discountsSlotFillProps } />
|
| 89 |
+
{ cartNeedsShipping && (
|
| 90 |
<TotalsWrapper>
|
| 91 |
<TotalsShipping
|
| 92 |
+
showCalculator={ isShippingCalculatorEnabled }
|
| 93 |
+
showRateSelector={ true }
|
| 94 |
values={ cartTotals }
|
| 95 |
currency={ totalsCurrency }
|
| 96 |
/>
|
| 100 |
parseInt( cartTotals.total_tax, 10 ) > 0 && (
|
| 101 |
<TotalsWrapper>
|
| 102 |
<TotalsTaxes
|
|
|
|
| 103 |
showRateAfterTaxName={ showRateAfterTaxName }
|
| 104 |
+
currency={ totalsCurrency }
|
| 105 |
values={ cartTotals }
|
| 106 |
/>
|
| 107 |
</TotalsWrapper>
|
| 112 |
values={ cartTotals }
|
| 113 |
/>
|
| 114 |
</TotalsWrapper>
|
| 115 |
+
|
| 116 |
<ExperimentalOrderMeta.Slot { ...slotFillProps } />
|
| 117 |
</>
|
| 118 |
);
|
| 119 |
};
|
| 120 |
|
| 121 |
+
export default Block;
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-order-summary-block/edit.tsx
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { __ } from '@wordpress/i18n';
|
| 5 |
+
import { useBlockProps, InspectorControls } from '@wordpress/block-editor';
|
| 6 |
+
import { Disabled, PanelBody, ToggleControl } from '@wordpress/components';
|
| 7 |
+
import { getSetting } from '@woocommerce/settings';
|
| 8 |
+
|
| 9 |
+
/**
|
| 10 |
+
* Internal dependencies
|
| 11 |
+
*/
|
| 12 |
+
import Block from './block';
|
| 13 |
+
|
| 14 |
+
export const Edit = ( {
|
| 15 |
+
attributes,
|
| 16 |
+
setAttributes,
|
| 17 |
+
}: {
|
| 18 |
+
attributes: {
|
| 19 |
+
showRateAfterTaxName: boolean;
|
| 20 |
+
isShippingCalculatorEnabled: boolean;
|
| 21 |
+
lock: {
|
| 22 |
+
move: boolean;
|
| 23 |
+
remove: boolean;
|
| 24 |
+
};
|
| 25 |
+
};
|
| 26 |
+
setAttributes: ( attributes: Record< string, unknown > ) => void;
|
| 27 |
+
} ): JSX.Element => {
|
| 28 |
+
const { showRateAfterTaxName, isShippingCalculatorEnabled } = attributes;
|
| 29 |
+
const blockProps = useBlockProps();
|
| 30 |
+
const taxesEnabled = getSetting( 'taxesEnabled' ) as boolean;
|
| 31 |
+
const displayItemizedTaxes = getSetting(
|
| 32 |
+
'displayItemizedTaxes',
|
| 33 |
+
false
|
| 34 |
+
) as boolean;
|
| 35 |
+
const displayCartPricesIncludingTax = getSetting(
|
| 36 |
+
'displayCartPricesIncludingTax',
|
| 37 |
+
false
|
| 38 |
+
) as boolean;
|
| 39 |
+
return (
|
| 40 |
+
<div { ...blockProps }>
|
| 41 |
+
<InspectorControls>
|
| 42 |
+
{ getSetting( 'shippingEnabled', true ) && (
|
| 43 |
+
<PanelBody
|
| 44 |
+
title={ __(
|
| 45 |
+
'Shipping rates',
|
| 46 |
+
'woo-gutenberg-products-block'
|
| 47 |
+
) }
|
| 48 |
+
>
|
| 49 |
+
<ToggleControl
|
| 50 |
+
label={ __(
|
| 51 |
+
'Shipping calculator',
|
| 52 |
+
'woo-gutenberg-products-block'
|
| 53 |
+
) }
|
| 54 |
+
help={ __(
|
| 55 |
+
'Allow customers to estimate shipping by entering their address.',
|
| 56 |
+
'woo-gutenberg-products-block'
|
| 57 |
+
) }
|
| 58 |
+
checked={ isShippingCalculatorEnabled }
|
| 59 |
+
onChange={ () =>
|
| 60 |
+
setAttributes( {
|
| 61 |
+
isShippingCalculatorEnabled: ! isShippingCalculatorEnabled,
|
| 62 |
+
} )
|
| 63 |
+
}
|
| 64 |
+
/>
|
| 65 |
+
</PanelBody>
|
| 66 |
+
) }
|
| 67 |
+
{ taxesEnabled &&
|
| 68 |
+
displayItemizedTaxes &&
|
| 69 |
+
! displayCartPricesIncludingTax && (
|
| 70 |
+
<PanelBody
|
| 71 |
+
title={ __(
|
| 72 |
+
'Taxes',
|
| 73 |
+
'woo-gutenberg-products-block'
|
| 74 |
+
) }
|
| 75 |
+
>
|
| 76 |
+
<ToggleControl
|
| 77 |
+
label={ __(
|
| 78 |
+
'Show rate after tax name',
|
| 79 |
+
'woo-gutenberg-products-block'
|
| 80 |
+
) }
|
| 81 |
+
help={ __(
|
| 82 |
+
'Show the percentage rate alongside each tax line in the summary.',
|
| 83 |
+
'woo-gutenberg-products-block'
|
| 84 |
+
) }
|
| 85 |
+
checked={ showRateAfterTaxName }
|
| 86 |
+
onChange={ () =>
|
| 87 |
+
setAttributes( {
|
| 88 |
+
showRateAfterTaxName: ! showRateAfterTaxName,
|
| 89 |
+
} )
|
| 90 |
+
}
|
| 91 |
+
/>
|
| 92 |
+
</PanelBody>
|
| 93 |
+
) }
|
| 94 |
+
</InspectorControls>
|
| 95 |
+
<Disabled>
|
| 96 |
+
<Block
|
| 97 |
+
showRateAfterTaxName={ attributes.showRateAfterTaxName }
|
| 98 |
+
isShippingCalculatorEnabled={
|
| 99 |
+
attributes.isShippingCalculatorEnabled
|
| 100 |
+
}
|
| 101 |
+
/>
|
| 102 |
+
</Disabled>
|
| 103 |
+
</div>
|
| 104 |
+
);
|
| 105 |
+
};
|
| 106 |
+
|
| 107 |
+
export const Save = (): JSX.Element => {
|
| 108 |
+
return <div { ...useBlockProps.save() } />;
|
| 109 |
+
};
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-order-summary-block/index.tsx
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { Icon, totals } from '@woocommerce/icons';
|
| 5 |
+
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
| 6 |
+
|
| 7 |
+
/**
|
| 8 |
+
* Internal dependencies
|
| 9 |
+
*/
|
| 10 |
+
import { Edit, Save } from './edit';
|
| 11 |
+
import attributes from './attributes';
|
| 12 |
+
import metadata from './block.json';
|
| 13 |
+
|
| 14 |
+
registerFeaturePluginBlockType( metadata, {
|
| 15 |
+
icon: {
|
| 16 |
+
src: <Icon srcElement={ totals } />,
|
| 17 |
+
foreground: '#874FB9',
|
| 18 |
+
},
|
| 19 |
+
attributes,
|
| 20 |
+
edit: Edit,
|
| 21 |
+
save: Save,
|
| 22 |
+
} );
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-totals-block/block.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "woocommerce/cart-totals-block",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"title": "Cart Totals",
|
| 5 |
+
"description": "Column containing the cart totals.",
|
| 6 |
+
"category": "woocommerce",
|
| 7 |
+
"supports": {
|
| 8 |
+
"align": false,
|
| 9 |
+
"html": false,
|
| 10 |
+
"multiple": false,
|
| 11 |
+
"reusable": false,
|
| 12 |
+
"inserter": false
|
| 13 |
+
},
|
| 14 |
+
"attributes": {
|
| 15 |
+
"checkbox": {
|
| 16 |
+
"type": "boolean",
|
| 17 |
+
"default": false
|
| 18 |
+
},
|
| 19 |
+
"text": {
|
| 20 |
+
"type": "string",
|
| 21 |
+
"required": false
|
| 22 |
+
},
|
| 23 |
+
"lock": {
|
| 24 |
+
"type": "object",
|
| 25 |
+
"default": {
|
| 26 |
+
"remove": true
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
},
|
| 30 |
+
"parent": [ "woocommerce/filled-cart-block" ],
|
| 31 |
+
"textdomain": "woo-gutenberg-products-block",
|
| 32 |
+
"apiVersion": 2
|
| 33 |
+
}
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-totals-block/edit.tsx
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { useBlockProps, InnerBlocks } from '@wordpress/block-editor';
|
| 5 |
+
import { Sidebar } from '@woocommerce/base-components/sidebar-layout';
|
| 6 |
+
import { innerBlockAreas } from '@woocommerce/blocks-checkout';
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* Internal dependencies
|
| 10 |
+
*/
|
| 11 |
+
import './style.scss';
|
| 12 |
+
import { useForcedLayout } from '../../use-forced-layout';
|
| 13 |
+
import { getAllowedBlocks } from '../../editor-utils';
|
| 14 |
+
|
| 15 |
+
export const Edit = ( { clientId }: { clientId: string } ): JSX.Element => {
|
| 16 |
+
const blockProps = useBlockProps();
|
| 17 |
+
const allowedBlocks = getAllowedBlocks( innerBlockAreas.CART_TOTALS );
|
| 18 |
+
|
| 19 |
+
useForcedLayout( {
|
| 20 |
+
clientId,
|
| 21 |
+
template: allowedBlocks,
|
| 22 |
+
} );
|
| 23 |
+
|
| 24 |
+
return (
|
| 25 |
+
<Sidebar className="wc-block-cart__sidebar">
|
| 26 |
+
<div { ...blockProps }>
|
| 27 |
+
<InnerBlocks
|
| 28 |
+
allowedBlocks={ allowedBlocks }
|
| 29 |
+
templateLock={ false }
|
| 30 |
+
/>
|
| 31 |
+
</div>
|
| 32 |
+
</Sidebar>
|
| 33 |
+
);
|
| 34 |
+
};
|
| 35 |
+
|
| 36 |
+
export const Save = (): JSX.Element => {
|
| 37 |
+
return (
|
| 38 |
+
<div { ...useBlockProps.save() }>
|
| 39 |
+
<InnerBlocks.Content />
|
| 40 |
+
</div>
|
| 41 |
+
);
|
| 42 |
+
};
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-totals-block/frontend.tsx
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { Sidebar } from '@woocommerce/base-components/sidebar-layout';
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* Internal dependencies
|
| 8 |
+
*/
|
| 9 |
+
import './style.scss';
|
| 10 |
+
|
| 11 |
+
const FrontendBlock = ( {
|
| 12 |
+
children,
|
| 13 |
+
}: {
|
| 14 |
+
children: JSX.Element;
|
| 15 |
+
} ): JSX.Element => {
|
| 16 |
+
return <Sidebar className="wc-block-cart__sidebar">{ children }</Sidebar>;
|
| 17 |
+
};
|
| 18 |
+
|
| 19 |
+
export default FrontendBlock;
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-totals-block/index.tsx
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { Icon, column } from '@wordpress/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: <Icon icon={ column } />,
|
| 16 |
+
foreground: '#874FB9',
|
| 17 |
+
},
|
| 18 |
+
edit: Edit,
|
| 19 |
+
save: Save,
|
| 20 |
+
} );
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/cart-totals-block/style.scss
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.is-mobile,
|
| 2 |
+
.is-small,
|
| 3 |
+
.is-medium {
|
| 4 |
+
.wc-block-cart__sidebar {
|
| 5 |
+
margin-bottom: $gap-large;
|
| 6 |
+
order: 0;
|
| 7 |
+
}
|
| 8 |
+
}
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/empty-cart-block/block.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "woocommerce/empty-cart-block",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"title": "Empty Cart",
|
| 5 |
+
"description": "Contains blocks that are displayed when the cart is empty.",
|
| 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/cart-i2" ],
|
| 24 |
+
"textdomain": "woo-gutenberg-products-block",
|
| 25 |
+
"apiVersion": 2
|
| 26 |
+
}
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/empty-cart-block/edit.tsx
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { useBlockProps, InnerBlocks } from '@wordpress/block-editor';
|
| 5 |
+
import { innerBlockAreas } from '@woocommerce/blocks-checkout';
|
| 6 |
+
|
| 7 |
+
/**
|
| 8 |
+
* Internal dependencies
|
| 9 |
+
*/
|
| 10 |
+
import { useForcedLayout } from '../../use-forced-layout';
|
| 11 |
+
import { getAllowedBlocks } from '../../editor-utils';
|
| 12 |
+
import { useCartBlockContext } from '../../context';
|
| 13 |
+
|
| 14 |
+
export const Edit = ( { clientId }: { clientId: string } ): JSX.Element => {
|
| 15 |
+
const blockProps = useBlockProps();
|
| 16 |
+
const { currentView } = useCartBlockContext();
|
| 17 |
+
const allowedBlocks = getAllowedBlocks( innerBlockAreas.EMPTY_CART );
|
| 18 |
+
|
| 19 |
+
useForcedLayout( {
|
| 20 |
+
clientId,
|
| 21 |
+
template: allowedBlocks,
|
| 22 |
+
} );
|
| 23 |
+
|
| 24 |
+
return (
|
| 25 |
+
<div
|
| 26 |
+
{ ...blockProps }
|
| 27 |
+
hidden={ currentView !== 'woocommerce/empty-cart-block' }
|
| 28 |
+
>
|
| 29 |
+
This is the empty cart block.
|
| 30 |
+
<InnerBlocks
|
| 31 |
+
allowedBlocks={ allowedBlocks }
|
| 32 |
+
templateLock={ false }
|
| 33 |
+
/>
|
| 34 |
+
</div>
|
| 35 |
+
);
|
| 36 |
+
};
|
| 37 |
+
|
| 38 |
+
export const Save = (): JSX.Element => {
|
| 39 |
+
return (
|
| 40 |
+
<div { ...useBlockProps.save() }>
|
| 41 |
+
<InnerBlocks.Content />
|
| 42 |
+
</div>
|
| 43 |
+
);
|
| 44 |
+
};
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/empty-cart-block/frontend.tsx
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { useStoreCart } from '@woocommerce/base-context/hooks';
|
| 5 |
+
import { useEffect } from '@wordpress/element';
|
| 6 |
+
import { dispatchEvent } from '@woocommerce/base-utils';
|
| 7 |
+
|
| 8 |
+
const FrontendBlock = ( {
|
| 9 |
+
children,
|
| 10 |
+
}: {
|
| 11 |
+
children: JSX.Element;
|
| 12 |
+
} ): JSX.Element | null => {
|
| 13 |
+
const { cartItems, cartIsLoading } = useStoreCart();
|
| 14 |
+
useEffect( () => {
|
| 15 |
+
dispatchEvent( 'wc-blocks_render_blocks_frontend', {
|
| 16 |
+
element: document.body.querySelector(
|
| 17 |
+
'.wp-block-woocommerce-cart'
|
| 18 |
+
),
|
| 19 |
+
} );
|
| 20 |
+
}, [] );
|
| 21 |
+
if ( ! cartIsLoading && cartItems.length === 0 ) {
|
| 22 |
+
return <>{ children }</>;
|
| 23 |
+
}
|
| 24 |
+
return null;
|
| 25 |
+
};
|
| 26 |
+
|
| 27 |
+
export default FrontendBlock;
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/empty-cart-block/index.tsx
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { Icon, removeCart } 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: <Icon srcElement={ removeCart } />,
|
| 16 |
+
foreground: '#874FB9',
|
| 17 |
+
},
|
| 18 |
+
edit: Edit,
|
| 19 |
+
save: Save,
|
| 20 |
+
} );
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/filled-cart-block/block.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "woocommerce/filled-cart-block",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"title": "Filled Cart",
|
| 5 |
+
"description": "Contains blocks that are displayed when the cart contains products.",
|
| 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/cart-i2" ],
|
| 24 |
+
"textdomain": "woo-gutenberg-products-block",
|
| 25 |
+
"apiVersion": 2
|
| 26 |
+
}
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/filled-cart-block/edit.tsx
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { useBlockProps, InnerBlocks } from '@wordpress/block-editor';
|
| 5 |
+
import { innerBlockAreas } from '@woocommerce/blocks-checkout';
|
| 6 |
+
import { SidebarLayout } from '@woocommerce/base-components/sidebar-layout';
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* Internal dependencies
|
| 10 |
+
*/
|
| 11 |
+
import { useForcedLayout } from '../../use-forced-layout';
|
| 12 |
+
import { getAllowedBlocks } from '../../editor-utils';
|
| 13 |
+
import { Columns } from './../../columns';
|
| 14 |
+
import './editor.scss';
|
| 15 |
+
import { useCartBlockContext } from '../../context';
|
| 16 |
+
|
| 17 |
+
export const Edit = ( { clientId }: { clientId: string } ): JSX.Element => {
|
| 18 |
+
const blockProps = useBlockProps();
|
| 19 |
+
const { currentView } = useCartBlockContext();
|
| 20 |
+
const allowedBlocks = getAllowedBlocks( innerBlockAreas.FILLED_CART );
|
| 21 |
+
|
| 22 |
+
useForcedLayout( {
|
| 23 |
+
clientId,
|
| 24 |
+
template: allowedBlocks,
|
| 25 |
+
} );
|
| 26 |
+
return (
|
| 27 |
+
<div
|
| 28 |
+
{ ...blockProps }
|
| 29 |
+
hidden={ currentView !== 'woocommerce/filled-cart-block' }
|
| 30 |
+
>
|
| 31 |
+
<Columns>
|
| 32 |
+
<SidebarLayout className={ 'wc-block-cart' }>
|
| 33 |
+
<InnerBlocks
|
| 34 |
+
allowedBlocks={ allowedBlocks }
|
| 35 |
+
templateLock={ false }
|
| 36 |
+
/>
|
| 37 |
+
</SidebarLayout>
|
| 38 |
+
</Columns>
|
| 39 |
+
</div>
|
| 40 |
+
);
|
| 41 |
+
};
|
| 42 |
+
|
| 43 |
+
export const Save = (): JSX.Element => {
|
| 44 |
+
return (
|
| 45 |
+
<div { ...useBlockProps.save() }>
|
| 46 |
+
<InnerBlocks.Content />
|
| 47 |
+
</div>
|
| 48 |
+
);
|
| 49 |
+
};
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/filled-cart-block/editor.scss
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.wp-block-woocommerce-filled-cart-block {
|
| 2 |
+
.wc-block-components-sidebar-layout {
|
| 3 |
+
display: block;
|
| 4 |
+
}
|
| 5 |
+
.block-editor-block-list__layout {
|
| 6 |
+
display: flex;
|
| 7 |
+
flex-flow: row wrap;
|
| 8 |
+
align-items: flex-start;
|
| 9 |
+
}
|
| 10 |
+
.wc-block-components-main,
|
| 11 |
+
.wc-block-components-sidebar,
|
| 12 |
+
.block-editor-block-list__layout {
|
| 13 |
+
> :first-child {
|
| 14 |
+
margin-top: 0;
|
| 15 |
+
}
|
| 16 |
+
}
|
| 17 |
+
.wp-block-woocommerce-cart-totals-block,
|
| 18 |
+
.wp-block-woocommerce-cart-items-block {
|
| 19 |
+
.block-editor-block-list__layout {
|
| 20 |
+
display: block;
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
}
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/filled-cart-block/frontend.tsx
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import classnames from 'classnames';
|
| 5 |
+
import { SidebarLayout } from '@woocommerce/base-components/sidebar-layout';
|
| 6 |
+
import { useStoreCart, useStoreNotices } from '@woocommerce/base-context/hooks';
|
| 7 |
+
import { useEffect } from '@wordpress/element';
|
| 8 |
+
import { decodeEntities } from '@wordpress/html-entities';
|
| 9 |
+
|
| 10 |
+
const FrontendBlock = ( {
|
| 11 |
+
children,
|
| 12 |
+
}: {
|
| 13 |
+
children: JSX.Element;
|
| 14 |
+
} ): JSX.Element | null => {
|
| 15 |
+
const { cartItems, cartIsLoading, cartItemErrors } = useStoreCart();
|
| 16 |
+
const { addErrorNotice } = useStoreNotices();
|
| 17 |
+
|
| 18 |
+
// Ensures any cart errors listed in the API response get shown.
|
| 19 |
+
useEffect( () => {
|
| 20 |
+
cartItemErrors.forEach( ( error ) => {
|
| 21 |
+
addErrorNotice( decodeEntities( error.message ), {
|
| 22 |
+
isDismissible: true,
|
| 23 |
+
id: error.code,
|
| 24 |
+
} );
|
| 25 |
+
} );
|
| 26 |
+
}, [ addErrorNotice, cartItemErrors ] );
|
| 27 |
+
// @todo pass attributes to inner most blocks.
|
| 28 |
+
const hasDarkControls = false;
|
| 29 |
+
if ( cartIsLoading || cartItems.length >= 1 ) {
|
| 30 |
+
return (
|
| 31 |
+
<SidebarLayout
|
| 32 |
+
className={ classnames( 'wc-block-cart', {
|
| 33 |
+
'has-dark-controls': hasDarkControls,
|
| 34 |
+
} ) }
|
| 35 |
+
>
|
| 36 |
+
{ children }
|
| 37 |
+
</SidebarLayout>
|
| 38 |
+
);
|
| 39 |
+
}
|
| 40 |
+
return null;
|
| 41 |
+
};
|
| 42 |
+
|
| 43 |
+
export default FrontendBlock;
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/filled-cart-block/index.tsx
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { Icon, filledCart } 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: <Icon srcElement={ filledCart } />,
|
| 16 |
+
foreground: '#874FB9',
|
| 17 |
+
},
|
| 18 |
+
edit: Edit,
|
| 19 |
+
save: Save,
|
| 20 |
+
} );
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/index.tsx
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Internal dependencies
|
| 3 |
+
*/
|
| 4 |
+
import './filled-cart-block';
|
| 5 |
+
import './cart-items-block';
|
| 6 |
+
import './cart-line-items-block';
|
| 7 |
+
import './cart-totals-block';
|
| 8 |
+
import './cart-order-summary-block';
|
| 9 |
+
import './cart-express-payment-block';
|
| 10 |
+
import './proceed-to-checkout-block';
|
| 11 |
+
import './empty-cart-block';
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/proceed-to-checkout-block/attributes.tsx
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export default {
|
| 2 |
+
checkoutPageId: {
|
| 3 |
+
type: 'number',
|
| 4 |
+
default: 0,
|
| 5 |
+
},
|
| 6 |
+
lock: {
|
| 7 |
+
type: 'object',
|
| 8 |
+
default: {
|
| 9 |
+
move: true,
|
| 10 |
+
remove: true,
|
| 11 |
+
},
|
| 12 |
+
},
|
| 13 |
+
};
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/proceed-to-checkout-block/block.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "woocommerce/proceed-to-checkout-block",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"title": "Proceed to checkout",
|
| 5 |
+
"description": "Allow customers proceed to Checkout.",
|
| 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 |
+
"default": {
|
| 17 |
+
"remove": true,
|
| 18 |
+
"move": true
|
| 19 |
+
}
|
| 20 |
+
}
|
| 21 |
+
},
|
| 22 |
+
"parent": [ "woocommerce/cart-totals-block" ],
|
| 23 |
+
"textdomain": "woo-gutenberg-products-block",
|
| 24 |
+
"apiVersion": 2
|
| 25 |
+
}
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/proceed-to-checkout-block/block.tsx
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { getSetting } from '@woocommerce/settings';
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* Internal dependencies
|
| 8 |
+
*/
|
| 9 |
+
import CheckoutButton from '../../checkout-button';
|
| 10 |
+
|
| 11 |
+
const Block = ( {
|
| 12 |
+
checkoutPageId,
|
| 13 |
+
}: {
|
| 14 |
+
checkoutPageId: number;
|
| 15 |
+
} ): JSX.Element => {
|
| 16 |
+
return (
|
| 17 |
+
<CheckoutButton
|
| 18 |
+
link={ getSetting( 'page-' + checkoutPageId, false ) }
|
| 19 |
+
/>
|
| 20 |
+
);
|
| 21 |
+
};
|
| 22 |
+
|
| 23 |
+
export default Block;
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/proceed-to-checkout-block/edit.tsx
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { useRef } from '@wordpress/element';
|
| 5 |
+
import { useSelect } from '@wordpress/data';
|
| 6 |
+
import { __ } from '@wordpress/i18n';
|
| 7 |
+
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
|
| 8 |
+
import PageSelector from '@woocommerce/editor-components/page-selector';
|
| 9 |
+
import { Disabled } from '@wordpress/components';
|
| 10 |
+
import { CART_PAGE_ID } from '@woocommerce/block-settings';
|
| 11 |
+
/**
|
| 12 |
+
* Internal dependencies
|
| 13 |
+
*/
|
| 14 |
+
import Block from './block';
|
| 15 |
+
export const Edit = ( {
|
| 16 |
+
attributes,
|
| 17 |
+
setAttributes,
|
| 18 |
+
}: {
|
| 19 |
+
attributes: {
|
| 20 |
+
checkoutPageId: number;
|
| 21 |
+
};
|
| 22 |
+
setAttributes: ( attributes: Record< string, unknown > ) => void;
|
| 23 |
+
} ): JSX.Element => {
|
| 24 |
+
const blockProps = useBlockProps();
|
| 25 |
+
const { checkoutPageId = 0 } = attributes;
|
| 26 |
+
const { current: savedCheckoutPageId } = useRef( checkoutPageId );
|
| 27 |
+
const currentPostId = useSelect(
|
| 28 |
+
( select ) => {
|
| 29 |
+
if ( ! savedCheckoutPageId ) {
|
| 30 |
+
const store = select( 'core/editor' );
|
| 31 |
+
return store.getCurrentPostId();
|
| 32 |
+
}
|
| 33 |
+
return savedCheckoutPageId;
|
| 34 |
+
},
|
| 35 |
+
[ savedCheckoutPageId ]
|
| 36 |
+
);
|
| 37 |
+
|
| 38 |
+
return (
|
| 39 |
+
<div { ...blockProps }>
|
| 40 |
+
<InspectorControls>
|
| 41 |
+
{ ! (
|
| 42 |
+
currentPostId === CART_PAGE_ID && savedCheckoutPageId === 0
|
| 43 |
+
) && (
|
| 44 |
+
<PageSelector
|
| 45 |
+
pageId={ checkoutPageId }
|
| 46 |
+
setPageId={ ( id ) =>
|
| 47 |
+
setAttributes( { checkoutPageId: id } )
|
| 48 |
+
}
|
| 49 |
+
labels={ {
|
| 50 |
+
title: __(
|
| 51 |
+
'Proceed to Checkout button',
|
| 52 |
+
'woo-gutenberg-products-block'
|
| 53 |
+
),
|
| 54 |
+
default: __(
|
| 55 |
+
'WooCommerce Checkout Page',
|
| 56 |
+
'woo-gutenberg-products-block'
|
| 57 |
+
),
|
| 58 |
+
} }
|
| 59 |
+
/>
|
| 60 |
+
) }
|
| 61 |
+
</InspectorControls>
|
| 62 |
+
<Disabled>
|
| 63 |
+
<Block checkoutPageId={ checkoutPageId } />
|
| 64 |
+
</Disabled>
|
| 65 |
+
</div>
|
| 66 |
+
);
|
| 67 |
+
};
|
| 68 |
+
|
| 69 |
+
export const Save = (): JSX.Element => {
|
| 70 |
+
return <div { ...useBlockProps.save() } />;
|
| 71 |
+
};
|
assets/js/blocks/cart-checkout/{checkout-i2/inner-blocks/checkout-actions-block → cart-i2/inner-blocks/proceed-to-checkout-block}/frontend.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/proceed-to-checkout-block/index.tsx
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { Icon, button } from '@wordpress/icons';
|
| 5 |
+
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
| 6 |
+
|
| 7 |
+
/**
|
| 8 |
+
* Internal dependencies
|
| 9 |
+
*/
|
| 10 |
+
import attributes from './attributes';
|
| 11 |
+
import { Edit, Save } from './edit';
|
| 12 |
+
import metadata from './block.json';
|
| 13 |
+
|
| 14 |
+
registerFeaturePluginBlockType( metadata, {
|
| 15 |
+
icon: {
|
| 16 |
+
src: <Icon icon={ button } />,
|
| 17 |
+
foreground: '#874FB9',
|
| 18 |
+
},
|
| 19 |
+
attributes,
|
| 20 |
+
edit: Edit,
|
| 21 |
+
save: Save,
|
| 22 |
+
} );
|
assets/js/blocks/cart-checkout/cart-i2/inner-blocks/register-components.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { lazy } from '@wordpress/element';
|
| 5 |
+
import { WC_BLOCKS_BUILD_URL } from '@woocommerce/block-settings';
|
| 6 |
+
import { registerCheckoutBlock } from '@woocommerce/blocks-checkout';
|
| 7 |
+
|
| 8 |
+
// Modify webpack publicPath at runtime based on location of WordPress Plugin.
|
| 9 |
+
// eslint-disable-next-line no-undef,camelcase
|
| 10 |
+
__webpack_public_path__ = WC_BLOCKS_BUILD_URL;
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* Internal dependencies
|
| 14 |
+
*/
|
| 15 |
+
import filledCartMetadata from './filled-cart-block/block.json';
|
| 16 |
+
import emptyCartMetadata from './empty-cart-block/block.json';
|
| 17 |
+
import cartItemsMetadata from './cart-items-block/block.json';
|
| 18 |
+
import cartExpressPaymentMetadata from './cart-express-payment-block/block.json';
|
| 19 |
+
import cartLineItemsMetadata from './cart-line-items-block/block.json';
|
| 20 |
+
import cartOrderSummaryMetadata from './cart-order-summary-block/block.json';
|
| 21 |
+
import cartTotalsMetadata from './cart-totals-block/block.json';
|
| 22 |
+
import cartProceedToCheckoutMetadata from './proceed-to-checkout-block/block.json';
|
| 23 |
+
|
| 24 |
+
registerCheckoutBlock( {
|
| 25 |
+
metadata: filledCartMetadata,
|
| 26 |
+
component: lazy( () =>
|
| 27 |
+
import(
|
| 28 |
+
/* webpackChunkName: "cart-blocks/filled-cart" */ './filled-cart-block/frontend'
|
| 29 |
+
)
|
| 30 |
+
),
|
| 31 |
+
} );
|
| 32 |
+
registerCheckoutBlock( {
|
| 33 |
+
metadata: emptyCartMetadata,
|
| 34 |
+
component: lazy( () =>
|
| 35 |
+
import(
|
| 36 |
+
/* webpackChunkName: "cart-blocks/empty-cart" */ './empty-cart-block/frontend'
|
| 37 |
+
)
|
| 38 |
+
),
|
| 39 |
+
} );
|
| 40 |
+
registerCheckoutBlock( {
|
| 41 |
+
metadata: filledCartMetadata,
|
| 42 |
+
component: lazy( () =>
|
| 43 |
+
import(
|
| 44 |
+
/* webpackChunkName: "cart-blocks/filled-cart" */ './filled-cart-block/frontend'
|
| 45 |
+
)
|
| 46 |
+
),
|
| 47 |
+
} );
|
| 48 |
+
registerCheckoutBlock( {
|
| 49 |
+
metadata: emptyCartMetadata,
|
| 50 |
+
component: lazy( () =>
|
| 51 |
+
import(
|
| 52 |
+
/* webpackChunkName: "cart-blocks/empty-cart" */ './empty-cart-block/frontend'
|
| 53 |
+
)
|
| 54 |
+
),
|
| 55 |
+
} );
|
| 56 |
+
registerCheckoutBlock( {
|
| 57 |
+
metadata: cartItemsMetadata,
|
| 58 |
+
component: lazy( () =>
|
| 59 |
+
import(
|
| 60 |
+
/* webpackChunkName: "cart-blocks/items" */ './cart-items-block/frontend'
|
| 61 |
+
)
|
| 62 |
+
),
|
| 63 |
+
} );
|
| 64 |
+
|
| 65 |
+
registerCheckoutBlock( {
|
| 66 |
+
metadata: cartLineItemsMetadata,
|
| 67 |
+
component: lazy( () =>
|
| 68 |
+
import(
|
| 69 |
+
/* webpackChunkName: "cart-blocks/line-items" */ './cart-line-items-block/block'
|
| 70 |
+
)
|
| 71 |
+
),
|
| 72 |
+
} );
|
| 73 |
+
|
| 74 |
+
registerCheckoutBlock( {
|
| 75 |
+
metadata: cartTotalsMetadata,
|
| 76 |
+
component: lazy( () =>
|
| 77 |
+
import(
|
| 78 |
+
/* webpackChunkName: "cart-blocks/totals" */ './cart-totals-block/frontend'
|
| 79 |
+
)
|
| 80 |
+
),
|
| 81 |
+
} );
|
| 82 |
+
|
| 83 |
+
registerCheckoutBlock( {
|
| 84 |
+
metadata: cartOrderSummaryMetadata,
|
| 85 |
+
component: lazy( () =>
|
| 86 |
+
import(
|
| 87 |
+
/* webpackChunkName: "cart-blocks/order-summary" */ './cart-order-summary-block/block'
|
| 88 |
+
)
|
| 89 |
+
),
|
| 90 |
+
} );
|
| 91 |
+
|
| 92 |
+
registerCheckoutBlock( {
|
| 93 |
+
metadata: cartExpressPaymentMetadata,
|
| 94 |
+
component: lazy( () =>
|
| 95 |
+
import(
|
| 96 |
+
/* webpackChunkName: "cart-blocks/express-payment" */ './cart-express-payment-block/block'
|
| 97 |
+
)
|
| 98 |
+
),
|
| 99 |
+
} );
|
| 100 |
+
|
| 101 |
+
registerCheckoutBlock( {
|
| 102 |
+
metadata: cartProceedToCheckoutMetadata,
|
| 103 |
+
component: lazy( () =>
|
| 104 |
+
import(
|
| 105 |
+
/* webpackChunkName: "cart-blocks/checkout-button" */ './proceed-to-checkout-block/frontend'
|
| 106 |
+
)
|
| 107 |
+
),
|
| 108 |
+
} );
|
assets/js/blocks/cart-checkout/cart-i2/style.scss
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.wp-block-woocommerce-cart.is-loading {
|
| 2 |
+
display: none;
|
| 3 |
+
}
|
| 4 |
+
|
| 5 |
+
.wp-block-woocommerce-cart {
|
| 6 |
+
margin-bottom: 3em;
|
| 7 |
+
}
|
assets/js/blocks/cart-checkout/cart-i2/types.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export type InnerBlockTemplate = [
|
| 2 |
+
string,
|
| 3 |
+
Record< string, unknown >,
|
| 4 |
+
InnerBlockTemplate[] | undefined
|
| 5 |
+
];
|
| 6 |
+
|
| 7 |
+
export interface Attributes {
|
| 8 |
+
isPreview: boolean;
|
| 9 |
+
isShippingCalculatorEnabled: boolean;
|
| 10 |
+
hasDarkControls: boolean;
|
| 11 |
+
showRateAfterTaxName: boolean;
|
| 12 |
+
checkoutPageId: number;
|
| 13 |
+
}
|
assets/js/blocks/cart-checkout/{checkout-i2 → cart-i2}/use-forced-layout.ts
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/cart-i2/use-view-switcher.tsx
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { __ } from '@wordpress/i18n';
|
| 5 |
+
import { useState } from '@wordpress/element';
|
| 6 |
+
import { useDispatch, select } from '@wordpress/data';
|
| 7 |
+
import { Toolbar, ToolbarDropdownMenu } from '@wordpress/components';
|
| 8 |
+
import { Icon, eye } from '@woocommerce/icons';
|
| 9 |
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
| 10 |
+
|
| 11 |
+
interface View {
|
| 12 |
+
view: string;
|
| 13 |
+
label: string;
|
| 14 |
+
icon: string | JSX.Element;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
export const useViewSwitcher = (
|
| 18 |
+
clientId: string,
|
| 19 |
+
views: View[]
|
| 20 |
+
): {
|
| 21 |
+
currentView: string;
|
| 22 |
+
component: () => JSX.Element;
|
| 23 |
+
} => {
|
| 24 |
+
const initialView = views[ 0 ];
|
| 25 |
+
const [ currentView, setCurrentView ] = useState( initialView );
|
| 26 |
+
const { selectBlock } = useDispatch( 'core/block-editor' );
|
| 27 |
+
const { getBlock } = select( blockEditorStore );
|
| 28 |
+
|
| 29 |
+
const ViewSwitcherComponent = () => (
|
| 30 |
+
<Toolbar>
|
| 31 |
+
<ToolbarDropdownMenu
|
| 32 |
+
label={ __( 'Switch view', 'woo-gutenberg-products-block' ) }
|
| 33 |
+
text={ currentView.label }
|
| 34 |
+
icon={
|
| 35 |
+
<Icon srcElement={ eye } style={ { marginRight: '8px' } } />
|
| 36 |
+
}
|
| 37 |
+
controls={ views.map( ( view ) => ( {
|
| 38 |
+
...view,
|
| 39 |
+
title: view.label,
|
| 40 |
+
onClick: () => {
|
| 41 |
+
setCurrentView( view );
|
| 42 |
+
selectBlock(
|
| 43 |
+
getBlock( clientId ).innerBlocks.find(
|
| 44 |
+
( block: { name: string } ) =>
|
| 45 |
+
block.name === view.view
|
| 46 |
+
)?.clientId || clientId
|
| 47 |
+
);
|
| 48 |
+
},
|
| 49 |
+
} ) ) }
|
| 50 |
+
/>
|
| 51 |
+
</Toolbar>
|
| 52 |
+
);
|
| 53 |
+
|
| 54 |
+
return {
|
| 55 |
+
currentView: currentView.view,
|
| 56 |
+
component: ViewSwitcherComponent,
|
| 57 |
+
};
|
| 58 |
+
};
|
| 59 |
+
|
| 60 |
+
export default useViewSwitcher;
|
assets/js/blocks/cart-checkout/cart/block.js
CHANGED
|
@@ -33,8 +33,11 @@ const Block = ( { emptyCart, attributes, scrollToTop } ) => {
|
|
| 33 |
const { cartItems, cartIsLoading } = useStoreCart();
|
| 34 |
|
| 35 |
useEffect( () => {
|
| 36 |
-
const invalidateCartData = () => {
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
| 38 |
scrollToTop();
|
| 39 |
};
|
| 40 |
|
| 33 |
const { cartItems, cartIsLoading } = useStoreCart();
|
| 34 |
|
| 35 |
useEffect( () => {
|
| 36 |
+
const invalidateCartData = ( e ) => {
|
| 37 |
+
const eventDetail = e.detail;
|
| 38 |
+
if ( ! eventDetail || ! eventDetail.preserveCartData ) {
|
| 39 |
+
dispatch( storeKey ).invalidateResolutionForStore();
|
| 40 |
+
}
|
| 41 |
scrollToTop();
|
| 42 |
};
|
| 43 |
|
assets/js/blocks/cart-checkout/cart/checkout-button/index.tsx
CHANGED
|
@@ -9,22 +9,25 @@ import { CHECKOUT_URL } from '@woocommerce/block-settings';
|
|
| 9 |
import { useCheckoutContext } from '@woocommerce/base-context';
|
| 10 |
import { usePaymentMethods } from '@woocommerce/base-context/hooks';
|
| 11 |
import { usePositionRelativeToViewport } from '@woocommerce/base-hooks';
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
/**
|
| 14 |
* Internal dependencies
|
| 15 |
*/
|
| 16 |
import './style.scss';
|
| 17 |
-
import type PaymentMethodConfig from '../../../../blocks-registry/payment-methods/payment-method-config';
|
| 18 |
|
| 19 |
const getIconsFromPaymentMethods = (
|
| 20 |
-
paymentMethods:
|
| 21 |
-
) => {
|
| 22 |
return Object.values( paymentMethods ).reduce( ( acc, paymentMethod ) => {
|
| 23 |
if ( paymentMethod.icons !== null ) {
|
| 24 |
acc = acc.concat( paymentMethod.icons );
|
| 25 |
}
|
| 26 |
return acc;
|
| 27 |
-
}, [] );
|
| 28 |
};
|
| 29 |
|
| 30 |
/**
|
| 9 |
import { useCheckoutContext } from '@woocommerce/base-context';
|
| 10 |
import { usePaymentMethods } from '@woocommerce/base-context/hooks';
|
| 11 |
import { usePositionRelativeToViewport } from '@woocommerce/base-hooks';
|
| 12 |
+
import type {
|
| 13 |
+
PaymentMethods,
|
| 14 |
+
PaymentMethodIcons as PaymentMethodIconsType,
|
| 15 |
+
} from '@woocommerce/type-defs/payments';
|
| 16 |
|
| 17 |
/**
|
| 18 |
* Internal dependencies
|
| 19 |
*/
|
| 20 |
import './style.scss';
|
|
|
|
| 21 |
|
| 22 |
const getIconsFromPaymentMethods = (
|
| 23 |
+
paymentMethods: PaymentMethods
|
| 24 |
+
): PaymentMethodIconsType => {
|
| 25 |
return Object.values( paymentMethods ).reduce( ( acc, paymentMethod ) => {
|
| 26 |
if ( paymentMethod.icons !== null ) {
|
| 27 |
acc = acc.concat( paymentMethod.icons );
|
| 28 |
}
|
| 29 |
return acc;
|
| 30 |
+
}, [] as PaymentMethodIconsType );
|
| 31 |
};
|
| 32 |
|
| 33 |
/**
|
assets/js/blocks/cart-checkout/cart/full-cart/cart-line-item-row.tsx
CHANGED
|
@@ -2,7 +2,8 @@
|
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import classnames from 'classnames';
|
| 5 |
-
import { __ } from '@wordpress/i18n';
|
|
|
|
| 6 |
import QuantitySelector from '@woocommerce/base-components/quantity-selector';
|
| 7 |
import ProductPrice from '@woocommerce/base-components/product-price';
|
| 8 |
import ProductName from '@woocommerce/base-components/product-name';
|
|
@@ -27,7 +28,7 @@ import {
|
|
| 27 |
mustContain,
|
| 28 |
} from '@woocommerce/blocks-checkout';
|
| 29 |
import Dinero from 'dinero.js';
|
| 30 |
-
import { useMemo } from '@wordpress/element';
|
| 31 |
import type { CartItem } from '@woocommerce/type-defs/cart';
|
| 32 |
import { objectHasProp } from '@woocommerce/types';
|
| 33 |
import { getSetting } from '@woocommerce/settings';
|
|
@@ -48,262 +49,284 @@ const getAmountFromRawPrice = (
|
|
| 48 |
|
| 49 |
const productPriceValidation = ( value ) => mustContain( value, '<price/>' );
|
| 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
/**
|
| 52 |
* Cart line item table row component.
|
| 53 |
-
*
|
| 54 |
-
* @param {Object} props
|
| 55 |
-
* @param {CartItem|Object} props.lineItem
|
| 56 |
*/
|
| 57 |
-
const CartLineItemRow = (
|
| 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 |
-
price: '0',
|
| 83 |
-
regular_price: '0',
|
| 84 |
-
sale_price: '0',
|
| 85 |
-
price_range: null,
|
| 86 |
-
raw_prices: {
|
| 87 |
-
precision: 6,
|
| 88 |
price: '0',
|
| 89 |
regular_price: '0',
|
| 90 |
sale_price: '0',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
},
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
} = lineItem;
|
| 106 |
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
|
| 161 |
-
|
| 162 |
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
<td
|
| 195 |
-
className="wc-block-cart-item__image"
|
| 196 |
-
aria-hidden={
|
| 197 |
-
! objectHasProp( firstImage, 'alt' ) || ! firstImage.alt
|
| 198 |
-
}
|
| 199 |
>
|
| 200 |
-
{ /*
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
<ProductImage image={ firstImage } />
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
/>
|
| 222 |
-
|
| 223 |
-
) }
|
| 224 |
|
| 225 |
-
|
| 226 |
-
<ProductPrice
|
| 227 |
currency={ priceCurrency }
|
| 228 |
-
|
| 229 |
-
|
| 230 |
priceCurrency
|
| 231 |
) }
|
| 232 |
-
|
| 233 |
-
purchaseAmountSingle,
|
| 234 |
-
priceCurrency
|
| 235 |
-
) }
|
| 236 |
-
format={ subtotalPriceFormat }
|
| 237 |
/>
|
| 238 |
-
</div>
|
| 239 |
-
|
| 240 |
-
<ProductSaleBadge
|
| 241 |
-
currency={ priceCurrency }
|
| 242 |
-
saleAmount={ getAmountFromRawPrice(
|
| 243 |
-
saleAmountSingle,
|
| 244 |
-
priceCurrency
|
| 245 |
-
) }
|
| 246 |
-
format={ saleBadgePriceFormat }
|
| 247 |
-
/>
|
| 248 |
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
/>
|
| 255 |
-
|
| 256 |
-
<div className="wc-block-cart-item__quantity">
|
| 257 |
-
<QuantitySelector
|
| 258 |
-
disabled={ isPendingDelete }
|
| 259 |
-
quantity={ quantity }
|
| 260 |
-
maximum={ quantityLimit }
|
| 261 |
-
onChange={ ( newQuantity ) => {
|
| 262 |
-
setItemQuantity( newQuantity );
|
| 263 |
-
dispatchStoreEvent( 'cart-set-item-quantity', {
|
| 264 |
-
product: lineItem,
|
| 265 |
-
quantity: newQuantity,
|
| 266 |
-
} );
|
| 267 |
-
} }
|
| 268 |
-
itemName={ name }
|
| 269 |
-
/>
|
| 270 |
-
<button
|
| 271 |
-
className="wc-block-cart-item__remove-link"
|
| 272 |
-
onClick={ () => {
|
| 273 |
-
removeItem();
|
| 274 |
-
dispatchStoreEvent( 'cart-remove-item', {
|
| 275 |
-
product: lineItem,
|
| 276 |
-
quantity,
|
| 277 |
-
} );
|
| 278 |
-
} }
|
| 279 |
-
disabled={ isPendingDelete }
|
| 280 |
-
>
|
| 281 |
-
{ __( 'Remove item', 'woo-gutenberg-products-block' ) }
|
| 282 |
-
</button>
|
| 283 |
-
</div>
|
| 284 |
-
</td>
|
| 285 |
-
<td className="wc-block-cart-item__total">
|
| 286 |
-
<div className="wc-block-cart-item__total-price-and-sale-badge-wrapper">
|
| 287 |
-
<ProductPrice
|
| 288 |
-
currency={ totalsCurrency }
|
| 289 |
-
format={ productPriceFormat }
|
| 290 |
-
price={ subtotalPrice.getAmount() }
|
| 291 |
/>
|
| 292 |
|
| 293 |
-
|
| 294 |
-
<
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
) }
|
| 300 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 301 |
/>
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 308 |
|
| 309 |
export default CartLineItemRow;
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import classnames from 'classnames';
|
| 5 |
+
import { __, sprintf } from '@wordpress/i18n';
|
| 6 |
+
import { speak } from '@wordpress/a11y';
|
| 7 |
import QuantitySelector from '@woocommerce/base-components/quantity-selector';
|
| 8 |
import ProductPrice from '@woocommerce/base-components/product-price';
|
| 9 |
import ProductName from '@woocommerce/base-components/product-name';
|
| 28 |
mustContain,
|
| 29 |
} from '@woocommerce/blocks-checkout';
|
| 30 |
import Dinero from 'dinero.js';
|
| 31 |
+
import { forwardRef, useMemo } from '@wordpress/element';
|
| 32 |
import type { CartItem } from '@woocommerce/type-defs/cart';
|
| 33 |
import { objectHasProp } from '@woocommerce/types';
|
| 34 |
import { getSetting } from '@woocommerce/settings';
|
| 49 |
|
| 50 |
const productPriceValidation = ( value ) => mustContain( value, '<price/>' );
|
| 51 |
|
| 52 |
+
interface CartLineItemRowProps {
|
| 53 |
+
lineItem: CartItem | Record< string, never >;
|
| 54 |
+
onRemove?: () => void;
|
| 55 |
+
tabIndex?: number;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
/**
|
| 59 |
* Cart line item table row component.
|
|
|
|
|
|
|
|
|
|
| 60 |
*/
|
| 61 |
+
const CartLineItemRow = forwardRef< HTMLTableRowElement, CartLineItemRowProps >(
|
| 62 |
+
(
|
| 63 |
+
{ lineItem, onRemove = () => void null, tabIndex = null },
|
| 64 |
+
ref
|
| 65 |
+
): JSX.Element => {
|
| 66 |
+
const {
|
| 67 |
+
name: initialName = '',
|
| 68 |
+
catalog_visibility: catalogVisibility = 'visible',
|
| 69 |
+
short_description: shortDescription = '',
|
| 70 |
+
description: fullDescription = '',
|
| 71 |
+
low_stock_remaining: lowStockRemaining = null,
|
| 72 |
+
show_backorder_badge: showBackorderBadge = false,
|
| 73 |
+
quantity_limit: quantityLimit = 99,
|
| 74 |
+
permalink = '',
|
| 75 |
+
images = [],
|
| 76 |
+
variation = [],
|
| 77 |
+
item_data: itemData = [],
|
| 78 |
+
prices = {
|
| 79 |
+
currency_code: 'USD',
|
| 80 |
+
currency_minor_unit: 2,
|
| 81 |
+
currency_symbol: '$',
|
| 82 |
+
currency_prefix: '$',
|
| 83 |
+
currency_suffix: '',
|
| 84 |
+
currency_decimal_separator: '.',
|
| 85 |
+
currency_thousand_separator: ',',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
price: '0',
|
| 87 |
regular_price: '0',
|
| 88 |
sale_price: '0',
|
| 89 |
+
price_range: null,
|
| 90 |
+
raw_prices: {
|
| 91 |
+
precision: 6,
|
| 92 |
+
price: '0',
|
| 93 |
+
regular_price: '0',
|
| 94 |
+
sale_price: '0',
|
| 95 |
+
},
|
| 96 |
},
|
| 97 |
+
totals = {
|
| 98 |
+
currency_code: 'USD',
|
| 99 |
+
currency_minor_unit: 2,
|
| 100 |
+
currency_symbol: '$',
|
| 101 |
+
currency_prefix: '$',
|
| 102 |
+
currency_suffix: '',
|
| 103 |
+
currency_decimal_separator: '.',
|
| 104 |
+
currency_thousand_separator: ',',
|
| 105 |
+
line_subtotal: '0',
|
| 106 |
+
line_subtotal_tax: '0',
|
| 107 |
+
},
|
| 108 |
+
extensions,
|
| 109 |
+
} = lineItem;
|
|
|
|
| 110 |
|
| 111 |
+
const {
|
| 112 |
+
quantity,
|
| 113 |
+
setItemQuantity,
|
| 114 |
+
removeItem,
|
| 115 |
+
isPendingDelete,
|
| 116 |
+
} = useStoreCartItemQuantity( lineItem );
|
| 117 |
+
const { dispatchStoreEvent } = useStoreEvents();
|
| 118 |
|
| 119 |
+
// Prepare props to pass to the __experimentalApplyCheckoutFilter filter.
|
| 120 |
+
// We need to pluck out receiveCart.
|
| 121 |
+
// eslint-disable-next-line no-unused-vars
|
| 122 |
+
const { receiveCart, ...cart } = useStoreCart();
|
| 123 |
+
const arg = useMemo(
|
| 124 |
+
() => ( {
|
| 125 |
+
context: 'cart',
|
| 126 |
+
cartItem: lineItem,
|
| 127 |
+
cart,
|
| 128 |
+
} ),
|
| 129 |
+
[ lineItem, cart ]
|
| 130 |
+
);
|
| 131 |
+
const priceCurrency = getCurrencyFromPriceResponse( prices );
|
| 132 |
+
const name = __experimentalApplyCheckoutFilter( {
|
| 133 |
+
filterName: 'itemName',
|
| 134 |
+
defaultValue: initialName,
|
| 135 |
+
extensions,
|
| 136 |
+
arg,
|
| 137 |
+
} );
|
| 138 |
|
| 139 |
+
const regularAmountSingle = Dinero( {
|
| 140 |
+
amount: parseInt( prices.raw_prices.regular_price, 10 ),
|
| 141 |
+
precision: prices.raw_prices.precision,
|
| 142 |
+
} );
|
| 143 |
+
const purchaseAmountSingle = Dinero( {
|
| 144 |
+
amount: parseInt( prices.raw_prices.price, 10 ),
|
| 145 |
+
precision: prices.raw_prices.precision,
|
| 146 |
+
} );
|
| 147 |
+
const saleAmountSingle = regularAmountSingle.subtract(
|
| 148 |
+
purchaseAmountSingle
|
| 149 |
+
);
|
| 150 |
+
const saleAmount = saleAmountSingle.multiply( quantity );
|
| 151 |
+
const totalsCurrency = getCurrencyFromPriceResponse( totals );
|
| 152 |
+
let lineSubtotal = parseInt( totals.line_subtotal, 10 );
|
| 153 |
+
if ( getSetting( 'displayCartPricesIncludingTax', false ) ) {
|
| 154 |
+
lineSubtotal += parseInt( totals.line_subtotal_tax, 10 );
|
| 155 |
+
}
|
| 156 |
+
const subtotalPrice = Dinero( {
|
| 157 |
+
amount: lineSubtotal,
|
| 158 |
+
precision: totalsCurrency.minorUnit,
|
| 159 |
+
} );
|
| 160 |
|
| 161 |
+
const firstImage = images.length ? images[ 0 ] : {};
|
| 162 |
+
const isProductHiddenFromCatalog =
|
| 163 |
+
catalogVisibility === 'hidden' || catalogVisibility === 'search';
|
| 164 |
|
| 165 |
+
// Allow extensions to filter how the price is displayed. Ie: prepending or appending some values.
|
| 166 |
|
| 167 |
+
const productPriceFormat = __experimentalApplyCheckoutFilter( {
|
| 168 |
+
filterName: 'cartItemPrice',
|
| 169 |
+
defaultValue: '<price/>',
|
| 170 |
+
extensions,
|
| 171 |
+
arg,
|
| 172 |
+
validation: productPriceValidation,
|
| 173 |
+
} );
|
| 174 |
|
| 175 |
+
const subtotalPriceFormat = __experimentalApplyCheckoutFilter( {
|
| 176 |
+
filterName: 'subtotalPriceFormat',
|
| 177 |
+
defaultValue: '<price/>',
|
| 178 |
+
extensions,
|
| 179 |
+
arg,
|
| 180 |
+
validation: productPriceValidation,
|
| 181 |
+
} );
|
| 182 |
|
| 183 |
+
const saleBadgePriceFormat = __experimentalApplyCheckoutFilter( {
|
| 184 |
+
filterName: 'saleBadgePriceFormat',
|
| 185 |
+
defaultValue: '<price/>',
|
| 186 |
+
extensions,
|
| 187 |
+
arg,
|
| 188 |
+
validation: productPriceValidation,
|
| 189 |
+
} );
|
| 190 |
|
| 191 |
+
return (
|
| 192 |
+
<tr
|
| 193 |
+
className={ classnames( 'wc-block-cart-items__row', {
|
| 194 |
+
'is-disabled': isPendingDelete,
|
| 195 |
+
} ) }
|
| 196 |
+
ref={ ref }
|
| 197 |
+
tabIndex={ tabIndex }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
>
|
| 199 |
+
{ /* If the image has no alt text, this link is unnecessary and can be hidden. */ }
|
| 200 |
+
<td
|
| 201 |
+
className="wc-block-cart-item__image"
|
| 202 |
+
aria-hidden={
|
| 203 |
+
! objectHasProp( firstImage, 'alt' ) || ! firstImage.alt
|
| 204 |
+
}
|
| 205 |
+
>
|
| 206 |
+
{ /* We don't need to make it focusable, because product name has the same link. */ }
|
| 207 |
+
{ isProductHiddenFromCatalog ? (
|
| 208 |
<ProductImage image={ firstImage } />
|
| 209 |
+
) : (
|
| 210 |
+
<a href={ permalink } tabIndex={ -1 }>
|
| 211 |
+
<ProductImage image={ firstImage } />
|
| 212 |
+
</a>
|
| 213 |
+
) }
|
| 214 |
+
</td>
|
| 215 |
+
<td className="wc-block-cart-item__product">
|
| 216 |
+
<ProductName
|
| 217 |
+
disabled={
|
| 218 |
+
isPendingDelete || isProductHiddenFromCatalog
|
| 219 |
+
}
|
| 220 |
+
name={ name }
|
| 221 |
+
permalink={ permalink }
|
| 222 |
+
/>
|
| 223 |
+
{ showBackorderBadge ? (
|
| 224 |
+
<ProductBackorderBadge />
|
| 225 |
+
) : (
|
| 226 |
+
!! lowStockRemaining && (
|
| 227 |
+
<ProductLowStockBadge
|
| 228 |
+
lowStockRemaining={ lowStockRemaining }
|
| 229 |
+
/>
|
| 230 |
+
)
|
| 231 |
+
) }
|
| 232 |
+
|
| 233 |
+
<div className="wc-block-cart-item__prices">
|
| 234 |
+
<ProductPrice
|
| 235 |
+
currency={ priceCurrency }
|
| 236 |
+
regularPrice={ getAmountFromRawPrice(
|
| 237 |
+
regularAmountSingle,
|
| 238 |
+
priceCurrency
|
| 239 |
+
) }
|
| 240 |
+
price={ getAmountFromRawPrice(
|
| 241 |
+
purchaseAmountSingle,
|
| 242 |
+
priceCurrency
|
| 243 |
+
) }
|
| 244 |
+
format={ subtotalPriceFormat }
|
| 245 |
/>
|
| 246 |
+
</div>
|
|
|
|
| 247 |
|
| 248 |
+
<ProductSaleBadge
|
|
|
|
| 249 |
currency={ priceCurrency }
|
| 250 |
+
saleAmount={ getAmountFromRawPrice(
|
| 251 |
+
saleAmountSingle,
|
| 252 |
priceCurrency
|
| 253 |
) }
|
| 254 |
+
format={ saleBadgePriceFormat }
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 256 |
|
| 257 |
+
<ProductMetadata
|
| 258 |
+
shortDescription={ shortDescription }
|
| 259 |
+
fullDescription={ fullDescription }
|
| 260 |
+
itemData={ itemData }
|
| 261 |
+
variation={ variation }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
/>
|
| 263 |
|
| 264 |
+
<div className="wc-block-cart-item__quantity">
|
| 265 |
+
<QuantitySelector
|
| 266 |
+
disabled={ isPendingDelete }
|
| 267 |
+
quantity={ quantity }
|
| 268 |
+
maximum={ quantityLimit }
|
| 269 |
+
onChange={ ( newQuantity ) => {
|
| 270 |
+
setItemQuantity( newQuantity );
|
| 271 |
+
dispatchStoreEvent( 'cart-set-item-quantity', {
|
| 272 |
+
product: lineItem,
|
| 273 |
+
quantity: newQuantity,
|
| 274 |
+
} );
|
| 275 |
+
} }
|
| 276 |
+
itemName={ name }
|
| 277 |
+
/>
|
| 278 |
+
<button
|
| 279 |
+
className="wc-block-cart-item__remove-link"
|
| 280 |
+
onClick={ () => {
|
| 281 |
+
onRemove();
|
| 282 |
+
removeItem();
|
| 283 |
+
dispatchStoreEvent( 'cart-remove-item', {
|
| 284 |
+
product: lineItem,
|
| 285 |
+
quantity,
|
| 286 |
+
} );
|
| 287 |
+
speak(
|
| 288 |
+
sprintf(
|
| 289 |
+
/* translators: %s refers to the item name in the cart. */
|
| 290 |
+
__(
|
| 291 |
+
'%s has been removed from your cart.',
|
| 292 |
+
'woo-gutenberg-products-block'
|
| 293 |
+
),
|
| 294 |
+
name
|
| 295 |
+
)
|
| 296 |
+
);
|
| 297 |
+
} }
|
| 298 |
+
disabled={ isPendingDelete }
|
| 299 |
+
>
|
| 300 |
+
{ __(
|
| 301 |
+
'Remove item',
|
| 302 |
+
'woo-gutenberg-products-block'
|
| 303 |
) }
|
| 304 |
+
</button>
|
| 305 |
+
</div>
|
| 306 |
+
</td>
|
| 307 |
+
<td className="wc-block-cart-item__total">
|
| 308 |
+
<div className="wc-block-cart-item__total-price-and-sale-badge-wrapper">
|
| 309 |
+
<ProductPrice
|
| 310 |
+
currency={ totalsCurrency }
|
| 311 |
+
format={ productPriceFormat }
|
| 312 |
+
price={ subtotalPrice.getAmount() }
|
| 313 |
/>
|
| 314 |
+
|
| 315 |
+
{ quantity > 1 && (
|
| 316 |
+
<ProductSaleBadge
|
| 317 |
+
currency={ priceCurrency }
|
| 318 |
+
saleAmount={ getAmountFromRawPrice(
|
| 319 |
+
saleAmount,
|
| 320 |
+
priceCurrency
|
| 321 |
+
) }
|
| 322 |
+
format={ saleBadgePriceFormat }
|
| 323 |
+
/>
|
| 324 |
+
) }
|
| 325 |
+
</div>
|
| 326 |
+
</td>
|
| 327 |
+
</tr>
|
| 328 |
+
);
|
| 329 |
+
}
|
| 330 |
+
);
|
| 331 |
|
| 332 |
export default CartLineItemRow;
|
assets/js/blocks/cart-checkout/cart/full-cart/cart-line-items-table.tsx
CHANGED
|
@@ -3,6 +3,8 @@
|
|
| 3 |
*/
|
| 4 |
import { __ } from '@wordpress/i18n';
|
| 5 |
import { CartResponseItem } from '@woocommerce/type-defs/cart-response';
|
|
|
|
|
|
|
| 6 |
|
| 7 |
/**
|
| 8 |
* Internal dependencies
|
|
@@ -18,23 +20,54 @@ interface CartLineItemsTableProps {
|
|
| 18 |
isLoading: boolean;
|
| 19 |
}
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
const CartLineItemsTable = ( {
|
| 22 |
lineItems = [],
|
| 23 |
isLoading = false,
|
| 24 |
}: CartLineItemsTableProps ): JSX.Element => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
const products = isLoading
|
| 26 |
? placeholderRows
|
| 27 |
-
: lineItems.map( ( lineItem ) => {
|
|
|
|
|
|
|
| 28 |
return (
|
| 29 |
<CartLineItemRow
|
| 30 |
key={ lineItem.key }
|
| 31 |
lineItem={ lineItem }
|
|
|
|
|
|
|
|
|
|
| 32 |
/>
|
| 33 |
);
|
| 34 |
} );
|
| 35 |
|
| 36 |
return (
|
| 37 |
-
<table className="wc-block-cart-items">
|
| 38 |
<thead>
|
| 39 |
<tr className="wc-block-cart-items__header">
|
| 40 |
<th className="wc-block-cart-items__header-image">
|
| 3 |
*/
|
| 4 |
import { __ } from '@wordpress/i18n';
|
| 5 |
import { CartResponseItem } from '@woocommerce/type-defs/cart-response';
|
| 6 |
+
import { createRef, useEffect, useRef } from '@wordpress/element';
|
| 7 |
+
import type { RefObject } from 'react';
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Internal dependencies
|
| 20 |
isLoading: boolean;
|
| 21 |
}
|
| 22 |
|
| 23 |
+
const setRefs = ( lineItems: CartResponseItem[] ) => {
|
| 24 |
+
const refs = {} as Record< string, RefObject< HTMLTableRowElement > >;
|
| 25 |
+
lineItems.forEach( ( { key } ) => {
|
| 26 |
+
refs[ key ] = createRef();
|
| 27 |
+
} );
|
| 28 |
+
return refs;
|
| 29 |
+
};
|
| 30 |
+
|
| 31 |
const CartLineItemsTable = ( {
|
| 32 |
lineItems = [],
|
| 33 |
isLoading = false,
|
| 34 |
}: CartLineItemsTableProps ): JSX.Element => {
|
| 35 |
+
const tableRef = useRef< HTMLTableElement | null >( null );
|
| 36 |
+
const rowRefs = useRef( setRefs( lineItems ) );
|
| 37 |
+
useEffect( () => {
|
| 38 |
+
rowRefs.current = setRefs( lineItems );
|
| 39 |
+
}, [ lineItems ] );
|
| 40 |
+
|
| 41 |
+
const onRemoveRow = ( nextItemKey: string | null ) => () => {
|
| 42 |
+
if (
|
| 43 |
+
rowRefs?.current &&
|
| 44 |
+
nextItemKey &&
|
| 45 |
+
rowRefs.current[ nextItemKey ].current instanceof HTMLElement
|
| 46 |
+
) {
|
| 47 |
+
( rowRefs.current[ nextItemKey ].current as HTMLElement ).focus();
|
| 48 |
+
} else if ( tableRef.current instanceof HTMLElement ) {
|
| 49 |
+
tableRef.current.focus();
|
| 50 |
+
}
|
| 51 |
+
};
|
| 52 |
+
|
| 53 |
const products = isLoading
|
| 54 |
? placeholderRows
|
| 55 |
+
: lineItems.map( ( lineItem, i ) => {
|
| 56 |
+
const nextItemKey =
|
| 57 |
+
lineItems.length > i + 1 ? lineItems[ i + 1 ].key : null;
|
| 58 |
return (
|
| 59 |
<CartLineItemRow
|
| 60 |
key={ lineItem.key }
|
| 61 |
lineItem={ lineItem }
|
| 62 |
+
onRemove={ onRemoveRow( nextItemKey ) }
|
| 63 |
+
ref={ rowRefs.current[ lineItem.key ] }
|
| 64 |
+
tabIndex={ -1 }
|
| 65 |
/>
|
| 66 |
);
|
| 67 |
} );
|
| 68 |
|
| 69 |
return (
|
| 70 |
+
<table className="wc-block-cart-items" ref={ tableRef } tabIndex={ -1 }>
|
| 71 |
<thead>
|
| 72 |
<tr className="wc-block-cart-items__header">
|
| 73 |
<th className="wc-block-cart-items__header-image">
|
assets/js/blocks/cart-checkout/cart/full-cart/index.tsx
CHANGED
|
@@ -107,7 +107,7 @@ const Cart = ( { attributes }: CartProps ): JSX.Element => {
|
|
| 107 |
// Prepare props to pass to the ExperimentalOrderMeta slot fill.
|
| 108 |
// We need to pluck out receiveCart.
|
| 109 |
// eslint-disable-next-line no-unused-vars
|
| 110 |
-
const { extensions, ...cart } = useStoreCart();
|
| 111 |
const slotFillProps = {
|
| 112 |
extensions,
|
| 113 |
cart,
|
| 107 |
// Prepare props to pass to the ExperimentalOrderMeta slot fill.
|
| 108 |
// We need to pluck out receiveCart.
|
| 109 |
// eslint-disable-next-line no-unused-vars
|
| 110 |
+
const { extensions, receiveCart, ...cart } = useStoreCart();
|
| 111 |
const slotFillProps = {
|
| 112 |
extensions,
|
| 113 |
cart,
|
assets/js/blocks/cart-checkout/cart/test/__snapshots__/block.js.snap
CHANGED
|
@@ -33,6 +33,7 @@ exports[`Testing cart Contains a Taxes section if Core options are set to show i
|
|
| 33 |
>
|
| 34 |
<table
|
| 35 |
class="wc-block-cart-items"
|
|
|
|
| 36 |
>
|
| 37 |
<thead>
|
| 38 |
<tr
|
|
@@ -64,6 +65,7 @@ exports[`Testing cart Contains a Taxes section if Core options are set to show i
|
|
| 64 |
<tbody>
|
| 65 |
<tr
|
| 66 |
class="wc-block-cart-items__row"
|
|
|
|
| 67 |
>
|
| 68 |
<td
|
| 69 |
aria-hidden="true"
|
|
@@ -210,6 +212,7 @@ exports[`Testing cart Contains a Taxes section if Core options are set to show i
|
|
| 210 |
</tr>
|
| 211 |
<tr
|
| 212 |
class="wc-block-cart-items__row"
|
|
|
|
| 213 |
>
|
| 214 |
<td
|
| 215 |
aria-hidden="true"
|
|
@@ -715,6 +718,7 @@ exports[`Testing cart Shows individual tax lines if the store is set to do so 1`
|
|
| 715 |
>
|
| 716 |
<table
|
| 717 |
class="wc-block-cart-items"
|
|
|
|
| 718 |
>
|
| 719 |
<thead>
|
| 720 |
<tr
|
|
@@ -746,6 +750,7 @@ exports[`Testing cart Shows individual tax lines if the store is set to do so 1`
|
|
| 746 |
<tbody>
|
| 747 |
<tr
|
| 748 |
class="wc-block-cart-items__row"
|
|
|
|
| 749 |
>
|
| 750 |
<td
|
| 751 |
aria-hidden="true"
|
|
@@ -892,6 +897,7 @@ exports[`Testing cart Shows individual tax lines if the store is set to do so 1`
|
|
| 892 |
</tr>
|
| 893 |
<tr
|
| 894 |
class="wc-block-cart-items__row"
|
|
|
|
| 895 |
>
|
| 896 |
<td
|
| 897 |
aria-hidden="true"
|
|
@@ -1402,6 +1408,7 @@ exports[`Testing cart Shows rate percentages after tax lines if the block is set
|
|
| 1402 |
>
|
| 1403 |
<table
|
| 1404 |
class="wc-block-cart-items"
|
|
|
|
| 1405 |
>
|
| 1406 |
<thead>
|
| 1407 |
<tr
|
|
@@ -1433,6 +1440,7 @@ exports[`Testing cart Shows rate percentages after tax lines if the block is set
|
|
| 1433 |
<tbody>
|
| 1434 |
<tr
|
| 1435 |
class="wc-block-cart-items__row"
|
|
|
|
| 1436 |
>
|
| 1437 |
<td
|
| 1438 |
aria-hidden="true"
|
|
@@ -1579,6 +1587,7 @@ exports[`Testing cart Shows rate percentages after tax lines if the block is set
|
|
| 1579 |
</tr>
|
| 1580 |
<tr
|
| 1581 |
class="wc-block-cart-items__row"
|
|
|
|
| 1582 |
>
|
| 1583 |
<td
|
| 1584 |
aria-hidden="true"
|
| 33 |
>
|
| 34 |
<table
|
| 35 |
class="wc-block-cart-items"
|
| 36 |
+
tabindex="-1"
|
| 37 |
>
|
| 38 |
<thead>
|
| 39 |
<tr
|
| 65 |
<tbody>
|
| 66 |
<tr
|
| 67 |
class="wc-block-cart-items__row"
|
| 68 |
+
tabindex="-1"
|
| 69 |
>
|
| 70 |
<td
|
| 71 |
aria-hidden="true"
|
| 212 |
</tr>
|
| 213 |
<tr
|
| 214 |
class="wc-block-cart-items__row"
|
| 215 |
+
tabindex="-1"
|
| 216 |
>
|
| 217 |
<td
|
| 218 |
aria-hidden="true"
|
| 718 |
>
|
| 719 |
<table
|
| 720 |
class="wc-block-cart-items"
|
| 721 |
+
tabindex="-1"
|
| 722 |
>
|
| 723 |
<thead>
|
| 724 |
<tr
|
| 750 |
<tbody>
|
| 751 |
<tr
|
| 752 |
class="wc-block-cart-items__row"
|
| 753 |
+
tabindex="-1"
|
| 754 |
>
|
| 755 |
<td
|
| 756 |
aria-hidden="true"
|
| 897 |
</tr>
|
| 898 |
<tr
|
| 899 |
class="wc-block-cart-items__row"
|
| 900 |
+
tabindex="-1"
|
| 901 |
>
|
| 902 |
<td
|
| 903 |
aria-hidden="true"
|
| 1408 |
>
|
| 1409 |
<table
|
| 1410 |
class="wc-block-cart-items"
|
| 1411 |
+
tabindex="-1"
|
| 1412 |
>
|
| 1413 |
<thead>
|
| 1414 |
<tr
|
| 1440 |
<tbody>
|
| 1441 |
<tr
|
| 1442 |
class="wc-block-cart-items__row"
|
| 1443 |
+
tabindex="-1"
|
| 1444 |
>
|
| 1445 |
<td
|
| 1446 |
aria-hidden="true"
|
| 1587 |
</tr>
|
| 1588 |
<tr
|
| 1589 |
class="wc-block-cart-items__row"
|
| 1590 |
+
tabindex="-1"
|
| 1591 |
>
|
| 1592 |
<td
|
| 1593 |
aria-hidden="true"
|
assets/js/blocks/cart-checkout/checkout-i2/checkout-order-error/constants.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
| 1 |
-
export const PRODUCT_OUT_OF_STOCK = 'woocommerce_product_out_of_stock';
|
| 2 |
-
export const PRODUCT_NOT_PURCHASABLE =
|
| 3 |
-
'woocommerce_rest_cart_product_is_not_purchasable';
|
| 4 |
-
export const PRODUCT_NOT_ENOUGH_STOCK =
|
| 5 |
-
'woocommerce_rest_cart_product_no_stock';
|
| 6 |
-
export const PRODUCT_SOLD_INDIVIDUALLY =
|
| 7 |
-
'woocommerce_rest_cart_product_sold_individually';
|
| 8 |
-
export const GENERIC_CART_ITEM_ERROR = 'woocommerce_rest_cart_item_error';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout-i2/checkout-order-error/index.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { CART_URL } from '@woocommerce/block-settings';
|
| 6 |
-
import { Icon, removeCart } from '@woocommerce/icons';
|
| 7 |
-
import { getSetting } from '@woocommerce/settings';
|
| 8 |
-
import { decodeEntities } from '@wordpress/html-entities';
|
| 9 |
-
|
| 10 |
-
/**
|
| 11 |
-
* Internal dependencies
|
| 12 |
-
*/
|
| 13 |
-
import {
|
| 14 |
-
PRODUCT_OUT_OF_STOCK,
|
| 15 |
-
PRODUCT_NOT_PURCHASABLE,
|
| 16 |
-
PRODUCT_NOT_ENOUGH_STOCK,
|
| 17 |
-
PRODUCT_SOLD_INDIVIDUALLY,
|
| 18 |
-
GENERIC_CART_ITEM_ERROR,
|
| 19 |
-
} from './constants';
|
| 20 |
-
|
| 21 |
-
const cartItemErrorCodes = [
|
| 22 |
-
PRODUCT_OUT_OF_STOCK,
|
| 23 |
-
PRODUCT_NOT_PURCHASABLE,
|
| 24 |
-
PRODUCT_NOT_ENOUGH_STOCK,
|
| 25 |
-
PRODUCT_SOLD_INDIVIDUALLY,
|
| 26 |
-
GENERIC_CART_ITEM_ERROR,
|
| 27 |
-
];
|
| 28 |
-
|
| 29 |
-
/**
|
| 30 |
-
* When an order was not created for the checkout, for example, when an item
|
| 31 |
-
* was out of stock, this component will be shown instead of the checkout form.
|
| 32 |
-
*
|
| 33 |
-
* The error message is derived by the hydrated API request passed to the
|
| 34 |
-
* checkout block.
|
| 35 |
-
*/
|
| 36 |
-
const CheckoutOrderError = () => {
|
| 37 |
-
const preloadedApiRequests = getSetting( 'preloadedApiRequests', {} );
|
| 38 |
-
const checkoutData = {
|
| 39 |
-
code: '',
|
| 40 |
-
message: '',
|
| 41 |
-
...( preloadedApiRequests[ '/wc/store/checkout' ]?.body || {} ),
|
| 42 |
-
};
|
| 43 |
-
|
| 44 |
-
const errorData = {
|
| 45 |
-
code: checkoutData.code || 'unknown',
|
| 46 |
-
message:
|
| 47 |
-
decodeEntities( checkoutData.message ) ||
|
| 48 |
-
__(
|
| 49 |
-
'There was a problem checking out. Please try again. If the problem persists, please get in touch with us so we can assist.',
|
| 50 |
-
'woo-gutenberg-products-block'
|
| 51 |
-
),
|
| 52 |
-
};
|
| 53 |
-
|
| 54 |
-
return (
|
| 55 |
-
<div className="wc-block-checkout-error">
|
| 56 |
-
<Icon
|
| 57 |
-
className="wc-block-checkout-error__image"
|
| 58 |
-
alt=""
|
| 59 |
-
srcElement={ removeCart }
|
| 60 |
-
size={ 100 }
|
| 61 |
-
/>
|
| 62 |
-
<ErrorTitle errorData={ errorData } />
|
| 63 |
-
<ErrorMessage errorData={ errorData } />
|
| 64 |
-
<ErrorButton errorData={ errorData } />
|
| 65 |
-
</div>
|
| 66 |
-
);
|
| 67 |
-
};
|
| 68 |
-
|
| 69 |
-
/**
|
| 70 |
-
* Get the error message to display.
|
| 71 |
-
*
|
| 72 |
-
* @param {Object} props Incoming props for the component.
|
| 73 |
-
* @param {Object} props.errorData Object containing code and message.
|
| 74 |
-
*/
|
| 75 |
-
const ErrorTitle = ( { errorData } ) => {
|
| 76 |
-
let heading = __( 'Checkout error', 'woo-gutenberg-products-block' );
|
| 77 |
-
|
| 78 |
-
if ( cartItemErrorCodes.includes( errorData.code ) ) {
|
| 79 |
-
heading = __(
|
| 80 |
-
'There is a problem with your cart',
|
| 81 |
-
'woo-gutenberg-products-block'
|
| 82 |
-
);
|
| 83 |
-
}
|
| 84 |
-
|
| 85 |
-
return (
|
| 86 |
-
<strong className="wc-block-checkout-error_title">{ heading }</strong>
|
| 87 |
-
);
|
| 88 |
-
};
|
| 89 |
-
|
| 90 |
-
/**
|
| 91 |
-
* Get the error message to display.
|
| 92 |
-
*
|
| 93 |
-
* @param {Object} props Incoming props for the component.
|
| 94 |
-
* @param {Object} props.errorData Object containing code and message.
|
| 95 |
-
*/
|
| 96 |
-
const ErrorMessage = ( { errorData } ) => {
|
| 97 |
-
let message = errorData.message;
|
| 98 |
-
|
| 99 |
-
if ( cartItemErrorCodes.includes( errorData.code ) ) {
|
| 100 |
-
message =
|
| 101 |
-
message +
|
| 102 |
-
' ' +
|
| 103 |
-
__(
|
| 104 |
-
'Please edit your cart and try again.',
|
| 105 |
-
'woo-gutenberg-products-block'
|
| 106 |
-
);
|
| 107 |
-
}
|
| 108 |
-
|
| 109 |
-
return <p className="wc-block-checkout-error__description">{ message }</p>;
|
| 110 |
-
};
|
| 111 |
-
|
| 112 |
-
/**
|
| 113 |
-
* Get the CTA button to display.
|
| 114 |
-
*
|
| 115 |
-
* @param {Object} props Incoming props for the component.
|
| 116 |
-
* @param {Object} props.errorData Object containing code and message.
|
| 117 |
-
*/
|
| 118 |
-
const ErrorButton = ( { errorData } ) => {
|
| 119 |
-
let buttonText = __( 'Retry', 'woo-gutenberg-products-block' );
|
| 120 |
-
let buttonUrl = 'javascript:window.location.reload(true)';
|
| 121 |
-
|
| 122 |
-
if ( cartItemErrorCodes.includes( errorData.code ) ) {
|
| 123 |
-
buttonText = __( 'Edit your cart', 'woo-gutenberg-products-block' );
|
| 124 |
-
buttonUrl = CART_URL;
|
| 125 |
-
}
|
| 126 |
-
|
| 127 |
-
return (
|
| 128 |
-
<span className="wp-block-button">
|
| 129 |
-
<a href={ buttonUrl } className="wp-block-button__link">
|
| 130 |
-
{ buttonText }
|
| 131 |
-
</a>
|
| 132 |
-
</span>
|
| 133 |
-
);
|
| 134 |
-
};
|
| 135 |
-
|
| 136 |
-
export default CheckoutOrderError;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout-i2/empty-cart/index.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { SHOP_URL } from '@woocommerce/block-settings';
|
| 6 |
-
import { Icon, cart } from '@woocommerce/icons';
|
| 7 |
-
|
| 8 |
-
const EmptyCart = () => {
|
| 9 |
-
return (
|
| 10 |
-
<div className="wc-block-checkout-empty">
|
| 11 |
-
<Icon
|
| 12 |
-
className="wc-block-checkout-empty__image"
|
| 13 |
-
alt=""
|
| 14 |
-
srcElement={ cart }
|
| 15 |
-
size={ 100 }
|
| 16 |
-
/>
|
| 17 |
-
<strong className="wc-block-checkout-empty__title">
|
| 18 |
-
{ __( 'Your cart is empty!', 'woo-gutenberg-products-block' ) }
|
| 19 |
-
</strong>
|
| 20 |
-
<p className="wc-block-checkout-empty__description">
|
| 21 |
-
{ __(
|
| 22 |
-
"Checkout is not available whilst your cart is empty—please take a look through our store and come back when you're ready to place an order.",
|
| 23 |
-
'woo-gutenberg-products-block'
|
| 24 |
-
) }
|
| 25 |
-
</p>
|
| 26 |
-
{ SHOP_URL && (
|
| 27 |
-
<span className="wp-block-button">
|
| 28 |
-
<a href={ SHOP_URL } className="wp-block-button__link">
|
| 29 |
-
{ __( 'Browse store', 'woo-gutenberg-products-block' ) }
|
| 30 |
-
</a>
|
| 31 |
-
</span>
|
| 32 |
-
) }
|
| 33 |
-
</div>
|
| 34 |
-
);
|
| 35 |
-
};
|
| 36 |
-
|
| 37 |
-
export default EmptyCart;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-actions-block/index.tsx
DELETED
|
@@ -1,37 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { Icon, button } from '@wordpress/icons';
|
| 6 |
-
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
| 7 |
-
|
| 8 |
-
/**
|
| 9 |
-
* Internal dependencies
|
| 10 |
-
*/
|
| 11 |
-
import attributes from './attributes';
|
| 12 |
-
import { Edit, Save } from './edit';
|
| 13 |
-
|
| 14 |
-
registerFeaturePluginBlockType( 'woocommerce/checkout-actions-block', {
|
| 15 |
-
title: __( 'Actions', 'woo-gutenberg-products-block' ),
|
| 16 |
-
category: 'woocommerce',
|
| 17 |
-
description: __(
|
| 18 |
-
'Allow customers to place their order.',
|
| 19 |
-
'woo-gutenberg-products-block'
|
| 20 |
-
),
|
| 21 |
-
icon: {
|
| 22 |
-
src: <Icon icon={ button } />,
|
| 23 |
-
foreground: '#874FB9',
|
| 24 |
-
},
|
| 25 |
-
supports: {
|
| 26 |
-
align: false,
|
| 27 |
-
html: false,
|
| 28 |
-
multiple: false,
|
| 29 |
-
reusable: false,
|
| 30 |
-
inserter: false,
|
| 31 |
-
},
|
| 32 |
-
parent: [ 'woocommerce/checkout-fields-block' ],
|
| 33 |
-
attributes,
|
| 34 |
-
apiVersion: 2,
|
| 35 |
-
edit: Edit,
|
| 36 |
-
save: Save,
|
| 37 |
-
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-billing-address-block/index.tsx
DELETED
|
@@ -1,37 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { Icon, address } from '@woocommerce/icons';
|
| 6 |
-
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
| 7 |
-
|
| 8 |
-
/**
|
| 9 |
-
* Internal dependencies
|
| 10 |
-
*/
|
| 11 |
-
import { Edit, Save } from './edit';
|
| 12 |
-
import attributes from './attributes';
|
| 13 |
-
|
| 14 |
-
registerFeaturePluginBlockType( 'woocommerce/checkout-billing-address-block', {
|
| 15 |
-
title: __( 'Billing Address', 'woo-gutenberg-products-block' ),
|
| 16 |
-
category: 'woocommerce',
|
| 17 |
-
description: __(
|
| 18 |
-
"Collect your customer's billing address.",
|
| 19 |
-
'woo-gutenberg-products-block'
|
| 20 |
-
),
|
| 21 |
-
icon: {
|
| 22 |
-
src: <Icon srcElement={ address } />,
|
| 23 |
-
foreground: '#874FB9',
|
| 24 |
-
},
|
| 25 |
-
supports: {
|
| 26 |
-
align: false,
|
| 27 |
-
html: false,
|
| 28 |
-
multiple: false,
|
| 29 |
-
reusable: false,
|
| 30 |
-
inserter: false,
|
| 31 |
-
},
|
| 32 |
-
parent: [ 'woocommerce/checkout-fields-block' ],
|
| 33 |
-
attributes,
|
| 34 |
-
apiVersion: 2,
|
| 35 |
-
edit: Edit,
|
| 36 |
-
save: Save,
|
| 37 |
-
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-contact-information-block/index.tsx
DELETED
|
@@ -1,40 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { Icon, contact } from '@woocommerce/icons';
|
| 6 |
-
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
| 7 |
-
|
| 8 |
-
/**
|
| 9 |
-
* Internal dependencies
|
| 10 |
-
*/
|
| 11 |
-
import { Edit, Save } from './edit';
|
| 12 |
-
import attributes from './attributes';
|
| 13 |
-
|
| 14 |
-
registerFeaturePluginBlockType(
|
| 15 |
-
'woocommerce/checkout-contact-information-block',
|
| 16 |
-
{
|
| 17 |
-
title: __( 'Contact Information', 'woo-gutenberg-products-block' ),
|
| 18 |
-
category: 'woocommerce',
|
| 19 |
-
description: __(
|
| 20 |
-
"Collect your customer's contact information.",
|
| 21 |
-
'woo-gutenberg-products-block'
|
| 22 |
-
),
|
| 23 |
-
icon: {
|
| 24 |
-
src: <Icon srcElement={ contact } />,
|
| 25 |
-
foreground: '#874FB9',
|
| 26 |
-
},
|
| 27 |
-
supports: {
|
| 28 |
-
align: false,
|
| 29 |
-
html: false,
|
| 30 |
-
multiple: false,
|
| 31 |
-
reusable: false,
|
| 32 |
-
inserter: false,
|
| 33 |
-
},
|
| 34 |
-
parent: [ 'woocommerce/checkout-fields-block' ],
|
| 35 |
-
attributes,
|
| 36 |
-
apiVersion: 2,
|
| 37 |
-
edit: Edit,
|
| 38 |
-
save: Save,
|
| 39 |
-
}
|
| 40 |
-
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-express-payment-block/index.tsx
DELETED
|
@@ -1,44 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { Icon, card } from '@woocommerce/icons';
|
| 6 |
-
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
| 7 |
-
|
| 8 |
-
/**
|
| 9 |
-
* Internal dependencies
|
| 10 |
-
*/
|
| 11 |
-
import { Edit, Save } from './edit';
|
| 12 |
-
|
| 13 |
-
registerFeaturePluginBlockType( 'woocommerce/checkout-express-payment-block', {
|
| 14 |
-
title: __( 'Express Checkout', 'woo-gutenberg-products-block' ),
|
| 15 |
-
category: 'woocommerce',
|
| 16 |
-
description: __(
|
| 17 |
-
'Provide an express payment option for your customers.',
|
| 18 |
-
'woo-gutenberg-products-block'
|
| 19 |
-
),
|
| 20 |
-
icon: {
|
| 21 |
-
src: <Icon srcElement={ card } />,
|
| 22 |
-
foreground: '#874FB9',
|
| 23 |
-
},
|
| 24 |
-
supports: {
|
| 25 |
-
align: false,
|
| 26 |
-
html: false,
|
| 27 |
-
multiple: false,
|
| 28 |
-
reusable: false,
|
| 29 |
-
inserter: false,
|
| 30 |
-
},
|
| 31 |
-
parent: [ 'woocommerce/checkout-fields-block' ],
|
| 32 |
-
attributes: {
|
| 33 |
-
lock: {
|
| 34 |
-
type: 'object',
|
| 35 |
-
default: {
|
| 36 |
-
remove: true,
|
| 37 |
-
move: true,
|
| 38 |
-
},
|
| 39 |
-
},
|
| 40 |
-
},
|
| 41 |
-
apiVersion: 2,
|
| 42 |
-
edit: Edit,
|
| 43 |
-
save: Save,
|
| 44 |
-
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-fields-block/index.tsx
DELETED
|
@@ -1,35 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { Icon, column } from '@wordpress/icons';
|
| 6 |
-
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
| 7 |
-
|
| 8 |
-
/**
|
| 9 |
-
* Internal dependencies
|
| 10 |
-
*/
|
| 11 |
-
import { Edit, Save } from './edit';
|
| 12 |
-
|
| 13 |
-
registerFeaturePluginBlockType( 'woocommerce/checkout-fields-block', {
|
| 14 |
-
title: __( 'Checkout Fields Block', 'woo-gutenberg-products-block' ),
|
| 15 |
-
category: 'woocommerce',
|
| 16 |
-
description: __(
|
| 17 |
-
'Column containing checkout address fields.',
|
| 18 |
-
'woo-gutenberg-products-block'
|
| 19 |
-
),
|
| 20 |
-
icon: {
|
| 21 |
-
src: <Icon icon={ column } />,
|
| 22 |
-
foreground: '#874FB9',
|
| 23 |
-
},
|
| 24 |
-
supports: {
|
| 25 |
-
align: false,
|
| 26 |
-
html: false,
|
| 27 |
-
multiple: false,
|
| 28 |
-
reusable: false,
|
| 29 |
-
inserter: false,
|
| 30 |
-
},
|
| 31 |
-
parent: [ 'woocommerce/checkout-i2' ],
|
| 32 |
-
apiVersion: 2,
|
| 33 |
-
edit: Edit,
|
| 34 |
-
save: Save,
|
| 35 |
-
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-order-note-block/index.tsx
DELETED
|
@@ -1,43 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { Icon, notes } from '@woocommerce/icons';
|
| 6 |
-
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
| 7 |
-
|
| 8 |
-
/**
|
| 9 |
-
* Internal dependencies
|
| 10 |
-
*/
|
| 11 |
-
import { Edit, Save } from './edit';
|
| 12 |
-
|
| 13 |
-
registerFeaturePluginBlockType( 'woocommerce/checkout-order-note-block', {
|
| 14 |
-
title: __( 'Order Note', 'woo-gutenberg-products-block' ),
|
| 15 |
-
category: 'woocommerce',
|
| 16 |
-
description: __(
|
| 17 |
-
'Allow customers to add a note to their order.',
|
| 18 |
-
'woo-gutenberg-products-block'
|
| 19 |
-
),
|
| 20 |
-
icon: {
|
| 21 |
-
src: <Icon srcElement={ notes } />,
|
| 22 |
-
foreground: '#874FB9',
|
| 23 |
-
},
|
| 24 |
-
supports: {
|
| 25 |
-
align: false,
|
| 26 |
-
html: false,
|
| 27 |
-
multiple: false,
|
| 28 |
-
reusable: false,
|
| 29 |
-
},
|
| 30 |
-
parent: [ 'woocommerce/checkout-fields-block' ],
|
| 31 |
-
attributes: {
|
| 32 |
-
lock: {
|
| 33 |
-
type: 'object',
|
| 34 |
-
default: {
|
| 35 |
-
move: true,
|
| 36 |
-
remove: true,
|
| 37 |
-
},
|
| 38 |
-
},
|
| 39 |
-
},
|
| 40 |
-
apiVersion: 2,
|
| 41 |
-
edit: Edit,
|
| 42 |
-
save: Save,
|
| 43 |
-
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-order-summary-block/index.tsx
DELETED
|
@@ -1,37 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { Icon, totals } from '@woocommerce/icons';
|
| 6 |
-
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
| 7 |
-
|
| 8 |
-
/**
|
| 9 |
-
* Internal dependencies
|
| 10 |
-
*/
|
| 11 |
-
import { Edit, Save } from './edit';
|
| 12 |
-
import attributes from './attributes';
|
| 13 |
-
|
| 14 |
-
registerFeaturePluginBlockType( 'woocommerce/checkout-order-summary-block', {
|
| 15 |
-
title: __( 'Order Summary', 'woo-gutenberg-products-block' ),
|
| 16 |
-
category: 'woocommerce',
|
| 17 |
-
description: __(
|
| 18 |
-
'Show customers a summary of their order.',
|
| 19 |
-
'woo-gutenberg-products-block'
|
| 20 |
-
),
|
| 21 |
-
icon: {
|
| 22 |
-
src: <Icon srcElement={ totals } />,
|
| 23 |
-
foreground: '#874FB9',
|
| 24 |
-
},
|
| 25 |
-
supports: {
|
| 26 |
-
align: false,
|
| 27 |
-
html: false,
|
| 28 |
-
multiple: false,
|
| 29 |
-
reusable: false,
|
| 30 |
-
inserter: false,
|
| 31 |
-
},
|
| 32 |
-
parent: [ 'woocommerce/checkout-totals-block' ],
|
| 33 |
-
attributes,
|
| 34 |
-
apiVersion: 2,
|
| 35 |
-
edit: Edit,
|
| 36 |
-
save: Save,
|
| 37 |
-
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-payment-block/index.tsx
DELETED
|
@@ -1,37 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { Icon, card } from '@woocommerce/icons';
|
| 6 |
-
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
| 7 |
-
|
| 8 |
-
/**
|
| 9 |
-
* Internal dependencies
|
| 10 |
-
*/
|
| 11 |
-
import { Edit, Save } from './edit';
|
| 12 |
-
import attributes from './attributes';
|
| 13 |
-
|
| 14 |
-
registerFeaturePluginBlockType( 'woocommerce/checkout-payment-block', {
|
| 15 |
-
title: __( 'Payment Options', 'woo-gutenberg-products-block' ),
|
| 16 |
-
category: 'woocommerce',
|
| 17 |
-
description: __(
|
| 18 |
-
'Payment options for your store.',
|
| 19 |
-
'woo-gutenberg-products-block'
|
| 20 |
-
),
|
| 21 |
-
icon: {
|
| 22 |
-
src: <Icon srcElement={ card } />,
|
| 23 |
-
foreground: '#874FB9',
|
| 24 |
-
},
|
| 25 |
-
supports: {
|
| 26 |
-
align: false,
|
| 27 |
-
html: false,
|
| 28 |
-
multiple: false,
|
| 29 |
-
reusable: false,
|
| 30 |
-
inserter: false,
|
| 31 |
-
},
|
| 32 |
-
parent: [ 'woocommerce/checkout-fields-block' ],
|
| 33 |
-
attributes,
|
| 34 |
-
apiVersion: 2,
|
| 35 |
-
edit: Edit,
|
| 36 |
-
save: Save,
|
| 37 |
-
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-sample-block/block.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"name": "woocommerce/checkout-sample-block",
|
| 3 |
-
"version": "1.0.0",
|
| 4 |
-
"title": "Checkout Sample Block",
|
| 5 |
-
"category": "woocommerce",
|
| 6 |
-
"description": "An example block showing how to integrate with Checkout i2.",
|
| 7 |
-
"supports": {
|
| 8 |
-
"html": false,
|
| 9 |
-
"align": true,
|
| 10 |
-
"multiple": true,
|
| 11 |
-
"reusable": false
|
| 12 |
-
},
|
| 13 |
-
"parent": [
|
| 14 |
-
"woocommerce/checkout-shipping-address-block",
|
| 15 |
-
"woocommerce/checkout-billing-address-block",
|
| 16 |
-
"woocommerce/checkout-fields-block",
|
| 17 |
-
"woocommerce/checkout-totals-block"
|
| 18 |
-
],
|
| 19 |
-
"textdomain": "woo-gutenberg-products-block"
|
| 20 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-sample-block/block.tsx
DELETED
|
@@ -1,15 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
const Block = (): JSX.Element => {
|
| 5 |
-
return (
|
| 6 |
-
<div className="wc-block-checkout__sample">
|
| 7 |
-
<p>
|
| 8 |
-
This sample block is a demonstration of the Checkout integration
|
| 9 |
-
interfaces.
|
| 10 |
-
</p>
|
| 11 |
-
</div>
|
| 12 |
-
);
|
| 13 |
-
};
|
| 14 |
-
|
| 15 |
-
export default Block;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-sample-block/edit.tsx
DELETED
|
@@ -1,35 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { useBlockProps, InspectorControls } from '@wordpress/block-editor';
|
| 6 |
-
import { PanelBody, Disabled } from '@wordpress/components';
|
| 7 |
-
|
| 8 |
-
/**
|
| 9 |
-
* Internal dependencies
|
| 10 |
-
*/
|
| 11 |
-
import Block from './block';
|
| 12 |
-
|
| 13 |
-
export const Edit = (): JSX.Element => {
|
| 14 |
-
return (
|
| 15 |
-
<>
|
| 16 |
-
<InspectorControls>
|
| 17 |
-
<PanelBody
|
| 18 |
-
title={ __(
|
| 19 |
-
'Block options',
|
| 20 |
-
'woo-gutenberg-products-block'
|
| 21 |
-
) }
|
| 22 |
-
>
|
| 23 |
-
Options for the block go here.
|
| 24 |
-
</PanelBody>
|
| 25 |
-
</InspectorControls>
|
| 26 |
-
<Disabled>
|
| 27 |
-
<Block />
|
| 28 |
-
</Disabled>
|
| 29 |
-
</>
|
| 30 |
-
);
|
| 31 |
-
};
|
| 32 |
-
|
| 33 |
-
export const Save = (): JSX.Element => {
|
| 34 |
-
return <div { ...useBlockProps.save() } />;
|
| 35 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-sample-block/frontend.tsx
DELETED
|
@@ -1,10 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* Internal dependencies
|
| 3 |
-
*/
|
| 4 |
-
import Block from './block';
|
| 5 |
-
|
| 6 |
-
const FrontendBlock = (): JSX.Element => {
|
| 7 |
-
return <Block />;
|
| 8 |
-
};
|
| 9 |
-
|
| 10 |
-
export default FrontendBlock;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-address-block/index.tsx
DELETED
|
@@ -1,37 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { Icon, address } from '@woocommerce/icons';
|
| 6 |
-
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
| 7 |
-
|
| 8 |
-
/**
|
| 9 |
-
* Internal dependencies
|
| 10 |
-
*/
|
| 11 |
-
import { Edit, Save } from './edit';
|
| 12 |
-
import attributes from './attributes';
|
| 13 |
-
|
| 14 |
-
registerFeaturePluginBlockType( 'woocommerce/checkout-shipping-address-block', {
|
| 15 |
-
title: __( 'Shipping Address', 'woo-gutenberg-products-block' ),
|
| 16 |
-
category: 'woocommerce',
|
| 17 |
-
description: __(
|
| 18 |
-
"Collect your customer's shipping address.",
|
| 19 |
-
'woo-gutenberg-products-block'
|
| 20 |
-
),
|
| 21 |
-
icon: {
|
| 22 |
-
src: <Icon srcElement={ address } />,
|
| 23 |
-
foreground: '#874FB9',
|
| 24 |
-
},
|
| 25 |
-
supports: {
|
| 26 |
-
align: false,
|
| 27 |
-
html: false,
|
| 28 |
-
multiple: false,
|
| 29 |
-
reusable: false,
|
| 30 |
-
inserter: false,
|
| 31 |
-
},
|
| 32 |
-
parent: [ 'woocommerce/checkout-fields-block' ],
|
| 33 |
-
attributes,
|
| 34 |
-
apiVersion: 2,
|
| 35 |
-
edit: Edit,
|
| 36 |
-
save: Save,
|
| 37 |
-
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-methods-block/index.tsx
DELETED
|
@@ -1,37 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { Icon, truck } from '@woocommerce/icons';
|
| 6 |
-
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
| 7 |
-
|
| 8 |
-
/**
|
| 9 |
-
* Internal dependencies
|
| 10 |
-
*/
|
| 11 |
-
import { Edit, Save } from './edit';
|
| 12 |
-
import attributes from './attributes';
|
| 13 |
-
|
| 14 |
-
registerFeaturePluginBlockType( 'woocommerce/checkout-shipping-methods-block', {
|
| 15 |
-
title: __( 'Shipping Options', 'woo-gutenberg-products-block' ),
|
| 16 |
-
category: 'woocommerce',
|
| 17 |
-
description: __(
|
| 18 |
-
'Shipping options for your store.',
|
| 19 |
-
'woo-gutenberg-products-block'
|
| 20 |
-
),
|
| 21 |
-
icon: {
|
| 22 |
-
src: <Icon srcElement={ truck } />,
|
| 23 |
-
foreground: '#874FB9',
|
| 24 |
-
},
|
| 25 |
-
supports: {
|
| 26 |
-
align: false,
|
| 27 |
-
html: false,
|
| 28 |
-
multiple: false,
|
| 29 |
-
reusable: false,
|
| 30 |
-
inserter: false,
|
| 31 |
-
},
|
| 32 |
-
parent: [ 'woocommerce/checkout-fields-block' ],
|
| 33 |
-
attributes,
|
| 34 |
-
apiVersion: 2,
|
| 35 |
-
edit: Edit,
|
| 36 |
-
save: Save,
|
| 37 |
-
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-terms-block/edit.tsx
DELETED
|
@@ -1,109 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import {
|
| 6 |
-
useBlockProps,
|
| 7 |
-
RichText,
|
| 8 |
-
InspectorControls,
|
| 9 |
-
} from '@wordpress/block-editor';
|
| 10 |
-
import CheckboxControl from '@woocommerce/base-components/checkbox-control';
|
| 11 |
-
import { PanelBody, ToggleControl, Notice } from '@wordpress/components';
|
| 12 |
-
|
| 13 |
-
/**
|
| 14 |
-
* Internal dependencies
|
| 15 |
-
*/
|
| 16 |
-
import './editor.scss';
|
| 17 |
-
import { termsConsentDefaultText, termsCheckboxDefaultText } from './constants';
|
| 18 |
-
|
| 19 |
-
export const Edit = ( {
|
| 20 |
-
attributes: { checkbox, text },
|
| 21 |
-
setAttributes,
|
| 22 |
-
}: {
|
| 23 |
-
attributes: { text: string; checkbox: boolean };
|
| 24 |
-
setAttributes: ( attributes: Record< string, unknown > ) => void;
|
| 25 |
-
} ): JSX.Element => {
|
| 26 |
-
const currentText = text || termsCheckboxDefaultText;
|
| 27 |
-
|
| 28 |
-
return (
|
| 29 |
-
<>
|
| 30 |
-
<InspectorControls>
|
| 31 |
-
<PanelBody
|
| 32 |
-
title={ __(
|
| 33 |
-
'Display options',
|
| 34 |
-
'woo-gutenberg-products-block'
|
| 35 |
-
) }
|
| 36 |
-
>
|
| 37 |
-
<ToggleControl
|
| 38 |
-
label={ __(
|
| 39 |
-
'Require checkbox',
|
| 40 |
-
'woo-gutenberg-products-block'
|
| 41 |
-
) }
|
| 42 |
-
checked={ checkbox }
|
| 43 |
-
onChange={ () =>
|
| 44 |
-
setAttributes( {
|
| 45 |
-
checkbox: ! checkbox,
|
| 46 |
-
} )
|
| 47 |
-
}
|
| 48 |
-
/>
|
| 49 |
-
</PanelBody>
|
| 50 |
-
</InspectorControls>
|
| 51 |
-
<div className="wc-block-checkout__terms">
|
| 52 |
-
{ checkbox ? (
|
| 53 |
-
<>
|
| 54 |
-
<CheckboxControl
|
| 55 |
-
id="terms-condition"
|
| 56 |
-
checked={ false }
|
| 57 |
-
/>
|
| 58 |
-
<RichText
|
| 59 |
-
value={ currentText }
|
| 60 |
-
onChange={ ( value ) =>
|
| 61 |
-
setAttributes( { text: value } )
|
| 62 |
-
}
|
| 63 |
-
/>
|
| 64 |
-
</>
|
| 65 |
-
) : (
|
| 66 |
-
<RichText
|
| 67 |
-
tagName="span"
|
| 68 |
-
value={ text || termsConsentDefaultText }
|
| 69 |
-
onChange={ ( value ) =>
|
| 70 |
-
setAttributes( { text: value } )
|
| 71 |
-
}
|
| 72 |
-
/>
|
| 73 |
-
) }
|
| 74 |
-
</div>
|
| 75 |
-
{ ! currentText.includes( '<a ' ) && (
|
| 76 |
-
<Notice
|
| 77 |
-
className="wc-block-checkout__terms_notice"
|
| 78 |
-
status="warning"
|
| 79 |
-
isDismissible={ false }
|
| 80 |
-
actions={
|
| 81 |
-
termsConsentDefaultText !== text
|
| 82 |
-
? [
|
| 83 |
-
{
|
| 84 |
-
label: __(
|
| 85 |
-
'Restore default text',
|
| 86 |
-
'woo-gutenberg-products-block'
|
| 87 |
-
),
|
| 88 |
-
onClick: () =>
|
| 89 |
-
setAttributes( { text: '' } ),
|
| 90 |
-
},
|
| 91 |
-
]
|
| 92 |
-
: []
|
| 93 |
-
}
|
| 94 |
-
>
|
| 95 |
-
<p>
|
| 96 |
-
{ __(
|
| 97 |
-
'Ensure you add links to your policy pages in this section.',
|
| 98 |
-
'woo-gutenberg-products-block'
|
| 99 |
-
) }
|
| 100 |
-
</p>
|
| 101 |
-
</Notice>
|
| 102 |
-
) }
|
| 103 |
-
</>
|
| 104 |
-
);
|
| 105 |
-
};
|
| 106 |
-
|
| 107 |
-
export const Save = (): JSX.Element => {
|
| 108 |
-
return <div { ...useBlockProps.save() } />;
|
| 109 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-terms-block/index.tsx
DELETED
|
@@ -1,42 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { Icon, asterisk } from '@woocommerce/icons';
|
| 6 |
-
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
| 7 |
-
/**
|
| 8 |
-
* Internal dependencies
|
| 9 |
-
*/
|
| 10 |
-
import { Edit, Save } from './edit';
|
| 11 |
-
|
| 12 |
-
registerFeaturePluginBlockType( 'woocommerce/checkout-terms-block', {
|
| 13 |
-
title: __( 'Terms and Conditions', 'woo-gutenberg-products-block' ),
|
| 14 |
-
category: 'woocommerce',
|
| 15 |
-
description: __(
|
| 16 |
-
'Ensure customers agree to your terms and conditions and privacy policy.',
|
| 17 |
-
'woo-gutenberg-products-block'
|
| 18 |
-
),
|
| 19 |
-
icon: {
|
| 20 |
-
src: <Icon srcElement={ asterisk } />,
|
| 21 |
-
foreground: '#874FB9',
|
| 22 |
-
},
|
| 23 |
-
supports: {
|
| 24 |
-
align: false,
|
| 25 |
-
html: false,
|
| 26 |
-
multiple: false,
|
| 27 |
-
reusable: false,
|
| 28 |
-
},
|
| 29 |
-
parent: [ 'woocommerce/checkout-fields-block' ],
|
| 30 |
-
attributes: {
|
| 31 |
-
checkbox: {
|
| 32 |
-
type: 'boolean',
|
| 33 |
-
default: false,
|
| 34 |
-
},
|
| 35 |
-
text: {
|
| 36 |
-
type: 'string',
|
| 37 |
-
required: false,
|
| 38 |
-
},
|
| 39 |
-
},
|
| 40 |
-
edit: Edit,
|
| 41 |
-
save: Save,
|
| 42 |
-
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-totals-block/index.tsx
DELETED
|
@@ -1,36 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { Icon, column } from '@wordpress/icons';
|
| 6 |
-
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
| 7 |
-
|
| 8 |
-
/**
|
| 9 |
-
* Internal dependencies
|
| 10 |
-
*/
|
| 11 |
-
import { Edit, Save } from './edit';
|
| 12 |
-
|
| 13 |
-
registerFeaturePluginBlockType( 'woocommerce/checkout-totals-block', {
|
| 14 |
-
title: __( 'Checkout Totals Block', 'woo-gutenberg-products-block' ),
|
| 15 |
-
category: 'woocommerce',
|
| 16 |
-
description: __(
|
| 17 |
-
'Column containing the checkout totals.',
|
| 18 |
-
'woo-gutenberg-products-block'
|
| 19 |
-
),
|
| 20 |
-
icon: {
|
| 21 |
-
src: <Icon icon={ column } />,
|
| 22 |
-
foreground: '#874FB9',
|
| 23 |
-
},
|
| 24 |
-
supports: {
|
| 25 |
-
align: false,
|
| 26 |
-
html: false,
|
| 27 |
-
multiple: false,
|
| 28 |
-
reusable: false,
|
| 29 |
-
inserter: false,
|
| 30 |
-
},
|
| 31 |
-
parent: [ 'woocommerce/checkout-i2' ],
|
| 32 |
-
attributes: {},
|
| 33 |
-
apiVersion: 2,
|
| 34 |
-
edit: Edit,
|
| 35 |
-
save: Save,
|
| 36 |
-
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout-i2/styles/style.scss
DELETED
|
@@ -1,98 +0,0 @@
|
|
| 1 |
-
// Loading skeleton.
|
| 2 |
-
|
| 3 |
-
.is-loading.wp-block-woocommerce-checkout-i2 {
|
| 4 |
-
.wp-block-woocommerce-checkout-totals-block,
|
| 5 |
-
.wp-block-woocommerce-checkout-fields-block {
|
| 6 |
-
> div {
|
| 7 |
-
@include placeholder();
|
| 8 |
-
margin: 0 0 1.5em 0;
|
| 9 |
-
display: none;
|
| 10 |
-
}
|
| 11 |
-
|
| 12 |
-
.wp-block-woocommerce-checkout-contact-information-block,
|
| 13 |
-
.wp-block-woocommerce-checkout-payment-block {
|
| 14 |
-
min-height: 10em;
|
| 15 |
-
display: block;
|
| 16 |
-
}
|
| 17 |
-
.wp-block-woocommerce-checkout-shipping-address-block {
|
| 18 |
-
min-height: 24em;
|
| 19 |
-
display: block;
|
| 20 |
-
}
|
| 21 |
-
.wp-block-woocommerce-checkout-actions-block {
|
| 22 |
-
width: 50%;
|
| 23 |
-
min-height: 4em;
|
| 24 |
-
margin-left: 50%;
|
| 25 |
-
display: block;
|
| 26 |
-
}
|
| 27 |
-
.wp-block-woocommerce-checkout-order-summary-block {
|
| 28 |
-
min-height: 47em;
|
| 29 |
-
display: block;
|
| 30 |
-
}
|
| 31 |
-
}
|
| 32 |
-
|
| 33 |
-
// @todo these styles replace the need for SidebarLayout styles. We define styles here so placeholder elements (loading state) for the checkout has the same sidebar type layout before JS loads.
|
| 34 |
-
&.wp-block-woocommerce-checkout-i2 {
|
| 35 |
-
display: flex;
|
| 36 |
-
flex-wrap: wrap;
|
| 37 |
-
margin: 0 auto $gap;
|
| 38 |
-
position: relative;
|
| 39 |
-
|
| 40 |
-
.wp-block-woocommerce-checkout-fields-block {
|
| 41 |
-
box-sizing: border-box;
|
| 42 |
-
margin: 0;
|
| 43 |
-
padding-right: percentage(math.div($gap-largest, 1060px)); // ~1060px is the default width of the content area in Storefront.
|
| 44 |
-
width: 65%;
|
| 45 |
-
}
|
| 46 |
-
.wp-block-woocommerce-checkout-totals-block {
|
| 47 |
-
box-sizing: border-box;
|
| 48 |
-
margin: 0;
|
| 49 |
-
padding-left: percentage(math.div($gap-large, 1060px));
|
| 50 |
-
width: 35%;
|
| 51 |
-
|
| 52 |
-
.wc-block-components-panel > h2 {
|
| 53 |
-
@include font-size(regular);
|
| 54 |
-
@include reset-box();
|
| 55 |
-
@include reset-typography();
|
| 56 |
-
.wc-block-components-panel__button {
|
| 57 |
-
font-weight: 400;
|
| 58 |
-
}
|
| 59 |
-
}
|
| 60 |
-
}
|
| 61 |
-
}
|
| 62 |
-
|
| 63 |
-
.is-medium,
|
| 64 |
-
.is-small,
|
| 65 |
-
.is-mobile {
|
| 66 |
-
&.wp-block-woocommerce-checkout-i2 {
|
| 67 |
-
flex-direction: column;
|
| 68 |
-
margin: 0 auto $gap;
|
| 69 |
-
|
| 70 |
-
.wp-block-woocommerce-checkout-fields-block {
|
| 71 |
-
padding: 0;
|
| 72 |
-
width: 100%;
|
| 73 |
-
}
|
| 74 |
-
.wp-block-woocommerce-checkout-totals-block {
|
| 75 |
-
padding: 0;
|
| 76 |
-
width: 100%;
|
| 77 |
-
}
|
| 78 |
-
}
|
| 79 |
-
}
|
| 80 |
-
|
| 81 |
-
.is-large {
|
| 82 |
-
.wp-block-woocommerce-checkout-totals-block {
|
| 83 |
-
.wc-block-components-totals-item,
|
| 84 |
-
.wc-block-components-panel {
|
| 85 |
-
padding-left: $gap;
|
| 86 |
-
padding-right: $gap;
|
| 87 |
-
}
|
| 88 |
-
}
|
| 89 |
-
}
|
| 90 |
-
|
| 91 |
-
// For Twenty Twenty we need to increase specificity a bit more.
|
| 92 |
-
.theme-twentytwenty {
|
| 93 |
-
.wp-block-woocommerce-checkout-totals-block .wc-block-components-panel > h2 {
|
| 94 |
-
@include font-size(large);
|
| 95 |
-
@include reset-box();
|
| 96 |
-
}
|
| 97 |
-
}
|
| 98 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout/attributes.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { getSetting } from '@woocommerce/settings';
|
| 5 |
-
|
| 6 |
-
const blockAttributes = {
|
| 7 |
-
isPreview: {
|
| 8 |
-
type: 'boolean',
|
| 9 |
-
default: false,
|
| 10 |
-
save: false,
|
| 11 |
-
},
|
| 12 |
-
showCompanyField: {
|
| 13 |
-
type: 'boolean',
|
| 14 |
-
default: false,
|
| 15 |
-
},
|
| 16 |
-
requireCompanyField: {
|
| 17 |
-
type: 'boolean',
|
| 18 |
-
default: false,
|
| 19 |
-
},
|
| 20 |
-
allowCreateAccount: {
|
| 21 |
-
type: 'boolean',
|
| 22 |
-
default: false,
|
| 23 |
-
},
|
| 24 |
-
showApartmentField: {
|
| 25 |
-
type: 'boolean',
|
| 26 |
-
default: true,
|
| 27 |
-
},
|
| 28 |
-
showPhoneField: {
|
| 29 |
-
type: 'boolean',
|
| 30 |
-
default: true,
|
| 31 |
-
},
|
| 32 |
-
requirePhoneField: {
|
| 33 |
-
type: 'boolean',
|
| 34 |
-
default: false,
|
| 35 |
-
},
|
| 36 |
-
showOrderNotes: {
|
| 37 |
-
type: 'boolean',
|
| 38 |
-
default: true,
|
| 39 |
-
},
|
| 40 |
-
showPolicyLinks: {
|
| 41 |
-
type: 'boolean',
|
| 42 |
-
default: true,
|
| 43 |
-
},
|
| 44 |
-
showReturnToCart: {
|
| 45 |
-
type: 'boolean',
|
| 46 |
-
default: true,
|
| 47 |
-
},
|
| 48 |
-
cartPageId: {
|
| 49 |
-
type: 'number',
|
| 50 |
-
default: 0,
|
| 51 |
-
},
|
| 52 |
-
hasDarkControls: {
|
| 53 |
-
type: 'boolean',
|
| 54 |
-
default: getSetting( 'hasDarkEditorStyleSupport', false ),
|
| 55 |
-
},
|
| 56 |
-
showRateAfterTaxName: {
|
| 57 |
-
type: 'boolean',
|
| 58 |
-
default: getSetting( 'displayCartPricesIncludingTax', false ),
|
| 59 |
-
},
|
| 60 |
-
};
|
| 61 |
-
|
| 62 |
-
export default blockAttributes;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/attributes.ts
RENAMED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
*/
|
| 4 |
import { getSetting } from '@woocommerce/settings';
|
| 5 |
|
| 6 |
-
export const blockName = 'woocommerce/checkout
|
| 7 |
export const blockAttributes = {
|
| 8 |
isPreview: {
|
| 9 |
type: 'boolean',
|
| 3 |
*/
|
| 4 |
import { getSetting } from '@woocommerce/settings';
|
| 5 |
|
| 6 |
+
export const blockName = 'woocommerce/checkout';
|
| 7 |
export const blockAttributes = {
|
| 8 |
isPreview: {
|
| 9 |
type: 'boolean',
|
assets/js/blocks/cart-checkout/checkout/block.js
DELETED
|
@@ -1,151 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import classnames from 'classnames';
|
| 5 |
-
import { useEffect } from '@wordpress/element';
|
| 6 |
-
import { __ } from '@wordpress/i18n';
|
| 7 |
-
import {
|
| 8 |
-
PlaceOrderButton,
|
| 9 |
-
Policies,
|
| 10 |
-
ReturnToCartButton,
|
| 11 |
-
} from '@woocommerce/base-components/cart-checkout';
|
| 12 |
-
import {
|
| 13 |
-
useCheckoutContext,
|
| 14 |
-
useEditorContext,
|
| 15 |
-
useValidationContext,
|
| 16 |
-
} from '@woocommerce/base-context';
|
| 17 |
-
import { useStoreCart, useStoreNotices } from '@woocommerce/base-context/hooks';
|
| 18 |
-
import {
|
| 19 |
-
Sidebar,
|
| 20 |
-
SidebarLayout,
|
| 21 |
-
Main,
|
| 22 |
-
} from '@woocommerce/base-components/sidebar-layout';
|
| 23 |
-
import withScrollToTop from '@woocommerce/base-hocs/with-scroll-to-top';
|
| 24 |
-
import { isWcVersion, getSetting } from '@woocommerce/settings';
|
| 25 |
-
|
| 26 |
-
/**
|
| 27 |
-
* Internal dependencies
|
| 28 |
-
*/
|
| 29 |
-
import CheckoutForm from './form';
|
| 30 |
-
import CheckoutSidebar from './sidebar';
|
| 31 |
-
import CheckoutOrderError from './checkout-order-error';
|
| 32 |
-
import { CheckoutExpressPayment } from '../payment-methods';
|
| 33 |
-
import { LOGIN_TO_CHECKOUT_URL } from './utils';
|
| 34 |
-
import './style.scss';
|
| 35 |
-
|
| 36 |
-
/**
|
| 37 |
-
* Main Checkout Component.
|
| 38 |
-
*
|
| 39 |
-
* @param {Object} props Component props.
|
| 40 |
-
* @param {Object} props.attributes Incoming block attributes.
|
| 41 |
-
* @param {function(any):any} props.scrollToTop Function for scrolling to top.
|
| 42 |
-
*/
|
| 43 |
-
const Checkout = ( { attributes, scrollToTop } ) => {
|
| 44 |
-
const { isEditor } = useEditorContext();
|
| 45 |
-
const {
|
| 46 |
-
cartItems,
|
| 47 |
-
cartTotals,
|
| 48 |
-
cartCoupons,
|
| 49 |
-
cartFees,
|
| 50 |
-
cartNeedsPayment,
|
| 51 |
-
} = useStoreCart();
|
| 52 |
-
const {
|
| 53 |
-
hasOrder,
|
| 54 |
-
hasError: checkoutHasError,
|
| 55 |
-
isIdle: checkoutIsIdle,
|
| 56 |
-
customerId,
|
| 57 |
-
} = useCheckoutContext();
|
| 58 |
-
const {
|
| 59 |
-
hasValidationErrors,
|
| 60 |
-
showAllValidationErrors,
|
| 61 |
-
} = useValidationContext();
|
| 62 |
-
const { hasNoticesOfType } = useStoreNotices();
|
| 63 |
-
|
| 64 |
-
const hasErrorsToDisplay =
|
| 65 |
-
checkoutIsIdle &&
|
| 66 |
-
checkoutHasError &&
|
| 67 |
-
( hasValidationErrors || hasNoticesOfType( 'default' ) );
|
| 68 |
-
|
| 69 |
-
// Checkout signup is feature gated to WooCommerce 4.7 and newer;
|
| 70 |
-
// uses updated my-account/lost-password screen from 4.7+ for
|
| 71 |
-
// setting initial password.
|
| 72 |
-
const allowCreateAccount =
|
| 73 |
-
attributes.allowCreateAccount && isWcVersion( '4.7.0', '>=' );
|
| 74 |
-
|
| 75 |
-
useEffect( () => {
|
| 76 |
-
if ( hasErrorsToDisplay ) {
|
| 77 |
-
showAllValidationErrors();
|
| 78 |
-
scrollToTop( { focusableSelector: 'input:invalid' } );
|
| 79 |
-
}
|
| 80 |
-
}, [ hasErrorsToDisplay, scrollToTop, showAllValidationErrors ] );
|
| 81 |
-
|
| 82 |
-
if ( ! isEditor && ! hasOrder ) {
|
| 83 |
-
return <CheckoutOrderError />;
|
| 84 |
-
}
|
| 85 |
-
|
| 86 |
-
if (
|
| 87 |
-
! isEditor &&
|
| 88 |
-
! customerId &&
|
| 89 |
-
! getSetting( 'checkoutAllowsGuest', false ) &&
|
| 90 |
-
! ( allowCreateAccount && getSetting( 'checkoutAllowsSignup', false ) )
|
| 91 |
-
) {
|
| 92 |
-
return (
|
| 93 |
-
<>
|
| 94 |
-
{ __(
|
| 95 |
-
'You must be logged in to checkout. ',
|
| 96 |
-
'woo-gutenberg-products-block'
|
| 97 |
-
) }
|
| 98 |
-
<a href={ LOGIN_TO_CHECKOUT_URL }>
|
| 99 |
-
{ __(
|
| 100 |
-
'Click here to log in.',
|
| 101 |
-
'woo-gutenberg-products-block'
|
| 102 |
-
) }
|
| 103 |
-
</a>
|
| 104 |
-
</>
|
| 105 |
-
);
|
| 106 |
-
}
|
| 107 |
-
const checkoutClassName = classnames( 'wc-block-checkout', {
|
| 108 |
-
'has-dark-controls': attributes.hasDarkControls,
|
| 109 |
-
} );
|
| 110 |
-
return (
|
| 111 |
-
<>
|
| 112 |
-
<SidebarLayout className={ checkoutClassName }>
|
| 113 |
-
<Main className="wc-block-checkout__main">
|
| 114 |
-
{ cartNeedsPayment && <CheckoutExpressPayment /> }
|
| 115 |
-
<CheckoutForm
|
| 116 |
-
showApartmentField={ attributes.showApartmentField }
|
| 117 |
-
showCompanyField={ attributes.showCompanyField }
|
| 118 |
-
showOrderNotes={ attributes.showOrderNotes }
|
| 119 |
-
showPhoneField={ attributes.showPhoneField }
|
| 120 |
-
requireCompanyField={ attributes.requireCompanyField }
|
| 121 |
-
requirePhoneField={ attributes.requirePhoneField }
|
| 122 |
-
allowCreateAccount={ allowCreateAccount }
|
| 123 |
-
/>
|
| 124 |
-
<div className="wc-block-checkout__actions">
|
| 125 |
-
{ attributes.showReturnToCart && (
|
| 126 |
-
<ReturnToCartButton
|
| 127 |
-
link={ getSetting(
|
| 128 |
-
'page-' + attributes?.cartPageId,
|
| 129 |
-
false
|
| 130 |
-
) }
|
| 131 |
-
/>
|
| 132 |
-
) }
|
| 133 |
-
<PlaceOrderButton />
|
| 134 |
-
</div>
|
| 135 |
-
{ attributes.showPolicyLinks && <Policies /> }
|
| 136 |
-
</Main>
|
| 137 |
-
<Sidebar className="wc-block-checkout__sidebar">
|
| 138 |
-
<CheckoutSidebar
|
| 139 |
-
cartCoupons={ cartCoupons }
|
| 140 |
-
cartItems={ cartItems }
|
| 141 |
-
cartTotals={ cartTotals }
|
| 142 |
-
cartFees={ cartFees }
|
| 143 |
-
showRateAfterTaxName={ attributes.showRateAfterTaxName }
|
| 144 |
-
/>
|
| 145 |
-
</Sidebar>
|
| 146 |
-
</SidebarLayout>
|
| 147 |
-
</>
|
| 148 |
-
);
|
| 149 |
-
};
|
| 150 |
-
|
| 151 |
-
export default withScrollToTop( Checkout );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/block.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/checkout/checkout-order-error/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import { decodeEntities } from '@wordpress/html-entities';
|
|
| 10 |
/**
|
| 11 |
* Internal dependencies
|
| 12 |
*/
|
|
|
|
| 13 |
import {
|
| 14 |
PRODUCT_OUT_OF_STOCK,
|
| 15 |
PRODUCT_NOT_PURCHASABLE,
|
| 10 |
/**
|
| 11 |
* Internal dependencies
|
| 12 |
*/
|
| 13 |
+
import './style.scss';
|
| 14 |
import {
|
| 15 |
PRODUCT_OUT_OF_STOCK,
|
| 16 |
PRODUCT_NOT_PURCHASABLE,
|
assets/js/blocks/cart-checkout/checkout/checkout-order-error/style.scss
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.wc-block-checkout-error {
|
| 2 |
+
padding: $gap-largest;
|
| 3 |
+
text-align: center;
|
| 4 |
+
width: 100%;
|
| 5 |
+
|
| 6 |
+
.wc-block-checkout-error__image {
|
| 7 |
+
max-width: 150px;
|
| 8 |
+
margin: 0 auto 1em;
|
| 9 |
+
display: block;
|
| 10 |
+
color: inherit;
|
| 11 |
+
}
|
| 12 |
+
.wc-block-checkout-error__title {
|
| 13 |
+
display: block;
|
| 14 |
+
margin: 0;
|
| 15 |
+
font-weight: bold;
|
| 16 |
+
}
|
| 17 |
+
.wc-block-checkout-error__description {
|
| 18 |
+
display: block;
|
| 19 |
+
margin: 0.25em 0 1em 0;
|
| 20 |
+
}
|
| 21 |
+
}
|
assets/js/blocks/cart-checkout/checkout/columns/columns-block.tsx
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { useBlockProps } from '@wordpress/block-editor';
|
| 5 |
+
|
| 6 |
+
export const Columns = ( {
|
| 7 |
+
children,
|
| 8 |
+
...props
|
| 9 |
+
}: {
|
| 10 |
+
children?: React.ReactNode;
|
| 11 |
+
} ): JSX.Element => {
|
| 12 |
+
const blockProps = useBlockProps( props );
|
| 13 |
+
|
| 14 |
+
return <div { ...blockProps }>{ children }</div>;
|
| 15 |
+
};
|
assets/js/blocks/cart-checkout/checkout/columns/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
| 1 |
+
export * from './columns-block';
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/context.ts
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/checkout/edit.js
DELETED
|
@@ -1,399 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import classnames from 'classnames';
|
| 5 |
-
import { __ } from '@wordpress/i18n';
|
| 6 |
-
import { InspectorControls } from '@wordpress/block-editor';
|
| 7 |
-
import {
|
| 8 |
-
PanelBody,
|
| 9 |
-
ToggleControl,
|
| 10 |
-
CheckboxControl,
|
| 11 |
-
Notice,
|
| 12 |
-
Disabled,
|
| 13 |
-
} from '@wordpress/components';
|
| 14 |
-
import BlockErrorBoundary from '@woocommerce/base-components/block-error-boundary';
|
| 15 |
-
import {
|
| 16 |
-
PRIVACY_URL,
|
| 17 |
-
TERMS_URL,
|
| 18 |
-
CHECKOUT_PAGE_ID,
|
| 19 |
-
} from '@woocommerce/block-settings';
|
| 20 |
-
import { isWcVersion, getAdminLink, getSetting } from '@woocommerce/settings';
|
| 21 |
-
import { createInterpolateElement, useRef } from '@wordpress/element';
|
| 22 |
-
import {
|
| 23 |
-
EditorProvider,
|
| 24 |
-
useEditorContext,
|
| 25 |
-
StoreNoticesProvider,
|
| 26 |
-
CheckoutProvider,
|
| 27 |
-
} from '@woocommerce/base-context';
|
| 28 |
-
import { CartCheckoutFeedbackPrompt } from '@woocommerce/editor-components/feedback-prompt';
|
| 29 |
-
import PageSelector from '@woocommerce/editor-components/page-selector';
|
| 30 |
-
import { CartCheckoutCompatibilityNotice } from '@woocommerce/editor-components/compatibility-notices';
|
| 31 |
-
import {
|
| 32 |
-
previewCart,
|
| 33 |
-
previewSavedPaymentMethods,
|
| 34 |
-
} from '@woocommerce/resource-previews';
|
| 35 |
-
|
| 36 |
-
/**
|
| 37 |
-
* Internal dependencies
|
| 38 |
-
*/
|
| 39 |
-
import Block from './block.js';
|
| 40 |
-
import './editor.scss';
|
| 41 |
-
|
| 42 |
-
const BlockSettings = ( { attributes, setAttributes } ) => {
|
| 43 |
-
const {
|
| 44 |
-
showCompanyField,
|
| 45 |
-
showApartmentField,
|
| 46 |
-
showPhoneField,
|
| 47 |
-
requireCompanyField,
|
| 48 |
-
requirePhoneField,
|
| 49 |
-
allowCreateAccount,
|
| 50 |
-
showOrderNotes,
|
| 51 |
-
showPolicyLinks,
|
| 52 |
-
showReturnToCart,
|
| 53 |
-
cartPageId,
|
| 54 |
-
hasDarkControls,
|
| 55 |
-
showRateAfterTaxName,
|
| 56 |
-
} = attributes;
|
| 57 |
-
const { currentPostId } = useEditorContext();
|
| 58 |
-
const { current: savedCartPageId } = useRef( cartPageId );
|
| 59 |
-
// Checkout signup is feature gated to WooCommerce 4.7 and newer;
|
| 60 |
-
// uses updated my-account/lost-password screen from 4.7+ for
|
| 61 |
-
// setting initial password.
|
| 62 |
-
// Also implicitly gated to feature plugin, because Checkout
|
| 63 |
-
// block is gated to plugin
|
| 64 |
-
const showCreateAccountOption =
|
| 65 |
-
getSetting( 'checkoutAllowsSignup', false ) &&
|
| 66 |
-
isWcVersion( '4.7.0', '>=' );
|
| 67 |
-
return (
|
| 68 |
-
<InspectorControls>
|
| 69 |
-
{ currentPostId !== CHECKOUT_PAGE_ID && (
|
| 70 |
-
<Notice
|
| 71 |
-
className="wc-block-checkout__page-notice"
|
| 72 |
-
isDismissible={ false }
|
| 73 |
-
status="warning"
|
| 74 |
-
>
|
| 75 |
-
{ createInterpolateElement(
|
| 76 |
-
__(
|
| 77 |
-
'If you would like to use this block as your default checkout you must update your <a>page settings in WooCommerce</a>.',
|
| 78 |
-
'woo-gutenberg-products-block'
|
| 79 |
-
),
|
| 80 |
-
{
|
| 81 |
-
a: (
|
| 82 |
-
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
| 83 |
-
<a
|
| 84 |
-
href={ getAdminLink(
|
| 85 |
-
'admin.php?page=wc-settings&tab=advanced'
|
| 86 |
-
) }
|
| 87 |
-
target="_blank"
|
| 88 |
-
rel="noopener noreferrer"
|
| 89 |
-
/>
|
| 90 |
-
),
|
| 91 |
-
}
|
| 92 |
-
) }
|
| 93 |
-
</Notice>
|
| 94 |
-
) }
|
| 95 |
-
<PanelBody
|
| 96 |
-
title={ __(
|
| 97 |
-
'Address options',
|
| 98 |
-
'woo-gutenberg-products-block'
|
| 99 |
-
) }
|
| 100 |
-
>
|
| 101 |
-
<p className="wc-block-checkout__controls-text">
|
| 102 |
-
{ __(
|
| 103 |
-
'Include additional address fields in the checkout form.',
|
| 104 |
-
'woo-gutenberg-products-block'
|
| 105 |
-
) }
|
| 106 |
-
</p>
|
| 107 |
-
<ToggleControl
|
| 108 |
-
label={ __( 'Company', 'woo-gutenberg-products-block' ) }
|
| 109 |
-
checked={ showCompanyField }
|
| 110 |
-
onChange={ () =>
|
| 111 |
-
setAttributes( {
|
| 112 |
-
showCompanyField: ! showCompanyField,
|
| 113 |
-
} )
|
| 114 |
-
}
|
| 115 |
-
/>
|
| 116 |
-
{ showCompanyField && (
|
| 117 |
-
<CheckboxControl
|
| 118 |
-
label={ __(
|
| 119 |
-
'Require company name?',
|
| 120 |
-
'woo-gutenberg-products-block'
|
| 121 |
-
) }
|
| 122 |
-
checked={ requireCompanyField }
|
| 123 |
-
onChange={ () =>
|
| 124 |
-
setAttributes( {
|
| 125 |
-
requireCompanyField: ! requireCompanyField,
|
| 126 |
-
} )
|
| 127 |
-
}
|
| 128 |
-
className="components-base-control--nested"
|
| 129 |
-
/>
|
| 130 |
-
) }
|
| 131 |
-
<ToggleControl
|
| 132 |
-
label={ __(
|
| 133 |
-
'Apartment, suite, etc.',
|
| 134 |
-
'woo-gutenberg-products-block'
|
| 135 |
-
) }
|
| 136 |
-
checked={ showApartmentField }
|
| 137 |
-
onChange={ () =>
|
| 138 |
-
setAttributes( {
|
| 139 |
-
showApartmentField: ! showApartmentField,
|
| 140 |
-
} )
|
| 141 |
-
}
|
| 142 |
-
/>
|
| 143 |
-
<ToggleControl
|
| 144 |
-
label={ __( 'Phone', 'woo-gutenberg-products-block' ) }
|
| 145 |
-
checked={ showPhoneField }
|
| 146 |
-
onChange={ () =>
|
| 147 |
-
setAttributes( {
|
| 148 |
-
showPhoneField: ! showPhoneField,
|
| 149 |
-
} )
|
| 150 |
-
}
|
| 151 |
-
/>
|
| 152 |
-
{ showPhoneField && (
|
| 153 |
-
<CheckboxControl
|
| 154 |
-
label={ __(
|
| 155 |
-
'Require phone number?',
|
| 156 |
-
'woo-gutenberg-products-block'
|
| 157 |
-
) }
|
| 158 |
-
checked={ requirePhoneField }
|
| 159 |
-
onChange={ () =>
|
| 160 |
-
setAttributes( {
|
| 161 |
-
requirePhoneField: ! requirePhoneField,
|
| 162 |
-
} )
|
| 163 |
-
}
|
| 164 |
-
className="components-base-control--nested"
|
| 165 |
-
/>
|
| 166 |
-
) }
|
| 167 |
-
</PanelBody>
|
| 168 |
-
{ showCreateAccountOption && (
|
| 169 |
-
<PanelBody
|
| 170 |
-
title={ __(
|
| 171 |
-
'Account options',
|
| 172 |
-
'woo-gutenberg-products-block'
|
| 173 |
-
) }
|
| 174 |
-
>
|
| 175 |
-
<ToggleControl
|
| 176 |
-
label={ __(
|
| 177 |
-
'Allow shoppers to sign up for a user account during checkout',
|
| 178 |
-
'woo-gutenberg-products-block'
|
| 179 |
-
) }
|
| 180 |
-
checked={ allowCreateAccount }
|
| 181 |
-
onChange={ () =>
|
| 182 |
-
setAttributes( {
|
| 183 |
-
allowCreateAccount: ! allowCreateAccount,
|
| 184 |
-
} )
|
| 185 |
-
}
|
| 186 |
-
/>
|
| 187 |
-
</PanelBody>
|
| 188 |
-
) }
|
| 189 |
-
<PanelBody
|
| 190 |
-
title={ __( 'Order notes', 'woo-gutenberg-products-block' ) }
|
| 191 |
-
>
|
| 192 |
-
<p className="wc-block-checkout__controls-text">
|
| 193 |
-
{ __(
|
| 194 |
-
'Reduce the number of fields to checkout.',
|
| 195 |
-
'woo-gutenberg-products-block'
|
| 196 |
-
) }
|
| 197 |
-
</p>
|
| 198 |
-
<ToggleControl
|
| 199 |
-
label={ __(
|
| 200 |
-
'Allow shoppers to optionally add order notes',
|
| 201 |
-
'woo-gutenberg-products-block'
|
| 202 |
-
) }
|
| 203 |
-
checked={ showOrderNotes }
|
| 204 |
-
onChange={ () =>
|
| 205 |
-
setAttributes( {
|
| 206 |
-
showOrderNotes: ! showOrderNotes,
|
| 207 |
-
} )
|
| 208 |
-
}
|
| 209 |
-
/>
|
| 210 |
-
</PanelBody>
|
| 211 |
-
<PanelBody
|
| 212 |
-
title={ __(
|
| 213 |
-
'Navigation options',
|
| 214 |
-
'woo-gutenberg-products-block'
|
| 215 |
-
) }
|
| 216 |
-
>
|
| 217 |
-
<ToggleControl
|
| 218 |
-
label={ __(
|
| 219 |
-
'Show links to policies',
|
| 220 |
-
'woo-gutenberg-products-block'
|
| 221 |
-
) }
|
| 222 |
-
help={ __(
|
| 223 |
-
'Shows links to your "terms and conditions" and "privacy policy" pages.',
|
| 224 |
-
'woo-gutenberg-products-block'
|
| 225 |
-
) }
|
| 226 |
-
checked={ showPolicyLinks }
|
| 227 |
-
onChange={ () =>
|
| 228 |
-
setAttributes( {
|
| 229 |
-
showPolicyLinks: ! showPolicyLinks,
|
| 230 |
-
} )
|
| 231 |
-
}
|
| 232 |
-
/>
|
| 233 |
-
{ showPolicyLinks && ( ! PRIVACY_URL || ! TERMS_URL ) && (
|
| 234 |
-
<Notice
|
| 235 |
-
className="wc-block-base-control-notice"
|
| 236 |
-
isDismissible={ false }
|
| 237 |
-
>
|
| 238 |
-
{ createInterpolateElement(
|
| 239 |
-
__(
|
| 240 |
-
'Pages must be first setup in store settings: <a1>Privacy policy</a1>, <a2>Terms and conditions</a2>.',
|
| 241 |
-
'woo-gutenberg-products-block'
|
| 242 |
-
),
|
| 243 |
-
{
|
| 244 |
-
a1: (
|
| 245 |
-
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
| 246 |
-
<a
|
| 247 |
-
href={ getAdminLink(
|
| 248 |
-
'admin.php?page=wc-settings&tab=account'
|
| 249 |
-
) }
|
| 250 |
-
target="_blank"
|
| 251 |
-
rel="noopener noreferrer"
|
| 252 |
-
/>
|
| 253 |
-
),
|
| 254 |
-
a2: (
|
| 255 |
-
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
| 256 |
-
<a
|
| 257 |
-
href={ getAdminLink(
|
| 258 |
-
'admin.php?page=wc-settings&tab=advanced'
|
| 259 |
-
) }
|
| 260 |
-
target="_blank"
|
| 261 |
-
rel="noopener noreferrer"
|
| 262 |
-
/>
|
| 263 |
-
),
|
| 264 |
-
}
|
| 265 |
-
) }
|
| 266 |
-
</Notice>
|
| 267 |
-
) }
|
| 268 |
-
<ToggleControl
|
| 269 |
-
label={ __(
|
| 270 |
-
'Show a "Return to Cart" link',
|
| 271 |
-
'woo-gutenberg-products-block'
|
| 272 |
-
) }
|
| 273 |
-
checked={ showReturnToCart }
|
| 274 |
-
onChange={ () =>
|
| 275 |
-
setAttributes( {
|
| 276 |
-
showReturnToCart: ! showReturnToCart,
|
| 277 |
-
} )
|
| 278 |
-
}
|
| 279 |
-
/>
|
| 280 |
-
</PanelBody>
|
| 281 |
-
{ showReturnToCart &&
|
| 282 |
-
! (
|
| 283 |
-
currentPostId === CHECKOUT_PAGE_ID && savedCartPageId === 0
|
| 284 |
-
) && (
|
| 285 |
-
<PageSelector
|
| 286 |
-
pageId={ cartPageId }
|
| 287 |
-
setPageId={ ( id ) =>
|
| 288 |
-
setAttributes( { cartPageId: id } )
|
| 289 |
-
}
|
| 290 |
-
labels={ {
|
| 291 |
-
title: __(
|
| 292 |
-
'Return to Cart button',
|
| 293 |
-
'woo-gutenberg-products-block'
|
| 294 |
-
),
|
| 295 |
-
default: __(
|
| 296 |
-
'WooCommerce Cart Page',
|
| 297 |
-
'woo-gutenberg-products-block'
|
| 298 |
-
),
|
| 299 |
-
} }
|
| 300 |
-
/>
|
| 301 |
-
) }
|
| 302 |
-
{ getSetting( 'taxesEnabled' ) &&
|
| 303 |
-
getSetting( 'displayItemizedTaxes', false ) &&
|
| 304 |
-
! getSetting( 'displayCartPricesIncludingTax', false ) && (
|
| 305 |
-
<PanelBody
|
| 306 |
-
title={ __( 'Taxes', 'woo-gutenberg-products-block' ) }
|
| 307 |
-
>
|
| 308 |
-
<ToggleControl
|
| 309 |
-
label={ __(
|
| 310 |
-
'Show rate after tax name',
|
| 311 |
-
'woo-gutenberg-products-block'
|
| 312 |
-
) }
|
| 313 |
-
help={ __(
|
| 314 |
-
'Show the percentage rate alongside each tax line in the summary.',
|
| 315 |
-
'woo-gutenberg-products-block'
|
| 316 |
-
) }
|
| 317 |
-
checked={ showRateAfterTaxName }
|
| 318 |
-
onChange={ () =>
|
| 319 |
-
setAttributes( {
|
| 320 |
-
showRateAfterTaxName: ! showRateAfterTaxName,
|
| 321 |
-
} )
|
| 322 |
-
}
|
| 323 |
-
/>
|
| 324 |
-
</PanelBody>
|
| 325 |
-
) }
|
| 326 |
-
<PanelBody title={ __( 'Style', 'woo-gutenberg-products-block' ) }>
|
| 327 |
-
<ToggleControl
|
| 328 |
-
label={ __(
|
| 329 |
-
'Dark mode inputs',
|
| 330 |
-
'woo-gutenberg-products-block'
|
| 331 |
-
) }
|
| 332 |
-
help={ __(
|
| 333 |
-
'Inputs styled specifically for use on dark background colors.',
|
| 334 |
-
'woo-gutenberg-products-block'
|
| 335 |
-
) }
|
| 336 |
-
checked={ hasDarkControls }
|
| 337 |
-
onChange={ () =>
|
| 338 |
-
setAttributes( {
|
| 339 |
-
hasDarkControls: ! hasDarkControls,
|
| 340 |
-
} )
|
| 341 |
-
}
|
| 342 |
-
/>
|
| 343 |
-
</PanelBody>
|
| 344 |
-
<CartCheckoutFeedbackPrompt />
|
| 345 |
-
</InspectorControls>
|
| 346 |
-
);
|
| 347 |
-
};
|
| 348 |
-
|
| 349 |
-
const CheckoutEditor = ( { attributes, setAttributes } ) => {
|
| 350 |
-
const { className, isPreview } = attributes;
|
| 351 |
-
return (
|
| 352 |
-
<>
|
| 353 |
-
<EditorProvider
|
| 354 |
-
previewData={ { previewCart, previewSavedPaymentMethods } }
|
| 355 |
-
>
|
| 356 |
-
<div
|
| 357 |
-
className={ classnames(
|
| 358 |
-
className,
|
| 359 |
-
'wp-block-woocommerce-checkout',
|
| 360 |
-
{
|
| 361 |
-
'is-editor-preview': isPreview,
|
| 362 |
-
}
|
| 363 |
-
) }
|
| 364 |
-
>
|
| 365 |
-
<BlockSettings
|
| 366 |
-
attributes={ attributes }
|
| 367 |
-
setAttributes={ setAttributes }
|
| 368 |
-
/>
|
| 369 |
-
<BlockErrorBoundary
|
| 370 |
-
header={ __(
|
| 371 |
-
'Checkout Block Error',
|
| 372 |
-
'woo-gutenberg-products-block'
|
| 373 |
-
) }
|
| 374 |
-
text={ __(
|
| 375 |
-
'There was an error whilst rendering the checkout block. If this problem continues, try re-creating the block.',
|
| 376 |
-
'woo-gutenberg-products-block'
|
| 377 |
-
) }
|
| 378 |
-
showErrorMessage={ true }
|
| 379 |
-
errorMessagePrefix={ __(
|
| 380 |
-
'Error message:',
|
| 381 |
-
'woo-gutenberg-products-block'
|
| 382 |
-
) }
|
| 383 |
-
>
|
| 384 |
-
<StoreNoticesProvider context="wc/checkout">
|
| 385 |
-
<Disabled>
|
| 386 |
-
<CheckoutProvider>
|
| 387 |
-
<Block attributes={ attributes } />
|
| 388 |
-
</CheckoutProvider>
|
| 389 |
-
</Disabled>
|
| 390 |
-
</StoreNoticesProvider>
|
| 391 |
-
</BlockErrorBoundary>
|
| 392 |
-
</div>
|
| 393 |
-
</EditorProvider>
|
| 394 |
-
<CartCheckoutCompatibilityNotice blockName="checkout" />
|
| 395 |
-
</>
|
| 396 |
-
);
|
| 397 |
-
};
|
| 398 |
-
|
| 399 |
-
export default CheckoutEditor;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/edit.tsx
RENAMED
|
@@ -28,13 +28,14 @@ import { CartCheckoutFeedbackPrompt } from '@woocommerce/editor-components/feedb
|
|
| 28 |
import { CHECKOUT_PAGE_ID } from '@woocommerce/block-settings';
|
| 29 |
import { createInterpolateElement } from '@wordpress/element';
|
| 30 |
import { getAdminLink } from '@woocommerce/settings';
|
|
|
|
| 31 |
|
| 32 |
/**
|
| 33 |
* Internal dependencies
|
| 34 |
*/
|
| 35 |
import './styles/editor.scss';
|
| 36 |
import { Columns } from './columns';
|
| 37 |
-
import { addClassToBody } from './hacks';
|
| 38 |
import { CheckoutBlockContext, CheckoutBlockControlsContext } from './context';
|
| 39 |
import type { Attributes } from './types';
|
| 40 |
|
|
@@ -259,49 +260,52 @@ export const Edit = ( {
|
|
| 259 |
</PanelBody>
|
| 260 |
</InspectorControls>
|
| 261 |
);
|
| 262 |
-
|
| 263 |
return (
|
| 264 |
-
<
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
<
|
| 273 |
-
<
|
| 274 |
-
|
| 275 |
-
'
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
<CheckoutBlockControlsContext.Provider
|
| 279 |
-
value={ {
|
| 280 |
-
addressFieldControls,
|
| 281 |
-
accountControls,
|
| 282 |
-
} }
|
| 283 |
>
|
| 284 |
-
<
|
| 285 |
value={ {
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
requireCompanyField,
|
| 289 |
-
showApartmentField,
|
| 290 |
-
showPhoneField,
|
| 291 |
-
requirePhoneField,
|
| 292 |
} }
|
| 293 |
>
|
| 294 |
-
<
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
);
|
| 306 |
};
|
| 307 |
|
| 28 |
import { CHECKOUT_PAGE_ID } from '@woocommerce/block-settings';
|
| 29 |
import { createInterpolateElement } from '@wordpress/element';
|
| 30 |
import { getAdminLink } from '@woocommerce/settings';
|
| 31 |
+
import { CartCheckoutCompatibilityNotice } from '@woocommerce/editor-components/compatibility-notices';
|
| 32 |
|
| 33 |
/**
|
| 34 |
* Internal dependencies
|
| 35 |
*/
|
| 36 |
import './styles/editor.scss';
|
| 37 |
import { Columns } from './columns';
|
| 38 |
+
import { addClassToBody, useBlockPropsWithLocking } from './hacks';
|
| 39 |
import { CheckoutBlockContext, CheckoutBlockControlsContext } from './context';
|
| 40 |
import type { Attributes } from './types';
|
| 41 |
|
| 260 |
</PanelBody>
|
| 261 |
</InspectorControls>
|
| 262 |
);
|
| 263 |
+
const blockProps = useBlockPropsWithLocking();
|
| 264 |
return (
|
| 265 |
+
<div { ...blockProps }>
|
| 266 |
+
<EditorProvider
|
| 267 |
+
previewData={ { previewCart, previewSavedPaymentMethods } }
|
| 268 |
+
>
|
| 269 |
+
<BlockSettings
|
| 270 |
+
attributes={ attributes }
|
| 271 |
+
setAttributes={ setAttributes }
|
| 272 |
+
/>
|
| 273 |
+
<CheckoutProvider>
|
| 274 |
+
<Columns>
|
| 275 |
+
<SidebarLayout
|
| 276 |
+
className={ classnames( 'wc-block-checkout', {
|
| 277 |
+
'has-dark-controls': attributes.hasDarkControls,
|
| 278 |
+
} ) }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 279 |
>
|
| 280 |
+
<CheckoutBlockControlsContext.Provider
|
| 281 |
value={ {
|
| 282 |
+
addressFieldControls,
|
| 283 |
+
accountControls,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
} }
|
| 285 |
>
|
| 286 |
+
<CheckoutBlockContext.Provider
|
| 287 |
+
value={ {
|
| 288 |
+
allowCreateAccount,
|
| 289 |
+
showCompanyField,
|
| 290 |
+
requireCompanyField,
|
| 291 |
+
showApartmentField,
|
| 292 |
+
showPhoneField,
|
| 293 |
+
requirePhoneField,
|
| 294 |
+
} }
|
| 295 |
+
>
|
| 296 |
+
<InnerBlocks
|
| 297 |
+
allowedBlocks={ ALLOWED_BLOCKS }
|
| 298 |
+
template={ defaultInnerBlocksTemplate }
|
| 299 |
+
templateLock="insert"
|
| 300 |
+
/>
|
| 301 |
+
</CheckoutBlockContext.Provider>
|
| 302 |
+
</CheckoutBlockControlsContext.Provider>
|
| 303 |
+
</SidebarLayout>
|
| 304 |
+
</Columns>
|
| 305 |
+
</CheckoutProvider>
|
| 306 |
+
</EditorProvider>
|
| 307 |
+
<CartCheckoutCompatibilityNotice blockName="checkout" />
|
| 308 |
+
</div>
|
| 309 |
);
|
| 310 |
};
|
| 311 |
|
assets/js/blocks/cart-checkout/checkout/editor-utils.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { getBlockTypes } from '@wordpress/blocks';
|
| 5 |
+
|
| 6 |
+
// List of core block types to allow in inner block areas.
|
| 7 |
+
const coreBlockTypes = [ 'core/paragraph', 'core/image', 'core/separator' ];
|
| 8 |
+
|
| 9 |
+
/**
|
| 10 |
+
* Gets a list of allowed blocks types under a specific parent block type.
|
| 11 |
+
*/
|
| 12 |
+
export const getAllowedBlocks = ( block: string ): string[] => [
|
| 13 |
+
...getBlockTypes()
|
| 14 |
+
.filter( ( blockType ) =>
|
| 15 |
+
( blockType?.parent || [] ).includes( block )
|
| 16 |
+
)
|
| 17 |
+
.map( ( { name } ) => name ),
|
| 18 |
+
...coreBlockTypes,
|
| 19 |
+
];
|
assets/js/blocks/cart-checkout/checkout/editor.scss
DELETED
|
@@ -1,29 +0,0 @@
|
|
| 1 |
-
.editor-styles-wrapper {
|
| 2 |
-
.wp-block h4.wc-block-components-checkout-step__title {
|
| 3 |
-
@include font-size(regular);
|
| 4 |
-
line-height: 24px;
|
| 5 |
-
margin: 0 $gap-small 0 0;
|
| 6 |
-
}
|
| 7 |
-
}
|
| 8 |
-
.wc-block-checkout__controls-text {
|
| 9 |
-
color: #999;
|
| 10 |
-
font-style: italic;
|
| 11 |
-
}
|
| 12 |
-
|
| 13 |
-
.components-base-control--nested {
|
| 14 |
-
padding-left: 52px;
|
| 15 |
-
margin-top: -12px;
|
| 16 |
-
}
|
| 17 |
-
|
| 18 |
-
.wc-block-checkout__page-notice {
|
| 19 |
-
margin: 0;
|
| 20 |
-
}
|
| 21 |
-
|
| 22 |
-
.components-panel__body-title .components-button {
|
| 23 |
-
opacity: 1;
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
-
.wp-block-woocommerce-checkout.is-editor-preview {
|
| 27 |
-
max-height: 1000px;
|
| 28 |
-
overflow: hidden;
|
| 29 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout/empty-cart/index.js
CHANGED
|
@@ -5,6 +5,11 @@ import { __ } from '@wordpress/i18n';
|
|
| 5 |
import { SHOP_URL } from '@woocommerce/block-settings';
|
| 6 |
import { Icon, cart } from '@woocommerce/icons';
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
const EmptyCart = () => {
|
| 9 |
return (
|
| 10 |
<div className="wc-block-checkout-empty">
|
| 5 |
import { SHOP_URL } from '@woocommerce/block-settings';
|
| 6 |
import { Icon, cart } from '@woocommerce/icons';
|
| 7 |
|
| 8 |
+
/**
|
| 9 |
+
* Internal dependencies
|
| 10 |
+
*/
|
| 11 |
+
import './style.scss';
|
| 12 |
+
|
| 13 |
const EmptyCart = () => {
|
| 14 |
return (
|
| 15 |
<div className="wc-block-checkout-empty">
|
assets/js/blocks/cart-checkout/checkout/empty-cart/style.scss
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.wc-block-checkout-empty {
|
| 2 |
+
padding: $gap-largest;
|
| 3 |
+
text-align: center;
|
| 4 |
+
width: 100%;
|
| 5 |
+
|
| 6 |
+
.wc-block-checkout-empty__image {
|
| 7 |
+
max-width: 150px;
|
| 8 |
+
margin: 0 auto 1em;
|
| 9 |
+
display: block;
|
| 10 |
+
color: inherit;
|
| 11 |
+
}
|
| 12 |
+
.wc-block-checkout-empty__title {
|
| 13 |
+
display: block;
|
| 14 |
+
margin: 0;
|
| 15 |
+
font-weight: bold;
|
| 16 |
+
}
|
| 17 |
+
.wc-block-checkout-empty__description {
|
| 18 |
+
display: block;
|
| 19 |
+
margin: 0.25em 0 1em 0;
|
| 20 |
+
}
|
| 21 |
+
}
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/form-step/additional-fields.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/form-step/attributes.ts
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/form-step/editor.scss
RENAMED
|
@@ -8,4 +8,5 @@
|
|
| 8 |
|
| 9 |
.wc-block-components-checkout-step__title {
|
| 10 |
display: flex;
|
|
|
|
| 11 |
}
|
| 8 |
|
| 9 |
.wc-block-components-checkout-step__title {
|
| 10 |
display: flex;
|
| 11 |
+
width: 100%;
|
| 12 |
}
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/form-step/form-step-block.tsx
RENAMED
|
@@ -3,14 +3,17 @@
|
|
| 3 |
*/
|
| 4 |
import { __ } from '@wordpress/i18n';
|
| 5 |
import classnames from 'classnames';
|
| 6 |
-
import {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
import { PanelBody, ToggleControl } from '@wordpress/components';
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Internal dependencies
|
| 11 |
*/
|
| 12 |
import FormStepHeading from './form-step-heading';
|
| 13 |
-
import { useBlockPropsWithLocking } from '../hacks';
|
| 14 |
export interface FormStepBlockProps {
|
| 15 |
attributes: { title: string; description: string; showStepNumber: boolean };
|
| 16 |
setAttributes: ( attributes: Record< string, unknown > ) => void;
|
|
@@ -29,11 +32,10 @@ export const FormStepBlock = ( {
|
|
| 29 |
children,
|
| 30 |
}: FormStepBlockProps ): JSX.Element => {
|
| 31 |
const { title = '', description = '', showStepNumber = true } = attributes;
|
| 32 |
-
const blockProps =
|
| 33 |
className: classnames( 'wc-block-components-checkout-step', className, {
|
| 34 |
'wc-block-components-checkout-step--with-step-number': showStepNumber,
|
| 35 |
} ),
|
| 36 |
-
attributes,
|
| 37 |
} );
|
| 38 |
return (
|
| 39 |
<div { ...blockProps }>
|
| 3 |
*/
|
| 4 |
import { __ } from '@wordpress/i18n';
|
| 5 |
import classnames from 'classnames';
|
| 6 |
+
import {
|
| 7 |
+
PlainText,
|
| 8 |
+
InspectorControls,
|
| 9 |
+
useBlockProps,
|
| 10 |
+
} from '@wordpress/block-editor';
|
| 11 |
import { PanelBody, ToggleControl } from '@wordpress/components';
|
| 12 |
|
| 13 |
/**
|
| 14 |
* Internal dependencies
|
| 15 |
*/
|
| 16 |
import FormStepHeading from './form-step-heading';
|
|
|
|
| 17 |
export interface FormStepBlockProps {
|
| 18 |
attributes: { title: string; description: string; showStepNumber: boolean };
|
| 19 |
setAttributes: ( attributes: Record< string, unknown > ) => void;
|
| 32 |
children,
|
| 33 |
}: FormStepBlockProps ): JSX.Element => {
|
| 34 |
const { title = '', description = '', showStepNumber = true } = attributes;
|
| 35 |
+
const blockProps = useBlockProps( {
|
| 36 |
className: classnames( 'wc-block-components-checkout-step', className, {
|
| 37 |
'wc-block-components-checkout-step--with-step-number': showStepNumber,
|
| 38 |
} ),
|
|
|
|
| 39 |
} );
|
| 40 |
return (
|
| 41 |
<div { ...blockProps }>
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/form-step/form-step-heading.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/form-step/index.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/checkout/form/billing-fields-step.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { FormStep } from '@woocommerce/base-components/cart-checkout';
|
| 6 |
-
import { useCheckoutSubmit } from '@woocommerce/base-context/hooks';
|
| 7 |
-
import PropTypes from 'prop-types';
|
| 8 |
-
|
| 9 |
-
const BillingFieldsStep = ( { children } ) => {
|
| 10 |
-
const { isDisabled } = useCheckoutSubmit();
|
| 11 |
-
return (
|
| 12 |
-
<FormStep
|
| 13 |
-
id="billing-fields"
|
| 14 |
-
disabled={ isDisabled }
|
| 15 |
-
className="wc-block-checkout__billing-fields"
|
| 16 |
-
title={ __( 'Billing address', 'woo-gutenberg-products-block' ) }
|
| 17 |
-
description={ __(
|
| 18 |
-
'Enter the address that matches your card or payment method.',
|
| 19 |
-
'woo-gutenberg-products-block'
|
| 20 |
-
) }
|
| 21 |
-
>
|
| 22 |
-
{ children }
|
| 23 |
-
</FormStep>
|
| 24 |
-
);
|
| 25 |
-
};
|
| 26 |
-
|
| 27 |
-
BillingFieldsStep.propTypes = {
|
| 28 |
-
children: PropTypes.node.isRequired,
|
| 29 |
-
};
|
| 30 |
-
|
| 31 |
-
export default BillingFieldsStep;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout/form/contact-fields-step.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { FormStep } from '@woocommerce/base-components/cart-checkout';
|
| 6 |
-
import { ValidatedTextInput } from '@woocommerce/base-components/text-input';
|
| 7 |
-
import { useCheckoutContext } from '@woocommerce/base-context';
|
| 8 |
-
import { useCheckoutSubmit } from '@woocommerce/base-context/hooks';
|
| 9 |
-
import { getSetting } from '@woocommerce/settings';
|
| 10 |
-
import CheckboxControl from '@woocommerce/base-components/checkbox-control';
|
| 11 |
-
|
| 12 |
-
/**
|
| 13 |
-
* Internal dependencies
|
| 14 |
-
*/
|
| 15 |
-
import LoginPrompt from './login-prompt';
|
| 16 |
-
const ContactFieldsStep = ( {
|
| 17 |
-
emailValue,
|
| 18 |
-
onChangeEmail,
|
| 19 |
-
allowCreateAccount,
|
| 20 |
-
} ) => {
|
| 21 |
-
const {
|
| 22 |
-
customerId,
|
| 23 |
-
shouldCreateAccount,
|
| 24 |
-
setShouldCreateAccount,
|
| 25 |
-
} = useCheckoutContext();
|
| 26 |
-
const { isDisabled } = useCheckoutSubmit();
|
| 27 |
-
|
| 28 |
-
const createAccountUI = ! customerId &&
|
| 29 |
-
allowCreateAccount &&
|
| 30 |
-
getSetting( 'checkoutAllowsGuest', false ) &&
|
| 31 |
-
getSetting( 'checkoutAllowsSignup', false ) && (
|
| 32 |
-
<CheckboxControl
|
| 33 |
-
className="wc-block-checkout__create-account"
|
| 34 |
-
label={ __(
|
| 35 |
-
'Create an account?',
|
| 36 |
-
'woo-gutenberg-products-block'
|
| 37 |
-
) }
|
| 38 |
-
checked={ shouldCreateAccount }
|
| 39 |
-
onChange={ ( value ) => setShouldCreateAccount( value ) }
|
| 40 |
-
/>
|
| 41 |
-
);
|
| 42 |
-
|
| 43 |
-
return (
|
| 44 |
-
<FormStep
|
| 45 |
-
id="contact-fields"
|
| 46 |
-
disabled={ isDisabled }
|
| 47 |
-
className="wc-block-checkout__contact-fields"
|
| 48 |
-
title={ __(
|
| 49 |
-
'Contact information',
|
| 50 |
-
'woo-gutenberg-products-block'
|
| 51 |
-
) }
|
| 52 |
-
description={ __(
|
| 53 |
-
"We'll use this email to send you details and updates about your order.",
|
| 54 |
-
'woo-gutenberg-products-block'
|
| 55 |
-
) }
|
| 56 |
-
stepHeadingContent={ () => <LoginPrompt /> }
|
| 57 |
-
>
|
| 58 |
-
<ValidatedTextInput
|
| 59 |
-
id="email"
|
| 60 |
-
type="email"
|
| 61 |
-
label={ __( 'Email address', 'woo-gutenberg-products-block' ) }
|
| 62 |
-
value={ emailValue }
|
| 63 |
-
autoComplete="email"
|
| 64 |
-
onChange={ onChangeEmail }
|
| 65 |
-
required={ true }
|
| 66 |
-
/>
|
| 67 |
-
{ createAccountUI }
|
| 68 |
-
</FormStep>
|
| 69 |
-
);
|
| 70 |
-
};
|
| 71 |
-
|
| 72 |
-
export default ContactFieldsStep;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout/form/index.js
DELETED
|
@@ -1,156 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import PropTypes from 'prop-types';
|
| 5 |
-
import { useEffect, useMemo } from '@wordpress/element';
|
| 6 |
-
import {
|
| 7 |
-
useCheckoutContext,
|
| 8 |
-
useShippingDataContext,
|
| 9 |
-
} from '@woocommerce/base-context';
|
| 10 |
-
import {
|
| 11 |
-
useStoreEvents,
|
| 12 |
-
useCheckoutAddress,
|
| 13 |
-
} from '@woocommerce/base-context/hooks';
|
| 14 |
-
import { AddressForm } from '@woocommerce/base-components/cart-checkout';
|
| 15 |
-
import Form from '@woocommerce/base-components/form';
|
| 16 |
-
|
| 17 |
-
/**
|
| 18 |
-
* Internal dependencies
|
| 19 |
-
*/
|
| 20 |
-
import BillingFieldsStep from './billing-fields-step';
|
| 21 |
-
import ContactFieldsStep from './contact-fields-step';
|
| 22 |
-
import ShippingFieldsStep from './shipping-fields-step';
|
| 23 |
-
import PhoneNumber from './phone-number';
|
| 24 |
-
import OrderNotesStep from './order-notes-step';
|
| 25 |
-
import PaymentMethodStep from './payment-method-step';
|
| 26 |
-
import ShippingOptionsStep from './shipping-options-step';
|
| 27 |
-
import './style.scss';
|
| 28 |
-
|
| 29 |
-
const CheckoutForm = ( {
|
| 30 |
-
requireCompanyField,
|
| 31 |
-
requirePhoneField,
|
| 32 |
-
showApartmentField,
|
| 33 |
-
showCompanyField,
|
| 34 |
-
showOrderNotes,
|
| 35 |
-
showPhoneField,
|
| 36 |
-
allowCreateAccount,
|
| 37 |
-
} ) => {
|
| 38 |
-
const { onSubmit } = useCheckoutContext();
|
| 39 |
-
const {
|
| 40 |
-
defaultAddressFields,
|
| 41 |
-
billingFields,
|
| 42 |
-
setBillingFields,
|
| 43 |
-
setEmail,
|
| 44 |
-
setPhone,
|
| 45 |
-
setShippingAsBilling,
|
| 46 |
-
setShippingFields,
|
| 47 |
-
shippingAsBilling,
|
| 48 |
-
shippingFields,
|
| 49 |
-
showBillingFields,
|
| 50 |
-
} = useCheckoutAddress();
|
| 51 |
-
const { needsShipping } = useShippingDataContext();
|
| 52 |
-
const { dispatchCheckoutEvent } = useStoreEvents();
|
| 53 |
-
|
| 54 |
-
const addressFieldsConfig = useMemo( () => {
|
| 55 |
-
return {
|
| 56 |
-
company: {
|
| 57 |
-
hidden: ! showCompanyField,
|
| 58 |
-
required: requireCompanyField,
|
| 59 |
-
},
|
| 60 |
-
address_2: {
|
| 61 |
-
hidden: ! showApartmentField,
|
| 62 |
-
},
|
| 63 |
-
};
|
| 64 |
-
}, [ showCompanyField, requireCompanyField, showApartmentField ] );
|
| 65 |
-
|
| 66 |
-
// Ignore changes to dispatchCheckoutEvent callback so this is ran on first mount only.
|
| 67 |
-
useEffect( () => {
|
| 68 |
-
dispatchCheckoutEvent( 'render-checkout-form' );
|
| 69 |
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
| 70 |
-
}, [] );
|
| 71 |
-
|
| 72 |
-
return (
|
| 73 |
-
<Form className="wc-block-checkout__form" onSubmit={ onSubmit }>
|
| 74 |
-
<ContactFieldsStep
|
| 75 |
-
emailValue={ billingFields.email }
|
| 76 |
-
onChangeEmail={ ( value ) => {
|
| 77 |
-
setEmail( value );
|
| 78 |
-
dispatchCheckoutEvent( 'set-email-address' );
|
| 79 |
-
} }
|
| 80 |
-
allowCreateAccount={ allowCreateAccount }
|
| 81 |
-
/>
|
| 82 |
-
{ needsShipping && (
|
| 83 |
-
<ShippingFieldsStep
|
| 84 |
-
shippingAsBilling={ shippingAsBilling }
|
| 85 |
-
setShippingAsBilling={ setShippingAsBilling }
|
| 86 |
-
>
|
| 87 |
-
<AddressForm
|
| 88 |
-
id="shipping"
|
| 89 |
-
type="shipping"
|
| 90 |
-
onChange={ ( values ) => {
|
| 91 |
-
setShippingFields( values );
|
| 92 |
-
dispatchCheckoutEvent( 'set-shipping-address' );
|
| 93 |
-
} }
|
| 94 |
-
values={ shippingFields }
|
| 95 |
-
fields={ Object.keys( defaultAddressFields ) }
|
| 96 |
-
fieldConfig={ addressFieldsConfig }
|
| 97 |
-
/>
|
| 98 |
-
{ showPhoneField && (
|
| 99 |
-
<PhoneNumber
|
| 100 |
-
isRequired={ requirePhoneField }
|
| 101 |
-
value={ billingFields.phone }
|
| 102 |
-
onChange={ ( value ) => {
|
| 103 |
-
setPhone( value );
|
| 104 |
-
dispatchCheckoutEvent( 'set-phone-number', {
|
| 105 |
-
step: 'shipping',
|
| 106 |
-
} );
|
| 107 |
-
} }
|
| 108 |
-
/>
|
| 109 |
-
) }
|
| 110 |
-
</ShippingFieldsStep>
|
| 111 |
-
) }
|
| 112 |
-
{ showBillingFields && (
|
| 113 |
-
<BillingFieldsStep>
|
| 114 |
-
<AddressForm
|
| 115 |
-
id="billing"
|
| 116 |
-
type="billing"
|
| 117 |
-
onChange={ ( values ) => {
|
| 118 |
-
setBillingFields( values );
|
| 119 |
-
dispatchCheckoutEvent( 'set-billing-address' );
|
| 120 |
-
} }
|
| 121 |
-
values={ billingFields }
|
| 122 |
-
fields={ Object.keys( defaultAddressFields ) }
|
| 123 |
-
fieldConfig={ addressFieldsConfig }
|
| 124 |
-
/>
|
| 125 |
-
{ showPhoneField && ! needsShipping && (
|
| 126 |
-
<PhoneNumber
|
| 127 |
-
isRequired={ requirePhoneField }
|
| 128 |
-
value={ billingFields.phone }
|
| 129 |
-
onChange={ ( value ) => {
|
| 130 |
-
setPhone( value );
|
| 131 |
-
dispatchCheckoutEvent( 'set-phone-number', {
|
| 132 |
-
step: 'billing',
|
| 133 |
-
} );
|
| 134 |
-
} }
|
| 135 |
-
/>
|
| 136 |
-
) }
|
| 137 |
-
</BillingFieldsStep>
|
| 138 |
-
) }
|
| 139 |
-
<ShippingOptionsStep />
|
| 140 |
-
<PaymentMethodStep />
|
| 141 |
-
{ showOrderNotes && <OrderNotesStep /> }
|
| 142 |
-
</Form>
|
| 143 |
-
);
|
| 144 |
-
};
|
| 145 |
-
|
| 146 |
-
CheckoutForm.propTypes = {
|
| 147 |
-
requireCompanyField: PropTypes.bool.isRequired,
|
| 148 |
-
requirePhoneField: PropTypes.bool.isRequired,
|
| 149 |
-
showApartmentField: PropTypes.bool.isRequired,
|
| 150 |
-
showCompanyField: PropTypes.bool.isRequired,
|
| 151 |
-
showOrderNotes: PropTypes.bool.isRequired,
|
| 152 |
-
showPhoneField: PropTypes.bool.isRequired,
|
| 153 |
-
allowCreateAccount: PropTypes.bool.isRequired,
|
| 154 |
-
};
|
| 155 |
-
|
| 156 |
-
export default CheckoutForm;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout/form/login-prompt.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { getSetting } from '@woocommerce/settings';
|
| 6 |
-
import { useCheckoutContext } from '@woocommerce/base-context';
|
| 7 |
-
|
| 8 |
-
/**
|
| 9 |
-
* Internal dependencies
|
| 10 |
-
*/
|
| 11 |
-
import { LOGIN_TO_CHECKOUT_URL } from '../utils';
|
| 12 |
-
|
| 13 |
-
const LoginPrompt = () => {
|
| 14 |
-
const { customerId } = useCheckoutContext();
|
| 15 |
-
|
| 16 |
-
if ( ! getSetting( 'checkoutShowLoginReminder', true ) || customerId ) {
|
| 17 |
-
return null;
|
| 18 |
-
}
|
| 19 |
-
|
| 20 |
-
return (
|
| 21 |
-
<>
|
| 22 |
-
{ __(
|
| 23 |
-
'Already have an account? ',
|
| 24 |
-
'woo-gutenberg-products-block'
|
| 25 |
-
) }
|
| 26 |
-
<a href={ LOGIN_TO_CHECKOUT_URL }>
|
| 27 |
-
{ __( 'Log in.', 'woo-gutenberg-products-block' ) }
|
| 28 |
-
</a>
|
| 29 |
-
</>
|
| 30 |
-
);
|
| 31 |
-
};
|
| 32 |
-
|
| 33 |
-
export default LoginPrompt;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout/form/no-shipping-placeholder/index.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { Placeholder, Button } from 'wordpress-components';
|
| 6 |
-
import { Icon, truck } from '@woocommerce/icons';
|
| 7 |
-
import { ADMIN_URL } from '@woocommerce/settings';
|
| 8 |
-
|
| 9 |
-
/**
|
| 10 |
-
* Internal dependencies
|
| 11 |
-
*/
|
| 12 |
-
import './style.scss';
|
| 13 |
-
|
| 14 |
-
const NoShippingPlaceholder = () => {
|
| 15 |
-
return (
|
| 16 |
-
<Placeholder
|
| 17 |
-
icon={ <Icon srcElement={ truck } /> }
|
| 18 |
-
label={ __( 'Shipping options', 'woo-gutenberg-products-block' ) }
|
| 19 |
-
className="wc-block-checkout__no-shipping-placeholder"
|
| 20 |
-
>
|
| 21 |
-
<span className="wc-block-checkout__no-shipping-placeholder-description">
|
| 22 |
-
{ __(
|
| 23 |
-
'Your store does not have any Shipping Options configured. Once you have added your Shipping Options they will appear here.',
|
| 24 |
-
'woo-gutenberg-products-block'
|
| 25 |
-
) }
|
| 26 |
-
</span>
|
| 27 |
-
<Button
|
| 28 |
-
isSecondary
|
| 29 |
-
href={ `${ ADMIN_URL }admin.php?page=wc-settings&tab=shipping` }
|
| 30 |
-
target="_blank"
|
| 31 |
-
rel="noopener noreferrer"
|
| 32 |
-
>
|
| 33 |
-
{ __(
|
| 34 |
-
'Configure Shipping Options',
|
| 35 |
-
'woo-gutenberg-products-block'
|
| 36 |
-
) }
|
| 37 |
-
</Button>
|
| 38 |
-
</Placeholder>
|
| 39 |
-
);
|
| 40 |
-
};
|
| 41 |
-
|
| 42 |
-
export default NoShippingPlaceholder;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout/form/no-shipping-placeholder/style.scss
DELETED
|
@@ -1,21 +0,0 @@
|
|
| 1 |
-
.components-placeholder.wc-block-checkout__no-shipping-placeholder {
|
| 2 |
-
margin-bottom: $gap;
|
| 3 |
-
|
| 4 |
-
* {
|
| 5 |
-
pointer-events: all; // Overrides parent disabled component in editor context
|
| 6 |
-
}
|
| 7 |
-
|
| 8 |
-
.components-placeholder__fieldset {
|
| 9 |
-
display: block;
|
| 10 |
-
|
| 11 |
-
.components-button {
|
| 12 |
-
background-color: $gray-900;
|
| 13 |
-
color: $white;
|
| 14 |
-
}
|
| 15 |
-
|
| 16 |
-
.wc-block-checkout__no-shipping-placeholder-description {
|
| 17 |
-
display: block;
|
| 18 |
-
margin: 0.25em 0 1em 0;
|
| 19 |
-
}
|
| 20 |
-
}
|
| 21 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout/form/order-notes-step.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { FormStep } from '@woocommerce/base-components/cart-checkout';
|
| 6 |
-
import {
|
| 7 |
-
useCheckoutContext,
|
| 8 |
-
useShippingDataContext,
|
| 9 |
-
} from '@woocommerce/base-context';
|
| 10 |
-
import { useCheckoutSubmit } from '@woocommerce/base-context/hooks';
|
| 11 |
-
|
| 12 |
-
/**
|
| 13 |
-
* Internal dependencies
|
| 14 |
-
*/
|
| 15 |
-
import CheckoutOrderNotes from './order-notes';
|
| 16 |
-
|
| 17 |
-
const OrderNotesStep = () => {
|
| 18 |
-
const { needsShipping } = useShippingDataContext();
|
| 19 |
-
const { orderNotes, dispatchActions } = useCheckoutContext();
|
| 20 |
-
const { isDisabled } = useCheckoutSubmit();
|
| 21 |
-
const { setOrderNotes } = dispatchActions;
|
| 22 |
-
|
| 23 |
-
return (
|
| 24 |
-
<FormStep
|
| 25 |
-
id="order-notes"
|
| 26 |
-
showStepNumber={ false }
|
| 27 |
-
className="wc-block-checkout__order-notes"
|
| 28 |
-
disabled={ isDisabled }
|
| 29 |
-
>
|
| 30 |
-
<CheckoutOrderNotes
|
| 31 |
-
onChange={ setOrderNotes }
|
| 32 |
-
disabled={ isDisabled }
|
| 33 |
-
placeholder={
|
| 34 |
-
needsShipping
|
| 35 |
-
? __(
|
| 36 |
-
'Notes about your order, e.g. special notes for delivery.',
|
| 37 |
-
'woo-gutenberg-products-block'
|
| 38 |
-
)
|
| 39 |
-
: __(
|
| 40 |
-
'Notes about your order.',
|
| 41 |
-
'woo-gutenberg-products-block'
|
| 42 |
-
)
|
| 43 |
-
}
|
| 44 |
-
value={ orderNotes }
|
| 45 |
-
/>
|
| 46 |
-
</FormStep>
|
| 47 |
-
);
|
| 48 |
-
};
|
| 49 |
-
|
| 50 |
-
export default OrderNotesStep;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout/form/payment-method-step.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { FormStep } from '@woocommerce/base-components/cart-checkout';
|
| 6 |
-
import { StoreNoticesProvider } from '@woocommerce/base-context';
|
| 7 |
-
import {
|
| 8 |
-
useStoreCart,
|
| 9 |
-
useEmitResponse,
|
| 10 |
-
usePaymentMethods,
|
| 11 |
-
useCheckoutSubmit,
|
| 12 |
-
} from '@woocommerce/base-context/hooks';
|
| 13 |
-
|
| 14 |
-
/**
|
| 15 |
-
* Internal dependencies
|
| 16 |
-
*/
|
| 17 |
-
import { PaymentMethods } from '../../payment-methods';
|
| 18 |
-
|
| 19 |
-
const PaymentMethodStep = () => {
|
| 20 |
-
const { isDisabled } = useCheckoutSubmit();
|
| 21 |
-
const { cartNeedsPayment } = useStoreCart();
|
| 22 |
-
const { paymentMethods } = usePaymentMethods();
|
| 23 |
-
const { noticeContexts } = useEmitResponse();
|
| 24 |
-
|
| 25 |
-
if ( ! cartNeedsPayment ) {
|
| 26 |
-
return null;
|
| 27 |
-
}
|
| 28 |
-
|
| 29 |
-
return (
|
| 30 |
-
<FormStep
|
| 31 |
-
id="payment-method"
|
| 32 |
-
disabled={ isDisabled }
|
| 33 |
-
className="wc-block-checkout__payment-method"
|
| 34 |
-
title={ __( 'Payment method', 'woo-gutenberg-products-block' ) }
|
| 35 |
-
description={
|
| 36 |
-
Object.keys( paymentMethods ).length > 1
|
| 37 |
-
? __(
|
| 38 |
-
'Select a payment method below.',
|
| 39 |
-
'woo-gutenberg-products-block'
|
| 40 |
-
)
|
| 41 |
-
: ''
|
| 42 |
-
}
|
| 43 |
-
>
|
| 44 |
-
<StoreNoticesProvider context={ noticeContexts.PAYMENTS }>
|
| 45 |
-
<PaymentMethods />
|
| 46 |
-
</StoreNoticesProvider>
|
| 47 |
-
</FormStep>
|
| 48 |
-
);
|
| 49 |
-
};
|
| 50 |
-
|
| 51 |
-
export default PaymentMethodStep;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout/form/phone-number/index.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { ValidatedTextInput } from '@woocommerce/base-components/text-input';
|
| 6 |
-
|
| 7 |
-
/**
|
| 8 |
-
* Renders a phone number input.
|
| 9 |
-
*
|
| 10 |
-
* @param {Object} props Component props.
|
| 11 |
-
* @param {boolean} props.isRequired Is the phone number required or optional.
|
| 12 |
-
* @param {Function} props.onChange Event fired when the input changes.
|
| 13 |
-
* @param {string} props.value Value of the input.
|
| 14 |
-
* @return {*} The component.
|
| 15 |
-
*/
|
| 16 |
-
const PhoneNumber = ( { isRequired = false, value = '', onChange } ) => {
|
| 17 |
-
return (
|
| 18 |
-
<ValidatedTextInput
|
| 19 |
-
id="phone"
|
| 20 |
-
type="tel"
|
| 21 |
-
autoComplete="tel"
|
| 22 |
-
required={ isRequired }
|
| 23 |
-
label={
|
| 24 |
-
isRequired
|
| 25 |
-
? __( 'Phone', 'woo-gutenberg-products-block' )
|
| 26 |
-
: __( 'Phone (optional)', 'woo-gutenberg-products-block' )
|
| 27 |
-
}
|
| 28 |
-
value={ value }
|
| 29 |
-
onChange={ onChange }
|
| 30 |
-
/>
|
| 31 |
-
);
|
| 32 |
-
};
|
| 33 |
-
|
| 34 |
-
export default PhoneNumber;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout/form/shipping-fields-step.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { FormStep } from '@woocommerce/base-components/cart-checkout';
|
| 6 |
-
import CheckboxControl from '@woocommerce/base-components/checkbox-control';
|
| 7 |
-
import { useCheckoutSubmit } from '@woocommerce/base-context/hooks';
|
| 8 |
-
import PropTypes from 'prop-types';
|
| 9 |
-
|
| 10 |
-
const ShippingFieldsStep = ( {
|
| 11 |
-
shippingAsBilling,
|
| 12 |
-
setShippingAsBilling,
|
| 13 |
-
children,
|
| 14 |
-
} ) => {
|
| 15 |
-
const { isDisabled } = useCheckoutSubmit();
|
| 16 |
-
|
| 17 |
-
return (
|
| 18 |
-
<FormStep
|
| 19 |
-
id="shipping-fields"
|
| 20 |
-
disabled={ isDisabled }
|
| 21 |
-
className="wc-block-checkout__shipping-fields"
|
| 22 |
-
title={ __( 'Shipping address', 'woo-gutenberg-products-block' ) }
|
| 23 |
-
description={ __(
|
| 24 |
-
'Enter the physical address where you want us to deliver your order.',
|
| 25 |
-
'woo-gutenberg-products-block'
|
| 26 |
-
) }
|
| 27 |
-
>
|
| 28 |
-
{ children }
|
| 29 |
-
<CheckboxControl
|
| 30 |
-
className="wc-block-checkout__use-address-for-billing"
|
| 31 |
-
label={ __(
|
| 32 |
-
'Use same address for billing',
|
| 33 |
-
'woo-gutenberg-products-block'
|
| 34 |
-
) }
|
| 35 |
-
checked={ shippingAsBilling }
|
| 36 |
-
onChange={ ( isChecked ) => setShippingAsBilling( isChecked ) }
|
| 37 |
-
/>
|
| 38 |
-
</FormStep>
|
| 39 |
-
);
|
| 40 |
-
};
|
| 41 |
-
|
| 42 |
-
ShippingFieldsStep.propTypes = {
|
| 43 |
-
shippingAsBilling: PropTypes.bool.isRequired,
|
| 44 |
-
setShippingAsBilling: PropTypes.func.isRequired,
|
| 45 |
-
children: PropTypes.node.isRequired,
|
| 46 |
-
};
|
| 47 |
-
|
| 48 |
-
export default ShippingFieldsStep;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout/form/shipping-options-step.tsx
DELETED
|
@@ -1,120 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import {
|
| 6 |
-
FormStep,
|
| 7 |
-
ShippingRatesControl,
|
| 8 |
-
} from '@woocommerce/base-components/cart-checkout';
|
| 9 |
-
import {
|
| 10 |
-
getShippingRatesPackageCount,
|
| 11 |
-
getShippingRatesRateCount,
|
| 12 |
-
} from '@woocommerce/base-utils';
|
| 13 |
-
import { getCurrencyFromPriceResponse } from '@woocommerce/price-format';
|
| 14 |
-
import FormattedMonetaryAmount from '@woocommerce/base-components/formatted-monetary-amount';
|
| 15 |
-
import {
|
| 16 |
-
useEditorContext,
|
| 17 |
-
useShippingDataContext,
|
| 18 |
-
} from '@woocommerce/base-context';
|
| 19 |
-
import { useCheckoutSubmit } from '@woocommerce/base-context/hooks';
|
| 20 |
-
import { decodeEntities } from '@wordpress/html-entities';
|
| 21 |
-
import { Notice } from 'wordpress-components';
|
| 22 |
-
import classnames from 'classnames';
|
| 23 |
-
import { getSetting } from '@woocommerce/settings';
|
| 24 |
-
import type { PackageRateOption } from '@woocommerce/type-defs/shipping';
|
| 25 |
-
import type { CartShippingPackageShippingRate } from '@woocommerce/type-defs/cart';
|
| 26 |
-
|
| 27 |
-
/**
|
| 28 |
-
* Internal dependencies
|
| 29 |
-
*/
|
| 30 |
-
import NoShippingPlaceholder from './no-shipping-placeholder';
|
| 31 |
-
|
| 32 |
-
/**
|
| 33 |
-
* Renders a shipping rate control option.
|
| 34 |
-
*
|
| 35 |
-
* @param {Object} option Shipping Rate.
|
| 36 |
-
*/
|
| 37 |
-
const renderShippingRatesControlOption = (
|
| 38 |
-
option: CartShippingPackageShippingRate
|
| 39 |
-
): PackageRateOption => {
|
| 40 |
-
const priceWithTaxes = getSetting( 'displayCartPricesIncludingTax', false )
|
| 41 |
-
? parseInt( option.price, 10 ) + parseInt( option.taxes, 10 )
|
| 42 |
-
: parseInt( option.price, 10 );
|
| 43 |
-
return {
|
| 44 |
-
label: decodeEntities( option.name ),
|
| 45 |
-
value: option.rate_id,
|
| 46 |
-
description: decodeEntities( option.description ),
|
| 47 |
-
secondaryLabel: (
|
| 48 |
-
<FormattedMonetaryAmount
|
| 49 |
-
currency={ getCurrencyFromPriceResponse( option ) }
|
| 50 |
-
value={ priceWithTaxes }
|
| 51 |
-
/>
|
| 52 |
-
),
|
| 53 |
-
secondaryDescription: decodeEntities( option.delivery_time ),
|
| 54 |
-
};
|
| 55 |
-
};
|
| 56 |
-
|
| 57 |
-
const ShippingOptionsStep = (): JSX.Element | null => {
|
| 58 |
-
const { isDisabled } = useCheckoutSubmit();
|
| 59 |
-
const { isEditor } = useEditorContext();
|
| 60 |
-
const {
|
| 61 |
-
shippingRates,
|
| 62 |
-
shippingRatesLoading,
|
| 63 |
-
needsShipping,
|
| 64 |
-
hasCalculatedShipping,
|
| 65 |
-
} = useShippingDataContext();
|
| 66 |
-
|
| 67 |
-
if ( ! needsShipping ) {
|
| 68 |
-
return null;
|
| 69 |
-
}
|
| 70 |
-
|
| 71 |
-
return (
|
| 72 |
-
<FormStep
|
| 73 |
-
id="shipping-option"
|
| 74 |
-
disabled={ isDisabled }
|
| 75 |
-
className="wc-block-checkout__shipping-option"
|
| 76 |
-
title={ __( 'Shipping options', 'woo-gutenberg-products-block' ) }
|
| 77 |
-
description={
|
| 78 |
-
getShippingRatesRateCount( shippingRates ) > 1
|
| 79 |
-
? __(
|
| 80 |
-
'Select shipping options below.',
|
| 81 |
-
'woo-gutenberg-products-block'
|
| 82 |
-
)
|
| 83 |
-
: ''
|
| 84 |
-
}
|
| 85 |
-
>
|
| 86 |
-
{ isEditor && ! getShippingRatesPackageCount( shippingRates ) ? (
|
| 87 |
-
<NoShippingPlaceholder />
|
| 88 |
-
) : (
|
| 89 |
-
<ShippingRatesControl
|
| 90 |
-
noResultsMessage={
|
| 91 |
-
hasCalculatedShipping ? (
|
| 92 |
-
<Notice
|
| 93 |
-
isDismissible={ false }
|
| 94 |
-
className={ classnames(
|
| 95 |
-
'wc-block-components-shipping-rates-control__no-results-notice',
|
| 96 |
-
'woocommerce-error'
|
| 97 |
-
) }
|
| 98 |
-
>
|
| 99 |
-
{ __(
|
| 100 |
-
'There are no shipping options available. Please ensure that your address has been entered correctly, or contact us if you need any help.',
|
| 101 |
-
'woo-gutenberg-products-block'
|
| 102 |
-
) }
|
| 103 |
-
</Notice>
|
| 104 |
-
) : (
|
| 105 |
-
__(
|
| 106 |
-
'Shipping options will appear here after entering your full shipping address.',
|
| 107 |
-
'woo-gutenberg-products-block'
|
| 108 |
-
)
|
| 109 |
-
)
|
| 110 |
-
}
|
| 111 |
-
renderOption={ renderShippingRatesControlOption }
|
| 112 |
-
shippingRates={ shippingRates }
|
| 113 |
-
shippingRatesLoading={ shippingRatesLoading }
|
| 114 |
-
/>
|
| 115 |
-
) }
|
| 116 |
-
</FormStep>
|
| 117 |
-
);
|
| 118 |
-
};
|
| 119 |
-
|
| 120 |
-
export default ShippingOptionsStep;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout/frontend.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import {
|
| 6 |
-
withStoreCartApiHydration,
|
| 7 |
-
withRestApiHydration,
|
| 8 |
-
} from '@woocommerce/block-hocs';
|
| 9 |
-
import { useStoreCart } from '@woocommerce/base-context/hooks';
|
| 10 |
-
import {
|
| 11 |
-
CheckoutProvider,
|
| 12 |
-
StoreNoticesProvider,
|
| 13 |
-
ValidationContextProvider,
|
| 14 |
-
} from '@woocommerce/base-context';
|
| 15 |
-
import BlockErrorBoundary from '@woocommerce/base-components/block-error-boundary';
|
| 16 |
-
import { CURRENT_USER_IS_ADMIN } from '@woocommerce/settings';
|
| 17 |
-
import {
|
| 18 |
-
renderFrontend,
|
| 19 |
-
getValidBlockAttributes,
|
| 20 |
-
} from '@woocommerce/base-utils';
|
| 21 |
-
import { StoreSnackbarNoticesProvider } from '@woocommerce/base-context/providers';
|
| 22 |
-
import { SlotFillProvider } from '@woocommerce/blocks-checkout';
|
| 23 |
-
|
| 24 |
-
/**
|
| 25 |
-
* Internal dependencies
|
| 26 |
-
*/
|
| 27 |
-
import Block from './block.js';
|
| 28 |
-
import blockAttributes from './attributes';
|
| 29 |
-
import EmptyCart from './empty-cart/index.js';
|
| 30 |
-
|
| 31 |
-
const reloadPage = () => void window.location.reload( true );
|
| 32 |
-
|
| 33 |
-
const errorBoundaryProps = {
|
| 34 |
-
header: __( 'Something went wrong…', 'woo-gutenberg-products-block' ),
|
| 35 |
-
text: __(
|
| 36 |
-
'The checkout has encountered an unexpected error. If the error persists, please get in touch with us for help.',
|
| 37 |
-
'woo-gutenberg-products-block'
|
| 38 |
-
),
|
| 39 |
-
showErrorMessage: CURRENT_USER_IS_ADMIN,
|
| 40 |
-
button: (
|
| 41 |
-
<button className="wc-block-button" onClick={ reloadPage }>
|
| 42 |
-
{ __( 'Reload the page', 'woo-gutenberg-products-block' ) }
|
| 43 |
-
</button>
|
| 44 |
-
),
|
| 45 |
-
};
|
| 46 |
-
|
| 47 |
-
/**
|
| 48 |
-
* Wrapper component for the checkout block.
|
| 49 |
-
*
|
| 50 |
-
* @param {Object} props Props for the block.
|
| 51 |
-
*/
|
| 52 |
-
const CheckoutFrontend = ( props ) => {
|
| 53 |
-
const { cartItems, cartIsLoading } = useStoreCart();
|
| 54 |
-
|
| 55 |
-
return (
|
| 56 |
-
<>
|
| 57 |
-
{ ! cartIsLoading && cartItems.length === 0 ? (
|
| 58 |
-
<EmptyCart />
|
| 59 |
-
) : (
|
| 60 |
-
<BlockErrorBoundary { ...errorBoundaryProps }>
|
| 61 |
-
<StoreSnackbarNoticesProvider context="wc/checkout">
|
| 62 |
-
<StoreNoticesProvider context="wc/checkout">
|
| 63 |
-
<ValidationContextProvider>
|
| 64 |
-
<SlotFillProvider>
|
| 65 |
-
<CheckoutProvider>
|
| 66 |
-
<Block { ...props } />
|
| 67 |
-
</CheckoutProvider>
|
| 68 |
-
</SlotFillProvider>
|
| 69 |
-
</ValidationContextProvider>
|
| 70 |
-
</StoreNoticesProvider>
|
| 71 |
-
</StoreSnackbarNoticesProvider>
|
| 72 |
-
</BlockErrorBoundary>
|
| 73 |
-
) }
|
| 74 |
-
</>
|
| 75 |
-
);
|
| 76 |
-
};
|
| 77 |
-
|
| 78 |
-
const getProps = ( el ) => {
|
| 79 |
-
return {
|
| 80 |
-
attributes: getValidBlockAttributes( blockAttributes, el.dataset ),
|
| 81 |
-
};
|
| 82 |
-
};
|
| 83 |
-
|
| 84 |
-
const getErrorBoundaryProps = () => {
|
| 85 |
-
return errorBoundaryProps;
|
| 86 |
-
};
|
| 87 |
-
|
| 88 |
-
renderFrontend( {
|
| 89 |
-
selector: '.wp-block-woocommerce-checkout',
|
| 90 |
-
Block: withStoreCartApiHydration(
|
| 91 |
-
withRestApiHydration( CheckoutFrontend )
|
| 92 |
-
),
|
| 93 |
-
getProps,
|
| 94 |
-
getErrorBoundaryProps,
|
| 95 |
-
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/frontend.tsx
RENAMED
|
@@ -59,7 +59,7 @@ const Wrapper = ( {
|
|
| 59 |
renderParentBlock( {
|
| 60 |
Block: withStoreCartApiHydration( withRestApiHydration( Block ) ),
|
| 61 |
blockName,
|
| 62 |
-
selector: '.wp-block-woocommerce-checkout
|
| 63 |
getProps,
|
| 64 |
blockMap: getRegisteredBlockComponents( blockName ) as Record<
|
| 65 |
string,
|
| 59 |
renderParentBlock( {
|
| 60 |
Block: withStoreCartApiHydration( withRestApiHydration( Block ) ),
|
| 61 |
blockName,
|
| 62 |
+
selector: '.wp-block-woocommerce-checkout',
|
| 63 |
getProps,
|
| 64 |
blockMap: getRegisteredBlockComponents( blockName ) as Record<
|
| 65 |
string,
|
assets/js/blocks/cart-checkout/checkout/hacks.ts
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* HACKS
|
| 3 |
+
*
|
| 4 |
+
* This file contains functionality to "lock" blocks i.e. to prevent blocks being moved or deleted. This needs to be
|
| 5 |
+
* kept in place until native support for locking is available in WordPress (estimated WordPress 5.9).
|
| 6 |
+
*/
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* @todo Remove custom block locking (requires native WordPress support)
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* External dependencies
|
| 14 |
+
*/
|
| 15 |
+
import {
|
| 16 |
+
useBlockProps,
|
| 17 |
+
store as blockEditorStore,
|
| 18 |
+
} from '@wordpress/block-editor';
|
| 19 |
+
import { isTextField } from '@wordpress/dom';
|
| 20 |
+
import { subscribe, select as _select } from '@wordpress/data';
|
| 21 |
+
import { useEffect, useRef } from '@wordpress/element';
|
| 22 |
+
import { MutableRefObject } from 'react';
|
| 23 |
+
import { BACKSPACE, DELETE } from '@wordpress/keycodes';
|
| 24 |
+
import { hasFilter } from '@wordpress/hooks';
|
| 25 |
+
import { getBlockType } from '@wordpress/blocks';
|
| 26 |
+
/**
|
| 27 |
+
* Toggle class on body.
|
| 28 |
+
*
|
| 29 |
+
* @param {string} className CSS Class name.
|
| 30 |
+
* @param {boolean} add True to add, false to remove.
|
| 31 |
+
*/
|
| 32 |
+
const toggleBodyClass = ( className: string, add = true ) => {
|
| 33 |
+
if ( add ) {
|
| 34 |
+
window.document.body.classList.add( className );
|
| 35 |
+
} else {
|
| 36 |
+
window.document.body.classList.remove( className );
|
| 37 |
+
}
|
| 38 |
+
};
|
| 39 |
+
|
| 40 |
+
/**
|
| 41 |
+
* addClassToBody
|
| 42 |
+
*
|
| 43 |
+
* This components watches the current selected block and adds a class name to the body if that block is locked. If the
|
| 44 |
+
* current block is not locked, it removes the class name. The appended body class is used to hide UI elements to prevent
|
| 45 |
+
* the block from being deleted.
|
| 46 |
+
*
|
| 47 |
+
* We use a component so we can react to changes in the store.
|
| 48 |
+
*/
|
| 49 |
+
export const addClassToBody = (): void => {
|
| 50 |
+
if ( ! hasFilter( 'blocks.registerBlockType', 'core/lock/addAttribute' ) ) {
|
| 51 |
+
subscribe( () => {
|
| 52 |
+
const blockEditorSelect = _select( blockEditorStore );
|
| 53 |
+
|
| 54 |
+
if ( ! blockEditorSelect ) {
|
| 55 |
+
return;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
const selectedBlock = blockEditorSelect.getSelectedBlock();
|
| 59 |
+
|
| 60 |
+
if ( ! selectedBlock ) {
|
| 61 |
+
return;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
toggleBodyClass(
|
| 65 |
+
'wc-lock-selected-block--remove',
|
| 66 |
+
!! selectedBlock?.attributes?.lock?.remove
|
| 67 |
+
);
|
| 68 |
+
|
| 69 |
+
toggleBodyClass(
|
| 70 |
+
'wc-lock-selected-block--move',
|
| 71 |
+
!! selectedBlock?.attributes?.lock?.move
|
| 72 |
+
);
|
| 73 |
+
} );
|
| 74 |
+
}
|
| 75 |
+
};
|
| 76 |
+
|
| 77 |
+
const isBlockLocked = ( clientId: string ): boolean => {
|
| 78 |
+
if ( ! clientId ) {
|
| 79 |
+
return false;
|
| 80 |
+
}
|
| 81 |
+
const { getBlock } = _select( blockEditorStore );
|
| 82 |
+
const block = getBlock( clientId );
|
| 83 |
+
// If lock.remove is defined at the block instance (not using the default value)
|
| 84 |
+
// Then we use it.
|
| 85 |
+
if ( typeof block?.attributes?.lock?.remove === 'boolean' ) {
|
| 86 |
+
return block.attributes.lock.remove;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
// If we don't have lock on the block instance, we check the type
|
| 90 |
+
const blockType = getBlockType( block.name );
|
| 91 |
+
if ( typeof blockType?.attributes?.lock?.default?.remove === 'boolean' ) {
|
| 92 |
+
return blockType?.attributes?.lock?.default?.remove;
|
| 93 |
+
}
|
| 94 |
+
// If nothing is defined, return false
|
| 95 |
+
return false;
|
| 96 |
+
};
|
| 97 |
+
|
| 98 |
+
/**
|
| 99 |
+
* This is a hook we use in conjunction with useBlockProps. Its goal is to check if of the block's children is locked and being deleted.
|
| 100 |
+
* It will stop the keydown event from propagating to stop it from being deleted via the keyboard.
|
| 101 |
+
*
|
| 102 |
+
*/
|
| 103 |
+
const useLockedChildren = ( {
|
| 104 |
+
ref,
|
| 105 |
+
}: {
|
| 106 |
+
ref: MutableRefObject< HTMLElement | undefined >;
|
| 107 |
+
} ): void => {
|
| 108 |
+
const lockInCore = hasFilter(
|
| 109 |
+
'blocks.registerBlockType',
|
| 110 |
+
'core/lock/addAttribute'
|
| 111 |
+
);
|
| 112 |
+
|
| 113 |
+
const node = ref.current;
|
| 114 |
+
return useEffect( () => {
|
| 115 |
+
if ( ! node || lockInCore ) {
|
| 116 |
+
return;
|
| 117 |
+
}
|
| 118 |
+
function onKeyDown( event: KeyboardEvent ) {
|
| 119 |
+
const { keyCode, target } = event;
|
| 120 |
+
|
| 121 |
+
if ( ! ( target instanceof HTMLElement ) ) {
|
| 122 |
+
return;
|
| 123 |
+
}
|
| 124 |
+
// We're not trying to delete something here.
|
| 125 |
+
if ( keyCode !== BACKSPACE && keyCode !== DELETE ) {
|
| 126 |
+
return;
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
// We're in a field, so we should let text be deleted.
|
| 130 |
+
if ( isTextField( target ) ) {
|
| 131 |
+
return;
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
// Typecast to fix issue with isTextField.
|
| 135 |
+
const targetNode = target as HTMLElement;
|
| 136 |
+
|
| 137 |
+
// Our target isn't a block.
|
| 138 |
+
if ( targetNode.dataset.block === undefined ) {
|
| 139 |
+
return;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
const clientId = targetNode.dataset.block;
|
| 143 |
+
const isLocked = isBlockLocked( clientId );
|
| 144 |
+
// Prevent the keyboard event from propogating if it supports locking.
|
| 145 |
+
if ( isLocked ) {
|
| 146 |
+
event.preventDefault();
|
| 147 |
+
event.stopPropagation();
|
| 148 |
+
event.stopImmediatePropagation();
|
| 149 |
+
}
|
| 150 |
+
}
|
| 151 |
+
node.addEventListener( 'keydown', onKeyDown, {
|
| 152 |
+
capture: true,
|
| 153 |
+
passive: false,
|
| 154 |
+
} );
|
| 155 |
+
|
| 156 |
+
return () => {
|
| 157 |
+
node.removeEventListener( 'keydown', onKeyDown, {
|
| 158 |
+
capture: true,
|
| 159 |
+
} );
|
| 160 |
+
};
|
| 161 |
+
}, [ node, lockInCore ] );
|
| 162 |
+
};
|
| 163 |
+
|
| 164 |
+
/**
|
| 165 |
+
* This hook is a light wrapper to useBlockProps, it wraps that hook plus useLockBlock to pass data between them.
|
| 166 |
+
*/
|
| 167 |
+
export const useBlockPropsWithLocking = (
|
| 168 |
+
props: Record< string, unknown > = {}
|
| 169 |
+
): Record< string, unknown > => {
|
| 170 |
+
const ref = useRef< HTMLElement >();
|
| 171 |
+
const blockProps = useBlockProps( { ref, ...props } );
|
| 172 |
+
useLockedChildren( {
|
| 173 |
+
ref,
|
| 174 |
+
} );
|
| 175 |
+
return blockProps;
|
| 176 |
+
};
|
assets/js/blocks/cart-checkout/checkout/index.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { Icon, card } from '@woocommerce/icons';
|
| 6 |
-
import classnames from 'classnames';
|
| 7 |
-
import {
|
| 8 |
-
registerFeaturePluginBlockType,
|
| 9 |
-
isExperimentalBuild,
|
| 10 |
-
} from '@woocommerce/block-settings';
|
| 11 |
-
import { createBlock } from '@wordpress/blocks';
|
| 12 |
-
|
| 13 |
-
/**
|
| 14 |
-
* Internal dependencies
|
| 15 |
-
*/
|
| 16 |
-
import edit from './edit';
|
| 17 |
-
import blockAttributes from './attributes';
|
| 18 |
-
import './editor.scss';
|
| 19 |
-
|
| 20 |
-
const transforms = isExperimentalBuild()
|
| 21 |
-
? {
|
| 22 |
-
transforms: {
|
| 23 |
-
from: [
|
| 24 |
-
{
|
| 25 |
-
type: 'block',
|
| 26 |
-
blocks: [ 'woocommerce/checkout' ],
|
| 27 |
-
transform: ( attributes ) => {
|
| 28 |
-
return createBlock( 'woocommerce/checkout', {
|
| 29 |
-
attributes,
|
| 30 |
-
} );
|
| 31 |
-
},
|
| 32 |
-
},
|
| 33 |
-
],
|
| 34 |
-
to: [
|
| 35 |
-
{
|
| 36 |
-
type: 'block',
|
| 37 |
-
blocks: [ 'woocommerce/checkout-i2' ],
|
| 38 |
-
transform: ( attributes ) => {
|
| 39 |
-
return createBlock(
|
| 40 |
-
'woocommerce/checkout-i2',
|
| 41 |
-
attributes
|
| 42 |
-
);
|
| 43 |
-
},
|
| 44 |
-
},
|
| 45 |
-
],
|
| 46 |
-
},
|
| 47 |
-
}
|
| 48 |
-
: {};
|
| 49 |
-
|
| 50 |
-
const settings = {
|
| 51 |
-
title: __( 'Checkout', 'woo-gutenberg-products-block' ),
|
| 52 |
-
icon: {
|
| 53 |
-
src: <Icon srcElement={ card } />,
|
| 54 |
-
foreground: '#96588a',
|
| 55 |
-
},
|
| 56 |
-
category: 'woocommerce',
|
| 57 |
-
keywords: [ __( 'WooCommerce', 'woo-gutenberg-products-block' ) ],
|
| 58 |
-
description: __(
|
| 59 |
-
'Display a checkout form so your customers can submit orders.',
|
| 60 |
-
'woo-gutenberg-products-block'
|
| 61 |
-
),
|
| 62 |
-
supports: {
|
| 63 |
-
align: [ 'wide', 'full' ],
|
| 64 |
-
html: false,
|
| 65 |
-
multiple: false,
|
| 66 |
-
},
|
| 67 |
-
example: {
|
| 68 |
-
attributes: {
|
| 69 |
-
isPreview: true,
|
| 70 |
-
},
|
| 71 |
-
},
|
| 72 |
-
attributes: blockAttributes,
|
| 73 |
-
edit,
|
| 74 |
-
|
| 75 |
-
//Save the props to post content.
|
| 76 |
-
save( { attributes } ) {
|
| 77 |
-
return (
|
| 78 |
-
<div
|
| 79 |
-
className={ classnames( 'is-loading', attributes.className ) }
|
| 80 |
-
/>
|
| 81 |
-
);
|
| 82 |
-
},
|
| 83 |
-
...transforms,
|
| 84 |
-
};
|
| 85 |
-
|
| 86 |
-
registerFeaturePluginBlockType( 'woocommerce/checkout', settings );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/index.tsx
RENAMED
|
@@ -2,9 +2,9 @@
|
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import { __ } from '@wordpress/i18n';
|
|
|
|
| 5 |
import { Icon, fields } from '@woocommerce/icons';
|
| 6 |
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
| 7 |
-
import { createBlock } from '@wordpress/blocks';
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Internal dependencies
|
|
@@ -14,7 +14,7 @@ import { blockName, blockAttributes } from './attributes';
|
|
| 14 |
import './inner-blocks';
|
| 15 |
|
| 16 |
const settings = {
|
| 17 |
-
title: __( 'Checkout
|
| 18 |
icon: {
|
| 19 |
src: <Icon srcElement={ fields } />,
|
| 20 |
foreground: '#874FB9',
|
|
@@ -34,28 +34,22 @@ const settings = {
|
|
| 34 |
apiVersion: 2,
|
| 35 |
edit: Edit,
|
| 36 |
save: Save,
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
| 47 |
},
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
{
|
| 51 |
-
type: 'block',
|
| 52 |
-
blocks: [ 'woocommerce/checkout-i2' ],
|
| 53 |
-
transform: ( attributes ) => {
|
| 54 |
-
return createBlock( 'woocommerce/checkout-i2', attributes );
|
| 55 |
-
},
|
| 56 |
-
},
|
| 57 |
-
],
|
| 58 |
-
},
|
| 59 |
};
|
| 60 |
|
| 61 |
registerFeaturePluginBlockType( blockName, settings );
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import { __ } from '@wordpress/i18n';
|
| 5 |
+
import classnames from 'classnames';
|
| 6 |
import { Icon, fields } from '@woocommerce/icons';
|
| 7 |
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
|
|
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Internal dependencies
|
| 14 |
import './inner-blocks';
|
| 15 |
|
| 16 |
const settings = {
|
| 17 |
+
title: __( 'Checkout', 'woo-gutenberg-products-block' ),
|
| 18 |
icon: {
|
| 19 |
src: <Icon srcElement={ fields } />,
|
| 20 |
foreground: '#874FB9',
|
| 34 |
apiVersion: 2,
|
| 35 |
edit: Edit,
|
| 36 |
save: Save,
|
| 37 |
+
// Migrates v1 to v2 checkout.
|
| 38 |
+
deprecated: [
|
| 39 |
+
{
|
| 40 |
+
attributes: blockAttributes,
|
| 41 |
+
save( { attributes }: { attributes: { className: string } } ) {
|
| 42 |
+
return (
|
| 43 |
+
<div
|
| 44 |
+
className={ classnames(
|
| 45 |
+
'is-loading',
|
| 46 |
+
attributes.className
|
| 47 |
+
) }
|
| 48 |
+
/>
|
| 49 |
+
);
|
| 50 |
},
|
| 51 |
+
},
|
| 52 |
+
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
};
|
| 54 |
|
| 55 |
registerFeaturePluginBlockType( blockName, settings );
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-actions-block/attributes.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-actions-block/block.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "woocommerce/checkout-actions-block",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"title": "Actions",
|
| 5 |
+
"description": "Allow customers to place their order.",
|
| 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/checkout-fields-block" ],
|
| 24 |
+
"textdomain": "woo-gutenberg-products-block",
|
| 25 |
+
"apiVersion": 2
|
| 26 |
+
}
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-actions-block/block.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-actions-block/edit.tsx
RENAMED
|
@@ -12,7 +12,7 @@ import { CHECKOUT_PAGE_ID } from '@woocommerce/block-settings';
|
|
| 12 |
* Internal dependencies
|
| 13 |
*/
|
| 14 |
import Block from './block';
|
| 15 |
-
|
| 16 |
export const Edit = ( {
|
| 17 |
attributes,
|
| 18 |
setAttributes,
|
|
@@ -23,7 +23,7 @@ export const Edit = ( {
|
|
| 23 |
};
|
| 24 |
setAttributes: ( attributes: Record< string, unknown > ) => void;
|
| 25 |
} ): JSX.Element => {
|
| 26 |
-
const blockProps =
|
| 27 |
const { cartPageId = 0, showReturnToCart = true } = attributes;
|
| 28 |
const { current: savedCartPageId } = useRef( cartPageId );
|
| 29 |
const currentPostId = useSelect(
|
| 12 |
* Internal dependencies
|
| 13 |
*/
|
| 14 |
import Block from './block';
|
| 15 |
+
|
| 16 |
export const Edit = ( {
|
| 17 |
attributes,
|
| 18 |
setAttributes,
|
| 23 |
};
|
| 24 |
setAttributes: ( attributes: Record< string, unknown > ) => void;
|
| 25 |
} ): JSX.Element => {
|
| 26 |
+
const blockProps = useBlockProps();
|
| 27 |
const { cartPageId = 0, showReturnToCart = true } = attributes;
|
| 28 |
const { current: savedCartPageId } = useRef( cartPageId );
|
| 29 |
const currentPostId = useSelect(
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-actions-block/frontend.tsx
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import withFilteredAttributes from '@woocommerce/base-hocs/with-filtered-attributes';
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* Internal dependencies
|
| 8 |
+
*/
|
| 9 |
+
import Block from './block';
|
| 10 |
+
import attributes from './attributes';
|
| 11 |
+
|
| 12 |
+
export default withFilteredAttributes( attributes )( Block );
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-actions-block/index.tsx
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { Icon, button } from '@wordpress/icons';
|
| 5 |
+
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
| 6 |
+
|
| 7 |
+
/**
|
| 8 |
+
* Internal dependencies
|
| 9 |
+
*/
|
| 10 |
+
import attributes from './attributes';
|
| 11 |
+
import { Edit, Save } from './edit';
|
| 12 |
+
import metadata from './block.json';
|
| 13 |
+
|
| 14 |
+
registerFeaturePluginBlockType( metadata, {
|
| 15 |
+
icon: {
|
| 16 |
+
src: <Icon icon={ button } />,
|
| 17 |
+
foreground: '#874FB9',
|
| 18 |
+
},
|
| 19 |
+
attributes,
|
| 20 |
+
edit: Edit,
|
| 21 |
+
save: Save,
|
| 22 |
+
} );
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-actions-block/style.scss
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-billing-address-block/attributes.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-billing-address-block/block.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "woocommerce/checkout-billing-address-block",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"title": "Billing Address",
|
| 5 |
+
"description": "Collect your customer's billing address.",
|
| 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/checkout-fields-block" ],
|
| 24 |
+
"textdomain": "woo-gutenberg-products-block",
|
| 25 |
+
"apiVersion": 2
|
| 26 |
+
}
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-billing-address-block/block.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-billing-address-block/edit.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-billing-address-block/frontend.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-billing-address-block/index.tsx
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { Icon, address } from '@woocommerce/icons';
|
| 5 |
+
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
| 6 |
+
|
| 7 |
+
/**
|
| 8 |
+
* Internal dependencies
|
| 9 |
+
*/
|
| 10 |
+
import { Edit, Save } from './edit';
|
| 11 |
+
import attributes from './attributes';
|
| 12 |
+
import metadata from './block.json';
|
| 13 |
+
|
| 14 |
+
registerFeaturePluginBlockType( metadata, {
|
| 15 |
+
icon: {
|
| 16 |
+
src: <Icon srcElement={ address } />,
|
| 17 |
+
foreground: '#874FB9',
|
| 18 |
+
},
|
| 19 |
+
attributes,
|
| 20 |
+
edit: Edit,
|
| 21 |
+
save: Save,
|
| 22 |
+
} );
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-contact-information-block/attributes.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-contact-information-block/block.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "woocommerce/checkout-contact-information-block",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"title": "Contact Information",
|
| 5 |
+
"description": "Collect your customer's contact information.",
|
| 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/checkout-fields-block" ],
|
| 24 |
+
"textdomain": "woo-gutenberg-products-block",
|
| 25 |
+
"apiVersion": 2
|
| 26 |
+
}
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-contact-information-block/block.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-contact-information-block/edit.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-contact-information-block/frontend.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-contact-information-block/index.tsx
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { Icon, contact } from '@woocommerce/icons';
|
| 5 |
+
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
| 6 |
+
|
| 7 |
+
/**
|
| 8 |
+
* Internal dependencies
|
| 9 |
+
*/
|
| 10 |
+
import { Edit, Save } from './edit';
|
| 11 |
+
import attributes from './attributes';
|
| 12 |
+
import metadata from './block.json';
|
| 13 |
+
|
| 14 |
+
registerFeaturePluginBlockType( metadata, {
|
| 15 |
+
icon: {
|
| 16 |
+
src: <Icon srcElement={ contact } />,
|
| 17 |
+
foreground: '#874FB9',
|
| 18 |
+
},
|
| 19 |
+
attributes,
|
| 20 |
+
edit: Edit,
|
| 21 |
+
save: Save,
|
| 22 |
+
} );
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-contact-information-block/login-prompt.js
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-express-payment-block/block.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "woocommerce/checkout-express-payment-block",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"title": "Express Checkout",
|
| 5 |
+
"description": "Provide an express payment option for your customers.",
|
| 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/checkout-fields-block" ],
|
| 24 |
+
"textdomain": "woo-gutenberg-products-block",
|
| 25 |
+
"apiVersion": 2
|
| 26 |
+
}
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-express-payment-block/block.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-express-payment-block/edit.tsx
RENAMED
|
@@ -14,7 +14,6 @@ import classnames from 'classnames';
|
|
| 14 |
*/
|
| 15 |
import Block from './block';
|
| 16 |
import './editor.scss';
|
| 17 |
-
import { useBlockPropsWithLocking } from '../../hacks';
|
| 18 |
|
| 19 |
/**
|
| 20 |
* Renders a placeholder in the editor.
|
|
@@ -60,7 +59,7 @@ export const Edit = ( {
|
|
| 60 |
} ): JSX.Element | null => {
|
| 61 |
const { paymentMethods, isInitialized } = useExpressPaymentMethods();
|
| 62 |
const hasExpressPaymentMethods = Object.keys( paymentMethods ).length > 0;
|
| 63 |
-
const blockProps =
|
| 64 |
className: classnames( {
|
| 65 |
'wp-block-woocommerce-checkout-express-payment-block--has-express-payment-methods': hasExpressPaymentMethods,
|
| 66 |
} ),
|
| 14 |
*/
|
| 15 |
import Block from './block';
|
| 16 |
import './editor.scss';
|
|
|
|
| 17 |
|
| 18 |
/**
|
| 19 |
* Renders a placeholder in the editor.
|
| 59 |
} ): JSX.Element | null => {
|
| 60 |
const { paymentMethods, isInitialized } = useExpressPaymentMethods();
|
| 61 |
const hasExpressPaymentMethods = Object.keys( paymentMethods ).length > 0;
|
| 62 |
+
const blockProps = useBlockProps( {
|
| 63 |
className: classnames( {
|
| 64 |
'wp-block-woocommerce-checkout-express-payment-block--has-express-payment-methods': hasExpressPaymentMethods,
|
| 65 |
} ),
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-express-payment-block/editor.scss
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-express-payment-block/index.tsx
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { Icon, card } 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: <Icon srcElement={ card } />,
|
| 16 |
+
foreground: '#874FB9',
|
| 17 |
+
},
|
| 18 |
+
edit: Edit,
|
| 19 |
+
save: Save,
|
| 20 |
+
} );
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/block.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "woocommerce/checkout-fields-block",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"title": "Checkout Fields",
|
| 5 |
+
"description": "Column containing checkout address fields.",
|
| 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/checkout" ],
|
| 24 |
+
"textdomain": "woo-gutenberg-products-block",
|
| 25 |
+
"apiVersion": 2
|
| 26 |
+
}
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-fields-block/edit.tsx
RENAMED
|
@@ -11,6 +11,7 @@ import { innerBlockAreas } from '@woocommerce/blocks-checkout';
|
|
| 11 |
import { useCheckoutBlockControlsContext } from '../../context';
|
| 12 |
import { useForcedLayout } from '../../use-forced-layout';
|
| 13 |
import { getAllowedBlocks } from '../../editor-utils';
|
|
|
|
| 14 |
|
| 15 |
export const Edit = ( { clientId }: { clientId: string } ): JSX.Element => {
|
| 16 |
const blockProps = useBlockProps();
|
| 11 |
import { useCheckoutBlockControlsContext } from '../../context';
|
| 12 |
import { useForcedLayout } from '../../use-forced-layout';
|
| 13 |
import { getAllowedBlocks } from '../../editor-utils';
|
| 14 |
+
import './style.scss';
|
| 15 |
|
| 16 |
export const Edit = ( { clientId }: { clientId: string } ): JSX.Element => {
|
| 17 |
const blockProps = useBlockProps();
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-fields-block/frontend.tsx
RENAMED
|
@@ -3,6 +3,11 @@
|
|
| 3 |
*/
|
| 4 |
import { Main } from '@woocommerce/base-components/sidebar-layout';
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
const FrontendBlock = ( {
|
| 7 |
children,
|
| 8 |
}: {
|
| 3 |
*/
|
| 4 |
import { Main } from '@woocommerce/base-components/sidebar-layout';
|
| 5 |
|
| 6 |
+
/**
|
| 7 |
+
* Internal dependencies
|
| 8 |
+
*/
|
| 9 |
+
import './style.scss';
|
| 10 |
+
|
| 11 |
const FrontendBlock = ( {
|
| 12 |
children,
|
| 13 |
}: {
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/index.tsx
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { Icon, column } from '@wordpress/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: <Icon icon={ column } />,
|
| 16 |
+
foreground: '#874FB9',
|
| 17 |
+
},
|
| 18 |
+
edit: Edit,
|
| 19 |
+
save: Save,
|
| 20 |
+
} );
|
assets/js/blocks/cart-checkout/checkout/{form → inner-blocks/checkout-fields-block}/style.scss
RENAMED
|
@@ -2,28 +2,18 @@
|
|
| 2 |
margin: 0;
|
| 3 |
max-width: 100%;
|
| 4 |
}
|
| 5 |
-
.
|
| 6 |
-
.
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
.wc-block-checkout__shipping-option {
|
| 11 |
-
.wc-block-components-radio-control__option {
|
| 12 |
-
@include with-translucent-border( 0 0 1px );
|
| 13 |
-
margin: 0;
|
| 14 |
-
padding: em($gap-small) 0 em($gap-small) em($gap-largest);
|
| 15 |
-
}
|
| 16 |
-
|
| 17 |
-
.wc-block-components-shipping-rates-control__no-results-notice {
|
| 18 |
-
margin: em($gap-small) 0;
|
| 19 |
}
|
| 20 |
}
|
| 21 |
-
|
| 22 |
.is-small,
|
| 23 |
.is-medium,
|
| 24 |
.is-large {
|
| 25 |
-
.wc-block-
|
| 26 |
-
.wc-block-
|
| 27 |
.wc-block-components-address-form {
|
| 28 |
margin-left: #{-$gap-small * 0.5};
|
| 29 |
margin-right: #{-$gap-small * 0.5};
|
|
@@ -58,7 +48,6 @@
|
|
| 58 |
.wc-block-components-checkbox {
|
| 59 |
clear: both;
|
| 60 |
}
|
| 61 |
-
|
| 62 |
}
|
| 63 |
}
|
| 64 |
}
|
| 2 |
margin: 0;
|
| 3 |
max-width: 100%;
|
| 4 |
}
|
| 5 |
+
.is-mobile,
|
| 6 |
+
.is-small,
|
| 7 |
+
.is-medium {
|
| 8 |
+
.wc-block-checkout__main {
|
| 9 |
+
order: 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
}
|
| 11 |
}
|
|
|
|
| 12 |
.is-small,
|
| 13 |
.is-medium,
|
| 14 |
.is-large {
|
| 15 |
+
.wc-block-checkout__shipping-fields,
|
| 16 |
+
.wc-block-checkout__billing-fields {
|
| 17 |
.wc-block-components-address-form {
|
| 18 |
margin-left: #{-$gap-small * 0.5};
|
| 19 |
margin-right: #{-$gap-small * 0.5};
|
| 48 |
.wc-block-components-checkbox {
|
| 49 |
clear: both;
|
| 50 |
}
|
|
|
|
| 51 |
}
|
| 52 |
}
|
| 53 |
}
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/block.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "woocommerce/checkout-order-note-block",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"title": "Order Note",
|
| 5 |
+
"description": "Allow customers to add a note to their order.",
|
| 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/checkout-fields-block" ],
|
| 24 |
+
"textdomain": "woo-gutenberg-products-block",
|
| 25 |
+
"apiVersion": 2
|
| 26 |
+
}
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-order-note-block/block.tsx
RENAMED
|
@@ -11,7 +11,7 @@ import {
|
|
| 11 |
/**
|
| 12 |
* Internal dependencies
|
| 13 |
*/
|
| 14 |
-
import CheckoutOrderNotes from '
|
| 15 |
|
| 16 |
const Block = (): JSX.Element => {
|
| 17 |
const { needsShipping } = useShippingDataContext();
|
| 11 |
/**
|
| 12 |
* Internal dependencies
|
| 13 |
*/
|
| 14 |
+
import CheckoutOrderNotes from '../../order-notes';
|
| 15 |
|
| 16 |
const Block = (): JSX.Element => {
|
| 17 |
const { needsShipping } = useShippingDataContext();
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-order-note-block/edit.tsx
RENAMED
|
@@ -9,19 +9,9 @@ import { Disabled } from '@wordpress/components';
|
|
| 9 |
*/
|
| 10 |
import Block from './block';
|
| 11 |
import './editor.scss';
|
| 12 |
-
import { useBlockPropsWithLocking } from '../../hacks';
|
| 13 |
|
| 14 |
-
export const Edit = ( {
|
| 15 |
-
|
| 16 |
-
}: {
|
| 17 |
-
attributes: {
|
| 18 |
-
lock: {
|
| 19 |
-
move: boolean;
|
| 20 |
-
remove: boolean;
|
| 21 |
-
};
|
| 22 |
-
};
|
| 23 |
-
} ): JSX.Element => {
|
| 24 |
-
const blockProps = useBlockPropsWithLocking( { attributes } );
|
| 25 |
return (
|
| 26 |
<div { ...blockProps }>
|
| 27 |
<Disabled>
|
| 9 |
*/
|
| 10 |
import Block from './block';
|
| 11 |
import './editor.scss';
|
|
|
|
| 12 |
|
| 13 |
+
export const Edit = (): JSX.Element => {
|
| 14 |
+
const blockProps = useBlockProps();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
return (
|
| 16 |
<div { ...blockProps }>
|
| 17 |
<Disabled>
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-order-note-block/editor.scss
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/index.tsx
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { Icon, notes } 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: <Icon srcElement={ notes } />,
|
| 16 |
+
foreground: '#874FB9',
|
| 17 |
+
},
|
| 18 |
+
edit: Edit,
|
| 19 |
+
save: Save,
|
| 20 |
+
} );
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/attributes.tsx
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { getSetting } from '@woocommerce/settings';
|
| 5 |
+
|
| 6 |
+
export default {
|
| 7 |
+
showRateAfterTaxName: {
|
| 8 |
+
type: 'boolean',
|
| 9 |
+
default: getSetting( 'displayCartPricesIncludingTax', false ),
|
| 10 |
+
},
|
| 11 |
+
lock: {
|
| 12 |
+
type: 'object',
|
| 13 |
+
default: {
|
| 14 |
+
move: true,
|
| 15 |
+
remove: true,
|
| 16 |
+
},
|
| 17 |
+
},
|
| 18 |
+
};
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/block.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "woocommerce/checkout-order-summary-block",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"title": "Order Summary",
|
| 5 |
+
"description": "Show customers a summary of their order.",
|
| 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 |
+
}
|
| 20 |
+
}
|
| 21 |
+
},
|
| 22 |
+
"parent": [ "woocommerce/checkout-totals-block" ],
|
| 23 |
+
"textdomain": "woo-gutenberg-products-block",
|
| 24 |
+
"apiVersion": 2
|
| 25 |
+
}
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-order-summary-block/block.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-order-summary-block/edit.tsx
RENAMED
|
@@ -10,7 +10,6 @@ import { getSetting } from '@woocommerce/settings';
|
|
| 10 |
* Internal dependencies
|
| 11 |
*/
|
| 12 |
import Block from './block';
|
| 13 |
-
import { useBlockPropsWithLocking } from '../../hacks';
|
| 14 |
|
| 15 |
export const Edit = ( {
|
| 16 |
attributes,
|
|
@@ -25,7 +24,7 @@ export const Edit = ( {
|
|
| 25 |
};
|
| 26 |
setAttributes: ( attributes: Record< string, unknown > ) => void;
|
| 27 |
} ): JSX.Element => {
|
| 28 |
-
const blockProps =
|
| 29 |
const taxesEnabled = getSetting( 'taxesEnabled' ) as boolean;
|
| 30 |
const displayItemizedTaxes = getSetting(
|
| 31 |
'displayItemizedTaxes',
|
| 10 |
* Internal dependencies
|
| 11 |
*/
|
| 12 |
import Block from './block';
|
|
|
|
| 13 |
|
| 14 |
export const Edit = ( {
|
| 15 |
attributes,
|
| 24 |
};
|
| 25 |
setAttributes: ( attributes: Record< string, unknown > ) => void;
|
| 26 |
} ): JSX.Element => {
|
| 27 |
+
const blockProps = useBlockProps();
|
| 28 |
const taxesEnabled = getSetting( 'taxesEnabled' ) as boolean;
|
| 29 |
const displayItemizedTaxes = getSetting(
|
| 30 |
'displayItemizedTaxes',
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/index.tsx
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { Icon, totals } from '@woocommerce/icons';
|
| 5 |
+
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
| 6 |
+
|
| 7 |
+
/**
|
| 8 |
+
* Internal dependencies
|
| 9 |
+
*/
|
| 10 |
+
import { Edit, Save } from './edit';
|
| 11 |
+
import attributes from './attributes';
|
| 12 |
+
import metadata from './block.json';
|
| 13 |
+
|
| 14 |
+
registerFeaturePluginBlockType( metadata, {
|
| 15 |
+
icon: {
|
| 16 |
+
src: <Icon srcElement={ totals } />,
|
| 17 |
+
foreground: '#874FB9',
|
| 18 |
+
},
|
| 19 |
+
attributes,
|
| 20 |
+
edit: Edit,
|
| 21 |
+
save: Save,
|
| 22 |
+
} );
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-payment-block/attributes.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/block.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "woocommerce/checkout-payment-block",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"title": "Payment Options",
|
| 5 |
+
"description": "Payment options for your store.",
|
| 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/checkout-fields-block" ],
|
| 24 |
+
"textdomain": "woo-gutenberg-products-block",
|
| 25 |
+
"apiVersion": 2
|
| 26 |
+
}
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-payment-block/block.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-payment-block/edit.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-payment-block/frontend.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/index.tsx
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { Icon, card } from '@woocommerce/icons';
|
| 5 |
+
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
| 6 |
+
|
| 7 |
+
/**
|
| 8 |
+
* Internal dependencies
|
| 9 |
+
*/
|
| 10 |
+
import { Edit, Save } from './edit';
|
| 11 |
+
import attributes from './attributes';
|
| 12 |
+
import metadata from './block.json';
|
| 13 |
+
|
| 14 |
+
registerFeaturePluginBlockType( metadata, {
|
| 15 |
+
icon: {
|
| 16 |
+
src: <Icon srcElement={ card } />,
|
| 17 |
+
foreground: '#874FB9',
|
| 18 |
+
},
|
| 19 |
+
attributes,
|
| 20 |
+
edit: Edit,
|
| 21 |
+
save: Save,
|
| 22 |
+
} );
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-shipping-address-block/attributes.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/block.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "woocommerce/checkout-shipping-address-block",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"title": "Shipping Address",
|
| 5 |
+
"description": "Collect your customer's shipping address.",
|
| 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/checkout-fields-block" ],
|
| 24 |
+
"textdomain": "woo-gutenberg-products-block",
|
| 25 |
+
"apiVersion": 2
|
| 26 |
+
}
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-shipping-address-block/block.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-shipping-address-block/edit.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-shipping-address-block/frontend.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/index.tsx
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { Icon, address } from '@woocommerce/icons';
|
| 5 |
+
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
| 6 |
+
|
| 7 |
+
/**
|
| 8 |
+
* Internal dependencies
|
| 9 |
+
*/
|
| 10 |
+
import { Edit, Save } from './edit';
|
| 11 |
+
import attributes from './attributes';
|
| 12 |
+
import metadata from './block.json';
|
| 13 |
+
|
| 14 |
+
registerFeaturePluginBlockType( metadata, {
|
| 15 |
+
icon: {
|
| 16 |
+
src: <Icon srcElement={ address } />,
|
| 17 |
+
foreground: '#874FB9',
|
| 18 |
+
},
|
| 19 |
+
attributes,
|
| 20 |
+
edit: Edit,
|
| 21 |
+
save: Save,
|
| 22 |
+
} );
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-shipping-methods-block/attributes.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/block.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "woocommerce/checkout-shipping-methods-block",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"title": "Shipping Options",
|
| 5 |
+
"description": "Shipping options for your store.",
|
| 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/checkout-fields-block" ],
|
| 24 |
+
"textdomain": "woo-gutenberg-products-block",
|
| 25 |
+
"apiVersion": 2
|
| 26 |
+
}
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-shipping-methods-block/block.tsx
RENAMED
|
@@ -21,6 +21,7 @@ import type { CartShippingPackageShippingRate } from '@woocommerce/type-defs/car
|
|
| 21 |
* Internal dependencies
|
| 22 |
*/
|
| 23 |
import NoShippingPlaceholder from './no-shipping-placeholder';
|
|
|
|
| 24 |
|
| 25 |
/**
|
| 26 |
* Renders a shipping rate control option.
|
|
@@ -60,32 +61,44 @@ const Block = (): JSX.Element | null => {
|
|
| 60 |
return null;
|
| 61 |
}
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
return (
|
| 64 |
<>
|
| 65 |
-
{ isEditor && !
|
| 66 |
<NoShippingPlaceholder />
|
| 67 |
) : (
|
| 68 |
<ShippingRatesControl
|
| 69 |
noResultsMessage={
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
'There are no shipping options available. Please ensure that your address has been entered correctly, or contact us if you need any help.',
|
| 80 |
-
'woo-gutenberg-products-block'
|
| 81 |
-
) }
|
| 82 |
-
</Notice>
|
| 83 |
-
) : (
|
| 84 |
-
__(
|
| 85 |
-
'Shipping options will appear here after entering your full shipping address.',
|
| 86 |
'woo-gutenberg-products-block'
|
| 87 |
-
)
|
| 88 |
-
|
| 89 |
}
|
| 90 |
renderOption={ renderShippingRatesControlOption }
|
| 91 |
shippingRates={ shippingRates }
|
| 21 |
* Internal dependencies
|
| 22 |
*/
|
| 23 |
import NoShippingPlaceholder from './no-shipping-placeholder';
|
| 24 |
+
import './style.scss';
|
| 25 |
|
| 26 |
/**
|
| 27 |
* Renders a shipping rate control option.
|
| 61 |
return null;
|
| 62 |
}
|
| 63 |
|
| 64 |
+
const shippingRatesPackageCount = getShippingRatesPackageCount(
|
| 65 |
+
shippingRates
|
| 66 |
+
);
|
| 67 |
+
|
| 68 |
+
if (
|
| 69 |
+
! isEditor &&
|
| 70 |
+
! hasCalculatedShipping &&
|
| 71 |
+
! shippingRatesPackageCount
|
| 72 |
+
) {
|
| 73 |
+
return (
|
| 74 |
+
<p>
|
| 75 |
+
{ __(
|
| 76 |
+
'Shipping options will be displayed here after entering your full shipping address.',
|
| 77 |
+
'woo-gutenberg-products-block'
|
| 78 |
+
) }
|
| 79 |
+
</p>
|
| 80 |
+
);
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
return (
|
| 84 |
<>
|
| 85 |
+
{ isEditor && ! shippingRatesPackageCount ? (
|
| 86 |
<NoShippingPlaceholder />
|
| 87 |
) : (
|
| 88 |
<ShippingRatesControl
|
| 89 |
noResultsMessage={
|
| 90 |
+
<Notice
|
| 91 |
+
isDismissible={ false }
|
| 92 |
+
className={ classnames(
|
| 93 |
+
'wc-block-components-shipping-rates-control__no-results-notice',
|
| 94 |
+
'woocommerce-error'
|
| 95 |
+
) }
|
| 96 |
+
>
|
| 97 |
+
{ __(
|
| 98 |
+
'There are no shipping options available. Please check your shipping address.',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
'woo-gutenberg-products-block'
|
| 100 |
+
) }
|
| 101 |
+
</Notice>
|
| 102 |
}
|
| 103 |
renderOption={ renderShippingRatesControlOption }
|
| 104 |
shippingRates={ shippingRates }
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-shipping-methods-block/edit.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-shipping-methods-block/frontend.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/index.tsx
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { Icon, truck } from '@woocommerce/icons';
|
| 5 |
+
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
| 6 |
+
|
| 7 |
+
/**
|
| 8 |
+
* Internal dependencies
|
| 9 |
+
*/
|
| 10 |
+
import { Edit, Save } from './edit';
|
| 11 |
+
import attributes from './attributes';
|
| 12 |
+
import metadata from './block.json';
|
| 13 |
+
|
| 14 |
+
registerFeaturePluginBlockType( metadata, {
|
| 15 |
+
icon: {
|
| 16 |
+
src: <Icon srcElement={ truck } />,
|
| 17 |
+
foreground: '#874FB9',
|
| 18 |
+
},
|
| 19 |
+
attributes,
|
| 20 |
+
edit: Edit,
|
| 21 |
+
save: Save,
|
| 22 |
+
} );
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-shipping-methods-block/no-shipping-placeholder/index.js
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-shipping-methods-block/no-shipping-placeholder/style.scss
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/style.scss
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.wc-block-checkout__shipping-option {
|
| 2 |
+
.wc-block-components-radio-control__option {
|
| 3 |
+
@include with-translucent-border( 0 0 1px );
|
| 4 |
+
margin: 0;
|
| 5 |
+
padding: em($gap-small) 0 em($gap-small) em($gap-largest);
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
.wc-block-components-shipping-rates-control__no-results-notice {
|
| 9 |
+
margin: em($gap-small) 0;
|
| 10 |
+
}
|
| 11 |
+
}
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/block.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "woocommerce/checkout-terms-block",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"title": "Terms and Conditions",
|
| 5 |
+
"description": "Ensure customers agree to your terms and conditions and privacy policy.",
|
| 6 |
+
"category": "woocommerce",
|
| 7 |
+
"supports": {
|
| 8 |
+
"align": false,
|
| 9 |
+
"html": false,
|
| 10 |
+
"multiple": false,
|
| 11 |
+
"reusable": false
|
| 12 |
+
},
|
| 13 |
+
"attributes": {
|
| 14 |
+
"checkbox": {
|
| 15 |
+
"type": "boolean",
|
| 16 |
+
"default": false
|
| 17 |
+
},
|
| 18 |
+
"text": {
|
| 19 |
+
"type": "string",
|
| 20 |
+
"required": false
|
| 21 |
+
}
|
| 22 |
+
},
|
| 23 |
+
"parent": [ "woocommerce/checkout-fields-block" ],
|
| 24 |
+
"textdomain": "woo-gutenberg-products-block",
|
| 25 |
+
"apiVersion": 2
|
| 26 |
+
}
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-terms-block/constants.js
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/edit.tsx
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { __ } from '@wordpress/i18n';
|
| 5 |
+
import {
|
| 6 |
+
useBlockProps,
|
| 7 |
+
RichText,
|
| 8 |
+
InspectorControls,
|
| 9 |
+
} from '@wordpress/block-editor';
|
| 10 |
+
import CheckboxControl from '@woocommerce/base-components/checkbox-control';
|
| 11 |
+
import { PanelBody, ToggleControl, Notice } from '@wordpress/components';
|
| 12 |
+
import { PRIVACY_URL, TERMS_URL } from '@woocommerce/block-settings';
|
| 13 |
+
import { ADMIN_URL } from '@woocommerce/settings';
|
| 14 |
+
import { Icon, external } from '@wordpress/icons';
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* Internal dependencies
|
| 18 |
+
*/
|
| 19 |
+
import './editor.scss';
|
| 20 |
+
import { termsConsentDefaultText, termsCheckboxDefaultText } from './constants';
|
| 21 |
+
|
| 22 |
+
export const Edit = ( {
|
| 23 |
+
attributes: { checkbox, text },
|
| 24 |
+
setAttributes,
|
| 25 |
+
}: {
|
| 26 |
+
attributes: { text: string; checkbox: boolean };
|
| 27 |
+
setAttributes: ( attributes: Record< string, unknown > ) => void;
|
| 28 |
+
} ): JSX.Element => {
|
| 29 |
+
const blockProps = useBlockProps();
|
| 30 |
+
|
| 31 |
+
const defaultText = checkbox
|
| 32 |
+
? termsCheckboxDefaultText
|
| 33 |
+
: termsConsentDefaultText;
|
| 34 |
+
|
| 35 |
+
const currentText = text || defaultText;
|
| 36 |
+
return (
|
| 37 |
+
<div { ...blockProps }>
|
| 38 |
+
<InspectorControls>
|
| 39 |
+
<PanelBody
|
| 40 |
+
title={ __(
|
| 41 |
+
'Display options',
|
| 42 |
+
'woo-gutenberg-products-block'
|
| 43 |
+
) }
|
| 44 |
+
>
|
| 45 |
+
<ToggleControl
|
| 46 |
+
label={ __(
|
| 47 |
+
'Require checkbox',
|
| 48 |
+
'woo-gutenberg-products-block'
|
| 49 |
+
) }
|
| 50 |
+
checked={ checkbox }
|
| 51 |
+
onChange={ () =>
|
| 52 |
+
setAttributes( {
|
| 53 |
+
checkbox: ! checkbox,
|
| 54 |
+
} )
|
| 55 |
+
}
|
| 56 |
+
/>
|
| 57 |
+
</PanelBody>
|
| 58 |
+
</InspectorControls>
|
| 59 |
+
<div className="wc-block-checkout__terms">
|
| 60 |
+
{ checkbox ? (
|
| 61 |
+
<>
|
| 62 |
+
<CheckboxControl
|
| 63 |
+
id="terms-condition"
|
| 64 |
+
checked={ false }
|
| 65 |
+
/>
|
| 66 |
+
<RichText
|
| 67 |
+
value={ currentText }
|
| 68 |
+
onChange={ ( value ) =>
|
| 69 |
+
setAttributes( { text: value } )
|
| 70 |
+
}
|
| 71 |
+
/>
|
| 72 |
+
</>
|
| 73 |
+
) : (
|
| 74 |
+
<RichText
|
| 75 |
+
tagName="span"
|
| 76 |
+
value={ currentText }
|
| 77 |
+
onChange={ ( value ) =>
|
| 78 |
+
setAttributes( { text: value } )
|
| 79 |
+
}
|
| 80 |
+
/>
|
| 81 |
+
) }
|
| 82 |
+
</div>
|
| 83 |
+
{ /* Show this notice if a terms page or a privacy page is not setup. */ }
|
| 84 |
+
{ ( ! TERMS_URL || ! PRIVACY_URL ) && (
|
| 85 |
+
<Notice
|
| 86 |
+
className="wc-block-checkout__terms_notice"
|
| 87 |
+
status="warning"
|
| 88 |
+
isDismissible={ false }
|
| 89 |
+
actions={ [
|
| 90 |
+
! TERMS_URL && {
|
| 91 |
+
className: 'wc-block-checkout__terms_notice-button',
|
| 92 |
+
label: (
|
| 93 |
+
<>
|
| 94 |
+
{ __(
|
| 95 |
+
'Setup a Terms and Conditions page',
|
| 96 |
+
'woo-gutenberg-products-block'
|
| 97 |
+
) }
|
| 98 |
+
<Icon
|
| 99 |
+
icon={ external }
|
| 100 |
+
size={ 16 }
|
| 101 |
+
className="wc-block-checkout__terms_notice-button__icon"
|
| 102 |
+
/>
|
| 103 |
+
</>
|
| 104 |
+
),
|
| 105 |
+
|
| 106 |
+
onClick: () =>
|
| 107 |
+
window.open(
|
| 108 |
+
`${ ADMIN_URL }admin.php?page=wc-settings&tab=advanced`,
|
| 109 |
+
'_blank'
|
| 110 |
+
),
|
| 111 |
+
},
|
| 112 |
+
! PRIVACY_URL && {
|
| 113 |
+
className: 'wc-block-checkout__terms_notice-button',
|
| 114 |
+
label: (
|
| 115 |
+
<>
|
| 116 |
+
{ __(
|
| 117 |
+
'Setup a Privacy Policy page',
|
| 118 |
+
'woo-gutenberg-products-block'
|
| 119 |
+
) }
|
| 120 |
+
<Icon
|
| 121 |
+
size={ 16 }
|
| 122 |
+
icon={ external }
|
| 123 |
+
className="wc-block-checkout__terms_notice-button__icon"
|
| 124 |
+
/>
|
| 125 |
+
</>
|
| 126 |
+
),
|
| 127 |
+
onClick: () =>
|
| 128 |
+
window.open(
|
| 129 |
+
`${ ADMIN_URL }options-privacy.php`,
|
| 130 |
+
'_blank'
|
| 131 |
+
),
|
| 132 |
+
},
|
| 133 |
+
].filter( Boolean ) }
|
| 134 |
+
>
|
| 135 |
+
<p>
|
| 136 |
+
{ __(
|
| 137 |
+
"You don't seem to have a Terms and Conditions and/or a Privacy Policy pages setup.",
|
| 138 |
+
'woo-gutenberg-products-block'
|
| 139 |
+
) }
|
| 140 |
+
</p>
|
| 141 |
+
</Notice>
|
| 142 |
+
) }
|
| 143 |
+
{ /* Show this notice if we have both a terms and privacy pages, but they're not present in the text. */ }
|
| 144 |
+
{ TERMS_URL &&
|
| 145 |
+
PRIVACY_URL &&
|
| 146 |
+
! (
|
| 147 |
+
currentText.includes( TERMS_URL ) &&
|
| 148 |
+
currentText.includes( PRIVACY_URL )
|
| 149 |
+
) && (
|
| 150 |
+
<Notice
|
| 151 |
+
className="wc-block-checkout__terms_notice"
|
| 152 |
+
status="warning"
|
| 153 |
+
isDismissible={ false }
|
| 154 |
+
actions={
|
| 155 |
+
termsConsentDefaultText !== text
|
| 156 |
+
? [
|
| 157 |
+
{
|
| 158 |
+
label: __(
|
| 159 |
+
'Restore default text',
|
| 160 |
+
'woo-gutenberg-products-block'
|
| 161 |
+
),
|
| 162 |
+
onClick: () =>
|
| 163 |
+
setAttributes( { text: '' } ),
|
| 164 |
+
},
|
| 165 |
+
]
|
| 166 |
+
: []
|
| 167 |
+
}
|
| 168 |
+
>
|
| 169 |
+
<p>
|
| 170 |
+
{ __(
|
| 171 |
+
'Ensure you add links to your policy pages in this section.',
|
| 172 |
+
'woo-gutenberg-products-block'
|
| 173 |
+
) }
|
| 174 |
+
</p>
|
| 175 |
+
</Notice>
|
| 176 |
+
) }
|
| 177 |
+
</div>
|
| 178 |
+
);
|
| 179 |
+
};
|
| 180 |
+
|
| 181 |
+
export const Save = (): JSX.Element => {
|
| 182 |
+
return <div { ...useBlockProps.save() } />;
|
| 183 |
+
};
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-terms-block/editor.scss
RENAMED
|
@@ -19,3 +19,14 @@
|
|
| 19 |
.wc-block-checkout__terms_notice .components-notice__action {
|
| 20 |
margin-left: 0;
|
| 21 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
.wc-block-checkout__terms_notice .components-notice__action {
|
| 20 |
margin-left: 0;
|
| 21 |
}
|
| 22 |
+
|
| 23 |
+
.wc-block-checkout__terms_notice-button {
|
| 24 |
+
display: flex;
|
| 25 |
+
flex-direction: row;
|
| 26 |
+
align-items: center;
|
| 27 |
+
|
| 28 |
+
.wc-block-checkout__terms_notice-button__icon {
|
| 29 |
+
margin-left: $gap-smallest;
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-terms-block/frontend.tsx
RENAMED
|
@@ -80,9 +80,7 @@ const FrontendBlock = ( {
|
|
| 80 |
id="terms-and-conditions"
|
| 81 |
checked={ checked }
|
| 82 |
onChange={ () => setChecked( ( value ) => ! value ) }
|
| 83 |
-
|
| 84 |
-
'has-error': hasError,
|
| 85 |
-
} ) }
|
| 86 |
disabled={ isDisabled }
|
| 87 |
>
|
| 88 |
<span
|
| 80 |
id="terms-and-conditions"
|
| 81 |
checked={ checked }
|
| 82 |
onChange={ () => setChecked( ( value ) => ! value ) }
|
| 83 |
+
hasError={ hasError }
|
|
|
|
|
|
|
| 84 |
disabled={ isDisabled }
|
| 85 |
>
|
| 86 |
<span
|
assets/js/blocks/cart-checkout/{checkout-i2/inner-blocks/checkout-sample-block → checkout/inner-blocks/checkout-terms-block}/index.tsx
RENAMED
|
@@ -2,15 +2,14 @@
|
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import { Icon, asterisk } from '@woocommerce/icons';
|
| 5 |
-
import {
|
| 6 |
-
|
| 7 |
/**
|
| 8 |
* Internal dependencies
|
| 9 |
*/
|
| 10 |
import { Edit, Save } from './edit';
|
| 11 |
import metadata from './block.json';
|
| 12 |
|
| 13 |
-
|
| 14 |
icon: {
|
| 15 |
src: <Icon srcElement={ asterisk } />,
|
| 16 |
foreground: '#874FB9',
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import { Icon, asterisk } from '@woocommerce/icons';
|
| 5 |
+
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';
|
|
|
|
| 6 |
/**
|
| 7 |
* Internal dependencies
|
| 8 |
*/
|
| 9 |
import { Edit, Save } from './edit';
|
| 10 |
import metadata from './block.json';
|
| 11 |
|
| 12 |
+
registerFeaturePluginBlockType( metadata, {
|
| 13 |
icon: {
|
| 14 |
src: <Icon srcElement={ asterisk } />,
|
| 15 |
foreground: '#874FB9',
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-terms-block/style.scss
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/block.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "woocommerce/checkout-totals-block",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"title": "Checkout Totals",
|
| 5 |
+
"description": "Column containing the checkout totals.",
|
| 6 |
+
"category": "woocommerce",
|
| 7 |
+
"supports": {
|
| 8 |
+
"align": false,
|
| 9 |
+
"html": false,
|
| 10 |
+
"multiple": false,
|
| 11 |
+
"reusable": false,
|
| 12 |
+
"inserter": false
|
| 13 |
+
},
|
| 14 |
+
"attributes": {
|
| 15 |
+
"checkbox": {
|
| 16 |
+
"type": "boolean",
|
| 17 |
+
"default": false
|
| 18 |
+
},
|
| 19 |
+
"text": {
|
| 20 |
+
"type": "string",
|
| 21 |
+
"required": false
|
| 22 |
+
}
|
| 23 |
+
},
|
| 24 |
+
"parent": [ "woocommerce/checkout" ],
|
| 25 |
+
"textdomain": "woo-gutenberg-products-block",
|
| 26 |
+
"apiVersion": 2
|
| 27 |
+
}
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-totals-block/edit.tsx
RENAMED
|
@@ -8,6 +8,7 @@ import { innerBlockAreas } from '@woocommerce/blocks-checkout';
|
|
| 8 |
/**
|
| 9 |
* Internal dependencies
|
| 10 |
*/
|
|
|
|
| 11 |
import { useForcedLayout } from '../../use-forced-layout';
|
| 12 |
import { getAllowedBlocks } from '../../editor-utils';
|
| 13 |
|
| 8 |
/**
|
| 9 |
* Internal dependencies
|
| 10 |
*/
|
| 11 |
+
import './style.scss';
|
| 12 |
import { useForcedLayout } from '../../use-forced-layout';
|
| 13 |
import { getAllowedBlocks } from '../../editor-utils';
|
| 14 |
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/checkout-totals-block/frontend.tsx
RENAMED
|
@@ -3,6 +3,11 @@
|
|
| 3 |
*/
|
| 4 |
import { Sidebar } from '@woocommerce/base-components/sidebar-layout';
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
const FrontendBlock = ( {
|
| 7 |
children,
|
| 8 |
}: {
|
| 3 |
*/
|
| 4 |
import { Sidebar } from '@woocommerce/base-components/sidebar-layout';
|
| 5 |
|
| 6 |
+
/**
|
| 7 |
+
* Internal dependencies
|
| 8 |
+
*/
|
| 9 |
+
import './style.scss';
|
| 10 |
+
|
| 11 |
const FrontendBlock = ( {
|
| 12 |
children,
|
| 13 |
}: {
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/index.tsx
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { Icon, column } from '@wordpress/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: <Icon icon={ column } />,
|
| 16 |
+
foreground: '#874FB9',
|
| 17 |
+
},
|
| 18 |
+
edit: Edit,
|
| 19 |
+
save: Save,
|
| 20 |
+
} );
|
assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/style.scss
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.wc-block-checkout__sidebar {
|
| 2 |
+
.wc-block-components-product-name {
|
| 3 |
+
display: block;
|
| 4 |
+
color: inherit;
|
| 5 |
+
flex-grow: 1;
|
| 6 |
+
// Required by IE11.
|
| 7 |
+
flex-basis: 0;
|
| 8 |
+
}
|
| 9 |
+
.wc-block-components-totals-taxes,
|
| 10 |
+
.wc-block-components-totals-footer-item {
|
| 11 |
+
margin: 0;
|
| 12 |
+
padding: 0;
|
| 13 |
+
}
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
.is-mobile,
|
| 17 |
+
.is-small,
|
| 18 |
+
.is-medium {
|
| 19 |
+
.wc-block-checkout__sidebar {
|
| 20 |
+
margin-bottom: $gap-large;
|
| 21 |
+
order: 0;
|
| 22 |
+
}
|
| 23 |
+
}
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/index.tsx
RENAMED
|
@@ -13,4 +13,3 @@ import './checkout-order-summary-block';
|
|
| 13 |
import './checkout-payment-block';
|
| 14 |
import './checkout-express-payment-block';
|
| 15 |
import './checkout-shipping-methods-block';
|
| 16 |
-
import './checkout-sample-block';
|
| 13 |
import './checkout-payment-block';
|
| 14 |
import './checkout-express-payment-block';
|
| 15 |
import './checkout-shipping-methods-block';
|
|
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/inner-blocks/register-components.ts
RENAMED
|
@@ -2,7 +2,6 @@
|
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import { lazy } from '@wordpress/element';
|
| 5 |
-
import { registerBlockComponent } from '@woocommerce/blocks-registry';
|
| 6 |
import { WC_BLOCKS_BUILD_URL } from '@woocommerce/block-settings';
|
| 7 |
import { registerCheckoutBlock } from '@woocommerce/blocks-checkout';
|
| 8 |
|
|
@@ -13,46 +12,58 @@ __webpack_public_path__ = WC_BLOCKS_BUILD_URL;
|
|
| 13 |
/**
|
| 14 |
* Internal dependencies
|
| 15 |
*/
|
| 16 |
-
import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
|
|
|
| 18 |
registerCheckoutBlock( {
|
| 19 |
-
metadata:
|
| 20 |
component: lazy( () =>
|
| 21 |
import(
|
| 22 |
-
/* webpackChunkName: "checkout-blocks/
|
| 23 |
)
|
| 24 |
),
|
| 25 |
} );
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
component: lazy( () =>
|
| 30 |
import(
|
| 31 |
-
/* webpackChunkName: "checkout-blocks/
|
| 32 |
)
|
| 33 |
),
|
| 34 |
} );
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
component: lazy( () =>
|
| 39 |
import(
|
| 40 |
-
/* webpackChunkName: "checkout-blocks/
|
| 41 |
)
|
| 42 |
),
|
| 43 |
} );
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
component: lazy( () =>
|
| 48 |
import(
|
| 49 |
-
/* webpackChunkName: "checkout-blocks/
|
| 50 |
)
|
| 51 |
),
|
| 52 |
} );
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
component: lazy( () =>
|
| 57 |
import(
|
| 58 |
/* webpackChunkName: "checkout-blocks/billing-address" */ './checkout-billing-address-block/frontend'
|
|
@@ -60,26 +71,26 @@ registerBlockComponent( {
|
|
| 60 |
),
|
| 61 |
} );
|
| 62 |
|
| 63 |
-
|
| 64 |
-
|
| 65 |
component: lazy( () =>
|
| 66 |
import(
|
| 67 |
-
/* webpackChunkName: "checkout-blocks/
|
| 68 |
)
|
| 69 |
),
|
| 70 |
} );
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
component: lazy( () =>
|
| 75 |
import(
|
| 76 |
-
/* webpackChunkName: "checkout-blocks/
|
| 77 |
)
|
| 78 |
),
|
| 79 |
} );
|
| 80 |
|
| 81 |
-
|
| 82 |
-
|
| 83 |
component: lazy( () =>
|
| 84 |
import(
|
| 85 |
/* webpackChunkName: "checkout-blocks/order-note" */ './checkout-order-note-block/block'
|
|
@@ -87,47 +98,38 @@ registerBlockComponent( {
|
|
| 87 |
),
|
| 88 |
} );
|
| 89 |
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
component: lazy( () =>
|
| 93 |
-
import(
|
| 94 |
-
/* webpackChunkName: "checkout-blocks/order-summary" */ './checkout-order-summary-block/block'
|
| 95 |
-
)
|
| 96 |
-
),
|
| 97 |
-
} );
|
| 98 |
-
|
| 99 |
-
registerBlockComponent( {
|
| 100 |
-
blockName: 'woocommerce/checkout-payment-block',
|
| 101 |
component: lazy( () =>
|
| 102 |
import(
|
| 103 |
-
/* webpackChunkName: "checkout-blocks/
|
| 104 |
)
|
| 105 |
),
|
| 106 |
} );
|
| 107 |
|
| 108 |
-
|
| 109 |
-
|
| 110 |
component: lazy( () =>
|
| 111 |
import(
|
| 112 |
-
/* webpackChunkName: "checkout-blocks/
|
| 113 |
)
|
| 114 |
),
|
| 115 |
} );
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
| 119 |
component: lazy( () =>
|
| 120 |
import(
|
| 121 |
-
/* webpackChunkName: "checkout-blocks/
|
| 122 |
)
|
| 123 |
),
|
| 124 |
} );
|
| 125 |
|
| 126 |
-
|
| 127 |
-
|
| 128 |
component: lazy( () =>
|
| 129 |
import(
|
| 130 |
-
/* webpackChunkName: "checkout-blocks/
|
| 131 |
)
|
| 132 |
),
|
| 133 |
} );
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import { lazy } from '@wordpress/element';
|
|
|
|
| 5 |
import { WC_BLOCKS_BUILD_URL } from '@woocommerce/block-settings';
|
| 6 |
import { registerCheckoutBlock } from '@woocommerce/blocks-checkout';
|
| 7 |
|
| 12 |
/**
|
| 13 |
* Internal dependencies
|
| 14 |
*/
|
| 15 |
+
import checkoutActionsMetadata from './checkout-actions-block/block.json';
|
| 16 |
+
import checkoutBillingAddressMetadata from './checkout-billing-address-block/block.json';
|
| 17 |
+
import checkoutContactInformationMetadata from './checkout-contact-information-block/block.json';
|
| 18 |
+
import checkoutExpressPaymentMetadata from './checkout-express-payment-block/block.json';
|
| 19 |
+
import checkoutFieldsMetadata from './checkout-fields-block/block.json';
|
| 20 |
+
import checkoutOrderNoteMetadata from './checkout-order-note-block/block.json';
|
| 21 |
+
import checkoutOrderSummaryMetadata from './checkout-order-summary-block/block.json';
|
| 22 |
+
import checkoutPaymentMetadata from './checkout-payment-block/block.json';
|
| 23 |
+
import checkoutShippingAddressMetadata from './checkout-shipping-address-block/block.json';
|
| 24 |
+
import checkoutShippingMethodsMetadata from './checkout-shipping-methods-block/block.json';
|
| 25 |
+
import checkoutTermsMetadata from './checkout-terms-block/block.json';
|
| 26 |
+
import checkoutTotalsMetadata from './checkout-totals-block/block.json';
|
| 27 |
|
| 28 |
+
// @todo When forcing all blocks at once, they will append based on the order they are registered. Introduce formal sorting param.
|
| 29 |
registerCheckoutBlock( {
|
| 30 |
+
metadata: checkoutFieldsMetadata,
|
| 31 |
component: lazy( () =>
|
| 32 |
import(
|
| 33 |
+
/* webpackChunkName: "checkout-blocks/fields" */ './checkout-fields-block/frontend'
|
| 34 |
)
|
| 35 |
),
|
| 36 |
} );
|
| 37 |
|
| 38 |
+
registerCheckoutBlock( {
|
| 39 |
+
metadata: checkoutExpressPaymentMetadata,
|
| 40 |
component: lazy( () =>
|
| 41 |
import(
|
| 42 |
+
/* webpackChunkName: "checkout-blocks/express-payment" */ './checkout-express-payment-block/block'
|
| 43 |
)
|
| 44 |
),
|
| 45 |
} );
|
| 46 |
|
| 47 |
+
registerCheckoutBlock( {
|
| 48 |
+
metadata: checkoutContactInformationMetadata,
|
| 49 |
component: lazy( () =>
|
| 50 |
import(
|
| 51 |
+
/* webpackChunkName: "checkout-blocks/contact-information" */ './checkout-contact-information-block/frontend'
|
| 52 |
)
|
| 53 |
),
|
| 54 |
} );
|
| 55 |
|
| 56 |
+
registerCheckoutBlock( {
|
| 57 |
+
metadata: checkoutShippingAddressMetadata,
|
| 58 |
component: lazy( () =>
|
| 59 |
import(
|
| 60 |
+
/* webpackChunkName: "checkout-blocks/shipping-address" */ './checkout-shipping-address-block/frontend'
|
| 61 |
)
|
| 62 |
),
|
| 63 |
} );
|
| 64 |
|
| 65 |
+
registerCheckoutBlock( {
|
| 66 |
+
metadata: checkoutBillingAddressMetadata,
|
| 67 |
component: lazy( () =>
|
| 68 |
import(
|
| 69 |
/* webpackChunkName: "checkout-blocks/billing-address" */ './checkout-billing-address-block/frontend'
|
| 71 |
),
|
| 72 |
} );
|
| 73 |
|
| 74 |
+
registerCheckoutBlock( {
|
| 75 |
+
metadata: checkoutShippingMethodsMetadata,
|
| 76 |
component: lazy( () =>
|
| 77 |
import(
|
| 78 |
+
/* webpackChunkName: "checkout-blocks/shipping-methods" */ './checkout-shipping-methods-block/frontend'
|
| 79 |
)
|
| 80 |
),
|
| 81 |
} );
|
| 82 |
|
| 83 |
+
registerCheckoutBlock( {
|
| 84 |
+
metadata: checkoutPaymentMetadata,
|
| 85 |
component: lazy( () =>
|
| 86 |
import(
|
| 87 |
+
/* webpackChunkName: "checkout-blocks/payment" */ './checkout-payment-block/frontend'
|
| 88 |
)
|
| 89 |
),
|
| 90 |
} );
|
| 91 |
|
| 92 |
+
registerCheckoutBlock( {
|
| 93 |
+
metadata: checkoutOrderNoteMetadata,
|
| 94 |
component: lazy( () =>
|
| 95 |
import(
|
| 96 |
/* webpackChunkName: "checkout-blocks/order-note" */ './checkout-order-note-block/block'
|
| 98 |
),
|
| 99 |
} );
|
| 100 |
|
| 101 |
+
registerCheckoutBlock( {
|
| 102 |
+
metadata: checkoutTermsMetadata,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
component: lazy( () =>
|
| 104 |
import(
|
| 105 |
+
/* webpackChunkName: "checkout-blocks/terms" */ './checkout-terms-block/frontend'
|
| 106 |
)
|
| 107 |
),
|
| 108 |
} );
|
| 109 |
|
| 110 |
+
registerCheckoutBlock( {
|
| 111 |
+
metadata: checkoutActionsMetadata,
|
| 112 |
component: lazy( () =>
|
| 113 |
import(
|
| 114 |
+
/* webpackChunkName: "checkout-blocks/actions" */ './checkout-actions-block/frontend'
|
| 115 |
)
|
| 116 |
),
|
| 117 |
} );
|
| 118 |
|
| 119 |
+
registerCheckoutBlock( {
|
| 120 |
+
metadata: checkoutTotalsMetadata,
|
| 121 |
component: lazy( () =>
|
| 122 |
import(
|
| 123 |
+
/* webpackChunkName: "checkout-blocks/totals" */ './checkout-totals-block/frontend'
|
| 124 |
)
|
| 125 |
),
|
| 126 |
} );
|
| 127 |
|
| 128 |
+
registerCheckoutBlock( {
|
| 129 |
+
metadata: checkoutOrderSummaryMetadata,
|
| 130 |
component: lazy( () =>
|
| 131 |
import(
|
| 132 |
+
/* webpackChunkName: "checkout-blocks/order-summary" */ './checkout-order-summary-block/block'
|
| 133 |
)
|
| 134 |
),
|
| 135 |
} );
|
assets/js/blocks/cart-checkout/checkout/{form/order-notes → order-notes}/index.js
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/checkout/{form/order-notes → order-notes}/style.scss
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/phone-number/index.tsx
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/checkout/sidebar/test/__snapshots__/index.js.snap
DELETED
|
@@ -1,116 +0,0 @@
|
|
| 1 |
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
| 2 |
-
|
| 3 |
-
exports[`Testing checkout sidebar Shows rate percentages after tax lines if the block is set to do so 1`] = `
|
| 4 |
-
<div>
|
| 5 |
-
<div
|
| 6 |
-
class="wc-block-components-totals-wrapper"
|
| 7 |
-
/>
|
| 8 |
-
<div
|
| 9 |
-
class="wc-block-components-totals-wrapper"
|
| 10 |
-
>
|
| 11 |
-
<div
|
| 12 |
-
class="wc-block-components-totals-item"
|
| 13 |
-
>
|
| 14 |
-
<span
|
| 15 |
-
class="wc-block-components-totals-item__label"
|
| 16 |
-
>
|
| 17 |
-
Subtotal
|
| 18 |
-
</span>
|
| 19 |
-
<span
|
| 20 |
-
class="wc-block-formatted-money-amount wc-block-components-formatted-money-amount wc-block-components-totals-item__value"
|
| 21 |
-
>
|
| 22 |
-
$24.00
|
| 23 |
-
</span>
|
| 24 |
-
<div
|
| 25 |
-
class="wc-block-components-totals-item__description"
|
| 26 |
-
/>
|
| 27 |
-
</div>
|
| 28 |
-
</div>
|
| 29 |
-
<div
|
| 30 |
-
class="wc-block-components-totals-wrapper"
|
| 31 |
-
>
|
| 32 |
-
<div
|
| 33 |
-
class="wc-block-components-totals-coupon wc-block-components-panel"
|
| 34 |
-
>
|
| 35 |
-
<div>
|
| 36 |
-
<button
|
| 37 |
-
aria-expanded="false"
|
| 38 |
-
class="wc-block-components-panel__button"
|
| 39 |
-
>
|
| 40 |
-
<svg
|
| 41 |
-
aria-hidden="true"
|
| 42 |
-
class="wc-block-components-panel__button-icon"
|
| 43 |
-
focusable="false"
|
| 44 |
-
height="24"
|
| 45 |
-
role="img"
|
| 46 |
-
viewBox="0 0 24 24"
|
| 47 |
-
width="24"
|
| 48 |
-
xmlns="http://www.w3.org/2000/svg"
|
| 49 |
-
>
|
| 50 |
-
<path
|
| 51 |
-
d="M17 9.4L12 14 7 9.4l-1 1.2 6 5.4 6-5.4z"
|
| 52 |
-
/>
|
| 53 |
-
</svg>
|
| 54 |
-
<span
|
| 55 |
-
aria-hidden="true"
|
| 56 |
-
>
|
| 57 |
-
Coupon code
|
| 58 |
-
</span>
|
| 59 |
-
<span
|
| 60 |
-
class="screen-reader-text"
|
| 61 |
-
>
|
| 62 |
-
Apply a coupon code
|
| 63 |
-
</span>
|
| 64 |
-
</button>
|
| 65 |
-
</div>
|
| 66 |
-
</div>
|
| 67 |
-
</div>
|
| 68 |
-
<div
|
| 69 |
-
class="wc-block-components-totals-wrapper"
|
| 70 |
-
>
|
| 71 |
-
<div
|
| 72 |
-
class="wc-block-components-totals-taxes"
|
| 73 |
-
>
|
| 74 |
-
<div
|
| 75 |
-
class="wc-block-components-totals-item wc-block-components-totals-taxes__grouped-rate"
|
| 76 |
-
>
|
| 77 |
-
<span
|
| 78 |
-
class="wc-block-components-totals-item__label"
|
| 79 |
-
>
|
| 80 |
-
Sales tax 20%
|
| 81 |
-
</span>
|
| 82 |
-
<span
|
| 83 |
-
class="wc-block-formatted-money-amount wc-block-components-formatted-money-amount wc-block-components-totals-item__value"
|
| 84 |
-
>
|
| 85 |
-
$6.00
|
| 86 |
-
</span>
|
| 87 |
-
<div
|
| 88 |
-
class="wc-block-components-totals-item__description"
|
| 89 |
-
/>
|
| 90 |
-
</div>
|
| 91 |
-
|
| 92 |
-
</div>
|
| 93 |
-
</div>
|
| 94 |
-
<div
|
| 95 |
-
class="wc-block-components-totals-wrapper"
|
| 96 |
-
>
|
| 97 |
-
<div
|
| 98 |
-
class="wc-block-components-totals-item wc-block-components-totals-footer-item"
|
| 99 |
-
>
|
| 100 |
-
<span
|
| 101 |
-
class="wc-block-components-totals-item__label"
|
| 102 |
-
>
|
| 103 |
-
Total
|
| 104 |
-
</span>
|
| 105 |
-
<span
|
| 106 |
-
class="wc-block-formatted-money-amount wc-block-components-formatted-money-amount wc-block-components-totals-item__value"
|
| 107 |
-
>
|
| 108 |
-
$30.00
|
| 109 |
-
</span>
|
| 110 |
-
<div
|
| 111 |
-
class="wc-block-components-totals-item__description"
|
| 112 |
-
/>
|
| 113 |
-
</div>
|
| 114 |
-
</div>
|
| 115 |
-
</div>
|
| 116 |
-
`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout/sidebar/test/index.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { render } from '@testing-library/react';
|
| 5 |
-
import { previewCart } from '@woocommerce/resource-previews';
|
| 6 |
-
|
| 7 |
-
/**
|
| 8 |
-
* Internal dependencies
|
| 9 |
-
*/
|
| 10 |
-
import { allSettings } from '../../../../../settings/shared/settings-init';
|
| 11 |
-
import CheckoutSidebar from '../index';
|
| 12 |
-
|
| 13 |
-
describe( 'Testing checkout sidebar', () => {
|
| 14 |
-
it( 'Shows rate percentages after tax lines if the block is set to do so', async () => {
|
| 15 |
-
allSettings.displayCartPricesIncludingTax = false;
|
| 16 |
-
allSettings.displayItemizedTaxes = true;
|
| 17 |
-
const { totals: cartTotals, items: cartItems } = previewCart;
|
| 18 |
-
const { container } = render(
|
| 19 |
-
<CheckoutSidebar
|
| 20 |
-
cartItems={ cartItems }
|
| 21 |
-
cartTotals={ cartTotals }
|
| 22 |
-
showRateAfterTaxName={ true }
|
| 23 |
-
/>
|
| 24 |
-
);
|
| 25 |
-
expect( container ).toMatchSnapshot();
|
| 26 |
-
} );
|
| 27 |
-
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/checkout/style.scss
DELETED
|
@@ -1,156 +0,0 @@
|
|
| 1 |
-
.wp-block-woocommerce-checkout .with-scroll-to-top__scroll-point {
|
| 2 |
-
top: -96px;
|
| 3 |
-
}
|
| 4 |
-
|
| 5 |
-
.wc-block-checkout__sidebar {
|
| 6 |
-
.wc-block-components-product-name {
|
| 7 |
-
display: block;
|
| 8 |
-
color: inherit;
|
| 9 |
-
flex-grow: 1;
|
| 10 |
-
// Required by IE11.
|
| 11 |
-
flex-basis: 0;
|
| 12 |
-
}
|
| 13 |
-
.wc-block-components-totals-taxes,
|
| 14 |
-
.wc-block-components-totals-footer-item {
|
| 15 |
-
margin: 0;
|
| 16 |
-
padding: 0;
|
| 17 |
-
}
|
| 18 |
-
}
|
| 19 |
-
|
| 20 |
-
.wc-block-checkout__actions {
|
| 21 |
-
display: flex;
|
| 22 |
-
justify-content: space-between;
|
| 23 |
-
align-items: center;
|
| 24 |
-
|
| 25 |
-
.wc-block-components-checkout-place-order-button {
|
| 26 |
-
width: 50%;
|
| 27 |
-
padding: 1em;
|
| 28 |
-
height: auto;
|
| 29 |
-
|
| 30 |
-
.wc-block-components-button__text {
|
| 31 |
-
line-height: 24px;
|
| 32 |
-
|
| 33 |
-
> svg {
|
| 34 |
-
fill: $white;
|
| 35 |
-
vertical-align: top;
|
| 36 |
-
}
|
| 37 |
-
}
|
| 38 |
-
}
|
| 39 |
-
}
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
// Loading placeholder state.
|
| 43 |
-
.wc-block-checkout--is-loading {
|
| 44 |
-
.wc-block-components-express-payment,
|
| 45 |
-
.wc-block-checkout__actions button {
|
| 46 |
-
@include placeholder();
|
| 47 |
-
@include force-content();
|
| 48 |
-
}
|
| 49 |
-
.wc-block-components-express-payment {
|
| 50 |
-
min-height: 150px;
|
| 51 |
-
}
|
| 52 |
-
.wc-block-components-express-payment-continue-rule > span {
|
| 53 |
-
@include placeholder();
|
| 54 |
-
@include force-content();
|
| 55 |
-
width: 150px;
|
| 56 |
-
}
|
| 57 |
-
.wc-block-checkout__form {
|
| 58 |
-
.wc-block-components-checkout-step__title {
|
| 59 |
-
@include placeholder();
|
| 60 |
-
@include force-content();
|
| 61 |
-
display: block;
|
| 62 |
-
width: 10em;
|
| 63 |
-
|
| 64 |
-
&::before {
|
| 65 |
-
@include placeholder();
|
| 66 |
-
@include force-content();
|
| 67 |
-
border-radius: 50%;
|
| 68 |
-
display: block;
|
| 69 |
-
height: 100%;
|
| 70 |
-
width: 1.5em;
|
| 71 |
-
}
|
| 72 |
-
}
|
| 73 |
-
.wc-block-components-checkout-step__container::after {
|
| 74 |
-
@include placeholder();
|
| 75 |
-
}
|
| 76 |
-
.wc-block-components-checkout-step__content > span {
|
| 77 |
-
@include placeholder();
|
| 78 |
-
@include force-content();
|
| 79 |
-
display: block;
|
| 80 |
-
min-height: 100px;
|
| 81 |
-
}
|
| 82 |
-
.wc-block-components-checkout-step::before,
|
| 83 |
-
.wc-block-components-checkout-step::after {
|
| 84 |
-
@include placeholder();
|
| 85 |
-
}
|
| 86 |
-
}
|
| 87 |
-
.wc-block-checkout__sidebar .components-card {
|
| 88 |
-
@include placeholder();
|
| 89 |
-
@include force-content();
|
| 90 |
-
min-height: 460px;
|
| 91 |
-
}
|
| 92 |
-
}
|
| 93 |
-
.wc-block-components-sidebar-layout.wc-block-checkout--skeleton {
|
| 94 |
-
display: none;
|
| 95 |
-
}
|
| 96 |
-
.is-loading + .wc-block-components-sidebar-layout.wc-block-checkout--skeleton {
|
| 97 |
-
display: flex;
|
| 98 |
-
}
|
| 99 |
-
|
| 100 |
-
.wc-block-checkout-empty,
|
| 101 |
-
.wc-block-checkout-error {
|
| 102 |
-
padding: $gap-largest;
|
| 103 |
-
text-align: center;
|
| 104 |
-
width: 100%;
|
| 105 |
-
|
| 106 |
-
.wc-block-checkout-empty__image,
|
| 107 |
-
.wc-block-checkout-error__image {
|
| 108 |
-
max-width: 150px;
|
| 109 |
-
margin: 0 auto 1em;
|
| 110 |
-
display: block;
|
| 111 |
-
color: inherit;
|
| 112 |
-
}
|
| 113 |
-
.wc-block-checkout-empty__title,
|
| 114 |
-
.wc-block-checkout-error__title {
|
| 115 |
-
display: block;
|
| 116 |
-
margin: 0;
|
| 117 |
-
font-weight: bold;
|
| 118 |
-
}
|
| 119 |
-
.wc-block-checkout-empty__description,
|
| 120 |
-
.wc-block-checkout-error__description {
|
| 121 |
-
display: block;
|
| 122 |
-
margin: 0.25em 0 1em 0;
|
| 123 |
-
}
|
| 124 |
-
}
|
| 125 |
-
|
| 126 |
-
.is-mobile {
|
| 127 |
-
.wc-block-checkout__actions {
|
| 128 |
-
.wc-block-components-checkout-return-to-cart-button {
|
| 129 |
-
display: none;
|
| 130 |
-
}
|
| 131 |
-
|
| 132 |
-
.wc-block-components-checkout-place-order-button {
|
| 133 |
-
width: 100%;
|
| 134 |
-
}
|
| 135 |
-
}
|
| 136 |
-
}
|
| 137 |
-
|
| 138 |
-
.is-mobile,
|
| 139 |
-
.is-small,
|
| 140 |
-
.is-medium {
|
| 141 |
-
.wc-block-checkout__main {
|
| 142 |
-
order: 1;
|
| 143 |
-
}
|
| 144 |
-
|
| 145 |
-
.wc-block-checkout__sidebar {
|
| 146 |
-
margin-bottom: $gap-large;
|
| 147 |
-
order: 0;
|
| 148 |
-
}
|
| 149 |
-
}
|
| 150 |
-
|
| 151 |
-
.is-large {
|
| 152 |
-
.wc-block-checkout__actions {
|
| 153 |
-
@include with-translucent-border(1px 0 0);
|
| 154 |
-
padding-top: em($gap-large);
|
| 155 |
-
}
|
| 156 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/styles/editor.scss
RENAMED
|
@@ -1,6 +1,4 @@
|
|
| 1 |
-
.wp-block-woocommerce-checkout
|
| 2 |
-
margin-top: 0;
|
| 3 |
-
|
| 4 |
.wc-block-components-sidebar-layout {
|
| 5 |
display: block;
|
| 6 |
}
|
|
@@ -13,7 +11,6 @@
|
|
| 13 |
padding: 0;
|
| 14 |
}
|
| 15 |
}
|
| 16 |
-
|
| 17 |
.wc-block-components-main,
|
| 18 |
.wc-block-components-sidebar,
|
| 19 |
.block-editor-block-list__layout {
|
|
@@ -21,7 +18,6 @@
|
|
| 21 |
margin-top: 0;
|
| 22 |
}
|
| 23 |
}
|
| 24 |
-
|
| 25 |
.wp-block-woocommerce-checkout-totals-block,
|
| 26 |
.wp-block-woocommerce-checkout-fields-block {
|
| 27 |
.block-editor-block-list__layout {
|
|
@@ -30,10 +26,6 @@
|
|
| 30 |
}
|
| 31 |
}
|
| 32 |
|
| 33 |
-
.wc-block-checkout__address-fields-notice {
|
| 34 |
-
margin: $gap 0 0;
|
| 35 |
-
}
|
| 36 |
-
|
| 37 |
body.wc-lock-selected-block--move {
|
| 38 |
.block-editor-block-mover__move-button-container,
|
| 39 |
.block-editor-block-mover {
|
|
@@ -52,10 +44,25 @@ body.wc-lock-selected-block--remove {
|
|
| 52 |
}
|
| 53 |
}
|
| 54 |
|
| 55 |
-
.
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
}
|
| 1 |
+
.wp-block-woocommerce-checkout {
|
|
|
|
|
|
|
| 2 |
.wc-block-components-sidebar-layout {
|
| 3 |
display: block;
|
| 4 |
}
|
| 11 |
padding: 0;
|
| 12 |
}
|
| 13 |
}
|
|
|
|
| 14 |
.wc-block-components-main,
|
| 15 |
.wc-block-components-sidebar,
|
| 16 |
.block-editor-block-list__layout {
|
| 18 |
margin-top: 0;
|
| 19 |
}
|
| 20 |
}
|
|
|
|
| 21 |
.wp-block-woocommerce-checkout-totals-block,
|
| 22 |
.wp-block-woocommerce-checkout-fields-block {
|
| 23 |
.block-editor-block-list__layout {
|
| 26 |
}
|
| 27 |
}
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
body.wc-lock-selected-block--move {
|
| 30 |
.block-editor-block-mover__move-button-container,
|
| 31 |
.block-editor-block-mover {
|
| 44 |
}
|
| 45 |
}
|
| 46 |
|
| 47 |
+
.wc-block-checkout__controls-text {
|
| 48 |
+
color: #999;
|
| 49 |
+
font-style: italic;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
.components-base-control--nested {
|
| 53 |
+
padding-left: 52px;
|
| 54 |
+
margin-top: -12px;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
.wc-block-checkout__page-notice {
|
| 58 |
+
margin: 0;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
.components-panel__body-title .components-button {
|
| 62 |
+
opacity: 1;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
.wp-block-woocommerce-checkout.is-editor-preview {
|
| 66 |
+
max-height: 1000px;
|
| 67 |
+
overflow: hidden;
|
| 68 |
}
|
assets/js/blocks/cart-checkout/checkout/styles/style.scss
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.wp-block-woocommerce-checkout {
|
| 2 |
+
margin: 0;
|
| 3 |
+
|
| 4 |
+
.with-scroll-to-top__scroll-point {
|
| 5 |
+
top: -96px;
|
| 6 |
+
}
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
.wp-block-woocommerce-checkout.is-loading {
|
| 10 |
+
display: flex;
|
| 11 |
+
flex-wrap: wrap;
|
| 12 |
+
margin: 0 auto $gap;
|
| 13 |
+
position: relative;
|
| 14 |
+
.wp-block-woocommerce-checkout-totals-block {
|
| 15 |
+
width: 35%;
|
| 16 |
+
padding-left: percentage(math.div($gap-large, 1060px));
|
| 17 |
+
}
|
| 18 |
+
.wp-block-woocommerce-checkout-fields-block {
|
| 19 |
+
width: 65%;
|
| 20 |
+
padding-right: percentage(math.div($gap-largest, 1060px)); // ~1060px is the default width of the content area in Storefront.
|
| 21 |
+
}
|
| 22 |
+
.wp-block-woocommerce-checkout-totals-block,
|
| 23 |
+
.wp-block-woocommerce-checkout-fields-block {
|
| 24 |
+
box-sizing: border-box;
|
| 25 |
+
margin: 0;
|
| 26 |
+
|
| 27 |
+
> div {
|
| 28 |
+
@include placeholder();
|
| 29 |
+
margin: 0 0 1.5em 0;
|
| 30 |
+
display: none;
|
| 31 |
+
}
|
| 32 |
+
.wp-block-woocommerce-checkout-contact-information-block,
|
| 33 |
+
.wp-block-woocommerce-checkout-payment-block {
|
| 34 |
+
min-height: 10em;
|
| 35 |
+
display: block;
|
| 36 |
+
}
|
| 37 |
+
.wp-block-woocommerce-checkout-shipping-address-block {
|
| 38 |
+
min-height: 24em;
|
| 39 |
+
display: block;
|
| 40 |
+
}
|
| 41 |
+
.wp-block-woocommerce-checkout-actions-block {
|
| 42 |
+
width: 50%;
|
| 43 |
+
min-height: 4em;
|
| 44 |
+
margin-left: 50%;
|
| 45 |
+
display: block;
|
| 46 |
+
}
|
| 47 |
+
.wp-block-woocommerce-checkout-order-summary-block {
|
| 48 |
+
min-height: 47em;
|
| 49 |
+
display: block;
|
| 50 |
+
}
|
| 51 |
+
.wc-block-components-panel > h2 {
|
| 52 |
+
@include font-size(regular);
|
| 53 |
+
@include reset-box();
|
| 54 |
+
@include reset-typography();
|
| 55 |
+
.wc-block-components-panel__button {
|
| 56 |
+
font-weight: 400;
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
.wc-block-components-totals-item,
|
| 60 |
+
.wc-block-components-panel {
|
| 61 |
+
padding-left: $gap;
|
| 62 |
+
padding-right: $gap;
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
// Skeleton is shown before mobile classes are appended.
|
| 67 |
+
@media only screen and (max-width: 700px) {
|
| 68 |
+
.wp-block-woocommerce-checkout.is-loading {
|
| 69 |
+
flex-direction: column;
|
| 70 |
+
margin: 0 auto $gap;
|
| 71 |
+
|
| 72 |
+
.wp-block-woocommerce-checkout-fields-block {
|
| 73 |
+
padding: 0;
|
| 74 |
+
width: 100%;
|
| 75 |
+
}
|
| 76 |
+
.wp-block-woocommerce-checkout-totals-block {
|
| 77 |
+
padding: 0;
|
| 78 |
+
width: 100%;
|
| 79 |
+
.wc-block-components-totals-item,
|
| 80 |
+
.wc-block-components-panel {
|
| 81 |
+
padding-left: 0;
|
| 82 |
+
padding-right: 0;
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
// For Twenty Twenty we need to increase specificity a bit more.
|
| 89 |
+
.theme-twentytwenty .wp-block-woocommerce-checkout.is-loading {
|
| 90 |
+
.wp-block-woocommerce-checkout-totals-block .wc-block-components-panel > h2 {
|
| 91 |
+
@include font-size(large);
|
| 92 |
+
@include reset-box();
|
| 93 |
+
}
|
| 94 |
+
}
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/types.ts
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/checkout/use-forced-layout.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { useLayoutEffect, useRef } from '@wordpress/element';
|
| 5 |
+
import { useSelect, useDispatch } from '@wordpress/data';
|
| 6 |
+
import {
|
| 7 |
+
createBlock,
|
| 8 |
+
getBlockType,
|
| 9 |
+
Block,
|
| 10 |
+
AttributeSource,
|
| 11 |
+
} from '@wordpress/blocks';
|
| 12 |
+
|
| 13 |
+
const isBlockLocked = ( {
|
| 14 |
+
attributes,
|
| 15 |
+
}: {
|
| 16 |
+
attributes: Record< string, AttributeSource.Attribute >;
|
| 17 |
+
} ) => Boolean( attributes.lock?.remove || attributes.lock?.default?.remove );
|
| 18 |
+
|
| 19 |
+
export const useForcedLayout = ( {
|
| 20 |
+
clientId,
|
| 21 |
+
template,
|
| 22 |
+
}: {
|
| 23 |
+
clientId: string;
|
| 24 |
+
template: Array< string >;
|
| 25 |
+
} ): void => {
|
| 26 |
+
const currentTemplate = useRef( template );
|
| 27 |
+
const { insertBlock } = useDispatch( 'core/block-editor' );
|
| 28 |
+
const { innerBlocks, templateTypes } = useSelect(
|
| 29 |
+
( select ) => {
|
| 30 |
+
return {
|
| 31 |
+
innerBlocks: select( 'core/block-editor' ).getBlocks(
|
| 32 |
+
clientId
|
| 33 |
+
),
|
| 34 |
+
templateTypes: currentTemplate.current.map( ( blockName ) =>
|
| 35 |
+
getBlockType( blockName )
|
| 36 |
+
),
|
| 37 |
+
};
|
| 38 |
+
},
|
| 39 |
+
[ clientId, currentTemplate ]
|
| 40 |
+
);
|
| 41 |
+
/**
|
| 42 |
+
* If the current inner blocks differ from the registered blocks, push the differences.
|
| 43 |
+
*
|
| 44 |
+
*/
|
| 45 |
+
useLayoutEffect( () => {
|
| 46 |
+
if ( ! clientId ) {
|
| 47 |
+
return;
|
| 48 |
+
}
|
| 49 |
+
// Missing check to see if registered block is 'forced'
|
| 50 |
+
templateTypes.forEach( ( block: Block | undefined ) => {
|
| 51 |
+
if (
|
| 52 |
+
block &&
|
| 53 |
+
isBlockLocked( block ) &&
|
| 54 |
+
! innerBlocks.find(
|
| 55 |
+
( { name }: { name: string } ) => name === block.name
|
| 56 |
+
)
|
| 57 |
+
) {
|
| 58 |
+
const newBlock = createBlock( block.name );
|
| 59 |
+
insertBlock( newBlock, innerBlocks.length, clientId, false );
|
| 60 |
+
}
|
| 61 |
+
} );
|
| 62 |
+
}, [ clientId, innerBlocks, insertBlock, templateTypes ] );
|
| 63 |
+
};
|
assets/js/blocks/cart-checkout/checkout/utils.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* External dependencies
|
| 3 |
-
*/
|
| 4 |
-
import { LOGIN_URL } from '@woocommerce/block-settings';
|
| 5 |
-
|
| 6 |
-
export const LOGIN_TO_CHECKOUT_URL = `${ LOGIN_URL }?redirect_to=${ encodeURIComponent(
|
| 7 |
-
window.location.href
|
| 8 |
-
) }`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/blocks/cart-checkout/{checkout-i2 → checkout}/utils.ts
RENAMED
|
File without changes
|
assets/js/blocks/cart-checkout/mini-cart/block.tsx
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import classNames from 'classnames';
|
| 5 |
+
import { __, _n, sprintf } from '@wordpress/i18n';
|
| 6 |
+
import { useState, useEffect, useRef } from '@wordpress/element';
|
| 7 |
+
import { dispatch } from '@wordpress/data';
|
| 8 |
+
import { translateJQueryEventToNative } from '@woocommerce/base-utils';
|
| 9 |
+
import { useStoreCart } from '@woocommerce/base-context/hooks';
|
| 10 |
+
import Drawer from '@woocommerce/base-components/drawer';
|
| 11 |
+
import { CART_STORE_KEY as storeKey } from '@woocommerce/block-data';
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* Internal dependencies
|
| 15 |
+
*/
|
| 16 |
+
import CartLineItemsTable from '../cart/full-cart/cart-line-items-table';
|
| 17 |
+
import './style.scss';
|
| 18 |
+
|
| 19 |
+
interface MiniCartBlockProps {
|
| 20 |
+
isPlaceholderOpen?: boolean;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
const MiniCartBlock = ( {
|
| 24 |
+
isPlaceholderOpen = false,
|
| 25 |
+
}: MiniCartBlockProps ): JSX.Element => {
|
| 26 |
+
const { cartItems, cartItemsCount, cartIsLoading } = useStoreCart();
|
| 27 |
+
const [ isOpen, setIsOpen ] = useState< boolean >( isPlaceholderOpen );
|
| 28 |
+
const emptyCartRef = useRef< HTMLDivElement | null >( null );
|
| 29 |
+
// We already rendered the HTML drawer placeholder, so we want to skip the
|
| 30 |
+
// slide in animation.
|
| 31 |
+
const [ skipSlideIn, setSkipSlideIn ] = useState< boolean >(
|
| 32 |
+
isPlaceholderOpen
|
| 33 |
+
);
|
| 34 |
+
|
| 35 |
+
useEffect( () => {
|
| 36 |
+
const openMiniCartAndRefreshData = ( e ) => {
|
| 37 |
+
const eventDetail = e.detail;
|
| 38 |
+
if ( ! eventDetail || ! eventDetail.preserveCartData ) {
|
| 39 |
+
dispatch( storeKey ).invalidateResolutionForStore();
|
| 40 |
+
}
|
| 41 |
+
setSkipSlideIn( false );
|
| 42 |
+
setIsOpen( true );
|
| 43 |
+
};
|
| 44 |
+
|
| 45 |
+
// Make it so we can read jQuery events triggered by WC Core elements.
|
| 46 |
+
const removeJQueryAddedToCartEvent = translateJQueryEventToNative(
|
| 47 |
+
'added_to_cart',
|
| 48 |
+
'wc-blocks_added_to_cart'
|
| 49 |
+
);
|
| 50 |
+
|
| 51 |
+
document.body.addEventListener(
|
| 52 |
+
'wc-blocks_added_to_cart',
|
| 53 |
+
openMiniCartAndRefreshData
|
| 54 |
+
);
|
| 55 |
+
|
| 56 |
+
return () => {
|
| 57 |
+
removeJQueryAddedToCartEvent();
|
| 58 |
+
|
| 59 |
+
document.body.removeEventListener(
|
| 60 |
+
'wc-blocks_added_to_cart',
|
| 61 |
+
openMiniCartAndRefreshData
|
| 62 |
+
);
|
| 63 |
+
};
|
| 64 |
+
}, [] );
|
| 65 |
+
|
| 66 |
+
useEffect( () => {
|
| 67 |
+
// If the cart has been completely emptied, move focus to empty cart
|
| 68 |
+
// element.
|
| 69 |
+
if ( isOpen && ! cartIsLoading && cartItems.length === 0 ) {
|
| 70 |
+
if ( emptyCartRef.current instanceof HTMLElement ) {
|
| 71 |
+
emptyCartRef.current.focus();
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
}, [ isOpen, cartIsLoading, cartItems.length, emptyCartRef ] );
|
| 75 |
+
|
| 76 |
+
const contents =
|
| 77 |
+
! cartIsLoading && cartItems.length === 0 ? (
|
| 78 |
+
<div
|
| 79 |
+
className="wc-block-mini-cart__empty-cart"
|
| 80 |
+
tabIndex={ -1 }
|
| 81 |
+
ref={ emptyCartRef }
|
| 82 |
+
>
|
| 83 |
+
{ __( 'Cart is empty', 'woo-gutenberg-products-block' ) }
|
| 84 |
+
</div>
|
| 85 |
+
) : (
|
| 86 |
+
<CartLineItemsTable
|
| 87 |
+
lineItems={ cartItems }
|
| 88 |
+
isLoading={ cartIsLoading }
|
| 89 |
+
/>
|
| 90 |
+
);
|
| 91 |
+
|
| 92 |
+
return (
|
| 93 |
+
<>
|
| 94 |
+
<button
|
| 95 |
+
className="wc-block-mini-cart__button"
|
| 96 |
+
onClick={ () => {
|
| 97 |
+
if ( ! isOpen ) {
|
| 98 |
+
setIsOpen( true );
|
| 99 |
+
setSkipSlideIn( false );
|
| 100 |
+
}
|
| 101 |
+
} }
|
| 102 |
+
>
|
| 103 |
+
{ sprintf(
|
| 104 |
+
/* translators: %d is the count of items in the cart. */
|
| 105 |
+
_n(
|
| 106 |
+
'%d item',
|
| 107 |
+
'%d items',
|
| 108 |
+
cartItemsCount,
|
| 109 |
+
'woo-gutenberg-products-block'
|
| 110 |
+
),
|
| 111 |
+
cartItemsCount
|
| 112 |
+
) }
|
| 113 |
+
</button>
|
| 114 |
+
<Drawer
|
| 115 |
+
className={ classNames(
|
| 116 |
+
'wc-block-mini-cart__drawer',
|
| 117 |
+
'is-mobile',
|
| 118 |
+
{
|
| 119 |
+
'is-loading': cartIsLoading,
|
| 120 |
+
}
|
| 121 |
+
) }
|
| 122 |
+
title={
|
| 123 |
+
cartIsLoading
|
| 124 |
+
? __( 'Your cart', 'woo-gutenberg-products-block' )
|
| 125 |
+
: sprintf(
|
| 126 |
+
/* translators: %d is the count of items in the cart. */
|
| 127 |
+
_n(
|
| 128 |
+
'Your cart (%d item)',
|
| 129 |
+
'Your cart (%d items)',
|
| 130 |
+
cartItemsCount,
|
| 131 |
+
'woo-gutenberg-products-block'
|
| 132 |
+
),
|
| 133 |
+
cartItemsCount
|
| 134 |
+
)
|
| 135 |
+
}
|
| 136 |
+
isOpen={ isOpen }
|
| 137 |
+
onClose={ () => {
|
| 138 |
+
setIsOpen( false );
|
| 139 |
+
} }
|
| 140 |
+
slideIn={ ! skipSlideIn }
|
| 141 |
+
>
|
| 142 |
+
{ contents }
|
| 143 |
+
</Drawer>
|
| 144 |
+
</>
|
| 145 |
+
);
|
| 146 |
+
};
|
| 147 |
+
|
| 148 |
+
export default MiniCartBlock;
|
assets/js/blocks/cart-checkout/mini-cart/component-frontend.tsx
CHANGED
|
@@ -1,130 +1,15 @@
|
|
| 1 |
/**
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
-
import
|
| 5 |
-
import { __, _n, sprintf } from '@wordpress/i18n';
|
| 6 |
-
import { useState, useEffect } from '@wordpress/element';
|
| 7 |
-
import { dispatch } from '@wordpress/data';
|
| 8 |
-
import {
|
| 9 |
-
translateJQueryEventToNative,
|
| 10 |
-
renderFrontend,
|
| 11 |
-
} from '@woocommerce/base-utils';
|
| 12 |
-
import { useStoreCart } from '@woocommerce/base-context/hooks';
|
| 13 |
-
import Drawer from '@woocommerce/base-components/drawer';
|
| 14 |
-
import { CART_STORE_KEY as storeKey } from '@woocommerce/block-data';
|
| 15 |
|
| 16 |
/**
|
| 17 |
* Internal dependencies
|
| 18 |
*/
|
| 19 |
-
import CartLineItemsTable from '../cart/full-cart/cart-line-items-table';
|
| 20 |
import withMiniCartConditionalHydration from './with-mini-cart-conditional-hydration';
|
|
|
|
| 21 |
import './style.scss';
|
| 22 |
|
| 23 |
-
interface MiniCartBlockProps {
|
| 24 |
-
isPlaceholderOpen?: boolean;
|
| 25 |
-
}
|
| 26 |
-
|
| 27 |
-
const MiniCartBlock = ( {
|
| 28 |
-
isPlaceholderOpen = false,
|
| 29 |
-
}: MiniCartBlockProps ): JSX.Element => {
|
| 30 |
-
const { cartItems, cartItemsCount, cartIsLoading } = useStoreCart();
|
| 31 |
-
const [ isOpen, setIsOpen ] = useState< boolean >( isPlaceholderOpen );
|
| 32 |
-
// We already rendered the HTML drawer placeholder, so we want to skip the
|
| 33 |
-
// slide in animation.
|
| 34 |
-
const [ skipSlideIn, setSkipSlideIn ] = useState< boolean >(
|
| 35 |
-
isPlaceholderOpen
|
| 36 |
-
);
|
| 37 |
-
|
| 38 |
-
useEffect( () => {
|
| 39 |
-
const openMiniCartAndRefreshData = () => {
|
| 40 |
-
dispatch( storeKey ).invalidateResolutionForStore();
|
| 41 |
-
setSkipSlideIn( false );
|
| 42 |
-
setIsOpen( true );
|
| 43 |
-
};
|
| 44 |
-
|
| 45 |
-
// Make it so we can read jQuery events triggered by WC Core elements.
|
| 46 |
-
const removeJQueryAddedToCartEvent = translateJQueryEventToNative(
|
| 47 |
-
'added_to_cart',
|
| 48 |
-
'wc-blocks_added_to_cart'
|
| 49 |
-
);
|
| 50 |
-
|
| 51 |
-
document.body.addEventListener(
|
| 52 |
-
'wc-blocks_added_to_cart',
|
| 53 |
-
openMiniCartAndRefreshData
|
| 54 |
-
);
|
| 55 |
-
|
| 56 |
-
return () => {
|
| 57 |
-
removeJQueryAddedToCartEvent();
|
| 58 |
-
|
| 59 |
-
document.body.removeEventListener(
|
| 60 |
-
'wc-blocks_added_to_cart',
|
| 61 |
-
openMiniCartAndRefreshData
|
| 62 |
-
);
|
| 63 |
-
};
|
| 64 |
-
}, [] );
|
| 65 |
-
|
| 66 |
-
const contents =
|
| 67 |
-
! cartIsLoading && cartItems.length === 0 ? (
|
| 68 |
-
<>{ __( 'Cart is empty', 'woo-gutenberg-products-block' ) }</>
|
| 69 |
-
) : (
|
| 70 |
-
<CartLineItemsTable
|
| 71 |
-
lineItems={ cartItems }
|
| 72 |
-
isLoading={ cartIsLoading }
|
| 73 |
-
/>
|
| 74 |
-
);
|
| 75 |
-
|
| 76 |
-
return (
|
| 77 |
-
<>
|
| 78 |
-
<button
|
| 79 |
-
className="wc-block-mini-cart__button"
|
| 80 |
-
onClick={ () => {
|
| 81 |
-
if ( ! isOpen ) {
|
| 82 |
-
setIsOpen( true );
|
| 83 |
-
setSkipSlideIn( false );
|
| 84 |
-
}
|
| 85 |
-
} }
|
| 86 |
-
>
|
| 87 |
-
{ sprintf(
|
| 88 |
-
/* translators: %d is the count of items in the cart. */
|
| 89 |
-
_n(
|
| 90 |
-
'%d item',
|
| 91 |
-
'%d items',
|
| 92 |
-
cartItemsCount,
|
| 93 |
-
'woo-gutenberg-products-block'
|
| 94 |
-
),
|
| 95 |
-
cartItemsCount
|
| 96 |
-
) }
|
| 97 |
-
</button>
|
| 98 |
-
<Drawer
|
| 99 |
-
className={ classNames(
|
| 100 |
-
'wc-block-mini-cart__drawer',
|
| 101 |
-
'is-mobile',
|
| 102 |
-
{
|
| 103 |
-
'is-loading': cartIsLoading,
|
| 104 |
-
}
|
| 105 |
-
) }
|
| 106 |
-
title={ sprintf(
|
| 107 |
-
/* translators: %d is the count of items in the cart. */
|
| 108 |
-
_n(
|
| 109 |
-
'Your cart (%d item)',
|
| 110 |
-
'Your cart (%d items)',
|
| 111 |
-
cartItemsCount,
|
| 112 |
-
'woo-gutenberg-products-block'
|
| 113 |
-
),
|
| 114 |
-
cartItemsCount
|
| 115 |
-
) }
|
| 116 |
-
isOpen={ isOpen }
|
| 117 |
-
onClose={ () => {
|
| 118 |
-
setIsOpen( false );
|
| 119 |
-
} }
|
| 120 |
-
slideIn={ ! skipSlideIn }
|
| 121 |
-
>
|
| 122 |
-
{ contents }
|
| 123 |
-
</Drawer>
|
| 124 |
-
</>
|
| 125 |
-
);
|
| 126 |
-
};
|
| 127 |
-
|
| 128 |
const renderMiniCartFrontend = () => {
|
| 129 |
// Check if button is focused. In that case, we want to refocus it after we
|
| 130 |
// replace it with the React equivalent.
|
|
@@ -146,7 +31,7 @@ const renderMiniCartFrontend = () => {
|
|
| 146 |
Block: withMiniCartConditionalHydration( MiniCartBlock ),
|
| 147 |
getProps: ( el: HTMLElement ) => ( {
|
| 148 |
isDataOutdated: el.dataset.isDataOutdated,
|
| 149 |
-
isPlaceholderOpen: el.dataset.isPlaceholderOpen,
|
| 150 |
} ),
|
| 151 |
} );
|
| 152 |
|
| 1 |
/**
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
+
import { renderFrontend } from '@woocommerce/base-utils';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
/**
|
| 7 |
* Internal dependencies
|
| 8 |
*/
|
|
|
|
| 9 |
import withMiniCartConditionalHydration from './with-mini-cart-conditional-hydration';
|
| 10 |
+
import MiniCartBlock from './block';
|
| 11 |
import './style.scss';
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
const renderMiniCartFrontend = () => {
|
| 14 |
// Check if button is focused. In that case, we want to refocus it after we
|
| 15 |
// replace it with the React equivalent.
|
| 31 |
Block: withMiniCartConditionalHydration( MiniCartBlock ),
|
| 32 |
getProps: ( el: HTMLElement ) => ( {
|
| 33 |
isDataOutdated: el.dataset.isDataOutdated,
|
| 34 |
+
isPlaceholderOpen: el.dataset.isPlaceholderOpen === 'true',
|
| 35 |
} ),
|
| 36 |
} );
|
| 37 |
|
assets/js/blocks/cart-checkout/mini-cart/frontend.ts
CHANGED
|
@@ -91,6 +91,9 @@ window.onload = () => {
|
|
| 91 |
}
|
| 92 |
|
| 93 |
const showContents = () => {
|
|
|
|
|
|
|
|
|
|
| 94 |
document.body.removeEventListener(
|
| 95 |
'wc-blocks_added_to_cart',
|
| 96 |
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
| 91 |
}
|
| 92 |
|
| 93 |
const showContents = () => {
|
| 94 |
+
if ( ! wasLoadScriptsCalled ) {
|
| 95 |
+
loadScripts();
|
| 96 |
+
}
|
| 97 |
document.body.removeEventListener(
|
| 98 |
'wc-blocks_added_to_cart',
|
| 99 |
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
assets/js/blocks/cart-checkout/mini-cart/index.tsx
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
*/
|
| 4 |
import { __ } from '@wordpress/i18n';
|
| 5 |
import { Icon, cart } from '@woocommerce/icons';
|
| 6 |
-
import {
|
| 7 |
|
| 8 |
/**
|
| 9 |
* Internal dependencies
|
|
@@ -47,4 +47,4 @@ const settings = {
|
|
| 47 |
},
|
| 48 |
};
|
| 49 |
|
| 50 |
-
|
| 3 |
*/
|
| 4 |
import { __ } from '@wordpress/i18n';
|
| 5 |
import { Icon, cart } from '@woocommerce/icons';
|
| 6 |
+
import { registerExperimentalBlockType } from '@woocommerce/block-settings';
|
| 7 |
|
| 8 |
/**
|
| 9 |
* Internal dependencies
|
| 47 |
},
|
| 48 |
};
|
| 49 |
|
| 50 |
+
registerExperimentalBlockType( 'woocommerce/mini-cart', settings );
|
assets/js/blocks/cart-checkout/payment-methods/test/payment-methods.js
CHANGED
|
@@ -11,6 +11,16 @@ import {
|
|
| 11 |
usePaymentMethodDataContext,
|
| 12 |
} from '@woocommerce/base-context';
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
/**
|
| 15 |
* Internal dependencies
|
| 16 |
*/
|
| 11 |
usePaymentMethodDataContext,
|
| 12 |
} from '@woocommerce/base-context';
|
| 13 |
|
| 14 |
+
/**
|
| 15 |
+
* Internal dependencies
|
| 16 |
+
*/
|
| 17 |
+
import * as useStoreCartHook from '../../../../base/context/hooks/cart/use-store-cart';
|
| 18 |
+
|
| 19 |
+
// Somewhere in your test case or test suite
|
| 20 |
+
useStoreCartHook.useStoreCart = jest
|
| 21 |
+
.fn()
|
| 22 |
+
.mockReturnValue( useStoreCartHook.defaultCartData );
|
| 23 |
+
|
| 24 |
/**
|
| 25 |
* Internal dependencies
|
| 26 |
*/
|
assets/js/blocks/price-filter/block.js
CHANGED
|
@@ -151,7 +151,9 @@ const PriceFilterBlock = ( { attributes, isEditor = false } ) => {
|
|
| 151 |
return (
|
| 152 |
<>
|
| 153 |
{ ! isEditor && attributes.heading && (
|
| 154 |
-
<TagName
|
|
|
|
|
|
|
| 155 |
) }
|
| 156 |
<div className="wc-block-price-slider">
|
| 157 |
<PriceSlider
|
| 151 |
return (
|
| 152 |
<>
|
| 153 |
{ ! isEditor && attributes.heading && (
|
| 154 |
+
<TagName className="wc-block-price-filter__title">
|
| 155 |
+
{ attributes.heading }
|
| 156 |
+
</TagName>
|
| 157 |
) }
|
| 158 |
<div className="wc-block-price-slider">
|
| 159 |
<PriceSlider
|
assets/js/blocks/price-filter/edit.js
CHANGED
|
@@ -158,6 +158,7 @@ export default function ( { attributes, setAttributes } ) {
|
|
| 158 |
<div className={ className }>
|
| 159 |
{ getInspectorControls() }
|
| 160 |
<BlockTitle
|
|
|
|
| 161 |
headingLevel={ headingLevel }
|
| 162 |
heading={ heading }
|
| 163 |
onChange={ ( value ) =>
|
| 158 |
<div className={ className }>
|
| 159 |
{ getInspectorControls() }
|
| 160 |
<BlockTitle
|
| 161 |
+
className="wc-block-price-filter__title"
|
| 162 |
headingLevel={ headingLevel }
|
| 163 |
heading={ heading }
|
| 164 |
onChange={ ( value ) =>
|
assets/js/blocks/product-category/block.js
CHANGED
|
@@ -22,6 +22,19 @@ import { gridBlockPreview } from '@woocommerce/resource-previews';
|
|
| 22 |
import { Icon, folder } from '@woocommerce/icons';
|
| 23 |
import { getSetting } from '@woocommerce/settings';
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
/**
|
| 26 |
* Component to handle edit mode of "Products by Category".
|
| 27 |
*/
|
|
@@ -250,21 +263,7 @@ class ProductByCategoryBlock extends Component {
|
|
| 250 |
<ServerSideRender
|
| 251 |
block={ name }
|
| 252 |
attributes={ attributes }
|
| 253 |
-
EmptyResponsePlaceholder={
|
| 254 |
-
<Placeholder
|
| 255 |
-
icon={ <Icon srcElement={ folder } /> }
|
| 256 |
-
label={ __(
|
| 257 |
-
'Products by Category',
|
| 258 |
-
'woo-gutenberg-products-block'
|
| 259 |
-
) }
|
| 260 |
-
className="wc-block-products-grid wc-block-products-category"
|
| 261 |
-
>
|
| 262 |
-
{ __(
|
| 263 |
-
'No products were found that matched your selection.',
|
| 264 |
-
'woo-gutenberg-products-block'
|
| 265 |
-
) }
|
| 266 |
-
</Placeholder>
|
| 267 |
-
) }
|
| 268 |
/>
|
| 269 |
) : (
|
| 270 |
__(
|
| 22 |
import { Icon, folder } from '@woocommerce/icons';
|
| 23 |
import { getSetting } from '@woocommerce/settings';
|
| 24 |
|
| 25 |
+
const EmptyPlaceholder = () => (
|
| 26 |
+
<Placeholder
|
| 27 |
+
icon={ <Icon srcElement={ folder } /> }
|
| 28 |
+
label={ __( 'Products by Category', 'woo-gutenberg-products-block' ) }
|
| 29 |
+
className="wc-block-products-grid wc-block-products-category"
|
| 30 |
+
>
|
| 31 |
+
{ __(
|
| 32 |
+
'No products were found that matched your selection.',
|
| 33 |
+
'woo-gutenberg-products-block'
|
| 34 |
+
) }
|
| 35 |
+
</Placeholder>
|
| 36 |
+
);
|
| 37 |
+
|
| 38 |
/**
|
| 39 |
* Component to handle edit mode of "Products by Category".
|
| 40 |
*/
|
| 263 |
<ServerSideRender
|
| 264 |
block={ name }
|
| 265 |
attributes={ attributes }
|
| 266 |
+
EmptyResponsePlaceholder={ EmptyPlaceholder }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 267 |
/>
|
| 268 |
) : (
|
| 269 |
__(
|
assets/js/blocks/reviews/all-reviews/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { Icon, discussion } from '@woocommerce/icons';
|
|
| 9 |
* Internal dependencies
|
| 10 |
*/
|
| 11 |
import '../editor.scss';
|
| 12 |
-
import
|
| 13 |
import sharedAttributes from '../attributes';
|
| 14 |
import save from '../save.js';
|
| 15 |
import { example } from '../example';
|
|
@@ -19,6 +19,7 @@ import { example } from '../example';
|
|
| 19 |
* This block lists all product reviews.
|
| 20 |
*/
|
| 21 |
registerBlockType( 'woocommerce/all-reviews', {
|
|
|
|
| 22 |
title: __( 'All Reviews', 'woo-gutenberg-products-block' ),
|
| 23 |
icon: {
|
| 24 |
src: <Icon srcElement={ discussion } />,
|
|
@@ -32,6 +33,12 @@ registerBlockType( 'woocommerce/all-reviews', {
|
|
| 32 |
),
|
| 33 |
supports: {
|
| 34 |
html: false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
},
|
| 36 |
example: {
|
| 37 |
...example,
|
|
@@ -72,17 +79,6 @@ registerBlockType( 'woocommerce/all-reviews', {
|
|
| 72 |
],
|
| 73 |
},
|
| 74 |
|
| 75 |
-
|
| 76 |
-
* Renders and manages the block.
|
| 77 |
-
*
|
| 78 |
-
* @param {Object} props Props to pass to block.
|
| 79 |
-
*/
|
| 80 |
-
edit( props ) {
|
| 81 |
-
return <Editor { ...props } />;
|
| 82 |
-
},
|
| 83 |
-
|
| 84 |
-
/**
|
| 85 |
-
* Save the props to post content.
|
| 86 |
-
*/
|
| 87 |
save,
|
| 88 |
} );
|
| 9 |
* Internal dependencies
|
| 10 |
*/
|
| 11 |
import '../editor.scss';
|
| 12 |
+
import edit from './edit';
|
| 13 |
import sharedAttributes from '../attributes';
|
| 14 |
import save from '../save.js';
|
| 15 |
import { example } from '../example';
|
| 19 |
* This block lists all product reviews.
|
| 20 |
*/
|
| 21 |
registerBlockType( 'woocommerce/all-reviews', {
|
| 22 |
+
apiVersion: 2,
|
| 23 |
title: __( 'All Reviews', 'woo-gutenberg-products-block' ),
|
| 24 |
icon: {
|
| 25 |
src: <Icon srcElement={ discussion } />,
|
| 33 |
),
|
| 34 |
supports: {
|
| 35 |
html: false,
|
| 36 |
+
color: {
|
| 37 |
+
background: false,
|
| 38 |
+
},
|
| 39 |
+
typography: {
|
| 40 |
+
fontSize: true,
|
| 41 |
+
},
|
| 42 |
},
|
| 43 |
example: {
|
| 44 |
...example,
|
| 79 |
],
|
| 80 |
},
|
| 81 |
|
| 82 |
+
edit,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
save,
|
| 84 |
} );
|
assets/js/blocks/reviews/editor-container-block.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { Component } from 'react';
|
| 6 |
import PropTypes from 'prop-types';
|
| 7 |
import { debounce } from 'lodash';
|
| 8 |
import { Placeholder } from '@wordpress/components';
|
|
|
|
| 9 |
|
| 10 |
/**
|
| 11 |
* Internal dependencies
|
|
@@ -13,13 +13,37 @@ import { Placeholder } from '@wordpress/components';
|
|
| 13 |
import EditorBlock from './editor-block.js';
|
| 14 |
import { getBlockClassName, getSortArgs } from './utils.js';
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
|
|
|
| 23 |
return (
|
| 24 |
<Placeholder icon={ icon } label={ name }>
|
| 25 |
{ __(
|
|
@@ -30,54 +54,27 @@ class EditorContainerBlock extends Component {
|
|
| 30 |
);
|
| 31 |
}
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
! showReviewContent &&
|
| 49 |
-
! showReviewRating &&
|
| 50 |
-
! showReviewDate &&
|
| 51 |
-
! showReviewerName &&
|
| 52 |
-
! showReviewImage &&
|
| 53 |
-
! showProductName;
|
| 54 |
-
|
| 55 |
-
if ( isAllContentHidden ) {
|
| 56 |
-
return this.renderHiddenContentPlaceholder();
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
return (
|
| 60 |
-
<div className={ getBlockClassName( attributes ) }>
|
| 61 |
-
<EditorBlock
|
| 62 |
-
attributes={ attributes }
|
| 63 |
-
categoryIds={ categoryIds }
|
| 64 |
-
delayFunction={ ( callback ) => debounce( callback, 400 ) }
|
| 65 |
-
noReviewsPlaceholder={ noReviewsPlaceholder }
|
| 66 |
-
orderby={ orderby }
|
| 67 |
-
order={ order }
|
| 68 |
-
productId={ productId }
|
| 69 |
-
reviewsToDisplay={ reviewsOnPageLoad }
|
| 70 |
-
/>
|
| 71 |
-
</div>
|
| 72 |
-
);
|
| 73 |
-
}
|
| 74 |
-
}
|
| 75 |
|
| 76 |
EditorContainerBlock.propTypes = {
|
| 77 |
attributes: PropTypes.object.isRequired,
|
| 78 |
icon: PropTypes.node.isRequired,
|
| 79 |
name: PropTypes.string.isRequired,
|
| 80 |
-
noReviewsPlaceholder: PropTypes.
|
| 81 |
className: PropTypes.string,
|
| 82 |
};
|
| 83 |
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import { __ } from '@wordpress/i18n';
|
|
|
|
| 5 |
import PropTypes from 'prop-types';
|
| 6 |
import { debounce } from 'lodash';
|
| 7 |
import { Placeholder } from '@wordpress/components';
|
| 8 |
+
import { useBlockProps } from '@wordpress/block-editor';
|
| 9 |
|
| 10 |
/**
|
| 11 |
* Internal dependencies
|
| 13 |
import EditorBlock from './editor-block.js';
|
| 14 |
import { getBlockClassName, getSortArgs } from './utils.js';
|
| 15 |
|
| 16 |
+
const EditorContainerBlock = ( {
|
| 17 |
+
attributes,
|
| 18 |
+
icon,
|
| 19 |
+
name,
|
| 20 |
+
noReviewsPlaceholder,
|
| 21 |
+
} ) => {
|
| 22 |
+
const {
|
| 23 |
+
categoryIds,
|
| 24 |
+
productId,
|
| 25 |
+
reviewsOnPageLoad,
|
| 26 |
+
showProductName,
|
| 27 |
+
showReviewDate,
|
| 28 |
+
showReviewerName,
|
| 29 |
+
showReviewContent,
|
| 30 |
+
showReviewImage,
|
| 31 |
+
showReviewRating,
|
| 32 |
+
} = attributes;
|
| 33 |
+
const { order, orderby } = getSortArgs( attributes.orderby );
|
| 34 |
+
const isAllContentHidden =
|
| 35 |
+
! showReviewContent &&
|
| 36 |
+
! showReviewRating &&
|
| 37 |
+
! showReviewDate &&
|
| 38 |
+
! showReviewerName &&
|
| 39 |
+
! showReviewImage &&
|
| 40 |
+
! showProductName;
|
| 41 |
+
|
| 42 |
+
const blockProps = useBlockProps( {
|
| 43 |
+
className: getBlockClassName( attributes ),
|
| 44 |
+
} );
|
| 45 |
|
| 46 |
+
if ( isAllContentHidden ) {
|
| 47 |
return (
|
| 48 |
<Placeholder icon={ icon } label={ name }>
|
| 49 |
{ __(
|
| 54 |
);
|
| 55 |
}
|
| 56 |
|
| 57 |
+
return (
|
| 58 |
+
<div { ...blockProps }>
|
| 59 |
+
<EditorBlock
|
| 60 |
+
attributes={ attributes }
|
| 61 |
+
categoryIds={ categoryIds }
|
| 62 |
+
delayFunction={ ( callback ) => debounce( callback, 400 ) }
|
| 63 |
+
noReviewsPlaceholder={ noReviewsPlaceholder }
|
| 64 |
+
orderby={ orderby }
|
| 65 |
+
order={ order }
|
| 66 |
+
productId={ productId }
|
| 67 |
+
reviewsToDisplay={ reviewsOnPageLoad }
|
| 68 |
+
/>
|
| 69 |
+
</div>
|
| 70 |
+
);
|
| 71 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
EditorContainerBlock.propTypes = {
|
| 74 |
attributes: PropTypes.object.isRequired,
|
| 75 |
icon: PropTypes.node.isRequired,
|
| 76 |
name: PropTypes.string.isRequired,
|
| 77 |
+
noReviewsPlaceholder: PropTypes.element.isRequired,
|
| 78 |
className: PropTypes.string,
|
| 79 |
};
|
| 80 |
|
assets/js/blocks/reviews/reviews-by-category/edit.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
/**
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
-
import { __
|
| 5 |
import { InspectorControls } from '@wordpress/block-editor';
|
| 6 |
import {
|
| 7 |
Button,
|
|
@@ -10,11 +10,9 @@ import {
|
|
| 10 |
ToggleControl,
|
| 11 |
withSpokenMessages,
|
| 12 |
} from '@wordpress/components';
|
| 13 |
-
import { SearchListItem } from '@woocommerce/components';
|
| 14 |
import PropTypes from 'prop-types';
|
| 15 |
import ProductCategoryControl from '@woocommerce/editor-components/product-category-control';
|
| 16 |
import { Icon, review } from '@woocommerce/icons';
|
| 17 |
-
import classNames from 'classnames';
|
| 18 |
|
| 19 |
/**
|
| 20 |
* Internal dependencies
|
|
@@ -42,39 +40,6 @@ const ReviewsByCategoryEditor = ( {
|
|
| 42 |
} ) => {
|
| 43 |
const { editMode, categoryIds } = attributes;
|
| 44 |
|
| 45 |
-
const renderCategoryControlItem = ( args ) => {
|
| 46 |
-
const { item, search, depth = 0 } = args;
|
| 47 |
-
|
| 48 |
-
const accessibleName = ! item.breadcrumbs.length
|
| 49 |
-
? item.name
|
| 50 |
-
: `${ item.breadcrumbs.join( ', ' ) }, ${ item.name }`;
|
| 51 |
-
|
| 52 |
-
return (
|
| 53 |
-
<SearchListItem
|
| 54 |
-
className={ classNames(
|
| 55 |
-
'woocommerce-product-categories__item',
|
| 56 |
-
'has-count',
|
| 57 |
-
{
|
| 58 |
-
'is-searching': search.length > 0,
|
| 59 |
-
'is-skip-level': depth === 0 && item.parent !== 0,
|
| 60 |
-
}
|
| 61 |
-
) }
|
| 62 |
-
{ ...args }
|
| 63 |
-
aria-label={ sprintf(
|
| 64 |
-
/* translators: %1$s is the search term name, %2$d is the number of products returned for search query. */
|
| 65 |
-
_n(
|
| 66 |
-
'%1$s, has %2$d product',
|
| 67 |
-
'%1$s, has %2$d products',
|
| 68 |
-
item.count,
|
| 69 |
-
'woo-gutenberg-products-block'
|
| 70 |
-
),
|
| 71 |
-
accessibleName,
|
| 72 |
-
item.count
|
| 73 |
-
) }
|
| 74 |
-
/>
|
| 75 |
-
);
|
| 76 |
-
};
|
| 77 |
-
|
| 78 |
const getInspectorControls = () => {
|
| 79 |
return (
|
| 80 |
<InspectorControls key="inspector">
|
|
@@ -88,7 +53,6 @@ const ReviewsByCategoryEditor = ( {
|
|
| 88 |
const ids = value.map( ( { id } ) => id );
|
| 89 |
setAttributes( { categoryIds: ids } );
|
| 90 |
} }
|
| 91 |
-
renderItem={ renderCategoryControlItem }
|
| 92 |
isCompact={ true }
|
| 93 |
showReviewCount={ true }
|
| 94 |
/>
|
| 1 |
/**
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
+
import { __ } from '@wordpress/i18n';
|
| 5 |
import { InspectorControls } from '@wordpress/block-editor';
|
| 6 |
import {
|
| 7 |
Button,
|
| 10 |
ToggleControl,
|
| 11 |
withSpokenMessages,
|
| 12 |
} from '@wordpress/components';
|
|
|
|
| 13 |
import PropTypes from 'prop-types';
|
| 14 |
import ProductCategoryControl from '@woocommerce/editor-components/product-category-control';
|
| 15 |
import { Icon, review } from '@woocommerce/icons';
|
|
|
|
| 16 |
|
| 17 |
/**
|
| 18 |
* Internal dependencies
|
| 40 |
} ) => {
|
| 41 |
const { editMode, categoryIds } = attributes;
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
const getInspectorControls = () => {
|
| 44 |
return (
|
| 45 |
<InspectorControls key="inspector">
|
| 53 |
const ids = value.map( ( { id } ) => id );
|
| 54 |
setAttributes( { categoryIds: ids } );
|
| 55 |
} }
|
|
|
|
| 56 |
isCompact={ true }
|
| 57 |
showReviewCount={ true }
|
| 58 |
/>
|
assets/js/blocks/reviews/reviews-by-category/index.js
CHANGED
|
@@ -17,6 +17,7 @@ import { example } from '../example';
|
|
| 17 |
* Register and run the "Reviews by category" block.
|
| 18 |
*/
|
| 19 |
registerBlockType( 'woocommerce/reviews-by-category', {
|
|
|
|
| 20 |
title: __( 'Reviews by Category', 'woo-gutenberg-products-block' ),
|
| 21 |
icon: {
|
| 22 |
src: <Icon srcElement={ review } />,
|
|
@@ -30,6 +31,12 @@ registerBlockType( 'woocommerce/reviews-by-category', {
|
|
| 30 |
),
|
| 31 |
supports: {
|
| 32 |
html: false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
},
|
| 34 |
example: {
|
| 35 |
...example,
|
| 17 |
* Register and run the "Reviews by category" block.
|
| 18 |
*/
|
| 19 |
registerBlockType( 'woocommerce/reviews-by-category', {
|
| 20 |
+
apiVersion: 2,
|
| 21 |
title: __( 'Reviews by Category', 'woo-gutenberg-products-block' ),
|
| 22 |
icon: {
|
| 23 |
src: <Icon srcElement={ review } />,
|
| 31 |
),
|
| 32 |
supports: {
|
| 33 |
html: false,
|
| 34 |
+
color: {
|
| 35 |
+
background: false,
|
| 36 |
+
},
|
| 37 |
+
typography: {
|
| 38 |
+
fontSize: true,
|
| 39 |
+
},
|
| 40 |
},
|
| 41 |
example: {
|
| 42 |
...example,
|
assets/js/blocks/reviews/reviews-by-product/index.js
CHANGED
|
@@ -17,6 +17,7 @@ import { example } from '../example';
|
|
| 17 |
* Register and run the "Reviews by Product" block.
|
| 18 |
*/
|
| 19 |
registerBlockType( 'woocommerce/reviews-by-product', {
|
|
|
|
| 20 |
title: __( 'Reviews by Product', 'woo-gutenberg-products-block' ),
|
| 21 |
icon: {
|
| 22 |
src: <Icon srcElement={ comment } />,
|
|
@@ -30,6 +31,12 @@ registerBlockType( 'woocommerce/reviews-by-product', {
|
|
| 30 |
),
|
| 31 |
supports: {
|
| 32 |
html: false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
},
|
| 34 |
example: {
|
| 35 |
...example,
|
| 17 |
* Register and run the "Reviews by Product" block.
|
| 18 |
*/
|
| 19 |
registerBlockType( 'woocommerce/reviews-by-product', {
|
| 20 |
+
apiVersion: 2,
|
| 21 |
title: __( 'Reviews by Product', 'woo-gutenberg-products-block' ),
|
| 22 |
icon: {
|
| 23 |
src: <Icon srcElement={ comment } />,
|
| 31 |
),
|
| 32 |
supports: {
|
| 33 |
html: false,
|
| 34 |
+
color: {
|
| 35 |
+
background: false,
|
| 36 |
+
},
|
| 37 |
+
typography: {
|
| 38 |
+
fontSize: true,
|
| 39 |
+
},
|
| 40 |
},
|
| 41 |
example: {
|
| 42 |
...example,
|
assets/js/blocks/reviews/save.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
/**
|
| 2 |
* Internal dependencies
|
| 3 |
*/
|
|
@@ -7,7 +12,9 @@ import { getBlockClassName, getDataAttrs } from './utils.js';
|
|
| 7 |
export default ( { attributes } ) => {
|
| 8 |
return (
|
| 9 |
<div
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
{ ...getDataAttrs( attributes ) }
|
| 12 |
/>
|
| 13 |
);
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { useBlockProps } from '@wordpress/block-editor';
|
| 5 |
+
|
| 6 |
/**
|
| 7 |
* Internal dependencies
|
| 8 |
*/
|
| 12 |
export default ( { attributes } ) => {
|
| 13 |
return (
|
| 14 |
<div
|
| 15 |
+
{ ...useBlockProps.save( {
|
| 16 |
+
className: getBlockClassName( attributes ),
|
| 17 |
+
} ) }
|
| 18 |
{ ...getDataAttrs( attributes ) }
|
| 19 |
/>
|
| 20 |
);
|
assets/js/blocks/stock-filter/block.js
CHANGED
|
@@ -23,20 +23,6 @@ import { decodeEntities } from '@wordpress/html-entities';
|
|
| 23 |
import { previewOptions } from './preview';
|
| 24 |
import './style.scss';
|
| 25 |
|
| 26 |
-
const hideOutOfStockItems = getSetting( 'hideOutOfStockItems', false );
|
| 27 |
-
const { outofstock, ...otherStockStatusOptions } = getSetting(
|
| 28 |
-
'stockStatusOptions',
|
| 29 |
-
{}
|
| 30 |
-
);
|
| 31 |
-
const STOCK_STATUS_OPTIONS = hideOutOfStockItems
|
| 32 |
-
? otherStockStatusOptions
|
| 33 |
-
: { outofstock, ...otherStockStatusOptions };
|
| 34 |
-
// Filter added to handle if there are slugs without a corresponding name defined.
|
| 35 |
-
const initialOptions = Object.entries( STOCK_STATUS_OPTIONS )
|
| 36 |
-
.map( ( [ slug, name ] ) => ( { slug, name } ) )
|
| 37 |
-
.filter( ( status ) => !! status.name )
|
| 38 |
-
.sort( ( a, b ) => a.slug.localeCompare( b.slug ) );
|
| 39 |
-
|
| 40 |
/**
|
| 41 |
* Component displaying an stock status filter.
|
| 42 |
*
|
|
@@ -48,10 +34,29 @@ const StockStatusFilterBlock = ( {
|
|
| 48 |
attributes: blockAttributes,
|
| 49 |
isEditor = false,
|
| 50 |
} ) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
const [ checked, setChecked ] = useState( [] );
|
| 52 |
const [ displayedOptions, setDisplayedOptions ] = useState(
|
| 53 |
blockAttributes.isPreview ? previewOptions : []
|
| 54 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
const [ queryState ] = useQueryStateByContext();
|
| 57 |
const [
|
|
@@ -140,6 +145,7 @@ const StockStatusFilterBlock = ( {
|
|
| 140 |
getFilteredStock,
|
| 141 |
checked,
|
| 142 |
queryState.stock_status,
|
|
|
|
| 143 |
] );
|
| 144 |
|
| 145 |
const onSubmit = useCallback(
|
|
@@ -252,7 +258,9 @@ const StockStatusFilterBlock = ( {
|
|
| 252 |
return (
|
| 253 |
<>
|
| 254 |
{ ! isEditor && blockAttributes.heading && (
|
| 255 |
-
<TagName
|
|
|
|
|
|
|
| 256 |
) }
|
| 257 |
<div className="wc-block-stock-filter">
|
| 258 |
<CheckboxList
|
| 23 |
import { previewOptions } from './preview';
|
| 24 |
import './style.scss';
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
/**
|
| 27 |
* Component displaying an stock status filter.
|
| 28 |
*
|
| 34 |
attributes: blockAttributes,
|
| 35 |
isEditor = false,
|
| 36 |
} ) => {
|
| 37 |
+
const [ hideOutOfStockItems ] = useState(
|
| 38 |
+
getSetting( 'hideOutOfStockItems', false )
|
| 39 |
+
);
|
| 40 |
+
const [ { outofstock, ...otherStockStatusOptions } ] = useState(
|
| 41 |
+
getSetting( 'stockStatusOptions', {} )
|
| 42 |
+
);
|
| 43 |
+
const [ STOCK_STATUS_OPTIONS ] = useState(
|
| 44 |
+
hideOutOfStockItems
|
| 45 |
+
? otherStockStatusOptions
|
| 46 |
+
: { outofstock, ...otherStockStatusOptions }
|
| 47 |
+
);
|
| 48 |
+
|
| 49 |
const [ checked, setChecked ] = useState( [] );
|
| 50 |
const [ displayedOptions, setDisplayedOptions ] = useState(
|
| 51 |
blockAttributes.isPreview ? previewOptions : []
|
| 52 |
);
|
| 53 |
+
// Filter added to handle if there are slugs without a corresponding name defined.
|
| 54 |
+
const [ initialOptions ] = useState(
|
| 55 |
+
Object.entries( STOCK_STATUS_OPTIONS )
|
| 56 |
+
.map( ( [ slug, name ] ) => ( { slug, name } ) )
|
| 57 |
+
.filter( ( status ) => !! status.name )
|
| 58 |
+
.sort( ( a, b ) => a.slug.localeCompare( b.slug ) )
|
| 59 |
+
);
|
| 60 |
|
| 61 |
const [ queryState ] = useQueryStateByContext();
|
| 62 |
const [
|
| 145 |
getFilteredStock,
|
| 146 |
checked,
|
| 147 |
queryState.stock_status,
|
| 148 |
+
initialOptions,
|
| 149 |
] );
|
| 150 |
|
| 151 |
const onSubmit = useCallback(
|
| 258 |
return (
|
| 259 |
<>
|
| 260 |
{ ! isEditor && blockAttributes.heading && (
|
| 261 |
+
<TagName className="wc-block-stock-filter__title">
|
| 262 |
+
{ blockAttributes.heading }
|
| 263 |
+
</TagName>
|
| 264 |
) }
|
| 265 |
<div className="wc-block-stock-filter">
|
| 266 |
<CheckboxList
|
assets/js/blocks/stock-filter/edit.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import { __ } from '@wordpress/i18n';
|
|
|
|
| 5 |
import { InspectorControls } from '@wordpress/block-editor';
|
| 6 |
import {
|
| 7 |
Disabled,
|
|
@@ -110,8 +111,14 @@ const Edit = ( { attributes, setAttributes } ) => {
|
|
| 110 |
<>
|
| 111 |
{ getInspectorControls() }
|
| 112 |
{
|
| 113 |
-
<div
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
<BlockTitle
|
|
|
|
| 115 |
headingLevel={ headingLevel }
|
| 116 |
heading={ heading }
|
| 117 |
onChange={ ( value ) =>
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import { __ } from '@wordpress/i18n';
|
| 5 |
+
import classnames from 'classnames';
|
| 6 |
import { InspectorControls } from '@wordpress/block-editor';
|
| 7 |
import {
|
| 8 |
Disabled,
|
| 111 |
<>
|
| 112 |
{ getInspectorControls() }
|
| 113 |
{
|
| 114 |
+
<div
|
| 115 |
+
className={ classnames(
|
| 116 |
+
'wc-block-stock-filter',
|
| 117 |
+
className
|
| 118 |
+
) }
|
| 119 |
+
>
|
| 120 |
<BlockTitle
|
| 121 |
+
className="wc-block-stock-filter__title"
|
| 122 |
headingLevel={ headingLevel }
|
| 123 |
heading={ heading }
|
| 124 |
onChange={ ( value ) =>
|
assets/js/blocks/stock-filter/test/__snapshots__/block.js.snap
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
| 2 |
+
|
| 3 |
+
exports[`Testing stock filter renders the stock filter block 1`] = `
|
| 4 |
+
<div>
|
| 5 |
+
<div
|
| 6 |
+
class="wc-block-stock-filter"
|
| 7 |
+
>
|
| 8 |
+
<ul
|
| 9 |
+
class="wc-block-checkbox-list wc-block-components-checkbox-list wc-block-stock-filter-list"
|
| 10 |
+
>
|
| 11 |
+
<li>
|
| 12 |
+
<input
|
| 13 |
+
id="instock"
|
| 14 |
+
type="checkbox"
|
| 15 |
+
value="instock"
|
| 16 |
+
/>
|
| 17 |
+
<label
|
| 18 |
+
for="instock"
|
| 19 |
+
>
|
| 20 |
+
In stock
|
| 21 |
+
</label>
|
| 22 |
+
</li>
|
| 23 |
+
<li>
|
| 24 |
+
<input
|
| 25 |
+
id="onbackorder"
|
| 26 |
+
type="checkbox"
|
| 27 |
+
value="onbackorder"
|
| 28 |
+
/>
|
| 29 |
+
<label
|
| 30 |
+
for="onbackorder"
|
| 31 |
+
>
|
| 32 |
+
On backorder
|
| 33 |
+
</label>
|
| 34 |
+
</li>
|
| 35 |
+
<li>
|
| 36 |
+
<input
|
| 37 |
+
id="outofstock"
|
| 38 |
+
type="checkbox"
|
| 39 |
+
value="outofstock"
|
| 40 |
+
/>
|
| 41 |
+
<label
|
| 42 |
+
for="outofstock"
|
| 43 |
+
>
|
| 44 |
+
Out of stock
|
| 45 |
+
</label>
|
| 46 |
+
</li>
|
| 47 |
+
</ul>
|
| 48 |
+
</div>
|
| 49 |
+
</div>
|
| 50 |
+
`;
|
| 51 |
+
|
| 52 |
+
exports[`Testing stock filter renders the stock filter block with the filter button 1`] = `
|
| 53 |
+
<div>
|
| 54 |
+
<div
|
| 55 |
+
class="wc-block-stock-filter"
|
| 56 |
+
>
|
| 57 |
+
<ul
|
| 58 |
+
class="wc-block-checkbox-list wc-block-components-checkbox-list wc-block-stock-filter-list"
|
| 59 |
+
>
|
| 60 |
+
<li>
|
| 61 |
+
<input
|
| 62 |
+
id="instock"
|
| 63 |
+
type="checkbox"
|
| 64 |
+
value="instock"
|
| 65 |
+
/>
|
| 66 |
+
<label
|
| 67 |
+
for="instock"
|
| 68 |
+
>
|
| 69 |
+
In stock
|
| 70 |
+
</label>
|
| 71 |
+
</li>
|
| 72 |
+
<li>
|
| 73 |
+
<input
|
| 74 |
+
id="onbackorder"
|
| 75 |
+
type="checkbox"
|
| 76 |
+
value="onbackorder"
|
| 77 |
+
/>
|
| 78 |
+
<label
|
| 79 |
+
for="onbackorder"
|
| 80 |
+
>
|
| 81 |
+
On backorder
|
| 82 |
+
</label>
|
| 83 |
+
</li>
|
| 84 |
+
<li>
|
| 85 |
+
<input
|
| 86 |
+
id="outofstock"
|
| 87 |
+
type="checkbox"
|
| 88 |
+
value="outofstock"
|
| 89 |
+
/>
|
| 90 |
+
<label
|
| 91 |
+
for="outofstock"
|
| 92 |
+
>
|
| 93 |
+
Out of stock
|
| 94 |
+
</label>
|
| 95 |
+
</li>
|
| 96 |
+
</ul>
|
| 97 |
+
<button
|
| 98 |
+
class="wc-block-filter-submit-button wc-block-components-filter-submit-button wc-block-stock-filter__button"
|
| 99 |
+
type="submit"
|
| 100 |
+
>
|
| 101 |
+
<span
|
| 102 |
+
aria-hidden="true"
|
| 103 |
+
>
|
| 104 |
+
Go
|
| 105 |
+
</span>
|
| 106 |
+
<span
|
| 107 |
+
class="screen-reader-text"
|
| 108 |
+
>
|
| 109 |
+
Apply filter
|
| 110 |
+
</span>
|
| 111 |
+
</button>
|
| 112 |
+
</div>
|
| 113 |
+
</div>
|
| 114 |
+
`;
|
| 115 |
+
|
| 116 |
+
exports[`Testing stock filter renders the stock filter block with the product counts 1`] = `
|
| 117 |
+
<div>
|
| 118 |
+
<div
|
| 119 |
+
class="wc-block-stock-filter"
|
| 120 |
+
>
|
| 121 |
+
<ul
|
| 122 |
+
class="wc-block-checkbox-list wc-block-components-checkbox-list wc-block-stock-filter-list"
|
| 123 |
+
>
|
| 124 |
+
<li>
|
| 125 |
+
<input
|
| 126 |
+
id="instock"
|
| 127 |
+
type="checkbox"
|
| 128 |
+
value="instock"
|
| 129 |
+
/>
|
| 130 |
+
<label
|
| 131 |
+
for="instock"
|
| 132 |
+
>
|
| 133 |
+
In stock
|
| 134 |
+
<span
|
| 135 |
+
class="wc-filter-element-label-list-count"
|
| 136 |
+
>
|
| 137 |
+
<span
|
| 138 |
+
aria-hidden="true"
|
| 139 |
+
>
|
| 140 |
+
18
|
| 141 |
+
</span>
|
| 142 |
+
<span
|
| 143 |
+
class="screen-reader-text"
|
| 144 |
+
>
|
| 145 |
+
18 products
|
| 146 |
+
</span>
|
| 147 |
+
</span>
|
| 148 |
+
</label>
|
| 149 |
+
</li>
|
| 150 |
+
<li>
|
| 151 |
+
<input
|
| 152 |
+
id="onbackorder"
|
| 153 |
+
type="checkbox"
|
| 154 |
+
value="onbackorder"
|
| 155 |
+
/>
|
| 156 |
+
<label
|
| 157 |
+
for="onbackorder"
|
| 158 |
+
>
|
| 159 |
+
On backorder
|
| 160 |
+
<span
|
| 161 |
+
class="wc-filter-element-label-list-count"
|
| 162 |
+
>
|
| 163 |
+
<span
|
| 164 |
+
aria-hidden="true"
|
| 165 |
+
>
|
| 166 |
+
5
|
| 167 |
+
</span>
|
| 168 |
+
<span
|
| 169 |
+
class="screen-reader-text"
|
| 170 |
+
>
|
| 171 |
+
5 products
|
| 172 |
+
</span>
|
| 173 |
+
</span>
|
| 174 |
+
</label>
|
| 175 |
+
</li>
|
| 176 |
+
<li>
|
| 177 |
+
<input
|
| 178 |
+
id="outofstock"
|
| 179 |
+
type="checkbox"
|
| 180 |
+
value="outofstock"
|
| 181 |
+
/>
|
| 182 |
+
<label
|
| 183 |
+
for="outofstock"
|
| 184 |
+
>
|
| 185 |
+
Out of stock
|
| 186 |
+
<span
|
| 187 |
+
class="wc-filter-element-label-list-count"
|
| 188 |
+
>
|
| 189 |
+
<span
|
| 190 |
+
aria-hidden="true"
|
| 191 |
+
>
|
| 192 |
+
1
|
| 193 |
+
</span>
|
| 194 |
+
<span
|
| 195 |
+
class="screen-reader-text"
|
| 196 |
+
>
|
| 197 |
+
1 product
|
| 198 |
+
</span>
|
| 199 |
+
</span>
|
| 200 |
+
</label>
|
| 201 |
+
</li>
|
| 202 |
+
</ul>
|
| 203 |
+
</div>
|
| 204 |
+
</div>
|
| 205 |
+
`;
|
assets/js/blocks/stock-filter/test/block.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Internal dependencies
|
| 3 |
+
*/
|
| 4 |
+
|
| 5 |
+
/**
|
| 6 |
+
* External dependencies
|
| 7 |
+
*/
|
| 8 |
+
import { render } from '@testing-library/react';
|
| 9 |
+
import { default as fetchMock } from 'jest-fetch-mock';
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* Internal dependencies
|
| 13 |
+
*/
|
| 14 |
+
import Block from '../block';
|
| 15 |
+
import { allSettings } from '../../../settings/shared/settings-init';
|
| 16 |
+
|
| 17 |
+
const mockResults = {
|
| 18 |
+
stock_status_counts: [
|
| 19 |
+
{ status: 'instock', count: '18' },
|
| 20 |
+
{ status: 'outofstock', count: '1' },
|
| 21 |
+
{ status: 'onbackorder', count: '5' },
|
| 22 |
+
],
|
| 23 |
+
};
|
| 24 |
+
|
| 25 |
+
jest.mock( '@woocommerce/base-context/hooks', () => {
|
| 26 |
+
return {
|
| 27 |
+
...jest.requireActual( '@woocommerce/base-context/hooks' ),
|
| 28 |
+
useCollectionData: () => ( { isLoading: false, results: mockResults } ),
|
| 29 |
+
};
|
| 30 |
+
} );
|
| 31 |
+
|
| 32 |
+
const StockFilterBlock = ( props ) => <Block { ...props } />;
|
| 33 |
+
describe( 'Testing stock filter', () => {
|
| 34 |
+
beforeEach( () => {
|
| 35 |
+
allSettings.stockStatusOptions = {
|
| 36 |
+
instock: 'In stock',
|
| 37 |
+
outofstock: 'Out of stock',
|
| 38 |
+
onbackorder: 'On backorder',
|
| 39 |
+
};
|
| 40 |
+
} );
|
| 41 |
+
|
| 42 |
+
afterEach( () => {
|
| 43 |
+
fetchMock.resetMocks();
|
| 44 |
+
} );
|
| 45 |
+
|
| 46 |
+
it( 'renders the stock filter block', async () => {
|
| 47 |
+
const { container } = render(
|
| 48 |
+
<StockFilterBlock attributes={ { isPreview: false } } />
|
| 49 |
+
);
|
| 50 |
+
expect( container ).toMatchSnapshot();
|
| 51 |
+
} );
|
| 52 |
+
|
| 53 |
+
it( 'renders the stock filter block with the filter button', async () => {
|
| 54 |
+
const { container } = render(
|
| 55 |
+
<StockFilterBlock
|
| 56 |
+
attributes={ { isPreview: false, showFilterButton: true } }
|
| 57 |
+
/>
|
| 58 |
+
);
|
| 59 |
+
expect( container ).toMatchSnapshot();
|
| 60 |
+
} );
|
| 61 |
+
|
| 62 |
+
it( 'renders the stock filter block with the product counts', async () => {
|
| 63 |
+
const { container } = render(
|
| 64 |
+
<StockFilterBlock
|
| 65 |
+
attributes={ {
|
| 66 |
+
isPreview: false,
|
| 67 |
+
showCounts: true,
|
| 68 |
+
} }
|
| 69 |
+
/>
|
| 70 |
+
);
|
| 71 |
+
expect( container ).toMatchSnapshot();
|
| 72 |
+
} );
|
| 73 |
+
} );
|
assets/js/data/cart/action-types.ts
CHANGED
|
@@ -11,4 +11,6 @@ export const ACTION_TYPES = {
|
|
| 11 |
UPDATING_CUSTOMER_DATA: 'UPDATING_CUSTOMER_DATA',
|
| 12 |
UPDATING_SELECTED_SHIPPING_RATE: 'UPDATING_SELECTED_SHIPPING_RATE',
|
| 13 |
UPDATE_LEGACY_CART_FRAGMENTS: 'UPDATE_LEGACY_CART_FRAGMENTS',
|
|
|
|
|
|
|
| 14 |
} as const;
|
| 11 |
UPDATING_CUSTOMER_DATA: 'UPDATING_CUSTOMER_DATA',
|
| 12 |
UPDATING_SELECTED_SHIPPING_RATE: 'UPDATING_SELECTED_SHIPPING_RATE',
|
| 13 |
UPDATE_LEGACY_CART_FRAGMENTS: 'UPDATE_LEGACY_CART_FRAGMENTS',
|
| 14 |
+
TRIGGER_ADDING_TO_CART_EVENT: 'TRIGGER_ADDING_TO_CART_EVENT',
|
| 15 |
+
TRIGGER_ADDED_TO_CART_EVENT: 'TRIGGER_ADDED_TO_CART_EVENT',
|
| 16 |
} as const;
|
assets/js/data/cart/actions.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type {
|
|
| 12 |
} from '@woocommerce/types';
|
| 13 |
import { ReturnOrGeneratorYieldUnion } from '@automattic/data-stores';
|
| 14 |
import { camelCase, mapKeys } from 'lodash';
|
|
|
|
| 15 |
|
| 16 |
/**
|
| 17 |
* Internal dependencies
|
|
@@ -168,6 +169,25 @@ export const updateCartFragments = () =>
|
|
| 168 |
type: types.UPDATE_LEGACY_CART_FRAGMENTS,
|
| 169 |
} as const );
|
| 170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
/**
|
| 172 |
* POSTs to the /cart/extensions endpoint with the data supplied by the extension.
|
| 173 |
*
|
|
@@ -295,6 +315,7 @@ export function* addItemToCart(
|
|
| 295 |
quantity = 1
|
| 296 |
): Generator< unknown, void, { response: CartResponse } > {
|
| 297 |
try {
|
|
|
|
| 298 |
const { response } = yield apiFetchWithHeaders( {
|
| 299 |
path: `/wc/store/cart/add-item`,
|
| 300 |
method: 'POST',
|
|
@@ -306,6 +327,7 @@ export function* addItemToCart(
|
|
| 306 |
} );
|
| 307 |
|
| 308 |
yield receiveCart( response );
|
|
|
|
| 309 |
yield updateCartFragments();
|
| 310 |
} catch ( error ) {
|
| 311 |
yield receiveError( error );
|
| 12 |
} from '@woocommerce/types';
|
| 13 |
import { ReturnOrGeneratorYieldUnion } from '@automattic/data-stores';
|
| 14 |
import { camelCase, mapKeys } from 'lodash';
|
| 15 |
+
import type { AddToCartEventDetail } from '@woocommerce/type-defs/events';
|
| 16 |
|
| 17 |
/**
|
| 18 |
* Internal dependencies
|
| 169 |
type: types.UPDATE_LEGACY_CART_FRAGMENTS,
|
| 170 |
} as const );
|
| 171 |
|
| 172 |
+
/**
|
| 173 |
+
* Triggers an adding to cart event so other blocks can update accordingly.
|
| 174 |
+
*/
|
| 175 |
+
export const triggerAddingToCartEvent = () =>
|
| 176 |
+
( {
|
| 177 |
+
type: types.TRIGGER_ADDING_TO_CART_EVENT,
|
| 178 |
+
} as const );
|
| 179 |
+
|
| 180 |
+
/**
|
| 181 |
+
* Triggers an added to cart event so other blocks can update accordingly.
|
| 182 |
+
*/
|
| 183 |
+
export const triggerAddedToCartEvent = ( {
|
| 184 |
+
preserveCartData,
|
| 185 |
+
}: AddToCartEventDetail ) =>
|
| 186 |
+
( {
|
| 187 |
+
type: types.TRIGGER_ADDED_TO_CART_EVENT,
|
| 188 |
+
preserveCartData,
|
| 189 |
+
} as const );
|
| 190 |
+
|
| 191 |
/**
|
| 192 |
* POSTs to the /cart/extensions endpoint with the data supplied by the extension.
|
| 193 |
*
|
| 315 |
quantity = 1
|
| 316 |
): Generator< unknown, void, { response: CartResponse } > {
|
| 317 |
try {
|
| 318 |
+
yield triggerAddingToCartEvent();
|
| 319 |
const { response } = yield apiFetchWithHeaders( {
|
| 320 |
path: `/wc/store/cart/add-item`,
|
| 321 |
method: 'POST',
|
| 327 |
} );
|
| 328 |
|
| 329 |
yield receiveCart( response );
|
| 330 |
+
yield triggerAddedToCartEvent( { preserveCartData: true } );
|
| 331 |
yield updateCartFragments();
|
| 332 |
} catch ( error ) {
|
| 333 |
yield receiveError( error );
|
assets/js/data/cart/controls.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
| 1 |
/**
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
-
import {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
/**
|
| 7 |
* Default export for registering the controls with the store.
|
|
@@ -12,4 +16,10 @@ export const controls = {
|
|
| 12 |
UPDATE_LEGACY_CART_FRAGMENTS() {
|
| 13 |
triggerFragmentRefresh();
|
| 14 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
};
|
| 1 |
/**
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
+
import {
|
| 5 |
+
triggerFragmentRefresh,
|
| 6 |
+
triggerAddedToCartEvent,
|
| 7 |
+
triggerAddingToCartEvent,
|
| 8 |
+
} from '@woocommerce/base-utils';
|
| 9 |
|
| 10 |
/**
|
| 11 |
* Default export for registering the controls with the store.
|
| 16 |
UPDATE_LEGACY_CART_FRAGMENTS() {
|
| 17 |
triggerFragmentRefresh();
|
| 18 |
},
|
| 19 |
+
TRIGGER_ADDING_TO_CART_EVENT() {
|
| 20 |
+
triggerAddingToCartEvent();
|
| 21 |
+
},
|
| 22 |
+
TRIGGER_ADDED_TO_CART_EVENT( preserveCartData ) {
|
| 23 |
+
triggerAddedToCartEvent( preserveCartData );
|
| 24 |
+
},
|
| 25 |
};
|
assets/js/editor-components/block-title/index.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
| 3 |
*/
|
| 4 |
import PropTypes from 'prop-types';
|
| 5 |
import { PlainText } from '@wordpress/block-editor';
|
| 6 |
-
import classnames from 'classnames';
|
| 7 |
import { withInstanceId } from '@wordpress/compose';
|
| 8 |
import { __ } from '@wordpress/i18n';
|
| 9 |
|
|
@@ -21,7 +20,7 @@ const BlockTitle = ( {
|
|
| 21 |
} ) => {
|
| 22 |
const TagName = `h${ headingLevel }`;
|
| 23 |
return (
|
| 24 |
-
<TagName>
|
| 25 |
<label
|
| 26 |
className="screen-reader-text"
|
| 27 |
htmlFor={ `block-title-${ instanceId }` }
|
|
@@ -30,10 +29,7 @@ const BlockTitle = ( {
|
|
| 30 |
</label>
|
| 31 |
<PlainText
|
| 32 |
id={ `block-title-${ instanceId }` }
|
| 33 |
-
className=
|
| 34 |
-
'wc-block-editor-components-title',
|
| 35 |
-
className
|
| 36 |
-
) }
|
| 37 |
value={ heading }
|
| 38 |
onChange={ onChange }
|
| 39 |
/>
|
| 3 |
*/
|
| 4 |
import PropTypes from 'prop-types';
|
| 5 |
import { PlainText } from '@wordpress/block-editor';
|
|
|
|
| 6 |
import { withInstanceId } from '@wordpress/compose';
|
| 7 |
import { __ } from '@wordpress/i18n';
|
| 8 |
|
| 20 |
} ) => {
|
| 21 |
const TagName = `h${ headingLevel }`;
|
| 22 |
return (
|
| 23 |
+
<TagName className={ className }>
|
| 24 |
<label
|
| 25 |
className="screen-reader-text"
|
| 26 |
htmlFor={ `block-title-${ instanceId }` }
|
| 29 |
</label>
|
| 30 |
<PlainText
|
| 31 |
id={ `block-title-${ instanceId }` }
|
| 32 |
+
className="wc-block-editor-components-title"
|
|
|
|
|
|
|
|
|
|
| 33 |
value={ heading }
|
| 34 |
onChange={ onChange }
|
| 35 |
/>
|
assets/js/editor-components/external-link-card/editor.scss
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
.wc-block-editor-components-external-link-card {
|
| 2 |
-
display: block;
|
| 3 |
display: flex;
|
| 4 |
flex-direction: row;
|
| 5 |
text-decoration: none;
|
| 1 |
.wc-block-editor-components-external-link-card {
|
|
|
|
| 2 |
display: flex;
|
| 3 |
flex-direction: row;
|
| 4 |
text-decoration: none;
|
assets/js/editor-components/external-link-card/index.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import { __ } from '@wordpress/i18n';
|
| 5 |
-
import { Icon,
|
| 6 |
import { VisuallyHidden } from '@wordpress/components';
|
| 7 |
|
| 8 |
/**
|
|
@@ -46,7 +46,7 @@ const ExternalLinkCard = ( {
|
|
| 46 |
}
|
| 47 |
</VisuallyHidden>
|
| 48 |
<Icon
|
| 49 |
-
|
| 50 |
className="wc-block-editor-components-external-link-card__icon"
|
| 51 |
/>
|
| 52 |
</a>
|
| 2 |
* External dependencies
|
| 3 |
*/
|
| 4 |
import { __ } from '@wordpress/i18n';
|
| 5 |
+
import { Icon, external } from '@wordpress/icons';
|
| 6 |
import { VisuallyHidden } from '@wordpress/components';
|
| 7 |
|
| 8 |
/**
|
| 46 |
}
|
| 47 |
</VisuallyHidden>
|
| 48 |
<Icon
|
| 49 |
+
icon={ external }
|
| 50 |
className="wc-block-editor-components-external-link-card__icon"
|
| 51 |
/>
|
| 52 |
</a>
|
assets/js/icons/index.js
CHANGED
|
@@ -20,9 +20,11 @@ export { default as comment } from './library/comment';
|
|
| 20 |
export { default as contact } from './library/contact';
|
| 21 |
export { default as done } from './library/done';
|
| 22 |
export { default as discussion } from './library/discussion';
|
|
|
|
| 23 |
export { default as exclamation } from './library/exclamation';
|
| 24 |
export { default as external } from './library/external';
|
| 25 |
export { default as fields } from './library/fields';
|
|
|
|
| 26 |
export { default as folderStarred } from './library/folder-starred';
|
| 27 |
export { default as folder } from './library/folder';
|
| 28 |
export { default as formStep } from './library/form-step';
|
| 20 |
export { default as contact } from './library/contact';
|
| 21 |
export { default as done } from './library/done';
|
| 22 |
export { default as discussion } from './library/discussion';
|
| 23 |
+
export { default as eye } from './library/eye';
|
| 24 |
export { default as exclamation } from './library/exclamation';
|
| 25 |
export { default as external } from './library/external';
|
| 26 |
export { default as fields } from './library/fields';
|
| 27 |
+
export { default as filledCart } from './library/filled-cart';
|
| 28 |
export { default as folderStarred } from './library/folder-starred';
|
| 29 |
export { default as folder } from './library/folder';
|
| 30 |
export { default as formStep } from './library/form-step';
|
assets/js/icons/library/eye.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { SVG } from 'wordpress-components';
|
| 5 |
+
|
| 6 |
+
const eye = (
|
| 7 |
+
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
| 8 |
+
<path fill="none" d="M0 0h24v24H0V0z" />
|
| 9 |
+
<path d="M12 6a9.77 9.77 0 0 1 8.82 5.5C19.17 14.87 15.79 17 12 17s-7.17-2.13-8.82-5.5A9.77 9.77 0 0 1 12 6m0-2C7 4 2.73 7.11 1 11.5 2.73 15.89 7 19 12 19s9.27-3.11 11-7.5C21.27 7.11 17 4 12 4zm0 5a2.5 2.5 0 0 1 0 5 2.5 2.5 0 0 1 0-5m0-2c-2.48 0-4.5 2.02-4.5 4.5S9.52 16 12 16s4.5-2.02 4.5-4.5S14.48 7 12 7z" />
|
| 10 |
+
</SVG>
|
| 11 |
+
);
|
| 12 |
+
|
| 13 |
+
export default eye;
|
assets/js/icons/library/filled-cart.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import { SVG } from 'wordpress-components';
|
| 5 |
+
|
| 6 |
+
const filledCart = (
|
| 7 |
+
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
| 8 |
+
<g fill="none" fillRule="evenodd">
|
| 9 |
+
<path d="M0 0h24v24H0z" />
|
| 10 |
+
<path
|
| 11 |
+
fill="currentColor"
|
| 12 |
+
fillRule="nonzero"
|
| 13 |
+
d="M15.55 13c.75 0 1.41-.41 1.75-1.03l3.58-6.49A.996.996 0 0 0 20.01 4H5.21l-.94-2H1v2h2l3.6 7.59-1.35 2.44C4.52 15.37 5.48 17 7 17h12v-2H7l1.1-2h7.45ZM7 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"
|
| 14 |
+
/>
|
| 15 |
+
</g>{ ' ' }
|
| 16 |
+
</SVG>
|
| 17 |
+
);
|
| 18 |
+
|
| 19 |
+
export default filledCart;
|
assets/js/types/type-defs/cart-response.ts
CHANGED
|
@@ -26,6 +26,8 @@ export interface CartResponseCouponItemWithLabel
|
|
| 26 |
label: string;
|
| 27 |
}
|
| 28 |
|
|
|
|
|
|
|
| 29 |
export interface ResponseFirstNameLastName {
|
| 30 |
first_name: string;
|
| 31 |
last_name: string;
|
| 26 |
label: string;
|
| 27 |
}
|
| 28 |
|
| 29 |
+
export type CartResponseCoupons = CartResponseCouponItemWithLabel[];
|
| 30 |
+
|
| 31 |
export interface ResponseFirstNameLastName {
|
| 32 |
first_name: string;
|
| 33 |
last_name: string;
|
assets/js/types/type-defs/cart.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
| 6 |
ShippingRateItem,
|
| 7 |
ExtensionsData,
|
| 8 |
} from './cart-response';
|
|
|
|
| 9 |
export interface CurrencyInfo {
|
| 10 |
currency_code: string;
|
| 11 |
currency_symbol: string;
|
| 6 |
ShippingRateItem,
|
| 7 |
ExtensionsData,
|
| 8 |
} from './cart-response';
|
| 9 |
+
|
| 10 |
export interface CurrencyInfo {
|
| 11 |
currency_code: string;
|
| 12 |
currency_symbol: string;
|
assets/js/types/type-defs/events.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export interface AddToCartEventDetail {
|
| 2 |
+
// Whether cart data in the data store should be preserved.
|
| 3 |
+
preserveCartData?: boolean;
|
| 4 |
+
}
|
assets/js/types/type-defs/hooks.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type {
|
|
| 11 |
CartResponseBillingAddress,
|
| 12 |
CartResponseShippingRate,
|
| 13 |
CartResponse,
|
|
|
|
| 14 |
} from './cart-response';
|
| 15 |
import type { ResponseError } from '../../data/types';
|
| 16 |
export interface StoreCartItemQuantity {
|
|
@@ -31,7 +32,7 @@ export interface StoreCartCoupon {
|
|
| 31 |
}
|
| 32 |
|
| 33 |
export interface StoreCart {
|
| 34 |
-
cartCoupons:
|
| 35 |
cartItems: Array< CartResponseItem >;
|
| 36 |
cartFees: Array< CartResponseFeeItem >;
|
| 37 |
cartItemsCount: number;
|
| 11 |
CartResponseBillingAddress,
|
| 12 |
CartResponseShippingRate,
|
| 13 |
CartResponse,
|
| 14 |
+
CartResponseCoupons,
|
| 15 |
} from './cart-response';
|
| 16 |
import type { ResponseError } from '../../data/types';
|
| 17 |
export interface StoreCartItemQuantity {
|
| 32 |
}
|
| 33 |
|
| 34 |
export interface StoreCart {
|
| 35 |
+
cartCoupons: CartResponseCoupons;
|
| 36 |
cartItems: Array< CartResponseItem >;
|
| 37 |
cartFees: Array< CartResponseFeeItem >;
|
| 38 |
cartItemsCount: number;
|
assets/js/types/type-defs/index.ts
CHANGED
|
@@ -3,4 +3,5 @@ export * from './product-response';
|
|
| 3 |
export * from './cart';
|
| 4 |
export * from './hooks';
|
| 5 |
export * from './currency';
|
| 6 |
-
export * from './
|
|
|
| 3 |
export * from './cart';
|
| 4 |
export * from './hooks';
|
| 5 |
export * from './currency';
|
| 6 |
+
export * from './payments';
|
| 7 |
+
export * from './objects';
|
assets/js/types/type-defs/objects.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
| 1 |
+
export type ObjectType = Record< string, unknown >;
|
| 2 |
+
export type EmptyObjectType = Record< string, never >;
|
assets/js/types/type-defs/payment-method-icon.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
| 1 |
-
export interface PaymentMethodIcon {
|
| 2 |
-
id: string;
|
| 3 |
-
src: string | null;
|
| 4 |
-
alt: string;
|
| 5 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/types/type-defs/payments.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* @typedef {Object} PaymentDataItem
|
| 3 |
-
*
|
| 4 |
-
* @property {string} key Property for the payment data item.
|
| 5 |
-
* @property {string} value Value for the payment data item.
|
| 6 |
-
*/
|
| 7 |
-
|
| 8 |
-
/**
|
| 9 |
-
* @typedef {Object} ExpressPaymentMethodRegistrationOptions
|
| 10 |
-
*
|
| 11 |
-
* @property {string} name A unique string to identify the payment method client side.
|
| 12 |
-
* @property {Object} content A react node for your payment method UI.
|
| 13 |
-
* @property {Object} edit A react node to display a preview of your payment method in the editor.
|
| 14 |
-
* @property {Function} canMakePayment A callback to determine whether the payment method should be shown in the checkout.
|
| 15 |
-
* @property {string} [paymentMethodId] A unique string to represent the payment method server side. If not provided, defaults to name.
|
| 16 |
-
* @property {Object} supports Object that describes various features provided by the payment method.
|
| 17 |
-
*/
|
| 18 |
-
|
| 19 |
-
/**
|
| 20 |
-
* @typedef {Object} PaymentMethodRegistrationOptions
|
| 21 |
-
*
|
| 22 |
-
* @property {string} name A unique string to identify the payment method client side.
|
| 23 |
-
* @property {Object} content A react node for your payment method UI.
|
| 24 |
-
* @property {Object} edit A react node to display a preview of your payment method in the editor.
|
| 25 |
-
* @property {Array} [icons] Array of card types (brands) supported by the payment method. (See stripe/credit-card for example.)
|
| 26 |
-
* @property {Function} canMakePayment A callback to determine whether the payment method should be shown in the checkout.
|
| 27 |
-
* @property {string} [paymentMethodId] A unique string to represent the payment method server side. If not provided, defaults to name.
|
| 28 |
-
* @property {Object} label A react node that will be used as a label for the payment method in the checkout.
|
| 29 |
-
* @property {string} ariaLabel An accessibility label. Screen readers will output this label when the payment method is selected.
|
| 30 |
-
* @property {string} [placeOrderButtonLabel] Optionally customise the label text for the checkout submit (`Place Order`) button.
|
| 31 |
-
* @property {Object} supports Object that describes various features provided by the payment method.
|
| 32 |
-
*/
|
| 33 |
-
|
| 34 |
-
export {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/types/type-defs/payments.ts
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* External dependencies
|
| 3 |
+
*/
|
| 4 |
+
import type { ReactNode } from 'react';
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* Internal dependencies
|
| 8 |
+
*/
|
| 9 |
+
import type { CartTotals, Cart } from './cart';
|
| 10 |
+
import {
|
| 11 |
+
CartResponseBillingAddress,
|
| 12 |
+
CartResponseShippingAddress,
|
| 13 |
+
} from './cart-response';
|
| 14 |
+
import type { EmptyObjectType } from './objects';
|
| 15 |
+
|
| 16 |
+
export interface SupportsConfiguration {
|
| 17 |
+
showSavedCards?: boolean;
|
| 18 |
+
showSaveOption?: boolean;
|
| 19 |
+
features?: string[];
|
| 20 |
+
// Deprecated, in favour of showSavedCards and showSaveOption
|
| 21 |
+
savePaymentInfo?: boolean;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
// we assign a value in the class for supports.features
|
| 25 |
+
export interface Supports extends SupportsConfiguration {
|
| 26 |
+
features: string[];
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
export interface CanMakePaymentArgument {
|
| 30 |
+
cart: Cart;
|
| 31 |
+
cartTotals: CartTotals;
|
| 32 |
+
cartNeedsShipping: boolean;
|
| 33 |
+
billingData: CartResponseBillingAddress;
|
| 34 |
+
shippingAddress: CartResponseShippingAddress;
|
| 35 |
+
selectedShippingMethods: Record< string, unknown >;
|
| 36 |
+
paymentRequirements: Array< string >;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
export type CanMakePaymentReturnType =
|
| 40 |
+
| boolean
|
| 41 |
+
| Promise< boolean | { error: { message: string } } >;
|
| 42 |
+
|
| 43 |
+
export type CanMakePaymentCallback = (
|
| 44 |
+
cartData: CanMakePaymentArgument
|
| 45 |
+
) => CanMakePaymentReturnType;
|
| 46 |
+
|
| 47 |
+
export type CanMakePaymentExtensionCallback = (
|
| 48 |
+
cartData: CanMakePaymentArgument
|
| 49 |
+
) => boolean;
|
| 50 |
+
|
| 51 |
+
export interface PaymentMethodIcon {
|
| 52 |
+
id: string;
|
| 53 |
+
src: string | null;
|
| 54 |
+
alt: string;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
export type PaymentMethodIcons = ( PaymentMethodIcon | string )[];
|
| 58 |
+
|
| 59 |
+
export interface PaymentMethodConfiguration {
|
| 60 |
+
// A unique string to identify the payment method client side.
|
| 61 |
+
name: string;
|
| 62 |
+
// A react node for your payment method UI.
|
| 63 |
+
content: ReactNode;
|
| 64 |
+
// A react node to display a preview of your payment method in the editor.
|
| 65 |
+
edit: ReactNode;
|
| 66 |
+
// A callback to determine whether the payment method should be shown in the checkout.
|
| 67 |
+
canMakePayment: CanMakePaymentCallback;
|
| 68 |
+
// A unique string to represent the payment method server side. If not provided, defaults to name.
|
| 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. (See stripe/credit-card for example.)
|
| 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;
|
| 76 |
+
// An accessibility label. Screen readers will output this label when the payment method is selected.
|
| 77 |
+
ariaLabel: string;
|
| 78 |
+
// Optionally customize the label text for the checkout submit (`Place Order`) button.
|
| 79 |
+
placeOrderButtonLabel?: string;
|
| 80 |
+
// A React node that contains logic handling any processing your payment method has to do with saved payment methods if your payment method supports them
|
| 81 |
+
savedTokenComponent?: ReactNode | null;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
export type ExpressPaymentMethodConfiguration = Omit<
|
| 85 |
+
PaymentMethodConfiguration,
|
| 86 |
+
'icons' | 'label' | 'ariaLabel' | 'placeOrderButtonLabel'
|
| 87 |
+
>;
|
| 88 |
+
|
| 89 |
+
export type PaymentMethods =
|
| 90 |
+
| Record< string, PaymentMethodConfigInstance >
|
| 91 |
+
| EmptyObjectType;
|
| 92 |
+
|
| 93 |
+
export type ExpressPaymentMethods =
|
| 94 |
+
| Record< string, ExpressPaymentMethodConfigInstance >
|
| 95 |
+
| EmptyObjectType;
|
| 96 |
+
|
| 97 |
+
export interface PaymentMethodConfigInstance {
|
| 98 |
+
name: string;
|
| 99 |
+
content: ReactNode;
|
| 100 |
+
edit: ReactNode;
|
| 101 |
+
paymentMethodId?: string;
|
| 102 |
+
supports: Supports;
|
| 103 |
+
icons: null | PaymentMethodIcons;
|
| 104 |
+
label: ReactNode;
|
| 105 |
+
ariaLabel: string;
|
| 106 |
+
placeOrderButtonLabel?: string;
|
| 107 |
+
savedTokenComponent?: ReactNode | null;
|
| 108 |
+
canMakePaymentFromConfig: CanMakePaymentCallback;
|
| 109 |
+
canMakePayment: CanMakePaymentCallback;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
export interface ExpressPaymentMethodConfigInstance {
|
| 113 |
+
name: string;
|
| 114 |
+
content: ReactNode;
|
| 115 |
+
edit: ReactNode;
|
| 116 |
+
paymentMethodId?: string;
|
| 117 |
+
supports: Supports;
|
| 118 |
+
canMakePaymentFromConfig: CanMakePaymentCallback;
|
| 119 |
+
canMakePayment: CanMakePaymentCallback;
|
| 120 |
+
}
|
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-
|
| 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' => '30388734b99f75d9bb3536481cc8c2cc');
|
build/active-filters-frontend.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
| 1 |
-
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.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 o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));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=274)}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},106:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(6),o=r.n(n),c=r(0),a=function(){var e=Object(c.useState)(),t=o()(e,2)[1];return Object(c.useCallback)((function(e){t((function(){throw e}))}),[])}},11:function(e,t){e.exports=window.wp.data},116:function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(4);function o(e,t){var r=Object(n.useRef)();return Object(n.useEffect)((function(){r.current===e||t&&!t(e,r.current)||(r.current=e)}),[e,t]),r.current}},12: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},120:function(e,t,r){"use strict";r.d(t,"a",(function(){return b}));var n=r(12),o=r.n(n),c=r(5),a=r.n(c),i=r(0),u=r(54);function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){a()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var p=[".wp-block-woocommerce-cart"],f=function(e){var t=e.Block,r=e.containers,n=e.getProps,c=void 0===n?function(){return{}}:n,a=e.getErrorBoundaryProps,s=void 0===a?function(){return{}}:a;0!==r.length&&Array.prototype.forEach.call(r,(function(e,r){var n=c(e,r),a=s(e,r),p=l(l({},e.dataset),n.attributes||{});e.classList.remove("is-loading"),Object(i.render)(React.createElement(u.a,a,React.createElement(i.Suspense,{fallback:React.createElement("div",{className:"wc-block-placeholder"})},React.createElement(t,o()({},n,{attributes:p})))),e)}))},b=function(e){var t,r,n,o,c,a,i,u=document.body.querySelectorAll(p.join(","));t=l(l({},e),{},{wrappers:u}),r=t.Block,n=t.getProps,o=t.getErrorBoundaryProps,c=t.selector,a=t.wrappers,i=document.body.querySelectorAll(c),a.length>0&&Array.prototype.filter.call(i,(function(e){return!function(e,t){return Array.prototype.some.call(t,(function(t){return t.contains(e)&&!t.isSameNode(e)}))}(e,a)})),f({Block:r,containers:i,getProps:n,getErrorBoundaryProps:o}),Array.prototype.forEach.call(u,(function(t){t.addEventListener("wc-blocks_render_blocks_frontend",(function(){var r,n,o,c,a,i;n=(r=l(l({},e),{},{wrapper:t})).Block,o=r.getProps,c=r.getErrorBoundaryProps,a=r.selector,i=r.wrapper.querySelectorAll(a),f({Block:n,containers:i,getProps:o,getErrorBoundaryProps:c})}))}))}},129:function(e,t,r){"use strict";r.d(t,"a",(function(){return u}));var n=r(8),o=r(11),c=r(0),a=r(60),i=r(106),u=function(e){var t=e.namespace,r=e.resourceName,u=e.resourceValues,s=void 0===u?[]:u,l=e.query,p=void 0===l?{}:l,f=e.shouldSelect,b=void 0===f||f;if(!t||!r)throw new Error("The options object must have valid values for the namespace and the resource properties.");var d=Object(c.useRef)({results:[],isLoading:!0}),m=Object(a.a)(p),y=Object(a.a)(s),g=Object(i.a)(),v=Object(o.useSelect)((function(e){if(!b)return null;var o=e(n.COLLECTIONS_STORE_KEY),c=[t,r,m,y],a=o.getCollectionError.apply(o,c);return a&&g(a),{results:o.getCollection.apply(o,c),isLoading:!o.hasFinishedResolution("getCollection",c)}}),[t,r,y,m,b]);return null!==v&&(d.current=v),d.current}},140:function(e,t,r){"use strict";var n=r(0),o=r(8),c=r(11),a=r(15);t.a=function(e){return function(t){var r;return r=Object(n.useRef)(a.o.restApiRoutes||{}),Object(c.useSelect)((function(e,t){if(r.current){var n=e(o.SCHEMA_STORE_KEY),c=n.isResolving,a=n.hasFinishedResolution,i=t.dispatch(o.SCHEMA_STORE_KEY),u=i.receiveRoutes,s=i.startResolution,l=i.finishResolution;Object.keys(r.current).forEach((function(e){var t=r.current[e];c("getRoutes",[e])||a("getRoutes",[e])||(s("getRoutes",[e]),u(t,[e]),l("getRoutes",[e]))}))}}),[]),React.createElement(e,t)}}},15:function(e,t,r){"use strict";r.d(t,"o",(function(){return c})),r.d(t,"n",(function(){return a})),r.d(t,"m",(function(){return i})),r.d(t,"j",(function(){return s})),r.d(t,"d",(function(){return l})),r.d(t,"g",(function(){return p})),r.d(t,"f",(function(){return f})),r.d(t,"l",(function(){return b})),r.d(t,"k",(function(){return d})),r.d(t,"c",(function(){return m})),r.d(t,"e",(function(){return y})),r.d(t,"h",(function(){return g})),r.d(t,"a",(function(){return v})),r.d(t,"i",(function(){return O})),r.d(t,"b",(function(){return _})),r.d(t,"p",(function(){return h}));var n,o=r(2),c=Object(o.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),a=c.pluginUrl+"images/",i=c.pluginUrl+"build/",u=c.buildPhase,s=null===(n=o.STORE_PAGES.shop)||void 0===n?void 0:n.permalink,l=(o.STORE_PAGES.checkout.id,o.STORE_PAGES.checkout.permalink),p=o.STORE_PAGES.privacy.permalink,f=o.STORE_PAGES.privacy.title,b=o.STORE_PAGES.terms.permalink,d=o.STORE_PAGES.terms.title,m=(o.STORE_PAGES.cart.id,o.STORE_PAGES.cart.permalink),y=o.STORE_PAGES.myaccount.permalink?o.STORE_PAGES.myaccount.permalink:Object(o.getSetting)("wpLoginUrl","/wp-login.php"),g=Object(o.getSetting)("shippingCountries",{}),v=Object(o.getSetting)("allowedCountries",{}),O=Object(o.getSetting)("shippingStates",{}),_=Object(o.getSetting)("allowedStates",{}),h=(r(53),function(){return u>1})},151:function(e,t){},155:function(e,t,r){"use strict";var n=r(5),o=r.n(n),c=r(17),a=r.n(c),i=r(0),u=["srcElement","size"];function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}t.a=function(e){var t=e.srcElement,r=e.size,n=void 0===r?24:r,c=a()(e,u);return Object(i.isValidElement)(t)?Object(i.cloneElement)(t,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({width:n,height:n},c)):null}},17:function(e,t,r){var n=r(79);e.exports=function(e,t){if(null==e)return{};var r,o,c=n(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)r=a[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(c[r]=e[r])}return c},e.exports.default=e.exports,e.exports.__esModule=!0},179:function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r.d(t,"b",(function(){return a}));var n=r(2),o=Object(n.getSetting)("attributes",[]).reduce((function(e,t){var r,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;return n.id&&e.push(n),e}),[]),c=function(e){if(e)return o.find((function(t){return t.id===e}))},a=function(e){if(e)return o.find((function(t){return t.taxonomy===e}))}},180:function(e,t,r){"use strict";r.d(t,"a",(function(){return o})),r.d(t,"b",(function(){return c}));var n=r(7),o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},r=arguments.length>2?arguments[2]:void 0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",c=e.filter((function(e){return e.attribute===r.taxonomy})),a=c.length?c[0]:null;if(a&&a.slug&&Array.isArray(a.slug)&&a.slug.includes(o)){var i=a.slug.filter((function(e){return e!==o})),u=e.filter((function(e){return e.attribute!==r.taxonomy}));i.length>0&&(a.slug=i.sort(),u.push(a)),t(Object(n.sortBy)(u,"attribute"))}},c=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},r=arguments.length>2?arguments[2]:void 0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],c=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"in",a=e.filter((function(e){return e.attribute!==r.taxonomy}));0===o.length?t(a):(a.push({attribute:r.taxonomy,operator:c,slug:o.map((function(e){return e.slug})).sort()}),t(Object(n.sortBy)(a,"attribute")))}},189:function(e,t,r){"use strict";var n=r(12),o=r.n(n),c=r(17),a=r.n(c),i=(r(9),r(3)),u=r.n(i),s=r(1),l=r(155),p=r(206),f=(r(151),["text","screenReaderText","element","className","radius","children"]),b=function(e){var t=e.text,r=e.screenReaderText,n=void 0===r?"":r,c=e.element,i=void 0===c?"li":c,s=e.className,l=void 0===s?"":s,p=e.radius,b=void 0===p?"small":p,d=e.children,m=void 0===d?null:d,y=a()(e,f),g=i,v=u()(l,"wc-block-components-chip","wc-block-components-chip--radius-"+b),O=Boolean(n&&n!==t);return React.createElement(g,o()({className:v},y),React.createElement("span",{"aria-hidden":O,className:"wc-block-components-chip__text"},t),O&&React.createElement("span",{className:"screen-reader-text"},n),m)},d=["ariaLabel","className","disabled","onRemove","removeOnAnyClick","text","screenReaderText"];t.a=function(e){var t=e.ariaLabel,r=void 0===t?"":t,n=e.className,c=void 0===n?"":n,i=e.disabled,f=void 0!==i&&i,m=e.onRemove,y=void 0===m?function(){}:m,g=e.removeOnAnyClick,v=void 0!==g&&g,O=e.text,_=e.screenReaderText,h=void 0===_?"":_,w=a()(e,d),x=v?"span":"button";if(!r){var j=h&&"string"==typeof h?h:O;r="string"!=typeof j?
|
| 2 |
/* translators: Remove chip. */
|
| 3 |
-
Object(
|
| 4 |
/* translators: %s text of the chip to remove. */
|
| 5 |
-
Object(
|
| 6 |
/* translators: %1$s min price, %2$s max price */
|
| 7 |
Object(i.__)("Between %1$s and %2$s","woo-gutenberg-products-block"),Object(m.formatPrice)(e),Object(m.formatPrice)(t)):Number.isFinite(e)?Object(i.sprintf)(
|
| 8 |
/* translators: %s min price */
|
| 9 |
Object(i.__)("From %s","woo-gutenberg-products-block"),Object(m.formatPrice)(e)):Object(i.sprintf)(
|
| 10 |
/* translators: %s max price */
|
| 11 |
-
Object(i.__)("Up to %s","woo-gutenberg-products-block"),Object(m.formatPrice)(t))},v=function(e){var t=e.type,r=e.name,n=e.prefix,o=e.removeCallback,c=void 0===o?function(){}:o,a=e.showLabel,
|
| 12 |
/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */
|
| 13 |
-
Object(i.__)("Remove %s filter","woo-gutenberg-products-block"),r);return React.createElement("li",{className:"wc-block-active-filters__list-item",key:t+":"+r},u&&React.createElement("span",{className:"wc-block-active-filters__list-item-type"},t+": "),"chips"===s?React.createElement(y.a,{element:"span",text:l,onRemove:c,radius:"large",ariaLabel:p}):React.createElement("span",{className:"wc-block-active-filters__list-item-name"},l,React.createElement("button",{className:"wc-block-active-filters__list-item-remove",onClick:c},React.createElement("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},React.createElement("ellipse",{cx:"8",cy:"8",rx:"8",ry:"8",transform:"rotate(-180 8 8)",fill:"currentColor",fillOpacity:"0.7"}),React.createElement("rect",{x:"10.636",y:"3.94983",width:"2",height:"9.9466",transform:"rotate(45 10.636 3.94983)",fill:"white"}),React.createElement("rect",{x:"12.0503",y:"11.0209",width:"2",height:"9.9466",transform:"rotate(135 12.0503 11.0209)",fill:"white"})),React.createElement(b.a,{screenReaderLabel:p}))))},O=r(129),_=r(24),h=r(180),w=function(e){var t=e.attributeObject,r=void 0===t?{}:t,n=e.slugs,o=void 0===n?[]:n,c=e.operator,s=void 0===c?"in":c,l=e.displayStyle,p=Object(O.a)({namespace:"/wc/store",resourceName:"products/attributes/terms",resourceValues:[r.id]}),f=p.results,b=p.isLoading,d=Object(u.b)("attributes",[]),m=a()(d,2),y=m[0],g=m[1];if(b)return null;var w=r.label;return React.createElement("li",null,React.createElement("span",{className:"wc-block-active-filters__list-item-type"},w,":"),React.createElement("ul",null,o.map((function(e,t){var n=f.find((function(t){return t.slug===e}));if(!n)return null;var o="";return t>0&&"and"===s&&(o=React.createElement("span",{className:"wc-block-active-filters__list-item-operator"},Object(i.__)("and","woo-gutenberg-products-block"))),v({type:w,name:Object(_.decodeEntities)(n.name||e),prefix:o,removeCallback:function(){Object(h.a)(y,g,r,e)},showLabel:!1,displayStyle:l})}))))};Object(o.a)({selector:".wp-block-woocommerce-active-filters",Block:Object(n.a)((function(e){var t=e.attributes,r=e.isEditor,n=void 0!==r&&r,o=Object(u.b)("attributes",[]),c=a()(o,2),p=c[0],m=c[1],y=Object(u.b)("stock_status",[]),O=a()(y,2),_=O[0],h=O[1],x=Object(u.b)("min_price"),j=a()(x,2),E=j[0],R=j[1],S=Object(u.b)("max_price"),k=a()(S,2),P=k[0],T=k[1],M=Object(s.getSetting)("stockStatusOptions",[]),N=Object(l.useMemo)((function(){if(_.length>0)return _.map((function(e){return v({type:Object(i.__)("Stock Status","woo-gutenberg-products-block"),name:M[e],removeCallback:function(){var t=_.filter((function(t){return t!==e}));h(t)},displayStyle:t.displayStyle})}))}),[M,_,h,t.displayStyle]),A=Object(l.useMemo)((function(){return Number.isFinite(E)||Number.isFinite(P)?v({type:Object(i.__)("Price","woo-gutenberg-products-block"),name:g(E,P),removeCallback:function(){R(void 0),T(void 0)},displayStyle:t.displayStyle}):null}),[E,P,t.displayStyle,R,T]),C=Object(l.useMemo)((function(){return p.map((function(e){var r=Object(d.b)(e.attribute);return React.createElement(w,{attributeObject:r,displayStyle:t.displayStyle,slugs:e.slug,key:e.attribute,operator:e.operator})}))}),[p,t.displayStyle]);if(!(p.length>0||_.length>0||Number.isFinite(E)||Number.isFinite(P)||n))return null;var L="h".concat(t.headingLevel),B=f()("wc-block-active-filters__list",{"wc-block-active-filters__list--chips":"chips"===t.displayStyle});return React.createElement(React.Fragment,null,!n&&t.heading&&React.createElement(L,null,t.heading),React.createElement("div",{className:"wc-block-active-filters"},React.createElement("ul",{className:B},n?React.createElement(React.Fragment,null,v({type:Object(i.__)("Size","woo-gutenberg-products-block"),name:Object(i.__)("Small","woo-gutenberg-products-block"),displayStyle:t.displayStyle}),v({type:Object(i.__)("Color","woo-gutenberg-products-block"),name:Object(i.__)("Blue","woo-gutenberg-products-block"),displayStyle:t.displayStyle})):React.createElement(React.Fragment,null,A,N,C)),React.createElement("button",{className:"wc-block-active-filters__clear-all",onClick:function(){R(void 0),T(void 0),m([]),h([])}},React.createElement(b.a,{label:Object(i.__)("Clear All","woo-gutenberg-products-block"),screenReaderLabel:Object(i.__)("Clear All Filters","woo-gutenberg-products-block")}))))})),getProps:function(e){return{attributes:{displayStyle:e.dataset.displayStyle,heading:e.dataset.heading,headingLevel:e.dataset.headingLevel||3}}}})},32:function(e,t){function r(t){return e.exports=r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.default=e.exports,e.exports.__esModule=!0,r(t)}e.exports=r,e.exports.default=e.exports,e.exports.__esModule=!0},34:function(e,t){e.exports=window.wp.primitives},37:function(e,t,r){"use strict";var n=r(5),o=r.n(n),c=r(0),a=r(3),i=r.n(a);function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}t.a=function(e){var t,r=e.label,n=e.screenReaderLabel,o=e.wrapperElement,a=e.wrapperProps,u=void 0===a?{}:a,l=null!=r,p=null!=n;return!l&&p?(t=o||"span",u=s(s({},u),{},{className:i()(u.className,"screen-reader-text")}),React.createElement(t,u,n)):(t=o||c.Fragment,l&&p&&r!==n?React.createElement(t,u,React.createElement("span",{"aria-hidden":"true"},r),React.createElement("span",{className:"screen-reader-text"},n)):React.createElement(t,u,r))}},4:function(e,t){e.exports=window.React},44:function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.default=e.exports,e.exports.__esModule=!0},45:function(e,t){function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}e.exports=function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e},e.exports.default=e.exports,e.exports.__esModule=!0},46:function(e,t,r){var n=r(75);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&n(e,t)},e.exports.default=e.exports,e.exports.__esModule=!0},47:function(e,t,r){var n=r(22).default,o=r(30);e.exports=function(e,t){return!t||"object"!==n(t)&&"function"!=typeof t?o(e):t},e.exports.default=e.exports,e.exports.__esModule=!0},5: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},50:function(e,t){e.exports=window.wc.priceFormat},53:function(e,t){e.exports=window.wp.blocks},54:function(e,t,r){"use strict";var n=r(44),o=r.n(n),c=r(45),a=r.n(c),i=r(30),u=r.n(i),s=r(46),l=r.n(s),p=r(47),f=r.n(p),b=r(32),d=r.n(b),m=r(5),y=r.n(m),g=(r(9),r(4)),v=r(1),O=r(15),_=function(e){var t=e.imageUrl,r=void 0===t?"".concat(O.n,"/block-error.svg"):t,n=e.header,o=void 0===n?Object(v.__)("Oops!","woo-gutenberg-products-block"):n,c=e.text,a=void 0===c?Object(v.__)("There was an error loading the content.","woo-gutenberg-products-block"):c,i=e.errorMessage,u=e.errorMessagePrefix,s=void 0===u?Object(v.__)("Error:","woo-gutenberg-products-block"):u,l=e.button;return React.createElement("div",{className:"wc-block-error wc-block-components-error"},r&&React.createElement("img",{className:"wc-block-error__image wc-block-components-error__image",src:r,alt:""}),React.createElement("div",{className:"wc-block-error__content wc-block-components-error__content"},o&&React.createElement("p",{className:"wc-block-error__header wc-block-components-error__header"},o),a&&React.createElement("p",{className:"wc-block-error__text wc-block-components-error__text"},a),i&&React.createElement("p",{className:"wc-block-error__message wc-block-components-error__message"},s?s+" ":"",i),l&&React.createElement("p",{className:"wc-block-error__button wc-block-components-error__button"},l)))};r(82);var h=function(e){l()(c,e);var t,r,n=(t=c,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d()(t);if(r){var o=d()(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return f()(this,e)});function c(){var e;o()(this,c);for(var t=arguments.length,r=new Array(t),a=0;a<t;a++)r[a]=arguments[a];return e=n.call.apply(n,[this].concat(r)),y()(u()(e),"state",{errorMessage:"",hasError:!1}),e}return a()(c,[{key:"render",value:function(){var e=this.props,t=e.header,r=e.imageUrl,n=e.showErrorMessage,o=e.text,c=e.errorMessagePrefix,a=e.renderError,i=e.button,u=this.state,s=u.errorMessage;return u.hasError?"function"==typeof a?a({errorMessage:s}):React.createElement(_,{errorMessage:n?s:null,header:t,imageUrl:r,text:o,errorMessagePrefix:c,button:i}):this.props.children}}],[{key:"getDerivedStateFromError",value:function(e){return void 0!==e.statusText&&void 0!==e.status?{errorMessage:React.createElement(React.Fragment,null,React.createElement("strong",null,e.status),": ",e.statusText),hasError:!0}:{errorMessage:e.message,hasError:!0}}}]),c}(g.Component);h.defaultProps={showErrorMessage:!0},t.a=h},6:function(e,t,r){var n=r(89),o=r(90),c=r(71),a=r(91);e.exports=function(e,t){return n(e)||o(e,t)||c(e,t)||a()},e.exports.default=e.exports,e.exports.__esModule=!0},60:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(0),o=r(27),c=r.n(o);function a(e){var t=Object(n.useRef)(e);return c()(e,t.current)||(t.current=e),t.current}},69:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(0),o=Object(n.createContext)("page"),c=function(){return Object(n.useContext)(o)};o.Provider},7:function(e,t){e.exports=window.lodash},71:function(e,t,r){var n=r(72);e.exports=function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}},e.exports.default=e.exports,e.exports.__esModule=!0},72:function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n},e.exports.default=e.exports,e.exports.__esModule=!0},75:function(e,t){function r(t,n){return e.exports=r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},e.exports.default=e.exports,e.exports.__esModule=!0,r(t,n)}e.exports=r,e.exports.default=e.exports,e.exports.__esModule=!0},79:function(e,t){e.exports=function(e,t){if(null==e)return{};var r,n,o={},c=Object.keys(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||(o[r]=e[r]);return o},e.exports.default=e.exports,e.exports.__esModule=!0},8:function(e,t){e.exports=window.wc.wcBlocksData},80:function(e,t,r){"use strict";var n=r(81);function o(){}function c(){}c.resetWarningCache=o,e.exports=function(){function e(e,t,r,o,c,a){if(a!==n){var i=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 i.name="Invariant Violation",i}}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:c,resetWarningCache:o};return r.PropTypes=r,r}},81:function(e,t,r){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},82:function(e,t){},89:function(e,t){e.exports=function(e){if(Array.isArray(e))return e},e.exports.default=e.exports,e.exports.__esModule=!0},9:function(e,t,r){e.exports=r(80)()},90:function(e,t){e.exports=function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,c=[],_n=!0,a=!1;try{for(r=r.call(e);!(_n=(n=r.next()).done)&&(c.push(n.value),!t||c.length!==t);_n=!0);}catch(e){a=!0,o=e}finally{try{_n||null==r.return||r.return()}finally{if(a)throw o}}return c}},e.exports.default=e.exports,e.exports.__esModule=!0},91:function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.default=e.exports,e.exports.__esModule=!0},96:function(e,t,r){"use strict";r.d(t,"a",(function(){return b})),r.d(t,"b",(function(){return d})),r.d(t,"c",(function(){return m}));var n=r(6),o=r.n(n),c=r(8),a=r(11),i=r(0),u=r(27),s=r.n(u),l=r(60),p=r(116),f=r(69),b=function(e){var t=Object(f.a)();e=e||t;var r=Object(a.useSelect)((function(t){return t(c.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0)}),[e]),n=Object(a.useDispatch)(c.QUERY_STATE_STORE_KEY).setValueForQueryContext;return[r,Object(i.useCallback)((function(t){n(e,t)}),[e,n])]},d=function(e,t,r){var n=Object(f.a)();r=r||n;var o=Object(a.useSelect)((function(n){return n(c.QUERY_STATE_STORE_KEY).getValueForQueryKey(r,e,t)}),[r,e]),u=Object(a.useDispatch)(c.QUERY_STATE_STORE_KEY).setQueryValue;return[o,Object(i.useCallback)((function(t){u(r,e,t)}),[r,e,u])]},m=function(e,t){var r=Object(f.a)(),n=b(t=t||r),c=o()(n,2),a=c[0],u=c[1],d=Object(l.a)(a),m=Object(l.a)(e),y=Object(p.a)(m),g=Object(i.useRef)(!1);return Object(i.useEffect)((function(){s()(y,m)||(u(Object.assign({},d,m)),g.current=!0)}),[d,m,y,u]),g.current?[a,u]:[e,u]}}});
|
| 1 |
+
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.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 o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));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=296)}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},10:function(e,t,r){e.exports=r(79)()},100:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(5),o=r.n(n),c=r(0),a=function(){var e=Object(c.useState)(),t=o()(e,2)[1];return Object(c.useCallback)((function(e){t((function(){throw e}))}),[])}},107:function(e,t,r){"use strict";r.d(t,"a",(function(){return b}));var n=r(14),o=r.n(n),c=r(4),a=r.n(c),i=r(0),s=r(44);function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){a()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var p=[".wp-block-woocommerce-cart"],f=function(e){var t=e.Block,r=e.containers,n=e.getProps,c=void 0===n?function(){return{}}:n,a=e.getErrorBoundaryProps,u=void 0===a?function(){return{}}:a;0!==r.length&&Array.prototype.forEach.call(r,(function(e,r){var n=c(e,r),a=u(e,r),p=l(l({},e.dataset),n.attributes||{});e.classList.remove("is-loading"),Object(i.render)(React.createElement(s.a,a,React.createElement(i.Suspense,{fallback:React.createElement("div",{className:"wc-block-placeholder"})},React.createElement(t,o()({},n,{attributes:p})))),e)}))},b=function(e){var t,r,n,o,c,a,i,s=document.body.querySelectorAll(p.join(","));t=l(l({},e),{},{wrappers:s}),r=t.Block,n=t.getProps,o=t.getErrorBoundaryProps,c=t.selector,a=t.wrappers,i=document.body.querySelectorAll(c),a.length>0&&Array.prototype.filter.call(i,(function(e){return!function(e,t){return Array.prototype.some.call(t,(function(t){return t.contains(e)&&!t.isSameNode(e)}))}(e,a)})),f({Block:r,containers:i,getProps:n,getErrorBoundaryProps:o}),Array.prototype.forEach.call(s,(function(t){t.addEventListener("wc-blocks_render_blocks_frontend",(function(){var r,n,o,c,a,i;n=(r=l(l({},e),{},{wrapper:t})).Block,o=r.getProps,c=r.getErrorBoundaryProps,a=r.selector,i=r.wrapper.querySelectorAll(a),f({Block:n,containers:i,getProps:o,getErrorBoundaryProps:c})}))}))}},11:function(e,t){e.exports=window.wp.data},120:function(e,t,r){"use strict";r.d(t,"a",(function(){return s}));var n=r(8),o=r(11),c=r(0),a=r(53),i=r(100),s=function(e){var t=e.namespace,r=e.resourceName,s=e.resourceValues,u=void 0===s?[]:s,l=e.query,p=void 0===l?{}:l,f=e.shouldSelect,b=void 0===f||f;if(!t||!r)throw new Error("The options object must have valid values for the namespace and the resource properties.");var d=Object(c.useRef)({results:[],isLoading:!0}),m=Object(a.a)(p),y=Object(a.a)(u),g=Object(i.a)(),v=Object(o.useSelect)((function(e){if(!b)return null;var o=e(n.COLLECTIONS_STORE_KEY),c=[t,r,m,y],a=o.getCollectionError.apply(o,c);return a&&g(a),{results:o.getCollection.apply(o,c),isLoading:!o.hasFinishedResolution("getCollection",c)}}),[t,r,y,m,b]);return null!==v&&(d.current=v),d.current}},128:function(e,t,r){"use strict";var n=r(0),o=r(8),c=r(11),a=r(83);t.a=function(e){return function(t){var r;return r=Object(n.useRef)(a.n.restApiRoutes||{}),Object(c.useSelect)((function(e,t){if(r.current){var n=e(o.SCHEMA_STORE_KEY),c=n.isResolving,a=n.hasFinishedResolution,i=t.dispatch(o.SCHEMA_STORE_KEY),s=i.receiveRoutes,u=i.startResolution,l=i.finishResolution;Object.keys(r.current).forEach((function(e){var t=r.current[e];c("getRoutes",[e])||a("getRoutes",[e])||(u("getRoutes",[e]),s(t,[e]),l("getRoutes",[e]))}))}}),[]),React.createElement(e,t)}}},14: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},149:function(e,t){},152:function(e,t,r){"use strict";var n=r(4),o=r.n(n),c=r(23),a=r.n(c),i=r(0),s=["srcElement","size"];function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}t.a=function(e){var t=e.srcElement,r=e.size,n=void 0===r?24:r,c=a()(e,s);return Object(i.isValidElement)(t)?Object(i.cloneElement)(t,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({width:n,height:n},c)):null}},169:function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r.d(t,"b",(function(){return a}));var n=r(2),o=Object(n.getSetting)("attributes",[]).reduce((function(e,t){var r,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;return n.id&&e.push(n),e}),[]),c=function(e){if(e)return o.find((function(t){return t.id===e}))},a=function(e){if(e)return o.find((function(t){return t.taxonomy===e}))}},170:function(e,t,r){"use strict";r.d(t,"a",(function(){return o})),r.d(t,"b",(function(){return c}));var n=r(7),o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},r=arguments.length>2?arguments[2]:void 0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",c=e.filter((function(e){return e.attribute===r.taxonomy})),a=c.length?c[0]:null;if(a&&a.slug&&Array.isArray(a.slug)&&a.slug.includes(o)){var i=a.slug.filter((function(e){return e!==o})),s=e.filter((function(e){return e.attribute!==r.taxonomy}));i.length>0&&(a.slug=i.sort(),s.push(a)),t(Object(n.sortBy)(s,"attribute"))}},c=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},r=arguments.length>2?arguments[2]:void 0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],c=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"in",a=e.filter((function(e){return e.attribute!==r.taxonomy}));0===o.length?t(a):(a.push({attribute:r.taxonomy,operator:c,slug:o.map((function(e){return e.slug})).sort()}),t(Object(n.sortBy)(a,"attribute")))}},194:function(e,t,r){"use strict";var n=r(14),o=r.n(n),c=r(23),a=r.n(c),i=(r(10),r(6)),s=r.n(i),u=r(1),l=r(152),p=r(216),f=(r(149),["text","screenReaderText","element","className","radius","children"]),b=function(e){var t=e.text,r=e.screenReaderText,n=void 0===r?"":r,c=e.element,i=void 0===c?"li":c,u=e.className,l=void 0===u?"":u,p=e.radius,b=void 0===p?"small":p,d=e.children,m=void 0===d?null:d,y=a()(e,f),g=i,v=s()(l,"wc-block-components-chip","wc-block-components-chip--radius-"+b),O=Boolean(n&&n!==t);return React.createElement(g,o()({className:v},y),React.createElement("span",{"aria-hidden":O,className:"wc-block-components-chip__text"},t),O&&React.createElement("span",{className:"screen-reader-text"},n),m)},d=["ariaLabel","className","disabled","onRemove","removeOnAnyClick","text","screenReaderText"];t.a=function(e){var t=e.ariaLabel,r=void 0===t?"":t,n=e.className,c=void 0===n?"":n,i=e.disabled,f=void 0!==i&&i,m=e.onRemove,y=void 0===m?function(){}:m,g=e.removeOnAnyClick,v=void 0!==g&&g,O=e.text,_=e.screenReaderText,h=void 0===_?"":_,w=a()(e,d),x=v?"span":"button";if(!r){var j=h&&"string"==typeof h?h:O;r="string"!=typeof j?
|
| 2 |
/* translators: Remove chip. */
|
| 3 |
+
Object(u.__)("Remove","woo-gutenberg-products-block"):Object(u.sprintf)(
|
| 4 |
/* translators: %s text of the chip to remove. */
|
| 5 |
+
Object(u.__)('Remove "%s"',"woo-gutenberg-products-block"),j)}var E={"aria-label":r,disabled:f,onClick:y,onKeyDown:function(e){"Backspace"!==e.key&&"Delete"!==e.key||y()}},R=v?E:{},S=v?{"aria-hidden":!0}:E;return React.createElement(b,o()({},w,R,{className:s()(c,"is-removable"),element:v?"button":w.element,screenReaderText:h,text:O}),React.createElement(x,o()({className:"wc-block-components-chip__remove"},S),React.createElement(l.a,{className:"wc-block-components-chip__remove-icon",srcElement:p.a,size:16})))}},2:function(e,t){e.exports=window.wc.wcSettings},20:function(e,t){function r(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(e.exports=r=function(e){return typeof e},e.exports.default=e.exports,e.exports.__esModule=!0):(e.exports=r=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.default=e.exports,e.exports.__esModule=!0),r(t)}e.exports=r,e.exports.default=e.exports,e.exports.__esModule=!0},216:function(e,t,r){"use strict";var n=r(14),o=r.n(n),c=r(23),a=r.n(c),i=r(34),s=["className","size"],u=function(e){var t=e.className,r=e.size,n=a()(e,s);return React.createElement(i.SVG,o()({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",className:t,width:r,height:r},n),React.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"}))},l=React.createElement(u,null);t.a=l},23:function(e,t,r){var n=r(77);e.exports=function(e,t){if(null==e)return{};var r,o,c=n(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)r=a[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(c[r]=e[r])}return c},e.exports.default=e.exports,e.exports.__esModule=!0},25:function(e,t){e.exports=window.wp.isShallowEqual},28:function(e,t){e.exports=window.wp.htmlEntities},29:function(e,t){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.default=e.exports,e.exports.__esModule=!0},296:function(e,t,r){e.exports=r(320)},297:function(e,t){},3:function(e,t){e.exports=window.React},30:function(e,t){function r(t){return e.exports=r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.default=e.exports,e.exports.__esModule=!0,r(t)}e.exports=r,e.exports.default=e.exports,e.exports.__esModule=!0},320:function(e,t,r){"use strict";r.r(t);var n=r(128),o=r(107),c=r(5),a=r.n(c),i=r(1),s=r(90),u=r(2),l=r(0),p=r(6),f=r.n(p),b=(r(10),r(51)),d=(r(297),r(169)),m=r(62),y=r(194),g=function(e,t){return Number.isFinite(e)&&Number.isFinite(t)?Object(i.sprintf)(
|
| 6 |
/* translators: %1$s min price, %2$s max price */
|
| 7 |
Object(i.__)("Between %1$s and %2$s","woo-gutenberg-products-block"),Object(m.formatPrice)(e),Object(m.formatPrice)(t)):Number.isFinite(e)?Object(i.sprintf)(
|
| 8 |
/* translators: %s min price */
|
| 9 |
Object(i.__)("From %s","woo-gutenberg-products-block"),Object(m.formatPrice)(e)):Object(i.sprintf)(
|
| 10 |
/* translators: %s max price */
|
| 11 |
+
Object(i.__)("Up to %s","woo-gutenberg-products-block"),Object(m.formatPrice)(t))},v=function(e){var t=e.type,r=e.name,n=e.prefix,o=e.removeCallback,c=void 0===o?function(){}:o,a=e.showLabel,s=void 0===a||a,u=e.displayStyle,l=n?React.createElement(React.Fragment,null,n," ",r):r,p=Object(i.sprintf)(
|
| 12 |
/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */
|
| 13 |
+
Object(i.__)("Remove %s filter","woo-gutenberg-products-block"),r);return React.createElement("li",{className:"wc-block-active-filters__list-item",key:t+":"+r},s&&React.createElement("span",{className:"wc-block-active-filters__list-item-type"},t+": "),"chips"===u?React.createElement(y.a,{element:"span",text:l,onRemove:c,radius:"large",ariaLabel:p}):React.createElement("span",{className:"wc-block-active-filters__list-item-name"},l,React.createElement("button",{className:"wc-block-active-filters__list-item-remove",onClick:c},React.createElement("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},React.createElement("ellipse",{cx:"8",cy:"8",rx:"8",ry:"8",transform:"rotate(-180 8 8)",fill:"currentColor",fillOpacity:"0.7"}),React.createElement("rect",{x:"10.636",y:"3.94983",width:"2",height:"9.9466",transform:"rotate(45 10.636 3.94983)",fill:"white"}),React.createElement("rect",{x:"12.0503",y:"11.0209",width:"2",height:"9.9466",transform:"rotate(135 12.0503 11.0209)",fill:"white"})),React.createElement(b.a,{screenReaderLabel:p}))))},O=r(120),_=r(28),h=r(170),w=function(e){var t=e.attributeObject,r=void 0===t?{}:t,n=e.slugs,o=void 0===n?[]:n,c=e.operator,u=void 0===c?"in":c,l=e.displayStyle,p=Object(O.a)({namespace:"/wc/store",resourceName:"products/attributes/terms",resourceValues:[r.id]}),f=p.results,b=p.isLoading,d=Object(s.b)("attributes",[]),m=a()(d,2),y=m[0],g=m[1];if(b)return null;var w=r.label;return React.createElement("li",null,React.createElement("span",{className:"wc-block-active-filters__list-item-type"},w,":"),React.createElement("ul",null,o.map((function(e,t){var n=f.find((function(t){return t.slug===e}));if(!n)return null;var o="";return t>0&&"and"===u&&(o=React.createElement("span",{className:"wc-block-active-filters__list-item-operator"},Object(i.__)("and","woo-gutenberg-products-block"))),v({type:w,name:Object(_.decodeEntities)(n.name||e),prefix:o,removeCallback:function(){Object(h.a)(y,g,r,e)},showLabel:!1,displayStyle:l})}))))};Object(o.a)({selector:".wp-block-woocommerce-active-filters",Block:Object(n.a)((function(e){var t=e.attributes,r=e.isEditor,n=void 0!==r&&r,o=Object(s.b)("attributes",[]),c=a()(o,2),p=c[0],m=c[1],y=Object(s.b)("stock_status",[]),O=a()(y,2),_=O[0],h=O[1],x=Object(s.b)("min_price"),j=a()(x,2),E=j[0],R=j[1],S=Object(s.b)("max_price"),k=a()(S,2),P=k[0],T=k[1],M=Object(u.getSetting)("stockStatusOptions",[]),N=Object(l.useMemo)((function(){if(_.length>0)return _.map((function(e){return v({type:Object(i.__)("Stock Status","woo-gutenberg-products-block"),name:M[e],removeCallback:function(){var t=_.filter((function(t){return t!==e}));h(t)},displayStyle:t.displayStyle})}))}),[M,_,h,t.displayStyle]),A=Object(l.useMemo)((function(){return Number.isFinite(E)||Number.isFinite(P)?v({type:Object(i.__)("Price","woo-gutenberg-products-block"),name:g(E,P),removeCallback:function(){R(void 0),T(void 0)},displayStyle:t.displayStyle}):null}),[E,P,t.displayStyle,R,T]),C=Object(l.useMemo)((function(){return p.map((function(e){var r=Object(d.b)(e.attribute);return React.createElement(w,{attributeObject:r,displayStyle:t.displayStyle,slugs:e.slug,key:e.attribute,operator:e.operator})}))}),[p,t.displayStyle]);if(!(p.length>0||_.length>0||Number.isFinite(E)||Number.isFinite(P)||n))return null;var L="h".concat(t.headingLevel),B=f()("wc-block-active-filters__list",{"wc-block-active-filters__list--chips":"chips"===t.displayStyle});return React.createElement(React.Fragment,null,!n&&t.heading&&React.createElement(L,{className:"wc-block-active-filters__title"},t.heading),React.createElement("div",{className:"wc-block-active-filters"},React.createElement("ul",{className:B},n?React.createElement(React.Fragment,null,v({type:Object(i.__)("Size","woo-gutenberg-products-block"),name:Object(i.__)("Small","woo-gutenberg-products-block"),displayStyle:t.displayStyle}),v({type:Object(i.__)("Color","woo-gutenberg-products-block"),name:Object(i.__)("Blue","woo-gutenberg-products-block"),displayStyle:t.displayStyle})):React.createElement(React.Fragment,null,A,N,C)),React.createElement("button",{className:"wc-block-active-filters__clear-all",onClick:function(){R(void 0),T(void 0),m([]),h([])}},React.createElement(b.a,{label:Object(i.__)("Clear All","woo-gutenberg-products-block"),screenReaderLabel:Object(i.__)("Clear All Filters","woo-gutenberg-products-block")}))))})),getProps:function(e){return{attributes:{displayStyle:e.dataset.displayStyle,heading:e.dataset.heading,headingLevel:e.dataset.headingLevel||3}}}})},34:function(e,t){e.exports=window.wp.primitives},4: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},40:function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.default=e.exports,e.exports.__esModule=!0},41:function(e,t){function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}e.exports=function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e},e.exports.default=e.exports,e.exports.__esModule=!0},42:function(e,t,r){var n=r(71);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&n(e,t)},e.exports.default=e.exports,e.exports.__esModule=!0},43:function(e,t,r){var n=r(20).default,o=r(29);e.exports=function(e,t){return!t||"object"!==n(t)&&"function"!=typeof t?o(e):t},e.exports.default=e.exports,e.exports.__esModule=!0},44:function(e,t,r){"use strict";var n=r(40),o=r.n(n),c=r(41),a=r.n(c),i=r(29),s=r.n(i),u=r(42),l=r.n(u),p=r(43),f=r.n(p),b=r(30),d=r.n(b),m=r(4),y=r.n(m),g=(r(10),r(3)),v=r(1),O=r(83),_=function(e){var t=e.imageUrl,r=void 0===t?"".concat(O.l,"/block-error.svg"):t,n=e.header,o=void 0===n?Object(v.__)("Oops!","woo-gutenberg-products-block"):n,c=e.text,a=void 0===c?Object(v.__)("There was an error loading the content.","woo-gutenberg-products-block"):c,i=e.errorMessage,s=e.errorMessagePrefix,u=void 0===s?Object(v.__)("Error:","woo-gutenberg-products-block"):s,l=e.button;return React.createElement("div",{className:"wc-block-error wc-block-components-error"},r&&React.createElement("img",{className:"wc-block-error__image wc-block-components-error__image",src:r,alt:""}),React.createElement("div",{className:"wc-block-error__content wc-block-components-error__content"},o&&React.createElement("p",{className:"wc-block-error__header wc-block-components-error__header"},o),a&&React.createElement("p",{className:"wc-block-error__text wc-block-components-error__text"},a),i&&React.createElement("p",{className:"wc-block-error__message wc-block-components-error__message"},u?u+" ":"",i),l&&React.createElement("p",{className:"wc-block-error__button wc-block-components-error__button"},l)))};r(81);var h=function(e){l()(c,e);var t,r,n=(t=c,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d()(t);if(r){var o=d()(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return f()(this,e)});function c(){var e;o()(this,c);for(var t=arguments.length,r=new Array(t),a=0;a<t;a++)r[a]=arguments[a];return e=n.call.apply(n,[this].concat(r)),y()(s()(e),"state",{errorMessage:"",hasError:!1}),e}return a()(c,[{key:"render",value:function(){var e=this.props,t=e.header,r=e.imageUrl,n=e.showErrorMessage,o=e.text,c=e.errorMessagePrefix,a=e.renderError,i=e.button,s=this.state,u=s.errorMessage;return s.hasError?"function"==typeof a?a({errorMessage:u}):React.createElement(_,{errorMessage:n?u:null,header:t,imageUrl:r,text:o,errorMessagePrefix:c,button:i}):this.props.children}}],[{key:"getDerivedStateFromError",value:function(e){return void 0!==e.statusText&&void 0!==e.status?{errorMessage:React.createElement(React.Fragment,null,React.createElement("strong",null,e.status),": ",e.statusText),hasError:!0}:{errorMessage:e.message,hasError:!0}}}]),c}(g.Component);h.defaultProps={showErrorMessage:!0},t.a=h},5:function(e,t,r){var n=r(84),o=r(85),c=r(67),a=r(86);e.exports=function(e,t){return n(e)||o(e,t)||c(e,t)||a()},e.exports.default=e.exports,e.exports.__esModule=!0},51:function(e,t,r){"use strict";var n=r(4),o=r.n(n),c=r(0),a=r(6),i=r.n(a);function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}t.a=function(e){var t,r=e.label,n=e.screenReaderLabel,o=e.wrapperElement,a=e.wrapperProps,s=void 0===a?{}:a,l=null!=r,p=null!=n;return!l&&p?(t=o||"span",s=u(u({},s),{},{className:i()(s.className,"screen-reader-text")}),React.createElement(t,s,n)):(t=o||c.Fragment,l&&p&&r!==n?React.createElement(t,s,React.createElement("span",{"aria-hidden":"true"},r),React.createElement("span",{className:"screen-reader-text"},n)):React.createElement(t,s,r))}},53:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(0),o=r(25),c=r.n(o);function a(e){var t=Object(n.useRef)(e);return c()(e,t.current)||(t.current=e),t.current}},6:function(e,t,r){var n;!function(){"use strict";var r={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var n=arguments[t];if(n){var c=typeof n;if("string"===c||"number"===c)e.push(n);else if(Array.isArray(n)){if(n.length){var a=o.apply(null,n);a&&e.push(a)}}else if("object"===c)if(n.toString===Object.prototype.toString)for(var i in n)r.call(n,i)&&n[i]&&e.push(i);else e.push(n.toString())}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(n=function(){return o}.apply(t,[]))||(e.exports=n)}()},62:function(e,t){e.exports=window.wc.priceFormat},64:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(0),o=Object(n.createContext)("page"),c=function(){return Object(n.useContext)(o)};o.Provider},67:function(e,t,r){var n=r(68);e.exports=function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}},e.exports.default=e.exports,e.exports.__esModule=!0},68:function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n},e.exports.default=e.exports,e.exports.__esModule=!0},7:function(e,t){e.exports=window.lodash},71:function(e,t){function r(t,n){return e.exports=r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},e.exports.default=e.exports,e.exports.__esModule=!0,r(t,n)}e.exports=r,e.exports.default=e.exports,e.exports.__esModule=!0},77:function(e,t){e.exports=function(e,t){if(null==e)return{};var r,n,o={},c=Object.keys(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||(o[r]=e[r]);return o},e.exports.default=e.exports,e.exports.__esModule=!0},79:function(e,t,r){"use strict";var n=r(80);function o(){}function c(){}c.resetWarningCache=o,e.exports=function(){function e(e,t,r,o,c,a){if(a!==n){var i=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 i.name="Invariant Violation",i}}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:c,resetWarningCache:o};return r.PropTypes=r,r}},8:function(e,t){e.exports=window.wc.wcBlocksData},80:function(e,t,r){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},81:function(e,t){},83:function(e,t,r){"use strict";r.d(t,"n",(function(){return c})),r.d(t,"l",(function(){return a})),r.d(t,"k",(function(){return i})),r.d(t,"m",(function(){return s})),r.d(t,"i",(function(){return u})),r.d(t,"d",(function(){return l})),r.d(t,"f",(function(){return p})),r.d(t,"j",(function(){return f})),r.d(t,"c",(function(){return b})),r.d(t,"e",(function(){return d})),r.d(t,"g",(function(){return m})),r.d(t,"a",(function(){return y})),r.d(t,"h",(function(){return g})),r.d(t,"b",(function(){return v}));var n,o=r(2),c=Object(o.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),a=c.pluginUrl+"images/",i=c.pluginUrl+"build/",s=c.buildPhase,u=null===(n=o.STORE_PAGES.shop)||void 0===n?void 0:n.permalink,l=(o.STORE_PAGES.checkout.id,o.STORE_PAGES.checkout.permalink),p=o.STORE_PAGES.privacy.permalink,f=(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),d=o.STORE_PAGES.myaccount.permalink?o.STORE_PAGES.myaccount.permalink:Object(o.getSetting)("wpLoginUrl","/wp-login.php"),m=Object(o.getSetting)("shippingCountries",{}),y=Object(o.getSetting)("allowedCountries",{}),g=Object(o.getSetting)("shippingStates",{}),v=Object(o.getSetting)("allowedStates",{})},84:function(e,t){e.exports=function(e){if(Array.isArray(e))return e},e.exports.default=e.exports,e.exports.__esModule=!0},85:function(e,t){e.exports=function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,c=[],_n=!0,a=!1;try{for(r=r.call(e);!(_n=(n=r.next()).done)&&(c.push(n.value),!t||c.length!==t);_n=!0);}catch(e){a=!0,o=e}finally{try{_n||null==r.return||r.return()}finally{if(a)throw o}}return c}},e.exports.default=e.exports,e.exports.__esModule=!0},86:function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.default=e.exports,e.exports.__esModule=!0},90:function(e,t,r){"use strict";r.d(t,"a",(function(){return b})),r.d(t,"b",(function(){return d})),r.d(t,"c",(function(){return m}));var n=r(5),o=r.n(n),c=r(8),a=r(11),i=r(0),s=r(25),u=r.n(s),l=r(53),p=r(99),f=r(64),b=function(e){var t=Object(f.a)();e=e||t;var r=Object(a.useSelect)((function(t){return t(c.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0)}),[e]),n=Object(a.useDispatch)(c.QUERY_STATE_STORE_KEY).setValueForQueryContext;return[r,Object(i.useCallback)((function(t){n(e,t)}),[e,n])]},d=function(e,t,r){var n=Object(f.a)();r=r||n;var o=Object(a.useSelect)((function(n){return n(c.QUERY_STATE_STORE_KEY).getValueForQueryKey(r,e,t)}),[r,e]),s=Object(a.useDispatch)(c.QUERY_STATE_STORE_KEY).setQueryValue;return[o,Object(i.useCallback)((function(t){s(r,e,t)}),[r,e,s])]},m=function(e,t){var r=Object(f.a)(),n=b(t=t||r),c=o()(n,2),a=c[0],s=c[1],d=Object(l.a)(a),m=Object(l.a)(e),y=Object(p.a)(m),g=Object(i.useRef)(!1);return Object(i.useEffect)((function(){u()(y,m)||(s(Object.assign({},d,m)),g.current=!0)}),[d,m,y,s]),g.current?[a,s]:[e,s]}},99:function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(3);function o(e,t){var r=Object(n.useRef)();return Object(n.useEffect)((function(){r.current===e||t&&!t(e,r.current)||(r.current=e)}),[e,t]),r.current}}});
|
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' => '457014276d6e0ad275390f78627cd552');
|
build/active-filters.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
-
this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["active-filters"]=function(e){function t(t){for(var r,a,i=t[0],l=t[1],s=t[2],b=0,p=[];b<i.length;b++)a=i[b],Object.prototype.hasOwnProperty.call(c,a)&&c[a]&&p.push(c[a][0]),c[a]=0;for(r in l)Object.prototype.hasOwnProperty.call(l,r)&&(e[r]=l[r]);for(u&&u(t);p.length;)p.shift()();return o.push.apply(o,s||[]),n()}function n(){for(var e,t=0;t<o.length;t++){for(var n=o[t],r=!0,i=1;i<n.length;i++){var l=n[i];0!==c[l]&&(r=!1)}r&&(o.splice(t--,1),e=a(a.s=n[0]))}return e}var r={},c={5:0},o=[];function a(t){if(r[t])return r[t].exports;var n=r[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,a),n.l=!0,n.exports}a.m=e,a.c=r,a.d=function(e,t,n){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},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 n=Object.create(null);if(a.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)a.d(n,r,function(t){return e[t]}.bind(null,r));return n},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="";var i=window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[],l=i.push.bind(i);i.push=t,i=i.slice();for(var s=0;s<i.length;s++)t(i[s]);var u=l;return o.push([
|
| 2 |
/* translators: %s: heading level e.g: "2", "3", "4" */
|
| 3 |
-
title:Object(m.sprintf)(Object(m.__)("Heading %d"),e),isActive:r,onClick:function(){return n(e)}}}},{key:"render",value:function(){var e=this,t=this.props,n=t.isCollapsed,r=void 0===n||n,c=t.minLevel,o=t.maxLevel,a=t.selectedLevel,i=t.onChange;return Object(f.createElement)(v.ToolbarGroup,{isCollapsed:r,icon:Object(f.createElement)(O,{level:a}),controls:Object(d.range)(c,o).map((function(t){return e.createLevelControl(t,a,i)}))})}}]),o}(f.Component);t.a=h},
|
| 4 |
/* translators: Remove chip. */
|
| 5 |
Object(u.__)("Remove","woo-gutenberg-products-block"):Object(u.sprintf)(
|
| 6 |
/* translators: %s text of the chip to remove. */
|
| 7 |
-
Object(u.__)('Remove "%s"',"woo-gutenberg-products-block"),k)}var x={"aria-label":n,disabled:f,onClick:O,onKeyDown:function(e){"Backspace"!==e.key&&"Delete"!==e.key||O()}},S=j?x:{},C=j?{"aria-hidden":!0}:x;return Object(i.createElement)(d,c()({},_,S,{className:s()(o,"is-removable"),element:j?"button":_.element,screenReaderText:y,text:g}),Object(i.createElement)(E,c()({className:"wc-block-components-chip__remove"},C),Object(i.createElement)(b.a,{className:"wc-block-components-chip__remove-icon",srcElement:p.a,size:16})))}},
|
| 8 |
/* translators: %1$s min price, %2$s max price */
|
| 9 |
Object(a.__)("Between %1$s and %2$s","woo-gutenberg-products-block"),Object(E.formatPrice)(e),Object(E.formatPrice)(t)):Number.isFinite(e)?Object(a.sprintf)(
|
| 10 |
/* translators: %s min price */
|
|
@@ -12,6 +12,6 @@ Object(a.__)("From %s","woo-gutenberg-products-block"),Object(E.formatPrice)(e))
|
|
| 12 |
/* translators: %s max price */
|
| 13 |
Object(a.__)("Up to %s","woo-gutenberg-products-block"),Object(E.formatPrice)(t))},S=function(e){var t=e.type,n=e.name,r=e.prefix,c=e.removeCallback,i=void 0===c?function(){}:c,l=e.showLabel,s=void 0===l||l,u=e.displayStyle,b=r?Object(o.createElement)(o.Fragment,null,r," ",n):n,p=Object(a.sprintf)(
|
| 14 |
/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */
|
| 15 |
-
Object(a.__)("Remove %s filter","woo-gutenberg-products-block"),n);return Object(o.createElement)("li",{className:"wc-block-active-filters__list-item",key:t+":"+n},s&&Object(o.createElement)("span",{className:"wc-block-active-filters__list-item-type"},t+": "),"chips"===u?Object(o.createElement)(k.a,{element:"span",text:b,onRemove:i,radius:"large",ariaLabel:p}):Object(o.createElement)("span",{className:"wc-block-active-filters__list-item-name"},b,Object(o.createElement)("button",{className:"wc-block-active-filters__list-item-remove",onClick:i},Object(o.createElement)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Object(o.createElement)("ellipse",{cx:"8",cy:"8",rx:"8",ry:"8",transform:"rotate(-180 8 8)",fill:"currentColor",fillOpacity:"0.7"}),Object(o.createElement)("rect",{x:"10.636",y:"3.94983",width:"2",height:"9.9466",transform:"rotate(45 10.636 3.94983)",fill:"white"}),Object(o.createElement)("rect",{x:"12.0503",y:"11.0209",width:"2",height:"9.9466",transform:"rotate(135 12.0503 11.0209)",fill:"white"})),Object(o.createElement)(y.a,{screenReaderLabel:p}))))},C=n(
|
| 16 |
/* translators: "Chips" is a tag-like display style for chosen attributes. */
|
| 17 |
-
label:Object(a.__)("Chips","woo-gutenberg-products-block"),value:"chips"}],onChange:function(e){return n({displayStyle:e})}}),Object(o.createElement)("p",null,Object(a.__)("Heading Level","woo-gutenberg-products-block")),Object(o.createElement)(m.a,{isCollapsed:!1,minLevel:2,maxLevel:7,selectedLevel:l,onChange:function(e){return n({headingLevel:e})}}))),Object(o.createElement)(v.a,{headingLevel:l,heading:i,onChange:function(e){return n({heading:e})}}),Object(o.createElement)(d.Disabled,null,Object(o.createElement)(L,{attributes:t,isEditor:!0})))}));Object(i.registerBlockType)("woocommerce/active-filters",{title:Object(a.__)("Active Product Filters","woo-gutenberg-products-block"),icon:{src:Object(o.createElement)(l.a,{srcElement:u}),foreground:"#96588a"},category:"woocommerce",keywords:[Object(a.__)("WooCommerce","woo-gutenberg-products-block")],description:Object(a.__)("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},example:{attributes:{}},attributes:{displayStyle:{type:"string",default:"list"},heading:{type:"string",default:Object(a.__)("Active filters","woo-gutenberg-products-block")},headingLevel:{type:"number",default:3}},edit:V,save:function(e){var t=e.attributes,n=t.className,r={"data-display-style":t.displayStyle,"data-heading":t.heading,"data-heading-level":t.headingLevel};return Object(o.createElement)("div",c()({className:p()("is-loading",n)},r),Object(o.createElement)("span",{"aria-hidden":!0,className:"wc-block-active-product-filters__placeholder"}))}})},
|
| 1 |
+
this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["active-filters"]=function(e){function t(t){for(var r,a,i=t[0],l=t[1],s=t[2],b=0,p=[];b<i.length;b++)a=i[b],Object.prototype.hasOwnProperty.call(c,a)&&c[a]&&p.push(c[a][0]),c[a]=0;for(r in l)Object.prototype.hasOwnProperty.call(l,r)&&(e[r]=l[r]);for(u&&u(t);p.length;)p.shift()();return o.push.apply(o,s||[]),n()}function n(){for(var e,t=0;t<o.length;t++){for(var n=o[t],r=!0,i=1;i<n.length;i++){var l=n[i];0!==c[l]&&(r=!1)}r&&(o.splice(t--,1),e=a(a.s=n[0]))}return e}var r={},c={5:0},o=[];function a(t){if(r[t])return r[t].exports;var n=r[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,a),n.l=!0,n.exports}a.m=e,a.c=r,a.d=function(e,t,n){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},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 n=Object.create(null);if(a.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)a.d(n,r,function(t){return e[t]}.bind(null,r));return n},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="";var i=window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[],l=i.push.bind(i);i.push=t,i=i.slice();for(var s=0;s<i.length;s++)t(i[s]);var u=l;return o.push([806,0]),n()}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},108:function(e,t,n){"use strict";n.d(t,"a",(function(){return f})),n.d(t,"b",(function(){return d})),n.d(t,"c",(function(){return m}));var r=n(8),c=n.n(r),o=n(24),a=n(14),i=n(0),l=n(34),s=n.n(l),u=n(62),b=n(136),p=n(78),f=function(e){var t=Object(p.a)();e=e||t;var n=Object(a.useSelect)((function(t){return t(o.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0)}),[e]),r=Object(a.useDispatch)(o.QUERY_STATE_STORE_KEY).setValueForQueryContext;return[n,Object(i.useCallback)((function(t){r(e,t)}),[e,r])]},d=function(e,t,n){var r=Object(p.a)();n=n||r;var c=Object(a.useSelect)((function(r){return r(o.QUERY_STATE_STORE_KEY).getValueForQueryKey(n,e,t)}),[n,e]),l=Object(a.useDispatch)(o.QUERY_STATE_STORE_KEY).setQueryValue;return[c,Object(i.useCallback)((function(t){l(n,e,t)}),[n,e,l])]},m=function(e,t){var n=Object(p.a)(),r=f(t=t||n),o=c()(r,2),a=o[0],l=o[1],d=Object(u.a)(a),m=Object(u.a)(e),v=Object(b.a)(m),O=Object(i.useRef)(!1);return Object(i.useEffect)((function(){s()(v,m)||(l(Object.assign({},d,m)),O.current=!0)}),[d,m,v,l]),O.current?[a,l]:[e,l]}},11:function(e,t){e.exports=window.React},12:function(e,t){e.exports=window.wp.blockEditor},123:function(e,t){},127:function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(8),c=n.n(r),o=n(0),a=function(){var e=Object(o.useState)(),t=c()(e,2)[1];return Object(o.useCallback)((function(e){t((function(){throw e}))}),[])}},133:function(e,t,n){"use strict";var r=n(17),c=n.n(r),o=n(18),a=n.n(o),i=n(19),l=n.n(i),s=n(20),u=n.n(s),b=n(10),p=n.n(b),f=n(0),d=n(7),m=n(1),v=n(4);function O(e){var t=e.level,n={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 n.hasOwnProperty(t)?Object(f.createElement)(v.SVG,{width:"20",height:"20",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg"},Object(f.createElement)(v.Path,{d:n[t]})):null}var h=function(e){l()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=p()(t);if(n){var c=p()(this).constructor;e=Reflect.construct(r,arguments,c)}else e=r.apply(this,arguments);return u()(this,e)});function o(){return c()(this,o),r.apply(this,arguments)}return a()(o,[{key:"createLevelControl",value:function(e,t,n){var r=e===t;return{icon:Object(f.createElement)(O,{level:e}),
|
| 2 |
/* translators: %s: heading level e.g: "2", "3", "4" */
|
| 3 |
+
title:Object(m.sprintf)(Object(m.__)("Heading %d"),e),isActive:r,onClick:function(){return n(e)}}}},{key:"render",value:function(){var e=this,t=this.props,n=t.isCollapsed,r=void 0===n||n,c=t.minLevel,o=t.maxLevel,a=t.selectedLevel,i=t.onChange;return Object(f.createElement)(v.ToolbarGroup,{isCollapsed:r,icon:Object(f.createElement)(O,{level:a}),controls:Object(d.range)(c,o).map((function(t){return e.createLevelControl(t,a,i)}))})}}]),o}(f.Component);t.a=h},136:function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(11);function c(e,t){var n=Object(r.useRef)();return Object(r.useEffect)((function(){n.current===e||t&&!t(e,n.current)||(n.current=e)}),[e,t]),n.current}},14:function(e,t){e.exports=window.wp.data},157:function(e,t,n){"use strict";var r=n(0),c=(n(2),n(12)),o=n(21),a=n(1);n(217),t.a=Object(o.withInstanceId)((function(e){var t=e.className,n=e.headingLevel,o=e.onChange,i=e.heading,l=e.instanceId,s="h".concat(n);return Object(r.createElement)(s,{className:t},Object(r.createElement)("label",{className:"screen-reader-text",htmlFor:"block-title-".concat(l)},Object(a.__)("Block title","woo-gutenberg-products-block")),Object(r.createElement)(c.PlainText,{id:"block-title-".concat(l),className:"wc-block-editor-components-title",value:i,onChange:o}))}))},165:function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(24),c=n(14),o=n(0),a=n(62),i=n(127),l=function(e){var t=e.namespace,n=e.resourceName,l=e.resourceValues,s=void 0===l?[]:l,u=e.query,b=void 0===u?{}:u,p=e.shouldSelect,f=void 0===p||p;if(!t||!n)throw new Error("The options object must have valid values for the namespace and the resource properties.");var d=Object(o.useRef)({results:[],isLoading:!0}),m=Object(a.a)(b),v=Object(a.a)(s),O=Object(i.a)(),h=Object(c.useSelect)((function(e){if(!f)return null;var c=e(r.COLLECTIONS_STORE_KEY),o=[t,n,m,v],a=c.getCollectionError.apply(c,o);return a&&O(a),{results:c.getCollection.apply(c,o),isLoading:!c.hasFinishedResolution("getCollection",o)}}),[t,n,v,m,f]);return null!==h&&(d.current=h),d.current}},179:function(e,t){},21:function(e,t){e.exports=window.wp.compose},217:function(e,t){},220:function(e,t,n){"use strict";var r=n(9),c=n.n(r),o=n(16),a=n.n(o),i=n(0),l=(n(2),n(6)),s=n.n(l),u=n(1),b=n(66),p=n(305),f=(n(179),["text","screenReaderText","element","className","radius","children"]),d=function(e){var t=e.text,n=e.screenReaderText,r=void 0===n?"":n,o=e.element,l=void 0===o?"li":o,u=e.className,b=void 0===u?"":u,p=e.radius,d=void 0===p?"small":p,m=e.children,v=void 0===m?null:m,O=a()(e,f),h=l,j=s()(b,"wc-block-components-chip","wc-block-components-chip--radius-"+d),g=Boolean(r&&r!==t);return Object(i.createElement)(h,c()({className:j},O),Object(i.createElement)("span",{"aria-hidden":g,className:"wc-block-components-chip__text"},t),g&&Object(i.createElement)("span",{className:"screen-reader-text"},r),v)},m=["ariaLabel","className","disabled","onRemove","removeOnAnyClick","text","screenReaderText"];t.a=function(e){var t=e.ariaLabel,n=void 0===t?"":t,r=e.className,o=void 0===r?"":r,l=e.disabled,f=void 0!==l&&l,v=e.onRemove,O=void 0===v?function(){}:v,h=e.removeOnAnyClick,j=void 0!==h&&h,g=e.text,w=e.screenReaderText,y=void 0===w?"":w,_=a()(e,m),E=j?"span":"button";if(!n){var k=y&&"string"==typeof y?y:g;n="string"!=typeof k?
|
| 4 |
/* translators: Remove chip. */
|
| 5 |
Object(u.__)("Remove","woo-gutenberg-products-block"):Object(u.sprintf)(
|
| 6 |
/* translators: %s text of the chip to remove. */
|
| 7 |
+
Object(u.__)('Remove "%s"',"woo-gutenberg-products-block"),k)}var x={"aria-label":n,disabled:f,onClick:O,onKeyDown:function(e){"Backspace"!==e.key&&"Delete"!==e.key||O()}},S=j?x:{},C=j?{"aria-hidden":!0}:x;return Object(i.createElement)(d,c()({},_,S,{className:s()(o,"is-removable"),element:j?"button":_.element,screenReaderText:y,text:g}),Object(i.createElement)(E,c()({className:"wc-block-components-chip__remove"},C),Object(i.createElement)(b.a,{className:"wc-block-components-chip__remove-icon",srcElement:p.a,size:16})))}},24:function(e,t){e.exports=window.wc.wcBlocksData},25:function(e,t){e.exports=window.wp.htmlEntities},26:function(e,t){e.exports=window.wp.blocks},278:function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return a}));var r=n(3),c=Object(r.getSetting)("attributes",[]).reduce((function(e,t){var n,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;return r.id&&e.push(r),e}),[]),o=function(e){if(e)return c.find((function(t){return t.id===e}))},a=function(e){if(e)return c.find((function(t){return t.taxonomy===e}))}},279:function(e,t,n){"use strict";n.d(t,"a",(function(){return c})),n.d(t,"b",(function(){return o}));var r=n(7),c=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},n=arguments.length>2?arguments[2]:void 0,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",o=e.filter((function(e){return e.attribute===n.taxonomy})),a=o.length?o[0]:null;if(a&&a.slug&&Array.isArray(a.slug)&&a.slug.includes(c)){var i=a.slug.filter((function(e){return e!==c})),l=e.filter((function(e){return e.attribute!==n.taxonomy}));i.length>0&&(a.slug=i.sort(),l.push(a)),t(Object(r.sortBy)(l,"attribute"))}},o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},n=arguments.length>2?arguments[2]:void 0,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"in",a=e.filter((function(e){return e.attribute!==n.taxonomy}));0===c.length?t(a):(a.push({attribute:n.taxonomy,operator:o,slug:c.map((function(e){return e.slug})).sort()}),t(Object(r.sortBy)(a,"attribute")))}},28:function(e,t){e.exports=window.wp.primitives},3:function(e,t){e.exports=window.wc.wcSettings},305:function(e,t,n){"use strict";var r=n(9),c=n.n(r),o=n(16),a=n.n(o),i=n(0),l=n(28),s=["className","size"],u=Object(i.createElement)((function(e){var t=e.className,n=e.size,r=a()(e,s);return Object(i.createElement)(l.SVG,c()({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=u},34:function(e,t){e.exports=window.wp.isShallowEqual},4:function(e,t){e.exports=window.wp.components},41:function(e,t,n){"use strict";var r=n(5),c=n.n(r),o=n(0),a=n(6),i=n.n(a);function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){c()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}t.a=function(e){var t,n=e.label,r=e.screenReaderLabel,c=e.wrapperElement,a=e.wrapperProps,l=void 0===a?{}:a,u=null!=n,b=null!=r;return!u&&b?(t=c||"span",l=s(s({},l),{},{className:i()(l.className,"screen-reader-text")}),Object(o.createElement)(t,l,r)):(t=c||o.Fragment,u&&b&&n!==r?Object(o.createElement)(t,l,Object(o.createElement)("span",{"aria-hidden":"true"},n),Object(o.createElement)("span",{className:"screen-reader-text"},r)):Object(o.createElement)(t,l,n))}},47:function(e,t){e.exports=window.wc.priceFormat},62:function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(0),c=n(34),o=n.n(c);function a(e){var t=Object(r.useRef)(e);return o()(e,t.current)||(t.current=e),t.current}},66:function(e,t,n){"use strict";var r=n(5),c=n.n(r),o=n(16),a=n.n(o),i=n(0),l=["srcElement","size"];function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}t.a=function(e){var t=e.srcElement,n=e.size,r=void 0===n?24:n,o=a()(e,l);return Object(i.isValidElement)(t)?Object(i.cloneElement)(t,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach((function(t){c()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({width:r,height:r},o)):null}},7:function(e,t){e.exports=window.lodash},78:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(0),c=Object(r.createContext)("page"),o=function(){return Object(r.useContext)(c)};c.Provider},806:function(e,t,n){e.exports=n(859)},807:function(e,t){},859:function(e,t,n){"use strict";n.r(t);var r=n(9),c=n.n(r),o=n(0),a=n(1),i=n(26),l=n(66),s=n(28),u=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 0h24v24H0z"}),Object(o.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=n(6),p=n.n(b),f=n(12),d=n(4),m=n(133),v=n(157),O=n(88),h=n(8),j=n.n(h),g=n(108),w=n(3),y=(n(2),n(41)),_=(n(807),n(278)),E=n(47),k=n(220),x=function(e,t){return Number.isFinite(e)&&Number.isFinite(t)?Object(a.sprintf)(
|
| 8 |
/* translators: %1$s min price, %2$s max price */
|
| 9 |
Object(a.__)("Between %1$s and %2$s","woo-gutenberg-products-block"),Object(E.formatPrice)(e),Object(E.formatPrice)(t)):Number.isFinite(e)?Object(a.sprintf)(
|
| 10 |
/* translators: %s min price */
|
| 12 |
/* translators: %s max price */
|
| 13 |
Object(a.__)("Up to %s","woo-gutenberg-products-block"),Object(E.formatPrice)(t))},S=function(e){var t=e.type,n=e.name,r=e.prefix,c=e.removeCallback,i=void 0===c?function(){}:c,l=e.showLabel,s=void 0===l||l,u=e.displayStyle,b=r?Object(o.createElement)(o.Fragment,null,r," ",n):n,p=Object(a.sprintf)(
|
| 14 |
/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */
|
| 15 |
+
Object(a.__)("Remove %s filter","woo-gutenberg-products-block"),n);return Object(o.createElement)("li",{className:"wc-block-active-filters__list-item",key:t+":"+n},s&&Object(o.createElement)("span",{className:"wc-block-active-filters__list-item-type"},t+": "),"chips"===u?Object(o.createElement)(k.a,{element:"span",text:b,onRemove:i,radius:"large",ariaLabel:p}):Object(o.createElement)("span",{className:"wc-block-active-filters__list-item-name"},b,Object(o.createElement)("button",{className:"wc-block-active-filters__list-item-remove",onClick:i},Object(o.createElement)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Object(o.createElement)("ellipse",{cx:"8",cy:"8",rx:"8",ry:"8",transform:"rotate(-180 8 8)",fill:"currentColor",fillOpacity:"0.7"}),Object(o.createElement)("rect",{x:"10.636",y:"3.94983",width:"2",height:"9.9466",transform:"rotate(45 10.636 3.94983)",fill:"white"}),Object(o.createElement)("rect",{x:"12.0503",y:"11.0209",width:"2",height:"9.9466",transform:"rotate(135 12.0503 11.0209)",fill:"white"})),Object(o.createElement)(y.a,{screenReaderLabel:p}))))},C=n(165),N=n(25),P=n(279),R=function(e){var t=e.attributeObject,n=void 0===t?{}:t,r=e.slugs,c=void 0===r?[]:r,i=e.operator,l=void 0===i?"in":i,s=e.displayStyle,u=Object(C.a)({namespace:"/wc/store",resourceName:"products/attributes/terms",resourceValues:[n.id]}),b=u.results,p=u.isLoading,f=Object(g.b)("attributes",[]),d=j()(f,2),m=d[0],v=d[1];if(p)return null;var O=n.label;return Object(o.createElement)("li",null,Object(o.createElement)("span",{className:"wc-block-active-filters__list-item-type"},O,":"),Object(o.createElement)("ul",null,c.map((function(e,t){var r=b.find((function(t){return t.slug===e}));if(!r)return null;var c="";return t>0&&"and"===l&&(c=Object(o.createElement)("span",{className:"wc-block-active-filters__list-item-operator"},Object(a.__)("and","woo-gutenberg-products-block"))),S({type:O,name:Object(N.decodeEntities)(r.name||e),prefix:c,removeCallback:function(){Object(P.a)(m,v,n,e)},showLabel:!1,displayStyle:s})}))))},L=function(e){var t=e.attributes,n=e.isEditor,r=void 0!==n&&n,c=Object(g.b)("attributes",[]),i=j()(c,2),l=i[0],s=i[1],u=Object(g.b)("stock_status",[]),b=j()(u,2),f=b[0],d=b[1],m=Object(g.b)("min_price"),v=j()(m,2),O=v[0],h=v[1],E=Object(g.b)("max_price"),k=j()(E,2),C=k[0],N=k[1],P=Object(w.getSetting)("stockStatusOptions",[]),L=Object(o.useMemo)((function(){if(f.length>0)return f.map((function(e){return S({type:Object(a.__)("Stock Status","woo-gutenberg-products-block"),name:P[e],removeCallback:function(){var t=f.filter((function(t){return t!==e}));d(t)},displayStyle:t.displayStyle})}))}),[P,f,d,t.displayStyle]),V=Object(o.useMemo)((function(){return Number.isFinite(O)||Number.isFinite(C)?S({type:Object(a.__)("Price","woo-gutenberg-products-block"),name:x(O,C),removeCallback:function(){h(void 0),N(void 0)},displayStyle:t.displayStyle}):null}),[O,C,t.displayStyle,h,N]),H=Object(o.useMemo)((function(){return l.map((function(e){var n=Object(_.b)(e.attribute);return Object(o.createElement)(R,{attributeObject:n,displayStyle:t.displayStyle,slugs:e.slug,key:e.attribute,operator:e.operator})}))}),[l,t.displayStyle]);if(!(l.length>0||f.length>0||Number.isFinite(O)||Number.isFinite(C)||r))return null;var z="h".concat(t.headingLevel),T=p()("wc-block-active-filters__list",{"wc-block-active-filters__list--chips":"chips"===t.displayStyle});return Object(o.createElement)(o.Fragment,null,!r&&t.heading&&Object(o.createElement)(z,{className:"wc-block-active-filters__title"},t.heading),Object(o.createElement)("div",{className:"wc-block-active-filters"},Object(o.createElement)("ul",{className:T},r?Object(o.createElement)(o.Fragment,null,S({type:Object(a.__)("Size","woo-gutenberg-products-block"),name:Object(a.__)("Small","woo-gutenberg-products-block"),displayStyle:t.displayStyle}),S({type:Object(a.__)("Color","woo-gutenberg-products-block"),name:Object(a.__)("Blue","woo-gutenberg-products-block"),displayStyle:t.displayStyle})):Object(o.createElement)(o.Fragment,null,V,L,H)),Object(o.createElement)("button",{className:"wc-block-active-filters__clear-all",onClick:function(){h(void 0),N(void 0),s([]),d([])}},Object(o.createElement)(y.a,{label:Object(a.__)("Clear All","woo-gutenberg-products-block"),screenReaderLabel:Object(a.__)("Clear All Filters","woo-gutenberg-products-block")}))))},V=Object(d.withSpokenMessages)((function(e){var t=e.attributes,n=e.setAttributes,r=t.className,c=t.displayStyle,i=t.heading,l=t.headingLevel;return Object(o.createElement)("div",{className:r},Object(o.createElement)(f.InspectorControls,{key:"inspector"},Object(o.createElement)(d.PanelBody,{title:Object(a.__)("Block Settings","woo-gutenberg-products-block")},Object(o.createElement)(O.a,{label:Object(a.__)("Display Style","woo-gutenberg-products-block"),value:c,options:[{label:Object(a.__)("List","woo-gutenberg-products-block"),value:"list"},{
|
| 16 |
/* translators: "Chips" is a tag-like display style for chosen attributes. */
|
| 17 |
+
label:Object(a.__)("Chips","woo-gutenberg-products-block"),value:"chips"}],onChange:function(e){return n({displayStyle:e})}}),Object(o.createElement)("p",null,Object(a.__)("Heading Level","woo-gutenberg-products-block")),Object(o.createElement)(m.a,{isCollapsed:!1,minLevel:2,maxLevel:7,selectedLevel:l,onChange:function(e){return n({headingLevel:e})}}))),Object(o.createElement)(v.a,{className:"wc-block-active-filters__title",headingLevel:l,heading:i,onChange:function(e){return n({heading:e})}}),Object(o.createElement)(d.Disabled,null,Object(o.createElement)(L,{attributes:t,isEditor:!0})))}));Object(i.registerBlockType)("woocommerce/active-filters",{title:Object(a.__)("Active Product Filters","woo-gutenberg-products-block"),icon:{src:Object(o.createElement)(l.a,{srcElement:u}),foreground:"#96588a"},category:"woocommerce",keywords:[Object(a.__)("WooCommerce","woo-gutenberg-products-block")],description:Object(a.__)("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},example:{attributes:{}},attributes:{displayStyle:{type:"string",default:"list"},heading:{type:"string",default:Object(a.__)("Active filters","woo-gutenberg-products-block")},headingLevel:{type:"number",default:3}},edit:V,save:function(e){var t=e.attributes,n=t.className,r={"data-display-style":t.displayStyle,"data-heading":t.heading,"data-heading-level":t.headingLevel};return Object(o.createElement)("div",c()({className:p()("is-loading",n)},r),Object(o.createElement)("span",{"aria-hidden":!0,className:"wc-block-active-product-filters__placeholder"}))}})},88:function(e,t,n){"use strict";var r=n(9),c=n.n(r),o=n(17),a=n.n(o),i=n(18),l=n.n(i),s=n(13),u=n.n(s),b=n(19),p=n.n(b),f=n(20),d=n.n(f),m=n(10),v=n.n(m),O=n(0),h=n(7),j=n(6),g=n.n(j),w=n(4),y=n(21);n(123);var _=function(e){p()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=v()(t);if(n){var c=v()(this).constructor;e=Reflect.construct(r,arguments,c)}else e=r.apply(this,arguments);return d()(this,e)});function o(){var e;return a()(this,o),(e=r.apply(this,arguments)).onClick=e.onClick.bind(u()(e)),e}return l()(o,[{key:"onClick",value:function(e){this.props.onChange&&this.props.onChange(e.target.value)}},{key:"render",value:function(){var e,t=this,n=this.props,r=n.label,o=n.checked,a=n.instanceId,i=n.className,l=n.help,s=n.options,u=n.value,b="inspector-toggle-button-control-".concat(a);return l&&(e=Object(h.isFunction)(l)?l(o):l),Object(O.createElement)(w.BaseControl,{id:b,help:e,className:g()("components-toggle-button-control",i)},Object(O.createElement)("label",{id:b+"__label",htmlFor:b,className:"components-toggle-button-control__label"},r),Object(O.createElement)(w.ButtonGroup,{"aria-labelledby":b+"__label"},s.map((function(e,n){var o={};return u===e.value?(o.isPrimary=!0,o["aria-pressed"]=!0):(o.isSecondary=!0,o["aria-pressed"]=!1),Object(O.createElement)(w.Button,c()({key:"".concat(e.label,"-").concat(e.value,"-").concat(n),value:e.value,onClick:t.onClick,"aria-label":r+": "+e.label},o),e.label)}))))}}]),o}(O.Component);t.a=Object(y.withInstanceId)(_)}});
|
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-keycodes', '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-keycodes', 'wp-polyfill', 'wp-primitives', 'wp-url', 'wp-warning', 'wp-wordcount'), 'version' => 'aac86aeec6b56567933ee06429825fa9');
|
build/all-products-frontend.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
-
!function(e){function t(t){for(var r,o,c=t[0],i=t[1],a=0,s=[];a<c.length;a++)o=c[a],Object.prototype.hasOwnProperty.call(n,o)&&n[o]&&s.push(n[o][0]),n[o]=0;for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r]);for(u&&u(t);s.length;)s.shift()()}var r={},n={1:0};function o(t){if(r[t])return r[t].exports;var n=r[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,o),n.l=!0,n.exports}o.e=function(e){var t=[],r=n[e];if(0!==r)if(r)t.push(r[2]);else{var c=new Promise((function(t,o){r=n[e]=[t,o]}));t.push(r[2]=c);var i,a=document.createElement("script");a.charset="utf-8",a.timeout=120,o.nc&&a.setAttribute("nonce",o.nc),a.src=function(e){return o.p+""+({2:"atomic-block-components/add-to-cart",3:"atomic-block-components/button",4:"atomic-block-components/category-list",5:"atomic-block-components/image",6:"atomic-block-components/price",7:"atomic-block-components/rating",8:"atomic-block-components/sale-badge",9:"atomic-block-components/sku",10:"atomic-block-components/stock-indicator",11:"atomic-block-components/summary",12:"atomic-block-components/tag-list",13:"atomic-block-components/title",24:"vendors--atomic-block-components/add-to-cart",25:"vendors--atomic-block-components/price"}[e]||e)+"-frontend.js"}(e);var u=new Error;i=function(t){a.onerror=a.onload=null,clearTimeout(s);var r=n[e];if(0!==r){if(r){var o=t&&("load"===t.type?"missing":t.type),c=t&&t.target&&t.target.src;u.message="Loading chunk "+e+" failed.\n("+o+": "+c+")",u.name="ChunkLoadError",u.type=o,u.request=c,r[1](u)}n[e]=void 0}};var s=setTimeout((function(){i({type:"timeout",target:a})}),12e4);a.onerror=a.onload=i,document.head.appendChild(a)}return Promise.all(t)},o.m=e,o.c=r,o.d=function(e,t,r){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)o.d(r,n,function(t){return e[t]}.bind(null,n));return r},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o.oe=function(e){throw console.error(e),e};var c=window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[],i=c.push.bind(c);c.push=t,c=c.slice();for(var a=0;a<c.length;a++)t(c[a]);var u=i;o(o.s=262)}([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,r){var n;!function(){"use strict";var r={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var n=arguments[t];if(n){var c=typeof n;if("string"===c||"number"===c)e.push(n);else if(Array.isArray(n)){if(n.length){var i=o.apply(null,n);i&&e.push(i)}}else if("object"===c)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?(o.default=o,e.exports=o):void 0===(n=function(){return o}.apply(t,[]))||(e.exports=n)}()},function(e,t){e.exports=window.React},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},function(e,t,r){var n=r(89),o=r(90),c=r(71),i=r(91);e.exports=function(e,t){return n(e)||o(e,t)||c(e,t)||i()},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=window.lodash},function(e,t){e.exports=window.wc.wcBlocksData},function(e,t,r){e.exports=r(80)()},function(e,t,r){"use strict";function n(e){return(n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}r.d(t,"a",(function(){return n}))},function(e,t){e.exports=window.wp.data},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},function(e,t,r){"use strict";function n(){return(n=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}).apply(this,arguments)}r.d(t,"a",(function(){return n}))},function(e,t,r){"use strict";function n(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}r.d(t,"a",(function(){return n}))},function(e,t,r){"use strict";r.d(t,"o",(function(){return c})),r.d(t,"n",(function(){return i})),r.d(t,"m",(function(){return a})),r.d(t,"j",(function(){return s})),r.d(t,"d",(function(){return l})),r.d(t,"g",(function(){return p})),r.d(t,"f",(function(){return f})),r.d(t,"l",(function(){return d})),r.d(t,"k",(function(){return b})),r.d(t,"c",(function(){return m})),r.d(t,"e",(function(){return h})),r.d(t,"h",(function(){return g})),r.d(t,"a",(function(){return O})),r.d(t,"i",(function(){return v})),r.d(t,"b",(function(){return y})),r.d(t,"p",(function(){return w}));var n,o=r(2),c=Object(o.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),i=c.pluginUrl+"images/",a=c.pluginUrl+"build/",u=c.buildPhase,s=null===(n=o.STORE_PAGES.shop)||void 0===n?void 0:n.permalink,l=(o.STORE_PAGES.checkout.id,o.STORE_PAGES.checkout.permalink),p=o.STORE_PAGES.privacy.permalink,f=o.STORE_PAGES.privacy.title,d=o.STORE_PAGES.terms.permalink,b=o.STORE_PAGES.terms.title,m=(o.STORE_PAGES.cart.id,o.STORE_PAGES.cart.permalink),h=o.STORE_PAGES.myaccount.permalink?o.STORE_PAGES.myaccount.permalink:Object(o.getSetting)("wpLoginUrl","/wp-login.php"),g=Object(o.getSetting)("shippingCountries",{}),O=Object(o.getSetting)("allowedCountries",{}),v=Object(o.getSetting)("shippingStates",{}),y=Object(o.getSetting)("allowedStates",{}),w=(r(53),function(){return u>1})},function(e,t,r){"use strict";function n(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},c=Object.keys(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}r.d(t,"a",(function(){return n}))},function(e,t,r){var n=r(79);e.exports=function(e,t){if(null==e)return{};var r,o,c=n(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)r=i[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(c[r]=e[r])}return c},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}r.d(t,"a",(function(){return n}))},function(e,t,r){"use strict";function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function o(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}r.d(t,"a",(function(){return o}))},function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(83);function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Object(n.a)(e,t)}},function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(22),o=r.n(n),c=r(14);function i(e,t){return!t||"object"!==o()(t)&&"function"!=typeof t?Object(c.a)(e):t}},function(e,t){function r(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(e.exports=r=function(e){return typeof e},e.exports.default=e.exports,e.exports.__esModule=!0):(e.exports=r=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.default=e.exports,e.exports.__esModule=!0),r(t)}e.exports=r,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=window.wp.compose},function(e,t){e.exports=window.wp.htmlEntities},function(e,t,r){"use strict";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.d(t,"a",(function(){return n}))},function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(70);function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,c=[],_n=!0,i=!1;try{for(r=r.call(e);!(_n=(n=r.next()).done)&&(c.push(n.value),!t||c.length!==t);_n=!0);}catch(e){i=!0,o=e}finally{try{_n||null==r.return||r.return()}finally{if(i)throw o}}return c}}(e,t)||Object(n.a)(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}},function(e,t){e.exports=window.wp.isShallowEqual},,function(e,t){e.exports=window.regeneratorRuntime},function(e,t){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.default=e.exports,e.exports.__esModule=!0},,function(e,t){function r(t){return e.exports=r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.default=e.exports,e.exports.__esModule=!0,r(t)}e.exports=r,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){"use strict";r.d(t,"a",(function(){return j}));var n=r(6),o=r.n(n),c=r(5),i=r.n(c),a=r(7),u=r(0),s=r(8),l=r(11),p=r(24),f=r(99),d=r(100),b=r(39);function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function h(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach((function(t){i()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var g={first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:""},O=h(h({},g),{},{email:""}),v={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:""},y=function(e){return Object(f.a)(Object.entries(e).map((function(e){var t=o()(e,2),r=t[0],n=t[1];return[r,Object(p.decodeEntities)(n)]})))},w={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:v,cartIsLoading:!0,cartErrors:s.EMPTY_CART_ERRORS,billingAddress:O,shippingAddress:g,shippingRates:s.EMPTY_SHIPPING_RATES,shippingRatesLoading:!1,cartHasCalculatedShipping:!1,paymentRequirements:s.EMPTY_PAYMENT_REQUIREMENTS,receiveCart:function(){},extensions:s.EMPTY_EXTENSIONS},j=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{shouldSelect:!0},t=Object(b.a)(),r=t.isEditor,n=t.previewData,o=null==n?void 0:n.previewCart,c=e.shouldSelect,i=Object(u.useRef)(),p=Object(l.useSelect)((function(e,t){var n=t.dispatch;if(!c)return w;if(r)return{cartCoupons:o.coupons,cartItems:o.items,cartFees:o.fees,cartItemsCount:o.items_count,cartItemsWeight:o.items_weight,cartNeedsPayment:o.needs_payment,cartNeedsShipping:o.needs_shipping,cartItemErrors:s.EMPTY_CART_ITEM_ERRORS,cartTotals:o.totals,cartIsLoading:!1,cartErrors:s.EMPTY_CART_ERRORS,billingAddress:O,shippingAddress:g,extensions:s.EMPTY_EXTENSIONS,shippingRates:o.shipping_rates,shippingRatesLoading:!1,cartHasCalculatedShipping:o.has_calculated_shipping,paymentRequirements:o.paymentRequirements,receiveCart:"function"==typeof(null==o?void 0:o.receiveCart)?o.receiveCart:function(){}};var i=e(s.CART_STORE_KEY),a=i.getCartData(),u=i.getCartErrors(),l=i.getCartTotals(),p=!i.hasFinishedResolution("getCartData"),f=i.isCustomerDataUpdating(),b=n(s.CART_STORE_KEY).receiveCart,m=y(a.billingAddress),v=a.needsShipping?y(a.shippingAddress):m,j=a.fees.length>0?a.fees.map((function(e){return y(e)})):s.EMPTY_CART_FEES;return{cartCoupons:a.coupons.length>0?a.coupons.map((function(e){return h(h({},e),{},{label:e.code})})):s.EMPTY_CART_COUPONS,cartItems:a.items,cartFees:j,cartItemsCount:a.itemsCount,cartItemsWeight:a.itemsWeight,cartNeedsPayment:a.needsPayment,cartNeedsShipping:a.needsShipping,cartItemErrors:a.errors,cartTotals:l,cartIsLoading:p,cartErrors:u,billingAddress:Object(d.a)(m),shippingAddress:Object(d.a)(v),extensions:a.extensions,shippingRates:a.shippingRates,shippingRatesLoading:f,cartHasCalculatedShipping:a.hasCalculatedShipping,paymentRequirements:a.paymentRequirements,receiveCart:b}}),[c]);return i.current&&Object(a.isEqual)(i.current,p)||(i.current=p),i.current}},function(e,t){e.exports=window.wp.primitives},function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(65),o=r(70);function c(e){return function(e){if(Array.isArray(e))return Object(n.a)(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Object(o.a)(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}},function(e,t){e.exports=window.wp.a11y},function(e,t,r){"use strict";var n=r(5),o=r.n(n),c=r(0),i=r(3),a=r.n(i);function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}t.a=function(e){var t,r=e.label,n=e.screenReaderLabel,o=e.wrapperElement,i=e.wrapperProps,u=void 0===i?{}:i,l=null!=r,p=null!=n;return!l&&p?(t=o||"span",u=s(s({},u),{},{className:a()(u.className,"screen-reader-text")}),React.createElement(t,u,n)):(t=o||c.Fragment,l&&p&&r!==n?React.createElement(t,u,React.createElement("span",{"aria-hidden":"true"},r),React.createElement("span",{className:"screen-reader-text"},n)):React.createElement(t,u,r))}},,function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(0),o=(r(11),Object(n.createContext)({isEditor:!1,currentPostId:0,previewData:{},getPreviewData:function(){}})),c=function(){return Object(n.useContext)(o)}},,,function(e,t){e.exports=window.wp.dom},function(e,t){e.exports=window.wc.wcBlocksRegistry},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}e.exports=function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){var n=r(75);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&n(e,t)},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){var n=r(22).default,o=r(30);e.exports=function(e,t){return!t||"object"!==n(t)&&"function"!=typeof t?o(e):t},e.exports.default=e.exports,e.exports.__esModule=!0},,function(e,t){e.exports=window.wp.deprecated},function(e,t){e.exports=window.wc.priceFormat},function(e,t){e.exports=window.wp.keycodes},,function(e,t){e.exports=window.wp.blocks},function(e,t,r){"use strict";var n=r(44),o=r.n(n),c=r(45),i=r.n(c),a=r(30),u=r.n(a),s=r(46),l=r.n(s),p=r(47),f=r.n(p),d=r(32),b=r.n(d),m=r(5),h=r.n(m),g=(r(9),r(4)),O=r(1),v=r(15),y=function(e){var t=e.imageUrl,r=void 0===t?"".concat(v.n,"/block-error.svg"):t,n=e.header,o=void 0===n?Object(O.__)("Oops!","woo-gutenberg-products-block"):n,c=e.text,i=void 0===c?Object(O.__)("There was an error loading the content.","woo-gutenberg-products-block"):c,a=e.errorMessage,u=e.errorMessagePrefix,s=void 0===u?Object(O.__)("Error:","woo-gutenberg-products-block"):u,l=e.button;return React.createElement("div",{className:"wc-block-error wc-block-components-error"},r&&React.createElement("img",{className:"wc-block-error__image wc-block-components-error__image",src:r,alt:""}),React.createElement("div",{className:"wc-block-error__content wc-block-components-error__content"},o&&React.createElement("p",{className:"wc-block-error__header wc-block-components-error__header"},o),i&&React.createElement("p",{className:"wc-block-error__text wc-block-components-error__text"},i),a&&React.createElement("p",{className:"wc-block-error__message wc-block-components-error__message"},s?s+" ":"",a),l&&React.createElement("p",{className:"wc-block-error__button wc-block-components-error__button"},l)))};r(82);var w=function(e){l()(c,e);var t,r,n=(t=c,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=b()(t);if(r){var o=b()(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return f()(this,e)});function c(){var e;o()(this,c);for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return e=n.call.apply(n,[this].concat(r)),h()(u()(e),"state",{errorMessage:"",hasError:!1}),e}return i()(c,[{key:"render",value:function(){var e=this.props,t=e.header,r=e.imageUrl,n=e.showErrorMessage,o=e.text,c=e.errorMessagePrefix,i=e.renderError,a=e.button,u=this.state,s=u.errorMessage;return u.hasError?"function"==typeof i?i({errorMessage:s}):React.createElement(y,{errorMessage:n?s:null,header:t,imageUrl:r,text:o,errorMessagePrefix:c,button:a}):this.props.children}}],[{key:"getDerivedStateFromError",value:function(e){return void 0!==e.statusText&&void 0!==e.status?{errorMessage:React.createElement(React.Fragment,null,React.createElement("strong",null,e.status),": ",e.statusText),hasError:!0}:{errorMessage:e.message,hasError:!0}}}]),c}(g.Component);w.defaultProps={showErrorMessage:!0},t.a=w},,function(e,t,r){"use strict";r.d(t,"a",(function(){return l}));var n=r(5),o=r.n(n),c=r(78),i=r(0),a=r(33);function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var l=function(){var e=Object(a.a)(),t=Object(i.useRef)(e);return Object(i.useEffect)((function(){t.current=e}),[e]),{dispatchStoreEvent:Object(i.useCallback)((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(c.doAction)("experimental__woocommerce_blocks-".concat(e),t)}catch(e){console.error(e)}}),[]),dispatchCheckoutEvent:Object(i.useCallback)((function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(c.doAction)("experimental__woocommerce_blocks-checkout-".concat(e),s(s({},r),{},{storeCart:t.current}))}catch(e){console.error(e)}}),[])}}},function(e,t,r){"use strict";(function(e){var n=r(0),o=(r(77),Object(n.createContext)({slots:{},fills:{},registerSlot:function(){void 0!==e&&e.env},updateSlot:function(){},unregisterSlot:function(){},registerFill:function(){},unregisterFill:function(){}}));t.a=o}).call(this,r(109))},,,function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(0),o=r(27),c=r.n(o);function i(e){var t=Object(n.useRef)(e);return c()(e,t.current)||(t.current=e),t.current}},,,,,function(e,t,r){"use strict";function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}r.d(t,"a",(function(){return n}))},function(e,t){e.exports=window.wp.apiFetch},,,function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(0),o=Object(n.createContext)("page"),c=function(){return Object(n.useContext)(o)};o.Provider},function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(65);function o(e,t){if(e){if("string"==typeof e)return Object(n.a)(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Object(n.a)(e,t):void 0}}},function(e,t,r){var n=r(72);e.exports=function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r.d(t,"c",(function(){return i})),r.d(t,"b",(function(){return a})),r.d(t,"d",(function(){return u}));var n=r(22),o=r.n(n),c=function(e){return"number"==typeof e},i=function(e){return"string"==typeof e},a=function(e){return!function(e){return null===e}(e)&&"object"===o()(e)};function u(e,t){return a(e)&&t in e}},function(e,t,r){"use strict";var n=r(13),o=r(16),c=r(0),i=r(3),a=r.n(i),u=r(7),s=r(49),l=r.n(s),p=r(18),f=r(19),d=r(20),b=r(21),m=r(10),h=r(26),g=r(42),O=r(51),v=r(23),y=r(126),w=r(25);function j(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function E(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?j(Object(r),!0).forEach((function(t){Object(w.a)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _(e,t,r,n,o,c,i){var a=t.width,u="rtl"===document.documentElement.dir;"left"===r&&u?r="right":"right"===r&&u&&(r="left"),"left"===n&&u?n="right":"right"===n&&u&&(n="left");var s=Math.round(e.left+e.width/2),l={popoverLeft:s,contentWidth:(s-a/2>0?a/2:s)+(s+a/2>window.innerWidth?window.innerWidth-s:a/2)},p=e.left;"right"===n?p=e.right:"middle"!==c&&(p=s);var f=e.right;"left"===n?f=e.left:"middle"!==c&&(f=s);var d,b={popoverLeft:p,contentWidth:p-a>0?a:p},m={popoverLeft:f,contentWidth:f+a>window.innerWidth?window.innerWidth-f:a},h=r,g=null;if(!o)if("center"===r&&l.contentWidth===a)h="center";else if("left"===r&&b.contentWidth===a)h="left";else if("right"===r&&m.contentWidth===a)h="right";else{var O="left"==(h=b.contentWidth>m.contentWidth?"left":"right")?b.contentWidth:m.contentWidth;g=O!==a?O:null}if(d="center"===h?l.popoverLeft:"left"===h?b.popoverLeft:m.popoverLeft,i){var v=i.getBoundingClientRect();d=Math.min(d,v.right-a)}return{xAxis:h,popoverLeft:d,contentWidth:g}}function x(e,t,r,n,o,c,i){var a=t.height;if(o){var u=(Object(g.getScrollContainer)(c)||document.body).getBoundingClientRect().top+a-i;if(e.top<=u)return{yAxis:r,popoverTop:Math.min(e.bottom,u)}}var s=e.top+e.height/2;"bottom"===n?s=e.bottom:"top"===n&&(s=e.top);var l={popoverTop:s,contentHeight:(s-a/2>0?a/2:s)+(s+a/2>window.innerHeight?window.innerHeight-s:a/2)},p={popoverTop:e.top,contentHeight:e.top-10-a>0?a:e.top-10},f={popoverTop:e.bottom,contentHeight:e.bottom+10+a>window.innerHeight?window.innerHeight-10-e.bottom:a},d=r,b=null;if(!o)if("middle"===r&&l.contentHeight===a)d="middle";else if("top"===r&&p.contentHeight===a)d="top";else if("bottom"===r&&f.contentHeight===a)d="bottom";else{var m="top"==(d=p.contentHeight>f.contentHeight?"top":"bottom")?p.contentHeight:f.contentHeight;b=m!==a?m:null}return{yAxis:d,popoverTop:"middle"===d?l.popoverTop:"top"===d?p.popoverTop:f.popoverTop,contentHeight:b}}var R=r(35),k=r(14);var P=Object(c.createContext)({focusHistory:[]}),S=P.Provider,C=P.Consumer;S.displayName="FocusReturnProvider",C.displayName="FocusReturnConsumer",c.Component;var T=Object(v.createHigherOrderComponent)((function e(t){if((n=t)instanceof c.Component||"function"==typeof n){var r=t;return e({})(r)}var n,o=t.onFocusReturn,i=void 0===o?u.stubTrue:o;return function(e){var t=function(t){Object(d.a)(a,t);var r,n,o=(r=a,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=Object(m.a)(r);if(n){var o=Object(m.a)(this).constructor;e=Reflect.construct(t,arguments,o)}else e=t.apply(this,arguments);return Object(b.a)(this,e)});function a(){var e;return Object(p.a)(this,a),(e=o.apply(this,arguments)).ownFocusedElements=new Set,e.activeElementOnMount=document.activeElement,e.setIsFocusedFalse=function(){return e.isFocused=!1},e.setIsFocusedTrue=function(t){e.ownFocusedElements.add(t.target),e.isFocused=!0},e}return Object(f.a)(a,[{key:"componentWillUnmount",value:function(){var e=this.activeElementOnMount,t=this.isFocused,r=this.ownFocusedElements;if(t&&!1!==i())for(var n,o=[].concat(Object(R.a)(u.without.apply(void 0,[this.props.focus.focusHistory].concat(Object(R.a)(r)))),[e]);n=o.pop();)if(document.body.contains(n))return void n.focus()}},{key:"render",value:function(){return Object(c.createElement)("div",{onFocus:this.setIsFocusedTrue,onBlur:this.setIsFocusedFalse},Object(c.createElement)(e,this.props.childProps))}}]),a}(c.Component);return function(e){return Object(c.createElement)(C,null,(function(r){return Object(c.createElement)(t,{childProps:e,focus:r})}))}}}),"withFocusReturn");var N=Object(v.createHigherOrderComponent)((function(e){return function(t){Object(d.a)(i,t);var r,n,o=(r=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=Object(m.a)(r);if(n){var o=Object(m.a)(this).constructor;e=Reflect.construct(t,arguments,o)}else e=t.apply(this,arguments);return Object(b.a)(this,e)});function i(){var e;return Object(p.a)(this,i),(e=o.apply(this,arguments)).focusContainRef=Object(c.createRef)(),e.handleTabBehaviour=e.handleTabBehaviour.bind(Object(k.a)(e)),e}return Object(f.a)(i,[{key:"handleTabBehaviour",value:function(e){if(e.keyCode===O.TAB){var t=g.focus.tabbable.find(this.focusContainRef.current);if(t.length){var r=t[0],n=t[t.length-1];e.shiftKey&&e.target===r?(e.preventDefault(),n.focus()):(e.shiftKey||e.target!==n)&&t.includes(e.target)||(e.preventDefault(),r.focus())}}}},{key:"render",value:function(){return Object(c.createElement)("div",{onKeyDown:this.handleTabBehaviour,ref:this.focusContainRef,tabIndex:"-1"},Object(c.createElement)(e,this.props))}}]),i}(c.Component)}),"withConstrainedTabbing"),D=r(86);var M=function(e){Object(d.a)(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=Object(m.a)(t);if(r){var o=Object(m.a)(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return Object(b.a)(this,e)});function o(){return Object(p.a)(this,o),n.apply(this,arguments)}return Object(f.a)(o,[{key:"handleFocusOutside",value:function(e){this.props.onFocusOutside(e)}},{key:"render",value:function(){return this.props.children}}]),o}(c.Component),A=Object(D.a)(M);function F(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=Object(m.a)(e);if(t){var o=Object(m.a)(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return Object(b.a)(this,r)}}var I=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.htmlDocument,r=void 0===t?document:t,n=e.className,o=void 0===n?"lockscroll":n,i=0,a=0;function u(e){var t=r.scrollingElement||r.body;e&&(a=t.scrollTop);var n=e?"add":"remove";t.classList[n](o),r.documentElement.classList[n](o),e||(t.scrollTop=a)}function s(){0===i&&u(!0),++i}function l(){1===i&&u(!1),--i}return function(e){Object(d.a)(r,e);var t=F(r);function r(){return Object(p.a)(this,r),t.apply(this,arguments)}return Object(f.a)(r,[{key:"componentDidMount",value:function(){s()}},{key:"componentWillUnmount",value:function(){l()}},{key:"render",value:function(){return null}}]),r}(c.Component)}();function B(e){e.stopPropagation()}var L=Object(c.forwardRef)((function(e,t){var r=e.children,i=Object(o.a)(e,["children"]);return Object(c.createElement)("div",Object(n.a)({},i,{ref:t,onMouseDown:B}),r)})),z=r(57);function H(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function U(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?H(Object(r),!0).forEach((function(t){Object(w.a)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):H(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function W(e){var t=Object(c.useContext)(z.a),r=t.slots[e]||{},n=t.fills[e],o=Object(c.useMemo)((function(){return n||[]}),[n]),i=Object(c.useCallback)((function(r){t.updateSlot(e,r)}),[e,t.updateSlot]),a=Object(c.useCallback)((function(r){t.unregisterSlot(e,r)}),[e,t.unregisterSlot]),u=Object(c.useCallback)((function(r){t.registerFill(e,r)}),[e,t.registerFill]),s=Object(c.useCallback)((function(r){t.unregisterFill(e,r)}),[e,t.unregisterFill]);return U(U({},r),{},{updateSlot:i,unregisterSlot:a,fills:o,registerFill:u,unregisterFill:s})}function Y(e,t,r){return(Y="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=Object(m.a)(e)););return e}(e,t);if(n){var o=Object.getOwnPropertyDescriptor(n,t);return o.get?o.get.call(r):o.value}})(e,t,r||e)}r(27);var q=Object(c.createContext)({registerSlot:function(){},unregisterSlot:function(){},registerFill:function(){},unregisterFill:function(){},getSlot:function(){},getFills:function(){},subscribe:function(){}}),V=(q.Provider,q.Consumer);c.Component;var G=function(e){Object(d.a)(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=Object(m.a)(t);if(r){var o=Object(m.a)(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return Object(b.a)(this,e)});function o(){var e;return Object(p.a)(this,o),(e=n.apply(this,arguments)).isUnmounted=!1,e.bindNode=e.bindNode.bind(Object(k.a)(e)),e}return Object(f.a)(o,[{key:"componentDidMount",value:function(){(0,this.props.registerSlot)(this.props.name,this)}},{key:"componentWillUnmount",value:function(){var e=this.props.unregisterSlot;this.isUnmounted=!0,e(this.props.name,this)}},{key:"componentDidUpdate",value:function(e){var t=this.props,r=t.name,n=t.unregisterSlot,o=t.registerSlot;e.name!==r&&(n(e.name),o(r,this))}},{key:"bindNode",value:function(e){this.node=e}},{key:"forceUpdate",value:function(){this.isUnmounted||Y(Object(m.a)(o.prototype),"forceUpdate",this).call(this)}},{key:"render",value:function(){var e=this.props,t=e.children,r=e.name,n=e.fillProps,o=void 0===n?{}:n,i=e.getFills,a=Object(u.map)(i(r,this),(function(e){var t=e.occurrence,r=Object(u.isFunction)(e.children)?e.children(o):e.children;return c.Children.map(r,(function(e,r){if(!e||Object(u.isString)(e))return e;var n="".concat(t,"---").concat(e.key||r);return Object(c.cloneElement)(e,{key:n})}))})).filter(Object(u.negate)(c.isEmptyElement));return Object(c.createElement)(c.Fragment,null,Object(u.isFunction)(t)?t(a):a)}}]),o}(c.Component),K=function(e){return Object(c.createElement)(V,null,(function(t){var r=t.registerSlot,o=t.unregisterSlot,i=t.getFills;return Object(c.createElement)(G,Object(n.a)({},e,{registerSlot:r,unregisterSlot:o,getFills:i}))}))},Q=0;function J(e){var t=e.name,r=e.children,n=e.registerFill,o=e.unregisterFill,i=function(e){var t=Object(c.useContext)(q),r=t.getSlot,n=t.subscribe,o=Object(c.useState)(r(e)),i=Object(h.a)(o,2),a=i[0],u=i[1];return Object(c.useEffect)((function(){return u(r(e)),n((function(){u(r(e))}))}),[e]),a}(t),a=Object(c.useRef)({name:t,children:r});return a.current.occurrence||(a.current.occurrence=++Q),Object(c.useLayoutEffect)((function(){return n(t,a.current),function(){return o(t,a.current)}}),[]),Object(c.useLayoutEffect)((function(){a.current.children=r,i&&i.forceUpdate()}),[r]),Object(c.useLayoutEffect)((function(){t!==a.current.name&&(o(a.current.name,a.current),a.current.name=t,n(t,a.current))}),[t]),i&&i.node?(Object(u.isFunction)(r)&&(r=r(i.props.fillProps)),Object(c.createPortal)(r,i.node)):null}var X=function(e){return Object(c.createElement)(V,null,(function(t){var r=t.registerFill,o=t.unregisterFill;return Object(c.createElement)(J,Object(n.a)({},e,{registerFill:r,unregisterFill:o}))}))};function $(e){var t=e.name,r=e.fillProps,i=void 0===r?{}:r,a=e.as,u=void 0===a?"div":a,s=Object(o.a)(e,["name","fillProps","as"]),l=Object(c.useContext)(z.a),p=Object(c.useRef)();return Object(c.useLayoutEffect)((function(){return l.registerSlot(t,p,i),function(){l.unregisterSlot(t,p)}}),[l.registerSlot,l.unregisterSlot,t]),Object(c.useLayoutEffect)((function(){l.updateSlot(t,i)})),Object(c.createElement)(u,Object(n.a)({ref:p},s))}function Z(e){var t,r,n=e.name,o=e.children,i=W(n),a=Object(c.useRef)({rerender:(t=Object(c.useState)({}),r=Object(h.a)(t,2)[1],function(){return r({})})});return Object(c.useEffect)((function(){return i.registerFill(a),function(){i.unregisterFill(a)}}),[i.registerFill,i.unregisterFill]),i.ref&&i.ref.current?("function"==typeof o&&(o=o(i.fillProps)),Object(c.createPortal)(o,i.ref.current)):null}function ee(e){var t=e.bubblesVirtually,r=Object(o.a)(e,["bubblesVirtually"]);return t?Object(c.createElement)($,r):Object(c.createElement)(K,r)}function te(e){return Object(c.createElement)(c.Fragment,null,Object(c.createElement)(X,e),Object(c.createElement)(Z,e))}function re(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ne(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?re(Object(r),!0).forEach((function(t){Object(w.a)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):re(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function oe(e){var t=e.type,r=e.origin,n=void 0===r?function(e){return"appear"===e?"top":"left"}(t):r;if("appear"===t){var o,c=n.split(" "),i=Object(h.a)(c,2),u=i[0],s=i[1],l=void 0===s?"center":s;return a()("components-animate__appear",(o={},Object(w.a)(o,"is-from-"+l,"center"!==l),Object(w.a)(o,"is-from-"+u,"middle"!==u),o))}return"slide-in"===t?a()("components-animate__slide-in","is-from-"+n):"loading"===t?a()("components-animate__loading"):void 0}function ce(e){var t=e.type,r=e.options,n=void 0===r?{}:r;return(0,e.children)({className:oe(ne({type:t},n))})}var ie=N(T((function(e){return e.children})));function ae(e,t){var r,n=(r=t).ownerDocument.defaultView.getComputedStyle(r),o=n.paddingTop,c=n.paddingBottom,i=n.paddingLeft,a=n.paddingRight,u=o?parseInt(o,10):0,s=c?parseInt(c,10):0,l=i?parseInt(i,10):0,p=a?parseInt(a,10):0;return{x:e.left+l,y:e.top+u,width:e.width-l-p,height:e.height-u-s,left:e.left+l,right:e.right-p,top:e.top+u,bottom:e.bottom-s}}function ue(e,t,r){r?e.getAttribute(t)!==r&&e.setAttribute(t,r):e.hasAttribute(t)&&e.removeAttribute(t)}function se(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";e.style[t]!==r&&(e.style[t]=r)}function le(e,t,r){r?e.classList.contains(t)||e.classList.add(t):e.classList.contains(t)&&e.classList.remove(t)}var pe=function(e){var t=e.headerTitle,r=e.onClose,i=e.onKeyDown,u=e.children,s=e.className,p=e.noArrow,f=void 0===p||p,d=e.isAlternate,b=e.position,m=void 0===b?"bottom right":b,w=(e.range,e.focusOnMount),j=void 0===w?"firstElement":w,R=e.anchorRef,k=e.shouldAnchorIncludePadding,P=e.anchorRect,S=e.getAnchorRect,C=e.expandOnMobile,T=e.animate,N=void 0===T||T,D=e.onClickOutside,M=e.onFocusOutside,F=e.__unstableSticky,B=e.__unstableSlotName,z=void 0===B?"Popover":B,H=e.__unstableObserveElement,U=e.__unstableBoundaryParent,Y=Object(o.a)(e,["headerTitle","onClose","onKeyDown","children","className","noArrow","isAlternate","position","range","focusOnMount","anchorRef","shouldAnchorIncludePadding","anchorRect","getAnchorRect","expandOnMobile","animate","onClickOutside","onFocusOutside","__unstableSticky","__unstableSlotName","__unstableObserveElement","__unstableBoundaryParent"]),q=Object(c.useRef)(null),V=Object(c.useRef)(null),G=Object(c.useRef)(),K=Object(v.useViewportMatch)("medium","<"),Q=Object(c.useState)(),J=Object(h.a)(Q,2),X=J[0],$=J[1],Z=W(z),ee=C&&K,re=Object(v.useResizeObserver)(),ne=Object(h.a)(re,2),oe=ne[0],pe=ne[1];f=ee||f,Object(c.useLayoutEffect)((function(){if(ee)return le(G.current,"is-without-arrow",f),le(G.current,"is-alternate",d),ue(G.current,"data-x-axis"),ue(G.current,"data-y-axis"),se(G.current,"top"),se(G.current,"left"),se(V.current,"maxHeight"),void se(V.current,"maxWidth");var e=function(){if(G.current&&V.current){var e=function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=arguments.length>4?arguments[4]:void 0;if(t)return t;if(r){if(!e.current)return;return r(e.current)}if(!1!==n){if(!(n&&window.Range&&window.Element&&window.DOMRect))return;if(n instanceof window.Range)return Object(g.getRectangleFromRange)(n);if(n instanceof window.Element){var c=n.getBoundingClientRect();return o?c:ae(c,n)}var i=n.top,a=n.bottom,u=i.getBoundingClientRect(),s=a.getBoundingClientRect(),l=new window.DOMRect(u.left,u.top,u.width,s.bottom-u.top);return o?l:ae(l,n)}if(e.current){var p=e.current.parentNode,f=p.getBoundingClientRect();return o?f:ae(f,p)}}(q,P,S,R,k);if(e){var t,r,n=G.current,o=n.offsetParent,c=n.ownerDocument,i=0;if(o&&o!==c.body){var a=o.getBoundingClientRect();i=a.top,e=new window.DOMRect(e.left-a.left,e.top-a.top,e.width,e.height)}U&&(t=null===(r=G.current.closest(".popover-slot"))||void 0===r?void 0:r.parentNode);var u=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"top",n=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,c=arguments.length>5?arguments[5]:void 0,i=arguments.length>6?arguments[6]:void 0,a=r.split(" "),u=Object(h.a)(a,3),s=u[0],l=u[1],p=void 0===l?"center":l,f=u[2],d=x(e,t,s,f,n,o,c),b=_(e,t,p,f,n,d.yAxis,i);return E(E({},b),d)}(e,pe.height?pe:V.current.getBoundingClientRect(),m,F,G.current,i,t),s=u.popoverTop,l=u.popoverLeft,p=u.xAxis,b=u.yAxis,O=u.contentHeight,v=u.contentWidth;"number"==typeof s&&"number"==typeof l&&(se(G.current,"top",s+"px"),se(G.current,"left",l+"px")),le(G.current,"is-without-arrow",f||"center"===p&&"middle"===b),le(G.current,"is-alternate",d),ue(G.current,"data-x-axis",p),ue(G.current,"data-y-axis",b),se(V.current,"maxHeight","number"==typeof O?O+"px":""),se(V.current,"maxWidth","number"==typeof v?v+"px":""),$(({left:"right",right:"left"}[p]||"center")+" "+({top:"bottom",bottom:"top"}[b]||"middle"))}}};e();var t,r,n=window.setInterval(e,500),o=function(){window.cancelAnimationFrame(t),t=window.requestAnimationFrame(e)};return window.addEventListener("click",o),window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),H&&(r=new window.MutationObserver(e)).observe(H,{attributes:!0}),function(){window.clearInterval(n),window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0),window.removeEventListener("click",o),window.cancelAnimationFrame(t),r&&r.disconnect()}}),[ee,P,S,R,k,m,pe,F,H,U]),function(e,t){Object(c.useEffect)((function(){var r=setTimeout((function(){if(e&&t.current)if("firstElement"!==e)"container"===e&&t.current.focus();else{var r=g.focus.tabbable.find(t.current)[0];r?r.focus():t.current.focus()}}),0);return function(){return clearTimeout(r)}}),[])}(j,V);var fe=function(e){e.keyCode===O.ESCAPE&&r&&(e.stopPropagation(),r()),i&&i(e)},de=Object(c.createElement)(A,{onFocusOutside:function(e){if(M)M(e);else if(D){var t;try{t=new window.MouseEvent("click")}catch(e){(t=document.createEvent("MouseEvent")).initMouseEvent("click",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null)}Object.defineProperty(t,"target",{get:function(){return e.relatedTarget}}),l()("Popover onClickOutside prop",{alternative:"onFocusOutside"}),D(t)}else r&&r()}},Object(c.createElement)(ce,{type:N&&X?"appear":null,options:{origin:X}},(function(e){var o=e.className;return Object(c.createElement)(L,Object(n.a)({className:a()("components-popover",s,o,{"is-expanded":ee,"is-without-arrow":f,"is-alternate":d})},Y,{onKeyDown:fe,ref:G}),ee&&Object(c.createElement)(I,null),ee&&Object(c.createElement)("div",{className:"components-popover__header"},Object(c.createElement)("span",{className:"components-popover__header-title"},t),Object(c.createElement)(Oe,{className:"components-popover__close",icon:y.a,onClick:r})),Object(c.createElement)("div",{ref:V,className:"components-popover__content",tabIndex:"-1"},Object(c.createElement)("div",{style:{position:"relative"}},oe,u)))})));return j&&(de=Object(c.createElement)(ie,null,de)),Z.ref&&(de=Object(c.createElement)(te,{name:z},de)),R||P?de:Object(c.createElement)("span",{ref:q},de)};pe.Slot=function(e){var t=e.name,r=void 0===t?"Popover":t;return Object(c.createElement)(ee,{bubblesVirtually:!0,name:r,className:"popover-slot"})};var fe=pe,de=function(e){var t,r,n=e.shortcut,o=e.className;return n?(Object(u.isString)(n)&&(t=n),Object(u.isObject)(n)&&(t=n.display,r=n.ariaLabel),Object(c.createElement)("span",{className:o,"aria-label":r},t)):null};var be=function(e){Object(d.a)(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=Object(m.a)(t);if(r){var o=Object(m.a)(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return Object(b.a)(this,e)});function o(){var e;return Object(p.a)(this,o),(e=n.apply(this,arguments)).delayedSetIsOver=Object(u.debounce)((function(t){return e.setState({isOver:t})}),700),e.cancelIsMouseDown=e.createSetIsMouseDown(!1),e.isInMouseDown=!1,e.state={isOver:!1},e}return Object(f.a)(o,[{key:"componentWillUnmount",value:function(){this.delayedSetIsOver.cancel(),document.removeEventListener("mouseup",this.cancelIsMouseDown)}},{key:"emitToChild",value:function(e,t){var r=this.props.children;if(1===c.Children.count(r)){var n=c.Children.only(r);"function"==typeof n.props[e]&&n.props[e](t)}}},{key:"createToggleIsOver",value:function(e,t){var r=this;return function(n){if(r.emitToChild(e,n),!(n.currentTarget.disabled||"focus"===n.type&&r.isInMouseDown)){r.delayedSetIsOver.cancel();var o=Object(u.includes)(["focus","mouseenter"],n.type);o!==r.state.isOver&&(t?r.delayedSetIsOver(o):r.setState({isOver:o}))}}}},{key:"createSetIsMouseDown",value:function(e){var t=this;return function(r){t.emitToChild(e?"onMouseDown":"onMouseUp",r),document[e?"addEventListener":"removeEventListener"]("mouseup",t.cancelIsMouseDown),t.isInMouseDown=e}}},{key:"render",value:function(){var e=this.props,t=e.children,r=e.position,n=e.text,o=e.shortcut;if(1!==c.Children.count(t))return t;var i=c.Children.only(t),a=this.state.isOver;return Object(c.cloneElement)(i,{onMouseEnter:this.createToggleIsOver("onMouseEnter",!0),onMouseLeave:this.createToggleIsOver("onMouseLeave"),onClick:this.createToggleIsOver("onClick"),onFocus:this.createToggleIsOver("onFocus"),onBlur:this.createToggleIsOver("onBlur"),onMouseDown:this.createSetIsMouseDown(!0),children:Object(c.concatChildren)(i.props.children,a&&Object(c.createElement)(fe,{focusOnMount:!1,position:r,className:"components-tooltip","aria-hidden":"true",animate:!1,noArrow:!0},n,Object(c.createElement)(de,{className:"components-tooltip__shortcut",shortcut:o})))})}}]),o}(c.Component),me=r(92);function he(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var ge=["onMouseDown","onClick"],Oe=t.a=Object(c.forwardRef)((function(e,t){var r=e.href,i=e.target,s=e.isPrimary,p=e.isSmall,f=e.isTertiary,d=e.isPressed,b=e.isBusy,m=e.isDefault,h=e.isSecondary,g=e.isLink,O=e.isDestructive,v=e.className,y=e.disabled,w=e.icon,j=e.iconSize,E=e.showTooltip,_=e.tooltipPosition,x=e.shortcut,R=e.label,k=e.children,P=e.__experimentalIsFocusable,S=Object(o.a)(e,["href","target","isPrimary","isSmall","isTertiary","isPressed","isBusy","isDefault","isSecondary","isLink","isDestructive","className","disabled","icon","iconSize","showTooltip","tooltipPosition","shortcut","label","children","__experimentalIsFocusable"]);m&&l()("Button isDefault prop",{alternative:"isSecondary"});var C=a()("components-button",v,{"is-secondary":m||h,"is-primary":s,"is-small":p,"is-tertiary":f,"is-pressed":d,"is-busy":b,"is-link":g,"is-destructive":O,"has-text":!!w&&!!k,"has-icon":!!w}),T=y&&!P,N=void 0===r||T?"button":"a",D="a"===N?{href:r,target:i}:{type:"button",disabled:T,"aria-pressed":d};if(y&&P){D["aria-disabled"]=!0;var M,A=function(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return he(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?he(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,i=!0,a=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return i=e.done,e},e:function(e){a=!0,c=e},f:function(){try{i||null==r.return||r.return()}finally{if(a)throw c}}}}(ge);try{for(A.s();!(M=A.n()).done;)S[M.value]=function(e){e.stopPropagation(),e.preventDefault()}}catch(e){A.e(e)}finally{A.f()}}var F=!T&&(E&&R||x||!!R&&(!k||Object(u.isArray)(k)&&!k.length)&&!1!==E),I=Object(c.createElement)(N,Object(n.a)({},D,S,{className:C,"aria-label":S["aria-label"]||R,ref:t}),w&&Object(c.createElement)(me.a,{icon:w,size:j}),k);return F?Object(c.createElement)(be,{text:R,shortcut:x,position:_},I):I}))},function(e,t){function r(t,n){return e.exports=r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},e.exports.default=e.exports,e.exports.__esModule=!0,r(t,n)}e.exports=r,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=window.wp.url},function(e,t){e.exports=window.wp.warning},function(e,t){e.exports=window.wp.hooks},function(e,t){e.exports=function(e,t){if(null==e)return{};var r,n,o={},c=Object.keys(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||(o[r]=e[r]);return o},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){"use strict";var n=r(81);function o(){}function c(){}c.resetWarningCache=o,e.exports=function(){function e(e,t,r,o,c,i){if(i!==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:c,resetWarningCache:o};return r.PropTypes=r,r}},function(e,t,r){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t){},function(e,t,r){"use strict";function n(e,t){return(n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}r.d(t,"a",(function(){return n}))},,function(e,t,r){"use strict";var n=r(5),o=r.n(n),c=r(6),i=r.n(c),a=r(2),u=r(1),s=r(73);function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function p(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var f=Object(a.getSetting)("countryLocale",{}),d=function(e){var 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(u.sprintf)(
|
| 2 |
/* translators: %s Field label. */
|
| 3 |
-
Object(u.__)("%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},b=Object.entries(f).map((function(e){var t=i()(e,2),r=t[0],n=t[1];return[r,Object.entries(n).map((function(e){var t=i()(e,2),r=t[0],n=t[1];return[r,d(n)]})).reduce((function(e,t){var r=i()(t,2),n=r[0],o=r[1];return e[n]=o,e}),{})]})).reduce((function(e,t){var r=i()(t,2),n=r[0],o=r[1];return e[n]=o,e}),{});t.a=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=r&&void 0!==b[r]?b[r]:{};return e.map((function(e){var r=a.defaultAddressFields[e]||{},o=n[e]||{},c=t[e]||{};return p(p(p({key:e},r),o),c)})).sort((function(e,t){return e.index-t.index}))}},function(e,t,r){"use strict";var n=r(13),o=r(18),c=r(19),i=r(14),a=r(20),u=r(21),s=r(10),l=r(0),p=r(7),f=r(23);var d=["button","submit"];t.a=Object(f.createHigherOrderComponent)((function(e){return function(t){Object(a.a)(m,t);var r,f,b=(r=m,f=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=Object(s.a)(r);if(f){var n=Object(s.a)(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return Object(u.a)(this,e)});function m(){var e;return Object(o.a)(this,m),(e=b.apply(this,arguments)).bindNode=e.bindNode.bind(Object(i.a)(e)),e.cancelBlurCheck=e.cancelBlurCheck.bind(Object(i.a)(e)),e.queueBlurCheck=e.queueBlurCheck.bind(Object(i.a)(e)),e.normalizeButtonFocus=e.normalizeButtonFocus.bind(Object(i.a)(e)),e}return Object(c.a)(m,[{key:"componentWillUnmount",value:function(){this.cancelBlurCheck()}},{key:"bindNode",value:function(e){e?this.node=e:(delete this.node,this.cancelBlurCheck())}},{key:"queueBlurCheck",value:function(e){var t=this;e.persist(),this.preventBlurCheck||(this.blurCheckTimeout=setTimeout((function(){document.hasFocus()?"function"==typeof t.node.handleFocusOutside&&t.node.handleFocusOutside(e):e.preventDefault()}),0))}},{key:"cancelBlurCheck",value:function(){clearTimeout(this.blurCheckTimeout)}},{key:"normalizeButtonFocus",value:function(e){var t=e.type,r=e.target;Object(p.includes)(["mouseup","touchend"],t)?this.preventBlurCheck=!1:function(e){switch(e.nodeName){case"A":case"BUTTON":return!0;case"INPUT":return Object(p.includes)(d,e.type)}return!1}(r)&&(this.preventBlurCheck=!0)}},{key:"render",value:function(){return Object(l.createElement)("div",{onFocus:this.cancelBlurCheck,onMouseDown:this.normalizeButtonFocus,onMouseUp:this.normalizeButtonFocus,onTouchStart:this.normalizeButtonFocus,onTouchEnd:this.normalizeButtonFocus,onBlur:this.queueBlurCheck},Object(l.createElement)(e,Object(n.a)({ref:this.bindNode},this.props)))}}]),m}(l.Component)}),"withFocusOutside")},,,function(e,t){e.exports=function(e){if(Array.isArray(e))return e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,c=[],_n=!0,i=!1;try{for(r=r.call(e);!(_n=(n=r.next()).done)&&(c.push(n.value),!t||c.length!==t);_n=!0);}catch(e){i=!0,o=e}finally{try{_n||null==r.return||r.return()}finally{if(i)throw o}}return c}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){"use strict";var n=r(25),o=r(13),c=r(16),i=r(0),a=r(34),u=function(e){var t=e.icon,r=e.className,n=Object(c.a)(e,["icon","className"]),a=["dashicon","dashicons","dashicons-"+t,r].filter(Boolean).join(" ");return Object(i.createElement)("span",Object(o.a)({className:a},n))};function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){Object(n.a)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}t.a=function(e){var t=e.icon,r=void 0===t?null:t,n=e.size,s=Object(c.a)(e,["icon","size"]);if("string"==typeof r)return Object(i.createElement)(u,Object(o.a)({icon:r},s));if(r&&u===r.type)return Object(i.cloneElement)(r,l({},s));var p=n||24;if("function"==typeof r)return r.prototype instanceof i.Component?Object(i.createElement)(r,l({size:p},s)):r(l({size:p},s));if(r&&("svg"===r.type||r.type===a.SVG)){var f=l(l({width:p,height:p},r.props),s);return Object(i.createElement)(a.SVG,f)}return Object(i.isValidElement)(r)?Object(i.cloneElement)(r,l({size:p},s)):r}},,,function(e,t){e.exports=window.wp.autop},function(e,t,r){"use strict";r.d(t,"a",(function(){return d})),r.d(t,"b",(function(){return b})),r.d(t,"c",(function(){return m}));var n=r(6),o=r.n(n),c=r(8),i=r(11),a=r(0),u=r(27),s=r.n(u),l=r(60),p=r(116),f=r(69),d=function(e){var t=Object(f.a)();e=e||t;var r=Object(i.useSelect)((function(t){return t(c.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0)}),[e]),n=Object(i.useDispatch)(c.QUERY_STATE_STORE_KEY).setValueForQueryContext;return[r,Object(a.useCallback)((function(t){n(e,t)}),[e,n])]},b=function(e,t,r){var n=Object(f.a)();r=r||n;var o=Object(i.useSelect)((function(n){return n(c.QUERY_STATE_STORE_KEY).getValueForQueryKey(r,e,t)}),[r,e]),u=Object(i.useDispatch)(c.QUERY_STATE_STORE_KEY).setQueryValue;return[o,Object(a.useCallback)((function(t){u(r,e,t)}),[r,e,u])]},m=function(e,t){var r=Object(f.a)(),n=d(t=t||r),c=o()(n,2),i=c[0],u=c[1],b=Object(l.a)(i),m=Object(l.a)(e),h=Object(p.a)(m),g=Object(a.useRef)(!1);return Object(a.useEffect)((function(){s()(h,m)||(u(Object.assign({},b,m)),g.current=!0)}),[b,m,h,u]),g.current?[i,u]:[e,u]}},,,function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(6),o=r.n(n),c=function(e){return e.reduce((function(e,t){var r=o()(t,2),n=r[0],c=r[1];return e[n]=c,e}),{})}},function(e,t,r){"use strict";r.d(t,"b",(function(){return i})),r.d(t,"c",(function(){return a})),r.d(t,"a",(function(){return u}));var n=r(2),o=r(85),c=r(76),i=function(e){var t=e.country,r=void 0===t?"":t,n=e.state,o=void 0===n?"":n,c=e.city,i=void 0===c?"":c,a=e.postcode,u=void 0===a?"":a;return{country:r.trim(),state:o.trim(),city:i.trim(),postcode:u?u.replace(" ","").toUpperCase():""}},a=function(e){var t=e.email,r=void 0===t?"":t;return Object(c.isEmail)(r)?r.trim():""},u=function(e){var t=Object.keys(n.defaultAddressFields),r=Object(o.a)(t,{},e.country),c=Object.assign({},e);return r.forEach((function(t){var r=t.key,n=void 0===r?"":r,o=t.hidden;void 0!==o&&o&&function(e,t){return e in t}(n,e)&&(c[n]="")})),c}},,,,,,function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(6),o=r.n(n),c=r(0),i=function(){var e=Object(c.useState)(),t=o()(e,2)[1];return Object(c.useCallback)((function(e){t((function(){throw e}))}),[])}},function(e,t){e.exports=window.wc.wcBlocksSharedContext},,function(e,t){var r,n,o=e.exports={};function c(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function a(e){if(r===setTimeout)return setTimeout(e,0);if((r===c||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:c}catch(e){r=c}try{n="function"==typeof clearTimeout?clearTimeout:i}catch(e){n=i}}();var u,s=[],l=!1,p=-1;function f(){l&&u&&(l=!1,u.length?s=u.concat(s):p=-1,s.length&&d())}function d(){if(!l){var e=a(f);l=!0;for(var t=s.length;t;){for(u=s,s=[];++p<t;)u&&u[p].run();p=-1,t=s.length}u=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===i||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function b(e,t){this.fun=e,this.array=t}function m(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];s.push(new b(e,t)),1!==s.length||l||a(d)},b.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=m,o.addListener=m,o.once=m,o.off=m,o.removeListener=m,o.removeAllListeners=m,o.emit=m,o.prependListener=m,o.prependOnceListener=m,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},,,,function(e,t,r){"use strict";r.d(t,"b",(function(){return w})),r.d(t,"a",(function(){return j}));var n=r(5),o=r.n(n),c=r(6),i=r.n(c),a=(r(9),r(0)),u=r(11),s=r(56),l=r(39),p=r(12),f=r.n(p),d=r(3),b=r.n(d),m=r(164),h=(r(122),function(e){var t=e.status;switch(void 0===t?"default":t){case"error":return"woocommerce-error";case"success":return"woocommerce-message";case"info":case"warning":return"woocommerce-info"}return""}),g=function(e){var t=e.className,r=e.notices,n=e.removeNotice,o=r.filter((function(e){return"snackbar"!==e.type}));if(!o.length)return null;var c=b()(t,"wc-block-components-notices");return React.createElement("div",{className:c},o.map((function(e){return React.createElement(m.a,f()({key:"store-notice-"+e.id},e,{className:b()("wc-block-components-notices__notice",h(e)),onRemove:function(){e.isDismissible&&n(e.id)}}),e.content)})))};function O(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function v(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?O(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):O(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var y=Object(a.createContext)({notices:[],createNotice:function(e,t,r){},removeNotice:function(e,t){},setIsSuppressed:function(e){},context:"wc/core"}),w=function(){return Object(a.useContext)(y)},j=function(e){var t=e.children,r=e.className,n=void 0===r?"":r,o=e.createNoticeContainer,c=void 0===o||o,p=e.context,f=void 0===p?"wc/core":p,d=Object(u.useDispatch)("core/notices"),b=d.createNotice,m=d.removeNotice,h=Object(a.useState)(!1),O=i()(h,2),w=O[0],j=O[1],E=Object(s.a)().dispatchStoreEvent,_=Object(l.a)().isEditor,x=Object(a.useCallback)((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};b(e,t,v(v({},r),{},{context:r.context||f})),E("store-notice-create",{status:e,content:t,options:r})}),[b,E,f]),R=Object(a.useCallback)((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:f;m(e,t)}),[m,f]),k={notices:Object(u.useSelect)((function(e){return{notices:e("core/notices").getNotices(f)}}),[f]).notices,createNotice:x,removeNotice:R,context:f,setIsSuppressed:j},P=w?null:React.createElement(g,{className:n,notices:k.notices,removeNotice:k.removeNotice,isEditor:_});return React.createElement(y.Provider,{value:k},c&&P,t)}},,,function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(4);function o(e,t){var r=Object(n.useRef)();return Object(n.useEffect)((function(){r.current===e||t&&!t(e,r.current)||(r.current=e)}),[e,t]),r.current}},function(e,t){e.exports=window.wp.wordcount},,,function(e,t,r){"use strict";r.d(t,"a",(function(){return d}));var n=r(12),o=r.n(n),c=r(5),i=r.n(c),a=r(0),u=r(54);function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){i()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var p=[".wp-block-woocommerce-cart"],f=function(e){var t=e.Block,r=e.containers,n=e.getProps,c=void 0===n?function(){return{}}:n,i=e.getErrorBoundaryProps,s=void 0===i?function(){return{}}:i;0!==r.length&&Array.prototype.forEach.call(r,(function(e,r){var n=c(e,r),i=s(e,r),p=l(l({},e.dataset),n.attributes||{});e.classList.remove("is-loading"),Object(a.render)(React.createElement(u.a,i,React.createElement(a.Suspense,{fallback:React.createElement("div",{className:"wc-block-placeholder"})},React.createElement(t,o()({},n,{attributes:p})))),e)}))},d=function(e){var t,r,n,o,c,i,a,u=document.body.querySelectorAll(p.join(","));t=l(l({},e),{},{wrappers:u}),r=t.Block,n=t.getProps,o=t.getErrorBoundaryProps,c=t.selector,i=t.wrappers,a=document.body.querySelectorAll(c),i.length>0&&Array.prototype.filter.call(a,(function(e){return!function(e,t){return Array.prototype.some.call(t,(function(t){return t.contains(e)&&!t.isSameNode(e)}))}(e,i)})),f({Block:r,containers:a,getProps:n,getErrorBoundaryProps:o}),Array.prototype.forEach.call(u,(function(t){t.addEventListener("wc-blocks_render_blocks_frontend",(function(){var r,n,o,c,i,a;n=(r=l(l({},e),{},{wrapper:t})).Block,o=r.getProps,c=r.getErrorBoundaryProps,i=r.selector,a=r.wrapper.querySelectorAll(i),f({Block:n,containers:a,getProps:o,getErrorBoundaryProps:c})}))}))}},,function(e,t){},,function(e,t,r){"use strict";var n=r(12),o=r.n(n),c=r(0),i=(r(150),function(e){if(e){var t=e.getBoundingClientRect().bottom;t>=0&&t<=window.innerHeight||e.scrollIntoView()}});t.a=function(e){return function(t){var r=Object(c.useRef)(null);return React.createElement(React.Fragment,null,React.createElement("div",{className:"with-scroll-to-top__scroll-point",ref:r,"aria-hidden":!0}),React.createElement(e,o()({},t,{scrollToTop:function(e){var t,n;null!==r.current&&(t=r.current,n=(e||{}).focusableSelector,window&&Number.isFinite(window.innerHeight)&&(n?function(e,t){var r,n=(null===(r=e.parentElement)||void 0===r?void 0:r.querySelectorAll(t))||[];if(n.length){var o=n[0];i(o),null==o||o.focus()}else i(e)}(t,n):i(t)))}})))}}},,function(e,t,r){"use strict";var n=r(0),o=r(34),c=Object(n.createElement)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(n.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,r){"use strict";r.d(t,"a",(function(){return u}));var n=r(8),o=r(11),c=r(0),i=r(60),a=r(106),u=function(e){var t=e.namespace,r=e.resourceName,u=e.resourceValues,s=void 0===u?[]:u,l=e.query,p=void 0===l?{}:l,f=e.shouldSelect,d=void 0===f||f;if(!t||!r)throw new Error("The options object must have valid values for the namespace and the resource properties.");var b=Object(c.useRef)({results:[],isLoading:!0}),m=Object(i.a)(p),h=Object(i.a)(s),g=Object(a.a)(),O=Object(o.useSelect)((function(e){if(!d)return null;var o=e(n.COLLECTIONS_STORE_KEY),c=[t,r,m,h],i=o.getCollectionError.apply(o,c);return i&&g(i),{results:o.getCollection.apply(o,c),isLoading:!o.hasFinishedResolution("getCollection",c)}}),[t,r,h,m,d]);return null!==O&&(b.current=O),b.current}},,,,,,,,,,,function(e,t,r){"use strict";var n=r(0),o=r(8),c=r(11),i=r(15);t.a=function(e){return function(t){var r;return r=Object(n.useRef)(i.o.restApiRoutes||{}),Object(c.useSelect)((function(e,t){if(r.current){var n=e(o.SCHEMA_STORE_KEY),c=n.isResolving,i=n.hasFinishedResolution,a=t.dispatch(o.SCHEMA_STORE_KEY),u=a.receiveRoutes,s=a.startResolution,l=a.finishResolution;Object.keys(r.current).forEach((function(e){var t=r.current[e];c("getRoutes",[e])||i("getRoutes",[e])||(s("getRoutes",[e]),u(t,[e]),l("getRoutes",[e]))}))}}),[]),React.createElement(e,t)}}},,,,,,,,,,function(e,t){},,,,,function(e,t,r){"use strict";var n=r(5),o=r.n(n),c=r(17),i=r.n(c),a=r(0),u=["srcElement","size"];function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}t.a=function(e){var t=e.srcElement,r=e.size,n=void 0===r?24:r,c=i()(e,u);return Object(a.isValidElement)(t)?Object(a.cloneElement)(t,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({width:n,height:n},c)):null}},,,,,,,,,function(e,t,r){"use strict";var n=r(0),o=r(7),c=r(3),i=r.n(c),a=r(1),u=r(36),s=r(126),l=r(74);t.a=function(e){var t=e.className,r=e.status,c=void 0===r?"info":r,p=e.children,f=e.spokenMessage,d=void 0===f?p:f,b=e.onRemove,m=void 0===b?o.noop:b,h=e.isDismissible,g=void 0===h||h,O=e.actions,v=void 0===O?[]:O,y=e.politeness,w=void 0===y?function(e){switch(e){case"success":case"warning":case"info":return"polite";case"error":default:return"assertive"}}(c):y,j=e.__unstableHTML;!function(e,t){var r="string"==typeof e?e:Object(n.renderToString)(e);Object(n.useEffect)((function(){r&&Object(u.speak)(r,t)}),[r,t])}(d,w);var E=i()(t,"components-notice","is-"+c,{"is-dismissible":g});return j&&(p=Object(n.createElement)(n.RawHTML,null,p)),Object(n.createElement)("div",{className:E},Object(n.createElement)("div",{className:"components-notice__content"},p,v.map((function(e,t){var r=e.className,o=e.label,c=e.isPrimary,a=e.noDefaultClasses,u=void 0!==a&&a,s=e.onClick,p=e.url;return Object(n.createElement)(l.a,{key:t,href:p,isPrimary:c,isSecondary:!u&&!p,isLink:!u&&!!p,onClick:p?void 0:s,className:i()("components-notice__action",r)},o)}))),g&&Object(n.createElement)(l.a,{className:"components-notice__dismiss",icon:s.a,label:Object(a.__)("Dismiss this notice"),onClick:m,showTooltip:!1}))}},,,,,,,,,,,,,,function(e,t,r){"use strict";r(9);var n=r(3),o=r.n(n),c=r(37),i=r(23);r(204),t.a=Object(i.withInstanceId)((function(e){var t=e.className,r=e.instanceId,n=e.label,i=e.onChange,a=e.options,u=e.screenReaderLabel,s=e.readOnly,l=e.value,p="wc-block-components-sort-select__select-".concat(r);return React.createElement("div",{className:o()("wc-block-sort-select","wc-block-components-sort-select",t)},React.createElement(c.a,{label:n,screenReaderLabel:u,wrapperElement:"label",wrapperProps:{className:"wc-block-sort-select__label wc-block-components-sort-select__label",htmlFor:p}}),React.createElement("select",{id:p,className:"wc-block-sort-select__select wc-block-components-sort-select__select",onChange:i,readOnly:s,value:l},a.map((function(e){return React.createElement("option",{key:e.key,value:e.key},e.label)}))))}))},,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t){},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(43),o=r(0),c=r(15);r.p=c.m,Object(n.registerBlockComponent)({blockName:"woocommerce/product-price",component:Object(o.lazy)((function(){return Promise.all([r.e(25),r.e(6)]).then(r.bind(null,346))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-image",component:Object(o.lazy)((function(){return r.e(5).then(r.bind(null,357))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-title",component:Object(o.lazy)((function(){return r.e(13).then(r.bind(null,356))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-rating",component:Object(o.lazy)((function(){return r.e(7).then(r.bind(null,347))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-button",component:Object(o.lazy)((function(){return r.e(3).then(r.bind(null,348))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-summary",component:Object(o.lazy)((function(){return r.e(11).then(r.bind(null,349))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-sale-badge",component:Object(o.lazy)((function(){return r.e(8).then(r.bind(null,332))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-sku",component:Object(o.lazy)((function(){return r.e(9).then(r.bind(null,350))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-category-list",component:Object(o.lazy)((function(){return r.e(4).then(r.bind(null,351))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-tag-list",component:Object(o.lazy)((function(){return r.e(12).then(r.bind(null,352))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-stock-indicator",component:Object(o.lazy)((function(){return r.e(10).then(r.bind(null,353))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-add-to-cart",component:Object(o.lazy)((function(){return Promise.all([r.e(24),r.e(2)]).then(r.bind(null,354))}))});var i=function(e){return Object(n.getRegisteredBlockComponents)(e)}},,,,,,,,,,,,,function(e,t){e.exports=window.wc.wcBlocksSharedHocs},function(e,t){e.exports=window.wp.blockEditor},,,,,,,,,function(e,t,r){e.exports=r(310)},function(e,t){},function(e,t){},function(e,t){},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t,r){"use strict";r.r(t);var n=r(140),o=r(113),c=r(120),i=r(44),a=r.n(i),u=r(45),s=r.n(u),l=r(46),p=r.n(l),f=r(47),d=r.n(f),b=r(32),m=r.n(b),h=r(4),g=(r(9),r(6)),O=r.n(g),v=r(0),y=r(17),w=r.n(y),j=r(5),E=r.n(j),_=r(1),x=r(7),R=r(3),k=r.n(R),P=r(37),S=(r(265),function(e){var t=e.currentPage,r=e.displayFirstAndLastPages,n=e.displayNextAndPreviousArrows,o=e.pagesToDisplay,c=e.onPageChange,i=e.totalPages,a=function(e,t,r){if(r<=2)return{minIndex:null,maxIndex:null};var n=e-1,o=Math.max(Math.floor(t-n/2),2),c=Math.min(Math.ceil(t+(n-(t-o))),r-1);return{minIndex:Math.max(Math.floor(t-(n-(c-t))),2),maxIndex:c}}(o,t,i),u=a.minIndex,s=a.maxIndex,l=r&&Boolean(1!==u),p=r&&Boolean(s!==i),f=r&&Boolean(u>3),d=r&&Boolean(s<i-2);l&&3===u&&(u-=1),p&&s===i-2&&(s+=1);var b=[];if(u&&s)for(var m=u;m<=s;m++)b.push(m);return React.createElement("div",{className:"wc-block-pagination wc-block-components-pagination"},React.createElement(P.a,{screenReaderLabel:Object(_.__)("Navigate to another page","woo-gutenberg-products-block")}),n&&React.createElement("button",{className:"wc-block-pagination-page wc-block-components-pagination__page wc-block-components-pagination-page--arrow",onClick:function(){return c(t-1)},title:Object(_.__)("Previous page","woo-gutenberg-products-block"),disabled:t<=1},React.createElement(P.a,{label:"←",screenReaderLabel:Object(_.__)("Previous page","woo-gutenberg-products-block")})),l&&React.createElement("button",{className:k()("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:function(){return c(1)},disabled:1===t},React.createElement(P.a,{label:1,screenReaderLabel:Object(_.sprintf)(
|
| 4 |
/* translators: %d is the page number (1, 2, 3...). */
|
| 5 |
Object(_.__)("Page %d","woo-gutenberg-products-block"),1)})),f&&React.createElement("span",{className:"wc-block-pagination-ellipsis wc-block-components-pagination__ellipsis","aria-hidden":"true"},Object(_.__)("…","woo-gutenberg-products-block")),b.map((function(e){return React.createElement("button",{key:e,className:k()("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:function(){return c(e)},disabled:t===e},React.createElement(P.a,{label:e,screenReaderLabel:Object(_.sprintf)(
|
| 6 |
/* translators: %d is the page number (1, 2, 3...). */
|
| 7 |
Object(_.__)("Page %d","woo-gutenberg-products-block"),e)}))})),d&&React.createElement("span",{className:"wc-block-pagination-ellipsis wc-block-components-pagination__ellipsis","aria-hidden":"true"},Object(_.__)("…","woo-gutenberg-products-block")),p&&React.createElement("button",{className:k()("wc-block-pagination-page","wc-block-components-pagination__page",{"wc-block-pagination-page--active":t===i,"wc-block-components-pagination__page--active":t===i}),onClick:function(){return c(i)},disabled:t===i},React.createElement(P.a,{label:i,screenReaderLabel:Object(_.sprintf)(
|
| 8 |
/* translators: %d is the page number (1, 2, 3...). */
|
| 9 |
-
Object(_.__)("Page %d","woo-gutenberg-products-block"),i)})),n&&React.createElement("button",{className:"wc-block-pagination-page wc-block-components-pagination__page wc-block-components-pagination-page--arrow",onClick:function(){return c(t+1)},title:Object(_.__)("Next page","woo-gutenberg-products-block"),disabled:t>=i},React.createElement(P.a,{label:"→",screenReaderLabel:Object(_.__)("Next page","woo-gutenberg-products-block")})))});S.defaultProps={displayFirstAndLastPages:!0,displayNextAndPreviousArrows:!0,pagesToDisplay:3};var C=S,T=r(
|
| 10 |
/* translators: %s is an integer higher than 0 (1, 2, 3...) */
|
| 11 |
Object(_._n)("%d product found","%d products found",e,"woo-gutenberg-products-block"),e)))}(q))}),[null==ne?void 0:ne.totalQuery,q,o,Z]);var ie,ae,ue,se,le,pe=r.contentVisibility,fe=r.columns*r.rows,de=!Number.isFinite(q)&&Number.isFinite(null==ne?void 0:ne.totalProducts)&&Object(x.isEqual)(Z,null==ne?void 0:ne.totalQuery)?Math.ceil(ne.totalProducts/fe):Math.ceil(q/fe),be=Y.length?Y:Array.from({length:fe}),me=0!==Y.length||G,he=l.length>0||b.length>0||Number.isFinite(y)||Number.isFinite(P);return React.createElement("div",{className:(ie=r.columns,ae=r.rows,ue=r.alignButtons,se=r.align,le=void 0!==se?"align"+se:"",k()(X,le,"has-"+ie+"-columns",{"has-multiple-rows":ae>1,"has-aligned-buttons":ue}))},pe.orderBy&&me&&React.createElement(J,{onChange:c,value:i}),!me&&he&&React.createElement(K,{resetCallback:function(){p([]),m([]),j(null),S(null)}}),!me&&!he&&React.createElement(V,null),me&&React.createElement("ul",{className:"".concat(X,"__products")},be.map((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return React.createElement(te,{key:e.id||t,attributes:r,product:e})}))),de>1&&React.createElement(C,{currentPage:n,onPageChange:function(e){a({focusableSelector:"a, button"}),o(e)},totalPages:de}))})),ae=function(e){var t=e.attributes,r=Object(v.useState)(1),n=O()(r,2),o=n[0],c=n[1],i=Object(v.useState)(t.orderby),a=O()(i,2),u=a[0],s=a[1];return Object(v.useEffect)((function(){s(t.orderby)}),[t.orderby]),React.createElement(ie,{attributes:t,currentPage:o,onPageChange:function(e){c(e)},onSortChange:function(e){var t=e.target.value;s(t),c(1)},sortValue:u})},ue=React.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 230 250",style:{width:"100%"}},React.createElement("title",null,"Grid Block Preview"),React.createElement("rect",{width:"65.374",height:"65.374",x:".162",y:".779",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"47.266",height:"5.148",x:"9.216",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),React.createElement("rect",{width:"62.8",height:"15",x:"1.565",y:"101.448",fill:"#E1E3E6",rx:"5"}),React.createElement("rect",{width:"65.374",height:"65.374",x:".162",y:"136.277",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"47.266",height:"5.148",x:"9.216",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),React.createElement("rect",{width:"62.8",height:"15",x:"1.565",y:"236.946",fill:"#E1E3E6",rx:"5"}),React.createElement("rect",{width:"65.374",height:"65.374",x:"82.478",y:".779",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"47.266",height:"5.148",x:"91.532",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),React.createElement("rect",{width:"62.8",height:"15",x:"83.882",y:"101.448",fill:"#E1E3E6",rx:"5"}),React.createElement("rect",{width:"65.374",height:"65.374",x:"82.478",y:"136.277",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"47.266",height:"5.148",x:"91.532",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),React.createElement("rect",{width:"62.8",height:"15",x:"83.882",y:"236.946",fill:"#E1E3E6",rx:"5"}),React.createElement("rect",{width:"65.374",height:"65.374",x:"164.788",y:".779",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"47.266",height:"5.148",x:"173.843",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),React.createElement("rect",{width:"62.8",height:"15",x:"166.192",y:"101.448",fill:"#E1E3E6",rx:"5"}),React.createElement("rect",{width:"65.374",height:"65.374",x:"164.788",y:"136.277",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"47.266",height:"5.148",x:"173.843",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),React.createElement("rect",{width:"62.8",height:"15",x:"166.192",y:"236.946",fill:"#E1E3E6",rx:"5"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"13.283",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"21.498",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"29.713",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"37.927",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"46.238",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"95.599",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"103.814",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"112.029",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"120.243",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"128.554",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"177.909",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"186.124",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"194.339",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"202.553",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"210.864",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"13.283",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"21.498",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"29.713",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"37.927",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"46.238",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"95.599",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"103.814",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"112.029",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"120.243",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"128.554",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"177.909",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"186.124",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"194.339",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"202.553",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"210.864",y:"221.798",fill:"#E1E3E6",rx:"3"}));var se=function(e){p()(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=m()(t);if(r){var o=m()(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return d()(this,e)});function o(){return a()(this,o),n.apply(this,arguments)}return s()(o,[{key:"render",value:function(){var e=this.props,t=e.attributes,r=e.urlParameterSuffix;return t.isPreview?ue:React.createElement(H.InnerBlockLayoutContextProvider,{parentName:"woocommerce/all-products",parentClassName:"wc-block-grid"},React.createElement(ae,{attributes:t,urlParameterSuffix:r}))}}]),o}(h.Component);Object(c.a)({selector:".wp-block-woocommerce-all-products",Block:Object(n.a)((function(e){return React.createElement(o.a,{context:"wc/all-products"},React.createElement(se,e))})),getProps:function(e){return{attributes:JSON.parse(e.dataset.attributes)}}})}]);
|
| 1 |
+
!function(e){function t(t){for(var r,o,c=t[0],i=t[1],a=0,s=[];a<c.length;a++)o=c[a],Object.prototype.hasOwnProperty.call(n,o)&&n[o]&&s.push(n[o][0]),n[o]=0;for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r]);for(u&&u(t);s.length;)s.shift()()}var r={},n={7:0};function o(t){if(r[t])return r[t].exports;var n=r[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,o),n.l=!0,n.exports}o.e=function(e){var t=[],r=n[e];if(0!==r)if(r)t.push(r[2]);else{var c=new Promise((function(t,o){r=n[e]=[t,o]}));t.push(r[2]=c);var i,a=document.createElement("script");a.charset="utf-8",a.timeout=120,o.nc&&a.setAttribute("nonce",o.nc),a.src=function(e){return o.p+""+({0:"vendors--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",8:"atomic-block-components/add-to-cart",9:"atomic-block-components/button",10:"atomic-block-components/category-list",11:"atomic-block-components/image",12:"atomic-block-components/price",13:"atomic-block-components/rating",14:"atomic-block-components/sale-badge",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",50:"vendors--atomic-block-components/add-to-cart"}[e]||e)+"-frontend.js"}(e);var u=new Error;i=function(t){a.onerror=a.onload=null,clearTimeout(s);var r=n[e];if(0!==r){if(r){var o=t&&("load"===t.type?"missing":t.type),c=t&&t.target&&t.target.src;u.message="Loading chunk "+e+" failed.\n("+o+": "+c+")",u.name="ChunkLoadError",u.type=o,u.request=c,r[1](u)}n[e]=void 0}};var s=setTimeout((function(){i({type:"timeout",target:a})}),12e4);a.onerror=a.onload=i,document.head.appendChild(a)}return Promise.all(t)},o.m=e,o.c=r,o.d=function(e,t,r){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)o.d(r,n,function(t){return e[t]}.bind(null,n));return r},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o.oe=function(e){throw console.error(e),e};var c=window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[],i=c.push.bind(c);c.push=t,c=c.slice();for(var a=0;a<c.length;a++)t(c[a]);var u=i;o(o.s=284)}([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){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},function(e,t,r){var n=r(84),o=r(85),c=r(67),i=r(86);e.exports=function(e,t){return n(e)||o(e,t)||c(e,t)||i()},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){var n;!function(){"use strict";var r={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var n=arguments[t];if(n){var c=typeof n;if("string"===c||"number"===c)e.push(n);else if(Array.isArray(n)){if(n.length){var i=o.apply(null,n);i&&e.push(i)}}else if("object"===c)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?(o.default=o,e.exports=o):void 0===(n=function(){return o}.apply(t,[]))||(e.exports=n)}()},function(e,t){e.exports=window.lodash},function(e,t){e.exports=window.wc.wcBlocksData},function(e,t,r){"use strict";function n(e){return(n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}r.d(t,"a",(function(){return n}))},function(e,t,r){e.exports=r(79)()},function(e,t){e.exports=window.wp.data},function(e,t,r){"use strict";function n(){return(n=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}).apply(this,arguments)}r.d(t,"a",(function(){return n}))},function(e,t,r){"use strict";function n(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}r.d(t,"a",(function(){return n}))},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},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}r.d(t,"a",(function(){return n}))},function(e,t,r){"use strict";function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function o(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}r.d(t,"a",(function(){return o}))},function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(88);function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Object(n.a)(e,t)}},function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(20),o=r.n(n),c=r(13);function i(e,t){return!t||"object"!==o()(t)&&"function"!=typeof t?Object(c.a)(e):t}},function(e,t,r){"use strict";function n(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},c=Object.keys(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}r.d(t,"a",(function(){return n}))},function(e,t){function r(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(e.exports=r=function(e){return typeof e},e.exports.default=e.exports,e.exports.__esModule=!0):(e.exports=r=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.default=e.exports,e.exports.__esModule=!0),r(t)}e.exports=r,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){"use strict";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.d(t,"a",(function(){return n}))},function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(65);function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,c=[],_n=!0,i=!1;try{for(r=r.call(e);!(_n=(n=r.next()).done)&&(c.push(n.value),!t||c.length!==t);_n=!0);}catch(e){i=!0,o=e}finally{try{_n||null==r.return||r.return()}finally{if(i)throw o}}return c}}(e,t)||Object(n.a)(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}},function(e,t,r){var n=r(77);e.exports=function(e,t){if(null==e)return{};var r,o,c=n(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)r=i[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(c[r]=e[r])}return c},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=window.wp.compose},function(e,t){e.exports=window.wp.isShallowEqual},,function(e,t){e.exports=window.regeneratorRuntime},function(e,t){e.exports=window.wp.htmlEntities},function(e,t){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){function r(t){return e.exports=r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.default=e.exports,e.exports.__esModule=!0,r(t)}e.exports=r,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(58),o=r(65);function c(e){return function(e){if(Array.isArray(e))return Object(n.a)(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Object(o.a)(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}},function(e,t,r){"use strict";r.d(t,"a",(function(){return j}));var n=r(5),o=r.n(n),c=r(4),i=r.n(c),a=r(7),u=r(0),s=r(8),l=r(11),p=r(28),f=r(92),d=r(93),b=r(36);function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function h(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach((function(t){i()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var g={first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:""},O=h(h({},g),{},{email:""}),v={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:""},y=function(e){return Object(f.a)(Object.entries(e).map((function(e){var t=o()(e,2),r=t[0],n=t[1];return[r,Object(p.decodeEntities)(n)]})))},w={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:v,cartIsLoading:!0,cartErrors:s.EMPTY_CART_ERRORS,billingAddress:O,shippingAddress:g,shippingRates:s.EMPTY_SHIPPING_RATES,shippingRatesLoading:!1,cartHasCalculatedShipping:!1,paymentRequirements:s.EMPTY_PAYMENT_REQUIREMENTS,receiveCart:function(){},extensions:s.EMPTY_EXTENSIONS},j=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{shouldSelect:!0},t=Object(b.a)(),r=t.isEditor,n=t.previewData,o=null==n?void 0:n.previewCart,c=e.shouldSelect,i=Object(u.useRef)(),p=Object(l.useSelect)((function(e,t){var n=t.dispatch;if(!c)return w;if(r)return{cartCoupons:o.coupons,cartItems:o.items,cartFees:o.fees,cartItemsCount:o.items_count,cartItemsWeight:o.items_weight,cartNeedsPayment:o.needs_payment,cartNeedsShipping:o.needs_shipping,cartItemErrors:s.EMPTY_CART_ITEM_ERRORS,cartTotals:o.totals,cartIsLoading:!1,cartErrors:s.EMPTY_CART_ERRORS,billingAddress:O,shippingAddress:g,extensions:s.EMPTY_EXTENSIONS,shippingRates:o.shipping_rates,shippingRatesLoading:!1,cartHasCalculatedShipping:o.has_calculated_shipping,paymentRequirements:o.paymentRequirements,receiveCart:"function"==typeof(null==o?void 0:o.receiveCart)?o.receiveCart:function(){}};var i=e(s.CART_STORE_KEY),a=i.getCartData(),u=i.getCartErrors(),l=i.getCartTotals(),p=!i.hasFinishedResolution("getCartData"),f=i.isCustomerDataUpdating(),b=n(s.CART_STORE_KEY).receiveCart,m=y(a.billingAddress),v=a.needsShipping?y(a.shippingAddress):m,j=a.fees.length>0?a.fees.map((function(e){return y(e)})):s.EMPTY_CART_FEES;return{cartCoupons:a.coupons.length>0?a.coupons.map((function(e){return h(h({},e),{},{label:e.code})})):s.EMPTY_CART_COUPONS,cartItems:a.items,cartFees:j,cartItemsCount:a.itemsCount,cartItemsWeight:a.itemsWeight,cartNeedsPayment:a.needsPayment,cartNeedsShipping:a.needsShipping,cartItemErrors:a.errors,cartTotals:l,cartIsLoading:p,cartErrors:u,billingAddress:Object(d.a)(m),shippingAddress:Object(d.a)(v),extensions:a.extensions,shippingRates:a.shippingRates,shippingRatesLoading:f,cartHasCalculatedShipping:a.hasCalculatedShipping,paymentRequirements:a.paymentRequirements,receiveCart:b}}),[c]);return i.current&&Object(a.isEqual)(i.current,p)||(i.current=p),i.current}},function(e,t){e.exports=window.wp.a11y},function(e,t){e.exports=window.wp.primitives},,function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(0),o=(r(11),Object(n.createContext)({isEditor:!1,currentPostId:0,previewData:{},getPreviewData:function(){}})),c=function(){return Object(n.useContext)(o)}},function(e,t){e.exports=window.wp.dom},function(e,t){e.exports=window.wc.wcBlocksRegistry},,function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}e.exports=function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){var n=r(71);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&n(e,t)},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){var n=r(20).default,o=r(29);e.exports=function(e,t){return!t||"object"!==n(t)&&"function"!=typeof t?o(e):t},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){"use strict";var n=r(40),o=r.n(n),c=r(41),i=r.n(c),a=r(29),u=r.n(a),s=r(42),l=r.n(s),p=r(43),f=r.n(p),d=r(30),b=r.n(d),m=r(4),h=r.n(m),g=(r(10),r(3)),O=r(1),v=r(83),y=function(e){var t=e.imageUrl,r=void 0===t?"".concat(v.l,"/block-error.svg"):t,n=e.header,o=void 0===n?Object(O.__)("Oops!","woo-gutenberg-products-block"):n,c=e.text,i=void 0===c?Object(O.__)("There was an error loading the content.","woo-gutenberg-products-block"):c,a=e.errorMessage,u=e.errorMessagePrefix,s=void 0===u?Object(O.__)("Error:","woo-gutenberg-products-block"):u,l=e.button;return React.createElement("div",{className:"wc-block-error wc-block-components-error"},r&&React.createElement("img",{className:"wc-block-error__image wc-block-components-error__image",src:r,alt:""}),React.createElement("div",{className:"wc-block-error__content wc-block-components-error__content"},o&&React.createElement("p",{className:"wc-block-error__header wc-block-components-error__header"},o),i&&React.createElement("p",{className:"wc-block-error__text wc-block-components-error__text"},i),a&&React.createElement("p",{className:"wc-block-error__message wc-block-components-error__message"},s?s+" ":"",a),l&&React.createElement("p",{className:"wc-block-error__button wc-block-components-error__button"},l)))};r(81);var w=function(e){l()(c,e);var t,r,n=(t=c,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=b()(t);if(r){var o=b()(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return f()(this,e)});function c(){var e;o()(this,c);for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return e=n.call.apply(n,[this].concat(r)),h()(u()(e),"state",{errorMessage:"",hasError:!1}),e}return i()(c,[{key:"render",value:function(){var e=this.props,t=e.header,r=e.imageUrl,n=e.showErrorMessage,o=e.text,c=e.errorMessagePrefix,i=e.renderError,a=e.button,u=this.state,s=u.errorMessage;return u.hasError?"function"==typeof i?i({errorMessage:s}):React.createElement(y,{errorMessage:n?s:null,header:t,imageUrl:r,text:o,errorMessagePrefix:c,button:a}):this.props.children}}],[{key:"getDerivedStateFromError",value:function(e){return void 0!==e.statusText&&void 0!==e.status?{errorMessage:React.createElement(React.Fragment,null,React.createElement("strong",null,e.status),": ",e.statusText),hasError:!0}:{errorMessage:e.message,hasError:!0}}}]),c}(g.Component);w.defaultProps={showErrorMessage:!0},t.a=w},function(e,t){e.exports=window.wp.deprecated},,function(e,t,r){"use strict";(function(e){var n=r(0),o=(r(74),Object(n.createContext)({slots:{},fills:{},registerSlot:function(){void 0!==e&&e.env},updateSlot:function(){},unregisterSlot:function(){},registerFill:function(){},unregisterFill:function(){}}));t.a=o}).call(this,r(102))},,function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r.d(t,"c",(function(){return i})),r.d(t,"b",(function(){return a})),r.d(t,"d",(function(){return u}));var n=r(20),o=r.n(n),c=function(e){return"number"==typeof e},i=function(e){return"string"==typeof e},a=function(e){return!function(e){return null===e}(e)&&"object"===o()(e)};function u(e,t){return a(e)&&t in e}},function(e,t){e.exports=window.wp.keycodes},function(e,t,r){"use strict";var n=r(4),o=r.n(n),c=r(0),i=r(6),a=r.n(i);function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}t.a=function(e){var t,r=e.label,n=e.screenReaderLabel,o=e.wrapperElement,i=e.wrapperProps,u=void 0===i?{}:i,l=null!=r,p=null!=n;return!l&&p?(t=o||"span",u=s(s({},u),{},{className:a()(u.className,"screen-reader-text")}),React.createElement(t,u,n)):(t=o||c.Fragment,l&&p&&r!==n?React.createElement(t,u,React.createElement("span",{"aria-hidden":"true"},r),React.createElement("span",{className:"screen-reader-text"},n)):React.createElement(t,u,r))}},function(e,t,r){"use strict";r.d(t,"a",(function(){return l}));var n=r(4),o=r.n(n),c=r(75),i=r(0),a=r(32);function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var l=function(){var e=Object(a.a)(),t=Object(i.useRef)(e);return Object(i.useEffect)((function(){t.current=e}),[e]),{dispatchStoreEvent:Object(i.useCallback)((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(c.doAction)("experimental__woocommerce_blocks-".concat(e),t)}catch(e){console.error(e)}}),[]),dispatchCheckoutEvent:Object(i.useCallback)((function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(c.doAction)("experimental__woocommerce_blocks-checkout-".concat(e),s(s({},r),{},{storeCart:t.current}))}catch(e){console.error(e)}}),[])}}},function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(0),o=r(25),c=r.n(o);function i(e){var t=Object(n.useRef)(e);return c()(e,t.current)||(t.current=e),t.current}},,,,,function(e,t,r){"use strict";function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}r.d(t,"a",(function(){return n}))},,function(e,t){e.exports=window.wp.apiFetch},,function(e,t){e.exports=window.wc.priceFormat},,function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(0),o=Object(n.createContext)("page"),c=function(){return Object(n.useContext)(o)};o.Provider},function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(58);function o(e,t){if(e){if("string"==typeof e)return Object(n.a)(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Object(n.a)(e,t):void 0}}},,function(e,t,r){var n=r(68);e.exports=function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n},e.exports.default=e.exports,e.exports.__esModule=!0},,,function(e,t){function r(t,n){return e.exports=r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},e.exports.default=e.exports,e.exports.__esModule=!0,r(t,n)}e.exports=r,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=window.wp.url},,function(e,t){e.exports=window.wp.warning},function(e,t){e.exports=window.wp.hooks},function(e,t,r){"use strict";var n=r(12),o=r(19),c=r(0),i=r(6),a=r.n(i),u=r(7),s=r(45),l=r.n(s),p=r(15),f=r(16),d=r(17),b=r(18),m=r(9),h=r(22),g=r(37),O=r(50),v=r(24),y=r(116),w=r(21);function j(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function E(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?j(Object(r),!0).forEach((function(t){Object(w.a)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _(e,t,r,n,o,c,i){var a=t.width,u="rtl"===document.documentElement.dir;"left"===r&&u?r="right":"right"===r&&u&&(r="left"),"left"===n&&u?n="right":"right"===n&&u&&(n="left");var s=Math.round(e.left+e.width/2),l={popoverLeft:s,contentWidth:(s-a/2>0?a/2:s)+(s+a/2>window.innerWidth?window.innerWidth-s:a/2)},p=e.left;"right"===n?p=e.right:"middle"!==c&&(p=s);var f=e.right;"left"===n?f=e.left:"middle"!==c&&(f=s);var d,b={popoverLeft:p,contentWidth:p-a>0?a:p},m={popoverLeft:f,contentWidth:f+a>window.innerWidth?window.innerWidth-f:a},h=r,g=null;if(!o)if("center"===r&&l.contentWidth===a)h="center";else if("left"===r&&b.contentWidth===a)h="left";else if("right"===r&&m.contentWidth===a)h="right";else{var O="left"==(h=b.contentWidth>m.contentWidth?"left":"right")?b.contentWidth:m.contentWidth;g=O!==a?O:null}if(d="center"===h?l.popoverLeft:"left"===h?b.popoverLeft:m.popoverLeft,i){var v=i.getBoundingClientRect();d=Math.min(d,v.right-a)}return{xAxis:h,popoverLeft:d,contentWidth:g}}function x(e,t,r,n,o,c,i){var a=t.height;if(o){var u=(Object(g.getScrollContainer)(c)||document.body).getBoundingClientRect().top+a-i;if(e.top<=u)return{yAxis:r,popoverTop:Math.min(e.bottom,u)}}var s=e.top+e.height/2;"bottom"===n?s=e.bottom:"top"===n&&(s=e.top);var l={popoverTop:s,contentHeight:(s-a/2>0?a/2:s)+(s+a/2>window.innerHeight?window.innerHeight-s:a/2)},p={popoverTop:e.top,contentHeight:e.top-10-a>0?a:e.top-10},f={popoverTop:e.bottom,contentHeight:e.bottom+10+a>window.innerHeight?window.innerHeight-10-e.bottom:a},d=r,b=null;if(!o)if("middle"===r&&l.contentHeight===a)d="middle";else if("top"===r&&p.contentHeight===a)d="top";else if("bottom"===r&&f.contentHeight===a)d="bottom";else{var m="top"==(d=p.contentHeight>f.contentHeight?"top":"bottom")?p.contentHeight:f.contentHeight;b=m!==a?m:null}return{yAxis:d,popoverTop:"middle"===d?l.popoverTop:"top"===d?p.popoverTop:f.popoverTop,contentHeight:b}}var R=r(31),k=r(13);var P=Object(c.createContext)({focusHistory:[]}),S=P.Provider,C=P.Consumer;S.displayName="FocusReturnProvider",C.displayName="FocusReturnConsumer",c.Component;var T=Object(v.createHigherOrderComponent)((function e(t){if((n=t)instanceof c.Component||"function"==typeof n){var r=t;return e({})(r)}var n,o=t.onFocusReturn,i=void 0===o?u.stubTrue:o;return function(e){var t=function(t){Object(d.a)(a,t);var r,n,o=(r=a,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=Object(m.a)(r);if(n){var o=Object(m.a)(this).constructor;e=Reflect.construct(t,arguments,o)}else e=t.apply(this,arguments);return Object(b.a)(this,e)});function a(){var e;return Object(p.a)(this,a),(e=o.apply(this,arguments)).ownFocusedElements=new Set,e.activeElementOnMount=document.activeElement,e.setIsFocusedFalse=function(){return e.isFocused=!1},e.setIsFocusedTrue=function(t){e.ownFocusedElements.add(t.target),e.isFocused=!0},e}return Object(f.a)(a,[{key:"componentWillUnmount",value:function(){var e=this.activeElementOnMount,t=this.isFocused,r=this.ownFocusedElements;if(t&&!1!==i())for(var n,o=[].concat(Object(R.a)(u.without.apply(void 0,[this.props.focus.focusHistory].concat(Object(R.a)(r)))),[e]);n=o.pop();)if(document.body.contains(n))return void n.focus()}},{key:"render",value:function(){return Object(c.createElement)("div",{onFocus:this.setIsFocusedTrue,onBlur:this.setIsFocusedFalse},Object(c.createElement)(e,this.props.childProps))}}]),a}(c.Component);return function(e){return Object(c.createElement)(C,null,(function(r){return Object(c.createElement)(t,{childProps:e,focus:r})}))}}}),"withFocusReturn");var N=Object(v.createHigherOrderComponent)((function(e){return function(t){Object(d.a)(i,t);var r,n,o=(r=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=Object(m.a)(r);if(n){var o=Object(m.a)(this).constructor;e=Reflect.construct(t,arguments,o)}else e=t.apply(this,arguments);return Object(b.a)(this,e)});function i(){var e;return Object(p.a)(this,i),(e=o.apply(this,arguments)).focusContainRef=Object(c.createRef)(),e.handleTabBehaviour=e.handleTabBehaviour.bind(Object(k.a)(e)),e}return Object(f.a)(i,[{key:"handleTabBehaviour",value:function(e){if(e.keyCode===O.TAB){var t=g.focus.tabbable.find(this.focusContainRef.current);if(t.length){var r=t[0],n=t[t.length-1];e.shiftKey&&e.target===r?(e.preventDefault(),n.focus()):(e.shiftKey||e.target!==n)&&t.includes(e.target)||(e.preventDefault(),r.focus())}}}},{key:"render",value:function(){return Object(c.createElement)("div",{onKeyDown:this.handleTabBehaviour,ref:this.focusContainRef,tabIndex:"-1"},Object(c.createElement)(e,this.props))}}]),i}(c.Component)}),"withConstrainedTabbing"),D=r(89);var M=function(e){Object(d.a)(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=Object(m.a)(t);if(r){var o=Object(m.a)(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return Object(b.a)(this,e)});function o(){return Object(p.a)(this,o),n.apply(this,arguments)}return Object(f.a)(o,[{key:"handleFocusOutside",value:function(e){this.props.onFocusOutside(e)}},{key:"render",value:function(){return this.props.children}}]),o}(c.Component),A=Object(D.a)(M);function F(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=Object(m.a)(e);if(t){var o=Object(m.a)(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return Object(b.a)(this,r)}}var I=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.htmlDocument,r=void 0===t?document:t,n=e.className,o=void 0===n?"lockscroll":n,i=0,a=0;function u(e){var t=r.scrollingElement||r.body;e&&(a=t.scrollTop);var n=e?"add":"remove";t.classList[n](o),r.documentElement.classList[n](o),e||(t.scrollTop=a)}function s(){0===i&&u(!0),++i}function l(){1===i&&u(!1),--i}return function(e){Object(d.a)(r,e);var t=F(r);function r(){return Object(p.a)(this,r),t.apply(this,arguments)}return Object(f.a)(r,[{key:"componentDidMount",value:function(){s()}},{key:"componentWillUnmount",value:function(){l()}},{key:"render",value:function(){return null}}]),r}(c.Component)}();function B(e){e.stopPropagation()}var L=Object(c.forwardRef)((function(e,t){var r=e.children,i=Object(o.a)(e,["children"]);return Object(c.createElement)("div",Object(n.a)({},i,{ref:t,onMouseDown:B}),r)})),z=r(47);function H(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function U(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?H(Object(r),!0).forEach((function(t){Object(w.a)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):H(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function W(e){var t=Object(c.useContext)(z.a),r=t.slots[e]||{},n=t.fills[e],o=Object(c.useMemo)((function(){return n||[]}),[n]),i=Object(c.useCallback)((function(r){t.updateSlot(e,r)}),[e,t.updateSlot]),a=Object(c.useCallback)((function(r){t.unregisterSlot(e,r)}),[e,t.unregisterSlot]),u=Object(c.useCallback)((function(r){t.registerFill(e,r)}),[e,t.registerFill]),s=Object(c.useCallback)((function(r){t.unregisterFill(e,r)}),[e,t.unregisterFill]);return U(U({},r),{},{updateSlot:i,unregisterSlot:a,fills:o,registerFill:u,unregisterFill:s})}function Y(e,t,r){return(Y="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=Object(m.a)(e)););return e}(e,t);if(n){var o=Object.getOwnPropertyDescriptor(n,t);return o.get?o.get.call(r):o.value}})(e,t,r||e)}r(25);var q=Object(c.createContext)({registerSlot:function(){},unregisterSlot:function(){},registerFill:function(){},unregisterFill:function(){},getSlot:function(){},getFills:function(){},subscribe:function(){}}),V=(q.Provider,q.Consumer);c.Component;var G=function(e){Object(d.a)(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=Object(m.a)(t);if(r){var o=Object(m.a)(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return Object(b.a)(this,e)});function o(){var e;return Object(p.a)(this,o),(e=n.apply(this,arguments)).isUnmounted=!1,e.bindNode=e.bindNode.bind(Object(k.a)(e)),e}return Object(f.a)(o,[{key:"componentDidMount",value:function(){(0,this.props.registerSlot)(this.props.name,this)}},{key:"componentWillUnmount",value:function(){var e=this.props.unregisterSlot;this.isUnmounted=!0,e(this.props.name,this)}},{key:"componentDidUpdate",value:function(e){var t=this.props,r=t.name,n=t.unregisterSlot,o=t.registerSlot;e.name!==r&&(n(e.name),o(r,this))}},{key:"bindNode",value:function(e){this.node=e}},{key:"forceUpdate",value:function(){this.isUnmounted||Y(Object(m.a)(o.prototype),"forceUpdate",this).call(this)}},{key:"render",value:function(){var e=this.props,t=e.children,r=e.name,n=e.fillProps,o=void 0===n?{}:n,i=e.getFills,a=Object(u.map)(i(r,this),(function(e){var t=e.occurrence,r=Object(u.isFunction)(e.children)?e.children(o):e.children;return c.Children.map(r,(function(e,r){if(!e||Object(u.isString)(e))return e;var n="".concat(t,"---").concat(e.key||r);return Object(c.cloneElement)(e,{key:n})}))})).filter(Object(u.negate)(c.isEmptyElement));return Object(c.createElement)(c.Fragment,null,Object(u.isFunction)(t)?t(a):a)}}]),o}(c.Component),K=function(e){return Object(c.createElement)(V,null,(function(t){var r=t.registerSlot,o=t.unregisterSlot,i=t.getFills;return Object(c.createElement)(G,Object(n.a)({},e,{registerSlot:r,unregisterSlot:o,getFills:i}))}))},Q=0;function J(e){var t=e.name,r=e.children,n=e.registerFill,o=e.unregisterFill,i=function(e){var t=Object(c.useContext)(q),r=t.getSlot,n=t.subscribe,o=Object(c.useState)(r(e)),i=Object(h.a)(o,2),a=i[0],u=i[1];return Object(c.useEffect)((function(){return u(r(e)),n((function(){u(r(e))}))}),[e]),a}(t),a=Object(c.useRef)({name:t,children:r});return a.current.occurrence||(a.current.occurrence=++Q),Object(c.useLayoutEffect)((function(){return n(t,a.current),function(){return o(t,a.current)}}),[]),Object(c.useLayoutEffect)((function(){a.current.children=r,i&&i.forceUpdate()}),[r]),Object(c.useLayoutEffect)((function(){t!==a.current.name&&(o(a.current.name,a.current),a.current.name=t,n(t,a.current))}),[t]),i&&i.node?(Object(u.isFunction)(r)&&(r=r(i.props.fillProps)),Object(c.createPortal)(r,i.node)):null}var X=function(e){return Object(c.createElement)(V,null,(function(t){var r=t.registerFill,o=t.unregisterFill;return Object(c.createElement)(J,Object(n.a)({},e,{registerFill:r,unregisterFill:o}))}))};function $(e){var t=e.name,r=e.fillProps,i=void 0===r?{}:r,a=e.as,u=void 0===a?"div":a,s=Object(o.a)(e,["name","fillProps","as"]),l=Object(c.useContext)(z.a),p=Object(c.useRef)();return Object(c.useLayoutEffect)((function(){return l.registerSlot(t,p,i),function(){l.unregisterSlot(t,p)}}),[l.registerSlot,l.unregisterSlot,t]),Object(c.useLayoutEffect)((function(){l.updateSlot(t,i)})),Object(c.createElement)(u,Object(n.a)({ref:p},s))}function Z(e){var t,r,n=e.name,o=e.children,i=W(n),a=Object(c.useRef)({rerender:(t=Object(c.useState)({}),r=Object(h.a)(t,2)[1],function(){return r({})})});return Object(c.useEffect)((function(){return i.registerFill(a),function(){i.unregisterFill(a)}}),[i.registerFill,i.unregisterFill]),i.ref&&i.ref.current?("function"==typeof o&&(o=o(i.fillProps)),Object(c.createPortal)(o,i.ref.current)):null}function ee(e){var t=e.bubblesVirtually,r=Object(o.a)(e,["bubblesVirtually"]);return t?Object(c.createElement)($,r):Object(c.createElement)(K,r)}function te(e){return Object(c.createElement)(c.Fragment,null,Object(c.createElement)(X,e),Object(c.createElement)(Z,e))}function re(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ne(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?re(Object(r),!0).forEach((function(t){Object(w.a)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):re(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function oe(e){var t=e.type,r=e.origin,n=void 0===r?function(e){return"appear"===e?"top":"left"}(t):r;if("appear"===t){var o,c=n.split(" "),i=Object(h.a)(c,2),u=i[0],s=i[1],l=void 0===s?"center":s;return a()("components-animate__appear",(o={},Object(w.a)(o,"is-from-"+l,"center"!==l),Object(w.a)(o,"is-from-"+u,"middle"!==u),o))}return"slide-in"===t?a()("components-animate__slide-in","is-from-"+n):"loading"===t?a()("components-animate__loading"):void 0}function ce(e){var t=e.type,r=e.options,n=void 0===r?{}:r;return(0,e.children)({className:oe(ne({type:t},n))})}var ie=N(T((function(e){return e.children})));function ae(e,t){var r,n=(r=t).ownerDocument.defaultView.getComputedStyle(r),o=n.paddingTop,c=n.paddingBottom,i=n.paddingLeft,a=n.paddingRight,u=o?parseInt(o,10):0,s=c?parseInt(c,10):0,l=i?parseInt(i,10):0,p=a?parseInt(a,10):0;return{x:e.left+l,y:e.top+u,width:e.width-l-p,height:e.height-u-s,left:e.left+l,right:e.right-p,top:e.top+u,bottom:e.bottom-s}}function ue(e,t,r){r?e.getAttribute(t)!==r&&e.setAttribute(t,r):e.hasAttribute(t)&&e.removeAttribute(t)}function se(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";e.style[t]!==r&&(e.style[t]=r)}function le(e,t,r){r?e.classList.contains(t)||e.classList.add(t):e.classList.contains(t)&&e.classList.remove(t)}var pe=function(e){var t=e.headerTitle,r=e.onClose,i=e.onKeyDown,u=e.children,s=e.className,p=e.noArrow,f=void 0===p||p,d=e.isAlternate,b=e.position,m=void 0===b?"bottom right":b,w=(e.range,e.focusOnMount),j=void 0===w?"firstElement":w,R=e.anchorRef,k=e.shouldAnchorIncludePadding,P=e.anchorRect,S=e.getAnchorRect,C=e.expandOnMobile,T=e.animate,N=void 0===T||T,D=e.onClickOutside,M=e.onFocusOutside,F=e.__unstableSticky,B=e.__unstableSlotName,z=void 0===B?"Popover":B,H=e.__unstableObserveElement,U=e.__unstableBoundaryParent,Y=Object(o.a)(e,["headerTitle","onClose","onKeyDown","children","className","noArrow","isAlternate","position","range","focusOnMount","anchorRef","shouldAnchorIncludePadding","anchorRect","getAnchorRect","expandOnMobile","animate","onClickOutside","onFocusOutside","__unstableSticky","__unstableSlotName","__unstableObserveElement","__unstableBoundaryParent"]),q=Object(c.useRef)(null),V=Object(c.useRef)(null),G=Object(c.useRef)(),K=Object(v.useViewportMatch)("medium","<"),Q=Object(c.useState)(),J=Object(h.a)(Q,2),X=J[0],$=J[1],Z=W(z),ee=C&&K,re=Object(v.useResizeObserver)(),ne=Object(h.a)(re,2),oe=ne[0],pe=ne[1];f=ee||f,Object(c.useLayoutEffect)((function(){if(ee)return le(G.current,"is-without-arrow",f),le(G.current,"is-alternate",d),ue(G.current,"data-x-axis"),ue(G.current,"data-y-axis"),se(G.current,"top"),se(G.current,"left"),se(V.current,"maxHeight"),void se(V.current,"maxWidth");var e=function(){if(G.current&&V.current){var e=function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=arguments.length>4?arguments[4]:void 0;if(t)return t;if(r){if(!e.current)return;return r(e.current)}if(!1!==n){if(!(n&&window.Range&&window.Element&&window.DOMRect))return;if(n instanceof window.Range)return Object(g.getRectangleFromRange)(n);if(n instanceof window.Element){var c=n.getBoundingClientRect();return o?c:ae(c,n)}var i=n.top,a=n.bottom,u=i.getBoundingClientRect(),s=a.getBoundingClientRect(),l=new window.DOMRect(u.left,u.top,u.width,s.bottom-u.top);return o?l:ae(l,n)}if(e.current){var p=e.current.parentNode,f=p.getBoundingClientRect();return o?f:ae(f,p)}}(q,P,S,R,k);if(e){var t,r,n=G.current,o=n.offsetParent,c=n.ownerDocument,i=0;if(o&&o!==c.body){var a=o.getBoundingClientRect();i=a.top,e=new window.DOMRect(e.left-a.left,e.top-a.top,e.width,e.height)}U&&(t=null===(r=G.current.closest(".popover-slot"))||void 0===r?void 0:r.parentNode);var u=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"top",n=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,c=arguments.length>5?arguments[5]:void 0,i=arguments.length>6?arguments[6]:void 0,a=r.split(" "),u=Object(h.a)(a,3),s=u[0],l=u[1],p=void 0===l?"center":l,f=u[2],d=x(e,t,s,f,n,o,c),b=_(e,t,p,f,n,d.yAxis,i);return E(E({},b),d)}(e,pe.height?pe:V.current.getBoundingClientRect(),m,F,G.current,i,t),s=u.popoverTop,l=u.popoverLeft,p=u.xAxis,b=u.yAxis,O=u.contentHeight,v=u.contentWidth;"number"==typeof s&&"number"==typeof l&&(se(G.current,"top",s+"px"),se(G.current,"left",l+"px")),le(G.current,"is-without-arrow",f||"center"===p&&"middle"===b),le(G.current,"is-alternate",d),ue(G.current,"data-x-axis",p),ue(G.current,"data-y-axis",b),se(V.current,"maxHeight","number"==typeof O?O+"px":""),se(V.current,"maxWidth","number"==typeof v?v+"px":""),$(({left:"right",right:"left"}[p]||"center")+" "+({top:"bottom",bottom:"top"}[b]||"middle"))}}};e();var t,r,n=window.setInterval(e,500),o=function(){window.cancelAnimationFrame(t),t=window.requestAnimationFrame(e)};return window.addEventListener("click",o),window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),H&&(r=new window.MutationObserver(e)).observe(H,{attributes:!0}),function(){window.clearInterval(n),window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0),window.removeEventListener("click",o),window.cancelAnimationFrame(t),r&&r.disconnect()}}),[ee,P,S,R,k,m,pe,F,H,U]),function(e,t){Object(c.useEffect)((function(){var r=setTimeout((function(){if(e&&t.current)if("firstElement"!==e)"container"===e&&t.current.focus();else{var r=g.focus.tabbable.find(t.current)[0];r?r.focus():t.current.focus()}}),0);return function(){return clearTimeout(r)}}),[])}(j,V);var fe=function(e){e.keyCode===O.ESCAPE&&r&&(e.stopPropagation(),r()),i&&i(e)},de=Object(c.createElement)(A,{onFocusOutside:function(e){if(M)M(e);else if(D){var t;try{t=new window.MouseEvent("click")}catch(e){(t=document.createEvent("MouseEvent")).initMouseEvent("click",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null)}Object.defineProperty(t,"target",{get:function(){return e.relatedTarget}}),l()("Popover onClickOutside prop",{alternative:"onFocusOutside"}),D(t)}else r&&r()}},Object(c.createElement)(ce,{type:N&&X?"appear":null,options:{origin:X}},(function(e){var o=e.className;return Object(c.createElement)(L,Object(n.a)({className:a()("components-popover",s,o,{"is-expanded":ee,"is-without-arrow":f,"is-alternate":d})},Y,{onKeyDown:fe,ref:G}),ee&&Object(c.createElement)(I,null),ee&&Object(c.createElement)("div",{className:"components-popover__header"},Object(c.createElement)("span",{className:"components-popover__header-title"},t),Object(c.createElement)(Oe,{className:"components-popover__close",icon:y.a,onClick:r})),Object(c.createElement)("div",{ref:V,className:"components-popover__content",tabIndex:"-1"},Object(c.createElement)("div",{style:{position:"relative"}},oe,u)))})));return j&&(de=Object(c.createElement)(ie,null,de)),Z.ref&&(de=Object(c.createElement)(te,{name:z},de)),R||P?de:Object(c.createElement)("span",{ref:q},de)};pe.Slot=function(e){var t=e.name,r=void 0===t?"Popover":t;return Object(c.createElement)(ee,{bubblesVirtually:!0,name:r,className:"popover-slot"})};var fe=pe,de=function(e){var t,r,n=e.shortcut,o=e.className;return n?(Object(u.isString)(n)&&(t=n),Object(u.isObject)(n)&&(t=n.display,r=n.ariaLabel),Object(c.createElement)("span",{className:o,"aria-label":r},t)):null};var be=function(e){Object(d.a)(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=Object(m.a)(t);if(r){var o=Object(m.a)(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return Object(b.a)(this,e)});function o(){var e;return Object(p.a)(this,o),(e=n.apply(this,arguments)).delayedSetIsOver=Object(u.debounce)((function(t){return e.setState({isOver:t})}),700),e.cancelIsMouseDown=e.createSetIsMouseDown(!1),e.isInMouseDown=!1,e.state={isOver:!1},e}return Object(f.a)(o,[{key:"componentWillUnmount",value:function(){this.delayedSetIsOver.cancel(),document.removeEventListener("mouseup",this.cancelIsMouseDown)}},{key:"emitToChild",value:function(e,t){var r=this.props.children;if(1===c.Children.count(r)){var n=c.Children.only(r);"function"==typeof n.props[e]&&n.props[e](t)}}},{key:"createToggleIsOver",value:function(e,t){var r=this;return function(n){if(r.emitToChild(e,n),!(n.currentTarget.disabled||"focus"===n.type&&r.isInMouseDown)){r.delayedSetIsOver.cancel();var o=Object(u.includes)(["focus","mouseenter"],n.type);o!==r.state.isOver&&(t?r.delayedSetIsOver(o):r.setState({isOver:o}))}}}},{key:"createSetIsMouseDown",value:function(e){var t=this;return function(r){t.emitToChild(e?"onMouseDown":"onMouseUp",r),document[e?"addEventListener":"removeEventListener"]("mouseup",t.cancelIsMouseDown),t.isInMouseDown=e}}},{key:"render",value:function(){var e=this.props,t=e.children,r=e.position,n=e.text,o=e.shortcut;if(1!==c.Children.count(t))return t;var i=c.Children.only(t),a=this.state.isOver;return Object(c.cloneElement)(i,{onMouseEnter:this.createToggleIsOver("onMouseEnter",!0),onMouseLeave:this.createToggleIsOver("onMouseLeave"),onClick:this.createToggleIsOver("onClick"),onFocus:this.createToggleIsOver("onFocus"),onBlur:this.createToggleIsOver("onBlur"),onMouseDown:this.createSetIsMouseDown(!0),children:Object(c.concatChildren)(i.props.children,a&&Object(c.createElement)(fe,{focusOnMount:!1,position:r,className:"components-tooltip","aria-hidden":"true",animate:!1,noArrow:!0},n,Object(c.createElement)(de,{className:"components-tooltip__shortcut",shortcut:o})))})}}]),o}(c.Component),me=r(91);function he(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var ge=["onMouseDown","onClick"],Oe=t.a=Object(c.forwardRef)((function(e,t){var r=e.href,i=e.target,s=e.isPrimary,p=e.isSmall,f=e.isTertiary,d=e.isPressed,b=e.isBusy,m=e.isDefault,h=e.isSecondary,g=e.isLink,O=e.isDestructive,v=e.className,y=e.disabled,w=e.icon,j=e.iconSize,E=e.showTooltip,_=e.tooltipPosition,x=e.shortcut,R=e.label,k=e.children,P=e.__experimentalIsFocusable,S=Object(o.a)(e,["href","target","isPrimary","isSmall","isTertiary","isPressed","isBusy","isDefault","isSecondary","isLink","isDestructive","className","disabled","icon","iconSize","showTooltip","tooltipPosition","shortcut","label","children","__experimentalIsFocusable"]);m&&l()("Button isDefault prop",{alternative:"isSecondary"});var C=a()("components-button",v,{"is-secondary":m||h,"is-primary":s,"is-small":p,"is-tertiary":f,"is-pressed":d,"is-busy":b,"is-link":g,"is-destructive":O,"has-text":!!w&&!!k,"has-icon":!!w}),T=y&&!P,N=void 0===r||T?"button":"a",D="a"===N?{href:r,target:i}:{type:"button",disabled:T,"aria-pressed":d};if(y&&P){D["aria-disabled"]=!0;var M,A=function(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return he(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?he(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,i=!0,a=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return i=e.done,e},e:function(e){a=!0,c=e},f:function(){try{i||null==r.return||r.return()}finally{if(a)throw c}}}}(ge);try{for(A.s();!(M=A.n()).done;)S[M.value]=function(e){e.stopPropagation(),e.preventDefault()}}catch(e){A.e(e)}finally{A.f()}}var F=!T&&(E&&R||x||!!R&&(!k||Object(u.isArray)(k)&&!k.length)&&!1!==E),I=Object(c.createElement)(N,Object(n.a)({},D,S,{className:C,"aria-label":S["aria-label"]||R,ref:t}),w&&Object(c.createElement)(me.a,{icon:w,size:j}),k);return F?Object(c.createElement)(be,{text:R,shortcut:x,position:_},I):I}))},function(e,t){e.exports=function(e,t){if(null==e)return{};var r,n,o={},c=Object.keys(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||(o[r]=e[r]);return o},e.exports.default=e.exports,e.exports.__esModule=!0},,function(e,t,r){"use strict";var n=r(80);function o(){}function c(){}c.resetWarningCache=o,e.exports=function(){function e(e,t,r,o,c,i){if(i!==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:c,resetWarningCache:o};return r.PropTypes=r,r}},function(e,t,r){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t){},,function(e,t,r){"use strict";r.d(t,"n",(function(){return c})),r.d(t,"l",(function(){return i})),r.d(t,"k",(function(){return a})),r.d(t,"m",(function(){return u})),r.d(t,"i",(function(){return s})),r.d(t,"d",(function(){return l})),r.d(t,"f",(function(){return p})),r.d(t,"j",(function(){return f})),r.d(t,"c",(function(){return d})),r.d(t,"e",(function(){return b})),r.d(t,"g",(function(){return m})),r.d(t,"a",(function(){return h})),r.d(t,"h",(function(){return g})),r.d(t,"b",(function(){return O}));var n,o=r(2),c=Object(o.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),i=c.pluginUrl+"images/",a=c.pluginUrl+"build/",u=c.buildPhase,s=null===(n=o.STORE_PAGES.shop)||void 0===n?void 0:n.permalink,l=(o.STORE_PAGES.checkout.id,o.STORE_PAGES.checkout.permalink),p=o.STORE_PAGES.privacy.permalink,f=(o.STORE_PAGES.privacy.title,o.STORE_PAGES.terms.permalink),d=(o.STORE_PAGES.terms.title,o.STORE_PAGES.cart.id,o.STORE_PAGES.cart.permalink),b=o.STORE_PAGES.myaccount.permalink?o.STORE_PAGES.myaccount.permalink:Object(o.getSetting)("wpLoginUrl","/wp-login.php"),m=Object(o.getSetting)("shippingCountries",{}),h=Object(o.getSetting)("allowedCountries",{}),g=Object(o.getSetting)("shippingStates",{}),O=Object(o.getSetting)("allowedStates",{})},function(e,t){e.exports=function(e){if(Array.isArray(e))return e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,c=[],_n=!0,i=!1;try{for(r=r.call(e);!(_n=(n=r.next()).done)&&(c.push(n.value),!t||c.length!==t);_n=!0);}catch(e){i=!0,o=e}finally{try{_n||null==r.return||r.return()}finally{if(i)throw o}}return c}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){"use strict";var n=r(4),o=r.n(n),c=r(5),i=r.n(c),a=r(2),u=r(1),s=r(49);function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function p(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var f=Object(a.getSetting)("countryLocale",{}),d=function(e){var 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(u.sprintf)(
|
| 2 |
/* translators: %s Field label. */
|
| 3 |
+
Object(u.__)("%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},b=Object.entries(f).map((function(e){var t=i()(e,2),r=t[0],n=t[1];return[r,Object.entries(n).map((function(e){var t=i()(e,2),r=t[0],n=t[1];return[r,d(n)]})).reduce((function(e,t){var r=i()(t,2),n=r[0],o=r[1];return e[n]=o,e}),{})]})).reduce((function(e,t){var r=i()(t,2),n=r[0],o=r[1];return e[n]=o,e}),{});t.a=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=r&&void 0!==b[r]?b[r]:{};return e.map((function(e){var r=a.defaultAddressFields[e]||{},o=n[e]||{},c=t[e]||{};return p(p(p({key:e},r),o),c)})).sort((function(e,t){return e.index-t.index}))}},function(e,t,r){"use strict";function n(e,t){return(n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}r.d(t,"a",(function(){return n}))},function(e,t,r){"use strict";var n=r(12),o=r(15),c=r(16),i=r(13),a=r(17),u=r(18),s=r(9),l=r(0),p=r(7),f=r(24);var d=["button","submit"];t.a=Object(f.createHigherOrderComponent)((function(e){return function(t){Object(a.a)(m,t);var r,f,b=(r=m,f=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=Object(s.a)(r);if(f){var n=Object(s.a)(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return Object(u.a)(this,e)});function m(){var e;return Object(o.a)(this,m),(e=b.apply(this,arguments)).bindNode=e.bindNode.bind(Object(i.a)(e)),e.cancelBlurCheck=e.cancelBlurCheck.bind(Object(i.a)(e)),e.queueBlurCheck=e.queueBlurCheck.bind(Object(i.a)(e)),e.normalizeButtonFocus=e.normalizeButtonFocus.bind(Object(i.a)(e)),e}return Object(c.a)(m,[{key:"componentWillUnmount",value:function(){this.cancelBlurCheck()}},{key:"bindNode",value:function(e){e?this.node=e:(delete this.node,this.cancelBlurCheck())}},{key:"queueBlurCheck",value:function(e){var t=this;e.persist(),this.preventBlurCheck||(this.blurCheckTimeout=setTimeout((function(){document.hasFocus()?"function"==typeof t.node.handleFocusOutside&&t.node.handleFocusOutside(e):e.preventDefault()}),0))}},{key:"cancelBlurCheck",value:function(){clearTimeout(this.blurCheckTimeout)}},{key:"normalizeButtonFocus",value:function(e){var t=e.type,r=e.target;Object(p.includes)(["mouseup","touchend"],t)?this.preventBlurCheck=!1:function(e){switch(e.nodeName){case"A":case"BUTTON":return!0;case"INPUT":return Object(p.includes)(d,e.type)}return!1}(r)&&(this.preventBlurCheck=!0)}},{key:"render",value:function(){return Object(l.createElement)("div",{onFocus:this.cancelBlurCheck,onMouseDown:this.normalizeButtonFocus,onMouseUp:this.normalizeButtonFocus,onTouchStart:this.normalizeButtonFocus,onTouchEnd:this.normalizeButtonFocus,onBlur:this.queueBlurCheck},Object(l.createElement)(e,Object(n.a)({ref:this.bindNode},this.props)))}}]),m}(l.Component)}),"withFocusOutside")},function(e,t,r){"use strict";r.d(t,"a",(function(){return d})),r.d(t,"b",(function(){return b})),r.d(t,"c",(function(){return m}));var n=r(5),o=r.n(n),c=r(8),i=r(11),a=r(0),u=r(25),s=r.n(u),l=r(53),p=r(99),f=r(64),d=function(e){var t=Object(f.a)();e=e||t;var r=Object(i.useSelect)((function(t){return t(c.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0)}),[e]),n=Object(i.useDispatch)(c.QUERY_STATE_STORE_KEY).setValueForQueryContext;return[r,Object(a.useCallback)((function(t){n(e,t)}),[e,n])]},b=function(e,t,r){var n=Object(f.a)();r=r||n;var o=Object(i.useSelect)((function(n){return n(c.QUERY_STATE_STORE_KEY).getValueForQueryKey(r,e,t)}),[r,e]),u=Object(i.useDispatch)(c.QUERY_STATE_STORE_KEY).setQueryValue;return[o,Object(a.useCallback)((function(t){u(r,e,t)}),[r,e,u])]},m=function(e,t){var r=Object(f.a)(),n=d(t=t||r),c=o()(n,2),i=c[0],u=c[1],b=Object(l.a)(i),m=Object(l.a)(e),h=Object(p.a)(m),g=Object(a.useRef)(!1);return Object(a.useEffect)((function(){s()(h,m)||(u(Object.assign({},b,m)),g.current=!0)}),[b,m,h,u]),g.current?[i,u]:[e,u]}},function(e,t,r){"use strict";var n=r(21),o=r(12),c=r(19),i=r(0),a=r(34),u=function(e){var t=e.icon,r=e.className,n=Object(c.a)(e,["icon","className"]),a=["dashicon","dashicons","dashicons-"+t,r].filter(Boolean).join(" ");return Object(i.createElement)("span",Object(o.a)({className:a},n))};function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){Object(n.a)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}t.a=function(e){var t=e.icon,r=void 0===t?null:t,n=e.size,s=Object(c.a)(e,["icon","size"]);if("string"==typeof r)return Object(i.createElement)(u,Object(o.a)({icon:r},s));if(r&&u===r.type)return Object(i.cloneElement)(r,l({},s));var p=n||24;if("function"==typeof r)return r.prototype instanceof i.Component?Object(i.createElement)(r,l({size:p},s)):r(l({size:p},s));if(r&&("svg"===r.type||r.type===a.SVG)){var f=l(l({width:p,height:p},r.props),s);return Object(i.createElement)(a.SVG,f)}return Object(i.isValidElement)(r)?Object(i.cloneElement)(r,l({size:p},s)):r}},function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(5),o=r.n(n),c=function(e){return e.reduce((function(e,t){var r=o()(t,2),n=r[0],c=r[1];return e[n]=c,e}),{})}},function(e,t,r){"use strict";r.d(t,"b",(function(){return i})),r.d(t,"c",(function(){return a})),r.d(t,"a",(function(){return u}));var n=r(2),o=r(87),c=r(72),i=function(e){var t=e.country,r=void 0===t?"":t,n=e.state,o=void 0===n?"":n,c=e.city,i=void 0===c?"":c,a=e.postcode,u=void 0===a?"":a;return{country:r.trim(),state:o.trim(),city:i.trim(),postcode:u?u.replace(" ","").toUpperCase():""}},a=function(e){var t=e.email,r=void 0===t?"":t;return Object(c.isEmail)(r)?r.trim():""},u=function(e){var t=Object.keys(n.defaultAddressFields),r=Object(o.a)(t,{},e.country),c=Object.assign({},e);return r.forEach((function(t){var r=t.key,n=void 0===r?"":r,o=t.hidden;void 0!==o&&o&&function(e,t){return e in t}(n,e)&&(c[n]="")})),c}},,,,function(e,t){e.exports=window.wp.autop},,function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(3);function o(e,t){var r=Object(n.useRef)();return Object(n.useEffect)((function(){r.current===e||t&&!t(e,r.current)||(r.current=e)}),[e,t]),r.current}},function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(5),o=r.n(n),c=r(0),i=function(){var e=Object(c.useState)(),t=o()(e,2)[1];return Object(c.useCallback)((function(e){t((function(){throw e}))}),[])}},function(e,t){e.exports=window.wc.wcBlocksSharedContext},function(e,t){var r,n,o=e.exports={};function c(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function a(e){if(r===setTimeout)return setTimeout(e,0);if((r===c||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:c}catch(e){r=c}try{n="function"==typeof clearTimeout?clearTimeout:i}catch(e){n=i}}();var u,s=[],l=!1,p=-1;function f(){l&&u&&(l=!1,u.length?s=u.concat(s):p=-1,s.length&&d())}function d(){if(!l){var e=a(f);l=!0;for(var t=s.length;t;){for(u=s,s=[];++p<t;)u&&u[p].run();p=-1,t=s.length}u=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===i||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function b(e,t){this.fun=e,this.array=t}function m(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];s.push(new b(e,t)),1!==s.length||l||a(d)},b.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=m,o.addListener=m,o.once=m,o.off=m,o.removeListener=m,o.removeAllListeners=m,o.emit=m,o.prependListener=m,o.prependOnceListener=m,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,r){"use strict";r.d(t,"b",(function(){return w})),r.d(t,"a",(function(){return j}));var n=r(4),o=r.n(n),c=r(5),i=r.n(c),a=(r(10),r(0)),u=r(11),s=r(52),l=r(36),p=r(14),f=r.n(p),d=r(6),b=r.n(d),m=r(153),h=(r(112),function(e){var t=e.status;switch(void 0===t?"default":t){case"error":return"woocommerce-error";case"success":return"woocommerce-message";case"info":case"warning":return"woocommerce-info"}return""}),g=function(e){var t=e.className,r=e.notices,n=e.removeNotice,o=r.filter((function(e){return"snackbar"!==e.type}));if(!o.length)return null;var c=b()(t,"wc-block-components-notices");return React.createElement("div",{className:c},o.map((function(e){return React.createElement(m.a,f()({key:"store-notice-"+e.id},e,{className:b()("wc-block-components-notices__notice",h(e)),onRemove:function(){e.isDismissible&&n(e.id)}}),e.content)})))};function O(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function v(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?O(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):O(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var y=Object(a.createContext)({notices:[],createNotice:function(e,t,r){},removeNotice:function(e,t){},setIsSuppressed:function(e){},context:"wc/core"}),w=function(){return Object(a.useContext)(y)},j=function(e){var t=e.children,r=e.className,n=void 0===r?"":r,o=e.createNoticeContainer,c=void 0===o||o,p=e.context,f=void 0===p?"wc/core":p,d=Object(u.useDispatch)("core/notices"),b=d.createNotice,m=d.removeNotice,h=Object(a.useState)(!1),O=i()(h,2),w=O[0],j=O[1],E=Object(s.a)().dispatchStoreEvent,_=Object(l.a)().isEditor,x=Object(a.useCallback)((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};b(e,t,v(v({},r),{},{context:r.context||f})),E("store-notice-create",{status:e,content:t,options:r})}),[b,E,f]),R=Object(a.useCallback)((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:f;m(e,t)}),[m,f]),k={notices:Object(u.useSelect)((function(e){return{notices:e("core/notices").getNotices(f)}}),[f]).notices,createNotice:x,removeNotice:R,context:f,setIsSuppressed:j},P=w?null:React.createElement(g,{className:n,notices:k.notices,removeNotice:k.removeNotice,isEditor:_});return React.createElement(y.Provider,{value:k},c&&P,t)}},,,,function(e,t,r){"use strict";r.d(t,"a",(function(){return d}));var n=r(14),o=r.n(n),c=r(4),i=r.n(c),a=r(0),u=r(44);function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){i()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var p=[".wp-block-woocommerce-cart"],f=function(e){var t=e.Block,r=e.containers,n=e.getProps,c=void 0===n?function(){return{}}:n,i=e.getErrorBoundaryProps,s=void 0===i?function(){return{}}:i;0!==r.length&&Array.prototype.forEach.call(r,(function(e,r){var n=c(e,r),i=s(e,r),p=l(l({},e.dataset),n.attributes||{});e.classList.remove("is-loading"),Object(a.render)(React.createElement(u.a,i,React.createElement(a.Suspense,{fallback:React.createElement("div",{className:"wc-block-placeholder"})},React.createElement(t,o()({},n,{attributes:p})))),e)}))},d=function(e){var t,r,n,o,c,i,a,u=document.body.querySelectorAll(p.join(","));t=l(l({},e),{},{wrappers:u}),r=t.Block,n=t.getProps,o=t.getErrorBoundaryProps,c=t.selector,i=t.wrappers,a=document.body.querySelectorAll(c),i.length>0&&Array.prototype.filter.call(a,(function(e){return!function(e,t){return Array.prototype.some.call(t,(function(t){return t.contains(e)&&!t.isSameNode(e)}))}(e,i)})),f({Block:r,containers:a,getProps:n,getErrorBoundaryProps:o}),Array.prototype.forEach.call(u,(function(t){t.addEventListener("wc-blocks_render_blocks_frontend",(function(){var r,n,o,c,i,a;n=(r=l(l({},e),{},{wrapper:t})).Block,o=r.getProps,c=r.getErrorBoundaryProps,i=r.selector,a=r.wrapper.querySelectorAll(i),f({Block:n,containers:a,getProps:o,getErrorBoundaryProps:c})}))}))}},,,,,function(e,t){},function(e,t){e.exports=window.wp.wordcount},function(e,t,r){"use strict";var n=r(14),o=r.n(n),c=r(0),i=(r(142),function(e){if(e){var t=e.getBoundingClientRect().bottom;t>=0&&t<=window.innerHeight||e.scrollIntoView()}});t.a=function(e){return function(t){var r=Object(c.useRef)(null);return React.createElement(React.Fragment,null,React.createElement("div",{className:"with-scroll-to-top__scroll-point",ref:r,"aria-hidden":!0}),React.createElement(e,o()({},t,{scrollToTop:function(e){var t,n;null!==r.current&&(t=r.current,n=(e||{}).focusableSelector,window&&Number.isFinite(window.innerHeight)&&(n?function(e,t){var r,n=(null===(r=e.parentElement)||void 0===r?void 0:r.querySelectorAll(t))||[];if(n.length){var o=n[0];i(o),null==o||o.focus()}else i(e)}(t,n):i(t)))}})))}}},,function(e,t,r){"use strict";var n=r(0),o=r(34),c=Object(n.createElement)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(n.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,r){"use strict";r.d(t,"a",(function(){return u}));var n=r(8),o=r(11),c=r(0),i=r(53),a=r(100),u=function(e){var t=e.namespace,r=e.resourceName,u=e.resourceValues,s=void 0===u?[]:u,l=e.query,p=void 0===l?{}:l,f=e.shouldSelect,d=void 0===f||f;if(!t||!r)throw new Error("The options object must have valid values for the namespace and the resource properties.");var b=Object(c.useRef)({results:[],isLoading:!0}),m=Object(i.a)(p),h=Object(i.a)(s),g=Object(a.a)(),O=Object(o.useSelect)((function(e){if(!d)return null;var o=e(n.COLLECTIONS_STORE_KEY),c=[t,r,m,h],i=o.getCollectionError.apply(o,c);return i&&g(i),{results:o.getCollection.apply(o,c),isLoading:!o.hasFinishedResolution("getCollection",c)}}),[t,r,h,m,d]);return null!==O&&(b.current=O),b.current}},,,,,,,,function(e,t,r){"use strict";var n=r(0),o=r(8),c=r(11),i=r(83);t.a=function(e){return function(t){var r;return r=Object(n.useRef)(i.n.restApiRoutes||{}),Object(c.useSelect)((function(e,t){if(r.current){var n=e(o.SCHEMA_STORE_KEY),c=n.isResolving,i=n.hasFinishedResolution,a=t.dispatch(o.SCHEMA_STORE_KEY),u=a.receiveRoutes,s=a.startResolution,l=a.finishResolution;Object.keys(r.current).forEach((function(e){var t=r.current[e];c("getRoutes",[e])||i("getRoutes",[e])||(s("getRoutes",[e]),u(t,[e]),l("getRoutes",[e]))}))}}),[]),React.createElement(e,t)}}},,,,,,,,,,,,,,function(e,t){},,,,,,,,,,function(e,t,r){"use strict";var n=r(4),o=r.n(n),c=r(23),i=r.n(c),a=r(0),u=["srcElement","size"];function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}t.a=function(e){var t=e.srcElement,r=e.size,n=void 0===r?24:r,c=i()(e,u);return Object(a.isValidElement)(t)?Object(a.cloneElement)(t,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({width:n,height:n},c)):null}},function(e,t,r){"use strict";var n=r(0),o=r(7),c=r(6),i=r.n(c),a=r(1),u=r(33),s=r(116),l=r(76);t.a=function(e){var t=e.className,r=e.status,c=void 0===r?"info":r,p=e.children,f=e.spokenMessage,d=void 0===f?p:f,b=e.onRemove,m=void 0===b?o.noop:b,h=e.isDismissible,g=void 0===h||h,O=e.actions,v=void 0===O?[]:O,y=e.politeness,w=void 0===y?function(e){switch(e){case"success":case"warning":case"info":return"polite";case"error":default:return"assertive"}}(c):y,j=e.__unstableHTML;!function(e,t){var r="string"==typeof e?e:Object(n.renderToString)(e);Object(n.useEffect)((function(){r&&Object(u.speak)(r,t)}),[r,t])}(d,w);var E=i()(t,"components-notice","is-"+c,{"is-dismissible":g});return j&&(p=Object(n.createElement)(n.RawHTML,null,p)),Object(n.createElement)("div",{className:E},Object(n.createElement)("div",{className:"components-notice__content"},p,v.map((function(e,t){var r=e.className,o=e.label,c=e.isPrimary,a=e.noDefaultClasses,u=void 0!==a&&a,s=e.onClick,p=e.url;return Object(n.createElement)(l.a,{key:t,href:p,isPrimary:c,isSecondary:!u&&!p,isLink:!u&&!!p,onClick:p?void 0:s,className:i()("components-notice__action",r)},o)}))),g&&Object(n.createElement)(l.a,{className:"components-notice__dismiss",icon:s.a,label:Object(a.__)("Dismiss this notice"),onClick:m,showTooltip:!1}))}},,,,,,,,,,,,,,,function(e,t,r){"use strict";r(10);var n=r(6),o=r.n(n),c=r(51),i=r(24);r(196),t.a=Object(i.withInstanceId)((function(e){var t=e.className,r=e.instanceId,n=e.label,i=e.onChange,a=e.options,u=e.screenReaderLabel,s=e.readOnly,l=e.value,p="wc-block-components-sort-select__select-".concat(r);return React.createElement("div",{className:o()("wc-block-sort-select","wc-block-components-sort-select",t)},React.createElement(c.a,{label:n,screenReaderLabel:u,wrapperElement:"label",wrapperProps:{className:"wc-block-sort-select__label wc-block-components-sort-select__label",htmlFor:p}}),React.createElement("select",{id:p,className:"wc-block-sort-select__select wc-block-components-sort-select__select",onChange:i,readOnly:s,value:l},a.map((function(e){return React.createElement("option",{key:e.key,value:e.key},e.label)}))))}))},,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t){},,,,function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(38),o=r(0),c=r(83);r.p=c.k,Object(n.registerBlockComponent)({blockName:"woocommerce/product-price",component:Object(o.lazy)((function(){return Promise.all([r.e(1),r.e(12)]).then(r.bind(null,387))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-image",component:Object(o.lazy)((function(){return r.e(11).then(r.bind(null,416))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-title",component:Object(o.lazy)((function(){return r.e(19).then(r.bind(null,409))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-rating",component:Object(o.lazy)((function(){return r.e(13).then(r.bind(null,388))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-button",component:Object(o.lazy)((function(){return r.e(9).then(r.bind(null,389))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-summary",component:Object(o.lazy)((function(){return r.e(17).then(r.bind(null,390))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-sale-badge",component:Object(o.lazy)((function(){return r.e(14).then(r.bind(null,354))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-sku",component:Object(o.lazy)((function(){return r.e(15).then(r.bind(null,391))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-category-list",component:Object(o.lazy)((function(){return r.e(10).then(r.bind(null,392))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-tag-list",component:Object(o.lazy)((function(){return r.e(18).then(r.bind(null,393))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-stock-indicator",component:Object(o.lazy)((function(){return r.e(16).then(r.bind(null,394))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-add-to-cart",component:Object(o.lazy)((function(){return Promise.all([r.e(0),r.e(50),r.e(8)]).then(r.bind(null,403))}))});var i=function(e){return Object(n.getRegisteredBlockComponents)(e)}},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t){e.exports=window.wc.wcBlocksSharedHocs},,,,,,,,,,,,,,,,,,,,,,,,,function(e,t){e.exports=window.wp.blockEditor},function(e,t){e.exports=window.wp.blocks},,,,,,,,,function(e,t,r){e.exports=r(312)},function(e,t){},function(e,t){},function(e,t){},,,,,,,,,,,,,,,,,,,,,,,,,function(e,t,r){"use strict";r.r(t);var n=r(128),o=r(103),c=r(107),i=r(40),a=r.n(i),u=r(41),s=r.n(u),l=r(42),p=r.n(l),f=r(43),d=r.n(f),b=r(30),m=r.n(b),h=r(3),g=(r(10),r(5)),O=r.n(g),v=r(0),y=r(23),w=r.n(y),j=r(4),E=r.n(j),_=r(1),x=r(7),R=r(6),k=r.n(R),P=r(51),S=(r(287),function(e){var t=e.currentPage,r=e.displayFirstAndLastPages,n=e.displayNextAndPreviousArrows,o=e.pagesToDisplay,c=e.onPageChange,i=e.totalPages,a=function(e,t,r){if(r<=2)return{minIndex:null,maxIndex:null};var n=e-1,o=Math.max(Math.floor(t-n/2),2),c=Math.min(Math.ceil(t+(n-(t-o))),r-1);return{minIndex:Math.max(Math.floor(t-(n-(c-t))),2),maxIndex:c}}(o,t,i),u=a.minIndex,s=a.maxIndex,l=r&&Boolean(1!==u),p=r&&Boolean(s!==i),f=r&&Boolean(u>3),d=r&&Boolean(s<i-2);l&&3===u&&(u-=1),p&&s===i-2&&(s+=1);var b=[];if(u&&s)for(var m=u;m<=s;m++)b.push(m);return React.createElement("div",{className:"wc-block-pagination wc-block-components-pagination"},React.createElement(P.a,{screenReaderLabel:Object(_.__)("Navigate to another page","woo-gutenberg-products-block")}),n&&React.createElement("button",{className:"wc-block-pagination-page wc-block-components-pagination__page wc-block-components-pagination-page--arrow",onClick:function(){return c(t-1)},title:Object(_.__)("Previous page","woo-gutenberg-products-block"),disabled:t<=1},React.createElement(P.a,{label:"←",screenReaderLabel:Object(_.__)("Previous page","woo-gutenberg-products-block")})),l&&React.createElement("button",{className:k()("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:function(){return c(1)},disabled:1===t},React.createElement(P.a,{label:1,screenReaderLabel:Object(_.sprintf)(
|
| 4 |
/* translators: %d is the page number (1, 2, 3...). */
|
| 5 |
Object(_.__)("Page %d","woo-gutenberg-products-block"),1)})),f&&React.createElement("span",{className:"wc-block-pagination-ellipsis wc-block-components-pagination__ellipsis","aria-hidden":"true"},Object(_.__)("…","woo-gutenberg-products-block")),b.map((function(e){return React.createElement("button",{key:e,className:k()("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:function(){return c(e)},disabled:t===e},React.createElement(P.a,{label:e,screenReaderLabel:Object(_.sprintf)(
|
| 6 |
/* translators: %d is the page number (1, 2, 3...). */
|
| 7 |
Object(_.__)("Page %d","woo-gutenberg-products-block"),e)}))})),d&&React.createElement("span",{className:"wc-block-pagination-ellipsis wc-block-components-pagination__ellipsis","aria-hidden":"true"},Object(_.__)("…","woo-gutenberg-products-block")),p&&React.createElement("button",{className:k()("wc-block-pagination-page","wc-block-components-pagination__page",{"wc-block-pagination-page--active":t===i,"wc-block-components-pagination__page--active":t===i}),onClick:function(){return c(i)},disabled:t===i},React.createElement(P.a,{label:i,screenReaderLabel:Object(_.sprintf)(
|
| 8 |
/* translators: %d is the page number (1, 2, 3...). */
|
| 9 |
+
Object(_.__)("Page %d","woo-gutenberg-products-block"),i)})),n&&React.createElement("button",{className:"wc-block-pagination-page wc-block-components-pagination__page wc-block-components-pagination-page--arrow",onClick:function(){return c(t+1)},title:Object(_.__)("Next page","woo-gutenberg-products-block"),disabled:t>=i},React.createElement(P.a,{label:"→",screenReaderLabel:Object(_.__)("Next page","woo-gutenberg-products-block")})))});S.defaultProps={displayFirstAndLastPages:!0,displayNextAndPreviousArrows:!0,pagesToDisplay:3};var C=S,T=r(99),N=r(90),D=r(120),M=r(8),A=r(11),F=r(53);function I(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function B(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?I(Object(r),!0).forEach((function(t){E()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):I(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var L=r(52),z=r(114),H=r(101),U=r(33),W=r(152),Y=r(34),q=React.createElement(Y.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},React.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"})),V=function(){var e=Object(H.useInnerBlockLayoutContext)().parentClassName;return React.createElement("div",{className:"".concat(e,"__no-products")},React.createElement(W.a,{className:"".concat(e,"__no-products-image"),alt:"",srcElement:q,size:100}),React.createElement("strong",{className:"".concat(e,"__no-products-title")},Object(_.__)("No products","woo-gutenberg-products-block")),React.createElement("p",{className:"".concat(e,"__no-products-description")},Object(_.__)("There are currently no products available to display.","woo-gutenberg-products-block")))},G=React.createElement(Y.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},React.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),React.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"})),K=function(e){var t=e.resetCallback,r=void 0===t?function(){}:t,n=Object(H.useInnerBlockLayoutContext)().parentClassName;return React.createElement("div",{className:"".concat(n,"__no-products")},React.createElement(W.a,{className:"".concat(n,"__no-products-image"),alt:"",srcElement:G,size:100}),React.createElement("strong",{className:"".concat(n,"__no-products-title")},Object(_.__)("No products found","woo-gutenberg-products-block")),React.createElement("p",{className:"".concat(n,"__no-products-description")},Object(_.__)("We were unable to find any results based on your search.","woo-gutenberg-products-block")),React.createElement("button",{onClick:r},Object(_.__)("Reset Search","woo-gutenberg-products-block")))},Q=r(168),J=(r(286),function(e){var t=e.onChange,r=e.readOnly,n=e.value;return React.createElement(Q.a,{className:"wc-block-product-sort-select wc-block-components-product-sort-select",name:"orderby",onChange:t,options:[{key:"menu_order",label:Object(_.__)("Default sorting","woo-gutenberg-products-block")},{key:"popularity",label:Object(_.__)("Popularity","woo-gutenberg-products-block")},{key:"rating",label:Object(_.__)("Average rating","woo-gutenberg-products-block")},{key:"date",label:Object(_.__)("Latest","woo-gutenberg-products-block")},{key:"price",label:Object(_.__)("Price: low to high","woo-gutenberg-products-block")},{key:"price-desc",label:Object(_.__)("Price: high to low","woo-gutenberg-products-block")}],readOnly:r,screenReaderLabel:Object(_.__)("Order products by","woo-gutenberg-products-block"),value:n})}),X=r(24),$=r(14),Z=r.n($),ee=r(200),te=Object(X.withInstanceId)((function(e){var t=e.product,r=e.attributes,n=e.instanceId,o=r.layoutConfig,c=Object(H.useInnerBlockLayoutContext)(),i=c.parentClassName,a=c.parentName,u=0===Object.keys(t).length,s=k()("".concat(i,"__product"),"wc-block-layout",{"is-loading":u});return React.createElement("li",{className:s,"aria-hidden":u},function e(t,r,n,o){if(n){var c=Object(ee.a)(t);return n.map((function(n,i){var a=O()(n,2),u=a[0],s=a[1],l=void 0===s?{}:s,p=[];l.children&&l.children.length>0&&(p=e(t,r,l.children,o));var f=c[u];if(!f)return null;var d=r.id||0,b=["layout",u,i,o,d];return React.createElement(v.Suspense,{key:b.join("_"),fallback:React.createElement("div",{className:"wc-block-placeholder"})},React.createElement(f,Z()({},l,{children:p,product:r})))}))}}(a,t,o,n))})),re=(r(285),["order","orderby","page","per_page"]);function ne(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function oe(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ne(Object(r),!0).forEach((function(t){E()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ne(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var ce=function(e){var t=e.totalQuery,r=e.totalProducts,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.totalQuery;return!Object(x.isEqual)(t,o)&&Number.isFinite(r)},ie=Object(z.a)((function(e){var t,r=e.attributes,n=e.currentPage,o=e.onPageChange,c=e.onSortChange,i=e.sortValue,a=e.scrollToTop,u=Object(N.b)("attributes",[]),s=O()(u,2),l=s[0],p=s[1],f=Object(N.b)("stock_status",[]),d=O()(f,2),b=d[0],m=d[1],h=Object(N.b)("min_price"),g=O()(h,2),y=g[0],j=g[1],E=Object(N.b)("max_price"),R=O()(E,2),P=R[0],S=R[1],I=Object(N.c)(function(e){var t=e.sortValue,r=e.currentPage,n=e.attributes,o=n.columns,c=n.rows;return oe(oe({},function(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:o*c,page:r})}({attributes:r,sortValue:i,currentPage:n})),z=O()(I,1)[0],W=function(e){var t={namespace:"/wc/store",resourceName:"products"},r=Object(D.a)(B(B({},t),{},{query:e})),n=r.results,o=r.isLoading,c=function(e,t){var r=t.namespace,n=t.resourceName,o=t.resourceValues,c=void 0===o?[]:o,i=t.query,a=void 0===i?{}:i;if(!r||!n)throw new Error("The options object must have valid values for the namespace and the resource name properties.");var u=Object(F.a)(a),s=Object(F.a)(c),l=Object(A.useSelect)((function(e){var t=e(M.COLLECTIONS_STORE_KEY),o=["x-wp-total",r,n,u,s];return{value:t.getCollectionHeader.apply(t,o),isLoading:t.hasFinishedResolution("getCollectionHeader",o)}}),["x-wp-total",r,n,s,u]),p=l.value,f=l.isLoading;return{value:p,isLoading:void 0===f||f}}(0,B(B({},t),{},{query:e})).value;return{products:n,totalProducts:parseInt(c,10),productsLoading:o}}(z),Y=W.products,q=W.totalProducts,G=W.productsLoading,Q=Object(H.useInnerBlockLayoutContext)(),X=Q.parentClassName,$=Q.parentName,Z=((t=z).order,t.orderby,t.page,t.per_page,w()(t,re)||{}),ee=Object(L.a)().dispatchStoreEvent,ne=Object(T.a)({totalQuery:Z,totalProducts:q},ce);Object(v.useEffect)((function(){ee("product-list-render",{products:Y,listName:$})}),[Y,$,ee]),Object(v.useEffect)((function(){Object(x.isEqual)(Z,null==ne?void 0:ne.totalQuery)||(o(1),null!=ne&&ne.totalQuery&&function(e){Number.isFinite(e)&&(0===e?Object(U.speak)(Object(_.__)("No products found","woo-gutenberg-products-block")):Object(U.speak)(Object(_.sprintf)(
|
| 10 |
/* translators: %s is an integer higher than 0 (1, 2, 3...) */
|
| 11 |
Object(_._n)("%d product found","%d products found",e,"woo-gutenberg-products-block"),e)))}(q))}),[null==ne?void 0:ne.totalQuery,q,o,Z]);var ie,ae,ue,se,le,pe=r.contentVisibility,fe=r.columns*r.rows,de=!Number.isFinite(q)&&Number.isFinite(null==ne?void 0:ne.totalProducts)&&Object(x.isEqual)(Z,null==ne?void 0:ne.totalQuery)?Math.ceil(ne.totalProducts/fe):Math.ceil(q/fe),be=Y.length?Y:Array.from({length:fe}),me=0!==Y.length||G,he=l.length>0||b.length>0||Number.isFinite(y)||Number.isFinite(P);return React.createElement("div",{className:(ie=r.columns,ae=r.rows,ue=r.alignButtons,se=r.align,le=void 0!==se?"align"+se:"",k()(X,le,"has-"+ie+"-columns",{"has-multiple-rows":ae>1,"has-aligned-buttons":ue}))},pe.orderBy&&me&&React.createElement(J,{onChange:c,value:i}),!me&&he&&React.createElement(K,{resetCallback:function(){p([]),m([]),j(null),S(null)}}),!me&&!he&&React.createElement(V,null),me&&React.createElement("ul",{className:"".concat(X,"__products")},be.map((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return React.createElement(te,{key:e.id||t,attributes:r,product:e})}))),de>1&&React.createElement(C,{currentPage:n,onPageChange:function(e){a({focusableSelector:"a, button"}),o(e)},totalPages:de}))})),ae=function(e){var t=e.attributes,r=Object(v.useState)(1),n=O()(r,2),o=n[0],c=n[1],i=Object(v.useState)(t.orderby),a=O()(i,2),u=a[0],s=a[1];return Object(v.useEffect)((function(){s(t.orderby)}),[t.orderby]),React.createElement(ie,{attributes:t,currentPage:o,onPageChange:function(e){c(e)},onSortChange:function(e){var t=e.target.value;s(t),c(1)},sortValue:u})},ue=React.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 230 250",style:{width:"100%"}},React.createElement("title",null,"Grid Block Preview"),React.createElement("rect",{width:"65.374",height:"65.374",x:".162",y:".779",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"47.266",height:"5.148",x:"9.216",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),React.createElement("rect",{width:"62.8",height:"15",x:"1.565",y:"101.448",fill:"#E1E3E6",rx:"5"}),React.createElement("rect",{width:"65.374",height:"65.374",x:".162",y:"136.277",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"47.266",height:"5.148",x:"9.216",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),React.createElement("rect",{width:"62.8",height:"15",x:"1.565",y:"236.946",fill:"#E1E3E6",rx:"5"}),React.createElement("rect",{width:"65.374",height:"65.374",x:"82.478",y:".779",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"47.266",height:"5.148",x:"91.532",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),React.createElement("rect",{width:"62.8",height:"15",x:"83.882",y:"101.448",fill:"#E1E3E6",rx:"5"}),React.createElement("rect",{width:"65.374",height:"65.374",x:"82.478",y:"136.277",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"47.266",height:"5.148",x:"91.532",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),React.createElement("rect",{width:"62.8",height:"15",x:"83.882",y:"236.946",fill:"#E1E3E6",rx:"5"}),React.createElement("rect",{width:"65.374",height:"65.374",x:"164.788",y:".779",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"47.266",height:"5.148",x:"173.843",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),React.createElement("rect",{width:"62.8",height:"15",x:"166.192",y:"101.448",fill:"#E1E3E6",rx:"5"}),React.createElement("rect",{width:"65.374",height:"65.374",x:"164.788",y:"136.277",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"47.266",height:"5.148",x:"173.843",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),React.createElement("rect",{width:"62.8",height:"15",x:"166.192",y:"236.946",fill:"#E1E3E6",rx:"5"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"13.283",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"21.498",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"29.713",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"37.927",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"46.238",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"95.599",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"103.814",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"112.029",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"120.243",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"128.554",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"177.909",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"186.124",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"194.339",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"202.553",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"210.864",y:"86.301",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"13.283",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"21.498",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"29.713",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"37.927",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"46.238",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"95.599",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"103.814",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"112.029",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"120.243",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"128.554",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"177.909",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"186.124",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"194.339",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"202.553",y:"221.798",fill:"#E1E3E6",rx:"3"}),React.createElement("rect",{width:"6.177",height:"6.177",x:"210.864",y:"221.798",fill:"#E1E3E6",rx:"3"}));var se=function(e){p()(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=m()(t);if(r){var o=m()(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return d()(this,e)});function o(){return a()(this,o),n.apply(this,arguments)}return s()(o,[{key:"render",value:function(){var e=this.props,t=e.attributes,r=e.urlParameterSuffix;return t.isPreview?ue:React.createElement(H.InnerBlockLayoutContextProvider,{parentName:"woocommerce/all-products",parentClassName:"wc-block-grid"},React.createElement(ae,{attributes:t,urlParameterSuffix:r}))}}]),o}(h.Component);Object(c.a)({selector:".wp-block-woocommerce-all-products",Block:Object(n.a)((function(e){return React.createElement(o.a,{context:"wc/all-products"},React.createElement(se,e))})),getProps:function(e){return{attributes:JSON.parse(e.dataset.attributes)}}})}]);
|
build/all-products.asset.php
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', '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-core-data', 'wp-data', 'wp-data-controls', 'wp-date', 'wp-deprecated', 'wp-dom', 'wp-element', 'wp-escape-html', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-keycodes', 'wp-polyfill', 'wp-primitives', 'wp-url', 'wp-viewport', 'wp-warning', 'wp-wordcount'), 'version' => '
|
| 1 |
+
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', '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-core-data', 'wp-data', 'wp-data-controls', 'wp-date', 'wp-deprecated', 'wp-dom', 'wp-element', 'wp-escape-html', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-keycodes', 'wp-polyfill', 'wp-primitives', 'wp-url', 'wp-viewport', 'wp-warning', 'wp-wordcount'), 'version' => '066e2c5e4885fee718bab60e9348fd12');
|
build/all-products.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
| 1 |
-
this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["all-products"]=function(e){function t(t){for(var n,a,i=t[0],s=t[1],
|
| 2 |
/* translators: %s Field label. */
|
| 3 |
-
Object(s.__)("%s (optional)","woo-gutenberg-products-block"),e.label)),e.priority&&(Object(
|
| 4 |
/* translators: %1$s min price, %2$s max price */
|
| 5 |
-
Object(a.__)("Price between %1$s and %2$s","woo-gutenberg-products-block"),Object(l.formatPrice)(n),Object(l.formatPrice)(r))),Object(o.createElement)("span",{"aria-hidden":!0},Object(o.createElement)(i.a,{className:u()("wc-block-components-product-price__value",c),currency:t,value:n,style:s})," — ",Object(o.createElement)(i.a,{className:u()("wc-block-components-product-price__value",c),currency:t,value:r,style:s})))}),p=function(e){var t=e.currency,r=e.regularPriceClassName,n=e.regularPriceStyle,c=e.regularPrice,s=e.priceClassName,l=e.priceStyle,b=e.price;return Object(o.createElement)(o.Fragment,null,Object(o.createElement)("span",{className:"screen-reader-text"},Object(a.__)("Previous price:","woo-gutenberg-products-block")),Object(o.createElement)(i.a,{currency:t,renderText:function(e){return Object(o.createElement)("del",{className:u()("wc-block-components-product-price__regular",r),style:n},e)},value:c}),Object(o.createElement)("span",{className:"screen-reader-text"},Object(a.__)("Discounted price:","woo-gutenberg-products-block")),Object(o.createElement)(i.a,{currency:t,renderText:function(e){return Object(o.createElement)("ins",{className:u()("wc-block-components-product-price__value","is-discounted",s),style:l},e)},value:b}))};t.a=function(e){var t=e.align,r=e.className,n=e.currency,a=e.format,s=void 0===a?"<price/>":a,l=e.maxPrice,d=void 0===l?null:l,f=e.minPrice,m=void 0===f?null:f,O=e.price,g=void 0===O?null:O,j=e.priceClassName,h=e.priceStyle,v=e.regularPrice,w=e.regularPriceClassName,y=e.regularPriceStyle,E=u()(r,"price","wc-block-components-product-price",c()({},"wc-block-components-product-price--align-".concat(t),t));s.includes("<price/>")||(s="<price/>",console.error("Price formats need to include the `<price/>` tag."));var _=v&&g!==v,k=Object(o.createElement)("span",{className:u()("wc-block-components-product-price__value",j)});return _?k=Object(o.createElement)(p,{currency:n,price:g,priceClassName:j,priceStyle:h,regularPrice:v,regularPriceClassName:w,regularPriceStyle:y}):null!==m&&null!==d?k=Object(o.createElement)(b,{currency:n,maxPrice:d,minPrice:m,priceClassName:j,priceStyle:h}):null!==g&&(k=Object(o.createElement)(i.a,{className:u()("wc-block-components-product-price__value",j),currency:n,value:g,style:h})),Object(o.createElement)("span",{className:E},Object(o.createInterpolateElement)(s,{price:k}))}},128:function(e,t,r){"use strict";r.d(t,"a",(function(){return u})),r.d(t,"b",(function(){return b}));var n,c=r(5),o=r.n(c),a=r(7);function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}!function(e){e.ADD_EVENT_CALLBACK="add_event_callback",e.REMOVE_EVENT_CALLBACK="remove_event_callback"}(n||(n={}));var u={addEventCallback:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10;return{id:Object(a.uniqueId)(),type:n.ADD_EVENT_CALLBACK,eventType:e,callback:t,priority:r}},removeEventCallback:function(e,t){return{id:t,type:n.REMOVE_EVENT_CALLBACK,eventType:e}}},l={},b=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:l,t=arguments.length>1?arguments[1]:void 0,r=t.type,c=t.eventType,a=t.id,i=t.callback,u=t.priority,b=e.hasOwnProperty(c)?new Map(e[c]):new Map;switch(r){case n.ADD_EVENT_CALLBACK:return b.set(a,{priority:u,callback:i}),s(s({},e),{},o()({},c,b));case n.REMOVE_EVENT_CALLBACK:return b.delete(a),s(s({},e),{},o()({},c,b))}}},129:function(e,t,r){"use strict";r.d(t,"b",(function(){return w})),r.d(t,"a",(function(){return y}));var n=r(5),c=r.n(n),o=r(8),a=r.n(o),i=r(0),s=(r(2),r(16)),u=r(66),l=r(60),b=r(9),p=r.n(b),d=r(6),f=r.n(d),m=r(868),O=(r(206),function(e){var t=e.status;switch(void 0===t?"default":t){case"error":return"woocommerce-error";case"success":return"woocommerce-message";case"info":case"warning":return"woocommerce-info"}return""}),g=function(e){var t=e.className,r=e.notices,n=e.removeNotice,c=r.filter((function(e){return"snackbar"!==e.type}));if(!c.length)return null;var o=f()(t,"wc-block-components-notices");return Object(i.createElement)("div",{className:o},c.map((function(e){return Object(i.createElement)(m.a,p()({key:"store-notice-"+e.id},e,{className:f()("wc-block-components-notices__notice",O(e)),onRemove:function(){e.isDismissible&&n(e.id)}}),e.content)})))};function j(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function h(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?j(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var v=Object(i.createContext)({notices:[],createNotice:function(e,t,r){},removeNotice:function(e,t){},setIsSuppressed:function(e){},context:"wc/core"}),w=function(){return Object(i.useContext)(v)},y=function(e){var t=e.children,r=e.className,n=void 0===r?"":r,c=e.createNoticeContainer,o=void 0===c||c,b=e.context,p=void 0===b?"wc/core":b,d=Object(s.useDispatch)("core/notices"),f=d.createNotice,m=d.removeNotice,O=Object(i.useState)(!1),j=a()(O,2),w=j[0],y=j[1],E=Object(u.a)().dispatchStoreEvent,_=Object(l.b)().isEditor,k=Object(i.useCallback)((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};f(e,t,h(h({},r),{},{context:r.context||p})),E("store-notice-create",{status:e,content:t,options:r})}),[f,E,p]),P=Object(i.useCallback)((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:p;m(e,t)}),[m,p]),C={notices:Object(s.useSelect)((function(e){return{notices:e("core/notices").getNotices(p)}}),[p]).notices,createNotice:k,removeNotice:P,context:p,setIsSuppressed:y},S=w?null:Object(i.createElement)(g,{className:n,notices:C.notices,removeNotice:C.removeNotice,isEditor:_});return Object(i.createElement)(v.Provider,{value:C},o&&S,t)}},130:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(8),c=r.n(n),o=r(0),a=function(){var e=Object(o.useState)(),t=c()(e,2)[1];return Object(o.useCallback)((function(e){t((function(){throw e}))}),[])}},134:function(e,t,r){"use strict";var n=r(9),c=r.n(n),o=r(14),a=r.n(o),i=r(0),s=r(47),u=r(4),l=r(6),b=r.n(l),p=["className","item","isSelected","isLoading","onSelect","disabled"];t.a=function(e){var t=e.className,r=e.item,n=e.isSelected,o=e.isLoading,l=e.onSelect,d=e.disabled,f=a()(e,p);return Object(i.createElement)(i.Fragment,null,Object(i.createElement)(s.c,c()({},f,{key:r.id,className:t,isSelected:n,item:r,onSelect:l,isSingle:!0,disabled:d})),n&&o&&Object(i.createElement)("div",{key:"loading",className:b()("woocommerce-search-list__item","woocommerce-product-attributes__item","depth-1","is-loading","is-not-active")},Object(i.createElement)(u.Spinner,null)))}},135:function(e,t,r){"use strict";r.d(t,"b",(function(){return h})),r.d(t,"a",(function(){return v}));var n=r(37),c=r.n(n),o=r(5),a=r.n(o),i=r(14),s=r.n(i),u=r(8),l=r.n(u),b=r(0),p=r(7),d=r(33),f=r.n(d);function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function O(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach((function(t){a()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function g(e){var t=function(e,t){if("object"!==c()(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!==c()(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===c()(t)?t:String(t)}var j=Object(b.createContext)({getValidationError:function(){return""},setValidationErrors:function(e){},clearValidationError:function(e){},clearAllValidationErrors:function(){},hideValidationError:function(){},showValidationError:function(){},showAllValidationErrors:function(){},hasValidationErrors:!1,getValidationErrorId:function(e){return e}}),h=function(){return Object(b.useContext)(j)},v=function(e){var t=e.children,r=Object(b.useState)({}),n=l()(r,2),c=n[0],o=n[1],i=Object(b.useCallback)((function(e){return c[e]}),[c]),u=Object(b.useCallback)((function(e){var t=c[e];return!t||t.hidden?"":"validate-error-".concat(e)}),[c]),d=Object(b.useCallback)((function(e){o((function(t){return t[e]?(t[e],s()(t,[e].map(g))):t}))}),[]),m=Object(b.useCallback)((function(){o({})}),[]),h=Object(b.useCallback)((function(e){e&&o((function(t){return e=Object(p.pickBy)(e,(function(e,r){return!("string"!=typeof e.message||t.hasOwnProperty(r)&&f()(t[r],e))})),0===Object.values(e).length?t:O(O({},t),e)}))}),[]),v=Object(b.useCallback)((function(e,t){o((function(r){if(!r.hasOwnProperty(e))return r;var n=O(O({},r[e]),t);return f()(r[e],n)?r:O(O({},r),{},a()({},e,n))}))}),[]),w={getValidationError:i,setValidationErrors:h,clearValidationError:d,clearAllValidationErrors:m,hideValidationError:Object(b.useCallback)((function(e){v(e,{hidden:!0})}),[v]),showValidationError:Object(b.useCallback)((function(e){v(e,{hidden:!1})}),[v]),showAllValidationErrors:Object(b.useCallback)((function(){o((function(e){var t={};return Object.keys(e).forEach((function(r){e[r].hidden&&(t[r]=O(O({},e[r]),{},{hidden:!1}))})),0===Object.values(t).length?e:O(O({},e),t)}))}),[]),hasValidationErrors:Object.keys(c).length>0,getValidationErrorId:u};return Object(b.createElement)(j.Provider,{value:w},t)}},136:function(e,t,r){"use strict";var n=r(17),c=r.n(n),o=r(18),a=r.n(o),i=r(19),s=r.n(i),u=r(20),l=r.n(u),b=r(10),p=r.n(b),d=r(0),f=r(7),m=r(1),O=r(4);function g(e){var t=e.level,r={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 r.hasOwnProperty(t)?Object(d.createElement)(O.SVG,{width:"20",height:"20",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg"},Object(d.createElement)(O.Path,{d:r[t]})):null}var j=function(e){s()(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=p()(t);if(r){var c=p()(this).constructor;e=Reflect.construct(n,arguments,c)}else e=n.apply(this,arguments);return l()(this,e)});function o(){return c()(this,o),n.apply(this,arguments)}return a()(o,[{key:"createLevelControl",value:function(e,t,r){var n=e===t;return{icon:Object(d.createElement)(g,{level:e}),
|
| 6 |
/* translators: %s: heading level e.g: "2", "3", "4" */
|
| 7 |
-
title:Object(m.sprintf)(Object(m.__)("Heading %d"),e),isActive:n,onClick:function(){return r(e)}}}},{key:"render",value:function(){var e=this,t=this.props,r=t.isCollapsed,n=void 0===r||r,c=t.minLevel,o=t.maxLevel,a=t.selectedLevel,i=t.onChange;return Object(d.createElement)(O.ToolbarGroup,{isCollapsed:n,icon:Object(d.createElement)(g,{level:a}),controls:Object(f.range)(c,o).map((function(t){return e.createLevelControl(t,a,i)}))})}}]),o}(d.Component);t.a=j},142:function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(8),c=r.n(n),o=function(e){return e.reduce((function(e,t){var r=c()(t,2),n=r[0],o=r[1];return e[n]=o,e}),{})}},143:function(e,t,r){"use strict";var n=r(0),c=r(1),o=r(63),a=r(163),i=r(3),s=r(21),u=r(43);t.a=function(e){var t=(Object(u.useProductDataContext)().product||{}).id||e.productId||0;return t?Object(n.createElement)(s.InspectorControls,null,Object(n.createElement)("div",{className:"wc-block-single-product__edit-card"},Object(n.createElement)("div",{className:"wc-block-single-product__edit-card-title"},Object(n.createElement)("a",{href:"".concat(i.ADMIN_URL,"post.php?post=").concat(t,"&action=edit"),target:"_blank",rel:"noopener noreferrer"},Object(c.__)("Edit this product's details","woo-gutenberg-products-block"),Object(n.createElement)(o.a,{srcElement:a.a,size:16}))),Object(n.createElement)("div",{className:"wc-block-single-product__edit-card-description"},Object(c.__)("Edit details such as title, price, description and more.","woo-gutenberg-products-block")))):null}},15:function(e,t){e.exports=window.wp.apiFetch},150:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(12);function c(e,t){var r=Object(n.useRef)();return Object(n.useEffect)((function(){r.current===e||t&&!t(e,r.current)||(r.current=e)}),[e,t]),r.current}},153:function(e,t,r){"use strict";var n=r(35),c=r.n(n),o=r(5),a=r.n(o),i=r(9),s=r.n(i),u=r(0),l=r(1),b=r(7),p=(r(2),r(47)),d=r(22),f=r(17),m=r.n(f),O=r(18),g=r.n(O),j=r(19),h=r.n(j),v=r(20),w=r.n(v),y=r(10),E=r.n(y);var _=Object(d.createHigherOrderComponent)((function(e){var t=function(t){h()(o,t);var r,n,c=(r=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=E()(r);if(n){var c=E()(this).constructor;e=Reflect.construct(t,arguments,c)}else e=t.apply(this,arguments);return w()(this,e)});function o(){return m()(this,o),c.apply(this,arguments)}return g()(o,[{key:"render",value:function(){var t=this.props.selected,r=null==t;return Object(u.createElement)(e,s()({},this.props,{selected:r?[]:[t]}))}}]),o}(u.Component);return t.defaultProps={selected:null},t}),"withTransformSingleSelectToMultipleSelect"),k=r(304),P=r(31),C=r.n(P),S=r(13),x=r.n(S),N=r(23),D=r.n(N),B=r(33),R=r.n(B),T=r(39),A=r(42);function I(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function L(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?I(Object(r),!0).forEach((function(t){a()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):I(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var z=Object(d.createHigherOrderComponent)((function(e){var t=function(t){h()(o,t);var r,n,c=(r=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=E()(r);if(n){var c=E()(this).constructor;e=Reflect.construct(t,arguments,c)}else e=t.apply(this,arguments);return w()(this,e)});function o(){var e;m()(this,o);for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return e=c.call.apply(c,[this].concat(r)),a()(x()(e),"state",{error:null,loading:!1,variations:{}}),a()(x()(e),"loadVariations",(function(){var t=e.props.products,r=e.state,n=r.loading,c=r.variations;if(!n){var o=e.getExpandedProduct();if(o&&!c[o]){var i=t.find((function(e){return e.id===o}));i.variations&&0!==i.variations.length?(e.setState({loading:!0}),Object(T.g)(o).then((function(t){var r=t.map((function(e){return L(L({},e),{},{parent:o})}));e.setState({variations:L(L({},e.state.variations),{},a()({},o,r)),loading:!1,error:null})})).catch(function(){var t=C()(D.a.mark((function t(r){var n;return D.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Object(A.a)(r);case 2:n=t.sent,e.setState({variations:L(L({},e.state.variations),{},a()({},o,null)),loading:!1,error:n});case 4:case"end":return t.stop()}}),t)})));return function(_x){return t.apply(this,arguments)}}())):e.setState({variations:L(L({},e.state.variations),{},a()({},o,null)),loading:!1,error:null})}}})),e}return g()(o,[{key:"componentDidMount",value:function(){var e=this.props,t=e.selected,r=e.showVariations;t&&r&&this.loadVariations()}},{key:"componentDidUpdate",value:function(e){var t=this.props,r=t.isLoading,n=t.selected;t.showVariations&&(!R()(e.selected,n)||e.isLoading&&!r)&&this.loadVariations()}},{key:"isProductId",value:function(e){return this.props.products.some((function(t){return t.id===e}))}},{key:"findParentProduct",value:function(e){return this.props.products.filter((function(t){return t.variations&&t.variations.find((function(t){return t.id===e}))}))[0].id}},{key:"getExpandedProduct",value:function(){var e=this.props,t=e.isLoading,r=e.selected;if(!e.showVariations)return null;var n=r&&r.length?r[0]:null;return n?this.prevSelectedItem=n:this.prevSelectedItem&&(t||this.isProductId(this.prevSelectedItem)||(n=this.prevSelectedItem)),!t&&n?this.isProductId(n)?n:this.findParentProduct(n):null}},{key:"render",value:function(){var t=this.props,r=t.error,n=t.isLoading,c=this.state,o=c.error,a=c.loading,i=c.variations;return Object(u.createElement)(e,s()({},this.props,{error:o||r,expandedProduct:this.getExpandedProduct(),isLoading:n,variations:i,variationsLoading:a}))}}]),o}(u.Component);return a()(t,"defaultProps",{selected:[],showVariations:!1}),t}),"withProductVariations"),V=r(52),F=r(6),M=r.n(F),H=r(134);function q(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function G(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?q(Object(r),!0).forEach((function(t){a()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):q(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}r(213);var Q={list:Object(l.__)("Products","woo-gutenberg-products-block"),noItems:Object(l.__)("Your store doesn't have any products.","woo-gutenberg-products-block"),search:Object(l.__)("Search for a product to display","woo-gutenberg-products-block"),updated:Object(l.__)("Product search results updated.","woo-gutenberg-products-block")},Y=function(e){var t=e.expandedProduct,r=e.error,n=e.instanceId,o=e.isCompact,a=e.isLoading,i=e.onChange,d=e.onSearch,f=e.products,m=e.renderItem,O=e.selected,g=e.showVariations,j=e.variations,h=e.variationsLoading;if(r)return Object(u.createElement)(V.a,{error:r});var v=j&&j[t]?j[t]:[],w=[].concat(c()(f),c()(v));return Object(u.createElement)(p.b,{className:"woocommerce-products",list:w,isCompact:o,isLoading:a,isSingle:!0,selected:w.filter((function(e){var t=e.id;return O.includes(t)})),onChange:i,renderItem:m||(g?function(e){var t=e.item,r=e.search,c=e.depth,o=void 0===c?0:c,i=e.isSelected,d=e.onSelect,f=t.variations&&Array.isArray(t.variations)?t.variations.length:0,m=M()("woocommerce-search-product__item","woocommerce-search-list__item","depth-".concat(o),"has-count",{"is-searching":r.length>0,"is-skip-level":0===o&&0!==t.parent,"is-variable":f>0});if(!t.breadcrumbs.length)return Object(u.createElement)(H.a,s()({},e,{className:M()(m,{"is-selected":i}),isSelected:i,item:t,onSelect:function(){return function(){d(t)()}},isLoading:a||h,countLabel:t.variations.length>0?Object(l.sprintf)(
|
| 8 |
/* translators: %1$d is the number of variations of a product product. */
|
| 9 |
-
Object(
|
| 10 |
/* translators: %1$s is the product name, %2$d is the number of variations of that product. */
|
| 11 |
-
Object(l._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)}));var O=Object(b.isEmpty)(t.variation)?e:G(G({},e),{},{item:G(G({},e.item),{},{name:t.variation}),"aria-label":"".concat(t.breadcrumbs[0],": ").concat(t.variation)});return Object(u.createElement)(p.c,s()({},O,{className:m,name:"variations-".concat(n)}))}:null),onSearch:d,messages:Q,isHierarchical:!0})};Y.defaultProps={isCompact:!1,expandedProduct:null,selected:[],showVariations:!1},t.a=_(Object(k.a)(z(Object(d.withInstanceId)(Y))))},154:function(e,t,r){"use strict";var n=r(0),c=r(30),o=Object(n.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(n.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=o},159:function(e,t,r){"use strict";var n=r(9),c=r.n(n),o=r(14),a=r.n(o),i=r(0),s=r(26),u=r(6),l=r.n(u),b=(r(204),["className","disabled","name","permalink"]);t.a=function(e){var t=e.className,r=void 0===t?"":t,n=e.disabled,o=void 0!==n&&n,u=e.name,p=e.permalink,d=void 0===p?"":p,f=a()(e,b),m=l()("wc-block-components-product-name",r);return o?Object(i.createElement)("span",c()({className:m},f,{dangerouslySetInnerHTML:{__html:Object(s.decodeEntities)(u)}})):Object(i.createElement)("a",c()({className:m,href:d},f,{dangerouslySetInnerHTML:{__html:Object(s.decodeEntities)(u)}}))}},16:function(e,t){e.exports=window.wp.data},160:function(e,t,r){"use strict";var n=r(0),c=r(118),o=r(89),a=function(e){var t=e.indexOf("</p>");return-1===t?e:e.substr(0,t+4)},i=function(e){return e.replace(/<\/?[a-z][^>]*?>/gi,"")},s=function(e,t){return e.replace(/[\s|\.\,]+$/i,"")+t},u=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"…",n=i(e),c=n.split(" ").splice(0,t).join(" ");return Object(o.autop)(s(c,r))},l=function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"…",c=i(e),a=c.slice(0,t);if(r)return Object(o.autop)(s(a,n));var u=a.match(/([\s]+)/g),l=u?u.length:0,b=c.slice(0,t+l);return Object(o.autop)(s(b,n))};t.a=function(e){var t=e.source,r=e.maxLength,i=void 0===r?15:r,s=e.countType,b=void 0===s?"words":s,p=e.className,d=void 0===p?"":p,f=Object(n.useMemo)((function(){return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:15,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"words",n=Object(o.autop)(e),i=Object(c.count)(n,r);if(i<=t)return n;var s=a(n),b=Object(c.count)(s,r);return b<=t?s:"words"===r?u(s,t):l(s,t,"characters_including_spaces"===r)}(t,i,b)}),[t,i,b]);return Object(n.createElement)(n.RawHTML,{className:d},f)}},161:function(e,t,r){"use strict";var n=r(0),c=(r(2),r(6)),o=r.n(c),a=r(40),i=r(22);r(215),t.a=Object(i.withInstanceId)((function(e){var t=e.className,r=e.instanceId,c=e.label,i=e.onChange,s=e.options,u=e.screenReaderLabel,l=e.readOnly,b=e.value,p="wc-block-components-sort-select__select-".concat(r);return Object(n.createElement)("div",{className:o()("wc-block-sort-select","wc-block-components-sort-select",t)},Object(n.createElement)(a.a,{label:c,screenReaderLabel:u,wrapperElement:"label",wrapperProps:{className:"wc-block-sort-select__label wc-block-components-sort-select__label",htmlFor:p}}),Object(n.createElement)("select",{id:p,className:"wc-block-sort-select__select wc-block-components-sort-select__select",onChange:i,readOnly:l,value:b},s.map((function(e){return Object(n.createElement)("option",{key:e.key,value:e.key},e.label)}))))}))},163:function(e,t,r){"use strict";var n=r(0),c=r(30),o=Object(n.createElement)(c.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=o},166:function(e,t,r){"use strict";r.d(t,"b",(function(){return a})),r.d(t,"c",(function(){return i})),r.d(t,"a",(function(){return s}));var n=r(3),c=r(113),o=r(24),a=function(e){var t=e.country,r=void 0===t?"":t,n=e.state,c=void 0===n?"":n,o=e.city,a=void 0===o?"":o,i=e.postcode,s=void 0===i?"":i;return{country:r.trim(),state:c.trim(),city:a.trim(),postcode:s?s.replace(" ","").toUpperCase():""}},i=function(e){var t=e.email,r=void 0===t?"":t;return Object(o.isEmail)(r)?r.trim():""},s=function(e){var t=Object.keys(n.defaultAddressFields),r=Object(c.a)(t,{},e.country),o=Object.assign({},e);return r.forEach((function(t){var r=t.key,n=void 0===r?"":r,c=t.hidden;void 0!==c&&c&&function(e,t){return e in t}(n,e)&&(o[n]="")})),o}},167:function(e,t,r){"use strict";r.d(t,"a",(function(){return s}));var n=r(27),c=r(16),o=r(0),a=r(62),i=r(130),s=function(e){var t=e.namespace,r=e.resourceName,s=e.resourceValues,u=void 0===s?[]:s,l=e.query,b=void 0===l?{}:l,p=e.shouldSelect,d=void 0===p||p;if(!t||!r)throw new Error("The options object must have valid values for the namespace and the resource properties.");var f=Object(o.useRef)({results:[],isLoading:!0}),m=Object(a.a)(b),O=Object(a.a)(u),g=Object(i.a)(),j=Object(c.useSelect)((function(e){if(!d)return null;var c=e(n.COLLECTIONS_STORE_KEY),o=[t,r,m,O],a=c.getCollectionError.apply(c,o);return a&&g(a),{results:c.getCollection.apply(c,o),isLoading:!c.hasFinishedResolution("getCollection",o)}}),[t,r,O,m,d]);return null!==j&&(f.current=j),f.current}},173:function(e,t){},186:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(0),c=Object(n.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 230 250",style:{width:"100%"}},Object(n.createElement)("title",null,"Grid Block Preview"),Object(n.createElement)("rect",{width:"65.374",height:"65.374",x:".162",y:".779",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(n.createElement)("rect",{width:"62.8",height:"15",x:"1.565",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(n.createElement)("rect",{width:"65.374",height:"65.374",x:".162",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(n.createElement)("rect",{width:"62.8",height:"15",x:"1.565",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(n.createElement)("rect",{width:"65.374",height:"65.374",x:"82.478",y:".779",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(n.createElement)("rect",{width:"62.8",height:"15",x:"83.882",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(n.createElement)("rect",{width:"65.374",height:"65.374",x:"82.478",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(n.createElement)("rect",{width:"62.8",height:"15",x:"83.882",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(n.createElement)("rect",{width:"65.374",height:"65.374",x:"164.788",y:".779",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(n.createElement)("rect",{width:"62.8",height:"15",x:"166.192",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(n.createElement)("rect",{width:"65.374",height:"65.374",x:"164.788",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(n.createElement)("rect",{width:"62.8",height:"15",x:"166.192",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"221.798",fill:"#E1E3E6",rx:"3"}))},189:function(e,t){e.exports=window.wp.warning},192:function(e,t,r){"use strict";var n=r(9),c=r.n(n),o=r(0),a=(r(258),function(e){if(e){var t=e.getBoundingClientRect().bottom;t>=0&&t<=window.innerHeight||e.scrollIntoView()}});t.a=function(e){return function(t){var r=Object(o.useRef)(null);return Object(o.createElement)(o.Fragment,null,Object(o.createElement)("div",{className:"with-scroll-to-top__scroll-point",ref:r,"aria-hidden":!0}),Object(o.createElement)(e,c()({},t,{scrollToTop:function(e){var t,n;null!==r.current&&(t=r.current,n=(e||{}).focusableSelector,window&&Number.isFinite(window.innerHeight)&&(n?function(e,t){var r,n=(null===(r=e.parentElement)||void 0===r?void 0:r.querySelectorAll(t))||[];if(n.length){var c=n[0];a(c),null==c||c.focus()}else a(e)}(t,n):a(t)))}})))}}},204:function(e,t){},205:function(e,t){},206:function(e,t){},207:function(e,t){},208:function(e,t){},209:function(e,t){},21:function(e,t){e.exports=window.wp.blockEditor},213:function(e,t){},215:function(e,t){},22:function(e,t){e.exports=window.wp.compose},23:function(e,t){e.exports=window.regeneratorRuntime},231:function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(0),c=(r(2),r(135)),o=(r(209),function(e){var t=e.errorMessage,r=void 0===t?"":t,o=e.propertyName,a=void 0===o?"":o,i=e.elementId,s=void 0===i?"":i,u=Object(c.b)(),l=u.getValidationError,b=u.getValidationErrorId;if(!r||"string"!=typeof r){var p=l(a)||{};if(!p.message||p.hidden)return null;r=p.message}return Object(n.createElement)("div",{className:"wc-block-components-validation-error",role:"alert"},Object(n.createElement)("p",{id:b(s)},r))})},24:function(e,t){e.exports=window.wp.url},25:function(e,t){e.exports=window.wp.blocks},258:function(e,t){},26:function(e,t){e.exports=window.wp.htmlEntities},27:function(e,t){e.exports=window.wc.wcBlocksData},3:function(e,t){e.exports=window.wc.wcSettings},30:function(e,t){e.exports=window.wp.primitives},304:function(e,t,r){"use strict";var n=r(9),c=r.n(n),o=r(31),a=r.n(o),i=r(8),s=r.n(i),u=r(14),l=r.n(u),b=r(0),p=r(23),d=r.n(p),f=r(11),m=r(39),O=r(221),g=r(42),j=["selected"];t.a=function(e){return function(t){var r=t.selected,n=l()(t,j),o=Object(b.useState)(!0),i=s()(o,2),u=i[0],p=i[1],h=Object(b.useState)(null),v=s()(h,2),w=v[0],y=v[1],E=Object(b.useState)([]),_=s()(E,2),k=_[0],P=_[1],C=f.q.productCount>100,S=function(){var e=a()(d.a.mark((function e(t){var r;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Object(g.a)(t);case 2:r=e.sent,y(r),p(!1);case 5:case"end":return e.stop()}}),e)})));return function(_x){return e.apply(this,arguments)}}();Object(b.useEffect)((function(){Object(m.h)({selected:r}).then((function(e){P(e),p(!1)})).catch(S)}),[r]);var x=Object(O.a)((function(e){Object(m.h)({selected:r,search:e}).then((function(e){P(e),p(!1)})).catch(S)}),400),N=s()(x,1)[0],D=Object(b.useCallback)((function(e){p(!0),N(e)}),[p,N]);return Object(b.createElement)(e,c()({},n,{selected:r,error:w,products:k,isLoading:u,onSearch:C?D:null}))}}},305:function(e,t,r){"use strict";var n=r(0),c=r(30),o=Object(n.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(n.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(n.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=o},306:function(e,t,r){"use strict";r.r(t);var n=r(5),c=r.n(n),o=r(0),a=(r(2),r(1)),i=r(6),s=r.n(i),u=r(40),l=r(43),b=r(84);r(541),t.default=Object(b.withProductDataContext)((function(e){var t=e.className,r=e.align,n=Object(l.useInnerBlockLayoutContext)().parentClassName,i=Object(l.useProductDataContext)().product;if(!i.id||!i.on_sale)return null;var b="string"==typeof r?"wc-block-components-product-sale-badge--align-".concat(r):"";return Object(o.createElement)("div",{className:s()("wc-block-components-product-sale-badge",t,b,c()({},"".concat(n,"__product-onsale"),n))},Object(o.createElement)(u.a,{label:Object(a.__)("Sale","woo-gutenberg-products-block"),screenReaderLabel:Object(a.__)("Product on sale","woo-gutenberg-products-block")}))}))},309:function(e,t,r){"use strict";var n=r(0),c=r(30),o=Object(n.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(n.createElement)("path",{fill:"none",d:"M0 0h24v24H0z"}),Object(n.createElement)("path",{d:"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"}));t.a=o},32:function(e,t){e.exports=window.moment},321:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(128),c=function(e,t){return function(r){var c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,o=n.a.addEventCallback(e,r,c);return t(o),function(){t(n.a.removeEventCallback(e,o.id))}}}},322:function(e,t,r){"use strict";r.d(t,"a",(function(){return d})),r.d(t,"b",(function(){return f}));var n=r(37),c=r.n(n),o=r(31),a=r.n(o),i=r(23),s=r.n(i),u=function(e,t){return e[t]?Array.from(e[t].values()).sort((function(e,t){return e.priority-t.priority})):[]},l=r(50);function b(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return p(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?p(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,c=function(){};return{s:c,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:c}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,i=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){i=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(i)throw o}}}}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var d=function(){var e=a()(s.a.mark((function e(t,r,n){var o,a,i,l,p,d;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o=u(t,r),a=[],i=b(o),e.prev=3,i.s();case 5:if((l=i.n()).done){e.next=19;break}return p=l.value,e.prev=7,e.next=10,Promise.resolve(p.callback(n));case 10:d=e.sent,"object"===c()(d)&&a.push(d),e.next=17;break;case 14:e.prev=14,e.t0=e.catch(7),console.error(e.t0);case 17:e.next=5;break;case 19:e.next=24;break;case 21:e.prev=21,e.t1=e.catch(3),i.e(e.t1);case 24:return e.prev=24,i.f(),e.finish(24);case 27:return e.abrupt("return",!a.length||a);case 28:case"end":return e.stop()}}),e,null,[[3,21,24,27],[7,14]])})));return function(_x,t,r){return e.apply(this,arguments)}}(),f=function(){var e=a()(s.a.mark((function e(t,r,n){var o,a,i,p,d,f;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o=[],a=u(t,r),i=b(a),e.prev=3,i.s();case 5:if((p=i.n()).done){e.next=28;break}return d=p.value,e.prev=7,e.next=10,Promise.resolve(d.callback(n));case 10:if(f=e.sent,"object"===c()(f)&&null!==f){e.next=13;break}return e.abrupt("continue",26);case 13:if(f.hasOwnProperty("type")){e.next=15;break}throw new Error("Returned objects from event emitter observers must return an object with a type property");case 15:if(!Object(l.a)(f)&&!Object(l.b)(f)){e.next=18;break}return o.push(f),e.abrupt("return",o);case 18:o.push(f),e.next=26;break;case 21:return e.prev=21,e.t0=e.catch(7),console.error(e.t0),o.push({type:"error"}),e.abrupt("return",o);case 26:e.next=5;break;case 28:e.next=33;break;case 30:e.prev=30,e.t1=e.catch(3),i.e(e.t1);case 33:return e.prev=33,i.f(),e.finish(33);case 36:return e.abrupt("return",o);case 37:case"end":return e.stop()}}),e,null,[[3,30,33,36],[7,21]])})));return function(t,r,n){return e.apply(this,arguments)}}()},33:function(e,t){e.exports=window.wp.isShallowEqual},36:function(e,t){e.exports=window.wp.dataControls},375:function(e,t){},376:function(e,t,r){"use strict";var n=r(5),c=r.n(n),o=r(11);function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var s={headingLevel:{type:"number",default:2},showProductLink:{type:"boolean",default:!0},productId:{type:"number",default:0}};Object(o.s)()&&(s=i(i({},s),{},{align:{type:"string"},color:{type:"string"},customColor:{type:"string"},fontSize:{type:"string"},customFontSize:{type:"number"}})),t.a=s},377:function(e,t,r){"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}}},378:function(e,t,r){"use strict";var n=r(9),c=r.n(n),o=r(5),a=r.n(o),i=r(8),s=r.n(i),u=r(0),l=(r(2),r(1)),b=r(6),p=r.n(b),d=r(3),f=r(43),m=r(84),O=r(66),g=r(306);function j(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function h(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?j(Object(r),!0).forEach((function(t){a()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}r(542);var v=function(){return Object(u.createElement)("img",{src:d.PLACEHOLDER_IMG_SRC,alt:"",width:500,height:500})},w=function(e){var t=e.image,r=e.onLoad,n=e.loaded,o=e.showFullSize,a=e.fallbackAlt,i=t||{},s=i.thumbnail,l=i.src,b=i.srcset,p=i.sizes,d=h({alt:i.alt||a,onLoad:r,hidden:!n,src:s},o&&{src:l,srcSet:b,sizes:p});return Object(u.createElement)(u.Fragment,null,d.src&&Object(u.createElement)("img",c()({"data-testid":"product-image"},d)),!n&&Object(u.createElement)(v,null))};t.a=Object(m.withProductDataContext)((function(e){var t=e.className,r=e.imageSizing,n=void 0===r?"full-size":r,c=e.showProductLink,o=void 0===c||c,i=e.showSaleBadge,b=e.saleBadgeAlign,d=void 0===b?"right":b,m=Object(f.useInnerBlockLayoutContext)().parentClassName,j=Object(f.useProductDataContext)().product,y=Object(u.useState)(!1),E=s()(y,2),_=E[0],k=E[1],P=Object(O.a)().dispatchStoreEvent;if(!j.id)return Object(u.createElement)("div",{className:p()(t,"wc-block-components-product-image","wc-block-components-product-image--placeholder",a()({},"".concat(m,"__product-image"),m))},Object(u.createElement)(v,null));var C=!!j.images.length,S=C?j.images[0]:null,x=o?"a":u.Fragment,N=Object(l.sprintf)(
|
| 12 |
/* translators: %s is referring to the product name */
|
| 13 |
-
Object(
|
| 14 |
/* translators: %s number of products in cart. */
|
| 15 |
-
Object(s._n)("%d in cart","%d in cart",r,"woo-gutenberg-products-block"),r):Object(s.__)("Add to cart","woo-gutenberg-products-block"),!!a&&Object(n.createElement)(F.a,{srcElement:M.a,alt:Object(s.__)("Done","woo-gutenberg-products-block")}))},Y=function(){var e=C(),t=e.showFormElements,r=e.productIsPurchasable,c=e.productHasOptions,o=e.product,a=e.productType,u=e.isDisabled,l=e.isProcessing,b=e.eventRegistration,p=e.hasError,d=e.dispatchActions,f=Object(I.useInnerBlockLayoutContext)().parentName,m=Object(H.a)().dispatchStoreEvent,O=Object(q.a)(o.id||0).cartQuantity,g=Object(n.useState)(!1),j=i()(g,2),h=j[0],v=j[1],w=o.add_to_cart||{url:"",text:""};return Object(n.useEffect)((function(){var e=b.onAddToCartAfterProcessingWithSuccess((function(){return p||v(!0),!0}),0);return function(){e()}}),[b,p]),(t||!c&&"simple"===a)&&r?Object(n.createElement)(Q,{className:"wc-block-components-product-add-to-cart-button",quantityInCart:O,isDisabled:u,isProcessing:l,isDone:h,onClick:function(){d.submitForm(),m("cart-add-item",{product:o,listName:f})}}):Object(n.createElement)(G,{className:"wc-block-components-product-add-to-cart-button",href:w.url,text:w.text||Object(s.__)("View Product","woo-gutenberg-products-block"),onClick:function(){m("product-view-link",{product:o,listName:f})}})},U=function(e){var t=e.disabled,r=e.min,c=e.max,o=e.value,a=e.onChange;return Object(n.createElement)("input",{className:"wc-block-components-product-add-to-cart-quantity",type:"number",value:o,min:r,max:c,hidden:1===c,disabled:t,onChange:function(e){a(e.target.value)}})},W=function(e){var t=e.reason,r=void 0===t?Object(s.__)("Sorry, this product cannot be purchased.","woo-gutenberg-products-block"):t;return Object(n.createElement)("div",{className:"wc-block-components-product-add-to-cart-unavailable"},r)},K=function(){var e=C(),t=e.product,r=e.quantity,c=e.minQuantity,o=e.maxQuantity,a=e.dispatchActions,i=e.isDisabled;return t.id&&!t.is_purchasable?Object(n.createElement)(W,null):t.id&&!t.is_in_stock?Object(n.createElement)(W,{reason:Object(s.__)("This product is currently out of stock and cannot be purchased.","woo-gutenberg-products-block")}):Object(n.createElement)(n.Fragment,null,Object(n.createElement)(U,{value:r,min:c,max:o,disabled:i,onChange:a.setQuantity}),Object(n.createElement)(Y,null))},$=(r(550),r(35)),J=r.n($),X=r(874),Z=r(12),ee=r(231),te={value:"",label:Object(s.__)("Select an option","woo-gutenberg-products-block")},re=function(e){var t=e.attributeName,r=e.options,c=void 0===r?[]:r,a=e.value,i=void 0===a?"":a,u=e.onChange,l=void 0===u?function(){}:u,b=e.errorMessage,p=void 0===b?Object(s.__)("Please select a value.","woo-gutenberg-products-block"):b,d=Object(E.b)(),m=d.getValidationError,O=d.setValidationErrors,g=d.clearValidationError,j=t,h=m(j)||{};return Object(Z.useEffect)((function(){i?g(j):O(f()({},j,{message:p,hidden:!0}))}),[i,j,p,g,O]),Object(Z.useEffect)((function(){return function(){g(j)}}),[j,g]),Object(n.createElement)("div",{className:"wc-block-components-product-add-to-cart-attribute-picker__container"},Object(n.createElement)(X.a,{label:Object(D.decodeEntities)(t),value:i||"",options:[te].concat(J()(c)),onChange:l,required:!0,className:o()("wc-block-components-product-add-to-cart-attribute-picker__select",{"has-error":h.message&&!h.hidden})}),Object(n.createElement)(ee.a,{propertyName:j,elementId:j}))};function ne(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ce(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ne(Object(r),!0).forEach((function(t){f()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ne(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var oe=function(e,t,r){var n=Object.values(t).map((function(e){return e.id}));if(Object.values(r).every((function(e){return""===e})))return n;var c=Object.keys(e);return n.filter((function(e){return c.every((function(n){var c=r[n]||"",o=t["id:"+e].attributes[n];return""===c||null===o||o===c}))}))};function ae(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ie(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ae(Object(r),!0).forEach((function(t){f()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ae(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var se=function(e){var t=e.attributes,r=e.variationAttributes,c=e.setRequestParams,o=Object(u.a)(t),a=Object(u.a)(r),s=Object(n.useState)(0),l=i()(s,2),b=l[0],p=l[1],d=Object(n.useState)({}),m=i()(d,2),O=m[0],g=m[1],j=Object(n.useMemo)((function(){return function(e,t,r){var n={},c=Object.keys(e),o=Object.values(r).filter(Boolean).length>0;return c.forEach((function(c){var a=e[c],i=ce(ce({},r),{},f()({},c,null)),s=o?oe(e,t,i):null,u=null!==s?s.map((function(e){return t["id:"+e].attributes[c]})):null;n[c]=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return Object.values(e).map((function(e){var r=e.name,n=e.slug;return null===t||t.includes(null)||t.includes(n)?{value:n,label:Object(D.decodeEntities)(r)}:null})).filter(Boolean)}(a.terms,u)})),n}(o,a,O)}),[O,o,a]);return Object(n.useEffect)((function(){Object.values(O).filter((function(e){return""!==e})).length===Object.keys(o).length?p(function(e,t,r){return oe(e,t,r)[0]||0}(o,a,O)):b>0&&p(0)}),[O,b,o,a]),Object(n.useEffect)((function(){c({id:b,variation:Object.keys(O).map((function(e){return{attribute:e,value:O[e]}}))})}),[c,b,O]),Object(n.createElement)("div",{className:"wc-block-components-product-add-to-cart-attribute-picker"},Object.keys(o).map((function(e){return Object(n.createElement)(re,{key:e,attributeName:e,options:j[e],value:O[e],onChange:function(t){g(ie(ie({},O),{},f()({},e,t)))}})})))},ue=function(e){var t=e.product,r=e.dispatchers,c=function(e){return e?Object(L.keyBy)(Object.values(e).filter((function(e){return e.has_variations})),"name"):{}}(t.attributes),o=function(e){if(!e)return{};var t={};return e.forEach((function(e){var r=e.id,n=e.attributes;t["id:".concat(r)]={id:r,attributes:n.reduce((function(e,t){var r=t.name,n=t.value;return e[r]=n,e}),{})}})),t}(t.variations);return 0===Object.keys(c).length||0===o.length?null:Object(n.createElement)(se,{attributes:c,variationAttributes:o,setRequestParams:r.setRequestParams})},le=function(){var e=C(),t=e.product,r=e.quantity,c=e.minQuantity,o=e.maxQuantity,a=e.dispatchActions,i=e.isDisabled;return t.id&&!t.is_purchasable?Object(n.createElement)(W,null):t.id&&!t.is_in_stock?Object(n.createElement)(W,{reason:Object(s.__)("This product is currently out of stock and cannot be purchased.","woo-gutenberg-products-block")}):Object(n.createElement)(n.Fragment,null,Object(n.createElement)(ue,{product:t,dispatchers:a}),Object(n.createElement)(U,{value:r,min:c,max:o,disabled:i,onChange:a.setQuantity}),Object(n.createElement)(Y,null))},be=function(){return Object(n.createElement)(Y,null)},pe=r(869),de=function(){return Object(n.createElement)(pe.a,{className:"wc-block-components-product-add-to-cart-group-list"},"This is a placeholder for the grouped products form element.")},fe=function(){return Object(n.createElement)(de,null)},me=function(){var e=C(),t=e.showFormElements,r=e.productType;return t?"variable"===r?Object(n.createElement)(le,null):"grouped"===r?Object(n.createElement)(fe,null):"external"===r?Object(n.createElement)(be,null):"simple"===r||"variation"===r?Object(n.createElement)(K,null):null:Object(n.createElement)(Y,null)};t.a=Object(z.withProductDataContext)((function(e){var t=e.className,r=e.showFormElements,c=Object(I.useProductDataContext)().product,a=o()(t,"wc-block-components-product-add-to-cart",{"wc-block-components-product-add-to-cart--placeholder":Object(L.isEmpty)(c)});return Object(n.createElement)(A,{product:c,showFormElements:r},Object(n.createElement)("div",{className:a},Object(n.createElement)(me,null)))}))},381:function(e,t,r){"use strict";var n=r(5),c=r.n(n),o=r(0),a=(r(2),r(6)),i=r.n(a),s=r(43),u=r(21),l=r(11),b=function(e){var t=e.color,r=e.fontSize;return Object(l.s)()?{color:t,fontSize:r}:{}},p=r(84),d=r(159),f=r(66);r(540),t.a=Object(p.withProductDataContext)((function(e){var t,r,n,a=e.className,p=e.headingLevel,m=void 0===p?2:p,O=e.showProductLink,g=void 0===O||O,j=e.align,h=e.color,v=e.customColor,w=e.fontSize,y=e.customFontSize,E=Object(s.useInnerBlockLayoutContext)().parentClassName,_=Object(s.useProductDataContext)().product,k=Object(f.a)().dispatchStoreEvent,P="h".concat(m),C=Object(u.getColorClassName)("color",h),S=Object(u.getFontSizeClass)(w),x=i()((t={"has-text-color":h||v,"has-font-size":w||y},c()(t,C,C),c()(t,S,S),t));return _.id?Object(o.createElement)(P,{className:i()(a,"wc-block-components-product-title",(r={},c()(r,"".concat(E,"__product-title"),E),c()(r,"wc-block-components-product-title--align-".concat(j),j&&Object(l.s)()),r))},Object(o.createElement)(d.a,{className:i()(c()({},x,Object(l.s)())),disabled:!g,name:_.name,permalink:_.permalink,rel:g?"nofollow":null,style:b({color:v,fontSize:y}),onClick:function(){k("product-view-link",{product:_})}})):Object(o.createElement)(P,{className:i()(a,"wc-block-components-product-title",(n={},c()(n,"".concat(E,"__product-title"),E),c()(n,"wc-block-components-product-title--align-".concat(j),j&&Object(l.s)()),c()(n,x,Object(l.s)()),n)),style:b({color:v,fontSize:y})})}))},39:function(e,t,r){"use strict";r.d(t,"h",(function(){return d})),r.d(t,"e",(function(){return f})),r.d(t,"b",(function(){return m})),r.d(t,"i",(function(){return O})),r.d(t,"f",(function(){return g})),r.d(t,"c",(function(){return j})),r.d(t,"d",(function(){return h})),r.d(t,"g",(function(){return v})),r.d(t,"a",(function(){return w}));var n=r(5),c=r.n(n),o=r(24),a=r(15),i=r.n(a),s=r(7),u=r(3),l=r(11);function b(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function p(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?b(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var d=function(e){var t=e.selected,r=void 0===t?[]:t,n=e.search,c=void 0===n?"":n,a=e.queryArgs,u=function(e){var t=e.selected,r=void 0===t?[]:t,n=e.search,c=void 0===n?"":n,a=e.queryArgs,i=void 0===a?{}:a,s=l.q.productCount>100,u={per_page:s?100:0,catalog_visibility:"any",search:c,orderby:"title",order:"asc"},b=[Object(o.addQueryArgs)("/wc/store/products",p(p({},u),i))];return s&&r.length&&b.push(Object(o.addQueryArgs)("/wc/store/products",{catalog_visibility:"any",include:r,per_page:0})),b}({selected:r,search:c,queryArgs:void 0===a?{}:a});return Promise.all(u.map((function(e){return i()({path:e})}))).then((function(e){return Object(s.uniqBy)(Object(s.flatten)(e),"id").map((function(e){return p(p({},e),{},{parent:0})}))})).catch((function(e){throw e}))},f=function(e){return i()({path:"/wc/store/products/".concat(e)})},m=function(){return i()({path:"wc/store/products/attributes"})},O=function(e){return i()({path:"wc/store/products/attributes/".concat(e,"/terms")})},g=function(e){var t=e.selected,r=function(e){var t=e.selected,r=void 0===t?[]:t,n=e.search,c=Object(u.getSetting)("limitTags",!1),a=[Object(o.addQueryArgs)("wc/store/products/tags",{per_page:c?100:0,orderby:c?"count":"name",order:c?"desc":"asc",search:n})];return c&&r.length&&a.push(Object(o.addQueryArgs)("wc/store/products/tags",{include:r})),a}({selected:void 0===t?[]:t,search:e.search});return Promise.all(r.map((function(e){return i()({path:e})}))).then((function(e){return Object(s.uniqBy)(Object(s.flatten)(e),"id")}))},j=function(e){return i()({path:Object(o.addQueryArgs)("wc/store/products/categories",p({per_page:0},e))})},h=function(e){return i()({path:"wc/store/products/categories/".concat(e)})},v=function(e){return i()({path:Object(o.addQueryArgs)("wc/store/products",{per_page:0,type:"variation",parent:e})})},w=function(e,t){if(!e.title.raw)return e.slug;var r=1===t.filter((function(t){return t.title.raw===e.title.raw})).length;return e.title.raw+(r?"":" - ".concat(e.slug))}},4:function(e,t){e.exports=window.wp.components},40:function(e,t,r){"use strict";var n=r(5),c=r.n(n),o=r(0),a=r(6),i=r.n(a);function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}t.a=function(e){var t,r=e.label,n=e.screenReaderLabel,c=e.wrapperElement,a=e.wrapperProps,s=void 0===a?{}:a,l=null!=r,b=null!=n;return!l&&b?(t=c||"span",s=u(u({},s),{},{className:i()(s.className,"screen-reader-text")}),Object(o.createElement)(t,s,n)):(t=c||o.Fragment,l&&b&&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))}},42:function(e,t,r){"use strict";r.d(t,"a",(function(){return s})),r.d(t,"b",(function(){return u}));var n=r(31),c=r.n(n),o=r(23),a=r.n(o),i=r(1),s=function(){var e=c()(a.a.mark((function e(t){var r;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("function"!=typeof t.json){e.next=11;break}return e.prev=1,e.next=4,t.json();case 4:return r=e.sent,e.abrupt("return",{message:r.message,type:r.type||"api"});case 8:return e.prev=8,e.t0=e.catch(1),e.abrupt("return",{message:e.t0.message,type:"general"});case 11:return e.abrupt("return",{message:t.message,type:t.type||"general"});case 12:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(_x){return e.apply(this,arguments)}}(),u=function(e){if(e.data&&"rest_invalid_param"===e.code){var t=Object.values(e.data.params);if(t[0])return t[0]}return(null==e?void 0:e.message)||Object(i.__)("Something went wrong. Please contact us to get assistance.","woo-gutenberg-products-block")}},43:function(e,t){e.exports=window.wc.wcBlocksSharedContext},44:function(e,t,r){"use strict";r.d(t,"a",(function(){return y}));var n=r(8),c=r.n(n),o=r(5),a=r.n(o),i=r(7),s=r(0),u=r(27),l=r(16),b=r(26),p=r(142),d=r(166),f=r(60);function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function O(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach((function(t){a()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var g={first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:""},j=O(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:u.EMPTY_TAX_LINES,currency_code:"",currency_symbol:"",currency_minor_unit:2,currency_decimal_separator:"",currency_thousand_separator:"",currency_prefix:"",currency_suffix:""},v=function(e){return Object(p.a)(Object.entries(e).map((function(e){var t=c()(e,2),r=t[0],n=t[1];return[r,Object(b.decodeEntities)(n)]})))},w={cartCoupons:u.EMPTY_CART_COUPONS,cartItems:u.EMPTY_CART_ITEMS,cartFees:u.EMPTY_CART_FEES,cartItemsCount:0,cartItemsWeight:0,cartNeedsPayment:!0,cartNeedsShipping:!0,cartItemErrors:u.EMPTY_CART_ITEM_ERRORS,cartTotals:h,cartIsLoading:!0,cartErrors:u.EMPTY_CART_ERRORS,billingAddress:j,shippingAddress:g,shippingRates:u.EMPTY_SHIPPING_RATES,shippingRatesLoading:!1,cartHasCalculatedShipping:!1,paymentRequirements:u.EMPTY_PAYMENT_REQUIREMENTS,receiveCart:function(){},extensions:u.EMPTY_EXTENSIONS},y=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{shouldSelect:!0},t=Object(f.b)(),r=t.isEditor,n=t.previewData,c=null==n?void 0:n.previewCart,o=e.shouldSelect,a=Object(s.useRef)(),b=Object(l.useSelect)((function(e,t){var n=t.dispatch;if(!o)return w;if(r)return{cartCoupons:c.coupons,cartItems:c.items,cartFees:c.fees,cartItemsCount:c.items_count,cartItemsWeight:c.items_weight,cartNeedsPayment:c.needs_payment,cartNeedsShipping:c.needs_shipping,cartItemErrors:u.EMPTY_CART_ITEM_ERRORS,cartTotals:c.totals,cartIsLoading:!1,cartErrors:u.EMPTY_CART_ERRORS,billingAddress:j,shippingAddress:g,extensions:u.EMPTY_EXTENSIONS,shippingRates:c.shipping_rates,shippingRatesLoading:!1,cartHasCalculatedShipping:c.has_calculated_shipping,paymentRequirements:c.paymentRequirements,receiveCart:"function"==typeof(null==c?void 0:c.receiveCart)?c.receiveCart:function(){}};var a=e(u.CART_STORE_KEY),i=a.getCartData(),s=a.getCartErrors(),l=a.getCartTotals(),b=!a.hasFinishedResolution("getCartData"),p=a.isCustomerDataUpdating(),f=n(u.CART_STORE_KEY).receiveCart,m=v(i.billingAddress),h=i.needsShipping?v(i.shippingAddress):m,y=i.fees.length>0?i.fees.map((function(e){return v(e)})):u.EMPTY_CART_FEES;return{cartCoupons:i.coupons.length>0?i.coupons.map((function(e){return O(O({},e),{},{label:e.code})})):u.EMPTY_CART_COUPONS,cartItems:i.items,cartFees:y,cartItemsCount:i.itemsCount,cartItemsWeight:i.itemsWeight,cartNeedsPayment:i.needsPayment,cartNeedsShipping:i.needsShipping,cartItemErrors:i.errors,cartTotals:l,cartIsLoading:b,cartErrors:s,billingAddress:Object(d.a)(m),shippingAddress:Object(d.a)(h),extensions:i.extensions,shippingRates:i.shippingRates,shippingRatesLoading:p,cartHasCalculatedShipping:i.hasCalculatedShipping,paymentRequirements:i.paymentRequirements,receiveCart:f}}),[o]);return a.current&&Object(i.isEqual)(a.current,b)||(a.current=b),a.current}},46:function(e,t){e.exports=window.wc.priceFormat},48:function(e,t){e.exports=window.wp.escapeHtml},485:function(e,t,r){"use strict";r.r(t);var n=r(5),c=r.n(n),o=r(0),a=(r(2),r(6)),i=r.n(a),s=r(126),u=r(46),l=r(43),b=r(21),p=r(11),d=r(84);t.default=Object(d.withProductDataContext)((function(e){var t,r,n,a,d,f,m,O=e.className,g=e.align,j=e.fontSize,h=e.customFontSize,v=e.saleFontSize,w=e.customSaleFontSize,y=e.color,E=e.customColor,_=e.saleColor,k=e.customSaleColor,P=Object(l.useInnerBlockLayoutContext)().parentClassName,C=Object(l.useProductDataContext)().product,S=i()(O,c()({},"".concat(P,"__product-price"),P));if(!C.id)return Object(o.createElement)(s.a,{align:g,className:S});var x=Object(b.getColorClassName)("color",y),N=Object(b.getFontSizeClass)(j),D=Object(b.getColorClassName)("color",_),B=Object(b.getFontSizeClass)(v),R=i()((t={"has-text-color":y||E,"has-font-size":j||h},c()(t,x,x),c()(t,N,N),t)),T=i()((r={"has-text-color":_||k,"has-font-size":v||w},c()(r,D,D),c()(r,B,B),r)),A={color:E,fontSize:h},I={color:k,fontSize:w},L=C.prices,z=Object(u.getCurrencyFromPriceResponse)(L),V=L.price!==L.regular_price,F=V?i()((n={},c()(n,"".concat(P,"__product-price__value"),P),c()(n,T,Object(p.s)()),n)):i()((a={},c()(a,"".concat(P,"__product-price__value"),P),c()(a,R,Object(p.s)()),a)),M=V?I:A;return Object(o.createElement)(s.a,{align:g,className:S,currency:z,price:L.price,priceClassName:F,priceStyle:Object(p.s)()?M:{},minPrice:null==L||null===(d=L.price_range)||void 0===d?void 0:d.min_amount,maxPrice:null==L||null===(f=L.price_range)||void 0===f?void 0:f.max_amount,regularPrice:L.regular_price,regularPriceClassName:i()((m={},c()(m,"".concat(P,"__product-price__regular"),P),c()(m,R,Object(p.s)()),m)),regularPriceStyle:Object(p.s)()?A:{}})}))},486:function(e,t,r){"use strict";r.r(t);var n=r(5),c=r.n(n),o=r(0),a=(r(2),r(1)),i=r(6),s=r.n(i),u=r(43),l=r(84),b=(r(543),function(e){var t=parseFloat(e.average_rating);return Number.isFinite(t)&&t>0?t:0});t.default=Object(l.withProductDataContext)((function(e){var t=e.className,r=Object(u.useInnerBlockLayoutContext)().parentClassName,n=Object(u.useProductDataContext)().product,i=b(n);if(!i)return null;var l={width:i/5*100+"%"},p=Object(a.sprintf)(
|
| 16 |
/* translators: %f is referring to the average rating value */
|
| 17 |
-
Object(a.__)("Rated %f out of 5","woo-gutenberg-products-block"),i);return Object(o.createElement)("div",{className:s()(t,"wc-block-components-product-rating",c()({},"".concat(r,"__product-rating"),r))},Object(o.createElement)("div",{className:s()("wc-block-components-product-rating__stars","".concat(r,"__product-rating__stars")),role:"img","aria-label":p},Object(o.createElement)("span",{style:
|
| 18 |
/* translators: %s number of products in cart. */
|
| 19 |
-
Object(
|
| 20 |
/* translators: %d stock amount (number of items in stock for product) */
|
| 21 |
-
Object(a.__)("%d left in stock","woo-gutenberg-products-block"),e)});t.default=Object(l.withProductDataContext)((function(e){var t,r=e.className,n=Object(u.useInnerBlockLayoutContext)().parentClassName,i=Object(u.useProductDataContext)().product;if(!i.id||!i.is_purchasable)return null;var l=!!i.is_in_stock,p=i.low_stock_remaining,d=i.is_on_backorder;return Object(o.createElement)("div",{className:s()(r,"wc-block-components-product-stock-indicator",(t={},c()(t,"".concat(n,"__stock-indicator"),n),c()(t,"wc-block-components-product-stock-indicator--in-stock",l),c()(t,"wc-block-components-product-stock-indicator--out-of-stock",!l),c()(t,"wc-block-components-product-stock-indicator--low-stock",!!p),c()(t,"wc-block-components-product-stock-indicator--available-on-backorder",!!d),t))},p?b(p):function(e,t){return t?Object(a.__)("Available on backorder","woo-gutenberg-products-block"):e?Object(a.__)("In Stock","woo-gutenberg-products-block"):Object(a.__)("Out of Stock","woo-gutenberg-products-block")}(l,d))}))},50:function(e,t,r){"use strict";r.d(t,"a",(function(){return s})),r.d(t,"b",(function(){return u})),r.d(t,"c",(function(){return b}));var n,c,o=r(104);!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={}));var a=function(e,t){return Object(o.b)(e)&&"type"in e&&e.type===t},i=function(e){return a(e,n.SUCCESS)},s=function(e){return a(e,n.ERROR)},u=function(e){return a(e,n.FAIL)},l=function(e){return!Object(o.b)(e)||void 0===e.retry||!0===e.retry},b=function(){return{responseTypes:n,noticeContexts:c,shouldRetry:l,isSuccessResponse:i,isErrorResponse:s,isFailResponse:u}}},52:function(e,t,r){"use strict";var n=r(0),c=r(1),o=(r(2),r(48));t.a=function(e){var t,r,a,i=e.error;return Object(n.createElement)("div",{className:"wc-block-error-message"},(r=(t=i).message,a=t.type,r?"general"===a?Object(n.createElement)("span",null,Object(c.__)("The following error was returned","woo-gutenberg-products-block"),Object(n.createElement)("br",null),Object(n.createElement)("code",null,Object(o.escapeHTML)(r))):"api"===a?Object(n.createElement)("span",null,Object(c.__)("The following error was returned from the API","woo-gutenberg-products-block"),Object(n.createElement)("br",null),Object(n.createElement)("code",null,Object(o.escapeHTML)(r))):r:Object(c.__)("An unknown error occurred which prevented the block from being updated.","woo-gutenberg-products-block")))}},53:function(e,t,r){"use strict";var n=r(9),c=r.n(n),o=r(5),a=r.n(o),i=r(14),s=r.n(i),u=r(0),l=r(168),b=r(6),p=r.n(b),d=(r(173),["className","value","currency","onValueChange","displayType"]);function f(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?f(Object(r),!0).forEach((function(t){a()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}t.a=function(e){var t=e.className,r=e.value,n=e.currency,o=e.onValueChange,a=e.displayType,i=void 0===a?"text":a,b=s()(e,d),f="string"==typeof r?parseInt(r,10):r;if(!Number.isFinite(f))return null;var O=f/Math.pow(10,n.minorUnit);if(!Number.isFinite(O))return null;var g=p()("wc-block-formatted-money-amount","wc-block-components-formatted-money-amount",t),j=m(m(m({},b),function(e){return{thousandSeparator:e.thousandSeparator,decimalSeparator:e.decimalSeparator,decimalScale:e.minorUnit,fixedDecimalScale:!0,prefix:e.prefix,suffix:e.suffix,isNumericString:!0}}(n)),{},{value:void 0,currency:void 0,onValueChange:void 0}),h=o?function(e){var t=e.value*Math.pow(10,n.minorUnit);o(t)}:function(){};return Object(u.createElement)(l.a,c()({className:g,displayType:i},j,{value:O,onValueChange:h}))}},54:function(e,t){e.exports=window.wp.deprecated},540:function(e,t){},541:function(e,t){},542:function(e,t){},543:function(e,t){},544:function(e,t){},545:function(e,t){},546:function(e,t){},547:function(e,t){},548:function(e,t){},549:function(e,t){},55:function(e,t){e.exports=window.wp.hooks},550:function(e,t){},56:function(e,t){e.exports=window.wc.wcBlocksRegistry},57:function(e,t,r){"use strict";r.d(t,"a",(function(){return u}));var n=r(5),c=r.n(n),o=r(0),a=r(129);function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var u=function(){var e=Object(a.b)(),t=e.notices,r=e.createNotice,n=e.removeNotice,c=e.setIsSuppressed,i=Object(o.useRef)(t);Object(o.useEffect)((function(){i.current=t}),[t]);var u=Object(o.useMemo)((function(){return{hasNoticesOfType:function(e){return i.current.some((function(t){return t.type===e}))},removeNotices:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;i.current.forEach((function(t){null!==e&&t.status!==e||n(t.id)}))},removeNotice:n}}),[n]),l=Object(o.useMemo)((function(){return{addDefaultNotice:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r("default",e,s({},t))},addErrorNotice:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r("error",e,s({},t))},addWarningNotice:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r("warning",e,s({},t))},addInfoNotice:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r("info",e,s({},t))},addSuccessNotice:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r("success",e,s({},t))}}}),[r]);return s(s(s({notices:t},u),l),{},{setIsSuppressed:c})}},60:function(e,t,r){"use strict";r.d(t,"b",(function(){return a})),r.d(t,"a",(function(){return i}));var n=r(0),c=r(16),o=Object(n.createContext)({isEditor:!1,currentPostId:0,previewData:{},getPreviewData:function(){}}),a=function(){return Object(n.useContext)(o)},i=function(e){var t=e.children,r=e.currentPostId,a=void 0===r?0:r,i=e.previewData,s=void 0===i?{}:i,u=Object(c.useSelect)((function(e){return a||e("core/editor").getCurrentPostId()}),[a]),l=Object(n.useCallback)((function(e){return e in s?s[e]:{}}),[s]),b={isEditor:!0,currentPostId:u,previewData:s,getPreviewData:l};return Object(n.createElement)(o.Provider,{value:b},t)}},62:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(0),c=r(33),o=r.n(c);function a(e){var t=Object(n.useRef)(e);return o()(e,t.current)||(t.current=e),t.current}},63:function(e,t,r){"use strict";var n=r(5),c=r.n(n),o=r(14),a=r.n(o),i=r(0),s=["srcElement","size"];function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}t.a=function(e){var t=e.srcElement,r=e.size,n=void 0===r?24:r,o=a()(e,s);return Object(i.isValidElement)(t)?Object(i.cloneElement)(t,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({width:n,height:n},o)):null}},66:function(e,t,r){"use strict";r.d(t,"a",(function(){return l}));var n=r(5),c=r.n(n),o=r(55),a=r(0),i=r(44);function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var l=function(){var e=Object(i.a)(),t=Object(a.useRef)(e);return Object(a.useEffect)((function(){t.current=e}),[e]),{dispatchStoreEvent:Object(a.useCallback)((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(o.doAction)("experimental__woocommerce_blocks-".concat(e),t)}catch(e){console.error(e)}}),[]),dispatchCheckoutEvent:Object(a.useCallback)((function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(o.doAction)("experimental__woocommerce_blocks-checkout-".concat(e),u(u({},r),{},{storeCart:t.current}))}catch(e){console.error(e)}}),[])}}},69:function(e,t){e.exports=window.wp.a11y},7:function(e,t){e.exports=window.lodash},74:function(e,t){e.exports=window.wp.dom},741:function(e,t,r){"use strict";var n=r(0),c=r(30),o=Object(n.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(n.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(n.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=o},748:function(e,t,r){"use strict";var n=r(0),c=r(30),o=Object(n.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(n.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(n.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(n.createElement)("circle",{cx:"6.5",cy:"6.5",r:"1.5"}),Object(n.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=o},75:function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(0),c=Object(n.createContext)("page"),o=function(){return Object(n.useContext)(c)};c.Provider},756:function(e,t,r){"use strict";var n=r(0),c=r(30),o=Object(n.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(n.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(n.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=o},757:function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(1),c=r(11),o=[{id:1,name:"WordPress Pennant",variation:"",permalink:"https://example.org",sku:"wp-pennant",short_description:Object(n.__)("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:c.p+"previews/pennant.jpg",thumbnail:c.p+"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(n.__)("Add to cart","woo-gutenberg-products-block"),description:Object(n.__)("Add to cart","woo-gutenberg-products-block")},has_options:!1,is_purchasable:!0,is_in_stock:!0,on_sale:!0}]},762:function(e,t,r){"use strict";var n=r(0),c=r(30),o=Object(n.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(n.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(n.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=o},769:function(e,t,r){e.exports=r(825)},770:function(e,t){},771:function(e,t){},772:function(e,t,r){"use strict";r.d(t,"a",(function(){return p}));var n=r(8),c=r.n(n),o=r(0),a=r(16),i=r(27),s=r(26),u=r(44),l=r(57),b=function(e,t){var r=e.find((function(e){return e.id===t}));return r?r.quantity:0},p=function(e){var t=Object(a.useDispatch)(i.CART_STORE_KEY).addItemToCart,r=Object(u.a)(),n=r.cartItems,p=r.cartIsLoading,d=Object(l.a)(),f=d.addErrorNotice,m=d.removeNotice,O=Object(o.useState)(!1),g=c()(O,2),j=g[0],h=g[1],v=Object(o.useRef)(b(n,e));return Object(o.useEffect)((function(){var t=b(n,e);t!==v.current&&(v.current=t)}),[n,e]),{cartQuantity:Number.isFinite(v.current)?v.current:0,addingToCart:j,cartIsLoading:p,addToCart:function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return h(!0),t(e,r).then((function(){m("add-to-cart")})).catch((function(e){f(Object(s.decodeEntities)(e.message),{context:"wc/all-products",id:"add-to-cart",isDismissible:!0})})).finally((function(){h(!1)}))}}}},773:function(e,t,r){"use strict";var n=r(0),c=r(30),o=Object(n.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16"},Object(n.createElement)("g",{fill:"none",fillRule:"evenodd"},Object(n.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(n.createElement)("path",{fill:"currentColor",d:"M12 6H4V4.75h8zM12 9H4V7.75h8zM10 12H4v-1.25h6z"})));t.a=o},774:function(e,t){},775:function(e,t){},776:function(e,t){},777:function(e,t){},825:function(e,t,r){"use strict";r.r(t),r.d(t,"blockSettings",(function(){return Dr}));var n=r(5),c=r.n(n),o=r(9),a=r.n(o),i=r(0),s=r(1),u=r(21),l=r(25),b=r(63),p=r(30),d=Object(i.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(i.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(i.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"})),f=r(11),m=r(6),O=r.n(m),g={category:"woocommerce-product-elements",keywords:[Object(s.__)("WooCommerce","woo-gutenberg-products-block")],icon:{src:Object(i.createElement)(b.a,{srcElement:d}),foreground:"#96588a"},supports:{html:!1},parent:Object(f.r)()?null:["@woocommerce/all-products","@woocommerce/single-product"],save:function(e){var t=e.attributes;return Object(i.createElement)("div",{className:O()("is-loading",t.className)})},deprecated:[{save:function(){}}]},j=r(376),h=r(4),v=r(22),w=r(136),y=r(381),E=r(8),_=r.n(E),k=r(153),P=r(14),C=r.n(P),S=(r(771),["className"]),x=function(e){var t=e.className,r=void 0===t?"":t,n=C()(e,S),c=O()("wc-block-text-toolbar-button",r);return Object(i.createElement)(h.Button,a()({className:c},n))},N=r(43),D=(r(770),function(e){return function(t){return function(r){var n=Object(N.useProductDataContext)(),c=r.attributes,o=r.setAttributes,a=c.productId,l=Object(i.useState)(!a),b=_()(l,2),p=b[0],d=b[1];return n.hasContext?Object(i.createElement)(t,r):Object(i.createElement)(i.Fragment,null,p?Object(i.createElement)(h.Placeholder,{icon:e.icon||"",label:e.label||"",className:"wc-atomic-blocks-product"},!!e.description&&Object(i.createElement)("div",null,e.description),Object(i.createElement)("div",{className:"wc-atomic-blocks-product__selection"},Object(i.createElement)(k.a,{selected:a||0,showVariations:!0,onChange:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];o({productId:e[0]?e[0].id:0})}}),Object(i.createElement)(h.Button,{isSecondary:!0,disabled:!a,onClick:function(){d(!1)}},Object(s.__)("Done","woo-gutenberg-products-block")))):Object(i.createElement)(i.Fragment,null,Object(i.createElement)(u.BlockControls,null,Object(i.createElement)(h.ToolbarGroup,null,Object(i.createElement)(x,{onClick:function(){return d(!0)}},Object(s.__)("Switch product…","woo-gutenberg-products-block")))),Object(i.createElement)(t,r)))}}}),B=Object(i.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(i.createElement)("path",{fill:"none",d:"M0 0h24v24H0z"}),Object(i.createElement)("path",{d:"M17 3H7a2 2 0 00-2 2v16l7-3 7 3V5a2 2 0 00-2-2z"})),R=Object(s.__)("Product Title","woo-gutenberg-products-block"),T=Object(i.createElement)(b.a,{srcElement:B}),A=Object(s.__)("Display the title of a product.","woo-gutenberg-products-block"),I=function(e){var t=e.color,r=e.fontSize,n=e.setFontSize,c=e.setColor,o=e.attributes,a=e.setAttributes,l=o.headingLevel,b=o.showProductLink,p=o.align;return Object(i.createElement)(i.Fragment,null,Object(i.createElement)(u.BlockControls,null,Object(i.createElement)(w.a,{isCollapsed:!0,minLevel:1,maxLevel:7,selectedLevel:l,onChange:function(e){return a({headingLevel:e})}}),Object(f.s)()&&Object(i.createElement)(u.AlignmentToolbar,{value:p,onChange:function(e){a({align:e})}})),Object(i.createElement)(u.InspectorControls,null,Object(i.createElement)(h.PanelBody,{title:Object(s.__)("Content","woo-gutenberg-products-block")},Object(i.createElement)(h.ToggleControl,{label:Object(s.__)("Link to Product Page","woo-gutenberg-products-block"),help:Object(s.__)("Links the image to the single product listing.","woo-gutenberg-products-block"),checked:b,onChange:function(){return a({showProductLink:!b})}})),Object(f.s)()&&Object(i.createElement)(i.Fragment,null,Object(i.createElement)(h.PanelBody,{title:Object(s.__)("Text settings","woo-gutenberg-products-block")},Object(i.createElement)(u.FontSizePicker,{value:r.size,onChange:n})),Object(i.createElement)(u.PanelColorSettings,{title:Object(s.__)("Color settings","woo-gutenberg-products-block"),colorSettings:[{value:t.color,onChange:c,label:Object(s.__)("Text color","woo-gutenberg-products-block")}]}))),Object(i.createElement)(h.Disabled,null,Object(i.createElement)(y.a,o)))},L=Object(f.s)()?Object(v.compose)([Object(u.withFontSizes)("fontSize"),Object(u.withColors)("color",{textColor:"color"}),D({icon:T,label:R,description:Object(s.__)("Choose a product to display its title.","woo-gutenberg-products-block")})])(I):I;function z(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function V(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?z(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):z(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var F={title:R,description:A,icon:{src:T,foreground:"#874FB9"},attributes:j.a,edit:L};Object(l.registerBlockType)("woocommerce/product-title",V(V({},g),F));var M=r(485),H=r(305),q=Object(s.__)("Product Price","woo-gutenberg-products-block"),G=Object(i.createElement)(b.a,{srcElement:H.a}),Q=Object(s.__)("Display the price of a product.","woo-gutenberg-products-block"),Y=function(e){var t=e.fontSize,r=e.setFontSize,n=e.color,c=e.setColor,o=e.colorLabel;return Object(i.createElement)(i.Fragment,null,Object(i.createElement)(u.FontSizePicker,{value:t.size,onChange:r}),Object(i.createElement)(h.BaseControl,{label:o},Object(i.createElement)(u.ColorPalette,{value:n.color,onChange:c,label:Object(s.__)("Color")})))},U=function(e){var t=e.fontSize,r=e.saleFontSize,n=e.setFontSize,c=e.setSaleFontSize,o=e.color,a=e.saleColor,l=e.setColor,b=e.setSaleColor,p=e.attributes,d=e.setAttributes,m=p.align;return Object(i.createElement)(i.Fragment,null,Object(f.s)()&&Object(i.createElement)(u.BlockControls,null,Object(i.createElement)(u.AlignmentToolbar,{value:m,onChange:function(e){d({align:e})}})),Object(i.createElement)(u.InspectorControls,null,Object(f.s)()&&Object(i.createElement)(i.Fragment,null,Object(i.createElement)(h.PanelBody,{title:Object(s.__)("Price","woo-gutenberg-products-block")},Object(i.createElement)(Y,{color:o,setColor:l,fontSize:t,setFontSize:n,colorLabel:Object(s.__)("Color","woo-gutenberg-products-block")})),Object(i.createElement)(h.PanelBody,{title:Object(s.__)("Sale price","woo-gutenberg-products-block")},Object(i.createElement)(Y,{color:a,setColor:b,fontSize:r,setFontSize:c,colorLabel:Object(s.__)("Color","woo-gutenberg-products-block")})))),Object(i.createElement)(M.default,p))},W=Object(f.s)()?Object(v.compose)([Object(u.withFontSizes)("fontSize"),Object(u.withFontSizes)("saleFontSize"),Object(u.withFontSizes)("originalFontSize"),Object(u.withColors)("color",{textColor:"color"}),Object(u.withColors)("saleColor",{textColor:"saleColor"}),Object(u.withColors)("originalColor",{textColor:"originalColor"}),D({icon:G,label:q,description:Object(s.__)("Choose a product to display its price.","woo-gutenberg-products-block")})])(U):U;function K(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function $(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?K(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):K(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var J={productId:{type:"number",default:0}};function X(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Z(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?X(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):X(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}Object(f.s)()&&(J=$($({},J),{},{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"}}));var ee={title:q,description:Q,icon:{src:G,foreground:"#874FB9"},attributes:J,edit:W};Object(l.registerBlockType)("woocommerce/product-price",Z(Z({},g),ee));var te=r(377),re=r(86),ne=r(3),ce=r(378),oe=Object(i.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(i.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(i.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"})),ae=Object(s.__)("Product Image","woo-gutenberg-products-block"),ie=Object(i.createElement)(b.a,{srcElement:oe}),se=Object(s.__)("Display the main product image","woo-gutenberg-products-block"),ue=D({icon:ie,label:ae,description:Object(s.__)("Choose a product to display its image.","woo-gutenberg-products-block")})((function(e){var t=e.attributes,r=e.setAttributes,n=t.showProductLink,c=t.imageSizing,o=t.showSaleBadge,a=t.saleBadgeAlign;return Object(i.createElement)(i.Fragment,null,Object(i.createElement)(u.InspectorControls,null,Object(i.createElement)(h.PanelBody,{title:Object(s.__)("Content","woo-gutenberg-products-block")},Object(i.createElement)(h.ToggleControl,{label:Object(s.__)("Link to Product Page","woo-gutenberg-products-block"),help:Object(s.__)("Links the image to the single product listing.","woo-gutenberg-products-block"),checked:n,onChange:function(){return r({showProductLink:!n})}}),Object(i.createElement)(h.ToggleControl,{label:Object(s.__)("Show On-Sale Badge","woo-gutenberg-products-block"),help:Object(s.__)('Overlay a "sale" badge if the product is on-sale.',"woo-gutenberg-products-block"),checked:o,onChange:function(){return r({showSaleBadge:!o})}}),o&&Object(i.createElement)(re.a,{label:Object(s.__)("Sale Badge Alignment","woo-gutenberg-products-block"),value:a,options:[{label:Object(s.__)("Left","woo-gutenberg-products-block"),value:"left"},{label:Object(s.__)("Center","woo-gutenberg-products-block"),value:"center"},{label:Object(s.__)("Right","woo-gutenberg-products-block"),value:"right"}],onChange:function(e){return r({saleBadgeAlign:e})}}),Object(i.createElement)(re.a,{label:Object(s.__)("Image Sizing","woo-gutenberg-products-block"),help:Object(i.createInterpolateElement)(Object(s.__)("Product image cropping can be modified in the <a>Customizer</a>.","woo-gutenberg-products-block"),{a:Object(i.createElement)("a",{href:"".concat(Object(ne.getAdminLink)("customize.php"),"?autofocus[panel]=woocommerce&autofocus[section]=woocommerce_product_images"),target:"_blank",rel:"noopener noreferrer"})}),value:c,options:[{label:Object(s.__)("Full Size","woo-gutenberg-products-block"),value:"full-size"},{label:Object(s.__)("Cropped","woo-gutenberg-products-block"),value:"cropped"}],onChange:function(e){return r({imageSizing:e})}}))),Object(i.createElement)(h.Disabled,null,Object(i.createElement)(ce.a,t)))}));function le(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function be(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?le(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):le(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var pe={title:ae,description:se,icon:{src:ie,foreground:"#874FB9"},attributes:te.a,edit:ue};Object(l.registerBlockType)("woocommerce/product-image",be(be({},g),pe));var de=r(486),fe=r(756),me=Object(s.__)("Product Rating","woo-gutenberg-products-block"),Oe=Object(i.createElement)(b.a,{srcElement:fe.a});function ge(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function je(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ge(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ge(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var he={title:me,description:Object(s.__)("Display the average rating of a product.","woo-gutenberg-products-block"),icon:{src:Oe,foreground:"#874FB9"},attributes:{productId:{type:"number",default:0}},edit:D({icon:Oe,label:me,description:Object(s.__)("Choose a product to display its rating.","woo-gutenberg-products-block")})((function(e){var t=e.attributes;return Object(i.createElement)(de.default,t)}))};Object(l.registerBlockType)("woocommerce/product-rating",je(je({},g),he));var ve=r(487),we=r(489),ye=Object(s.__)("Add to Cart Button","woo-gutenberg-products-block"),Ee=Object(i.createElement)(b.a,{srcElement:we.a});function _e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ke(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?_e(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_e(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Pe={title:ye,description:Object(s.__)("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:Ee,foreground:"#874FB9"},attributes:{productId:{type:"number",default:0}},edit:D({icon:Ee,label:ye,description:Object(s.__)("Choose a product to display its add to cart button.","woo-gutenberg-products-block")})((function(e){var t=e.attributes;return Object(i.createElement)(h.Disabled,null,Object(i.createElement)(ve.default,t))}))};Object(l.registerBlockType)("woocommerce/product-button",ke(ke({},g),Pe));var Ce=r(490),Se=r(773),xe=Object(s.__)("Product Summary","woo-gutenberg-products-block"),Ne=Object(i.createElement)(b.a,{srcElement:Se.a});function De(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Be(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?De(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):De(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Re={title:xe,description:Object(s.__)("Display a short description about a product.","woo-gutenberg-products-block"),icon:{src:Ne,foreground:"#874FB9"},attributes:{productId:{type:"number",default:0}},edit:D({icon:Ne,label:xe,description:Object(s.__)("Choose a product to display its short description.","woo-gutenberg-products-block")})((function(e){var t=e.attributes;return Object(i.createElement)(Ce.default,t)}))};Object(l.registerBlockType)("woocommerce/product-summary",Be(Be({},g),Re));var Te=r(306),Ae=r(748),Ie=Object(s.__)("On-Sale Badge","woo-gutenberg-products-block"),Le=Object(i.createElement)(b.a,{srcElement:Ae.a});function ze(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Ve(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ze(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ze(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Fe={title:Ie,description:Object(s.__)("Displays an on-sale badge if the product is on-sale.","woo-gutenberg-products-block"),icon:{src:Le,foreground:"#874FB9"},supports:{html:!1},attributes:{productId:{type:"number",default:0}},edit:D({icon:Le,label:Ie,description:Object(s.__)("Choose a product to display its sale-badge.","woo-gutenberg-products-block")})((function(e){var t=e.attributes;return Object(i.createElement)(Te.default,t)}))};Object(l.registerBlockType)("woocommerce/product-sale-badge",Ve(Ve({},g),Fe));var Me=r(143),He=r(491),qe=Object(i.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(i.createElement)("path",{d:"M2 6h2v12H2V6m3 0h1v12H5V6m2 0h3v12H7V6m4 0h1v12h-1V6m3 0h2v12h-2V6m3 0h3v12h-3V6m4 0h1v12h-1V6z"})),Ge=Object(s.__)("Product SKU","woo-gutenberg-products-block"),Qe=Object(i.createElement)(b.a,{srcElement:qe});function Ye(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Ue(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ye(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ye(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var We={title:Ge,description:Object(s.__)("Display the SKU of a product.","woo-gutenberg-products-block"),icon:{src:Qe,foreground:"#874FB9"},attributes:{productId:{type:"number",default:0}},edit:D({icon:Qe,label:Ge,description:Object(s.__)("Choose a product to display its SKU.","woo-gutenberg-products-block")})((function(e){var t=e.attributes;return Object(i.createElement)(i.Fragment,null,Object(i.createElement)(Me.a,null),Object(i.createElement)(He.default,t))}))};Object(f.t)("woocommerce/product-sku",Ue(Ue({},g),We));var Ke=r(492),$e=r(741),Je=Object(s.__)("Product Category List","woo-gutenberg-products-block"),Xe=Object(i.createElement)(b.a,{srcElement:$e.a});function Ze(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function et(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ze(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ze(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var tt={title:Je,description:Object(s.__)("Display a list of categories belonging to a product.","woo-gutenberg-products-block"),icon:{src:Xe,foreground:"#874FB9"},attributes:{productId:{type:"number",default:0}},edit:D({icon:Xe,label:Je,description:Object(s.__)("Choose a product to display its categories.","woo-gutenberg-products-block")})((function(e){var t=e.attributes;return Object(i.createElement)(i.Fragment,null,Object(i.createElement)(Me.a,null),Object(i.createElement)(h.Disabled,null,Object(i.createElement)(Ke.default,t)))}))};Object(f.t)("woocommerce/product-category-list",et(et({},g),tt));var rt=r(493),nt=Object(s.__)("Product Tag List","woo-gutenberg-products-block"),ct=Object(i.createElement)(b.a,{srcElement:Ae.a});function ot(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function at(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ot(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ot(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var it={title:nt,description:Object(s.__)("Display a list of tags belonging to a product.","woo-gutenberg-products-block"),icon:{src:ct,foreground:"#874FB9"},attributes:{productId:{type:"number",default:0}},edit:D({icon:ct,label:nt,description:Object(s.__)("Choose a product to display its tags.","woo-gutenberg-products-block")})((function(e){var t=e.attributes;return Object(i.createElement)(i.Fragment,null,Object(i.createElement)(Me.a,null),Object(i.createElement)(h.Disabled,null,Object(i.createElement)(rt.default,t)))}))};Object(f.t)("woocommerce/product-tag-list",at(at({},g),it));var st=r(494),ut=Object(i.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(i.createElement)("g",{fillRule:"evenodd"},Object(i.createElement)("path",{d:"M0 0h24v24H0z",fill:"none"}),Object(i.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"}))),lt=Object(s.__)("Product Stock Indicator","woo-gutenberg-products-block"),bt=Object(i.createElement)(b.a,{srcElement:ut});function pt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function dt(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?pt(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):pt(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var ft={title:lt,description:Object(s.__)("Display product stock status.","woo-gutenberg-products-block"),icon:{src:bt,foreground:"#874FB9"},attributes:{productId:{type:"number",default:0}},edit:D({icon:bt,label:lt,description:Object(s.__)("Choose a product to display its stock.","woo-gutenberg-products-block")})((function(e){var t=e.attributes;return Object(i.createElement)(i.Fragment,null,Object(i.createElement)(Me.a,null),Object(i.createElement)(st.default,t))}))};Object(f.t)("woocommerce/product-stock-indicator",dt(dt({},g),ft));var mt=r(858),Ot=(r(375),r(380)),gt=Object(s.__)("Add to Cart","woo-gutenberg-products-block"),jt=Object(i.createElement)(b.a,{srcElement:we.a});function ht(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function vt(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ht(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ht(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var wt={title:gt,description:Object(s.__)("Displays an add to cart button. Optionally displays other add to cart form elements.","woo-gutenberg-products-block"),icon:{src:jt,foreground:"#874FB9"},edit:D({icon:jt,label:gt,description:Object(s.__)("Choose a product to display its add to cart form.","woo-gutenberg-products-block")})((function(e){var t=e.attributes,r=e.setAttributes,n=Object(N.useProductDataContext)().product,c=t.className,o=t.showFormElements;return Object(i.createElement)("div",{className:O()(c,"wc-block-components-product-add-to-cart")},Object(i.createElement)(Me.a,{productId:n.id}),Object(i.createElement)(u.InspectorControls,null,Object(i.createElement)(h.PanelBody,{title:Object(s.__)("Layout","woo-gutenberg-products-block")},Object(mt.b)(n)?Object(i.createElement)(h.ToggleControl,{label:Object(s.__)("Display form elements","woo-gutenberg-products-block"),help:Object(s.__)("Depending on product type, allow customers to select a quantity, variations etc.","woo-gutenberg-products-block"),checked:o,onChange:function(){return r({showFormElements:!o})}}):Object(i.createElement)(h.Notice,{className:"wc-block-components-product-add-to-cart-notice",isDismissible:!1,status:"info"},Object(s.__)("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(i.createElement)(h.Disabled,null,Object(i.createElement)(Ot.a,t)))})),attributes:r(379).a};Object(f.t)("woocommerce/product-add-to-cart",vt(vt({},g),wt));var yt=r(17),Et=r.n(yt),_t=r(13),kt=r.n(_t),Pt=r(19),Ct=r.n(Pt),St=r(20),xt=r.n(St),Nt=r(10),Dt=r.n(Nt),Bt=r(16),Rt=(r(2),r(91)),Tt=r(853),At=r(757),It=function(e,t){var r=t.className,n=t.contentVisibility;return O()(e,r,{"has-image":n&&n.image,"has-title":n&&n.title,"has-rating":n&&n.rating,"has-price":n&&n.price,"has-button":n&&n.button})},Lt=r(163),zt=function(e,t){return Object(i.createElement)(h.Placeholder,{className:"wc-block-products",icon:t,label:e},Object(i.createElement)("p",null,Object(s.__)("You haven't published any products to list here yet.","woo-gutenberg-products-block")),Object(i.createElement)(h.Button,{className:"wc-block-products__add-product-button",isSecondary:!0,href:ne.ADMIN_URL+"post-new.php?post_type=product"},Object(s.__)("Add new product","woo-gutenberg-products-block")+" ",Object(i.createElement)(b.a,{srcElement:Lt.a})),Object(i.createElement)(h.Button,{className:"wc-block-products__read_more_button",isTertiary:!0,href:"https://docs.woocommerce.com/document/managing-products/"},Object(s.__)("Learn more","woo-gutenberg-products-block")))},Vt=function(e,t){return Object(i.createElement)(h.Placeholder,{className:"wc-block-products",icon:t,label:e},Object(s.__)("The content for this block is hidden due to block settings.","woo-gutenberg-products-block"))};function Ft(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Mt(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ft(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ft(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Ht=[["woocommerce/product-image"],["woocommerce/product-title"],["woocommerce/product-price"],["woocommerce/product-rating"],["woocommerce/product-button"]],qt=function e(t){return t&&0!==t.length?t.map((function(t){return[t.name,Mt(Mt({},t.attributes),{},{product:void 0,children:t.innerBlocks.length>0?e(t.innerBlocks):[]})]})):[]};function Gt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Qt(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Gt(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Gt(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Yt=function(e,t){var r=e.contentVisibility;return Object(i.createElement)(h.ToggleControl,{label:Object(s.__)("Show Sorting Dropdown","woo-gutenberg-products-block"),checked:r.orderBy,onChange:function(){return t({contentVisibility:Qt(Qt({},r),{},{orderBy:!r.orderBy})})}})},Ut=function(e,t){return Object(i.createElement)(h.SelectControl,{label:Object(s.__)("Order Products By","woo-gutenberg-products-block"),value:e.orderby,options:[{label:Object(s.__)("Default sorting (menu order)","woo-gutenberg-products-block"),value:"menu_order"},{label:Object(s.__)("Popularity","woo-gutenberg-products-block"),value:"popularity"},{label:Object(s.__)("Average rating","woo-gutenberg-products-block"),value:"rating"},{label:Object(s.__)("Latest","woo-gutenberg-products-block"),value:"date"},{label:Object(s.__)("Price: low to high","woo-gutenberg-products-block"),value:"price"},{label:Object(s.__)("Price: high to low","woo-gutenberg-products-block"),value:"price-desc"}],onChange:function(e){return t({orderby:e})}})},Wt=r(18),Kt=r.n(Wt),$t=r(12),Jt=r(7),Xt=r(40),Zt=(r(777),function(e){var t=e.currentPage,r=e.displayFirstAndLastPages,n=e.displayNextAndPreviousArrows,c=e.pagesToDisplay,o=e.onPageChange,a=e.totalPages,u=function(e,t,r){if(r<=2)return{minIndex:null,maxIndex:null};var n=e-1,c=Math.max(Math.floor(t-n/2),2),o=Math.min(Math.ceil(t+(n-(t-c))),r-1);return{minIndex:Math.max(Math.floor(t-(n-(o-t))),2),maxIndex:o}}(c,t,a),l=u.minIndex,b=u.maxIndex,p=r&&Boolean(1!==l),d=r&&Boolean(b!==a),f=r&&Boolean(l>3),m=r&&Boolean(b<a-2);p&&3===l&&(l-=1),d&&b===a-2&&(b+=1);var g=[];if(l&&b)for(var j=l;j<=b;j++)g.push(j);return Object(i.createElement)("div",{className:"wc-block-pagination wc-block-components-pagination"},Object(i.createElement)(Xt.a,{screenReaderLabel:Object(s.__)("Navigate to another page","woo-gutenberg-products-block")}),n&&Object(i.createElement)("button",{className:"wc-block-pagination-page wc-block-components-pagination__page wc-block-components-pagination-page--arrow",onClick:function(){return o(t-1)},title:Object(s.__)("Previous page","woo-gutenberg-products-block"),disabled:t<=1},Object(i.createElement)(Xt.a,{label:"←",screenReaderLabel:Object(s.__)("Previous page","woo-gutenberg-products-block")})),p&&Object(i.createElement)("button",{className:O()("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:function(){return o(1)},disabled:1===t},Object(i.createElement)(Xt.a,{label:1,screenReaderLabel:Object(s.sprintf)(
|
| 22 |
/* translators: %d is the page number (1, 2, 3...). */
|
| 23 |
-
Object(s.__)("Page %d","woo-gutenberg-products-block"),1)})),f&&Object(i.createElement)("span",{className:"wc-block-pagination-ellipsis wc-block-components-pagination__ellipsis","aria-hidden":"true"},Object(s.__)("…","woo-gutenberg-products-block")),g.map((function(e){return Object(i.createElement)("button",{key:e,className:O()("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:function(){return o(e)},disabled:t===e},Object(i.createElement)(
|
| 24 |
/* translators: %d is the page number (1, 2, 3...). */
|
| 25 |
-
Object(s.__)("Page %d","woo-gutenberg-products-block"),e)}))})),m&&Object(i.createElement)("span",{className:"wc-block-pagination-ellipsis wc-block-components-pagination__ellipsis","aria-hidden":"true"},Object(s.__)("…","woo-gutenberg-products-block")),d&&Object(i.createElement)("button",{className:O()("wc-block-pagination-page","wc-block-components-pagination__page",{"wc-block-pagination-page--active":t===a,"wc-block-components-pagination__page--active":t===a}),onClick:function(){return o(a)},disabled:t===a},Object(i.createElement)(
|
| 26 |
/* translators: %d is the page number (1, 2, 3...). */
|
| 27 |
-
Object(s.__)("Page %d","woo-gutenberg-products-block"),a)})),n&&Object(i.createElement)("button",{className:"wc-block-pagination-page wc-block-components-pagination__page wc-block-components-pagination-page--arrow",onClick:function(){return o(t+1)},title:Object(s.__)("Next page","woo-gutenberg-products-block"),disabled:t>=a},Object(i.createElement)(
|
| 28 |
/* translators: %s is an integer higher than 0 (1, 2, 3...) */
|
| 29 |
-
Object(s._n)("%d product found","%d products found",e,"woo-gutenberg-products-block"),e)))}(T))}),[null==M?void 0:M.totalQuery,T,c,V]);var H,q,G,Q,Y,U=r.contentVisibility,W=r.columns*r.rows,K=!Number.isFinite(T)&&Number.isFinite(null==M?void 0:M.totalProducts)&&Object(Jt.isEqual)(V,null==M?void 0:M.totalQuery)?Math.ceil(M.totalProducts/W):Math.ceil(T/W),$=R.length?R:Array.from({length:W}),J=0!==R.length||A,X=p.length>0||g.length>0||Number.isFinite(w)||Number.isFinite(P);return Object(i.createElement)("div",{className:(H=r.columns,q=r.rows,G=r.alignButtons,Q=r.align,Y=void 0!==Q?"align"+Q:"",O()(L,Y,"has-"+H+"-columns",{"has-multiple-rows":q>1,"has-aligned-buttons":G}))},U.orderBy&&J&&Object(i.createElement)(Or,{onChange:o,value:a}),!J&&X&&Object(i.createElement)(fr,{resetCallback:function(){d([]),j([]),y(null),S(null)}}),!J&&!X&&Object(i.createElement)(pr,null),J&&Object(i.createElement)("ul",{className:"".concat(L,"__products")},$.map((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return Object(i.createElement)(gr,{key:e.id||t,attributes:r,product:e})}))),K>1&&Object(i.createElement)(er,{currentPage:n,onPageChange:function(e){u({focusableSelector:"a, button"}),c(e)},totalPages:K}))})),Er=function(e){var t=e.attributes,r=Object(i.useState)(1),n=_()(r,2),c=n[0],o=n[1],a=Object(i.useState)(t.orderby),s=_()(a,2),u=s[0],l=s[1];return Object(i.useEffect)((function(){l(t.orderby)}),[t.orderby]),Object(i.createElement)(yr,{attributes:t,currentPage:c,onPageChange:function(e){o(e)},onSortChange:function(e){var t=e.target.value;l(t),o(1)},sortValue:u})},_r=r(186);var kr=function(e){Ct()(c,e);var t,r,n=(t=c,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=Dt()(t);if(r){var c=Dt()(this).constructor;e=Reflect.construct(n,arguments,c)}else e=n.apply(this,arguments);return xt()(this,e)});function c(){return Et()(this,c),n.apply(this,arguments)}return Kt()(c,[{key:"render",value:function(){var e=this.props,t=e.attributes,r=e.urlParameterSuffix;return t.isPreview?_r.a:Object(i.createElement)(N.InnerBlockLayoutContextProvider,{parentName:"woocommerce/all-products",parentClassName:"wc-block-grid"},Object(i.createElement)(Er,{attributes:t,urlParameterSuffix:r}))}}]),c}($t.Component);r(774);var Pr=function(e){Ct()(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=Dt()(t);if(r){var c=Dt()(this).constructor;e=Reflect.construct(n,arguments,c)}else e=n.apply(this,arguments);return xt()(this,e)});function o(){var e;Et()(this,o);for(var t=arguments.length,r=new Array(t),a=0;a<t;a++)r[a]=arguments[a];return e=n.call.apply(n,[this].concat(r)),c()(kt()(e),"state",{isEditing:!1,innerBlocks:[]}),c()(kt()(e),"blockMap",Object(Tt.a)("woocommerce/all-products")),c()(kt()(e),"componentDidMount",(function(){var t=e.props.block;e.setState({innerBlocks:t.innerBlocks})})),c()(kt()(e),"getTitle",(function(){return Object(s.__)("All Products","woo-gutenberg-products-block")})),c()(kt()(e),"getIcon",(function(){return Object(i.createElement)(b.a,{srcElement:d})})),c()(kt()(e),"togglePreview",(function(){var t=e.props.debouncedSpeak;e.setState({isEditing:!e.state.isEditing}),e.state.isEditing||t(Object(s.__)("Showing All Products block preview.","woo-gutenberg-products-block"))})),c()(kt()(e),"getInspectorControls",(function(){var t=e.props,r=t.attributes,n=t.setAttributes,c=r.columns,o=r.rows,a=r.alignButtons;return Object(i.createElement)(u.InspectorControls,{key:"inspector"},Object(i.createElement)(h.PanelBody,{title:Object(s.__)("Layout Settings","woo-gutenberg-products-block"),initialOpen:!0},Object(i.createElement)(Rt.a,{columns:c,rows:o,alignButtons:a,setAttributes:n,minColumns:Object(ne.getSetting)("min_columns",1),maxColumns:Object(ne.getSetting)("max_columns",6),minRows:Object(ne.getSetting)("min_rows",1),maxRows:Object(ne.getSetting)("max_rows",6)})),Object(i.createElement)(h.PanelBody,{title:Object(s.__)("Content Settings","woo-gutenberg-products-block")},Yt(r,n),Ut(r,n)))})),c()(kt()(e),"getBlockControls",(function(){var t=e.state.isEditing;return Object(i.createElement)(u.BlockControls,null,Object(i.createElement)(h.ToolbarGroup,{controls:[{icon:"edit",title:Object(s.__)("Edit","woo-gutenberg-products-block"),onClick:function(){return e.togglePreview()},isActive:t}]}))})),c()(kt()(e),"renderEditMode",(function(){var t={template:e.props.attributes.layoutConfig,templateLock:!1,allowedBlocks:Object.keys(e.blockMap)};return 0!==e.props.attributes.layoutConfig.length&&(t.renderAppender=!1),Object(i.createElement)(h.Placeholder,{icon:e.getIcon(),label:e.getTitle()},Object(s.__)("Display all products from your store as a grid.","woo-gutenberg-products-block"),Object(i.createElement)("div",{className:"wc-block-all-products-grid-item-template"},Object(i.createElement)(h.Tip,null,Object(s.__)("Edit the blocks inside the preview below to change the content displayed for each product within the product grid.","woo-gutenberg-products-block")),Object(i.createElement)(N.InnerBlockLayoutContextProvider,{parentName:"woocommerce/all-products",parentClassName:"wc-block-grid"},Object(i.createElement)("div",{className:"wc-block-grid wc-block-layout has-1-columns"},Object(i.createElement)("ul",{className:"wc-block-grid__products"},Object(i.createElement)("li",{className:"wc-block-grid__product"},Object(i.createElement)(N.ProductDataContextProvider,{product:At.a[0]},Object(i.createElement)(u.InnerBlocks,t)))))),Object(i.createElement)("div",{className:"wc-block-all-products__actions"},Object(i.createElement)(h.Button,{className:"wc-block-all-products__done-button",isPrimary:!0,onClick:function(){var t=e.props,r=t.block;(0,t.setAttributes)({layoutConfig:qt(r.innerBlocks)}),e.setState({innerBlocks:r.innerBlocks}),e.togglePreview()}},Object(s.__)("Done","woo-gutenberg-products-block")),Object(i.createElement)(h.Button,{className:"wc-block-all-products__cancel-button",isTertiary:!0,onClick:function(){var t=e.props,r=t.block,n=t.replaceInnerBlocks,c=e.state.innerBlocks;n(r.clientId,c,!1),e.togglePreview()}},Object(s.__)("Cancel","woo-gutenberg-products-block")),Object(i.createElement)(h.Button,{className:"wc-block-all-products__reset-button",icon:Object(i.createElement)(b.a,{srcElement:d}),label:Object(s.__)("Reset layout to default","woo-gutenberg-products-block"),onClick:function(){var t=e.props,r=t.block,n=t.replaceInnerBlocks,c=[];Ht.map((function(e){var t=_()(e,2),r=t[0],n=t[1];return c.push(Object(l.createBlock)(r,n)),!0})),n(r.clientId,c,!1),e.setState({innerBlocks:r.innerBlocks})}},Object(s.__)("Reset Layout","woo-gutenberg-products-block")))))})),c()(kt()(e),"renderViewMode",(function(){var t=e.props.attributes,r=t.layoutConfig,n=r&&0!==r.length,c=e.getTitle(),o=e.getIcon();return n?Object(i.createElement)(h.Disabled,null,Object(i.createElement)(kr,{attributes:t})):Vt(c,o)})),c()(kt()(e),"render",(function(){var t=e.props.attributes,r=e.state.isEditing,n=e.getTitle(),c=e.getIcon();return 0===f.q.productCount?zt(n,c):Object(i.createElement)("div",{className:It("wc-block-all-products",t)},e.getBlockControls(),e.getInspectorControls(),r?e.renderEditMode():e.renderViewMode())})),e}return o}(i.Component),Cr=Object(v.compose)(h.withSpokenMessages,Object(Bt.withSelect)((function(e,t){var r=t.clientId;return{block:(0,e("core/block-editor").getBlock)(r)}})),Object(Bt.withDispatch)((function(e){return{replaceInnerBlocks:e("core/block-editor").replaceInnerBlocks}})))(Pr),Sr={columns:Object(ne.getSetting)("default_columns",3),rows:Object(ne.getSetting)("default_rows",3),alignButtons:!1,contentVisibility:{orderBy:!0},orderby:"date",layoutConfig:Ht,isPreview:!1};function xr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Nr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?xr(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):xr(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Dr={title:Object(s.__)("All Products","woo-gutenberg-products-block"),icon:{src:Object(i.createElement)(b.a,{srcElement:d}),foreground:"#96588a"},category:"woocommerce",keywords:[Object(s.__)("WooCommerce","woo-gutenberg-products-block")],description:Object(s.__)("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:Sr,edit:function(e){return Object(i.createElement)(Cr,e)},save:function(e){var t=e.attributes,r={};Object.keys(t).sort().forEach((function(e){r[e]=t[e]}));var n={"data-attributes":JSON.stringify(r)};return Object(i.createElement)("div",a()({className:It("wc-block-all-products",t)},n),Object(i.createElement)(u.InnerBlocks.Content,null))}};Object(l.registerBlockType)("woocommerce/all-products",Nr(Nr({},Dr),{},{deprecated:[{attributes:Object.assign({},Dr.attributes,{rows:{type:"number",default:1}}),save:function(e){var t=e.attributes,r={"data-attributes":JSON.stringify(t)};return Object(i.createElement)("div",a()({className:It("wc-block-all-products",t)},r),Object(i.createElement)(u.InnerBlocks.Content,null))}}]}))},84:function(e,t){e.exports=window.wc.wcBlocksSharedHocs},85:function(e,t){e.exports=window.ReactDOM},853:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(56),c=r(0),o=r(11);r.p=o.o,Object(n.registerBlockComponent)({blockName:"woocommerce/product-price",component:Object(c.lazy)((function(){return Promise.all([r.e(0),r.e(12)]).then(r.bind(null,485))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-image",component:Object(c.lazy)((function(){return Promise.all([r.e(1),r.e(2),r.e(4),r.e(11)]).then(r.bind(null,878))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-title",component:Object(c.lazy)((function(){return Promise.all([r.e(1),r.e(2),r.e(18)]).then(r.bind(null,879))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-rating",component:Object(c.lazy)((function(){return r.e(13).then(r.bind(null,486))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-button",component:Object(c.lazy)((function(){return Promise.all([r.e(0),r.e(1),r.e(3),r.e(9)]).then(r.bind(null,487))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-summary",component:Object(c.lazy)((function(){return r.e(16).then(r.bind(null,490))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-sale-badge",component:Object(c.lazy)((function(){return r.e(4).then(r.bind(null,306))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-sku",component:Object(c.lazy)((function(){return r.e(14).then(r.bind(null,491))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-category-list",component:Object(c.lazy)((function(){return r.e(10).then(r.bind(null,492))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-tag-list",component:Object(c.lazy)((function(){return r.e(17).then(r.bind(null,493))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-stock-indicator",component:Object(c.lazy)((function(){return r.e(15).then(r.bind(null,494))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-add-to-cart",component:Object(c.lazy)((function(){return Promise.all([r.e(0),r.e(1),r.e(2),r.e(3),r.e(8)]).then(r.bind(null,880))}))});var a=function(e){return Object(n.getRegisteredBlockComponents)(e)}},858:function(e,t,r){"use strict";r.d(t,"a",(function(){return n})),r.d(t,"b",(function(){return c}));var n=function(e){return e.is_purchasable||!1},c=function(e){return["simple","variable"].includes(e.type||"simple")}},86:function(e,t,r){"use strict";var n=r(9),c=r.n(n),o=r(17),a=r.n(o),i=r(18),s=r.n(i),u=r(13),l=r.n(u),b=r(19),p=r.n(b),d=r(20),f=r.n(d),m=r(10),O=r.n(m),g=r(0),j=r(7),h=r(6),v=r.n(h),w=r(4),y=r(22);r(124);var E=function(e){p()(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=O()(t);if(r){var c=O()(this).constructor;e=Reflect.construct(n,arguments,c)}else e=n.apply(this,arguments);return f()(this,e)});function o(){var e;return a()(this,o),(e=n.apply(this,arguments)).onClick=e.onClick.bind(l()(e)),e}return s()(o,[{key:"onClick",value:function(e){this.props.onChange&&this.props.onChange(e.target.value)}},{key:"render",value:function(){var e,t=this,r=this.props,n=r.label,o=r.checked,a=r.instanceId,i=r.className,s=r.help,u=r.options,l=r.value,b="inspector-toggle-button-control-".concat(a);return s&&(e=Object(j.isFunction)(s)?s(o):s),Object(g.createElement)(w.BaseControl,{id:b,help:e,className:v()("components-toggle-button-control",i)},Object(g.createElement)("label",{id:b+"__label",htmlFor:b,className:"components-toggle-button-control__label"},n),Object(g.createElement)(w.ButtonGroup,{"aria-labelledby":b+"__label"},u.map((function(e,r){var o={};return l===e.value?(o.isPrimary=!0,o["aria-pressed"]=!0):(o.isSecondary=!0,o["aria-pressed"]=!1),Object(g.createElement)(w.Button,c()({key:"".concat(e.label,"-").concat(e.value,"-").concat(r),value:e.value,onClick:t.onClick,"aria-label":n+": "+e.label},o),e.label)}))))}}]),o}(g.Component);t.a=Object(y.withInstanceId)(E)},87:function(e,t){e.exports=window.wp.viewport},88:function(e,t,r){"use strict";var n=r(9),c=r.n(n),o=r(14),a=r.n(o),i=r(0),s=r(181),u=r(6),l=r.n(u),b=r(114),p=(r(207),["className","showSpinner","children"]);t.a=function(e){var t=e.className,r=e.showSpinner,n=void 0!==r&&r,o=e.children,u=a()(e,p),d=l()("wc-block-components-button",t,{"wc-block-components-button--loading":n});return Object(i.createElement)(s.a,c()({className:d},u),n&&Object(i.createElement)(b.a,null),Object(i.createElement)("span",{className:"wc-block-components-button__text"},o))}},89:function(e,t){e.exports=window.wp.autop},91:function(e,t,r){"use strict";var n=r(0),c=r(1),o=r(7),a=(r(2),r(4));t.a=function(e){var t=e.columns,r=e.rows,i=e.setAttributes,s=e.alignButtons,u=e.minColumns,l=void 0===u?1:u,b=e.maxColumns,p=void 0===b?6:b,d=e.minRows,f=void 0===d?1:d,m=e.maxRows,O=void 0===m?6:m;return Object(n.createElement)(n.Fragment,null,Object(n.createElement)(a.RangeControl,{label:Object(c.__)("Columns","woo-gutenberg-products-block"),value:t,onChange:function(e){var t=Object(o.clamp)(e,l,p);i({columns:Number.isNaN(t)?"":t})},min:l,max:p}),Object(n.createElement)(a.RangeControl,{label:Object(c.__)("Rows","woo-gutenberg-products-block"),value:r,onChange:function(e){var t=Object(o.clamp)(e,f,O);i({rows:Number.isNaN(t)?"":t})},min:f,max:O}),Object(n.createElement)(a.ToggleControl,{label:Object(c.__)("Align Last Block","woo-gutenberg-products-block"),help:s?Object(c.__)("The last inner block will be aligned vertically.","woo-gutenberg-products-block"):Object(c.__)("The last inner block will follow other content.","woo-gutenberg-products-block"),checked:s,onChange:function(){return i({alignButtons:!s})}}))}},95:function(e,t){e.exports=window.wp.date}});
|
| 1 |
+
this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["all-products"]=function(e){function t(t){for(var n,a,i=t[0],s=t[1],l=t[2],b=0,p=[];b<i.length;b++)a=i[b],Object.prototype.hasOwnProperty.call(c,a)&&c[a]&&p.push(c[a][0]),c[a]=0;for(n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n]);for(u&&u(t);p.length;)p.shift()();return o.push.apply(o,l||[]),r()}function r(){for(var e,t=0;t<o.length;t++){for(var r=o[t],n=!0,i=1;i<r.length;i++){var s=r[i];0!==c[s]&&(n=!1)}n&&(o.splice(t--,1),e=a(a.s=r[0]))}return e}var n={},c={6:0,1:0,3:0,4:0,9:0,10:0,12:0,13:0,14:0,15:0,16:0,17:0},o=[];function a(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,a),r.l=!0,r.exports}a.e=function(e){var t=[],r=c[e];if(0!==r)if(r)t.push(r[2]);else{var n=new Promise((function(t,n){r=c[e]=[t,n]}));t.push(r[2]=n);var o,i=document.createElement("script");i.charset="utf-8",i.timeout=120,a.nc&&i.setAttribute("nonce",a.nc),i.src=function(e){return a.p+""+({1:"atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/image---a7e2bb9b",2:"atomic-block-components/add-to-cart--atomic-block-components/image--atomic-block-components/title",3:"atomic-block-components/add-to-cart--atomic-block-components/button",4:"atomic-block-components/sale-badge",8:"atomic-block-components/add-to-cart",9:"atomic-block-components/button",10:"atomic-block-components/category-list",11:"atomic-block-components/image",12:"atomic-block-components/price",13:"atomic-block-components/rating",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"}[e]||e)+".js"}(e);var s=new Error;o=function(t){i.onerror=i.onload=null,clearTimeout(l);var r=c[e];if(0!==r){if(r){var n=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;s.message="Loading chunk "+e+" failed.\n("+n+": "+o+")",s.name="ChunkLoadError",s.type=n,s.request=o,r[1](s)}c[e]=void 0}};var l=setTimeout((function(){o({type:"timeout",target:i})}),12e4);i.onerror=i.onload=o,document.head.appendChild(i)}return Promise.all(t)},a.m=e,a.c=n,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 n in e)a.d(r,n,function(t){return e[t]}.bind(null,n));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="",a.oe=function(e){throw console.error(e),e};var i=window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[],s=i.push.bind(i);i.push=t,i=i.slice();for(var l=0;l<i.length;l++)t(i[l]);var u=s;return o.push([785,0]),r()}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},108:function(e,t,r){"use strict";r.d(t,"a",(function(){return d})),r.d(t,"b",(function(){return f})),r.d(t,"c",(function(){return m}));var n=r(8),c=r.n(n),o=r(24),a=r(14),i=r(0),s=r(34),l=r.n(s),u=r(62),b=r(136),p=r(78),d=function(e){var t=Object(p.a)();e=e||t;var r=Object(a.useSelect)((function(t){return t(o.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0)}),[e]),n=Object(a.useDispatch)(o.QUERY_STATE_STORE_KEY).setValueForQueryContext;return[r,Object(i.useCallback)((function(t){n(e,t)}),[e,n])]},f=function(e,t,r){var n=Object(p.a)();r=r||n;var c=Object(a.useSelect)((function(n){return n(o.QUERY_STATE_STORE_KEY).getValueForQueryKey(r,e,t)}),[r,e]),s=Object(a.useDispatch)(o.QUERY_STATE_STORE_KEY).setQueryValue;return[c,Object(i.useCallback)((function(t){s(r,e,t)}),[r,e,s])]},m=function(e,t){var r=Object(p.a)(),n=d(t=t||r),o=c()(n,2),a=o[0],s=o[1],f=Object(u.a)(a),m=Object(u.a)(e),O=Object(b.a)(m),g=Object(i.useRef)(!1);return Object(i.useEffect)((function(){l()(O,m)||(s(Object.assign({},f,m)),g.current=!0)}),[f,m,O,s]),g.current?[a,s]:[e,s]}},11:function(e,t){e.exports=window.React},113:function(e,t,r){"use strict";var n=r(5),c=r.n(n),o=r(8),a=r.n(o),i=r(3),s=r(1),l=r(72);function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var p=Object(i.getSetting)("countryLocale",{}),d=function(e){var 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(s.sprintf)(
|
| 2 |
/* translators: %s Field label. */
|
| 3 |
+
Object(s.__)("%s (optional)","woo-gutenberg-products-block"),e.label)),e.priority&&(Object(l.a)(e.priority)&&(t.index=e.priority),Object(l.c)(e.priority)&&(t.index=parseInt(e.priority,10))),e.hidden&&(t.required=!1),t},f=Object.entries(p).map((function(e){var t=a()(e,2),r=t[0],n=t[1];return[r,Object.entries(n).map((function(e){var t=a()(e,2),r=t[0],n=t[1];return[r,d(n)]})).reduce((function(e,t){var r=a()(t,2),n=r[0],c=r[1];return e[n]=c,e}),{})]})).reduce((function(e,t){var r=a()(t,2),n=r[0],c=r[1];return e[n]=c,e}),{});t.a=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=r&&void 0!==f[r]?f[r]:{};return e.map((function(e){var r=i.defaultAddressFields[e]||{},c=n[e]||{},o=t[e]||{};return b(b(b({key:e},r),c),o)})).sort((function(e,t){return e.index-t.index}))}},114:function(e,t,r){"use strict";var n=r(0);r(209),t.a=function(){return Object(n.createElement)("span",{className:"wc-block-components-spinner","aria-hidden":"true"})}},119:function(e,t){e.exports=window.wp.wordcount},12:function(e,t){e.exports=window.wp.blockEditor},121:function(e,t){},122:function(e,t){e.exports=window.wp.coreData},123:function(e,t){},124:function(e,t,r){"use strict";var n=r(5),c=r.n(n),o=r(0),a=r(1),i=r(53),s=r(6),l=r.n(s),u=(r(2),r(47)),b=(r(206),function(e){var t=e.currency,r=e.maxPrice,n=e.minPrice,c=e.priceClassName,s=e.priceStyle;return Object(o.createElement)(o.Fragment,null,Object(o.createElement)("span",{className:"screen-reader-text"},Object(a.sprintf)(
|
| 4 |
/* translators: %1$s min price, %2$s max price */
|
| 5 |
+
Object(a.__)("Price between %1$s and %2$s","woo-gutenberg-products-block"),Object(u.formatPrice)(n),Object(u.formatPrice)(r))),Object(o.createElement)("span",{"aria-hidden":!0},Object(o.createElement)(i.a,{className:l()("wc-block-components-product-price__value",c),currency:t,value:n,style:s})," — ",Object(o.createElement)(i.a,{className:l()("wc-block-components-product-price__value",c),currency:t,value:r,style:s})))}),p=function(e){var t=e.currency,r=e.regularPriceClassName,n=e.regularPriceStyle,c=e.regularPrice,s=e.priceClassName,u=e.priceStyle,b=e.price;return Object(o.createElement)(o.Fragment,null,Object(o.createElement)("span",{className:"screen-reader-text"},Object(a.__)("Previous price:","woo-gutenberg-products-block")),Object(o.createElement)(i.a,{currency:t,renderText:function(e){return Object(o.createElement)("del",{className:l()("wc-block-components-product-price__regular",r),style:n},e)},value:c}),Object(o.createElement)("span",{className:"screen-reader-text"},Object(a.__)("Discounted price:","woo-gutenberg-products-block")),Object(o.createElement)(i.a,{currency:t,renderText:function(e){return Object(o.createElement)("ins",{className:l()("wc-block-components-product-price__value","is-discounted",s),style:u},e)},value:b}))};t.a=function(e){var t=e.align,r=e.className,n=e.currency,a=e.format,s=void 0===a?"<price/>":a,u=e.maxPrice,d=void 0===u?null:u,f=e.minPrice,m=void 0===f?null:f,O=e.price,g=void 0===O?null:O,j=e.priceClassName,h=e.priceStyle,v=e.regularPrice,w=e.regularPriceClassName,y=e.regularPriceStyle,E=l()(r,"price","wc-block-components-product-price",c()({},"wc-block-components-product-price--align-".concat(t),t));s.includes("<price/>")||(s="<price/>",console.error("Price formats need to include the `<price/>` tag."));var _=v&&g!==v,k=Object(o.createElement)("span",{className:l()("wc-block-components-product-price__value",j)});return _?k=Object(o.createElement)(p,{currency:n,price:g,priceClassName:j,priceStyle:h,regularPrice:v,regularPriceClassName:w,regularPriceStyle:y}):null!==m&&null!==d?k=Object(o.createElement)(b,{currency:n,maxPrice:d,minPrice:m,priceClassName:j,priceStyle:h}):null!==g&&(k=Object(o.createElement)(i.a,{className:l()("wc-block-components-product-price__value",j),currency:n,value:g,style:h})),Object(o.createElement)("span",{className:E},Object(o.createInterpolateElement)(s,{price:k}))}},126:function(e,t,r){"use strict";r.d(t,"a",(function(){return l})),r.d(t,"b",(function(){return b}));var n,c=r(5),o=r.n(c),a=r(7);function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}!function(e){e.ADD_EVENT_CALLBACK="add_event_callback",e.REMOVE_EVENT_CALLBACK="remove_event_callback"}(n||(n={}));var l={addEventCallback:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10;return{id:Object(a.uniqueId)(),type:n.ADD_EVENT_CALLBACK,eventType:e,callback:t,priority:r}},removeEventCallback:function(e,t){return{id:t,type:n.REMOVE_EVENT_CALLBACK,eventType:e}}},u={},b=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:u,t=arguments.length>1?arguments[1]:void 0,r=t.type,c=t.eventType,a=t.id,i=t.callback,l=t.priority,b=e.hasOwnProperty(c)?new Map(e[c]):new Map;switch(r){case n.ADD_EVENT_CALLBACK:return b.set(a,{priority:l,callback:i}),s(s({},e),{},o()({},c,b));case n.REMOVE_EVENT_CALLBACK:return b.delete(a),s(s({},e),{},o()({},c,b))}}},127:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(8),c=r.n(n),o=r(0),a=function(){var e=Object(o.useState)(),t=c()(e,2)[1];return Object(o.useCallback)((function(e){t((function(){throw e}))}),[])}},131:function(e,t,r){"use strict";var n=r(9),c=r.n(n),o=r(16),a=r.n(o),i=r(0),s=r(49),l=r(4),u=r(6),b=r.n(u),p=["className","item","isSelected","isLoading","onSelect","disabled"];t.a=function(e){var t=e.className,r=e.item,n=e.isSelected,o=e.isLoading,u=e.onSelect,d=e.disabled,f=a()(e,p);return Object(i.createElement)(i.Fragment,null,Object(i.createElement)(s.c,c()({},f,{key:r.id,className:t,isSelected:n,item:r,onSelect:u,isSingle:!0,disabled:d})),n&&o&&Object(i.createElement)("div",{key:"loading",className:b()("woocommerce-search-list__item","woocommerce-product-attributes__item","depth-1","is-loading","is-not-active")},Object(i.createElement)(l.Spinner,null)))}},132:function(e,t,r){"use strict";r.d(t,"b",(function(){return h})),r.d(t,"a",(function(){return v}));var n=r(37),c=r.n(n),o=r(5),a=r.n(o),i=r(16),s=r.n(i),l=r(8),u=r.n(l),b=r(0),p=r(7),d=r(34),f=r.n(d);function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function O(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach((function(t){a()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function g(e){var t=function(e,t){if("object"!==c()(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!==c()(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===c()(t)?t:String(t)}var j=Object(b.createContext)({getValidationError:function(){return""},setValidationErrors:function(e){},clearValidationError:function(e){},clearAllValidationErrors:function(){},hideValidationError:function(){},showValidationError:function(){},showAllValidationErrors:function(){},hasValidationErrors:!1,getValidationErrorId:function(e){return e}}),h=function(){return Object(b.useContext)(j)},v=function(e){var t=e.children,r=Object(b.useState)({}),n=u()(r,2),c=n[0],o=n[1],i=Object(b.useCallback)((function(e){return c[e]}),[c]),l=Object(b.useCallback)((function(e){var t=c[e];return!t||t.hidden?"":"validate-error-".concat(e)}),[c]),d=Object(b.useCallback)((function(e){o((function(t){return t[e]?(t[e],s()(t,[e].map(g))):t}))}),[]),m=Object(b.useCallback)((function(){o({})}),[]),h=Object(b.useCallback)((function(e){e&&o((function(t){return e=Object(p.pickBy)(e,(function(e,r){return!("string"!=typeof e.message||t.hasOwnProperty(r)&&f()(t[r],e))})),0===Object.values(e).length?t:O(O({},t),e)}))}),[]),v=Object(b.useCallback)((function(e,t){o((function(r){if(!r.hasOwnProperty(e))return r;var n=O(O({},r[e]),t);return f()(r[e],n)?r:O(O({},r),{},a()({},e,n))}))}),[]),w={getValidationError:i,setValidationErrors:h,clearValidationError:d,clearAllValidationErrors:m,hideValidationError:Object(b.useCallback)((function(e){v(e,{hidden:!0})}),[v]),showValidationError:Object(b.useCallback)((function(e){v(e,{hidden:!1})}),[v]),showAllValidationErrors:Object(b.useCallback)((function(){o((function(e){var t={};return Object.keys(e).forEach((function(r){e[r].hidden&&(t[r]=O(O({},e[r]),{},{hidden:!1}))})),0===Object.values(t).length?e:O(O({},e),t)}))}),[]),hasValidationErrors:Object.keys(c).length>0,getValidationErrorId:l};return Object(b.createElement)(j.Provider,{value:w},t)}},133:function(e,t,r){"use strict";var n=r(17),c=r.n(n),o=r(18),a=r.n(o),i=r(19),s=r.n(i),l=r(20),u=r.n(l),b=r(10),p=r.n(b),d=r(0),f=r(7),m=r(1),O=r(4);function g(e){var t=e.level,r={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 r.hasOwnProperty(t)?Object(d.createElement)(O.SVG,{width:"20",height:"20",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg"},Object(d.createElement)(O.Path,{d:r[t]})):null}var j=function(e){s()(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=p()(t);if(r){var c=p()(this).constructor;e=Reflect.construct(n,arguments,c)}else e=n.apply(this,arguments);return u()(this,e)});function o(){return c()(this,o),n.apply(this,arguments)}return a()(o,[{key:"createLevelControl",value:function(e,t,r){var n=e===t;return{icon:Object(d.createElement)(g,{level:e}),
|
| 6 |
/* translators: %s: heading level e.g: "2", "3", "4" */
|
| 7 |
+
title:Object(m.sprintf)(Object(m.__)("Heading %d"),e),isActive:n,onClick:function(){return r(e)}}}},{key:"render",value:function(){var e=this,t=this.props,r=t.isCollapsed,n=void 0===r||r,c=t.minLevel,o=t.maxLevel,a=t.selectedLevel,i=t.onChange;return Object(d.createElement)(O.ToolbarGroup,{isCollapsed:n,icon:Object(d.createElement)(g,{level:a}),controls:Object(f.range)(c,o).map((function(t){return e.createLevelControl(t,a,i)}))})}}]),o}(d.Component);t.a=j},136:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(11);function c(e,t){var r=Object(n.useRef)();return Object(n.useEffect)((function(){r.current===e||t&&!t(e,r.current)||(r.current=e)}),[e,t]),r.current}},14:function(e,t){e.exports=window.wp.data},141:function(e,t,r){"use strict";r.d(t,"b",(function(){return w})),r.d(t,"a",(function(){return y}));var n=r(5),c=r.n(n),o=r(8),a=r.n(o),i=r(0),s=(r(2),r(14)),l=r(68),u=r(63),b=r(9),p=r.n(b),d=r(6),f=r.n(d),m=r(890),O=(r(207),function(e){var t=e.status;switch(void 0===t?"default":t){case"error":return"woocommerce-error";case"success":return"woocommerce-message";case"info":case"warning":return"woocommerce-info"}return""}),g=function(e){var t=e.className,r=e.notices,n=e.removeNotice,c=r.filter((function(e){return"snackbar"!==e.type}));if(!c.length)return null;var o=f()(t,"wc-block-components-notices");return Object(i.createElement)("div",{className:o},c.map((function(e){return Object(i.createElement)(m.a,p()({key:"store-notice-"+e.id},e,{className:f()("wc-block-components-notices__notice",O(e)),onRemove:function(){e.isDismissible&&n(e.id)}}),e.content)})))};function j(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function h(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?j(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var v=Object(i.createContext)({notices:[],createNotice:function(e,t,r){},removeNotice:function(e,t){},setIsSuppressed:function(e){},context:"wc/core"}),w=function(){return Object(i.useContext)(v)},y=function(e){var t=e.children,r=e.className,n=void 0===r?"":r,c=e.createNoticeContainer,o=void 0===c||c,b=e.context,p=void 0===b?"wc/core":b,d=Object(s.useDispatch)("core/notices"),f=d.createNotice,m=d.removeNotice,O=Object(i.useState)(!1),j=a()(O,2),w=j[0],y=j[1],E=Object(l.a)().dispatchStoreEvent,_=Object(u.b)().isEditor,k=Object(i.useCallback)((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};f(e,t,h(h({},r),{},{context:r.context||p})),E("store-notice-create",{status:e,content:t,options:r})}),[f,E,p]),P=Object(i.useCallback)((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:p;m(e,t)}),[m,p]),C={notices:Object(s.useSelect)((function(e){return{notices:e("core/notices").getNotices(p)}}),[p]).notices,createNotice:k,removeNotice:P,context:p,setIsSuppressed:y},S=w?null:Object(i.createElement)(g,{className:n,notices:C.notices,removeNotice:C.removeNotice,isEditor:_});return Object(i.createElement)(v.Provider,{value:C},o&&S,t)}},142:function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(8),c=r.n(n),o=function(e){return e.reduce((function(e,t){var r=c()(t,2),n=r[0],o=r[1];return e[n]=o,e}),{})}},143:function(e,t,r){"use strict";var n=r(0),c=r(1),o=r(66),a=r(158),i=r(3),s=r(12),l=r(45);t.a=function(e){var t=(Object(l.useProductDataContext)().product||{}).id||e.productId||0;return t?Object(n.createElement)(s.InspectorControls,null,Object(n.createElement)("div",{className:"wc-block-single-product__edit-card"},Object(n.createElement)("div",{className:"wc-block-single-product__edit-card-title"},Object(n.createElement)("a",{href:"".concat(i.ADMIN_URL,"post.php?post=").concat(t,"&action=edit"),target:"_blank",rel:"noopener noreferrer"},Object(c.__)("Edit this product's details","woo-gutenberg-products-block"),Object(n.createElement)(o.a,{srcElement:a.a,size:16}))),Object(n.createElement)("div",{className:"wc-block-single-product__edit-card-description"},Object(c.__)("Edit details such as title, price, description and more.","woo-gutenberg-products-block")))):null}},149:function(e,t,r){"use strict";var n=r(33),c=r.n(n),o=r(5),a=r.n(o),i=r(9),s=r.n(i),l=r(0),u=r(1),b=r(7),p=(r(2),r(49)),d=r(21),f=r(17),m=r.n(f),O=r(18),g=r.n(O),j=r(19),h=r.n(j),v=r(20),w=r.n(v),y=r(10),E=r.n(y);var _=Object(d.createHigherOrderComponent)((function(e){var t=function(t){h()(o,t);var r,n,c=(r=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=E()(r);if(n){var c=E()(this).constructor;e=Reflect.construct(t,arguments,c)}else e=t.apply(this,arguments);return w()(this,e)});function o(){return m()(this,o),c.apply(this,arguments)}return g()(o,[{key:"render",value:function(){var t=this.props.selected,r=null==t;return Object(l.createElement)(e,s()({},this.props,{selected:r?[]:[t]}))}}]),o}(l.Component);return t.defaultProps={selected:null},t}),"withTransformSingleSelectToMultipleSelect"),k=r(302),P=r(29),C=r.n(P),S=r(13),x=r.n(S),N=r(22),D=r.n(N),B=r(34),R=r.n(B),T=r(39),A=r(42);function I(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function L(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?I(Object(r),!0).forEach((function(t){a()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):I(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var z=Object(d.createHigherOrderComponent)((function(e){var t=function(t){h()(o,t);var r,n,c=(r=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=E()(r);if(n){var c=E()(this).constructor;e=Reflect.construct(t,arguments,c)}else e=t.apply(this,arguments);return w()(this,e)});function o(){var e;m()(this,o);for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return e=c.call.apply(c,[this].concat(r)),a()(x()(e),"state",{error:null,loading:!1,variations:{}}),a()(x()(e),"loadVariations",(function(){var t=e.props.products,r=e.state,n=r.loading,c=r.variations;if(!n){var o=e.getExpandedProduct();if(o&&!c[o]){var i=t.find((function(e){return e.id===o}));i.variations&&0!==i.variations.length?(e.setState({loading:!0}),Object(T.g)(o).then((function(t){var r=t.map((function(e){return L(L({},e),{},{parent:o})}));e.setState({variations:L(L({},e.state.variations),{},a()({},o,r)),loading:!1,error:null})})).catch(function(){var t=C()(D.a.mark((function t(r){var n;return D.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Object(A.a)(r);case 2:n=t.sent,e.setState({variations:L(L({},e.state.variations),{},a()({},o,null)),loading:!1,error:n});case 4:case"end":return t.stop()}}),t)})));return function(_x){return t.apply(this,arguments)}}())):e.setState({variations:L(L({},e.state.variations),{},a()({},o,null)),loading:!1,error:null})}}})),e}return g()(o,[{key:"componentDidMount",value:function(){var e=this.props,t=e.selected,r=e.showVariations;t&&r&&this.loadVariations()}},{key:"componentDidUpdate",value:function(e){var t=this.props,r=t.isLoading,n=t.selected;t.showVariations&&(!R()(e.selected,n)||e.isLoading&&!r)&&this.loadVariations()}},{key:"isProductId",value:function(e){return this.props.products.some((function(t){return t.id===e}))}},{key:"findParentProduct",value:function(e){return this.props.products.filter((function(t){return t.variations&&t.variations.find((function(t){return t.id===e}))}))[0].id}},{key:"getExpandedProduct",value:function(){var e=this.props,t=e.isLoading,r=e.selected;if(!e.showVariations)return null;var n=r&&r.length?r[0]:null;return n?this.prevSelectedItem=n:this.prevSelectedItem&&(t||this.isProductId(this.prevSelectedItem)||(n=this.prevSelectedItem)),!t&&n?this.isProductId(n)?n:this.findParentProduct(n):null}},{key:"render",value:function(){var t=this.props,r=t.error,n=t.isLoading,c=this.state,o=c.error,a=c.loading,i=c.variations;return Object(l.createElement)(e,s()({},this.props,{error:o||r,expandedProduct:this.getExpandedProduct(),isLoading:n,variations:i,variationsLoading:a}))}}]),o}(l.Component);return a()(t,"defaultProps",{selected:[],showVariations:!1}),t}),"withProductVariations"),V=r(52),F=r(6),M=r.n(F),H=r(131);function q(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function G(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?q(Object(r),!0).forEach((function(t){a()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):q(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}r(214);var Q={list:Object(u.__)("Products","woo-gutenberg-products-block"),noItems:Object(u.__)("Your store doesn't have any products.","woo-gutenberg-products-block"),search:Object(u.__)("Search for a product to display","woo-gutenberg-products-block"),updated:Object(u.__)("Product search results updated.","woo-gutenberg-products-block")},Y=function(e){var t=e.expandedProduct,r=e.error,n=e.instanceId,o=e.isCompact,a=e.isLoading,i=e.onChange,d=e.onSearch,f=e.products,m=e.renderItem,O=e.selected,g=e.showVariations,j=e.variations,h=e.variationsLoading;if(r)return Object(l.createElement)(V.a,{error:r});var v=j&&j[t]?j[t]:[],w=[].concat(c()(f),c()(v));return Object(l.createElement)(p.b,{className:"woocommerce-products",list:w,isCompact:o,isLoading:a,isSingle:!0,selected:w.filter((function(e){var t=e.id;return O.includes(t)})),onChange:i,renderItem:m||(g?function(e){var t=e.item,r=e.search,c=e.depth,o=void 0===c?0:c,i=e.isSelected,d=e.onSelect,f=t.variations&&Array.isArray(t.variations)?t.variations.length:0,m=M()("woocommerce-search-product__item","woocommerce-search-list__item","depth-".concat(o),"has-count",{"is-searching":r.length>0,"is-skip-level":0===o&&0!==t.parent,"is-variable":f>0});if(!t.breadcrumbs.length)return Object(l.createElement)(H.a,s()({},e,{className:M()(m,{"is-selected":i}),isSelected:i,item:t,onSelect:function(){return function(){d(t)()}},isLoading:a||h,countLabel:t.variations.length>0?Object(u.sprintf)(
|
| 8 |
/* translators: %1$d is the number of variations of a product product. */
|
| 9 |
+
Object(u.__)("%1$d variations","woo-gutenberg-products-block"),t.variations.length):null,name:"products-".concat(n),"aria-label":Object(u.sprintf)(
|
| 10 |
/* translators: %1$s is the product name, %2$d is the number of variations of that product. */
|
| 11 |
+
Object(u._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)}));var O=Object(b.isEmpty)(t.variation)?e:G(G({},e),{},{item:G(G({},e.item),{},{name:t.variation}),"aria-label":"".concat(t.breadcrumbs[0],": ").concat(t.variation)});return Object(l.createElement)(p.c,s()({},O,{className:m,name:"variations-".concat(n)}))}:null),onSearch:d,messages:Q,isHierarchical:!0})};Y.defaultProps={isCompact:!1,expandedProduct:null,selected:[],showVariations:!1},t.a=_(Object(k.a)(z(Object(d.withInstanceId)(Y))))},15:function(e,t){e.exports=window.wp.apiFetch},150:function(e,t,r){"use strict";var n=r(0),c=r(28),o=Object(n.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(n.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=o},154:function(e,t,r){"use strict";var n=r(9),c=r.n(n),o=r(16),a=r.n(o),i=r(0),s=r(25),l=r(6),u=r.n(l),b=(r(205),["className","disabled","name","permalink"]);t.a=function(e){var t=e.className,r=void 0===t?"":t,n=e.disabled,o=void 0!==n&&n,l=e.name,p=e.permalink,d=void 0===p?"":p,f=a()(e,b),m=u()("wc-block-components-product-name",r);return o?Object(i.createElement)("span",c()({className:m},f,{dangerouslySetInnerHTML:{__html:Object(s.decodeEntities)(l)}})):Object(i.createElement)("a",c()({className:m,href:d},f,{dangerouslySetInnerHTML:{__html:Object(s.decodeEntities)(l)}}))}},155:function(e,t,r){"use strict";var n=r(0),c=r(119),o=r(91),a=function(e){var t=e.indexOf("</p>");return-1===t?e:e.substr(0,t+4)},i=function(e){return e.replace(/<\/?[a-z][^>]*?>/gi,"")},s=function(e,t){return e.replace(/[\s|\.\,]+$/i,"")+t},l=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"…",n=i(e),c=n.split(" ").splice(0,t).join(" ");return Object(o.autop)(s(c,r))},u=function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"…",c=i(e),a=c.slice(0,t);if(r)return Object(o.autop)(s(a,n));var l=a.match(/([\s]+)/g),u=l?l.length:0,b=c.slice(0,t+u);return Object(o.autop)(s(b,n))};t.a=function(e){var t=e.source,r=e.maxLength,i=void 0===r?15:r,s=e.countType,b=void 0===s?"words":s,p=e.className,d=void 0===p?"":p,f=Object(n.useMemo)((function(){return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:15,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"words",n=Object(o.autop)(e),i=Object(c.count)(n,r);if(i<=t)return n;var s=a(n),b=Object(c.count)(s,r);return b<=t?s:"words"===r?l(s,t):u(s,t,"characters_including_spaces"===r)}(t,i,b)}),[t,i,b]);return Object(n.createElement)(n.RawHTML,{className:d},f)}},156:function(e,t,r){"use strict";var n=r(0),c=(r(2),r(6)),o=r.n(c),a=r(41),i=r(21);r(216),t.a=Object(i.withInstanceId)((function(e){var t=e.className,r=e.instanceId,c=e.label,i=e.onChange,s=e.options,l=e.screenReaderLabel,u=e.readOnly,b=e.value,p="wc-block-components-sort-select__select-".concat(r);return Object(n.createElement)("div",{className:o()("wc-block-sort-select","wc-block-components-sort-select",t)},Object(n.createElement)(a.a,{label:c,screenReaderLabel:l,wrapperElement:"label",wrapperProps:{className:"wc-block-sort-select__label wc-block-components-sort-select__label",htmlFor:p}}),Object(n.createElement)("select",{id:p,className:"wc-block-sort-select__select wc-block-components-sort-select__select",onChange:i,readOnly:u,value:b},s.map((function(e){return Object(n.createElement)("option",{key:e.key,value:e.key},e.label)}))))}))},158:function(e,t,r){"use strict";var n=r(0),c=r(28),o=Object(n.createElement)(c.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=o},159:function(e,t,r){"use strict";r.d(t,"c",(function(){return o})),r.d(t,"d",(function(){return a})),r.d(t,"a",(function(){return i})),r.d(t,"b",(function(){return s}));var n=r(26),c=r(38),o=function(e,t){if(c.n>2)return Object(n.registerBlockType)(e,t)},a=function(e,t){if(c.n>1)return Object(n.registerBlockType)(e,t)},i=function(){return c.n>2},s=function(){return c.n>1}},162:function(e,t,r){"use strict";r.d(t,"b",(function(){return a})),r.d(t,"c",(function(){return i})),r.d(t,"a",(function(){return s}));var n=r(3),c=r(113),o=r(23),a=function(e){var t=e.country,r=void 0===t?"":t,n=e.state,c=void 0===n?"":n,o=e.city,a=void 0===o?"":o,i=e.postcode,s=void 0===i?"":i;return{country:r.trim(),state:c.trim(),city:a.trim(),postcode:s?s.replace(" ","").toUpperCase():""}},i=function(e){var t=e.email,r=void 0===t?"":t;return Object(o.isEmail)(r)?r.trim():""},s=function(e){var t=Object.keys(n.defaultAddressFields),r=Object(c.a)(t,{},e.country),o=Object.assign({},e);return r.forEach((function(t){var r=t.key,n=void 0===r?"":r,c=t.hidden;void 0!==c&&c&&function(e,t){return e in t}(n,e)&&(o[n]="")})),o}},165:function(e,t,r){"use strict";r.d(t,"a",(function(){return s}));var n=r(24),c=r(14),o=r(0),a=r(62),i=r(127),s=function(e){var t=e.namespace,r=e.resourceName,s=e.resourceValues,l=void 0===s?[]:s,u=e.query,b=void 0===u?{}:u,p=e.shouldSelect,d=void 0===p||p;if(!t||!r)throw new Error("The options object must have valid values for the namespace and the resource properties.");var f=Object(o.useRef)({results:[],isLoading:!0}),m=Object(a.a)(b),O=Object(a.a)(l),g=Object(i.a)(),j=Object(c.useSelect)((function(e){if(!d)return null;var c=e(n.COLLECTIONS_STORE_KEY),o=[t,r,m,O],a=c.getCollectionError.apply(c,o);return a&&g(a),{results:c.getCollection.apply(c,o),isLoading:!c.hasFinishedResolution("getCollection",o)}}),[t,r,O,m,d]);return null!==j&&(f.current=j),f.current}},175:function(e,t){},188:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(0),c=Object(n.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 230 250",style:{width:"100%"}},Object(n.createElement)("title",null,"Grid Block Preview"),Object(n.createElement)("rect",{width:"65.374",height:"65.374",x:".162",y:".779",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(n.createElement)("rect",{width:"62.8",height:"15",x:"1.565",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(n.createElement)("rect",{width:"65.374",height:"65.374",x:".162",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(n.createElement)("rect",{width:"62.8",height:"15",x:"1.565",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(n.createElement)("rect",{width:"65.374",height:"65.374",x:"82.478",y:".779",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(n.createElement)("rect",{width:"62.8",height:"15",x:"83.882",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(n.createElement)("rect",{width:"65.374",height:"65.374",x:"82.478",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(n.createElement)("rect",{width:"62.8",height:"15",x:"83.882",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(n.createElement)("rect",{width:"65.374",height:"65.374",x:"164.788",y:".779",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(n.createElement)("rect",{width:"62.8",height:"15",x:"166.192",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(n.createElement)("rect",{width:"65.374",height:"65.374",x:"164.788",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(n.createElement)("rect",{width:"62.8",height:"15",x:"166.192",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"221.798",fill:"#E1E3E6",rx:"3"}))},191:function(e,t){e.exports=window.wp.warning},205:function(e,t){},206:function(e,t){},207:function(e,t){},208:function(e,t){},209:function(e,t){},21:function(e,t){e.exports=window.wp.compose},210:function(e,t){},214:function(e,t){},216:function(e,t){},22:function(e,t){e.exports=window.regeneratorRuntime},23:function(e,t){e.exports=window.wp.url},234:function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(0),c=(r(2),r(132)),o=(r(210),function(e){var t=e.errorMessage,r=void 0===t?"":t,o=e.propertyName,a=void 0===o?"":o,i=e.elementId,s=void 0===i?"":i,l=Object(c.b)(),u=l.getValidationError,b=l.getValidationErrorId;if(!r||"string"!=typeof r){var p=u(a)||{};if(!p.message||p.hidden)return null;r=p.message}return Object(n.createElement)("div",{className:"wc-block-components-validation-error",role:"alert"},Object(n.createElement)("p",{id:b(s)},r))})},24:function(e,t){e.exports=window.wc.wcBlocksData},25:function(e,t){e.exports=window.wp.htmlEntities},26:function(e,t){e.exports=window.wp.blocks},277:function(e,t,r){"use strict";var n=r(9),c=r.n(n),o=r(0),a=(r(362),function(e){if(e){var t=e.getBoundingClientRect().bottom;t>=0&&t<=window.innerHeight||e.scrollIntoView()}});t.a=function(e){return function(t){var r=Object(o.useRef)(null);return Object(o.createElement)(o.Fragment,null,Object(o.createElement)("div",{className:"with-scroll-to-top__scroll-point",ref:r,"aria-hidden":!0}),Object(o.createElement)(e,c()({},t,{scrollToTop:function(e){var t,n;null!==r.current&&(t=r.current,n=(e||{}).focusableSelector,window&&Number.isFinite(window.innerHeight)&&(n?function(e,t){var r,n=(null===(r=e.parentElement)||void 0===r?void 0:r.querySelectorAll(t))||[];if(n.length){var c=n[0];a(c),null==c||c.focus()}else a(e)}(t,n):a(t)))}})))}}},28:function(e,t){e.exports=window.wp.primitives},3:function(e,t){e.exports=window.wc.wcSettings},302:function(e,t,r){"use strict";var n=r(9),c=r.n(n),o=r(29),a=r.n(o),i=r(8),s=r.n(i),l=r(16),u=r.n(l),b=r(0),p=r(22),d=r.n(p),f=r(38),m=r(39),O=r(222),g=r(42),j=["selected"];t.a=function(e){return function(t){var r=t.selected,n=u()(t,j),o=Object(b.useState)(!0),i=s()(o,2),l=i[0],p=i[1],h=Object(b.useState)(null),v=s()(h,2),w=v[0],y=v[1],E=Object(b.useState)([]),_=s()(E,2),k=_[0],P=_[1],C=f.o.productCount>100,S=function(){var e=a()(d.a.mark((function e(t){var r;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Object(g.a)(t);case 2:r=e.sent,y(r),p(!1);case 5:case"end":return e.stop()}}),e)})));return function(_x){return e.apply(this,arguments)}}();Object(b.useEffect)((function(){Object(m.h)({selected:r}).then((function(e){P(e),p(!1)})).catch(S)}),[r]);var x=Object(O.a)((function(e){Object(m.h)({selected:r,search:e}).then((function(e){P(e),p(!1)})).catch(S)}),400),N=s()(x,1)[0],D=Object(b.useCallback)((function(e){p(!0),N(e)}),[p,N]);return Object(b.createElement)(e,c()({},n,{selected:r,error:w,products:k,isLoading:l,onSearch:C?D:null}))}}},303:function(e,t,r){"use strict";var n=r(0),c=r(28),o=Object(n.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(n.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(n.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=o},304:function(e,t,r){"use strict";r.r(t);var n=r(5),c=r.n(n),o=r(0),a=(r(2),r(1)),i=r(6),s=r.n(i),l=r(41),u=r(45),b=r(86);r(557),t.default=Object(b.withProductDataContext)((function(e){var t=e.className,r=e.align,n=Object(u.useInnerBlockLayoutContext)().parentClassName,i=Object(u.useProductDataContext)().product;if(!i.id||!i.on_sale)return null;var b="string"==typeof r?"wc-block-components-product-sale-badge--align-".concat(r):"";return Object(o.createElement)("div",{className:s()("wc-block-components-product-sale-badge",t,b,c()({},"".concat(n,"__product-onsale"),n))},Object(o.createElement)(l.a,{label:Object(a.__)("Sale","woo-gutenberg-products-block"),screenReaderLabel:Object(a.__)("Product on sale","woo-gutenberg-products-block")}))}))},31:function(e,t){e.exports=window.moment},321:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(126),c=function(e,t){return function(r){var c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,o=n.a.addEventCallback(e,r,c);return t(o),function(){t(n.a.removeEventCallback(e,o.id))}}}},322:function(e,t,r){"use strict";r.d(t,"a",(function(){return d})),r.d(t,"b",(function(){return f}));var n=r(37),c=r.n(n),o=r(29),a=r.n(o),i=r(22),s=r.n(i),l=function(e,t){return e[t]?Array.from(e[t].values()).sort((function(e,t){return e.priority-t.priority})):[]},u=r(50);function b(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return p(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?p(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,c=function(){};return{s:c,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:c}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,i=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){i=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(i)throw o}}}}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var d=function(){var e=a()(s.a.mark((function e(t,r,n){var o,a,i,u,p,d;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o=l(t,r),a=[],i=b(o),e.prev=3,i.s();case 5:if((u=i.n()).done){e.next=19;break}return p=u.value,e.prev=7,e.next=10,Promise.resolve(p.callback(n));case 10:d=e.sent,"object"===c()(d)&&a.push(d),e.next=17;break;case 14:e.prev=14,e.t0=e.catch(7),console.error(e.t0);case 17:e.next=5;break;case 19:e.next=24;break;case 21:e.prev=21,e.t1=e.catch(3),i.e(e.t1);case 24:return e.prev=24,i.f(),e.finish(24);case 27:return e.abrupt("return",!a.length||a);case 28:case"end":return e.stop()}}),e,null,[[3,21,24,27],[7,14]])})));return function(_x,t,r){return e.apply(this,arguments)}}(),f=function(){var e=a()(s.a.mark((function e(t,r,n){var o,a,i,p,d,f;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o=[],a=l(t,r),i=b(a),e.prev=3,i.s();case 5:if((p=i.n()).done){e.next=28;break}return d=p.value,e.prev=7,e.next=10,Promise.resolve(d.callback(n));case 10:if(f=e.sent,"object"===c()(f)&&null!==f){e.next=13;break}return e.abrupt("continue",26);case 13:if(f.hasOwnProperty("type")){e.next=15;break}throw new Error("Returned objects from event emitter observers must return an object with a type property");case 15:if(!Object(u.a)(f)&&!Object(u.b)(f)){e.next=18;break}return o.push(f),e.abrupt("return",o);case 18:o.push(f),e.next=26;break;case 21:return e.prev=21,e.t0=e.catch(7),console.error(e.t0),o.push({type:"error"}),e.abrupt("return",o);case 26:e.next=5;break;case 28:e.next=33;break;case 30:e.prev=30,e.t1=e.catch(3),i.e(e.t1);case 33:return e.prev=33,i.f(),e.finish(33);case 36:return e.abrupt("return",o);case 37:case"end":return e.stop()}}),e,null,[[3,30,33,36],[7,21]])})));return function(t,r,n){return e.apply(this,arguments)}}()},34:function(e,t){e.exports=window.wp.isShallowEqual},36:function(e,t){e.exports=window.wp.dataControls},361:function(e,t,r){"use strict";var n=r(0),c=r(28),o=Object(n.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(n.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(n.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=o},362:function(e,t){},372:function(e,t){},373:function(e,t,r){"use strict";var n=r(5),c=r.n(n),o=r(159);function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var s={headingLevel:{type:"number",default:2},showProductLink:{type:"boolean",default:!0},productId:{type:"number",default:0}};Object(o.b)()&&(s=i(i({},s),{},{align:{type:"string"},color:{type:"string"},customColor:{type:"string"},fontSize:{type:"string"},customFontSize:{type:"number"}})),t.a=s},374:function(e,t,r){"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}}},375:function(e,t,r){"use strict";var n=r(9),c=r.n(n),o=r(5),a=r.n(o),i=r(8),s=r.n(i),l=r(0),u=(r(2),r(1)),b=r(6),p=r.n(b),d=r(3),f=r(45),m=r(86),O=r(68),g=r(304);function j(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function h(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?j(Object(r),!0).forEach((function(t){a()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}r(558);var v=function(){return Object(l.createElement)("img",{src:d.PLACEHOLDER_IMG_SRC,alt:"",width:500,height:500})},w=function(e){var t=e.image,r=e.onLoad,n=e.loaded,o=e.showFullSize,a=e.fallbackAlt,i=t||{},s=i.thumbnail,u=i.src,b=i.srcset,p=i.sizes,d=h({alt:i.alt||a,onLoad:r,hidden:!n,src:s},o&&{src:u,srcSet:b,sizes:p});return Object(l.createElement)(l.Fragment,null,d.src&&Object(l.createElement)("img",c()({"data-testid":"product-image"},d)),!n&&Object(l.createElement)(v,null))};t.a=Object(m.withProductDataContext)((function(e){var t=e.className,r=e.imageSizing,n=void 0===r?"full-size":r,c=e.showProductLink,o=void 0===c||c,i=e.showSaleBadge,b=e.saleBadgeAlign,d=void 0===b?"right":b,m=Object(f.useInnerBlockLayoutContext)().parentClassName,j=Object(f.useProductDataContext)().product,y=Object(l.useState)(!1),E=s()(y,2),_=E[0],k=E[1],P=Object(O.a)().dispatchStoreEvent;if(!j.id)return Object(l.createElement)("div",{className:p()(t,"wc-block-components-product-image","wc-block-components-product-image--placeholder",a()({},"".concat(m,"__product-image"),m))},Object(l.createElement)(v,null));var C=!!j.images.length,S=C?j.images[0]:null,x=o?"a":l.Fragment,N=Object(u.sprintf)(
|
| 12 |
/* translators: %s is referring to the product name */
|
| 13 |
+
Object(u.__)("Link to %s","woo-gutenberg-products-block"),j.name),D=h(h({href:j.permalink,rel:"nofollow"},!C&&{"aria-label":N}),{},{onClick:function(){P("product-view-link",{product:j})}});return Object(l.createElement)("div",{className:p()(t,"wc-block-components-product-image",a()({},"".concat(m,"__product-image"),m))},Object(l.createElement)(x,o&&D,!!i&&Object(l.createElement)(g.default,{align:d,product:j}),Object(l.createElement)(w,{fallbackAlt:j.name,image:S,onLoad:function(){return k(!0)},loaded:_,showFullSize:"cropped"!==n})))}))},376:function(e,t,r){"use strict";t.a={showFormElements:{type:"boolean",default:!1},productId:{type:"number",default:0}}},377:function(e,t,r){"use strict";var n=r(0),c=(r(2),r(6)),o=r.n(c),a=r(8),i=r.n(a),s=r(1),l=r(62),u=r(879),b={status:"pristine",hasError:!1,quantity:1,processingResponse:null,requestParams:{}},p=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=e?"set_has_error":"set_no_error";return{type:t}},d=r(5),f=r.n(d);function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function O(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach((function(t){f()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var g="idle",j=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:b,r=arguments.length>1?arguments[1]:void 0,n=r.quantity,c=r.type,o=r.data;switch(c){case"set_pristine":e=b;break;case"set_idle":e=t.status!==g?O(O({},t),{},{status:g}):t;break;case"set_disabled":e="disabled"!==t.status?O(O({},t),{},{status:"disabled"}):t;break;case"set_quantity":e=n!==t.quantity?O(O({},t),{},{quantity:n}):t;break;case"set_request_params":e=O(O({},t),{},{requestParams:O(O({},t.requestParams),o)});break;case"set_processing_response":e=O(O({},t),{},{processingResponse:o});break;case"set_processing":e=!1===(e="processing"!==t.status?O(O({},t),{},{status:"processing",hasError:!1}):t).hasError?e:O(O({},e),{},{hasError:!1});break;case"set_before_processing":e="before_processing"!==t.status?O(O({},t),{},{status:"before_processing",hasError:!1}):t;break;case"set_after_processing":e="after_processing"!==t.status?O(O({},t),{},{status:"after_processing"}):t;break;case"set_has_error":e=t.hasError?t:O(O({},t),{},{hasError:!0}),e="processing"===t.status||"before_processing"===t.status?O(O({},e),{},{status:g}):e;break;case"set_no_error":e=t.hasError?O(O({},t),{},{hasError:!1}):t}return e!==t&&"set_pristine"!==c&&"pristine"===e.status&&(e.status=g),e},h=r(126),v=r(321),w=function(e){return{onAddToCartAfterProcessingWithSuccess:Object(v.a)("add_to_cart_after_processing_with_success",e),onAddToCartProcessingWithError:Object(v.a)("add_to_cart_after_processing_with_error",e),onAddToCartBeforeProcessing:Object(v.a)("add_to_cart_before_processing",e)}},y=r(322),E=r(132),_=r(59),k=r(50),P=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:function(e){},onAddToCartAfterProcessingWithError:function(e){},onAddToCartBeforeProcessing:function(e){}},dispatchActions:{resetForm:function(){},submitForm:function(){},setQuantity:function(e){},setHasError:function(e){},setAfterProcessing:function(e){},setRequestParams:function(e){}}}),C=function(){return Object(n.useContext)(P)},S=function(e){var t=e.children,r=e.product,c=e.showFormElements,o=Object(n.useReducer)(j,b),a=i()(o,2),d=a[0],f=a[1],m=Object(n.useReducer)(h.b,{}),O=i()(m,2),g=O[0],v=O[1],C=Object(l.a)(g),S=Object(_.a)(),x=S.addErrorNotice,N=S.removeNotices,D=Object(E.b)().setValidationErrors,B=Object(k.c)(),R=B.isSuccessResponse,T=B.isErrorResponse,A=B.isFailResponse,I=Object(n.useMemo)((function(){return{onAddToCartAfterProcessingWithSuccess:w(v).onAddToCartAfterProcessingWithSuccess,onAddToCartAfterProcessingWithError:w(v).onAddToCartAfterProcessingWithError,onAddToCartBeforeProcessing:w(v).onAddToCartBeforeProcessing}}),[v]),L=Object(n.useMemo)((function(){return{resetForm:function(){f({type:"set_pristine"})},submitForm:function(){f({type:"set_before_processing"})},setQuantity:function(e){f(function(e){return{type:"set_quantity",quantity:e}}(e))},setHasError:function(e){f(p(e))},setRequestParams:function(e){f(function(e){return{type:"set_request_params",data:e}}(e))},setAfterProcessing:function(e){f({type:"set_processing_response",data:e}),f({type:"set_after_processing"})}}}),[]);Object(n.useEffect)((function(){var e=d.status,t=!r.id||!Object(u.a)(r);"disabled"!==e||t?"disabled"!==e&&t&&f({type:"set_disabled"}):f({type:"set_idle"})}),[d.status,r,f]),Object(n.useEffect)((function(){"before_processing"===d.status&&(N("error"),Object(y.a)(C,"add_to_cart_before_processing",{}).then((function(e){!0!==e?(Array.isArray(e)&&e.forEach((function(e){var t=e.errorMessage,r=e.validationErrors;t&&x(t),r&&D(r)})),f({type:"set_idle"})):f({type:"set_processing"})})))}),[d.status,D,x,N,f,C]),Object(n.useEffect)((function(){if("after_processing"===d.status){var e={processingResponse:d.processingResponse},t=function(e){var t=!1;return e.forEach((function(e){var r=e.message,n=e.messageContext;(T(e)||A(e))&&r&&(t=!0,x(r,n?{context:n}:void 0))})),t};if(d.hasError)return void Object(y.b)(C,"add_to_cart_after_processing_with_error",e).then((function(r){if(!t(r)){var n,c=(null===(n=e.processingResponse)||void 0===n?void 0:n.message)||Object(s.__)("Something went wrong. Please contact us to get assistance.","woo-gutenberg-products-block");x(c,{id:"add-to-cart"})}f({type:"set_idle"})}));Object(y.b)(C,"add_to_cart_after_processing_with_success",e).then((function(e){t(e)?f(p(!0)):f({type:"set_idle"})}))}}),[d.status,d.hasError,d.processingResponse,L,x,T,A,R,C]);var z=Object(u.b)(r),V={product:r,productType:r.type||"simple",productIsPurchasable:Object(u.a)(r),productHasOptions:r.has_options||!1,supportsFormElements:z,showFormElements:c&&z,quantity:d.quantity,minQuantity:1,maxQuantity:r.quantity_limit||99,requestParams:d.requestParams,isIdle:"idle"===d.status,isDisabled:"disabled"===d.status,isProcessing:"processing"===d.status,isBeforeProcessing:"before_processing"===d.status,isAfterProcessing:"after_processing"===d.status,hasError:d.hasError,eventRegistration:I,dispatchActions:L};return Object(n.createElement)(P.Provider,{value:V},t)},x=r(15),N=r.n(x),D=r(25),B=r(43);function R(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}var T=function(){var e=C(),t=e.dispatchActions,r=e.product,c=e.quantity,o=e.eventRegistration,a=e.hasError,l=e.isProcessing,u=e.requestParams,b=Object(E.b)(),p=b.hasValidationErrors,d=b.showAllValidationErrors,m=Object(_.a)(),O=m.addErrorNotice,g=m.removeNotice,j=Object(B.a)().receiveCart,h=Object(n.useState)(!1),v=i()(h,2),w=v[0],y=v[1],k=!a&&l,P=Object(n.useCallback)((function(){return!p||(d(),{type:"error"})}),[p,d]);Object(n.useEffect)((function(){var e=o.onAddToCartBeforeProcessing(P,0);return function(){e()}}),[o,P]);var S=Object(n.useCallback)((function(){y(!0),g("add-to-cart");var e=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?R(Object(r),!0).forEach((function(t){f()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):R(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({id:r.id||0,quantity:c},u);N()({path:"/wc/store/cart/add-item",method:"POST",data:e,cache:"no-store",parse:!1}).then((function(e){N.a.setNonce(e.headers),e.json().then((function(r){e.ok?j(r):(r.body&&r.body.message?O(Object(D.decodeEntities)(r.body.message),{id:"add-to-cart"}):O(Object(s.__)("Something went wrong. Please contact us to get assistance.","woo-gutenberg-products-block"),{id:"add-to-cart"}),t.setHasError()),t.setAfterProcessing(r),y(!1)}))})).catch((function(e){e.json().then((function(e){var r;null!==(r=e.data)&&void 0!==r&&r.cart&&j(e.data.cart),t.setHasError(),t.setAfterProcessing(e),y(!1)}))}))}),[r,O,g,j,t,c,u]);return Object(n.useEffect)((function(){k&&!w&&S()}),[k,S,w]),null},A=function(e){var t=e.children,r=e.product,c=e.showFormElements;return Object(n.createElement)(E.a,null,Object(n.createElement)(S,{product:r,showFormElements:c},t,Object(n.createElement)(T,null)))},I=r(45),L=r(7),z=r(86),V=(r(372),r(90)),F=r(66),M=r(567),H=r(68),q=r(788),G=function(e){var t=e.className,r=e.href,c=e.text,o=e.onClick;return Object(n.createElement)(V.a,{className:t,href:r,onClick:o,rel:"nofollow"},c)},Q=function(e){var t=e.className,r=e.quantityInCart,c=e.isProcessing,o=e.isDisabled,a=e.isDone,i=e.onClick;return Object(n.createElement)(V.a,{className:t,disabled:o,showSpinner:c,onClick:i},a&&r>0?Object(s.sprintf)(
|
| 14 |
/* translators: %s number of products in cart. */
|
| 15 |
+
Object(s._n)("%d in cart","%d in cart",r,"woo-gutenberg-products-block"),r):Object(s.__)("Add to cart","woo-gutenberg-products-block"),!!a&&Object(n.createElement)(F.a,{srcElement:M.a,alt:Object(s.__)("Done","woo-gutenberg-products-block")}))},Y=function(){var e=C(),t=e.showFormElements,r=e.productIsPurchasable,c=e.productHasOptions,o=e.product,a=e.productType,l=e.isDisabled,u=e.isProcessing,b=e.eventRegistration,p=e.hasError,d=e.dispatchActions,f=Object(I.useInnerBlockLayoutContext)().parentName,m=Object(H.a)().dispatchStoreEvent,O=Object(q.a)(o.id||0).cartQuantity,g=Object(n.useState)(!1),j=i()(g,2),h=j[0],v=j[1],w=o.add_to_cart||{url:"",text:""};return Object(n.useEffect)((function(){var e=b.onAddToCartAfterProcessingWithSuccess((function(){return p||v(!0),!0}),0);return function(){e()}}),[b,p]),(t||!c&&"simple"===a)&&r?Object(n.createElement)(Q,{className:"wc-block-components-product-add-to-cart-button",quantityInCart:O,isDisabled:l,isProcessing:u,isDone:h,onClick:function(){d.submitForm(),m("cart-add-item",{product:o,listName:f})}}):Object(n.createElement)(G,{className:"wc-block-components-product-add-to-cart-button",href:w.url,text:w.text||Object(s.__)("View Product","woo-gutenberg-products-block"),onClick:function(){m("product-view-link",{product:o,listName:f})}})},U=function(e){var t=e.disabled,r=e.min,c=e.max,o=e.value,a=e.onChange;return Object(n.createElement)("input",{className:"wc-block-components-product-add-to-cart-quantity",type:"number",value:o,min:r,max:c,hidden:1===c,disabled:t,onChange:function(e){a(e.target.value)}})},W=function(e){var t=e.reason,r=void 0===t?Object(s.__)("Sorry, this product cannot be purchased.","woo-gutenberg-products-block"):t;return Object(n.createElement)("div",{className:"wc-block-components-product-add-to-cart-unavailable"},r)},K=function(){var e=C(),t=e.product,r=e.quantity,c=e.minQuantity,o=e.maxQuantity,a=e.dispatchActions,i=e.isDisabled;return t.id&&!t.is_purchasable?Object(n.createElement)(W,null):t.id&&!t.is_in_stock?Object(n.createElement)(W,{reason:Object(s.__)("This product is currently out of stock and cannot be purchased.","woo-gutenberg-products-block")}):Object(n.createElement)(n.Fragment,null,Object(n.createElement)(U,{value:r,min:c,max:o,disabled:i,onChange:a.setQuantity}),Object(n.createElement)(Y,null))},$=(r(566),r(33)),J=r.n($),X=r(897),Z=r(11),ee=r(234),te={value:"",label:Object(s.__)("Select an option","woo-gutenberg-products-block")},re=function(e){var t=e.attributeName,r=e.options,c=void 0===r?[]:r,a=e.value,i=void 0===a?"":a,l=e.onChange,u=void 0===l?function(){}:l,b=e.errorMessage,p=void 0===b?Object(s.__)("Please select a value.","woo-gutenberg-products-block"):b,d=Object(E.b)(),m=d.getValidationError,O=d.setValidationErrors,g=d.clearValidationError,j=t,h=m(j)||{};return Object(Z.useEffect)((function(){i?g(j):O(f()({},j,{message:p,hidden:!0}))}),[i,j,p,g,O]),Object(Z.useEffect)((function(){return function(){g(j)}}),[j,g]),Object(n.createElement)("div",{className:"wc-block-components-product-add-to-cart-attribute-picker__container"},Object(n.createElement)(X.a,{label:Object(D.decodeEntities)(t),value:i||"",options:[te].concat(J()(c)),onChange:u,required:!0,className:o()("wc-block-components-product-add-to-cart-attribute-picker__select",{"has-error":h.message&&!h.hidden})}),Object(n.createElement)(ee.a,{propertyName:j,elementId:j}))};function ne(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ce(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ne(Object(r),!0).forEach((function(t){f()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ne(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var oe=function(e,t,r){var n=Object.values(t).map((function(e){return e.id}));if(Object.values(r).every((function(e){return""===e})))return n;var c=Object.keys(e);return n.filter((function(e){return c.every((function(n){var c=r[n]||"",o=t["id:"+e].attributes[n];return""===c||null===o||o===c}))}))};function ae(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ie(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ae(Object(r),!0).forEach((function(t){f()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ae(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var se=function(e){var t=e.attributes,r=e.variationAttributes,c=e.setRequestParams,o=Object(l.a)(t),a=Object(l.a)(r),s=Object(n.useState)(0),u=i()(s,2),b=u[0],p=u[1],d=Object(n.useState)({}),m=i()(d,2),O=m[0],g=m[1],j=Object(n.useMemo)((function(){return function(e,t,r){var n={},c=Object.keys(e),o=Object.values(r).filter(Boolean).length>0;return c.forEach((function(c){var a=e[c],i=ce(ce({},r),{},f()({},c,null)),s=o?oe(e,t,i):null,l=null!==s?s.map((function(e){return t["id:"+e].attributes[c]})):null;n[c]=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return Object.values(e).map((function(e){var r=e.name,n=e.slug;return null===t||t.includes(null)||t.includes(n)?{value:n,label:Object(D.decodeEntities)(r)}:null})).filter(Boolean)}(a.terms,l)})),n}(o,a,O)}),[O,o,a]);return Object(n.useEffect)((function(){Object.values(O).filter((function(e){return""!==e})).length===Object.keys(o).length?p(function(e,t,r){return oe(e,t,r)[0]||0}(o,a,O)):b>0&&p(0)}),[O,b,o,a]),Object(n.useEffect)((function(){c({id:b,variation:Object.keys(O).map((function(e){return{attribute:e,value:O[e]}}))})}),[c,b,O]),Object(n.createElement)("div",{className:"wc-block-components-product-add-to-cart-attribute-picker"},Object.keys(o).map((function(e){return Object(n.createElement)(re,{key:e,attributeName:e,options:j[e],value:O[e],onChange:function(t){g(ie(ie({},O),{},f()({},e,t)))}})})))},le=function(e){var t=e.product,r=e.dispatchers,c=function(e){return e?Object(L.keyBy)(Object.values(e).filter((function(e){return e.has_variations})),"name"):{}}(t.attributes),o=function(e){if(!e)return{};var t={};return e.forEach((function(e){var r=e.id,n=e.attributes;t["id:".concat(r)]={id:r,attributes:n.reduce((function(e,t){var r=t.name,n=t.value;return e[r]=n,e}),{})}})),t}(t.variations);return 0===Object.keys(c).length||0===o.length?null:Object(n.createElement)(se,{attributes:c,variationAttributes:o,setRequestParams:r.setRequestParams})},ue=function(){var e=C(),t=e.product,r=e.quantity,c=e.minQuantity,o=e.maxQuantity,a=e.dispatchActions,i=e.isDisabled;return t.id&&!t.is_purchasable?Object(n.createElement)(W,null):t.id&&!t.is_in_stock?Object(n.createElement)(W,{reason:Object(s.__)("This product is currently out of stock and cannot be purchased.","woo-gutenberg-products-block")}):Object(n.createElement)(n.Fragment,null,Object(n.createElement)(le,{product:t,dispatchers:a}),Object(n.createElement)(U,{value:r,min:c,max:o,disabled:i,onChange:a.setQuantity}),Object(n.createElement)(Y,null))},be=function(){return Object(n.createElement)(Y,null)},pe=r(891),de=function(){return Object(n.createElement)(pe.a,{className:"wc-block-components-product-add-to-cart-group-list"},"This is a placeholder for the grouped products form element.")},fe=function(){return Object(n.createElement)(de,null)},me=function(){var e=C(),t=e.showFormElements,r=e.productType;return t?"variable"===r?Object(n.createElement)(ue,null):"grouped"===r?Object(n.createElement)(fe,null):"external"===r?Object(n.createElement)(be,null):"simple"===r||"variation"===r?Object(n.createElement)(K,null):null:Object(n.createElement)(Y,null)};t.a=Object(z.withProductDataContext)((function(e){var t=e.className,r=e.showFormElements,c=Object(I.useProductDataContext)().product,a=o()(t,"wc-block-components-product-add-to-cart",{"wc-block-components-product-add-to-cart--placeholder":Object(L.isEmpty)(c)});return Object(n.createElement)(A,{product:c,showFormElements:r},Object(n.createElement)("div",{className:a},Object(n.createElement)(me,null)))}))},378:function(e,t,r){"use strict";var n=r(5),c=r.n(n),o=r(0),a=(r(2),r(6)),i=r.n(a),s=r(45),l=r(12),u=r(159),b=function(e){var t=e.color,r=e.fontSize;return Object(u.b)()?{color:t,fontSize:r}:{}},p=r(86),d=r(154),f=r(68);r(556),t.a=Object(p.withProductDataContext)((function(e){var t,r,n,a=e.className,p=e.headingLevel,m=void 0===p?2:p,O=e.showProductLink,g=void 0===O||O,j=e.align,h=e.color,v=e.customColor,w=e.fontSize,y=e.customFontSize,E=Object(s.useInnerBlockLayoutContext)().parentClassName,_=Object(s.useProductDataContext)().product,k=Object(f.a)().dispatchStoreEvent,P="h".concat(m),C=Object(l.getColorClassName)("color",h),S=Object(l.getFontSizeClass)(w),x=i()((t={"has-text-color":h||v,"has-font-size":w||y},c()(t,C,C),c()(t,S,S),t));return _.id?Object(o.createElement)(P,{className:i()(a,"wc-block-components-product-title",(r={},c()(r,"".concat(E,"__product-title"),E),c()(r,"wc-block-components-product-title--align-".concat(j),j&&Object(u.b)()),r))},Object(o.createElement)(d.a,{className:i()(c()({},x,Object(u.b)())),disabled:!g,name:_.name,permalink:_.permalink,rel:g?"nofollow":null,style:b({color:v,fontSize:y}),onClick:function(){k("product-view-link",{product:_})}})):Object(o.createElement)(P,{className:i()(a,"wc-block-components-product-title",(n={},c()(n,"".concat(E,"__product-title"),E),c()(n,"wc-block-components-product-title--align-".concat(j),j&&Object(u.b)()),c()(n,x,Object(u.b)()),n)),style:b({color:v,fontSize:y})})}))},38:function(e,t,r){"use strict";r.d(t,"o",(function(){return o})),r.d(t,"m",(function(){return a})),r.d(t,"l",(function(){return i})),r.d(t,"n",(function(){return s})),r.d(t,"j",(function(){return l})),r.d(t,"e",(function(){return u})),r.d(t,"f",(function(){return b})),r.d(t,"g",(function(){return p})),r.d(t,"k",(function(){return d})),r.d(t,"c",(function(){return f})),r.d(t,"d",(function(){return m})),r.d(t,"h",(function(){return O})),r.d(t,"a",(function(){return g})),r.d(t,"i",(function(){return j})),r.d(t,"b",(function(){return h}));var n,c=r(3),o=Object(c.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),a=o.pluginUrl+"images/",i=o.pluginUrl+"build/",s=o.buildPhase,l=null===(n=c.STORE_PAGES.shop)||void 0===n?void 0:n.permalink,u=c.STORE_PAGES.checkout.id,b=c.STORE_PAGES.checkout.permalink,p=c.STORE_PAGES.privacy.permalink,d=(c.STORE_PAGES.privacy.title,c.STORE_PAGES.terms.permalink),f=(c.STORE_PAGES.terms.title,c.STORE_PAGES.cart.id),m=c.STORE_PAGES.cart.permalink,O=(c.STORE_PAGES.myaccount.permalink?c.STORE_PAGES.myaccount.permalink:Object(c.getSetting)("wpLoginUrl","/wp-login.php"),Object(c.getSetting)("shippingCountries",{})),g=Object(c.getSetting)("allowedCountries",{}),j=Object(c.getSetting)("shippingStates",{}),h=Object(c.getSetting)("allowedStates",{})},39:function(e,t,r){"use strict";r.d(t,"h",(function(){return d})),r.d(t,"e",(function(){return f})),r.d(t,"b",(function(){return m})),r.d(t,"i",(function(){return O})),r.d(t,"f",(function(){return g})),r.d(t,"c",(function(){return j})),r.d(t,"d",(function(){return h})),r.d(t,"g",(function(){return v})),r.d(t,"a",(function(){return w}));var n=r(5),c=r.n(n),o=r(23),a=r(15),i=r.n(a),s=r(7),l=r(3),u=r(38);function b(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function p(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?b(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var d=function(e){var t=e.selected,r=void 0===t?[]:t,n=e.search,c=void 0===n?"":n,a=e.queryArgs,l=function(e){var t=e.selected,r=void 0===t?[]:t,n=e.search,c=void 0===n?"":n,a=e.queryArgs,i=void 0===a?{}:a,s=u.o.productCount>100,l={per_page:s?100:0,catalog_visibility:"any",search:c,orderby:"title",order:"asc"},b=[Object(o.addQueryArgs)("/wc/store/products",p(p({},l),i))];return s&&r.length&&b.push(Object(o.addQueryArgs)("/wc/store/products",{catalog_visibility:"any",include:r,per_page:0})),b}({selected:r,search:c,queryArgs:void 0===a?{}:a});return Promise.all(l.map((function(e){return i()({path:e})}))).then((function(e){return Object(s.uniqBy)(Object(s.flatten)(e),"id").map((function(e){return p(p({},e),{},{parent:0})}))})).catch((function(e){throw e}))},f=function(e){return i()({path:"/wc/store/products/".concat(e)})},m=function(){return i()({path:"wc/store/products/attributes"})},O=function(e){return i()({path:"wc/store/products/attributes/".concat(e,"/terms")})},g=function(e){var t=e.selected,r=function(e){var t=e.selected,r=void 0===t?[]:t,n=e.search,c=Object(l.getSetting)("limitTags",!1),a=[Object(o.addQueryArgs)("wc/store/products/tags",{per_page:c?100:0,orderby:c?"count":"name",order:c?"desc":"asc",search:n})];return c&&r.length&&a.push(Object(o.addQueryArgs)("wc/store/products/tags",{include:r})),a}({selected:void 0===t?[]:t,search:e.search});return Promise.all(r.map((function(e){return i()({path:e})}))).then((function(e){return Object(s.uniqBy)(Object(s.flatten)(e),"id")}))},j=function(e){return i()({path:Object(o.addQueryArgs)("wc/store/products/categories",p({per_page:0},e))})},h=function(e){return i()({path:"wc/store/products/categories/".concat(e)})},v=function(e){return i()({path:Object(o.addQueryArgs)("wc/store/products",{per_page:0,type:"variation",parent:e})})},w=function(e,t){if(!e.title.raw)return e.slug;var r=1===t.filter((function(t){return t.title.raw===e.title.raw})).length;return e.title.raw+(r?"":" - ".concat(e.slug))}},4:function(e,t){e.exports=window.wp.components},41:function(e,t,r){"use strict";var n=r(5),c=r.n(n),o=r(0),a=r(6),i=r.n(a);function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}t.a=function(e){var t,r=e.label,n=e.screenReaderLabel,c=e.wrapperElement,a=e.wrapperProps,s=void 0===a?{}:a,u=null!=r,b=null!=n;return!u&&b?(t=c||"span",s=l(l({},s),{},{className:i()(s.className,"screen-reader-text")}),Object(o.createElement)(t,s,n)):(t=c||o.Fragment,u&&b&&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))}},42:function(e,t,r){"use strict";r.d(t,"a",(function(){return s})),r.d(t,"b",(function(){return l}));var n=r(29),c=r.n(n),o=r(22),a=r.n(o),i=r(1),s=function(){var e=c()(a.a.mark((function e(t){var r;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("function"!=typeof t.json){e.next=11;break}return e.prev=1,e.next=4,t.json();case 4:return r=e.sent,e.abrupt("return",{message:r.message,type:r.type||"api"});case 8:return e.prev=8,e.t0=e.catch(1),e.abrupt("return",{message:e.t0.message,type:"general"});case 11:return e.abrupt("return",{message:t.message,type:t.type||"general"});case 12:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(_x){return e.apply(this,arguments)}}(),l=function(e){if(e.data&&"rest_invalid_param"===e.code){var t=Object.values(e.data.params);if(t[0])return t[0]}return(null==e?void 0:e.message)||Object(i.__)("Something went wrong. Please contact us to get assistance.","woo-gutenberg-products-block")}},43:function(e,t,r){"use strict";r.d(t,"a",(function(){return y}));var n=r(8),c=r.n(n),o=r(5),a=r.n(o),i=r(7),s=r(0),l=r(24),u=r(14),b=r(25),p=r(142),d=r(162),f=r(63);function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function O(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach((function(t){a()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var g={first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:""},j=O(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:l.EMPTY_TAX_LINES,currency_code:"",currency_symbol:"",currency_minor_unit:2,currency_decimal_separator:"",currency_thousand_separator:"",currency_prefix:"",currency_suffix:""},v=function(e){return Object(p.a)(Object.entries(e).map((function(e){var t=c()(e,2),r=t[0],n=t[1];return[r,Object(b.decodeEntities)(n)]})))},w={cartCoupons:l.EMPTY_CART_COUPONS,cartItems:l.EMPTY_CART_ITEMS,cartFees:l.EMPTY_CART_FEES,cartItemsCount:0,cartItemsWeight:0,cartNeedsPayment:!0,cartNeedsShipping:!0,cartItemErrors:l.EMPTY_CART_ITEM_ERRORS,cartTotals:h,cartIsLoading:!0,cartErrors:l.EMPTY_CART_ERRORS,billingAddress:j,shippingAddress:g,shippingRates:l.EMPTY_SHIPPING_RATES,shippingRatesLoading:!1,cartHasCalculatedShipping:!1,paymentRequirements:l.EMPTY_PAYMENT_REQUIREMENTS,receiveCart:function(){},extensions:l.EMPTY_EXTENSIONS},y=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{shouldSelect:!0},t=Object(f.b)(),r=t.isEditor,n=t.previewData,c=null==n?void 0:n.previewCart,o=e.shouldSelect,a=Object(s.useRef)(),b=Object(u.useSelect)((function(e,t){var n=t.dispatch;if(!o)return w;if(r)return{cartCoupons:c.coupons,cartItems:c.items,cartFees:c.fees,cartItemsCount:c.items_count,cartItemsWeight:c.items_weight,cartNeedsPayment:c.needs_payment,cartNeedsShipping:c.needs_shipping,cartItemErrors:l.EMPTY_CART_ITEM_ERRORS,cartTotals:c.totals,cartIsLoading:!1,cartErrors:l.EMPTY_CART_ERRORS,billingAddress:j,shippingAddress:g,extensions:l.EMPTY_EXTENSIONS,shippingRates:c.shipping_rates,shippingRatesLoading:!1,cartHasCalculatedShipping:c.has_calculated_shipping,paymentRequirements:c.paymentRequirements,receiveCart:"function"==typeof(null==c?void 0:c.receiveCart)?c.receiveCart:function(){}};var a=e(l.CART_STORE_KEY),i=a.getCartData(),s=a.getCartErrors(),u=a.getCartTotals(),b=!a.hasFinishedResolution("getCartData"),p=a.isCustomerDataUpdating(),f=n(l.CART_STORE_KEY).receiveCart,m=v(i.billingAddress),h=i.needsShipping?v(i.shippingAddress):m,y=i.fees.length>0?i.fees.map((function(e){return v(e)})):l.EMPTY_CART_FEES;return{cartCoupons:i.coupons.length>0?i.coupons.map((function(e){return O(O({},e),{},{label:e.code})})):l.EMPTY_CART_COUPONS,cartItems:i.items,cartFees:y,cartItemsCount:i.itemsCount,cartItemsWeight:i.itemsWeight,cartNeedsPayment:i.needsPayment,cartNeedsShipping:i.needsShipping,cartItemErrors:i.errors,cartTotals:u,cartIsLoading:b,cartErrors:s,billingAddress:Object(d.a)(m),shippingAddress:Object(d.a)(h),extensions:i.extensions,shippingRates:i.shippingRates,shippingRatesLoading:p,cartHasCalculatedShipping:i.hasCalculatedShipping,paymentRequirements:i.paymentRequirements,receiveCart:f}}),[o]);return a.current&&Object(i.isEqual)(a.current,b)||(a.current=b),a.current}},45:function(e,t){e.exports=window.wc.wcBlocksSharedContext},46:function(e,t){e.exports=window.wp.keycodes},47:function(e,t){e.exports=window.wc.priceFormat},48:function(e,t){e.exports=window.wp.escapeHtml},482:function(e,t,r){"use strict";r.r(t);var n=r(5),c=r.n(n),o=r(0),a=(r(2),r(6)),i=r.n(a),s=r(124),l=r(47),u=r(45),b=r(12),p=r(159),d=r(86);t.default=Object(d.withProductDataContext)((function(e){var t,r,n,a,d,f,m,O=e.className,g=e.align,j=e.fontSize,h=e.customFontSize,v=e.saleFontSize,w=e.customSaleFontSize,y=e.color,E=e.customColor,_=e.saleColor,k=e.customSaleColor,P=Object(u.useInnerBlockLayoutContext)().parentClassName,C=Object(u.useProductDataContext)().product,S=i()(O,c()({},"".concat(P,"__product-price"),P));if(!C.id)return Object(o.createElement)(s.a,{align:g,className:S});var x=Object(b.getColorClassName)("color",y),N=Object(b.getFontSizeClass)(j),D=Object(b.getColorClassName)("color",_),B=Object(b.getFontSizeClass)(v),R=i()((t={"has-text-color":y||E,"has-font-size":j||h},c()(t,x,x),c()(t,N,N),t)),T=i()((r={"has-text-color":_||k,"has-font-size":v||w},c()(r,D,D),c()(r,B,B),r)),A={color:E,fontSize:h},I={color:k,fontSize:w},L=C.prices,z=Object(l.getCurrencyFromPriceResponse)(L),V=L.price!==L.regular_price,F=V?i()((n={},c()(n,"".concat(P,"__product-price__value"),P),c()(n,T,Object(p.b)()),n)):i()((a={},c()(a,"".concat(P,"__product-price__value"),P),c()(a,R,Object(p.b)()),a)),M=V?I:A;return Object(o.createElement)(s.a,{align:g,className:S,currency:z,price:L.price,priceClassName:F,priceStyle:Object(p.b)()?M:{},minPrice:null==L||null===(d=L.price_range)||void 0===d?void 0:d.min_amount,maxPrice:null==L||null===(f=L.price_range)||void 0===f?void 0:f.max_amount,regularPrice:L.regular_price,regularPriceClassName:i()((m={},c()(m,"".concat(P,"__product-price__regular"),P),c()(m,R,Object(p.b)()),m)),regularPriceStyle:Object(p.b)()?A:{}})}))},483:function(e,t,r){"use strict";r.r(t);var n=r(5),c=r.n(n),o=r(0),a=(r(2),r(1)),i=r(6),s=r.n(i),l=r(45),u=r(86),b=(r(559),function(e){var t=parseFloat(e.average_rating);return Number.isFinite(t)&&t>0?t:0});t.default=Object(u.withProductDataContext)((function(e){var t=e.className,r=Object(l.useInnerBlockLayoutContext)().parentClassName,n=Object(l.useProductDataContext)().product,i=b(n);if(!i)return null;var u={width:i/5*100+"%"},p=Object(a.sprintf)(
|
| 16 |
/* translators: %f is referring to the average rating value */
|
| 17 |
+
Object(a.__)("Rated %f out of 5","woo-gutenberg-products-block"),i);return Object(o.createElement)("div",{className:s()(t,"wc-block-components-product-rating",c()({},"".concat(r,"__product-rating"),r))},Object(o.createElement)("div",{className:s()("wc-block-components-product-rating__stars","".concat(r,"__product-rating__stars")),role:"img","aria-label":p},Object(o.createElement)("span",{style:u},p)))}))},484:function(e,t,r){"use strict";r.r(t);var n=r(9),c=r.n(n),o=r(5),a=r.n(o),i=r(0),s=(r(2),r(6)),l=r.n(s),u=r(1),b=r(68),p=r(788),d=r(25),f=r(45),m=r(86),O=(r(560),function(e){var t=e.product,r=t.id,n=t.permalink,o=t.add_to_cart,a=t.has_options,s=t.is_purchasable,f=t.is_in_stock,m=Object(b.a)().dispatchStoreEvent,O=Object(p.a)(r),g=O.cartQuantity,j=O.addingToCart,h=O.addToCart,v=Number.isFinite(g)&&g>0,w=!a&&s&&f,y=Object(d.decodeEntities)((null==o?void 0:o.description)||""),E=v?Object(u.sprintf)(
|
| 18 |
/* translators: %s number of products in cart. */
|
| 19 |
+
Object(u._n)("%d in cart","%d in cart",g,"woo-gutenberg-products-block"),g):Object(d.decodeEntities)((null==o?void 0:o.text)||Object(u.__)("Add to cart","woo-gutenberg-products-block")),_=w?"button":"a",k={};return w?k.onClick=function(){h(),m("cart-add-item",{product:t})}:(k.href=n,k.rel="nofollow",k.onClick=function(){m("product-view-link",{product:t})}),Object(i.createElement)(_,c()({"aria-label":y,className:l()("wp-block-button__link","add_to_cart_button","wc-block-components-product-button__button",{loading:j,added:v}),disabled:j},k),E)}),g=function(){return Object(i.createElement)("button",{className:l()("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)((function(e){var t=e.className,r=Object(f.useInnerBlockLayoutContext)().parentClassName,n=Object(f.useProductDataContext)().product;return Object(i.createElement)("div",{className:l()(t,"wp-block-button","wc-block-components-product-button",a()({},"".concat(r,"__product-add-to-cart"),r))},n.id?Object(i.createElement)(O,{product:n}):Object(i.createElement)(g,null))}))},486:function(e,t,r){"use strict";r.r(t);var n=r(5),c=r.n(n),o=r(0),a=(r(2),r(6)),i=r.n(a),s=r(155),l=r(38),u=r(45),b=r(86);r(561),t.default=Object(b.withProductDataContext)((function(e){var t=e.className,r=Object(u.useInnerBlockLayoutContext)().parentClassName,n=Object(u.useProductDataContext)().product;if(!n)return Object(o.createElement)("div",{className:i()(t,"wc-block-components-product-summary",c()({},"".concat(r,"__product-summary"),r))});var a=n.short_description?n.short_description:n.description;return a?Object(o.createElement)(s.a,{className:i()(t,"wc-block-components-product-summary",c()({},"".concat(r,"__product-summary"),r)),source:a,maxLength:150,countType:l.o.wordCountType||"words"}):null}))},487:function(e,t,r){"use strict";r.r(t);var n=r(5),c=r.n(n),o=r(0),a=r(1),i=(r(2),r(6)),s=r.n(i),l=r(45),u=r(86);r(562),t.default=Object(u.withProductDataContext)((function(e){var t=e.className,r=Object(l.useInnerBlockLayoutContext)().parentClassName,n=Object(l.useProductDataContext)().product.sku;return n?Object(o.createElement)("div",{className:s()(t,"wc-block-components-product-sku",c()({},"".concat(r,"__product-sku"),r))},Object(a.__)("SKU:","woo-gutenberg-products-block")," ",Object(o.createElement)("strong",null,n)):null}))},488:function(e,t,r){"use strict";r.r(t);var n=r(5),c=r.n(n),o=r(0),a=r(1),i=(r(2),r(6)),s=r.n(i),l=r(45),u=r(7),b=r(86);r(563),t.default=Object(b.withProductDataContext)((function(e){var t=e.className,r=Object(l.useInnerBlockLayoutContext)().parentClassName,n=Object(l.useProductDataContext)().product;return Object(u.isEmpty)(n.categories)?null:Object(o.createElement)("div",{className:s()(t,"wc-block-components-product-category-list",c()({},"".concat(r,"__product-category-list"),r))},Object(a.__)("Categories:","woo-gutenberg-products-block")," ",Object(o.createElement)("ul",null,Object.values(n.categories).map((function(e){var t=e.name,r=e.link,n=e.slug;return Object(o.createElement)("li",{key:"category-list-item-".concat(n)},Object(o.createElement)("a",{href:r},t))}))))}))},489:function(e,t,r){"use strict";r.r(t);var n=r(5),c=r.n(n),o=r(0),a=r(1),i=(r(2),r(6)),s=r.n(i),l=r(45),u=r(7),b=r(86);r(564),t.default=Object(b.withProductDataContext)((function(e){var t=e.className,r=Object(l.useInnerBlockLayoutContext)().parentClassName,n=Object(l.useProductDataContext)().product;return Object(u.isEmpty)(n.tags)?null:Object(o.createElement)("div",{className:s()(t,"wc-block-components-product-tag-list",c()({},"".concat(r,"__product-tag-list"),r))},Object(a.__)("Tags:","woo-gutenberg-products-block")," ",Object(o.createElement)("ul",null,Object.values(n.tags).map((function(e){var t=e.name,r=e.link,n=e.slug;return Object(o.createElement)("li",{key:"tag-list-item-".concat(n)},Object(o.createElement)("a",{href:r},t))}))))}))},490:function(e,t,r){"use strict";r.r(t);var n=r(5),c=r.n(n),o=r(0),a=r(1),i=(r(2),r(6)),s=r.n(i),l=r(45),u=r(86),b=(r(565),function(e){return Object(a.sprintf)(
|
| 20 |
/* translators: %d stock amount (number of items in stock for product) */
|
| 21 |
+
Object(a.__)("%d left in stock","woo-gutenberg-products-block"),e)});t.default=Object(u.withProductDataContext)((function(e){var t,r=e.className,n=Object(l.useInnerBlockLayoutContext)().parentClassName,i=Object(l.useProductDataContext)().product;if(!i.id||!i.is_purchasable)return null;var u=!!i.is_in_stock,p=i.low_stock_remaining,d=i.is_on_backorder;return Object(o.createElement)("div",{className:s()(r,"wc-block-components-product-stock-indicator",(t={},c()(t,"".concat(n,"__stock-indicator"),n),c()(t,"wc-block-components-product-stock-indicator--in-stock",u),c()(t,"wc-block-components-product-stock-indicator--out-of-stock",!u),c()(t,"wc-block-components-product-stock-indicator--low-stock",!!p),c()(t,"wc-block-components-product-stock-indicator--available-on-backorder",!!d),t))},p?b(p):function(e,t){return t?Object(a.__)("Available on backorder","woo-gutenberg-products-block"):e?Object(a.__)("In Stock","woo-gutenberg-products-block"):Object(a.__)("Out of Stock","woo-gutenberg-products-block")}(u,d))}))},50:function(e,t,r){"use strict";r.d(t,"a",(function(){return s})),r.d(t,"b",(function(){return l})),r.d(t,"c",(function(){return b}));var n,c,o=r(72);!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={}));var a=function(e,t){return Object(o.b)(e)&&"type"in e&&e.type===t},i=function(e){return a(e,n.SUCCESS)},s=function(e){return a(e,n.ERROR)},l=function(e){return a(e,n.FAIL)},u=function(e){return!Object(o.b)(e)||void 0===e.retry||!0===e.retry},b=function(){return{responseTypes:n,noticeContexts:c,shouldRetry:u,isSuccessResponse:i,isErrorResponse:s,isFailResponse:l}}},52:function(e,t,r){"use strict";var n=r(0),c=r(1),o=(r(2),r(48));t.a=function(e){var t,r,a,i=e.error;return Object(n.createElement)("div",{className:"wc-block-error-message"},(r=(t=i).message,a=t.type,r?"general"===a?Object(n.createElement)("span",null,Object(c.__)("The following error was returned","woo-gutenberg-products-block"),Object(n.createElement)("br",null),Object(n.createElement)("code",null,Object(o.escapeHTML)(r))):"api"===a?Object(n.createElement)("span",null,Object(c.__)("The following error was returned from the API","woo-gutenberg-products-block"),Object(n.createElement)("br",null),Object(n.createElement)("code",null,Object(o.escapeHTML)(r))):r:Object(c.__)("An unknown error occurred which prevented the block from being updated.","woo-gutenberg-products-block")))}},53:function(e,t,r){"use strict";var n=r(9),c=r.n(n),o=r(5),a=r.n(o),i=r(16),s=r.n(i),l=r(0),u=r(166),b=r(6),p=r.n(b),d=(r(175),["className","value","currency","onValueChange","displayType"]);function f(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?f(Object(r),!0).forEach((function(t){a()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}t.a=function(e){var t=e.className,r=e.value,n=e.currency,o=e.onValueChange,a=e.displayType,i=void 0===a?"text":a,b=s()(e,d),f="string"==typeof r?parseInt(r,10):r;if(!Number.isFinite(f))return null;var O=f/Math.pow(10,n.minorUnit);if(!Number.isFinite(O))return null;var g=p()("wc-block-formatted-money-amount","wc-block-components-formatted-money-amount",t),j=m(m(m({},b),function(e){return{thousandSeparator:e.thousandSeparator,decimalSeparator:e.decimalSeparator,decimalScale:e.minorUnit,fixedDecimalScale:!0,prefix:e.prefix,suffix:e.suffix,isNumericString:!0}}(n)),{},{value:void 0,currency:void 0,onValueChange:void 0}),h=o?function(e){var t=e.value*Math.pow(10,n.minorUnit);o(t)}:function(){};return Object(l.createElement)(u.a,c()({className:g,displayType:i},j,{value:O,onValueChange:h}))}},55:function(e,t){e.exports=window.wp.hooks},556:function(e,t){},557:function(e,t){},558:function(e,t){},559:function(e,t){},56:function(e,t){e.exports=window.wp.deprecated},560:function(e,t){},561:function(e,t){},562:function(e,t){},563:function(e,t){},564:function(e,t){},565:function(e,t){},566:function(e,t){},567:function(e,t,r){"use strict";var n=r(0),c=r(28),o=Object(n.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(n.createElement)("path",{fill:"none",d:"M0 0h24v24H0z"}),Object(n.createElement)("path",{d:"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"}));t.a=o},59:function(e,t,r){"use strict";r.d(t,"a",(function(){return l}));var n=r(5),c=r.n(n),o=r(0),a=r(141);function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var l=function(){var e=Object(a.b)(),t=e.notices,r=e.createNotice,n=e.removeNotice,c=e.setIsSuppressed,i=Object(o.useRef)(t);Object(o.useEffect)((function(){i.current=t}),[t]);var l=Object(o.useMemo)((function(){return{hasNoticesOfType:function(e){return i.current.some((function(t){return t.type===e}))},removeNotices:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;i.current.forEach((function(t){null!==e&&t.status!==e||n(t.id)}))},removeNotice:n}}),[n]),u=Object(o.useMemo)((function(){return{addDefaultNotice:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r("default",e,s({},t))},addErrorNotice:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r("error",e,s({},t))},addWarningNotice:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r("warning",e,s({},t))},addInfoNotice:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r("info",e,s({},t))},addSuccessNotice:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r("success",e,s({},t))}}}),[r]);return s(s(s({notices:t},l),u),{},{setIsSuppressed:c})}},60:function(e,t){e.exports=window.wc.wcBlocksRegistry},62:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(0),c=r(34),o=r.n(c);function a(e){var t=Object(n.useRef)(e);return o()(e,t.current)||(t.current=e),t.current}},63:function(e,t,r){"use strict";r.d(t,"b",(function(){return a})),r.d(t,"a",(function(){return i}));var n=r(0),c=r(14),o=Object(n.createContext)({isEditor:!1,currentPostId:0,previewData:{},getPreviewData:function(){}}),a=function(){return Object(n.useContext)(o)},i=function(e){var t=e.children,r=e.currentPostId,a=void 0===r?0:r,i=e.previewData,s=void 0===i?{}:i,l=Object(c.useSelect)((function(e){return a||e("core/editor").getCurrentPostId()}),[a]),u=Object(n.useCallback)((function(e){return e in s?s[e]:{}}),[s]),b={isEditor:!0,currentPostId:l,previewData:s,getPreviewData:u};return Object(n.createElement)(o.Provider,{value:b},t)}},64:function(e,t){e.exports=window.wp.a11y},66:function(e,t,r){"use strict";var n=r(5),c=r.n(n),o=r(16),a=r.n(o),i=r(0),s=["srcElement","size"];function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}t.a=function(e){var t=e.srcElement,r=e.size,n=void 0===r?24:r,o=a()(e,s);return Object(i.isValidElement)(t)?Object(i.cloneElement)(t,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({width:n,height:n},o)):null}},68:function(e,t,r){"use strict";r.d(t,"a",(function(){return u}));var n=r(5),c=r.n(n),o=r(55),a=r(0),i=r(43);function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var u=function(){var e=Object(i.a)(),t=Object(a.useRef)(e);return Object(a.useEffect)((function(){t.current=e}),[e]),{dispatchStoreEvent:Object(a.useCallback)((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(o.doAction)("experimental__woocommerce_blocks-".concat(e),t)}catch(e){console.error(e)}}),[]),dispatchCheckoutEvent:Object(a.useCallback)((function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(o.doAction)("experimental__woocommerce_blocks-checkout-".concat(e),l(l({},r),{},{storeCart:t.current}))}catch(e){console.error(e)}}),[])}}},7:function(e,t){e.exports=window.lodash},72:function(e,t,r){"use strict";r.d(t,"a",(function(){return o})),r.d(t,"c",(function(){return a})),r.d(t,"b",(function(){return i})),r.d(t,"d",(function(){return s}));var n=r(37),c=r.n(n),o=function(e){return"number"==typeof e},a=function(e){return"string"==typeof e},i=function(e){return!function(e){return null===e}(e)&&"object"===c()(e)};function s(e,t){return i(e)&&t in e}},74:function(e,t){e.exports=window.wp.dom},757:function(e,t,r){"use strict";var n=r(0),c=r(28),o=Object(n.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(n.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(n.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=o},764:function(e,t,r){"use strict";var n=r(0),c=r(28),o=Object(n.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(n.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(n.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(n.createElement)("circle",{cx:"6.5",cy:"6.5",r:"1.5"}),Object(n.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=o},772:function(e,t,r){"use strict";var n=r(0),c=r(28),o=Object(n.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(n.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(n.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=o},773:function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(1),c=r(38),o=[{id:1,name:"WordPress Pennant",variation:"",permalink:"https://example.org",sku:"wp-pennant",short_description:Object(n.__)("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:c.m+"previews/pennant.jpg",thumbnail:c.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(n.__)("Add to cart","woo-gutenberg-products-block"),description:Object(n.__)("Add to cart","woo-gutenberg-products-block")},has_options:!1,is_purchasable:!0,is_in_stock:!0,on_sale:!0}]},778:function(e,t,r){"use strict";var n=r(0),c=r(28),o=Object(n.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(n.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(n.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=o},78:function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(0),c=Object(n.createContext)("page"),o=function(){return Object(n.useContext)(c)};c.Provider},785:function(e,t,r){e.exports=r(852)},786:function(e,t){},787:function(e,t){},788:function(e,t,r){"use strict";r.d(t,"a",(function(){return p}));var n=r(8),c=r.n(n),o=r(0),a=r(14),i=r(24),s=r(25),l=r(43),u=r(59),b=function(e,t){var r=e.find((function(e){return e.id===t}));return r?r.quantity:0},p=function(e){var t=Object(a.useDispatch)(i.CART_STORE_KEY).addItemToCart,r=Object(l.a)(),n=r.cartItems,p=r.cartIsLoading,d=Object(u.a)(),f=d.addErrorNotice,m=d.removeNotice,O=Object(o.useState)(!1),g=c()(O,2),j=g[0],h=g[1],v=Object(o.useRef)(b(n,e));return Object(o.useEffect)((function(){var t=b(n,e);t!==v.current&&(v.current=t)}),[n,e]),{cartQuantity:Number.isFinite(v.current)?v.current:0,addingToCart:j,cartIsLoading:p,addToCart:function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return h(!0),t(e,r).then((function(){m("add-to-cart")})).catch((function(e){f(Object(s.decodeEntities)(e.message),{context:"wc/all-products",id:"add-to-cart",isDismissible:!0})})).finally((function(){h(!1)}))}}}},789:function(e,t,r){"use strict";var n=r(0),c=r(28),o=Object(n.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16"},Object(n.createElement)("g",{fill:"none",fillRule:"evenodd"},Object(n.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(n.createElement)("path",{fill:"currentColor",d:"M12 6H4V4.75h8zM12 9H4V7.75h8zM10 12H4v-1.25h6z"})));t.a=o},790:function(e,t){},791:function(e,t){},792:function(e,t){},793:function(e,t){},852:function(e,t,r){"use strict";r.r(t),r.d(t,"blockSettings",(function(){return Br}));var n=r(5),c=r.n(n),o=r(9),a=r.n(o),i=r(0),s=r(1),l=r(12),u=r(26),b=r(66),p=r(28),d=Object(i.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(i.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(i.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"})),f=r(159),m=r(6),O=r.n(m),g={category:"woocommerce-product-elements",keywords:[Object(s.__)("WooCommerce","woo-gutenberg-products-block")],icon:{src:Object(i.createElement)(b.a,{srcElement:d}),foreground:"#96588a"},supports:{html:!1},parent:Object(f.a)()?null:["@woocommerce/all-products","@woocommerce/single-product"],save:function(e){var t=e.attributes;return Object(i.createElement)("div",{className:O()("is-loading",t.className)})},deprecated:[{save:function(){}}]},j=r(373),h=r(4),v=r(21),w=r(133),y=r(378),E=r(8),_=r.n(E),k=r(149),P=r(16),C=r.n(P),S=(r(787),["className"]),x=function(e){var t=e.className,r=void 0===t?"":t,n=C()(e,S),c=O()("wc-block-text-toolbar-button",r);return Object(i.createElement)(h.Button,a()({className:c},n))},N=r(45),D=(r(786),function(e){return function(t){return function(r){var n=Object(N.useProductDataContext)(),c=r.attributes,o=r.setAttributes,a=c.productId,u=Object(i.useState)(!a),b=_()(u,2),p=b[0],d=b[1];return n.hasContext?Object(i.createElement)(t,r):Object(i.createElement)(i.Fragment,null,p?Object(i.createElement)(h.Placeholder,{icon:e.icon||"",label:e.label||"",className:"wc-atomic-blocks-product"},!!e.description&&Object(i.createElement)("div",null,e.description),Object(i.createElement)("div",{className:"wc-atomic-blocks-product__selection"},Object(i.createElement)(k.a,{selected:a||0,showVariations:!0,onChange:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];o({productId:e[0]?e[0].id:0})}}),Object(i.createElement)(h.Button,{isSecondary:!0,disabled:!a,onClick:function(){d(!1)}},Object(s.__)("Done","woo-gutenberg-products-block")))):Object(i.createElement)(i.Fragment,null,Object(i.createElement)(l.BlockControls,null,Object(i.createElement)(h.ToolbarGroup,null,Object(i.createElement)(x,{onClick:function(){return d(!0)}},Object(s.__)("Switch product…","woo-gutenberg-products-block")))),Object(i.createElement)(t,r)))}}}),B=Object(i.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(i.createElement)("path",{fill:"none",d:"M0 0h24v24H0z"}),Object(i.createElement)("path",{d:"M17 3H7a2 2 0 00-2 2v16l7-3 7 3V5a2 2 0 00-2-2z"})),R=Object(s.__)("Product Title","woo-gutenberg-products-block"),T=Object(i.createElement)(b.a,{srcElement:B}),A=Object(s.__)("Display the title of a product.","woo-gutenberg-products-block"),I=function(e){var t=e.color,r=e.fontSize,n=e.setFontSize,c=e.setColor,o=e.attributes,a=e.setAttributes,u=o.headingLevel,b=o.showProductLink,p=o.align;return Object(i.createElement)(i.Fragment,null,Object(i.createElement)(l.BlockControls,null,Object(i.createElement)(w.a,{isCollapsed:!0,minLevel:1,maxLevel:7,selectedLevel:u,onChange:function(e){return a({headingLevel:e})}}),Object(f.b)()&&Object(i.createElement)(l.AlignmentToolbar,{value:p,onChange:function(e){a({align:e})}})),Object(i.createElement)(l.InspectorControls,null,Object(i.createElement)(h.PanelBody,{title:Object(s.__)("Content","woo-gutenberg-products-block")},Object(i.createElement)(h.ToggleControl,{label:Object(s.__)("Link to Product Page","woo-gutenberg-products-block"),help:Object(s.__)("Links the image to the single product listing.","woo-gutenberg-products-block"),checked:b,onChange:function(){return a({showProductLink:!b})}})),Object(f.b)()&&Object(i.createElement)(i.Fragment,null,Object(i.createElement)(h.PanelBody,{title:Object(s.__)("Text settings","woo-gutenberg-products-block")},Object(i.createElement)(l.FontSizePicker,{value:r.size,onChange:n})),Object(i.createElement)(l.PanelColorSettings,{title:Object(s.__)("Color settings","woo-gutenberg-products-block"),colorSettings:[{value:t.color,onChange:c,label:Object(s.__)("Text color","woo-gutenberg-products-block")}]}))),Object(i.createElement)(h.Disabled,null,Object(i.createElement)(y.a,o)))},L=Object(f.b)()?Object(v.compose)([Object(l.withFontSizes)("fontSize"),Object(l.withColors)("color",{textColor:"color"}),D({icon:T,label:R,description:Object(s.__)("Choose a product to display its title.","woo-gutenberg-products-block")})])(I):I;function z(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function V(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?z(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):z(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var F={title:R,description:A,icon:{src:T,foreground:"#874FB9"},attributes:j.a,edit:L};Object(u.registerBlockType)("woocommerce/product-title",V(V({},g),F));var M=r(482),H=r(303),q=Object(s.__)("Product Price","woo-gutenberg-products-block"),G=Object(i.createElement)(b.a,{srcElement:H.a}),Q=Object(s.__)("Display the price of a product.","woo-gutenberg-products-block"),Y=function(e){var t=e.fontSize,r=e.setFontSize,n=e.color,c=e.setColor,o=e.colorLabel;return Object(i.createElement)(i.Fragment,null,Object(i.createElement)(l.FontSizePicker,{value:t.size,onChange:r}),Object(i.createElement)(h.BaseControl,{label:o},Object(i.createElement)(l.ColorPalette,{value:n.color,onChange:c,label:Object(s.__)("Color")})))},U=function(e){var t=e.fontSize,r=e.saleFontSize,n=e.setFontSize,c=e.setSaleFontSize,o=e.color,a=e.saleColor,u=e.setColor,b=e.setSaleColor,p=e.attributes,d=e.setAttributes,m=p.align;return Object(i.createElement)(i.Fragment,null,Object(f.b)()&&Object(i.createElement)(l.BlockControls,null,Object(i.createElement)(l.AlignmentToolbar,{value:m,onChange:function(e){d({align:e})}})),Object(i.createElement)(l.InspectorControls,null,Object(f.b)()&&Object(i.createElement)(i.Fragment,null,Object(i.createElement)(h.PanelBody,{title:Object(s.__)("Price","woo-gutenberg-products-block")},Object(i.createElement)(Y,{color:o,setColor:u,fontSize:t,setFontSize:n,colorLabel:Object(s.__)("Color","woo-gutenberg-products-block")})),Object(i.createElement)(h.PanelBody,{title:Object(s.__)("Sale price","woo-gutenberg-products-block")},Object(i.createElement)(Y,{color:a,setColor:b,fontSize:r,setFontSize:c,colorLabel:Object(s.__)("Color","woo-gutenberg-products-block")})))),Object(i.createElement)(M.default,p))},W=Object(f.b)()?Object(v.compose)([Object(l.withFontSizes)("fontSize"),Object(l.withFontSizes)("saleFontSize"),Object(l.withFontSizes)("originalFontSize"),Object(l.withColors)("color",{textColor:"color"}),Object(l.withColors)("saleColor",{textColor:"saleColor"}),Object(l.withColors)("originalColor",{textColor:"originalColor"}),D({icon:G,label:q,description:Object(s.__)("Choose a product to display its price.","woo-gutenberg-products-block")})])(U):U;function K(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function $(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?K(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):K(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var J={productId:{type:"number",default:0}};function X(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Z(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?X(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):X(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}Object(f.b)()&&(J=$($({},J),{},{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"}}));var ee={title:q,description:Q,icon:{src:G,foreground:"#874FB9"},attributes:J,edit:W};Object(u.registerBlockType)("woocommerce/product-price",Z(Z({},g),ee));var te=r(374),re=r(88),ne=r(3),ce=r(375),oe=Object(i.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(i.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(i.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"})),ae=Object(s.__)("Product Image","woo-gutenberg-products-block"),ie=Object(i.createElement)(b.a,{srcElement:oe}),se=Object(s.__)("Display the main product image","woo-gutenberg-products-block"),le=D({icon:ie,label:ae,description:Object(s.__)("Choose a product to display its image.","woo-gutenberg-products-block")})((function(e){var t=e.attributes,r=e.setAttributes,n=t.showProductLink,c=t.imageSizing,o=t.showSaleBadge,a=t.saleBadgeAlign;return Object(i.createElement)(i.Fragment,null,Object(i.createElement)(l.InspectorControls,null,Object(i.createElement)(h.PanelBody,{title:Object(s.__)("Content","woo-gutenberg-products-block")},Object(i.createElement)(h.ToggleControl,{label:Object(s.__)("Link to Product Page","woo-gutenberg-products-block"),help:Object(s.__)("Links the image to the single product listing.","woo-gutenberg-products-block"),checked:n,onChange:function(){return r({showProductLink:!n})}}),Object(i.createElement)(h.ToggleControl,{label:Object(s.__)("Show On-Sale Badge","woo-gutenberg-products-block"),help:Object(s.__)('Overlay a "sale" badge if the product is on-sale.',"woo-gutenberg-products-block"),checked:o,onChange:function(){return r({showSaleBadge:!o})}}),o&&Object(i.createElement)(re.a,{label:Object(s.__)("Sale Badge Alignment","woo-gutenberg-products-block"),value:a,options:[{label:Object(s.__)("Left","woo-gutenberg-products-block"),value:"left"},{label:Object(s.__)("Center","woo-gutenberg-products-block"),value:"center"},{label:Object(s.__)("Right","woo-gutenberg-products-block"),value:"right"}],onChange:function(e){return r({saleBadgeAlign:e})}}),Object(i.createElement)(re.a,{label:Object(s.__)("Image Sizing","woo-gutenberg-products-block"),help:Object(i.createInterpolateElement)(Object(s.__)("Product image cropping can be modified in the <a>Customizer</a>.","woo-gutenberg-products-block"),{a:Object(i.createElement)("a",{href:"".concat(Object(ne.getAdminLink)("customize.php"),"?autofocus[panel]=woocommerce&autofocus[section]=woocommerce_product_images"),target:"_blank",rel:"noopener noreferrer"})}),value:c,options:[{label:Object(s.__)("Full Size","woo-gutenberg-products-block"),value:"full-size"},{label:Object(s.__)("Cropped","woo-gutenberg-products-block"),value:"cropped"}],onChange:function(e){return r({imageSizing:e})}}))),Object(i.createElement)(h.Disabled,null,Object(i.createElement)(ce.a,t)))}));function ue(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function be(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ue(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ue(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var pe={title:ae,description:se,icon:{src:ie,foreground:"#874FB9"},attributes:te.a,edit:le};Object(u.registerBlockType)("woocommerce/product-image",be(be({},g),pe));var de=r(483),fe=r(772),me=Object(s.__)("Product Rating","woo-gutenberg-products-block"),Oe=Object(i.createElement)(b.a,{srcElement:fe.a});function ge(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function je(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ge(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ge(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var he={title:me,description:Object(s.__)("Display the average rating of a product.","woo-gutenberg-products-block"),icon:{src:Oe,foreground:"#874FB9"},attributes:{productId:{type:"number",default:0}},edit:D({icon:Oe,label:me,description:Object(s.__)("Choose a product to display its rating.","woo-gutenberg-products-block")})((function(e){var t=e.attributes;return Object(i.createElement)(de.default,t)}))};Object(u.registerBlockType)("woocommerce/product-rating",je(je({},g),he));var ve=r(484),we=r(361),ye=Object(s.__)("Add to Cart Button","woo-gutenberg-products-block"),Ee=Object(i.createElement)(b.a,{srcElement:we.a});function _e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ke(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?_e(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_e(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Pe={title:ye,description:Object(s.__)("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:Ee,foreground:"#874FB9"},attributes:{productId:{type:"number",default:0}},edit:D({icon:Ee,label:ye,description:Object(s.__)("Choose a product to display its add to cart button.","woo-gutenberg-products-block")})((function(e){var t=e.attributes;return Object(i.createElement)(h.Disabled,null,Object(i.createElement)(ve.default,t))}))};Object(u.registerBlockType)("woocommerce/product-button",ke(ke({},g),Pe));var Ce=r(486),Se=r(789),xe=Object(s.__)("Product Summary","woo-gutenberg-products-block"),Ne=Object(i.createElement)(b.a,{srcElement:Se.a});function De(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Be(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?De(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):De(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Re={title:xe,description:Object(s.__)("Display a short description about a product.","woo-gutenberg-products-block"),icon:{src:Ne,foreground:"#874FB9"},attributes:{productId:{type:"number",default:0}},edit:D({icon:Ne,label:xe,description:Object(s.__)("Choose a product to display its short description.","woo-gutenberg-products-block")})((function(e){var t=e.attributes;return Object(i.createElement)(Ce.default,t)}))};Object(u.registerBlockType)("woocommerce/product-summary",Be(Be({},g),Re));var Te=r(304),Ae=r(764),Ie=Object(s.__)("On-Sale Badge","woo-gutenberg-products-block"),Le=Object(i.createElement)(b.a,{srcElement:Ae.a});function ze(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Ve(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ze(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ze(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Fe={title:Ie,description:Object(s.__)("Displays an on-sale badge if the product is on-sale.","woo-gutenberg-products-block"),icon:{src:Le,foreground:"#874FB9"},supports:{html:!1},attributes:{productId:{type:"number",default:0}},edit:D({icon:Le,label:Ie,description:Object(s.__)("Choose a product to display its sale-badge.","woo-gutenberg-products-block")})((function(e){var t=e.attributes;return Object(i.createElement)(Te.default,t)}))};Object(u.registerBlockType)("woocommerce/product-sale-badge",Ve(Ve({},g),Fe));var Me=r(143),He=r(487),qe=Object(i.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(i.createElement)("path",{d:"M2 6h2v12H2V6m3 0h1v12H5V6m2 0h3v12H7V6m4 0h1v12h-1V6m3 0h2v12h-2V6m3 0h3v12h-3V6m4 0h1v12h-1V6z"})),Ge=Object(s.__)("Product SKU","woo-gutenberg-products-block"),Qe=Object(i.createElement)(b.a,{srcElement:qe});function Ye(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Ue(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ye(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ye(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var We={title:Ge,description:Object(s.__)("Display the SKU of a product.","woo-gutenberg-products-block"),icon:{src:Qe,foreground:"#874FB9"},attributes:{productId:{type:"number",default:0}},edit:D({icon:Qe,label:Ge,description:Object(s.__)("Choose a product to display its SKU.","woo-gutenberg-products-block")})((function(e){var t=e.attributes;return Object(i.createElement)(i.Fragment,null,Object(i.createElement)(Me.a,null),Object(i.createElement)(He.default,t))}))};Object(f.c)("woocommerce/product-sku",Ue(Ue({},g),We));var Ke=r(488),$e=r(757),Je=Object(s.__)("Product Category List","woo-gutenberg-products-block"),Xe=Object(i.createElement)(b.a,{srcElement:$e.a});function Ze(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function et(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ze(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ze(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var tt={title:Je,description:Object(s.__)("Display a list of categories belonging to a product.","woo-gutenberg-products-block"),icon:{src:Xe,foreground:"#874FB9"},attributes:{productId:{type:"number",default:0}},edit:D({icon:Xe,label:Je,description:Object(s.__)("Choose a product to display its categories.","woo-gutenberg-products-block")})((function(e){var t=e.attributes;return Object(i.createElement)(i.Fragment,null,Object(i.createElement)(Me.a,null),Object(i.createElement)(h.Disabled,null,Object(i.createElement)(Ke.default,t)))}))};Object(f.c)("woocommerce/product-category-list",et(et({},g),tt));var rt=r(489),nt=Object(s.__)("Product Tag List","woo-gutenberg-products-block"),ct=Object(i.createElement)(b.a,{srcElement:Ae.a});function ot(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function at(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ot(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ot(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var it={title:nt,description:Object(s.__)("Display a list of tags belonging to a product.","woo-gutenberg-products-block"),icon:{src:ct,foreground:"#874FB9"},attributes:{productId:{type:"number",default:0}},edit:D({icon:ct,label:nt,description:Object(s.__)("Choose a product to display its tags.","woo-gutenberg-products-block")})((function(e){var t=e.attributes;return Object(i.createElement)(i.Fragment,null,Object(i.createElement)(Me.a,null),Object(i.createElement)(h.Disabled,null,Object(i.createElement)(rt.default,t)))}))};Object(f.c)("woocommerce/product-tag-list",at(at({},g),it));var st=r(490),lt=Object(i.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(i.createElement)("g",{fillRule:"evenodd"},Object(i.createElement)("path",{d:"M0 0h24v24H0z",fill:"none"}),Object(i.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"}))),ut=Object(s.__)("Product Stock Indicator","woo-gutenberg-products-block"),bt=Object(i.createElement)(b.a,{srcElement:lt});function pt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function dt(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?pt(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):pt(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var ft={title:ut,description:Object(s.__)("Display product stock status.","woo-gutenberg-products-block"),icon:{src:bt,foreground:"#874FB9"},attributes:{productId:{type:"number",default:0}},edit:D({icon:bt,label:ut,description:Object(s.__)("Choose a product to display its stock.","woo-gutenberg-products-block")})((function(e){var t=e.attributes;return Object(i.createElement)(i.Fragment,null,Object(i.createElement)(Me.a,null),Object(i.createElement)(st.default,t))}))};Object(f.c)("woocommerce/product-stock-indicator",dt(dt({},g),ft));var mt=r(879),Ot=(r(372),r(377)),gt=Object(s.__)("Add to Cart","woo-gutenberg-products-block"),jt=Object(i.createElement)(b.a,{srcElement:we.a});function ht(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function vt(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ht(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ht(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var wt={title:gt,description:Object(s.__)("Displays an add to cart button. Optionally displays other add to cart form elements.","woo-gutenberg-products-block"),icon:{src:jt,foreground:"#874FB9"},edit:D({icon:jt,label:gt,description:Object(s.__)("Choose a product to display its add to cart form.","woo-gutenberg-products-block")})((function(e){var t=e.attributes,r=e.setAttributes,n=Object(N.useProductDataContext)().product,c=t.className,o=t.showFormElements;return Object(i.createElement)("div",{className:O()(c,"wc-block-components-product-add-to-cart")},Object(i.createElement)(Me.a,{productId:n.id}),Object(i.createElement)(l.InspectorControls,null,Object(i.createElement)(h.PanelBody,{title:Object(s.__)("Layout","woo-gutenberg-products-block")},Object(mt.b)(n)?Object(i.createElement)(h.ToggleControl,{label:Object(s.__)("Display form elements","woo-gutenberg-products-block"),help:Object(s.__)("Depending on product type, allow customers to select a quantity, variations etc.","woo-gutenberg-products-block"),checked:o,onChange:function(){return r({showFormElements:!o})}}):Object(i.createElement)(h.Notice,{className:"wc-block-components-product-add-to-cart-notice",isDismissible:!1,status:"info"},Object(s.__)("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(i.createElement)(h.Disabled,null,Object(i.createElement)(Ot.a,t)))})),attributes:r(376).a};Object(f.c)("woocommerce/product-add-to-cart",vt(vt({},g),wt));var yt=r(17),Et=r.n(yt),_t=r(13),kt=r.n(_t),Pt=r(19),Ct=r.n(Pt),St=r(20),xt=r.n(St),Nt=r(10),Dt=r.n(Nt),Bt=r(14),Rt=(r(2),r(94)),Tt=r(877),At=r(773),It=r(38),Lt=function(e,t){var r=t.className,n=t.contentVisibility;return O()(e,r,{"has-image":n&&n.image,"has-title":n&&n.title,"has-rating":n&&n.rating,"has-price":n&&n.price,"has-button":n&&n.button})},zt=r(158),Vt=function(e,t){return Object(i.createElement)(h.Placeholder,{className:"wc-block-products",icon:t,label:e},Object(i.createElement)("p",null,Object(s.__)("You haven't published any products to list here yet.","woo-gutenberg-products-block")),Object(i.createElement)(h.Button,{className:"wc-block-products__add-product-button",isSecondary:!0,href:ne.ADMIN_URL+"post-new.php?post_type=product"},Object(s.__)("Add new product","woo-gutenberg-products-block")+" ",Object(i.createElement)(b.a,{srcElement:zt.a})),Object(i.createElement)(h.Button,{className:"wc-block-products__read_more_button",isTertiary:!0,href:"https://docs.woocommerce.com/document/managing-products/"},Object(s.__)("Learn more","woo-gutenberg-products-block")))},Ft=function(e,t){return Object(i.createElement)(h.Placeholder,{className:"wc-block-products",icon:t,label:e},Object(s.__)("The content for this block is hidden due to block settings.","woo-gutenberg-products-block"))};function Mt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Ht(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Mt(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Mt(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var qt=[["woocommerce/product-image"],["woocommerce/product-title"],["woocommerce/product-price"],["woocommerce/product-rating"],["woocommerce/product-button"]],Gt=function e(t){return t&&0!==t.length?t.map((function(t){return[t.name,Ht(Ht({},t.attributes),{},{product:void 0,children:t.innerBlocks.length>0?e(t.innerBlocks):[]})]})):[]};function Qt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Yt(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Qt(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Qt(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Ut=function(e,t){var r=e.contentVisibility;return Object(i.createElement)(h.ToggleControl,{label:Object(s.__)("Show Sorting Dropdown","woo-gutenberg-products-block"),checked:r.orderBy,onChange:function(){return t({contentVisibility:Yt(Yt({},r),{},{orderBy:!r.orderBy})})}})},Wt=function(e,t){return Object(i.createElement)(h.SelectControl,{label:Object(s.__)("Order Products By","woo-gutenberg-products-block"),value:e.orderby,options:[{label:Object(s.__)("Default sorting (menu order)","woo-gutenberg-products-block"),value:"menu_order"},{label:Object(s.__)("Popularity","woo-gutenberg-products-block"),value:"popularity"},{label:Object(s.__)("Average rating","woo-gutenberg-products-block"),value:"rating"},{label:Object(s.__)("Latest","woo-gutenberg-products-block"),value:"date"},{label:Object(s.__)("Price: low to high","woo-gutenberg-products-block"),value:"price"},{label:Object(s.__)("Price: high to low","woo-gutenberg-products-block"),value:"price-desc"}],onChange:function(e){return t({orderby:e})}})},Kt=r(18),$t=r.n(Kt),Jt=r(11),Xt=r(7),Zt=r(41),er=(r(793),function(e){var t=e.currentPage,r=e.displayFirstAndLastPages,n=e.displayNextAndPreviousArrows,c=e.pagesToDisplay,o=e.onPageChange,a=e.totalPages,l=function(e,t,r){if(r<=2)return{minIndex:null,maxIndex:null};var n=e-1,c=Math.max(Math.floor(t-n/2),2),o=Math.min(Math.ceil(t+(n-(t-c))),r-1);return{minIndex:Math.max(Math.floor(t-(n-(o-t))),2),maxIndex:o}}(c,t,a),u=l.minIndex,b=l.maxIndex,p=r&&Boolean(1!==u),d=r&&Boolean(b!==a),f=r&&Boolean(u>3),m=r&&Boolean(b<a-2);p&&3===u&&(u-=1),d&&b===a-2&&(b+=1);var g=[];if(u&&b)for(var j=u;j<=b;j++)g.push(j);return Object(i.createElement)("div",{className:"wc-block-pagination wc-block-components-pagination"},Object(i.createElement)(Zt.a,{screenReaderLabel:Object(s.__)("Navigate to another page","woo-gutenberg-products-block")}),n&&Object(i.createElement)("button",{className:"wc-block-pagination-page wc-block-components-pagination__page wc-block-components-pagination-page--arrow",onClick:function(){return o(t-1)},title:Object(s.__)("Previous page","woo-gutenberg-products-block"),disabled:t<=1},Object(i.createElement)(Zt.a,{label:"←",screenReaderLabel:Object(s.__)("Previous page","woo-gutenberg-products-block")})),p&&Object(i.createElement)("button",{className:O()("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:function(){return o(1)},disabled:1===t},Object(i.createElement)(Zt.a,{label:1,screenReaderLabel:Object(s.sprintf)(
|
| 22 |
/* translators: %d is the page number (1, 2, 3...). */
|
| 23 |
+
Object(s.__)("Page %d","woo-gutenberg-products-block"),1)})),f&&Object(i.createElement)("span",{className:"wc-block-pagination-ellipsis wc-block-components-pagination__ellipsis","aria-hidden":"true"},Object(s.__)("…","woo-gutenberg-products-block")),g.map((function(e){return Object(i.createElement)("button",{key:e,className:O()("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:function(){return o(e)},disabled:t===e},Object(i.createElement)(Zt.a,{label:e,screenReaderLabel:Object(s.sprintf)(
|
| 24 |
/* translators: %d is the page number (1, 2, 3...). */
|
| 25 |
+
Object(s.__)("Page %d","woo-gutenberg-products-block"),e)}))})),m&&Object(i.createElement)("span",{className:"wc-block-pagination-ellipsis wc-block-components-pagination__ellipsis","aria-hidden":"true"},Object(s.__)("…","woo-gutenberg-products-block")),d&&Object(i.createElement)("button",{className:O()("wc-block-pagination-page","wc-block-components-pagination__page",{"wc-block-pagination-page--active":t===a,"wc-block-components-pagination__page--active":t===a}),onClick:function(){return o(a)},disabled:t===a},Object(i.createElement)(Zt.a,{label:a,screenReaderLabel:Object(s.sprintf)(
|
| 26 |
/* translators: %d is the page number (1, 2, 3...). */
|
| 27 |
+
Object(s.__)("Page %d","woo-gutenberg-products-block"),a)})),n&&Object(i.createElement)("button",{className:"wc-block-pagination-page wc-block-components-pagination__page wc-block-components-pagination-page--arrow",onClick:function(){return o(t+1)},title:Object(s.__)("Next page","woo-gutenberg-products-block"),disabled:t>=a},Object(i.createElement)(Zt.a,{label:"→",screenReaderLabel:Object(s.__)("Next page","woo-gutenberg-products-block")})))});er.defaultProps={displayFirstAndLastPages:!0,displayNextAndPreviousArrows:!0,pagesToDisplay:3};var tr=er,rr=r(136),nr=r(108),cr=r(165),or=r(24),ar=r(62);function ir(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function sr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ir(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ir(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var lr=r(68),ur=r(277),br=r(64),pr=r(150),dr=function(){var e=Object(N.useInnerBlockLayoutContext)().parentClassName;return Object(i.createElement)("div",{className:"".concat(e,"__no-products")},Object(i.createElement)(b.a,{className:"".concat(e,"__no-products-image"),alt:"",srcElement:pr.a,size:100}),Object(i.createElement)("strong",{className:"".concat(e,"__no-products-title")},Object(s.__)("No products","woo-gutenberg-products-block")),Object(i.createElement)("p",{className:"".concat(e,"__no-products-description")},Object(s.__)("There are currently no products available to display.","woo-gutenberg-products-block")))},fr=r(778),mr=function(e){var t=e.resetCallback,r=void 0===t?function(){}:t,n=Object(N.useInnerBlockLayoutContext)().parentClassName;return Object(i.createElement)("div",{className:"".concat(n,"__no-products")},Object(i.createElement)(b.a,{className:"".concat(n,"__no-products-image"),alt:"",srcElement:fr.a,size:100}),Object(i.createElement)("strong",{className:"".concat(n,"__no-products-title")},Object(s.__)("No products found","woo-gutenberg-products-block")),Object(i.createElement)("p",{className:"".concat(n,"__no-products-description")},Object(s.__)("We were unable to find any results based on your search.","woo-gutenberg-products-block")),Object(i.createElement)("button",{onClick:r},Object(s.__)("Reset Search","woo-gutenberg-products-block")))},Or=r(156),gr=(r(792),function(e){var t=e.onChange,r=e.readOnly,n=e.value;return Object(i.createElement)(Or.a,{className:"wc-block-product-sort-select wc-block-components-product-sort-select",name:"orderby",onChange:t,options:[{key:"menu_order",label:Object(s.__)("Default sorting","woo-gutenberg-products-block")},{key:"popularity",label:Object(s.__)("Popularity","woo-gutenberg-products-block")},{key:"rating",label:Object(s.__)("Average rating","woo-gutenberg-products-block")},{key:"date",label:Object(s.__)("Latest","woo-gutenberg-products-block")},{key:"price",label:Object(s.__)("Price: low to high","woo-gutenberg-products-block")},{key:"price-desc",label:Object(s.__)("Price: high to low","woo-gutenberg-products-block")}],readOnly:r,screenReaderLabel:Object(s.__)("Order products by","woo-gutenberg-products-block"),value:n})}),jr=Object(v.withInstanceId)((function(e){var t=e.product,r=e.attributes,n=e.instanceId,c=r.layoutConfig,o=Object(N.useInnerBlockLayoutContext)(),s=o.parentClassName,l=o.parentName,u=0===Object.keys(t).length,b=O()("".concat(s,"__product"),"wc-block-layout",{"is-loading":u});return Object(i.createElement)("li",{className:b,"aria-hidden":u},function e(t,r,n,c){if(n){var o=Object(Tt.a)(t);return n.map((function(n,s){var l=_()(n,2),u=l[0],b=l[1],p=void 0===b?{}:b,d=[];p.children&&p.children.length>0&&(d=e(t,r,p.children,c));var f=o[u];if(!f)return null;var m=r.id||0,O=["layout",u,s,c,m];return Object(i.createElement)(i.Suspense,{key:O.join("_"),fallback:Object(i.createElement)("div",{className:"wc-block-placeholder"})},Object(i.createElement)(f,a()({},p,{children:d,product:r})))}))}}(l,t,c,n))})),hr=(r(791),["order","orderby","page","per_page"]);function vr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function wr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?vr(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):vr(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var yr=function(e){var t=e.totalQuery,r=e.totalProducts,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},c=n.totalQuery;return!Object(Xt.isEqual)(t,c)&&Number.isFinite(r)},Er=Object(ur.a)((function(e){var t,r=e.attributes,n=e.currentPage,c=e.onPageChange,o=e.onSortChange,a=e.sortValue,l=e.scrollToTop,u=Object(nr.b)("attributes",[]),b=_()(u,2),p=b[0],d=b[1],f=Object(nr.b)("stock_status",[]),m=_()(f,2),g=m[0],j=m[1],h=Object(nr.b)("min_price"),v=_()(h,2),w=v[0],y=v[1],E=Object(nr.b)("max_price"),k=_()(E,2),P=k[0],S=k[1],x=Object(nr.c)(function(e){var t=e.sortValue,r=e.currentPage,n=e.attributes,c=n.columns,o=n.rows;return wr(wr({},function(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:c*o,page:r})}({attributes:r,sortValue:a,currentPage:n})),D=_()(x,1)[0],B=function(e){var t={namespace:"/wc/store",resourceName:"products"},r=Object(cr.a)(sr(sr({},t),{},{query:e})),n=r.results,c=r.isLoading,o=function(e,t){var r=t.namespace,n=t.resourceName,c=t.resourceValues,o=void 0===c?[]:c,a=t.query,i=void 0===a?{}:a;if(!r||!n)throw new Error("The options object must have valid values for the namespace and the resource name properties.");var s=Object(ar.a)(i),l=Object(ar.a)(o),u=Object(Bt.useSelect)((function(e){var t=e(or.COLLECTIONS_STORE_KEY),c=["x-wp-total",r,n,s,l];return{value:t.getCollectionHeader.apply(t,c),isLoading:t.hasFinishedResolution("getCollectionHeader",c)}}),["x-wp-total",r,n,l,s]),b=u.value,p=u.isLoading;return{value:b,isLoading:void 0===p||p}}(0,sr(sr({},t),{},{query:e})).value;return{products:n,totalProducts:parseInt(o,10),productsLoading:c}}(D),R=B.products,T=B.totalProducts,A=B.productsLoading,I=Object(N.useInnerBlockLayoutContext)(),L=I.parentClassName,z=I.parentName,V=((t=D).order,t.orderby,t.page,t.per_page,C()(t,hr)||{}),F=Object(lr.a)().dispatchStoreEvent,M=Object(rr.a)({totalQuery:V,totalProducts:T},yr);Object(i.useEffect)((function(){F("product-list-render",{products:R,listName:z})}),[R,z,F]),Object(i.useEffect)((function(){Object(Xt.isEqual)(V,null==M?void 0:M.totalQuery)||(c(1),null!=M&&M.totalQuery&&function(e){Number.isFinite(e)&&(0===e?Object(br.speak)(Object(s.__)("No products found","woo-gutenberg-products-block")):Object(br.speak)(Object(s.sprintf)(
|
| 28 |
/* translators: %s is an integer higher than 0 (1, 2, 3...) */
|
| 29 |
+
Object(s._n)("%d product found","%d products found",e,"woo-gutenberg-products-block"),e)))}(T))}),[null==M?void 0:M.totalQuery,T,c,V]);var H,q,G,Q,Y,U=r.contentVisibility,W=r.columns*r.rows,K=!Number.isFinite(T)&&Number.isFinite(null==M?void 0:M.totalProducts)&&Object(Xt.isEqual)(V,null==M?void 0:M.totalQuery)?Math.ceil(M.totalProducts/W):Math.ceil(T/W),$=R.length?R:Array.from({length:W}),J=0!==R.length||A,X=p.length>0||g.length>0||Number.isFinite(w)||Number.isFinite(P);return Object(i.createElement)("div",{className:(H=r.columns,q=r.rows,G=r.alignButtons,Q=r.align,Y=void 0!==Q?"align"+Q:"",O()(L,Y,"has-"+H+"-columns",{"has-multiple-rows":q>1,"has-aligned-buttons":G}))},U.orderBy&&J&&Object(i.createElement)(gr,{onChange:o,value:a}),!J&&X&&Object(i.createElement)(mr,{resetCallback:function(){d([]),j([]),y(null),S(null)}}),!J&&!X&&Object(i.createElement)(dr,null),J&&Object(i.createElement)("ul",{className:"".concat(L,"__products")},$.map((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return Object(i.createElement)(jr,{key:e.id||t,attributes:r,product:e})}))),K>1&&Object(i.createElement)(tr,{currentPage:n,onPageChange:function(e){l({focusableSelector:"a, button"}),c(e)},totalPages:K}))})),_r=function(e){var t=e.attributes,r=Object(i.useState)(1),n=_()(r,2),c=n[0],o=n[1],a=Object(i.useState)(t.orderby),s=_()(a,2),l=s[0],u=s[1];return Object(i.useEffect)((function(){u(t.orderby)}),[t.orderby]),Object(i.createElement)(Er,{attributes:t,currentPage:c,onPageChange:function(e){o(e)},onSortChange:function(e){var t=e.target.value;u(t),o(1)},sortValue:l})},kr=r(188);var Pr=function(e){Ct()(c,e);var t,r,n=(t=c,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=Dt()(t);if(r){var c=Dt()(this).constructor;e=Reflect.construct(n,arguments,c)}else e=n.apply(this,arguments);return xt()(this,e)});function c(){return Et()(this,c),n.apply(this,arguments)}return $t()(c,[{key:"render",value:function(){var e=this.props,t=e.attributes,r=e.urlParameterSuffix;return t.isPreview?kr.a:Object(i.createElement)(N.InnerBlockLayoutContextProvider,{parentName:"woocommerce/all-products",parentClassName:"wc-block-grid"},Object(i.createElement)(_r,{attributes:t,urlParameterSuffix:r}))}}]),c}(Jt.Component);r(790);var Cr=function(e){Ct()(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=Dt()(t);if(r){var c=Dt()(this).constructor;e=Reflect.construct(n,arguments,c)}else e=n.apply(this,arguments);return xt()(this,e)});function o(){var e;Et()(this,o);for(var t=arguments.length,r=new Array(t),a=0;a<t;a++)r[a]=arguments[a];return e=n.call.apply(n,[this].concat(r)),c()(kt()(e),"state",{isEditing:!1,innerBlocks:[]}),c()(kt()(e),"blockMap",Object(Tt.a)("woocommerce/all-products")),c()(kt()(e),"componentDidMount",(function(){var t=e.props.block;e.setState({innerBlocks:t.innerBlocks})})),c()(kt()(e),"getTitle",(function(){return Object(s.__)("All Products","woo-gutenberg-products-block")})),c()(kt()(e),"getIcon",(function(){return Object(i.createElement)(b.a,{srcElement:d})})),c()(kt()(e),"togglePreview",(function(){var t=e.props.debouncedSpeak;e.setState({isEditing:!e.state.isEditing}),e.state.isEditing||t(Object(s.__)("Showing All Products block preview.","woo-gutenberg-products-block"))})),c()(kt()(e),"getInspectorControls",(function(){var t=e.props,r=t.attributes,n=t.setAttributes,c=r.columns,o=r.rows,a=r.alignButtons;return Object(i.createElement)(l.InspectorControls,{key:"inspector"},Object(i.createElement)(h.PanelBody,{title:Object(s.__)("Layout Settings","woo-gutenberg-products-block"),initialOpen:!0},Object(i.createElement)(Rt.a,{columns:c,rows:o,alignButtons:a,setAttributes:n,minColumns:Object(ne.getSetting)("min_columns",1),maxColumns:Object(ne.getSetting)("max_columns",6),minRows:Object(ne.getSetting)("min_rows",1),maxRows:Object(ne.getSetting)("max_rows",6)})),Object(i.createElement)(h.PanelBody,{title:Object(s.__)("Content Settings","woo-gutenberg-products-block")},Ut(r,n),Wt(r,n)))})),c()(kt()(e),"getBlockControls",(function(){var t=e.state.isEditing;return Object(i.createElement)(l.BlockControls,null,Object(i.createElement)(h.ToolbarGroup,{controls:[{icon:"edit",title:Object(s.__)("Edit","woo-gutenberg-products-block"),onClick:function(){return e.togglePreview()},isActive:t}]}))})),c()(kt()(e),"renderEditMode",(function(){var t={template:e.props.attributes.layoutConfig,templateLock:!1,allowedBlocks:Object.keys(e.blockMap)};return 0!==e.props.attributes.layoutConfig.length&&(t.renderAppender=!1),Object(i.createElement)(h.Placeholder,{icon:e.getIcon(),label:e.getTitle()},Object(s.__)("Display all products from your store as a grid.","woo-gutenberg-products-block"),Object(i.createElement)("div",{className:"wc-block-all-products-grid-item-template"},Object(i.createElement)(h.Tip,null,Object(s.__)("Edit the blocks inside the preview below to change the content displayed for each product within the product grid.","woo-gutenberg-products-block")),Object(i.createElement)(N.InnerBlockLayoutContextProvider,{parentName:"woocommerce/all-products",parentClassName:"wc-block-grid"},Object(i.createElement)("div",{className:"wc-block-grid wc-block-layout has-1-columns"},Object(i.createElement)("ul",{className:"wc-block-grid__products"},Object(i.createElement)("li",{className:"wc-block-grid__product"},Object(i.createElement)(N.ProductDataContextProvider,{product:At.a[0]},Object(i.createElement)(l.InnerBlocks,t)))))),Object(i.createElement)("div",{className:"wc-block-all-products__actions"},Object(i.createElement)(h.Button,{className:"wc-block-all-products__done-button",isPrimary:!0,onClick:function(){var t=e.props,r=t.block;(0,t.setAttributes)({layoutConfig:Gt(r.innerBlocks)}),e.setState({innerBlocks:r.innerBlocks}),e.togglePreview()}},Object(s.__)("Done","woo-gutenberg-products-block")),Object(i.createElement)(h.Button,{className:"wc-block-all-products__cancel-button",isTertiary:!0,onClick:function(){var t=e.props,r=t.block,n=t.replaceInnerBlocks,c=e.state.innerBlocks;n(r.clientId,c,!1),e.togglePreview()}},Object(s.__)("Cancel","woo-gutenberg-products-block")),Object(i.createElement)(h.Button,{className:"wc-block-all-products__reset-button",icon:Object(i.createElement)(b.a,{srcElement:d}),label:Object(s.__)("Reset layout to default","woo-gutenberg-products-block"),onClick:function(){var t=e.props,r=t.block,n=t.replaceInnerBlocks,c=[];qt.map((function(e){var t=_()(e,2),r=t[0],n=t[1];return c.push(Object(u.createBlock)(r,n)),!0})),n(r.clientId,c,!1),e.setState({innerBlocks:r.innerBlocks})}},Object(s.__)("Reset Layout","woo-gutenberg-products-block")))))})),c()(kt()(e),"renderViewMode",(function(){var t=e.props.attributes,r=t.layoutConfig,n=r&&0!==r.length,c=e.getTitle(),o=e.getIcon();return n?Object(i.createElement)(h.Disabled,null,Object(i.createElement)(Pr,{attributes:t})):Ft(c,o)})),c()(kt()(e),"render",(function(){var t=e.props.attributes,r=e.state.isEditing,n=e.getTitle(),c=e.getIcon();return 0===It.o.productCount?Vt(n,c):Object(i.createElement)("div",{className:Lt("wc-block-all-products",t)},e.getBlockControls(),e.getInspectorControls(),r?e.renderEditMode():e.renderViewMode())})),e}return o}(i.Component),Sr=Object(v.compose)(h.withSpokenMessages,Object(Bt.withSelect)((function(e,t){var r=t.clientId;return{block:(0,e("core/block-editor").getBlock)(r)}})),Object(Bt.withDispatch)((function(e){return{replaceInnerBlocks:e("core/block-editor").replaceInnerBlocks}})))(Cr),xr={columns:Object(ne.getSetting)("default_columns",3),rows:Object(ne.getSetting)("default_rows",3),alignButtons:!1,contentVisibility:{orderBy:!0},orderby:"date",layoutConfig:qt,isPreview:!1};function Nr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Dr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Nr(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Nr(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Br={title:Object(s.__)("All Products","woo-gutenberg-products-block"),icon:{src:Object(i.createElement)(b.a,{srcElement:d}),foreground:"#96588a"},category:"woocommerce",keywords:[Object(s.__)("WooCommerce","woo-gutenberg-products-block")],description:Object(s.__)("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:xr,edit:function(e){return Object(i.createElement)(Sr,e)},save:function(e){var t=e.attributes,r={};Object.keys(t).sort().forEach((function(e){r[e]=t[e]}));var n={"data-attributes":JSON.stringify(r)};return Object(i.createElement)("div",a()({className:Lt("wc-block-all-products",t)},n),Object(i.createElement)(l.InnerBlocks.Content,null))}};Object(u.registerBlockType)("woocommerce/all-products",Dr(Dr({},Br),{},{deprecated:[{attributes:Object.assign({},Br.attributes,{rows:{type:"number",default:1}}),save:function(e){var t=e.attributes,r={"data-attributes":JSON.stringify(t)};return Object(i.createElement)("div",a()({className:Lt("wc-block-all-products",t)},r),Object(i.createElement)(l.InnerBlocks.Content,null))}}]}))},86:function(e,t){e.exports=window.wc.wcBlocksSharedHocs},87:function(e,t){e.exports=window.ReactDOM},877:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(60),c=r(0),o=r(38);r.p=o.l,Object(n.registerBlockComponent)({blockName:"woocommerce/product-price",component:Object(c.lazy)((function(){return Promise.all([r.e(0),r.e(12)]).then(r.bind(null,482))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-image",component:Object(c.lazy)((function(){return Promise.all([r.e(1),r.e(2),r.e(4),r.e(11)]).then(r.bind(null,901))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-title",component:Object(c.lazy)((function(){return Promise.all([r.e(1),r.e(2),r.e(18)]).then(r.bind(null,902))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-rating",component:Object(c.lazy)((function(){return r.e(13).then(r.bind(null,483))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-button",component:Object(c.lazy)((function(){return Promise.all([r.e(0),r.e(1),r.e(3),r.e(9)]).then(r.bind(null,484))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-summary",component:Object(c.lazy)((function(){return r.e(16).then(r.bind(null,486))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-sale-badge",component:Object(c.lazy)((function(){return r.e(4).then(r.bind(null,304))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-sku",component:Object(c.lazy)((function(){return r.e(14).then(r.bind(null,487))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-category-list",component:Object(c.lazy)((function(){return r.e(10).then(r.bind(null,488))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-tag-list",component:Object(c.lazy)((function(){return r.e(17).then(r.bind(null,489))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-stock-indicator",component:Object(c.lazy)((function(){return r.e(15).then(r.bind(null,490))}))}),Object(n.registerBlockComponent)({blockName:"woocommerce/product-add-to-cart",component:Object(c.lazy)((function(){return Promise.all([r.e(0),r.e(1),r.e(2),r.e(3),r.e(8)]).then(r.bind(null,903))}))});var a=function(e){return Object(n.getRegisteredBlockComponents)(e)}},879:function(e,t,r){"use strict";r.d(t,"a",(function(){return n})),r.d(t,"b",(function(){return c}));var n=function(e){return e.is_purchasable||!1},c=function(e){return["simple","variable"].includes(e.type||"simple")}},88:function(e,t,r){"use strict";var n=r(9),c=r.n(n),o=r(17),a=r.n(o),i=r(18),s=r.n(i),l=r(13),u=r.n(l),b=r(19),p=r.n(b),d=r(20),f=r.n(d),m=r(10),O=r.n(m),g=r(0),j=r(7),h=r(6),v=r.n(h),w=r(4),y=r(21);r(123);var E=function(e){p()(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=O()(t);if(r){var c=O()(this).constructor;e=Reflect.construct(n,arguments,c)}else e=n.apply(this,arguments);return f()(this,e)});function o(){var e;return a()(this,o),(e=n.apply(this,arguments)).onClick=e.onClick.bind(u()(e)),e}return s()(o,[{key:"onClick",value:function(e){this.props.onChange&&this.props.onChange(e.target.value)}},{key:"render",value:function(){var e,t=this,r=this.props,n=r.label,o=r.checked,a=r.instanceId,i=r.className,s=r.help,l=r.options,u=r.value,b="inspector-toggle-button-control-".concat(a);return s&&(e=Object(j.isFunction)(s)?s(o):s),Object(g.createElement)(w.BaseControl,{id:b,help:e,className:v()("components-toggle-button-control",i)},Object(g.createElement)("label",{id:b+"__label",htmlFor:b,className:"components-toggle-button-control__label"},n),Object(g.createElement)(w.ButtonGroup,{"aria-labelledby":b+"__label"},l.map((function(e,r){var o={};return u===e.value?(o.isPrimary=!0,o["aria-pressed"]=!0):(o.isSecondary=!0,o["aria-pressed"]=!1),Object(g.createElement)(w.Button,c()({key:"".concat(e.label,"-").concat(e.value,"-").concat(r),value:e.value,onClick:t.onClick,"aria-label":n+": "+e.label},o),e.label)}))))}}]),o}(g.Component);t.a=Object(y.withInstanceId)(E)},89:function(e,t){e.exports=window.wp.viewport},90:function(e,t,r){"use strict";var n=r(9),c=r.n(n),o=r(16),a=r.n(o),i=r(0),s=r(182),l=r(6),u=r.n(l),b=r(114),p=(r(208),["className","showSpinner","children"]);t.a=function(e){var t=e.className,r=e.showSpinner,n=void 0!==r&&r,o=e.children,l=a()(e,p),d=u()("wc-block-components-button",t,{"wc-block-components-button--loading":n});return Object(i.createElement)(s.a,c()({className:d},l),n&&Object(i.createElement)(b.a,null),Object(i.createElement)("span",{className:"wc-block-components-button__text"},o))}},91:function(e,t){e.exports=window.wp.autop},94:function(e,t,r){"use strict";var n=r(0),c=r(1),o=r(7),a=(r(2),r(4));t.a=function(e){var t=e.columns,r=e.rows,i=e.setAttributes,s=e.alignButtons,l=e.minColumns,u=void 0===l?1:l,b=e.maxColumns,p=void 0===b?6:b,d=e.minRows,f=void 0===d?1:d,m=e.maxRows,O=void 0===m?6:m;return Object(n.createElement)(n.Fragment,null,Object(n.createElement)(a.RangeControl,{label:Object(c.__)("Columns","woo-gutenberg-products-block"),value:t,onChange:function(e){var t=Object(o.clamp)(e,u,p);i({columns:Number.isNaN(t)?"":t})},min:u,max:p}),Object(n.createElement)(a.RangeControl,{label:Object(c.__)("Rows","woo-gutenberg-products-block"),value:r,onChange:function(e){var t=Object(o.clamp)(e,f,O);i({rows:Number.isNaN(t)?"":t})},min:f,max:O}),Object(n.createElement)(a.ToggleControl,{label:Object(c.__)("Align Last Block","woo-gutenberg-products-block"),help:s?Object(c.__)("The last inner block will be aligned vertically.","woo-gutenberg-products-block"):Object(c.__)("The last inner block will follow other content.","woo-gutenberg-products-block"),checked:s,onChange:function(){return i({alignButtons:!s})}}))}},97:function(e,t){e.exports=window.wp.date}});
|
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' => '0e5c3c818dcd1829a90e549879b275f0');
|
build/all-reviews.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
-
this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["all-reviews"]=function(e){function t(t){for(var n,a,i=t[0],s=t[1],l=t[2],b=0,d=[];b<i.length;b++)a=i[b],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&d.push(o[a][0]),o[a]=0;for(n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n]);for(u&&u(t);d.length;)d.shift()();return c.push.apply(c,l||[]),r()}function r(){for(var e,t=0;t<c.length;t++){for(var r=c[t],n=!0,i=1;i<r.length;i++){var s=r[i];0!==o[s]&&(n=!1)}n&&(c.splice(t--,1),e=a(a.s=r[0]))}return e}var n={},o={7:0},c=[];function a(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,a),r.l=!0,r.exports}a.m=e,a.c=n,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 n in e)a.d(r,n,function(t){return e[t]}.bind(null,n));return r},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="";var i=window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[],s=i.push.bind(i);i.push=t,i=i.slice();for(var l=0;l<i.length;l++)t(i[l]);var u=s;return c.push([
|
| 2 |
/* translators: An example person name used for the block previews. */
|
| 3 |
-
reviewer:Object(n.__)("Alice","woo-gutenberg-products-block"),review:"<p>".concat(Object(n.__)("I bought this product last week and I'm very happy with it.","woo-gutenberg-products-block"),"</p>\n"),reviewer_avatar_urls:{48:o.
|
| 4 |
/* translators: An example person name used for the block previews. */
|
| 5 |
-
reviewer:Object(n.__)("Bob","woo-gutenberg-products-block"),review:"<p>".concat(Object(n.__)("This product is awesome, I love it!","woo-gutenberg-products-block"),"</p>\n"),reviewer_avatar_urls:{48:o.
|
| 6 |
/* translators: %f is referring to the average rating value */
|
| 7 |
-
Object(w.__)("Rated %f out of 5","woo-gutenberg-products-block"),t);return Object(p.createElement)("div",{className:"wc-block-review-list-item__rating wc-block-components-review-list-item__rating"},Object(p.createElement)("div",{className:"wc-block-review-list-item__rating__stars wc-block-components-review-list-item__rating__stars",role:"img","aria-label":n},Object(p.createElement)("span",{style:r},n)))}(n),u&&function(e){return Object(p.createElement)("div",{className:"wc-block-review-list-item__product wc-block-components-review-list-item__product"},Object(p.createElement)("a",{href:e.product_permalink,dangerouslySetInnerHTML:{__html:e.product_name}}))}(n),a&&function(e){var t=e.reviewer,r=void 0===t?"":t;return Object(p.createElement)("div",{className:"wc-block-review-list-item__author wc-block-components-review-list-item__author"},r)}(n),c&&function(e){var t=e.date_created,r=e.formatted_date_created;return Object(p.createElement)("time",{className:"wc-block-review-list-item__published-date wc-block-components-review-list-item__published-date",dateTime:t},r)}(n))),l&&function(e){return Object(p.createElement)(B,{maxLines:10,moreText:Object(w.__)("Read full review","woo-gutenberg-products-block"),lessText:Object(w.__)("Hide full review","woo-gutenberg-products-block"),className:"wc-block-review-list-item__text wc-block-components-review-list-item__text"},Object(p.createElement)("div",{dangerouslySetInnerHTML:{__html:e.review||""}}))}(n))};function G(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function F(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?G(Object(r),!0).forEach((function(t){E()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):G(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}r(255);var V=function(e){var t=e.attributes,r=e.reviews,n=Object(g.getSetting)("showAvatars",!0),o=Object(g.getSetting)("reviewRatingsEnabled",!0),c=(n||"product"===t.imageType)&&t.showReviewImage,a=o&&t.showReviewRating,i=F(F({},t),{},{showReviewImage:c,showReviewRating:a});return Object(p.createElement)("ul",{className:"wc-block-review-list wc-block-components-review-list"},0===r.length?Object(p.createElement)(H,{attributes:i}):r.map((function(e,t){return Object(p.createElement)(H,{key:e.id||t,attributes:i,review:e})})))},z=r(9),W=r.n(z),q=r(31),U=r.n(q),J=r(23),Y=r.n(J),K=r(33),Q=r.n(K),X=r(83),Z=r(42);var $=function(e){var t=function(t){s()(i,t);var r,n,c=(r=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=d()(r);if(n){var o=d()(this).constructor;e=Reflect.construct(t,arguments,o)}else e=t.apply(this,arguments);return u()(this,e)});function i(){var e;o()(this,i);for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return e=c.call.apply(c,[this].concat(r)),E()(N()(e),"isPreview",!!e.props.attributes.previewReviews),E()(N()(e),"delayedAppendReviews",e.props.delayFunction(e.appendReviews)),E()(N()(e),"isMounted",!1),E()(N()(e),"state",{error:null,loading:!0,reviews:e.isPreview?e.props.attributes.previewReviews:[],totalReviews:e.isPreview?e.props.attributes.previewReviews.length:0}),E()(N()(e),"setError",function(){var t=U()(Y.a.mark((function t(r){var n,o;return Y.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.isMounted){t.next=2;break}return t.abrupt("return");case 2:return n=e.props.onReviewsLoadError,t.next=5,Object(Z.a)(r);case 5:o=t.sent,e.setState({reviews:[],loading:!1,error:o}),n(o);case 8:case"end":return t.stop()}}),t)})));return function(_x){return t.apply(this,arguments)}}()),e}return a()(i,[{key:"componentDidMount",value:function(){this.isMounted=!0,this.replaceReviews()}},{key:"componentDidUpdate",value:function(e){e.reviewsToDisplay<this.props.reviewsToDisplay?this.delayedAppendReviews():this.shouldReplaceReviews(e,this.props)&&this.replaceReviews()}},{key:"shouldReplaceReviews",value:function(e,t){return e.orderby!==t.orderby||e.order!==t.order||e.productId!==t.productId||!Q()(e.categoryIds,t.categoryIds)}},{key:"componentWillUnmount",value:function(){this.isMounted=!1,this.delayedAppendReviews.cancel&&this.delayedAppendReviews.cancel()}},{key:"getArgs",value:function(e){var t=this.props,r=t.categoryIds,n=t.order,o=t.orderby,c=t.productId,a={order:n,orderby:o,per_page:t.reviewsToDisplay-e,offset:e};return r&&r.length&&(a.category_id=Array.isArray(r)?r.join(","):r),c&&(a.product_id=c),a}},{key:"replaceReviews",value:function(){if(!this.isPreview){var e=this.props.onReviewsReplaced;this.updateListOfReviews().then(e)}}},{key:"appendReviews",value:function(){if(!this.isPreview){var e=this.props,t=e.onReviewsAppended,r=e.reviewsToDisplay,n=this.state.reviews;r<=n.length||this.updateListOfReviews(n).then(t)}}},{key:"updateListOfReviews",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=this.props.reviewsToDisplay,n=this.state.totalReviews,o=Math.min(n,r)-t.length;return this.setState({loading:!0,reviews:t.concat(Array(o).fill({}))}),Object(X.c)(this.getArgs(t.length)).then((function(r){var n=r.reviews,o=r.totalReviews;return e.isMounted&&e.setState({reviews:t.filter((function(e){return Object.keys(e).length})).concat(n),totalReviews:o,loading:!1,error:null}),{newReviews:n}})).catch(this.setError)}},{key:"render",value:function(){var t=this.props.reviewsToDisplay,r=this.state,n=r.error,o=r.loading,c=r.reviews,a=r.totalReviews;return Object(p.createElement)(e,W()({},this.props,{error:n,isLoading:o,reviews:c.slice(0,t),totalReviews:a}))}}]),i}(v.Component);E()(t,"defaultProps",{delayFunction:function(e){return e},onReviewsAppended:function(){},onReviewsLoadError:function(){},onReviewsReplaced:function(){}});var r=e.displayName,n=void 0===r?e.name||"Component":r;return t.displayName="WithReviews( ".concat(n," )"),t}(function(e){s()(c,e);var t,r,n=(t=c,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d()(t);if(r){var o=d()(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return u()(this,e)});function c(){return o()(this,c),n.apply(this,arguments)}return a()(c,[{key:"render",value:function(){var e=this.props,t=e.attributes,r=e.error,n=e.isLoading,o=e.noReviewsPlaceholder,c=e.reviews,a=e.totalReviews;if(r)return Object(p.createElement)(h.a,{className:"wc-block-featured-product-error",error:r,isLoading:n});if(0===c.length&&!n)return Object(p.createElement)(o,{attributes:t});var i=Object(g.getSetting)("reviewRatingsEnabled",!0);return Object(p.createElement)(f.Disabled,null,t.showOrderby&&i&&Object(p.createElement)(k,{readOnly:!0,value:t.orderby}),Object(p.createElement)(V,{attributes:t,reviews:c}),t.showLoadMore&&a>c.length&&Object(p.createElement)(j,{screenReaderLabel:Object(w.__)("Load more reviews","woo-gutenberg-products-block")}))}}]),c}(v.Component));var ee=function(e){s()(c,e);var t,r,n=(t=c,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d()(t);if(r){var o=d()(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return u()(this,e)});function c(){return o()(this,c),n.apply(this,arguments)}return a()(c,[{key:"renderHiddenContentPlaceholder",value:function(){var e=this.props,t=e.icon,r=e.name;return Object(p.createElement)(f.Placeholder,{icon:t,label:r},Object(w.__)("The content for this block is hidden due to block settings.","woo-gutenberg-products-block"))}},{key:"render",value:function(){var e=this.props,t=e.attributes,r=e.noReviewsPlaceholder,n=t.categoryIds,o=t.productId,c=t.reviewsOnPageLoad,a=t.showProductName,i=t.showReviewDate,s=t.showReviewerName,l=t.showReviewContent,u=t.showReviewImage,b=t.showReviewRating,d=Object(X.d)(t.orderby),w=d.order,v=d.orderby;return l||b||i||s||u||a?Object(p.createElement)("div",{className:Object(X.a)(t)},Object(p.createElement)($,{attributes:t,categoryIds:n,delayFunction:function(e){return Object(m.debounce)(e,400)},noReviewsPlaceholder:r,orderby:v,order:w,productId:o,reviewsToDisplay:c})):this.renderHiddenContentPlaceholder()}}]),c}(v.Component);t.a=ee},21:function(e,t){e.exports=window.wp.blockEditor},214:function(e,t){},215:function(e,t){},22:function(e,t){e.exports=window.wp.compose},23:function(e,t){e.exports=window.regeneratorRuntime},25:function(e,t){e.exports=window.wp.blocks},254:function(e,t){},255:function(e,t){},256:function(e,t){},257:function(e,t){},3:function(e,t){e.exports=window.wc.wcSettings},30:function(e,t){e.exports=window.wp.primitives},33:function(e,t){e.exports=window.wp.isShallowEqual},4:function(e,t){e.exports=window.wp.components},40:function(e,t,r){"use strict";var n=r(5),o=r.n(n),c=r(0),a=r(6),i=r.n(a);function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}t.a=function(e){var t,r=e.label,n=e.screenReaderLabel,o=e.wrapperElement,a=e.wrapperProps,s=void 0===a?{}:a,u=null!=r,b=null!=n;return!u&&b?(t=o||"span",s=l(l({},s),{},{className:i()(s.className,"screen-reader-text")}),Object(c.createElement)(t,s,n)):(t=o||c.Fragment,u&&b&&r!==n?Object(c.createElement)(t,s,Object(c.createElement)("span",{"aria-hidden":"true"},r),Object(c.createElement)("span",{className:"screen-reader-text"},n)):Object(c.createElement)(t,s,r))}},42:function(e,t,r){"use strict";r.d(t,"a",(function(){return s})),r.d(t,"b",(function(){return l}));var n=r(31),o=r.n(n),c=r(23),a=r.n(c),i=r(1),s=function(){var e=o()(a.a.mark((function e(t){var r;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("function"!=typeof t.json){e.next=11;break}return e.prev=1,e.next=4,t.json();case 4:return r=e.sent,e.abrupt("return",{message:r.message,type:r.type||"api"});case 8:return e.prev=8,e.t0=e.catch(1),e.abrupt("return",{message:e.t0.message,type:"general"});case 11:return e.abrupt("return",{message:t.message,type:t.type||"general"});case 12:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(_x){return e.apply(this,arguments)}}(),l=function(e){if(e.data&&"rest_invalid_param"===e.code){var t=Object.values(e.data.params);if(t[0])return t[0]}return(null==e?void 0:e.message)||Object(i.__)("Something went wrong. Please contact us to get assistance.","woo-gutenberg-products-block")}},48:function(e,t){e.exports=window.wp.escapeHtml},52:function(e,t,r){"use strict";var n=r(0),o=r(1),c=(r(2),r(48));t.a=function(e){var t,r,a,i=e.error;return Object(n.createElement)("div",{className:"wc-block-error-message"},(r=(t=i).message,a=t.type,r?"general"===a?Object(n.createElement)("span",null,Object(o.__)("The following error was returned","woo-gutenberg-products-block"),Object(n.createElement)("br",null),Object(n.createElement)("code",null,Object(c.escapeHTML)(r))):"api"===a?Object(n.createElement)("span",null,Object(o.__)("The following error was returned from the API","woo-gutenberg-products-block"),Object(n.createElement)("br",null),Object(n.createElement)("code",null,Object(c.escapeHTML)(r))):r:Object(o.__)("An unknown error occurred which prevented the block from being updated.","woo-gutenberg-products-block")))}},63:function(e,t,r){"use strict";var n=r(5),o=r.n(n),c=r(14),a=r.n(c),i=r(0),s=["srcElement","size"];function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}t.a=function(e){var t=e.srcElement,r=e.size,n=void 0===r?24:r,c=a()(e,s);return Object(i.isValidElement)(t)?Object(i.cloneElement)(t,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({width:n,height:n},c)):null}},7:function(e,t){e.exports=window.lodash},758:function(e,t,r){e.exports=r(839)},83:function(e,t,r){"use strict";r.d(t,"d",(function(){return s})),r.d(t,"c",(function(){return l})),r.d(t,"a",(function(){return u})),r.d(t,"b",(function(){return b}));var n=r(15),o=r.n(n),c=r(6),a=r.n(c),i=r(3),s=function(e){if(Object(i.getSetting)("reviewRatingsEnabled",!0)){if("lowest-rating"===e)return{order:"asc",orderby:"rating"};if("highest-rating"===e)return{order:"desc",orderby:"rating"}}return{order:"desc",orderby:"date_gmt"}},l=function(e){return o()({path:"/wc/store/products/reviews?"+Object.entries(e).map((function(e){return e.join("=")})).join("&"),parse:!1}).then((function(e){return e.json().then((function(t){return{reviews:t,totalReviews:parseInt(e.headers.get("x-wp-total"),10)}}))}))},u=function(e){var t=e.className,r=e.categoryIds,n=e.productId,o=e.showReviewDate,c=e.showReviewerName,i=e.showReviewContent,s=e.showProductName,l=e.showReviewImage,u=e.showReviewRating,b="wc-block-all-reviews";return n&&(b="wc-block-reviews-by-product"),Array.isArray(r)&&(b="wc-block-reviews-by-category"),a()(b,t,{"has-image":l,"has-name":c,"has-date":o,"has-rating":u,"has-content":i,"has-product-name":s})},b=function(e){var t=e.categoryIds,r=e.imageType,n=e.orderby,o=e.productId,c={"data-image-type":r,"data-orderby":n,"data-reviews-on-page-load":e.reviewsOnPageLoad,"data-reviews-on-load-more":e.reviewsOnLoadMore,"data-show-load-more":e.showLoadMore,"data-show-orderby":e.showOrderby};return o&&(c["data-product-id"]=o),Array.isArray(t)&&(c["data-category-ids"]=t.join(",")),c}},839:function(e,t,r){"use strict";r.r(t);var n=r(5),o=r.n(n),c=r(0),a=r(1),i=r(25),s=r(63),l=r(30),u=Object(c.createElement)(l.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(c.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(c.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"})),b=(r(214),r(21)),d=r(4),p=(r(2),r(198)),w=function(){return Object(c.createElement)(d.Placeholder,{className:"wc-block-all-reviews",icon:Object(c.createElement)(s.a,{srcElement:u,className:"block-editor-block-icon"}),label:Object(a.__)("All Reviews","woo-gutenberg-products-block")},Object(a.__)("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"))},v=r(144),m=function(e){var t=e.attributes,r=e.setAttributes;return Object(c.createElement)(c.Fragment,null,Object(c.createElement)(b.InspectorControls,{key:"inspector"},Object(c.createElement)(d.PanelBody,{title:Object(a.__)("Content","woo-gutenberg-products-block")},Object(c.createElement)(d.ToggleControl,{label:Object(a.__)("Product name","woo-gutenberg-products-block"),checked:t.showProductName,onChange:function(){return r({showProductName:!t.showProductName})}}),Object(v.b)(t,r)),Object(c.createElement)(d.PanelBody,{title:Object(a.__)("List Settings","woo-gutenberg-products-block")},Object(v.c)(t,r))),Object(c.createElement)(p.a,{attributes:t,icon:Object(c.createElement)(s.a,{icon:u,className:"block-editor-block-icon"}),name:Object(a.__)("All Reviews","woo-gutenberg-products-block"),noReviewsPlaceholder:w}))},f=r(190),g=r(191),h=r(165);function O(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function y(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?O(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):O(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}Object(i.registerBlockType)("woocommerce/all-reviews",{title:Object(a.__)("All Reviews","woo-gutenberg-products-block"),icon:{src:Object(c.createElement)(s.a,{srcElement:u}),foreground:"#96588a"},category:"woocommerce",keywords:[Object(a.__)("WooCommerce","woo-gutenberg-products-block")],description:Object(a.__)("Show a list of all product reviews.","woo-gutenberg-products-block"),supports:{html:!1},example:y(y({},h.a),{},{attributes:y(y({},h.a.attributes),{},{showProductName:!0})}),attributes:y(y({},f.a),{},{showProductName:{type:"boolean",default:!0}}),transforms:{from:[{type:"block",blocks:["core/legacy-widget"],isMatch:function(e){var t=e.idBase,r=e.instance;return"woocommerce_recent_reviews"===t&&!(null==r||!r.raw)},transform:function(e){var t=e.instance;return Object(i.createBlock)("woocommerce/all-reviews",{reviewsOnPageLoad:t.raw.number,imageType:"product",showLoadMore:!1,showOrderby:!1,showReviewDate:!1,showReviewContent:!1})}}]},edit:function(e){return Object(c.createElement)(m,e)},save:g.a})},86:function(e,t,r){"use strict";var n=r(9),o=r.n(n),c=r(17),a=r.n(c),i=r(18),s=r.n(i),l=r(13),u=r.n(l),b=r(19),d=r.n(b),p=r(20),w=r.n(p),v=r(10),m=r.n(v),f=r(0),g=r(7),h=r(6),O=r.n(h),y=r(4),j=r(22);r(124);var _=function(e){d()(c,e);var t,r,n=(t=c,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=m()(t);if(r){var o=m()(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return w()(this,e)});function c(){var e;return a()(this,c),(e=n.apply(this,arguments)).onClick=e.onClick.bind(u()(e)),e}return s()(c,[{key:"onClick",value:function(e){this.props.onChange&&this.props.onChange(e.target.value)}},{key:"render",value:function(){var e,t=this,r=this.props,n=r.label,c=r.checked,a=r.instanceId,i=r.className,s=r.help,l=r.options,u=r.value,b="inspector-toggle-button-control-".concat(a);return s&&(e=Object(g.isFunction)(s)?s(c):s),Object(f.createElement)(y.BaseControl,{id:b,help:e,className:O()("components-toggle-button-control",i)},Object(f.createElement)("label",{id:b+"__label",htmlFor:b,className:"components-toggle-button-control__label"},n),Object(f.createElement)(y.ButtonGroup,{"aria-labelledby":b+"__label"},l.map((function(e,r){var c={};return u===e.value?(c.isPrimary=!0,c["aria-pressed"]=!0):(c.isSecondary=!0,c["aria-pressed"]=!1),Object(f.createElement)(y.Button,o()({key:"".concat(e.label,"-").concat(e.value,"-").concat(r),value:e.value,onClick:t.onClick,"aria-label":n+": "+e.label},c),e.label)}))))}}]),c}(f.Component);t.a=Object(j.withInstanceId)(_)}});
|
| 1 |
+
this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["all-reviews"]=function(e){function t(t){for(var n,a,i=t[0],s=t[1],l=t[2],b=0,d=[];b<i.length;b++)a=i[b],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&d.push(o[a][0]),o[a]=0;for(n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n]);for(u&&u(t);d.length;)d.shift()();return c.push.apply(c,l||[]),r()}function r(){for(var e,t=0;t<c.length;t++){for(var r=c[t],n=!0,i=1;i<r.length;i++){var s=r[i];0!==o[s]&&(n=!1)}n&&(c.splice(t--,1),e=a(a.s=r[0]))}return e}var n={},o={7:0},c=[];function a(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,a),r.l=!0,r.exports}a.m=e,a.c=n,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 n in e)a.d(r,n,function(t){return e[t]}.bind(null,n));return r},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="";var i=window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[],s=i.push.bind(i);i.push=t,i=i.slice();for(var l=0;l<i.length;l++)t(i[l]);var u=s;return c.push([774,0]),r()}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},106:function(e,t,r){"use strict";var n=r(0),o=r(1),c=(r(2),r(66)),a=r(150),i=r(6),s=r.n(i),l=r(4),u=r(52);r(153),t.a=function(e){var t=e.className,r=e.error,i=e.isLoading,b=e.onRetry;return Object(n.createElement)(l.Placeholder,{icon:Object(n.createElement)(c.a,{srcElement:a.a}),label:Object(o.__)("Sorry, an error occurred","woo-gutenberg-products-block"),className:s()("wc-block-api-error",t)},Object(n.createElement)(u.a,{error:r}),b&&Object(n.createElement)(n.Fragment,null,i?Object(n.createElement)(l.Spinner,null):Object(n.createElement)(l.Button,{isSecondary:!0,onClick:b},Object(o.__)("Retry","woo-gutenberg-products-block"))))}},11:function(e,t){e.exports=window.React},12:function(e,t){e.exports=window.wp.blockEditor},123:function(e,t){},144:function(e,t,r){"use strict";r.d(t,"a",(function(){return l})),r.d(t,"b",(function(){return u})),r.d(t,"c",(function(){return b}));var n=r(0),o=r(1),c=r(4),a=r(12),i=r(3),s=r(88),l=function(e,t){return Object(n.createElement)(a.BlockControls,null,Object(n.createElement)(c.ToolbarGroup,{controls:[{icon:"edit",title:Object(o.__)("Edit","woo-gutenberg-products-block"),onClick:function(){return t({editMode:!e})},isActive:e}]}))},u=function(e,t){var r=Object(i.getSetting)("showAvatars",!0),a=Object(i.getSetting)("reviewRatingsEnabled",!0);return Object(n.createElement)(n.Fragment,null,Object(n.createElement)(c.ToggleControl,{label:Object(o.__)("Product rating","woo-gutenberg-products-block"),checked:e.showReviewRating,onChange:function(){return t({showReviewRating:!e.showReviewRating})}}),e.showReviewRating&&!a&&Object(n.createElement)(c.Notice,{className:"wc-block-base-control-notice",isDismissible:!1},Object(n.createInterpolateElement)(Object(o.__)("Product rating is disabled in your <a>store settings</a>.","woo-gutenberg-products-block"),{a:Object(n.createElement)("a",{href:Object(i.getAdminLink)("admin.php?page=wc-settings&tab=products"),target:"_blank",rel:"noopener noreferrer"})})),Object(n.createElement)(c.ToggleControl,{label:Object(o.__)("Reviewer name","woo-gutenberg-products-block"),checked:e.showReviewerName,onChange:function(){return t({showReviewerName:!e.showReviewerName})}}),Object(n.createElement)(c.ToggleControl,{label:Object(o.__)("Image","woo-gutenberg-products-block"),checked:e.showReviewImage,onChange:function(){return t({showReviewImage:!e.showReviewImage})}}),Object(n.createElement)(c.ToggleControl,{label:Object(o.__)("Review date","woo-gutenberg-products-block"),checked:e.showReviewDate,onChange:function(){return t({showReviewDate:!e.showReviewDate})}}),Object(n.createElement)(c.ToggleControl,{label:Object(o.__)("Review content","woo-gutenberg-products-block"),checked:e.showReviewContent,onChange:function(){return t({showReviewContent:!e.showReviewContent})}}),e.showReviewImage&&Object(n.createElement)(n.Fragment,null,Object(n.createElement)(s.a,{label:Object(o.__)("Review image","woo-gutenberg-products-block"),value:e.imageType,options:[{label:Object(o.__)("Reviewer photo","woo-gutenberg-products-block"),value:"reviewer"},{label:Object(o.__)("Product","woo-gutenberg-products-block"),value:"product"}],onChange:function(e){return t({imageType:e})}}),"reviewer"===e.imageType&&!r&&Object(n.createElement)(c.Notice,{className:"wc-block-base-control-notice",isDismissible:!1},Object(n.createInterpolateElement)(Object(o.__)("Reviewer photo is disabled in your <a>site settings</a>.","woo-gutenberg-products-block"),{a:Object(n.createElement)("a",{href:Object(i.getAdminLink)("options-discussion.php"),target:"_blank",rel:"noopener noreferrer"})}))))},b=function(e,t){return Object(n.createElement)(n.Fragment,null,Object(n.createElement)(c.ToggleControl,{label:Object(o.__)("Order by","woo-gutenberg-products-block"),checked:e.showOrderby,onChange:function(){return t({showOrderby:!e.showOrderby})}}),Object(n.createElement)(c.SelectControl,{label:Object(o.__)("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:function(e){return t({orderby:e})}}),Object(n.createElement)(c.RangeControl,{label:Object(o.__)("Starting Number of Reviews","woo-gutenberg-products-block"),value:e.reviewsOnPageLoad,onChange:function(e){return t({reviewsOnPageLoad:e})},max:20,min:1}),Object(n.createElement)(c.ToggleControl,{label:Object(o.__)("Load more","woo-gutenberg-products-block"),checked:e.showLoadMore,onChange:function(){return t({showLoadMore:!e.showLoadMore})}}),e.showLoadMore&&Object(n.createElement)(c.RangeControl,{label:Object(o.__)("Load More Reviews","woo-gutenberg-products-block"),value:e.reviewsOnLoadMore,onChange:function(e){return t({reviewsOnLoadMore:e})},max:20,min:1}))}},15:function(e,t){e.exports=window.wp.apiFetch},150:function(e,t,r){"use strict";var n=r(0),o=r(28),c=Object(n.createElement)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(n.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},153:function(e,t){},156:function(e,t,r){"use strict";var n=r(0),o=(r(2),r(6)),c=r.n(o),a=r(41),i=r(21);r(216),t.a=Object(i.withInstanceId)((function(e){var t=e.className,r=e.instanceId,o=e.label,i=e.onChange,s=e.options,l=e.screenReaderLabel,u=e.readOnly,b=e.value,d="wc-block-components-sort-select__select-".concat(r);return Object(n.createElement)("div",{className:c()("wc-block-sort-select","wc-block-components-sort-select",t)},Object(n.createElement)(a.a,{label:o,screenReaderLabel:l,wrapperElement:"label",wrapperProps:{className:"wc-block-sort-select__label wc-block-components-sort-select__label",htmlFor:d}}),Object(n.createElement)("select",{id:d,className:"wc-block-sort-select__select wc-block-components-sort-select__select",onChange:i,readOnly:u,value:b},s.map((function(e){return Object(n.createElement)("option",{key:e.key,value:e.key},e.label)}))))}))},161:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(1),o=r(38),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(n.__)("July 15, 2019","woo-gutenberg-products-block"),date_created_gmt:"2019-07-15T15:05:04",product_id:0,product_name:Object(n.__)("WordPress Pennant","woo-gutenberg-products-block"),product_permalink:"#",
|
| 2 |
/* translators: An example person name used for the block previews. */
|
| 3 |
+
reviewer:Object(n.__)("Alice","woo-gutenberg-products-block"),review:"<p>".concat(Object(n.__)("I bought this product last week and I'm very happy with it.","woo-gutenberg-products-block"),"</p>\n"),reviewer_avatar_urls:{48:o.o.defaultAvatar,96:o.o.defaultAvatar},rating:5,verified:!0},{id:2,date_created:"2019-07-12T12:39:39",formatted_date_created:Object(n.__)("July 12, 2019","woo-gutenberg-products-block"),date_created_gmt:"2019-07-12T10:39:39",product_id:0,product_name:Object(n.__)("WordPress Pennant","woo-gutenberg-products-block"),product_permalink:"#",
|
| 4 |
/* translators: An example person name used for the block previews. */
|
| 5 |
+
reviewer:Object(n.__)("Bob","woo-gutenberg-products-block"),review:"<p>".concat(Object(n.__)("This product is awesome, I love it!","woo-gutenberg-products-block"),"</p>\n"),reviewer_avatar_urls:{48:o.o.defaultAvatar,96:o.o.defaultAvatar},rating:null,verified:!1}]}}},192: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}}},193:function(e,t,r){"use strict";var n=r(9),o=r.n(n),c=r(0),a=r(12),i=(r(215),r(85));t.a=function(e){var t=e.attributes;return Object(c.createElement)("div",o()({},a.useBlockProps.save({className:Object(i.a)(t)}),Object(i.b)(t)))}},199:function(e,t,r){"use strict";var n=r(0),o=r(1),c=(r(2),r(7)),a=r(4),i=r(12),s=r(17),l=r.n(s),u=r(18),b=r.n(u),d=r(19),p=r.n(d),w=r(20),m=r.n(w),v=r(10),g=r.n(v),f=r(11),h=r(3),O=r(106),y=r(41),j=(r(256),function(e){var t=e.onClick,r=e.label,o=e.screenReaderLabel;return Object(n.createElement)("div",{className:"wp-block-button wc-block-load-more wc-block-components-load-more"},Object(n.createElement)("button",{className:"wp-block-button__link",onClick:t},Object(n.createElement)(y.a,{label:r,screenReaderLabel:o})))});j.defaultProps={label:Object(o.__)("Load more","woo-gutenberg-products-block")};var _=j,k=r(156),R=(r(253),function(e){var t=e.onChange,r=e.readOnly,c=e.value;return Object(n.createElement)(k.a,{className:"wc-block-review-sort-select wc-block-components-review-sort-select",label:Object(o.__)("Order by","woo-gutenberg-products-block"),onChange:t,options:[{key:"most-recent",label:Object(o.__)("Most recent","woo-gutenberg-products-block")},{key:"highest-rating",label:Object(o.__)("Highest rating","woo-gutenberg-products-block")},{key:"lowest-rating",label:Object(o.__)("Lowest rating","woo-gutenberg-products-block")}],readOnly:r,screenReaderLabel:Object(o.__)("Order reviews by","woo-gutenberg-products-block"),value:c})}),E=r(5),P=r.n(E),S=r(6),C=r.n(S),N=r(13),T=r.n(N),x=r(236),L=r.n(x),A=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"...",n=L()(e,{suffix:r,limit:t});return n.html},M=function(e,t,r,n){var o=I(e,t,r);return A(e,o-n.length,n)},I=function(e,t,r){for(var n={start:0,middle:0,end:e.length};n.start<=n.end;)n.middle=Math.floor((n.start+n.end)/2),t.innerHTML=A(e,n.middle),n=D(n,t.clientHeight,r);return n.middle},D=function(e,t,r){return t<=r?e.start=e.middle+1:e.end=e.middle-1,e};var B=function(e){p()(c,e);var t,r,o=(t=c,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=g()(t);if(r){var o=g()(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return m()(this,e)});function c(e){var t;return l()(this,c),(t=o.apply(this,arguments)).state={isExpanded:!1,clampEnabled:null,content:e.children,summary:"."},t.reviewSummary=Object(f.createRef)(),t.reviewContent=Object(f.createRef)(),t.getButton=t.getButton.bind(T()(t)),t.onClick=t.onClick.bind(T()(t)),t}return b()(c,[{key:"componentDidMount",value:function(){if(this.props.children){var e=this.props,t=e.maxLines,r=e.ellipsis,n=(this.reviewSummary.current.clientHeight+1)*t+1,o=this.reviewContent.current.clientHeight+1>n;this.setState({clampEnabled:o}),o&&this.setState({summary:M(this.reviewContent.current.innerHTML,this.reviewSummary.current,n,r)})}}},{key:"getButton",value:function(){var e=this.state.isExpanded,t=this.props,r=t.className,o=t.lessText,c=t.moreText,a=e?o:c;if(a)return Object(n.createElement)("a",{href:"#more",className:r+"__read_more",onClick:this.onClick,"aria-expanded":!e,role:"button"},a)}},{key:"onClick",value:function(e){e.preventDefault();var t=this.state.isExpanded;this.setState({isExpanded:!t})}},{key:"render",value:function(){var e=this.props.className,t=this.state,r=t.content,o=t.summary,c=t.clampEnabled,a=t.isExpanded;return r?!1===c?Object(n.createElement)("div",{className:e},Object(n.createElement)("div",{ref:this.reviewContent},r)):Object(n.createElement)("div",{className:e},(!a||null===c)&&Object(n.createElement)("div",{ref:this.reviewSummary,"aria-hidden":a,dangerouslySetInnerHTML:{__html:o}}),(a||null===c)&&Object(n.createElement)("div",{ref:this.reviewContent,"aria-hidden":!a},r),this.getButton()):null}}]),c}(f.Component);B.defaultProps={maxLines:3,ellipsis:"…",moreText:Object(o.__)("Read more","woo-gutenberg-products-block"),lessText:Object(o.__)("Read less","woo-gutenberg-products-block"),className:"read-more-content"};var H=B;r(255);var G=function(e){var t=e.attributes,r=e.review,c=void 0===r?{}:r,a=t.imageType,i=t.showReviewDate,s=t.showReviewerName,l=t.showReviewImage,u=t.showReviewRating,b=t.showReviewContent,d=t.showProductName,p=c.rating,w=!Object.keys(c).length>0,m=Number.isFinite(p)&&u;return Object(n.createElement)("li",{className:C()("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":l}),"aria-hidden":w},(d||i||s||l||m)&&Object(n.createElement)("div",{className:"wc-block-review-list-item__info wc-block-components-review-list-item__info"},l&&function(e,t,r){var c,a;return r||!e?Object(n.createElement)("div",{className:"wc-block-review-list-item__image wc-block-components-review-list-item__image"}):Object(n.createElement)("div",{className:"wc-block-review-list-item__image wc-block-components-review-list-item__image"},"product"===t?Object(n.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(n.createElement)("img",{"aria-hidden":"true",alt:"",src:e.reviewer_avatar_urls[96]||""}),e.verified&&Object(n.createElement)("div",{className:"wc-block-review-list-item__verified wc-block-components-review-list-item__verified",title:Object(o.__)("Verified buyer","woo-gutenberg-products-block")},Object(o.__)("Verified buyer","woo-gutenberg-products-block")))}(c,a,w),(d||s||m||i)&&Object(n.createElement)("div",{className:"wc-block-review-list-item__meta wc-block-components-review-list-item__meta"},m&&function(e){var t=e.rating,r={width:t/5*100+"%"},c=Object(o.sprintf)(
|
| 6 |
/* translators: %f is referring to the average rating value */
|
| 7 |
+
Object(o.__)("Rated %f out of 5","woo-gutenberg-products-block"),t);return Object(n.createElement)("div",{className:"wc-block-review-list-item__rating wc-block-components-review-list-item__rating"},Object(n.createElement)("div",{className:"wc-block-review-list-item__rating__stars wc-block-components-review-list-item__rating__stars",role:"img","aria-label":c},Object(n.createElement)("span",{style:r},c)))}(c),d&&function(e){return Object(n.createElement)("div",{className:"wc-block-review-list-item__product wc-block-components-review-list-item__product"},Object(n.createElement)("a",{href:e.product_permalink,dangerouslySetInnerHTML:{__html:e.product_name}}))}(c),s&&function(e){var t=e.reviewer,r=void 0===t?"":t;return Object(n.createElement)("div",{className:"wc-block-review-list-item__author wc-block-components-review-list-item__author"},r)}(c),i&&function(e){var t=e.date_created,r=e.formatted_date_created;return Object(n.createElement)("time",{className:"wc-block-review-list-item__published-date wc-block-components-review-list-item__published-date",dateTime:t},r)}(c))),b&&function(e){return Object(n.createElement)(H,{maxLines:10,moreText:Object(o.__)("Read full review","woo-gutenberg-products-block"),lessText:Object(o.__)("Hide full review","woo-gutenberg-products-block"),className:"wc-block-review-list-item__text wc-block-components-review-list-item__text"},Object(n.createElement)("div",{dangerouslySetInnerHTML:{__html:e.review||""}}))}(c))};function F(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function V(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?F(Object(r),!0).forEach((function(t){P()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):F(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}r(254);var z=function(e){var t=e.attributes,r=e.reviews,o=Object(h.getSetting)("showAvatars",!0),c=Object(h.getSetting)("reviewRatingsEnabled",!0),a=(o||"product"===t.imageType)&&t.showReviewImage,i=c&&t.showReviewRating,s=V(V({},t),{},{showReviewImage:a,showReviewRating:i});return Object(n.createElement)("ul",{className:"wc-block-review-list wc-block-components-review-list"},0===r.length?Object(n.createElement)(G,{attributes:s}):r.map((function(e,t){return Object(n.createElement)(G,{key:e.id||t,attributes:s,review:e})})))},W=r(9),U=r.n(W),J=r(29),q=r.n(J),Y=r(22),K=r.n(Y),Q=r(34),X=r.n(Q),Z=r(85),$=r(42);var ee=function(e){var t=function(t){p()(a,t);var r,o,c=(r=a,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=g()(r);if(o){var n=g()(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return m()(this,e)});function a(){var e;l()(this,a);for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return e=c.call.apply(c,[this].concat(r)),P()(T()(e),"isPreview",!!e.props.attributes.previewReviews),P()(T()(e),"delayedAppendReviews",e.props.delayFunction(e.appendReviews)),P()(T()(e),"isMounted",!1),P()(T()(e),"state",{error:null,loading:!0,reviews:e.isPreview?e.props.attributes.previewReviews:[],totalReviews:e.isPreview?e.props.attributes.previewReviews.length:0}),P()(T()(e),"setError",function(){var t=q()(K.a.mark((function t(r){var n,o;return K.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.isMounted){t.next=2;break}return t.abrupt("return");case 2:return n=e.props.onReviewsLoadError,t.next=5,Object($.a)(r);case 5:o=t.sent,e.setState({reviews:[],loading:!1,error:o}),n(o);case 8:case"end":return t.stop()}}),t)})));return function(_x){return t.apply(this,arguments)}}()),e}return b()(a,[{key:"componentDidMount",value:function(){this.isMounted=!0,this.replaceReviews()}},{key:"componentDidUpdate",value:function(e){e.reviewsToDisplay<this.props.reviewsToDisplay?this.delayedAppendReviews():this.shouldReplaceReviews(e,this.props)&&this.replaceReviews()}},{key:"shouldReplaceReviews",value:function(e,t){return e.orderby!==t.orderby||e.order!==t.order||e.productId!==t.productId||!X()(e.categoryIds,t.categoryIds)}},{key:"componentWillUnmount",value:function(){this.isMounted=!1,this.delayedAppendReviews.cancel&&this.delayedAppendReviews.cancel()}},{key:"getArgs",value:function(e){var t=this.props,r=t.categoryIds,n=t.order,o=t.orderby,c=t.productId,a={order:n,orderby:o,per_page:t.reviewsToDisplay-e,offset:e};return r&&r.length&&(a.category_id=Array.isArray(r)?r.join(","):r),c&&(a.product_id=c),a}},{key:"replaceReviews",value:function(){if(!this.isPreview){var e=this.props.onReviewsReplaced;this.updateListOfReviews().then(e)}}},{key:"appendReviews",value:function(){if(!this.isPreview){var e=this.props,t=e.onReviewsAppended,r=e.reviewsToDisplay,n=this.state.reviews;r<=n.length||this.updateListOfReviews(n).then(t)}}},{key:"updateListOfReviews",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=this.props.reviewsToDisplay,n=this.state.totalReviews,o=Math.min(n,r)-t.length;return this.setState({loading:!0,reviews:t.concat(Array(o).fill({}))}),Object(Z.c)(this.getArgs(t.length)).then((function(r){var n=r.reviews,o=r.totalReviews;return e.isMounted&&e.setState({reviews:t.filter((function(e){return Object.keys(e).length})).concat(n),totalReviews:o,loading:!1,error:null}),{newReviews:n}})).catch(this.setError)}},{key:"render",value:function(){var t=this.props.reviewsToDisplay,r=this.state,o=r.error,c=r.loading,a=r.reviews,i=r.totalReviews;return Object(n.createElement)(e,U()({},this.props,{error:o,isLoading:c,reviews:a.slice(0,t),totalReviews:i}))}}]),a}(f.Component);P()(t,"defaultProps",{delayFunction:function(e){return e},onReviewsAppended:function(){},onReviewsLoadError:function(){},onReviewsReplaced:function(){}});var r=e.displayName,o=void 0===r?e.name||"Component":r;return t.displayName="WithReviews( ".concat(o," )"),t}(function(e){p()(i,e);var t,r,c=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=g()(t);if(r){var o=g()(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return m()(this,e)});function i(){return l()(this,i),c.apply(this,arguments)}return b()(i,[{key:"render",value:function(){var e=this.props,t=e.attributes,r=e.error,c=e.isLoading,i=e.noReviewsPlaceholder,s=e.reviews,l=e.totalReviews;if(r)return Object(n.createElement)(O.a,{className:"wc-block-featured-product-error",error:r,isLoading:c});if(0===s.length&&!c)return Object(n.createElement)(i,{attributes:t});var u=Object(h.getSetting)("reviewRatingsEnabled",!0);return Object(n.createElement)(a.Disabled,null,t.showOrderby&&u&&Object(n.createElement)(R,{readOnly:!0,value:t.orderby}),Object(n.createElement)(z,{attributes:t,reviews:s}),t.showLoadMore&&l>s.length&&Object(n.createElement)(_,{screenReaderLabel:Object(o.__)("Load more reviews","woo-gutenberg-products-block")}))}}]),i}(f.Component));t.a=function(e){var t=e.attributes,r=e.icon,s=e.name,l=e.noReviewsPlaceholder,u=t.categoryIds,b=t.productId,d=t.reviewsOnPageLoad,p=t.showProductName,w=t.showReviewDate,m=t.showReviewerName,v=t.showReviewContent,g=t.showReviewImage,f=t.showReviewRating,h=Object(Z.d)(t.orderby),O=h.order,y=h.orderby,j=!(v||f||w||m||g||p),_=Object(i.useBlockProps)({className:Object(Z.a)(t)});return j?Object(n.createElement)(a.Placeholder,{icon:r,label:s},Object(o.__)("The content for this block is hidden due to block settings.","woo-gutenberg-products-block")):Object(n.createElement)("div",_,Object(n.createElement)(ee,{attributes:t,categoryIds:u,delayFunction:function(e){return Object(c.debounce)(e,400)},noReviewsPlaceholder:l,orderby:y,order:O,productId:b,reviewsToDisplay:d}))}},21:function(e,t){e.exports=window.wp.compose},215:function(e,t){},216:function(e,t){},22:function(e,t){e.exports=window.regeneratorRuntime},253:function(e,t){},254:function(e,t){},255:function(e,t){},256:function(e,t){},26:function(e,t){e.exports=window.wp.blocks},28:function(e,t){e.exports=window.wp.primitives},3:function(e,t){e.exports=window.wc.wcSettings},34:function(e,t){e.exports=window.wp.isShallowEqual},38:function(e,t,r){"use strict";r.d(t,"o",(function(){return c})),r.d(t,"m",(function(){return a})),r.d(t,"l",(function(){return i})),r.d(t,"n",(function(){return s})),r.d(t,"j",(function(){return l})),r.d(t,"e",(function(){return u})),r.d(t,"f",(function(){return b})),r.d(t,"g",(function(){return d})),r.d(t,"k",(function(){return p})),r.d(t,"c",(function(){return w})),r.d(t,"d",(function(){return m})),r.d(t,"h",(function(){return v})),r.d(t,"a",(function(){return g})),r.d(t,"i",(function(){return f})),r.d(t,"b",(function(){return h}));var n,o=r(3),c=Object(o.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),a=c.pluginUrl+"images/",i=c.pluginUrl+"build/",s=c.buildPhase,l=null===(n=o.STORE_PAGES.shop)||void 0===n?void 0:n.permalink,u=o.STORE_PAGES.checkout.id,b=o.STORE_PAGES.checkout.permalink,d=o.STORE_PAGES.privacy.permalink,p=(o.STORE_PAGES.privacy.title,o.STORE_PAGES.terms.permalink),w=(o.STORE_PAGES.terms.title,o.STORE_PAGES.cart.id),m=o.STORE_PAGES.cart.permalink,v=(o.STORE_PAGES.myaccount.permalink?o.STORE_PAGES.myaccount.permalink:Object(o.getSetting)("wpLoginUrl","/wp-login.php"),Object(o.getSetting)("shippingCountries",{})),g=Object(o.getSetting)("allowedCountries",{}),f=Object(o.getSetting)("shippingStates",{}),h=Object(o.getSetting)("allowedStates",{})},4:function(e,t){e.exports=window.wp.components},41:function(e,t,r){"use strict";var n=r(5),o=r.n(n),c=r(0),a=r(6),i=r.n(a);function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}t.a=function(e){var t,r=e.label,n=e.screenReaderLabel,o=e.wrapperElement,a=e.wrapperProps,s=void 0===a?{}:a,u=null!=r,b=null!=n;return!u&&b?(t=o||"span",s=l(l({},s),{},{className:i()(s.className,"screen-reader-text")}),Object(c.createElement)(t,s,n)):(t=o||c.Fragment,u&&b&&r!==n?Object(c.createElement)(t,s,Object(c.createElement)("span",{"aria-hidden":"true"},r),Object(c.createElement)("span",{className:"screen-reader-text"},n)):Object(c.createElement)(t,s,r))}},42:function(e,t,r){"use strict";r.d(t,"a",(function(){return s})),r.d(t,"b",(function(){return l}));var n=r(29),o=r.n(n),c=r(22),a=r.n(c),i=r(1),s=function(){var e=o()(a.a.mark((function e(t){var r;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("function"!=typeof t.json){e.next=11;break}return e.prev=1,e.next=4,t.json();case 4:return r=e.sent,e.abrupt("return",{message:r.message,type:r.type||"api"});case 8:return e.prev=8,e.t0=e.catch(1),e.abrupt("return",{message:e.t0.message,type:"general"});case 11:return e.abrupt("return",{message:t.message,type:t.type||"general"});case 12:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(_x){return e.apply(this,arguments)}}(),l=function(e){if(e.data&&"rest_invalid_param"===e.code){var t=Object.values(e.data.params);if(t[0])return t[0]}return(null==e?void 0:e.message)||Object(i.__)("Something went wrong. Please contact us to get assistance.","woo-gutenberg-products-block")}},48:function(e,t){e.exports=window.wp.escapeHtml},52:function(e,t,r){"use strict";var n=r(0),o=r(1),c=(r(2),r(48));t.a=function(e){var t,r,a,i=e.error;return Object(n.createElement)("div",{className:"wc-block-error-message"},(r=(t=i).message,a=t.type,r?"general"===a?Object(n.createElement)("span",null,Object(o.__)("The following error was returned","woo-gutenberg-products-block"),Object(n.createElement)("br",null),Object(n.createElement)("code",null,Object(c.escapeHTML)(r))):"api"===a?Object(n.createElement)("span",null,Object(o.__)("The following error was returned from the API","woo-gutenberg-products-block"),Object(n.createElement)("br",null),Object(n.createElement)("code",null,Object(c.escapeHTML)(r))):r:Object(o.__)("An unknown error occurred which prevented the block from being updated.","woo-gutenberg-products-block")))}},66:function(e,t,r){"use strict";var n=r(5),o=r.n(n),c=r(16),a=r.n(c),i=r(0),s=["srcElement","size"];function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}t.a=function(e){var t=e.srcElement,r=e.size,n=void 0===r?24:r,c=a()(e,s);return Object(i.isValidElement)(t)?Object(i.cloneElement)(t,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({width:n,height:n},c)):null}},7:function(e,t){e.exports=window.lodash},774:function(e,t,r){e.exports=r(864)},85:function(e,t,r){"use strict";r.d(t,"d",(function(){return s})),r.d(t,"c",(function(){return l})),r.d(t,"a",(function(){return u})),r.d(t,"b",(function(){return b}));var n=r(15),o=r.n(n),c=r(6),a=r.n(c),i=r(3),s=function(e){if(Object(i.getSetting)("reviewRatingsEnabled",!0)){if("lowest-rating"===e)return{order:"asc",orderby:"rating"};if("highest-rating"===e)return{order:"desc",orderby:"rating"}}return{order:"desc",orderby:"date_gmt"}},l=function(e){return o()({path:"/wc/store/products/reviews?"+Object.entries(e).map((function(e){return e.join("=")})).join("&"),parse:!1}).then((function(e){return e.json().then((function(t){return{reviews:t,totalReviews:parseInt(e.headers.get("x-wp-total"),10)}}))}))},u=function(e){var t=e.className,r=e.categoryIds,n=e.productId,o=e.showReviewDate,c=e.showReviewerName,i=e.showReviewContent,s=e.showProductName,l=e.showReviewImage,u=e.showReviewRating,b="wc-block-all-reviews";return n&&(b="wc-block-reviews-by-product"),Array.isArray(r)&&(b="wc-block-reviews-by-category"),a()(b,t,{"has-image":l,"has-name":c,"has-date":o,"has-rating":u,"has-content":i,"has-product-name":s})},b=function(e){var t=e.categoryIds,r=e.imageType,n=e.orderby,o=e.productId,c={"data-image-type":r,"data-orderby":n,"data-reviews-on-page-load":e.reviewsOnPageLoad,"data-reviews-on-load-more":e.reviewsOnLoadMore,"data-show-load-more":e.showLoadMore,"data-show-orderby":e.showOrderby};return o&&(c["data-product-id"]=o),Array.isArray(t)&&(c["data-category-ids"]=t.join(",")),c}},864:function(e,t,r){"use strict";r.r(t);var n=r(5),o=r.n(n),c=r(0),a=r(1),i=r(26),s=r(66),l=r(28),u=Object(c.createElement)(l.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(c.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(c.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"})),b=(r(215),r(12)),d=r(4),p=(r(2),r(199)),w=function(){return Object(c.createElement)(d.Placeholder,{className:"wc-block-all-reviews",icon:Object(c.createElement)(s.a,{srcElement:u,className:"block-editor-block-icon"}),label:Object(a.__)("All Reviews","woo-gutenberg-products-block")},Object(a.__)("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"))},m=r(144),v=r(192),g=r(193),f=r(161);function h(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function O(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?h(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):h(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}Object(i.registerBlockType)("woocommerce/all-reviews",{apiVersion:2,title:Object(a.__)("All Reviews","woo-gutenberg-products-block"),icon:{src:Object(c.createElement)(s.a,{srcElement:u}),foreground:"#96588a"},category:"woocommerce",keywords:[Object(a.__)("WooCommerce","woo-gutenberg-products-block")],description:Object(a.__)("Show a list of all product reviews.","woo-gutenberg-products-block"),supports:{html:!1,color:{background:!1},typography:{fontSize:!0}},example:O(O({},f.a),{},{attributes:O(O({},f.a.attributes),{},{showProductName:!0})}),attributes:O(O({},v.a),{},{showProductName:{type:"boolean",default:!0}}),transforms:{from:[{type:"block",blocks:["core/legacy-widget"],isMatch:function(e){var t=e.idBase,r=e.instance;return"woocommerce_recent_reviews"===t&&!(null==r||!r.raw)},transform:function(e){var t=e.instance;return Object(i.createBlock)("woocommerce/all-reviews",{reviewsOnPageLoad:t.raw.number,imageType:"product",showLoadMore:!1,showOrderby:!1,showReviewDate:!1,showReviewContent:!1})}}]},edit:function(e){var t=e.attributes,r=e.setAttributes;return Object(c.createElement)(c.Fragment,null,Object(c.createElement)(b.InspectorControls,{key:"inspector"},Object(c.createElement)(d.PanelBody,{title:Object(a.__)("Content","woo-gutenberg-products-block")},Object(c.createElement)(d.ToggleControl,{label:Object(a.__)("Product name","woo-gutenberg-products-block"),checked:t.showProductName,onChange:function(){return r({showProductName:!t.showProductName})}}),Object(m.b)(t,r)),Object(c.createElement)(d.PanelBody,{title:Object(a.__)("List Settings","woo-gutenberg-products-block")},Object(m.c)(t,r))),Object(c.createElement)(p
|
