@salla.sa/twilight-components 1.0.21 → 1.0.22

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 (95) hide show
  1. package/dist/cjs/Helper-fcea994c.js +23 -0
  2. package/dist/cjs/index-714023c8.js +1653 -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_5.cjs.entry.js +1727 -0
  7. package/dist/cjs/salla-localization.cjs.entry.js +82 -0
  8. package/dist/cjs/salla-login-c438bb35.js +128 -0
  9. package/dist/cjs/salla-offer.cjs.entry.js +79 -0
  10. package/dist/cjs/salla-product-availability.cjs.entry.js +75 -0
  11. package/dist/cjs/salla-rating.cjs.entry.js +195 -0
  12. package/dist/cjs/salla-search-45173394.js +85 -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 +22 -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 +208 -0
  23. package/dist/collection/components/salla-login/salla-login.css +3 -0
  24. package/dist/collection/components/salla-login/salla-login.js +380 -0
  25. package/dist/collection/components/salla-modal/salla-modal.js +477 -0
  26. package/dist/collection/components/salla-offer/offer-schema.js +1 -0
  27. package/dist/collection/components/salla-offer/salla-offer.js +110 -0
  28. package/dist/collection/components/salla-product-availability/salla-product-availability.js +331 -0
  29. package/dist/collection/components/salla-rating/order-feedback-response.js +1 -0
  30. package/dist/collection/components/salla-rating/salla-rating.css +7 -0
  31. package/dist/collection/components/salla-rating/salla-rating.js +277 -0
  32. package/dist/collection/components/salla-search/salla-search.css +24 -0
  33. package/dist/collection/components/salla-search/salla-search.js +143 -0
  34. package/dist/collection/components/salla-tel-input/salla-tel-input.js +121 -0
  35. package/dist/collection/components/salla-verify/salla-verify.js +280 -0
  36. package/dist/collection/index.js +2 -0
  37. package/dist/collection/interfaces/colors.js +1 -0
  38. package/dist/collection/interfaces/index.js +2 -0
  39. package/dist/collection/interfaces/ratio.js +1 -0
  40. package/dist/collection/plugins/tailwind-theme/generator.js +62 -0
  41. package/dist/collection/plugins/tailwind-theme/index.js +26 -0
  42. package/dist/{twilight-components → esm}/Helper-d07ebbc7.js +0 -0
  43. package/dist/esm/index-a1bf769d.js +1625 -0
  44. package/dist/esm/index.js +4 -0
  45. package/dist/esm/loader.js +17 -0
  46. package/dist/esm/polyfills/core-js.js +11 -0
  47. package/dist/esm/polyfills/css-shim.js +1 -0
  48. package/dist/esm/polyfills/dom.js +79 -0
  49. package/dist/esm/polyfills/es5-html-element.js +1 -0
  50. package/dist/esm/polyfills/index.js +34 -0
  51. package/dist/esm/polyfills/system.js +6 -0
  52. package/dist/{twilight-components → esm}/salla-branches.entry.js +2 -2
  53. package/dist/{twilight-components/salla-tel-input.entry.js → esm/salla-button_5.entry.js} +337 -35
  54. package/dist/{twilight-components → esm}/salla-localization.entry.js +1 -1
  55. package/dist/{twilight-components/salla-login-57b18c2c.js → esm/salla-login-dd957742.js} +26 -23
  56. package/dist/{twilight-components → esm}/salla-offer.entry.js +1 -1
  57. package/dist/{twilight-components → esm}/salla-product-availability.entry.js +1 -1
  58. package/dist/{twilight-components → esm}/salla-rating.entry.js +71 -108
  59. package/dist/{twilight-components/salla-search-30fec1e8.js → esm/salla-search-5e691ebb.js} +15 -11
  60. package/dist/esm/salla-search.entry.js +3 -0
  61. package/dist/esm/twilight-components.js +17 -0
  62. package/dist/index.cjs.js +1 -0
  63. package/dist/index.js +1 -0
  64. package/dist/twilight-components/index.esm.js +1 -4
  65. package/dist/twilight-components/p-1a6d8171.entry.js +1 -0
  66. package/dist/twilight-components/p-1deb8111.entry.js +1 -0
  67. package/dist/twilight-components/p-3a4d963e.js +1 -0
  68. package/dist/twilight-components/p-47f17d3b.js +1 -0
  69. package/dist/twilight-components/p-5b2eb87d.entry.js +1 -0
  70. package/dist/twilight-components/p-6a5be894.js +1 -0
  71. package/dist/twilight-components/p-7fbdf746.entry.js +1 -0
  72. package/dist/twilight-components/p-7fe5d346.entry.js +1 -0
  73. package/dist/twilight-components/p-81a61f4e.js +1 -0
  74. package/dist/twilight-components/p-ce991664.entry.js +1 -0
  75. package/dist/twilight-components/p-da73fc9b.entry.js +1 -0
  76. package/dist/twilight-components/twilight-components.css +1 -3
  77. package/dist/twilight-components/twilight-components.esm.js +1 -125
  78. package/dist/types/components/salla-login/salla-login.d.ts +3 -3
  79. package/dist/types/components/salla-modal/salla-modal.d.ts +1 -0
  80. package/dist/types/components/salla-rating/salla-rating.d.ts +6 -23
  81. package/dist/types/components/salla-search/salla-search.d.ts +1 -1
  82. package/dist/types/components/salla-tel-input/salla-tel-input.d.ts +14 -0
  83. package/dist/types/components/salla-verify/salla-verify.d.ts +3 -1
  84. package/dist/types/components.d.ts +12 -35
  85. package/package.json +1 -1
  86. package/dist/twilight-components/app-globals-0f993ce5.js +0 -3
  87. package/dist/twilight-components/css-shim-a64b8820.js +0 -4
  88. package/dist/twilight-components/dom-d08ba8aa.js +0 -73
  89. package/dist/twilight-components/index-9c087700.js +0 -3010
  90. package/dist/twilight-components/salla-button.entry.js +0 -75
  91. package/dist/twilight-components/salla-login.entry.js +0 -3
  92. package/dist/twilight-components/salla-modal.entry.js +0 -113
  93. package/dist/twilight-components/salla-search.entry.js +0 -3
  94. package/dist/twilight-components/salla-verify.entry.js +0 -114
  95. package/dist/twilight-components/shadow-css-bc14d9fd.js +0 -389
