@salla.sa/twilight-components 1.6.3 → 1.6.4

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 (102) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/salla-button_27.cjs.entry.js +27879 -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-tel-input/interfaces.js +4 -0
  35. package/dist/collection/components/salla-tel-input/salla-tel-input.css +1 -2
  36. package/dist/collection/components/salla-tel-input/salla-tel-input.js +32 -3
  37. package/dist/collection/components/salla-verify/salla-verify.js +1 -1
  38. package/dist/collection/global/app.js +15 -12
  39. package/dist/components/_commonjsHelpers.js +24 -0
  40. package/dist/components/anime.es.js +1312 -0
  41. package/dist/components/index.d.ts +5 -0
  42. package/dist/components/index.js +5 -0
  43. package/dist/components/salla-datetime-picker.d.ts +11 -0
  44. package/dist/components/salla-datetime-picker.js +9 -0
  45. package/dist/components/salla-datetime-picker2.js +2876 -0
  46. package/dist/components/salla-file-upload.d.ts +11 -0
  47. package/dist/components/salla-file-upload.js +9 -0
  48. package/dist/components/salla-file-upload2.js +14623 -0
  49. package/dist/components/salla-gifting.d.ts +11 -0
  50. package/dist/components/salla-gifting.js +499 -0
  51. package/dist/components/salla-localization-modal.js +31 -16
  52. package/dist/components/salla-login-modal.js +37 -20
  53. package/dist/components/salla-loyalty-prize-item.d.ts +11 -0
  54. package/dist/components/salla-loyalty-prize-item.js +42 -0
  55. package/dist/components/salla-loyalty.js +28 -17
  56. package/dist/components/salla-modal2.js +1 -1
  57. package/dist/components/salla-offer-modal.js +42 -12
  58. package/dist/components/salla-product-size-guide.js +21 -6
  59. package/dist/components/salla-rating-modal.js +47 -19
  60. package/dist/components/salla-scopes.js +10 -6
  61. package/dist/components/salla-search.js +1 -1
  62. package/dist/components/salla-select.d.ts +11 -0
  63. package/dist/components/salla-select.js +199 -0
  64. package/dist/components/salla-social-share.js +1 -1308
  65. package/dist/components/salla-swiper2.js +9 -9
  66. package/dist/components/salla-tel-input2.js +15 -18
  67. package/dist/components/salla-verify2.js +1 -1
  68. package/dist/esm/loader.js +1 -1
  69. package/dist/esm/salla-button_27.entry.js +27849 -0
  70. package/dist/esm/salla-loyalty-prize-item.entry.js +22 -0
  71. package/dist/esm/salla-scopes.entry.js +9 -6
  72. package/dist/esm/salla-select.entry.js +155 -0
  73. package/dist/esm/twilight-components.js +1 -1
  74. package/dist/twilight-components/p-49125b6a.entry.js +4 -0
  75. package/dist/twilight-components/p-9a25753c.entry.js +4 -0
  76. package/dist/twilight-components/p-b7b9439d.entry.js +22 -0
  77. package/dist/twilight-components/p-df1eb1e5.entry.js +4 -0
  78. package/dist/twilight-components/twilight-components.esm.js +1 -1
  79. package/dist/types/components/salla-datetime-picker/interfaces.d.ts +8 -0
  80. package/dist/types/components/salla-datetime-picker/salla-datetime-picker.d.ts +250 -0
  81. package/dist/types/components/salla-file-upload/interfaces.d.ts +766 -0
  82. package/dist/types/components/salla-file-upload/salla-file-upload.d.ts +267 -0
  83. package/dist/types/components/salla-gifting/gift-schema.d.ts +20 -0
  84. package/dist/types/components/salla-gifting/intefaces.d.ts +18 -0
  85. package/dist/types/components/salla-gifting/salla-gifting.d.ts +98 -0
  86. package/dist/types/components/salla-localization-modal/salla-localization-modal.d.ts +3 -2
  87. package/dist/types/components/salla-login-modal/salla-login-modal.d.ts +13 -3
  88. package/dist/types/components/salla-loyalty/salla-loyalty-prize-item.d.ts +8 -0
  89. package/dist/types/components/salla-loyalty/salla-loyalty.d.ts +2 -0
  90. package/dist/types/components/salla-offer-modal/salla-offer-modal.d.ts +3 -1
  91. package/dist/types/components/salla-product-size-guide/salla-product-size-guide.d.ts +4 -0
  92. package/dist/types/components/salla-rating-modal/salla-rating-modal.d.ts +3 -2
  93. package/dist/types/components/salla-scopes/salla-scopes.d.ts +1 -0
  94. package/dist/types/components/salla-select/salla-select.d.ts +110 -0
  95. package/dist/types/components/salla-tel-input/interfaces.d.ts +4 -0
  96. package/dist/types/components/salla-tel-input/salla-tel-input.d.ts +3 -0
  97. package/dist/types/components.d.ts +1253 -10
  98. package/package.json +2 -2
  99. package/dist/cjs/salla-button_24.cjs.entry.js +0 -10087
  100. package/dist/esm/salla-button_24.entry.js +0 -10060
  101. package/dist/twilight-components/p-30b2c5b0.entry.js +0 -4
  102. package/dist/twilight-components/p-5fb32395.entry.js +0 -4
