@formio/js 5.0.0-rc.39 → 5.0.0-rc.41

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. package/dist/formio.builder.css +2 -2
  2. package/dist/formio.builder.min.css +1 -1
  3. package/dist/formio.embed.js +1 -1
  4. package/dist/formio.embed.min.js +1 -1
  5. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  6. package/dist/formio.form.css +2 -2
  7. package/dist/formio.form.js +5373 -2370
  8. package/dist/formio.form.min.css +1 -1
  9. package/dist/formio.form.min.js +1 -1
  10. package/dist/formio.form.min.js.LICENSE.txt +25 -7
  11. package/dist/formio.full.css +2 -2
  12. package/dist/formio.full.js +5715 -2704
  13. package/dist/formio.full.min.css +1 -1
  14. package/dist/formio.full.min.js +1 -1
  15. package/dist/formio.full.min.js.LICENSE.txt +25 -7
  16. package/dist/formio.js +143 -61
  17. package/dist/formio.min.js +1 -1
  18. package/dist/formio.min.js.LICENSE.txt +13 -1
  19. package/dist/formio.utils.js +149 -96
  20. package/dist/formio.utils.min.js +1 -1
  21. package/dist/formio.utils.min.js.LICENSE.txt +4 -4
  22. package/lib/cjs/Element.js +1 -0
  23. package/lib/cjs/Embed.js +121 -121
  24. package/lib/cjs/Webform.js +36 -13
  25. package/lib/cjs/WebformBuilder.js +4 -2
  26. package/lib/cjs/Wizard.js +6 -1
  27. package/lib/cjs/components/_classes/component/Component.js +33 -22
  28. package/lib/cjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
  29. package/lib/cjs/components/_classes/component/editForm/Component.edit.validation.js +8 -0
  30. package/lib/cjs/components/_classes/component/fixtures/comp5.js +2 -2
  31. package/lib/cjs/components/_classes/multivalue/Multivalue.js +2 -2
  32. package/lib/cjs/components/_classes/nested/NestedComponent.js +2 -2
  33. package/lib/cjs/components/address/fixtures/comp3.js +1 -1
  34. package/lib/cjs/components/builder.js +0 -2
  35. package/lib/cjs/components/button/Button.js +7 -1
  36. package/lib/cjs/components/datagrid/DataGrid.js +16 -3
  37. package/lib/cjs/components/datagrid/fixtures/comp-with-allow-calculate-override.js +68 -0
  38. package/lib/cjs/components/datagrid/fixtures/comp6.js +1 -1
  39. package/lib/cjs/components/datagrid/fixtures/index.js +5 -1
  40. package/lib/cjs/components/datagrid/fixtures/two-comp-with-allow-calculate-override.js +104 -0
  41. package/lib/cjs/components/editgrid/EditGrid.js +11 -4
  42. package/lib/cjs/components/editgrid/fixtures/formsWithEditGridAndConditions.js +923 -0
  43. package/lib/cjs/components/file/File.js +2 -2
  44. package/lib/cjs/components/file/editForm/File.edit.file.js +1 -1
  45. package/lib/cjs/components/form/Form.js +1 -1
  46. package/lib/cjs/components/html/HTML.js +11 -2
  47. package/lib/cjs/components/html/fixtures/index.js +1 -3
  48. package/lib/cjs/components/index.js +0 -2
  49. package/lib/cjs/components/recaptcha/ReCaptcha.js +46 -46
  50. package/lib/cjs/components/select/Select.js +3 -1
  51. package/lib/cjs/components/select/fixtures/comp20.js +46 -0
  52. package/lib/cjs/components/select/fixtures/comp21.js +106 -0
  53. package/lib/cjs/components/select/fixtures/index.js +5 -1
  54. package/lib/cjs/components/selectboxes/SelectBoxes.js +1 -1
  55. package/lib/cjs/components/textfield/TextField.js +63 -3
  56. package/lib/cjs/providers/storage/s3.js +5 -3
  57. package/lib/cjs/providers/storage/uploadAdapter.js +1 -1
  58. package/lib/cjs/providers/storage/url.js +19 -13
  59. package/lib/cjs/templates/Templates.js +4 -4
  60. package/lib/cjs/translations/en.js +10 -6
  61. package/lib/cjs/utils/Evaluator.js +1 -1
  62. package/lib/cjs/utils/conditionOperators/IsEqualTo.js +2 -2
  63. package/lib/cjs/utils/formUtils.js +3 -3
  64. package/lib/cjs/utils/utils.js +4 -19
  65. package/lib/cjs/widgets/CalendarWidget.js +1 -1
  66. package/lib/mjs/Element.js +1 -0
  67. package/lib/mjs/Embed.js +1 -2
  68. package/lib/mjs/FormBuilder.js +1 -2
  69. package/lib/mjs/Webform.js +36 -13
  70. package/lib/mjs/WebformBuilder.js +4 -2
  71. package/lib/mjs/Wizard.js +6 -1
  72. package/lib/mjs/builders/Builders.js +1 -2
  73. package/lib/mjs/components/Components.js +1 -2
  74. package/lib/mjs/components/_classes/component/Component.js +33 -24
  75. package/lib/mjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
  76. package/lib/mjs/components/_classes/component/editForm/Component.edit.validation.js +8 -0
  77. package/lib/mjs/components/_classes/component/fixtures/comp5.js +2 -2
  78. package/lib/mjs/components/_classes/multivalue/Multivalue.js +2 -2
  79. package/lib/mjs/components/_classes/nested/NestedComponent.js +2 -2
  80. package/lib/mjs/components/address/fixtures/comp3.js +1 -1
  81. package/lib/mjs/components/builder.js +0 -2
  82. package/lib/mjs/components/button/Button.js +7 -1
  83. package/lib/mjs/components/datagrid/DataGrid.js +15 -3
  84. package/lib/mjs/components/datagrid/fixtures/comp-with-allow-calculate-override.js +66 -0
  85. package/lib/mjs/components/datagrid/fixtures/comp6.js +1 -1
  86. package/lib/mjs/components/datagrid/fixtures/index.js +3 -1
  87. package/lib/mjs/components/datagrid/fixtures/two-comp-with-allow-calculate-override.js +102 -0
  88. package/lib/mjs/components/editgrid/EditGrid.js +11 -4
  89. package/lib/mjs/components/editgrid/fixtures/formsWithEditGridAndConditions.js +921 -0
  90. package/lib/mjs/components/file/File.js +2 -2
  91. package/lib/mjs/components/file/editForm/File.edit.file.js +1 -1
  92. package/lib/mjs/components/form/Form.js +1 -1
  93. package/lib/mjs/components/html/HTML.js +10 -2
  94. package/lib/mjs/components/html/fixtures/index.js +1 -2
  95. package/lib/mjs/components/index.js +0 -2
  96. package/lib/mjs/components/recaptcha/ReCaptcha.js +32 -43
  97. package/lib/mjs/components/select/Select.js +3 -1
  98. package/lib/mjs/components/select/fixtures/comp20.js +44 -0
  99. package/lib/mjs/components/select/fixtures/comp21.js +104 -0
  100. package/lib/mjs/components/select/fixtures/index.js +3 -1
  101. package/lib/mjs/components/selectboxes/SelectBoxes.js +1 -1
  102. package/lib/mjs/components/textfield/TextField.js +62 -3
  103. package/lib/mjs/displays/Displays.js +1 -2
  104. package/lib/mjs/licenses/Licenses.js +1 -2
  105. package/lib/mjs/providers/Providers.js +1 -2
  106. package/lib/mjs/providers/storage/s3.js +5 -3
  107. package/lib/mjs/providers/storage/uploadAdapter.js +1 -1
  108. package/lib/mjs/providers/storage/url.js +19 -13
  109. package/lib/mjs/templates/Templates.js +1 -1
  110. package/lib/mjs/translations/en.js +10 -6
  111. package/lib/mjs/utils/Evaluator.js +1 -1
  112. package/lib/mjs/utils/conditionOperators/IsEqualTo.js +2 -2
  113. package/lib/mjs/utils/formUtils.js +3 -3
  114. package/lib/mjs/utils/utils.js +2 -16
  115. package/lib/mjs/widgets/CalendarWidget.js +1 -1
  116. package/package.json +23 -22
  117. package/lib/cjs/components/html/fixtures/comp3.js +0 -31
  118. package/lib/cjs/components/resource/Resource.form.js +0 -16
  119. package/lib/cjs/components/resource/Resource.js +0 -39
  120. package/lib/cjs/components/resource/editForm/Resource.edit.display.js +0 -102
  121. package/lib/cjs/components/resource/fixtures/comp1.js +0 -30
  122. package/lib/cjs/components/resource/fixtures/comp2.js +0 -31
  123. package/lib/cjs/components/resource/fixtures/index.js +0 -10
  124. package/lib/mjs/components/html/fixtures/comp3.js +0 -29
  125. package/lib/mjs/components/resource/Resource.form.js +0 -10
  126. package/lib/mjs/components/resource/Resource.js +0 -33
  127. package/lib/mjs/components/resource/editForm/Resource.edit.display.js +0 -100
  128. package/lib/mjs/components/resource/fixtures/comp1.js +0 -28
  129. package/lib/mjs/components/resource/fixtures/comp2.js +0 -29
  130. package/lib/mjs/components/resource/fixtures/index.js +0 -3
