@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.
|
@@ -273,6 +273,9 @@ class ButtonGroup {
|
|
|
273
273
|
this.options.activeItem = -1
|
|
274
274
|
event.target.classList.remove('active')
|
|
275
275
|
}
|
|
276
|
+
if (this.options.onClick) {
|
|
277
|
+
this.options.onClick(this.options.items[index], index, event, this)
|
|
278
|
+
}
|
|
276
279
|
}
|
|
277
280
|
}
|
|
278
281
|
on (event, fn) {
|
|
@@ -2357,6 +2360,7 @@ class WebsyForm {
|
|
|
2357
2360
|
clearAfterSave: false,
|
|
2358
2361
|
fields: [],
|
|
2359
2362
|
mode: 'add',
|
|
2363
|
+
useLoader: false,
|
|
2360
2364
|
onSuccess: function (data) {},
|
|
2361
2365
|
onError: function (err) { console.log('Error submitting form data:', err) }
|
|
2362
2366
|
}
|
|
@@ -2391,6 +2395,7 @@ class WebsyForm {
|
|
|
2391
2395
|
if (this.options.cancelFn) {
|
|
2392
2396
|
this.options.cancelFn(this.elementId)
|
|
2393
2397
|
}
|
|
2398
|
+
this.loader.hide()
|
|
2394
2399
|
}
|
|
2395
2400
|
checkRecaptcha () {
|
|
2396
2401
|
return new Promise((resolve, reject) => {
|
|
@@ -2441,6 +2446,7 @@ class WebsyForm {
|
|
|
2441
2446
|
clear () {
|
|
2442
2447
|
const formEl = document.getElementById(`${this.elementId}Form`)
|
|
2443
2448
|
formEl.reset()
|
|
2449
|
+
this.loader.hide()
|
|
2444
2450
|
}
|
|
2445
2451
|
get data () {
|
|
2446
2452
|
const formEl = document.getElementById(`${this.elementId}Form`)
|
|
@@ -2463,6 +2469,9 @@ class WebsyForm {
|
|
|
2463
2469
|
if (this.fieldMap[key] && this.fieldMap[key].type === 'checkbox') {
|
|
2464
2470
|
data[key] = false
|
|
2465
2471
|
}
|
|
2472
|
+
else if (this.fieldMap[key] && (this.fieldMap[key].component === 'Switch' || this.fieldMap[key].component === 'WebsySwitch')) {
|
|
2473
|
+
data[key] = this.fieldMap[key].instance.options.enabled
|
|
2474
|
+
}
|
|
2466
2475
|
else if (this.fieldMap[key] && this.fieldMap[key].instance && this.fieldMap[key].instance.value) {
|
|
2467
2476
|
data[key] = this.fieldMap[key].instance.value
|
|
2468
2477
|
}
|
|
@@ -2699,6 +2708,7 @@ class WebsyForm {
|
|
|
2699
2708
|
this.options.fields.forEach((f, i) => {
|
|
2700
2709
|
this.fieldMap[f.field] = f
|
|
2701
2710
|
f.owningElement = this.elementId
|
|
2711
|
+
let inputValue = typeof f.value === 'function' ? f.value() : f.value
|
|
2702
2712
|
if (f.disabled || f.readOnly || this.options.readOnly) {
|
|
2703
2713
|
if (!f.options) {
|
|
2704
2714
|
f.options = {}
|
|
@@ -2742,7 +2752,7 @@ class WebsyForm {
|
|
|
2742
2752
|
${f.disabled || f.readOnly || this.options.readOnly ? 'disabled' : ''}
|
|
2743
2753
|
${(f.attributes || []).join(' ')}
|
|
2744
2754
|
class="websy-input websy-textarea ${f.readOnly || this.options.readOnly ? 'websy-input-readonly' : ''}"
|
|
2745
|
-
>${
|
|
2755
|
+
>${inputValue || ''}</textarea>
|
|
2746
2756
|
<span id='${this.elementId}_${f.field}_error' class='websy-form-validation-error'></span>
|
|
2747
2757
|
</div><!--
|
|
2748
2758
|
`
|
|
@@ -2761,8 +2771,8 @@ class WebsyForm {
|
|
|
2761
2771
|
${(f.attributes || []).join(' ')}
|
|
2762
2772
|
name="${f.field}"
|
|
2763
2773
|
placeholder="${f.placeholder || ''}"
|
|
2764
|
-
value="${f.type === 'date' ? '' :
|
|
2765
|
-
valueAsDate="${f.type === 'date' ?
|
|
2774
|
+
value="${f.type === 'date' ? '' : inputValue || ''}"
|
|
2775
|
+
valueAsDate="${f.type === 'date' ? inputValue : ''}"
|
|
2766
2776
|
${f.disabled || f.readOnly || this.options.readOnly ? 'disabled' : ''}
|
|
2767
2777
|
oninvalidx="this.setCustomValidity('${f.invalidMessage || 'Please fill in this field.'}')"
|
|
2768
2778
|
/>
|
|
@@ -2793,8 +2803,12 @@ class WebsyForm {
|
|
|
2793
2803
|
html += `
|
|
2794
2804
|
</form>
|
|
2795
2805
|
<div id="${this.elementId}_validationFail" class="websy-validation-failure"></div>
|
|
2806
|
+
<div id="${this.elementId}_loader" class=""></div>
|
|
2796
2807
|
`
|
|
2797
2808
|
el.innerHTML = html
|
|
2809
|
+
if (!this.loader) {
|
|
2810
|
+
this.loader = new WebsyDesigns.LoadingDialog(`${this.elementId}_loader`, { title: ' ' })
|
|
2811
|
+
}
|
|
2798
2812
|
this.processComponents(componentsToProcess, () => {
|
|
2799
2813
|
if ((this.options.useRecaptcha === true || this.options.useRecaptchaV3 === true) && typeof grecaptcha !== 'undefined') {
|
|
2800
2814
|
this.recaptchaReady()
|
|
@@ -2847,6 +2861,9 @@ class WebsyForm {
|
|
|
2847
2861
|
if (recaptchErrEl) {
|
|
2848
2862
|
recaptchErrEl.classList.add('websy-hidden')
|
|
2849
2863
|
}
|
|
2864
|
+
if (this.options.useLoader) {
|
|
2865
|
+
this.loader.show()
|
|
2866
|
+
}
|
|
2850
2867
|
const formData = new FormData(formEl)
|
|
2851
2868
|
const data = {}
|
|
2852
2869
|
const temp = new FormData(formEl)
|
|
@@ -2875,10 +2892,13 @@ class WebsyForm {
|
|
|
2875
2892
|
}
|
|
2876
2893
|
else if (this.options.submitFn) {
|
|
2877
2894
|
this.options.submitFn(data, () => {
|
|
2895
|
+
this.loader.hide()
|
|
2878
2896
|
if (this.options.clearAfterSave === true) {
|
|
2879
2897
|
// this.render()
|
|
2880
2898
|
formEl.reset()
|
|
2881
2899
|
}
|
|
2900
|
+
}, () => {
|
|
2901
|
+
this.loader.hide()
|
|
2882
2902
|
})
|
|
2883
2903
|
}
|
|
2884
2904
|
}
|
|
@@ -5295,6 +5315,9 @@ class WebsyRouter {
|
|
|
5295
5315
|
if (this.options.views[view].load) {
|
|
5296
5316
|
this.options.views[view].load(callbackFn)
|
|
5297
5317
|
}
|
|
5318
|
+
else if (callbackFn) {
|
|
5319
|
+
callbackFn()
|
|
5320
|
+
}
|
|
5298
5321
|
}
|
|
5299
5322
|
initView (view) {
|
|
5300
5323
|
return new Promise((resolve, reject) => {
|
|
@@ -5375,6 +5398,10 @@ class WebsyRouter {
|
|
|
5375
5398
|
this.showView(this.currentView, this.currentParams, 'main')
|
|
5376
5399
|
}
|
|
5377
5400
|
navigate (inputPath, group = 'main', event, popped) {
|
|
5401
|
+
if (inputPath.indexOf('http') === 0) {
|
|
5402
|
+
window.open(inputPath, '_blank')
|
|
5403
|
+
return
|
|
5404
|
+
}
|
|
5378
5405
|
if (typeof popped === 'undefined') {
|
|
5379
5406
|
popped = false
|
|
5380
5407
|
}
|
|
@@ -6046,6 +6073,12 @@ class Switch {
|
|
|
6046
6073
|
this.render()
|
|
6047
6074
|
}
|
|
6048
6075
|
}
|
|
6076
|
+
get data () {
|
|
6077
|
+
return this.options.enabled
|
|
6078
|
+
}
|
|
6079
|
+
set data (d) {
|
|
6080
|
+
this.options.enabled = d
|
|
6081
|
+
}
|
|
6049
6082
|
disable () {
|
|
6050
6083
|
this.options.enabled = false
|
|
6051
6084
|
let method = this.options.enabled === true ? 'add' : 'remove'
|
package/dist/websy-designs.js
CHANGED
|
@@ -313,6 +313,9 @@ var ButtonGroup = /*#__PURE__*/function () {
|
|
|
313
313
|
this.options.activeItem = -1;
|
|
314
314
|
event.target.classList.remove('active');
|
|
315
315
|
}
|
|
316
|
+
if (this.options.onClick) {
|
|
317
|
+
this.options.onClick(this.options.items[index], index, event, this);
|
|
318
|
+
}
|
|
316
319
|
}
|
|
317
320
|
}
|
|
318
321
|
}, {
|
|
@@ -2321,6 +2324,7 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2321
2324
|
clearAfterSave: false,
|
|
2322
2325
|
fields: [],
|
|
2323
2326
|
mode: 'add',
|
|
2327
|
+
useLoader: false,
|
|
2324
2328
|
onSuccess: function onSuccess(data) {},
|
|
2325
2329
|
onError: function onError(err) {
|
|
2326
2330
|
console.log('Error submitting form data:', err);
|
|
@@ -2359,6 +2363,7 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2359
2363
|
if (this.options.cancelFn) {
|
|
2360
2364
|
this.options.cancelFn(this.elementId);
|
|
2361
2365
|
}
|
|
2366
|
+
this.loader.hide();
|
|
2362
2367
|
}
|
|
2363
2368
|
}, {
|
|
2364
2369
|
key: "checkRecaptcha",
|
|
@@ -2419,6 +2424,7 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2419
2424
|
value: function clear() {
|
|
2420
2425
|
var formEl = document.getElementById("".concat(this.elementId, "Form"));
|
|
2421
2426
|
formEl.reset();
|
|
2427
|
+
this.loader.hide();
|
|
2422
2428
|
}
|
|
2423
2429
|
}, {
|
|
2424
2430
|
key: "data",
|
|
@@ -2442,6 +2448,8 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2442
2448
|
if (keys.indexOf(key) === -1) {
|
|
2443
2449
|
if (this.fieldMap[key] && this.fieldMap[key].type === 'checkbox') {
|
|
2444
2450
|
data[key] = false;
|
|
2451
|
+
} else if (this.fieldMap[key] && (this.fieldMap[key].component === 'Switch' || this.fieldMap[key].component === 'WebsySwitch')) {
|
|
2452
|
+
data[key] = this.fieldMap[key].instance.options.enabled;
|
|
2445
2453
|
} else if (this.fieldMap[key] && this.fieldMap[key].instance && this.fieldMap[key].instance.value) {
|
|
2446
2454
|
data[key] = this.fieldMap[key].instance.value;
|
|
2447
2455
|
}
|
|
@@ -2703,6 +2711,7 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2703
2711
|
this.options.fields.forEach(function (f, i) {
|
|
2704
2712
|
_this20.fieldMap[f.field] = f;
|
|
2705
2713
|
f.owningElement = _this20.elementId;
|
|
2714
|
+
var inputValue = typeof f.value === 'function' ? f.value() : f.value;
|
|
2706
2715
|
if (f.disabled || f.readOnly || _this20.options.readOnly) {
|
|
2707
2716
|
if (!f.options) {
|
|
2708
2717
|
f.options = {};
|
|
@@ -2726,9 +2735,9 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2726
2735
|
componentsToProcess.push(f);
|
|
2727
2736
|
html += "\n ".concat(i > 0 ? '-->' : '', "<div id='").concat(_this20.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(_this20.elementId, "_input_").concat(f.field, "_component' class='form-component'></div>\n <span id='").concat(_this20.elementId, "_").concat(f.field, "_error' class='websy-form-validation-error'></span>\n </div><!--\n ");
|
|
2728
2737
|
} else if (f.type === 'longtext') {
|
|
2729
|
-
html += "\n ".concat(i > 0 ? '-->' : '', "<div id='").concat(_this20.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(_this20.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 || _this20.options.readOnly ? 'disabled' : '', "\n ").concat((f.attributes || []).join(' '), "\n class=\"websy-input websy-textarea ").concat(f.readOnly || _this20.options.readOnly ? 'websy-input-readonly' : '', "\"\n >").concat(
|
|
2738
|
+
html += "\n ".concat(i > 0 ? '-->' : '', "<div id='").concat(_this20.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(_this20.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 || _this20.options.readOnly ? 'disabled' : '', "\n ").concat((f.attributes || []).join(' '), "\n class=\"websy-input websy-textarea ").concat(f.readOnly || _this20.options.readOnly ? 'websy-input-readonly' : '', "\"\n >").concat(inputValue || '', "</textarea>\n <span id='").concat(_this20.elementId, "_").concat(f.field, "_error' class='websy-form-validation-error'></span>\n </div><!--\n ");
|
|
2730
2739
|
} else {
|
|
2731
|
-
html += "\n ".concat(i > 0 ? '-->' : '', "<div id='").concat(_this20.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(_this20.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 || _this20.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' ? '' :
|
|
2740
|
+
html += "\n ".concat(i > 0 ? '-->' : '', "<div id='").concat(_this20.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(_this20.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 || _this20.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 || _this20.options.readOnly ? 'disabled' : '', "\n oninvalidx=\"this.setCustomValidity('").concat(f.invalidMessage || 'Please fill in this field.', "')\"\n />\n <span id='").concat(_this20.elementId, "_").concat(f.field, "_error' class='websy-form-validation-error'></span>\n </div><!--\n ");
|
|
2732
2741
|
}
|
|
2733
2742
|
});
|
|
2734
2743
|
if (this.options.useRecaptcha === true) {
|
|
@@ -2742,8 +2751,13 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2742
2751
|
if (this.options.cancel) {
|
|
2743
2752
|
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 ");
|
|
2744
2753
|
}
|
|
2745
|
-
html += " \n </form>\n <div id=\"".concat(this.elementId, "_validationFail\" class=\"websy-validation-failure\"></div>\n ");
|
|
2754
|
+
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 ");
|
|
2746
2755
|
el.innerHTML = html;
|
|
2756
|
+
if (!this.loader) {
|
|
2757
|
+
this.loader = new WebsyDesigns.LoadingDialog("".concat(this.elementId, "_loader"), {
|
|
2758
|
+
title: ' '
|
|
2759
|
+
});
|
|
2760
|
+
}
|
|
2747
2761
|
this.processComponents(componentsToProcess, function () {
|
|
2748
2762
|
if ((_this20.options.useRecaptcha === true || _this20.options.useRecaptchaV3 === true) && typeof grecaptcha !== 'undefined') {
|
|
2749
2763
|
_this20.recaptchaReady();
|
|
@@ -2798,6 +2812,9 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2798
2812
|
if (recaptchErrEl) {
|
|
2799
2813
|
recaptchErrEl.classList.add('websy-hidden');
|
|
2800
2814
|
}
|
|
2815
|
+
if (_this21.options.useLoader) {
|
|
2816
|
+
_this21.loader.show();
|
|
2817
|
+
}
|
|
2801
2818
|
var formData = new FormData(formEl);
|
|
2802
2819
|
var data = {};
|
|
2803
2820
|
var temp = new FormData(formEl);
|
|
@@ -2824,10 +2841,13 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2824
2841
|
});
|
|
2825
2842
|
} else if (_this21.options.submitFn) {
|
|
2826
2843
|
_this21.options.submitFn(data, function () {
|
|
2844
|
+
_this21.loader.hide();
|
|
2827
2845
|
if (_this21.options.clearAfterSave === true) {
|
|
2828
2846
|
// this.render()
|
|
2829
2847
|
formEl.reset();
|
|
2830
2848
|
}
|
|
2849
|
+
}, function () {
|
|
2850
|
+
_this21.loader.hide();
|
|
2831
2851
|
});
|
|
2832
2852
|
}
|
|
2833
2853
|
} else {
|
|
@@ -5102,6 +5122,8 @@ var WebsyRouter = /*#__PURE__*/function () {
|
|
|
5102
5122
|
value: function preloadView(view, callbackFn) {
|
|
5103
5123
|
if (this.options.views[view].load) {
|
|
5104
5124
|
this.options.views[view].load(callbackFn);
|
|
5125
|
+
} else if (callbackFn) {
|
|
5126
|
+
callbackFn();
|
|
5105
5127
|
}
|
|
5106
5128
|
}
|
|
5107
5129
|
}, {
|
|
@@ -5193,6 +5215,10 @@ var WebsyRouter = /*#__PURE__*/function () {
|
|
|
5193
5215
|
var group = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'main';
|
|
5194
5216
|
var event = arguments.length > 2 ? arguments[2] : undefined;
|
|
5195
5217
|
var popped = arguments.length > 3 ? arguments[3] : undefined;
|
|
5218
|
+
if (inputPath.indexOf('http') === 0) {
|
|
5219
|
+
window.open(inputPath, '_blank');
|
|
5220
|
+
return;
|
|
5221
|
+
}
|
|
5196
5222
|
if (typeof popped === 'undefined') {
|
|
5197
5223
|
popped = false;
|
|
5198
5224
|
}
|
|
@@ -5890,6 +5916,14 @@ var Switch = /*#__PURE__*/function () {
|
|
|
5890
5916
|
}
|
|
5891
5917
|
}
|
|
5892
5918
|
_createClass(Switch, [{
|
|
5919
|
+
key: "data",
|
|
5920
|
+
get: function get() {
|
|
5921
|
+
return this.options.enabled;
|
|
5922
|
+
},
|
|
5923
|
+
set: function set(d) {
|
|
5924
|
+
this.options.enabled = d;
|
|
5925
|
+
}
|
|
5926
|
+
}, {
|
|
5893
5927
|
key: "disable",
|
|
5894
5928
|
value: function disable() {
|
|
5895
5929
|
this.options.enabled = false;
|