@salla.sa/twilight-components 1.0.14 → 1.0.15
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-0b5b5867.js +1656 -0
- package/dist/cjs/index.cjs.js +13 -0
- package/dist/cjs/loader.cjs.js +21 -0
- package/dist/cjs/salla-branches.cjs.entry.js +92 -0
- package/dist/cjs/salla-button.cjs.entry.js +77 -0
- package/dist/cjs/salla-localization.cjs.entry.js +77 -0
- package/dist/cjs/salla-login-6a54572d.js +14 -0
- package/dist/cjs/salla-login_2.cjs.entry.js +97 -0
- package/dist/cjs/salla-product-availability.cjs.entry.js +75 -0
- package/dist/cjs/salla-rating.cjs.entry.js +303 -0
- package/dist/cjs/salla-search-311c7053.js +81 -0
- package/dist/cjs/salla-search.cjs.entry.js +11 -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/salla-branches/salla-branches.css +12 -0
- package/dist/collection/components/salla-branches/salla-branches.js +235 -0
- package/dist/collection/components/salla-button/salla-button.css +3 -0
- package/dist/collection/components/salla-button/salla-button.js +243 -0
- package/dist/collection/components/salla-localization/salla-localization.js +200 -0
- package/dist/collection/components/salla-login/salla-login.js +31 -0
- package/dist/collection/components/salla-modal/salla-modal.js +360 -0
- package/dist/collection/components/salla-product-availability/salla-product-availability.js +331 -0
- package/dist/collection/components/salla-rating/salla-rating.css +3 -0
- package/dist/collection/components/salla-rating/salla-rating.js +488 -0
- package/dist/collection/components/salla-search/salla-search.js +132 -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 → esm}/Helper-81ac9a8c.js +0 -0
- package/dist/esm/index-8b97d225.js +1628 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/loader.js +17 -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/{twilight-components/multi-warehouse.entry.js → esm/salla-branches.entry.js} +16 -17
- package/dist/{twilight-components → esm}/salla-button.entry.js +1 -1
- package/dist/{twilight-components → esm}/salla-localization.entry.js +1 -1
- package/dist/{twilight-components/salla-login-97e0a9ab.js → esm/salla-login-c9c9fa57.js} +1 -1
- package/dist/{twilight-components/salla-modal.entry.js → esm/salla-login_2.entry.js} +16 -9
- package/dist/{twilight-components → esm}/salla-product-availability.entry.js +1 -1
- package/dist/{twilight-components → esm}/salla-rating.entry.js +9 -5
- package/dist/esm/salla-search-add7bdb6.js +79 -0
- package/dist/esm/salla-search.entry.js +3 -0
- package/dist/{twilight-components → esm}/salla-verify.entry.js +1 -1
- 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-010b8dfd.entry.js +1 -0
- package/dist/twilight-components/p-0ceecf63.js +1 -0
- package/dist/twilight-components/p-32d29245.entry.js +1 -0
- package/dist/twilight-components/p-50e70ad4.entry.js +1 -0
- package/dist/twilight-components/p-68c9f122.entry.js +1 -0
- package/dist/twilight-components/p-8126278e.entry.js +1 -0
- package/dist/twilight-components/p-9bc28e0c.js +1 -0
- package/dist/twilight-components/p-9d327a79.entry.js +1 -0
- package/dist/twilight-components/p-b05450bc.entry.js +1 -0
- package/dist/twilight-components/p-bd5da080.js +1 -0
- package/dist/twilight-components/p-cb1c59a2.js +1 -0
- package/dist/twilight-components/p-d584d0c7.entry.js +1 -0
- package/dist/twilight-components/twilight-components.css +1 -3
- package/dist/twilight-components/twilight-components.esm.js +1 -125
- package/dist/types/components/{multi-warehouse/multi-warehouse.d.ts → salla-branches/salla-branches.d.ts} +1 -1
- package/dist/types/components/salla-modal/salla-modal.d.ts +3 -0
- package/dist/types/components/salla-rating/salla-rating.d.ts +2 -2
- package/dist/types/components/salla-search/salla-search.d.ts +20 -17
- package/dist/types/components.d.ts +19 -15
- 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/salla-login.entry.js +0 -2
- package/dist/twilight-components/salla-search-df1c9b54.js +0 -95
- package/dist/twilight-components/salla-search.entry.js +0 -2
- package/dist/twilight-components/shadow-css-bc14d9fd.js +0 -389
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const sallaLogin = require('./salla-login-6a54572d.js');
|
|
6
|
+
const sallaSearch = require('./salla-search-311c7053.js');
|
|
7
|
+
require('./index-0b5b5867.js');
|
|
8
|
+
require('./Helper-8852feaa.js');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
exports.SallaLogin = sallaLogin.SallaLogin;
|
|
13
|
+
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-0b5b5867.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([["salla-button.cjs",[[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"disable":[64],"enable":[64]}]]],["salla-login_2.cjs",[[0,"salla-login"],[4,"salla-modal",{"error":[4],"success":[4],"isClosable":[1028,"is-closable"],"modalWidth":[513,"modal-width"],"visible":[516],"subTitleFirst":[4,"sub-title-first"],"subTitle":[1,"sub-title"],"icon":[1],"imageIcon":[1,"image-icon"],"show":[64],"hide":[64],"setTitle":[64]}]]],["salla-branches.cjs",[[4,"salla-branches",{"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]}]]],["salla-localization.cjs",[[4,"salla-localization",{"languagesTitle":[1,"languages-title"],"currenciesTitle":[1,"currencies-title"],"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"],"subscribeText":[1,"subscribe-text"],"cancelText":[1,"cancel-text"],"subTitle":[1,"sub-title"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"mobilePlaceholder":[1,"mobile-placeholder"],"emailPlaceholder":[1,"email-placeholder"],"productId":[2,"product-id"],"subscribedMessage":[1,"subscribed-message"],"isSubscribed":[1028,"is-subscribed"],"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",[[0,"salla-search",{"placeholder":[1],"noResultsText":[1,"no-results-text"],"results":[32]},[[0,"close","onModalClose"]]]]]], options);
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.defineCustomElements = defineCustomElements;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-0b5b5867.js');
|
|
6
|
+
|
|
7
|
+
const sallaBranchesCss = ":host{display:block}";
|
|
8
|
+
|
|
9
|
+
let engine = require('store/src/store-engine');
|
|
10
|
+
let storages = require('store/storages/sessionStorage');
|
|
11
|
+
let sessionStore = engine.createStore(storages);
|
|
12
|
+
const SallaBranches = class {
|
|
13
|
+
constructor(hostRef) {
|
|
14
|
+
index.registerInstance(this, hostRef);
|
|
15
|
+
this.open = false;
|
|
16
|
+
this.isOpenedBefore = sessionStore.get("branch-choosed-before");
|
|
17
|
+
this.displayAs = 'default';
|
|
18
|
+
this.browseProductsFrom = 'all';
|
|
19
|
+
this.branches = [
|
|
20
|
+
{ id: 1, name: 'فرع الرياض', open: true, available: true, limited: false, tag: 'متوفر' },
|
|
21
|
+
{ id: 2, name: 'فرع جدة', open: false, available: false, limited: false, tag: 'غير متوفر' },
|
|
22
|
+
{ id: 3, name: 'فرع مكة', open: true, available: true, limited: false, tag: 'متوفر' },
|
|
23
|
+
{ id: 4, name: 'فرع المدينة', open: true, available: true, limited: false, tag: 'متوفر' },
|
|
24
|
+
{ id: 5, name: 'فرع جازان', open: true, available: true, limited: true, tag: 'الكمية محدودة' }
|
|
25
|
+
];
|
|
26
|
+
this.current = 1;
|
|
27
|
+
this.currentBranch = (prop) => {
|
|
28
|
+
return this.branches.filter((el) => el.id == this.current)[0][prop];
|
|
29
|
+
};
|
|
30
|
+
this.statusColor = (branch = null) => {
|
|
31
|
+
return branch ?
|
|
32
|
+
branch.limited ? 'text-red-400' : branch.available ? 'text-green-500' : 'text-gray-400'
|
|
33
|
+
:
|
|
34
|
+
this.currentBranch('limited') ? 'text-red-400' : this.currentBranch('available') ? 'text-green-500' : 'text-gray-400';
|
|
35
|
+
};
|
|
36
|
+
this.isChoiceable = () => {
|
|
37
|
+
return (this.browseProductsFrom !== 'all' && this.position == 'single') || this.position == 'header';
|
|
38
|
+
};
|
|
39
|
+
this.formTitle = () => {
|
|
40
|
+
return this.isChoiceable() ?
|
|
41
|
+
'توفر المنتج في الفروع الآخرى'
|
|
42
|
+
: 'التسوق من فرع آخر';
|
|
43
|
+
};
|
|
44
|
+
salla.event.on('branches::show', () => this.show());
|
|
45
|
+
}
|
|
46
|
+
async show() {
|
|
47
|
+
return this.modal.show();
|
|
48
|
+
}
|
|
49
|
+
async hide() {
|
|
50
|
+
return this.modal.hide();
|
|
51
|
+
}
|
|
52
|
+
handelChange(event) {
|
|
53
|
+
this.selected = event.target.value;
|
|
54
|
+
}
|
|
55
|
+
handleSubmit() {
|
|
56
|
+
this.btn.load().then(() => {
|
|
57
|
+
setTimeout(() => location.reload(), 2000);
|
|
58
|
+
});
|
|
59
|
+
sessionStore.set("branch-choosed-before", true);
|
|
60
|
+
this.show();
|
|
61
|
+
setTimeout(() => {
|
|
62
|
+
this.current = this.selected;
|
|
63
|
+
}, 300);
|
|
64
|
+
}
|
|
65
|
+
render() {
|
|
66
|
+
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", "sub-title-first": true, "is-closable": !this.isOpenedBefore && this.displayAs == 'popup' ? 'false' : 'true', ref: modal => this.modal = modal, "modal-width": "w-116", id: "s-branches-modal", class: "hidden" }, index.h("fieldset", null, index.h("h4", { class: "s-branches-title" }, this.formTitle()), index.h("legend", { class: "s-branches-sr-only" }, this.formTitle()), this.branches.length <= 5 ?
|
|
67
|
+
index.h("div", { class: "s-branches-space-v" }, this.branches.map((branch) => index.h("div", { class: "s-branches-input-wrap" }, 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: {
|
|
68
|
+
's-branches-input': true,
|
|
69
|
+
'opacity-50': !branch.open,
|
|
70
|
+
'hidden': !this.isChoiceable()
|
|
71
|
+
}, checked: this.current == branch.id }), index.h("label", { htmlFor: this.position + '_branch_' + branch.id, class: {
|
|
72
|
+
's-branches-label': true,
|
|
73
|
+
's-branches-clickable': this.isChoiceable()
|
|
74
|
+
} }, index.h("span", { class: { 's-branches-is-closed': !branch.open } }, branch.name), this.isChoiceable() ?
|
|
75
|
+
index.h("small", { class: "s-branches-closed-badge" }, branch.open ? '' : 'مُغلق')
|
|
76
|
+
:
|
|
77
|
+
index.h("span", { class: this.statusColor(branch) }, branch.tag)))))
|
|
78
|
+
:
|
|
79
|
+
index.h("select", { class: "s-branches-select", 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() ?
|
|
80
|
+
index.h("slot", { name: "footer" }, index.h("salla-button", { "loader-position": "before", ref: btn => this.btn = btn, onClick: () => this.handleSubmit(), class: "s-branches-submit" }, salla.lang.get('common.elements.ok')))
|
|
81
|
+
: ''));
|
|
82
|
+
}
|
|
83
|
+
componentDidRender() {
|
|
84
|
+
if (!this.isOpenedBefore && this.displayAs == 'popup') {
|
|
85
|
+
this.show();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
get host() { return index.getElement(this); }
|
|
89
|
+
};
|
|
90
|
+
SallaBranches.style = sallaBranchesCss;
|
|
91
|
+
|
|
92
|
+
exports.salla_branches = SallaBranches;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-0b5b5867.js');
|
|
6
|
+
const Helper = require('./Helper-8852feaa.js');
|
|
7
|
+
|
|
8
|
+
const sallaButtonCss = ":host{display:block}";
|
|
9
|
+
|
|
10
|
+
const SallaButton = class {
|
|
11
|
+
constructor(hostRef) {
|
|
12
|
+
index.registerInstance(this, hostRef);
|
|
13
|
+
this.btnStyle = 'primary'; // outline, outline-primary ,danger
|
|
14
|
+
this.loading = false;
|
|
15
|
+
this.disabled = false;
|
|
16
|
+
this.loaderPosition = 'before';
|
|
17
|
+
this.wide = false;
|
|
18
|
+
this.hostAttributes = {};
|
|
19
|
+
//============= Initiate Button Attributes =============//
|
|
20
|
+
for (let i = 0; i < this.host.attributes.length; i++) {
|
|
21
|
+
this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
|
|
22
|
+
}
|
|
23
|
+
this.hostAttributes.type = this.hostAttributes.type || 'button';
|
|
24
|
+
this.hostAttributes.class += ' s-button-btn btn--has-loading '
|
|
25
|
+
+ 'btn-' + this.btnStyle
|
|
26
|
+
+ (this.wide ? ' s-button-wide ' : '')
|
|
27
|
+
+ 'loader-' + this.loaderPosition
|
|
28
|
+
+ (this.loaderPosition == 'before' ? ' flex-row-reverse' : '');
|
|
29
|
+
// if(this.hostAttributes.onclick){
|
|
30
|
+
// this.hostAttributes.onclick=eval(this.hostAttributes.onclick);
|
|
31
|
+
// }
|
|
32
|
+
delete this.hostAttributes['btn-style'];
|
|
33
|
+
delete this.hostAttributes['id'];
|
|
34
|
+
if (this.wide) {
|
|
35
|
+
this.host.classList.add('s-button-wide');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async load() {
|
|
39
|
+
if (this.loaderPosition == 'center')
|
|
40
|
+
this.host.querySelector('.btn-text').classList.add('opacity-0');
|
|
41
|
+
this.host.setAttribute('loading', '');
|
|
42
|
+
return this.host;
|
|
43
|
+
}
|
|
44
|
+
async stop() {
|
|
45
|
+
this.host.removeAttribute('loading');
|
|
46
|
+
return this.host;
|
|
47
|
+
}
|
|
48
|
+
async disable() {
|
|
49
|
+
this.host.setAttribute('disabled', '');
|
|
50
|
+
}
|
|
51
|
+
async enable() {
|
|
52
|
+
this.host.removeAttribute('disabled');
|
|
53
|
+
}
|
|
54
|
+
handleVisible(newKind, oldKind) {
|
|
55
|
+
this.btn.classList.remove('btn-' + oldKind);
|
|
56
|
+
this.btn.classList.add('btn-' + newKind);
|
|
57
|
+
}
|
|
58
|
+
handleLoading(newVal) {
|
|
59
|
+
Helper.Helper.toggleElement(this.btn, 'btn--is-loading', 'btn--no-loading', () => newVal);
|
|
60
|
+
}
|
|
61
|
+
render() {
|
|
62
|
+
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: {
|
|
63
|
+
'loader loader--small s-button-loader': true,
|
|
64
|
+
'absolute right-2': this.loaderPosition === 'start',
|
|
65
|
+
'absolute left-2': this.loaderPosition === 'end',
|
|
66
|
+
'absolute top-1/2 left-1/2 !-translate-x-1/2 !-translate-y-1/2 !m-0': this.loaderPosition === 'center',
|
|
67
|
+
} }) : ''));
|
|
68
|
+
}
|
|
69
|
+
get host() { return index.getElement(this); }
|
|
70
|
+
static get watchers() { return {
|
|
71
|
+
"btnStyle": ["handleVisible"],
|
|
72
|
+
"loading": ["handleLoading"]
|
|
73
|
+
}; }
|
|
74
|
+
};
|
|
75
|
+
SallaButton.style = sallaButtonCss;
|
|
76
|
+
|
|
77
|
+
exports.salla_button = SallaButton;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-0b5b5867.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
|
+
//todo::
|
|
15
|
+
this.languagesTitle = salla.lang.get('common.titles.language');
|
|
16
|
+
this.currenciesTitle = salla.lang.get('common.titles.currency');
|
|
17
|
+
this.ok = salla.lang.get('common.elements.ok');
|
|
18
|
+
Helper.Helper.setHost(this.host);
|
|
19
|
+
salla.event.on('localization::show', () => this.show());
|
|
20
|
+
/**
|
|
21
|
+
* letting developer to insert his own slot like:
|
|
22
|
+
* <salla-localization>
|
|
23
|
+
* <div slot="language">...{name}....</div>
|
|
24
|
+
* <div slot="currency">...{name}....</div>
|
|
25
|
+
* </salla-localization>
|
|
26
|
+
* Because scoped templates not supported in stencil );
|
|
27
|
+
* we made a workaround to pass language & currency attributes, then replace names in rendering
|
|
28
|
+
*/
|
|
29
|
+
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>';
|
|
30
|
+
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>';
|
|
31
|
+
}
|
|
32
|
+
async show() {
|
|
33
|
+
return this.modal.show();
|
|
34
|
+
}
|
|
35
|
+
async hide() {
|
|
36
|
+
return this.modal.hide();
|
|
37
|
+
}
|
|
38
|
+
async submit() {
|
|
39
|
+
let url;
|
|
40
|
+
this.btn.load()
|
|
41
|
+
.then(() => {
|
|
42
|
+
if (this.currency && this.currency.code !== salla.config.currency.code) {
|
|
43
|
+
url = window.location.href;
|
|
44
|
+
return salla.currency.api.change(this.currency.code);
|
|
45
|
+
}
|
|
46
|
+
}).then(() => {
|
|
47
|
+
if (this.language && this.language.code !== salla.config.language.code) {
|
|
48
|
+
url = this.language.url;
|
|
49
|
+
}
|
|
50
|
+
}).then(() => this.btn.stop())
|
|
51
|
+
.then(() => this.hide())
|
|
52
|
+
.then(() => url && (window.location.href = url));
|
|
53
|
+
}
|
|
54
|
+
render() {
|
|
55
|
+
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
|
|
56
|
+
? index.h("div", { class: "s-localization-section" }, index.h("label", { class: "s-localization-title" }, this.languagesTitle), index.h("fieldset", { class: "s-localization-fieldset" }, 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
|
|
57
|
+
.replace(/\{name\}/g, lang.name)
|
|
58
|
+
.replace(/\{code\}/g, lang.code)
|
|
59
|
+
.replace(/\{country_code\}/g, lang.country_code) }))))))
|
|
60
|
+
: '', salla.config.currencies
|
|
61
|
+
? index.h("div", { class: "s-localization-section" }, index.h("label", { class: "s-localization-title" }, this.currenciesTitle), index.h("fieldset", { class: "s-localization-fieldset" }, 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
|
|
62
|
+
.replace(/\{name\}/g, currency.name)
|
|
63
|
+
.replace(/\{code\}/g, currency.code)
|
|
64
|
+
.replace(/\{country_code\}/g, currency.country_code) }))))))
|
|
65
|
+
: ''), index.h("p", { slot: "footer" }, index.h("slot", { name: "footer" }, index.h("salla-button", { wide: true, ref: btn => this.btn = btn, onClick: () => this.submit() }, this.ok)))));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* to reduce dom levels we will move slot data into the parent dom
|
|
69
|
+
*/
|
|
70
|
+
componentDidRender() {
|
|
71
|
+
this.host.querySelectorAll('#currency-slot').forEach(el => el.replaceWith(el.firstChild));
|
|
72
|
+
this.host.querySelectorAll('#language-slot').forEach(el => el.replaceWith(el.firstChild));
|
|
73
|
+
}
|
|
74
|
+
get host() { return index.getElement(this); }
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
exports.salla_localization = SallaLocalization;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('./index-0b5b5867.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,97 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const sallaLogin = require('./salla-login-6a54572d.js');
|
|
6
|
+
const index = require('./index-0b5b5867.js');
|
|
7
|
+
const Helper = require('./Helper-8852feaa.js');
|
|
8
|
+
|
|
9
|
+
const SallaModal = class {
|
|
10
|
+
constructor(hostRef) {
|
|
11
|
+
index.registerInstance(this, hostRef);
|
|
12
|
+
this.ready = index.createEvent(this, "ready", 7);
|
|
13
|
+
this.close = index.createEvent(this, "close", 7);
|
|
14
|
+
var _a;
|
|
15
|
+
this.error = false;
|
|
16
|
+
this.success = false;
|
|
17
|
+
this.isClosable = true;
|
|
18
|
+
this.modalWidth = 'w-96'; //todo use friendly names
|
|
19
|
+
this.visible = false;
|
|
20
|
+
this.subTitleFirst = false;
|
|
21
|
+
this.subTitle = '';
|
|
22
|
+
this.icon = '';
|
|
23
|
+
this.imageIcon = '';
|
|
24
|
+
Helper.Helper.setHost(this.host);
|
|
25
|
+
salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
|
|
26
|
+
salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
|
|
27
|
+
this.title = this.host.title;
|
|
28
|
+
this.host.removeAttribute('title');
|
|
29
|
+
(_a = Helper.Helper.getElement('[slot=body]')) === null || _a === void 0 ? void 0 : _a.classList.add('s-modal-body');
|
|
30
|
+
}
|
|
31
|
+
handleVisible(newValue) {
|
|
32
|
+
if (!newValue) {
|
|
33
|
+
this.toggleModal(false);
|
|
34
|
+
this.close.emit();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
this.host.classList.remove('hidden');
|
|
38
|
+
setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
|
|
39
|
+
this.ready.emit();
|
|
40
|
+
}
|
|
41
|
+
async show() {
|
|
42
|
+
this.host.setAttribute('visible', '');
|
|
43
|
+
return this.host;
|
|
44
|
+
}
|
|
45
|
+
async hide() {
|
|
46
|
+
this.host.removeAttribute('visible');
|
|
47
|
+
return this.host;
|
|
48
|
+
}
|
|
49
|
+
async setTitle(title) {
|
|
50
|
+
this.title = title;
|
|
51
|
+
return this.host;
|
|
52
|
+
}
|
|
53
|
+
toggleModal(isOpen) {
|
|
54
|
+
Helper.Helper.toggleElement(this.host.querySelector('.s-modal-body'), 's-modal-entering', 's-modal-leaving', () => isOpen)
|
|
55
|
+
.toggleElement(this.host.querySelector('[slot=body]'), 's-modal-entering', 's-modal-leaving', () => isOpen)
|
|
56
|
+
.toggleElement(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
|
|
57
|
+
.toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
|
|
58
|
+
if (!isOpen) {
|
|
59
|
+
setTimeout(() => this.host.classList.add('hidden'), 350);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
closeModal() {
|
|
63
|
+
if (!this.isClosable) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
this.host.removeAttribute('visible');
|
|
67
|
+
}
|
|
68
|
+
//todo:: pref for each modal
|
|
69
|
+
render() {
|
|
70
|
+
this.host.id = this.host.id || 'salla-modal';
|
|
71
|
+
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", ref: el => this.overlay = el, onClick: () => this.closeModal() }), index.h("span", { class: "s-modal-spacer" }, "\u200B"), index.h("slot", { name: "body" }, index.h("div", { class: 's-modal-body ' + this.modalWidth }, index.h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.icon != '' || this.imageIcon != '' } }, this.isClosable ?
|
|
72
|
+
index.h("button", { class: "s-modal-close cursor-pointer", onClick: () => this.closeModal(), type: "button" }, index.h("span", { class: "sicon-cancel" }))
|
|
73
|
+
: '', this.error || this.success || this.icon
|
|
74
|
+
? index.h("div", { class: {
|
|
75
|
+
's-modal-icon': true,
|
|
76
|
+
's-modal-bg-error': this.error,
|
|
77
|
+
's-modal-bg-success': this.success,
|
|
78
|
+
's-modal-bg-normal': !this.error && !this.success
|
|
79
|
+
} }, index.h("i", { class: {
|
|
80
|
+
[this.icon]: true,
|
|
81
|
+
's-modal-text-error': this.error,
|
|
82
|
+
's-modal-text-success': this.success,
|
|
83
|
+
} }))
|
|
84
|
+
: this.imageIcon ?
|
|
85
|
+
index.h("img", { class: "s-modal-header-img", src: this.imageIcon })
|
|
86
|
+
: '', this.title || this.subTitle ?
|
|
87
|
+
index.h("div", { class: "s-modal-header-content" }, index.h("div", { class: { 's-modal-title': true, 's-modal-title-below': this.subTitleFirst }, innerHTML: this.title }), index.h("p", { class: { 's-modal-sub-title': true }, innerHTML: this.subTitle }))
|
|
88
|
+
: ''), index.h("slot", null), index.h("slot", { name: "footer" }))))));
|
|
89
|
+
}
|
|
90
|
+
get host() { return index.getElement(this); }
|
|
91
|
+
static get watchers() { return {
|
|
92
|
+
"visible": ["handleVisible"]
|
|
93
|
+
}; }
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
exports.salla_login = sallaLogin.SallaLogin;
|
|
97
|
+
exports.salla_modal = SallaModal;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-0b5b5867.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.subscribeText = salla.lang.get('common.elements.submit');
|
|
15
|
+
this.cancelText = 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.subscribedMessage = salla.lang.get('pages.products.notify_availability_success');
|
|
23
|
+
this.isSubscribed = false;
|
|
24
|
+
if (this.isUser) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
this.channelsWatcher(this.channels);
|
|
28
|
+
this.title_ = this.host.title || salla.lang.get('pages.products.notify_availability_title');
|
|
29
|
+
this.host.removeAttribute('title');
|
|
30
|
+
}
|
|
31
|
+
channelsWatcher(newValue) {
|
|
32
|
+
this.channels_ = newValue.split(',');
|
|
33
|
+
}
|
|
34
|
+
async submit() {
|
|
35
|
+
if (this.isUser) {
|
|
36
|
+
return salla.api.product.availabilitySubscribe(this.productId)
|
|
37
|
+
.then(() => this.isSubscribed = true);
|
|
38
|
+
}
|
|
39
|
+
let data = { id: this.productId, country_code: this.countryCode };
|
|
40
|
+
if (this.mobile.value !== '') {
|
|
41
|
+
data['mobile'] = this.mobile.value;
|
|
42
|
+
}
|
|
43
|
+
if (this.email.value !== '') {
|
|
44
|
+
data['email'] = this.email.value;
|
|
45
|
+
}
|
|
46
|
+
return this.btn.load()
|
|
47
|
+
.then(() => this.btn.disable())
|
|
48
|
+
.then(() => salla.api.product.availabilitySubscribe(data))
|
|
49
|
+
.then(() => this.isSubscribed = true) //no need to wait until finishing alert animation
|
|
50
|
+
.then(() => this.btn.stop())
|
|
51
|
+
.then(() => this.modal.hide())
|
|
52
|
+
.catch(() => this.btn.stop() && this.btn.enable());
|
|
53
|
+
}
|
|
54
|
+
render() {
|
|
55
|
+
return (index.h(index.Host, null, this.isSubscribed
|
|
56
|
+
? index.h("div", { class: "s-product-availability-subscribed" }, this.subscribedMessage)
|
|
57
|
+
: index.h("slot", null, index.h("salla-button", { wide: true, onClick: () => this.isUser ? this.submit() : this.modal.show() }, this.buttonText)), this.isUser || this.isSubscribed ? '' : this.renderModal()));
|
|
58
|
+
}
|
|
59
|
+
renderModal() {
|
|
60
|
+
return (index.h("salla-modal", { ref: modal => this.modal = modal, title: this.title_, subTitle: this.subTitle, icon: "sicon-bell-ring", modalWidth: "w-96" }, index.h("div", { class: "s-product-availability-body" }, this.channels_.includes('email') ? [
|
|
61
|
+
index.h("label", { class: "s-product-availability-label" }, this.emailLabel),
|
|
62
|
+
index.h("input", { class: "s-product-availability-input", placeholder: this.emailPlaceholder, ref: el => this.email = el, type: "email" })
|
|
63
|
+
] : '', this.channels_.includes('sms') ? [
|
|
64
|
+
index.h("label", { class: "s-product-availability-label" }, this.mobileLabel),
|
|
65
|
+
index.h("input", { class: "s-product-availability-input", placeholder: this.mobilePlaceholder, ref: el => this.mobile = el, type: "text" }),
|
|
66
|
+
index.h("input", { type: "hidden", value: this.countryCode }),
|
|
67
|
+
] : ''), index.h("div", { slot: "footer", class: "s-product-availability-footer" }, index.h("salla-button", { wide: true, ref: btn => this.btn = btn, onClick: () => this.submit() }, this.subscribeText), index.h("salla-button", { wide: true, "btn-style": "outline" }, this.cancelText))));
|
|
68
|
+
}
|
|
69
|
+
get host() { return index.getElement(this); }
|
|
70
|
+
static get watchers() { return {
|
|
71
|
+
"channels": ["channelsWatcher"]
|
|
72
|
+
}; }
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
exports.salla_product_availability = SallaProductAvailability;
|