@jsonforms/core 3.3.0 → 3.4.0-alpha.1
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/lib/actions/actions.d.ts +3 -4
- package/lib/generators/Generate.d.ts +1 -1
- package/lib/i18n/i18nUtil.d.ts +1 -1
- package/lib/i18n/index.d.ts +2 -2
- package/lib/i18n/selectors.d.ts +7 -0
- package/lib/index.d.ts +1 -1
- package/lib/jsonforms-core.cjs.js +1921 -1916
- package/lib/jsonforms-core.cjs.js.map +1 -1
- package/lib/jsonforms-core.esm.js +1606 -1604
- package/lib/jsonforms-core.esm.js.map +1 -1
- package/lib/{util → mappers}/cell.d.ts +1 -3
- package/lib/{util → mappers}/combinators.d.ts +1 -1
- package/lib/mappers/index.d.ts +4 -0
- package/lib/{util → mappers}/renderer.d.ts +20 -6
- package/lib/mappers/util.d.ts +10 -0
- package/lib/models/uischema.d.ts +0 -8
- package/lib/reducers/cells.d.ts +1 -6
- package/lib/reducers/config.d.ts +1 -1
- package/lib/reducers/core.d.ts +7 -25
- package/lib/reducers/default-data.d.ts +3 -1
- package/lib/reducers/i18n.d.ts +2 -5
- package/lib/reducers/index.d.ts +0 -1
- package/lib/reducers/middleware.d.ts +1 -1
- package/lib/reducers/reducers.d.ts +8 -16
- package/lib/reducers/renderers.d.ts +2 -6
- package/lib/reducers/uischemas.d.ts +2 -6
- package/lib/store/index.d.ts +4 -0
- package/lib/store/jsonFormsCore.d.ts +19 -0
- package/lib/{store.d.ts → store/store.d.ts} +28 -3
- package/lib/testers/testers.d.ts +1 -0
- package/lib/util/errors.d.ts +5 -0
- package/lib/{Helpers.d.ts → util/helpers.d.ts} +1 -1
- package/lib/util/index.d.ts +2 -5
- package/lib/util/label.d.ts +1 -13
- package/lib/util/path.d.ts +6 -2
- package/lib/util/runtime.d.ts +1 -10
- package/lib/util/schema.d.ts +1 -1
- package/lib/util/uischema.d.ts +10 -7
- package/lib/util/util.d.ts +1 -2
- package/lib/util/validator.d.ts +2 -1
- package/package.json +1 -1
- package/src/actions/actions.ts +3 -4
- package/src/generators/Generate.ts +1 -1
- package/src/generators/uischema.ts +1 -3
- package/src/i18n/i18nUtil.ts +7 -4
- package/src/i18n/index.ts +2 -2
- package/src/i18n/selectors.ts +67 -0
- package/src/index.ts +1 -2
- package/src/{util → mappers}/cell.ts +19 -15
- package/src/{util → mappers}/combinators.ts +3 -2
- package/src/mappers/index.ts +29 -0
- package/src/{util → mappers}/renderer.ts +140 -32
- package/src/mappers/util.ts +43 -0
- package/src/models/uischema.ts +0 -29
- package/src/reducers/cells.ts +1 -7
- package/src/reducers/config.ts +1 -1
- package/src/reducers/core.ts +33 -200
- package/src/reducers/default-data.ts +8 -2
- package/src/reducers/i18n.ts +3 -27
- package/src/reducers/index.ts +0 -1
- package/src/reducers/middleware.ts +1 -1
- package/src/reducers/reducers.ts +3 -31
- package/src/reducers/renderers.ts +2 -7
- package/src/reducers/uischemas.ts +2 -12
- package/src/{util/array.ts → store/index.ts} +5 -19
- package/src/store/jsonFormsCore.ts +72 -0
- package/src/{store.ts → store/store.ts} +36 -8
- package/src/testers/testers.ts +6 -0
- package/src/util/errors.ts +142 -0
- package/src/{Helpers.ts → util/helpers.ts} +3 -2
- package/src/util/index.ts +2 -5
- package/src/util/label.ts +1 -98
- package/src/util/path.ts +12 -15
- package/src/util/runtime.ts +1 -44
- package/src/util/schema.ts +1 -1
- package/src/util/uischema.ts +52 -16
- package/src/util/util.ts +1 -9
- package/src/util/validator.ts +15 -1
- package/lib/reducers/selectors.d.ts +0 -15
- package/lib/util/array.d.ts +0 -3
- package/src/reducers/selectors.ts +0 -64
- /package/lib/{i18n → store}/i18nTypes.d.ts +0 -0
- /package/lib/{util → store}/type.d.ts +0 -0
- /package/src/{i18n → store}/i18nTypes.ts +0 -0
- /package/src/{util → store}/type.ts +0 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*
|
|
2
|
+
The MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2017-2019 EclipseSource Munich
|
|
5
|
+
https://github.com/eclipsesource/jsonforms
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
THE SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import get from 'lodash/get';
|
|
27
|
+
import {
|
|
28
|
+
ErrorTranslator,
|
|
29
|
+
JsonFormsI18nState,
|
|
30
|
+
Translator,
|
|
31
|
+
JsonFormsState,
|
|
32
|
+
} from '../store';
|
|
33
|
+
import { defaultErrorTranslator, defaultTranslator } from './i18nUtil';
|
|
34
|
+
|
|
35
|
+
export const fetchLocale = (state?: JsonFormsI18nState) => {
|
|
36
|
+
if (state === undefined) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
return state.locale;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const fetchTranslator = (state?: JsonFormsI18nState) => {
|
|
43
|
+
if (state === undefined) {
|
|
44
|
+
return defaultTranslator;
|
|
45
|
+
}
|
|
46
|
+
return state.translate;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const fetchErrorTranslator = (state?: JsonFormsI18nState) => {
|
|
50
|
+
if (state === undefined) {
|
|
51
|
+
return defaultErrorTranslator;
|
|
52
|
+
}
|
|
53
|
+
return state.translateError;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const getLocale = (state: JsonFormsState) =>
|
|
57
|
+
fetchLocale(get(state, 'jsonforms.i18n'));
|
|
58
|
+
|
|
59
|
+
export const getTranslator =
|
|
60
|
+
() =>
|
|
61
|
+
(state: JsonFormsState): Translator =>
|
|
62
|
+
fetchTranslator(get(state, 'jsonforms.i18n'));
|
|
63
|
+
|
|
64
|
+
export const getErrorTranslator =
|
|
65
|
+
() =>
|
|
66
|
+
(state: JsonFormsState): ErrorTranslator =>
|
|
67
|
+
fetchErrorTranslator(get(state, 'jsonforms.i18n'));
|
package/src/index.ts
CHANGED
|
@@ -24,19 +24,7 @@
|
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
import isEmpty from 'lodash/isEmpty';
|
|
27
|
-
import {
|
|
28
|
-
getErrorTranslator,
|
|
29
|
-
getAjv,
|
|
30
|
-
getConfig,
|
|
31
|
-
getData,
|
|
32
|
-
getErrorAt,
|
|
33
|
-
getSchema,
|
|
34
|
-
getTranslator,
|
|
35
|
-
} from '../reducers';
|
|
36
|
-
import type { JsonFormsCellRendererRegistryEntry } from '../reducers';
|
|
37
|
-
import type { AnyAction, Dispatch } from './type';
|
|
38
|
-
import { Resolve } from './util';
|
|
39
|
-
import { isInherentlyEnabled, isVisible } from './runtime';
|
|
27
|
+
import { isVisible, Resolve } from '../util';
|
|
40
28
|
import {
|
|
41
29
|
DispatchPropsOfControl,
|
|
42
30
|
EnumOption,
|
|
@@ -47,9 +35,25 @@ import {
|
|
|
47
35
|
OwnPropsOfEnum,
|
|
48
36
|
StatePropsOfScopedRenderer,
|
|
49
37
|
} from './renderer';
|
|
50
|
-
import {
|
|
51
|
-
|
|
38
|
+
import {
|
|
39
|
+
getCombinedErrorMessage,
|
|
40
|
+
getErrorTranslator,
|
|
41
|
+
getI18nKeyPrefix,
|
|
42
|
+
getTranslator,
|
|
43
|
+
} from '../i18n';
|
|
52
44
|
import type { JsonSchema } from '../models';
|
|
45
|
+
import {
|
|
46
|
+
AnyAction,
|
|
47
|
+
Dispatch,
|
|
48
|
+
getAjv,
|
|
49
|
+
getConfig,
|
|
50
|
+
getData,
|
|
51
|
+
getErrorAt,
|
|
52
|
+
getSchema,
|
|
53
|
+
JsonFormsCellRendererRegistryEntry,
|
|
54
|
+
JsonFormsState,
|
|
55
|
+
} from '../store';
|
|
56
|
+
import { isInherentlyEnabled } from './util';
|
|
53
57
|
|
|
54
58
|
export interface OwnPropsOfCell extends OwnPropsOfControl {
|
|
55
59
|
data?: any;
|
|
@@ -24,8 +24,9 @@
|
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
import type { ControlElement, JsonSchema, UISchemaElement } from '../models';
|
|
27
|
-
import { findUISchema
|
|
28
|
-
import {
|
|
27
|
+
import { findUISchema } from '../reducers';
|
|
28
|
+
import { JsonFormsUISchemaRegistryEntry } from '../store';
|
|
29
|
+
import { Resolve } from '../util/util';
|
|
29
30
|
|
|
30
31
|
export interface CombinatorSubSchemaRenderInfo {
|
|
31
32
|
schema: JsonSchema;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
The MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2024 EclipseSource Munich
|
|
5
|
+
https://github.com/eclipsesource/jsonforms
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
THE SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
export * from './renderer';
|
|
27
|
+
export * from './cell';
|
|
28
|
+
export * from './combinators';
|
|
29
|
+
export * from './util';
|
|
@@ -26,41 +26,21 @@
|
|
|
26
26
|
import get from 'lodash/get';
|
|
27
27
|
import {
|
|
28
28
|
ControlElement,
|
|
29
|
-
isLabelable,
|
|
30
29
|
JsonSchema,
|
|
31
30
|
LabelElement,
|
|
32
31
|
UISchemaElement,
|
|
33
32
|
} from '../models';
|
|
34
|
-
import {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
getCells,
|
|
38
|
-
getConfig,
|
|
39
|
-
getData,
|
|
40
|
-
getErrorAt,
|
|
41
|
-
getErrorTranslator,
|
|
42
|
-
getRenderers,
|
|
43
|
-
getSchema,
|
|
44
|
-
getSubErrorsAt,
|
|
45
|
-
getTranslator,
|
|
46
|
-
getUiSchema,
|
|
47
|
-
} from '../reducers';
|
|
33
|
+
import type { RankedTester } from '../testers';
|
|
34
|
+
import { CoreActions, update, UpdateArrayContext } from '../actions';
|
|
35
|
+
import type { ErrorObject } from 'ajv';
|
|
48
36
|
import type {
|
|
37
|
+
AnyAction,
|
|
38
|
+
Dispatch,
|
|
49
39
|
JsonFormsCellRendererRegistryEntry,
|
|
50
40
|
JsonFormsRendererRegistryEntry,
|
|
41
|
+
JsonFormsState,
|
|
51
42
|
JsonFormsUISchemaRegistryEntry,
|
|
52
|
-
} from '../
|
|
53
|
-
import type { RankedTester } from '../testers';
|
|
54
|
-
import { hasShowRule, isInherentlyEnabled, isVisible } from './runtime';
|
|
55
|
-
import { computeChildLabel, createLabelDescriptionFrom } from './label';
|
|
56
|
-
import type { CombinatorKeyword } from './combinators';
|
|
57
|
-
import { moveDown, moveUp } from './array';
|
|
58
|
-
import type { AnyAction, Dispatch } from './type';
|
|
59
|
-
import { Resolve, convertDateToString, hasType } from './util';
|
|
60
|
-
import { composePaths, composeWithUi } from './path';
|
|
61
|
-
import { CoreActions, update, UpdateArrayContext } from '../actions';
|
|
62
|
-
import type { ErrorObject } from 'ajv';
|
|
63
|
-
import type { JsonFormsState } from '../store';
|
|
43
|
+
} from '../store';
|
|
64
44
|
import {
|
|
65
45
|
deriveLabelForUISchemaElement,
|
|
66
46
|
getCombinedErrorMessage,
|
|
@@ -68,17 +48,65 @@ import {
|
|
|
68
48
|
getI18nKeyPrefix,
|
|
69
49
|
getI18nKeyPrefixBySchema,
|
|
70
50
|
getArrayTranslations,
|
|
71
|
-
Translator,
|
|
72
51
|
CombinatorTranslations,
|
|
73
52
|
getCombinatorTranslations,
|
|
74
53
|
combinatorDefaultTranslations,
|
|
75
|
-
|
|
76
|
-
|
|
54
|
+
getTranslator,
|
|
55
|
+
getErrorTranslator,
|
|
77
56
|
arrayDefaultTranslations,
|
|
78
57
|
ArrayTranslations,
|
|
79
|
-
} from '../i18n
|
|
80
|
-
import { resolveSchema } from './resolvers';
|
|
58
|
+
} from '../i18n';
|
|
81
59
|
import cloneDeep from 'lodash/cloneDeep';
|
|
60
|
+
import {
|
|
61
|
+
composePaths,
|
|
62
|
+
composeWithUi,
|
|
63
|
+
convertDateToString,
|
|
64
|
+
createLabelDescriptionFrom,
|
|
65
|
+
findUiControl,
|
|
66
|
+
getFirstPrimitiveProp,
|
|
67
|
+
getPropPath,
|
|
68
|
+
hasShowRule,
|
|
69
|
+
hasType,
|
|
70
|
+
isEnumSchema,
|
|
71
|
+
isLabelable,
|
|
72
|
+
isOneOfEnumSchema,
|
|
73
|
+
isVisible,
|
|
74
|
+
Resolve,
|
|
75
|
+
resolveSchema,
|
|
76
|
+
} from '../util';
|
|
77
|
+
import {
|
|
78
|
+
Translator,
|
|
79
|
+
getAjv,
|
|
80
|
+
getCells,
|
|
81
|
+
getConfig,
|
|
82
|
+
getData,
|
|
83
|
+
getErrorAt,
|
|
84
|
+
getRenderers,
|
|
85
|
+
getSchema,
|
|
86
|
+
getSubErrorsAt,
|
|
87
|
+
getUISchemas,
|
|
88
|
+
getUiSchema,
|
|
89
|
+
} from '../store';
|
|
90
|
+
import { isInherentlyEnabled } from './util';
|
|
91
|
+
import { CombinatorKeyword } from './combinators';
|
|
92
|
+
import { isEqual } from 'lodash';
|
|
93
|
+
|
|
94
|
+
const move = (array: any[], index: number, delta: number) => {
|
|
95
|
+
const newIndex: number = index + delta;
|
|
96
|
+
if (newIndex < 0 || newIndex >= array.length) {
|
|
97
|
+
return;
|
|
98
|
+
} // Already at the top or bottom.
|
|
99
|
+
const indexes: number[] = [index, newIndex].sort((a, b) => a - b); // Sort the indixes
|
|
100
|
+
array.splice(indexes[0], 2, array[indexes[1]], array[indexes[0]]);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const moveUp = (array: any[], toMove: number) => {
|
|
104
|
+
move(array, toMove, -1);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export const moveDown = (array: any[], toMove: number) => {
|
|
108
|
+
move(array, toMove, 1);
|
|
109
|
+
};
|
|
82
110
|
|
|
83
111
|
const isRequired = (
|
|
84
112
|
schema: JsonSchema,
|
|
@@ -726,6 +754,7 @@ export interface OwnPropsOfMasterListItem {
|
|
|
726
754
|
handleSelect(index: number): () => void;
|
|
727
755
|
removeItem(path: string, value: number): () => void;
|
|
728
756
|
translations: ArrayTranslations;
|
|
757
|
+
disableRemove?: boolean;
|
|
729
758
|
}
|
|
730
759
|
|
|
731
760
|
export interface StatePropsOfMasterItem extends OwnPropsOfMasterListItem {
|
|
@@ -1133,6 +1162,8 @@ export interface StatePropsOfArrayLayout extends StatePropsOfControlWithDetail {
|
|
|
1133
1162
|
data: number;
|
|
1134
1163
|
translations: ArrayTranslations;
|
|
1135
1164
|
minItems?: number;
|
|
1165
|
+
disableRemove?: boolean;
|
|
1166
|
+
disableAdd?: boolean;
|
|
1136
1167
|
}
|
|
1137
1168
|
/**
|
|
1138
1169
|
* Map state to table props
|
|
@@ -1219,3 +1250,80 @@ export const mapStateToLabelProps = (
|
|
|
1219
1250
|
cells: props.cells || getCells(state),
|
|
1220
1251
|
};
|
|
1221
1252
|
};
|
|
1253
|
+
|
|
1254
|
+
/**
|
|
1255
|
+
* Compute the child label title for array based controls
|
|
1256
|
+
* @param data the data of the control
|
|
1257
|
+
* @param childPath the child path
|
|
1258
|
+
* @param childLabelProp the dotted path to the value used as child label
|
|
1259
|
+
* @param {JsonSchema} schema the json schema for this control
|
|
1260
|
+
* @param {JsonSchema} rootSchema the root json schema
|
|
1261
|
+
* @param {Translator} translateFct the translator fonction
|
|
1262
|
+
* @param {UISchemaElement} uiSchema the uiSchema of the control
|
|
1263
|
+
*/
|
|
1264
|
+
export const computeChildLabel = (
|
|
1265
|
+
data: any,
|
|
1266
|
+
childPath: string,
|
|
1267
|
+
childLabelProp: string,
|
|
1268
|
+
schema: JsonSchema,
|
|
1269
|
+
rootSchema: JsonSchema,
|
|
1270
|
+
translateFct: Translator,
|
|
1271
|
+
uiSchema: UISchemaElement
|
|
1272
|
+
): string => {
|
|
1273
|
+
const childData = Resolve.data(data, childPath);
|
|
1274
|
+
|
|
1275
|
+
if (!childLabelProp) {
|
|
1276
|
+
childLabelProp = getFirstPrimitiveProp(schema);
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
// return early in case there is no prop we can query
|
|
1280
|
+
if (!childLabelProp) {
|
|
1281
|
+
return '';
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
const currentValue = get(childData, childLabelProp);
|
|
1285
|
+
|
|
1286
|
+
// in case there is no value, then we can't map it to an enum or oneOf
|
|
1287
|
+
if (currentValue === undefined) {
|
|
1288
|
+
return '';
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
// check whether the value is part of a oneOf or enum and needs to be translated
|
|
1292
|
+
const childSchema = Resolve.schema(
|
|
1293
|
+
schema,
|
|
1294
|
+
'#' + getPropPath(childLabelProp),
|
|
1295
|
+
rootSchema
|
|
1296
|
+
);
|
|
1297
|
+
|
|
1298
|
+
let enumOption: EnumOption = undefined;
|
|
1299
|
+
if (isEnumSchema(childSchema)) {
|
|
1300
|
+
enumOption = enumToEnumOptionMapper(
|
|
1301
|
+
currentValue,
|
|
1302
|
+
translateFct,
|
|
1303
|
+
getI18nKeyPrefix(
|
|
1304
|
+
childSchema,
|
|
1305
|
+
findUiControl(uiSchema, childLabelProp),
|
|
1306
|
+
childPath + '.' + childLabelProp
|
|
1307
|
+
)
|
|
1308
|
+
);
|
|
1309
|
+
} else if (isOneOfEnumSchema(childSchema)) {
|
|
1310
|
+
const oneOfArray = childSchema.oneOf as JsonSchema[];
|
|
1311
|
+
const oneOfSchema = oneOfArray.find((e: JsonSchema) =>
|
|
1312
|
+
isEqual(e.const, currentValue)
|
|
1313
|
+
);
|
|
1314
|
+
|
|
1315
|
+
if (oneOfSchema) {
|
|
1316
|
+
enumOption = oneOfToEnumOptionMapper(
|
|
1317
|
+
oneOfSchema,
|
|
1318
|
+
translateFct,
|
|
1319
|
+
getI18nKeyPrefix(
|
|
1320
|
+
oneOfSchema,
|
|
1321
|
+
undefined,
|
|
1322
|
+
childPath + '.' + childLabelProp
|
|
1323
|
+
)
|
|
1324
|
+
);
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
return enumOption ? enumOption.label : currentValue;
|
|
1329
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { JsonSchema, UISchemaElement } from '../models';
|
|
2
|
+
import { JsonFormsState, getAjv } from '../store';
|
|
3
|
+
import { hasEnableRule, isEnabled } from '../util';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Indicates whether the given `uischema` element shall be enabled or disabled.
|
|
7
|
+
* Checks the global readonly flag, uischema rule, uischema options (including the config),
|
|
8
|
+
* the schema and the enablement indicator of the parent.
|
|
9
|
+
*/
|
|
10
|
+
export const isInherentlyEnabled = (
|
|
11
|
+
state: JsonFormsState,
|
|
12
|
+
ownProps: any,
|
|
13
|
+
uischema: UISchemaElement,
|
|
14
|
+
schema: (JsonSchema & { readOnly?: boolean }) | undefined,
|
|
15
|
+
rootData: any,
|
|
16
|
+
config: any
|
|
17
|
+
) => {
|
|
18
|
+
if (state?.jsonforms?.readonly) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
if (uischema && hasEnableRule(uischema)) {
|
|
22
|
+
return isEnabled(uischema, rootData, ownProps?.path, getAjv(state));
|
|
23
|
+
}
|
|
24
|
+
if (typeof uischema?.options?.readonly === 'boolean') {
|
|
25
|
+
return !uischema.options.readonly;
|
|
26
|
+
}
|
|
27
|
+
if (typeof uischema?.options?.readOnly === 'boolean') {
|
|
28
|
+
return !uischema.options.readOnly;
|
|
29
|
+
}
|
|
30
|
+
if (typeof config?.readonly === 'boolean') {
|
|
31
|
+
return !config.readonly;
|
|
32
|
+
}
|
|
33
|
+
if (typeof config?.readOnly === 'boolean') {
|
|
34
|
+
return !config.readOnly;
|
|
35
|
+
}
|
|
36
|
+
if (schema?.readOnly === true) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
if (typeof ownProps?.enabled === 'boolean') {
|
|
40
|
+
return ownProps.enabled;
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
};
|
package/src/models/uischema.ts
CHANGED
|
@@ -284,32 +284,3 @@ export interface Categorization
|
|
|
284
284
|
*/
|
|
285
285
|
elements: (Category | Categorization)[];
|
|
286
286
|
}
|
|
287
|
-
|
|
288
|
-
export const isInternationalized = (
|
|
289
|
-
element: unknown
|
|
290
|
-
): element is Required<Internationalizable> =>
|
|
291
|
-
typeof element === 'object' &&
|
|
292
|
-
element !== null &&
|
|
293
|
-
typeof (element as Internationalizable).i18n === 'string';
|
|
294
|
-
|
|
295
|
-
export const isGroup = (layout: Layout): layout is GroupLayout =>
|
|
296
|
-
layout.type === 'Group';
|
|
297
|
-
|
|
298
|
-
export const isLayout = (uischema: UISchemaElement): uischema is Layout =>
|
|
299
|
-
(uischema as Layout).elements !== undefined;
|
|
300
|
-
|
|
301
|
-
export const isScopable = (obj: unknown): obj is Scopable =>
|
|
302
|
-
!!obj && typeof obj === 'object';
|
|
303
|
-
|
|
304
|
-
export const isScoped = (obj: unknown): obj is Scoped =>
|
|
305
|
-
isScopable(obj) && typeof obj.scope === 'string';
|
|
306
|
-
|
|
307
|
-
export const isLabelable = (obj: unknown): obj is Labelable =>
|
|
308
|
-
!!obj && typeof obj === 'object';
|
|
309
|
-
|
|
310
|
-
export const isLabeled = <T = never>(obj: unknown): obj is Labeled<T> =>
|
|
311
|
-
isLabelable(obj) && ['string', 'boolean'].includes(typeof obj.label);
|
|
312
|
-
|
|
313
|
-
export const isControlElement = (
|
|
314
|
-
uiSchema: UISchemaElement
|
|
315
|
-
): uiSchema is ControlElement => uiSchema.type === 'Control';
|
package/src/reducers/cells.ts
CHANGED
|
@@ -23,25 +23,19 @@
|
|
|
23
23
|
THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import type { RankedTester } from '../testers';
|
|
27
26
|
import {
|
|
28
27
|
ADD_CELL,
|
|
29
28
|
AddCellRendererAction,
|
|
30
29
|
REMOVE_CELL,
|
|
31
30
|
RemoveCellRendererAction,
|
|
32
31
|
} from '../actions';
|
|
33
|
-
import
|
|
32
|
+
import { JsonFormsCellRendererRegistryEntry, Reducer } from '../store';
|
|
34
33
|
|
|
35
34
|
type ValidCellReducerActions = AddCellRendererAction | RemoveCellRendererAction;
|
|
36
35
|
|
|
37
36
|
export type JsonFormsCellRendererRegistryState =
|
|
38
37
|
JsonFormsCellRendererRegistryEntry[];
|
|
39
38
|
|
|
40
|
-
export interface JsonFormsCellRendererRegistryEntry {
|
|
41
|
-
tester: RankedTester;
|
|
42
|
-
cell: any;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
39
|
export const cellReducer: Reducer<
|
|
46
40
|
JsonFormsCellRendererRegistryState,
|
|
47
41
|
ValidCellReducerActions
|
package/src/reducers/config.ts
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
import merge from 'lodash/merge';
|
|
27
27
|
import { SET_CONFIG, SetConfigAction } from '../actions';
|
|
28
28
|
import { configDefault } from '../configDefault';
|
|
29
|
-
import
|
|
29
|
+
import { Reducer } from '../store';
|
|
30
30
|
|
|
31
31
|
const applyDefaultConfiguration = (config: any = {}) =>
|
|
32
32
|
merge({}, configDefault, config);
|