@salla.sa/twilight-components 1.0.14 → 1.0.16

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.
@@ -1,5 +1,5 @@
1
1
  const NAMESPACE = 'twilight-components';
2
- const BUILD = /* twilight-components */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: false, cmpDidRender: true, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: true, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: false, constructableCSS: false, cssAnnotations: true, cssVarShim: false, devTools: true, disconnectedCallback: false, dynamicImportShim: false, element: false, event: true, hasRenderFn: true, hostListener: false, hostListenerTarget: false, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: false, hotModuleReplacement: true, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, initializeNextTick: false, invisiblePrehydration: true, isDebug: false, isDev: true, isTesting: false, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: false, member: true, method: true, mode: false, observeAttribute: true, profile: true, prop: true, propBoolean: true, propMutable: true, propNumber: true, propString: true, reflect: true, safari10: false, scoped: false, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: false, shadowDomShim: false, slot: true, slotChildNodesFix: false, slotRelocation: true, state: true, style: true, svg: false, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: false, vdomKey: true, vdomListener: true, vdomPropOrAttr: true, vdomRef: true, vdomRender: true, vdomStyle: true, vdomText: true, vdomXlink: true, watchCallback: true };
2
+ const BUILD = /* twilight-components */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: true, cmpDidRender: true, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: true, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: false, constructableCSS: false, cssAnnotations: true, cssVarShim: false, devTools: true, disconnectedCallback: false, dynamicImportShim: false, element: false, event: true, hasRenderFn: true, hostListener: true, hostListenerTarget: false, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: false, hotModuleReplacement: true, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, initializeNextTick: false, invisiblePrehydration: true, isDebug: false, isDev: true, isTesting: false, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: false, member: true, method: true, mode: false, observeAttribute: true, profile: true, prop: true, propBoolean: true, propMutable: true, propNumber: true, propString: true, reflect: true, safari10: false, scoped: false, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: false, shadowDomShim: false, slot: true, slotChildNodesFix: false, slotRelocation: true, state: true, style: true, svg: false, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: false, vdomKey: true, vdomListener: true, vdomPropOrAttr: true, vdomRef: true, vdomRender: true, vdomStyle: true, vdomText: true, vdomXlink: true, watchCallback: true };
3
3
  const Env = /* twilight-components */ {};
4
4
 
5
5
  let scopeId;
@@ -1,3 +1,4 @@
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';
1
+ export { S as SallaLogin } from './salla-login-4d620368.js';
2
+ export { S as SallaSearch } from './salla-search-5338c0a1.js';
3
+ import './index-8966d27f.js';
4
+ import './Helper-81ac9a8c.js';
@@ -1,16 +1,15 @@
1
- import { r as registerInstance, h, g as getElement } from './index-8cf58712.js';
1
+ import { r as registerInstance, h, g as getElement } from './index-8966d27f.js';
2
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}";
3
+ const sallaBranchesCss = ":host{display:block}";
4
4
 
5
- // import Helper from "../../Helpers/Helper";
6
5
  let engine = require('store/src/store-engine');
7
6
  let storages = require('store/storages/sessionStorage');
8
7
  let sessionStore = engine.createStore(storages);
9
- const MultiWarehouse = class {
8
+ const SallaBranches = class {
10
9
  constructor(hostRef) {
11
10
  registerInstance(this, hostRef);
12
11
  this.open = false;
13
- this.isOpenedBefore = sessionStore.get("multi-warehouse-opened-before");
12
+ this.isOpenedBefore = sessionStore.get("branch-choosed-before");
14
13
  this.displayAs = 'default';
15
14
  this.browseProductsFrom = 'all';
16
15
  this.branches = [
@@ -53,28 +52,28 @@ const MultiWarehouse = class {
53
52
  this.btn.load().then(() => {
54
53
  setTimeout(() => location.reload(), 2000);
55
54
  });
56
- sessionStore.set("multi-warehouse-opened-before", true);
55
+ sessionStore.set("branch-choosed-before", true);
57
56
  this.show();
58
57
  setTimeout(() => {
59
58
  this.current = this.selected;
60
59
  }, 300);
61
60
  }
62
61
  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,
62
+ 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", "sub-title-first": true, "is-closable": !this.isOpenedBefore && this.displayAs == 'popup' ? 'false' : 'true', ref: modal => this.modal = modal, "modal-width": "w-116", id: "s-branches-modal", class: "hidden" }, h("fieldset", null, h("h4", { class: "s-branches-title" }, this.formTitle()), h("legend", { class: "s-branches-sr-only" }, this.formTitle()), this.branches.length <= 5 ?
63
+ h("div", { class: "s-branches-space-v" }, this.branches.map((branch) => h("div", { class: "s-branches-input-wrap" }, 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: {
64
+ 's-branches-input': true,
66
65
  'opacity-50': !branch.open,
67
66
  'hidden': !this.isChoiceable()
68
67
  }, 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 ? '' : 'مُغلق')
68
+ 's-branches-label': true,
69
+ 's-branches-clickable': this.isChoiceable()
70
+ } }, h("span", { class: { 's-branches-is-closed': !branch.open } }, branch.name), this.isChoiceable() ?
71
+ h("small", { class: "s-branches-closed-badge" }, branch.open ? '' : 'مُغلق')
73
72
  :
74
73
  h("span", { class: this.statusColor(branch) }, branch.tag)))))
75
74
  :
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'))))
75
+ h("select", { class: "s-branches-select", 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() ?
76
+ h("slot", { name: "footer" }, h("salla-button", { "loader-position": "before", ref: btn => this.btn = btn, onClick: () => this.handleSubmit(), class: "s-branches-submit" }, salla.lang.get('common.elements.ok')))
78
77
  : ''));
79
78
  }
80
79
  componentDidRender() {
@@ -84,6 +83,6 @@ const MultiWarehouse = class {
84
83
  }
85
84
  get host() { return getElement(this); }
86
85
  };
87
- MultiWarehouse.style = multiWarehouseCss;
86
+ SallaBranches.style = sallaBranchesCss;
88
87
 
89
- export { MultiWarehouse as multi_warehouse };
88
+ export { SallaBranches as salla_branches };
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h, g as getElement } from './index-8cf58712.js';
1
+ import { r as registerInstance, h, g as getElement } from './index-8966d27f.js';
2
2
  import { H as Helper } from './Helper-81ac9a8c.js';
3
3
 
4
4
  const sallaButtonCss = ":host{display:block}";
