@formio/js 5.1.0-dev.5972.f3a71a8 → 5.1.0-dev.5972.fc33c16

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.
@@ -1296,7 +1296,7 @@ class Component extends Element_1.default {
1296
1296
  detach() {
1297
1297
  // First iterate through each ref and delete the component so there are no dangling component references.
1298
1298
  lodash_1.default.each(this.refs, (ref) => {
1299
- if ((window === null || window === void 0 ? void 0 : window.NodeList) && typeof ref === NodeList) {
1299
+ if ((window === null || window === void 0 ? void 0 : window.NodeList) && ref instanceof NodeList) {
1300
1300
  ref.forEach((elem) => {
1301
1301
  delete elem.component;
1302
1302
  });
@@ -411,7 +411,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
411
411
  row
412
412
  });
413
413
  this.checkConditions();
414
- this.triggerChange();
414
+ this.triggerChange({ modified: true });
415
415
  this.redraw().then(() => {
416
416
  this.focusOnNewRowElement(this.rows[index]);
417
417
  });
@@ -491,6 +491,9 @@ class DataGridComponent extends NestedArrayComponent_1.default {
491
491
  options.name += `[${rowIndex}]`;
492
492
  options.row = `${rowIndex}-${colIndex}`;
493
493
  options.rowIndex = rowIndex;
494
+ options.onChange = (flags, changed, modified) => {
495
+ this.triggerChange({ modified });
496
+ };
494
497
  let columnComponent;
495
498
  if (this.builderMode) {
496
499
  col.id = col.id + rowIndex;
@@ -32,6 +32,7 @@ export default class FormComponent extends Component {
32
32
  attach(element: any): Promise<void>;
33
33
  get hasLoadedForm(): any;
34
34
  get isRevisionChanged(): any;
35
+ get subFormData(): any;
35
36
  subFormReady: Promise<any> | null | undefined;
36
37
  /**
37
38
  * Pass everyComponent to subform.
@@ -332,6 +332,10 @@ class FormComponent extends Component_1.default {
332
332
  && lodash_1.default.isNumber(this.formObj._vid)
333
333
  && this.formObj._vid !== this.subFormRevision;
334
334
  }
335
+ get subFormData() {
336
+ var _a;
337
+ return ((_a = this.dataValue) === null || _a === void 0 ? void 0 : _a.data) || {};
338
+ }
335
339
  destroy(all = false) {
336
340
  if (this.subForm) {
337
341
  this.subForm.destroy(all);
@@ -482,14 +486,14 @@ class FormComponent extends Component_1.default {
482
486
  return visible;
483
487
  }
484
488
  if (this.subForm) {
485
- return this.subForm.checkConditions(data, flags, row);
489
+ return this.subForm.checkConditions(this.subFormData, flags);
486
490
  }
487
491
  // There are few cases when subForm is not loaded when a change is triggered,
488
492
  // so we need to perform checkConditions after it is ready, or some conditional fields might be hidden in View mode
489
493
  else if (this.subFormReady) {
490
494
  this.subFormReady.then(() => {
491
495
  if (this.subForm) {
492
- return this.subForm.checkConditions(data, flags, row);
496
+ return this.subForm.checkConditions(this.subFormData, flags);
493
497
  }
494
498
  });
495
499
  }
@@ -497,7 +501,7 @@ class FormComponent extends Component_1.default {
497
501
  }
498
502
  calculateValue(data, flags, row) {
499
503
  if (this.subForm) {
500
- return this.subForm.calculateValue(data, flags, row);
504
+ return this.subForm.calculateValue(this.subFormData, flags);
501
505
  }
502
506
  return super.calculateValue(data, flags, row);
503
507
  }
@@ -1264,7 +1264,7 @@ export default class Component extends Element {
1264
1264
  detach() {
1265
1265
  // First iterate through each ref and delete the component so there are no dangling component references.
1266
1266
  _.each(this.refs, (ref) => {
1267
- if (window?.NodeList && typeof ref === NodeList) {
1267
+ if (window?.NodeList && ref instanceof NodeList) {
1268
1268
  ref.forEach((elem) => {
1269
1269
  delete elem.component;
1270
1270
  });
@@ -408,7 +408,7 @@ export default class DataGridComponent extends NestedArrayComponent {
408
408
  row
409
409
  });
410
410
  this.checkConditions();
411
- this.triggerChange();
411
+ this.triggerChange({ modified: true });
412
412
  this.redraw().then(() => {
413
413
  this.focusOnNewRowElement(this.rows[index]);
414
414
  });
@@ -487,6 +487,9 @@ export default class DataGridComponent extends NestedArrayComponent {
487
487
  options.name += `[${rowIndex}]`;
488
488
  options.row = `${rowIndex}-${colIndex}`;
489
489
  options.rowIndex = rowIndex;
490
+ options.onChange = (flags, changed, modified) => {
491
+ this.triggerChange({ modified });
492
+ };
490
493
  let columnComponent;
491
494
  if (this.builderMode) {
492
495
  col.id = col.id + rowIndex;
@@ -32,6 +32,7 @@ export default class FormComponent extends Component {
32
32
  attach(element: any): Promise<void>;
33
33
  get hasLoadedForm(): any;
34
34
  get isRevisionChanged(): any;
35
+ get subFormData(): any;
35
36
  subFormReady: Promise<any> | null | undefined;
36
37
  /**
37
38
  * Pass everyComponent to subform.
@@ -329,6 +329,9 @@ export default class FormComponent extends Component {
329
329
  && _.isNumber(this.formObj._vid)
330
330
  && this.formObj._vid !== this.subFormRevision;
331
331
  }
332
+ get subFormData() {
333
+ return this.dataValue?.data || {};
334
+ }
332
335
  destroy(all = false) {
333
336
  if (this.subForm) {
334
337
  this.subForm.destroy(all);
@@ -477,14 +480,14 @@ export default class FormComponent extends Component {
477
480
  return visible;
478
481
  }
479
482
  if (this.subForm) {
480
- return this.subForm.checkConditions(data, flags, row);
483
+ return this.subForm.checkConditions(this.subFormData, flags);
481
484
  }
482
485
  // There are few cases when subForm is not loaded when a change is triggered,
483
486
  // so we need to perform checkConditions after it is ready, or some conditional fields might be hidden in View mode
484
487
  else if (this.subFormReady) {
485
488
  this.subFormReady.then(() => {
486
489
  if (this.subForm) {
487
- return this.subForm.checkConditions(data, flags, row);
490
+ return this.subForm.checkConditions(this.subFormData, flags);
488
491
  }
489
492
  });
490
493
  }
@@ -492,7 +495,7 @@ export default class FormComponent extends Component {
492
495
  }
493
496
  calculateValue(data, flags, row) {
494
497
  if (this.subForm) {
495
- return this.subForm.calculateValue(data, flags, row);
498
+ return this.subForm.calculateValue(this.subFormData, flags);
496
499
  }
497
500
  return super.calculateValue(data, flags, row);
498
501
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.1.0-dev.5972.f3a71a8",
3
+ "version": "5.1.0-dev.5972.fc33c16",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {