@formio/js 5.0.0-dev.5936.905c79f → 5.0.0-dev.5937.6595453

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 (88) hide show
  1. package/Changelog.md +302 -10
  2. package/dist/formio.form.js +586 -596
  3. package/dist/formio.form.min.js +1 -1
  4. package/dist/formio.form.min.js.LICENSE.txt +2 -4
  5. package/dist/formio.full.js +587 -597
  6. package/dist/formio.full.min.js +1 -1
  7. package/dist/formio.full.min.js.LICENSE.txt +2 -4
  8. package/dist/formio.js +3006 -287
  9. package/dist/formio.min.js +1 -1
  10. package/dist/formio.min.js.LICENSE.txt +13 -1
  11. package/dist/formio.utils.js +41 -51
  12. package/dist/formio.utils.min.js +1 -1
  13. package/dist/formio.utils.min.js.LICENSE.txt +2 -4
  14. package/lib/cjs/Webform.d.ts +1 -1
  15. package/lib/cjs/Webform.js +27 -28
  16. package/lib/cjs/WebformBuilder.js +6 -13
  17. package/lib/cjs/Wizard.js +4 -11
  18. package/lib/cjs/components/Components.d.ts +0 -7
  19. package/lib/cjs/components/Components.js +1 -33
  20. package/lib/cjs/components/_classes/component/Component.d.ts +39 -7
  21. package/lib/cjs/components/_classes/component/Component.js +97 -29
  22. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +2 -2
  23. package/lib/cjs/components/_classes/componentModal/ComponentModal.d.ts +1 -0
  24. package/lib/cjs/components/_classes/componentModal/ComponentModal.js +1 -0
  25. package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +4 -19
  26. package/lib/cjs/components/_classes/nested/NestedComponent.js +54 -60
  27. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -1
  28. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +9 -46
  29. package/lib/cjs/components/datagrid/DataGrid.d.ts +0 -1
  30. package/lib/cjs/components/datagrid/DataGrid.js +1 -45
  31. package/lib/cjs/components/datamap/DataMap.js +2 -3
  32. package/lib/cjs/components/editgrid/EditGrid.d.ts +1 -1
  33. package/lib/cjs/components/editgrid/EditGrid.js +20 -15
  34. package/lib/cjs/components/form/Form.d.ts +1 -3
  35. package/lib/cjs/components/form/Form.js +21 -28
  36. package/lib/cjs/components/html/HTML.js +15 -3
  37. package/lib/cjs/components/number/Number.js +11 -4
  38. package/lib/cjs/components/radio/Radio.d.ts +0 -4
  39. package/lib/cjs/components/radio/Radio.js +23 -66
  40. package/lib/cjs/components/selectboxes/SelectBoxes.js +0 -1
  41. package/lib/cjs/formio.form.js +1 -0
  42. package/lib/cjs/utils/conditionOperators/DateGreaterThan.js +2 -2
  43. package/lib/cjs/utils/conditionOperators/IsEmptyValue.d.ts +2 -2
  44. package/lib/cjs/utils/conditionOperators/IsEmptyValue.js +2 -2
  45. package/lib/cjs/utils/conditionOperators/IsEqualTo.d.ts +2 -2
  46. package/lib/cjs/utils/conditionOperators/IsEqualTo.js +2 -2
  47. package/lib/cjs/utils/formUtils.d.ts +25 -14
  48. package/lib/cjs/utils/formUtils.js +11 -16
  49. package/lib/cjs/utils/utils.d.ts +1 -2
  50. package/lib/cjs/utils/utils.js +15 -31
  51. package/lib/mjs/Webform.d.ts +1 -1
  52. package/lib/mjs/Webform.js +24 -27
  53. package/lib/mjs/WebformBuilder.js +6 -13
  54. package/lib/mjs/Wizard.js +2 -8
  55. package/lib/mjs/components/Components.d.ts +0 -7
  56. package/lib/mjs/components/Components.js +1 -32
  57. package/lib/mjs/components/_classes/component/Component.d.ts +39 -7
  58. package/lib/mjs/components/_classes/component/Component.js +99 -30
  59. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +2 -2
  60. package/lib/mjs/components/_classes/componentModal/ComponentModal.d.ts +1 -0
  61. package/lib/mjs/components/_classes/componentModal/ComponentModal.js +1 -0
  62. package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +4 -19
  63. package/lib/mjs/components/_classes/nested/NestedComponent.js +55 -61
  64. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -1
  65. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +8 -43
  66. package/lib/mjs/components/datagrid/DataGrid.d.ts +0 -1
  67. package/lib/mjs/components/datagrid/DataGrid.js +1 -45
  68. package/lib/mjs/components/datamap/DataMap.js +2 -3
  69. package/lib/mjs/components/editgrid/EditGrid.d.ts +1 -1
  70. package/lib/mjs/components/editgrid/EditGrid.js +22 -14
  71. package/lib/mjs/components/form/Form.d.ts +1 -3
  72. package/lib/mjs/components/form/Form.js +22 -28
  73. package/lib/mjs/components/html/HTML.js +15 -3
  74. package/lib/mjs/components/number/Number.js +11 -4
  75. package/lib/mjs/components/radio/Radio.d.ts +0 -4
  76. package/lib/mjs/components/radio/Radio.js +23 -66
  77. package/lib/mjs/components/selectboxes/SelectBoxes.js +0 -1
  78. package/lib/mjs/formio.form.js +1 -0
  79. package/lib/mjs/utils/conditionOperators/DateGreaterThan.js +2 -2
  80. package/lib/mjs/utils/conditionOperators/IsEmptyValue.d.ts +2 -2
  81. package/lib/mjs/utils/conditionOperators/IsEmptyValue.js +2 -2
  82. package/lib/mjs/utils/conditionOperators/IsEqualTo.d.ts +2 -2
  83. package/lib/mjs/utils/conditionOperators/IsEqualTo.js +2 -2
  84. package/lib/mjs/utils/formUtils.d.ts +25 -14
  85. package/lib/mjs/utils/formUtils.js +2 -12
  86. package/lib/mjs/utils/utils.d.ts +1 -2
  87. package/lib/mjs/utils/utils.js +14 -29
  88. package/package.json +4 -4
