@react-typed-forms/schemas 15.1.1 → 15.1.3
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/controlBuilder.d.ts +2 -1
- package/lib/controlDefinition.d.ts +36 -42
- package/lib/controlRender.d.ts +85 -36
- package/lib/defaultSchemaInterface.d.ts +6 -2
- package/lib/formNode.d.ts +46 -0
- package/lib/hooks.d.ts +2 -1
- package/lib/index.cjs +858 -678
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +4 -0
- package/lib/index.js +712 -563
- package/lib/index.js.map +1 -1
- package/lib/renderers.d.ts +0 -1
- package/lib/schemaDataNode.d.ts +31 -0
- package/lib/schemaField.d.ts +1 -133
- package/lib/schemaInterface.d.ts +102 -0
- package/lib/schemaNode.d.ts +54 -0
- package/lib/util.d.ts +10 -11
- package/package.json +1 -1
- package/src/controlBuilder.ts +8 -2
- package/src/controlDefinition.ts +43 -243
- package/src/controlRender.tsx +157 -97
- package/src/createFormRenderer.tsx +1 -2
- package/src/defaultSchemaInterface.ts +15 -5
- package/src/formNode.ts +253 -0
- package/src/hooks.tsx +7 -7
- package/src/index.ts +4 -0
- package/src/renderers.tsx +0 -1
- package/src/schemaDataNode.ts +129 -0
- package/src/schemaField.ts +1 -400
- package/src/schemaInterface.ts +135 -0
- package/src/schemaNode.ts +279 -0
- package/src/util.ts +127 -89
- package/src/validators.ts +3 -3
package/lib/renderers.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ export interface DefaultRenderers {
|
|
|
12
12
|
renderLayout: LayoutRendererRegistration;
|
|
13
13
|
visibility: VisibilityRendererRegistration;
|
|
14
14
|
extraRenderers: RendererRegistration[];
|
|
15
|
-
renderText: (props: ReactNode) => ReactNode;
|
|
16
15
|
html: HtmlComponents;
|
|
17
16
|
}
|
|
18
17
|
export interface LayoutRendererRegistration {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Control } from "@react-typed-forms/core";
|
|
2
|
+
import { SchemaNode } from "./schemaNode";
|
|
3
|
+
export declare abstract class SchemaDataTree {
|
|
4
|
+
abstract rootNode: SchemaDataNode;
|
|
5
|
+
abstract getChild(parent: SchemaDataNode, child: SchemaNode): SchemaDataNode;
|
|
6
|
+
abstract getChildElement(parent: SchemaDataNode, elementIndex: number): SchemaDataNode;
|
|
7
|
+
}
|
|
8
|
+
export declare class SchemaDataNode {
|
|
9
|
+
id: string;
|
|
10
|
+
schema: SchemaNode;
|
|
11
|
+
elementIndex: number | undefined;
|
|
12
|
+
control: Control<any>;
|
|
13
|
+
tree: SchemaDataTree;
|
|
14
|
+
parent?: SchemaDataNode | undefined;
|
|
15
|
+
constructor(id: string, schema: SchemaNode, elementIndex: number | undefined, control: Control<any>, tree: SchemaDataTree, parent?: SchemaDataNode | undefined);
|
|
16
|
+
getChild(childNode: SchemaNode): SchemaDataNode;
|
|
17
|
+
getChildElement(elementIndex: number): SchemaDataNode;
|
|
18
|
+
}
|
|
19
|
+
export declare class SchemaDataTreeImpl extends SchemaDataTree {
|
|
20
|
+
rootNode: SchemaDataNode;
|
|
21
|
+
constructor(rootSchema: SchemaNode, rootControl: Control<any>);
|
|
22
|
+
getChild(parent: SchemaDataNode, childNode: SchemaNode): SchemaDataNode;
|
|
23
|
+
getChildElement(parent: SchemaDataNode, elementIndex: number): SchemaDataNode;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated Use createSchemaDataNode instead.
|
|
27
|
+
*/
|
|
28
|
+
export declare const makeSchemaDataNode: typeof createSchemaDataNode;
|
|
29
|
+
export declare function createSchemaDataNode(schema: SchemaNode, control: Control<unknown>): SchemaDataNode;
|
|
30
|
+
export declare function schemaDataForFieldRef(fieldRef: string | undefined, schema: SchemaDataNode): SchemaDataNode;
|
|
31
|
+
export declare function schemaDataForFieldPath(fieldPath: string[], dataNode: SchemaDataNode): SchemaDataNode;
|
package/lib/schemaField.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { SchemaValidator } from "./schemaValidator";
|
|
2
|
-
import { Control, ControlSetup } from "@react-typed-forms/core";
|
|
3
2
|
export type EqualityFunc = (a: any, b: any) => boolean;
|
|
4
3
|
/**
|
|
5
4
|
* Represents a schema field with various properties.
|
|
@@ -106,141 +105,10 @@ export declare enum ValidationMessageType {
|
|
|
106
105
|
NotAfterDate = "NotAfterDate",
|
|
107
106
|
NotBeforeDate = "NotBeforeDate"
|
|
108
107
|
}
|
|
109
|
-
/**
|
|
110
|
-
* Interface for schema-related operations.
|
|
111
|
-
*/
|
|
112
|
-
export interface SchemaInterface {
|
|
113
|
-
/**
|
|
114
|
-
* Checks if the value of a field is empty.
|
|
115
|
-
* @param field The schema field.
|
|
116
|
-
* @param value The value to check.
|
|
117
|
-
* @returns True if the value is empty, false otherwise.
|
|
118
|
-
*/
|
|
119
|
-
isEmptyValue(field: SchemaField, value: any): boolean;
|
|
120
|
-
/**
|
|
121
|
-
* Gets the text representation of a field's value.
|
|
122
|
-
* @param field The schema field.
|
|
123
|
-
* @param value The value to convert.
|
|
124
|
-
* @param element Indicates if the value is an element, optional.
|
|
125
|
-
* @returns The text representation of the value.
|
|
126
|
-
*/
|
|
127
|
-
textValue(field: SchemaField, value: any, element?: boolean): string | undefined;
|
|
128
|
-
/**
|
|
129
|
-
* Gets the length of a control's value.
|
|
130
|
-
* @param field The schema field.
|
|
131
|
-
* @param control The control to check.
|
|
132
|
-
* @returns The length of the control's value.
|
|
133
|
-
*/
|
|
134
|
-
controlLength(field: SchemaField, control: Control<any>): number;
|
|
135
|
-
/**
|
|
136
|
-
* Gets the length of a field's value.
|
|
137
|
-
* @param field The schema field.
|
|
138
|
-
* @param value The value to check.
|
|
139
|
-
* @returns The length of the value.
|
|
140
|
-
*/
|
|
141
|
-
valueLength(field: SchemaField, value: any): number;
|
|
142
|
-
/**
|
|
143
|
-
* Gets the data options for a schema data node.
|
|
144
|
-
* @param node The schema data node.
|
|
145
|
-
* @returns The data options.
|
|
146
|
-
*/
|
|
147
|
-
getDataOptions(node: SchemaDataNode): FieldOption[] | null | undefined;
|
|
148
|
-
/**
|
|
149
|
-
* Gets the node options for a schema node.
|
|
150
|
-
* @param node The schema node.
|
|
151
|
-
* @returns The node options.
|
|
152
|
-
*/
|
|
153
|
-
getNodeOptions(node: SchemaNode): FieldOption[] | null | undefined;
|
|
154
|
-
/**
|
|
155
|
-
* Gets the options for a schema field.
|
|
156
|
-
* @param field The schema field.
|
|
157
|
-
* @returns The field options.
|
|
158
|
-
*/
|
|
159
|
-
getOptions(field: SchemaField): FieldOption[] | undefined | null;
|
|
160
|
-
/**
|
|
161
|
-
* Gets the filter options for a schema data node and field.
|
|
162
|
-
* @param array The schema data node.
|
|
163
|
-
* @param field The schema node.
|
|
164
|
-
* @returns The filter options.
|
|
165
|
-
*/
|
|
166
|
-
getFilterOptions(array: SchemaDataNode, field: SchemaNode): FieldOption[] | undefined | null;
|
|
167
|
-
/**
|
|
168
|
-
* Parses a string value to milliseconds.
|
|
169
|
-
* @param field The schema field.
|
|
170
|
-
* @param v The string value to parse.
|
|
171
|
-
* @returns The parsed value in milliseconds.
|
|
172
|
-
*/
|
|
173
|
-
parseToMillis(field: SchemaField, v: string): number;
|
|
174
|
-
/**
|
|
175
|
-
* Gets the validation message text for a field.
|
|
176
|
-
* @param field The schema field.
|
|
177
|
-
* @param messageType The type of validation message.
|
|
178
|
-
* @param actual The actual value.
|
|
179
|
-
* @param expected The expected value.
|
|
180
|
-
* @returns The validation message text.
|
|
181
|
-
*/
|
|
182
|
-
validationMessageText(field: SchemaField, messageType: ValidationMessageType, actual: any, expected: any): string;
|
|
183
|
-
/**
|
|
184
|
-
* Compares two values of a field.
|
|
185
|
-
* @param field The schema field.
|
|
186
|
-
* @param v1 The first value.
|
|
187
|
-
* @param v2 The second value.
|
|
188
|
-
* @returns The comparison result.
|
|
189
|
-
*/
|
|
190
|
-
compareValue(field: SchemaField, v1: unknown, v2: unknown): number;
|
|
191
|
-
/**
|
|
192
|
-
* Gets the search text for a field's value.
|
|
193
|
-
* @param field The schema field.
|
|
194
|
-
* @param value The value to search.
|
|
195
|
-
* @returns The search text.
|
|
196
|
-
*/
|
|
197
|
-
searchText(field: SchemaField, value: any): string;
|
|
198
|
-
makeEqualityFunc(field: SchemaNode, element?: boolean): EqualityFunc;
|
|
199
|
-
makeControlSetup(field: SchemaNode, element?: boolean): ControlSetup<any>;
|
|
200
|
-
}
|
|
201
|
-
export interface SchemaTreeLookup {
|
|
202
|
-
getSchema(schemaId: string): SchemaNode | undefined;
|
|
203
|
-
}
|
|
204
|
-
export interface SchemaNode extends SchemaTreeLookup {
|
|
205
|
-
id: string;
|
|
206
|
-
field: SchemaField;
|
|
207
|
-
getChildNode(field: string): SchemaNode | undefined;
|
|
208
|
-
getChildNodes(noRecurse?: boolean, withParent?: SchemaNode): SchemaNode[];
|
|
209
|
-
parent?: SchemaNode;
|
|
210
|
-
}
|
|
211
|
-
export interface SchemaDataNode {
|
|
212
|
-
id: string;
|
|
213
|
-
schema: SchemaNode;
|
|
214
|
-
elementIndex?: number;
|
|
215
|
-
control: Control<any>;
|
|
216
|
-
parent?: SchemaDataNode;
|
|
217
|
-
getChild(schemaNode: SchemaNode): SchemaDataNode;
|
|
218
|
-
getChildElement(index: number): SchemaDataNode;
|
|
219
|
-
}
|
|
220
108
|
export declare function findField(fields: SchemaField[], field: string): SchemaField | undefined;
|
|
221
109
|
export declare function isScalarField(sf: SchemaField): sf is SchemaField;
|
|
222
110
|
export declare function isCompoundField(sf: SchemaField): sf is CompoundField;
|
|
223
|
-
export declare function
|
|
224
|
-
getSchema(schemaId: keyof A): SchemaNode;
|
|
225
|
-
};
|
|
226
|
-
export declare function makeSchemaDataNode(schema: SchemaNode, control: Control<unknown>, parent?: SchemaDataNode, elementIndex?: number): SchemaDataNode;
|
|
227
|
-
export declare function schemaDataForFieldRef(fieldRef: string | undefined, schema: SchemaDataNode): SchemaDataNode;
|
|
228
|
-
export declare function schemaForFieldRef(fieldRef: string | undefined, schema: SchemaNode): SchemaNode;
|
|
229
|
-
export declare function traverseSchemaPath<A>(fieldPath: string[], schema: SchemaNode, acc: A, next: (acc: A, node: SchemaNode) => A): A;
|
|
230
|
-
export declare function traverseData(fieldPath: string[], root: SchemaNode, data: {
|
|
231
|
-
[k: string]: any;
|
|
232
|
-
}): unknown;
|
|
233
|
-
export declare function schemaDataForFieldPath(fieldPath: string[], dataNode: SchemaDataNode): SchemaDataNode;
|
|
234
|
-
export declare function schemaForFieldPath(fieldPath: string[], schema: SchemaNode): SchemaNode;
|
|
235
|
-
export declare function rootSchemaNode(fields: SchemaField[], lookup?: SchemaTreeLookup): SchemaNode;
|
|
236
|
-
export declare function getSchemaNodePath(node: SchemaNode): string[];
|
|
237
|
-
export declare function isCompoundNode(node: SchemaNode): boolean;
|
|
238
|
-
/**
|
|
239
|
-
* Returns the relative path from a parent node to a child node.
|
|
240
|
-
* @param parent
|
|
241
|
-
* @param child
|
|
242
|
-
*/
|
|
243
|
-
export declare function relativePath(parent: SchemaNode, child: SchemaNode): string;
|
|
111
|
+
export declare function missingField(field: string): SchemaField;
|
|
244
112
|
export declare enum SchemaTags {
|
|
245
113
|
NoControl = "_NoControl",
|
|
246
114
|
HtmlEditor = "_HtmlEditor",
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Control, ControlSetup } from "@react-typed-forms/core";
|
|
2
|
+
import { EqualityFunc, FieldOption, SchemaField, ValidationMessageType } from "./schemaField";
|
|
3
|
+
import { SchemaDataNode } from "./schemaDataNode";
|
|
4
|
+
import { SchemaNode } from "./schemaNode";
|
|
5
|
+
/**
|
|
6
|
+
* Interface for schema-related operations.
|
|
7
|
+
*/
|
|
8
|
+
export interface SchemaInterface {
|
|
9
|
+
/**
|
|
10
|
+
* Checks if the value of a field is empty.
|
|
11
|
+
* @param field The schema field.
|
|
12
|
+
* @param value The value to check.
|
|
13
|
+
* @returns True if the value is empty, false otherwise.
|
|
14
|
+
*/
|
|
15
|
+
isEmptyValue(field: SchemaField, value: any): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Gets the text representation of a field's value.
|
|
18
|
+
* @param field The schema field.
|
|
19
|
+
* @param value The value to convert.
|
|
20
|
+
* @param element Indicates if the value is an element, optional.
|
|
21
|
+
* @param options The field options, optional.
|
|
22
|
+
* @returns The text representation of the value.
|
|
23
|
+
*/
|
|
24
|
+
textValue(field: SchemaField, value: any, element?: boolean, options?: FieldOption[]): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Gets the text representation of a field's value for a data node.
|
|
27
|
+
* @param dataNode
|
|
28
|
+
*/
|
|
29
|
+
textValueForData(dataNode: SchemaDataNode): string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Gets the length of a control's value.
|
|
32
|
+
* @param field The schema field.
|
|
33
|
+
* @param control The control to check.
|
|
34
|
+
* @returns The length of the control's value.
|
|
35
|
+
*/
|
|
36
|
+
controlLength(field: SchemaField, control: Control<any>): number;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the length of a field's value.
|
|
39
|
+
* @param field The schema field.
|
|
40
|
+
* @param value The value to check.
|
|
41
|
+
* @returns The length of the value.
|
|
42
|
+
*/
|
|
43
|
+
valueLength(field: SchemaField, value: any): number;
|
|
44
|
+
/**
|
|
45
|
+
* Gets the data options for a schema data node.
|
|
46
|
+
* @param node The schema data node.
|
|
47
|
+
* @returns The data options.
|
|
48
|
+
*/
|
|
49
|
+
getDataOptions(node: SchemaDataNode): FieldOption[] | null | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Gets the node options for a schema node.
|
|
52
|
+
* @param node The schema node.
|
|
53
|
+
* @returns The node options.
|
|
54
|
+
*/
|
|
55
|
+
getNodeOptions(node: SchemaNode): FieldOption[] | null | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Gets the options for a schema field.
|
|
58
|
+
* @param field The schema field.
|
|
59
|
+
* @returns The field options.
|
|
60
|
+
*/
|
|
61
|
+
getOptions(field: SchemaField): FieldOption[] | undefined | null;
|
|
62
|
+
/**
|
|
63
|
+
* Gets the filter options for a schema data node and field.
|
|
64
|
+
* @param array The schema data node.
|
|
65
|
+
* @param field The schema node.
|
|
66
|
+
* @returns The filter options.
|
|
67
|
+
*/
|
|
68
|
+
getFilterOptions(array: SchemaDataNode, field: SchemaNode): FieldOption[] | undefined | null;
|
|
69
|
+
/**
|
|
70
|
+
* Parses a string value to milliseconds.
|
|
71
|
+
* @param field The schema field.
|
|
72
|
+
* @param v The string value to parse.
|
|
73
|
+
* @returns The parsed value in milliseconds.
|
|
74
|
+
*/
|
|
75
|
+
parseToMillis(field: SchemaField, v: string): number;
|
|
76
|
+
/**
|
|
77
|
+
* Gets the validation message text for a field.
|
|
78
|
+
* @param field The schema field.
|
|
79
|
+
* @param messageType The type of validation message.
|
|
80
|
+
* @param actual The actual value.
|
|
81
|
+
* @param expected The expected value.
|
|
82
|
+
* @returns The validation message text.
|
|
83
|
+
*/
|
|
84
|
+
validationMessageText(field: SchemaField, messageType: ValidationMessageType, actual: any, expected: any): string;
|
|
85
|
+
/**
|
|
86
|
+
* Compares two values of a field.
|
|
87
|
+
* @param field The schema field.
|
|
88
|
+
* @param v1 The first value.
|
|
89
|
+
* @param v2 The second value.
|
|
90
|
+
* @returns The comparison result.
|
|
91
|
+
*/
|
|
92
|
+
compareValue(field: SchemaField, v1: unknown, v2: unknown): number;
|
|
93
|
+
/**
|
|
94
|
+
* Gets the search text for a field's value.
|
|
95
|
+
* @param field The schema field.
|
|
96
|
+
* @param value The value to search.
|
|
97
|
+
* @returns The search text.
|
|
98
|
+
*/
|
|
99
|
+
searchText(field: SchemaField, value: any): string;
|
|
100
|
+
makeEqualityFunc(field: SchemaNode, element?: boolean): EqualityFunc;
|
|
101
|
+
makeControlSetup(field: SchemaNode, element?: boolean): ControlSetup<any>;
|
|
102
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { SchemaField } from "./schemaField";
|
|
2
|
+
export interface SchemaTreeLookup {
|
|
3
|
+
getSchema(schemaId: string): SchemaNode | undefined;
|
|
4
|
+
getSchemaTree(schemaId: string): SchemaTree | undefined;
|
|
5
|
+
}
|
|
6
|
+
export declare abstract class SchemaTree {
|
|
7
|
+
abstract rootNode: SchemaNode;
|
|
8
|
+
abstract getSchemaTree(schemaId: string): SchemaTree | undefined;
|
|
9
|
+
createChildNode(parent: SchemaNode, field: SchemaField): SchemaNode;
|
|
10
|
+
getSchema(schemaId: string): SchemaNode | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare function createSchemaTree(rootFields: SchemaField[], lookup?: SchemaTreeLookup): SchemaTree;
|
|
13
|
+
export declare class SchemaNode {
|
|
14
|
+
id: string;
|
|
15
|
+
field: SchemaField;
|
|
16
|
+
tree: SchemaTree;
|
|
17
|
+
parent?: SchemaNode | undefined;
|
|
18
|
+
constructor(id: string, field: SchemaField, tree: SchemaTree, parent?: SchemaNode | undefined);
|
|
19
|
+
getSchema(schemaId: string): SchemaNode | undefined;
|
|
20
|
+
getUnresolvedFields(): SchemaField[];
|
|
21
|
+
getResolvedParent(): SchemaNode | undefined;
|
|
22
|
+
getResolvedFields(): SchemaField[];
|
|
23
|
+
getChildNodes(): SchemaNode[];
|
|
24
|
+
getChildField(field: string): SchemaField;
|
|
25
|
+
createChildNode(field: SchemaField): SchemaNode;
|
|
26
|
+
getChildNode(field: string): SchemaNode;
|
|
27
|
+
}
|
|
28
|
+
export declare function resolveSchemaNode(node: SchemaNode, fieldSegment: string): SchemaNode | undefined;
|
|
29
|
+
export declare function createSchemaNode(field: SchemaField, lookup: SchemaTree, parent: SchemaNode | undefined): SchemaNode;
|
|
30
|
+
export declare function createSchemaLookup<A extends Record<string, SchemaField[]>>(schemaMap: A): {
|
|
31
|
+
getSchema(schemaId: keyof A): SchemaNode;
|
|
32
|
+
getSchemaTree(schemaId: keyof A): SchemaTree;
|
|
33
|
+
};
|
|
34
|
+
export declare function schemaForFieldRef(fieldRef: string | undefined, schema: SchemaNode): SchemaNode;
|
|
35
|
+
export declare function traverseSchemaPath<A>(fieldPath: string[], schema: SchemaNode, acc: A, next: (acc: A, node: SchemaNode) => A): A;
|
|
36
|
+
export declare function traverseData(fieldPath: string[], root: SchemaNode, data: {
|
|
37
|
+
[k: string]: any;
|
|
38
|
+
}): unknown;
|
|
39
|
+
export declare function schemaForFieldPath(fieldPath: string[], schema: SchemaNode): SchemaNode;
|
|
40
|
+
export declare function getSchemaNodePath(node: SchemaNode): string[];
|
|
41
|
+
export declare function getSchemaNodePathString(node: SchemaNode): string;
|
|
42
|
+
export declare function isCompoundNode(node: SchemaNode): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Returns the relative path from a parent node to a child node.
|
|
45
|
+
* @param parent
|
|
46
|
+
* @param child
|
|
47
|
+
*/
|
|
48
|
+
export declare function relativePath(parent: SchemaNode, child: SchemaNode): string;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the relative path from a parent node to a child node.
|
|
51
|
+
* @param parentPath
|
|
52
|
+
* @param childPath
|
|
53
|
+
*/
|
|
54
|
+
export declare function relativeSegmentPath(parentPath: string[], childPath: string[]): string;
|
package/lib/util.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { ControlActionHandler,
|
|
1
|
+
import { ControlActionHandler, ControlDefinition, DataControlDefinition, DisplayOnlyRenderOptions, GroupRenderOptions } from "./controlDefinition";
|
|
2
2
|
import { MutableRefObject } from "react";
|
|
3
|
-
import { CompoundField, FieldOption,
|
|
3
|
+
import { CompoundField, FieldOption, SchemaField } from "./schemaField";
|
|
4
4
|
import { Control } from "@react-typed-forms/core";
|
|
5
5
|
import { ActionRendererProps } from "./controlRender";
|
|
6
|
+
import { ControlDataVisitor } from "./formNode";
|
|
7
|
+
import { SchemaDataNode } from "./schemaDataNode";
|
|
8
|
+
import { SchemaNode } from "./schemaNode";
|
|
6
9
|
/**
|
|
7
10
|
* Interface representing the classes for a control.
|
|
8
11
|
*/
|
|
@@ -10,6 +13,8 @@ export interface ControlClasses {
|
|
|
10
13
|
styleClass?: string;
|
|
11
14
|
layoutClass?: string;
|
|
12
15
|
labelClass?: string;
|
|
16
|
+
textClass?: string;
|
|
17
|
+
labelTextClass?: string;
|
|
13
18
|
}
|
|
14
19
|
/**
|
|
15
20
|
* Type representing a JSON path, which can be a string or a number.
|
|
@@ -117,13 +122,6 @@ export declare function addMissingControls(fields: SchemaField[], controls: Cont
|
|
|
117
122
|
* @returns The control definitions with missing controls added.
|
|
118
123
|
*/
|
|
119
124
|
export declare function addMissingControlsForSchema(schema: SchemaNode, controls: ControlDefinition[], warning?: (msg: string) => void): ControlDefinition[];
|
|
120
|
-
/**
|
|
121
|
-
* Adds missing controls to the provided form tree based on the schema fields.
|
|
122
|
-
* @param schema - The root schema node to use for adding missing controls.
|
|
123
|
-
* @param tree - The form tree to add missing controls to.
|
|
124
|
-
* @param warning - An optional function to call with warning messages.
|
|
125
|
-
*/
|
|
126
|
-
export declare function addMissingControlsToForm(schema: SchemaNode, tree: FormTree, warning?: (msg: string) => void): void;
|
|
127
125
|
/**
|
|
128
126
|
* Custom hook to use an updated reference.
|
|
129
127
|
* @param a - The value to create a reference for.
|
|
@@ -151,13 +149,13 @@ export declare function getDisplayOnlyOptions(d: ControlDefinition): DisplayOnly
|
|
|
151
149
|
/**
|
|
152
150
|
* Cleans data for a schema based on the provided schema fields.
|
|
153
151
|
* @param v - The data to clean.
|
|
154
|
-
* @param
|
|
152
|
+
* @param schemaNode
|
|
155
153
|
* @param removeIfDefault - Flag indicating if default values should be removed.
|
|
156
154
|
* @returns The cleaned data.
|
|
157
155
|
*/
|
|
158
156
|
export declare function cleanDataForSchema(v: {
|
|
159
157
|
[k: string]: any;
|
|
160
|
-
} | undefined,
|
|
158
|
+
} | undefined, schemaNode: SchemaNode, removeIfDefault?: boolean): any;
|
|
161
159
|
/**
|
|
162
160
|
* Returns all referenced classes for a control definition.
|
|
163
161
|
* @param c - The control definition to get the referenced classes for.
|
|
@@ -224,6 +222,7 @@ export declare function findFieldPath(fields: SchemaField[], fieldPath: string |
|
|
|
224
222
|
* @returns {A} - The merged object.
|
|
225
223
|
*/
|
|
226
224
|
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;
|
|
225
|
+
export declare function deepMerge<A>(value: A, fallback: A): A;
|
|
227
226
|
/**
|
|
228
227
|
* Coerces a value to a string.
|
|
229
228
|
* @param {unknown} v - The value to coerce.
|
package/package.json
CHANGED
package/src/controlBuilder.ts
CHANGED
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
LengthValidator,
|
|
33
33
|
ValidatorType,
|
|
34
34
|
} from "./schemaValidator";
|
|
35
|
-
import { SchemaField, SchemaMap
|
|
35
|
+
import { SchemaField, SchemaMap } from "./schemaField";
|
|
36
36
|
import {
|
|
37
37
|
DataExpression,
|
|
38
38
|
DataMatchExpression,
|
|
@@ -40,6 +40,7 @@ import {
|
|
|
40
40
|
ExpressionType,
|
|
41
41
|
JsonataExpression,
|
|
42
42
|
} from "./entityExpression";
|
|
43
|
+
import { SchemaNode } from "./schemaNode";
|
|
43
44
|
|
|
44
45
|
export function dataControl(
|
|
45
46
|
field: string,
|
|
@@ -203,7 +204,12 @@ export function createAction(
|
|
|
203
204
|
actionText?: string,
|
|
204
205
|
options?: Partial<ActionRendererProps>,
|
|
205
206
|
): ActionRendererProps {
|
|
206
|
-
return {
|
|
207
|
+
return {
|
|
208
|
+
actionId,
|
|
209
|
+
onClick,
|
|
210
|
+
actionText: actionText ?? actionId,
|
|
211
|
+
...options,
|
|
212
|
+
};
|
|
207
213
|
}
|
|
208
214
|
|
|
209
215
|
export const emptyGroupDefinition: GroupedControlsDefinition = {
|