@salla.sa/twilight-components 1.0.19 → 1.0.21
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.
- package/dist/{esm → twilight-components}/Helper-d07ebbc7.js +0 -0
- package/dist/twilight-components/app-globals-0f993ce5.js +3 -0
- package/dist/twilight-components/css-shim-a64b8820.js +4 -0
- package/dist/twilight-components/dom-d08ba8aa.js +73 -0
- package/dist/twilight-components/index-9c087700.js +3010 -0
- package/dist/twilight-components/index.esm.js +4 -1
- package/dist/{esm → twilight-components}/salla-branches.entry.js +1 -1
- package/dist/twilight-components/salla-button.entry.js +75 -0
- package/dist/{esm → twilight-components}/salla-localization.entry.js +1 -1
- package/dist/{esm/salla-login-38586400.js → twilight-components/salla-login-57b18c2c.js} +1 -1
- package/dist/twilight-components/salla-login.entry.js +3 -0
- package/dist/twilight-components/salla-modal.entry.js +113 -0
- package/dist/twilight-components/salla-offer.entry.js +75 -0
- package/dist/{esm → twilight-components}/salla-product-availability.entry.js +1 -1
- package/dist/twilight-components/salla-rating.entry.js +228 -0
- package/dist/{esm/salla-search-ca856aab.js → twilight-components/salla-search-30fec1e8.js} +1 -1
- package/dist/twilight-components/salla-search.entry.js +3 -0
- package/dist/{esm/salla-button_5.entry.js → twilight-components/salla-tel-input.entry.js} +33 -294
- package/dist/twilight-components/salla-verify.entry.js +114 -0
- package/dist/twilight-components/shadow-css-bc14d9fd.js +389 -0
- package/dist/twilight-components/twilight-components.css +3 -1
- package/dist/twilight-components/twilight-components.esm.js +125 -1
- package/dist/types/components/salla-offer/offer-schema.d.ts +47 -0
- package/dist/types/components/salla-offer/salla-offer.d.ts +13 -48
- package/dist/types/components/salla-rating/order-feedback-response.d.ts +62 -0
- package/dist/types/components/salla-rating/salla-rating.d.ts +25 -23
- package/dist/types/components.d.ts +2 -10
- package/package.json +1 -1
- package/dist/cjs/Helper-fcea994c.js +0 -23
- package/dist/cjs/index-4b8b3ffe.js +0 -1696
- package/dist/cjs/index.cjs.js +0 -13
- package/dist/cjs/loader.cjs.js +0 -21
- package/dist/cjs/salla-branches.cjs.entry.js +0 -92
- package/dist/cjs/salla-button_5.cjs.entry.js +0 -1686
- package/dist/cjs/salla-localization.cjs.entry.js +0 -82
- package/dist/cjs/salla-login-008cc893.js +0 -125
- package/dist/cjs/salla-offer.cjs.entry.js +0 -50
- package/dist/cjs/salla-product-availability.cjs.entry.js +0 -75
- package/dist/cjs/salla-rating.cjs.entry.js +0 -300
- package/dist/cjs/salla-search-c7aad59a.js +0 -81
- package/dist/cjs/salla-search.cjs.entry.js +0 -11
- package/dist/cjs/twilight-components.cjs.js +0 -19
- package/dist/collection/Helpers/Helper.js +0 -19
- package/dist/collection/collection-manifest.json +0 -22
- package/dist/collection/components/generate-summary.js +0 -35
- package/dist/collection/components/salla-branches/salla-branches.css +0 -12
- package/dist/collection/components/salla-branches/salla-branches.js +0 -233
- package/dist/collection/components/salla-button/salla-button.css +0 -3
- package/dist/collection/components/salla-button/salla-button.js +0 -246
- package/dist/collection/components/salla-localization/salla-localization.js +0 -208
- package/dist/collection/components/salla-login/salla-login.css +0 -3
- package/dist/collection/components/salla-login/salla-login.js +0 -378
- package/dist/collection/components/salla-modal/salla-modal.js +0 -459
- package/dist/collection/components/salla-offer/salla-offer.js +0 -81
- package/dist/collection/components/salla-product-availability/salla-product-availability.js +0 -331
- package/dist/collection/components/salla-rating/salla-rating.css +0 -7
- package/dist/collection/components/salla-rating/salla-rating.js +0 -483
- package/dist/collection/components/salla-search/salla-search.js +0 -132
- package/dist/collection/components/salla-tel-input/salla-tel-input.js +0 -14
- package/dist/collection/components/salla-verify/salla-verify.js +0 -273
- package/dist/collection/index.js +0 -2
- package/dist/collection/interfaces/colors.js +0 -1
- package/dist/collection/interfaces/index.js +0 -2
- package/dist/collection/interfaces/ratio.js +0 -1
- package/dist/collection/plugins/tailwind-theme/generator.js +0 -62
- package/dist/collection/plugins/tailwind-theme/index.js +0 -26
- package/dist/esm/index-092659c7.js +0 -1668
- package/dist/esm/index.js +0 -4
- package/dist/esm/loader.js +0 -17
- package/dist/esm/polyfills/core-js.js +0 -11
- package/dist/esm/polyfills/css-shim.js +0 -1
- package/dist/esm/polyfills/dom.js +0 -79
- package/dist/esm/polyfills/es5-html-element.js +0 -1
- package/dist/esm/polyfills/index.js +0 -34
- package/dist/esm/polyfills/system.js +0 -6
- package/dist/esm/salla-offer.entry.js +0 -46
- package/dist/esm/salla-rating.entry.js +0 -296
- package/dist/esm/salla-search.entry.js +0 -3
- package/dist/esm/twilight-components.js +0 -17
- package/dist/index.cjs.js +0 -1
- package/dist/index.js +0 -1
- package/dist/twilight-components/p-03d0ec44.entry.js +0 -1
- package/dist/twilight-components/p-13a55257.entry.js +0 -1
- package/dist/twilight-components/p-160062c6.js +0 -1
- package/dist/twilight-components/p-47f17d3b.js +0 -1
- package/dist/twilight-components/p-5307c7b5.entry.js +0 -1
- package/dist/twilight-components/p-6a1f43c6.entry.js +0 -1
- package/dist/twilight-components/p-7088e517.entry.js +0 -1
- package/dist/twilight-components/p-924e3c88.js +0 -1
- package/dist/twilight-components/p-e8965b01.js +0 -1
- package/dist/twilight-components/p-ecb1b6cc.entry.js +0 -1
- package/dist/twilight-components/p-f11b401a.entry.js +0 -1
|
@@ -1,197 +1,44 @@
|
|
|
1
|
-
import { r as registerInstance, h,
|
|
2
|
-
import { H as Helper } from './Helper-d07ebbc7.js';
|
|
3
|
-
export { S as salla_login } from './salla-login-38586400.js';
|
|
1
|
+
import { r as registerInstance, h, e as Host } from './index-9c087700.js';
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
};
|
|
5
|
+
function getDefaultExportFromCjs (x) {
|
|
6
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
7
|
+
}
|
|
184
8
|
|
|
185
9
|
function createCommonjsModule(fn, basedir, module) {
|
|
186
10
|
return module = {
|
|
187
11
|
path: basedir,
|
|
188
12
|
exports: {},
|
|
189
13
|
require: function (path, base) {
|
|
190
|
-
return commonjsRequire();
|
|
14
|
+
return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
|
|
191
15
|
}
|
|
192
16
|
}, fn(module, module.exports), module.exports;
|
|
193
17
|
}
|
|
194
18
|
|
|
19
|
+
function getDefaultExportFromNamespaceIfPresent (n) {
|
|
20
|
+
return n && Object.prototype.hasOwnProperty.call(n, 'default') ? n['default'] : n;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getDefaultExportFromNamespaceIfNotNamed (n) {
|
|
24
|
+
return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getAugmentedNamespace(n) {
|
|
28
|
+
if (n.__esModule) return n;
|
|
29
|
+
var a = Object.defineProperty({}, '__esModule', {value: true});
|
|
30
|
+
Object.keys(n).forEach(function (k) {
|
|
31
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
32
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return n[k];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
return a;
|
|
40
|
+
}
|
|
41
|
+
|
|
195
42
|
function commonjsRequire () {
|
|
196
43
|
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
|
|
197
44
|
}
|
|
@@ -205,8 +52,9 @@ var intlTelInput$1 = createCommonjsModule(function (module) {
|
|
|
205
52
|
|
|
206
53
|
// wrap in UMD
|
|
207
54
|
(function(factory) {
|
|
208
|
-
if (module.exports) module.exports = factory(); else window.intlTelInput = factory();
|
|
55
|
+
if ('object' === "object" && module.exports) module.exports = factory(); else window.intlTelInput = factory();
|
|
209
56
|
})(function(undefined$1) {
|
|
57
|
+
"use strict";
|
|
210
58
|
return function() {
|
|
211
59
|
// Array of country objects for the flag dropdown.
|
|
212
60
|
// Here is the criteria for the plugin to support a given country/territory
|
|
@@ -234,6 +82,7 @@ var intlTelInput$1 = createCommonjsModule(function (module) {
|
|
|
234
82
|
areaCodes: c[4] || null
|
|
235
83
|
};
|
|
236
84
|
}
|
|
85
|
+
"use strict";
|
|
237
86
|
function _classCallCheck(instance, Constructor) {
|
|
238
87
|
if (!(instance instanceof Constructor)) {
|
|
239
88
|
throw new TypeError("Cannot call a class as a function");
|
|
@@ -1565,114 +1414,4 @@ const SallaTelInput = class {
|
|
|
1565
1414
|
}
|
|
1566
1415
|
};
|
|
1567
1416
|
|
|
1568
|
-
|
|
1569
|
-
constructor(hostRef) {
|
|
1570
|
-
registerInstance(this, hostRef);
|
|
1571
|
-
this.verified = createEvent(this, "verified", 7);
|
|
1572
|
-
this.backClicked = createEvent(this, "backClicked", 7);
|
|
1573
|
-
this.url = 'profile/verify-mobile';
|
|
1574
|
-
this.by = 'sms';
|
|
1575
|
-
this.autoReload = true;
|
|
1576
|
-
Helper.setHost(this.host);
|
|
1577
|
-
if (this.withoutModal) {
|
|
1578
|
-
this.modal = { show: () => '', hide: () => '' };
|
|
1579
|
-
}
|
|
1580
|
-
else {
|
|
1581
|
-
salla.event.on('profile::verify.mobile', data => this.show(data));
|
|
1582
|
-
}
|
|
1583
|
-
}
|
|
1584
|
-
async getCode() {
|
|
1585
|
-
return this.code.value;
|
|
1586
|
-
}
|
|
1587
|
-
async show(data) {
|
|
1588
|
-
this.data = data;
|
|
1589
|
-
this.resendTimer();
|
|
1590
|
-
this.otpInputs = document.querySelectorAll('.s-verify-input');
|
|
1591
|
-
this.otpInputs[0].focus();
|
|
1592
|
-
Helper.on('input', '.s-verify-input', e => salla.helpers.digitsOnly(e.target));
|
|
1593
|
-
Helper.onKeyUp('.s-verify-input', event => {
|
|
1594
|
-
var _a, _b, _c, _d;
|
|
1595
|
-
let key = event.keyCode || event.charCode;
|
|
1596
|
-
if (event.target.value) {
|
|
1597
|
-
(_a = event.target.nextElementSibling) === null || _a === void 0 ? void 0 : _a.focus();
|
|
1598
|
-
(_b = event.target.nextElementSibling) === null || _b === void 0 ? void 0 : _b.select();
|
|
1599
|
-
}
|
|
1600
|
-
else if ([8, 46].includes(key)) {
|
|
1601
|
-
(_c = event.target.previousElementSibling) === null || _c === void 0 ? void 0 : _c.focus();
|
|
1602
|
-
(_d = event.target.previousElementSibling) === null || _d === void 0 ? void 0 : _d.select();
|
|
1603
|
-
}
|
|
1604
|
-
this.toggleOTPSubmit();
|
|
1605
|
-
});
|
|
1606
|
-
Helper.on('paste', '.s-verify-input', event => {
|
|
1607
|
-
let text = event.clipboardData.getData('text').toArabicDigits().replace(/[^0-9.]/g, '').replace('..', '.');
|
|
1608
|
-
this.otpInputs.forEach((input, i) => input.value = text[i] || '');
|
|
1609
|
-
this.toggleOTPSubmit();
|
|
1610
|
-
setTimeout(() => this.otpInputs[3].focus(), 100);
|
|
1611
|
-
});
|
|
1612
|
-
return this.modal.show();
|
|
1613
|
-
}
|
|
1614
|
-
toggleOTPSubmit() {
|
|
1615
|
-
let otp = [];
|
|
1616
|
-
this.otpInputs.forEach(input => input.value && otp.push(input.value));
|
|
1617
|
-
this.code.value = otp.join('');
|
|
1618
|
-
if (otp.length === 4) {
|
|
1619
|
-
this.btn.removeAttribute('disabled');
|
|
1620
|
-
this.btn.click();
|
|
1621
|
-
return;
|
|
1622
|
-
}
|
|
1623
|
-
this.btn.setAttribute('disabled', '');
|
|
1624
|
-
}
|
|
1625
|
-
resendTimer() {
|
|
1626
|
-
Helper.showElement(this.resendMessage).hideElement(this.resend);
|
|
1627
|
-
let resendAfter = 30;
|
|
1628
|
-
let timerId = setInterval(() => {
|
|
1629
|
-
if (resendAfter === -1) {
|
|
1630
|
-
clearTimeout(timerId);
|
|
1631
|
-
Helper.hideElement(this.resendMessage).showElement(this.resend);
|
|
1632
|
-
}
|
|
1633
|
-
else {
|
|
1634
|
-
this.timer.innerHTML = `${resendAfter >= 10 ? resendAfter : '0' + resendAfter} : 00`;
|
|
1635
|
-
resendAfter--;
|
|
1636
|
-
}
|
|
1637
|
-
}, 1000);
|
|
1638
|
-
}
|
|
1639
|
-
resendCode() {
|
|
1640
|
-
return this.btn.stop()
|
|
1641
|
-
.then(() => this.btn.disable())
|
|
1642
|
-
.then(() => {
|
|
1643
|
-
this.otpInputs.forEach(input => input.value = '');
|
|
1644
|
-
this.otpInputs[0].focus();
|
|
1645
|
-
})
|
|
1646
|
-
.then(() => salla.api.auth.resend(Object.assign({ resend_by: this.by }, this.data)))
|
|
1647
|
-
.then(() => this.resendTimer())
|
|
1648
|
-
.catch(() => this.resendTimer());
|
|
1649
|
-
}
|
|
1650
|
-
submit() {
|
|
1651
|
-
return this.btn.load()
|
|
1652
|
-
.then(() => this.btn.disable())
|
|
1653
|
-
.then(() => salla.document.api.request(this.url, Object.assign({ code: this.code.value }, this.data)))
|
|
1654
|
-
.then(response => this.verified.emit(response))
|
|
1655
|
-
.then(() => this.btn.stop() && this.btn.disable())
|
|
1656
|
-
.then(() => this.modal.hide())
|
|
1657
|
-
.then(() => this.autoReload && window.location.reload())
|
|
1658
|
-
.catch(() => this.btn.stop() && this.btn.enable());
|
|
1659
|
-
}
|
|
1660
|
-
render() {
|
|
1661
|
-
return this.withoutModal ? this.myBody() :
|
|
1662
|
-
h("salla-modal", { id: "s-verify", ref: modal => this.modal = modal, title: salla.lang.get('pages.profile.verify_title') }, this.myBody());
|
|
1663
|
-
}
|
|
1664
|
-
myBody() {
|
|
1665
|
-
return [
|
|
1666
|
-
h("div", { class: "s-verify-message", innerHTML: salla.lang.get('pages.profile.verify_message') }),
|
|
1667
|
-
// <label class="s-verify-label">{salla.lang.get('pages.profile.verify_placeholder')}</label>,
|
|
1668
|
-
h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }),
|
|
1669
|
-
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 }))),
|
|
1670
|
-
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')), this.backText ?
|
|
1671
|
-
h("a", { href: "#", class: "s-verify-resend", onClick: () => this.backClicked.emit() }, this.backText)
|
|
1672
|
-
: '')
|
|
1673
|
-
];
|
|
1674
|
-
}
|
|
1675
|
-
get host() { return getElement(this); }
|
|
1676
|
-
};
|
|
1677
|
-
|
|
1678
|
-
export { SallaButton as salla_button, SallaModal as salla_modal, SallaTelInput as salla_tel_input, SallaVerify as salla_verify };
|
|
1417
|
+
export { SallaTelInput as salla_tel_input };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { r as registerInstance, f as createEvent, h, g as getElement } from './index-9c087700.js';
|
|
2
|
+
import { H as Helper } from './Helper-d07ebbc7.js';
|
|
3
|
+
|
|
4
|
+
const SallaVerify = class {
|
|
5
|
+
constructor(hostRef) {
|
|
6
|
+
registerInstance(this, hostRef);
|
|
7
|
+
this.verified = createEvent(this, "verified", 7);
|
|
8
|
+
this.backClicked = createEvent(this, "backClicked", 7);
|
|
9
|
+
this.url = 'profile/verify-mobile';
|
|
10
|
+
this.by = 'sms';
|
|
11
|
+
this.autoReload = true;
|
|
12
|
+
Helper.setHost(this.host);
|
|
13
|
+
if (this.withoutModal) {
|
|
14
|
+
this.modal = { show: () => '', hide: () => '' };
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
salla.event.on('profile::verify.mobile', data => this.show(data));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async getCode() {
|
|
21
|
+
return this.code.value;
|
|
22
|
+
}
|
|
23
|
+
async show(data) {
|
|
24
|
+
this.data = data;
|
|
25
|
+
this.resendTimer();
|
|
26
|
+
this.otpInputs = document.querySelectorAll('.s-verify-input');
|
|
27
|
+
this.otpInputs[0].focus();
|
|
28
|
+
Helper.on('input', '.s-verify-input', e => salla.helpers.digitsOnly(e.target));
|
|
29
|
+
Helper.onKeyUp('.s-verify-input', event => {
|
|
30
|
+
var _a, _b, _c, _d;
|
|
31
|
+
let key = event.keyCode || event.charCode;
|
|
32
|
+
if (event.target.value) {
|
|
33
|
+
(_a = event.target.nextElementSibling) === null || _a === void 0 ? void 0 : _a.focus();
|
|
34
|
+
(_b = event.target.nextElementSibling) === null || _b === void 0 ? void 0 : _b.select();
|
|
35
|
+
}
|
|
36
|
+
else if ([8, 46].includes(key)) {
|
|
37
|
+
(_c = event.target.previousElementSibling) === null || _c === void 0 ? void 0 : _c.focus();
|
|
38
|
+
(_d = event.target.previousElementSibling) === null || _d === void 0 ? void 0 : _d.select();
|
|
39
|
+
}
|
|
40
|
+
this.toggleOTPSubmit();
|
|
41
|
+
});
|
|
42
|
+
Helper.on('paste', '.s-verify-input', event => {
|
|
43
|
+
let text = event.clipboardData.getData('text').toArabicDigits().replace(/[^0-9.]/g, '').replace('..', '.');
|
|
44
|
+
this.otpInputs.forEach((input, i) => input.value = text[i] || '');
|
|
45
|
+
this.toggleOTPSubmit();
|
|
46
|
+
setTimeout(() => this.otpInputs[3].focus(), 100);
|
|
47
|
+
});
|
|
48
|
+
return this.modal.show();
|
|
49
|
+
}
|
|
50
|
+
toggleOTPSubmit() {
|
|
51
|
+
let otp = [];
|
|
52
|
+
this.otpInputs.forEach(input => input.value && otp.push(input.value));
|
|
53
|
+
this.code.value = otp.join('');
|
|
54
|
+
if (otp.length === 4) {
|
|
55
|
+
this.btn.removeAttribute('disabled');
|
|
56
|
+
this.btn.click();
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
this.btn.setAttribute('disabled', '');
|
|
60
|
+
}
|
|
61
|
+
resendTimer() {
|
|
62
|
+
Helper.showElement(this.resendMessage).hideElement(this.resend);
|
|
63
|
+
let resendAfter = 30;
|
|
64
|
+
let timerId = setInterval(() => {
|
|
65
|
+
if (resendAfter === -1) {
|
|
66
|
+
clearTimeout(timerId);
|
|
67
|
+
Helper.hideElement(this.resendMessage).showElement(this.resend);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
this.timer.innerHTML = `${resendAfter >= 10 ? resendAfter : '0' + resendAfter} : 00`;
|
|
71
|
+
resendAfter--;
|
|
72
|
+
}
|
|
73
|
+
}, 1000);
|
|
74
|
+
}
|
|
75
|
+
resendCode() {
|
|
76
|
+
return this.btn.stop()
|
|
77
|
+
.then(() => this.btn.disable())
|
|
78
|
+
.then(() => {
|
|
79
|
+
this.otpInputs.forEach(input => input.value = '');
|
|
80
|
+
this.otpInputs[0].focus();
|
|
81
|
+
})
|
|
82
|
+
.then(() => salla.api.auth.resend(Object.assign({ resend_by: this.by }, this.data)))
|
|
83
|
+
.then(() => this.resendTimer())
|
|
84
|
+
.catch(() => this.resendTimer());
|
|
85
|
+
}
|
|
86
|
+
submit() {
|
|
87
|
+
return this.btn.load()
|
|
88
|
+
.then(() => this.btn.disable())
|
|
89
|
+
.then(() => salla.document.api.request(this.url, Object.assign({ code: this.code.value }, this.data)))
|
|
90
|
+
.then(response => this.verified.emit(response))
|
|
91
|
+
.then(() => this.btn.stop() && this.btn.disable())
|
|
92
|
+
.then(() => this.modal.hide())
|
|
93
|
+
.then(() => this.autoReload && window.location.reload())
|
|
94
|
+
.catch(() => this.btn.stop() && this.btn.enable());
|
|
95
|
+
}
|
|
96
|
+
render() {
|
|
97
|
+
return this.withoutModal ? this.myBody() :
|
|
98
|
+
h("salla-modal", { id: "s-verify", ref: modal => this.modal = modal, title: salla.lang.get('pages.profile.verify_title') }, this.myBody());
|
|
99
|
+
}
|
|
100
|
+
myBody() {
|
|
101
|
+
return [
|
|
102
|
+
h("div", { class: "s-verify-message", innerHTML: salla.lang.get('pages.profile.verify_message') }),
|
|
103
|
+
// <label class="s-verify-label">{salla.lang.get('pages.profile.verify_placeholder')}</label>,
|
|
104
|
+
h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }),
|
|
105
|
+
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 }))),
|
|
106
|
+
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')), this.backText ?
|
|
107
|
+
h("a", { href: "#", class: "s-verify-resend", onClick: () => this.backClicked.emit() }, this.backText)
|
|
108
|
+
: '')
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
get host() { return getElement(this); }
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export { SallaVerify as salla_verify };
|