@salla.sa/twilight-components 1.6.3 → 1.6.5

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 (103) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/salla-button_27.cjs.entry.js +27877 -0
  3. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +26 -0
  4. package/dist/cjs/salla-scopes.cjs.entry.js +9 -6
  5. package/dist/cjs/salla-select.cjs.entry.js +159 -0
  6. package/dist/cjs/twilight-components.cjs.js +1 -1
  7. package/dist/collection/assets/svg/caret-down.svg +0 -1
  8. package/dist/collection/assets/svg/images.svg +0 -1
  9. package/dist/collection/collection-manifest.json +5 -0
  10. package/dist/collection/components/salla-datetime-picker/interfaces.js +4 -0
  11. package/dist/collection/components/salla-datetime-picker/salla-datetime-picker.css +13 -0
  12. package/dist/collection/components/salla-datetime-picker/salla-datetime-picker.js +1374 -0
  13. package/dist/collection/components/salla-file-upload/interfaces.js +42 -0
  14. package/dist/collection/components/salla-file-upload/salla-file-upload.css +219 -0
  15. package/dist/collection/components/salla-file-upload/salla-file-upload.js +1435 -0
  16. package/dist/collection/components/salla-gifting/gift-schema.js +4 -0
  17. package/dist/collection/components/salla-gifting/intefaces.js +4 -0
  18. package/dist/collection/components/salla-gifting/salla-gifting.css +20 -0
  19. package/dist/collection/components/salla-gifting/salla-gifting.js +564 -0
  20. package/dist/collection/components/salla-localization-modal/salla-localization-modal.js +23 -13
  21. package/dist/collection/components/salla-login-modal/salla-login-modal.js +48 -29
  22. package/dist/collection/components/salla-loyalty/salla-loyalty-prize-item.css +3 -0
  23. package/dist/collection/components/salla-loyalty/salla-loyalty-prize-item.js +69 -0
  24. package/dist/collection/components/salla-loyalty/salla-loyalty.css +0 -4
  25. package/dist/collection/components/salla-loyalty/salla-loyalty.js +29 -16
  26. package/dist/collection/components/salla-modal/salla-modal.css +6 -1
  27. package/dist/collection/components/salla-offer-modal/salla-offer-modal.js +37 -13
  28. package/dist/collection/components/salla-product-size-guide/salla-product-size-guide.js +23 -8
  29. package/dist/collection/components/salla-rating-modal/salla-rating-modal.js +87 -64
  30. package/dist/collection/components/salla-scopes/salla-scopes.js +11 -7
  31. package/dist/collection/components/salla-search/salla-search.js +1 -1
  32. package/dist/collection/components/salla-select/salla-select.css +86 -0
  33. package/dist/collection/components/salla-select/salla-select.js +610 -0
  34. package/dist/collection/components/salla-social-share/salla-social-share.js +1 -3
  35. package/dist/collection/components/salla-tel-input/interfaces.js +4 -0
  36. package/dist/collection/components/salla-tel-input/salla-tel-input.css +1 -2
  37. package/dist/collection/components/salla-tel-input/salla-tel-input.js +32 -3
  38. package/dist/collection/components/salla-verify/salla-verify.js +1 -1
  39. package/dist/collection/global/app.js +15 -12
  40. package/dist/components/_commonjsHelpers.js +24 -0
  41. package/dist/components/anime.es.js +1312 -0
  42. package/dist/components/index.d.ts +5 -0
  43. package/dist/components/index.js +5 -0
  44. package/dist/components/salla-datetime-picker.d.ts +11 -0
  45. package/dist/components/salla-datetime-picker.js +9 -0
  46. package/dist/components/salla-datetime-picker2.js +2876 -0
  47. package/dist/components/salla-file-upload.d.ts +11 -0
  48. package/dist/components/salla-file-upload.js +9 -0
  49. package/dist/components/salla-file-upload2.js +14623 -0
  50. package/dist/components/salla-gifting.d.ts +11 -0
  51. package/dist/components/salla-gifting.js +499 -0
  52. package/dist/components/salla-localization-modal.js +31 -16
  53. package/dist/components/salla-login-modal.js +37 -20
  54. package/dist/components/salla-loyalty-prize-item.d.ts +11 -0
  55. package/dist/components/salla-loyalty-prize-item.js +42 -0
  56. package/dist/components/salla-loyalty.js +28 -17
  57. package/dist/components/salla-modal2.js +1 -1
  58. package/dist/components/salla-offer-modal.js +42 -12
  59. package/dist/components/salla-product-size-guide.js +21 -6
  60. package/dist/components/salla-rating-modal.js +47 -19
  61. package/dist/components/salla-scopes.js +10 -6
  62. package/dist/components/salla-search.js +1 -1
  63. package/dist/components/salla-select.d.ts +11 -0
  64. package/dist/components/salla-select.js +199 -0
  65. package/dist/components/salla-social-share.js +2 -1311
  66. package/dist/components/salla-swiper2.js +9 -9
  67. package/dist/components/salla-tel-input2.js +15 -18
  68. package/dist/components/salla-verify2.js +1 -1
  69. package/dist/esm/loader.js +1 -1
  70. package/dist/esm/salla-button_27.entry.js +27847 -0
  71. package/dist/esm/salla-loyalty-prize-item.entry.js +22 -0
  72. package/dist/esm/salla-scopes.entry.js +9 -6
  73. package/dist/esm/salla-select.entry.js +155 -0
  74. package/dist/esm/twilight-components.js +1 -1
  75. package/dist/twilight-components/p-49125b6a.entry.js +4 -0
  76. package/dist/twilight-components/p-6087187d.entry.js +22 -0
  77. package/dist/twilight-components/p-9a25753c.entry.js +4 -0
  78. package/dist/twilight-components/p-df1eb1e5.entry.js +4 -0
  79. package/dist/twilight-components/twilight-components.esm.js +1 -1
  80. package/dist/types/components/salla-datetime-picker/interfaces.d.ts +8 -0
  81. package/dist/types/components/salla-datetime-picker/salla-datetime-picker.d.ts +250 -0
  82. package/dist/types/components/salla-file-upload/interfaces.d.ts +766 -0
  83. package/dist/types/components/salla-file-upload/salla-file-upload.d.ts +267 -0
  84. package/dist/types/components/salla-gifting/gift-schema.d.ts +20 -0
  85. package/dist/types/components/salla-gifting/intefaces.d.ts +18 -0
  86. package/dist/types/components/salla-gifting/salla-gifting.d.ts +98 -0
  87. package/dist/types/components/salla-localization-modal/salla-localization-modal.d.ts +3 -2
  88. package/dist/types/components/salla-login-modal/salla-login-modal.d.ts +13 -3
  89. package/dist/types/components/salla-loyalty/salla-loyalty-prize-item.d.ts +8 -0
  90. package/dist/types/components/salla-loyalty/salla-loyalty.d.ts +2 -0
  91. package/dist/types/components/salla-offer-modal/salla-offer-modal.d.ts +3 -1
  92. package/dist/types/components/salla-product-size-guide/salla-product-size-guide.d.ts +4 -0
  93. package/dist/types/components/salla-rating-modal/salla-rating-modal.d.ts +3 -2
  94. package/dist/types/components/salla-scopes/salla-scopes.d.ts +1 -0
  95. package/dist/types/components/salla-select/salla-select.d.ts +110 -0
  96. package/dist/types/components/salla-tel-input/interfaces.d.ts +4 -0
  97. package/dist/types/components/salla-tel-input/salla-tel-input.d.ts +3 -0
  98. package/dist/types/components.d.ts +1253 -10
  99. package/package.json +3 -3
  100. package/dist/cjs/salla-button_24.cjs.entry.js +0 -10087
  101. package/dist/esm/salla-button_24.entry.js +0 -10060
  102. package/dist/twilight-components/p-30b2c5b0.entry.js +0 -4
  103. package/dist/twilight-components/p-5fb32395.entry.js +0 -4
