@salla.sa/twilight-components 2.11.48 → 2.11.50

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 (76) hide show
  1. package/dist/cjs/index-1d2b3370.js +4 -0
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/salla-add-product-button.cjs.entry.js +4 -13
  4. package/dist/cjs/salla-button_36.cjs.entry.js +94 -27
  5. package/dist/cjs/salla-comment-form.cjs.entry.js +43 -0
  6. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  7. package/dist/cjs/salla-product-options.cjs.entry.js +64 -16
  8. package/dist/cjs/twilight.cjs.js +1 -1
  9. package/dist/collection/collection-manifest.json +1 -0
  10. package/dist/collection/components/salla-add-product-button/salla-add-product-button.js +4 -13
  11. package/dist/collection/components/salla-cart-summary/salla-cart-summary.js +26 -3
  12. package/dist/collection/components/salla-count-down/salla-count-down.css +0 -0
  13. package/dist/collection/components/salla-count-down/salla-count-down.js +253 -0
  14. package/dist/collection/components/salla-datetime-picker/salla-datetime-picker.js +1 -1
  15. package/dist/collection/components/salla-gifting/salla-gifting.js +8 -1
  16. package/dist/collection/components/salla-installment/salla-installment.css +4 -0
  17. package/dist/collection/components/salla-login-modal/salla-login-modal.js +4 -3
  18. package/dist/collection/components/salla-modal/salla-modal.js +10 -0
  19. package/dist/collection/components/salla-product-options/salla-product-options.js +86 -20
  20. package/dist/collection/components/salla-scopes/salla-scopes.js +1 -1
  21. package/dist/components/index.d.ts +1 -0
  22. package/dist/components/index.js +1 -0
  23. package/dist/components/salla-add-product-button.js +4 -13
  24. package/dist/components/salla-cart-summary.js +4 -1
  25. package/dist/components/salla-count-down.d.ts +11 -0
  26. package/dist/components/salla-count-down.js +122 -0
  27. package/dist/components/salla-gifting.js +8 -1
  28. package/dist/components/salla-installment.js +1 -1
  29. package/dist/components/salla-login-modal.js +4 -3
  30. package/dist/components/salla-modal2.js +10 -0
  31. package/dist/components/salla-product-options.js +67 -16
  32. package/dist/components/salla-scopes.js +1 -1
  33. package/dist/esm/index-f1d446ac.js +4 -0
  34. package/dist/esm/loader.js +1 -1
  35. package/dist/esm/salla-add-product-button.entry.js +4 -13
  36. package/dist/esm/salla-button_36.entry.js +94 -27
  37. package/dist/esm/salla-comment-form.entry.js +39 -0
  38. package/dist/esm/salla-installment.entry.js +1 -1
  39. package/dist/esm/salla-product-options.entry.js +64 -16
  40. package/dist/esm/twilight.js +1 -1
  41. package/dist/esm-es5/index-f1d446ac.js +1 -1
  42. package/dist/esm-es5/loader.js +1 -1
  43. package/dist/esm-es5/salla-add-product-button.entry.js +2 -2
  44. package/dist/esm-es5/salla-button_36.entry.js +3 -3
  45. package/dist/esm-es5/salla-comment-form.entry.js +4 -0
  46. package/dist/esm-es5/salla-installment.entry.js +1 -1
  47. package/dist/esm-es5/salla-product-options.entry.js +2 -2
  48. package/dist/esm-es5/twilight.js +1 -1
  49. package/dist/twilight/{p-a6821ab8.system.entry.js → p-295d0d13.entry.js} +1 -1
  50. package/dist/twilight/p-4192bf33.system.entry.js +4 -0
  51. package/dist/twilight/p-7d966812.entry.js +4 -0
  52. package/dist/twilight/p-9fda3312.system.js +1 -1
  53. package/dist/twilight/p-b540cfc6.system.entry.js +4 -0
  54. package/dist/twilight/p-c537eb89.system.entry.js +53 -0
  55. package/dist/twilight/p-cdb6aa9e.entry.js +4 -0
  56. package/dist/twilight/p-d9579b04.system.entry.js +4 -0
  57. package/dist/twilight/p-e0a12040.entry.js +4 -0
  58. package/dist/twilight/p-fb2533e0.entry.js +36 -0
  59. package/dist/twilight/p-fb863c38.system.entry.js +4 -0
  60. package/dist/twilight/twilight.esm.js +1 -1
  61. package/dist/types/components/salla-add-product-button/salla-add-product-button.d.ts +0 -1
  62. package/dist/types/components/salla-cart-summary/salla-cart-summary.d.ts +5 -0
  63. package/dist/types/components/salla-count-down/salla-count-down.d.ts +53 -0
  64. package/dist/types/components/salla-gifting/salla-gifting.d.ts +1 -0
  65. package/dist/types/components/salla-modal/salla-modal.d.ts +1 -0
  66. package/dist/types/components/salla-product-options/interfaces.d.ts +4 -0
  67. package/dist/types/components/salla-product-options/salla-product-options.d.ts +14 -1
  68. package/dist/types/components.d.ts +85 -0
  69. package/package.json +3 -3
  70. package/dist/twilight/p-14fd987d.system.entry.js +0 -53
  71. package/dist/twilight/p-3c98b71d.entry.js +0 -4
  72. package/dist/twilight/p-7e9e675f.entry.js +0 -4
  73. package/dist/twilight/p-85c55961.system.entry.js +0 -4
  74. package/dist/twilight/p-984370cd.entry.js +0 -4
  75. package/dist/twilight/p-d2c63efe.entry.js +0 -36
  76. package/dist/twilight/p-e22d9712.system.entry.js +0 -4
