@salla.sa/twilight-components 1.0.10 → 1.0.11
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/cjs/Helper-8852feaa.js +23 -0
- package/dist/cjs/index-23da2c6b.js +1601 -0
- package/dist/cjs/index.cjs.js +12 -0
- package/dist/cjs/loader.cjs.js +21 -0
- package/dist/cjs/multi-warehouse_4.cjs.entry.js +242 -0
- package/dist/cjs/salla-localization.cjs.entry.js +76 -0
- package/dist/cjs/salla-login-476fb312.js +14 -0
- package/dist/cjs/salla-product-availability.cjs.entry.js +78 -0
- package/dist/cjs/salla-rating.cjs.entry.js +299 -0
- package/dist/cjs/salla-search-f9e00be9.js +97 -0
- package/dist/cjs/salla-search.cjs.entry.js +10 -0
- package/dist/cjs/salla-verify.cjs.entry.js +96 -0
- package/dist/cjs/twilight-components.cjs.js +19 -0
- package/dist/collection/Helpers/Helper.js +19 -0
- package/dist/collection/collection-manifest.json +20 -0
- package/dist/collection/components/generate-summary.js +35 -0
- package/dist/collection/components/multi-warehouse/multi-warehouse.css +13 -0
- package/dist/collection/components/multi-warehouse/multi-warehouse.js +238 -0
- package/dist/collection/components/salla-button/salla-button.css +3 -0
- package/dist/collection/components/salla-button/salla-button.js +219 -0
- package/dist/collection/components/salla-localization/salla-localization.js +201 -0
- package/dist/collection/components/salla-login/salla-login.js +31 -0
- package/dist/collection/components/salla-modal/salla-modal.js +316 -0
- package/dist/collection/components/salla-product-availability/salla-product-availability.js +333 -0
- package/dist/collection/components/salla-rating/salla-rating.css +3 -0
- package/dist/collection/components/salla-rating/salla-rating.js +484 -0
- package/dist/collection/components/salla-search/salla-search.js +155 -0
- package/dist/collection/components/salla-verify/salla-verify.js +99 -0
- package/dist/collection/index.js +2 -0
- package/dist/collection/interfaces/colors.js +1 -0
- package/dist/collection/interfaces/index.js +2 -0
- package/dist/collection/interfaces/ratio.js +1 -0
- package/dist/collection/plugins/tailwind-theme/generator.js +53 -0
- package/dist/collection/plugins/tailwind-theme/index.js +26 -0
- package/dist/{twilight-components/Helper-23b2de40.js → esm/Helper-81ac9a8c.js} +3 -0
- package/dist/esm/index-643344dc.js +1573 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/loader.js +17 -0
- package/dist/esm/multi-warehouse_4.entry.js +235 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/esm/salla-localization.entry.js +72 -0
- package/dist/{twilight-components/salla-login-97e0a9ab.js → esm/salla-login-0e85b2d8.js} +1 -1
- package/dist/{twilight-components → esm}/salla-product-availability.entry.js +38 -19
- package/dist/esm/salla-rating.entry.js +295 -0
- package/dist/{twilight-components/salla-search-df1c9b54.js → esm/salla-search-615b8f94.js} +1 -1
- package/dist/esm/salla-search.entry.js +2 -0
- package/dist/{twilight-components → esm}/salla-verify.entry.js +2 -2
- package/dist/esm/twilight-components.js +17 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/twilight-components/index.esm.js +1 -3
- package/dist/twilight-components/p-2b8a5fa4.entry.js +1 -0
- package/dist/twilight-components/p-36c87e2e.js +1 -0
- package/dist/twilight-components/p-4e37a6cb.entry.js +1 -0
- package/dist/twilight-components/p-751643d8.entry.js +1 -0
- package/dist/twilight-components/p-8a2410e6.js +1 -0
- package/dist/twilight-components/p-94b18718.entry.js +1 -0
- package/dist/twilight-components/p-9bc28e0c.js +1 -0
- package/dist/twilight-components/p-bb503365.entry.js +1 -0
- package/dist/twilight-components/p-d1ef2268.js +1 -0
- package/dist/twilight-components/p-d34bbfc4.entry.js +1 -0
- package/dist/twilight-components/twilight-components.esm.js +1 -125
- package/dist/types/Helpers/Helper.d.ts +1 -0
- package/dist/types/components/salla-button/salla-button.d.ts +2 -1
- package/dist/types/components/salla-localization/salla-localization.d.ts +9 -2
- package/dist/types/components/salla-product-availability/salla-product-availability.d.ts +5 -2
- package/dist/types/components/{order-rating/order-rating.d.ts → salla-rating/salla-rating.d.ts} +13 -4
- package/dist/types/components.d.ts +40 -22
- package/package.json +1 -1
- package/dist/twilight-components/app-globals-0f993ce5.js +0 -3
- package/dist/twilight-components/css-shim-a64b8820.js +0 -4
- package/dist/twilight-components/dom-d08ba8aa.js +0 -73
- package/dist/twilight-components/index-8cf58712.js +0 -3010
- package/dist/twilight-components/multi-warehouse.entry.js +0 -86
- package/dist/twilight-components/order-rating.entry.js +0 -257
- package/dist/twilight-components/salla-button.entry.js +0 -57
- package/dist/twilight-components/salla-localization.entry.js +0 -48
- package/dist/twilight-components/salla-login.entry.js +0 -2
- package/dist/twilight-components/salla-modal.entry.js +0 -84
- package/dist/twilight-components/salla-search.entry.js +0 -2
- package/dist/twilight-components/shadow-css-bc14d9fd.js +0 -389
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const sallaLogin = require('./salla-login-476fb312.js');
|
|
6
|
+
const sallaSearch = require('./salla-search-f9e00be9.js');
|
|
7
|
+
require('./index-23da2c6b.js');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.SallaLogin = sallaLogin.SallaLogin;
|
|
12
|
+
exports.SallaSearch = sallaSearch.SallaSearch;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-23da2c6b.js');
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
Stencil Client Patch Esm v2.8.1 | MIT Licensed | https://stenciljs.com
|
|
9
|
+
*/
|
|
10
|
+
const patchEsm = () => {
|
|
11
|
+
return index.promiseResolve();
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const defineCustomElements = (win, options) => {
|
|
15
|
+
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
|
+
return patchEsm().then(() => {
|
|
17
|
+
return index.bootstrapLazy([["multi-warehouse_4.cjs",[[4,"multi-warehouse",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}],[0,"salla-login"],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"load":[64],"stop":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"error":[4],"success":[4],"isClosable":[1028,"is-closable"],"modalWidth":[513,"modal-width"],"visible":[516],"subTitle":[1,"sub-title"],"icon":[1],"show":[64],"hide":[64],"setTitle":[64]}]]],["salla-localization.cjs",[[4,"salla-localization",{"languages":[1],"currencies":[1],"ok":[1],"show":[64],"hide":[64],"submit":[64]}]]],["salla-product-availability.cjs",[[4,"salla-product-availability",{"channels":[1],"buttonText":[1,"button-text"],"countryCode":[1,"country-code"],"title_":[1],"subscribe":[1],"cancel":[1],"subTitle":[1,"sub-title"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"mobilePlaceholder":[1,"mobile-placeholder"],"emailPlaceholder":[1,"email-placeholder"],"productId":[2,"product-id"],"subscribed":[1],"submit":[64]}]]],["salla-rating.cjs",[[0,"salla-rating",{"orderId":[2,"order-id"],"thanksMsg":[1,"thanks-msg"],"isStoreRating":[4,"is-store-rating"],"isProductsRating":[4,"is-products-rating"],"isShippingRating":[4,"is-shipping-rating"],"show":[64],"hide":[64]}]]],["salla-verify.cjs",[[0,"salla-verify"]]],["salla-search.cjs",[[4,"salla-search",{"searchPlaceholder":[1,"search-placeholder"],"noResultsText":[1,"no-results-text"],"searchTerm":[32],"results":[32],"fetchStatus":[32],"showResult":[32],"showModal":[32]}]]]], options);
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.defineCustomElements = defineCustomElements;
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-23da2c6b.js');
|
|
6
|
+
const Helper = require('./Helper-8852feaa.js');
|
|
7
|
+
const sallaLogin = require('./salla-login-476fb312.js');
|
|
8
|
+
|
|
9
|
+
const multiWarehouseCss = "#s-multi-warehouse-modal .s-modal-header{display:flex;flex-direction:column;margin-bottom:40px}#s-multi-warehouse-modal .s-modal-sub-title{margin:0}#s-multi-warehouse-modal .s-modal-title{order:10}";
|
|
10
|
+
|
|
11
|
+
// import Helper from "../../Helpers/Helper";
|
|
12
|
+
let engine = require('store/src/store-engine');
|
|
13
|
+
let storages = require('store/storages/sessionStorage');
|
|
14
|
+
let sessionStore = engine.createStore(storages);
|
|
15
|
+
const MultiWarehouse = class {
|
|
16
|
+
constructor(hostRef) {
|
|
17
|
+
index.registerInstance(this, hostRef);
|
|
18
|
+
this.open = false;
|
|
19
|
+
this.isOpenedBefore = sessionStore.get("multi-warehouse-opened-before");
|
|
20
|
+
this.displayAs = 'default';
|
|
21
|
+
this.browseProductsFrom = 'all';
|
|
22
|
+
this.branches = [
|
|
23
|
+
{ id: 1, name: 'فرع الرياض', open: true, available: true, limited: false, tag: 'متوفر' },
|
|
24
|
+
{ id: 2, name: 'فرع جدة', open: false, available: false, limited: false, tag: 'غير متوفر' },
|
|
25
|
+
{ id: 3, name: 'فرع مكة', open: true, available: true, limited: false, tag: 'متوفر' },
|
|
26
|
+
{ id: 4, name: 'فرع المدينة', open: true, available: true, limited: false, tag: 'متوفر' },
|
|
27
|
+
{ id: 5, name: 'فرع جازان', open: true, available: true, limited: true, tag: 'الكمية محدودة' }
|
|
28
|
+
];
|
|
29
|
+
this.current = 1;
|
|
30
|
+
this.currentBranch = (prop) => {
|
|
31
|
+
return this.branches.filter((el) => el.id == this.current)[0][prop];
|
|
32
|
+
};
|
|
33
|
+
this.statusColor = (branch = null) => {
|
|
34
|
+
return branch ?
|
|
35
|
+
branch.limited ? 'text-red-400' : branch.available ? 'text-green-500' : 'text-gray-400'
|
|
36
|
+
:
|
|
37
|
+
this.currentBranch('limited') ? 'text-red-400' : this.currentBranch('available') ? 'text-green-500' : 'text-gray-400';
|
|
38
|
+
};
|
|
39
|
+
this.isChoiceable = () => {
|
|
40
|
+
return (this.browseProductsFrom !== 'all' && this.position == 'single') || this.position == 'header';
|
|
41
|
+
};
|
|
42
|
+
this.formTitle = () => {
|
|
43
|
+
return this.isChoiceable() ?
|
|
44
|
+
'توفر المنتج في الفروع الآخرى'
|
|
45
|
+
: 'التسوق من فرع آخر';
|
|
46
|
+
};
|
|
47
|
+
salla.event.on('branches::show', () => this.show());
|
|
48
|
+
}
|
|
49
|
+
async show() {
|
|
50
|
+
return this.modal.show();
|
|
51
|
+
}
|
|
52
|
+
async hide() {
|
|
53
|
+
return this.modal.hide();
|
|
54
|
+
}
|
|
55
|
+
handelChange(event) {
|
|
56
|
+
this.selected = event.target.value;
|
|
57
|
+
}
|
|
58
|
+
handleSubmit() {
|
|
59
|
+
this.btn.load().then(() => {
|
|
60
|
+
setTimeout(() => location.reload(), 2000);
|
|
61
|
+
});
|
|
62
|
+
sessionStore.set("multi-warehouse-opened-before", true);
|
|
63
|
+
this.show();
|
|
64
|
+
setTimeout(() => {
|
|
65
|
+
this.current = this.selected;
|
|
66
|
+
}, 300);
|
|
67
|
+
}
|
|
68
|
+
render() {
|
|
69
|
+
return (index.h("salla-modal", { icon: "sicon-store-alt", title: "\u0641\u0631\u0639 \u0627\u0644\u0631\u064A\u0627\u0636", "sub-title": "\u0623\u0646\u062A \u0627\u0644\u0622\u0646 \u062A\u062A\u0635\u0641\u062D \u0627\u0644\u0645\u062A\u062C\u0631 \u0645\u0646", "is-closable": !this.isOpenedBefore && this.displayAs == 'popup' ? 'false' : 'true', ref: modal => this.modal = modal, "modal-width": "w-116", id: "s-multi-warehouse-modal", class: "hidden" }, index.h("div", { class: "text-right" }, index.h("fieldset", { class: "mt-4" }, index.h("h4", { class: "text-sm text-gray-600 mb-6" }, this.formTitle()), index.h("legend", { class: "sr-only" }, this.formTitle()), this.branches.length <= 5 ?
|
|
70
|
+
index.h("div", { class: "space-y-5" }, this.branches.map((branch) => index.h("div", { class: "flex items-center" }, index.h("input", { id: this.position + '_branch_' + branch.id, disabled: !branch.open && this.isChoiceable(), name: "lang", type: "radio", value: branch.id, onChange: (event) => this.handelChange(event), class: {
|
|
71
|
+
'me-3 focus:ring-primary h-4 w-4 text-primary border-gray-300': true,
|
|
72
|
+
'opacity-50': !branch.open,
|
|
73
|
+
'hidden': !this.isChoiceable()
|
|
74
|
+
}, checked: this.current == branch.id }), index.h("label", { htmlFor: this.position + '_branch_' + branch.id, class: {
|
|
75
|
+
'flex items-center justify-between text-sm font-medium text-gray-700 flex-grow': true,
|
|
76
|
+
'cursor-pointer': this.isChoiceable()
|
|
77
|
+
} }, index.h("span", { class: { 'opacity-50': !branch.open } }, branch.name), this.isChoiceable() ?
|
|
78
|
+
index.h("small", { class: "text-red-400" }, branch.open ? '' : 'مُغلق')
|
|
79
|
+
:
|
|
80
|
+
index.h("span", { class: this.statusColor(branch) }, branch.tag)))))
|
|
81
|
+
:
|
|
82
|
+
index.h("select", { class: "w-full h-10 transition-colors duration-300 focus:ring-transparent focus:border-primary sm:text-sm border-gray-200 rounded-md appearance-none visibility_condition px-4", onInput: (event) => this.handelChange(event) }, this.branches.map(branch => (index.h("option", { value: branch.id, disabled: !branch.open, selected: this.selected == branch.id }, branch.name, " ", branch.open ? '' : '- مُغلق')))))), this.isChoiceable() ?
|
|
83
|
+
index.h("div", { slot: "footer", class: "mt-6" }, index.h("slot", { name: "footer" }, index.h("salla-button", { "loader-position": "before", ref: btn => this.btn = btn, onClick: () => this.handleSubmit(), class: "w-full" }, salla.lang.get('common.elements.ok'))))
|
|
84
|
+
: ''));
|
|
85
|
+
}
|
|
86
|
+
componentDidRender() {
|
|
87
|
+
if (!this.isOpenedBefore && this.displayAs == 'popup') {
|
|
88
|
+
this.show();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
get host() { return index.getElement(this); }
|
|
92
|
+
};
|
|
93
|
+
MultiWarehouse.style = multiWarehouseCss;
|
|
94
|
+
|
|
95
|
+
const sallaButtonCss = ":host{display:block}";
|
|
96
|
+
|
|
97
|
+
const SallaButton = class {
|
|
98
|
+
constructor(hostRef) {
|
|
99
|
+
index.registerInstance(this, hostRef);
|
|
100
|
+
this.btnStyle = 'primary'; // outline, outline-primary ,danger
|
|
101
|
+
this.loading = false;
|
|
102
|
+
this.disabled = false;
|
|
103
|
+
this.loaderPosition = 'before';
|
|
104
|
+
this.hostAttributes = {};
|
|
105
|
+
//============= Initiate Button Attributes =============//
|
|
106
|
+
for (let i = 0; i < this.host.attributes.length; i++) {
|
|
107
|
+
this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
|
|
108
|
+
}
|
|
109
|
+
this.hostAttributes.type = this.hostAttributes.type || 'button';
|
|
110
|
+
this.hostAttributes.class = (this.hostAttributes.class || '') +
|
|
111
|
+
' s-button-btn btn--has-loading btn-' + this.btnStyle + ' loader-' + this.loaderPosition;
|
|
112
|
+
this.hostAttributes.class += this.loaderPosition == 'before' ? ' flex-row-reverse' : '';
|
|
113
|
+
// if(this.hostAttributes.onclick){
|
|
114
|
+
// this.hostAttributes.onclick=eval(this.hostAttributes.onclick);
|
|
115
|
+
// }
|
|
116
|
+
delete this.hostAttributes['btn-style'];
|
|
117
|
+
delete this.hostAttributes['id'];
|
|
118
|
+
}
|
|
119
|
+
async load() {
|
|
120
|
+
if (this.loaderPosition == 'center')
|
|
121
|
+
this.host.querySelector('.btn-text').classList.add('opacity-0');
|
|
122
|
+
this.host.setAttribute('loading', '');
|
|
123
|
+
return this.host;
|
|
124
|
+
}
|
|
125
|
+
async stop() {
|
|
126
|
+
this.host.removeAttribute('loading');
|
|
127
|
+
return this.host;
|
|
128
|
+
}
|
|
129
|
+
async disable() {
|
|
130
|
+
this.host.setAttribute('disabled', '');
|
|
131
|
+
}
|
|
132
|
+
async enable() {
|
|
133
|
+
this.host.removeAttribute('disabled');
|
|
134
|
+
}
|
|
135
|
+
handleVisible(newKind, oldKind) {
|
|
136
|
+
this.btn.classList.remove('btn-' + oldKind);
|
|
137
|
+
this.btn.classList.add('btn-' + newKind);
|
|
138
|
+
}
|
|
139
|
+
handleLoading(newVal) {
|
|
140
|
+
Helper.Helper.toggleElement(this.btn, 'btn--is-loading', 'btn--no-loading', () => newVal);
|
|
141
|
+
}
|
|
142
|
+
render() {
|
|
143
|
+
return (index.h("button", Object.assign({ ref: btn => this.btn = btn, disabled: this.disabled }, this.hostAttributes), index.h("span", { class: "btn-text transition-opacity duration-300" }, index.h("slot", null)), this.loading ? index.h("span", { class: {
|
|
144
|
+
'loader loader--small s-button-loader': true,
|
|
145
|
+
'absolute right-2': this.loaderPosition === 'start',
|
|
146
|
+
'absolute left-2': this.loaderPosition === 'end',
|
|
147
|
+
'absolute top-1/2 left-1/2 !-translate-x-1/2 !-translate-y-1/2 !m-0': this.loaderPosition === 'center',
|
|
148
|
+
} }) : ''));
|
|
149
|
+
}
|
|
150
|
+
get host() { return index.getElement(this); }
|
|
151
|
+
static get watchers() { return {
|
|
152
|
+
"btnStyle": ["handleVisible"],
|
|
153
|
+
"loading": ["handleLoading"]
|
|
154
|
+
}; }
|
|
155
|
+
};
|
|
156
|
+
SallaButton.style = sallaButtonCss;
|
|
157
|
+
|
|
158
|
+
const SallaModal = class {
|
|
159
|
+
constructor(hostRef) {
|
|
160
|
+
index.registerInstance(this, hostRef);
|
|
161
|
+
this.ready = index.createEvent(this, "ready", 7);
|
|
162
|
+
this.close = index.createEvent(this, "close", 7);
|
|
163
|
+
this.error = false;
|
|
164
|
+
this.success = false;
|
|
165
|
+
this.isClosable = true;
|
|
166
|
+
this.modalWidth = 'w-96'; //todo use friendly names
|
|
167
|
+
this.visible = false;
|
|
168
|
+
this.subTitle = '';
|
|
169
|
+
this.icon = '';
|
|
170
|
+
salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
|
|
171
|
+
salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
|
|
172
|
+
this.title = this.host.title;
|
|
173
|
+
this.host.removeAttribute('title');
|
|
174
|
+
}
|
|
175
|
+
handleVisible(newValue) {
|
|
176
|
+
if (!newValue) {
|
|
177
|
+
this.toggleModal(false);
|
|
178
|
+
this.close.emit();
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
this.host.classList.remove('hidden');
|
|
182
|
+
setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
|
|
183
|
+
this.ready.emit();
|
|
184
|
+
}
|
|
185
|
+
async show() {
|
|
186
|
+
this.host.setAttribute('visible', '');
|
|
187
|
+
return this.host;
|
|
188
|
+
}
|
|
189
|
+
async hide() {
|
|
190
|
+
this.host.removeAttribute('visible');
|
|
191
|
+
return this.host;
|
|
192
|
+
}
|
|
193
|
+
async setTitle(title) {
|
|
194
|
+
this.title = title;
|
|
195
|
+
return this.host;
|
|
196
|
+
}
|
|
197
|
+
toggleModal(isOpen) {
|
|
198
|
+
//todo:: use ref
|
|
199
|
+
Helper.Helper.toggleElement(this.host.querySelector('.s-modal-overlay'), 'ease-out duration-300 opacity-100', 'opacity-0', () => isOpen)
|
|
200
|
+
.toggleElement(this.host.querySelector('.s-modal-body'), 'ease-out duration-300 opacity-100 translate-y-0 sm:scale-100', //add these classes
|
|
201
|
+
'opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95', //remove these classes
|
|
202
|
+
() => isOpen)
|
|
203
|
+
.toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
|
|
204
|
+
if (!isOpen) {
|
|
205
|
+
setTimeout(() => this.host.classList.add('hidden'), 350);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
closeModal() {
|
|
209
|
+
if (!this.isClosable) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
this.host.removeAttribute('visible');
|
|
213
|
+
}
|
|
214
|
+
//todo:: pref for each modal
|
|
215
|
+
render() {
|
|
216
|
+
this.host.id = this.host.id || 'salla-modal';
|
|
217
|
+
return (index.h(index.Host, { class: 's-modal-container hidden', "aria-modal": "true", role: "dialog" }, index.h("div", { class: "s-modal-wrapper" }, index.h("div", { class: "s-modal-overlay", onClick: () => this.closeModal() }), index.h("span", { class: "s-modal-spacer" }, "\u200B"), index.h("div", { class: 's-modal-body ' + this.modalWidth }, index.h("div", { class: { 's-modal-header': true,
|
|
218
|
+
'text-center': this.icon != '' } }, this.isClosable ?
|
|
219
|
+
index.h("button", { class: "s-modal-close cursor-pointer", onClick: () => this.closeModal(), type: "button" }, index.h("span", { class: "sicon-cancel" }))
|
|
220
|
+
: '', this.error || this.success || this.icon
|
|
221
|
+
? index.h("div", { class: {
|
|
222
|
+
's-modal-icon': true,
|
|
223
|
+
's-modal-bg-error': this.error,
|
|
224
|
+
's-modal-bg-success': this.success,
|
|
225
|
+
's-modal-bg-normal': !this.error && !this.success
|
|
226
|
+
} }, index.h("i", { class: {
|
|
227
|
+
[this.icon]: true,
|
|
228
|
+
's-modal-text-error': this.error,
|
|
229
|
+
's-modal-text-success': this.success,
|
|
230
|
+
} }))
|
|
231
|
+
: '', index.h("div", { class: "s-modal-title", innerHTML: this.title }), index.h("p", { class: "s-modal-sub-title", innerHTML: this.subTitle })), index.h("slot", null), index.h("slot", { name: "footer" })))));
|
|
232
|
+
}
|
|
233
|
+
get host() { return index.getElement(this); }
|
|
234
|
+
static get watchers() { return {
|
|
235
|
+
"visible": ["handleVisible"]
|
|
236
|
+
}; }
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
exports.salla_login = sallaLogin.SallaLogin;
|
|
240
|
+
exports.multi_warehouse = MultiWarehouse;
|
|
241
|
+
exports.salla_button = SallaButton;
|
|
242
|
+
exports.salla_modal = SallaModal;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-23da2c6b.js');
|
|
6
|
+
const Helper = require('./Helper-8852feaa.js');
|
|
7
|
+
|
|
8
|
+
const SallaLocalization = class {
|
|
9
|
+
constructor(hostRef) {
|
|
10
|
+
index.registerInstance(this, hostRef);
|
|
11
|
+
var _a, _b;
|
|
12
|
+
this.language = salla.config.language;
|
|
13
|
+
this.currency = salla.config.currency;
|
|
14
|
+
this.languages = salla.lang.get('common.titles.language');
|
|
15
|
+
this.currencies = salla.lang.get('common.titles.currency');
|
|
16
|
+
this.ok = salla.lang.get('common.elements.ok');
|
|
17
|
+
Helper.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.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.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
|
+
}
|
|
31
|
+
async show() {
|
|
32
|
+
return this.modal.show();
|
|
33
|
+
}
|
|
34
|
+
async hide() {
|
|
35
|
+
return this.modal.hide();
|
|
36
|
+
}
|
|
37
|
+
async submit() {
|
|
38
|
+
let url;
|
|
39
|
+
this.btn.load()
|
|
40
|
+
.then(() => {
|
|
41
|
+
if (this.currency && this.currency.code !== salla.config.currency.code) {
|
|
42
|
+
url = window.location.href;
|
|
43
|
+
return salla.currency.api.change(this.currency.code);
|
|
44
|
+
}
|
|
45
|
+
}).then(() => {
|
|
46
|
+
if (this.language && this.language.code !== salla.config.language.code) {
|
|
47
|
+
url = this.language.url;
|
|
48
|
+
}
|
|
49
|
+
}).then(() => this.btn.stop())
|
|
50
|
+
.then(() => this.hide())
|
|
51
|
+
.then(() => url && (window.location.href = url));
|
|
52
|
+
}
|
|
53
|
+
render() {
|
|
54
|
+
return (index.h("salla-modal", { id: "salla-localization", class: "hidden", ref: modal => this.modal = modal }, index.h("slot", { name: "header" }, index.h("div", { slot: "header" })), index.h("div", { class: "s-localization-inner" }, salla.config.languages
|
|
55
|
+
? index.h("div", { class: "s-localization-section" }, index.h("label", { class: "s-localization-title" }, this.languages), index.h("fieldset", { class: "s-localization-fieldset" }, index.h("legend", { class: "sr-only" }, salla.lang.get('blocks.header.change_language')), index.h("div", { class: "s-localization-section-inner" }, salla.config.languages.map(lang => index.h("div", { class: "s-localization-item" }, index.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 }), index.h("div", { id: "language-slot", innerHTML: this.languageSlot
|
|
56
|
+
.replace(/\{name\}/g, lang.name)
|
|
57
|
+
.replace(/\{code\}/g, lang.code)
|
|
58
|
+
.replace(/\{country_code\}/g, lang.country_code) }))))))
|
|
59
|
+
: '', salla.config.currencies
|
|
60
|
+
? index.h("div", { class: "s-localization-section" }, index.h("label", { class: "s-localization-title" }, this.currencies), index.h("fieldset", { class: "s-localization-fieldset" }, index.h("legend", { class: "sr-only" }, salla.lang.get('blocks.header.change_currency')), index.h("div", { class: "s-localization-section-inner" }, salla.config.currencies.map(currency => index.h("div", { class: "s-localization-item" }, index.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 }), index.h("div", { id: "currency-slot", innerHTML: this.currencySlot
|
|
61
|
+
.replace(/\{name\}/g, currency.name)
|
|
62
|
+
.replace(/\{code\}/g, currency.code)
|
|
63
|
+
.replace(/\{country_code\}/g, currency.country_code) }))))))
|
|
64
|
+
: ''), index.h("p", { slot: "footer" }, index.h("slot", { name: "footer" }, index.h("salla-button", { ref: btn => this.btn = btn, onClick: () => this.submit(), class: "w-full" }, 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 index.getElement(this); }
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
exports.salla_localization = SallaLocalization;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('./index-23da2c6b.js');
|
|
4
|
+
|
|
5
|
+
const SallaLogin = class {
|
|
6
|
+
constructor(hostRef) {
|
|
7
|
+
index.registerInstance(this, hostRef);
|
|
8
|
+
}
|
|
9
|
+
render() {
|
|
10
|
+
return (index.h("salla-modal", { id: "salla-login", title: "\u0633\u062C\u0644 \u062F\u062E\u0648\u0644 \u0625\u0644\u0649 \u0627\u0644\u0645\u0648\u0642\u0639" }, index.h("div", { id: "showLoginMethods" }, index.h("p", { class: "text-sm text-gray-text mb-5" }, "\u0627\u062E\u062A\u0631 \u0627\u0644\u0648\u0633\u064A\u0644\u0629 \u0627\u0644\u0645\u0646\u0627\u0633\u0628\u0629"), index.h("div", { id: "openEmailLogin", class: "mb-2.5 box-content relative rounded-md border border-border-color bg-white py-5 pe-4 ps-5 flex items-center space-s-3 hover:border-gray-200" }, index.h("div", { class: "flex-shrink-0" }, index.h("div", { class: "bg-primary w-12 h-12 text-lg text-white rounded-icon" }, index.h("i", { class: "sicon-mail" }))), index.h("div", { class: "flex-1 min-w-0" }, index.h("a", { href: "#", class: "focus:outline-none flex justify-between items-center" }, index.h("div", { class: "flex-1" }, index.h("span", { class: "absolute inset-0", "aria-hidden": "true" }), index.h("p", { class: "text-sm text-gray-text" }, "\u0633\u062C\u0644 \u062F\u062E\u0648\u0644"), index.h("h6", { class: "font-boldf" }, "\u0627\u0644\u0628\u0631\u064A\u062F \u0627\u0644\u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A")), index.h("i", { class: "sicon-keyboard_arrow_left text-primary text-xl" })))), index.h("div", { class: "box-content relative rounded-md border border-border-color bg-white py-5 pe-4 ps-5 flex items-center space-s-3 hover:border-gray-200" }, index.h("div", { class: "flex-shrink-0" }, index.h("div", { class: "bg-primary w-12 h-12 text-lg text-white rounded-icon" }, index.h("i", { class: "sicon-phone" }))), index.h("div", { class: "flex-1 min-w-0" }, index.h("a", { href: "#", class: "focus:outline-none flex justify-between items-center" }, index.h("div", { class: "flex-1" }, index.h("span", { class: "absolute inset-0", "aria-hidden": "true" }), index.h("p", { class: "text-sm text-gray-text" }, "\u0633\u062C\u0644 \u062F\u062E\u0648\u0644"), index.h("h6", { class: "font-boldf" }, "\u0627\u0644\u0647\u0627\u062A\u0641")), index.h("i", { class: "sicon-keyboard_arrow_left text-primary text-xl" })))))));
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.SallaLogin = SallaLogin;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-23da2c6b.js');
|
|
6
|
+
const Helper = require('./Helper-8852feaa.js');
|
|
7
|
+
|
|
8
|
+
const SallaProductAvailability = class {
|
|
9
|
+
constructor(hostRef) {
|
|
10
|
+
index.registerInstance(this, hostRef);
|
|
11
|
+
this.isUser = Helper.Helper.isUser();
|
|
12
|
+
this.buttonText = salla.lang.get('pages.products.notify_availability');
|
|
13
|
+
this.countryCode = salla.config.country_code || 'SA';
|
|
14
|
+
this.subscribe = salla.lang.get('common.elements.submit');
|
|
15
|
+
this.cancel = salla.lang.get('common.elements.cancel');
|
|
16
|
+
this.subTitle = salla.lang.get('pages.products.notify_availability_subtitle');
|
|
17
|
+
this.mobileLabel = salla.lang.get('common.elements.mobile');
|
|
18
|
+
this.emailLabel = salla.lang.get('common.elements.email');
|
|
19
|
+
this.mobilePlaceholder = salla.lang.get('common.elements.mobile_placeholder');
|
|
20
|
+
this.emailPlaceholder = salla.lang.get('common.elements.email_placeholder');
|
|
21
|
+
this.productId = salla.config.page.id;
|
|
22
|
+
this.subscribed = salla.lang.get('pages.products.notify_availability_success');
|
|
23
|
+
if (this.isUser) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
this.channelsWatcher(this.channels);
|
|
27
|
+
this.title_ = this.host.title || salla.lang.get('pages.products.notify_availability_title');
|
|
28
|
+
this.host.removeAttribute('title');
|
|
29
|
+
}
|
|
30
|
+
channelsWatcher(newValue) {
|
|
31
|
+
this.channels_ = newValue.split(',');
|
|
32
|
+
}
|
|
33
|
+
async submit() {
|
|
34
|
+
if (this.isUser) {
|
|
35
|
+
return salla.api.product.availabilitySubscribe(this.productId)
|
|
36
|
+
.then(() => {
|
|
37
|
+
salla.success(this.subscribed);
|
|
38
|
+
}) //no need to wait until finishing alert animation
|
|
39
|
+
.then(() => this.host.remove());
|
|
40
|
+
}
|
|
41
|
+
let data = { id: this.productId, country_code: this.countryCode };
|
|
42
|
+
if (this.mobile.value !== '') {
|
|
43
|
+
data['mobile'] = this.mobile.value;
|
|
44
|
+
}
|
|
45
|
+
if (this.email.value !== '') {
|
|
46
|
+
data['email'] = this.email.value;
|
|
47
|
+
}
|
|
48
|
+
return this.btn.load()
|
|
49
|
+
.then(() => this.btn.disable())
|
|
50
|
+
.then(() => salla.api.product.availabilitySubscribe(data))
|
|
51
|
+
.then(() => {
|
|
52
|
+
salla.success(this.subscribed);
|
|
53
|
+
}) //no need to wait until finishing alert animation
|
|
54
|
+
.then(() => this.btn.stop())
|
|
55
|
+
.then(() => this.modal.hide())
|
|
56
|
+
.then(() => this.host.remove())
|
|
57
|
+
.catch(() => this.btn.stop() && this.btn.enable());
|
|
58
|
+
}
|
|
59
|
+
render() {
|
|
60
|
+
return (index.h(index.Host, null, index.h("slot", null, index.h("salla-button", { onClick: () => this.isUser ? this.submit() : this.modal.show() }, this.buttonText)), this.isUser ? '' : this.renderModal()));
|
|
61
|
+
}
|
|
62
|
+
renderModal() {
|
|
63
|
+
return (index.h("salla-modal", { ref: modal => this.modal = modal, id: "product-availability-modal", title: this.title_, subTitle: this.subTitle, icon: "sicon-bell-ring", modalWidth: "w-full" }, index.h("div", { class: "s-product-availability-body" }, this.channels_.includes('email') ? [
|
|
64
|
+
index.h("label", { class: "s-product-availability-label" }, this.emailLabel),
|
|
65
|
+
index.h("input", { class: "s-product-availability-input", placeholder: this.emailPlaceholder, ref: el => this.email = el, type: "email" })
|
|
66
|
+
] : '', this.channels_.includes('sms') ? [
|
|
67
|
+
index.h("label", { class: "s-product-availability-label" }, this.mobileLabel),
|
|
68
|
+
index.h("input", { class: "s-product-availability-input", placeholder: this.mobilePlaceholder, ref: el => this.mobile = el, type: "text" }),
|
|
69
|
+
index.h("input", { type: "hidden", value: this.countryCode }),
|
|
70
|
+
] : ''), index.h("div", { slot: "footer", class: "common-anime flex justify-between space-s-4" }, index.h("salla-button", { ref: btn => this.btn = btn, class: "w-full", onClick: () => this.submit() }, this.subscribe), index.h("salla-button", { class: "w-full", color: "outline" }, this.cancel))));
|
|
71
|
+
}
|
|
72
|
+
get host() { return index.getElement(this); }
|
|
73
|
+
static get watchers() { return {
|
|
74
|
+
"channels": ["channelsWatcher"]
|
|
75
|
+
}; }
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
exports.salla_product_availability = SallaProductAvailability;
|