package/lib/cjs/Wizard.js CHANGED
@@ -722,7 +722,7 @@ class Wizard extends Webform_1.default {
722
722
  if (this.enabledIndex) {
723
723
  this.enabledIndex = 0;
724
724
  }
725
- this.onChange();
725
+ this.onChange({ resetValue: true });
726
726
  this.redraw();
727
727
  return this.page;
728
728
  });
@@ -880,6 +880,11 @@ class Wizard extends Webform_1.default {
880
880
  }
881
881
  return super.redraw();
882
882
  }
883
+ rebuild() {
884
+ const currentPage = this.page;
885
+ const setCurrentPage = () => this.setPage(currentPage);
886
+ return super.rebuild().then(setCurrentPage);
887
+ }
883
888
  checkValidity(data, dirty, row, currentPageOnly, childErrors = []) {
884
889
  if (!this.checkCondition(row, data)) {
885
890
  this.setCustomValidity('');
@@ -778,6 +778,7 @@ class Component extends Element_1.default {
778
778
  return !this.component.label ||
779
779
  ((!this.isInDataGrid && this.component.hideLabel) ||
780
780
  (this.isInDataGrid && !this.component.dataGridLabel) ||
781
+ this.options.floatingLabels ||
781
782
  this.options.inputsOnly) && !this.builderMode;
782
783
  }
783
784
  transform(type, value) {
@@ -850,11 +851,7 @@ class Component extends Element_1.default {
850
851
  renderTemplate(name, data = {}, modeOption) {
851
852
  // Need to make this fall back to form if renderMode is not found similar to how we search templates.
852
853
  const mode = modeOption || this.options.renderMode || 'form';
853
- data.component = Object.assign({}, this.component);
854
- // Escape HTML provided in component description and render it as a string instead
855
- if (this.component.description) {
856
- data.component.description = FormioUtils.escapeHTML(this.component.description);
857
- }
854
+ data.component = this.component;
858
855
  data.self = this;
859
856
  data.options = this.options;
860
857
  data.readOnly = this.options.readOnly;
@@ -1068,12 +1065,12 @@ class Component extends Element_1.default {
1068
1065
  const tooltipText = this.interpolate(tooltipDataTitle || tooltipAttribute)
1069
1066
  .replace(/(?:\r\n|\r|\n)/g, '<br />');
1070
1067
  this.tooltips[index] = (0, tippy_js_1.default)(tooltip, {
1071
- allowHTML: false,
1068
+ allowHTML: true,
1072
1069
  trigger: 'mouseenter click focus',
1073
1070
  placement: 'right',
1074
1071
  zIndex: 10000,
1075
1072
  interactive: true,
1076
- content: this.t(tooltipText, { _userInput: true }),
1073
+ content: this.t(this.sanitize(tooltipText), { _userInput: true }),
1077
1074
  });
1078
1075
  }
1079
1076
  });
@@ -1850,6 +1847,10 @@ class Component extends Element_1.default {
1850
1847
  this.setElementInvalid(this.performInputMapping(element), false);
1851
1848
  });
1852
1849
  this.setInputWidgetErrorClasses(elements, hasErrors);
1850
+ // do not set error classes for hidden components
1851
+ if (!this.visible) {
1852
+ return;
1853
+ }
1853
1854
  if (hasErrors) {
1854
1855
  // Add error classes
1855
1856
  elements.forEach((input) => {
@@ -1949,7 +1950,7 @@ class Component extends Element_1.default {
1949
1950
  placeholder: this.t(this.component.placeholder, { _userInput: true }),
1950
1951
  modules: {
1951
1952
  toolbar: [
1952
- [{ 'size': ['small', false, 'large', 'huge'] }],
1953
+ [{ 'size': ['small', false, 'large', 'huge'] }], // custom dropdown
1953
1954
  [{ 'header': [1, 2, 3, 4, 5, 6, false] }],
1954
1955
  [{ 'font': [] }],
1955
1956
  ['bold', 'italic', 'underline', 'strike', { 'script': 'sub' }, { 'script': 'super' }, 'clean'],
@@ -2203,10 +2204,12 @@ class Component extends Element_1.default {
2203
2204
  defaultValue = this.getCustomDefaultValue(defaultValue);
2204
2205
  const checkMask = (value) => {
2205
2206
  if (typeof value === 'string') {
2206
- const placeholderChar = this.placeholderChar;
2207
- value = (0, vanilla_text_mask_1.conformToMask)(value, this.defaultMask, { placeholderChar }).conformedValue;
2208
- if (!FormioUtils.matchInputMask(value, this.defaultMask)) {
2209
- value = '';
2207
+ if (this.component.type !== 'textfield') {
2208
+ const placeholderChar = this.placeholderChar;
2209
+ value = (0, vanilla_text_mask_1.conformToMask)(value, this.defaultMask, { placeholderChar }).conformedValue;
2210
+ if (!FormioUtils.matchInputMask(value, this.defaultMask)) {
2211
+ value = '';
2212
+ }
2210
2213
  }
2211
2214
  }
2212
2215
  else {
@@ -2305,10 +2308,10 @@ class Component extends Element_1.default {
2305
2308
  }
2306
2309
  const input = this.performInputMapping(this.refs.input[index]);
2307
2310
  const valueMaskInput = this.refs.valueMaskInput;
2308
- if (valueMaskInput === null || valueMaskInput === void 0 ? void 0 : valueMaskInput.mask) {
2311
+ if ((valueMaskInput === null || valueMaskInput === void 0 ? void 0 : valueMaskInput.mask) && valueMaskInput.mask.textMaskInputElement) {
2309
2312
  valueMaskInput.mask.textMaskInputElement.update(value);
2310
2313
  }
2311
- if (input.mask) {
2314
+ if (input.mask && input.mask.textMaskInputElement) {
2312
2315
  input.mask.textMaskInputElement.update(value);
2313
2316
  }
2314
2317
  else if (input.widget && input.widget.setValue) {
@@ -2465,8 +2468,8 @@ class Component extends Element_1.default {
2465
2468
  }
2466
2469
  /* eslint-disable max-statements */
2467
2470
  calculateComponentValue(data, flags, row) {
2468
- // Skip value calculation for the component if we don't have entire form data set
2469
- if (lodash_1.default.isUndefined(lodash_1.default.get(this, 'root.data'))) {
2471
+ // Skip value calculation for the component if we don't have entire form data set or in builder mode
2472
+ if (this.builderMode || lodash_1.default.isUndefined(lodash_1.default.get(this, 'root.data'))) {
2470
2473
  return false;
2471
2474
  }
2472
2475
  // If no calculated value or
@@ -2474,10 +2477,16 @@ class Component extends Element_1.default {
2474
2477
  const { clearOnHide } = this.component;
2475
2478
  const shouldBeCleared = !this.visible && clearOnHide;
2476
2479
  const allowOverride = lodash_1.default.get(this.component, 'allowCalculateOverride', false);
2480
+ if (shouldBeCleared) {
2481
+ // remove calculated value so that the value is recalculated once component becomes visible
2482
+ if (this.hasOwnProperty('calculatedValue') && allowOverride) {
2483
+ lodash_1.default.unset(this, 'calculatedValue');
2484
+ }
2485
+ return false;
2486
+ }
2477
2487
  // Handle all cases when calculated values should not fire.
2478
2488
  if ((this.options.readOnly && !this.options.pdf && !this.component.calculateValue) ||
2479
2489
  !(this.component.calculateValue || this.component.calculateValueVariable) ||
2480
- shouldBeCleared ||
2481
2490
  (this.options.server && !this.component.calculateServer) ||
2482
2491
  (flags.dataSourceInitialLoading && allowOverride)) {
2483
2492
  return false;
@@ -2504,7 +2513,7 @@ class Component extends Element_1.default {
2504
2513
  this.calculationLocked = true;
2505
2514
  return false;
2506
2515
  }
2507
- const firstPass = (this.calculatedValue === undefined);
2516
+ const firstPass = (this.calculatedValue === undefined) || flags.resetValue;
2508
2517
  if (firstPass) {
2509
2518
  this.calculatedValue = null;
2510
2519
  }
@@ -2518,6 +2527,7 @@ class Component extends Element_1.default {
2518
2527
  }
2519
2528
  // Check to ensure that the calculated value is different than the previously calculated value.
2520
2529
  if (previousCalculatedValue && previousChanged && !calculationChanged) {
2530
+ this.calculatedValue = null;
2521
2531
  return false;
2522
2532
  }
2523
2533
  if (flags.isReordered || !calculationChanged) {
@@ -2525,7 +2535,7 @@ class Component extends Element_1.default {
2525
2535
  }
2526
2536
  if (fromSubmission) {
2527
2537
  // If we set value from submission and it differs from calculated one, set the calculated value to prevent overriding dataValue in the next pass
2528
- this.calculatedValue = calculatedValue;
2538
+ this.calculatedValue = (0, utils_1.fastCloneDeep)(calculatedValue);
2529
2539
  return false;
2530
2540
  }
2531
2541
  // If this is the firstPass, and the dataValue is different than to the calculatedValue.
@@ -2534,7 +2544,7 @@ class Component extends Element_1.default {
2534
2544
  return true;
2535
2545
  }
2536
2546
  }
2537
- this.calculatedValue = calculatedValue;
2547
+ this.calculatedValue = (0, utils_1.fastCloneDeep)(calculatedValue);
2538
2548
  if (changed) {
2539
2549
  if (!flags.noPristineChangeOnModified) {
2540
2550
  this.pristine = false;
@@ -2954,6 +2964,7 @@ class Component extends Element_1.default {
2954
2964
  return (this.component.protected || !this.component.persistent || (this.component.persistent === 'client-only'));
2955
2965
  }
2956
2966
  shouldSkipValidation(data, row, flags = {}) {
2967
+ const { validateWhenHidden = false } = this.component || {};
2957
2968
  const rules = [
2958
2969
  // Do not validate if the flags say not too.
2959
2970
  () => flags.noValidate,
@@ -2964,9 +2975,9 @@ class Component extends Element_1.default {
2964
2975
  // Check to see if we are editing and if so, check component persistence.
2965
2976
  () => this.isValueHidden(),
2966
2977
  // Force valid if component is hidden.
2967
- () => !this.visible,
2978
+ () => !this.visible && !validateWhenHidden,
2968
2979
  // Force valid if component is conditionally hidden.
2969
- () => !this.checkCondition(row, data)
2980
+ () => !this.checkCondition(row, data) && !validateWhenHidden
2970
2981
  ];
2971
2982
  return rules.some(pred => pred());
2972
2983
  }
@@ -373,7 +373,7 @@ exports.default = [
373
373
  {
374
374
  weight: 20,
375
375
  input: true,
376
- label: 'Schema Defenition',
376
+ label: 'Schema Definition',
377
377
  key: 'schemaDefinition',
378
378
  editor: 'ace',
379
379
  as: 'javascript',
@@ -23,6 +23,14 @@ exports.default = [
23
23
  key: 'unique',
24
24
  input: true
25
25
  },
26
+ {
27
+ weight: 100,
28
+ type: 'checkbox',
29
+ label: 'Validate When Hidden',
30
+ tooltip: 'Validates the component when it is hidden/conditionally hidden. Vaildation errors are displayed in the error alert on the form submission.',
31
+ key: 'validateWhenHidden',
32
+ input: true
33
+ },
26
34
  {
27
35
  weight: 0,
28
36
  type: 'select',
@@ -6,8 +6,8 @@ exports.default = {
6
6
  components: [
7
7
  {
8
8
  label: 'Text Field',
9
- description: "<img src='https://somesite' onerror='var _ee = 2' >",
10
- tooltip: "<img src='https://somesite' onerror='var _ee = 1' >",
9
+ description: "<img <img src='https://somesite' onerror='var _ee = 2' >",
10
+ tooltip: "<img src='https://somesite' onerror='var _ee = 1 >",
11
11
  applyMaskOn: 'change',
12
12
  tableView: true,
13
13
  key: 'textField',
@@ -100,7 +100,7 @@ class Multivalue extends Field_1.default {
100
100
  if (this.refs.input && this.refs.input.length) {
101
101
  this.refs.input.forEach((input) => {
102
102
  if (input.mask) {
103
- input.mask.destroy();
103
+ input.mask.destroy ? input.mask.destroy() : input.mask.remove();
104
104
  }
105
105
  if (input.widget) {
106
106
  input.widget.destroy();
@@ -110,7 +110,7 @@ class Multivalue extends Field_1.default {
110
110
  if (this.refs.mask && this.refs.mask.length) {
111
111
  this.refs.mask.forEach((input) => {
112
112
  if (input.mask) {
113
- input.mask.destroy();
113
+ input.mask.destroy ? input.mask.destroy() : input.mask.remove();
114
114
  }
115
115
  });
116
116
  }
@@ -511,8 +511,8 @@ class NestedComponent extends Field_1.default {
511
511
  flags = flags || {};
512
512
  row = row || this.data;
513
513
  components = components && lodash_1.default.isArray(components) ? components : this.getComponents();
514
- super.checkData(data, flags, row);
515
- components.forEach((comp) => comp.checkData(data, flags, row));
514
+ super.checkData(data, Object.assign({}, flags), row);
515
+ components.forEach((comp) => comp.checkData(data, Object.assign({}, flags), row));
516
516
  }
517
517
  checkConditions(data, flags, row) {
518
518
  // check conditions of parent component first, because it may influence on visibility of it's children
@@ -14,7 +14,7 @@ exports.default = {
14
14
  providerOptions: {
15
15
  params: {
16
16
  autocompleteOptions: {},
17
- key: 'AIzaSyBNL2e4MnmyPj9zN7SVAe428nCSLP1X144',
17
+ key: '',
18
18
  },
19
19
  },
20
20
  input: true,
@@ -31,7 +31,6 @@ const Password_form_1 = __importDefault(require("./password/Password.form"));
31
31
  const PhoneNumber_form_1 = __importDefault(require("./phonenumber/PhoneNumber.form"));
32
32
  const Radio_form_1 = __importDefault(require("./radio/Radio.form"));
33
33
  const ReCaptcha_form_1 = __importDefault(require("./recaptcha/ReCaptcha.form"));
34
- const Resource_form_1 = __importDefault(require("./resource/Resource.form"));
35
34
  const SelectBoxes_form_1 = __importDefault(require("./selectboxes/SelectBoxes.form"));
36
35
  const Select_form_1 = __importDefault(require("./select/Select.form"));
37
36
  const Signature_form_1 = __importDefault(require("./signature/Signature.form"));
@@ -72,7 +71,6 @@ _1.default.password.editForm = Password_form_1.default;
72
71
  _1.default.phoneNumber.editForm = PhoneNumber_form_1.default;
73
72
  _1.default.radio.editForm = Radio_form_1.default;
74
73
  _1.default.recaptcha.editForm = ReCaptcha_form_1.default;
75
- _1.default.resource.editForm = Resource_form_1.default;
76
74
  _1.default.select.editForm = Select_form_1.default;
77
75
  _1.default.selectboxes.editForm = SelectBoxes_form_1.default;
78
76
  _1.default.signature.editForm = Signature_form_1.default;
@@ -364,9 +364,15 @@ class ButtonComponent extends Field_1.default {
364
364
  response_type: 'code',
365
365
  client_id: settings.clientId,
366
366
  redirect_uri: (settings.redirectURI && this.interpolate(settings.redirectURI)) || window.location.origin || `${window.location.protocol}//${window.location.host}`,
367
- state: settings.state,
368
367
  scope: settings.scope
369
368
  };
369
+ if (settings.state) {
370
+ params.state = settings.state;
371
+ }
372
+ else if (settings.code_challenge) {
373
+ params.code_challenge = settings.code_challenge;
374
+ params.code_challenge_method = 'S256';
375
+ }
370
376
  /*eslint-enable camelcase */
371
377
  // Needs for the correct redirection URI for the OpenID
372
378
  const originalRedirectUri = params.redirect_uri;
@@ -127,6 +127,16 @@ class DataGridComponent extends NestedArrayComponent_1.default {
127
127
  data: this.dataValue[index],
128
128
  }));
129
129
  }
130
+ isEmpty(value = this.dataValue) {
131
+ var _a;
132
+ const isEmpty = super.isEmpty(value);
133
+ if ((_a = this.components) === null || _a === void 0 ? void 0 : _a.length) {
134
+ return this.components.reduce((isEmpty, component) => {
135
+ return isEmpty && component.isEmpty();
136
+ }, true);
137
+ }
138
+ return isEmpty;
139
+ }
130
140
  /**
131
141
  * Split rows into chunks.
132
142
  * @param {Number[]} groups - array of numbers where each item is size of group
@@ -403,12 +413,14 @@ class DataGridComponent extends NestedArrayComponent_1.default {
403
413
  });
404
414
  }
405
415
  removeRow(index) {
406
- this.splice(index, { isReordered: true });
416
+ const makeEmpty = index === 0 && this.rows.length === 1;
417
+ const flags = { isReordered: !makeEmpty, resetValue: makeEmpty };
418
+ this.splice(index, flags);
407
419
  this.emit('dataGridDeleteRow', { index });
408
420
  const [row] = this.rows.splice(index, 1);
409
421
  this.removeRowComponents(row);
410
422
  this.updateRowsComponents(index);
411
- this.setValue(this.dataValue, { isReordered: true });
423
+ this.setValue(this.dataValue, flags);
412
424
  this.redraw();
413
425
  }
414
426
  removeRowComponents(row) {
@@ -555,7 +567,8 @@ class DataGridComponent extends NestedArrayComponent_1.default {
555
567
  const isSettingSubmission = flags.fromSubmission && !lodash_1.default.isEqual(value, this.emptyValue);
556
568
  const changed = this.hasChanged(value, this.dataValue);
557
569
  this.dataValue = value;
558
- if (this.initRows || isSettingSubmission) {
570
+ if (this.initRows || isSettingSubmission ||
571
+ (Array.isArray(this.dataValue) && this.dataValue.length !== this.rows.length)) {
559
572
  if (!this.createRows() && changed) {
560
573
  this.redraw();
561
574
  }
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ type: 'form',
5
+ display: 'form',
6
+ components: [
7
+ {
8
+ label: 'Select',
9
+ widget: 'choicesjs',
10
+ tableView: true,
11
+ data: {
12
+ values: [
13
+ {
14
+ label: 'a',
15
+ value: 'a'
16
+ },
17
+ {
18
+ label: 'b',
19
+ value: 'b'
20
+ },
21
+ {
22
+ label: 'c',
23
+ value: 'c'
24
+ }
25
+ ]
26
+ },
27
+ key: 'select',
28
+ type: 'select',
29
+ input: true
30
+ },
31
+ {
32
+ label: 'Data Grid',
33
+ reorder: false,
34
+ addAnotherPosition: 'bottom',
35
+ layoutFixed: false,
36
+ enableRowGroups: false,
37
+ initEmpty: false,
38
+ tableView: false,
39
+ defaultValue: [
40
+ {
41
+ firstName: '',
42
+ lastName: ''
43
+ }
44
+ ],
45
+ calculateValue: "var temp = instance.defaultValue;\n if(data.select === 'a')\n {\n temp = [{'firstName': 'A f 1','lastName': 'A l 1'}];\n } else if(data.select === 'b') { \n temp = [{'firstName': 'B f 1','lastName': 'B l 1'} \n ,{'firstName': 'B f 2','lastName': 'B l 2'}];\n } else if(data.select === 'c') { \n temp = [{'firstName': 'C f 1','lastName': 'C l 1'}];\n }\n value = temp;",
46
+ allowCalculateOverride: true,
47
+ key: 'dataGrid',
48
+ type: 'datagrid',
49
+ input: true,
50
+ components: [
51
+ {
52
+ label: 'First Name',
53
+ tableView: true,
54
+ key: 'firstName',
55
+ type: 'textfield',
56
+ input: true
57
+ },
58
+ {
59
+ label: 'Last Name',
60
+ tableView: true,
61
+ key: 'lastName',
62
+ type: 'textfield',
63
+ input: true
64
+ }
65
+ ]
66
+ }
67
+ ]
68
+ };
@@ -140,7 +140,7 @@ exports.default = {
140
140
  providerOptions: {
141
141
  params: {
142
142
  autocompleteOptions: {},
143
- key: 'AIzaSyBNL2e4MnmyPj9zN7SVAe428nCSLP1X144',
143
+ key: '',
144
144
  },
145
145
  },
146
146
  input: true,
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.modalWithRequiredFields = exports.withRowGroupsAndDefValue = exports.withLogic = exports.withDefValue = exports.withConditionalFieldsAndValidations = exports.withCollapsibleRowGroups = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
6
+ exports.twoWithAllowCalculatedOverride = exports.withAllowCalculateOverride = exports.modalWithRequiredFields = exports.withRowGroupsAndDefValue = exports.withLogic = exports.withDefValue = exports.withConditionalFieldsAndValidations = exports.withCollapsibleRowGroups = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
7
7
  const comp1_1 = __importDefault(require("./comp1"));
8
8
  exports.comp1 = comp1_1.default;
9
9
  const comp2_1 = __importDefault(require("./comp2"));
@@ -32,3 +32,7 @@ const comp_with_logic_1 = __importDefault(require("./comp-with-logic"));
32
32
  exports.withLogic = comp_with_logic_1.default;
33
33
  const comp_with_collapsible_groups_1 = __importDefault(require("./comp-with-collapsible-groups"));
34
34
  exports.withCollapsibleRowGroups = comp_with_collapsible_groups_1.default;
35
+ const comp_with_allow_calculate_override_1 = __importDefault(require("./comp-with-allow-calculate-override"));
36
+ exports.withAllowCalculateOverride = comp_with_allow_calculate_override_1.default;
37
+ const two_comp_with_allow_calculate_override_1 = __importDefault(require("./two-comp-with-allow-calculate-override"));
38
+ exports.twoWithAllowCalculatedOverride = two_comp_with_allow_calculate_override_1.default;
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ type: 'form',
5
+ display: 'form',
6
+ components: [
7
+ {
8
+ label: 'Select',
9
+ widget: 'choicesjs',
10
+ tableView: true,
11
+ data: {
12
+ values: [
13
+ {
14
+ label: 'a',
15
+ value: 'a'
16
+ },
17
+ {
18
+ label: 'b',
19
+ value: 'b'
20
+ },
21
+ {
22
+ label: 'c',
23
+ value: 'c'
24
+ }
25
+ ]
26
+ },
27
+ key: 'select',
28
+ type: 'select',
29
+ input: true
30
+ },
31
+ {
32
+ label: 'Data Grid',
33
+ reorder: false,
34
+ addAnotherPosition: 'bottom',
35
+ layoutFixed: false,
36
+ enableRowGroups: false,
37
+ initEmpty: false,
38
+ tableView: false,
39
+ defaultValue: [
40
+ {
41
+ firstName: '',
42
+ lastName: ''
43
+ }
44
+ ],
45
+ calculateValue: "var temp = instance.defaultValue;\n if(data.select === 'a')\n {\n temp = [{'firstName': 'A f 1','lastName': 'A l 1'}];\n } else if(data.select === 'b') { \n temp = [{'firstName': 'B f 1','lastName': 'B l 1'} \n ,{'firstName': 'B f 2','lastName': 'B l 2'}];\n } else if(data.select === 'c') { \n temp = [{'firstName': 'C f 1','lastName': 'C l 1'}];\n }\n value = temp;",
46
+ allowCalculateOverride: true,
47
+ key: 'dataGrid',
48
+ type: 'datagrid',
49
+ input: true,
50
+ components: [
51
+ {
52
+ label: 'First Name',
53
+ tableView: true,
54
+ key: 'firstName',
55
+ type: 'textfield',
56
+ input: true
57
+ },
58
+ {
59
+ label: 'Last Name',
60
+ tableView: true,
61
+ key: 'lastName',
62
+ type: 'textfield',
63
+ input: true
64
+ }
65
+ ]
66
+ },
67
+ {
68
+ label: 'Data Grid 2',
69
+ reorder: false,
70
+ addAnotherPosition: 'bottom',
71
+ layoutFixed: false,
72
+ enableRowGroups: false,
73
+ initEmpty: false,
74
+ tableView: false,
75
+ defaultValue: [
76
+ {
77
+ firstName: '',
78
+ lastName: ''
79
+ }
80
+ ],
81
+ calculateValue: "var temp = instance.defaultValue;\n if(data.select === 'a')\n {\n temp = [{'firstName': 'A f 1','lastName': 'A l 1'}];\n } else if(data.select === 'b') { \n temp = [{'firstName': 'B f 1','lastName': 'B l 1'} \n ,{'firstName': 'B f 2','lastName': 'B l 2'}];\n } else if(data.select === 'c') { \n temp = [{'firstName': 'C f 1','lastName': 'C l 1'}];\n }\n value = temp;",
82
+ allowCalculateOverride: true,
83
+ key: 'dataGrid2',
84
+ type: 'datagrid',
85
+ input: true,
86
+ components: [
87
+ {
88
+ label: 'First Name',
89
+ tableView: true,
90
+ key: 'firstName',
91
+ type: 'textfield',
92
+ input: true
93
+ },
94
+ {
95
+ label: 'Last Name',
96
+ tableView: true,
97
+ key: 'lastName',
98
+ type: 'textfield',
99
+ input: true
100
+ }
101
+ ]
102
+ }
103
+ ]
104
+ };
@@ -579,6 +579,10 @@ class EditGridComponent extends NestedArrayComponent_1.default {
579
579
  ? (((_a = this.editRows[rowIndex]) === null || _a === void 0 ? void 0 : _a.components) || [])
580
580
  : this.editRows.reduce((result, row) => result.concat(row.components || []), []);
581
581
  }
582
+ destroy(all = false) {
583
+ this.calculatedValue = undefined;
584
+ super.destroy(all);
585
+ }
582
586
  destroyComponents(all = false, rowIndex = 0) {
583
587
  if (this.builderMode) {
584
588
  return super.destroyComponents(all);
@@ -1085,7 +1089,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1085
1089
  }
1086
1090
  return false;
1087
1091
  }
1088
- else if (rowsEditing && this.saveEditMode) {
1092
+ else if (rowsEditing && this.saveEditMode && !this.component.openWhenEmpty) {
1089
1093
  this.setCustomValidity(this.t(this.errorMessage('unsavedRowsError')), dirty);
1090
1094
  return false;
1091
1095
  }
@@ -1113,7 +1117,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1113
1117
  }
1114
1118
  }
1115
1119
  changeState(changed, flags) {
1116
- if (changed || (flags.resetValue && this.component.modalEdit)) {
1120
+ if (this.visible && (changed || (flags.resetValue && this.component.modalEdit))) {
1117
1121
  this.rebuild();
1118
1122
  }
1119
1123
  else {
@@ -1133,7 +1137,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1133
1137
  }
1134
1138
  }
1135
1139
  const changed = this.hasChanged(value, this.dataValue);
1136
- if (this.parent) {
1140
+ if (this.parent && !this.options.server) {
1137
1141
  this.parent.checkComponentConditions();
1138
1142
  }
1139
1143
  this.dataValue = value;
@@ -1166,7 +1170,10 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1166
1170
  this.editRows = this.editRows.slice(0, dataLength);
1167
1171
  this.openWhenEmpty();
1168
1172
  this.updateOnChange(flags, changed);
1169
- this.checkData();
1173
+ // do not call checkData with server option, it is called when change is triggered in updateOnChange
1174
+ if (!this.options.server) {
1175
+ this.checkData();
1176
+ }
1170
1177
  this.changeState(changed, flags);
1171
1178
  return changed;
1172
1179
  }