@websy/websy-designs 1.11.9 → 1.11.11
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.
|
@@ -267,6 +267,9 @@ class ButtonGroup {
|
|
|
267
267
|
this.options.activeItem = -1
|
|
268
268
|
event.target.classList.remove('active')
|
|
269
269
|
}
|
|
270
|
+
if (this.options.onClick) {
|
|
271
|
+
this.options.onClick(this.options.items[index], index, event, this)
|
|
272
|
+
}
|
|
270
273
|
}
|
|
271
274
|
}
|
|
272
275
|
on (event, fn) {
|
|
@@ -2152,6 +2155,7 @@ class WebsyForm {
|
|
|
2152
2155
|
clearAfterSave: false,
|
|
2153
2156
|
fields: [],
|
|
2154
2157
|
mode: 'add',
|
|
2158
|
+
useLoader: false,
|
|
2155
2159
|
onSuccess: function (data) {},
|
|
2156
2160
|
onError: function (err) { console.log('Error submitting form data:', err) }
|
|
2157
2161
|
}
|
|
@@ -2186,6 +2190,7 @@ class WebsyForm {
|
|
|
2186
2190
|
if (this.options.cancelFn) {
|
|
2187
2191
|
this.options.cancelFn(this.elementId)
|
|
2188
2192
|
}
|
|
2193
|
+
this.loader.hide()
|
|
2189
2194
|
}
|
|
2190
2195
|
checkRecaptcha () {
|
|
2191
2196
|
return new Promise((resolve, reject) => {
|
|
@@ -2236,6 +2241,7 @@ class WebsyForm {
|
|
|
2236
2241
|
clear () {
|
|
2237
2242
|
const formEl = document.getElementById(`${this.elementId}Form`)
|
|
2238
2243
|
formEl.reset()
|
|
2244
|
+
this.loader.hide()
|
|
2239
2245
|
}
|
|
2240
2246
|
get data () {
|
|
2241
2247
|
const formEl = document.getElementById(`${this.elementId}Form`)
|
|
@@ -2258,6 +2264,9 @@ class WebsyForm {
|
|
|
2258
2264
|
if (this.fieldMap[key] && this.fieldMap[key].type === 'checkbox') {
|
|
2259
2265
|
data[key] = false
|
|
2260
2266
|
}
|
|
2267
|
+
else if (this.fieldMap[key] && (this.fieldMap[key].component === 'Switch' || this.fieldMap[key].component === 'WebsySwitch')) {
|
|
2268
|
+
data[key] = this.fieldMap[key].instance.options.enabled
|
|
2269
|
+
}
|
|
2261
2270
|
else if (this.fieldMap[key] && this.fieldMap[key].instance && this.fieldMap[key].instance.value) {
|
|
2262
2271
|
data[key] = this.fieldMap[key].instance.value
|
|
2263
2272
|
}
|
|
@@ -2494,6 +2503,7 @@ class WebsyForm {
|
|
|
2494
2503
|
this.options.fields.forEach((f, i) => {
|
|
2495
2504
|
this.fieldMap[f.field] = f
|
|
2496
2505
|
f.owningElement = this.elementId
|
|
2506
|
+
let inputValue = typeof f.value === 'function' ? f.value() : f.value
|
|
2497
2507
|
if (f.disabled || f.readOnly || this.options.readOnly) {
|
|
2498
2508
|
if (!f.options) {
|
|
2499
2509
|
f.options = {}
|
|
@@ -2537,7 +2547,7 @@ class WebsyForm {
|
|
|
2537
2547
|
${f.disabled || f.readOnly || this.options.readOnly ? 'disabled' : ''}
|
|
2538
2548
|
${(f.attributes || []).join(' ')}
|
|
2539
2549
|
class="websy-input websy-textarea ${f.readOnly || this.options.readOnly ? 'websy-input-readonly' : ''}"
|
|
2540
|
-
>${
|
|
2550
|
+
>${inputValue || ''}</textarea>
|
|
2541
2551
|
<span id='${this.elementId}_${f.field}_error' class='websy-form-validation-error'></span>
|
|
2542
2552
|
</div><!--
|
|
2543
2553
|
`
|
|
@@ -2556,8 +2566,8 @@ class WebsyForm {
|
|
|
2556
2566
|
${(f.attributes || []).join(' ')}
|
|
2557
2567
|
name="${f.field}"
|
|
2558
2568
|
placeholder="${f.placeholder || ''}"
|
|
2559
|
-
value="${f.type === 'date' ? '' :
|
|
2560
|
-
valueAsDate="${f.type === 'date' ?
|
|
2569
|
+
value="${f.type === 'date' ? '' : inputValue || ''}"
|
|
2570
|
+
valueAsDate="${f.type === 'date' ? inputValue : ''}"
|
|
2561
2571
|
${f.disabled || f.readOnly || this.options.readOnly ? 'disabled' : ''}
|
|
2562
2572
|
oninvalidx="this.setCustomValidity('${f.invalidMessage || 'Please fill in this field.'}')"
|
|
2563
2573
|
/>
|
|
@@ -2588,8 +2598,12 @@ class WebsyForm {
|
|
|
2588
2598
|
html += `
|
|
2589
2599
|
</form>
|
|
2590
2600
|
<div id="${this.elementId}_validationFail" class="websy-validation-failure"></div>
|
|
2601
|
+
<div id="${this.elementId}_loader" class=""></div>
|
|
2591
2602
|
`
|
|
2592
2603
|
el.innerHTML = html
|
|
2604
|
+
if (!this.loader) {
|
|
2605
|
+
this.loader = new WebsyDesigns.LoadingDialog(`${this.elementId}_loader`, { title: ' ' })
|
|
2606
|
+
}
|
|
2593
2607
|
this.processComponents(componentsToProcess, () => {
|
|
2594
2608
|
if ((this.options.useRecaptcha === true || this.options.useRecaptchaV3 === true) && typeof grecaptcha !== 'undefined') {
|
|
2595
2609
|
this.recaptchaReady()
|
|
@@ -2642,6 +2656,9 @@ class WebsyForm {
|
|
|
2642
2656
|
if (recaptchErrEl) {
|
|
2643
2657
|
recaptchErrEl.classList.add('websy-hidden')
|
|
2644
2658
|
}
|
|
2659
|
+
if (this.options.useLoader) {
|
|
2660
|
+
this.loader.show()
|
|
2661
|
+
}
|
|
2645
2662
|
const formData = new FormData(formEl)
|
|
2646
2663
|
const data = {}
|
|
2647
2664
|
const temp = new FormData(formEl)
|
|
@@ -2670,10 +2687,13 @@ class WebsyForm {
|
|
|
2670
2687
|
}
|
|
2671
2688
|
else if (this.options.submitFn) {
|
|
2672
2689
|
this.options.submitFn(data, () => {
|
|
2690
|
+
this.loader.hide()
|
|
2673
2691
|
if (this.options.clearAfterSave === true) {
|
|
2674
2692
|
// this.render()
|
|
2675
2693
|
formEl.reset()
|
|
2676
2694
|
}
|
|
2695
|
+
}, () => {
|
|
2696
|
+
this.loader.hide()
|
|
2677
2697
|
})
|
|
2678
2698
|
}
|
|
2679
2699
|
}
|
|
@@ -4851,6 +4871,9 @@ class WebsyRouter {
|
|
|
4851
4871
|
if (this.options.views[view].load) {
|
|
4852
4872
|
this.options.views[view].load(callbackFn)
|
|
4853
4873
|
}
|
|
4874
|
+
else if (callbackFn) {
|
|
4875
|
+
callbackFn()
|
|
4876
|
+
}
|
|
4854
4877
|
}
|
|
4855
4878
|
initView (view) {
|
|
4856
4879
|
return new Promise((resolve, reject) => {
|
|
@@ -4931,6 +4954,10 @@ class WebsyRouter {
|
|
|
4931
4954
|
this.showView(this.currentView, this.currentParams, 'main')
|
|
4932
4955
|
}
|
|
4933
4956
|
navigate (inputPath, group = 'main', event, popped) {
|
|
4957
|
+
if (inputPath.indexOf('http') === 0) {
|
|
4958
|
+
window.open(inputPath, '_blank')
|
|
4959
|
+
return
|
|
4960
|
+
}
|
|
4934
4961
|
if (typeof popped === 'undefined') {
|
|
4935
4962
|
popped = false
|
|
4936
4963
|
}
|
|
@@ -5156,6 +5183,12 @@ class Switch {
|
|
|
5156
5183
|
this.render()
|
|
5157
5184
|
}
|
|
5158
5185
|
}
|
|
5186
|
+
get data () {
|
|
5187
|
+
return this.options.enabled
|
|
5188
|
+
}
|
|
5189
|
+
set data (d) {
|
|
5190
|
+
this.options.enabled = d
|
|
5191
|
+
}
|
|
5159
5192
|
disable () {
|
|
5160
5193
|
this.options.enabled = false
|
|
5161
5194
|
let method = this.options.enabled === true ? 'add' : 'remove'
|
|
@@ -312,6 +312,9 @@ var ButtonGroup = /*#__PURE__*/function () {
|
|
|
312
312
|
this.options.activeItem = -1;
|
|
313
313
|
event.target.classList.remove('active');
|
|
314
314
|
}
|
|
315
|
+
if (this.options.onClick) {
|
|
316
|
+
this.options.onClick(this.options.items[index], index, event, this);
|
|
317
|
+
}
|
|
315
318
|
}
|
|
316
319
|
}
|
|
317
320
|
}, {
|
|
@@ -2142,6 +2145,7 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2142
2145
|
clearAfterSave: false,
|
|
2143
2146
|
fields: [],
|
|
2144
2147
|
mode: 'add',
|
|
2148
|
+
useLoader: false,
|
|
2145
2149
|
onSuccess: function onSuccess(data) {},
|
|
2146
2150
|
onError: function onError(err) {
|
|
2147
2151
|
console.log('Error submitting form data:', err);
|
|
@@ -2180,6 +2184,7 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2180
2184
|
if (this.options.cancelFn) {
|
|
2181
2185
|
this.options.cancelFn(this.elementId);
|
|
2182
2186
|
}
|
|
2187
|
+
this.loader.hide();
|
|
2183
2188
|
}
|
|
2184
2189
|
}, {
|
|
2185
2190
|
key: "checkRecaptcha",
|
|
@@ -2240,6 +2245,7 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2240
2245
|
value: function clear() {
|
|
2241
2246
|
var formEl = document.getElementById("".concat(this.elementId, "Form"));
|
|
2242
2247
|
formEl.reset();
|
|
2248
|
+
this.loader.hide();
|
|
2243
2249
|
}
|
|
2244
2250
|
}, {
|
|
2245
2251
|
key: "data",
|
|
@@ -2263,6 +2269,8 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2263
2269
|
if (keys.indexOf(key) === -1) {
|
|
2264
2270
|
if (this.fieldMap[key] && this.fieldMap[key].type === 'checkbox') {
|
|
2265
2271
|
data[key] = false;
|
|
2272
|
+
} else if (this.fieldMap[key] && (this.fieldMap[key].component === 'Switch' || this.fieldMap[key].component === 'WebsySwitch')) {
|
|
2273
|
+
data[key] = this.fieldMap[key].instance.options.enabled;
|
|
2266
2274
|
} else if (this.fieldMap[key] && this.fieldMap[key].instance && this.fieldMap[key].instance.value) {
|
|
2267
2275
|
data[key] = this.fieldMap[key].instance.value;
|
|
2268
2276
|
}
|
|
@@ -2524,6 +2532,7 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2524
2532
|
this.options.fields.forEach(function (f, i) {
|
|
2525
2533
|
_this18.fieldMap[f.field] = f;
|
|
2526
2534
|
f.owningElement = _this18.elementId;
|
|
2535
|
+
var inputValue = typeof f.value === 'function' ? f.value() : f.value;
|
|
2527
2536
|
if (f.disabled || f.readOnly || _this18.options.readOnly) {
|
|
2528
2537
|
if (!f.options) {
|
|
2529
2538
|
f.options = {};
|
|
@@ -2547,9 +2556,9 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2547
2556
|
componentsToProcess.push(f);
|
|
2548
2557
|
html += "\n ".concat(i > 0 ? '-->' : '', "<div id='").concat(_this18.elementId, "_").concat(f.field, "_inputContainer' style='").concat(f.style || '', "' class='websy-input-container ").concat(f.classes ? f.classes.join(' ') : '', " ").concat(f.component === 'MediaUpload' ? 'media-upload' : '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '').concat(f.required === true ? '<span class="websy-form-required-value">*</span>' : '', "\n <div id='").concat(_this18.elementId, "_input_").concat(f.field, "_component' class='form-component'></div>\n <span id='").concat(_this18.elementId, "_").concat(f.field, "_error' class='websy-form-validation-error'></span>\n </div><!--\n ");
|
|
2549
2558
|
} else if (f.type === 'longtext') {
|
|
2550
|
-
html += "\n ".concat(i > 0 ? '-->' : '', "<div id='").concat(_this18.elementId, "_").concat(f.field, "_inputContainer' style='").concat(f.style || '', "' class='websy-input-container ").concat(f.classes ? f.classes.join(' ') : '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '').concat(f.required === true ? '<span class="websy-form-required-value">*</span>' : '', "\n <textarea\n id=\"").concat(_this18.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n placeholder=\"").concat(f.placeholder || '', "\"\n data-user-type=\"").concat(f.type, "\"\n data-index=\"").concat(i, "\"\n name=\"").concat(f.field, "\" \n ").concat(f.disabled || f.readOnly || _this18.options.readOnly ? 'disabled' : '', "\n ").concat((f.attributes || []).join(' '), "\n class=\"websy-input websy-textarea ").concat(f.readOnly || _this18.options.readOnly ? 'websy-input-readonly' : '', "\"\n >").concat(
|
|
2559
|
+
html += "\n ".concat(i > 0 ? '-->' : '', "<div id='").concat(_this18.elementId, "_").concat(f.field, "_inputContainer' style='").concat(f.style || '', "' class='websy-input-container ").concat(f.classes ? f.classes.join(' ') : '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '').concat(f.required === true ? '<span class="websy-form-required-value">*</span>' : '', "\n <textarea\n id=\"").concat(_this18.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n placeholder=\"").concat(f.placeholder || '', "\"\n data-user-type=\"").concat(f.type, "\"\n data-index=\"").concat(i, "\"\n name=\"").concat(f.field, "\" \n ").concat(f.disabled || f.readOnly || _this18.options.readOnly ? 'disabled' : '', "\n ").concat((f.attributes || []).join(' '), "\n class=\"websy-input websy-textarea ").concat(f.readOnly || _this18.options.readOnly ? 'websy-input-readonly' : '', "\"\n >").concat(inputValue || '', "</textarea>\n <span id='").concat(_this18.elementId, "_").concat(f.field, "_error' class='websy-form-validation-error'></span>\n </div><!--\n ");
|
|
2551
2560
|
} else {
|
|
2552
|
-
html += "\n ".concat(i > 0 ? '-->' : '', "<div id='").concat(_this18.elementId, "_").concat(f.field, "_inputContainer' style='").concat(f.style || '', "' class='websy-input-container ").concat(f.classes ? f.classes.join(' ') : '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '').concat(f.required === true ? '<span class="websy-form-required-value">*</span>' : '', "\n <input \n id=\"").concat(_this18.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n type=\"").concat((f.type === 'expiry' ? 'text' : f.type === 'cvv' ? 'number' : f.type) || 'text', "\" \n data-user-type=\"").concat(f.type, "\"\n data-index=\"").concat(i, "\"\n class=\"websy-input ").concat(f.readOnly || _this18.options.readOnly ? 'websy-input-readonly' : '', "\" \n ").concat((f.attributes || []).join(' '), "\n name=\"").concat(f.field, "\" \n placeholder=\"").concat(f.placeholder || '', "\"\n value=\"").concat(f.type === 'date' ? '' :
|
|
2561
|
+
html += "\n ".concat(i > 0 ? '-->' : '', "<div id='").concat(_this18.elementId, "_").concat(f.field, "_inputContainer' style='").concat(f.style || '', "' class='websy-input-container ").concat(f.classes ? f.classes.join(' ') : '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '').concat(f.required === true ? '<span class="websy-form-required-value">*</span>' : '', "\n <input \n id=\"").concat(_this18.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n type=\"").concat((f.type === 'expiry' ? 'text' : f.type === 'cvv' ? 'number' : f.type) || 'text', "\" \n data-user-type=\"").concat(f.type, "\"\n data-index=\"").concat(i, "\"\n class=\"websy-input ").concat(f.readOnly || _this18.options.readOnly ? 'websy-input-readonly' : '', "\" \n ").concat((f.attributes || []).join(' '), "\n name=\"").concat(f.field, "\" \n placeholder=\"").concat(f.placeholder || '', "\"\n value=\"").concat(f.type === 'date' ? '' : inputValue || '', "\"\n valueAsDate=\"").concat(f.type === 'date' ? inputValue : '', "\"\n ").concat(f.disabled || f.readOnly || _this18.options.readOnly ? 'disabled' : '', "\n oninvalidx=\"this.setCustomValidity('").concat(f.invalidMessage || 'Please fill in this field.', "')\"\n />\n <span id='").concat(_this18.elementId, "_").concat(f.field, "_error' class='websy-form-validation-error'></span>\n </div><!--\n ");
|
|
2553
2562
|
}
|
|
2554
2563
|
});
|
|
2555
2564
|
if (this.options.useRecaptcha === true) {
|
|
@@ -2563,8 +2572,13 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2563
2572
|
if (this.options.cancel) {
|
|
2564
2573
|
html += "\n --><button class=\"websy-btn cancel ".concat(this.options.cancel.classes ? this.options.cancel.classes.join(' ') : '', "\">").concat(this.options.cancel.text || 'Cancel', "</button>\n ");
|
|
2565
2574
|
}
|
|
2566
|
-
html += " \n </form>\n <div id=\"".concat(this.elementId, "_validationFail\" class=\"websy-validation-failure\"></div>\n ");
|
|
2575
|
+
html += " \n </form>\n <div id=\"".concat(this.elementId, "_validationFail\" class=\"websy-validation-failure\"></div>\n <div id=\"").concat(this.elementId, "_loader\" class=\"\"></div>\n ");
|
|
2567
2576
|
el.innerHTML = html;
|
|
2577
|
+
if (!this.loader) {
|
|
2578
|
+
this.loader = new WebsyDesigns.LoadingDialog("".concat(this.elementId, "_loader"), {
|
|
2579
|
+
title: ' '
|
|
2580
|
+
});
|
|
2581
|
+
}
|
|
2568
2582
|
this.processComponents(componentsToProcess, function () {
|
|
2569
2583
|
if ((_this18.options.useRecaptcha === true || _this18.options.useRecaptchaV3 === true) && typeof grecaptcha !== 'undefined') {
|
|
2570
2584
|
_this18.recaptchaReady();
|
|
@@ -2619,6 +2633,9 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2619
2633
|
if (recaptchErrEl) {
|
|
2620
2634
|
recaptchErrEl.classList.add('websy-hidden');
|
|
2621
2635
|
}
|
|
2636
|
+
if (_this19.options.useLoader) {
|
|
2637
|
+
_this19.loader.show();
|
|
2638
|
+
}
|
|
2622
2639
|
var formData = new FormData(formEl);
|
|
2623
2640
|
var data = {};
|
|
2624
2641
|
var temp = new FormData(formEl);
|
|
@@ -2645,10 +2662,13 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2645
2662
|
});
|
|
2646
2663
|
} else if (_this19.options.submitFn) {
|
|
2647
2664
|
_this19.options.submitFn(data, function () {
|
|
2665
|
+
_this19.loader.hide();
|
|
2648
2666
|
if (_this19.options.clearAfterSave === true) {
|
|
2649
2667
|
// this.render()
|
|
2650
2668
|
formEl.reset();
|
|
2651
2669
|
}
|
|
2670
|
+
}, function () {
|
|
2671
|
+
_this19.loader.hide();
|
|
2652
2672
|
});
|
|
2653
2673
|
}
|
|
2654
2674
|
} else {
|
|
@@ -4680,6 +4700,8 @@ var WebsyRouter = /*#__PURE__*/function () {
|
|
|
4680
4700
|
value: function preloadView(view, callbackFn) {
|
|
4681
4701
|
if (this.options.views[view].load) {
|
|
4682
4702
|
this.options.views[view].load(callbackFn);
|
|
4703
|
+
} else if (callbackFn) {
|
|
4704
|
+
callbackFn();
|
|
4683
4705
|
}
|
|
4684
4706
|
}
|
|
4685
4707
|
}, {
|
|
@@ -4771,6 +4793,10 @@ var WebsyRouter = /*#__PURE__*/function () {
|
|
|
4771
4793
|
var group = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'main';
|
|
4772
4794
|
var event = arguments.length > 2 ? arguments[2] : undefined;
|
|
4773
4795
|
var popped = arguments.length > 3 ? arguments[3] : undefined;
|
|
4796
|
+
if (inputPath.indexOf('http') === 0) {
|
|
4797
|
+
window.open(inputPath, '_blank');
|
|
4798
|
+
return;
|
|
4799
|
+
}
|
|
4774
4800
|
if (typeof popped === 'undefined') {
|
|
4775
4801
|
popped = false;
|
|
4776
4802
|
}
|
|
@@ -5012,6 +5038,14 @@ var Switch = /*#__PURE__*/function () {
|
|
|
5012
5038
|
}
|
|
5013
5039
|
}
|
|
5014
5040
|
_createClass(Switch, [{
|
|
5041
|
+
key: "data",
|
|
5042
|
+
get: function get() {
|
|
5043
|
+
return this.options.enabled;
|
|
5044
|
+
},
|
|
5045
|
+
set: function set(d) {
|
|
5046
|
+
this.options.enabled = d;
|
|
5047
|
+
}
|
|
5048
|
+
}, {
|
|
5015
5049
|
key: "disable",
|
|
5016
5050
|
value: function disable() {
|
|
5017
5051
|
this.options.enabled = false;
|