@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
|
@@ -1,398 +0,0 @@
|
|
|
1
|
-
import { SchemaValidator } from "./schemaValidator";
|
|
2
|
-
import { FieldOption, SchemaDataNode, SchemaField, SchemaInterface, SchemaNode } from "./schemaField";
|
|
3
|
-
import { EntityExpression } from "./entityExpression";
|
|
4
|
-
/**
|
|
5
|
-
* Interface representing the form context data.
|
|
6
|
-
*/
|
|
7
|
-
export interface FormContextData {
|
|
8
|
-
option?: FieldOption;
|
|
9
|
-
optionSelected?: boolean;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Interface representing the control data context.
|
|
13
|
-
*/
|
|
14
|
-
export interface ControlDataContext {
|
|
15
|
-
schemaInterface: SchemaInterface;
|
|
16
|
-
dataNode: SchemaDataNode | undefined;
|
|
17
|
-
parentNode: SchemaDataNode;
|
|
18
|
-
formData: FormContextData;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Represents any control definition.
|
|
22
|
-
*/
|
|
23
|
-
export type AnyControlDefinition = DataControlDefinition | GroupedControlsDefinition | ActionControlDefinition | DisplayControlDefinition;
|
|
24
|
-
/**
|
|
25
|
-
* Represents a control definition.
|
|
26
|
-
*/
|
|
27
|
-
export interface ControlDefinition {
|
|
28
|
-
type: string;
|
|
29
|
-
id?: string | null;
|
|
30
|
-
childRefId?: string | null;
|
|
31
|
-
title?: string | null;
|
|
32
|
-
styleClass?: string | null;
|
|
33
|
-
layoutClass?: string | null;
|
|
34
|
-
labelClass?: string | null;
|
|
35
|
-
dynamic?: DynamicProperty[] | null;
|
|
36
|
-
adornments?: ControlAdornment[] | null;
|
|
37
|
-
children?: ControlDefinition[] | null;
|
|
38
|
-
}
|
|
39
|
-
export declare enum ControlDefinitionType {
|
|
40
|
-
Data = "Data",
|
|
41
|
-
Group = "Group",
|
|
42
|
-
Display = "Display",
|
|
43
|
-
Action = "Action"
|
|
44
|
-
}
|
|
45
|
-
export interface DynamicProperty {
|
|
46
|
-
type: string;
|
|
47
|
-
expr: EntityExpression;
|
|
48
|
-
}
|
|
49
|
-
export declare enum DynamicPropertyType {
|
|
50
|
-
Visible = "Visible",
|
|
51
|
-
DefaultValue = "DefaultValue",
|
|
52
|
-
Readonly = "Readonly",
|
|
53
|
-
Disabled = "Disabled",
|
|
54
|
-
Display = "Display",
|
|
55
|
-
Style = "Style",
|
|
56
|
-
LayoutStyle = "LayoutStyle",
|
|
57
|
-
AllowedOptions = "AllowedOptions",
|
|
58
|
-
Label = "Label",
|
|
59
|
-
ActionData = "ActionData"
|
|
60
|
-
}
|
|
61
|
-
export interface ControlAdornment {
|
|
62
|
-
type: string;
|
|
63
|
-
}
|
|
64
|
-
export declare enum AdornmentPlacement {
|
|
65
|
-
ControlStart = "ControlStart",
|
|
66
|
-
ControlEnd = "ControlEnd",
|
|
67
|
-
LabelStart = "LabelStart",
|
|
68
|
-
LabelEnd = "LabelEnd"
|
|
69
|
-
}
|
|
70
|
-
export declare enum ControlAdornmentType {
|
|
71
|
-
Tooltip = "Tooltip",
|
|
72
|
-
Accordion = "Accordion",
|
|
73
|
-
HelpText = "HelpText",
|
|
74
|
-
Icon = "Icon",
|
|
75
|
-
SetField = "SetField",
|
|
76
|
-
Optional = "Optional"
|
|
77
|
-
}
|
|
78
|
-
export interface IconAdornment extends ControlAdornment {
|
|
79
|
-
type: ControlAdornmentType.Icon;
|
|
80
|
-
iconClass: string;
|
|
81
|
-
placement?: AdornmentPlacement | null;
|
|
82
|
-
}
|
|
83
|
-
export interface TooltipAdornment extends ControlAdornment {
|
|
84
|
-
type: ControlAdornmentType.Tooltip;
|
|
85
|
-
tooltip: string;
|
|
86
|
-
}
|
|
87
|
-
export interface AccordionAdornment extends ControlAdornment {
|
|
88
|
-
type: ControlAdornmentType.Accordion;
|
|
89
|
-
title: string;
|
|
90
|
-
defaultExpanded?: boolean | null;
|
|
91
|
-
}
|
|
92
|
-
export interface HelpTextAdornment extends ControlAdornment {
|
|
93
|
-
type: ControlAdornmentType.HelpText;
|
|
94
|
-
helpText: string;
|
|
95
|
-
placement?: AdornmentPlacement | null;
|
|
96
|
-
}
|
|
97
|
-
export interface SetFieldAdornment extends ControlAdornment {
|
|
98
|
-
type: ControlAdornmentType.SetField;
|
|
99
|
-
field: string;
|
|
100
|
-
defaultOnly?: boolean | null;
|
|
101
|
-
expression?: EntityExpression;
|
|
102
|
-
}
|
|
103
|
-
export interface OptionalAdornment extends ControlAdornment {
|
|
104
|
-
type: ControlAdornmentType.Optional;
|
|
105
|
-
placement?: AdornmentPlacement | null;
|
|
106
|
-
allowNull?: boolean;
|
|
107
|
-
editSelectable?: boolean;
|
|
108
|
-
}
|
|
109
|
-
export interface DataControlDefinition extends ControlDefinition {
|
|
110
|
-
type: ControlDefinitionType.Data;
|
|
111
|
-
field: string;
|
|
112
|
-
required?: boolean | null;
|
|
113
|
-
renderOptions?: RenderOptions | null;
|
|
114
|
-
defaultValue?: any;
|
|
115
|
-
readonly?: boolean | null;
|
|
116
|
-
disabled?: boolean | null;
|
|
117
|
-
validators?: SchemaValidator[] | null;
|
|
118
|
-
hideTitle?: boolean | null;
|
|
119
|
-
dontClearHidden?: boolean | null;
|
|
120
|
-
}
|
|
121
|
-
export interface RenderOptions {
|
|
122
|
-
type: string;
|
|
123
|
-
}
|
|
124
|
-
export declare enum DataRenderType {
|
|
125
|
-
Standard = "Standard",
|
|
126
|
-
Textfield = "Textfield",
|
|
127
|
-
Radio = "Radio",
|
|
128
|
-
HtmlEditor = "HtmlEditor",
|
|
129
|
-
IconList = "IconList",
|
|
130
|
-
CheckList = "CheckList",
|
|
131
|
-
UserSelection = "UserSelection",
|
|
132
|
-
Synchronised = "Synchronised",
|
|
133
|
-
IconSelector = "IconSelector",
|
|
134
|
-
DateTime = "DateTime",
|
|
135
|
-
Checkbox = "Checkbox",
|
|
136
|
-
Dropdown = "Dropdown",
|
|
137
|
-
DisplayOnly = "DisplayOnly",
|
|
138
|
-
Group = "Group",
|
|
139
|
-
NullToggle = "NullToggle",
|
|
140
|
-
Autocomplete = "Autocomplete",
|
|
141
|
-
Jsonata = "Jsonata",
|
|
142
|
-
Array = "Array",
|
|
143
|
-
ArrayElement = "ArrayElement"
|
|
144
|
-
}
|
|
145
|
-
export interface TextfieldRenderOptions extends RenderOptions {
|
|
146
|
-
type: DataRenderType.Textfield;
|
|
147
|
-
placeholder?: string | null;
|
|
148
|
-
multiline?: boolean | null;
|
|
149
|
-
}
|
|
150
|
-
export interface AutocompleteRenderOptions extends RenderOptions, AutocompleteClasses {
|
|
151
|
-
type: DataRenderType.Autocomplete;
|
|
152
|
-
}
|
|
153
|
-
export interface AutocompleteClasses {
|
|
154
|
-
listContainerClass?: string | null;
|
|
155
|
-
listEntryClass?: string | null;
|
|
156
|
-
chipContainerClass?: string | null;
|
|
157
|
-
chipCloseButtonClass?: string | null;
|
|
158
|
-
placeholder?: string | null;
|
|
159
|
-
}
|
|
160
|
-
export interface CheckEntryClasses {
|
|
161
|
-
entryWrapperClass?: string | null;
|
|
162
|
-
selectedClass?: string | null;
|
|
163
|
-
notSelectedClass?: string | null;
|
|
164
|
-
}
|
|
165
|
-
export interface RadioButtonRenderOptions extends RenderOptions, CheckEntryClasses {
|
|
166
|
-
type: DataRenderType.Radio;
|
|
167
|
-
}
|
|
168
|
-
export interface StandardRenderer extends RenderOptions {
|
|
169
|
-
type: DataRenderType.Standard;
|
|
170
|
-
}
|
|
171
|
-
export interface DataGroupRenderOptions extends RenderOptions {
|
|
172
|
-
type: DataRenderType.Group;
|
|
173
|
-
groupOptions?: GroupRenderOptions;
|
|
174
|
-
}
|
|
175
|
-
export interface HtmlEditorRenderOptions extends RenderOptions {
|
|
176
|
-
type: DataRenderType.HtmlEditor;
|
|
177
|
-
allowImages: boolean;
|
|
178
|
-
}
|
|
179
|
-
export interface DateTimeRenderOptions extends RenderOptions {
|
|
180
|
-
type: DataRenderType.DateTime;
|
|
181
|
-
format?: string | null;
|
|
182
|
-
forceMidnight?: boolean;
|
|
183
|
-
forceStandard?: boolean;
|
|
184
|
-
}
|
|
185
|
-
export interface IconListRenderOptions extends RenderOptions {
|
|
186
|
-
type: DataRenderType.IconList;
|
|
187
|
-
iconMappings: IconMapping[];
|
|
188
|
-
}
|
|
189
|
-
export interface DisplayOnlyRenderOptions extends RenderOptions {
|
|
190
|
-
type: DataRenderType.DisplayOnly;
|
|
191
|
-
emptyText?: string | null;
|
|
192
|
-
sampleText?: string | null;
|
|
193
|
-
}
|
|
194
|
-
export interface IconMapping {
|
|
195
|
-
value: string;
|
|
196
|
-
materialIcon?: string | null;
|
|
197
|
-
}
|
|
198
|
-
export interface JsonataRenderOptions extends RenderOptions {
|
|
199
|
-
type: DataRenderType.Jsonata;
|
|
200
|
-
expression: string;
|
|
201
|
-
}
|
|
202
|
-
export interface JsonataRenderOptions extends RenderOptions {
|
|
203
|
-
type: DataRenderType.Jsonata;
|
|
204
|
-
expression: string;
|
|
205
|
-
}
|
|
206
|
-
export interface ArrayRenderOptions extends RenderOptions {
|
|
207
|
-
type: DataRenderType.Array;
|
|
208
|
-
addText?: string | null;
|
|
209
|
-
addActionId?: string | null;
|
|
210
|
-
removeText?: string | null;
|
|
211
|
-
removeActionId?: string | null;
|
|
212
|
-
editText?: string | null;
|
|
213
|
-
editActionId?: string | null;
|
|
214
|
-
noAdd?: boolean | null;
|
|
215
|
-
noRemove?: boolean | null;
|
|
216
|
-
noReorder?: boolean | null;
|
|
217
|
-
childOptions?: RenderOptions | null;
|
|
218
|
-
editExternal?: boolean | null;
|
|
219
|
-
}
|
|
220
|
-
export interface ArrayElementRenderOptions extends RenderOptions {
|
|
221
|
-
type: DataRenderType.ArrayElement;
|
|
222
|
-
showInline?: boolean | null;
|
|
223
|
-
}
|
|
224
|
-
export type ArrayActionOptions = Pick<ArrayRenderOptions, "addText" | "addActionId" | "removeText" | "removeActionId" | "noAdd" | "noRemove" | "noReorder" | "editExternal" | "editActionId" | "editText"> & {
|
|
225
|
-
readonly?: boolean;
|
|
226
|
-
disabled?: boolean;
|
|
227
|
-
designMode?: boolean;
|
|
228
|
-
};
|
|
229
|
-
export interface CheckListRenderOptions extends RenderOptions, CheckEntryClasses {
|
|
230
|
-
type: DataRenderType.CheckList;
|
|
231
|
-
}
|
|
232
|
-
export interface SynchronisedRenderOptions extends RenderOptions {
|
|
233
|
-
type: DataRenderType.Synchronised;
|
|
234
|
-
fieldToSync: string;
|
|
235
|
-
syncType: SyncTextType;
|
|
236
|
-
}
|
|
237
|
-
export declare enum SyncTextType {
|
|
238
|
-
Camel = "Camel",
|
|
239
|
-
Snake = "Snake",
|
|
240
|
-
Pascal = "Pascal"
|
|
241
|
-
}
|
|
242
|
-
export interface UserSelectionRenderOptions extends RenderOptions {
|
|
243
|
-
type: DataRenderType.UserSelection;
|
|
244
|
-
noGroups: boolean;
|
|
245
|
-
noUsers: boolean;
|
|
246
|
-
}
|
|
247
|
-
export interface IconSelectionRenderOptions extends RenderOptions {
|
|
248
|
-
type: DataRenderType.IconSelector;
|
|
249
|
-
}
|
|
250
|
-
export interface GroupedControlsDefinition extends ControlDefinition {
|
|
251
|
-
type: ControlDefinitionType.Group;
|
|
252
|
-
compoundField?: string | null;
|
|
253
|
-
groupOptions?: GroupRenderOptions;
|
|
254
|
-
}
|
|
255
|
-
export interface GroupRenderOptions {
|
|
256
|
-
type: string;
|
|
257
|
-
hideTitle?: boolean | null;
|
|
258
|
-
childStyleClass?: string | null;
|
|
259
|
-
childLayoutClass?: string | null;
|
|
260
|
-
childLabelClass?: string | null;
|
|
261
|
-
displayOnly?: boolean | null;
|
|
262
|
-
}
|
|
263
|
-
export declare enum GroupRenderType {
|
|
264
|
-
Standard = "Standard",
|
|
265
|
-
Grid = "Grid",
|
|
266
|
-
Flex = "Flex",
|
|
267
|
-
Tabs = "Tabs",
|
|
268
|
-
GroupElement = "GroupElement",
|
|
269
|
-
SelectChild = "SelectChild"
|
|
270
|
-
}
|
|
271
|
-
export interface StandardGroupRenderer extends GroupRenderOptions {
|
|
272
|
-
type: GroupRenderType.Standard;
|
|
273
|
-
}
|
|
274
|
-
export interface FlexRenderer extends GroupRenderOptions {
|
|
275
|
-
type: GroupRenderType.Flex;
|
|
276
|
-
direction?: string | null;
|
|
277
|
-
gap?: string | null;
|
|
278
|
-
}
|
|
279
|
-
export interface GroupElementRenderer extends GroupRenderOptions {
|
|
280
|
-
type: GroupRenderType.GroupElement;
|
|
281
|
-
value: any;
|
|
282
|
-
}
|
|
283
|
-
export interface GridRenderer extends GroupRenderOptions {
|
|
284
|
-
type: GroupRenderType.Grid;
|
|
285
|
-
columns?: number | null;
|
|
286
|
-
}
|
|
287
|
-
export interface TabsRenderOptions extends GroupRenderOptions {
|
|
288
|
-
type: GroupRenderType.Tabs;
|
|
289
|
-
contentClass?: string;
|
|
290
|
-
}
|
|
291
|
-
export interface SelectChildRenderer extends GroupRenderOptions {
|
|
292
|
-
type: GroupRenderType.SelectChild;
|
|
293
|
-
childIndexExpression?: EntityExpression | null;
|
|
294
|
-
}
|
|
295
|
-
export interface DisplayControlDefinition extends ControlDefinition {
|
|
296
|
-
type: ControlDefinitionType.Display;
|
|
297
|
-
displayData: DisplayData;
|
|
298
|
-
}
|
|
299
|
-
export interface DisplayData {
|
|
300
|
-
type: string;
|
|
301
|
-
}
|
|
302
|
-
export declare enum DisplayDataType {
|
|
303
|
-
Text = "Text",
|
|
304
|
-
Html = "Html",
|
|
305
|
-
Icon = "Icon",
|
|
306
|
-
Custom = "Custom"
|
|
307
|
-
}
|
|
308
|
-
export interface TextDisplay extends DisplayData {
|
|
309
|
-
type: DisplayDataType.Text;
|
|
310
|
-
text: string;
|
|
311
|
-
}
|
|
312
|
-
export interface IconDisplay extends DisplayData {
|
|
313
|
-
type: DisplayDataType.Icon;
|
|
314
|
-
iconClass: string;
|
|
315
|
-
}
|
|
316
|
-
export interface HtmlDisplay extends DisplayData {
|
|
317
|
-
type: DisplayDataType.Html;
|
|
318
|
-
html: string;
|
|
319
|
-
}
|
|
320
|
-
export interface CustomDisplay extends DisplayData {
|
|
321
|
-
type: DisplayDataType.Custom;
|
|
322
|
-
customId: string;
|
|
323
|
-
}
|
|
324
|
-
export interface ActionControlDefinition extends ControlDefinition {
|
|
325
|
-
type: ControlDefinitionType.Action;
|
|
326
|
-
actionId: string;
|
|
327
|
-
actionData?: string | null;
|
|
328
|
-
}
|
|
329
|
-
export interface ControlVisitor<A> {
|
|
330
|
-
data(d: DataControlDefinition): A;
|
|
331
|
-
group(d: GroupedControlsDefinition): A;
|
|
332
|
-
display(d: DisplayControlDefinition): A;
|
|
333
|
-
action(d: ActionControlDefinition): A;
|
|
334
|
-
}
|
|
335
|
-
export declare function visitControlDefinition<A>(x: ControlDefinition, visitor: ControlVisitor<A>, defaultValue: (c: ControlDefinition) => A): A;
|
|
336
|
-
export declare function isGridRenderer(options: GroupRenderOptions): options is GridRenderer;
|
|
337
|
-
export declare function isSelectChildRenderer(options: GroupRenderOptions): options is SelectChildRenderer;
|
|
338
|
-
export declare function isTabsRenderer(options: GroupRenderOptions): options is TabsRenderOptions;
|
|
339
|
-
export declare function isFlexRenderer(options: GroupRenderOptions): options is FlexRenderer;
|
|
340
|
-
export declare function isDisplayOnlyRenderer(options: RenderOptions): options is DisplayOnlyRenderOptions;
|
|
341
|
-
export declare function isTextfieldRenderer(options: RenderOptions): options is TextfieldRenderOptions;
|
|
342
|
-
export declare function isDateTimeRenderer(options: RenderOptions): options is DateTimeRenderOptions;
|
|
343
|
-
export declare function isAutocompleteRenderer(options: RenderOptions): options is AutocompleteRenderOptions;
|
|
344
|
-
export declare function isAutoCompleteClasses(options?: RenderOptions | null): options is AutocompleteClasses & RenderOptions;
|
|
345
|
-
export declare function isDataGroupRenderer(options?: RenderOptions | null): options is DataGroupRenderOptions;
|
|
346
|
-
export declare function isArrayRenderer(options: RenderOptions): options is ArrayRenderOptions;
|
|
347
|
-
export declare function isDataControl(c: ControlDefinition): c is DataControlDefinition;
|
|
348
|
-
export declare function isGroupControl(c: ControlDefinition): c is GroupedControlsDefinition;
|
|
349
|
-
export declare function isActionControl(c: ControlDefinition): c is ActionControlDefinition;
|
|
350
|
-
export declare function isDisplayControl(c: ControlDefinition): c is DisplayControlDefinition;
|
|
351
|
-
export type ControlActionHandler = (actionId: string, actionData: any, ctx: ControlDataContext) => (() => void) | undefined;
|
|
352
|
-
export declare function isCheckEntryClasses(options?: RenderOptions | null): options is CheckEntryClasses & RenderOptions;
|
|
353
|
-
export type ControlMap = {
|
|
354
|
-
[k: string]: ControlDefinition;
|
|
355
|
-
};
|
|
356
|
-
export interface FormNode {
|
|
357
|
-
id: string;
|
|
358
|
-
definition: ControlDefinition;
|
|
359
|
-
tree: FormTree;
|
|
360
|
-
parent?: FormNode;
|
|
361
|
-
getChildNodes(): FormNode[];
|
|
362
|
-
}
|
|
363
|
-
export interface FormTreeLookup {
|
|
364
|
-
getForm(formId: string): FormTree | undefined;
|
|
365
|
-
}
|
|
366
|
-
export declare abstract class FormTree implements FormTreeLookup {
|
|
367
|
-
abstract rootNode: FormNode;
|
|
368
|
-
abstract getByRefId(id: string): FormNode | undefined;
|
|
369
|
-
abstract addChild(parent: FormNode, control: ControlDefinition): FormNode;
|
|
370
|
-
abstract getForm(formId: string): FormTree | undefined;
|
|
371
|
-
createTempNode(id: string, definition: ControlDefinition, children?: FormNode[], parent?: FormNode): FormNode;
|
|
372
|
-
createChildNodes(parent: FormNode, definitions: ControlDefinition[] | undefined | null): FormNode[];
|
|
373
|
-
}
|
|
374
|
-
export declare function legacyFormNode(definition: ControlDefinition): FormNode;
|
|
375
|
-
export declare function createFormTree(controls: ControlDefinition[], getForm?: FormTreeLookup): FormTree;
|
|
376
|
-
export declare function createFormLookup<A extends Record<string, ControlDefinition[]>>(formMap: A): {
|
|
377
|
-
getForm(formId: keyof A): FormTree;
|
|
378
|
-
};
|
|
379
|
-
export declare function fieldPathForDefinition(c: ControlDefinition): string[] | undefined;
|
|
380
|
-
export declare function lookupDataNode(c: ControlDefinition, parentNode: SchemaDataNode): SchemaDataNode | undefined;
|
|
381
|
-
export declare function traverseParents<A, B extends {
|
|
382
|
-
parent?: B | undefined;
|
|
383
|
-
}>(current: B | undefined, get: (b: B) => A, until?: (b: B) => boolean): A[];
|
|
384
|
-
export declare function getRootDataNode(dataNode: SchemaDataNode): SchemaDataNode;
|
|
385
|
-
export declare function getJsonPath(dataNode: SchemaDataNode): (string | number)[];
|
|
386
|
-
export declare function getSchemaPath(schemaNode: SchemaNode): SchemaField[];
|
|
387
|
-
export declare function getSchemaFieldList(schema: SchemaNode): SchemaField[];
|
|
388
|
-
/**
|
|
389
|
-
* @deprecated use visitFormNodeData instead
|
|
390
|
-
*/
|
|
391
|
-
export declare function visitControlDataArray<A>(controls: ControlDefinition[] | undefined | null, context: SchemaDataNode, cb: (definition: DataControlDefinition, node: SchemaDataNode) => A | undefined): A | undefined;
|
|
392
|
-
/**
|
|
393
|
-
* @deprecated use visitFormDataInContext instead
|
|
394
|
-
*/
|
|
395
|
-
export declare function visitControlData<A>(definition: ControlDefinition, ctx: SchemaDataNode, cb: (definition: DataControlDefinition, field: SchemaDataNode) => A | undefined): A | undefined;
|
|
396
|
-
export type ControlDataVisitor<A> = (dataNode: SchemaDataNode, definition: DataControlDefinition) => A | undefined;
|
|
397
|
-
export declare function visitFormData<A>(node: FormNode, dataNode: SchemaDataNode, cb: ControlDataVisitor<A>, notSelf?: boolean): A | undefined;
|
|
398
|
-
export declare function visitFormDataInContext<A>(parentContext: SchemaDataNode, node: FormNode, cb: ControlDataVisitor<A>): A | undefined;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Control, ControlSetup } from "@react-typed-forms/core";
|
|
2
|
-
import { EqualityFunc, FieldOption, SchemaDataNode, SchemaField, SchemaInterface, SchemaNode, ValidationMessageType } from "./schemaField";
|
|
3
|
-
export declare class DefaultSchemaInterface implements SchemaInterface {
|
|
4
|
-
protected boolStrings: [string, string];
|
|
5
|
-
protected parseDateTime: (s: string) => number;
|
|
6
|
-
constructor(boolStrings?: [string, string], parseDateTime?: (s: string) => number);
|
|
7
|
-
parseToMillis(field: SchemaField, v: string): number;
|
|
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;
|
|
11
|
-
getOptions({ options }: SchemaField): FieldOption[] | null | undefined;
|
|
12
|
-
getFilterOptions(array: SchemaDataNode, field: SchemaNode): FieldOption[] | undefined | null;
|
|
13
|
-
isEmptyValue(f: SchemaField, value: any): boolean;
|
|
14
|
-
searchText(field: SchemaField, value: any): string;
|
|
15
|
-
textValue(field: SchemaField, value: any, element?: boolean | undefined): string | undefined;
|
|
16
|
-
controlLength(f: SchemaField, control: Control<any>): number;
|
|
17
|
-
valueLength(field: SchemaField, value: any): number;
|
|
18
|
-
compareValue(field: SchemaField, v1: unknown, v2: unknown): number;
|
|
19
|
-
compoundFieldSetup(f: SchemaNode): [string, ControlSetup<any>][];
|
|
20
|
-
compoundFieldEquality(f: SchemaNode): [string, EqualityFunc][];
|
|
21
|
-
makeEqualityFunc(field: SchemaNode, element?: boolean): EqualityFunc;
|
|
22
|
-
makeControlSetup(field: SchemaNode, element?: boolean): ControlSetup<any>;
|
|
23
|
-
}
|
|
24
|
-
export declare const defaultSchemaInterface: SchemaInterface;
|
package/lib/dynamicHooks.d.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type representing a hook dependency, which can be a string, number, undefined, or null.
|
|
3
|
-
*/
|
|
4
|
-
export type HookDep = string | number | undefined | null;
|
|
5
|
-
/**
|
|
6
|
-
* Interface representing a dynamic hook generator.
|
|
7
|
-
* @template A - The type of the hook result.
|
|
8
|
-
* @template P - The type of the hook context.
|
|
9
|
-
*/
|
|
10
|
-
export interface DynamicHookGenerator<A, P> {
|
|
11
|
-
deps: HookDep;
|
|
12
|
-
state: any;
|
|
13
|
-
runHook(ctx: P, state: any): A;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Creates a dynamic hook generator.
|
|
17
|
-
* @template A - The type of the hook result.
|
|
18
|
-
* @template P - The type of the hook context.
|
|
19
|
-
* @template S - The type of the hook state.
|
|
20
|
-
* @param runHook - The function to run the hook.
|
|
21
|
-
* @param state - The initial state of the hook.
|
|
22
|
-
* @param deps - The dependencies of the hook.
|
|
23
|
-
* @returns The dynamic hook generator.
|
|
24
|
-
*/
|
|
25
|
-
export declare function makeHook<A, P, S = undefined>(runHook: (ctx: P, state: S) => A, state: S, deps?: HookDep): DynamicHookGenerator<A, P>;
|
|
26
|
-
/**
|
|
27
|
-
* Type representing the value of a dynamic hook.
|
|
28
|
-
* @template A - The type of the dynamic hook generator.
|
|
29
|
-
*/
|
|
30
|
-
export type DynamicHookValue<A> = A extends DynamicHookGenerator<infer V, any> ? V : never;
|
|
31
|
-
/**
|
|
32
|
-
* Converts an array of dependencies to a dependency string.
|
|
33
|
-
* @template A - The type of the dependencies.
|
|
34
|
-
* @param deps - The array of dependencies.
|
|
35
|
-
* @param asHookDep - The function to convert a dependency to a hook dependency.
|
|
36
|
-
* @returns The dependency string.
|
|
37
|
-
*/
|
|
38
|
-
export declare function makeHookDepString<A>(deps: A[], asHookDep: (a: A) => HookDep): string;
|
|
39
|
-
/**
|
|
40
|
-
* Custom hook to use dynamic hooks.
|
|
41
|
-
* @template P - The type of the hook context.
|
|
42
|
-
* @template Hooks - The type of the hooks.
|
|
43
|
-
* @param hooks - The hooks to use.
|
|
44
|
-
* @returns A function that takes the hook context and returns the hook values.
|
|
45
|
-
*/
|
|
46
|
-
export declare function useDynamicHooks<P, Hooks extends Record<string, DynamicHookGenerator<any, P>>>(hooks: Hooks): (p: P) => {
|
|
47
|
-
[K in keyof Hooks]: DynamicHookValue<Hooks[K]>;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Converts a value to a dependency string.
|
|
51
|
-
* @param x - The value to convert.
|
|
52
|
-
* @returns The dependency string.
|
|
53
|
-
*/
|
|
54
|
-
export declare function toDepString(x: any): string;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export interface EntityExpression {
|
|
2
|
-
type: string;
|
|
3
|
-
}
|
|
4
|
-
export declare enum ExpressionType {
|
|
5
|
-
Jsonata = "Jsonata",
|
|
6
|
-
Data = "Data",
|
|
7
|
-
DataMatch = "FieldValue",
|
|
8
|
-
UserMatch = "UserMatch",
|
|
9
|
-
NotEmpty = "NotEmpty",
|
|
10
|
-
UUID = "UUID"
|
|
11
|
-
}
|
|
12
|
-
export interface JsonataExpression extends EntityExpression {
|
|
13
|
-
type: ExpressionType.Jsonata;
|
|
14
|
-
expression: string;
|
|
15
|
-
}
|
|
16
|
-
export interface DataExpression extends EntityExpression {
|
|
17
|
-
type: ExpressionType.Data;
|
|
18
|
-
field: string;
|
|
19
|
-
}
|
|
20
|
-
export interface DataMatchExpression extends EntityExpression {
|
|
21
|
-
type: ExpressionType.DataMatch;
|
|
22
|
-
field: string;
|
|
23
|
-
value: any;
|
|
24
|
-
}
|
|
25
|
-
export interface NotEmptyExpression extends EntityExpression {
|
|
26
|
-
type: ExpressionType.DataMatch;
|
|
27
|
-
field: string;
|
|
28
|
-
}
|
|
29
|
-
export interface UserMatchExpression extends EntityExpression {
|
|
30
|
-
type: ExpressionType.UserMatch;
|
|
31
|
-
userMatch: string;
|
|
32
|
-
}
|
package/lib/hooks.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ControlDefinition, DynamicPropertyType, ControlDataContext } from "./controlDefinition";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { Control } from "@react-typed-forms/core";
|
|
4
|
-
import { JsonPath } from "./util";
|
|
5
|
-
import { DynamicHookGenerator } from "./dynamicHooks";
|
|
6
|
-
import { SchemaDataNode, SchemaInterface } from "./schemaField";
|
|
7
|
-
import { EntityExpression } from "./entityExpression";
|
|
8
|
-
export type EvalExpressionHook<A = any> = DynamicHookGenerator<Control<A | undefined>, ControlDataContext>;
|
|
9
|
-
export type UseEvalExpressionHook = (expr: EntityExpression | undefined | null, coerce: (v: any) => any) => DynamicHookGenerator<Control<any> | undefined, ControlDataContext>;
|
|
10
|
-
export declare function optionalHook(expr: EntityExpression | undefined | null, useHook: UseEvalExpressionHook, coerce: (v: any) => any): DynamicHookGenerator<Control<any> | undefined, ControlDataContext> | undefined;
|
|
11
|
-
export declare function useEvalVisibilityHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition, overrideDataNode?: SchemaDataNode): EvalExpressionHook<boolean>;
|
|
12
|
-
export declare function useEvalReadonlyHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition): EvalExpressionHook<boolean>;
|
|
13
|
-
export declare function useEvalStyleHook(useEvalExpressionHook: UseEvalExpressionHook, property: DynamicPropertyType, definition: ControlDefinition): EvalExpressionHook<React.CSSProperties>;
|
|
14
|
-
export declare function useEvalAllowedOptionsHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition): EvalExpressionHook<any[]>;
|
|
15
|
-
export declare function useEvalDisabledHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition): EvalExpressionHook<boolean>;
|
|
16
|
-
export declare function useEvalDisplayHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition): DynamicHookGenerator<Control<string | undefined> | undefined, ControlDataContext>;
|
|
17
|
-
export declare function useEvalDefaultValueHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition): EvalExpressionHook;
|
|
18
|
-
export declare function defaultEvalHooks(expr: EntityExpression, context: ControlDataContext, coerce: (v: any) => any): Control<any>;
|
|
19
|
-
export declare const defaultUseEvalExpressionHook: UseEvalExpressionHook;
|
|
20
|
-
export declare function makeEvalExpressionHook(f: (expr: EntityExpression, context: ControlDataContext, coerce: (v: any) => any) => Control<any>): UseEvalExpressionHook;
|
|
21
|
-
export declare function useEvalDynamicBoolHook(definition: ControlDefinition, type: DynamicPropertyType, useEvalExpressionHook: UseEvalExpressionHook): DynamicHookGenerator<Control<any> | undefined, ControlDataContext>;
|
|
22
|
-
export declare function useEvalDynamicHook<V>(definition: ControlDefinition, type: DynamicPropertyType, useEvalExpressionHook: UseEvalExpressionHook, coerce?: (v: any) => any): DynamicHookGenerator<Control<V> | undefined, ControlDataContext>;
|
|
23
|
-
export declare function matchesType(context: SchemaDataNode): boolean;
|
|
24
|
-
export declare function hideDisplayOnly(context: SchemaDataNode, schemaInterface: SchemaInterface, definition: ControlDefinition): boolean | undefined;
|
|
25
|
-
export declare function useUuidExpression(coerce?: (v: any) => any): Control<any>;
|
|
26
|
-
export declare function useJsonataExpression(jExpr: string, data: Control<any>, path: JsonPath[], bindings?: Control<Record<string, any>>, coerce?: (v: any) => any): Control<any>;
|
|
27
|
-
export declare function useEvalActionHook(useExpr: UseEvalExpressionHook, definition: ControlDefinition): EvalExpressionHook<string | null>;
|
|
28
|
-
export declare function useEvalLabelText(useExpr: UseEvalExpressionHook, definition: ControlDefinition): EvalExpressionHook<string | null>;
|
package/lib/schemaBuilder.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { CompoundField, FieldOption, FieldType, SchemaField, SchemaMap } from "./schemaField";
|
|
2
|
-
export type AllowedSchema<T> = T extends string ? SchemaField & {
|
|
3
|
-
type: FieldType.String | FieldType.Date | FieldType.DateTime | FieldType.Time;
|
|
4
|
-
} : T extends number ? SchemaField & {
|
|
5
|
-
type: FieldType.Int | FieldType.Double;
|
|
6
|
-
} : T extends boolean ? SchemaField & {
|
|
7
|
-
type: FieldType.Bool;
|
|
8
|
-
} : T extends Array<infer E> ? AllowedSchema<E> & {
|
|
9
|
-
collection: true;
|
|
10
|
-
} : T extends {
|
|
11
|
-
[key: string]: any;
|
|
12
|
-
} ? CompoundField & {
|
|
13
|
-
type: FieldType.Compound;
|
|
14
|
-
} : SchemaField & {
|
|
15
|
-
type: FieldType.Any;
|
|
16
|
-
};
|
|
17
|
-
type AllowedField<T, K> = (name: string) => (SchemaField & {
|
|
18
|
-
type: K;
|
|
19
|
-
}) | AllowedSchema<T>;
|
|
20
|
-
export declare function buildSchema<T, Custom = "">(def: {
|
|
21
|
-
[K in keyof T]-?: AllowedField<T[K], Custom>;
|
|
22
|
-
}): SchemaField[];
|
|
23
|
-
export type FieldBuilder<T extends FieldType, K> = (name: string) => Omit<SchemaField, "type"> & {
|
|
24
|
-
type: T;
|
|
25
|
-
} & K;
|
|
26
|
-
export declare function stringField(displayName: string): FieldBuilder<FieldType.String, {}>;
|
|
27
|
-
export declare function stringField<S extends Partial<SchemaField>>(displayName: string, options: S): FieldBuilder<FieldType.String, S>;
|
|
28
|
-
export declare function stringOptionsField(displayName: string, ...options: FieldOption[]): (name: string) => SchemaField & {
|
|
29
|
-
type: FieldType.String;
|
|
30
|
-
displayName: string;
|
|
31
|
-
options: FieldOption[];
|
|
32
|
-
};
|
|
33
|
-
export declare function withScalarOptions<S extends SchemaField, S2 extends Partial<SchemaField>>(options: S2, v: (name: string) => S): (name: string) => S & S2;
|
|
34
|
-
export declare function makeScalarField<S extends Partial<SchemaField>>(options: S): (name: string) => SchemaField & S;
|
|
35
|
-
export declare function makeCompoundField<S extends Partial<CompoundField>>(options: S): (name: string) => CompoundField & {
|
|
36
|
-
type: FieldType.Compound;
|
|
37
|
-
} & S;
|
|
38
|
-
export declare function intField(displayName: string): FieldBuilder<FieldType.Int, {}>;
|
|
39
|
-
export declare function intField<S extends Partial<SchemaField>>(displayName: string, options: S): FieldBuilder<FieldType.Int, S>;
|
|
40
|
-
export declare function doubleField(displayName: string): FieldBuilder<FieldType.Double, {}>;
|
|
41
|
-
export declare function doubleField<S extends Partial<SchemaField>>(displayName: string, options: S): FieldBuilder<FieldType.Double, S>;
|
|
42
|
-
export declare function dateField(displayName: string): FieldBuilder<FieldType.Date, {}>;
|
|
43
|
-
export declare function dateField<S extends Partial<SchemaField>>(displayName: string, options: S): FieldBuilder<FieldType.Date, S>;
|
|
44
|
-
export declare function timeField<S extends Partial<SchemaField>>(displayName: string, options?: S): (name: string) => SchemaField & {
|
|
45
|
-
type: FieldType.Time;
|
|
46
|
-
displayName: string;
|
|
47
|
-
} & S;
|
|
48
|
-
export declare function dateTimeField<S extends Partial<SchemaField>>(displayName: string, options?: S): (name: string) => SchemaField & {
|
|
49
|
-
type: FieldType.DateTime;
|
|
50
|
-
displayName: string;
|
|
51
|
-
} & S;
|
|
52
|
-
export declare function boolField(displayName: string): FieldBuilder<FieldType.Bool, {}>;
|
|
53
|
-
export declare function boolField<S extends Partial<SchemaField>>(displayName: string, options: S): FieldBuilder<FieldType.Bool, S>;
|
|
54
|
-
export declare function compoundField<Other extends Partial<Omit<CompoundField, "type" | "schemaType">>>(displayName: string, fields: SchemaField[], other?: Other): (name: string) => CompoundField & {
|
|
55
|
-
collection: Other["collection"];
|
|
56
|
-
};
|
|
57
|
-
export declare function defaultScalarField(field: string, displayName: string): Omit<SchemaField, "type"> & {
|
|
58
|
-
type: FieldType.String;
|
|
59
|
-
};
|
|
60
|
-
export declare function defaultCompoundField(field: string, displayName: string, collection: boolean): CompoundField & {
|
|
61
|
-
type: FieldType.Compound;
|
|
62
|
-
};
|
|
63
|
-
export declare function mergeField(field: SchemaField, mergeInto: SchemaField[]): SchemaField[];
|
|
64
|
-
export declare function mergeFields(fields: SchemaField[], name: string, value: any, newFields: SchemaField[]): SchemaField[];
|
|
65
|
-
export declare function addFieldOption(typeField: SchemaField, name: string, value: any): SchemaField;
|
|
66
|
-
export declare function resolveSchemas<A extends SchemaMap>(schemaMap: A): A;
|
|
67
|
-
export {};
|