@@ -7,7 +7,6 @@ const lodash_1 = __importDefault(require("lodash"));
7
7
  const ListComponent_1 = __importDefault(require("../_classes/list/ListComponent"));
8
8
  const Formio_1 = require("../../Formio");
9
9
  const utils_1 = require("../../utils/utils");
10
- const uuid_1 = require("uuid");
11
10
  class RadioComponent extends ListComponent_1.default {
12
11
  static schema(...extend) {
13
12
  return ListComponent_1.default.schema({
@@ -143,7 +142,6 @@ class RadioComponent extends ListComponent_1.default {
143
142
  });
144
143
  this.optionsLoaded = !this.component.dataSrc || this.component.dataSrc === 'values';
145
144
  this.loadedOptions = [];
146
- this.valuesMap = new Map();
147
145
  if (!this.visible) {
148
146
  this.itemsLoadedResolve();
149
147
  }
@@ -183,12 +181,9 @@ class RadioComponent extends ListComponent_1.default {
183
181
  if (!lodash_1.default.isString(this.dataValue)) {
184
182
  dataValue = lodash_1.default.toString(this.dataValue);
185
183
  }
186
- if (this.isSelectURL) {
187
- const valueKey = this.loadedOptions[index].value;
188
- const optionValue = this.valuesMap.has(valueKey)
189
- ? this.valuesMap.get(valueKey)
190
- : valueKey;
191
- input.checked = lodash_1.default.isEqual(this.normalizeValue(optionValue), this.dataValue);
184
+ if (this.isSelectURL && lodash_1.default.isObject(this.loadedOptions[index].value)) {
185
+ const optionValue = this.component.dataType === 'string' ? JSON.stringify(this.loadedOptions[index].value) : this.loadedOptions[index].value;
186
+ input.checked = lodash_1.default.isEqual(optionValue, this.dataValue);
192
187
  }
193
188
  else {
194
189
  input.checked = (dataValue === input.value && (input.value || this.component.dataSrc !== 'url'));
@@ -225,14 +220,9 @@ class RadioComponent extends ListComponent_1.default {
225
220
  let value = this.component.inputType === 'checkbox' ? '' : this.dataValue;
226
221
  this.refs.input.forEach((input, index) => {
227
222
  if (input.checked) {
228
- if (!this.isSelectURL) {
229
- value = input.value;
230
- return;
231
- }
232
- const optionValue = this.loadedOptions[index].value;
233
- value = this.valuesMap.has(optionValue)
234
- ? this.valuesMap.get(optionValue)
235
- : optionValue;
223
+ value = (this.isSelectURL && lodash_1.default.isObject(this.loadedOptions[index].value)) ?
224
+ this.loadedOptions[index].value :
225
+ input.value;
236
226
  }
237
227
  });
238
228
  return value;
@@ -276,8 +266,8 @@ class RadioComponent extends ListComponent_1.default {
276
266
  }
277
267
  setValueAt(index, value) {
278
268
  if (this.refs.input && this.refs.input[index] && value !== null && value !== undefined) {
279
- const inputValue = this.getValueByInput(this.refs.input[index]);
280
- this.refs.input[index].checked = lodash_1.default.isEqual(inputValue, value);
269
+ const inputValue = this.refs.input[index].value;
270
+ this.refs.input[index].checked = (inputValue === value.toString());
281
271
  }
282
272
  }
283
273
  get shouldLoad() {
@@ -287,23 +277,6 @@ class RadioComponent extends ListComponent_1.default {
287
277
  }
288
278
  return super.shouldLoad;
289
279
  }
290
- prepareValue(item, options = {}) {
291
- const value = this.component.valueProperty && !options.skipValueProperty
292
- ? lodash_1.default.get(item, this.component.valueProperty)
293
- : item;
294
- if (this.component.type === 'radio' && typeof value !== 'string') {
295
- const uuid = (0, uuid_1.v4)();
296
- this.valuesMap.set(uuid, value);
297
- return uuid;
298
- }
299
- return value;
300
- }
301
- getValueByInput(input) {
302
- const inputValue = input.value;
303
- return this.valuesMap.has(inputValue)
304
- ? this.valuesMap.get(inputValue)
305
- : inputValue;
306
- }
307
280
  loadItems(url, search, headers, options, method, body) {
308
281
  if (this.optionsLoaded) {
309
282
  this.itemsLoadedResolve();
@@ -354,7 +327,7 @@ class RadioComponent extends ListComponent_1.default {
354
327
  label: this.itemTemplate(item)
355
328
  };
356
329
  if (lodash_1.default.isEqual(item, this.selectData || lodash_1.default.pick(this.dataValue, lodash_1.default.keys(item)))) {
357
- this.loadedOptions[i].value = this.prepareValue(this.dataValue, { skipValueProperty: true });
330
+ this.loadedOptions[i].value = this.dataValue;
358
331
  }
359
332
  });
360
333
  this.optionsLoaded = true;
@@ -364,15 +337,12 @@ class RadioComponent extends ListComponent_1.default {
364
337
  const listData = [];
365
338
  items === null || items === void 0 ? void 0 : items.forEach((item, i) => {
366
339
  const valueAtProperty = lodash_1.default.get(item, this.component.valueProperty);
367
- const value = this.prepareValue(item);
368
- const label = this.component.valueProperty
369
- ? this.itemTemplate(item, valueAtProperty, i)
370
- : this.itemTemplate(item, item, i);
371
- this.loadedOptions[i] = { label, value };
372
- listData.push(this.templateData[i]);
373
- if (this.valuesMap.has(value)) {
374
- this.templateData[value] = this.templateData[i];
375
- }
340
+ this.loadedOptions[i] = {
341
+ value: this.component.valueProperty ? valueAtProperty : item,
342
+ label: this.component.valueProperty ? this.itemTemplate(item, valueAtProperty) : this.itemTemplate(item, item, i)
343
+ };
344
+ listData.push(this.templateData[this.component.valueProperty ? valueAtProperty : i]);
345
+ const value = this.loadedOptions[i].value;
376
346
  if (!this.isRadio && (lodash_1.default.isObject(value) || lodash_1.default.isBoolean(value) || lodash_1.default.isUndefined(value))) {
377
347
  this.loadedOptions[i].invalid = true;
378
348
  }
@@ -395,9 +365,7 @@ class RadioComponent extends ListComponent_1.default {
395
365
  const value = this.dataValue;
396
366
  this.refs.wrapper.forEach((wrapper, index) => {
397
367
  const input = this.refs.input[index];
398
- const checked = (input.type === 'checkbox')
399
- ? value[input.value] || input.checked
400
- : lodash_1.default.isEqual(this.normalizeValue(this.getValueByInput(input)), value);
368
+ const checked = (input.type === 'checkbox') ? value[input.value] || input.checked : (input.value.toString() === value.toString());
401
369
  if (checked) {
402
370
  //add class to container when selected
403
371
  this.addClass(wrapper, this.optionSelectedClass);
@@ -411,25 +379,10 @@ class RadioComponent extends ListComponent_1.default {
411
379
  });
412
380
  }
413
381
  }
414
- setMetadata(value) {
415
- let key = value;
416
- if (typeof value !== 'string') {
417
- const checkedInput = Array.prototype.find.call(this.refs.input, (input => input.type === 'radio' && input.getAttribute('checked')));
418
- key = (checkedInput === null || checkedInput === void 0 ? void 0 : checkedInput.value) || key;
419
- }
420
- if (this.isSelectURL && this.templateData && this.templateData[key]) {
421
- const submission = this.root.submission;
422
- if (!submission.metadata.selectData) {
423
- submission.metadata.selectData = {};
424
- }
425
- lodash_1.default.set(submission.metadata.selectData, this.path, this.templateData[key]);
426
- }
427
- }
428
382
  updateValue(value, flags) {
429
383
  const changed = super.updateValue(value, flags);
430
384
  if (changed) {
431
385
  this.setSelectedClasses();
432
- this.setMetadata(this.dataValue);
433
386
  }
434
387
  if (!flags || !flags.modified || !this.isRadio) {
435
388
  if (changed) {
@@ -485,10 +438,14 @@ class RadioComponent extends ListComponent_1.default {
485
438
  value = !(!value || value.toString() === 'false');
486
439
  break;
487
440
  }
441
+ if (this.isSelectURL && this.templateData && this.templateData[value]) {
442
+ const submission = this.root.submission;
443
+ if (!submission.metadata.selectData) {
444
+ submission.metadata.selectData = {};
445
+ }
446
+ lodash_1.default.set(submission.metadata.selectData, this.path, this.templateData[value]);
447
+ }
488
448
  return super.normalizeValue(value);
489
449
  }
490
- isSingleInputValue() {
491
- return true;
492
- }
493
450
  }
494
451
  exports.default = RadioComponent;
@@ -275,7 +275,6 @@ class SelectBoxesComponent extends Radio_1.default {
275
275
  else {
276
276
  return super.setCustomValidity(messages, dirty, external);
277
277
  }
278
- ;
279
278
  }
280
279
  validateValueAvailability(setting, value) {
281
280
  if (!(0, utils_1.boolValue)(setting) || !value) {
@@ -73,6 +73,7 @@ function registerModule(mod, defaultFn = null, options = {}) {
73
73
  case 'templates':
74
74
  for (const framework of Object.keys(mod.templates)) {
75
75
  Formio_1.Formio.Templates.extendTemplate(framework, mod.templates[framework]);
76
+ Formio_1.Formio.Templates.defaultTemplates = lodash_1.default.defaults(mod.templates[framework], Formio_1.Formio.Templates.defaultTemplates);
76
77
  }
77
78
  if (mod.templates[current]) {
78
79
  Formio_1.Formio.Templates.current = mod.templates[current];
@@ -20,13 +20,13 @@ class DateGeaterThan extends ConditionOperator_1.default {
20
20
  }
21
21
  execute(options, functionName = 'isAfter') {
22
22
  var _a;
23
- const { value, instance, conditionComponentPath } = options;
23
+ const { value, instance, path } = options;
24
24
  if (!value) {
25
25
  return false;
26
26
  }
27
27
  let conditionTriggerComponent = null;
28
28
  if ((_a = instance === null || instance === void 0 ? void 0 : instance.root) === null || _a === void 0 ? void 0 : _a.getComponent) {
29
- conditionTriggerComponent = instance.root.getComponent(conditionComponentPath);
29
+ conditionTriggerComponent = instance.root.getComponent(path);
30
30
  }
31
31
  if (conditionTriggerComponent && conditionTriggerComponent.isPartialDay && conditionTriggerComponent.isPartialDay(value)) {
32
32
  return false;
@@ -1,8 +1,8 @@
1
1
  export default class IsEmptyValue extends ConditionOperator {
2
- execute({ value, instance, conditionComponentPath }: {
2
+ execute({ value, instance, path }: {
3
3
  value: any;
4
4
  instance: any;
5
- conditionComponentPath: any;
5
+ path: any;
6
6
  }): any;
7
7
  getResult(options: any): any;
8
8
  }
@@ -15,11 +15,11 @@ class IsEmptyValue extends ConditionOperator_1.default {
15
15
  static get requireValue() {
16
16
  return false;
17
17
  }
18
- execute({ value, instance, conditionComponentPath }) {
18
+ execute({ value, instance, path }) {
19
19
  var _a;
20
20
  const isEmptyValue = lodash_1.default.isEmpty(lodash_1.default.isNumber(value) ? String(value) : value);
21
21
  if ((_a = instance === null || instance === void 0 ? void 0 : instance.root) === null || _a === void 0 ? void 0 : _a.getComponent) {
22
- const conditionTriggerComponent = instance.root.getComponent(conditionComponentPath);
22
+ const conditionTriggerComponent = instance.root.getComponent(path);
23
23
  return (conditionTriggerComponent === null || conditionTriggerComponent === void 0 ? void 0 : conditionTriggerComponent.isEmpty) ? conditionTriggerComponent.isEmpty() : isEmptyValue;
24
24
  }
25
25
  return isEmptyValue;
@@ -1,9 +1,9 @@
1
1
  export default class IsEqualTo extends ConditionOperator {
2
- execute({ value, comparedValue, instance, conditionComponentPath }: {
2
+ execute({ value, comparedValue, instance, path }: {
3
3
  value: any;
4
4
  comparedValue: any;
5
5
  instance: any;
6
- conditionComponentPath: any;
6
+ path: any;
7
7
  }): any;
8
8
  }
9
9
  import ConditionOperator from './ConditionOperator';
@@ -13,7 +13,7 @@ class IsEqualTo extends ConditionOperator_1.default {
13
13
  static get displayedName() {
14
14
  return 'Is Equal To';
15
15
  }
16
- execute({ value, comparedValue, instance, conditionComponentPath }) {
16
+ execute({ value, comparedValue, instance, path }) {
17
17
  var _a, _b;
18
18
  if ((value || value === false) && comparedValue && typeof value !== typeof comparedValue && lodash_1.default.isString(comparedValue)) {
19
19
  try {
@@ -23,7 +23,7 @@ class IsEqualTo extends ConditionOperator_1.default {
23
23
  catch (e) { }
24
24
  }
25
25
  if ((_a = instance === null || instance === void 0 ? void 0 : instance.root) === null || _a === void 0 ? void 0 : _a.getComponent) {
26
- const conditionTriggerComponent = instance.root.getComponent(conditionComponentPath);
26
+ const conditionTriggerComponent = instance.root.getComponent(path);
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)) {
@@ -1,22 +1,33 @@
1
- /**
2
- * Deprecated version of findComponents. Renamed to searchComponents.
3
- * @param {import('@formio/core').Component[]} components - The components to find components within.
4
- * @param {object} query - The query to use when searching for the components.
5
- * @returns {import('@formio/core').Component[]} - The result of the component that is found.
6
- */
7
- export function findComponents(components: import('@formio/core').Component[], query: object): import('@formio/core').Component[];
8
1
  export const flattenComponents: typeof Utils.flattenComponents;
9
2
  export const guid: typeof Utils.guid;
10
3
  export const uniqueName: typeof Utils.uniqueName;
11
- export const MODEL_TYPES: any;
4
+ export const MODEL_TYPES_OF_KNOWN_COMPONENTS: {
5
+ nestedArray: string[];
6
+ nestedDataArray: string[];
7
+ dataObject: string[];
8
+ object: string[];
9
+ map: string[];
10
+ content: string[];
11
+ string: string[];
12
+ number: string[];
13
+ boolean: string[];
14
+ none: string[];
15
+ any: string[];
16
+ };
12
17
  export const getModelType: typeof Utils.getModelType;
13
- export const getComponentAbsolutePath: typeof Utils.getComponentAbsolutePath;
14
- export const getComponentPath: typeof Utils.getComponentPath;
18
+ export const getComponentPath: any;
19
+ export const setComponentScope: typeof Utils.setComponentScope;
20
+ export const resetComponentScope: typeof Utils.resetComponentScope;
15
21
  export const isComponentNestedDataType: typeof Utils.isComponentNestedDataType;
16
22
  export const componentPath: typeof Utils.componentPath;
17
- export const componentChildPath: any;
18
- export const eachComponentDataAsync: (components: Component[], data: DataObject, fn: EachComponentDataAsyncCallback, path?: string | undefined, index?: number | undefined, parent?: any, includeAll?: boolean | undefined) => Promise<void>;
19
- export const eachComponentData: (components: Component[], data: DataObject, fn: EachComponentDataCallback, path?: string | undefined, index?: number | undefined, parent?: any, includeAll?: boolean | undefined) => void;
23
+ export const getComponentPaths: typeof Utils.getComponentPaths;
24
+ export const componentMatches: typeof Utils.componentMatches;
25
+ export const getBestMatch: typeof Utils.getBestMatch;
26
+ export const getComponentFromPath: typeof Utils.getComponentFromPath;
27
+ export const getComponentValue: typeof Utils.getComponentValue;
28
+ export const findComponents: typeof Utils.findComponents;
29
+ export const eachComponentDataAsync: (components: Component[], data: DataObject, fn: EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: any, parentPaths?: any) => Promise<void>;
30
+ export const eachComponentData: (components: Component[], data: DataObject, fn: EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: any, parentPaths?: any) => void;
20
31
  export const getComponentKey: typeof Utils.getComponentKey;
21
32
  export const getContextualRowPath: typeof Utils.getContextualRowPath;
22
33
  export const getContextualRowData: typeof Utils.getContextualRowData;
@@ -24,7 +35,7 @@ export const componentInfo: typeof Utils.componentInfo;
24
35
  export const eachComponent: typeof Utils.eachComponent;
25
36
  export const eachComponentAsync: typeof Utils.eachComponentAsync;
26
37
  export const getComponentData: typeof Utils.getComponentData;
27
- export const getComponentActualValue: typeof Utils.getComponentActualValue;
38
+ export const getComponentActualValue: any;
28
39
  export const isLayoutComponent: typeof Utils.isLayoutComponent;
29
40
  export const matchComponent: typeof Utils.matchComponent;
30
41
  export const getComponent: typeof Utils.getComponent;
@@ -1,18 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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;
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.findComponents = exports.getComponentValue = exports.getComponentFromPath = exports.getBestMatch = exports.componentMatches = exports.getComponentPaths = exports.componentPath = exports.isComponentNestedDataType = exports.resetComponentScope = exports.setComponentScope = exports.getComponentPath = exports.getModelType = exports.MODEL_TYPES_OF_KNOWN_COMPONENTS = exports.uniqueName = exports.guid = exports.flattenComponents = 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, isSelectResourceWithObjectValue, compareSelectResourceWithObjectTypeValues, getItemTemplateKeys } = core_1.Utils;
5
+ const { flattenComponents, guid, uniqueName, MODEL_TYPES_OF_KNOWN_COMPONENTS, getModelType, getComponentPath, setComponentScope, resetComponentScope, isComponentNestedDataType, componentPath, getComponentPaths, componentMatches, getBestMatch, getComponentFromPath, getComponentValue, findComponents, 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;
9
- exports.MODEL_TYPES = MODEL_TYPES;
9
+ exports.MODEL_TYPES_OF_KNOWN_COMPONENTS = MODEL_TYPES_OF_KNOWN_COMPONENTS;
10
10
  exports.getModelType = getModelType;
11
- exports.getComponentAbsolutePath = getComponentAbsolutePath;
12
11
  exports.getComponentPath = getComponentPath;
12
+ exports.setComponentScope = setComponentScope;
13
+ exports.resetComponentScope = resetComponentScope;
13
14
  exports.isComponentNestedDataType = isComponentNestedDataType;
14
15
  exports.componentPath = componentPath;
15
- exports.componentChildPath = componentChildPath;
16
+ exports.getComponentPaths = getComponentPaths;
17
+ exports.componentMatches = componentMatches;
18
+ exports.getBestMatch = getBestMatch;
19
+ exports.getComponentFromPath = getComponentFromPath;
20
+ exports.getComponentValue = getComponentValue;
21
+ exports.findComponents = findComponents;
16
22
  exports.eachComponentDataAsync = eachComponentDataAsync;
17
23
  exports.eachComponentData = eachComponentData;
18
24
  exports.getComponentKey = getComponentKey;
@@ -42,14 +48,3 @@ exports.isComponentDataEmpty = isComponentDataEmpty;
42
48
  exports.isSelectResourceWithObjectValue = isSelectResourceWithObjectValue;
43
49
  exports.compareSelectResourceWithObjectTypeValues = compareSelectResourceWithObjectTypeValues;
44
50
  exports.getItemTemplateKeys = getItemTemplateKeys;
45
- /**
46
- * Deprecated version of findComponents. Renamed to searchComponents.
47
- * @param {import('@formio/core').Component[]} components - The components to find components within.
48
- * @param {object} query - The query to use when searching for the components.
49
- * @returns {import('@formio/core').Component[]} - The result of the component that is found.
50
- */
51
- function findComponents(components, query) {
52
- console.warn('formio.js/utils findComponents is deprecated. Use searchComponents instead.');
53
- return searchComponents(components, query);
54
- }
55
- exports.findComponents = findComponents;
@@ -462,10 +462,9 @@ export function getComponentPathWithoutIndicies(path?: string): string;
462
462
  /**
463
463
  * Returns a path to the component which based on its schema
464
464
  * @param {import('@formio/core').Component} component - Component containing link to its parent's schema in the 'parent' property
465
- * @param {string} path - Path to the component
466
465
  * @returns {string} - Path to the component
467
466
  */
468
- export function getComponentPath(component: import('@formio/core').Component, path?: string): string;
467
+ export function getComponentPath(component: import('@formio/core').Component): string;
469
468
  /**
470
469
  * Returns a parent component of the passed component instance skipping all the Layout components
471
470
  * @param {Component} componentInstance - The component to check for the parent.
@@ -51,17 +51,6 @@ json_logic_js_1.default.add_operation('relativeMinDate', (relativeMinDate) => {
51
51
  json_logic_js_1.default.add_operation('relativeMaxDate', (relativeMaxDate) => {
52
52
  return (0, moment_timezone_1.default)().add(relativeMaxDate, 'days').toISOString();
53
53
  });
54
- /**
55
- * Sets the path to the component and parent schema.
56
- * @param {import('@formio/core').Component} component - The component to set the path for.
57
- */
58
- function setPathToComponentAndPerentSchema(component) {
59
- component.path = getComponentPath(component);
60
- const dataParent = getDataParentComponent(component);
61
- if (dataParent && typeof dataParent === 'object') {
62
- dataParent.path = getComponentPath(dataParent);
63
- }
64
- }
65
54
  /**
66
55
  * Evaluate a method.
67
56
  * @param {Function|string|object} func - The function to evaluate.
@@ -262,7 +251,7 @@ function checkSimpleConditional(component, condition, row, data, instance) {
262
251
  const value = getComponentActualValue(path, data, row);
263
252
  const ConditionOperator = conditionOperators_1.default[operator];
264
253
  return ConditionOperator
265
- ? new ConditionOperator().getResult({ value, comparedValue, instance, component, conditionComponentPath })
254
+ ? new ConditionOperator().getResult({ value, comparedValue, instance, component, path })
266
255
  : true;
267
256
  });
268
257
  }
@@ -270,7 +259,7 @@ function checkSimpleConditional(component, condition, row, data, instance) {
270
259
  const value = getComponentActualValue(conditionComponentPath, data, row);
271
260
  const СonditionOperator = conditionOperators_1.default[operator];
272
261
  return СonditionOperator
273
- ? new СonditionOperator().getResult({ value, comparedValue, instance, component, conditionComponentPath })
262
+ ? new СonditionOperator().getResult({ value, comparedValue, instance, component, path: conditionComponentPath })
274
263
  : true;
275
264
  }
276
265
  });
@@ -367,22 +356,23 @@ exports.checkJsonConditional = checkJsonConditional;
367
356
  * @returns {*} - The contextual row data for the component.
368
357
  */
369
358
  function getRow(component, row, instance, conditional) {
370
- var _a;
359
+ var _a, _b, _c;
371
360
  const condition = conditional || component.conditional;
372
361
  // If no component's instance passed (happens only in 6.x server), calculate its path based on the schema
373
362
  if (!instance) {
374
363
  instance = lodash_1.default.cloneDeep(component);
375
- setPathToComponentAndPerentSchema(instance);
376
364
  }
377
365
  const dataParent = getDataParentComponent(instance);
378
- const parentPath = dataParent ? getComponentPath(dataParent) : null;
379
- const isTriggerCondtionComponentPath = condition.when || !condition.conditions
380
- ? (_a = condition.when) === null || _a === void 0 ? void 0 : _a.startsWith(parentPath)
381
- : lodash_1.default.some(condition.conditions, cond => cond.component.startsWith(parentPath));
382
- if (dataParent && isTriggerCondtionComponentPath) {
383
- const newRow = {};
384
- lodash_1.default.set(newRow, parentPath, row);
385
- row = newRow;
366
+ if (dataParent) {
367
+ const parentPath = (_a = dataParent.paths) === null || _a === void 0 ? void 0 : _a.localDataPath;
368
+ const isTriggerCondtionComponentPath = condition.when || !condition.conditions
369
+ ? (_b = condition.when) === null || _b === void 0 ? void 0 : _b.startsWith((_c = dataParent.paths) === null || _c === void 0 ? void 0 : _c.localPath)
370
+ : lodash_1.default.some(condition.conditions, cond => { var _a; return cond.component.startsWith((_a = dataParent.paths) === null || _a === void 0 ? void 0 : _a.localPath); });
371
+ if (isTriggerCondtionComponentPath) {
372
+ const newRow = {};
373
+ lodash_1.default.set(newRow, parentPath, row);
374
+ row = newRow;
375
+ }
386
376
  }
387
377
  return row;
388
378
  }
@@ -1566,16 +1556,10 @@ exports.getComponentPathWithoutIndicies = getComponentPathWithoutIndicies;
1566
1556
  /**
1567
1557
  * Returns a path to the component which based on its schema
1568
1558
  * @param {import('@formio/core').Component} component - Component containing link to its parent's schema in the 'parent' property
1569
- * @param {string} path - Path to the component
1570
1559
  * @returns {string} - Path to the component
1571
1560
  */
1572
- function getComponentPath(component, path = '') {
1573
- var _a;
1574
- if (!component || !component.key || ((_a = component === null || component === void 0 ? void 0 : component._form) === null || _a === void 0 ? void 0 : _a.display) === 'wizard') { // unlike the Webform, the Wizard has the key and it is a duplicate of the panel key
1575
- return path;
1576
- }
1577
- path = component.isInputComponent || component.input === true ? `${component.key}${path ? '.' : ''}${path}` : path;
1578
- return getComponentPath(component.parent, path);
1561
+ function getComponentPath(component) {
1562
+ return component.paths.localDataPath;
1579
1563
  }
1580
1564
  exports.getComponentPath = getComponentPath;
1581
1565
  /**
@@ -426,7 +426,7 @@ declare class Webform extends NestedDataComponent {
426
426
  */
427
427
  cancel(noconfirm: boolean): boolean;
428
428
  setMetadata(submission: any): void;
429
- submitForm(options?: {}): Promise<any>;
429
+ submitForm(options?: {}, local?: boolean): Promise<any>;
430
430
  setServerErrors(error: any): void;
431
431
  serverErrors: any;
432
432
  executeSubmit(options: any): Promise<object>;
@@ -588,6 +588,7 @@ export default class Webform extends NestedDataComponent {
588
588
  try {
589
589
  // Do not set the form again if it has been already set
590
590
  if (isFormAlreadySet && JSON.stringify(this._form) === JSON.stringify(form)) {
591
+ this.formReadyResolve();
591
592
  return Promise.resolve();
592
593
  }
593
594
  // Create the form.
@@ -595,13 +596,11 @@ export default class Webform extends NestedDataComponent {
595
596
  if (this.onSetForm) {
596
597
  this.onSetForm(_.cloneDeep(this._form), form);
597
598
  }
598
- if (this.parent?.component?.modalEdit) {
599
- return Promise.resolve();
600
- }
601
599
  }
602
600
  catch (err) {
603
601
  console.warn(err);
604
602
  // If provided form is not a valid JSON object, do not set it too
603
+ this.formReadyReject(err);
605
604
  return Promise.resolve();
606
605
  }
607
606
  // Allow the form to provide component overrides.
@@ -850,6 +849,9 @@ export default class Webform extends NestedDataComponent {
850
849
  return changed;
851
850
  }
852
851
  getValue() {
852
+ if (!this._submission) {
853
+ this._submission = {};
854
+ }
853
855
  if (!this._submission.data) {
854
856
  this._submission.data = {};
855
857
  }
@@ -1111,29 +1113,23 @@ export default class Webform extends NestedDataComponent {
1111
1113
  return;
1112
1114
  }
1113
1115
  // Mark any components as invalid if in a custom message.
1116
+ const componentErrors = {};
1114
1117
  errors.forEach((err) => {
1115
- const { components = [] } = err;
1116
- if (err.component) {
1117
- components.push(err.component);
1118
+ const path = err.path || err.context?.path || err.component?.key;
1119
+ if (!componentErrors[path]) {
1120
+ componentErrors[path] = [];
1118
1121
  }
1119
- if (err.path) {
1120
- components.push(err.path);
1121
- }
1122
- components.forEach((path) => {
1123
- const originalPath = getStringFromComponentPath(path);
1124
- const component = this.getComponent(path, _.identity, originalPath);
1125
- if (err.fromServer) {
1126
- if (component.serverErrors) {
1127
- component.serverErrors.push(err);
1128
- }
1129
- else {
1130
- component.serverErrors = [err];
1131
- }
1132
- }
1133
- const components = _.compact(Array.isArray(component) ? component : [component]);
1134
- components.forEach((component) => component.setCustomValidity(err.message, true));
1135
- });
1122
+ componentErrors[path].push(err);
1136
1123
  });
1124
+ // Iterate through all of our component errors and apply them to the components.
1125
+ for (let path in componentErrors) {
1126
+ const component = this.getComponent(path);
1127
+ const errors = componentErrors[path];
1128
+ if (component) {
1129
+ component.serverErrors = errors.filter((err) => err.fromServer);
1130
+ component.setCustomValidity(errors, true);
1131
+ }
1132
+ }
1137
1133
  const displayedErrors = [];
1138
1134
  if (errors.length) {
1139
1135
  errors = _.uniqBy(errors, (error) => [error.message, error.component?.id, error.context?.path].join());
@@ -1326,7 +1322,7 @@ export default class Webform extends NestedDataComponent {
1326
1322
  onLine: navigator.onLine,
1327
1323
  });
1328
1324
  }
1329
- submitForm(options = {}) {
1325
+ submitForm(options = {}, local = false) {
1330
1326
  this.clearServerErrors();
1331
1327
  return new Promise((resolve, reject) => {
1332
1328
  // Read-only forms should never submit.
@@ -1351,6 +1347,7 @@ export default class Webform extends NestedDataComponent {
1351
1347
  return reject("Invalid Submission");
1352
1348
  }
1353
1349
  const errors = this.validate(submission.data, {
1350
+ local,
1354
1351
  dirty: true,
1355
1352
  silentCheck: false,
1356
1353
  process: "submit",
@@ -1366,11 +1363,11 @@ export default class Webform extends NestedDataComponent {
1366
1363
  }
1367
1364
  this.everyComponent((comp) => {
1368
1365
  if (submission._vnote && comp.type === "form" && comp.component.reference) {
1369
- _.get(submission.data, comp.path, {})._vnote = submission._vnote;
1366
+ _.get(submission.data, local ? comp.paths?.localDataPath : comp.path, {})._vnote = submission._vnote;
1370
1367
  }
1371
1368
  const { persistent } = comp.component;
1372
1369
  if (persistent === "client-only") {
1373
- _.unset(submission.data, comp.path);
1370
+ _.unset(submission.data, local ? comp.paths?.localDataPath : comp.path);
1374
1371
  }
1375
1372
  });
1376
1373
  this.hook("customValidation", { ...submission, component: options.component }, (err) => {
@@ -1536,7 +1533,7 @@ export default class Webform extends NestedDataComponent {
1536
1533
  return;
1537
1534
  }
1538
1535
  const captchaComponent = [];
1539
- eachComponent(this.components, (component) => {
1536
+ this.eachComponent((component) => {
1540
1537
  if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {
1541
1538
  captchaComponent.push(component);
1542
1539
  }
@@ -1096,20 +1096,12 @@ export default class WebformBuilder extends Component {
1096
1096
  findRepeatablePaths() {
1097
1097
  const repeatablePaths = [];
1098
1098
  const keys = new Map();
1099
- eachComponent(this.form.components, (comp, path) => {
1100
- if (!comp.key) {
1101
- return;
1102
- }
1103
- if (keys.has(comp.key)) {
1104
- if (keys.get(comp.key).includes(path)) {
1105
- repeatablePaths.push(path);
1106
- }
1107
- else {
1108
- keys.set(comp.key, [...keys.get(comp.key), path]);
1109
- }
1099
+ eachComponent(this.form.components, (comp, path, components, parent, paths) => {
1100
+ if (keys.has(paths.dataPath)) {
1101
+ repeatablePaths.push(paths.dataPath);
1110
1102
  }
1111
1103
  else {
1112
- keys.set(comp.key, [path]);
1104
+ keys.set(paths.dataPath, true);
1113
1105
  }
1114
1106
  }, true);
1115
1107
  return repeatablePaths;
@@ -1241,7 +1233,8 @@ export default class WebformBuilder extends Component {
1241
1233
  helplinks: this.helplinks,
1242
1234
  }));
1243
1235
  this.editForm.attach(this.componentEdit.querySelector(`[${this._referenceAttributeName}="editForm"]`));
1244
- this.updateComponent(this.editForm.submission.data ?? component);
1236
+ const editFormData = this.editForm.submission?.data;
1237
+ this.updateComponent(editFormData?.componentJson || editFormData || component);
1245
1238
  this.attachEditComponentControls(component, parent, isNew, original, ComponentClass);
1246
1239
  });
1247
1240
  });