@formio/js 5.0.0 → 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 (80) 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 +120 -109
  5. package/dist/formio.form.min.js +1 -1
  6. package/dist/formio.form.min.js.LICENSE.txt +3 -3
  7. package/dist/formio.full.js +121 -110
  8. package/dist/formio.full.min.js +1 -1
  9. package/dist/formio.full.min.js.LICENSE.txt +3 -3
  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 +55 -44
  14. package/dist/formio.utils.min.js +1 -1
  15. package/dist/formio.utils.min.js.LICENSE.txt +3 -3
  16. package/lib/cjs/Webform.d.ts +8 -1
  17. package/lib/cjs/Webform.js +40 -32
  18. package/lib/cjs/WebformBuilder.js +4 -12
  19. package/lib/cjs/Wizard.js +4 -11
  20. package/lib/cjs/components/Components.d.ts +0 -7
  21. package/lib/cjs/components/Components.js +1 -33
  22. package/lib/cjs/components/_classes/component/Component.d.ts +37 -7
  23. package/lib/cjs/components/_classes/component/Component.js +70 -26
  24. package/lib/cjs/components/_classes/componentModal/ComponentModal.d.ts +1 -0
  25. package/lib/cjs/components/_classes/componentModal/ComponentModal.js +1 -0
  26. package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +4 -19
  27. package/lib/cjs/components/_classes/nested/NestedComponent.js +38 -53
  28. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -1
  29. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +7 -44
  30. package/lib/cjs/components/datagrid/DataGrid.d.ts +0 -1
  31. package/lib/cjs/components/datagrid/DataGrid.js +1 -45
  32. package/lib/cjs/components/datamap/DataMap.js +1 -2
  33. package/lib/cjs/components/editgrid/EditGrid.js +6 -6
  34. package/lib/cjs/components/form/Form.d.ts +8 -3
  35. package/lib/cjs/components/form/Form.js +26 -25
  36. package/lib/cjs/components/selectboxes/SelectBoxes.js +0 -1
  37. package/lib/cjs/components/signature/Signature.d.ts +0 -1
  38. package/lib/cjs/components/signature/Signature.js +1 -1
  39. package/lib/cjs/utils/conditionOperators/DateGreaterThan.js +2 -2
  40. package/lib/cjs/utils/conditionOperators/IsEmptyValue.d.ts +2 -2
  41. package/lib/cjs/utils/conditionOperators/IsEmptyValue.js +2 -2
  42. package/lib/cjs/utils/conditionOperators/IsEqualTo.d.ts +2 -2
  43. package/lib/cjs/utils/conditionOperators/IsEqualTo.js +2 -2
  44. package/lib/cjs/utils/formUtils.d.ts +25 -14
  45. package/lib/cjs/utils/formUtils.js +11 -16
  46. package/lib/cjs/utils/utils.d.ts +1 -3
  47. package/lib/cjs/utils/utils.js +19 -35
  48. package/lib/mjs/Webform.d.ts +8 -1
  49. package/lib/mjs/Webform.js +37 -31
  50. package/lib/mjs/WebformBuilder.js +4 -12
  51. package/lib/mjs/Wizard.js +2 -8
  52. package/lib/mjs/components/Components.d.ts +0 -7
  53. package/lib/mjs/components/Components.js +1 -32
  54. package/lib/mjs/components/_classes/component/Component.d.ts +37 -7
  55. package/lib/mjs/components/_classes/component/Component.js +80 -27
  56. package/lib/mjs/components/_classes/componentModal/ComponentModal.d.ts +1 -0
  57. package/lib/mjs/components/_classes/componentModal/ComponentModal.js +1 -0
  58. package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +4 -19
  59. package/lib/mjs/components/_classes/nested/NestedComponent.js +39 -54
  60. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -1
  61. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +8 -43
  62. package/lib/mjs/components/datagrid/DataGrid.d.ts +0 -1
  63. package/lib/mjs/components/datagrid/DataGrid.js +1 -45
  64. package/lib/mjs/components/datamap/DataMap.js +1 -2
  65. package/lib/mjs/components/editgrid/EditGrid.js +9 -6
  66. package/lib/mjs/components/form/Form.d.ts +8 -3
  67. package/lib/mjs/components/form/Form.js +27 -25
  68. package/lib/mjs/components/selectboxes/SelectBoxes.js +0 -1
  69. package/lib/mjs/components/signature/Signature.d.ts +0 -1
  70. package/lib/mjs/components/signature/Signature.js +1 -1
  71. package/lib/mjs/utils/conditionOperators/DateGreaterThan.js +2 -2
  72. package/lib/mjs/utils/conditionOperators/IsEmptyValue.d.ts +2 -2
  73. package/lib/mjs/utils/conditionOperators/IsEmptyValue.js +2 -2
  74. package/lib/mjs/utils/conditionOperators/IsEqualTo.d.ts +2 -2
  75. package/lib/mjs/utils/conditionOperators/IsEqualTo.js +2 -2
  76. package/lib/mjs/utils/formUtils.d.ts +25 -14
  77. package/lib/mjs/utils/formUtils.js +2 -12
  78. package/lib/mjs/utils/utils.d.ts +1 -3
  79. package/lib/mjs/utils/utils.js +18 -33
  80. package/package.json +4 -4
