@salla.sa/twilight-components 2.11.110 → 2.11.112

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 (150) hide show
  1. package/README.md +48 -42
  2. package/dist/cjs/{app-globals-c392da62.js → app-globals-38ac4fe8.js} +2 -2
  3. package/dist/cjs/{app-globals-c392da62.js.map → app-globals-38ac4fe8.js.map} +1 -1
  4. package/dist/cjs/loader.cjs.js +2 -2
  5. package/dist/cjs/salla-add-product-button_40.cjs.entry.js +74 -24
  6. package/dist/cjs/salla-add-product-button_40.cjs.entry.js.map +1 -1
  7. package/dist/cjs/salla-filters-widget.cjs.entry.js +5 -27
  8. package/dist/cjs/salla-filters-widget.cjs.entry.js.map +1 -1
  9. package/dist/cjs/salla-filters.cjs.entry.js +8 -4
  10. package/dist/cjs/salla-filters.cjs.entry.js.map +1 -1
  11. package/dist/cjs/salla-price-range.cjs.entry.js +109 -37
  12. package/dist/cjs/salla-price-range.cjs.entry.js.map +1 -1
  13. package/dist/cjs/salla-products-list.cjs.entry.js +85 -59
  14. package/dist/cjs/salla-products-list.cjs.entry.js.map +1 -1
  15. package/dist/cjs/salla-products-slider.cjs.entry.js +12 -4
  16. package/dist/cjs/salla-products-slider.cjs.entry.js.map +1 -1
  17. package/dist/cjs/twilight.cjs.js +2 -2
  18. package/dist/collection/components/salla-filters/salla-filters.js +8 -4
  19. package/dist/collection/components/salla-filters/salla-filters.js.map +1 -1
  20. package/dist/collection/components/salla-filters-widget/salla-filters-widget.js +5 -27
  21. package/dist/collection/components/salla-filters-widget/salla-filters-widget.js.map +1 -1
  22. package/dist/collection/components/salla-login-modal/intefaces.js.map +1 -1
  23. package/dist/collection/components/salla-login-modal/salla-login-modal.js +1 -1
  24. package/dist/collection/components/salla-login-modal/salla-login-modal.js.map +1 -1
  25. package/dist/collection/components/salla-maintenance-alert/salla-maintenance-alert.js +14 -1
  26. package/dist/collection/components/salla-maintenance-alert/salla-maintenance-alert.js.map +1 -1
  27. package/dist/collection/components/salla-price-range/salla-price-range.js +152 -148
  28. package/dist/collection/components/salla-price-range/salla-price-range.js.map +1 -1
  29. package/dist/collection/components/salla-products-list/salla-products-list.js +85 -59
  30. package/dist/collection/components/salla-products-list/salla-products-list.js.map +1 -1
  31. package/dist/collection/components/salla-products-slider/salla-products-slider.js +29 -5
  32. package/dist/collection/components/salla-products-slider/salla-products-slider.js.map +1 -1
  33. package/dist/collection/components/salla-verify/salla-verify.css +12 -0
  34. package/dist/collection/components/salla-verify/salla-verify.js +59 -21
  35. package/dist/collection/components/salla-verify/salla-verify.js.map +1 -1
  36. package/dist/components/index.js +1 -1
  37. package/dist/components/index.js.map +1 -1
  38. package/dist/components/salla-filters-widget2.js +5 -27
  39. package/dist/components/salla-filters-widget2.js.map +1 -1
  40. package/dist/components/salla-filters.js +8 -4
  41. package/dist/components/salla-filters.js.map +1 -1
  42. package/dist/components/salla-login-modal.js +1 -1
  43. package/dist/components/salla-login-modal.js.map +1 -1
  44. package/dist/components/salla-maintenance-alert.js +14 -1
  45. package/dist/components/salla-maintenance-alert.js.map +1 -1
  46. package/dist/components/salla-price-range2.js +113 -43
  47. package/dist/components/salla-price-range2.js.map +1 -1
  48. package/dist/components/salla-products-list.js +85 -59
  49. package/dist/components/salla-products-list.js.map +1 -1
  50. package/dist/components/salla-products-slider.js +13 -5
  51. package/dist/components/salla-products-slider.js.map +1 -1
  52. package/dist/components/salla-verify2.js +60 -22
  53. package/dist/components/salla-verify2.js.map +1 -1
  54. package/dist/esm/{app-globals-663240cc.js → app-globals-3a81b4f2.js} +2 -2
  55. package/dist/esm/{app-globals-663240cc.js.map → app-globals-3a81b4f2.js.map} +1 -1
  56. package/dist/esm/loader.js +2 -2
  57. package/dist/esm/salla-add-product-button_40.entry.js +74 -24
  58. package/dist/esm/salla-add-product-button_40.entry.js.map +1 -1
  59. package/dist/esm/salla-filters-widget.entry.js +5 -27
  60. package/dist/esm/salla-filters-widget.entry.js.map +1 -1
  61. package/dist/esm/salla-filters.entry.js +8 -4
  62. package/dist/esm/salla-filters.entry.js.map +1 -1
  63. package/dist/esm/salla-price-range.entry.js +109 -37
  64. package/dist/esm/salla-price-range.entry.js.map +1 -1
  65. package/dist/esm/salla-products-list.entry.js +85 -59
  66. package/dist/esm/salla-products-list.entry.js.map +1 -1
  67. package/dist/esm/salla-products-slider.entry.js +12 -4
  68. package/dist/esm/salla-products-slider.entry.js.map +1 -1
  69. package/dist/esm/twilight.js +2 -2
  70. package/dist/esm-es5/{app-globals-663240cc.js → app-globals-3a81b4f2.js} +2 -2
  71. package/dist/{twilight/p-dcfa0f39.system.js.map → esm-es5/app-globals-3a81b4f2.js.map} +1 -1
  72. package/dist/esm-es5/loader.js +1 -1
  73. package/dist/esm-es5/loader.js.map +1 -1
  74. package/dist/esm-es5/salla-add-product-button_40.entry.js +4 -4
  75. package/dist/esm-es5/salla-add-product-button_40.entry.js.map +1 -1
  76. package/dist/esm-es5/salla-filters-widget.entry.js +1 -1
  77. package/dist/esm-es5/salla-filters-widget.entry.js.map +1 -1
  78. package/dist/esm-es5/salla-filters.entry.js +1 -1
  79. package/dist/esm-es5/salla-filters.entry.js.map +1 -1
  80. package/dist/esm-es5/salla-price-range.entry.js +2 -2
  81. package/dist/esm-es5/salla-price-range.entry.js.map +1 -1
  82. package/dist/esm-es5/salla-products-list.entry.js +2 -2
  83. package/dist/esm-es5/salla-products-list.entry.js.map +1 -1
  84. package/dist/esm-es5/salla-products-slider.entry.js +1 -1
  85. package/dist/esm-es5/salla-products-slider.entry.js.map +1 -1
  86. package/dist/esm-es5/twilight.js +1 -1
  87. package/dist/esm-es5/twilight.js.map +1 -1
  88. package/dist/twilight/{p-6948b825.js → p-1edec127.js} +2 -2
  89. package/dist/twilight/{p-6948b825.js.map → p-1edec127.js.map} +1 -1
  90. package/dist/twilight/{p-7c6638f5.system.entry.js → p-2739ddc5.system.entry.js} +2 -2
  91. package/dist/twilight/p-2739ddc5.system.entry.js.map +1 -0
  92. package/dist/twilight/p-3212e42c.entry.js +5 -0
  93. package/dist/twilight/p-3212e42c.entry.js.map +1 -0
  94. package/dist/twilight/{p-6404a9a5.system.js → p-37389934.system.js} +2 -2
  95. package/dist/twilight/{p-6404a9a5.system.js.map → p-37389934.system.js.map} +1 -1
  96. package/dist/twilight/{p-dcfa0f39.system.js → p-38496eab.system.js} +2 -2
  97. package/dist/{esm-es5/app-globals-663240cc.js.map → twilight/p-38496eab.system.js.map} +1 -1
  98. package/dist/twilight/p-3f03d17c.system.entry.js +5 -0
  99. package/dist/twilight/p-3f03d17c.system.entry.js.map +1 -0
  100. package/dist/twilight/p-46b7f931.system.entry.js +5 -0
  101. package/dist/twilight/p-46b7f931.system.entry.js.map +1 -0
  102. package/dist/twilight/p-54783694.system.entry.js +5 -0
  103. package/dist/twilight/p-54783694.system.entry.js.map +1 -0
  104. package/dist/twilight/{p-1e4abb42.system.entry.js → p-9a1231a6.system.entry.js} +2 -2
  105. package/dist/twilight/p-9a1231a6.system.entry.js.map +1 -0
  106. package/dist/twilight/{p-9713044b.entry.js → p-b766115a.entry.js} +2 -2
  107. package/dist/twilight/p-b766115a.entry.js.map +1 -0
  108. package/dist/twilight/p-cd5cb2f7.entry.js +5 -0
  109. package/dist/twilight/p-cd5cb2f7.entry.js.map +1 -0
  110. package/dist/twilight/p-d7a62fb3.system.entry.js +5 -0
  111. package/dist/twilight/p-d7a62fb3.system.entry.js.map +1 -0
  112. package/dist/twilight/p-def222e1.entry.js +5 -0
  113. package/dist/twilight/p-def222e1.entry.js.map +1 -0
  114. package/dist/twilight/p-e393f123.entry.js +5 -0
  115. package/dist/twilight/p-e393f123.entry.js.map +1 -0
  116. package/dist/twilight/p-e3dc0687.entry.js +5 -0
  117. package/dist/twilight/p-e3dc0687.entry.js.map +1 -0
  118. package/dist/twilight/twilight.esm.js +1 -1
  119. package/dist/twilight/twilight.esm.js.map +1 -1
  120. package/dist/twilight/twilight.js +1 -1
  121. package/dist/types/components/salla-filters-widget/salla-filters-widget.d.ts +0 -7
  122. package/dist/types/components/salla-login-modal/intefaces.d.ts +1 -0
  123. package/dist/types/components/salla-maintenance-alert/salla-maintenance-alert.d.ts +3 -0
  124. package/dist/types/components/salla-price-range/salla-price-range.d.ts +16 -10
  125. package/dist/types/components/salla-products-list/salla-products-list.d.ts +2 -2
  126. package/dist/types/components/salla-products-slider/salla-products-slider.d.ts +5 -1
  127. package/dist/types/components/salla-verify/salla-verify.d.ts +6 -1
  128. package/dist/types/components.d.ts +14 -8
  129. package/package.json +4 -4
  130. package/dist/twilight/p-1e4abb42.system.entry.js.map +0 -1
  131. package/dist/twilight/p-3b1a0059.entry.js +0 -5
  132. package/dist/twilight/p-3b1a0059.entry.js.map +0 -1
  133. package/dist/twilight/p-41b3e09d.entry.js +0 -5
  134. package/dist/twilight/p-41b3e09d.entry.js.map +0 -1
  135. package/dist/twilight/p-4a743b5e.system.entry.js +0 -5
  136. package/dist/twilight/p-4a743b5e.system.entry.js.map +0 -1
  137. package/dist/twilight/p-62c1b309.entry.js +0 -5
  138. package/dist/twilight/p-62c1b309.entry.js.map +0 -1
  139. package/dist/twilight/p-6349125a.entry.js +0 -5
  140. package/dist/twilight/p-6349125a.entry.js.map +0 -1
  141. package/dist/twilight/p-7c6638f5.system.entry.js.map +0 -1
  142. package/dist/twilight/p-8ee37cc6.entry.js +0 -5
  143. package/dist/twilight/p-8ee37cc6.entry.js.map +0 -1
  144. package/dist/twilight/p-9713044b.entry.js.map +0 -1
  145. package/dist/twilight/p-9e27da8e.system.entry.js +0 -5
  146. package/dist/twilight/p-9e27da8e.system.entry.js.map +0 -1
  147. package/dist/twilight/p-b1f8b436.system.entry.js +0 -5
  148. package/dist/twilight/p-b1f8b436.system.entry.js.map +0 -1
  149. package/dist/twilight/p-c9cdaea6.system.entry.js +0 -5
  150. package/dist/twilight/p-c9cdaea6.system.entry.js.map +0 -1
