@formio/js 5.1.0-dev.6218.dde7b07 → 5.1.0-dev.6221.d976115
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.form.js +5 -5
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +7 -7
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.utils.js +1 -1
- package/dist/formio.utils.min.js +1 -1
- package/lib/cjs/Element.js +2 -2
- package/lib/cjs/WebformBuilder.js +6 -3
- package/lib/cjs/WizardBuilder.js +4 -0
- package/lib/cjs/components/form/Form.d.ts +1 -0
- package/lib/cjs/components/form/Form.js +9 -3
- package/lib/cjs/components/number/Number.js +4 -1
- package/lib/cjs/formio.form.d.ts +2 -1
- package/lib/cjs/formio.form.js +2 -1
- package/lib/cjs/utils/index.d.ts +3 -2
- package/lib/cjs/utils/index.js +2 -1
- package/lib/mjs/Element.js +2 -2
- package/lib/mjs/WebformBuilder.js +6 -3
- package/lib/mjs/WizardBuilder.js +4 -0
- package/lib/mjs/components/form/Form.d.ts +1 -0
- package/lib/mjs/components/form/Form.js +9 -3
- package/lib/mjs/components/number/Number.js +4 -1
- package/lib/mjs/formio.form.d.ts +2 -1
- package/lib/mjs/formio.form.js +2 -2
- package/lib/mjs/utils/index.d.ts +3 -2
- package/lib/mjs/utils/index.js +2 -2
- package/package.json +1 -1
package/lib/cjs/Element.js
CHANGED
@@ -533,9 +533,9 @@ class Element {
|
|
533
533
|
if (this.component.filter === string && !this.options.building) {
|
534
534
|
const evalContext = this.evalContext(data);
|
535
535
|
evalContext.data = lodash_1.default.mapValues(evalContext.data, (val) => lodash_1.default.isString(val) ? encodeURIComponent(val) : val);
|
536
|
-
return utils_1.default.
|
536
|
+
return utils_1.default.interpolate(string, evalContext, options);
|
537
537
|
}
|
538
|
-
return utils_1.default.
|
538
|
+
return utils_1.default.interpolate(string, this.evalContext(data), options);
|
539
539
|
}
|
540
540
|
/**
|
541
541
|
* Performs an evaluation using the evaluation context of this component.
|
@@ -529,8 +529,8 @@ class WebformBuilder extends Component_1.default {
|
|
529
529
|
}
|
530
530
|
return elem;
|
531
531
|
};
|
532
|
-
const hideShow = (group,
|
533
|
-
if (show) {
|
532
|
+
const hideShow = (group, forceShow, toggle = false) => {
|
533
|
+
if (forceShow || (toggle && !Array.from(group.classList).includes('show'))) {
|
534
534
|
group.classList.add(['show']);
|
535
535
|
group.style.display = 'inherit';
|
536
536
|
}
|
@@ -552,7 +552,9 @@ class WebformBuilder extends Component_1.default {
|
|
552
552
|
const openByDefault = getAttribute(group, 'default') === 'true';
|
553
553
|
const groupId = group.getAttribute('id').slice('group-'.length);
|
554
554
|
const groupParent = getAttribute(group, 'parent').slice('#builder-sidebar-'.length);
|
555
|
-
|
555
|
+
if (((openByDefault && groupParent === clickedId) || groupId === clickedParentId || groupIndex === index)) {
|
556
|
+
hideShow(group, false, true);
|
557
|
+
}
|
556
558
|
});
|
557
559
|
}, true);
|
558
560
|
});
|
@@ -1206,6 +1208,7 @@ class WebformBuilder extends Component_1.default {
|
|
1206
1208
|
submissionData = submissionData.componentJson || submissionData;
|
1207
1209
|
if (submissionData.components && this.originalDefaultValue) {
|
1208
1210
|
submissionData.components = this.originalDefaultValue.components;
|
1211
|
+
this.originalDefaultValue = null;
|
1209
1212
|
}
|
1210
1213
|
const fieldsToRemoveDoubleQuotes = ['label', 'tooltip'];
|
1211
1214
|
this.replaceDoubleQuotes(submissionData, fieldsToRemoveDoubleQuotes);
|
package/lib/cjs/WizardBuilder.js
CHANGED
@@ -183,6 +183,10 @@ class WizardBuilder extends WebformBuilder_1.default {
|
|
183
183
|
this.navigationDragula = null;
|
184
184
|
super.detach();
|
185
185
|
}
|
186
|
+
destroy(all = false) {
|
187
|
+
this.off('saveComponent');
|
188
|
+
super.destroy(all);
|
189
|
+
}
|
186
190
|
rebuild() {
|
187
191
|
var _a;
|
188
192
|
const page = this.currentPage;
|
@@ -42,6 +42,7 @@ export default class FormComponent extends Component {
|
|
42
42
|
everyComponent(...args: any[]): any;
|
43
43
|
setSubFormDisabled(subForm: any): void;
|
44
44
|
updateSubWizards(subForm: any): void;
|
45
|
+
setComponentsMap(): void;
|
45
46
|
/**
|
46
47
|
* Create a subform instance.
|
47
48
|
* @param {boolean} [fromAttach] - This function is being called from an `attach` method.
|
@@ -315,6 +315,7 @@ class FormComponent extends Component_1.default {
|
|
315
315
|
}
|
316
316
|
}
|
317
317
|
postAttach();
|
318
|
+
this.setComponentsMap();
|
318
319
|
});
|
319
320
|
}
|
320
321
|
postAttach();
|
@@ -395,6 +396,14 @@ class FormComponent extends Component_1.default {
|
|
395
396
|
this.emit('subWizardsUpdated', subForm);
|
396
397
|
}
|
397
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
|
+
}
|
398
407
|
/**
|
399
408
|
* Create a subform instance.
|
400
409
|
* @param {boolean} [fromAttach] - This function is being called from an `attach` method.
|
@@ -420,9 +429,6 @@ class FormComponent extends Component_1.default {
|
|
420
429
|
this.subForm = instance;
|
421
430
|
this.subForm.currentForm = this;
|
422
431
|
this.subForm.parentVisible = this.visible;
|
423
|
-
const componentsMap = this.componentsMap;
|
424
|
-
const formComponentsMap = this.subForm.componentsMap;
|
425
|
-
lodash_1.default.assign(componentsMap, formComponentsMap);
|
426
432
|
this.component.components = (_a = this.subForm._form) === null || _a === void 0 ? void 0 : _a.components;
|
427
433
|
this.component.display = (_b = this.subForm._form) === null || _b === void 0 ? void 0 : _b.display;
|
428
434
|
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;
|
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) => {
|
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;
|
@@ -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/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.
|
@@ -515,8 +515,8 @@ export default class WebformBuilder extends Component {
|
|
515
515
|
}
|
516
516
|
return elem;
|
517
517
|
};
|
518
|
-
const hideShow = (group,
|
519
|
-
if (show) {
|
518
|
+
const hideShow = (group, forceShow, toggle = false) => {
|
519
|
+
if (forceShow || (toggle && !Array.from(group.classList).includes('show'))) {
|
520
520
|
group.classList.add(['show']);
|
521
521
|
group.style.display = 'inherit';
|
522
522
|
}
|
@@ -538,7 +538,9 @@ export default class WebformBuilder extends Component {
|
|
538
538
|
const openByDefault = getAttribute(group, 'default') === 'true';
|
539
539
|
const groupId = group.getAttribute('id').slice('group-'.length);
|
540
540
|
const groupParent = getAttribute(group, 'parent').slice('#builder-sidebar-'.length);
|
541
|
-
|
541
|
+
if (((openByDefault && groupParent === clickedId) || groupId === clickedParentId || groupIndex === index)) {
|
542
|
+
hideShow(group, false, true);
|
543
|
+
}
|
542
544
|
});
|
543
545
|
}, true);
|
544
546
|
});
|
@@ -1188,6 +1190,7 @@ export default class WebformBuilder extends Component {
|
|
1188
1190
|
submissionData = submissionData.componentJson || submissionData;
|
1189
1191
|
if (submissionData.components && this.originalDefaultValue) {
|
1190
1192
|
submissionData.components = this.originalDefaultValue.components;
|
1193
|
+
this.originalDefaultValue = null;
|
1191
1194
|
}
|
1192
1195
|
const fieldsToRemoveDoubleQuotes = ['label', 'tooltip'];
|
1193
1196
|
this.replaceDoubleQuotes(submissionData, fieldsToRemoveDoubleQuotes);
|
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({
|
@@ -42,6 +42,7 @@ export default class FormComponent extends Component {
|
|
42
42
|
everyComponent(...args: any[]): any;
|
43
43
|
setSubFormDisabled(subForm: any): void;
|
44
44
|
updateSubWizards(subForm: any): void;
|
45
|
+
setComponentsMap(): void;
|
45
46
|
/**
|
46
47
|
* Create a subform instance.
|
47
48
|
* @param {boolean} [fromAttach] - This function is being called from an `attach` method.
|
@@ -311,6 +311,7 @@ export default class FormComponent extends Component {
|
|
311
311
|
}
|
312
312
|
}
|
313
313
|
postAttach();
|
314
|
+
this.setComponentsMap();
|
314
315
|
});
|
315
316
|
}
|
316
317
|
postAttach();
|
@@ -389,6 +390,14 @@ export default class FormComponent extends Component {
|
|
389
390
|
this.emit('subWizardsUpdated', subForm);
|
390
391
|
}
|
391
392
|
}
|
393
|
+
setComponentsMap() {
|
394
|
+
if (!this.subForm) {
|
395
|
+
return;
|
396
|
+
}
|
397
|
+
const componentsMap = this.componentsMap;
|
398
|
+
const formComponentsMap = this.subForm.componentsMap;
|
399
|
+
_.assign(componentsMap, formComponentsMap);
|
400
|
+
}
|
392
401
|
/**
|
393
402
|
* Create a subform instance.
|
394
403
|
* @param {boolean} [fromAttach] - This function is being called from an `attach` method.
|
@@ -413,9 +422,6 @@ export default class FormComponent extends Component {
|
|
413
422
|
this.subForm = instance;
|
414
423
|
this.subForm.currentForm = this;
|
415
424
|
this.subForm.parentVisible = this.visible;
|
416
|
-
const componentsMap = this.componentsMap;
|
417
|
-
const formComponentsMap = this.subForm.componentsMap;
|
418
|
-
_.assign(componentsMap, formComponentsMap);
|
419
425
|
this.component.components = this.subForm._form?.components;
|
420
426
|
this.component.display = this.subForm._form?.display;
|
421
427
|
this.subForm.on('change', () => {
|
@@ -89,10 +89,13 @@ export default class NumberComponent extends Input {
|
|
89
89
|
}
|
90
90
|
get defaultValue() {
|
91
91
|
let defaultValue = super.defaultValue;
|
92
|
-
if (typeof defaultValue === 'string') {
|
92
|
+
if (typeof defaultValue === 'string' && defaultValue) {
|
93
93
|
// Default value may be a string or have custom thousands separators or decimal symbols, so we need to call
|
94
94
|
// parseNumber on it
|
95
95
|
defaultValue = this.parseNumber(defaultValue);
|
96
|
+
if (_.isNaN(defaultValue)) {
|
97
|
+
defaultValue = null;
|
98
|
+
}
|
96
99
|
}
|
97
100
|
if (!defaultValue && this.component.defaultValue === 0) {
|
98
101
|
defaultValue = this.component.defaultValue;
|
package/lib/mjs/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/mjs/formio.form.js
CHANGED
@@ -12,7 +12,7 @@ import Licenses from './licenses';
|
|
12
12
|
import EventEmitter from './EventEmitter';
|
13
13
|
import Webform from './Webform';
|
14
14
|
import { I18n } from '@formio/core';
|
15
|
-
import { Evaluator, registerEvaluator } from './utils';
|
15
|
+
import { Evaluator, registerEvaluator, DefaultEvaluator } from './utils';
|
16
16
|
Formio.loadModules = (path = `${Formio.getApiUrl()}/externalModules.js`, name = 'externalModules') => {
|
17
17
|
Formio.requireLibrary(name, name, path, true)
|
18
18
|
.then((modules) => {
|
@@ -130,4 +130,4 @@ export function useModule(defaultFn = null) {
|
|
130
130
|
Formio.use = useModule();
|
131
131
|
export { Formio as FormioCore } from './Formio';
|
132
132
|
// Export the components.
|
133
|
-
export { Components, Displays, Providers, Widgets, Templates, Utils, Form, Formio, Licenses, EventEmitter, Webform };
|
133
|
+
export { Components, Displays, Providers, Widgets, Templates, Utils, Form, Formio, Licenses, EventEmitter, Webform, DefaultEvaluator };
|
package/lib/mjs/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;
|
@@ -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/mjs/utils/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import * as utils from './utils';
|
2
2
|
import * as formUtils from './formUtils';
|
3
|
-
import { Evaluator, registerEvaluator, interpolate } from './Evaluator';
|
3
|
+
import { Evaluator, registerEvaluator, interpolate, DefaultEvaluator } from './Evaluator';
|
4
4
|
import ConditionOperators from './conditionOperators';
|
5
5
|
import _ from 'lodash';
|
6
6
|
import moment from 'moment';
|
@@ -17,7 +17,7 @@ if (typeof global === 'object') {
|
|
17
17
|
global.FormioUtils = FormioUtils;
|
18
18
|
}
|
19
19
|
export { FormioUtils as Utils };
|
20
|
-
export { Evaluator, registerEvaluator };
|
20
|
+
export { Evaluator, DefaultEvaluator, registerEvaluator };
|
21
21
|
export * from './utils';
|
22
22
|
export * from './formUtils';
|
23
23
|
export default FormioUtils;
|