@@ -4,9 +4,11 @@
4
4
  import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
5
5
  import { H as Helper } from './Helper.js';
6
6
  import { K as KeyboardArrowRightIcon } from './keyboard_arrow_right.js';
7
- import { d as defineCustomElement$4 } from './salla-button2.js';
8
- import { d as defineCustomElement$3 } from './salla-loading2.js';
9
- import { d as defineCustomElement$2 } from './salla-modal2.js';
7
+ import { d as defineCustomElement$6 } from './salla-button2.js';
8
+ import { d as defineCustomElement$5 } from './salla-loading2.js';
9
+ import { d as defineCustomElement$4 } from './salla-modal2.js';
10
+ import { d as defineCustomElement$3 } from './salla-placeholder2.js';
11
+ import { d as defineCustomElement$2 } from './salla-skeleton2.js';
10
12
 
11
13
  const SpecialDiscountIcon = `<!-- Generated by IcoMoon.io -->
12
14
  <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
@@ -28,6 +30,13 @@ const Tag = `<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" he
28
30
  </svg>
29
31
  `;
30
32
 
33
+ const Cart2 = `<!-- Generated by IcoMoon.io -->
34
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
35
+ <title>cart2</title>
36
+ <path d="M6.845 5.333l-1.905-5.333h-3.607c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333v0h1.727l5.72 16.012c0.569 1.56 2.039 2.654 3.765 2.655h12.133c0.001 0 0.002 0 0.003 0 1.825 0 3.364-1.222 3.845-2.892l0.007-0.028 3.161-13.080zM25.96 17.716c-0.167 0.554-0.672 0.951-1.27 0.951-0.002 0-0.005 0-0.007-0h-12.133c-0.575-0-1.065-0.364-1.252-0.875l-0.003-0.009-3.497-9.783h20.508zM13.333 24c-2.209 0-4 1.791-4 4s1.791 4 4 4c2.209 0 4-1.791 4-4v0c0-2.209-1.791-4-4-4v0zM13.333 29.333c-0.736 0-1.333-0.597-1.333-1.333s0.597-1.333 1.333-1.333c0.736 0 1.333 0.597 1.333 1.333v0c0 0.736-0.597 1.333-1.333 1.333v0zM24 24c-2.209 0-4 1.791-4 4s1.791 4 4 4c2.209 0 4-1.791 4-4v0c0-2.209-1.791-4-4-4v0zM24 29.333c-0.736 0-1.333-0.597-1.333-1.333s0.597-1.333 1.333-1.333c0.736 0 1.333 0.597 1.333 1.333v0c0 0.736-0.597 1.333-1.333 1.333v0z"></path>
37
+ </svg>
38
+ `;
39
+
31
40
  const sallaOfferModalCss = "";
32
41
 
33
42
  const SallaOfferModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
@@ -36,8 +45,10 @@ const SallaOfferModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
36
45
  this.__registerHost();
37
46
  var _a, _b;
38
47
  this.offer = null;
48
+ this.hasError = false;
39
49
  this.translationLoaded = false;
40
50
  Helper.setHost(this.host);
51
+ salla.event.on('offer-modal::open', (product_id) => this.open(product_id));
41
52
  salla.lang.onLoaded(() => {
42
53
  this.translationLoaded = true;
43
54
  });
@@ -57,8 +68,15 @@ const SallaOfferModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
57
68
  */
58
69
  async open(product_id) {
59
70
  //TODO:: make sure there is only one offer
60
- return salla.product.offers(product_id)
61
- .then(response => this.showOffer(response.data[0]));
71
+ this.modal.open();
72
+ return salla.api.withoutNotifier(salla.product.offers(product_id))
73
+ .then(response => this.showOffer(response.data[0]))
74
+ .catch(e => {
75
+ var _a, _b, _c, _d;
76
+ this.hasError = true;
77
+ this.errorMessage = ((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || ((_d = e.response) === null || _d === void 0 ? void 0 : _d.data);
78
+ })
79
+ .finally(() => setTimeout(() => { this.modal.stopLoading(); }, 1000));
62
80
  }
63
81
  /**
64
82
  * Show offer details
@@ -69,7 +87,6 @@ const SallaOfferModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
69
87
  this.offer_name = offer.name;
70
88
  this.offer_message = offer.message;
71
89
  this.modal.setTitle(this.offer_name);
72
- return this.modal.open();
73
90
  }
74
91
  rememberMe(event) {
75
92
  salla.storage.set('remember-offer-' + this.offer.id, event.target.checked);
@@ -91,8 +108,8 @@ const SallaOfferModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
91
108
  }
92
109
  render() {
93
110
  var _a, _b;
94
- return h("salla-modal", { "sub-title-first": true, "sub-title": this.offer_message, ref: modal => this.modal = modal, "is-loading": this.offer === null }, h("span", { slot: 'icon', class: "s-offer-modal-header-icon", innerHTML: SpecialDiscountIcon }), this.offer !== null
95
- ? [h("div", { class: "s-offer-modal-scrolled-slider-wrap" }, h("div", { class: "s-offer-modal-body s-offer-modal-scrolled-slider" }, ((_a = this.offer.get.categories) === null || _a === void 0 ? void 0 : _a.length) > 0
111
+ return h("salla-modal", { "sub-title-first": true, "has-skeleton": true, "sub-title": this.offer_message, ref: modal => this.modal = modal, isLoading: true }, h("div", { slot: 'loading' }, h("div", { class: "s-offer-modal-skeleton" }, h("div", { class: "s-offer-modal-skeleton-header" }, h("salla-skeleton", { type: 'circle', height: '80px', width: '80px' }), h("salla-skeleton", { height: '15px', width: '50%' }), h("salla-skeleton", { height: '10px', width: '30%' })), h("div", { class: "s-offer-modal-skeleton-items" }, [...Array(3)].map(() => h("div", { class: "s-offer-modal-skeleton-item" }, h("salla-skeleton", { height: '9rem' }), h("div", { class: "s-offer-modal-skeleton-item-title" }, h("salla-skeleton", { height: '15px', width: '100%' })), h("div", { class: "s-offer-modal-skeleton-item-subtitle" }, h("salla-skeleton", { height: '9px', width: '50%' }), h("div", { innerHTML: Cart2 }))))), h("div", { class: "s-offer-modal-skeleton-footer" }, h("salla-skeleton", { height: '15px', width: '50%' }), h("salla-skeleton", { height: '15px', width: '30%' })))), !this.hasError && this.offer !== null
112
+ ? [h("span", { slot: 'icon', class: "s-offer-modal-header-icon", innerHTML: SpecialDiscountIcon }), h("div", { class: "s-offer-modal-scrolled-slider-wrap" }, h("div", { class: "s-offer-modal-body s-offer-modal-scrolled-slider" }, ((_a = this.offer.get.categories) === null || _a === void 0 ? void 0 : _a.length) > 0
96
113
  ? this.offer.get.categories.map(category => h("a", { href: category.urls.customer, class: "s-offer-modal-badge s-offer-modal-slider-item", innerHTML: this.categorySlot
97
114
  .replace(/\{tagIcon\}/g, Tag)
98
115
  .replace(/\{name\}/g, category.name)
@@ -106,7 +123,8 @@ const SallaOfferModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
106
123
  : salla.money(product.price)) }, h("div", { class: "s-offer-modal-btn-wrap" }, h("salla-button", { width: "wide", fill: 'outline', "data-id": product.id, disabled: !product.is_available, "loader-position": "center", onClick: this.addItem }, product.is_available ? salla.lang.get('pages.cart.add_to_cart') : salla.lang.get('pages.products.out_of_stock')))))), h("div", { class: "s-offer-modal-slider-nav" }, h("button", { class: "s-offer-modal-nav-btn s-offer-modal-prev-btn" }, h("span", { class: "s-offer-modal-nav-btn-icon", innerHTML: KeyboardArrowLeftIcon })), h("button", { class: "s-offer-modal-nav-btn s-offer-modal-next-btn" }, h("span", { class: "s-offer-modal-nav-btn-icon", innerHTML: KeyboardArrowRightIcon })))), h("div", { class: "s-offer-modal-footer", slot: "footer" }, this.offer.formatted_date ?
107
124
  h("p", { class: "s-offer-modal-expiry" }, salla.lang.get('pages.products.offer_expires_in'), " ", this.offer.formatted_date)
108
125
  : '', h("label", { class: "s-offer-modal-remember-label" }, h("input", { type: "checkbox", onChange: e => this.rememberMe(e), class: "s-offer-modal-remember-input" }), "\u00A0 ", salla.lang.get('common.elements.remember_my_choice'))),
109
- ] : '');
126
+ ] :
127
+ h("salla-placeholder", { class: "s-loyalty-placeholder", alignment: "center" }, !!this.errorMessage ? h("span", { slot: "description" }, this.errorMessage) : ''));
110
128
  }
111
129
  componentDidRender() {
112
130
  // Sooo mini Slider
@@ -159,6 +177,8 @@ const SallaOfferModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
159
177
  "offer": [32],
160
178
  "offer_name": [32],
161
179
  "offer_message": [32],
180
+ "hasError": [32],
181
+ "errorMessage": [32],
162
182
  "translationLoaded": [32],
163
183
  "open": [64],
164
184
  "showOffer": [64]
@@ -167,7 +187,7 @@ function defineCustomElement$1() {
167
187
  if (typeof customElements === "undefined") {
168
188
  return;
169
189
  }
170
- const components = ["salla-offer-modal", "salla-button", "salla-loading", "salla-modal"];
190
+ const components = ["salla-offer-modal", "salla-button", "salla-loading", "salla-modal", "salla-placeholder", "salla-skeleton"];
171
191
  components.forEach(tagName => { switch (tagName) {
172
192
  case "salla-offer-modal":
173
193
  if (!customElements.get(tagName)) {
@@ -176,15 +196,25 @@ function defineCustomElement$1() {
176
196
  break;
177
197
  case "salla-button":
178
198
  if (!customElements.get(tagName)) {
179
- defineCustomElement$4();
199
+ defineCustomElement$6();
180
200
  }
181
201
  break;
182
202
  case "salla-loading":
183
203
  if (!customElements.get(tagName)) {
184
- defineCustomElement$3();
204
+ defineCustomElement$5();
185
205
  }
186
206
  break;
187
207
  case "salla-modal":
208
+ if (!customElements.get(tagName)) {
209
+ defineCustomElement$4();
210
+ }
211
+ break;
212
+ case "salla-placeholder":
213
+ if (!customElements.get(tagName)) {
214
+ defineCustomElement$3();
215
+ }
216
+ break;
217
+ case "salla-skeleton":
188
218
  if (!customElements.get(tagName)) {
189
219
  defineCustomElement$2();
190
220
  }
@@ -17,21 +17,32 @@ const SallaProductSizeGuide$1 = /*@__PURE__*/ proxyCustomElement(class extends H
17
17
  constructor() {
18
18
  super();
19
19
  this.__registerHost();
20
+ this.hasError = false;
20
21
  Helper.setHost(document);
21
22
  salla.event.on('size-guide::open', (product_id) => this.open(product_id));
23
+ salla.lang.onLoaded(() => {
24
+ this.placeholder_title = salla.lang.get('pages.products.size_guide_placeholder');
25
+ this.placeholder_description = salla.lang.get('pages.products.size_guide_placeholder_info');
26
+ this.modal_title = salla.lang.get('pages.products.size_guides');
27
+ });
22
28
  }
23
29
  /**
24
30
  * Show the size-guide modal window
25
31
  */
26
32
  async open(product_id) {
27
- this.modal.setTitle(salla.lang.get('pages.products.size_guides'));
33
+ this.modal.setTitle(this.modal_title);
28
34
  this.modal.open();
29
- return await salla.product.getSizeGuides(product_id)
35
+ return await salla.api.withoutNotifier(salla.product.getSizeGuides(product_id)
30
36
  .then((response) => {
31
37
  this.guides = response.data;
32
38
  })
33
- .catch(e => console.log(e))
34
- .finally(() => this.modal.stopLoading());
39
+ .catch(e => {
40
+ var _a, _b, _c, _d;
41
+ console.log(e);
42
+ this.hasError = true;
43
+ this.placeholder_description = ((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || ((_d = e.response) === null || _d === void 0 ? void 0 : _d.data);
44
+ })
45
+ .finally(() => this.modal.stopLoading()));
35
46
  }
36
47
  /**
37
48
  *
@@ -42,10 +53,10 @@ const SallaProductSizeGuide$1 = /*@__PURE__*/ proxyCustomElement(class extends H
42
53
  }
43
54
  // !Todo - Enhance placeholder text
44
55
  showPlaceholder() {
45
- return h("salla-placeholder", { alignment: "center", iconSize: "xl" }, h("div", { slot: "title" }, salla.lang.get('pages.products.size_guide_placeholder')), h("div", { slot: "description" }, salla.lang.get('pages.products.size_guide_placeholder_info')));
56
+ return h("salla-placeholder", { alignment: "center", iconSize: "xl" }, h("div", { slot: "title" }, this.placeholder_title), h("div", { slot: "description" }, this.placeholder_description));
46
57
  }
47
58
  render() {
48
- return (h(Host, { class: "s-product-size-guide-block" }, h("salla-modal", { id: 'salla-product-size-guide-modal', isLoading: true, "has-skeleton": true, width: "md", ref: modal => this.modal = modal }, h("div", { slot: "loading" }, h("div", { class: "s-product-size-guide-skeleton" }, h("salla-skeleton", { height: '15px', width: '25%' }), h("div", { class: "s-product-size-guide-skeleton-header" }, h("salla-skeleton", { height: '40px' }), h("salla-skeleton", { height: '40px' }), h("salla-skeleton", { height: '40px' }), h("salla-skeleton", { height: '40px' })), h("div", { class: "s-product-size-guide-skeleton-content" }, h("salla-skeleton", { height: '15px', width: '25%' }), h("salla-skeleton", { height: '10px', width: '75%' }), h("salla-skeleton", { height: '10px', width: '50%' }), h("salla-skeleton", { height: '10px', width: '75%' }), h("salla-skeleton", { height: '10px', width: '100%' }), h("salla-skeleton", { height: '10px', width: '25%' }), h("salla-skeleton", { height: '10px', width: '60%' }), h("salla-skeleton", { height: '10px', width: '45%' }), h("salla-skeleton", { height: '10px', width: '30%' })))), h("slot", { name: "header" }), !!this.guides ?
59
+ return (h(Host, { class: "s-product-size-guide-block" }, h("salla-modal", { id: 'salla-product-size-guide-modal', isLoading: true, "has-skeleton": true, width: "md", ref: modal => this.modal = modal }, h("div", { slot: "loading" }, h("div", { class: "s-product-size-guide-skeleton" }, h("salla-skeleton", { height: '15px', width: '25%' }), h("div", { class: "s-product-size-guide-skeleton-header" }, h("salla-skeleton", { height: '40px' }), h("salla-skeleton", { height: '40px' }), h("salla-skeleton", { height: '40px' }), h("salla-skeleton", { height: '40px' })), h("div", { class: "s-product-size-guide-skeleton-content" }, h("salla-skeleton", { height: '15px', width: '25%' }), h("salla-skeleton", { height: '10px', width: '75%' }), h("salla-skeleton", { height: '10px', width: '50%' }), h("salla-skeleton", { height: '10px', width: '75%' }), h("salla-skeleton", { height: '10px', width: '100%' }), h("salla-skeleton", { height: '10px', width: '25%' }), h("salla-skeleton", { height: '10px', width: '60%' }), h("salla-skeleton", { height: '10px', width: '45%' }), h("salla-skeleton", { height: '10px', width: '30%' })))), h("slot", { name: "header" }), !this.hasError && !!this.guides ?
49
60
  [h("div", { class: "container px-8" }, h("salla-tabs", null, this.guides.map((guide) => h("salla-tab-header", { slot: "header", name: guide.name }, h("span", null, guide.name))), this.guides.map((guide) => h("salla-tab-content", { slot: "content", name: guide.name }, h("div", { innerHTML: guide.description })))))]
50
61
  : this.showPlaceholder(), h("slot", { name: "footer" }))));
51
62
  }
@@ -54,6 +65,10 @@ const SallaProductSizeGuide$1 = /*@__PURE__*/ proxyCustomElement(class extends H
54
65
  }, [4, "salla-product-size-guide", {
55
66
  "guides": [32],
56
67
  "productId": [32],
68
+ "placeholder_title": [32],
69
+ "placeholder_description": [32],
70
+ "modal_title": [32],
71
+ "hasError": [32],
57
72
  "open": [64],
58
73
  "close": [64]
59
74
  }]);
@@ -3,10 +3,18 @@
3
3
  */
4
4
  import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
5
5
  import { H as Helper } from './Helper.js';
6
- import { C as CheckCircle2, d as defineCustomElement$3 } from './salla-modal2.js';
7
- import { d as defineCustomElement$5 } from './salla-button2.js';
8
- import { d as defineCustomElement$4 } from './salla-loading2.js';
9
- import { d as defineCustomElement$2 } from './salla-rating-stars2.js';
6
+ import { C as CheckCircle2, d as defineCustomElement$4 } from './salla-modal2.js';
7
+ import { d as defineCustomElement$6 } from './salla-button2.js';
8
+ import { d as defineCustomElement$5 } from './salla-loading2.js';
9
+ import { d as defineCustomElement$3 } from './salla-rating-stars2.js';
10
+ import { d as defineCustomElement$2 } from './salla-skeleton2.js';
11
+
12
+ const Star = `<!-- Generated by IcoMoon.io -->
13
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
14
+ <title>star</title>
15
+ <path d="M31.819 12.077c-0.367-0.883-1.209-1.411-2.259-1.411h-8.437l-2.681-8.871c-0.347-1.075-1.329-1.796-2.443-1.796s-2.096 0.721-2.447 1.805l-2.788 8.861h-8.275c-1.076 0-1.939 0.533-2.308 1.427-0.375 0.904-0.159 2.012 0.525 2.693 0.044 0.044 0.092 0.085 0.141 0.124l6.811 5.101-2.773 8.567c-0.344 1.063 0.019 2.228 0.899 2.899 0.459 0.351 1.001 0.527 1.544 0.527 0.528 0 1.056-0.165 1.511-0.499l7.159-5.267 7.161 5.268c0.896 0.659 2.168 0.645 3.051-0.028 0.884-0.671 1.245-1.836 0.901-2.9l-2.773-8.567 6.811-5.101c0.051-0.037 0.099-0.080 0.143-0.124 0.687-0.687 0.904-1.8 0.528-2.709zM21.976 18.448c-0.456 0.343-0.644 0.936-0.469 1.477l3.044 9.293-7.763-5.711c-0.235-0.173-0.513-0.259-0.791-0.259s-0.556 0.085-0.791 0.259l-7.713 5.676 2.997-9.257c0.175-0.541-0.013-1.136-0.469-1.477l-6.829-5.116h8.551c0.583 0 1.097-0.377 1.272-0.933l2.981-9.479 2.861 9.465c0.169 0.561 0.688 0.947 1.276 0.947h8.672z"></path>
16
+ </svg>
17
+ `;
10
18
 
11
19
  const ShippingFast = `<!-- Generated by IcoMoon.io -->