@@ -16,37 +16,46 @@ export class SallaProductOptions {
16
16
  exl: 'application/excel,application/vnd.ms-excel,application/x-excel,application/x-msexcel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
17
17
  txt: 'text/plain',
18
18
  };
19
- this.outOfStockText = salla.lang.get("pages.products.out_of_stock");
19
+ this.outOfStockText = '';
20
20
  this.donationAmount = salla.lang.get('pages.products.donation_amount');
21
21
  this.selectedOptions = [];
22
+ this.outSkus = [];
22
23
  /**
23
24
  * The id of the product to which the options are going to be fetched for.
24
25
  */
25
26
  this.productId = salla.config.get('page.id');
26
- this.canDisabled = !salla.config.get('store.settings.products.notify_options_availability');
27
+ this.canDisabled = salla.config.get('store.settings.products.notify_options_availability');
27
28
  salla.lang.onLoaded(() => {
28
29
  this.outOfStockText = salla.lang.get("pages.products.out_of_stock");
29
30
  this.donationAmount = salla.lang.get('pages.products.donation_amount');
30
31
  });
31
32
  if (this.options) {
32
33
  try {
33
- this.optionsData = JSON.parse(this.options);
34
+ this.setOptionsData(JSON.parse(this.options));
34
35
  return;
35
36
  }
36
37
  catch (e) {
37
38
  salla.log('Bad json passed via options prop');
38
39
  }
39
40
  }
40
- if (Array.isArray(this.optionsData)) {
41
+ if (!Array.isArray(this.optionsData)) {
41
42
  salla.log('Options is not an array[] ---> ', this.optionsData);
42
- this.optionsData = [];
43
+ this.setOptionsData([]);
43
44
  }
44
45
  if (this.productId && !salla.url.is_page('cart')) {
45
- salla.api.product.getDetails(this.productId, ['options']).then((resp) => {
46
- this.optionsData = resp.data.options;
47
- });
46
+ salla.api.product.getDetails(this.productId, ['options']).then(resp => this.setOptionsData(resp.data.options));
48
47
  }
49
48
  }
49
+ setOptionsData(optionsData) {
50
+ var _a, _b;
51
+ this.optionsData = optionsData;
52
+ let that = this;
53
+ (_b = (_a = this.optionsData[0]) === null || _a === void 0 ? void 0 : _a.details) === null || _b === void 0 ? void 0 : _b.forEach(function (detail) {
54
+ Object.entries(detail.skus_availability || {})
55
+ .filter(sku => !sku[1])
56
+ .map(sku => that.outSkus.push(Number(sku[0])));
57
+ });
58
+ }
50
59
  /**
51
60
  * Get the id's of the selected options.
52
61
  * */
@@ -58,6 +67,12 @@ export class SallaProductOptions {
58
67
  });
59
68
  return selectedOptions;
60
69
  }
70
+ /**
71
+ * Return true if there is any out of stock options are selected and vise versa.
72
+ * */
73
+ async hasOutOfStockOption() {
74
+ return this.selectedOptions.some(option => option.is_out) || (this.selectedSkus.length && this.selectedSkus.every(sku => this.outSkus.includes(sku)));
75
+ }
61
76
  /**
62
77
  * Get selected options.
63
78
  * */
@@ -80,10 +95,19 @@ export class SallaProductOptions {
80
95
  }
81
96
  const index = this.selectedOptions.findIndex(option => option.option_id === data.option.id);
82
97
  index > -1 ? this.selectedOptions[index] = Object.assign(Object.assign({}, data.detail), { option_id: data.option.id }) : this.selectedOptions.push(Object.assign(Object.assign({}, data.detail), { option_id: data.option.id }));
98
+ this.setSelectedSkus();
83
99
  this.handleRequiredMultipleOptions(option);
84
100
  this.changed.emit(data);
85
101
  salla.event.emit('product-options::change', data);
86
102
  }
103
+ /**
104
+ * loop throw all selected details, then get common sku, if it's only one, means we selected all of them;
105
+ */
106
+ setSelectedSkus() {
107
+ this.selectedSkus = this.selectedOptions.map(detail => Object.keys(detail.skus_availability || {}))
108
+ .reduce((p, c) => p.filter(e => c.includes(e)))
109
+ .map(sku => Number(sku));
110
+ }
87
111
  handleRequiredMultipleOptions(option) {
88
112
  if (option.type !== DisplayType.MULTIPLE_OPTIONS || !option.required) {
89
113
  return;
@@ -147,7 +171,7 @@ export class SallaProductOptions {
147
171
  h("salla-progress-bar", { donation: option.donation }))
148
172
  : '',
149
173
  h("div", { class: "s-product-options-donation-input-group" },
150
- h("input", { type: "text", id: "donating-amount", name: "donating_amount", class: "s-form-control", value: option.value, placeholder: option.placeholder, onInput: e => salla.helpers.inputDigitsOnly(e.target), onBlur: e => this.changedHandler(e, option) }),
174
+ h("input", { type: "text", id: "donating-amount", name: "donating_amount", class: "s-form-control", value: option.value, required: true, placeholder: option.placeholder, onInput: e => salla.helpers.inputDigitsOnly(e.target), onBlur: e => this.changedHandler(e, option) }),
151
175
  h("span", { class: "s-product-options-donation-amount-currency" }, salla.config.currency(salla.config.get('user.currency_code')).symbol)));
152
176
  }
