@react-typed-forms/schemas 12.0.1 → 12.1.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/hooks.d.ts +2 -2
- package/lib/index.cjs +1 -1
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/schemaInterface.d.ts +6 -1
- package/lib/treeNodes.d.ts +5 -0
- package/lib/types.d.ts +4 -1
- package/lib/util.d.ts +1 -16
- package/package.json +1 -1
package/lib/schemaInterface.d.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { FieldOption, SchemaField, SchemaInterface, ValidationMessageType } from "./types";
|
|
2
2
|
import { Control } from "@react-typed-forms/core";
|
|
3
|
+
import { SchemaDataNode, SchemaNode } from "./treeNodes";
|
|
3
4
|
export declare class DefaultSchemaInterface implements SchemaInterface {
|
|
4
5
|
protected boolStrings: [string, string];
|
|
5
6
|
constructor(boolStrings?: [string, string]);
|
|
6
7
|
parseToMillis(field: SchemaField, v: string): number;
|
|
7
8
|
validationMessageText(field: SchemaField, messageType: ValidationMessageType, actual: any, expected: any): string;
|
|
9
|
+
getDataOptions(node: SchemaDataNode): FieldOption[] | null | undefined;
|
|
10
|
+
getNodeOptions(node: SchemaNode): FieldOption[] | null | undefined;
|
|
8
11
|
getOptions({ options }: SchemaField): FieldOption[] | null | undefined;
|
|
9
|
-
getFilterOptions(field:
|
|
12
|
+
getFilterOptions(array: SchemaDataNode, field: SchemaNode): FieldOption[] | undefined | null;
|
|
10
13
|
isEmptyValue(f: SchemaField, value: any): boolean;
|
|
14
|
+
searchText(field: SchemaField, value: any): string;
|
|
11
15
|
textValue(field: SchemaField, value: any, element?: boolean | undefined): string | undefined;
|
|
12
16
|
controlLength(f: SchemaField, control: Control<any>): number;
|
|
13
17
|
valueLength(field: SchemaField, value: any): number;
|
|
18
|
+
compareValue(field: SchemaField, v1: unknown, v2: unknown): number;
|
|
14
19
|
}
|
|
15
20
|
export declare const defaultSchemaInterface: SchemaInterface;
|
package/lib/treeNodes.d.ts
CHANGED
|
@@ -34,6 +34,10 @@ export declare function makeSchemaDataNode(schema: SchemaNode, control?: Control
|
|
|
34
34
|
export declare function fieldPathForDefinition(c: ControlDefinition): string[] | undefined;
|
|
35
35
|
export declare function schemaDataForFieldRef(fieldRef: string | undefined, schema: SchemaDataNode): SchemaDataNode;
|
|
36
36
|
export declare function schemaForFieldRef(fieldRef: string | undefined, schema: SchemaNode): SchemaNode;
|
|
37
|
+
export declare function traverseSchemaPath<A>(fieldPath: string[], schema: SchemaNode, acc: A, next: (acc: A, node: SchemaNode) => A): A;
|
|
38
|
+
export declare function traverseData(fieldPath: string[], root: SchemaNode, data: {
|
|
39
|
+
[k: string]: any;
|
|
40
|
+
}): unknown;
|
|
37
41
|
export declare function schemaDataForFieldPath(fieldPath: string[], schema: SchemaDataNode): SchemaDataNode;
|
|
38
42
|
export declare function schemaForFieldPath(fieldPath: string[], schema: SchemaNode): SchemaNode;
|
|
39
43
|
export declare function traverseParents<A, B extends {
|
|
@@ -41,6 +45,7 @@ export declare function traverseParents<A, B extends {
|
|
|
41
45
|
}>(current: B | undefined, get: (b: B) => A, until?: (b: B) => boolean): A[];
|
|
42
46
|
export declare function getRootDataNode(dataNode: SchemaDataNode): SchemaDataNode;
|
|
43
47
|
export declare function getJsonPath(dataNode: SchemaDataNode): (string | number)[];
|
|
48
|
+
export declare function getSchemaPath(schemaNode: SchemaNode): SchemaField[];
|
|
44
49
|
export declare function getSchemaFieldList(schema: SchemaNode): SchemaField[];
|
|
45
50
|
export declare function rootSchemaNode(fields: SchemaField[], lookup?: SchemaTreeLookup): SchemaNode;
|
|
46
51
|
export declare function visitControlDataArray<A>(controls: ControlDefinition[] | undefined | null, context: SchemaDataNode, cb: (definition: DataControlDefinition, node: SchemaDataNode) => A | undefined): A | undefined;
|
package/lib/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Control } from "@react-typed-forms/core";
|
|
2
|
+
import { SchemaDataNode, SchemaNode } from "./treeNodes";
|
|
2
3
|
export interface SchemaField {
|
|
3
4
|
type: string;
|
|
4
5
|
field: string;
|
|
@@ -62,9 +63,11 @@ export interface SchemaInterface {
|
|
|
62
63
|
controlLength(field: SchemaField, control: Control<any>): number;
|
|
63
64
|
valueLength(field: SchemaField, value: any): number;
|
|
64
65
|
getOptions(field: SchemaField): FieldOption[] | undefined | null;
|
|
65
|
-
getFilterOptions(field:
|
|
66
|
+
getFilterOptions(array: SchemaDataNode, field: SchemaNode): FieldOption[] | undefined | null;
|
|
66
67
|
parseToMillis(field: SchemaField, v: string): number;
|
|
67
68
|
validationMessageText(field: SchemaField, messageType: ValidationMessageType, actual: any, expected: any): string;
|
|
69
|
+
compareValue(field: SchemaField, v1: unknown, v2: unknown): number;
|
|
70
|
+
searchText(field: SchemaField, value: any): string;
|
|
68
71
|
}
|
|
69
72
|
export interface ControlDefinition {
|
|
70
73
|
type: string;
|
package/lib/util.d.ts
CHANGED
|
@@ -1,26 +1,11 @@
|
|
|
1
1
|
import { CompoundField, ControlDefinition, DataControlDefinition, DisplayOnlyRenderOptions, FieldOption, SchemaField, SchemaInterface } from "./types";
|
|
2
2
|
import { MutableRefObject } from "react";
|
|
3
|
-
import { Control } from "@react-typed-forms/core";
|
|
4
3
|
import { SchemaDataNode } from "./treeNodes";
|
|
5
4
|
export type JsonPath = string | number;
|
|
6
|
-
export interface
|
|
7
|
-
data: Control<any>;
|
|
8
|
-
path: JsonPath[];
|
|
9
|
-
}
|
|
10
|
-
export interface ControlDataContext extends DataContext {
|
|
11
|
-
fields: SchemaField[];
|
|
12
|
-
schemaInterface: SchemaInterface;
|
|
13
|
-
dataNode: SchemaDataNode | undefined;
|
|
14
|
-
parentNode: SchemaDataNode;
|
|
15
|
-
}
|
|
16
|
-
export declare class ControlDataContextImpl implements ControlDataContext {
|
|
5
|
+
export interface ControlDataContext {
|
|
17
6
|
schemaInterface: SchemaInterface;
|
|
18
7
|
dataNode: SchemaDataNode | undefined;
|
|
19
8
|
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)[];
|
|
24
9
|
}
|
|
25
10
|
export declare function applyDefaultValues(v: Record<string, any> | undefined, fields: SchemaField[], doneSet?: Set<Record<string, any>>): any;
|
|
26
11
|
export declare function applyDefaultForField(v: any, field: SchemaField, parent: SchemaField[], notElement?: boolean, doneSet?: Set<Record<string, any>>): any;
|