12
20
  <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
@@ -21,6 +29,7 @@ const SallaRatingModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
21
29
  constructor() {
22
30
  super();
23
31
  this.__registerHost();
32
+ this.hasError = false;
24
33
  this.stepsCount = 0;
25
34
  this.currentIndex = 0;
26
35
  this.submitted = [];
@@ -39,12 +48,23 @@ const SallaRatingModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
39
48
  * Show the rating modal
40
49
  */
41
50
  async open() {
42
- return this.modal.open()
43
- .then(() => this.order || salla.rating.api.order(this.orderId).then(res => this.order = res.data))
44
- .then(() => this.modal.setTitle(salla.lang.get('pages.rating.rate_order') + ' <span class="unicode">(#' + this.order.id + ')</span>'))
45
- .then(() => this.modal.stopLoading())
46
- .then(() => this.stepsCount = [this.order.testimonials_enabled, this.order.products_enabled, this.order.shipping_enabled].filter(enabled => enabled).length)
47
- .then(() => setTimeout(() => this.handleWizard(), 100));
51
+ this.modal.open();
52
+ return await salla.api.withoutNotifier(salla.rating.api.order(this.orderId)
53
+ .then(res => this.order = res.data)
54
+ .catch(e => {
55
+ var _a, _b, _c, _d;
56
+ this.hasError = true;
57
+ this.errorMessage = ((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || ((_d = e.response) === null || _d === void 0 ? void 0 : _d.data);
58
+ })
59
+ .finally(() => {
60
+ var _a, _b, _c;
61
+ this.modal.setTitle(`${salla.lang.get('pages.rating.rate_order')} <span class="unicode">${!!this.order ? `(#${this.order.id})` : ''}</span>`);
62
+ this.stepsCount = [(_a = this.order) === null || _a === void 0 ? void 0 : _a.testimonials_enabled, (_b = this.order) === null || _b === void 0 ? void 0 : _b.products_enabled, (_c = this.order) === null || _c === void 0 ? void 0 : _c.shipping_enabled].filter(enabled => enabled).length;
63
+ setTimeout(() => this.handleWizard(), 100);
64
+ setTimeout(() => {
65
+ this.modal.stopLoading();
66
+ }, 1000);
67
+ }));
48
68
  }
49
69
  /**
50
70
  * Show the rating modal
@@ -59,7 +79,7 @@ const SallaRatingModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
59
79
  this.showActiveStep();
60
80
  }
61
81
  showActiveStep(current = null) {
62
- var _a;
82
+ var _a, _b;
63
83
  this.currentTab = current || this.steps[this.currentIndex];
64
84
  Helper.toggleClassIf('.s-rating-modal-step-dot', 's-rating-modal-bg-gray', 's-rating-modal-bg-primary', dot => dot != this.dots[this.currentIndex])
65
85
  .toggleClassIf('.s-rating-modal-step', 's-rating-modal-active', 's-rating-modal-hidden', tab => tab == this.currentTab);
@@ -70,9 +90,9 @@ const SallaRatingModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
70
90
  }
71
91
  // Btn text
72
92
  let nextType = (_a = this.steps[this.currentIndex + 1]) === null || _a === void 0 ? void 0 : _a.dataset.type;
73
- this.nextBtn.setText(nextType ? salla.lang.get('pages.rating.rate') + ' ' + salla.lang.get('pages.rating.' + nextType)
93
+ (_b = this.nextBtn) === null || _b === void 0 ? void 0 : _b.setText(nextType ? salla.lang.get('pages.rating.rate') + ' ' + salla.lang.get('pages.rating.' + nextType)
74
94
  : salla.lang.get('pages.rating.send_ratings'));
75
- setTimeout(() => { var _a; return this.body.setAttribute('style', 'height:' + ((_a = this.currentTab) === null || _a === void 0 ? void 0 : _a.scrollHeight) + 'px'); });
95
+ setTimeout(() => { var _a, _b; return (_a = this.body) === null || _a === void 0 ? void 0 : _a.setAttribute('style', 'height:' + ((_b = this.currentTab) === null || _b === void 0 ? void 0 : _b.scrollHeight) + 'px'); });
76
96
  }
77
97
  previousTab() {
78
98
  this.currentIndex > 0 && this.currentIndex--;
@@ -147,8 +167,9 @@ const SallaRatingModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
147
167
  this.showActiveStep(this.thanksTab);
148
168
  }
149
169
  render() {
150
- return (h(Host, { class: "s-rating" }, h("salla-modal", { isLoading: true, width: "md", ref: modal => this.modal = modal }, this.order
151
- ? [h("div", { class: "s-rating-modal-wrapper", ref: el => this.body = el }, this.order.testimonials_enabled ?
170
+ var _a;
171
+ return (h(Host, { class: "s-rating-modal" }, h("salla-modal", { isLoading: true, width: "md", ref: modal => this.modal = modal }, h("div", { slot: 'loading' }, h("div", { class: "s-rating-modal-skeleton" }, h("salla-skeleton", { type: 'circle', height: '80px', width: '80px' }), h("salla-skeleton", { height: '15px', width: '60%' }), h("salla-skeleton", { height: '10px', width: '30%' }), h("div", { class: "s-rating-modal-skeleton-stars" }, [...Array(5)].map(() => h("div", { innerHTML: Star }))), h("salla-skeleton", { height: '100px', width: '100%' }), h("div", { class: "s-rating-modal-skeleton-footer" }, h("salla-skeleton", { height: '40px', width: '30%' })))), !this.hasError && this.order
172
+ ? [h("div", { class: "s-rating-modal-wrapper", ref: el => this.body = el }, ((_a = this.order) === null || _a === void 0 ? void 0 : _a.testimonials_enabled) ?
152
173
  h("div", { class: "rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden", "data-type": "store" }, h("div", { class: "s-rating-modal-rounded-icon" }, h("img", { src: salla.config.get('store.logo', 'https://assets.salla.sa/cp/assets/images/logo-new.png'), alt: "store name", class: "s-rating-modal-store-logo" })), h("h2", { class: "s-rating-modal-title" }, salla.lang.get('pages.rating.rate_the_store')), h("div", { class: "s-rating-modal-stars-company" }, h("salla-rating-stars", { size: "large" })), h("textarea", { name: "comment", class: "s-rating-modal-comment", placeholder: salla.lang.get('pages.rating.write_store_rate') }), h("small", { class: "s-rating-modal-validation-msg" }))
153
174
  : '', this.order.products_enabled
154
175
  ? h("section", { class: "s-rating-modal-step s-rating-modal-hidden", "data-type": "products" }, this.order.products.map((item, index) => h("div", { class: "rating-outer-form s-rating-modal-product", "data-stars-error": salla.lang.get('pages.rating.rate_product_stars') }, h("div", { class: "s-rating-modal-product-img-wrap" }, h("img", { src: item.product.thumbnail, alt: item.product.name, class: "s-rating-modal-product-img" })), h("div", { class: "s-rating-modal-product-details" }, h("h3", { class: "s-rating-modal-product-title" }, " ", item.product.name), h("div", { class: "s-rating-modal-stars-product" }, h("salla-rating-stars", { size: "small", name: `products[${index}][rating]` })), h("input", { type: "hidden", name: `products[${index}][product_id]`, value: item.product.id }), h("textarea", { placeholder: salla.lang.get('pages.rating.write_product_rate'), name: `products[${index}][comment]`, class: "s-rating-modal-comment" }), h("small", { class: "s-rating-modal-validation-msg" })))))
@@ -167,6 +188,8 @@ const SallaRatingModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
167
188
  }, [0, "salla-rating-modal", {
168
189
  "orderId": [2, "order-id"],
169
190
  "order": [32],
191
+ "hasError": [32],
192
+ "errorMessage": [32],
170
193
  "translationLoaded": [32],
171
194
  "open": [64],
172
195
  "close": [64]
@@ -175,7 +198,7 @@ function defineCustomElement$1() {
175
198
  if (typeof customElements === "undefined") {
176
199
  return;
177
200
  }
178
- const components = ["salla-rating-modal", "salla-button", "salla-loading", "salla-modal", "salla-rating-stars"];
201
+ const components = ["salla-rating-modal", "salla-button", "salla-loading", "salla-modal", "salla-rating-stars", "salla-skeleton"];
179
202
  components.forEach(tagName => { switch (tagName) {
180
203
  case "salla-rating-modal":
181
204
  if (!customElements.get(tagName)) {
@@ -184,20 +207,25 @@ function defineCustomElement$1() {
184
207
  break;
185
208
  case "salla-button":
186
209
  if (!customElements.get(tagName)) {
187
- defineCustomElement$5();
210
+ defineCustomElement$6();
188
211
  }
189
212
  break;
190
213
  case "salla-loading":
191
214
  if (!customElements.get(tagName)) {
192
- defineCustomElement$4();
215
+ defineCustomElement$5();
193
216
  }
194
217
  break;
195
218
  case "salla-modal":
196
219
  if (!customElements.get(tagName)) {
197
- defineCustomElement$3();
220
+ defineCustomElement$4();
198
221
  }
199
222
  break;
200
223
  case "salla-rating-stars":
224
+ if (!customElements.get(tagName)) {
225
+ defineCustomElement$3();
226
+ }
227
+ break;
228
+ case "salla-skeleton":
201
229
  if (!customElements.get(tagName)) {
202
230
  defineCustomElement$2();
203
231
  }
@@ -34,6 +34,7 @@ const SallaScopees = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
34
34
  this.scopes = [];
35
35
  this.originalScopesList = [];
36
36
  this.isOpenedBefore = salla.storage.get("branch-choosed-before");
37
+ this.hasError = false;
37
38
  /**
38
39
  * Optionally open the modal or enforce the pop-up to the viewer
39
40
  */
@@ -75,9 +76,8 @@ const SallaScopees = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
75
76
  else {
76
77
  this.mode = ModeType.DEFAULT;
77
78
  }
78
- this.modal.loading();
79
79
  this.modal.open();
80
- return await (mode == ModeType.AVAILABILITY ? salla.scope.getProductAvailability(product_id) : salla.scope.get())
80
+ return await salla.api.withoutNotifier((mode == ModeType.AVAILABILITY ? salla.scope.getProductAvailability(product_id) : salla.scope.get())
81
81
  .then((resp) => {
82
82
  if (mode == ModeType.AVAILABILITY) {
83
83
  this.setScopeValues(resp.data);
@@ -85,10 +85,13 @@ const SallaScopees = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
85
85
  else {
86
86
  this.setScopeValues(resp.data.scopes);
87
87
  }
88
- }).catch(e => console.log(e))
88
+ }).catch(e => {
89
+ console.log(e);
90
+ this.hasError = true;
91
+ })
89
92
  .finally(() => {
90
93
  this.modal.stopLoading();
91
- });
94
+ }));
92
95
  }
93
96
  /**
94
97
  * Submit form to change exsiting scope.
@@ -153,8 +156,8 @@ const SallaScopees = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
153
156
  }
154
157
  render() {
155
158
  return (h(Host, null, h("salla-modal", { ref: modal => this.modal = modal, isClosable: !!(this.isOpenedBefore || (this.selection == 'optional')), class: "s-scopes-modal", isLoading: true, "has-skeleton": true }, h("div", { slot: "loading" }, h("div", { class: "s-scopes-skeleton" }, h("salla-list-tile", { class: "s-scopes-header" }, h("div", { slot: "icon", class: "s-scopes-header-icon" }, h("salla-skeleton", { type: "circle" })), h("div", { slot: "title", class: "s-scopes-header-title mb-5" }, h("salla-skeleton", { height: '15px', width: '50%' })), h("div", { slot: "subtitle", class: "s-scopes-header-subtitle" }, h("salla-skeleton", { height: '10px' }), h("salla-skeleton", { height: '10px', width: '75%' }))), h("div", { class: "s-scopes-skeleton-search" }, h("salla-skeleton", { height: '10px', width: '50%' }), h("salla-skeleton", { height: '30px', width: '100%' })), h("div", { class: "s-scopes-skeleton-scopes" }, h("salla-skeleton", { height: '10px', width: '30%' }), h("salla-skeleton", { height: '10px', width: '25%' }), h("salla-skeleton", { height: '10px', width: '30%' }), h("salla-skeleton", { height: '10px', width: '25%' }), h("salla-skeleton", { height: '10px', width: '30%' }), h("salla-skeleton", { height: '10px', width: '25%' }), h("salla-skeleton", { height: '10px', width: '30%' }), h("salla-skeleton", { height: '10px', width: '25%' })), h("div", { class: "s-scopes-skeleton-btn" }, h("salla-skeleton", { height: '40px', width: '100%' })))), h("salla-list-tile", { class: this.originalScopesList.length ? "s-scopes-header block" : "s-hidden" }, h("div", { slot: "icon", class: "s-scopes-header-icon", innerHTML: StoreAlt }), h("div", { slot: "title", class: "s-scopes-header-title" }, salla.lang.get('blocks.scope.you_are_browse_store_from')), h("div", { slot: "subtitle", class: "s-scopes-header-subtitle" }, !!this.selected_scope ? this.selected_scope.name : "")), h("div", { class: "s-scopes-wrap" }, !!this.originalScopesList.length && h("h4", { class: "s-scopes-title" }, this.getFormTitle()), this.originalScopesList.length > this.searchDisplayLimit ?
156
- h("div", { class: "s-scopes-search-wrapper" }, h("div", { class: "s-scopes-search-icon", innerHTML: Search }), h("input", { type: "text", class: "s-scopes-search-input", onInput: e => this.handleSearchFieldTyping(e), placeholder: salla.lang.get('blocks.scope.searching_for_a_branch') }))
157
- : "", this.scopes.length < 2 ?
159
+ h("div", { class: "s-scopes-search-wrapper" }, h("div", { class: "s-scopes-search-icon", innerHTML: Search }), h("input", { type: "text", class: "s-scopes-search-input", onInput: e => this.handleSearchFieldTyping(e), enterkeyhint: "search", placeholder: salla.lang.get('blocks.scope.searching_for_a_branch') }))
160
+ : "", this.hasError || this.scopes.length < 2 ?
158
161
  this.placeholderContent()
159
162
  : this.mode === ModeType.DEFAULT ? this.defaultContent() : this.availabilityContent()))));
160
163
  }
@@ -174,6 +177,7 @@ const SallaScopees = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
174
177
  "originalScopesList": [32],
175
178
  "selected_scope": [32],
176
179
  "isOpenedBefore": [32],
180
+ "hasError": [32],
177
181
  "close": [64],
178
182
  "open": [64],
179
183
  "handleSubmit": [64]
@@ -100,7 +100,7 @@ const SallaSearch$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
100
100
  }
101
101
  render() {
102
102
  var _a;
103
- const searchContent = h("div", { class: { 's-search-container': true, 's-search-inline': this.inline }, ref: container => this.container = container }, h("input", { type: "text", autocomplete: "off", class: "s-search-input", placeholder: salla.lang.get('blocks.header.search_placeholder'), onInput: e => this.debounceSearch(e), onKeyDown: e => this.handleKeyDown(e), ref: input => this.searchInput = input, style: { height: this.height + 'px', borderRadius: this.oval ? this.height / 2 + 'px' : '' } }), h("span", { class: "s-search-icon-wrap" }, h("span", { class: "s-search-icon", innerHTML: this.loading ? '<i class="s-search-spinner-loader"></i>' : Search })), h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
103
+ const searchContent = h("div", { class: { 's-search-container': true, 's-search-inline': this.inline }, ref: container => this.container = container }, h("input", { type: "search", enterkeyhint: "search", autocomplete: "off", class: "s-search-input", placeholder: salla.lang.get('blocks.header.search_placeholder'), onInput: e => this.debounceSearch(e), onKeyDown: e => this.handleKeyDown(e), ref: input => this.searchInput = input, style: { height: this.height + 'px', borderRadius: this.oval ? this.height / 2 + 'px' : '' } }), h("span", { class: "s-search-icon-wrap" }, h("span", { class: "s-search-icon", innerHTML: this.loading ? '<i class="s-search-spinner-loader"></i>' : Search })), h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
104
104
  _a.data.map(item => h("a", { href: item.url, class: { "s-search-product": true, 's-search-product-not-available': !item.is_available }, innerHTML: this.productSlot
105
105
  .replace(/\{name\}/g, item.name)
106
106
  .replace(/\{price\}/g, salla.money(item.price))
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface SallaSelect extends Components.SallaSelect, HTMLElement {}
4
+ export const SallaSelect: {
5
+ prototype: SallaSelect;
6
+ new (): SallaSelect;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,199 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
5
+
6
+ const sallaSelectCss = ".s-select-label{display:block;margin-bottom:0.5rem;color:#111827;font-size:0.875rem;line-height:1.25rem;font-weight:500}.s-select-underline{display:block;padding-left:0;padding-right:0;padding-top:0.625rem;padding-bottom:0.625rem;background-color:transparent;color:#6B7280;font-size:0.875rem;line-height:1.25rem;width:100%;border-width:0;border-bottom-width:2px;border-color:#E5E7EB;appearance:none}.s-select-outlined{display:block;padding:0.625rem;padding-top:0.75rem;padding-bottom:0.75rem;padding-left:1rem;padding-right:1rem;background-color:#F9FAFB;color:#111827;font-size:0.875rem;line-height:1.25rem;width:100%;border-radius:0.5rem;border-width:1px;border-color:#D1D5DB}.s-select-x-large{height:5rem}.s-select-large{height:4rem}.s-select-normal{height:3rem}.s-select-small{height:3rem}.s-select-x-small{height:2.5rem}.s-select-field{padding-top:0.25rem;padding-bottom:0.25rem;padding-right:0.5rem;padding-left:0.5rem;margin:0;font-size:1.125rem;line-height:1.75rem;font-weight:400;line-height:1.75rem;width:100%;border-radius:0.375rem;border-color:#9CA3AF;box-shadow:none}.s-select-hint{margin-top:0.25rem;color:#374151;font-size:0.875rem;line-height:1.25rem;line-height:1.25rem}";
7
+
8
+ const SallaSelect$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
9
+ constructor() {
10
+ super();
11
+ this.__registerHost();
12
+ /**
13
+ * Sets label
14
+ */
15
+ this.label = undefined;
16
+ /**
17
+ * Can be an array of objects or array of strings.
18
+ * When using objects, will look for a text, value and disabled keys.
19
+ */
20
+ this.items = [];
21
+ /**
22
+ * Set property of items’s text value
23
+ */
24
+ this.itemText = "text";
25
+ /**
26
+ * Set property of items’s value - must be primitive.
27
+ * Dot notation is supported.
28
+ */
29
+ this.itemValue = "value";
30
+ /**
31
+ * Set property of items’s disabled value
32
+ */
33
+ this.itemDisabled = 'disabled';
34
+ /**
35
+ * Sizing options
36
+ */
37
+ this.size = 'normal';
38
+ /**
39
+ * The selected value
40
+ */
41
+ this.value = undefined;
42
+ /**
43
+ * Enable autofocus
44
+ */
45
+ this.autofocus = false;
46
+ /**
47
+ * Add input clear functionality, default icon is `sicon-cancel`
48
+ */
49
+ this.clearable = false;
50
+ /**
51
+ * Applied when using clearable and the input is dirty
52
+ */
53
+ this.clearIcon = 'sicon-cancel';
54
+ /**
55
+ * Applies specified color to the control.
56
+ */
57
+ this.color = 'primary';
58
+ /**
59
+ * Remove elevation or box shadow.
60
+ */
61
+ this.flat = undefined;
62
+ /**
63
+ * Disable the input
64
+ */
65
+ this.disabled = false;
66
+ /**
67
+ * Displays linear progress bar.
68
+ */
69
+ this.loading = false;
70
+ /**
71
+ * Specifies which color is applied to the progress bar.
72
+ */
73
+ this.loadingColor = 'primary';
74
+ /**
75
+ * Hint text
76
+ */
77
+ this.hint = undefined;
78
+ /**
79
+ * Forces hint to always be visible.
80
+ */
81
+ this.persistHint = false;
82
+ /**
83
+ * Sets the input’s placeholder text.
84
+ */
85
+ this.placeholder = undefined;
86
+ /**
87
+ * Enable multiple item selection
88
+ */
89
+ this.multiple = false;
90
+ /**
91
+ * Enable multiple item selection
92
+ */
93
+ this.autocomplete = false;
94
+ /**
95
+ * Enable multiple item selection
96
+ */
97
+ this.required = false;
98
+ /**
99
+ * Changes display of selections to chips
100
+ */
101
+ this.chips = false;
102
+ /**
103
+ * Define appearance of the component
104
+ */
105
+ this.shape = 'outlined';
106
+ /**
107
+ * Changes the selection behavior to return the object directly
108
+ * rather than the value specified with item-value
109
+ */
110
+ this.returnObject = false;
111
+ /**
112
+ * Hides hint if any
113
+ */
114
+ this.hideDetail = false;
115
+ }
116
+ selectClass() {
117
+ return `s-select-field s-select-${this.shape} ${this.color} ${this.size}`;
118
+ }
119
+ onSelectedItemChange(event) {
120
+ let selectedIndex = event.target.selectedIndex;
121
+ if (selectedIndex < 0) {
122
+ this.value = undefined;
123
+ return;
124
+ }
125
+ let selectedItem = this.items[!!this.placeholder ? selectedIndex - 1 : selectedIndex];
126
+ this.value = this.returnObject ? selectedItem : selectedItem[this.itemValue];
127
+ console.log("🚀 ~ file: salla-select.tsx ~ line 153 ~ SallaSelect ~ onSelectedItemChange ~ this.value", this.value);
128
+ }
129
+ generateHint() {
130
+ if (!this.persistHint && !this.value) {
131
+ return "";
132
+ }
133
+ return h("div", { class: "s-select-hint" }, this.hint);
134
+ }
135
+ checkForSelected(item) {
136
+ if (this.returnObject && !!this.value) {
137
+ return item[this.itemValue] = this.value[this.itemValue];
138
+ }
139
+ return item[this.itemValue] == this.value;
140
+ }
141
+ render() {
142
+ return (h(Host, null, !!this.label ?
143
+ h("label", { htmlFor: "s-select", class: "s-select-label" }, this.label)
144
+ : "", h("select", { multiple: this.multiple, autocomplete: this.autocomplete ? 'on' : 'off', disabled: this.disabled, autoFocus: this.autofocus, id: "s-select", class: this.selectClass(), onChange: this.onSelectedItemChange.bind(this) }, !!this.placeholder ?
145
+ h("option", { selected: !this.value }, this.placeholder)
146
+ : "", this.items.map((item) =>
147
+ // item instanceof Object ?
148
+ h("option", { label: item[this.itemText], value: item[this.itemValue], selected: this.checkForSelected(item), disabled: item[this.itemDisabled] })
149
+ // :
150
+ // <option label={item} value={item} selected={item == this.value} disabled={item == this.itemDisabled}></option>
151
+ )), h("div", { class: { "s-hidden": this.hideDetail } }, this.generateHint())));
152
+ }
153
+ static get style() { return sallaSelectCss; }
154
+ }, [0, "salla-select", {
155
+ "label": [1],
156
+ "items": [16],
157
+ "itemText": [1, "item-text"],
158
+ "itemValue": [1, "item-value"],
159
+ "itemDisabled": [1, "item-disabled"],
160
+ "size": [1],
161
+ "value": [1032],
162
+ "autofocus": [4],
163
+ "clearable": [4],
164
+ "clearIcon": [1, "clear-icon"],
165
+ "color": [1],
166
+ "flat": [4],
167
+ "disabled": [4],
168
+ "loading": [4],
169
+ "loadingColor": [1, "loading-color"],
170
+ "hint": [1],
171
+ "persistHint": [4, "persist-hint"],
172
+ "placeholder": [1],
173
+ "multiple": [4],
174
+ "autocomplete": [4],
175
+ "required": [4],
176
+ "chips": [4],
177
+ "shape": [1],
178
+ "returnObject": [4, "return-object"],
179
+ "hideDetail": [4, "hide-detail"]
180
+ }]);
181
+ function defineCustomElement$1() {
182
+ if (typeof customElements === "undefined") {
183
+ return;
184
+ }
185
+ const components = ["salla-select"];
186
+ components.forEach(tagName => { switch (tagName) {
187
+ case "salla-select":
188
+ if (!customElements.get(tagName)) {
189
+ customElements.define(tagName, SallaSelect$1);
190
+ }
191
+ break;
192
+ } });
193
+ }
194
+ defineCustomElement$1();
195
+
196
+ const SallaSelect = SallaSelect$1;
197
+ const defineCustomElement = defineCustomElement$1;
198
+
199
+ export { SallaSelect, defineCustomElement };