@wikala/spmkt 3.0.0-beta.2 → 4.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -0
- package/dist/analytics/ga4.d.ts +44 -0
- package/dist/analytics/ga4.js +47 -0
- package/dist/analytics/ga4.js.map +1 -0
- package/dist/core/api/account.d.ts +25 -0
- package/dist/core/api/account.js +27 -0
- package/dist/core/api/account.js.map +1 -0
- package/dist/core/api/address.d.ts +15 -0
- package/dist/core/api/address.js +23 -0
- package/dist/core/api/address.js.map +1 -0
- package/dist/core/api/cart.d.ts +24 -0
- package/dist/core/api/cart.js +20 -0
- package/dist/core/api/cart.js.map +1 -0
- package/dist/core/api/checkout.d.ts +83 -0
- package/dist/core/api/checkout.js +68 -0
- package/dist/core/api/checkout.js.map +1 -0
- package/dist/core/api/index.d.ts +12 -0
- package/dist/core/api/location.d.ts +8 -0
- package/dist/core/api/location.js +16 -0
- package/dist/core/api/location.js.map +1 -0
- package/dist/core/api/product.d.ts +5 -0
- package/dist/core/api/product.js +7 -0
- package/dist/core/api/product.js.map +1 -0
- package/dist/core/api/questions.d.ts +3 -0
- package/dist/core/api/questions.js +9 -0
- package/dist/core/api/questions.js.map +1 -0
- package/dist/core/api/reviews.d.ts +17 -0
- package/dist/core/api/reviews.js +30 -0
- package/dist/core/api/reviews.js.map +1 -0
- package/dist/core/api/search.d.ts +3 -0
- package/dist/core/api/search.js +8 -0
- package/dist/core/api/search.js.map +1 -0
- package/dist/core/config.d.ts +16 -0
- package/dist/core/config.js +33 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/cookies.d.ts +5 -0
- package/dist/core/cookies.js +29 -0
- package/dist/core/cookies.js.map +1 -0
- package/dist/core/errors.d.ts +27 -0
- package/dist/core/errors.js +42 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/events.d.ts +138 -0
- package/dist/core/events.js +13 -0
- package/dist/core/events.js.map +1 -0
- package/dist/core/forms.d.ts +17 -0
- package/dist/core/forms.js +70 -0
- package/dist/core/forms.js.map +1 -0
- package/dist/core/i18n.d.ts +26 -0
- package/dist/core/i18n.js +82 -0
- package/dist/core/i18n.js.map +1 -0
- package/dist/core/index.d.ts +22 -0
- package/dist/core/index.js +160 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/money.d.ts +12 -0
- package/dist/core/money.js +35 -0
- package/dist/core/money.js.map +1 -0
- package/dist/core/page-events.d.ts +30 -0
- package/dist/core/page-events.js +110 -0
- package/dist/core/page-events.js.map +1 -0
- package/dist/core/recaptcha.d.ts +17 -0
- package/dist/core/recaptcha.js +44 -0
- package/dist/core/recaptcha.js.map +1 -0
- package/dist/core/request.d.ts +38 -0
- package/dist/core/request.js +170 -0
- package/dist/core/request.js.map +1 -0
- package/dist/core/session.d.ts +7 -0
- package/dist/core/session.js +16 -0
- package/dist/core/session.js.map +1 -0
- package/dist/core/state.d.ts +29 -0
- package/dist/core/state.js +192 -0
- package/dist/core/state.js.map +1 -0
- package/dist/core/stores/cart.d.ts +44 -0
- package/dist/core/stores/cart.js +94 -0
- package/dist/core/stores/cart.js.map +1 -0
- package/dist/core/stores/checkout-draft.d.ts +58 -0
- package/dist/core/stores/checkout-draft.js +67 -0
- package/dist/core/stores/checkout-draft.js.map +1 -0
- package/dist/core/stores/checkout.d.ts +83 -0
- package/dist/core/stores/checkout.js +294 -0
- package/dist/core/stores/checkout.js.map +1 -0
- package/dist/core/stores/compare.d.ts +17 -0
- package/dist/core/stores/compare.js +78 -0
- package/dist/core/stores/compare.js.map +1 -0
- package/dist/core/stores/customer.d.ts +2 -0
- package/dist/core/stores/customer.js +13 -0
- package/dist/core/stores/customer.js.map +1 -0
- package/dist/core/stores/index.d.ts +9 -0
- package/dist/core/stores/location.d.ts +13 -0
- package/dist/core/stores/location.js +32 -0
- package/dist/core/stores/location.js.map +1 -0
- package/dist/core/types.d.ts +273 -0
- package/dist/elements/account-form/account-form.d.ts +33 -0
- package/dist/elements/account-form/account-form.js +42 -0
- package/dist/elements/account-form/account-form.js.map +1 -0
- package/dist/elements/account-form/index.d.ts +3 -0
- package/dist/elements/account-form/index.js +6 -0
- package/dist/elements/account-form/index.js.map +1 -0
- package/dist/elements/add-to-cart/add-to-cart.d.ts +42 -0
- package/dist/elements/add-to-cart/add-to-cart.js +113 -0
- package/dist/elements/add-to-cart/add-to-cart.js.map +1 -0
- package/dist/elements/add-to-cart/index.d.ts +3 -0
- package/dist/elements/add-to-cart/index.js +6 -0
- package/dist/elements/add-to-cart/index.js.map +1 -0
- package/dist/elements/address-autocomplete/address-autocomplete.d.ts +65 -0
- package/dist/elements/address-autocomplete/address-autocomplete.js +124 -0
- package/dist/elements/address-autocomplete/address-autocomplete.js.map +1 -0
- package/dist/elements/address-autocomplete/index.d.ts +3 -0
- package/dist/elements/address-autocomplete/index.js +7 -0
- package/dist/elements/address-autocomplete/index.js.map +1 -0
- package/dist/elements/address-book/address-book.d.ts +66 -0
- package/dist/elements/address-book/address-book.js +248 -0
- package/dist/elements/address-book/address-book.js.map +1 -0
- package/dist/elements/address-book/index.d.ts +3 -0
- package/dist/elements/address-book/index.js +6 -0
- package/dist/elements/address-book/index.js.map +1 -0
- package/dist/elements/age-check/age-check.d.ts +89 -0
- package/dist/elements/age-check/age-check.js +195 -0
- package/dist/elements/age-check/age-check.js.map +1 -0
- package/dist/elements/age-check/index.d.ts +3 -0
- package/dist/elements/age-check/index.js +8 -0
- package/dist/elements/age-check/index.js.map +1 -0
- package/dist/elements/age-gate/age-gate.d.ts +21 -0
- package/dist/elements/age-gate/age-gate.js +24 -0
- package/dist/elements/age-gate/age-gate.js.map +1 -0
- package/dist/elements/age-gate/index.d.ts +3 -0
- package/dist/elements/age-gate/index.js +7 -0
- package/dist/elements/age-gate/index.js.map +1 -0
- package/dist/elements/back-in-stock/back-in-stock.d.ts +61 -0
- package/dist/elements/back-in-stock/back-in-stock.js +101 -0
- package/dist/elements/back-in-stock/back-in-stock.js.map +1 -0
- package/dist/elements/back-in-stock/index.d.ts +3 -0
- package/dist/elements/back-in-stock/index.js +6 -0
- package/dist/elements/back-in-stock/index.js.map +1 -0
- package/dist/elements/carousel/carousel.d.ts +51 -0
- package/dist/elements/carousel/carousel.js +133 -0
- package/dist/elements/carousel/carousel.js.map +1 -0
- package/dist/elements/carousel/index.d.ts +3 -0
- package/dist/elements/carousel/index.js +6 -0
- package/dist/elements/carousel/index.js.map +1 -0
- package/dist/elements/cart/cart.d.ts +50 -0
- package/dist/elements/cart/cart.js +268 -0
- package/dist/elements/cart/cart.js.map +1 -0
- package/dist/elements/cart/index.d.ts +3 -0
- package/dist/elements/cart/index.js +6 -0
- package/dist/elements/cart/index.js.map +1 -0
- package/dist/elements/cart-count/cart-count.d.ts +16 -0
- package/dist/elements/cart-count/cart-count.js +32 -0
- package/dist/elements/cart-count/cart-count.js.map +1 -0
- package/dist/elements/cart-count/index.d.ts +3 -0
- package/dist/elements/cart-count/index.js +6 -0
- package/dist/elements/cart-count/index.js.map +1 -0
- package/dist/elements/checkout/checkout.d.ts +58 -0
- package/dist/elements/checkout/checkout.js +177 -0
- package/dist/elements/checkout/checkout.js.map +1 -0
- package/dist/elements/checkout/index.d.ts +3 -0
- package/dist/elements/checkout/index.js +6 -0
- package/dist/elements/checkout/index.js.map +1 -0
- package/dist/elements/checkout-address/checkout-address.d.ts +41 -0
- package/dist/elements/checkout-address/checkout-address.js +105 -0
- package/dist/elements/checkout-address/checkout-address.js.map +1 -0
- package/dist/elements/checkout-address/index.d.ts +3 -0
- package/dist/elements/checkout-address/index.js +6 -0
- package/dist/elements/checkout-address/index.js.map +1 -0
- package/dist/elements/checkout-delivery/checkout-delivery.d.ts +68 -0
- package/dist/elements/checkout-delivery/checkout-delivery.js +286 -0
- package/dist/elements/checkout-delivery/checkout-delivery.js.map +1 -0
- package/dist/elements/checkout-delivery/index.d.ts +3 -0
- package/dist/elements/checkout-delivery/index.js +6 -0
- package/dist/elements/checkout-delivery/index.js.map +1 -0
- package/dist/elements/checkout-identity/checkout-identity.d.ts +34 -0
- package/dist/elements/checkout-identity/checkout-identity.js +49 -0
- package/dist/elements/checkout-identity/checkout-identity.js.map +1 -0
- package/dist/elements/checkout-identity/index.d.ts +3 -0
- package/dist/elements/checkout-identity/index.js +6 -0
- package/dist/elements/checkout-identity/index.js.map +1 -0
- package/dist/elements/checkout-payment/checkout-payment.d.ts +67 -0
- package/dist/elements/checkout-payment/checkout-payment.js +279 -0
- package/dist/elements/checkout-payment/checkout-payment.js.map +1 -0
- package/dist/elements/checkout-payment/index.d.ts +3 -0
- package/dist/elements/checkout-payment/index.js +6 -0
- package/dist/elements/checkout-payment/index.js.map +1 -0
- package/dist/elements/collection/collection.d.ts +62 -0
- package/dist/elements/collection/collection.js +179 -0
- package/dist/elements/collection/collection.js.map +1 -0
- package/dist/elements/collection/index.d.ts +3 -0
- package/dist/elements/collection/index.js +6 -0
- package/dist/elements/collection/index.js.map +1 -0
- package/dist/elements/combobox/combobox.d.ts +54 -0
- package/dist/elements/combobox/combobox.js +178 -0
- package/dist/elements/combobox/combobox.js.map +1 -0
- package/dist/elements/combobox/index.d.ts +2 -0
- package/dist/elements/combobox/index.js +5 -0
- package/dist/elements/combobox/index.js.map +1 -0
- package/dist/elements/compare-bar/compare-bar.d.ts +21 -0
- package/dist/elements/compare-bar/compare-bar.js +34 -0
- package/dist/elements/compare-bar/compare-bar.js.map +1 -0
- package/dist/elements/compare-bar/index.d.ts +3 -0
- package/dist/elements/compare-bar/index.js +6 -0
- package/dist/elements/compare-bar/index.js.map +1 -0
- package/dist/elements/compare-remove/compare-remove.d.ts +20 -0
- package/dist/elements/compare-remove/compare-remove.js +19 -0
- package/dist/elements/compare-remove/compare-remove.js.map +1 -0
- package/dist/elements/compare-remove/index.d.ts +3 -0
- package/dist/elements/compare-remove/index.js +6 -0
- package/dist/elements/compare-remove/index.js.map +1 -0
- package/dist/elements/compare-toggle/compare-toggle.d.ts +39 -0
- package/dist/elements/compare-toggle/compare-toggle.js +53 -0
- package/dist/elements/compare-toggle/compare-toggle.js.map +1 -0
- package/dist/elements/compare-toggle/index.d.ts +3 -0
- package/dist/elements/compare-toggle/index.js +6 -0
- package/dist/elements/compare-toggle/index.js.map +1 -0
- package/dist/elements/dialog/dialog.d.ts +27 -0
- package/dist/elements/dialog/dialog.js +69 -0
- package/dist/elements/dialog/dialog.js.map +1 -0
- package/dist/elements/dialog/index.d.ts +3 -0
- package/dist/elements/dialog/index.js +6 -0
- package/dist/elements/dialog/index.js.map +1 -0
- package/dist/elements/location-picker/index.d.ts +3 -0
- package/dist/elements/location-picker/index.js +6 -0
- package/dist/elements/location-picker/index.js.map +1 -0
- package/dist/elements/location-picker/location-picker.d.ts +28 -0
- package/dist/elements/location-picker/location-picker.js +88 -0
- package/dist/elements/location-picker/location-picker.js.map +1 -0
- package/dist/elements/mini-cart/index.d.ts +3 -0
- package/dist/elements/mini-cart/index.js +6 -0
- package/dist/elements/mini-cart/index.js.map +1 -0
- package/dist/elements/mini-cart/mini-cart.d.ts +29 -0
- package/dist/elements/mini-cart/mini-cart.js +114 -0
- package/dist/elements/mini-cart/mini-cart.js.map +1 -0
- package/dist/elements/mobile-nav/index.d.ts +3 -0
- package/dist/elements/mobile-nav/index.js +6 -0
- package/dist/elements/mobile-nav/index.js.map +1 -0
- package/dist/elements/mobile-nav/mobile-nav.d.ts +20 -0
- package/dist/elements/mobile-nav/mobile-nav.js +29 -0
- package/dist/elements/mobile-nav/mobile-nav.js.map +1 -0
- package/dist/elements/order-confirmation/index.d.ts +3 -0
- package/dist/elements/order-confirmation/index.js +7 -0
- package/dist/elements/order-confirmation/index.js.map +1 -0
- package/dist/elements/order-confirmation/order-confirmation.d.ts +35 -0
- package/dist/elements/order-confirmation/order-confirmation.js +123 -0
- package/dist/elements/order-confirmation/order-confirmation.js.map +1 -0
- package/dist/elements/product-gallery/index.d.ts +3 -0
- package/dist/elements/product-gallery/index.js +6 -0
- package/dist/elements/product-gallery/index.js.map +1 -0
- package/dist/elements/product-gallery/product-gallery.d.ts +49 -0
- package/dist/elements/product-gallery/product-gallery.js +143 -0
- package/dist/elements/product-gallery/product-gallery.js.map +1 -0
- package/dist/elements/quantity/index.d.ts +3 -0
- package/dist/elements/quantity/index.js +6 -0
- package/dist/elements/quantity/index.js.map +1 -0
- package/dist/elements/quantity/quantity.d.ts +21 -0
- package/dist/elements/quantity/quantity.js +57 -0
- package/dist/elements/quantity/quantity.js.map +1 -0
- package/dist/elements/questions/index.d.ts +3 -0
- package/dist/elements/questions/index.js +6 -0
- package/dist/elements/questions/index.js.map +1 -0
- package/dist/elements/questions/questions.d.ts +28 -0
- package/dist/elements/questions/questions.js +65 -0
- package/dist/elements/questions/questions.js.map +1 -0
- package/dist/elements/quick-view/index.d.ts +2 -0
- package/dist/elements/quick-view/index.js +6 -0
- package/dist/elements/quick-view/index.js.map +1 -0
- package/dist/elements/quick-view/quick-view.d.ts +29 -0
- package/dist/elements/quick-view/quick-view.js +76 -0
- package/dist/elements/quick-view/quick-view.js.map +1 -0
- package/dist/elements/range/index.d.ts +3 -0
- package/dist/elements/range/index.js +6 -0
- package/dist/elements/range/index.js.map +1 -0
- package/dist/elements/range/range.d.ts +24 -0
- package/dist/elements/range/range.js +37 -0
- package/dist/elements/range/range.js.map +1 -0
- package/dist/elements/related/index.d.ts +3 -0
- package/dist/elements/related/index.js +6 -0
- package/dist/elements/related/index.js.map +1 -0
- package/dist/elements/related/related.d.ts +28 -0
- package/dist/elements/related/related.js +69 -0
- package/dist/elements/related/related.js.map +1 -0
- package/dist/elements/review-form/index.d.ts +3 -0
- package/dist/elements/review-form/index.js +6 -0
- package/dist/elements/review-form/index.js.map +1 -0
- package/dist/elements/review-form/review-form.d.ts +60 -0
- package/dist/elements/review-form/review-form.js +158 -0
- package/dist/elements/review-form/review-form.js.map +1 -0
- package/dist/elements/reviews/index.d.ts +3 -0
- package/dist/elements/reviews/index.js +6 -0
- package/dist/elements/reviews/index.js.map +1 -0
- package/dist/elements/reviews/reviews.d.ts +19 -0
- package/dist/elements/reviews/reviews.js +30 -0
- package/dist/elements/reviews/reviews.js.map +1 -0
- package/dist/elements/search/index.d.ts +3 -0
- package/dist/elements/search/index.js +6 -0
- package/dist/elements/search/index.js.map +1 -0
- package/dist/elements/search/search.d.ts +20 -0
- package/dist/elements/search/search.js +53 -0
- package/dist/elements/search/search.js.map +1 -0
- package/dist/elements/shared/folding-form.d.ts +15 -0
- package/dist/elements/shared/folding-form.js +35 -0
- package/dist/elements/shared/folding-form.js.map +1 -0
- package/dist/elements/shared/google-maps.d.ts +100 -0
- package/dist/elements/shared/google-maps.js +34 -0
- package/dist/elements/shared/google-maps.js.map +1 -0
- package/dist/elements/shared/json-form.d.ts +28 -0
- package/dist/elements/shared/json-form.js +85 -0
- package/dist/elements/shared/json-form.js.map +1 -0
- package/dist/elements/shared/paged-section.d.ts +28 -0
- package/dist/elements/shared/paged-section.js +93 -0
- package/dist/elements/shared/paged-section.js.map +1 -0
- package/dist/elements/shared/phone-mask.d.ts +9 -0
- package/dist/elements/shared/phone-mask.js +38 -0
- package/dist/elements/shared/phone-mask.js.map +1 -0
- package/dist/elements/shared/select-item.d.ts +7 -0
- package/dist/elements/shared/select-item.js +19 -0
- package/dist/elements/shared/select-item.js.map +1 -0
- package/dist/elements/shared/totals.d.ts +53 -0
- package/dist/elements/shared/totals.js +82 -0
- package/dist/elements/shared/totals.js.map +1 -0
- package/dist/elements/store-availability/index.d.ts +3 -0
- package/dist/elements/store-availability/index.js +6 -0
- package/dist/elements/store-availability/index.js.map +1 -0
- package/dist/elements/store-availability/store-availability.d.ts +26 -0
- package/dist/elements/store-availability/store-availability.js +66 -0
- package/dist/elements/store-availability/store-availability.js.map +1 -0
- package/dist/elements/store-map/index.d.ts +4 -0
- package/dist/elements/store-map/index.js +8 -0
- package/dist/elements/store-map/index.js.map +1 -0
- package/dist/elements/store-map/store-map.d.ts +59 -0
- package/dist/elements/store-map/store-map.js +118 -0
- package/dist/elements/store-map/store-map.js.map +1 -0
- package/dist/elements/tabs/index.d.ts +3 -0
- package/dist/elements/tabs/index.js +6 -0
- package/dist/elements/tabs/index.js.map +1 -0
- package/dist/elements/tabs/tabs.d.ts +21 -0
- package/dist/elements/tabs/tabs.js +69 -0
- package/dist/elements/tabs/tabs.js.map +1 -0
- package/dist/elements/toaster/index.d.ts +3 -0
- package/dist/elements/toaster/index.js +7 -0
- package/dist/elements/toaster/index.js.map +1 -0
- package/dist/elements/toaster/toaster.d.ts +47 -0
- package/dist/elements/toaster/toaster.js +109 -0
- package/dist/elements/toaster/toaster.js.map +1 -0
- package/dist/elements/variant-picker/index.d.ts +3 -0
- package/dist/elements/variant-picker/index.js +6 -0
- package/dist/elements/variant-picker/index.js.map +1 -0
- package/dist/elements/variant-picker/variant-picker.d.ts +30 -0
- package/dist/elements/variant-picker/variant-picker.js +85 -0
- package/dist/elements/variant-picker/variant-picker.js.map +1 -0
- package/dist/elements/vote/index.d.ts +3 -0
- package/dist/elements/vote/index.js +6 -0
- package/dist/elements/vote/index.js.map +1 -0
- package/dist/elements/vote/vote.d.ts +33 -0
- package/dist/elements/vote/vote.js +72 -0
- package/dist/elements/vote/vote.js.map +1 -0
- package/dist/lit/forms.d.ts +8 -0
- package/dist/lit/forms.js +42 -0
- package/dist/lit/forms.js.map +1 -0
- package/dist/lit/fragments.d.ts +28 -0
- package/dist/lit/fragments.js +70 -0
- package/dist/lit/fragments.js.map +1 -0
- package/dist/lit/index.d.ts +7 -0
- package/dist/lit/index.js +21 -0
- package/dist/lit/index.js.map +1 -0
- package/dist/lit/lazy-define.d.ts +35 -0
- package/dist/lit/lazy-define.js +103 -0
- package/dist/lit/lazy-define.js.map +1 -0
- package/dist/lit/signal-controller.d.ts +19 -0
- package/dist/lit/signal-controller.js +30 -0
- package/dist/lit/signal-controller.js.map +1 -0
- package/dist/lit/spmkt-element.d.ts +40 -0
- package/dist/lit/spmkt-element.js +76 -0
- package/dist/lit/spmkt-element.js.map +1 -0
- package/dist/locales/en.json +170 -0
- package/dist/locales/sr.json +176 -0
- package/package.json +45 -55
- package/MIGRATION_GUIDE.md +0 -310
- package/api/address.js +0 -115
- package/api/affiliate.js +0 -12
- package/api/cart.js +0 -81
- package/api/compare.js +0 -47
- package/api/countries.js +0 -13
- package/api/order.js +0 -27
- package/api/product-questions.js +0 -36
- package/api/product-reviews.js +0 -35
- package/api/product.js +0 -59
- package/api/request.js +0 -118
- package/api/user.js +0 -71
- package/api.js +0 -26
- package/components/Account/AccountDashboard.vue +0 -136
- package/components/Account/AccountStore.js +0 -97
- package/components/Account/AffiliateReport.vue +0 -98
- package/components/Account/Orders/OrderDetail.vue +0 -169
- package/components/Account/Orders/Orders.vue +0 -124
- package/components/Account/Settings/AccountSettings.vue +0 -45
- package/components/Account/Settings/ChangeEmail.vue +0 -136
- package/components/Account/Settings/ChangeName.vue +0 -82
- package/components/Account/Settings/ChangePassword.vue +0 -91
- package/components/Address/Address.vue +0 -141
- package/components/Address/AddressBook.vue +0 -171
- package/components/Address/AddressSelect.vue +0 -203
- package/components/Address/Edit.vue +0 -507
- package/components/Address/PostalCode.vue +0 -67
- package/components/Address/address.schema.js +0 -84
- package/components/AgeGate.vue +0 -109
- package/components/Auth/Login.vue +0 -191
- package/components/Auth/Register.vue +0 -240
- package/components/Auth/ResetPassword.vue +0 -108
- package/components/Cart/AgeVerification/AgeChecker.vue +0 -141
- package/components/Cart/CartBadge.vue +0 -68
- package/components/Cart/CartBox.vue +0 -139
- package/components/Cart/CartItem.vue +0 -126
- package/components/Cart/CartMode.vue +0 -200
- package/components/Cart/CartPreview.vue +0 -166
- package/components/Cart/CartSummary.vue +0 -107
- package/components/Cart/Coupon.vue +0 -107
- package/components/Cart/CreditCard/Everyware.vue +0 -262
- package/components/Cart/CreditCard/ExtendedCreditCard.vue +0 -240
- package/components/Cart/CreditCard/SquarePay.vue +0 -296
- package/components/Cart/CreditCard/StandardCreditCard.vue +0 -241
- package/components/Cart/Delivery/Delivery.vue +0 -364
- package/components/Cart/Delivery/DeliveryAddress.vue +0 -195
- package/components/Cart/Delivery/DeliveryAddressGuest.vue +0 -204
- package/components/Cart/Delivery/DeliveryMethods.vue +0 -109
- package/components/Cart/Delivery/DeliveryOptions.vue +0 -171
- package/components/Cart/Delivery/DeliveryTypes.vue +0 -61
- package/components/Cart/Delivery/DeliveryWarning.vue +0 -14
- package/components/Cart/Delivery/ReservationSlots.vue +0 -88
- package/components/Cart/Delivery/reservation.schema.js +0 -35
- package/components/Cart/Disclaimer.vue +0 -56
- package/components/Cart/OrderConfirmation.vue +0 -187
- package/components/Cart/Payment/Payment.vue +0 -436
- package/components/Cart/Payment/PaymentMethods.vue +0 -59
- package/components/Cart/ReviewAndSubmit.vue +0 -159
- package/components/Cart/ShoppingCart.vue +0 -219
- package/components/Cart/Store/actions.js +0 -129
- package/components/Cart/Store/getters.js +0 -82
- package/components/Cart/Store/index.js +0 -14
- package/components/Cart/Store/mutations.js +0 -174
- package/components/Cart/Store/state.js +0 -80
- package/components/Cart/UserIdentity.vue +0 -178
- package/components/Category/CategoryFilter.vue +0 -333
- package/components/Category/CategorySort.vue +0 -77
- package/components/Category/LoadMore.vue +0 -98
- package/components/DeliverTo.vue +0 -51
- package/components/DeliveryNotice.vue +0 -123
- package/components/DobInput.vue +0 -294
- package/components/Gmaps/GmapsAutocomplete.vue +0 -166
- package/components/Gmaps/GmapsLocations.vue +0 -233
- package/components/Gmaps/GmapsSingleLocation.vue +0 -134
- package/components/MobileMenu/MobileMenu.vue +0 -224
- package/components/MobileMenu/components/MenuBurger.vue +0 -23
- package/components/MobileMenu/components/MenuPanel.vue +0 -80
- package/components/MobileMenu/components/MenuShadow.vue +0 -21
- package/components/MobileMenu/demo-data.js +0 -97
- package/components/MobileMenu/icons/LeftArrowIcon.vue +0 -25
- package/components/MobileMenu/icons/MenuIcon.vue +0 -27
- package/components/MobileMenu/icons/RightArrowIcon.vue +0 -25
- package/components/MobileMenu/index.js +0 -8
- package/components/MobileMenu/mixins/contentControl.mixin.js +0 -46
- package/components/MobileMenu/mixins/functionalityStyle.mixin.js +0 -59
- package/components/MobileMenu/mixins/panelControl.mixin.js +0 -51
- package/components/ModalContainer/ModalContainer.vue +0 -212
- package/components/ModalContainer/index.js +0 -103
- package/components/Oembed.vue +0 -46
- package/components/Product/AddToCart.vue +0 -287
- package/components/Product/BoxAddToCart.vue +0 -177
- package/components/Product/Compare.vue +0 -150
- package/components/Product/CompareBox.vue +0 -164
- package/components/Product/Lookup.vue +0 -132
- package/components/Product/Photo.vue +0 -115
- package/components/Product/Price.vue +0 -106
- package/components/Product/ProductAutocomplete.vue +0 -103
- package/components/Product/ProductBox.vue +0 -88
- package/components/Product/ProductImages.vue +0 -137
- package/components/Product/Quantity.vue +0 -126
- package/components/Product/QuickView.vue +0 -145
- package/components/Product/RelatedProducts.vue +0 -104
- package/components/Product/SKU.vue +0 -46
- package/components/Product/Variants.vue +0 -399
- package/components/Product/reviews-questions/ProductQuestions.vue +0 -319
- package/components/Product/reviews-questions/ProductReviews.vue +0 -182
- package/components/Product/reviews-questions/Review.vue +0 -126
- package/components/Product/reviews-questions/ReviewForm.vue +0 -313
- package/components/Product/reviews-questions/ReviewImages.vue +0 -229
- package/components/Product/reviews-questions/Vote.vue +0 -104
- package/components/QuantityInput.vue +0 -111
- package/components/RangeInput.vue +0 -141
- package/components/Recaptcha.vue +0 -104
- package/components/SelectShippingCountry.vue +0 -115
- package/components/TimedOffer.vue +0 -84
- package/composables/globals.js +0 -53
- package/config.js +0 -21
- package/index.js +0 -182
- package/install.js +0 -88
- package/locales/en.json +0 -288
- package/locales/sr.json +0 -288
- package/translations.js +0 -4
- package/utils/animate.css +0 -50
- package/utils/animate.js +0 -23
- package/utils/buefy.js +0 -62
- package/utils/custom-event-bus.js +0 -13
- package/utils/directives.js +0 -79
- package/utils/event-bus.js +0 -56
- package/utils/filters.js +0 -161
- package/utils/format-date.js +0 -17
- package/utils/google/gmaps.js +0 -269
- package/utils/google/google-analytics-eec.js +0 -108
- package/utils/native-dom.js +0 -27
- package/utils/objects.js +0 -19
- package/utils/parse-url-filters.js +0 -19
- package/utils/random-id.js +0 -10
- package/utils/rc-token.js +0 -24
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { SpmktElement } from '../../lit/spmkt-element';
|
|
2
|
+
import { type CheckoutDraft } from '../../core/stores/checkout';
|
|
3
|
+
import type { CheckoutAddress } from '../../core/types';
|
|
4
|
+
/**
|
|
5
|
+
* The age rules of the page (AgeVerification::rules on the platform): minimum ages by country id and by state
|
|
6
|
+
* id (a state's wins), the age for every other address (null: no check there), and a customer's saved
|
|
7
|
+
* addresses by id, as the age-checker endpoint takes them.
|
|
8
|
+
*/
|
|
9
|
+
export interface AgeRules {
|
|
10
|
+
everywhere: number | null;
|
|
11
|
+
countries: Record<string, number>;
|
|
12
|
+
states: Record<string, number>;
|
|
13
|
+
addresses: Record<string, CheckoutAddress>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Parts of <spmkt-age-check api-key> (in the payment step, inside its form):
|
|
17
|
+
* - rules (required): <script type="application/json"> with the AgeRules
|
|
18
|
+
* - field (required): the date-of-birth field; shown only when the delivery address needs the check
|
|
19
|
+
* - input (required): <input type="date" name="date_of_birth">, with a [data-error-for="date_of_birth"] slot
|
|
20
|
+
* - hint (optional): the minimum age is written into it
|
|
21
|
+
* - error (optional): why the check stopped the order, when it is not the field's fault
|
|
22
|
+
*
|
|
23
|
+
* It adds an order check (when the page state's checkout.ageVerification is on): placing the order first asks
|
|
24
|
+
* POST cart/age-checker with the delivery address and the date of birth. "accepted" lets the order go;
|
|
25
|
+
* "photo_id" opens AgeChecker.net's popup (api-key is its client key) and stops this attempt. Only when the popup
|
|
26
|
+
* reports the photo ID accepted, or submitted for review ("pending"), does the visitor count as verified in this
|
|
27
|
+
* browser (the ac_custom_verified cookie, as spmkt 3 sets it) and place the order again; closing the popup
|
|
28
|
+
* without that verifies nothing. Anything else stops the order.
|
|
29
|
+
*
|
|
30
|
+
* This check is the visitor's convenience, not the enforcement: a visitor can set the cookie, or leave this
|
|
31
|
+
* element off the page. Placing the order must check the age on the server.
|
|
32
|
+
*/
|
|
33
|
+
export interface AgeCheckParts {
|
|
34
|
+
rules: HTMLScriptElement;
|
|
35
|
+
field: HTMLElement;
|
|
36
|
+
input: HTMLInputElement;
|
|
37
|
+
hint?: HTMLElement;
|
|
38
|
+
error?: HTMLElement;
|
|
39
|
+
}
|
|
40
|
+
export declare const VERIFIED_COOKIE = "ac_custom_verified";
|
|
41
|
+
interface AgeCheckerApi {
|
|
42
|
+
show(uuid: string): void;
|
|
43
|
+
}
|
|
44
|
+
/** What the popup reports: a verification's status changed (onstatuschanged), or the popup closed. */
|
|
45
|
+
export interface AgeCheckerCallbacks {
|
|
46
|
+
onStatus(status: string, uuid: string): void;
|
|
47
|
+
onClosed(): void;
|
|
48
|
+
}
|
|
49
|
+
declare global {
|
|
50
|
+
interface Window {
|
|
51
|
+
AgeCheckerAPI?: AgeCheckerApi;
|
|
52
|
+
AgeCheckerConfig?: Record<string, unknown>;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export declare class SpmktAgeCheck extends SpmktElement {
|
|
56
|
+
static properties: {
|
|
57
|
+
apiKey: {
|
|
58
|
+
type: StringConstructor;
|
|
59
|
+
attribute: string;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
apiKey: string;
|
|
63
|
+
private rules;
|
|
64
|
+
private popup;
|
|
65
|
+
/** The photo-ID verification shown in the popup, and whether it reached a passing status */
|
|
66
|
+
private pendingUuid;
|
|
67
|
+
private passed;
|
|
68
|
+
constructor();
|
|
69
|
+
connectedCallback(): void;
|
|
70
|
+
/** The age the delivery address asks for, or null when it needs no check. */
|
|
71
|
+
minimumAge(draft: CheckoutDraft): number | null;
|
|
72
|
+
/** The order check: true lets the order be placed. */
|
|
73
|
+
verify(): Promise<boolean>;
|
|
74
|
+
/** Loads AgeChecker.net's popup once; replaceable (tests, themes). */
|
|
75
|
+
loadPopup: (apiKey: string, callbacks: AgeCheckerCallbacks) => Promise<AgeCheckerApi>;
|
|
76
|
+
private showPopup;
|
|
77
|
+
/** The popup's verification moved on; a passing status verifies the visitor in this browser. */
|
|
78
|
+
private statusChanged;
|
|
79
|
+
/** The popup closed: the visitor places the order again, which passes only after a passing status. */
|
|
80
|
+
private closed;
|
|
81
|
+
private deliveryAddress;
|
|
82
|
+
private paint;
|
|
83
|
+
private refuse;
|
|
84
|
+
private showError;
|
|
85
|
+
private readRules;
|
|
86
|
+
}
|
|
87
|
+
/** Full years from a YYYY-MM-DD birth date to today. */
|
|
88
|
+
export declare function yearsSince(date: string, today?: Date): number;
|
|
89
|
+
export {};
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { SpmktElement } from "../../lit/spmkt-element.js";
|
|
2
|
+
import { SignalController } from "../../lit/signal-controller.js";
|
|
3
|
+
import { clearFieldErrors, showFieldErrors, errorMessage } from "../../lit/forms.js";
|
|
4
|
+
import { checkAge } from "../../core/api/checkout.js";
|
|
5
|
+
import { readCookie, writeCookie } from "../../core/cookies.js";
|
|
6
|
+
import { ValidationError } from "../../core/errors.js";
|
|
7
|
+
import { t } from "../../core/i18n.js";
|
|
8
|
+
import { addOrderCheck } from "../../core/stores/checkout.js";
|
|
9
|
+
import { customerSignedIn } from "../../core/stores/customer.js";
|
|
10
|
+
import { storefront } from "../../core/state.js";
|
|
11
|
+
import { checkoutDraft } from "../../core/stores/checkout-draft.js";
|
|
12
|
+
const VERIFIED_COOKIE = "ac_custom_verified";
|
|
13
|
+
const POPUP_SCRIPT = "https://cdn.agechecker.net/static/popup/v1/popup.js";
|
|
14
|
+
const PASSING = /* @__PURE__ */ new Set(["accepted", "pending"]);
|
|
15
|
+
class SpmktAgeCheck extends SpmktElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
this.apiKey = "";
|
|
19
|
+
this.rules = { everywhere: null, countries: {}, states: {}, addresses: {} };
|
|
20
|
+
this.pendingUuid = null;
|
|
21
|
+
this.passed = false;
|
|
22
|
+
this.loadPopup = (apiKey, callbacks) => {
|
|
23
|
+
this.popup ??= new Promise((resolve, reject) => {
|
|
24
|
+
if (window.AgeCheckerAPI) {
|
|
25
|
+
resolve(window.AgeCheckerAPI);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
window.AgeCheckerConfig = {
|
|
29
|
+
mode: "manual",
|
|
30
|
+
key: apiKey,
|
|
31
|
+
onstatuschanged: (verification) => callbacks.onStatus(String(verification?.status ?? ""), String(verification?.uuid ?? "")),
|
|
32
|
+
onclosed: () => callbacks.onClosed()
|
|
33
|
+
};
|
|
34
|
+
const script = document.createElement("script");
|
|
35
|
+
script.src = POPUP_SCRIPT;
|
|
36
|
+
script.crossOrigin = "anonymous";
|
|
37
|
+
script.onload = () => window.AgeCheckerAPI ? resolve(window.AgeCheckerAPI) : reject(new Error("AgeChecker did not load"));
|
|
38
|
+
script.onerror = () => {
|
|
39
|
+
this.popup = void 0;
|
|
40
|
+
reject(new Error("AgeChecker could not be loaded"));
|
|
41
|
+
};
|
|
42
|
+
document.head.append(script);
|
|
43
|
+
});
|
|
44
|
+
return this.popup;
|
|
45
|
+
};
|
|
46
|
+
new SignalController(
|
|
47
|
+
this,
|
|
48
|
+
() => {
|
|
49
|
+
void customerSignedIn.value;
|
|
50
|
+
return this.minimumAge(checkoutDraft.value);
|
|
51
|
+
},
|
|
52
|
+
(age) => this.paint(age)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
static {
|
|
56
|
+
this.properties = {
|
|
57
|
+
apiKey: { type: String, attribute: "api-key" }
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
connectedCallback() {
|
|
61
|
+
super.connectedCallback();
|
|
62
|
+
this.requirePart("field");
|
|
63
|
+
this.requirePart("input");
|
|
64
|
+
this.rules = this.readRules();
|
|
65
|
+
this.paint(this.minimumAge(checkoutDraft.value));
|
|
66
|
+
this.onDisconnect(addOrderCheck(() => this.verify()));
|
|
67
|
+
}
|
|
68
|
+
/** The age the delivery address asks for, or null when it needs no check. */
|
|
69
|
+
minimumAge(draft) {
|
|
70
|
+
if (!storefront().checkout.ageVerification) return null;
|
|
71
|
+
const address = this.deliveryAddress(draft);
|
|
72
|
+
if (!address) return null;
|
|
73
|
+
const state = address.state_id != null ? this.rules.states[String(address.state_id)] : void 0;
|
|
74
|
+
const country = address.country_id != null ? this.rules.countries[String(address.country_id)] : void 0;
|
|
75
|
+
return state ?? country ?? this.rules.everywhere;
|
|
76
|
+
}
|
|
77
|
+
/** The order check: true lets the order be placed. */
|
|
78
|
+
async verify() {
|
|
79
|
+
const draft = checkoutDraft.value;
|
|
80
|
+
const age = this.minimumAge(draft);
|
|
81
|
+
if (age === null || readCookie(VERIFIED_COOKIE)) return true;
|
|
82
|
+
const field = this.requirePart("field");
|
|
83
|
+
const input = this.requirePart("input");
|
|
84
|
+
clearFieldErrors(field);
|
|
85
|
+
this.showError(null);
|
|
86
|
+
const born = input.value;
|
|
87
|
+
if (!born) return this.refuse({ date_of_birth: [t("checkout.ageBirthDate")] });
|
|
88
|
+
if (yearsSince(born) < age) return this.refuse({ date_of_birth: [t("checkout.ageTooYoung", { age })] });
|
|
89
|
+
const address = this.deliveryAddress(draft);
|
|
90
|
+
try {
|
|
91
|
+
const answer = await checkAge({ ...address, date_of_birth: born });
|
|
92
|
+
if (answer.status === "accepted") return true;
|
|
93
|
+
if (answer.status === "photo_id") {
|
|
94
|
+
await this.showPopup(answer.uuid);
|
|
95
|
+
this.showError(t("checkout.agePhotoId"));
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
const message = answer.message;
|
|
99
|
+
this.showError(typeof message === "string" && message ? message : t("checkout.ageDenied"));
|
|
100
|
+
return false;
|
|
101
|
+
} catch (error) {
|
|
102
|
+
if (error instanceof ValidationError) {
|
|
103
|
+
const unplaced = showFieldErrors(field, error.errors);
|
|
104
|
+
if (unplaced.length) this.showError(`${unplaced.join(" ")} ${t("checkout.checkDelivery")}`);
|
|
105
|
+
input.focus();
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
this.showError(errorMessage(error, t("checkout.ageUnavailable")));
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async showPopup(uuid) {
|
|
113
|
+
this.pendingUuid = uuid;
|
|
114
|
+
this.passed = false;
|
|
115
|
+
try {
|
|
116
|
+
const api = await this.loadPopup(this.apiKey, {
|
|
117
|
+
onStatus: (status, statusUuid) => this.statusChanged(status, statusUuid),
|
|
118
|
+
onClosed: () => this.closed()
|
|
119
|
+
});
|
|
120
|
+
api.show(uuid);
|
|
121
|
+
} catch {
|
|
122
|
+
this.pendingUuid = null;
|
|
123
|
+
throw new Error(t("checkout.ageUnavailable"));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/** The popup's verification moved on; a passing status verifies the visitor in this browser. */
|
|
127
|
+
statusChanged(status, uuid) {
|
|
128
|
+
if (!this.pendingUuid || uuid && uuid !== this.pendingUuid || !PASSING.has(status)) return;
|
|
129
|
+
this.passed = true;
|
|
130
|
+
writeCookie(VERIFIED_COOKIE, "1", 1);
|
|
131
|
+
}
|
|
132
|
+
/** The popup closed: the visitor places the order again, which passes only after a passing status. */
|
|
133
|
+
closed() {
|
|
134
|
+
if (!this.pendingUuid) return;
|
|
135
|
+
this.pendingUuid = null;
|
|
136
|
+
const error = this.findPart("error");
|
|
137
|
+
if (error) {
|
|
138
|
+
error.textContent = t(this.passed ? "checkout.ageVerified" : "checkout.ageNotVerified");
|
|
139
|
+
error.hidden = false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
deliveryAddress(draft) {
|
|
143
|
+
if (customerSignedIn.value) {
|
|
144
|
+
return draft.addressId === null ? null : this.rules.addresses[String(draft.addressId)] ?? null;
|
|
145
|
+
}
|
|
146
|
+
return draft.address;
|
|
147
|
+
}
|
|
148
|
+
paint(age) {
|
|
149
|
+
const field = this.findPart("field");
|
|
150
|
+
if (!field) return;
|
|
151
|
+
field.hidden = age === null;
|
|
152
|
+
const input = this.findPart("input");
|
|
153
|
+
if (input) input.required = age !== null;
|
|
154
|
+
const hint = this.findPart("hint");
|
|
155
|
+
if (hint) hint.textContent = age === null ? "" : t("checkout.ageHint", { age });
|
|
156
|
+
}
|
|
157
|
+
refuse(errors) {
|
|
158
|
+
showFieldErrors(this.requirePart("field"), errors);
|
|
159
|
+
this.requirePart("input").focus();
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
showError(message) {
|
|
163
|
+
const part = this.findPart("error");
|
|
164
|
+
if (part) {
|
|
165
|
+
part.textContent = message ?? "";
|
|
166
|
+
part.hidden = message === null;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
readRules() {
|
|
170
|
+
try {
|
|
171
|
+
const parsed = JSON.parse(this.requirePart("rules").textContent ?? "");
|
|
172
|
+
return {
|
|
173
|
+
everywhere: typeof parsed.everywhere === "number" ? parsed.everywhere : null,
|
|
174
|
+
countries: parsed.countries ?? {},
|
|
175
|
+
states: parsed.states ?? {},
|
|
176
|
+
addresses: parsed.addresses ?? {}
|
|
177
|
+
};
|
|
178
|
+
} catch {
|
|
179
|
+
return { everywhere: null, countries: {}, states: {}, addresses: {} };
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function yearsSince(date, today = /* @__PURE__ */ new Date()) {
|
|
184
|
+
const [year, month, day] = date.split("-").map(Number);
|
|
185
|
+
if (!year || !month || !day) return 0;
|
|
186
|
+
let years = today.getFullYear() - year;
|
|
187
|
+
if (today.getMonth() + 1 < month || today.getMonth() + 1 === month && today.getDate() < day) years--;
|
|
188
|
+
return years;
|
|
189
|
+
}
|
|
190
|
+
export {
|
|
191
|
+
SpmktAgeCheck,
|
|
192
|
+
VERIFIED_COOKIE,
|
|
193
|
+
yearsSince
|
|
194
|
+
};
|
|
195
|
+
//# sourceMappingURL=age-check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"age-check.js","sources":["../../../src/elements/age-check/age-check.ts"],"sourcesContent":["import { SpmktElement } from '../../lit/spmkt-element'\nimport { SignalController } from '../../lit/signal-controller'\nimport { clearFieldErrors, errorMessage, showFieldErrors } from '../../lit/forms'\nimport { checkAge } from '../../core/api/checkout'\nimport { readCookie, writeCookie } from '../../core/cookies'\nimport { ValidationError } from '../../core/errors'\nimport { t } from '../../core/i18n'\nimport { addOrderCheck, checkoutDraft, type CheckoutDraft } from '../../core/stores/checkout'\nimport { customerSignedIn } from '../../core/stores/customer'\nimport { storefront } from '../../core/state'\nimport type { CheckoutAddress } from '../../core/types'\n\n/**\n * The age rules of the page (AgeVerification::rules on the platform): minimum ages by country id and by state\n * id (a state's wins), the age for every other address (null: no check there), and a customer's saved\n * addresses by id, as the age-checker endpoint takes them.\n */\nexport interface AgeRules {\n everywhere: number | null\n countries: Record<string, number>\n states: Record<string, number>\n addresses: Record<string, CheckoutAddress>\n}\n\n/**\n * Parts of <spmkt-age-check api-key> (in the payment step, inside its form):\n * - rules (required): <script type=\"application/json\"> with the AgeRules\n * - field (required): the date-of-birth field; shown only when the delivery address needs the check\n * - input (required): <input type=\"date\" name=\"date_of_birth\">, with a [data-error-for=\"date_of_birth\"] slot\n * - hint (optional): the minimum age is written into it\n * - error (optional): why the check stopped the order, when it is not the field's fault\n *\n * It adds an order check (when the page state's checkout.ageVerification is on): placing the order first asks\n * POST cart/age-checker with the delivery address and the date of birth. \"accepted\" lets the order go;\n * \"photo_id\" opens AgeChecker.net's popup (api-key is its client key) and stops this attempt. Only when the popup\n * reports the photo ID accepted, or submitted for review (\"pending\"), does the visitor count as verified in this\n * browser (the ac_custom_verified cookie, as spmkt 3 sets it) and place the order again; closing the popup\n * without that verifies nothing. Anything else stops the order.\n *\n * This check is the visitor's convenience, not the enforcement: a visitor can set the cookie, or leave this\n * element off the page. Placing the order must check the age on the server.\n */\nexport interface AgeCheckParts {\n rules: HTMLScriptElement\n field: HTMLElement\n input: HTMLInputElement\n hint?: HTMLElement\n error?: HTMLElement\n}\n\nexport const VERIFIED_COOKIE = 'ac_custom_verified'\nconst POPUP_SCRIPT = 'https://cdn.agechecker.net/static/popup/v1/popup.js'\n\ninterface AgeCheckerApi {\n show(uuid: string): void\n}\n\n/** What the popup reports: a verification's status changed (onstatuschanged), or the popup closed. */\nexport interface AgeCheckerCallbacks {\n onStatus(status: string, uuid: string): void\n onClosed(): void\n}\n\n/** Statuses after which the order may go: verified, or the photo ID is submitted and under review. */\nconst PASSING = new Set(['accepted', 'pending'])\n\ndeclare global {\n interface Window {\n AgeCheckerAPI?: AgeCheckerApi\n AgeCheckerConfig?: Record<string, unknown>\n }\n}\n\nexport class SpmktAgeCheck extends SpmktElement {\n static override properties = {\n apiKey: { type: String, attribute: 'api-key' },\n }\n apiKey = ''\n\n private rules: AgeRules = { everywhere: null, countries: {}, states: {}, addresses: {} }\n private popup: Promise<AgeCheckerApi> | undefined\n /** The photo-ID verification shown in the popup, and whether it reached a passing status */\n private pendingUuid: string | null = null\n private passed = false\n\n constructor() {\n super()\n new SignalController(\n this,\n () => {\n void customerSignedIn.value\n return this.minimumAge(checkoutDraft.value)\n },\n (age) => this.paint(age),\n )\n }\n\n override connectedCallback(): void {\n super.connectedCallback()\n this.requirePart('field')\n this.requirePart('input')\n this.rules = this.readRules()\n this.paint(this.minimumAge(checkoutDraft.value))\n this.onDisconnect(addOrderCheck(() => this.verify()))\n }\n\n /** The age the delivery address asks for, or null when it needs no check. */\n minimumAge(draft: CheckoutDraft): number | null {\n if (!storefront().checkout.ageVerification) return null\n const address = this.deliveryAddress(draft)\n if (!address) return null\n const state = address.state_id != null ? this.rules.states[String(address.state_id)] : undefined\n const country = address.country_id != null ? this.rules.countries[String(address.country_id)] : undefined\n return state ?? country ?? this.rules.everywhere\n }\n\n /** The order check: true lets the order be placed. */\n async verify(): Promise<boolean> {\n const draft = checkoutDraft.value\n const age = this.minimumAge(draft)\n if (age === null || readCookie(VERIFIED_COOKIE)) return true\n\n const field = this.requirePart('field')\n const input = this.requirePart<HTMLInputElement>('input')\n clearFieldErrors(field)\n this.showError(null)\n\n const born = input.value\n if (!born) return this.refuse({ date_of_birth: [t('checkout.ageBirthDate')] })\n if (yearsSince(born) < age) return this.refuse({ date_of_birth: [t('checkout.ageTooYoung', { age })] })\n\n const address = this.deliveryAddress(draft)!\n try {\n const answer = await checkAge({ ...address, date_of_birth: born })\n // The platform also answers accepted when AgeChecker.net's answer could not be read\n if (answer.status === 'accepted') return true\n if (answer.status === 'photo_id') {\n await this.showPopup(answer.uuid)\n this.showError(t('checkout.agePhotoId'))\n return false\n }\n const message = (answer as { message?: unknown }).message\n this.showError(typeof message === 'string' && message ? message : t('checkout.ageDenied'))\n return false\n } catch (error) {\n if (error instanceof ValidationError) {\n const unplaced = showFieldErrors(field, error.errors)\n if (unplaced.length) this.showError(`${unplaced.join(' ')} ${t('checkout.checkDelivery')}`)\n input.focus()\n return false\n }\n this.showError(errorMessage(error, t('checkout.ageUnavailable')))\n return false\n }\n }\n\n /** Loads AgeChecker.net's popup once; replaceable (tests, themes). */\n loadPopup: (apiKey: string, callbacks: AgeCheckerCallbacks) => Promise<AgeCheckerApi> = (\n apiKey,\n callbacks,\n ) => {\n this.popup ??= new Promise<AgeCheckerApi>((resolve, reject) => {\n if (window.AgeCheckerAPI) {\n resolve(window.AgeCheckerAPI)\n return\n }\n window.AgeCheckerConfig = {\n mode: 'manual',\n key: apiKey,\n onstatuschanged: (verification: { status?: unknown; uuid?: unknown }) =>\n callbacks.onStatus(String(verification?.status ?? ''), String(verification?.uuid ?? '')),\n onclosed: () => callbacks.onClosed(),\n }\n const script = document.createElement('script')\n script.src = POPUP_SCRIPT\n script.crossOrigin = 'anonymous'\n script.onload = () =>\n window.AgeCheckerAPI ? resolve(window.AgeCheckerAPI) : reject(new Error('AgeChecker did not load'))\n script.onerror = () => {\n this.popup = undefined\n reject(new Error('AgeChecker could not be loaded'))\n }\n document.head.append(script)\n })\n return this.popup\n }\n\n private async showPopup(uuid: string): Promise<void> {\n this.pendingUuid = uuid\n this.passed = false\n try {\n const api = await this.loadPopup(this.apiKey, {\n onStatus: (status, statusUuid) => this.statusChanged(status, statusUuid),\n onClosed: () => this.closed(),\n })\n api.show(uuid)\n } catch {\n this.pendingUuid = null\n throw new Error(t('checkout.ageUnavailable'))\n }\n }\n\n /** The popup's verification moved on; a passing status verifies the visitor in this browser. */\n private statusChanged(status: string, uuid: string): void {\n if (!this.pendingUuid || (uuid && uuid !== this.pendingUuid) || !PASSING.has(status)) return\n this.passed = true\n writeCookie(VERIFIED_COOKIE, '1', 1)\n }\n\n /** The popup closed: the visitor places the order again, which passes only after a passing status. */\n private closed(): void {\n if (!this.pendingUuid) return\n this.pendingUuid = null\n const error = this.findPart('error')\n if (error) {\n error.textContent = t(this.passed ? 'checkout.ageVerified' : 'checkout.ageNotVerified')\n error.hidden = false\n }\n }\n\n private deliveryAddress(draft: CheckoutDraft): CheckoutAddress | null {\n if (customerSignedIn.value) {\n return draft.addressId === null ? null : (this.rules.addresses[String(draft.addressId)] ?? null)\n }\n return draft.address\n }\n\n private paint(age: number | null): void {\n const field = this.findPart('field')\n if (!field) return\n field.hidden = age === null\n const input = this.findPart<HTMLInputElement>('input')\n if (input) input.required = age !== null\n const hint = this.findPart('hint')\n if (hint) hint.textContent = age === null ? '' : t('checkout.ageHint', { age })\n }\n\n private refuse(errors: Record<string, string[]>): false {\n showFieldErrors(this.requirePart('field'), errors)\n this.requirePart<HTMLInputElement>('input').focus()\n return false\n }\n\n private showError(message: string | null): void {\n const part = this.findPart('error')\n if (part) {\n part.textContent = message ?? ''\n part.hidden = message === null\n }\n }\n\n private readRules(): AgeRules {\n try {\n const parsed = JSON.parse(this.requirePart('rules').textContent ?? '') as Partial<AgeRules>\n return {\n everywhere: typeof parsed.everywhere === 'number' ? parsed.everywhere : null,\n countries: parsed.countries ?? {},\n states: parsed.states ?? {},\n addresses: parsed.addresses ?? {},\n }\n } catch {\n return { everywhere: null, countries: {}, states: {}, addresses: {} }\n }\n }\n}\n\n/** Full years from a YYYY-MM-DD birth date to today. */\nexport function yearsSince(date: string, today = new Date()): number {\n const [year, month, day] = date.split('-').map(Number)\n if (!year || !month || !day) return 0\n let years = today.getFullYear() - year\n if (today.getMonth() + 1 < month || (today.getMonth() + 1 === month && today.getDate() < day)) years--\n return years\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAkDO,MAAM,kBAAkB;AAC/B,MAAM,eAAe;AAarB,MAAM,UAAU,oBAAI,IAAI,CAAC,YAAY,SAAS,CAAC;AASxC,MAAM,sBAAsB,aAAa;AAAA,EAY9C,cAAc;AACZ,UAAA;AATF,SAAA,SAAS;AAET,SAAQ,QAAkB,EAAE,YAAY,MAAM,WAAW,CAAA,GAAI,QAAQ,CAAA,GAAI,WAAW,GAAC;AAGrF,SAAQ,cAA6B;AACrC,SAAQ,SAAS;AA0EjB,SAAA,YAAwF,CACtF,QACA,cACG;AACH,WAAK,UAAU,IAAI,QAAuB,CAAC,SAAS,WAAW;AAC7D,YAAI,OAAO,eAAe;AACxB,kBAAQ,OAAO,aAAa;AAC5B;AAAA,QACF;AACA,eAAO,mBAAmB;AAAA,UACxB,MAAM;AAAA,UACN,KAAK;AAAA,UACL,iBAAiB,CAAC,iBAChB,UAAU,SAAS,OAAO,cAAc,UAAU,EAAE,GAAG,OAAO,cAAc,QAAQ,EAAE,CAAC;AAAA,UACzF,UAAU,MAAM,UAAU,SAAA;AAAA,QAAS;AAErC,cAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,eAAO,MAAM;AACb,eAAO,cAAc;AACrB,eAAO,SAAS,MACd,OAAO,gBAAgB,QAAQ,OAAO,aAAa,IAAI,OAAO,IAAI,MAAM,yBAAyB,CAAC;AACpG,eAAO,UAAU,MAAM;AACrB,eAAK,QAAQ;AACb,iBAAO,IAAI,MAAM,gCAAgC,CAAC;AAAA,QACpD;AACA,iBAAS,KAAK,OAAO,MAAM;AAAA,MAC7B,CAAC;AACD,aAAO,KAAK;AAAA,IACd;AAlGE,QAAI;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AM,SAAS,KAAK,MAAM,KAAK,YAAY,OAAO,EAAE,eAAe,EAAE;AACrE,aAAO;AAAA,QACL,YAAY,OAAO,OAAO,eAAe,WAAW,OAAO,aAAa;AAAA,QACxE,WAAW,OAAO,aAAa,CAAA;AAAA,QAC/B,QAAQ,OAAO,UAAU,CAAA;AAAA,QACzB,WAAW,OAAO,aAAa,CAAA;AAAA,MAAC;AAAA,IAEpC,QAAQ;AACN,aAAO,EAAE,YAAY,MAAM,WAAW,CAAA,GAAI,QAAQ,CAAA,GAAI,WAAW,GAAC;AAAA,IACpE;AAAA,EACF;AACF;AAGO,SAAS,WAAW,MAAc,QAAQ,oBAAI,QAAgB;AACnE,QAAM,CAAC,MAAM,OAAO,GAAG,IAAI,KAAK,MAAM,GAAG,EAAE,IAAI,MAAM;AACrD,MAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAK,QAAO;AACpC,MAAI,QAAQ,MAAM,YAAA,IAAgB;AAClC,MAAI,MAAM,SAAA,IAAa,IAAI,SAAU,MAAM,SAAA,IAAa,MAAM,SAAS,MAAM,QAAA,IAAY,IAAM;AAC/F,SAAO;AACT;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SpmktElement } from '../../lit/spmkt-element';
|
|
2
|
+
export declare const AGE_GATE_COOKIE = "age-gate";
|
|
3
|
+
/**
|
|
4
|
+
* Parts of <spmkt-age-gate>:
|
|
5
|
+
* - dialog (required): a <dialog> with the question; it opens as a modal at once, unless the visitor answered
|
|
6
|
+
* before (the `age-gate` cookie; the theme should not render the gate then at all). Escape does not close it
|
|
7
|
+
* - accept (required): "yes": remembers the answer and closes the dialog
|
|
8
|
+
* - remember (optional): a checkbox; ticked, the answer is kept for a year, otherwise for the browser session
|
|
9
|
+
* - reject (optional): "no", usually a link away from the shop; the element leaves it to the browser
|
|
10
|
+
*/
|
|
11
|
+
export interface AgeGateParts {
|
|
12
|
+
dialog: HTMLDialogElement;
|
|
13
|
+
accept: HTMLElement;
|
|
14
|
+
remember?: HTMLInputElement;
|
|
15
|
+
reject?: HTMLElement;
|
|
16
|
+
}
|
|
17
|
+
/** The site-entry age question. */
|
|
18
|
+
export declare class SpmktAgeGate extends SpmktElement {
|
|
19
|
+
connectedCallback(): void;
|
|
20
|
+
accept(): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { readCookie, writeCookie } from "../../core/cookies.js";
|
|
2
|
+
import { SpmktElement } from "../../lit/spmkt-element.js";
|
|
3
|
+
const AGE_GATE_COOKIE = "age-gate";
|
|
4
|
+
class SpmktAgeGate extends SpmktElement {
|
|
5
|
+
connectedCallback() {
|
|
6
|
+
super.connectedCallback();
|
|
7
|
+
const dialog = this.requirePart("dialog");
|
|
8
|
+
this.listen(this.requirePart("accept"), "click", () => this.accept());
|
|
9
|
+
this.listen(dialog, "cancel", (event) => event.preventDefault());
|
|
10
|
+
if (readCookie(AGE_GATE_COOKIE) !== "yes" && !dialog.open) {
|
|
11
|
+
dialog.showModal();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
accept() {
|
|
15
|
+
const remember = this.findPart("remember");
|
|
16
|
+
writeCookie(AGE_GATE_COOKIE, "yes", !remember || remember.checked ? 365 : void 0);
|
|
17
|
+
this.requirePart("dialog").close();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
AGE_GATE_COOKIE,
|
|
22
|
+
SpmktAgeGate
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=age-gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"age-gate.js","sources":["../../../src/elements/age-gate/age-gate.ts"],"sourcesContent":["import { readCookie, writeCookie } from '../../core/cookies'\nimport { SpmktElement } from '../../lit/spmkt-element'\n\nexport const AGE_GATE_COOKIE = 'age-gate'\n\n/**\n * Parts of <spmkt-age-gate>:\n * - dialog (required): a <dialog> with the question; it opens as a modal at once, unless the visitor answered\n * before (the `age-gate` cookie; the theme should not render the gate then at all). Escape does not close it\n * - accept (required): \"yes\": remembers the answer and closes the dialog\n * - remember (optional): a checkbox; ticked, the answer is kept for a year, otherwise for the browser session\n * - reject (optional): \"no\", usually a link away from the shop; the element leaves it to the browser\n */\nexport interface AgeGateParts {\n dialog: HTMLDialogElement\n accept: HTMLElement\n remember?: HTMLInputElement\n reject?: HTMLElement\n}\n\n/** The site-entry age question. */\nexport class SpmktAgeGate extends SpmktElement {\n override connectedCallback(): void {\n super.connectedCallback()\n const dialog = this.requirePart<HTMLDialogElement>('dialog')\n this.listen(this.requirePart('accept'), 'click', () => this.accept())\n this.listen(dialog, 'cancel', (event) => event.preventDefault())\n if (readCookie(AGE_GATE_COOKIE) !== 'yes' && !dialog.open) {\n dialog.showModal()\n }\n }\n\n accept(): void {\n const remember = this.findPart<HTMLInputElement>('remember')\n writeCookie(AGE_GATE_COOKIE, 'yes', !remember || remember.checked ? 365 : undefined)\n this.requirePart<HTMLDialogElement>('dialog').close()\n }\n}\n"],"names":[],"mappings":";;AAGO,MAAM,kBAAkB;AAkBxB,MAAM,qBAAqB,aAAa;AAAA,EACpC,oBAA0B;AACjC,UAAM,kBAAA;AACN,UAAM,SAAS,KAAK,YAA+B,QAAQ;AAC3D,SAAK,OAAO,KAAK,YAAY,QAAQ,GAAG,SAAS,MAAM,KAAK,QAAQ;AACpE,SAAK,OAAO,QAAQ,UAAU,CAAC,UAAU,MAAM,gBAAgB;AAC/D,QAAI,WAAW,eAAe,MAAM,SAAS,CAAC,OAAO,MAAM;AACzD,aAAO,UAAA;AAAA,IACT;AAAA,EACF;AAAA,EAEA,SAAe;AACb,UAAM,WAAW,KAAK,SAA2B,UAAU;AAC3D,gBAAY,iBAAiB,OAAO,CAAC,YAAY,SAAS,UAAU,MAAM,MAAS;AACnF,SAAK,YAA+B,QAAQ,EAAE,MAAA;AAAA,EAChD;AACF;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { SpmktElement } from '../../lit/spmkt-element';
|
|
2
|
+
/**
|
|
3
|
+
* Parts of <spmkt-back-in-stock product-id url resend-url error-message too-many-message>, for the product shown
|
|
4
|
+
* (`url` is the subscription base: POST/DELETE <url>/<product-id>; the platform's routes need a signed-in
|
|
5
|
+
* customer with a confirmed e-mail). Every part is optional, so the theme renders only the visitor's state:
|
|
6
|
+
* - subscribe, offer: the button, and what is shown until the visitor subscribes
|
|
7
|
+
* - cancel, subscribed: the button, and what is shown while they wait
|
|
8
|
+
* - resend, sent: a new verification link (POST resend-url) for a customer whose e-mail is not confirmed
|
|
9
|
+
* - error: a message (render it hidden): too-many-message after 429, error-message otherwise
|
|
10
|
+
*
|
|
11
|
+
* A button may sit in a form that does the same without JavaScript (POST <url>/<id>, a DELETE through _method,
|
|
12
|
+
* POST resend-url): its submit is then taken over here, and the form posts natively only before the element runs.
|
|
13
|
+
*/
|
|
14
|
+
export interface BackInStockParts {
|
|
15
|
+
subscribe?: HTMLButtonElement;
|
|
16
|
+
offer?: HTMLElement;
|
|
17
|
+
cancel?: HTMLButtonElement;
|
|
18
|
+
subscribed?: HTMLElement;
|
|
19
|
+
resend?: HTMLButtonElement;
|
|
20
|
+
sent?: HTMLElement;
|
|
21
|
+
error?: HTMLElement;
|
|
22
|
+
}
|
|
23
|
+
/** "Notify me when it is back in stock" on a product page. */
|
|
24
|
+
export declare class SpmktBackInStock extends SpmktElement {
|
|
25
|
+
static properties: {
|
|
26
|
+
productId: {
|
|
27
|
+
type: NumberConstructor;
|
|
28
|
+
attribute: string;
|
|
29
|
+
};
|
|
30
|
+
url: {
|
|
31
|
+
type: StringConstructor;
|
|
32
|
+
};
|
|
33
|
+
resendUrl: {
|
|
34
|
+
type: StringConstructor;
|
|
35
|
+
attribute: string;
|
|
36
|
+
};
|
|
37
|
+
errorMessage: {
|
|
38
|
+
type: StringConstructor;
|
|
39
|
+
attribute: string;
|
|
40
|
+
};
|
|
41
|
+
tooManyMessage: {
|
|
42
|
+
type: StringConstructor;
|
|
43
|
+
attribute: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
productId: number;
|
|
47
|
+
url: string;
|
|
48
|
+
resendUrl: string;
|
|
49
|
+
errorMessage: string;
|
|
50
|
+
tooManyMessage: string;
|
|
51
|
+
private busy;
|
|
52
|
+
connectedCallback(): void;
|
|
53
|
+
/** A part's button runs `action`: through its form's submit when it has one, else on click. */
|
|
54
|
+
private bind;
|
|
55
|
+
subscribe(): Promise<void>;
|
|
56
|
+
cancel(): Promise<void>;
|
|
57
|
+
resend(): Promise<void>;
|
|
58
|
+
private show;
|
|
59
|
+
private run;
|
|
60
|
+
private showError;
|
|
61
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { HttpError } from "../../core/errors.js";
|
|
2
|
+
import { post, del } from "../../core/request.js";
|
|
3
|
+
import { SpmktElement } from "../../lit/spmkt-element.js";
|
|
4
|
+
class SpmktBackInStock extends SpmktElement {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.productId = 0;
|
|
8
|
+
this.url = "/back-in-stock";
|
|
9
|
+
this.resendUrl = "";
|
|
10
|
+
this.errorMessage = "";
|
|
11
|
+
this.tooManyMessage = "";
|
|
12
|
+
this.busy = false;
|
|
13
|
+
}
|
|
14
|
+
static {
|
|
15
|
+
this.properties = {
|
|
16
|
+
productId: { type: Number, attribute: "product-id" },
|
|
17
|
+
url: { type: String },
|
|
18
|
+
resendUrl: { type: String, attribute: "resend-url" },
|
|
19
|
+
errorMessage: { type: String, attribute: "error-message" },
|
|
20
|
+
tooManyMessage: { type: String, attribute: "too-many-message" }
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
connectedCallback() {
|
|
24
|
+
super.connectedCallback();
|
|
25
|
+
this.bind("subscribe", () => this.subscribe());
|
|
26
|
+
this.bind("cancel", () => this.cancel());
|
|
27
|
+
this.bind("resend", () => this.resend());
|
|
28
|
+
}
|
|
29
|
+
/** A part's button runs `action`: through its form's submit when it has one, else on click. */
|
|
30
|
+
bind(part, action) {
|
|
31
|
+
const button = this.findPart(part);
|
|
32
|
+
if (!button) return;
|
|
33
|
+
const form = button.form;
|
|
34
|
+
if (form) {
|
|
35
|
+
this.listen(form, "submit", (event) => {
|
|
36
|
+
event.preventDefault();
|
|
37
|
+
void action();
|
|
38
|
+
});
|
|
39
|
+
} else {
|
|
40
|
+
this.listen(button, "click", () => void action());
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async subscribe() {
|
|
44
|
+
await this.run(
|
|
45
|
+
() => post(`${this.url}/${this.productId}`),
|
|
46
|
+
() => this.show(true)
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
async cancel() {
|
|
50
|
+
await this.run(
|
|
51
|
+
() => del(`${this.url}/${this.productId}`),
|
|
52
|
+
() => this.show(false)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
async resend() {
|
|
56
|
+
await this.run(
|
|
57
|
+
() => post(this.resendUrl),
|
|
58
|
+
() => {
|
|
59
|
+
const resend = this.findPart("resend");
|
|
60
|
+
if (resend) resend.hidden = true;
|
|
61
|
+
const sent = this.findPart("sent");
|
|
62
|
+
if (sent) sent.hidden = false;
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
show(subscribed) {
|
|
67
|
+
const offer = this.findPart("offer");
|
|
68
|
+
const waiting = this.findPart("subscribed");
|
|
69
|
+
if (offer) offer.hidden = subscribed;
|
|
70
|
+
if (waiting) waiting.hidden = !subscribed;
|
|
71
|
+
this.findPart(subscribed ? "cancel" : "subscribe")?.focus();
|
|
72
|
+
}
|
|
73
|
+
async run(request, done) {
|
|
74
|
+
if (this.busy) return;
|
|
75
|
+
this.busy = true;
|
|
76
|
+
this.setAttribute("aria-busy", "true");
|
|
77
|
+
this.showError(null);
|
|
78
|
+
try {
|
|
79
|
+
await request();
|
|
80
|
+
done();
|
|
81
|
+
} catch (error) {
|
|
82
|
+
this.showError(
|
|
83
|
+
error instanceof HttpError && error.status === 429 ? this.tooManyMessage : this.errorMessage
|
|
84
|
+
);
|
|
85
|
+
} finally {
|
|
86
|
+
this.busy = false;
|
|
87
|
+
this.removeAttribute("aria-busy");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
showError(message) {
|
|
91
|
+
const part = this.findPart("error");
|
|
92
|
+
if (part) {
|
|
93
|
+
part.textContent = message ?? "";
|
|
94
|
+
part.hidden = message === null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export {
|
|
99
|
+
SpmktBackInStock
|
|
100
|
+
};
|
|
101
|
+
//# sourceMappingURL=back-in-stock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"back-in-stock.js","sources":["../../../src/elements/back-in-stock/back-in-stock.ts"],"sourcesContent":["import { HttpError } from '../../core/errors'\nimport { del, post } from '../../core/request'\nimport { SpmktElement } from '../../lit/spmkt-element'\n\n/**\n * Parts of <spmkt-back-in-stock product-id url resend-url error-message too-many-message>, for the product shown\n * (`url` is the subscription base: POST/DELETE <url>/<product-id>; the platform's routes need a signed-in\n * customer with a confirmed e-mail). Every part is optional, so the theme renders only the visitor's state:\n * - subscribe, offer: the button, and what is shown until the visitor subscribes\n * - cancel, subscribed: the button, and what is shown while they wait\n * - resend, sent: a new verification link (POST resend-url) for a customer whose e-mail is not confirmed\n * - error: a message (render it hidden): too-many-message after 429, error-message otherwise\n *\n * A button may sit in a form that does the same without JavaScript (POST <url>/<id>, a DELETE through _method,\n * POST resend-url): its submit is then taken over here, and the form posts natively only before the element runs.\n */\nexport interface BackInStockParts {\n subscribe?: HTMLButtonElement\n offer?: HTMLElement\n cancel?: HTMLButtonElement\n subscribed?: HTMLElement\n resend?: HTMLButtonElement\n sent?: HTMLElement\n error?: HTMLElement\n}\n\n/** \"Notify me when it is back in stock\" on a product page. */\nexport class SpmktBackInStock extends SpmktElement {\n static override properties = {\n productId: { type: Number, attribute: 'product-id' },\n url: { type: String },\n resendUrl: { type: String, attribute: 'resend-url' },\n errorMessage: { type: String, attribute: 'error-message' },\n tooManyMessage: { type: String, attribute: 'too-many-message' },\n }\n productId = 0\n url = '/back-in-stock'\n resendUrl = ''\n errorMessage = ''\n tooManyMessage = ''\n\n private busy = false\n\n override connectedCallback(): void {\n super.connectedCallback()\n this.bind('subscribe', () => this.subscribe())\n this.bind('cancel', () => this.cancel())\n this.bind('resend', () => this.resend())\n }\n\n /** A part's button runs `action`: through its form's submit when it has one, else on click. */\n private bind(part: 'subscribe' | 'cancel' | 'resend', action: () => Promise<void>): void {\n const button = this.findPart<HTMLButtonElement>(part)\n if (!button) return\n const form = button.form\n if (form) {\n this.listen(form, 'submit', (event) => {\n event.preventDefault()\n void action()\n })\n } else {\n this.listen(button, 'click', () => void action())\n }\n }\n\n async subscribe(): Promise<void> {\n await this.run(\n () => post(`${this.url}/${this.productId}`),\n () => this.show(true),\n )\n }\n\n async cancel(): Promise<void> {\n await this.run(\n () => del(`${this.url}/${this.productId}`),\n () => this.show(false),\n )\n }\n\n async resend(): Promise<void> {\n await this.run(\n () => post(this.resendUrl),\n () => {\n const resend = this.findPart('resend')\n if (resend) resend.hidden = true\n const sent = this.findPart('sent')\n if (sent) sent.hidden = false\n },\n )\n }\n\n private show(subscribed: boolean): void {\n const offer = this.findPart('offer')\n const waiting = this.findPart('subscribed')\n if (offer) offer.hidden = subscribed\n if (waiting) waiting.hidden = !subscribed\n this.findPart(subscribed ? 'cancel' : 'subscribe')?.focus()\n }\n\n private async run(request: () => Promise<unknown>, done: () => void): Promise<void> {\n if (this.busy) return\n this.busy = true\n this.setAttribute('aria-busy', 'true')\n this.showError(null)\n try {\n await request()\n done()\n } catch (error) {\n this.showError(\n error instanceof HttpError && error.status === 429 ? this.tooManyMessage : this.errorMessage,\n )\n } finally {\n this.busy = false\n this.removeAttribute('aria-busy')\n }\n }\n\n private showError(message: string | null): void {\n const part = this.findPart('error')\n if (part) {\n part.textContent = message ?? ''\n part.hidden = message === null\n }\n }\n}\n"],"names":[],"mappings":";;;AA2BO,MAAM,yBAAyB,aAAa;AAAA,EAA5C,cAAA;AAAA,UAAA,GAAA,SAAA;AAQL,SAAA,YAAY;AACZ,SAAA,MAAM;AACN,SAAA,YAAY;AACZ,SAAA,eAAe;AACf,SAAA,iBAAiB;AAEjB,SAAQ,OAAO;AAAA,EAAA;AAAA,EAbf,OAAA;AAAA,SAAgB,aAAa;AAAA,MAC3B,WAAW,EAAE,MAAM,QAAQ,WAAW,aAAA;AAAA,MACtC,KAAK,EAAE,MAAM,OAAA;AAAA,MACb,WAAW,EAAE,MAAM,QAAQ,WAAW,aAAA;AAAA,MACtC,cAAc,EAAE,MAAM,QAAQ,WAAW,gBAAA;AAAA,MACzC,gBAAgB,EAAE,MAAM,QAAQ,WAAW,mBAAA;AAAA,IAAmB;AAAA,EAChE;AAAA,EASS,oBAA0B;AACjC,UAAM,kBAAA;AACN,SAAK,KAAK,aAAa,MAAM,KAAK,WAAW;AAC7C,SAAK,KAAK,UAAU,MAAM,KAAK,QAAQ;AACvC,SAAK,KAAK,UAAU,MAAM,KAAK,QAAQ;AAAA,EACzC;AAAA;AAAA,EAGQ,KAAK,MAAyC,QAAmC;AACvF,UAAM,SAAS,KAAK,SAA4B,IAAI;AACpD,QAAI,CAAC,OAAQ;AACb,UAAM,OAAO,OAAO;AACpB,QAAI,MAAM;AACR,WAAK,OAAO,MAAM,UAAU,CAAC,UAAU;AACrC,cAAM,eAAA;AACN,aAAK,OAAA;AAAA,MACP,CAAC;AAAA,IACH,OAAO;AACL,WAAK,OAAO,QAAQ,SAAS,MAAM,KAAK,QAAQ;AAAA,IAClD;AAAA,EACF;AAAA,EAEA,MAAM,YAA2B;AAC/B,UAAM,KAAK;AA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,WAAK,cAAc,WAAW;AAC9B,WAAK,SAAS,YAAY;AAAA,IAC5B;AAAA,EACF;AACF;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { SpmktElement } from '../../lit/spmkt-element';
|
|
2
|
+
/**
|
|
3
|
+
* Parts of <spmkt-carousel autoplay="6000"> (a scroll-snap track; Blade renders everything):
|
|
4
|
+
* - track (required): the horizontally scrolling element
|
|
5
|
+
* - slide (required, several): its slides
|
|
6
|
+
* - prev, next (optional): buttons
|
|
7
|
+
* - dot (optional, several): one button per slide, in order; the current one gets aria-current="true"
|
|
8
|
+
* - toggle (optional): a pause/play button, aria-pressed="true" while paused (WCAG 2.2.2)
|
|
9
|
+
* `autoplay` is the interval in milliseconds; 0 or absent turns it off.
|
|
10
|
+
* Slides (and their dots) may be hidden with CSS, e.g. per device; the carousel skips them. While fewer than two
|
|
11
|
+
* slides are shown there is nothing to move between, and prev, next, the dots and toggle are `hidden`.
|
|
12
|
+
*/
|
|
13
|
+
export interface CarouselParts {
|
|
14
|
+
track: HTMLElement;
|
|
15
|
+
slide: HTMLElement[];
|
|
16
|
+
prev?: HTMLElement;
|
|
17
|
+
next?: HTMLElement;
|
|
18
|
+
dot?: HTMLElement[];
|
|
19
|
+
toggle?: HTMLElement;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The track scrolls natively (swipe, keyboard, scrollbar); this adds arrows, dots and autoplay.
|
|
23
|
+
* Autoplay holds for reduced motion, hover, focus, hidden tabs, the pause button, and while the carousel is
|
|
24
|
+
* scrolled out of view.
|
|
25
|
+
*/
|
|
26
|
+
export declare class SpmktCarousel extends SpmktElement {
|
|
27
|
+
static properties: {
|
|
28
|
+
autoplay: {
|
|
29
|
+
type: NumberConstructor;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
autoplay: number;
|
|
33
|
+
/** Index of the slide most in view */
|
|
34
|
+
current: number;
|
|
35
|
+
private hovered;
|
|
36
|
+
private stopped;
|
|
37
|
+
private inView;
|
|
38
|
+
/** Autoplay is set up (an interval, and no reduced motion) */
|
|
39
|
+
private playing;
|
|
40
|
+
connectedCallback(): void;
|
|
41
|
+
/** The controls show only while there are at least two shown slides to move between. */
|
|
42
|
+
private refreshControls;
|
|
43
|
+
/**
|
|
44
|
+
* Scrolls to slide `index` (wraps around). A slide the page does not display (e.g. hidden on this device by the
|
|
45
|
+
* theme's CSS) is skipped in the direction of travel, so arrows, dots and autoplay only land on shown slides.
|
|
46
|
+
*/
|
|
47
|
+
go(index: number): void;
|
|
48
|
+
private mark;
|
|
49
|
+
private setUpAutoplay;
|
|
50
|
+
private paintToggle;
|
|
51
|
+
}
|