@formio/js 5.1.0-dev.6112.86987a5 → 5.1.0-dev.6112.b627acb
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/dist/formio.builder.css +6 -0
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.embed.css +1 -1
- package/dist/formio.embed.min.css +1 -1
- package/dist/formio.form.css +6 -0
- package/dist/formio.form.js +43 -65
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.css +6 -0
- package/dist/formio.full.js +47 -69
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.js +21 -43
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +22 -44
- package/dist/formio.utils.min.js +1 -1
- package/lib/cjs/Element.js +2 -2
- package/lib/cjs/PDFBuilder.js +8 -6
- package/lib/cjs/Webform.js +9 -1
- package/lib/cjs/WebformBuilder.js +17 -6
- package/lib/cjs/Wizard.js +7 -6
- package/lib/cjs/WizardBuilder.js +4 -0
- package/lib/cjs/components/Components.js +7 -1
- package/lib/cjs/components/_classes/component/Component.d.ts +1 -0
- package/lib/cjs/components/_classes/component/Component.js +30 -17
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.d.ts +7 -0
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +1 -0
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +2 -1
- package/lib/cjs/components/_classes/nested/NestedComponent.js +18 -5
- package/lib/cjs/components/address/Address.js +4 -4
- package/lib/cjs/components/address/editForm/Address.edit.provider.js +1 -1
- package/lib/cjs/components/datagrid/DataGrid.js +12 -1
- package/lib/cjs/components/editgrid/EditGrid.d.ts +2 -3
- package/lib/cjs/components/editgrid/EditGrid.js +0 -8
- package/lib/cjs/components/form/Form.d.ts +2 -1
- package/lib/cjs/components/form/Form.js +32 -20
- package/lib/cjs/components/number/Number.js +4 -1
- package/lib/cjs/components/radio/Radio.d.ts +1 -0
- package/lib/cjs/components/radio/Radio.js +5 -5
- package/lib/cjs/components/select/Select.js +1 -1
- package/lib/cjs/components/tags/Tags.js +7 -0
- package/lib/cjs/formio.form.d.ts +2 -1
- package/lib/cjs/formio.form.js +2 -1
- package/lib/cjs/providers/storage/url.js +7 -3
- package/lib/cjs/utils/formUtils.d.ts +3 -3
- package/lib/cjs/utils/index.d.ts +6 -5
- package/lib/cjs/utils/index.js +2 -1
- package/lib/cjs/utils/utils.js +0 -4
- package/lib/cjs/widgets/CalendarWidget.js +8 -1
- package/lib/mjs/Element.js +2 -2
- package/lib/mjs/PDFBuilder.js +8 -6
- package/lib/mjs/Webform.js +9 -1
- package/lib/mjs/WebformBuilder.js +17 -6
- package/lib/mjs/Wizard.js +7 -6
- package/lib/mjs/WizardBuilder.js +4 -0
- package/lib/mjs/components/Components.js +7 -1
- package/lib/mjs/components/_classes/component/Component.d.ts +1 -0
- package/lib/mjs/components/_classes/component/Component.js +29 -16
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.d.ts +7 -0
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +1 -0
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +2 -1
- package/lib/mjs/components/_classes/nested/NestedComponent.js +17 -5
- package/lib/mjs/components/address/Address.js +4 -4
- package/lib/mjs/components/address/editForm/Address.edit.provider.js +1 -1
- package/lib/mjs/components/datagrid/DataGrid.js +11 -1
- package/lib/mjs/components/editgrid/EditGrid.d.ts +2 -3
- package/lib/mjs/components/editgrid/EditGrid.js +0 -8
- package/lib/mjs/components/form/Form.d.ts +2 -1
- package/lib/mjs/components/form/Form.js +32 -20
- package/lib/mjs/components/number/Number.js +4 -1
- package/lib/mjs/components/radio/Radio.d.ts +1 -0
- package/lib/mjs/components/radio/Radio.js +5 -5
- package/lib/mjs/components/select/Select.js +1 -1
- package/lib/mjs/components/tags/Tags.js +7 -0
- package/lib/mjs/formio.form.d.ts +2 -1
- package/lib/mjs/formio.form.js +2 -2
- package/lib/mjs/providers/storage/url.js +7 -3
- package/lib/mjs/utils/formUtils.d.ts +3 -3
- package/lib/mjs/utils/index.d.ts +6 -5
- package/lib/mjs/utils/index.js +2 -2
- package/lib/mjs/utils/utils.js +0 -4
- package/lib/mjs/widgets/CalendarWidget.js +8 -1
- package/package.json +2 -2
|
@@ -290,29 +290,35 @@ class FormComponent extends Component_1.default {
|
|
|
290
290
|
return;
|
|
291
291
|
}
|
|
292
292
|
this.setContent(element, this.render());
|
|
293
|
+
const postAttach = () => {
|
|
294
|
+
if (!this.builderMode && this.component.modalEdit) {
|
|
295
|
+
const modalShouldBeOpened = this.componentModal ? this.componentModal.isOpened : false;
|
|
296
|
+
const currentValue = modalShouldBeOpened ? this.componentModal.currentValue : this.dataValue;
|
|
297
|
+
this.componentModal = new ComponentModal_1.default(this, element, modalShouldBeOpened, currentValue, this._referenceAttributeName);
|
|
298
|
+
this.subForm.element = this.componentModal.refs.componentContent || this.subForm.element;
|
|
299
|
+
this.setOpenModalElement();
|
|
300
|
+
}
|
|
301
|
+
this.calculateValue();
|
|
302
|
+
};
|
|
293
303
|
if (this.subForm) {
|
|
294
304
|
if (this.isNestedWizard) {
|
|
295
305
|
element = this.root.element;
|
|
296
306
|
}
|
|
297
|
-
this.subForm.attach(element)
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
307
|
+
return this.subForm.attach(element).then(() => {
|
|
308
|
+
this.valueChanged = this.hasSetValue;
|
|
309
|
+
if (!this.shouldConditionallyClear()) {
|
|
310
|
+
if (!this.valueChanged && this.dataValue.state !== 'submitted') {
|
|
311
|
+
this.setDefaultValue();
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
this.restoreValue();
|
|
315
|
+
}
|
|
305
316
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
const modalShouldBeOpened = this.componentModal ? this.componentModal.isOpened : false;
|
|
310
|
-
const currentValue = modalShouldBeOpened ? this.componentModal.currentValue : this.dataValue;
|
|
311
|
-
this.componentModal = new ComponentModal_1.default(this, element, modalShouldBeOpened, currentValue, this._referenceAttributeName);
|
|
312
|
-
this.subForm.element = this.componentModal.refs.componentContent || this.subForm.element;
|
|
313
|
-
this.setOpenModalElement();
|
|
317
|
+
postAttach();
|
|
318
|
+
this.setComponentsMap();
|
|
319
|
+
});
|
|
314
320
|
}
|
|
315
|
-
|
|
321
|
+
postAttach();
|
|
316
322
|
});
|
|
317
323
|
});
|
|
318
324
|
}
|
|
@@ -390,6 +396,14 @@ class FormComponent extends Component_1.default {
|
|
|
390
396
|
this.emit('subWizardsUpdated', subForm);
|
|
391
397
|
}
|
|
392
398
|
}
|
|
399
|
+
setComponentsMap() {
|
|
400
|
+
if (!this.subForm) {
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
const componentsMap = this.componentsMap;
|
|
404
|
+
const formComponentsMap = this.subForm.componentsMap;
|
|
405
|
+
lodash_1.default.assign(componentsMap, formComponentsMap);
|
|
406
|
+
}
|
|
393
407
|
/**
|
|
394
408
|
* Create a subform instance.
|
|
395
409
|
* @param {boolean} [fromAttach] - This function is being called from an `attach` method.
|
|
@@ -415,9 +429,7 @@ class FormComponent extends Component_1.default {
|
|
|
415
429
|
this.subForm = instance;
|
|
416
430
|
this.subForm.currentForm = this;
|
|
417
431
|
this.subForm.parentVisible = this.visible;
|
|
418
|
-
|
|
419
|
-
const formComponentsMap = this.subForm.componentsMap;
|
|
420
|
-
lodash_1.default.assign(componentsMap, formComponentsMap);
|
|
432
|
+
this.setComponentsMap();
|
|
421
433
|
this.component.components = (_a = this.subForm._form) === null || _a === void 0 ? void 0 : _a.components;
|
|
422
434
|
this.component.display = (_b = this.subForm._form) === null || _b === void 0 ? void 0 : _b.display;
|
|
423
435
|
this.subForm.on('change', () => {
|
|
@@ -91,10 +91,13 @@ class NumberComponent extends Input_1.default {
|
|
|
91
91
|
}
|
|
92
92
|
get defaultValue() {
|
|
93
93
|
let defaultValue = super.defaultValue;
|
|
94
|
-
if (typeof defaultValue === 'string') {
|
|
94
|
+
if (typeof defaultValue === 'string' && defaultValue) {
|
|
95
95
|
// Default value may be a string or have custom thousands separators or decimal symbols, so we need to call
|
|
96
96
|
// parseNumber on it
|
|
97
97
|
defaultValue = this.parseNumber(defaultValue);
|
|
98
|
+
if (lodash_1.default.isNaN(defaultValue)) {
|
|
99
|
+
defaultValue = null;
|
|
100
|
+
}
|
|
98
101
|
}
|
|
99
102
|
if (!defaultValue && this.component.defaultValue === 0) {
|
|
100
103
|
defaultValue = this.component.defaultValue;
|
|
@@ -16,6 +16,7 @@ export default class RadioComponent extends ListComponent {
|
|
|
16
16
|
static savedValueTypes(schema: any): any[];
|
|
17
17
|
constructor(component: any, options: any, data: any);
|
|
18
18
|
previousValue: any;
|
|
19
|
+
uncheckValue(flags?: {}): void;
|
|
19
20
|
get inputInfo(): any;
|
|
20
21
|
get emptyValue(): string;
|
|
21
22
|
get isRadio(): boolean;
|
|
@@ -79,13 +79,15 @@ class RadioComponent extends ListComponent_1.default {
|
|
|
79
79
|
}
|
|
80
80
|
return defaultValue;
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
uncheckValue(flags = {}) {
|
|
83
83
|
this.unset();
|
|
84
84
|
this.setValue(this.emptyValue, {
|
|
85
85
|
noUpdateEvent: true,
|
|
86
86
|
noValidate: true,
|
|
87
87
|
resetValue: true
|
|
88
88
|
});
|
|
89
|
+
this.triggerChange(flags);
|
|
90
|
+
this.setSelectedClasses();
|
|
89
91
|
}
|
|
90
92
|
get inputInfo() {
|
|
91
93
|
var _a;
|
|
@@ -142,7 +144,7 @@ class RadioComponent extends ListComponent_1.default {
|
|
|
142
144
|
});
|
|
143
145
|
this.optionsLoaded = !this.component.dataSrc || this.component.dataSrc === 'values';
|
|
144
146
|
this.loadedOptions = [];
|
|
145
|
-
if (!this.visible) {
|
|
147
|
+
if (!this.visible || this.optionsLoaded) {
|
|
146
148
|
this.itemsLoadedResolve();
|
|
147
149
|
}
|
|
148
150
|
// Get the template keys for this radio component.
|
|
@@ -400,9 +402,7 @@ class RadioComponent extends ListComponent_1.default {
|
|
|
400
402
|
this.currentValue = this.dataValue;
|
|
401
403
|
const shouldResetValue = flags && flags.modified && !flags.noUpdateEvent && this.previousValue === this.currentValue;
|
|
402
404
|
if (shouldResetValue) {
|
|
403
|
-
this.
|
|
404
|
-
this.triggerChange(flags);
|
|
405
|
-
this.setSelectedClasses();
|
|
405
|
+
this.uncheckValue(flags);
|
|
406
406
|
}
|
|
407
407
|
this.previousValue = this.dataValue;
|
|
408
408
|
return changed;
|
|
@@ -1124,7 +1124,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1124
1124
|
}
|
|
1125
1125
|
// Choices will return undefined if nothing is selected. We really want '' to be empty.
|
|
1126
1126
|
if (value === undefined || value === null) {
|
|
1127
|
-
value =
|
|
1127
|
+
value = this.emptyValue;
|
|
1128
1128
|
}
|
|
1129
1129
|
return value;
|
|
1130
1130
|
}
|
|
@@ -160,6 +160,13 @@ class TagsComponent extends Input_1.default {
|
|
|
160
160
|
this.refs.input[0].parentNode.lastChild.focus();
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
+
getValue() {
|
|
164
|
+
if (this.choices) {
|
|
165
|
+
const value = this.choices.getValue(true);
|
|
166
|
+
return value.join(`${this.delimiter}`);
|
|
167
|
+
}
|
|
168
|
+
return super.getValue();
|
|
169
|
+
}
|
|
163
170
|
getValueAsString(value) {
|
|
164
171
|
if (!value) {
|
|
165
172
|
return '';
|
package/lib/cjs/formio.form.d.ts
CHANGED
|
@@ -23,4 +23,5 @@ import { Formio } from './Formio';
|
|
|
23
23
|
import Licenses from './licenses';
|
|
24
24
|
import EventEmitter from './EventEmitter';
|
|
25
25
|
import Webform from './Webform';
|
|
26
|
-
|
|
26
|
+
import { DefaultEvaluator } from './utils';
|
|
27
|
+
export { Components, Displays, Providers, Widgets, Templates, Utils, Form, Formio, Licenses, EventEmitter, Webform, DefaultEvaluator };
|
package/lib/cjs/formio.form.js
CHANGED
|
@@ -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.Webform = exports.EventEmitter = exports.Licenses = exports.Formio = exports.Form = exports.Utils = exports.Templates = exports.Widgets = exports.Providers = exports.Displays = exports.Components = exports.FormioCore = exports.useModule = exports.registerModule = void 0;
|
|
6
|
+
exports.DefaultEvaluator = exports.Webform = exports.EventEmitter = exports.Licenses = exports.Formio = exports.Form = exports.Utils = exports.Templates = exports.Widgets = exports.Providers = exports.Displays = exports.Components = exports.FormioCore = exports.useModule = exports.registerModule = void 0;
|
|
7
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
8
|
const Formio_1 = require("./Formio");
|
|
9
9
|
Object.defineProperty(exports, "Formio", { enumerable: true, get: function () { return Formio_1.Formio; } });
|
|
@@ -30,6 +30,7 @@ const Webform_1 = __importDefault(require("./Webform"));
|
|
|
30
30
|
exports.Webform = Webform_1.default;
|
|
31
31
|
const core_1 = require("@formio/core");
|
|
32
32
|
const utils_2 = require("./utils");
|
|
33
|
+
Object.defineProperty(exports, "DefaultEvaluator", { enumerable: true, get: function () { return utils_2.DefaultEvaluator; } });
|
|
33
34
|
Formio_1.Formio.loadModules = (path = `${Formio_1.Formio.getApiUrl()}/externalModules.js`, name = 'externalModules') => {
|
|
34
35
|
Formio_1.Formio.requireLibrary(name, name, path, true)
|
|
35
36
|
.then((modules) => {
|
|
@@ -127,13 +127,17 @@ function url(formio) {
|
|
|
127
127
|
deleteFile(fileInfo, options) {
|
|
128
128
|
return new Promise((resolve, reject) => {
|
|
129
129
|
const xhr = new XMLHttpRequest();
|
|
130
|
-
xhr.open(
|
|
130
|
+
xhr.open("DELETE", fileInfo.url, true);
|
|
131
|
+
const token = formio.getToken();
|
|
132
|
+
if (token) {
|
|
133
|
+
xhr.setRequestHeader("x-jwt-token", token);
|
|
134
|
+
}
|
|
131
135
|
xhr.onload = () => {
|
|
132
136
|
if (xhr.status >= 200 && xhr.status < 300) {
|
|
133
|
-
resolve(
|
|
137
|
+
resolve("File deleted");
|
|
134
138
|
}
|
|
135
139
|
else {
|
|
136
|
-
reject(xhr.response ||
|
|
140
|
+
reject(xhr.response || "Unable to delete file");
|
|
137
141
|
}
|
|
138
142
|
};
|
|
139
143
|
if (options) {
|
|
@@ -26,10 +26,10 @@ export const getBestMatch: typeof Utils.getBestMatch;
|
|
|
26
26
|
export const getComponentFromPath: typeof Utils.getComponentFromPath;
|
|
27
27
|
export const getComponentValue: typeof Utils.getComponentValue;
|
|
28
28
|
export const findComponents: typeof Utils.findComponents;
|
|
29
|
-
export const eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined) => Promise<void>;
|
|
30
|
-
export const eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined) => void;
|
|
29
|
+
export const eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataAsyncCallback | undefined) => Promise<void>;
|
|
30
|
+
export const eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataCallback | undefined) => void;
|
|
31
31
|
export const getComponentKey: typeof Utils.getComponentKey;
|
|
32
|
-
export const getContextualRowPath:
|
|
32
|
+
export const getContextualRowPath: any;
|
|
33
33
|
export const getContextualRowData: typeof Utils.getContextualRowData;
|
|
34
34
|
export const componentInfo: typeof Utils.componentInfo;
|
|
35
35
|
export const eachComponent: typeof Utils.eachComponent;
|
package/lib/cjs/utils/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export * from "./utils";
|
|
|
2
2
|
export * from "./formUtils";
|
|
3
3
|
export default FormioUtils;
|
|
4
4
|
declare const FormioUtils: {
|
|
5
|
-
Evaluator:
|
|
5
|
+
Evaluator: DefaultEvaluator;
|
|
6
6
|
interpolate: typeof interpolate;
|
|
7
7
|
ConditionOperators: {
|
|
8
8
|
[x: string]: typeof import("./conditionOperators/IsEqualTo").default | typeof import("./conditionOperators/DateGreaterThan").default;
|
|
@@ -37,10 +37,10 @@ declare const FormioUtils: {
|
|
|
37
37
|
getComponentFromPath: typeof import("@formio/core/lib/utils/formUtil").getComponentFromPath;
|
|
38
38
|
getComponentValue: typeof import("@formio/core/lib/utils/formUtil").getComponentValue;
|
|
39
39
|
findComponents: typeof import("@formio/core/lib/utils/formUtil").findComponents;
|
|
40
|
-
eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined) => Promise<void>;
|
|
41
|
-
eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined) => void;
|
|
40
|
+
eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataAsyncCallback | undefined) => Promise<void>;
|
|
41
|
+
eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataCallback | undefined) => void;
|
|
42
42
|
getComponentKey: typeof import("@formio/core/lib/utils/formUtil").getComponentKey;
|
|
43
|
-
getContextualRowPath:
|
|
43
|
+
getContextualRowPath: any;
|
|
44
44
|
getContextualRowData: typeof import("@formio/core/lib/utils/formUtil").getContextualRowData;
|
|
45
45
|
componentInfo: typeof import("@formio/core/lib/utils/formUtil").componentInfo;
|
|
46
46
|
eachComponent: typeof import("@formio/core/lib/utils/formUtil").eachComponent;
|
|
@@ -164,7 +164,8 @@ declare const FormioUtils: {
|
|
|
164
164
|
interpolateErrors: (component: Component, errors: FieldError[], interpolateFn: Function) => [];
|
|
165
165
|
};
|
|
166
166
|
import { Evaluator } from './Evaluator';
|
|
167
|
+
import { DefaultEvaluator } from './Evaluator';
|
|
167
168
|
import { registerEvaluator } from './Evaluator';
|
|
168
169
|
import { interpolate } from './Evaluator';
|
|
169
170
|
import moment from 'moment';
|
|
170
|
-
export { FormioUtils as Utils, Evaluator, registerEvaluator };
|
|
171
|
+
export { FormioUtils as Utils, Evaluator, DefaultEvaluator, registerEvaluator };
|
package/lib/cjs/utils/index.js
CHANGED
|
@@ -29,12 +29,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
29
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.registerEvaluator = exports.Evaluator = exports.Utils = void 0;
|
|
32
|
+
exports.registerEvaluator = exports.DefaultEvaluator = exports.Evaluator = exports.Utils = void 0;
|
|
33
33
|
const utils = __importStar(require("./utils"));
|
|
34
34
|
const formUtils = __importStar(require("./formUtils"));
|
|
35
35
|
const Evaluator_1 = require("./Evaluator");
|
|
36
36
|
Object.defineProperty(exports, "Evaluator", { enumerable: true, get: function () { return Evaluator_1.Evaluator; } });
|
|
37
37
|
Object.defineProperty(exports, "registerEvaluator", { enumerable: true, get: function () { return Evaluator_1.registerEvaluator; } });
|
|
38
|
+
Object.defineProperty(exports, "DefaultEvaluator", { enumerable: true, get: function () { return Evaluator_1.DefaultEvaluator; } });
|
|
38
39
|
const conditionOperators_1 = __importDefault(require("./conditionOperators"));
|
|
39
40
|
const lodash_1 = __importDefault(require("lodash"));
|
|
40
41
|
const moment_1 = __importDefault(require("moment"));
|
package/lib/cjs/utils/utils.js
CHANGED
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.translateHTMLTemplate = exports.getContextButtons = exports.getContextComponents = exports.observeOverload = exports.withSwitch = exports.firstNonNil = exports.unfold = exports.bootstrapVersion = exports.uniqueKey = exports.iterateKey = exports.delay = exports.fieldData = exports.getCurrencyAffixes = exports.getNumberDecimalLimit = exports.getNumberSeparators = exports.matchInputMask = exports.unmaskValue = exports.getInputMask = exports.convertFormatToMask = exports.convertFormatToDayjs = exports.convertFormatToFlatpickr = exports.getLocaleDateFormatInfo = exports.formatOffset = exports.formatDate = exports.dayjsDate = exports.shouldHandleTimezone = exports.offsetDate = exports.currentTimezone = exports.isValidDate = exports.getDateSetting = exports.guid = exports.uniqueName = exports.convertStringToHTMLElement = exports.unescapeHTML = exports.removeHTML = exports.setActionProperty = exports.checkTrigger = exports.checkCondition = exports.checkJsonConditional = exports.checkCustomConditional = exports.getComponentActualValue = exports.checkSimpleConditional = exports.checkCalculated = exports.isMongoId = exports.boolValue = exports.getScriptPlugin = exports.getElementRect = exports.getPropertyValue = exports.getRandomComponentId = exports.evaluate = void 0;
|
|
7
7
|
exports.hasEncodedTimezone = exports.interpolateErrors = exports.getComponentSavedTypes = exports.componentValueTypes = exports.getFocusableElements = exports.isPromise = exports.getDataParentComponent = exports.getComponentPath = exports.getComponentPathWithoutIndicies = exports.getBrowserInfo = exports.getIEBrowserVersion = exports.round = exports.getStringFromComponentPath = exports.isChildOf = exports.getArrayFromComponentPath = exports.isInputComponent = exports.fastCloneDeep = exports.sanitize = void 0;
|
|
8
|
-
/* global jQuery */
|
|
9
8
|
const lodash_1 = __importDefault(require("lodash"));
|
|
10
9
|
const moment_timezone_1 = __importDefault(require("moment-timezone/moment-timezone"));
|
|
11
10
|
const jstimezonedetect_1 = __importDefault(require("jstimezonedetect"));
|
|
@@ -1064,9 +1063,6 @@ function bootstrapVersion(options) {
|
|
|
1064
1063
|
if (options.bootstrap) {
|
|
1065
1064
|
return options.bootstrap;
|
|
1066
1065
|
}
|
|
1067
|
-
if ((typeof jQuery === 'function') && (typeof jQuery().collapse === 'function')) {
|
|
1068
|
-
return parseInt(jQuery.fn.collapse.Constructor.VERSION.split('.')[0], 10);
|
|
1069
|
-
}
|
|
1070
1066
|
if (window.bootstrap && window.bootstrap.Collapse) {
|
|
1071
1067
|
return parseInt(window.bootstrap.Collapse.VERSION.split('.')[0], 10);
|
|
1072
1068
|
}
|
|
@@ -123,7 +123,14 @@ class CalendarWidget extends InputWidget_1.default {
|
|
|
123
123
|
if (this._input) {
|
|
124
124
|
const { locale } = this.settings;
|
|
125
125
|
if (locale && locale.length >= 2 && locale !== 'en') {
|
|
126
|
-
return Formio_1.Formio.requireLibrary(`flatpickr-${locale}`, `flatpickr.l10ns.${locale}`, `${Formio_1.Formio.cdn['flatpickr']}/l10n/${locale}.js`, true)
|
|
126
|
+
return Formio_1.Formio.requireLibrary(`flatpickr-${locale}`, `flatpickr.l10ns.${locale}`, `${Formio_1.Formio.cdn['flatpickr']}/l10n/${locale}.js`, true)
|
|
127
|
+
.catch(() => {
|
|
128
|
+
// fallback to en if locale fails to load
|
|
129
|
+
this.settings.locale = 'en';
|
|
130
|
+
})
|
|
131
|
+
.finally(() => {
|
|
132
|
+
this.initFlatpickr(Flatpickr);
|
|
133
|
+
});
|
|
127
134
|
}
|
|
128
135
|
else {
|
|
129
136
|
this.initFlatpickr(Flatpickr);
|
package/lib/mjs/Element.js
CHANGED
|
@@ -525,9 +525,9 @@ export default class Element {
|
|
|
525
525
|
if (this.component.filter === string && !this.options.building) {
|
|
526
526
|
const evalContext = this.evalContext(data);
|
|
527
527
|
evalContext.data = _.mapValues(evalContext.data, (val) => _.isString(val) ? encodeURIComponent(val) : val);
|
|
528
|
-
return FormioUtils.
|
|
528
|
+
return FormioUtils.interpolate(string, evalContext, options);
|
|
529
529
|
}
|
|
530
|
-
return FormioUtils.
|
|
530
|
+
return FormioUtils.interpolate(string, this.evalContext(data), options);
|
|
531
531
|
}
|
|
532
532
|
/**
|
|
533
533
|
* Performs an evaluation using the evaluation context of this component.
|
package/lib/mjs/PDFBuilder.js
CHANGED
|
@@ -447,18 +447,20 @@ export default class PDFBuilder extends WebformBuilder {
|
|
|
447
447
|
const repeatablePathsComps = this.findComponentsWithRepeatablePaths();
|
|
448
448
|
// update elements which path was duplicated if any pathes have been changed
|
|
449
449
|
if (!_.isEqual(this.repeatablePathsComps, repeatablePathsComps)) {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
this.
|
|
453
|
-
|
|
454
|
-
|
|
450
|
+
if (!_.isEmpty(this.repeatablePathsComps)) {
|
|
451
|
+
eachComponent(this.webform.getComponents(), (comp) => {
|
|
452
|
+
if (this.repeatablePathsComps.includes(comp.component)) {
|
|
453
|
+
this.webform.postMessage({ name: 'updateElement', data: comp.component });
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
}
|
|
455
457
|
this.repeatablePathsComps = repeatablePathsComps;
|
|
456
458
|
}
|
|
457
459
|
if (!repeatablePathsComps.length) {
|
|
458
460
|
return;
|
|
459
461
|
}
|
|
460
462
|
eachComponent(this.webform.getComponents(), (comp) => {
|
|
461
|
-
if (this.repeatablePathsComps.includes(comp)) {
|
|
463
|
+
if (this.repeatablePathsComps.includes(comp.component)) {
|
|
462
464
|
this.webform.postMessage({
|
|
463
465
|
name: 'showBuilderErrors',
|
|
464
466
|
data: {
|
package/lib/mjs/Webform.js
CHANGED
|
@@ -333,6 +333,14 @@ export default class Webform extends NestedDataComponent {
|
|
|
333
333
|
get shadowRoot() {
|
|
334
334
|
return this.options.shadowRoot;
|
|
335
335
|
}
|
|
336
|
+
// Webforms have no default value setting, so this should be always false
|
|
337
|
+
// I does not affect setting default value to nested forms
|
|
338
|
+
get shouldAddDefaultValue() {
|
|
339
|
+
return false;
|
|
340
|
+
}
|
|
341
|
+
get componentsMap() {
|
|
342
|
+
return this.childComponentsMap || {};
|
|
343
|
+
}
|
|
336
344
|
/**
|
|
337
345
|
* Add a language for translations
|
|
338
346
|
* @param {string} code - The language code for the language being added.
|
|
@@ -1121,7 +1129,7 @@ export default class Webform extends NestedDataComponent {
|
|
|
1121
1129
|
// Mark any components as invalid if in a custom message.
|
|
1122
1130
|
const componentErrors = {};
|
|
1123
1131
|
errors.forEach((err) => {
|
|
1124
|
-
const path = err.path || err.context?.path || err.component?.key;
|
|
1132
|
+
const path = getStringFromComponentPath(err.path) || err.context?.path || err.component?.key;
|
|
1125
1133
|
if (!componentErrors[path]) {
|
|
1126
1134
|
componentErrors[path] = [];
|
|
1127
1135
|
}
|
|
@@ -63,8 +63,16 @@ export default class WebformBuilder extends Component {
|
|
|
63
63
|
}
|
|
64
64
|
this.groupOrder = this.groupOrder
|
|
65
65
|
.filter(group => group && !group.ignore)
|
|
66
|
-
.sort((a, b) => a.weight - b.weight)
|
|
67
|
-
|
|
66
|
+
.sort((a, b) => a.weight - b.weight);
|
|
67
|
+
const defaultOpenedGroup = this.groupOrder.find(x => x.key !== 'basic' && x.default);
|
|
68
|
+
if (defaultOpenedGroup) {
|
|
69
|
+
this.groupOrder.forEach(x => {
|
|
70
|
+
if ('default' in x && x.key !== defaultOpenedGroup.key) {
|
|
71
|
+
x.default = false;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
this.groupOrder = this.groupOrder.map(group => group.key);
|
|
68
76
|
for (const type in Components.components) {
|
|
69
77
|
const component = Components.components[type];
|
|
70
78
|
if (component.builderInfo && component.builderInfo.schema) {
|
|
@@ -507,8 +515,8 @@ export default class WebformBuilder extends Component {
|
|
|
507
515
|
}
|
|
508
516
|
return elem;
|
|
509
517
|
};
|
|
510
|
-
const hideShow = (group,
|
|
511
|
-
if (show) {
|
|
518
|
+
const hideShow = (group, forceShow, toggle = false) => {
|
|
519
|
+
if (forceShow || (toggle && !Array.from(group.classList).includes('show'))) {
|
|
512
520
|
group.classList.add(['show']);
|
|
513
521
|
group.style.display = 'inherit';
|
|
514
522
|
}
|
|
@@ -530,7 +538,9 @@ export default class WebformBuilder extends Component {
|
|
|
530
538
|
const openByDefault = getAttribute(group, 'default') === 'true';
|
|
531
539
|
const groupId = group.getAttribute('id').slice('group-'.length);
|
|
532
540
|
const groupParent = getAttribute(group, 'parent').slice('#builder-sidebar-'.length);
|
|
533
|
-
|
|
541
|
+
if (((openByDefault && groupParent === clickedId) || groupId === clickedParentId || groupIndex === index)) {
|
|
542
|
+
hideShow(group, false, true);
|
|
543
|
+
}
|
|
534
544
|
});
|
|
535
545
|
}, true);
|
|
536
546
|
});
|
|
@@ -1082,7 +1092,7 @@ export default class WebformBuilder extends Component {
|
|
|
1082
1092
|
const newComp = parentComponent.addComponent(defaultValueComponent.component, defaultValueComponent.data, sibling);
|
|
1083
1093
|
_.pull(newComp.validators, 'required');
|
|
1084
1094
|
parentComponent.tabs[tabIndex].splice(index, 1, newComp);
|
|
1085
|
-
newComp.
|
|
1095
|
+
newComp.processOwnValidation = true;
|
|
1086
1096
|
newComp.build(defaultValueComponent.element);
|
|
1087
1097
|
if (this.preview && !this.preview.defaultChanged) {
|
|
1088
1098
|
const defaultValue = _.get(this.preview._data, this.editForm._data.key);
|
|
@@ -1180,6 +1190,7 @@ export default class WebformBuilder extends Component {
|
|
|
1180
1190
|
submissionData = submissionData.componentJson || submissionData;
|
|
1181
1191
|
if (submissionData.components && this.originalDefaultValue) {
|
|
1182
1192
|
submissionData.components = this.originalDefaultValue.components;
|
|
1193
|
+
this.originalDefaultValue = null;
|
|
1183
1194
|
}
|
|
1184
1195
|
const fieldsToRemoveDoubleQuotes = ['label', 'tooltip'];
|
|
1185
1196
|
this.replaceDoubleQuotes(submissionData, fieldsToRemoveDoubleQuotes);
|
package/lib/mjs/Wizard.js
CHANGED
|
@@ -591,7 +591,7 @@ export default class Wizard extends Webform {
|
|
|
591
591
|
if (!this._seenPages.includes(parentNum)) {
|
|
592
592
|
this._seenPages = this._seenPages.concat(parentNum);
|
|
593
593
|
}
|
|
594
|
-
this.redraw().then(() => {
|
|
594
|
+
return this.redraw().then(() => {
|
|
595
595
|
this.checkData(this.submission.data);
|
|
596
596
|
this.triggerCaptcha(this.currentPage.components);
|
|
597
597
|
const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
|
|
@@ -599,7 +599,6 @@ export default class Wizard extends Webform {
|
|
|
599
599
|
this.showErrors(errors, true, true);
|
|
600
600
|
}
|
|
601
601
|
});
|
|
602
|
-
return Promise.resolve();
|
|
603
602
|
}
|
|
604
603
|
else if (!this.pages.length) {
|
|
605
604
|
this.redraw();
|
|
@@ -810,6 +809,11 @@ export default class Wizard extends Webform {
|
|
|
810
809
|
}
|
|
811
810
|
}
|
|
812
811
|
setValue(submission, flags = {}, ignoreEstablishment) {
|
|
812
|
+
if (!submission || !submission.data) {
|
|
813
|
+
submission = {
|
|
814
|
+
data: {},
|
|
815
|
+
};
|
|
816
|
+
}
|
|
813
817
|
const changed = this.getPages({ all: true }).reduce((changed, page) => {
|
|
814
818
|
return this.setNestedValue(page, submission.data, flags, changed) || changed;
|
|
815
819
|
}, false);
|
|
@@ -919,10 +923,7 @@ export default class Wizard extends Webform {
|
|
|
919
923
|
if (pageIndex >= 0) {
|
|
920
924
|
const page = this.pages[pageIndex];
|
|
921
925
|
if (page && page !== this.currentPage) {
|
|
922
|
-
return this.setPage(pageIndex).then(() =>
|
|
923
|
-
this.showErrors(this.validate(this.localData, { dirty: true }));
|
|
924
|
-
super.focusOnComponent(key);
|
|
925
|
-
});
|
|
926
|
+
return this.setPage(pageIndex).then(() => super.focusOnComponent(key));
|
|
926
927
|
}
|
|
927
928
|
}
|
|
928
929
|
}
|
package/lib/mjs/WizardBuilder.js
CHANGED
|
@@ -178,6 +178,10 @@ export default class WizardBuilder extends WebformBuilder {
|
|
|
178
178
|
this.navigationDragula = null;
|
|
179
179
|
super.detach();
|
|
180
180
|
}
|
|
181
|
+
destroy(all = false) {
|
|
182
|
+
this.off('saveComponent');
|
|
183
|
+
super.destroy(all);
|
|
184
|
+
}
|
|
181
185
|
rebuild() {
|
|
182
186
|
const page = this.currentPage;
|
|
183
187
|
this.webform.setForm({
|
|
@@ -54,7 +54,7 @@ export default class Components {
|
|
|
54
54
|
// eslint-disable-next-line new-cap
|
|
55
55
|
comp = new Components.components['datagrid'](component, options, data);
|
|
56
56
|
}
|
|
57
|
-
else if (component.tree) {
|
|
57
|
+
else if (component.tree || (component.input && Array.isArray(component.components))) {
|
|
58
58
|
// eslint-disable-next-line new-cap
|
|
59
59
|
comp = new Components.components['nesteddata'](component, options, data);
|
|
60
60
|
}
|
|
@@ -72,6 +72,12 @@ export default class Components {
|
|
|
72
72
|
if (comp.path) {
|
|
73
73
|
comp.componentsMap[comp.path] = comp;
|
|
74
74
|
}
|
|
75
|
+
// Reset the componentMatches on the root element if any new component is created.
|
|
76
|
+
let parent = comp.parent;
|
|
77
|
+
while (parent) {
|
|
78
|
+
parent.componentMatches = {};
|
|
79
|
+
parent = parent.parent;
|
|
80
|
+
}
|
|
75
81
|
return comp;
|
|
76
82
|
}
|
|
77
83
|
}
|
|
@@ -168,6 +168,7 @@ declare class Component extends Element {
|
|
|
168
168
|
* @returns {boolean} - If the parent should conditionally clear.
|
|
169
169
|
*/
|
|
170
170
|
parentShouldConditionallyClear(): boolean;
|
|
171
|
+
hasCondionallyHiddenLayoutParent(): boolean;
|
|
171
172
|
parentConditionallyHidden(): boolean;
|
|
172
173
|
/**
|
|
173
174
|
* Returns true if any of the parents default their component "hidden" property to true.
|
|
@@ -437,6 +437,16 @@ export default class Component extends Element {
|
|
|
437
437
|
}
|
|
438
438
|
return false;
|
|
439
439
|
}
|
|
440
|
+
hasCondionallyHiddenLayoutParent() {
|
|
441
|
+
let currentParent = this.parent;
|
|
442
|
+
while (currentParent) {
|
|
443
|
+
if (currentParent._conditionallyHidden && FormioUtils.isLayoutComponent(currentParent) && currentParent.component.clearOnHide === true) {
|
|
444
|
+
return true;
|
|
445
|
+
}
|
|
446
|
+
currentParent = currentParent.parent;
|
|
447
|
+
}
|
|
448
|
+
return false;
|
|
449
|
+
}
|
|
440
450
|
parentConditionallyHidden() {
|
|
441
451
|
let currentParent = this.parent;
|
|
442
452
|
while (currentParent) {
|
|
@@ -620,10 +630,13 @@ export default class Component extends Element {
|
|
|
620
630
|
if (!component) {
|
|
621
631
|
component = this.component;
|
|
622
632
|
}
|
|
633
|
+
if (!this.path) {
|
|
634
|
+
return false;
|
|
635
|
+
}
|
|
623
636
|
if (_.isArray(this.options[visibility])) {
|
|
624
|
-
return this.options[visibility].includes(
|
|
637
|
+
return this.options[visibility].includes(this.path);
|
|
625
638
|
}
|
|
626
|
-
return this.options[visibility][
|
|
639
|
+
return this.options[visibility][this.path];
|
|
627
640
|
}
|
|
628
641
|
shouldForceHide(component) {
|
|
629
642
|
return this.shouldForceVisibility(component, 'hide');
|
|
@@ -703,7 +716,7 @@ export default class Component extends Element {
|
|
|
703
716
|
this._conditionallyClear = true;
|
|
704
717
|
return this._conditionallyClear;
|
|
705
718
|
}
|
|
706
|
-
this._conditionallyClear = this.hasSetValue ?
|
|
719
|
+
this._conditionallyClear = this.hasSetValue ? this.hasCondionallyHiddenLayoutParent() : this.parentShouldConditionallyClear();
|
|
707
720
|
return this._conditionallyClear;
|
|
708
721
|
}
|
|
709
722
|
/**
|
|
@@ -1160,9 +1173,15 @@ export default class Component extends Element {
|
|
|
1160
1173
|
if (this.hasInput && this.component.validate?.required && !this.isPDFReadOnlyMode) {
|
|
1161
1174
|
modalLabel = { className: 'field-required' };
|
|
1162
1175
|
}
|
|
1176
|
+
let messages = '';
|
|
1177
|
+
if (this.errors?.length) {
|
|
1178
|
+
messages = this.errors.map((err) => {
|
|
1179
|
+
return err.level === 'error' ? this.renderTemplate('message', { ...err }) : '';
|
|
1180
|
+
}).join('');
|
|
1181
|
+
}
|
|
1163
1182
|
return this.renderModalPreview({
|
|
1164
1183
|
previewText: this.getValueAsString(dataValue, { modalPreview: true }) || this.t('clickToSetValue'),
|
|
1165
|
-
messages
|
|
1184
|
+
messages,
|
|
1166
1185
|
labelInfo: modalLabel,
|
|
1167
1186
|
});
|
|
1168
1187
|
}
|
|
@@ -2549,7 +2568,7 @@ export default class Component extends Element {
|
|
|
2549
2568
|
if ((value !== null) && (value !== undefined)) {
|
|
2550
2569
|
value = this.hook('setDataValue', value, this.key, this._data);
|
|
2551
2570
|
}
|
|
2552
|
-
if ((value === null) || (value === undefined)) {
|
|
2571
|
+
if ((value === null) || (value === undefined) || _.isNaN(value)) {
|
|
2553
2572
|
this.unset();
|
|
2554
2573
|
return;
|
|
2555
2574
|
}
|
|
@@ -2582,17 +2601,6 @@ export default class Component extends Element {
|
|
|
2582
2601
|
noUpdateEvent: true,
|
|
2583
2602
|
noDefault: true
|
|
2584
2603
|
});
|
|
2585
|
-
if (FormioUtils.isLayoutComponent(this.component) && this.component.clearOnHide === true && !this.hasValue()) {
|
|
2586
|
-
FormioUtils.eachComponent(this.components, (component) => {
|
|
2587
|
-
if (component.component.clearOnHide !== false) {
|
|
2588
|
-
component.setValue(null, {
|
|
2589
|
-
noUpdateEvent: true,
|
|
2590
|
-
noDefault: true
|
|
2591
|
-
});
|
|
2592
|
-
component.unset();
|
|
2593
|
-
}
|
|
2594
|
-
});
|
|
2595
|
-
}
|
|
2596
2604
|
this.unset();
|
|
2597
2605
|
}
|
|
2598
2606
|
getCustomDefaultValue(defaultValue) {
|
|
@@ -2718,6 +2726,11 @@ export default class Component extends Element {
|
|
|
2718
2726
|
this.setValueAt(i, isArray && !this.isSingleInputValue() ? value[i] : value, flags);
|
|
2719
2727
|
}
|
|
2720
2728
|
}
|
|
2729
|
+
// Also reset value of the modal component, otherwise it will keep the old value locally and the preview
|
|
2730
|
+
// element won't refresh
|
|
2731
|
+
if (this.componentModal && flags && flags.resetValue) {
|
|
2732
|
+
this.componentModal.setValue(value);
|
|
2733
|
+
}
|
|
2721
2734
|
return changed;
|
|
2722
2735
|
}
|
|
2723
2736
|
/**
|