153
177
  fileUploader(option, additions = null) {
@@ -208,7 +232,7 @@ export class SallaProductOptions {
208
232
  dateOption(option) {
209
233
  //todo:: consider date-range @see https://github.com/SallaApp/theme-raed/blob/master/src/assets/js/partials/product-options.js#L8-L23
210
234
  return h("div", { class: "s-product-options-date-element" },
211
- h("salla-datetime-picker", { value: option.value, placeholder: option.name, required: option.required, name: `options[${option.id}]`, onPicked: e => this.changedHandler(e, option) }));
235
+ h("salla-datetime-picker", { value: option.value, placeholder: option.name, required: option.required, minDate: new Date(), name: `options[${option.id}]`, onPicked: e => this.changedHandler(e, option) }));
212
236
  }
213
237
  //@ts-ignore
214
238
  datetimeOption(option) {
@@ -219,43 +243,67 @@ export class SallaProductOptions {
219
243
  /**
220
244
  * ============= Advanced options =============
221
245
  */
222
- getOptionDetailName(detail, outOfStock = true) {
246
+ // <<<<<<< HEAD
247
+ getOptionDetailName(detail, outOfStock = true, optionType) {
248
+ if (optionType && optionType == DisplayType.COLOR) {
249
+ return detail.name
250
+ + ((outOfStock && this.isOptionDetailOut(detail)) ? ` <br/> <p> ${this.outOfStockText} </p>` : '')
251
+ + (detail.additional_price ? ` <p> (${salla.money(detail.additional_price)}) </p>` : '');
252
+ }
223
253
  return detail.name
224
- + ((outOfStock && detail.is_out) ? ` - ${this.outOfStockText}` : '')
254
+ + ((outOfStock && this.isOptionDetailOut(detail)) ? ` - ${this.outOfStockText}` : '')
225
255
  + (detail.additional_price ? ` (${salla.money(detail.additional_price)})` : '');
226
256
  }
257
+ isOptionDetailOut(detail) {
258
+ var _a;
259
+ if (detail.is_out || !detail.skus_availability || !((_a = this.selectedSkus) === null || _a === void 0 ? void 0 : _a.length)) {
260
+ return detail.is_out;
261
+ }
262
+ let isDetailSelected = this.selectedOptions.filter(option => option.id == detail.id).length;
263
+ //if the current options is the only selected option, so we are sure that it's not out, because there is no other options selected yet
264
+ if (isDetailSelected && this.selectedOptions.length == 1) {
265
+ return false;
266
+ }
267
+ //if current details has sku in the possible outSkus it's out for sure
268
+ if (isDetailSelected) {
269
+ //here we will get the possible outSkus for current selected options
270
+ let outSelectableSkus = this.selectedSkus.filter(sku => this.outSkus.includes(sku));
271
+ return Object.keys(detail.skus_availability).some(sku => outSelectableSkus.includes(Number(sku)));
272
+ }
273
+ return this.selectedOptions.some(option => option.is_out && option.option_id !== detail.option_id);
274
+ }
227
275
  singleOption(option) {
228
276
  return h("div", null,
229
277
  h("select", { name: `options[${option.id}]`, required: option.required, class: "s-form-control", onChange: e => this.changedHandler(e, option) },
230
278
  h("option", { value: "" }, option.placeholder), option === null || option === void 0 ? void 0 :
231
279
  option.details.map((detail) => {
232
- return h("option", { value: detail.id, disabled: this.canDisabled && detail.is_out, selected: detail.is_selected }, this.getOptionDetailName(detail));
280
+ return h("option", { value: detail.id, disabled: this.canDisabled && this.isOptionDetailOut(detail), selected: detail.is_selected }, this.getOptionDetailName(detail));
233
281
  })));
234
282
  }
235
283
  multipleOptions(option) {
236
284
  return h("div", { class: { "s-product-options-multiple-options-wrapper": true, 'required': option.required } }, option === null || option === void 0 ? void 0 : option.details.map((detail) => {
237
285
  return h("div", null,
238
- h("input", { type: "checkbox", value: detail.id, disabled: detail.is_out, checked: detail.is_selected, required: option.required, name: `options[${option.id}][]`, id: `field-${option.id}-${detail.id}`, onChange: (e) => this.changedHandler(e, option), "aria-describedby": `options[${option.id}]-description` }),
286
+ h("input", { type: "checkbox", value: detail.id, disabled: this.isOptionDetailOut(detail), checked: detail.is_selected, required: option.required, name: `options[${option.id}][]`, id: `field-${option.id}-${detail.id}`, onChange: (e) => this.changedHandler(e, option), "aria-describedby": `options[${option.id}]-description` }),
239
287
  h("label", { htmlFor: `field-${option.id}-${detail.id}` }, this.getOptionDetailName(detail)));
240
288
  }));
241
289
  }
242
290
  //@ts-ignore
243
291
  colorOption(option) {
244
- return h("fieldset", { class: "s-product-options-colors-wrapper" }, option === null || option === void 0 ? void 0 : option.details.map((detail) => h("div", null,
245
- h("input", { type: "radio", value: detail.id, required: option.required, checked: detail.is_selected, name: `options[${option.id}]`, disabled: this.canDisabled && detail.is_out, id: `color-${this.productId}-${option.id}-${detail.id}`, onChange: e => this.changedHandler(e, option) }),
292
+ return h("fieldset", { class: "s-product-options-colors-wrapper" }, option === null || option === void 0 ? void 0 : option.details.map((detail) => h("div", { class: "s-product-options-colors-item" },
293
+ h("input", { type: "radio", value: detail.id, required: option.required, checked: detail.is_selected, name: `options[${option.id}]`, disabled: this.canDisabled && this.isOptionDetailOut(detail), id: `color-${this.productId}-${option.id}-${detail.id}`, onChange: e => this.changedHandler(e, option) }),
246
294
  h("label", { htmlFor: `color-${this.productId}-${option.id}-${detail.id}` },
247
295
  h("span", { style: { "background-color": detail.color } }),
248
- h("p", null, this.getOptionDetailName(detail))))));
296
+ h("div", { innerHTML: this.getOptionDetailName(detail, true, option.type) })))));
249
297
  }
250
298
  //@ts-ignore
251
299
  thumbnailOption(option) {
252
300
  return h("div", { class: "s-product-options-thumbnails-wrapper" }, option.details.map((detail) => {
253
301
  return h("div", null,
254
- h("input", { type: "radio", value: detail.id, "data-itemid": detail.id, required: option.required, checked: detail.is_selected, name: `options[${option.id}]`, "data-img-id": detail.option_value, disabled: this.canDisabled && detail.is_out, id: `option_${this.productId}-${option.id}_${detail.id}`, onChange: (e) => this.changedHandler(e, option) }),
302
+ h("input", { type: "radio", value: detail.id, "data-itemid": detail.id, required: option.required, checked: detail.is_selected, name: `options[${option.id}]`, "data-img-id": detail.option_value, disabled: this.canDisabled && this.isOptionDetailOut(detail), id: `option_${this.productId}-${option.id}_${detail.id}`, onChange: (e) => this.changedHandler(e, option) }),
255
303
  h("label", { htmlFor: `option_${this.productId}-${option.id}_${detail.id}`, "data-img-id": detail.option_value, class: "go-to-slide" },
256
304
  h("img", { "data-src": detail.image, src: detail.image, title: detail.name, alt: detail.name }),
257
305
  h("span", { innerHTML: CheckCircleIcon, class: "s-product-options-thumbnails-icon" }),
258
- detail.is_out ?
306
+ this.isOptionDetailOut(detail) ?
259
307
  [
260
308
  h("small", { class: "s-product-options-thumbnails-stock-badge" }, this.outOfStockText),
261
309
  this.canDisabled ? h("div", { class: "s-product-options-thumbnails-badge-overlay" }) : '',
@@ -315,7 +363,9 @@ export class SallaProductOptions {
315
363
  "outOfStockText": {},
316
364
  "donationAmount": {},
317
365
  "selectedOptions": {},
318
- "canDisabled": {}
366
+ "canDisabled": {},
367
+ "selectedSkus": {},
368
+ "selectedOutSkus": {}
319
369
  }; }
320
370
  static get events() { return [{
321
371
  "method": "changed",
@@ -350,6 +400,22 @@ export class SallaProductOptions {
350
400
  "tags": []
351
401
  }
352
402
  },
403
+ "hasOutOfStockOption": {
404
+ "complexType": {
405
+ "signature": "() => Promise<boolean>",
406
+ "parameters": [],
407
+ "references": {
408
+ "Promise": {
409
+ "location": "global"
410
+ }
411
+ },
412
+ "return": "Promise<boolean>"
413
+ },
414
+ "docs": {
415
+ "text": "Return true if there is any out of stock options are selected and vise versa.",
416
+ "tags": []
417
+ }
418
+ },
353
419
  "getSelectedOptions": {
354
420
  "complexType": {
355
421
  "signature": "() => Promise<any[]>",
@@ -192,7 +192,7 @@ export class SallaScopees {
192
192
  h("div", { class: "s-scopes-search-icon", innerHTML: Search }),
193
193
  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') }))
194
194
  : "",
195
- this.hasError || ((_d = this.scopes) === null || _d === void 0 ? void 0 : _d.length) < 2 ?
195
+ this.hasError || ((_d = this.originalScopesList) === null || _d === void 0 ? void 0 : _d.length) < 2 ?
196
196
  this.placeholderContent()
197
197
  : this.mode === ModeType.DEFAULT ? this.defaultContent() : this.availabilityContent())])));
198
198
  }
@@ -5,6 +5,7 @@ export { SallaCartSummary as SallaCartSummary } from '../types/components/salla-
5
5
  export { SallaColorPicker as SallaColorPicker } from '../types/components/salla-color-picker/salla-color-picker';
6
6
  export { SallaCommentForm as SallaCommentForm } from '../types/components/salla-comment-form/salla-comment-form';
7
7
  export { SallaConditionalFields as SallaConditionalFields } from '../types/components/salla-conditional-fields/salla-conditional-fields';
8
+ export { SallaCountDown as SallaCountDown } from '../types/components/salla-count-down/salla-count-down';
8
9
  export { SallaDatetimePicker as SallaDatetimePicker } from '../types/components/salla-datetime-picker/salla-datetime-picker';
9
10
  export { SallaFileUpload as SallaFileUpload } from '../types/components/salla-file-upload/salla-file-upload';
10
11
  export { SallaGifting as SallaGifting } from '../types/components/salla-gifting/salla-gifting';
@@ -9,6 +9,7 @@ export { SallaCartSummary, defineCustomElement as defineCustomElementSallaCartSu
9
9
  export { SallaColorPicker, defineCustomElement as defineCustomElementSallaColorPicker } from './salla-color-picker.js';
10
10
  export { SallaCommentForm, defineCustomElement as defineCustomElementSallaCommentForm } from './salla-comment-form.js';
11
11
  export { SallaConditionalFields, defineCustomElement as defineCustomElementSallaConditionalFields } from './salla-conditional-fields.js';
12
+ export { SallaCountDown, defineCustomElement as defineCustomElementSallaCountDown } from './salla-count-down.js';
12
13
  export { SallaDatetimePicker, defineCustomElement as defineCustomElementSallaDatetimePicker } from './salla-datetime-picker.js';
13
14
  export { SallaFileUpload, defineCustomElement as defineCustomElementSallaFileUpload } from './salla-file-upload.js';
14
15
  export { SallaGifting, defineCustomElement as defineCustomElementSallaGifting } from './salla-gifting.js';
@@ -83,16 +83,6 @@ const SallaAddProductButton$1 = /*@__PURE__*/ proxyCustomElement(class extends H
83
83
  }
84
84
  return this.hostAttributes;
85
85
  }
86
- pushSelectedOption(data) {
87
- const index = this.selectedOptions.findIndex(option => option.option_id === data.option.id);
88
- if (index > -1) {
89
- this.selectedOptions[index] = Object.assign(Object.assign({}, data.detail), { option_id: data.option.id });
90
- }
91
- else {
92
- this.selectedOptions.push(Object.assign(Object.assign({}, data.detail), { option_id: data.option.id }));
93
- }
94
- this.hasOutOfStockOption = this.selectedOptions.some(option => option.is_out);
95
- }
96
86
  componentWillLoad() {
97
87
  this.hasLabel = !!this.host.innerHTML.replace('<!---->', '').trim();
98
88
  }
@@ -108,17 +98,18 @@ const SallaAddProductButton$1 = /*@__PURE__*/ proxyCustomElement(class extends H
108
98
  if ((this.productStatus === 'out-and-notify' && this.channels) || this.hasOutOfStockOption) {
109
99
  return h(Host, null, h("salla-product-availability", Object.assign({}, this.getBtnAttributes())));
110
100
  }
111
- return h(Host, null, h("salla-button", Object.assign({ color: this.productStatus === 'sale' ? 'primary' : 'light', fill: this.productStatus === 'sale' ? 'solid' : 'outline', ref: el => this.btn = el, onClick: event => this.addProductToCart(event), disabled: this.productStatus !== 'sale' }, this.getBtnAttributes(), { "loader-position": "center", type: "button" }), h("slot", null)));
101
+ return h(Host, null, h("salla-button", Object.assign({ color: this.productStatus === 'sale' ? 'primary' : 'light', type: "button", fill: this.productStatus === 'sale' ? 'solid' : 'outline', ref: el => this.btn = el, onClick: event => this.addProductToCart(event), disabled: this.productStatus !== 'sale' }, this.getBtnAttributes(), { "loader-position": "center" }), h("slot", null)));
112
102
  }
113
103
  componentDidLoad() {
114
104
  if (!this.notifyOptionsAvailability) {
115
105
  return;
116
106
  }
117
- salla.event.on('product-options::change', data => {
107
+ salla.event.on('product-options::change', async (data) => {
108
+ var _a;
118
109
  if (!['thumbnail', 'color', 'single-option'].includes(data.option.type)) {
119
110
  return;
120
111
  }
121
- this.pushSelectedOption(data);
112
+ this.hasOutOfStockOption = await ((_a = document.querySelector(`salla-product-options[product-id="${this.productId}"]`)) === null || _a === void 0 ? void 0 : _a.hasOutOfStockOption());
122
113
  this.hasLabel = false;
123
114
  if (!this.subscribedOptions || this.subscribedOptions === 'null') {
124
115
  return;
@@ -13,6 +13,7 @@ const SallaCartSummary$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
13
13
  this.__registerHost();
14
14
  this.cartSummaryCount = salla.storage.get('cart.summary.count') || 0;
15
15
  this.cartSummaryTotal = salla.storage.get('cart.summary.total') || 0;
16
+ this.cartLabel = salla.config.get('user.language_code') === 'ar' ? 'السلة' : 'Cart';
16
17
  salla.cart.event.onUpdated((response) => {
17
18
  this.cartSummaryCount = response.count || 0;
18
19
  this.cartSummaryTotal = response.total || 0;
@@ -68,13 +69,15 @@ const SallaCartSummary$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
68
69
  }, '-=1700');
69
70
  }
70
71
  render() {
71
- return (h(Host, null, h("a", { class: "s-cart-summary-wrapper", href: salla.url.get('cart') }, h("div", { id: "s-cart-icon" }, h("slot", { name: "icon" }, h("i", { class: "s-cart-summary-icon", innerHTML: PendingOrdersIcon }))), h("span", { class: "s-cart-summary-count" }, salla.helpers.number(this.cartSummaryCount)), h("b", { class: "s-cart-summary-total" }, salla.money(this.cartSummaryTotal)))));
72
+ return (h(Host, null, h("a", { class: "s-cart-summary-wrapper", href: salla.url.get('cart') }, h("div", { id: "s-cart-icon" }, h("slot", { name: "icon" }, h("i", { class: "s-cart-summary-icon", innerHTML: PendingOrdersIcon }))), h("span", { class: "s-cart-summary-count" }, salla.helpers.number(this.cartSummaryCount)), h("p", { class: "s-cart-summary-content" }, this.showCartLabel && h("span", { class: "s-cart-summary-label" }, this.cartLabel), h("b", { class: "s-cart-summary-total" }, salla.money(this.cartSummaryTotal))))));
72
73
  }
73
74
  get host() { return this; }
74
75
  static get style() { return sallaCartSummaryCss; }
75
76
  }, [4, "salla-cart-summary", {
77
+ "showCartLabel": [4, "show-cart-label"],
76
78
  "cartSummaryCount": [32],
77
79
  "cartSummaryTotal": [32],
80
+ "cartLabel": [32],
78
81
  "animateToCart": [64]
79
82
  }]);
80
83
  function defineCustomElement$1() {
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface SallaCountDown extends Components.SallaCountDown, HTMLElement {}
4
+ export const SallaCountDown: {
5
+ prototype: SallaCountDown;
6
+ new (): SallaCountDown;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,122 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
5
+
6
+ const sallaCountDownCss = "";
7
+
8
+ const SallaCountDown$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
9
+ constructor() {
10
+ super();
11
+ this.__registerHost();
12
+ /**
13
+ * The size of the count down
14
+ * */
15
+ this.size = 'md';
16
+ /**
17
+ * The color of the count down
18
+ * */
19
+ this.color = 'dark';
20
+ /**
21
+ * The digits lang to show in the count down
22
+ * */
23
+ this.digits = 'auto';
24
+ this.daysLabel = '';
25
+ this.hoursLabel = '';
26
+ this.minutesLabel = '';
27
+ this.secondsLabel = '';
28
+ this.endLabel = '';
29
+ this.invalidDate = '';
30
+ this.offerEnded = false;
31
+ salla.lang.onLoaded(() => {
32
+ this.daysLabel = salla.lang.get('pages.checkout.day');
33
+ this.hoursLabel = salla.lang.get('pages.checkout.hour');
34
+ this.minutesLabel = salla.lang.get('pages.checkout.minute');
35
+ this.invalidDate = salla.lang.get('blocks.buy_as_gift.incorrect_date');
36
+ this.secondsLabel = salla.lang.get('pages.checkout.second');
37
+ this.endLabel = salla.lang.get('pages.checkout.offer_ended');
38
+ });
39
+ }
40
+ /**
41
+ * End the count down
42
+ * */
43
+ async endCountDown() {
44
+ clearInterval(this.countInterval);
45
+ this.offerEnded = true;
46
+ this.daysEl.innerHTML = this.number(0);
47
+ this.hoursEl.innerHTML = this.number(0);
48
+ this.minutesEl.innerHTML = this.number(0);
49
+ this.secondsEl.innerHTML = this.number(0);
50
+ }
51
+ isValidDate(date) {
52
+ return !isNaN(Date.parse(date));
53
+ }
54
+ number(digit) {
55
+ return salla.helpers.number(digit, this.digits === 'en');
56
+ }
57
+ startCountDown() {
58
+ let countDownDate = new Date(this.date);
59
+ countDownDate.setHours(23, 59, 59, 999);
60
+ let countDownTime = countDownDate.getTime();
61
+ this.countInterval = setInterval(() => {
62
+ let now = new Date().getTime();
63
+ let distance = countDownTime - now;
64
+ this.daysEl.innerHTML = this.number(Math.floor(distance / (1000 * 60 * 60 * 24)));
65
+ this.hoursEl.innerHTML = this.number(Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)));
66
+ this.minutesEl.innerHTML = this.number(Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)));
67
+ this.secondsEl.innerHTML = this.number(Math.floor((distance % (1000 * 60)) / 1000));
68
+ if (distance < 0) {
69
+ this.endCountDown();
70
+ }
71
+ }, 1000);
72
+ }
73
+ componentDidLoad() {
74
+ if (!this.date) {
75
+ return;
76
+ }
77
+ this.startCountDown();
78
+ }
79
+ render() {
80
+ if (!this.isValidDate(this.date)) {
81
+ return h("div", null, this.invalidDate);
82
+ }
83
+ return (h(Host, { class: "s-count-down-wrapper" }, h("ul", { class: `s-count-down-list ${this.boxed ? 's-count-down-boxed' : ''} ${this.offerEnded ? 's-count-down-ended' : ''} s-count-down-${this.size} s-count-down-${this.color}` }, h("li", { class: "s-count-down-item" }, h("div", { class: "s-count-down-item-value", ref: el => this.secondsEl = el }, this.number(0)), this.labeled && h("div", { class: "s-count-down-item-label" }, this.secondsLabel)), h("li", { class: "s-count-down-item" }, h("div", { class: "s-count-down-item-value", ref: el => this.minutesEl = el }, this.number(0)), this.labeled && h("div", { class: "s-count-down-item-label" }, this.minutesLabel)), h("li", { class: "s-count-down-item" }, h("div", { class: "s-count-down-item-value", ref: el => this.hoursEl = el }, this.number(0)), this.labeled && h("div", { class: "s-count-down-item-label" }, this.hoursLabel)), h("li", { class: "s-count-down-item" }, h("div", { class: "s-count-down-item-value", ref: el => this.daysEl = el }, this.number(0)), this.labeled && h("div", { class: "s-count-down-item-label" }, this.daysLabel))), this.offerEnded && h("div", { class: "s-count-down-end-text" }, this.endText || this.endLabel)));
84
+ }
85
+ static get style() { return sallaCountDownCss; }
86
+ }, [0, "salla-count-down", {
87
+ "date": [1],
88
+ "boxed": [4],
89
+ "size": [1],
90
+ "color": [1],
91
+ "labeled": [4],
92
+ "endText": [1, "end-text"],
93
+ "digits": [1],
94
+ "daysLabel": [32],
95
+ "hoursLabel": [32],
96
+ "minutesLabel": [32],
97
+ "secondsLabel": [32],
98
+ "endLabel": [32],
99
+ "invalidDate": [32],
100
+ "offerEnded": [32],
101
+ "countInterval": [32],
102
+ "endCountDown": [64]
103
+ }]);
104
+ function defineCustomElement$1() {
105
+ if (typeof customElements === "undefined") {
106
+ return;
107
+ }
108
+ const components = ["salla-count-down"];
109
+ components.forEach(tagName => { switch (tagName) {
110
+ case "salla-count-down":
111
+ if (!customElements.get(tagName)) {
112
+ customElements.define(tagName, SallaCountDown$1);
113
+ }
114
+ break;
115
+ } });
116
+ }
117
+ defineCustomElement$1();
118
+
119
+ const SallaCountDown = SallaCountDown$1;
120
+ const defineCustomElement = defineCustomElement$1;
121
+
122
+ export { SallaCountDown, defineCustomElement };
@@ -82,6 +82,13 @@ const SallaGifting$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
82
82
  this.currentLang = salla.lang.locale;
83
83
  });
84
84
  }
85
+ componentDidLoad() {
86
+ salla.event.product.onPriceUpdated(() => {
87
+ const quantityInput = document.querySelector('.s-quantity-input-input');
88
+ // @ts-ignore
89
+ this.quantity = quantityInput.value;
90
+ });
91
+ }
85
92
  /**
86
93
  * Show / Open the gifting modal window
87
94
  */
@@ -318,7 +325,7 @@ const SallaGifting$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
318
325
  let payload = {
319
326
  text: this.selectedText,
320
327
  sender_name: this.senderName,
321
- quantity: 1,
328
+ quantity: this.quantity,
322
329
  deliver_at: this.showCalendar ? this.deliveryDate : null,
323
330
  image_url: (_a = this.uploadedImage) !== null && _a !== void 0 ? _a : this.selectedImage,
324
331
  receiver: {
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
5
5
 
6
- const sallaInstallmentCss = "#tabbyPromoWrapper{background:white;border-radius:0.375rem;-webkit-transition:-webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:-webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1), -webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);margin-bottom:20px}.salla-y #tabbyPromoWrapper{border:1px solid var(--color-grey-dark);border-radius:12px}#tabbyPromoWrapper:hover{-webkit-box-shadow:0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D;box-shadow:0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D}#tabbyPromoWrapper #tabbyPromo *{font-family:var(--font-main)}#tabbyPromoWrapper #tabbyPromo>div>div{max-width:none;-webkit-box-shadow:none;box-shadow:none;border:none}#tabbyPromoWrapper #tabbyPromo .tabby-promo-snippet{max-width:100%;min-height:100px;padding:18px 20px;border:none !important}#tabbyPromoWrapper #tabbyPromo .tabby-promo-snippet__text,#tabbyPromoWrapper #tabbyPromo .tabby-promo-snippet__link{font-size:var(--font-sm);color:var(--color-text) !important}#tabbyPromoWrapper #tabbyPromo .tabby-promo-snippet__link{font-weight:bold}.tabby-promo-wrapper #tabby-promo{font-family:var(--font-main) !important}.tabby-promo-wrapper #tabby-promo .tabby-promo__feature-title{font-size:var(--font-md)}.tabby-promo-wrapper #tabby-promo .tabby-promo__feature-desc{font-size:var(--font-sm);line-height:20px}.tamara-product-widget{margin-bottom:20px}.tamara-product-widget,.spotii-wrapper{min-height:100px;position:relative;color:var(--color-text);font-size:var(--font-sm);line-height:1.25;padding:18px 20px 18px 100px !important;background:white;border-radius:0.375rem;-webkit-transition:-webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:-webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1), -webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1)}.salla-y .tamara-product-widget,.salla-y .spotii-wrapper{border-radius:12px;border:1px solid var(--color-grey-dark)}.tamara-product-widget:hover,.spotii-wrapper:hover{-webkit-box-shadow:0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D;box-shadow:0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D}.tamara-product-widget .spotii-logo,.spotii-wrapper .spotii-logo{float:left;margin:0 0 0 -75px}.ltr .tamara-product-widget,.ltr .spotii-wrapper{text-align:left;padding:18px 100px 18px 20px !important}.ltr .tamara-product-widget .spotii-logo,.ltr .spotii-wrapper .spotii-logo{float:right;margin:0 -75px 0 0}.ltr .tamara-product-widget .spotii-product-widget,.ltr .spotii-wrapper .spotii-product-widget{text-align:left !important}.spotii-wrapper{margin-bottom:20px}.spotii-wrapper .spotii-promo{font-size:var(--font-md)}.spotii-wrapper .spotii-product-widget{font-size:var(--font-sm) !important;margin-top:10px}.tamara-product-widget .tamara-logo{position:absolute;left:20px;top:18px;margin:0 !important}.ltr .tamara-product-widget .tamara-logo{right:20px;left:auto}.tamara-product-widget span{font-family:var(--font-main);font-size:var(--font-sm);color:var(--color-text)}.tamara-product-widget span:last-child{display:block;position:relative;margin-top:8px}.tamara-popup__wrap{overflow:auto !important}";
6
+ const sallaInstallmentCss = "salla-installment:empty{display:none}#tabbyPromoWrapper{background:white;border-radius:0.375rem;-webkit-transition:-webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:-webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1), -webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);margin-bottom:20px}.salla-y #tabbyPromoWrapper{border:1px solid var(--color-grey-dark);border-radius:12px}#tabbyPromoWrapper:hover{-webkit-box-shadow:0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D;box-shadow:0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D}#tabbyPromoWrapper #tabbyPromo *{font-family:var(--font-main)}#tabbyPromoWrapper #tabbyPromo>div>div{max-width:none;-webkit-box-shadow:none;box-shadow:none;border:none}#tabbyPromoWrapper #tabbyPromo .tabby-promo-snippet{max-width:100%;min-height:100px;padding:18px 20px;border:none !important}#tabbyPromoWrapper #tabbyPromo .tabby-promo-snippet__text,#tabbyPromoWrapper #tabbyPromo .tabby-promo-snippet__link{font-size:var(--font-sm);color:var(--color-text) !important}#tabbyPromoWrapper #tabbyPromo .tabby-promo-snippet__link{font-weight:bold}.tabby-promo-wrapper #tabby-promo{font-family:var(--font-main) !important}.tabby-promo-wrapper #tabby-promo .tabby-promo__feature-title{font-size:var(--font-md)}.tabby-promo-wrapper #tabby-promo .tabby-promo__feature-desc{font-size:var(--font-sm);line-height:20px}.tamara-product-widget{margin-bottom:20px}.tamara-product-widget,.spotii-wrapper{min-height:100px;position:relative;color:var(--color-text);font-size:var(--font-sm);line-height:1.25;padding:18px 20px 18px 100px !important;background:white;border-radius:0.375rem;-webkit-transition:-webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:-webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1), -webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1)}.salla-y .tamara-product-widget,.salla-y .spotii-wrapper{border-radius:12px;border:1px solid var(--color-grey-dark)}.tamara-product-widget:hover,.spotii-wrapper:hover{-webkit-box-shadow:0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D;box-shadow:0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D}.tamara-product-widget .spotii-logo,.spotii-wrapper .spotii-logo{float:left;margin:0 0 0 -75px}.ltr .tamara-product-widget,.ltr .spotii-wrapper{text-align:left;padding:18px 100px 18px 20px !important}.ltr .tamara-product-widget .spotii-logo,.ltr .spotii-wrapper .spotii-logo{float:right;margin:0 -75px 0 0}.ltr .tamara-product-widget .spotii-product-widget,.ltr .spotii-wrapper .spotii-product-widget{text-align:left !important}.spotii-wrapper{margin-bottom:20px}.spotii-wrapper .spotii-promo{font-size:var(--font-md)}.spotii-wrapper .spotii-product-widget{font-size:var(--font-sm) !important;margin-top:10px}.tamara-product-widget .tamara-logo{position:absolute;left:20px;top:18px;margin:0 !important}.ltr .tamara-product-widget .tamara-logo{right:20px;left:auto}.tamara-product-widget span{font-family:var(--font-main);font-size:var(--font-sm);color:var(--color-text)}.tamara-product-widget span:last-child{display:block;position:relative;margin-top:8px}.tamara-popup__wrap{overflow:auto !important}";
7
7
 
8
8
  const SallaInstallment$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
9
9
  constructor() {
@@ -210,9 +210,10 @@ const SallaLoginModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
210
210
  if ([this.mobileTab, this.emailTab].includes(tab)) {
211
211
  this.regType = tab === this.mobileTab ? 'phone' : 'email';
212
212
  }
213
- // this.loginTelInput.focus();
214
- // tab.querySelector('input')?.focus();
215
- // setTimeout(() =>this.loginTelInput.focus(), 100);
213
+ const input = tab.querySelector('input[type="tel"], input[type="email"]');
214
+ input && setTimeout(() => {
215
+ input.focus();
216
+ }, 100);
216
217
  (_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.currentTabName === 'registration' ? salla.lang.get('common.titles.registration') : this.title);
217
218
  return this;
218
219
  }
@@ -95,6 +95,7 @@ const SallaModal = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
95
95
  */
96
96
  async open() {
97
97
  this.host.setAttribute('visible', '');
98
+ this.handleAutoFocus();
98
99
  return this.host;
99
100
  }
100
101
  /**
@@ -126,6 +127,15 @@ const SallaModal = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
126
127
  this.isLoading = false;
127
128
  return this.host;
128
129
  }
130
+ handleAutoFocus() {
131
+ const firstFocusableElement = this.host.querySelector('input, textarea, select');
132
+ if (!firstFocusableElement) {
133
+ return;
134
+ }
135
+ setTimeout(() => {
136
+ firstFocusableElement.focus();
137
+ }, 100);
138
+ }
129
139
  toggleModal(isOpen) {
130
140
  const body = this.host.querySelector('.s-modal-body');
131
141
  Helper.toggleElementClassIf(body, 's-modal-entering', 's-modal-leaving', () => isOpen)