@salla.sa/twilight-components 2.11.25 → 2.11.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/camera-058ddeeb.js +13 -0
- package/dist/cjs/index-1d2b3370.js +10 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{salla-button_37.cjs.entry.js → salla-button_36.cjs.entry.js} +66 -348
- package/dist/cjs/salla-conditional-fields.cjs.entry.js +99 -0
- package/dist/cjs/salla-product-options.cjs.entry.js +257 -0
- package/dist/cjs/twilight.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/salla-product-options/salla-product-options.js +11 -4
- package/dist/collection/components/salla-progress-bar/salla-progress-bar.css +34 -0
- package/dist/collection/components/salla-progress-bar/salla-progress-bar.js +196 -0
- package/dist/collection/components/salla-slider/salla-slider.js +13 -10
- package/dist/collection/global/app-dev.js +5 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/salla-product-options.js +32 -21
- package/dist/components/salla-progress-bar.d.ts +11 -0
- package/dist/components/salla-progress-bar.js +9 -0
- package/dist/components/salla-progress-bar2.js +81 -0
- package/dist/components/salla-slider2.js +11 -8
- package/dist/esm/camera-647ab50f.js +11 -0
- package/dist/esm/index-f1d446ac.js +10 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{salla-button_37.entry.js → salla-button_36.entry.js} +65 -346
- package/dist/esm/salla-conditional-fields.entry.js +95 -0
- package/dist/esm/salla-product-options.entry.js +253 -0
- package/dist/esm/twilight.js +1 -1
- package/dist/esm-es5/camera-647ab50f.js +4 -0
- package/dist/esm-es5/index-f1d446ac.js +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/salla-button_36.entry.js +53 -0
- package/dist/esm-es5/salla-conditional-fields.entry.js +4 -0
- package/dist/esm-es5/salla-product-options.entry.js +4 -0
- package/dist/esm-es5/twilight.js +1 -1
- package/dist/twilight/p-1b87ab66.system.js +1 -1
- package/dist/twilight/p-485b62a3.entry.js +36 -0
- package/dist/twilight/p-56830c52.system.entry.js +4 -0
- package/dist/twilight/p-643ea74e.entry.js +4 -0
- package/dist/twilight/p-79264f27.system.entry.js +53 -0
- package/dist/twilight/p-9b7452c1.entry.js +4 -0
- package/dist/twilight/p-c328c14e.system.js +4 -0
- package/dist/twilight/p-ccd78636.js +4 -0
- package/dist/twilight/p-dbe8db94.system.entry.js +4 -0
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/types/components/salla-product-options/interfaces.d.ts +9 -0
- package/dist/types/components/salla-progress-bar/salla-progress-bar.d.ts +35 -0
- package/dist/types/components/salla-slider/salla-slider.d.ts +1 -1
- package/dist/types/components.d.ts +72 -2
- package/package.json +4 -4
- package/dist/esm-es5/salla-button_37.entry.js +0 -53
- package/dist/twilight/p-11da4b05.entry.js +0 -36
- package/dist/twilight/p-cd5fda9d.system.entry.js +0 -53
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
7
7
|
|
|
8
8
|
const index = require('./index-1d2b3370.js');
|
|
9
9
|
const _commonjsHelpers = require('./_commonjsHelpers-691dd63b.js');
|
|
10
|
+
const camera = require('./camera-058ddeeb.js');
|
|
10
11
|
|
|
11
12
|
const sallaButtonCss = "";
|
|
12
13
|
|
|
@@ -2699,95 +2700,6 @@ const SallaCommentForm = class {
|
|
|
2699
2700
|
};
|
|
2700
2701
|
SallaCommentForm.style = sallaCommentFormCss;
|
|
2701
2702
|
|
|
2702
|
-
const SallaConditionalFields = class {
|
|
2703
|
-
constructor(hostRef) {
|
|
2704
|
-
index.registerInstance(this, hostRef);
|
|
2705
|
-
}
|
|
2706
|
-
hideAllOptions(optionId) {
|
|
2707
|
-
this.host.querySelectorAll(`[data-show-when^="options[${optionId}"]`).forEach((field) => {
|
|
2708
|
-
field.classList.add('hidden');
|
|
2709
|
-
this.hideAllOptions(field.dataset.optionId);
|
|
2710
|
-
this.disableInputs(field);
|
|
2711
|
-
});
|
|
2712
|
-
}
|
|
2713
|
-
disableInputs(field) {
|
|
2714
|
-
field.querySelectorAll('[name]').forEach((input) => {
|
|
2715
|
-
var _a;
|
|
2716
|
-
input.setAttribute('disabled', '');
|
|
2717
|
-
input.removeAttribute('required');
|
|
2718
|
-
if (((_a = input === null || input === void 0 ? void 0 : input.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'select') {
|
|
2719
|
-
input.value = '';
|
|
2720
|
-
}
|
|
2721
|
-
if (['checkbox'].includes(input.getAttribute('type')) && input.hasOwnProperty('checked')) {
|
|
2722
|
-
// @ts-ignore
|
|
2723
|
-
input.checked = false;
|
|
2724
|
-
}
|
|
2725
|
-
});
|
|
2726
|
-
}
|
|
2727
|
-
changeHandler(event) {
|
|
2728
|
-
var _a;
|
|
2729
|
-
salla.event.emit('salla-onditional-fields::change', event);
|
|
2730
|
-
salla.log('Received the change event: ', event);
|
|
2731
|
-
if (!event.target || !['SELECT'].includes(event.target.tagName) && !['checkbox'].includes(event.target.getAttribute('type'))) {
|
|
2732
|
-
salla.log('Ignore the change because is not support input: ' + (((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.tagName) || 'N/A'));
|
|
2733
|
-
return;
|
|
2734
|
-
}
|
|
2735
|
-
// to extract the option id from the input name, the supported names are name[*] and name[*][]
|
|
2736
|
-
let optionId = event.target.name.replace('[]', '');
|
|
2737
|
-
let isMultiple = event.target.getAttribute('type') === 'checkbox';
|
|
2738
|
-
salla.log('Trying to find all the element with condition:', `[data-show-when^="${optionId}"]`);
|
|
2739
|
-
this.host.querySelectorAll(`[data-show-when^="${optionId}"]`)
|
|
2740
|
-
.forEach((field) => {
|
|
2741
|
-
let isEqual = !(field === null || field === void 0 ? void 0 : field.dataset.showWhen.includes('!='));
|
|
2742
|
-
let value = field === null || field === void 0 ? void 0 : field.dataset.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$3').trim();
|
|
2743
|
-
// let isSelected = isMultiple ? event.target?.checked : value === event.target.value;
|
|
2744
|
-
let isSelected;
|
|
2745
|
-
if (isMultiple) {
|
|
2746
|
-
// @ts-ignore
|
|
2747
|
-
let selectedValues = Array.from(this.host.querySelectorAll(`input[name="${event.target.name}"]:checked`), e => e === null || e === void 0 ? void 0 : e.value);
|
|
2748
|
-
isSelected = selectedValues.includes(value.toString());
|
|
2749
|
-
}
|
|
2750
|
-
else {
|
|
2751
|
-
isSelected = value === event.target.value;
|
|
2752
|
-
}
|
|
2753
|
-
salla.log('The input is ', (isMultiple ? 'Multiple' : 'Single'), ' value:', isSelected);
|
|
2754
|
-
let showTheInput = (isEqual && isSelected) || (!isEqual && !isSelected);
|
|
2755
|
-
if (showTheInput) {
|
|
2756
|
-
field.classList.remove('hidden');
|
|
2757
|
-
field.querySelectorAll('[name]').forEach((input) => {
|
|
2758
|
-
input.removeAttribute('disabled');
|
|
2759
|
-
//To handle focus on hidden input error
|
|
2760
|
-
if (!['checkbox'].includes(input.getAttribute('type')) && field.getElementsByClassName('required').length) {
|
|
2761
|
-
input.setAttribute('required', '');
|
|
2762
|
-
}
|
|
2763
|
-
});
|
|
2764
|
-
}
|
|
2765
|
-
else {
|
|
2766
|
-
this.hideAllOptions(field.dataset.optionId);
|
|
2767
|
-
field.classList.add('hidden');
|
|
2768
|
-
this.disableInputs(field);
|
|
2769
|
-
}
|
|
2770
|
-
});
|
|
2771
|
-
}
|
|
2772
|
-
componentDidRender() {
|
|
2773
|
-
this.host.querySelectorAll(`[data-show-when]`).forEach((field) => {
|
|
2774
|
-
var _a;
|
|
2775
|
-
// @ts-ignore
|
|
2776
|
-
let optionName = (_a = field === null || field === void 0 ? void 0 : field.dataset) === null || _a === void 0 ? void 0 : _a.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$1').trim();
|
|
2777
|
-
if (!optionName) {
|
|
2778
|
-
return;
|
|
2779
|
-
}
|
|
2780
|
-
this.changeHandler({
|
|
2781
|
-
target: this.host.querySelector('[name^="' + optionName + '"]')
|
|
2782
|
-
});
|
|
2783
|
-
});
|
|
2784
|
-
}
|
|
2785
|
-
render() {
|
|
2786
|
-
return (index.h(index.Host, null, index.h("slot", null)));
|
|
2787
|
-
}
|
|
2788
|
-
get host() { return index.getElement(this); }
|
|
2789
|
-
};
|
|
2790
|
-
|
|
2791
2703
|
var HOOKS = [
|
|
2792
2704
|
"onChange",
|
|
2793
2705
|
"onClose",
|
|
@@ -21667,13 +21579,6 @@ const MailIcon = `<!-- Generated by IcoMoon.io -->
|
|
|
21667
21579
|
</svg>
|
|
21668
21580
|
`;
|
|
21669
21581
|
|
|
21670
|
-
const CameraIcon = `<!-- Generated by IcoMoon.io -->
|
|
21671
|
-
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
|
21672
|
-
<title>camera</title>
|
|
21673
|
-
<path d="M16 10.667c-4.044 0-7.333 3.289-7.333 7.333s3.289 7.333 7.333 7.333 7.333-3.289 7.333-7.333-3.289-7.333-7.333-7.333zM16 22.667c-2.573 0-4.667-2.093-4.667-4.667s2.093-4.667 4.667-4.667 4.667 2.093 4.667 4.667-2.093 4.667-4.667 4.667zM28 5.333h-3.287l-2.271-3.407c-0.248-0.371-0.664-0.593-1.109-0.593h-10.667c-0.445 0-0.861 0.223-1.109 0.593l-2.271 3.407h-3.287c-2.205 0-4 1.795-4 4v17.333c0 2.205 1.795 4 4 4h24c2.205 0 4-1.795 4-4v-17.333c0-2.205-1.795-4-4-4zM29.333 26.667c0 0.735-0.599 1.333-1.333 1.333h-24c-0.735 0-1.333-0.599-1.333-1.333v-17.333c0-0.735 0.599-1.333 1.333-1.333h4c0.445 0 0.861-0.223 1.109-0.593l2.272-3.407h9.239l2.271 3.407c0.248 0.371 0.664 0.593 1.109 0.593h4c0.735 0 1.333 0.599 1.333 1.333zM25.333 10.66c-0.736 0-1.333 0.604-1.333 1.34s0.597 1.333 1.333 1.333 1.333-0.597 1.333-1.333v-0.013c0-0.736-0.597-1.327-1.333-1.327z"></path>
|
|
21674
|
-
</svg>
|
|
21675
|
-
`;
|
|
21676
|
-
|
|
21677
21582
|
const ArrowRightIcon$1 = `<!-- Generated by IcoMoon.io -->
|
|
21678
21583
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
|
21679
21584
|
<title>keyboard_arrow_right</title>
|
|
@@ -21900,7 +21805,7 @@ const SallaLoginModal = class {
|
|
|
21900
21805
|
throw 'Please insert required fields';
|
|
21901
21806
|
}
|
|
21902
21807
|
getFilepondPlaceholder() {
|
|
21903
|
-
return `<div class="s-login-modal-filepond-placeholder"><span class="s-login-modal-filepond-placeholder-icon">${CameraIcon}</span><p class="s-login-modal-filepond-placeholder-text">${this.dragAndDrop}</p> <span class="filepond--label-action">${this.browseFromFiles}</span></div>`;
|
|
21808
|
+
return `<div class="s-login-modal-filepond-placeholder"><span class="s-login-modal-filepond-placeholder-icon">${camera.CameraIcon}</span><p class="s-login-modal-filepond-placeholder-text">${this.dragAndDrop}</p> <span class="filepond--label-action">${this.browseFromFiles}</span></div>`;
|
|
21904
21809
|
}
|
|
21905
21810
|
// eslint-disable-next-line @stencil/own-methods-must-be-private
|
|
21906
21811
|
validateField(field, errorMsg) {
|
|
@@ -23313,247 +23218,6 @@ const SallaProductAvailability = class {
|
|
|
23313
23218
|
};
|
|
23314
23219
|
SallaProductAvailability.style = sallaProductAvailabilityCss;
|
|
23315
23220
|
|
|
23316
|
-
var DisplayType;
|
|
23317
|
-
(function (DisplayType) {
|
|
23318
|
-
DisplayType["COLOR"] = "color";
|
|
23319
|
-
DisplayType["DATE"] = "date";
|
|
23320
|
-
DisplayType["DATETIME"] = "datetime";
|
|
23321
|
-
DisplayType["DONATION"] = "donation";
|
|
23322
|
-
DisplayType["IMAGE"] = "image";
|
|
23323
|
-
DisplayType["MULTIPLE_OPTIONS"] = "multiple-options";
|
|
23324
|
-
DisplayType["NUMBER"] = "number";
|
|
23325
|
-
DisplayType["SINGLE_OPTION"] = "single-option";
|
|
23326
|
-
DisplayType["SPLITTER"] = "splitter";
|
|
23327
|
-
DisplayType["TEXT"] = "text";
|
|
23328
|
-
DisplayType["TEXTAREA"] = "textarea";
|
|
23329
|
-
DisplayType["THUMBNAIL"] = "thumbnail";
|
|
23330
|
-
DisplayType["TIME"] = "time";
|
|
23331
|
-
DisplayType["RADIO"] = "radio";
|
|
23332
|
-
DisplayType["CHECKBOX"] = "checkbox";
|
|
23333
|
-
DisplayType["MAP"] = "map";
|
|
23334
|
-
DisplayType["FILE"] = "file";
|
|
23335
|
-
DisplayType["COLOR_PICKER"] = "color_picker";
|
|
23336
|
-
})(DisplayType || (DisplayType = {}));
|
|
23337
|
-
var Currency;
|
|
23338
|
-
(function (Currency) {
|
|
23339
|
-
Currency["Sar"] = "SAR";
|
|
23340
|
-
})(Currency || (Currency = {}));
|
|
23341
|
-
|
|
23342
|
-
const CheckCircleIcon = `<!-- Generated by IcoMoon.io -->
|
|
23343
|
-
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
|
23344
|
-
<title>check</title>
|
|
23345
|
-
<path d="M27.521 6.976c-0.569-0.472-1.407-0.393-1.879 0.171l-12.567 15.080-7.003-4.668c-0.615-0.411-1.441-0.244-1.849 0.369-0.409 0.612-0.244 1.441 0.369 1.849l8 5.333c0.227 0.149 0.484 0.223 0.739 0.223 0.384 0 0.763-0.165 1.027-0.48l13.333-16c0.471-0.565 0.393-1.407-0.171-1.877z"></path>
|
|
23346
|
-
</svg>
|
|
23347
|
-
`;
|
|
23348
|
-
|
|
23349
|
-
const FileIcon = `<!-- Generated by IcoMoon.io -->
|
|
23350
|
-
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
|
23351
|
-
<title>file-upload</title>
|
|
23352
|
-
<path d="M21.333 24c0.341 0 0.683-0.131 0.943-0.391 0.521-0.521 0.521-1.364 0-1.885l-5.333-5.333c-0.123-0.123-0.271-0.22-0.433-0.288-0.327-0.135-0.693-0.135-1.019 0-0.163 0.068-0.311 0.165-0.433 0.288l-5.333 5.333c-0.521 0.521-0.521 1.364 0 1.885s1.364 0.521 1.885 0l3.057-3.057v10.115c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-10.115l3.057 3.057c0.26 0.26 0.601 0.391 0.943 0.391zM28.943 9.724l-9.333-9.333c-0.249-0.251-0.589-0.391-0.943-0.391h-12c-2.205 0-4 1.795-4 4v24c0 2.205 1.795 4 4 4h4c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333h-4c-0.735 0-1.333-0.599-1.333-1.333v-24c0-0.735 0.599-1.333 1.333-1.333h11.448l8.552 8.552v16.781c0 0.735-0.599 1.333-1.333 1.333h-4c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333h4c2.205 0 4-1.795 4-4v-17.333c0-0.353-0.14-0.693-0.391-0.943z"></path>
|
|
23353
|
-
</svg>
|
|
23354
|
-
`;
|
|
23355
|
-
|
|
23356
|
-
const sallaProductOptionsCss = "";
|
|
23357
|
-
|
|
23358
|
-
const SallaProductOptions = class {
|
|
23359
|
-
constructor(hostRef) {
|
|
23360
|
-
index.registerInstance(this, hostRef);
|
|
23361
|
-
this.colorSelected = index.createEvent(this, "colorSelected", 7);
|
|
23362
|
-
this.thumbnailSelected = index.createEvent(this, "thumbnailSelected", 7);
|
|
23363
|
-
this.singleSelectOptionSelected = index.createEvent(this, "singleSelectOptionSelected", 7);
|
|
23364
|
-
this.donationMoneyEntered = index.createEvent(this, "donationMoneyEntered", 7);
|
|
23365
|
-
this.textOptionEntered = index.createEvent(this, "textOptionEntered", 7);
|
|
23366
|
-
this.textareaOptionEntered = index.createEvent(this, "textareaOptionEntered", 7);
|
|
23367
|
-
this.numberOptionEntered = index.createEvent(this, "numberOptionEntered", 7);
|
|
23368
|
-
this.itemsSelected = index.createEvent(this, "itemsSelected", 7);
|
|
23369
|
-
this.dateTimeSelected = index.createEvent(this, "dateTimeSelected", 7);
|
|
23370
|
-
this.dateSelected = index.createEvent(this, "dateSelected", 7);
|
|
23371
|
-
this.timeSelected = index.createEvent(this, "timeSelected", 7);
|
|
23372
|
-
this.colorPicked = index.createEvent(this, "colorPicked", 7);
|
|
23373
|
-
this.locationSelected = index.createEvent(this, "locationSelected", 7);
|
|
23374
|
-
this.fileTypes = {
|
|
23375
|
-
pdf: 'application/pdf',
|
|
23376
|
-
png: 'image/png',
|
|
23377
|
-
jpg: 'image/jpeg',
|
|
23378
|
-
word: 'application/msword',
|
|
23379
|
-
exl: 'application/vnd.ms-excel',
|
|
23380
|
-
txt: 'text/plain',
|
|
23381
|
-
};
|
|
23382
|
-
this.outOfStockText = salla.lang.get("pages.products.out_of_stock");
|
|
23383
|
-
this.donationAmount = salla.lang.get('pages.products.donation_amount');
|
|
23384
|
-
/**
|
|
23385
|
-
* The id of the product to which the options are going to be fetched for.
|
|
23386
|
-
*/
|
|
23387
|
-
this.productId = salla.config.get('page.id');
|
|
23388
|
-
salla.lang.onLoaded(() => {
|
|
23389
|
-
this.outOfStockText = salla.lang.get("pages.products.out_of_stock");
|
|
23390
|
-
this.donationAmount = salla.lang.get('pages.products.donation_amount');
|
|
23391
|
-
});
|
|
23392
|
-
if (this.options) {
|
|
23393
|
-
try {
|
|
23394
|
-
this.optionsData = JSON.parse(this.options);
|
|
23395
|
-
return;
|
|
23396
|
-
}
|
|
23397
|
-
catch (e) {
|
|
23398
|
-
salla.log('Bad json passed via options prop');
|
|
23399
|
-
}
|
|
23400
|
-
}
|
|
23401
|
-
if (Array.isArray(this.optionsData)) {
|
|
23402
|
-
salla.log('Options is not an array[] ---> ', this.optionsData);
|
|
23403
|
-
this.optionsData = [];
|
|
23404
|
-
}
|
|
23405
|
-
if (this.productId && !salla.url.is_page('cart')) {
|
|
23406
|
-
salla.api.product.getDetails(this.productId, ['options']).then(resp => this.optionsData = resp.data.options);
|
|
23407
|
-
}
|
|
23408
|
-
}
|
|
23409
|
-
//todo:: typo here, but I think we will drop it anyway😌
|
|
23410
|
-
handleMultiSelectFieldInput() {
|
|
23411
|
-
var checkedBoxes = this.multipleOptionDom.querySelectorAll('input[type="checkbox"]:checked');
|
|
23412
|
-
var multiSelectedItems = [];
|
|
23413
|
-
for (let checkbox of checkedBoxes) {
|
|
23414
|
-
multiSelectedItems.push(checkbox.value);
|
|
23415
|
-
}
|
|
23416
|
-
this.itemsSelected.emit(multiSelectedItems);
|
|
23417
|
-
}
|
|
23418
|
-
getLatLng(value, type) {
|
|
23419
|
-
return value
|
|
23420
|
-
? value.split(',')[type == 'lat' ? 0 : 1]
|
|
23421
|
-
: '';
|
|
23422
|
-
}
|
|
23423
|
-
getDisplayForType(option) {
|
|
23424
|
-
if (this[`${option.type}Option`]) {
|
|
23425
|
-
return this[`${option.type}Option`](option);
|
|
23426
|
-
}
|
|
23427
|
-
if (option.type === DisplayType.COLOR_PICKER) {
|
|
23428
|
-
return this.colorPickerOption(option);
|
|
23429
|
-
}
|
|
23430
|
-
if (option.type === DisplayType.MULTIPLE_OPTIONS) {
|
|
23431
|
-
return this.multipleOptions(option);
|
|
23432
|
-
}
|
|
23433
|
-
if (option.type === DisplayType.SINGLE_OPTION) {
|
|
23434
|
-
return this.singleOption(option);
|
|
23435
|
-
}
|
|
23436
|
-
salla.log(`Couldn't find options type(${option.type})😢`);
|
|
23437
|
-
return '';
|
|
23438
|
-
}
|
|
23439
|
-
getOptionShownWhen(option) {
|
|
23440
|
-
return option.visibility_condition
|
|
23441
|
-
? { "data-show-when": `options[${option.visibility_condition.option}] ${option.visibility_condition.operator} ${option.visibility_condition.value}` }
|
|
23442
|
-
: {};
|
|
23443
|
-
}
|
|
23444
|
-
//we need the cart Id for productOption Image
|
|
23445
|
-
componentWillLoad() {
|
|
23446
|
-
return salla.api.cart.getCurrentCartId();
|
|
23447
|
-
}
|
|
23448
|
-
render() {
|
|
23449
|
-
if (this.optionsData.length == 0) {
|
|
23450
|
-
return;
|
|
23451
|
-
}
|
|
23452
|
-
return (index.h(index.Host, { class: "s-product-options-wrapper" }, index.h("salla-conditional-fields", null, this.optionsData.map((option) => index.h("div", Object.assign({ class: `s-product-options-option-container${option.visibility_condition ? ' hidden' : ''}`, "data-option-id": option.id }, this.getOptionShownWhen(option)), option.name == 'splitter' ?
|
|
23453
|
-
this.splitterOption()
|
|
23454
|
-
: index.h("div", { class: "s-product-options-option" }, index.h("label", { htmlFor: 'options[' + option.id + ']', class: "s-product-options-option-label" }, index.h("b", null, option.name, option.required && index.h("span", null, " * "), " "), index.h("small", null, option.placeholder)), index.h("div", { class: "s-product-options-option-content" }, this.getDisplayForType(option))))))));
|
|
23455
|
-
}
|
|
23456
|
-
//@ts-ignore
|
|
23457
|
-
donationOption(option) {
|
|
23458
|
-
return index.h("div", { class: "s-product-options-donation-wrapper" }, index.h("input", { type: "text", id: "donating-amount", name: "donating_amount", class: "s-form-control", value: option.value, placeholder: option.placeholder, onInput: e => salla.helpers.inputDigitsOnly(e.target), onBlur: e => this.donationMoneyEntered.emit(e) }), index.h("span", { class: "s-product-options-donation-amount-currency" }, salla.config.currency(salla.config.get('user.currency_code')).symbol));
|
|
23459
|
-
}
|
|
23460
|
-
//todo:: why we need this way, use the native way!!
|
|
23461
|
-
//@ts-ignore
|
|
23462
|
-
selectThumbnail(e, value) {
|
|
23463
|
-
this.thumbnailSelected.emit(e);
|
|
23464
|
-
}
|
|
23465
|
-
fileUploader(option, additions = null) {
|
|
23466
|
-
return index.h("salla-file-upload", Object.assign({}, (additions || {}), { "payload-name": "file", value: option.value, "instant-upload": true, name: `options[${option.id}]`, height: "120px", url: salla.cart.api.getUploadImageEndpoint(), "form-data": { cart_item_id: this.productId, product_id: this.productId }, class: { "s-product-options-image-input": true, required: option.required } }), index.h("div", { class: "s-product-options-filepond-placeholder" }, index.h("span", { class: "s-product-options-filepond-placeholder-icon", innerHTML: additions.accept && additions.accept.split(',').every(type => type.includes('image'))
|
|
23467
|
-
? CameraIcon
|
|
23468
|
-
: FileIcon }), index.h("p", { class: "s-product-options-filepond-placeholder-text" }, salla.lang.get('common.uploader.drag_and_drop')), index.h("span", { class: "filepond--label-action" }, salla.lang.get('common.uploader.browse'))));
|
|
23469
|
-
}
|
|
23470
|
-
//@ts-ignore
|
|
23471
|
-
imageOption(option) {
|
|
23472
|
-
return this.fileUploader(option, { accept: 'image/png,image/jpeg,image/jpg,image/gif' });
|
|
23473
|
-
}
|
|
23474
|
-
//@ts-ignore
|
|
23475
|
-
fileOption(option) {
|
|
23476
|
-
let types = option.details.map(detail => this.fileTypes[detail.name]).filter(Boolean);
|
|
23477
|
-
return types.length
|
|
23478
|
-
? this.fileUploader(option, { accept: types.join(',') })
|
|
23479
|
-
: 'File types not selected.';
|
|
23480
|
-
}
|
|
23481
|
-
//@ts-ignore
|
|
23482
|
-
numberOption(option) {
|
|
23483
|
-
return index.h("input", { type: "text", value: option.value, class: "s-form-control", required: option.required, name: `options[${option.id}]`, placeholder: option.placeholder, onBlur: e => this.numberOptionEntered.emit(e), onInput: e => salla.helpers.inputDigitsOnly(e.target) });
|
|
23484
|
-
}
|
|
23485
|
-
//@ts-ignore
|
|
23486
|
-
splitterOption() {
|
|
23487
|
-
return index.h("div", { class: "s-product-options-splitter" });
|
|
23488
|
-
}
|
|
23489
|
-
//@ts-ignore
|
|
23490
|
-
textOption(option) {
|
|
23491
|
-
return index.h("div", { class: "s-product-options-text" }, index.h("input", { type: "text", value: option.value, class: 's-form-control', required: option.required, name: `options[${option.id}]`, placeholder: option.placeholder, onInput: e => this.textOptionEntered.emit(e) }));
|
|
23492
|
-
}
|
|
23493
|
-
//@ts-ignore
|
|
23494
|
-
textareaOption(option) {
|
|
23495
|
-
//todo::remove mt-1 class, and if it's okay to remove the tag itself will be great
|
|
23496
|
-
return index.h("div", { class: "s-product-options-textarea" }, index.h("div", { class: "mt-1" }, index.h("textarea", { rows: 4, value: option.value, class: "s-form-control", required: option.required, id: `options[${option.id}]`, name: `options[${option.id}]`, placeholder: option.placeholder, onInput: (e) => this.textareaOptionEntered.emit(e) })));
|
|
23497
|
-
}
|
|
23498
|
-
//@ts-ignore
|
|
23499
|
-
mapOption(option) {
|
|
23500
|
-
return index.h("salla-map", { zoom: 15, lat: this.getLatLng(option.value, 'lat'), lng: this.getLatLng(option.value, 'lng'), name: `options[${option.id}]`, searchable: true, required: option.required, onSelected: e => this.locationSelected.emit(e) });
|
|
23501
|
-
}
|
|
23502
|
-
colorPickerOption(option) {
|
|
23503
|
-
return index.h("salla-color-picker", { onSubmitted: e => this.colorPicked.emit(e), name: `options[${option.id}]`, required: option.required, color: option.value || '#5dd5c4' });
|
|
23504
|
-
}
|
|
23505
|
-
/**
|
|
23506
|
-
* ============= Date Time options =============
|
|
23507
|
-
*/
|
|
23508
|
-
//@ts-ignore
|
|
23509
|
-
timeOption(option) {
|
|
23510
|
-
return index.h("salla-datetime-picker", { noCalendar: true, enableTime: true, dateFormat: "h:i K", value: option.value, placeholder: option.name, required: option.required, name: `options[${option.id}]`, class: "s-product-options-time-element", onPicked: e => this.timeSelected.emit(e) });
|
|
23511
|
-
}
|
|
23512
|
-
//@ts-ignore
|
|
23513
|
-
dateOption(option) {
|
|
23514
|
-
//todo:: consider date-range @see https://github.com/SallaApp/theme-raed/blob/master/src/assets/js/partials/product-options.js#L8-L23
|
|
23515
|
-
return index.h("div", { class: "s-product-options-date-element" }, index.h("salla-datetime-picker", { value: option.value, placeholder: option.name, required: option.required, name: `options[${option.id}]`, onPicked: e => this.dateSelected.emit(e) }));
|
|
23516
|
-
}
|
|
23517
|
-
//@ts-ignore
|
|
23518
|
-
datetimeOption(option) {
|
|
23519
|
-
//todo:: consider date-range @see https://github.com/SallaApp/theme-raed/blob/master/src/assets/js/partials/product-options.js#L8-L23
|
|
23520
|
-
return index.h("div", { class: "s-product-options-datetime-element" }, index.h("salla-datetime-picker", { enableTime: true, value: option.value, dateFormat: "Y-m-d G:i:K", placeholder: option.name, required: option.required, name: `options[${option.id}]`, maxDate: option.to_date_time, minDate: option.from_date_time, onPicked: e => this.dateTimeSelected.emit(e) }));
|
|
23521
|
-
}
|
|
23522
|
-
/**
|
|
23523
|
-
* ============= Advanced options =============
|
|
23524
|
-
*/
|
|
23525
|
-
getOptionDetailName(detail, outOfStock = true) {
|
|
23526
|
-
return detail.name
|
|
23527
|
-
+ ((outOfStock && detail.is_out) ? ` - ${this.outOfStockText}` : '')
|
|
23528
|
-
+ (detail.additional_price ? ` (${salla.money(detail.additional_price)})` : '');
|
|
23529
|
-
}
|
|
23530
|
-
singleOption(option) {
|
|
23531
|
-
return index.h("div", null, index.h("select", { name: `options[${option.id}]`, required: option.required, class: "s-form-control" }, index.h("option", { value: "" }, option.placeholder), option === null || option === void 0 ? void 0 :
|
|
23532
|
-
option.details.map((detail) => {
|
|
23533
|
-
return index.h("option", { value: detail.id, disabled: detail.is_out, selected: detail.is_selected, onChange: e => this.singleSelectOptionSelected.emit(e) }, this.getOptionDetailName(detail));
|
|
23534
|
-
})));
|
|
23535
|
-
}
|
|
23536
|
-
multipleOptions(option) {
|
|
23537
|
-
return index.h("div", { ref: element => this.multipleOptionDom = element, class: { "s-product-options-multiple-options-wrapper": true, 'required': option.required } }, option === null || option === void 0 ? void 0 : option.details.map((detail) => {
|
|
23538
|
-
return index.h("div", null, index.h("input", { type: "checkbox", value: detail.id, disabled: detail.is_out, checked: detail.is_selected, name: `options[${option.id}][]`, id: `field-${option.id}-${detail.id}`, onChange: () => this.handleMultiSelectFieldInput(), "aria-describedby": `options[${option.id}]-description` }), index.h("label", { htmlFor: `field-${option.id}-${detail.id}` }, this.getOptionDetailName(detail)));
|
|
23539
|
-
}));
|
|
23540
|
-
}
|
|
23541
|
-
//@ts-ignore
|
|
23542
|
-
colorOption(option) {
|
|
23543
|
-
return index.h("fieldset", { class: "s-product-options-colors-wrapper" }, option === null || option === void 0 ? void 0 : option.details.map((detail) => index.h("div", null, index.h("input", { type: "radio", value: detail.id, disabled: detail.is_out, required: option.required, checked: detail.is_selected, name: `options[${option.id}]`, id: `color-${this.productId}-${option.id}-${detail.id}`, onChange: e => this.colorSelected.emit(e) }), index.h("label", { htmlFor: `color-${this.productId}-${option.id}-${detail.id}` }, index.h("span", { style: { "background-color": detail.color } }), index.h("p", null, this.getOptionDetailName(detail))))));
|
|
23544
|
-
}
|
|
23545
|
-
//@ts-ignore
|
|
23546
|
-
thumbnailOption(option) {
|
|
23547
|
-
return index.h("div", { class: "s-product-options-thumbnails-wrapper" }, option.details.map((detail) => {
|
|
23548
|
-
return index.h("div", null, index.h("input", { type: "radio", value: detail.id, "data-itemid": detail.id, disabled: detail.is_out, required: option.required, checked: detail.is_selected, name: `options[${option.id}]`, "data-img-id": detail.option_value, id: `option_${this.productId}-${option.id}_${detail.id}`, onChange: (e) => this.selectThumbnail(e, detail.option_value) }), index.h("label", { htmlFor: `option_${this.productId}-${option.id}_${detail.id}`, "data-img-id": detail.option_value, class: "go-to-slide" }, index.h("img", { "data-src": detail.image, src: detail.image, title: detail.name, alt: detail.name }), index.h("span", { innerHTML: CheckCircleIcon, class: "s-product-options-thumbnails-icon" })), index.h("p", null, this.getOptionDetailName(detail, false), " "), detail.is_out ?
|
|
23549
|
-
[index.h("small", { class: "s-product-options-thumbnails-stock-badge" }, this.outOfStockText), index.h("div", { class: "s-product-options-thumbnails-badge-overlay" })]
|
|
23550
|
-
: '');
|
|
23551
|
-
}));
|
|
23552
|
-
}
|
|
23553
|
-
get host() { return index.getElement(this); }
|
|
23554
|
-
};
|
|
23555
|
-
SallaProductOptions.style = sallaProductOptionsCss;
|
|
23556
|
-
|
|
23557
23221
|
const PencilRuler = `<!-- Generated by IcoMoon.io -->
|
|
23558
23222
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
|
23559
23223
|
<title>pencil-ruler</title>
|
|
@@ -23613,6 +23277,58 @@ const SallaProductSizeGuide = class {
|
|
|
23613
23277
|
};
|
|
23614
23278
|
SallaProductSizeGuide.style = sallaProductSizeGuideCss;
|
|
23615
23279
|
|
|
23280
|
+
const sallaProgressBarCss = ".s-progress-bar-header{font-size:0.875rem;line-height:1.25rem;color:#6b7280;font-weight:bold}.s-progress-bar-target-section{display:-ms-flexbox;display:flex;margin-bottom:0.625rem;font-size:0.875rem;line-height:1.25rem;-ms-flex-pack:justify;justify-content:space-between}.s-progress-bar-container{margin-bottom:0.625rem}.s-progress-bar-wrapper{background-color:#E5E7EB;width:100%;height:0.625rem;border-radius:9999px;margin-bottom:0.375rem}.s-progress-bar-progress{height:0.625rem;border-radius:9999px}.s-progress-bar-message{color:#a2a8b4;font-size:0.75rem;line-height:1rem;display:block;margin-bottom:0.625rem}";
|
|
23281
|
+
|
|
23282
|
+
const SallaProgressBar = class {
|
|
23283
|
+
constructor(hostRef) {
|
|
23284
|
+
index.registerInstance(this, hostRef);
|
|
23285
|
+
try {
|
|
23286
|
+
if (this.donation) {
|
|
23287
|
+
let donationJson = typeof this.donation == 'string' ? JSON.parse(this.donation) : this.donation;
|
|
23288
|
+
if (donationJson.can_donate) {
|
|
23289
|
+
this.value = donationJson.collected_amount;
|
|
23290
|
+
this.target = donationJson.target_amount;
|
|
23291
|
+
this.header = salla.lang.get('pages.products.target');
|
|
23292
|
+
this.message = salla.lang.get('pages.products.donation_target_date') + ' ' + donationJson.target_end_date;
|
|
23293
|
+
}
|
|
23294
|
+
else {
|
|
23295
|
+
this.message = donationJson.target_message;
|
|
23296
|
+
}
|
|
23297
|
+
}
|
|
23298
|
+
}
|
|
23299
|
+
catch (e) {
|
|
23300
|
+
salla.log('Wrong donation json');
|
|
23301
|
+
}
|
|
23302
|
+
salla.lang.onLoaded(() => {
|
|
23303
|
+
var _a, _b;
|
|
23304
|
+
this.header = (_a = this.header) === null || _a === void 0 ? void 0 : _a.replace('pages.products.target', salla.lang.get('pages.products.target'));
|
|
23305
|
+
this.message = (_b = this.message) === null || _b === void 0 ? void 0 : _b.replace('pages.products.donation_target_date', salla.lang.get('pages.products.donation_target_date'));
|
|
23306
|
+
});
|
|
23307
|
+
salla.onReady(() => {
|
|
23308
|
+
this.color = this.color || salla.config.get('theme.color.primary', "#ffd5c4");
|
|
23309
|
+
if (!this.unit) {
|
|
23310
|
+
this.unit = salla.config.currency().symbol;
|
|
23311
|
+
}
|
|
23312
|
+
});
|
|
23313
|
+
}
|
|
23314
|
+
getPercentage() {
|
|
23315
|
+
return (this.value / this.target) * 100;
|
|
23316
|
+
}
|
|
23317
|
+
render() {
|
|
23318
|
+
if (!this.target && !this.message) {
|
|
23319
|
+
return '';
|
|
23320
|
+
}
|
|
23321
|
+
return (index.h("div", { class: "s-progress-bar-container" }, this.header ? index.h("div", { class: "s-progress-bar-header" }, this.header) : '', this.getProgressBar(), this.message ? index.h("span", { class: "s-progress-bar-message" }, this.message) : ''));
|
|
23322
|
+
}
|
|
23323
|
+
getProgressBar() {
|
|
23324
|
+
return this.target ? [
|
|
23325
|
+
index.h("div", { class: "s-progress-bar-target-section" }, index.h("span", null, salla.helpers.number(this.value), " ", this.unit), index.h("span", null, salla.helpers.number(this.target), " ", this.unit)),
|
|
23326
|
+
index.h("div", { class: "s-progress-bar-wrapper" }, index.h("div", { class: "s-progress-bar-progress", style: { 'width': `${this.getPercentage()}%`, 'background-color': this.color } }))
|
|
23327
|
+
] : '';
|
|
23328
|
+
}
|
|
23329
|
+
};
|
|
23330
|
+
SallaProgressBar.style = sallaProgressBarCss;
|
|
23331
|
+
|
|
23616
23332
|
const Add = `<!-- Generated by IcoMoon.io -->
|
|
23617
23333
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
|
23618
23334
|
<title>add</title>
|
|
@@ -24740,7 +24456,7 @@ const SallaSwiper = class {
|
|
|
24740
24456
|
this.displayAllTitle = salla.lang.get('blocks.home.display_all');
|
|
24741
24457
|
});
|
|
24742
24458
|
this.hasThumbSlot = !!this.host.querySelector('[slot="thumbs"]');
|
|
24743
|
-
// if (this.enableCallToSlide) {
|
|
24459
|
+
// if (this.enableCallToSlide) {
|
|
24744
24460
|
// salla.event.on('product-options::goToSlide', data => {
|
|
24745
24461
|
// const slideIndex = this.sliderWrapper.querySelector(`[data-img-id="${data}"]`).getAttribute('data-slid-index');
|
|
24746
24462
|
// this.slideTo(parseInt(slideIndex), 300, false);
|
|
@@ -24787,15 +24503,18 @@ const SallaSwiper = class {
|
|
|
24787
24503
|
autoHeight: this.autoHeight,
|
|
24788
24504
|
lazy: true,
|
|
24789
24505
|
on: {
|
|
24790
|
-
// todo:: find better way for this workaround to show lazyLoad for duplicated slides,
|
|
24791
|
-
|
|
24506
|
+
// todo:: find better way for this workaround to show lazyLoad for duplicated slides, because it clones the slide after it's already rendered,
|
|
24507
|
+
// then it re appended it as is,in this case the image is loaded but class not added.
|
|
24508
|
+
afterInit: (slider) => {
|
|
24792
24509
|
var _a;
|
|
24793
24510
|
(_a = document.lazyLoadInstance) === null || _a === void 0 ? void 0 : _a.update();
|
|
24794
|
-
|
|
24795
|
-
|
|
24796
|
-
|
|
24797
|
-
|
|
24798
|
-
|
|
24511
|
+
this.loop && slider.slides.map(slide => {
|
|
24512
|
+
if (!slide.classList.contains('swiper-slide-duplicate')) {
|
|
24513
|
+
return;
|
|
24514
|
+
}
|
|
24515
|
+
slide.querySelectorAll('img.lazy:not(.loaded)').forEach(img => img.classList.add('loaded'));
|
|
24516
|
+
});
|
|
24517
|
+
},
|
|
24799
24518
|
},
|
|
24800
24519
|
pagination: this.pagination ? {
|
|
24801
24520
|
el: this.host.id ? `#${this.host.id} .swiper-pagination` : '',
|
|
@@ -27071,7 +26790,6 @@ exports.salla_button = SallaButton;
|
|
|
27071
26790
|
exports.salla_cart_summary = SallaCartSummary;
|
|
27072
26791
|
exports.salla_color_picker = SallaColorPicker;
|
|
27073
26792
|
exports.salla_comment_form = SallaCommentForm;
|
|
27074
|
-
exports.salla_conditional_fields = SallaConditionalFields;
|
|
27075
26793
|
exports.salla_datetime_picker = SallaDatetimePicker;
|
|
27076
26794
|
exports.salla_file_upload = SallaFileUpload;
|
|
27077
26795
|
exports.salla_gifting = SallaGifting;
|
|
@@ -27086,8 +26804,8 @@ exports.salla_modal = SallaModal;
|
|
|
27086
26804
|
exports.salla_offer_modal = SallaOfferModal;
|
|
27087
26805
|
exports.salla_placeholder = SallaPlaceholder;
|
|
27088
26806
|
exports.salla_product_availability = SallaProductAvailability;
|
|
27089
|
-
exports.salla_product_options = SallaProductOptions;
|
|
27090
26807
|
exports.salla_product_size_guide = SallaProductSizeGuide;
|
|
26808
|
+
exports.salla_progress_bar = SallaProgressBar;
|
|
27091
26809
|
exports.salla_quantity_input = SallaQuantityInput;
|
|
27092
26810
|
exports.salla_quick_order = SallaQuickOrder;
|
|
27093
26811
|
exports.salla_rating_modal = SallaRatingModal;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Crafted with ❤ by Salla
|
|
3
|
+
*/
|
|
4
|
+
'use strict';
|
|
5
|
+
|
|
6
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
7
|
+
|
|
8
|
+
const index = require('./index-1d2b3370.js');
|
|
9
|
+
|
|
10
|
+
const SallaConditionalFields = class {
|
|
11
|
+
constructor(hostRef) {
|
|
12
|
+
index.registerInstance(this, hostRef);
|
|
13
|
+
}
|
|
14
|
+
hideAllOptions(optionId) {
|
|
15
|
+
this.host.querySelectorAll(`[data-show-when^="options[${optionId}"]`).forEach((field) => {
|
|
16
|
+
field.classList.add('hidden');
|
|
17
|
+
this.hideAllOptions(field.dataset.optionId);
|
|
18
|
+
this.disableInputs(field);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
disableInputs(field) {
|
|
22
|
+
field.querySelectorAll('[name]').forEach((input) => {
|
|
23
|
+
var _a;
|
|
24
|
+
input.setAttribute('disabled', '');
|
|
25
|
+
input.removeAttribute('required');
|
|
26
|
+
if (((_a = input === null || input === void 0 ? void 0 : input.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'select') {
|
|
27
|
+
input.value = '';
|
|
28
|
+
}
|
|
29
|
+
if (['checkbox'].includes(input.getAttribute('type')) && input.hasOwnProperty('checked')) {
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
input.checked = false;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
changeHandler(event) {
|
|
36
|
+
var _a;
|
|
37
|
+
salla.event.emit('salla-onditional-fields::change', event);
|
|
38
|
+
salla.log('Received the change event: ', event);
|
|
39
|
+
if (!event.target || !['SELECT'].includes(event.target.tagName) && !['checkbox'].includes(event.target.getAttribute('type'))) {
|
|
40
|
+
salla.log('Ignore the change because is not support input: ' + (((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.tagName) || 'N/A'));
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
// to extract the option id from the input name, the supported names are name[*] and name[*][]
|
|
44
|
+
let optionId = event.target.name.replace('[]', '');
|
|
45
|
+
let isMultiple = event.target.getAttribute('type') === 'checkbox';
|
|
46
|
+
salla.log('Trying to find all the element with condition:', `[data-show-when^="${optionId}"]`);
|
|
47
|
+
this.host.querySelectorAll(`[data-show-when^="${optionId}"]`)
|
|
48
|
+
.forEach((field) => {
|
|
49
|
+
let isEqual = !(field === null || field === void 0 ? void 0 : field.dataset.showWhen.includes('!='));
|
|
50
|
+
let value = field === null || field === void 0 ? void 0 : field.dataset.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$3').trim();
|
|
51
|
+
// let isSelected = isMultiple ? event.target?.checked : value === event.target.value;
|
|
52
|
+
let isSelected;
|
|
53
|
+
if (isMultiple) {
|
|
54
|
+
// @ts-ignore
|
|
55
|
+
let selectedValues = Array.from(this.host.querySelectorAll(`input[name="${event.target.name}"]:checked`), e => e === null || e === void 0 ? void 0 : e.value);
|
|
56
|
+
isSelected = selectedValues.includes(value.toString());
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
isSelected = value === event.target.value;
|
|
60
|
+
}
|
|
61
|
+
salla.log('The input is ', (isMultiple ? 'Multiple' : 'Single'), ' value:', isSelected);
|
|
62
|
+
let showTheInput = (isEqual && isSelected) || (!isEqual && !isSelected);
|
|
63
|
+
if (showTheInput) {
|
|
64
|
+
field.classList.remove('hidden');
|
|
65
|
+
field.querySelectorAll('[name]').forEach((input) => {
|
|
66
|
+
input.removeAttribute('disabled');
|
|
67
|
+
//To handle focus on hidden input error
|
|
68
|
+
if (!['checkbox'].includes(input.getAttribute('type')) && field.getElementsByClassName('required').length) {
|
|
69
|
+
input.setAttribute('required', '');
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
this.hideAllOptions(field.dataset.optionId);
|
|
75
|
+
field.classList.add('hidden');
|
|
76
|
+
this.disableInputs(field);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
componentDidRender() {
|
|
81
|
+
this.host.querySelectorAll(`[data-show-when]`).forEach((field) => {
|
|
82
|
+
var _a;
|
|
83
|
+
// @ts-ignore
|
|
84
|
+
let optionName = (_a = field === null || field === void 0 ? void 0 : field.dataset) === null || _a === void 0 ? void 0 : _a.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$1').trim();
|
|
85
|
+
if (!optionName) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
this.changeHandler({
|
|
89
|
+
target: this.host.querySelector('[name^="' + optionName + '"]')
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
render() {
|
|
94
|
+
return (index.h(index.Host, null, index.h("slot", null)));
|
|
95
|
+
}
|
|
96
|
+
get host() { return index.getElement(this); }
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
exports.salla_conditional_fields = SallaConditionalFields;
|