@salla.sa/twilight-components 2.9.2 → 2.9.3

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.
@@ -61,15 +61,12 @@ const SallaAddProductButton = class {
61
61
  const data = Object.entries({
62
62
  id: this.productId,
63
63
  donating_amount: this.donatingAmount,
64
- quantity: this.quantity
64
+ quantity: this.quantity,
65
+ endpoint: 'quickAdd'
65
66
  }).reduce((a, [k, v]) => (v ? (a[k] = v, a) : a), {});
66
- return salla.cart.quickAdd(data)
67
- .then((response) => {
68
- return this.success.emit(response);
69
- })
70
- .catch((error) => {
71
- return this.failed.emit(error);
72
- });
67
+ return salla.cart.addItem(data)
68
+ .then(response => this.success.emit(response))
69
+ .catch(error => this.failed.emit(error));
73
70
  }
74
71
  getBtnAttributes() {
75
72
  for (let i = 0; i < this.host.attributes.length; i++) {
@@ -170,7 +170,7 @@ const SallaCommentForm = class {
170
170
  return;
171
171
  }
172
172
  this.submitBtn.load()
173
- .then(() => salla.comment.add({ id: this.itemId, comment: this.commmentField.value, type: this.type }))
173
+ .then(() => salla.comment.add({ id: this.itemId, comment: this.commentField.value, type: this.type }))
174
174
  .finally(() => this.submitBtn.stop);
175
175
  }
176
176
  handleKeyDown(ev) {
@@ -180,7 +180,7 @@ const SallaCommentForm = class {
180
180
  }
181
181
  }
182
182
  render() {
183
- return (index$1.h(index$1.Host, null, !!this.canComment ? index$1.h("form", { ref: frm => this.commentForm = frm }, index$1.h("textarea", { required: true, rows: 5, cols: 30, minlength: "4", maxlength: "500", placeholder: this.placeholder, onKeyDown: e => this.handleKeyDown(e), ref: field => this.commmentField = field, class: "s-comment-form-input" }), index$1.h("br", null), index$1.h("div", { class: "s-comment-form-action" }, index$1.h("salla-button", { ref: btn => this.submitBtn = btn, "loader-position": 'center', onClick: () => this.submit() }, this.submitText))) : ''));
183
+ return (index$1.h(index$1.Host, null, !!this.canComment ? index$1.h("form", { ref: frm => this.commentForm = frm }, index$1.h("textarea", { required: true, rows: 5, cols: 30, minlength: "4", maxlength: "500", placeholder: this.placeholder, onKeyDown: e => this.handleKeyDown(e), ref: field => this.commentField = field, class: "s-comment-form-input" }), index$1.h("br", null), index$1.h("div", { class: "s-comment-form-action" }, index$1.h("salla-button", { ref: btn => this.submitBtn = btn, "loader-position": 'center', onClick: () => this.submit() }, this.submitText))) : ''));
184
184
  }
185
185
  };
186
186
  SallaCommentForm.style = sallaCommentFormCss;
@@ -51,15 +51,12 @@ export class SallaAddProductButton {
51
51
  const data = Object.entries({
52
52
  id: this.productId,
53
53
  donating_amount: this.donatingAmount,
54
- quantity: this.quantity
54
+ quantity: this.quantity,
55
+ endpoint: 'quickAdd'
55
56
  }).reduce((a, [k, v]) => (v ? (a[k] = v, a) : a), {});
56
- return salla.cart.quickAdd(data)
57
- .then((response) => {
58
- return this.success.emit(response);
59
- })
60
- .catch((error) => {
61
- return this.failed.emit(error);
62
- });
57
+ return salla.cart.addItem(data)
58
+ .then(response => this.success.emit(response))
59
+ .catch(error => this.failed.emit(error));
63
60
  }
