@salla.sa/twilight-components 1.0.57 → 1.0.58

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 (29) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/salla-button.cjs.entry.js +7 -7
  3. package/dist/cjs/salla-conditional-fields.cjs.entry.js +76 -0
  4. package/dist/cjs/salla-quantity-input.cjs.entry.js +64 -0
  5. package/dist/cjs/twilight-components.cjs.js +1 -1
  6. package/dist/collection/collection-manifest.json +2 -0
  7. package/dist/collection/components/salla-button/salla-button.js +10 -10
  8. package/dist/collection/components/salla-conditional-fields/salla-conditional-fields.css +3 -0
  9. package/dist/collection/components/salla-conditional-fields/salla-conditional-fields.js +82 -0
  10. package/dist/collection/components/salla-quantity-input/salla-quantity-input.css +3 -0
  11. package/dist/collection/components/salla-quantity-input/salla-quantity-input.js +71 -0
  12. package/dist/esm/loader.js +1 -1
  13. package/dist/esm/salla-button.entry.js +7 -7
  14. package/dist/esm/salla-conditional-fields.entry.js +72 -0
  15. package/dist/esm/salla-quantity-input.entry.js +60 -0
  16. package/dist/esm/twilight-components.js +1 -1
  17. package/dist/twilight-components/p-40693cd3.entry.js +1 -0
  18. package/dist/twilight-components/p-5d5b04ec.entry.js +1 -0
  19. package/dist/twilight-components/p-6c928c14.entry.js +1 -0
  20. package/dist/twilight-components/twilight-components.esm.js +1 -1
  21. package/dist/types/components/salla-button/salla-button.d.ts +2 -2
  22. package/dist/types/components/salla-conditional-fields/salla-conditional-fields.d.ts +9 -0
  23. package/dist/types/components/salla-quantity-input/salla-quantity-input.d.ts +18 -0
  24. package/dist/types/components.d.ts +34 -8
  25. package/example/dist/tailwind.css +944 -326
  26. package/example/dist/twilight.js +1 -1
  27. package/example/index.html +523 -123
  28. package/package.json +1 -1
  29. package/dist/twilight-components/p-646fbb7f.entry.js +0 -1
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- return index.bootstrapLazy([["salla-button.cjs",[[4,"salla-button",{"buttonType":[513,"button-type"],"color":[513],"fill":[513],"size":[513],"width":[513],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"href":[1],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}]]],["salla-modal_2.cjs",[[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[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"],"title":[32],"show":[64],"hide":[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],"show":[64]},[[0,"verified","onVerified"]]]]],["salla-product-availability.cjs",[[4,"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]}]]],["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],"show":[64],"hide":[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],"show":[64],"showOffer":[64]}]]],["salla-rating-modal.cjs",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-verify-modal.cjs",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}]]],["salla-tel-input.cjs",[[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}]]]], options);
17
+ return index.bootstrapLazy([["salla-button.cjs",[[4,"salla-button",{"shape":[513],"color":[513],"fill":[513],"size":[513],"width":[513],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"href":[1],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}]]],["salla-modal_2.cjs",[[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[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"],"title":[32],"show":[64],"hide":[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],"show":[64]},[[0,"verified","onVerified"]]]]],["salla-product-availability.cjs",[[4,"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]}]]],["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],"show":[64],"hide":[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],"show":[64],"showOffer":[64]}]]],["salla-rating-modal.cjs",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[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"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-quantity-input.cjs",[[4,"salla-quantity-input",{"quantity":[32]}]]],["salla-verify-modal.cjs",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}]]],["salla-tel-input.cjs",[[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -11,9 +11,9 @@ const SallaButton = class {
11
11
  index.registerInstance(this, hostRef);
12
12
  this.hostAttributes = {};
13
13
  /**
14
- * Button Type
14
+ * Button Type todo :: find better name,
15
15
  */
16
- this.buttonType = 'btn';
16
+ this.shape = 'btn';
17
17
  /**
18
18
  * Button Color
19
19
  */
@@ -92,21 +92,21 @@ const SallaButton = class {
92
92
  }
93
93
  getBtnAttributes() {
94
94
  for (let i = 0; i < this.host.attributes.length; i++) {
95
- if (!['type', 'color', 'fill', 'size', 'width', 'id', 'loading'].includes(this.host.attributes[i].name)) {
95
+ if (!['color', 'fill', 'size', 'width', 'id', 'loading'].includes(this.host.attributes[i].name)) {
96
96
  this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
97
97
  }
98
98
  }
99
99
  this.hostAttributes.type = this.hostAttributes.type || 'button';
100
100
  this.hostAttributes.class +=
101
- ' s-button-element s-button-' + this.buttonType
101
+ ' s-button-element s-button-' + this.shape
102
102
  + ' s-button-' + (this.fill == "none" ? 'fill-none' : this.fill)
103
103
  + (this.size != "medium" ? ' s-button-' + this.size : '')
104
104
  + (this.width != "normal" ? ' s-button-' + this.width : '')
105
- + (this.buttonType == "link" ? ' s-button-' + this.color + '-link' : '')
106
- + (this.buttonType != "link" && this.fill != 'outline' ? ' s-button-' + this.color : '')
105
+ + (this.shape == "link" ? ' s-button-' + this.color + '-link' : '')
106
+ + (this.shape != "link" && this.fill != 'outline' ? ' s-button-' + this.color : '')
107
107
  + (this.fill == 'outline' ? ' s-button-' + this.color + '-outline' : '')
108
108
  + (this.disabled ? ' s-button-disabled ' : '')
109
- + (this.buttonType == 'icon' ? ' s-button-loader-center' : ' s-button-loader-' + this.loaderPosition);
109
+ + (this.shape == 'icon' ? ' s-button-loader-center' : ' s-button-loader-' + this.loaderPosition);
110
110
  return this.hostAttributes;
111
111
  }
112
112
  render() {
@@ -0,0 +1,76 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-0b5b5867.js');
6
+
7
+ const sallaConditionalFieldsCss = ":host{display:block}";
8
+
9
+ const SallaConditionalFields = class {
10
+ constructor(hostRef) {
11
+ index.registerInstance(this, hostRef);
12
+ }
13
+ changeHandler(event) {
14
+ salla.log('Received the change event: ', event);
15
+ if (!['SELECT'].includes(event.target.tagName) && !['checkbox'].includes(event.target.getAttribute('type'))) {
16
+ // todo :: support debug
17
+ salla.log('Ignore the change because is not support input: ' + event.target.tagName);
18
+ return;
19
+ }
20
+ // to extract the option id from the input name, the supported names are name[*] and name[*][]
21
+ let optionId = event.target.name.replace('[]', '');
22
+ let isMultiple = event.target.getAttribute('type') === 'checkbox';
23
+ salla.log('Trying to find all the element with condation:', `[data-show-when^="${optionId}"]`);
24
+ this.host.querySelectorAll(`[data-show-when^="${optionId}"]`)
25
+ .forEach((field) => {
26
+ // @ts-ignore
27
+ let isEqual = !(field === null || field === void 0 ? void 0 : field.dataset.showWhen.includes('!='));
28
+ // @ts-ignore
29
+ let value = field === null || field === void 0 ? void 0 : field.dataset.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$3').trim();
30
+ // let isSelected = isMultiple ? event.target?.checked : value === event.target.value;
31
+ let isSelected = false;
32
+ if (isMultiple) {
33
+ // @ts-ignore
34
+ let selectedValues = Array.from(this.host.querySelectorAll(`input[name="${event.target.name}"]:checked`), e => e === null || e === void 0 ? void 0 : e.value);
35
+ isSelected = selectedValues.includes(value.toString());
36
+ }
37
+ else {
38
+ isSelected = value === event.target.value;
39
+ }
40
+ salla.log('The input is ', (isMultiple ? 'Multiple' : 'Single'), ' value:', isSelected);
41
+ let showTheInput = (isEqual && isSelected) || (!isEqual && !isSelected);
42
+ if (showTheInput) {
43
+ field.classList.remove('hidden');
44
+ field.querySelectorAll('[name]').forEach((input) => {
45
+ input.removeAttribute('disabled');
46
+ //To handle focus on hidden input error
47
+ if (!['checkbox'].includes(input.getAttribute('type')) && field.getElementsByClassName('required').length) {
48
+ input.setAttribute('required', '');
49
+ }
50
+ });
51
+ }
52
+ else {
53
+ field.classList.add('hidden');
54
+ field.querySelectorAll('[name]').forEach((input) => {
55
+ input.setAttribute('disabled', '');
56
+ input.removeAttribute('required');
57
+ if (['checkbox'].includes(input.getAttribute('type')) && input.hasOwnProperty('checked')) {
58
+ // @ts-ignore
59
+ input.checked = false;
60
+ }
61
+ //firing this event will show errors, so don't run it when pageLoading.
62
+ // if (this.optionsAlreadyInitiated) {
63
+ // salla.document.event.fireEvent(input, 'change', {'bubbles': true});
64
+ // }
65
+ });
66
+ }
67
+ });
68
+ }
69
+ render() {
70
+ return (index.h(index.Host, null, index.h("slot", null)));
71
+ }
72
+ get host() { return index.getElement(this); }
73
+ };
74
+ SallaConditionalFields.style = sallaConditionalFieldsCss;
75
+
76
+ exports.salla_conditional_fields = SallaConditionalFields;
@@ -0,0 +1,64 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-0b5b5867.js');
6
+
7
+ const sallaQuantityInputCss = ":host{display:block}";
8
+
9
+ const SallaQuantityInput = class {
10
+ constructor(hostRef) {
11
+ index.registerInstance(this, hostRef);
12
+ this.hostAttributes = {};
13
+ this.hasIncrementSlot = false;
14
+ this.hasDecrementSlot = false;
15
+ this.quantity = 1;
16
+ }
17
+ /**
18
+ * Workaround to fire change event for the input.
19
+ */
20
+ watchPropHandler() {
21
+ salla.helpers.debounce(() => salla.document.event.fireEvent(this.textInput, 'change', { 'bubbles': true }))();
22
+ }
23
+ componentWillLoad() {
24
+ this.hasIncrementSlot = !!this.host.querySelector('[slot="increment-button"]');
25
+ this.hasDecrementSlot = !!this.host.querySelector('[slot="decrement-button"]');
26
+ }
27
+ // border-border-color
28
+ // transtion transition-color duration-300
29
+ componentdidLoad() {
30
+ this.quantity = parseInt(this.host.getAttribute('value')) || 1;
31
+ //app.on('input', '[name="quantity"]', event => salla.helpers.inputDigitsOnly(event.target));
32
+ }
33
+ getInputAttributes() {
34
+ for (let i = 0; i < this.host.attributes.length; i++) {
35
+ if (!['id', 'value', 'min', 'class'].includes(this.host.attributes[i].name)) {
36
+ this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
37
+ }
38
+ }
39
+ return this.hostAttributes;
40
+ }
41
+ decrement() {
42
+ if (this.quantity <= 1) {
43
+ return;
44
+ }
45
+ this.quantity--;
46
+ }
47
+ increment() {
48
+ let maxQuantity = parseInt(this.host.getAttribute('max'));
49
+ if (maxQuantity && this.quantity >= maxQuantity) {
50
+ return;
51
+ }
52
+ this.quantity++;
53
+ }
54
+ render() {
55
+ return (index.h(index.Host, { class: "s-quantity-input s-quantity-input-container" }, index.h("button", { onClick: () => this.increment(), class: "s-quantity-input-button", type: "button" }, !this.hasIncrementSlot ? index.h("i", { class: "sicon-add" }) : '', index.h("slot", { name: "increment-button" })), index.h("input", Object.assign({ class: "s-quantity-input-input" }, this.getInputAttributes(), { min: "1", value: this.quantity, ref: (el) => this.textInput = el })), index.h("button", { class: "s-quantity-input-button", onClick: () => this.decrement(), type: "button" }, !this.hasDecrementSlot ? index.h("i", { class: "sicon-minus" }) : '', index.h("slot", { name: "decrement-button" }))));
56
+ }
57
+ get host() { return index.getElement(this); }
58
+ static get watchers() { return {
59
+ "quantity": ["watchPropHandler"]
60
+ }; }
61
+ };
62
+ SallaQuantityInput.style = sallaQuantityInputCss;
63
+
64
+ exports.salla_quantity_input = SallaQuantityInput;
@@ -15,5 +15,5 @@ const patchBrowser = () => {
15
15
  };
16
16
 
17
17
  patchBrowser().then(options => {
18
- return index.bootstrapLazy([["salla-button.cjs",[[4,"salla-button",{"buttonType":[513,"button-type"],"color":[513],"fill":[513],"size":[513],"width":[513],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"href":[1],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}]]],["salla-modal_2.cjs",[[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[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"],"title":[32],"show":[64],"hide":[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],"show":[64]},[[0,"verified","onVerified"]]]]],["salla-product-availability.cjs",[[4,"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]}]]],["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],"show":[64],"hide":[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],"show":[64],"showOffer":[64]}]]],["salla-rating-modal.cjs",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-verify-modal.cjs",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}]]],["salla-tel-input.cjs",[[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}]]]], options);
18
+ return index.bootstrapLazy([["salla-button.cjs",[[4,"salla-button",{"shape":[513],"color":[513],"fill":[513],"size":[513],"width":[513],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"href":[1],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}]]],["salla-modal_2.cjs",[[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[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"],"title":[32],"show":[64],"hide":[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],"show":[64]},[[0,"verified","onVerified"]]]]],["salla-product-availability.cjs",[[4,"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]}]]],["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],"show":[64],"hide":[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],"show":[64],"showOffer":[64]}]]],["salla-rating-modal.cjs",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[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"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-quantity-input.cjs",[[4,"salla-quantity-input",{"quantity":[32]}]]],["salla-verify-modal.cjs",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}]]],["salla-tel-input.cjs",[[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}]]]], options);
19
19
  });
@@ -4,11 +4,13 @@
4
4
  "./components/salla-search/salla-search.js",
5
5
  "./components/salla-branches/salla-branches.js",
6
6
  "./components/salla-button/salla-button.js",
7
+ "./components/salla-conditional-fields/salla-conditional-fields.js",
7
8
  "./components/salla-infinite-scroll/salla-infinite-scroll.js",
8
9
  "./components/salla-localization-modal/salla-localization-modal.js",
9
10
  "./components/salla-modal/salla-modal.js",
10
11
  "./components/salla-offer-modal/salla-offer-modal.js",
11
12
  "./components/salla-product-availability/salla-product-availability.js",
13
+ "./components/salla-quantity-input/salla-quantity-input.js",
12
14
  "./components/salla-rating-modal/salla-rating-modal.js",
13
15
  "./components/salla-tel-input/salla-tel-input.js",
14
16
  "./components/salla-verify-modal/salla-verify-modal.js"
@@ -3,9 +3,9 @@ export class SallaButton {
3
3
  constructor() {
4
4
  this.hostAttributes = {};
5
5
  /**
6
- * Button Type
6
+ * Button Type todo :: find better name,
7
7
  */
8
- this.buttonType = 'btn';
8
+ this.shape = 'btn';
9
9
  /**
10
10
  * Button Color
11
11
  */
@@ -84,21 +84,21 @@ export class SallaButton {
84
84
  }
85
85
  getBtnAttributes() {
86
86
  for (let i = 0; i < this.host.attributes.length; i++) {
87
- if (!['type', 'color', 'fill', 'size', 'width', 'id', 'loading'].includes(this.host.attributes[i].name)) {
87
+ if (!['color', 'fill', 'size', 'width', 'id', 'loading'].includes(this.host.attributes[i].name)) {
88
88
  this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
89
89
  }
90
90
  }
91
91
  this.hostAttributes.type = this.hostAttributes.type || 'button';
92
92
  this.hostAttributes.class +=
93
- ' s-button-element s-button-' + this.buttonType
93
+ ' s-button-element s-button-' + this.shape
94
94
  + ' s-button-' + (this.fill == "none" ? 'fill-none' : this.fill)
95
95
  + (this.size != "medium" ? ' s-button-' + this.size : '')
96
96
  + (this.width != "normal" ? ' s-button-' + this.width : '')
97
- + (this.buttonType == "link" ? ' s-button-' + this.color + '-link' : '')
98
- + (this.buttonType != "link" && this.fill != 'outline' ? ' s-button-' + this.color : '')
97
+ + (this.shape == "link" ? ' s-button-' + this.color + '-link' : '')
98
+ + (this.shape != "link" && this.fill != 'outline' ? ' s-button-' + this.color : '')
99
99
  + (this.fill == 'outline' ? ' s-button-' + this.color + '-outline' : '')
100
100
  + (this.disabled ? ' s-button-disabled ' : '')
101
- + (this.buttonType == 'icon' ? ' s-button-loader-center' : ' s-button-loader-' + this.loaderPosition);
101
+ + (this.shape == 'icon' ? ' s-button-loader-center' : ' s-button-loader-' + this.loaderPosition);
102
102
  return this.hostAttributes;
103
103
  }
104
104
  render() {
@@ -116,7 +116,7 @@ export class SallaButton {
116
116
  "$": ["salla-button.css"]
117
117
  }; }
118
118
  static get properties() { return {
119
- "buttonType": {
119
+ "shape": {
120
120
  "type": "string",
121
121
  "mutable": false,
122
122
  "complexType": {
@@ -128,9 +128,9 @@ export class SallaButton {
128
128
  "optional": false,
129
129
  "docs": {
130
130
  "tags": [],
131
- "text": "Button Type"
131
+ "text": "Button Type todo :: find better name,"
132
132
  },
133
- "attribute": "button-type",
133
+ "attribute": "shape",
134
134
  "reflect": true,
135
135
  "defaultValue": "'btn'"
136
136
  },
@@ -0,0 +1,82 @@
1
+ import { Component, Element, Host, Listen, h } from '@stencil/core';
2
+ /**
3
+ * its to easy to use, currenlty its support select & checkbox input as trigger for show/hide the dom
4
+ * the dom you can put it like this data-show-when="{name of the field} {= or !=} {value of the field}"
5
+ */
6
+ export class SallaConditionalFields {
7
+ changeHandler(event) {
8
+ salla.log('Received the change event: ', event);
9
+ if (!['SELECT'].includes(event.target.tagName) && !['checkbox'].includes(event.target.getAttribute('type'))) {
10
+ // todo :: support debug
11
+ salla.log('Ignore the change because is not support input: ' + event.target.tagName);
12
+ return;
13
+ }
14
+ // to extract the option id from the input name, the supported names are name[*] and name[*][]
15
+ let optionId = event.target.name.replace('[]', '');
16
+ let isMultiple = event.target.getAttribute('type') === 'checkbox';
17
+ salla.log('Trying to find all the element with condation:', `[data-show-when^="${optionId}"]`);
18
+ this.host.querySelectorAll(`[data-show-when^="${optionId}"]`)
19
+ .forEach((field) => {
20
+ // @ts-ignore
21
+ let isEqual = !(field === null || field === void 0 ? void 0 : field.dataset.showWhen.includes('!='));
22
+ // @ts-ignore
23
+ let value = field === null || field === void 0 ? void 0 : field.dataset.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$3').trim();
24
+ // let isSelected = isMultiple ? event.target?.checked : value === event.target.value;
25
+ let isSelected = false;
26
+ if (isMultiple) {
27
+ // @ts-ignore
28
+ let selectedValues = Array.from(this.host.querySelectorAll(`input[name="${event.target.name}"]:checked`), e => e === null || e === void 0 ? void 0 : e.value);
29
+ isSelected = selectedValues.includes(value.toString());
30
+ }
31
+ else {
32
+ isSelected = value === event.target.value;
33
+ }
34
+ salla.log('The input is ', (isMultiple ? 'Multiple' : 'Single'), ' value:', isSelected);
35
+ let showTheInput = (isEqual && isSelected) || (!isEqual && !isSelected);
36
+ if (showTheInput) {
37
+ field.classList.remove('hidden');
38
+ field.querySelectorAll('[name]').forEach((input) => {
39
+ input.removeAttribute('disabled');
40
+ //To handle focus on hidden input error
41
+ if (!['checkbox'].includes(input.getAttribute('type')) && field.getElementsByClassName('required').length) {
42
+ input.setAttribute('required', '');
43
+ }
44
+ });
45
+ }
46
+ else {
47
+ field.classList.add('hidden');
48
+ field.querySelectorAll('[name]').forEach((input) => {
49
+ input.setAttribute('disabled', '');
50
+ input.removeAttribute('required');
51
+ if (['checkbox'].includes(input.getAttribute('type')) && input.hasOwnProperty('checked')) {
52
+ // @ts-ignore
53
+ input.checked = false;
54
+ }
55
+ //firing this event will show errors, so don't run it when pageLoading.
56
+ // if (this.optionsAlreadyInitiated) {
57
+ // salla.document.event.fireEvent(input, 'change', {'bubbles': true});
58
+ // }
59
+ });
60
+ }
61
+ });
62
+ }
63
+ render() {
64
+ return (h(Host, null,
65
+ h("slot", null)));
66
+ }
67
+ static get is() { return "salla-conditional-fields"; }
68
+ static get originalStyleUrls() { return {
69
+ "$": ["salla-conditional-fields.css"]
70
+ }; }
71
+ static get styleUrls() { return {
72
+ "$": ["salla-conditional-fields.css"]
73
+ }; }
74
+ static get elementRef() { return "host"; }
75
+ static get listeners() { return [{
76
+ "name": "change",
77
+ "method": "changeHandler",
78
+ "target": undefined,
79
+ "capture": false,
80
+ "passive": false
81
+ }]; }
82
+ }
@@ -0,0 +1,3 @@
1
+ :host {
2
+ display: block;
3
+ }
@@ -0,0 +1,71 @@
1
+ import { Component, Element, Host, State, Watch, h } from '@stencil/core';
2
+ export class SallaQuantityInput {
3
+ constructor() {
4
+ this.hostAttributes = {};
5
+ this.hasIncrementSlot = false;
6
+ this.hasDecrementSlot = false;
7
+ this.quantity = 1;
8
+ }
9
+ /**
10
+ * Workaround to fire change event for the input.
11
+ */
12
+ watchPropHandler() {
13
+ salla.helpers.debounce(() => salla.document.event.fireEvent(this.textInput, 'change', { 'bubbles': true }))();
14
+ }
15
+ componentWillLoad() {
16
+ this.hasIncrementSlot = !!this.host.querySelector('[slot="increment-button"]');
17
+ this.hasDecrementSlot = !!this.host.querySelector('[slot="decrement-button"]');
18
+ }
19
+ // border-border-color
20
+ // transtion transition-color duration-300
21
+ componentdidLoad() {
22
+ this.quantity = parseInt(this.host.getAttribute('value')) || 1;
23
+ //app.on('input', '[name="quantity"]', event => salla.helpers.inputDigitsOnly(event.target));
24
+ }
25
+ getInputAttributes() {
26
+ for (let i = 0; i < this.host.attributes.length; i++) {
27
+ if (!['id', 'value', 'min', 'class'].includes(this.host.attributes[i].name)) {
28
+ this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
29
+ }
30
+ }
31
+ return this.hostAttributes;
32
+ }
33
+ decrement() {
34
+ if (this.quantity <= 1) {
35
+ return;
36
+ }
37
+ this.quantity--;
38
+ }
39
+ increment() {
40
+ let maxQuantity = parseInt(this.host.getAttribute('max'));
41
+ if (maxQuantity && this.quantity >= maxQuantity) {
42
+ return;
43
+ }
44
+ this.quantity++;
45
+ }
46
+ render() {
47
+ return (h(Host, { class: "s-quantity-input s-quantity-input-container" },
48
+ h("button", { onClick: () => this.increment(), class: "s-quantity-input-button", type: "button" },
49
+ !this.hasIncrementSlot ? h("i", { class: "sicon-add" }) : '',
50
+ h("slot", { name: "increment-button" })),
51
+ h("input", Object.assign({ class: "s-quantity-input-input" }, this.getInputAttributes(), { min: "1", value: this.quantity, ref: (el) => this.textInput = el })),
52
+ h("button", { class: "s-quantity-input-button", onClick: () => this.decrement(), type: "button" },
53
+ !this.hasDecrementSlot ? h("i", { class: "sicon-minus" }) : '',
54
+ h("slot", { name: "decrement-button" }))));
55
+ }
56
+ static get is() { return "salla-quantity-input"; }
57
+ static get originalStyleUrls() { return {
58
+ "$": ["salla-quantity-input.css"]
59
+ }; }
60
+ static get styleUrls() { return {
61
+ "$": ["salla-quantity-input.css"]
62
+ }; }
63
+ static get states() { return {
64
+ "quantity": {}
65
+ }; }
66
+ static get elementRef() { return "host"; }
67
+ static get watchers() { return [{
68
+ "propName": "quantity",
69
+ "methodName": "watchPropHandler"
70
+ }]; }
71
+ }
@@ -10,7 +10,7 @@ const patchEsm = () => {
10
10
  const defineCustomElements = (win, options) => {
11
11
  if (typeof window === 'undefined') return Promise.resolve();
12
12
  return patchEsm().then(() => {
13
- return bootstrapLazy([["salla-button",[[4,"salla-button",{"buttonType":[513,"button-type"],"color":[513],"fill":[513],"size":[513],"width":[513],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"href":[1],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}]]],["salla-modal_2",[[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[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"],"title":[32],"show":[64],"hide":[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],"show":[64]},[[0,"verified","onVerified"]]]]],["salla-product-availability",[[4,"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]}]]],["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],"show":[64],"hide":[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],"show":[64],"showOffer":[64]}]]],["salla-rating-modal",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-verify-modal",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}]]],["salla-tel-input",[[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}]]]], options);
13
+ return bootstrapLazy([["salla-button",[[4,"salla-button",{"shape":[513],"color":[513],"fill":[513],"size":[513],"width":[513],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"href":[1],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}]]],["salla-modal_2",[[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[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"],"title":[32],"show":[64],"hide":[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],"show":[64]},[[0,"verified","onVerified"]]]]],["salla-product-availability",[[4,"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]}]]],["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],"show":[64],"hide":[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],"show":[64],"showOffer":[64]}]]],["salla-rating-modal",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-conditional-fields",[[4,"salla-conditional-fields",null,[[0,"change","changeHandler"]]]]],["salla-infinite-scroll",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-quantity-input",[[4,"salla-quantity-input",{"quantity":[32]}]]],["salla-verify-modal",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}]]],["salla-tel-input",[[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}]]]], options);
14
14
  });
15
15
  };
16
16
 
@@ -7,9 +7,9 @@ const SallaButton = class {
7
7
  registerInstance(this, hostRef);
8
8
  this.hostAttributes = {};
9
9
  /**
10
- * Button Type
10
+ * Button Type todo :: find better name,
11
11
  */
12
- this.buttonType = 'btn';
12
+ this.shape = 'btn';
13
13
  /**
14
14
  * Button Color
15
15
  */
@@ -88,21 +88,21 @@ const SallaButton = class {
88
88
  }
89
89
  getBtnAttributes() {
90
90
  for (let i = 0; i < this.host.attributes.length; i++) {
91
- if (!['type', 'color', 'fill', 'size', 'width', 'id', 'loading'].includes(this.host.attributes[i].name)) {
91
+ if (!['color', 'fill', 'size', 'width', 'id', 'loading'].includes(this.host.attributes[i].name)) {
92
92
  this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
93
93
  }
94
94
  }
95
95
  this.hostAttributes.type = this.hostAttributes.type || 'button';
96
96
  this.hostAttributes.class +=
97
- ' s-button-element s-button-' + this.buttonType
97
+ ' s-button-element s-button-' + this.shape
98
98
  + ' s-button-' + (this.fill == "none" ? 'fill-none' : this.fill)
99
99
  + (this.size != "medium" ? ' s-button-' + this.size : '')
100
100
  + (this.width != "normal" ? ' s-button-' + this.width : '')
101
- + (this.buttonType == "link" ? ' s-button-' + this.color + '-link' : '')
102
- + (this.buttonType != "link" && this.fill != 'outline' ? ' s-button-' + this.color : '')
101
+ + (this.shape == "link" ? ' s-button-' + this.color + '-link' : '')
102
+ + (this.shape != "link" && this.fill != 'outline' ? ' s-button-' + this.color : '')
103
103
  + (this.fill == 'outline' ? ' s-button-' + this.color + '-outline' : '')
104
104
  + (this.disabled ? ' s-button-disabled ' : '')
105
- + (this.buttonType == 'icon' ? ' s-button-loader-center' : ' s-button-loader-' + this.loaderPosition);
105
+ + (this.shape == 'icon' ? ' s-button-loader-center' : ' s-button-loader-' + this.loaderPosition);
106
106
  return this.hostAttributes;
107
107
  }
108
108
  render() {
@@ -0,0 +1,72 @@
1
+ import { r as registerInstance, h, H as Host, g as getElement } from './index-8b97d225.js';
2
+
3
+ const sallaConditionalFieldsCss = ":host{display:block}";
4
+
5
+ const SallaConditionalFields = class {
6
+ constructor(hostRef) {
7
+ registerInstance(this, hostRef);
8
+ }
9
+ changeHandler(event) {
10
+ salla.log('Received the change event: ', event);
11
+ if (!['SELECT'].includes(event.target.tagName) && !['checkbox'].includes(event.target.getAttribute('type'))) {
12
+ // todo :: support debug
13
+ salla.log('Ignore the change because is not support input: ' + event.target.tagName);
14
+ return;
15
+ }
16
+ // to extract the option id from the input name, the supported names are name[*] and name[*][]
17
+ let optionId = event.target.name.replace('[]', '');
18
+ let isMultiple = event.target.getAttribute('type') === 'checkbox';
19
+ salla.log('Trying to find all the element with condation:', `[data-show-when^="${optionId}"]`);
20
+ this.host.querySelectorAll(`[data-show-when^="${optionId}"]`)
21
+ .forEach((field) => {
22
+ // @ts-ignore
23
+ let isEqual = !(field === null || field === void 0 ? void 0 : field.dataset.showWhen.includes('!='));
24
+ // @ts-ignore
25
+ let value = field === null || field === void 0 ? void 0 : field.dataset.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$3').trim();
26
+ // let isSelected = isMultiple ? event.target?.checked : value === event.target.value;
27
+ let isSelected = false;
28
+ if (isMultiple) {
29
+ // @ts-ignore
30
+ let selectedValues = Array.from(this.host.querySelectorAll(`input[name="${event.target.name}"]:checked`), e => e === null || e === void 0 ? void 0 : e.value);
31
+ isSelected = selectedValues.includes(value.toString());
32
+ }
33
+ else {
34
+ isSelected = value === event.target.value;
35
+ }
36
+ salla.log('The input is ', (isMultiple ? 'Multiple' : 'Single'), ' value:', isSelected);
37
+ let showTheInput = (isEqual && isSelected) || (!isEqual && !isSelected);
38
+ if (showTheInput) {
39
+ field.classList.remove('hidden');
40
+ field.querySelectorAll('[name]').forEach((input) => {
41
+ input.removeAttribute('disabled');
42
+ //To handle focus on hidden input error
43
+ if (!['checkbox'].includes(input.getAttribute('type')) && field.getElementsByClassName('required').length) {
44
+ input.setAttribute('required', '');
45
+ }
46
+ });
47
+ }
48
+ else {
49
+ field.classList.add('hidden');
50
+ field.querySelectorAll('[name]').forEach((input) => {
51
+ input.setAttribute('disabled', '');
52
+ input.removeAttribute('required');
53
+ if (['checkbox'].includes(input.getAttribute('type')) && input.hasOwnProperty('checked')) {
54
+ // @ts-ignore
55
+ input.checked = false;
56
+ }
57
+ //firing this event will show errors, so don't run it when pageLoading.
58
+ // if (this.optionsAlreadyInitiated) {
59
+ // salla.document.event.fireEvent(input, 'change', {'bubbles': true});
60
+ // }
61
+ });
62
+ }
63
+ });
64
+ }
65
+ render() {
66
+ return (h(Host, null, h("slot", null)));
67
+ }
68
+ get host() { return getElement(this); }
69
+ };
70
+ SallaConditionalFields.style = sallaConditionalFieldsCss;
71
+
72
+ export { SallaConditionalFields as salla_conditional_fields };