@formio/js 5.0.0-dev.5695.024ad9c → 5.0.0-dev.5703.20a26ed

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 +11 -0
  2. package/dist/formio.builder.css +0 -1
  3. package/dist/formio.builder.min.css +1 -1
  4. package/dist/formio.embed.js +1 -1
  5. package/dist/formio.embed.min.js +1 -1
  6. package/dist/formio.form.css +0 -1
  7. package/dist/formio.form.js +64 -120
  8. package/dist/formio.form.min.css +1 -1
  9. package/dist/formio.form.min.js +1 -1
  10. package/dist/formio.full.css +0 -1
  11. package/dist/formio.full.js +45 -25
  12. package/dist/formio.full.min.css +1 -1
  13. package/dist/formio.full.min.js +1 -1
  14. package/dist/formio.js +2 -2
  15. package/dist/formio.min.js +1 -1
  16. package/dist/formio.utils.js +57 -17
  17. package/dist/formio.utils.min.js +1 -1
  18. package/lib/cjs/CDN.d.ts +1 -0
  19. package/lib/cjs/CDN.js +1 -0
  20. package/lib/cjs/Webform.js +4 -2
  21. package/lib/cjs/components/_classes/component/Component.d.ts +1 -0
  22. package/lib/cjs/components/_classes/component/Component.js +18 -0
  23. package/lib/cjs/components/checkbox/Checkbox.d.ts +1 -1
  24. package/lib/cjs/components/checkbox/Checkbox.js +1 -1
  25. package/lib/cjs/components/checkbox/fixtures/comp6.d.ts +32 -0
  26. package/lib/cjs/components/checkbox/fixtures/comp6.js +30 -0
  27. package/lib/cjs/components/checkbox/fixtures/index.d.ts +2 -1
  28. package/lib/cjs/components/checkbox/fixtures/index.js +3 -1
  29. package/lib/cjs/components/datagrid/DataGrid.d.ts +2 -0
  30. package/lib/cjs/components/datagrid/DataGrid.js +38 -26
  31. package/lib/cjs/components/datagrid/fixtures/comp10.d.ts +81 -0
  32. package/lib/cjs/components/datagrid/fixtures/comp10.js +87 -0
  33. package/lib/cjs/components/datagrid/fixtures/index.d.ts +2 -1
  34. package/lib/cjs/components/datagrid/fixtures/index.js +3 -1
  35. package/lib/cjs/components/datamap/DataMap.js +2 -2
  36. package/lib/cjs/components/day/fixtures/comp8.d.ts +41 -0
  37. package/lib/cjs/components/day/fixtures/comp8.js +40 -0
  38. package/lib/cjs/components/day/fixtures/index.d.ts +2 -1
  39. package/lib/cjs/components/day/fixtures/index.js +3 -1
  40. package/lib/cjs/components/editgrid/EditGrid.js +12 -1
  41. package/lib/cjs/components/editgrid/fixtures/comp-test-events.d.ts +54 -0
  42. package/lib/cjs/components/editgrid/fixtures/comp-test-events.js +54 -0
  43. package/lib/cjs/components/editgrid/fixtures/comp16.d.ts +52 -0
  44. package/lib/cjs/components/editgrid/fixtures/comp16.js +71 -0
  45. package/lib/cjs/components/editgrid/fixtures/index.d.ts +3 -1
  46. package/lib/cjs/components/editgrid/fixtures/index.js +5 -1
  47. package/lib/cjs/translations/en.d.ts +3 -0
  48. package/lib/cjs/translations/en.js +4 -1
  49. package/lib/cjs/utils/conditionOperators/IsEmptyValue.js +4 -3
  50. package/lib/cjs/utils/conditionOperators/IsEqualTo.js +3 -3
  51. package/lib/cjs/utils/utils.d.ts +1 -10
  52. package/lib/cjs/utils/utils.js +59 -7
  53. package/lib/mjs/CDN.d.ts +1 -0
  54. package/lib/mjs/CDN.js +1 -0
  55. package/lib/mjs/Webform.js +4 -2
  56. package/lib/mjs/components/_classes/component/Component.d.ts +1 -0
  57. package/lib/mjs/components/_classes/component/Component.js +7 -0
  58. package/lib/mjs/components/checkbox/Checkbox.d.ts +1 -1
  59. package/lib/mjs/components/checkbox/Checkbox.js +1 -1
  60. package/lib/mjs/components/checkbox/fixtures/comp6.d.ts +32 -0
  61. package/lib/mjs/components/checkbox/fixtures/comp6.js +28 -0
  62. package/lib/mjs/components/checkbox/fixtures/index.d.ts +2 -1
  63. package/lib/mjs/components/checkbox/fixtures/index.js +2 -1
  64. package/lib/mjs/components/datagrid/DataGrid.d.ts +2 -0
  65. package/lib/mjs/components/datagrid/DataGrid.js +37 -25
  66. package/lib/mjs/components/datagrid/fixtures/comp10.d.ts +81 -0
  67. package/lib/mjs/components/datagrid/fixtures/comp10.js +85 -0
  68. package/lib/mjs/components/datagrid/fixtures/index.d.ts +2 -1
  69. package/lib/mjs/components/datagrid/fixtures/index.js +2 -1
  70. package/lib/mjs/components/datamap/DataMap.js +1 -1
  71. package/lib/mjs/components/day/fixtures/comp8.d.ts +41 -0
  72. package/lib/mjs/components/day/fixtures/comp8.js +38 -0
  73. package/lib/mjs/components/day/fixtures/index.d.ts +2 -1
  74. package/lib/mjs/components/day/fixtures/index.js +2 -1
  75. package/lib/mjs/components/editgrid/EditGrid.js +12 -1
  76. package/lib/mjs/components/editgrid/fixtures/comp-test-events.d.ts +54 -0
  77. package/lib/mjs/components/editgrid/fixtures/comp-test-events.js +52 -0
  78. package/lib/mjs/components/editgrid/fixtures/comp16.d.ts +52 -0
  79. package/lib/mjs/components/editgrid/fixtures/comp16.js +69 -0
  80. package/lib/mjs/components/editgrid/fixtures/index.d.ts +3 -1
  81. package/lib/mjs/components/editgrid/fixtures/index.js +3 -1
  82. package/lib/mjs/translations/en.d.ts +3 -0
  83. package/lib/mjs/translations/en.js +4 -1
  84. package/lib/mjs/utils/conditionOperators/IsEmptyValue.js +3 -3
  85. package/lib/mjs/utils/conditionOperators/IsEqualTo.js +1 -1
  86. package/lib/mjs/utils/utils.d.ts +1 -10
  87. package/lib/mjs/utils/utils.js +58 -7
  88. package/package.json +2 -2