@@ -26,11 +26,11 @@ const SallaProductsSlider$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
26
26
  this.displayAllUrl = undefined;
27
27
  this.source = undefined;
28
28
  this.sourceValue = undefined;
29
+ this.limit = undefined;
29
30
  this.productsData = undefined;
30
31
  this.isReady = undefined;
31
32
  this.sourceValueIsValid = undefined;
32
33
  this.hasCustomComponent = undefined;
33
- this.urlPrefix = '';
34
34
  this.apiUrl = '';
35
35
  this.parsedSourceValue = undefined;
36
36
  salla.onReady(() => {
@@ -48,18 +48,26 @@ const SallaProductsSlider$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
48
48
  }
49
49
  return h("div", { class: "s-products-slider-card" }, h("salla-product-card", { "show-quantity": this.getSource() == 'landing-page', "hide-add-btn": this.getSource() == 'landing-page', "shadow-on-hover": true, product: product }));
50
50
  }
51
+ getUrlPrefix() {
52
+ let urlPrefix = '';
53
+ if (this.limit) {
54
+ urlPrefix = `&per_page=${this.limit > 32 ? 32 : this.limit}`;
55
+ }
56
+ return urlPrefix;
57
+ }
51
58
  getApiUrl() {
52
59
  if (this.getSource() === 'json') {
53
60
  return;
54
61
  }
62
+ let prefixes = this.getUrlPrefix();
55
63
  if (['offers', 'latest'].includes(this.getSource())) {
56
- return salla.url.api(`products?source=${this.getSource()}${this.urlPrefix}`);
64
+ return salla.url.api(`products?source=${this.getSource()}${prefixes}`);
57
65
  }
58
66
  if (['related', 'landing-page'].includes(this.getSource())) {
59
- return salla.url.api(`products?source=${this.getSource()}&source_value=${this.getSourceValue()}${this.urlPrefix}`);
67
+ return salla.url.api(`products?source=${this.getSource()}&source_value=${this.getSourceValue()}${prefixes}`);
60
68
  }
61
69
  try {
62
- return salla.url.api(`products?source=${this.getSource()}&source_value[]=${this.getSourceValue().join('&source_value[]=')}${this.urlPrefix}`);
70
+ return salla.url.api(`products?source=${this.getSource()}&source_value[]=${this.getSourceValue().join('&source_value[]=')}${prefixes}`);
63
71
  }
64
72
  catch (e) {
65
73
  salla.logger.warn(`source-value prop should be array of ids ex source-value="[1,2,3]" for the source [${this.getSource()}]`);
@@ -118,11 +126,11 @@ const SallaProductsSlider$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
118
126
  "displayAllUrl": [1, "display-all-url"],
119
127
  "source": [1537],
120
128
  "sourceValue": [1, "source-value"],
129
+ "limit": [1026],
121
130
  "productsData": [32],
122
131
  "isReady": [32],
123
132
  "sourceValueIsValid": [32],
124
133
  "hasCustomComponent": [32],
125
- "urlPrefix": [32],
126
134
  "apiUrl": [32],
127
135
  "parsedSourceValue": [32]
128
136
  }]);
