@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,35 @@
|
|
|
1
|
+
import { storefront } from "../../core/state.js";
|
|
2
|
+
import { JsonForm } from "./json-form.js";
|
|
3
|
+
import { applyPhoneMask } from "./phone-mask.js";
|
|
4
|
+
class FoldingForm extends JsonForm {
|
|
5
|
+
connectedCallback() {
|
|
6
|
+
super.connectedCallback();
|
|
7
|
+
const edit = this.findPart("edit");
|
|
8
|
+
if (edit) this.listen(edit, "click", () => this.unfold());
|
|
9
|
+
const mask = storefront().checkout.phoneMask;
|
|
10
|
+
const phone = this.form().elements.namedItem("phone");
|
|
11
|
+
if (mask && phone instanceof HTMLInputElement) this.onDisconnect(applyPhoneMask(phone, mask));
|
|
12
|
+
}
|
|
13
|
+
accepted(text) {
|
|
14
|
+
if (text !== null) this.fold(text);
|
|
15
|
+
}
|
|
16
|
+
fold(text) {
|
|
17
|
+
const done = this.findPart("done");
|
|
18
|
+
if (!done) return;
|
|
19
|
+
const doneText = this.findPart("done-text");
|
|
20
|
+
if (doneText) doneText.textContent = text;
|
|
21
|
+
this.form().hidden = true;
|
|
22
|
+
done.hidden = false;
|
|
23
|
+
}
|
|
24
|
+
unfold() {
|
|
25
|
+
const form = this.form();
|
|
26
|
+
form.hidden = false;
|
|
27
|
+
const done = this.findPart("done");
|
|
28
|
+
if (done) done.hidden = true;
|
|
29
|
+
form.querySelector("input, select")?.focus();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
FoldingForm
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=folding-form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"folding-form.js","sources":["../../../src/elements/shared/folding-form.ts"],"sourcesContent":["import { storefront } from '../../core/state'\nimport { JsonForm } from './json-form'\nimport { applyPhoneMask } from './phone-mask'\n\n/**\n * A checkout block whose form, once accepted, folds into a line of text with an \"edit\" button. Parts, besides\n * JsonForm's (form, submit, error):\n * - done (optional): shown instead of the form once accepted; done-text gets the summary, edit unfolds the form\n * A `phone` field follows the shop's phone mask (checkout.phoneMask), when it has one.\n */\nexport abstract class FoldingForm extends JsonForm<string | null> {\n /** Sends the values; resolves with the line to show once folded, or null to leave the form open. */\n protected abstract override accept(values: Record<string, string>): Promise<string | null>\n\n override connectedCallback(): void {\n super.connectedCallback()\n const edit = this.findPart('edit')\n if (edit) this.listen(edit, 'click', () => this.unfold())\n const mask = storefront().checkout.phoneMask\n const phone = this.form().elements.namedItem('phone')\n if (mask && phone instanceof HTMLInputElement) this.onDisconnect(applyPhoneMask(phone, mask))\n }\n\n protected override accepted(text: string | null): void {\n if (text !== null) this.fold(text)\n }\n\n protected fold(text: string): void {\n const done = this.findPart('done')\n if (!done) return\n const doneText = this.findPart('done-text')\n if (doneText) doneText.textContent = text\n this.form().hidden = true\n done.hidden = false\n }\n\n protected unfold(): void {\n const form = this.form()\n form.hidden = false\n const done = this.findPart('done')\n if (done) done.hidden = true\n form.querySelector<HTMLElement>('input, select')?.focus()\n }\n}\n"],"names":[],"mappings":";;;AAUO,MAAe,oBAAoB,SAAwB;AAAA,EAIvD,oBAA0B;AACjC,UAAM,kBAAA;AACN,UAAM,OAAO,KAAK,SAAS,MAAM;AACjC,QAAI,WAAW,OAAO,MAAM,SAAS,MAAM,KAAK,QAAQ;AACxD,UAAM,OAAO,aAAa,SAAS;AACnC,UAAM,QAAQ,KAAK,KAAA,EAAO,SAAS,UAAU,OAAO;AACpD,QAAI,QAAQ,iBAAiB,iBAAkB,MAAK,aAAa,eAAe,OAAO,IAAI,CAAC;AAAA,EAC9F;AAAA,EAEmB,SAAS,MAA2B;AACrD,QAAI,SAAS,KAAM,MAAK,KAAK,IAAI;AAAA,EACnC;AAAA,EAEU,KAAK,MAAoB;AACjC,UAAM,OAAO,KAAK,SAAS,MAAM;AACjC,QAAI,CAAC,KAAM;AACX,UAAM,WAAW,KAAK,SAAS,WAAW;AAC1C,QAAI,mBAAmB,cAAc;AACrC,SAAK,OAAO,SAAS;AACrB,SAAK,SAAS;AAAA,EAChB;AAAA,EAEU,SAAe;AACvB,UAAM,OAAO,KAAK,KAAA;AAClB,SAAK,SAAS;AACd,UAAM,OAAO,KAAK,SAAS,MAAM;AACjC,QAAI,WAAW,SAAS;AACxB,SAAK,cAA2B,eAAe,GAAG,MAAA;AAAA,EACpD;AACF;"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The parts of the Google Maps JS API spmkt uses: the store map, and Places for address autocomplete (typed
|
|
3
|
+
* here instead of depending on @types/google.maps).
|
|
4
|
+
*/
|
|
5
|
+
export interface LatLng {
|
|
6
|
+
lat: number;
|
|
7
|
+
lng: number;
|
|
8
|
+
}
|
|
9
|
+
export interface GoogleMap {
|
|
10
|
+
setCenter(position: LatLng): void;
|
|
11
|
+
setZoom(zoom: number): void;
|
|
12
|
+
fitBounds(bounds: unknown, padding?: number): void;
|
|
13
|
+
}
|
|
14
|
+
export interface InfoWindow {
|
|
15
|
+
setContent(content: Node | string): void;
|
|
16
|
+
open(options: {
|
|
17
|
+
map: GoogleMap;
|
|
18
|
+
anchor: unknown;
|
|
19
|
+
}): void;
|
|
20
|
+
close(): void;
|
|
21
|
+
}
|
|
22
|
+
export interface Marker {
|
|
23
|
+
addListener(event: 'click' | 'gmp-click', handler: () => void): unknown;
|
|
24
|
+
}
|
|
25
|
+
export interface GoogleMapsApi {
|
|
26
|
+
Map: new (element: HTMLElement, options: Record<string, unknown>) => GoogleMap;
|
|
27
|
+
InfoWindow: new () => InfoWindow;
|
|
28
|
+
LatLngBounds: new () => {
|
|
29
|
+
extend(position: LatLng): void;
|
|
30
|
+
};
|
|
31
|
+
Marker: new (options: {
|
|
32
|
+
map: GoogleMap;
|
|
33
|
+
position: LatLng;
|
|
34
|
+
title: string;
|
|
35
|
+
}) => Marker;
|
|
36
|
+
marker?: {
|
|
37
|
+
AdvancedMarkerElement: new (options: {
|
|
38
|
+
map: GoogleMap;
|
|
39
|
+
position: LatLng;
|
|
40
|
+
title: string;
|
|
41
|
+
}) => Marker;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
declare global {
|
|
45
|
+
interface Window {
|
|
46
|
+
google?: {
|
|
47
|
+
maps?: GoogleMapsApi & {
|
|
48
|
+
importLibrary?: (name: string) => Promise<unknown>;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The Google Maps JS API, loaded once per page with the theme's key (an already loaded API is used as is).
|
|
55
|
+
* The marker library is loaded too, for maps with a Map ID (advanced markers).
|
|
56
|
+
*/
|
|
57
|
+
export declare function loadGoogleMaps(apiKey: string): Promise<GoogleMapsApi>;
|
|
58
|
+
/** Text with match offsets, as Places (New) gives it; only the text is used. */
|
|
59
|
+
export interface FormattableText {
|
|
60
|
+
text: string;
|
|
61
|
+
}
|
|
62
|
+
export interface AddressComponent {
|
|
63
|
+
longText: string | null;
|
|
64
|
+
shortText: string | null;
|
|
65
|
+
types: string[];
|
|
66
|
+
}
|
|
67
|
+
export interface Place {
|
|
68
|
+
addressComponents?: AddressComponent[];
|
|
69
|
+
fetchFields(options: {
|
|
70
|
+
fields: string[];
|
|
71
|
+
}): Promise<unknown>;
|
|
72
|
+
}
|
|
73
|
+
export interface PlacePrediction {
|
|
74
|
+
placeId: string;
|
|
75
|
+
text: FormattableText;
|
|
76
|
+
mainText: FormattableText | null;
|
|
77
|
+
secondaryText: FormattableText | null;
|
|
78
|
+
toPlace(): Place;
|
|
79
|
+
}
|
|
80
|
+
export interface AutocompleteRequest {
|
|
81
|
+
input: string;
|
|
82
|
+
sessionToken?: unknown;
|
|
83
|
+
includedRegionCodes?: string[];
|
|
84
|
+
language?: string;
|
|
85
|
+
}
|
|
86
|
+
export interface PlacesLibrary {
|
|
87
|
+
AutocompleteSessionToken: new () => unknown;
|
|
88
|
+
AutocompleteSuggestion: {
|
|
89
|
+
fetchAutocompleteSuggestions(request: AutocompleteRequest): Promise<{
|
|
90
|
+
suggestions: {
|
|
91
|
+
placePrediction: PlacePrediction | null;
|
|
92
|
+
}[];
|
|
93
|
+
}>;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The Places library (Places API (New): AutocompleteSuggestion), on top of the Maps JS API loaded with the
|
|
98
|
+
* same key. The key needs the Places API (New) enabled.
|
|
99
|
+
*/
|
|
100
|
+
export declare function loadPlaces(apiKey: string): Promise<PlacesLibrary>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
let loading;
|
|
2
|
+
function loadGoogleMaps(apiKey) {
|
|
3
|
+
if (window.google?.maps?.Map) {
|
|
4
|
+
return Promise.resolve(window.google.maps);
|
|
5
|
+
}
|
|
6
|
+
loading ??= new Promise((resolve, reject) => {
|
|
7
|
+
const callback = `__spmktMaps${Date.now()}`;
|
|
8
|
+
window[callback] = () => {
|
|
9
|
+
delete window[callback];
|
|
10
|
+
resolve(window.google.maps);
|
|
11
|
+
};
|
|
12
|
+
const script = document.createElement("script");
|
|
13
|
+
const query = new URLSearchParams({ key: apiKey, loading: "async", libraries: "marker", callback });
|
|
14
|
+
script.src = `https://maps.googleapis.com/maps/api/js?${query}`;
|
|
15
|
+
script.async = true;
|
|
16
|
+
script.onerror = () => {
|
|
17
|
+
loading = void 0;
|
|
18
|
+
reject(new Error("Google Maps could not be loaded"));
|
|
19
|
+
};
|
|
20
|
+
document.head.append(script);
|
|
21
|
+
});
|
|
22
|
+
return loading;
|
|
23
|
+
}
|
|
24
|
+
async function loadPlaces(apiKey) {
|
|
25
|
+
await loadGoogleMaps(apiKey);
|
|
26
|
+
const importLibrary = window.google?.maps?.importLibrary;
|
|
27
|
+
if (!importLibrary) throw new Error("Google Maps has no importLibrary");
|
|
28
|
+
return await importLibrary("places");
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
loadGoogleMaps,
|
|
32
|
+
loadPlaces
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=google-maps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-maps.js","sources":["../../../src/elements/shared/google-maps.ts"],"sourcesContent":["/**\n * The parts of the Google Maps JS API spmkt uses: the store map, and Places for address autocomplete (typed\n * here instead of depending on @types/google.maps).\n */\nexport interface LatLng {\n lat: number\n lng: number\n}\nexport interface GoogleMap {\n setCenter(position: LatLng): void\n setZoom(zoom: number): void\n fitBounds(bounds: unknown, padding?: number): void\n}\nexport interface InfoWindow {\n setContent(content: Node | string): void\n open(options: { map: GoogleMap; anchor: unknown }): void\n close(): void\n}\nexport interface Marker {\n addListener(event: 'click' | 'gmp-click', handler: () => void): unknown\n}\nexport interface GoogleMapsApi {\n Map: new (element: HTMLElement, options: Record<string, unknown>) => GoogleMap\n InfoWindow: new () => InfoWindow\n LatLngBounds: new () => { extend(position: LatLng): void }\n Marker: new (options: { map: GoogleMap; position: LatLng; title: string }) => Marker\n marker?: {\n AdvancedMarkerElement: new (options: { map: GoogleMap; position: LatLng; title: string }) => Marker\n }\n}\n\ndeclare global {\n interface Window {\n google?: { maps?: GoogleMapsApi & { importLibrary?: (name: string) => Promise<unknown> } }\n }\n}\n\nlet loading: Promise<GoogleMapsApi> | undefined\n\n/**\n * The Google Maps JS API, loaded once per page with the theme's key (an already loaded API is used as is).\n * The marker library is loaded too, for maps with a Map ID (advanced markers).\n */\nexport function loadGoogleMaps(apiKey: string): Promise<GoogleMapsApi> {\n if (window.google?.maps?.Map) {\n return Promise.resolve(window.google.maps)\n }\n loading ??= new Promise<GoogleMapsApi>((resolve, reject) => {\n const callback = `__spmktMaps${Date.now()}`\n ;(window as unknown as Record<string, unknown>)[callback] = () => {\n delete (window as unknown as Record<string, unknown>)[callback]\n resolve(window.google!.maps!)\n }\n const script = document.createElement('script')\n const query = new URLSearchParams({ key: apiKey, loading: 'async', libraries: 'marker', callback })\n script.src = `https://maps.googleapis.com/maps/api/js?${query}`\n script.async = true\n script.onerror = () => {\n loading = undefined\n reject(new Error('Google Maps could not be loaded'))\n }\n document.head.append(script)\n })\n return loading\n}\n\n/** Text with match offsets, as Places (New) gives it; only the text is used. */\nexport interface FormattableText {\n text: string\n}\nexport interface AddressComponent {\n longText: string | null\n shortText: string | null\n types: string[]\n}\nexport interface Place {\n addressComponents?: AddressComponent[]\n fetchFields(options: { fields: string[] }): Promise<unknown>\n}\nexport interface PlacePrediction {\n placeId: string\n text: FormattableText\n mainText: FormattableText | null\n secondaryText: FormattableText | null\n toPlace(): Place\n}\nexport interface AutocompleteRequest {\n input: string\n sessionToken?: unknown\n includedRegionCodes?: string[]\n language?: string\n}\nexport interface PlacesLibrary {\n AutocompleteSessionToken: new () => unknown\n AutocompleteSuggestion: {\n fetchAutocompleteSuggestions(\n request: AutocompleteRequest,\n ): Promise<{ suggestions: { placePrediction: PlacePrediction | null }[] }>\n }\n}\n\n/**\n * The Places library (Places API (New): AutocompleteSuggestion), on top of the Maps JS API loaded with the\n * same key. The key needs the Places API (New) enabled.\n */\nexport async function loadPlaces(apiKey: string): Promise<PlacesLibrary> {\n await loadGoogleMaps(apiKey)\n const importLibrary = window.google?.maps?.importLibrary\n if (!importLibrary) throw new Error('Google Maps has no importLibrary')\n return (await importLibrary('places')) as PlacesLibrary\n}\n"],"names":[],"mappings":"AAqCA,IAAI;AAMG,SAAS,eAAe,QAAwC;AACrE,MAAI,OAAO,QAAQ,MAAM,KAAK;AAC5B,WAAO,QAAQ,QAAQ,OAAO,OAAO,IAAI;AAAA,EAC3C;AACA,cAAY,IAAI,QAAuB,CAAC,SAAS,WAAW;AAC1D,UAAM,WAAW,cAAc,KAAK,IAAA,CAAK;AACvC,WAA8C,QAAQ,IAAI,MAAM;AAChE,aAAQ,OAA8C,QAAQ;AAC9D,cAAQ,OAAO,OAAQ,IAAK;AAAA,IAC9B;AACA,UAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,UAAM,QAAQ,IAAI,gBAAgB,EAAE,KAAK,QAAQ,SAAS,SAAS,WAAW,UAAU,SAAA,CAAU;AAClG,WAAO,MAAM,2CAA2C,KAAK;AAC7D,WAAO,QAAQ;AACf,WAAO,UAAU,MAAM;AACrB,gBAAU;AACV,aAAO,IAAI,MAAM,iCAAiC,CAAC;AAAA,IACrD;AACA,aAAS,KAAK,OAAO,MAAM;AAAA,EAC7B,CAAC;AACD,SAAO;AACT;AAyCA,eAAsB,WAAW,QAAwC;AACvE,QAAM,eAAe,MAAM;AAC3B,QAAM,gBAAgB,OAAO,QAAQ,MAAM;AAC3C,MAAI,CAAC,cAAe,OAAM,IAAI,MAAM,kCAAkC;AACtE,SAAQ,MAAM,cAAc,QAAQ;AACtC;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SpmktElement } from '../../lit/spmkt-element';
|
|
2
|
+
/**
|
|
3
|
+
* A form whose values go to the server as JSON, with the answer's errors shown in the theme's markup. Parts:
|
|
4
|
+
* - form (required): fields named as the endpoint takes them, each with a [data-error-for] slot. It has no
|
|
5
|
+
* `action`, so a submit before the element loads is held (the theme's early-submit guard) rather than sent
|
|
6
|
+
* - submit (optional): busy while the form is sent
|
|
7
|
+
* - error (optional): a message not tied to a field (render it hidden)
|
|
8
|
+
* Subclasses send the values in accept() and react to the result in accepted().
|
|
9
|
+
*/
|
|
10
|
+
export declare abstract class JsonForm<Result = unknown> extends SpmktElement {
|
|
11
|
+
protected busy: boolean;
|
|
12
|
+
/** Sends the values; throws the request's error when the server refuses them. */
|
|
13
|
+
protected abstract accept(values: Record<string, string>): Promise<Result>;
|
|
14
|
+
/** After the server took the values. */
|
|
15
|
+
protected accepted(_result: Result): void;
|
|
16
|
+
connectedCallback(): void;
|
|
17
|
+
protected form(): HTMLFormElement;
|
|
18
|
+
/**
|
|
19
|
+
* The form's values as strings, trimmed, except passwords: they go exactly as typed, as the plain sign-in and
|
|
20
|
+
* registration forms send them (a space can be part of a password).
|
|
21
|
+
*/
|
|
22
|
+
protected values(): Record<string, string>;
|
|
23
|
+
/** Fills empty (or all, with `overwrite`) fields of the form from `values`. */
|
|
24
|
+
protected fill(values: Record<string, unknown>, overwrite?: boolean): void;
|
|
25
|
+
/** Sends the form once at a time. Resolves true when the server took it. */
|
|
26
|
+
send(): Promise<boolean>;
|
|
27
|
+
protected showError(message: string | null): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { SpmktElement } from "../../lit/spmkt-element.js";
|
|
2
|
+
import { clearFieldErrors, showFieldErrors, errorMessage } from "../../lit/forms.js";
|
|
3
|
+
import { ValidationError } from "../../core/errors.js";
|
|
4
|
+
class JsonForm extends SpmktElement {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.busy = false;
|
|
8
|
+
}
|
|
9
|
+
/** After the server took the values. */
|
|
10
|
+
accepted(_result) {
|
|
11
|
+
}
|
|
12
|
+
connectedCallback() {
|
|
13
|
+
super.connectedCallback();
|
|
14
|
+
this.listen(this.form(), "submit", (event) => {
|
|
15
|
+
event.preventDefault();
|
|
16
|
+
void this.send();
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
form() {
|
|
20
|
+
return this.requirePart("form");
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The form's values as strings, trimmed, except passwords: they go exactly as typed, as the plain sign-in and
|
|
24
|
+
* registration forms send them (a space can be part of a password).
|
|
25
|
+
*/
|
|
26
|
+
values() {
|
|
27
|
+
const form = this.form();
|
|
28
|
+
const values = {};
|
|
29
|
+
for (const [name, value] of new FormData(form)) {
|
|
30
|
+
if (typeof value !== "string") continue;
|
|
31
|
+
const control = form.elements.namedItem(name);
|
|
32
|
+
values[name] = control instanceof HTMLInputElement && control.type === "password" ? value : value.trim();
|
|
33
|
+
}
|
|
34
|
+
return values;
|
|
35
|
+
}
|
|
36
|
+
/** Fills empty (or all, with `overwrite`) fields of the form from `values`. */
|
|
37
|
+
fill(values, overwrite = false) {
|
|
38
|
+
const form = this.form();
|
|
39
|
+
for (const [name, value] of Object.entries(values)) {
|
|
40
|
+
const control = form.elements.namedItem(name);
|
|
41
|
+
if ((control instanceof HTMLInputElement || control instanceof HTMLSelectElement) && value !== null && value !== void 0 && (overwrite || control.value === "" || control instanceof HTMLSelectElement)) {
|
|
42
|
+
control.value = String(value);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** Sends the form once at a time. Resolves true when the server took it. */
|
|
47
|
+
async send() {
|
|
48
|
+
if (this.busy) return false;
|
|
49
|
+
const form = this.form();
|
|
50
|
+
const submit = this.findPart("submit");
|
|
51
|
+
this.busy = true;
|
|
52
|
+
form.setAttribute("aria-busy", "true");
|
|
53
|
+
submit?.setAttribute("aria-busy", "true");
|
|
54
|
+
clearFieldErrors(form);
|
|
55
|
+
this.showError(null);
|
|
56
|
+
try {
|
|
57
|
+
this.accepted(await this.accept(this.values()));
|
|
58
|
+
return true;
|
|
59
|
+
} catch (error) {
|
|
60
|
+
if (error instanceof ValidationError) {
|
|
61
|
+
const unplaced = showFieldErrors(form, error.errors);
|
|
62
|
+
if (unplaced.length) this.showError(unplaced.join(" "));
|
|
63
|
+
form.querySelector('[aria-invalid="true"]')?.focus();
|
|
64
|
+
} else {
|
|
65
|
+
this.showError(errorMessage(error));
|
|
66
|
+
}
|
|
67
|
+
return false;
|
|
68
|
+
} finally {
|
|
69
|
+
this.busy = false;
|
|
70
|
+
form.removeAttribute("aria-busy");
|
|
71
|
+
submit?.removeAttribute("aria-busy");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
showError(message) {
|
|
75
|
+
const part = this.findPart("error");
|
|
76
|
+
if (part) {
|
|
77
|
+
part.textContent = message ?? "";
|
|
78
|
+
part.hidden = message === null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export {
|
|
83
|
+
JsonForm
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=json-form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-form.js","sources":["../../../src/elements/shared/json-form.ts"],"sourcesContent":["import { SpmktElement } from '../../lit/spmkt-element'\nimport { clearFieldErrors, errorMessage, showFieldErrors } from '../../lit/forms'\nimport { ValidationError } from '../../core/errors'\n\n/**\n * A form whose values go to the server as JSON, with the answer's errors shown in the theme's markup. Parts:\n * - form (required): fields named as the endpoint takes them, each with a [data-error-for] slot. It has no\n * `action`, so a submit before the element loads is held (the theme's early-submit guard) rather than sent\n * - submit (optional): busy while the form is sent\n * - error (optional): a message not tied to a field (render it hidden)\n * Subclasses send the values in accept() and react to the result in accepted().\n */\nexport abstract class JsonForm<Result = unknown> extends SpmktElement {\n protected busy = false\n\n /** Sends the values; throws the request's error when the server refuses them. */\n protected abstract accept(values: Record<string, string>): Promise<Result>\n\n /** After the server took the values. */\n protected accepted(_result: Result): void {}\n\n override connectedCallback(): void {\n super.connectedCallback()\n this.listen(this.form(), 'submit', (event) => {\n event.preventDefault()\n void this.send()\n })\n }\n\n protected form(): HTMLFormElement {\n return this.requirePart<HTMLFormElement>('form')\n }\n\n /**\n * The form's values as strings, trimmed, except passwords: they go exactly as typed, as the plain sign-in and\n * registration forms send them (a space can be part of a password).\n */\n protected values(): Record<string, string> {\n const form = this.form()\n const values: Record<string, string> = {}\n for (const [name, value] of new FormData(form)) {\n if (typeof value !== 'string') continue\n const control = form.elements.namedItem(name)\n values[name] = control instanceof HTMLInputElement && control.type === 'password' ? value : value.trim()\n }\n return values\n }\n\n /** Fills empty (or all, with `overwrite`) fields of the form from `values`. */\n protected fill(values: Record<string, unknown>, overwrite = false): void {\n const form = this.form()\n for (const [name, value] of Object.entries(values)) {\n const control = form.elements.namedItem(name)\n if (\n (control instanceof HTMLInputElement || control instanceof HTMLSelectElement) &&\n value !== null &&\n value !== undefined &&\n (overwrite || control.value === '' || control instanceof HTMLSelectElement)\n ) {\n control.value = String(value)\n }\n }\n }\n\n /** Sends the form once at a time. Resolves true when the server took it. */\n async send(): Promise<boolean> {\n if (this.busy) return false\n const form = this.form()\n const submit = this.findPart('submit')\n this.busy = true\n form.setAttribute('aria-busy', 'true')\n submit?.setAttribute('aria-busy', 'true')\n clearFieldErrors(form)\n this.showError(null)\n try {\n this.accepted(await this.accept(this.values()))\n return true\n } catch (error) {\n if (error instanceof ValidationError) {\n const unplaced = showFieldErrors(form, error.errors)\n if (unplaced.length) this.showError(unplaced.join(' '))\n form.querySelector<HTMLElement>('[aria-invalid=\"true\"]')?.focus()\n } else {\n this.showError(errorMessage(error))\n }\n return false\n } finally {\n this.busy = false\n form.removeAttribute('aria-busy')\n submit?.removeAttribute('aria-busy')\n }\n }\n\n protected 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":";;;AAYO,MAAe,iBAAmC,aAAa;AAAA,EAA/D,cAAA;AAAA,UAAA,GAAA,SAAA;AACL,SAAU,OAAO;AAAA,EAAA;AAAA;AAAA,EAMP,SAAS,SAAuB;AAAA,EAAC;AAAA,EAElC,oBAA0B;AACjC,UAAM,kBAAA;AACN,SAAK,OAAO,KAAK,KAAA,GAAQ,UAAU,CAAC,UAAU;AAC5C,YAAM,eAAA;AACN,WAAK,KAAK,KAAA;AAAA,IACZ,CAAC;AAAA,EACH;AAAA,EAEU,OAAwB;AAChC,WAAO,KAAK,YAA6B,MAAM;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMU,SAAiC;AACzC,UAAM,OAAO,KAAK,KAAA;AAClB,UAAM,SAAiC,CAAA;AACvC,eAAW,CAAC,MAAM,KAAK,KAAK,IAAI,SAAS,IAAI,GAAG;AAC9C,UAAI,OAAO,UAAU,SAAU;AAC/B,YAAM,UAAU,KAAK,SAAS,UAAU,IAAI;AAC5C,aAAO,IAAI,IAAI,mBAAmB,oBAAoB,QAAQ,SAAS,aAAa,QAAQ,MAAM,KAAA;AAAA,IACpG;AACA,WAAO;AAAA,EACT;AAAA;AAAA,EAGU,KAAK,QAAiC,YAAY,OAAa;AACvE,UAAM,OAAO,KAAK,KAAA;AAClB,eAAW,CAAC,MAAM,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AAClD,YAAM,UAAU,KAAK,SAAS,UAAU,IAAI;AAC5C,WACG,mBAAmB,oBAAoB,mBAAmB,sBAC3D,UAAU,QACV,UAAU,WACT,aAAa,QAAQ,UAAU,MAAM,mBAAmB,oBACzD;AACA,gBAAQ,QAAQ,OAAO,KAAK;AAAA,MAC9B;AAAA,IACF;AAAA,EACF;AAAA;AAAA,EAGA,MAAM,OAAyB;AAC7B,QAAI,KAAK,KAAM,QAAO;AACtB,UAAM,OAAO,KAAK,KAAA;AAClB,UAAM,SAAS,KAAK,SAAS,QAAQ;AACrC,SAAK,OAAO;AACZ,SAAK,aAAa,aAAa,MAAM;AACrC,YAAQ,aAAa,aAAa,MAAM;AACxC,qBAAiB,IAAI;AACrB,SAAK,UAAU,IAAI;AACnB,QAAI;AACF,WAAK,SAAS,MAAM,KAAK,OAAO,KAAK,OAAA,CAAQ,CAAC;AAC9C,aAAO;AAAA,IACT,SAAS,OAAO;AACd,UAAI,iBAAiB,iBAAiB;AACpC,cAAM,WAAW,gBAAgB,MAAM,MAAM,MAAM;AACnD,YAAI,SAAS,OAAQ,MAAK,UAAU,SAAS,KAAK,GAAG,CAAC;AACtD,aAAK,cAA2B,uBAAuB,GAAG,MAAA;AAAA,MAC5D,OAAO;AACL,aAAK,UAAU,aAAa,KAAK,CAAC;AAAA,MACpC;AACA,aAAO;AAAA,IACT,UAAA;AACE,WAAK,OAAO;AACZ,WAAK,gBAAgB,WAAW;AAChC,cAAQ,gBAAgB,WAAW;AAAA,IACrC;AAAA,EACF;AAAA,EAEU,UAAU,SAA8B;AAChD,UAAM,OAAO,KAAK,SAAS,OAAO;AAClC,QAAI,MAAM;AACR,WAAK,cAAc,WAAW;AAC9B,WAAK,SAAS,YAAY;AAAA,IAC5B;AAAA,EACF;AACF;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SpmktElement } from '../../lit/spmkt-element';
|
|
2
|
+
/**
|
|
3
|
+
* Parts every paged list in a theme section has (reviews, questions):
|
|
4
|
+
* - items (element-owned for appending): the list; leave it out when there is nothing to list
|
|
5
|
+
* - more (optional): the paging block, with load-more: a link to the next page's URL
|
|
6
|
+
* - sort (optional): a GET form whose changes re-render the section; apply is its submit button
|
|
7
|
+
*
|
|
8
|
+
* Both work as plain links and forms; inside a theme section, the next page is fetched as that section and
|
|
9
|
+
* its items appended, and a sort re-renders the section. The page's URL does not change.
|
|
10
|
+
*/
|
|
11
|
+
export interface PagedSectionParts {
|
|
12
|
+
items?: HTMLElement;
|
|
13
|
+
more?: HTMLElement;
|
|
14
|
+
'load-more'?: HTMLAnchorElement;
|
|
15
|
+
sort?: HTMLFormElement;
|
|
16
|
+
apply?: HTMLElement;
|
|
17
|
+
}
|
|
18
|
+
export declare abstract class PagedSectionElement extends SpmktElement {
|
|
19
|
+
private inFlight;
|
|
20
|
+
connectedCallback(): void;
|
|
21
|
+
/** Appends the items of the page at `url` and takes over its paging block. */
|
|
22
|
+
loadMore(url: string): Promise<void>;
|
|
23
|
+
/** Re-renders the section for `url` (a sort). */
|
|
24
|
+
show(url: string): Promise<void>;
|
|
25
|
+
private formUrl;
|
|
26
|
+
/** The section's HTML for `url`, or null when it could not be had (the visitor is told). */
|
|
27
|
+
private fetchSection;
|
|
28
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { SpmktElement } from "../../lit/spmkt-element.js";
|
|
2
|
+
import { sectionKey, swapSection, fetchFragments } from "../../lit/fragments.js";
|
|
3
|
+
import { isAbortError } from "../../core/errors.js";
|
|
4
|
+
import { t } from "../../core/i18n.js";
|
|
5
|
+
import { showToast } from "../toaster/toaster.js";
|
|
6
|
+
class PagedSectionElement extends SpmktElement {
|
|
7
|
+
connectedCallback() {
|
|
8
|
+
super.connectedCallback();
|
|
9
|
+
if (!sectionKey(this)) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const sort = this.findPart("sort");
|
|
13
|
+
if (sort) {
|
|
14
|
+
const apply = this.findPart("apply");
|
|
15
|
+
if (apply) apply.hidden = true;
|
|
16
|
+
this.listen(sort, "change", () => void this.show(this.formUrl(sort)));
|
|
17
|
+
this.listen(sort, "submit", (event) => {
|
|
18
|
+
event.preventDefault();
|
|
19
|
+
void this.show(this.formUrl(sort));
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
this.listen(this, "click", (event) => {
|
|
23
|
+
const link = event.target.closest('a[data-part="load-more"]');
|
|
24
|
+
if (link && this.contains(link) && !event.defaultPrevented && event.button === 0 && !event.metaKey && !event.ctrlKey) {
|
|
25
|
+
event.preventDefault();
|
|
26
|
+
void this.loadMore(link.href);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
this.onDisconnect(() => this.inFlight?.abort());
|
|
30
|
+
}
|
|
31
|
+
/** Appends the items of the page at `url` and takes over its paging block. */
|
|
32
|
+
async loadMore(url) {
|
|
33
|
+
const more = this.findPart("more");
|
|
34
|
+
more?.setAttribute("aria-busy", "true");
|
|
35
|
+
const html = await this.fetchSection(url);
|
|
36
|
+
more?.removeAttribute("aria-busy");
|
|
37
|
+
if (html === null) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const page = document.createElement("template");
|
|
41
|
+
page.innerHTML = html;
|
|
42
|
+
const items = page.content.querySelector('[data-part="items"]');
|
|
43
|
+
if (items) {
|
|
44
|
+
this.findPart("items")?.append(...Array.from(items.children));
|
|
45
|
+
}
|
|
46
|
+
const nextMore = page.content.querySelector('[data-part="more"]');
|
|
47
|
+
if (more) {
|
|
48
|
+
if (nextMore) more.replaceChildren(...Array.from(nextMore.childNodes));
|
|
49
|
+
else more.hidden = true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** Re-renders the section for `url` (a sort). */
|
|
53
|
+
async show(url) {
|
|
54
|
+
const key = sectionKey(this);
|
|
55
|
+
const items = this.findPart("items");
|
|
56
|
+
items?.setAttribute("aria-busy", "true");
|
|
57
|
+
const html = await this.fetchSection(url);
|
|
58
|
+
if (html === null) {
|
|
59
|
+
items?.removeAttribute("aria-busy");
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (key) swapSection(this, html);
|
|
63
|
+
}
|
|
64
|
+
formUrl(form) {
|
|
65
|
+
const url = new URL(form.action || location.href, location.href);
|
|
66
|
+
url.search = "";
|
|
67
|
+
url.hash = "";
|
|
68
|
+
for (const [name, value] of new FormData(form)) {
|
|
69
|
+
if (typeof value === "string" && value !== "") url.searchParams.append(name, value);
|
|
70
|
+
}
|
|
71
|
+
return url.toString();
|
|
72
|
+
}
|
|
73
|
+
/** The section's HTML for `url`, or null when it could not be had (the visitor is told). */
|
|
74
|
+
async fetchSection(url) {
|
|
75
|
+
const key = sectionKey(this);
|
|
76
|
+
if (!key) return null;
|
|
77
|
+
this.inFlight?.abort();
|
|
78
|
+
const controller = this.inFlight = new AbortController();
|
|
79
|
+
try {
|
|
80
|
+
const target = new URL(url, location.href);
|
|
81
|
+
target.hash = "";
|
|
82
|
+
const response = await fetchFragments(target, { sections: [key], signal: controller.signal });
|
|
83
|
+
return response.sections[key] ?? null;
|
|
84
|
+
} catch (error) {
|
|
85
|
+
if (!isAbortError(error)) showToast({ message: t("common.error"), tone: "error" });
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
export {
|
|
91
|
+
PagedSectionElement
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=paged-section.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paged-section.js","sources":["../../../src/elements/shared/paged-section.ts"],"sourcesContent":["import { SpmktElement } from '../../lit/spmkt-element'\nimport { fetchFragments, sectionKey, swapSection } from '../../lit/fragments'\nimport { isAbortError } from '../../core/errors'\nimport { t } from '../../core/i18n'\nimport { showToast } from '../toaster/toaster'\n\n/**\n * Parts every paged list in a theme section has (reviews, questions):\n * - items (element-owned for appending): the list; leave it out when there is nothing to list\n * - more (optional): the paging block, with load-more: a link to the next page's URL\n * - sort (optional): a GET form whose changes re-render the section; apply is its submit button\n *\n * Both work as plain links and forms; inside a theme section, the next page is fetched as that section and\n * its items appended, and a sort re-renders the section. The page's URL does not change.\n */\nexport interface PagedSectionParts {\n items?: HTMLElement\n more?: HTMLElement\n 'load-more'?: HTMLAnchorElement\n sort?: HTMLFormElement\n apply?: HTMLElement\n}\n\nexport abstract class PagedSectionElement extends SpmktElement {\n private inFlight: AbortController | undefined\n\n override connectedCallback(): void {\n super.connectedCallback()\n if (!sectionKey(this)) {\n return\n }\n const sort = this.findPart<HTMLFormElement>('sort')\n if (sort) {\n const apply = this.findPart('apply')\n if (apply) apply.hidden = true\n this.listen(sort, 'change', () => void this.show(this.formUrl(sort)))\n this.listen(sort, 'submit', (event) => {\n event.preventDefault()\n void this.show(this.formUrl(sort))\n })\n }\n this.listen(this, 'click', (event) => {\n const link = (event.target as Element).closest<HTMLAnchorElement>('a[data-part=\"load-more\"]')\n if (\n link &&\n this.contains(link) &&\n !event.defaultPrevented &&\n event.button === 0 &&\n !event.metaKey &&\n !event.ctrlKey\n ) {\n event.preventDefault()\n void this.loadMore(link.href)\n }\n })\n this.onDisconnect(() => this.inFlight?.abort())\n }\n\n /** Appends the items of the page at `url` and takes over its paging block. */\n async loadMore(url: string): Promise<void> {\n const more = this.findPart('more')\n more?.setAttribute('aria-busy', 'true')\n const html = await this.fetchSection(url)\n more?.removeAttribute('aria-busy')\n if (html === null) {\n return\n }\n const page = document.createElement('template')\n page.innerHTML = html\n const items = page.content.querySelector('[data-part=\"items\"]')\n if (items) {\n this.findPart('items')?.append(...Array.from(items.children))\n }\n const nextMore = page.content.querySelector('[data-part=\"more\"]')\n if (more) {\n // The paging block is the server's: the next one, or none on the last page\n if (nextMore) more.replaceChildren(...Array.from(nextMore.childNodes))\n else more.hidden = true\n }\n }\n\n /** Re-renders the section for `url` (a sort). */\n async show(url: string): Promise<void> {\n const key = sectionKey(this)\n const items = this.findPart('items')\n items?.setAttribute('aria-busy', 'true')\n const html = await this.fetchSection(url)\n if (html === null) {\n items?.removeAttribute('aria-busy')\n return\n }\n if (key) swapSection(this, html)\n }\n\n private formUrl(form: HTMLFormElement): string {\n const url = new URL(form.action || location.href, location.href)\n url.search = ''\n url.hash = ''\n for (const [name, value] of new FormData(form)) {\n if (typeof value === 'string' && value !== '') url.searchParams.append(name, value)\n }\n return url.toString()\n }\n\n /** The section's HTML for `url`, or null when it could not be had (the visitor is told). */\n private async fetchSection(url: string): Promise<string | null> {\n const key = sectionKey(this)\n if (!key) return null\n this.inFlight?.abort()\n const controller = (this.inFlight = new AbortController())\n try {\n const target = new URL(url, location.href)\n target.hash = ''\n const response = await fetchFragments(target, { sections: [key], signal: controller.signal })\n return response.sections[key] ?? null\n } catch (error) {\n if (!isAbortError(error)) showToast({ message: t('common.error'), tone: 'error' })\n return null\n }\n }\n}\n"],"names":[],"mappings":";;;;;AAuBO,MAAe,4BAA4B,aAAa;AAAA,EAGpD,oBAA0B;AACjC,UAAM,kBAAA;AACN,QAAI,CAAC,WAAW,IAAI,GAAG;AACrB;AAAA,IACF;AACA,UAAM,OAAO,KAAK,SAA0B,MAAM;AAClD,QAAI,MAAM;AACR,YAAM,QAAQ,KAAK,SAAS,OAAO;AACnC,UAAI,aAAa,SAAS;AAC1B,WAAK,OAAO,MAAM,UAAU,MAAM,KAAK,KAAK,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC;AACpE,WAAK,OAAO,MAAM,UAAU,CAAC,UAAU;AACrC,cAAM,eAAA;AACN,aAAK,KAAK,KAAK,KAAK,QAAQ,IAAI,CAAC;AAAA,MACnC,CAAC;AAAA,IACH;AACA,SAAK,OAAO,MAAM,SAAS,CAAC,UAAU;AACpC,YAAM,OAAQ,MAAM,OAAmB,QAA2B,0BAA0B;AAC5F,UACE,QACA,KAAK,SAAS,IAAI,KAClB,CAAC,MAAM,oBACP,MAAM,WAAW,KACjB,CAAC,MAAM,WACP,CAAC,MAAM,SACP;AACA,cAAM,eAAA;AACN,aAAK,KAAK,SAAS,KAAK,IAAI;AAAA,MAC9B;AAAA,IACF,CAAC;AACD,SAAK,aAAa,MAAM,KAAK,UAAU,OAAO;AAAA,EAChD;AAAA;AAAA,EAGA,MAAM,SAAS,KAA4B;AACzC,UAAM,OAAO,KAAK,SAAS,MAAM;AACjC,UAAM,aAAa,aAAa,MAAM;AACtC,UAAM,OAAO,MAAM,KAAK,aAAa,GAAG;AACxC,UAAM,gBAAgB,WAAW;AACjC,QAAI,SAAS,MAAM;AACjB;AAAA,IACF;AACA,UAAM,OAAO,SAAS,cAAc,UAAU;AAC9C,SAAK,YAAY;AACjB,UAAM,QAAQ,KAAK,QAAQ,cAAc,qBAAqB;AAC9D,QAAI,OAAO;AACT,WAAK,SAAS,OAAO,GAAG,OAAO,GAAG,MAAM,KAAK,MAAM,QAAQ,CAAC;AAAA,IAC9D;AACA,UAAM,WAAW,KAAK,QAAQ,cAAc,oBAAoB;AAChE,QAAI,MAAM;AAER,UAAI,eAAe,gBAAgB,GAAG,MAAM,KAAK,SAAS,UAAU,CAAC;AAAA,gBAC3D,SAAS;AAAA,IACrB;AAAA,EACF;AAAA;AAAA,EAGA,MAAM,KAAK,KAA4B;AACrC,UAAM,MAAM,WAAW,IAAI;AAC3B,UAAM,QAAQ,KAAK,SAAS,OAAO;AACnC,WAAO,aAAa,aAAa,MAAM;AACvC,UAAM,OAAO,MAAM,KAAK,aAAa,GAAG;AACxC,QAAI,SAAS,MAAM;AACjB,aAAO,gBAAgB,WAAW;AAClC;AAAA,IACF;AACA,QAAI,IAAK,aAAY,MAAM,IAAI;AAAA,EACjC;AAAA,EAEQ,QAAQ,MAA+B;AAC7C,UAAM,MAAM,IAAI,IAAI,KAAK,UAAU,SAAS,MAAM,SAAS,IAAI;AAC/D,QAAI,SAAS;AACb,QAAI,OAAO;AACX,eAAW,CAAC,MAAM,KAAK,KAAK,IAAI,SAAS,IAAI,GAAG;AAC9C,UAAI,OAAO,UAAU,YAAY,UAAU,GAAI,KAAI,aAAa,OAAO,MAAM,KAAK;AAAA,IACpF;AACA,WAAO,IAAI,SAAA;AAAA,EACb;AAAA;AAAA,EAGA,MAAc,aAAa,KAAqC;AAC9D,UAAM,MAAM,WAAW,IAAI;AAC3B,QAAI,CAAC,IAAK,QAAO;AACjB,SAAK,UAAU,MAAA;AACf,UAAM,aAAc,KAAK,WAAW,IAAI,gBAAA;AACxC,QAAI;AACF,YAAM,SAAS,IAAI,IAAI,KAAK,SAAS,IAAI;AACzC,aAAO,OAAO;AACd,YAAM,WAAW,MAAM,eAAe,QAAQ,EAAE,UAAU,CAAC,GAAG,GAAG,QAAQ,WAAW,OAAA,CAAQ;AAC5F,aAAO,SAAS,SAAS,GAAG,KAAK;AAAA,IACnC,SAAS,OAAO;AACd,UAAI,CAAC,aAAa,KAAK,EAAG,WAAU,EAAE,SAAS,EAAE,cAAc,GAAG,MAAM,QAAA,CAAS;AACjF,aAAO;AAAA,IACT;AAAA,EACF;AACF;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shop's phone mask (the page state's checkout.phoneMask), as spmkt 3's v-mask applied it: `#` is a digit,
|
|
3
|
+
* anything else is written as it is. The typed digits fill the #s in order; literals come in as the digits
|
|
4
|
+
* reach them, and a typed literal (a "+" or a space) is taken as that literal rather than dropped. Digits the
|
|
5
|
+
* mask starts with ("+381 ## ...") are not asked for twice when the visitor types them.
|
|
6
|
+
*/
|
|
7
|
+
export declare function maskPhone(value: string, mask: string): string;
|
|
8
|
+
/** Keeps `input` in the mask's shape as the visitor types. Returns the remover. */
|
|
9
|
+
export declare function applyPhoneMask(input: HTMLInputElement, mask: string): () => void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
function maskPhone(value, mask) {
|
|
2
|
+
if (value === "" || mask === "") return value;
|
|
3
|
+
let rest = value;
|
|
4
|
+
const lead = /^[^#]*/.exec(mask)[0];
|
|
5
|
+
const leadDigits = lead.replace(/\D/g, "");
|
|
6
|
+
if (leadDigits && rest.replace(/\D/g, "").startsWith(leadDigits)) {
|
|
7
|
+
let skip = leadDigits.length;
|
|
8
|
+
rest = rest.replace(/\d/g, (digit) => skip-- > 0 ? "" : digit);
|
|
9
|
+
}
|
|
10
|
+
let out = "";
|
|
11
|
+
let i = 0;
|
|
12
|
+
for (const char of mask) {
|
|
13
|
+
if (char === "#") {
|
|
14
|
+
while (i < rest.length && !/\d/.test(rest[i])) i++;
|
|
15
|
+
if (i >= rest.length) break;
|
|
16
|
+
out += rest[i++];
|
|
17
|
+
} else {
|
|
18
|
+
if (i >= rest.length && out.length >= lead.length) break;
|
|
19
|
+
out += char;
|
|
20
|
+
if (rest[i] === char) i++;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
25
|
+
function applyPhoneMask(input, mask) {
|
|
26
|
+
const onInput = () => {
|
|
27
|
+
const masked = maskPhone(input.value, mask);
|
|
28
|
+
if (masked !== input.value) input.value = masked;
|
|
29
|
+
};
|
|
30
|
+
input.addEventListener("input", onInput);
|
|
31
|
+
if (input.value) onInput();
|
|
32
|
+
return () => input.removeEventListener("input", onInput);
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
applyPhoneMask,
|
|
36
|
+
maskPhone
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=phone-mask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone-mask.js","sources":["../../../src/elements/shared/phone-mask.ts"],"sourcesContent":["/**\n * The shop's phone mask (the page state's checkout.phoneMask), as spmkt 3's v-mask applied it: `#` is a digit,\n * anything else is written as it is. The typed digits fill the #s in order; literals come in as the digits\n * reach them, and a typed literal (a \"+\" or a space) is taken as that literal rather than dropped. Digits the\n * mask starts with (\"+381 ## ...\") are not asked for twice when the visitor types them.\n */\nexport function maskPhone(value: string, mask: string): string {\n if (value === '' || mask === '') return value\n let rest = value\n // The mask's own leading digits, typed by the visitor too (pasting \"+381 64...\")\n const lead = /^[^#]*/.exec(mask)![0]\n const leadDigits = lead.replace(/\\D/g, '')\n if (leadDigits && rest.replace(/\\D/g, '').startsWith(leadDigits)) {\n let skip = leadDigits.length\n rest = rest.replace(/\\d/g, (digit) => (skip-- > 0 ? '' : digit))\n }\n let out = ''\n let i = 0\n for (const char of mask) {\n if (char === '#') {\n while (i < rest.length && !/\\d/.test(rest[i]!)) i++\n if (i >= rest.length) break\n out += rest[i++]\n } else {\n if (i >= rest.length && out.length >= lead.length) break\n out += char\n if (rest[i] === char) i++\n }\n }\n return out\n}\n\n/** Keeps `input` in the mask's shape as the visitor types. Returns the remover. */\nexport function applyPhoneMask(input: HTMLInputElement, mask: string): () => void {\n const onInput = (): void => {\n const masked = maskPhone(input.value, mask)\n if (masked !== input.value) input.value = masked\n }\n input.addEventListener('input', onInput)\n if (input.value) onInput()\n return () => input.removeEventListener('input', onInput)\n}\n"],"names":[],"mappings":"AAMO,SAAS,UAAU,OAAe,MAAsB;AAC7D,MAAI,UAAU,MAAM,SAAS,GAAI,QAAO;AACxC,MAAI,OAAO;AAEX,QAAM,OAAO,SAAS,KAAK,IAAI,EAAG,CAAC;AACnC,QAAM,aAAa,KAAK,QAAQ,OAAO,EAAE;AACzC,MAAI,cAAc,KAAK,QAAQ,OAAO,EAAE,EAAE,WAAW,UAAU,GAAG;AAChE,QAAI,OAAO,WAAW;AACtB,WAAO,KAAK,QAAQ,OAAO,CAAC,UAAW,SAAS,IAAI,KAAK,KAAM;AAAA,EACjE;AACA,MAAI,MAAM;AACV,MAAI,IAAI;AACR,aAAW,QAAQ,MAAM;AACvB,QAAI,SAAS,KAAK;AAChB,aAAO,IAAI,KAAK,UAAU,CAAC,KAAK,KAAK,KAAK,CAAC,CAAE,EAAG;AAChD,UAAI,KAAK,KAAK,OAAQ;AACtB,aAAO,KAAK,GAAG;AAAA,IACjB,OAAO;AACL,UAAI,KAAK,KAAK,UAAU,IAAI,UAAU,KAAK,OAAQ;AACnD,aAAO;AACP,UAAI,KAAK,CAAC,MAAM,KAAM;AAAA,IACxB;AAAA,EACF;AACA,SAAO;AACT;AAGO,SAAS,eAAe,OAAyB,MAA0B;AAChF,QAAM,UAAU,MAAY;AAC1B,UAAM,SAAS,UAAU,MAAM,OAAO,IAAI;AAC1C,QAAI,WAAW,MAAM,MAAO,OAAM,QAAQ;AAAA,EAC5C;AACA,QAAM,iBAAiB,SAAS,OAAO;AACvC,MAAI,MAAM,MAAO,SAAA;AACjB,SAAO,MAAM,MAAM,oBAAoB,SAAS,OAAO;AACzD;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SpmktElement } from '../../lit/spmkt-element';
|
|
2
|
+
/**
|
|
3
|
+
* spmkt:select-item for a click on a product link in a listing: the link sits in a card whose closest
|
|
4
|
+
* [data-item] holds the product as a GA4 item (JSON), and the list's name comes from the closest
|
|
5
|
+
* [data-item-list]. Clicks outside such cards, and cards with unreadable JSON, send nothing.
|
|
6
|
+
*/
|
|
7
|
+
export declare function emitSelectItem(host: SpmktElement, event: Event): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { dispatch } from "../../core/events.js";
|
|
2
|
+
function emitSelectItem(host, event) {
|
|
3
|
+
const link = event.target?.closest?.("a[href]");
|
|
4
|
+
const card = link?.closest("[data-item]");
|
|
5
|
+
if (!link || !card || !host.contains(card)) return;
|
|
6
|
+
let item;
|
|
7
|
+
try {
|
|
8
|
+
item = JSON.parse(card.dataset.item ?? "");
|
|
9
|
+
} catch {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (!item || typeof item !== "object" || !item.item_id) return;
|
|
13
|
+
const list = card.closest("[data-item-list]")?.dataset.itemList;
|
|
14
|
+
dispatch(host, "spmkt:select-item", { ...list ? { item_list_name: list } : {}, items: [item] });
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
emitSelectItem
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=select-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-item.js","sources":["../../../src/elements/shared/select-item.ts"],"sourcesContent":["import { dispatch, type Ga4Item } from '../../core/events'\nimport type { SpmktElement } from '../../lit/spmkt-element'\n\n/**\n * spmkt:select-item for a click on a product link in a listing: the link sits in a card whose closest\n * [data-item] holds the product as a GA4 item (JSON), and the list's name comes from the closest\n * [data-item-list]. Clicks outside such cards, and cards with unreadable JSON, send nothing.\n */\nexport function emitSelectItem(host: SpmktElement, event: Event): void {\n const link = (event.target as Element | null)?.closest?.('a[href]')\n const card = link?.closest<HTMLElement>('[data-item]')\n if (!link || !card || !host.contains(card)) return\n let item: Ga4Item\n try {\n item = JSON.parse(card.dataset.item ?? '') as Ga4Item\n } catch {\n return\n }\n if (!item || typeof item !== 'object' || !item.item_id) return\n const list = card.closest<HTMLElement>('[data-item-list]')?.dataset.itemList\n dispatch(host, 'spmkt:select-item', { ...(list ? { item_list_name: list } : {}), items: [item] })\n}\n"],"names":[],"mappings":";AAQO,SAAS,eAAe,MAAoB,OAAoB;AACrE,QAAM,OAAQ,MAAM,QAA2B,UAAU,SAAS;AAClE,QAAM,OAAO,MAAM,QAAqB,aAAa;AACrD,MAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,SAAS,IAAI,EAAG;AAC5C,MAAI;AACJ,MAAI;AACF,WAAO,KAAK,MAAM,KAAK,QAAQ,QAAQ,EAAE;AAAA,EAC3C,QAAQ;AACN;AAAA,EACF;AACA,MAAI,CAAC,QAAQ,OAAO,SAAS,YAAY,CAAC,KAAK,QAAS;AACxD,QAAM,OAAO,KAAK,QAAqB,kBAAkB,GAAG,QAAQ;AACpE,WAAS,MAAM,qBAAqB,EAAE,GAAI,OAAO,EAAE,gBAAgB,KAAA,IAAS,CAAA,GAAK,OAAO,CAAC,IAAI,GAAG;AAClG;"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { nothing, type TemplateResult } from 'lit';
|
|
2
|
+
import type { CartLine } from '../../core/types';
|
|
3
|
+
/**
|
|
4
|
+
* Templates the cart, the mini cart, the checkout summary and the order confirmation share: the totals list
|
|
5
|
+
* (`dl.cart-totals`, base's markup and data-test attributes), its tax row, and pieces of a line.
|
|
6
|
+
*/
|
|
7
|
+
/** What a totals list shows; a row whose value is undefined is left out. */
|
|
8
|
+
export interface Totals {
|
|
9
|
+
subtotal?: number;
|
|
10
|
+
discount?: number;
|
|
11
|
+
/** Named after "Popust" when given */
|
|
12
|
+
coupon?: string | null;
|
|
13
|
+
shipping: number;
|
|
14
|
+
taxAmount: number;
|
|
15
|
+
/** The tax rate, when known (the confirmation does not have it) */
|
|
16
|
+
taxPercent?: number;
|
|
17
|
+
total: number;
|
|
18
|
+
}
|
|
19
|
+
export interface TotalsOptions {
|
|
20
|
+
/**
|
|
21
|
+
* How shipping shows: 'charged' only when there is any (the cart); 'always' as an amount or "free"; 'by-choice'
|
|
22
|
+
* as "by the delivery chosen" until the summary priced a choice (the checkout, before one is chosen)
|
|
23
|
+
*/
|
|
24
|
+
shipping: 'charged' | 'always' | 'by-choice';
|
|
25
|
+
/** The list's data-test */
|
|
26
|
+
testId?: string;
|
|
27
|
+
/** The total's data-test */
|
|
28
|
+
totalTestId: string;
|
|
29
|
+
/** The shipping row's data-test */
|
|
30
|
+
shippingTestId?: string;
|
|
31
|
+
/** More classes on the list */
|
|
32
|
+
className?: string;
|
|
33
|
+
}
|
|
34
|
+
/** The totals list: subtotal, discount, shipping, tax and total. */
|
|
35
|
+
export declare function renderTotals(totals: Totals, options: TotalsOptions): TemplateResult;
|
|
36
|
+
/**
|
|
37
|
+
* The tax row: nothing without tax. The rate has the shop's decimal separator and no trailing zeros ("20%",
|
|
38
|
+
* "8,5%"); "included" is said when the shop's prices include tax (pricesIncludeTax in the page state).
|
|
39
|
+
*/
|
|
40
|
+
export declare function renderTaxRow(amount: number, percent?: number): TemplateResult | typeof nothing;
|
|
41
|
+
/**
|
|
42
|
+
* A translated sentence with one parameter in <strong>, e.g. "Kupon <strong>X</strong> je primenjen.";
|
|
43
|
+
* `testId` goes on the <strong>.
|
|
44
|
+
*/
|
|
45
|
+
export declare function withStrong(key: string, param: string, value: string, testId?: string): TemplateResult;
|
|
46
|
+
/** The name a line shows: its parent product's, without the variant (the variant is shown below it). */
|
|
47
|
+
export declare function lineName(line: CartLine): string;
|
|
48
|
+
/** The product page of a line. */
|
|
49
|
+
export declare function lineUrl(line: CartLine, shopUrl: (path: string) => string): string;
|
|
50
|
+
/** Whether a line has a real image (the platform's placeholder is left out). */
|
|
51
|
+
export declare function hasImage(line: CartLine): boolean;
|
|
52
|
+
/** Whether the cart can go to checkout: no line has a problem (e.g. more than the stock). */
|
|
53
|
+
export declare function cartBlocked(lines: readonly CartLine[]): boolean;
|