@salla.sa/twilight-components 1.0.104 → 1.0.107

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 (55) hide show
  1. package/README.md +8 -1
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/salla-add-product-button.cjs.entry.js +85 -0
  4. package/dist/cjs/{salla-add-product-button_6.cjs.entry.js → salla-branches_13.cjs.entry.js} +989 -62
  5. package/dist/cjs/twilight-components.cjs.js +1 -1
  6. package/dist/collection/components/salla-login-modal/salla-login-modal.js +15 -4
  7. package/dist/collection/global/app.js +23 -0
  8. package/dist/collection/plugins/tailwind-theme/index.js +3 -4
  9. package/dist/components/salla-login-modal.js +10 -2
  10. package/dist/esm/loader.js +1 -1
  11. package/dist/esm/salla-add-product-button.entry.js +81 -0
  12. package/dist/esm/{salla-add-product-button_6.entry.js → salla-branches_13.entry.js} +983 -63
  13. package/dist/esm/twilight-components.js +1 -1
  14. package/dist/twilight-components/p-6f4f4260.entry.js +4 -0
  15. package/dist/twilight-components/p-7b5b8647.entry.js +4 -0
  16. package/dist/twilight-components/twilight-components.esm.js +1 -1
  17. package/dist/types/components/salla-login-modal/salla-login-modal.d.ts +1 -1
  18. package/dist/types/components.d.ts +1 -1
  19. package/dist/types/global/app.d.ts +3 -0
  20. package/example/assets/tailwind.css +3938 -3
  21. package/example/assets/translations.js +4981 -0
  22. package/example/index.html +8 -8
  23. package/package.json +13 -6
  24. package/dist/cjs/salla-branches.cjs.entry.js +0 -98
  25. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +0 -93
  26. package/dist/cjs/salla-localization-modal.cjs.entry.js +0 -121
  27. package/dist/cjs/salla-login-modal.cjs.entry.js +0 -196
  28. package/dist/cjs/salla-offer-modal.cjs.entry.js +0 -145
  29. package/dist/cjs/salla-rating-modal.cjs.entry.js +0 -177
  30. package/dist/cjs/salla-rating-stars.cjs.entry.js +0 -76
  31. package/dist/cjs/salla-verify.cjs.entry.js +0 -168
  32. package/dist/esm/salla-branches.entry.js +0 -94
  33. package/dist/esm/salla-infinite-scroll.entry.js +0 -89
  34. package/dist/esm/salla-localization-modal.entry.js +0 -117
  35. package/dist/esm/salla-login-modal.entry.js +0 -192
  36. package/dist/esm/salla-offer-modal.entry.js +0 -141
  37. package/dist/esm/salla-rating-modal.entry.js +0 -173
  38. package/dist/esm/salla-rating-stars.entry.js +0 -72
  39. package/dist/esm/salla-verify.entry.js +0 -164
  40. package/dist/twilight-components/p-30e63760.entry.js +0 -4
  41. package/dist/twilight-components/p-799da239.entry.js +0 -4
  42. package/dist/twilight-components/p-9ff78dd1.entry.js +0 -4
  43. package/dist/twilight-components/p-c1952856.entry.js +0 -4
  44. package/dist/twilight-components/p-cf143464.entry.js +0 -4
  45. package/dist/twilight-components/p-d3778858.entry.js +0 -4
  46. package/dist/twilight-components/p-ebd2e045.entry.js +0 -4
  47. package/dist/twilight-components/p-ec0a2892.entry.js +0 -4
  48. package/dist/twilight-components/p-fab65162.entry.js +0 -4
  49. package/example/dist/demo.js +0 -153
  50. package/example/dist/flags.png +0 -0
  51. package/example/dist/flags@2x.png +0 -0
  52. package/example/dist/intlTelInput.min.css +0 -1
  53. package/example/dist/tailwind.css +0 -3856
  54. package/example/dist/translations.js +0 -1
  55. 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-add-product-button_6.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"]}],[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32],"typing":[32],"debounce":[32],"search_term":[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]}],[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-login-modal.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"]]]]],["salla-rating-modal.cjs",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"open":[64],"close":[64]}]]],["salla-branches.cjs",[[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]}]]],["salla-localization-modal.cjs",[[0,"salla-localization-modal",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"open":[64],"close":[64],"submit":[64]}]]],["salla-offer-modal.cjs",[[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]}]]],["salla-conditional-fields.cjs",[[4,"salla-conditional-fields",null,[[0,"change","changeHandler"]]]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[1028],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["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]}]]],["salla-verify.cjs",[[4,"salla-verify",{"display":[1],"type":[1025],"autoReload":[4,"auto-reload"],"title":[32],"resendAfter":[32],"isProfileVerify":[32],"getCode":[64],"open":[64]}]]],["salla-rating-stars.cjs",[[0,"salla-rating-stars",{"name":[1],"size":[1],"value":[2]}]]]], options);
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
  });
@@ -93,7 +93,7 @@ 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
98
  this.isEmailAllowed = salla.config.get('store.settings.auth.email_allowed', !!this.isEmailAllowed);
99
99
  this.isMobileAllowed = salla.config.get('store.settings.auth.mobile_allowed', !!this.isMobileAllowed);
@@ -127,7 +127,15 @@ export class SallaLoginModal {
127
127
  /**
128
128
  * Open login component
129
129
  */
130
- async open() {
130
+ // @ts-ignore
131
+ async open(event = null) {
132
+ // if(event && event.hasOwnProperty('isEmailAllowed')){
133
+ // this.isEmailAllowed = event?.isEmailAllowed;
134
+ // }
135
+ //
136
+ // if(event && event.hasOwnProperty('isMobileAllowed')){
137
+ // this.isMobileAllowed = event?.isMobileAllowed;
138
+ // }
131
139
  if (this.isEmailAllowed && this.isMobileAllowed) {
132
140
  this.showTab(this.homeTab);
133
141
  }
@@ -323,8 +331,11 @@ export class SallaLoginModal {
323
331
  static get methods() { return {
324
332
  "open": {
325
333
  "complexType": {
326
- "signature": "() => Promise<HTMLElement>",
327
- "parameters": [],
334
+ "signature": "(event?: any) => Promise<HTMLElement>",
335
+ "parameters": [{
336
+ "tags": [],
337
+ "text": ""
338
+ }],
328
339
  "references": {
329
340
  "Promise": {
330
341
  "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-150 dark:bg-gray-600 dark:border-gray-600 rounded-md': {}},
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-150': {}},
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
@@ -91,7 +91,7 @@ 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
96
  this.isEmailAllowed = salla.config.get('store.settings.auth.email_allowed', !!this.isEmailAllowed);
97
97
  this.isMobileAllowed = salla.config.get('store.settings.auth.mobile_allowed', !!this.isMobileAllowed);
@@ -125,7 +125,15 @@ const SallaLoginModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
125
125
  /**
126
126
  * Open login component
127
127
  */
128
- async open() {
128
+ // @ts-ignore
129
+ async open(event = null) {
130
+ // if(event && event.hasOwnProperty('isEmailAllowed')){
131
+ // this.isEmailAllowed = event?.isEmailAllowed;
132
+ // }
133
+ //
134
+ // if(event && event.hasOwnProperty('isMobileAllowed')){
135
+ // this.isMobileAllowed = event?.isMobileAllowed;
136
+ // }
129
137
  if (this.isEmailAllowed && this.isMobileAllowed) {
130
138
  this.showTab(this.homeTab);
131
139
  }
@@ -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-add-product-button_6",[[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"]}],[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32],"typing":[32],"debounce":[32],"search_term":[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]}],[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-login-modal",[[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"]]]]],["salla-rating-modal",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"open":[64],"close":[64]}]]],["salla-branches",[[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]}]]],["salla-localization-modal",[[0,"salla-localization-modal",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"open":[64],"close":[64],"submit":[64]}]]],["salla-offer-modal",[[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]}]]],["salla-conditional-fields",[[4,"salla-conditional-fields",null,[[0,"change","changeHandler"]]]]],["salla-infinite-scroll",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[1028],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["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]}]]],["salla-verify",[[4,"salla-verify",{"display":[1],"type":[1025],"autoReload":[4,"auto-reload"],"title":[32],"resendAfter":[32],"isProfileVerify":[32],"getCode":[64],"open":[64]}]]],["salla-rating-stars",[[0,"salla-rating-stars",{"name":[1],"size":[1],"value":[2]}]]]], options);
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 };