@formio/js 5.0.0-dev.5859.acbf6fa → 5.0.0-dev.5863.8f10146

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.
Files changed (56) hide show
  1. package/Changelog.md +16 -14
  2. package/dist/formio.form.js +97 -97
  3. package/dist/formio.form.min.js +1 -1
  4. package/dist/formio.full.js +98 -98
  5. package/dist/formio.full.min.js +1 -1
  6. package/dist/formio.js +9 -9
  7. package/dist/formio.min.js +1 -1
  8. package/dist/formio.utils.js +71 -71
  9. package/dist/formio.utils.min.js +1 -1
  10. package/lib/cjs/Wizard.js +1 -1
  11. package/lib/cjs/components/_classes/component/Component.js +4 -6
  12. package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  13. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +1 -1
  14. package/lib/cjs/components/_classes/component/editForm/utils.js +1 -1
  15. package/lib/cjs/components/day/Day.d.ts +1 -0
  16. package/lib/cjs/components/day/Day.js +15 -0
  17. package/lib/cjs/components/editgrid/EditGrid.d.ts +2 -2
  18. package/lib/cjs/components/editgrid/EditGrid.js +12 -13
  19. package/lib/cjs/components/form/editForm/Form.edit.data.js +1 -1
  20. package/lib/cjs/components/radio/Radio.d.ts +1 -0
  21. package/lib/cjs/components/radio/Radio.js +13 -4
  22. package/lib/cjs/components/select/Select.d.ts +1 -1
  23. package/lib/cjs/components/select/Select.js +12 -5
  24. package/lib/cjs/components/selectboxes/SelectBoxes.js +9 -2
  25. package/lib/cjs/components/textarea/TextArea.d.ts +4 -4
  26. package/lib/cjs/components/textarea/TextArea.js +4 -4
  27. package/lib/cjs/components/time/Time.js +0 -6
  28. package/lib/cjs/utils/conditionOperators/IsEqualTo.js +1 -9
  29. package/lib/cjs/utils/formUtils.d.ts +3 -0
  30. package/lib/cjs/utils/formUtils.js +5 -2
  31. package/lib/cjs/utils/utils.d.ts +0 -13
  32. package/lib/cjs/utils/utils.js +1 -33
  33. package/lib/mjs/Wizard.js +1 -1
  34. package/lib/mjs/components/_classes/component/Component.js +4 -6
  35. package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  36. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +1 -1
  37. package/lib/mjs/components/_classes/component/editForm/utils.js +1 -1
  38. package/lib/mjs/components/day/Day.d.ts +1 -0
  39. package/lib/mjs/components/day/Day.js +15 -0
  40. package/lib/mjs/components/editgrid/EditGrid.d.ts +2 -2
  41. package/lib/mjs/components/editgrid/EditGrid.js +12 -13
  42. package/lib/mjs/components/form/editForm/Form.edit.data.js +1 -1
  43. package/lib/mjs/components/radio/Radio.d.ts +1 -0
  44. package/lib/mjs/components/radio/Radio.js +13 -4
  45. package/lib/mjs/components/select/Select.d.ts +1 -1
  46. package/lib/mjs/components/select/Select.js +11 -4
  47. package/lib/mjs/components/selectboxes/SelectBoxes.js +8 -2
  48. package/lib/mjs/components/textarea/TextArea.d.ts +4 -4
  49. package/lib/mjs/components/textarea/TextArea.js +4 -4
  50. package/lib/mjs/components/time/Time.js +0 -6
  51. package/lib/mjs/utils/conditionOperators/IsEqualTo.js +2 -10
  52. package/lib/mjs/utils/formUtils.d.ts +3 -0
  53. package/lib/mjs/utils/formUtils.js +2 -2
  54. package/lib/mjs/utils/utils.d.ts +0 -13
  55. package/lib/mjs/utils/utils.js +0 -30
  56. package/package.json +2 -2
package/lib/cjs/Wizard.js CHANGED
@@ -916,7 +916,7 @@ class Wizard extends Webform_1.default {
916
916
  const components = !currentPageOnly || this.isLastPage()
917
917
  ? this.getComponents()
918
918
  : this.currentPage.components;
919
- return components.reduce((check, comp) => comp.checkValidity(data, dirty, row, childErrors) && check, true);
919
+ return components.reduce((check, comp) => comp.checkValidity(data, dirty, row, currentPageOnly, childErrors) && check, true);
920
920
  }
