@formio/js 5.0.0-dev.5661.22d0f16 → 5.0.0-dev.5664.50b8944
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 +21 -2
- package/dist/formio.form.js +111 -15
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +15 -15
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.js +2 -2
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +1 -1
- package/dist/formio.utils.min.js +1 -1
- package/lib/cjs/Formio.js +1 -0
- package/lib/cjs/Webform.d.ts +7 -0
- package/lib/cjs/Webform.js +18 -5
- package/lib/cjs/components/_classes/component/Component.d.ts +13 -0
- package/lib/cjs/components/_classes/component/Component.js +27 -13
- 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 +1 -1
- package/lib/cjs/components/_classes/multivalue/Multivalue.js +8 -1
- package/lib/cjs/components/datagrid/DataGrid.d.ts +9 -0
- package/lib/cjs/components/datagrid/DataGrid.js +50 -32
- 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/comp9.d.ts +41 -0
- package/lib/cjs/components/datagrid/fixtures/comp9.js +44 -0
- package/lib/cjs/components/datagrid/fixtures/index.d.ts +3 -1
- package/lib/cjs/components/datagrid/fixtures/index.js +5 -1
- package/lib/cjs/components/day/Day.d.ts +1 -1
- package/lib/cjs/components/day/Day.js +1 -1
- package/lib/cjs/components/day/fixtures/comp7.d.ts +109 -0
- package/lib/cjs/components/day/fixtures/comp7.js +109 -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 +2 -2
- package/lib/cjs/components/form/Form.d.ts +7 -0
- package/lib/cjs/components/form/Form.js +10 -1
- package/lib/cjs/components/number/Number.js +1 -1
- 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/index.d.ts +2 -1
- package/lib/cjs/components/number/fixtures/index.js +3 -1
- 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/select/Select.js +1 -2
- package/lib/cjs/components/signature/Signature.d.ts +0 -1
- package/lib/cjs/components/signature/Signature.js +1 -1
- package/lib/cjs/providers/address/GoogleAddressProvider.d.ts +5 -0
- package/lib/cjs/providers/address/GoogleAddressProvider.js +23 -1
- package/lib/cjs/utils/utils.js +0 -4
- package/lib/mjs/Formio.js +1 -0
- package/lib/mjs/Webform.d.ts +7 -0
- package/lib/mjs/Webform.js +18 -5
- package/lib/mjs/components/_classes/component/Component.d.ts +13 -0
- package/lib/mjs/components/_classes/component/Component.js +35 -13
- 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 +1 -1
- package/lib/mjs/components/_classes/multivalue/Multivalue.js +8 -1
- package/lib/mjs/components/datagrid/DataGrid.d.ts +9 -0
- package/lib/mjs/components/datagrid/DataGrid.js +50 -32
- 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/comp9.d.ts +41 -0
- package/lib/mjs/components/datagrid/fixtures/comp9.js +42 -0
- package/lib/mjs/components/datagrid/fixtures/index.d.ts +3 -1
- package/lib/mjs/components/datagrid/fixtures/index.js +3 -1
- package/lib/mjs/components/day/Day.d.ts +1 -1
- package/lib/mjs/components/day/Day.js +1 -1
- package/lib/mjs/components/day/fixtures/comp7.d.ts +109 -0
- package/lib/mjs/components/day/fixtures/comp7.js +107 -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 +2 -2
- package/lib/mjs/components/form/Form.d.ts +7 -0
- package/lib/mjs/components/form/Form.js +10 -1
- package/lib/mjs/components/number/Number.js +1 -1
- 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/index.d.ts +2 -1
- package/lib/mjs/components/number/fixtures/index.js +2 -1
- 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/select/Select.js +1 -2
- package/lib/mjs/components/signature/Signature.d.ts +0 -1
- package/lib/mjs/components/signature/Signature.js +1 -1
- package/lib/mjs/providers/address/GoogleAddressProvider.d.ts +5 -0
- package/lib/mjs/providers/address/GoogleAddressProvider.js +22 -1
- package/lib/mjs/utils/utils.js +0 -4
- package/package.json +1 -2
package/lib/cjs/Formio.js
CHANGED
package/lib/cjs/Webform.d.ts
CHANGED
|
@@ -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
|
+
* @returns {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.
|
package/lib/cjs/Webform.js
CHANGED
|
@@ -13,6 +13,7 @@ const Components_1 = __importDefault(require("./components/Components"));
|
|
|
13
13
|
const NestedDataComponent_1 = __importDefault(require("./components/_classes/nesteddata/NestedDataComponent"));
|
|
14
14
|
const utils_1 = require("./utils/utils");
|
|
15
15
|
const formUtils_1 = require("./utils/formUtils");
|
|
16
|
+
const dragula_1 = __importDefault(require("dragula"));
|
|
16
17
|
// Initialize the available forms.
|
|
17
18
|
Formio_1.Formio.forms = {};
|
|
18
19
|
// Allow people to register components.
|
|
@@ -309,6 +310,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
309
310
|
// Ensure the root is set to this component.
|
|
310
311
|
this.root = this;
|
|
311
312
|
this.localRoot = this;
|
|
313
|
+
this.root.dragulaLib = dragula_1.default;
|
|
312
314
|
}
|
|
313
315
|
/* eslint-enable max-statements */
|
|
314
316
|
get language() {
|
|
@@ -698,6 +700,18 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
698
700
|
set submission(submission) {
|
|
699
701
|
this.setSubmission(submission);
|
|
700
702
|
}
|
|
703
|
+
/**
|
|
704
|
+
* Sets the submission value
|
|
705
|
+
* @param {object|null|undefined} submission - The submission to set.
|
|
706
|
+
* @param {object|null|undefined} flags - Any flags to apply when setting the submission.
|
|
707
|
+
* @returns {void}
|
|
708
|
+
*/
|
|
709
|
+
onSetSubmission(submission, flags = {}) {
|
|
710
|
+
this.submissionSet = true;
|
|
711
|
+
this.triggerChange(flags);
|
|
712
|
+
this.emit('beforeSetSubmission', submission);
|
|
713
|
+
this.setValue(submission, flags);
|
|
714
|
+
}
|
|
701
715
|
/**
|
|
702
716
|
* Sets a submission and returns the promise when it is ready.
|
|
703
717
|
* @param {any} submission - The submission to set.
|
|
@@ -711,10 +725,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
711
725
|
if (resolveFlags) {
|
|
712
726
|
flags = Object.assign(Object.assign({}, flags), resolveFlags);
|
|
713
727
|
}
|
|
714
|
-
this.
|
|
715
|
-
this.triggerChange(flags);
|
|
716
|
-
this.emit("beforeSetSubmission", submission);
|
|
717
|
-
this.setValue(submission, flags);
|
|
728
|
+
this.onSetSubmission(submission, flags);
|
|
718
729
|
return this.submissionReadyResolve(submission);
|
|
719
730
|
}, (err) => this.submissionReadyReject(err))
|
|
720
731
|
.catch((err) => this.submissionReadyReject(err)));
|
|
@@ -873,7 +884,9 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
873
884
|
this.addComponents();
|
|
874
885
|
this.on("submitButton", (options) => {
|
|
875
886
|
this.submit(false, options).catch((e) => {
|
|
876
|
-
options.instance
|
|
887
|
+
if (options === null || options === void 0 ? void 0 : options.instance) {
|
|
888
|
+
options.instance.loading = false;
|
|
889
|
+
}
|
|
877
890
|
return e !== false && e !== undefined && console.log(e);
|
|
878
891
|
});
|
|
879
892
|
}, true);
|
|
@@ -343,6 +343,12 @@ declare class Component extends Element {
|
|
|
343
343
|
* @param {string} template - The template to use for the modal dialog.
|
|
344
344
|
*/
|
|
345
345
|
setOpenModalElement(template?: string): void;
|
|
346
|
+
/**
|
|
347
|
+
* Renders a modal preview template and returns the markup as a string
|
|
348
|
+
* @param {object|null|undefined} ctx - The rendering context
|
|
349
|
+
* @returns {string} - The modal preview markup
|
|
350
|
+
*/
|
|
351
|
+
renderModalPreview(ctx: object | null | undefined): string;
|
|
346
352
|
/**
|
|
347
353
|
* Returns the modal preview template.
|
|
348
354
|
* @returns {string} - The modal preview template.
|
|
@@ -362,6 +368,13 @@ declare class Component extends Element {
|
|
|
362
368
|
* @returns {string} - The rendered HTML string of a component.
|
|
363
369
|
*/
|
|
364
370
|
render(children?: string, topLevel?: boolean): string;
|
|
371
|
+
/**
|
|
372
|
+
* Creates the tooltip instance using tippy.js and returns it
|
|
373
|
+
* @param {HTMLElement} tooltipEl - HTML element to attach the tooltip
|
|
374
|
+
* @param {object|null|undefined} settings - tippy.js options
|
|
375
|
+
* @returns {import('tippy.js').Tippy} - tippy.js instance
|
|
376
|
+
*/
|
|
377
|
+
createTooltip(tooltipEl: HTMLElement, settings?: object | null | undefined): import('tippy.js').Tippy;
|
|
365
378
|
/**
|
|
366
379
|
* Attaches all the tooltips provided the refs object.
|
|
367
380
|
* @param {object} toolTipsRefs - The refs for the tooltips within your template.
|
|
@@ -1046,6 +1046,14 @@ class Component extends Element_1.default {
|
|
|
1046
1046
|
setOpenModalElement(template = null) {
|
|
1047
1047
|
this.componentModal.setOpenModalElement(template || this.getModalPreviewTemplate());
|
|
1048
1048
|
}
|
|
1049
|
+
/**
|
|
1050
|
+
* Renders a modal preview template and returns the markup as a string
|
|
1051
|
+
* @param {object|null|undefined} ctx - The rendering context
|
|
1052
|
+
* @returns {string} - The modal preview markup
|
|
1053
|
+
*/
|
|
1054
|
+
renderModalPreview(ctx) {
|
|
1055
|
+
return this.renderTemplate('modalPreview', ctx || {});
|
|
1056
|
+
}
|
|
1049
1057
|
/**
|
|
1050
1058
|
* Returns the modal preview template.
|
|
1051
1059
|
* @returns {string} - The modal preview template.
|
|
@@ -1057,7 +1065,7 @@ class Component extends Element_1.default {
|
|
|
1057
1065
|
if (this.hasInput && ((_a = this.component.validate) === null || _a === void 0 ? void 0 : _a.required) && !this.isPDFReadOnlyMode) {
|
|
1058
1066
|
modalLabel = { className: 'field-required' };
|
|
1059
1067
|
}
|
|
1060
|
-
return this.
|
|
1068
|
+
return this.renderModalPreview({
|
|
1061
1069
|
previewText: this.getValueAsString(dataValue, { modalPreview: true }) || this.t('Click to set value'),
|
|
1062
1070
|
messages: '',
|
|
1063
1071
|
labelInfo: modalLabel,
|
|
@@ -1106,6 +1114,19 @@ class Component extends Element_1.default {
|
|
|
1106
1114
|
}, topLevel);
|
|
1107
1115
|
}
|
|
1108
1116
|
}
|
|
1117
|
+
/**
|
|
1118
|
+
* Creates the tooltip instance using tippy.js and returns it
|
|
1119
|
+
* @param {HTMLElement} tooltipEl - HTML element to attach the tooltip
|
|
1120
|
+
* @param {object|null|undefined} settings - tippy.js options
|
|
1121
|
+
* @returns {import('tippy.js').Tippy} - tippy.js instance
|
|
1122
|
+
*/
|
|
1123
|
+
createTooltip(tooltipEl, settings = {}) {
|
|
1124
|
+
const tooltipAttribute = tooltipEl.getAttribute('data-tooltip');
|
|
1125
|
+
const tooltipDataTitle = tooltipEl.getAttribute('data-title');
|
|
1126
|
+
const tooltipText = this.interpolate(tooltipDataTitle || tooltipAttribute)
|
|
1127
|
+
.replace(/(?:\r\n|\r|\n)/g, '<br />');
|
|
1128
|
+
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 }) }));
|
|
1129
|
+
}
|
|
1109
1130
|
/**
|
|
1110
1131
|
* Attaches all the tooltips provided the refs object.
|
|
1111
1132
|
* @param {object} toolTipsRefs - The refs for the tooltips within your template.
|
|
@@ -1114,18 +1135,7 @@ class Component extends Element_1.default {
|
|
|
1114
1135
|
attachTooltips(toolTipsRefs) {
|
|
1115
1136
|
toolTipsRefs === null || toolTipsRefs === void 0 ? void 0 : toolTipsRefs.forEach((tooltip, index) => {
|
|
1116
1137
|
if (tooltip) {
|
|
1117
|
-
|
|
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
|
-
});
|
|
1138
|
+
this.tooltips[index] = this.createTooltip(tooltip);
|
|
1129
1139
|
}
|
|
1130
1140
|
});
|
|
1131
1141
|
}
|
|
@@ -3378,6 +3388,10 @@ class Component extends Element_1.default {
|
|
|
3378
3388
|
const disabled = this.shouldDisabled;
|
|
3379
3389
|
// Change states which won't be recalculated during redrawing
|
|
3380
3390
|
if (this.visible !== visible) {
|
|
3391
|
+
// If the logic is triggered by an event and the action sets the hidden state then the original
|
|
3392
|
+
// component definition must be changed so that the components hidden state does not get flipped back by
|
|
3393
|
+
// the fieldLogic function
|
|
3394
|
+
this.originalComponent.hidden = !visible;
|
|
3381
3395
|
this.visible = visible;
|
|
3382
3396
|
}
|
|
3383
3397
|
if (this.disabled !== disabled) {
|
|
@@ -190,5 +190,13 @@ exports.default = [
|
|
|
190
190
|
key: 'tableView',
|
|
191
191
|
input: true
|
|
192
192
|
},
|
|
193
|
+
{
|
|
194
|
+
weight: 1600,
|
|
195
|
+
type: 'checkbox',
|
|
196
|
+
label: 'Modal Edit',
|
|
197
|
+
tooltip: 'Opens up a modal to edit the value of this component.',
|
|
198
|
+
key: 'modalEdit',
|
|
199
|
+
input: true
|
|
200
|
+
}
|
|
193
201
|
];
|
|
194
202
|
/* eslint-enable max-len */
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
declare namespace _default {
|
|
2
|
+
let components: ({
|
|
3
|
+
label: string;
|
|
4
|
+
action: string;
|
|
5
|
+
showValidations: boolean;
|
|
6
|
+
tableView: boolean;
|
|
7
|
+
key: string;
|
|
8
|
+
type: string;
|
|
9
|
+
event: string;
|
|
10
|
+
input: boolean;
|
|
11
|
+
theme?: undefined;
|
|
12
|
+
collapsible?: undefined;
|
|
13
|
+
hidden?: undefined;
|
|
14
|
+
logic?: undefined;
|
|
15
|
+
collapsed?: undefined;
|
|
16
|
+
components?: undefined;
|
|
17
|
+
applyMaskOn?: undefined;
|
|
18
|
+
} | {
|
|
19
|
+
label: string;
|
|
20
|
+
action: string;
|
|
21
|
+
showValidations: boolean;
|
|
22
|
+
theme: string;
|
|
23
|
+
tableView: boolean;
|
|
24
|
+
key: string;
|
|
25
|
+
type: string;
|
|
26
|
+
event: string;
|
|
27
|
+
input: boolean;
|
|
28
|
+
collapsible?: undefined;
|
|
29
|
+
hidden?: undefined;
|
|
30
|
+
logic?: undefined;
|
|
31
|
+
collapsed?: undefined;
|
|
32
|
+
components?: undefined;
|
|
33
|
+
applyMaskOn?: undefined;
|
|
34
|
+
} | {
|
|
35
|
+
collapsible: boolean;
|
|
36
|
+
hidden: boolean;
|
|
37
|
+
key: string;
|
|
38
|
+
logic: {
|
|
39
|
+
name: string;
|
|
40
|
+
trigger: {
|
|
41
|
+
type: string;
|
|
42
|
+
event: string;
|
|
43
|
+
};
|
|
44
|
+
actions: {
|
|
45
|
+
name: string;
|
|
46
|
+
type: string;
|
|
47
|
+
property: {
|
|
48
|
+
label: string;
|
|
49
|
+
value: string;
|
|
50
|
+
type: string;
|
|
51
|
+
};
|
|
52
|
+
state: boolean;
|
|
53
|
+
}[];
|
|
54
|
+
}[];
|
|
55
|
+
type: string;
|
|
56
|
+
label: string;
|
|
57
|
+
collapsed: boolean;
|
|
58
|
+
input: boolean;
|
|
59
|
+
tableView: boolean;
|
|
60
|
+
components: never[];
|
|
61
|
+
action?: undefined;
|
|
62
|
+
showValidations?: undefined;
|
|
63
|
+
event?: undefined;
|
|
64
|
+
theme?: undefined;
|
|
65
|
+
applyMaskOn?: undefined;
|
|
66
|
+
} | {
|
|
67
|
+
label: string;
|
|
68
|
+
applyMaskOn: string;
|
|
69
|
+
tableView: boolean;
|
|
70
|
+
key: string;
|
|
71
|
+
type: string;
|
|
72
|
+
input: boolean;
|
|
73
|
+
action?: undefined;
|
|
74
|
+
showValidations?: undefined;
|
|
75
|
+
event?: undefined;
|
|
76
|
+
theme?: undefined;
|
|
77
|
+
collapsible?: undefined;
|
|
78
|
+
hidden?: undefined;
|
|
79
|
+
logic?: undefined;
|
|
80
|
+
collapsed?: undefined;
|
|
81
|
+
components?: undefined;
|
|
82
|
+
})[];
|
|
83
|
+
}
|
|
84
|
+
export default _default;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
components: [
|
|
5
|
+
{
|
|
6
|
+
"label": "Show",
|
|
7
|
+
"action": "event",
|
|
8
|
+
"showValidations": false,
|
|
9
|
+
"tableView": false,
|
|
10
|
+
"key": "show",
|
|
11
|
+
"type": "button",
|
|
12
|
+
"event": "show",
|
|
13
|
+
"input": true
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"label": "Hide",
|
|
17
|
+
"action": "event",
|
|
18
|
+
"showValidations": false,
|
|
19
|
+
"theme": "danger",
|
|
20
|
+
"tableView": false,
|
|
21
|
+
"key": "hide",
|
|
22
|
+
"type": "button",
|
|
23
|
+
"event": "hide",
|
|
24
|
+
"input": true
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"collapsible": true,
|
|
28
|
+
"hidden": true,
|
|
29
|
+
"key": "panel",
|
|
30
|
+
"logic": [
|
|
31
|
+
{
|
|
32
|
+
"name": "ShowPanel",
|
|
33
|
+
"trigger": {
|
|
34
|
+
"type": "event",
|
|
35
|
+
"event": "show"
|
|
36
|
+
},
|
|
37
|
+
"actions": [
|
|
38
|
+
{
|
|
39
|
+
"name": "Show",
|
|
40
|
+
"type": "property",
|
|
41
|
+
"property": {
|
|
42
|
+
"label": "Hidden",
|
|
43
|
+
"value": "hidden",
|
|
44
|
+
"type": "boolean"
|
|
45
|
+
},
|
|
46
|
+
"state": false
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": "HidePanel",
|
|
52
|
+
"trigger": {
|
|
53
|
+
"type": "event",
|
|
54
|
+
"event": "hide"
|
|
55
|
+
},
|
|
56
|
+
"actions": [
|
|
57
|
+
{
|
|
58
|
+
"name": "Hide",
|
|
59
|
+
"type": "property",
|
|
60
|
+
"property": {
|
|
61
|
+
"label": "Hidden",
|
|
62
|
+
"value": "hidden",
|
|
63
|
+
"type": "boolean"
|
|
64
|
+
},
|
|
65
|
+
"state": true
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
"type": "panel",
|
|
71
|
+
"label": "Panel",
|
|
72
|
+
"collapsed": false,
|
|
73
|
+
"input": false,
|
|
74
|
+
"tableView": false,
|
|
75
|
+
"components": []
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"label": "Text Field",
|
|
79
|
+
"applyMaskOn": "change",
|
|
80
|
+
"tableView": true,
|
|
81
|
+
"key": "textField1",
|
|
82
|
+
"type": "textfield",
|
|
83
|
+
"input": true
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
};
|
|
@@ -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.comp6 = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
|
|
6
|
+
exports.comp7 = 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 comp2_1 = __importDefault(require("./comp2"));
|
|
@@ -16,3 +16,5 @@ const comp5_1 = __importDefault(require("./comp5"));
|
|
|
16
16
|
exports.comp5 = comp5_1.default;
|
|
17
17
|
const comp6_1 = __importDefault(require("./comp6"));
|
|
18
18
|
exports.comp6 = comp6_1.default;
|
|
19
|
+
const comp7_1 = __importDefault(require("./comp7"));
|
|
20
|
+
exports.comp7 = comp7_1.default;
|
|
@@ -234,11 +234,33 @@ class Input extends Multivalue_1.default {
|
|
|
234
234
|
this.addFocusBlurEvents(element);
|
|
235
235
|
if (this.options.submitOnEnter) {
|
|
236
236
|
this.addEventListener(element, 'keypress', (event) => {
|
|
237
|
+
var _a;
|
|
237
238
|
const key = event.keyCode || event.which;
|
|
238
239
|
if (key === 13) {
|
|
239
240
|
event.preventDefault();
|
|
240
241
|
event.stopPropagation();
|
|
241
|
-
|
|
242
|
+
let submitButton = null;
|
|
243
|
+
if ((_a = this.root) === null || _a === void 0 ? void 0 : _a.everyComponent) {
|
|
244
|
+
this.root.everyComponent((component) => {
|
|
245
|
+
if ((component === null || component === void 0 ? void 0 : component.component.type) === 'button' &&
|
|
246
|
+
(component === null || component === void 0 ? void 0 : component.component.action) === 'submit') {
|
|
247
|
+
submitButton = component;
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
const options = {};
|
|
253
|
+
if (submitButton) {
|
|
254
|
+
options.instance = submitButton;
|
|
255
|
+
options.component = submitButton.component;
|
|
256
|
+
options.noValidate = this.component.state === 'draft';
|
|
257
|
+
options.state = this.component.state || 'submitted';
|
|
258
|
+
submitButton.loading = true;
|
|
259
|
+
this.emit('submitButton', options);
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
this.emit('submitButton', options);
|
|
263
|
+
}
|
|
242
264
|
}
|
|
243
265
|
});
|
|
244
266
|
}
|
|
@@ -44,7 +44,7 @@ export default class Multivalue extends Field {
|
|
|
44
44
|
attachMultiMask(index: number): boolean;
|
|
45
45
|
/**
|
|
46
46
|
* @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.
|
|
47
|
+
* @param {string} mask - The mask pattern to apply to the input element. Exit early and remove previous mask if no mask.
|
|
48
48
|
*/
|
|
49
49
|
updateMask(input: any, mask: string): void;
|
|
50
50
|
/**
|
|
@@ -237,10 +237,17 @@ class Multivalue extends Field_1.default {
|
|
|
237
237
|
}
|
|
238
238
|
/**
|
|
239
239
|
* @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.
|
|
240
|
+
* @param {string} mask - The mask pattern to apply to the input element. Exit early and remove previous mask if no mask.
|
|
241
241
|
*/
|
|
242
242
|
updateMask(input, mask) {
|
|
243
243
|
if (!mask) {
|
|
244
|
+
if (input.mask) {
|
|
245
|
+
input.mask.destroy();
|
|
246
|
+
}
|
|
247
|
+
if (!this.component.placeholder) {
|
|
248
|
+
input.removeAttribute('placeholder');
|
|
249
|
+
}
|
|
250
|
+
input.value = '';
|
|
244
251
|
return;
|
|
245
252
|
}
|
|
246
253
|
this.setInputMask(input, mask, !this.component.placeholder);
|
|
@@ -61,6 +61,15 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
61
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;
|
|
65
74
|
focusOnNewRowElement(row: any): void;
|
|
66
75
|
addRow(): void;
|
|
@@ -7,6 +7,7 @@ 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
9
|
const Components_1 = require("../Components");
|
|
10
|
+
const dragula_1 = __importDefault(require("dragula"));
|
|
10
11
|
class DataGridComponent extends NestedArrayComponent_1.default {
|
|
11
12
|
static schema(...extend) {
|
|
12
13
|
return NestedArrayComponent_1.default.schema({
|
|
@@ -281,34 +282,32 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
281
282
|
this.refs[`${this.datagridKey}-row`].forEach((row, index) => {
|
|
282
283
|
row.dragInfo = { index };
|
|
283
284
|
});
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
return clickedElement.classList.contains('formio-drag-button');
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}).on('drop', this.onReorder.bind(this));
|
|
295
|
-
this.dragula.on('cloned', (el, original) => {
|
|
296
|
-
if (el && el.children && original && original.children) {
|
|
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
|
-
});
|
|
285
|
+
this.dragula = (0, dragula_1.default)([this.refs[`${this.datagridKey}-tbody`]], {
|
|
286
|
+
moves: (_draggedElement, _oldParent, clickedElement) => {
|
|
287
|
+
const clickedElementKey = clickedElement.getAttribute('data-key');
|
|
288
|
+
const oldParentKey = _oldParent.getAttribute('data-key');
|
|
289
|
+
//Check if the clicked button belongs to that container, if false, it belongs to the nested container
|
|
290
|
+
if (oldParentKey === clickedElementKey) {
|
|
291
|
+
return clickedElement.classList.contains('formio-drag-button');
|
|
309
292
|
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
293
|
+
}
|
|
294
|
+
}).on('drop', this.onReorder.bind(this));
|
|
295
|
+
this.dragula.on('cloned', (el, original) => {
|
|
296
|
+
if (el && el.children && original && original.children) {
|
|
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
|
+
});
|
|
312
311
|
}
|
|
313
312
|
this.refs[`${this.datagridKey}-addRow`].forEach((addButton) => {
|
|
314
313
|
this.addEventListener(addButton, 'click', this.addRow.bind(this));
|
|
@@ -336,6 +335,24 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
336
335
|
getComponentsContainer() {
|
|
337
336
|
return this.component.components;
|
|
338
337
|
}
|
|
338
|
+
/**
|
|
339
|
+
* Reorder values in array based on the old and new position
|
|
340
|
+
* @param {any} valuesArr - An array of values.
|
|
341
|
+
* @param {number} oldPosition - The index of the value in array before reordering.
|
|
342
|
+
* @param {number} newPosition - The index of the value in array after reordering.
|
|
343
|
+
* @param {boolean|any} movedBelow - Whether or not the value is moved below.
|
|
344
|
+
* @returns {void}
|
|
345
|
+
*/
|
|
346
|
+
reorderValues(valuesArr, oldPosition, newPosition, movedBelow) {
|
|
347
|
+
if (!lodash_1.default.isArray(valuesArr) || lodash_1.default.isEmpty(valuesArr)) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
const draggedRowData = valuesArr[oldPosition];
|
|
351
|
+
//insert element at new position
|
|
352
|
+
valuesArr.splice(newPosition, 0, draggedRowData);
|
|
353
|
+
//remove element from old position (if was moved above, after insertion it's at +1 index)
|
|
354
|
+
valuesArr.splice(movedBelow ? oldPosition : oldPosition + 1, 1);
|
|
355
|
+
}
|
|
339
356
|
onReorder(element, _target, _source, sibling) {
|
|
340
357
|
if (!element.dragInfo || (sibling && !sibling.dragInfo)) {
|
|
341
358
|
console.warn('There is no Drag Info available for either dragged or sibling element');
|
|
@@ -346,11 +363,12 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
346
363
|
const newPosition = sibling ? sibling.dragInfo.index : this.dataValue.length;
|
|
347
364
|
const movedBelow = newPosition > oldPosition;
|
|
348
365
|
const dataValue = (0, utils_1.fastCloneDeep)(this.dataValue);
|
|
349
|
-
|
|
350
|
-
//
|
|
351
|
-
|
|
352
|
-
//
|
|
353
|
-
|
|
366
|
+
this.reorderValues(dataValue, oldPosition, newPosition, movedBelow);
|
|
367
|
+
//reorder select data
|
|
368
|
+
this.reorderValues(lodash_1.default.get(this.root, `submission.metadata.selectData.${this.path}`, []), oldPosition, newPosition, movedBelow);
|
|
369
|
+
// When components are reordered we need to set the dataGrid and form pristine properties to false
|
|
370
|
+
this.root.pristine = false;
|
|
371
|
+
this.pristine = false;
|
|
354
372
|
//need to re-build rows to re-calculate indexes and other indexed fields for component instance (like rows for ex.)
|
|
355
373
|
this.setValue(dataValue, { isReordered: true });
|
|
356
374
|
this.rebuild();
|