@salla.sa/twilight-components 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Helper-8ae6a805.js +28 -0
- package/dist/cjs/arrow-right-3d137e4c.js +13 -0
- package/dist/cjs/cancel-ae668d91.js +13 -0
- package/dist/cjs/check-circle2-1aac98d1.js +13 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mail-2db058ee.js +13 -0
- package/dist/cjs/salla-add-product-button_13.cjs.entry.js +2870 -0
- package/dist/cjs/salla-infinite-scroll.cjs.entry.js +93 -0
- package/dist/cjs/salla-list-tile_2.cjs.entry.js +80 -0
- package/dist/cjs/salla-loyalty.cjs.entry.js +229 -0
- package/dist/cjs/salla-product-size-guide.cjs.entry.js +52 -0
- package/dist/cjs/salla-quantity-input.cjs.entry.js +101 -0
- package/dist/cjs/salla-rating-modal.cjs.entry.js +169 -0
- package/dist/cjs/salla-social-share.cjs.entry.js +1447 -0
- package/dist/cjs/salla-swiper.cjs.entry.js +5023 -0
- package/dist/cjs/salla-tab-content_3.cjs.entry.js +159 -0
- package/dist/cjs/star2-8288e6e1.js +13 -0
- package/dist/cjs/twilight-components.cjs.js +1 -1
- package/dist/collection/components/salla-login-modal/salla-login-modal.js +4 -3
- package/dist/components/salla-login-modal.js +4 -3
- package/dist/esm/Helper-e1d414a5.js +26 -0
- package/dist/esm/arrow-right-1c3e04f2.js +11 -0
- package/dist/esm/cancel-41a92070.js +11 -0
- package/dist/esm/check-circle2-f6e5f685.js +11 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mail-9d5204c6.js +11 -0
- package/dist/esm/salla-add-product-button_13.entry.js +2854 -0
- package/dist/esm/salla-infinite-scroll.entry.js +89 -0
- package/dist/esm/salla-list-tile_2.entry.js +75 -0
- package/dist/esm/salla-loyalty.entry.js +225 -0
- package/dist/esm/salla-product-size-guide.entry.js +48 -0
- package/dist/esm/salla-quantity-input.entry.js +97 -0
- package/dist/esm/salla-rating-modal.entry.js +165 -0
- package/dist/esm/salla-social-share.entry.js +1443 -0
- package/dist/esm/salla-swiper.entry.js +5019 -0
- package/dist/esm/salla-tab-content_3.entry.js +153 -0
- package/dist/esm/star2-b134fc74.js +11 -0
- package/dist/esm/twilight-components.js +1 -1
- package/dist/twilight-components/p-14f0ff17.entry.js +4 -0
- package/dist/twilight-components/p-2749c9d3.entry.js +4 -0
- package/dist/twilight-components/p-335abbbb.entry.js +4 -0
- package/dist/twilight-components/p-4cafb11b.entry.js +4 -0
- package/dist/twilight-components/p-5e63e308.entry.js +4 -0
- package/dist/twilight-components/p-648e74e5.entry.js +4 -0
- package/dist/twilight-components/p-897b2018.js +4 -0
- package/dist/twilight-components/p-93708e1e.js +4 -0
- package/dist/twilight-components/p-9d236cf4.entry.js +4 -0
- package/dist/twilight-components/p-9d2ca9c8.js +4 -0
- package/dist/twilight-components/p-af7d5660.js +4 -0
- package/dist/twilight-components/p-bdbd2386.entry.js +4 -0
- package/dist/twilight-components/p-cac3db69.entry.js +4 -0
- package/dist/twilight-components/p-d914a212.js +4 -0
- package/dist/twilight-components/p-dace8e6d.js +4 -0
- package/dist/twilight-components/p-f9253fda.entry.js +4 -0
- package/dist/twilight-components/twilight-components.esm.js +1 -1
- package/package.json +2 -2
- package/dist/cjs/salla-add-product-button.cjs.entry.js +0 -104
- package/dist/cjs/salla-button_24.cjs.entry.js +0 -10087
- package/dist/esm/salla-add-product-button.entry.js +0 -100
- package/dist/esm/salla-button_24.entry.js +0 -10060
- package/dist/twilight-components/p-30b2c5b0.entry.js +0 -4
- package/dist/twilight-components/p-76cb2574.entry.js +0 -4
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Crafted with ❤ by Salla
|
|
3
|
-
*/
|
|
4
|
-
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-4e30ffd0.js';
|
|
5
|
-
|
|
6
|
-
const sallaAddProductButtonCss = ":host{display:block}salla-add-product-button[width=wide]{width:100%}";
|
|
7
|
-
|
|
8
|
-
const SallaAddProductButton = class {
|
|
9
|
-
constructor(hostRef) {
|
|
10
|
-
registerInstance(this, hostRef);
|
|
11
|
-
this.success = createEvent(this, "success", 7);
|
|
12
|
-
this.failed = createEvent(this, "failed", 7);
|
|
13
|
-
this.hostAttributes = {};
|
|
14
|
-
this.hasLabel = false;
|
|
15
|
-
/**
|
|
16
|
-
* Channels.
|
|
17
|
-
*/
|
|
18
|
-
this.channels = null;
|
|
19
|
-
/**
|
|
20
|
-
* Product Quantity
|
|
21
|
-
*/
|
|
22
|
-
this.quantity = 0;
|
|
23
|
-
/**
|
|
24
|
-
* Donating amount.
|
|
25
|
-
*/
|
|
26
|
-
this.donatingAmount = 0;
|
|
27
|
-
/**
|
|
28
|
-
* Product Status.Defaults to `sale`
|
|
29
|
-
*/
|
|
30
|
-
this.productStatus = 'sale';
|
|
31
|
-
/**
|
|
32
|
-
* Product type. Defaults to `product`
|
|
33
|
-
*/
|
|
34
|
-
this.productType = 'product';
|
|
35
|
-
}
|
|
36
|
-
getLabel() {
|
|
37
|
-
if (this.productStatus === 'sale') {
|
|
38
|
-
return salla.lang.get('pages.cart.add_to_cart');
|
|
39
|
-
}
|
|
40
|
-
if (this.productType !== 'donating') {
|
|
41
|
-
return salla.lang.get('pages.products.out_of_stock');
|
|
42
|
-
}
|
|
43
|
-
// donating
|
|
44
|
-
return salla.lang.get('pages.products.donation_exceed');
|
|
45
|
-
}
|
|
46
|
-
addProductToCart(event) {
|
|
47
|
-
// we want to ignore the click action when the type of button is submit a form
|
|
48
|
-
if (this.hostAttributes['type'] === 'submit') {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
event.preventDefault();
|
|
52
|
-
/**
|
|
53
|
-
* by default the quick add is just an alias for add item function
|
|
54
|
-
* but its work only when the id is the only value is passed via the object
|
|
55
|
-
* so we will filter the object entities to remove null and zero values in case we don't want the normal add item action
|
|
56
|
-
*/
|
|
57
|
-
const data = Object.entries({
|
|
58
|
-
id: this.productId,
|
|
59
|
-
donating_amount: this.donatingAmount,
|
|
60
|
-
quantity: this.quantity
|
|
61
|
-
}).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
|
-
});
|
|
69
|
-
}
|
|
70
|
-
getBtnAttributes() {
|
|
71
|
-
for (let i = 0; i < this.host.attributes.length; i++) {
|
|
72
|
-
if (!['id', 'class'].includes(this.host.attributes[i].name)) {
|
|
73
|
-
this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return this.hostAttributes;
|
|
77
|
-
}
|
|
78
|
-
componentWillLoad() {
|
|
79
|
-
this.hasLabel = !!this.host.innerHTML.replace('<!---->', '').trim();
|
|
80
|
-
}
|
|
81
|
-
render() {
|
|
82
|
-
return (h(Host, null, this.productStatus === 'out-and-notify' && this.channels ?
|
|
83
|
-
h("salla-product-availability", Object.assign({}, this.getBtnAttributes()), h("slot", null)) :
|
|
84
|
-
h("salla-button", Object.assign({ ref: el => this.btn = el, onClick: event => this.addProductToCart(event), 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))));
|
|
85
|
-
}
|
|
86
|
-
componentDidRender() {
|
|
87
|
-
//if label not passed, get label
|
|
88
|
-
if (this.hasLabel) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
this.btn.setText(this.getLabel() || 'اضافة للسلة');
|
|
92
|
-
salla.lang.onLoaded(() => {
|
|
93
|
-
this.btn.setText(this.getLabel() || 'اضافة للسلة');
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
get host() { return getElement(this); }
|
|
97
|
-
};
|
|
98
|
-
SallaAddProductButton.style = sallaAddProductButtonCss;
|
|
99
|
-
|
|
100
|
-
export { SallaAddProductButton as salla_add_product_button };
|