@salla.sa/twilight-components 1.0.32 → 1.0.34

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 (77) hide show
  1. package/dist/cjs/index.cjs.js +1 -1
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/salla-branches.cjs.entry.js +5 -6
  4. package/dist/cjs/salla-button_7.cjs.entry.js +147 -55
  5. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +3 -0
  6. package/dist/cjs/salla-offer.cjs.entry.js +10 -2
  7. package/dist/cjs/salla-product-availability.cjs.entry.js +6 -0
  8. package/dist/cjs/salla-rating.cjs.entry.js +40 -8
  9. package/dist/cjs/{salla-search-94d97bc0.js → salla-search-6738ec5e.js} +12 -11
  10. package/dist/cjs/twilight-components.cjs.js +1 -1
  11. package/dist/collection/components/salla-branches/salla-branches.js +6 -8
  12. package/dist/collection/components/salla-button/salla-button.js +62 -26
  13. package/dist/collection/components/salla-infinite-scroll/salla-infinite-scroll.js +4 -1
  14. package/dist/collection/components/salla-localization/salla-localization.js +13 -6
  15. package/dist/collection/components/salla-login/salla-login.js +33 -18
  16. package/dist/collection/components/salla-modal/salla-modal.js +86 -49
  17. package/dist/collection/components/salla-offer/salla-offer.js +29 -9
  18. package/dist/collection/components/salla-product-availability/salla-product-availability.js +11 -5
  19. package/dist/collection/components/salla-rating/salla-rating.js +68 -16
  20. package/dist/collection/components/salla-search/salla-search.js +3 -0
  21. package/dist/collection/components/salla-tel-input/salla-tel-input.js +30 -14
  22. package/dist/collection/components/salla-verify/salla-verify.js +43 -50
  23. package/dist/collection/plugins/tailwind-theme/index.js +2 -1
  24. package/dist/esm/index.js +1 -1
  25. package/dist/esm/loader.js +1 -1
  26. package/dist/esm/salla-branches.entry.js +5 -6
  27. package/dist/esm/salla-button_7.entry.js +147 -55
  28. package/dist/esm/salla-infinite-scroll.entry.js +3 -0
  29. package/dist/esm/salla-offer.entry.js +10 -2
  30. package/dist/esm/salla-product-availability.entry.js +6 -0
  31. package/dist/esm/salla-rating.entry.js +40 -8
  32. package/dist/esm/{salla-search-c72c4eb6.js → salla-search-90231876.js} +12 -11
  33. package/dist/esm/twilight-components.js +1 -1
  34. package/dist/twilight-components/index.esm.js +1 -1
  35. package/dist/twilight-components/p-2abf9fc5.js +1 -0
  36. package/dist/twilight-components/p-dd9469a1.entry.js +1 -0
  37. package/dist/twilight-components/p-ebc6e474.entry.js +1 -0
  38. package/dist/twilight-components/p-f36fa4c6.entry.js +1 -0
  39. package/dist/twilight-components/twilight-components.esm.js +1 -1
  40. package/dist/types/components/salla-branches/salla-branches.d.ts +0 -1
  41. package/dist/types/components/salla-button/salla-button.d.ts +32 -1
  42. package/dist/types/components/salla-infinite-scroll/salla-infinite-scroll.d.ts +3 -0
  43. package/dist/types/components/salla-localization/salla-localization.d.ts +6 -0
  44. package/dist/types/components/salla-login/salla-login.d.ts +14 -1
  45. package/dist/types/components/salla-modal/salla-modal.d.ts +37 -2
  46. package/dist/types/components/salla-offer/salla-offer.d.ts +9 -1
  47. package/dist/types/components/salla-product-availability/salla-product-availability.d.ts +10 -1
  48. package/dist/types/components/salla-rating/salla-rating.d.ts +20 -0
  49. package/dist/types/components/salla-search/salla-search.d.ts +3 -0
  50. package/dist/types/components/salla-tel-input/salla-tel-input.d.ts +15 -1
  51. package/dist/types/components/salla-verify/salla-verify.d.ts +26 -4
  52. package/dist/types/components.d.ts +209 -10
  53. package/example/.DS_Store +0 -0
  54. package/example/assets/tailwind.css +1 -0
  55. package/example/auth/email/send_verification +0 -0
  56. package/example/auth/email/verify +11 -0
  57. package/example/auth/mobile/send_verification +0 -0
  58. package/example/auth/mobile/verify +9 -0
  59. package/example/dist/.DS_Store +0 -0
  60. package/example/dist/demo.js +69 -0
  61. package/example/dist/flags.png +0 -0
  62. package/example/dist/flags@2x.png +0 -0
  63. package/example/dist/intlTelInput.min.css +1 -0
  64. package/example/dist/tailwind.css +5 -0
  65. package/example/dist/translations.js +1 -0
  66. package/example/dist/twilight.js +2 -0
  67. package/example/index.html +65 -74
  68. package/example/products/search +13 -0
  69. package/example/rating/products +0 -0
  70. package/example/rating/rating.json +1 -0
  71. package/example/rating/shipping +0 -0
  72. package/example/rating/store +0 -0
  73. package/package.json +1 -1
  74. package/dist/twilight-components/p-622cae84.js +0 -1
  75. package/dist/twilight-components/p-744b4c0c.entry.js +0 -1
  76. package/dist/twilight-components/p-9cabc8a4.entry.js +0 -1
  77. package/dist/twilight-components/p-b6f8a19a.entry.js +0 -1
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const sallaSearch = require('./salla-search-94d97bc0.js');
5
+ const sallaSearch = require('./salla-search-6738ec5e.js');
6
6
  require('./index-714023c8.js');