@@ -681,6 +681,11 @@ class EditGridComponent extends NestedArrayComponent_1.default {
681
681
  }
682
682
  },
683
683
  }, this.component.saveRow || 'Save'));
684
+ this.emit('editGridOpenModal', {
685
+ component: this.component,
686
+ row: editRow,
687
+ instance: this,
688
+ });
684
689
  return this.attachComponents(modalContent, components);
685
690
  }
686
691
  showDialog(rowIndex) {
@@ -738,6 +743,11 @@ class EditGridComponent extends NestedArrayComponent_1.default {
738
743
  editRow.data = dataSnapshot;
739
744
  this.restoreRowContext(editRow);
740
745
  }
746
+ this.emit('editGridEditRow', {
747
+ component: this.component,
748
+ row: editRow,
749
+ instance: this,
750
+ });
741
751
  if (this.component.modal) {
742
752
  return this.addRowModal(rowIndex);
743
753
  }
@@ -1091,7 +1101,8 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1091
1101
  return false;
1092
1102
  }
1093
1103
  else if (rowsEditing && this.saveEditMode && !this.component.openWhenEmpty) {
1094
- this.setCustomValidity(this.t(this.errorMessage('unsavedRowsError')), dirty);
1104
+ this._errors = this.setCustomValidity(this.t(this.errorMessage('unsavedRowsError')), dirty);
1105
+ errors.push(...this._errors);
1095
1106
  return false;
1096
1107
  }
1097
1108
  const message = this.invalid || this.invalidMessage(data, dirty, false, row);
