@salla.sa/twilight-components 2.14.38 → 2.14.40

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 (65) hide show
  1. package/dist/cjs/{app-globals-b6f5d986.js → app-globals-6da6c1dc.js} +3 -3
  2. package/dist/cjs/app-globals-6da6c1dc.js.map +1 -0
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/salla-add-product-button_48.cjs.entry.js.map +1 -1
  5. package/dist/cjs/salla-booking-field_2.cjs.entry.js +9 -13
  6. package/dist/cjs/salla-booking-field_2.cjs.entry.js.map +1 -1
  7. package/dist/cjs/salla-payments.cjs.entry.js +3 -3
  8. package/dist/cjs/salla-payments.cjs.entry.js.map +1 -1
  9. package/dist/cjs/twilight.cjs.js +1 -1
  10. package/dist/collection/components/salla-conditional-fields/salla-conditional-fields.js +9 -13
  11. package/dist/collection/components/salla-conditional-fields/salla-conditional-fields.js.map +1 -1
  12. package/dist/collection/components/salla-payments/salla-payments.js +3 -3
  13. package/dist/collection/components/salla-payments/salla-payments.js.map +1 -1
  14. package/dist/components/index.js +2 -2
  15. package/dist/components/index.js.map +1 -1
  16. package/dist/components/salla-conditional-fields2.js +9 -13
  17. package/dist/components/salla-conditional-fields2.js.map +1 -1
  18. package/dist/components/salla-payments.js +3 -3
  19. package/dist/components/salla-payments.js.map +1 -1
  20. package/dist/components/salla-quick-buy2.js.map +1 -1
  21. package/dist/esm/{app-globals-9c9225a7.js → app-globals-54b35df8.js} +3 -3
  22. package/dist/esm/app-globals-54b35df8.js.map +1 -0
  23. package/dist/esm/loader.js +1 -1
  24. package/dist/esm/salla-add-product-button_48.entry.js.map +1 -1
  25. package/dist/esm/salla-booking-field_2.entry.js +9 -13
  26. package/dist/esm/salla-booking-field_2.entry.js.map +1 -1
  27. package/dist/esm/salla-payments.entry.js +3 -3
  28. package/dist/esm/salla-payments.entry.js.map +1 -1
  29. package/dist/esm/twilight.js +1 -1
  30. package/dist/esm-es5/{app-globals-9c9225a7.js → app-globals-54b35df8.js} +3 -3
  31. package/dist/{twilight/p-71830393.system.js.map → esm-es5/app-globals-54b35df8.js.map} +1 -1
  32. package/dist/esm-es5/loader.js +1 -1
  33. package/dist/esm-es5/salla-add-product-button_48.entry.js.map +1 -1
  34. package/dist/esm-es5/salla-booking-field_2.entry.js +1 -1
  35. package/dist/esm-es5/salla-booking-field_2.entry.js.map +1 -1
  36. package/dist/esm-es5/salla-payments.entry.js +1 -1
  37. package/dist/esm-es5/salla-payments.entry.js.map +1 -1
  38. package/dist/esm-es5/twilight.js +1 -1
  39. package/dist/twilight/{p-ee43190e.system.entry.js → p-1738a61e.system.entry.js} +2 -2
  40. package/dist/twilight/p-1738a61e.system.entry.js.map +1 -0
  41. package/dist/twilight/p-4f5aa38b.entry.js +5 -0
  42. package/dist/twilight/p-4f5aa38b.entry.js.map +1 -0
  43. package/dist/twilight/{p-2f036c53.system.js → p-6ad782b3.system.js} +2 -2
  44. package/dist/twilight/{p-f0dd4217.entry.js → p-6b82ee90.entry.js} +2 -2
  45. package/dist/twilight/p-6b82ee90.entry.js.map +1 -0
  46. package/dist/twilight/p-a3e8ed53.entry.js.map +1 -1
  47. package/dist/twilight/{p-7d79e66d.system.entry.js → p-afdc10ed.system.entry.js} +2 -2
  48. package/dist/twilight/p-afdc10ed.system.entry.js.map +1 -0
  49. package/dist/twilight/{p-71830393.system.js → p-bdc20110.system.js} +2 -2
  50. package/dist/{esm-es5/app-globals-9c9225a7.js.map → twilight/p-bdc20110.system.js.map} +1 -1
  51. package/dist/twilight/{p-dfcd47a6.js → p-ce054ee5.js} +2 -2
  52. package/dist/twilight/{p-dfcd47a6.js.map → p-ce054ee5.js.map} +1 -1
  53. package/dist/twilight/p-ebd108c0.system.entry.js.map +1 -1
  54. package/dist/twilight/twilight.esm.js +1 -1
  55. package/dist/twilight/twilight.js +1 -1
  56. package/package.json +5 -5
  57. package/dist/cjs/app-globals-b6f5d986.js.map +0 -1
  58. package/dist/esm/app-globals-9c9225a7.js.map +0 -1
  59. package/dist/twilight/p-7d79e66d.system.entry.js.map +0 -1
  60. package/dist/twilight/p-a69f32dc.entry.js +0 -5
  61. package/dist/twilight/p-a69f32dc.entry.js.map +0 -1
  62. package/dist/twilight/p-ee43190e.system.entry.js.map +0 -1
  63. package/dist/twilight/p-f0dd4217.entry.js.map +0 -1
  64. package/dist/types/global.d.ts +0 -20
  65. /package/dist/twilight/{p-2f036c53.system.js.map → p-6ad782b3.system.js.map} +0 -0