7
7
  require('./Helper-98cc9f18.js');
8
8
 
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- return index.bootstrapLazy([["salla-button_7.cjs",[[0,"salla-login",{"isEmailAllowed":[4,"is-email-allowed"],"isMobileAllowed":[4,"is-mobile-allowed"],"isEmailRequired":[4,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"show":[64]},[[0,"verified","onVerified"],[0,"backClicked","onbackClicked"]]],[4,"salla-localization",{"languagesTitle":[32],"currenciesTitle":[32],"show":[64],"hide":[64],"submit":[64]}],[0,"salla-search",{"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[0,"salla-verify",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"isShowBack":[4,"is-show-back"],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}],[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"setText":[64],"stop":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"error":[4],"success":[4],"primary":[4],"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-product-availability.cjs",[[4,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32]}]]],["salla-branches.cjs",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"ok":[32],"show":[64],"hide":[64]}]]],["salla-offer.cjs",[[0,"salla-offer",{"offer":[32],"show":[64],"showOffer":[64]}]]],["salla-rating.cjs",[[0,"salla-rating",{"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[4],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]]], options);
17
+ return index.bootstrapLazy([["salla-button_7.cjs",[[4,"salla-login",{"isEmailAllowed":[4,"is-email-allowed"],"isMobileAllowed":[4,"is-mobile-allowed"],"isEmailRequired":[4,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"show":[64]},[[0,"verified","onVerified"]]],[4,"salla-localization",{"languagesTitle":[32],"currenciesTitle":[32],"show":[64],"hide":[64],"submit":[64]}],[0,"salla-search",{"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[4,"salla-verify",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}],[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"error":[4],"success":[4],"primary":[4],"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-product-availability.cjs",[[4,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32]}]]],["salla-branches.cjs",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-offer.cjs",[[0,"salla-offer",{"offer":[32],"show":[64],"showOffer":[64]}]]],["salla-rating.cjs",[[0,"salla-rating",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[4],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -11,8 +11,8 @@ const SallaBranches = class {
11
11
  index.registerInstance(this, hostRef);
12
12
  this.open = false;
13
13
  this.isOpenedBefore = salla.localData.get("branch-choosed-before");
14
- this.displayAs = 'default';
15
- this.browseProductsFrom = 'all';
14
+ this.displayAs = 'default'; //todo:: change it to boolean, isPopup default false
15
+ this.browseProductsFrom = 'all'; //todo:: get better name
16
16
  this.branches = [
17
17
  { id: 1, name: 'فرع الرياض', open: true, available: true, limited: false, tag: 'متوفر' },
18
18
  { id: 2, name: 'فرع جدة', open: false, available: false, limited: false, tag: 'غير متوفر' },
@@ -39,10 +39,9 @@ const SallaBranches = class {
39
39
  : 'التسوق من فرع آخر';
40
40
  };
41
41
  salla.event.on('branches::show', () => this.show());
42
- salla.event.on('languages::translations.loaded', () => {
43
- this.ok = salla.lang.get('common.elements.ok');
44
- });
42
+ salla.event.on('languages::translations.loaded', () => { var _a; return (_a = this.btn) === null || _a === void 0 ? void 0 : _a.setText(salla.lang.get('common.elements.ok')); });
45
43
  }
44
+ //todo:: add description for all @methods
46
45
  async show() {
47
46
  return this.modal.show();
48
47
  }
@@ -77,7 +76,7 @@ const SallaBranches = class {
77
76
  index.h("span", { class: this.statusColor(branch) }, branch.tag)))))
78
77
  :
79
78
  index.h("select", { class: "s-branches-select", onInput: (event) => this.handelChange(event) }, this.branches.map(branch => (index.h("option", { value: branch.id, disabled: !branch.open, selected: this.selected == branch.id }, branch.name, " ", branch.open ? '' : '- مُغلق')))), this.isChoiceable() ?
80
- index.h("slot", { name: "footer" }, index.h("salla-button", { ref: btn => this.btn = btn, onClick: () => this.handleSubmit(), class: "s-branches-submit", wide: true }, this.ok))
79
+ index.h("slot", { name: "footer" }, index.h("salla-button", { ref: btn => this.btn = btn, onClick: () => this.handleSubmit(), class: "s-branches-submit", wide: true }, salla.lang.get('common.elements.ok')))
81
80
  : ''));
82
81
  }
83
82
  componentDidRender() {
@@ -4,20 +4,34 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-714023c8.js');
6
6
  const Helper = require('./Helper-98cc9f18.js');
7
- const sallaSearch = require('./salla-search-94d97bc0.js');
7
+ const sallaSearch = require('./salla-search-6738ec5e.js');
8
8
 
9
9
  const sallaButtonCss = ":host{display:block}";
10
10
 
11
11
  const SallaButton = class {
12
12
  constructor(hostRef) {
13
13
  index.registerInstance(this, hostRef);
14
+ /**
15
+ * Button Style
16
+ */
14
17
  this.btnStyle = 'primary';
18
+ /**
19
+ * Is the button currently loading
20
+ */
15
21
  this.loading = false;
22
+ /**
23
+ * Is the button currently disabled
24
+ */
16
25
  this.disabled = false;
26
+ /**
27
+ * If there is need to change loader position, pass the position
28
+ */
17
29
  this.loaderPosition = 'before';
30
+ /**
31
+ * Is the button wide
32
+ */
18
33
  this.wide = false;
19
34
  this.hostAttributes = {};
20
- //============= Initiate Button Attributes =============//
21
35
  for (let i = 0; i < this.host.attributes.length; i++) {
22
36
  this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
23
37
  }
@@ -25,7 +39,7 @@ const SallaButton = class {
25
39
  this.hostAttributes.class += ' s-button-btn btn--has-loading'
26
40
  + ' s-button-' + this.btnStyle
27
41
  + (this.wide ? ' s-button-wide ' : '')
28
- + ' loader-' + this.loaderPosition
42
+ + ' loader-' + this.loaderPosition //todo:: it looks there is no need for this class🤔
29
43
  + (this.loaderPosition == 'before' ? ' s-button-loader-after' : '');
30
44
  delete this.hostAttributes['btn-style'];
31
45
  delete this.hostAttributes['id'];
@@ -33,25 +47,41 @@ const SallaButton = class {
33
47
  this.host.classList.add('s-button-wide');
34
48
  }
35
49
  }
50
+ /**
51
+ * Run loading animation
52
+ */
36
53
  async load() {
37
54
  if (this.loaderPosition == 'center')
38
55
  this.text.classList.add('s-button-hide');
39
56
  this.host.setAttribute('loading', '');
40
57
  return this.host;
41
58
  }
42
- async setText(html) {
43
- this.text.innerHTML = html;
44
- return this.host;
45
- }
59
+ /**
60
+ * Stop loading animation
61
+ */
46
62
  async stop() {
47
63
  this.host.removeAttribute('loading');
48
64
  if (this.loaderPosition == 'center')
49
65
  this.text.classList.remove('s-button-hide');
50
66
  return this.host;
51
67
  }
68
+ /**
69
+ * Changing the body of the button
70
+ * @param html
71
+ */
72
+ async setText(html) {
73
+ this.text.innerHTML = html;
74
+ return this.host;
75
+ }
76
+ /**
77
+ * Add `disabled` attribute
78
+ */
52
79
  async disable() {
53
80
  this.host.setAttribute('disabled', '');
54
81
  }
82
+ /**
83
+ * Remove `disabled` attribute
84
+ */
55
85
  async enable() {
56
86
  this.host.removeAttribute('disabled');
57
87
  }
@@ -92,9 +122,10 @@ const SallaLocalization = class {
92
122
  Helper.Helper.setHost(this.host);
93
123
  salla.event.on('localization::show', () => this.show());
94
124
  salla.event.on('languages::translations.loaded', () => {
125
+ var _a;
95
126
  this.languagesTitle = salla.lang.get('common.titles.language');
96
127
  this.currenciesTitle = salla.lang.get('common.titles.currency');
97
- this.btn.setText(salla.lang.get('common.elements.ok'));
128
+ (_a = this.btn) === null || _a === void 0 ? void 0 : _a.setText(salla.lang.get('common.elements.ok'));
98
129
  });
99
130
  /**
100
131
  * letting developer to insert his own slot like:
@@ -110,9 +141,15 @@ const SallaLocalization = class {
110
141
  this.languages = Object.values(salla.config.get('languages', {}));
111
142
  this.currencies = Object.values(salla.config.get('currencies', {}));
112
143
  }
144
+ /**
145
+ * Show the component
146
+ */
113
147
  async show() {
114
148
  return this.modal.show();
115
149
  }
150
+ /**
151
+ * Hide the component
152
+ */
116
153
  async hide() {
117
154
  return this.modal.hide();
118
155
  }
@@ -124,10 +161,10 @@ const SallaLocalization = class {
124
161
  }
125
162
  async submit() {
126
163
  let url;
127
- console.log('this.currency.code::::', this.currency, this.currency.code);
164
+ console.log('this.currency.code::::', this.currency, this.currency.code); //todo:: remove it
128
165
  this.btn.load()
129
- .then(() => this.currency.code === salla.config.get('user.currency') || ((url = window.location.href) && salla.currency.api.change(this.currency.code)))
130
- .then(() => this.language.code === salla.config.get('user.language') || (url = this.language.url))
166
+ .then(() => this.currency.code === salla.config.get('user.currency_code', 'SAR') || ((url = window.location.href) && salla.currency.api.change(this.currency.code)))
167
+ .then(() => this.language.code === salla.config.get('user.language_code', 'ar') || (url = this.language.url))
131
168
  .then(() => this.btn.stop())
132
169
  .then(() => this.hide())
133
170
  .then(() => url && (window.location.href = url));
@@ -166,27 +203,43 @@ const SallaModal = class {
166
203
  index.registerInstance(this, hostRef);
167
204
  this.modalOpened = index.createEvent(this, "modalOpened", 7);
168
205
  this.modalClosed = index.createEvent(this, "modalClosed", 7);
169
- var _a;
170
206
  //todo:: unite three colors (error, success, primary) in one prop
171
207
  this.error = false;
172
208
  this.success = false;
173
209
  this.primary = false;
174
- this.isClosable = true;
210
+ this.isClosable = true; //todo::rename unclude
211
+ /**
212
+ * The size of the modal
213
+ */
175
214
  this.width = 'md';
176
- this.position = 'middel';
215
+ /**
216
+ * The position of the modal
217
+ */
218
+ this.position = 'middle';
219
+ /**
220
+ * Show the modal on rendering
221
+ */
177
222
  this.visible = false;
223
+ /**
224
+ * Show loading in the middle
225
+ */
178
226
  this.isLoading = false;
179
- this.subTitleFirst = false;
180
- this.noPadding = false;
227
+ this.subTitleFirst = false; //todo:: choose better name
228
+ this.noPadding = false; //todo:: choose better name
181
229
  this.subTitle = '';
230
+ /**
231
+ * Icon css class, default for types `error` is `sicon-alert-engine`, `success` is `sicon-check-circle2`
232
+ */
182
233
  this.icon = '';
234
+ /**
235
+ * url of an image
236
+ */
183
237
  this.imageIcon = '';
184
238
  Helper.Helper.setHost(this.host);
185
239
  salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
186
240
  salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
187
241
  this.title = this.host.title;
188
242
  this.host.removeAttribute('title');
189
- (_a = Helper.Helper.getElement('[slot=body]')) === null || _a === void 0 ? void 0 : _a.classList.add('s-modal-body', 's-modal-' + this.width);
190
243
  }
191
244
  handleVisible(newValue) {
192
245
  if (!newValue) {
@@ -194,39 +247,53 @@ const SallaModal = class {
194
247
  this.modalClosed.emit();
195
248
  return;
196
249
  }
197
- this.host.classList.remove('hidden');
250
+ this.host.classList.remove('s-hidden');
198
251
  setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
199
252
  this.modalOpened.emit();
200
253
  }
254
+ /**
255
+ * Show the modal
256
+ */
201
257
  async show() {
202
258
  this.host.setAttribute('visible', '');
203
259
  return this.host;
204
260
  }
261
+ /**
262
+ * hide the modal
263
+ */
205
264
  async hide() {
206
265
  this.host.removeAttribute('visible');
207
266
  return this.host;
208
267
  }
268
+ /**
269
+ * Change the title
270
+ * @param {string} title
271
+ */
209
272
  async setTitle(title) {
210
273
  this.title = title;
211
274
  return this.host;
212
275
  }
276
+ /**
277
+ * Start loading
278
+ */
213
279
  async loading() {
214
280
  this.isLoading = true;
215
281
  return this.host;
216
282
  }
283
+ /**
284
+ * Stop the loading
285
+ */
217
286
  async stopLoading() {
218
287
  this.isLoading = false;
219
288
  return this.host;
220
289
  }
221
290
  toggleModal(isOpen) {
222
- Helper.Helper
223
- // .toggleElement(this.host.querySelector('.s-modal-body'), 's-modal-entering', 's-modal-leaving', () => isOpen)
224
- .toggleElement(this.host.querySelector('[slot=body]') || this.host, 's-modal-entering', 's-modal-leaving', () => isOpen)
291
+ Helper.Helper.toggleElement(this.host, 's-modal-entering', 's-modal-leaving', () => isOpen)
225
292
  .toggleElement(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
226
293
  //todo:: use united class names
227
294
  .toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
228
295
  if (!isOpen) {
229
- setTimeout(() => this.host.classList.add('hidden'), 350);
296
+ setTimeout(() => this.host.classList.add('s-hidden'), 350);
230
297
  }
231
298
  }
232
299
  closeModal() {
@@ -235,34 +302,36 @@ const SallaModal = class {
235
302
  }
236
303
  this.host.removeAttribute('visible');
237
304
  }
305
+ iconBlockClasses() {
306
+ return {
307
+ 's-modal-icon': true,
308
+ 's-modal-bg-error': this.error,
309
+ 's-modal-bg-success': this.success,
310
+ 's-modal-bg-normal': !this.error && !this.success,
311
+ 's-modal-bg-primary': this.primary
312
+ };
313
+ }
314
+ iconClasses() {
315
+ return {
316
+ [this.icon]: true,
317
+ 's-modal-text-error': this.error,
318
+ 's-modal-text-success': this.success,
319
+ 'sicon-alert-engine': !this.icon && this.error && !this.imageIcon,
320
+ 'sicon-check-circle2': !this.icon && this.success && !this.imageIcon,
321
+ };
322
+ }
238
323
  //todo:: pref for each modal
239
324
  render() {
240
325
  this.host.id = this.host.id || 'salla-modal';
241
- return (
242
- //todo:: use suitable class name instead of hidden
243
- index.h(index.Host, { class: 's-modal-container hidden', "aria-modal": "true", role: "dialog" }, index.h("div", { class: "s-modal-wrapper" }, index.h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }), index.h("span", { class: 's-modal-spacer s-modal-align-' + this.position }, "\u200B"), index.h("div", { class: 's-modal-body s-modal-scroll-y ' + 's-modal-align-' + this.position + ' s-modal-' + this.width + (this.noPadding ? ' s-modal-nopadding' : ' s-modal-padding'), slot: "body" }, this.isLoading
326
+ return (index.h(index.Host, { class: 's-modal-container s-hidden', "aria-modal": "true", role: "dialog" }, index.h("div", { class: "s-modal-wrapper" }, index.h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }), index.h("span", { class: 's-modal-spacer s-modal-align-' + this.position }, "\u200B"), index.h("div", { class: 's-modal-body s-modal-scroll-y ' + 's-modal-align-' + this.position + ' s-modal-' + this.width + (this.noPadding ? ' s-modal-nopadding' : ' s-modal-padding') }, this.isLoading
244
327
  ? index.h("div", { class: "s-modal-loader-wrap" }, index.h("span", { class: "s-modal-loader" }))
245
328
  :
246
329
  [index.h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.icon != '' || this.imageIcon != '' } }, this.isClosable ?
247
330
  index.h("button", { class: "s-modal-close", onClick: () => this.closeModal(), type: "button" }, index.h("span", { class: "sicon-cancel" }))
248
331
  : '', this.title || this.subTitle ?
249
332
  index.h("div", { class: "s-modal-header-inner" }, this.error || this.success || this.icon
250
- ? index.h("div", { class: {
251
- 's-modal-icon': true,
252
- 's-modal-bg-error': this.error,
253
- 's-modal-bg-success': this.success,
254
- 's-modal-bg-normal': !this.error && !this.success,
255
- 's-modal-bg-primary': this.primary
256
- } }, index.h("i", { class: {
257
- [this.icon]: true,
258
- 's-modal-text-error': this.error,
259
- 's-modal-text-success': this.success,
260
- 'sicon-alert-engine': !this.icon && this.error,
261
- 'sicon-check-circle2': !this.icon && this.success,
262
- } }))
263
- : this.imageIcon ?
264
- index.h("img", { class: "s-modal-header-img", src: this.imageIcon })
265
- : '', index.h("div", { class: "s-modal-header-content" }, index.h("div", { class: { 's-modal-title': true, 's-modal-title-below': this.subTitleFirst }, innerHTML: this.title }), index.h("p", { class: { 's-modal-sub-title': true }, innerHTML: this.subTitle })))
333
+ ? index.h("div", { class: this.iconBlockClasses() }, index.h("i", { class: this.iconClasses() }))
334
+ : this.imageIcon ? index.h("img", { class: "s-modal-header-img", src: this.imageIcon }) : '', index.h("div", { class: "s-modal-header-content" }, index.h("div", { class: { 's-modal-title': true, 's-modal-title-below': this.subTitleFirst }, innerHTML: this.title }), index.h("p", { class: { 's-modal-sub-title': true }, innerHTML: this.subTitle })))
266
335
  : ''),
267
336
  index.h("slot", null),
268
337
  index.h("slot", { name: "footer" })
@@ -1652,8 +1721,11 @@ const SallaTelInput = class {
1652
1721
  constructor(hostRef) {
1653
1722
  index.registerInstance(this, hostRef);
1654
1723
  this.enterClicked = index.createEvent(this, "enterClicked", 7);
1724
+ /**
1725
+ * Current country_code
1726
+ */
1655
1727
  this.countryCode = salla.config.get('user.country_code', 'SA');
1656
- this.countryKey = "+966"; //TODO:: why we need it
1728
+ this.countryKey = "+966"; //TODO:: why we need it, if it's important find a way to get it automatically for the current user
1657
1729
  this.countryCodeLabel = salla.lang.get('common.country_code');
1658
1730
  this.mobileLabel = salla.lang.get('common.elements.mobile');
1659
1731
  this.tooShort = salla.lang.get('common.errors.too_short', { attribute: this.mobileLabel });
@@ -1673,12 +1745,21 @@ const SallaTelInput = class {
1673
1745
  this.errorMap = [this.invalidNumber, this.invalidCountryCode, this.tooShort, this.tooLong, this.invalidNumber];
1674
1746
  });
1675
1747
  }
1748
+ /**
1749
+ * Get current values
1750
+ * @return {{mobile:number,countryCode:'SA'|string, countryKey:'+966'|string}}
1751
+ */
1676
1752
  async getValues() {
1677
- this.mobile = this.phoneInput.value;
1678
- this.countryCode = this.countryCodeInput.value;
1679
- this.countryKey = this.countryKeyInput.value;
1680
- return { mobile: this.phoneInput.value, countryCode: this.countryCodeInput.value, countryKey: this.countryKeyInput.value };
1753
+ return {
1754
+ mobile: this.mobile = this.phoneInput.value,
1755
+ countryCode: this.countryCode = this.countryCodeInput.value,
1756
+ countryKey: this.countryKey = this.countryKeyInput.value
1757
+ };
1681
1758
  }
1759
+ /**
1760
+ * Is current data valid or not
1761
+ * @return {boolean}
1762
+ */
1682
1763
  async isValid() {
1683
1764
  this.reset();
1684
1765
  if (this.iti.isValidNumber())
@@ -1711,9 +1792,7 @@ const SallaTelInput = class {
1711
1792
  });
1712
1793
  });
1713
1794
  // on blur: validate
1714
- this.phoneInput.addEventListener('blur', () => {
1715
- this.isValid();
1716
- });
1795
+ this.phoneInput.addEventListener('blur', () => this.isValid());
1717
1796
  // on keyup / change flag: reset
1718
1797
  this.phoneInput.addEventListener('input', e => {
1719
1798
  salla.helpers.digitsOnly(e.target);
@@ -1738,10 +1817,15 @@ const SallaVerify = class {
1738
1817
  constructor(hostRef) {
1739
1818
  index.registerInstance(this, hostRef);
1740
1819
  this.verified = index.createEvent(this, "verified", 7);
1741
- this.backClicked = index.createEvent(this, "backClicked", 7);
1820
+ this.initiated = false;
1821
+ /**
1822
+ * Verifying method
1823
+ */
1742
1824
  this.by = 'sms';
1825
+ /**
1826
+ * should auto reloading the page after success verification
1827
+ */
1743
1828
  this.autoReload = true;
1744
- this.initiated = false;
1745
1829
  Helper.Helper.setHost(this.host);
1746
1830
  if (this.withoutModal) {
1747
1831
  this.modal = { show: () => '', hide: () => '' };
@@ -1753,12 +1837,22 @@ const SallaVerify = class {
1753
1837
  });
1754
1838
  }
1755
1839
  salla.event.on('languages::translations.loaded', () => {
1840
+ var _a;
1756
1841
  this.title = salla.lang.get('pages.profile.verify_title');
1842
+ (_a = this.btn) === null || _a === void 0 ? void 0 : _a.setText(salla.lang.get('pages.profile.verify'));
1757
1843
  });
1758
1844
  }
1845
+ /**
1846
+ * Get current code
1847
+ * @return {string}
1848
+ */
1759
1849
  async getCode() {
1760
1850
  return this.code.value;
1761
1851
  }
1852
+ /**
1853
+ * Show verifying modal
1854
+ * @param data
1855
+ */
1762
1856
  async show(data) {
1763
1857
  var _a;
1764
1858
  this.data = data;
@@ -1853,12 +1947,10 @@ const SallaVerify = class {
1853
1947
  myBody() {
1854
1948
  return [
1855
1949
  index.h("div", { class: "s-verify-message", innerHTML: salla.lang.get('pages.profile.verify_message') }),
1856
- // <label class="s-verify-label">{salla.lang.get('pages.profile.verify_placeholder')}</label>,
1857
1950
  index.h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }),
1858
1951
  index.h("div", { class: "s-verify-codes", dir: "ltr" }, [1, 2, 3, 4].map(() => index.h("input", { type: "text", maxlength: "1", class: "s-verify-input", required: true }))),
1859
- index.h("div", { slot: "footer", class: "s-verify-footer" }, index.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')), index.h("p", { class: "s-verify-resend-message", ref: el => this.resendMessage = el }, salla.lang.get('blocks.header.resend_after'), index.h("b", { class: "s-verify-timer", ref: el => this.timer = el })), index.h("a", { href: "#", class: "s-verify-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit')), this.isShowBack ?
1860
- index.h("a", { href: "#", class: "s-verify-back", onClick: () => this.backClicked.emit() }, index.h("i", { class: "sicon-arrow-right" }))
1861
- : '')
1952
+ index.h("div", { slot: "footer", class: "s-verify-footer" }, index.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')), index.h("p", { class: "s-verify-resend-message", ref: el => this.resendMessage = el }, salla.lang.get('blocks.header.resend_after'), index.h("b", { class: "s-verify-timer", ref: el => this.timer = el })), index.h("a", { href: "#", class: "s-verify-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit'))),
1953
+ index.h("slot", { name: "after-footer" })
1862
1954
  ];
1863
1955
  }
1864
1956
  get host() { return index.getElement(this); }
@@ -12,6 +12,9 @@ const SallaInfiniteScroll = class {
12
12
  * Next Page element
13
13
  */
14
14
  this.nextPage = '';
15
+ /**
16
+ * Is there is need to autoload next page when scroll
17
+ */
15
18
  this.autoload = false;
16
19
  /**
17
20
  * Class selector to know the container if it's not the host `<salla-infinite-scroll>`
@@ -23,10 +23,18 @@ const SallaOffer = class {
23
23
  this.show(data.product_id);
24
24
  });
25
25
  }
26
- async show(productId) {
26
+ /**
27
+ * Show the available offers for the product
28
+ * @param product_id
29
+ */
30
+ async show(product_id) {
27
31
  //TODO:: make sure there is only one offer
28
- return salla.api.offer.details(productId).then(response => this.offer = response.data[0]);
32
+ return salla.api.offer.details(product_id).then(response => this.offer = response.data[0]);
29
33
  }
34
+ /**
35
+ * Show offer details
36
+ * @param {Offer} offer
37
+ */
30
38
  async showOffer(offer) {
31
39
  this.offer = offer;
32
40
  return this.modal.show();
@@ -9,7 +9,13 @@ const SallaProductAvailability = class {
9
9
  constructor(hostRef) {
10
10
  index.registerInstance(this, hostRef);
11
11
  this.isUser = Helper.Helper.isUser();
12
+ /**
13
+ * product id that can visitor subscribe to its availability notification
14
+ */
12
15
  this.productId = salla.config.get('page.id');
16
+ /**
17
+ * is current user already subscribed
18
+ */
13
19
  this.isSubscribed = false;
14
20
  // @Method()
15
21
  this.submit = async () => {
@@ -13,18 +13,47 @@ const SallaRating = class {
13
13
  this.stepsCount = 0;
14
14
  this.currentIndex = 0;
15
15
  this.submitted = [];
16
+ /**
17
+ * The order id, to rate on its products & shipping
18
+ */
19
+ this.orderId = salla.config.get('page.id');
20
+ this.rate_the_store = salla.lang.get('pages.rating.rate_the_store');
21
+ this.write_store_rate = salla.lang.get('pages.rating.write_store_rate');
22
+ this.rate_product_stars = salla.lang.get('pages.rating.rate_product_stars');
23
+ this.write_product_rate = salla.lang.get('pages.rating.write_product_rate');
24
+ this.rate_shipping = salla.lang.get('pages.rating.rate_shipping');
25
+ this.write_shipping_rate = salla.lang.get('pages.rating.write_shipping_rate');
26
+ this.thanks = salla.lang.get('pages.rating.thanks');
27
+ this.back = salla.lang.get('common.elements.back');
28
+ this.next = salla.lang.get('common.elements.next');
16
29
  Helper.Helper.setHost(this.host);
17
30
  salla.event.on('rating::show', () => this.show());
31
+ salla.event.on('languages::translations.loaded', () => {
32
+ this.rate_the_store = salla.lang.get('pages.rating.rate_the_store');
33
+ this.write_store_rate = salla.lang.get('pages.rating.write_store_rate');
34
+ this.rate_product_stars = salla.lang.get('pages.rating.rate_product_stars');
35
+ this.write_product_rate = salla.lang.get('pages.rating.write_product_rate');
36
+ this.rate_shipping = salla.lang.get('pages.rating.rate_shipping');
37
+ this.write_shipping_rate = salla.lang.get('pages.rating.write_shipping_rate');
38
+ this.thanks = salla.lang.get('pages.rating.thanks');
39
+ this.back = salla.lang.get('common.elements.back');
40
+ this.next = salla.lang.get('common.elements.next');
41
+ });
18
42
  }
43
+ /**
44
+ * Show the rating modal
45
+ */
19
46
  async show() {
20
47
  return this.modal.show()
21
- .then(() => salla.feedback.api.order(salla.config.get('page.id')))
22
- .then(res => this.order = res.data)
48
+ .then(() => this.order || salla.feedback.api.order(this.orderId).then(res => this.order = res.data))
23
49
  .then(() => this.modal.setTitle(salla.lang.get('pages.rating.rate_order') + ' <span class="unicode">(#' + this.order.id + ')</span>'))
24
50
  .then(() => this.modal.stopLoading())
25
51
  .then(() => this.stepsCount = [this.order.testimonials_enabled, this.order.products_enabled, this.order.shipping_enabled].filter(enabled => enabled).length)
26
52
  .then(() => setTimeout(() => this.initiateRating(), 100));
27
53
  }
54
+ /**
55
+ * Show the rating modal
56
+ */
28
57
  async hide() {
29
58
  return this.modal.hide();
30
59
  }
@@ -150,7 +179,7 @@ const SallaRating = class {
150
179
  if (Object.keys(data).length == 0) {
151
180
  return;
152
181
  }
153
- data['order_id'] = salla.config.get('page.id');
182
+ data['order_id'] = this.orderId;
154
183
  data['type'] = this.currentTab.dataset.type;
155
184
  this.submitted.push(this.currentIndex);
156
185
  return salla.feedback.api[this.currentTab.dataset.type](data);
@@ -176,21 +205,24 @@ const SallaRating = class {
176
205
  render() {
177
206
  return (index.h(index.Host, null, index.h("salla-modal", { isLoading: true, width: "md", ref: modal => this.modal = modal }, this.order
178
207
  ? [index.h("div", { class: "s-rating-wrapper", ref: el => this.body = el }, this.order.testimonials_enabled ?
179
- index.h("div", { class: "rating-outer-form s-rating-step-wrap s-rating-step s-rating-hidden", "data-type": "store" }, index.h("div", { class: "s-rating-rounded-icon" }, index.h("img", { src: salla.config.get('store.logo'), alt: "store name", class: "s-rating-store-logo" })), index.h("h2", { class: "s-rating-title" }, salla.lang.get('pages.rating.rate_the_store')), index.h("div", { class: "s-rating-stars-company" }, " ", this.renderRatingStars('large')), index.h("textarea", { id: "storeReview", name: "comment", class: "s-rating-comment", placeholder: salla.lang.get('pages.rating.write_store_rate') }), index.h("small", { class: "s-rating-validation-msg" }))
208
+ index.h("div", { class: "rating-outer-form s-rating-step-wrap s-rating-step s-rating-hidden", "data-type": "store" }, index.h("div", { class: "s-rating-rounded-icon" }, index.h("img", { src: salla.config.get('store.logo', 'https://assets.salla.sa/cp/assets/images/logo-new.png'), alt: "store name", class: "s-rating-store-logo" })), index.h("h2", { class: "s-rating-title" }, this.rate_the_store), index.h("div", { class: "s-rating-stars-company" }, " ", this.renderRatingStars('large')), index.h("textarea", { id: "storeReview", name: "comment", class: "s-rating-comment", placeholder: this.write_store_rate }), index.h("small", { class: "s-rating-validation-msg" }))
180
209
  : '', this.order.products_enabled
181
- ? index.h("section", { class: "s-rating-step s-rating-hidden", "data-type": "products" }, this.order.products.map((item, index$1) => index.h("div", { class: "rating-outer-form s-rating-product", "data-stars-error": salla.lang.get('pages.rating.rate_product_stars') }, index.h("img", { src: item.product.thumbnail, alt: item.product.name, class: "s-rating-product-img" }), index.h("div", { class: "s-rating-product-details" }, index.h("h3", { class: "s-rating-product-title" }, " ", item.product.name), index.h("div", { class: "s-rating-stars-product" }, " ", this.renderRatingStars('small', `products[${index$1}][rating]`)), index.h("input", { type: "hidden", name: `products[${index$1}][product_id]`, value: item.product.id }), index.h("textarea", { placeholder: salla.lang.get('pages.rating.write_product_rate'), name: `products[${index$1}][comment]`, class: "s-rating-comment" }), index.h("small", { class: "s-rating-validation-msg" })))))
210
+ ? index.h("section", { class: "s-rating-step s-rating-hidden", "data-type": "products" }, this.order.products.map((item, index$1) => index.h("div", { class: "rating-outer-form s-rating-product", "data-stars-error": this.rate_product_stars }, index.h("img", { src: item.product.thumbnail, alt: item.product.name, class: "s-rating-product-img" }), index.h("div", { class: "s-rating-product-details" }, index.h("h3", { class: "s-rating-product-title" }, " ", item.product.name), index.h("div", { class: "s-rating-stars-product" }, " ", this.renderRatingStars('small', `products[${index$1}][rating]`)), index.h("input", { type: "hidden", name: `products[${index$1}][product_id]`, value: item.product.id }), index.h("textarea", { placeholder: this.write_product_rate, name: `products[${index$1}][comment]`, class: "s-rating-comment" }), index.h("small", { class: "s-rating-validation-msg" })))))
182
211
  : '', this.order.shipping_enabled
183
212
  ? index.h("div", { class: "rating-outer-form s-rating-step-wrap s-rating-step s-rating-hidden", "data-type": "shipping" }, index.h("input", { type: "hidden", name: "shipping_company_id", value: this.order.shipping.company.id }), this.order.shipping.company.logo
184
213
  ? index.h("div", { class: "s-rating-rounded-icon" }, index.h("img", { src: this.order.shipping.company.logo, class: "s-rating-shipping-logo", alt: this.order.shipping.company.name }))
185
- : index.h("span", { class: "s-rating-icon sicon-shipping-fast" }), index.h("div", { class: "s-rating-title" }, " ", salla.lang.get('pages.rating.rate_shipping') + ' ' + this.order.shipping.company.name), index.h("div", { class: "s-rating-stars-company" }, this.renderRatingStars('large')), index.h("textarea", { name: "comment", class: "s-rating-comment", placeholder: salla.lang.get('pages.rating.write_shipping_rate') }), index.h("small", { class: "s-rating-validation-msg" }))
186
- : '', index.h("div", { class: "s-rating-thanks s-rating-hidden", ref: el => this.thanksTab = el }, index.h("span", { class: "s-rating-icon sicon-check-circle2" }), index.h("h3", { class: "s-rating-thanks-title" }, salla.lang.get('pages.rating.thanks')), index.h("div", { class: "s-rating-thanks-msg", innerHTML: this.order.thanks_message }), index.h("time", { class: "s-rating-thanks-time", ref: el => this.thanksTime = el }))),
187
- index.h("div", { class: "s-rating-footer" }, index.h("button", { ref: el => this.backBtn = el, onClick: () => this.previousTab(), class: "s-rating-btn s-rating-unvisiable" }, salla.lang.get('common.elements.back')), this.stepsCount > 1 ? index.h("ul", { class: "s-rating-dots" }, [0, 1, 2].slice(0, this.stepsCount).map(() => index.h("li", { class: 's-rating-bg-gray s-rating-step-dot' }))) : '', index.h("salla-button", { "loader-position": 'center', ref: el => this.nextBtn = el, onClick: () => this.submit() }, salla.lang.get('common.elements.next'))),]
214
+ : index.h("span", { class: "s-rating-icon sicon-shipping-fast" }), index.h("div", { class: "s-rating-title" }, " ", this.rate_shipping + ' ' + this.order.shipping.company.name), index.h("div", { class: "s-rating-stars-company" }, this.renderRatingStars('large')), index.h("textarea", { name: "comment", class: "s-rating-comment", placeholder: this.write_shipping_rate }), index.h("small", { class: "s-rating-validation-msg" }))
215
+ : '', index.h("div", { class: "s-rating-thanks s-rating-hidden", ref: el => this.thanksTab = el }, index.h("span", { class: "s-rating-icon sicon-check-circle2" }), index.h("h3", { class: "s-rating-thanks-title" }, this.thanks), index.h("div", { class: "s-rating-thanks-msg", innerHTML: this.order.thanks_message }), index.h("time", { class: "s-rating-thanks-time", ref: el => this.thanksTime = el }))),
216
+ index.h("div", { class: "s-rating-footer" }, index.h("button", { ref: el => this.backBtn = el, onClick: () => this.previousTab(), class: "s-rating-btn s-rating-unvisiable" }, this.back), this.stepsCount > 1 ? index.h("ul", { class: "s-rating-dots" }, [0, 1, 2].slice(0, this.stepsCount).map(() => index.h("li", { class: 's-rating-bg-gray s-rating-step-dot' }))) : '', index.h("salla-button", { "loader-position": 'center', ref: el => this.nextBtn = el, onClick: () => this.submit() }, this.next)),]
188
217
  : '')));
189
218
  }
190
219
  componentDidRender() {
191
220
  //todo:: know from where there is hidden attributes to the doms🤔
192
221
  this.modal.querySelectorAll('[hidden]').forEach(el => el.removeAttribute('hidden'));
193
222
  }
223
+ componentDidLoad() {
224
+ salla.event.dispatch('rating::ready', this);
225
+ }
194
226
  get host() { return index.getElement(this); }
195
227
  };
196
228
  SallaRating.style = sallaRatingCss;