@salla.sa/twilight-components 1.0.12 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/{esm → twilight-components}/Helper-81ac9a8c.js +0 -0
  2. package/dist/twilight-components/app-globals-0f993ce5.js +3 -0
  3. package/dist/twilight-components/css-shim-a64b8820.js +4 -0
  4. package/dist/twilight-components/dom-d08ba8aa.js +73 -0
  5. package/dist/twilight-components/index-8cf58712.js +3010 -0
  6. package/dist/twilight-components/index.esm.js +3 -1
  7. package/dist/twilight-components/multi-warehouse.entry.js +89 -0
  8. package/dist/twilight-components/salla-button.entry.js +70 -0
  9. package/dist/{esm → twilight-components}/salla-localization.entry.js +8 -7
  10. package/dist/{esm/salla-login-0e85b2d8.js → twilight-components/salla-login-97e0a9ab.js} +1 -1
  11. package/dist/twilight-components/salla-login.entry.js +2 -0
  12. package/dist/twilight-components/salla-modal.entry.js +85 -0
  13. package/dist/{esm → twilight-components}/salla-product-availability.entry.js +12 -15
  14. package/dist/{esm → twilight-components}/salla-rating.entry.js +17 -17
  15. package/dist/{esm/salla-search-615b8f94.js → twilight-components/salla-search-df1c9b54.js} +1 -1
  16. package/dist/twilight-components/salla-search.entry.js +2 -0
  17. package/dist/{esm → twilight-components}/salla-verify.entry.js +1 -1
  18. package/dist/twilight-components/shadow-css-bc14d9fd.js +389 -0
  19. package/dist/twilight-components/twilight-components.esm.js +125 -1
  20. package/dist/types/components/salla-button/salla-button.d.ts +1 -0
  21. package/dist/types/components/salla-localization/salla-localization.d.ts +2 -2
  22. package/dist/types/components/salla-product-availability/salla-product-availability.d.ts +4 -3
  23. package/dist/types/components.d.ts +14 -10
  24. package/package.json +1 -1
  25. package/dist/cjs/Helper-8852feaa.js +0 -23
  26. package/dist/cjs/index-23da2c6b.js +0 -1601
  27. package/dist/cjs/index.cjs.js +0 -12
  28. package/dist/cjs/loader.cjs.js +0 -21
  29. package/dist/cjs/multi-warehouse_4.cjs.entry.js +0 -242
  30. package/dist/cjs/salla-localization.cjs.entry.js +0 -76
  31. package/dist/cjs/salla-login-476fb312.js +0 -14
  32. package/dist/cjs/salla-product-availability.cjs.entry.js +0 -78
  33. package/dist/cjs/salla-rating.cjs.entry.js +0 -299
  34. package/dist/cjs/salla-search-f9e00be9.js +0 -97
  35. package/dist/cjs/salla-search.cjs.entry.js +0 -10
  36. package/dist/cjs/salla-verify.cjs.entry.js +0 -96
  37. package/dist/cjs/twilight-components.cjs.js +0 -19
  38. package/dist/collection/Helpers/Helper.js +0 -19
  39. package/dist/collection/collection-manifest.json +0 -20
  40. package/dist/collection/components/generate-summary.js +0 -35
  41. package/dist/collection/components/multi-warehouse/multi-warehouse.css +0 -13
  42. package/dist/collection/components/multi-warehouse/multi-warehouse.js +0 -238
  43. package/dist/collection/components/salla-button/salla-button.css +0 -3
  44. package/dist/collection/components/salla-button/salla-button.js +0 -219
  45. package/dist/collection/components/salla-localization/salla-localization.js +0 -201
  46. package/dist/collection/components/salla-login/salla-login.js +0 -31
  47. package/dist/collection/components/salla-modal/salla-modal.js +0 -316
  48. package/dist/collection/components/salla-product-availability/salla-product-availability.js +0 -316
  49. package/dist/collection/components/salla-rating/salla-rating.css +0 -3
  50. package/dist/collection/components/salla-rating/salla-rating.js +0 -484
  51. package/dist/collection/components/salla-search/salla-search.js +0 -155
  52. package/dist/collection/components/salla-verify/salla-verify.js +0 -99
  53. package/dist/collection/index.js +0 -2
  54. package/dist/collection/interfaces/colors.js +0 -1
  55. package/dist/collection/interfaces/index.js +0 -2
  56. package/dist/collection/interfaces/ratio.js +0 -1
  57. package/dist/collection/plugins/tailwind-theme/generator.js +0 -53
  58. package/dist/collection/plugins/tailwind-theme/index.js +0 -26
  59. package/dist/esm/index-643344dc.js +0 -1573
  60. package/dist/esm/index.js +0 -3
  61. package/dist/esm/loader.js +0 -17
  62. package/dist/esm/multi-warehouse_4.entry.js +0 -235
  63. package/dist/esm/polyfills/core-js.js +0 -11
  64. package/dist/esm/polyfills/css-shim.js +0 -1
  65. package/dist/esm/polyfills/dom.js +0 -79
  66. package/dist/esm/polyfills/es5-html-element.js +0 -1
  67. package/dist/esm/polyfills/index.js +0 -34
  68. package/dist/esm/polyfills/system.js +0 -6
  69. package/dist/esm/salla-search.entry.js +0 -2
  70. package/dist/esm/twilight-components.js +0 -17
  71. package/dist/index.cjs.js +0 -1
  72. package/dist/index.js +0 -1
  73. package/dist/twilight-components/p-2b8a5fa4.entry.js +0 -1
  74. package/dist/twilight-components/p-36c87e2e.js +0 -1
  75. package/dist/twilight-components/p-4e37a6cb.entry.js +0 -1
  76. package/dist/twilight-components/p-751643d8.entry.js +0 -1
  77. package/dist/twilight-components/p-8a2410e6.js +0 -1
  78. package/dist/twilight-components/p-94b18718.entry.js +0 -1
  79. package/dist/twilight-components/p-9bc28e0c.js +0 -1
  80. package/dist/twilight-components/p-bb503365.entry.js +0 -1
  81. package/dist/twilight-components/p-d1ef2268.js +0 -1
  82. package/dist/twilight-components/p-d34bbfc4.entry.js +0 -1