@@ -1 +1 @@
1
- {"file":"salla-products-slider.js","mappings":";;;;;;;;;;;;;;;;AAAA,MAAM,sBAAsB,GAAG,EAAE;;MCMpBA,qBAAmB;EAC9B;;;;;;;;;;;;;qBAiE6B,EAAE;kBACL,EAAE;;IAjE1B,KAAK,CAAC,OAAO,CAAC;MACZ,IAAI,CAAC,kBAAkB,GAAG,CAAC,EAAE,IAAI,CAAC,WAAW,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;KACnG,CAAC,CAAC;IACH,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE;MAC5B,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,6CAA6C,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;MACpF,OAAO;KACR;IACD,IAAI,CAAC,kBAAkB,GAAG,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;GAC7E;EA4DO,WAAW,CAAC,OAAO;IACzB,IAAI,IAAI,CAAC,kBAAkB,EAAE;MAC3B,OAAO,WAAK,KAAK,EAAC,wBAAwB,IACxC,iCAA2B,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,kBAAgB,IAAI,CAAC,cAAc,EAAE,GAAG,CACzG,CAAC;KACR;IAED,OAAO,WAAK,KAAK,EAAC,wBAAwB,IACxC,2CACiB,IAAI,CAAC,SAAS,EAAE,IAAI,cAAc,kB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AC,OAAO,GAAG,IAAI,CAAA;KACpB,CAAC,CAAA;GACH;EAED,MAAM;;IACJ,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,SAAS,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,iDAAiD,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE;MAChI,OAAO;KACR;IACD,QACE,EAAC,IAAI,IAAC,KAAK,EAAC,2BAA2B,IACrC,oBACE,KAAK,EAAC,0BAA0B,EAChC,EAAE,EAAE,IAAI,CAAC,QAAQ,IAAI,qBAAqB,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EACnF,IAAI,EAAC,UAAU,iBACF,IAAI,CAAC,UAAU,oBACZ,IAAI,CAAC,QAAQ,qBACZ,IAAI,CAAC,aAAa,IAEnC,WAAK,IAAI,EAAC,OAAO,IACd,MAAA,IAAI,CAAC,YAAY,0CAAE,GAAG,CAAC,CAAC,OAAO,KAC9B,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAC1B,CACG,CACO,CACV,EACP;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SallaProductsSlider"],"sources":["./src/components/salla-products-slider/salla-products-slider.scss?tag=salla-products-slider","./src/components/salla-products-slider/salla-products-slider.tsx"],"sourcesContent":[".s-products-slider{\n &-wrapper{\n\n }\n &-slider{\n\n }\n &-card{\n\n }\n}","import {Component, Host, h, Prop, Element, State} from '@stencil/core';\n\n@Component({\n tag: 'salla-products-slider',\n styleUrl: 'salla-products-slider.scss'\n})\nexport class SallaProductsSlider {\n constructor() {\n salla.onReady(() => {\n this.sourceValueIsValid = !!(this.sourceValue || ['latest', 'offers'].includes(this.getSource()));\n });\n if (!this.sourceValueIsValid) {\n salla.logger.warn(`source-value prop is required for source [${this.getSource()}]`);\n return;\n }\n this.hasCustomComponent = !!customElements.get('custom-salla-product-card');\n }\n\n @Element() host: HTMLElement;\n //todo:: support limit, default =10, make sure that maximum is 32,\n\n /**\n * Title of the block - works only if slider is true\n * @type {string}\n * @default ''\n * */\n @Prop() blockTitle: string;\n\n /**\n * Sub title of the block - works only if slider is true\n * @type {string}\n * @default ''\n * */\n @Prop() subTitle: string;\n\n /**\n * Slider Id, if not provided will be generated automatically\n * @type {string}\n * @default ''\n * */\n @Prop() sliderId: string;\n\n /**\n * Display 'ALL' URL\n * @type {string}\n * @default ''\n * */\n @Prop() displayAllUrl: string;\n\n /**\n * Source of the products, if api will get the products from the API, if json will get the products from the products prop\n * @type {string}\n * @default ''\n * */\n @Prop({\n reflect: true,\n mutable: true\n }) source: 'categories' | 'latest' | 'related' | 'brands' | 'json' | 'tags' | 'selected' | 'offers' | 'landing-page';\n\n /**\n * The source value, cloud be different values as following:\n * - array of ids when `source` in ['categories', 'brands', 'tags', 'selected']\n * - products payload when `source` = 'json'\n * - product_id when `source` = 'related'\n *\n * @type {string}\n * */\n @Prop() sourceValue: string;\n @State() productsData: any;\n @State() isReady: boolean;\n @State() sourceValueIsValid: boolean;\n @State() hasCustomComponent: boolean;\n @State() urlPrefix: string = '';\n @State() apiUrl: string = '';\n @State() parsedSourceValue: any;\n\n private getItemHTML(product) {\n if (this.hasCustomComponent) {\n return <div class=\"s-products-slider-card\">\n <custom-salla-product-card product={product} source={this.getSource()} source-value={this.getSourceValue()}/>\n </div>;\n }\n\n return <div class=\"s-products-slider-card\">\n <salla-product-card\n show-quantity={this.getSource() == 'landing-page'}\n hide-add-btn={this.getSource() == 'landing-page'}\n shadow-on-hover={true}\n product={product}/>\n </div>;\n }\n\n getApiUrl() {\n if (this.getSource() === 'json') {\n return;\n }\n if (['offers', 'latest'].includes(this.getSource())) {\n return salla.url.api(`products?source=${this.getSource()}${this.urlPrefix}`);\n }\n if (['related', 'landing-page'].includes(this.getSource())) {\n return salla.url.api(`products?source=${this.getSource()}&source_value=${this.getSourceValue()}${this.urlPrefix}`);\n }\n\n try {\n return salla.url.api(`products?source=${this.getSource()}&source_value[]=${this.getSourceValue().join('&source_value[]=')}${this.urlPrefix}`);\n } catch (e) {\n salla.logger.warn(`source-value prop should be array of ids ex source-value=\"[1,2,3]\" for the source [${this.getSource()}]`);\n this.sourceValueIsValid = false;\n }\n }\n private getSource(){\n return {\n 'brands.single': 'brands',\n 'product.index': 'categories',\n 'product.index.latest': 'latest',\n 'product.index.offers': 'offers',\n 'product.index.search': 'search',\n 'landing-page': 'landing-page',\n 'product.index.tag': 'tags',\n }[this.source || salla.config.get('page.slug')] || this.source ||'latest';\n }\n\n private getSourceValue() {\n if (!['search', 'json'].includes(this.getSource())) {\n if (Array.isArray(JSON.parse(this.sourceValue)) && JSON.parse(this.sourceValue).length) {\n return JSON.parse(this.sourceValue);\n }\n\n if (typeof JSON.parse(this.sourceValue) == 'number') {\n return [JSON.parse(this.sourceValue)];\n }\n }\n return this.sourceValue || salla.config.get('page.id');\n }\n private canRender() {\n return this.sourceValueIsValid && this.isReady;\n }\n\n componentWillLoad() {\n if (this.source === 'json') {\n this.productsData = this.getSourceValue();\n this.isReady = true\n return;\n }\n salla.api.request(this.getApiUrl(), null, 'get').then(res => {\n this.productsData = res.data\n this.isReady = true\n })\n }\n\n render() {\n if ((this.getSource() == 'related' && !salla.config.get('store.settings.product.related_products_enabled')) || !this.canRender()) {\n return;\n }\n return (\n <Host class=\"s-products-slider-wrapper\">\n <salla-slider\n class=\"s-products-slider-slider\"\n id={this.sliderId || `s-products-slider-${Math.random().toString(36).substr(2, 9)}`}\n type=\"carousel\"\n block-title={this.blockTitle}\n block-subTitle={this.subTitle}\n display-all-url={this.displayAllUrl}\n >\n <div slot=\"items\">\n {this.productsData?.map((product) =>\n this.getItemHTML(product)\n )}\n </div>\n </salla-slider>\n </Host>\n );\n }\n\n}\n"],"version":3}
1
+ {"file":"salla-products-slider.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AAC,SAAS,EAAE,IAAI,SAAS,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,iDAAiD,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE;MAChI,OAAO;KACR;IACD,QACE,EAAC,IAAI,IAAC,KAAK,EAAC,2BAA2B,IACrC,oBACE,KAAK,EAAC,0BAA0B,EAChC,EAAE,EAAE,IAAI,CAAC,QAAQ,IAAI,qBAAqB,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EACnF,IAAI,EAAC,UAAU,iBACF,IAAI,CAAC,UAAU,oBACZ,IAAI,CAAC,QAAQ,qBACZ,IAAI,CAAC,aAAa,IAEnC,WAAK,IAAI,EAAC,OAAO,IACd,MAAA,IAAI,CAAC,YAAY,0CAAE,GAAG,CAAC,CAAC,OAAO,KAC9B,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAC1B,CACG,CACO,CACV,EACP;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SallaProductsSlider"],"sources":["./src/components/salla-products-slider/salla-products-slider.scss?tag=salla-products-slider","./src/components/salla-products-slider/salla-products-slider.tsx"],"sourcesContent":[".s-products-slider{\n &-wrapper{\n\n }\n &-slider{\n\n }\n &-card{\n\n }\n}","import {Component, Host, h, Prop, Element, State} from '@stencil/core';\n\n@Component({\n tag: 'salla-products-slider',\n styleUrl: 'salla-products-slider.scss'\n})\nexport class SallaProductsSlider {\n constructor() {\n salla.onReady(() => {\n this.sourceValueIsValid = !!(this.sourceValue || ['latest', 'offers'].includes(this.getSource()));\n });\n if (!this.sourceValueIsValid) {\n salla.logger.warn(`source-value prop is required for source [${this.getSource()}]`);\n return;\n }\n this.hasCustomComponent = !!customElements.get('custom-salla-product-card');\n }\n\n @Element() host: HTMLElement;\n //todo:: support limit, default =10, make sure that maximum is 32,\n\n /**\n * Title of the block - works only if slider is true\n * @type {string}\n * @default ''\n * */\n @Prop() blockTitle: string;\n\n /**\n * Sub title of the block - works only if slider is true\n * @type {string}\n * @default ''\n * */\n @Prop() subTitle: string;\n\n /**\n * Slider Id, if not provided will be generated automatically\n * @type {string}\n * @default ''\n * */\n @Prop() sliderId: string;\n\n /**\n * Display 'ALL' URL\n * @type {string}\n * @default ''\n * */\n @Prop() displayAllUrl: string;\n\n /**\n * Source of the products, if api will get the products from the API, if json will get the products from the products prop\n * @type {string}\n * @default ''\n * */\n @Prop({\n reflect: true,\n mutable: true\n }) source: 'categories' | 'latest' | 'related' | 'brands' | 'json' | 'tags' | 'selected' | 'offers' | 'landing-page';\n\n /**\n * The source value, cloud be different values as following:\n * - array of ids when `source` in ['categories', 'brands', 'tags', 'selected']\n * - products payload when `source` = 'json'\n * - product_id when `source` = 'related'\n *\n * @type {string}\n * */\n @Prop() sourceValue: string;\n\n /**\n * Limit for number of products in the list.\n */\n @Prop({mutable: true}) limit: number;\n\n \n @State() productsData: any;\n @State() isReady: boolean;\n @State() sourceValueIsValid: boolean;\n @State() hasCustomComponent: boolean;\n @State() apiUrl: string = '';\n @State() parsedSourceValue: any;\n\n private getItemHTML(product) {\n if (this.hasCustomComponent) {\n return <div class=\"s-products-slider-card\">\n <custom-salla-product-card product={product} source={this.getSource()} source-value={this.getSourceValue()}/>\n </div>;\n }\n\n return <div class=\"s-products-slider-card\">\n <salla-product-card\n show-quantity={this.getSource() == 'landing-page'}\n hide-add-btn={this.getSource() == 'landing-page'}\n shadow-on-hover={true}\n product={product}/>\n </div>;\n }\n\n private getUrlPrefix() {\n let urlPrefix = '';\n if (this.limit) {\n urlPrefix = `&per_page=${this.limit > 32 ? 32 : this.limit}`;\n }\n return urlPrefix;\n }\n\n getApiUrl() {\n if (this.getSource() === 'json') {\n return;\n }\n let prefixes = this.getUrlPrefix();\n if (['offers', 'latest'].includes(this.getSource())) {\n return salla.url.api(`products?source=${this.getSource()}${prefixes}`);\n }\n if (['related', 'landing-page'].includes(this.getSource())) {\n return salla.url.api(`products?source=${this.getSource()}&source_value=${this.getSourceValue()}${prefixes}`);\n }\n\n try {\n return salla.url.api(`products?source=${this.getSource()}&source_value[]=${this.getSourceValue().join('&source_value[]=')}${prefixes}`);\n } catch (e) {\n salla.logger.warn(`source-value prop should be array of ids ex source-value=\"[1,2,3]\" for the source [${this.getSource()}]`);\n this.sourceValueIsValid = false;\n }\n }\n private getSource(){\n return {\n 'brands.single': 'brands',\n 'product.index': 'categories',\n 'product.index.latest': 'latest',\n 'product.index.offers': 'offers',\n 'product.index.search': 'search',\n 'landing-page': 'landing-page',\n 'product.index.tag': 'tags',\n }[this.source || salla.config.get('page.slug')] || this.source ||'latest';\n }\n\n private getSourceValue() {\n if (!['search', 'json'].includes(this.getSource())) {\n if (Array.isArray(JSON.parse(this.sourceValue)) && JSON.parse(this.sourceValue).length) {\n return JSON.parse(this.sourceValue);\n }\n\n if (typeof JSON.parse(this.sourceValue) == 'number') {\n return [JSON.parse(this.sourceValue)];\n }\n }\n return this.sourceValue || salla.config.get('page.id');\n }\n private canRender() {\n return this.sourceValueIsValid && this.isReady;\n }\n\n componentWillLoad() {\n if (this.source === 'json') {\n this.productsData = this.getSourceValue();\n this.isReady = true\n return;\n }\n salla.api.request(this.getApiUrl(), null, 'get').then(res => {\n this.productsData = res.data\n this.isReady = true\n })\n }\n\n render() {\n if ((this.getSource() == 'related' && !salla.config.get('store.settings.product.related_products_enabled')) || !this.canRender()) {\n return;\n }\n return (\n <Host class=\"s-products-slider-wrapper\">\n <salla-slider\n class=\"s-products-slider-slider\"\n id={this.sliderId || `s-products-slider-${Math.random().toString(36).substr(2, 9)}`}\n type=\"carousel\"\n block-title={this.blockTitle}\n block-subTitle={this.subTitle}\n display-all-url={this.displayAllUrl}\n >\n <div slot=\"items\">\n {this.productsData?.map((product) =>\n this.getItemHTML(product)\n )}\n </div>\n </salla-slider>\n </Host>\n );\n }\n\n}\n"],"version":3}
@@ -14,7 +14,7 @@ const AndroidPhoneIcon = `<!-- Generated by IcoMoon.io -->
14
14
  </svg>
15
15
  `;
