@salla.sa/twilight-components 1.0.7 → 1.0.9

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 (36) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/multi-warehouse_3.cjs.entry.js +7 -1
  3. package/dist/cjs/order-rating.cjs.entry.js +37 -12
  4. package/dist/cjs/salla-button.cjs.entry.js +4 -3
  5. package/dist/cjs/salla-localization.cjs.entry.js +12 -9
  6. package/dist/cjs/salla-verify.cjs.entry.js +94 -0
  7. package/dist/cjs/twilight-components.cjs.js +1 -1
  8. package/dist/collection/collection-manifest.json +2 -1
  9. package/dist/collection/components/order-rating/order-rating.js +47 -14
  10. package/dist/collection/components/salla-button/salla-button.js +22 -3
  11. package/dist/collection/components/salla-localization/salla-localization.js +12 -9
  12. package/dist/collection/components/salla-modal/salla-modal.js +29 -1
  13. package/dist/collection/components/salla-verify/salla-verify.js +97 -0
  14. package/dist/esm/loader.js +1 -1
  15. package/dist/esm/multi-warehouse_3.entry.js +7 -1
  16. package/dist/esm/order-rating.entry.js +37 -12
  17. package/dist/esm/salla-button.entry.js +4 -3
  18. package/dist/esm/salla-localization.entry.js +12 -9
  19. package/dist/esm/salla-verify.entry.js +90 -0
  20. package/dist/esm/twilight-components.js +1 -1
  21. package/dist/twilight-components/p-653bb9a8.entry.js +1 -0
  22. package/dist/twilight-components/p-a2395c9d.entry.js +1 -0
  23. package/dist/twilight-components/p-bd10d8d5.entry.js +1 -0
  24. package/dist/twilight-components/{p-b490f9e0.entry.js → p-ea986bca.entry.js} +1 -1
  25. package/dist/twilight-components/p-f4340bd9.entry.js +1 -0
  26. package/dist/twilight-components/twilight-components.esm.js +1 -1
  27. package/dist/types/components/order-rating/order-rating.d.ts +4 -0
  28. package/dist/types/components/salla-button/salla-button.d.ts +1 -0
  29. package/dist/types/components/salla-localization/salla-localization.d.ts +4 -0
  30. package/dist/types/components/salla-modal/salla-modal.d.ts +2 -0
  31. package/dist/types/components/salla-verify/salla-verify.d.ts +19 -0
  32. package/dist/types/components.d.ts +16 -0
  33. package/package.json +1 -1
  34. package/dist/twilight-components/p-4cc11ee2.entry.js +0 -1
  35. package/dist/twilight-components/p-60f0446f.entry.js +0 -1
  36. package/dist/twilight-components/p-b72e6cfa.entry.js +0 -1
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- return index.bootstrapLazy([["salla-localization.cjs",[[4,"salla-localization",{"show":[64],"hide":[64]}]]],["order-rating.cjs",[[0,"order-rating",{"order":[8]}]]],["salla-search.cjs",[[4,"salla-search",{"searchPlaceholder":[1,"search-placeholder"],"noResultsText":[1,"no-results-text"],"searchTerm":[32],"results":[32],"fetchStatus":[32],"showResult":[32],"showModal":[32]}]]],["salla-button.cjs",[[4,"salla-button",{"kind":[513],"loading":[516],"load":[64],"stop":[64],"disable":[64],"enable":[64]}]]],["multi-warehouse_3.cjs",[[4,"multi-warehouse",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}],[0,"salla-login"],[4,"salla-modal",{"error":[4],"success":[4],"isClosable":[1028,"is-closable"],"modalWidth":[1,"modal-width"],"visible":[516],"subTitle":[1,"sub-title"],"icon":[1],"show":[64],"hide":[64]}]]]], options);
17
+ return index.bootstrapLazy([["salla-localization.cjs",[[4,"salla-localization",{"show":[64],"hide":[64]}]]],["salla-verify.cjs",[[0,"salla-verify"]]],["order-rating.cjs",[[0,"order-rating",{"order":[8]}]]],["salla-search.cjs",[[4,"salla-search",{"searchPlaceholder":[1,"search-placeholder"],"noResultsText":[1,"no-results-text"],"searchTerm":[32],"results":[32],"fetchStatus":[32],"showResult":[32],"showModal":[32]}]]],["salla-button.cjs",[[4,"salla-button",{"kind":[513],"loading":[516],"disabled":[516],"load":[64],"stop":[64],"disable":[64],"enable":[64]}]]],["multi-warehouse_3.cjs",[[4,"multi-warehouse",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}],[0,"salla-login"],[4,"salla-modal",{"error":[4],"success":[4],"isClosable":[1028,"is-closable"],"modalWidth":[1,"modal-width"],"visible":[516],"subTitle":[1,"sub-title"],"icon":[1],"show":[64],"hide":[64],"setTitle":[64]}]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -97,6 +97,8 @@ const SallaModal = class {
97
97
  this.icon = 'sicon-cancel';
98
98
  salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
99
99
  salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
100
+ this.title = this.host.title;
101
+ this.host.removeAttribute('title');
100
102
  }
101
103
  handleVisible(newValue) {
102
104
  if (!newValue) {
@@ -116,6 +118,10 @@ const SallaModal = class {
116
118
  this.host.removeAttribute('visible');
117
119
  return this.host;
118
120
  }
121
+ async setTitle(title) {
122
+ this.title = title;
123
+ return this.host;
124
+ }
119
125
  toggleModal(isOpen) {
120
126
  Helper.Helper.toggleElement(this.host.querySelector('.s-modal-overlay'), 'ease-out duration-300 opacity-100', 'opacity-0', () => isOpen)
121
127
  .toggleElement(this.host.querySelector('.s-modal-body'), 'ease-out duration-300 opacity-100 translate-y-0 sm:scale-100', //add these classes
@@ -142,7 +148,7 @@ const SallaModal = class {
142
148
  's-modal-text-error': this.error,
143
149
  's-modal-text-success': this.success
144
150
  } }))
145
- : '', index.h("div", { class: "s-modal-title", innerHTML: this.host.title }), index.h("p", { class: "s-modal-sub-title", innerHTML: this.subTitle }))), index.h("slot", null), index.h("slot", { name: "footer" })))));
151
+ : '', index.h("div", { class: "s-modal-title", innerHTML: this.title }), index.h("p", { class: "s-modal-sub-title", innerHTML: this.subTitle }))), index.h("slot", null), index.h("slot", { name: "footer" })))));
146
152
  }
147
153
  get host() { return index.getElement(this); }
