@formio/js 5.1.0-dev.5522.293c9bf → 5.1.0-dev.5892.54c1dc7
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 +9 -9
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +10 -10
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.js +4 -4
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +7 -7
- package/dist/formio.utils.min.js +1 -1
- package/lib/cjs/WebformBuilder.js +12 -6
- package/lib/cjs/components/button/Button.d.ts +1 -1
- package/lib/cjs/components/button/Button.js +4 -4
- package/lib/cjs/components/radio/Radio.d.ts +8 -0
- package/lib/cjs/components/radio/Radio.js +15 -5
- package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +6 -0
- package/lib/cjs/utils/Evaluator.d.ts +7 -1
- package/lib/cjs/utils/Evaluator.js +10 -1
- package/lib/cjs/utils/index.d.ts +8 -1
- package/lib/cjs/utils/index.js +10 -1
- package/lib/cjs/utils/utils.js +10 -3
- package/lib/mjs/WebformBuilder.js +13 -7
- package/lib/mjs/components/button/Button.d.ts +1 -1
- package/lib/mjs/components/button/Button.js +1 -1
- package/lib/mjs/components/radio/Radio.d.ts +8 -0
- package/lib/mjs/components/radio/Radio.js +15 -5
- package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +6 -0
- package/lib/mjs/utils/Evaluator.d.ts +7 -1
- package/lib/mjs/utils/Evaluator.js +9 -1
- package/lib/mjs/utils/index.d.ts +8 -1
- package/lib/mjs/utils/index.js +7 -1
- package/lib/mjs/utils/utils.js +10 -2
- package/package.json +2 -2
@@ -1129,11 +1129,14 @@ class WebformBuilder extends Component_1.default {
|
|
1129
1129
|
const repeatablePaths = [];
|
1130
1130
|
const keys = new Map();
|
1131
1131
|
(0, utils_1.eachComponent)(this.form.components, (comp, path, components, parent, paths) => {
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1132
|
+
const isLayout = (0, utils_1.componentInfo)(comp).layout;
|
1133
|
+
if (!isLayout) {
|
1134
|
+
if (keys.has(paths.dataPath)) {
|
1135
|
+
repeatablePaths.push(paths.dataPath);
|
1136
|
+
}
|
1137
|
+
else {
|
1138
|
+
keys.set(paths.dataPath, true);
|
1139
|
+
}
|
1137
1140
|
}
|
1138
1141
|
}, true);
|
1139
1142
|
return repeatablePaths;
|
@@ -1150,10 +1153,13 @@ class WebformBuilder extends Component_1.default {
|
|
1150
1153
|
comp.setCustomValidity(this.t('apiKey', { key: comp.key }));
|
1151
1154
|
hasInvalidComponents = true;
|
1152
1155
|
}
|
1153
|
-
if (comp.key.replace(badCharacters, '') === '') {
|
1156
|
+
else if (comp.key.replace(badCharacters, '') === '') {
|
1154
1157
|
comp.setCustomValidity(this.t('apiKeyNotValid', { key: comp.key }));
|
1155
1158
|
hasInvalidComponents = true;
|
1156
1159
|
}
|
1160
|
+
else {
|
1161
|
+
comp.setCustomValidity();
|
1162
|
+
}
|
1157
1163
|
});
|
1158
1164
|
this.emit('builderFormValidityChange', hasInvalidComponents);
|
1159
1165
|
}
|
@@ -7,7 +7,7 @@ export default class ButtonComponent extends Field {
|
|
7
7
|
weight: number;
|
8
8
|
schema: any;
|
9
9
|
};
|
10
|
-
static savedValueTypes(schema: any):
|
10
|
+
static savedValueTypes(schema: any): string[];
|
11
11
|
constructor(component: any, options: any, data: any);
|
12
12
|
filesUploading: number;
|
13
13
|
get inputInfo(): any;
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const lodash_1 = __importDefault(require("lodash"));
|
7
7
|
const Field_1 = __importDefault(require("../_classes/field/Field"));
|
8
8
|
const Input_1 = __importDefault(require("../_classes/input/Input"));
|
9
|
-
const
|
9
|
+
const utils_1 = require("../../utils");
|
10
10
|
class ButtonComponent extends Field_1.default {
|
11
11
|
static schema(...extend) {
|
12
12
|
return Input_1.default.schema({
|
@@ -35,7 +35,7 @@ class ButtonComponent extends Field_1.default {
|
|
35
35
|
};
|
36
36
|
}
|
37
37
|
static savedValueTypes(schema) {
|
38
|
-
return (0,
|
38
|
+
return (0, utils_1.getComponentSavedTypes)(schema) || [utils_1.componentValueTypes.boolean];
|
39
39
|
}
|
40
40
|
constructor(component, options, data) {
|
41
41
|
super(component, options, data);
|
@@ -306,7 +306,7 @@ class ButtonComponent extends Field_1.default {
|
|
306
306
|
const form = this.getRoot();
|
307
307
|
const flattened = {};
|
308
308
|
const components = {};
|
309
|
-
(0,
|
309
|
+
(0, utils_1.eachComponent)(form.components, (componentWrapper, path) => {
|
310
310
|
const component = componentWrapper.component || componentWrapper;
|
311
311
|
flattened[path] = component;
|
312
312
|
components[component.key] = component;
|
@@ -447,7 +447,7 @@ class ButtonComponent extends Field_1.default {
|
|
447
447
|
}, 100);
|
448
448
|
}
|
449
449
|
get oauthComponentPath() {
|
450
|
-
const pathArray = (0,
|
450
|
+
const pathArray = (0, utils_1.getArrayFromComponentPath)(this.path);
|
451
451
|
return lodash_1.default.chain(pathArray).filter(pathPart => !lodash_1.default.isNumber(pathPart)).join('.').value();
|
452
452
|
}
|
453
453
|
focus() {
|
@@ -28,6 +28,7 @@ export default class RadioComponent extends ListComponent {
|
|
28
28
|
optionsLoaded: boolean | undefined;
|
29
29
|
loadedOptions: any[] | undefined;
|
30
30
|
beforeSubmit(): Promise<any>;
|
31
|
+
convertValues(values: any): any;
|
31
32
|
render(): string;
|
32
33
|
attach(element: any): Promise<void>;
|
33
34
|
detach(element: any): void;
|
@@ -41,5 +42,12 @@ export default class RadioComponent extends ListComponent {
|
|
41
42
|
setSelectedClasses(): void;
|
42
43
|
updateValue(value: any, flags: any): boolean;
|
43
44
|
currentValue: any;
|
45
|
+
/**
|
46
|
+
* Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
|
47
|
+
* @param {*} value - The value to normalize
|
48
|
+
* @returns {*} - Returns the normalized value
|
49
|
+
*/
|
50
|
+
convertByDataType(value: any): any;
|
51
|
+
normalizeValue(value: any): any;
|
44
52
|
}
|
45
53
|
import ListComponent from '../_classes/list/ListComponent';
|
@@ -153,6 +153,12 @@ class RadioComponent extends ListComponent_1.default {
|
|
153
153
|
this.dataReady.then(() => res(true));
|
154
154
|
});
|
155
155
|
}
|
156
|
+
convertValues(values) {
|
157
|
+
if (this.options.renderMode === 'html' && this.type === 'radio') {
|
158
|
+
return values.map(x => (Object.assign(Object.assign({}, x), { value: this.convertByDataType(x.value) })));
|
159
|
+
}
|
160
|
+
return values;
|
161
|
+
}
|
156
162
|
render() {
|
157
163
|
if (!this.optionsLoaded) {
|
158
164
|
return super.render(this.renderTemplate('loader'));
|
@@ -160,7 +166,7 @@ class RadioComponent extends ListComponent_1.default {
|
|
160
166
|
return super.render(this.renderTemplate('radio', {
|
161
167
|
input: this.inputInfo,
|
162
168
|
inline: this.component.inline,
|
163
|
-
values: this.component.dataSrc === 'values' ? this.component.values : this.loadedOptions,
|
169
|
+
values: this.component.dataSrc === 'values' ? this.convertValues(this.component.values) : this.loadedOptions,
|
164
170
|
value: this.dataValue,
|
165
171
|
row: this.row,
|
166
172
|
}));
|
@@ -406,7 +412,7 @@ class RadioComponent extends ListComponent_1.default {
|
|
406
412
|
* @param {*} value - The value to normalize
|
407
413
|
* @returns {*} - Returns the normalized value
|
408
414
|
*/
|
409
|
-
|
415
|
+
convertByDataType(value) {
|
410
416
|
const dataType = this.component.dataType || 'auto';
|
411
417
|
if (value === this.emptyValue) {
|
412
418
|
return value;
|
@@ -438,14 +444,18 @@ class RadioComponent extends ListComponent_1.default {
|
|
438
444
|
value = !(!value || value.toString() === 'false');
|
439
445
|
break;
|
440
446
|
}
|
441
|
-
|
447
|
+
return value;
|
448
|
+
}
|
449
|
+
normalizeValue(value) {
|
450
|
+
const valueConverted = this.convertByDataType(value);
|
451
|
+
if (this.isSelectURL && this.templateData && this.templateData[valueConverted]) {
|
442
452
|
const submission = this.root.submission;
|
443
453
|
if (!submission.metadata.selectData) {
|
444
454
|
submission.metadata.selectData = {};
|
445
455
|
}
|
446
|
-
lodash_1.default.set(submission.metadata.selectData, this.path, this.templateData[
|
456
|
+
lodash_1.default.set(submission.metadata.selectData, this.path, this.templateData[valueConverted]);
|
447
457
|
}
|
448
|
-
return super.normalizeValue(
|
458
|
+
return super.normalizeValue(valueConverted);
|
449
459
|
}
|
450
460
|
}
|
451
461
|
exports.default = RadioComponent;
|
@@ -8,6 +8,12 @@ export default class SelectBoxesComponent extends RadioComponent {
|
|
8
8
|
* @returns {boolean} - If the value is empty.
|
9
9
|
*/
|
10
10
|
isEmpty(value?: any): boolean;
|
11
|
+
/**
|
12
|
+
* Normalize values coming into updateValue.
|
13
|
+
* @param {any} value - The value to normalize.
|
14
|
+
* @returns {*} - The normalized value
|
15
|
+
*/
|
16
|
+
normalizeValue(value: any): any;
|
11
17
|
setInputsDisabled(value: any, onlyUnchecked: any): void;
|
12
18
|
checkComponentValidity(data: any, dirty: any, rowData: any, options: any, errors?: any[]): boolean;
|
13
19
|
}
|
@@ -1,3 +1,10 @@
|
|
1
|
+
/**
|
2
|
+
* For backwards compatibility we a standalone interpolate function. This merely calls the
|
3
|
+
* global mutable Evaluator instance's interpolate function.
|
4
|
+
* @param {...any} args - interpolate arguments, typically "rawTemplate", "data", and "options"
|
5
|
+
* @returns {any} the interpolation result.
|
6
|
+
*/
|
7
|
+
export function interpolate(...args: any[]): any;
|
1
8
|
/**
|
2
9
|
* Set the evaluator to use for evaluating expressions.
|
3
10
|
* @param {CoreEvaluator} override - The new evaluator instance to use.
|
@@ -11,5 +18,4 @@ export class DefaultEvaluator extends CoreEvaluator {
|
|
11
18
|
interpolate(rawTemplate: any, data: any, _options: any): any;
|
12
19
|
}
|
13
20
|
export let Evaluator: DefaultEvaluator;
|
14
|
-
export function interpolate(rawTemplate: any, data: any, _options: any): any;
|
15
21
|
import { DefaultEvaluator as CoreEvaluator } from '@formio/core';
|
@@ -62,7 +62,16 @@ class DefaultEvaluator extends core_1.DefaultEvaluator {
|
|
62
62
|
exports.DefaultEvaluator = DefaultEvaluator;
|
63
63
|
exports.Evaluator = new DefaultEvaluator();
|
64
64
|
// preserve the standalone interpolate function for backwards compatibility
|
65
|
-
|
65
|
+
/**
|
66
|
+
* For backwards compatibility we a standalone interpolate function. This merely calls the
|
67
|
+
* global mutable Evaluator instance's interpolate function.
|
68
|
+
* @param {...any} args - interpolate arguments, typically "rawTemplate", "data", and "options"
|
69
|
+
* @returns {any} the interpolation result.
|
70
|
+
*/
|
71
|
+
function interpolate(...args) {
|
72
|
+
return exports.Evaluator.interpolate(...args);
|
73
|
+
}
|
74
|
+
exports.interpolate = interpolate;
|
66
75
|
/**
|
67
76
|
* Set the evaluator to use for evaluating expressions.
|
68
77
|
* @param {CoreEvaluator} override - The new evaluator instance to use.
|
package/lib/cjs/utils/index.d.ts
CHANGED
@@ -3,7 +3,12 @@ export * from "./formUtils";
|
|
3
3
|
export default FormioUtils;
|
4
4
|
declare const FormioUtils: {
|
5
5
|
Evaluator: import("./Evaluator").DefaultEvaluator;
|
6
|
-
interpolate:
|
6
|
+
interpolate: typeof interpolate;
|
7
|
+
ConditionOperators: {
|
8
|
+
[x: string]: typeof import("./conditionOperators/IsEqualTo").default | typeof import("./conditionOperators/DateGreaterThan").default;
|
9
|
+
};
|
10
|
+
_: any;
|
11
|
+
moment: typeof moment;
|
7
12
|
flattenComponents: typeof import("@formio/core/lib/utils/formUtil").flattenComponents;
|
8
13
|
guid: typeof import("@formio/core/lib/utils/formUtil").guid;
|
9
14
|
uniqueName: typeof import("@formio/core/lib/utils/formUtil").uniqueName;
|
@@ -160,4 +165,6 @@ declare const FormioUtils: {
|
|
160
165
|
};
|
161
166
|
import { Evaluator } from './Evaluator';
|
162
167
|
import { registerEvaluator } from './Evaluator';
|
168
|
+
import { interpolate } from './Evaluator';
|
169
|
+
import moment from 'moment';
|
163
170
|
export { FormioUtils as Utils, Evaluator, registerEvaluator };
|
package/lib/cjs/utils/index.js
CHANGED
@@ -25,6 +25,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
25
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
26
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
27
27
|
};
|
28
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
29
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
30
|
+
};
|
28
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
32
|
exports.registerEvaluator = exports.Evaluator = exports.Utils = void 0;
|
30
33
|
const utils = __importStar(require("./utils"));
|
@@ -32,8 +35,14 @@ const formUtils = __importStar(require("./formUtils"));
|
|
32
35
|
const Evaluator_1 = require("./Evaluator");
|
33
36
|
Object.defineProperty(exports, "Evaluator", { enumerable: true, get: function () { return Evaluator_1.Evaluator; } });
|
34
37
|
Object.defineProperty(exports, "registerEvaluator", { enumerable: true, get: function () { return Evaluator_1.registerEvaluator; } });
|
38
|
+
const conditionOperators_1 = __importDefault(require("./conditionOperators"));
|
39
|
+
const lodash_1 = __importDefault(require("lodash"));
|
40
|
+
const moment_1 = __importDefault(require("moment"));
|
35
41
|
const FormioUtils = Object.assign(Object.assign(Object.assign({}, utils), formUtils), { Evaluator: Evaluator_1.Evaluator,
|
36
|
-
interpolate: Evaluator_1.interpolate
|
42
|
+
interpolate: Evaluator_1.interpolate,
|
43
|
+
ConditionOperators: conditionOperators_1.default,
|
44
|
+
_: lodash_1.default,
|
45
|
+
moment: moment_1.default });
|
37
46
|
exports.Utils = FormioUtils;
|
38
47
|
if (typeof global === 'object') {
|
39
48
|
global.FormioUtils = FormioUtils;
|
package/lib/cjs/utils/utils.js
CHANGED
@@ -209,13 +209,20 @@ function checkSimpleConditional(component, condition, row, data, instance) {
|
|
209
209
|
return true;
|
210
210
|
}
|
211
211
|
const conditionsResult = lodash_1.default.map(conditions, (cond) => {
|
212
|
-
var _a, _b;
|
213
212
|
const { value: comparedValue, operator, component: conditionComponentPath } = cond;
|
214
213
|
if (!conditionComponentPath) {
|
215
214
|
return true;
|
216
215
|
}
|
217
216
|
const splittedConditionPath = conditionComponentPath.split('.');
|
218
|
-
const
|
217
|
+
const checkParentTypeInTree = (instance, componentType) => {
|
218
|
+
if (!(instance === null || instance === void 0 ? void 0 : instance.parent)) {
|
219
|
+
return false;
|
220
|
+
}
|
221
|
+
return (instance === null || instance === void 0 ? void 0 : instance.parent.type) === componentType || checkParentTypeInTree(instance.parent, componentType);
|
222
|
+
};
|
223
|
+
const conditionalPaths = checkParentTypeInTree(instance, 'datagrid') || checkParentTypeInTree(instance, 'editgrid')
|
224
|
+
? []
|
225
|
+
: getConditionalPathsRecursive(splittedConditionPath, data);
|
219
226
|
if (conditionalPaths.length > 0) {
|
220
227
|
return conditionalPaths.map((path) => {
|
221
228
|
const value = getComponentActualValue(path, data, row);
|
@@ -334,7 +341,7 @@ function getRow(component, row, instance, conditional) {
|
|
334
341
|
}
|
335
342
|
const dataParent = getDataParentComponent(instance);
|
336
343
|
if (dataParent) {
|
337
|
-
const parentPath = (_a = dataParent.paths) === null || _a === void 0 ? void 0 : _a.
|
344
|
+
const parentPath = (_a = dataParent.paths) === null || _a === void 0 ? void 0 : _a.localPath;
|
338
345
|
const isTriggerCondtionComponentPath = condition.when || !condition.conditions
|
339
346
|
? (_b = condition.when) === null || _b === void 0 ? void 0 : _b.startsWith((_c = dataParent.paths) === null || _c === void 0 ? void 0 : _c.localPath)
|
340
347
|
: lodash_1.default.some(condition.conditions, cond => { var _a; return cond.component.startsWith((_a = dataParent.paths) === null || _a === void 0 ? void 0 : _a.localPath); });
|
@@ -3,7 +3,7 @@ import Component from './components/_classes/component/Component';
|
|
3
3
|
import tippy from 'tippy.js';
|
4
4
|
import Components from './components/Components';
|
5
5
|
import { Formio } from './Formio';
|
6
|
-
import { fastCloneDeep, bootstrapVersion, getArrayFromComponentPath, getStringFromComponentPath, eachComponent, getComponent, } from './utils';
|
6
|
+
import { fastCloneDeep, bootstrapVersion, getArrayFromComponentPath, getStringFromComponentPath, eachComponent, getComponent, componentInfo } from './utils';
|
7
7
|
import BuilderUtils from './utils/builder';
|
8
8
|
import _ from 'lodash';
|
9
9
|
import autoScroll from 'dom-autoscroller';
|
@@ -1112,11 +1112,14 @@ export default class WebformBuilder extends Component {
|
|
1112
1112
|
const repeatablePaths = [];
|
1113
1113
|
const keys = new Map();
|
1114
1114
|
eachComponent(this.form.components, (comp, path, components, parent, paths) => {
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1115
|
+
const isLayout = componentInfo(comp).layout;
|
1116
|
+
if (!isLayout) {
|
1117
|
+
if (keys.has(paths.dataPath)) {
|
1118
|
+
repeatablePaths.push(paths.dataPath);
|
1119
|
+
}
|
1120
|
+
else {
|
1121
|
+
keys.set(paths.dataPath, true);
|
1122
|
+
}
|
1120
1123
|
}
|
1121
1124
|
}, true);
|
1122
1125
|
return repeatablePaths;
|
@@ -1133,10 +1136,13 @@ export default class WebformBuilder extends Component {
|
|
1133
1136
|
comp.setCustomValidity(this.t('apiKey', { key: comp.key }));
|
1134
1137
|
hasInvalidComponents = true;
|
1135
1138
|
}
|
1136
|
-
if (comp.key.replace(badCharacters, '') === '') {
|
1139
|
+
else if (comp.key.replace(badCharacters, '') === '') {
|
1137
1140
|
comp.setCustomValidity(this.t('apiKeyNotValid', { key: comp.key }));
|
1138
1141
|
hasInvalidComponents = true;
|
1139
1142
|
}
|
1143
|
+
else {
|
1144
|
+
comp.setCustomValidity();
|
1145
|
+
}
|
1140
1146
|
});
|
1141
1147
|
this.emit('builderFormValidityChange', hasInvalidComponents);
|
1142
1148
|
}
|
@@ -7,7 +7,7 @@ export default class ButtonComponent extends Field {
|
|
7
7
|
weight: number;
|
8
8
|
schema: any;
|
9
9
|
};
|
10
|
-
static savedValueTypes(schema: any):
|
10
|
+
static savedValueTypes(schema: any): string[];
|
11
11
|
constructor(component: any, options: any, data: any);
|
12
12
|
filesUploading: number;
|
13
13
|
get inputInfo(): any;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import _ from 'lodash';
|
2
2
|
import Field from '../_classes/field/Field';
|
3
3
|
import Input from '../_classes/input/Input';
|
4
|
-
import { componentValueTypes, eachComponent, getArrayFromComponentPath, getComponentSavedTypes } from '../../utils
|
4
|
+
import { componentValueTypes, eachComponent, getArrayFromComponentPath, getComponentSavedTypes } from '../../utils';
|
5
5
|
export default class ButtonComponent extends Field {
|
6
6
|
static schema(...extend) {
|
7
7
|
return Input.schema({
|
@@ -28,6 +28,7 @@ export default class RadioComponent extends ListComponent {
|
|
28
28
|
optionsLoaded: boolean | undefined;
|
29
29
|
loadedOptions: any[] | undefined;
|
30
30
|
beforeSubmit(): Promise<any>;
|
31
|
+
convertValues(values: any): any;
|
31
32
|
render(): string;
|
32
33
|
attach(element: any): Promise<void>;
|
33
34
|
detach(element: any): void;
|
@@ -41,5 +42,12 @@ export default class RadioComponent extends ListComponent {
|
|
41
42
|
setSelectedClasses(): void;
|
42
43
|
updateValue(value: any, flags: any): boolean;
|
43
44
|
currentValue: any;
|
45
|
+
/**
|
46
|
+
* Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
|
47
|
+
* @param {*} value - The value to normalize
|
48
|
+
* @returns {*} - Returns the normalized value
|
49
|
+
*/
|
50
|
+
convertByDataType(value: any): any;
|
51
|
+
normalizeValue(value: any): any;
|
44
52
|
}
|
45
53
|
import ListComponent from '../_classes/list/ListComponent';
|
@@ -153,6 +153,12 @@ export default class RadioComponent extends ListComponent {
|
|
153
153
|
this.dataReady.then(() => res(true));
|
154
154
|
});
|
155
155
|
}
|
156
|
+
convertValues(values) {
|
157
|
+
if (this.options.renderMode === 'html' && this.type === 'radio') {
|
158
|
+
return values.map(x => ({ ...x, value: this.convertByDataType(x.value) }));
|
159
|
+
}
|
160
|
+
return values;
|
161
|
+
}
|
156
162
|
render() {
|
157
163
|
if (!this.optionsLoaded) {
|
158
164
|
return super.render(this.renderTemplate('loader'));
|
@@ -160,7 +166,7 @@ export default class RadioComponent extends ListComponent {
|
|
160
166
|
return super.render(this.renderTemplate('radio', {
|
161
167
|
input: this.inputInfo,
|
162
168
|
inline: this.component.inline,
|
163
|
-
values: this.component.dataSrc === 'values' ? this.component.values : this.loadedOptions,
|
169
|
+
values: this.component.dataSrc === 'values' ? this.convertValues(this.component.values) : this.loadedOptions,
|
164
170
|
value: this.dataValue,
|
165
171
|
row: this.row,
|
166
172
|
}));
|
@@ -406,7 +412,7 @@ export default class RadioComponent extends ListComponent {
|
|
406
412
|
* @param {*} value - The value to normalize
|
407
413
|
* @returns {*} - Returns the normalized value
|
408
414
|
*/
|
409
|
-
|
415
|
+
convertByDataType(value) {
|
410
416
|
const dataType = this.component.dataType || 'auto';
|
411
417
|
if (value === this.emptyValue) {
|
412
418
|
return value;
|
@@ -438,13 +444,17 @@ export default class RadioComponent extends ListComponent {
|
|
438
444
|
value = !(!value || value.toString() === 'false');
|
439
445
|
break;
|
440
446
|
}
|
441
|
-
|
447
|
+
return value;
|
448
|
+
}
|
449
|
+
normalizeValue(value) {
|
450
|
+
const valueConverted = this.convertByDataType(value);
|
451
|
+
if (this.isSelectURL && this.templateData && this.templateData[valueConverted]) {
|
442
452
|
const submission = this.root.submission;
|
443
453
|
if (!submission.metadata.selectData) {
|
444
454
|
submission.metadata.selectData = {};
|
445
455
|
}
|
446
|
-
_.set(submission.metadata.selectData, this.path, this.templateData[
|
456
|
+
_.set(submission.metadata.selectData, this.path, this.templateData[valueConverted]);
|
447
457
|
}
|
448
|
-
return super.normalizeValue(
|
458
|
+
return super.normalizeValue(valueConverted);
|
449
459
|
}
|
450
460
|
}
|
@@ -8,6 +8,12 @@ export default class SelectBoxesComponent extends RadioComponent {
|
|
8
8
|
* @returns {boolean} - If the value is empty.
|
9
9
|
*/
|
10
10
|
isEmpty(value?: any): boolean;
|
11
|
+
/**
|
12
|
+
* Normalize values coming into updateValue.
|
13
|
+
* @param {any} value - The value to normalize.
|
14
|
+
* @returns {*} - The normalized value
|
15
|
+
*/
|
16
|
+
normalizeValue(value: any): any;
|
11
17
|
setInputsDisabled(value: any, onlyUnchecked: any): void;
|
12
18
|
checkComponentValidity(data: any, dirty: any, rowData: any, options: any, errors?: any[]): boolean;
|
13
19
|
}
|
@@ -1,3 +1,10 @@
|
|
1
|
+
/**
|
2
|
+
* For backwards compatibility we a standalone interpolate function. This merely calls the
|
3
|
+
* global mutable Evaluator instance's interpolate function.
|
4
|
+
* @param {...any} args - interpolate arguments, typically "rawTemplate", "data", and "options"
|
5
|
+
* @returns {any} the interpolation result.
|
6
|
+
*/
|
7
|
+
export function interpolate(...args: any[]): any;
|
1
8
|
/**
|
2
9
|
* Set the evaluator to use for evaluating expressions.
|
3
10
|
* @param {CoreEvaluator} override - The new evaluator instance to use.
|
@@ -11,5 +18,4 @@ export class DefaultEvaluator extends CoreEvaluator {
|
|
11
18
|
interpolate(rawTemplate: any, data: any, _options: any): any;
|
12
19
|
}
|
13
20
|
export let Evaluator: DefaultEvaluator;
|
14
|
-
export function interpolate(rawTemplate: any, data: any, _options: any): any;
|
15
21
|
import { DefaultEvaluator as CoreEvaluator } from '@formio/core';
|
@@ -52,7 +52,15 @@ export class DefaultEvaluator extends CoreEvaluator {
|
|
52
52
|
}
|
53
53
|
export let Evaluator = new DefaultEvaluator();
|
54
54
|
// preserve the standalone interpolate function for backwards compatibility
|
55
|
-
|
55
|
+
/**
|
56
|
+
* For backwards compatibility we a standalone interpolate function. This merely calls the
|
57
|
+
* global mutable Evaluator instance's interpolate function.
|
58
|
+
* @param {...any} args - interpolate arguments, typically "rawTemplate", "data", and "options"
|
59
|
+
* @returns {any} the interpolation result.
|
60
|
+
*/
|
61
|
+
export function interpolate(...args) {
|
62
|
+
return Evaluator.interpolate(...args);
|
63
|
+
}
|
56
64
|
/**
|
57
65
|
* Set the evaluator to use for evaluating expressions.
|
58
66
|
* @param {CoreEvaluator} override - The new evaluator instance to use.
|
package/lib/mjs/utils/index.d.ts
CHANGED
@@ -3,7 +3,12 @@ export * from "./formUtils";
|
|
3
3
|
export default FormioUtils;
|
4
4
|
declare const FormioUtils: {
|
5
5
|
Evaluator: import("./Evaluator").DefaultEvaluator;
|
6
|
-
interpolate:
|
6
|
+
interpolate: typeof interpolate;
|
7
|
+
ConditionOperators: {
|
8
|
+
[x: string]: typeof import("./conditionOperators/IsEqualTo").default | typeof import("./conditionOperators/DateGreaterThan").default;
|
9
|
+
};
|
10
|
+
_: any;
|
11
|
+
moment: typeof moment;
|
7
12
|
flattenComponents: typeof import("@formio/core/lib/utils/formUtil").flattenComponents;
|
8
13
|
guid: typeof import("@formio/core/lib/utils/formUtil").guid;
|
9
14
|
uniqueName: typeof import("@formio/core/lib/utils/formUtil").uniqueName;
|
@@ -160,4 +165,6 @@ declare const FormioUtils: {
|
|
160
165
|
};
|
161
166
|
import { Evaluator } from './Evaluator';
|
162
167
|
import { registerEvaluator } from './Evaluator';
|
168
|
+
import { interpolate } from './Evaluator';
|
169
|
+
import moment from 'moment';
|
163
170
|
export { FormioUtils as Utils, Evaluator, registerEvaluator };
|
package/lib/mjs/utils/index.js
CHANGED
@@ -1,11 +1,17 @@
|
|
1
1
|
import * as utils from './utils';
|
2
2
|
import * as formUtils from './formUtils';
|
3
3
|
import { Evaluator, registerEvaluator, interpolate } from './Evaluator';
|
4
|
+
import ConditionOperators from './conditionOperators';
|
5
|
+
import _ from 'lodash';
|
6
|
+
import moment from 'moment';
|
4
7
|
const FormioUtils = {
|
5
8
|
...utils,
|
6
9
|
...formUtils,
|
7
10
|
Evaluator,
|
8
|
-
interpolate
|
11
|
+
interpolate,
|
12
|
+
ConditionOperators,
|
13
|
+
_,
|
14
|
+
moment
|
9
15
|
};
|
10
16
|
if (typeof global === 'object') {
|
11
17
|
global.FormioUtils = FormioUtils;
|
package/lib/mjs/utils/utils.js
CHANGED
@@ -199,7 +199,15 @@ export function checkSimpleConditional(component, condition, row, data, instance
|
|
199
199
|
return true;
|
200
200
|
}
|
201
201
|
const splittedConditionPath = conditionComponentPath.split('.');
|
202
|
-
const
|
202
|
+
const checkParentTypeInTree = (instance, componentType) => {
|
203
|
+
if (!instance?.parent) {
|
204
|
+
return false;
|
205
|
+
}
|
206
|
+
return instance?.parent.type === componentType || checkParentTypeInTree(instance.parent, componentType);
|
207
|
+
};
|
208
|
+
const conditionalPaths = checkParentTypeInTree(instance, 'datagrid') || checkParentTypeInTree(instance, 'editgrid')
|
209
|
+
? []
|
210
|
+
: getConditionalPathsRecursive(splittedConditionPath, data);
|
203
211
|
if (conditionalPaths.length > 0) {
|
204
212
|
return conditionalPaths.map((path) => {
|
205
213
|
const value = getComponentActualValue(path, data, row);
|
@@ -313,7 +321,7 @@ function getRow(component, row, instance, conditional) {
|
|
313
321
|
}
|
314
322
|
const dataParent = getDataParentComponent(instance);
|
315
323
|
if (dataParent) {
|
316
|
-
const parentPath = dataParent.paths?.
|
324
|
+
const parentPath = dataParent.paths?.localPath;
|
317
325
|
const isTriggerCondtionComponentPath = condition.when || !condition.conditions
|
318
326
|
? condition.when?.startsWith(dataParent.paths?.localPath)
|
319
327
|
: _.some(condition.conditions, cond => cond.component.startsWith(dataParent.paths?.localPath));
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@formio/js",
|
3
|
-
"version": "5.1.0-dev.
|
3
|
+
"version": "5.1.0-dev.5892.54c1dc7",
|
4
4
|
"description": "JavaScript powered Forms with JSON Form Builder",
|
5
5
|
"main": "lib/cjs/index.js",
|
6
6
|
"exports": {
|
@@ -81,7 +81,7 @@
|
|
81
81
|
"homepage": "https://github.com/formio/formio.js#readme",
|
82
82
|
"dependencies": {
|
83
83
|
"@formio/bootstrap": "v3.0.0-dev.121.085d187",
|
84
|
-
"@formio/core": "
|
84
|
+
"@formio/core": "v2.4.0-dev.255.7fab6ff",
|
85
85
|
"@formio/text-mask-addons": "3.8.0-formio.4",
|
86
86
|
"@formio/vanilla-text-mask": "^5.1.1-formio.1",
|
87
87
|
"abortcontroller-polyfill": "^1.7.5",
|