@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,82 @@
|
|
|
1
|
+
import { nothing, html } from "lit";
|
|
2
|
+
import { formatMoney, moneyFormat, numberFormat } from "../../core/money.js";
|
|
3
|
+
import { t } from "../../core/i18n.js";
|
|
4
|
+
import { storefront } from "../../core/state.js";
|
|
5
|
+
function renderTotals(totals, options) {
|
|
6
|
+
const discount = totals.discount ?? 0;
|
|
7
|
+
return html`<dl
|
|
8
|
+
class="cart-totals${options.className ? ` ${options.className}` : ""}"
|
|
9
|
+
data-test=${options.testId ?? nothing}
|
|
10
|
+
>
|
|
11
|
+
${totals.subtotal === void 0 ? nothing : html`<div>
|
|
12
|
+
<dt>${t("totals.subtotal")}</dt>
|
|
13
|
+
<dd>${formatMoney(totals.subtotal)}</dd>
|
|
14
|
+
</div>`}
|
|
15
|
+
${discount > 0 ? html`<div class="cart-totals__discount">
|
|
16
|
+
<dt>
|
|
17
|
+
${totals.coupon ? t("totals.discountCoupon", { code: totals.coupon }) : t("totals.discount")}
|
|
18
|
+
</dt>
|
|
19
|
+
<dd>−${formatMoney(discount)}</dd>
|
|
20
|
+
</div>` : nothing}
|
|
21
|
+
${renderShipping(totals.shipping, options)} ${renderTaxRow(totals.taxAmount, totals.taxPercent)}
|
|
22
|
+
<div class="cart-totals__total">
|
|
23
|
+
<dt>${t("totals.total")}</dt>
|
|
24
|
+
<dd data-test=${options.totalTestId}>${formatMoney(totals.total)}</dd>
|
|
25
|
+
</div>
|
|
26
|
+
</dl>`;
|
|
27
|
+
}
|
|
28
|
+
function renderShipping(shipping, options) {
|
|
29
|
+
if (options.shipping === "charged" && shipping <= 0) return nothing;
|
|
30
|
+
const value = shipping > 0 ? formatMoney(shipping) : options.shipping === "by-choice" ? html`<span class="text-muted">${t("totals.shippingByChoice")}</span>` : t("checkout.free");
|
|
31
|
+
return html`<div data-test=${options.shippingTestId ?? nothing}>
|
|
32
|
+
<dt>${t("totals.shipping")}</dt>
|
|
33
|
+
<dd>${value}</dd>
|
|
34
|
+
</div>`;
|
|
35
|
+
}
|
|
36
|
+
function renderTaxRow(amount, percent) {
|
|
37
|
+
if (!(amount > 0)) return nothing;
|
|
38
|
+
const details = [taxRate(percent), storefront().pricesIncludeTax ? t("totals.taxIncluded") : null].filter(
|
|
39
|
+
(detail) => detail !== null
|
|
40
|
+
);
|
|
41
|
+
const label = details.length ? `${t("totals.tax")} (${details.join(", ")})` : t("totals.tax");
|
|
42
|
+
return html`<div class="cart-totals__tax" data-test="tax-row">
|
|
43
|
+
<dt>${label}</dt>
|
|
44
|
+
<dd>${formatMoney(amount)}</dd>
|
|
45
|
+
</div>`;
|
|
46
|
+
}
|
|
47
|
+
function taxRate(percent) {
|
|
48
|
+
if (percent === void 0 || !(percent > 0)) return null;
|
|
49
|
+
const decimal = moneyFormat().decimal;
|
|
50
|
+
const number = numberFormat(percent, 2, decimal, "");
|
|
51
|
+
return `${number.replace(/0+$/, "").replace(new RegExp(`${escapeRegExp(decimal)}$`), "")}%`;
|
|
52
|
+
}
|
|
53
|
+
function escapeRegExp(text) {
|
|
54
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
55
|
+
}
|
|
56
|
+
function withStrong(key, param, value, testId) {
|
|
57
|
+
const marker = "\0";
|
|
58
|
+
const [before = "", after = ""] = t(key, { [param]: marker }).split(marker);
|
|
59
|
+
return html`${before}<strong data-test=${testId ?? nothing}>${value}</strong>${after}`;
|
|
60
|
+
}
|
|
61
|
+
function lineName(line) {
|
|
62
|
+
return line.parent_name || line.name;
|
|
63
|
+
}
|
|
64
|
+
function lineUrl(line, shopUrl) {
|
|
65
|
+
return shopUrl(`/${line.slug.replace(/^\/+/, "")}`);
|
|
66
|
+
}
|
|
67
|
+
function hasImage(line) {
|
|
68
|
+
return line.image_url !== "" && !line.image_url.includes("image_not_found");
|
|
69
|
+
}
|
|
70
|
+
function cartBlocked(lines) {
|
|
71
|
+
return lines.some((line) => line.error !== "");
|
|
72
|
+
}
|
|
73
|
+
export {
|
|
74
|
+
cartBlocked,
|
|
75
|
+
hasImage,
|
|
76
|
+
lineName,
|
|
77
|
+
lineUrl,
|
|
78
|
+
renderTaxRow,
|
|
79
|
+
renderTotals,
|
|
80
|
+
withStrong
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=totals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"totals.js","sources":["../../../src/elements/shared/totals.ts"],"sourcesContent":["import { html, nothing, type TemplateResult } from 'lit'\nimport { formatMoney, moneyFormat, numberFormat } from '../../core/money'\nimport { t } from '../../core/i18n'\nimport { storefront } from '../../core/state'\nimport type { CartLine } from '../../core/types'\n\n/**\n * Templates the cart, the mini cart, the checkout summary and the order confirmation share: the totals list\n * (`dl.cart-totals`, base's markup and data-test attributes), its tax row, and pieces of a line.\n */\n\n/** What a totals list shows; a row whose value is undefined is left out. */\nexport interface Totals {\n subtotal?: number\n discount?: number\n /** Named after \"Popust\" when given */\n coupon?: string | null\n shipping: number\n taxAmount: number\n /** The tax rate, when known (the confirmation does not have it) */\n taxPercent?: number\n total: number\n}\n\nexport interface TotalsOptions {\n /**\n * How shipping shows: 'charged' only when there is any (the cart); 'always' as an amount or \"free\"; 'by-choice'\n * as \"by the delivery chosen\" until the summary priced a choice (the checkout, before one is chosen)\n */\n shipping: 'charged' | 'always' | 'by-choice'\n /** The list's data-test */\n testId?: string\n /** The total's data-test */\n totalTestId: string\n /** The shipping row's data-test */\n shippingTestId?: string\n /** More classes on the list */\n className?: string\n}\n\n/** The totals list: subtotal, discount, shipping, tax and total. */\nexport function renderTotals(totals: Totals, options: TotalsOptions): TemplateResult {\n const discount = totals.discount ?? 0\n return html`<dl\n class=\"cart-totals${options.className ? ` ${options.className}` : ''}\"\n data-test=${options.testId ?? nothing}\n >\n ${\n totals.subtotal === undefined\n ? nothing\n : html`<div>\n <dt>${t('totals.subtotal')}</dt>\n <dd>${formatMoney(totals.subtotal)}</dd>\n </div>`\n }\n ${\n discount > 0\n ? html`<div class=\"cart-totals__discount\">\n <dt>\n ${totals.coupon ? t('totals.discountCoupon', { code: totals.coupon }) : t('totals.discount')}\n </dt>\n <dd>−${formatMoney(discount)}</dd>\n </div>`\n : nothing\n }\n ${renderShipping(totals.shipping, options)} ${renderTaxRow(totals.taxAmount, totals.taxPercent)}\n <div class=\"cart-totals__total\">\n <dt>${t('totals.total')}</dt>\n <dd data-test=${options.totalTestId}>${formatMoney(totals.total)}</dd>\n </div>\n </dl>`\n}\n\nfunction renderShipping(shipping: number, options: TotalsOptions): TemplateResult | typeof nothing {\n if (options.shipping === 'charged' && shipping <= 0) return nothing\n const value =\n shipping > 0\n ? formatMoney(shipping)\n : options.shipping === 'by-choice'\n ? html`<span class=\"text-muted\">${t('totals.shippingByChoice')}</span>`\n : t('checkout.free')\n return html`<div data-test=${options.shippingTestId ?? nothing}>\n <dt>${t('totals.shipping')}</dt>\n <dd>${value}</dd>\n </div>`\n}\n\n/**\n * The tax row: nothing without tax. The rate has the shop's decimal separator and no trailing zeros (\"20%\",\n * \"8,5%\"); \"included\" is said when the shop's prices include tax (pricesIncludeTax in the page state).\n */\nexport function renderTaxRow(amount: number, percent?: number): TemplateResult | typeof nothing {\n if (!(amount > 0)) return nothing\n const details = [taxRate(percent), storefront().pricesIncludeTax ? t('totals.taxIncluded') : null].filter(\n (detail) => detail !== null,\n )\n const label = details.length ? `${t('totals.tax')} (${details.join(', ')})` : t('totals.tax')\n return html`<div class=\"cart-totals__tax\" data-test=\"tax-row\">\n <dt>${label}</dt>\n <dd>${formatMoney(amount)}</dd>\n </div>`\n}\n\nfunction taxRate(percent: number | undefined): string | null {\n if (percent === undefined || !(percent > 0)) return null\n const decimal = moneyFormat().decimal\n const number = numberFormat(percent, 2, decimal, '')\n return `${number.replace(/0+$/, '').replace(new RegExp(`${escapeRegExp(decimal)}$`), '')}%`\n}\n\nfunction escapeRegExp(text: string): string {\n return text.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n\n/**\n * A translated sentence with one parameter in <strong>, e.g. \"Kupon <strong>X</strong> je primenjen.\";\n * `testId` goes on the <strong>.\n */\nexport function withStrong(key: string, param: string, value: string, testId?: string): TemplateResult {\n const marker = '\\u0000'\n const [before = '', after = ''] = t(key, { [param]: marker }).split(marker)\n return html`${before}<strong data-test=${testId ?? nothing}>${value}</strong>${after}`\n}\n\n/** The name a line shows: its parent product's, without the variant (the variant is shown below it). */\nexport function lineName(line: CartLine): string {\n return line.parent_name || line.name\n}\n\n/** The product page of a line. */\nexport function lineUrl(line: CartLine, shopUrl: (path: string) => string): string {\n return shopUrl(`/${line.slug.replace(/^\\/+/, '')}`)\n}\n\n/** Whether a line has a real image (the platform's placeholder is left out). */\nexport function hasImage(line: CartLine): boolean {\n return line.image_url !== '' && !line.image_url.includes('image_not_found')\n}\n\n/** Whether the cart can go to checkout: no line has a problem (e.g. more than the stock). */\nexport function cartBlocked(lines: readonly CartLine[]): boolean {\n return lines.some((line) => line.error !== '')\n}\n"],"names":[],"mappings":";;;;AAyCO,SAAS,aAAa,QAAgB,SAAwC;AACnF,QAAM,WAAW,OAAO,YAAY;AACpC,SAAO;AAAA,wBACe,QAAQ,YAAY,IAAI,QAAQ,SAAS,KAAK,EAAE;AAAA,gBACxD,QAAQ,UAAU,OAAO;AAAA;AAAA,MAGnC,OAAO,aAAa,SAChB,UACA;AAAA,kBACQ,EAAE,iBAAiB,CAAC;AAAA,kBACpB,YAAY,OAAO,QAAQ,CAAC;AAAA,iBAE1C;AAAA,MAEE,WAAW,IACP;AAAA;AAAA,gBAEM,OAAO,SAAS,EAAE,yBAAyB,EAAE,MAAM,OAAO,OAAA,CAAQ,IAAI,EAAE,iBAAiB,CAAC;AAAA;AAAA,yBAEjF,YAAY,QAAQ,CAAC;AAAA,oBAEpC,OACN;AAAA,MACE,eAAe,OAAO,UAAU,OAAO,CAAC,IAAI,aAAa,OAAO,WAAW,OAAO,UAA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AC,SAAS,IAAI,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,KAAK,GAAG,OAAA,CAAQ,EAAE,MAAM,MAAM;AAC1E,SAAO,OAAO,MAAM,qBAAqB,UAAU,OAAO,IAAI,KAAK,YAAY,KAAK;AACtF;AAGO,SAAS,SAAS,MAAwB;AAC/C,SAAO,KAAK,eAAe,KAAK;AAClC;AAGO,SAAS,QAAQ,MAAgB,SAA2C;AACjF,SAAO,QAAQ,IAAI,KAAK,KAAK,QAAQ,QAAQ,EAAE,CAAC,EAAE;AACpD;AAGO,SAAS,SAAS,MAAyB;AAChD,SAAO,KAAK,cAAc,MAAM,CAAC,KAAK,UAAU,SAAS,iBAAiB;AAC5E;AAGO,SAAS,YAAY,OAAqC;AAC/D,SAAO,MAAM,KAAK,CAAC,SAAS,KAAK,UAAU,EAAE;AAC/C;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SpmktElement } from '../../lit/spmkt-element';
|
|
2
|
+
import type { LocationAvailability } from '../../core/types';
|
|
3
|
+
/**
|
|
4
|
+
* Parts of <spmkt-store-availability product-id> (on the product page):
|
|
5
|
+
* - button (required): asks which other stores have the product (any of its variants)
|
|
6
|
+
* - result (required, element-owned): an empty container for the answer
|
|
7
|
+
*/
|
|
8
|
+
export interface StoreAvailabilityParts {
|
|
9
|
+
button: HTMLButtonElement;
|
|
10
|
+
result: HTMLElement;
|
|
11
|
+
}
|
|
12
|
+
/** The stores that have the product, asked for on demand. */
|
|
13
|
+
export declare class SpmktStoreAvailability extends SpmktElement {
|
|
14
|
+
static properties: {
|
|
15
|
+
productId: {
|
|
16
|
+
type: NumberConstructor;
|
|
17
|
+
attribute: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
productId: number;
|
|
21
|
+
private inFlight;
|
|
22
|
+
connectedCallback(): void;
|
|
23
|
+
load(): Promise<void>;
|
|
24
|
+
/** The answer; override to change the markup. */
|
|
25
|
+
protected renderAvailability(stores: LocationAvailability[]): unknown;
|
|
26
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { html, nothing } from "lit";
|
|
2
|
+
import { SpmktElement } from "../../lit/spmkt-element.js";
|
|
3
|
+
import { availabilityByLocation } from "../../core/api/location.js";
|
|
4
|
+
import { isAbortError } from "../../core/errors.js";
|
|
5
|
+
import { t } from "../../core/i18n.js";
|
|
6
|
+
import { showToast } from "../toaster/toaster.js";
|
|
7
|
+
class SpmktStoreAvailability extends SpmktElement {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.productId = 0;
|
|
11
|
+
}
|
|
12
|
+
static {
|
|
13
|
+
this.properties = { productId: { type: Number, attribute: "product-id" } };
|
|
14
|
+
}
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
super.connectedCallback();
|
|
17
|
+
const button = this.requirePart("button");
|
|
18
|
+
this.requirePart("result");
|
|
19
|
+
button.setAttribute("aria-expanded", "false");
|
|
20
|
+
this.listen(button, "click", () => void this.load());
|
|
21
|
+
this.onDisconnect(() => this.inFlight?.abort());
|
|
22
|
+
}
|
|
23
|
+
async load() {
|
|
24
|
+
const button = this.requirePart("button");
|
|
25
|
+
this.inFlight?.abort();
|
|
26
|
+
const controller = this.inFlight = new AbortController();
|
|
27
|
+
button.setAttribute("aria-busy", "true");
|
|
28
|
+
try {
|
|
29
|
+
const stores = await availabilityByLocation(this.productId, controller.signal);
|
|
30
|
+
this.renderPart("result", this.renderAvailability(stores));
|
|
31
|
+
button.setAttribute("aria-expanded", "true");
|
|
32
|
+
} catch (error) {
|
|
33
|
+
if (!isAbortError(error)) showToast({ message: t("common.error"), tone: "error" });
|
|
34
|
+
} finally {
|
|
35
|
+
button.removeAttribute("aria-busy");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** The answer; override to change the markup. */
|
|
39
|
+
renderAvailability(stores) {
|
|
40
|
+
if (stores.length === 0) {
|
|
41
|
+
return html`<p class="store-availability__none">${t("location.noneAvailable")}</p>`;
|
|
42
|
+
}
|
|
43
|
+
return html`<ul class="store-availability__list" role="list">
|
|
44
|
+
${stores.map((store) => {
|
|
45
|
+
const address = store.address;
|
|
46
|
+
const line = address ? [
|
|
47
|
+
address.address1?.trim(),
|
|
48
|
+
address.address2?.trim(),
|
|
49
|
+
[address.postcode, address.city].filter(Boolean).join(" ")
|
|
50
|
+
].filter(Boolean).join(", ") : "";
|
|
51
|
+
return html`<li class="store-availability__store">
|
|
52
|
+
<strong>${store.name}</strong>
|
|
53
|
+
${line ? html`<span>${line}</span>` : nothing}
|
|
54
|
+
${store.phone ? html`<span>${t("location.phone", { phone: store.phone })}</span>` : nothing}
|
|
55
|
+
${store.items_as_string ? html`<span class="store-availability__variants"
|
|
56
|
+
>${t("location.variants", { items: store.items_as_string })}</span
|
|
57
|
+
>` : nothing}
|
|
58
|
+
</li>`;
|
|
59
|
+
})}
|
|
60
|
+
</ul>`;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
SpmktStoreAvailability
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=store-availability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store-availability.js","sources":["../../../src/elements/store-availability/store-availability.ts"],"sourcesContent":["import { html, nothing } from 'lit'\nimport { SpmktElement } from '../../lit/spmkt-element'\nimport { availabilityByLocation } from '../../core/api/location'\nimport { isAbortError } from '../../core/errors'\nimport { t } from '../../core/i18n'\nimport { showToast } from '../toaster/toaster'\nimport type { LocationAvailability } from '../../core/types'\n\n/**\n * Parts of <spmkt-store-availability product-id> (on the product page):\n * - button (required): asks which other stores have the product (any of its variants)\n * - result (required, element-owned): an empty container for the answer\n */\nexport interface StoreAvailabilityParts {\n button: HTMLButtonElement\n result: HTMLElement\n}\n\n/** The stores that have the product, asked for on demand. */\nexport class SpmktStoreAvailability extends SpmktElement {\n static override properties = { productId: { type: Number, attribute: 'product-id' } }\n productId = 0\n\n private inFlight: AbortController | undefined\n\n override connectedCallback(): void {\n super.connectedCallback()\n const button = this.requirePart<HTMLButtonElement>('button')\n this.requirePart('result')\n button.setAttribute('aria-expanded', 'false')\n this.listen(button, 'click', () => void this.load())\n this.onDisconnect(() => this.inFlight?.abort())\n }\n\n async load(): Promise<void> {\n const button = this.requirePart<HTMLButtonElement>('button')\n this.inFlight?.abort()\n const controller = (this.inFlight = new AbortController())\n button.setAttribute('aria-busy', 'true')\n try {\n const stores = await availabilityByLocation(this.productId, controller.signal)\n this.renderPart('result', this.renderAvailability(stores))\n button.setAttribute('aria-expanded', 'true')\n } catch (error) {\n if (!isAbortError(error)) showToast({ message: t('common.error'), tone: 'error' })\n } finally {\n button.removeAttribute('aria-busy')\n }\n }\n\n /** The answer; override to change the markup. */\n protected renderAvailability(stores: LocationAvailability[]): unknown {\n if (stores.length === 0) {\n return html`<p class=\"store-availability__none\">${t('location.noneAvailable')}</p>`\n }\n return html`<ul class=\"store-availability__list\" role=\"list\">\n ${stores.map((store) => {\n const address = store.address\n const line = address\n ? [\n address.address1?.trim(),\n address.address2?.trim(),\n [address.postcode, address.city].filter(Boolean).join(' '),\n ]\n .filter(Boolean)\n .join(', ')\n : ''\n return html`<li class=\"store-availability__store\">\n <strong>${store.name}</strong>\n ${line ? html`<span>${line}</span>` : nothing}\n ${store.phone ? html`<span>${t('location.phone', { phone: store.phone })}</span>` : nothing}\n ${\n store.items_as_string\n ? html`<span class=\"store-availability__variants\"\n >${t('location.variants', { items: store.items_as_string })}</span\n >`\n : nothing\n }\n </li>`\n })}\n </ul>`\n }\n}\n"],"names":[],"mappings":";;;;;;AAmBO,MAAM,+BAA+B,aAAa;AAAA,EAAlD,cAAA;AAAA,UAAA,GAAA,SAAA;AAEL,SAAA,YAAY;AAAA,EAAA;AAAA,EADZ,OAAA;AAAA,SAAgB,aAAa,EAAE,WAAW,E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YAClB,OAAO,aAAa,IAAI,YAAY,OAAO;AAAA,YAC3C,MAAM,QAAQ,aAAa,EAAE,kBAAkB,EAAE,OAAO,MAAM,MAAA,CAAO,CAAC,YAAY,OAAO;AAAA,YAEzF,MAAM,kBACF;AAAA,qBACK,EAAE,qBAAqB,EAAE,OAAO,MAAM,gBAAA,CAAiB,CAAC;AAAA,qBAE7D,OACN;AAAA;AAAA,IAEJ,CAAC,CAAC;AAAA;AAAA,EAEN;AACF;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { SpmktElement } from '../../lit/spmkt-element';
|
|
2
|
+
import { type GoogleMap } from '../shared/google-maps';
|
|
3
|
+
/**
|
|
4
|
+
* Parts of <spmkt-store-map api-key map-id zoom> (the stores page, or a single store):
|
|
5
|
+
* - map (required): the container Google draws the map into (element-owned once the map loads)
|
|
6
|
+
* - locations (required): <script type="application/json"> with [{ id, name, lat, lng }]
|
|
7
|
+
* - info (optional, one per store): <template data-location-id> whose content the store's info window shows
|
|
8
|
+
* - location (optional, any number): links to the stores (data-location-id); with the map they show the store on it
|
|
9
|
+
* - item, filter, empty (optional): list items (data-search holds what they match), a search field narrowing
|
|
10
|
+
* them, and a message for no match (render it hidden)
|
|
11
|
+
*
|
|
12
|
+
* The API loads only when the map comes into view. `map-id` (a Google Cloud Map ID) gives advanced markers.
|
|
13
|
+
*/
|
|
14
|
+
export interface StoreMapParts {
|
|
15
|
+
map: HTMLElement;
|
|
16
|
+
locations: HTMLScriptElement;
|
|
17
|
+
info?: HTMLTemplateElement[];
|
|
18
|
+
location?: HTMLAnchorElement[];
|
|
19
|
+
item?: HTMLElement[];
|
|
20
|
+
filter?: HTMLInputElement;
|
|
21
|
+
empty?: HTMLElement;
|
|
22
|
+
}
|
|
23
|
+
export interface StoreLocation {
|
|
24
|
+
id: number;
|
|
25
|
+
name: string;
|
|
26
|
+
lat: number;
|
|
27
|
+
lng: number;
|
|
28
|
+
}
|
|
29
|
+
/** Stores on a Google map, with a list that filters and points into it. */
|
|
30
|
+
export declare class SpmktStoreMap extends SpmktElement {
|
|
31
|
+
static properties: {
|
|
32
|
+
apiKey: {
|
|
33
|
+
type: StringConstructor;
|
|
34
|
+
attribute: string;
|
|
35
|
+
};
|
|
36
|
+
mapId: {
|
|
37
|
+
type: StringConstructor;
|
|
38
|
+
attribute: string;
|
|
39
|
+
};
|
|
40
|
+
zoom: {
|
|
41
|
+
type: NumberConstructor;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
apiKey: string;
|
|
45
|
+
mapId: string;
|
|
46
|
+
/** Zoom for one store, or when a store is picked from the list */
|
|
47
|
+
zoom: number;
|
|
48
|
+
map: GoogleMap | null;
|
|
49
|
+
private markers;
|
|
50
|
+
private infoWindow;
|
|
51
|
+
connectedCallback(): void;
|
|
52
|
+
get locations(): StoreLocation[];
|
|
53
|
+
/** Centres the map on a store and opens its info window. */
|
|
54
|
+
show(id: number): void;
|
|
55
|
+
/** Narrows the list to items whose data-search contains the query. */
|
|
56
|
+
filter(query: string): void;
|
|
57
|
+
private draw;
|
|
58
|
+
private openInfo;
|
|
59
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { SpmktElement } from "../../lit/spmkt-element.js";
|
|
2
|
+
import { t } from "../../core/i18n.js";
|
|
3
|
+
import { loadGoogleMaps } from "../shared/google-maps.js";
|
|
4
|
+
class SpmktStoreMap extends SpmktElement {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.apiKey = "";
|
|
8
|
+
this.mapId = "";
|
|
9
|
+
this.zoom = 14;
|
|
10
|
+
this.map = null;
|
|
11
|
+
this.markers = /* @__PURE__ */ new Map();
|
|
12
|
+
this.infoWindow = null;
|
|
13
|
+
}
|
|
14
|
+
static {
|
|
15
|
+
this.properties = {
|
|
16
|
+
apiKey: { type: String, attribute: "api-key" },
|
|
17
|
+
mapId: { type: String, attribute: "map-id" },
|
|
18
|
+
zoom: { type: Number }
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
connectedCallback() {
|
|
22
|
+
super.connectedCallback();
|
|
23
|
+
const container = this.requirePart("map");
|
|
24
|
+
const filter = this.findPart("filter");
|
|
25
|
+
if (filter) this.listen(filter, "input", () => this.filter(filter.value));
|
|
26
|
+
this.listen(this, "click", (event) => {
|
|
27
|
+
const link = event.target.closest('a[data-part="location"]');
|
|
28
|
+
if (link && this.map && !event.metaKey && !event.ctrlKey && event.button === 0) {
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
this.show(Number(link.dataset.locationId));
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
if (this.map) return;
|
|
34
|
+
const observer = new IntersectionObserver((entries) => {
|
|
35
|
+
if (entries.some((entry) => entry.isIntersecting)) {
|
|
36
|
+
observer.disconnect();
|
|
37
|
+
void this.draw();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
observer.observe(container);
|
|
41
|
+
this.onDisconnect(() => observer.disconnect());
|
|
42
|
+
}
|
|
43
|
+
get locations() {
|
|
44
|
+
try {
|
|
45
|
+
const parsed = JSON.parse(this.requirePart("locations").textContent || "[]");
|
|
46
|
+
return Array.isArray(parsed) ? parsed.filter((l) => Number.isFinite(l?.lat) && Number.isFinite(l?.lng)) : [];
|
|
47
|
+
} catch {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** Centres the map on a store and opens its info window. */
|
|
52
|
+
show(id) {
|
|
53
|
+
const location = this.locations.find((l) => l.id === id);
|
|
54
|
+
if (!this.map || !location) return;
|
|
55
|
+
this.map.setCenter({ lat: location.lat, lng: location.lng });
|
|
56
|
+
this.map.setZoom(this.zoom);
|
|
57
|
+
this.openInfo(location);
|
|
58
|
+
}
|
|
59
|
+
/** Narrows the list to items whose data-search contains the query. */
|
|
60
|
+
filter(query) {
|
|
61
|
+
const q = query.trim().toLocaleLowerCase();
|
|
62
|
+
let shown = 0;
|
|
63
|
+
for (const item of this.findParts("item")) {
|
|
64
|
+
item.hidden = q !== "" && !(item.dataset.search ?? item.textContent ?? "").toLocaleLowerCase().includes(q);
|
|
65
|
+
if (!item.hidden) shown++;
|
|
66
|
+
}
|
|
67
|
+
const empty = this.findPart("empty");
|
|
68
|
+
if (empty) empty.hidden = shown > 0;
|
|
69
|
+
}
|
|
70
|
+
async draw() {
|
|
71
|
+
const container = this.requirePart("map");
|
|
72
|
+
const locations = this.locations;
|
|
73
|
+
if (!this.apiKey || locations.length === 0) return;
|
|
74
|
+
let maps;
|
|
75
|
+
try {
|
|
76
|
+
maps = await loadGoogleMaps(this.apiKey);
|
|
77
|
+
} catch {
|
|
78
|
+
container.textContent = t("location.mapFailed");
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (!this.isConnected) return;
|
|
82
|
+
const first = locations[0];
|
|
83
|
+
const map = new maps.Map(container, {
|
|
84
|
+
center: { lat: first.lat, lng: first.lng },
|
|
85
|
+
zoom: this.zoom,
|
|
86
|
+
...this.mapId ? { mapId: this.mapId } : {},
|
|
87
|
+
streetViewControl: false,
|
|
88
|
+
mapTypeControl: false
|
|
89
|
+
});
|
|
90
|
+
this.map = map;
|
|
91
|
+
this.infoWindow = new maps.InfoWindow();
|
|
92
|
+
const Advanced = this.mapId ? maps.marker?.AdvancedMarkerElement : void 0;
|
|
93
|
+
for (const location of locations) {
|
|
94
|
+
const options = { map, position: { lat: location.lat, lng: location.lng }, title: location.name };
|
|
95
|
+
const marker = Advanced ? new Advanced(options) : new maps.Marker(options);
|
|
96
|
+
marker.addListener(Advanced ? "gmp-click" : "click", () => this.openInfo(location));
|
|
97
|
+
this.markers.set(location.id, marker);
|
|
98
|
+
}
|
|
99
|
+
if (locations.length > 1) {
|
|
100
|
+
const bounds = new maps.LatLngBounds();
|
|
101
|
+
locations.forEach((l) => bounds.extend({ lat: l.lat, lng: l.lng }));
|
|
102
|
+
map.fitBounds(bounds, 40);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
openInfo(location) {
|
|
106
|
+
const marker = this.markers.get(location.id);
|
|
107
|
+
const template = this.findParts("info").find(
|
|
108
|
+
(t2) => Number(t2.dataset.locationId) === location.id
|
|
109
|
+
);
|
|
110
|
+
if (!this.map || !this.infoWindow || !marker || !template) return;
|
|
111
|
+
this.infoWindow.setContent(template.content.cloneNode(true));
|
|
112
|
+
this.infoWindow.open({ map: this.map, anchor: marker });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
export {
|
|
116
|
+
SpmktStoreMap
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=store-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store-map.js","sources":["../../../src/elements/store-map/store-map.ts"],"sourcesContent":["import { SpmktElement } from '../../lit/spmkt-element'\nimport { t } from '../../core/i18n'\nimport {\n loadGoogleMaps,\n type GoogleMap,\n type GoogleMapsApi,\n type InfoWindow,\n type Marker,\n} from '../shared/google-maps'\n\n/**\n * Parts of <spmkt-store-map api-key map-id zoom> (the stores page, or a single store):\n * - map (required): the container Google draws the map into (element-owned once the map loads)\n * - locations (required): <script type=\"application/json\"> with [{ id, name, lat, lng }]\n * - info (optional, one per store): <template data-location-id> whose content the store's info window shows\n * - location (optional, any number): links to the stores (data-location-id); with the map they show the store on it\n * - item, filter, empty (optional): list items (data-search holds what they match), a search field narrowing\n * them, and a message for no match (render it hidden)\n *\n * The API loads only when the map comes into view. `map-id` (a Google Cloud Map ID) gives advanced markers.\n */\nexport interface StoreMapParts {\n map: HTMLElement\n locations: HTMLScriptElement\n info?: HTMLTemplateElement[]\n location?: HTMLAnchorElement[]\n item?: HTMLElement[]\n filter?: HTMLInputElement\n empty?: HTMLElement\n}\n\nexport interface StoreLocation {\n id: number\n name: string\n lat: number\n lng: number\n}\n\n/** Stores on a Google map, with a list that filters and points into it. */\nexport class SpmktStoreMap extends SpmktElement {\n static override properties = {\n apiKey: { type: String, attribute: 'api-key' },\n mapId: { type: String, attribute: 'map-id' },\n zoom: { type: Number },\n }\n apiKey = ''\n mapId = ''\n /** Zoom for one store, or when a store is picked from the list */\n zoom = 14\n\n map: GoogleMap | null = null\n private markers = new Map<number, Marker>()\n private infoWindow: InfoWindow | null = null\n\n override connectedCallback(): void {\n super.connectedCallback()\n const container = this.requirePart('map')\n const filter = this.findPart<HTMLInputElement>('filter')\n if (filter) this.listen(filter, 'input', () => this.filter(filter.value))\n this.listen(this, 'click', (event) => {\n const link = (event.target as Element).closest<HTMLAnchorElement>('a[data-part=\"location\"]')\n if (link && this.map && !event.metaKey && !event.ctrlKey && event.button === 0) {\n event.preventDefault()\n this.show(Number(link.dataset.locationId))\n }\n })\n if (this.map) return\n const observer = new IntersectionObserver((entries) => {\n if (entries.some((entry) => entry.isIntersecting)) {\n observer.disconnect()\n void this.draw()\n }\n })\n observer.observe(container)\n this.onDisconnect(() => observer.disconnect())\n }\n\n get locations(): StoreLocation[] {\n try {\n const parsed: unknown = JSON.parse(this.requirePart('locations').textContent || '[]')\n return Array.isArray(parsed)\n ? parsed.filter((l): l is StoreLocation => Number.isFinite(l?.lat) && Number.isFinite(l?.lng))\n : []\n } catch {\n return []\n }\n }\n\n /** Centres the map on a store and opens its info window. */\n show(id: number): void {\n const location = this.locations.find((l) => l.id === id)\n if (!this.map || !location) return\n this.map.setCenter({ lat: location.lat, lng: location.lng })\n this.map.setZoom(this.zoom)\n this.openInfo(location)\n }\n\n /** Narrows the list to items whose data-search contains the query. */\n filter(query: string): void {\n const q = query.trim().toLocaleLowerCase()\n let shown = 0\n for (const item of this.findParts('item')) {\n item.hidden =\n q !== '' && !(item.dataset.search ?? item.textContent ?? '').toLocaleLowerCase().includes(q)\n if (!item.hidden) shown++\n }\n const empty = this.findPart('empty')\n if (empty) empty.hidden = shown > 0\n }\n\n private async draw(): Promise<void> {\n const container = this.requirePart('map')\n const locations = this.locations\n if (!this.apiKey || locations.length === 0) return\n let maps: GoogleMapsApi\n try {\n maps = await loadGoogleMaps(this.apiKey)\n } catch {\n container.textContent = t('location.mapFailed')\n return\n }\n if (!this.isConnected) return\n const first = locations[0]!\n const map = new maps.Map(container, {\n center: { lat: first.lat, lng: first.lng },\n zoom: this.zoom,\n ...(this.mapId ? { mapId: this.mapId } : {}),\n streetViewControl: false,\n mapTypeControl: false,\n })\n this.map = map\n this.infoWindow = new maps.InfoWindow()\n const Advanced = this.mapId ? maps.marker?.AdvancedMarkerElement : undefined\n for (const location of locations) {\n const options = { map, position: { lat: location.lat, lng: location.lng }, title: location.name }\n const marker = Advanced ? new Advanced(options) : new maps.Marker(options)\n marker.addListener(Advanced ? 'gmp-click' : 'click', () => this.openInfo(location))\n this.markers.set(location.id, marker)\n }\n if (locations.length > 1) {\n const bounds = new maps.LatLngBounds()\n locations.forEach((l) => bounds.extend({ lat: l.lat, lng: l.lng }))\n map.fitBounds(bounds, 40)\n }\n }\n\n private openInfo(location: StoreLocation): void {\n const marker = this.markers.get(location.id)\n const template = this.findParts<HTMLTemplateElement>('info').find(\n (t) => Number(t.dataset.locationId) === location.id,\n )\n if (!this.map || !this.infoWindow || !marker || !template) return\n this.infoWindow.setContent(template.content.cloneNode(true))\n this.infoWindow.open({ map: this.map, anchor: marker })\n }\n}\n"],"names":["t"],"mappings":";;;AAuCO,MAAM,sBAAsB,aAAa;AAAA,EAAzC,cAAA;AAAA,UAAA,GAAA,SAAA;AAML,SAAA,SAAS;AACT,SAAA,QAAQ;AAER,SAAA,OAAO;AAEP,SAAA,MAAwB;AACxB,SAAQ,8BAAc,IAAA;AACtB,SAAQ,aAAgC;AAAA,EAAA;AAAA,EAZxC,OAAA;AAAA,SAAgB,aAAa;AAAA,MAC3B,QAAQ,EAAE,MAAM,QAAQ,WAAW,UAAA;AAAA,MACnC,OAAO,EAAE,MAAM,QAAQ,WAAW,SAAA;AAAA,MAClC,MAAM,EAAE,MAAM,OAAA;AAAA,IAAO;AA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,KAAK,SAAS,IAAA,GAAO,OAAO,SAAS,KAAA;AAC3F,YAAM,SAAS,WAAW,IAAI,SAAS,OAAO,IAAI,IAAI,KAAK,OAAO,OAAO;AACzE,aAAO,YAAY,WAAW,cAAc,SAAS,MAAM,KAAK,SAAS,QAAQ,CAAC;AAClF,WAAK,QAAQ,IAAI,SAAS,IAAI,MAAM;AAAA,IACtC;AACA,QAAI,UAAU,SAAS,GAAG;AACxB,YAAM,SAAS,IAAI,KAAK,aAAA;AACxB,gBAAU,QAAQ,CAAC,MAAM,OAAO,OAAO,EAAE,KAAK,EAAE,KAAK,KAAK,EAAE,IAAA,CAAK,CAAC;AAClE,UAAI,UAAU,QAAQ,EAAE;AAAA,IAC1B;AAAA,EACF;AAAA,EAEQ,SAAS,UAA+B;AAC9C,UAAM,SAAS,KAAK,QAAQ,IAAI,SAAS,EAAE;AAC3C,UAAM,WAAW,KAAK,UAA+B,MAAM,EAAE;AAAA,MAC3D,CAACA,OAAM,OAAOA,GAAE,QAAQ,UAAU,MAAM,SAAS;AAAA,IAAA;AAEnD,QAAI,CAAC,KAAK,OAAO,CAAC,KAAK,cAAc,CAAC,UAAU,CAAC,SAAU;AAC3D,SAAK,WAAW,WAAW,SAAS,QAAQ,UAAU,IAAI,CAAC;AAC3D,SAAK,WAAW,KAAK,EAAE,KAAK,KAAK,KAAK,QAAQ,QAAQ;AAAA,EACxD;AACF;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SpmktElement } from '../../lit/spmkt-element';
|
|
2
|
+
/**
|
|
3
|
+
* Parts of <spmkt-tabs> (Blade renders the ARIA roles and ids):
|
|
4
|
+
* - tab (required, several): role="tab" buttons with aria-controls="<panel id>", inside a role="tablist"
|
|
5
|
+
* - panel (required, several): role="tabpanel" elements with ids
|
|
6
|
+
* The tab with aria-selected="true" (or the one whose panel id is the URL hash) starts selected.
|
|
7
|
+
*/
|
|
8
|
+
export interface TabsParts {
|
|
9
|
+
tab: HTMLElement[];
|
|
10
|
+
panel: HTMLElement[];
|
|
11
|
+
}
|
|
12
|
+
/** ARIA tabs with automatic activation, roving tabindex, arrow/Home/End keys and #panel-id links. */
|
|
13
|
+
export declare class SpmktTabs extends SpmktElement {
|
|
14
|
+
connectedCallback(): void;
|
|
15
|
+
/** The id of the selected panel. */
|
|
16
|
+
get selected(): string;
|
|
17
|
+
/** Selects the tab of panel `id`; `updateHash` puts #id in the URL without scrolling. */
|
|
18
|
+
select(id: string, updateHash?: boolean): void;
|
|
19
|
+
private selectFromHash;
|
|
20
|
+
private onKey;
|
|
21
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { SpmktElement } from "../../lit/spmkt-element.js";
|
|
2
|
+
class SpmktTabs extends SpmktElement {
|
|
3
|
+
connectedCallback() {
|
|
4
|
+
super.connectedCallback();
|
|
5
|
+
const tabs = this.findParts("tab");
|
|
6
|
+
tabs.forEach((tab) => {
|
|
7
|
+
this.listen(tab, "click", () => this.select(tab.getAttribute("aria-controls") ?? "", true));
|
|
8
|
+
this.listen(tab, "keydown", (event) => this.onKey(event, tab));
|
|
9
|
+
});
|
|
10
|
+
this.listen(window, "hashchange", () => this.selectFromHash());
|
|
11
|
+
if (!this.selectFromHash()) {
|
|
12
|
+
const preselected = tabs.find((tab) => tab.getAttribute("aria-selected") === "true") ?? tabs[0];
|
|
13
|
+
this.select(preselected?.getAttribute("aria-controls") ?? "", false);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** The id of the selected panel. */
|
|
17
|
+
get selected() {
|
|
18
|
+
return this.findParts("tab").find((tab) => tab.getAttribute("aria-selected") === "true")?.getAttribute("aria-controls") ?? "";
|
|
19
|
+
}
|
|
20
|
+
/** Selects the tab of panel `id`; `updateHash` puts #id in the URL without scrolling. */
|
|
21
|
+
select(id, updateHash = false) {
|
|
22
|
+
const panels = this.findParts("panel");
|
|
23
|
+
if (!panels.some((panel) => panel.id === id)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
for (const tab of this.findParts("tab")) {
|
|
27
|
+
const on = tab.getAttribute("aria-controls") === id;
|
|
28
|
+
tab.setAttribute("aria-selected", String(on));
|
|
29
|
+
tab.tabIndex = on ? 0 : -1;
|
|
30
|
+
}
|
|
31
|
+
panels.forEach((panel) => panel.hidden = panel.id !== id);
|
|
32
|
+
if (updateHash && location.hash !== `#${id}`) {
|
|
33
|
+
history.replaceState(history.state, "", `#${id}`);
|
|
34
|
+
}
|
|
35
|
+
this.emit("spmkt:tab-change", { panel: id });
|
|
36
|
+
}
|
|
37
|
+
selectFromHash() {
|
|
38
|
+
let id = location.hash.slice(1);
|
|
39
|
+
try {
|
|
40
|
+
id = decodeURIComponent(id);
|
|
41
|
+
} catch {
|
|
42
|
+
}
|
|
43
|
+
if (id && this.findParts("panel").some((panel) => panel.id === id)) {
|
|
44
|
+
this.select(id);
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
onKey(event, tab) {
|
|
50
|
+
const tabs = this.findParts("tab");
|
|
51
|
+
const index = tabs.indexOf(tab);
|
|
52
|
+
const targets = {
|
|
53
|
+
ArrowRight: (index + 1) % tabs.length,
|
|
54
|
+
ArrowLeft: (index - 1 + tabs.length) % tabs.length,
|
|
55
|
+
Home: 0,
|
|
56
|
+
End: tabs.length - 1
|
|
57
|
+
};
|
|
58
|
+
const next = tabs[targets[event.key] ?? -1];
|
|
59
|
+
if (next) {
|
|
60
|
+
event.preventDefault();
|
|
61
|
+
next.focus();
|
|
62
|
+
this.select(next.getAttribute("aria-controls") ?? "", true);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
SpmktTabs
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=tabs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs.js","sources":["../../../src/elements/tabs/tabs.ts"],"sourcesContent":["import { SpmktElement } from '../../lit/spmkt-element'\n\n/**\n * Parts of <spmkt-tabs> (Blade renders the ARIA roles and ids):\n * - tab (required, several): role=\"tab\" buttons with aria-controls=\"<panel id>\", inside a role=\"tablist\"\n * - panel (required, several): role=\"tabpanel\" elements with ids\n * The tab with aria-selected=\"true\" (or the one whose panel id is the URL hash) starts selected.\n */\nexport interface TabsParts {\n tab: HTMLElement[]\n panel: HTMLElement[]\n}\n\n/** ARIA tabs with automatic activation, roving tabindex, arrow/Home/End keys and #panel-id links. */\nexport class SpmktTabs extends SpmktElement {\n override connectedCallback(): void {\n super.connectedCallback()\n const tabs = this.findParts('tab')\n tabs.forEach((tab) => {\n this.listen(tab, 'click', () => this.select(tab.getAttribute('aria-controls') ?? '', true))\n this.listen(tab, 'keydown', (event) => this.onKey(event, tab))\n })\n this.listen(window, 'hashchange', () => this.selectFromHash())\n if (!this.selectFromHash()) {\n const preselected = tabs.find((tab) => tab.getAttribute('aria-selected') === 'true') ?? tabs[0]\n this.select(preselected?.getAttribute('aria-controls') ?? '', false)\n }\n }\n\n /** The id of the selected panel. */\n get selected(): string {\n return (\n this.findParts('tab')\n .find((tab) => tab.getAttribute('aria-selected') === 'true')\n ?.getAttribute('aria-controls') ?? ''\n )\n }\n\n /** Selects the tab of panel `id`; `updateHash` puts #id in the URL without scrolling. */\n select(id: string, updateHash = false): void {\n const panels = this.findParts('panel')\n if (!panels.some((panel) => panel.id === id)) {\n return\n }\n for (const tab of this.findParts('tab')) {\n const on = tab.getAttribute('aria-controls') === id\n tab.setAttribute('aria-selected', String(on))\n tab.tabIndex = on ? 0 : -1\n }\n panels.forEach((panel) => (panel.hidden = panel.id !== id))\n if (updateHash && location.hash !== `#${id}`) {\n history.replaceState(history.state, '', `#${id}`)\n }\n this.emit('spmkt:tab-change', { panel: id })\n }\n\n private selectFromHash(): boolean {\n let id = location.hash.slice(1)\n try {\n id = decodeURIComponent(id)\n } catch {\n // A malformed escape (#%): the hash as it is, which matches no panel\n }\n if (id && this.findParts('panel').some((panel) => panel.id === id)) {\n this.select(id)\n return true\n }\n return false\n }\n\n private onKey(event: KeyboardEvent, tab: HTMLElement): void {\n const tabs = this.findParts('tab')\n const index = tabs.indexOf(tab)\n const targets: Record<string, number> = {\n ArrowRight: (index + 1) % tabs.length,\n ArrowLeft: (index - 1 + tabs.length) % tabs.length,\n Home: 0,\n End: tabs.length - 1,\n }\n const next = tabs[targets[event.key] ?? -1]\n if (next) {\n event.preventDefault()\n next.focus()\n this.select(next.getAttribute('aria-controls') ?? '', true)\n }\n }\n}\n"],"names":[],"mappings":";AAcO,MAAM,kBAAkB,aAAa;AAAA,EACjC,oBAA0B;AACjC,UAAM,kBAAA;AACN,UAAM,OAAO,KAAK,UAAU,KAAK;AACjC,SAAK,QAAQ,CAAC,QAAQ;AACpB,WAAK,OAAO,KAAK,SAAS,MAAM,KAAK,OAAO,IAAI,aAAa,eAAe,KAAK,IAAI,IAAI,CAAC;AAC1F,WAAK,OAAO,KAAK,WAAW,CAAC,UAAU,KAAK,MAAM,OAAO,GAAG,CAAC;AAAA,IAC/D,CAAC;AACD,SAAK,OAAO,QAAQ,cAAc,MAAM,KAAK,gBAAgB;AAC7D,QAAI,CAAC,KAAK,kBAAkB;AAC1B,YAAM,cAAc,KAAK,KAAK,CAAC,QAAQ,IAAI,aAAa,eAAe,MAAM,MAAM,KAAK,KAAK,CAAC;AAC9F,WAAK,OAAO,aAAa,aAAa,eAAe,KAAK,IAAI,KAAK;AAAA,IACrE;AAAA,EACF;AAAA;AAAA,EAGA,IAAI,WAAmB;AACrB,WACE,KAAK,UAAU,KAAK,EACjB,KAAK,CAAC,QAAQ,IAAI,aAAa,eAAe,MAAM,MAAM,GACzD,aAAa,eAAe,KAAK;AAAA,EAEzC;AAAA;AAAA,EAGA,OAAO,IAAY,aAAa,OAAa;AAC3C,UAAM,SAAS,KAAK,UAAU,OAAO;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A,EACF;AACF;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { SpmktElement } from '../../lit/spmkt-element';
|
|
2
|
+
export type ToastTone = 'info' | 'success' | 'error';
|
|
3
|
+
export interface ToastInput {
|
|
4
|
+
message: string;
|
|
5
|
+
tone?: ToastTone;
|
|
6
|
+
/** A link shown with the message, e.g. "Na korpu" */
|
|
7
|
+
action?: {
|
|
8
|
+
label: string;
|
|
9
|
+
href: string;
|
|
10
|
+
};
|
|
11
|
+
/** Milliseconds; 0 keeps it until closed. Default 5000 */
|
|
12
|
+
duration?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface Toast extends Required<Pick<ToastInput, 'message' | 'tone' | 'duration'>> {
|
|
15
|
+
id: number;
|
|
16
|
+
action?: ToastInput['action'];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Parts of <spmkt-toaster>:
|
|
20
|
+
* - list (required, element-owned): an empty list; give it aria-live="polite" (and role="status") in Blade
|
|
21
|
+
*/
|
|
22
|
+
export interface ToasterParts {
|
|
23
|
+
list: HTMLElement;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Shows a toast in the page's toaster. Toasts before the toaster is ready (its class still loading) wait for
|
|
27
|
+
* it. Several elements tell the visitor about errors only by toast, so every layout needs a <spmkt-toaster>:
|
|
28
|
+
* without one, debug mode warns, and an error is logged to the console rather than lost without a trace.
|
|
29
|
+
*/
|
|
30
|
+
export declare function showToast(input: ToastInput): void;
|
|
31
|
+
/**
|
|
32
|
+
* Short messages (added to cart, errors). Each expires after its duration; hovering or focusing the list
|
|
33
|
+
* holds them. Subclass and override renderToast() to change the markup.
|
|
34
|
+
*/
|
|
35
|
+
export declare class SpmktToaster extends SpmktElement {
|
|
36
|
+
private toasts;
|
|
37
|
+
private timers;
|
|
38
|
+
private held;
|
|
39
|
+
connectedCallback(): void;
|
|
40
|
+
show(input: ToastInput): Toast;
|
|
41
|
+
dismiss(id: number): void;
|
|
42
|
+
get current(): readonly Toast[];
|
|
43
|
+
protected renderToast(toast: Toast): unknown;
|
|
44
|
+
private paint;
|
|
45
|
+
private schedule;
|
|
46
|
+
private hold;
|
|
47
|
+
}
|