@salla.sa/twilight-components 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{esm → twilight-components}/Helper-23b2de40.js +0 -0
- package/dist/twilight-components/app-globals-0f993ce5.js +3 -0
- package/dist/twilight-components/css-shim-a64b8820.js +4 -0
- package/dist/twilight-components/dom-d08ba8aa.js +73 -0
- package/dist/twilight-components/index-8cf58712.js +3010 -0
- package/dist/twilight-components/index.esm.js +3 -1
- package/dist/twilight-components/multi-warehouse.entry.js +86 -0
- package/dist/twilight-components/order-rating.entry.js +257 -0
- package/dist/{esm → twilight-components}/salla-button.entry.js +10 -6
- package/dist/{esm → twilight-components}/salla-localization.entry.js +8 -8
- package/dist/{esm/salla-login-0e85b2d8.js → twilight-components/salla-login-97e0a9ab.js} +1 -1
- package/dist/twilight-components/salla-login.entry.js +2 -0
- package/dist/twilight-components/salla-modal.entry.js +84 -0
- package/dist/twilight-components/salla-product-availability.entry.js +55 -0
- package/dist/{esm/salla-search-5d4a6f1a.js → twilight-components/salla-search-df1c9b54.js} +2 -1
- package/dist/twilight-components/salla-search.entry.js +2 -0
- package/dist/{esm → twilight-components}/salla-verify.entry.js +5 -3
- package/dist/twilight-components/shadow-css-bc14d9fd.js +389 -0
- package/dist/twilight-components/twilight-components.esm.js +125 -1
- package/dist/types/components/multi-warehouse/multi-warehouse.d.ts +1 -0
- package/dist/types/components/order-rating/order-rating.d.ts +16 -10
- package/dist/types/components/salla-button/salla-button.d.ts +1 -1
- package/dist/types/components/salla-localization/salla-localization.d.ts +3 -3
- package/dist/types/components/salla-product-availability/salla-product-availability.d.ts +24 -0
- package/dist/types/components.d.ts +43 -2
- package/package.json +1 -1
- package/dist/cjs/Helper-8c75b6ac.js +0 -20
- package/dist/cjs/index-23da2c6b.js +0 -1601
- package/dist/cjs/index.cjs.js +0 -12
- package/dist/cjs/loader.cjs.js +0 -21
- package/dist/cjs/multi-warehouse_3.cjs.entry.js +0 -161
- package/dist/cjs/order-rating.cjs.entry.js +0 -252
- package/dist/cjs/salla-button.cjs.entry.js +0 -57
- package/dist/cjs/salla-localization.cjs.entry.js +0 -52
- package/dist/cjs/salla-login-476fb312.js +0 -14
- package/dist/cjs/salla-search-b9403062.js +0 -96
- package/dist/cjs/salla-search.cjs.entry.js +0 -10
- package/dist/cjs/salla-verify.cjs.entry.js +0 -94
- package/dist/cjs/twilight-components.cjs.js +0 -19
- package/dist/collection/Helpers/Helper.js +0 -16
- package/dist/collection/collection-manifest.json +0 -19
- package/dist/collection/components/generate-summary.js +0 -35
- package/dist/collection/components/multi-warehouse/multi-warehouse.js +0 -239
- package/dist/collection/components/order-rating/order-rating.css +0 -3
- package/dist/collection/components/order-rating/order-rating.js +0 -321
- package/dist/collection/components/salla-button/salla-button.css +0 -3
- package/dist/collection/components/salla-button/salla-button.js +0 -186
- package/dist/collection/components/salla-localization/salla-localization.js +0 -109
- package/dist/collection/components/salla-login/salla-login.js +0 -31
- package/dist/collection/components/salla-modal/salla-modal.js +0 -309
- package/dist/collection/components/salla-search/salla-search.js +0 -154
- package/dist/collection/components/salla-verify/salla-verify.js +0 -97
- package/dist/collection/index.js +0 -2
- package/dist/collection/interfaces/colors.js +0 -1
- package/dist/collection/interfaces/index.js +0 -2
- package/dist/collection/interfaces/ratio.js +0 -1
- package/dist/collection/plugins/tailwind-theme/generator.js +0 -53
- package/dist/collection/plugins/tailwind-theme/index.js +0 -26
- package/dist/esm/index-643344dc.js +0 -1573
- package/dist/esm/index.js +0 -3
- package/dist/esm/loader.js +0 -17
- package/dist/esm/multi-warehouse_3.entry.js +0 -155
- package/dist/esm/order-rating.entry.js +0 -248
- package/dist/esm/polyfills/core-js.js +0 -11
- package/dist/esm/polyfills/css-shim.js +0 -1
- package/dist/esm/polyfills/dom.js +0 -79
- package/dist/esm/polyfills/es5-html-element.js +0 -1
- package/dist/esm/polyfills/index.js +0 -34
- package/dist/esm/polyfills/system.js +0 -6
- package/dist/esm/salla-search.entry.js +0 -2
- package/dist/esm/twilight-components.js +0 -17
- package/dist/index.cjs.js +0 -1
- package/dist/index.js +0 -1
- package/dist/twilight-components/p-36c87e2e.js +0 -1
- package/dist/twilight-components/p-4b137380.js +0 -1
- package/dist/twilight-components/p-520446eb.js +0 -1
- package/dist/twilight-components/p-653bb9a8.entry.js +0 -1
- package/dist/twilight-components/p-a2395c9d.entry.js +0 -1
- package/dist/twilight-components/p-baeca520.entry.js +0 -1
- package/dist/twilight-components/p-bd10d8d5.entry.js +0 -1
- package/dist/twilight-components/p-d1ef2268.js +0 -1
- package/dist/twilight-components/p-ea986bca.entry.js +0 -1
- package/dist/twilight-components/p-f4340bd9.entry.js +0 -1
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const index = require('./index-23da2c6b.js');
|
|
4
|
-
|
|
5
|
-
const SallaSearch = class {
|
|
6
|
-
constructor(hostRef) {
|
|
7
|
-
index.registerInstance(this, hostRef);
|
|
8
|
-
this.fetchStatus = '';
|
|
9
|
-
this.showModal = false;
|
|
10
|
-
/**
|
|
11
|
-
* The text to overwrite search placeholder.
|
|
12
|
-
*/
|
|
13
|
-
this.searchPlaceholder = 'Search here ...';
|
|
14
|
-
/**
|
|
15
|
-
* The text to overwrite no results text.
|
|
16
|
-
*/
|
|
17
|
-
this.noResultsText = 'There are no results at the moment';
|
|
18
|
-
this.handleChange = event => {
|
|
19
|
-
this.searchTerm = event.target.value;
|
|
20
|
-
this.fetchStatus = 'loading';
|
|
21
|
-
this.showResult = false;
|
|
22
|
-
this.results = [];
|
|
23
|
-
if (this.searchTerm.length > 2) {
|
|
24
|
-
window.salla.search.api
|
|
25
|
-
.search(this.searchTerm)
|
|
26
|
-
.then(response => response)
|
|
27
|
-
.then(response => {
|
|
28
|
-
console.log('response', response);
|
|
29
|
-
this.fetchStatus = 'idle';
|
|
30
|
-
this.results = response.results;
|
|
31
|
-
this.showResult = true;
|
|
32
|
-
if (this.results.length < 1) {
|
|
33
|
-
this.fetchStatus = 'error';
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
.catch(err => {
|
|
37
|
-
this.showResult = true;
|
|
38
|
-
this.fetchStatus = 'error';
|
|
39
|
-
console.log(err);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
this.openSearch = () => {
|
|
44
|
-
this.searchTerm = '';
|
|
45
|
-
this.fetchStatus = '';
|
|
46
|
-
this.results = [];
|
|
47
|
-
this.showModal = true;
|
|
48
|
-
window.scrollTo(0, 0);
|
|
49
|
-
document.getElementsByTagName('html')[0].style.position = 'fixed';
|
|
50
|
-
document.getElementsByTagName('html')[0].style.overflowY = 'scroll';
|
|
51
|
-
};
|
|
52
|
-
this.closeSearch = () => {
|
|
53
|
-
this.searchTerm = '';
|
|
54
|
-
this.fetchStatus = '';
|
|
55
|
-
this.results = [];
|
|
56
|
-
document.getElementsByTagName('html')[0].style.position = 'static';
|
|
57
|
-
document.getElementsByTagName('html')[0].style.overflowY = 'auto';
|
|
58
|
-
this.showModal = false;
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
componentWillLoad() {
|
|
62
|
-
this.hasSearchIconSlot = !!this.hostElement.querySelector('[slot="search-icon"]');
|
|
63
|
-
this.hasProductTemplateSlot = !!this.hostElement.querySelector('[slot="product-template"]');
|
|
64
|
-
if (this.hasProductTemplateSlot) {
|
|
65
|
-
this.productTemplateHtml = this.hostElement.querySelector('[slot="product-template"]').innerHTML;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
getProduct(item) {
|
|
69
|
-
var _a, _b;
|
|
70
|
-
// todo use art-template https://aui.github.io/art-template/docs/.
|
|
71
|
-
if (this.hasProductTemplateSlot) {
|
|
72
|
-
let product = this.productTemplateHtml
|
|
73
|
-
.replace("{title}", item.title)
|
|
74
|
-
.replace("{price}", (_a = item.price) === null || _a === void 0 ? void 0 : _a.after)
|
|
75
|
-
.replace("{url}", item.url)
|
|
76
|
-
.replace("{thumb}", item.thumb);
|
|
77
|
-
return (index.h("div", { class: "s-search-product", innerHTML: product }));
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
return (index.h("div", { class: "s-search-product" }, index.h("a", { target: "_blank", href: item.url, class: "s-search-product-image-container" }, index.h("img", { class: "s-search-product-image", src: item.thumb })), index.h("div", { class: "s-search-product-details" }, index.h("div", { class: "s-search-product-title" }, item.title), index.h("div", { class: "s-search-product-price" }, (_b = item.price) === null || _b === void 0 ? void 0 : _b.after))));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
render() {
|
|
84
|
-
return (index.h(index.Host, { class: "s-search" }, index.h("button", { type: "button", onClick: this.openSearch, class: "s-search-search-button-icon" }, this.hasSearchIconSlot ? (index.h("slot", { name: "search-icon" })) : (index.h("i", { class: "sicon-search font-bold" }))), this.showModal && (index.h("div", { class: "s-search-container", style: { backgroundColor: 'rgba(0,0,0,0.5)' } }, index.h("div", { class: "s-search-wrapper", onClick: this.closeSearch }, index.h("div", { class: "s-search-inner", onClick: e => {
|
|
85
|
-
e.stopPropagation();
|
|
86
|
-
} }, index.h("div", { class: "s-search-search-box-container" }, index.h("div", { class: !this.showResult
|
|
87
|
-
? 's-search-search-box-inner'
|
|
88
|
-
: 's-search-search-box-inner-open' }, index.h("input", { class: "s-search-input", type: "text", placeholder: this.searchPlaceholder, value: this.searchTerm, onInput: event => this.handleChange(event) }), this.fetchStatus != 'loading' ? (index.h("button", { class: "s-search-search-icon" }, index.h("i", { class: "sicon-search" }))) : (index.h("span", { class: "s-search-spinner" }, index.h("span", { class: "s-search-spinner-loader" }))))), index.h("div", { class: "s-search-search-results" }, this.fetchStatus === 'error' && (index.h("p", { class: "s-search-no-results error p-4 text-sm text-gray-text" }, this.noResultsText)), this.results &&
|
|
89
|
-
this.results.map(item => {
|
|
90
|
-
return this.getProduct(item);
|
|
91
|
-
}))))))));
|
|
92
|
-
}
|
|
93
|
-
get hostElement() { return index.getElement(this); }
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
exports.SallaSearch = SallaSearch;
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const index = require('./index-23da2c6b.js');
|
|
6
|
-
const Helper = require('./Helper-8c75b6ac.js');
|
|
7
|
-
|
|
8
|
-
const SallaVerify = class {
|
|
9
|
-
constructor(hostRef) {
|
|
10
|
-
index.registerInstance(this, hostRef);
|
|
11
|
-
Helper.Helper.setHost(this.host);
|
|
12
|
-
salla.event.on('profile::verify.mobile', data => this.show(data));
|
|
13
|
-
}
|
|
14
|
-
show({ international_mobile: mobile, _country_iso2: country_code }) {
|
|
15
|
-
this.mobile = mobile;
|
|
16
|
-
this.country_code = country_code;
|
|
17
|
-
this.resendTimer();
|
|
18
|
-
this.otpInputs = document.querySelectorAll('.s-verify-input');
|
|
19
|
-
this.otpInputs[0].focus();
|
|
20
|
-
Helper.Helper.onKeyUp('.s-verify-input', event => {
|
|
21
|
-
var _a, _b;
|
|
22
|
-
let key = event.keyCode || event.charCode;
|
|
23
|
-
salla.helpers.digitsOnly(event.target);
|
|
24
|
-
if (event.target.value) {
|
|
25
|
-
(_a = event.target.nextElementSibling) === null || _a === void 0 ? void 0 : _a.focus();
|
|
26
|
-
}
|
|
27
|
-
else if ([8, 46].includes(key)) {
|
|
28
|
-
(_b = event.target.previousElementSibling) === null || _b === void 0 ? void 0 : _b.focus();
|
|
29
|
-
}
|
|
30
|
-
this.toggleOTPSubmit();
|
|
31
|
-
});
|
|
32
|
-
Helper.Helper.on('paste', '.s-verify-input', event => {
|
|
33
|
-
let text = event.clipboardData.getData('text').toArabicDigits().replace(/[^0-9.]/g, '').replace('..', '.');
|
|
34
|
-
this.otpInputs.forEach((input, i) => input.value = text[i] || '');
|
|
35
|
-
this.toggleOTPSubmit();
|
|
36
|
-
setTimeout(() => this.otpInputs[3].focus(), 100);
|
|
37
|
-
});
|
|
38
|
-
return this.modal.show();
|
|
39
|
-
}
|
|
40
|
-
toggleOTPSubmit() {
|
|
41
|
-
let otp = [];
|
|
42
|
-
this.otpInputs.forEach(input => input.value && otp.push(input.value));
|
|
43
|
-
this.code.value = otp.join('');
|
|
44
|
-
if (otp.length === 4) {
|
|
45
|
-
this.btn.removeAttribute('disabled');
|
|
46
|
-
this.btn.click();
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
this.btn.setAttribute('disabled', '');
|
|
50
|
-
}
|
|
51
|
-
resendTimer() {
|
|
52
|
-
Helper.Helper.showElement(this.resendMessage).hideElement(this.resend);
|
|
53
|
-
let resendAfter = 30;
|
|
54
|
-
let timerId = setInterval(() => {
|
|
55
|
-
if (resendAfter === -1) {
|
|
56
|
-
clearTimeout(timerId);
|
|
57
|
-
Helper.Helper.hideElement(this.resendMessage).showElement(this.resend);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
this.timer.innerHTML = `${resendAfter >= 10 ? resendAfter : '0' + resendAfter} : 00`;
|
|
61
|
-
resendAfter--;
|
|
62
|
-
}
|
|
63
|
-
}, 1000);
|
|
64
|
-
}
|
|
65
|
-
submit() {
|
|
66
|
-
return this.btn.load()
|
|
67
|
-
.then(() => this.btn.disable())
|
|
68
|
-
.then(() => salla.document.api.request('profile/verify-mobile', {
|
|
69
|
-
mobile: this.mobile,
|
|
70
|
-
country_code: this.country_code,
|
|
71
|
-
code: this.code.value
|
|
72
|
-
})).then(() => this.btn.stop() && this.btn.disable())
|
|
73
|
-
.then(() => this.modal.hide())
|
|
74
|
-
.then(() => window.location.reload())
|
|
75
|
-
.catch(() => this.btn.stop() && this.btn.enable());
|
|
76
|
-
}
|
|
77
|
-
resendCode() {
|
|
78
|
-
return this.btn.stop()
|
|
79
|
-
.then(() => this.btn.disable())
|
|
80
|
-
.then(() => {
|
|
81
|
-
this.otpInputs.forEach(input => input.value = '');
|
|
82
|
-
this.otpInputs[0].focus();
|
|
83
|
-
})
|
|
84
|
-
.then(() => salla.api.auth.resend({ phone: this.mobile, country_code: this.country_code }))
|
|
85
|
-
.then(() => this.resendTimer())
|
|
86
|
-
.catch(() => this.resendTimer());
|
|
87
|
-
}
|
|
88
|
-
render() {
|
|
89
|
-
return (index.h("salla-modal", { id: "s-verify", ref: modal => this.modal = modal, title: salla.lang.get('pages.profile.verify_title') }, index.h("div", { class: "s-verify-message", innerHTML: salla.lang.get('pages.profile.verify_message') }), index.h("label", { class: "s-verify-label" }, salla.lang.get('pages.profile.verify_placeholder')), index.h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }), index.h("div", { class: "s-verify-codes", dir: "ltr" }, [1, 2, 3, 4].map(() => index.h("input", { type: "text", maxlength: "1", class: "s-verify-input", required: true }))), index.h("div", { slot: "footer", class: "s-verify-footer" }, index.h("salla-button", { class: "s-verify-submit", disabled: true, onClick: () => this.submit(), ref: b => this.btn = b }, salla.lang.get('pages.profile.verify')), index.h("p", { class: "s-verify-resend-message", ref: el => this.resendMessage = el }, salla.lang.get('blocks.header.resend_after'), index.h("b", { class: "s-verify-timer", ref: el => this.timer = el })), index.h("a", { href: "#", class: "s-verify-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit')))));
|
|
90
|
-
}
|
|
91
|
-
get host() { return index.getElement(this); }
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
exports.salla_verify = SallaVerify;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const index = require('./index-23da2c6b.js');
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
Stencil Client Patch Browser v2.8.1 | MIT Licensed | https://stenciljs.com
|
|
7
|
-
*/
|
|
8
|
-
const patchBrowser = () => {
|
|
9
|
-
const importMeta = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('twilight-components.cjs.js', document.baseURI).href));
|
|
10
|
-
const opts = {};
|
|
11
|
-
if (importMeta !== '') {
|
|
12
|
-
opts.resourcesUrl = new URL('.', importMeta).href;
|
|
13
|
-
}
|
|
14
|
-
return index.promiseResolve(opts);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
patchBrowser().then(options => {
|
|
18
|
-
return index.bootstrapLazy([["salla-localization.cjs",[[4,"salla-localization",{"show":[64],"hide":[64]}]]],["salla-verify.cjs",[[0,"salla-verify"]]],["order-rating.cjs",[[0,"order-rating",{"order":[8]}]]],["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]}]]],["salla-button.cjs",[[4,"salla-button",{"kind":[513],"loading":[516],"disabled":[516],"load":[64],"stop":[64],"disable":[64],"enable":[64]}]]],["multi-warehouse_3.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-modal",{"error":[4],"success":[4],"isClosable":[1028,"is-closable"],"modalWidth":[1,"modal-width"],"visible":[516],"subTitle":[1,"sub-title"],"icon":[1],"show":[64],"hide":[64],"setTitle":[64]}]]]], options);
|
|
19
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
class Helper extends salla.AppHelpers {
|
|
2
|
-
setHost(host) {
|
|
3
|
-
this.host = host;
|
|
4
|
-
}
|
|
5
|
-
getElement(selector) {
|
|
6
|
-
return this.host.querySelector(selector);
|
|
7
|
-
}
|
|
8
|
-
getAttribute(selector, attribute) {
|
|
9
|
-
var _a;
|
|
10
|
-
return (_a = this.getElement(selector)) === null || _a === void 0 ? void 0 : _a.getAttribute(attribute);
|
|
11
|
-
}
|
|
12
|
-
val(selector) {
|
|
13
|
-
return this.getAttribute(selector, 'value');
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export default new Helper;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"entries": [
|
|
3
|
-
"./components/salla-login/salla-login.js",
|
|
4
|
-
"./components/salla-search/salla-search.js",
|
|
5
|
-
"./components/multi-warehouse/multi-warehouse.js",
|
|
6
|
-
"./components/order-rating/order-rating.js",
|
|
7
|
-
"./components/salla-button/salla-button.js",
|
|
8
|
-
"./components/salla-localization/salla-localization.js",
|
|
9
|
-
"./components/salla-modal/salla-modal.js",
|
|
10
|
-
"./components/salla-verify/salla-verify.js"
|
|
11
|
-
],
|
|
12
|
-
"compiler": {
|
|
13
|
-
"name": "@stencil/core",
|
|
14
|
-
"version": "2.8.1",
|
|
15
|
-
"typescriptVersion": "4.2.3"
|
|
16
|
-
},
|
|
17
|
-
"collections": [],
|
|
18
|
-
"bundles": []
|
|
19
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
var fs = require('fs'), path = require('path'), util = require('util');
|
|
2
|
-
|
|
3
|
-
var dirToJSON = function (dir, done) {
|
|
4
|
-
var results = [];
|
|
5
|
-
|
|
6
|
-
function recWalk(d, res) {
|
|
7
|
-
var list = fs.readdirSync(d);
|
|
8
|
-
list.forEach((name) => {
|
|
9
|
-
var file = path.resolve(d, name);
|
|
10
|
-
var stat = fs.statSync(file);
|
|
11
|
-
if (stat && stat.isDirectory()) {
|
|
12
|
-
var title;
|
|
13
|
-
if (name) {
|
|
14
|
-
title = 'salla-' + name
|
|
15
|
-
}
|
|
16
|
-
res.push({ title: title, file: name + '/readme.md' });
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
recWalk(dir, results);
|
|
23
|
-
done(null, results);
|
|
24
|
-
} catch (err) {
|
|
25
|
-
done(err);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
dirToJSON("src/components", function (err, results) {
|
|
30
|
-
if (err) console.log(err);
|
|
31
|
-
else fs.writeFile('src/components/summary.json', JSON.stringify(results), 'utf8', function (err) {
|
|
32
|
-
if (err) throw err;
|
|
33
|
-
console.log('Saved!');
|
|
34
|
-
});
|
|
35
|
-
});
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
import { Component, h, Prop, Method, State, Element } from "@stencil/core";
|
|
2
|
-
// import Helper from "../../Helpers/Helper";
|
|
3
|
-
let engine = require('store/src/store-engine');
|
|
4
|
-
let storages = require('store/storages/sessionStorage');
|
|
5
|
-
let sessionStore = engine.createStore(storages);
|
|
6
|
-
export class MultiWarehouse {
|
|
7
|
-
constructor() {
|
|
8
|
-
this.open = false;
|
|
9
|
-
this.isOpenedBefore = sessionStore.get("multi-warehouse-opened-before");
|
|
10
|
-
this.displayAs = 'default';
|
|
11
|
-
this.browseProductsFrom = 'all';
|
|
12
|
-
this.branches = [
|
|
13
|
-
{ id: 1, name: 'فرع الرياض', open: true, available: true, limited: false, tag: 'متوفر' },
|
|
14
|
-
{ id: 2, name: 'فرع جدة', open: false, available: false, limited: false, tag: 'غير متوفر' },
|
|
15
|
-
{ id: 3, name: 'فرع مكة', open: true, available: true, limited: false, tag: 'متوفر' },
|
|
16
|
-
{ id: 4, name: 'فرع المدينة', open: true, available: true, limited: false, tag: 'متوفر' },
|
|
17
|
-
{ id: 5, name: 'فرع جازان', open: true, available: true, limited: true, tag: 'الكمية محدودة' }
|
|
18
|
-
];
|
|
19
|
-
this.current = 1;
|
|
20
|
-
this.currentBranch = (prop) => {
|
|
21
|
-
return this.branches.filter((el) => el.id == this.current)[0][prop];
|
|
22
|
-
};
|
|
23
|
-
this.statusColor = (branch = null) => {
|
|
24
|
-
return branch ?
|
|
25
|
-
branch.limited ? 'text-red-400' : branch.available ? 'text-green-500' : 'text-gray-400'
|
|
26
|
-
:
|
|
27
|
-
this.currentBranch('limited') ? 'text-red-400' : this.currentBranch('available') ? 'text-green-500' : 'text-gray-400';
|
|
28
|
-
};
|
|
29
|
-
this.isChoiceable = () => {
|
|
30
|
-
return (this.browseProductsFrom !== 'all' && this.position == 'single') || this.position == 'header';
|
|
31
|
-
};
|
|
32
|
-
this.formTitle = () => {
|
|
33
|
-
return this.isChoiceable() ?
|
|
34
|
-
'توفر المنتج في الفروع الآخرى'
|
|
35
|
-
: 'التسوق من فرع آخر';
|
|
36
|
-
};
|
|
37
|
-
salla.event.on('branches::show', () => this.show());
|
|
38
|
-
}
|
|
39
|
-
async show() {
|
|
40
|
-
return this.modal.show();
|
|
41
|
-
}
|
|
42
|
-
async hide() {
|
|
43
|
-
return this.modal.hide();
|
|
44
|
-
}
|
|
45
|
-
handelChange(event) {
|
|
46
|
-
this.selected = event.target.value;
|
|
47
|
-
}
|
|
48
|
-
handleSubmit() {
|
|
49
|
-
sessionStore.set("multi-warehouse-opened-before", true);
|
|
50
|
-
this.show();
|
|
51
|
-
setTimeout(() => {
|
|
52
|
-
this.current = this.selected;
|
|
53
|
-
}, 300);
|
|
54
|
-
}
|
|
55
|
-
render() {
|
|
56
|
-
return (h("salla-modal", { "is-closable": !this.isOpenedBefore && this.displayAs == 'popup' ? 'false' : 'true', ref: modal => this.modal = modal, "modal-width": "w-116", id: "multi-warehouse-modal", class: "hidden" },
|
|
57
|
-
h("slot", { name: "header" },
|
|
58
|
-
h("div", { slot: "header" })),
|
|
59
|
-
h("div", null,
|
|
60
|
-
h("div", { class: "text-right" },
|
|
61
|
-
h("div", { class: "flex items-center mb-8" },
|
|
62
|
-
h("div", { class: "flex-shrink-0 sm:mb-0 me-4" },
|
|
63
|
-
h("div", { class: "h-16 w-16 border border-gray-200 bg-white text-primary rounded-full flex justify-center items-center" },
|
|
64
|
-
h("span", { class: "sicon-store-alt" }))),
|
|
65
|
-
h("div", null,
|
|
66
|
-
h("p", { class: "mt-1 text-xs text-gray-400" }, "\u0623\u0646\u062A \u0627\u0644\u0622\u0646 \u062A\u062A\u0635\u0641\u062D \u0627\u0644\u0645\u062A\u062C\u0631 \u0645\u0646"),
|
|
67
|
-
h("h4", { class: "text-base" }, "\u0641\u0631\u0639 \u0627\u0644\u0631\u064A\u0627\u0636"))),
|
|
68
|
-
h("fieldset", { class: "mt-4" },
|
|
69
|
-
h("h4", { class: "text-sm text-gray-600 mb-6" }, this.formTitle()),
|
|
70
|
-
h("legend", { class: "sr-only" }, this.formTitle()),
|
|
71
|
-
this.branches.length <= 5 ?
|
|
72
|
-
h("div", { class: "space-y-5" }, this.branches.map((branch) => h("div", { class: "flex items-center" },
|
|
73
|
-
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: {
|
|
74
|
-
'me-3 focus:ring-primary h-4 w-4 text-primary border-gray-300': true,
|
|
75
|
-
'opacity-50': !branch.open,
|
|
76
|
-
'hidden': !this.isChoiceable()
|
|
77
|
-
}, checked: this.current == branch.id }),
|
|
78
|
-
h("label", { htmlFor: this.position + '_branch_' + branch.id, class: {
|
|
79
|
-
'flex items-center justify-between text-sm font-medium text-gray-700 flex-grow': true,
|
|
80
|
-
'cursor-pointer': this.isChoiceable()
|
|
81
|
-
} },
|
|
82
|
-
h("span", { class: { 'opacity-50': !branch.open } }, branch.name),
|
|
83
|
-
this.isChoiceable() ?
|
|
84
|
-
h("small", { class: "text-red-400" }, branch.open ? '' : 'مُغلق')
|
|
85
|
-
:
|
|
86
|
-
h("span", { class: this.statusColor(branch) }, branch.tag)))))
|
|
87
|
-
:
|
|
88
|
-
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 => (h("option", { value: branch.id, disabled: !branch.open, selected: this.selected == branch.id },
|
|
89
|
-
branch.name,
|
|
90
|
-
" ",
|
|
91
|
-
branch.open ? '' : '- مُغلق'))))))),
|
|
92
|
-
this.isChoiceable() ?
|
|
93
|
-
h("p", { slot: "footer" },
|
|
94
|
-
h("slot", { name: "footer" },
|
|
95
|
-
h("button", { type: "button", class: "mt-8 w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-primary text-base font-medium text-white transition-colors hover:bg-primary-d focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary sm:col-start-2 sm:text-sm", onClick: () => this.handleSubmit() }, salla.lang.get('common.elements.ok'))))
|
|
96
|
-
: ''));
|
|
97
|
-
}
|
|
98
|
-
componentDidRender() {
|
|
99
|
-
if (!this.isOpenedBefore && this.displayAs == 'popup') {
|
|
100
|
-
//this.show()
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
static get is() { return "multi-warehouse"; }
|
|
104
|
-
static get properties() { return {
|
|
105
|
-
"position": {
|
|
106
|
-
"type": "string",
|
|
107
|
-
"mutable": false,
|
|
108
|
-
"complexType": {
|
|
109
|
-
"original": "string",
|
|
110
|
-
"resolved": "string",
|
|
111
|
-
"references": {}
|
|
112
|
-
},
|
|
113
|
-
"required": false,
|
|
114
|
-
"optional": false,
|
|
115
|
-
"docs": {
|
|
116
|
-
"tags": [],
|
|
117
|
-
"text": ""
|
|
118
|
-
},
|
|
119
|
-
"attribute": "position",
|
|
120
|
-
"reflect": false
|
|
121
|
-
},
|
|
122
|
-
"displayAs": {
|
|
123
|
-
"type": "string",
|
|
124
|
-
"mutable": false,
|
|
125
|
-
"complexType": {
|
|
126
|
-
"original": "string",
|
|
127
|
-
"resolved": "string",
|
|
128
|
-
"references": {}
|
|
129
|
-
},
|
|
130
|
-
"required": false,
|
|
131
|
-
"optional": false,
|
|
132
|
-
"docs": {
|
|
133
|
-
"tags": [],
|
|
134
|
-
"text": ""
|
|
135
|
-
},
|
|
136
|
-
"attribute": "display-as",
|
|
137
|
-
"reflect": false,
|
|
138
|
-
"defaultValue": "'default'"
|
|
139
|
-
},
|
|
140
|
-
"browseProductsFrom": {
|
|
141
|
-
"type": "string",
|
|
142
|
-
"mutable": false,
|
|
143
|
-
"complexType": {
|
|
144
|
-
"original": "string",
|
|
145
|
-
"resolved": "string",
|
|
146
|
-
"references": {}
|
|
147
|
-
},
|
|
148
|
-
"required": false,
|
|
149
|
-
"optional": false,
|
|
150
|
-
"docs": {
|
|
151
|
-
"tags": [],
|
|
152
|
-
"text": ""
|
|
153
|
-
},
|
|
154
|
-
"attribute": "browse-products-from",
|
|
155
|
-
"reflect": false,
|
|
156
|
-
"defaultValue": "'all'"
|
|
157
|
-
},
|
|
158
|
-
"branches": {
|
|
159
|
-
"type": "unknown",
|
|
160
|
-
"mutable": false,
|
|
161
|
-
"complexType": {
|
|
162
|
-
"original": "any[]",
|
|
163
|
-
"resolved": "any[]",
|
|
164
|
-
"references": {}
|
|
165
|
-
},
|
|
166
|
-
"required": false,
|
|
167
|
-
"optional": false,
|
|
168
|
-
"docs": {
|
|
169
|
-
"tags": [],
|
|
170
|
-
"text": ""
|
|
171
|
-
},
|
|
172
|
-
"defaultValue": "[\n {id: 1, name: '\u0641\u0631\u0639 \u0627\u0644\u0631\u064A\u0627\u0636', open: true, available: true, limited: false, tag: '\u0645\u062A\u0648\u0641\u0631'},\n {id: 2, name: '\u0641\u0631\u0639 \u062C\u062F\u0629', open: false, available: false, limited: false, tag: '\u063A\u064A\u0631 \u0645\u062A\u0648\u0641\u0631'},\n {id: 3, name: '\u0641\u0631\u0639 \u0645\u0643\u0629', open: true, available: true, limited: false, tag: '\u0645\u062A\u0648\u0641\u0631'},\n {id: 4, name: '\u0641\u0631\u0639 \u0627\u0644\u0645\u062F\u064A\u0646\u0629', open: true, available: true, limited: false, tag: '\u0645\u062A\u0648\u0641\u0631'},\n {id: 5, name: '\u0641\u0631\u0639 \u062C\u0627\u0632\u0627\u0646', open: true, available: true, limited: true, tag: '\u0627\u0644\u0643\u0645\u064A\u0629 \u0645\u062D\u062F\u0648\u062F\u0629'}\n ]"
|
|
173
|
-
},
|
|
174
|
-
"current": {
|
|
175
|
-
"type": "number",
|
|
176
|
-
"mutable": true,
|
|
177
|
-
"complexType": {
|
|
178
|
-
"original": "number",
|
|
179
|
-
"resolved": "number",
|
|
180
|
-
"references": {}
|
|
181
|
-
},
|
|
182
|
-
"required": false,
|
|
183
|
-
"optional": false,
|
|
184
|
-
"docs": {
|
|
185
|
-
"tags": [],
|
|
186
|
-
"text": ""
|
|
187
|
-
},
|
|
188
|
-
"attribute": "current",
|
|
189
|
-
"reflect": false,
|
|
190
|
-
"defaultValue": "1"
|
|
191
|
-
}
|
|
192
|
-
}; }
|
|
193
|
-
static get states() { return {
|
|
194
|
-
"open": {},
|
|
195
|
-
"selected": {},
|
|
196
|
-
"isOpenedBefore": {}
|
|
197
|
-
}; }
|
|
198
|
-
static get methods() { return {
|
|
199
|
-
"show": {
|
|
200
|
-
"complexType": {
|
|
201
|
-
"signature": "() => Promise<HTMLElement>",
|
|
202
|
-
"parameters": [],
|
|
203
|
-
"references": {
|
|
204
|
-
"Promise": {
|
|
205
|
-
"location": "global"
|
|
206
|
-
},
|
|
207
|
-
"HTMLElement": {
|
|
208
|
-
"location": "global"
|
|
209
|
-
}
|
|
210
|
-
},
|
|
211
|
-
"return": "Promise<HTMLElement>"
|
|
212
|
-
},
|
|
213
|
-
"docs": {
|
|
214
|
-
"text": "",
|
|
215
|
-
"tags": []
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
"hide": {
|
|
219
|
-
"complexType": {
|
|
220
|
-
"signature": "() => Promise<HTMLElement>",
|
|
221
|
-
"parameters": [],
|
|
222
|
-
"references": {
|
|
223
|
-
"Promise": {
|
|
224
|
-
"location": "global"
|
|
225
|
-
},
|
|
226
|
-
"HTMLElement": {
|
|
227
|
-
"location": "global"
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
"return": "Promise<HTMLElement>"
|
|
231
|
-
},
|
|
232
|
-
"docs": {
|
|
233
|
-
"text": "",
|
|
234
|
-
"tags": []
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}; }
|
|
238
|
-
static get elementRef() { return "host"; }
|
|
239
|
-
}
|