@formio/js 5.0.0-rc.37 → 5.0.0-rc.38
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/fonts/bootstrap-icons.woff +0 -0
- package/dist/fonts/bootstrap-icons.woff2 +0 -0
- package/dist/formio.embed.js +1 -1
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.js +853 -132
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +5 -3
- package/dist/formio.full.css +4 -4
- package/dist/formio.full.js +827 -136
- package/dist/formio.full.min.css +3 -3
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +5 -3
- package/dist/formio.js +4 -4
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.js +25 -14
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +5 -3
- package/lib/cjs/Element.js +2 -2
- package/lib/cjs/components/_classes/component/Component.js +21 -7
- package/lib/cjs/components/_classes/component/fixtures/comp5.js +2 -2
- package/lib/cjs/components/_classes/list/ListComponent.js +5 -12
- package/lib/cjs/components/_classes/nested/NestedComponent.js +17 -9
- package/lib/cjs/components/columns/editForm/Columns.edit.display.js +1 -1
- package/lib/cjs/components/editgrid/EditGrid.js +11 -4
- package/lib/cjs/components/form/Form.js +3 -1
- package/lib/cjs/components/html/HTML.js +2 -2
- package/lib/cjs/components/html/fixtures/comp3.js +31 -0
- package/lib/cjs/components/html/fixtures/index.js +3 -1
- package/lib/cjs/components/radio/Radio.js +2 -1
- package/lib/cjs/components/radio/fixtures/comp10.js +23 -0
- package/lib/cjs/components/radio/fixtures/index.js +3 -1
- package/lib/cjs/components/recaptcha/ReCaptcha.js +3 -0
- package/lib/cjs/components/select/Select.js +84 -9
- package/lib/cjs/components/survey/Survey.js +10 -0
- package/lib/cjs/utils/conditionOperators/IsEqualTo.js +19 -1
- package/lib/cjs/utils/conditionOperators/IsNotEqualTo.js +4 -5
- package/lib/cjs/utils/utils.js +40 -2
- package/lib/mjs/Element.js +2 -2
- package/lib/mjs/components/_classes/component/Component.js +24 -8
- package/lib/mjs/components/_classes/component/fixtures/comp5.js +2 -2
- package/lib/mjs/components/_classes/list/ListComponent.js +5 -12
- package/lib/mjs/components/_classes/nested/NestedComponent.js +17 -9
- package/lib/mjs/components/columns/editForm/Columns.edit.display.js +1 -1
- package/lib/mjs/components/editgrid/EditGrid.js +11 -4
- package/lib/mjs/components/form/Form.js +3 -1
- package/lib/mjs/components/html/HTML.js +2 -2
- package/lib/mjs/components/html/fixtures/comp3.js +29 -0
- package/lib/mjs/components/html/fixtures/index.js +2 -1
- package/lib/mjs/components/radio/Radio.js +2 -1
- package/lib/mjs/components/radio/fixtures/comp10.js +21 -0
- package/lib/mjs/components/radio/fixtures/index.js +2 -1
- package/lib/mjs/components/recaptcha/ReCaptcha.js +3 -0
- package/lib/mjs/components/select/Select.js +83 -10
- package/lib/mjs/components/survey/Survey.js +10 -0
- package/lib/mjs/utils/conditionOperators/IsEqualTo.js +18 -1
- package/lib/mjs/utils/conditionOperators/IsNotEqualTo.js +4 -5
- package/lib/mjs/utils/utils.js +35 -0
- package/package.json +2 -2
- package/types/formio.d.ts +4 -0
@@ -1,5 +1,6 @@
|
|
1
1
|
import ConditionOperator from './ConditionOperator';
|
2
2
|
import _ from 'lodash';
|
3
|
+
import { getItemTemplateKeys, isSelectResourceWithObjectValue } from '../utils';
|
3
4
|
export default class IsEqualTo extends ConditionOperator {
|
4
5
|
static get operatorKey() {
|
5
6
|
return 'isEqual';
|
@@ -7,7 +8,7 @@ export default class IsEqualTo extends ConditionOperator {
|
|
7
8
|
static get displayedName() {
|
8
9
|
return 'Is Equal To';
|
9
10
|
}
|
10
|
-
execute({ value, comparedValue }) {
|
11
|
+
execute({ value, comparedValue, instance, conditionComponentPath }) {
|
11
12
|
if (value && comparedValue && typeof value !== typeof comparedValue && _.isString(comparedValue)) {
|
12
13
|
try {
|
13
14
|
comparedValue = JSON.parse(comparedValue);
|
@@ -15,6 +16,22 @@ export default class IsEqualTo extends ConditionOperator {
|
|
15
16
|
// eslint-disable-next-line no-empty
|
16
17
|
catch (e) { }
|
17
18
|
}
|
19
|
+
if (instance && instance.root) {
|
20
|
+
const conditionTriggerComponent = instance.root.getComponent(conditionComponentPath);
|
21
|
+
if (conditionTriggerComponent
|
22
|
+
&& isSelectResourceWithObjectValue(conditionTriggerComponent.component)
|
23
|
+
&& conditionTriggerComponent.component?.template) {
|
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)));
|
33
|
+
}
|
34
|
+
}
|
18
35
|
//special check for select boxes
|
19
36
|
if (_.isObject(value) && comparedValue && _.isString(comparedValue)) {
|
20
37
|
return value[comparedValue];
|
@@ -1,13 +1,12 @@
|
|
1
|
-
import
|
2
|
-
|
3
|
-
export default class IsNotEqualTo extends ConditionOperator {
|
1
|
+
import IsEqualTo from './IsEqualTo';
|
2
|
+
export default class IsNotEqualTo extends IsEqualTo {
|
4
3
|
static get operatorKey() {
|
5
4
|
return 'isNotEqual';
|
6
5
|
}
|
7
6
|
static get displayedName() {
|
8
7
|
return 'Is Not Equal To';
|
9
8
|
}
|
10
|
-
execute(
|
11
|
-
return !
|
9
|
+
execute(options) {
|
10
|
+
return !super.execute(options);
|
12
11
|
}
|
13
12
|
}
|
package/lib/mjs/utils/utils.js
CHANGED
@@ -394,6 +394,21 @@ export function unescapeHTML(str) {
|
|
394
394
|
const doc = new window.DOMParser().parseFromString(str, 'text/html');
|
395
395
|
return doc.documentElement.textContent;
|
396
396
|
}
|
397
|
+
/**
|
398
|
+
* Escape HTML characters like <, >, & and etc.
|
399
|
+
* @param str
|
400
|
+
* @returns {string}
|
401
|
+
*/
|
402
|
+
export function escapeHTML(html) {
|
403
|
+
if (html) {
|
404
|
+
return html.replace(/&/g, '&')
|
405
|
+
.replace(/</g, '<')
|
406
|
+
.replace(/>/g, '>')
|
407
|
+
.replace(/"/g, '"')
|
408
|
+
.replace(/'/g, ''');
|
409
|
+
}
|
410
|
+
return '';
|
411
|
+
}
|
397
412
|
/**
|
398
413
|
* Make HTML element from string
|
399
414
|
* @param str
|
@@ -1407,3 +1422,23 @@ export const interpolateErrors = (component, errors, interpolateFn) => {
|
|
1407
1422
|
return { ...error, message: unescapeHTML(interpolateFn(toInterpolate, context)), context: { ...context } };
|
1408
1423
|
});
|
1409
1424
|
};
|
1425
|
+
export function getItemTemplateKeys(template) {
|
1426
|
+
const templateKeys = [];
|
1427
|
+
if (!template) {
|
1428
|
+
return templateKeys;
|
1429
|
+
}
|
1430
|
+
const keys = template.match(/({{\s*(.*?)\s*}})/g);
|
1431
|
+
if (keys) {
|
1432
|
+
keys.forEach((key) => {
|
1433
|
+
const propKey = key.match(/{{\s*item\.(.*?)\s*}}/);
|
1434
|
+
if (propKey && propKey.length > 1) {
|
1435
|
+
templateKeys.push(propKey[1]);
|
1436
|
+
}
|
1437
|
+
});
|
1438
|
+
}
|
1439
|
+
return templateKeys;
|
1440
|
+
}
|
1441
|
+
export function isSelectResourceWithObjectValue(comp = {}) {
|
1442
|
+
const { reference, dataSrc, valueProperty } = comp;
|
1443
|
+
return reference || (dataSrc === 'resource' && (!valueProperty || valueProperty === 'data'));
|
1444
|
+
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@formio/js",
|
3
|
-
"version": "5.0.0-rc.
|
3
|
+
"version": "5.0.0-rc.38",
|
4
4
|
"description": "JavaScript powered Forms with JSON Form Builder",
|
5
5
|
"main": "lib/cjs/index.js",
|
6
6
|
"exports": {
|
@@ -86,7 +86,7 @@
|
|
86
86
|
"dependencies": {
|
87
87
|
"@formio/bootstrap": "^3.0.0-rc.20",
|
88
88
|
"@formio/choices.js": "^10.2.0",
|
89
|
-
"@formio/core": "^2.0.0-rc.
|
89
|
+
"@formio/core": "^2.0.0-rc.6",
|
90
90
|
"@formio/text-mask-addons": "^3.8.0-formio.2",
|
91
91
|
"@formio/vanilla-text-mask": "^5.1.1-formio.1",
|
92
92
|
"abortcontroller-polyfill": "^1.7.5",
|
package/types/formio.d.ts
CHANGED
@@ -159,6 +159,10 @@ export declare class Formio {
|
|
159
159
|
* Stores all of the libraries lazy loaded with ```Formio.requireLibrary``` method.
|
160
160
|
*/
|
161
161
|
static libraries: any;
|
162
|
+
/**
|
163
|
+
* The Library license for this application.
|
164
|
+
*/
|
165
|
+
static license: string;
|
162
166
|
/**
|
163
167
|
* A direct interface to the Form.io fetch polyfill.
|
164
168
|
*/
|