@formio/js 5.0.0-rc.99 → 5.1.0-rc.1

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 (86) hide show
  1. package/dist/formio.embed.js +1 -1
  2. package/dist/formio.embed.min.js +1 -1
  3. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  4. package/dist/formio.form.js +122 -121
  5. package/dist/formio.form.min.js +1 -1
  6. package/dist/formio.form.min.js.LICENSE.txt +3 -11
  7. package/dist/formio.full.js +123 -122
  8. package/dist/formio.full.min.js +1 -1
  9. package/dist/formio.full.min.js.LICENSE.txt +3 -11
  10. package/dist/formio.js +3011 -281
  11. package/dist/formio.min.js +1 -1
  12. package/dist/formio.min.js.LICENSE.txt +14 -2
  13. package/dist/formio.utils.js +65 -54
  14. package/dist/formio.utils.min.js +1 -1
  15. package/dist/formio.utils.min.js.LICENSE.txt +7 -5
  16. package/lib/cjs/Webform.d.ts +8 -1
  17. package/lib/cjs/Webform.js +40 -32
  18. package/lib/cjs/WebformBuilder.js +22 -18
  19. package/lib/cjs/Wizard.d.ts +0 -1
  20. package/lib/cjs/Wizard.js +19 -33
  21. package/lib/cjs/components/Components.d.ts +0 -7
  22. package/lib/cjs/components/Components.js +1 -33
  23. package/lib/cjs/components/_classes/component/Component.d.ts +37 -7
  24. package/lib/cjs/components/_classes/component/Component.js +70 -26
  25. package/lib/cjs/components/_classes/component/editForm/Component.edit.validation.js +1 -1
  26. package/lib/cjs/components/_classes/componentModal/ComponentModal.d.ts +1 -0
  27. package/lib/cjs/components/_classes/componentModal/ComponentModal.js +1 -0
  28. package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +4 -19
  29. package/lib/cjs/components/_classes/nested/NestedComponent.js +38 -53
  30. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -1
  31. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +7 -44
  32. package/lib/cjs/components/datagrid/DataGrid.d.ts +0 -1
  33. package/lib/cjs/components/datagrid/DataGrid.js +1 -45
  34. package/lib/cjs/components/datamap/DataMap.js +1 -2
  35. package/lib/cjs/components/editgrid/EditGrid.js +6 -6
  36. package/lib/cjs/components/form/Form.d.ts +8 -3
  37. package/lib/cjs/components/form/Form.js +26 -25
  38. package/lib/cjs/components/html/HTML.js +1 -1
  39. package/lib/cjs/components/selectboxes/SelectBoxes.js +8 -1
  40. package/lib/cjs/components/signature/Signature.d.ts +0 -1
  41. package/lib/cjs/components/signature/Signature.js +1 -1
  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 -3
  50. package/lib/cjs/utils/utils.js +19 -35
  51. package/lib/mjs/Webform.d.ts +8 -1
  52. package/lib/mjs/Webform.js +37 -31
  53. package/lib/mjs/WebformBuilder.js +22 -18
  54. package/lib/mjs/Wizard.d.ts +0 -1
  55. package/lib/mjs/Wizard.js +16 -29
  56. package/lib/mjs/components/Components.d.ts +0 -7
  57. package/lib/mjs/components/Components.js +1 -32
  58. package/lib/mjs/components/_classes/component/Component.d.ts +37 -7
  59. package/lib/mjs/components/_classes/component/Component.js +80 -27
  60. package/lib/mjs/components/_classes/component/editForm/Component.edit.validation.js +1 -1
  61. package/lib/mjs/components/_classes/componentModal/ComponentModal.d.ts +1 -0
  62. package/lib/mjs/components/_classes/componentModal/ComponentModal.js +1 -0
  63. package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +4 -19
  64. package/lib/mjs/components/_classes/nested/NestedComponent.js +39 -54
  65. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -1
  66. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +8 -43
  67. package/lib/mjs/components/datagrid/DataGrid.d.ts +0 -1
  68. package/lib/mjs/components/datagrid/DataGrid.js +1 -45
  69. package/lib/mjs/components/datamap/DataMap.js +1 -2
  70. package/lib/mjs/components/editgrid/EditGrid.js +9 -6
  71. package/lib/mjs/components/form/Form.d.ts +8 -3
  72. package/lib/mjs/components/form/Form.js +27 -25
  73. package/lib/mjs/components/html/HTML.js +1 -1
  74. package/lib/mjs/components/selectboxes/SelectBoxes.js +8 -1
  75. package/lib/mjs/components/signature/Signature.d.ts +0 -1
  76. package/lib/mjs/components/signature/Signature.js +1 -1
  77. package/lib/mjs/utils/conditionOperators/DateGreaterThan.js +2 -2
  78. package/lib/mjs/utils/conditionOperators/IsEmptyValue.d.ts +2 -2
  79. package/lib/mjs/utils/conditionOperators/IsEmptyValue.js +2 -2
  80. package/lib/mjs/utils/conditionOperators/IsEqualTo.d.ts +2 -2
  81. package/lib/mjs/utils/conditionOperators/IsEqualTo.js +2 -2
  82. package/lib/mjs/utils/formUtils.d.ts +25 -14
  83. package/lib/mjs/utils/formUtils.js +2 -12
  84. package/lib/mjs/utils/utils.d.ts +1 -3
  85. package/lib/mjs/utils/utils.js +18 -33
  86. package/package.json +4 -4
