@salla.sa/twilight-components 1.6.1 → 1.6.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.
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/salla-add-product-button.cjs.entry.js +104 -0
- package/dist/cjs/salla-button_24.cjs.entry.js +10087 -0
- package/dist/cjs/twilight-components.cjs.js +1 -1
- package/dist/collection/components/salla-login-modal/salla-login-modal.js +3 -4
- package/dist/components/salla-login-modal.js +3 -4
- package/dist/esm/loader.js +1 -1
- package/dist/esm/salla-add-product-button.entry.js +100 -0
- package/dist/esm/salla-button_24.entry.js +10060 -0
- package/dist/esm/twilight-components.js +1 -1
- package/dist/twilight-components/p-30b2c5b0.entry.js +4 -0
- package/dist/twilight-components/p-76cb2574.entry.js +4 -0
- package/dist/twilight-components/twilight-components.esm.js +1 -1
- package/package.json +9 -3
- package/dist/cjs/Helper-8ae6a805.js +0 -28
- package/dist/cjs/arrow-right-3d137e4c.js +0 -13
- package/dist/cjs/cancel-ae668d91.js +0 -13
- package/dist/cjs/check-circle2-1aac98d1.js +0 -13
- package/dist/cjs/mail-2db058ee.js +0 -13
- package/dist/cjs/salla-add-product-button_13.cjs.entry.js +0 -2870
- package/dist/cjs/salla-infinite-scroll.cjs.entry.js +0 -93
- package/dist/cjs/salla-list-tile_2.cjs.entry.js +0 -80
- package/dist/cjs/salla-loyalty.cjs.entry.js +0 -229
- package/dist/cjs/salla-product-size-guide.cjs.entry.js +0 -52
- package/dist/cjs/salla-quantity-input.cjs.entry.js +0 -101
- package/dist/cjs/salla-rating-modal.cjs.entry.js +0 -169
- package/dist/cjs/salla-social-share.cjs.entry.js +0 -1447
- package/dist/cjs/salla-swiper.cjs.entry.js +0 -5023
- package/dist/cjs/salla-tab-content_3.cjs.entry.js +0 -159
- package/dist/cjs/star2-8288e6e1.js +0 -13
- package/dist/esm/Helper-e1d414a5.js +0 -26
- package/dist/esm/arrow-right-1c3e04f2.js +0 -11
- package/dist/esm/cancel-41a92070.js +0 -11
- package/dist/esm/check-circle2-f6e5f685.js +0 -11
- package/dist/esm/mail-9d5204c6.js +0 -11
- package/dist/esm/salla-add-product-button_13.entry.js +0 -2854
- package/dist/esm/salla-infinite-scroll.entry.js +0 -89
- package/dist/esm/salla-list-tile_2.entry.js +0 -75
- package/dist/esm/salla-loyalty.entry.js +0 -225
- package/dist/esm/salla-product-size-guide.entry.js +0 -48
- package/dist/esm/salla-quantity-input.entry.js +0 -97
- package/dist/esm/salla-rating-modal.entry.js +0 -165
- package/dist/esm/salla-social-share.entry.js +0 -1443
- package/dist/esm/salla-swiper.entry.js +0 -5019
- package/dist/esm/salla-tab-content_3.entry.js +0 -153
- package/dist/esm/star2-b134fc74.js +0 -11
- package/dist/twilight-components/p-14f0ff17.entry.js +0 -4
- package/dist/twilight-components/p-2749c9d3.entry.js +0 -4
- package/dist/twilight-components/p-335abbbb.entry.js +0 -4
- package/dist/twilight-components/p-4cafb11b.entry.js +0 -4
- package/dist/twilight-components/p-5e63e308.entry.js +0 -4
- package/dist/twilight-components/p-648e74e5.entry.js +0 -4
- package/dist/twilight-components/p-897b2018.js +0 -4
- package/dist/twilight-components/p-93708e1e.js +0 -4
- package/dist/twilight-components/p-9d236cf4.entry.js +0 -4
- package/dist/twilight-components/p-9d2ca9c8.js +0 -4
- package/dist/twilight-components/p-af7d5660.js +0 -4
- package/dist/twilight-components/p-bdbd2386.entry.js +0 -4
- package/dist/twilight-components/p-cac3db69.entry.js +0 -4
- package/dist/twilight-components/p-d914a212.js +0 -4
- package/dist/twilight-components/p-dace8e6d.js +0 -4
- package/dist/twilight-components/p-f9253fda.entry.js +0 -4
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -17,7 +17,7 @@ const patchEsm = () => {
|
|
|
17
17
|
const defineCustomElements = (win, options) => {
|
|
18
18
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
19
19
|
return patchEsm().then(() => {
|
|
20
|
-
return index.bootstrapLazy([["salla-
|
|
20
|
+
return index.bootstrapLazy([["salla-button_24.cjs",[[4,"salla-loyalty",{"prizePoints":[8,"prize-points"],"customerPoints":[2,"customer-points"],"prizeTitle":[1,"prize-title"],"allowEmail":[4,"allow-email"],"allowMobile":[4,"allow-mobile"],"requireEmail":[4,"require-email"],"guestMessage":[1,"guest-message"],"loyaltyProgram":[32],"buttonLoading":[32],"selectedItem":[32],"askConfirmation":[32],"is_loggedin":[32],"translationLoaded":[32],"open":[64],"close":[64],"resetExchange":[64],"exchangeLoyaltyPoint":[64]}],[4,"salla-product-size-guide",{"guides":[32],"productId":[32],"open":[64],"close":[64]}],[4,"salla-login-modal",{"isEmailAllowed":[1028,"is-email-allowed"],"isMobileAllowed":[1028,"is-mobile-allowed"],"isEmailRequired":[1028,"is-email-required"],"translationLoaded":[32],"title":[32],"emailErrorMsg":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"open":[64]},[[8,"verified","onVerified"]]],[0,"salla-localization-modal",{"language":[1537],"currency":[1537],"translationLoaded":[32],"languages":[32],"currencies":[32],"isLoading":[32],"open":[64],"close":[64],"submit":[64]}],[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"translationLoaded":[32],"open":[64],"close":[64]}],[0,"salla-offer-modal",{"offer":[32],"offer_name":[32],"offer_message":[32],"translationLoaded":[32],"open":[64],"showOffer":[64]}],[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"translationLoaded":[32],"results":[32],"loading":[32],"typing":[32],"debounce":[32],"search_term":[32]},[[0,"keydown","handleKeyDown"]]],[4,"salla-social-share",{"url":[513],"urlName":[513,"url-name"],"platforms":[16],"opened":[32],"allPlatforms":[32],"platformIcons":[32],"open":[64]}],[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[1028],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}],[4,"salla-quantity-input",{"quantity":[32],"decrease":[64],"increase":[64],"setValue":[64]}],[0,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"translationLoaded":[32],"title_":[32],"isVisitorSubscribed":[32]}],[4,"salla-verify",{"display":[1],"type":[1025],"autoReload":[4,"auto-reload"],"translationLoaded":[32],"title":[32],"resendAfter":[32],"isProfileVerify":[32],"getCode":[64],"open":[64]}],[4,"salla-swiper",{"loop":[4],"speed":[2],"itemPerView":[8,"item-per-view"],"spaceBetweenItems":[2,"space-between-items"],"currentIndex":[32],"isLastSlideItem":[32],"isFirstSlideItem":[32]}],[0,"salla-rating-stars",{"name":[1],"size":[1],"value":[2]}],[4,"salla-list-tile",{"href":[1],"target":[1]}],[4,"salla-tab-content",{"name":[1],"isSelected":[32],"getChild":[64]}],[4,"salla-tab-header",{"name":[1],"activeClass":[1,"active-class"],"height":[8],"centered":[4],"isSelected":[32],"getChild":[64]}],[4,"salla-tabs",{"backgroundColor":[1,"background-color"],"vertical":[4]},[[0,"tabSelected","onSelectedTab"]]],[4,"salla-placeholder",{"icon":[1],"alignment":[1],"iconSize":[1,"icon-size"],"translationLoaded":[32]}],[0,"salla-tel-input",{"phone":[1025],"name":[1],"countryCode":[1025,"country-code"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}],[0,"salla-skeleton",{"type":[1],"width":[1],"height":[1]}],[4,"salla-modal",{"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"hasSkeleton":[516,"has-skeleton"],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"centered":[4],"iconStyle":[1,"icon-style"],"modalTitle":[32],"open":[64],"close":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}],[4,"salla-button",{"shape":[513],"color":[513],"fill":[513],"size":[513],"width":[513],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"href":[1],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}],[0,"salla-loading",{"size":[8],"width":[8],"color":[1],"bgColor":[1,"bg-color"]}]]],["salla-scopes.cjs",[[4,"salla-scopes",{"selection":[1],"searchDisplayLimit":[2,"search-display-limit"],"translationLoaded":[32],"mode":[32],"current_scope":[32],"scopes":[32],"originalScopesList":[32],"selected_scope":[32],"isOpenedBefore":[32],"close":[64],"open":[64],"handleSubmit":[64]}]]],["salla-add-product-button.cjs",[[4,"salla-add-product-button",{"channels":[513],"quantity":[514],"donatingAmount":[514,"donating-amount"],"productId":[520,"product-id"],"productStatus":[513,"product-status"],"productType":[513,"product-type"]}]]],["salla-conditional-fields.cjs",[[4,"salla-conditional-fields",null,[[0,"change","changeHandler"]]]]],["salla-installment.cjs",[[0,"salla-installment",{"price":[1],"language":[1],"currency":[1],"tamaraIsActive":[32],"tabbyIsActive":[32],"spotiiIsActive":[32]}]]]], options);
|
|
21
21
|
});
|
|
22
22
|
};
|
|
23
23
|
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Crafted with ❤ by Salla
|
|
3
|
+
*/
|
|
4
|
+
'use strict';
|
|
5
|
+
|
|
6
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
7
|
+
|
|
8
|
+
const index = require('./index-0d0167d5.js');
|
|
9
|
+
|
|
10
|
+
const sallaAddProductButtonCss = ":host{display:block}salla-add-product-button[width=wide]{width:100%}";
|
|
11
|
+
|
|
12
|
+
const SallaAddProductButton = class {
|
|
13
|
+
constructor(hostRef) {
|
|
14
|
+
index.registerInstance(this, hostRef);
|
|
15
|
+
this.success = index.createEvent(this, "success", 7);
|
|
16
|
+
this.failed = index.createEvent(this, "failed", 7);
|
|
17
|
+
this.hostAttributes = {};
|
|
18
|
+
this.hasLabel = false;
|
|
19
|
+
/**
|
|
20
|
+
* Channels.
|
|
21
|
+
*/
|
|
22
|
+
this.channels = null;
|
|
23
|
+
/**
|
|
24
|
+
* Product Quantity
|
|
25
|
+
*/
|
|
26
|
+
this.quantity = 0;
|
|
27
|
+
/**
|
|
28
|
+
* Donating amount.
|
|
29
|
+
*/
|
|
30
|
+
this.donatingAmount = 0;
|
|
31
|
+
/**
|
|
32
|
+
* Product Status.Defaults to `sale`
|
|
33
|
+
*/
|
|
34
|
+
this.productStatus = 'sale';
|
|
35
|
+
/**
|
|
36
|
+
* Product type. Defaults to `product`
|
|
37
|
+
*/
|
|
38
|
+
this.productType = 'product';
|
|
39
|
+
}
|
|
40
|
+
getLabel() {
|
|
41
|
+
if (this.productStatus === 'sale') {
|
|
42
|
+
return salla.lang.get('pages.cart.add_to_cart');
|
|
43
|
+
}
|
|
44
|
+
if (this.productType !== 'donating') {
|
|
45
|
+
return salla.lang.get('pages.products.out_of_stock');
|
|
46
|
+
}
|
|
47
|
+
// donating
|
|
48
|
+
return salla.lang.get('pages.products.donation_exceed');
|
|
49
|
+
}
|
|
50
|
+
addProductToCart(event) {
|
|
51
|
+
// we want to ignore the click action when the type of button is submit a form
|
|
52
|
+
if (this.hostAttributes['type'] === 'submit') {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
event.preventDefault();
|
|
56
|
+
/**
|
|
57
|
+
* by default the quick add is just an alias for add item function
|
|
58
|
+
* but its work only when the id is the only value is passed via the object
|
|
59
|
+
* so we will filter the object entities to remove null and zero values in case we don't want the normal add item action
|
|
60
|
+
*/
|
|
61
|
+
const data = Object.entries({
|
|
62
|
+
id: this.productId,
|
|
63
|
+
donating_amount: this.donatingAmount,
|
|
64
|
+
quantity: this.quantity
|
|
65
|
+
}).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
|
+
});
|
|
73
|
+
}
|
|
74
|
+
getBtnAttributes() {
|
|
75
|
+
for (let i = 0; i < this.host.attributes.length; i++) {
|
|
76
|
+
if (!['id', 'class'].includes(this.host.attributes[i].name)) {
|
|
77
|
+
this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return this.hostAttributes;
|
|
81
|
+
}
|
|
82
|
+
componentWillLoad() {
|
|
83
|
+
this.hasLabel = !!this.host.innerHTML.replace('<!---->', '').trim();
|
|
84
|
+
}
|
|
85
|
+
render() {
|
|
86
|
+
return (index.h(index.Host, null, this.productStatus === 'out-and-notify' && this.channels ?
|
|
87
|
+
index.h("salla-product-availability", Object.assign({}, this.getBtnAttributes()), index.h("slot", null)) :
|
|
88
|
+
index.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' }), index.h("slot", null))));
|
|
89
|
+
}
|
|
90
|
+
componentDidRender() {
|
|
91
|
+
//if label not passed, get label
|
|
92
|
+
if (this.hasLabel) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
this.btn.setText(this.getLabel() || 'اضافة للسلة');
|
|
96
|
+
salla.lang.onLoaded(() => {
|
|
97
|
+
this.btn.setText(this.getLabel() || 'اضافة للسلة');
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
get host() { return index.getElement(this); }
|
|
101
|
+
};
|
|
102
|
+
SallaAddProductButton.style = sallaAddProductButtonCss;
|
|
103
|
+
|
|
104
|
+
exports.salla_add_product_button = SallaAddProductButton;
|