@salla.sa/twilight-components 1.0.16 → 1.0.17

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 (93) hide show
  1. package/dist/cjs/Helper-8852feaa.js +23 -0
  2. package/dist/cjs/index-0b5b5867.js +1656 -0
  3. package/dist/cjs/index.cjs.js +13 -0
  4. package/dist/cjs/loader.cjs.js +21 -0
  5. package/dist/cjs/salla-branches.cjs.entry.js +92 -0
  6. package/dist/cjs/salla-button_4.cjs.entry.js +299 -0
  7. package/dist/cjs/salla-localization.cjs.entry.js +80 -0
  8. package/dist/cjs/salla-login-342876b9.js +118 -0
  9. package/dist/cjs/salla-offer.cjs.entry.js +25 -0
  10. package/dist/cjs/salla-product-availability.cjs.entry.js +75 -0
  11. package/dist/cjs/salla-rating.cjs.entry.js +300 -0
  12. package/dist/cjs/salla-search-28da4616.js +81 -0
  13. package/dist/cjs/salla-search.cjs.entry.js +11 -0
  14. package/dist/cjs/twilight-components.cjs.js +19 -0
  15. package/dist/collection/Helpers/Helper.js +19 -0
  16. package/dist/collection/collection-manifest.json +21 -0
  17. package/dist/collection/components/generate-summary.js +35 -0
  18. package/dist/collection/components/salla-branches/salla-branches.css +12 -0
  19. package/dist/collection/components/salla-branches/salla-branches.js +233 -0
  20. package/dist/collection/components/salla-button/salla-button.css +3 -0
  21. package/dist/collection/components/salla-button/salla-button.js +246 -0
  22. package/dist/collection/components/salla-localization/salla-localization.js +206 -0
  23. package/dist/collection/components/salla-login/salla-login.js +348 -0
  24. package/dist/collection/components/salla-modal/salla-modal.js +459 -0
  25. package/dist/collection/components/salla-offer/salla-offer.js +40 -0
  26. package/dist/collection/components/salla-product-availability/salla-product-availability.js +331 -0
  27. package/dist/collection/components/salla-rating/salla-rating.css +7 -0
  28. package/dist/collection/components/salla-rating/salla-rating.js +483 -0
  29. package/dist/collection/components/salla-search/salla-search.js +132 -0
  30. package/dist/collection/components/salla-verify/salla-verify.js +238 -0
  31. package/dist/collection/index.js +2 -0
  32. package/dist/collection/interfaces/colors.js +1 -0
  33. package/dist/collection/interfaces/index.js +2 -0
  34. package/dist/collection/interfaces/ratio.js +1 -0
  35. package/dist/collection/plugins/tailwind-theme/generator.js +62 -0
  36. package/dist/collection/plugins/tailwind-theme/index.js +26 -0
  37. package/dist/{twilight-components → esm}/Helper-81ac9a8c.js +0 -0
  38. package/dist/esm/index-8b97d225.js +1628 -0
  39. package/dist/esm/index.js +4 -0
  40. package/dist/esm/loader.js +17 -0
  41. package/dist/esm/polyfills/core-js.js +11 -0
  42. package/dist/esm/polyfills/css-shim.js +1 -0
  43. package/dist/esm/polyfills/dom.js +79 -0
  44. package/dist/esm/polyfills/es5-html-element.js +1 -0
  45. package/dist/esm/polyfills/index.js +34 -0
  46. package/dist/esm/polyfills/system.js +6 -0
  47. package/dist/{twilight-components → esm}/salla-branches.entry.js +6 -6
  48. package/dist/esm/salla-button_4.entry.js +292 -0
  49. package/dist/esm/salla-localization.entry.js +76 -0
  50. package/dist/esm/salla-login-32d25ffa.js +116 -0
  51. package/dist/esm/salla-offer.entry.js +21 -0
  52. package/dist/{twilight-components → esm}/salla-product-availability.entry.js +2 -2
  53. package/dist/{twilight-components → esm}/salla-rating.entry.js +73 -70
  54. package/dist/{twilight-components/salla-search-5338c0a1.js → esm/salla-search-f552c487.js} +1 -1
  55. package/dist/esm/salla-search.entry.js +3 -0
  56. package/dist/esm/twilight-components.js +17 -0
  57. package/dist/index.cjs.js +1 -0
  58. package/dist/index.js +1 -0
  59. package/dist/twilight-components/index.esm.js +1 -4
  60. package/dist/twilight-components/p-33990e49.entry.js +1 -0
  61. package/dist/twilight-components/p-36683152.js +1 -0
  62. package/dist/twilight-components/p-3cfede65.entry.js +1 -0
  63. package/dist/twilight-components/p-648661c8.entry.js +1 -0
  64. package/dist/twilight-components/p-93c3ac79.js +1 -0
  65. package/dist/twilight-components/p-9bc28e0c.js +1 -0
  66. package/dist/twilight-components/p-a923a51e.entry.js +1 -0
  67. package/dist/twilight-components/p-bc278b0e.entry.js +1 -0
  68. package/dist/twilight-components/p-cb1c59a2.js +1 -0
  69. package/dist/twilight-components/p-fa04c4b6.entry.js +1 -0
  70. package/dist/twilight-components/p-fa2f0e64.entry.js +1 -0
  71. package/dist/twilight-components/twilight-components.css +1 -3
  72. package/dist/twilight-components/twilight-components.esm.js +1 -125
  73. package/dist/types/components/salla-button/salla-button.d.ts +3 -2
  74. package/dist/types/components/salla-localization/salla-localization.d.ts +8 -0
  75. package/dist/types/components/salla-login/salla-login.d.ts +39 -0
  76. package/dist/types/components/salla-modal/salla-modal.d.ts +12 -4
  77. package/dist/types/components/salla-offer/salla-offer.d.ts +8 -0
  78. package/dist/types/components/salla-rating/salla-rating.d.ts +17 -2
  79. package/dist/types/components/salla-verify/salla-verify.d.ts +16 -6
  80. package/dist/types/components.d.ts +94 -8
  81. package/package.json +2 -1
  82. package/dist/twilight-components/app-globals-0f993ce5.js +0 -3
  83. package/dist/twilight-components/css-shim-a64b8820.js +0 -4
  84. package/dist/twilight-components/dom-d08ba8aa.js +0 -73
  85. package/dist/twilight-components/index-8966d27f.js +0 -3010
  86. package/dist/twilight-components/salla-button.entry.js +0 -73
  87. package/dist/twilight-components/salla-localization.entry.js +0 -73
  88. package/dist/twilight-components/salla-login-4d620368.js +0 -12
  89. package/dist/twilight-components/salla-login.entry.js +0 -2
  90. package/dist/twilight-components/salla-modal.entry.js +0 -91
  91. package/dist/twilight-components/salla-search.entry.js +0 -3
  92. package/dist/twilight-components/salla-verify.entry.js +0 -92
  93. package/dist/twilight-components/shadow-css-bc14d9fd.js +0 -389
