@salla.sa/twilight-components 1.0.9 → 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
package/dist/esm/index.js
DELETED
package/dist/esm/loader.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { p as promiseResolve, b as bootstrapLazy } from './index-643344dc.js';
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
Stencil Client Patch Esm v2.8.1 | MIT Licensed | https://stenciljs.com
|
|
5
|
-
*/
|
|
6
|
-
const patchEsm = () => {
|
|
7
|
-
return promiseResolve();
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const defineCustomElements = (win, options) => {
|
|
11
|
-
if (typeof window === 'undefined') return Promise.resolve();
|
|
12
|
-
return patchEsm().then(() => {
|
|
13
|
-
return bootstrapLazy([["salla-localization",[[4,"salla-localization",{"show":[64],"hide":[64]}]]],["salla-verify",[[0,"salla-verify"]]],["order-rating",[[0,"order-rating",{"order":[8]}]]],["salla-search",[[4,"salla-search",{"searchPlaceholder":[1,"search-placeholder"],"noResultsText":[1,"no-results-text"],"searchTerm":[32],"results":[32],"fetchStatus":[32],"showResult":[32],"showModal":[32]}]]],["salla-button",[[4,"salla-button",{"kind":[513],"loading":[516],"disabled":[516],"load":[64],"stop":[64],"disable":[64],"enable":[64]}]]],["multi-warehouse_3",[[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);
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export { defineCustomElements };
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { r as registerInstance, h, g as getElement, c as createEvent, H as Host } from './index-643344dc.js';
|
|
2
|
-
export { S as salla_login } from './salla-login-0e85b2d8.js';
|
|
3
|
-
import { H as Helper } from './Helper-23b2de40.js';
|
|
4
|
-
|
|
5
|
-
// import Helper from "../../Helpers/Helper";
|
|
6
|
-
let engine = require('store/src/store-engine');
|
|
7
|
-
let storages = require('store/storages/sessionStorage');
|
|
8
|
-
let sessionStore = engine.createStore(storages);
|
|
9
|
-
const MultiWarehouse = class {
|
|
10
|
-
constructor(hostRef) {
|
|
11
|
-
registerInstance(this, hostRef);
|
|
12
|
-
this.open = false;
|
|
13
|
-
this.isOpenedBefore = sessionStore.get("multi-warehouse-opened-before");
|
|
14
|
-
this.displayAs = 'default';
|
|
15
|
-
this.browseProductsFrom = 'all';
|
|
16
|
-
this.branches = [
|
|
17
|
-
{ id: 1, name: 'فرع الرياض', open: true, available: true, limited: false, tag: 'متوفر' },
|
|
18
|
-
{ id: 2, name: 'فرع جدة', open: false, available: false, limited: false, tag: 'غير متوفر' },
|
|
19
|
-
{ id: 3, name: 'فرع مكة', open: true, available: true, limited: false, tag: 'متوفر' },
|
|
20
|
-
{ id: 4, name: 'فرع المدينة', open: true, available: true, limited: false, tag: 'متوفر' },
|
|
21
|
-
{ id: 5, name: 'فرع جازان', open: true, available: true, limited: true, tag: 'الكمية محدودة' }
|
|
22
|
-
];
|
|
23
|
-
this.current = 1;
|
|
24
|
-
this.currentBranch = (prop) => {
|
|
25
|
-
return this.branches.filter((el) => el.id == this.current)[0][prop];
|
|
26
|
-
};
|
|
27
|
-
this.statusColor = (branch = null) => {
|
|
28
|
-
return branch ?
|
|
29
|
-
branch.limited ? 'text-red-400' : branch.available ? 'text-green-500' : 'text-gray-400'
|
|
30
|
-
:
|
|
31
|
-
this.currentBranch('limited') ? 'text-red-400' : this.currentBranch('available') ? 'text-green-500' : 'text-gray-400';
|
|
32
|
-
};
|
|
33
|
-
this.isChoiceable = () => {
|
|
34
|
-
return (this.browseProductsFrom !== 'all' && this.position == 'single') || this.position == 'header';
|
|
35
|
-
};
|
|
36
|
-
this.formTitle = () => {
|
|
37
|
-
return this.isChoiceable() ?
|
|
38
|
-
'توفر المنتج في الفروع الآخرى'
|
|
39
|
-
: 'التسوق من فرع آخر';
|
|
40
|
-
};
|
|
41
|
-
salla.event.on('branches::show', () => this.show());
|
|
42
|
-
}
|
|
43
|
-
async show() {
|
|
44
|
-
return this.modal.show();
|
|
45
|
-
}
|
|
46
|
-
async hide() {
|
|
47
|
-
return this.modal.hide();
|
|
48
|
-
}
|
|
49
|
-
handelChange(event) {
|
|
50
|
-
this.selected = event.target.value;
|
|
51
|
-
}
|
|
52
|
-
handleSubmit() {
|
|
53
|
-
sessionStore.set("multi-warehouse-opened-before", true);
|
|
54
|
-
this.show();
|
|
55
|
-
setTimeout(() => {
|
|
56
|
-
this.current = this.selected;
|
|
57
|
-
}, 300);
|
|
58
|
-
}
|
|
59
|
-
render() {
|
|
60
|
-
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" }, h("slot", { name: "header" }, h("div", { slot: "header" })), h("div", null, h("div", { class: "text-right" }, h("div", { class: "flex items-center mb-8" }, h("div", { class: "flex-shrink-0 sm:mb-0 me-4" }, h("div", { class: "h-16 w-16 border border-gray-200 bg-white text-primary rounded-full flex justify-center items-center" }, h("span", { class: "sicon-store-alt" }))), h("div", null, 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"), h("h4", { class: "text-base" }, "\u0641\u0631\u0639 \u0627\u0644\u0631\u064A\u0627\u0636"))), h("fieldset", { class: "mt-4" }, h("h4", { class: "text-sm text-gray-600 mb-6" }, this.formTitle()), h("legend", { class: "sr-only" }, this.formTitle()), this.branches.length <= 5 ?
|
|
61
|
-
h("div", { class: "space-y-5" }, this.branches.map((branch) => h("div", { class: "flex items-center" }, 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: {
|
|
62
|
-
'me-3 focus:ring-primary h-4 w-4 text-primary border-gray-300': true,
|
|
63
|
-
'opacity-50': !branch.open,
|
|
64
|
-
'hidden': !this.isChoiceable()
|
|
65
|
-
}, checked: this.current == branch.id }), h("label", { htmlFor: this.position + '_branch_' + branch.id, class: {
|
|
66
|
-
'flex items-center justify-between text-sm font-medium text-gray-700 flex-grow': true,
|
|
67
|
-
'cursor-pointer': this.isChoiceable()
|
|
68
|
-
} }, h("span", { class: { 'opacity-50': !branch.open } }, branch.name), this.isChoiceable() ?
|
|
69
|
-
h("small", { class: "text-red-400" }, branch.open ? '' : 'مُغلق')
|
|
70
|
-
:
|
|
71
|
-
h("span", { class: this.statusColor(branch) }, branch.tag)))))
|
|
72
|
-
:
|
|
73
|
-
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 }, branch.name, " ", branch.open ? '' : '- مُغلق'))))))), this.isChoiceable() ?
|
|
74
|
-
h("p", { slot: "footer" }, h("slot", { name: "footer" }, 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'))))
|
|
75
|
-
: ''));
|
|
76
|
-
}
|
|
77
|
-
componentDidRender() {
|
|
78
|
-
}
|
|
79
|
-
get host() { return getElement(this); }
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const SallaModal = class {
|
|
83
|
-
constructor(hostRef) {
|
|
84
|
-
registerInstance(this, hostRef);
|
|
85
|
-
this.ready = createEvent(this, "ready", 7);
|
|
86
|
-
this.close = createEvent(this, "close", 7);
|
|
87
|
-
this.error = false;
|
|
88
|
-
this.success = false;
|
|
89
|
-
this.isClosable = true;
|
|
90
|
-
this.modalWidth = 'w-96'; //todo use friendly names
|
|
91
|
-
this.visible = false;
|
|
92
|
-
this.subTitle = '';
|
|
93
|
-
this.icon = 'sicon-cancel';
|
|
94
|
-
salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
|
|
95
|
-
salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
|
|
96
|
-
this.title = this.host.title;
|
|
97
|
-
this.host.removeAttribute('title');
|
|
98
|
-
}
|
|
99
|
-
handleVisible(newValue) {
|
|
100
|
-
if (!newValue) {
|
|
101
|
-
this.toggleModal(false);
|
|
102
|
-
this.close.emit();
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
this.host.classList.remove('hidden');
|
|
106
|
-
setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
|
|
107
|
-
this.ready.emit();
|
|
108
|
-
}
|
|
109
|
-
async show() {
|
|
110
|
-
this.host.setAttribute('visible', '');
|
|
111
|
-
return this.host;
|
|
112
|
-
}
|
|
113
|
-
async hide() {
|
|
114
|
-
this.host.removeAttribute('visible');
|
|
115
|
-
return this.host;
|
|
116
|
-
}
|
|
117
|
-
async setTitle(title) {
|
|
118
|
-
this.title = title;
|
|
119
|
-
return this.host;
|
|
120
|
-
}
|
|
121
|
-
toggleModal(isOpen) {
|
|
122
|
-
Helper.toggleElement(this.host.querySelector('.s-modal-overlay'), 'ease-out duration-300 opacity-100', 'opacity-0', () => isOpen)
|
|
123
|
-
.toggleElement(this.host.querySelector('.s-modal-body'), 'ease-out duration-300 opacity-100 translate-y-0 sm:scale-100', //add these classes
|
|
124
|
-
'opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95', //remove these classes
|
|
125
|
-
() => isOpen)
|
|
126
|
-
.toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
|
|
127
|
-
if (!isOpen) {
|
|
128
|
-
setTimeout(() => this.host.classList.add('hidden'), 350);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
closeModal() {
|
|
132
|
-
if (!this.isClosable) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
this.host.removeAttribute('visible');
|
|
136
|
-
}
|
|
137
|
-
render() {
|
|
138
|
-
this.host.id = this.host.id || 'salla-modal';
|
|
139
|
-
return (h(Host, { class: 's-modal-container hidden', "aria-modal": "true", role: "dialog" }, h("div", { class: "s-modal-wrapper" }, h("div", { class: "s-modal-overlay", onClick: () => this.closeModal() }), h("span", { class: "s-modal-spacer" }, "\u200B"), h("div", { class: 's-modal-body ' + this.modalWidth }, h("slot", { name: "header" }, h("div", { class: "s-modal-header" }, this.isClosable ?
|
|
140
|
-
h("button", { class: "s-modal-close cursor-pointer", onClick: () => this.closeModal(), type: "button" }, h("span", { class: "sicon-cancel" }))
|
|
141
|
-
: '', this.error || this.success
|
|
142
|
-
? h("div", { class: { 's-modal-icon': true, 's-modal-bg-error': this.error, 's-modal-bg-success': this.success } }, h("i", { class: {
|
|
143
|
-
[this.icon]: true,
|
|
144
|
-
's-modal-text-error': this.error,
|
|
145
|
-
's-modal-text-success': this.success
|
|
146
|
-
} }))
|
|
147
|
-
: '', h("div", { class: "s-modal-title", innerHTML: this.title }), h("p", { class: "s-modal-sub-title", innerHTML: this.subTitle }))), h("slot", null), h("slot", { name: "footer" })))));
|
|
148
|
-
}
|
|
149
|
-
get host() { return getElement(this); }
|
|
150
|
-
static get watchers() { return {
|
|
151
|
-
"visible": ["handleVisible"]
|
|
152
|
-
}; }
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
export { MultiWarehouse as multi_warehouse, SallaModal as salla_modal };
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
import { r as registerInstance, h, H as Host } from './index-643344dc.js';
|
|
2
|
-
import { H as Helper } from './Helper-23b2de40.js';
|
|
3
|
-
|
|
4
|
-
const orderRatingCss = ":host{display:block}";
|
|
5
|
-
|
|
6
|
-
const OrderRating = class {
|
|
7
|
-
constructor(hostRef) {
|
|
8
|
-
registerInstance(this, hostRef);
|
|
9
|
-
this.stars = [1, 2, 3, 4, 5];
|
|
10
|
-
this.order = {
|
|
11
|
-
shipping: { id: 5622 },
|
|
12
|
-
order_id: "179794",
|
|
13
|
-
products: [
|
|
14
|
-
{
|
|
15
|
-
"title": "ميكروفون عالى الجودة",
|
|
16
|
-
"image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/pMdEEyMVpZFj4L1Hrdm2g48AuiSx0TrKULBiOnPo.jpg",
|
|
17
|
-
"price": "10,978.00 ر.س",
|
|
18
|
-
"qty": "2",
|
|
19
|
-
"totalBefore": "1120 ر.س",
|
|
20
|
-
"discount": "-5%",
|
|
21
|
-
"total": "1064 ر.س",
|
|
22
|
-
"id": "2314513454",
|
|
23
|
-
"getOptimusRouteKey": "7351233357"
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
"title": "وحدة تحكم لمشغل العاب",
|
|
27
|
-
"image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/NOa4kHvOkd1hBWHk3JIgAo1602oVACfuWGFz3vXv.jpg",
|
|
28
|
-
"price": "10,978.00 ر.س",
|
|
29
|
-
"qty": "2",
|
|
30
|
-
"totalBefore": "1120 ر.س",
|
|
31
|
-
"discount": "-5%",
|
|
32
|
-
"total": "1064 ر.س",
|
|
33
|
-
"id": "9842833",
|
|
34
|
-
"getOptimusRouteKey": "735152357"
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"title": "ساعة ذكية بنظام اندرويد",
|
|
38
|
-
"image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/T4kTqYNuPAZmPMLw1bx92RnjVMZyFszVXOUZQsFJ.jpg",
|
|
39
|
-
"price": "10,978.00 ر.س",
|
|
40
|
-
"qty": "2",
|
|
41
|
-
"totalBefore": "1120 ر.س",
|
|
42
|
-
"discount": "-5%",
|
|
43
|
-
"total": "1064 ر.س",
|
|
44
|
-
"id": "679822376",
|
|
45
|
-
"getOptimusRouteKey": "73233357"
|
|
46
|
-
}
|
|
47
|
-
],
|
|
48
|
-
ratingMessage: {
|
|
49
|
-
1: "غير راضي <span class='emoji mx-1'>😒</span>",
|
|
50
|
-
2: "لم يعجبني <span class='emoji mx-1'>😌</span>",
|
|
51
|
-
3: "معقول <span class='emoji mx-1'>🙄</span>",
|
|
52
|
-
4: "أعجبني <span class='emoji mx-1'>👍</span>",
|
|
53
|
-
5: "أعجبني جداً <span class='emoji mx-1'>🤩</span>"
|
|
54
|
-
},
|
|
55
|
-
settings: {
|
|
56
|
-
isProductsRating: true,
|
|
57
|
-
isStoreRating: true,
|
|
58
|
-
isShippingRating: true,
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
this.ratingChain = Promise.resolve();
|
|
62
|
-
this.wizardInex = 0;
|
|
63
|
-
}
|
|
64
|
-
componentDidRender() {
|
|
65
|
-
this.initiateRating();
|
|
66
|
-
}
|
|
67
|
-
render() {
|
|
68
|
-
return (h(Host, null, h("div", { class: "pannel__body" }, this.order.settings.isStoreRating && this.renderStoreRating(), this.order.settings.isProductsRating && this.renderProductsRating(), this.order.settings.isShippingRating && this.renderShippingRating()), h("div", { class: "pannel__footer relative flex justify-between items-center" }, h("button", { id: "prev-btn", class: "font-bold text-sm text-primary hidden" }, "\u0627\u0644\u0633\u0627\u0628\u0642"), h("ul", { class: "flex justify-center text-center space-s-1.5 py-8 flex-1" }, h("li", { class: "cursor-pointer w-2.5 h-2.5 bg-primary rounded-full transition-colors duration-300" }), h("li", { class: "cursor-pointer w-2.5 h-2.5 bg-gray-200 rounded-full transition-colors duration-300" }), h("li", { class: "cursor-pointer w-2.5 h-2.5 bg-gray-200 rounded-full transition-colors duration-300" })), h("button", { id: "next-btn", class: "btn btn-primary h-10 px-8 flex-none" }, "\u0627\u0644\u062A\u0627\u0644\u064A"))));
|
|
69
|
-
}
|
|
70
|
-
renderProductsRating() {
|
|
71
|
-
return (h("section", { class: "step rating-section products-section hidden", "data-type": "product" }, h("div", { class: "bg-white mb-5 p-5 rounded-md overflow-hidden mb-10" }, this.order.products.map((item, index) => {
|
|
72
|
-
var _a;
|
|
73
|
-
return h("div", { class: "rating-outer-form", "data-stars-error": `يرجى تقييم (${item.title}) بواسطة النجمات` }, h("div", { class: "product-item mb-4" }, h("div", { class: "mb-5" }, h("div", { class: "flex space-s-5 mb-8" }, h("img", { src: item.image, alt: item.title, class: "w-18 h-14 object-cover rounded-md" }), h("div", { class: "flex-1" }, h("h3", { class: "section-title leading-5 mb-1.5 md:text-base" }, " ", item.title), h("div", { class: "rw-product-entry__rate" }, h("div", { class: "rating-wrap flex items-center space-s-4" }, h("form", { class: "rate-element rate-element--has-label" }, this.getStarsRating()), h("p", { class: "rate-label fix-align font-xsm my-0" })), h("input", { type: "hidden", name: "order_id", value: (_a = this.order) === null || _a === void 0 ? void 0 : _a.order_id }), h("input", { type: "hidden", name: `products[${index}][product_id]`, value: item.getOptimusRouteKey }), h("input", { type: "hidden", name: "type", value: "products" }), h("textarea", { "data-product-id": item.id, name: `products[${index}][comment]`, id: `productReview_${item.id}`, class: "comment form-input h-20 product-review", placeholder: `اضف رأيك عن المنتج (${item.title})` }), h("small", { class: "text-red-400 validation-message" })))))));
|
|
74
|
-
}))));
|
|
75
|
-
}
|
|
76
|
-
renderStoreRating() {
|
|
77
|
-
return (h("section", { class: "step rating-section bg-white my-10 p-5 rounded-md mb-5 active", "data-type": "store" }, h("div", { class: "rating-outer-form", "data-stars-error": "\u064A\u0631\u062C\u0649 \u062A\u0642\u064A\u064A\u0645 \u0627\u0644\u0645\u062A\u062C\u0631 \u0628\u0648\u0627\u0633\u0637\u0629 \u0627\u0644\u0646\u062C\u0645\u0627\u062A" }, h("input", { type: "hidden", name: "order_id", value: this.order.order_id }), h("input", { type: "hidden", name: "type", value: "store" }), h("h2", { class: "section-title text-lg font-bold mb-5" }, "\u0643\u064A\u0641 \u0643\u0627\u0646\u062A \u062A\u062C\u0631\u0628\u062A\u0643 \u0645\u0639 \u0627\u0644\u0645\u062A\u062C\u0631 \u0647\u0630\u0647 \u0627\u0644\u0645\u0631\u0629"), h("div", { class: "mb-2" }, h("textarea", { id: "storeReview", name: "comment", class: "form-input comment h-20", placeholder: "\u0627\u0636\u0641 \u0631\u0623\u064A\u0643 \u0639\u0646 \u0627\u0644\u0645\u062A\u062C\u0631.." })), h("div", { class: "rating-wrap flex items-center space-s-4" }, h("form", { class: "rate-element rate-element--has-label" }, this.getStarsRating()), h("p", { class: "rate-label fix-align font-sm center mb-0" })), h("small", { class: "text-red-400 validation-message" }))));
|
|
78
|
-
}
|
|
79
|
-
renderShippingRating() {
|
|
80
|
-
return (h("section", { class: "step rating-section bg-white my-10 p-5 rounded-md mb-5 hidden", "data-type": "shipping" }, h("div", { class: "rating-outer-form", "data-stars-error": "\u064A\u0631\u062C\u0649 \u062A\u0642\u064A\u064A\u0645 \u0634\u0631\u0643\u0629 \u0627\u0644\u0634\u062D\u0646 \u0628\u0648\u0627\u0633\u0637\u0629 \u0627\u0644\u0646\u062C\u0645\u0627\u062A" }, h("input", { type: "hidden", name: "order_id", value: this.order.order_id }), h("input", { type: "hidden", name: "shipping_company_id", value: this.order.shipping.id }), h("input", { type: "hidden", name: "type", value: "shipping" }), h("h2", { class: "section-title text-lg font-bold mb-5" }, "\u062E\u0628\u0631\u0646\u0627 \u0639\u0646 \u062A\u062C\u0631\u0628\u062A\u0643 \u0645\u0639 \u0634\u0631\u0643\u0629 \u0627\u0644\u0634\u062D\u0646"), h("div", { class: "mb-2" }, h("textarea", { id: "shippingReview", name: "comment", class: "form-input comment h-20 mb-2", placeholder: "\u0627\u0636\u0641 \u0631\u0623\u064A\u0643 \u0639\u0646 \u0634\u0631\u0643\u0629 \u0627\u0644\u0634\u062D\u0646" })), h("div", { class: "rating-wrap flex items-center space-s-4" }, h("form", { class: "rate-element ratFeedbackPresentere-element--has-label" }, this.getStarsRating()), h("p", { class: "rate-label fix-align font-sm center mb-0" })), h("small", { class: "text-red-400 validation-message" }))));
|
|
81
|
-
}
|
|
82
|
-
getStarsRating() {
|
|
83
|
-
return (h("div", { class: "mb-1" }, h("input", { type: "hidden", class: "rating_hidden_input", name: "rating", value: "" }), this.stars.map((star) => h("button", { type: "submit", class: "btn btn--transparent px-1 text-lg text-gray-400 btn--star", "data-star": star, "data-text": this.order.ratingMessage[`${star}`] }, h("i", { class: "sicon-star2" })))));
|
|
84
|
-
}
|
|
85
|
-
initiateRating() {
|
|
86
|
-
this.highlightSelectedStars();
|
|
87
|
-
this.starsRating();
|
|
88
|
-
this.handleWizard();
|
|
89
|
-
//show submitRating Button Only When there is a comment field
|
|
90
|
-
// Helper.toggle('#submitRating', 'btn', 'hidden', () => Helper.element('#shippingReview,#storeReview,.product-review'))
|
|
91
|
-
// this.ratingChain = Promise.resolve();
|
|
92
|
-
// Helper.onClick('#submitRating', () => this.sendRating().then(() => window.location.reload()));
|
|
93
|
-
salla.event.on('submit::order-rating', () => this.sendRating().then(() => window.location.reload()));
|
|
94
|
-
}
|
|
95
|
-
handleWizard() {
|
|
96
|
-
let steps = document.querySelectorAll(".step"), stepsCount = document.querySelectorAll(".step").length;
|
|
97
|
-
Helper.onClick("#prev-btn", () => {
|
|
98
|
-
this.wizardInex > 0 && this.wizardInex--;
|
|
99
|
-
this.showActiveStep(steps);
|
|
100
|
-
this.wizardInex == 0 && Helper.toggle('#prev-btn', 'hidden', 'block', () => true);
|
|
101
|
-
});
|
|
102
|
-
Helper.onClick("#next-btn", () => {
|
|
103
|
-
this.ratingValidation();
|
|
104
|
-
this.wizardInex == stepsCount - 1 && salla.event.dispatch("submit::order-rating");
|
|
105
|
-
this.wizardInex < stepsCount - 1 && this.wizardInex++;
|
|
106
|
-
this.showActiveStep(steps);
|
|
107
|
-
Helper.toggle('#prev-btn', 'block', 'hidden', () => true);
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
showActiveStep(steps) {
|
|
111
|
-
Helper.toggle('.step', 'hidden', 'active', () => true);
|
|
112
|
-
Helper.toggleElement(steps[this.wizardInex], 'active', 'hidden', () => true);
|
|
113
|
-
}
|
|
114
|
-
sendRating() {
|
|
115
|
-
// this.ratingValidation()
|
|
116
|
-
Helper.all('.rating-section', ratingSection => {
|
|
117
|
-
let type = ratingSection.dataset.type;
|
|
118
|
-
let formsData = [];
|
|
119
|
-
ratingSection.querySelectorAll('.rating-outer-form')
|
|
120
|
-
.forEach((form) => {
|
|
121
|
-
let formData = {};
|
|
122
|
-
form.querySelectorAll('[name]')
|
|
123
|
-
.forEach(function (input) {
|
|
124
|
-
let inputData = salla.helpers.inputData(input.name, input.value, formData);
|
|
125
|
-
formData[inputData.name] = inputData.value;
|
|
126
|
-
});
|
|
127
|
-
formsData = [];
|
|
128
|
-
formsData.push(formData);
|
|
129
|
-
this.sendFeedback(type, formsData);
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
return this.ratingChain;
|
|
133
|
-
}
|
|
134
|
-
sendFeedback(type, formsData) {
|
|
135
|
-
if (!formsData || formsData.length == 0) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
salla.config.canLeave = false;
|
|
139
|
-
this.ratingChain = salla.feedback.api[type](formsData[0])
|
|
140
|
-
.then(function () {
|
|
141
|
-
salla.config.canLeave = true;
|
|
142
|
-
}).catch(() => salla.config.canLeave = true);
|
|
143
|
-
}
|
|
144
|
-
ratingValidation() {
|
|
145
|
-
let errorMsg = '';
|
|
146
|
-
document.querySelectorAll('.rating-section.active')
|
|
147
|
-
.forEach((ratingSection) => {
|
|
148
|
-
ratingSection.querySelectorAll('.rating-outer-form')
|
|
149
|
-
.forEach((rating) => {
|
|
150
|
-
let ratingInput = rating.querySelector('.rating_hidden_input');
|
|
151
|
-
let commentInput = rating.querySelector('.comment');
|
|
152
|
-
let sectionTitle = rating.querySelector('.section-title');
|
|
153
|
-
let validationMessage = rating.querySelector('.validation-message');
|
|
154
|
-
if (ratingInput.value && commentInput.value && commentInput.value.length > 3) {
|
|
155
|
-
commentInput.classList.remove('has-error');
|
|
156
|
-
sectionTitle === null || sectionTitle === void 0 ? void 0 : sectionTitle.classList.remove('has-error', 'text-red-400');
|
|
157
|
-
validationMessage.innerHTML = '';
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
else if (commentInput.value && commentInput.value.length > 3) {
|
|
161
|
-
commentInput.classList.remove('has-error');
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
commentInput.classList.add('has-error');
|
|
165
|
-
}
|
|
166
|
-
sectionTitle === null || sectionTitle === void 0 ? void 0 : sectionTitle.classList.add('has-error', 'text-red-400');
|
|
167
|
-
errorMsg = ratingInput.value
|
|
168
|
-
? (salla.lang.get('common.errors.not_less_than_chars', { chars: 4 }) + ' ' + commentInput.getAttribute('placeholder'))
|
|
169
|
-
: (rating.dataset.starsError || salla.lang.get('pages.rating.rate_store_stars'));
|
|
170
|
-
validationMessage.innerHTML = errorMsg;
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
//Fire error to prevent sending rating
|
|
174
|
-
if (errorMsg) {
|
|
175
|
-
// scroll to first error
|
|
176
|
-
let ratingErrors = document.querySelectorAll('.has-error');
|
|
177
|
-
if (ratingErrors.length) {
|
|
178
|
-
let firstError = ratingErrors[0].offsetTop;
|
|
179
|
-
window.scrollTo({ top: firstError - 80 }); // 80 = fixed nav height
|
|
180
|
-
}
|
|
181
|
-
throw new Error(errorMsg);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
// for hovered star ---
|
|
185
|
-
highlightSelectedStars() {
|
|
186
|
-
let hover = ['hovered', 'text-theme-yellow'];
|
|
187
|
-
Helper.all('.rate-element', el => {
|
|
188
|
-
let starElements = el.querySelectorAll('.btn--star');
|
|
189
|
-
// remove hovered state from stars ---
|
|
190
|
-
el.addEventListener('mouseout', () => el.querySelectorAll('.btn--star').forEach(star => star.classList.remove(...hover)));
|
|
191
|
-
starElements.forEach((starElement, index) => {
|
|
192
|
-
starElement.addEventListener('mouseover', () => {
|
|
193
|
-
starElement.classList.add(...hover);
|
|
194
|
-
if (index <= 1) {
|
|
195
|
-
starElement.previousElementSibling.tagName === 'BUTTON' ? starElement.previousElementSibling.classList.add(...hover) : null;
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
for (let i = 0; i < index; i++) {
|
|
199
|
-
starElements[i].classList.add(...hover);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
starElement.addEventListener('mouseout', () => {
|
|
204
|
-
starElement.classList.contains(...hover) ? starElement.classList.remove(...hover) : null;
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
starsRating() {
|
|
210
|
-
let selectedClasses = ['selected', 'text-theme-yellow'];
|
|
211
|
-
// Listen for form submissions
|
|
212
|
-
salla.document.event.onSubmit('.rate-element', function (event) {
|
|
213
|
-
// Prevent form from submitting
|
|
214
|
-
event.preventDefault();
|
|
215
|
-
// Get the selected star - activeElement is not supported in safari
|
|
216
|
-
var activeStars = event.target.querySelectorAll('.btn--star.hovered');
|
|
217
|
-
var selected = activeStars[activeStars.length - 1];
|
|
218
|
-
if (!selected)
|
|
219
|
-
return;
|
|
220
|
-
var selectedIndex = parseInt(selected.dataset.star, 10), selectedText = selected.dataset.text;
|
|
221
|
-
event.target.nextElementSibling.innerHTML = selectedText;
|
|
222
|
-
event.target.querySelector('.rating_hidden_input').value = selectedIndex;
|
|
223
|
-
// Get all stars in this form (only search in the form, not the whole document)
|
|
224
|
-
// Loop through each star, and add or remove the `.selected` class to toggle highlighting
|
|
225
|
-
event.target
|
|
226
|
-
.querySelectorAll('.btn--star')
|
|
227
|
-
.forEach(function (star, index) {
|
|
228
|
-
if (index < selectedIndex) {
|
|
229
|
-
// Selected star or before it, Add highlighting
|
|
230
|
-
star.classList.add(...selectedClasses);
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
// After selected star, Remove highlight
|
|
234
|
-
star.classList.remove(...selectedClasses);
|
|
235
|
-
});
|
|
236
|
-
// Remove aria-pressed from any previously selected star
|
|
237
|
-
var previousRating = event.target.querySelector('.star[aria-pressed="true"]');
|
|
238
|
-
if (previousRating) {
|
|
239
|
-
previousRating.removeAttribute('aria-pressed');
|
|
240
|
-
}
|
|
241
|
-
// Add aria-pressed role to the selected button
|
|
242
|
-
selected.setAttribute('aria-pressed', true);
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
OrderRating.style = orderRatingCss;
|
|
247
|
-
|
|
248
|
-
export { OrderRating as order_rating };
|