@@ -15,7 +15,7 @@ export class SallaLocalizationModal {
15
15
  this.translationLoaded = false;
16
16
  this.languages = [];
17
17
  this.currencies = [];
18
- this.isLoading = true;
18
+ this.hasError = false;
19
19
  /**
20
20
  * Current language (existing or newly selected)
21
21
  */
@@ -45,10 +45,18 @@ export class SallaLocalizationModal {
45
45
  * open the component
46
46
  */
47
47
  async open() {
48
- return await this.modal.open()
49
- .then(() => this.getLanguages())
48
+ this.modal.open();
49
+ return await salla.api.withoutNotifier(this.getLanguages()
50
50
  .then(() => this.getCurrencies())
51
- .then(() => this.isLoading = false);
51
+ .catch(e => {
52
+ var _a, _b, _c, _d;
53
+ console.log(e);
54
+ this.hasError = true;
55
+ 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);
56
+ })
57
+ .finally(() => {
58
+ this.modal.stopLoading();
59
+ }));
52
60
  }
53
61
  /**
54
62
  * Hide the component
@@ -93,7 +101,7 @@ export class SallaLocalizationModal {
93
101
  .then(() => url && (window.location.href = url));
94
102
  }
95
103
  render() {
96
- return (h("salla-modal", { isLoading: this.isLoading, class: "s-hidden", ref: modal => this.modal = modal, width: "xs" },
104
+ return (h("salla-modal", { isLoading: true, class: "s-hidden", ref: modal => this.modal = modal, width: "xs" },
97
105
  h("div", { slot: 'loading' },
98
106
  h("div", { class: "s-localization-modal-skeleton" },
99
107
  h("salla-skeleton", { width: '25%', height: '15px' }),
@@ -109,12 +117,14 @@ export class SallaLocalizationModal {
109
117
  h("salla-skeleton", { height: '10px', width: '100px' })),
110
118
  h("salla-skeleton", { height: '15px', width: '20px' })))),
111
119
  h("salla-skeleton", { height: '40px', width: '100%' }))),
112
- !this.isLoading ?
120
+ !!this.hasError ?
121
+ h("salla-placeholder", { alignment: "center" },
122
+ h("span", { slot: "description" }, this.errorMessage)) :
113
123
  h("div", { class: "s-localization-modal-inner" },
114
124
  this.languages.length > 1 ?
115
125
  h("div", { class: "s-localization-modal-section" },
116
126
  h("label", { class: "s-localization-modal-title" }, salla.lang.get('common.titles.language')),
117
- h("div", { class: "s-localization-modal-section-inner" }, this.languages.length < 6 ?
127
+ h("div", { class: "s-localization-modal-section-inner" }, this.languages.length < 6 || this.currencies.length == 1 ?
118
128
  this.languages.map(lang => h("div", { class: "s-localization-modal-item" },
119
129
  h("input", { class: "s-localization-modal-input", type: "radio", checked: this.language == lang.iso_code, onChange: () => this.language = lang.iso_code, name: "language", id: 'lang-' + lang.code.toLowerCase(), value: lang.code }),
120
130
  h("div", { class: "s-localization-modal-label-slot", id: "language-slot", innerHTML: this.languageSlot
@@ -126,7 +136,7 @@ export class SallaLocalizationModal {
126
136
  this.currencies.length > 1 ?
127
137
  h("div", { class: "s-localization-modal-section" },
128
138
  h("label", { class: "s-localization-modal-title" }, salla.lang.get('common.titles.currency')),
129
- h("div", { class: "s-localization-modal-section-inner" }, this.currencies.length < 6 ?
139
+ h("div", { class: "s-localization-modal-section-inner" }, this.currencies.length < 6 || this.languages.length == 1 ?
130
140
  this.currencies.map(currency => h("div", { class: "s-localization-modal-item" },
131
141
  h("input", { class: "s-localization-modal-input", type: "radio", name: "currency", checked: this.currency == currency.code, onChange: () => this.currency = currency.code, id: 'currency-' + currency.code, value: currency.code }),
132
142
  h("div", { class: "s-localization-modal-label-slot", id: "currency-slot", innerHTML: this.currencySlot
@@ -135,8 +145,7 @@ export class SallaLocalizationModal {
135
145
  .replace(/\{country_code\}/g, currency.country_code) }))) :
136
146
  h("select", { class: "s-localization-modal-select", name: "currency", onChange: e => this.onChangeCurrency(e) }, this.currencies.map(currency => h("option", { value: currency.code, selected: this.currency == currency.code }, currency.name)))))
137
147
  : '',
138
- h("salla-button", { width: "wide", ref: btn => this.btn = btn, onClick: () => this.submit() }, salla.lang.get('common.elements.ok')))
139
- : ''));
148
+ h("salla-button", { width: "wide", ref: btn => this.btn = btn, onClick: () => this.submit() }, salla.lang.get('common.elements.ok')))));
140
149
  }
141
150
  /**
142
151
  * to reduce dom levels we will move slot data into the parent dom
@@ -194,19 +203,20 @@ export class SallaLocalizationModal {
194
203
  "translationLoaded": {},
195
204
  "languages": {},
196
205
  "currencies": {},
197
- "isLoading": {}
206
+ "hasError": {},
207
+ "errorMessage": {}
198
208
  }; }
199
209
  static get methods() { return {
200
210
  "open": {
201
211
  "complexType": {
202
- "signature": "() => Promise<boolean>",
212
+ "signature": "() => Promise<any>",
203
213
  "parameters": [],
204
214
  "references": {
205
215
  "Promise": {
206
216
  "location": "global"
207
217
  }
208
218
  },
209
- "return": "Promise<boolean>"
219
+ "return": "Promise<any>"
210
220
  },
211
221
  "docs": {
212
222
  "text": "open the component",
@@ -33,6 +33,7 @@ export class SallaLoginModal {
33
33
  * Does the merchant require registration with email & mobile
34
34
  */
35
35
  this.isEmailRequired = false;
36
+ this.currentTabName = 'home';
36
37
  this.regType = 'phone';
37
38
  this.translationLoaded = false;
38
39
  this.typing = (e, submitMethod) => {
@@ -41,15 +42,18 @@ export class SallaLoginModal {
41
42
  (error === null || error === void 0 ? void 0 : error.classList.contains('s-login-modal-error-message')) && (error.innerText = '');
42
43
  e.key == 'Enter' && submitMethod();
43
44
  };
44
- this.loginBySMS = async () => {
45
+ this.loginBySMS = async (event = null) => {
46
+ event === null || event === void 0 ? void 0 : event.preventDefault();
45
47
  const { phone, countryCode } = await this.loginTelInput.getValues();
46
48
  const isPhoneValid = await this.loginTelInput.isValid();
47
49
  if (!isPhoneValid) {
48
50
  return;
49
51
  }
50
52
  this.login(this.smsBtn, { type: 'mobile', phone: phone, country_code: countryCode });
53
+ return false;
51
54
  };
52
- this.loginByEmail = () => {
55
+ this.loginByEmail = (event = null) => {
56
+ event === null || event === void 0 ? void 0 : event.preventDefault();
53
57
  if (!Helper.isValidEmail(this.loginEmail.value)) {
54
58
  this.validateField(this.loginEmail, this.emailErrorMsg);
55
59
  return;
@@ -151,24 +155,18 @@ export class SallaLoginModal {
151
155
  return this.modal.open();
152
156
  }
153
157
  showTab(tab, evt) {
154
- var _a, _b;
158
+ var _a;
155
159
  evt === null || evt === void 0 ? void 0 : evt.preventDefault();
156
- let tabs = [this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab];
157
- tabs.map(el => Helper.toggleElementClassIf(el, 'visible', 's-hidden', () => el == tab));
158
- setTimeout(() => tabs.map(el => Helper.toggleElementClassIf(el, 's-login-modal-active', 's-login-modal-unactive', () => el == tab)), 200);
159
- //we should have only one salla-login, so it's okay to get it from document
160
- //todo:: use better way for resize the modal
161
- setTimeout(() => { var _a; return (_a = this.modal.querySelector('.s-login-modal-wrapper')) === null || _a === void 0 ? void 0 : _a.setAttribute('style', 'height:' + (tab === null || tab === void 0 ? void 0 : tab.scrollHeight) + 'px'); });
160
+ this.currentTabName = tab.getAttribute('data-name');
161
+ // todo:: use better way for resize the modal
162
+ // setTimeout(() => this.modal.querySelector('.s-login-modal-wrapper')?.setAttribute('style', 'height:' + tab?.scrollHeight + 'px'));
162
163
  if ([this.mobileTab, this.emailTab].includes(tab)) {
163
164
  this.regType = tab === this.mobileTab ? 'phone' : 'email';
164
165
  }
165
- let isRegistrationTab = tab == this.registrationTab;
166
- (_a = tab.querySelector('input')) === null || _a === void 0 ? void 0 : _a.focus(); // focus the first input in tab
167
- (_b = this.modal) === null || _b === void 0 ? void 0 : _b.setTitle(isRegistrationTab ? salla.lang.get('common.titles.registration') : this.title);
168
- if (!isRegistrationTab) {
169
- Helper.toggleElementClassIf(this.regMobileBlock, 's-hidden', 's-show', () => this.regType === 'phone')
170
- .toggleElementClassIf(this.regEmailBlock, 's-hidden', 's-show', () => this.regType === 'email');
171
- }
166
+ // this.loginTelInput.focus();
167
+ // tab.querySelector('input')?.focus();
168
+ // setTimeout(() =>this.loginTelInput.focus(), 100);
169
+ (_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.currentTabName === 'registration' ? salla.lang.get('common.titles.registration') : this.title);
172
170
  return this;
173
171
  }
174
172
  login(btn, data) {
@@ -193,12 +191,29 @@ export class SallaLoginModal {
193
191
  field.classList.add('s-has-error');
194
192
  field.nextElementSibling['innerText'] = '* ' + errorMsg;
195
193
  }
194
+ generateTabClasses(tabName) {
195
+ return {
196
+ 's-login-modal-tab': tabName !== 'registration' && tabName !== 'otp',
197
+ "s-hidden": this.currentTabName !== tabName,
198
+ "s-show": this.currentTabName === tabName,
199
+ 's-login-modal-unactive': tabName !== 'registration' && tabName !== 'otp' && this.currentTabName !== tabName,
200
+ 's-login-modal-active': tabName !== 'registration' && tabName !== 'otp' && this.currentTabName === tabName
201
+ };
202
+ }
203
+ generateRegClasses(regType) {
204
+ return {
205
+ "mb-1.5": true,
206
+ "s-hidden": this.regType !== regType
207
+ };
208
+ }
196
209
  render() {
210
+ // @ts-ignore
211
+ // @ts-ignore
197
212
  return (h("salla-modal", { class: "s-login-modal", "modal-title": this.title, ref: modal => this.modal = modal, width: "xs" },
198
213
  h("span", { slot: 'icon', class: "s-login-modal-header-icon", innerHTML: UserIcon }),
199
214
  h("div", { class: "s-login-modal-wrapper" },
200
215
  this.isEmailAllowed && this.isMobileAllowed ?
201
- h("div", { class: "s-login-modal-tab", ref: tab => this.homeTab = tab },
216
+ h("div", { class: this.generateTabClasses('home'), "data-name": "home", ref: tab => this.homeTab = tab },
202
217
  h("p", { class: "s-login-modal-sub-title" }, salla.lang.get('blocks.header.select_login_way')),
203
218
  h("slot", { name: "before-login-type" }),
204
219
  h("a", { href: "#", class: "s-login-modal-main-btn", onClick: (evt) => this.showTab(this.mobileTab, evt) },
@@ -212,28 +227,30 @@ export class SallaLoginModal {
212
227
  h("slot", { name: "after-login-type" }))
213
228
  : '',
214
229
  this.isMobileAllowed ?
215
- h("div", { class: "s-login-modal-tab", ref: tab => this.mobileTab = tab },
230
+ h("div", { class: this.generateTabClasses('login-phone'), "data-name": "login-phone", ref: tab => this.mobileTab = tab },
216
231
  h("slot", { name: "before-login-mobile" }),
217
- h("label", { class: "s-login-modal-label" }, salla.lang.get('common.elements.mobile')),
218
- h("salla-tel-input", { ref: el => this.loginTelInput = el, onKeyDown: e => this.typing(e, this.loginBySMS) }),
219
- h("salla-button", { "loader-position": 'center', width: "wide", onClick: () => this.loginBySMS(), ref: b => this.smsBtn = b }, salla.lang.get('blocks.header.enter')),
232
+ h("form", { onSubmit: () => this.loginBySMS(event), method: "POST" },
233
+ h("label", { class: "s-login-modal-label" }, salla.lang.get('common.elements.mobile')),
234
+ h("salla-tel-input", { tabindex: "0", ref: el => this.loginTelInput = el, onKeyDown: e => this.typing(e, this.loginBySMS) }),
235
+ h("salla-button", { type: "submit", "loader-position": 'center', width: "wide", ref: b => this.smsBtn = b }, salla.lang.get('blocks.header.enter'))),
220
236
  this.isEmailAllowed ?
221
237
  h("a", { href: "#", onClick: () => this.showTab(this.emailTab), class: "s-login-modal-link" }, salla.lang.get('blocks.header.login_by_email')) : '',
222
238
  h("slot", { name: "after-login-mobile" })) : '',
223
239
  this.isEmailAllowed ?
224
- h("div", { class: "s-login-modal-tab", ref: tab => this.emailTab = tab },
240
+ h("div", { class: this.generateTabClasses('login-email'), "data-name": "login-email", ref: tab => this.emailTab = tab },
225
241
  h("slot", { name: "before-login-email" }),
226
242
  h("label", { class: "s-login-modal-label" }, salla.lang.get('common.elements.email')),
227
- h("input", { type: "email", ref: el => this.loginEmail = el, onKeyDown: e => this.typing(e, this.loginByEmail), placeholder: "your@email.com", class: "s-login-modal-input s-ltr" }),
228
- h("span", { class: "s-login-modal-error-message" }),
229
- h("salla-button", { "loader-position": 'center', width: "wide", onClick: () => this.loginByEmail(), ref: b => this.emailBtn = b }, salla.lang.get('blocks.header.enter')),
243
+ h("form", { onSubmit: () => this.loginByEmail(event), method: "POST" },
244
+ h("input", { type: "email", ref: el => this.loginEmail = el, onKeyDown: e => this.typing(e, this.loginByEmail), placeholder: "your@email.com", enterkeyhint: "next", class: "s-login-modal-input s-ltr" }),
245
+ h("span", { class: "s-login-modal-error-message" }),
246
+ h("salla-button", { "loader-position": 'center', width: "wide", onClick: () => this.loginByEmail(), ref: b => this.emailBtn = b }, salla.lang.get('blocks.header.enter'))),
230
247
  this.isMobileAllowed ?
231
248
  h("a", { href: "#", onClick: () => this.showTab(this.mobileTab), class: "s-login-modal-link" }, salla.lang.get('blocks.header.login_by_sms'))
232
249
  : '',
233
250
  h("slot", { name: "after-login-email" })) : '',
234
- h("salla-verify", { display: "inline", ref: tab => this.verifyTab = tab, autoReload: false },
251
+ h("salla-verify", { display: "inline", class: this.generateTabClasses('otp'), "data-name": "otp", ref: tab => this.verifyTab = tab, autoReload: false },
235
252
  h("a", { onClick: () => this.showTab(this.regType == 'phone' ? this.mobileTab : this.emailTab), class: "s-verify-back", innerHTML: ArrowRightIcon, slot: "after-footer", href: "#" })),
236
- h("div", { ref: tab => this.registrationTab = tab },
253
+ h("div", { "data-name": "registration", class: this.generateTabClasses('registration'), ref: tab => this.registrationTab = tab },
237
254
  h("slot", { name: "before-registration" }),
238
255
  h("div", null,
239
256
  h("label", { class: "s-login-modal-label" }, salla.lang.get('blocks.header.your_name')),
@@ -243,10 +260,10 @@ export class SallaLoginModal {
243
260
  h("label", { class: "s-login-modal-label" }, salla.lang.get('pages.profile.last_name')),
244
261
  h("input", { type: "text", class: "s-login-modal-input", ref: el => this.lastName = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: salla.lang.get('pages.profile.last_name') }),
245
262
  h("span", { class: "s-login-modal-error-message" })),
246
- h("div", { ref: el => this.regMobileBlock = el, class: "mb-1.5" },
263
+ h("div", { class: this.generateRegClasses('phone') },
247
264
  h("label", { class: "s-login-modal-label" }, salla.lang.get('common.elements.mobile')),
248
265
  h("salla-tel-input", { ref: el => this.regTelInput = el, onKeyDown: e => this.typing(e, this.newUser) })),
249
- h("div", { ref: el => this.regEmailBlock = el, class: "mb-1.5" },
266
+ h("div", { class: this.generateRegClasses('email') },
250
267
  h("label", { class: "s-login-modal-label" }, salla.lang.get('common.elements.email')),
251
268
  h("input", { type: "email", ref: el => this.regEmail = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: "your@email.com", class: "s-login-modal-input s-ltr" }),
252
269
  h("span", { class: "s-login-modal-error-message" })),
@@ -317,6 +334,8 @@ export class SallaLoginModal {
317
334
  }
318
335
  }; }
319
336
  static get states() { return {
337
+ "currentTabName": {},
338
+ "regType": {},
320
339
  "translationLoaded": {},
321
340
  "title": {},
322
341
  "emailErrorMsg": {},
@@ -0,0 +1,3 @@
1
+ salla-loyalty-prize-item:hover {
2
+ box-shadow: 0 5px 15px 1px rgba(0, 0, 0, 0.04) !important;
3
+ }
@@ -0,0 +1,69 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ import { Component, h, Prop, Host, Event } from '@stencil/core';
5
+ export class SallaLoyaltyPrizeItem {
6
+ onPrizeItemClick() {
7
+ this.prizeItemSelected.emit(this.item);
8
+ }
9
+ render() {
10
+ return (h(Host, null,
11
+ h("div", { onClick: this.onPrizeItemClick.bind(this) },
12
+ h("img", { class: "s-loyalty-prize-item-image", src: this.item.image, alt: this.item.name }),
13
+ h("div", { class: "s-loyalty-prize-item-title" }, this.item.name),
14
+ h("div", { class: "s-loyalty-prize-item-subtitle" }, this.item.description),
15
+ h("div", { class: "s-loyalty-prize-item-points" },
16
+ this.item.cost_points,
17
+ " Points"))));
18
+ }
19
+ static get is() { return "salla-loyalty-prize-item"; }
20
+ static get originalStyleUrls() { return {
21
+ "$": ["salla-loyalty-prize-item.scss"]
22
+ }; }
23
+ static get styleUrls() { return {
24
+ "$": ["salla-loyalty-prize-item.css"]
25
+ }; }
26
+ static get properties() { return {
27
+ "item": {
28
+ "type": "unknown",
29
+ "mutable": false,
30
+ "complexType": {
31
+ "original": "Item",
32
+ "resolved": "Item",
33
+ "references": {
34
+ "Item": {
35
+ "location": "import",
36
+ "path": "./loyalty-schema"
37
+ }
38
+ }
39
+ },
40
+ "required": false,
41
+ "optional": false,
42
+ "docs": {
43
+ "tags": [],
44
+ "text": ""
45
+ }
46
+ }
47
+ }; }
48
+ static get events() { return [{
49
+ "method": "prizeItemSelected",
50
+ "name": "prizeItemSelected",
51
+ "bubbles": true,
52
+ "cancelable": true,
53
+ "composed": true,
54
+ "docs": {
55
+ "tags": [],
56
+ "text": ""
57
+ },
58
+ "complexType": {
59
+ "original": "Item",
60
+ "resolved": "Item",
61
+ "references": {
62
+ "Item": {
63
+ "location": "import",
64
+ "path": "./loyalty-schema"
65
+ }
66
+ }
67
+ }
68
+ }]; }
69
+ }
@@ -1,4 +0,0 @@
1
- #salla-loyalty-modal .s-swiper-button-prev button,
2
- #salla-loyalty-modal .s-swiper-button-next button {
3
- box-shadow: #32325d40 0px 6px 12px -2px, #0000004d 0px 3px 7px -3px;
4
- }
@@ -13,6 +13,7 @@ export class SallaLoyalty {
13
13
  this.selectedItem = undefined;
14
14
  this.askConfirmation = false;
15
15
  this.is_loggedin = false;
16
+ this.hasError = false;
16
17
  /**
17
18
  * The exchanged prize point
18
19
  */
@@ -46,7 +47,8 @@ export class SallaLoyalty {
46
47
  });
47
48
  }
48
49
  setSelectedPrizeItem(item) {
49
- if (!this.selectedItem || this.selectedItem.id != item.id) {
50
+ var _a;
51
+ if (!this.selectedItem || ((_a = this.selectedItem) === null || _a === void 0 ? void 0 : _a.id) != item.id) {
50
52
  this.selectedItem = item;
51
53
  }
52
54
  else {
@@ -60,8 +62,9 @@ export class SallaLoyalty {
60
62
  return text;
61
63
  }
62
64
  prizeItem(item) {
65
+ var _a;
63
66
  let klass = {
64
- 's-loyalty-prize-item-selected': !!this.selectedItem && this.selectedItem.id == item.id,
67
+ 's-loyalty-prize-item-selected': !!this.selectedItem && ((_a = this.selectedItem) === null || _a === void 0 ? void 0 : _a.id) == item.id,
65
68
  "s-loyalty-prize-item": true
66
69
  };
67
70
  return h("div", { onClick: () => this.setSelectedPrizeItem(item), class: klass },
@@ -100,7 +103,9 @@ export class SallaLoyalty {
100
103
  h("div", { slot: "title", class: "s-loyalty-after-exchange-title" },
101
104
  this.prizeTitle,
102
105
  " \u00A0 - \u00A0 ",
103
- this.prizePoints),
106
+ this.prizePoints,
107
+ " ",
108
+ salla.lang.get('pages.loyalty_program.point')),
104
109
  h("div", { slot: 'action', class: "s-loyalty-after-exchange-action" },
105
110
  h("salla-button", { class: "s-loyalty-after-exchange-reset", shape: "icon", fill: 'outline', color: "danger", size: "small", onClick: () => this.resetExchange() },
106
111
  h("span", { innerHTML: CancelIcon })))));
@@ -109,17 +114,18 @@ export class SallaLoyalty {
109
114
  * Show loyalty modal
110
115
  */
111
116
  async open() {
117
+ var _a;
112
118
  if (!this.is_loggedin)
113
119
  return salla.event.dispatch('login::open');
114
- this.modal.open();
120
+ (_a = this.modal) === null || _a === void 0 ? void 0 : _a.open();
115
121
  return await salla.loyalty.getProgram()
116
- .then((response) => {
117
- this.loyaltyProgram = response.data;
122
+ .then(response => this.loyaltyProgram = response.data)
123
+ .catch(e => {
124
+ var _a, _b, _c, _d;
125
+ this.hasError = true;
126
+ 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);
118
127
  })
119
- .catch(e => console.log(e))
120
- .finally(() => {
121
- this.modal.stopLoading();
122
- });
128
+ .finally(() => { var _a; return (_a = this.modal) === null || _a === void 0 ? void 0 : _a.stopLoading(); });
123
129
  }
124
130
  /**
125
131
  *
@@ -134,7 +140,9 @@ export class SallaLoyalty {
134
140
  */
135
141
  async resetExchange() {
136
142
  return await salla.loyalty.reset()
137
- .then(() => {
143
+ .then((response) => {
144
+ var _a;
145
+ this.customerPoints = this.customerPoints || ((_a = response.data) === null || _a === void 0 ? void 0 : _a.customer_points);
138
146
  this.prizePoints = undefined;
139
147
  this.prizeTitle = undefined;
140
148
  }).catch(e => console.log(e));
@@ -144,7 +152,7 @@ export class SallaLoyalty {
144
152
  */
145
153
  async openConfirmation() {
146
154
  return await this.modal.close()
147
- .then(() => this.confirmationModal.open())
155
+ .then(() => { var _a; return (_a = this.confirmationModal) === null || _a === void 0 ? void 0 : _a.open(); })
148
156
  .catch(e => console.log(e));
149
157
  }
150
158
  /**
@@ -161,10 +169,13 @@ export class SallaLoyalty {
161
169
  *
162
170
  */
163
171
  async exchangeLoyaltyPoint() {
172
+ var _a;
164
173
  this.buttonLoading = true;
165
- return await salla.loyalty.exchange(this.selectedItem.id)
174
+ return await salla.loyalty.exchange((_a = this.selectedItem) === null || _a === void 0 ? void 0 : _a.id)
166
175
  .then((response) => {
167
- this.loyaltyProgram = response.data;
176
+ var _a, _b;
177
+ this.prizePoints = (_a = response === null || response === void 0 ? void 0 : response.prize) === null || _a === void 0 ? void 0 : _a.points;
178
+ this.prizeTitle = (_b = response === null || response === void 0 ? void 0 : response.prize) === null || _b === void 0 ? void 0 : _b.title;
168
179
  })
169
180
  .catch(e => console.log(e))
170
181
  .finally(() => {
@@ -208,7 +219,7 @@ export class SallaLoyalty {
208
219
  h("salla-skeleton", { height: '15px', width: '100px' }),
209
220
  h("div", { class: "s-loyalty-prize-item-check" },
210
221
  h("salla-skeleton", { height: '1rem', width: '1rem', type: 'circle' })))))))),
211
- !!this.loyaltyProgram ?
222
+ !this.hasError && !!this.loyaltyProgram ?
212
223
  [
213
224
  h("salla-list-tile", { id: 's-loyalty-header', class: "s-loyalty-header" },
214
225
  h("div", { slot: "icon", class: "s-loyalty-header-icon", innerHTML: GiftImg }),
@@ -221,7 +232,7 @@ export class SallaLoyalty {
221
232
  h("salla-swiper", { "space-between-items": "20" }, prize.items.map((item) => this.prizeItem(item)))))),
222
233
  h("salla-button", { disabled: !this.selectedItem, width: "wide", class: "s-loyalty-program-redeem-btn", onClick: () => this.openConfirmation() }, salla.lang.get('pages.loyalty_program.exchange_points')),
223
234
  ]
224
- : h("salla-placeholder", { class: "s-loyalty-placeholder", alignment: "center" })),
235
+ : h("salla-placeholder", { class: "s-loyalty-placeholder", alignment: "center" }, !!this.errorMessage ? h("span", { slot: "description" }, this.errorMessage) : '')),
225
236
  ];
226
237
  }
227
238
  componentDidLoad() {
@@ -367,6 +378,8 @@ export class SallaLoyalty {
367
378
  "selectedItem": {},
368
379
  "askConfirmation": {},
369
380
  "is_loggedin": {},
381
+ "hasError": {},
382
+ "errorMessage": {},
370
383
  "translationLoaded": {}
371
384
  }; }
372
385
  static get methods() { return {
@@ -1,4 +1,9 @@
1
1
  /*
2
2
  * Salla Modal Component: popup modal used in most parts of the theme
3
3
  * You can use these classes to target the elements in the component.
4
- */
4
+ */
5
+ @media screen and (max-width: 470px) {
6
+ .modal-is-open {
7
+ position: fixed;
8
+ }
9
+ }
@@ -7,6 +7,7 @@ import SpecialDiscountIcon from '../../assets/svg/special-discount.svg';
7
7
  import KeyboardArrowRightIcon from "../../assets/svg/keyboard_arrow_right.svg";
8
8
  import KeyboardArrowLeftIcon from "../../assets/svg/keyboard_arrow_left.svg";
9
9
  import Tag from "../../assets/svg/tag.svg";
10
+ import Cart2 from '../../assets/svg/cart2.svg';
10
11
  /**
11
12
  * @slot header - The top of the popup, has replaceable props `{name}`, `{message}`.
12
13
  * @slot product - Replaces product card, has replaceable props `{name}`, `{url}`, `{image}`, `{price}`.
@@ -16,8 +17,10 @@ export class SallaOfferModal {
16
17
  constructor() {
17
18
  var _a, _b;
18
19
  this.offer = null;
20
+ this.hasError = false;
19
21
  this.translationLoaded = false;
20
22
  Helper.setHost(this.host);
23
+ salla.event.on('offer-modal::open', (product_id) => this.open(product_id));
21
24
  salla.lang.onLoaded(() => {
22
25
  this.translationLoaded = true;
23
26
  });
@@ -37,8 +40,15 @@ export class SallaOfferModal {
37
40
  */
38
41
  async open(product_id) {
39
42
  //TODO:: make sure there is only one offer
40
- return salla.product.offers(product_id)
41
- .then(response => this.showOffer(response.data[0]));
43
+ this.modal.open();
44
+ return salla.api.withoutNotifier(salla.product.offers(product_id))
45
+ .then(response => this.showOffer(response.data[0]))
46
+ .catch(e => {
47
+ var _a, _b, _c, _d;
48
+ this.hasError = true;
49
+ 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);
50
+ })
51
+ .finally(() => setTimeout(() => { this.modal.stopLoading(); }, 1000));
42
52
  }
43
53
  /**
44
54
  * Show offer details
@@ -49,7 +59,6 @@ export class SallaOfferModal {
49
59
  this.offer_name = offer.name;
50
60
  this.offer_message = offer.message;
51
61
  this.modal.setTitle(this.offer_name);
52
- return this.modal.open();
53
62
  }
54
63
  rememberMe(event) {
55
64
  salla.storage.set('remember-offer-' + this.offer.id, event.target.checked);
@@ -71,10 +80,25 @@ export class SallaOfferModal {
71
80
  }
72
81
  render() {
73
82
  var _a, _b;
74
- return h("salla-modal", { "sub-title-first": true, "sub-title": this.offer_message, ref: modal => this.modal = modal, "is-loading": this.offer === null },
75
- h("span", { slot: 'icon', class: "s-offer-modal-header-icon", innerHTML: SpecialDiscountIcon }),
76
- this.offer !== null
77
- ? [h("div", { class: "s-offer-modal-scrolled-slider-wrap" },
83
+ return h("salla-modal", { "sub-title-first": true, "has-skeleton": true, "sub-title": this.offer_message, ref: modal => this.modal = modal, isLoading: true },
84
+ h("div", { slot: 'loading' },
85
+ h("div", { class: "s-offer-modal-skeleton" },
86
+ h("div", { class: "s-offer-modal-skeleton-header" },
87
+ h("salla-skeleton", { type: 'circle', height: '80px', width: '80px' }),
88
+ h("salla-skeleton", { height: '15px', width: '50%' }),
89
+ h("salla-skeleton", { height: '10px', width: '30%' })),
90
+ h("div", { class: "s-offer-modal-skeleton-items" }, [...Array(3)].map(() => h("div", { class: "s-offer-modal-skeleton-item" },
91
+ h("salla-skeleton", { height: '9rem' }),
92
+ h("div", { class: "s-offer-modal-skeleton-item-title" },
93
+ h("salla-skeleton", { height: '15px', width: '100%' })),
94
+ h("div", { class: "s-offer-modal-skeleton-item-subtitle" },
95
+ h("salla-skeleton", { height: '9px', width: '50%' }),
96
+ h("div", { innerHTML: Cart2 }))))),
97
+ h("div", { class: "s-offer-modal-skeleton-footer" },
98
+ h("salla-skeleton", { height: '15px', width: '50%' }),
99
+ h("salla-skeleton", { height: '15px', width: '30%' })))),
100
+ !this.hasError && this.offer !== null
101
+ ? [h("span", { slot: 'icon', class: "s-offer-modal-header-icon", innerHTML: SpecialDiscountIcon }), h("div", { class: "s-offer-modal-scrolled-slider-wrap" },
78
102
  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
79
103
  ? 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
80
104
  .replace(/\{tagIcon\}/g, Tag)
@@ -104,7 +128,8 @@ export class SallaOfferModal {
104
128
  h("input", { type: "checkbox", onChange: e => this.rememberMe(e), class: "s-offer-modal-remember-input" }),
105
129
  "\u00A0 ",
106
130
  salla.lang.get('common.elements.remember_my_choice'))),
107
- ] : '');
131
+ ] :
132
+ h("salla-placeholder", { class: "s-loyalty-placeholder", alignment: "center" }, !!this.errorMessage ? h("span", { slot: "description" }, this.errorMessage) : ''));
108
133
  }
109
134
  componentDidRender() {
110
135
  // Sooo mini Slider
@@ -162,6 +187,8 @@ export class SallaOfferModal {
162
187
  "offer": {},
163
188
  "offer_name": {},
164
189
  "offer_message": {},
190
+ "hasError": {},
191
+ "errorMessage": {},
165
192
  "translationLoaded": {}
166
193
  }; }
167
194
  static get methods() { return {
@@ -192,7 +219,7 @@ export class SallaOfferModal {
192
219
  },
193
220
  "showOffer": {
194
221
  "complexType": {
195
- "signature": "(offer: any) => Promise<HTMLElement>",
222
+ "signature": "(offer: any) => Promise<void>",
196
223
  "parameters": [{
197
224
  "tags": [{
198
225
  "name": "param",
@@ -203,12 +230,9 @@ export class SallaOfferModal {
203
230
  "references": {
204
231
  "Promise": {
205
232
  "location": "global"
206
- },
207
- "HTMLElement": {
208
- "location": "global"
209
233
  }
210
234
  },
211
- "return": "Promise<HTMLElement>"
235
+ "return": "Promise<void>"
212
236
  },
213
237
  "docs": {
214
238
  "text": "Show offer details",