@@ -0,0 +1,54 @@
1
+ declare namespace _default {
2
+ let _id: string;
3
+ let title: string;
4
+ let name: string;
5
+ let path: string;
6
+ let type: string;
7
+ let display: string;
8
+ let owner: string;
9
+ let components: ({
10
+ label: string;
11
+ tableView: boolean;
12
+ modal: boolean;
13
+ validateWhenHidden: boolean;
14
+ rowDrafts: boolean;
15
+ key: string;
16
+ type: string;
17
+ displayAsTable: boolean;
18
+ input: boolean;
19
+ components: {
20
+ label: string;
21
+ applyMaskOn: string;
22
+ tableView: boolean;
23
+ validateWhenHidden: boolean;
24
+ key: string;
25
+ type: string;
26
+ input: boolean;
27
+ }[];
28
+ disableOnInvalid?: undefined;
29
+ } | {
30
+ type: string;
31
+ label: string;
32
+ key: string;
33
+ disableOnInvalid: boolean;
34
+ input: boolean;
35
+ tableView: boolean;
36
+ modal?: undefined;
37
+ validateWhenHidden?: undefined;
38
+ rowDrafts?: undefined;
39
+ displayAsTable?: undefined;
40
+ components?: undefined;
41
+ })[];
42
+ let pdfComponents: never[];
43
+ let settings: {};
44
+ let properties: {};
45
+ let project: string;
46
+ let controller: string;
47
+ let revisions: string;
48
+ let submissionRevisions: string;
49
+ let _vid: number;
50
+ let created: string;
51
+ let modified: string;
52
+ let machineName: string;
53
+ }
54
+ export default _default;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ _id: '669e1c88a40e327e67e7d1c5',
5
+ title: 'editGrid test',
6
+ name: 'editGridTest',
7
+ path: 'editgridtest',
8
+ type: 'form',
9
+ display: 'form',
10
+ owner: '637b2e6b48c1227e60b1f910',
11
+ components: [
12
+ {
13
+ label: 'Edit Grid',
14
+ tableView: false,
15
+ modal: false,
16
+ validateWhenHidden: false,
17
+ rowDrafts: false,
18
+ key: 'editGrid',
19
+ type: 'editgrid',
20
+ displayAsTable: false,
21
+ input: true,
22
+ components: [
23
+ {
24
+ label: 'Text Field',
25
+ applyMaskOn: 'change',
26
+ tableView: true,
27
+ validateWhenHidden: false,
28
+ key: 'textField',
29
+ type: 'textfield',
30
+ input: true,
31
+ },
32
+ ],
33
+ },
34
+ {
35
+ type: 'button',
36
+ label: 'Submit',
37
+ key: 'submit',
38
+ disableOnInvalid: true,
39
+ input: true,
40
+ tableView: false,
41
+ },
42
+ ],
43
+ pdfComponents: [],
44
+ settings: {},
45
+ properties: {},
46
+ project: '669e1c68a40e327e67e7cedd',
47
+ controller: '',
48
+ revisions: '',
49
+ submissionRevisions: '',
50
+ _vid: 0,
51
+ created: '2024-07-22T08:47:04.399Z',
52
+ modified: '2024-07-22T10:04:23.474Z',
53
+ machineName: 'authoring-qzdhayddccjauyr:editGridTest',
54
+ };
@@ -0,0 +1,52 @@
1
+ declare namespace _default {
2
+ let type: string;
3
+ let display: string;
4
+ let components: ({
5
+ title: string;
6
+ breadcrumbClickable: boolean;
7
+ buttonSettings: {
8
+ previous: boolean;
9
+ cancel: boolean;
10
+ next: boolean;
11
+ };
12
+ collapsible: boolean;
13
+ tableView: boolean;
14
+ key: string;
15
+ type: string;
16
+ label: string;
17
+ input: boolean;
18
+ components: {
19
+ label: string;
20
+ tableView: boolean;
21
+ rowDrafts: boolean;
22
+ key: string;
23
+ type: string;
24
+ input: boolean;
25
+ components: {
26
+ label: string;
27
+ tableView: boolean;
28
+ key: string;
29
+ type: string;
30
+ input: boolean;
31
+ alwaysEnabled: boolean;
32
+ }[];
33
+ alwaysEnabled: boolean;
34
+ }[];
35
+ alwaysEnabled: boolean;
36
+ showValidations?: undefined;
37
+ } | {
38
+ label: string;
39
+ showValidations: boolean;
40
+ alwaysEnabled: boolean;
41
+ tableView: boolean;
42
+ key: string;
43
+ type: string;
44
+ input: boolean;
45
+ title?: undefined;
46
+ breadcrumbClickable?: undefined;
47
+ buttonSettings?: undefined;
48
+ collapsible?: undefined;
49
+ components?: undefined;
50
+ })[];
51
+ }
52
+ export default _default;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ type: 'form',
5
+ display: 'wizard',
6
+ components: [
7
+ {
8
+ title: 'Page 1',
9
+ breadcrumbClickable: true,
10
+ buttonSettings: {
11
+ previous: true,
12
+ cancel: true,
13
+ next: true
14
+ },
15
+ collapsible: false,
16
+ tableView: false,
17
+ key: 'page3',
18
+ type: 'panel',
19
+ label: 'Page 2',
20
+ input: false,
21
+ components: [
22
+ {
23
+ label: 'Edit Grid',
24
+ tableView: true,
25
+ rowDrafts: false,
26
+ key: 'editGrid',
27
+ type: 'editgrid',
28
+ input: true,
29
+ components: [
30
+ {
31
+ label: 'Text Field',
32
+ tableView: true,
33
+ key: 'textField',
34
+ type: 'textfield',
35
+ input: true,
36
+ alwaysEnabled: false
37
+ }
38
+ ],
39
+ alwaysEnabled: false
40
+ }
41
+ ],
42
+ alwaysEnabled: false
43
+ },
44
+ {
45
+ title: 'Page 2',
46
+ breadcrumbClickable: true,
47
+ buttonSettings: {
48
+ previous: true,
49
+ cancel: true,
50
+ next: true
51
+ },
52
+ collapsible: false,
53
+ tableView: false,
54
+ key: 'page2',
55
+ type: 'panel',
56
+ label: 'Page 1',
57
+ input: false,
58
+ alwaysEnabled: false,
59
+ components: []
60
+ },
61
+ {
62
+ label: 'Submit',
63
+ showValidations: false,
64
+ alwaysEnabled: false,
65
+ tableView: false,
66
+ key: 'submit',
67
+ type: 'button',
68
+ input: true
69
+ }
70
+ ]
71
+ };
@@ -13,7 +13,9 @@ import comp6 from './comp6';
13
13
  import comp7 from './comp7';