@@ -18,9 +18,9 @@
18
18
  * MIT licensed
19
19
  */
20
20
 
21
- /*! @license DOMPurify 3.1.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.6/LICENSE */
21
+ /*! @license DOMPurify 3.2.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.3/LICENSE */
22
22
 
23
- /*! formiojs v5.0.0 | https://unpkg.com/formiojs@5.0.0/LICENSE.txt */
23
+ /*! formiojs v5.1.0-rc.1 | https://unpkg.com/formiojs@5.1.0-rc.1/LICENSE.txt */
24
24
 
25
25
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
26
26
 
@@ -43,4 +43,4 @@
43
43
 
44
44
  //! moment.js
45
45
 
46
- //! version : 0.5.45
46
+ //! version : 0.5.46
@@ -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>;
@@ -587,11 +587,12 @@ class Webform extends NestedDataComponent_1.default {
587
587
  * @returns {Promise} - The promise that is triggered when the form is set.
588
588
  */
589
589
  setForm(form, flags = {}) {
590
- var _a, _b, _c;
590
+ var _a;
591
591
  const isFormAlreadySet = this._form && ((_a = this._form.components) === null || _a === void 0 ? void 0 : _a.length);
592
592
  try {
593
593
  // Do not set the form again if it has been already set
594
594
  if (isFormAlreadySet && JSON.stringify(this._form) === JSON.stringify(form)) {
595
+ this.formReadyResolve();
595
596
  return Promise.resolve();
596
597
  }
597
598
  // Create the form.
@@ -599,13 +600,11 @@ class Webform extends NestedDataComponent_1.default {
599
600
  if (this.onSetForm) {
600
601
  this.onSetForm(lodash_1.default.cloneDeep(this._form), form);
601
602
  }
602
- if ((_c = (_b = this.parent) === null || _b === void 0 ? void 0 : _b.component) === null || _c === void 0 ? void 0 : _c.modalEdit) {
603
- return Promise.resolve();
604
- }
605
603
  }
606
604
  catch (err) {
607
605
  console.warn(err);
608
606
  // If provided form is not a valid JSON object, do not set it too
607
+ this.formReadyReject(err);
609
608
  return Promise.resolve();
610
609
  }
611
610
  // Allow the form to provide component overrides.
@@ -704,6 +703,18 @@ class Webform extends NestedDataComponent_1.default {
704
703
  set submission(submission) {
705
704
  this.setSubmission(submission);
706
705
  }
706
+ /**
707
+ * Sets the submission value
708
+ * @param {object|null|undefined} submission - The submission to set.
709
+ * @param {object|null|undefined} flags - Any flags to apply when setting the submission.
710
+ * @return {void}
711
+ */
712
+ onSetSubmission(submission, flags = {}) {
713
+ this.submissionSet = true;
714
+ this.triggerChange(flags);
715
+ this.emit('beforeSetSubmission', submission);
716
+ this.setValue(submission, flags);
717
+ }
707
718
  /**
708
719
  * Sets a submission and returns the promise when it is ready.
709
720
  * @param {any} submission - The submission to set.
@@ -717,10 +728,7 @@ class Webform extends NestedDataComponent_1.default {
717
728
  if (resolveFlags) {
718
729
  flags = Object.assign(Object.assign({}, flags), resolveFlags);
719
730
  }
720
- this.submissionSet = true;
721
- this.triggerChange(flags);
722
- this.emit("beforeSetSubmission", submission);
723
- this.setValue(submission, flags);
731
+ this.onSetSubmission(submission, flags);
724
732
  return this.submissionReadyResolve(submission);
725
733
  }, (err) => this.submissionReadyReject(err))
726
734
  .catch((err) => this.submissionReadyReject(err)));
@@ -839,6 +847,9 @@ class Webform extends NestedDataComponent_1.default {
839
847
  return changed;
840
848
  }
841
849
  getValue() {
850
+ if (!this._submission) {
851
+ this._submission = {};
852
+ }
842
853
  if (!this._submission.data) {
843
854
  this._submission.data = {};
844
855
  }
@@ -1098,29 +1109,24 @@ class Webform extends NestedDataComponent_1.default {
1098
1109
  return;
1099
1110
  }
1100
1111
  // Mark any components as invalid if in a custom message.
1112
+ const componentErrors = {};
1101
1113
  errors.forEach((err) => {
1102
- const { components = [] } = err;
1103
- if (err.component) {
1104
- components.push(err.component);
1105
- }
1106
- if (err.path) {
1107
- components.push(err.path);
1114
+ var _a, _b;
1115
+ const path = err.path || ((_a = err.context) === null || _a === void 0 ? void 0 : _a.path) || ((_b = err.component) === null || _b === void 0 ? void 0 : _b.key);
1116
+ if (!componentErrors[path]) {
1117
+ componentErrors[path] = [];
1108
1118
  }
1109
- components.forEach((path) => {
1110
- const originalPath = (0, utils_1.getStringFromComponentPath)(path);
1111
- const component = this.getComponent(path, lodash_1.default.identity, originalPath);
1112
- if (err.fromServer) {
1113
- if (component.serverErrors) {
1114
- component.serverErrors.push(err);
1115
- }
1116
- else {
1117
- component.serverErrors = [err];
1118
- }
1119
- }
1120
- const components = lodash_1.default.compact(Array.isArray(component) ? component : [component]);
1121
- components.forEach((component) => component.setCustomValidity(err.message, true));
1122
- });
1119
+ componentErrors[path].push(err);
1123
1120
  });
1121
+ // Iterate through all of our component errors and apply them to the components.
1122
+ for (let path in componentErrors) {
1123
+ const component = this.getComponent(path);
1124
+ const errors = componentErrors[path];
1125
+ if (component) {
1126
+ component.serverErrors = errors.filter((err) => err.fromServer);
1127
+ component.setCustomValidity(errors, true);
1128
+ }
1129
+ }
1124
1130
  const displayedErrors = [];
1125
1131
  if (errors.length) {
1126
1132
  errors = lodash_1.default.uniqBy(errors, (error) => { var _a, _b; return [error.message, (_a = error.component) === null || _a === void 0 ? void 0 : _a.id, (_b = error.context) === null || _b === void 0 ? void 0 : _b.path].join(); });
@@ -1312,7 +1318,7 @@ class Webform extends NestedDataComponent_1.default {
1312
1318
  onLine: navigator.onLine,
1313
1319
  });
1314
1320
  }
1315
- submitForm(options = {}) {
1321
+ submitForm(options = {}, local = false) {
1316
1322
  this.clearServerErrors();
1317
1323
  return new Promise((resolve, reject) => {
1318
1324
  // Read-only forms should never submit.
@@ -1338,6 +1344,7 @@ class Webform extends NestedDataComponent_1.default {
1338
1344
  return reject("Invalid Submission");
1339
1345
  }
1340
1346
  const errors = this.validate(submission.data, {
1347
+ local,
1341
1348
  dirty: true,
1342
1349
  silentCheck: false,
1343
1350
  process: "submit",
@@ -1352,12 +1359,13 @@ class Webform extends NestedDataComponent_1.default {
1352
1359
  console.error(err);
1353
1360
  }
1354
1361
  this.everyComponent((comp) => {
1362
+ var _a, _b;
1355
1363
  if (submission._vnote && comp.type === "form" && comp.component.reference) {
1356
- lodash_1.default.get(submission.data, comp.path, {})._vnote = submission._vnote;
1364
+ lodash_1.default.get(submission.data, local ? (_a = comp.paths) === null || _a === void 0 ? void 0 : _a.localDataPath : comp.path, {})._vnote = submission._vnote;
1357
1365
  }
1358
1366
  const { persistent } = comp.component;
1359
1367
  if (persistent === "client-only") {
1360
- lodash_1.default.unset(submission.data, comp.path);
1368
+ lodash_1.default.unset(submission.data, local ? (_b = comp.paths) === null || _b === void 0 ? void 0 : _b.localDataPath : comp.path);
1361
1369
  }
1362
1370
  });
1363
1371
  this.hook("customValidation", Object.assign(Object.assign({}, submission), { component: options.component }), (err) => {
@@ -1524,7 +1532,7 @@ class Webform extends NestedDataComponent_1.default {
1524
1532
  return;
1525
1533
  }
1526
1534
  const captchaComponent = [];
1527
- (0, formUtils_1.eachComponent)(this.components, (component) => {
1535
+ this.eachComponent((component) => {
1528
1536
  if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {
1529
1537
  captchaComponent.push(component);
1530
1538
  }
@@ -1124,20 +1124,12 @@ class WebformBuilder extends Component_1.default {
1124
1124
  findRepeatablePaths() {
1125
1125
  const repeatablePaths = [];
1126
1126
  const keys = new Map();
1127
- (0, formUtils_1.eachComponent)(this.form.components, (comp, path) => {
1128
- if (!comp.key) {
1129
- return;
1130
- }
1131
- if (keys.has(comp.key)) {
1132
- if (keys.get(comp.key).includes(path)) {
1133
- repeatablePaths.push(path);
1134
- }
1135
- else {
1136
- keys.set(comp.key, [...keys.get(comp.key), path]);
1137
- }
1127
+ (0, formUtils_1.eachComponent)(this.form.components, (comp, path, components, parent, paths) => {
1128
+ if (keys.has(paths.dataPath)) {
1129
+ repeatablePaths.push(paths.dataPath);
1138
1130
  }
1139
1131
  else {
1140
- keys.set(comp.key, [path]);
1132
+ keys.set(paths.dataPath, true);
1141
1133
  }
1142
1134
  }, true);
1143
1135
  return repeatablePaths;
package/lib/cjs/Wizard.js CHANGED
@@ -375,11 +375,11 @@ class Wizard extends Webform_1.default {
375
375
  this.emit('wizardPageSelected', this.pages[index], index);
376
376
  }
377
377
  attachHeader() {
378
- var _a;
378
+ var _a, _b;
379
379
  const isAllowPrevious = this.isAllowPrevious();
380
- this.attachTooltips(this.refs[`${this.wizardKey}-tooltip`], this.currentPanel.tooltip);
380
+ this.attachTooltips(this.refs[`${this.wizardKey}-tooltip`], (_a = this.currentPanel) === null || _a === void 0 ? void 0 : _a.tooltip);
381
381
  if (this.isBreadcrumbClickable() || isAllowPrevious) {
382
- (_a = this.refs[`${this.wizardKey}-link`]) === null || _a === void 0 ? void 0 : _a.forEach((link, index) => {
382
+ (_b = this.refs[`${this.wizardKey}-link`]) === null || _b === void 0 ? void 0 : _b.forEach((link, index) => {
383
383
  if (!isAllowPrevious || index <= this.enabledIndex) {
384
384
  this.addEventListener(link, 'click', (event) => {
385
385
  this.emit('wizardNavigationClicked', this.pages[index]);
@@ -728,7 +728,7 @@ class Wizard extends Webform_1.default {
728
728
  var _a, _b;
729
729
  const components = (_a = this.currentPage) === null || _a === void 0 ? void 0 : _a.components.map((component) => component.component);
730
730
  // Accessing the parent ensures the right instance (whether it's the parent Wizard or a nested Wizard) performs its validation
731
- return (_b = this.currentPage) === null || _b === void 0 ? void 0 : _b.parent.validateComponents(components, this.currentPage.parent.data, flags);
731
+ return (_b = this.currentPage) === null || _b === void 0 ? void 0 : _b.parent.validateComponents(components, this.root.data, flags);
732
732
  }
733
733
  emitPrevPage() {
734
734
  this.emit('prevPage', { page: this.page, submission: this.submission });
@@ -903,13 +903,6 @@ class Wizard extends Webform_1.default {
903
903
  this.redraw();
904
904
  }
905
905
  }
906
- redraw() {
907
- var _a, _b;
908
- if ((_b = (_a = this.parent) === null || _a === void 0 ? void 0 : _a.component) === null || _b === void 0 ? void 0 : _b.modalEdit) {
909
- return this.parent.redraw();
910
- }
911
- return super.redraw();
912
- }
913
906
  rebuild() {
914
907
  const currentPage = this.page;
915
908
  const setCurrentPage = () => this.setPage(currentPage);
@@ -256,13 +256,6 @@ export default class Components {
256
256
  static setComponents(comps: any): void;
257
257
  static addComponent(name: any, comp: any): void;
258
258
  static setComponent(name: any, comp: any): void;
259
- /**
260
- * Return a path of component's value.
261
- * @param {Component} component - The component instance.
262
- * @returns {string} - The component's value path.
263
- */
264
- static getComponentPath(component: Component): string;
265
259
  static create(component: any, options: any, data: any): any;
266
260
  }
267
261
  import BaseEditForm from './_classes/component/Component.form';
268
- import Component from './_classes/component/Component';
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const Component_1 = __importDefault(require("./_classes/component/Component"));
7
7
  const utils_1 = __importDefault(require("./_classes/component/editForm/utils"));
8
8
  const Component_form_1 = __importDefault(require("./_classes/component/Component.form"));
9
- const utils_2 = require("../utils/utils");
10
9
  const lodash_1 = __importDefault(require("lodash"));
11
10
  class Components {
12
11
  static set EditFormUtils(value) {
@@ -49,35 +48,6 @@ class Components {
49
48
  static setComponent(name, comp) {
50
49
  Components.components[name] = comp;
51
50
  }
52
- /**
53
- * Return a path of component's value.
54
- * @param {Component} component - The component instance.
55
- * @returns {string} - The component's value path.
56
- */
57
- static getComponentPath(component) {
58
- var _a;
59
- let path = '';
60
- const componentKey = (0, utils_2.getComponentKey)(component.component);
61
- if (componentKey) {
62
- let thisPath = ((_a = component.options) === null || _a === void 0 ? void 0 : _a.parent) || component;
63
- while (thisPath && !thisPath.allowData && thisPath.parent) {
64
- thisPath = thisPath.parent;
65
- }
66
- // TODO: any component that is nested in e.g. a Data Grid or an Edit Grid is going to receive a row prop; the problem
67
- // is that options.row is passed to each further nested component, which results in erroneous paths like
68
- // `editGrid[0].container[0].textField` rather than `editGrid[0].container.textField`. This should be adapted for other
69
- // components with a tree-like data model
70
- const rowIndex = component.row;
71
- const rowIndexPath = rowIndex && !['container'].includes(thisPath.component.type) ? `[${Number.parseInt(rowIndex)}]` : '';
72
- path = `${thisPath.path}${rowIndexPath}.`;
73
- if (rowIndexPath && (0, utils_2.getModelType)(thisPath) === 'nestedDataArray') {
74
- path = `${path}data.`;
75
- }
76
- path += componentKey;
77
- return lodash_1.default.trim(path, '.');
78
- }
79
- return path;
80
- }
81
51
  static create(component, options, data) {
82
52
  let comp = null;
83
53
  if (component.type && Components.components.hasOwnProperty(component.type)) {
@@ -102,9 +72,7 @@ class Components {
102
72
  else {
103
73
  comp = new Component_1.default(component, options, data);
104
74
  }
105
- const path = Components.getComponentPath(comp);
106
- if (path) {
107
- comp.path = path;
75
+ if (comp.path) {
108
76
  comp.componentsMap[comp.path] = comp;
109
77
  }
110
78
  return comp;
@@ -42,14 +42,13 @@ declare class Component extends Element {
42
42
  */
43
43
  private _hasCondition;
44
44
  /**
45
- * References to dom elements
45
+ * The row index for this component.
46
46
  */
47
- refs: {};
47
+ _rowIndex: number | undefined;
48
48
  /**
49
- * The data path to this specific component instance.
50
- * @type {string}
49
+ * References to dom elements
51
50
  */
52
- path: string;
51
+ refs: {};
53
52
  /**
54
53
  * An array of all the children components errors.
55
54
  */
@@ -114,6 +113,11 @@ declare class Component extends Element {
114
113
  * @type {Component}
115
114
  */
116
115
  parent: Component;
116
+ /**
117
+ * The component paths for this component.
118
+ * @type {import('@formio/core').ComponentPaths} - The component paths.
119
+ */
120
+ paths: import('@formio/core').ComponentPaths;
117
121
  _path: string;
118
122
  /**
119
123
  * Determines if this component is visible, or not.
@@ -158,7 +162,7 @@ declare class Component extends Element {
158
162
  * @type {*}
159
163
  */
160
164
  info: any;
161
- get componentsMap(): any;
165
+ get componentsMap(): object;
162
166
  set data(value: any);
163
167
  get data(): any;
164
168
  mergeSchema(component?: {}): any;
@@ -182,6 +186,17 @@ declare class Component extends Element {
182
186
  * @returns {boolean} - TRUE if the component is disabled.
183
187
  */
184
188
  get disabled(): boolean;
189
+ /**
190
+ * Set Row Index to row and update each component.
191
+ * @param {number} value - The row index.
192
+ * @returns {void}
193
+ */
194
+ set rowIndex(value: number);
195
+ /**
196
+ * Get Row Index.
197
+ * @returns {number} - The row index.
198
+ */
199
+ get rowIndex(): number;
185
200
  afterComponentAssign(): void;
186
201
  createAddon(addonConfiguration: any): any;
187
202
  get shouldDisabled(): any;
@@ -190,6 +205,8 @@ declare class Component extends Element {
190
205
  get hasInput(): any;
191
206
  get defaultSchema(): any;
192
207
  get key(): any;
208
+ set path(path: string | undefined);
209
+ get path(): string | undefined;
193
210
  set parentVisible(value: any);
194
211
  get parentVisible(): any;
195
212
  set parentDisabled(value: boolean);
@@ -212,7 +229,7 @@ declare class Component extends Element {
212
229
  _currentForm: any;
213
230
  get fullMode(): boolean;
214
231
  get builderMode(): boolean;
215
- get calculatedPath(): string;
232
+ get calculatedPath(): string | undefined;
216
233
  get labelPosition(): any;
217
234
  get labelWidth(): any;
218
235
  get labelMargin(): any;
@@ -343,6 +360,12 @@ declare class Component extends Element {
343
360
  * @param {string} template - The template to use for the modal dialog.
344
361
  */
345
362
  setOpenModalElement(template?: string): void;
363
+ /**
364
+ * Renders a modal preview template and returns the markup as a string
365
+ * @param {object|null|undefined} ctx - The rendering context
366
+ * @return {string} - The modal preview markup
367
+ */
368
+ renderModalPreview(ctx: object | null | undefined): string;
346
369
  /**
347
370
  * Returns the modal preview template.
348
371
  * @returns {string} - The modal preview template.
@@ -362,6 +385,13 @@ declare class Component extends Element {
362
385
  * @returns {string} - The rendered HTML string of a component.
363
386
  */
364
387
  render(children?: string, topLevel?: boolean): string;
388
+ /**
389
+ * Creates the tooltip instance using tippy.js and returns it
390
+ * @param {HTMLElement} tooltipEl - HTML element to attach the tooltip
391
+ * @param {object|null|undefined} settings - tippy.js options
392
+ * @return {import('tippy.js').Tippy} - tippy.js instance
393
+ */
394
+ createTooltip(tooltipEl: HTMLElement, settings?: object | null | undefined): import('tippy.js').Tippy;
365
395
  /**
366
396
  * Attaches all the tooltips provided the refs object.
367
397
  * @param {object} toolTipsRefs - The refs for the tooltips within your template.
@@ -234,6 +234,7 @@ class Component extends Element_1.default {
234
234
  */
235
235
  /* eslint-disable max-statements */
236
236
  constructor(component, options, data) {
237
+ var _a, _b, _c, _d;
237
238
  super(Object.assign({
238
239
  renderMode: 'form',
239
240
  attachMode: 'full',
@@ -249,6 +250,10 @@ class Component extends Element_1.default {
249
250
  * @private
250
251
  */
251
252
  this._hasCondition = null;
253
+ /**
254
+ * The row index for this component.
255
+ */
256
+ this._rowIndex = undefined;
252
257
  /**
253
258
  * References to dom elements
254
259
  */
@@ -259,11 +264,6 @@ class Component extends Element_1.default {
259
264
  this.options.components[component.type]) {
260
265
  lodash_1.default.merge(component, this.options.components[component.type]);
261
266
  }
262
- /**
263
- * The data path to this specific component instance.
264
- * @type {string}
265
- */
266
- this.path = (component === null || component === void 0 ? void 0 : component.key) || '';
267
267
  /**
268
268
  * An array of all the children components errors.
269
269
  */
@@ -332,6 +332,11 @@ class Component extends Element_1.default {
332
332
  * @type {Component}
333
333
  */
334
334
  this.parent = this.options.parent;
335
+ /**
336
+ * The component paths for this component.
337
+ * @type {import('@formio/core').ComponentPaths} - The component paths.
338
+ */
339
+ this.paths = FormioUtils.getComponentPaths(this.component, (_a = this.parent) === null || _a === void 0 ? void 0 : _a.component, Object.assign(Object.assign({}, (_b = this.parent) === null || _b === void 0 ? void 0 : _b.paths), { dataIndex: this.options.rowIndex === undefined ? (_d = (_c = this.parent) === null || _c === void 0 ? void 0 : _c.paths) === null || _d === void 0 ? void 0 : _d.dataIndex : this.options.rowIndex }));
335
340
  this.options.name = this.options.name || 'data';
336
341
  this._path = '';
337
342
  // Needs for Nextgen Rules Engine
@@ -438,12 +443,7 @@ class Component extends Element_1.default {
438
443
  /* eslint-enable max-statements */
439
444
  get componentsMap() {
440
445
  var _a;
441
- if ((_a = this.localRoot) === null || _a === void 0 ? void 0 : _a.childComponentsMap) {
442
- return this.localRoot.childComponentsMap;
443
- }
444
- const localMap = {};
445
- localMap[this.path] = this;
446
- return localMap;
446
+ return ((_a = this.root) === null || _a === void 0 ? void 0 : _a.childComponentsMap) || {};
447
447
  }
448
448
  get data() {
449
449
  return this._data;
@@ -490,6 +490,23 @@ class Component extends Element_1.default {
490
490
  this.component.addons.forEach((addon) => this.createAddon(addon));
491
491
  }
492
492
  }
493
+ /**
494
+ * Get Row Index.
495
+ * @returns {number} - The row index.
496
+ */
497
+ get rowIndex() {
498
+ return this._rowIndex;
499
+ }
500
+ /**
501
+ * Set Row Index to row and update each component.
502
+ * @param {number} value - The row index.
503
+ * @returns {void}
504
+ */
505
+ set rowIndex(value) {
506
+ var _a, _b;
507
+ this.paths = FormioUtils.getComponentPaths(this.component, (_a = this.parent) === null || _a === void 0 ? void 0 : _a.component, Object.assign(Object.assign({}, (((_b = this.parent) === null || _b === void 0 ? void 0 : _b.paths) || {})), { dataIndex: value }));
508
+ this._rowIndex = value;
509
+ }
493
510
  afterComponentAssign() {
494
511
  //implement in extended classes
495
512
  }
@@ -559,6 +576,12 @@ class Component extends Element_1.default {
559
576
  get key() {
560
577
  return lodash_1.default.get(this.component, 'key', '');
561
578
  }
579
+ get path() {
580
+ return this.paths.dataPath;
581
+ }
582
+ set path(path) {
583
+ throw new Error('Should not be setting the path of a component.');
584
+ }
562
585
  set parentVisible(value) {
563
586
  this._parentVisible = value;
564
587
  }
@@ -1046,6 +1069,14 @@ class Component extends Element_1.default {
1046
1069
  setOpenModalElement(template = null) {
1047
1070
  this.componentModal.setOpenModalElement(template || this.getModalPreviewTemplate());
1048
1071
  }
1072
+ /**
1073
+ * Renders a modal preview template and returns the markup as a string
1074
+ * @param {object|null|undefined} ctx - The rendering context
1075
+ * @return {string} - The modal preview markup
1076
+ */
1077
+ renderModalPreview(ctx) {
1078
+ return this.renderTemplate('modalPreview', ctx || {});
1079
+ }
1049
1080
  /**
1050
1081
  * Returns the modal preview template.
1051
1082
  * @returns {string} - The modal preview template.
@@ -1057,7 +1088,7 @@ class Component extends Element_1.default {
1057
1088
  if (this.hasInput && ((_a = this.component.validate) === null || _a === void 0 ? void 0 : _a.required) && !this.isPDFReadOnlyMode) {
1058
1089
  modalLabel = { className: 'field-required' };
1059
1090
  }
1060
- return this.renderTemplate('modalPreview', {
1091
+ return this.renderModalPreview({
1061
1092
  previewText: this.getValueAsString(dataValue, { modalPreview: true }) || this.t('Click to set value'),
1062
1093
  messages: '',
1063
1094
  labelInfo: modalLabel,
@@ -1106,6 +1137,19 @@ class Component extends Element_1.default {
1106
1137
  }, topLevel);
1107
1138
  }
1108
1139
  }
1140
+ /**
1141
+ * Creates the tooltip instance using tippy.js and returns it
1142
+ * @param {HTMLElement} tooltipEl - HTML element to attach the tooltip
1143
+ * @param {object|null|undefined} settings - tippy.js options
1144
+ * @return {import('tippy.js').Tippy} - tippy.js instance
1145
+ */
1146
+ createTooltip(tooltipEl, settings = {}) {
1147
+ const tooltipAttribute = tooltipEl.getAttribute('data-tooltip');
1148
+ const tooltipDataTitle = tooltipEl.getAttribute('data-title');
1149
+ const tooltipText = this.interpolate(tooltipDataTitle || tooltipAttribute)
1150
+ .replace(/(?:\r\n|\r|\n)/g, '<br />');
1151
+ return (0, tippy_js_1.default)(tooltipEl, Object.assign(Object.assign({ allowHTML: true, trigger: 'mouseenter click focus', placement: 'right', zIndex: 10000, interactive: true }, settings), { content: this.t(this.sanitize(tooltipText), { _userInput: true }) }));
1152
+ }
1109
1153
  /**
1110
1154
  * Attaches all the tooltips provided the refs object.
1111
1155
  * @param {object} toolTipsRefs - The refs for the tooltips within your template.
@@ -1114,18 +1158,7 @@ class Component extends Element_1.default {
1114
1158
  attachTooltips(toolTipsRefs) {
1115
1159
  toolTipsRefs === null || toolTipsRefs === void 0 ? void 0 : toolTipsRefs.forEach((tooltip, index) => {
1116
1160
  if (tooltip) {
1117
- const tooltipAttribute = tooltip.getAttribute('data-tooltip');
1118
- const tooltipDataTitle = tooltip.getAttribute('data-title');
1119
- const tooltipText = this.interpolate(tooltipDataTitle || tooltipAttribute)
1120
- .replace(/(?:\r\n|\r|\n)/g, '<br />');
1121
- this.tooltips[index] = (0, tippy_js_1.default)(tooltip, {
1122
- allowHTML: true,
1123
- trigger: 'mouseenter click focus',
1124
- placement: 'right',
1125
- zIndex: 10000,
1126
- interactive: true,
1127
- content: this.t(this.sanitize(tooltipText), { _userInput: true }),
1128
- });
1161
+ this.tooltips[index] = this.createTooltip(tooltip);
1129
1162
  }
1130
1163
  });
1131
1164
  }
@@ -1255,6 +1288,7 @@ class Component extends Element_1.default {
1255
1288
  * @returns {void}
1256
1289
  */
1257
1290
  checkRefresh(refreshData, changed, flags) {
1291
+ var _a, _b;
1258
1292
  const changePath = lodash_1.default.get(changed, 'instance.path', false);
1259
1293
  // Don't let components change themselves.
1260
1294
  if (changePath && this.path === changePath) {
@@ -1263,7 +1297,7 @@ class Component extends Element_1.default {
1263
1297
  if (refreshData === 'data') {
1264
1298
  this.refresh(this.data, changed, flags);
1265
1299
  }
1266
- else if ((changePath && (0, utils_1.getComponentPath)(changed.instance) === refreshData) && changed && changed.instance &&
1300
+ else if ((changePath && (((_b = (_a = changed.instance) === null || _a === void 0 ? void 0 : _a.paths) === null || _b === void 0 ? void 0 : _b.localPath) === refreshData)) && changed && changed.instance &&
1267
1301
  // Make sure the changed component is not in a different "context". Solves issues where refreshOn being set
1268
1302
  // in fields inside EditGrids could alter their state from other rows (which is bad).
1269
1303
  this.inContext(changed.instance)) {
@@ -2864,6 +2898,10 @@ class Component extends Element_1.default {
2864
2898
  * @returns {string} - The message to show when the component is invalid.
2865
2899
  */
2866
2900
  invalidMessage(data, dirty, ignoreCondition, row) {
2901
+ var _a;
2902
+ if (!row) {
2903
+ row = (0, utils_1.getContextualRowData)(this.component, data, this.paths);
2904
+ }
2867
2905
  if (!ignoreCondition && !this.checkCondition(row, data)) {
2868
2906
  return '';
2869
2907
  }
@@ -2881,6 +2919,8 @@ class Component extends Element_1.default {
2881
2919
  data,
2882
2920
  row,
2883
2921
  path: this.path || this.component.key,
2922
+ parent: (_a = this.parent) === null || _a === void 0 ? void 0 : _a.component,
2923
+ paths: this.paths,
2884
2924
  scope: validationScope,
2885
2925
  instance: this,
2886
2926
  processors: [
@@ -2934,7 +2974,7 @@ class Component extends Element_1.default {
2934
2974
  if (flags.silentCheck) {
2935
2975
  return [];
2936
2976
  }
2937
- let isDirty = this.dirty || flags.dirty;
2977
+ let isDirty = (flags.dirty === false) ? false : (this.dirty || flags.dirty);
2938
2978
  if (this.options.alwaysDirty) {
2939
2979
  isDirty = true;
2940
2980
  }
@@ -2949,6 +2989,7 @@ class Component extends Element_1.default {
2949
2989
  * @returns {Array<any>} - An array of errors if the component is invalid.
2950
2990
  */
2951
2991
  validateComponent(data = null, row = null, flags = {}) {
2992
+ var _a;
2952
2993
  data = data || this.rootValue;
2953
2994
  row = row || this.data;
2954
2995
  const { async = false } = flags;
@@ -2959,7 +3000,10 @@ class Component extends Element_1.default {
2959
3000
  component: this.component,
2960
3001
  data,
2961
3002
  row,
3003
+ local: !!flags.local,
2962
3004
  value: this.validationValue,
3005
+ parent: (_a = this.parent) === null || _a === void 0 ? void 0 : _a.component,
3006
+ paths: this.paths,
2963
3007
  path: this.path || this.component.key,
2964
3008
  instance: this,
2965
3009
  form: this.root ? this.root._form : {},
@@ -22,6 +22,7 @@ export default class ComponentModal {
22
22
  modalOverlay: string;
23
23
  modalContents: string;
24
24
  modalClose: string;
25
+ componentContent: string;
25
26
  openModalWrapper: string;
26
27
  openModal: string;
27
28
  modalSave: string;
@@ -64,6 +64,7 @@ class ComponentModal {
64
64
  modalOverlay: 'single',
65
65
  modalContents: 'single',
66
66
  modalClose: 'single',
67
+ componentContent: 'single',
67
68
  openModalWrapper: 'single',
68
69
  openModal: 'single',
69
70
  modalSave: 'single',