@@ -21,7 +21,7 @@ const SallaButton = class {
21
21
  + 'btn-' + this.btnStyle
22
22
  + (this.wide ? ' s-button-wide ' : '')
23
23
  + 'loader-' + this.loaderPosition
24
- + (this.loaderPosition == 'before' ? ' flex-row-reverse' : '');
24
+ + (this.loaderPosition == 'before' ? ' s-button-loader-after' : '');
25
25
  // if(this.hostAttributes.onclick){
26
26
  // this.hostAttributes.onclick=eval(this.hostAttributes.onclick);
27
27
  // }
@@ -33,7 +33,7 @@ const SallaButton = class {
33
33
  }
34
34
  async load() {
35
35
  if (this.loaderPosition == 'center')
36
- this.host.querySelector('.btn-text').classList.add('opacity-0');
36
+ this.host.querySelector('.s-button-text').classList.add('s-button-hide');
37
37
  this.host.setAttribute('loading', '');
38
38
  return this.host;
39
39
  }
@@ -55,11 +55,11 @@ const SallaButton = class {
55
55
  Helper.toggleElement(this.btn, 'btn--is-loading', 'btn--no-loading', () => newVal);
56
56
  }
57
57
  render() {
58
- 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: {
58
+ return (h("button", Object.assign({ ref: btn => this.btn = btn, disabled: this.disabled }, this.hostAttributes), h("span", { class: "s-button-text" }, h("slot", null)), this.loading ? h("span", { class: {
59
59
  'loader loader--small s-button-loader': true,
60
- 'absolute right-2': this.loaderPosition === 'start',
61
- 'absolute left-2': this.loaderPosition === 'end',
62
- 'absolute top-1/2 left-1/2 !-translate-x-1/2 !-translate-y-1/2 !m-0': this.loaderPosition === 'center',
60
+ 's-button-loader-start': this.loaderPosition === 'start',
61
+ 's-button-loader-end': this.loaderPosition === 'end',
62
+ 's-buton-loader-center': this.loaderPosition === 'center',
63
63
  } }) : ''));
64
64
  }
65
65
  get host() { return getElement(this); }
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h, g as getElement } from './index-8cf58712.js';
1
+ import { r as registerInstance, h, g as getElement } from './index-8966d27f.js';
2
2
  import { H as Helper } from './Helper-81ac9a8c.js';
3
3
 
4
4
  const SallaLocalization = class {
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h } from './index-8cf58712.js';
1
+ import { r as registerInstance, h } from './index-8966d27f.js';
2
2
 
3
3
  const SallaLogin = class {
4
4
  constructor(hostRef) {
@@ -1,2 +1,2 @@
1
- export { S as salla_login } from './salla-login-97e0a9ab.js';
2
- import './index-8cf58712.js';
1
+ export { S as salla_login } from './salla-login-4d620368.js';
2
+ import './index-8966d27f.js';
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, f as createEvent, h, e as Host, g as getElement } from './index-8cf58712.js';
1
+ import { r as registerInstance, f as createEvent, h, e as Host, g as getElement } from './index-8966d27f.js';
2
2
  import { H as Helper } from './Helper-81ac9a8c.js';
3
3
 
4
4
  const SallaModal = class {
@@ -6,17 +6,22 @@ const SallaModal = class {
6
6
  registerInstance(this, hostRef);
7
7
  this.ready = createEvent(this, "ready", 7);
8
8
  this.close = createEvent(this, "close", 7);
9
+ var _a;
9
10
  this.error = false;
10
11
  this.success = false;
11
12
  this.isClosable = true;
12
13
  this.modalWidth = 'w-96'; //todo use friendly names
13
14
  this.visible = false;
15
+ this.subTitleFirst = false;
14
16
  this.subTitle = '';
15
17
  this.icon = '';
18
+ this.imageIcon = '';
19
+ Helper.setHost(this.host);
16
20
  salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
17
21
  salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
18
22
  this.title = this.host.title;
19
23
  this.host.removeAttribute('title');
24
+ (_a = Helper.getElement('[slot=body]')) === null || _a === void 0 ? void 0 : _a.classList.add('s-modal-body');
20
25
  }
21
26
  handleVisible(newValue) {
22
27
  if (!newValue) {
@@ -41,11 +46,9 @@ const SallaModal = class {
41
46
  return this.host;
42
47
  }
43
48
  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
+ Helper.toggleElement(this.host.querySelector('.s-modal-body'), 's-modal-entering', 's-modal-leaving', () => isOpen)
50
+ .toggleElement(this.host.querySelector('[slot=body]'), 's-modal-entering', 's-modal-leaving', () => isOpen)
51
+ .toggleElement(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
49
52
  .toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
50
53
  if (!isOpen) {
51
54
  setTimeout(() => this.host.classList.add('hidden'), 350);
@@ -60,8 +63,7 @@ const SallaModal = class {
60
63
  //todo:: pref for each modal
61
64
  render() {
62
65
  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 ?
66
+ 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", ref: el => this.overlay = el, onClick: () => this.closeModal() }), h("span", { class: "s-modal-spacer" }, "\u200B"), h("slot", { name: "body" }, h("div", { class: 's-modal-body ' + this.modalWidth }, h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.icon != '' || this.imageIcon != '' } }, this.isClosable ?
65
67
  h("button", { class: "s-modal-close cursor-pointer", onClick: () => this.closeModal(), type: "button" }, h("span", { class: "sicon-cancel" }))
66
68
  : '', this.error || this.success || this.icon
67
69
  ? h("div", { class: {
@@ -74,7 +76,11 @@ const SallaModal = class {
74
76
  's-modal-text-error': this.error,
75
77
  's-modal-text-success': this.success,
76
78
  } }))
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" })))));
79
+ : this.imageIcon ?
80
+ h("img", { class: "s-modal-header-img", src: this.imageIcon })
81
+ : '', this.title || this.subTitle ?
82
+ h("div", { class: "s-modal-header-content" }, h("div", { class: { 's-modal-title': true, 's-modal-title-below': this.subTitleFirst }, innerHTML: this.title }), h("p", { class: { 's-modal-sub-title': true }, innerHTML: this.subTitle }))
83
+ : ''), h("slot", null), h("slot", { name: "footer" }))))));
78
84
  }
79
85
  get host() { return getElement(this); }
80
86
  static get watchers() { return {
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h, e as Host, g as getElement } from './index-8cf58712.js';
1
+ import { r as registerInstance, h, e as Host, g as getElement } from './index-8966d27f.js';
2
2
  import { H as Helper } from './Helper-81ac9a8c.js';
3
3
 
4
4
  const SallaProductAvailability = class {
@@ -1,12 +1,11 @@
1
- import { r as registerInstance, h, e as Host, g as getElement } from './index-8cf58712.js';
1
+ import { r as registerInstance, h, e as Host, g as getElement } from './index-8966d27f.js';
2
2
  import { H as Helper } from './Helper-81ac9a8c.js';
3
3
 
4
- const sallaRatingCss = ":host{display:block}";
4
+ const sallaRatingCss = ":host{display:block}.unicode{unicode-bidi:plaintext}";
5
5
 
6
6
  const SallaRating = class {
7
7
  constructor(hostRef) {
8
8
  registerInstance(this, hostRef);
9
- this.stars = [1, 2, 3, 4, 5];
10
9
  this.order = {
11
10
  shipping: { id: 5622 },
12
11
  products: [
@@ -21,17 +20,17 @@ const SallaRating = class {
21
20
  "id": "2314513454",
22
21
  "getOptimusRouteKey": "7351233357"
23
22
  },
24
- // {
25
- // "title": "وحدة تحكم لمشغل العاب",
26
- // "image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/NOa4kHvOkd1hBWHk3JIgAo1602oVACfuWGFz3vXv.jpg",
27
- // "price": "‏10,978.00 ر.س",
28
- // "qty": "‏2",
29
- // "totalBefore": "‏1120 ر.س",
30
- // "discount": "-5%",
31
- // "total": "‏1064 ر.س",
32
- // "id": "9842833",
33
- // "getOptimusRouteKey": "735152357"
34
- // },
23
+ {
24
+ "title": "ميكروفون عالى الجودة",
25
+ "image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/pMdEEyMVpZFj4L1Hrdm2g48AuiSx0TrKULBiOnPo.jpg",
26
+ "price": "‏10,978.00 ر.س",
27
+ "qty": "‏2",
28
+ "totalBefore": "‏1120 ر.س",
29
+ "discount": "-5%",
30
+ "total": "‏1064 ر.س",
31
+ "id": "2314513454",
32
+ "getOptimusRouteKey": "7351233357"
33
+ },
35
34
  {
36
35
  "title": "ساعة ذكية بنظام اندرويد",
37
36
  "image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/T4kTqYNuPAZmPMLw1bx92RnjVMZyFszVXOUZQsFJ.jpg",
@@ -44,8 +43,9 @@ const SallaRating = class {
44
43
  "getOptimusRouteKey": "73233357"
45
44
  }
46
45
  ],
46
+ storeLogo: "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/X3NKcY7nhaFQlR7kBBHvfDpMY48cerunKrmDA1gi.png",
47
+ shippingLogo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcScPt4R6KaKDldrXb-9pUljFwL3m6A72BhN6p1qZJKprwC6VbCWC_8ASZgiJAoL_l7DepM&usqp=CAU"
47
48
  };
48
- this.isProductsRating = false;
49
49
  this.ratingChain = Promise.resolve();
50
50
  this.stepsCount = 0;
51
51
  Helper.setHost(this.host);
@@ -58,52 +58,57 @@ const SallaRating = class {
58
58
  }
59
59
  componentWillLoad() {
60
60
  this.stepsCount = [this.isStoreRating, this.isProductsRating, this.isShippingRating].filter(item => item).length;
61
- this.getData();
61
+ // this.getData();
62
62
  }
63
63
  componentDidRender() {
64
64
  this.show();
65
65
  this.initiateRating();
66
66
  }
67
67
  initiateRating() {
68
- this.highlightSelectedStars();
69
68
  this.starsRating();
69
+ this.highlightSelectedStars();
70
70
  this.handleWizard();
71
- const step = this.host.querySelector('.step:first-child');
72
- this.setModalHeight(step);
73
71
  salla.event.on('submit::order-rating', () => this.sendRating().then(() => {
74
72
  let seconds = 10;
75
73
  let timeToClose = setInterval(() => {
76
74
  seconds--;
77
- this.host.querySelector('.close-time').innerHTML = `00:0${seconds}`;
75
+ this.host.querySelector('.s-rating-thanks-time').innerHTML = `00:0${seconds}`;
78
76
  if (seconds == 0) {
79
- this.hide();
77
+ // this.hide();
80
78
  clearInterval(timeToClose);
81
79
  }
82
80
  }, 1000);
83
- this.host.querySelector('.wizard-footer').classList.add('opacity-0', 'pointer-events-0');
84
- Helper.toggle('.step', 'hidden', 'block', () => true);
85
- Helper.toggle('.thankyou-view', 'is-opened', 'hidden', () => true);
86
- const thankYouView = this.host.querySelector('.thankyou-view');
81
+ this.host.querySelector('.s-rating-footer').classList.add('s-rating-unvisiable');
82
+ Helper.toggle('.s-rating-step', 's-rating-hidden', 's-rating-active', () => true);
83
+ Helper.toggle('.s-rating-thanks', 's-rating-unactive', 's-rating-hidden', () => true);
84
+ const thankYouView = this.host.querySelector('.s-rating-thanks');
87
85
  this.setModalHeight(thankYouView);
88
86
  setTimeout(() => {
89
- Helper.toggleElement(thankYouView, ['opacity-1', 'translate-x-0'], ['opacity-0', 'translate-x-3'], () => true);
87
+ Helper.toggleElement(thankYouView, 's-rating-active', 's-rating-unactive', () => true);
90
88
  }, 200);
91
89
  }));
92
90
  }
91
+ // getdata
92
+ getData() {
93
+ salla.api.order.endpointsMethods.details = 'get';
94
+ salla.order.api.details(salla.config.page.id).then(data => console.log(''));
95
+ }
93
96
  // handle wizard
94
97
  handleWizard() {
95
- let index = 0, steps = document.querySelectorAll(".step"), dots = document.querySelectorAll(".step-dot");
96
- // show first step
98
+ var _a;
99
+ let index = 0, steps = this.host.querySelectorAll(".s-rating-step"), dots = this.host.querySelectorAll(".s-rating-step-dot"), nextBtnText = this.host.querySelector('#next-btn .btn-text');
100
+ this.setModalHeight(steps[0]);
97
101
  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
102
+ nextBtnText.innerHTML = ((_a = steps[index + 1]) === null || _a === void 0 ? void 0 : _a.dataset.stepName) || 'إرسال التقييم';
101
103
  Helper.onClick("#prev-btn", () => {
104
+ var _a;
102
105
  index > 0 && index--;
103
106
  this.showActiveStep(steps, dots, index);
104
- index == 0 && Helper.toggle('#prev-btn', ['pointer-events-none', 'opacity-0'], 'block', () => true);
107
+ nextBtnText.innerHTML = ((_a = steps[index + 1]) === null || _a === void 0 ? void 0 : _a.dataset.stepName) || 'إرسال التقييم';
108
+ index == 0 && Helper.toggle('#prev-btn', 's-rating-unvisiable', 'block', () => true);
105
109
  });
106
110
  Helper.onClick("#next-btn", () => {
111
+ var _a;
107
112
  this.ratingValidation();
108
113
  if (index == this.stepsCount - 1) {
109
114
  salla.event.dispatch("submit::order-rating");
@@ -111,33 +116,94 @@ const SallaRating = class {
111
116
  else {
112
117
  index < this.stepsCount - 1 && index++;
113
118
  this.showActiveStep(steps, dots, index);
114
- Helper.toggle('#prev-btn', 'block', ['pointer-events-none', 'opacity-0'], () => true);
119
+ nextBtnText.innerHTML = ((_a = steps[index + 1]) === null || _a === void 0 ? void 0 : _a.dataset.stepName) || 'إرسال التقييم';
120
+ Helper.toggle('#prev-btn', 'block', 's-rating-unvisiable', () => true);
115
121
  }
116
122
  });
117
123
  }
118
124
  showActiveStep(steps, dots, currentIndex) {
119
- Helper.toggle('.step-dot', 'bg-gray-200', 'bg-primay', () => true);
125
+ Helper.toggle('.s-rating-step-dot', 'bg-gray-200', 'bg-primay', () => true);
120
126
  this.stepsCount > 1 && Helper.toggleElement(dots[currentIndex], 'bg-primary', 'bg-gray-200', () => true);
121
127
  // hide all steps
122
- Helper.toggle('.step', ['hidden', 'opacity-0', 'translate-x-3'], ['active', 'opacity-1', 'translate-x-0'], () => true);
123
- Helper.toggleElement(steps[currentIndex], 'active', 'hidden', () => true);
128
+ Helper.toggle('.s-rating-step', 's-rating-hidden', 's-rating-active', () => true);
129
+ Helper.toggleElement(steps[currentIndex], 'block', 's-rating-hidden', () => true); // remove class s-rating-hidde
124
130
  this.setModalHeight(steps[currentIndex]);
125
131
  setTimeout(() => {
126
- Helper.toggleElement(steps[currentIndex], ['opacity-1', 'translate-x-0'], ['opacity-0', 'translate-x-3',], () => true);
132
+ Helper.toggleElement(steps[currentIndex], 's-rating-active', 's-rating-unactive', () => true);
127
133
  }, 200);
128
134
  }
129
135
  setModalHeight(current) {
130
- const wrapper = this.host.querySelector('.s-order-rating-steps-wrapper');
136
+ const wrapper = this.host.querySelector('.s-rating-wrapper');
131
137
  setTimeout(() => {
132
138
  wrapper === null || wrapper === void 0 ? void 0 : wrapper.setAttribute('style', 'height:' + (current === null || current === void 0 ? void 0 : current.scrollHeight) + 'px');
133
139
  });
134
140
  }
141
+ // handle star rating
142
+ starsRating() {
143
+ let selectedClasses = ['selected', 'text-theme-yellow'];
144
+ // Listen for form submissions
145
+ salla.document.event.onSubmit('.s-rating-stars-element', function (event) {
146
+ // Prevent form from submitting
147
+ event.preventDefault();
148
+ // Get the selected star - activeElement is not supported in safari
149
+ var activeStars = event.target.querySelectorAll('.btn--star.hovered');
150
+ var selected = activeStars[activeStars.length - 1];
151
+ if (!selected)
152
+ return;
153
+ var selectedIndex = parseInt(selected.dataset.star, 10);
154
+ event.target.querySelector('.rating_hidden_input').value = selectedIndex;
155
+ // Get all stars in this form (only search in the form, not the whole document)
156
+ // Loop through each star, and add or remove the `.selected` class to toggle highlighting
157
+ event.target
158
+ .querySelectorAll('.btn--star')
159
+ .forEach(function (star, index) {
160
+ if (index < selectedIndex) {
161
+ // Selected star or before it, Add highlighting
162
+ star.classList.add(...selectedClasses);
163
+ return;
164
+ }
165
+ // After selected star, Remove highlight
166
+ star.classList.remove(...selectedClasses);
167
+ });
168
+ // Remove aria-pressed from any previously selected star
169
+ var previousRating = event.target.querySelector('.star[aria-pressed="true"]');
170
+ if (previousRating) {
171
+ previousRating.removeAttribute('aria-pressed');
172
+ }
173
+ // Add aria-pressed role to the selected button
174
+ selected.setAttribute('aria-pressed', true);
175
+ });
176
+ }
177
+ highlightSelectedStars() {
178
+ let hover = ['hovered', 'text-theme-yellow'];
179
+ Helper.all('.s-rating-stars-element', el => {
180
+ let starElements = el.querySelectorAll('.btn--star');
181
+ // remove hovered state from stars ---
182
+ el.addEventListener('mouseout', () => el.querySelectorAll('.btn--star').forEach(star => star.classList.remove(...hover)));
183
+ starElements.forEach((starElement, index) => {
184
+ starElement.addEventListener('mouseover', () => {
185
+ starElement.classList.add(...hover);
186
+ if (index <= 1) {
187
+ starElement.previousElementSibling.tagName === 'BUTTON' ? starElement.previousElementSibling.classList.add(...hover) : null;
188
+ }
189
+ else {
190
+ for (let i = 0; i < index; i++) {
191
+ starElements[i].classList.add(...hover);
192
+ }
193
+ }
194
+ });
195
+ starElement.addEventListener('mouseout', () => {
196
+ starElement.classList.contains(...hover) ? starElement.classList.remove(...hover) : null;
197
+ });
198
+ });
199
+ });
200
+ }
135
201
  // send feedback rating and validation
136
202
  sendRating() {
137
- Helper.all('.rating-section', ratingSection => {
138
- let type = ratingSection.dataset.type;
203
+ Helper.all('.s-rating-step', ratingStep => {
204
+ let type = ratingStep.dataset.type;
139
205
  let formsData = [];
140
- ratingSection.querySelectorAll('.rating-outer-form')
206
+ ratingStep.querySelectorAll('.rating-outer-form')
141
207
  .forEach((form) => {
142
208
  let formData = {};
143
209
  form.querySelectorAll('[name]')
@@ -165,17 +231,15 @@ const SallaRating = class {
165
231
  }
166
232
  ratingValidation() {
167
233
  let errorMsg = '';
168
- document.querySelectorAll('.rating-section.active')
234
+ document.querySelectorAll('.s-rating-step.s-rating-active')
169
235
  .forEach((ratingSection) => {
170
236
  ratingSection.querySelectorAll('.rating-outer-form')
171
237
  .forEach((rating) => {
172
238
  let ratingInput = rating.querySelector('.rating_hidden_input');
173
- let commentInput = rating.querySelector('.comment');
174
- // let sectionTitle = rating.querySelector('.section-title');
175
- let validationMessage = rating.querySelector('.validation-message');
239
+ let commentInput = rating.querySelector('.s-rating-comment');
240
+ let validationMessage = rating.querySelector('.s-rating-validation-msg');
176
241
  if (ratingInput.value && commentInput.value && commentInput.value.length > 3) {
177
242
  commentInput.classList.remove('has-error');
178
- // sectionTitle?.classList.remove('has-error', 'text-red-400');
179
243
  validationMessage.innerHTML = '';
180
244
  return;
181
245
  }
@@ -185,14 +249,13 @@ const SallaRating = class {
185
249
  else {
186
250
  commentInput.classList.add('has-error');
187
251
  }
188
- // sectionTitle?.classList.add('has-error', 'text-red-400');
189
252
  errorMsg = ratingInput.value
190
253
  ? (salla.lang.get('common.errors.not_less_than_chars', { chars: 4 }) + ' ' + commentInput.getAttribute('placeholder'))
191
254
  : (rating.dataset.starsError || salla.lang.get('pages.rating.rate_store_stars'));
192
255
  validationMessage.innerHTML = errorMsg;
193
256
  });
194
257
  });
195
- //Fire error to prevent sending rating
258
+ //Fire error to prevent going to next step
196
259
  if (errorMsg) {
197
260
  // scroll to first error
198
261
  let ratingErrors = document.querySelectorAll('.has-error');
@@ -203,90 +266,25 @@ const SallaRating = class {
203
266
  throw new Error(errorMsg);
204
267
  }
205
268
  }
206
- // getdata
207
- getData() {
208
- salla.api.order.endpointsMethods.details = 'get';
209
- salla.order.api.details(salla.config.page.id).then(data => console.log(''));
210
- }
211
- // handle star rating
212
- starsRating() {
213
- let selectedClasses = ['selected', 'text-theme-yellow'];
214
- // Listen for form submissions
215
- salla.document.event.onSubmit('.rate-element', function (event) {
216
- // Prevent form from submitting
217
- event.preventDefault();
218
- // Get the selected star - activeElement is not supported in safari
219
- var activeStars = event.target.querySelectorAll('.btn--star.hovered');
220
- var selected = activeStars[activeStars.length - 1];
221
- if (!selected)
222
- return;
223
- var selectedIndex = parseInt(selected.dataset.star, 10);
224
- event.target.querySelector('.rating_hidden_input').value = selectedIndex;
225
- // Get all stars in this form (only search in the form, not the whole document)
226
- // Loop through each star, and add or remove the `.selected` class to toggle highlighting
227
- event.target
228
- .querySelectorAll('.btn--star')
229
- .forEach(function (star, index) {
230
- if (index < selectedIndex) {
231
- // Selected star or before it, Add highlighting
232
- star.classList.add(...selectedClasses);
233
- return;
234
- }
235
- // After selected star, Remove highlight
236
- star.classList.remove(...selectedClasses);
237
- });
238
- // Remove aria-pressed from any previously selected star
239
- var previousRating = event.target.querySelector('.star[aria-pressed="true"]');
240
- if (previousRating) {
241
- previousRating.removeAttribute('aria-pressed');
242
- }
243
- // Add aria-pressed role to the selected button
244
- selected.setAttribute('aria-pressed', true);
245
- });
246
- }
247
- highlightSelectedStars() {
248
- let hover = ['hovered', 'text-theme-yellow'];
249
- Helper.all('.rate-element', el => {
250
- let starElements = el.querySelectorAll('.btn--star');
251
- // remove hovered state from stars ---
252
- el.addEventListener('mouseout', () => el.querySelectorAll('.btn--star').forEach(star => star.classList.remove(...hover)));
253
- starElements.forEach((starElement, index) => {
254
- starElement.addEventListener('mouseover', () => {
255
- starElement.classList.add(...hover);
256
- if (index <= 1) {
257
- starElement.previousElementSibling.tagName === 'BUTTON' ? starElement.previousElementSibling.classList.add(...hover) : null;
258
- }
259
- else {
260
- for (let i = 0; i < index; i++) {
261
- starElements[i].classList.add(...hover);
262
- }
263
- }
264
- });
265
- starElement.addEventListener('mouseout', () => {
266
- starElement.classList.contains(...hover) ? starElement.classList.remove(...hover) : null;
267
- });
268
- });
269
- });
270
- }
271
269
  // render
272
270
  render() {
273
- return (h(Host, null, h("salla-modal", { class: "hidden", "modal-width": "w-[800px]", ref: modal => this.modal = modal, title: salla.lang.get('pages.rating.rate_order') + ' <span class="unicode">(#' + this.orderId + ')</span>' }, h("div", { class: "s-order-rating-steps-wrapper mt-12 mb-10 transition-all duration-300 ease-elastic" }, this.isStoreRating && this.renderStoreRating(), this.isProductsRating && this.renderProductsRating(), this.isShippingRating && this.renderShippingRating(), this.renderThanksView()), h("div", { class: "wizard-footer relative flex justify-between items-center" }, h("button", { id: "prev-btn", class: "font-bold text-sm w-28 h-10 px-4 text-primary hover:text-primary-d opacity-0 pointer-events-none duration-300 transition-all" }, "\u0627\u0644\u0633\u0627\u0628\u0642"), this.stepsCount > 1 ?
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")))));
271
+ return (h(Host, null, h("salla-modal", { class: "hidden", "modal-width": "w-[800px]", ref: modal => this.modal = modal, title: salla.lang.get('pages.rating.rate_order') + ' <span class="unicode">(#' + this.orderId + ')</span>' }, h("div", { class: "s-rating-wrapper " }, this.isStoreRating && this.renderStoreRating(), this.isProductsRating && this.renderProductsRating(), this.isShippingRating && this.renderShippingRating(), this.renderThanksView()), h("div", { class: "s-rating-footer" }, h("button", { id: "prev-btn", class: "s-rating-btn s-rating-unvisiable" }, "\u0627\u0644\u0633\u0627\u0628\u0642"), this.stepsCount > 1 ?
272
+ h("ul", { class: "s-rating-dots" }, [0, 1, 2].slice(0, this.stepsCount).map(index => h("li", { class: `${index == 0 ? 'bg-primary' : 'bg-gray-200'} s-rating-step-dot` }))) : '', h("salla-button", { id: "next-btn", class: "w-28", ref: nextBtn => this.nextBtn = nextBtn }, "\u0627\u0644\u062A\u0627\u0644\u064A")))));
275
273
  }
276
274
  renderStoreRating() {
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
- }
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", "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" }))))))))));
275
+ return (h("section", { class: "s-rating-step", "data-type": "store", "data-step-name": "\u062A\u0642\u064A\u064A\u0645 \u0627\u0644\u0645\u062A\u062C\u0631" }, h("div", { class: "rating-outer-form s-rating-step-wrap", "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: "s-rating-rounded-icon" }, h("img", { src: this.order.storeLogo, alt: "store name", class: "s-rating-store-logo" })), h("h2", { class: "s-rating-title" }, salla.lang.get('pages.rating.rate_the_store')), this.getStarsRating(), h("textarea", { id: "storeReview", name: "comment", class: "s-rating-comment", placeholder: salla.lang.get('pages.rating.write_store_rate') }), h("small", { class: "s-rating-validation-msg" }))));
281
276
  }
282
277
  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", "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" }))));
278
+ return (h("section", { class: "s-rating-step", "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 s-rating-step-wrap", "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: "s-rating-rounded-icon" }, h("img", { src: this.order.shippingLogo, alt: "company name", class: "s-rating-shipping-logo" })), h("h2", { class: "s-rating-title" }, " ", salla.lang.get('pages.rating.rate_shipping'), " \u0627\u0631\u0627\u0645\u0643\u0633"), this.getStarsRating(), h("textarea", { id: "shippingReview", name: "comment", class: "s-rating-comment", placeholder: salla.lang.get('pages.rating.write_shipping_rate') }), h("small", { class: "s-rating-validation-msg" }))));
279
+ }
280
+ renderProductsRating() {
281
+ return (h("section", { class: "s-rating-step", "data-type": "product", "data-step-name": "\u062A\u0642\u064A\u064A\u0645 \u0627\u0644\u0645\u0646\u062A\u062C\u0627\u062A" }, this.order.products.map((item, index) => h("div", { class: "rating-outer-form s-rating-product", "data-stars-error": salla.lang.get('pages.rating.rate_product_stars', { "item": item.title }) }, h("img", { src: item.image, alt: item.title, class: "s-rating-product-img" }), h("div", { class: "flex-1" }, h("h3", { class: "s-rating-product-title" }, " ", item.title), 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: "s-rating-comment", placeholder: salla.lang.get('pages.rating.write_product_rate') }), h("small", { class: "s-rating-validation-msg" }))))));
284
282
  }
285
283
  renderThanksView() {
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" })));
284
+ return (h("div", { class: "s-rating-thanks s-rating-hidden" }, h("span", { class: "s-rating-thanks-icon sicon-check-circle2" }), h("h3", { class: "s-rating-thanks-title" }, salla.lang.get('pages.rating.thanks')), h("div", { class: "s-rating-thanks-msg", innerHTML: this.thanksMsg }), h("a", { href: "#!", onClick: () => this.hide(), class: "s-rating-thanks-btn" }, "\u0639\u0648\u062F\u0629 \u0625\u0644\u064A \u062A\u0641\u0627\u0635\u064A\u0644 \u0627\u0644\u0637\u0644\u0628"), h("time", { class: "s-rating-thanks-time" })));
287
285
  }
288
286
  getStarsRating() {
289
- 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-2xl text-gray-400 btn--star", "data-star": star }, h("i", { class: "sicon-star2" })))));
287
+ return (h("form", { class: "s-rating-stars-element" }, h("div", { class: "mb-1" }, h("input", { type: "hidden", class: "rating_hidden_input", name: "rating", value: "" }), [1, 2, 3, 4, 5].map((star) => h("button", { type: "submit", class: "btn btn--transparent px-1 text-2xl text-gray-400 btn--star", "data-star": star }, h("i", { class: "sicon-star2" }))))));
290
288
  }
291
289
  get host() { return getElement(this); }
292
290
  };
@@ -0,0 +1,79 @@
1
+ import { r as registerInstance, h, e as Host, g as getElement } from './index-8966d27f.js';
2
+ import { H as Helper } from './Helper-81ac9a8c.js';
3
+
4
+ const SallaSearch = class {
5
+ constructor(hostRef) {
6
+ registerInstance(this, hostRef);
7
+ var _a, _b;
8
+ this.results = [];
9
+ /**
10
+ * Override search placeholder.
11
+ */
12
+ this.placeholder = salla.lang.get('blocks.header.search_placeholder');
13
+ /**
14
+ * Override no results error message.
15
+ */
16
+ this.noResultsText = salla.lang.get('common.elements.no_options');
17
+ Helper.setHost(this.host);
18
+ this.buttonSlot = ((_a = Helper.getElement('[slot="button"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '<i class="sicon-search"></i>';
19
+ this.productSlot = ((_b = Helper.getElement('[slot="product"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || this.getDefaultProductSlot();
20
+ }
21
+ onModalClose() {
22
+ Helper.getElement('.s-search-input').value = '';
23
+ this.results = [];
24
+ this.afterSearching();
25
+ }
26
+ getDefaultProductSlot() {
27
+ return '<a target="_blank" href={url} class="s-search-product-image-container">' +
28
+ ' <img class="s-search-product-image" src="{image}" alt="{name}"/>' +
29
+ '</a>' +
30
+ '<div class="s-search-product-details">' +
31
+ ' <div class="s-search-product-name">{name}</div> <div class="s-search-product-price">{price}</div>' +
32
+ '</div>';
33
+ }
34
+ //todo:: reset data when closing
35
+ search(e) {
36
+ Helper.hideElement(this.noResults);
37
+ if (e.target.value.length === 0) {
38
+ this.results = [];
39
+ this.afterSearching();
40
+ return;
41
+ }
42
+ if (e.target.value.length <= 2) {
43
+ return;
44
+ }
45
+ //run loading spinner or stop it
46
+ Helper.toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => true);
47
+ salla.search.api.search(e.target.value)
48
+ .then(response => this.results = response.results)
49
+ .catch(err => err !== 'Query Same As Previous!' ? this.results = [] : null)
50
+ .finally(() => this.afterSearching(/*isEmpty*/ false));
51
+ }
52
+ afterSearching(isEmpty = true) {
53
+ this.noResults.style.display = isEmpty || this.results.length > 0 ? 'none' : 'block';
54
+ Helper.toggleElement(this.container, 's-search-container-open', 'no-results', () => this.results.length)
55
+ .toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => false); //stop searching anime
56
+ salla.search.api.previousQuery = ''; //avoid having error 'Query Same As Previous' after reopen modal;
57
+ }
58
+ render() {
59
+ var _a;
60
+ return (h(Host, { class: "s-search" }, h("button", { onClick: () => this.modal.show(), class: "s-search-button", innerHTML: this.buttonSlot }), h("salla-modal", { ref: modal => this.modal = modal }, h("div", { class: "s-search-container", slot: "body", ref: container => this.container = container }, h("input", { class: "s-search-input", type: "text", placeholder: this.placeholder, onInput: e => this.search(e) }), h("span", { class: "s-search-icon" }, h("i", { class: "sicon-search", ref: el => this.searchIcon = el })), h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
61
+ _a.map(item => {
62
+ var _a;
63
+ return h("div", { class: "s-search-product", innerHTML: this.productSlot
64
+ .replace(/\{name\}/g, item.title)
65
+ .replace(/\{price\}/g, (_a = item.price) === null || _a === void 0 ? void 0 : _a.after) //todo:: get discounted price too
66
+ .replace(/\{url\}/g, item.url)
67
+ .replace(/\{image\}/g, item.thumb) });
68
+ }), h("p", { ref: el => this.noResults = el, class: "s-search-no-results" }, this.noResultsText))))));
69
+ }
70
+ /**
71
+ * Run it one time after load
72
+ */
73
+ componentDidLoad() {
74
+ this.afterSearching();
75
+ }
76
+ get host() { return getElement(this); }
77
+ };
78
+
79
+ export { SallaSearch as S };
@@ -1,2 +1,3 @@
1
- export { S as salla_search } from './salla-search-df1c9b54.js';
2
- import './index-8cf58712.js';
1
+ export { S as salla_search } from './salla-search-5338c0a1.js';
2
+ import './index-8966d27f.js';
3
+ import './Helper-81ac9a8c.js';
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h, g as getElement } from './index-8cf58712.js';
1
+ import { r as registerInstance, h, g as getElement } from './index-8966d27f.js';
2
2
  import { H as Helper } from './Helper-81ac9a8c.js';
3
3
 
4
4
  const SallaVerify = class {
@@ -1,4 +1,4 @@
1
- import { B as BUILD, c as consoleDevInfo, p as plt, w as win, H, d as doc, N as NAMESPACE, a as promiseResolve, b as bootstrapLazy } from './index-8cf58712.js';
1
+ import { B as BUILD, c as consoleDevInfo, p as plt, w as win, H, d as doc, N as NAMESPACE, a as promiseResolve, b as bootstrapLazy } from './index-8966d27f.js';
2
2
  import { g as globalScripts } from './app-globals-0f993ce5.js';
3
3
 
4
4
  /*
@@ -121,5 +121,5 @@ const patchCloneNodeFix = (HTMLElementPrototype) => {
121
121
 
122
122
  patchBrowser().then(options => {
123
123
  globalScripts();
124
- return bootstrapLazy([["salla-button",[[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"disable":[64],"enable":[64]}]]],["salla-modal",[[4,"salla-modal",{"error":[4],"success":[4],"isClosable":[1028,"is-closable"],"modalWidth":[513,"modal-width"],"visible":[516],"subTitle":[1,"sub-title"],"icon":[1],"show":[64],"hide":[64],"setTitle":[64]}]]],["multi-warehouse",[[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]}]]],["salla-localization",[[4,"salla-localization",{"languagesTitle":[1,"languages-title"],"currenciesTitle":[1,"currencies-title"],"ok":[1],"show":[64],"hide":[64],"submit":[64]}]]],["salla-product-availability",[[4,"salla-product-availability",{"channels":[1],"buttonText":[1,"button-text"],"countryCode":[1,"country-code"],"subscribeText":[1,"subscribe-text"],"cancelText":[1,"cancel-text"],"subTitle":[1,"sub-title"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"mobilePlaceholder":[1,"mobile-placeholder"],"emailPlaceholder":[1,"email-placeholder"],"productId":[2,"product-id"],"subscribedMessage":[1,"subscribed-message"],"isSubscribed":[1028,"is-subscribed"],"submit":[64]}]]],["salla-rating",[[0,"salla-rating",{"orderId":[2,"order-id"],"thanksMsg":[1,"thanks-msg"],"isStoreRating":[4,"is-store-rating"],"isProductsRating":[4,"is-products-rating"],"isShippingRating":[4,"is-shipping-rating"],"show":[64],"hide":[64]}]]],["salla-verify",[[0,"salla-verify"]]],["salla-login",[[0,"salla-login"]]],["salla-search",[[4,"salla-search",{"searchPlaceholder":[1,"search-placeholder"],"noResultsText":[1,"no-results-text"],"searchTerm":[32],"results":[32],"fetchStatus":[32],"showResult":[32],"showModal":[32]}]]]], options);
124
+ return bootstrapLazy([["salla-button",[[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"disable":[64],"enable":[64]}]]],["salla-modal",[[4,"salla-modal",{"error":[4],"success":[4],"isClosable":[1028,"is-closable"],"modalWidth":[513,"modal-width"],"visible":[516],"subTitleFirst":[4,"sub-title-first"],"subTitle":[1,"sub-title"],"icon":[1],"imageIcon":[1,"image-icon"],"show":[64],"hide":[64],"setTitle":[64]}]]],["salla-branches",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization",[[4,"salla-localization",{"languagesTitle":[1,"languages-title"],"currenciesTitle":[1,"currencies-title"],"ok":[1],"show":[64],"hide":[64],"submit":[64]}]]],["salla-product-availability",[[4,"salla-product-availability",{"channels":[1],"buttonText":[1,"button-text"],"countryCode":[1,"country-code"],"subscribeText":[1,"subscribe-text"],"cancelText":[1,"cancel-text"],"subTitle":[1,"sub-title"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"mobilePlaceholder":[1,"mobile-placeholder"],"emailPlaceholder":[1,"email-placeholder"],"productId":[2,"product-id"],"subscribedMessage":[1,"subscribed-message"],"isSubscribed":[1028,"is-subscribed"],"submit":[64]}]]],["salla-rating",[[0,"salla-rating",{"orderId":[2,"order-id"],"thanksMsg":[1,"thanks-msg"],"isStoreRating":[4,"is-store-rating"],"isProductsRating":[4,"is-products-rating"],"isShippingRating":[4,"is-shipping-rating"],"show":[64],"hide":[64]}]]],["salla-verify",[[0,"salla-verify"]]],["salla-login",[[0,"salla-login"]]],["salla-search",[[0,"salla-search",{"placeholder":[1],"noResultsText":[1,"no-results-text"],"results":[32]},[[0,"close","onModalClose"]]]]]], options);
125
125
  });
@@ -1,4 +1,4 @@
1
- export declare class MultiWarehouse {
1
+ export declare class SallaBranches {
2
2
  open: boolean;
3
3
  selected: number;
4
4
  isOpenedBefore: string;
@@ -6,9 +6,12 @@ export declare class SallaModal {
6
6
  isClosable: boolean;
7
7
  modalWidth: string;
8
8
  visible: boolean;
9
+ subTitleFirst: boolean;
9
10
  subTitle: string;
10
11
  icon: string;
12
+ imageIcon: string;
11
13
  private title;
14
+ private overlay;
12
15
  host: HTMLElement;
13
16
  ready: EventEmitter;
14
17
  close: EventEmitter;
@@ -1,7 +1,5 @@
1
1
  export declare class SallaRating {
2
- nextBtn: HTMLSallaButtonElement;
3
2
  constructor();
4
- stars: Number[];
5
3
  order: any;
6
4
  orderId: number;
7
5
  thanksMsg: string;
@@ -10,6 +8,7 @@ export declare class SallaRating {
10
8
  isShippingRating: boolean;
11
9
  private ratingChain;
12
10
  private stepsCount;
11
+ private nextBtn;
13
12
  private modal;
14
13
  host: HTMLElement;
15
14
  show(): Promise<HTMLElement>;
@@ -17,19 +16,19 @@ export declare class SallaRating {
17
16
  componentWillLoad(): void;
18
17
  componentDidRender(): void;
19
18
  initiateRating(): void;
19
+ private getData;
20
20
  private handleWizard;
21
21
  private showActiveStep;
22
22
  private setModalHeight;
23
+ private starsRating;
24
+ private highlightSelectedStars;
23
25
  private sendRating;
24
26
  private sendFeedback;
25
27
  private ratingValidation;
26
- private getData;
27
- private starsRating;
28
- private highlightSelectedStars;
29
28
  render(): any;
30
29
  renderStoreRating(): any;
31
- renderProductsRating(): any;
32
30
  renderShippingRating(): any;
31
+ renderProductsRating(): any;
33
32
  renderThanksView(): any;
34
33
  getStarsRating(): any;
35
34
  }
@@ -1,26 +1,29 @@
1
1
  import { HTMLStencilElement } from '../../stencil-public-runtime';
2
2
  export declare class SallaSearch {
3
- searchTerm: string;
4
- results: string[];
5
- fetchStatus: string;
6
- showResult: boolean;
7
- showModal: boolean;
3
+ constructor();
4
+ private readonly buttonSlot;
5
+ private readonly productSlot;
6
+ private modal;
7
+ private container;
8
+ private searchIcon;
9
+ private noResults;
10
+ host: HTMLStencilElement;
11
+ results: any[];
8
12
  /**
9
- * The text to overwrite search placeholder.
13
+ * Override search placeholder.
10
14
  */
11
- searchPlaceholder: string;
15
+ placeholder: string;
12
16
  /**
13
- * The text to overwrite no results text.
17
+ * Override no results error message.
14
18
  */
15
19
  noResultsText: string;
16
- private hasSearchIconSlot;
17
- private hasProductTemplateSlot;
18
- private productTemplateHtml;
19
- hostElement: HTMLStencilElement;
20
- componentWillLoad(): void;
21
- private handleChange;
22
- private getProduct;
23
- private openSearch;
24
- private closeSearch;
20
+ onModalClose(): void;
21
+ private getDefaultProductSlot;
22
+ private search;
23
+ private afterSearching;
25
24
  render(): any;
25
+ /**
26
+ * Run it one time after load
27
+ */
28
+ componentDidLoad(): void;
26
29
  }
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { HTMLStencilElement, JSXBase } from "./stencil-public-runtime";
8
8
  export namespace Components {
9
- interface MultiWarehouse {
9
+ interface SallaBranches {
10
10
  "branches": any[];
11
11
  "browseProductsFrom": string;
12
12
  "current": number;
@@ -40,11 +40,13 @@ export namespace Components {
40
40
  "error": boolean;
41
41
  "hide": () => Promise<HTMLElement>;
42
42
  "icon": string;
43
+ "imageIcon": string;
43
44
  "isClosable": boolean;
44
45
  "modalWidth": string;
45
46
  "setTitle": (title: any) => Promise<HTMLElement>;
46
47
  "show": () => Promise<HTMLElement>;
47
48
  "subTitle": string;
49
+ "subTitleFirst": boolean;
48
50
  "success": boolean;
49
51
  "visible": boolean;
50
52
  }
@@ -75,23 +77,23 @@ export namespace Components {
75
77
  }
76
78
  interface SallaSearch {
77
79
  /**
78
- * The text to overwrite no results text.
80
+ * Override no results error message.
79
81
  */
80
82
  "noResultsText": string;
81
83
  /**
82
- * The text to overwrite search placeholder.
84
+ * Override search placeholder.
83
85
  */
84
- "searchPlaceholder": string;
86
+ "placeholder": string;
85
87
  }
86
88
  interface SallaVerify {
87
89
  }
88
90
  }
89
91
  declare global {
90
- interface HTMLMultiWarehouseElement extends Components.MultiWarehouse, HTMLStencilElement {
92
+ interface HTMLSallaBranchesElement extends Components.SallaBranches, HTMLStencilElement {
91
93
  }
92
- var HTMLMultiWarehouseElement: {
93
- prototype: HTMLMultiWarehouseElement;
94
- new (): HTMLMultiWarehouseElement;
94
+ var HTMLSallaBranchesElement: {
95
+ prototype: HTMLSallaBranchesElement;
96
+ new (): HTMLSallaBranchesElement;
95
97
  };
96
98
  interface HTMLSallaButtonElement extends Components.SallaButton, HTMLStencilElement {
97
99
  }
@@ -142,7 +144,7 @@ declare global {
142
144
  new (): HTMLSallaVerifyElement;
143
145
  };
144
146
  interface HTMLElementTagNameMap {
145
- "multi-warehouse": HTMLMultiWarehouseElement;
147
+ "salla-branches": HTMLSallaBranchesElement;
146
148
  "salla-button": HTMLSallaButtonElement;
147
149
  "salla-localization": HTMLSallaLocalizationElement;
148
150
  "salla-login": HTMLSallaLoginElement;
@@ -154,7 +156,7 @@ declare global {
154
156
  }
155
157
  }
156
158
  declare namespace LocalJSX {
157
- interface MultiWarehouse {
159
+ interface SallaBranches {
158
160
  "branches"?: any[];
159
161
  "browseProductsFrom"?: string;
160
162
  "current"?: number;
@@ -178,11 +180,13 @@ declare namespace LocalJSX {
178
180
  interface SallaModal {
179
181
  "error"?: boolean;
180
182
  "icon"?: string;
183
+ "imageIcon"?: string;
181
184
  "isClosable"?: boolean;
182
185
  "modalWidth"?: string;
183
186
  "onClose"?: (event: CustomEvent<any>) => void;
184
187
  "onReady"?: (event: CustomEvent<any>) => void;
185
188
  "subTitle"?: string;
189
+ "subTitleFirst"?: boolean;
186
190
  "success"?: boolean;
187
191
  "visible"?: boolean;
188
192
  }
@@ -210,18 +214,18 @@ declare namespace LocalJSX {
210
214
  }
211
215
  interface SallaSearch {
212
216
  /**
213
- * The text to overwrite no results text.
217
+ * Override no results error message.
214
218
  */
215
219
  "noResultsText"?: string;
216
220
  /**
217
- * The text to overwrite search placeholder.
221
+ * Override search placeholder.
218
222
  */
219
- "searchPlaceholder"?: string;
223
+ "placeholder"?: string;
220
224
  }
221
225
  interface SallaVerify {
222
226
  }
223
227
  interface IntrinsicElements {
224
- "multi-warehouse": MultiWarehouse;
228
+ "salla-branches": SallaBranches;
225
229
  "salla-button": SallaButton;
226
230
  "salla-localization": SallaLocalization;
227
231
  "salla-login": SallaLogin;
@@ -236,7 +240,7 @@ export { LocalJSX as JSX };
236
240
  declare module "@stencil/core" {
237
241
  export namespace JSX {
238
242
  interface IntrinsicElements {
239
- "multi-warehouse": LocalJSX.MultiWarehouse & JSXBase.HTMLAttributes<HTMLMultiWarehouseElement>;
243
+ "salla-branches": LocalJSX.SallaBranches & JSXBase.HTMLAttributes<HTMLSallaBranchesElement>;
240
244
  "salla-button": LocalJSX.SallaButton & JSXBase.HTMLAttributes<HTMLSallaButtonElement>;
241
245
  "salla-localization": LocalJSX.SallaLocalization & JSXBase.HTMLAttributes<HTMLSallaLocalizationElement>;
242
246
  "salla-login": LocalJSX.SallaLogin & JSXBase.HTMLAttributes<HTMLSallaLoginElement>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salla.sa/twilight-components",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "license": "MIT",
5
5
  "keywords": [
6
6
  "twilight",
@@ -1,95 +0,0 @@
1
- import { r as registerInstance, h, e as Host, g as getElement } from './index-8cf58712.js';
2
-
3
- const SallaSearch = class {
4
- constructor(hostRef) {
5
- registerInstance(this, hostRef);
6
- this.fetchStatus = '';
7
- this.showModal = false;
8
- /**
9
- * The text to overwrite search placeholder.
10
- */
11
- this.searchPlaceholder = 'Search here ...';
12
- /**
13
- * The text to overwrite no results text.
14
- */
15
- this.noResultsText = 'There are no results at the moment';
16
- this.handleChange = event => {
17
- this.searchTerm = event.target.value;
18
- this.fetchStatus = 'loading';
19
- this.showResult = false;
20
- this.results = [];
21
- if (this.searchTerm.length > 2) {
22
- window.salla.search.api
23
- .search(this.searchTerm)
24
- .then(response => response)
25
- .then(response => {
26
- console.log('response', response);
27
- this.fetchStatus = 'idle';
28
- this.results = response.results;
29
- this.showResult = true;
30
- if (this.results.length < 1) {
31
- this.fetchStatus = 'error';
32
- }
33
- })
34
- .catch(err => {
35
- this.showResult = true;
36
- this.fetchStatus = 'error';
37
- console.log(err);
38
- });
39
- }
40
- };
41
- this.openSearch = () => {
42
- this.searchTerm = '';
43
- this.fetchStatus = '';
44
- this.results = [];
45
- this.showModal = true;
46
- window.scrollTo(0, 0);
47
- document.getElementsByTagName('html')[0].style.position = 'fixed';
48
- document.getElementsByTagName('html')[0].style.overflowY = 'scroll';
49
- };
50
- this.closeSearch = () => {
51
- this.searchTerm = '';
52
- this.fetchStatus = '';
53
- this.results = [];
54
- document.getElementsByTagName('html')[0].style.position = 'static';
55
- document.getElementsByTagName('html')[0].style.overflowY = 'auto';
56
- this.showModal = false;
57
- };
58
- }
59
- componentWillLoad() {
60
- this.hasSearchIconSlot = !!this.hostElement.querySelector('[slot="search-icon"]');
61
- this.hasProductTemplateSlot = !!this.hostElement.querySelector('[slot="product-template"]');
62
- if (this.hasProductTemplateSlot) {
63
- this.productTemplateHtml = this.hostElement.querySelector('[slot="product-template"]').innerHTML;
64
- }
65
- }
66
- getProduct(item) {
67
- var _a, _b;
68
- // todo use art-template https://aui.github.io/art-template/docs/.
69
- if (this.hasProductTemplateSlot) {
70
- //slot scope
71
- let product = this.productTemplateHtml
72
- .replace("{title}", item.title)
73
- .replace("{price}", (_a = item.price) === null || _a === void 0 ? void 0 : _a.after)
74
- .replace("{url}", item.url)
75
- .replace("{thumb}", item.thumb);
76
- return (h("div", { class: "s-search-product", innerHTML: product }));
77
- }
78
- else {
79
- return (h("div", { class: "s-search-product" }, h("a", { target: "_blank", href: item.url, class: "s-search-product-image-container" }, h("img", { class: "s-search-product-image", src: item.thumb })), h("div", { class: "s-search-product-details" }, h("div", { class: "s-search-product-title" }, item.title), h("div", { class: "s-search-product-price" }, (_b = item.price) === null || _b === void 0 ? void 0 : _b.after))));
80
- }
81
- }
82
- render() {
83
- return (h(Host, { class: "s-search" }, h("button", { type: "button", onClick: this.openSearch, class: "s-search-search-button-icon" }, this.hasSearchIconSlot ? (h("slot", { name: "search-icon" })) : (h("i", { class: "sicon-search font-bold" }))), this.showModal && (h("div", { class: "s-search-container", style: { backgroundColor: 'rgba(0,0,0,0.5)' } }, h("div", { class: "s-search-wrapper", onClick: this.closeSearch }, h("div", { class: "s-search-inner", onClick: e => {
84
- e.stopPropagation();
85
- } }, h("div", { class: "s-search-search-box-container" }, h("div", { class: !this.showResult
86
- ? 's-search-search-box-inner'
87
- : 's-search-search-box-inner-open' }, h("input", { class: "s-search-input", type: "text", placeholder: this.searchPlaceholder, value: this.searchTerm, onInput: event => this.handleChange(event) }), this.fetchStatus != 'loading' ? (h("button", { class: "s-search-search-icon" }, h("i", { class: "sicon-search" }))) : (h("span", { class: "s-search-spinner" }, h("span", { class: "s-search-spinner-loader" }))))), h("div", { class: "s-search-search-results" }, this.fetchStatus === 'error' && (h("p", { class: "s-search-no-results error p-4 text-sm text-gray-text" }, this.noResultsText)), this.results &&
88
- this.results.map(item => {
89
- return this.getProduct(item);
90
- }))))))));
91
- }
92
- get hostElement() { return getElement(this); }
93
- };
94
-
95
- export { SallaSearch as S };