14
14
  import comp8 from './comp8';
15
15
  import comp9 from './comp9';
16
+ import comp16 from './comp16';
16
17
  import compOpenWhenEmpty from './comp-openWhenEmpty';
17
18
  import withOpenWhenEmptyAndConditions from './comp-with-conditions-and-openWhenEmpty';
18
19
  import compWithCustomDefaultValue from './comp-with-custom-default-value';
19
- export { comp1, comp2, comp3, comp10, comp11, comp12, comp13, comp14, comp15, comp4, comp5, comp6, comp7, comp8, comp9, compOpenWhenEmpty, withOpenWhenEmptyAndConditions, compWithCustomDefaultValue };
20
+ import compTestEvents from './comp-test-events';
21
+ export { comp1, comp2, comp3, comp10, comp11, comp12, comp13, comp14, comp15, comp4, comp5, comp6, comp7, comp8, comp9, comp16, compOpenWhenEmpty, withOpenWhenEmptyAndConditions, compWithCustomDefaultValue, compTestEvents };
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.compWithCustomDefaultValue = exports.withOpenWhenEmptyAndConditions = exports.compOpenWhenEmpty = exports.comp9 = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp15 = exports.comp14 = exports.comp13 = exports.comp12 = exports.comp11 = exports.comp10 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
6
+ exports.compTestEvents = exports.compWithCustomDefaultValue = exports.withOpenWhenEmptyAndConditions = exports.compOpenWhenEmpty = exports.comp16 = exports.comp9 = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp15 = exports.comp14 = exports.comp13 = exports.comp12 = exports.comp11 = exports.comp10 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
7
7
  const comp1_1 = __importDefault(require("./comp1"));
8
8
  exports.comp1 = comp1_1.default;
9
9
  const comp2_1 = __importDefault(require("./comp2"));
@@ -34,9 +34,13 @@ const comp14_1 = __importDefault(require("./comp14"));
34
34
  exports.comp14 = comp14_1.default;
35
35
  const comp15_1 = __importDefault(require("./comp15"));
36
36
  exports.comp15 = comp15_1.default;
37
+ const comp16_1 = __importDefault(require("./comp16"));
38
+ exports.comp16 = comp16_1.default;
37
39
  const comp_with_conditions_and_openWhenEmpty_1 = __importDefault(require("./comp-with-conditions-and-openWhenEmpty"));
38
40
  exports.withOpenWhenEmptyAndConditions = comp_with_conditions_and_openWhenEmpty_1.default;
