@formio/js 5.0.0-dev.5870.aa1e3d9 → 5.0.0-dev.5871.544083b
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 +86 -86
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +86 -86
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.js +9 -9
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +69 -69
- package/dist/formio.utils.min.js +1 -1
- package/lib/cjs/components/radio/Radio.d.ts +1 -0
- package/lib/cjs/components/radio/Radio.js +13 -4
- package/lib/cjs/components/selectboxes/SelectBoxes.js +9 -2
- package/lib/cjs/components/textarea/TextArea.d.ts +4 -4
- package/lib/cjs/components/textarea/TextArea.js +4 -4
- package/lib/cjs/utils/conditionOperators/IsEqualTo.js +9 -1
- package/lib/cjs/utils/formUtils.d.ts +0 -3
- package/lib/cjs/utils/formUtils.js +2 -5
- package/lib/cjs/utils/utils.d.ts +13 -0
- package/lib/cjs/utils/utils.js +33 -1
- package/lib/mjs/components/radio/Radio.d.ts +1 -0
- package/lib/mjs/components/radio/Radio.js +13 -4
- package/lib/mjs/components/selectboxes/SelectBoxes.js +8 -2
- package/lib/mjs/components/textarea/TextArea.d.ts +4 -4
- package/lib/mjs/components/textarea/TextArea.js +4 -4
- package/lib/mjs/utils/conditionOperators/IsEqualTo.js +10 -2
- package/lib/mjs/utils/formUtils.d.ts +0 -3
- package/lib/mjs/utils/formUtils.js +2 -2
- package/lib/mjs/utils/utils.d.ts +13 -0
- package/lib/mjs/utils/utils.js +30 -0
- package/package.json +2 -2
|
@@ -21,6 +21,7 @@ export default class RadioComponent extends ListComponent {
|
|
|
21
21
|
get isRadio(): boolean;
|
|
22
22
|
get optionSelectedClass(): string;
|
|
23
23
|
get listData(): any;
|
|
24
|
+
get selectMetadata(): any;
|
|
24
25
|
templateData: {} | undefined;
|
|
25
26
|
triggerUpdate: ((...args: any[]) => any) | undefined;
|
|
26
27
|
itemsLoadedResolve: ((value: any) => void) | undefined;
|
|
@@ -109,6 +109,12 @@ class RadioComponent extends ListComponent_1.default {
|
|
|
109
109
|
const listData = lodash_1.default.get(this.root, 'submission.metadata.listData', {});
|
|
110
110
|
return lodash_1.default.get(listData, this.path);
|
|
111
111
|
}
|
|
112
|
+
get selectMetadata() {
|
|
113
|
+
return super.selectData;
|
|
114
|
+
}
|
|
115
|
+
get selectData() {
|
|
116
|
+
return this.selectMetadata || this.component.selectData;
|
|
117
|
+
}
|
|
112
118
|
init() {
|
|
113
119
|
super.init();
|
|
114
120
|
this.templateData = {};
|
|
@@ -244,12 +250,15 @@ class RadioComponent extends ListComponent_1.default {
|
|
|
244
250
|
else if (!lodash_1.default.isString(value)) {
|
|
245
251
|
value = lodash_1.default.toString(value);
|
|
246
252
|
}
|
|
247
|
-
const
|
|
248
|
-
|
|
253
|
+
const shouldUseSelectData = (options.modalPreview || this.inDataTable)
|
|
254
|
+
&& this.component.dataSrc === 'url' && (this.loadedOptions.length || this.selectData);
|
|
255
|
+
if (this.component.dataSrc !== 'values' && !shouldUseSelectData) {
|
|
249
256
|
return value;
|
|
250
257
|
}
|
|
251
|
-
const values =
|
|
252
|
-
const option =
|
|
258
|
+
const values = shouldUseSelectData ? this.loadedOptions : this.component.values;
|
|
259
|
+
const option = !(values === null || values === void 0 ? void 0 : values.length) && shouldUseSelectData ? {
|
|
260
|
+
label: this.itemTemplate(this.selectData),
|
|
261
|
+
} : lodash_1.default.find(values, (v) => v.value === value);
|
|
253
262
|
if (!value) {
|
|
254
263
|
return lodash_1.default.get(option, 'label', '');
|
|
255
264
|
}
|
|
@@ -166,12 +166,19 @@ class SelectBoxesComponent extends Radio_1.default {
|
|
|
166
166
|
return changed;
|
|
167
167
|
}
|
|
168
168
|
getValueAsString(value, options = {}) {
|
|
169
|
+
var _a, _b;
|
|
169
170
|
if (!value) {
|
|
170
171
|
return '';
|
|
171
172
|
}
|
|
172
173
|
if (this.isSelectURL) {
|
|
173
|
-
if (options.modalPreview
|
|
174
|
-
|
|
174
|
+
if (options.modalPreview || this.options.readOnly || this.inDataTable) {
|
|
175
|
+
const checkedItems = lodash_1.default.keys(lodash_1.default.pickBy(value, (val) => val));
|
|
176
|
+
if (((_a = this.selectData) === null || _a === void 0 ? void 0 : _a.length) === checkedItems.length) {
|
|
177
|
+
return this.selectData.map(item => this.itemTemplate(item)).join(', ');
|
|
178
|
+
}
|
|
179
|
+
else if ((_b = this.loadedOptions) === null || _b === void 0 ? void 0 : _b.length) {
|
|
180
|
+
return this.loadedOptions.filter((option) => value[option.value]).map((option) => option.label).join(', ');
|
|
181
|
+
}
|
|
175
182
|
}
|
|
176
183
|
return (0, lodash_1.default)(value).pickBy((val) => val).keys().join(', ');
|
|
177
184
|
}
|
|
@@ -20,10 +20,10 @@ export default class TextAreaComponent extends TextFieldComponent {
|
|
|
20
20
|
setReadOnlyValue(value: any, index: any): void;
|
|
21
21
|
get isJsonValue(): any;
|
|
22
22
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
* Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
|
|
24
|
+
* @param {*} value - The value to normalize
|
|
25
|
+
* @returns {*} - Returns the normalized value
|
|
26
|
+
*/
|
|
27
27
|
normalizeValue(value: any): any;
|
|
28
28
|
normalizeSingleValue(value: any): any;
|
|
29
29
|
setConvertedValue(value: any, index: any): any;
|
|
@@ -310,10 +310,10 @@ class TextAreaComponent extends TextField_1.default {
|
|
|
310
310
|
return this.component.as && this.component.as === 'json';
|
|
311
311
|
}
|
|
312
312
|
/**
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
313
|
+
* Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
|
|
314
|
+
* @param {*} value - The value to normalize
|
|
315
|
+
* @returns {*} - Returns the normalized value
|
|
316
|
+
*/
|
|
317
317
|
normalizeValue(value) {
|
|
318
318
|
if (this.component.multiple && Array.isArray(value)) {
|
|
319
319
|
return value.map((singleValue) => this.normalizeSingleValue(singleValue));
|
|
@@ -27,7 +27,15 @@ class IsEqualTo extends ConditionOperator_1.default {
|
|
|
27
27
|
if (conditionTriggerComponent
|
|
28
28
|
&& (0, utils_1.isSelectResourceWithObjectValue)(conditionTriggerComponent.component)
|
|
29
29
|
&& ((_b = conditionTriggerComponent.component) === null || _b === void 0 ? void 0 : _b.template)) {
|
|
30
|
-
|
|
30
|
+
if (!value || !lodash_1.default.isPlainObject(value)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
const { template, valueProperty } = conditionTriggerComponent.component;
|
|
34
|
+
if (valueProperty === 'data') {
|
|
35
|
+
value = { data: value };
|
|
36
|
+
comparedValue = { data: comparedValue };
|
|
37
|
+
}
|
|
38
|
+
return lodash_1.default.every((0, utils_1.getItemTemplateKeys)(template) || [], k => lodash_1.default.isEqual(lodash_1.default.get(value, k), lodash_1.default.get(comparedValue, k)));
|
|
31
39
|
}
|
|
32
40
|
}
|
|
33
41
|
//special check for select boxes
|
|
@@ -41,7 +41,4 @@ export const applyFormChanges: typeof Utils.applyFormChanges;
|
|
|
41
41
|
export const findComponent: typeof Utils.findComponent;
|
|
42
42
|
export const getEmptyValue: typeof Utils.getEmptyValue;
|
|
43
43
|
export const isComponentDataEmpty: typeof Utils.isComponentDataEmpty;
|
|
44
|
-
export const isSelectResourceWithObjectValue: typeof Utils.isSelectResourceWithObjectValue;
|
|
45
|
-
export const compareSelectResourceWithObjectTypeValues: typeof Utils.compareSelectResourceWithObjectTypeValues;
|
|
46
|
-
export const getItemTemplateKeys: typeof Utils.getItemTemplateKeys;
|
|
47
44
|
import { Utils } from '@formio/core';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isComponentDataEmpty = exports.getEmptyValue = exports.findComponent = exports.applyFormChanges = exports.generateFormChange = exports.getStrings = exports.getValue = exports.escapeRegExCharacters = exports.formatAsCurrency = exports.parseFloatExt = exports.hasCondition = exports.removeComponent = exports.searchComponents = exports.getComponent = exports.matchComponent = exports.isLayoutComponent = exports.getComponentActualValue = exports.getComponentData = exports.eachComponentAsync = exports.eachComponent = exports.componentInfo = exports.getContextualRowData = exports.getContextualRowPath = exports.getComponentKey = exports.eachComponentData = exports.eachComponentDataAsync = exports.componentChildPath = exports.componentPath = exports.isComponentNestedDataType = exports.getComponentPath = exports.getComponentAbsolutePath = exports.getModelType = exports.MODEL_TYPES = exports.uniqueName = exports.guid = exports.flattenComponents = exports.findComponents = void 0;
|
|
4
4
|
const core_1 = require("@formio/core");
|
|
5
|
-
const { flattenComponents, guid, uniqueName, MODEL_TYPES, getModelType, getComponentAbsolutePath, getComponentPath, isComponentNestedDataType, componentPath, componentChildPath, eachComponentDataAsync, eachComponentData, getComponentKey, getContextualRowPath, getContextualRowData, componentInfo, eachComponent, eachComponentAsync, getComponentData, getComponentActualValue, isLayoutComponent, matchComponent, getComponent, searchComponents, removeComponent, hasCondition, parseFloatExt, formatAsCurrency, escapeRegExCharacters, getValue, getStrings, generateFormChange, applyFormChanges, findComponent, getEmptyValue, isComponentDataEmpty
|
|
5
|
+
const { flattenComponents, guid, uniqueName, MODEL_TYPES, getModelType, getComponentAbsolutePath, getComponentPath, isComponentNestedDataType, componentPath, componentChildPath, eachComponentDataAsync, eachComponentData, getComponentKey, getContextualRowPath, getContextualRowData, componentInfo, eachComponent, eachComponentAsync, getComponentData, getComponentActualValue, isLayoutComponent, matchComponent, getComponent, searchComponents, removeComponent, hasCondition, parseFloatExt, formatAsCurrency, escapeRegExCharacters, getValue, getStrings, generateFormChange, applyFormChanges, findComponent, getEmptyValue, isComponentDataEmpty } = core_1.Utils;
|
|
6
6
|
exports.flattenComponents = flattenComponents;
|
|
7
7
|
exports.guid = guid;
|
|
8
8
|
exports.uniqueName = uniqueName;
|
|
@@ -39,9 +39,6 @@ exports.applyFormChanges = applyFormChanges;
|
|
|
39
39
|
exports.findComponent = findComponent;
|
|
40
40
|
exports.getEmptyValue = getEmptyValue;
|
|
41
41
|
exports.isComponentDataEmpty = isComponentDataEmpty;
|
|
42
|
-
exports.isSelectResourceWithObjectValue = isSelectResourceWithObjectValue;
|
|
43
|
-
exports.compareSelectResourceWithObjectTypeValues = compareSelectResourceWithObjectTypeValues;
|
|
44
|
-
exports.getItemTemplateKeys = getItemTemplateKeys;
|
|
45
42
|
/**
|
|
46
43
|
* Deprecated version of findComponents. Renamed to searchComponents.
|
|
47
44
|
* @param {import('@formio/core').Component[]} components - The components to find components within.
|
package/lib/cjs/utils/utils.d.ts
CHANGED
|
@@ -498,6 +498,18 @@ export function getFocusableElements(element: HTMLElement): NodeList<HTMLElement
|
|
|
498
498
|
* @returns {Array<string>|null} - The saved types for the component
|
|
499
499
|
*/
|
|
500
500
|
export function getComponentSavedTypes(fullSchema: import('@formio/core').Component): Array<string> | null;
|
|
501
|
+
/**
|
|
502
|
+
* Returns the template keys inside the template code.
|
|
503
|
+
* @param {string} template - The template to get the keys from.
|
|
504
|
+
* @returns {Array<string>} - The keys inside the template.
|
|
505
|
+
*/
|
|
506
|
+
export function getItemTemplateKeys(template: string): Array<string>;
|
|
507
|
+
/**
|
|
508
|
+
* Returns if the component is a select resource with an object for its value.
|
|
509
|
+
* @param {import('@formio/core').Component} comp - The component to check.
|
|
510
|
+
* @returns {boolean} - TRUE if the component is a select resource with an object for its value; FALSE otherwise.
|
|
511
|
+
*/
|
|
512
|
+
export function isSelectResourceWithObjectValue(comp?: import('@formio/core').Component): boolean;
|
|
501
513
|
export * from "./formUtils";
|
|
502
514
|
/**
|
|
503
515
|
* Map values through unfold and return first non-nil value.
|
|
@@ -515,6 +527,7 @@ export namespace componentValueTypes {
|
|
|
515
527
|
let any: string;
|
|
516
528
|
}
|
|
517
529
|
export function interpolateErrors(component: Component, errors: FieldError[], interpolateFn: Function): [];
|
|
530
|
+
import jsonLogic from 'json-logic-js';
|
|
518
531
|
import ConditionOperators from './conditionOperators';
|
|
519
532
|
import { Evaluator } from './Evaluator';
|
|
520
533
|
export const interpolate: typeof Evaluator.interpolate;
|
package/lib/cjs/utils/utils.js
CHANGED
|
@@ -19,7 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
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.convertFormatToMoment = exports.convertFormatToFlatpickr = exports.getLocaleDateFormatInfo = exports.formatOffset = exports.formatDate = exports.momentDate = exports.loadZones = exports.shouldLoadZones = exports.zonesLoaded = 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 = exports.moment = exports.ConditionOperators = exports.jsonLogic = void 0;
|
|
22
|
-
exports.interpolateErrors = exports.getComponentSavedTypes = exports.componentValueTypes = exports._ = exports.getFocusableElements = exports.isInsideScopingComponent = exports.isPromise = exports.getDataParentComponent = exports.getComponentPath = exports.getComponentPathWithoutIndicies = exports.getBrowserInfo = exports.getIEBrowserVersion = exports.round = exports.getStringFromComponentPath = exports.isChildOf = exports.getArrayFromComponentPath = exports.isInputComponent = exports.interpolate = exports.Evaluator = exports.fastCloneDeep = exports.sanitize = exports.translateHTMLTemplate = exports.getContextButtons = exports.getContextComponents = exports.observeOverload = exports.withSwitch = void 0;
|
|
22
|
+
exports.isSelectResourceWithObjectValue = exports.getItemTemplateKeys = exports.interpolateErrors = exports.getComponentSavedTypes = exports.componentValueTypes = exports._ = exports.getFocusableElements = exports.isInsideScopingComponent = exports.isPromise = exports.getDataParentComponent = exports.getComponentPath = exports.getComponentPathWithoutIndicies = exports.getBrowserInfo = exports.getIEBrowserVersion = exports.round = exports.getStringFromComponentPath = exports.isChildOf = exports.getArrayFromComponentPath = exports.isInputComponent = exports.interpolate = exports.Evaluator = exports.fastCloneDeep = exports.sanitize = exports.translateHTMLTemplate = exports.getContextButtons = exports.getContextComponents = exports.observeOverload = exports.withSwitch = void 0;
|
|
23
23
|
const lodash_1 = __importDefault(require("lodash"));
|
|
24
24
|
exports._ = lodash_1.default;
|
|
25
25
|
const json_logic_js_1 = __importDefault(require("json-logic-js"));
|
|
@@ -1681,3 +1681,35 @@ const interpolateErrors = (component, errors, interpolateFn) => {
|
|
|
1681
1681
|
});
|
|
1682
1682
|
};
|
|
1683
1683
|
exports.interpolateErrors = interpolateErrors;
|
|
1684
|
+
/**
|
|
1685
|
+
* Returns the template keys inside the template code.
|
|
1686
|
+
* @param {string} template - The template to get the keys from.
|
|
1687
|
+
* @returns {Array<string>} - The keys inside the template.
|
|
1688
|
+
*/
|
|
1689
|
+
function getItemTemplateKeys(template) {
|
|
1690
|
+
const templateKeys = [];
|
|
1691
|
+
if (!template) {
|
|
1692
|
+
return templateKeys;
|
|
1693
|
+
}
|
|
1694
|
+
const keys = template.match(/({{\s*(.*?)\s*}})/g);
|
|
1695
|
+
if (keys) {
|
|
1696
|
+
keys.forEach((key) => {
|
|
1697
|
+
const propKey = key.match(/{{\s*item\.(.*?)\s*}}/);
|
|
1698
|
+
if (propKey && propKey.length > 1) {
|
|
1699
|
+
templateKeys.push(propKey[1]);
|
|
1700
|
+
}
|
|
1701
|
+
});
|
|
1702
|
+
}
|
|
1703
|
+
return templateKeys;
|
|
1704
|
+
}
|
|
1705
|
+
exports.getItemTemplateKeys = getItemTemplateKeys;
|
|
1706
|
+
/**
|
|
1707
|
+
* Returns if the component is a select resource with an object for its value.
|
|
1708
|
+
* @param {import('@formio/core').Component} comp - The component to check.
|
|
1709
|
+
* @returns {boolean} - TRUE if the component is a select resource with an object for its value; FALSE otherwise.
|
|
1710
|
+
*/
|
|
1711
|
+
function isSelectResourceWithObjectValue(comp = {}) {
|
|
1712
|
+
const { reference, dataSrc, valueProperty } = comp;
|
|
1713
|
+
return reference || (dataSrc === 'resource' && (!valueProperty || valueProperty === 'data'));
|
|
1714
|
+
}
|
|
1715
|
+
exports.isSelectResourceWithObjectValue = isSelectResourceWithObjectValue;
|
|
@@ -21,6 +21,7 @@ export default class RadioComponent extends ListComponent {
|
|
|
21
21
|
get isRadio(): boolean;
|
|
22
22
|
get optionSelectedClass(): string;
|
|
23
23
|
get listData(): any;
|
|
24
|
+
get selectMetadata(): any;
|
|
24
25
|
templateData: {} | undefined;
|
|
25
26
|
triggerUpdate: ((...args: any[]) => any) | undefined;
|
|
26
27
|
itemsLoadedResolve: ((value: any) => void) | undefined;
|
|
@@ -109,6 +109,12 @@ export default class RadioComponent extends ListComponent {
|
|
|
109
109
|
const listData = _.get(this.root, 'submission.metadata.listData', {});
|
|
110
110
|
return _.get(listData, this.path);
|
|
111
111
|
}
|
|
112
|
+
get selectMetadata() {
|
|
113
|
+
return super.selectData;
|
|
114
|
+
}
|
|
115
|
+
get selectData() {
|
|
116
|
+
return this.selectMetadata || this.component.selectData;
|
|
117
|
+
}
|
|
112
118
|
init() {
|
|
113
119
|
super.init();
|
|
114
120
|
this.templateData = {};
|
|
@@ -244,12 +250,15 @@ export default class RadioComponent extends ListComponent {
|
|
|
244
250
|
else if (!_.isString(value)) {
|
|
245
251
|
value = _.toString(value);
|
|
246
252
|
}
|
|
247
|
-
const
|
|
248
|
-
|
|
253
|
+
const shouldUseSelectData = (options.modalPreview || this.inDataTable)
|
|
254
|
+
&& this.component.dataSrc === 'url' && (this.loadedOptions.length || this.selectData);
|
|
255
|
+
if (this.component.dataSrc !== 'values' && !shouldUseSelectData) {
|
|
249
256
|
return value;
|
|
250
257
|
}
|
|
251
|
-
const values =
|
|
252
|
-
const option =
|
|
258
|
+
const values = shouldUseSelectData ? this.loadedOptions : this.component.values;
|
|
259
|
+
const option = !values?.length && shouldUseSelectData ? {
|
|
260
|
+
label: this.itemTemplate(this.selectData),
|
|
261
|
+
} : _.find(values, (v) => v.value === value);
|
|
253
262
|
if (!value) {
|
|
254
263
|
return _.get(option, 'label', '');
|
|
255
264
|
}
|
|
@@ -172,8 +172,14 @@ export default class SelectBoxesComponent extends RadioComponent {
|
|
|
172
172
|
return '';
|
|
173
173
|
}
|
|
174
174
|
if (this.isSelectURL) {
|
|
175
|
-
if (options.modalPreview
|
|
176
|
-
|
|
175
|
+
if (options.modalPreview || this.options.readOnly || this.inDataTable) {
|
|
176
|
+
const checkedItems = _.keys(_.pickBy(value, (val) => val));
|
|
177
|
+
if (this.selectData?.length === checkedItems.length) {
|
|
178
|
+
return this.selectData.map(item => this.itemTemplate(item)).join(', ');
|
|
179
|
+
}
|
|
180
|
+
else if (this.loadedOptions?.length) {
|
|
181
|
+
return this.loadedOptions.filter((option) => value[option.value]).map((option) => option.label).join(', ');
|
|
182
|
+
}
|
|
177
183
|
}
|
|
178
184
|
return _(value).pickBy((val) => val).keys().join(', ');
|
|
179
185
|
}
|
|
@@ -20,10 +20,10 @@ export default class TextAreaComponent extends TextFieldComponent {
|
|
|
20
20
|
setReadOnlyValue(value: any, index: any): void;
|
|
21
21
|
get isJsonValue(): any;
|
|
22
22
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
* Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
|
|
24
|
+
* @param {*} value - The value to normalize
|
|
25
|
+
* @returns {*} - Returns the normalized value
|
|
26
|
+
*/
|
|
27
27
|
normalizeValue(value: any): any;
|
|
28
28
|
normalizeSingleValue(value: any): any;
|
|
29
29
|
setConvertedValue(value: any, index: any): any;
|
|
@@ -305,10 +305,10 @@ export default class TextAreaComponent extends TextFieldComponent {
|
|
|
305
305
|
return this.component.as && this.component.as === 'json';
|
|
306
306
|
}
|
|
307
307
|
/**
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
308
|
+
* Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
|
|
309
|
+
* @param {*} value - The value to normalize
|
|
310
|
+
* @returns {*} - Returns the normalized value
|
|
311
|
+
*/
|
|
312
312
|
normalizeValue(value) {
|
|
313
313
|
if (this.component.multiple && Array.isArray(value)) {
|
|
314
314
|
return value.map((singleValue) => this.normalizeSingleValue(singleValue));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ConditionOperator from './ConditionOperator';
|
|
2
2
|
import _ from 'lodash';
|
|
3
|
-
import {
|
|
3
|
+
import { getItemTemplateKeys, isSelectResourceWithObjectValue } from '../utils';
|
|
4
4
|
export default class IsEqualTo extends ConditionOperator {
|
|
5
5
|
static get operatorKey() {
|
|
6
6
|
return 'isEqual';
|
|
@@ -21,7 +21,15 @@ export default class IsEqualTo extends ConditionOperator {
|
|
|
21
21
|
if (conditionTriggerComponent
|
|
22
22
|
&& isSelectResourceWithObjectValue(conditionTriggerComponent.component)
|
|
23
23
|
&& conditionTriggerComponent.component?.template) {
|
|
24
|
-
|
|
24
|
+
if (!value || !_.isPlainObject(value)) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
const { template, valueProperty } = conditionTriggerComponent.component;
|
|
28
|
+
if (valueProperty === 'data') {
|
|
29
|
+
value = { data: value };
|
|
30
|
+
comparedValue = { data: comparedValue };
|
|
31
|
+
}
|
|
32
|
+
return _.every(getItemTemplateKeys(template) || [], k => _.isEqual(_.get(value, k), _.get(comparedValue, k)));
|
|
25
33
|
}
|
|
26
34
|
}
|
|
27
35
|
//special check for select boxes
|
|
@@ -41,7 +41,4 @@ export const applyFormChanges: typeof Utils.applyFormChanges;
|
|
|
41
41
|
export const findComponent: typeof Utils.findComponent;
|
|
42
42
|
export const getEmptyValue: typeof Utils.getEmptyValue;
|
|
43
43
|
export const isComponentDataEmpty: typeof Utils.isComponentDataEmpty;
|
|
44
|
-
export const isSelectResourceWithObjectValue: typeof Utils.isSelectResourceWithObjectValue;
|
|
45
|
-
export const compareSelectResourceWithObjectTypeValues: typeof Utils.compareSelectResourceWithObjectTypeValues;
|
|
46
|
-
export const getItemTemplateKeys: typeof Utils.getItemTemplateKeys;
|
|
47
44
|
import { Utils } from '@formio/core';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Utils } from '@formio/core';
|
|
2
|
-
const { flattenComponents, guid, uniqueName, MODEL_TYPES, getModelType, getComponentAbsolutePath, getComponentPath, isComponentNestedDataType, componentPath, componentChildPath, eachComponentDataAsync, eachComponentData, getComponentKey, getContextualRowPath, getContextualRowData, componentInfo, eachComponent, eachComponentAsync, getComponentData, getComponentActualValue, isLayoutComponent, matchComponent, getComponent, searchComponents, removeComponent, hasCondition, parseFloatExt, formatAsCurrency, escapeRegExCharacters, getValue, getStrings, generateFormChange, applyFormChanges, findComponent, getEmptyValue, isComponentDataEmpty
|
|
2
|
+
const { flattenComponents, guid, uniqueName, MODEL_TYPES, getModelType, getComponentAbsolutePath, getComponentPath, isComponentNestedDataType, componentPath, componentChildPath, eachComponentDataAsync, eachComponentData, getComponentKey, getContextualRowPath, getContextualRowData, componentInfo, eachComponent, eachComponentAsync, getComponentData, getComponentActualValue, isLayoutComponent, matchComponent, getComponent, searchComponents, removeComponent, hasCondition, parseFloatExt, formatAsCurrency, escapeRegExCharacters, getValue, getStrings, generateFormChange, applyFormChanges, findComponent, getEmptyValue, isComponentDataEmpty } = Utils;
|
|
3
3
|
/**
|
|
4
4
|
* Deprecated version of findComponents. Renamed to searchComponents.
|
|
5
5
|
* @param {import('@formio/core').Component[]} components - The components to find components within.
|
|
@@ -10,4 +10,4 @@ export function findComponents(components, query) {
|
|
|
10
10
|
console.warn('formio.js/utils findComponents is deprecated. Use searchComponents instead.');
|
|
11
11
|
return searchComponents(components, query);
|
|
12
12
|
}
|
|
13
|
-
export { flattenComponents, guid, uniqueName, MODEL_TYPES, getModelType, getComponentAbsolutePath, getComponentPath, isComponentNestedDataType, componentPath, componentChildPath, eachComponentDataAsync, eachComponentData, getComponentKey, getContextualRowPath, getContextualRowData, componentInfo, eachComponent, eachComponentAsync, getComponentData, getComponentActualValue, isLayoutComponent, matchComponent, getComponent, searchComponents, removeComponent, hasCondition, parseFloatExt, formatAsCurrency, escapeRegExCharacters, getValue, getStrings, generateFormChange, applyFormChanges, findComponent, getEmptyValue, isComponentDataEmpty
|
|
13
|
+
export { flattenComponents, guid, uniqueName, MODEL_TYPES, getModelType, getComponentAbsolutePath, getComponentPath, isComponentNestedDataType, componentPath, componentChildPath, eachComponentDataAsync, eachComponentData, getComponentKey, getContextualRowPath, getContextualRowData, componentInfo, eachComponent, eachComponentAsync, getComponentData, getComponentActualValue, isLayoutComponent, matchComponent, getComponent, searchComponents, removeComponent, hasCondition, parseFloatExt, formatAsCurrency, escapeRegExCharacters, getValue, getStrings, generateFormChange, applyFormChanges, findComponent, getEmptyValue, isComponentDataEmpty };
|
package/lib/mjs/utils/utils.d.ts
CHANGED
|
@@ -498,6 +498,18 @@ export function getFocusableElements(element: HTMLElement): NodeList<HTMLElement
|
|
|
498
498
|
* @returns {Array<string>|null} - The saved types for the component
|
|
499
499
|
*/
|
|
500
500
|
export function getComponentSavedTypes(fullSchema: import('@formio/core').Component): Array<string> | null;
|
|
501
|
+
/**
|
|
502
|
+
* Returns the template keys inside the template code.
|
|
503
|
+
* @param {string} template - The template to get the keys from.
|
|
504
|
+
* @returns {Array<string>} - The keys inside the template.
|
|
505
|
+
*/
|
|
506
|
+
export function getItemTemplateKeys(template: string): Array<string>;
|
|
507
|
+
/**
|
|
508
|
+
* Returns if the component is a select resource with an object for its value.
|
|
509
|
+
* @param {import('@formio/core').Component} comp - The component to check.
|
|
510
|
+
* @returns {boolean} - TRUE if the component is a select resource with an object for its value; FALSE otherwise.
|
|
511
|
+
*/
|
|
512
|
+
export function isSelectResourceWithObjectValue(comp?: import('@formio/core').Component): boolean;
|
|
501
513
|
export * from "./formUtils";
|
|
502
514
|
/**
|
|
503
515
|
* Map values through unfold and return first non-nil value.
|
|
@@ -515,6 +527,7 @@ export namespace componentValueTypes {
|
|
|
515
527
|
let any: string;
|
|
516
528
|
}
|
|
517
529
|
export function interpolateErrors(component: Component, errors: FieldError[], interpolateFn: Function): [];
|
|
530
|
+
import jsonLogic from 'json-logic-js';
|
|
518
531
|
import ConditionOperators from './conditionOperators';
|
|
519
532
|
import { Evaluator } from './Evaluator';
|
|
520
533
|
export const interpolate: typeof Evaluator.interpolate;
|
package/lib/mjs/utils/utils.js
CHANGED
|
@@ -1587,3 +1587,33 @@ export const interpolateErrors = (component, errors, interpolateFn) => {
|
|
|
1587
1587
|
return { ...error, message: unescapeHTML(interpolateFn(toInterpolate, context)), context: { ...context } };
|
|
1588
1588
|
});
|
|
1589
1589
|
};
|
|
1590
|
+
/**
|
|
1591
|
+
* Returns the template keys inside the template code.
|
|
1592
|
+
* @param {string} template - The template to get the keys from.
|
|
1593
|
+
* @returns {Array<string>} - The keys inside the template.
|
|
1594
|
+
*/
|
|
1595
|
+
export function getItemTemplateKeys(template) {
|
|
1596
|
+
const templateKeys = [];
|
|
1597
|
+
if (!template) {
|
|
1598
|
+
return templateKeys;
|
|
1599
|
+
}
|
|
1600
|
+
const keys = template.match(/({{\s*(.*?)\s*}})/g);
|
|
1601
|
+
if (keys) {
|
|
1602
|
+
keys.forEach((key) => {
|
|
1603
|
+
const propKey = key.match(/{{\s*item\.(.*?)\s*}}/);
|
|
1604
|
+
if (propKey && propKey.length > 1) {
|
|
1605
|
+
templateKeys.push(propKey[1]);
|
|
1606
|
+
}
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
return templateKeys;
|
|
1610
|
+
}
|
|
1611
|
+
/**
|
|
1612
|
+
* Returns if the component is a select resource with an object for its value.
|
|
1613
|
+
* @param {import('@formio/core').Component} comp - The component to check.
|
|
1614
|
+
* @returns {boolean} - TRUE if the component is a select resource with an object for its value; FALSE otherwise.
|
|
1615
|
+
*/
|
|
1616
|
+
export function isSelectResourceWithObjectValue(comp = {}) {
|
|
1617
|
+
const { reference, dataSrc, valueProperty } = comp;
|
|
1618
|
+
return reference || (dataSrc === 'resource' && (!valueProperty || valueProperty === 'data'));
|
|
1619
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formio/js",
|
|
3
|
-
"version": "5.0.0-dev.
|
|
3
|
+
"version": "5.0.0-dev.5871.544083b",
|
|
4
4
|
"description": "JavaScript powered Forms with JSON Form Builder",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"dependencies": {
|
|
83
83
|
"@formio/bootstrap": "3.0.0-dev.98.17ba6ea",
|
|
84
84
|
"@formio/choices.js": "^10.2.1",
|
|
85
|
-
"@formio/core": "
|
|
85
|
+
"@formio/core": "2.3.0-dev.160.cabaa43",
|
|
86
86
|
"@formio/text-mask-addons": "^3.8.0-formio.2",
|
|
87
87
|
"@formio/vanilla-text-mask": "^5.1.1-formio.1",
|
|
88
88
|
"abortcontroller-polyfill": "^1.7.5",
|