@salla.sa/twilight-components 1.0.104 → 1.0.108
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/README.md +8 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/salla-add-product-button.cjs.entry.js +85 -0
- package/dist/cjs/{salla-add-product-button_6.cjs.entry.js → salla-branches_13.cjs.entry.js} +990 -62
- package/dist/cjs/twilight-components.cjs.js +1 -1
- package/dist/collection/components/salla-login-modal/salla-login-modal.js +25 -13
- package/dist/collection/global/app.js +23 -0
- package/dist/collection/plugins/tailwind-theme/index.js +3 -4
- package/dist/components/salla-login-modal.js +17 -8
- package/dist/esm/loader.js +1 -1
- package/dist/esm/salla-add-product-button.entry.js +81 -0
- package/dist/esm/{salla-add-product-button_6.entry.js → salla-branches_13.entry.js} +984 -63
- package/dist/esm/twilight-components.js +1 -1
- package/dist/twilight-components/p-6f4f4260.entry.js +4 -0
- package/dist/twilight-components/p-d4539c3e.entry.js +4 -0
- package/dist/twilight-components/twilight-components.esm.js +1 -1
- package/dist/types/components/salla-login-modal/salla-login-modal.d.ts +1 -1
- package/dist/types/components.d.ts +1 -1
- package/dist/types/global/app.d.ts +3 -0
- package/example/assets/tailwind.css +3938 -3
- package/example/assets/translations.js +4981 -0
- package/example/index.html +8 -8
- package/package.json +13 -6
- package/dist/cjs/salla-branches.cjs.entry.js +0 -98
- package/dist/cjs/salla-infinite-scroll.cjs.entry.js +0 -93
- package/dist/cjs/salla-localization-modal.cjs.entry.js +0 -121
- package/dist/cjs/salla-login-modal.cjs.entry.js +0 -196
- package/dist/cjs/salla-offer-modal.cjs.entry.js +0 -145
- package/dist/cjs/salla-rating-modal.cjs.entry.js +0 -177
- package/dist/cjs/salla-rating-stars.cjs.entry.js +0 -76
- package/dist/cjs/salla-verify.cjs.entry.js +0 -168
- package/dist/esm/salla-branches.entry.js +0 -94
- package/dist/esm/salla-infinite-scroll.entry.js +0 -89
- package/dist/esm/salla-localization-modal.entry.js +0 -117
- package/dist/esm/salla-login-modal.entry.js +0 -192
- package/dist/esm/salla-offer-modal.entry.js +0 -141
- package/dist/esm/salla-rating-modal.entry.js +0 -173
- package/dist/esm/salla-rating-stars.entry.js +0 -72
- package/dist/esm/salla-verify.entry.js +0 -164
- package/dist/twilight-components/p-30e63760.entry.js +0 -4
- package/dist/twilight-components/p-799da239.entry.js +0 -4
- package/dist/twilight-components/p-9ff78dd1.entry.js +0 -4
- package/dist/twilight-components/p-c1952856.entry.js +0 -4
- package/dist/twilight-components/p-cf143464.entry.js +0 -4
- package/dist/twilight-components/p-d3778858.entry.js +0 -4
- package/dist/twilight-components/p-ebd2e045.entry.js +0 -4
- package/dist/twilight-components/p-ec0a2892.entry.js +0 -4
- package/dist/twilight-components/p-fab65162.entry.js +0 -4
- package/example/dist/demo.js +0 -153
- package/example/dist/flags.png +0 -0
- package/example/dist/flags@2x.png +0 -0
- package/example/dist/intlTelInput.min.css +0 -1
- package/example/dist/tailwind.css +0 -3856
- package/example/dist/translations.js +0 -1
- package/example/dist/twilight.js +0 -437
|
@@ -18,5 +18,5 @@ const patchBrowser = () => {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
patchBrowser().then(options => {
|
|
21
|
-
return index.bootstrapLazy([["salla-
|
|
21
|
+
return index.bootstrapLazy([["salla-branches_13.cjs",[[4,"salla-login-modal",{"isEmailAllowed":[1028,"is-email-allowed"],"isMobileAllowed":[1028,"is-mobile-allowed"],"isEmailRequired":[1028,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"open":[64]},[[8,"verified","onVerified"]]],[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"open":[64],"close":[64]}],[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]}],[0,"salla-localization-modal",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"open":[64],"close":[64],"submit":[64]}],[0,"salla-offer-modal",{"offer":[32],"offer_name":[32],"offer_message":[32],"offer_expires_in":[32],"remember_my_choice":[32],"add_to_cart":[32],"out_of_stock":[32],"open":[64],"showOffer":[64]}],[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32],"typing":[32],"debounce":[32],"search_term":[32]}],[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[1028],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}],[0,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32],"isVisitorSubscribed":[32]}],[4,"salla-verify",{"display":[1],"type":[1025],"autoReload":[4,"auto-reload"],"title":[32],"resendAfter":[32],"isProfileVerify":[32],"getCode":[64],"open":[64]}],[0,"salla-rating-stars",{"name":[1],"size":[1],"value":[2]}],[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]}],[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]}],[4,"salla-modal",{"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"iconStyle":[1,"icon-style"],"imageIcon":[1,"image-icon"],"modalTitle":[32],"open":[64],"close":[64],"setTitle":[64],"loading":[64],"stopLoading":[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]}]]],["salla-quantity-input.cjs",[[4,"salla-quantity-input",{"quantity":[32],"decrease":[64],"increase":[64],"setValue":[64]}]]]], options);
|
|
22
22
|
});
|
|
@@ -19,15 +19,15 @@ export class SallaLoginModal {
|
|
|
19
19
|
/**
|
|
20
20
|
* Does the merchant allow to login using email
|
|
21
21
|
*/
|
|
22
|
-
this.isEmailAllowed =
|
|
22
|
+
this.isEmailAllowed = true;
|
|
23
23
|
/**
|
|
24
24
|
* Does the merchant/current location for visitor allow to login using mobile, By default outside KSA is `false`
|
|
25
25
|
*/
|
|
26
|
-
this.isMobileAllowed =
|
|
26
|
+
this.isMobileAllowed = true;
|
|
27
27
|
/**
|
|
28
28
|
* Does the merchant require registration with email & mobile
|
|
29
29
|
*/
|
|
30
|
-
this.isEmailRequired =
|
|
30
|
+
this.isEmailRequired = false;
|
|
31
31
|
this.regType = 'phone';
|
|
32
32
|
this.typing = (e, submitMethod) => {
|
|
33
33
|
const error = e.target.nextElementSibling;
|
|
@@ -93,11 +93,11 @@ export class SallaLoginModal {
|
|
|
93
93
|
salla.auth.event.onVerificationFailed(() => {
|
|
94
94
|
//
|
|
95
95
|
});
|
|
96
|
-
salla.event.on('login::open', () => this.open());
|
|
96
|
+
salla.event.on('login::open', (event) => this.open(event));
|
|
97
97
|
salla.event.on('twilight::initiated', () => {
|
|
98
|
-
this.isEmailAllowed = salla.config.get('store.settings.auth.email_allowed',
|
|
99
|
-
this.isMobileAllowed = salla.config.get('store.settings.auth.mobile_allowed',
|
|
100
|
-
this.isEmailRequired = salla.config.get('store.settings.auth.is_email_required',
|
|
98
|
+
this.isEmailAllowed = salla.config.get('store.settings.auth.email_allowed', this.isEmailAllowed);
|
|
99
|
+
this.isMobileAllowed = salla.config.get('store.settings.auth.mobile_allowed', this.isMobileAllowed);
|
|
100
|
+
this.isEmailRequired = salla.config.get('store.settings.auth.is_email_required', this.isEmailRequired);
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
@@ -127,7 +127,16 @@ export class SallaLoginModal {
|
|
|
127
127
|
/**
|
|
128
128
|
* Open login component
|
|
129
129
|
*/
|
|
130
|
-
|
|
130
|
+
// @ts-ignore
|
|
131
|
+
async open(event = null) {
|
|
132
|
+
// todo :: support change the settings from event details
|
|
133
|
+
// if(event && event.hasOwnProperty('isEmailAllowed')){
|
|
134
|
+
// this.isEmailAllowed = event?.isEmailAllowed;
|
|
135
|
+
// }
|
|
136
|
+
//
|
|
137
|
+
// if(event && event.hasOwnProperty('isMobileAllowed')){
|
|
138
|
+
// this.isMobileAllowed = event?.isMobileAllowed;
|
|
139
|
+
// }
|
|
131
140
|
if (this.isEmailAllowed && this.isMobileAllowed) {
|
|
132
141
|
this.showTab(this.homeTab);
|
|
133
142
|
}
|
|
@@ -265,7 +274,7 @@ export class SallaLoginModal {
|
|
|
265
274
|
},
|
|
266
275
|
"attribute": "is-email-allowed",
|
|
267
276
|
"reflect": false,
|
|
268
|
-
"defaultValue": "
|
|
277
|
+
"defaultValue": "true"
|
|
269
278
|
},
|
|
270
279
|
"isMobileAllowed": {
|
|
271
280
|
"type": "boolean",
|
|
@@ -283,7 +292,7 @@ export class SallaLoginModal {
|
|
|
283
292
|
},
|
|
284
293
|
"attribute": "is-mobile-allowed",
|
|
285
294
|
"reflect": false,
|
|
286
|
-
"defaultValue": "
|
|
295
|
+
"defaultValue": "true"
|
|
287
296
|
},
|
|
288
297
|
"isEmailRequired": {
|
|
289
298
|
"type": "boolean",
|
|
@@ -301,7 +310,7 @@ export class SallaLoginModal {
|
|
|
301
310
|
},
|
|
302
311
|
"attribute": "is-email-required",
|
|
303
312
|
"reflect": false,
|
|
304
|
-
"defaultValue": "
|
|
313
|
+
"defaultValue": "false"
|
|
305
314
|
}
|
|
306
315
|
}; }
|
|
307
316
|
static get states() { return {
|
|
@@ -323,8 +332,11 @@ export class SallaLoginModal {
|
|
|
323
332
|
static get methods() { return {
|
|
324
333
|
"open": {
|
|
325
334
|
"complexType": {
|
|
326
|
-
"signature": "() => Promise<HTMLElement>",
|
|
327
|
-
"parameters": [
|
|
335
|
+
"signature": "(event?: any) => Promise<HTMLElement>",
|
|
336
|
+
"parameters": [{
|
|
337
|
+
"tags": [],
|
|
338
|
+
"text": ""
|
|
339
|
+
}],
|
|
328
340
|
"references": {
|
|
329
341
|
"Promise": {
|
|
330
342
|
"location": "global"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Crafted with ❤ by Salla
|
|
3
|
+
*/
|
|
4
|
+
import "../../example/assets/translations.js";
|
|
5
|
+
import '@salla.sa/twilight/dist/cjs/index';
|
|
6
|
+
export default function () {
|
|
7
|
+
salla.init({
|
|
8
|
+
debug: true,
|
|
9
|
+
language_code: 'en',
|
|
10
|
+
store: {
|
|
11
|
+
// stage
|
|
12
|
+
url: "https://web-26c3cd35add3468fc189c714bd1a1345.salla.group/bayans",
|
|
13
|
+
api: "https://web-26c3cd35add3468fc189c714bd1a1345.salla.group/api/v1/",
|
|
14
|
+
id: 693312468,
|
|
15
|
+
// prod
|
|
16
|
+
// id: 1305146709,
|
|
17
|
+
// url: "https://salla.sa",
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
// this is required to bypass cloudflare in stage
|
|
21
|
+
salla.api.defaults.headers.common['CF-Access-Client-Id'] = '2db165f2f48c6b43320719d5d17ef7cf.access';
|
|
22
|
+
salla.api.defaults.headers.common['CF-Access-Client-Secret'] = 'f01a3100d5d93a04bb6f052b73032cce167ca94b5ade49880ccff1f94d03dc9c';
|
|
23
|
+
}
|
|
@@ -3,15 +3,14 @@ module.exports = require('tailwindcss/plugin').withOptions(() => {
|
|
|
3
3
|
addUtilities({
|
|
4
4
|
// TODO :: find if there are used and defined them here if its.
|
|
5
5
|
'.s-hidden' : {'@apply hidden': {}},
|
|
6
|
-
'.text-md' : {},
|
|
7
6
|
'.s-has-error' : {'@apply border-red-400 focus:border-red-500': {}},
|
|
8
7
|
'.rounded-icon' : {'@apply w-16 h-16 flex justify-center items-center rounded-full text-3xl': {}},
|
|
9
|
-
'.form-input' : {'@apply w-full h-10 transition-colors duration-300 focus:ring-transparent focus:border-primary dark:focus:border-primary sm:text-sm border-gray-
|
|
8
|
+
'.form-input' : {'@apply w-full h-10 transition-colors duration-300 focus:ring-transparent focus:border-primary dark:focus:border-primary sm:text-sm border-gray-200 dark:bg-gray-600 dark:border-gray-600 rounded-md': {}},
|
|
10
9
|
'.btn' : {'@apply transition duration-300 flex-1 inline-flex justify-center items-center px-6 pb-2.5 pt-2 text-sm font-bold rounded-md hover:opacity-80 whitespace-nowrap': {}},
|
|
11
10
|
'.btn-primary' : {'@apply text-primary-reverse border border-primary bg-primary': {}},
|
|
12
11
|
'.btn-danger' : {'@apply bg-red-400 text-white hover:opacity-80': {}},
|
|
13
|
-
'.btn-outline' : {'@apply text-gray-400 bg-white shadow-sm hover:text-gray-600 border border-gray-
|
|
14
|
-
'.btn-outline-primary': {'@apply border border-primary text-primary hover:bg-primary hover:text-reverse': {}},
|
|
12
|
+
'.btn-outline' : {'@apply text-gray-400 bg-white shadow-sm hover:text-gray-600 border border-gray-200': {}},
|
|
13
|
+
'.btn-outline-primary': {'@apply border border-primary text-primary hover:bg-primary hover:text-primary-reverse': {}},
|
|
15
14
|
});
|
|
16
15
|
|
|
17
16
|
// todo :: move it to global
|
|
@@ -17,15 +17,15 @@ const SallaLoginModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
17
17
|
/**
|
|
18
18
|
* Does the merchant allow to login using email
|
|
19
19
|
*/
|
|
20
|
-
this.isEmailAllowed =
|
|
20
|
+
this.isEmailAllowed = true;
|
|
21
21
|
/**
|
|
22
22
|
* Does the merchant/current location for visitor allow to login using mobile, By default outside KSA is `false`
|
|
23
23
|
*/
|
|
24
|
-
this.isMobileAllowed =
|
|
24
|
+
this.isMobileAllowed = true;
|
|
25
25
|
/**
|
|
26
26
|
* Does the merchant require registration with email & mobile
|
|
27
27
|
*/
|
|
28
|
-
this.isEmailRequired =
|
|
28
|
+
this.isEmailRequired = false;
|
|
29
29
|
this.regType = 'phone';
|
|
30
30
|
this.typing = (e, submitMethod) => {
|
|
31
31
|
const error = e.target.nextElementSibling;
|
|
@@ -91,11 +91,11 @@ const SallaLoginModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
91
91
|
salla.auth.event.onVerificationFailed(() => {
|
|
92
92
|
//
|
|
93
93
|
});
|
|
94
|
-
salla.event.on('login::open', () => this.open());
|
|
94
|
+
salla.event.on('login::open', (event) => this.open(event));
|
|
95
95
|
salla.event.on('twilight::initiated', () => {
|
|
96
|
-
this.isEmailAllowed = salla.config.get('store.settings.auth.email_allowed',
|
|
97
|
-
this.isMobileAllowed = salla.config.get('store.settings.auth.mobile_allowed',
|
|
98
|
-
this.isEmailRequired = salla.config.get('store.settings.auth.is_email_required',
|
|
96
|
+
this.isEmailAllowed = salla.config.get('store.settings.auth.email_allowed', this.isEmailAllowed);
|
|
97
|
+
this.isMobileAllowed = salla.config.get('store.settings.auth.mobile_allowed', this.isMobileAllowed);
|
|
98
|
+
this.isEmailRequired = salla.config.get('store.settings.auth.is_email_required', this.isEmailRequired);
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
@@ -125,7 +125,16 @@ const SallaLoginModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
125
125
|
/**
|
|
126
126
|
* Open login component
|
|
127
127
|
*/
|
|
128
|
-
|
|
128
|
+
// @ts-ignore
|
|
129
|
+
async open(event = null) {
|
|
130
|
+
// todo :: support change the settings from event details
|
|
131
|
+
// if(event && event.hasOwnProperty('isEmailAllowed')){
|
|
132
|
+
// this.isEmailAllowed = event?.isEmailAllowed;
|
|
133
|
+
// }
|
|
134
|
+
//
|
|
135
|
+
// if(event && event.hasOwnProperty('isMobileAllowed')){
|
|
136
|
+
// this.isMobileAllowed = event?.isMobileAllowed;
|
|
137
|
+
// }
|
|
129
138
|
if (this.isEmailAllowed && this.isMobileAllowed) {
|
|
130
139
|
this.showTab(this.homeTab);
|
|
131
140
|
}
|
package/dist/esm/loader.js
CHANGED
|
@@ -13,7 +13,7 @@ const patchEsm = () => {
|
|
|
13
13
|
const defineCustomElements = (win, options) => {
|
|
14
14
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
15
15
|
return patchEsm().then(() => {
|
|
16
|
-
return bootstrapLazy([["salla-
|
|
16
|
+
return bootstrapLazy([["salla-branches_13",[[4,"salla-login-modal",{"isEmailAllowed":[1028,"is-email-allowed"],"isMobileAllowed":[1028,"is-mobile-allowed"],"isEmailRequired":[1028,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"open":[64]},[[8,"verified","onVerified"]]],[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"open":[64],"close":[64]}],[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]}],[0,"salla-localization-modal",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"open":[64],"close":[64],"submit":[64]}],[0,"salla-offer-modal",{"offer":[32],"offer_name":[32],"offer_message":[32],"offer_expires_in":[32],"remember_my_choice":[32],"add_to_cart":[32],"out_of_stock":[32],"open":[64],"showOffer":[64]}],[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32],"typing":[32],"debounce":[32],"search_term":[32]}],[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[1028],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}],[0,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32],"isVisitorSubscribed":[32]}],[4,"salla-verify",{"display":[1],"type":[1025],"autoReload":[4,"auto-reload"],"title":[32],"resendAfter":[32],"isProfileVerify":[32],"getCode":[64],"open":[64]}],[0,"salla-rating-stars",{"name":[1],"size":[1],"value":[2]}],[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]}],[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]}],[4,"salla-modal",{"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"iconStyle":[1,"icon-style"],"imageIcon":[1,"image-icon"],"modalTitle":[32],"open":[64],"close":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-add-product-button",[[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",[[4,"salla-conditional-fields",null,[[0,"change","changeHandler"]]]]],["salla-installment",[[0,"salla-installment",{"price":[1],"language":[1],"currency":[1],"tamaraIsActive":[32],"tabbyIsActive":[32],"spotiiIsActive":[32]}]]],["salla-quantity-input",[[4,"salla-quantity-input",{"quantity":[32],"decrease":[64],"increase":[64],"setValue":[64]}]]]], options);
|
|
17
17
|
});
|
|
18
18
|
};
|
|
19
19
|
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Crafted with ❤ by Salla
|
|
3
|
+
*/
|
|
4
|
+
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-20b84fd0.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
|
+
this.channels = null;
|
|
16
|
+
this.quantity = 0;
|
|
17
|
+
this.donatingAmount = 0;
|
|
18
|
+
this.productStatus = 'sale';
|
|
19
|
+
this.productType = 'product';
|
|
20
|
+
}
|
|
21
|
+
getLabel() {
|
|
22
|
+
if (this.productStatus === 'sale') {
|
|
23
|
+
return salla.lang.get('pages.cart.add_to_cart');
|
|
24
|
+
}
|
|
25
|
+
if (this.productType !== 'donating') {
|
|
26
|
+
return salla.lang.get('pages.products.out_of_stock');
|
|
27
|
+
}
|
|
28
|
+
// donating
|
|
29
|
+
return salla.lang.get('pages.products.donation_exceed');
|
|
30
|
+
}
|
|
31
|
+
addProductToCart(event) {
|
|
32
|
+
// we want to ignore the click action when the type of button is submit a form
|
|
33
|
+
if (this.hostAttributes['type'] === 'submit') {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
event.preventDefault();
|
|
37
|
+
/**
|
|
38
|
+
* by default the quick add is just an alias for add item function
|
|
39
|
+
* but its work only when the id is the only value is passed via the object
|
|
40
|
+
* so we will filter the object entities to remove null and zero values in case we don't want the normal add item action
|
|
41
|
+
*/
|
|
42
|
+
const data = Object.entries({
|
|
43
|
+
id: this.productId,
|
|
44
|
+
donating_amount: this.donatingAmount,
|
|
45
|
+
quantity: this.quantity
|
|
46
|
+
}).reduce((a, [k, v]) => (v ? (a[k] = v, a) : a), {});
|
|
47
|
+
return salla.cart.quickAdd(data)
|
|
48
|
+
.then((response) => {
|
|
49
|
+
console.log("🚀 ~ file: salla-add-product-button.tsx ~ line 67 ~ SallaAddProductButton ~ .then ~ response", response);
|
|
50
|
+
return this.success.emit(response);
|
|
51
|
+
})
|
|
52
|
+
.catch((error) => {
|
|
53
|
+
console.log("🚀 ~ file: salla-add-product-button.tsx ~ line 70 ~ SallaAddProductButton ~ addProductToCart ~ error", error);
|
|
54
|
+
return this.failed.emit(error);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
getBtnAttributes() {
|
|
58
|
+
for (let i = 0; i < this.host.attributes.length; i++) {
|
|
59
|
+
if (!['id', 'class'].includes(this.host.attributes[i].name)) {
|
|
60
|
+
this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return this.hostAttributes;
|
|
64
|
+
}
|
|
65
|
+
componentWillLoad() {
|
|
66
|
+
this.hasLabel = !!this.host.innerHTML.replace('<!---->', '').trim();
|
|
67
|
+
}
|
|
68
|
+
render() {
|
|
69
|
+
return (h(Host, null, this.productStatus === 'out-and-notify' && this.channels ?
|
|
70
|
+
h("salla-product-availability", Object.assign({}, this.getBtnAttributes()), h("slot", null)) :
|
|
71
|
+
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))));
|
|
72
|
+
}
|
|
73
|
+
componentDidRender() {
|
|
74
|
+
//if label not passed, get label
|
|
75
|
+
this.hasLabel || salla.event.on('languages::translations.loaded', () => this.btn.setText(this.getLabel() || 'اضافة للسلة'));
|
|
76
|
+
}
|
|
77
|
+
get host() { return getElement(this); }
|
|
78
|
+
};
|
|
79
|
+
SallaAddProductButton.style = sallaAddProductButtonCss;
|
|
80
|
+
|
|
81
|
+
export { SallaAddProductButton as salla_add_product_button };
|