@formio/js 5.0.0-dev.5673.3d062b9 → 5.0.0-dev.5673.ae99c16
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.
- package/Changelog.md +63 -1
- package/dist/formio.builder.css +0 -1
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.embed.js +1 -1
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.form.css +0 -1
- package/dist/formio.form.js +646 -594
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +1 -9
- package/dist/formio.full.css +0 -1
- package/dist/formio.full.js +633 -601
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +1 -9
- package/dist/formio.js +4 -4
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +100 -38
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +5 -3
- package/lib/cjs/CDN.d.ts +1 -0
- package/lib/cjs/CDN.js +2 -2
- package/lib/cjs/Form.d.ts +2 -2
- package/lib/cjs/Form.js +11 -5
- package/lib/cjs/Formio.js +1 -0
- package/lib/cjs/PDF.js +1 -1
- package/lib/cjs/PDFBuilder.js +2 -1
- package/lib/cjs/Webform.d.ts +1 -1
- package/lib/cjs/Webform.js +11 -6
- package/lib/cjs/WebformBuilder.js +13 -3
- package/lib/cjs/Wizard.js +1 -1
- package/lib/cjs/components/_classes/component/Component.d.ts +4 -3
- package/lib/cjs/components/_classes/component/Component.js +31 -8
- package/lib/cjs/components/_classes/component/editForm/Component.edit.display.js +8 -0
- package/lib/cjs/components/_classes/component/fixtures/comp7.d.ts +84 -0
- package/lib/cjs/components/_classes/component/fixtures/comp7.js +86 -0
- package/lib/cjs/components/_classes/component/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/_classes/component/fixtures/index.js +3 -1
- package/lib/cjs/components/_classes/input/Input.js +23 -1
- package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +9 -2
- package/lib/cjs/components/_classes/multivalue/Multivalue.js +53 -26
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +2 -1
- package/lib/cjs/components/_classes/nested/NestedComponent.js +5 -1
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +3 -0
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +56 -29
- package/lib/cjs/components/address/Address.d.ts +6 -0
- package/lib/cjs/components/address/Address.js +11 -1
- package/lib/cjs/components/address/editForm/Address.edit.provider.js +1 -1
- package/lib/cjs/components/checkbox/Checkbox.d.ts +1 -1
- package/lib/cjs/components/checkbox/Checkbox.js +1 -1
- package/lib/cjs/components/checkbox/fixtures/comp6.d.ts +32 -0
- package/lib/cjs/components/checkbox/fixtures/comp6.js +30 -0
- package/lib/cjs/components/checkbox/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/checkbox/fixtures/index.js +3 -1
- package/lib/cjs/components/currency/Currency.d.ts +2 -0
- package/lib/cjs/components/datagrid/DataGrid.d.ts +11 -1
- package/lib/cjs/components/datagrid/DataGrid.js +59 -36
- package/lib/cjs/components/datagrid/fixtures/comp-with-reorder.d.ts +100 -0
- package/lib/cjs/components/datagrid/fixtures/comp-with-reorder.js +139 -0
- package/lib/cjs/components/datagrid/fixtures/comp10.d.ts +81 -0
- package/lib/cjs/components/datagrid/fixtures/comp10.js +87 -0
- package/lib/cjs/components/datagrid/fixtures/comp11.d.ts +50 -0
- package/lib/cjs/components/datagrid/fixtures/comp11.js +55 -0
- package/lib/cjs/components/datagrid/fixtures/comp9.d.ts +41 -0
- package/lib/cjs/components/datagrid/fixtures/comp9.js +44 -0
- package/lib/cjs/components/datagrid/fixtures/index.d.ts +5 -1
- package/lib/cjs/components/datagrid/fixtures/index.js +9 -1
- package/lib/cjs/components/datamap/DataMap.js +2 -2
- package/lib/cjs/components/datetime/fixtures/comp14.d.ts +35 -0
- package/lib/cjs/components/datetime/fixtures/comp14.js +38 -0
- package/lib/cjs/components/datetime/fixtures/index.d.ts +6 -5
- package/lib/cjs/components/datetime/fixtures/index.js +3 -1
- package/lib/cjs/components/day/Day.d.ts +3 -4
- package/lib/cjs/components/day/Day.js +31 -10
- package/lib/cjs/components/day/fixtures/comp8.d.ts +41 -0
- package/lib/cjs/components/day/fixtures/comp8.js +40 -0
- package/lib/cjs/components/day/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/day/fixtures/index.js +3 -1
- package/lib/cjs/components/editgrid/EditGrid.js +16 -8
- package/lib/cjs/components/editgrid/fixtures/comp-test-events.d.ts +54 -0
- package/lib/cjs/components/editgrid/fixtures/comp-test-events.js +54 -0
- package/lib/cjs/components/editgrid/fixtures/comp16.d.ts +52 -0
- package/lib/cjs/components/editgrid/fixtures/comp16.js +71 -0
- package/lib/cjs/components/editgrid/fixtures/comp17.d.ts +80 -0
- package/lib/cjs/components/editgrid/fixtures/comp17.js +99 -0
- package/lib/cjs/components/editgrid/fixtures/index.d.ts +10 -7
- package/lib/cjs/components/editgrid/fixtures/index.js +7 -1
- package/lib/cjs/components/file/File.d.ts +2 -2
- package/lib/cjs/components/file/File.js +13 -2
- package/lib/cjs/components/file/editForm/File.edit.display.js +1 -1
- package/lib/cjs/components/form/Form.d.ts +1 -1
- package/lib/cjs/components/form/Form.js +1 -1
- package/lib/cjs/components/form/editForm/Form.edit.form.js +1 -1
- package/lib/cjs/components/form/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/form/fixtures/index.js +3 -1
- package/lib/cjs/components/form/fixtures/nestedWizardForm.d.ts +771 -0
- package/lib/cjs/components/form/fixtures/nestedWizardForm.js +765 -0
- package/lib/cjs/components/html/HTML.js +1 -1
- package/lib/cjs/components/number/Number.d.ts +17 -2
- package/lib/cjs/components/number/Number.js +27 -7
- package/lib/cjs/components/number/fixtures/comp10.d.ts +18 -0
- package/lib/cjs/components/number/fixtures/comp10.js +21 -0
- package/lib/cjs/components/number/fixtures/comp8.d.ts +32 -0
- package/lib/cjs/components/number/fixtures/comp8.js +28 -0
- package/lib/cjs/components/number/fixtures/comp9.d.ts +18 -0
- package/lib/cjs/components/number/fixtures/comp9.js +21 -0
- package/lib/cjs/components/number/fixtures/index.d.ts +4 -1
- package/lib/cjs/components/number/fixtures/index.js +7 -1
- package/lib/cjs/components/panel/Panel.d.ts +1 -0
- package/lib/cjs/components/panel/Panel.js +1 -0
- package/lib/cjs/components/phonenumber/fixtures/comp2.d.ts +16 -0
- package/lib/cjs/components/phonenumber/fixtures/comp2.js +25 -0
- package/lib/cjs/components/phonenumber/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/phonenumber/fixtures/index.js +3 -1
- package/lib/cjs/components/radio/Radio.d.ts +2 -18
- package/lib/cjs/components/radio/Radio.js +29 -27
- package/lib/cjs/components/radio/fixtures/comp12.d.ts +29 -0
- package/lib/cjs/components/radio/fixtures/comp12.js +36 -0
- package/lib/cjs/components/radio/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/radio/fixtures/index.js +3 -1
- package/lib/cjs/components/recaptcha/ReCaptcha.d.ts +6 -0
- package/lib/cjs/components/recaptcha/ReCaptcha.js +6 -0
- package/lib/cjs/components/select/Select.d.ts +38 -0
- package/lib/cjs/components/select/Select.js +14 -5
- package/lib/cjs/components/select/fixtures/comp25.d.ts +59 -0
- package/lib/cjs/components/select/fixtures/comp25.js +66 -0
- package/lib/cjs/components/select/fixtures/comp26.d.ts +44 -0
- package/lib/cjs/components/select/fixtures/comp26.js +59 -0
- package/lib/cjs/components/select/fixtures/index.d.ts +3 -1
- package/lib/cjs/components/select/fixtures/index.js +5 -1
- package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +0 -22
- package/lib/cjs/components/selectboxes/SelectBoxes.js +12 -9
- package/lib/cjs/components/signature/editForm/Signature.edit.display.d.ts +0 -6
- package/lib/cjs/components/signature/editForm/Signature.edit.display.js +0 -1
- package/lib/cjs/components/tags/Tags.js +3 -3
- package/lib/cjs/components/time/Time.d.ts +2 -2
- package/lib/cjs/components/time/Time.form.js +2 -2
- package/lib/cjs/components/time/Time.js +3 -7
- package/lib/cjs/components/time/fixtures/comp4.d.ts +166 -0
- package/lib/cjs/components/time/fixtures/comp4.js +171 -0
- package/lib/cjs/components/time/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/time/fixtures/index.js +3 -1
- package/lib/cjs/providers/address/GoogleAddressProvider.d.ts +5 -0
- package/lib/cjs/providers/address/GoogleAddressProvider.js +23 -1
- package/lib/cjs/templates/Templates.js +1 -1
- package/lib/cjs/translations/en.d.ts +4 -0
- package/lib/cjs/translations/en.js +5 -1
- package/lib/cjs/utils/conditionOperators/IsEmptyValue.js +2 -2
- package/lib/cjs/utils/utils.d.ts +2 -11
- package/lib/cjs/utils/utils.js +60 -24
- package/lib/cjs/widgets/CalendarWidget.js +24 -10
- package/lib/mjs/CDN.d.ts +1 -0
- package/lib/mjs/CDN.js +2 -2
- package/lib/mjs/Form.d.ts +2 -2
- package/lib/mjs/Form.js +11 -5
- package/lib/mjs/Formio.js +1 -0
- package/lib/mjs/PDF.js +1 -1
- package/lib/mjs/PDFBuilder.js +1 -1
- package/lib/mjs/Webform.d.ts +1 -1
- package/lib/mjs/Webform.js +15 -6
- package/lib/mjs/WebformBuilder.js +12 -3
- package/lib/mjs/Wizard.js +1 -1
- package/lib/mjs/components/_classes/component/Component.d.ts +4 -3
- package/lib/mjs/components/_classes/component/Component.js +17 -5
- package/lib/mjs/components/_classes/component/editForm/Component.edit.display.js +8 -0
- package/lib/mjs/components/_classes/component/fixtures/comp7.d.ts +84 -0
- package/lib/mjs/components/_classes/component/fixtures/comp7.js +84 -0
- package/lib/mjs/components/_classes/component/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/_classes/component/fixtures/index.js +2 -1
- package/lib/mjs/components/_classes/input/Input.js +22 -1
- package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +9 -2
- package/lib/mjs/components/_classes/multivalue/Multivalue.js +53 -26
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +2 -1
- package/lib/mjs/components/_classes/nested/NestedComponent.js +5 -1
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +3 -0
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +57 -29
- package/lib/mjs/components/address/Address.d.ts +6 -0
- package/lib/mjs/components/address/Address.js +14 -1
- package/lib/mjs/components/address/editForm/Address.edit.provider.js +1 -1
- package/lib/mjs/components/checkbox/Checkbox.d.ts +1 -1
- package/lib/mjs/components/checkbox/Checkbox.js +1 -1
- package/lib/mjs/components/checkbox/fixtures/comp6.d.ts +32 -0
- package/lib/mjs/components/checkbox/fixtures/comp6.js +28 -0
- package/lib/mjs/components/checkbox/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/checkbox/fixtures/index.js +2 -1
- package/lib/mjs/components/currency/Currency.d.ts +2 -0
- package/lib/mjs/components/datagrid/DataGrid.d.ts +11 -1
- package/lib/mjs/components/datagrid/DataGrid.js +58 -35
- package/lib/mjs/components/datagrid/fixtures/comp-with-reorder.d.ts +100 -0
- package/lib/mjs/components/datagrid/fixtures/comp-with-reorder.js +137 -0
- package/lib/mjs/components/datagrid/fixtures/comp10.d.ts +81 -0
- package/lib/mjs/components/datagrid/fixtures/comp10.js +85 -0
- package/lib/mjs/components/datagrid/fixtures/comp11.d.ts +50 -0
- package/lib/mjs/components/datagrid/fixtures/comp11.js +53 -0
- package/lib/mjs/components/datagrid/fixtures/comp9.d.ts +41 -0
- package/lib/mjs/components/datagrid/fixtures/comp9.js +42 -0
- package/lib/mjs/components/datagrid/fixtures/index.d.ts +5 -1
- package/lib/mjs/components/datagrid/fixtures/index.js +5 -1
- package/lib/mjs/components/datamap/DataMap.js +2 -2
- package/lib/mjs/components/datetime/fixtures/comp14.d.ts +35 -0
- package/lib/mjs/components/datetime/fixtures/comp14.js +36 -0
- package/lib/mjs/components/datetime/fixtures/index.d.ts +6 -5
- package/lib/mjs/components/datetime/fixtures/index.js +2 -1
- package/lib/mjs/components/day/Day.d.ts +3 -4
- package/lib/mjs/components/day/Day.js +30 -10
- package/lib/mjs/components/day/fixtures/comp8.d.ts +41 -0
- package/lib/mjs/components/day/fixtures/comp8.js +38 -0
- package/lib/mjs/components/day/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/day/fixtures/index.js +2 -1
- package/lib/mjs/components/editgrid/EditGrid.js +16 -8
- package/lib/mjs/components/editgrid/fixtures/comp-test-events.d.ts +54 -0
- package/lib/mjs/components/editgrid/fixtures/comp-test-events.js +52 -0
- package/lib/mjs/components/editgrid/fixtures/comp16.d.ts +52 -0
- package/lib/mjs/components/editgrid/fixtures/comp16.js +69 -0
- package/lib/mjs/components/editgrid/fixtures/comp17.d.ts +80 -0
- package/lib/mjs/components/editgrid/fixtures/comp17.js +97 -0
- package/lib/mjs/components/editgrid/fixtures/index.d.ts +10 -7
- package/lib/mjs/components/editgrid/fixtures/index.js +4 -1
- package/lib/mjs/components/file/File.d.ts +2 -2
- package/lib/mjs/components/file/File.js +13 -2
- package/lib/mjs/components/file/editForm/File.edit.display.js +1 -1
- package/lib/mjs/components/form/Form.d.ts +1 -1
- package/lib/mjs/components/form/Form.js +1 -1
- package/lib/mjs/components/form/editForm/Form.edit.form.js +1 -1
- package/lib/mjs/components/form/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/form/fixtures/index.js +2 -1
- package/lib/mjs/components/form/fixtures/nestedWizardForm.d.ts +771 -0
- package/lib/mjs/components/form/fixtures/nestedWizardForm.js +763 -0
- package/lib/mjs/components/html/HTML.js +1 -1
- package/lib/mjs/components/number/Number.d.ts +17 -2
- package/lib/mjs/components/number/Number.js +26 -6
- package/lib/mjs/components/number/fixtures/comp10.d.ts +18 -0
- package/lib/mjs/components/number/fixtures/comp10.js +19 -0
- package/lib/mjs/components/number/fixtures/comp8.d.ts +32 -0
- package/lib/mjs/components/number/fixtures/comp8.js +26 -0
- package/lib/mjs/components/number/fixtures/comp9.d.ts +18 -0
- package/lib/mjs/components/number/fixtures/comp9.js +19 -0
- package/lib/mjs/components/number/fixtures/index.d.ts +4 -1
- package/lib/mjs/components/number/fixtures/index.js +4 -1
- package/lib/mjs/components/panel/Panel.d.ts +1 -0
- package/lib/mjs/components/panel/Panel.js +1 -0
- package/lib/mjs/components/phonenumber/fixtures/comp2.d.ts +16 -0
- package/lib/mjs/components/phonenumber/fixtures/comp2.js +23 -0
- package/lib/mjs/components/phonenumber/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/phonenumber/fixtures/index.js +2 -1
- package/lib/mjs/components/radio/Radio.d.ts +2 -18
- package/lib/mjs/components/radio/Radio.js +32 -30
- package/lib/mjs/components/radio/fixtures/comp12.d.ts +29 -0
- package/lib/mjs/components/radio/fixtures/comp12.js +34 -0
- package/lib/mjs/components/radio/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/radio/fixtures/index.js +2 -1
- package/lib/mjs/components/recaptcha/ReCaptcha.d.ts +6 -0
- package/lib/mjs/components/recaptcha/ReCaptcha.js +9 -0
- package/lib/mjs/components/select/Select.d.ts +38 -0
- package/lib/mjs/components/select/Select.js +17 -6
- package/lib/mjs/components/select/fixtures/comp25.d.ts +59 -0
- package/lib/mjs/components/select/fixtures/comp25.js +64 -0
- package/lib/mjs/components/select/fixtures/comp26.d.ts +44 -0
- package/lib/mjs/components/select/fixtures/comp26.js +57 -0
- package/lib/mjs/components/select/fixtures/index.d.ts +3 -1
- package/lib/mjs/components/select/fixtures/index.js +3 -1
- package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +0 -22
- package/lib/mjs/components/selectboxes/SelectBoxes.js +16 -9
- package/lib/mjs/components/signature/editForm/Signature.edit.display.d.ts +0 -6
- package/lib/mjs/components/signature/editForm/Signature.edit.display.js +0 -1
- package/lib/mjs/components/tags/Tags.js +3 -3
- package/lib/mjs/components/time/Time.d.ts +2 -2
- package/lib/mjs/components/time/Time.form.js +2 -2
- package/lib/mjs/components/time/Time.js +3 -13
- package/lib/mjs/components/time/fixtures/comp4.d.ts +166 -0
- package/lib/mjs/components/time/fixtures/comp4.js +169 -0
- package/lib/mjs/components/time/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/time/fixtures/index.js +2 -1
- package/lib/mjs/providers/address/GoogleAddressProvider.d.ts +5 -0
- package/lib/mjs/providers/address/GoogleAddressProvider.js +22 -1
- package/lib/mjs/templates/Templates.js +1 -1
- package/lib/mjs/translations/en.d.ts +4 -0
- package/lib/mjs/translations/en.js +5 -1
- package/lib/mjs/utils/conditionOperators/IsEmptyValue.js +2 -2
- package/lib/mjs/utils/utils.d.ts +2 -11
- package/lib/mjs/utils/utils.js +59 -13
- package/lib/mjs/widgets/CalendarWidget.js +24 -10
- package/package.json +5 -6
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
export default class Multivalue extends Field {
|
|
2
|
+
/**
|
|
3
|
+
* Normalize values coming into updateValue.
|
|
4
|
+
* @param {*} value - The value to normalize before setting.
|
|
5
|
+
* @param {Object} flags - Flags to use when normalizing the value.
|
|
6
|
+
* @param {*} emptyValue - The empty value for the field.
|
|
7
|
+
* @returns {*} - The normalized value.
|
|
8
|
+
*/
|
|
9
|
+
normalizeValue(value: any, flags?: Object, emptyValue?: any): any;
|
|
2
10
|
get addAnother(): string;
|
|
3
|
-
useWrapper(): any;
|
|
4
11
|
/**
|
|
5
12
|
* @returns {Field} - The created field.
|
|
6
13
|
*/
|
|
@@ -44,7 +51,7 @@ export default class Multivalue extends Field {
|
|
|
44
51
|
attachMultiMask(index: number): boolean;
|
|
45
52
|
/**
|
|
46
53
|
* @param {any} input - The input element on which the mask is to be applied.
|
|
47
|
-
* @param {string} mask - The mask pattern to apply to the input element. Exit early if no mask.
|
|
54
|
+
* @param {string} mask - The mask pattern to apply to the input element. Exit early and remove previous mask if no mask.
|
|
48
55
|
*/
|
|
49
56
|
updateMask(input: any, mask: string): void;
|
|
50
57
|
/**
|
|
@@ -6,12 +6,42 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const Field_1 = __importDefault(require("../field/Field"));
|
|
7
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
8
|
class Multivalue extends Field_1.default {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Normalize values coming into updateValue.
|
|
11
|
+
* @param {*} value - The value to normalize before setting.
|
|
12
|
+
* @param {Object} flags - Flags to use when normalizing the value.
|
|
13
|
+
* @param {*} emptyValue - The empty value for the field.
|
|
14
|
+
* @returns {*} - The normalized value.
|
|
15
|
+
*/
|
|
16
|
+
normalizeValue(value, flags = {}, emptyValue = this.emptyValue) {
|
|
17
|
+
if (this.component.multiple) {
|
|
18
|
+
if (Array.isArray(value)) {
|
|
19
|
+
if (value.length === 0) {
|
|
20
|
+
return [emptyValue];
|
|
21
|
+
}
|
|
22
|
+
if (this.component.storeas === 'array') {
|
|
23
|
+
return super.normalizeValue([value], flags);
|
|
24
|
+
}
|
|
25
|
+
return super.normalizeValue(value, flags);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return super.normalizeValue(value == null ? [emptyValue] : [value], flags);
|
|
29
|
+
}
|
|
13
30
|
}
|
|
14
|
-
|
|
31
|
+
else {
|
|
32
|
+
if (Array.isArray(value) && !Array.isArray(emptyValue)) {
|
|
33
|
+
if (this.component.storeas === 'string') {
|
|
34
|
+
return super.normalizeValue(value.join(this.delimiter || ''), flags);
|
|
35
|
+
}
|
|
36
|
+
return super.normalizeValue(value[0] || emptyValue, flags);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return super.normalizeValue(value, flags);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
get dataValue() {
|
|
44
|
+
return this.normalizeValue(super.dataValue);
|
|
15
45
|
}
|
|
16
46
|
set dataValue(value) {
|
|
17
47
|
super.dataValue = value;
|
|
@@ -31,30 +61,20 @@ class Multivalue extends Field_1.default {
|
|
|
31
61
|
get addAnother() {
|
|
32
62
|
return this.t(this.component.addAnother || 'Add Another');
|
|
33
63
|
}
|
|
34
|
-
useWrapper() {
|
|
35
|
-
return this.component.hasOwnProperty('multiple') && this.component.multiple;
|
|
36
|
-
}
|
|
37
64
|
/**
|
|
38
65
|
* @returns {Field} - The created field.
|
|
39
66
|
*/
|
|
40
67
|
render() {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
// If multiple value field.
|
|
53
|
-
return super.render(this.renderTemplate('multiValueTable', {
|
|
54
|
-
rows: dataValue.map(this.renderRow.bind(this)).join(''),
|
|
55
|
-
disabled: this.disabled,
|
|
56
|
-
addAnother: this.addAnother,
|
|
57
|
-
}));
|
|
68
|
+
let dataValue = this.normalizeValue(this.dataValue);
|
|
69
|
+
return this.component.hasOwnProperty('multiple') && this.component.multiple
|
|
70
|
+
? super.render(this.renderTemplate('multiValueTable', {
|
|
71
|
+
rows: dataValue.map(this.renderRow.bind(this)).join(''),
|
|
72
|
+
disabled: this.disabled,
|
|
73
|
+
addAnother: this.addAnother,
|
|
74
|
+
}))
|
|
75
|
+
: super.render(`<div ${this._referenceAttributeName}="element">
|
|
76
|
+
${this.renderElement(this.component.type !== 'hidden' ? dataValue : '')}
|
|
77
|
+
</div>`);
|
|
58
78
|
}
|
|
59
79
|
renderElement() {
|
|
60
80
|
return '';
|
|
@@ -237,10 +257,17 @@ class Multivalue extends Field_1.default {
|
|
|
237
257
|
}
|
|
238
258
|
/**
|
|
239
259
|
* @param {any} input - The input element on which the mask is to be applied.
|
|
240
|
-
* @param {string} mask - The mask pattern to apply to the input element. Exit early if no mask.
|
|
260
|
+
* @param {string} mask - The mask pattern to apply to the input element. Exit early and remove previous mask if no mask.
|
|
241
261
|
*/
|
|
242
262
|
updateMask(input, mask) {
|
|
243
263
|
if (!mask) {
|
|
264
|
+
if (input.mask) {
|
|
265
|
+
input.mask.destroy();
|
|
266
|
+
}
|
|
267
|
+
if (!this.component.placeholder) {
|
|
268
|
+
input.removeAttribute('placeholder');
|
|
269
|
+
}
|
|
270
|
+
input.value = '';
|
|
244
271
|
return;
|
|
245
272
|
}
|
|
246
273
|
this.setInputMask(input, mask, !this.component.placeholder);
|
|
@@ -211,11 +211,12 @@ export default class NestedComponent extends Field {
|
|
|
211
211
|
calculateValue(data: any, flags: any, row: any): any;
|
|
212
212
|
isLastPage(): boolean;
|
|
213
213
|
isValid(data: any, dirty: any): any;
|
|
214
|
-
validationProcessor({ scope, data, row, instance }: {
|
|
214
|
+
validationProcessor({ scope, data, row, instance, component }: {
|
|
215
215
|
scope: any;
|
|
216
216
|
data: any;
|
|
217
217
|
row: any;
|
|
218
218
|
instance: any;
|
|
219
|
+
component: any;
|
|
219
220
|
}, flags: any): void;
|
|
220
221
|
/**
|
|
221
222
|
* Perform a validation on all child components of this nested component.
|
|
@@ -497,6 +497,7 @@ class NestedComponent extends Field_1.default {
|
|
|
497
497
|
header: 'single',
|
|
498
498
|
collapsed: this.collapsed,
|
|
499
499
|
[this.nestedKey]: 'single',
|
|
500
|
+
messageContainer: 'single-scope',
|
|
500
501
|
});
|
|
501
502
|
let childPromise = Promise.resolve();
|
|
502
503
|
if (this.refs[this.nestedKey]) {
|
|
@@ -681,8 +682,11 @@ class NestedComponent extends Field_1.default {
|
|
|
681
682
|
isValid(data, dirty) {
|
|
682
683
|
return this.getComponents().reduce((valid, comp) => comp.isValid(data, dirty) && valid, super.isValid(data, dirty));
|
|
683
684
|
}
|
|
684
|
-
validationProcessor({ scope, data, row, instance }, flags) {
|
|
685
|
+
validationProcessor({ scope, data, row, instance, component }, flags) {
|
|
685
686
|
const { dirty } = flags;
|
|
687
|
+
if (this.root.hasExtraPages && this.page !== this.root.page) {
|
|
688
|
+
instance = this.getComponent(component.path);
|
|
689
|
+
}
|
|
686
690
|
if (!instance) {
|
|
687
691
|
return;
|
|
688
692
|
}
|
|
@@ -12,6 +12,9 @@ export default class NestedArrayComponent extends NestedDataComponent {
|
|
|
12
12
|
hasAddButton(): any;
|
|
13
13
|
getComponent(path: any, fn: any, originalPath: any): any;
|
|
14
14
|
everyComponent(fn: any, rowIndex: any, options?: {}): void;
|
|
15
|
+
_getEmailTableHeader(options: any): string;
|
|
16
|
+
_getEmailTableBody(options: any): string;
|
|
15
17
|
getComponents(rowIndex: any): any;
|
|
18
|
+
removeSubmissionMetadataRow(index: any): void;
|
|
16
19
|
}
|
|
17
20
|
import NestedDataComponent from '../nesteddata/NestedDataComponent';
|
|
@@ -149,39 +149,60 @@ class NestedArrayComponent extends NestedDataComponent_1.default {
|
|
|
149
149
|
}
|
|
150
150
|
});
|
|
151
151
|
}
|
|
152
|
+
_getEmailTableHeader(options) {
|
|
153
|
+
let row = '';
|
|
154
|
+
const getHeaderCell = (component) => {
|
|
155
|
+
if (!component.isInputComponent || !component.visible || component.skipInEmail) {
|
|
156
|
+
return '';
|
|
157
|
+
}
|
|
158
|
+
const label = component.label || component.key;
|
|
159
|
+
return `<th style="padding: 5px 10px;">${label}</th>`;
|
|
160
|
+
};
|
|
161
|
+
const components = this.getComponents(0);
|
|
162
|
+
for (const component of components) {
|
|
163
|
+
if (component.isInputComponent) {
|
|
164
|
+
row += getHeaderCell(component);
|
|
165
|
+
}
|
|
166
|
+
else if ((0, utils_1.isLayoutComponent)(component) && typeof component.everyComponent === 'function') {
|
|
167
|
+
component.everyComponent((comp) => {
|
|
168
|
+
row += getHeaderCell(comp);
|
|
169
|
+
}, options);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return `<thead><tr>${row}</tr></thead>`;
|
|
173
|
+
}
|
|
174
|
+
_getEmailTableBody(options) {
|
|
175
|
+
const getBodyCell = (component) => {
|
|
176
|
+
if (!component.isInputComponent || !component.visible || component.skipInEmail) {
|
|
177
|
+
return '';
|
|
178
|
+
}
|
|
179
|
+
return `<td style="padding: 5px 10px;">${component.getView(component.dataValue, options)}</td>`;
|
|
180
|
+
};
|
|
181
|
+
const rows = [];
|
|
182
|
+
for (const { components } of this.iteratableRows) {
|
|
183
|
+
let row = '';
|
|
184
|
+
for (const component of components) {
|
|
185
|
+
if (component.isInputComponent) {
|
|
186
|
+
row += getBodyCell(component);
|
|
187
|
+
}
|
|
188
|
+
else if ((0, utils_1.isLayoutComponent)(component) && typeof component.everyComponent === 'function') {
|
|
189
|
+
component.everyComponent((comp) => {
|
|
190
|
+
row += getBodyCell(comp);
|
|
191
|
+
}, options);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
rows.push(`<tr>${row}</tr>`);
|
|
195
|
+
}
|
|
196
|
+
return `<tbody>${rows.join('')}</tbody>`;
|
|
197
|
+
}
|
|
152
198
|
getValueAsString(value, options) {
|
|
153
|
-
var _a;
|
|
154
199
|
if (options === null || options === void 0 ? void 0 : options.email) {
|
|
155
|
-
|
|
200
|
+
return `
|
|
156
201
|
<table border="1" style="width:100%">
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
`);
|
|
160
|
-
(_a = this.component.components) === null || _a === void 0 ? void 0 : _a.forEach((component) => {
|
|
161
|
-
const label = component.label || component.key;
|
|
162
|
-
result += `<th style="padding: 5px 10px;">${label}</th>`;
|
|
163
|
-
});
|
|
164
|
-
result += (`
|
|
165
|
-
</tr>
|
|
166
|
-
</thead>
|
|
167
|
-
<tbody>
|
|
168
|
-
`);
|
|
169
|
-
this.iteratableRows.forEach(({ components }) => {
|
|
170
|
-
result += '<tr>';
|
|
171
|
-
lodash_1.default.each(components, (component) => {
|
|
172
|
-
result += '<td style="padding:5px 10px;">';
|
|
173
|
-
if (component.isInputComponent && component.visible && !component.skipInEmail) {
|
|
174
|
-
result += component.getView(component.dataValue, options);
|
|
175
|
-
}
|
|
176
|
-
result += '</td>';
|
|
177
|
-
});
|
|
178
|
-
result += '</tr>';
|
|
179
|
-
});
|
|
180
|
-
result += (`
|
|
181
|
-
</tbody>
|
|
202
|
+
${this._getEmailTableHeader(options)}
|
|
203
|
+
${this._getEmailTableBody(options)}
|
|
182
204
|
</table>
|
|
183
|
-
|
|
184
|
-
return result;
|
|
205
|
+
`;
|
|
185
206
|
}
|
|
186
207
|
if (!value || !value.length) {
|
|
187
208
|
return '';
|
|
@@ -197,5 +218,11 @@ class NestedArrayComponent extends NestedDataComponent_1.default {
|
|
|
197
218
|
}
|
|
198
219
|
return super.getComponents();
|
|
199
220
|
}
|
|
221
|
+
removeSubmissionMetadataRow(index) {
|
|
222
|
+
const componentMetadata = lodash_1.default.get(this.root, `submission.metadata.selectData.${this.path}`, null);
|
|
223
|
+
if (lodash_1.default.isArray(componentMetadata)) {
|
|
224
|
+
componentMetadata.splice(index, 1);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
200
227
|
}
|
|
201
228
|
exports.default = NestedArrayComponent;
|
|
@@ -11,6 +11,12 @@ export default class AddressComponent extends ContainerComponent {
|
|
|
11
11
|
weight: number;
|
|
12
12
|
schema: any;
|
|
13
13
|
};
|
|
14
|
+
static get serverConditionSettings(): {
|
|
15
|
+
operators: string[];
|
|
16
|
+
};
|
|
17
|
+
static get conditionOperatorsSettings(): {
|
|
18
|
+
operators: string[];
|
|
19
|
+
};
|
|
14
20
|
static get modeSwitcherRef(): string;
|
|
15
21
|
static get removeValueIconRef(): string;
|
|
16
22
|
static get searchInputRef(): string;
|
|
@@ -97,6 +97,12 @@ class AddressComponent extends Container_1.default {
|
|
|
97
97
|
schema: AddressComponent.schema(),
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
|
+
static get serverConditionSettings() {
|
|
101
|
+
return AddressComponent.conditionOperatorsSettings;
|
|
102
|
+
}
|
|
103
|
+
static get conditionOperatorsSettings() {
|
|
104
|
+
return Object.assign(Object.assign({}, super.conditionOperatorsSettings), { operators: ['isEmpty', 'isNotEmpty'] });
|
|
105
|
+
}
|
|
100
106
|
mergeSchema(component = {}) {
|
|
101
107
|
let { defaultSchema } = this;
|
|
102
108
|
if (component.components) {
|
|
@@ -113,6 +119,10 @@ class AddressComponent extends Container_1.default {
|
|
|
113
119
|
if (!this.builderMode) {
|
|
114
120
|
if (this.component.provider) {
|
|
115
121
|
const { provider, providerOptions, } = this.component;
|
|
122
|
+
if (lodash_1.default.get(providerOptions, 'params.subscriptionKey')) {
|
|
123
|
+
lodash_1.default.set(providerOptions, "params['subscription-key']", lodash_1.default.get(providerOptions, 'params.subscriptionKey'));
|
|
124
|
+
lodash_1.default.unset(providerOptions, 'params.subscriptionKey');
|
|
125
|
+
}
|
|
116
126
|
this.provider = this.initializeProvider(provider, providerOptions);
|
|
117
127
|
}
|
|
118
128
|
else if (this.component.map) {
|
|
@@ -184,7 +194,7 @@ class AddressComponent extends Container_1.default {
|
|
|
184
194
|
return (this.manualModeEnabled && this.dataValue) ? this.dataValue.address : this.dataValue;
|
|
185
195
|
}
|
|
186
196
|
set address(value) {
|
|
187
|
-
if (this.manualModeEnabled && !this.isMultiple) {
|
|
197
|
+
if (this.manualModeEnabled && !this.isMultiple && !lodash_1.default.isEqual(value, this.emptyValue)) {
|
|
188
198
|
this.dataValue.address = value;
|
|
189
199
|
}
|
|
190
200
|
else {
|
|
@@ -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 |
|
|
46
|
+
get emptyValue(): false | "";
|
|
47
47
|
getValueAt(index: any): any;
|
|
48
48
|
get checked(): boolean;
|
|
49
49
|
setCheckedState(value: any): any;
|
|
@@ -117,7 +117,7 @@ class CheckBoxComponent extends Field_1.default {
|
|
|
117
117
|
super.detach();
|
|
118
118
|
}
|
|
119
119
|
get emptyValue() {
|
|
120
|
-
return this.component.inputType === 'radio' ?
|
|
120
|
+
return this.component.inputType === 'radio' ? '' : false;
|
|
121
121
|
}
|
|
122
122
|
isEmpty(value = this.dataValue) {
|
|
123
123
|
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,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
name: 'ckeckbox',
|
|
5
|
+
path: 'ckeckbox',
|
|
6
|
+
type: 'form',
|
|
7
|
+
display: 'form',
|
|
8
|
+
components: [
|
|
9
|
+
{
|
|
10
|
+
label: 'Checkbox',
|
|
11
|
+
inputType: 'radio',
|
|
12
|
+
tableView: false,
|
|
13
|
+
defaultValue: false,
|
|
14
|
+
key: 'checkbox',
|
|
15
|
+
type: 'checkbox',
|
|
16
|
+
name: 'some name',
|
|
17
|
+
value: 'ok',
|
|
18
|
+
input: true,
|
|
19
|
+
'some name': false
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
type: 'button',
|
|
23
|
+
label: 'Submit',
|
|
24
|
+
key: 'submit',
|
|
25
|
+
disableOnInvalid: true,
|
|
26
|
+
input: true,
|
|
27
|
+
tableView: false
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
};
|
|
@@ -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 };
|
|
@@ -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.customDefaultComponent = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
|
|
6
|
+
exports.customDefaultComponent = exports.comp6 = exports.comp5 = exports.comp4 = 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 customDefaultComponent_1 = __importDefault(require("./customDefaultComponent"));
|
|
@@ -16,3 +16,5 @@ const comp4_1 = __importDefault(require("./comp4"));
|
|
|
16
16
|
exports.comp4 = comp4_1.default;
|
|
17
17
|
const comp5_1 = __importDefault(require("./comp5"));
|
|
18
18
|
exports.comp5 = comp5_1.default;
|
|
19
|
+
const comp6_1 = __importDefault(require("./comp6"));
|
|
20
|
+
exports.comp6 = comp6_1.default;
|
|
@@ -2,6 +2,8 @@ export default class CurrencyComponent extends NumberComponent {
|
|
|
2
2
|
constructor(component: any, options: any, data: any);
|
|
3
3
|
currencyPrefix: any;
|
|
4
4
|
currencySuffix: any;
|
|
5
|
+
parseNumber(value: any): number;
|
|
6
|
+
parseValue(value: any): string | null;
|
|
5
7
|
addZerosAndFormatValue(value: any): any;
|
|
6
8
|
stripPrefixSuffix(value: any): any;
|
|
7
9
|
}
|
|
@@ -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[];
|
|
@@ -58,10 +59,19 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
58
59
|
getRows(): {}[];
|
|
59
60
|
getColumns(): any[];
|
|
60
61
|
hasHeader(): any;
|
|
61
|
-
loadRefs(element: any, refs: any): void;
|
|
62
62
|
dragula: any;
|
|
63
63
|
getComponentsContainer(): any;
|
|
64
|
+
/**
|
|
65
|
+
* Reorder values in array based on the old and new position
|
|
66
|
+
* @param {any} valuesArr - An array of values.
|
|
67
|
+
* @param {number} oldPosition - The index of the value in array before reordering.
|
|
68
|
+
* @param {number} newPosition - The index of the value in array after reordering.
|
|
69
|
+
* @param {boolean|any} movedBelow - Whether or not the value is moved below.
|
|
70
|
+
* @returns {void}
|
|
71
|
+
*/
|
|
72
|
+
reorderValues(valuesArr: any, oldPosition: number, newPosition: number, movedBelow: boolean | any): void;
|
|
64
73
|
onReorder(element: any, _target: any, _source: any, sibling: any): void;
|
|
74
|
+
onCloned(el: any, original: any): void;
|
|
65
75
|
focusOnNewRowElement(row: any): void;
|
|
66
76
|
addRow(): void;
|
|
67
77
|
updateComponentsRowIndex(components: any, rowIndex: any): void;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const lodash_1 = __importDefault(require("lodash"));
|
|
7
7
|
const NestedArrayComponent_1 = __importDefault(require("../_classes/nestedarray/NestedArrayComponent"));
|
|
8
8
|
const utils_1 = require("../../utils/utils");
|
|
9
|
-
const Components_1 = require("../Components");
|
|
9
|
+
const Components_1 = __importDefault(require("../Components"));
|
|
10
10
|
class DataGridComponent extends NestedArrayComponent_1.default {
|
|
11
11
|
static schema(...extend) {
|
|
12
12
|
return NestedArrayComponent_1.default.schema({
|
|
@@ -43,6 +43,9 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
43
43
|
if (this.initRows || !lodash_1.default.isEqual(this.dataValue, this.emptyValue)) {
|
|
44
44
|
this.createRows(true);
|
|
45
45
|
}
|
|
46
|
+
if (this.allowReorder) {
|
|
47
|
+
this.dragulaReady = this.getDragula();
|
|
48
|
+
}
|
|
46
49
|
this.visibleColumns = {};
|
|
47
50
|
this.prevHasAddButton = this.hasAddButton();
|
|
48
51
|
this.checkColumns();
|
|
@@ -260,13 +263,6 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
260
263
|
return hasHeader || ((col.label || col.title) && !col.hideLabel);
|
|
261
264
|
}, false);
|
|
262
265
|
}
|
|
263
|
-
loadRefs(element, refs) {
|
|
264
|
-
super.loadRefs(element, refs);
|
|
265
|
-
if (refs['messageContainer'] === 'single') {
|
|
266
|
-
const container = lodash_1.default.last(element.querySelectorAll(`[${this._referenceAttributeName}=messageContainer]`));
|
|
267
|
-
this.refs['messageContainer'] = container || this.refs['messageContainer'];
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
266
|
attach(element) {
|
|
271
267
|
this.loadRefs(element, {
|
|
272
268
|
[`${this.datagridKey}-row`]: 'multiple',
|
|
@@ -275,14 +271,20 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
275
271
|
[`${this.datagridKey}-removeRow`]: 'multiple',
|
|
276
272
|
[`${this.datagridKey}-group-header`]: 'multiple',
|
|
277
273
|
[this.datagridKey]: 'multiple',
|
|
278
|
-
'messageContainer': 'single'
|
|
279
274
|
});
|
|
280
275
|
if (this.allowReorder) {
|
|
281
276
|
this.refs[`${this.datagridKey}-row`].forEach((row, index) => {
|
|
282
277
|
row.dragInfo = { index };
|
|
283
278
|
});
|
|
284
|
-
|
|
285
|
-
|
|
279
|
+
this.dragulaReady.then((dragula) => {
|
|
280
|
+
// The drop event may call redraw twice which calls attach twice and because this block of code is asynchronous
|
|
281
|
+
// BOTH redraws may be called before this block of code runs (which causes this block of code to run twice sequentially).
|
|
282
|
+
// This causes two dragula() calls on the same container which breaks dragula. To fix this the return value must
|
|
283
|
+
// be saved in this.dragula and have its container contents reset if it exists
|
|
284
|
+
if (this.dragula && this.dragula.containers) {
|
|
285
|
+
this.dragula.containers = [];
|
|
286
|
+
}
|
|
287
|
+
this.dragula = dragula([this.refs[`${this.datagridKey}-tbody`]], {
|
|
286
288
|
moves: (_draggedElement, _oldParent, clickedElement) => {
|
|
287
289
|
const clickedElementKey = clickedElement.getAttribute('data-key');
|
|
288
290
|
const oldParentKey = _oldParent.getAttribute('data-key');
|
|
@@ -291,24 +293,9 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
291
293
|
return clickedElement.classList.contains('formio-drag-button');
|
|
292
294
|
}
|
|
293
295
|
}
|
|
294
|
-
}).on('drop', this.onReorder.bind(this))
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
lodash_1.default.each(original.children, (child, index) => {
|
|
298
|
-
const styles = getComputedStyle(child, null);
|
|
299
|
-
if (styles.cssText !== '') {
|
|
300
|
-
el.children[index].style.cssText = styles.cssText;
|
|
301
|
-
}
|
|
302
|
-
else {
|
|
303
|
-
const cssText = Object.values(styles).reduce((css, propertyName) => {
|
|
304
|
-
return `${css}${propertyName}:${styles.getPropertyValue(propertyName)};`;
|
|
305
|
-
}, '');
|
|
306
|
-
el.children[index].style.cssText = cssText;
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
}
|
|
296
|
+
}).on('drop', this.onReorder.bind(this))
|
|
297
|
+
.on('cloned', this.onCloned.bind(this));
|
|
298
|
+
});
|
|
312
299
|
}
|
|
313
300
|
this.refs[`${this.datagridKey}-addRow`].forEach((addButton) => {
|
|
314
301
|
this.addEventListener(addButton, 'click', this.addRow.bind(this));
|
|
@@ -336,6 +323,24 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
336
323
|
getComponentsContainer() {
|
|
337
324
|
return this.component.components;
|
|
338
325
|
}
|
|
326
|
+
/**
|
|
327
|
+
* Reorder values in array based on the old and new position
|
|
328
|
+
* @param {any} valuesArr - An array of values.
|
|
329
|
+
* @param {number} oldPosition - The index of the value in array before reordering.
|
|
330
|
+
* @param {number} newPosition - The index of the value in array after reordering.
|
|
331
|
+
* @param {boolean|any} movedBelow - Whether or not the value is moved below.
|
|
332
|
+
* @returns {void}
|
|
333
|
+
*/
|
|
334
|
+
reorderValues(valuesArr, oldPosition, newPosition, movedBelow) {
|
|
335
|
+
if (!lodash_1.default.isArray(valuesArr) || lodash_1.default.isEmpty(valuesArr)) {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
const draggedRowData = valuesArr[oldPosition];
|
|
339
|
+
//insert element at new position
|
|
340
|
+
valuesArr.splice(newPosition, 0, draggedRowData);
|
|
341
|
+
//remove element from old position (if was moved above, after insertion it's at +1 index)
|
|
342
|
+
valuesArr.splice(movedBelow ? oldPosition : oldPosition + 1, 1);
|
|
343
|
+
}
|
|
339
344
|
onReorder(element, _target, _source, sibling) {
|
|
340
345
|
if (!element.dragInfo || (sibling && !sibling.dragInfo)) {
|
|
341
346
|
console.warn('There is no Drag Info available for either dragged or sibling element');
|
|
@@ -346,15 +351,32 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
346
351
|
const newPosition = sibling ? sibling.dragInfo.index : this.dataValue.length;
|
|
347
352
|
const movedBelow = newPosition > oldPosition;
|
|
348
353
|
const dataValue = (0, utils_1.fastCloneDeep)(this.dataValue);
|
|
349
|
-
|
|
350
|
-
//
|
|
351
|
-
|
|
352
|
-
//
|
|
353
|
-
|
|
354
|
+
this.reorderValues(dataValue, oldPosition, newPosition, movedBelow);
|
|
355
|
+
//reorder select data
|
|
356
|
+
this.reorderValues(lodash_1.default.get(this.root, `submission.metadata.selectData.${this.path}`, []), oldPosition, newPosition, movedBelow);
|
|
357
|
+
// When components are reordered we need to set the dataGrid and form pristine properties to false
|
|
358
|
+
this.root.pristine = false;
|
|
359
|
+
this.pristine = false;
|
|
354
360
|
//need to re-build rows to re-calculate indexes and other indexed fields for component instance (like rows for ex.)
|
|
355
361
|
this.setValue(dataValue, { isReordered: true });
|
|
356
362
|
this.rebuild();
|
|
357
363
|
}
|
|
364
|
+
onCloned(el, original) {
|
|
365
|
+
if (el && el.children && original && original.children) {
|
|
366
|
+
lodash_1.default.each(original.children, (child, index) => {
|
|
367
|
+
const styles = getComputedStyle(child, null);
|
|
368
|
+
if (styles.cssText !== '') {
|
|
369
|
+
el.children[index].style.cssText = styles.cssText;
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
const cssText = Object.values(styles).reduce((css, propertyName) => {
|
|
373
|
+
return `${css}${propertyName}:${styles.getPropertyValue(propertyName)};`;
|
|
374
|
+
}, '');
|
|
375
|
+
el.children[index].style.cssText = cssText;
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
}
|
|
358
380
|
focusOnNewRowElement(row) {
|
|
359
381
|
Object.keys(row).find((key) => {
|
|
360
382
|
const element = row[key].element;
|
|
@@ -404,7 +426,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
404
426
|
}
|
|
405
427
|
component.rowIndex = rowIndex;
|
|
406
428
|
component.row = `${rowIndex}-${colIndex}`;
|
|
407
|
-
component.path = Components_1.
|
|
429
|
+
component.path = Components_1.default.getComponentPath(component);
|
|
408
430
|
});
|
|
409
431
|
}
|
|
410
432
|
updateRowsComponents(rowIndex) {
|
|
@@ -414,10 +436,11 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
414
436
|
}
|
|
415
437
|
removeRow(index) {
|
|
416
438
|
const makeEmpty = index === 0 && this.rows.length === 1;
|
|
417
|
-
const flags = { isReordered: !makeEmpty, resetValue: makeEmpty };
|
|
439
|
+
const flags = { isReordered: !makeEmpty, resetValue: makeEmpty, modified: true };
|
|
418
440
|
this.splice(index, flags);
|
|
419
441
|
this.emit('dataGridDeleteRow', { index });
|
|
420
442
|
const [row] = this.rows.splice(index, 1);
|
|
443
|
+
this.removeSubmissionMetadataRow(index);
|
|
421
444
|
this.removeRowComponents(row);
|
|
422
445
|
this.updateRowsComponents(index);
|
|
423
446
|
this.setValue(this.dataValue, flags);
|