16
16
 
17
- const sallaVerifyCss = "salla-verify{display:block}";
17
+ const sallaVerifyCss = "salla-verify{display:block}.s-verify-input{}.s-verify-input::-webkit-outer-spin-button,.s-verify-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.s-verify-input[type=number]{-moz-appearance:textfield}";
18
18
 
19
19
  const SallaVerify = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
20
20
  constructor() {
@@ -52,7 +52,32 @@ const SallaVerify = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
52
52
  this.resendAfter = 0;
53
53
  this.timer.innerHTML = '30 : 00';
54
54
  });
55
- this.otpHandler();
55
+ }
56
+ splitNumber(e) {
57
+ let data = e.data || e.target.value; // Chrome doesn't get the e.data, it's always empty, fallback to value then.
58
+ if (!data)
59
+ return; // Shouldn't happen, just in case.
60
+ if (data.length === 1)
61
+ return; // Here is a normal behavior, not a paste action.
62
+ this.modifyNext(e.target, data);
63
+ }
64
+ modifyNext(el, data) {
65
+ el.value = data[0]; // Apply first item to first input
66
+ data = data.substring(1); // remove the first char.
67
+ if (el.nextElementSibling && data.length) {
68
+ // Do the same with the next element and next data
69
+ this.modifyNext(el.nextElementSibling, data);
70
+ }
71
+ }
72
+ ;
73
+ checkAllInputs() {
74
+ let allFilled = true;
75
+ for (let i = 0; i < this.otpInputs.length; i++) {
76
+ if (this.otpInputs[i].value === '') {
77
+ allFilled = false;
78
+ }
79
+ }
80
+ return allFilled;
56
81
  }