@@ -924,6 +924,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
924
924
  const options = lodash_1.default.clone(this.options);
925
925
  options.name += `[${rowIndex}]`;
926
926
  options.row = `${rowIndex}-${colIndex}`;
927
+ options.rowIndex = rowIndex;
927
928
  options.onChange = (flags = {}, changed, modified) => {
928
929
  var _a, _b;
929
930
  if (((_a = changed.instance.root) === null || _a === void 0 ? void 0 : _a.id) && (((_b = this.root) === null || _b === void 0 ? void 0 : _b.id) !== changed.instance.root.id)) {
@@ -938,7 +939,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
938
939
  const editRow = this.editRows[rowIndex];
939
940
  if (editRow) {
940
941
  this.processRow('checkData', null, Object.assign(Object.assign({}, flags), { changed }), editRow.data, editRow.components);
941
- this.validateRow(editRow, false);
942
+ this.validateRow(editRow, false, false);
942
943
  }
943
944
  if (this.variableTypeComponentsIndexes.length) {
944
945
  this.checkRowVariableTypeComponents(editRow, rowIndex);
@@ -980,22 +981,21 @@ class EditGridComponent extends NestedArrayComponent_1.default {
980
981
  var _a;
981
982
  editRow.errors = [];
982
983
  if (this.shouldValidateRow(editRow, dirty, fromSubmission)) {
983
- const silentCheck = (this.component.rowDrafts && !this.shouldValidateDraft(editRow)) || forceSilentCheck;
984
+ const silentCheck = forceSilentCheck === false ? false : ((this.component.rowDrafts && !this.shouldValidateDraft(editRow)) || forceSilentCheck);
984
985
  const rootValue = (0, utils_1.fastCloneDeep)(this.rootValue);
985
986
  const editGridValue = lodash_1.default.get(rootValue, this.path, []);
986
987
  editGridValue[editRow.rowIndex] = editRow.data;
987
988
  lodash_1.default.set(rootValue, this.path, editGridValue);
988
989
  const validationProcessorProcess = (context) => this.validationProcessor(context, { dirty, silentCheck });
989
990
  const errors = (0, process_1.processSync)({
990
- components: (0, utils_1.fastCloneDeep)(this.component.components).map((component) => {
991
- component.parentPath = `${this.path}[${editRow.rowIndex}]`;
992
- return component;
993
- }),
991
+ components: this.component.components,
994
992
  data: rootValue,
995
993
  row: editRow.data,
996
994
  process: 'validateRow',
997
995
  instances: this.componentsMap,
998
996
  scope: { errors: [] },
997
+ parent: this.component,
998
+ parentPaths: Object.assign(Object.assign({}, this.paths), { dataIndex: editRow.rowIndex }),
999
999
  processors: [
1000
1000
  {
1001
1001
  process: validationProcessorProcess,
@@ -21,7 +21,7 @@ export default class FormComponent extends Component {
21
21
  get useOriginalRevision(): any;
22
22
  setFormRevision(rev: any): void;
23
23
  subFormRevision: any;
24
- getComponent(path: any, fn: any): any;
24
+ getComponent(path: any): any;
25
25
  getSubOptions(options?: {}): {};
26
26
  render(): string;
27
27
  asString(value: any): any;
@@ -55,8 +55,6 @@ export default class FormComponent extends Component {
55
55
  */
56
56
  loadSubForm(fromAttach: boolean): Promise<any>;
57
57
  subFormLoading: boolean | undefined;
58
- get subFormData(): any;
59
- checkComponentValidity(data: any, dirty: any, row: any, options: any, errors?: any[]): any;
60
58
  checkComponentConditions(data: any, flags: any, row: any): any;
61
59
  calculateValue(data: any, flags: any, row: any): any;
62
60
  setPristine(pristine: any): void;
@@ -90,6 +88,13 @@ export default class FormComponent extends Component {
90
88
  isHidden(): boolean;
91
89
  setValue(submission: any, flags?: {}): boolean;
92
90
  setSubFormValue(submission: any, flags: any): void;
91
+ /**
92
+ * Sets the subform value
93
+ * @param {object|null|undefined} submission - The submission to set.
94
+ * @param {object|null|undefined} flags - Any flags to apply when setting the submission.
95
+ * @return {void}
96
+ */
97
+ onSetSubFormValue(submission: object | null | undefined, flags: object | null | undefined): void;
93
98
  areAllComponentsEmpty(data: any): boolean;
94
99
  updateSubFormVisibility(): void;
95
100
  /**
@@ -133,15 +133,11 @@ class FormComponent extends Component_1.default {
133
133
  this.subFormRevision = undefined;
134
134
  }
135
135
  }
136
- getComponent(path, fn) {
137
- path = (0, utils_1.getArrayFromComponentPath)(path);
138
- if (path[0] === 'data') {
139
- path.shift();
140
- }
141
- const originalPathStr = `${this.path}.data.${(0, utils_1.getStringFromComponentPath)(path)}`;
142
- if (this.subForm) {
143
- return this.subForm.getComponent(path, fn, originalPathStr);
136
+ getComponent(path) {
137
+ if (!this.subForm) {
138
+ return null;
144
139
  }
140
+ return this.subForm.getComponent(path);
145
141
  }
146
142
  /* eslint-disable max-statements */
147
143
  getSubOptions(options = {}) {
@@ -209,6 +205,7 @@ class FormComponent extends Component_1.default {
209
205
  if (this.options.skipDraftRestore) {
210
206
  options.skipDraftRestore = this.options.skipDraftRestore;
211
207
  }
208
+ options.parent = this;
212
209
  return options;
213
210
  }
214
211
  /* eslint-enable max-statements */
@@ -297,6 +294,7 @@ class FormComponent extends Component_1.default {
297
294
  const modalShouldBeOpened = this.componentModal ? this.componentModal.isOpened : false;
298
295
  const currentValue = modalShouldBeOpened ? this.componentModal.currentValue : this.dataValue;
299
296
  this.componentModal = new ComponentModal_1.default(this, element, modalShouldBeOpened, currentValue, this._referenceAttributeName);
297
+ this.subForm.element = this.componentModal.refs.componentContent || this.subForm.element;
300
298
  this.setOpenModalElement();
301
299
  }
302
300
  this.calculateValue();
@@ -395,6 +393,10 @@ class FormComponent extends Component_1.default {
395
393
  return (new Form_1.default(form, this.getSubOptions())).ready.then((instance) => {
396
394
  this.subForm = instance;
397
395
  this.subForm.currentForm = this;
396
+ const componentsMap = this.componentsMap;
397
+ const formComponentsMap = this.subForm.componentsMap;
398
+ lodash_1.default.assign(componentsMap, formComponentsMap);
399
+ this.component.components = this.subForm.components.map((comp) => comp.component);
398
400
  this.subForm.parent = this;
399
401
  this.subForm.parentVisible = this.visible;
400
402
  this.subForm.on('change', () => {
@@ -413,6 +415,8 @@ class FormComponent extends Component_1.default {
413
415
  this.valueChanged = this.hasSetValue;
414
416
  this.onChange();
415
417
  return this.subForm;
418
+ }).catch((err) => {
419
+ console.log(err);
416
420
  });
417
421
  }).then((subForm) => {
418
422
  this.updateSubWizards(subForm);
@@ -469,18 +473,6 @@ class FormComponent extends Component_1.default {
469
473
  }
470
474
  return Promise.resolve();
471
475
  }
472
- get subFormData() {
473
- var _a;
474
- return ((_a = this.dataValue) === null || _a === void 0 ? void 0 : _a.data) || {};
475
- }
476
- checkComponentValidity(data, dirty, row, options, errors = []) {
477
- options = options || {};
478
- const silentCheck = options.silentCheck || false;
479
- if (this.subForm && !this.isNestedWizard) {
480
- return this.subForm.checkValidity(this.subFormData, dirty, null, silentCheck, errors);
481
- }
482
- return super.checkComponentValidity(data, dirty, row, options, errors);
483
- }
484
476
  checkComponentConditions(data, flags, row) {
485
477
  const visible = super.checkComponentConditions(data, flags, row);
486
478
  // Return if already hidden
@@ -488,14 +480,14 @@ class FormComponent extends Component_1.default {
488
480
  return visible;
489
481
  }
490
482
  if (this.subForm) {
491
- return this.subForm.checkConditions(this.subFormData);
483
+ return this.subForm.checkConditions(data, flags, row);
492
484
  }
493
485
  // There are few cases when subForm is not loaded when a change is triggered,
494
486
  // so we need to perform checkConditions after it is ready, or some conditional fields might be hidden in View mode
495
487
  else if (this.subFormReady) {
496
488
  this.subFormReady.then(() => {
497
489
  if (this.subForm) {
498
- return this.subForm.checkConditions(this.subFormData);
490
+ return this.subForm.checkConditions(data, flags, row);
499
491
  }
500
492
  });
501
493
  }
@@ -503,7 +495,7 @@ class FormComponent extends Component_1.default {
503
495
  }
504
496
  calculateValue(data, flags, row) {
505
497
  if (this.subForm) {
506
- return this.subForm.calculateValue(this.subFormData, flags);
498
+ return this.subForm.calculateValue(data, flags, row);
507
499
  }
508
500
  return super.calculateValue(data, flags, row);
509
501
  }
@@ -545,7 +537,7 @@ class FormComponent extends Component_1.default {
545
537
  }
546
538
  this.subForm.nosubmit = false;
547
539
  this.subForm.submitted = true;
548
- return this.subForm.submitForm().then(result => {
540
+ return this.subForm.submitForm({}, true).then(result => {
549
541
  this.subForm.loading = false;
550
542
  this.subForm.showAllErrors = false;
551
543
  this.dataValue = result.submission;
@@ -649,9 +641,18 @@ class FormComponent extends Component_1.default {
649
641
  });
650
642
  }
651
643
  else {
652
- this.subForm.setValue(submission, flags);
644
+ this.onSetSubFormValue(submission, flags);
653
645
  }
654
646
  }
647
+ /**
648
+ * Sets the subform value
649
+ * @param {object|null|undefined} submission - The submission to set.
650
+ * @param {object|null|undefined} flags - Any flags to apply when setting the submission.
651
+ * @return {void}
652
+ */
653
+ onSetSubFormValue(submission, flags) {
654
+ this.subForm.setValue(submission, flags);
655
+ }
655
656
  isEmpty(value = this.dataValue) {
656
657
  return value === null || lodash_1.default.isEqual(value, this.emptyValue) || (this.areAllComponentsEmpty(value === null || value === void 0 ? void 0 : value.data) && !(value === null || value === void 0 ? void 0 : value._id));
657
658
  }
@@ -10,7 +10,7 @@ class HTMLComponent extends Component_1.default {
10
10
  return Component_1.default.schema({
11
11
  label: 'HTML',
12
12
  type: 'htmlelement',
13
- tag: 'p',
13
+ tag: 'div',
14
14
  attrs: [],
15
15
  content: '',
16
16
  input: false,
@@ -139,6 +139,14 @@ class SelectBoxesComponent extends Radio_1.default {
139
139
  checkedValues.forEach((value) => selectData.push(this.templateData[value]));
140
140
  lodash_1.default.set(submission.metadata.selectData, this.path, selectData);
141
141
  }
142
+ // Ensure that for dataSrc == 'values' that there are not any other superfluous values.
143
+ if (this.component.dataSrc === 'values') {
144
+ for (const key in value) {
145
+ if (!this.component.values.find((val) => val.value === key)) {
146
+ delete value[key];
147
+ }
148
+ }
149
+ }
142
150
  return value;
143
151
  }
144
152
  /**
@@ -267,7 +275,6 @@ class SelectBoxesComponent extends Radio_1.default {
267
275
  else {
268
276
  return super.setCustomValidity(messages, dirty, external);
269
277
  }
270
- ;
271
278
  }
272
279
  validateValueAvailability(setting, value) {
273
280
  if (!(0, utils_1.boolValue)(setting) || !value) {
@@ -22,7 +22,6 @@ export default class SignatureComponent extends Input {
22
22
  showCanvas(show: any): void;
23
23
  onDisabled(): void;
24
24
  checkSize(force: any, scale: any): void;
25
- getModalPreviewTemplate(): any;
26
25
  signaturePad: SignaturePad | null | undefined;
27
26
  observer: any;
28
27
  getValueAsString(value: any): "" | "Yes" | "No";
@@ -172,7 +172,7 @@ class SignatureComponent extends Input_1.default {
172
172
  return false;
173
173
  }
174
174
  getModalPreviewTemplate() {
175
- return this.renderTemplate('modalPreview', {
175
+ return this.renderModalPreview({
176
176
  previewText: this.dataValue ?
177
177
  `<img src=${this.dataValue} ${this._referenceAttributeName}='openModal' style="width: 100%;height: 100%;" />` :
178
178
  this.t('Click to Sign')
@@ -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.
@@ -515,7 +514,6 @@ export namespace componentValueTypes {
515
514
  let any: string;
516
515
  }
517
516
  export function interpolateErrors(component: Component, errors: FieldError[], interpolateFn: Function): [];
518
- import jsonLogic from 'json-logic-js';
519
517
  import ConditionOperators from './conditionOperators';
520
518
  import { Evaluator } from './Evaluator';
521
519
  export const interpolate: typeof Evaluator.interpolate;
@@ -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
  });
@@ -295,12 +284,12 @@ exports.checkSimpleConditional = checkSimpleConditional;
295
284
  */
296
285
  function getComponentActualValue(compPath, data, row) {
297
286
  let value = null;
298
- if (row) {
299
- value = (0, formUtils_1.getValue)({ data: row }, compPath);
300
- }
301
- if (data && lodash_1.default.isNil(value)) {
287
+ if (data) {
302
288
  value = (0, formUtils_1.getValue)({ data }, compPath);
303
289
  }
290
+ if (row && lodash_1.default.isNil(value)) {
291
+ value = (0, formUtils_1.getValue)({ data: row }, compPath);
292
+ }
304
293
  // FOR-400 - Fix issue where falsey values were being evaluated as show=true
305
294
  if (lodash_1.default.isNil(value) || (lodash_1.default.isObject(value) && lodash_1.default.isEmpty(value))) {
306
295
  value = '';
@@ -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
  /**
@@ -330,6 +330,13 @@ declare class Webform extends NestedDataComponent {
330
330
  * @returns {object} - The submission object.
331
331
  */
332
332
  get submission(): object;
333
+ /**
334
+ * Sets the submission value
335
+ * @param {object|null|undefined} submission - The submission to set.
336
+ * @param {object|null|undefined} flags - Any flags to apply when setting the submission.
337
+ * @return {void}
338
+ */
339
+ onSetSubmission(submission: object | null | undefined, flags?: object | null | undefined): void;
333
340
  /**
334
341
  * Sets a submission and returns the promise when it is ready.
335
342
  * @param {any} submission - The submission to set.
@@ -419,7 +426,7 @@ declare class Webform extends NestedDataComponent {
419
426
  */
420
427
  cancel(noconfirm: boolean): boolean;
421
428
  setMetadata(submission: any): void;
422
- submitForm(options?: {}): Promise<any>;
429
+ submitForm(options?: {}, local?: boolean): Promise<any>;
423
430
  setServerErrors(error: any): void;
424
431
  serverErrors: any;
425
432
  executeSubmit(options: any): Promise<object>;