39
41
  const comp_openWhenEmpty_1 = __importDefault(require("./comp-openWhenEmpty"));
40
42
  exports.compOpenWhenEmpty = comp_openWhenEmpty_1.default;
41
43
  const comp_with_custom_default_value_1 = __importDefault(require("./comp-with-custom-default-value"));
42
44
  exports.compWithCustomDefaultValue = comp_with_custom_default_value_1.default;
45
+ const comp_test_events_1 = __importDefault(require("./comp-test-events"));
46
+ exports.compTestEvents = comp_test_events_1.default;
@@ -74,5 +74,8 @@ declare namespace _default {
74
74
  let apiKey: string;
75
75
  let typeRemaining: string;
76
76
  let typeCount: string;
77
+ let requiredDayField: string;
78
+ let requiredMonthField: string;
79
+ let requiredYearField: string;
77
80
  }
78
81
  export default _default;
@@ -75,5 +75,8 @@ exports.default = {
75
75
  reCaptchaTokenNotSpecifiedError: 'ReCAPTCHA: Token is not specified in submission',
76
76
  apiKey: 'API Key is not unique: {{key}}',
77
77
  typeRemaining: '{{ remaining }} {{ type }} remaining.',
78
- typeCount: '{{ count }} {{ type }}'
78
+ typeCount: '{{ count }} {{ type }}',
79
+ requiredDayField: '{{ field }} is required',
80
+ requiredMonthField: '{{ field }} is required',
81
+ requiredYearField: '{{ field }} is required'
79
82
  };
@@ -16,10 +16,11 @@ class IsEmptyValue extends ConditionOperator_1.default {
16
16
  return false;
17
17
  }
18
18
  execute({ value, instance, conditionComponentPath }) {
19
- const isEmptyValue = lodash_1.default.isEmpty(value);
19
+ var _a;
20
+ const isEmptyValue = lodash_1.default.isEmpty(lodash_1.default.isNumber(value) ? String(value) : value);
20
21
  if (instance && instance.root) {
21
- const conditionTriggerComponent = instance.root.getComponent(conditionComponentPath);
22
- return conditionTriggerComponent ? conditionTriggerComponent.isEmpty() : isEmptyValue;
22
+ const conditionTriggerComponent = ((_a = instance.root) === null || _a === void 0 ? void 0 : _a.getComponent) && instance.root.getComponent(conditionComponentPath);
23
+ return (conditionTriggerComponent === null || conditionTriggerComponent === void 0 ? void 0 : conditionTriggerComponent.isEmpty) ? conditionTriggerComponent.isEmpty() : isEmptyValue;
23
24
  }
24
25
  return isEmptyValue;
25
26
  }
@@ -14,7 +14,7 @@ class IsEqualTo extends ConditionOperator_1.default {
14
14
  return 'Is Equal To';
15
15
  }