@@ -1 +1,3 @@
1
- export{S as SallaLogin}from"./p-36c87e2e.js";export{S as SallaSearch}from"./p-8a2410e6.js";import"./p-d1ef2268.js";
1
+ export { S as SallaLogin } from './salla-login-97e0a9ab.js';
2
+ export { S as SallaSearch } from './salla-search-df1c9b54.js';
3
+ import './index-8cf58712.js';
@@ -0,0 +1,89 @@
1
+ import { r as registerInstance, h, g as getElement } from './index-8cf58712.js';
2
+
3
+ const multiWarehouseCss = "#s-multi-warehouse-modal .s-modal-header{display:flex;flex-direction:column;margin-bottom:40px}#s-multi-warehouse-modal .s-modal-sub-title{margin:0}#s-multi-warehouse-modal .s-modal-title{order:10}";
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
+ this.btn.load().then(() => {
54
+ setTimeout(() => location.reload(), 2000);
55
+ });
56
+ sessionStore.set("multi-warehouse-opened-before", true);
57
+ this.show();
58
+ setTimeout(() => {
59
+ this.current = this.selected;
60
+ }, 300);
61
+ }
62
+ render() {
63
+ return (h("salla-modal", { icon: "sicon-store-alt", title: "\u0641\u0631\u0639 \u0627\u0644\u0631\u064A\u0627\u0636", "sub-title": "\u0623\u0646\u062A \u0627\u0644\u0622\u0646 \u062A\u062A\u0635\u0641\u062D \u0627\u0644\u0645\u062A\u062C\u0631 \u0645\u0646", "is-closable": !this.isOpenedBefore && this.displayAs == 'popup' ? 'false' : 'true', ref: modal => this.modal = modal, "modal-width": "w-116", id: "s-multi-warehouse-modal", class: "hidden" }, h("div", { class: "text-right" }, 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 ?
64
+ 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: {
65
+ 'me-3 focus:ring-primary h-4 w-4 text-primary border-gray-300': true,
66
+ 'opacity-50': !branch.open,
67
+ 'hidden': !this.isChoiceable()
68
+ }, checked: this.current == branch.id }), h("label", { htmlFor: this.position + '_branch_' + branch.id, class: {
69
+ 'flex items-center justify-between text-sm font-medium text-gray-700 flex-grow': true,
70
+ 'cursor-pointer': this.isChoiceable()
71
+ } }, h("span", { class: { 'opacity-50': !branch.open } }, branch.name), this.isChoiceable() ?
72
+ h("small", { class: "text-red-400" }, branch.open ? '' : 'مُغلق')
73
+ :
74
+ h("span", { class: this.statusColor(branch) }, branch.tag)))))
75
+ :
76
+ 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() ?
77
+ h("div", { slot: "footer", class: "mt-6" }, h("slot", { name: "footer" }, h("salla-button", { "loader-position": "before", ref: btn => this.btn = btn, onClick: () => this.handleSubmit(), class: "w-full" }, salla.lang.get('common.elements.ok'))))
78
+ : ''));
79
+ }
80
+ componentDidRender() {
81
+ if (!this.isOpenedBefore && this.displayAs == 'popup') {
82
+ this.show();
83
+ }
84
+ }
85
+ get host() { return getElement(this); }
86
+ };
87
+ MultiWarehouse.style = multiWarehouseCss;
88
+
89
+ export { MultiWarehouse as multi_warehouse };
@@ -0,0 +1,70 @@
1
+ import { r as registerInstance, h, g as getElement } from './index-8cf58712.js';
2
+ import { H as Helper } from './Helper-81ac9a8c.js';
3
+
4
+ const sallaButtonCss = ":host{display:block}";
5
+
6
+ const SallaButton = class {
7
+ constructor(hostRef) {
8
+ registerInstance(this, hostRef);
9
+ this.btnStyle = 'primary'; // outline, outline-primary ,danger
10
+ this.loading = false;
11
+ this.disabled = false;
12
+ this.loaderPosition = 'before';
13
+ this.wide = false;
14
+ this.hostAttributes = {};
15
+ //============= Initiate Button Attributes =============//
16
+ for (let i = 0; i < this.host.attributes.length; i++) {
17
+ this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
18
+ }
19
+ this.hostAttributes.type = this.hostAttributes.type || 'button';
20
+ this.hostAttributes.class += ' s-button-btn btn--has-loading '
21
+ + 'btn-' + this.btnStyle
22
+ + (this.wide ? ' s-button-btn-wide ' : '')
23
+ + 'loader-' + this.loaderPosition
24
+ + (this.loaderPosition == 'before' ? ' flex-row-reverse' : '');
25
+ // if(this.hostAttributes.onclick){
26
+ // this.hostAttributes.onclick=eval(this.hostAttributes.onclick);
27
+ // }
28
+ delete this.hostAttributes['btn-style'];
29
+ delete this.hostAttributes['id'];
30
+ }
31
+ async load() {
32
+ if (this.loaderPosition == 'center')
33
+ this.host.querySelector('.btn-text').classList.add('opacity-0');
34
+ this.host.setAttribute('loading', '');
35
+ return this.host;
36
+ }
37
+ async stop() {
38
+ this.host.removeAttribute('loading');
39
+ return this.host;
40
+ }
41
+ async disable() {
42
+ this.host.setAttribute('disabled', '');
43
+ }
44
+ async enable() {
45
+ this.host.removeAttribute('disabled');
46
+ }
47
+ handleVisible(newKind, oldKind) {
48
+ this.btn.classList.remove('btn-' + oldKind);
49
+ this.btn.classList.add('btn-' + newKind);
50
+ }
51
+ handleLoading(newVal) {
52
+ Helper.toggleElement(this.btn, 'btn--is-loading', 'btn--no-loading', () => newVal);
53
+ }
54
+ render() {
55
+ return (h("button", Object.assign({ ref: btn => this.btn = btn, disabled: this.disabled }, this.hostAttributes), h("span", { class: "btn-text transition-opacity duration-300" }, h("slot", null)), this.loading ? h("span", { class: {
56
+ 'loader loader--small s-button-loader': true,
57
+ 'absolute right-2': this.loaderPosition === 'start',
58
+ 'absolute left-2': this.loaderPosition === 'end',
59
+ 'absolute top-1/2 left-1/2 !-translate-x-1/2 !-translate-y-1/2 !m-0': this.loaderPosition === 'center',
60
+ } }) : ''));
61
+ }
62
+ get host() { return getElement(this); }
63
+ static get watchers() { return {
64
+ "btnStyle": ["handleVisible"],
65
+ "loading": ["handleLoading"]
66
+ }; }
67
+ };
68
+ SallaButton.style = sallaButtonCss;
69
+
70
+ export { SallaButton as salla_button };
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h, g as getElement } from './index-643344dc.js';
1
+ import { r as registerInstance, h, g as getElement } from './index-8cf58712.js';
2
2
  import { H as Helper } from './Helper-81ac9a8c.js';