@@ -0,0 +1,292 @@
1
+ import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-8b97d225.js';
2
+ import { H as Helper } from './Helper-81ac9a8c.js';
3
+ export { S as salla_login } from './salla-login-32d25ffa.js';
4
+
5
+ const sallaButtonCss = ":host{display:block}";
6
+
7
+ const SallaButton = class {
8
+ constructor(hostRef) {
9
+ registerInstance(this, hostRef);
10
+ this.btnStyle = 'primary';
11
+ this.loading = false;
12
+ this.disabled = false;
13
+ this.loaderPosition = 'before';
14
+ this.wide = false;
15
+ this.hostAttributes = {};
16
+ //============= Initiate Button Attributes =============//
17
+ for (let i = 0; i < this.host.attributes.length; i++) {
18
+ this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
19
+ }
20
+ this.hostAttributes.type = this.hostAttributes.type || 'button';
21
+ this.hostAttributes.class += ' s-button-btn btn--has-loading'
22
+ + ' s-button-' + this.btnStyle
23
+ + (this.wide ? ' s-button-wide ' : '')
24
+ + ' loader-' + this.loaderPosition
25
+ + (this.loaderPosition == 'before' ? ' s-button-loader-after' : '');
26
+ delete this.hostAttributes['btn-style'];
27
+ delete this.hostAttributes['id'];
28
+ if (this.wide) {
29
+ this.host.classList.add('s-button-wide');
30
+ }
31
+ }
32
+ async load() {
33
+ if (this.loaderPosition == 'center')
34
+ this.text.classList.add('s-button-hide');
35
+ this.host.setAttribute('loading', '');
36
+ return this.host;
37
+ }
38
+ async stop() {
39
+ this.host.removeAttribute('loading');
40
+ return this.host;
41
+ }
42
+ async disable() {
43
+ this.host.setAttribute('disabled', '');
44
+ }
45
+ async enable() {
46
+ this.host.removeAttribute('disabled');
47
+ }
48
+ handleVisible(newKind, oldKind) {
49
+ //todo::use united styles
50
+ this.btn.classList.remove('btn-' + oldKind);
51
+ this.btn.classList.add('btn-' + newKind);
52
+ }
53
+ handleLoading(newVal) {
54
+ //todo::use united styles
55
+ Helper.toggleElement(this.btn, 'btn--is-loading', 'btn--no-loading', () => newVal);
56
+ }
57
+ render() {
58
+ return (
59
+ //TODO:: use HOST then fake button behaviours
60
+ h(Host, { class: "s-button-host-tag" }, h("button", Object.assign({ ref: btn => this.btn = btn, disabled: this.disabled }, this.hostAttributes), h("span", { class: "s-button-text", ref: el => this.text = el }, h("slot", null)), this.loading ? h("span", { class: {
61
+ //todo::use united styles
62
+ 's-button-loader': true,
63
+ 's-button-loader-start': this.loaderPosition === 'start',
64
+ 's-button-loader-end': this.loaderPosition === 'end',
65
+ 's-button-loader-center': this.loaderPosition === 'center',
66
+ } }) : '')));
67
+ }
68
+ get host() { return getElement(this); }
69
+ static get watchers() { return {
70
+ "btnStyle": ["handleVisible"],
71
+ "loading": ["handleLoading"]
72
+ }; }
73
+ };
74
+ SallaButton.style = sallaButtonCss;
75
+
76
+ const SallaModal = class {
77
+ constructor(hostRef) {
78
+ registerInstance(this, hostRef);
79
+ this.modalOpened = createEvent(this, "modalOpened", 7);
80
+ this.modalClosed = createEvent(this, "modalClosed", 7);
81
+ var _a;
82
+ //todo:: unite three colors (error, success, primary) in one prop
83
+ this.error = false;
84
+ this.success = false;
85
+ this.primary = false;
86
+ this.isClosable = true;
87
+ this.width = 'md';
88
+ this.visible = false;
89
+ this.isLoading = false;
90
+ this.subTitleFirst = false;
91
+ this.subTitle = '';
92
+ this.icon = '';
93
+ this.imageIcon = '';
94
+ Helper.setHost(this.host);
95
+ salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
96
+ salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
97
+ this.title = this.host.title;
98
+ this.host.removeAttribute('title');
99
+ (_a = Helper.getElement('[slot=body]')) === null || _a === void 0 ? void 0 : _a.classList.add('s-modal-body', 's-modal-' + this.width);
100
+ }
101
+ handleVisible(newValue) {
102
+ if (!newValue) {
103
+ this.toggleModal(false);
104
+ this.modalClosed.emit();
105
+ return;
106
+ }
107
+ this.host.classList.remove('hidden');
108
+ setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
109
+ this.modalOpened.emit();
110
+ }
111
+ async show() {
112
+ this.host.setAttribute('visible', '');
113
+ return this.host;
114
+ }
115
+ async hide() {
116
+ this.host.removeAttribute('visible');
117
+ return this.host;
118
+ }
119
+ async setTitle(title) {
120
+ this.title = title;
121
+ return this.host;
122
+ }
123
+ async loading() {
124
+ this.isLoading = true;
125
+ return this.host;
126
+ }
127
+ async stopLoading() {
128
+ this.isLoading = false;
129
+ return this.host;
130
+ }
131
+ toggleModal(isOpen) {
132
+ Helper
133
+ // .toggleElement(this.host.querySelector('.s-modal-body'), 's-modal-entering', 's-modal-leaving', () => isOpen)
134
+ .toggleElement(this.host.querySelector('[slot=body]') || this.host, 's-modal-entering', 's-modal-leaving', () => isOpen)
135
+ .toggleElement(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
136
+ //todo:: use united class names
137
+ .toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
138
+ if (!isOpen) {
139
+ setTimeout(() => this.host.classList.add('hidden'), 350);
140
+ }
141
+ }
142
+ closeModal() {
143
+ if (!this.isClosable) {
144
+ return;
145
+ }
146
+ this.host.removeAttribute('visible');
147
+ }
148
+ //todo:: pref for each modal
149
+ render() {
150
+ this.host.id = this.host.id || 'salla-modal';
151
+ return (
152
+ //todo:: use suitable class name instead of hidden
153
+ h(Host, { class: 's-modal-container hidden', "aria-modal": "true", role: "dialog" }, h("div", { class: "s-modal-wrapper" }, h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }), h("span", { class: "s-modal-spacer" }, "\u200B"), h("slot", { name: "body" }, h("div", { class: 's-modal-body ' + 's-modal-' + this.width, slot: "body" }, this.isLoading
154
+ ? h("span", null, "Loading...")
155
+ : [h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.icon != '' || this.imageIcon != '' } }, this.isClosable ?
156
+ //todo:: remove cursor-pointer
157
+ h("button", { class: "s-modal-close cursor-pointer", onClick: () => this.closeModal(), type: "button" }, h("span", { class: "sicon-cancel" }))
158
+ : '', this.error || this.success || this.icon
159
+ ? h("div", { class: {
160
+ 's-modal-icon': true,
161
+ 's-modal-bg-error': this.error,
162
+ 's-modal-bg-success': this.success,
163
+ 's-modal-bg-normal': !this.error && !this.success,
164
+ 's-modal-bg-primary': this.primary
165
+ } }, h("i", { class: {
166
+ [this.icon]: true,
167
+ 's-modal-text-error': this.error,
168
+ 's-modal-text-success': this.success,
169
+ } }))
170
+ : this.imageIcon ?
171
+ h("img", { class: "s-modal-header-img", src: this.imageIcon })
172
+ : '', this.title || this.subTitle ?
173
+ h("div", { class: "s-modal-header-content" }, h("div", { class: { 's-modal-title': true, 's-modal-title-below': this.subTitleFirst }, innerHTML: this.title }), h("p", { class: { 's-modal-sub-title': true }, innerHTML: this.subTitle }))
174
+ : ''),
175
+ h("slot", null),
176
+ h("slot", { name: "footer" })
177
+ ])))));
178
+ }
179
+ get host() { return getElement(this); }
180
+ static get watchers() { return {
181
+ "visible": ["handleVisible"]
182
+ }; }
183
+ };
184
+
185
+ const SallaVerify = class {
186
+ constructor(hostRef) {
187
+ registerInstance(this, hostRef);
188
+ this.verified = createEvent(this, "verified", 7);
189
+ this.url = 'profile/verify-mobile';
190
+ this.by = 'sms';
191
+ this.autoReload = true;
192
+ Helper.setHost(this.host);
193
+ if (this.withoutModal) {
194
+ this.modal = { show: () => '', hide: () => '' };
195
+ }
196
+ else {
197
+ salla.event.on('profile::verify.mobile', data => this.show(data));
198
+ }
199
+ }
200
+ async getCode() {
201
+ return this.code.value;
202
+ }
203
+ async show(data) {
204
+ this.data = data;
205
+ this.resendTimer();
206
+ this.otpInputs = document.querySelectorAll('.s-verify-input');
207
+ this.otpInputs[0].focus();
208
+ Helper.on('input', '.s-verify-input', e => salla.helpers.digitsOnly(e.target));
209
+ Helper.onKeyUp('.s-verify-input', event => {
210
+ var _a, _b, _c, _d;
211
+ let key = event.keyCode || event.charCode;
212
+ if (event.target.value) {
213
+ (_a = event.target.nextElementSibling) === null || _a === void 0 ? void 0 : _a.focus();
214
+ (_b = event.target.nextElementSibling) === null || _b === void 0 ? void 0 : _b.select();
215
+ }
216
+ else if ([8, 46].includes(key)) {
217
+ (_c = event.target.previousElementSibling) === null || _c === void 0 ? void 0 : _c.focus();
218
+ (_d = event.target.previousElementSibling) === null || _d === void 0 ? void 0 : _d.select();
219
+ }
220
+ this.toggleOTPSubmit();
221
+ });
222
+ Helper.on('paste', '.s-verify-input', event => {
223
+ let text = event.clipboardData.getData('text').toArabicDigits().replace(/[^0-9.]/g, '').replace('..', '.');
224
+ this.otpInputs.forEach((input, i) => input.value = text[i] || '');
225
+ this.toggleOTPSubmit();
226
+ setTimeout(() => this.otpInputs[3].focus(), 100);
227
+ });
228
+ return this.modal.show();
229
+ }
230
+ toggleOTPSubmit() {
231
+ let otp = [];
232
+ this.otpInputs.forEach(input => input.value && otp.push(input.value));
233
+ this.code.value = otp.join('');
234
+ if (otp.length === 4) {
235
+ this.btn.removeAttribute('disabled');
236
+ this.btn.click();
237
+ return;
238
+ }
239
+ this.btn.setAttribute('disabled', '');
240
+ }
241
+ resendTimer() {
242
+ Helper.showElement(this.resendMessage).hideElement(this.resend);
243
+ let resendAfter = 30;
244
+ let timerId = setInterval(() => {
245
+ if (resendAfter === -1) {
246
+ clearTimeout(timerId);
247
+ Helper.hideElement(this.resendMessage).showElement(this.resend);
248
+ }
249
+ else {
250
+ this.timer.innerHTML = `${resendAfter >= 10 ? resendAfter : '0' + resendAfter} : 00`;
251
+ resendAfter--;
252
+ }
253
+ }, 1000);
254
+ }
255
+ resendCode() {
256
+ return this.btn.stop()
257
+ .then(() => this.btn.disable())
258
+ .then(() => {
259
+ this.otpInputs.forEach(input => input.value = '');
260
+ this.otpInputs[0].focus();
261
+ })
262
+ .then(() => salla.api.auth.resend(Object.assign({ resend_by: this.by }, this.data)))
263
+ .then(() => this.resendTimer())
264
+ .catch(() => this.resendTimer());
265
+ }
266
+ submit() {
267
+ return this.btn.load()
268
+ .then(() => this.btn.disable())
269
+ .then(() => salla.document.api.request(this.url, Object.assign({ code: this.code.value }, this.data)))
270
+ .then(response => this.verified.emit(response))
271
+ .then(() => this.btn.stop() && this.btn.disable())
272
+ .then(() => this.modal.hide())
273
+ .then(() => this.autoReload && window.location.reload())
274
+ .catch(() => this.btn.stop() && this.btn.enable());
275
+ }
276
+ render() {
277
+ return this.withoutModal ? this.myBody() :
278
+ h("salla-modal", { id: "s-verify", ref: modal => this.modal = modal, title: salla.lang.get('pages.profile.verify_title') }, this.myBody());
279
+ }
280
+ myBody() {
281
+ return [
282
+ h("div", { class: "s-verify-message", innerHTML: salla.lang.get('pages.profile.verify_message') }),
283
+ h("label", { class: "s-verify-label" }, salla.lang.get('pages.profile.verify_placeholder')),
284
+ h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }),
285
+ h("div", { class: "s-verify-codes", dir: "ltr" }, [1, 2, 3, 4].map(() => h("input", { type: "text", maxlength: "1", class: "s-verify-input", required: true }))),
286
+ h("div", { slot: "footer", class: "s-verify-footer" }, h("salla-button", { class: "s-verify-submit", disabled: true, onClick: () => this.submit(), ref: b => this.btn = b }, salla.lang.get('pages.profile.verify')), h("p", { class: "s-verify-resend-message", ref: el => this.resendMessage = el }, salla.lang.get('blocks.header.resend_after'), h("b", { class: "s-verify-timer", ref: el => this.timer = el })), h("a", { href: "#", class: "s-verify-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit')))
287
+ ];
288
+ }
289
+ get host() { return getElement(this); }
290
+ };
291
+
292
+ export { SallaButton as salla_button, SallaModal as salla_modal, SallaVerify as salla_verify };
@@ -0,0 +1,76 @@
1
+ import { r as registerInstance, h, g as getElement } from './index-8b97d225.js';
2
+ import { H as Helper } from './Helper-81ac9a8c.js';
3
+
4
+ const SallaLocalization = class {
5
+ constructor(hostRef) {
6
+ registerInstance(this, hostRef);
7
+ var _a, _b;
8
+ this.language = salla.config.language || {};
9
+ this.currency = salla.config.currency || {};
10
+ this.languagesTitle = salla.lang.get('common.titles.language');
11
+ this.currenciesTitle = salla.lang.get('common.titles.currency');
12
+ this.ok = salla.lang.get('common.elements.ok');
13
+ Helper.setHost(this.host);
14
+ salla.event.on('localization::show', () => this.show());
15
+ /**
16
+ * letting developer to insert his own slot like:
17
+ * <salla-localization>
18
+ * <div slot="language">...{name}....</div>
19
+ * <div slot="currency">...{name}....</div>
20
+ * </salla-localization>
21
+ * Because scoped templates not supported in stencil );
22
+ * we made a workaround to pass language & currency attributes, then replace names in rendering
23
+ */
24
+ this.languageSlot = ((_a = Helper.getElement('[slot="language"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '<label class="s-localization-label" for="lang-{code}"><span>{name}</span><div class="s-localization-flag flag iti__flag iti__{country_code}"></div></label>';
25
+ this.currencySlot = ((_b = Helper.getElement('[slot="currency"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || '<label class="s-localization-label" for="currency-{code}"><span>{name}</span><small class="s-localization-currency">{code}</small></label>';
26
+ }
27
+ async show() {
28
+ return this.modal.show();
29
+ }
30
+ async hide() {
31
+ return this.modal.hide();
32
+ }
33
+ onChangeCurrency(event) {
34
+ this.currency = salla.config.currencies.filter(currency => currency.code == event.target.value)[0];
35
+ }
36
+ onChangeLanguage(event) {
37
+ this.language = salla.config.languages.filter(lang => lang.code == event.target.value)[0];
38
+ }
39
+ async submit() {
40
+ let url;
41
+ console.log('this.currency.code::::', this.currency, this.currency.code);
42
+ this.btn.load()
43
+ .then(() => (this.currency.code === salla.config.currency.code) || ((url = window.location.href) && salla.currency.api.change(this.currency.code)))
44
+ .then(() => (this.language.code === salla.config.language.code) || (url = this.language.url))
45
+ .then(() => this.btn.stop())
46
+ .then(() => this.hide())
47
+ .then(() => url && (window.location.href = url));
48
+ }
49
+ render() {
50
+ return (h("salla-modal", { id: "salla-localization", class: "hidden", ref: modal => this.modal = modal, "modal-width": "xs" }, h("div", { slot: "header" }, h("slot", { name: "header" })), h("div", { class: "s-localization-inner" }, salla.config.languages ?
51
+ h("div", { class: "s-localization-section" }, h("label", { class: "s-localization-title" }, this.languagesTitle), h("div", { class: "s-localization-section-inner" }, salla.config.languages.length < 6 ?
52
+ salla.config.languages.map(lang => h("div", { class: "s-localization-item" }, h("input", { class: "s-localization-input", type: "radio", checked: this.language.code == lang.code, onChange: () => this.language = lang, name: "language", id: 'lang-' + lang.code.toLowerCase(), value: lang.code }), h("div", { id: "language-slot", innerHTML: this.languageSlot
53
+ .replace(/\{name\}/g, lang.name)
54
+ .replace(/\{code\}/g, lang.code)
55
+ .replace(/\{country_code\}/g, lang.country_code) }))) :
56
+ h("select", { class: "s-branches-select", name: "currency", onChange: e => this.onChangeLanguage(e) }, salla.config.languages.map(lang => h("option", { value: lang.code, selected: this.language.code == lang.code }, lang.name)))))
57
+ : '', salla.config.currencies ?
58
+ h("div", { class: "s-localization-section" }, h("label", { class: "s-localization-title" }, this.currenciesTitle), h("div", { class: "s-localization-section-inner" }, salla.config.currencies.length < 6 ?
59
+ salla.config.currencies.map(currency => h("div", { class: "s-localization-item" }, h("input", { class: "s-localization-input", type: "radio", name: "currency", checked: this.currency.code == currency.code, onChange: () => this.currency = currency, id: 'currency-' + currency.code, value: currency.code }), h("div", { id: "currency-slot", innerHTML: this.currencySlot
60
+ .replace(/\{name\}/g, currency.name)
61
+ .replace(/\{code\}/g, currency.code)
62
+ .replace(/\{country_code\}/g, currency.country_code) }))) :
63
+ h("select", { class: "s-branches-select", name: "currency", onChange: e => this.onChangeCurrency(e) }, salla.config.currencies.map(currency => h("option", { value: currency.code, selected: this.currency.code == currency.code }, currency.name)))))
64
+ : ''), h("slot", { name: "footer" }, h("salla-button", { wide: true, ref: btn => this.btn = btn, onClick: () => this.submit() }, this.ok))));
65
+ }
66
+ /**
67
+ * to reduce dom levels we will move slot data into the parent dom
68
+ */
69
+ componentDidRender() {
70
+ this.host.querySelectorAll('#currency-slot').forEach(el => el.replaceWith(el.firstChild));
71
+ this.host.querySelectorAll('#language-slot').forEach(el => el.replaceWith(el.firstChild));
72
+ }
73
+ get host() { return getElement(this); }
74
+ };
75
+
76
+ export { SallaLocalization as salla_localization };
@@ -0,0 +1,116 @@
1
+ import { r as registerInstance, h, g as getElement } from './index-8b97d225.js';
2
+ import { H as Helper } from './Helper-81ac9a8c.js';
3
+
4
+ const SallaLogin = class {
5
+ constructor(hostRef) {
6
+ registerInstance(this, hostRef);
7
+ this.regType = 'sms';
8
+ this.loginTypeTitle = salla.lang.get('blocks.header.select_login_way');
9
+ this.loginText = salla.lang.get('blocks.header.login');
10
+ this.smsLabel = salla.lang.get('blocks.header.sms');
11
+ this.mobileLabel = salla.lang.get('common.elements.mobile');
12
+ this.emailLabel = salla.lang.get('common.elements.email');
13
+ this.enterText = salla.lang.get('blocks.header.enter');
14
+ this.bySMSText = salla.lang.get('blocks.header.login_by_sms');
15
+ this.byEmailText = salla.lang.get('blocks.header.login_by_email');
16
+ this.backText = salla.lang.get('common.elements.back');
17
+ this.title = this.host.title || salla.lang.get('blocks.header.login');
18
+ this.host.removeAttribute('title');
19
+ salla.auth.event.onVerificationFailed(() => {
20
+ //
21
+ });
22
+ }
23
+ /**
24
+ * @param {CustomEvent|{details:{case:'new_customer'|'authenticated', redirect_url:string|null}}} event
25
+ */
26
+ onVerified(event) {
27
+ if (!event.detail.case) {
28
+ console.log('verified but without case!');
29
+ return;
30
+ }
31
+ if (event.detail.case === "new_customer") {
32
+ return this.showTab(this.tab5);
33
+ }
34
+ //TODO::It looks that is this workaround🤔
35
+ if (salla.auth.event.getTypeActionOnVerified() !== 'redirect') {
36
+ return;
37
+ }
38
+ if (event.redirect_url) {
39
+ return window.location.href = event.redirect_url;
40
+ }
41
+ window.location.reload();
42
+ }
43
+ onModalClose() {
44
+ this.showTab(this.tab1);
45
+ }
46
+ async show() {
47
+ return this.modal.show();
48
+ }
49
+ showTab(tab) {
50
+ [this.tab1, this.tab2, this.tab3, this.tab4, this.tab5].map(el => Helper.toggleElement(el, 'visible', 'hidden', () => el == tab));
51
+ if ([this.tab2, this.tab3].includes(tab)) {
52
+ this.regType = tab === this.tab2 ? 'sms' : 'email';
53
+ }
54
+ let isRegistrationTab = tab == this.tab5;
55
+ this.modal.setTitle(isRegistrationTab ? salla.lang.get('common.titles.registration') : this.title);
56
+ if (!isRegistrationTab) {
57
+ Helper.toggleElement(this.regMobileBlock, 's-hidden', 's-block', () => this.regType === 'sms')
58
+ .toggleElement(this.regEmailBlock, 's-hidden', 's-block', () => this.regType === 'email');
59
+ }
60
+ return this;
61
+ }
62
+ loginByEmail() {
63
+ if (!Helper.isValidEmail(this.email.value)) {
64
+ this.email.classList.add('s-has-error');
65
+ this.email.nextElementSibling['innerText'] = '* ' + salla.lang.get('common.elements.email_is_valid');
66
+ return;
67
+ }
68
+ this.email.nextElementSibling['innerText'] = '';
69
+ this.email.classList.remove('s-has-error');
70
+ salla.auth.api.login({ type: 'email', email: this.email.value })
71
+ .then(() => this.showTab(this.tab4))
72
+ .then(() => (this.tab4.by = 'email') && (this.tab4.url = 'auth/email/verify'))
73
+ .then(() => this.tab4.show({ email: this.email.value }));
74
+ }
75
+ loginBySMS() {
76
+ if (this.mobile.value.length < 6) {
77
+ this.mobile.classList.add('s-has-error');
78
+ this.mobile.nextElementSibling['innerText'] = '* ' + salla.lang.get('mobile_app.strings.incorrect_mobile');
79
+ return;
80
+ }
81
+ this.mobile.nextElementSibling['innerText'] = '';
82
+ this.mobile.classList.remove('s-has-error');
83
+ salla.auth.api.login({ type: 'sms', mobile: this.mobile.value })
84
+ .then(() => this.showTab(this.tab4))
85
+ .then(() => (this.tab4.by = 'sms') && (this.tab4.url = 'auth/mobile/verify'))
86
+ .then(() => this.tab4.show({ mobile: this.mobile.value, country_code: 'SA' }));
87
+ }
88
+ //TODO:: if it's enter, go submit
89
+ typing({ target }) {
90
+ target.type === 'tel' && salla.helpers.digitsOnly(target);
91
+ target.classList.remove('s-has-error');
92
+ target.nextElementSibling.innerText = '';
93
+ }
94
+ newUser() {
95
+ this.tab4.getCode()
96
+ .then(code => salla.auth.api.register({
97
+ first_name: this.firstName.value,
98
+ last_name: this.lastName.value,
99
+ phone: this.regMobile.value || this.mobile.value,
100
+ email: this.regEmail.value || this.email.value,
101
+ country_code: '',
102
+ country_key: '',
103
+ code: code,
104
+ verified_by: this.regType,
105
+ }));
106
+ }
107
+ render() {
108
+ return (h("salla-modal", { id: "salla-login", title: this.title, ref: modal => this.modal = modal, width: "xs" }, h("div", { class: "s-login-tab", ref: tab => this.tab1 = tab }, h("p", { class: "s-login-sub-title" }, this.loginTypeTitle), h("a", { href: "#", class: "s-login-main-btn", onClick: () => this.showTab(this.tab2) }, h("i", { class: "s-login-main-btn-icon sicon-phone" }), h("span", { class: "s-login-main-btn-text" }, this.smsLabel), h("i", { class: "main-btn-arrow sicon-keyboard_arrow_left" })), h("a", { href: "#", class: "s-login-main-btn", onClick: () => this.showTab(this.tab3) }, h("i", { class: "s-login-main-btn-icon sicon-mail" }), h("span", { class: "s-login-main-btn-text" }, this.emailLabel), h("i", { class: "main-btn-arrow sicon-keyboard_arrow_left" }))), h("div", { class: "s-login-tab", ref: tab => this.tab2 = tab }, h("label", { class: "s-login-label" }, this.mobileLabel), h("input", { type: "tel", ref: el => this.mobile = el, onInput: this.typing, placeholder: "5xx xxx xxx", class: "s-login-input s-ltr" }), h("span", { class: "s-login-error-message" }), h("salla-button", { wide: true, onClick: () => this.loginBySMS() }, this.enterText), h("a", { href: "#", onClick: () => this.showTab(this.tab3), class: "s-login-link" }, this.byEmailText)), h("div", { class: "s-login-tab", ref: tab => this.tab3 = tab }, h("label", { class: "s-login-label" }, this.emailLabel), h("input", { type: "email", ref: el => this.email = el, onInput: this.typing, placeholder: "your@email.com", class: "s-login-input s-ltr" }), h("span", { class: "s-login-error-message" }), h("salla-button", { wide: true, onClick: () => this.loginByEmail() }, this.enterText), h("a", { href: "#", onClick: () => this.showTab(this.tab2), class: "s-login-link" }, this.bySMSText)), h("salla-verify", { "without-modal": true, ref: tab => this.tab4 = tab, autoReload: false }), h("div", { ref: tab => this.tab5 = tab }, h("label", { class: "s-login-label" }, salla.lang.get('blocks.header.your_name')), h("div", { class: "s-login-input-group" }, h("input", { type: "text", class: "s-login-input", ref: el => this.firstName = el, placeholder: salla.lang.get('pages.profile.first_name') }), h("input", { type: "text", class: "s-login-input", ref: el => this.lastName = el, placeholder: salla.lang.get('pages.profile.last_name') })), h("div", { ref: el => this.regMobileBlock = el }, h("label", { class: "s-login-label" }, this.mobileLabel), h("input", { type: "tel", ref: el => this.regMobile = el, onInput: this.typing, placeholder: "5xx xxx xxx", class: "s-login-input s-ltr" }), h("span", { class: "s-login-error-message" })), h("div", { ref: el => this.regEmailBlock = el }, h("label", { class: "s-login-label" }, this.emailLabel), h("input", { type: "email", ref: el => this.regEmail = el, onInput: this.typing, placeholder: "your@email.com", class: "s-login-input s-ltr" }), h("span", { class: "s-login-error-message" })), h("salla-button", { wide: true, onClick: () => this.newUser() }, salla.lang.get('blocks.header.register')))));
109
+ }
110
+ componentDidRender() {
111
+ this.showTab(this.tab1);
112
+ }
113
+ get host() { return getElement(this); }
114
+ };
115
+
116
+ export { SallaLogin as S };
@@ -0,0 +1,21 @@
1
+ import { r as registerInstance, h, g as getElement } from './index-8b97d225.js';
2
+
3
+ const SallaOffer = class {
4
+ constructor(hostRef) {
5
+ registerInstance(this, hostRef);
6
+ salla.offer.event.onExisted(data => this.show(data.offer.offer_id));
7
+ }
8
+ async show(offerId) {
9
+ this.modal.show();
10
+ console.log(offerId);
11
+ }
12
+ render() {
13
+ return h("salla-modal", { ref: modal => this.modal = modal, "is-loading": true }, h("slot", null));
14
+ }
15
+ componentDidLoad() {
16
+ //
17
+ }
18
+ get host() { return getElement(this); }
19
+ };
20
+
21
+ export { SallaOffer as salla_offer };
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h, e as Host, g as getElement } from './index-8966d27f.js';
1
+ import { r as registerInstance, h, H as Host, g as getElement } from './index-8b97d225.js';
2
2
  import { H as Helper } from './Helper-81ac9a8c.js';
3
3
 
4
4
  const SallaProductAvailability = class {
@@ -53,7 +53,7 @@ const SallaProductAvailability = class {
53
53
  : h("slot", null, h("salla-button", { wide: true, onClick: () => this.isUser ? this.submit() : this.modal.show() }, this.buttonText)), this.isUser || this.isSubscribed ? '' : this.renderModal()));
54
54
  }
55
55
  renderModal() {
56
- return (h("salla-modal", { ref: modal => this.modal = modal, title: this.title_, subTitle: this.subTitle, icon: "sicon-bell-ring", modalWidth: "w-96" }, h("div", { class: "s-product-availability-body" }, this.channels_.includes('email') ? [
56
+ return (h("salla-modal", { ref: modal => this.modal = modal, title: this.title_, subTitle: this.subTitle, icon: "sicon-bell-ring", width: "md" }, h("div", { class: "s-product-availability-body" }, this.channels_.includes('email') ? [
57
57
  h("label", { class: "s-product-availability-label" }, this.emailLabel),
58
58
  h("input", { class: "s-product-availability-input", placeholder: this.emailPlaceholder, ref: el => this.email = el, type: "email" })
59
59
  ] : '', this.channels_.includes('sms') ? [