57
82
  handleKeyUp(ev) {
58
83
  var _a, _b, _c, _d;
@@ -68,16 +93,43 @@ const SallaVerify = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
68
93
  (_c = ev.target.previousElementSibling) === null || _c === void 0 ? void 0 : _c.focus();
69
94
  (_d = ev.target.previousElementSibling) === null || _d === void 0 ? void 0 : _d.select();
70
95
  }
71
- this.toggleOTPSubmit();
96
+ // If the target is populated to quickly, value length can be > 1
97
+ if (ev.target.value.length > 1) {
98
+ this.splitNumber(ev);
99
+ }
72
100
  }
73
101
  handlePaste(ev) {
74
102
  let text = salla.helpers.number(ev.clipboardData.getData('text'))
75
103
  .replace(/[^0-9.]/g, '')
76
104
  .replace('..', '.');
77
105
  this.otpInputs.forEach((input, i) => input.value = text[i] || '');
78
- this.toggleOTPSubmit();
106
+ // this.toggleOTPSubmit();
79
107
  setTimeout(() => this.otpInputs[3].focus(), 100);
80
108
  }
109
+ handleInput(ev) {
110
+ salla.helpers.inputDigitsOnly(ev.target);
111
+ // check if all otpInputs has values then send the request
112
+ if (this.checkAllInputs()) {
113
+ setTimeout(() => {
114
+ this.toggleOTPSubmit();
115
+ }, 100);
116
+ }
117
+ }
118
+ handleFocus(ev) {
119
+ var _a;
120
+ // If the focus element is the first one, do nothing
121
+ if (ev.target === this.firstOtpInput)
122
+ return;
123
+ // If value of input 1 is empty, focus it.
124
+ if (((_a = this.firstOtpInput) === null || _a === void 0 ? void 0 : _a.value) == '') {
125
+ this.firstOtpInput.focus();
126
+ }
127
+ // If value of a previous input is empty, focus it.
128
+ // To remove if you don't wanna force user respecting the fields order.
129
+ if (ev.target.previousElementSibling.value == '') {
130
+ ev.target.previousElementSibling.focus();
131
+ }
132
+ }
81
133
  /**
82
134
  * Get current code
83
135
  * @return {string}
@@ -90,15 +142,17 @@ const SallaVerify = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
90
142
  * @param data
91
143
  */
92
144
  async open(data) {
93
- var _a;
145
+ var _a, _b;
94
146
  this.data = data;
95
147
  this.data.type = this.data.type || this.type;
96
148
  this.type = this.data.type;
97
149
  this.resendTimer();
98
150
  this.otpInputs = this.body.querySelectorAll('.s-verify-input');
151
+ this.firstOtpInput = this.body.querySelector('#otp-1');
99
152
  this.reset();
100
153
  this.display == 'modal' && ((_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title));
101
154
  this.modal.open();
155
+ (_b = this.firstOtpInput) === null || _b === void 0 ? void 0 : _b.addEventListener('input', e => this.splitNumber(e));
102
156
  // focus the first input after opening the modal
103
157
  setTimeout(() => this.otpInputs[0].focus(), 100);
104
158
  }
@@ -168,24 +222,8 @@ const SallaVerify = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
168
222
  return this.display == 'inline' ? h(Host, null, this.myBody()) :
169
223
  h("salla-modal", { width: "xs", class: "s-verify", ref: modal => this.modal = modal, "modal-title": this.title }, h("span", { slot: 'icon', class: "s-verify-header-icon", innerHTML: this.type == "mobile" ? AndroidPhoneIcon : email }), this.myBody());
170
224
  }