64
61
  getBtnAttributes() {
65
62
  for (let i = 0; i < this.host.attributes.length; i++) {
@@ -26,7 +26,7 @@ export class SallaCommentForm {
26
26
  return;
27
27
  }
28
28
  this.submitBtn.load()
29
- .then(() => salla.comment.add({ id: this.itemId, comment: this.commmentField.value, type: this.type }))
29
+ .then(() => salla.comment.add({ id: this.itemId, comment: this.commentField.value, type: this.type }))
30
30
  .finally(() => this.submitBtn.stop);
31
31
  }
32
32
  handleKeyDown(ev) {
@@ -37,7 +37,7 @@ export class SallaCommentForm {
37
37
  }
38
38
  render() {
39
39
  return (h(Host, null, !!this.canComment ? h("form", { ref: frm => this.commentForm = frm },
40
- h("textarea", { required: true, rows: 5, cols: 30, minlength: "4", maxlength: "500", placeholder: this.placeholder, onKeyDown: e => this.handleKeyDown(e), ref: field => this.commmentField = field, class: "s-comment-form-input" }),
40
+ h("textarea", { required: true, rows: 5, cols: 30, minlength: "4", maxlength: "500", placeholder: this.placeholder, onKeyDown: e => this.handleKeyDown(e), ref: field => this.commentField = field, class: "s-comment-form-input" }),
41
41
  h("br", null),
42
42
  h("div", { class: "s-comment-form-action" },
43
43
  h("salla-button", { ref: btn => this.submitBtn = btn, "loader-position": 'center', onClick: () => this.submit() }, this.submitText))) : ''));
@@ -63,15 +63,12 @@ const SallaAddProductButton$1 = /*@__PURE__*/ proxyCustomElement(class extends H
63
63
  const data = Object.entries({
64
64
  id: this.productId,
65
65
  donating_amount: this.donatingAmount,
66
- quantity: this.quantity
66
+ quantity: this.quantity,
67
+ endpoint: 'quickAdd'
67
68
  }).reduce((a, [k, v]) => (v ? (a[k] = v, a) : a), {});
68
- return salla.cart.quickAdd(data)
69
- .then((response) => {
70
- return this.success.emit(response);
71
- })
72
- .catch((error) => {
73
- return this.failed.emit(error);
74
- });
69
+ return salla.cart.addItem(data)
70
+ .then(response => this.success.emit(response))
71
+ .catch(error => this.failed.emit(error));
75
72
  }
76
73
  getBtnAttributes() {
77
74
  for (let i = 0; i < this.host.attributes.length; i++) {
@@ -32,7 +32,7 @@ const SallaCommentForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
32
32
  return;
33
33
  }
34
34
  this.submitBtn.load()
35
- .then(() => salla.comment.add({ id: this.itemId, comment: this.commmentField.value, type: this.type }))
35
+ .then(() => salla.comment.add({ id: this.itemId, comment: this.commentField.value, type: this.type }))
36
36
  .finally(() => this.submitBtn.stop);
37
37
  }
38
38
  handleKeyDown(ev) {
@@ -42,7 +42,7 @@ const SallaCommentForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
42
42
  }
43
43
  }
44
44
  render() {
45
- return (h(Host, null, !!this.canComment ? h("form", { ref: frm => this.commentForm = frm }, h("textarea", { required: true, rows: 5, cols: 30, minlength: "4", maxlength: "500", placeholder: this.placeholder, onKeyDown: e => this.handleKeyDown(e), ref: field => this.commmentField = field, class: "s-comment-form-input" }), h("br", null), h("div", { class: "s-comment-form-action" }, h("salla-button", { ref: btn => this.submitBtn = btn, "loader-position": 'center', onClick: () => this.submit() }, this.submitText))) : ''));
45
+ return (h(Host, null, !!this.canComment ? h("form", { ref: frm => this.commentForm = frm }, h("textarea", { required: true, rows: 5, cols: 30, minlength: "4", maxlength: "500", placeholder: this.placeholder, onKeyDown: e => this.handleKeyDown(e), ref: field => this.commentField = field, class: "s-comment-form-input" }), h("br", null), h("div", { class: "s-comment-form-action" }, h("salla-button", { ref: btn => this.submitBtn = btn, "loader-position": 'center', onClick: () => this.submit() }, this.submitText))) : ''));
46
46
  }
47
47
  static get style() { return sallaCommentFormCss; }
48
48
  }, [0, "salla-comment-form", {
@@ -57,15 +57,12 @@ const SallaAddProductButton = class {
57
57
  const data = Object.entries({
58
58
  id: this.productId,
59
59
  donating_amount: this.donatingAmount,
60
- quantity: this.quantity
60
+ quantity: this.quantity,
61
+ endpoint: 'quickAdd'
61
62
  }).reduce((a, [k, v]) => (v ? (a[k] = v, a) : a), {});
62
- return salla.cart.quickAdd(data)
63
- .then((response) => {
64
- return this.success.emit(response);
65
- })
66
- .catch((error) => {
67
- return this.failed.emit(error);
68
- });
63
+ return salla.cart.addItem(data)
64
+ .then(response => this.success.emit(response))
65
+ .catch(error => this.failed.emit(error));
69
66
  }
70
67
  getBtnAttributes() {
71
68
  for (let i = 0; i < this.host.attributes.length; i++) {
@@ -166,7 +166,7 @@ const SallaCommentForm = class {
166
166
  return;
167
167
  }
168
168
  this.submitBtn.load()
169
- .then(() => salla.comment.add({ id: this.itemId, comment: this.commmentField.value, type: this.type }))
169
+ .then(() => salla.comment.add({ id: this.itemId, comment: this.commentField.value, type: this.type }))
170
170
  .finally(() => this.submitBtn.stop);
171
171
  }
172
172
  handleKeyDown(ev) {
@@ -176,7 +176,7 @@ const SallaCommentForm = class {
176
176
  }
177
177
  }
178
178
  render() {
179
- return (h(Host, null, !!this.canComment ? h("form", { ref: frm => this.commentForm = frm }, h("textarea", { required: true, rows: 5, cols: 30, minlength: "4", maxlength: "500", placeholder: this.placeholder, onKeyDown: e => this.handleKeyDown(e), ref: field => this.commmentField = field, class: "s-comment-form-input" }), h("br", null), h("div", { class: "s-comment-form-action" }, h("salla-button", { ref: btn => this.submitBtn = btn, "loader-position": 'center', onClick: () => this.submit() }, this.submitText))) : ''));
179
+ return (h(Host, null, !!this.canComment ? h("form", { ref: frm => this.commentForm = frm }, h("textarea", { required: true, rows: 5, cols: 30, minlength: "4", maxlength: "500", placeholder: this.placeholder, onKeyDown: e => this.handleKeyDown(e), ref: field => this.commentField = field, class: "s-comment-form-input" }), h("br", null), h("div", { class: "s-comment-form-action" }, h("salla-button", { ref: btn => this.submitBtn = btn, "loader-position": 'center', onClick: () => this.submit() }, this.submitText))) : ''));
180
180
  }
181
181
  };
182
182
  SallaCommentForm.style = sallaCommentFormCss;
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as registerInstance,c as createEvent,h,H as Host,g as getElement}from"./index-0ce70ad2.js";var sallaAddProductButtonCss=":host{display:block}salla-add-product-button[width=wide]{width:100%}";var SallaAddProductButton=function(){function t(t){registerInstance(this,t);this.success=createEvent(this,"success",7);this.failed=createEvent(this,"failed",7);this.hostAttributes={};this.hasLabel=false;this.channels=null;this.quantity=0;this.donatingAmount=0;this.productStatus="sale";this.productType="product"}t.prototype.getLabel=function(){if(this.productStatus==="sale"){return salla.lang.get("pages.cart.add_to_cart")}if(this.productType!=="donating"){return salla.lang.get("pages.products.out_of_stock")}return salla.lang.get("pages.products.donation_exceed")};t.prototype.addProductToCart=function(t){var e=this;if(this.hostAttributes["type"]==="submit"){return false}t.preventDefault();var s=Object.entries({id:this.productId,donating_amount:this.donatingAmount,quantity:this.quantity}).reduce((function(t,e){var s=e[0],a=e[1];return a?(t[s]=a,t):t}),{});return salla.cart.quickAdd(s).then((function(t){return e.success.emit(t)})).catch((function(t){return e.failed.emit(t)}))};t.prototype.getBtnAttributes=function(){for(var t=0;t<this.host.attributes.length;t++){if(!["id","class"].includes(this.host.attributes[t].name)){this.hostAttributes[this.host.attributes[t].name]=this.host.attributes[t].value}}return this.hostAttributes};t.prototype.componentWillLoad=function(){this.hasLabel=!!this.host.innerHTML.replace("\x3c!----\x3e","").trim()};t.prototype.render=function(){var t=this;return h(Host,null,this.productStatus==="out-and-notify"&&this.channels?h("salla-product-availability",Object.assign({},this.getBtnAttributes()),h("slot",null)):h("salla-button",Object.assign({ref:function(e){return t.btn=e},onClick:function(e){return t.addProductToCart(e)},type:"button",fill:this.productStatus==="sale"?"solid":"outline",color:this.productStatus==="sale"?"primary":"light","loader-position":"center"},this.getBtnAttributes(),{disabled:this.productStatus!=="sale"}),h("slot",null)))};t.prototype.componentDidRender=function(){var t=this;if(this.hasLabel){return}this.btn.setText(this.getLabel()||"اضافة للسلة");salla.lang.onLoaded((function(){t.btn.setText(t.getLabel()||"اضافة للسلة")}))};Object.defineProperty(t.prototype,"host",{get:function(){return getElement(this)},enumerable:false,configurable:true});return t}();SallaAddProductButton.style=sallaAddProductButtonCss;export{SallaAddProductButton as salla_add_product_button};
4
+ import{r as registerInstance,c as createEvent,h,H as Host,g as getElement}from"./index-0ce70ad2.js";var sallaAddProductButtonCss=":host{display:block}salla-add-product-button[width=wide]{width:100%}";var SallaAddProductButton=function(){function t(t){registerInstance(this,t);this.success=createEvent(this,"success",7);this.failed=createEvent(this,"failed",7);this.hostAttributes={};this.hasLabel=false;this.channels=null;this.quantity=0;this.donatingAmount=0;this.productStatus="sale";this.productType="product"}t.prototype.getLabel=function(){if(this.productStatus==="sale"){return salla.lang.get("pages.cart.add_to_cart")}if(this.productType!=="donating"){return salla.lang.get("pages.products.out_of_stock")}return salla.lang.get("pages.products.donation_exceed")};t.prototype.addProductToCart=function(t){var e=this;if(this.hostAttributes["type"]==="submit"){return false}t.preventDefault();var s=Object.entries({id:this.productId,donating_amount:this.donatingAmount,quantity:this.quantity,endpoint:"quickAdd"}).reduce((function(t,e){var s=e[0],a=e[1];return a?(t[s]=a,t):t}),{});return salla.cart.addItem(s).then((function(t){return e.success.emit(t)})).catch((function(t){return e.failed.emit(t)}))};t.prototype.getBtnAttributes=function(){for(var t=0;t<this.host.attributes.length;t++){if(!["id","class"].includes(this.host.attributes[t].name)){this.hostAttributes[this.host.attributes[t].name]=this.host.attributes[t].value}}return this.hostAttributes};t.prototype.componentWillLoad=function(){this.hasLabel=!!this.host.innerHTML.replace("\x3c!----\x3e","").trim()};t.prototype.render=function(){var t=this;return h(Host,null,this.productStatus==="out-and-notify"&&this.channels?h("salla-product-availability",Object.assign({},this.getBtnAttributes()),h("slot",null)):h("salla-button",Object.assign({ref:function(e){return t.btn=e},onClick:function(e){return t.addProductToCart(e)},type:"button",fill:this.productStatus==="sale"?"solid":"outline",color:this.productStatus==="sale"?"primary":"light","loader-position":"center"},this.getBtnAttributes(),{disabled:this.productStatus!=="sale"}),h("slot",null)))};t.prototype.componentDidRender=function(){var t=this;if(this.hasLabel){return}this.btn.setText(this.getLabel()||"اضافة للسلة");salla.lang.onLoaded((function(){t.btn.setText(t.getLabel()||"اضافة للسلة")}))};Object.defineProperty(t.prototype,"host",{get:function(){return getElement(this)},enumerable:false,configurable:true});return t}();SallaAddProductButton.style=sallaAddProductButtonCss;export{SallaAddProductButton as salla_add_product_button};