148
154
  static get watchers() { return {
@@ -62,37 +62,62 @@ const OrderRating = class {
62
62
  isShippingRating: true,
63
63
  }
64
64
  };
65
+ this.ratingChain = Promise.resolve();
66
+ this.wizardInex = 0;
67
+ }
68
+ componentDidRender() {
69
+ this.initiateRating();
65
70
  }
66
71
  render() {
67
- return (index.h(index.Host, null, this.order.settings.isProductsRating && this.renderProductsRating(), this.order.settings.isStoreRating && this.renderStoreRating(), this.order.settings.isShippingRating && this.renderShippingRating()));
72
+ return (index.h(index.Host, null, index.h("div", { class: "pannel__body" }, this.order.settings.isStoreRating && this.renderStoreRating(), this.order.settings.isProductsRating && this.renderProductsRating(), this.order.settings.isShippingRating && this.renderShippingRating()), index.h("div", { class: "pannel__footer relative flex justify-between items-center" }, index.h("button", { id: "prev-btn", class: "font-bold text-sm text-primary hidden" }, "\u0627\u0644\u0633\u0627\u0628\u0642"), index.h("ul", { class: "flex justify-center text-center space-s-1.5 py-8 flex-1" }, index.h("li", { class: "cursor-pointer w-2.5 h-2.5 bg-primary rounded-full transition-colors duration-300" }), index.h("li", { class: "cursor-pointer w-2.5 h-2.5 bg-gray-200 rounded-full transition-colors duration-300" }), index.h("li", { class: "cursor-pointer w-2.5 h-2.5 bg-gray-200 rounded-full transition-colors duration-300" })), index.h("button", { id: "next-btn", class: "btn btn-primary h-10 px-8 flex-none" }, "\u0627\u0644\u062A\u0627\u0644\u064A"))));
68
73
  }
