@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,238 @@
1
+ import { Component, Element, Event, h, Method, Prop } from '@stencil/core';
2
+ import Helper from "../../Helpers/Helper";
3
+ export class SallaVerify {
4
+ constructor() {
5
+ this.url = 'profile/verify-mobile';
6
+ this.by = 'sms';
7
+ this.autoReload = true;
8
+ Helper.setHost(this.host);
9
+ if (this.withoutModal) {
10
+ this.modal = { show: () => '', hide: () => '' };
11
+ }
12
+ else {
13
+ salla.event.on('profile::verify.mobile', data => this.show(data));
14
+ }
15
+ }
16
+ async getCode() {
17
+ return this.code.value;
18
+ }
19
+ async show(data) {
20
+ this.data = data;
21
+ this.resendTimer();
22
+ this.otpInputs = document.querySelectorAll('.s-verify-input');
23
+ this.otpInputs[0].focus();
24
+ Helper.on('input', '.s-verify-input', e => salla.helpers.digitsOnly(e.target));
25
+ Helper.onKeyUp('.s-verify-input', event => {
26
+ var _a, _b, _c, _d;
27
+ let key = event.keyCode || event.charCode;
28
+ if (event.target.value) {
29
+ (_a = event.target.nextElementSibling) === null || _a === void 0 ? void 0 : _a.focus();
30
+ (_b = event.target.nextElementSibling) === null || _b === void 0 ? void 0 : _b.select();
31
+ }
32
+ else if ([8, 46].includes(key)) {
33
+ (_c = event.target.previousElementSibling) === null || _c === void 0 ? void 0 : _c.focus();
34
+ (_d = event.target.previousElementSibling) === null || _d === void 0 ? void 0 : _d.select();
35
+ }
36
+ this.toggleOTPSubmit();
37
+ });
38
+ Helper.on('paste', '.s-verify-input', event => {
39
+ let text = event.clipboardData.getData('text').toArabicDigits().replace(/[^0-9.]/g, '').replace('..', '.');
40
+ this.otpInputs.forEach((input, i) => input.value = text[i] || '');
41
+ this.toggleOTPSubmit();
42
+ setTimeout(() => this.otpInputs[3].focus(), 100);
43
+ });
44
+ return this.modal.show();
45
+ }
46
+ toggleOTPSubmit() {
47
+ let otp = [];
48
+ this.otpInputs.forEach(input => input.value && otp.push(input.value));
49
+ this.code.value = otp.join('');
50
+ if (otp.length === 4) {
51
+ this.btn.removeAttribute('disabled');
52
+ this.btn.click();
53
+ return;
54
+ }
55
+ this.btn.setAttribute('disabled', '');
56
+ }
57
+ resendTimer() {
58
+ Helper.showElement(this.resendMessage).hideElement(this.resend);
59
+ let resendAfter = 30;
60
+ let timerId = setInterval(() => {
61
+ if (resendAfter === -1) {
62
+ clearTimeout(timerId);
63
+ Helper.hideElement(this.resendMessage).showElement(this.resend);
64
+ }
65
+ else {
66
+ this.timer.innerHTML = `${resendAfter >= 10 ? resendAfter : '0' + resendAfter} : 00`;
67
+ resendAfter--;
68
+ }
69
+ }, 1000);
70
+ }
71
+ resendCode() {
72
+ return this.btn.stop()
73
+ .then(() => this.btn.disable())
74
+ .then(() => {
75
+ this.otpInputs.forEach(input => input.value = '');
76
+ this.otpInputs[0].focus();
77
+ })
78
+ .then(() => salla.api.auth.resend(Object.assign({ resend_by: this.by }, this.data)))
79
+ .then(() => this.resendTimer())
80
+ .catch(() => this.resendTimer());
81
+ }
82
+ submit() {
83
+ return this.btn.load()
84
+ .then(() => this.btn.disable())
85
+ .then(() => salla.document.api.request(this.url, Object.assign({ code: this.code.value }, this.data)))
86
+ .then(response => this.verified.emit(response))
87
+ .then(() => this.btn.stop() && this.btn.disable())
88
+ .then(() => this.modal.hide())
89
+ .then(() => this.autoReload && window.location.reload())
90
+ .catch(() => this.btn.stop() && this.btn.enable());
91
+ }
92
+ render() {
93
+ return this.withoutModal ? this.myBody() :
94
+ h("salla-modal", { id: "s-verify", ref: modal => this.modal = modal, title: salla.lang.get('pages.profile.verify_title') }, this.myBody());
95
+ }
96
+ myBody() {
97
+ return [
98
+ h("div", { class: "s-verify-message", innerHTML: salla.lang.get('pages.profile.verify_message') }),
99
+ h("label", { class: "s-verify-label" }, salla.lang.get('pages.profile.verify_placeholder')),
100
+ h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }),
101
+ 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 }))),
102
+ h("div", { slot: "footer", class: "s-verify-footer" },
103
+ h("salla-button", { class: "s-verify-submit", disabled: true, onClick: () => this.submit(), ref: b => this.btn = b }, salla.lang.get('pages.profile.verify')),
104
+ h("p", { class: "s-verify-resend-message", ref: el => this.resendMessage = el },
105
+ salla.lang.get('blocks.header.resend_after'),
106
+ h("b", { class: "s-verify-timer", ref: el => this.timer = el })),
107
+ h("a", { href: "#", class: "s-verify-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit')))
108
+ ];
109
+ }
110
+ static get is() { return "salla-verify"; }
111
+ static get properties() { return {
112
+ "withoutModal": {
113
+ "type": "boolean",
114
+ "mutable": false,
115
+ "complexType": {
116
+ "original": "boolean",
117
+ "resolved": "boolean",
118
+ "references": {}
119
+ },
120
+ "required": false,
121
+ "optional": false,
122
+ "docs": {
123
+ "tags": [],
124
+ "text": "Should render component without modal"
125
+ },
126
+ "attribute": "without-modal",
127
+ "reflect": false
128
+ },
129
+ "url": {
130
+ "type": "string",
131
+ "mutable": false,
132
+ "complexType": {
133
+ "original": "string",
134
+ "resolved": "string",
135
+ "references": {}
136
+ },
137
+ "required": false,
138
+ "optional": false,
139
+ "docs": {
140
+ "tags": [],
141
+ "text": ""
142
+ },
143
+ "attribute": "url",
144
+ "reflect": false,
145
+ "defaultValue": "'profile/verify-mobile'"
146
+ },
147
+ "by": {
148
+ "type": "string",
149
+ "mutable": false,
150
+ "complexType": {
151
+ "original": "string",
152
+ "resolved": "string",
153
+ "references": {}
154
+ },
155
+ "required": false,
156
+ "optional": false,
157
+ "docs": {
158
+ "tags": [],
159
+ "text": ""
160
+ },
161
+ "attribute": "by",
162
+ "reflect": false,
163
+ "defaultValue": "'sms'"
164
+ },
165
+ "autoReload": {
166
+ "type": "boolean",
167
+ "mutable": false,
168
+ "complexType": {
169
+ "original": "boolean",
170
+ "resolved": "boolean",
171
+ "references": {}
172
+ },
173
+ "required": false,
174
+ "optional": false,
175
+ "docs": {
176
+ "tags": [],
177
+ "text": ""
178
+ },
179
+ "attribute": "auto-reload",
180
+ "reflect": false,
181
+ "defaultValue": "true"
182
+ }
183
+ }; }
184
+ static get events() { return [{
185
+ "method": "verified",
186
+ "name": "verified",
187
+ "bubbles": true,
188
+ "cancelable": true,
189
+ "composed": true,
190
+ "docs": {
191
+ "tags": [],
192
+ "text": ""
193
+ },
194
+ "complexType": {
195
+ "original": "any",
196
+ "resolved": "any",
197
+ "references": {}
198
+ }
199
+ }]; }
200
+ static get methods() { return {
201
+ "getCode": {
202
+ "complexType": {
203
+ "signature": "() => Promise<string>",
204
+ "parameters": [],
205
+ "references": {
206
+ "Promise": {
207
+ "location": "global"
208
+ }
209
+ },
210
+ "return": "Promise<string>"
211
+ },
212
+ "docs": {
213
+ "text": "",
214
+ "tags": []
215
+ }
216
+ },
217
+ "show": {
218
+ "complexType": {
219
+ "signature": "(data: any) => Promise<any>",
220
+ "parameters": [{
221
+ "tags": [],
222
+ "text": ""
223
+ }],
224
+ "references": {
225
+ "Promise": {
226
+ "location": "global"
227
+ }
228
+ },
229
+ "return": "Promise<any>"
230
+ },
231
+ "docs": {
232
+ "text": "",
233
+ "tags": []
234
+ }
235
+ }
236
+ }; }
237
+ static get elementRef() { return "host"; }
238
+ }
@@ -0,0 +1,2 @@
1
+ export * from './components/salla-login/salla-login';
2
+ export * from './components/salla-search/salla-search';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './colors';
2
+ export * from './ratio';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,62 @@
1
+ var fs = require('fs');
2
+ var path = require('path');
3
+ var _ = require('lodash');
4
+ var components = {};
5
+ var componentsPath = path.resolve(__dirname, '../../components');
6
+
7
+ //==================== Global Salla Components Styles ====================//
8
+ var utilities = {
9
+ '.s-has-error': {'@apply !border-red-500 !text-red-500': {}},
10
+ '.s-ltr' : {direction: 'ltr'},
11
+ '.s-input' : {'@apply appearance-none form-input': {}},
12
+ '.s-hidden' : {'@apply hidden': {}},
13
+ '.s-block' : {'@apply block': {}},
14
+ };
15
+
16
+ fs.readdirSync(componentsPath, {withFileTypes: true})
17
+ .filter(parent => parent.isDirectory())
18
+ .forEach(directory => {
19
+ try {
20
+ components[directory.name.replace('salla-', '')] = require(path.resolve(componentsPath, directory.name, 'utilities.json'));
21
+ } catch (e) {
22
+ // ignore
23
+ }
24
+ });
25
+
26
+ for (const [keyComponent, value] of Object.entries(components)) {
27
+ console.log('> Processing ' + keyComponent + ' ...');
28
+ _.forEach(value, function (value, keyUtility) {
29
+ keyUtility = '.s-' + keyComponent + '-' + keyUtility;
30
+ utilities[keyUtility] = {[`@apply ${value}`]: {}};
31
+ });
32
+ console.log('✓ Processed ' + keyComponent + '');
33
+ }
34
+
35
+ // write the utilities for the plugin
36
+ console.log('> Write utilities ...');
37
+ fs.writeFileSync(
38
+ path.resolve(__dirname, 'utilities.json'),
39
+ JSON.stringify(utilities),
40
+ function (err) {
41
+ if (err) {
42
+ return console.log(err);
43
+ }
44
+ console.log('The file was saved!');
45
+ }
46
+ );
47
+
48
+
49
+ // write the save list css
50
+ console.log('> Write safe-list-css ...');
51
+ fs.writeFileSync(
52
+ path.resolve(__dirname, 'safe-list-css.txt'),
53
+ Object.keys(utilities).map((name) => name.replace('.', '')).join('\n'),
54
+ function (err) {
55
+ if (err) {
56
+ return console.log(err);
57
+ }
58
+ console.log('The file was saved!');
59
+ }
60
+ );
61
+
62
+ console.log('✓ Done ...');
@@ -0,0 +1,26 @@
1
+ module.exports = require('tailwindcss/plugin').withOptions(() => {
2
+ return function ({addUtilities}) {
3
+ addUtilities({
4
+ // TODO :: find if there are used and defined them here if its.
5
+ '.anime-item' : {},
6
+ '.text-md' : {},
7
+ '.items-top' : {},
8
+ '.error' : {},
9
+ '.search-box' : {},
10
+ '.spinner-loader-wrap': {},
11
+ });
12
+
13
+ // todo :: move it to global
14
+ addUtilities({
15
+ '.spinner-loader': {
16
+ 'border-right-color': 'var(--color-main) !important',
17
+ '&.reverse': {
18
+ 'border-right-color': '#9f7171 !important',
19
+ 'background-color' : '#f98181'
20
+ }
21
+ }
22
+ });
23
+
24
+ addUtilities(require('./utilities.json'));
25
+ };
26
+ });