@jsonforms/core 3.4.0-alpha.2 → 3.4.0-beta.0
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/jsonforms-core.cjs.js +16 -12
- package/lib/jsonforms-core.cjs.js.map +1 -1
- package/lib/jsonforms-core.esm.js +13 -12
- package/lib/jsonforms-core.esm.js.map +1 -1
- package/lib/mappers/renderer.d.ts +2 -4
- package/lib/util/schema.d.ts +1 -1
- package/package.json +1 -1
- package/src/mappers/renderer.ts +3 -31
- package/src/util/schema.ts +21 -10
|
@@ -3,7 +3,7 @@ import type { RankedTester } from '../testers';
|
|
|
3
3
|
import { CoreActions } from '../actions';
|
|
4
4
|
import type { ErrorObject } from 'ajv';
|
|
5
5
|
import type { AnyAction, Dispatch, JsonFormsCellRendererRegistryEntry, JsonFormsRendererRegistryEntry, JsonFormsState, JsonFormsUISchemaRegistryEntry } from '../store';
|
|
6
|
-
import {
|
|
6
|
+
import { ArrayTranslations } from '../i18n';
|
|
7
7
|
import { Translator } from '../store';
|
|
8
8
|
import { CombinatorKeyword } from './combinators';
|
|
9
9
|
export declare const moveUp: (array: any[], toMove: number) => void;
|
|
@@ -310,7 +310,6 @@ export interface ControlWithDetailProps extends StatePropsOfControlWithDetail, D
|
|
|
310
310
|
* State-based props of a table control.
|
|
311
311
|
*/
|
|
312
312
|
export interface StatePropsOfArrayControl extends StatePropsOfControlWithDetail {
|
|
313
|
-
translations: ArrayTranslations;
|
|
314
313
|
childErrors?: ErrorObject[];
|
|
315
314
|
}
|
|
316
315
|
/**
|
|
@@ -384,7 +383,6 @@ export interface StatePropsOfCombinator extends StatePropsOfControl {
|
|
|
384
383
|
indexOfFittingSchema: number;
|
|
385
384
|
uischemas: JsonFormsUISchemaRegistryEntry[];
|
|
386
385
|
data: any;
|
|
387
|
-
translations: CombinatorTranslations;
|
|
388
386
|
}
|
|
389
387
|
export declare const mapStateToCombinatorRendererProps: (state: JsonFormsState, ownProps: OwnPropsOfControl, keyword: CombinatorKeyword) => StatePropsOfCombinator;
|
|
390
388
|
export interface CombinatorRendererProps extends StatePropsOfCombinator, DispatchPropsOfControl {
|
|
@@ -400,7 +398,6 @@ export declare const mapStateToAnyOfProps: (state: JsonFormsState, ownProps: Own
|
|
|
400
398
|
export declare const mapStateToOneOfProps: (state: JsonFormsState, ownProps: OwnPropsOfControl) => StatePropsOfCombinator;
|
|
401
399
|
export interface StatePropsOfArrayLayout extends StatePropsOfControlWithDetail {
|
|
402
400
|
data: number;
|
|
403
|
-
translations: ArrayTranslations;
|
|
404
401
|
minItems?: number;
|
|
405
402
|
disableRemove?: boolean;
|
|
406
403
|
disableAdd?: boolean;
|
|
@@ -429,6 +426,7 @@ export declare const mapStateToLabelProps: (state: JsonFormsState, props: OwnPro
|
|
|
429
426
|
config: any;
|
|
430
427
|
renderers: JsonFormsRendererRegistryEntry[];
|
|
431
428
|
cells: JsonFormsCellRendererRegistryEntry[];
|
|
429
|
+
uischema: LabelElement;
|
|
432
430
|
};
|
|
433
431
|
/**
|
|
434
432
|
* Compute the child label title for array based controls
|
package/lib/util/schema.d.ts
CHANGED
package/package.json
CHANGED
package/src/mappers/renderer.ts
CHANGED
|
@@ -47,13 +47,8 @@ import {
|
|
|
47
47
|
getI18nKey,
|
|
48
48
|
getI18nKeyPrefix,
|
|
49
49
|
getI18nKeyPrefixBySchema,
|
|
50
|
-
getArrayTranslations,
|
|
51
|
-
CombinatorTranslations,
|
|
52
|
-
getCombinatorTranslations,
|
|
53
|
-
combinatorDefaultTranslations,
|
|
54
50
|
getTranslator,
|
|
55
51
|
getErrorTranslator,
|
|
56
|
-
arrayDefaultTranslations,
|
|
57
52
|
ArrayTranslations,
|
|
58
53
|
} from '../i18n';
|
|
59
54
|
import cloneDeep from 'lodash/cloneDeep';
|
|
@@ -790,7 +785,6 @@ export interface ControlWithDetailProps
|
|
|
790
785
|
*/
|
|
791
786
|
export interface StatePropsOfArrayControl
|
|
792
787
|
extends StatePropsOfControlWithDetail {
|
|
793
|
-
translations: ArrayTranslations;
|
|
794
788
|
childErrors?: ErrorObject[];
|
|
795
789
|
}
|
|
796
790
|
|
|
@@ -805,12 +799,11 @@ export const mapStateToArrayControlProps = (
|
|
|
805
799
|
state: JsonFormsState,
|
|
806
800
|
ownProps: OwnPropsOfControl
|
|
807
801
|
): StatePropsOfArrayControl => {
|
|
808
|
-
const { path, schema, uischema,
|
|
802
|
+
const { path, schema, uischema, label, ...props } =
|
|
809
803
|
mapStateToControlWithDetailProps(state, ownProps);
|
|
810
804
|
|
|
811
805
|
const resolvedSchema = Resolve.schema(schema, 'items', props.rootSchema);
|
|
812
806
|
const childErrors = getSubErrorsAt(path, resolvedSchema)(state);
|
|
813
|
-
const t = getTranslator()(state);
|
|
814
807
|
|
|
815
808
|
return {
|
|
816
809
|
...props,
|
|
@@ -821,12 +814,6 @@ export const mapStateToArrayControlProps = (
|
|
|
821
814
|
childErrors,
|
|
822
815
|
renderers: ownProps.renderers || getRenderers(state),
|
|
823
816
|
cells: ownProps.cells || getCells(state),
|
|
824
|
-
translations: getArrayTranslations(
|
|
825
|
-
t,
|
|
826
|
-
arrayDefaultTranslations,
|
|
827
|
-
i18nKeyPrefix,
|
|
828
|
-
label
|
|
829
|
-
),
|
|
830
817
|
};
|
|
831
818
|
};
|
|
832
819
|
|
|
@@ -1061,7 +1048,6 @@ export interface StatePropsOfCombinator extends StatePropsOfControl {
|
|
|
1061
1048
|
indexOfFittingSchema: number;
|
|
1062
1049
|
uischemas: JsonFormsUISchemaRegistryEntry[];
|
|
1063
1050
|
data: any;
|
|
1064
|
-
translations: CombinatorTranslations;
|
|
1065
1051
|
}
|
|
1066
1052
|
|
|
1067
1053
|
export const mapStateToCombinatorRendererProps = (
|
|
@@ -1073,13 +1059,6 @@ export const mapStateToCombinatorRendererProps = (
|
|
|
1073
1059
|
mapStateToControlProps(state, ownProps);
|
|
1074
1060
|
|
|
1075
1061
|
const ajv = state.jsonforms.core.ajv;
|
|
1076
|
-
const t = getTranslator()(state);
|
|
1077
|
-
const translations = getCombinatorTranslations(
|
|
1078
|
-
t,
|
|
1079
|
-
combinatorDefaultTranslations,
|
|
1080
|
-
i18nKeyPrefix,
|
|
1081
|
-
label
|
|
1082
|
-
);
|
|
1083
1062
|
const structuralKeywords = [
|
|
1084
1063
|
'required',
|
|
1085
1064
|
'additionalProperties',
|
|
@@ -1126,7 +1105,6 @@ export const mapStateToCombinatorRendererProps = (
|
|
|
1126
1105
|
label,
|
|
1127
1106
|
indexOfFittingSchema,
|
|
1128
1107
|
uischemas: getUISchemas(state),
|
|
1129
|
-
translations,
|
|
1130
1108
|
};
|
|
1131
1109
|
};
|
|
1132
1110
|
|
|
@@ -1161,7 +1139,6 @@ export const mapStateToOneOfProps = (
|
|
|
1161
1139
|
|
|
1162
1140
|
export interface StatePropsOfArrayLayout extends StatePropsOfControlWithDetail {
|
|
1163
1141
|
data: number;
|
|
1164
|
-
translations: ArrayTranslations;
|
|
1165
1142
|
minItems?: number;
|
|
1166
1143
|
disableRemove?: boolean;
|
|
1167
1144
|
disableAdd?: boolean;
|
|
@@ -1177,7 +1154,7 @@ export const mapStateToArrayLayoutProps = (
|
|
|
1177
1154
|
state: JsonFormsState,
|
|
1178
1155
|
ownProps: OwnPropsOfControl
|
|
1179
1156
|
): StatePropsOfArrayLayout => {
|
|
1180
|
-
const { path, schema, uischema, errors,
|
|
1157
|
+
const { path, schema, uischema, errors, label, ...props } =
|
|
1181
1158
|
mapStateToControlWithDetailProps(state, ownProps);
|
|
1182
1159
|
|
|
1183
1160
|
const resolvedSchema = Resolve.schema(schema, 'items', props.rootSchema);
|
|
@@ -1205,12 +1182,6 @@ export const mapStateToArrayLayoutProps = (
|
|
|
1205
1182
|
data: props.data ? props.data.length : 0,
|
|
1206
1183
|
errors: allErrors,
|
|
1207
1184
|
minItems: schema.minItems,
|
|
1208
|
-
translations: getArrayTranslations(
|
|
1209
|
-
t,
|
|
1210
|
-
arrayDefaultTranslations,
|
|
1211
|
-
i18nKeyPrefix,
|
|
1212
|
-
label
|
|
1213
|
-
),
|
|
1214
1185
|
};
|
|
1215
1186
|
};
|
|
1216
1187
|
|
|
@@ -1249,6 +1220,7 @@ export const mapStateToLabelProps = (
|
|
|
1249
1220
|
config: getConfig(state),
|
|
1250
1221
|
renderers: props.renderers || getRenderers(state),
|
|
1251
1222
|
cells: props.cells || getCells(state),
|
|
1223
|
+
uischema,
|
|
1252
1224
|
};
|
|
1253
1225
|
};
|
|
1254
1226
|
|
package/src/util/schema.ts
CHANGED
|
@@ -26,16 +26,27 @@
|
|
|
26
26
|
import find from 'lodash/find';
|
|
27
27
|
import type { JsonSchema } from '../models';
|
|
28
28
|
|
|
29
|
-
export const getFirstPrimitiveProp = (schema:
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
)
|
|
38
|
-
|
|
29
|
+
export const getFirstPrimitiveProp = (schema: unknown) => {
|
|
30
|
+
if (
|
|
31
|
+
schema &&
|
|
32
|
+
typeof schema === 'object' &&
|
|
33
|
+
'properties' in schema &&
|
|
34
|
+
schema.properties
|
|
35
|
+
) {
|
|
36
|
+
return find(
|
|
37
|
+
Object.keys(schema.properties),
|
|
38
|
+
(propName: keyof typeof schema.properties) => {
|
|
39
|
+
const prop: unknown = schema.properties[propName];
|
|
40
|
+
return (
|
|
41
|
+
prop &&
|
|
42
|
+
typeof prop === 'object' &&
|
|
43
|
+
'type' in prop &&
|
|
44
|
+
(prop.type === 'string' ||
|
|
45
|
+
prop.type === 'number' ||
|
|
46
|
+
prop.type === 'integer')
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
);
|
|
39
50
|
}
|
|
40
51
|
return undefined;
|
|
41
52
|
};
|