69
74
  renderProductsRating() {
70
- return (index.h("section", { class: "rating-section products-section", "data-type": "product" }, index.h("div", { class: "bg-white mb-5 p-5 rounded-md overflow-hidden mb-10" }, this.order.products.map((item, index$1) => {
75
+ return (index.h("section", { class: "step rating-section products-section hidden", "data-type": "product" }, index.h("div", { class: "bg-white mb-5 p-5 rounded-md overflow-hidden mb-10" }, this.order.products.map((item, index$1) => {
71
76
  var _a;
72
77
  return index.h("div", { class: "rating-outer-form", "data-stars-error": `يرجى تقييم (${item.title}) بواسطة النجمات` }, index.h("div", { class: "product-item mb-4" }, index.h("div", { class: "mb-5" }, index.h("div", { class: "flex space-s-5 mb-8" }, index.h("img", { src: item.image, alt: item.title, class: "w-18 h-14 object-cover rounded-md" }), index.h("div", { class: "flex-1" }, index.h("h3", { class: "section-title leading-5 mb-1.5 md:text-base" }, " ", item.title), index.h("div", { class: "rw-product-entry__rate" }, index.h("div", { class: "rating-wrap flex items-center space-s-4" }, index.h("form", { class: "rate-element rate-element--has-label" }, this.getStarsRating()), index.h("p", { class: "rate-label fix-align font-xsm my-0" })), index.h("input", { type: "hidden", name: "order_id", value: (_a = this.order) === null || _a === void 0 ? void 0 : _a.order_id }), index.h("input", { type: "hidden", name: `products[${index$1}][product_id]`, value: item.getOptimusRouteKey }), index.h("input", { type: "hidden", name: "type", value: "products" }), index.h("textarea", { "data-product-id": item.id, name: `products[${index$1}][comment]`, id: `productReview_${item.id}`, class: "comment form-input h-20 product-review", placeholder: `اضف رأيك عن المنتج (${item.title})` }), index.h("small", { class: "text-red-400 validation-message" })))))));
73
78
  }))));
74
79
  }
75
80
  renderStoreRating() {
76
- return (index.h("section", { class: "rating-section bg-white my-10 p-5 rounded-md mb-5", "data-type": "store" }, index.h("div", { class: "rating-outer-form", "data-stars-error": "\u064A\u0631\u062C\u0649 \u062A\u0642\u064A\u064A\u0645 \u0627\u0644\u0645\u062A\u062C\u0631 \u0628\u0648\u0627\u0633\u0637\u0629 \u0627\u0644\u0646\u062C\u0645\u0627\u062A" }, index.h("input", { type: "hidden", name: "order_id", value: this.order.order_id }), index.h("input", { type: "hidden", name: "type", value: "store" }), index.h("h2", { class: "section-title text-lg font-bold mb-5" }, "\u0643\u064A\u0641 \u0643\u0627\u0646\u062A \u062A\u062C\u0631\u0628\u062A\u0643 \u0645\u0639 \u0627\u0644\u0645\u062A\u062C\u0631 \u0647\u0630\u0647 \u0627\u0644\u0645\u0631\u0629"), index.h("div", { class: "mb-2" }, index.h("textarea", { id: "storeReview", name: "comment", class: "form-input comment h-20", placeholder: "\u0627\u0636\u0641 \u0631\u0623\u064A\u0643 \u0639\u0646 \u0627\u0644\u0645\u062A\u062C\u0631.." })), index.h("div", { class: "rating-wrap flex items-center space-s-4" }, index.h("form", { class: "rate-element rate-element--has-label" }, this.getStarsRating()), index.h("p", { class: "rate-label fix-align font-sm center mb-0" })), index.h("small", { class: "text-red-400 validation-message" }))));
81
+ return (index.h("section", { class: "step rating-section bg-white my-10 p-5 rounded-md mb-5 active", "data-type": "store" }, index.h("div", { class: "rating-outer-form", "data-stars-error": "\u064A\u0631\u062C\u0649 \u062A\u0642\u064A\u064A\u0645 \u0627\u0644\u0645\u062A\u062C\u0631 \u0628\u0648\u0627\u0633\u0637\u0629 \u0627\u0644\u0646\u062C\u0645\u0627\u062A" }, index.h("input", { type: "hidden", name: "order_id", value: this.order.order_id }), index.h("input", { type: "hidden", name: "type", value: "store" }), index.h("h2", { class: "section-title text-lg font-bold mb-5" }, "\u0643\u064A\u0641 \u0643\u0627\u0646\u062A \u062A\u062C\u0631\u0628\u062A\u0643 \u0645\u0639 \u0627\u0644\u0645\u062A\u062C\u0631 \u0647\u0630\u0647 \u0627\u0644\u0645\u0631\u0629"), index.h("div", { class: "mb-2" }, index.h("textarea", { id: "storeReview", name: "comment", class: "form-input comment h-20", placeholder: "\u0627\u0636\u0641 \u0631\u0623\u064A\u0643 \u0639\u0646 \u0627\u0644\u0645\u062A\u062C\u0631.." })), index.h("div", { class: "rating-wrap flex items-center space-s-4" }, index.h("form", { class: "rate-element rate-element--has-label" }, this.getStarsRating()), index.h("p", { class: "rate-label fix-align font-sm center mb-0" })), index.h("small", { class: "text-red-400 validation-message" }))));
77
82
  }
78
83
  renderShippingRating() {
79
- return (index.h("section", { class: "rating-section bg-white my-10 p-5 rounded-md mb-5", "data-type": "shipping" }, index.h("div", { class: "rating-outer-form", "data-stars-error": "\u064A\u0631\u062C\u0649 \u062A\u0642\u064A\u064A\u0645 \u0634\u0631\u0643\u0629 \u0627\u0644\u0634\u062D\u0646 \u0628\u0648\u0627\u0633\u0637\u0629 \u0627\u0644\u0646\u062C\u0645\u0627\u062A" }, index.h("input", { type: "hidden", name: "order_id", value: this.order.order_id }), index.h("input", { type: "hidden", name: "shipping_company_id", value: this.order.shipping.id }), index.h("input", { type: "hidden", name: "type", value: "shipping" }), index.h("h2", { class: "section-title text-lg font-bold mb-5" }, "\u062E\u0628\u0631\u0646\u0627 \u0639\u0646 \u062A\u062C\u0631\u0628\u062A\u0643 \u0645\u0639 \u0634\u0631\u0643\u0629 \u0627\u0644\u0634\u062D\u0646"), index.h("div", { class: "mb-2" }, index.h("textarea", { id: "shippingReview", name: "comment", class: "form-input comment h-20 mb-2", placeholder: "\u0627\u0636\u0641 \u0631\u0623\u064A\u0643 \u0639\u0646 \u0634\u0631\u0643\u0629 \u0627\u0644\u0634\u062D\u0646" })), index.h("div", { class: "rating-wrap flex items-center space-s-4" }, index.h("form", { class: "rate-element ratFeedbackPresentere-element--has-label" }, this.getStarsRating()), index.h("p", { class: "rate-label fix-align font-sm center mb-0" })), index.h("small", { class: "text-red-400 validation-message" }))));
84
+ return (index.h("section", { class: "step rating-section bg-white my-10 p-5 rounded-md mb-5 hidden", "data-type": "shipping" }, index.h("div", { class: "rating-outer-form", "data-stars-error": "\u064A\u0631\u062C\u0649 \u062A\u0642\u064A\u064A\u0645 \u0634\u0631\u0643\u0629 \u0627\u0644\u0634\u062D\u0646 \u0628\u0648\u0627\u0633\u0637\u0629 \u0627\u0644\u0646\u062C\u0645\u0627\u062A" }, index.h("input", { type: "hidden", name: "order_id", value: this.order.order_id }), index.h("input", { type: "hidden", name: "shipping_company_id", value: this.order.shipping.id }), index.h("input", { type: "hidden", name: "type", value: "shipping" }), index.h("h2", { class: "section-title text-lg font-bold mb-5" }, "\u062E\u0628\u0631\u0646\u0627 \u0639\u0646 \u062A\u062C\u0631\u0628\u062A\u0643 \u0645\u0639 \u0634\u0631\u0643\u0629 \u0627\u0644\u0634\u062D\u0646"), index.h("div", { class: "mb-2" }, index.h("textarea", { id: "shippingReview", name: "comment", class: "form-input comment h-20 mb-2", placeholder: "\u0627\u0636\u0641 \u0631\u0623\u064A\u0643 \u0639\u0646 \u0634\u0631\u0643\u0629 \u0627\u0644\u0634\u062D\u0646" })), index.h("div", { class: "rating-wrap flex items-center space-s-4" }, index.h("form", { class: "rate-element ratFeedbackPresentere-element--has-label" }, this.getStarsRating()), index.h("p", { class: "rate-label fix-align font-sm center mb-0" })), index.h("small", { class: "text-red-400 validation-message" }))));
80
85
  }
81
86
  getStarsRating() {
82
87
  return (index.h("div", { class: "mb-1" }, index.h("input", { type: "hidden", class: "rating_hidden_input", name: "rating", value: "" }), this.stars.map((star) => index.h("button", { type: "submit", class: "btn btn--transparent px-1 text-lg text-gray-400 btn--star", "data-star": star, "data-text": this.order.ratingMessage[`${star}`] }, index.h("i", { class: "sicon-star2" })))));
83
88
  }
84
- //========================= Start Rating Logic =========================//
85
89
  initiateRating() {
86
90
  this.highlightSelectedStars();
87
91
  this.starsRating();
92
+ this.handleWizard();
88
93
  //show submitRating Button Only When there is a comment field
89
- Helper.Helper.app.toggle('#submitRating', 'btn', 'hidden', () => Helper.Helper.app.element('#shippingReview,#storeReview,.product-review'));
90
- this.ratingChain = Promise.resolve();
91
- Helper.Helper.app.onClick('#submitRating', () => this.sendRating().then(() => window.location.reload()));
94
+ // Helper.toggle('#submitRating', 'btn', 'hidden', () => Helper.element('#shippingReview,#storeReview,.product-review'))
95
+ // this.ratingChain = Promise.resolve();
96
+ // Helper.onClick('#submitRating', () => this.sendRating().then(() => window.location.reload()));
97
+ salla.event.on('submit::order-rating', () => this.sendRating().then(() => window.location.reload()));
98
+ }
99
+ handleWizard() {
100
+ let steps = document.querySelectorAll(".step"), stepsCount = document.querySelectorAll(".step").length;
101
+ Helper.Helper.onClick("#prev-btn", () => {
102
+ this.wizardInex > 0 && this.wizardInex--;
103
+ this.showActiveStep(steps);
104
+ this.wizardInex == 0 && Helper.Helper.toggle('#prev-btn', 'hidden', 'block', () => true);
105
+ });
106
+ Helper.Helper.onClick("#next-btn", () => {
107
+ this.ratingValidation();
108
+ this.wizardInex == stepsCount - 1 && salla.event.dispatch("submit::order-rating");
109
+ this.wizardInex < stepsCount - 1 && this.wizardInex++;
110
+ this.showActiveStep(steps);
111
+ Helper.Helper.toggle('#prev-btn', 'block', 'hidden', () => true);
112
+ });
113
+ }
114
+ showActiveStep(steps) {
115
+ Helper.Helper.toggle('.step', 'hidden', 'active', () => true);
116
+ Helper.Helper.toggleElement(steps[this.wizardInex], 'active', 'hidden', () => true);
92
117
  }
93
118
  sendRating() {
94
- this.ratingValidation();
95
- Helper.Helper.app.all('.rating-section', ratingSection => {
119
+ // this.ratingValidation()
120
+ Helper.Helper.all('.rating-section', ratingSection => {
96
121
  let type = ratingSection.dataset.type;
97
122
  let formsData = [];
98
123
  ratingSection.querySelectorAll('.rating-outer-form')
@@ -122,7 +147,7 @@ const OrderRating = class {
122
147
  }
123
148
  ratingValidation() {
124
149
  let errorMsg = '';
125
- document.querySelectorAll('.rating-section')
150
+ document.querySelectorAll('.rating-section.active')
126
151
  .forEach((ratingSection) => {
127
152
  ratingSection.querySelectorAll('.rating-outer-form')
128
153
  .forEach((rating) => {
@@ -163,7 +188,7 @@ const OrderRating = class {
163
188
  // for hovered star ---
164
189
  highlightSelectedStars() {
165
190
  let hover = ['hovered', 'text-theme-yellow'];
166
- Helper.Helper.app.all('.rate-element', el => {
191
+ Helper.Helper.all('.rate-element', el => {
167
192
  let starElements = el.querySelectorAll('.btn--star');
168
193
  // remove hovered state from stars ---
169
194
  el.addEventListener('mouseout', () => el.querySelectorAll('.btn--star').forEach(star => star.classList.remove(...hover)));
@@ -12,6 +12,7 @@ const SallaButton = class {
12
12
  index.registerInstance(this, hostRef);
13
13
  this.kind = 'primary';
14
14
  this.loading = false;
15
+ this.disabled = false;
15
16
  this.hostAttributes = {};
16
17
  for (let i = 0; i < this.host.attributes.length; i++) {
17
18
  this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
@@ -30,10 +31,10 @@ const SallaButton = class {
30
31
  return this.host;
31
32
  }
32
33
  async disable() {
33
- this.btn.setAttribute('disabled', '');
34
+ this.host.setAttribute('disabled', '');
34
35
  }
35
36
  async enable() {
36
- this.btn.removeAttribute('disabled');
37
+ this.host.removeAttribute('disabled');
37
38
  }
38
39
  handleVisible(newKind, oldKind) {
39
40
  this.btn.classList.remove('btn-' + oldKind);
@@ -43,7 +44,7 @@ const SallaButton = class {
43
44
  Helper.Helper.toggleElement(this.btn, 'btn--is-loading', 'btn--no-loading', () => newVal);
44
45
  }
45
46
  render() {
46
- return (index.h("button", Object.assign({ ref: el => this.btn = el }, this.hostAttributes), index.h("slot", null), this.loading ? index.h("span", { class: "loader loader--small s-button-loader" }) : ''));
47
+ return (index.h("button", Object.assign({ ref: btn => this.btn = btn, disabled: this.disabled }, this.hostAttributes), index.h("slot", null), this.loading ? index.h("span", { class: "loader loader--small s-button-loader" }) : ''));
47
48
  }
48
49
  get host() { return index.getElement(this); }
49
50
  static get watchers() { return {
@@ -11,6 +11,12 @@ const SallaLocalization = class {
11
11
  Helper.Helper.setHost(this.host);
12
12
  salla.event.on('localization::show', () => this.show());
13
13
  }
14
+ setCurrentLanguage(language) {
15
+ this.language = language;
16
+ }
17
+ setCurrentCurrency(currency) {
18
+ this.currency = currency;
19
+ }
14
20
  async show() {
15
21
  return this.modal.show();
16
22
  }
@@ -21,16 +27,13 @@ const SallaLocalization = class {
21
27
  let url;
22
28
  this.btn.load()
23
29
  .then(() => {
24
- let code = Helper.Helper.val('[name=currency]:checked');
25
- if (code !== salla.config.currency.code) {
30
+ if (this.currency && this.currency.code !== salla.config.currency.code) {
26
31
  url = window.location.href;
27
- return salla.currency.api.change(code);
32
+ return salla.currency.api.change(this.currency.code);
28
33
  }
29
- //binding
30
34
  }).then(() => {
31
- let language = Helper.Helper.val('[name=lang]:checked');
32
- if (language !== salla.config.language.code) {
33
- url = salla.config.languages.filter(lang => lang.code === language)[0].url;
35
+ if (this.language && this.language.code !== salla.config.language.code) {
36
+ url = this.language.url;
34
37
  }
35
38
  }).then(() => this.btn.stop())
36
39
  .then(() => this.hide())
@@ -38,9 +41,9 @@ const SallaLocalization = class {
38
41
  }
39
42
  render() {
40
43
  return (index.h("salla-modal", { id: "salla-localization", class: "hidden", ref: modal => this.modal = modal }, index.h("slot", { name: "header" }, index.h("div", { slot: "header" })), index.h("div", { class: "s-localization-inner" }, salla.config.languages
41
- ? index.h("div", { class: "s-localization-section" }, index.h("label", { class: "s-localization-title" }, salla.lang.get('common.titles.language')), index.h("fieldset", { class: "s-localization-fieldset" }, index.h("legend", { class: "sr-only" }, salla.lang.get('blocks.header.change_language')), index.h("div", { class: "s-localization-section-inner" }, salla.config.languages.map(lang => index.h("div", { class: "flex items-center" }, index.h("input", { id: 'lang-' + lang.code.toLowerCase(), class: "s-localization-input", name: "lang", checked: salla.config.language.code == lang.code, type: "radio", value: lang.code }), index.h("label", { htmlFor: 'lang-' + lang.code.toLowerCase(), class: "s-localization-label" }, index.h("span", null, lang.name), index.h("div", { class: 's-localization-flag flag iti__flag iti__' + lang.country_code })))))))
44
+ ? index.h("div", { class: "s-localization-section" }, index.h("label", { class: "s-localization-title" }, salla.lang.get('common.titles.language')), index.h("fieldset", { class: "s-localization-fieldset" }, index.h("legend", { class: "sr-only" }, salla.lang.get('blocks.header.change_language')), index.h("div", { class: "s-localization-section-inner" }, salla.config.languages.map(lang => index.h("div", { class: "flex items-center" }, index.h("input", { class: "s-localization-input", checked: salla.config.language.code == lang.code, onChange: () => this.setCurrentLanguage(lang), id: 'lang-' + lang.code.toLowerCase(), name: "language", type: "radio", value: lang.code }), index.h("label", { htmlFor: 'lang-' + lang.code.toLowerCase(), class: "s-localization-label" }, index.h("span", null, lang.name), index.h("div", { class: 's-localization-flag flag iti__flag iti__' + lang.country_code })))))))
42
45
  : '', salla.config.currencies
43
- ? index.h("div", { class: "s-localization-section" }, index.h("label", { class: "s-localization-title" }, salla.lang.get('common.titles.currency')), index.h("fieldset", { class: "s-localization-fieldset" }, index.h("legend", { class: "sr-only" }, salla.lang.get('blocks.header.change_currency')), index.h("div", { class: "s-localization-section-inner" }, salla.config.currencies.map(currency => index.h("div", { class: "s-localization-item" }, index.h("input", { class: "s-localization-input", checked: salla.config.currency.code == currency.code, id: 'currency-' + currency.code, name: "currency", type: "radio", value: currency.code }), index.h("label", { class: "s-localization-label", htmlFor: 'currency-' + currency.code }, index.h("span", null, currency.name), index.h("small", { class: "s-localization-currency" }, currency.code)))))))
46
+ ? index.h("div", { class: "s-localization-section" }, index.h("label", { class: "s-localization-title" }, salla.lang.get('common.titles.currency')), index.h("fieldset", { class: "s-localization-fieldset" }, index.h("legend", { class: "sr-only" }, salla.lang.get('blocks.header.change_currency')), index.h("div", { class: "s-localization-section-inner" }, salla.config.currencies.map(currency => index.h("div", { class: "s-localization-item" }, index.h("input", { class: "s-localization-input", checked: salla.config.currency.code == currency.code, onChange: () => this.setCurrentCurrency(currency), id: 'currency-' + currency.code, name: "currency", type: "radio", value: currency.code }), index.h("label", { class: "s-localization-label", htmlFor: 'currency-' + currency.code }, index.h("span", null, currency.name), index.h("small", { class: "s-localization-currency" }, currency.code)))))))
44
47
  : ''), index.h("p", { slot: "footer" }, index.h("slot", { name: "footer" }, index.h("salla-button", { ref: btn => this.btn = btn, onClick: () => this.submit(), class: "w-full" }, salla.lang.get('common.elements.ok'))))));
45
48
  }
46
49
  get host() { return index.getElement(this); }
@@ -0,0 +1,94 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-23da2c6b.js');
6
+ const Helper = require('./Helper-8c75b6ac.js');
7
+
8
+ const SallaVerify = class {
9
+ constructor(hostRef) {
10
+ index.registerInstance(this, hostRef);
11
+ Helper.Helper.setHost(this.host);
12
+ salla.event.on('profile::verify.mobile', data => this.show(data));
13
+ }
14
+ show({ international_mobile: mobile, _country_iso2: country_code }) {
15
+ this.mobile = mobile;
16
+ this.country_code = country_code;
17
+ this.resendTimer();
18
+ this.otpInputs = document.querySelectorAll('.s-verify-input');
19
+ this.otpInputs[0].focus();
20
+ Helper.Helper.onKeyUp('.s-verify-input', event => {
21
+ var _a, _b;
22
+ let key = event.keyCode || event.charCode;
23
+ salla.helpers.digitsOnly(event.target);
24
+ if (event.target.value) {
25
+ (_a = event.target.nextElementSibling) === null || _a === void 0 ? void 0 : _a.focus();
26
+ }
27
+ else if ([8, 46].includes(key)) {
28
+ (_b = event.target.previousElementSibling) === null || _b === void 0 ? void 0 : _b.focus();
29
+ }
30
+ this.toggleOTPSubmit();
31
+ });
32
+ Helper.Helper.on('paste', '.s-verify-input', event => {
33
+ let text = event.clipboardData.getData('text').toArabicDigits().replace(/[^0-9.]/g, '').replace('..', '.');
34
+ this.otpInputs.forEach((input, i) => input.value = text[i] || '');
35
+ this.toggleOTPSubmit();
36
+ setTimeout(() => this.otpInputs[3].focus(), 100);
37
+ });
38
+ return this.modal.show();
39
+ }
40
+ toggleOTPSubmit() {
41
+ let otp = [];
42
+ this.otpInputs.forEach(input => input.value && otp.push(input.value));
43
+ this.code.value = otp.join('');
44
+ if (otp.length === 4) {
45
+ this.btn.removeAttribute('disabled');
46
+ this.btn.click();
47
+ return;
48
+ }
49
+ this.btn.setAttribute('disabled', '');
50
+ }
51
+ resendTimer() {
52
+ Helper.Helper.showElement(this.resendMessage).hideElement(this.resend);
53
+ let resendAfter = 30;
54
+ let timerId = setInterval(() => {
55
+ if (resendAfter === -1) {
56
+ clearTimeout(timerId);
57
+ Helper.Helper.hideElement(this.resendMessage).showElement(this.resend);
58
+ }
59
+ else {
60
+ this.timer.innerHTML = `${resendAfter >= 10 ? resendAfter : '0' + resendAfter} : 00`;
61
+ resendAfter--;
62
+ }
63
+ }, 1000);
64
+ }
65
+ submit() {
66
+ return this.btn.load()
67
+ .then(() => this.btn.disable())
68
+ .then(() => salla.document.api.request('profile/verify-mobile', {
69
+ mobile: this.mobile,
70
+ country_code: this.country_code,
71
+ code: this.code.value
72
+ })).then(() => this.btn.stop() && this.btn.disable())
73
+ .then(() => this.modal.hide())
74
+ .then(() => window.location.reload())
75
+ .catch(() => this.btn.stop() && this.btn.enable());
76
+ }
77
+ resendCode() {
78
+ return this.btn.stop()
79
+ .then(() => this.btn.disable())
80
+ .then(() => {
81
+ this.otpInputs.forEach(input => input.value = '');
82
+ this.otpInputs[0].focus();
83
+ })
84
+ .then(() => salla.api.auth.resend({ phone: this.mobile, country_code: this.country_code }))
85
+ .then(() => this.resendTimer())
86
+ .catch(() => this.resendTimer());
87
+ }
88
+ render() {
89
+ return (index.h("salla-modal", { id: "s-verify", ref: modal => this.modal = modal, title: salla.lang.get('pages.profile.verify_title') }, index.h("div", { class: "s-verify-message", innerHTML: salla.lang.get('pages.profile.verify_message') }), index.h("label", { class: "s-verify-label" }, salla.lang.get('pages.profile.verify_placeholder')), index.h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }), index.h("div", { class: "s-verify-codes", dir: "ltr" }, [1, 2, 3, 4].map(() => index.h("input", { type: "text", maxlength: "1", class: "s-verify-input", required: true }))), index.h("div", { slot: "footer", class: "s-verify-footer" }, index.h("salla-button", { class: "s-verify-submit", disabled: true, onClick: () => this.submit(), ref: b => this.btn = b }, salla.lang.get('pages.profile.verify')), index.h("p", { class: "s-verify-resend-message", ref: el => this.resendMessage = el }, salla.lang.get('blocks.header.resend_after'), index.h("b", { class: "s-verify-timer", ref: el => this.timer = el })), index.h("a", { href: "#", class: "s-verify-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit')))));
90
+ }
91
+ get host() { return index.getElement(this); }
92
+ };
93
+
94
+ exports.salla_verify = SallaVerify;
@@ -15,5 +15,5 @@ const patchBrowser = () => {
15
15
  };
16
16
 
17
17
  patchBrowser().then(options => {
18
- return index.bootstrapLazy([["salla-localization.cjs",[[4,"salla-localization",{"show":[64],"hide":[64]}]]],["order-rating.cjs",[[0,"order-rating",{"order":[8]}]]],["salla-search.cjs",[[4,"salla-search",{"searchPlaceholder":[1,"search-placeholder"],"noResultsText":[1,"no-results-text"],"searchTerm":[32],"results":[32],"fetchStatus":[32],"showResult":[32],"showModal":[32]}]]],["salla-button.cjs",[[4,"salla-button",{"kind":[513],"loading":[516],"load":[64],"stop":[64],"disable":[64],"enable":[64]}]]],["multi-warehouse_3.cjs",[[4,"multi-warehouse",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}],[0,"salla-login"],[4,"salla-modal",{"error":[4],"success":[4],"isClosable":[1028,"is-closable"],"modalWidth":[1,"modal-width"],"visible":[516],"subTitle":[1,"sub-title"],"icon":[1],"show":[64],"hide":[64]}]]]], options);
18
+ return index.bootstrapLazy([["salla-localization.cjs",[[4,"salla-localization",{"show":[64],"hide":[64]}]]],["salla-verify.cjs",[[0,"salla-verify"]]],["order-rating.cjs",[[0,"order-rating",{"order":[8]}]]],["salla-search.cjs",[[4,"salla-search",{"searchPlaceholder":[1,"search-placeholder"],"noResultsText":[1,"no-results-text"],"searchTerm":[32],"results":[32],"fetchStatus":[32],"showResult":[32],"showModal":[32]}]]],["salla-button.cjs",[[4,"salla-button",{"kind":[513],"loading":[516],"disabled":[516],"load":[64],"stop":[64],"disable":[64],"enable":[64]}]]],["multi-warehouse_3.cjs",[[4,"multi-warehouse",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}],[0,"salla-login"],[4,"salla-modal",{"error":[4],"success":[4],"isClosable":[1028,"is-closable"],"modalWidth":[1,"modal-width"],"visible":[516],"subTitle":[1,"sub-title"],"icon":[1],"show":[64],"hide":[64],"setTitle":[64]}]]]], options);
19
19
  });
@@ -6,7 +6,8 @@
6
6
  "./components/order-rating/order-rating.js",
7
7
  "./components/salla-button/salla-button.js",
8
8
  "./components/salla-localization/salla-localization.js",
9
- "./components/salla-modal/salla-modal.js"
9
+ "./components/salla-modal/salla-modal.js",
10
+ "./components/salla-verify/salla-verify.js"
10
11
  ],
11
12
  "compiler": {
12
13
  "name": "@stencil/core",
@@ -54,15 +54,28 @@ export class OrderRating {
54
54
  isShippingRating: true,
55
55
  }
56
56
  };
57
+ this.ratingChain = Promise.resolve();
58
+ this.wizardInex = 0;
59
+ }
60
+ componentDidRender() {
61
+ this.initiateRating();
57
62
  }
58
63
  render() {
59
64
  return (h(Host, null,
60
- this.order.settings.isProductsRating && this.renderProductsRating(),
61
- this.order.settings.isStoreRating && this.renderStoreRating(),
62
- this.order.settings.isShippingRating && this.renderShippingRating()));
65
+ h("div", { class: "pannel__body" },
66
+ this.order.settings.isStoreRating && this.renderStoreRating(),
67
+ this.order.settings.isProductsRating && this.renderProductsRating(),
68
+ this.order.settings.isShippingRating && this.renderShippingRating()),
69
+ h("div", { class: "pannel__footer relative flex justify-between items-center" },
70
+ h("button", { id: "prev-btn", class: "font-bold text-sm text-primary hidden" }, "\u0627\u0644\u0633\u0627\u0628\u0642"),
71
+ h("ul", { class: "flex justify-center text-center space-s-1.5 py-8 flex-1" },
72
+ h("li", { class: "cursor-pointer w-2.5 h-2.5 bg-primary rounded-full transition-colors duration-300" }),
73
+ h("li", { class: "cursor-pointer w-2.5 h-2.5 bg-gray-200 rounded-full transition-colors duration-300" }),
74
+ h("li", { class: "cursor-pointer w-2.5 h-2.5 bg-gray-200 rounded-full transition-colors duration-300" })),
75
+ h("button", { id: "next-btn", class: "btn btn-primary h-10 px-8 flex-none" }, "\u0627\u0644\u062A\u0627\u0644\u064A"))));
63
76
  }
64
77
  renderProductsRating() {
65
- return (h("section", { class: "rating-section products-section", "data-type": "product" },
78
+ return (h("section", { class: "step rating-section products-section hidden", "data-type": "product" },
66
79
  h("div", { class: "bg-white mb-5 p-5 rounded-md overflow-hidden mb-10" }, this.order.products.map((item, index) => {
67
80
  var _a;
68
81
  return h("div", { class: "rating-outer-form", "data-stars-error": `يرجى تقييم (${item.title}) بواسطة النجمات` },
@@ -86,7 +99,7 @@ export class OrderRating {
86
99
  }))));
87
100
  }
88
101
  renderStoreRating() {
89
- return (h("section", { class: "rating-section bg-white my-10 p-5 rounded-md mb-5", "data-type": "store" },
102
+ return (h("section", { class: "step rating-section bg-white my-10 p-5 rounded-md mb-5 active", "data-type": "store" },
90
103
  h("div", { class: "rating-outer-form", "data-stars-error": "\u064A\u0631\u062C\u0649 \u062A\u0642\u064A\u064A\u0645 \u0627\u0644\u0645\u062A\u062C\u0631 \u0628\u0648\u0627\u0633\u0637\u0629 \u0627\u0644\u0646\u062C\u0645\u0627\u062A" },
91
104
  h("input", { type: "hidden", name: "order_id", value: this.order.order_id }),
92
105
  h("input", { type: "hidden", name: "type", value: "store" }),
@@ -99,7 +112,7 @@ export class OrderRating {
99
112
  h("small", { class: "text-red-400 validation-message" }))));
100
113
  }
101
114
  renderShippingRating() {
102
- return (h("section", { class: "rating-section bg-white my-10 p-5 rounded-md mb-5", "data-type": "shipping" },
115
+ return (h("section", { class: "step rating-section bg-white my-10 p-5 rounded-md mb-5 hidden", "data-type": "shipping" },
103
116
  h("div", { class: "rating-outer-form", "data-stars-error": "\u064A\u0631\u062C\u0649 \u062A\u0642\u064A\u064A\u0645 \u0634\u0631\u0643\u0629 \u0627\u0644\u0634\u062D\u0646 \u0628\u0648\u0627\u0633\u0637\u0629 \u0627\u0644\u0646\u062C\u0645\u0627\u062A" },
104
117
  h("input", { type: "hidden", name: "order_id", value: this.order.order_id }),
105
118
  h("input", { type: "hidden", name: "shipping_company_id", value: this.order.shipping.id }),
@@ -118,18 +131,38 @@ export class OrderRating {
118
131
  this.stars.map((star) => h("button", { type: "submit", class: "btn btn--transparent px-1 text-lg text-gray-400 btn--star", "data-star": star, "data-text": this.order.ratingMessage[`${star}`] },
119
132
  h("i", { class: "sicon-star2" })))));
120
133
  }
121
- //========================= Start Rating Logic =========================//
122
134
  initiateRating() {
123
135
  this.highlightSelectedStars();
124
136
  this.starsRating();
137
+ this.handleWizard();
125
138
  //show submitRating Button Only When there is a comment field
126
- Helper.app.toggle('#submitRating', 'btn', 'hidden', () => Helper.app.element('#shippingReview,#storeReview,.product-review'));
127
- this.ratingChain = Promise.resolve();
128
- Helper.app.onClick('#submitRating', () => this.sendRating().then(() => window.location.reload()));
139
+ // Helper.toggle('#submitRating', 'btn', 'hidden', () => Helper.element('#shippingReview,#storeReview,.product-review'))
140
+ // this.ratingChain = Promise.resolve();
141
+ // Helper.onClick('#submitRating', () => this.sendRating().then(() => window.location.reload()));
142
+ salla.event.on('submit::order-rating', () => this.sendRating().then(() => window.location.reload()));
143
+ }
144
+ handleWizard() {
145
+ let steps = document.querySelectorAll(".step"), stepsCount = document.querySelectorAll(".step").length;
146
+ Helper.onClick("#prev-btn", () => {
147
+ this.wizardInex > 0 && this.wizardInex--;
148
+ this.showActiveStep(steps);
149
+ this.wizardInex == 0 && Helper.toggle('#prev-btn', 'hidden', 'block', () => true);
150
+ });
151
+ Helper.onClick("#next-btn", () => {
152
+ this.ratingValidation();
153
+ this.wizardInex == stepsCount - 1 && salla.event.dispatch("submit::order-rating");
154
+ this.wizardInex < stepsCount - 1 && this.wizardInex++;
155
+ this.showActiveStep(steps);
156
+ Helper.toggle('#prev-btn', 'block', 'hidden', () => true);
157
+ });
158
+ }
159
+ showActiveStep(steps) {
160
+ Helper.toggle('.step', 'hidden', 'active', () => true);
161
+ Helper.toggleElement(steps[this.wizardInex], 'active', 'hidden', () => true);
129
162
  }
130
163
  sendRating() {
131
- this.ratingValidation();
132
- Helper.app.all('.rating-section', ratingSection => {
164
+ // this.ratingValidation()
165
+ Helper.all('.rating-section', ratingSection => {
133
166
  let type = ratingSection.dataset.type;
134
167
  let formsData = [];
135
168
  ratingSection.querySelectorAll('.rating-outer-form')
@@ -159,7 +192,7 @@ export class OrderRating {
159
192
  }
160
193
  ratingValidation() {
161
194
  let errorMsg = '';
162
- document.querySelectorAll('.rating-section')
195
+ document.querySelectorAll('.rating-section.active')
163
196
  .forEach((ratingSection) => {
164
197
  ratingSection.querySelectorAll('.rating-outer-form')
165
198
  .forEach((rating) => {
@@ -200,7 +233,7 @@ export class OrderRating {
200
233
  // for hovered star ---
201
234
  highlightSelectedStars() {
202
235
  let hover = ['hovered', 'text-theme-yellow'];
203
- Helper.app.all('.rate-element', el => {
236
+ Helper.all('.rate-element', el => {
204
237
  let starElements = el.querySelectorAll('.btn--star');
205
238
  // remove hovered state from stars ---
206
239
  el.addEventListener('mouseout', () => el.querySelectorAll('.btn--star').forEach(star => star.classList.remove(...hover)));
@@ -4,6 +4,7 @@ export class SallaButton {
4
4
  constructor() {
5
5
  this.kind = 'primary';
6
6
  this.loading = false;
7
+ this.disabled = false;
7
8
  this.hostAttributes = {};
8
9
  for (let i = 0; i < this.host.attributes.length; i++) {
9
10
  this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
@@ -22,10 +23,10 @@ export class SallaButton {
22
23
  return this.host;
23
24
  }
24
25
  async disable() {
25
- this.btn.setAttribute('disabled', '');
26
+ this.host.setAttribute('disabled', '');
26
27
  }
27
28
  async enable() {
28
- this.btn.removeAttribute('disabled');
29
+ this.host.removeAttribute('disabled');
29
30
  }
30
31
  handleVisible(newKind, oldKind) {
31
32
  this.btn.classList.remove('btn-' + oldKind);
@@ -35,7 +36,7 @@ export class SallaButton {
35
36
  Helper.toggleElement(this.btn, 'btn--is-loading', 'btn--no-loading', () => newVal);
36
37
  }
37
38
  render() {
38
- return (h("button", Object.assign({ ref: el => this.btn = el }, this.hostAttributes),
39
+ return (h("button", Object.assign({ ref: btn => this.btn = btn, disabled: this.disabled }, this.hostAttributes),
39
40
  h("slot", null),
40
41
  this.loading ? h("span", { class: "loader loader--small s-button-loader" }) : ''));
41
42
  }
@@ -82,6 +83,24 @@ export class SallaButton {
82
83
  "attribute": "loading",
83
84
  "reflect": true,
84
85
  "defaultValue": "false"
86
+ },
87
+ "disabled": {
88
+ "type": "boolean",
89
+ "mutable": false,
90
+ "complexType": {
91
+ "original": "boolean",
92
+ "resolved": "boolean",
93
+ "references": {}
94
+ },
95
+ "required": false,
96
+ "optional": false,
97
+ "docs": {
98
+ "tags": [],
99
+ "text": ""
100
+ },
101
+ "attribute": "disabled",
102
+ "reflect": true,
103
+ "defaultValue": "false"
85
104
  }
86
105
  }; }
87
106
  static get methods() { return {
@@ -5,6 +5,12 @@ export class SallaLocalization {
5
5
  Helper.setHost(this.host);
6
6
  salla.event.on('localization::show', () => this.show());
7
7
  }
8
+ setCurrentLanguage(language) {
9
+ this.language = language;
10
+ }
11
+ setCurrentCurrency(currency) {
12
+ this.currency = currency;
13
+ }
8
14
  async show() {
9
15
  return this.modal.show();
10
16
  }
@@ -15,16 +21,13 @@ export class SallaLocalization {
15
21
  let url;
16
22
  this.btn.load()
17
23
  .then(() => {
18
- let code = Helper.val('[name=currency]:checked');
19
- if (code !== salla.config.currency.code) {
24
+ if (this.currency && this.currency.code !== salla.config.currency.code) {
20
25
  url = window.location.href;
21
- return salla.currency.api.change(code);
26
+ return salla.currency.api.change(this.currency.code);
22
27
  }
23
- //binding
24
28
  }).then(() => {
25
- let language = Helper.val('[name=lang]:checked');
26
- if (language !== salla.config.language.code) {
27
- url = salla.config.languages.filter(lang => lang.code === language)[0].url;
29
+ if (this.language && this.language.code !== salla.config.language.code) {
30
+ url = this.language.url;
28
31
  }
29
32
  }).then(() => this.btn.stop())
30
33
  .then(() => this.hide())
@@ -41,7 +44,7 @@ export class SallaLocalization {
41
44
  h("fieldset", { class: "s-localization-fieldset" },
42
45
  h("legend", { class: "sr-only" }, salla.lang.get('blocks.header.change_language')),
43
46
  h("div", { class: "s-localization-section-inner" }, salla.config.languages.map(lang => h("div", { class: "flex items-center" },
44
- h("input", { id: 'lang-' + lang.code.toLowerCase(), class: "s-localization-input", name: "lang", checked: salla.config.language.code == lang.code, type: "radio", value: lang.code }),
47
+ h("input", { class: "s-localization-input", checked: salla.config.language.code == lang.code, onChange: () => this.setCurrentLanguage(lang), id: 'lang-' + lang.code.toLowerCase(), name: "language", type: "radio", value: lang.code }),
45
48
  h("label", { htmlFor: 'lang-' + lang.code.toLowerCase(), class: "s-localization-label" },
46
49
  h("span", null, lang.name),
47
50
  h("div", { class: 's-localization-flag flag iti__flag iti__' + lang.country_code })))))))
@@ -52,7 +55,7 @@ export class SallaLocalization {
52
55
  h("fieldset", { class: "s-localization-fieldset" },
53
56
  h("legend", { class: "sr-only" }, salla.lang.get('blocks.header.change_currency')),
54
57
  h("div", { class: "s-localization-section-inner" }, salla.config.currencies.map(currency => h("div", { class: "s-localization-item" },
55
- h("input", { class: "s-localization-input", checked: salla.config.currency.code == currency.code, id: 'currency-' + currency.code, name: "currency", type: "radio", value: currency.code }),
58
+ h("input", { class: "s-localization-input", checked: salla.config.currency.code == currency.code, onChange: () => this.setCurrentCurrency(currency), id: 'currency-' + currency.code, name: "currency", type: "radio", value: currency.code }),
56
59
  h("label", { class: "s-localization-label", htmlFor: 'currency-' + currency.code },
57
60
  h("span", null, currency.name),
58
61
  h("small", { class: "s-localization-currency" }, currency.code)))))))
@@ -12,6 +12,8 @@ export class SallaModal {
12
12
  this.icon = 'sicon-cancel';
13
13
  salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
14
14
  salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
15
+ this.title = this.host.title;
16
+ this.host.removeAttribute('title');
15
17
  }
16
18
  handleVisible(newValue) {
17
19
  if (!newValue) {
@@ -31,6 +33,10 @@ export class SallaModal {
31
33
  this.host.removeAttribute('visible');
32
34
  return this.host;
33
35
  }
36
+ async setTitle(title) {
37
+ this.title = title;
38
+ return this.host;
39
+ }
34
40
  toggleModal(isOpen) {
35
41
  Helper.toggleElement(this.host.querySelector('.s-modal-overlay'), 'ease-out duration-300 opacity-100', 'opacity-0', () => isOpen)
36
42
  .toggleElement(this.host.querySelector('.s-modal-body'), 'ease-out duration-300 opacity-100 translate-y-0 sm:scale-100', //add these classes
@@ -68,7 +74,7 @@ export class SallaModal {
68
74
  's-modal-text-success': this.success
69
75
  } }))
70
76
  : '',
71
- h("div", { class: "s-modal-title", innerHTML: this.host.title }),
77
+ h("div", { class: "s-modal-title", innerHTML: this.title }),
72
78
  h("p", { class: "s-modal-sub-title", innerHTML: this.subTitle }))),
73
79
  h("slot", null),
74
80
  h("slot", { name: "footer" })))));
@@ -271,6 +277,28 @@ export class SallaModal {
271
277
  "text": "",
272
278
  "tags": []
273
279
  }
280
+ },
281
+ "setTitle": {
282
+ "complexType": {
283
+ "signature": "(title: any) => Promise<HTMLElement>",
284
+ "parameters": [{
285
+ "tags": [],
286
+ "text": ""
287
+ }],
288
+ "references": {
289
+ "Promise": {
290
+ "location": "global"
291
+ },
292
+ "HTMLElement": {
293
+ "location": "global"
294
+ }
295
+ },
296
+ "return": "Promise<HTMLElement>"
297
+ },
298
+ "docs": {
299
+ "text": "",
300
+ "tags": []
301
+ }
274
302
  }
275
303
  }; }
276
304
  static get elementRef() { return "host"; }