@react-typed-forms/schemas 15.2.0 → 16.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/RenderForm.d.ts +39 -0
- package/lib/controlBuilder.d.ts +3 -6
- package/lib/controlRender.d.ts +107 -87
- package/lib/index.cjs +535 -2117
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +3 -9
- package/lib/index.js +402 -1639
- package/lib/index.js.map +1 -1
- package/lib/renderers.d.ts +3 -3
- package/lib/types.d.ts +31 -0
- package/lib/util.d.ts +8 -54
- package/package.json +5 -4
- package/src/RenderForm.tsx +301 -0
- package/src/controlBuilder.ts +22 -19
- package/src/controlRender.tsx +228 -507
- package/src/createFormRenderer.tsx +4 -5
- package/src/index.ts +3 -9
- package/src/renderers.tsx +2 -3
- package/src/types.ts +52 -0
- package/src/util.ts +149 -183
- package/lib/controlDefinition.d.ts +0 -398
- package/lib/defaultSchemaInterface.d.ts +0 -24
- package/lib/dynamicHooks.d.ts +0 -54
- package/lib/entityExpression.d.ts +0 -32
- package/lib/hooks.d.ts +0 -28
- package/lib/schemaBuilder.d.ts +0 -67
- package/lib/schemaField.d.ts +0 -252
- package/lib/schemaValidator.d.ts +0 -27
- package/lib/validators.d.ts +0 -19
- package/src/controlDefinition.ts +0 -821
- package/src/defaultSchemaInterface.ts +0 -191
- package/src/dynamicHooks.ts +0 -98
- package/src/entityExpression.ts +0 -38
- package/src/hooks.tsx +0 -469
- package/src/schemaBuilder.ts +0 -318
- package/src/schemaField.ts +0 -552
- package/src/schemaValidator.ts +0 -32
- package/src/validators.ts +0 -217
package/lib/schemaField.d.ts
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import { SchemaValidator } from "./schemaValidator";
|
|
2
|
-
import { Control, ControlSetup } from "@react-typed-forms/core";
|
|
3
|
-
export type EqualityFunc = (a: any, b: any) => boolean;
|
|
4
|
-
/**
|
|
5
|
-
* Represents a schema field with various properties.
|
|
6
|
-
*/
|
|
7
|
-
export interface SchemaField {
|
|
8
|
-
/** The type of the field. */
|
|
9
|
-
type: string;
|
|
10
|
-
/** The name of the field. */
|
|
11
|
-
field: string;
|
|
12
|
-
/** The display name of the field, optional. */
|
|
13
|
-
displayName?: string | null;
|
|
14
|
-
/** Tags associated with the field, optional. */
|
|
15
|
-
tags?: string[] | null;
|
|
16
|
-
/** Indicates if the field is a system field, optional. */
|
|
17
|
-
system?: boolean | null;
|
|
18
|
-
/** Indicates if the field is a collection, optional. */
|
|
19
|
-
collection?: boolean | null;
|
|
20
|
-
/** Specifies the types for which the field is applicable, optional. */
|
|
21
|
-
onlyForTypes?: string[] | null;
|
|
22
|
-
/** Indicates if the field is required, optional. */
|
|
23
|
-
required?: boolean | null;
|
|
24
|
-
/** Indicates if the field is not nullable, optional. */
|
|
25
|
-
notNullable?: boolean | null;
|
|
26
|
-
/** The default value of the field, optional. */
|
|
27
|
-
defaultValue?: any;
|
|
28
|
-
/** Indicates if the field is a type field, optional. */
|
|
29
|
-
isTypeField?: boolean | null;
|
|
30
|
-
/** Indicates if the field is searchable, optional. */
|
|
31
|
-
searchable?: boolean | null;
|
|
32
|
-
/** Options for the field, optional. */
|
|
33
|
-
options?: FieldOption[] | null;
|
|
34
|
-
/** Validators for the field, optional. */
|
|
35
|
-
validators?: SchemaValidator[] | null;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Represents a map of schema fields.
|
|
39
|
-
* The key is a string representing the schema name.
|
|
40
|
-
* The value is an array of SchemaField objects.
|
|
41
|
-
*/
|
|
42
|
-
export type SchemaMap = Record<string, SchemaField[]>;
|
|
43
|
-
/**
|
|
44
|
-
* Enum representing the various field types.
|
|
45
|
-
*/
|
|
46
|
-
export declare enum FieldType {
|
|
47
|
-
String = "String",
|
|
48
|
-
Bool = "Bool",
|
|
49
|
-
Int = "Int",
|
|
50
|
-
Date = "Date",
|
|
51
|
-
DateTime = "DateTime",
|
|
52
|
-
Time = "Time",
|
|
53
|
-
Double = "Double",
|
|
54
|
-
EntityRef = "EntityRef",
|
|
55
|
-
Compound = "Compound",
|
|
56
|
-
AutoId = "AutoId",
|
|
57
|
-
Image = "Image",
|
|
58
|
-
Any = "Any"
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Represents a field that references an entity.
|
|
62
|
-
*/
|
|
63
|
-
export interface EntityRefField extends SchemaField {
|
|
64
|
-
/** The type of the field, which is EntityRef. */
|
|
65
|
-
type: FieldType.EntityRef;
|
|
66
|
-
/** The type of the referenced entity. */
|
|
67
|
-
entityRefType: string;
|
|
68
|
-
/** The parent field of the entity reference. */
|
|
69
|
-
parentField: string;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Represents an option for a field.
|
|
73
|
-
*/
|
|
74
|
-
export interface FieldOption {
|
|
75
|
-
/** The name of the option. */
|
|
76
|
-
name: string;
|
|
77
|
-
/** The value of the option. */
|
|
78
|
-
value: any;
|
|
79
|
-
/** The description of the option, optional. */
|
|
80
|
-
description?: string | null;
|
|
81
|
-
/** The group of the option, optional. */
|
|
82
|
-
group?: string | null;
|
|
83
|
-
/** Indicates if the option is disabled, optional. */
|
|
84
|
-
disabled?: boolean | null;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Represents a compound field that contains child fields.
|
|
88
|
-
*/
|
|
89
|
-
export interface CompoundField extends SchemaField {
|
|
90
|
-
/** The type of the field, which is Compound. */
|
|
91
|
-
type: FieldType.Compound;
|
|
92
|
-
/** The child fields of the compound field. */
|
|
93
|
-
children: SchemaField[];
|
|
94
|
-
/** Indicates if the children are tree-structured, optional. */
|
|
95
|
-
treeChildren?: boolean;
|
|
96
|
-
/** The schema reference for the compound field, optional. */
|
|
97
|
-
schemaRef?: string;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Enum representing the various validation message types.
|
|
101
|
-
*/
|
|
102
|
-
export declare enum ValidationMessageType {
|
|
103
|
-
NotEmpty = "NotEmpty",
|
|
104
|
-
MinLength = "MinLength",
|
|
105
|
-
MaxLength = "MaxLength",
|
|
106
|
-
NotAfterDate = "NotAfterDate",
|
|
107
|
-
NotBeforeDate = "NotBeforeDate"
|
|
108
|
-
}
|
|
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
|
-
export declare function findField(fields: SchemaField[], field: string): SchemaField | undefined;
|
|
221
|
-
export declare function isScalarField(sf: SchemaField): sf is SchemaField;
|
|
222
|
-
export declare function isCompoundField(sf: SchemaField): sf is CompoundField;
|
|
223
|
-
export declare function createSchemaLookup<A extends Record<string, SchemaField[]>>(schemaMap: A): {
|
|
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;
|
|
244
|
-
export declare enum SchemaTags {
|
|
245
|
-
NoControl = "_NoControl",
|
|
246
|
-
HtmlEditor = "_HtmlEditor",
|
|
247
|
-
ControlGroup = "_ControlGroup:",
|
|
248
|
-
ControlRef = "_ControlRef:",
|
|
249
|
-
IdField = "_IdField:"
|
|
250
|
-
}
|
|
251
|
-
export declare function getTagParam(field: SchemaField, tag: string): string | undefined;
|
|
252
|
-
export declare function makeParamTag(tag: string, value: string): string;
|
package/lib/schemaValidator.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export declare enum ValidatorType {
|
|
2
|
-
Jsonata = "Jsonata",
|
|
3
|
-
Date = "Date",
|
|
4
|
-
Length = "Length"
|
|
5
|
-
}
|
|
6
|
-
export interface SchemaValidator {
|
|
7
|
-
type: string;
|
|
8
|
-
}
|
|
9
|
-
export interface JsonataValidator extends SchemaValidator {
|
|
10
|
-
type: ValidatorType.Jsonata;
|
|
11
|
-
expression: string;
|
|
12
|
-
}
|
|
13
|
-
export interface LengthValidator extends SchemaValidator {
|
|
14
|
-
type: ValidatorType.Length;
|
|
15
|
-
min?: number | null;
|
|
16
|
-
max?: number | null;
|
|
17
|
-
}
|
|
18
|
-
export declare enum DateComparison {
|
|
19
|
-
NotBefore = "NotBefore",
|
|
20
|
-
NotAfter = "NotAfter"
|
|
21
|
-
}
|
|
22
|
-
export interface DateValidator extends SchemaValidator {
|
|
23
|
-
type: ValidatorType.Date;
|
|
24
|
-
comparison: DateComparison;
|
|
25
|
-
fixedDate?: string | null;
|
|
26
|
-
daysFromCurrent?: number | null;
|
|
27
|
-
}
|
package/lib/validators.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ControlDefinition, DataControlDefinition, ControlDataContext } from "./controlDefinition";
|
|
2
|
-
import { Control } from "@react-typed-forms/core";
|
|
3
|
-
import { DateValidator, JsonataValidator, LengthValidator, SchemaValidator } from "./schemaValidator";
|
|
4
|
-
import { SchemaField } from "./schemaField";
|
|
5
|
-
interface ValidationHookContext {
|
|
6
|
-
hiddenControl: Control<boolean | null | undefined>;
|
|
7
|
-
dataContext: ControlDataContext;
|
|
8
|
-
control: Control<any>;
|
|
9
|
-
}
|
|
10
|
-
export interface ValidationContext extends ValidationHookContext {
|
|
11
|
-
definition: DataControlDefinition;
|
|
12
|
-
field: SchemaField;
|
|
13
|
-
index: number;
|
|
14
|
-
}
|
|
15
|
-
export declare function useMakeValidationHook(definition: ControlDefinition, useValidatorFor?: (validator: SchemaValidator, ctx: ValidationContext) => void): (ctx: ValidationHookContext) => void;
|
|
16
|
-
export declare function useJsonataValidator(validator: JsonataValidator, ctx: ValidationContext): void;
|
|
17
|
-
export declare function useLengthValidator(lv: LengthValidator, ctx: ValidationContext): void;
|
|
18
|
-
export declare function useDateValidator(dv: DateValidator, ctx: ValidationContext): void;
|
|
19
|
-
export {};
|