16
16
  execute({ value, comparedValue, instance, conditionComponentPath }) {
17
- var _a;
17
+ var _a, _b;
18
18
  if ((value || value === false) && comparedValue && typeof value !== typeof comparedValue && lodash_1.default.isString(comparedValue)) {
19
19
  try {
20
20
  comparedValue = JSON.parse(comparedValue);
@@ -23,10 +23,10 @@ class IsEqualTo extends ConditionOperator_1.default {
23
23
  catch (e) { }
24
24
  }
25
25
  if (instance && instance.root) {
26
- const conditionTriggerComponent = instance.root.getComponent(conditionComponentPath);
26
+ const conditionTriggerComponent = ((_a = instance.root) === null || _a === void 0 ? void 0 : _a.getComponent) && instance.root.getComponent(conditionComponentPath);
27
27
  if (conditionTriggerComponent
28
28
  && (0, utils_1.isSelectResourceWithObjectValue)(conditionTriggerComponent.component)
29
- && ((_a = conditionTriggerComponent.component) === null || _a === void 0 ? void 0 : _a.template)) {
29
+ && ((_b = conditionTriggerComponent.component) === null || _b === void 0 ? void 0 : _b.template)) {
30
30
  if (!value || !lodash_1.default.isPlainObject(value)) {
31
31
  return false;
32
32
  }
@@ -56,16 +56,7 @@ export function isMongoId(text: string): boolean;
56
56
  * @param {*} rowData - The contextual row data for the component.
57
57
  */
58
58
  export function checkCalculated(component: import('@formio/core').Component, submission: import('@formio/core').Submission, rowData: any): void;
59
- /**
60
- * Check if a simple conditional evaluates to true.
61
- * @param {import('@formio/core').Component} component - The component to check for the conditional.
62
- * @param {import('@formio/core').SimpleConditional} condition - The condition to check.
63
- * @param {*} row - The row data for the component.
64
- * @param {*} data - The full submission data.
65
- * @param {import('../../src/components/_classes/component/Component').Component} instance - The instance of the component.
66
- * @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
67
- */
68
- export function checkSimpleConditional(component: import('@formio/core').Component, condition: import('@formio/core').SimpleConditional, row: any, data: any, instance: any): boolean;
59
+ export function checkSimpleConditional(component: any, condition: any, row: any, data: any, instance: any): boolean;
69
60
  /**
70
61
  * Returns a components normalized value.
71
62
  * @param {string} compPath - The full path to the component.
@@ -190,6 +190,44 @@ exports.checkCalculated = checkCalculated;
190
190
  * @param {import('../../src/components/_classes/component/Component').Component} instance - The instance of the component.
191
191
  * @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
192
192
  */
193
+ function getConditionalPathsRecursive(conditionPaths, data) {
194
+ let currentGlobalIndex = 0;
195
+ const conditionalPathsArray = [];
196
+ const getConditionalPaths = (data, currentPath = '', localIndex = 0) => {
197
+ currentPath = currentPath.replace(/^\.+|\.+$/g, '');
198
+ const currentLocalIndex = localIndex;
199
+ const currentData = lodash_1.default.get(data, currentPath);
200
+ if (Array.isArray(currentData) && currentData.filter(Boolean).length > 0) {
201
+ if (currentData.some(element => typeof element !== 'object')) {
202
+ return;
203
+ }
204
+ const hasInnerDataArray = currentData.find(x => Array.isArray(x[conditionPaths[currentLocalIndex]]));
205
+ if (hasInnerDataArray) {
206
+ currentData.forEach((_, indexOutside) => {
207
+ const innerCompDataPath = `${currentPath}[${indexOutside}].${conditionPaths[currentLocalIndex]}`;
208
+ getConditionalPaths(data, innerCompDataPath, currentLocalIndex + 1);
209
+ });
210
+ }
211
+ else {
212
+ currentData.forEach((x, index) => {
213
+ if (!lodash_1.default.isNil(x[conditionPaths[currentLocalIndex]])) {
214
+ const compDataPath = `${currentPath}[${index}].${conditionPaths[currentLocalIndex]}`;
215
+ conditionalPathsArray.push(compDataPath);
216
+ }
217
+ });
218
+ }
219
+ }
220
+ else {
221
+ if (!conditionPaths[currentGlobalIndex]) {
222
+ return;
223
+ }
224
+ currentGlobalIndex = currentGlobalIndex + 1;
225
+ getConditionalPaths(data, `${currentPath}.${conditionPaths[currentGlobalIndex - 1]}`, currentGlobalIndex);
226
+ }
227
+ };
228
+ getConditionalPaths(data);
229
+ return conditionalPathsArray;
230
+ }
193
231
  function checkSimpleConditional(component, condition, row, data, instance) {
194
232
  if (condition.when) {
195
233
  const value = getComponentActualValue(condition.when, data, row);
@@ -211,23 +249,37 @@ function checkSimpleConditional(component, condition, row, data, instance) {
211
249
  return true;
212
250
  }
213
251
  const conditionsResult = lodash_1.default.map(conditions, (cond) => {
252
+ var _a, _b;
214
253
  const { value: comparedValue, operator, component: conditionComponentPath } = cond;
215
254
  if (!conditionComponentPath) {
216
255
  return true;
217
256
  }
218
- const value = getComponentActualValue(conditionComponentPath, data, row);
219
- const ConditionOperator = conditionOperators_1.default[operator];
220
- return ConditionOperator
221
- ? new ConditionOperator().getResult({ value, comparedValue, instance, component, conditionComponentPath })
222
- : true;
257
+ const splittedConditionPath = conditionComponentPath.split('.');
258
+ const conditionalPaths = ((_a = instance === null || instance === void 0 ? void 0 : instance.parent) === null || _a === void 0 ? void 0 : _a.type) === 'datagrid' || ((_b = instance === null || instance === void 0 ? void 0 : instance.parent) === null || _b === void 0 ? void 0 : _b.type) === 'editgrid' ? [] : getConditionalPathsRecursive(splittedConditionPath, data);
259
+ if (conditionalPaths.length > 0) {
260
+ return conditionalPaths.map((path) => {
261
+ const value = getComponentActualValue(path, data, row);
262
+ const ConditionOperator = conditionOperators_1.default[operator];
263
+ return ConditionOperator
264
+ ? new ConditionOperator().getResult({ value, comparedValue, instance, component, conditionComponentPath })
265
+ : true;
266
+ });
267
+ }
268
+ else {
269
+ const value = getComponentActualValue(conditionComponentPath, data, row);
270
+ const СonditionOperator = conditionOperators_1.default[operator];
271
+ return СonditionOperator
272
+ ? new СonditionOperator().getResult({ value, comparedValue, instance, component, conditionComponentPath })
273
+ : true;
274
+ }
223
275
  });
224
276
  let result = false;
225
277
  switch (conjunction) {
226
278
  case 'any':
227
- result = lodash_1.default.some(conditionsResult, res => !!res);
279
+ result = lodash_1.default.some(conditionsResult.flat(), res => !!res);
228
280
  break;
229
281
  default:
230
- result = lodash_1.default.every(conditionsResult, res => !!res);
282
+ result = lodash_1.default.every(conditionsResult.flat(), res => !!res);
231
283
  }
232
284
  return show ? result : !result;
233
285
  }
package/lib/mjs/CDN.d.ts CHANGED
@@ -13,6 +13,7 @@ declare class CDN {
13
13
  bootswatch: string;
14
14
  'bootstrap-icons': string;
15
15
  ckeditor: string;
16
+ dragula: string;
16
17
  flatpickr: string;
17
18
  'flatpickr-formio': string;
18
19
  'font-awesome': string;
package/lib/mjs/CDN.js CHANGED
@@ -16,6 +16,7 @@ class CDN {
16
16
  'bootswatch': '5.3.3',
17
17
  'bootstrap-icons': '1.11.1',
18
18
  'ckeditor': '19.0.0',
19
+ 'dragula': '3.7.3',
19
20
  'flatpickr': '4.6.8',
20
21
  'flatpickr-formio': '4.6.13-formio.3',
21
22
  'font-awesome': '4.7.0',
@@ -8,7 +8,10 @@ import Components from "./components/Components";
8
8
  import NestedDataComponent from "./components/_classes/nesteddata/NestedDataComponent";
9
9
  import { fastCloneDeep, currentTimezone, unescapeHTML, getStringFromComponentPath, convertStringToHTMLElement, getArrayFromComponentPath, } from "./utils/utils";
10
10
  import { eachComponent } from "./utils/formUtils";
11
- import dragula from "dragula";
11
+ // We need this here because dragula pulls in CustomEvent class that requires global to exist.
12
+ if (typeof window !== 'undefined' && typeof window.global === 'undefined') {
13
+ window.global = window;
14
+ }
12
15
  // Initialize the available forms.
13
16
  Formio.forms = {};
14
17
  // Allow people to register components.
@@ -282,7 +285,6 @@ export default class Webform extends NestedDataComponent {
282
285
  // Ensure the root is set to this component.
283
286
  this.root = this;
284
287
  this.localRoot = this;
285
- this.root.dragulaLib = dragula;
286
288
  }
287
289
  /* eslint-enable max-statements */
288
290
  get language() {
@@ -830,6 +830,7 @@ declare class Component extends Element {
830
830
  quill: any;
831
831
  get shouldSanitizeValue(): boolean;
832
832
  addAce(element: any, settings: any, onChange: any): any;
833
+ getDragula(): Promise<any>;
833
834
  get tree(): any;
834
835
  /**
835
836
  * The empty value for this component.
@@ -2351,6 +2351,13 @@ export default class Component extends Element {
2351
2351
  return editor;
2352
2352
  });
2353
2353
  }
2354
+ async getDragula() {
2355
+ return new Promise((resolve) => {
2356
+ return Formio.requireLibrary('dragula', 'dragula', `${Formio.cdn.dragula}/dragula.js`, true, (ready) => {
2357
+ return ready.then(resolve);
2358
+ });
2359
+ });
2360
+ }
2354
2361
  get tree() {
2355
2362
  return this.component.tree || false;
2356
2363
  }
@@ -43,7 +43,7 @@ export default class CheckBoxComponent extends Field {
43
43
  attach(element: any): Promise<void>;
44
44
  input: any;
45
45
  detach(element: any): void;
46
- get emptyValue(): false | null;
46
+ get emptyValue(): false | "";
47
47
  getValueAt(index: any): any;
48
48
  get checked(): boolean;
49
49
  setCheckedState(value: any): any;
@@ -116,7 +116,7 @@ export default class CheckBoxComponent extends Field {
116
116
  super.detach();
117
117
  }
118
118
  get emptyValue() {
119
- return this.component.inputType === 'radio' ? null : false;
119
+ return this.component.inputType === 'radio' ? '' : false;
120
120
  }
121
121
  isEmpty(value = this.dataValue) {
122
122
  return super.isEmpty(value) || value === false;
@@ -0,0 +1,32 @@
1
+ declare namespace _default {
2
+ let name: string;
3
+ let path: string;
4
+ let type: string;
5
+ let display: string;
6
+ let components: ({
7
+ label: string;
8
+ inputType: string;
9
+ tableView: boolean;
10
+ defaultValue: boolean;
11
+ key: string;
12
+ type: string;
13
+ name: string;
14
+ value: string;
15
+ input: boolean;
16
+ 'some name': boolean;
17
+ disableOnInvalid?: undefined;
18
+ } | {
19
+ type: string;
20
+ label: string;
21
+ key: string;
22
+ disableOnInvalid: boolean;
23
+ input: boolean;
24
+ tableView: boolean;
25
+ inputType?: undefined;
26
+ defaultValue?: undefined;
27
+ name?: undefined;
28
+ value?: undefined;
29
+ 'some name'?: undefined;
30
+ })[];
31
+ }
32
+ export default _default;
@@ -0,0 +1,28 @@
1
+ export default {
2
+ name: 'ckeckbox',
3
+ path: 'ckeckbox',
4
+ type: 'form',
5
+ display: 'form',
6
+ components: [
7
+ {
8
+ label: 'Checkbox',
9
+ inputType: 'radio',
10
+ tableView: false,
11
+ defaultValue: false,
12
+ key: 'checkbox',
13
+ type: 'checkbox',
14
+ name: 'some name',
15
+ value: 'ok',
16
+ input: true,
17
+ 'some name': false
18
+ },
19
+ {
20
+ type: 'button',
21
+ label: 'Submit',
22
+ key: 'submit',
23
+ disableOnInvalid: true,
24
+ input: true,
25
+ tableView: false
26
+ }
27
+ ],
28
+ };
@@ -3,5 +3,6 @@ import comp2 from './comp2';
3
3
  import comp3 from './comp3';
4
4
  import comp4 from './comp4';
5
5
  import comp5 from './comp5';
6
+ import comp6 from './comp6';
6
7
  import customDefaultComponent from './customDefaultComponent';
7
- export { comp1, comp2, comp3, comp4, comp5, customDefaultComponent };
8
+ export { comp1, comp2, comp3, comp4, comp5, comp6, customDefaultComponent };
@@ -4,4 +4,5 @@ import comp2 from './comp2';
4
4
  import comp3 from './comp3';
5
5
  import comp4 from './comp4';
6
6
  import comp5 from './comp5';
7
- export { comp1, comp2, comp3, comp4, comp5, customDefaultComponent };
7
+ import comp6 from './comp6';
8
+ export { comp1, comp2, comp3, comp4, comp5, comp6, customDefaultComponent };
@@ -12,6 +12,7 @@ export default class DataGridComponent extends NestedArrayComponent {
12
12
  tabIndex: number;
13
13
  rows: any[] | undefined;
14
14
  columns: any[] | undefined;
15
+ dragulaReady: Promise<any> | undefined;
15
16
  visibleColumns: {} | undefined;
16
17
  set dataValue(value: any[]);
17
18
  get dataValue(): any[];
@@ -71,6 +72,7 @@ export default class DataGridComponent extends NestedArrayComponent {
71
72
  */
72
73
  reorderValues(valuesArr: any, oldPosition: number, newPosition: number, movedBelow: boolean | any): void;
73
74
  onReorder(element: any, _target: any, _source: any, sibling: any): void;
75
+ onCloned(el: any, original: any): void;
74
76
  focusOnNewRowElement(row: any): void;
75
77
  addRow(): void;
76
78
  updateComponentsRowIndex(components: any, rowIndex: any): void;