921
921
  get errors() {
922
922
  if (!this.isLastPage()) {
@@ -2962,14 +2962,12 @@ class Component extends Element_1.default {
2962
2962
  if (flags.silentCheck) {
2963
2963
  return [];
2964
2964
  }
2965
+ let isDirty = this.dirty || flags.dirty;
2965
2966
  if (this.options.alwaysDirty) {
2966
- flags.dirty = true;
2967
+ isDirty = true;
2967
2968
  }
2968
- if (flags.fromSubmission && this.hasValue(data)) {
2969
- flags.dirty = this.pristine && this.component.protected ? false : true;
2970
- }
2971
- this.setDirty(flags.dirty);
2972
- return this.setComponentValidity(errors, flags.dirty, flags.silentCheck, flags.fromSubmission);
2969
+ this.setDirty(isDirty);
2970
+ return this.setComponentValidity(errors, isDirty, flags.silentCheck, flags.fromSubmission);
2973
2971
  }
2974
2972
  /**
2975
2973
  * Perform a component validation.
@@ -50,6 +50,6 @@ exports.default = [
50
50
  },
51
51
  utils_1.default.javaScriptValue('Advanced Conditions', 'customConditional', 'conditional.json', 110, '<p>You must assign the <strong>show</strong> variable a boolean result.</p>' +
52
52
  '<p><strong>Note: Advanced Conditional logic will override the results of the Simple Conditional logic.</strong></p>' +
53
- '<h5>Example</h5><pre>show = !!data.showMe;</pre>', '<p><a href="http://formio.github.io/formio.js/app/examples/conditions.html" target="_blank" rel="noopener noreferrer">Click here for an example</a></p>')
53
+ '<h5>Example</h5><pre>show = !!data.showMe;</pre>', '<p><a href="https://help.form.io/userguide/form-building/logic-and-conditions" target="_blank" rel="noopener noreferrer">Click here for an example</a></p>')
54
54
  ];
55
55
  /* eslint-enable quotes, max-len */
@@ -140,7 +140,7 @@ exports.default = [
140
140
  input: true
141
141
  },
142
142
  utils_1.default.javaScriptValue('Custom Default Value', 'customDefaultValue', 'customDefaultValue', 1000, '<p><h4>Example:</h4><pre>value = data.firstName + " " + data.lastName;</pre></p>', '<p><h4>Example:</h4><pre>{"cat": [{"var": "data.firstName"}, " ", {"var": "data.lastName"}]}</pre>'),
143
- utils_1.default.javaScriptValue('Calculated Value', 'calculateValue', 'calculateValue', 1100, '<p><h4>Example:</h4><pre>value = data.a + data.b + data.c;</pre></p>', '<p><h4>Example:</h4><pre>{"+": [{"var": "data.a"}, {"var": "data.b"}, {"var": "data.c"}]}</pre><p><a href="http://formio.github.io/formio.js/app/examples/calculated.html" target="_blank" rel="noopener noreferrer">Click here for an example</a></p>', '<tr><th>token</th><td>The decoded JWT token for the authenticated user.</td></tr>'),
143
+ utils_1.default.javaScriptValue('Calculated Value', 'calculateValue', 'calculateValue', 1100, '<p><h4>Example:</h4><pre>value = data.a + data.b + data.c;</pre></p>', '<p><h4>Example:</h4><pre>{"+": [{"var": "data.a"}, {"var": "data.b"}, {"var": "data.c"}]}</pre><p><a href="https://help.form.io/userguide/form-building/logic-and-conditions#calculated-values" target="_blank" rel="noopener noreferrer">Click here for an example</a></p>', '<tr><th>token</th><td>The decoded JWT token for the authenticated user.</td></tr>'),
144
144
  {
145
145
  type: 'checkbox',
146
146
  input: true,
@@ -55,7 +55,7 @@ const EditFormUtils = {
55
55
  '<tr><th>value</th><td>The current value of the component.</td></tr>' +
56
56
  '<tr><th>moment</th><td>The moment.js library for date manipulation.</td></tr>' +
57
57
  '<tr><th>_</th><td>An instance of <a href="https://lodash.com/docs/" target="_blank" rel="noopener noreferrer">Lodash</a>.</td></tr>' +
58
- '<tr><th>utils</th><td>An instance of the <a href="http://formio.github.io/formio.js/docs/identifiers.html#utils" target="_blank" rel="noopener noreferrer">FormioUtils</a> object.</td></tr>' +
58
+ '<tr><th>utils</th><td>An instance of the <a href="https://help.form.io/developers/javascript-development/javascript-utilities" target="_blank" rel="noopener noreferrer">FormioUtils</a> object.</td></tr>' +
59
59
  '<tr><th>util</th><td>An alias for "utils".</td></tr>' +
60
60
  '</table><br/>'
61
61
  /* eslint-enable prefer-template */
@@ -11,6 +11,7 @@ export default class DayComponent extends Field {
11
11
  operators: string[];
12
12
  };
13
13
  static savedValueTypes(schema: any): string[];
14
+ static oldEmptyValue: string;
14
15
  static get serverConditionSettings(): {
15
16
  operators: string[];
16
17
  };
@@ -104,6 +104,12 @@ class DayComponent extends Field_1.default {
104
104
  info.changeEvent = 'input';
105
105
  return info;
106
106
  }
107
+ isEmpty(value = this.dataValue) {
108
+ if (value === DayComponent.oldEmptyValue) {
109
+ return true;
110
+ }
111
+ return super.isEmpty(value);
112
+ }
107
113
  inputDefinition(name) {
108
114
  let min, max;
109
115
  if (name === 'day') {
@@ -337,6 +343,10 @@ class DayComponent extends Field_1.default {
337
343
  }
338
344
  }
339
345
  normalizeValue(value) {
346
+ // Adjust the value from old to new format
347
+ if (value === DayComponent.oldEmptyValue) {
348
+ value = '';
349
+ }
340
350
  if (!value || this.valueMask.test(value)) {
341
351
  return value;
342
352
  }
@@ -584,6 +594,9 @@ class DayComponent extends Field_1.default {
584
594
  * @returns {string|null} - The string value of the date.
585
595
  */
586
596
  getValueAsString(value) {
597
+ if (!value) {
598
+ return '';
599
+ }
587
600
  return this.getDate(value) || '';
588
601
  }
589
602
  focus(field) {
@@ -640,4 +653,6 @@ class DayComponent extends Field_1.default {
640
653
  return validationFormat;
641
654
  }
642
655
  }
656
+ // Empty value used before 9.3.x
657
+ DayComponent.oldEmptyValue = '00/00/0000';
643
658
  exports.default = DayComponent;
@@ -89,8 +89,8 @@ export default class EditGridComponent extends NestedArrayComponent {
89
89
  hasOpenRows(): any;
90
90
  getAttachedData(data?: null): any;
91
91
  shouldValidateDraft(editRow: any): any;
92
- shouldValidateRow(editRow: any, dirty: any): any;
93
- validateRow(editRow: any, dirty: any, forceSilentCheck: any): any;
92
+ shouldValidateRow(editRow: any, dirty: any, fromSubmission: any): any;
93
+ validateRow(editRow: any, dirty: any, forceSilentCheck: any, fromSubmission: any): any;
94
94
  showRowErrorAlerts(editRow: any, errors: any): void;
95
95
  /**
96
96
  * @returns {boolean} - Return that this component processes its own validation.
@@ -13,7 +13,6 @@ const utils_1 = require("../../utils/utils");
13
13
  const EditRowState = {
14
14
  New: 'new',
15
15
  Editing: 'editing',
16
- Saving: 'saving',
17
16
  Saved: 'saved',
18
17
  Viewing: 'viewing',
19
18
  Removed: 'removed',
@@ -809,10 +808,6 @@ class EditGridComponent extends NestedArrayComponent_1.default {
809
808
  if (!this.component.rowDrafts) {
810
809
  editRow.components.forEach((comp) => comp.setPristine(false));
811
810
  }
812
- // Mark the row with a 'Saving' state to trigger validation for future row changes
813
- if (editRow.state === EditRowState.New) {
814
- editRow.state = EditRowState.Saving;
815
- }
816
811
  const errors = this.validateRow(editRow, true);
817
812
  if (!this.component.rowDrafts) {
818
813
  if (errors.length) {
@@ -825,7 +820,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
825
820
  this.root.focusedComponent = null;
826
821
  }
827
822
  switch (editRow.state) {
828
- case EditRowState.Saving: {
823
+ case EditRowState.New: {
829
824
  const newIndex = dataValue.length;
830
825
  dataValue.push(editRow.data);
831
826
  editRow.components.forEach(component => component.rowIndex = newIndex);
@@ -983,24 +978,25 @@ class EditGridComponent extends NestedArrayComponent_1.default {
983
978
  !this.hasOpenRows()) ||
984
979
  ((_b = this.root) === null || _b === void 0 ? void 0 : _b.submitted);
985
980
  }
986
- shouldValidateRow(editRow, dirty) {
981
+ shouldValidateRow(editRow, dirty, fromSubmission) {
987
982
  return this.shouldValidateDraft(editRow) ||
988
- editRow.state === EditRowState.Saving ||
983
+ editRow.state === EditRowState.New ||
989
984
  editRow.state === EditRowState.Editing ||
990
985
  editRow.alerts ||
986
+ fromSubmission ||
991
987
  dirty;
992
988
  }
993
- validateRow(editRow, dirty, forceSilentCheck) {
989
+ validateRow(editRow, dirty, forceSilentCheck, fromSubmission) {
994
990
  var _a;
995
991
  editRow.errors = [];
996
- if (this.shouldValidateRow(editRow, dirty)) {
992
+ if (this.shouldValidateRow(editRow, dirty, fromSubmission)) {
997
993
  const silentCheck = (this.component.rowDrafts && !this.shouldValidateDraft(editRow)) || forceSilentCheck;
998
994
  const rootValue = (0, utils_1.fastCloneDeep)(this.rootValue);
999
995
  const editGridValue = lodash_1.default.get(rootValue, this.path, []);
1000
996
  editGridValue[editRow.rowIndex] = editRow.data;
1001
997
  lodash_1.default.set(rootValue, this.path, editGridValue);
1002
998
  const validationProcessorProcess = (context) => this.validationProcessor(context, { dirty, silentCheck });
1003
- editRow.errors = (0, process_1.processSync)({
999
+ const errors = (0, process_1.processSync)({
1004
1000
  components: (0, utils_1.fastCloneDeep)(this.component.components).map((component) => {
1005
1001
  component.parentPath = `${this.path}[${editRow.rowIndex}]`;
1006
1002
  return component;
@@ -1017,6 +1013,9 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1017
1013
  }
1018
1014
  ]
1019
1015
  }).errors;
1016
+ editRow.errors = (this.component.modal || this.component.rowDrafts)
1017
+ ? errors
1018
+ : errors.filter((err) => lodash_1.default.find(this.visibleErrors, ['component.id', err.component.id]));
1020
1019
  }
1021
1020
  // TODO: this is essentially running its own custom validation and should be moved into a validation rule
1022
1021
  if (this.component.validate && this.component.validate.row) {
@@ -1065,7 +1064,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1065
1064
  }
1066
1065
  checkComponentValidity(data, dirty, row, options = {}, errors = []) {
1067
1066
  var _a, _b;
1068
- const { silentCheck } = options;
1067
+ const { silentCheck, fromSubmission } = options;
1069
1068
  const superValid = super.checkComponentValidity(data, dirty, row, options, errors);
1070
1069
  // If super tells us that component invalid and there is no need to update alerts, just return false
1071
1070
  if (!superValid && (!this.alert && !this.hasOpenRows())) {
@@ -1075,7 +1074,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1075
1074
  const allRowErrors = [];
1076
1075
  this.editRows.forEach((editRow, index) => {
1077
1076
  // Trigger all errors on the row.
1078
- const rowErrors = this.validateRow(editRow, dirty, silentCheck);
1077
+ const rowErrors = this.validateRow(editRow, dirty, silentCheck, fromSubmission);
1079
1078
  errors.push(...rowErrors);
1080
1079
  allRowErrors.push(...rowErrors);
1081
1080
  if (this.rowRefs) {
@@ -7,7 +7,7 @@ const utils_1 = __importDefault(require("../../_classes/component/editForm/utils
7
7
  /* eslint-disable max-len */
8
8
  exports.default = [
9
9
  utils_1.default.javaScriptValue('Custom Default Value', 'customDefaultValue', 'customDefaultValue', 120, '<p><h4>Example:</h4><pre>value = data.firstName + " " + data.lastName;</pre></p>', '<p><h4>Example:</h4><pre>{"cat": [{"var": "data.firstName"}, " ", {"var": "data.lastName"}]}</pre>'),
10
- utils_1.default.javaScriptValue('Calculated Value', 'calculateValue', 'calculateValue', 130, '<p><h4>Example:</h4><pre>value = data.a + data.b + data.c;</pre></p>', '<p><h4>Example:</h4><pre>{"+": [{"var": "data.a"}, {"var": "data.b"}, {"var": "data.c"}]}</pre><p><a href="http://formio.github.io/formio.js/app/examples/calculated.html" target="_blank" rel="noopener noreferrer">Click here for an example</a></p>'),
10
+ utils_1.default.javaScriptValue('Calculated Value', 'calculateValue', 'calculateValue', 130, '<p><h4>Example:</h4><pre>value = data.a + data.b + data.c;</pre></p>', '<p><h4>Example:</h4><pre>{"+": [{"var": "data.a"}, {"var": "data.b"}, {"var": "data.c"}]}</pre><p><a href="https://help.form.io/userguide/form-building/logic-and-conditions#calculated-values" target="_blank" rel="noopener noreferrer">Click here for an example</a></p>'),
11
11
  {
12
12
  weight: 140,
13
13
  type: 'checkbox',
@@ -21,6 +21,7 @@ export default class RadioComponent extends ListComponent {
21
21
  get isRadio(): boolean;
22
22
  get optionSelectedClass(): string;
23
23
  get listData(): any;
24
+ get selectMetadata(): any;
24
25
  templateData: {} | undefined;
25
26
  triggerUpdate: ((...args: any[]) => any) | undefined;
26
27
  itemsLoadedResolve: ((value: any) => void) | undefined;
@@ -109,6 +109,12 @@ class RadioComponent extends ListComponent_1.default {
109
109
  const listData = lodash_1.default.get(this.root, 'submission.metadata.listData', {});
110
110
  return lodash_1.default.get(listData, this.path);
111
111
  }
112
+ get selectMetadata() {
113
+ return super.selectData;
114
+ }
115
+ get selectData() {
116
+ return this.selectMetadata || this.component.selectData;
117
+ }
112
118
  init() {
113
119
  super.init();
114
120
  this.templateData = {};
@@ -244,12 +250,15 @@ class RadioComponent extends ListComponent_1.default {
244
250
  else if (!lodash_1.default.isString(value)) {
245
251
  value = lodash_1.default.toString(value);
246
252
  }
247
- const isModalPreviewWithUrlDataSource = options.modalPreview && this.component.dataSrc === 'url';
248
- if (this.component.dataSrc !== 'values' && !isModalPreviewWithUrlDataSource) {
253
+ const shouldUseSelectData = (options.modalPreview || this.inDataTable)
254
+ && this.component.dataSrc === 'url' && (this.loadedOptions.length || this.selectData);
255
+ if (this.component.dataSrc !== 'values' && !shouldUseSelectData) {
249
256
  return value;
250
257
  }
251
- const values = isModalPreviewWithUrlDataSource ? this.loadedOptions : this.component.values;
252
- const option = lodash_1.default.find(values, (v) => v.value === value);
258
+ const values = shouldUseSelectData ? this.loadedOptions : this.component.values;
259
+ const option = !(values === null || values === void 0 ? void 0 : values.length) && shouldUseSelectData ? {
260
+ label: this.itemTemplate(this.selectData),
261
+ } : lodash_1.default.find(values, (v) => v.value === value);
253
262
  if (!value) {
254
263
  return lodash_1.default.get(option, 'label', '');
255
264
  }
@@ -131,7 +131,7 @@ export default class SelectComponent extends ListComponent {
131
131
  addCurrentChoices(values: any, items: any, keyValue: any): any;
132
132
  getValueAsString(data: any, options: any): any;
133
133
  normalizeSingleValue(value: any): any;
134
- setMetadata(value: any): any;
134
+ setMetadata(value: any, flags?: {}): any;
135
135
  updateValue(value: any, flags: any): boolean;
136
136
  undoValueTyping(value: any): any;
137
137
  setValue(value: any, flags?: {}): boolean;
@@ -1204,8 +1204,8 @@ class SelectComponent extends ListComponent_1.default {
1204
1204
  }
1205
1205
  return super.normalizeValue(this.normalizeSingleValue(value));
1206
1206
  }
1207
- setMetadata(value) {
1208
- var _a;
1207
+ setMetadata(value, flags = {}) {
1208
+ var _a, _b;
1209
1209
  if (lodash_1.default.isNil(value)) {
1210
1210
  return;
1211
1211
  }
@@ -1239,15 +1239,22 @@ class SelectComponent extends ListComponent_1.default {
1239
1239
  }
1240
1240
  lodash_1.default.set(submission.metadata.selectData, this.path, templateData);
1241
1241
  }
1242
+ if (flags.resetValue && ((_b = this.root) === null || _b === void 0 ? void 0 : _b.submission)) {
1243
+ const submission = this.root.submission;
1244
+ if (!submission.metadata) {
1245
+ submission.metadata = {};
1246
+ }
1247
+ submission.metadata.selectData = {};
1248
+ }
1242
1249
  }
1243
1250
  updateValue(value, flags) {
1244
1251
  const changed = super.updateValue(value, flags);
1245
- if (changed || !this.selectMetadata) {
1252
+ if (changed || !this.selectMetadata || flags.resetValue) {
1246
1253
  if (this.component.multiple && Array.isArray(this.dataValue)) {
1247
- this.dataValue.forEach(singleValue => this.setMetadata(singleValue));
1254
+ this.dataValue.forEach(singleValue => this.setMetadata(singleValue, flags));
1248
1255
  }
1249
1256
  else {
1250
- this.setMetadata(this.dataValue);
1257
+ this.setMetadata(this.dataValue, flags);
1251
1258
  }
1252
1259
  }
1253
1260
  return changed;
@@ -166,12 +166,19 @@ class SelectBoxesComponent extends Radio_1.default {
166
166
  return changed;
167
167
  }
168
168
  getValueAsString(value, options = {}) {
169
+ var _a, _b;
169
170
  if (!value) {
170
171
  return '';
171
172
  }
172
173
  if (this.isSelectURL) {
173
- if (options.modalPreview && this.loadedOptions) {
174
- return this.loadedOptions.filter((option) => value[option.value]).map((option) => option.label).join(', ');
174
+ if (options.modalPreview || this.options.readOnly || this.inDataTable) {
175
+ const checkedItems = lodash_1.default.keys(lodash_1.default.pickBy(value, (val) => val));
176
+ if (((_a = this.selectData) === null || _a === void 0 ? void 0 : _a.length) === checkedItems.length) {
177
+ return this.selectData.map(item => this.itemTemplate(item)).join(', ');
178
+ }
179
+ else if ((_b = this.loadedOptions) === null || _b === void 0 ? void 0 : _b.length) {
180
+ return this.loadedOptions.filter((option) => value[option.value]).map((option) => option.label).join(', ');
181
+ }
175
182
  }
176
183
  return (0, lodash_1.default)(value).pickBy((val) => val).keys().join(', ');
177
184
  }
@@ -20,10 +20,10 @@ export default class TextAreaComponent extends TextFieldComponent {
20
20
  setReadOnlyValue(value: any, index: any): void;
21
21
  get isJsonValue(): any;
22
22
  /**
23
- * Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
24
- * @param {*} value - The value to normalize
25
- * @returns {*} - Returns the normalized value
26
- */
23
+ * Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
24
+ * @param {*} value - The value to normalize
25
+ * @returns {*} - Returns the normalized value
26
+ */
27
27
  normalizeValue(value: any): any;
28
28
  normalizeSingleValue(value: any): any;
29
29
  setConvertedValue(value: any, index: any): any;
@@ -310,10 +310,10 @@ class TextAreaComponent extends TextField_1.default {
310
310
  return this.component.as && this.component.as === 'json';
311
311
  }
312
312
  /**
313
- * Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
314
- * @param {*} value - The value to normalize
315
- * @returns {*} - Returns the normalized value
316
- */
313
+ * Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
314
+ * @param {*} value - The value to normalize
315
+ * @returns {*} - Returns the normalized value
316
+ */
317
317
  normalizeValue(value) {
318
318
  if (this.component.multiple && Array.isArray(value)) {
319
319
  return value.map((singleValue) => this.normalizeSingleValue(singleValue));
@@ -56,12 +56,6 @@ class TimeComponent extends TextField_1.default {
56
56
  }
57
57
  return value;
58
58
  }
59
- get validationValue() {
60
- if ((Array.isArray(this.rawData) && !this.rawData.length) || !this.rawData) {
61
- return this.dataValue;
62
- }
63
- return this.rawData;
64
- }
65
59
  get inputInfo() {
66
60
  const info = super.inputInfo;
67
61
  info.attr.type = this.component.inputType;
@@ -27,15 +27,7 @@ class IsEqualTo extends ConditionOperator_1.default {
27
27
  if (conditionTriggerComponent
28
28
  && (0, utils_1.isSelectResourceWithObjectValue)(conditionTriggerComponent.component)
29
29
  && ((_b = conditionTriggerComponent.component) === null || _b === void 0 ? void 0 : _b.template)) {
30
- if (!value || !lodash_1.default.isPlainObject(value)) {
31
- return false;
32
- }
33
- const { template, valueProperty } = conditionTriggerComponent.component;
34
- if (valueProperty === 'data') {
35
- value = { data: value };
36
- comparedValue = { data: comparedValue };
37
- }
38
- return lodash_1.default.every((0, utils_1.getItemTemplateKeys)(template) || [], k => lodash_1.default.isEqual(lodash_1.default.get(value, k), lodash_1.default.get(comparedValue, k)));
30
+ return (0, utils_1.compareSelectResourceWithObjectTypeValues)(value, comparedValue, conditionTriggerComponent.component);
39
31
  }
40
32
  }
41
33
  //special check for select boxes
@@ -41,4 +41,7 @@ export const applyFormChanges: typeof Utils.applyFormChanges;
41
41
  export const findComponent: typeof Utils.findComponent;
42
42
  export const getEmptyValue: typeof Utils.getEmptyValue;
43
43
  export const isComponentDataEmpty: typeof Utils.isComponentDataEmpty;
44
+ export const isSelectResourceWithObjectValue: typeof Utils.isSelectResourceWithObjectValue;
45
+ export const compareSelectResourceWithObjectTypeValues: typeof Utils.compareSelectResourceWithObjectTypeValues;
46
+ export const getItemTemplateKeys: typeof Utils.getItemTemplateKeys;
44
47
  import { Utils } from '@formio/core';
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isComponentDataEmpty = exports.getEmptyValue = exports.findComponent = exports.applyFormChanges = exports.generateFormChange = exports.getStrings = exports.getValue = exports.escapeRegExCharacters = exports.formatAsCurrency = exports.parseFloatExt = exports.hasCondition = exports.removeComponent = exports.searchComponents = exports.getComponent = exports.matchComponent = exports.isLayoutComponent = exports.getComponentActualValue = exports.getComponentData = exports.eachComponentAsync = exports.eachComponent = exports.componentInfo = exports.getContextualRowData = exports.getContextualRowPath = exports.getComponentKey = exports.eachComponentData = exports.eachComponentDataAsync = exports.componentChildPath = exports.componentPath = exports.isComponentNestedDataType = exports.getComponentPath = exports.getComponentAbsolutePath = exports.getModelType = exports.MODEL_TYPES = exports.uniqueName = exports.guid = exports.flattenComponents = exports.findComponents = void 0;
3
+ exports.getItemTemplateKeys = exports.compareSelectResourceWithObjectTypeValues = exports.isSelectResourceWithObjectValue = exports.isComponentDataEmpty = exports.getEmptyValue = exports.findComponent = exports.applyFormChanges = exports.generateFormChange = exports.getStrings = exports.getValue = exports.escapeRegExCharacters = exports.formatAsCurrency = exports.parseFloatExt = exports.hasCondition = exports.removeComponent = exports.searchComponents = exports.getComponent = exports.matchComponent = exports.isLayoutComponent = exports.getComponentActualValue = exports.getComponentData = exports.eachComponentAsync = exports.eachComponent = exports.componentInfo = exports.getContextualRowData = exports.getContextualRowPath = exports.getComponentKey = exports.eachComponentData = exports.eachComponentDataAsync = exports.componentChildPath = exports.componentPath = exports.isComponentNestedDataType = exports.getComponentPath = exports.getComponentAbsolutePath = exports.getModelType = exports.MODEL_TYPES = exports.uniqueName = exports.guid = exports.flattenComponents = exports.findComponents = void 0;
4
4
  const core_1 = require("@formio/core");
5
- const { flattenComponents, guid, uniqueName, MODEL_TYPES, getModelType, getComponentAbsolutePath, getComponentPath, isComponentNestedDataType, componentPath, componentChildPath, eachComponentDataAsync, eachComponentData, getComponentKey, getContextualRowPath, getContextualRowData, componentInfo, eachComponent, eachComponentAsync, getComponentData, getComponentActualValue, isLayoutComponent, matchComponent, getComponent, searchComponents, removeComponent, hasCondition, parseFloatExt, formatAsCurrency, escapeRegExCharacters, getValue, getStrings, generateFormChange, applyFormChanges, findComponent, getEmptyValue, isComponentDataEmpty } = core_1.Utils;
5
+ const { flattenComponents, guid, uniqueName, MODEL_TYPES, getModelType, getComponentAbsolutePath, getComponentPath, isComponentNestedDataType, componentPath, componentChildPath, eachComponentDataAsync, eachComponentData, getComponentKey, getContextualRowPath, getContextualRowData, componentInfo, eachComponent, eachComponentAsync, getComponentData, getComponentActualValue, isLayoutComponent, matchComponent, getComponent, searchComponents, removeComponent, hasCondition, parseFloatExt, formatAsCurrency, escapeRegExCharacters, getValue, getStrings, generateFormChange, applyFormChanges, findComponent, getEmptyValue, isComponentDataEmpty, isSelectResourceWithObjectValue, compareSelectResourceWithObjectTypeValues, getItemTemplateKeys } = core_1.Utils;
6
6
  exports.flattenComponents = flattenComponents;
7
7
  exports.guid = guid;
8
8
  exports.uniqueName = uniqueName;
@@ -39,6 +39,9 @@ exports.applyFormChanges = applyFormChanges;
39
39
  exports.findComponent = findComponent;
40
40
  exports.getEmptyValue = getEmptyValue;
41
41
  exports.isComponentDataEmpty = isComponentDataEmpty;
42
+ exports.isSelectResourceWithObjectValue = isSelectResourceWithObjectValue;
43
+ exports.compareSelectResourceWithObjectTypeValues = compareSelectResourceWithObjectTypeValues;
44
+ exports.getItemTemplateKeys = getItemTemplateKeys;
42
45
  /**
43
46
  * Deprecated version of findComponents. Renamed to searchComponents.
44
47
  * @param {import('@formio/core').Component[]} components - The components to find components within.
@@ -498,18 +498,6 @@ export function getFocusableElements(element: HTMLElement): NodeList<HTMLElement
498
498
  * @returns {Array<string>|null} - The saved types for the component
499
499
  */
500
500
  export function getComponentSavedTypes(fullSchema: import('@formio/core').Component): Array<string> | null;
501
- /**
502
- * Returns the template keys inside the template code.
503
- * @param {string} template - The template to get the keys from.
504
- * @returns {Array<string>} - The keys inside the template.
505
- */
506
- export function getItemTemplateKeys(template: string): Array<string>;
507
- /**
508
- * Returns if the component is a select resource with an object for its value.
509
- * @param {import('@formio/core').Component} comp - The component to check.
510
- * @returns {boolean} - TRUE if the component is a select resource with an object for its value; FALSE otherwise.
511
- */
512
- export function isSelectResourceWithObjectValue(comp?: import('@formio/core').Component): boolean;
513
501
  export * from "./formUtils";
514
502
  /**
515
503
  * Map values through unfold and return first non-nil value.
@@ -527,7 +515,6 @@ export namespace componentValueTypes {
527
515
  let any: string;
528
516
  }
529
517
  export function interpolateErrors(component: Component, errors: FieldError[], interpolateFn: Function): [];
530
- import jsonLogic from 'json-logic-js';
531
518
  import ConditionOperators from './conditionOperators';
532
519
  import { Evaluator } from './Evaluator';
533
520
  export const interpolate: typeof Evaluator.interpolate;
@@ -19,7 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.firstNonNil = exports.unfold = exports.bootstrapVersion = exports.uniqueKey = exports.iterateKey = exports.delay = exports.fieldData = exports.getCurrencyAffixes = exports.getNumberDecimalLimit = exports.getNumberSeparators = exports.matchInputMask = exports.unmaskValue = exports.getInputMask = exports.convertFormatToMask = exports.convertFormatToMoment = exports.convertFormatToFlatpickr = exports.getLocaleDateFormatInfo = exports.formatOffset = exports.formatDate = exports.momentDate = exports.loadZones = exports.shouldLoadZones = exports.zonesLoaded = exports.offsetDate = exports.currentTimezone = exports.isValidDate = exports.getDateSetting = exports.guid = exports.uniqueName = exports.convertStringToHTMLElement = exports.unescapeHTML = exports.removeHTML = exports.setActionProperty = exports.checkTrigger = exports.checkCondition = exports.checkJsonConditional = exports.checkCustomConditional = exports.getComponentActualValue = exports.checkSimpleConditional = exports.checkCalculated = exports.isMongoId = exports.boolValue = exports.getScriptPlugin = exports.getElementRect = exports.getPropertyValue = exports.getRandomComponentId = exports.evaluate = exports.moment = exports.ConditionOperators = exports.jsonLogic = void 0;
22
- exports.isSelectResourceWithObjectValue = exports.getItemTemplateKeys = exports.interpolateErrors = exports.getComponentSavedTypes = exports.componentValueTypes = exports._ = exports.getFocusableElements = exports.isInsideScopingComponent = exports.isPromise = exports.getDataParentComponent = exports.getComponentPath = exports.getComponentPathWithoutIndicies = exports.getBrowserInfo = exports.getIEBrowserVersion = exports.round = exports.getStringFromComponentPath = exports.isChildOf = exports.getArrayFromComponentPath = exports.isInputComponent = exports.interpolate = exports.Evaluator = exports.fastCloneDeep = exports.sanitize = exports.translateHTMLTemplate = exports.getContextButtons = exports.getContextComponents = exports.observeOverload = exports.withSwitch = void 0;
22
+ exports.interpolateErrors = exports.getComponentSavedTypes = exports.componentValueTypes = exports._ = exports.getFocusableElements = exports.isInsideScopingComponent = exports.isPromise = exports.getDataParentComponent = exports.getComponentPath = exports.getComponentPathWithoutIndicies = exports.getBrowserInfo = exports.getIEBrowserVersion = exports.round = exports.getStringFromComponentPath = exports.isChildOf = exports.getArrayFromComponentPath = exports.isInputComponent = exports.interpolate = exports.Evaluator = exports.fastCloneDeep = exports.sanitize = exports.translateHTMLTemplate = exports.getContextButtons = exports.getContextComponents = exports.observeOverload = exports.withSwitch = void 0;
23
23
  const lodash_1 = __importDefault(require("lodash"));
24
24
  exports._ = lodash_1.default;
25
25
  const json_logic_js_1 = __importDefault(require("json-logic-js"));
@@ -1681,35 +1681,3 @@ const interpolateErrors = (component, errors, interpolateFn) => {
1681
1681
  });
1682
1682
  };
1683
1683
  exports.interpolateErrors = interpolateErrors;
1684
- /**
1685
- * Returns the template keys inside the template code.
1686
- * @param {string} template - The template to get the keys from.
1687
- * @returns {Array<string>} - The keys inside the template.
1688
- */
1689
- function getItemTemplateKeys(template) {
1690
- const templateKeys = [];
1691
- if (!template) {
1692
- return templateKeys;
1693
- }
1694
- const keys = template.match(/({{\s*(.*?)\s*}})/g);
1695
- if (keys) {
1696
- keys.forEach((key) => {
1697
- const propKey = key.match(/{{\s*item\.(.*?)\s*}}/);
1698
- if (propKey && propKey.length > 1) {
1699
- templateKeys.push(propKey[1]);
1700
- }
1701
- });
1702
- }
1703
- return templateKeys;
1704
- }
1705
- exports.getItemTemplateKeys = getItemTemplateKeys;
1706
- /**
1707
- * Returns if the component is a select resource with an object for its value.
1708
- * @param {import('@formio/core').Component} comp - The component to check.
1709
- * @returns {boolean} - TRUE if the component is a select resource with an object for its value; FALSE otherwise.
1710
- */
1711
- function isSelectResourceWithObjectValue(comp = {}) {
1712
- const { reference, dataSrc, valueProperty } = comp;
1713
- return reference || (dataSrc === 'resource' && (!valueProperty || valueProperty === 'data'));
1714
- }
1715
- exports.isSelectResourceWithObjectValue = isSelectResourceWithObjectValue;
package/lib/mjs/Wizard.js CHANGED
@@ -903,7 +903,7 @@ export default class Wizard extends Webform {
903
903
  const components = !currentPageOnly || this.isLastPage()
904
904
  ? this.getComponents()
905
905
  : this.currentPage.components;
906
- return components.reduce((check, comp) => comp.checkValidity(data, dirty, row, childErrors) && check, true);
906
+ return components.reduce((check, comp) => comp.checkValidity(data, dirty, row, currentPageOnly, childErrors) && check, true);
907
907
  }
908
908
  get errors() {
909
909
  if (!this.isLastPage()) {
@@ -2926,14 +2926,12 @@ export default class Component extends Element {
2926
2926
  if (flags.silentCheck) {
2927
2927
  return [];
2928
2928
  }
2929
+ let isDirty = this.dirty || flags.dirty;
2929
2930
  if (this.options.alwaysDirty) {
2930
- flags.dirty = true;
2931
+ isDirty = true;
2931
2932
  }
2932
- if (flags.fromSubmission && this.hasValue(data)) {
2933
- flags.dirty = this.pristine && this.component.protected ? false : true;
2934
- }
2935
- this.setDirty(flags.dirty);
2936
- return this.setComponentValidity(errors, flags.dirty, flags.silentCheck, flags.fromSubmission);
2933
+ this.setDirty(isDirty);
2934
+ return this.setComponentValidity(errors, isDirty, flags.silentCheck, flags.fromSubmission);
2937
2935
  }
2938
2936
  /**
2939
2937
  * Perform a component validation.
@@ -45,6 +45,6 @@ export default [
45
45
  },
46
46
  EditFormUtils.javaScriptValue('Advanced Conditions', 'customConditional', 'conditional.json', 110, '<p>You must assign the <strong>show</strong> variable a boolean result.</p>' +
47
47
  '<p><strong>Note: Advanced Conditional logic will override the results of the Simple Conditional logic.</strong></p>' +
48
- '<h5>Example</h5><pre>show = !!data.showMe;</pre>', '<p><a href="http://formio.github.io/formio.js/app/examples/conditions.html" target="_blank" rel="noopener noreferrer">Click here for an example</a></p>')
48
+ '<h5>Example</h5><pre>show = !!data.showMe;</pre>', '<p><a href="https://help.form.io/userguide/form-building/logic-and-conditions" target="_blank" rel="noopener noreferrer">Click here for an example</a></p>')
49
49
  ];
50
50
  /* eslint-enable quotes, max-len */
@@ -135,7 +135,7 @@ export default [
135
135
  input: true
136
136
  },
137
137
  EditFormUtils.javaScriptValue('Custom Default Value', 'customDefaultValue', 'customDefaultValue', 1000, '<p><h4>Example:</h4><pre>value = data.firstName + " " + data.lastName;</pre></p>', '<p><h4>Example:</h4><pre>{"cat": [{"var": "data.firstName"}, " ", {"var": "data.lastName"}]}</pre>'),
138
- EditFormUtils.javaScriptValue('Calculated Value', 'calculateValue', 'calculateValue', 1100, '<p><h4>Example:</h4><pre>value = data.a + data.b + data.c;</pre></p>', '<p><h4>Example:</h4><pre>{"+": [{"var": "data.a"}, {"var": "data.b"}, {"var": "data.c"}]}</pre><p><a href="http://formio.github.io/formio.js/app/examples/calculated.html" target="_blank" rel="noopener noreferrer">Click here for an example</a></p>', '<tr><th>token</th><td>The decoded JWT token for the authenticated user.</td></tr>'),
138
+ EditFormUtils.javaScriptValue('Calculated Value', 'calculateValue', 'calculateValue', 1100, '<p><h4>Example:</h4><pre>value = data.a + data.b + data.c;</pre></p>', '<p><h4>Example:</h4><pre>{"+": [{"var": "data.a"}, {"var": "data.b"}, {"var": "data.c"}]}</pre><p><a href="https://help.form.io/userguide/form-building/logic-and-conditions#calculated-values" target="_blank" rel="noopener noreferrer">Click here for an example</a></p>', '<tr><th>token</th><td>The decoded JWT token for the authenticated user.</td></tr>'),
139
139
  {
140
140
  type: 'checkbox',
141
141
  input: true,
@@ -50,7 +50,7 @@ const EditFormUtils = {
50
50
  '<tr><th>value</th><td>The current value of the component.</td></tr>' +
51
51
  '<tr><th>moment</th><td>The moment.js library for date manipulation.</td></tr>' +
52
52
  '<tr><th>_</th><td>An instance of <a href="https://lodash.com/docs/" target="_blank" rel="noopener noreferrer">Lodash</a>.</td></tr>' +
53
- '<tr><th>utils</th><td>An instance of the <a href="http://formio.github.io/formio.js/docs/identifiers.html#utils" target="_blank" rel="noopener noreferrer">FormioUtils</a> object.</td></tr>' +
53
+ '<tr><th>utils</th><td>An instance of the <a href="https://help.form.io/developers/javascript-development/javascript-utilities" target="_blank" rel="noopener noreferrer">FormioUtils</a> object.</td></tr>' +
54
54
  '<tr><th>util</th><td>An alias for "utils".</td></tr>' +
55
55
  '</table><br/>'
56
56
  /* eslint-enable prefer-template */
@@ -11,6 +11,7 @@ export default class DayComponent extends Field {
11
11
  operators: string[];
12
12
  };
13
13
  static savedValueTypes(schema: any): string[];
14
+ static oldEmptyValue: string;
14
15
  static get serverConditionSettings(): {
15
16
  operators: string[];
16
17
  };