@salla.sa/twilight-components 2.14.272 → 2.14.274
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/dist/cjs/{filepond-EG2Mf8a1.js → filepond-L1nMkdqn.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-poster-DjNsnxTw.js → filepond-plugin-file-poster-BYZl5BE2.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-size-BlM1btNO.js → filepond-plugin-file-validate-size-DSrSXg4-.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-type-DhymSoh9.js → filepond-plugin-file-validate-type-CgnsyE2V.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-edit-BQfvfpQ1.js → filepond-plugin-image-edit-lODj8ghv.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-exif-orientation-DOi06s13.js → filepond-plugin-image-exif-orientation-uQ5EYlsy.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-preview-Rfix7Xbt.js → filepond-plugin-image-preview-Cm1OgAvZ.js} +1 -1
- package/dist/cjs/{index-DS7mXxWq.js → index-BEeccvkl.js} +136 -26
- package/dist/cjs/{index-vIV5iX-W.js → index-D0NII6ks.js} +1 -1
- package/dist/cjs/loader.cjs.js +3 -4
- package/dist/cjs/{salla-add-product-button_51.cjs.entry.js → salla-accordion_62.cjs.entry.js} +2104 -120
- package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
- package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
- package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
- package/dist/cjs/salla-cart-item-offers.cjs.entry.js +1 -1
- package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters.cjs.entry.js +1 -1
- package/dist/cjs/salla-installment.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-program.cjs.entry.js +1 -1
- package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
- package/dist/cjs/salla-notification-item.cjs.entry.js +2 -2
- package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/{salla-accordion_4.cjs.entry.js → salla-order-details-options.cjs.entry.js} +1 -100
- package/dist/cjs/salla-order-details.cjs.entry.js +2 -2
- package/dist/cjs/salla-order-summary.cjs.entry.js +2 -2
- package/dist/cjs/salla-orders.cjs.entry.js +1 -1
- package/dist/cjs/salla-payments.cjs.entry.js +3 -3
- package/dist/cjs/salla-price-range.cjs.entry.js +3 -3
- package/dist/cjs/salla-review-card.cjs.entry.js +2 -2
- package/dist/cjs/salla-reviews-page.cjs.entry.js +2 -2
- package/dist/cjs/salla-reviews.cjs.entry.js +2 -2
- package/dist/cjs/salla-social.cjs.entry.js +2 -2
- package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-tooltip.cjs.entry.js +2 -2
- package/dist/cjs/salla-verify.cjs.entry.js +1 -1
- package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
- package/dist/cjs/twilight.cjs.js +3 -4
- package/dist/collection/collection-manifest.json +5 -0
- package/dist/collection/components/salla-accordion/salla-accordion-head.js +8 -2
- package/dist/collection/components/salla-comments/salla-comments.js +20 -1
- package/dist/collection/components/salla-conditional-fields/salla-conditional-fields.js +33 -5
- package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-cart.css +0 -0
- package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-cart.js +89 -0
- package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-details.css +0 -0
- package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-details.js +195 -0
- package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-options-modal.css +3 -0
- package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-options-modal.js +595 -0
- package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-slider.css +0 -0
- package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-slider.js +174 -0
- package/dist/collection/components/salla-multiple-bundle-product/interfaces.js +1 -0
- package/dist/collection/components/salla-multiple-bundle-product/salla-multiple-bundle-product.css +3 -0
- package/dist/collection/components/salla-multiple-bundle-product/salla-multiple-bundle-product.js +132 -0
- package/dist/collection/components/salla-notifications/salla-notification-item.js +1 -1
- package/dist/collection/components/salla-offer-modal/salla-offer-modal.js +1 -1
- package/dist/collection/components/salla-order-details/salla-order-details.js +1 -1
- package/dist/collection/components/salla-order-summary/salla-order-summary.js +1 -1
- package/dist/collection/components/salla-payments/salla-payments.js +2 -2
- package/dist/collection/components/salla-placeholder/salla-placeholder.js +1 -1
- package/dist/collection/components/salla-price-range/salla-price-range.js +2 -2
- package/dist/collection/components/salla-product-availability/salla-product-availability.js +1 -1
- package/dist/collection/components/salla-product-card/salla-product-card.js +5 -5
- package/dist/collection/components/salla-product-options/salla-product-options.js +105 -22
- package/dist/collection/components/salla-product-size-guide/salla-product-size-guide.js +2 -2
- package/dist/collection/components/salla-quantity-input/salla-quantity-input.js +1 -1
- package/dist/collection/components/salla-quick-buy/salla-quick-buy.js +1 -1
- package/dist/collection/components/salla-review-card/salla-review-card.js +1 -1
- package/dist/collection/components/salla-reviews/salla-reviews.js +1 -1
- package/dist/collection/components/salla-reviews-page/salla-reviews-page.js +1 -1
- package/dist/collection/components/salla-scopes/salla-scopes.js +1 -1
- package/dist/collection/components/salla-search/salla-search.js +3 -3
- package/dist/collection/components/salla-skeleton/salla-skeleton.js +1 -1
- package/dist/collection/components/salla-slider/salla-slider.js +2 -2
- package/dist/collection/components/salla-social/salla-social.js +1 -1
- package/dist/collection/components/salla-social-share/salla-social-share.js +1 -1
- package/dist/collection/components/salla-tabs/salla-tab-content.js +1 -1
- package/dist/collection/components/salla-tabs/salla-tab-header.js +1 -1
- package/dist/collection/components/salla-tabs/salla-tabs.js +1 -1
- package/dist/collection/components/salla-tel-input/salla-tel-input.js +1 -1
- package/dist/collection/components/salla-tooltip/salla-tooltip.js +1 -1
- package/dist/collection/components/salla-user-settings/salla-user-settings.js +1 -1
- package/dist/components/index.js +2 -2
- package/dist/components/salla-accordion-head2.js +2 -2
- package/dist/components/salla-comments.js +20 -1
- package/dist/components/salla-conditional-fields2.js +28 -6
- package/dist/components/salla-multiple-bundle-product-cart.d.ts +11 -0
- package/dist/components/salla-multiple-bundle-product-cart.js +9 -0
- package/dist/components/salla-multiple-bundle-product-cart2.js +153 -0
- package/dist/components/salla-multiple-bundle-product-details.d.ts +11 -0
- package/dist/components/salla-multiple-bundle-product-details.js +9 -0
- package/dist/components/salla-multiple-bundle-product-details2.js +283 -0
- package/dist/components/salla-multiple-bundle-product-options-modal.d.ts +11 -0
- package/dist/components/salla-multiple-bundle-product-options-modal.js +9 -0
- package/dist/components/salla-multiple-bundle-product-options-modal2.js +585 -0
- package/dist/components/salla-multiple-bundle-product-slider.d.ts +11 -0
- package/dist/components/salla-multiple-bundle-product-slider.js +9 -0
- package/dist/components/salla-multiple-bundle-product-slider2.js +81 -0
- package/dist/components/salla-multiple-bundle-product.d.ts +11 -0
- package/dist/components/salla-multiple-bundle-product.js +210 -0
- package/dist/components/salla-notification-item2.js +1 -1
- package/dist/components/salla-offer-modal.js +1 -1
- package/dist/components/salla-order-details.js +1 -1
- package/dist/components/salla-order-summary.js +1 -1
- package/dist/components/salla-payments.js +2 -2
- package/dist/components/salla-placeholder2.js +1 -1
- package/dist/components/salla-price-range2.js +2 -2
- package/dist/components/salla-product-availability2.js +1 -1
- package/dist/components/salla-product-card2.js +5 -5
- package/dist/components/salla-product-options.js +1 -810
- package/dist/{esm/salla-product-options.entry.js → components/salla-product-options2.js} +197 -30
- package/dist/components/salla-product-size-guide.js +2 -2
- package/dist/components/salla-quantity-input.js +1 -1
- package/dist/components/salla-quick-buy2.js +1 -1
- package/dist/components/salla-review-card2.js +1 -1
- package/dist/components/salla-reviews-page.js +1 -1
- package/dist/components/salla-reviews.js +1 -1
- package/dist/components/salla-scopes.js +1 -1
- package/dist/components/salla-search.js +3 -3
- package/dist/components/salla-skeleton2.js +1 -1
- package/dist/components/salla-slider2.js +2 -2
- package/dist/components/salla-social-share.js +1 -1
- package/dist/components/salla-social.js +1 -1
- package/dist/components/salla-tab-content2.js +1 -1
- package/dist/components/salla-tab-header2.js +1 -1
- package/dist/components/salla-tabs2.js +1 -1
- package/dist/components/salla-tel-input2.js +1 -1
- package/dist/components/salla-tooltip2.js +1 -1
- package/dist/components/salla-user-settings.js +1 -1
- package/dist/esm/{filepond-DbR8YXoW.js → filepond-JStnJXdo.js} +1 -1
- package/dist/esm/{filepond-plugin-file-poster-DEj3O3wZ.js → filepond-plugin-file-poster-13kSl6pa.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-size-DYnIp5yF.js → filepond-plugin-file-validate-size-DGYz9wX6.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-type-Cx_PD8SU.js → filepond-plugin-file-validate-type-7M_EeTPs.js} +1 -1
- package/dist/esm/{filepond-plugin-image-edit-BwmXRkmP.js → filepond-plugin-image-edit-C5N0Q0IF.js} +1 -1
- package/dist/esm/{filepond-plugin-image-exif-orientation-BtsMS4U-.js → filepond-plugin-image-exif-orientation-BvYJ1LVk.js} +1 -1
- package/dist/esm/{filepond-plugin-image-preview-DQ0c3hIt.js → filepond-plugin-image-preview-P4HnGsSt.js} +1 -1
- package/dist/esm/{index-D5PGwR59.js → index-Bdj1TBK9.js} +136 -26
- package/dist/esm/{index-xiIpq8fU.js → index-CqLymITv.js} +1 -1
- package/dist/esm/loader.js +3 -4
- package/dist/esm/{salla-add-product-button_51.entry.js → salla-accordion_62.entry.js} +2084 -111
- package/dist/esm/salla-advertisement.entry.js +1 -1
- package/dist/esm/salla-app-install-alert.entry.js +1 -1
- package/dist/esm/salla-apps-icons.entry.js +1 -1
- package/dist/esm/salla-cart-item-offers.entry.js +1 -1
- package/dist/esm/salla-conditional-offer.entry.js +1 -1
- package/dist/esm/salla-contacts.entry.js +1 -1
- package/dist/esm/salla-filters-widget.entry.js +1 -1
- package/dist/esm/salla-filters.entry.js +1 -1
- package/dist/esm/salla-installment.entry.js +1 -1
- package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
- package/dist/esm/salla-loyalty-program.entry.js +1 -1
- package/dist/esm/salla-metadata.entry.js +1 -1
- package/dist/esm/salla-notification-item.entry.js +2 -2
- package/dist/esm/salla-notifications.entry.js +1 -1
- package/dist/esm/salla-offer.entry.js +1 -1
- package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/{salla-accordion_4.entry.js → salla-order-details-options.entry.js} +2 -98
- package/dist/esm/salla-order-details.entry.js +2 -2
- package/dist/esm/salla-order-summary.entry.js +2 -2
- package/dist/esm/salla-orders.entry.js +1 -1
- package/dist/esm/salla-payments.entry.js +3 -3
- package/dist/esm/salla-price-range.entry.js +3 -3
- package/dist/esm/salla-review-card.entry.js +2 -2
- package/dist/esm/salla-reviews-page.entry.js +2 -2
- package/dist/esm/salla-reviews.entry.js +2 -2
- package/dist/esm/salla-social.entry.js +2 -2
- package/dist/esm/salla-tiered-offer.entry.js +1 -1
- package/dist/esm/salla-tooltip.entry.js +2 -2
- package/dist/esm/salla-verify.entry.js +1 -1
- package/dist/esm/salla-wallet.entry.js +1 -1
- package/dist/esm/twilight.js +3 -4
- package/dist/twilight/{p-56fa3b9c.entry.js → p-0f8534fd.entry.js} +1 -1
- package/dist/twilight/{p-3f412ab2.entry.js → p-1be88437.entry.js} +1 -1
- package/dist/twilight/{p-10856491.entry.js → p-1d81f143.entry.js} +1 -1
- package/dist/twilight/{p-4611a11b.entry.js → p-282f4f69.entry.js} +1 -1
- package/dist/twilight/{p-9e3f55be.entry.js → p-34e10e96.entry.js} +1 -1
- package/dist/twilight/{p-c15928d5.entry.js → p-3a4137eb.entry.js} +1 -1
- package/dist/twilight/{p-0ffafdea.entry.js → p-456d49c3.entry.js} +1 -1
- package/dist/twilight/{p-a61e2b8e.entry.js → p-4d05539c.entry.js} +1 -1
- package/dist/twilight/{p-e3b0a71f.entry.js → p-550d2b59.entry.js} +1 -1
- package/dist/twilight/{p-de200512.entry.js → p-57629f65.entry.js} +1 -1
- package/dist/twilight/p-5971eca7.entry.js +4 -0
- package/dist/twilight/p-723d7b1b.entry.js +4 -0
- package/dist/twilight/{p-92848d53.entry.js → p-78e6e403.entry.js} +1 -1
- package/dist/twilight/{p-2613f6dc.entry.js → p-895bd462.entry.js} +1 -1
- package/dist/twilight/p-9760fa21.entry.js +4 -0
- package/dist/twilight/{p-C4wd-bXb.js → p-AhRhML1e.js} +1 -1
- package/dist/twilight/{p-Bvez5luh.js → p-BP3jjHyr.js} +1 -1
- package/dist/twilight/{p-D5PGwR59.js → p-Bdj1TBK9.js} +2 -2
- package/dist/twilight/{p-BsHa_73h.js → p-Btn8p1Mk.js} +1 -1
- package/dist/twilight/{p-D0ZZ4jO5.js → p-CDM6fsL2.js} +2 -2
- package/dist/twilight/{p-CH8-uKSN.js → p-Ccp_rmSW.js} +1 -1
- package/dist/twilight/{p-DV_VEuIe.js → p-D6-aDTP4.js} +1 -1
- package/dist/twilight/{p-D5p2t_CX.js → p-DD6CdbcU.js} +1 -1
- package/dist/twilight/{p-DEUne75O.js → p-DYhkBiMu.js} +1 -1
- package/dist/twilight/p-a1e9d695.entry.js +4 -0
- package/dist/twilight/{p-eaad31d1.entry.js → p-a5681537.entry.js} +1 -1
- package/dist/twilight/{p-e95284d7.entry.js → p-a8d01888.entry.js} +1 -1
- package/dist/twilight/p-b254a752.entry.js +4 -0
- package/dist/twilight/{p-eae51196.entry.js → p-bd7a0c4f.entry.js} +1 -1
- package/dist/twilight/{p-7df916fc.entry.js → p-bf90a8c8.entry.js} +1 -1
- package/dist/twilight/p-c293f9c1.entry.js +11 -0
- package/dist/twilight/{p-b94ebbd9.entry.js → p-c9ad0ad1.entry.js} +1 -1
- package/dist/twilight/p-cc93a79e.entry.js +4 -0
- package/dist/twilight/{p-2bf21126.entry.js → p-e825aae4.entry.js} +1 -1
- package/dist/twilight/{p-8ba8efe1.entry.js → p-e99645f0.entry.js} +1 -1
- package/dist/twilight/{p-f3c29342.entry.js → p-f232e683.entry.js} +1 -1
- package/dist/twilight/{p-65b1fcea.entry.js → p-f7784dda.entry.js} +1 -1
- package/dist/twilight/{p-280c1f64.entry.js → p-f85916d5.entry.js} +1 -1
- package/dist/twilight/{p-bcab2639.entry.js → p-f96be282.entry.js} +1 -1
- package/dist/twilight/{p-b40d5871.entry.js → p-faee9d58.entry.js} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/types/components/salla-accordion/salla-accordion-head.d.ts +6 -0
- package/dist/types/components/salla-conditional-fields/salla-conditional-fields.d.ts +2 -0
- package/dist/types/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-cart.d.ts +10 -0
- package/dist/types/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-details.d.ts +20 -0
- package/dist/types/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-options-modal.d.ts +46 -0
- package/dist/types/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-slider.d.ts +22 -0
- package/dist/types/components/salla-multiple-bundle-product/interfaces.d.ts +101 -0
- package/dist/types/components/salla-multiple-bundle-product/salla-multiple-bundle-product.d.ts +42 -0
- package/dist/types/components/salla-product-options/salla-product-options.d.ts +21 -1
- package/dist/types/components.d.ts +298 -2
- package/package.json +5 -5
- package/dist/cjs/app-globals-OVEmNa5W.js +0 -38
- package/dist/cjs/camera-DytepEoK.js +0 -13
- package/dist/cjs/minus-CCryh1qf.js +0 -21
- package/dist/cjs/salla-booking-field_2.cjs.entry.js +0 -280
- package/dist/cjs/salla-product-options.cjs.entry.js +0 -715
- package/dist/esm/app-globals-BKgAyoNJ.js +0 -36
- package/dist/esm/camera-C6jIkM-X.js +0 -11
- package/dist/esm/minus-DfeagqF1.js +0 -18
- package/dist/esm/salla-booking-field_2.entry.js +0 -277
- package/dist/twilight/p-19c38b4a.entry.js +0 -11
- package/dist/twilight/p-8272b58f.entry.js +0 -4
- package/dist/twilight/p-989fcbb4.entry.js +0 -4
- package/dist/twilight/p-9f47b72b.entry.js +0 -4
- package/dist/twilight/p-C6jIkM-X.js +0 -4
- package/dist/twilight/p-DfeagqF1.js +0 -4
- package/dist/twilight/p-KHt1Smzh.js +0 -4
- package/dist/twilight/p-b8d41065.entry.js +0 -4
- package/dist/twilight/p-dd9695d6.entry.js +0 -4
- package/dist/twilight/p-e2ebb686.entry.js +0 -4
- package/dist/twilight/p-e30f7c20.entry.js +0 -4
- package/dist/twilight/p-fcb3e719.entry.js +0 -4
|
@@ -1,19 +1,126 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import { r as registerInstance,
|
|
4
|
+
import { r as registerInstance, h, H as Host, a as getElement, c as createEvent, d as getDefaultExportFromCjs, F as Fragment, j as axios } from './index-Bdj1TBK9.js';
|
|
5
5
|
import { a as anime } from './anime.es-CgtvEd63.js';
|
|
6
6
|
import { A as ArrowDownIcon, S as SpecialDiscountIcon } from './special-discount-yRO-ZESF.js';
|
|
7
7
|
import { I as IconVerified } from './check-uTyAzPSy.js';
|
|
8
8
|
import { H as Helper } from './Helper-B51hb0bi.js';
|
|
9
9
|
import { a as arrowLeft } from './arrow-left-BedNk7k1.js';
|
|
10
10
|
import { S as ShoppingBag } from './shopping-bag-DiKTtDW5.js';
|
|
11
|
-
import { p as plusIcon, m as minusIcon } from './minus-DfeagqF1.js';
|
|
12
11
|
import { M as MailIcon } from './mail-DmgxDvXL.js';
|
|
13
12
|
import { w as whatsapp$1 } from './whatsapp2-DWksgowB.js';
|
|
14
13
|
import { f as facebook, t as twitter } from './twitter-Dz7o69vX.js';
|
|
15
14
|
import { G as GiftIcon } from './gift-C0JNGIpa.js';
|
|
16
|
-
|
|
15
|
+
|
|
16
|
+
const sallaAccordionCss = "";
|
|
17
|
+
|
|
18
|
+
const SallaAccordion = class {
|
|
19
|
+
constructor(hostRef) {
|
|
20
|
+
registerInstance(this, hostRef);
|
|
21
|
+
/** Should the accordion be collapsible or not. Default is true. */
|
|
22
|
+
this.collapsible = true;
|
|
23
|
+
this.bordered = false;
|
|
24
|
+
this.size = "md";
|
|
25
|
+
/** Detect if accordion collapsed or not. */
|
|
26
|
+
this.collapsed = true;
|
|
27
|
+
/** Represents the direction of the layout. */
|
|
28
|
+
this.dir = document.dir || 'rtl';
|
|
29
|
+
}
|
|
30
|
+
directionChangedHandler(event) {
|
|
31
|
+
this.dir = event.detail.dir;
|
|
32
|
+
}
|
|
33
|
+
handleCollapse(event) {
|
|
34
|
+
this.collapsed = event.detail.payload.collapsed;
|
|
35
|
+
}
|
|
36
|
+
setcollapsibleProp() {
|
|
37
|
+
const head = this.host.querySelector('salla-accordion-head');
|
|
38
|
+
if (this.collapsible && head) {
|
|
39
|
+
head.setAttribute('collapsible', 'true');
|
|
40
|
+
head.setAttribute('collapsed', this.collapsed.toString());
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
componentDidRender() {
|
|
44
|
+
this.setcollapsibleProp();
|
|
45
|
+
const body = this.host.querySelector('salla-accordion-body');
|
|
46
|
+
if (this.collapsible) {
|
|
47
|
+
this.host.setAttribute('data-collapsed', this.collapsed.toString());
|
|
48
|
+
body?.setAttribute('data-collapsed', this.collapsed.toString());
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
render() {
|
|
52
|
+
return (h(Host, { key: 'ed8e4c0f24fa4462654e94fa46706e892c141351', class: `s-accordion-wrapper ${this.dir} ${this.bordered ? 's-accordion-wrapper-bordered' : ''} ${this.size ? `size-${this.size}` : ''}`, "data-collapsed": this.collapsed.toString() }, h("slot", { key: '1dbda01c073f3018a55ebcf5d8613a82a5dc6b27' })));
|
|
53
|
+
}
|
|
54
|
+
get host() { return getElement(this); }
|
|
55
|
+
};
|
|
56
|
+
SallaAccordion.style = sallaAccordionCss;
|
|
57
|
+
|
|
58
|
+
const sallaAccordionBodyCss = "";
|
|
59
|
+
|
|
60
|
+
const SallaAccordionBody = class {
|
|
61
|
+
constructor(hostRef) {
|
|
62
|
+
registerInstance(this, hostRef);
|
|
63
|
+
}
|
|
64
|
+
render() {
|
|
65
|
+
return (h(Host, { key: '298d42a5bf1bcefdb181ec35060220cf749b56ed', class: "s-accordion-body-wrapper" }, h("slot", { key: '6ab081e8b71b5dc69fb66fbdec82b4725ab53b0d' })));
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
SallaAccordionBody.style = sallaAccordionBodyCss;
|
|
69
|
+
|
|
70
|
+
var Add = `<!-- Generated by IcoMoon.io -->
|
|
71
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
|
72
|
+
<title>add</title>
|
|
73
|
+
<path d="M26.667 14.667h-9.333v-9.333c0-0.736-0.597-1.333-1.333-1.333s-1.333 0.597-1.333 1.333v9.333h-9.333c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333h9.333v9.333c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-9.333h9.333c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333z"></path>
|
|
74
|
+
</svg>
|
|
75
|
+
`;
|
|
76
|
+
|
|
77
|
+
var Minus = `<!-- Generated by IcoMoon.io -->
|
|
78
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
|
79
|
+
<title>minus</title>
|
|
80
|
+
<path d="M26.667 14.667h-21.333c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333h21.333c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333z"></path>
|
|
81
|
+
</svg>
|
|
82
|
+
`;
|
|
83
|
+
|
|
84
|
+
const sallaAccordionHeadCss = "";
|
|
85
|
+
|
|
86
|
+
const SallaAccordionHead = class {
|
|
87
|
+
constructor(hostRef) {
|
|
88
|
+
registerInstance(this, hostRef);
|
|
89
|
+
this.accordionToggle = createEvent(this, "accordionToggle");
|
|
90
|
+
/** Should the accordion be collapsible or not. */
|
|
91
|
+
this.collapsible = false;
|
|
92
|
+
/** Current collapsed state */
|
|
93
|
+
this.collapsed = true;
|
|
94
|
+
}
|
|
95
|
+
emitCollapsePanel() {
|
|
96
|
+
this.accordionToggle.emit({
|
|
97
|
+
payload: {
|
|
98
|
+
collapsed: this.collapsed,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
toggleCollapse() {
|
|
103
|
+
if (!this.collapsible)
|
|
104
|
+
return;
|
|
105
|
+
this.collapsed = !this.collapsed;
|
|
106
|
+
this.host.parentElement?.setAttribute('data-collapsed', this.collapsed.toString());
|
|
107
|
+
this.host.parentElement
|
|
108
|
+
?.querySelector('salla-accordion-body')
|
|
109
|
+
?.setAttribute('data-collapsed', this.collapsed.toString());
|
|
110
|
+
this.emitCollapsePanel();
|
|
111
|
+
}
|
|
112
|
+
render() {
|
|
113
|
+
return (h(Host, { key: '9d88d243306cdf451c20d7068fbb9f48807b22e9', "data-collapsed": this.collapsed.toString(), onClick: () => this.toggleCollapse(), class: "s-accordion-head-wrapper" }, h("div", { key: 'bad4c5a913ce1c4581b09c0b6d96fcbdb4236638', class: "s-accordion-head-wrapper-start" }, h("slot", { key: 'acb83cec8cbca5771a9f84e81c0b955c3edad731', name: "title" }), h("slot", { key: 'a4ad42ea6fad4f452c4c218a9ee02dca0adb4a67', name: "progress" }), h("slot", { key: '96ab95d413dc906ac299079f4008816f01881990', name: "html" })), (this.collapsible || this.host.querySelector('[slot="note"]')) && (h("div", { key: '8f9666a5038cd7b1ac6e357c6920ea26d31c5f03', class: "s-accordion-head-wrapper-end" }, h("slot", { key: '14895e8c1385e91c14f046c9ae38ce5e4a4c9a60', name: "note" }), this.collapsible && (h("button", { key: '97dc7fabbb207fcc8b68ebf0a86f6c8a980dca13', class: {
|
|
114
|
+
's-accordion-head-wrapper-toggle': true,
|
|
115
|
+
active: !this.collapsed,
|
|
116
|
+
}, onClick: e => {
|
|
117
|
+
e.stopPropagation();
|
|
118
|
+
this.toggleCollapse();
|
|
119
|
+
} }, h("span", { key: '3b24faf71dcd332663a354310b2ce09f7879eddc', class: "s-accordion-head-wrapper-toggle-icon", innerHTML: this.collapsed ? Add : Minus })))))));
|
|
120
|
+
}
|
|
121
|
+
get host() { return getElement(this); }
|
|
122
|
+
};
|
|
123
|
+
SallaAccordionHead.style = sallaAccordionHeadCss;
|
|
17
124
|
|
|
18
125
|
var PendingOrdersIcon = `<!-- Generated by IcoMoon.io -->
|
|
19
126
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="30" height="32" viewBox="0 0 30 32">
|
|
@@ -274,6 +381,180 @@ const SallaAlert = class {
|
|
|
274
381
|
};
|
|
275
382
|
SallaAlert.style = sallaAlertCss;
|
|
276
383
|
|
|
384
|
+
var BookingTime = `<!-- Generated by IcoMoon.io -->
|
|
385
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
|
386
|
+
<title>calendar-time</title>
|
|
387
|
+
<path d="M22.667 17.333c-0.737 0-1.333 0.596-1.333 1.333v2.667h-2.667c-0.737 0-1.333 0.596-1.333 1.333s0.596 1.333 1.333 1.333h4c0.737 0 1.333-0.596 1.333-1.333v-4c0-0.737-0.596-1.333-1.333-1.333zM28 2.667h-2.667v-1.333c0-0.736-0.596-1.333-1.333-1.333s-1.333 0.597-1.333 1.333v1.333h-13.333v-1.333c0-0.736-0.596-1.333-1.333-1.333s-1.333 0.597-1.333 1.333v1.333h-2.667c-2.205 0-4 1.795-4 4v21.333c0 2.205 1.795 4 4 4h5.363c0.737 0 1.333-0.596 1.333-1.333s-0.596-1.333-1.333-1.333h-5.363c-0.736 0-1.333-0.597-1.333-1.333v-21.333c0-0.736 0.597-1.333 1.333-1.333h2.667v2.667c0 0.736 0.596 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-2.667h13.333v2.667c0 0.736 0.596 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-2.667h2.667c0.736 0 1.333 0.599 1.333 1.333v2.696c0 0.736 0.596 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-2.696c0-2.205-1.795-4-4-4zM22 12c-5.515 0-10 4.485-10 10s4.485 10 10 10 10-4.485 10-10-4.485-10-10-10zM22 29.333c-4.043 0-7.333-3.291-7.333-7.333s3.291-7.333 7.333-7.333 7.333 3.291 7.333 7.333-3.291 7.333-7.333 7.333z"></path>
|
|
388
|
+
</svg>
|
|
389
|
+
`;
|
|
390
|
+
|
|
391
|
+
var Calendar = `<!-- Generated by IcoMoon.io -->
|
|
392
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
|
393
|
+
<title>calendar</title>
|
|
394
|
+
<path d="M28 2.667h-2.667v-1.333c0-0.736-0.597-1.333-1.333-1.333s-1.333 0.597-1.333 1.333v1.333h-13.333v-1.333c0-0.736-0.597-1.333-1.333-1.333s-1.333 0.597-1.333 1.333v1.333h-2.667c-2.205 0-4 1.795-4 4v21.333c0 2.205 1.795 4 4 4h24c2.205 0 4-1.795 4-4v-21.333c0-2.205-1.795-4-4-4zM29.333 28c0 0.736-0.599 1.333-1.333 1.333h-24c-0.736 0-1.333-0.599-1.333-1.333v-13.333h26.667zM29.333 12h-26.667v-5.333c0-0.736 0.599-1.333 1.333-1.333h2.667v2.667c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-2.667h13.333v2.667c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-2.667h2.667c0.736 0 1.333 0.599 1.333 1.333z"></path>
|
|
395
|
+
</svg>
|
|
396
|
+
`;
|
|
397
|
+
|
|
398
|
+
var TimeIcon = `<!-- Generated by IcoMoon.io -->
|
|
399
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
|
400
|
+
<title>time</title>
|
|
401
|
+
<path d="M16 0c-8.823 0-16 7.177-16 16s7.177 16 16 16 16-7.177 16-16-7.177-16-16-16zM16 29.333c-7.352 0-13.333-5.981-13.333-13.333s5.981-13.333 13.333-13.333 13.333 5.981 13.333 13.333-5.981 13.333-13.333 13.333zM16 8c-0.736 0-1.333 0.596-1.333 1.333v6.667h-4c-0.736 0-1.333 0.596-1.333 1.333s0.597 1.333 1.333 1.333h5.333c0.736 0 1.333-0.596 1.333-1.333v-8c0-0.737-0.597-1.333-1.333-1.333z"></path>
|
|
402
|
+
</svg>
|
|
403
|
+
`;
|
|
404
|
+
|
|
405
|
+
const sallaBookingFieldCss = ":host{display:block}";
|
|
406
|
+
|
|
407
|
+
const SallaBookingField = class {
|
|
408
|
+
constructor(hostRef) {
|
|
409
|
+
registerInstance(this, hostRef);
|
|
410
|
+
this.invalidInput = createEvent(this, "invalidInput");
|
|
411
|
+
this.bookNowLabel = salla.lang.get('pages.cart.book_an_appointment', 'حجز موعد');
|
|
412
|
+
this.editLabel = salla.lang.get('pages.cart.edit_an_appointment', 'تعديل الموعد');
|
|
413
|
+
this.bookedLabel = salla.lang.get('pages.cart.booked_successfully', 'تمت اضافة الموعد بنجاح');
|
|
414
|
+
this.selectDate = salla.lang.get('pages.cart.select_appointment_date', 'حدد تاريخ الموعد');
|
|
415
|
+
this.bookingUrl = '';
|
|
416
|
+
this.iframeReady = false;
|
|
417
|
+
this.reservations = [];
|
|
418
|
+
// Load translations
|
|
419
|
+
salla.lang.onLoaded(() => this.setTranslations());
|
|
420
|
+
// Register event listeners
|
|
421
|
+
Salla.event.on('booking::open', (data) => this.handleBookingOpen(data));
|
|
422
|
+
}
|
|
423
|
+
async setTranslations() {
|
|
424
|
+
const setNestedAsync = (lang, key, value) => {
|
|
425
|
+
return new Promise((resolve) => {
|
|
426
|
+
salla.helpers.setNested(salla.lang.messages[lang], key, value);
|
|
427
|
+
resolve(true);
|
|
428
|
+
});
|
|
429
|
+
};
|
|
430
|
+
await setNestedAsync('ar.trans', 'pages.cart.book_an_appointment', 'حجز موعد');
|
|
431
|
+
await setNestedAsync('en.trans', 'pages.cart.book_an_appointment', 'Book an Appointment');
|
|
432
|
+
await setNestedAsync('ar.trans', 'pages.cart.edit_an_appointment', 'تعديل الموعد');
|
|
433
|
+
await setNestedAsync('en.trans', 'pages.cart.edit_an_appointment', 'Edit an Appointment');
|
|
434
|
+
await setNestedAsync('ar.trans', 'pages.cart.booked_successfully', 'تمت اضافة الموعد بنجاح');
|
|
435
|
+
await setNestedAsync('en.trans', 'pages.cart.booked_successfully', 'Booked Successfully');
|
|
436
|
+
await setNestedAsync('ar.trans', 'pages.cart.select_appointment_date', 'حدد تاريخ الموعد');
|
|
437
|
+
await setNestedAsync('en.trans', 'pages.cart.select_appointment_date', 'Select appointment date');
|
|
438
|
+
this.bookNowLabel = salla.lang.get('pages.cart.book_an_appointment');
|
|
439
|
+
this.editLabel = salla.lang.get('pages.cart.edit_an_appointment');
|
|
440
|
+
this.bookedLabel = salla.lang.get('pages.cart.booked_successfully');
|
|
441
|
+
this.selectDate = salla.lang.get('pages.cart.select_appointment_date');
|
|
442
|
+
}
|
|
443
|
+
openBookingModal(event, afterReload = false) {
|
|
444
|
+
if (afterReload && (!event.detail || typeof event.detail !== 'number' || event.detail !== this.productId)) {
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
if (salla.config.isGuest()) {
|
|
448
|
+
this.setAfterReloadEvent('booking::open-after-reload', this.productId);
|
|
449
|
+
salla.event.dispatch('login::open');
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
salla.booking.add(this.productId, false)
|
|
453
|
+
.then((resp) => {
|
|
454
|
+
if (resp.data.redirect.to !== 'booking') {
|
|
455
|
+
throw new Error('Unexpected redirect!');
|
|
456
|
+
}
|
|
457
|
+
salla.event.dispatch('booking::open', { url: resp.data.redirect.url, id: this.productId });
|
|
458
|
+
})
|
|
459
|
+
.catch((error) => {
|
|
460
|
+
salla.error(salla.lang.get('common.errors.error_occurred'));
|
|
461
|
+
salla.logger.error(error.response || error);
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
handleBookingOpen(data) {
|
|
465
|
+
if (data.id !== this.productId)
|
|
466
|
+
return;
|
|
467
|
+
this.bookingUrl = salla.url.addParamToUrl('product_id', data.id, data.url);
|
|
468
|
+
this.iframeReady = true;
|
|
469
|
+
setTimeout(() => {
|
|
470
|
+
this.modal.setTitle(this.selectDate);
|
|
471
|
+
this.modal.open();
|
|
472
|
+
}, 100);
|
|
473
|
+
}
|
|
474
|
+
setAfterReloadEvent(event, payload) {
|
|
475
|
+
salla.storage.set('afterReloadEvent', { event, payload });
|
|
476
|
+
}
|
|
477
|
+
emitAfterReloadEvent() {
|
|
478
|
+
const eventDetails = salla.storage.get('afterReloadEvent');
|
|
479
|
+
if (eventDetails && eventDetails.event) {
|
|
480
|
+
const customEvent = new CustomEvent(eventDetails.event, {
|
|
481
|
+
detail: eventDetails.payload
|
|
482
|
+
});
|
|
483
|
+
window.dispatchEvent(customEvent);
|
|
484
|
+
salla.storage.remove('afterReloadEvent');
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
componentWillLoad() {
|
|
488
|
+
if (this.option && this.option.details.length) {
|
|
489
|
+
this.reservations = this.option.details;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
componentDidLoad() {
|
|
493
|
+
window.addEventListener('booking::open-after-reload', (event) => this.openBookingModal(event, true));
|
|
494
|
+
this.emitAfterReloadEvent();
|
|
495
|
+
window.addEventListener('message', this.handleMessageEvent.bind(this));
|
|
496
|
+
this.reservationsInput.addEventListener('invalid', e => this.invalidInput.emit(e));
|
|
497
|
+
this.reservationsInput.addEventListener('input', () => {
|
|
498
|
+
this.reservationsInput.setCustomValidity('');
|
|
499
|
+
this.reservationsInput.reportValidity();
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
handleMessageEvent(event) {
|
|
503
|
+
if (event.data.source !== 'booking')
|
|
504
|
+
return;
|
|
505
|
+
const action = event.data.type;
|
|
506
|
+
const value = event.data.message;
|
|
507
|
+
if (localStorage.getItem('debug'))
|
|
508
|
+
console.log(`Received an action:${action}`, event.data);
|
|
509
|
+
if (action === 'error') {
|
|
510
|
+
if (value.fields?.reservation) {
|
|
511
|
+
salla.notify.error(value.fields.reservation[0]);
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
const errorList = Object.values(value.fields || [value.message]).flat().map(error => `<li>${error}</li>`).join('');
|
|
515
|
+
salla.notify.error(`<ul>${errorList}</ul>`);
|
|
516
|
+
}
|
|
517
|
+
if (action === 'success') {
|
|
518
|
+
if (Number(value.productId) !== Number(this.productId))
|
|
519
|
+
return;
|
|
520
|
+
this.reservations = value.data.reservations.map(schedule => {
|
|
521
|
+
if (schedule.time && schedule.time.length > 0) {
|
|
522
|
+
const timeSlot = schedule.time[0];
|
|
523
|
+
return {
|
|
524
|
+
date: schedule.date,
|
|
525
|
+
day: schedule.day,
|
|
526
|
+
from_timestamp: timeSlot.from,
|
|
527
|
+
to_timestamp: timeSlot.to,
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
return null;
|
|
531
|
+
}).filter(item => item !== null);
|
|
532
|
+
salla.notify.success(this.bookedLabel);
|
|
533
|
+
this.modal?.close();
|
|
534
|
+
setTimeout(() => window.location.reload());
|
|
535
|
+
}
|
|
536
|
+
if (action === 'height') {
|
|
537
|
+
this.iframe.height = value?.height + 'px';
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
bookingModal() {
|
|
541
|
+
return (h("salla-modal", { class: "s-booking-field-modal", ref: modal => (this.modal = modal), width: "md", position: "middle", noPadding: true }, h("iframe", { ref: iframe => (this.iframe = iframe), src: this.bookingUrl, frameborder: "0" })));
|
|
542
|
+
}
|
|
543
|
+
renderReservationDate(reservation) {
|
|
544
|
+
return (h("span", { class: reservation.from_timestamp ? 's-booking-field-reservations-has-time' : '' }, h("i", { class: "s-booking-field-reservations-icon", innerHTML: Calendar }), reservation.date));
|
|
545
|
+
}
|
|
546
|
+
renderReservationTime(reservation) {
|
|
547
|
+
if (!reservation.from_timestamp)
|
|
548
|
+
return '';
|
|
549
|
+
return (h("span", { class: "s-booking-field-reservations-time" }, h("i", { class: "s-booking-field-reservations-icon", innerHTML: TimeIcon }), h("span", null, reservation.from_timestamp, " - ", reservation.to_timestamp)));
|
|
550
|
+
}
|
|
551
|
+
render() {
|
|
552
|
+
return (h(Host, { key: '04c9e3dc3dc825bd6905221d858c260f7ca34748' }, h("div", { key: '07ec38cec1bd1798640dd7ea9592bb3b17d945c6', class: "s-booking-field-main" }, this.option.required || this.reservations.length > 0 ? h("div", { class: "s-booking-field-price" }, h("span", { innerHTML: salla.money(this.option.price) })) : '', h("salla-button", { key: '6b71889cfc0429d15c466a6f194df31549f09786', class: "s-booking-field-book-now", size: "small", loaderPosition: "center", fill: "outline", onClick: event => this.openBookingModal(event, false) }, h("span", { key: 'a16f8db6f52c7751ea605efcae04057ca0dc5b61', class: "s-booking-field-book-now-content" }, h("span", { key: '95f6086a599bcc620c87ece6c6ae9620dba15581', innerHTML: BookingTime }), this.reservations.length ? this.editLabel : this.bookNowLabel))), this.reservations.length > 0 && (h("div", { key: 'b3615100bbfff3d98d0ac99145aaf53449790c94', class: "s-booking-field-reservations" }, this.reservations.map((reservation, index) => (h("div", { key: index, class: "s-booking-field-reservations-item" }, this.renderReservationDate(reservation), this.renderReservationTime(reservation)))))), h("input", { key: '126f14f2e520b8696bc7450e209bad30b267878b', class: "s-hidden", name: this.option.name, required: this.option.required, value: JSON.stringify(this.reservations) === '[]' ? '' : JSON.stringify(this.reservations), ref: reservations => this.reservationsInput = reservations }), this.iframeReady && this.bookingModal()));
|
|
553
|
+
}
|
|
554
|
+
get host() { return getElement(this); }
|
|
555
|
+
};
|
|
556
|
+
SallaBookingField.style = sallaBookingFieldCss;
|
|
557
|
+
|
|
277
558
|
var infoIcon = `<!-- Generated by IcoMoon.io -->
|
|
278
559
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
|
279
560
|
<title>info</title>
|
|
@@ -2398,7 +2679,8 @@ const SallaComments = class {
|
|
|
2398
2679
|
resp = await salla.api.request('reviews', { params }, 'get');
|
|
2399
2680
|
}
|
|
2400
2681
|
else {
|
|
2401
|
-
|
|
2682
|
+
// Ensure sort is passed for regular comments as well
|
|
2683
|
+
resp = await salla.api.comment.getComments(this.type, this.itemId, 1, 5, this.sort);
|
|
2402
2684
|
}
|
|
2403
2685
|
if (!resp.data || !resp.data.length) {
|
|
2404
2686
|
this.showPlaceholder = false;
|
|
@@ -2412,6 +2694,24 @@ const SallaComments = class {
|
|
|
2412
2694
|
this.pagination = resp.pagination;
|
|
2413
2695
|
this.total = resp.pagination.total;
|
|
2414
2696
|
this.nextPage = typeof resp.pagination.links === 'object' && !!resp.pagination.links.next ? resp.pagination.links.next : null;
|
|
2697
|
+
// Preserve sort param in next page URL for infinite scroll
|
|
2698
|
+
if (this.nextPage && this.sort) {
|
|
2699
|
+
try {
|
|
2700
|
+
const url = new URL(this.nextPage, window.location.origin);
|
|
2701
|
+
if (!url.searchParams.get('sort')) {
|
|
2702
|
+
url.searchParams.set('sort', this.sort);
|
|
2703
|
+
this.nextPage = url.toString();
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
catch (_e) {
|
|
2707
|
+
// fallback for relative next links
|
|
2708
|
+
const hasQuery = this.nextPage.includes('?');
|
|
2709
|
+
const hasSort = /[?&]sort=/.test(this.nextPage);
|
|
2710
|
+
if (!hasSort) {
|
|
2711
|
+
this.nextPage = this.nextPage + (hasQuery ? '&' : '?') + `sort=${this.sort}`;
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
}
|
|
2415
2715
|
setTimeout(() => {
|
|
2416
2716
|
for (const card of this.handleResponse(resp)) {
|
|
2417
2717
|
this.wrapper.append(card);
|
|
@@ -2453,6 +2753,125 @@ const SallaComments = class {
|
|
|
2453
2753
|
};
|
|
2454
2754
|
SallaComments.style = sallaCommentsCss;
|
|
2455
2755
|
|
|
2756
|
+
const SallaConditionalFields = class {
|
|
2757
|
+
constructor(hostRef) {
|
|
2758
|
+
registerInstance(this, hostRef);
|
|
2759
|
+
}
|
|
2760
|
+
hideAllOptions(optionId) {
|
|
2761
|
+
this.host.querySelectorAll(`[data-show-when^="options[${optionId}"]`).forEach((field) => {
|
|
2762
|
+
field.classList.add('hidden');
|
|
2763
|
+
this.hideAllOptions(field.dataset.optionId);
|
|
2764
|
+
this.disableInputs(field);
|
|
2765
|
+
});
|
|
2766
|
+
}
|
|
2767
|
+
disableInputs(field) {
|
|
2768
|
+
field.querySelectorAll('[name]').forEach((input) => {
|
|
2769
|
+
input.setAttribute('disabled', '');
|
|
2770
|
+
input.removeAttribute('required');
|
|
2771
|
+
if (input?.tagName?.toLowerCase() === 'select') {
|
|
2772
|
+
input.value = '';
|
|
2773
|
+
}
|
|
2774
|
+
if (['checkbox'].includes(input.getAttribute('type')) && input.hasOwnProperty('checked')) {
|
|
2775
|
+
// @ts-ignore
|
|
2776
|
+
input.checked = false;
|
|
2777
|
+
}
|
|
2778
|
+
});
|
|
2779
|
+
}
|
|
2780
|
+
changeHandler(event) {
|
|
2781
|
+
salla.event.emit('salla-onditional-fields::change', event);
|
|
2782
|
+
salla.log('Received the change/input event:', event);
|
|
2783
|
+
if (!event.target ||
|
|
2784
|
+
(!['SELECT', 'INPUT', 'TEXTAREA'].includes(event.target.tagName) &&
|
|
2785
|
+
!['checkbox', 'radio', 'text'].includes(event.target.getAttribute('type')))) {
|
|
2786
|
+
salla.log('Ignore the event because is not a supported input: ' + (event?.target?.tagName || 'N/A'));
|
|
2787
|
+
return;
|
|
2788
|
+
}
|
|
2789
|
+
// For text inputs, debounce the handling to improve performance on mobile
|
|
2790
|
+
const isTextInput = ['INPUT', 'TEXTAREA'].includes(event.target.tagName) &&
|
|
2791
|
+
(!event.target.getAttribute('type') || event.target.getAttribute('type') === 'text');
|
|
2792
|
+
if (isTextInput && event.type === 'input') {
|
|
2793
|
+
clearTimeout(this.debounceTimeout);
|
|
2794
|
+
this.debounceTimeout = setTimeout(() => {
|
|
2795
|
+
this.processConditionalFields(event);
|
|
2796
|
+
}, 300); // 300ms debounce for text inputs
|
|
2797
|
+
return;
|
|
2798
|
+
}
|
|
2799
|
+
// Process immediately for change events and non-text inputs
|
|
2800
|
+
this.processConditionalFields(event);
|
|
2801
|
+
}
|
|
2802
|
+
processConditionalFields(event) {
|
|
2803
|
+
let optionId = event.target.name.replace('[]', '');
|
|
2804
|
+
let isMultiple = event.target.getAttribute('type') === 'checkbox';
|
|
2805
|
+
let isRadio = event.target.getAttribute('type') === 'radio';
|
|
2806
|
+
let isTextInput = ['INPUT', 'TEXTAREA'].includes(event.target.tagName) &&
|
|
2807
|
+
(!event.target.getAttribute('type') || event.target.getAttribute('type') === 'text');
|
|
2808
|
+
salla.log('Trying to find all elements with condition:', `[data-show-when^="${optionId}"]`);
|
|
2809
|
+
this.host.querySelectorAll(`[data-show-when^="${optionId}"]`)
|
|
2810
|
+
.forEach((field) => {
|
|
2811
|
+
let isEqual = !field?.dataset.showWhen.includes('!=');
|
|
2812
|
+
let value = field?.dataset.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$3').trim();
|
|
2813
|
+
let isSelected;
|
|
2814
|
+
if (isMultiple) {
|
|
2815
|
+
let selectedValues = Array.from(this.host.querySelectorAll(`input[name="${event.target.name}"]:checked`), e => e?.value);
|
|
2816
|
+
isSelected = selectedValues.includes(value.toString());
|
|
2817
|
+
}
|
|
2818
|
+
else if (isRadio) {
|
|
2819
|
+
// Handle radio inputs.
|
|
2820
|
+
isSelected = event.target.checked && event.target.value === value;
|
|
2821
|
+
}
|
|
2822
|
+
else if (isTextInput) {
|
|
2823
|
+
// Handle text inputs and textareas - check if value matches or is not empty for boolean conditions
|
|
2824
|
+
isSelected = value === event.target.value || (value.toLowerCase() === 'true' && event.target.value.trim() !== '');
|
|
2825
|
+
}
|
|
2826
|
+
else {
|
|
2827
|
+
isSelected = value === event.target.value;
|
|
2828
|
+
}
|
|
2829
|
+
salla.log('The input is ', isMultiple ? 'Multiple' : isRadio ? 'Radio' : isTextInput ? 'Text' : 'Single', ' value:', isSelected);
|
|
2830
|
+
let showTheInput = (isEqual && isSelected) || (!isEqual && !isSelected);
|
|
2831
|
+
if (showTheInput) {
|
|
2832
|
+
field.classList.remove('hidden');
|
|
2833
|
+
field.querySelectorAll('[name]').forEach((input) => {
|
|
2834
|
+
input.removeAttribute('disabled');
|
|
2835
|
+
const closestProductOption = input.closest('.s-product-options-option');
|
|
2836
|
+
if (closestProductOption.dataset.optionRequired === 'true') {
|
|
2837
|
+
input.setAttribute('required', '');
|
|
2838
|
+
}
|
|
2839
|
+
if (input.getAttribute('type') === 'checkbox') {
|
|
2840
|
+
const checkboxes = Array.from(document.querySelectorAll(`input[type="checkbox"][name="${input.getAttribute('name')}"]`));
|
|
2841
|
+
const isAnyChecked = checkboxes.some((checkbox) => checkbox.checked);
|
|
2842
|
+
if (isAnyChecked) {
|
|
2843
|
+
checkboxes.forEach((checkbox) => {
|
|
2844
|
+
checkbox.removeAttribute('required');
|
|
2845
|
+
});
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
});
|
|
2849
|
+
}
|
|
2850
|
+
else {
|
|
2851
|
+
this.hideAllOptions(field.dataset.optionId);
|
|
2852
|
+
field.classList.add('hidden');
|
|
2853
|
+
this.disableInputs(field);
|
|
2854
|
+
}
|
|
2855
|
+
});
|
|
2856
|
+
}
|
|
2857
|
+
componentDidRender() {
|
|
2858
|
+
this.host.querySelectorAll(`[data-show-when]`).forEach((field) => {
|
|
2859
|
+
// @ts-ignore
|
|
2860
|
+
let optionName = field?.dataset?.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$1').trim();
|
|
2861
|
+
if (!optionName) {
|
|
2862
|
+
return;
|
|
2863
|
+
}
|
|
2864
|
+
this.changeHandler({
|
|
2865
|
+
target: this.host.querySelector('[name^="' + optionName + '"]')
|
|
2866
|
+
});
|
|
2867
|
+
});
|
|
2868
|
+
}
|
|
2869
|
+
render() {
|
|
2870
|
+
return (h(Host, { key: 'b29d3a3e7e7af01540efbd2868cd302e91bba8a4' }, h("slot", { key: 'b6d6544834ea082ffcd20deef2da1206a47e98ba' })));
|
|
2871
|
+
}
|
|
2872
|
+
get host() { return getElement(this); }
|
|
2873
|
+
};
|
|
2874
|
+
|
|
2456
2875
|
const sallaCountDownCss = "";
|
|
2457
2876
|
|
|
2458
2877
|
const SallaCountDown = class {
|
|
@@ -3075,13 +3494,13 @@ const SallaFileUpload = class {
|
|
|
3075
3494
|
return;
|
|
3076
3495
|
try {
|
|
3077
3496
|
const [FilePondModule, FilePondPluginFileValidateSize, FilePondPluginImageExifOrientation, FilePondPluginImagePreview, FilePondPluginImageEdit, FilePondPluginFileValidateType, FilePondPluginFilePoster] = await Promise.all([
|
|
3078
|
-
import('./filepond-
|
|
3079
|
-
import('./filepond-plugin-file-validate-size-
|
|
3080
|
-
import('./filepond-plugin-image-exif-orientation-
|
|
3081
|
-
import('./filepond-plugin-image-preview-
|
|
3082
|
-
import('./filepond-plugin-image-edit-
|
|
3083
|
-
import('./filepond-plugin-file-validate-type-
|
|
3084
|
-
import('./filepond-plugin-file-poster-
|
|
3497
|
+
import('./filepond-JStnJXdo.js').then(function (n) { return n.f; }),
|
|
3498
|
+
import('./filepond-plugin-file-validate-size-DGYz9wX6.js').then(function (n) { return n.f; }),
|
|
3499
|
+
import('./filepond-plugin-image-exif-orientation-BvYJ1LVk.js').then(function (n) { return n.f; }),
|
|
3500
|
+
import('./filepond-plugin-image-preview-P4HnGsSt.js').then(function (n) { return n.f; }),
|
|
3501
|
+
import('./filepond-plugin-image-edit-C5N0Q0IF.js').then(function (n) { return n.f; }),
|
|
3502
|
+
import('./filepond-plugin-file-validate-type-7M_EeTPs.js').then(function (n) { return n.f; }),
|
|
3503
|
+
import('./filepond-plugin-file-poster-13kSl6pa.js').then(function (n) { return n.f; })
|
|
3085
3504
|
]);
|
|
3086
3505
|
this.FilePond = FilePondModule;
|
|
3087
3506
|
// Register plugins
|
|
@@ -5840,88 +6259,866 @@ const SallaModal = class {
|
|
|
5840
6259
|
};
|
|
5841
6260
|
SallaModal.style = sallaModalCss;
|
|
5842
6261
|
|
|
5843
|
-
|
|
5844
|
-
<title>tag</title>
|
|
5845
|
-
<path d="M28 0h-9.344c-1.059 0-2.056 0.411-2.809 1.153l-14.673 14.456c-1.56 1.56-1.561 4.097-0.001 5.657l9.56 9.56c0.755 0.755 1.76 1.172 2.828 1.173h0.003c1.068 0 2.072-0.416 2.833-1.179l14.451-14.668c0.743-0.753 1.153-1.751 1.153-2.809v-9.344c0-2.205-1.795-4-4-4zM29.333 13.344c0 0.353-0.137 0.685-0.385 0.937l-14.444 14.661c-0.252 0.252-0.587 0.391-0.941 0.391-0.001 0-0.001 0-0.001 0-0.356-0.001-0.691-0.139-0.943-0.392l-9.561-9.56c-0.52-0.52-0.52-1.365-0.005-1.88l14.667-14.449c0.253-0.248 0.585-0.385 0.937-0.385h9.344c0.736 0 1.333 0.597 1.333 1.333zM24 6.673c-0.737 0-1.333 0.604-1.333 1.341s0.596 1.333 1.333 1.333 1.333-0.596 1.333-1.333v-0.015c0-0.737-0.596-1.327-1.333-1.327z"></path>
|
|
5846
|
-
</svg>
|
|
5847
|
-
`;
|
|
6262
|
+
const sallaMultipleBundleProductCss = ":host{display:block}";
|
|
5848
6263
|
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
6264
|
+
const SallaMultipleBundleProduct = class {
|
|
6265
|
+
constructor(hostRef) {
|
|
6266
|
+
registerInstance(this, hostRef);
|
|
6267
|
+
this.parsedSections = [];
|
|
6268
|
+
}
|
|
6269
|
+
parseProducts(newValue) {
|
|
6270
|
+
let sections = [];
|
|
6271
|
+
if (typeof newValue === 'string') {
|
|
6272
|
+
try {
|
|
6273
|
+
const parsed = JSON.parse(newValue);
|
|
6274
|
+
sections = this.extractSections(parsed);
|
|
6275
|
+
}
|
|
6276
|
+
catch (e) {
|
|
6277
|
+
console.error('Invalid JSON passed to bundleSections prop:', newValue);
|
|
6278
|
+
sections = [];
|
|
6279
|
+
}
|
|
6280
|
+
}
|
|
6281
|
+
else if (newValue) {
|
|
6282
|
+
sections = this.extractSections(newValue);
|
|
6283
|
+
}
|
|
6284
|
+
this.parsedSections = sections;
|
|
6285
|
+
}
|
|
6286
|
+
extractSections(data) {
|
|
6287
|
+
// Handle new nested structure: data.bundle.sections
|
|
6288
|
+
if (data.bundle && data.bundle.sections && Array.isArray(data.bundle.sections)) {
|
|
6289
|
+
return data.bundle.sections;
|
|
6290
|
+
}
|
|
6291
|
+
// Handle old flat structure: data is directly an array of sections
|
|
6292
|
+
if (Array.isArray(data)) {
|
|
6293
|
+
return data;
|
|
6294
|
+
}
|
|
6295
|
+
// Handle case where data.sections exists at root level
|
|
6296
|
+
if (data.sections && Array.isArray(data.sections)) {
|
|
6297
|
+
return data.sections;
|
|
6298
|
+
}
|
|
6299
|
+
console.warn('No valid sections found in data:', data);
|
|
6300
|
+
return [];
|
|
6301
|
+
}
|
|
6302
|
+
isCartPage() {
|
|
6303
|
+
return salla.url.is_page('cart');
|
|
6304
|
+
}
|
|
6305
|
+
renderCartPage() {
|
|
6306
|
+
return h("salla-multiple-bundle-product-cart", { sections: this.parsedSections });
|
|
6307
|
+
}
|
|
6308
|
+
renderDetailsPage() {
|
|
6309
|
+
return h("salla-multiple-bundle-product-details", { sections: this.parsedSections });
|
|
6310
|
+
}
|
|
6311
|
+
componentWillLoad() {
|
|
6312
|
+
this.parseProducts(this.bundleSections);
|
|
6313
|
+
}
|
|
6314
|
+
render() {
|
|
6315
|
+
return (h(Host, { key: '6f9e20c6db0c7d79f84ba197f015f43c1b0a79fc', class: "s-multiple-bundle-product-wrapper" }, this.isCartPage() ? this.renderCartPage() : this.renderDetailsPage()));
|
|
6316
|
+
}
|
|
6317
|
+
static get watchers() { return {
|
|
6318
|
+
"bundleSections": ["parseProducts"]
|
|
6319
|
+
}; }
|
|
6320
|
+
};
|
|
6321
|
+
SallaMultipleBundleProduct.style = sallaMultipleBundleProductCss;
|
|
5855
6322
|
|
|
5856
|
-
const
|
|
6323
|
+
const sallaMultipleBundleProductCartCss = "";
|
|
5857
6324
|
|
|
5858
|
-
const
|
|
6325
|
+
const SallaMultipleBundleProductCart = class {
|
|
5859
6326
|
constructor(hostRef) {
|
|
5860
6327
|
registerInstance(this, hostRef);
|
|
5861
|
-
this.
|
|
5862
|
-
this.
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
salla.log('User selected to don\'t show this offer again.');
|
|
5876
|
-
return;
|
|
6328
|
+
this.sections = [];
|
|
6329
|
+
this.itemNumber = '';
|
|
6330
|
+
}
|
|
6331
|
+
deleteItem(sectionId, product) {
|
|
6332
|
+
const form = this.host.closest('form');
|
|
6333
|
+
if (form) {
|
|
6334
|
+
const formId = form.getAttribute('id');
|
|
6335
|
+
if (formId && typeof formId === 'string') {
|
|
6336
|
+
const itemNumber = formId.match(/item-(\d+)/)?.[1];
|
|
6337
|
+
this.itemNumber = itemNumber || '';
|
|
6338
|
+
const selectedAccordion = this.host.querySelector(`#accordion-${product.id}`);
|
|
6339
|
+
salla.cart
|
|
6340
|
+
.deleteItem(`${this.itemNumber}?product_id=${product.id}§ion_id=${sectionId}`)
|
|
6341
|
+
.then(() => selectedAccordion?.remove());
|
|
5877
6342
|
}
|
|
5878
|
-
|
|
5879
|
-
});
|
|
6343
|
+
}
|
|
5880
6344
|
}
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
* @param offer - The offer being viewed in the modal
|
|
5884
|
-
*/
|
|
5885
|
-
emitPromotionViewed(offer) {
|
|
5886
|
-
if (!offer)
|
|
5887
|
-
return;
|
|
5888
|
-
salla.event.emit('promotion::viewed', [{
|
|
5889
|
-
id: offer.id?.toString(),
|
|
5890
|
-
creative: offer.message,
|
|
5891
|
-
name: offer.name,
|
|
5892
|
-
position: `${this.offer_type}_offer_modal`
|
|
5893
|
-
}]);
|
|
6345
|
+
renderRemoveButton(sectionId, product, isText = false) {
|
|
6346
|
+
return (h("salla-button", { type: "button", shape: isText ? 'btn' : 'icon', fill: isText ? 'outline' : 'solid', size: "small", color: "danger", "aria-label": "Remove from the cart", onClick: () => this.deleteItem(sectionId, product) }, isText ? salla.lang.get('common.elements.delete') : h("i", { class: "sicon-cancel" })));
|
|
5894
6347
|
}
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
*/
|
|
5899
|
-
emitPromotionClicked(offer) {
|
|
5900
|
-
if (!offer)
|
|
5901
|
-
return;
|
|
5902
|
-
salla.event.emit('promotion::clicked', [{
|
|
5903
|
-
id: offer.id?.toString(),
|
|
5904
|
-
creative: offer.message,
|
|
5905
|
-
name: offer.name,
|
|
5906
|
-
position: `${this.offer_type}_offer_modal`
|
|
5907
|
-
}]);
|
|
6348
|
+
renderAccordionHeader(sectionId, product) {
|
|
6349
|
+
const hasOptions = product?.options && product?.options?.length > 0; // undefined or empty array
|
|
6350
|
+
return (h("div", { slot: "html", class: "s-multiple-bundle-product-cart-header-wrapper" }, h("div", { class: `s-multiple-bundle-product-cart-header ${hasOptions ? '' : 's-multiple-bundle-product-cart-header-no-options'}` }, h("div", { class: "s-multiple-bundle-product-cart-header-content" }, h("a", { href: product?.url, class: "s-multiple-bundle-product-cart-header-image-wrapper" }, h("img", { src: product?.image?.url, alt: product?.image?.alt || product?.name, class: "s-multiple-bundle-product-cart-header-image" })), h("div", { class: "s-multiple-bundle-product-cart-header-content-details" }, h("h2", { class: "s-multiple-bundle-product-cart-header-content-details-title" }, h("a", { href: product?.url, class: "s-multiple-bundle-product-cart-header-content-details-title-link" }, product?.name)), h("div", { class: "s-multiple-bundle-product-cart-header-content-details-price" }, h("span", { class: "s-multiple-bundle-product-cart-header-content-details-price-regular" }, h("span", { innerHTML: product?.price ? salla.money(product?.price) : '' })), product?.sale_price > 0 && (h("span", { class: "s-multiple-bundle-product-cart-header-content-details-price-sale" }, h("span", { innerHTML: salla.money(product?.sale_price) })))), product?.quantity_in_group > 0 && product?.quantity !== 0 && (h("p", { class: "s-multiple-bundle-product-cart-header-content-details-quantity" }, h("span", null, salla.lang.get('pages.products.number_of_pieces')), h("span", null, product?.quantity_in_group))))), !hasOptions && (h("div", { class: "s-multiple-bundle-product-cart-header-remove-button" }, this.renderRemoveButton(sectionId, product, false))))));
|
|
5908
6351
|
}
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
6352
|
+
render() {
|
|
6353
|
+
return (h(Host, { key: 'b9542b8e0cc7705e6bbd9dc17db8284c11d27846', class: "s-multiple-bundle-product-wrapper" }, h("div", { key: '44bfe630604e8d45aa1218eebcdf026b47f9fd99', class: "s-multiple-bundle-product-wrapper-sections" }, this.sections.map((section, sectionIndex) => {
|
|
6354
|
+
return section.products.map(product => {
|
|
6355
|
+
const bundleContext = {
|
|
6356
|
+
sectionId: section.id,
|
|
6357
|
+
sectionIndex: sectionIndex,
|
|
6358
|
+
productId: product.id,
|
|
6359
|
+
};
|
|
6360
|
+
return (h("salla-accordion", { key: product.id, collapsed: false, bordered: true, collapsible: product.options && product.options.length > 0 ? true : false, size: "sm", id: `accordion-${product.id}` }, h("salla-accordion-head", null, this.renderAccordionHeader(String(section.id), product)), product.options && product.options.length > 0 && (h("salla-accordion-body", null, h("salla-product-options", { options: JSON.stringify(product.options), key: `${product.id}-persistent`, "product-id": product.id, "bundle-context": JSON.stringify(bundleContext) }), h("div", { class: "s-multiple-bundle-product-cart-body-remove-button" }, this.renderRemoveButton(String(section.id), product, true))))));
|
|
6361
|
+
});
|
|
6362
|
+
}))));
|
|
6363
|
+
}
|
|
6364
|
+
get host() { return getElement(this); }
|
|
6365
|
+
};
|
|
6366
|
+
SallaMultipleBundleProductCart.style = sallaMultipleBundleProductCartCss;
|
|
6367
|
+
|
|
6368
|
+
const sallaMultipleBundleProductDetailsCss = "";
|
|
6369
|
+
|
|
6370
|
+
const SallaMultipleBundleProductDetails = class {
|
|
6371
|
+
constructor(hostRef) {
|
|
6372
|
+
registerInstance(this, hostRef);
|
|
6373
|
+
this.sections = [];
|
|
6374
|
+
// store selected product IDs per section (can be string or number)
|
|
6375
|
+
this.selectedProducts = {};
|
|
6376
|
+
// Event handler reference for cleanup
|
|
6377
|
+
this.productSelectedHandler = null;
|
|
6378
|
+
// handle selecting a product (toggle)
|
|
6379
|
+
this.onSelectProduct = (sectionId, product) => {
|
|
6380
|
+
this.selectedProducts = {
|
|
6381
|
+
...this.selectedProducts,
|
|
6382
|
+
[sectionId]: new Set(this.selectedProducts[sectionId] || []),
|
|
6383
|
+
};
|
|
6384
|
+
const productId = product.id;
|
|
6385
|
+
const wasSelected = this.selectedProducts[sectionId].has(productId);
|
|
6386
|
+
if (wasSelected) {
|
|
6387
|
+
// Product is being deselected
|
|
6388
|
+
this.selectedProducts[sectionId].delete(productId);
|
|
6389
|
+
// Clear form data and modal options for this product in this specific section
|
|
6390
|
+
this.clearProductFormData(productId, sectionId);
|
|
6391
|
+
this.clearProductModalOptions(productId);
|
|
6392
|
+
}
|
|
6393
|
+
else {
|
|
6394
|
+
// Product is being selected
|
|
6395
|
+
this.selectedProducts[sectionId].add(productId);
|
|
6396
|
+
}
|
|
6397
|
+
// force re-render
|
|
6398
|
+
this.selectedProducts = { ...this.selectedProducts };
|
|
6399
|
+
// still dispatch event
|
|
6400
|
+
salla.event.dispatch('on-bundle-product-selected', {
|
|
6401
|
+
id: product.id,
|
|
6402
|
+
name: product.name,
|
|
6403
|
+
options: product.options,
|
|
6404
|
+
wasSelected: wasSelected,
|
|
6405
|
+
isSelected: !wasSelected,
|
|
6406
|
+
});
|
|
6407
|
+
};
|
|
6408
|
+
// ensure product is selected (only add if not already selected)
|
|
6409
|
+
this.ensureProductSelected = (sectionId, product) => {
|
|
6410
|
+
this.selectedProducts = {
|
|
6411
|
+
...this.selectedProducts,
|
|
6412
|
+
[sectionId]: new Set(this.selectedProducts[sectionId] || []),
|
|
6413
|
+
};
|
|
6414
|
+
const productId = product.id;
|
|
6415
|
+
// Only add if not already selected
|
|
6416
|
+
if (!this.selectedProducts[sectionId].has(productId)) {
|
|
6417
|
+
this.selectedProducts[sectionId].add(productId);
|
|
6418
|
+
// force re-render
|
|
6419
|
+
this.selectedProducts = { ...this.selectedProducts };
|
|
6420
|
+
// dispatch event
|
|
6421
|
+
salla.event.dispatch('on-bundle-product-selected', {
|
|
6422
|
+
id: product.id,
|
|
6423
|
+
name: product.name,
|
|
6424
|
+
options: product.options,
|
|
6425
|
+
});
|
|
6426
|
+
}
|
|
6427
|
+
};
|
|
6428
|
+
// open product options modal
|
|
6429
|
+
this.onSelectProductOptions = (product, sectionId) => {
|
|
6430
|
+
// Find the section index from the sectionId
|
|
6431
|
+
const sectionIndex = this.sections.findIndex(section => section.id == sectionId);
|
|
6432
|
+
// Find the product index within the section
|
|
6433
|
+
const section = this.sections.find(section => section.id == sectionId);
|
|
6434
|
+
const productIndex = section?.products?.findIndex(p => p.id == product.id) ?? 0;
|
|
6435
|
+
salla.event.dispatch('multiple-bundle-product-modal::open', {
|
|
6436
|
+
product,
|
|
6437
|
+
sectionId,
|
|
6438
|
+
sectionIndex,
|
|
6439
|
+
productIndex,
|
|
6440
|
+
});
|
|
6441
|
+
};
|
|
6442
|
+
// Event handlers for bundle slider component
|
|
6443
|
+
this.handleBundleSliderProductSelected = (event) => {
|
|
6444
|
+
const { product, sectionId } = event.detail;
|
|
6445
|
+
this.onSelectProduct(sectionId, product);
|
|
6446
|
+
};
|
|
6447
|
+
this.handleBundleSliderProductOptionsSelected = (event) => {
|
|
6448
|
+
const { product, sectionId } = event.detail;
|
|
6449
|
+
this.onSelectProductOptions(product, sectionId);
|
|
6450
|
+
};
|
|
6451
|
+
}
|
|
6452
|
+
// Clear form data for a specific product in specific section
|
|
6453
|
+
clearProductFormData(productId, sectionId) {
|
|
6454
|
+
const form = this.host.closest('form');
|
|
6455
|
+
if (sectionId) {
|
|
6456
|
+
// Remove inputs for specific section/productIndex combination
|
|
6457
|
+
const productInputPattern = `bundle[${sectionId}][`;
|
|
6458
|
+
const inputsToRemove = Array.from(form.querySelectorAll('input')).filter((input) => input.getAttribute('data-product-id') === String(productId) &&
|
|
6459
|
+
input.name &&
|
|
6460
|
+
input.name.startsWith(productInputPattern));
|
|
6461
|
+
inputsToRemove.forEach(input => input.remove());
|
|
6462
|
+
}
|
|
6463
|
+
else {
|
|
6464
|
+
// Fallback: Remove all hidden inputs related to this product (legacy behavior)
|
|
6465
|
+
const inputsToRemove = form.querySelectorAll(`[data-product-id="${productId}"]`);
|
|
6466
|
+
inputsToRemove.forEach(input => input.remove());
|
|
6467
|
+
}
|
|
6468
|
+
}
|
|
6469
|
+
// Clear modal options state for a specific product
|
|
6470
|
+
clearProductModalOptions(productId) {
|
|
6471
|
+
// Emit event to notify modal to reset its state for this product
|
|
6472
|
+
salla.event.dispatch('multiple-bundle-product-modal::clear-options', {
|
|
6473
|
+
productId,
|
|
6474
|
+
});
|
|
6475
|
+
}
|
|
6476
|
+
renderAccordionHeader(section, selectedCount) {
|
|
6477
|
+
return (h(Fragment, null, h("h2", { slot: "title" }, section?.name), section?.obligatory_products && (h("span", { slot: "note" }, salla.lang.get('pages.products.obligatory_products', {
|
|
6478
|
+
count: section?.obligatory_products || 0,
|
|
6479
|
+
}))), h("span", { slot: "progress" }, selectedCount, "/", section?.products?.length || 0)));
|
|
6480
|
+
}
|
|
6481
|
+
componentDidLoad() {
|
|
6482
|
+
// Listen for product selected event from modal
|
|
6483
|
+
const modal = this.host.querySelector('salla-multiple-bundle-product-options-modal');
|
|
6484
|
+
if (modal) {
|
|
6485
|
+
this.productSelectedHandler = (e) => {
|
|
6486
|
+
const { productId, sectionId, product, fromModal } = e.detail;
|
|
6487
|
+
if (fromModal) {
|
|
6488
|
+
// When called from modal, only add to selection if not already selected
|
|
6489
|
+
this.ensureProductSelected(sectionId, product || { id: productId });
|
|
6490
|
+
}
|
|
6491
|
+
else {
|
|
6492
|
+
// Normal toggle behavior
|
|
6493
|
+
this.onSelectProduct(sectionId, product || { id: productId });
|
|
6494
|
+
}
|
|
6495
|
+
};
|
|
6496
|
+
modal.addEventListener('productSelected', this.productSelectedHandler);
|
|
6497
|
+
}
|
|
6498
|
+
}
|
|
6499
|
+
disconnectedCallback() {
|
|
6500
|
+
// Clean up event listener to prevent memory leaks
|
|
6501
|
+
if (this.productSelectedHandler) {
|
|
6502
|
+
const modal = this.host.querySelector('salla-multiple-bundle-product-options-modal');
|
|
6503
|
+
if (modal) {
|
|
6504
|
+
modal.removeEventListener('productSelected', this.productSelectedHandler);
|
|
6505
|
+
}
|
|
6506
|
+
this.productSelectedHandler = null;
|
|
6507
|
+
}
|
|
6508
|
+
}
|
|
6509
|
+
render() {
|
|
6510
|
+
return (h(Host, { key: '0a24e2c3ee4bdff3891334a49318a7cfeb668d54', class: "s-multiple-bundle-product-wrapper" }, h("div", { key: '713f1b101aed42cabacd17d662aad49520b89f4b', class: "s-multiple-bundle-product-wrapper-sections" }, this.sections.map((section, index) => {
|
|
6511
|
+
const selectedCount = this.selectedProducts[section.id]?.size || 0;
|
|
6512
|
+
return (h("salla-accordion", { key: section.id, collapsed: index === 1 ? true : false }, h("salla-accordion-head", null, this.renderAccordionHeader(section, selectedCount)), h("salla-accordion-body", null, h("salla-multiple-bundle-product-slider", { section: section, sectionIndex: index, selectedProducts: this.selectedProducts, onProductSelected: this.handleBundleSliderProductSelected, onProductOptionsSelected: this.handleBundleSliderProductOptionsSelected }))));
|
|
6513
|
+
})), h("salla-multiple-bundle-product-options-modal", { key: '2d889aa72a36040f87cd791363f71600d86458e7' })));
|
|
6514
|
+
}
|
|
6515
|
+
get host() { return getElement(this); }
|
|
6516
|
+
};
|
|
6517
|
+
SallaMultipleBundleProductDetails.style = sallaMultipleBundleProductDetailsCss;
|
|
6518
|
+
|
|
6519
|
+
const sallaMultipleBundleProductOptionsModalCss = ":host{display:block}";
|
|
6520
|
+
|
|
6521
|
+
const SallaMultipleBundleProductOptionsModal = class {
|
|
6522
|
+
constructor(hostRef) {
|
|
6523
|
+
registerInstance(this, hostRef);
|
|
6524
|
+
this.optionsSaved = createEvent(this, "optionsSaved");
|
|
6525
|
+
this.productSelected = createEvent(this, "productSelected");
|
|
6526
|
+
this.product = null;
|
|
6527
|
+
this.sectionId = null;
|
|
6528
|
+
this.sectionIndex = 0;
|
|
6529
|
+
this.productIndex = 0;
|
|
6530
|
+
this.selectedOptions = {};
|
|
6531
|
+
this.isLoading = false;
|
|
6532
|
+
this.hasUnsavedChanges = false;
|
|
6533
|
+
this.validationErrors = [];
|
|
6534
|
+
}
|
|
6535
|
+
/**
|
|
6536
|
+
* Generate a unique cache key for selected options using section ID, product index, and product ID
|
|
6537
|
+
*/
|
|
6538
|
+
generateCacheKey(sectionId, productIndex, productId) {
|
|
6539
|
+
return `${sectionId || 'unknown'}-${productIndex || 0}-${productId || 'unknown'}`;
|
|
6540
|
+
}
|
|
6541
|
+
handleProductChange(newValue) {
|
|
6542
|
+
// Use setTimeout to ensure modal is ready
|
|
6543
|
+
setTimeout(() => {
|
|
6544
|
+
if (this.modal && newValue) {
|
|
6545
|
+
const title = newValue.name || '';
|
|
6546
|
+
this.modal.setTitle(title);
|
|
6547
|
+
}
|
|
6548
|
+
}, 100);
|
|
6549
|
+
// Reset validation errors when product changes
|
|
6550
|
+
this.validationErrors = [];
|
|
6551
|
+
this.hasUnsavedChanges = false;
|
|
6552
|
+
}
|
|
6553
|
+
async open() {
|
|
6554
|
+
if (!this.modal) {
|
|
6555
|
+
requestAnimationFrame(() => this.open());
|
|
6556
|
+
return;
|
|
6557
|
+
}
|
|
6558
|
+
this.isLoading = true;
|
|
6559
|
+
// Set the title before opening
|
|
6560
|
+
if (this.product?.name) {
|
|
6561
|
+
this.modal.setTitle(this.product.name);
|
|
6562
|
+
}
|
|
6563
|
+
this.modal.open();
|
|
6564
|
+
// Initialize selectedOptions with current selections from the component
|
|
6565
|
+
setTimeout(async () => {
|
|
6566
|
+
if (this.product?.id) {
|
|
6567
|
+
await this.initializeSelectedOptions();
|
|
6568
|
+
}
|
|
6569
|
+
// Set title again after modal is fully loaded
|
|
6570
|
+
if (this.product?.name) {
|
|
6571
|
+
this.modal.setTitle(this.product.name);
|
|
6572
|
+
}
|
|
6573
|
+
this.modal.stopLoading();
|
|
6574
|
+
this.isLoading = false;
|
|
6575
|
+
}, 300);
|
|
6576
|
+
}
|
|
6577
|
+
async close() {
|
|
6578
|
+
if (this.modal) {
|
|
6579
|
+
this.modal.close();
|
|
6580
|
+
}
|
|
6581
|
+
}
|
|
6582
|
+
async refreshOptionsState() {
|
|
6583
|
+
// Force re-render by updating the component state
|
|
6584
|
+
this.selectedOptions = { ...this.selectedOptions };
|
|
6585
|
+
}
|
|
6586
|
+
componentDidLoad() {
|
|
6587
|
+
salla.event.on('multiple-bundle-product-modal::open', (data) => {
|
|
6588
|
+
this.product = data.product;
|
|
6589
|
+
this.sectionId = data.sectionId || null;
|
|
6590
|
+
this.sectionIndex = data.sectionIndex || 0;
|
|
6591
|
+
this.productIndex = data.productIndex || 0;
|
|
6592
|
+
this.open();
|
|
6593
|
+
});
|
|
6594
|
+
// Listen for clear-options event when a product is deselected
|
|
6595
|
+
salla.event.on('multiple-bundle-product-modal::clear-options', (data) => {
|
|
6596
|
+
this.clearProductOptions(data.productId);
|
|
6597
|
+
});
|
|
6598
|
+
// Create and store the option change listener for proper cleanup
|
|
6599
|
+
this.optionChangeListener = (e) => {
|
|
6600
|
+
const { productId, option, detail } = e.detail;
|
|
6601
|
+
// Convert productId to the same type as our product ID
|
|
6602
|
+
const normalizedProductId = this.product?.id ? String(this.product.id) : null;
|
|
6603
|
+
const normalizedEventProductId = productId ? String(productId) : null;
|
|
6604
|
+
// Only handle events for the current product
|
|
6605
|
+
if (normalizedProductId &&
|
|
6606
|
+
normalizedEventProductId &&
|
|
6607
|
+
normalizedProductId === normalizedEventProductId &&
|
|
6608
|
+
option &&
|
|
6609
|
+
detail) {
|
|
6610
|
+
this.handleOptionChange(Number(normalizedProductId), option, detail);
|
|
6611
|
+
}
|
|
6612
|
+
};
|
|
6613
|
+
salla.event.on('product-options::change', this.optionChangeListener);
|
|
6614
|
+
// Create and store the checkbox change listener for proper cleanup
|
|
6615
|
+
this.checkboxChangeListener = (e) => {
|
|
6616
|
+
const target = e.target;
|
|
6617
|
+
// Check if this is a product selection checkbox
|
|
6618
|
+
if (target && target.type === 'checkbox' && target.name && target.name.includes('bundle[') && target.name.includes('][id]')) {
|
|
6619
|
+
// Extract section info from the checkbox name: bundle[sectionId][productIndex][id]
|
|
6620
|
+
const nameMatch = target.name.match(/^bundle\[([^\]]+)\]\[([^\]]+)\]\[id\]$/);
|
|
6621
|
+
if (nameMatch && !target.checked) {
|
|
6622
|
+
// Product was deselected, clear its cached options
|
|
6623
|
+
const [, sectionId, productIndex] = nameMatch;
|
|
6624
|
+
const productId = target.value;
|
|
6625
|
+
// Prevent the immediate event to ensure cleanup happens first
|
|
6626
|
+
e.preventDefault();
|
|
6627
|
+
e.stopPropagation();
|
|
6628
|
+
// Ensure the checkbox is actually unchecked
|
|
6629
|
+
target.checked = false;
|
|
6630
|
+
// Generate the same cache key used by the modal
|
|
6631
|
+
const cacheKey = this.generateCacheKey(sectionId, parseInt(productIndex), productId);
|
|
6632
|
+
// Clear the cached options for this product
|
|
6633
|
+
const updatedSelectedOptions = { ...this.selectedOptions };
|
|
6634
|
+
delete updatedSelectedOptions[cacheKey];
|
|
6635
|
+
this.selectedOptions = updatedSelectedOptions;
|
|
6636
|
+
// Force re-render of the modal if it's currently open for this product
|
|
6637
|
+
if (this.product && this.product.id == productId) {
|
|
6638
|
+
this.selectedOptions = { ...this.selectedOptions };
|
|
6639
|
+
}
|
|
6640
|
+
const form = this.host.closest('form');
|
|
6641
|
+
if (form) {
|
|
6642
|
+
const productInputPattern = `bundle[${sectionId}][${productIndex}]`;
|
|
6643
|
+
// Get all form inputs and filter manually
|
|
6644
|
+
const allInputs = Array.from(form.querySelectorAll('input'));
|
|
6645
|
+
const matchingInputs = allInputs.filter(input => input.name && input.name.startsWith(productInputPattern));
|
|
6646
|
+
// Process matching inputs for removal
|
|
6647
|
+
matchingInputs.forEach(el => {
|
|
6648
|
+
// Don't remove the visible checkbox that was just unchecked
|
|
6649
|
+
if (el !== target && (el.type === 'hidden' || el.hasAttribute('data-product-id'))) {
|
|
6650
|
+
el.remove();
|
|
6651
|
+
}
|
|
6652
|
+
});
|
|
6653
|
+
// Method 2: Find inputs by data-product-id BUT only within the same section/productIndex
|
|
6654
|
+
const dataProductInputs = allInputs.filter(input => {
|
|
6655
|
+
// Must have data-product-id matching the productId
|
|
6656
|
+
if (input.getAttribute('data-product-id') !== String(productId)) {
|
|
6657
|
+
return false;
|
|
6658
|
+
}
|
|
6659
|
+
// Must also be within the same section/productIndex pattern
|
|
6660
|
+
return input.name && input.name.startsWith(productInputPattern);
|
|
6661
|
+
});
|
|
6662
|
+
// Process inputs with matching section/productIndex and productId for removal
|
|
6663
|
+
dataProductInputs.forEach(el => {
|
|
6664
|
+
if (el !== target) {
|
|
6665
|
+
el.remove();
|
|
6666
|
+
}
|
|
6667
|
+
});
|
|
6668
|
+
// Method 3: Removed broader search to prevent removing inputs from other products
|
|
6669
|
+
// The cleanup is now more precise and only removes inputs for the specific product
|
|
6670
|
+
// Trigger form change event after cleanup is complete
|
|
6671
|
+
setTimeout(() => {
|
|
6672
|
+
const changeEvent = new window.Event('change', { bubbles: true });
|
|
6673
|
+
form.dispatchEvent(changeEvent);
|
|
6674
|
+
}, 50); // Small delay to ensure cleanup is complete
|
|
6675
|
+
}
|
|
6676
|
+
}
|
|
6677
|
+
}
|
|
6678
|
+
};
|
|
6679
|
+
// Listen for product checkbox changes to reset options when product is deselected
|
|
6680
|
+
document.addEventListener('change', this.checkboxChangeListener);
|
|
6681
|
+
}
|
|
6682
|
+
disconnectedCallback() {
|
|
6683
|
+
// Clean up event listeners to prevent memory leaks
|
|
6684
|
+
if (this.checkboxChangeListener) {
|
|
6685
|
+
document.removeEventListener('change', this.checkboxChangeListener);
|
|
6686
|
+
}
|
|
6687
|
+
}
|
|
6688
|
+
generateFormInputName(sectionId, productIndex, optionParentId) {
|
|
6689
|
+
return `bundle[${sectionId}][${productIndex}][options][${optionParentId}]`;
|
|
6690
|
+
}
|
|
6691
|
+
async initializeSelectedOptions() {
|
|
6692
|
+
if (!this.product?.id)
|
|
6693
|
+
return;
|
|
6694
|
+
const productId = this.product.id;
|
|
6695
|
+
const cacheKey = this.generateCacheKey(this.sectionId, this.productIndex, productId);
|
|
6696
|
+
const optionsEl = document.querySelector(`salla-product-options[product-id="${productId}"]`);
|
|
6697
|
+
if (optionsEl) {
|
|
6698
|
+
try {
|
|
6699
|
+
const selectedOptions = await optionsEl.getSelectedOptions();
|
|
6700
|
+
if (selectedOptions && selectedOptions.length > 0) {
|
|
6701
|
+
this.selectedOptions = {
|
|
6702
|
+
...this.selectedOptions,
|
|
6703
|
+
[cacheKey]: selectedOptions,
|
|
6704
|
+
};
|
|
6705
|
+
}
|
|
6706
|
+
}
|
|
6707
|
+
catch (e) {
|
|
6708
|
+
console.warn('Could not initialize selected options:', e);
|
|
6709
|
+
}
|
|
6710
|
+
}
|
|
6711
|
+
}
|
|
6712
|
+
// Clear options state for a specific product
|
|
6713
|
+
clearProductOptions(productId) {
|
|
6714
|
+
// Generate cache key for this specific product in current section context
|
|
6715
|
+
const cacheKey = this.generateCacheKey(this.sectionId, this.productIndex, productId);
|
|
6716
|
+
// Remove the product from selectedOptions using the cache key
|
|
6717
|
+
const updatedSelectedOptions = { ...this.selectedOptions };
|
|
6718
|
+
delete updatedSelectedOptions[cacheKey];
|
|
6719
|
+
this.selectedOptions = updatedSelectedOptions;
|
|
6720
|
+
// Reset validation errors and unsaved changes
|
|
6721
|
+
this.validationErrors = [];
|
|
6722
|
+
this.hasUnsavedChanges = false;
|
|
6723
|
+
}
|
|
6724
|
+
async handleOptionChange(productId, option, detail) {
|
|
6725
|
+
const cacheKey = this.generateCacheKey(this.sectionId, this.productIndex, productId);
|
|
6726
|
+
// Get the current state from the component to ensure we have the latest selections
|
|
6727
|
+
const optionsEl = document.querySelector(`salla-product-options[product-id="${productId}"]`);
|
|
6728
|
+
let currentComponentSelections = [];
|
|
6729
|
+
if (optionsEl) {
|
|
6730
|
+
try {
|
|
6731
|
+
currentComponentSelections = (await optionsEl.getSelectedOptions()) || [];
|
|
6732
|
+
}
|
|
6733
|
+
catch (e) {
|
|
6734
|
+
console.warn('Could not get current selections from component:', e);
|
|
6735
|
+
}
|
|
6736
|
+
}
|
|
6737
|
+
// If component returns data, use it; otherwise, fall back to manual tracking
|
|
6738
|
+
if (currentComponentSelections.length > 0) {
|
|
6739
|
+
// Component returned data, use it
|
|
6740
|
+
this.selectedOptions = {
|
|
6741
|
+
...this.selectedOptions,
|
|
6742
|
+
[cacheKey]: currentComponentSelections,
|
|
6743
|
+
};
|
|
6744
|
+
}
|
|
6745
|
+
else {
|
|
6746
|
+
// If we have existing selections in internal state and component returns empty,
|
|
6747
|
+
// it might be a deselection, so we should use manual tracking
|
|
6748
|
+
if (this.selectedOptions[cacheKey] && this.selectedOptions[cacheKey].length > 0) {
|
|
6749
|
+
// Component didn't return data, use manual tracking
|
|
6750
|
+
const currentSelected = this.selectedOptions[cacheKey] || [];
|
|
6751
|
+
const updatedSelected = [...currentSelected];
|
|
6752
|
+
// Find existing selection for this specific option (by option_id)
|
|
6753
|
+
const existingIndex = updatedSelected.findIndex(opt => opt.option_id === option.id);
|
|
6754
|
+
if (existingIndex > -1) {
|
|
6755
|
+
// Check if this is a deselection (detail might be null or undefined)
|
|
6756
|
+
if (!detail || detail.id === null || detail.id === undefined) {
|
|
6757
|
+
// Remove the option (deselection)
|
|
6758
|
+
updatedSelected.splice(existingIndex, 1);
|
|
6759
|
+
}
|
|
6760
|
+
else {
|
|
6761
|
+
// Replace existing selection for this option
|
|
6762
|
+
updatedSelected[existingIndex] = { ...detail, option_id: option.id };
|
|
6763
|
+
}
|
|
6764
|
+
}
|
|
6765
|
+
else {
|
|
6766
|
+
// Only add if detail exists (not a deselection)
|
|
6767
|
+
if (detail && detail.id !== null && detail.id !== undefined) {
|
|
6768
|
+
updatedSelected.push({ ...detail, option_id: option.id });
|
|
6769
|
+
}
|
|
6770
|
+
}
|
|
6771
|
+
this.selectedOptions = {
|
|
6772
|
+
...this.selectedOptions,
|
|
6773
|
+
[cacheKey]: updatedSelected,
|
|
6774
|
+
};
|
|
6775
|
+
}
|
|
6776
|
+
else {
|
|
6777
|
+
// No existing selections, component returned empty, and we're trying to add
|
|
6778
|
+
// This might be the first selection, so add it manually
|
|
6779
|
+
if (detail && detail.id !== null && detail.id !== undefined) {
|
|
6780
|
+
this.selectedOptions = {
|
|
6781
|
+
...this.selectedOptions,
|
|
6782
|
+
[cacheKey]: [{ ...detail, option_id: option.id }],
|
|
6783
|
+
};
|
|
6784
|
+
}
|
|
6785
|
+
}
|
|
6786
|
+
}
|
|
6787
|
+
this.hasUnsavedChanges = true;
|
|
6788
|
+
this.validationErrors = []; // Clear validation errors when user makes changes
|
|
6789
|
+
}
|
|
6790
|
+
async validateOptions() {
|
|
6791
|
+
if (!this.product?.options)
|
|
6792
|
+
return true;
|
|
6793
|
+
const errors = [];
|
|
6794
|
+
const productId = this.product.id;
|
|
6795
|
+
const cacheKey = this.generateCacheKey(this.sectionId, this.productIndex, productId);
|
|
6796
|
+
// Get the actual selected options from the component
|
|
6797
|
+
const optionsEl = document.querySelector(`salla-product-options[product-id="${productId}"]`);
|
|
6798
|
+
let currentSelected = [];
|
|
6799
|
+
if (optionsEl) {
|
|
6800
|
+
try {
|
|
6801
|
+
currentSelected = (await optionsEl.getSelectedOptions()) || [];
|
|
6802
|
+
// Also check our internal state as fallback
|
|
6803
|
+
const internalSelected = this.selectedOptions[cacheKey] || [];
|
|
6804
|
+
// Use whichever has more selections, or if component returns empty but internal has data, use internal
|
|
6805
|
+
if (internalSelected.length > currentSelected.length ||
|
|
6806
|
+
(currentSelected.length === 0 && internalSelected.length > 0)) {
|
|
6807
|
+
currentSelected = internalSelected;
|
|
6808
|
+
}
|
|
6809
|
+
}
|
|
6810
|
+
catch (e) {
|
|
6811
|
+
// Fallback to internal state
|
|
6812
|
+
currentSelected = this.selectedOptions[cacheKey] || [];
|
|
6813
|
+
}
|
|
6814
|
+
}
|
|
6815
|
+
else {
|
|
6816
|
+
// Fallback to internal state
|
|
6817
|
+
currentSelected = this.selectedOptions[cacheKey] || [];
|
|
6818
|
+
}
|
|
6819
|
+
// Check if any options are selected at all
|
|
6820
|
+
if (currentSelected.length === 0) {
|
|
6821
|
+
errors.push(salla.lang.get('pages.products.no_options_selected'));
|
|
6822
|
+
}
|
|
6823
|
+
// Check required options
|
|
6824
|
+
this.product.options.forEach(option => {
|
|
6825
|
+
if (option.required) {
|
|
6826
|
+
const hasSelection = currentSelected.some(selected => {
|
|
6827
|
+
return selected.option_id == option.id; // Use == instead of === for type flexibility
|
|
6828
|
+
});
|
|
6829
|
+
if (!hasSelection) {
|
|
6830
|
+
errors.push(salla.lang.get('pages.products.required_option_missing', {
|
|
6831
|
+
option: option.name,
|
|
6832
|
+
}));
|
|
6833
|
+
}
|
|
6834
|
+
}
|
|
6835
|
+
});
|
|
6836
|
+
this.validationErrors = errors;
|
|
6837
|
+
return errors.length === 0;
|
|
6838
|
+
}
|
|
6839
|
+
async onSave(e) {
|
|
6840
|
+
e.preventDefault();
|
|
6841
|
+
const productId = this.product?.id;
|
|
6842
|
+
if (!productId)
|
|
6843
|
+
return;
|
|
6844
|
+
const cacheKey = this.generateCacheKey(this.sectionId, this.productIndex, productId);
|
|
6845
|
+
// Small delay to ensure component state is updated
|
|
6846
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
6847
|
+
// Validate options before saving
|
|
6848
|
+
const isValid = await this.validateOptions();
|
|
6849
|
+
if (!isValid) {
|
|
6850
|
+
salla.notify.error(this.validationErrors.join(', '));
|
|
6851
|
+
return;
|
|
6852
|
+
}
|
|
6853
|
+
this.isLoading = true;
|
|
6854
|
+
try {
|
|
6855
|
+
// please don't change this with this.host.querySelector it will return null
|
|
6856
|
+
const optionsEl = document.querySelector(`salla-product-options[product-id="${productId}"]`);
|
|
6857
|
+
let selectedOptions = await optionsEl?.getSelectedOptions();
|
|
6858
|
+
// If component returns empty but we have internal state, use internal state
|
|
6859
|
+
if ((!selectedOptions || selectedOptions.length === 0) &&
|
|
6860
|
+
this.selectedOptions[cacheKey]?.length > 0) {
|
|
6861
|
+
selectedOptions = this.selectedOptions[cacheKey];
|
|
6862
|
+
}
|
|
6863
|
+
if (!selectedOptions || selectedOptions.length === 0) {
|
|
6864
|
+
this.isLoading = false;
|
|
6865
|
+
return;
|
|
6866
|
+
}
|
|
6867
|
+
// Store the selected options for this product using cache key
|
|
6868
|
+
this.selectedOptions = {
|
|
6869
|
+
...this.selectedOptions,
|
|
6870
|
+
[cacheKey]: selectedOptions,
|
|
6871
|
+
};
|
|
6872
|
+
const form = this.host.closest('form');
|
|
6873
|
+
if (!form) {
|
|
6874
|
+
this.isLoading = false;
|
|
6875
|
+
return;
|
|
6876
|
+
}
|
|
6877
|
+
// remove old inputs for this specific product in this specific section/index only
|
|
6878
|
+
const productInputPattern = `bundle[${this.sectionId}][${this.productIndex}]`;
|
|
6879
|
+
// Remove only hidden inputs and inputs with data-product-id, but preserve visible checkboxes
|
|
6880
|
+
Array.from(form.querySelectorAll(`input[name^="${productInputPattern}"][type="hidden"]`)).forEach(el => el.remove());
|
|
6881
|
+
// Also remove any inputs with data-product-id that match this specific pattern
|
|
6882
|
+
Array.from(form.querySelectorAll(`[data-product-id="${productId}"][name^="${productInputPattern}"]`)).forEach(el => el.remove());
|
|
6883
|
+
// Ensure the actual checkbox in the UI is checked to reflect the selection visually
|
|
6884
|
+
const checkboxId = `bundle[${this.sectionId}][${this.productIndex}][id]`;
|
|
6885
|
+
const checkbox = document.getElementById(checkboxId);
|
|
6886
|
+
if (checkbox) {
|
|
6887
|
+
checkbox.checked = true;
|
|
6888
|
+
// Don't dispatch change event here to avoid double API calls
|
|
6889
|
+
}
|
|
6890
|
+
else {
|
|
6891
|
+
// If checkbox doesn't exist, create a hidden input as fallback
|
|
6892
|
+
const productSelectionInput = document.createElement('input');
|
|
6893
|
+
productSelectionInput.type = 'hidden';
|
|
6894
|
+
productSelectionInput.name = `bundle[${this.sectionId}][${this.productIndex}][id]`;
|
|
6895
|
+
productSelectionInput.value = String(productId);
|
|
6896
|
+
productSelectionInput.dataset.productId = String(productId);
|
|
6897
|
+
form.appendChild(productSelectionInput);
|
|
6898
|
+
}
|
|
6899
|
+
// append new hidden inputs for options
|
|
6900
|
+
selectedOptions.forEach((option) => {
|
|
6901
|
+
// how to get option parent id?
|
|
6902
|
+
const optionParentId = option.option_id;
|
|
6903
|
+
const hidden = document.createElement('input');
|
|
6904
|
+
hidden.type = 'hidden';
|
|
6905
|
+
// Use productIndex for the form input name
|
|
6906
|
+
hidden.name = this.generateFormInputName(this.sectionId, this.productIndex ?? 0, optionParentId);
|
|
6907
|
+
hidden.value = String(option.id);
|
|
6908
|
+
hidden.dataset.productId = String(productId);
|
|
6909
|
+
form.appendChild(hidden);
|
|
6910
|
+
});
|
|
6911
|
+
// Trigger single form change event with all updates (product selection + options)
|
|
6912
|
+
const changeEvent = new window.Event('change', { bubbles: true });
|
|
6913
|
+
form.dispatchEvent(changeEvent);
|
|
6914
|
+
// Emit custom event
|
|
6915
|
+
this.optionsSaved.emit({
|
|
6916
|
+
productId: Number(productId),
|
|
6917
|
+
selectedOptions,
|
|
6918
|
+
});
|
|
6919
|
+
// Emit product selected event to check the card
|
|
6920
|
+
if (this.sectionId) {
|
|
6921
|
+
this.productSelected.emit({
|
|
6922
|
+
productId: Number(productId),
|
|
6923
|
+
sectionId: this.sectionId,
|
|
6924
|
+
product: this.product,
|
|
6925
|
+
fromModal: true,
|
|
6926
|
+
});
|
|
6927
|
+
}
|
|
6928
|
+
// Show success message
|
|
6929
|
+
salla.notify.success(salla.lang.get('pages.products.options_saved'));
|
|
6930
|
+
this.hasUnsavedChanges = false;
|
|
6931
|
+
this.validationErrors = [];
|
|
6932
|
+
// close modal
|
|
6933
|
+
this.modal.close();
|
|
6934
|
+
}
|
|
6935
|
+
catch (error) {
|
|
6936
|
+
salla.notify.error(salla.lang.get('pages.products.options_save_error'));
|
|
6937
|
+
}
|
|
6938
|
+
finally {
|
|
6939
|
+
this.isLoading = false;
|
|
6940
|
+
}
|
|
6941
|
+
}
|
|
6942
|
+
// Method to get options with selected state preserved
|
|
6943
|
+
getOptionsWithSelectedState() {
|
|
6944
|
+
if (!this.product?.options)
|
|
6945
|
+
return [];
|
|
6946
|
+
const cacheKey = this.generateCacheKey(this.sectionId, this.productIndex, this.product.id);
|
|
6947
|
+
const savedOptions = this.selectedOptions[cacheKey] || [];
|
|
6948
|
+
return this.product.options.map(option => ({
|
|
6949
|
+
...option,
|
|
6950
|
+
details: option.details.map(detail => {
|
|
6951
|
+
const isSelected = savedOptions.some(saved => {
|
|
6952
|
+
return saved.id === detail.id;
|
|
6953
|
+
});
|
|
6954
|
+
return {
|
|
6955
|
+
...detail,
|
|
6956
|
+
is_selected: isSelected,
|
|
6957
|
+
};
|
|
6958
|
+
}),
|
|
6959
|
+
}));
|
|
6960
|
+
}
|
|
6961
|
+
render() {
|
|
6962
|
+
const productId = this.product?.id;
|
|
6963
|
+
const optionsWithSelectedState = this.getOptionsWithSelectedState();
|
|
6964
|
+
return (h(Host, { key: '52efc988e52036a0be8c5dfe7d9375aed2072b55' }, h("salla-modal", { key: 'e07dd856effc65a718528c6836884cd82520e94e', isLoading: this.isLoading, ref: el => (this.modal = el), width: "md", centered: false, id: `s-multiple-bundle-product-options-modal-options-${productId}`, class: "s-multiple-bundle-product-options-modal-wrapper" }, h("div", { key: '5365b7d796d48759a8cd0e7bb7e6cd755382afc8', slot: "loading" }, h("salla-skeleton", { key: 'deb66b5f95587584ade5581da3c891a95d3750af', height: "100%", width: "100%" })), this.product?.images && this.product?.images.length > 0 && (h("salla-slider", { key: 'e79b63e49ba9c29ef9d625ca99ffd17bbf282f79', id: `details-slider-${this.product?.id}`, type: "thumbs", loop: false, "auto-height": true, "listen-to-thumbnails-option": true, showThumbsControls: false, controlsOuter: false, showControls: false, class: "s-multiple-bundle-product-options-modal-slider", verticalThumbs: true, thumbsConfig: {
|
|
6965
|
+
centeredSlides: true,
|
|
6966
|
+
centeredSlidesBounds: true,
|
|
6967
|
+
slidesPerView: Math.min(5, Math.max(1, this.product?.images.length)),
|
|
6968
|
+
watchOverflow: true,
|
|
6969
|
+
watchSlidesVisibility: true,
|
|
6970
|
+
watchSlidesProgress: true,
|
|
6971
|
+
direction: 'vertical',
|
|
6972
|
+
spaceBetween: 10,
|
|
6973
|
+
} }, h("div", { key: '3c3f3d2a1de4869a0d2d15583630d04a400097d7', slot: "items" }, this.product?.images &&
|
|
6974
|
+
this.product?.images.map((image, index) => (h("div", { key: index, class: "swiper-slide" }, h("img", { src: image.url, alt: image.alt || `${this.product?.name} - Image ${index + 1}`, loading: "lazy", onError: e => {
|
|
6975
|
+
e.target.style.display = 'none';
|
|
6976
|
+
} }))))), this.product?.images && this.product?.images.length > 1 && (h("div", { key: '5d0f67677595c442d76f0fb3a42dacb1996e58db', slot: "thumbs" }, this.product?.images &&
|
|
6977
|
+
this.product?.images.map((image, index) => (h("div", { key: index, "data-caption": `${this.product?.name} - Image ${index + 1}` }, h("img", { src: image.url, loading: "eager", class: "s-multiple-bundle-product-options-modal-slider-thumb", title: `${this.product?.name} - ${index + 1}`, alt: image.alt || `${this.product?.name} - ${index + 1}`, onError: e => {
|
|
6978
|
+
e.target.style.display = 'none';
|
|
6979
|
+
} })))))))), h("salla-product-options", { options: JSON.stringify(optionsWithSelectedState), key: `${this.sectionId}-${this.sectionIndex}-${productId}-persistent`, "product-id": productId }), h("div", { key: '1f166bdaf78a78b99aeecc141e6f99b9fa1e50b1', slot: "footer" }, h("div", { key: 'e4ea869eaf9690ee3aba7319f976a82f8187767e', class: "s-multiple-bundle-product-options-modal-footer" }, h("salla-button", { key: '17e4f97284528019b25bd640ff3843dbbefb5dae', onClick: e => this.onSave(e), loading: this.isLoading, disabled: this.isLoading }, this.isLoading
|
|
6980
|
+
? salla.lang.get('common.elements.saving')
|
|
6981
|
+
: salla.lang.get('common.elements.save')))))));
|
|
6982
|
+
}
|
|
6983
|
+
get host() { return getElement(this); }
|
|
6984
|
+
static get watchers() { return {
|
|
6985
|
+
"product": ["handleProductChange"]
|
|
6986
|
+
}; }
|
|
6987
|
+
};
|
|
6988
|
+
SallaMultipleBundleProductOptionsModal.style = sallaMultipleBundleProductOptionsModalCss;
|
|
6989
|
+
|
|
6990
|
+
const sallaMultipleBundleProductSliderCss = "";
|
|
6991
|
+
|
|
6992
|
+
const SallaMultipleBundleProductSlider = class {
|
|
6993
|
+
constructor(hostRef) {
|
|
6994
|
+
registerInstance(this, hostRef);
|
|
6995
|
+
this.productSelected = createEvent(this, "productSelected");
|
|
6996
|
+
this.productOptionsSelected = createEvent(this, "productOptionsSelected");
|
|
6997
|
+
this.selectedProducts = {};
|
|
6998
|
+
this.handleProductClick = (product, productIndex) => {
|
|
6999
|
+
// Find the checkbox input for this product
|
|
7000
|
+
const checkboxId = this.generateEventName(this.section.id, productIndex);
|
|
7001
|
+
const checkbox = document.getElementById(checkboxId);
|
|
7002
|
+
if (!checkbox)
|
|
7003
|
+
return;
|
|
7004
|
+
if (checkbox) {
|
|
7005
|
+
// Toggle the checkbox state
|
|
7006
|
+
checkbox.checked = !checkbox.checked;
|
|
7007
|
+
// Dispatch a change event to trigger form validation/submission
|
|
7008
|
+
const changeEvent = new window.Event('change', { bubbles: true });
|
|
7009
|
+
checkbox.dispatchEvent(changeEvent);
|
|
7010
|
+
}
|
|
7011
|
+
this.productSelected.emit({
|
|
7012
|
+
product,
|
|
7013
|
+
sectionId: this.section.id,
|
|
7014
|
+
});
|
|
7015
|
+
};
|
|
7016
|
+
this.handleOptionsClick = (product) => {
|
|
7017
|
+
this.productOptionsSelected.emit({
|
|
7018
|
+
product,
|
|
7019
|
+
sectionId: this.section.id,
|
|
7020
|
+
});
|
|
7021
|
+
};
|
|
7022
|
+
}
|
|
7023
|
+
generateEventName(sectionId, productIndex) {
|
|
7024
|
+
return `bundle[${sectionId}][${productIndex}][id]`;
|
|
7025
|
+
}
|
|
7026
|
+
render() {
|
|
7027
|
+
return (h(Host, { key: '8c1d316ceeb7a0833d689695f00569a0da1d642e' }, h("salla-slider", { key: 'ca86cee09dc4f8c48edf14bfb4a26b86982fd84d', type: "carousel", controlsOuter: false, showControls: false, id: "accordion-multiple-bundle-product", pagination: true, class: "s-multiple-bundle-product-wrapper-slider", sliderConfig: {
|
|
7028
|
+
spaceBetween: 0,
|
|
7029
|
+
} }, h("div", { key: 'b59ac0393f6e826658dcca7eef8c2c21019664d4', slot: "items" }, this?.section?.products?.map((product, productIndex) => {
|
|
7030
|
+
const isChecked = this.selectedProducts[this.section.id]?.has(product.id) || false;
|
|
7031
|
+
return (h("div", { class: `swiper-slide s-multiple-bundle-product-slide-one-third ${product.quantity == 0
|
|
7032
|
+
? 's-multiple-bundle-product-slide-one-third-disabled'
|
|
7033
|
+
: ''}`, key: product.id }, h("div", { class: "s-multiple-bundle-product-card" }, h("div", { class: "s-multiple-bundle-product-image-wrapper", onClick: () => this.handleProductClick(product, productIndex) }, h("input", { id: this.generateEventName(this.section.id, productIndex), type: "checkbox", class: "s-multiple-bundle-product-checkbox", checked: isChecked, name: this.generateEventName(this.section.id, productIndex), value: product.id }), h("img", { src: product.image.url || salla.url.cdn('images/s-empty.png'), loading: "lazy", alt: product.image.alt || product.name, class: "s-multiple-bundle-product-image" })), h("div", { class: "s-multiple-bundle-product-content-wrapper" }, h("div", { class: "s-multiple-bundle-product-content" }, h("div", { class: "s-multiple-bundle-product-details" }, h("div", { class: "s-multiple-bundle-product-title-wrapper" }, h("h2", { class: "s-multiple-bundle-product-title" }, product.name)), h("div", { class: "s-multiple-bundle-product-price-wrapper" }, h("span", { class: "s-multiple-bundle-product-price" }, h("span", { innerHTML: salla.money(product.price) })), product.sale_price > 0 && (h("span", { class: "s-multiple-bundle-product-price-discount" }, h("span", { innerHTML: salla.money(product.sale_price) }))))), product.quantity_in_group > 0 && product.quantity !== 0 && (h("span", { class: "s-multiple-bundle-product-badge" }, salla.lang.get('pages.products.pieces'), h("span", null, product.quantity_in_group))), product.quantity === 0 && (h("span", { class: "s-multiple-bundle-product-badge" }, salla.lang.get('pages.products.quantity_in_group_finished')))), product.options?.length > 0 && (h("button", { class: "s-multiple-bundle-product-button", onClick: () => this.handleOptionsClick(product), type: "button" }, salla.lang.get('pages.products.choose_from_options'), h("i", { class: "sicon-keyboard_arrow_left s-multiple-bundle-product-button-icon" })))))));
|
|
7034
|
+
})))));
|
|
7035
|
+
}
|
|
7036
|
+
get host() { return getElement(this); }
|
|
7037
|
+
};
|
|
7038
|
+
SallaMultipleBundleProductSlider.style = sallaMultipleBundleProductSliderCss;
|
|
7039
|
+
|
|
7040
|
+
var Tag = `<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
|
7041
|
+
<title>tag</title>
|
|
7042
|
+
<path d="M28 0h-9.344c-1.059 0-2.056 0.411-2.809 1.153l-14.673 14.456c-1.56 1.56-1.561 4.097-0.001 5.657l9.56 9.56c0.755 0.755 1.76 1.172 2.828 1.173h0.003c1.068 0 2.072-0.416 2.833-1.179l14.451-14.668c0.743-0.753 1.153-1.751 1.153-2.809v-9.344c0-2.205-1.795-4-4-4zM29.333 13.344c0 0.353-0.137 0.685-0.385 0.937l-14.444 14.661c-0.252 0.252-0.587 0.391-0.941 0.391-0.001 0-0.001 0-0.001 0-0.356-0.001-0.691-0.139-0.943-0.392l-9.561-9.56c-0.52-0.52-0.52-1.365-0.005-1.88l14.667-14.449c0.253-0.248 0.585-0.385 0.937-0.385h9.344c0.736 0 1.333 0.597 1.333 1.333zM24 6.673c-0.737 0-1.333 0.604-1.333 1.341s0.596 1.333 1.333 1.333 1.333-0.596 1.333-1.333v-0.015c0-0.737-0.596-1.327-1.333-1.327z"></path>
|
|
7043
|
+
</svg>
|
|
7044
|
+
`;
|
|
7045
|
+
|
|
7046
|
+
var Cart2 = `<!-- Generated by IcoMoon.io -->
|
|
7047
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
|
7048
|
+
<title>cart2</title>
|
|
7049
|
+
<path d="M6.845 5.333l-1.905-5.333h-3.607c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333v0h1.727l5.72 16.012c0.569 1.56 2.039 2.654 3.765 2.655h12.133c0.001 0 0.002 0 0.003 0 1.825 0 3.364-1.222 3.845-2.892l0.007-0.028 3.161-13.080zM25.96 17.716c-0.167 0.554-0.672 0.951-1.27 0.951-0.002 0-0.005 0-0.007-0h-12.133c-0.575-0-1.065-0.364-1.252-0.875l-0.003-0.009-3.497-9.783h20.508zM13.333 24c-2.209 0-4 1.791-4 4s1.791 4 4 4c2.209 0 4-1.791 4-4v0c0-2.209-1.791-4-4-4v0zM13.333 29.333c-0.736 0-1.333-0.597-1.333-1.333s0.597-1.333 1.333-1.333c0.736 0 1.333 0.597 1.333 1.333v0c0 0.736-0.597 1.333-1.333 1.333v0zM24 24c-2.209 0-4 1.791-4 4s1.791 4 4 4c2.209 0 4-1.791 4-4v0c0-2.209-1.791-4-4-4v0zM24 29.333c-0.736 0-1.333-0.597-1.333-1.333s0.597-1.333 1.333-1.333c0.736 0 1.333 0.597 1.333 1.333v0c0 0.736-0.597 1.333-1.333 1.333v0z"></path>
|
|
7050
|
+
</svg>
|
|
7051
|
+
`;
|
|
7052
|
+
|
|
7053
|
+
const sallaOfferModalCss = ".s-offer-modal-type-products .s-modal-body{min-height:690px;position:relative}";
|
|
7054
|
+
|
|
7055
|
+
const SallaOfferModal = class {
|
|
7056
|
+
constructor(hostRef) {
|
|
7057
|
+
registerInstance(this, hostRef);
|
|
7058
|
+
this.offer = null;
|
|
7059
|
+
this.hasError = false;
|
|
7060
|
+
this.translationLoaded = false;
|
|
7061
|
+
this.addToCartLabel = salla.lang.get("pages.cart.add_to_cart");
|
|
7062
|
+
salla.event.on('offer-modal::open', product_id => this.open(product_id));
|
|
7063
|
+
salla.lang.onLoaded(() => {
|
|
7064
|
+
this.addToCartLabel = salla.lang.get("pages.cart.add_to_cart");
|
|
7065
|
+
this.translationLoaded = true;
|
|
7066
|
+
});
|
|
7067
|
+
this.categorySlot = this.host.querySelector('[slot="category"]')?.innerHTML || `<span class="s-offer-modal-badge-icon">{tagIcon}</span><span class="s-offer-modal-badge-text">{name}</span>`;
|
|
7068
|
+
// this.productSlot = this.host.querySelector('[slot="product"]')?.innerHTML || this.defaultProductSlot();
|
|
7069
|
+
salla.event.on('offer-modal::open', product_id => this.open(product_id));
|
|
7070
|
+
salla.product.event.onOfferExisted(offer => {
|
|
7071
|
+
if (salla.storage.get('remember-offer-' + offer.id)) {
|
|
7072
|
+
salla.log('User selected to don\'t show this offer again.');
|
|
7073
|
+
return;
|
|
7074
|
+
}
|
|
7075
|
+
this.open(offer.product_id);
|
|
7076
|
+
});
|
|
7077
|
+
}
|
|
7078
|
+
/**
|
|
7079
|
+
* Emits a promotion viewed event for analytics tracking
|
|
7080
|
+
* @param offer - The offer being viewed in the modal
|
|
7081
|
+
*/
|
|
7082
|
+
emitPromotionViewed(offer) {
|
|
7083
|
+
if (!offer)
|
|
7084
|
+
return;
|
|
7085
|
+
salla.event.emit('promotion::viewed', [{
|
|
7086
|
+
id: offer.id?.toString(),
|
|
7087
|
+
creative: offer.message,
|
|
7088
|
+
name: offer.name,
|
|
7089
|
+
position: `${this.offer_type}_offer_modal`
|
|
7090
|
+
}]);
|
|
7091
|
+
}
|
|
7092
|
+
/**
|
|
7093
|
+
* Emits a promotion clicked event for analytics tracking
|
|
7094
|
+
* @param offer - The offer being clicked in the modal
|
|
7095
|
+
*/
|
|
7096
|
+
emitPromotionClicked(offer) {
|
|
7097
|
+
if (!offer)
|
|
7098
|
+
return;
|
|
7099
|
+
salla.event.emit('promotion::clicked', [{
|
|
7100
|
+
id: offer.id?.toString(),
|
|
7101
|
+
creative: offer.message,
|
|
7102
|
+
name: offer.name,
|
|
7103
|
+
position: `${this.offer_type}_offer_modal`
|
|
7104
|
+
}]);
|
|
7105
|
+
}
|
|
7106
|
+
/**
|
|
7107
|
+
* Show the available offers for the product
|
|
7108
|
+
* @param product_id
|
|
7109
|
+
*/
|
|
7110
|
+
async open(product_id) {
|
|
7111
|
+
this.productID = product_id;
|
|
7112
|
+
//TODO:: make sure there is only one offer
|
|
7113
|
+
this.hasError = false;
|
|
7114
|
+
this.modal.open();
|
|
7115
|
+
return await salla.api.withoutNotifier(() => salla.product.offers(product_id))
|
|
7116
|
+
.then(response => this.showOffer(response.data[0]))
|
|
7117
|
+
.catch(e => {
|
|
7118
|
+
this.hasError = true;
|
|
7119
|
+
this.errorMessage = e.response?.data?.error?.message || e.response?.data;
|
|
7120
|
+
})
|
|
7121
|
+
.finally(() => setTimeout(() => this.modal.stopLoading(), 1000));
|
|
5925
7122
|
}
|
|
5926
7123
|
/**
|
|
5927
7124
|
* Show offer details
|
|
@@ -6011,7 +7208,7 @@ const SallaOfferModal = class {
|
|
|
6011
7208
|
// '</div>';
|
|
6012
7209
|
// }
|
|
6013
7210
|
render() {
|
|
6014
|
-
return h("salla-modal", { key: '
|
|
7211
|
+
return h("salla-modal", { key: '6dce27c3f20b031aa33b7e15980c55af84d1c9f6', "has-skeleton": true, "sub-title": this.offer_message, ref: modal => this.modal = modal, isLoading: true, class: `s-offer-modal-type-${this.offer_type ? this.offer_type : ''}` }, h("div", { key: '1f63aa0fd3a95ba54e8ed5168f1439f4cafce036', slot: 'loading' }, h("div", { key: '748de710f2ad5c6c60a9e324d1e1b44672dee28f', class: "s-offer-modal-skeleton" }, h("div", { key: '96d6d1d8edc3e511c87eaa44539617d529e8a3e0', class: "s-offer-modal-skeleton-header" }, h("salla-skeleton", { key: '1abe6ddf5096af877c9ce59dfbcdecb08a263e4b', type: 'circle', height: '80px', width: '80px' }), h("salla-skeleton", { key: '7010a9056b168f4df7168a55dbfde1da2726c913', height: '15px', width: '50%' }), h("salla-skeleton", { key: '4168b53b7a4358240f8f6d4d3b9f9a999992ddcb', height: '10px', width: '30%' })), h("div", { key: 'd019372cebf6d3e4d80842fa48e3ce1433457f06', class: "s-offer-modal-skeleton-items" }, [...Array(3)].map(() => h("div", { class: "s-offer-modal-skeleton-item" }, h("salla-skeleton", { height: '9rem' }), h("div", { class: "s-offer-modal-skeleton-item-title" }, h("salla-skeleton", { height: '15px', width: '100%' })), h("div", { class: "s-offer-modal-skeleton-item-subtitle" }, h("salla-skeleton", { height: '9px', width: '50%' }), h("div", { innerHTML: Cart2 }))))), h("div", { key: '4cbc9f99a98ccc9ea27f41e50fa037ea44d85048', class: "s-offer-modal-skeleton-footer" }, h("salla-skeleton", { key: '467546d4ded93cd95a7be78e6dd39935a20867c8', height: '15px', width: '50%' }), h("salla-skeleton", { key: '399a4a4ebedcc54def70ff428f3c5f24fd98a775', height: '15px', width: '30%' })))), !this.hasError && this.offer !== null
|
|
6015
7212
|
? [h("span", { slot: 'icon', class: "s-offer-modal-header-icon", innerHTML: SpecialDiscountIcon }), this.getOfferContent(), h("div", { class: "s-offer-modal-footer", slot: "footer" }, this.offer.formatted_date ?
|
|
6016
7213
|
h("p", { class: "s-offer-modal-expiry" }, salla.lang.get('pages.products.offer_expires_in'), " ", this.offer.formatted_date)
|
|
6017
7214
|
: '', h("label", { class: "s-offer-modal-remember-label" }, h("input", { type: "checkbox", onChange: e => this.rememberMe(e), class: "s-offer-modal-remember-input" }), "\u00A0 ", salla.lang.get('common.elements.remember_my_choice'))),
|
|
@@ -6060,7 +7257,7 @@ const SallaPlaceholder = class {
|
|
|
6060
7257
|
};
|
|
6061
7258
|
}
|
|
6062
7259
|
render() {
|
|
6063
|
-
return (h(Host, { key: '
|
|
7260
|
+
return (h(Host, { key: '9bf5c9b70ee7dddc65bdb550f98681aa6eb4a2b1', class: this.alignmentClass() }, h("div", { key: '05bf79dd66fb30d76ffe05ea50b66d1bab976bb0', class: `s-placeholder-icon s-placeholder-icon-${this.iconSize}`, innerHTML: this.icon }), h("div", { key: '1373cfaad7e993e6cc888047346348083ee8bf7e', class: "s-placeholder-title" }, h("slot", { key: '5a6d70c7fee74334cf46143511bf2465e32025be', name: 'title' }, h("span", { key: '5b531362a3dea0a8a59960a28925c03bdfc64f82' }, salla.lang.get('common.elements.no_options')))), h("div", { key: 'd9d0c28b47f7c2972817630a9011e17116fa66c8', class: "s-placeholder-description" }, h("slot", { key: '0b67052476e584464107d56b4c8f263cfebaac87', name: 'description' }, h("span", { key: '61b16c16799ce96a53eca32936c8d49b2e81ff03' }, salla.lang.get('common.errors.empty_results'))))));
|
|
6064
7261
|
}
|
|
6065
7262
|
};
|
|
6066
7263
|
SallaPlaceholder.style = sallaPlaceholderCss;
|
|
@@ -6202,7 +7399,7 @@ const SallaProductAvailability = class {
|
|
|
6202
7399
|
field.nextElementSibling['innerText'] = '* ' + errorMsg;
|
|
6203
7400
|
}
|
|
6204
7401
|
render() {
|
|
6205
|
-
return (h(Host, { key: '
|
|
7402
|
+
return (h(Host, { key: '631de4fa7186561daed53943f2ece491a8dbe934', class: "s-product-availability-wrap" }, this.isSubscribed || this.isVisitorSubscribed
|
|
6206
7403
|
? h("div", { class: "s-product-availability-subscribed" }, h("span", { innerHTML: BellRing, class: "s-product-availability-subs-icon" }), salla.lang.get('pages.products.notify_availability_success'))
|
|
6207
7404
|
:
|
|
6208
7405
|
h("salla-button", { width: "wide", onClick: () => this.isUser ? this.submit() : this.openModel() }, salla.lang.get('pages.products.notify_availability')), this.isUser || this.isSubscribed || this.isVisitorSubscribed ? '' : this.renderModal()));
|
|
@@ -6318,14 +7515,14 @@ const SallaProductCard = class {
|
|
|
6318
7515
|
's-product-card-out-of-stock': this.productData?.is_out_of_stock,
|
|
6319
7516
|
};
|
|
6320
7517
|
const hrefProp = this.productData?.url ? { href: this.productData.url, title: `Learn more about ${this.productData?.name}` } : {};
|
|
6321
|
-
return (h(Host, { key: '
|
|
7518
|
+
return (h(Host, { key: 'e46cba8a24104176d7a95c02ead575a6fa360783', id: `product-${this.productData?.id}`, class: classes }, h("div", { key: '6370f6a5ca0a63ab4f4d97492ef1f8911ef82bda', class: !this.fullImage ? 's-product-card-image' : 's-product-card-image-full' }, h("a", { key: '37f2f82fa1c500e9cdb4a0aabe570429b9b9daaa', ...hrefProp }, h("img", { key: '4ce43329b5a44b4d5ef174469c510ef28d547440', class: `s-product-card-image-${salla.url.is_placeholder(this.productData?.image?.url)
|
|
6322
7519
|
? 'contain'
|
|
6323
7520
|
: this.fitImageHeight
|
|
6324
7521
|
? this.fitImageHeight
|
|
6325
|
-
: 'cover'} lazy`, src: this.placeholder, alt: this.productData?.image?.alt || this.productData?.name, "data-src": this.productData?.image?.url || this.productData?.thumbnail }), !this.fullImage && !this.minimal ? this.getProductBadge() : ''), this.fullImage && h("a", { key: '
|
|
6326
|
-
h("salla-button", { shape: "icon", fill: "none", color: "light", "aria-label": "Add or remove to wishlist", ref: el => this.wishlistBtn = el, class: "s-product-card-wishlist-btn animated", onClick: () => salla.wishlist.toggle(this.productData.id) }, h("span", { innerHTML: Heart })) : ''), h("div", { key: '
|
|
7522
|
+
: 'cover'} lazy`, src: this.placeholder, alt: this.productData?.image?.alt || this.productData?.name, "data-src": this.productData?.image?.url || this.productData?.thumbnail }), !this.fullImage && !this.minimal ? this.getProductBadge() : ''), this.fullImage && h("a", { key: '87a4e4caafb0edba3c634ff5760ae0556a510d3c', ...hrefProp, class: "s-product-card-overlay" }), !this.horizontal && !this.fullImage ?
|
|
7523
|
+
h("salla-button", { shape: "icon", fill: "none", color: "light", "aria-label": "Add or remove to wishlist", ref: el => this.wishlistBtn = el, class: "s-product-card-wishlist-btn animated", onClick: () => salla.wishlist.toggle(this.productData.id) }, h("span", { innerHTML: Heart })) : ''), h("div", { key: '7cb392ea3fe61d41d5ba5a36650725545ddd3cf8', class: "s-product-card-content" }, this.isSpecial && this.productData?.quantity ?
|
|
6327
7524
|
h("div", { class: "s-product-card-content-pie", ref: pie => this.pie = pie }, h("span", null, h("b", null, salla.helpers.number(this.productData?.quantity)), this.remained), h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "-2 -1 36 34", class: "s-product-card-content-pie-svg" }, h("circle", { cx: "16", cy: "16", r: "15.9155", class: "s-product-card-content-pie-svg-base" }), h("circle", { cx: "16", cy: "16", r: "15.9155", class: "s-product-card-content-pie-svg-bar" })))
|
|
6328
|
-
: '', h("div", { key: '
|
|
7525
|
+
: '', h("div", { key: '28322ef080ae243b55ed4c982f59226159b81d6b', class: { 's-product-card-content-main': true, 's-product-card-content-extra-padding': this.isSpecial } }, h("h3", { key: 'dc378461ca91f1af0c29b35271e8f6b76321f133', class: "s-product-card-content-title" }, h("a", { key: '1bf4c4cf4d04ebb4990053d9721581b276083f30', ...hrefProp }, this.productData?.name)), this.productData?.subtitle && !this.minimal ?
|
|
6329
7526
|
h("p", { class: "s-product-card-content-subtitle" }, this.productData?.subtitle)
|
|
6330
7527
|
: ''), this.productData?.donation && !this.minimal && !this.fullImage ?
|
|
6331
7528
|
[h("salla-progress-bar", { donation: this.productData?.donation }), h("div", { class: "s-product-card-donation-input" }, this.productData?.donation?.can_donate ?
|
|
@@ -6334,7 +7531,7 @@ const SallaProductCard = class {
|
|
|
6334
7531
|
this.addBtn.donatingAmount = e.target.value;
|
|
6335
7532
|
}, id: "donation-amount", name: "donating_amount", class: "s-form-control", placeholder: this.donationAmount })]
|
|
6336
7533
|
: '')]
|
|
6337
|
-
: '', h("div", { key: '
|
|
7534
|
+
: '', h("div", { key: '86474ac2519b7589053b39dc36ae316ad64c8e29', class: { 's-product-card-content-sub': true, 's-product-card-content-extra-padding': this.isSpecial } }, this.getProductPrice(), this.productData?.rating?.stars && !this.minimal ?
|
|
6338
7535
|
h("div", { class: "s-product-card-rating" }, h("span", { innerHTML: Rate }), h("span", null, this.productData.rating.stars))
|
|
6339
7536
|
: ''), this.isSpecial && this.productData.discount_ends
|
|
6340
7537
|
? h("salla-count-down", { date: this.formatDate(this.productData.discount_ends), "end-of-day": true, boxed: true, labeled: true })
|
|
@@ -6358,6 +7555,782 @@ const SallaProductCard = class {
|
|
|
6358
7555
|
};
|
|
6359
7556
|
SallaProductCard.style = sallaProductCardCss;
|
|
6360
7557
|
|
|
7558
|
+
var DisplayType;
|
|
7559
|
+
(function (DisplayType) {
|
|
7560
|
+
DisplayType["COLOR"] = "color";
|
|
7561
|
+
DisplayType["DATE"] = "date";
|
|
7562
|
+
DisplayType["DATETIME"] = "datetime";
|
|
7563
|
+
DisplayType["DONATION"] = "donation";
|
|
7564
|
+
DisplayType["IMAGE"] = "image";
|
|
7565
|
+
DisplayType["MULTIPLE_OPTIONS"] = "multiple-options";
|
|
7566
|
+
DisplayType["NUMBER"] = "number";
|
|
7567
|
+
DisplayType["SINGLE_OPTION"] = "single-option";
|
|
7568
|
+
DisplayType["DIGITAL_CARD_VALUE"] = "digital-code-value";
|
|
7569
|
+
DisplayType["COUNTRY"] = "country";
|
|
7570
|
+
DisplayType["SPLITTER"] = "splitter";
|
|
7571
|
+
DisplayType["TEXT"] = "text";
|
|
7572
|
+
DisplayType["TEXTAREA"] = "textarea";
|
|
7573
|
+
DisplayType["THUMBNAIL"] = "thumbnail";
|
|
7574
|
+
DisplayType["TIME"] = "time";
|
|
7575
|
+
DisplayType["RADIO"] = "radio";
|
|
7576
|
+
DisplayType["CHECKBOX"] = "checkbox";
|
|
7577
|
+
DisplayType["MAP"] = "map";
|
|
7578
|
+
DisplayType["FILE"] = "file";
|
|
7579
|
+
DisplayType["COLOR_PICKER"] = "color_picker";
|
|
7580
|
+
DisplayType["BOOKING"] = "booking";
|
|
7581
|
+
})(DisplayType || (DisplayType = {}));
|
|
7582
|
+
var Currency;
|
|
7583
|
+
(function (Currency) {
|
|
7584
|
+
Currency["Sar"] = "SAR";
|
|
7585
|
+
})(Currency || (Currency = {}));
|
|
7586
|
+
|
|
7587
|
+
var CameraIcon = `<!-- Generated by IcoMoon.io -->
|
|
7588
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
|
7589
|
+
<title>camera</title>
|
|
7590
|
+
<path d="M16 10.667c-4.044 0-7.333 3.289-7.333 7.333s3.289 7.333 7.333 7.333 7.333-3.289 7.333-7.333-3.289-7.333-7.333-7.333zM16 22.667c-2.573 0-4.667-2.093-4.667-4.667s2.093-4.667 4.667-4.667 4.667 2.093 4.667 4.667-2.093 4.667-4.667 4.667zM28 5.333h-3.287l-2.271-3.407c-0.248-0.371-0.664-0.593-1.109-0.593h-10.667c-0.445 0-0.861 0.223-1.109 0.593l-2.271 3.407h-3.287c-2.205 0-4 1.795-4 4v17.333c0 2.205 1.795 4 4 4h24c2.205 0 4-1.795 4-4v-17.333c0-2.205-1.795-4-4-4zM29.333 26.667c0 0.735-0.599 1.333-1.333 1.333h-24c-0.735 0-1.333-0.599-1.333-1.333v-17.333c0-0.735 0.599-1.333 1.333-1.333h4c0.445 0 0.861-0.223 1.109-0.593l2.272-3.407h9.239l2.271 3.407c0.248 0.371 0.664 0.593 1.109 0.593h4c0.735 0 1.333 0.599 1.333 1.333zM25.333 10.66c-0.736 0-1.333 0.604-1.333 1.34s0.597 1.333 1.333 1.333 1.333-0.597 1.333-1.333v-0.013c0-0.736-0.597-1.327-1.333-1.327z"></path>
|
|
7591
|
+
</svg>
|
|
7592
|
+
`;
|
|
7593
|
+
|
|
7594
|
+
var FileIcon = `<!-- Generated by IcoMoon.io -->
|
|
7595
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
|
7596
|
+
<title>file-upload</title>
|
|
7597
|
+
<path d="M21.333 24c0.341 0 0.683-0.131 0.943-0.391 0.521-0.521 0.521-1.364 0-1.885l-5.333-5.333c-0.123-0.123-0.271-0.22-0.433-0.288-0.327-0.135-0.693-0.135-1.019 0-0.163 0.068-0.311 0.165-0.433 0.288l-5.333 5.333c-0.521 0.521-0.521 1.364 0 1.885s1.364 0.521 1.885 0l3.057-3.057v10.115c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-10.115l3.057 3.057c0.26 0.26 0.601 0.391 0.943 0.391zM28.943 9.724l-9.333-9.333c-0.249-0.251-0.589-0.391-0.943-0.391h-12c-2.205 0-4 1.795-4 4v24c0 2.205 1.795 4 4 4h4c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333h-4c-0.735 0-1.333-0.599-1.333-1.333v-24c0-0.735 0.599-1.333 1.333-1.333h11.448l8.552 8.552v16.781c0 0.735-0.599 1.333-1.333 1.333h-4c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333h4c2.205 0 4-1.795 4-4v-17.333c0-0.353-0.14-0.693-0.391-0.943z"></path>
|
|
7598
|
+
</svg>
|
|
7599
|
+
`;
|
|
7600
|
+
|
|
7601
|
+
const sallaProductOptionsCss = "";
|
|
7602
|
+
|
|
7603
|
+
const SallaProductOptions = class {
|
|
7604
|
+
constructor(hostRef) {
|
|
7605
|
+
registerInstance(this, hostRef);
|
|
7606
|
+
this.changed = createEvent(this, "changed");
|
|
7607
|
+
this.fileTypes = {
|
|
7608
|
+
pdf: 'application/pdf',
|
|
7609
|
+
png: 'image/png',
|
|
7610
|
+
jpg: 'image/jpeg',
|
|
7611
|
+
word: 'application/doc,application/ms-doc,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
7612
|
+
exl: 'application/excel,application/vnd.ms-excel,application/x-excel,application/x-msexcel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
7613
|
+
txt: 'text/plain',
|
|
7614
|
+
};
|
|
7615
|
+
this.outOfStockText = "";
|
|
7616
|
+
this.donationAmount = salla.lang.get('pages.products.donation_amount');
|
|
7617
|
+
this.selectDonationAmount = salla.lang.getWithDefault('pages.products.select_donation_amount', 'تحديد مبلغ التبرع');
|
|
7618
|
+
this.selectAmount = salla.lang.getWithDefault('pages.products.select_amount', 'اختر المبلغ');
|
|
7619
|
+
this.isCustomDonation = false;
|
|
7620
|
+
this.selectedOptions = [];
|
|
7621
|
+
this.disableCardValue = true;
|
|
7622
|
+
this.availableDigitalCardValues = [];
|
|
7623
|
+
this.userInitiatedValidation = false;
|
|
7624
|
+
this.outSkus = [];
|
|
7625
|
+
/**
|
|
7626
|
+
* Avoid selection of previous default or selected card value option
|
|
7627
|
+
* when switching between digital card country options for the 1st time
|
|
7628
|
+
*/
|
|
7629
|
+
this.ignoreDefaultCardValue = false;
|
|
7630
|
+
/**
|
|
7631
|
+
* The id of the product to which the options are going to be fetched for.
|
|
7632
|
+
*/
|
|
7633
|
+
this.productId = salla.config.get('page.id');
|
|
7634
|
+
this.handleDonationOptions = (event, detail, type) => {
|
|
7635
|
+
if (detail === 'custom' && type === 'input') {
|
|
7636
|
+
salla.helpers.inputDigitsOnly(event.target);
|
|
7637
|
+
salla.event.emit('product-options::donation-changed', {
|
|
7638
|
+
id: this.productId,
|
|
7639
|
+
price: event.target.value
|
|
7640
|
+
});
|
|
7641
|
+
return;
|
|
7642
|
+
}
|
|
7643
|
+
event.preventDefault();
|
|
7644
|
+
event.stopPropagation();
|
|
7645
|
+
this.isCustomDonation = event.target.value === 'custom';
|
|
7646
|
+
if (this.donationInput) {
|
|
7647
|
+
if (event.target.value === 'custom') {
|
|
7648
|
+
this.donationInput.value = '';
|
|
7649
|
+
this.donationInput.focus();
|
|
7650
|
+
}
|
|
7651
|
+
else {
|
|
7652
|
+
this.donationInput.value = event.target.value;
|
|
7653
|
+
}
|
|
7654
|
+
if (detail === 'custom') {
|
|
7655
|
+
return;
|
|
7656
|
+
}
|
|
7657
|
+
salla.event.emit('product-options::donation-changed', {
|
|
7658
|
+
id: this.productId,
|
|
7659
|
+
price: event.target.value
|
|
7660
|
+
});
|
|
7661
|
+
}
|
|
7662
|
+
};
|
|
7663
|
+
this.hideLabel = (option) => {
|
|
7664
|
+
if (option.type === DisplayType.DONATION && (option.donation && !option.donation.can_donate)) {
|
|
7665
|
+
return true;
|
|
7666
|
+
}
|
|
7667
|
+
return false;
|
|
7668
|
+
};
|
|
7669
|
+
this.getExpireDonationMessage = (option) => {
|
|
7670
|
+
if (!option.donation) {
|
|
7671
|
+
return;
|
|
7672
|
+
}
|
|
7673
|
+
const completed = option.donation.target_amount <= option.donation.collected_amount;
|
|
7674
|
+
return h("div", { class: { "s-product-options-donation-message": true, "s-product-options-donation-completed": completed, "s-product-options-donation-expired": !completed } }, h("p", null, option.donation.target_message), h("span", { innerHTML: completed ? salla.money(option.donation.target_amount) : '' }));
|
|
7675
|
+
};
|
|
7676
|
+
this.canDisabled = !salla.config.get('store.settings.product.notify_options_availability') || salla.url.is_page('cart');
|
|
7677
|
+
salla.lang.onLoaded(() => {
|
|
7678
|
+
this.outOfStockText = salla.lang.get("pages.products.out_of_stock");
|
|
7679
|
+
this.donationAmount = salla.lang.get('pages.products.donation_amount');
|
|
7680
|
+
this.selectDonationAmount = salla.lang.getWithDefault('pages.products.select_donation_amount', 'تحديد مبلغ التبرع');
|
|
7681
|
+
this.selectAmount = salla.lang.getWithDefault('pages.products.select_amount', 'اختر المبلغ');
|
|
7682
|
+
});
|
|
7683
|
+
if (this.options) {
|
|
7684
|
+
try {
|
|
7685
|
+
this.setOptionsData(Array.isArray(this.options) ? this.options : JSON.parse(this.options));
|
|
7686
|
+
return;
|
|
7687
|
+
}
|
|
7688
|
+
catch (e) {
|
|
7689
|
+
salla.log('Bad json passed via options prop');
|
|
7690
|
+
}
|
|
7691
|
+
}
|
|
7692
|
+
if (!Array.isArray(this.optionsData)) {
|
|
7693
|
+
salla.log('Options is not an array[] ---> ', this.optionsData);
|
|
7694
|
+
this.setOptionsData([]);
|
|
7695
|
+
}
|
|
7696
|
+
if (this.productId && !salla.url.is_page('cart')) {
|
|
7697
|
+
salla.api.product.getDetails(this.productId, ['options']).then(resp => this.setOptionsData(resp.data.options));
|
|
7698
|
+
}
|
|
7699
|
+
}
|
|
7700
|
+
/**
|
|
7701
|
+
* Sets the options data for the product
|
|
7702
|
+
* @param optionsData - Array of product options
|
|
7703
|
+
*/
|
|
7704
|
+
async setOptionsData(optionsData) {
|
|
7705
|
+
this.optionsData = optionsData;
|
|
7706
|
+
const that = this;
|
|
7707
|
+
this.optionsData[0]?.details?.forEach(function (detail) {
|
|
7708
|
+
Object.entries(detail.skus_availability || {})
|
|
7709
|
+
.filter(sku => !sku[1])
|
|
7710
|
+
.map(sku => that.outSkus.push(Number(sku[0])));
|
|
7711
|
+
});
|
|
7712
|
+
}
|
|
7713
|
+
/**
|
|
7714
|
+
* Get the id's of the selected options.
|
|
7715
|
+
* */
|
|
7716
|
+
async getSelectedOptionsData() {
|
|
7717
|
+
const selectedOptions = {};
|
|
7718
|
+
const formData = this.host.getElementSallaData();
|
|
7719
|
+
// Check if bundleContext is defined as a prop on the component before accessing it
|
|
7720
|
+
const contextData = (typeof this.bundleContext !== 'undefined') ? this.bundleContext : null;
|
|
7721
|
+
formData.forEach((value, key) => {
|
|
7722
|
+
if (contextData) {
|
|
7723
|
+
// Handle bundle naming convention: bundle[sectionId][index][options][optionId]
|
|
7724
|
+
if (key.startsWith('bundle[') && key.includes('[options][')) {
|
|
7725
|
+
const optionId = key.split('[options][')[1].replace(']', '');
|
|
7726
|
+
selectedOptions[optionId] = value;
|
|
7727
|
+
}
|
|
7728
|
+
}
|
|
7729
|
+
else {
|
|
7730
|
+
// Handle standard naming convention: options[optionId]
|
|
7731
|
+
if (key.startsWith('options[')) {
|
|
7732
|
+
selectedOptions[key.replace('options[', '').replace(']', '')] = value;
|
|
7733
|
+
}
|
|
7734
|
+
}
|
|
7735
|
+
});
|
|
7736
|
+
return selectedOptions;
|
|
7737
|
+
}
|
|
7738
|
+
/**
|
|
7739
|
+
* Report options form validity.
|
|
7740
|
+
* */
|
|
7741
|
+
async reportValidity() {
|
|
7742
|
+
const requiredElements = this.host.querySelectorAll('[required]');
|
|
7743
|
+
let pass = true;
|
|
7744
|
+
for (let i = 0; i < requiredElements.length; i++) {
|
|
7745
|
+
//if there is only one invalid option, return false
|
|
7746
|
+
if ('reportValidity' in requiredElements[i] && !requiredElements[i].reportValidity()) {
|
|
7747
|
+
pass = false;
|
|
7748
|
+
}
|
|
7749
|
+
}
|
|
7750
|
+
return pass;
|
|
7751
|
+
}
|
|
7752
|
+
/**
|
|
7753
|
+
* Return true if there is any out of stock options are selected and vise versa.
|
|
7754
|
+
* */
|
|
7755
|
+
async hasOutOfStockOption() {
|
|
7756
|
+
return this.selectedOptions.some(option => option.is_out) || (this.selectedSkus?.length && this.selectedSkus?.every(sku => this.outSkus.includes(sku)));
|
|
7757
|
+
}
|
|
7758
|
+
/**
|
|
7759
|
+
* Get selected options.
|
|
7760
|
+
* */
|
|
7761
|
+
async getSelectedOptions() {
|
|
7762
|
+
return this.selectedOptions;
|
|
7763
|
+
}
|
|
7764
|
+
/**
|
|
7765
|
+
* Get a specific option by its id.
|
|
7766
|
+
* */
|
|
7767
|
+
async getOption(option_id) {
|
|
7768
|
+
return this.optionsData.find(option => option.id === option_id);
|
|
7769
|
+
}
|
|
7770
|
+
// @ts-ignore
|
|
7771
|
+
invalidHandler(event, option) {
|
|
7772
|
+
const closestProductOption = event.target.closest('.s-product-options-option');
|
|
7773
|
+
if (!closestProductOption.classList.contains('s-product-options-option-error')) {
|
|
7774
|
+
closestProductOption.classList.add('s-product-options-option-error');
|
|
7775
|
+
}
|
|
7776
|
+
if (this.userInitiatedValidation && !salla.url.is_page('cart')) {
|
|
7777
|
+
const firstInvalidElement = this.host.querySelector('.s-product-options-option-error');
|
|
7778
|
+
if (firstInvalidElement === closestProductOption) {
|
|
7779
|
+
this.scrollToElement(closestProductOption);
|
|
7780
|
+
}
|
|
7781
|
+
}
|
|
7782
|
+
}
|
|
7783
|
+
scrollToElement(element) {
|
|
7784
|
+
if (element) {
|
|
7785
|
+
element.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
7786
|
+
}
|
|
7787
|
+
}
|
|
7788
|
+
changedHandler(event, option, fireChangeEvent = true) {
|
|
7789
|
+
const data = {
|
|
7790
|
+
event: event,
|
|
7791
|
+
option: option,
|
|
7792
|
+
detail: null,
|
|
7793
|
+
productId: this.productId
|
|
7794
|
+
};
|
|
7795
|
+
if (option.details) {
|
|
7796
|
+
const detail = option.details.find((detail) => {
|
|
7797
|
+
return Number(detail.id) === Number(event.target.value);
|
|
7798
|
+
});
|
|
7799
|
+
data.detail = detail;
|
|
7800
|
+
}
|
|
7801
|
+
if (option.type === 'country') {
|
|
7802
|
+
this.handleCountryOptionChange(event, data.detail);
|
|
7803
|
+
}
|
|
7804
|
+
const optionElement = event.target.closest('.s-product-options-option');
|
|
7805
|
+
if (event.target.value ||
|
|
7806
|
+
((option.type === DisplayType.FILE || option.type === DisplayType.IMAGE) && event.type === 'added') ||
|
|
7807
|
+
(option.type === DisplayType.MAP && event.type === 'selected' && (event.target.lat && event.target.lng))) {
|
|
7808
|
+
setTimeout(() => {
|
|
7809
|
+
optionElement.classList.remove('s-product-options-option-error');
|
|
7810
|
+
}, 200);
|
|
7811
|
+
}
|
|
7812
|
+
if (option.type === DisplayType.DONATION) {
|
|
7813
|
+
salla.event.emit('product-options::donation-changed', {
|
|
7814
|
+
id: this.productId,
|
|
7815
|
+
price: event.target.value
|
|
7816
|
+
});
|
|
7817
|
+
}
|
|
7818
|
+
this.setSelectedSkus();
|
|
7819
|
+
this.handleRequiredMultipleOptions(option);
|
|
7820
|
+
const index = this.selectedOptions.findIndex(opt => opt.option_id === data.option.id);
|
|
7821
|
+
if (data.option.type === DisplayType.MULTIPLE_OPTIONS) {
|
|
7822
|
+
// Handle multiple selections
|
|
7823
|
+
const detailIndex = this.selectedOptions.findIndex(opt => opt.option_id === data.option.id && opt?.id === data.detail?.id);
|
|
7824
|
+
if (detailIndex > -1) {
|
|
7825
|
+
// If the option is already selected, remove it (unselect)
|
|
7826
|
+
this.selectedOptions.splice(detailIndex, 1);
|
|
7827
|
+
}
|
|
7828
|
+
else {
|
|
7829
|
+
// If the option is not selected, add it to the selectedOptions array
|
|
7830
|
+
this.selectedOptions.push({ ...data.detail, option_id: data.option.id });
|
|
7831
|
+
}
|
|
7832
|
+
}
|
|
7833
|
+
else {
|
|
7834
|
+
// Handle single selection
|
|
7835
|
+
if (!data.detail || Object.keys(data.detail).length === 0) {
|
|
7836
|
+
// If there is no value for the single-select, remove it from the selectedOptions array
|
|
7837
|
+
if (index > -1) {
|
|
7838
|
+
this.selectedOptions.splice(index, 1);
|
|
7839
|
+
}
|
|
7840
|
+
}
|
|
7841
|
+
else {
|
|
7842
|
+
// If a value exists, update or add the selection
|
|
7843
|
+
if (index > -1) {
|
|
7844
|
+
// Replace the existing selection with the new one
|
|
7845
|
+
this.selectedOptions[index] = { ...data.detail, option_id: data.option.id };
|
|
7846
|
+
}
|
|
7847
|
+
else {
|
|
7848
|
+
// If no selection exists for this input, add the new selection
|
|
7849
|
+
this.selectedOptions.push({ ...data.detail, option_id: data.option.id });
|
|
7850
|
+
}
|
|
7851
|
+
}
|
|
7852
|
+
}
|
|
7853
|
+
// Update optionsData directly
|
|
7854
|
+
this.optionsData = this.optionsData.map(opt => {
|
|
7855
|
+
if (opt.id === data.option.id) {
|
|
7856
|
+
return {
|
|
7857
|
+
...opt,
|
|
7858
|
+
details: opt.details.map(detail => ({
|
|
7859
|
+
...detail,
|
|
7860
|
+
is_selected: data.option.type === DisplayType.MULTIPLE_OPTIONS
|
|
7861
|
+
? this.selectedOptions.some(selected => selected.id === detail.id)
|
|
7862
|
+
: Number(detail.id) === Number(data.detail?.id),
|
|
7863
|
+
value: data.detail?.value
|
|
7864
|
+
}))
|
|
7865
|
+
};
|
|
7866
|
+
}
|
|
7867
|
+
return opt;
|
|
7868
|
+
});
|
|
7869
|
+
// Emit the event only if fireChangeEvent is true
|
|
7870
|
+
if (fireChangeEvent) {
|
|
7871
|
+
this.changed.emit(data);
|
|
7872
|
+
salla.event.emit('product-options::change', data);
|
|
7873
|
+
}
|
|
7874
|
+
}
|
|
7875
|
+
/**
|
|
7876
|
+
* loop throw all selected details, then get common sku, if it's only one, means we selected all of them;
|
|
7877
|
+
*/
|
|
7878
|
+
setSelectedSkus() {
|
|
7879
|
+
this.selectedSkus = this.selectedOptions.map(detail => Object.keys(detail.skus_availability || {}))
|
|
7880
|
+
.reduce((p, c) => p.filter(e => c.includes(e)), []) // Initialize accumulator as an empty array
|
|
7881
|
+
.map(sku => Number(sku));
|
|
7882
|
+
}
|
|
7883
|
+
handleRequiredMultipleOptions(option) {
|
|
7884
|
+
if (option.type !== DisplayType.MULTIPLE_OPTIONS || !option.required) {
|
|
7885
|
+
return;
|
|
7886
|
+
}
|
|
7887
|
+
const optionContainer = this.host.querySelector(`[data-option-id="${option.id}"]`);
|
|
7888
|
+
const hasChecked = optionContainer.querySelectorAll('input:checked').length;
|
|
7889
|
+
optionContainer.querySelectorAll('input').forEach(input => input.toggleAttribute('required', !hasChecked));
|
|
7890
|
+
}
|
|
7891
|
+
getLatLng(value, type) {
|
|
7892
|
+
return value
|
|
7893
|
+
? value.split(',')[type === 'lat' ? 0 : 1]
|
|
7894
|
+
: '';
|
|
7895
|
+
}
|
|
7896
|
+
getDisplayForType(option) {
|
|
7897
|
+
if (this[`${option.type}Option`]) {
|
|
7898
|
+
return this[`${option.type}Option`](option);
|
|
7899
|
+
}
|
|
7900
|
+
if (option.type === DisplayType.COLOR_PICKER) {
|
|
7901
|
+
return this.colorPickerOption(option);
|
|
7902
|
+
}
|
|
7903
|
+
if (option.type === DisplayType.MULTIPLE_OPTIONS) {
|
|
7904
|
+
return this.multipleOptions(option);
|
|
7905
|
+
}
|
|
7906
|
+
if (option.type === DisplayType.SINGLE_OPTION) {
|
|
7907
|
+
return this.singleOption(option);
|
|
7908
|
+
}
|
|
7909
|
+
// Handle radio type as single option for bundle products
|
|
7910
|
+
if (option.type === DisplayType.RADIO) {
|
|
7911
|
+
return this.radioOption(option);
|
|
7912
|
+
}
|
|
7913
|
+
if (option.type === DisplayType.DIGITAL_CARD_VALUE) {
|
|
7914
|
+
return this.digitalCardValuesOption(option);
|
|
7915
|
+
}
|
|
7916
|
+
if (option.type === DisplayType.COUNTRY) {
|
|
7917
|
+
return this.countryOption(option);
|
|
7918
|
+
}
|
|
7919
|
+
if (option.type === DisplayType.BOOKING && salla.url.is_page("cart")) {
|
|
7920
|
+
return h("salla-booking-field", { onInvalidInput: (e) => this.invalidHandler(e, option), option: option, productId: option.value });
|
|
7921
|
+
}
|
|
7922
|
+
salla.log(`Couldn't find options type(${option.type})😢`);
|
|
7923
|
+
return '';
|
|
7924
|
+
}
|
|
7925
|
+
getOptionShownWhen(option) {
|
|
7926
|
+
return option.visibility_condition
|
|
7927
|
+
? { "data-show-when": `options[${option.visibility_condition.option}] ${option.visibility_condition.operator} ${option.visibility_condition.value}` }
|
|
7928
|
+
: {};
|
|
7929
|
+
}
|
|
7930
|
+
getAvailableDigitalCardSKUs(detail) {
|
|
7931
|
+
const digitalCardOption = this.optionsData.find(({ type }) => type === 'digital-code-value');
|
|
7932
|
+
if (!digitalCardOption)
|
|
7933
|
+
throw new Error('product-options:: No digital card options found');
|
|
7934
|
+
const outofStockSKUs = Object.keys(detail.skus_availability).filter(key => detail.skus_availability[key] === false);
|
|
7935
|
+
this.availableDigitalCardValues = digitalCardOption.details.filter((op) => {
|
|
7936
|
+
return !Object.keys(op.skus_availability).filter(SKU_key => outofStockSKUs.includes(SKU_key)).length;
|
|
7937
|
+
});
|
|
7938
|
+
}
|
|
7939
|
+
handleCountryOptionChange(event, detail) {
|
|
7940
|
+
event.stopImmediatePropagation();
|
|
7941
|
+
this.ignoreDefaultCardValue = true;
|
|
7942
|
+
const currentCardValue = this.host.querySelector("input[data-code-value]:checked");
|
|
7943
|
+
if (currentCardValue)
|
|
7944
|
+
currentCardValue.checked = false;
|
|
7945
|
+
const digitalCardOption = this.optionsData.find(({ type }) => type === 'digital-code-value');
|
|
7946
|
+
if (!digitalCardOption)
|
|
7947
|
+
throw new Error('product-options:: No digital card options found');
|
|
7948
|
+
this.getAvailableDigitalCardSKUs(detail);
|
|
7949
|
+
}
|
|
7950
|
+
getSelectedDigitalCardOptions(option) {
|
|
7951
|
+
const selectedOption = option.details.find(detail => detail.is_selected);
|
|
7952
|
+
const defaultOption = option.details.find(detail => !!detail.is_default) || option.details[0]; /*option.details[0] only applys for counrty options*/
|
|
7953
|
+
if (!['digital-code-value', 'country'].includes(option.type))
|
|
7954
|
+
return;
|
|
7955
|
+
return selectedOption || defaultOption;
|
|
7956
|
+
}
|
|
7957
|
+
//we need the cart Id for productOption Image
|
|
7958
|
+
async componentWillLoad() {
|
|
7959
|
+
if (salla.url.is_page("cart")) {
|
|
7960
|
+
this.disableCardValue = false;
|
|
7961
|
+
this.fillSelectedOptions();
|
|
7962
|
+
}
|
|
7963
|
+
if (this.config) {
|
|
7964
|
+
try {
|
|
7965
|
+
this.optionConfig = typeof this.config === 'string' ? JSON.parse(this.config) : this.config;
|
|
7966
|
+
}
|
|
7967
|
+
catch (error) {
|
|
7968
|
+
console.error('Failed to parse JSON in config prop:', error);
|
|
7969
|
+
}
|
|
7970
|
+
}
|
|
7971
|
+
const shouldSelectDefaultOption = this.optionsData.filter(({ type }) => ["country", "digital-card-value"].includes(type)).length > 0 && salla.url.is_page('cart');
|
|
7972
|
+
if (shouldSelectDefaultOption) {
|
|
7973
|
+
const countryOption = this.optionsData.find(option => option.type === 'country');
|
|
7974
|
+
const defaultSelection = countryOption && this.getSelectedDigitalCardOptions(countryOption);
|
|
7975
|
+
if (defaultSelection) {
|
|
7976
|
+
this.getAvailableDigitalCardSKUs(defaultSelection);
|
|
7977
|
+
}
|
|
7978
|
+
}
|
|
7979
|
+
this.outOfStockText = salla.lang.get('pages.products.out_of_stock');
|
|
7980
|
+
await salla.onReady();
|
|
7981
|
+
document.addEventListener("paste", this.handlePaste.bind(this));
|
|
7982
|
+
const needsCartId = (!salla.storage.get('cart.id') && this.optionsData.some(option => ['file', 'image'].includes(option.type)));
|
|
7983
|
+
return needsCartId ? salla.api.cart.getCurrentCartId(false, "salla-product-options") : null;
|
|
7984
|
+
}
|
|
7985
|
+
/**
|
|
7986
|
+
* This is a workaround for a bug in iOS 26 Safari, when pasting English text to RTL inputs, it adds extra text!!
|
|
7987
|
+
* To avoid any break changes, we will make it only work on these conditions:
|
|
7988
|
+
* - content_copyright is on
|
|
7989
|
+
* - Apple Pay is enabled (means it's iOS/safari)
|
|
7990
|
+
* - Input is an input or textarea
|
|
7991
|
+
* - Salla form control
|
|
7992
|
+
* - Options array
|
|
7993
|
+
*/
|
|
7994
|
+
handlePaste(event) {
|
|
7995
|
+
const target = event.target;
|
|
7996
|
+
if (!Salla.config.get('store.settings.content_copyright')
|
|
7997
|
+
|| !Salla.helpers.hasApplePay()
|
|
7998
|
+
|| !(target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement)
|
|
7999
|
+
|| !target.classList.contains('s-form-control')
|
|
8000
|
+
|| !target.name.startsWith('options[')) {
|
|
8001
|
+
return;
|
|
8002
|
+
}
|
|
8003
|
+
// Prevent default paste (to avoid Safari inserting extra content)
|
|
8004
|
+
event.preventDefault();
|
|
8005
|
+
// Read only the clipboard data
|
|
8006
|
+
const text = event.clipboardData?.getData("text") || "";
|
|
8007
|
+
// Insert it manually at cursor if you want
|
|
8008
|
+
const start = target.selectionStart;
|
|
8009
|
+
const end = target.selectionEnd;
|
|
8010
|
+
const newValue = target.value.slice(0, start) + text + target.value.slice(end);
|
|
8011
|
+
target.value = newValue;
|
|
8012
|
+
// Reset cursor position
|
|
8013
|
+
target.setSelectionRange(start + text.length, start + text.length);
|
|
8014
|
+
}
|
|
8015
|
+
hideDigitalCardsOptions(option) {
|
|
8016
|
+
return (this.disableCardValue && option.type === DisplayType.DIGITAL_CARD_VALUE && !salla.url.is_page("cart"));
|
|
8017
|
+
}
|
|
8018
|
+
render() {
|
|
8019
|
+
if (this.optionsData?.length === 0) {
|
|
8020
|
+
return;
|
|
8021
|
+
}
|
|
8022
|
+
return (h(Host, { class: "s-product-options-wrapper" }, h("salla-conditional-fields", null, this.optionsData.map((option) => h("div", { key: option.id, class: `s-product-options-option-container${option.visibility_condition || this.hideDigitalCardsOptions(option) ? ' hidden' : ''}`, "data-option-id": option.id, ...this.getOptionShownWhen(option) }, option.name === 'splitter' ?
|
|
8023
|
+
this.splitterOption()
|
|
8024
|
+
: h("div", { class: { "s-product-options-option": true, "s-product-options-option-booking": option.type === DisplayType.BOOKING && salla.url.is_page("cart") }, "data-option-type": option.type, "data-option-required": `${option.required}` }, h("label", { htmlFor: this.generateInputName(option.id), class: `s-product-options-option-label ${this.hideLabel(option) ? 's-product-options-option-label-hidden' : ''}` }, h("b", null, option.name, option.required && h("span", null, " * "), " "), h("small", null, option.placeholder)), h("div", { class: `s-product-options-option-content ${this.hideLabel(option) || (option.type === DisplayType.BOOKING && salla.url.is_page("cart")) ? 's-product-options-option-content-full-width' : ''}` }, this.getDisplayForType(option))))))));
|
|
8025
|
+
}
|
|
8026
|
+
generateUniqueKey(defaultValue) {
|
|
8027
|
+
const contextData = this.bundleContext;
|
|
8028
|
+
let baseKey = this.uniqueKey ? `${defaultValue}-${this.uniqueKey}` : defaultValue;
|
|
8029
|
+
if (contextData) {
|
|
8030
|
+
try {
|
|
8031
|
+
// Handle both string and object types
|
|
8032
|
+
const context = typeof contextData === 'string'
|
|
8033
|
+
? JSON.parse(contextData)
|
|
8034
|
+
: contextData;
|
|
8035
|
+
const { sectionId, productId } = context;
|
|
8036
|
+
baseKey = `${baseKey}-bundle-${sectionId}-${productId}`;
|
|
8037
|
+
}
|
|
8038
|
+
catch (e) {
|
|
8039
|
+
// If parsing fails, just use the base key
|
|
8040
|
+
}
|
|
8041
|
+
}
|
|
8042
|
+
return baseKey;
|
|
8043
|
+
}
|
|
8044
|
+
/**
|
|
8045
|
+
* Generate the correct input name based on bundle context
|
|
8046
|
+
* @param optionId - The option ID
|
|
8047
|
+
* @returns The formatted input name
|
|
8048
|
+
*/
|
|
8049
|
+
generateInputName(optionId) {
|
|
8050
|
+
const contextData = this.bundleContext;
|
|
8051
|
+
if (contextData) {
|
|
8052
|
+
try {
|
|
8053
|
+
// Handle both string and object types
|
|
8054
|
+
const context = typeof contextData === 'string'
|
|
8055
|
+
? JSON.parse(contextData)
|
|
8056
|
+
: contextData;
|
|
8057
|
+
const { sectionId, productId } = context;
|
|
8058
|
+
return `bundle[${sectionId}][${productId}][options][${optionId}]`;
|
|
8059
|
+
}
|
|
8060
|
+
catch (e) {
|
|
8061
|
+
return `options[${optionId}]`;
|
|
8062
|
+
}
|
|
8063
|
+
}
|
|
8064
|
+
return `options[${optionId}]`;
|
|
8065
|
+
}
|
|
8066
|
+
fillSelectedOptions() {
|
|
8067
|
+
this.selectedOptions = this.optionsData.reduce((acc, opt) => {
|
|
8068
|
+
const selectedDetails = opt.details.filter(detail => detail.is_selected);
|
|
8069
|
+
const mappedDetails = selectedDetails.map(detail => ({
|
|
8070
|
+
...detail,
|
|
8071
|
+
option_id: opt.id
|
|
8072
|
+
}));
|
|
8073
|
+
return acc.concat(mappedDetails);
|
|
8074
|
+
}, []);
|
|
8075
|
+
}
|
|
8076
|
+
componentDidLoad() {
|
|
8077
|
+
if (this.optionsData?.length === 0 && !this.optionsData.some(option => option.type === DisplayType.DONATION)) {
|
|
8078
|
+
return;
|
|
8079
|
+
}
|
|
8080
|
+
const selectedDonationOption = this.optionsData.find(option => option.type === DisplayType.DONATION)?.details.find(detail => detail.is_selected);
|
|
8081
|
+
if (!selectedDonationOption) {
|
|
8082
|
+
return;
|
|
8083
|
+
}
|
|
8084
|
+
setTimeout(() => {
|
|
8085
|
+
salla.event.emit('product-options::donation-changed', {
|
|
8086
|
+
id: this.productId,
|
|
8087
|
+
price: selectedDonationOption.additional_price
|
|
8088
|
+
});
|
|
8089
|
+
}, 1000);
|
|
8090
|
+
}
|
|
8091
|
+
/**
|
|
8092
|
+
* Enable user-initiated validation mode so invalid fields will scroll into view
|
|
8093
|
+
*/
|
|
8094
|
+
async enableUserInitiatedValidation() {
|
|
8095
|
+
this.userInitiatedValidation = true;
|
|
8096
|
+
}
|
|
8097
|
+
/**
|
|
8098
|
+
* Validate options and trigger scrolling to the first invalid option if any
|
|
8099
|
+
*/
|
|
8100
|
+
async validateAndScroll() {
|
|
8101
|
+
await this.enableUserInitiatedValidation();
|
|
8102
|
+
return this.reportValidity();
|
|
8103
|
+
}
|
|
8104
|
+
//@ts-ignore
|
|
8105
|
+
donationOption(option, product) {
|
|
8106
|
+
return h("div", { class: "s-product-options-donation-wrapper" }, option.donation?.can_donate ? [
|
|
8107
|
+
option.donation ?
|
|
8108
|
+
h("div", { key: option.id, class: "s-product-options-donation-progress" }, h("salla-progress-bar", { donation: option.donation }))
|
|
8109
|
+
: '',
|
|
8110
|
+
option.details.length ?
|
|
8111
|
+
[h("h4", { key: option.id }, this.selectAmount), h("div", { key: option.id, class: "s-product-options-donation-options" }, option.details.map((detail, i) => h("div", { key: option.id, class: "s-product-options-donation-options-item" }, h("input", { id: this.generateUniqueKey(`donation-option-${i}`), type: "radio", name: "donating_option", checked: detail.is_selected, value: detail.additional_price, onChange: e => this.handleDonationOptions(e, detail, 'option') }), h("label", { htmlFor: this.generateUniqueKey(`donation-option-${i}`) }, h("span", { innerHTML: salla.money(detail.name) })))), option.donation?.custom_amount_enabled ?
|
|
8112
|
+
h("div", { class: "s-product-options-donation-options-item" }, h("input", { id: this.generateUniqueKey("donation-option-custom"), type: "radio", name: "donating_option", value: "custom", onChange: e => this.handleDonationOptions(e, 'custom', 'option') }), h("label", { htmlFor: this.generateUniqueKey("donation-option-custom") }, h("span", null, " ", this.selectDonationAmount, " ")))
|
|
8113
|
+
: '')] : '',
|
|
8114
|
+
h("div", { key: option.id, class: { "s-product-options-donation-input-group": true, "shown": !option.details.length || (option.details.length && this.isCustomDonation) } }, h("input", { type: "text", id: "donating-amount", name: "donation_amount", class: "s-form-control", ref: el => { this.donationInput = el; }, value: option.details.length
|
|
8115
|
+
&& option.details.some(detail => detail.is_selected)
|
|
8116
|
+
? option.details.find(detail => detail.is_selected).additional_price
|
|
8117
|
+
: option.value,
|
|
8118
|
+
// required
|
|
8119
|
+
placeholder: option.placeholder, onInput: e => this.handleDonationOptions(e, 'custom', 'input'), onBlur: e => this.changedHandler(e, option), onInvalid: (e) => this.invalidHandler(e, option) }), h("span", { class: "s-product-options-donation-amount-currency" }, salla.config.currency(salla.config.get('user.currency_code')).symbol))
|
|
8120
|
+
] :
|
|
8121
|
+
this.getExpireDonationMessage(option));
|
|
8122
|
+
}
|
|
8123
|
+
fileUploader(option, additions = null) {
|
|
8124
|
+
return h("salla-file-upload", { ...(additions || {}), "payload-name": "file", value: option.value, "instant-upload": true, name: this.generateInputName(option.id), required: !option.visibility_condition && option.required, height: "120px", onAdded: (e) => this.changedHandler(e, option), url: salla.cart.api.getUploadImageEndpoint(), "form-data": { cart_item_id: this.productId, product_id: this.productId }, onInvalidInput: (e) => this.invalidHandler(e, option), class: { "s-product-options-image-input": true, required: option.required } }, h("div", { class: "s-product-options-filepond-placeholder" }, h("span", { class: "s-product-options-filepond-placeholder-icon", innerHTML: additions.accept?.split(',').every(type => type.includes('image'))
|
|
8125
|
+
? CameraIcon
|
|
8126
|
+
: FileIcon }), h("p", { class: "s-product-options-filepond-placeholder-text" }, salla.lang.get('common.uploader.drag_and_drop')), h("span", { class: "filepond--label-action" }, salla.lang.get('common.uploader.browse'))));
|
|
8127
|
+
}
|
|
8128
|
+
//@ts-ignore
|
|
8129
|
+
imageOption(option) {
|
|
8130
|
+
return this.fileUploader(option, { accept: 'image/png,image/jpeg,image/jpg,image/gif' });
|
|
8131
|
+
}
|
|
8132
|
+
//@ts-ignore
|
|
8133
|
+
fileOption(option) {
|
|
8134
|
+
const types = option.details.map(detail => this.fileTypes[detail.name]).filter(Boolean);
|
|
8135
|
+
return types?.length
|
|
8136
|
+
? this.fileUploader(option, { accept: types.join(',') })
|
|
8137
|
+
: 'File types not selected.';
|
|
8138
|
+
}
|
|
8139
|
+
// TODO: (ONLY FOR TESTING!) find a better way to make it testable, e.g. wrap it with a unique class like textOption
|
|
8140
|
+
//@ts-ignore
|
|
8141
|
+
numberOption(option) {
|
|
8142
|
+
return h("input", { type: "text", value: option.value, class: "s-form-control", required: !option.visibility_condition && option.required, name: this.generateInputName(option.id), placeholder: option.placeholder, onBlur: e => this.changedHandler(e, option), onInvalid: (e) => this.invalidHandler(e, option), onInput: e => salla.helpers.inputDigitsOnly(e.target) });
|
|
8143
|
+
}
|
|
8144
|
+
//@ts-ignore
|
|
8145
|
+
splitterOption() {
|
|
8146
|
+
return h("div", { class: "s-product-options-splitter" });
|
|
8147
|
+
}
|
|
8148
|
+
//@ts-ignore
|
|
8149
|
+
textOption(option) {
|
|
8150
|
+
return h("div", { class: "s-product-options-text" }, h("input", { type: "text", value: option.value, maxLength: option?.length, class: 's-form-control', required: !option.visibility_condition && option.required, name: this.generateInputName(option.id), placeholder: option.placeholder, onInvalid: (e) => this.invalidHandler(e, option), onChange: e => this.changedHandler(e, option), onInput: e => this.changedHandler(e, option) }));
|
|
8151
|
+
}
|
|
8152
|
+
//@ts-ignore
|
|
8153
|
+
textareaOption(option) {
|
|
8154
|
+
//todo::remove mt-1 class, and if it's okay to remove the tag itself will be great
|
|
8155
|
+
return h("div", { class: "s-product-options-textarea" }, h("div", { class: "mt-1" }, h("textarea", { rows: 4, value: option.value, maxLength: option?.length, class: "s-form-control", required: !option.visibility_condition && option.required, id: this.generateUniqueKey(option.id.toString()), name: this.generateInputName(option.id), placeholder: option.placeholder, onInvalid: (e) => this.invalidHandler(e, option), onChange: (e) => this.changedHandler(e, option), onInput: (e) => this.changedHandler(e, option) })));
|
|
8156
|
+
}
|
|
8157
|
+
//@ts-ignore
|
|
8158
|
+
mapOption(option) {
|
|
8159
|
+
return h("salla-map", { zoom: 15, lat: this.getLatLng(option.value, 'lat'), lng: this.getLatLng(option.value, 'lng'), name: this.generateInputName(option.id), searchable: true, required: option.required, onInvalidInput: (e) => this.invalidHandler(e, option), onSelected: e => this.changedHandler(e, option) });
|
|
8160
|
+
}
|
|
8161
|
+
colorPickerOption(option) {
|
|
8162
|
+
return h("salla-color-picker", { onSubmitted: e => this.changedHandler(e, option), name: this.generateInputName(option.id), required: !option.visibility_condition && option.required, onInvalidInput: (e) => this.invalidHandler(e, option), color: option.value });
|
|
8163
|
+
}
|
|
8164
|
+
/**
|
|
8165
|
+
* ============= Date Time options =============
|
|
8166
|
+
*/
|
|
8167
|
+
//@ts-ignore
|
|
8168
|
+
timeOption(option) {
|
|
8169
|
+
return h("salla-datetime-picker", { noCalendar: true, enableTime: true, dateFormat: "h:i K", value: option.value, placeholder: option.name, required: !option.visibility_condition && option.required, name: this.generateInputName(option.id), class: "s-product-options-time-element", onInvalidInput: (e) => this.invalidHandler(e, option), onPicked: e => this.changedHandler(e, option) });
|
|
8170
|
+
}
|
|
8171
|
+
//@ts-ignore
|
|
8172
|
+
dateOption(option) {
|
|
8173
|
+
//todo:: consider date-range @see https://github.com/SallaApp/theme-raed/blob/master/src/assets/js/partials/product-options.js#L8-L23
|
|
8174
|
+
return h("div", { class: "s-product-options-date-element" }, h("salla-datetime-picker", { value: option.value, placeholder: option.name, required: !option.visibility_condition && option.required, minDate: new Date(), name: this.generateInputName(option.id), onInvalidInput: (e) => this.invalidHandler(e, option), onPicked: e => this.changedHandler(e, option) }));
|
|
8175
|
+
}
|
|
8176
|
+
//@ts-ignore
|
|
8177
|
+
datetimeOption(option) {
|
|
8178
|
+
//todo:: consider date-range @see https://github.com/SallaApp/theme-raed/blob/master/src/assets/js/partials/product-options.js#L8-L23
|
|
8179
|
+
return h("div", { class: "s-product-options-datetime-element" }, h("salla-datetime-picker", { enableTime: true, value: option.value, dateFormat: "Y-m-d G:i:K", placeholder: option.name, required: !option.visibility_condition && option.required, name: this.generateInputName(option.id), maxDate: option.to_date_time, minDate: option.from_date_time, onInvalidInput: (e) => this.invalidHandler(e, option), onPicked: e => this.changedHandler(e, option) }));
|
|
8180
|
+
}
|
|
8181
|
+
/**
|
|
8182
|
+
* ============= Advanced options =============
|
|
8183
|
+
*/
|
|
8184
|
+
getOptionDetailName(detail, outOfStock = true, optionType) {
|
|
8185
|
+
let detailName;
|
|
8186
|
+
if (optionType && optionType === DisplayType.COLOR) {
|
|
8187
|
+
detailName = detail.name
|
|
8188
|
+
+ ((outOfStock && this.isOptionDetailOut(detail) && !salla.url.is_page("cart")) && !this.hideOutLabel ? ` <br/> <p> ${this.outOfStockText} </p>` : '')
|
|
8189
|
+
+ (detail.additional_price ? ` <p> (${salla.money(detail.additional_price, false)}) </p>` : '');
|
|
8190
|
+
}
|
|
8191
|
+
if (!detailName) {
|
|
8192
|
+
detailName = detail.name
|
|
8193
|
+
+ ((outOfStock && this.isOptionDetailOut(detail) && !salla.url.is_page("cart")) && !this.hideOutLabel ? ` - ${this.outOfStockText}` : '')
|
|
8194
|
+
+ (detail.additional_price ? ` (${salla.money(detail.additional_price, false)})` : '');
|
|
8195
|
+
}
|
|
8196
|
+
//Some merchants adding price to the names of the options,
|
|
8197
|
+
//and because we are using this inside select option, we need to replace the html currency symbol with the store currency symbol
|
|
8198
|
+
return detailName.replace('<i class=sicon-sar></i>', salla.config.currency()?.symbol || 'ر.س');
|
|
8199
|
+
}
|
|
8200
|
+
isOptionDetailOut(detail) {
|
|
8201
|
+
if (detail.is_out || !detail.skus_availability || !this.selectedSkus?.length) {
|
|
8202
|
+
return detail.is_out;
|
|
8203
|
+
}
|
|
8204
|
+
const isDetailSelected = this.selectedOptions.filter(option => option.id === detail.id).length;
|
|
8205
|
+
//if the current options is the only selected option, so we are sure that it's not out, because there is no other options selected yet
|
|
8206
|
+
if (isDetailSelected && this.selectedOptions.length === 1) {
|
|
8207
|
+
return false;
|
|
8208
|
+
}
|
|
8209
|
+
//if current details has sku in the possible outSkus it's out for sure
|
|
8210
|
+
if (isDetailSelected) {
|
|
8211
|
+
//here we will get the possible outSkus for current selected options
|
|
8212
|
+
const outSelectableSkus = this.selectedSkus.filter(sku => this.outSkus.includes(sku));
|
|
8213
|
+
return Object.keys(detail.skus_availability).some(sku => outSelectableSkus.includes(Number(sku)));
|
|
8214
|
+
}
|
|
8215
|
+
return this.selectedOptions.some(option => option.is_out && option.option_id !== detail.option_id);
|
|
8216
|
+
}
|
|
8217
|
+
/**
|
|
8218
|
+
* Renders a single input element (radio or checkbox) for an option detail.
|
|
8219
|
+
* @param type - The type of input element ('radio' or 'checkbox').
|
|
8220
|
+
* @param detail - The detail object representing an option detail.
|
|
8221
|
+
* @param option - The parent option object containing the details.
|
|
8222
|
+
* @param isRequired - Indicates if the input is required based on the option's rules.
|
|
8223
|
+
* @param name - The name attribute for the input element.
|
|
8224
|
+
* @returns HTMLElement - A labeled input element.
|
|
8225
|
+
*/
|
|
8226
|
+
renderInput(type, detail, option, isRequired, name, buttonStyle) {
|
|
8227
|
+
const id = this.generateUniqueKey(`${type}-${option.id}-${detail.id}`);
|
|
8228
|
+
const isDisabled = this.isOptionDetailOut(detail);
|
|
8229
|
+
return (h("label", { class: {
|
|
8230
|
+
"s-product-options-disabled": isDisabled,
|
|
8231
|
+
} }, h("input", { id: id, type: type, name: name, value: detail.id, disabled: isDisabled, required: isRequired, checked: detail.is_selected, onInvalid: (e) => this.invalidHandler(e, option), onChange: (e) => this.changedHandler(e, option) }), h("div", { class: { "s-product-options-grid-mode-span": buttonStyle, "s-product-options-disabled": isDisabled } }, this.getOptionDetailName(detail))));
|
|
8232
|
+
}
|
|
8233
|
+
/**
|
|
8234
|
+
* Renders a collection of input elements for all details of an option.
|
|
8235
|
+
* @param type - The type of input elements ('radio' or 'checkbox').
|
|
8236
|
+
* @param option - The parent option object containing the details.
|
|
8237
|
+
* @param isRequired - Indicates if the inputs are required based on the option's rules.
|
|
8238
|
+
* @returns HTMLElement[] - An array of labeled input elements.
|
|
8239
|
+
*/
|
|
8240
|
+
renderOptionDetails(type, option, isRequired, buttonStyle = false) {
|
|
8241
|
+
const baseName = this.generateInputName(option.id);
|
|
8242
|
+
const name = type === 'radio' ? baseName : `${baseName}[]`;
|
|
8243
|
+
return option?.details.map((detail) => this.renderInput(type, detail, option, isRequired, name, buttonStyle));
|
|
8244
|
+
}
|
|
8245
|
+
/**
|
|
8246
|
+
* Renders a dropdown (select) element for a single-option selection.
|
|
8247
|
+
* @param option - The parent option object.
|
|
8248
|
+
* @returns HTMLElement - A select dropdown element with all option details.
|
|
8249
|
+
*/
|
|
8250
|
+
renderSelect(option) {
|
|
8251
|
+
return (h("div", null, h("select", { name: this.generateInputName(option.id), required: !option.visibility_condition && option.required, class: "s-form-control", onInvalid: (e) => this.invalidHandler(e, option), onChange: (e) => this.changedHandler(e, option) }, h("option", { value: "" }, option.placeholder), option?.details.map((detail) => (h("option", { key: detail.id, value: detail.id, disabled: this.canDisabled && this.isOptionDetailOut(detail), selected: detail.is_selected }, this.getOptionDetailName(detail)))))));
|
|
8252
|
+
}
|
|
8253
|
+
/**
|
|
8254
|
+
* Renders a grid-based layout for option inputs (radio or checkbox).
|
|
8255
|
+
* @param type - The type of input elements ('radio' or 'checkbox').
|
|
8256
|
+
* @param option - The parent option object containing the details.
|
|
8257
|
+
* @param isRequired - Indicates if the inputs are required based on the option's rules.
|
|
8258
|
+
* @returns HTMLElement - A grid-based container with input elements.
|
|
8259
|
+
*/
|
|
8260
|
+
renderButtonStyle(type, option, isRequired) {
|
|
8261
|
+
return (h("div", { class: "s-product-options-grid-mode" }, this.renderOptionDetails(type, option, isRequired, true)));
|
|
8262
|
+
}
|
|
8263
|
+
/**
|
|
8264
|
+
* Renders a single-option selection, either as a grid or dropdown, based on configuration.
|
|
8265
|
+
* @param option - The parent option object.
|
|
8266
|
+
* @returns HTMLElement - The rendered single-option element.
|
|
8267
|
+
*/
|
|
8268
|
+
singleOption(option) {
|
|
8269
|
+
const buttonStyle = this.optionConfig?.['single-option']?.type === 'button';
|
|
8270
|
+
const isRequired = !option.visibility_condition && option.required;
|
|
8271
|
+
return buttonStyle
|
|
8272
|
+
? this.renderButtonStyle('radio', option, isRequired)
|
|
8273
|
+
: this.renderSelect(option);
|
|
8274
|
+
}
|
|
8275
|
+
/**
|
|
8276
|
+
* Renders a multiple-option selection, either as a grid or list, based on configuration.
|
|
8277
|
+
* @param option - The parent option object.
|
|
8278
|
+
* @returns HTMLElement - The rendered multiple-option element.
|
|
8279
|
+
*/
|
|
8280
|
+
multipleOptions(option) {
|
|
8281
|
+
const buttonStyle = this.optionConfig?.['multiple-option']?.type === 'button';
|
|
8282
|
+
const isRequired = option.required &&
|
|
8283
|
+
!option.details.some((detail) => detail.is_selected) &&
|
|
8284
|
+
!option.visibility_condition;
|
|
8285
|
+
return buttonStyle
|
|
8286
|
+
? this.renderButtonStyle('checkbox', option, isRequired)
|
|
8287
|
+
: (h("div", { class: {
|
|
8288
|
+
's-product-options-multiple-options-wrapper': true,
|
|
8289
|
+
required: option.required,
|
|
8290
|
+
} }, this.renderOptionDetails('checkbox', option, isRequired)));
|
|
8291
|
+
}
|
|
8292
|
+
/**
|
|
8293
|
+
* Renders a radio option selection (used for bundle products).
|
|
8294
|
+
* This is essentially the same as single option but with explicit radio handling.
|
|
8295
|
+
* @param option - The parent option object.
|
|
8296
|
+
* @returns HTMLElement - The rendered radio option element.
|
|
8297
|
+
*/
|
|
8298
|
+
radioOption(option) {
|
|
8299
|
+
// Radio options behave the same as single options
|
|
8300
|
+
return this.singleOption(option);
|
|
8301
|
+
}
|
|
8302
|
+
//@ts-ignore
|
|
8303
|
+
colorOption(option) {
|
|
8304
|
+
return (h("fieldset", { class: "s-product-options-colors-wrapper" }, option?.details.map((detail) => (h("div", { class: "s-product-options-colors-item", key: detail.id }, h("input", { type: "radio", value: detail.id, required: !option.visibility_condition && option.required, checked: detail.is_selected, name: this.generateInputName(option.id), disabled: this.canDisabled && this.isOptionDetailOut(detail), id: this.generateUniqueKey(`color-${this.productId}-${option.id}-${detail.id}`), onInvalid: (e) => this.invalidHandler(e, option), onChange: (e) => this.changedHandler(e, option) }), h("label", { htmlFor: this.generateUniqueKey(`color-${this.productId}-${option.id}-${detail.id}`) }, h("span", { style: { backgroundColor: detail.color } }), h("div", { innerHTML: this.getOptionDetailName(detail, true, option.type) })))))));
|
|
8305
|
+
}
|
|
8306
|
+
//@ts-ignore
|
|
8307
|
+
thumbnailOption(option) {
|
|
8308
|
+
return h("div", { class: "s-product-options-thumbnails-wrapper" }, option.details.map((detail) => {
|
|
8309
|
+
return h("div", { key: detail.id }, h("input", { type: "radio", value: detail.id, "data-itemid": detail.id, required: !option.visibility_condition && option.required, checked: detail.is_selected, name: this.generateInputName(option.id), "data-img-id": detail.option_value, disabled: this.canDisabled && this.isOptionDetailOut(detail), id: this.generateUniqueKey(`option_${this.productId}-${option.id}_${detail.id}`), onInvalid: (e) => this.invalidHandler(e, option), onChange: (e) => this.changedHandler(e, option) }), h("label", { htmlFor: this.generateUniqueKey(`option_${this.productId}-${option.id}_${detail.id}`), "data-img-id": detail.option_value, class: "go-to-slide" }, h("img", { "data-src": detail.image, src: detail.image, title: detail.name, alt: detail.name }), h("span", { innerHTML: IconVerified, class: "s-product-options-thumbnails-icon" }), this.isOptionDetailOut(detail) ?
|
|
8310
|
+
[
|
|
8311
|
+
h("small", { key: detail.id, class: "s-product-options-thumbnails-stock-badge" }, this.outOfStockText),
|
|
8312
|
+
this.canDisabled ? h("div", { key: detail.id, class: "s-product-options-thumbnails-badge-overlay" }) : '',
|
|
8313
|
+
]
|
|
8314
|
+
: ''), h("p", null, this.getOptionDetailName(detail, false), " "));
|
|
8315
|
+
}));
|
|
8316
|
+
}
|
|
8317
|
+
// Digital card options
|
|
8318
|
+
digitalCardValuesOption(option) {
|
|
8319
|
+
return h("div", { class: "s-product-options-digital-card-wrapper" }, this.availableDigitalCardValues.length > 0 ? this.availableDigitalCardValues.map((detail) => {
|
|
8320
|
+
const id = String(detail.id);
|
|
8321
|
+
return h("label", { htmlFor: this.generateUniqueKey(id.toString()), key: id, class: "s-product-options-digital-card-option" }, h("input", { type: "radio", "data-code-value": true, class: "s-form-control s-product-options-digital-card-input", value: detail.id, name: this.generateInputName(option.id), id: this.generateUniqueKey(id.toString()), required: !option.visibility_condition && option.required, onInvalid: (e) => this.invalidHandler(e, option), ...(!this.ignoreDefaultCardValue ? { defaultChecked: this.getSelectedDigitalCardOptions(option)?.id === detail.id } : {}) }), h("span", null, detail.name, " ", salla.config?.currency()?.symbol));
|
|
8322
|
+
})
|
|
8323
|
+
: h("div", { class: "s-product-options-digital-card-out-of-stock" }));
|
|
8324
|
+
}
|
|
8325
|
+
countryOption(option) {
|
|
8326
|
+
return h("div", { class: "s-product-options-digital-card-wrapper" }, option.details.map((detail) => {
|
|
8327
|
+
return h("label", { htmlFor: this.generateUniqueKey(detail.id.toString()), key: detail.id, class: { "s-product-options-digital-card-option": true, "s-product-options-digital-card-option-stock-out": detail.is_out } }, h("input", { id: this.generateUniqueKey(detail.id.toString()), type: "radio", class: "s-form-control s-product-options-digital-card-input", value: detail.id, name: this.generateInputName(option.id), disabled: detail.is_out, required: !option.visibility_condition && option.required, onInvalid: (e) => this.invalidHandler(e, option), onChange: e => this.changedHandler(e, option), onClick: () => { this.disableCardValue = false; }, ...(salla.url.is_page("cart") ? { defaultChecked: this.getSelectedDigitalCardOptions(option)?.id === detail.id } : {}) }), h("img", { loading: 'lazy', alt: detail.code, height: 24, width: 24, class: "s-product-options-country-flag", src: `https://cdn.assets.salla.network/prod/admin/cp/assets/flags/1x1/${String(detail.code).toLocaleLowerCase()}.svg` }), h("span", null, detail.name));
|
|
8328
|
+
}));
|
|
8329
|
+
}
|
|
8330
|
+
get host() { return getElement(this); }
|
|
8331
|
+
};
|
|
8332
|
+
SallaProductOptions.style = sallaProductOptionsCss;
|
|
8333
|
+
|
|
6361
8334
|
var PencilRuler = `<!-- Generated by IcoMoon.io -->
|
|
6362
8335
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
|
6363
8336
|
<title>pencil-ruler</title>
|
|
@@ -6406,11 +8379,11 @@ const SallaProductSizeGuide = class {
|
|
|
6406
8379
|
return h("salla-placeholder", { alignment: "center", iconSize: "xl" }, h("div", { slot: "title" }, this.placeholder_title), h("div", { slot: "description" }, this.placeholder_description));
|
|
6407
8380
|
}
|
|
6408
8381
|
render() {
|
|
6409
|
-
return (h("salla-modal", { key: '
|
|
8382
|
+
return (h("salla-modal", { key: 'f80606d8b6e1e950c87209ca4e195c92f70dc341', class: "s-product-size-guide-wrapper", id: 'salla-product-size-guide-modal', isLoading: true, "has-skeleton": true, width: "md", ref: modal => this.modal = modal }, h("span", { key: '245688c24b70279566b0f7c51c7bf924ca5196c0', slot: 'icon', class: "s-product-size-guide-header-icon", innerHTML: PencilRuler }), h("div", { key: '9dc9b4aa8dea0599dbc78f5821e36bc4c600c6aa', slot: "loading" }, h("div", { key: 'fca84d9c2c5fa20ac446270c1c68c4ccda16dd77', class: "s-product-size-guide-skeleton" }, h("salla-skeleton", { key: '0f036371c9b42314beb4e2c1f308a99e2b068ab8', height: '15px', width: '25%' }), h("div", { key: 'a9059b864fddf26b6e15869cab013e793966907e', class: "s-product-size-guide-skeleton-header" }, h("salla-skeleton", { key: '34e188b1ff7e0b5e24df84d1b14df2b2255fc9eb', height: '40px' }), h("salla-skeleton", { key: '38653491fd73cf4d66cb87658b8121f88130e52e', height: '40px' }), h("salla-skeleton", { key: 'a8c3b3cc039fbbb8796c611f4485d889c94e632a', height: '40px' }), h("salla-skeleton", { key: '2de2d63a1a56a58f7f1bef92c46843683528ee1a', height: '40px' })), h("div", { key: 'cf0b08cb85830fcec4dd82140c89b6d009e1bc74', class: "s-product-size-guide-skeleton-content" }, h("salla-skeleton", { key: '402ed4292bb79e839316440ed985b1caed102602', height: '15px', width: '25%' }), h("salla-skeleton", { key: '88f0019d79ea72ef7748a5c04b7a8364c1160b92', height: '10px', width: '75%' }), h("salla-skeleton", { key: '10d7879c306d7185092c9e9aa0d407d2bb57519e', height: '10px', width: '50%' }), h("salla-skeleton", { key: '7b2d00c4c8000083b79d93466ed07828d61b6fbd', height: '10px', width: '75%' }), h("salla-skeleton", { key: '5d33b9848d9bccf34bb5f4a93ad99889fe1ee69f', height: '10px', width: '100%' }), h("salla-skeleton", { key: '6e49c074a8611a819814d17829466b983a419196', height: '10px', width: '25%' }), h("salla-skeleton", { key: '0fb70ed844efeda0d3c2ba348e14d1469a7b279b', height: '10px', width: '60%' }), h("salla-skeleton", { key: '5e55cb90aba76662377efccfef4a84fe0f64c341', height: '10px', width: '45%' }), h("salla-skeleton", { key: '058b96e3db12454ddfced543d6ecbdf0c38ac3dd', height: '10px', width: '30%' })))), h("slot", { key: 'e9eef25bce60cbb1dd48b3d8bc1ebda2305acda0', name: "header" }), !this.hasError && !!this.guides ?
|
|
6410
8383
|
[
|
|
6411
8384
|
h("salla-tabs", null, this.guides.map((guide) => h("salla-tab-header", { slot: "header", name: guide.name }, h("span", null, guide.name))), this.guides.map((guide) => h("salla-tab-content", { slot: "content", name: guide.name }, h("div", { innerHTML: guide.description }))))
|
|
6412
8385
|
]
|
|
6413
|
-
: this.showPlaceholder(), h("slot", { key: '
|
|
8386
|
+
: this.showPlaceholder(), h("slot", { key: '6b8bebc72d4a7baea765b1e5a6d4a81862206f94', name: "footer" })));
|
|
6414
8387
|
}
|
|
6415
8388
|
get host() { return getElement(this); }
|
|
6416
8389
|
};
|
|
@@ -7403,7 +9376,7 @@ const SallaQuantityInput = class {
|
|
|
7403
9376
|
return this.host;
|
|
7404
9377
|
}
|
|
7405
9378
|
render() {
|
|
7406
|
-
return (h(Host, { key: '
|
|
9379
|
+
return (h(Host, { key: '5627ef48310739dc0a112c9c214f78bae9b71bca', class: "s-quantity-input" }, h("div", { key: '50040d9cd5bbf38d06d6a13f17a1b4d756f5285d', class: "s-quantity-input-container" }, h("button", { key: '334c465e2ac46c3b88e3f89ae3b0754dc3741f69', onClick: () => this.increase(), class: "s-quantity-input-increase-button s-quantity-input-button", type: "button" }, !this.hasIncrementSlot ? h("span", { innerHTML: Add }) : '', h("slot", { key: '9f41e975e7c47f4cbc3e97dd3f8591b633d9da29', name: "increment-button" })), h("input", { key: '6f5bfdeb1804cf98a13f12b966e5fa6582e39557', class: "s-quantity-input-input", ...this.getInputAttributes(), ref: (el) => this.textInput = el, onInput: (event) => this.setValue(event.target.value), min: "1", value: this.quantity }), h("button", { key: '583f5edb96bc5a368851eadb5940d79b7afed3be', class: "s-quantity-input-decrease-button s-quantity-input-button", onClick: () => this.decrease(), type: "button" }, !this.hasDecrementSlot ? h("span", { innerHTML: Minus }) : '', h("slot", { key: '8726d4d616dd6f4fd1348312d3a9c24bf9268146', name: "decrement-button" })))));
|
|
7407
9380
|
}
|
|
7408
9381
|
get host() { return getElement(this); }
|
|
7409
9382
|
static get watchers() { return {
|
|
@@ -8303,7 +10276,7 @@ const SallaQuickBuy = class {
|
|
|
8303
10276
|
});
|
|
8304
10277
|
}
|
|
8305
10278
|
render() {
|
|
8306
|
-
return h(Host, { key: '
|
|
10279
|
+
return h(Host, { key: '46c3a8b699f4390166d027a0eb2d34451a1dd6f1' }, this.quickBuyButton());
|
|
8307
10280
|
}
|
|
8308
10281
|
quickBuyButton() {
|
|
8309
10282
|
return h("apple-pay-button", { locale: salla.config.get('user.language_code'), onClick: () => this.quickBuyHandler(), "data-quick-purchase": "applepay", class: "s-quick-buy-apple-pay", "data-is-applepay": "1", buttonstyle: "black", type: this.type });
|
|
@@ -9351,7 +11324,7 @@ const SallaScopees = class {
|
|
|
9351
11324
|
return salla.onReady();
|
|
9352
11325
|
}
|
|
9353
11326
|
render() {
|
|
9354
|
-
return (h(Host, { key: '
|
|
11327
|
+
return (h(Host, { key: '42ac0a93262d5a6bdd602b97fa636b70c2269635' }, h("salla-modal", { key: '632eca8b8faa74fd990bc5c024befa11d461568f', ref: modal => this.modal = modal, isClosable: !!(this.isOpenedBefore || (this.selection == 'optional')), class: "s-scopes-modal", isLoading: this.loading, "has-skeleton": true }, this.loading ?
|
|
9355
11328
|
h("div", { slot: "loading" }, h("div", { class: "s-scopes-skeleton" }, h("salla-list-tile", { class: "s-scopes-header" }, h("div", { slot: "icon", class: "s-scopes-header-icon" }, h("salla-skeleton", { type: "circle" })), h("div", { slot: "title", class: "s-scopes-header-title mb-5" }, h("salla-skeleton", { height: '15px', width: '50%' })), h("div", { slot: "subtitle", class: "s-scopes-header-subtitle" }, h("salla-skeleton", { height: '10px' }), h("salla-skeleton", { height: '10px', width: '75%' }))), h("div", { class: "s-scopes-skeleton-search" }, h("salla-skeleton", { height: '10px', width: '50%' }), h("salla-skeleton", { height: '30px', width: '100%' })), h("div", { class: "s-scopes-skeleton-scopes" }, h("salla-skeleton", { height: '10px', width: '30%' }), h("salla-skeleton", { height: '10px', width: '25%' }), h("salla-skeleton", { height: '10px', width: '30%' }), h("salla-skeleton", { height: '10px', width: '25%' }), h("salla-skeleton", { height: '10px', width: '30%' }), h("salla-skeleton", { height: '10px', width: '25%' }), h("salla-skeleton", { height: '10px', width: '30%' }), h("salla-skeleton", { height: '10px', width: '25%' })), h("div", { class: "s-scopes-skeleton-btn" }, h("salla-skeleton", { height: '40px', width: '100%' }))))
|
|
9356
11329
|
:
|
|
9357
11330
|
[h("salla-list-tile", { class: this.originalScopesList?.length ? "s-scopes-header block" : "s-hidden" }, h("div", { slot: "icon", class: "s-scopes-header-icon", innerHTML: StoreAlt }), h("div", { slot: "title", class: "s-scopes-header-title" }, salla.lang.get('blocks.scope.you_are_browse_store_from')), h("div", { slot: "subtitle", class: "s-scopes-header-subtitle" }, !!this.selected_scope ? this.selected_scope.name : "")), h("div", { class: "s-scopes-wrap" }, !!this.originalScopesList?.length && h("h4", { class: "s-scopes-title" }, this.getFormTitle()), this.originalScopesList?.length > this.searchDisplayLimit ?
|
|
@@ -9485,12 +11458,12 @@ const SallaSearch = class {
|
|
|
9485
11458
|
this.inputValue.length < 3 ? this.container.classList.remove('s-search-no-results') : '';
|
|
9486
11459
|
}
|
|
9487
11460
|
render() {
|
|
9488
|
-
const searchContent = h("div", { key: '
|
|
9489
|
-
h("salla-button", { loading: this.loading, class: { 's-search-action': true, 's-search-action-oval': this.oval }, onClick: () => this.handleActionClick() }, !this.loading && h("span", { innerHTML: Search })) : null), h("div", { key: '
|
|
11461
|
+
const searchContent = h("div", { key: 'fe1ad73a7d7cdc9bfacb43e5c8f1b2d2c5983f9e', class: { 's-search-container': true, 's-search-inline': this.inline }, ref: container => this.container = container }, h("div", { key: 'df9c5af32950d9fc1ec30f46054630244fd2e2c1', class: "s-search-input-wrapper" }, h("span", { key: 'f4c1788bcd50992364e52388e425cc19c0906ec5', class: "s-search-icon-wrap" }, h("span", { key: 'a46da8c6f02e4970c903dc73d3d4a4e107a543f4', class: "s-search-icon", innerHTML: this.loading ? '<i class="s-search-spinner-loader"/>' : Search })), h("input", { key: 'af5fff2641e6416f06c51c01e19e007c6ff43e32', type: "search", enterkeyhint: "search", autocomplete: "off", class: "s-search-input", placeholder: salla.lang.get('blocks.header.search_placeholder'), onInput: (e) => this.limitWordsAndSearch(e), onKeyDown: e => this.handleKeyDown(e), ref: input => this.searchInput = input, style: { height: this.height + 'px', borderRadius: this.oval ? this.height / 2 + 'px' : '' } }), this.showAction ?
|
|
11462
|
+
h("salla-button", { loading: this.loading, class: { 's-search-action': true, 's-search-action-oval': this.oval }, onClick: () => this.handleActionClick() }, !this.loading && h("span", { innerHTML: Search })) : null), h("div", { key: 'e742cf41fdf23b37a46324df3bac24abc2c9bf03', class: "s-search-results" }, this.results?.data.map((product) => h("a", { href: product.url + '?from=search-bar', class: { "s-search-product": true, 's-search-product-not-available': !product.is_available }, innerHTML: this.productSlot
|
|
9490
11463
|
.replace(/\{name\}/g, product.name)
|
|
9491
11464
|
.replace(/\{price\}/g, product.price ? salla.money(product.price) : '')
|
|
9492
11465
|
.replace(/\{regular_price\}/g, product.is_on_sale && product.regular_price ? salla.money(product.regular_price) : '')
|
|
9493
|
-
.replace(/\{image\}/g, product.image.url) })), h("p", { key: '
|
|
11466
|
+
.replace(/\{image\}/g, product.image.url) })), h("p", { key: 'bea643f12fa014f6df1dee41a1a8ee8c41022458', ref: el => this.noResults = el, class: "s-search-no-results-placeholder" }, salla.lang.get('common.elements.no_options'))));
|
|
9494
11467
|
return (this.inline ?
|
|
9495
11468
|
h("div", { class: "s-search-modal" }, searchContent)
|
|
9496
11469
|
:
|
|
@@ -9533,7 +11506,7 @@ const SallaSkeleton = class {
|
|
|
9533
11506
|
's-skeleton-item': true,
|
|
9534
11507
|
's-skeleton-item-circular': this.type == 'circle',
|
|
9535
11508
|
};
|
|
9536
|
-
return (h(Host, { key: '
|
|
11509
|
+
return (h(Host, { key: 'df1344797b9cbe42331625a2a1f432e07d6bd9ef', class: "s-skeleton-wrapper", style: { width: this.width, height: this.height } }, h("div", { key: 'b56611551bb2b2bcb02b46240e30f88e2ea7aea5', class: classes }, "\u00A0")));
|
|
9537
11510
|
}
|
|
9538
11511
|
};
|
|
9539
11512
|
SallaSkeleton.style = sallaSkeletonCss;
|
|
@@ -10056,7 +12029,7 @@ const SallaSlider = class {
|
|
|
10056
12029
|
classes += this.verticalThumbs ? ' s-slider-vertical ' : ' s-slider-horizontal ';
|
|
10057
12030
|
classes += this.arrowsCentered ? ' s-slider-v-centered ' : '';
|
|
10058
12031
|
classes += this.gridThumbs ? ' s-slider-with-grid-thumbs ' : '';
|
|
10059
|
-
return (h(Host, { key: '
|
|
12032
|
+
return (h(Host, { key: '85e91dde02b7f32655d0ac10e5abb7f9e49d7157', class: 's-slider-wrapper ' + classes }, this.blockTitle || this.showControls ?
|
|
10060
12033
|
h("div", { class: "s-slider-block__title" }, this.blockTitle ?
|
|
10061
12034
|
h("div", { class: "s-slider-block__title-right" }, h("h2", null, this.blockTitle), this.blockSubtitle ? h("p", { innerHTML: this.blockSubtitle }) : '')
|
|
10062
12035
|
: '', h("div", { class: "s-slider-block__title-left" }, this.displayAllUrl ?
|
|
@@ -10064,7 +12037,7 @@ const SallaSlider = class {
|
|
|
10064
12037
|
: '', this.showControls ?
|
|
10065
12038
|
h("div", { class: "s-slider-block__title-nav", dir: "rtl" }, h("button", { "aria-label": "Previous Slide", class: "s-slider-prev s-slider-nav-arrow" }, h("span", { class: "s-slider-button-icon", innerHTML: this.direction == 'rtl' ? ArrowRightIcon : ArrowLeftIcon })), h("button", { "aria-label": "Next Slide", class: "s-slider-next s-slider-nav-arrow" }, h("span", { class: "s-slider-button-icon", innerHTML: this.direction == 'rtl' ? ArrowLeftIcon : ArrowRightIcon })))
|
|
10066
12039
|
: ''))
|
|
10067
|
-
: '', h("div", { key: '
|
|
12040
|
+
: '', h("div", { key: '8842ac56011138fd8456257bff568919c9ce8867', class: "swiper s-slider-container", ref: el => this.sliderContainer = el, dir: this.vertical ? "ltr" : this.direction }, h("slot", { key: '17fb40e69031d4c329df9d00fb75443d0ff9ba0c' }), h("div", { key: 'b8f42b180a271b4a873d99024251705e9d76adde', class: "swiper-wrapper s-slider-swiper-wrapper", ref: el => this.sliderWrapper = el }, h("slot", { key: '82ef4871810000d0b65a24518c6613a6484a2ee9', name: 'items' })), this.pagination ? h("div", { class: "swiper-pagination" }) : ''), this.type == 'thumbs' && this.hasThumbSlot ? h("div", { class: "s-slider-thumbs" }, h("div", { class: "swiper s-slider-thumbs-container", dir: this.getThumbsDirection(), ref: el => this.thumbsSliderContainer = el }, h("div", { class: { "s-slider-swiper-wrapper swiper-wrapper": true, "s-slider-grid-thumbs": this.gridThumbs }, ref: el => this.thumbsSliderWrapper = el }, h("slot", { name: "thumbs" })), this.showThumbsControls ?
|
|
10068
12041
|
h("div", { class: "s-slider-thumbs-nav", dir: "rtl" }, h("button", { "aria-label": "Previous Slide", class: "s-slider-thumbs-prev s-slider-nav-arrow" }, h("span", { class: "s-slider-button-icon", innerHTML: this.direction == 'rtl' ? ArrowRightIcon : ArrowLeftIcon })), h("button", { "aria-label": "Next Slide", class: "s-slider-thumbs-next s-slider-nav-arrow" }, h("span", { class: "s-slider-button-icon", innerHTML: this.direction == 'rtl' ? ArrowLeftIcon : ArrowRightIcon })))
|
|
10069
12042
|
: null))
|
|
10070
12043
|
: null));
|
|
@@ -10227,7 +12200,7 @@ const SallaSocialShare = class {
|
|
|
10227
12200
|
window.a2a?.init('page');
|
|
10228
12201
|
}
|
|
10229
12202
|
render() {
|
|
10230
|
-
return (h("div", { key: '
|
|
12203
|
+
return (h("div", { key: 'e104cbf1051f36e7d1055a96b8d42e0f38b70f21', class: "s-social-share-wrapper" }, h("slot", { key: '8519676943448a6b87b1b3df8dd74b78de72aeb9', name: 'widget' }, h("salla-button", { key: '0be8b0bf52f046f6818b530430ce1e636fcd36c2', "aria-label": "Share", onClick: () => this.open(), class: "s-social-share-btn", shape: "icon", fill: "outline", color: "light" }, h("span", { key: 'e637247fec7fd1a0235a410ca3e28fb4e7eff7f3', innerHTML: this.opened ? Cancel : ShareAlt }))), h("ul", { key: '8a378bac1865b26744ad31e6bf7218174b24bdd6', ref: el => this.shareMenu = el, class: "s-social-share-list a2a_kit share", "data-a2a-url": this.url ? this.url : window.location.href, "data-a2a-title": this.urlName ? this.urlName : document.title }, this.platforms.split(',').map(platform => {
|
|
10231
12204
|
return (h("li", null, h("a", { class: `a2a_button_${platform}`, "aria-label": `Share Via ${platform}` }, this.platformIcons.map((icon) => {
|
|
10232
12205
|
if (icon.name === platform) {
|
|
10233
12206
|
return h("span", { class: "s-social-share-icon", innerHTML: icon.icon });
|
|
@@ -10266,7 +12239,7 @@ const SallaTabContent = class {
|
|
|
10266
12239
|
's-tabs-content': true,
|
|
10267
12240
|
's-tabs-content-selected': this.isSelected
|
|
10268
12241
|
};
|
|
10269
|
-
return (h("div", { key: '
|
|
12242
|
+
return (h("div", { key: '571a30d15d890516a1382ed25239df46de519a12', class: classes }, h("slot", { key: '4ceb77d0d6fb15f28e1bb51ec842b7a658ccc160' })));
|
|
10270
12243
|
}
|
|
10271
12244
|
};
|
|
10272
12245
|
SallaTabContent.style = sallaTabContentCss;
|
|
@@ -10325,7 +12298,7 @@ const SallaTabHeader = class {
|
|
|
10325
12298
|
's-tabs-active': this.isSelected,
|
|
10326
12299
|
};
|
|
10327
12300
|
return [
|
|
10328
|
-
h("div", { key: '
|
|
12301
|
+
h("div", { key: '01eec3d799fd24f75ee29e65447e166057aed846', class: classes, onClick: this.onClick.bind(this) }, h("slot", { key: '200d5e89d7bf9cf232c997fa14c0384be65001c1' })),
|
|
10329
12302
|
];
|
|
10330
12303
|
}
|
|
10331
12304
|
};
|
|
@@ -10378,7 +12351,7 @@ const SallaTabs = class {
|
|
|
10378
12351
|
}
|
|
10379
12352
|
render() {
|
|
10380
12353
|
return [
|
|
10381
|
-
h("div", { key: '
|
|
12354
|
+
h("div", { key: '11dca6efd64c797274f2b71aa10426fbdf08d351', class: "s-tabs" }, h("div", { key: '9afd9c6a09728218cddc084c77f417d0249bdfd9', class: "s-tabs-header" }, h("slot", { key: 'eef1f2faed6b440c592e51f6d1205e140584b070', name: "header" })), h("div", { key: 'adb5bd9c1af2ba78c173eb3fbd5c73c0513ccca5', class: "s-tabs-content-wrapper" }, h("slot", { key: 'db9eaa79d095ef71fb1df1ab96ddbb925ec59b40', name: "content" })))
|
|
10382
12355
|
];
|
|
10383
12356
|
}
|
|
10384
12357
|
get host() { return getElement(this); }
|
|
@@ -10396,7 +12369,7 @@ const SallaTelInput = class {
|
|
|
10396
12369
|
if (this.TelInput)
|
|
10397
12370
|
return;
|
|
10398
12371
|
try {
|
|
10399
|
-
const telInputModule = await import('./index-
|
|
12372
|
+
const telInputModule = await import('./index-CqLymITv.js').then(function (n) { return n.i; });
|
|
10400
12373
|
this.TelInput = telInputModule.default;
|
|
10401
12374
|
}
|
|
10402
12375
|
catch (error) {
|
|
@@ -10510,7 +12483,7 @@ const SallaTelInput = class {
|
|
|
10510
12483
|
}
|
|
10511
12484
|
}
|
|
10512
12485
|
render() {
|
|
10513
|
-
return (h(Host, { key: '
|
|
12486
|
+
return (h(Host, { key: '8dae2336c70ca8da12846544c99eff5150ee3197', class: "s-tel-input" }, h("input", { key: '6512ba297a7f1e85f3e6b1a6ba7634c16e57116c', type: "tel", disabled: this.disabled, name: this.name, value: this.phone, onChange: (event) => this.handleCountryInput(event), ref: el => this.phoneInput = el, enterkeyhint: "next", autocomplete: "tel", class: "s-tel-input-control tel-input s-ltr" }), h("span", { key: '92def9152e10e06c390e8333048095dcc7613867', class: "s-tel-input-error-msg", ref: el => this.errorMsg = el }), h("input", { key: '0a77d8be70d5f9a1e8ac75e444537f0f45fa76d0', type: "hidden", name: "country_code", value: this.countryCode, ref: el => this.countryCodeInput = el, class: "country_code" })));
|
|
10514
12487
|
}
|
|
10515
12488
|
componentDidLoad() {
|
|
10516
12489
|
this.initTelInput();
|
|
@@ -11031,9 +13004,9 @@ const SallaUserSettings = class {
|
|
|
11031
13004
|
await salla.profile.delete().finally(() => this.confirmationModal.close());
|
|
11032
13005
|
}
|
|
11033
13006
|
render() {
|
|
11034
|
-
return (h(Host, { key: '
|
|
13007
|
+
return (h(Host, { key: '85b2fe2739f6ac3c55939d3cb9c87fc404413e7f', class: "s-user-settings-wrapper" }, this.canHideName && h("div", { key: 'e46be8b9cb4898c9b676ee67f0750bb654bda953', class: "s-user-settings-section" }, h("salla-list-tile", { key: '48f81d5a9b511c2a8baabab2aab6ad3dcfb98370' }, h("div", { key: '9009c4d612aea7e7a6834b90f38d03d8c95bcc84', slot: "icon", class: "s-user-settings-section-icon" }, h("span", { key: '03f209e6e1e1adbdb130f9b80aed30f0618dd58c', innerHTML: UserCancel })), h("div", { key: 'fb02ca2387806135ac3f074f0a9f30ce4bb325ca', slot: "title", class: "s-user-settings-section-title" }, this.capitalizeText(this.hideMyName)), h("div", { key: '1ddbd1144a59745bf26f4650eb5d050a34d42e8f', slot: "subtitle", class: "s-user-settings-section-subtitle" }, this.capitalizeText(this.hideMyNameDesc)), h("div", { key: '0ff6163a407a53ff100c8d3235212c167dbb006a', slot: 'action', class: "s-user-settings-section-action" }, h("label", { key: '03b817a0bea880c9a2e056d4d8f0fb737dc0e5da', class: "s-toggle" }, h("input", { key: 'fcb56427c6d1ae503abdc768358e9ecfa9139dac', class: "s-toggle-input", checked: this.isHiddenName, onChange: (e) => this.toggleSetting('is_hidden_name', e), type: "checkbox" }), h("div", { key: 'ff312279ede50b86446d1305217053942d05a603', class: "s-toggle-switcher" }))))), h("div", { key: '08cf0045a6f96ae7046d9a7c640e53a5b2cec7dc', class: "s-user-settings-section" }, h("salla-list-tile", { key: '1ccbcd93cf4cef91693603b5b05dbc4f3b85dc65' }, h("div", { key: 'bf5270f2d2cae798463ab9516c11321e96c461ff', slot: "icon", class: "s-user-settings-section-icon" }, h("span", { key: '3bc3927296faa253a8b91710049eca3372fb24aa', innerHTML: Bullhorn })), h("div", { key: '60ddca373590545a7fd03498e4ff7306a23b05a9', slot: "title", class: "s-user-settings-section-title" }, this.capitalizeText(this.promotionalMsgs)), h("div", { key: '874e81d5e4727160a85bb3381fdfadcd65e774c0', slot: "subtitle", class: "s-user-settings-section-subtitle" }, this.capitalizeText(this.promotionalMsgsDesc)), h("div", { key: '6d2aacf7a72c4d25163913eccbb0a3e94595ec75', slot: 'action', class: "s-user-settings-section-action" }, h("label", { key: 'cf58459624592b34083afe61a0afc29dea03864e', class: "s-toggle" }, h("input", { key: 'b854ce4ca8224c8200623aad0dea4c659d89dee1', class: "s-toggle-input", checked: this.isNotifiable, onChange: (e) => this.toggleSetting('is_notifiable', e), type: "checkbox" }), h("div", { key: '785a5765e36056629a23ca53e48715f91c14ee1f', class: "s-toggle-switcher" }))))), h("div", { key: '9f58724a8d748809b39874efaa861643a78076eb', class: "s-user-settings-section s-user-settings-section-deactivate-user" }, h("salla-list-tile", { key: '12a69027f2822b6fa1e8fb641278932fc2206335' }, h("div", { key: '679eec74598612167c77443e5f6977991b333fd7', slot: "icon", class: "s-user-settings-section-icon" }, h("span", { key: '0263f8f31ad3e4ca60f2bb4bae910c143f2d36a8', innerHTML: UserOff })), h("div", { key: '6c0c17dfbcbb48ae3882b07b58fb0d1245a28cdb', slot: "title", class: "s-user-settings-section-title" }, this.capitalizeText(this.deactivateAccount)), h("div", { key: '07389c3b86b3d8e821b8b9c33cf43de1ee6527db', slot: "subtitle", class: "s-user-settings-section-subtitle" }, this.capitalizeText(this.deactivateDesc)), h("div", { key: 'e98736162d465c0717550eb8231b120acfafc4f6', slot: 'action', class: "s-user-settings-section-action" }, h("salla-button", { key: 'd29c5023b3a35f95c94a06dc87f0e2504b3a6390', fill: "outline", color: "danger", shape: "btn", size: "medium", width: "normal", onClick: () => this.openDeactivateModal() }, this.capitalizeText(this.deactivateAccount))))), h("salla-modal", { key: '6f23ca61fe62de261e7d2f616a4d5bf13fba1577', width: "sm", subTitle: this.capitalizeText(this.sorryForLeavingText), ref: modal => this.confirmationModal = modal }, h("span", { key: '89073dfc15d4a1349618180c776968012e843556', slot: 'icon', class: "s-user-settings-confirmation-icon", innerHTML: UserOff }), h("div", { key: 'f464a56ab783c4ddd51cc40e4d4dbf2f4ae21be2', class: "s-user-settings-confirmation" }, h("div", { key: 'e9921faaf8718ba51937006360b11d409bde4e05', class: "s-user-settings-confirmation-warning" }, this.capitalizeText(this.warningText)), h("div", { key: '4a71df323e6fa2b86cb85e77af438a51e9c1c5a9', class: "s-user-settings-confirmation-actions" }, h("salla-button", { key: '156249d17bdcc25b7c586af416001ec60e8b0f5b', width: "wide", onClick: () => this.confirmationModal.close() }, this.capitalizeText(this.keepAccount)), h("salla-button", { key: 'acbe44c04f77f8ccdcaeb90bfb731de399f88fc7', fill: 'outline', loading: this.buttonLoading, width: "wide", onClick: () => this.deleteAccount() }, this.capitalizeText(this.deactivateAccount)))))));
|
|
11035
13008
|
}
|
|
11036
13009
|
};
|
|
11037
13010
|
SallaUserSettings.style = sallaUserSettingsCss;
|
|
11038
13011
|
|
|
11039
|
-
export { SallaAddProductButton as salla_add_product_button, SallaAlert as salla_alert, SallaBottomAlert as salla_bottom_alert, SallaBreadcrumb as salla_breadcrumb, SallaButton as salla_button, SallaCartSummary as salla_cart_summary, SallaColorPicker as salla_color_picker, SallaCommentForm as salla_comment_form, SallaCommentItem as salla_comment_item, SallaComments as salla_comments, SallaCountDown as salla_count_down, SallaDatetimePicker as salla_datetime_picker, SallaDrawer as salla_drawer, SallaFileUpload as salla_file_upload, SallaGifting as salla_gifting, SallaInfiniteScroll as salla_infinite_scroll, SallaListTile as salla_list_tile, SallaLoading as salla_loading, SallaLocalizationModal as salla_localization_modal, SallaLoginModal as salla_login_modal, SallaLoyalty as salla_loyalty, SallaMaintenanceAlert as salla_maintenance_alert, SallaMap as salla_map, SallaMenu as salla_menu, SallaModal as salla_modal, SallaOfferModal as salla_offer_modal, SallaPlaceholder as salla_placeholder, SallaProductAvailability as salla_product_availability, SallaProductCard as salla_product_card, SallaProductSizeGuide as salla_product_size_guide, SallaProductsList as salla_products_list, SallaProductsSlider as salla_products_slider, SallaProgressBar as salla_progress_bar, SallaQuantityInput as salla_quantity_input, SallaQuickBuy as salla_quick_buy, SallaQuickOrder as salla_quick_order, SallaRatingModal as salla_rating_modal, SallaRatingStars as salla_rating_stars, SallaReviewsSummary as salla_reviews_summary, SallaScopees as salla_scopes, SallaSearch as salla_search, SallaSkeleton as salla_skeleton, SallaSlider as salla_slider, SallaSocialShare as salla_social_share, SallaTabContent as salla_tab_content, SallaTabHeader as salla_tab_header, SallaTabs as salla_tabs, SallaTelInput as salla_tel_input, SallaUserMenu as salla_user_menu, SallaUserProfile as salla_user_profile, SallaUserSettings as salla_user_settings };
|
|
13012
|
+
export { SallaAccordion as salla_accordion, SallaAccordionBody as salla_accordion_body, SallaAccordionHead as salla_accordion_head, SallaAddProductButton as salla_add_product_button, SallaAlert as salla_alert, SallaBookingField as salla_booking_field, SallaBottomAlert as salla_bottom_alert, SallaBreadcrumb as salla_breadcrumb, SallaButton as salla_button, SallaCartSummary as salla_cart_summary, SallaColorPicker as salla_color_picker, SallaCommentForm as salla_comment_form, SallaCommentItem as salla_comment_item, SallaComments as salla_comments, SallaConditionalFields as salla_conditional_fields, SallaCountDown as salla_count_down, SallaDatetimePicker as salla_datetime_picker, SallaDrawer as salla_drawer, SallaFileUpload as salla_file_upload, SallaGifting as salla_gifting, SallaInfiniteScroll as salla_infinite_scroll, SallaListTile as salla_list_tile, SallaLoading as salla_loading, SallaLocalizationModal as salla_localization_modal, SallaLoginModal as salla_login_modal, SallaLoyalty as salla_loyalty, SallaMaintenanceAlert as salla_maintenance_alert, SallaMap as salla_map, SallaMenu as salla_menu, SallaModal as salla_modal, SallaMultipleBundleProduct as salla_multiple_bundle_product, SallaMultipleBundleProductCart as salla_multiple_bundle_product_cart, SallaMultipleBundleProductDetails as salla_multiple_bundle_product_details, SallaMultipleBundleProductOptionsModal as salla_multiple_bundle_product_options_modal, SallaMultipleBundleProductSlider as salla_multiple_bundle_product_slider, SallaOfferModal as salla_offer_modal, SallaPlaceholder as salla_placeholder, SallaProductAvailability as salla_product_availability, SallaProductCard as salla_product_card, SallaProductOptions as salla_product_options, SallaProductSizeGuide as salla_product_size_guide, SallaProductsList as salla_products_list, SallaProductsSlider as salla_products_slider, SallaProgressBar as salla_progress_bar, SallaQuantityInput as salla_quantity_input, SallaQuickBuy as salla_quick_buy, SallaQuickOrder as salla_quick_order, SallaRatingModal as salla_rating_modal, SallaRatingStars as salla_rating_stars, SallaReviewsSummary as salla_reviews_summary, SallaScopees as salla_scopes, SallaSearch as salla_search, SallaSkeleton as salla_skeleton, SallaSlider as salla_slider, SallaSocialShare as salla_social_share, SallaTabContent as salla_tab_content, SallaTabHeader as salla_tab_header, SallaTabs as salla_tabs, SallaTelInput as salla_tel_input, SallaUserMenu as salla_user_menu, SallaUserProfile as salla_user_profile, SallaUserSettings as salla_user_settings };
|