@salla.sa/twilight-components 2.11.25 → 2.11.27

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.
Files changed (52) hide show
  1. package/dist/cjs/camera-058ddeeb.js +13 -0
  2. package/dist/cjs/index-1d2b3370.js +10 -2
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/{salla-button_37.cjs.entry.js → salla-button_36.cjs.entry.js} +66 -348
  5. package/dist/cjs/salla-conditional-fields.cjs.entry.js +99 -0
  6. package/dist/cjs/salla-product-options.cjs.entry.js +257 -0
  7. package/dist/cjs/twilight.cjs.js +1 -1
  8. package/dist/collection/collection-manifest.json +1 -0
  9. package/dist/collection/components/salla-product-options/salla-product-options.js +11 -4
  10. package/dist/collection/components/salla-progress-bar/salla-progress-bar.css +34 -0
  11. package/dist/collection/components/salla-progress-bar/salla-progress-bar.js +196 -0
  12. package/dist/collection/components/salla-slider/salla-slider.js +13 -10
  13. package/dist/collection/global/app-dev.js +5 -0
  14. package/dist/components/index.d.ts +1 -0
  15. package/dist/components/index.js +1 -0
  16. package/dist/components/salla-product-options.js +32 -21
  17. package/dist/components/salla-progress-bar.d.ts +11 -0
  18. package/dist/components/salla-progress-bar.js +9 -0
  19. package/dist/components/salla-progress-bar2.js +81 -0
  20. package/dist/components/salla-slider2.js +11 -8
  21. package/dist/esm/camera-647ab50f.js +11 -0
  22. package/dist/esm/index-f1d446ac.js +10 -2
  23. package/dist/esm/loader.js +1 -1
  24. package/dist/esm/{salla-button_37.entry.js → salla-button_36.entry.js} +65 -346
  25. package/dist/esm/salla-conditional-fields.entry.js +95 -0
  26. package/dist/esm/salla-product-options.entry.js +253 -0
  27. package/dist/esm/twilight.js +1 -1
  28. package/dist/esm-es5/camera-647ab50f.js +4 -0
  29. package/dist/esm-es5/index-f1d446ac.js +1 -1
  30. package/dist/esm-es5/loader.js +1 -1
  31. package/dist/esm-es5/salla-button_36.entry.js +53 -0
  32. package/dist/esm-es5/salla-conditional-fields.entry.js +4 -0
  33. package/dist/esm-es5/salla-product-options.entry.js +4 -0
  34. package/dist/esm-es5/twilight.js +1 -1
  35. package/dist/twilight/p-1b87ab66.system.js +1 -1
  36. package/dist/twilight/p-485b62a3.entry.js +36 -0
  37. package/dist/twilight/p-56830c52.system.entry.js +4 -0
  38. package/dist/twilight/p-643ea74e.entry.js +4 -0
  39. package/dist/twilight/p-79264f27.system.entry.js +53 -0
  40. package/dist/twilight/p-9b7452c1.entry.js +4 -0
  41. package/dist/twilight/p-c328c14e.system.js +4 -0
  42. package/dist/twilight/p-ccd78636.js +4 -0
  43. package/dist/twilight/p-dbe8db94.system.entry.js +4 -0
  44. package/dist/twilight/twilight.esm.js +1 -1
  45. package/dist/types/components/salla-product-options/interfaces.d.ts +9 -0
  46. package/dist/types/components/salla-progress-bar/salla-progress-bar.d.ts +35 -0
  47. package/dist/types/components/salla-slider/salla-slider.d.ts +1 -1
  48. package/dist/types/components.d.ts +72 -2
  49. package/package.json +4 -4
  50. package/dist/esm-es5/salla-button_37.entry.js +0 -53
  51. package/dist/twilight/p-11da4b05.entry.js +0 -36
  52. package/dist/twilight/p-cd5fda9d.system.entry.js +0 -53
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-f1d446ac.js';
5
5
  import { a as createCommonjsModule, c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-1415ffd3.js';
6
+ import { C as CameraIcon } from './camera-647ab50f.js';
6
7
 
7
8
  const sallaButtonCss = "";
8
9
 
@@ -2695,95 +2696,6 @@ const SallaCommentForm = class {
2695
2696
  };
2696
2697
  SallaCommentForm.style = sallaCommentFormCss;
2697
2698
 
2698
- const SallaConditionalFields = class {
2699
- constructor(hostRef) {
2700
- registerInstance(this, hostRef);
2701
- }
2702
- hideAllOptions(optionId) {
2703
- this.host.querySelectorAll(`[data-show-when^="options[${optionId}"]`).forEach((field) => {
2704
- field.classList.add('hidden');
2705
- this.hideAllOptions(field.dataset.optionId);
2706
- this.disableInputs(field);
2707
- });
2708
- }
2709
- disableInputs(field) {
2710
- field.querySelectorAll('[name]').forEach((input) => {
2711
- var _a;
2712
- input.setAttribute('disabled', '');
2713
- input.removeAttribute('required');
2714
- if (((_a = input === null || input === void 0 ? void 0 : input.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'select') {
2715
- input.value = '';
2716
- }
2717
- if (['checkbox'].includes(input.getAttribute('type')) && input.hasOwnProperty('checked')) {
2718
- // @ts-ignore
2719
- input.checked = false;
2720
- }
2721
- });
2722
- }
2723
- changeHandler(event) {
2724
- var _a;
2725
- salla.event.emit('salla-onditional-fields::change', event);
2726
- salla.log('Received the change event: ', event);
2727
- if (!event.target || !['SELECT'].includes(event.target.tagName) && !['checkbox'].includes(event.target.getAttribute('type'))) {
2728
- salla.log('Ignore the change because is not support input: ' + (((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.tagName) || 'N/A'));
2729
- return;
2730
- }
2731
- // to extract the option id from the input name, the supported names are name[*] and name[*][]
2732
- let optionId = event.target.name.replace('[]', '');
2733
- let isMultiple = event.target.getAttribute('type') === 'checkbox';
2734
- salla.log('Trying to find all the element with condition:', `[data-show-when^="${optionId}"]`);
2735
- this.host.querySelectorAll(`[data-show-when^="${optionId}"]`)
2736
- .forEach((field) => {
2737
- let isEqual = !(field === null || field === void 0 ? void 0 : field.dataset.showWhen.includes('!='));
2738
- let value = field === null || field === void 0 ? void 0 : field.dataset.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$3').trim();
2739
- // let isSelected = isMultiple ? event.target?.checked : value === event.target.value;
2740
- let isSelected;
2741
- if (isMultiple) {
2742
- // @ts-ignore
2743
- let selectedValues = Array.from(this.host.querySelectorAll(`input[name="${event.target.name}"]:checked`), e => e === null || e === void 0 ? void 0 : e.value);
2744
- isSelected = selectedValues.includes(value.toString());
2745
- }
2746
- else {
2747
- isSelected = value === event.target.value;
2748
- }
2749
- salla.log('The input is ', (isMultiple ? 'Multiple' : 'Single'), ' value:', isSelected);
2750
- let showTheInput = (isEqual && isSelected) || (!isEqual && !isSelected);
2751
- if (showTheInput) {
2752
- field.classList.remove('hidden');
2753
- field.querySelectorAll('[name]').forEach((input) => {
2754
- input.removeAttribute('disabled');
2755
- //To handle focus on hidden input error
2756
- if (!['checkbox'].includes(input.getAttribute('type')) && field.getElementsByClassName('required').length) {
2757
- input.setAttribute('required', '');
2758
- }
2759
- });
2760
- }
2761
- else {
2762
- this.hideAllOptions(field.dataset.optionId);
2763
- field.classList.add('hidden');
2764
- this.disableInputs(field);
2765
- }
2766
- });
2767
- }
2768
- componentDidRender() {
2769
- this.host.querySelectorAll(`[data-show-when]`).forEach((field) => {
2770
- var _a;
2771
- // @ts-ignore
2772
- let optionName = (_a = field === null || field === void 0 ? void 0 : field.dataset) === null || _a === void 0 ? void 0 : _a.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$1').trim();
2773
- if (!optionName) {
2774
- return;
2775
- }
2776
- this.changeHandler({
2777
- target: this.host.querySelector('[name^="' + optionName + '"]')
2778
- });
2779
- });
2780
- }
2781
- render() {
2782
- return (h(Host, null, h("slot", null)));
2783
- }
2784
- get host() { return getElement(this); }
2785
- };
2786
-
2787
2699
  var HOOKS = [
2788
2700
  "onChange",
2789
2701
  "onClose",
@@ -21663,13 +21575,6 @@ const MailIcon = `<!-- Generated by IcoMoon.io -->
21663
21575
  </svg>
21664
21576
  `;
21665
21577
 
21666
- const CameraIcon = `<!-- Generated by IcoMoon.io -->
21667
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
21668
- <title>camera</title>
21669
- <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>
21670
- </svg>
21671
- `;
21672
-
21673
21578
  const ArrowRightIcon$1 = `<!-- Generated by IcoMoon.io -->
21674
21579
  <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
21675
21580
  <title>keyboard_arrow_right</title>
@@ -23309,247 +23214,6 @@ const SallaProductAvailability = class {
23309
23214
  };
23310
23215
  SallaProductAvailability.style = sallaProductAvailabilityCss;
23311
23216
 
23312
- var DisplayType;
23313
- (function (DisplayType) {
23314
- DisplayType["COLOR"] = "color";
23315
- DisplayType["DATE"] = "date";
23316
- DisplayType["DATETIME"] = "datetime";
23317
- DisplayType["DONATION"] = "donation";
23318
- DisplayType["IMAGE"] = "image";
23319
- DisplayType["MULTIPLE_OPTIONS"] = "multiple-options";
23320
- DisplayType["NUMBER"] = "number";
23321
- DisplayType["SINGLE_OPTION"] = "single-option";
23322
- DisplayType["SPLITTER"] = "splitter";
23323
- DisplayType["TEXT"] = "text";
23324
- DisplayType["TEXTAREA"] = "textarea";
23325
- DisplayType["THUMBNAIL"] = "thumbnail";
23326
- DisplayType["TIME"] = "time";
23327
- DisplayType["RADIO"] = "radio";
23328
- DisplayType["CHECKBOX"] = "checkbox";
23329
- DisplayType["MAP"] = "map";
23330
- DisplayType["FILE"] = "file";
23331
- DisplayType["COLOR_PICKER"] = "color_picker";
23332
- })(DisplayType || (DisplayType = {}));
23333
- var Currency;
23334
- (function (Currency) {
23335
- Currency["Sar"] = "SAR";
23336
- })(Currency || (Currency = {}));
23337
-
23338
- const CheckCircleIcon = `<!-- Generated by IcoMoon.io -->
23339
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
23340
- <title>check</title>
23341
- <path d="M27.521 6.976c-0.569-0.472-1.407-0.393-1.879 0.171l-12.567 15.080-7.003-4.668c-0.615-0.411-1.441-0.244-1.849 0.369-0.409 0.612-0.244 1.441 0.369 1.849l8 5.333c0.227 0.149 0.484 0.223 0.739 0.223 0.384 0 0.763-0.165 1.027-0.48l13.333-16c0.471-0.565 0.393-1.407-0.171-1.877z"></path>
23342
- </svg>
23343
- `;
23344
-
23345
- const FileIcon = `<!-- Generated by IcoMoon.io -->
23346
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
23347
- <title>file-upload</title>
23348
- <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>
23349
- </svg>
23350
- `;
23351
-
23352
- const sallaProductOptionsCss = "";
23353
-
23354
- const SallaProductOptions = class {
23355
- constructor(hostRef) {
23356
- registerInstance(this, hostRef);
23357
- this.colorSelected = createEvent(this, "colorSelected", 7);
23358
- this.thumbnailSelected = createEvent(this, "thumbnailSelected", 7);
23359
- this.singleSelectOptionSelected = createEvent(this, "singleSelectOptionSelected", 7);
23360
- this.donationMoneyEntered = createEvent(this, "donationMoneyEntered", 7);
23361
- this.textOptionEntered = createEvent(this, "textOptionEntered", 7);
23362
- this.textareaOptionEntered = createEvent(this, "textareaOptionEntered", 7);
23363
- this.numberOptionEntered = createEvent(this, "numberOptionEntered", 7);
23364
- this.itemsSelected = createEvent(this, "itemsSelected", 7);
23365
- this.dateTimeSelected = createEvent(this, "dateTimeSelected", 7);
23366
- this.dateSelected = createEvent(this, "dateSelected", 7);
23367
- this.timeSelected = createEvent(this, "timeSelected", 7);
23368
- this.colorPicked = createEvent(this, "colorPicked", 7);
23369
- this.locationSelected = createEvent(this, "locationSelected", 7);
23370
- this.fileTypes = {
23371
- pdf: 'application/pdf',
23372
- png: 'image/png',
23373
- jpg: 'image/jpeg',
23374
- word: 'application/msword',
23375
- exl: 'application/vnd.ms-excel',
23376
- txt: 'text/plain',
23377
- };
23378
- this.outOfStockText = salla.lang.get("pages.products.out_of_stock");
23379
- this.donationAmount = salla.lang.get('pages.products.donation_amount');
23380
- /**
23381
- * The id of the product to which the options are going to be fetched for.
23382
- */
23383
- this.productId = salla.config.get('page.id');
23384
- salla.lang.onLoaded(() => {
23385
- this.outOfStockText = salla.lang.get("pages.products.out_of_stock");
23386
- this.donationAmount = salla.lang.get('pages.products.donation_amount');
23387
- });
23388
- if (this.options) {
23389
- try {
23390
- this.optionsData = JSON.parse(this.options);
23391
- return;
23392
- }
23393
- catch (e) {
23394
- salla.log('Bad json passed via options prop');
23395
- }
23396
- }
23397
- if (Array.isArray(this.optionsData)) {
23398
- salla.log('Options is not an array[] ---> ', this.optionsData);
23399
- this.optionsData = [];
23400
- }
23401
- if (this.productId && !salla.url.is_page('cart')) {
23402
- salla.api.product.getDetails(this.productId, ['options']).then(resp => this.optionsData = resp.data.options);
23403
- }
23404
- }
23405
- //todo:: typo here, but I think we will drop it anyway😌
23406
- handleMultiSelectFieldInput() {
23407
- var checkedBoxes = this.multipleOptionDom.querySelectorAll('input[type="checkbox"]:checked');
23408
- var multiSelectedItems = [];
23409
- for (let checkbox of checkedBoxes) {
23410
- multiSelectedItems.push(checkbox.value);
23411
- }
23412
- this.itemsSelected.emit(multiSelectedItems);
23413
- }
23414
- getLatLng(value, type) {
23415
- return value
23416
- ? value.split(',')[type == 'lat' ? 0 : 1]
23417
- : '';
23418
- }
23419
- getDisplayForType(option) {
23420
- if (this[`${option.type}Option`]) {
23421
- return this[`${option.type}Option`](option);
23422
- }
23423
- if (option.type === DisplayType.COLOR_PICKER) {
23424
- return this.colorPickerOption(option);
23425
- }
23426
- if (option.type === DisplayType.MULTIPLE_OPTIONS) {
23427
- return this.multipleOptions(option);
23428
- }
23429
- if (option.type === DisplayType.SINGLE_OPTION) {
23430
- return this.singleOption(option);
23431
- }
23432
- salla.log(`Couldn't find options type(${option.type})😢`);
23433
- return '';
23434
- }
23435
- getOptionShownWhen(option) {
23436
- return option.visibility_condition
23437
- ? { "data-show-when": `options[${option.visibility_condition.option}] ${option.visibility_condition.operator} ${option.visibility_condition.value}` }
23438
- : {};
23439
- }
23440
- //we need the cart Id for productOption Image
23441
- componentWillLoad() {
23442
- return salla.api.cart.getCurrentCartId();
23443
- }
23444
- render() {
23445
- if (this.optionsData.length == 0) {
23446
- return;
23447
- }
23448
- return (h(Host, { class: "s-product-options-wrapper" }, h("salla-conditional-fields", null, this.optionsData.map((option) => h("div", Object.assign({ class: `s-product-options-option-container${option.visibility_condition ? ' hidden' : ''}`, "data-option-id": option.id }, this.getOptionShownWhen(option)), option.name == 'splitter' ?
23449
- this.splitterOption()
23450
- : h("div", { class: "s-product-options-option" }, h("label", { htmlFor: 'options[' + option.id + ']', class: "s-product-options-option-label" }, h("b", null, option.name, option.required && h("span", null, " * "), " "), h("small", null, option.placeholder)), h("div", { class: "s-product-options-option-content" }, this.getDisplayForType(option))))))));
23451
- }
23452
- //@ts-ignore
23453
- donationOption(option) {
23454
- return h("div", { class: "s-product-options-donation-wrapper" }, h("input", { type: "text", id: "donating-amount", name: "donating_amount", class: "s-form-control", value: option.value, placeholder: option.placeholder, onInput: e => salla.helpers.inputDigitsOnly(e.target), onBlur: e => this.donationMoneyEntered.emit(e) }), h("span", { class: "s-product-options-donation-amount-currency" }, salla.config.currency(salla.config.get('user.currency_code')).symbol));
23455
- }
23456
- //todo:: why we need this way, use the native way!!
23457
- //@ts-ignore
23458
- selectThumbnail(e, value) {
23459
- this.thumbnailSelected.emit(e);
23460
- }
23461
- fileUploader(option, additions = null) {
23462
- return h("salla-file-upload", Object.assign({}, (additions || {}), { "payload-name": "file", value: option.value, "instant-upload": true, name: `options[${option.id}]`, height: "120px", url: salla.cart.api.getUploadImageEndpoint(), "form-data": { cart_item_id: this.productId, product_id: this.productId }, 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 && additions.accept.split(',').every(type => type.includes('image'))
23463
- ? CameraIcon
23464
- : 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'))));
23465
- }
23466
- //@ts-ignore
23467
- imageOption(option) {
23468
- return this.fileUploader(option, { accept: 'image/png,image/jpeg,image/jpg,image/gif' });
23469
- }
23470
- //@ts-ignore
23471
- fileOption(option) {
23472
- let types = option.details.map(detail => this.fileTypes[detail.name]).filter(Boolean);
23473
- return types.length
23474
- ? this.fileUploader(option, { accept: types.join(',') })
23475
- : 'File types not selected.';
23476
- }
23477
- //@ts-ignore
23478
- numberOption(option) {
23479
- return h("input", { type: "text", value: option.value, class: "s-form-control", required: option.required, name: `options[${option.id}]`, placeholder: option.placeholder, onBlur: e => this.numberOptionEntered.emit(e), onInput: e => salla.helpers.inputDigitsOnly(e.target) });
23480
- }
23481
- //@ts-ignore
23482
- splitterOption() {
23483
- return h("div", { class: "s-product-options-splitter" });
23484
- }
23485
- //@ts-ignore
23486
- textOption(option) {
23487
- return h("div", { class: "s-product-options-text" }, h("input", { type: "text", value: option.value, class: 's-form-control', required: option.required, name: `options[${option.id}]`, placeholder: option.placeholder, onInput: e => this.textOptionEntered.emit(e) }));
23488
- }
23489
- //@ts-ignore
23490
- textareaOption(option) {
23491
- //todo::remove mt-1 class, and if it's okay to remove the tag itself will be great
23492
- return h("div", { class: "s-product-options-textarea" }, h("div", { class: "mt-1" }, h("textarea", { rows: 4, value: option.value, class: "s-form-control", required: option.required, id: `options[${option.id}]`, name: `options[${option.id}]`, placeholder: option.placeholder, onInput: (e) => this.textareaOptionEntered.emit(e) })));
23493
- }
23494
- //@ts-ignore
23495
- mapOption(option) {
23496
- return h("salla-map", { zoom: 15, lat: this.getLatLng(option.value, 'lat'), lng: this.getLatLng(option.value, 'lng'), name: `options[${option.id}]`, searchable: true, required: option.required, onSelected: e => this.locationSelected.emit(e) });
23497
- }
23498
- colorPickerOption(option) {
23499
- return h("salla-color-picker", { onSubmitted: e => this.colorPicked.emit(e), name: `options[${option.id}]`, required: option.required, color: option.value || '#5dd5c4' });
23500
- }
23501
- /**
23502
- * ============= Date Time options =============
23503
- */
23504
- //@ts-ignore
23505
- timeOption(option) {
23506
- return h("salla-datetime-picker", { noCalendar: true, enableTime: true, dateFormat: "h:i K", value: option.value, placeholder: option.name, required: option.required, name: `options[${option.id}]`, class: "s-product-options-time-element", onPicked: e => this.timeSelected.emit(e) });
23507
- }
23508
- //@ts-ignore
23509
- dateOption(option) {
23510
- //todo:: consider date-range @see https://github.com/SallaApp/theme-raed/blob/master/src/assets/js/partials/product-options.js#L8-L23
23511
- return h("div", { class: "s-product-options-date-element" }, h("salla-datetime-picker", { value: option.value, placeholder: option.name, required: option.required, name: `options[${option.id}]`, onPicked: e => this.dateSelected.emit(e) }));
23512
- }
23513
- //@ts-ignore
23514
- datetimeOption(option) {
23515
- //todo:: consider date-range @see https://github.com/SallaApp/theme-raed/blob/master/src/assets/js/partials/product-options.js#L8-L23
23516
- 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.required, name: `options[${option.id}]`, maxDate: option.to_date_time, minDate: option.from_date_time, onPicked: e => this.dateTimeSelected.emit(e) }));
23517
- }
23518
- /**
23519
- * ============= Advanced options =============
23520
- */
23521
- getOptionDetailName(detail, outOfStock = true) {
23522
- return detail.name
23523
- + ((outOfStock && detail.is_out) ? ` - ${this.outOfStockText}` : '')
23524
- + (detail.additional_price ? ` (${salla.money(detail.additional_price)})` : '');
23525
- }
23526
- singleOption(option) {
23527
- return h("div", null, h("select", { name: `options[${option.id}]`, required: option.required, class: "s-form-control" }, h("option", { value: "" }, option.placeholder), option === null || option === void 0 ? void 0 :
23528
- option.details.map((detail) => {
23529
- return h("option", { value: detail.id, disabled: detail.is_out, selected: detail.is_selected, onChange: e => this.singleSelectOptionSelected.emit(e) }, this.getOptionDetailName(detail));
23530
- })));
23531
- }
23532
- multipleOptions(option) {
23533
- return h("div", { ref: element => this.multipleOptionDom = element, class: { "s-product-options-multiple-options-wrapper": true, 'required': option.required } }, option === null || option === void 0 ? void 0 : option.details.map((detail) => {
23534
- return h("div", null, h("input", { type: "checkbox", value: detail.id, disabled: detail.is_out, checked: detail.is_selected, name: `options[${option.id}][]`, id: `field-${option.id}-${detail.id}`, onChange: () => this.handleMultiSelectFieldInput(), "aria-describedby": `options[${option.id}]-description` }), h("label", { htmlFor: `field-${option.id}-${detail.id}` }, this.getOptionDetailName(detail)));
23535
- }));
23536
- }
23537
- //@ts-ignore
23538
- colorOption(option) {
23539
- return h("fieldset", { class: "s-product-options-colors-wrapper" }, option === null || option === void 0 ? void 0 : option.details.map((detail) => h("div", null, h("input", { type: "radio", value: detail.id, disabled: detail.is_out, required: option.required, checked: detail.is_selected, name: `options[${option.id}]`, id: `color-${this.productId}-${option.id}-${detail.id}`, onChange: e => this.colorSelected.emit(e) }), h("label", { htmlFor: `color-${this.productId}-${option.id}-${detail.id}` }, h("span", { style: { "background-color": detail.color } }), h("p", null, this.getOptionDetailName(detail))))));
23540
- }
23541
- //@ts-ignore
23542
- thumbnailOption(option) {
23543
- return h("div", { class: "s-product-options-thumbnails-wrapper" }, option.details.map((detail) => {
23544
- return h("div", null, h("input", { type: "radio", value: detail.id, "data-itemid": detail.id, disabled: detail.is_out, required: option.required, checked: detail.is_selected, name: `options[${option.id}]`, "data-img-id": detail.option_value, id: `option_${this.productId}-${option.id}_${detail.id}`, onChange: (e) => this.selectThumbnail(e, detail.option_value) }), h("label", { htmlFor: `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: CheckCircleIcon, class: "s-product-options-thumbnails-icon" })), h("p", null, this.getOptionDetailName(detail, false), " "), detail.is_out ?
23545
- [h("small", { class: "s-product-options-thumbnails-stock-badge" }, this.outOfStockText), h("div", { class: "s-product-options-thumbnails-badge-overlay" })]
23546
- : '');
23547
- }));
23548
- }
23549
- get host() { return getElement(this); }
23550
- };
23551
- SallaProductOptions.style = sallaProductOptionsCss;
23552
-
23553
23217
  const PencilRuler = `<!-- Generated by IcoMoon.io -->
23554
23218
  <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
23555
23219
  <title>pencil-ruler</title>
@@ -23609,6 +23273,58 @@ const SallaProductSizeGuide = class {
23609
23273
  };
23610
23274
  SallaProductSizeGuide.style = sallaProductSizeGuideCss;
23611
23275
 
23276
+ const sallaProgressBarCss = ".s-progress-bar-header{font-size:0.875rem;line-height:1.25rem;color:#6b7280;font-weight:bold}.s-progress-bar-target-section{display:-ms-flexbox;display:flex;margin-bottom:0.625rem;font-size:0.875rem;line-height:1.25rem;-ms-flex-pack:justify;justify-content:space-between}.s-progress-bar-container{margin-bottom:0.625rem}.s-progress-bar-wrapper{background-color:#E5E7EB;width:100%;height:0.625rem;border-radius:9999px;margin-bottom:0.375rem}.s-progress-bar-progress{height:0.625rem;border-radius:9999px}.s-progress-bar-message{color:#a2a8b4;font-size:0.75rem;line-height:1rem;display:block;margin-bottom:0.625rem}";
23277
+
23278
+ const SallaProgressBar = class {
23279
+ constructor(hostRef) {
23280
+ registerInstance(this, hostRef);
23281
+ try {
23282
+ if (this.donation) {
23283
+ let donationJson = typeof this.donation == 'string' ? JSON.parse(this.donation) : this.donation;
23284
+ if (donationJson.can_donate) {
23285
+ this.value = donationJson.collected_amount;
23286
+ this.target = donationJson.target_amount;
23287
+ this.header = salla.lang.get('pages.products.target');
23288
+ this.message = salla.lang.get('pages.products.donation_target_date') + ' ' + donationJson.target_end_date;
23289
+ }
23290
+ else {
23291
+ this.message = donationJson.target_message;
23292
+ }
23293
+ }
23294
+ }
23295
+ catch (e) {
23296
+ salla.log('Wrong donation json');
23297
+ }
23298
+ salla.lang.onLoaded(() => {
23299
+ var _a, _b;
23300
+ this.header = (_a = this.header) === null || _a === void 0 ? void 0 : _a.replace('pages.products.target', salla.lang.get('pages.products.target'));
23301
+ this.message = (_b = this.message) === null || _b === void 0 ? void 0 : _b.replace('pages.products.donation_target_date', salla.lang.get('pages.products.donation_target_date'));
23302
+ });
23303
+ salla.onReady(() => {
23304
+ this.color = this.color || salla.config.get('theme.color.primary', "#ffd5c4");
23305
+ if (!this.unit) {
23306
+ this.unit = salla.config.currency().symbol;
23307
+ }
23308
+ });
23309
+ }
23310
+ getPercentage() {
23311
+ return (this.value / this.target) * 100;
23312
+ }
23313
+ render() {
23314
+ if (!this.target && !this.message) {
23315
+ return '';
23316
+ }
23317
+ return (h("div", { class: "s-progress-bar-container" }, this.header ? h("div", { class: "s-progress-bar-header" }, this.header) : '', this.getProgressBar(), this.message ? h("span", { class: "s-progress-bar-message" }, this.message) : ''));
23318
+ }
23319
+ getProgressBar() {
23320
+ return this.target ? [
23321
+ h("div", { class: "s-progress-bar-target-section" }, h("span", null, salla.helpers.number(this.value), " ", this.unit), h("span", null, salla.helpers.number(this.target), " ", this.unit)),
23322
+ h("div", { class: "s-progress-bar-wrapper" }, h("div", { class: "s-progress-bar-progress", style: { 'width': `${this.getPercentage()}%`, 'background-color': this.color } }))
23323
+ ] : '';
23324
+ }
23325
+ };
23326
+ SallaProgressBar.style = sallaProgressBarCss;
23327
+
23612
23328
  const Add = `<!-- Generated by IcoMoon.io -->
23613
23329
  <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
23614
23330
  <title>add</title>
@@ -24736,7 +24452,7 @@ const SallaSwiper = class {
24736
24452
  this.displayAllTitle = salla.lang.get('blocks.home.display_all');
24737
24453
  });
24738
24454
  this.hasThumbSlot = !!this.host.querySelector('[slot="thumbs"]');
24739
- // if (this.enableCallToSlide) {
24455
+ // if (this.enableCallToSlide) {
24740
24456
  // salla.event.on('product-options::goToSlide', data => {
24741
24457
  // const slideIndex = this.sliderWrapper.querySelector(`[data-img-id="${data}"]`).getAttribute('data-slid-index');
24742
24458
  // this.slideTo(parseInt(slideIndex), 300, false);
@@ -24783,15 +24499,18 @@ const SallaSwiper = class {
24783
24499
  autoHeight: this.autoHeight,
24784
24500
  lazy: true,
24785
24501
  on: {
24786
- // todo:: find better way for this workaround to show lazyLoad for duplicated slides, for some reason they are loaded but class not added.
24787
- afterInit: (slider) => this.loop && slider.slides.map(slide => {
24502
+ // todo:: find better way for this workaround to show lazyLoad for duplicated slides, because it clones the slide after it's already rendered,
24503
+ // then it re appended it as is,in this case the image is loaded but class not added.
24504
+ afterInit: (slider) => {
24788
24505
  var _a;
24789
24506
  (_a = document.lazyLoadInstance) === null || _a === void 0 ? void 0 : _a.update();
24790
- if (!slide.classList.contains('swiper-slide-duplicate')) {
24791
- return;
24792
- }
24793
- slide.querySelectorAll('img.lazy:not(.loaded)').forEach(img => img.classList.add('loaded'));
24794
- }),
24507
+ this.loop && slider.slides.map(slide => {
24508
+ if (!slide.classList.contains('swiper-slide-duplicate')) {
24509
+ return;
24510
+ }
24511
+ slide.querySelectorAll('img.lazy:not(.loaded)').forEach(img => img.classList.add('loaded'));
24512
+ });
24513
+ },
24795
24514
  },
24796
24515
  pagination: this.pagination ? {
24797
24516
  el: this.host.id ? `#${this.host.id} .swiper-pagination` : '',
@@ -27063,4 +26782,4 @@ const SallaVerify = class {
27063
26782
  };
27064
26783
  SallaVerify.style = sallaVerifyCss;
27065
26784
 
27066
- export { SallaButton as salla_button, SallaCartSummary as salla_cart_summary, SallaColorPicker as salla_color_picker, SallaCommentForm as salla_comment_form, SallaConditionalFields as salla_conditional_fields, SallaDatetimePicker as salla_datetime_picker, 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, SallaMap as salla_map, SallaModal as salla_modal, SallaOfferModal as salla_offer_modal, SallaPlaceholder as salla_placeholder, SallaProductAvailability as salla_product_availability, SallaProductOptions as salla_product_options, SallaProductSizeGuide as salla_product_size_guide, SallaQuantityInput as salla_quantity_input, SallaQuickOrder as salla_quick_order, SallaRatingModal as salla_rating_modal, SallaRatingStars as salla_rating_stars, SallaScopees as salla_scopes, SallaSearch as salla_search, SallaSkeleton as salla_skeleton, SallaSwiper 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, SallaUserSettings as salla_user_settings, SallaVerify as salla_verify };
26785
+ export { SallaButton as salla_button, SallaCartSummary as salla_cart_summary, SallaColorPicker as salla_color_picker, SallaCommentForm as salla_comment_form, SallaDatetimePicker as salla_datetime_picker, 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, SallaMap as salla_map, SallaModal as salla_modal, SallaOfferModal as salla_offer_modal, SallaPlaceholder as salla_placeholder, SallaProductAvailability as salla_product_availability, SallaProductSizeGuide as salla_product_size_guide, SallaProgressBar as salla_progress_bar, SallaQuantityInput as salla_quantity_input, SallaQuickOrder as salla_quick_order, SallaRatingModal as salla_rating_modal, SallaRatingStars as salla_rating_stars, SallaScopees as salla_scopes, SallaSearch as salla_search, SallaSkeleton as salla_skeleton, SallaSwiper 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, SallaUserSettings as salla_user_settings, SallaVerify as salla_verify };
@@ -0,0 +1,95 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ import { r as registerInstance, h, H as Host, g as getElement } from './index-f1d446ac.js';
5
+
6
+ const SallaConditionalFields = class {
7
+ constructor(hostRef) {
8
+ registerInstance(this, hostRef);
9
+ }
10
+ hideAllOptions(optionId) {
11
+ this.host.querySelectorAll(`[data-show-when^="options[${optionId}"]`).forEach((field) => {
12
+ field.classList.add('hidden');
13
+ this.hideAllOptions(field.dataset.optionId);
14
+ this.disableInputs(field);
15
+ });
16
+ }
17
+ disableInputs(field) {
18
+ field.querySelectorAll('[name]').forEach((input) => {
19
+ var _a;
20
+ input.setAttribute('disabled', '');
21
+ input.removeAttribute('required');
22
+ if (((_a = input === null || input === void 0 ? void 0 : input.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'select') {
23
+ input.value = '';
24
+ }
25
+ if (['checkbox'].includes(input.getAttribute('type')) && input.hasOwnProperty('checked')) {
26
+ // @ts-ignore
27
+ input.checked = false;
28
+ }
29
+ });
30
+ }
31
+ changeHandler(event) {
32
+ var _a;
33
+ salla.event.emit('salla-onditional-fields::change', event);
34
+ salla.log('Received the change event: ', event);
35
+ if (!event.target || !['SELECT'].includes(event.target.tagName) && !['checkbox'].includes(event.target.getAttribute('type'))) {
36
+ salla.log('Ignore the change because is not support input: ' + (((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.tagName) || 'N/A'));
37
+ return;
38
+ }
39
+ // to extract the option id from the input name, the supported names are name[*] and name[*][]
40
+ let optionId = event.target.name.replace('[]', '');
41
+ let isMultiple = event.target.getAttribute('type') === 'checkbox';
42
+ salla.log('Trying to find all the element with condition:', `[data-show-when^="${optionId}"]`);
43
+ this.host.querySelectorAll(`[data-show-when^="${optionId}"]`)
44
+ .forEach((field) => {
45
+ let isEqual = !(field === null || field === void 0 ? void 0 : field.dataset.showWhen.includes('!='));
46
+ let value = field === null || field === void 0 ? void 0 : field.dataset.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$3').trim();
47
+ // let isSelected = isMultiple ? event.target?.checked : value === event.target.value;
48
+ let isSelected;
49
+ if (isMultiple) {
50
+ // @ts-ignore
51
+ let selectedValues = Array.from(this.host.querySelectorAll(`input[name="${event.target.name}"]:checked`), e => e === null || e === void 0 ? void 0 : e.value);
52
+ isSelected = selectedValues.includes(value.toString());
53
+ }
54
+ else {
55
+ isSelected = value === event.target.value;
56
+ }
57
+ salla.log('The input is ', (isMultiple ? 'Multiple' : 'Single'), ' value:', isSelected);
58
+ let showTheInput = (isEqual && isSelected) || (!isEqual && !isSelected);
59
+ if (showTheInput) {
60
+ field.classList.remove('hidden');
61
+ field.querySelectorAll('[name]').forEach((input) => {
62
+ input.removeAttribute('disabled');
63
+ //To handle focus on hidden input error
64
+ if (!['checkbox'].includes(input.getAttribute('type')) && field.getElementsByClassName('required').length) {
65
+ input.setAttribute('required', '');
66
+ }
67
+ });
68
+ }
69
+ else {
70
+ this.hideAllOptions(field.dataset.optionId);
71
+ field.classList.add('hidden');
72
+ this.disableInputs(field);
73
+ }
74
+ });
75
+ }
76
+ componentDidRender() {
77
+ this.host.querySelectorAll(`[data-show-when]`).forEach((field) => {
78
+ var _a;
79
+ // @ts-ignore
80
+ let optionName = (_a = field === null || field === void 0 ? void 0 : field.dataset) === null || _a === void 0 ? void 0 : _a.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$1').trim();
81
+ if (!optionName) {
82
+ return;
83
+ }
84
+ this.changeHandler({
85
+ target: this.host.querySelector('[name^="' + optionName + '"]')
86
+ });
87
+ });
88
+ }
89
+ render() {
90
+ return (h(Host, null, h("slot", null)));
91
+ }
92
+ get host() { return getElement(this); }
93
+ };
94
+
95
+ export { SallaConditionalFields as salla_conditional_fields };