171
- otpHandler() {
172
- if (!window.OTPCredential) {
173
- return;
174
- }
175
- const ac = new AbortController();
176
- let o = {
177
- otp: { transport: ['sms'] },
178
- signal: ac.signal
179
- };
180
- navigator.credentials.get(o)
181
- .then(otp => {
182
- // @ts-ignore
183
- this.otpInputs.forEach((input, index) => input.value = otp.code[index]);
184
- return this.submit();
185
- });
186
- }
187
225
  myBody() {
188
- return (h("div", { class: "s-verify-body", ref: body => this.body = body }, h("div", { class: "s-verify-message", innerHTML: salla.lang.get('pages.profile.verify_message') }), h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }), h("div", { class: "s-verify-codes", dir: "ltr" }, [1, 2, 3, 4].map(() => h("input", { type: "tel", autocomplete: "one-time-code", pattern: "[0-9]*", inputmode: "numeric", maxlength: "1", class: "s-verify-input", onInput: e => salla.helpers.inputDigitsOnly(e.target), onPaste: e => this.handlePaste(e), onKeyUp: e => this.handleKeyUp(e), required: true }))), h("div", { slot: "footer", class: "s-verify-footer" }, h("salla-button", { class: "s-verify-submit", "loader-position": 'center', disabled: true, onClick: () => this.submit(), ref: b => this.btn = b }, salla.lang.get('pages.profile.verify')), h("p", { class: "s-verify-resend-message", ref: el => this.resendMessage = el }, salla.lang.get('blocks.header.resend_after'), h("b", { class: "s-verify-timer", ref: el => this.timer = el })), h("a", { href: "#", class: "s-verify-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit'))), h("slot", { name: "after-footer" })));
226
+ return (h("div", { class: "s-verify-body", ref: body => this.body = body }, h("div", { class: "s-verify-message", innerHTML: salla.lang.get('pages.profile.verify_message') }), h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }), h("div", { class: "s-verify-codes", dir: "ltr" }, [1, 2, 3, 4].map((i) => h("input", { type: "number", autocomplete: "one-time-code", pattern: "[0-9]*", inputmode: "numeric", maxlength: "1", value: "", id: `otp-${i}`, class: "s-verify-input", onInput: e => this.handleInput(e), onPaste: e => this.handlePaste(e), onKeyUp: e => this.handleKeyUp(e), onFocus: e => this.handleFocus(e), required: true }))), h("div", { slot: "footer", class: "s-verify-footer" }, h("salla-button", { class: "s-verify-submit", "loader-position": 'center', disabled: true, onClick: () => this.submit(), ref: b => this.btn = b }, salla.lang.get('pages.profile.verify')), h("p", { class: "s-verify-resend-message", ref: el => this.resendMessage = el }, salla.lang.get('blocks.header.resend_after'), h("b", { class: "s-verify-timer", ref: el => this.timer = el })), h("a", { href: "#", class: "s-verify-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit'))), h("slot", { name: "after-footer" })));
189
227
  }
190
228
  get host() { return this; }
191
229
  static get style() { return sallaVerifyCss; }
@@ -1 +1 @@
1
- {"file":"salla-verify2.js","mappings":";;;;;;;;;;;;;;;;AAAA,MAAM,cAAc,GAAG,6BAA6B;;MCUvC,WAAW;EACtB;;;;6BAuCsC,KAAK;mBAML,OAAO;gBAKO,QAAQ;sBAI9B,IAAI;0BAKA,IAAI;;uBASP,EAAE;2BAIG,KAAK;IAvEvC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;;MAClB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;MAC9B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,GAA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,4BAA4B,CAAC,EAC7C,SAAG,KAAK,EAAC,gBAAgB,EAAC,GAAG,EAAE,EAAE,IAAI,IAAI,CAAC,KAAK,GAAG,EAAE,GAAM,CAAI,EAChE,SAAG,IAAI,EAAC,GAAG,EAAC,KAAK,EAAC,iBAAiB,EAAC,OAAO,EAAE,MAAM,IAAI,CAAC,UAAU,EAAE,EAClE,GAAG,EAAE,EAAE,IAAI,IAAI,CAAC,MAAM,GAAG,EAAE,IAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAK,CACzE,EACN,YAAM,IAAI,EAAC,cAAc,GAAG,CACxB,EACN;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["MailIcon"],"sources":["./src/components/salla-verify/salla-verify.scss?tag=salla-verify","./src/components/salla-verify/salla-verify.tsx"],"sourcesContent":["/*\n* Verify Component: verify step in login and register and displays after the user change it's phone number.\n* You can use these classes to target the elements in the component.\n*/\n\nsalla-verify {\n display: block;\n}\n\n.s-verify {\n &-host{\n \n }\n &-message {\n\n }\n &-label {\n\n }\n &-codes {\n\n }\n &-input {\n\n }\n &-footer {\n\n }\n &-submit {\n\n }\n &-resend-message {\n\n }\n &-timer {\n\n }\n &-resend {\n\n }\n &-back {\n \n }\n}\n","import { Component, Host, Element, Event, EventEmitter, h, Method, Prop, State } from '@stencil/core';\nimport AndroidPhoneIcon from '../../assets/svg/android-phone.svg';\nimport MailIcon from '../../assets/svg/mail.svg';\n\n/**\n * @slot footer - Replaces the footer, by default it contains: verify button, resend, and timer\n * @slot after-footer - placeholder position\n */\n@Component({ tag: 'salla-verify', styleUrl: 'salla-verify.scss' })\n\nexport class SallaVerify {\n constructor() {\n salla.lang.onLoaded(() => {\n this.translationLoaded = true;\n this.title = salla.lang.get('pages.profile.verify_title') + salla.lang.get('common.elements.' + this.type);\n this.modal?.setTitle(this.title);\n });\n\n if (this.display == 'inline') {\n this.modal = { open: () => '', close: () => '', setTitle: () => '' };\n return;\n }\n\n //todo:: change this way, now we fire the event from the backend, we should listen to salla.profile.event.onUpdated\n salla.event.on('profile::verification', data => {\n let payload = Array.isArray(data) ? data[0] : data;\n this.isProfileVerify = true;\n this.open(payload);\n this.title = salla.lang.get('pages.profile.verify_title') + salla.lang.get('common.elements.' + payload.type);\n this.modal?.setTitle(this.title);\n });\n\n salla.event.on('modalClosed', () => {\n this.resendAfter = 0;\n this.timer.innerHTML = '30 : 00';\n });\n\n this.otpHandler();\n }\n\n private modal: HTMLSallaModalElement | any;\n private body: HTMLDivElement;\n private code: HTMLInputElement;\n private btn: HTMLSallaButtonElement;\n private resendMessage: HTMLParagraphElement;\n private timer: HTMLElement;\n private resend: HTMLAnchorElement;\n private otpInputs: NodeListOf<HTMLInputElement>;\n private data: { type: 'mobile' | 'email', phone?: string, country_code?: string, email?: string };\n\n @State() translationLoaded: boolean = false;\n\n @Element() host: HTMLElement;\n /**\n * Should render component without modal\n */\n @Prop() display: 'inline' | 'modal' = 'modal';\n\n /**\n * Verifying method\n */\n @Prop({ mutable: true }) type: 'mobile' | 'email' = 'mobile';\n /**\n * should auto reloading the page after success verification\n */\n @Prop() autoReload: boolean = true;\n\n /**\n * Once the api verify success, it will be login the customer in web pages\n */\n @Prop() supportWebAuth: boolean = true;\n\n /**\n * Event when success verification\n */\n @Event() verified: EventEmitter;\n\n @State() title: string;\n\n @State() resendAfter: number = 30;\n /**\n * to use: `salla.api.auth.verify` or `salla.profile.verify`\n */\n @State() isProfileVerify: boolean = false;\n\n private handleKeyUp(ev) {\n if (['Alt', 'Shift', 'Control', 'AltGraph', 'Ctrl'].includes(ev.key)) {\n return;\n }\n let key = ev.keyCode || ev.charCode;\n if (ev.target.value) {\n ev.target.nextElementSibling?.focus();\n ev.target.nextElementSibling?.select();\n } else if ([8, 46].includes(key)) {\n ev.target.previousElementSibling?.focus();\n ev.target.previousElementSibling?.select();\n }\n this.toggleOTPSubmit();\n }\n\n private handlePaste(ev) {\n let text = salla.helpers.number(ev.clipboardData.getData('text'))\n .replace(/[^0-9.]/g, '')\n .replace('..', '.');\n this.otpInputs.forEach((input, i) => input.value = text[i] || '');\n this.toggleOTPSubmit();\n setTimeout(() => this.otpInputs[3].focus(), 100);\n }\n\n /**\n * Get current code\n * @return {string}\n */\n @Method()\n async getCode() {\n return this.code.value;\n }\n\n /**\n * Open verifying modal\n * @param data\n */\n @Method()\n async open(data) {\n this.data = data;\n this.data.type = this.data.type || this.type;\n this.type = this.data.type;\n this.resendTimer();\n this.otpInputs = this.body.querySelectorAll('.s-verify-input');\n\n this.reset();\n this.display == 'modal' && this.modal?.setTitle(this.title);\n this.modal.open();\n\n // focus the first input after opening the modal\n setTimeout(() => this.otpInputs[0].focus(), 100);\n }\n\n private toggleOTPSubmit() {\n let otp = []\n this.otpInputs.forEach(input => input.value && otp.push(input.value));\n\n this.code.value = otp.join('');\n\n if (otp.length === 4) {\n this.btn.disable()\n this.btn.click();\n return;\n }\n\n this.btn.enable()\n }\n\n private reset() {\n this.otpInputs.forEach((input) => input.value = '');\n this.code.value = '';\n this.otpInputs[0].focus();\n }\n\n private resendTimer() {\n this.resendMessage.style.display = 'block';\n this.resend.style.display = 'none';\n this.resendAfter = 30;\n\n let timerId = setInterval(() => {\n if (this.resendAfter <= 0) {\n clearInterval(timerId);\n this.resend.style.display = 'block';\n this.resendMessage.style.display = 'none';\n } else {\n this.timer.innerHTML = `${this.resendAfter >= 10 ? this.resendAfter : '0' + this.resendAfter} : 00`;\n this.resendAfter--;\n }\n }, 1000);\n }\n\n private resendCode() {\n return this.btn.stop()\n .then(() => this.btn.disable())\n .then(() => {\n this.otpInputs.forEach(input => input.value = '');\n this.otpInputs[0].focus();\n })\n .then(() => salla.api.auth.resend(this.data))\n .finally(() => this.resendTimer());\n }\n\n private submit() {\n //if code not 4 digits, focus on the after filled input,\n if (this.code.value.length < 4) {\n this.otpInputs[this.code.value.length].focus();\n salla.log('Trying to submit without 4 digits!');\n return;\n }\n\n let data = { code: this.code.value, ...this.data };\n\n return this.btn.load()\n .then(() => this.btn.disable())\n .then(() => this.isProfileVerify ? salla.profile.verify(data) : salla.auth.verify(data, this.supportWebAuth))\n .then(response => this.verified.emit(response))\n .then(() => this.btn.stop() && this.btn.disable())\n .then(() => this.modal.close())\n .then(() => this.autoReload && window.location.reload())\n .catch((error) => {\n salla.logger.error(error);\n this.btn.stop() && this.btn.enable() && this.reset()\n });\n }\n\n render() {\n return this.display == 'inline' ? <Host>{this.myBody()}</Host> :\n <salla-modal width=\"xs\" class=\"s-verify\" ref={modal => this.modal = modal}\n modal-title={this.title}>\n <span slot='icon' class=\"s-verify-header-icon\" innerHTML={this.type == \"mobile\" ? AndroidPhoneIcon : MailIcon}></span>\n {this.myBody()}\n </salla-modal>;\n }\n\n private otpHandler() {\n if (!window.OTPCredential) {\n return;\n }\n\n const ac = new AbortController();\n\n let o = {\n otp: {transport: ['sms']},\n signal: ac.signal\n }\n\n navigator.credentials.get(o)\n .then(otp => {\n // @ts-ignore\n this.otpInputs.forEach((input, index) => input.value = otp.code[index])\n return this.submit()\n });\n }\n\n private myBody() {\n return (\n <div class=\"s-verify-body\" ref={body => this.body = body}>\n <div class=\"s-verify-message\" innerHTML={salla.lang.get('pages.profile.verify_message')} />\n <input type=\"hidden\" name=\"code\" maxlength=\"4\" required ref={code => this.code = code} />\n <div class=\"s-verify-codes\" dir=\"ltr\">\n {[1, 2, 3, 4].map(() => <input type=\"tel\" autocomplete=\"one-time-code\" pattern=\"[0-9]*\" inputmode=\"numeric\"\n maxlength=\"1\" class=\"s-verify-input\"\n onInput={e => salla.helpers.inputDigitsOnly(e.target)}\n onPaste={e => this.handlePaste(e)}\n onKeyUp={e => this.handleKeyUp(e)}\n required />)}\n </div>\n <div slot=\"footer\" class=\"s-verify-footer\">\n <salla-button class=\"s-verify-submit\" loader-position='center' disabled={true}\n onClick={() => this.submit()}\n ref={b => this.btn = b}>\n {salla.lang.get('pages.profile.verify')}\n </salla-button>\n <p class=\"s-verify-resend-message\" ref={el => this.resendMessage = el}>\n {salla.lang.get('blocks.header.resend_after')}\n <b class=\"s-verify-timer\" ref={el => this.timer = el}></b></p>\n <a href=\"#\" class=\"s-verify-resend\" onClick={() => this.resendCode()}\n ref={el => this.resend = el}>{salla.lang.get('blocks.comments.submit')}</a>\n </div>\n <slot name=\"after-footer\" />\n </div>\n );\n }\n}\n"],"version":3}
1
+ {"file":"salla-verify2.js","mappings":";;;;;;;;;;;;;;;;AAAA,MAAM,cAAc,GAAG,4NAA4N;;MCUtO,WAAW;EACtB;;;;6BAuCsC,KAAK;mBAML,OAAO;gBAKO,QAAQ;sBAI9B,IAAI;0BAKA,IAAI;;uBASP,EAAE;2BAIG,KAAK;IAvEvC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;;MAClB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;MAC9B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,4BAA4B,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,kBAAkB,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;MAC3G,MAAA,IAAI,CAAC,KAAK,0CAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KAClC,CAAC,CAAC;IAEH,IAAI,IAAI,CAAC,OAAO,IAAI,QAAQ,EAAE;MAC5B,IAAI,CAAC,KAAK,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC;MACrE,OAAO;KACR;;IAGD,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,uBAAuB,EAAE,IAAI;;MAC1C,IAAI,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;MACnD,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;MAC5B,IAAI,CAAC,IA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C,OAAO,EAAE,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EACjC,OAAO,EAAE,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EACjC,OAAO,EAAE,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EACjC,QAAQ,SAAG,CAAC,CACV,EACN,WAAK,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAC,iBAAiB,IACxC,oBAAc,KAAK,EAAC,iBAAiB,qBAAiB,QAAQ,EAAC,QAAQ,EAAE,IAAI,EAC3E,OAAO,EAAE,MAAM,IAAI,CAAC,MAAM,EAAE,EAC5B,GAAG,EAAE,CAAC,IAAI,IAAI,CAAC,GAAG,GAAG,CAAC,IACrB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAC1B,EACf,SAAG,KAAK,EAAC,yBAAyB,EAAC,GAAG,EAAE,EAAE,IAAI,IAAI,CAAC,aAAa,GAAG,EAAE,IAClE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,4BAA4B,CAAC,EAC7C,SAAG,KAAK,EAAC,gBAAgB,EAAC,GAAG,EAAE,EAAE,IAAI,IAAI,CAAC,KAAK,GAAG,EAAE,GAAM,CAAI,EAChE,SAAG,IAAI,EAAC,GAAG,EAAC,KAAK,EAAC,iBAAiB,EAAC,OAAO,EAAE,MAAM,IAAI,CAAC,UAAU,EAAE,EAClE,GAAG,EAAE,EAAE,IAAI,IAAI,CAAC,MAAM,GAAG,EAAE,IAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAK,CACzE,EACN,YAAM,IAAI,EAAC,cAAc,GAAG,CACxB,EACN;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["MailIcon"],"sources":["./src/components/salla-verify/salla-verify.scss?tag=salla-verify","./src/components/salla-verify/salla-verify.tsx"],"sourcesContent":["/*\n* Verify Component: verify step in login and register and displays after the user change it's phone number.\n* You can use these classes to target the elements in the component.\n*/\n\nsalla-verify {\n display: block;\n}\n\n.s-verify {\n &-host{\n \n }\n &-message {\n\n }\n &-label {\n\n }\n &-codes {\n\n }\n &-input {\n // Hide number input arrows\n /* Chrome, Safari, Edge, Opera */\n &::-webkit-outer-spin-button,\n &::-webkit-inner-spin-button {\n -webkit-appearance: none;\n margin: 0;\n }\n\n /* Firefox */\n &[type=number] {\n -moz-appearance: textfield;\n }\n }\n &-footer {\n\n }\n &-submit {\n\n }\n &-resend-message {\n\n }\n &-timer {\n\n }\n &-resend {\n\n }\n &-back {\n \n }\n}\n","import { Component, Host, Element, Event, EventEmitter, h, Method, Prop, State } from '@stencil/core';\nimport AndroidPhoneIcon from '../../assets/svg/android-phone.svg';\nimport MailIcon from '../../assets/svg/mail.svg';\n\n/**\n * @slot footer - Replaces the footer, by default it contains: verify button, resend, and timer\n * @slot after-footer - placeholder position\n */\n@Component({ tag: 'salla-verify', styleUrl: 'salla-verify.scss' })\n\nexport class SallaVerify {\n constructor() {\n salla.lang.onLoaded(() => {\n this.translationLoaded = true;\n this.title = salla.lang.get('pages.profile.verify_title') + salla.lang.get('common.elements.' + this.type);\n this.modal?.setTitle(this.title);\n });\n\n if (this.display == 'inline') {\n this.modal = { open: () => '', close: () => '', setTitle: () => '' };\n return;\n }\n\n //todo:: change this way, now we fire the event from the backend, we should listen to salla.profile.event.onUpdated\n salla.event.on('profile::verification', data => {\n let payload = Array.isArray(data) ? data[0] : data;\n this.isProfileVerify = true;\n this.open(payload);\n this.title = salla.lang.get('pages.profile.verify_title') + salla.lang.get('common.elements.' + payload.type);\n this.modal?.setTitle(this.title);\n });\n\n salla.event.on('modalClosed', () => {\n this.resendAfter = 0;\n this.timer.innerHTML = '30 : 00';\n });\n\n }\n\n private modal: HTMLSallaModalElement | any;\n private body: HTMLDivElement;\n private code: HTMLInputElement;\n private btn: HTMLSallaButtonElement;\n private resendMessage: HTMLParagraphElement;\n private timer: HTMLElement;\n private resend: HTMLAnchorElement;\n private otpInputs: NodeListOf<HTMLInputElement>;\n private firstOtpInput: HTMLInputElement;\n private data: { type: 'mobile' | 'email', phone?: string, country_code?: string, email?: string };\n\n @State() translationLoaded: boolean = false;\n\n @Element() host: HTMLElement;\n /**\n * Should render component without modal\n */\n @Prop() display: 'inline' | 'modal' = 'modal';\n\n /**\n * Verifying method\n */\n @Prop({ mutable: true }) type: 'mobile' | 'email' = 'mobile';\n /**\n * should auto reloading the page after success verification\n */\n @Prop() autoReload: boolean = true;\n\n /**\n * Once the api verify success, it will be login the customer in web pages\n */\n @Prop() supportWebAuth: boolean = true;\n\n /**\n * Event when success verification\n */\n @Event() verified: EventEmitter;\n\n @State() title: string;\n\n @State() resendAfter: number = 30;\n /**\n * to use: `salla.api.auth.verify` or `salla.profile.verify`\n */\n @State() isProfileVerify: boolean = false;\n\n private splitNumber(e) {\n let data = e.data || e.target.value; // Chrome doesn't get the e.data, it's always empty, fallback to value then.\n if (!data) return; // Shouldn't happen, just in case.\n if (data.length === 1) return; // Here is a normal behavior, not a paste action.\n this.modifyNext(e.target, data);\n }\n\n private modifyNext(el, data) {\n el.value = data[0]; // Apply first item to first input\n data = data.substring(1); // remove the first char.\n if (el.nextElementSibling && data.length) {\n // Do the same with the next element and next data\n this.modifyNext(el.nextElementSibling, data);\n }\n };\n\n private checkAllInputs() {\n let allFilled = true;\n for (let i = 0; i < this.otpInputs.length; i++) {\n if (this.otpInputs[i].value === '') {\n allFilled = false;\n }\n }\n return allFilled;\n }\n\n private handleKeyUp(ev) {\n if (['Alt', 'Shift', 'Control', 'AltGraph', 'Ctrl'].includes(ev.key)) {\n return;\n }\n let key = ev.keyCode || ev.charCode;\n if (ev.target.value) {\n ev.target.nextElementSibling?.focus();\n ev.target.nextElementSibling?.select();\n } else if ([8, 46].includes(key)) {\n ev.target.previousElementSibling?.focus();\n ev.target.previousElementSibling?.select();\n }\n // If the target is populated to quickly, value length can be > 1\n if (ev.target.value.length > 1) {\n this.splitNumber(ev);\n }\n }\n\n private handlePaste(ev) {\n let text = salla.helpers.number(ev.clipboardData.getData('text'))\n .replace(/[^0-9.]/g, '')\n .replace('..', '.');\n this.otpInputs.forEach((input, i) => input.value = text[i] || '');\n // this.toggleOTPSubmit();\n setTimeout(() => this.otpInputs[3].focus(), 100);\n }\n\n private handleInput(ev) {\n salla.helpers.inputDigitsOnly(ev.target)\n // check if all otpInputs has values then send the request\n if (this.checkAllInputs()) {\n setTimeout(() => {\n this.toggleOTPSubmit();\n }, 100);\n }\n }\n\n private handleFocus(ev) {\n // If the focus element is the first one, do nothing\n if (ev.target === this.firstOtpInput) return;\n // If value of input 1 is empty, focus it.\n if (this.firstOtpInput?.value == '') {\n this.firstOtpInput.focus();\n }\n // If value of a previous input is empty, focus it.\n // To remove if you don't wanna force user respecting the fields order.\n if (ev.target.previousElementSibling.value == '') {\n ev.target.previousElementSibling.focus();\n }\n }\n\n /**\n * Get current code\n * @return {string}\n */\n @Method()\n async getCode() {\n return this.code.value;\n }\n\n /**\n * Open verifying modal\n * @param data\n */\n @Method()\n async open(data) {\n this.data = data;\n this.data.type = this.data.type || this.type;\n this.type = this.data.type;\n this.resendTimer();\n this.otpInputs = this.body.querySelectorAll('.s-verify-input');\n this.firstOtpInput = this.body.querySelector('#otp-1');\n this.reset();\n this.display == 'modal' && this.modal?.setTitle(this.title);\n this.modal.open();\n this.firstOtpInput?.addEventListener('input', e => this.splitNumber(e));\n\n // focus the first input after opening the modal\n setTimeout(() => this.otpInputs[0].focus(), 100);\n }\n\n private toggleOTPSubmit() {\n let otp = []\n this.otpInputs.forEach(input => input.value && otp.push(input.value));\n\n this.code.value = otp.join('');\n\n if (otp.length === 4) {\n this.btn.disable()\n this.btn.click();\n return;\n }\n\n this.btn.enable()\n }\n\n private reset() {\n this.otpInputs.forEach((input) => input.value = '');\n this.code.value = '';\n this.otpInputs[0].focus();\n }\n\n private resendTimer() {\n this.resendMessage.style.display = 'block';\n this.resend.style.display = 'none';\n this.resendAfter = 30;\n\n let timerId = setInterval(() => {\n if (this.resendAfter <= 0) {\n clearInterval(timerId);\n this.resend.style.display = 'block';\n this.resendMessage.style.display = 'none';\n } else {\n this.timer.innerHTML = `${this.resendAfter >= 10 ? this.resendAfter : '0' + this.resendAfter} : 00`;\n this.resendAfter--;\n }\n }, 1000);\n }\n\n private resendCode() {\n return this.btn.stop()\n .then(() => this.btn.disable())\n .then(() => {\n this.otpInputs.forEach(input => input.value = '');\n this.otpInputs[0].focus();\n })\n .then(() => salla.api.auth.resend(this.data))\n .finally(() => this.resendTimer());\n }\n\n private submit() {\n //if code not 4 digits, focus on the after filled input,\n if (this.code.value.length < 4) {\n this.otpInputs[this.code.value.length].focus();\n salla.log('Trying to submit without 4 digits!');\n return;\n }\n\n let data = { code: this.code.value, ...this.data };\n\n return this.btn.load()\n .then(() => this.btn.disable())\n .then(() => this.isProfileVerify ? salla.profile.verify(data) : salla.auth.verify(data, this.supportWebAuth))\n .then(response => this.verified.emit(response))\n .then(() => this.btn.stop() && this.btn.disable())\n .then(() => this.modal.close())\n .then(() => this.autoReload && window.location.reload())\n .catch((error) => {\n salla.logger.error(error);\n this.btn.stop() && this.btn.enable() && this.reset()\n });\n }\n\n render() {\n return this.display == 'inline' ? <Host>{this.myBody()}</Host> :\n <salla-modal width=\"xs\" class=\"s-verify\" ref={modal => this.modal = modal}\n modal-title={this.title}>\n <span slot='icon' class=\"s-verify-header-icon\" innerHTML={this.type == \"mobile\" ? AndroidPhoneIcon : MailIcon}></span>\n {this.myBody()}\n </salla-modal>;\n }\n\n\n private myBody() {\n return (\n <div class=\"s-verify-body\" ref={body => this.body = body}>\n <div class=\"s-verify-message\" innerHTML={salla.lang.get('pages.profile.verify_message')} />\n <input type=\"hidden\" name=\"code\" maxlength=\"4\" required ref={code => this.code = code} />\n <div class=\"s-verify-codes\" dir=\"ltr\">\n {[1, 2, 3, 4].map((i) => <input type=\"number\" autocomplete=\"one-time-code\" pattern=\"[0-9]*\" inputmode=\"numeric\"\n maxlength=\"1\" value=\"\" id={`otp-${i}`} class=\"s-verify-input\"\n onInput={e => this.handleInput(e)}\n onPaste={e => this.handlePaste(e)}\n onKeyUp={e => this.handleKeyUp(e)}\n onFocus={e => this.handleFocus(e)}\n required />)}\n </div>\n <div slot=\"footer\" class=\"s-verify-footer\">\n <salla-button class=\"s-verify-submit\" loader-position='center' disabled={true}\n onClick={() => this.submit()}\n ref={b => this.btn = b}>\n {salla.lang.get('pages.profile.verify')}\n </salla-button>\n <p class=\"s-verify-resend-message\" ref={el => this.resendMessage = el}>\n {salla.lang.get('blocks.header.resend_after')}\n <b class=\"s-verify-timer\" ref={el => this.timer = el}></b></p>\n <a href=\"#\" class=\"s-verify-resend\" onClick={() => this.resendCode()}\n ref={el => this.resend = el}>{salla.lang.get('blocks.comments.submit')}</a>\n </div>\n <slot name=\"after-footer\" />\n </div>\n );\n }\n}\n"],"version":3}