@react-typed-forms/schemas 11.19.2 → 12.0.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/controlRender.d.ts +16 -12
- package/lib/hooks.d.ts +7 -6
- package/lib/index.cjs +1 -1
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/schemaInterface.d.ts +1 -0
- package/lib/treeNodes.d.ts +45 -0
- package/lib/types.d.ts +6 -0
- package/lib/util.d.ts +13 -8
- package/lib/validators.d.ts +1 -1
- package/package.json +1 -1
package/lib/schemaInterface.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare class DefaultSchemaInterface implements SchemaInterface {
|
|
|
6
6
|
parseToMillis(field: SchemaField, v: string): number;
|
|
7
7
|
validationMessageText(field: SchemaField, messageType: ValidationMessageType, actual: any, expected: any): string;
|
|
8
8
|
getOptions({ options }: SchemaField): FieldOption[] | null | undefined;
|
|
9
|
+
getFilterOptions(field: SchemaField): FieldOption[] | undefined | null;
|
|
9
10
|
isEmptyValue(f: SchemaField, value: any): boolean;
|
|
10
11
|
textValue(field: SchemaField, value: any, element?: boolean | undefined): string | undefined;
|
|
11
12
|
controlLength(f: SchemaField, control: Control<any>): number;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Control } from "@react-typed-forms/core";
|
|
2
|
+
import { ControlDefinition, SchemaField } from "./types";
|
|
3
|
+
export interface FormNode {
|
|
4
|
+
definition: ControlDefinition;
|
|
5
|
+
getChildNodes(): FormNode[];
|
|
6
|
+
parent?: FormNode;
|
|
7
|
+
}
|
|
8
|
+
export interface FormTreeLookup<A = string> {
|
|
9
|
+
getForm(formId: A): FormTreeNode | undefined;
|
|
10
|
+
}
|
|
11
|
+
export interface FormTreeNode extends FormTreeLookup {
|
|
12
|
+
rootNode: FormNode;
|
|
13
|
+
}
|
|
14
|
+
export interface SchemaTreeLookup<A = string> {
|
|
15
|
+
getSchema(schemaId: A): SchemaNode | undefined;
|
|
16
|
+
}
|
|
17
|
+
export interface SchemaNode extends SchemaTreeLookup {
|
|
18
|
+
field: SchemaField;
|
|
19
|
+
getChildNode(field: string): SchemaNode | undefined;
|
|
20
|
+
getChildNodes(): SchemaNode[];
|
|
21
|
+
parent?: SchemaNode;
|
|
22
|
+
}
|
|
23
|
+
export interface SchemaDataNode {
|
|
24
|
+
schema: SchemaNode;
|
|
25
|
+
elementIndex?: number;
|
|
26
|
+
control?: Control<unknown>;
|
|
27
|
+
parent?: SchemaDataNode;
|
|
28
|
+
getChild(node: SchemaNode): SchemaDataNode;
|
|
29
|
+
getChildElement(index: number): SchemaDataNode;
|
|
30
|
+
}
|
|
31
|
+
export declare function createSchemaLookup<A extends Record<string, SchemaField[]>>(schemaMap: A): SchemaTreeLookup<keyof A>;
|
|
32
|
+
export declare function createFormLookup<A extends Record<string, ControlDefinition[]>>(formMap: A): FormTreeLookup<keyof A>;
|
|
33
|
+
export declare function makeSchemaDataNode(schema: SchemaNode, control?: Control<unknown>, parent?: SchemaDataNode, elementIndex?: number): SchemaDataNode;
|
|
34
|
+
export declare function fieldPathForDefinition(c: ControlDefinition): string[] | undefined;
|
|
35
|
+
export declare function schemaDataForFieldRef(fieldRef: string | undefined, schema: SchemaDataNode): SchemaDataNode;
|
|
36
|
+
export declare function schemaForFieldRef(fieldRef: string | undefined, schema: SchemaNode): SchemaNode;
|
|
37
|
+
export declare function schemaDataForFieldPath(fieldPath: string[], schema: SchemaDataNode): SchemaDataNode;
|
|
38
|
+
export declare function schemaForFieldPath(fieldPath: string[], schema: SchemaNode): SchemaNode;
|
|
39
|
+
export declare function traverseParents<A, B extends {
|
|
40
|
+
parent?: B | undefined;
|
|
41
|
+
}>(current: B | undefined, get: (b: B) => A, until?: (b: B) => boolean): A[];
|
|
42
|
+
export declare function getRootDataNode(dataNode: SchemaDataNode): SchemaDataNode;
|
|
43
|
+
export declare function getJsonPath(dataNode: SchemaDataNode): (string | number)[];
|
|
44
|
+
export declare function getSchemaFieldList(schema: SchemaNode): SchemaField[];
|
|
45
|
+
export declare function rootSchemaNode(fields: SchemaField[], lookup?: SchemaTreeLookup): SchemaNode;
|
package/lib/types.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ export interface SchemaInterface {
|
|
|
62
62
|
controlLength(field: SchemaField, control: Control<any>): number;
|
|
63
63
|
valueLength(field: SchemaField, value: any): number;
|
|
64
64
|
getOptions(field: SchemaField): FieldOption[] | undefined | null;
|
|
65
|
+
getFilterOptions(field: SchemaField): FieldOption[] | undefined | null;
|
|
65
66
|
parseToMillis(field: SchemaField, v: string): number;
|
|
66
67
|
validationMessageText(field: SchemaField, messageType: ValidationMessageType, actual: any, expected: any): string;
|
|
67
68
|
}
|
|
@@ -391,3 +392,8 @@ export declare function isDisplayOnlyRenderer(options: RenderOptions): options i
|
|
|
391
392
|
export declare function isTextfieldRenderer(options: RenderOptions): options is TextfieldRenderOptions;
|
|
392
393
|
export declare function isDataGroupRenderer(options: RenderOptions): options is DataGroupRenderOptions;
|
|
393
394
|
export declare function isArrayRenderer(options: RenderOptions): options is ArrayRenderOptions;
|
|
395
|
+
export declare function findField(fields: SchemaField[], field: string): SchemaField | undefined;
|
|
396
|
+
export declare function isScalarField(sf: SchemaField): sf is SchemaField;
|
|
397
|
+
export declare function isCompoundField(sf: SchemaField): sf is CompoundField;
|
|
398
|
+
export declare function isDataControl(c: ControlDefinition): c is DataControlDefinition;
|
|
399
|
+
export declare function isGroupControl(c: ControlDefinition): c is GroupedControlsDefinition;
|
package/lib/util.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { CompoundField, ControlDefinition, DataControlDefinition, DisplayOnlyRenderOptions, FieldOption,
|
|
1
|
+
import { CompoundField, ControlDefinition, DataControlDefinition, DisplayOnlyRenderOptions, FieldOption, SchemaField, SchemaInterface } from "./types";
|
|
2
2
|
import { MutableRefObject } from "react";
|
|
3
3
|
import { Control } from "@react-typed-forms/core";
|
|
4
|
+
import { SchemaDataNode } from "./treeNodes";
|
|
4
5
|
export type JsonPath = string | number;
|
|
5
6
|
export interface DataContext {
|
|
6
7
|
data: Control<any>;
|
|
@@ -9,6 +10,17 @@ export interface DataContext {
|
|
|
9
10
|
export interface ControlDataContext extends DataContext {
|
|
10
11
|
fields: SchemaField[];
|
|
11
12
|
schemaInterface: SchemaInterface;
|
|
13
|
+
dataNode: SchemaDataNode | undefined;
|
|
14
|
+
parentNode: SchemaDataNode;
|
|
15
|
+
}
|
|
16
|
+
export declare class ControlDataContextImpl implements ControlDataContext {
|
|
17
|
+
schemaInterface: SchemaInterface;
|
|
18
|
+
dataNode: SchemaDataNode | undefined;
|
|
19
|
+
parentNode: SchemaDataNode;
|
|
20
|
+
constructor(schemaInterface: SchemaInterface, dataNode: SchemaDataNode | undefined, parentNode: SchemaDataNode);
|
|
21
|
+
get fields(): SchemaField[];
|
|
22
|
+
get data(): Control<unknown>;
|
|
23
|
+
get path(): (string | number)[];
|
|
12
24
|
}
|
|
13
25
|
export declare function applyDefaultValues(v: Record<string, any> | undefined, fields: SchemaField[], doneSet?: Set<Record<string, any>>): any;
|
|
14
26
|
export declare function applyDefaultForField(v: any, field: SchemaField, parent: SchemaField[], notElement?: boolean, doneSet?: Set<Record<string, any>>): any;
|
|
@@ -17,11 +29,6 @@ export declare function defaultValueForField(sf: SchemaField, required?: boolean
|
|
|
17
29
|
export declare function elementValueForField(sf: SchemaField): any;
|
|
18
30
|
export declare function findScalarField(fields: SchemaField[], field: string): SchemaField | undefined;
|
|
19
31
|
export declare function findCompoundField(fields: SchemaField[], field: string): CompoundField | undefined;
|
|
20
|
-
export declare function findField(fields: SchemaField[], field: string): SchemaField | undefined;
|
|
21
|
-
export declare function isScalarField(sf: SchemaField): sf is SchemaField;
|
|
22
|
-
export declare function isCompoundField(sf: SchemaField): sf is CompoundField;
|
|
23
|
-
export declare function isDataControl(c: ControlDefinition): c is DataControlDefinition;
|
|
24
|
-
export declare function isGroupControl(c: ControlDefinition): c is GroupedControlsDefinition;
|
|
25
32
|
export declare function fieldHasTag(field: SchemaField, tag: string): boolean;
|
|
26
33
|
export declare function fieldDisplayName(field: SchemaField): string;
|
|
27
34
|
export declare function hasOptions(o: {
|
|
@@ -41,7 +48,6 @@ export declare function useUpdatedRef<A>(a: A): MutableRefObject<A>;
|
|
|
41
48
|
export declare function isControlReadonly(c: ControlDefinition): boolean;
|
|
42
49
|
export declare function isControlDisabled(c: ControlDefinition): boolean;
|
|
43
50
|
export declare function getDisplayOnlyOptions(d: ControlDefinition): DisplayOnlyRenderOptions | undefined;
|
|
44
|
-
export declare function getTypeField(context: ControlDataContext, fieldPath: SchemaField[]): Control<string> | undefined;
|
|
45
51
|
export declare function visitControlDataArray<A>(controls: ControlDefinition[] | undefined | null, context: ControlDataContext, cb: (definition: DataControlDefinition, field: SchemaField, control: Control<any>, element: boolean) => A | undefined): A | undefined;
|
|
46
52
|
export declare function visitControlData<A>(definition: ControlDefinition, ctx: ControlDataContext, cb: (definition: DataControlDefinition, field: SchemaField, control: Control<any>, element: boolean) => A | undefined): A | undefined;
|
|
47
53
|
export declare function lookupChildControl(data: DataContext, path: SchemaField[], element?: number): Control<any> | undefined;
|
|
@@ -68,7 +74,6 @@ export declare function useDynamicHooks<P, Hooks extends Record<string, DynamicH
|
|
|
68
74
|
[K in keyof Hooks]: DynamicHookValue<Hooks[K]>;
|
|
69
75
|
};
|
|
70
76
|
export declare function toDepString(x: any): string;
|
|
71
|
-
export declare function appendElementIndex(dataContext: ControlDataContext, elementIndex: number): ControlDataContext;
|
|
72
77
|
export declare function applyLengthRestrictions<Min, Max>(length: number, min: number | null | undefined, max: number | null | undefined, minValue: Min, maxValue: Max): [Min | undefined, Max | undefined];
|
|
73
78
|
export declare function findFieldPath(fields: SchemaField[], fieldPath: string | undefined): SchemaField[] | undefined;
|
|
74
79
|
export declare function mergeObjects<A extends Record<string, any> | undefined>(o1: A, o2: A, doMerge?: (k: keyof NonNullable<A>, v1: unknown, v2: unknown) => unknown): A;
|
package/lib/validators.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface ValidationContext extends ValidationHookContext {
|
|
|
11
11
|
field: SchemaField;
|
|
12
12
|
index: number;
|
|
13
13
|
}
|
|
14
|
-
export declare function useMakeValidationHook(definition: ControlDefinition,
|
|
14
|
+
export declare function useMakeValidationHook(definition: ControlDefinition, useValidatorFor?: (validator: SchemaValidator, ctx: ValidationContext) => void): (ctx: ValidationHookContext) => void;
|
|
15
15
|
export declare function useJsonataValidator(validator: JsonataValidator, ctx: ValidationContext): void;
|
|
16
16
|
export declare function useLengthValidator(lv: LengthValidator, ctx: ValidationContext): void;
|
|
17
17
|
export declare function useDateValidator(dv: DateValidator, ctx: ValidationContext): void;
|