@websy/websy-designs 1.11.10 → 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.
@@ -2360,6 +2360,7 @@ class WebsyForm {
2360
2360
  clearAfterSave: false,
2361
2361
  fields: [],
2362
2362
  mode: 'add',
2363
+ useLoader: false,
2363
2364
  onSuccess: function (data) {},
2364
2365
  onError: function (err) { console.log('Error submitting form data:', err) }
2365
2366
  }
@@ -2394,6 +2395,7 @@ class WebsyForm {
2394
2395
  if (this.options.cancelFn) {
2395
2396
  this.options.cancelFn(this.elementId)
2396
2397
  }
2398
+ this.loader.hide()
2397
2399
  }
2398
2400
  checkRecaptcha () {
2399
2401
  return new Promise((resolve, reject) => {
@@ -2444,6 +2446,7 @@ class WebsyForm {
2444
2446
  clear () {
2445
2447
  const formEl = document.getElementById(`${this.elementId}Form`)
2446
2448
  formEl.reset()
2449
+ this.loader.hide()
2447
2450
  }
2448
2451
  get data () {
2449
2452
  const formEl = document.getElementById(`${this.elementId}Form`)
@@ -2466,6 +2469,9 @@ class WebsyForm {
2466
2469
  if (this.fieldMap[key] && this.fieldMap[key].type === 'checkbox') {
2467
2470
  data[key] = false
2468
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
+ }
2469
2475
  else if (this.fieldMap[key] && this.fieldMap[key].instance && this.fieldMap[key].instance.value) {
2470
2476
  data[key] = this.fieldMap[key].instance.value
2471
2477
  }
@@ -2702,6 +2708,7 @@ class WebsyForm {
2702
2708
  this.options.fields.forEach((f, i) => {
2703
2709
  this.fieldMap[f.field] = f
2704
2710
  f.owningElement = this.elementId
2711
+ let inputValue = typeof f.value === 'function' ? f.value() : f.value
2705
2712
  if (f.disabled || f.readOnly || this.options.readOnly) {
2706
2713
  if (!f.options) {
2707
2714
  f.options = {}
@@ -2745,7 +2752,7 @@ class WebsyForm {
2745
2752
  ${f.disabled || f.readOnly || this.options.readOnly ? 'disabled' : ''}
2746
2753
  ${(f.attributes || []).join(' ')}
2747
2754
  class="websy-input websy-textarea ${f.readOnly || this.options.readOnly ? 'websy-input-readonly' : ''}"
2748
- >${f.value || ''}</textarea>
2755
+ >${inputValue || ''}</textarea>
2749
2756
  <span id='${this.elementId}_${f.field}_error' class='websy-form-validation-error'></span>
2750
2757
  </div><!--
2751
2758
  `
@@ -2764,8 +2771,8 @@ class WebsyForm {
2764
2771
  ${(f.attributes || []).join(' ')}
2765
2772
  name="${f.field}"
2766
2773
  placeholder="${f.placeholder || ''}"
2767
- value="${f.type === 'date' ? '' : f.value || ''}"
2768
- valueAsDate="${f.type === 'date' ? f.value : ''}"
2774
+ value="${f.type === 'date' ? '' : inputValue || ''}"
2775
+ valueAsDate="${f.type === 'date' ? inputValue : ''}"
2769
2776
  ${f.disabled || f.readOnly || this.options.readOnly ? 'disabled' : ''}
2770
2777
  oninvalidx="this.setCustomValidity('${f.invalidMessage || 'Please fill in this field.'}')"
2771
2778
  />
@@ -2796,8 +2803,12 @@ class WebsyForm {
2796
2803
  html += `
2797
2804
  </form>
2798
2805
  <div id="${this.elementId}_validationFail" class="websy-validation-failure"></div>
2806
+ <div id="${this.elementId}_loader" class=""></div>
2799
2807
  `
2800
2808
  el.innerHTML = html
2809
+ if (!this.loader) {
2810
+ this.loader = new WebsyDesigns.LoadingDialog(`${this.elementId}_loader`, { title: '&nbsp;' })
2811
+ }
2801
2812
  this.processComponents(componentsToProcess, () => {
2802
2813
  if ((this.options.useRecaptcha === true || this.options.useRecaptchaV3 === true) && typeof grecaptcha !== 'undefined') {
2803
2814
  this.recaptchaReady()
@@ -2850,6 +2861,9 @@ class WebsyForm {
2850
2861
  if (recaptchErrEl) {
2851
2862
  recaptchErrEl.classList.add('websy-hidden')
2852
2863
  }
2864
+ if (this.options.useLoader) {
2865
+ this.loader.show()
2866
+ }
2853
2867
  const formData = new FormData(formEl)
2854
2868
  const data = {}
2855
2869
  const temp = new FormData(formEl)
@@ -2878,10 +2892,13 @@ class WebsyForm {
2878
2892
  }
2879
2893
  else if (this.options.submitFn) {
2880
2894
  this.options.submitFn(data, () => {
2895
+ this.loader.hide()
2881
2896
  if (this.options.clearAfterSave === true) {
2882
2897
  // this.render()
2883
2898
  formEl.reset()
2884
2899
  }
2900
+ }, () => {
2901
+ this.loader.hide()
2885
2902
  })
2886
2903
  }
2887
2904
  }
@@ -5381,6 +5398,10 @@ class WebsyRouter {
5381
5398
  this.showView(this.currentView, this.currentParams, 'main')
5382
5399
  }
5383
5400
  navigate (inputPath, group = 'main', event, popped) {
5401
+ if (inputPath.indexOf('http') === 0) {
5402
+ window.open(inputPath, '_blank')
5403
+ return
5404
+ }
5384
5405
  if (typeof popped === 'undefined') {
5385
5406
  popped = false
5386
5407
  }
@@ -6052,6 +6073,12 @@ class Switch {
6052
6073
  this.render()
6053
6074
  }
6054
6075
  }
6076
+ get data () {
6077
+ return this.options.enabled
6078
+ }
6079
+ set data (d) {
6080
+ this.options.enabled = d
6081
+ }
6055
6082
  disable () {
6056
6083
  this.options.enabled = false
6057
6084
  let method = this.options.enabled === true ? 'add' : 'remove'
@@ -2324,6 +2324,7 @@ var WebsyForm = /*#__PURE__*/function () {
2324
2324
  clearAfterSave: false,
2325
2325
  fields: [],
2326
2326
  mode: 'add',
2327
+ useLoader: false,
2327
2328
  onSuccess: function onSuccess(data) {},
2328
2329
  onError: function onError(err) {
2329
2330
  console.log('Error submitting form data:', err);
@@ -2362,6 +2363,7 @@ var WebsyForm = /*#__PURE__*/function () {
2362
2363
  if (this.options.cancelFn) {
2363
2364
  this.options.cancelFn(this.elementId);
2364
2365
  }
2366
+ this.loader.hide();
2365
2367
  }
2366
2368
  }, {
2367
2369
  key: "checkRecaptcha",
@@ -2422,6 +2424,7 @@ var WebsyForm = /*#__PURE__*/function () {
2422
2424
  value: function clear() {
2423
2425
  var formEl = document.getElementById("".concat(this.elementId, "Form"));
2424
2426
  formEl.reset();
2427
+ this.loader.hide();
2425
2428
  }
2426
2429
  }, {
2427
2430
  key: "data",
@@ -2445,6 +2448,8 @@ var WebsyForm = /*#__PURE__*/function () {
2445
2448
  if (keys.indexOf(key) === -1) {
2446
2449
  if (this.fieldMap[key] && this.fieldMap[key].type === 'checkbox') {
2447
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;
2448
2453
  } else if (this.fieldMap[key] && this.fieldMap[key].instance && this.fieldMap[key].instance.value) {
2449
2454
  data[key] = this.fieldMap[key].instance.value;
2450
2455
  }
@@ -2706,6 +2711,7 @@ var WebsyForm = /*#__PURE__*/function () {
2706
2711
  this.options.fields.forEach(function (f, i) {
2707
2712
  _this20.fieldMap[f.field] = f;
2708
2713
  f.owningElement = _this20.elementId;
2714
+ var inputValue = typeof f.value === 'function' ? f.value() : f.value;
2709
2715
  if (f.disabled || f.readOnly || _this20.options.readOnly) {
2710
2716
  if (!f.options) {
2711
2717
  f.options = {};
@@ -2729,9 +2735,9 @@ var WebsyForm = /*#__PURE__*/function () {
2729
2735
  componentsToProcess.push(f);
2730
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 ");
2731
2737
  } else if (f.type === 'longtext') {
2732
- 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(f.value || '', "</textarea>\n <span id='").concat(_this20.elementId, "_").concat(f.field, "_error' class='websy-form-validation-error'></span>\n </div><!--\n ");
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 ");
2733
2739
  } else {
2734
- 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' ? '' : f.value || '', "\"\n valueAsDate=\"").concat(f.type === 'date' ? f.value : '', "\"\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 ");
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 ");
2735
2741
  }
2736
2742
  });
2737
2743
  if (this.options.useRecaptcha === true) {
@@ -2745,8 +2751,13 @@ var WebsyForm = /*#__PURE__*/function () {
2745
2751
  if (this.options.cancel) {
2746
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 ");
2747
2753
  }
2748
- 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 ");
2749
2755
  el.innerHTML = html;
2756
+ if (!this.loader) {
2757
+ this.loader = new WebsyDesigns.LoadingDialog("".concat(this.elementId, "_loader"), {
2758
+ title: '&nbsp;'
2759
+ });
2760
+ }
2750
2761
  this.processComponents(componentsToProcess, function () {
2751
2762
  if ((_this20.options.useRecaptcha === true || _this20.options.useRecaptchaV3 === true) && typeof grecaptcha !== 'undefined') {
2752
2763
  _this20.recaptchaReady();
@@ -2801,6 +2812,9 @@ var WebsyForm = /*#__PURE__*/function () {
2801
2812
  if (recaptchErrEl) {
2802
2813
  recaptchErrEl.classList.add('websy-hidden');
2803
2814
  }
2815
+ if (_this21.options.useLoader) {
2816
+ _this21.loader.show();
2817
+ }
2804
2818
  var formData = new FormData(formEl);
2805
2819
  var data = {};
2806
2820
  var temp = new FormData(formEl);
@@ -2827,10 +2841,13 @@ var WebsyForm = /*#__PURE__*/function () {
2827
2841
  });
2828
2842
  } else if (_this21.options.submitFn) {
2829
2843
  _this21.options.submitFn(data, function () {
2844
+ _this21.loader.hide();
2830
2845
  if (_this21.options.clearAfterSave === true) {
2831
2846
  // this.render()
2832
2847
  formEl.reset();
2833
2848
  }
2849
+ }, function () {
2850
+ _this21.loader.hide();
2834
2851
  });
2835
2852
  }
2836
2853
  } else {
@@ -5198,6 +5215,10 @@ var WebsyRouter = /*#__PURE__*/function () {
5198
5215
  var group = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'main';
5199
5216
  var event = arguments.length > 2 ? arguments[2] : undefined;
5200
5217
  var popped = arguments.length > 3 ? arguments[3] : undefined;
5218
+ if (inputPath.indexOf('http') === 0) {
5219
+ window.open(inputPath, '_blank');
5220
+ return;
5221
+ }
5201
5222
  if (typeof popped === 'undefined') {
5202
5223
  popped = false;
5203
5224
  }
@@ -5895,6 +5916,14 @@ var Switch = /*#__PURE__*/function () {
5895
5916
  }
5896
5917
  }
5897
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
+ }, {
5898
5927
  key: "disable",
5899
5928
  value: function disable() {
5900
5929
  this.options.enabled = false;