@@ -33,40 +33,40 @@ const SallaConditionalFields = /*@__PURE__*/ proxyCustomElement(class SallaCondi
33
33
  var _a;
34
34
  salla.event.emit('salla-onditional-fields::change', event);
35
35
  salla.log('Received the change event: ', event);
36
- if (!event.target || !['SELECT'].includes(event.target.tagName) && !['checkbox'].includes(event.target.getAttribute('type'))) {
37
- 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'));
36
+ if (!event.target || !['SELECT'].includes(event.target.tagName) && !['checkbox', 'radio'].includes(event.target.getAttribute('type'))) {
37
+ salla.log('Ignore the change because is not a supported input: ' + (((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.tagName) || 'N/A'));
38
38
  return;
39
39
  }
40
- // to extract the option id from the input name, the supported names are name[*] and name[*][]
41
40
  let optionId = event.target.name.replace('[]', '');
42
41
  let isMultiple = event.target.getAttribute('type') === 'checkbox';
43
- salla.log('Trying to find all the element with condition:', `[data-show-when^="${optionId}"]`);
42
+ let isRadio = event.target.getAttribute('type') === 'radio';
43
+ salla.log('Trying to find all elements with condition:', `[data-show-when^="${optionId}"]`);
44
44
  this.host.querySelectorAll(`[data-show-when^="${optionId}"]`)
45
45
  .forEach((field) => {
46
46
  let isEqual = !(field === null || field === void 0 ? void 0 : field.dataset.showWhen.includes('!='));
47
47
  let value = field === null || field === void 0 ? void 0 : field.dataset.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$3').trim();
48
- // let isSelected = isMultiple ? event.target?.checked : value === event.target.value;
49
48
  let isSelected;
50
49
  if (isMultiple) {
51
- // @ts-ignore
52
50
  let selectedValues = Array.from(this.host.querySelectorAll(`input[name="${event.target.name}"]:checked`), e => e === null || e === void 0 ? void 0 : e.value);
53
51
  isSelected = selectedValues.includes(value.toString());
54
52
  }
53
+ else if (isRadio) {
54
+ // Handle radio inputs.
55
+ isSelected = event.target.checked && event.target.value === value;
56
+ }
55
57
  else {
56
58
  isSelected = value === event.target.value;
57
59
  }
58
- salla.log('The input is ', (isMultiple ? 'Multiple' : 'Single'), ' value:', isSelected);
60
+ salla.log('The input is ', isMultiple ? 'Multiple' : isRadio ? 'Radio' : 'Single', ' value:', isSelected);
59
61
  let showTheInput = (isEqual && isSelected) || (!isEqual && !isSelected);
60
62
  if (showTheInput) {
61
63
  field.classList.remove('hidden');
62
64
  field.querySelectorAll('[name]').forEach((input) => {
63
65
  input.removeAttribute('disabled');
64
- // Return required attribute to the input if the option is required
65
66
  const closestProductOption = input.closest('.s-product-options-option');
66
67
  if (closestProductOption.dataset.optionRequired === 'true') {
67
68
  input.setAttribute('required', '');
68
69
  }
69
- // Handle multiple checkboxes with same name and required attribute
70
70
  if (input.getAttribute('type') === 'checkbox') {
71
71
  const checkboxes = Array.from(document.querySelectorAll(`input[type="checkbox"][name="${input.getAttribute('name')}"]`));
72
72
  const isAnyChecked = checkboxes.some((checkbox) => checkbox.checked);
@@ -76,10 +76,6 @@ const SallaConditionalFields = /*@__PURE__*/ proxyCustomElement(class SallaCondi
76
76
  });
77
77
  }
78
78
  }
79
- //To handle focus on hidden input error
80
- if (!['checkbox'].includes(input.getAttribute('type')) && field.getElementsByClassName('required').length) {
81
- input.setAttribute('required', '');
82
- }
83
79
  });
84
80
  }
85
81
  else {
@@ -1 +1 @@
1
- {"file":"salla-conditional-fields2.js","mappings":";;;;;MASa,sBAAsB;;;;;EAIzB,cAAc,CAAC,QAAQ;IAC7B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C,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE;YACzG,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;WACpC;SACF,CAAC,CAAC;OACJ;WAAM;QACL,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC5C,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC9B,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;OAC3B;KACF,CAAC,CAAC;GACN;EAED,kBAAkB;IAChB,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK;;;MAE3D,IAAI,UAAU,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,0CAAE,QAAQ,CAAC,OAAO,CAAC,kBAAkB,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;MACnF,IAAI,CAAC,UAAU,EAAE;QACf,OAAO;OACR;MAED,IAAI,CAAC,aAAa,CAAC;QACjB,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,GAAG,UAAU,GAAG,IAAI,CAAC;OAChE,CAAC,CAAA;KACH,CAAC,CAAC;GACJ;EAED,MAAM;IACJ,QACE,EAAC,IAAI,QACH,eAAa,CACR,EACP;GACH;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/salla-conditional-fields/salla-conditional-fields.tsx"],"sourcesContent":["import { Component, Element, Host, Listen, h } from '@stencil/core';\n\n/**\n * its to easy to use, currenlty its support select & checkbox input as trigger for show/hide the dom\n * the dom you can put it like this data-show-when=\"{name of the field} {= or !=} {value of the field}\"\n */\n@Component({\n tag: 'salla-conditional-fields'\n})\nexport class SallaConditionalFields {\n\n @Element() host: HTMLElement;\n\n private hideAllOptions(optionId) {\n this.host.querySelectorAll(`[data-show-when^=\"options[${optionId}\"]`).forEach((field: HTMLElement) => {\n field.classList.add('hidden');\n this.hideAllOptions(field.dataset.optionId);\n this.disableInputs(field);\n });\n }\n\n private disableInputs(field) {\n field.querySelectorAll('[name]').forEach((input) => {\n\n input.setAttribute('disabled', '');\n input.removeAttribute('required');\n if (input?.tagName?.toLowerCase() === 'select') {\n input.value = ''\n }\n if (['checkbox'].includes(input.getAttribute('type')) && input.hasOwnProperty('checked')) {\n // @ts-ignore\n input.checked = false;\n }\n });\n }\n \n @Listen('change')\n changeHandler(event) {\n salla.event.emit('salla-onditional-fields::change', event);\n salla.log('Received the change event: ', event);\n\n if (!event.target || !['SELECT'].includes(event.target.tagName) && !['checkbox'].includes(event.target.getAttribute('type'))) {\n salla.log('Ignore the change because is not support input: ' + (event?.target?.tagName || 'N/A'));\n return;\n }\n\n // to extract the option id from the input name, the supported names are name[*] and name[*][]\n let optionId = event.target.name.replace('[]', '');\n let isMultiple = event.target.getAttribute('type') === 'checkbox';\n\n\n salla.log('Trying to find all the element with condition:', `[data-show-when^=\"${optionId}\"]`);\n\n this.host.querySelectorAll(`[data-show-when^=\"${optionId}\"]`)\n .forEach((field: HTMLElement) => {\n let isEqual = !field?.dataset.showWhen.includes('!=');\n let value = field?.dataset.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$3').trim();\n // let isSelected = isMultiple ? event.target?.checked : value === event.target.value;\n let isSelected;\n\n if (isMultiple) {\n // @ts-ignore\n let selectedValues = Array.from(this.host.querySelectorAll(`input[name=\"${event.target.name}\"]:checked`), e => e?.value);\n isSelected = selectedValues.includes(value.toString());\n } else {\n isSelected = value === event.target.value;\n }\n\n salla.log('The input is ', (isMultiple ? 'Multiple' : 'Single'), ' value:', isSelected);\n\n let showTheInput = (isEqual && isSelected) || (!isEqual && !isSelected);\n if (showTheInput) {\n field.classList.remove('hidden');\n field.querySelectorAll('[name]').forEach((input) => {\n input.removeAttribute('disabled');\n\n\n // Return required attribute to the input if the option is required\n const closestProductOption = (input as HTMLInputElement).closest('.s-product-options-option') as HTMLElement;\n if (closestProductOption.dataset.optionRequired === 'true') {\n input.setAttribute('required', '');\n }\n\n\n // Handle multiple checkboxes with same name and required attribute \n if (input.getAttribute('type') === 'checkbox') {\n const checkboxes = Array.from(document.querySelectorAll(`input[type=\"checkbox\"][name=\"${input.getAttribute('name')}\"]`)) as HTMLInputElement[];\n const isAnyChecked = checkboxes.some((checkbox) => checkbox.checked); \n if (isAnyChecked) {\n checkboxes.forEach((checkbox) => {\n checkbox.removeAttribute('required');\n });\n }\n }\n //To handle focus on hidden input error\n if (!['checkbox'].includes(input.getAttribute('type')) && field.getElementsByClassName('required').length) {\n input.setAttribute('required', '');\n }\n });\n } else {\n this.hideAllOptions(field.dataset.optionId);\n field.classList.add('hidden');\n this.disableInputs(field);\n }\n });\n }\n\n componentDidRender() {\n this.host.querySelectorAll(`[data-show-when]`).forEach((field) => {\n // @ts-ignore\n let optionName = field?.dataset?.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$1').trim();\n if (!optionName) {\n return;\n }\n\n this.changeHandler({\n target: this.host.querySelector('[name^=\"' + optionName + '\"]')\n })\n });\n }\n\n render() {\n return (\n <Host>\n <slot></slot>\n </Host>\n );\n }\n}\n"],"version":3}
1
+ {"file":"salla-conditional-fields2.js","mappings":";;;;;MASa,sBAAsB;;;;;EAIzB,cAAc,CAAC,QAAQ;IAC7B,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,6BAA6B,QAAQ,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,KAAkB;MAC/F,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;MAC9B,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;MAC5C,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;KAC3B,CAAC,CAAC;GACJ;EAEO,aAAa,CAAC,KAAK;IACzB,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAA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OAC3B;KACF,CAAC,CAAC;GACN;EAED,kBAAkB;IAChB,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK;;;MAE3D,IAAI,UAAU,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,0CAAE,QAAQ,CAAC,OAAO,CAAC,kBAAkB,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;MACnF,IAAI,CAAC,UAAU,EAAE;QACf,OAAO;OACR;MAED,IAAI,CAAC,aAAa,CAAC;QACjB,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,GAAG,UAAU,GAAG,IAAI,CAAC;OAChE,CAAC,CAAA;KACH,CAAC,CAAC;GACJ;EAED,MAAM;IACJ,QACE,EAAC,IAAI,QACH,eAAa,CACR,EACP;GACH;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/salla-conditional-fields/salla-conditional-fields.tsx"],"sourcesContent":["import { Component, Element, Host, Listen, h } from '@stencil/core';\n\n/**\n * its to easy to use, currenlty its support select & checkbox input as trigger for show/hide the dom\n * the dom you can put it like this data-show-when=\"{name of the field} {= or !=} {value of the field}\"\n */\n@Component({\n tag: 'salla-conditional-fields'\n})\nexport class SallaConditionalFields {\n\n @Element() host: HTMLElement;\n\n private hideAllOptions(optionId) {\n this.host.querySelectorAll(`[data-show-when^=\"options[${optionId}\"]`).forEach((field: HTMLElement) => {\n field.classList.add('hidden');\n this.hideAllOptions(field.dataset.optionId);\n this.disableInputs(field);\n });\n }\n\n private disableInputs(field) {\n field.querySelectorAll('[name]').forEach((input) => {\n\n input.setAttribute('disabled', '');\n input.removeAttribute('required');\n if (input?.tagName?.toLowerCase() === 'select') {\n input.value = ''\n }\n if (['checkbox'].includes(input.getAttribute('type')) && input.hasOwnProperty('checked')) {\n // @ts-ignore\n input.checked = false;\n }\n });\n }\n \n @Listen('change')\n changeHandler(event) {\n salla.event.emit('salla-onditional-fields::change', event);\n salla.log('Received the change event: ', event);\n\n if (!event.target || !['SELECT'].includes(event.target.tagName) && !['checkbox', 'radio'].includes(event.target.getAttribute('type'))) {\n salla.log('Ignore the change because is not a supported input: ' + (event?.target?.tagName || 'N/A'));\n return;\n }\n\n let optionId = event.target.name.replace('[]', '');\n let isMultiple = event.target.getAttribute('type') === 'checkbox';\n let isRadio = event.target.getAttribute('type') === 'radio';\n\n salla.log('Trying to find all elements with condition:', `[data-show-when^=\"${optionId}\"]`);\n\n this.host.querySelectorAll(`[data-show-when^=\"${optionId}\"]`)\n .forEach((field: HTMLElement) => {\n let isEqual = !field?.dataset.showWhen.includes('!=');\n let value = field?.dataset.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$3').trim();\n let isSelected;\n if (isMultiple) {\n let selectedValues = Array.from(this.host.querySelectorAll(`input[name=\"${event.target.name}\"]:checked`), e => (e as HTMLInputElement)?.value);\n isSelected = selectedValues.includes(value.toString());\n } else if (isRadio) {\n // Handle radio inputs.\n isSelected = event.target.checked && event.target.value === value;\n } else {\n isSelected = value === event.target.value;\n }\n\n salla.log('The input is ', isMultiple ? 'Multiple' : isRadio ? 'Radio' : 'Single', ' value:', isSelected);\n\n let showTheInput = (isEqual && isSelected) || (!isEqual && !isSelected);\n if (showTheInput) {\n field.classList.remove('hidden');\n field.querySelectorAll('[name]').forEach((input) => {\n input.removeAttribute('disabled');\n\n const closestProductOption = (input as HTMLInputElement).closest('.s-product-options-option') as HTMLElement;\n if (closestProductOption.dataset.optionRequired === 'true') {\n input.setAttribute('required', '');\n }\n\n if (input.getAttribute('type') === 'checkbox') {\n const checkboxes = Array.from(document.querySelectorAll(`input[type=\"checkbox\"][name=\"${input.getAttribute('name')}\"]`)) as HTMLInputElement[];\n const isAnyChecked = checkboxes.some((checkbox) => checkbox.checked);\n if (isAnyChecked) {\n checkboxes.forEach((checkbox) => {\n checkbox.removeAttribute('required');\n });\n }\n }\n });\n } else {\n this.hideAllOptions(field.dataset.optionId);\n field.classList.add('hidden');\n this.disableInputs(field);\n }\n });\n } \n\n componentDidRender() {\n this.host.querySelectorAll(`[data-show-when]`).forEach((field) => {\n // @ts-ignore\n let optionName = field?.dataset?.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$1').trim();\n if (!optionName) {\n return;\n }\n\n this.changeHandler({\n target: this.host.querySelector('[name^=\"' + optionName + '\"]')\n })\n });\n }\n\n render() {\n return (\n <Host>\n <slot></slot>\n </Host>\n );\n }\n}\n"],"version":3}
@@ -34,14 +34,14 @@ const SallaPayments$1 = /*@__PURE__*/ proxyCustomElement(class SallaPayments ext
34
34
  render() {
35
35
  const madeInKSA = !this.exclude.includes('made-in-ksa') && salla.config.get('store.settings.made_in_ksa');
36
36
  const sbcId = this.exclude.includes('sbc') ? null : salla.config.get('store.settings.certificate.id');
37
- return (h(Host, { class: "s-payments-list-wrap" }, madeInKSA && h("li", { class: "s-payments-list-item" }, h("img", { class: "lazy", width: "100%", height: "100%", decoding: "async", loading: "lazy", "data-src": salla.url.cdn(`images/made-in-ksa.svg`, 58, 58), alt: "made in KSA certified" })), h("ul", { class: "s-payments-list" }, this.payments.map((payment) => (payment == "cod" ?
37
+ return (h(Host, { class: "s-payments-list-wrap" }, h("ul", { class: "s-payments-list" }, madeInKSA && h("li", { class: "s-payments-list-item" }, h("img", { class: "lazy", width: "100%", height: "100%", decoding: "async", loading: "lazy", "data-src": salla.url.cdn(`images/made-in-ksa.svg`, 58, 58), alt: "made in KSA certified" })), this.payments.map((payment) => (payment == "cod" ?
38
38
  h("div", { id: "cod-slot", innerHTML: this.codSlot
39
39
  .replace(/\{image\}/g, salla.url.cdn(`images/payment/cod_mini.png`, 58, 58)) }) :
40
40
  h("div", { id: "payment-slot", innerHTML: this.paymentSlot
41
41
  .replace(/\{image\}/g, salla.url.cdn(`images/payment/${payment}_mini.png`, 58, 58))
42
- .replace(/\{payment\}/g, payment) })))), sbcId && h("div", { id: "sbc-slot", innerHTML: this.sbcSlot
42
+ .replace(/\{payment\}/g, payment) }))), sbcId && h("div", { id: "sbc-slot", innerHTML: this.sbcSlot
43
43
  .replace(/\{image\}/g, salla.url.cdn(`images/sbc.png`, 58, 58))
44
- .replace(/\{link\}/g, `https://eauthenticate.saudibusiness.gov.sa/certificate-details/${sbcId}`) })));
44
+ .replace(/\{link\}/g, `https://eauthenticate.saudibusiness.gov.sa/certificate-details/${sbcId}`) }))));
45
45
  }
46
46
  componentDidLoad() {
47
47
  var _a;
@@ -1 +1 @@
1
- {"file":"salla-payments.js","mappings":";;;;;AAAA,MAAM,gBAAgB,GAAG,sBAAsB;;MCWlCA,eAAa;;;;mBAUqB,EAAE;;EAE/C,iBAAiB;IACf,OAAO,KAAK,CAAC,OAAO,EAAE;OACnB,IAAI,CAAC;;MACJ,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAE;QACpC,IAAI;UACF,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACzC;QAAC,OAAO,KAAK,EAAE;UACd,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,qDAAqD,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;UACxF,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;SACnB;OACF;MACD,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;MAC5D,IAAI,CAAC,WAAW,GAAG,CAAA,MAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,0CAAE,SAAS,KAAI,sFAAsF,IAAI,CAAC,gBAAgB,2CAA2C,CAAC;MACpO,IAAI,CAAC,OAAO,GAAG,CAAA,MAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,0CAAE,SAAS,KAAI,2GAA2G,IAAI,CAAC,gBAAgB,0EAA0E,CAAC;MAChR,IAAI,CAAC,OAAO,GAAG,CAAA,MAAA,IAAI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,WAAW,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IACrF,MAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,0CAAE,MAAM,EAAE,CAAC;IACtD,MAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,0CAAE,MAAM,EAAE,CAAC;IAClD,MAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,0CAAE,MAAM,EAAE,CAAC;GACnD;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SallaPayments"],"sources":["src/components/salla-payments/salla-payments.scss?tag=salla-payments","src/components/salla-payments/salla-payments.tsx"],"sourcesContent":[":host {\n display: block;\n}\n","import { Component, Host, Prop, h, Element } from '@stencil/core';\n/**\n * @slot payment - Replaces payment item, has replaceable props `{image}`, `{payment}`.\n * @slot sbc - Replaces SBC certificate item, has replaceable props `{image}`.\n * @slot cod - Replaces COD item, has replaceable props `{image}`.\n */\n@Component({\n tag: 'salla-payments',\n styleUrl: 'salla-payments.scss'\n})\n\nexport class SallaPayments {\n @Element() host: HTMLElement;\n private paymentSlot: string;\n private sbcSlot: string;\n private codSlot: string;\n private payments: string[];\n private placeholderImage: string;\n /**\n * Array of the payments/items that are not supported, ex: [\"sbc\", \"made-in-ksa\", \"cod\", \"mada\", \"\"].\n */\n @Prop({ mutable: true }) exclude: string[] = [];\n\n componentWillLoad() {\n return salla.onReady()\n .then(() => {\n if (typeof this.exclude === 'string') {\n try {\n this.exclude = JSON.parse(this.exclude);\n } catch (error) {\n salla.logger.error('salla-payments:: failed to parse the exclude props!', this.exclude);\n this.exclude = [];\n }\n }\n this.placeholderImage = salla.url.cdn(`images/s-empty.png`);\n this.paymentSlot = this.host.querySelector('[slot=\"payment\"]')?.innerHTML || `<li class=\"s-payments-list-item\"><img class=\"lazy\" width=\"100%\" height=\"100%\" src=\"${this.placeholderImage}\" data-src=\"{image}\" alt={payment} /><li>`;\n this.sbcSlot = this.host.querySelector('[slot=\"sbc\"]')?.innerHTML || `<li class=\"s-payments-list-item\"><a target=\"_blank\" href=\"{link}\"> <img width=\"100%\" height=\"100%\" src=\"${this.placeholderImage}\" data-src={image} class=\"lazy s-payments-sbc-image\" alt=\"SBC\"/></a><li>`;\n this.codSlot = this.host.querySelector('[slot=\"cod\"]')?.innerHTML || `<li class=\"s-payments-list-item\"> <img width=\"100%\" height=\"100%\" src=\"${this.placeholderImage}\" data-src={image} class=\"lazy\" alt=\"COD\"/><li>`;\n this.payments = salla.config.get('store.settings.payments');\n })\n }\n \n render() {\n const madeInKSA = !this.exclude.includes('made-in-ksa') && salla.config.get('store.settings.made_in_ksa');\n const sbcId = this.exclude.includes('sbc') ? null : salla.config.get('store.settings.certificate.id');\n return (\n <Host class=\"s-payments-list-wrap\">\n { }\n {madeInKSA && <li class=\"s-payments-list-item\">\n <img class=\"lazy\" width=\"100%\" height=\"100%\" decoding=\"async\" loading=\"lazy\" data-src={salla.url.cdn(`images/made-in-ksa.svg`, 58, 58)} alt=\"made in KSA certified\" />\n </li>}\n\n {/* Dynamic methods */}\n <ul class=\"s-payments-list\">\n {this.payments.map((payment) => (\n payment == \"cod\" ?\n <div id=\"cod-slot\" innerHTML={this.codSlot\n .replace(/\\{image\\}/g, salla.url.cdn(`images/payment/cod_mini.png`, 58, 58))}>\n </div> :\n <div id=\"payment-slot\" innerHTML={this.paymentSlot\n .replace(/\\{image\\}/g, salla.url.cdn(`images/payment/${payment}_mini.png`, 58, 58))\n .replace(/\\{payment\\}/g, payment)}>\n </div>\n ))}\n </ul>\n\n\n {/* SBC certificate */}\n {sbcId && <div id=\"sbc-slot\" innerHTML={this.sbcSlot\n .replace(/\\{image\\}/g, salla.url.cdn(`images/sbc.png`, 58, 58))\n .replace(/\\{link\\}/g, `https://eauthenticate.saudibusiness.gov.sa/certificate-details/${sbcId}`)}>\n </div>}\n </Host>\n );\n }\n componentDidLoad() {\n //todo:: double check about the following workaround, it looks not normal\n document.lazyLoadInstance?.update(this.host.querySelectorAll('.lazy'));\n // fix lazy loaded images that have 100% width and height\n this.host.querySelectorAll('.lazy').forEach((img) => {\n img.addEventListener('load', () => {\n img.setAttribute('width', \"100%\");\n img.setAttribute('height', \"100%\");\n });\n });\n }\n componentDidRender() {\n //todo:: double check about the following workaround to reduce the dom length, it looks unusal\n this.host.querySelectorAll('#payment-slot').forEach(el => el.replaceWith(el.firstChild));\n this.host.querySelectorAll('#sbc-slot').forEach(el => el.replaceWith(el.firstChild));\n this.host.querySelectorAll('#cod-slot').forEach(el => el.replaceWith(el.firstChild));\n this.host.querySelector('[slot=\"payment\"]')?.remove();\n this.host.querySelector('[slot=\"sbc\"]')?.remove();\n this.host.querySelector('[slot=\"cod\"]')?.remove();\n }\n}\n"],"version":3}
1
+ {"file":"salla-payments.js","mappings":";;;;;AAAA,MAAM,gBAAgB,GAAG,sBAAsB;;MCWlCA,eAAa;;;;mBAUqB,EAAE;;EAE/C,iBAAiB;IACf,OAAO,KAAK,CAAC,OAAO,EAAE;OACnB,IAAI,CAAC;;MACJ,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAE;QACpC,IAAI;UACF,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACzC;QAAC,OAAO,KAAK,EAAE;UACd,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,qDAAqD,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;UACxF,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;SACnB;OACF;MACD,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;MAC5D,IAAI,CAAC,WAAW,GAAG,CAAA,MAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,0CAAE,SAAS,KAAI,sFAAsF,IAAI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AC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IACzF,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IACrF,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IACrF,MAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,0CAAE,MAAM,EAAE,CAAC;IACtD,MAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,0CAAE,MAAM,EAAE,CAAC;IAClD,MAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,0CAAE,MAAM,EAAE,CAAC;GACnD;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SallaPayments"],"sources":["src/components/salla-payments/salla-payments.scss?tag=salla-payments","src/components/salla-payments/salla-payments.tsx"],"sourcesContent":[":host {\n display: block;\n}\n","import { Component, Host, Prop, h, Element } from '@stencil/core';\n/**\n * @slot payment - Replaces payment item, has replaceable props `{image}`, `{payment}`.\n * @slot sbc - Replaces SBC certificate item, has replaceable props `{image}`.\n * @slot cod - Replaces COD item, has replaceable props `{image}`.\n */\n@Component({\n tag: 'salla-payments',\n styleUrl: 'salla-payments.scss'\n})\n\nexport class SallaPayments {\n @Element() host: HTMLElement;\n private paymentSlot: string;\n private sbcSlot: string;\n private codSlot: string;\n private payments: string[];\n private placeholderImage: string;\n /**\n * Array of the payments/items that are not supported, ex: [\"sbc\", \"made-in-ksa\", \"cod\", \"mada\", \"\"].\n */\n @Prop({ mutable: true }) exclude: string[] = [];\n\n componentWillLoad() {\n return salla.onReady()\n .then(() => {\n if (typeof this.exclude === 'string') {\n try {\n this.exclude = JSON.parse(this.exclude);\n } catch (error) {\n salla.logger.error('salla-payments:: failed to parse the exclude props!', this.exclude);\n this.exclude = [];\n }\n }\n this.placeholderImage = salla.url.cdn(`images/s-empty.png`);\n this.paymentSlot = this.host.querySelector('[slot=\"payment\"]')?.innerHTML || `<li class=\"s-payments-list-item\"><img class=\"lazy\" width=\"100%\" height=\"100%\" src=\"${this.placeholderImage}\" data-src=\"{image}\" alt={payment} /><li>`;\n this.sbcSlot = this.host.querySelector('[slot=\"sbc\"]')?.innerHTML || `<li class=\"s-payments-list-item\"><a target=\"_blank\" href=\"{link}\"> <img width=\"100%\" height=\"100%\" src=\"${this.placeholderImage}\" data-src={image} class=\"lazy s-payments-sbc-image\" alt=\"SBC\"/></a><li>`;\n this.codSlot = this.host.querySelector('[slot=\"cod\"]')?.innerHTML || `<li class=\"s-payments-list-item\"> <img width=\"100%\" height=\"100%\" src=\"${this.placeholderImage}\" data-src={image} class=\"lazy\" alt=\"COD\"/><li>`;\n this.payments = salla.config.get('store.settings.payments');\n })\n }\n \n render() {\n const madeInKSA = !this.exclude.includes('made-in-ksa') && salla.config.get('store.settings.made_in_ksa');\n const sbcId = this.exclude.includes('sbc') ? null : salla.config.get('store.settings.certificate.id');\n return (\n <Host class=\"s-payments-list-wrap\">\n { }\n <ul class=\"s-payments-list\">\n {madeInKSA && <li class=\"s-payments-list-item\">\n <img class=\"lazy\" width=\"100%\" height=\"100%\" decoding=\"async\" loading=\"lazy\" data-src={salla.url.cdn(`images/made-in-ksa.svg`, 58, 58)} alt=\"made in KSA certified\" />\n </li>}\n\n {/* Dynamic methods */}\n {this.payments.map((payment) => (\n payment == \"cod\" ?\n <div id=\"cod-slot\" innerHTML={this.codSlot\n .replace(/\\{image\\}/g, salla.url.cdn(`images/payment/cod_mini.png`, 58, 58))}>\n </div> :\n <div id=\"payment-slot\" innerHTML={this.paymentSlot\n .replace(/\\{image\\}/g, salla.url.cdn(`images/payment/${payment}_mini.png`, 58, 58))\n .replace(/\\{payment\\}/g, payment)}>\n </div>\n ))}\n\n {/* SBC certificate */}\n {sbcId && <div id=\"sbc-slot\" innerHTML={this.sbcSlot\n .replace(/\\{image\\}/g, salla.url.cdn(`images/sbc.png`, 58, 58))\n .replace(/\\{link\\}/g, `https://eauthenticate.saudibusiness.gov.sa/certificate-details/${sbcId}`)}>\n </div>}\n </ul>\n </Host>\n );\n }\n componentDidLoad() {\n //todo:: double check about the following workaround, it looks not normal\n document.lazyLoadInstance?.update(this.host.querySelectorAll('.lazy'));\n // fix lazy loaded images that have 100% width and height\n this.host.querySelectorAll('.lazy').forEach((img) => {\n img.addEventListener('load', () => {\n img.setAttribute('width', \"100%\");\n img.setAttribute('height', \"100%\");\n });\n });\n }\n componentDidRender() {\n //todo:: double check about the following workaround to reduce the dom length, it looks unusal\n this.host.querySelectorAll('#payment-slot').forEach(el => el.replaceWith(el.firstChild));\n this.host.querySelectorAll('#sbc-slot').forEach(el => el.replaceWith(el.firstChild));\n this.host.querySelectorAll('#cod-slot').forEach(el => el.replaceWith(el.firstChild));\n this.host.querySelector('[slot=\"payment\"]')?.remove();\n this.host.querySelector('[slot=\"sbc\"]')?.remove();\n this.host.querySelector('[slot=\"cod\"]')?.remove();\n }\n}\n"],"version":3}