3
3
 
4
4
  const SallaLocalization = class {
@@ -7,8 +7,9 @@ const SallaLocalization = class {
7
7
  var _a, _b;
8
8
  this.language = salla.config.language;
9
9
  this.currency = salla.config.currency;
10
- this.languages = salla.lang.get('common.titles.language');
11
- this.currencies = salla.lang.get('common.titles.currency');
10
+ //todo::
11
+ this.languagesTitle = salla.lang.get('common.titles.language');
12
+ this.currenciesTitle = salla.lang.get('common.titles.currency');
12
13
  this.ok = salla.lang.get('common.elements.ok');
13
14
  Helper.setHost(this.host);
14
15
  salla.event.on('localization::show', () => this.show());
@@ -21,7 +22,7 @@ const SallaLocalization = class {
21
22
  * Because scoped templates not supported in stencil );
22
23
  * we made a workaround to pass language & currency attributes, then replace names in rendering
23
24
  */
24
- this.languageSlot = ((_a = Helper.getElement('[slot="language"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '<label class="s-localization-label" for"lang-{code}"><span>{name}</span><div class="s-localization-flag flag iti__flag iti__{country_code}"></div></label>';
25
+ this.languageSlot = ((_a = Helper.getElement('[slot="language"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '<label class="s-localization-label" for="lang-{code}"><span>{name}</span><div class="s-localization-flag flag iti__flag iti__{country_code}"></div></label>';
25
26
  this.currencySlot = ((_b = Helper.getElement('[slot="currency"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || '<label class="s-localization-label" for="currency-{code}"><span>{name}</span><small class="s-localization-currency">{code}</small></label>';
26
27
  }
27
28
  async show() {
@@ -48,16 +49,16 @@ const SallaLocalization = class {
48
49
  }
49
50
  render() {
50
51
  return (h("salla-modal", { id: "salla-localization", class: "hidden", ref: modal => this.modal = modal }, h("slot", { name: "header" }, h("div", { slot: "header" })), h("div", { class: "s-localization-inner" }, salla.config.languages
51
- ? h("div", { class: "s-localization-section" }, h("label", { class: "s-localization-title" }, this.languages), h("fieldset", { class: "s-localization-fieldset" }, h("legend", { class: "sr-only" }, salla.lang.get('blocks.header.change_language')), h("div", { class: "s-localization-section-inner" }, salla.config.languages.map(lang => h("div", { class: "s-localization-item" }, 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 }), h("div", { id: "language-slot", innerHTML: this.languageSlot
52
+ ? h("div", { class: "s-localization-section" }, h("label", { class: "s-localization-title" }, this.languagesTitle), h("fieldset", { class: "s-localization-fieldset" }, h("div", { class: "s-localization-section-inner" }, salla.config.languages.map(lang => h("div", { class: "s-localization-item" }, 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 }), h("div", { id: "language-slot", innerHTML: this.languageSlot
52
53
  .replace(/\{name\}/g, lang.name)
53
54
  .replace(/\{code\}/g, lang.code)
54
55
  .replace(/\{country_code\}/g, lang.country_code) }))))))
55
56
  : '', salla.config.currencies
56
- ? h("div", { class: "s-localization-section" }, h("label", { class: "s-localization-title" }, this.currencies), h("fieldset", { class: "s-localization-fieldset" }, h("legend", { class: "sr-only" }, salla.lang.get('blocks.header.change_currency')), h("div", { class: "s-localization-section-inner" }, salla.config.currencies.map(currency => h("div", { class: "s-localization-item" }, 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 }), h("div", { id: "currency-slot", innerHTML: this.currencySlot
57
+ ? h("div", { class: "s-localization-section" }, h("label", { class: "s-localization-title" }, this.currenciesTitle), h("fieldset", { class: "s-localization-fieldset" }, h("div", { class: "s-localization-section-inner" }, salla.config.currencies.map(currency => h("div", { class: "s-localization-item" }, 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 }), h("div", { id: "currency-slot", innerHTML: this.currencySlot
57
58
  .replace(/\{name\}/g, currency.name)
58
59
  .replace(/\{code\}/g, currency.code)
59
60
  .replace(/\{country_code\}/g, currency.country_code) }))))))
60
- : ''), h("p", { slot: "footer" }, h("slot", { name: "footer" }, h("salla-button", { ref: btn => this.btn = btn, onClick: () => this.submit(), class: "w-full" }, this.ok)))));
61
+ : ''), h("p", { slot: "footer" }, h("slot", { name: "footer" }, h("salla-button", { wide: true, ref: btn => this.btn = btn, onClick: () => this.submit() }, this.ok)))));
61
62
  }
62
63
  /**
63
64
  * to reduce dom levels we will move slot data into the parent dom
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h } from './index-643344dc.js';
1
+ import { r as registerInstance, h } from './index-8cf58712.js';
2
2
 
3
3
  const SallaLogin = class {
4
4
  constructor(hostRef) {
@@ -0,0 +1,2 @@
1
+ export { S as salla_login } from './salla-login-97e0a9ab.js';
2
+ import './index-8cf58712.js';
@@ -0,0 +1,85 @@
1
+ import { r as registerInstance, f as createEvent, h, e as Host, g as getElement } from './index-8cf58712.js';
2
+ import { H as Helper } from './Helper-81ac9a8c.js';
3
+
4
+ const SallaModal = class {
5
+ constructor(hostRef) {
6
+ registerInstance(this, hostRef);
7
+ this.ready = createEvent(this, "ready", 7);
8
+ this.close = createEvent(this, "close", 7);
9
+ this.error = false;
10
+ this.success = false;
11
+ this.isClosable = true;
12
+ this.modalWidth = 'w-96'; //todo use friendly names
13
+ this.visible = false;
14
+ this.subTitle = '';
15
+ this.icon = '';
16
+ salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
17
+ salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
18
+ this.title = this.host.title;
19
+ this.host.removeAttribute('title');
20
+ }
21
+ handleVisible(newValue) {
22
+ if (!newValue) {
23
+ this.toggleModal(false);
24
+ this.close.emit();
25
+ return;
26
+ }
27
+ this.host.classList.remove('hidden');
28
+ setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
29
+ this.ready.emit();
30
+ }
31
+ async show() {
32
+ this.host.setAttribute('visible', '');
33
+ return this.host;
34
+ }
35
+ async hide() {
36
+ this.host.removeAttribute('visible');
37
+ return this.host;
38
+ }
39
+ async setTitle(title) {
40
+ this.title = title;
41
+ return this.host;
42
+ }
43
+ toggleModal(isOpen) {
44
+ //todo:: use ref
45
+ Helper.toggleElement(this.host.querySelector('.s-modal-overlay'), 'ease-out duration-300 opacity-100', 'opacity-0', () => isOpen)
46
+ .toggleElement(this.host.querySelector('.s-modal-body'), 'ease-out duration-300 opacity-100 translate-y-0 sm:scale-100', //add these classes
47
+ 'opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95', //remove these classes
48
+ () => isOpen)
49
+ .toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
50
+ if (!isOpen) {
51
+ setTimeout(() => this.host.classList.add('hidden'), 350);
52
+ }
53
+ }
54
+ closeModal() {
55
+ if (!this.isClosable) {
56
+ return;
57
+ }
58
+ this.host.removeAttribute('visible');
59
+ }
60
+ //todo:: pref for each modal
61
+ render() {
62
+ this.host.id = this.host.id || 'salla-modal';
63
+ 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("div", { class: { 's-modal-header': true,
64
+ 'text-center': this.icon != '' } }, this.isClosable ?
65
+ h("button", { class: "s-modal-close cursor-pointer", onClick: () => this.closeModal(), type: "button" }, h("span", { class: "sicon-cancel" }))
66
+ : '', this.error || this.success || this.icon
67
+ ? h("div", { class: {
68
+ 's-modal-icon': true,
69
+ 's-modal-bg-error': this.error,
70
+ 's-modal-bg-success': this.success,
71
+ 's-modal-bg-normal': !this.error && !this.success
72
+ } }, h("i", { class: {
73
+ [this.icon]: true,
74
+ 's-modal-text-error': this.error,
75
+ 's-modal-text-success': this.success,
76
+ } }))
77
+ : '', 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" })))));
78
+ }
79
+ get host() { return getElement(this); }
80
+ static get watchers() { return {
81
+ "visible": ["handleVisible"]
82
+ }; }
83
+ };
84
+
85
+ export { SallaModal as salla_modal };
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h, H as Host, g as getElement } from './index-643344dc.js';
1
+ import { r as registerInstance, h, e as Host, g as getElement } from './index-8cf58712.js';
2
2
  import { H as Helper } from './Helper-81ac9a8c.js';
3
3
 
4
4
  const SallaProductAvailability = class {
@@ -7,15 +7,16 @@ const SallaProductAvailability = class {
7
7
  this.isUser = Helper.isUser();
8
8
  this.buttonText = salla.lang.get('pages.products.notify_availability');
9
9
  this.countryCode = salla.config.country_code || 'SA';
10
- this.subscribe = salla.lang.get('common.elements.submit');
11
- this.cancel = salla.lang.get('common.elements.cancel');
10
+ this.subscribeText = salla.lang.get('common.elements.submit');
11
+ this.cancelText = salla.lang.get('common.elements.cancel');
12
12
  this.subTitle = salla.lang.get('pages.products.notify_availability_subtitle');
13
13
  this.mobileLabel = salla.lang.get('common.elements.mobile');
14
14
  this.emailLabel = salla.lang.get('common.elements.email');
15
15
  this.mobilePlaceholder = salla.lang.get('common.elements.mobile_placeholder');
16
16
  this.emailPlaceholder = salla.lang.get('common.elements.email_placeholder');
17
17
  this.productId = salla.config.page.id;
18
- this.subscribed = salla.lang.get('pages.products.notify_availability_success');
18
+ this.subscribedMessage = salla.lang.get('pages.products.notify_availability_success');
19
+ this.isSubscribed = false;
19
20
  if (this.isUser) {
20
21
  return;
21
22
  }
@@ -29,10 +30,7 @@ const SallaProductAvailability = class {
29
30
  async submit() {
30
31
  if (this.isUser) {
31
32
  return salla.api.product.availabilitySubscribe(this.productId)
32
- .then(() => {
33
- salla.success(this.subscribed);
34
- }) //no need to wait until finishing alert animation
35
- .then(() => this.host.remove());
33
+ .then(() => this.isSubscribed = true);
36
34
  }
37
35
  let data = { id: this.productId, country_code: this.countryCode };
38
36
  if (this.mobile.value !== '') {
@@ -44,26 +42,25 @@ const SallaProductAvailability = class {
44
42
  return this.btn.load()
45
43
  .then(() => this.btn.disable())
46
44
  .then(() => salla.api.product.availabilitySubscribe(data))
47
- .then(() => {
48
- salla.success(this.subscribed);
49
- }) //no need to wait until finishing alert animation
45
+ .then(() => this.isSubscribed = true) //no need to wait until finishing alert animation
50
46
  .then(() => this.btn.stop())
51
47
  .then(() => this.modal.hide())
52
- .then(() => this.host.remove())
53
48
  .catch(() => this.btn.stop() && this.btn.enable());
54
49
  }
55
50
  render() {
56
- return (h(Host, null, h("slot", null, h("salla-button", { onClick: () => this.isUser ? this.submit() : this.modal.show() }, this.buttonText)), this.isUser ? '' : this.renderModal()));
51
+ return (h(Host, null, this.isSubscribed
52
+ ? h("div", { class: "s-product-availability-subscribed" }, this.subscribedMessage)
53
+ : h("slot", null, h("salla-button", { wide: true, onClick: () => this.isUser ? this.submit() : this.modal.show() }, this.buttonText)), this.isUser || this.isSubscribed ? '' : this.renderModal()));
57
54
  }
58
55
  renderModal() {
59
- return (h("salla-modal", { ref: modal => this.modal = modal, id: "product-availability-modal", title: this.title_, subTitle: this.subTitle, icon: "sicon-bell-ring", modalWidth: "w-full" }, h("div", { class: "s-product-availability-body" }, this.channels_.includes('email') ? [
56
+ return (h("salla-modal", { ref: modal => this.modal = modal, title: this.title_, subTitle: this.subTitle, icon: "sicon-bell-ring", modalWidth: "w-full" }, h("div", { class: "s-product-availability-body" }, this.channels_.includes('email') ? [
60
57
  h("label", { class: "s-product-availability-label" }, this.emailLabel),
61
58
  h("input", { class: "s-product-availability-input", placeholder: this.emailPlaceholder, ref: el => this.email = el, type: "email" })
62
59
  ] : '', this.channels_.includes('sms') ? [
63
60
  h("label", { class: "s-product-availability-label" }, this.mobileLabel),
64
61
  h("input", { class: "s-product-availability-input", placeholder: this.mobilePlaceholder, ref: el => this.mobile = el, type: "text" }),
65
62
  h("input", { type: "hidden", value: this.countryCode }),
66
- ] : ''), h("div", { slot: "footer", class: "common-anime flex justify-between space-s-4" }, h("salla-button", { ref: btn => this.btn = btn, class: "w-full", onClick: () => this.submit() }, this.subscribe), h("salla-button", { class: "w-full", color: "outline" }, this.cancel))));
63
+ ] : ''), h("div", { slot: "footer", class: "s-product-availability-footer" }, h("salla-button", { wide: true, ref: btn => this.btn = btn, onClick: () => this.submit() }, this.subscribeText), h("salla-button", { wide: true, "btn-style": "outline" }, this.cancelText))));
67
64
  }
68
65
  get host() { return getElement(this); }
69
66
  static get watchers() { return {
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h, H as Host, g as getElement } from './index-643344dc.js';
1
+ import { r as registerInstance, h, e as Host, g as getElement } from './index-8cf58712.js';
2
2
  import { H as Helper } from './Helper-81ac9a8c.js';
3
3
 
4
4
  const sallaRatingCss = ":host{display:block}";
@@ -81,7 +81,6 @@ const SallaRating = class {
81
81
  }
82
82
  }, 1000);
83
83
  this.host.querySelector('.wizard-footer').classList.add('opacity-0', 'pointer-events-0');
84
- this.host.querySelector('.s-order-rating-title').classList.add('opacity-0', 'pointer-events-0');
85
84
  Helper.toggle('.step', 'hidden', 'block', () => true);
86
85
  Helper.toggle('.thankyou-view', 'is-opened', 'hidden', () => true);
87
86
  const thankYouView = this.host.querySelector('.thankyou-view');
@@ -93,30 +92,32 @@ const SallaRating = class {
93
92
  }
94
93
  // handle wizard
95
94
  handleWizard() {
96
- let currentIndex = 0, steps = document.querySelectorAll(".step"), dots = document.querySelectorAll(".step-dot");
95
+ let index = 0, steps = document.querySelectorAll(".step"), dots = document.querySelectorAll(".step-dot");
97
96
  // show first step
98
- Helper.toggleElement(steps[0], ['opacity-1', 'translate-x-0'], ['opacity-0', 'translate-x-3', 'hidden'], () => true);
99
- console.log("🚀 ~ file: order-rating.tsx ~ line 129 ~ OrderRating ~ handleWizard ~ steps[0]", steps[0]);
97
+ this.showActiveStep(steps, dots, index);
98
+ // handle btn text
99
+ // Helper.getElement('#next-btn .btn-text').innerHTML= steps[index + 1].dataset.stepName;
100
+ // change to be seprated method
100
101
  Helper.onClick("#prev-btn", () => {
101
- currentIndex > 0 && currentIndex--;
102
- this.showActiveStep(steps, dots, currentIndex);
103
- currentIndex == 0 && Helper.toggle('#prev-btn', ['pointer-events-none', 'opacity-0'], 'block', () => true);
102
+ index > 0 && index--;
103
+ this.showActiveStep(steps, dots, index);
104
+ index == 0 && Helper.toggle('#prev-btn', ['pointer-events-none', 'opacity-0'], 'block', () => true);
104
105
  });
105
106
  Helper.onClick("#next-btn", () => {
106
107
  this.ratingValidation();
107
- if (currentIndex == this.stepsCount - 1) {
108
+ if (index == this.stepsCount - 1) {
108
109
  salla.event.dispatch("submit::order-rating");
109
110
  }
110
111
  else {
111
- currentIndex < this.stepsCount - 1 && currentIndex++;
112
- this.showActiveStep(steps, dots, currentIndex);
112
+ index < this.stepsCount - 1 && index++;
113
+ this.showActiveStep(steps, dots, index);
113
114
  Helper.toggle('#prev-btn', 'block', ['pointer-events-none', 'opacity-0'], () => true);
114
115
  }
115
116
  });
116
117
  }
117
118
  showActiveStep(steps, dots, currentIndex) {
118
119
  Helper.toggle('.step-dot', 'bg-gray-200', 'bg-primay', () => true);
119
- Helper.toggleElement(dots[currentIndex], 'bg-primary', 'bg-gray-200', () => true);
120
+ this.stepsCount > 1 && Helper.toggleElement(dots[currentIndex], 'bg-primary', 'bg-gray-200', () => true);
120
121
  // hide all steps
121
122
  Helper.toggle('.step', ['hidden', 'opacity-0', 'translate-x-3'], ['active', 'opacity-1', 'translate-x-0'], () => true);
122
123
  Helper.toggleElement(steps[currentIndex], 'active', 'hidden', () => true);
@@ -205,8 +206,7 @@ const SallaRating = class {
205
206
  // getdata
206
207
  getData() {
207
208
  salla.api.order.endpointsMethods.details = 'get';
208
- // salla.order.api.details(this.orderId).then(data => console.log(''));
209
- console.log("🚀 ~ file", salla.order.api.details(this.orderId));
209
+ salla.order.api.details(salla.config.page.id).then(data => console.log(''));
210
210
  }
211
211
  // handle star rating
212
212
  starsRating() {
@@ -274,13 +274,13 @@ const SallaRating = class {
274
274
  h("ul", { class: "flex justify-center text-center space-s-1.5 flex-1" }, [0, 1, 2].slice(0, this.stepsCount).map(index => h("li", { class: `${index == 0 ? 'bg-primary' : 'bg-gray-200'} step-dot w-2.5 h-2.5 rounded-full transition-colors duration-300` }))) : '', h("salla-button", { id: "next-btn", class: "w-28", ref: nextBtn => this.nextBtn = nextBtn }, "\u0627\u0644\u062A\u0627\u0644\u064A")))));
275
275
  }
276
276
  renderStoreRating() {
277
- return (h("section", { class: "step rating-section active transition-all duration-500", "data-type": "store" }, h("div", { class: "rating-outer-form", "data-stars-error": salla.lang.get('pages.rating.rate_store_stars') }, h("input", { type: "hidden", name: "order_id", value: this.orderId }), h("input", { type: "hidden", name: "type", value: "store" }), h("div", { class: "flex flex-col items-center " }, h("div", { class: "w-28 h-28 border border-gray-200 rounded-full flex items-center justify-center mb-4" }, h("img", { src: "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/X3NKcY7nhaFQlR7kBBHvfDpMY48cerunKrmDA1gi.png", alt: "store name", class: "w-12 object-contain" })), h("h2", { class: "section-title text-lg font-bold mb-4" }, salla.lang.get('pages.rating.rate_the_store'))), h("div", { class: "rating-wrap flex items-center flex justify-center mb-4" }, h("form", { class: "rate-element rate-element--has-label" }, this.getStarsRating())), h("textarea", { id: "storeReview", name: "comment", class: "form-input comment h-20", placeholder: salla.lang.get('pages.rating.write_store_rate') }), h("small", { class: "text-red-400 validation-message" }))));
277
+ return (h("section", { class: "step rating-section active transition-all duration-500 opacity-0 translate-x-3 hidden", "data-type": "store", "data-step-name": "\u062A\u0642\u064A\u064A\u0645 \u0627\u0644\u0645\u062A\u062C\u0631" }, h("div", { class: "rating-outer-form", "data-stars-error": salla.lang.get('pages.rating.rate_store_stars') }, h("input", { type: "hidden", name: "order_id", value: this.orderId }), h("input", { type: "hidden", name: "type", value: "store" }), h("div", { class: "flex flex-col items-center " }, h("div", { class: "w-28 h-28 border border-gray-200 rounded-full flex items-center justify-center mb-4" }, h("img", { src: "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/X3NKcY7nhaFQlR7kBBHvfDpMY48cerunKrmDA1gi.png", alt: "store name", class: "w-12 object-contain" })), h("h2", { class: "section-title text-lg font-bold mb-4" }, salla.lang.get('pages.rating.rate_the_store'))), h("div", { class: "rating-wrap flex items-center flex justify-center mb-4" }, h("form", { class: "rate-element rate-element--has-label" }, this.getStarsRating())), h("textarea", { id: "storeReview", name: "comment", class: "form-input comment h-20", placeholder: salla.lang.get('pages.rating.write_store_rate') }), h("small", { class: "text-red-400 validation-message" }))));
278
278
  }
279
279
  renderProductsRating() {
280
- return (h("section", { class: "step rating-section products-section transition-all duration-500 opacity-0 translate-x-3 hidden", "data-type": "product" }, h("div", { class: "overflow-hidden" }, this.order.products.map((item, index) => h("div", { class: "rating-outer-form mb-8 last:mb-0", "data-stars-error": salla.lang.get('pages.rating.rate_product_stars', { "item": item.title }) }, h("div", { class: "product-item" }, h("div", { class: "flex space-s-5" }, 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 font-bold md:text-sm" }, " ", 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("input", { type: "hidden", name: "order_id", value: this.orderId }), 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: salla.lang.get('pages.rating.write_product_rate') }), h("small", { class: "text-red-400 validation-message" }))))))))));
280
+ return (h("section", { class: "step rating-section products-section transition-all duration-500 opacity-0 translate-x-3 hidden", "data-type": "product", "data-step-name": "\u062A\u0642\u064A\u064A\u0645 \u0627\u0644\u0645\u0646\u062A\u062C\u0627\u062A" }, h("div", { class: "overflow-hidden" }, this.order.products.map((item, index) => h("div", { class: "rating-outer-form mb-8 last:mb-0", "data-stars-error": salla.lang.get('pages.rating.rate_product_stars', { "item": item.title }) }, h("div", { class: "product-item" }, h("div", { class: "flex space-s-5" }, 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 font-bold md:text-sm" }, " ", 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("input", { type: "hidden", name: "order_id", value: this.orderId }), 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: salla.lang.get('pages.rating.write_product_rate') }), h("small", { class: "text-red-400 validation-message" }))))))))));
281
281
  }
282
282
  renderShippingRating() {
283
- return (h("section", { class: "step rating-section py-5 rounded-md transition-all duration-500 opacity-0 translate-x-3 hidden", "data-type": "shipping" }, h("div", { class: "rating-outer-form", "data-stars-error": salla.lang.get('pages.rating.rate_shipping_stars') }, h("input", { type: "hidden", name: "order_id", value: this.orderId }), h("input", { type: "hidden", name: "shipping_company_id", value: this.order.shipping.id }), h("input", { type: "hidden", name: "type", value: "shipping" }), h("div", { class: "flex flex-col items-center " }, h("div", { class: "w-28 h-28 overflow-hidden border border-gray-200 rounded-full flex items-center justify-center mb-4" }, h("img", { src: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcScPt4R6KaKDldrXb-9pUljFwL3m6A72BhN6p1qZJKprwC6VbCWC_8ASZgiJAoL_l7DepM&usqp=CAU", alt: "company name", class: "w-full h-full object-contain" })), h("h2", { class: "section-title text-lg font-bold mb-4" }, " ", salla.lang.get('pages.rating.rate_shipping'), " \u0627\u0631\u0627\u0645\u0643\u0633")), h("div", { class: "rating-wrap flex flex justify-center mb-4" }, h("form", { class: "rate-element ratFeedbackPresentere-element--has-label" }, this.getStarsRating())), h("textarea", { id: "shippingReview", name: "comment", class: "form-input comment h-20 mb-2", placeholder: salla.lang.get('pages.rating.write_shipping_rate') }), h("small", { class: "text-red-400 validation-message" }))));
283
+ return (h("section", { class: "step rating-section py-5 rounded-md transition-all duration-500 opacity-0 translate-x-3 hidden", "data-type": "shipping", "data-step-name": "\u062A\u0642\u064A\u064A\u0645 \u0634\u0631\u0643\u0629 \u0627\u0644\u0634\u062D\u0646" }, h("div", { class: "rating-outer-form", "data-stars-error": salla.lang.get('pages.rating.rate_shipping_stars') }, h("input", { type: "hidden", name: "order_id", value: this.orderId }), h("input", { type: "hidden", name: "shipping_company_id", value: this.order.shipping.id }), h("input", { type: "hidden", name: "type", value: "shipping" }), h("div", { class: "flex flex-col items-center " }, h("div", { class: "w-28 h-28 overflow-hidden border border-gray-200 rounded-full flex items-center justify-center mb-4" }, h("img", { src: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcScPt4R6KaKDldrXb-9pUljFwL3m6A72BhN6p1qZJKprwC6VbCWC_8ASZgiJAoL_l7DepM&usqp=CAU", alt: "company name", class: "w-full h-full object-contain" })), h("h2", { class: "section-title text-lg font-bold mb-4" }, " ", salla.lang.get('pages.rating.rate_shipping'), " \u0627\u0631\u0627\u0645\u0643\u0633")), h("div", { class: "rating-wrap flex flex justify-center mb-4" }, h("form", { class: "rate-element ratFeedbackPresentere-element--has-label" }, this.getStarsRating())), h("textarea", { id: "shippingReview", name: "comment", class: "form-input comment h-20 mb-2", placeholder: salla.lang.get('pages.rating.write_shipping_rate') }), h("small", { class: "text-red-400 validation-message" }))));
284
284
  }
285
285
  renderThanksView() {
286
286
  return (h("div", { class: "thankyou-view px-8 text-center transition-all duration-500 opacity-0 translate-x-3 hidden" }, h("span", { class: "w-20 h-20 text-4xl inline-flex justify-center items-center bg-gray-50 rounded-full text-primary sicon-check-circle2" }), h("div", { class: "mt-4 mb-6" }, h("h3", { class: "font-bold" }, salla.lang.get('pages.rating.thanks')), h("div", { class: "text-gray-400 text-sm", innerHTML: this.thanksMsg })), h("a", { href: "#!", onClick: () => this.hide(), class: "btn btn-primary h-10 flex-none px-8" }, "\u0639\u0648\u062F\u0629 \u0625\u0644\u064A \u062A\u0641\u0627\u0635\u064A\u0644 \u0627\u0644\u0637\u0644\u0628"), h("time", { class: "close-time text-gray-400 block h-6 mt-3 text-sm" })));
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h, H as Host, g as getElement } from './index-643344dc.js';
1
+ import { r as registerInstance, h, e as Host, g as getElement } from './index-8cf58712.js';
2
2
 
3
3
  const SallaSearch = class {
4
4
  constructor(hostRef) {
@@ -0,0 +1,2 @@
1
+ export { S as salla_search } from './salla-search-df1c9b54.js';
2
+ import './index-8cf58712.js';
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h, g as getElement } from './index-643344dc.js';
1
+ import { r as registerInstance, h, g as getElement } from './index-8cf58712.js';
2
2
  import { H as Helper } from './Helper-81ac9a8c.js';
3
3
 
4
4
  const SallaVerify = class {