@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.
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} +990 -62
  5. package/dist/cjs/twilight-components.cjs.js +1 -1
  6. package/dist/collection/components/salla-login-modal/salla-login-modal.js +25 -13
  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 +17 -8
  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} +984 -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-d4539c3e.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
package/README.md CHANGED
@@ -52,4 +52,11 @@ todo :: finx the publish scripts
52
52
 
53
53
  ```
54
54
  node publish.js
55
- ```
55
+ ```
56
+
57
+ ## Deveplement
58
+
59
+ 1. make sure you are update the tailwind output everytime `npm run tailwind`
60
+ 1. Everytime you change the utilities json you should run this command to update the output of tailwind css (TODO :: make it automatic with watch command)
61
+ 2. Change the store settings in `src/global/app.ts`
62
+ 3. Run watch `npm run watch`
@@ -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-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);
20
+ 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);
21
21
  });
22
22
  };
23
23
 
@@ -0,0 +1,85 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ 'use strict';
5
+
6
+ Object.defineProperty(exports, '__esModule', { value: true });
7
+
8
+ const index = require('./index-b4140db0.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
+ this.channels = null;
20
+ this.quantity = 0;
21
+ this.donatingAmount = 0;
22
+ this.productStatus = 'sale';
23
+ this.productType = 'product';
24
+ }
25
+ getLabel() {
26
+ if (this.productStatus === 'sale') {
27
+ return salla.lang.get('pages.cart.add_to_cart');
28
+ }
29
+ if (this.productType !== 'donating') {
30
+ return salla.lang.get('pages.products.out_of_stock');
31
+ }
32
+ // donating
33
+ return salla.lang.get('pages.products.donation_exceed');
34
+ }
35
+ addProductToCart(event) {
36
+ // we want to ignore the click action when the type of button is submit a form
37
+ if (this.hostAttributes['type'] === 'submit') {
38
+ return false;
39
+ }
40
+ event.preventDefault();
41
+ /**
42
+ * by default the quick add is just an alias for add item function
43
+ * but its work only when the id is the only value is passed via the object
44
+ * so we will filter the object entities to remove null and zero values in case we don't want the normal add item action
45
+ */
46
+ const data = Object.entries({
47
+ id: this.productId,
48
+ donating_amount: this.donatingAmount,
49
+ quantity: this.quantity
50
+ }).reduce((a, [k, v]) => (v ? (a[k] = v, a) : a), {});
51
+ return salla.cart.quickAdd(data)
52
+ .then((response) => {
53
+ console.log("🚀 ~ file: salla-add-product-button.tsx ~ line 67 ~ SallaAddProductButton ~ .then ~ response", response);
54
+ return this.success.emit(response);
55
+ })
56
+ .catch((error) => {
57
+ console.log("🚀 ~ file: salla-add-product-button.tsx ~ line 70 ~ SallaAddProductButton ~ addProductToCart ~ error", error);
58
+ return this.failed.emit(error);
59
+ });
60
+ }
61
+ getBtnAttributes() {
62
+ for (let i = 0; i < this.host.attributes.length; i++) {
63
+ if (!['id', 'class'].includes(this.host.attributes[i].name)) {
64
+ this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
65
+ }
66
+ }
67
+ return this.hostAttributes;
68
+ }
69
+ componentWillLoad() {
70
+ this.hasLabel = !!this.host.innerHTML.replace('<!---->', '').trim();
71
+ }
72
+ render() {
73
+ return (index.h(index.Host, null, this.productStatus === 'out-and-notify' && this.channels ?
74
+ index.h("salla-product-availability", Object.assign({}, this.getBtnAttributes()), index.h("slot", null)) :
75
+ 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))));
76
+ }
77
+ componentDidRender() {
78
+ //if label not passed, get label
79
+ this.hasLabel || salla.event.on('languages::translations.loaded', () => this.btn.setText(this.getLabel() || 'اضافة للسلة'));
80
+ }
81
+ get host() { return index.getElement(this); }
82
+ };
83
+ SallaAddProductButton.style = sallaAddProductButtonCss;
84
+
85
+ exports.salla_add_product_button = SallaAddProductButton;