@wikala/spmkt 3.0.0-beta.2 → 4.0.0-alpha.1
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 +10 -0
- package/dist/core/api/address.js +18 -0
- package/dist/core/api/address.js.map +1 -0
- package/dist/core/api/cart.d.ts +43 -0
- package/dist/core/api/cart.js +46 -0
- package/dist/core/api/cart.js.map +1 -0
- package/dist/core/api/checkout.d.ts +90 -0
- package/dist/core/api/checkout.js +75 -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 +13 -0
- package/dist/core/api/product.js +19 -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 +137 -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 +156 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/money.d.ts +10 -0
- package/dist/core/money.js +30 -0
- package/dist/core/money.js.map +1 -0
- package/dist/core/page-events.d.ts +13 -0
- package/dist/core/page-events.js +76 -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 +22 -0
- package/dist/core/state.js +120 -0
- package/dist/core/state.js.map +1 -0
- package/dist/core/stores/cart.d.ts +45 -0
- package/dist/core/stores/cart.js +102 -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 +85 -0
- package/dist/core/stores/checkout.js +299 -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 +251 -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 +43 -0
- package/dist/elements/add-to-cart/add-to-cart.js +99 -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 +61 -0
- package/dist/elements/address-book/address-book.js +184 -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 +153 -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 +65 -0
- package/dist/elements/checkout/checkout.js +144 -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 +75 -0
- package/dist/elements/checkout-delivery/checkout-delivery.js +293 -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 +74 -0
- package/dist/elements/checkout-payment/checkout-payment.js +286 -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 +66 -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 +23 -0
- package/dist/elements/dialog/dialog.js +61 -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 +102 -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/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 +26 -0
- package/dist/elements/quick-view/quick-view.js +70 -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 +33 -0
- package/dist/elements/related/related.js +66 -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/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 +28 -0
- package/dist/elements/variant-picker/variant-picker.js +83 -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 +74 -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 +125 -0
- package/dist/locales/sr.json +130 -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,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A product's own storefront endpoint (GET /products/{id}). Themes ask it for fragments: the quick view, and
|
|
3
|
+
* the "added to cart" dialog after an add to cart (?fragments=added-to-cart&qty=N).
|
|
4
|
+
*/
|
|
5
|
+
export declare function productUrl(id: number): string;
|
|
6
|
+
/**
|
|
7
|
+
* POST /products/{id}/related: the next related products, skipping those already shown. With
|
|
8
|
+
* `fragments`, the theme renders them (the response is a FragmentResponse); without, it is JSON.
|
|
9
|
+
*/
|
|
10
|
+
export declare function fetchRelated<T = unknown>(id: number, shownIds: number[], options?: {
|
|
11
|
+
fragments?: string[];
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
}): Promise<T>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { post } from "../request.js";
|
|
2
|
+
function productUrl(id) {
|
|
3
|
+
return `/products/${id}`;
|
|
4
|
+
}
|
|
5
|
+
function fetchRelated(id, shownIds, options = {}) {
|
|
6
|
+
return post(
|
|
7
|
+
`/products/${id}/related`,
|
|
8
|
+
{ relatedIds: shownIds },
|
|
9
|
+
{
|
|
10
|
+
query: options.fragments?.length ? { fragments: options.fragments.join(",") } : void 0,
|
|
11
|
+
signal: options.signal
|
|
12
|
+
}
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
fetchRelated,
|
|
17
|
+
productUrl
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=product.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product.js","sources":["../../../src/core/api/product.ts"],"sourcesContent":["import { post } from '../request'\n\n/**\n * A product's own storefront endpoint (GET /products/{id}). Themes ask it for fragments: the quick view, and\n * the \"added to cart\" dialog after an add to cart (?fragments=added-to-cart&qty=N).\n */\nexport function productUrl(id: number): string {\n return `/products/${id}`\n}\n\n/**\n * POST /products/{id}/related: the next related products, skipping those already shown. With\n * `fragments`, the theme renders them (the response is a FragmentResponse); without, it is JSON.\n */\nexport function fetchRelated<T = unknown>(\n id: number,\n shownIds: number[],\n options: { fragments?: string[]; signal?: AbortSignal } = {},\n): Promise<T> {\n return post<T>(\n `/products/${id}/related`,\n { relatedIds: shownIds },\n {\n query: options.fragments?.length ? { fragments: options.fragments.join(',') } : undefined,\n signal: options.signal,\n },\n )\n}\n"],"names":[],"mappings":";AAMO,SAAS,WAAW,IAAoB;AAC7C,SAAO,aAAa,EAAE;AACxB;AAMO,SAAS,aACd,IACA,UACA,UAA0D,CAAA,GAC9C;AACZ,SAAO;AAAA,IACL,aAAa,EAAE;AAAA,IACf,EAAE,YAAY,SAAA;AAAA,IACd;AAAA,MACE,OAAO,QAAQ,WAAW,SAAS,EAAE,WAAW,QAAQ,UAAU,KAAK,GAAG,EAAA,IAAM;AAAA,MAChF,QAAQ,QAAQ;AAAA,IAAA;AAAA,EAClB;AAEJ;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { post } from "../request.js";
|
|
2
|
+
async function askQuestion(productId, body) {
|
|
3
|
+
const response = await post(`/api/products/${productId}/questions`, { body });
|
|
4
|
+
return response.data;
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
askQuestion
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=questions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"questions.js","sources":["../../../src/core/api/questions.ts"],"sourcesContent":["import { post } from '../request'\nimport type { Review } from '../types'\n\n/** Questions are reviews of type \"question\" on the server. Throttled per visitor. */\nexport async function askQuestion(productId: number, body: string): Promise<Review> {\n const response = await post<{ data: Review }>(`/api/products/${productId}/questions`, { body })\n return response.data\n}\n"],"names":[],"mappings":";AAIA,eAAsB,YAAY,WAAmB,MAA+B;AAClF,QAAM,WAAW,MAAM,KAAuB,iBAAiB,SAAS,cAAc,EAAE,MAAM;AAC9F,SAAO,SAAS;AAClB;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Review, UploadedImage } from '../types';
|
|
2
|
+
export interface ReviewInput {
|
|
3
|
+
rating: number;
|
|
4
|
+
body: string;
|
|
5
|
+
title?: string;
|
|
6
|
+
recommended: boolean;
|
|
7
|
+
/** Ids from uploadReviewImage() */
|
|
8
|
+
images?: number[];
|
|
9
|
+
/** Review invitation token from the e-mail link, when there is one */
|
|
10
|
+
token?: string;
|
|
11
|
+
}
|
|
12
|
+
/** Signed-in buyers only; others get 400 { message }. */
|
|
13
|
+
export declare function submitReview(productId: number, input: ReviewInput): Promise<Review>;
|
|
14
|
+
/** One vote per review and visitor; a repeat answers 422 { error } (ValidationError with that message). */
|
|
15
|
+
export declare function voteOnReview(reviewId: number, helpful: boolean): Promise<Review>;
|
|
16
|
+
export declare function uploadReviewImage(file: File, signal?: AbortSignal): Promise<UploadedImage>;
|
|
17
|
+
export declare function deleteReviewImage(id: number): Promise<unknown>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { del, post, request } from "../request.js";
|
|
2
|
+
async function submitReview(productId, input) {
|
|
3
|
+
const response = await post(`/api/products/${productId}/reviews`, input);
|
|
4
|
+
return response.data;
|
|
5
|
+
}
|
|
6
|
+
async function voteOnReview(reviewId, helpful) {
|
|
7
|
+
const response = await post(`/api/reviews/${reviewId}/votes`, { vote: helpful ? 1 : 0 });
|
|
8
|
+
return response.data;
|
|
9
|
+
}
|
|
10
|
+
async function uploadReviewImage(file, signal) {
|
|
11
|
+
const form = new FormData();
|
|
12
|
+
form.append("media-file", file);
|
|
13
|
+
form.append("media_type", "review-image");
|
|
14
|
+
const response = await request("POST", "/api/media-files", {
|
|
15
|
+
body: form,
|
|
16
|
+
signal,
|
|
17
|
+
timeout: 12e4
|
|
18
|
+
});
|
|
19
|
+
return response.data;
|
|
20
|
+
}
|
|
21
|
+
function deleteReviewImage(id) {
|
|
22
|
+
return del(`/api/media-files/${id}`);
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
deleteReviewImage,
|
|
26
|
+
submitReview,
|
|
27
|
+
uploadReviewImage,
|
|
28
|
+
voteOnReview
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=reviews.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reviews.js","sources":["../../../src/core/api/reviews.ts"],"sourcesContent":["import { del, post, request } from '../request'\nimport type { Review, UploadedImage } from '../types'\n\nexport interface ReviewInput {\n rating: number\n body: string\n title?: string\n recommended: boolean\n /** Ids from uploadReviewImage() */\n images?: number[]\n /** Review invitation token from the e-mail link, when there is one */\n token?: string\n}\n\n/** Signed-in buyers only; others get 400 { message }. */\nexport async function submitReview(productId: number, input: ReviewInput): Promise<Review> {\n const response = await post<{ data: Review }>(`/api/products/${productId}/reviews`, input)\n return response.data\n}\n\n/** One vote per review and visitor; a repeat answers 422 { error } (ValidationError with that message). */\nexport async function voteOnReview(reviewId: number, helpful: boolean): Promise<Review> {\n const response = await post<{ data: Review }>(`/api/reviews/${reviewId}/votes`, { vote: helpful ? 1 : 0 })\n return response.data\n}\n\nexport async function uploadReviewImage(file: File, signal?: AbortSignal): Promise<UploadedImage> {\n const form = new FormData()\n form.append('media-file', file)\n form.append('media_type', 'review-image')\n const response = await request<{ data: UploadedImage }>('POST', '/api/media-files', {\n body: form,\n signal,\n timeout: 120_000,\n })\n return response.data\n}\n\nexport function deleteReviewImage(id: number): Promise<unknown> {\n return del(`/api/media-files/${id}`)\n}\n"],"names":[],"mappings":";AAeA,eAAsB,aAAa,WAAmB,OAAqC;AACzF,QAAM,WAAW,MAAM,KAAuB,iBAAiB,SAAS,YAAY,KAAK;AACzF,SAAO,SAAS;AAClB;AAGA,eAAsB,aAAa,UAAkB,SAAmC;AACtF,QAAM,WAAW,MAAM,KAAuB,gBAAgB,QAAQ,UAAU,EAAE,MAAM,UAAU,IAAI,EAAA,CAAG;AACzG,SAAO,SAAS;AAClB;AAEA,eAAsB,kBAAkB,MAAY,QAA8C;AAChG,QAAM,OAAO,IAAI,SAAA;AACjB,OAAK,OAAO,cAAc,IAAI;AAC9B,OAAK,OAAO,cAAc,cAAc;AACxC,QAAM,WAAW,MAAM,QAAiC,QAAQ,oBAAoB;AAAA,IAClF,MAAM;AAAA,IACN;AAAA,IACA,SAAS;AAAA,EAAA,CACV;AACD,SAAO,SAAS;AAClB;AAEO,SAAS,kBAAkB,IAA8B;AAC9D,SAAO,IAAI,oBAAoB,EAAE,EAAE;AACrC;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sources":["../../../src/core/api/search.ts"],"sourcesContent":["import { get } from '../request'\nimport type { SearchSuggestion } from '../types'\n\n/** GET /search?q= as JSON: at most 15 products. */\nexport function suggest(q: string, signal?: AbortSignal): Promise<SearchSuggestion[]> {\n return get<SearchSuggestion[]>('/search', { query: { q }, signal })\n}\n"],"names":[],"mappings":";AAIO,SAAS,QAAQ,GAAW,QAAmD;AACpF,SAAO,IAAwB,WAAW,EAAE,OAAO,EAAE,EAAA,GAAK,QAAQ;AACpE;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface ConfigureOptions {
|
|
2
|
+
debug?: boolean;
|
|
3
|
+
/**
|
|
4
|
+
* The path the shop is served under, for a shop that is not at the root of its host (e.g. "/sr"). spmkt's
|
|
5
|
+
* own root-relative URLs (/cart, /shopping-cart, /products/{id}, ...) are prefixed with it.
|
|
6
|
+
*/
|
|
7
|
+
basePath?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function configure(options: ConfigureOptions): void;
|
|
10
|
+
export declare function isDebug(): boolean;
|
|
11
|
+
/** A root-relative path of the shop ("/cart") under the configured base path; other URLs are returned as they are. */
|
|
12
|
+
export declare function shopUrl(path: string): string;
|
|
13
|
+
/** console.warn once per key, and only in debug mode. */
|
|
14
|
+
export declare function warnOnce(key: string, message: string): void;
|
|
15
|
+
/** For tests. */
|
|
16
|
+
export declare function resetWarnings(): void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
let debug = false;
|
|
2
|
+
let basePath = "";
|
|
3
|
+
const warned = /* @__PURE__ */ new Set();
|
|
4
|
+
function configure(options) {
|
|
5
|
+
if (options.debug !== void 0) {
|
|
6
|
+
debug = options.debug;
|
|
7
|
+
}
|
|
8
|
+
if (options.basePath !== void 0) {
|
|
9
|
+
basePath = options.basePath.replace(/\/+$/, "");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function isDebug() {
|
|
13
|
+
return debug;
|
|
14
|
+
}
|
|
15
|
+
function shopUrl(path) {
|
|
16
|
+
if (!basePath || !path.startsWith("/") || path.startsWith("//")) return path;
|
|
17
|
+
if (path === basePath || path.startsWith(`${basePath}/`) || path.startsWith(`${basePath}?`)) return path;
|
|
18
|
+
return basePath + path;
|
|
19
|
+
}
|
|
20
|
+
function warnOnce(key, message) {
|
|
21
|
+
if (!debug || warned.has(key)) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
warned.add(key);
|
|
25
|
+
console.warn(`[spmkt] ${message}`);
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
configure,
|
|
29
|
+
isDebug,
|
|
30
|
+
shopUrl,
|
|
31
|
+
warnOnce
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../src/core/config.ts"],"sourcesContent":["/**\n * Package-wide switches. The theme turns debug on in development builds\n * (configure({ debug: import.meta.env.DEV })): spmkt's own build cannot know the consumer's mode.\n */\nlet debug = false\nlet basePath = ''\nconst warned = new Set<string>()\n\nexport interface ConfigureOptions {\n debug?: boolean\n /**\n * The path the shop is served under, for a shop that is not at the root of its host (e.g. \"/sr\"). spmkt's\n * own root-relative URLs (/cart, /shopping-cart, /products/{id}, ...) are prefixed with it.\n */\n basePath?: string\n}\n\nexport function configure(options: ConfigureOptions): void {\n if (options.debug !== undefined) {\n debug = options.debug\n }\n if (options.basePath !== undefined) {\n basePath = options.basePath.replace(/\\/+$/, '')\n }\n}\n\nexport function isDebug(): boolean {\n return debug\n}\n\n/** A root-relative path of the shop (\"/cart\") under the configured base path; other URLs are returned as they are. */\nexport function shopUrl(path: string): string {\n if (!basePath || !path.startsWith('/') || path.startsWith('//')) return path\n if (path === basePath || path.startsWith(`${basePath}/`) || path.startsWith(`${basePath}?`)) return path\n return basePath + path\n}\n\n/** console.warn once per key, and only in debug mode. */\nexport function warnOnce(key: string, message: string): void {\n if (!debug || warned.has(key)) {\n return\n }\n warned.add(key)\n console.warn(`[spmkt] ${message}`)\n}\n\n/** For tests. */\nexport function resetWarnings(): void {\n warned.clear()\n}\n"],"names":[],"mappings":"AAIA,IAAI,QAAQ;AACZ,IAAI,WAAW;AACf,MAAM,6BAAa,IAAA;AAWZ,SAAS,UAAU,SAAiC;AACzD,MAAI,QAAQ,UAAU,QAAW;AAC/B,YAAQ,QAAQ;AAAA,EAClB;AACA,MAAI,QAAQ,aAAa,QAAW;AAClC,eAAW,QAAQ,SAAS,QAAQ,QAAQ,EAAE;AAAA,EAChD;AACF;AAEO,SAAS,UAAmB;AACjC,SAAO;AACT;AAGO,SAAS,QAAQ,MAAsB;AAC5C,MAAI,CAAC,YAAY,CAAC,KAAK,WAAW,GAAG,KAAK,KAAK,WAAW,IAAI,EAAG,QAAO;AACxE,MAAI,SAAS,YAAY,KAAK,WAAW,GAAG,QAAQ,GAAG,KAAK,KAAK,WAAW,GAAG,QAAQ,GAAG,EAAG,QAAO;AACpG,SAAO,WAAW;AACpB;AAGO,SAAS,SAAS,KAAa,SAAuB;AAC3D,MAAI,CAAC,SAAS,OAAO,IAAI,GAAG,GAAG;AAC7B;AAAA,EACF;AACA,SAAO,IAAI,GAAG;AACd,UAAQ,KAAK,WAAW,OAAO,EAAE;AACnC;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Minimal cookie access, compatible with js-cookie's encoding (which mi2 uses for the same cookies). */
|
|
2
|
+
export declare function readCookie(name: string): string | null;
|
|
3
|
+
/** Without `days`, a session cookie (gone when the browser closes). */
|
|
4
|
+
export declare function writeCookie(name: string, value: string, days?: number): void;
|
|
5
|
+
export declare function deleteCookie(name: string): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function readCookie(name) {
|
|
2
|
+
for (const pair of document.cookie ? document.cookie.split("; ") : []) {
|
|
3
|
+
const index = pair.indexOf("=");
|
|
4
|
+
if (pair.slice(0, index) === name) {
|
|
5
|
+
try {
|
|
6
|
+
return decodeURIComponent(pair.slice(index + 1));
|
|
7
|
+
} catch {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
function secure() {
|
|
15
|
+
return location.protocol === "https:" ? "; Secure" : "";
|
|
16
|
+
}
|
|
17
|
+
function writeCookie(name, value, days) {
|
|
18
|
+
const expires = days === void 0 ? "" : `; expires=${new Date(Date.now() + days * 864e5).toUTCString()}`;
|
|
19
|
+
document.cookie = `${name}=${encodeURIComponent(value)}${expires}; path=/; SameSite=Lax${secure()}`;
|
|
20
|
+
}
|
|
21
|
+
function deleteCookie(name) {
|
|
22
|
+
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; SameSite=Lax${secure()}`;
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
deleteCookie,
|
|
26
|
+
readCookie,
|
|
27
|
+
writeCookie
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=cookies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookies.js","sources":["../../src/core/cookies.ts"],"sourcesContent":["/** Minimal cookie access, compatible with js-cookie's encoding (which mi2 uses for the same cookies). */\nexport function readCookie(name: string): string | null {\n for (const pair of document.cookie ? document.cookie.split('; ') : []) {\n const index = pair.indexOf('=')\n if (pair.slice(0, index) === name) {\n try {\n return decodeURIComponent(pair.slice(index + 1))\n } catch {\n return null\n }\n }\n }\n return null\n}\n\n/** Secure on HTTPS pages, so the cookie never travels over plain HTTP. */\nfunction secure(): string {\n return location.protocol === 'https:' ? '; Secure' : ''\n}\n\n/** Without `days`, a session cookie (gone when the browser closes). */\nexport function writeCookie(name: string, value: string, days?: number): void {\n const expires = days === undefined ? '' : `; expires=${new Date(Date.now() + days * 864e5).toUTCString()}`\n document.cookie = `${name}=${encodeURIComponent(value)}${expires}; path=/; SameSite=Lax${secure()}`\n}\n\nexport function deleteCookie(name: string): void {\n document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; SameSite=Lax${secure()}`\n}\n"],"names":[],"mappings":"AACO,SAAS,WAAW,MAA6B;AACtD,aAAW,QAAQ,SAAS,SAAS,SAAS,OAAO,MAAM,IAAI,IAAI,IAAI;AACrE,UAAM,QAAQ,KAAK,QAAQ,GAAG;AAC9B,QAAI,KAAK,MAAM,GAAG,KAAK,MAAM,MAAM;AACjC,UAAI;AACF,eAAO,mBAAmB,KAAK,MAAM,QAAQ,CAAC,CAAC;AAAA,MACjD,QAAQ;AACN,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAGA,SAAS,SAAiB;AACxB,SAAO,SAAS,aAAa,WAAW,aAAa;AACvD;AAGO,SAAS,YAAY,MAAc,OAAe,MAAqB;AAC5E,QAAM,UAAU,SAAS,SAAY,KAAK,aAAa,IAAI,KAAK,KAAK,IAAA,IAAQ,OAAO,KAAK,EAAE,aAAa;AACxG,WAAS,SAAS,GAAG,IAAI,IAAI,mBAAmB,KAAK,CAAC,GAAG,OAAO,yBAAyB,OAAA,CAAQ;AACnG;AAEO,SAAS,aAAa,MAAoB;AAC/C,WAAS,SAAS,GAAG,IAAI,iEAAiE,QAAQ;AACpG;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Any failed request. `status` is 0 when no response arrived. */
|
|
2
|
+
export declare class RequestError extends Error {
|
|
3
|
+
readonly status: number;
|
|
4
|
+
constructor(message: string, status?: number);
|
|
5
|
+
}
|
|
6
|
+
/** A non-2xx response. `body` is the parsed JSON when the server sent JSON, otherwise the text. */
|
|
7
|
+
export declare class HttpError extends RequestError {
|
|
8
|
+
readonly body: unknown;
|
|
9
|
+
constructor(message: string, status: number, body: unknown);
|
|
10
|
+
}
|
|
11
|
+
/** Laravel validation failure (422): field name -> messages. */
|
|
12
|
+
export declare class ValidationError extends HttpError {
|
|
13
|
+
readonly errors: Record<string, string[]>;
|
|
14
|
+
constructor(message: string, errors: Record<string, string[]>, body: unknown);
|
|
15
|
+
/** The first message for a field, or undefined. */
|
|
16
|
+
first(field: string): string | undefined;
|
|
17
|
+
}
|
|
18
|
+
/** 419: the CSRF token expired (usually a tab left open for hours); the page needs a reload. */
|
|
19
|
+
export declare class SessionExpiredError extends HttpError {
|
|
20
|
+
}
|
|
21
|
+
/** The request did not finish within its timeout. */
|
|
22
|
+
export declare class TimeoutError extends RequestError {
|
|
23
|
+
}
|
|
24
|
+
/** fetch() failed before a response (offline, DNS, CORS). */
|
|
25
|
+
export declare class NetworkError extends RequestError {
|
|
26
|
+
}
|
|
27
|
+
export declare function isAbortError(error: unknown): boolean;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
class RequestError extends Error {
|
|
2
|
+
constructor(message, status = 0) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.status = status;
|
|
5
|
+
this.name = new.target.name;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
class HttpError extends RequestError {
|
|
9
|
+
constructor(message, status, body) {
|
|
10
|
+
super(message, status);
|
|
11
|
+
this.body = body;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
class ValidationError extends HttpError {
|
|
15
|
+
constructor(message, errors, body) {
|
|
16
|
+
super(message, 422, body);
|
|
17
|
+
this.errors = errors;
|
|
18
|
+
}
|
|
19
|
+
/** The first message for a field, or undefined. */
|
|
20
|
+
first(field) {
|
|
21
|
+
return this.errors[field]?.[0];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
class SessionExpiredError extends HttpError {
|
|
25
|
+
}
|
|
26
|
+
class TimeoutError extends RequestError {
|
|
27
|
+
}
|
|
28
|
+
class NetworkError extends RequestError {
|
|
29
|
+
}
|
|
30
|
+
function isAbortError(error) {
|
|
31
|
+
return error instanceof DOMException && error.name === "AbortError";
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
HttpError,
|
|
35
|
+
NetworkError,
|
|
36
|
+
RequestError,
|
|
37
|
+
SessionExpiredError,
|
|
38
|
+
TimeoutError,
|
|
39
|
+
ValidationError,
|
|
40
|
+
isAbortError
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sources":["../../src/core/errors.ts"],"sourcesContent":["/** Any failed request. `status` is 0 when no response arrived. */\nexport class RequestError extends Error {\n constructor(\n message: string,\n public readonly status: number = 0,\n ) {\n super(message)\n this.name = new.target.name\n }\n}\n\n/** A non-2xx response. `body` is the parsed JSON when the server sent JSON, otherwise the text. */\nexport class HttpError extends RequestError {\n constructor(\n message: string,\n status: number,\n public readonly body: unknown,\n ) {\n super(message, status)\n }\n}\n\n/** Laravel validation failure (422): field name -> messages. */\nexport class ValidationError extends HttpError {\n constructor(\n message: string,\n public readonly errors: Record<string, string[]>,\n body: unknown,\n ) {\n super(message, 422, body)\n }\n\n /** The first message for a field, or undefined. */\n first(field: string): string | undefined {\n return this.errors[field]?.[0]\n }\n}\n\n/** 419: the CSRF token expired (usually a tab left open for hours); the page needs a reload. */\nexport class SessionExpiredError extends HttpError {}\n\n/** The request did not finish within its timeout. */\nexport class TimeoutError extends RequestError {}\n\n/** fetch() failed before a response (offline, DNS, CORS). */\nexport class NetworkError extends RequestError {}\n\nexport function isAbortError(error: unknown): boolean {\n return error instanceof DOMException && error.name === 'AbortError'\n}\n"],"names":[],"mappings":"AACO,MAAM,qBAAqB,MAAM;AAAA,EACtC,YACE,SACgB,SAAiB,GACjC;AACA,UAAM,OAAO;AAFG,SAAA,SAAA;AAGhB,SAAK,OAAO,WAAW;AAAA,EACzB;AACF;AAGO,MAAM,kBAAkB,aAAa;AAAA,EAC1C,YACE,SACA,QACgB,MAChB;AACA,UAAM,SAAS,MAAM;AAFL,SAAA,OAAA;AAAA,EAGlB;AACF;AAGO,MAAM,wBAAwB,UAAU;AAAA,EAC7C,YACE,SACgB,QAChB,MACA;AACA,UAAM,SAAS,KAAK,IAAI;AAHR,SAAA,SAAA;AAAA,EAIlB;AAAA;AAAA,EAGA,MAAM,OAAmC;AACvC,WAAO,KAAK,OAAO,KAAK,IAAI,CAAC;AAAA,EAC/B;AACF;AAGO,MAAM,4BAA4B,UAAU;AAAC;AAG7C,MAAM,qBAAqB,aAAa;AAAC;AAGzC,MAAM,qBAAqB,aAAa;AAAC;AAEzC,SAAS,aAAa,OAAyB;AACpD,SAAO,iBAAiB,gBAAgB,MAAM,SAAS;AACzD;"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/** GA4's item shape, used by every commerce event so analytics adapters pass it through. */
|
|
2
|
+
export interface Ga4Item {
|
|
3
|
+
item_id: string;
|
|
4
|
+
item_name: string;
|
|
5
|
+
price?: number;
|
|
6
|
+
quantity?: number;
|
|
7
|
+
item_variant?: string;
|
|
8
|
+
item_brand?: string;
|
|
9
|
+
item_category?: string;
|
|
10
|
+
item_list_name?: string;
|
|
11
|
+
index?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Every event spmkt dispatches, with its detail. Events bubble and are composed; core dispatches
|
|
15
|
+
* store-level events on document, elements dispatch on themselves. Part of the public API.
|
|
16
|
+
*/
|
|
17
|
+
export interface SpmktEventMap {
|
|
18
|
+
'spmkt:view-item': {
|
|
19
|
+
currency: string;
|
|
20
|
+
value: number;
|
|
21
|
+
items: Ga4Item[];
|
|
22
|
+
};
|
|
23
|
+
'spmkt:view-item-list': {
|
|
24
|
+
item_list_name?: string;
|
|
25
|
+
items: Ga4Item[];
|
|
26
|
+
};
|
|
27
|
+
'spmkt:select-item': {
|
|
28
|
+
item_list_name?: string;
|
|
29
|
+
items: Ga4Item[];
|
|
30
|
+
};
|
|
31
|
+
'spmkt:search': {
|
|
32
|
+
search_term: string;
|
|
33
|
+
};
|
|
34
|
+
/** A sign-in or registration through the shop's own form (page events after the redirect) */
|
|
35
|
+
'spmkt:login': {
|
|
36
|
+
method: string;
|
|
37
|
+
};
|
|
38
|
+
'spmkt:sign-up': {
|
|
39
|
+
method: string;
|
|
40
|
+
};
|
|
41
|
+
'spmkt:add-to-cart': {
|
|
42
|
+
currency: string;
|
|
43
|
+
value: number;
|
|
44
|
+
items: Ga4Item[];
|
|
45
|
+
};
|
|
46
|
+
'spmkt:remove-from-cart': {
|
|
47
|
+
currency: string;
|
|
48
|
+
value: number;
|
|
49
|
+
items: Ga4Item[];
|
|
50
|
+
};
|
|
51
|
+
/** Page event of the cart page */
|
|
52
|
+
'spmkt:view-cart': {
|
|
53
|
+
currency: string;
|
|
54
|
+
value: number;
|
|
55
|
+
items: Ga4Item[];
|
|
56
|
+
};
|
|
57
|
+
/** The delivery step was entered */
|
|
58
|
+
'spmkt:begin-checkout': {
|
|
59
|
+
currency: string;
|
|
60
|
+
value: number;
|
|
61
|
+
items: Ga4Item[];
|
|
62
|
+
coupon?: string;
|
|
63
|
+
};
|
|
64
|
+
/** The delivery step was completed */
|
|
65
|
+
'spmkt:add-shipping-info': {
|
|
66
|
+
currency: string;
|
|
67
|
+
value: number;
|
|
68
|
+
items: Ga4Item[];
|
|
69
|
+
coupon?: string;
|
|
70
|
+
shipping_tier?: string;
|
|
71
|
+
};
|
|
72
|
+
/** An order is being placed */
|
|
73
|
+
'spmkt:add-payment-info': {
|
|
74
|
+
currency: string;
|
|
75
|
+
value: number;
|
|
76
|
+
items: Ga4Item[];
|
|
77
|
+
coupon?: string;
|
|
78
|
+
payment_type?: string;
|
|
79
|
+
};
|
|
80
|
+
/** The checkout showed another step */
|
|
81
|
+
'spmkt:checkout-step': {
|
|
82
|
+
step: 'cart' | 'delivery' | 'payment' | 'done';
|
|
83
|
+
};
|
|
84
|
+
/** A checkout request came back with re-rendered theme fragments (e.g. the order summary) */
|
|
85
|
+
'spmkt:checkout-updated': {
|
|
86
|
+
fragments: Record<string, string>;
|
|
87
|
+
};
|
|
88
|
+
/** Page event of the order confirmation; dispatched once per order id */
|
|
89
|
+
'spmkt:purchase': {
|
|
90
|
+
transaction_id: string;
|
|
91
|
+
currency: string;
|
|
92
|
+
value: number;
|
|
93
|
+
tax?: number;
|
|
94
|
+
shipping?: number;
|
|
95
|
+
coupon?: string;
|
|
96
|
+
items: Ga4Item[];
|
|
97
|
+
};
|
|
98
|
+
'spmkt:cart-changed': {
|
|
99
|
+
count: number;
|
|
100
|
+
subtotal: number;
|
|
101
|
+
};
|
|
102
|
+
'spmkt:compare-changed': {
|
|
103
|
+
ids: number[];
|
|
104
|
+
};
|
|
105
|
+
/** A variant picker showed another variant (the product section was re-rendered for it) */
|
|
106
|
+
'spmkt:variant-change': {
|
|
107
|
+
id: number;
|
|
108
|
+
};
|
|
109
|
+
'spmkt:location-changed': {
|
|
110
|
+
id: number;
|
|
111
|
+
};
|
|
112
|
+
'spmkt:dialog-open': {
|
|
113
|
+
id: string;
|
|
114
|
+
};
|
|
115
|
+
'spmkt:dialog-close': {
|
|
116
|
+
id: string;
|
|
117
|
+
};
|
|
118
|
+
'spmkt:tab-change': {
|
|
119
|
+
panel: string;
|
|
120
|
+
};
|
|
121
|
+
'spmkt:slide-change': {
|
|
122
|
+
index: number;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
export type SpmktEventName = keyof SpmktEventMap;
|
|
126
|
+
export type SpmktEvent<N extends SpmktEventName> = CustomEvent<SpmktEventMap[N]>;
|
|
127
|
+
type SpmktDomEvents = {
|
|
128
|
+
[N in SpmktEventName]: SpmktEvent<N>;
|
|
129
|
+
};
|
|
130
|
+
declare global {
|
|
131
|
+
interface GlobalEventHandlersEventMap extends SpmktDomEvents {
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
export declare function dispatch<N extends SpmktEventName>(target: EventTarget, name: N, detail: SpmktEventMap[N]): boolean;
|
|
135
|
+
/** addEventListener with the detail typed; returns the remover. */
|
|
136
|
+
export declare function on<N extends SpmktEventName>(target: EventTarget, name: N, handler: (event: SpmktEvent<N>) => void, options?: AddEventListenerOptions): () => void;
|
|
137
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function dispatch(target, name, detail) {
|
|
2
|
+
return target.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true }));
|
|
3
|
+
}
|
|
4
|
+
function on(target, name, handler, options) {
|
|
5
|
+
const listener = handler;
|
|
6
|
+
target.addEventListener(name, listener, options);
|
|
7
|
+
return () => target.removeEventListener(name, listener, options);
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
dispatch,
|
|
11
|
+
on
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sources":["../../src/core/events.ts"],"sourcesContent":["/** GA4's item shape, used by every commerce event so analytics adapters pass it through. */\nexport interface Ga4Item {\n item_id: string\n item_name: string\n price?: number\n quantity?: number\n item_variant?: string\n item_brand?: string\n item_category?: string\n item_list_name?: string\n index?: number\n}\n\n/**\n * Every event spmkt dispatches, with its detail. Events bubble and are composed; core dispatches\n * store-level events on document, elements dispatch on themselves. Part of the public API.\n */\nexport interface SpmktEventMap {\n 'spmkt:view-item': { currency: string; value: number; items: Ga4Item[] }\n 'spmkt:view-item-list': { item_list_name?: string; items: Ga4Item[] }\n 'spmkt:select-item': { item_list_name?: string; items: Ga4Item[] }\n 'spmkt:search': { search_term: string }\n /** A sign-in or registration through the shop's own form (page events after the redirect) */\n 'spmkt:login': { method: string }\n 'spmkt:sign-up': { method: string }\n 'spmkt:add-to-cart': { currency: string; value: number; items: Ga4Item[] }\n 'spmkt:remove-from-cart': { currency: string; value: number; items: Ga4Item[] }\n /** Page event of the cart page */\n 'spmkt:view-cart': { currency: string; value: number; items: Ga4Item[] }\n /** The delivery step was entered */\n 'spmkt:begin-checkout': { currency: string; value: number; items: Ga4Item[]; coupon?: string }\n /** The delivery step was completed */\n 'spmkt:add-shipping-info': {\n currency: string\n value: number\n items: Ga4Item[]\n coupon?: string\n shipping_tier?: string\n }\n /** An order is being placed */\n 'spmkt:add-payment-info': {\n currency: string\n value: number\n items: Ga4Item[]\n coupon?: string\n payment_type?: string\n }\n /** The checkout showed another step */\n 'spmkt:checkout-step': { step: 'cart' | 'delivery' | 'payment' | 'done' }\n /** A checkout request came back with re-rendered theme fragments (e.g. the order summary) */\n 'spmkt:checkout-updated': { fragments: Record<string, string> }\n /** Page event of the order confirmation; dispatched once per order id */\n 'spmkt:purchase': {\n transaction_id: string\n currency: string\n value: number\n tax?: number\n shipping?: number\n coupon?: string\n items: Ga4Item[]\n }\n 'spmkt:cart-changed': { count: number; subtotal: number }\n 'spmkt:compare-changed': { ids: number[] }\n /** A variant picker showed another variant (the product section was re-rendered for it) */\n 'spmkt:variant-change': { id: number }\n 'spmkt:location-changed': { id: number }\n 'spmkt:dialog-open': { id: string }\n 'spmkt:dialog-close': { id: string }\n 'spmkt:tab-change': { panel: string }\n 'spmkt:slide-change': { index: number }\n}\n\nexport type SpmktEventName = keyof SpmktEventMap\nexport type SpmktEvent<N extends SpmktEventName> = CustomEvent<SpmktEventMap[N]>\ntype SpmktDomEvents = { [N in SpmktEventName]: SpmktEvent<N> }\n\ndeclare global {\n // addEventListener('spmkt:...') on elements and document is typed\n interface GlobalEventHandlersEventMap extends SpmktDomEvents {}\n}\n\nexport function dispatch<N extends SpmktEventName>(\n target: EventTarget,\n name: N,\n detail: SpmktEventMap[N],\n): boolean {\n return target.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true }))\n}\n\n/** addEventListener with the detail typed; returns the remover. */\nexport function on<N extends SpmktEventName>(\n target: EventTarget,\n name: N,\n handler: (event: SpmktEvent<N>) => void,\n options?: AddEventListenerOptions,\n): () => void {\n const listener = handler as EventListener\n target.addEventListener(name, listener, options)\n return () => target.removeEventListener(name, listener, options)\n}\n"],"names":[],"mappings":"AAiFO,SAAS,SACd,QACA,MACA,QACS;AACT,SAAO,OAAO,cAAc,IAAI,YAAY,MAAM,EAAE,QAAQ,SAAS,MAAM,UAAU,KAAA,CAAM,CAAC;AAC9F;AAGO,SAAS,GACd,QACA,MACA,SACA,SACY;AACZ,QAAM,WAAW;AACjB,SAAO,iBAAiB,MAAM,UAAU,OAAO;AAC/C,SAAO,MAAM,OAAO,oBAAoB,MAAM,UAAU,OAAO;AACjE;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plain forms the server answers with a page load (sign-in, registration) are sent once: a form marked
|
|
3
|
+
* `data-busy-on-submit` gets `aria-busy="true"` and disabled submit buttons once it is sent. A submit some
|
|
4
|
+
* script took over (defaultPrevented) changes nothing. Coming Back to the page from the back/forward cache
|
|
5
|
+
* makes the forms usable again. Returns the uninstaller.
|
|
6
|
+
*/
|
|
7
|
+
export declare function installBusyForms(root?: Document): () => void;
|
|
8
|
+
/**
|
|
9
|
+
* Plain forms the server guards with reCAPTCHA (sign-in, registration, password reset, contact): a form marked
|
|
10
|
+
* `data-recaptcha="<action>"` is held when it is submitted, a token for the action is fetched (tokens live two
|
|
11
|
+
* minutes and work once, so not earlier), put in a hidden `recaptcha_token` field, and the form is sent as it
|
|
12
|
+
* was, with the same button. While it waits the form is `aria-busy` and further submits are dropped.
|
|
13
|
+
* Without a site key the forms are left alone. When reCAPTCHA cannot answer within `timeout`, the form goes
|
|
14
|
+
* without a token and the server decides (it lets a few such requests through). Without JavaScript the same.
|
|
15
|
+
* Install it before installBusyForms, so that one sees the held submit as handled. Returns the uninstaller.
|
|
16
|
+
*/
|
|
17
|
+
export declare function installRecaptchaForms(root?: Document, timeout?: number): () => void;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { recaptchaToken } from "./recaptcha.js";
|
|
2
|
+
import { storefront } from "./state.js";
|
|
3
|
+
const BUSY = "form[data-busy-on-submit]";
|
|
4
|
+
function installBusyForms(root = document) {
|
|
5
|
+
const onSubmit = (event) => {
|
|
6
|
+
const form = event.target;
|
|
7
|
+
if (!(form instanceof HTMLFormElement) || !form.matches(BUSY)) return;
|
|
8
|
+
setTimeout(() => {
|
|
9
|
+
if (event.defaultPrevented) return;
|
|
10
|
+
form.setAttribute("aria-busy", "true");
|
|
11
|
+
submitButtons(form).forEach((button) => button.disabled = true);
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
const onPageShow = (event) => {
|
|
15
|
+
if (!event.persisted) return;
|
|
16
|
+
root.querySelectorAll(`${BUSY}[aria-busy]`).forEach((form) => {
|
|
17
|
+
form.removeAttribute("aria-busy");
|
|
18
|
+
submitButtons(form).forEach((button) => button.disabled = false);
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
root.addEventListener("submit", onSubmit);
|
|
22
|
+
const view = root.defaultView;
|
|
23
|
+
view?.addEventListener("pageshow", onPageShow);
|
|
24
|
+
return () => {
|
|
25
|
+
root.removeEventListener("submit", onSubmit);
|
|
26
|
+
view?.removeEventListener("pageshow", onPageShow);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function submitButtons(form) {
|
|
30
|
+
return [...form.querySelectorAll('button:not([type]), button[type="submit"]')];
|
|
31
|
+
}
|
|
32
|
+
const RECAPTCHA = "form[data-recaptcha]";
|
|
33
|
+
function installRecaptchaForms(root = document, timeout = 4e3) {
|
|
34
|
+
const waiting = /* @__PURE__ */ new WeakSet();
|
|
35
|
+
const cleared = /* @__PURE__ */ new WeakSet();
|
|
36
|
+
const onSubmit = (event) => {
|
|
37
|
+
const form = event.target;
|
|
38
|
+
if (!(form instanceof HTMLFormElement) || !form.matches(RECAPTCHA) || cleared.has(form)) return;
|
|
39
|
+
if (!storefront().recaptchaSiteKey) return;
|
|
40
|
+
event.preventDefault();
|
|
41
|
+
event.stopImmediatePropagation();
|
|
42
|
+
if (waiting.has(form)) return;
|
|
43
|
+
waiting.add(form);
|
|
44
|
+
form.setAttribute("aria-busy", "true");
|
|
45
|
+
const submitter = event.submitter instanceof HTMLElement ? event.submitter : null;
|
|
46
|
+
void recaptchaToken(form.dataset.recaptcha || "form", timeout).then((token) => {
|
|
47
|
+
let field = form.querySelector('input[type="hidden"][name="recaptcha_token"]');
|
|
48
|
+
if (token && !field) {
|
|
49
|
+
field = Object.assign(document.createElement("input"), { type: "hidden", name: "recaptcha_token" });
|
|
50
|
+
form.append(field);
|
|
51
|
+
}
|
|
52
|
+
if (field) field.value = token ?? "";
|
|
53
|
+
waiting.delete(form);
|
|
54
|
+
form.removeAttribute("aria-busy");
|
|
55
|
+
cleared.add(form);
|
|
56
|
+
try {
|
|
57
|
+
form.requestSubmit(submitter?.isConnected ? submitter : null);
|
|
58
|
+
} finally {
|
|
59
|
+
cleared.delete(form);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
root.addEventListener("submit", onSubmit, true);
|
|
64
|
+
return () => root.removeEventListener("submit", onSubmit, true);
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
installBusyForms,
|
|
68
|
+
installRecaptchaForms
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=forms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forms.js","sources":["../../src/core/forms.ts"],"sourcesContent":["import { recaptchaToken } from './recaptcha'\nimport { storefront } from './state'\n\nconst BUSY = 'form[data-busy-on-submit]'\n\n/**\n * Plain forms the server answers with a page load (sign-in, registration) are sent once: a form marked\n * `data-busy-on-submit` gets `aria-busy=\"true\"` and disabled submit buttons once it is sent. A submit some\n * script took over (defaultPrevented) changes nothing. Coming Back to the page from the back/forward cache\n * makes the forms usable again. Returns the uninstaller.\n */\nexport function installBusyForms(root: Document = document): () => void {\n const onSubmit = (event: SubmitEvent): void => {\n const form = event.target\n if (!(form instanceof HTMLFormElement) || !form.matches(BUSY)) return\n // In the next task: every listener has run, so a submit handled in place (defaultPrevented) is left alone,\n // and the browser has already read the submitter, so its name and value are still sent\n setTimeout(() => {\n if (event.defaultPrevented) return\n form.setAttribute('aria-busy', 'true')\n submitButtons(form).forEach((button) => (button.disabled = true))\n })\n }\n const onPageShow = (event: PageTransitionEvent): void => {\n if (!event.persisted) return\n root.querySelectorAll<HTMLFormElement>(`${BUSY}[aria-busy]`).forEach((form) => {\n form.removeAttribute('aria-busy')\n submitButtons(form).forEach((button) => (button.disabled = false))\n })\n }\n root.addEventListener('submit', onSubmit)\n const view = root.defaultView\n view?.addEventListener('pageshow', onPageShow)\n return () => {\n root.removeEventListener('submit', onSubmit)\n view?.removeEventListener('pageshow', onPageShow)\n }\n}\n\nfunction submitButtons(form: HTMLFormElement): HTMLButtonElement[] {\n return [...form.querySelectorAll<HTMLButtonElement>('button:not([type]), button[type=\"submit\"]')]\n}\n\nconst RECAPTCHA = 'form[data-recaptcha]'\n\n/**\n * Plain forms the server guards with reCAPTCHA (sign-in, registration, password reset, contact): a form marked\n * `data-recaptcha=\"<action>\"` is held when it is submitted, a token for the action is fetched (tokens live two\n * minutes and work once, so not earlier), put in a hidden `recaptcha_token` field, and the form is sent as it\n * was, with the same button. While it waits the form is `aria-busy` and further submits are dropped.\n * Without a site key the forms are left alone. When reCAPTCHA cannot answer within `timeout`, the form goes\n * without a token and the server decides (it lets a few such requests through). Without JavaScript the same.\n * Install it before installBusyForms, so that one sees the held submit as handled. Returns the uninstaller.\n */\nexport function installRecaptchaForms(root: Document = document, timeout = 4000): () => void {\n const waiting = new WeakSet<HTMLFormElement>()\n const cleared = new WeakSet<HTMLFormElement>()\n const onSubmit = (event: SubmitEvent): void => {\n const form = event.target\n if (!(form instanceof HTMLFormElement) || !form.matches(RECAPTCHA) || cleared.has(form)) return\n if (!storefront().recaptchaSiteKey) return\n event.preventDefault()\n event.stopImmediatePropagation()\n if (waiting.has(form)) return\n waiting.add(form)\n form.setAttribute('aria-busy', 'true')\n const submitter = event.submitter instanceof HTMLElement ? event.submitter : null\n\n void recaptchaToken(form.dataset.recaptcha || 'form', timeout).then((token) => {\n let field = form.querySelector<HTMLInputElement>('input[type=\"hidden\"][name=\"recaptcha_token\"]')\n if (token && !field) {\n field = Object.assign(document.createElement('input'), { type: 'hidden', name: 'recaptcha_token' })\n form.append(field)\n }\n if (field) field.value = token ?? ''\n waiting.delete(form)\n form.removeAttribute('aria-busy')\n // The same submit again, this time let through (requestSubmit announces it before it returns)\n cleared.add(form)\n try {\n form.requestSubmit(submitter?.isConnected ? submitter : null)\n } finally {\n cleared.delete(form)\n }\n })\n }\n root.addEventListener('submit', onSubmit, true)\n return () => root.removeEventListener('submit', onSubmit, true)\n}\n"],"names":[],"mappings":";;AAGA,MAAM,OAAO;AAQN,SAAS,iBAAiB,OAAiB,UAAsB;AACtE,QAAM,WAAW,CAAC,UAA6B;AAC7C,UAAM,OAAO,MAAM;AACnB,QAAI,EAAE,gBAAgB,oBAAoB,CAAC,KAAK,QAAQ,IAAI,EAAG;AAG/D,eAAW,MAAM;AACf,UAAI,MAAM,iBAAkB;AAC5B,WAAK,aAAa,aAAa,MAAM;AACrC,oBAAc,IAAI,EAAE,QAAQ,CAAC,WAAY,OAAO,WAAW,IAAK;AAAA,IAClE,CAAC;AAAA,EACH;AACA,QAAM,aAAa,CAAC,UAAqC;AACvD,QAAI,CAAC,MAAM,UAAW;AACtB,SAAK,iBAAkC,GAAG,IAAI,aAAa,EAAE,QAAQ,CAAC,SAAS;AAC7E,WAAK,gBAAgB,WAAW;AAChC,oBAAc,IAAI,EAAE,QAAQ,CAAC,WAAY,OAAO,WAAW,KAAM;AAAA,IACnE,CAAC;AAAA,EACH;AACA,OAAK,iBAAiB,UAAU,QAAQ;AACxC,QAAM,OAAO,KAAK;AAClB,QAAM,iBAAiB,YAAY,UAAU;AAC7C,SAAO,MAAM;AACX,SAAK,oBAAoB,UAAU,QAAQ;AAC3C,UAAM,oBAAoB,YAAY,UAAU;AAAA,EAClD;AACF;AAEA,SAAS,cAAc,MAA4C;AACjE,SAAO,CAAC,GAAG,KAAK,iBAAoC,2CAA2C,CAAC;AAClG;AAEA,MAAM,YAAY;AAWX,SAAS,sBAAsB,OAAiB,UAAU,UAAU,KAAkB;AAC3F,QAAM,8BAAc,QAAA;AACpB,QAAM,8BAAc,QAAA;AACpB,QAAM,WAAW,CAAC,UAA6B;AAC7C,UAAM,OAAO,MAAM;AACnB,QAAI,EAAE,gBAAgB,oBAAoB,CAAC,KAAK,QAAQ,SAAS,KAAK,QAAQ,IAAI,IAAI,EAAG;AACzF,QAAI,CAAC,WAAA,EAAa,iBAAkB;AACpC,UAAM,eAAA;AACN,UAAM,yBAAA;AACN,QAAI,QAAQ,IAAI,IAAI,EAAG;AACvB,YAAQ,IAAI,IAAI;AAChB,SAAK,aAAa,aAAa,MAAM;AACrC,UAAM,YAAY,MAAM,qBAAqB,cAAc,MAAM,YAAY;AAE7E,SAAK,eAAe,KAAK,QAAQ,aAAa,QAAQ,OAAO,EAAE,KAAK,CAAC,UAAU;AAC7E,UAAI,QAAQ,KAAK,cAAgC,8CAA8C;AAC/F,UAAI,SAAS,CAAC,OAAO;AACnB,gBAAQ,OAAO,OAAO,SAAS,cAAc,OAAO,GAAG,EAAE,MAAM,UAAU,MAAM,kBAAA,CAAmB;AAClG,aAAK,OAAO,KAAK;AAAA,MACnB;AACA,UAAI,MAAO,OAAM,QAAQ,SAAS;AAClC,cAAQ,OAAO,IAAI;AACnB,WAAK,gBAAgB,WAAW;AAEhC,cAAQ,IAAI,IAAI;AAChB,UAAI;AACF,aAAK,cAAc,WAAW,cAAc,YAAY,IAAI;AAAA,MAC9D,UAAA;AACE,gBAAQ,OAAO,IAAI;AAAA,MACrB;AAAA,IACF,CAAC;AAAA,EACH;AACA,OAAK,iBAAiB,UAAU,UAAU,IAAI;AAC9C,SAAO,MAAM,KAAK,oBAAoB,UAAU,UAAU,IAAI;AAChE;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** A string, or plural forms keyed by Intl plural category ("one", "few", "other", ...). */
|
|
2
|
+
export type Message = string | Partial<Record<Intl.LDMLPluralRule, string>>;
|
|
3
|
+
export interface Messages {
|
|
4
|
+
[key: string]: Message | Messages;
|
|
5
|
+
}
|
|
6
|
+
export type Params = Record<string, string | number>;
|
|
7
|
+
/**
|
|
8
|
+
* Sets the locale and the strings. `messages` is one catalog or several merged in order, typically
|
|
9
|
+
* spmkt's own locale file followed by the theme's overrides:
|
|
10
|
+
* import sr from '@wikala/spmkt/locales/sr.json'
|
|
11
|
+
* configureI18n({ locale: 'sr', messages: [sr, themeStrings] })
|
|
12
|
+
*/
|
|
13
|
+
export declare function configureI18n(options: {
|
|
14
|
+
locale?: string;
|
|
15
|
+
messages?: Messages | Messages[];
|
|
16
|
+
}): void;
|
|
17
|
+
export declare function currentLocale(): string;
|
|
18
|
+
/**
|
|
19
|
+
* The locale for Intl formatters (dates, lists). A bare "sr" means Serbian Latin, as spmkt's own strings are:
|
|
20
|
+
* Intl would otherwise write Cyrillic. A theme in Cyrillic sets lang="sr-Cyrl".
|
|
21
|
+
*/
|
|
22
|
+
export declare function intlLocale(): string;
|
|
23
|
+
/** The string for a dotted key, with {name} placeholders filled; the key itself when missing. */
|
|
24
|
+
export declare function t(key: string, params?: Params): string;
|
|
25
|
+
/** The plural form for `count` ({count} is available as a placeholder). */
|
|
26
|
+
export declare function plural(key: string, count: number, params?: Params): string;
|