@@ -0,0 +1,246 @@
1
+ import { Component, Element, h, Method, Prop, Watch, Host } from '@stencil/core';
2
+ import Helper from "../../Helpers/Helper";
3
+ export class SallaButton {
4
+ constructor() {
5
+ this.btnStyle = 'primary';
6
+ this.loading = false;
7
+ this.disabled = false;
8
+ this.loaderPosition = 'before';
9
+ this.wide = false;
10
+ this.hostAttributes = {};
11
+ //============= Initiate Button Attributes =============//
12
+ for (let i = 0; i < this.host.attributes.length; i++) {
13
+ this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
14
+ }
15
+ this.hostAttributes.type = this.hostAttributes.type || 'button';
16
+ this.hostAttributes.class += ' s-button-btn btn--has-loading'
17
+ + ' s-button-' + this.btnStyle
18
+ + (this.wide ? ' s-button-wide ' : '')
19
+ + ' loader-' + this.loaderPosition
20
+ + (this.loaderPosition == 'before' ? ' s-button-loader-after' : '');
21
+ delete this.hostAttributes['btn-style'];
22
+ delete this.hostAttributes['id'];
23
+ if (this.wide) {
24
+ this.host.classList.add('s-button-wide');
25
+ }
26
+ }
27
+ async load() {
28
+ if (this.loaderPosition == 'center')
29
+ this.text.classList.add('s-button-hide');
30
+ this.host.setAttribute('loading', '');
31
+ return this.host;
32
+ }
33
+ async stop() {
34
+ this.host.removeAttribute('loading');
35
+ return this.host;
36
+ }
37
+ async disable() {
38
+ this.host.setAttribute('disabled', '');
39
+ }
40
+ async enable() {
41
+ this.host.removeAttribute('disabled');
42
+ }
43
+ handleVisible(newKind, oldKind) {
44
+ //todo::use united styles
45
+ this.btn.classList.remove('btn-' + oldKind);
46
+ this.btn.classList.add('btn-' + newKind);
47
+ }
48
+ handleLoading(newVal) {
49
+ //todo::use united styles
50
+ Helper.toggleElement(this.btn, 'btn--is-loading', 'btn--no-loading', () => newVal);
51
+ }
52
+ render() {
53
+ return (
54
+ //TODO:: use HOST then fake button behaviours
55
+ h(Host, { class: "s-button-host-tag" },
56
+ h("button", Object.assign({ ref: btn => this.btn = btn, disabled: this.disabled }, this.hostAttributes),
57
+ h("span", { class: "s-button-text", ref: el => this.text = el },
58
+ h("slot", null)),
59
+ this.loading ? h("span", { class: {
60
+ //todo::use united styles
61
+ 's-button-loader': true,
62
+ 's-button-loader-start': this.loaderPosition === 'start',
63
+ 's-button-loader-end': this.loaderPosition === 'end',
64
+ 's-button-loader-center': this.loaderPosition === 'center',
65
+ } }) : '')));
66
+ }
67
+ static get is() { return "salla-button"; }
68
+ static get originalStyleUrls() { return {
69
+ "$": ["salla-button.css"]
70
+ }; }
71
+ static get styleUrls() { return {
72
+ "$": ["salla-button.css"]
73
+ }; }
74
+ static get properties() { return {
75
+ "btnStyle": {
76
+ "type": "string",
77
+ "mutable": false,
78
+ "complexType": {
79
+ "original": "'primary' | 'outline' | 'outline-primary' | 'danger'",
80
+ "resolved": "\"danger\" | \"outline\" | \"outline-primary\" | \"primary\"",
81
+ "references": {}
82
+ },
83
+ "required": false,
84
+ "optional": false,
85
+ "docs": {
86
+ "tags": [],
87
+ "text": ""
88
+ },
89
+ "attribute": "btn-style",
90
+ "reflect": true,
91
+ "defaultValue": "'primary'"
92
+ },
93
+ "loading": {
94
+ "type": "boolean",
95
+ "mutable": false,
96
+ "complexType": {
97
+ "original": "boolean",
98
+ "resolved": "boolean",
99
+ "references": {}
100
+ },
101
+ "required": false,
102
+ "optional": false,
103
+ "docs": {
104
+ "tags": [],
105
+ "text": ""
106
+ },
107
+ "attribute": "loading",
108
+ "reflect": true,
109
+ "defaultValue": "false"
110
+ },
111
+ "disabled": {
112
+ "type": "boolean",
113
+ "mutable": false,
114
+ "complexType": {
115
+ "original": "boolean",
116
+ "resolved": "boolean",
117
+ "references": {}
118
+ },
119
+ "required": false,
120
+ "optional": false,
121
+ "docs": {
122
+ "tags": [],
123
+ "text": ""
124
+ },
125
+ "attribute": "disabled",
126
+ "reflect": true,
127
+ "defaultValue": "false"
128
+ },
129
+ "loaderPosition": {
130
+ "type": "string",
131
+ "mutable": false,
132
+ "complexType": {
133
+ "original": "'start' | 'end' | 'center' | 'before'",
134
+ "resolved": "\"before\" | \"center\" | \"end\" | \"start\"",
135
+ "references": {}
136
+ },
137
+ "required": false,
138
+ "optional": false,
139
+ "docs": {
140
+ "tags": [],
141
+ "text": ""
142
+ },
143
+ "attribute": "loader-position",
144
+ "reflect": false,
145
+ "defaultValue": "'before'"
146
+ },
147
+ "wide": {
148
+ "type": "boolean",
149
+ "mutable": false,
150
+ "complexType": {
151
+ "original": "boolean",
152
+ "resolved": "boolean",
153
+ "references": {}
154
+ },
155
+ "required": false,
156
+ "optional": false,
157
+ "docs": {
158
+ "tags": [],
159
+ "text": ""
160
+ },
161
+ "attribute": "wide",
162
+ "reflect": false,
163
+ "defaultValue": "false"
164
+ }
165
+ }; }
166
+ static get methods() { return {
167
+ "load": {
168
+ "complexType": {
169
+ "signature": "() => Promise<HTMLElement>",
170
+ "parameters": [],
171
+ "references": {
172
+ "Promise": {
173
+ "location": "global"
174
+ },
175
+ "HTMLElement": {
176
+ "location": "global"
177
+ }
178
+ },
179
+ "return": "Promise<HTMLElement>"
180
+ },
181
+ "docs": {
182
+ "text": "",
183
+ "tags": []
184
+ }
185
+ },
186
+ "stop": {
187
+ "complexType": {
188
+ "signature": "() => Promise<HTMLElement>",
189
+ "parameters": [],
190
+ "references": {
191
+ "Promise": {
192
+ "location": "global"
193
+ },
194
+ "HTMLElement": {
195
+ "location": "global"
196
+ }
197
+ },
198
+ "return": "Promise<HTMLElement>"
199
+ },
200
+ "docs": {
201
+ "text": "",
202
+ "tags": []
203
+ }
204
+ },
205
+ "disable": {
206
+ "complexType": {
207
+ "signature": "() => Promise<void>",
208
+ "parameters": [],
209
+ "references": {
210
+ "Promise": {
211
+ "location": "global"
212
+ }
213
+ },
214
+ "return": "Promise<void>"
215
+ },
216
+ "docs": {
217
+ "text": "",
218
+ "tags": []
219
+ }
220
+ },
221
+ "enable": {
222
+ "complexType": {
223
+ "signature": "() => Promise<void>",
224
+ "parameters": [],
225
+ "references": {
226
+ "Promise": {
227
+ "location": "global"
228
+ }
229
+ },
230
+ "return": "Promise<void>"
231
+ },
232
+ "docs": {
233
+ "text": "",
234
+ "tags": []
235
+ }
236
+ }
237
+ }; }
238
+ static get elementRef() { return "host"; }
239
+ static get watchers() { return [{
240
+ "propName": "btnStyle",
241
+ "methodName": "handleVisible"
242
+ }, {
243
+ "propName": "loading",
244
+ "methodName": "handleLoading"
245
+ }]; }
246
+ }
@@ -0,0 +1,208 @@
1
+ import { Component, Element, h, Method, Prop } from '@stencil/core';
2
+ import Helper from "../../Helpers/Helper";
3
+ /**
4
+ * @slot header - The top of the modal.
5
+ * @slot footer - Replaces the bottom button.
6
+ * @slot language - Replaces language label, has replaceable props `{name}`, `{code}`, `{country_code}`.
7
+ * @slot currency - Replaces currency label, has replaceable props `{name}`, `{code}`, `{country_code}`.
8
+ */
9
+ export class SallaLocalization {
10
+ constructor() {
11
+ var _a, _b;
12
+ this.language = salla.config.get('language', {});
13
+ this.currency = salla.config.get('currency', {});
14
+ this.languagesTitle = salla.lang.get('common.titles.language');
15
+ this.currenciesTitle = salla.lang.get('common.titles.currency');
16
+ this.ok = salla.lang.get('common.elements.ok');
17
+ Helper.setHost(this.host);
18
+ salla.event.on('localization::show', () => this.show());
19
+ /**
20
+ * letting developer to insert his own slot like:
21
+ * <salla-localization>
22
+ * <div slot="language">...{name}....</div>
23
+ * <div slot="currency">...{name}....</div>
24
+ * </salla-localization>
25
+ * Because scoped templates not supported in stencil );
26
+ * we made a workaround to pass language & currency attributes, then replace names in rendering
27
+ */
28
+ 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>';
29
+ 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>';
30
+ this.languages = Object.values(salla.config.get('languages', {}));
31
+ this.currencies = Object.values(salla.config.get('currencies', {}));
32
+ }
33
+ async show() {
34
+ return this.modal.show();
35
+ }
36
+ async hide() {
37
+ return this.modal.hide();
38
+ }
39
+ onChangeCurrency(event) {
40
+ this.currency = salla.config.get('currencies.' + event.target.value);
41
+ }
42
+ onChangeLanguage(event) {
43
+ this.language = salla.config.get('languages.' + event.target.value);
44
+ }
45
+ async submit() {
46
+ let url;
47
+ console.log('this.currency.code::::', this.currency, this.currency.code);
48
+ this.btn.load()
49
+ .then(() => this.currency.code === salla.config.get('user.currency') || ((url = window.location.href) && salla.currency.api.change(this.currency.code)))
50
+ .then(() => this.language.code === salla.config.get('user.language') || (url = this.language.url))
51
+ .then(() => this.btn.stop())
52
+ .then(() => this.hide())
53
+ .then(() => url && (window.location.href = url));
54
+ }
55
+ render() {
56
+ return (h("salla-modal", { id: "salla-localization", class: "hidden", ref: modal => this.modal = modal, "modal-width": "xs" },
57
+ h("div", { slot: "header" },
58
+ h("slot", { name: "header" })),
59
+ h("div", { class: "s-localization-inner" },
60
+ this.languages.length > 1 ?
61
+ h("div", { class: "s-localization-section" },
62
+ h("label", { class: "s-localization-title" }, this.languagesTitle),
63
+ h("div", { class: "s-localization-section-inner" }, this.languages.length < 6 ?
64
+ this.languages.map(lang => h("div", { class: "s-localization-item" },
65
+ 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 }),
66
+ h("div", { id: "language-slot", innerHTML: this.languageSlot
67
+ .replace(/\{name\}/g, lang.name)
68
+ .replace(/\{code\}/g, lang.code)
69
+ .replace(/\{country_code\}/g, lang.country_code) }))) :
70
+ h("select", { class: "s-branches-select", name: "currency", onChange: e => this.onChangeLanguage(e) }, this.languages.map(lang => h("option", { value: lang.code, selected: this.language.code == lang.code }, lang.name)))))
71
+ : '',
72
+ this.currencies.length > 1 ?
73
+ h("div", { class: "s-localization-section" },
74
+ h("label", { class: "s-localization-title" }, this.currenciesTitle),
75
+ h("div", { class: "s-localization-section-inner" }, this.currencies.length < 6 ?
76
+ this.currencies.map(currency => h("div", { class: "s-localization-item" },
77
+ 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 }),
78
+ h("div", { id: "currency-slot", innerHTML: this.currencySlot
79
+ .replace(/\{name\}/g, currency.name)
80
+ .replace(/\{code\}/g, currency.code)
81
+ .replace(/\{country_code\}/g, currency.country_code) }))) :
82
+ h("select", { class: "s-branches-select", name: "currency", onChange: e => this.onChangeCurrency(e) }, this.currencies.map(currency => h("option", { value: currency.code, selected: this.currency.code == currency.code }, currency.name)))))
83
+ : ''),
84
+ h("slot", { name: "footer" },
85
+ h("salla-button", { wide: true, ref: btn => this.btn = btn, onClick: () => this.submit() }, this.ok))));
86
+ }
87
+ /**
88
+ * to reduce dom levels we will move slot data into the parent dom
89
+ */
90
+ componentDidRender() {
91
+ this.host.querySelectorAll('#currency-slot').forEach(el => el.replaceWith(el.firstChild));
92
+ this.host.querySelectorAll('#language-slot').forEach(el => el.replaceWith(el.firstChild));
93
+ }
94
+ static get is() { return "salla-localization"; }
95
+ static get properties() { return {
96
+ "languagesTitle": {
97
+ "type": "string",
98
+ "mutable": false,
99
+ "complexType": {
100
+ "original": "string",
101
+ "resolved": "string",
102
+ "references": {}
103
+ },
104
+ "required": false,
105
+ "optional": false,
106
+ "docs": {
107
+ "tags": [],
108
+ "text": ""
109
+ },
110
+ "attribute": "languages-title",
111
+ "reflect": false,
112
+ "defaultValue": "salla.lang.get('common.titles.language')"
113
+ },
114
+ "currenciesTitle": {
115
+ "type": "string",
116
+ "mutable": false,
117
+ "complexType": {
118
+ "original": "string",
119
+ "resolved": "string",
120
+ "references": {}
121
+ },
122
+ "required": false,
123
+ "optional": false,
124
+ "docs": {
125
+ "tags": [],
126
+ "text": ""
127
+ },
128
+ "attribute": "currencies-title",
129
+ "reflect": false,
130
+ "defaultValue": "salla.lang.get('common.titles.currency')"
131
+ },
132
+ "ok": {
133
+ "type": "string",
134
+ "mutable": false,
135
+ "complexType": {
136
+ "original": "string",
137
+ "resolved": "string",
138
+ "references": {}
139
+ },
140
+ "required": false,
141
+ "optional": false,
142
+ "docs": {
143
+ "tags": [],
144
+ "text": ""
145
+ },
146
+ "attribute": "ok",
147
+ "reflect": false,
148
+ "defaultValue": "salla.lang.get('common.elements.ok')"
149
+ }
150
+ }; }
151
+ static get methods() { return {
152
+ "show": {
153
+ "complexType": {
154
+ "signature": "() => Promise<HTMLElement>",
155
+ "parameters": [],
156
+ "references": {
157
+ "Promise": {
158
+ "location": "global"
159
+ },
160
+ "HTMLElement": {
161
+ "location": "global"
162
+ }
163
+ },
164
+ "return": "Promise<HTMLElement>"
165
+ },
166
+ "docs": {
167
+ "text": "",
168
+ "tags": []
169
+ }
170
+ },
171
+ "hide": {
172
+ "complexType": {
173
+ "signature": "() => Promise<HTMLElement>",
174
+ "parameters": [],
175
+ "references": {
176
+ "Promise": {
177
+ "location": "global"
178
+ },
179
+ "HTMLElement": {
180
+ "location": "global"
181
+ }
182
+ },
183
+ "return": "Promise<HTMLElement>"
184
+ },
185
+ "docs": {
186
+ "text": "",
187
+ "tags": []
188
+ }
189
+ },
190
+ "submit": {
191
+ "complexType": {
192
+ "signature": "() => Promise<void>",
193
+ "parameters": [],
194
+ "references": {
195
+ "Promise": {
196
+ "location": "global"
197
+ }
198
+ },
199
+ "return": "Promise<void>"
200
+ },
201
+ "docs": {
202
+ "text": "",
203
+ "tags": []
204
+ }
205
+ }
206
+ }; }
207
+ static get elementRef() { return "host"; }
208
+ }
@@ -0,0 +1,3 @@
1
+ salla-verify{
2
+ display: block;
3
+ }