@jsonforms/core 3.4.0-alpha.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 +17 -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 +137 -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
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import type { JsonFormsCellRendererRegistryEntry } from '../reducers';
|
|
2
|
-
import type { AnyAction, Dispatch } from './type';
|
|
3
1
|
import { DispatchPropsOfControl, OwnPropsOfControl, OwnPropsOfEnum, StatePropsOfScopedRenderer } from './renderer';
|
|
4
|
-
import type { JsonFormsState } from '../store';
|
|
5
2
|
import type { JsonSchema } from '../models';
|
|
3
|
+
import { AnyAction, Dispatch, JsonFormsCellRendererRegistryEntry, JsonFormsState } from '../store';
|
|
6
4
|
export interface OwnPropsOfCell extends OwnPropsOfControl {
|
|
7
5
|
data?: any;
|
|
8
6
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ControlElement, JsonSchema, UISchemaElement } from '../models';
|
|
2
|
-
import { JsonFormsUISchemaRegistryEntry } from '../
|
|
2
|
+
import { JsonFormsUISchemaRegistryEntry } from '../store';
|
|
3
3
|
export interface CombinatorSubSchemaRenderInfo {
|
|
4
4
|
schema: JsonSchema;
|
|
5
5
|
uischema: UISchemaElement;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ControlElement, JsonSchema, LabelElement, UISchemaElement } from '../models';
|
|
2
|
-
import type { JsonFormsCellRendererRegistryEntry, JsonFormsRendererRegistryEntry, JsonFormsUISchemaRegistryEntry } from '../reducers';
|
|
3
2
|
import type { RankedTester } from '../testers';
|
|
4
|
-
import type { CombinatorKeyword } from './combinators';
|
|
5
|
-
import type { AnyAction, Dispatch } from './type';
|
|
6
3
|
import { CoreActions } from '../actions';
|
|
7
4
|
import type { ErrorObject } from 'ajv';
|
|
8
|
-
import type { JsonFormsState } from '../store';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
5
|
+
import type { AnyAction, Dispatch, JsonFormsCellRendererRegistryEntry, JsonFormsRendererRegistryEntry, JsonFormsState, JsonFormsUISchemaRegistryEntry } from '../store';
|
|
6
|
+
import { CombinatorTranslations, ArrayTranslations } from '../i18n';
|
|
7
|
+
import { Translator } from '../store';
|
|
8
|
+
import { CombinatorKeyword } from './combinators';
|
|
9
|
+
export declare const moveUp: (array: any[], toMove: number) => void;
|
|
10
|
+
export declare const moveDown: (array: any[], toMove: number) => void;
|
|
11
11
|
/**
|
|
12
12
|
* Adds an asterisk to the given label string based
|
|
13
13
|
* on the required parameter.
|
|
@@ -430,3 +430,14 @@ export declare const mapStateToLabelProps: (state: JsonFormsState, props: OwnPro
|
|
|
430
430
|
renderers: JsonFormsRendererRegistryEntry[];
|
|
431
431
|
cells: JsonFormsCellRendererRegistryEntry[];
|
|
432
432
|
};
|
|
433
|
+
/**
|
|
434
|
+
* Compute the child label title for array based controls
|
|
435
|
+
* @param data the data of the control
|
|
436
|
+
* @param childPath the child path
|
|
437
|
+
* @param childLabelProp the dotted path to the value used as child label
|
|
438
|
+
* @param {JsonSchema} schema the json schema for this control
|
|
439
|
+
* @param {JsonSchema} rootSchema the root json schema
|
|
440
|
+
* @param {Translator} translateFct the translator fonction
|
|
441
|
+
* @param {UISchemaElement} uiSchema the uiSchema of the control
|
|
442
|
+
*/
|
|
443
|
+
export declare const computeChildLabel: (data: any, childPath: string, childLabelProp: string, schema: JsonSchema, rootSchema: JsonSchema, translateFct: Translator, uiSchema: UISchemaElement) => string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { JsonSchema, UISchemaElement } from '../models';
|
|
2
|
+
import { JsonFormsState } from '../store';
|
|
3
|
+
/**
|
|
4
|
+
* Indicates whether the given `uischema` element shall be enabled or disabled.
|
|
5
|
+
* Checks the global readonly flag, uischema rule, uischema options (including the config),
|
|
6
|
+
* the schema and the enablement indicator of the parent.
|
|
7
|
+
*/
|
|
8
|
+
export declare const isInherentlyEnabled: (state: JsonFormsState, ownProps: any, uischema: UISchemaElement, schema: (JsonSchema & {
|
|
9
|
+
readOnly?: boolean;
|
|
10
|
+
}) | undefined, rootData: any, config: any) => any;
|
package/lib/models/uischema.d.ts
CHANGED
|
@@ -221,11 +221,3 @@ export interface Categorization extends UISchemaElement, Labeled, Internationali
|
|
|
221
221
|
*/
|
|
222
222
|
elements: (Category | Categorization)[];
|
|
223
223
|
}
|
|
224
|
-
export declare const isInternationalized: (element: unknown) => element is Required<Internationalizable>;
|
|
225
|
-
export declare const isGroup: (layout: Layout) => layout is GroupLayout;
|
|
226
|
-
export declare const isLayout: (uischema: UISchemaElement) => uischema is Layout;
|
|
227
|
-
export declare const isScopable: (obj: unknown) => obj is Scopable;
|
|
228
|
-
export declare const isScoped: (obj: unknown) => obj is Scoped;
|
|
229
|
-
export declare const isLabelable: (obj: unknown) => obj is Labelable<string>;
|
|
230
|
-
export declare const isLabeled: <T = never>(obj: unknown) => obj is Labeled<T>;
|
|
231
|
-
export declare const isControlElement: (uiSchema: UISchemaElement) => uiSchema is ControlElement;
|
package/lib/reducers/cells.d.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import type { RankedTester } from '../testers';
|
|
2
1
|
import { AddCellRendererAction, RemoveCellRendererAction } from '../actions';
|
|
3
|
-
import
|
|
2
|
+
import { JsonFormsCellRendererRegistryEntry, Reducer } from '../store';
|
|
4
3
|
type ValidCellReducerActions = AddCellRendererAction | RemoveCellRendererAction;
|
|
5
4
|
export type JsonFormsCellRendererRegistryState = JsonFormsCellRendererRegistryEntry[];
|
|
6
|
-
export interface JsonFormsCellRendererRegistryEntry {
|
|
7
|
-
tester: RankedTester;
|
|
8
|
-
cell: any;
|
|
9
|
-
}
|
|
10
5
|
export declare const cellReducer: Reducer<JsonFormsCellRendererRegistryState, ValidCellReducerActions>;
|
|
11
6
|
export {};
|
package/lib/reducers/config.d.ts
CHANGED
package/lib/reducers/core.d.ts
CHANGED
|
@@ -1,26 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export declare const
|
|
7
|
-
export
|
|
8
|
-
export interface JsonFormsCore {
|
|
9
|
-
data: any;
|
|
10
|
-
schema: JsonSchema;
|
|
11
|
-
uischema: UISchemaElement;
|
|
12
|
-
errors?: ErrorObject[];
|
|
13
|
-
additionalErrors?: ErrorObject[];
|
|
14
|
-
validator?: ValidateFunction;
|
|
15
|
-
ajv?: Ajv;
|
|
16
|
-
validationMode?: ValidationMode;
|
|
17
|
-
}
|
|
1
|
+
import { CoreActions, InitAction, UpdateCoreAction } from '../actions';
|
|
2
|
+
import { JsonFormsCore, Reducer, ValidationMode } from '../store';
|
|
3
|
+
import Ajv, { ErrorObject } from 'ajv';
|
|
4
|
+
export declare const initState: JsonFormsCore;
|
|
5
|
+
export declare const getValidationMode: (state: JsonFormsCore, action?: InitAction | UpdateCoreAction) => ValidationMode;
|
|
6
|
+
export declare const getAdditionalErrors: (state: JsonFormsCore, action?: InitAction | UpdateCoreAction) => ErrorObject[];
|
|
7
|
+
export declare const getOrCreateAjv: (state: JsonFormsCore, action?: InitAction | UpdateCoreAction) => Ajv;
|
|
18
8
|
export declare const coreReducer: Reducer<JsonFormsCore, CoreActions>;
|
|
19
|
-
export declare const extractData: (state: JsonFormsCore) => any;
|
|
20
|
-
export declare const extractSchema: (state: JsonFormsCore) => JsonSchema;
|
|
21
|
-
export declare const extractUiSchema: (state: JsonFormsCore) => UISchemaElement;
|
|
22
|
-
export declare const extractAjv: (state: JsonFormsCore) => Ajv;
|
|
23
|
-
export declare const getControlPath: (error: ErrorObject) => any;
|
|
24
|
-
export declare const errorsAt: (instancePath: string, schema: JsonSchema, matchPath: (path: string) => boolean) => (errors: ErrorObject[]) => ErrorObject[];
|
|
25
|
-
export declare const errorAt: (instancePath: string, schema: JsonSchema) => (state: JsonFormsCore) => ErrorObject[];
|
|
26
|
-
export declare const subErrorsAt: (instancePath: string, schema: JsonSchema) => (state: JsonFormsCore) => ErrorObject[];
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { RegisterDefaultDataAction, UnregisterDefaultDataAction } from '../actions';
|
|
2
|
-
import type { Reducer } from '../
|
|
2
|
+
import type { Reducer } from '../store/type';
|
|
3
|
+
import { JsonFormsState } from '../store';
|
|
3
4
|
export interface JsonFormsDefaultDataRegistryEntry {
|
|
4
5
|
schemaPath: string;
|
|
5
6
|
data: any;
|
|
6
7
|
}
|
|
7
8
|
type ValidDefaultDataActions = RegisterDefaultDataAction | UnregisterDefaultDataAction;
|
|
8
9
|
export declare const defaultDataReducer: Reducer<JsonFormsDefaultDataRegistryEntry[], ValidDefaultDataActions>;
|
|
10
|
+
export declare const getDefaultData: (state: JsonFormsState) => JsonFormsDefaultDataRegistryEntry[];
|
|
9
11
|
export declare const extractDefaultData: (state: JsonFormsDefaultDataRegistryEntry[]) => JsonFormsDefaultDataRegistryEntry[];
|
|
10
12
|
export {};
|
package/lib/reducers/i18n.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { JsonFormsI18nState } from '../i18n';
|
|
2
1
|
import { I18nActions } from '../actions';
|
|
3
|
-
import
|
|
2
|
+
import { Reducer } from '../store/type';
|
|
3
|
+
import { JsonFormsI18nState } from '../store';
|
|
4
4
|
export declare const defaultJsonFormsI18nState: Required<JsonFormsI18nState>;
|
|
5
5
|
export declare const i18nReducer: Reducer<JsonFormsI18nState, I18nActions>;
|
|
6
|
-
export declare const fetchLocale: (state?: JsonFormsI18nState) => string;
|
|
7
|
-
export declare const fetchTranslator: (state?: JsonFormsI18nState) => import("../i18n").Translator;
|
|
8
|
-
export declare const fetchErrorTranslator: (state?: JsonFormsI18nState) => import("../i18n").ErrorTranslator;
|
package/lib/reducers/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CoreActions } from '../actions';
|
|
2
|
-
import { JsonFormsCore } from '
|
|
2
|
+
import { JsonFormsCore } from '../store';
|
|
3
3
|
export interface Middleware {
|
|
4
4
|
(state: JsonFormsCore, action: CoreActions, defaultReducer: (state: JsonFormsCore, action: CoreActions) => JsonFormsCore): JsonFormsCore;
|
|
5
5
|
}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import type { ControlElement, UISchemaElement } from '../models';
|
|
2
|
-
import type { JsonFormsState } from '../store';
|
|
3
|
-
import type { JsonFormsUISchemaRegistryEntry } from './uischemas';
|
|
4
2
|
import type { JsonSchema } from '../models/jsonSchema';
|
|
5
|
-
import
|
|
3
|
+
import { JsonFormsUISchemaRegistryEntry } from '../store';
|
|
6
4
|
export declare const jsonFormsReducerConfig: {
|
|
7
|
-
core: import("
|
|
8
|
-
renderers: import("
|
|
9
|
-
cells: import("
|
|
10
|
-
config: import("
|
|
11
|
-
uischemas: import("
|
|
12
|
-
defaultData: import("
|
|
13
|
-
i18n: import("
|
|
5
|
+
core: import("../store").Reducer<import("../store").JsonFormsCore, import("..").CoreActions>;
|
|
6
|
+
renderers: import("../store").Reducer<import("../store").JsonFormsRendererRegistryEntry[], import("..").AddRendererAction | import("..").RemoveRendererAction>;
|
|
7
|
+
cells: import("../store").Reducer<import("./cells").JsonFormsCellRendererRegistryState, import("..").AddCellRendererAction | import("..").RemoveCellRendererAction>;
|
|
8
|
+
config: import("../store").Reducer<any, import("..").SetConfigAction>;
|
|
9
|
+
uischemas: import("../store").Reducer<JsonFormsUISchemaRegistryEntry[], import("..").UISchemaActions>;
|
|
10
|
+
defaultData: import("../store").Reducer<import("./default-data").JsonFormsDefaultDataRegistryEntry[], import("..").RegisterDefaultDataAction | import("..").UnregisterDefaultDataAction>;
|
|
11
|
+
i18n: import("../store").Reducer<import("../store").JsonFormsI18nState, import("..").I18nActions>;
|
|
14
12
|
};
|
|
15
13
|
/**
|
|
16
14
|
* Finds a registered UI schema to use, if any.
|
|
@@ -21,9 +19,3 @@ export declare const jsonFormsReducerConfig: {
|
|
|
21
19
|
* @param control may be checked for embedded inline uischema options
|
|
22
20
|
*/
|
|
23
21
|
export declare const findUISchema: (uischemas: JsonFormsUISchemaRegistryEntry[], schema: JsonSchema, schemaPath: string, path: string, fallback?: string | (() => UISchemaElement), control?: ControlElement, rootSchema?: JsonSchema) => UISchemaElement;
|
|
24
|
-
export declare const getErrorAt: (instancePath: string, schema: JsonSchema) => (state: JsonFormsState) => import("ajv").ErrorObject<string, Record<string, any>, unknown>[];
|
|
25
|
-
export declare const getSubErrorsAt: (instancePath: string, schema: JsonSchema) => (state: JsonFormsState) => import("ajv").ErrorObject<string, Record<string, any>, unknown>[];
|
|
26
|
-
export declare const getConfig: (state: JsonFormsState) => any;
|
|
27
|
-
export declare const getLocale: (state: JsonFormsState) => string;
|
|
28
|
-
export declare const getTranslator: () => (state: JsonFormsState) => Translator;
|
|
29
|
-
export declare const getErrorTranslator: () => (state: JsonFormsState) => ErrorTranslator;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import type { RankedTester } from '../testers';
|
|
2
1
|
import { AddRendererAction, RemoveRendererAction } from '../actions';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
tester: RankedTester;
|
|
6
|
-
renderer: any;
|
|
7
|
-
}
|
|
2
|
+
import { Reducer } from '../store/type';
|
|
3
|
+
import { JsonFormsRendererRegistryEntry } from '../store';
|
|
8
4
|
type ValidRendererReducerActions = AddRendererAction | RemoveRendererAction;
|
|
9
5
|
export declare const rendererReducer: Reducer<JsonFormsRendererRegistryEntry[], ValidRendererReducerActions>;
|
|
10
6
|
export {};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { UISchemaActions } from '../actions';
|
|
2
2
|
import type { JsonSchema, UISchemaElement } from '../models';
|
|
3
|
-
import type { Reducer } from '../
|
|
4
|
-
|
|
5
|
-
export interface JsonFormsUISchemaRegistryEntry {
|
|
6
|
-
tester: UISchemaTester;
|
|
7
|
-
uischema: UISchemaElement;
|
|
8
|
-
}
|
|
3
|
+
import type { Reducer } from '../store/type';
|
|
4
|
+
import { JsonFormsUISchemaRegistryEntry } from '../store';
|
|
9
5
|
export declare const uischemaRegistryReducer: Reducer<JsonFormsUISchemaRegistryEntry[], UISchemaActions>;
|
|
10
6
|
export declare const findMatchingUISchema: (state: JsonFormsUISchemaRegistryEntry[]) => (jsonSchema: JsonSchema, schemaPath: string, path: string) => UISchemaElement;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Ajv, { ErrorObject } from 'ajv';
|
|
2
|
+
import { JsonSchema, UISchemaElement } from '../models';
|
|
3
|
+
import { JsonFormsCellRendererRegistryEntry, JsonFormsCore, JsonFormsRendererRegistryEntry, JsonFormsState, JsonFormsUISchemaRegistryEntry } from './store';
|
|
4
|
+
export declare const errorAt: (instancePath: string, schema: JsonSchema) => (state: JsonFormsCore) => ErrorObject[];
|
|
5
|
+
export declare const subErrorsAt: (instancePath: string, schema: JsonSchema) => (state: JsonFormsCore) => ErrorObject[];
|
|
6
|
+
export declare const getErrorAt: (instancePath: string, schema: JsonSchema) => (state: JsonFormsState) => ErrorObject<string, Record<string, any>, unknown>[];
|
|
7
|
+
export declare const getSubErrorsAt: (instancePath: string, schema: JsonSchema) => (state: JsonFormsState) => ErrorObject<string, Record<string, any>, unknown>[];
|
|
8
|
+
export declare const getData: (state: JsonFormsState) => any;
|
|
9
|
+
export declare const getSchema: (state: JsonFormsState) => JsonSchema;
|
|
10
|
+
export declare const getUiSchema: (state: JsonFormsState) => UISchemaElement;
|
|
11
|
+
export declare const getAjv: (state: JsonFormsState) => Ajv;
|
|
12
|
+
export declare const getRenderers: (state: JsonFormsState) => JsonFormsRendererRegistryEntry[];
|
|
13
|
+
export declare const getCells: (state: JsonFormsState) => JsonFormsCellRendererRegistryEntry[];
|
|
14
|
+
export declare const getUISchemas: (state: JsonFormsState) => JsonFormsUISchemaRegistryEntry[];
|
|
15
|
+
export declare const extractData: (state: JsonFormsCore) => any;
|
|
16
|
+
export declare const extractSchema: (state: JsonFormsCore) => JsonSchema;
|
|
17
|
+
export declare const extractUiSchema: (state: JsonFormsCore) => UISchemaElement;
|
|
18
|
+
export declare const extractAjv: (state: JsonFormsCore) => Ajv;
|
|
19
|
+
export declare const getConfig: (state: JsonFormsState) => any;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type { Store } from './
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import type { Store } from './type';
|
|
2
|
+
import { RankedTester, UISchemaTester } from '../testers';
|
|
3
|
+
import { JsonSchema, UISchemaElement } from '../models';
|
|
4
|
+
import Ajv, { ErrorObject, ValidateFunction } from 'ajv';
|
|
5
|
+
import { JsonFormsI18nState } from './i18nTypes';
|
|
4
6
|
/**
|
|
5
7
|
* JSONForms store.
|
|
6
8
|
*/
|
|
@@ -46,6 +48,29 @@ export interface JsonFormsSubStates {
|
|
|
46
48
|
readonly?: boolean;
|
|
47
49
|
[additionalState: string]: any;
|
|
48
50
|
}
|
|
51
|
+
export type ValidationMode = 'ValidateAndShow' | 'ValidateAndHide' | 'NoValidation';
|
|
52
|
+
export interface JsonFormsCore {
|
|
53
|
+
data: any;
|
|
54
|
+
schema: JsonSchema;
|
|
55
|
+
uischema: UISchemaElement;
|
|
56
|
+
errors?: ErrorObject[];
|
|
57
|
+
additionalErrors?: ErrorObject[];
|
|
58
|
+
validator?: ValidateFunction;
|
|
59
|
+
ajv?: Ajv;
|
|
60
|
+
validationMode?: ValidationMode;
|
|
61
|
+
}
|
|
62
|
+
export interface JsonFormsRendererRegistryEntry {
|
|
63
|
+
tester: RankedTester;
|
|
64
|
+
renderer: any;
|
|
65
|
+
}
|
|
66
|
+
export interface JsonFormsUISchemaRegistryEntry {
|
|
67
|
+
tester: UISchemaTester;
|
|
68
|
+
uischema: UISchemaElement;
|
|
69
|
+
}
|
|
70
|
+
export interface JsonFormsCellRendererRegistryEntry {
|
|
71
|
+
tester: RankedTester;
|
|
72
|
+
cell: any;
|
|
73
|
+
}
|
|
49
74
|
export interface JsonFormsExtendedState<T> extends JsonFormsState {
|
|
50
75
|
jsonforms: {
|
|
51
76
|
[subState: string]: T;
|
package/lib/testers/testers.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export interface TesterContext {
|
|
|
23
23
|
/** The form wide configuration object given to JsonForms. */
|
|
24
24
|
config: any;
|
|
25
25
|
}
|
|
26
|
+
export type UISchemaTester = (schema: JsonSchema, schemaPath: string, path: string) => number;
|
|
26
27
|
export declare const isControl: (uischema: any) => uischema is ControlElement;
|
|
27
28
|
/**
|
|
28
29
|
* Only applicable for Controls.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ErrorObject } from 'ajv';
|
|
2
|
+
import { JsonSchema } from '../models';
|
|
3
|
+
export declare const getControlPath: (error: ErrorObject) => any;
|
|
4
|
+
export declare const errorsAt: (instancePath: string, schema: JsonSchema, matchPath: (path: string) => boolean) => (errors: ErrorObject[]) => ErrorObject[];
|
|
5
|
+
export declare const formatErrorMessage: (errors: string[]) => string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ControlElement, JsonSchema, LabelDescription } from '
|
|
1
|
+
import type { ControlElement, JsonSchema, LabelDescription } from '../models';
|
|
2
2
|
export declare const Helpers: {
|
|
3
3
|
createLabelDescriptionFrom(withLabel: ControlElement, schema: JsonSchema): LabelDescription;
|
|
4
4
|
convertToValidClassName(s: string): string;
|
package/lib/util/index.d.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
export * from './array';
|
|
2
|
-
export * from './cell';
|
|
3
|
-
export * from './combinators';
|
|
4
1
|
export * from './Formatted';
|
|
5
2
|
export * from './ids';
|
|
6
3
|
export * from './label';
|
|
7
4
|
export * from './path';
|
|
8
|
-
export * from './renderer';
|
|
9
5
|
export * from './resolvers';
|
|
10
6
|
export * from './runtime';
|
|
11
7
|
export * from './schema';
|
|
12
|
-
export * from './type';
|
|
13
8
|
export * from './uischema';
|
|
14
9
|
export * from './util';
|
|
15
10
|
export * from './validator';
|
|
16
11
|
export * from './defaultDateFormat';
|
|
12
|
+
export * from './errors';
|
|
13
|
+
export * from './helpers';
|
package/lib/util/label.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { ControlElement, JsonSchema, LabelDescription
|
|
2
|
-
import { Translator } from '../i18n';
|
|
1
|
+
import { ControlElement, JsonSchema, LabelDescription } from '../models';
|
|
3
2
|
export declare const createCleanLabel: (label: string) => string;
|
|
4
3
|
/**
|
|
5
4
|
* Return a label object based on the given control and schema element.
|
|
@@ -8,14 +7,3 @@ export declare const createCleanLabel: (label: string) => string;
|
|
|
8
7
|
* @returns {LabelDescription}
|
|
9
8
|
*/
|
|
10
9
|
export declare const createLabelDescriptionFrom: (withLabel: ControlElement, schema?: JsonSchema) => LabelDescription;
|
|
11
|
-
/**
|
|
12
|
-
* Compute the child label title for array based controls
|
|
13
|
-
* @param data the data of the control
|
|
14
|
-
* @param childPath the child path
|
|
15
|
-
* @param childLabelProp the dotted path to the value used as child label
|
|
16
|
-
* @param {JsonSchema} schema the json schema for this control
|
|
17
|
-
* @param {JsonSchema} rootSchema the root json schema
|
|
18
|
-
* @param {Translator} translateFct the translator fonction
|
|
19
|
-
* @param {UISchemaElement} uiSchema the uiSchema of the control
|
|
20
|
-
*/
|
|
21
|
-
export declare const computeChildLabel: (data: any, childPath: string, childLabelProp: string, schema: JsonSchema, rootSchema: JsonSchema, translateFct: Translator, uiSchema: UISchemaElement) => string;
|
package/lib/util/path.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Scopable } from '../models';
|
|
2
1
|
export declare const compose: (path1: string, path2: string) => string;
|
|
3
2
|
export { compose as composePaths };
|
|
4
3
|
/**
|
|
@@ -25,7 +24,6 @@ export declare const toDataPathSegments: (schemaPath: string) => string[];
|
|
|
25
24
|
* @returns {string} the data path
|
|
26
25
|
*/
|
|
27
26
|
export declare const toDataPath: (schemaPath: string) => string;
|
|
28
|
-
export declare const composeWithUi: (scopableUi: Scopable, path: string) => string;
|
|
29
27
|
/**
|
|
30
28
|
* Encodes the given segment to be used as part of a JSON Pointer
|
|
31
29
|
*
|
|
@@ -36,3 +34,9 @@ export declare const encode: (segment: string) => string;
|
|
|
36
34
|
* Decodes a given JSON Pointer segment to its "normal" representation
|
|
37
35
|
*/
|
|
38
36
|
export declare const decode: (pointerSegment: string) => string;
|
|
37
|
+
/**
|
|
38
|
+
* Transform a dotted path to a uiSchema properties path
|
|
39
|
+
* @param path a dotted prop path to a schema value (i.e. articles.comment.author)
|
|
40
|
+
* @return the uiSchema properties path (i.e. /properties/articles/properties/comment/properties/author)
|
|
41
|
+
*/
|
|
42
|
+
export declare const getPropPath: (path: string) => string;
|
package/lib/util/runtime.d.ts
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UISchemaElement } from '../models';
|
|
2
2
|
import type Ajv from 'ajv';
|
|
3
|
-
import type { JsonFormsState } from '../store';
|
|
4
3
|
export declare const evalVisibility: (uischema: UISchemaElement, data: any, path: string, ajv: Ajv) => boolean;
|
|
5
4
|
export declare const evalEnablement: (uischema: UISchemaElement, data: any, path: string, ajv: Ajv) => boolean;
|
|
6
5
|
export declare const hasShowRule: (uischema: UISchemaElement) => boolean;
|
|
7
6
|
export declare const hasEnableRule: (uischema: UISchemaElement) => boolean;
|
|
8
7
|
export declare const isVisible: (uischema: UISchemaElement, data: any, path: string, ajv: Ajv) => boolean;
|
|
9
8
|
export declare const isEnabled: (uischema: UISchemaElement, data: any, path: string, ajv: Ajv) => boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Indicates whether the given `uischema` element shall be enabled or disabled.
|
|
12
|
-
* Checks the global readonly flag, uischema rule, uischema options (including the config),
|
|
13
|
-
* the schema and the enablement indicator of the parent.
|
|
14
|
-
*/
|
|
15
|
-
export declare const isInherentlyEnabled: (state: JsonFormsState, ownProps: any, uischema: UISchemaElement, schema: (JsonSchema & {
|
|
16
|
-
readOnly?: boolean;
|
|
17
|
-
}) | undefined, rootData: any, config: any) => any;
|
package/lib/util/schema.d.ts
CHANGED
package/lib/util/uischema.d.ts
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import { UISchemaElement } from '../models';
|
|
1
|
+
import { ControlElement, GroupLayout, Internationalizable, Labelable, Labeled, Layout, Scopable, Scoped, UISchemaElement } from '../models';
|
|
2
2
|
export type IterateCallback = (uischema: UISchemaElement) => void;
|
|
3
3
|
export declare const setReadonly: (uischema: UISchemaElement) => void;
|
|
4
4
|
export declare const unsetReadonly: (uischema: UISchemaElement) => void;
|
|
5
5
|
export declare const iterateSchema: (uischema: UISchemaElement, toApply: IterateCallback) => void;
|
|
6
|
-
/**
|
|
7
|
-
* Transform a dotted path to a uiSchema properties path
|
|
8
|
-
* @param path a dotted prop path to a schema value (i.e. articles.comment.author)
|
|
9
|
-
* @return the uiSchema properties path (i.e. /properties/articles/properties/comment/properties/author)
|
|
10
|
-
*/
|
|
11
|
-
export declare const getPropPath: (path: string) => string;
|
|
12
6
|
/**
|
|
13
7
|
* Find a control in a uiSchema, based on the dotted path of the schema value
|
|
14
8
|
* @param {UISchemaElement} uiSchema the uiSchema to search from
|
|
@@ -16,3 +10,12 @@ export declare const getPropPath: (path: string) => string;
|
|
|
16
10
|
* @return {UISchemaElement} or undefined if not found
|
|
17
11
|
*/
|
|
18
12
|
export declare const findUiControl: (uiSchema: UISchemaElement, path: string) => UISchemaElement | undefined;
|
|
13
|
+
export declare const composeWithUi: (scopableUi: Scopable, path: string) => string;
|
|
14
|
+
export declare const isInternationalized: (element: unknown) => element is Required<Internationalizable>;
|
|
15
|
+
export declare const isGroup: (layout: Layout) => layout is GroupLayout;
|
|
16
|
+
export declare const isLayout: (uischema: UISchemaElement) => uischema is Layout;
|
|
17
|
+
export declare const isScopable: (obj: unknown) => obj is Scopable;
|
|
18
|
+
export declare const isScoped: (obj: unknown) => obj is Scoped;
|
|
19
|
+
export declare const isLabelable: (obj: unknown) => obj is Labelable<string>;
|
|
20
|
+
export declare const isLabeled: <T = never>(obj: unknown) => obj is Labeled<T>;
|
|
21
|
+
export declare const isControlElement: (uiSchema: UISchemaElement) => uiSchema is ControlElement;
|
package/lib/util/util.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { JsonSchema, Scoped, UISchemaElement } from '..';
|
|
2
1
|
import type Ajv from 'ajv';
|
|
2
|
+
import type { JsonSchema, Scoped, UISchemaElement } from '../models';
|
|
3
3
|
/**
|
|
4
4
|
* Returns the string representation of the given date. The format of the output string can be specified:
|
|
5
5
|
* - 'date' for a date-only string (YYYY-MM-DD),
|
|
@@ -34,7 +34,6 @@ export declare const convertDateToString: (date: Date, format?: 'date' | 'time'
|
|
|
34
34
|
* @returns {string} the escaped string
|
|
35
35
|
*/
|
|
36
36
|
export declare const convertToValidClassName: (s: string) => string;
|
|
37
|
-
export declare const formatErrorMessage: (errors: string[]) => string;
|
|
38
37
|
export declare const hasType: (jsonSchema: JsonSchema, expected: string) => boolean;
|
|
39
38
|
/**
|
|
40
39
|
* Derives the type of the jsonSchema element
|
package/lib/util/validator.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import Ajv from 'ajv';
|
|
2
|
-
import type { Options } from 'ajv';
|
|
2
|
+
import type { ErrorObject, Options, ValidateFunction } from 'ajv';
|
|
3
3
|
export declare const createAjv: (options?: Options) => Ajv;
|
|
4
|
+
export declare const validate: (validator: ValidateFunction | undefined, data: any) => ErrorObject[];
|
package/package.json
CHANGED
package/src/actions/actions.ts
CHANGED
|
@@ -25,12 +25,11 @@
|
|
|
25
25
|
|
|
26
26
|
import type AJV from 'ajv';
|
|
27
27
|
import type { ErrorObject } from 'ajv';
|
|
28
|
-
import
|
|
28
|
+
import { JsonSchema, UISchemaElement } from '../models';
|
|
29
29
|
import { generateDefaultUISchema, generateJsonSchema } from '../generators';
|
|
30
30
|
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
import type { ErrorTranslator, Translator } from '../i18n';
|
|
31
|
+
import { RankedTester, UISchemaTester } from '../testers';
|
|
32
|
+
import { ErrorTranslator, Translator, ValidationMode } from '../store';
|
|
34
33
|
|
|
35
34
|
export const INIT = 'jsonforms/INIT' as const;
|
|
36
35
|
export const UPDATE_CORE = 'jsonforms/UPDATE_CORE' as const;
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
+
import { ControlElement, JsonSchema, UISchemaElement } from '../models';
|
|
26
27
|
import { generateJsonSchema } from './schema';
|
|
27
28
|
import { createControlElement, generateDefaultUISchema } from './uischema';
|
|
28
|
-
import type { ControlElement, JsonSchema, UISchemaElement } from '../';
|
|
29
29
|
|
|
30
30
|
export const Generate: {
|
|
31
31
|
// TODO fix @typescript-eslint/ban-types
|
|
@@ -28,14 +28,12 @@ import startCase from 'lodash/startCase';
|
|
|
28
28
|
import keys from 'lodash/keys';
|
|
29
29
|
import {
|
|
30
30
|
ControlElement,
|
|
31
|
-
isGroup,
|
|
32
|
-
isLayout,
|
|
33
31
|
JsonSchema,
|
|
34
32
|
LabelElement,
|
|
35
33
|
Layout,
|
|
36
34
|
UISchemaElement,
|
|
37
35
|
} from '../models';
|
|
38
|
-
import { deriveTypes, encode, resolveSchema } from '../util';
|
|
36
|
+
import { deriveTypes, encode, isGroup, isLayout, resolveSchema } from '../util';
|
|
39
37
|
|
|
40
38
|
/**
|
|
41
39
|
* Creates a new ILayout.
|
package/src/i18n/i18nUtil.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { ErrorObject } from 'ajv';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { formatErrorMessage } from '../util';
|
|
5
|
-
import type { i18nJsonSchema, ErrorTranslator, Translator } from './i18nTypes';
|
|
2
|
+
import { Labelable, UISchemaElement } from '../models';
|
|
3
|
+
import type { i18nJsonSchema, ErrorTranslator, Translator } from '../store';
|
|
6
4
|
import {
|
|
7
5
|
ArrayDefaultTranslation,
|
|
8
6
|
ArrayTranslations,
|
|
@@ -11,6 +9,11 @@ import {
|
|
|
11
9
|
CombinatorDefaultTranslation,
|
|
12
10
|
CombinatorTranslations,
|
|
13
11
|
} from './combinatorTranslations';
|
|
12
|
+
import {
|
|
13
|
+
formatErrorMessage,
|
|
14
|
+
getControlPath,
|
|
15
|
+
isInternationalized,
|
|
16
|
+
} from '../util';
|
|
14
17
|
|
|
15
18
|
export const getI18nKeyPrefixBySchema = (
|
|
16
19
|
schema: i18nJsonSchema | undefined,
|