@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/controlBuilder.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { AccordionAdornment, ActionControlDefinition, AutocompleteRenderOptions, CheckListRenderOptions, ControlAdornmentType, ControlDefinition, DataControlDefinition, DataRenderType, DisplayControlDefinition, DisplayOnlyRenderOptions, DynamicProperty, GroupedControlsDefinition, JsonataRenderOptions, RadioButtonRenderOptions, RenderOptions, TextfieldRenderOptions } from "./controlDefinition";
|
|
2
2
|
import { ActionRendererProps } from "./controlRender";
|
|
3
3
|
import { DateValidator, JsonataValidator, LengthValidator, ValidatorType } from "./schemaValidator";
|
|
4
|
-
import { SchemaField, SchemaMap
|
|
4
|
+
import { SchemaField, SchemaMap } from "./schemaField";
|
|
5
5
|
import { DataExpression, DataMatchExpression, EntityExpression, JsonataExpression } from "./entityExpression";
|
|
6
|
+
import { SchemaNode } from "./schemaNode";
|
|
6
7
|
export declare function dataControl(field: string, title?: string | null, options?: Partial<DataControlDefinition>): DataControlDefinition;
|
|
7
8
|
export declare function validatorOptions<A extends {
|
|
8
9
|
type: string;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { SchemaValidator } from "./schemaValidator";
|
|
2
|
-
import { FieldOption,
|
|
2
|
+
import { FieldOption, SchemaField } from "./schemaField";
|
|
3
3
|
import { EntityExpression } from "./entityExpression";
|
|
4
|
+
import { SchemaInterface } from "./schemaInterface";
|
|
5
|
+
import { SchemaDataNode } from "./schemaDataNode";
|
|
6
|
+
import { SchemaNode } from "./schemaNode";
|
|
4
7
|
/**
|
|
5
8
|
* Interface representing the form context data.
|
|
6
9
|
*/
|
|
@@ -30,8 +33,10 @@ export interface ControlDefinition {
|
|
|
30
33
|
childRefId?: string | null;
|
|
31
34
|
title?: string | null;
|
|
32
35
|
styleClass?: string | null;
|
|
36
|
+
textClass?: string | null;
|
|
33
37
|
layoutClass?: string | null;
|
|
34
38
|
labelClass?: string | null;
|
|
39
|
+
labelTextClass?: string | null;
|
|
35
40
|
dynamic?: DynamicProperty[] | null;
|
|
36
41
|
adornments?: ControlAdornment[] | null;
|
|
37
42
|
children?: ControlDefinition[] | null;
|
|
@@ -75,9 +80,19 @@ export declare enum ControlAdornmentType {
|
|
|
75
80
|
SetField = "SetField",
|
|
76
81
|
Optional = "Optional"
|
|
77
82
|
}
|
|
83
|
+
export declare enum IconLibrary {
|
|
84
|
+
FontAwesome = "FontAwesome",
|
|
85
|
+
Material = "Material",
|
|
86
|
+
CssClass = "CssClass"
|
|
87
|
+
}
|
|
88
|
+
export interface IconReference {
|
|
89
|
+
library: string;
|
|
90
|
+
name: string;
|
|
91
|
+
}
|
|
78
92
|
export interface IconAdornment extends ControlAdornment {
|
|
79
93
|
type: ControlAdornmentType.Icon;
|
|
80
94
|
iconClass: string;
|
|
95
|
+
icon?: IconReference;
|
|
81
96
|
placement?: AdornmentPlacement | null;
|
|
82
97
|
}
|
|
83
98
|
export interface TooltipAdornment extends ControlAdornment {
|
|
@@ -214,7 +229,6 @@ export interface ArrayRenderOptions extends RenderOptions {
|
|
|
214
229
|
noAdd?: boolean | null;
|
|
215
230
|
noRemove?: boolean | null;
|
|
216
231
|
noReorder?: boolean | null;
|
|
217
|
-
childOptions?: RenderOptions | null;
|
|
218
232
|
editExternal?: boolean | null;
|
|
219
233
|
}
|
|
220
234
|
export interface ArrayElementRenderOptions extends RenderOptions {
|
|
@@ -266,7 +280,8 @@ export declare enum GroupRenderType {
|
|
|
266
280
|
Flex = "Flex",
|
|
267
281
|
Tabs = "Tabs",
|
|
268
282
|
GroupElement = "GroupElement",
|
|
269
|
-
SelectChild = "SelectChild"
|
|
283
|
+
SelectChild = "SelectChild",
|
|
284
|
+
Inline = "Inline"
|
|
270
285
|
}
|
|
271
286
|
export interface StandardGroupRenderer extends GroupRenderOptions {
|
|
272
287
|
type: GroupRenderType.Standard;
|
|
@@ -283,6 +298,7 @@ export interface GroupElementRenderer extends GroupRenderOptions {
|
|
|
283
298
|
export interface GridRenderer extends GroupRenderOptions {
|
|
284
299
|
type: GroupRenderType.Grid;
|
|
285
300
|
columns?: number | null;
|
|
301
|
+
rowClass?: string | null;
|
|
286
302
|
}
|
|
287
303
|
export interface TabsRenderOptions extends GroupRenderOptions {
|
|
288
304
|
type: GroupRenderType.Tabs;
|
|
@@ -312,6 +328,7 @@ export interface TextDisplay extends DisplayData {
|
|
|
312
328
|
export interface IconDisplay extends DisplayData {
|
|
313
329
|
type: DisplayDataType.Icon;
|
|
314
330
|
iconClass: string;
|
|
331
|
+
icon?: IconReference | null;
|
|
315
332
|
}
|
|
316
333
|
export interface HtmlDisplay extends DisplayData {
|
|
317
334
|
type: DisplayDataType.Html;
|
|
@@ -325,6 +342,17 @@ export interface ActionControlDefinition extends ControlDefinition {
|
|
|
325
342
|
type: ControlDefinitionType.Action;
|
|
326
343
|
actionId: string;
|
|
327
344
|
actionData?: string | null;
|
|
345
|
+
icon?: IconReference | null;
|
|
346
|
+
actionStyle?: ActionStyle | null;
|
|
347
|
+
iconPlacement?: IconPlacement | null;
|
|
348
|
+
}
|
|
349
|
+
export declare enum ActionStyle {
|
|
350
|
+
Button = "Button",
|
|
351
|
+
Link = "Link"
|
|
352
|
+
}
|
|
353
|
+
export declare enum IconPlacement {
|
|
354
|
+
BeforeText = "BeforeText",
|
|
355
|
+
AfterText = "AfterText"
|
|
328
356
|
}
|
|
329
357
|
export interface ControlVisitor<A> {
|
|
330
358
|
data(d: DataControlDefinition): A;
|
|
@@ -334,6 +362,7 @@ export interface ControlVisitor<A> {
|
|
|
334
362
|
}
|
|
335
363
|
export declare function visitControlDefinition<A>(x: ControlDefinition, visitor: ControlVisitor<A>, defaultValue: (c: ControlDefinition) => A): A;
|
|
336
364
|
export declare function isGridRenderer(options: GroupRenderOptions): options is GridRenderer;
|
|
365
|
+
export declare function isInlineRenderer(options: GroupRenderOptions): options is GridRenderer;
|
|
337
366
|
export declare function isSelectChildRenderer(options: GroupRenderOptions): options is SelectChildRenderer;
|
|
338
367
|
export declare function isTabsRenderer(options: GroupRenderOptions): options is TabsRenderOptions;
|
|
339
368
|
export declare function isFlexRenderer(options: GroupRenderOptions): options is FlexRenderer;
|
|
@@ -350,34 +379,6 @@ export declare function isActionControl(c: ControlDefinition): c is ActionContro
|
|
|
350
379
|
export declare function isDisplayControl(c: ControlDefinition): c is DisplayControlDefinition;
|
|
351
380
|
export type ControlActionHandler = (actionId: string, actionData: any, ctx: ControlDataContext) => (() => void) | undefined;
|
|
352
381
|
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
382
|
export declare function traverseParents<A, B extends {
|
|
382
383
|
parent?: B | undefined;
|
|
383
384
|
}>(current: B | undefined, get: (b: B) => A, until?: (b: B) => boolean): A[];
|
|
@@ -385,14 +386,7 @@ export declare function getRootDataNode(dataNode: SchemaDataNode): SchemaDataNod
|
|
|
385
386
|
export declare function getJsonPath(dataNode: SchemaDataNode): (string | number)[];
|
|
386
387
|
export declare function getSchemaPath(schemaNode: SchemaNode): SchemaField[];
|
|
387
388
|
export declare function getSchemaFieldList(schema: SchemaNode): SchemaField[];
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
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;
|
|
389
|
+
export declare function fontAwesomeIcon(icon: string): {
|
|
390
|
+
library: IconLibrary;
|
|
391
|
+
name: string;
|
|
392
|
+
};
|
package/lib/controlRender.d.ts
CHANGED
|
@@ -1,20 +1,72 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { ComponentType, ElementType, FC, HTMLAttributes, Key, ReactElement, ReactNode } from "react";
|
|
2
2
|
import { Control } from "@react-typed-forms/core";
|
|
3
|
-
import { AdornmentPlacement, ArrayActionOptions, ControlActionHandler, ControlAdornment, ControlDataContext, ControlDefinition, DataControlDefinition, DisplayData, FormContextData,
|
|
3
|
+
import { ActionStyle, AdornmentPlacement, ArrayActionOptions, ControlActionHandler, ControlAdornment, ControlDataContext, ControlDefinition, DataControlDefinition, DisplayData, FormContextData, GroupRenderOptions, IconPlacement, IconReference, RenderOptions } from "./controlDefinition";
|
|
4
4
|
import { ControlClasses, JsonPath } from "./util";
|
|
5
5
|
import { EvalExpressionHook, UseEvalExpressionHook } from "./hooks";
|
|
6
6
|
import { ValidationContext } from "./validators";
|
|
7
7
|
import { SchemaValidator } from "./schemaValidator";
|
|
8
|
-
import { FieldOption,
|
|
8
|
+
import { FieldOption, SchemaField } from "./schemaField";
|
|
9
|
+
import { FormNode } from "./formNode";
|
|
10
|
+
import { SchemaInterface } from "./schemaInterface";
|
|
11
|
+
import { SchemaDataNode } from "./schemaDataNode";
|
|
12
|
+
export interface HtmlIconProperties {
|
|
13
|
+
className?: string;
|
|
14
|
+
style?: React.CSSProperties;
|
|
15
|
+
iconLibrary?: string;
|
|
16
|
+
iconName?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface HtmlLabelProperties {
|
|
19
|
+
htmlFor?: string;
|
|
20
|
+
className?: string;
|
|
21
|
+
textClass?: string;
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
}
|
|
24
|
+
export interface HtmlDivProperties {
|
|
25
|
+
id?: string;
|
|
26
|
+
className?: string;
|
|
27
|
+
textClass?: string;
|
|
28
|
+
style?: React.CSSProperties;
|
|
29
|
+
children?: ReactNode;
|
|
30
|
+
text?: string;
|
|
31
|
+
html?: string;
|
|
32
|
+
nativeRef?: (e: HTMLElement | null) => void;
|
|
33
|
+
inline?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface HtmlInputProperties {
|
|
36
|
+
id?: string;
|
|
37
|
+
className?: string;
|
|
38
|
+
textClass?: string;
|
|
39
|
+
name?: string;
|
|
40
|
+
type?: string;
|
|
41
|
+
checked?: boolean;
|
|
42
|
+
style?: React.CSSProperties;
|
|
43
|
+
readOnly?: boolean;
|
|
44
|
+
placeholder?: string;
|
|
45
|
+
value?: string | number;
|
|
46
|
+
onBlur?: () => void;
|
|
47
|
+
disabled?: boolean;
|
|
48
|
+
inputRef?: (e: HTMLElement | null) => void;
|
|
49
|
+
onChangeValue?: (value: string) => void;
|
|
50
|
+
onChangeChecked?: (checked: boolean) => void;
|
|
51
|
+
}
|
|
52
|
+
export interface HtmlButtonProperties {
|
|
53
|
+
className?: string;
|
|
54
|
+
textClass?: string;
|
|
55
|
+
disabled?: boolean;
|
|
56
|
+
style?: React.CSSProperties;
|
|
57
|
+
onClick?: () => void;
|
|
58
|
+
inline?: boolean;
|
|
59
|
+
children?: ReactNode;
|
|
60
|
+
}
|
|
9
61
|
export interface HtmlComponents {
|
|
10
|
-
Div:
|
|
62
|
+
Div: ComponentType<HtmlDivProperties>;
|
|
11
63
|
Span: ElementType<HTMLAttributes<HTMLSpanElement>>;
|
|
12
|
-
Button:
|
|
13
|
-
I:
|
|
14
|
-
Label:
|
|
64
|
+
Button: ComponentType<HtmlButtonProperties>;
|
|
65
|
+
I: ComponentType<HtmlIconProperties>;
|
|
66
|
+
Label: ComponentType<HtmlLabelProperties>;
|
|
15
67
|
B: ElementType<HTMLAttributes<HTMLElement>>;
|
|
16
68
|
H1: ElementType<HTMLAttributes<HTMLElement>>;
|
|
17
|
-
Input:
|
|
69
|
+
Input: ComponentType<HtmlInputProperties>;
|
|
18
70
|
}
|
|
19
71
|
/**
|
|
20
72
|
* Interface for rendering different types of form controls.
|
|
@@ -82,7 +134,6 @@ export interface FormRenderer {
|
|
|
82
134
|
* @returns A React node.
|
|
83
135
|
*/
|
|
84
136
|
renderLabelText: (props: ReactNode) => ReactNode;
|
|
85
|
-
renderText: (props: ReactNode, className?: string) => ReactNode;
|
|
86
137
|
html: HtmlComponents;
|
|
87
138
|
}
|
|
88
139
|
export interface AdornmentProps {
|
|
@@ -127,12 +178,14 @@ export interface RenderedLayout {
|
|
|
127
178
|
className?: string;
|
|
128
179
|
style?: React.CSSProperties;
|
|
129
180
|
wrapLayout: (layout: ReactElement) => ReactElement;
|
|
181
|
+
inline?: boolean;
|
|
130
182
|
}
|
|
131
183
|
export interface RenderedControl {
|
|
132
184
|
children: ReactNode;
|
|
133
185
|
className?: string;
|
|
134
186
|
style?: React.CSSProperties;
|
|
135
187
|
divRef?: (cb: HTMLElement | null) => void;
|
|
188
|
+
inline?: boolean;
|
|
136
189
|
}
|
|
137
190
|
export interface VisibilityRendererProps extends RenderedControl {
|
|
138
191
|
visibility: Control<Visibility | undefined>;
|
|
@@ -145,6 +198,7 @@ export interface ControlLayoutProps {
|
|
|
145
198
|
processLayout?: (props: ControlLayoutProps) => ControlLayoutProps;
|
|
146
199
|
className?: string | null;
|
|
147
200
|
style?: React.CSSProperties;
|
|
201
|
+
inline?: boolean;
|
|
148
202
|
}
|
|
149
203
|
/**
|
|
150
204
|
* Enum representing the types of labels that can be rendered.
|
|
@@ -192,6 +246,10 @@ export interface LabelRendererProps {
|
|
|
192
246
|
* The CSS class name for the label.
|
|
193
247
|
*/
|
|
194
248
|
className?: string;
|
|
249
|
+
/**
|
|
250
|
+
* The CSS class name for the label text.
|
|
251
|
+
*/
|
|
252
|
+
textClass?: string;
|
|
195
253
|
}
|
|
196
254
|
/**
|
|
197
255
|
* Properties for display renderers.
|
|
@@ -213,16 +271,19 @@ export interface DisplayRendererProps {
|
|
|
213
271
|
* The CSS class name for the display renderer.
|
|
214
272
|
*/
|
|
215
273
|
className?: string;
|
|
274
|
+
textClass?: string;
|
|
216
275
|
/**
|
|
217
276
|
* The CSS styles for the display renderer.
|
|
218
277
|
*/
|
|
219
278
|
style?: React.CSSProperties;
|
|
279
|
+
inline?: boolean;
|
|
220
280
|
}
|
|
221
281
|
export type ChildVisibilityFunc = (child: ControlDefinition, parentNode?: SchemaDataNode, dontOverride?: boolean) => EvalExpressionHook<boolean>;
|
|
222
282
|
export interface ParentRendererProps {
|
|
223
283
|
formNode: FormNode;
|
|
224
284
|
renderChild: ChildRenderer;
|
|
225
285
|
className?: string;
|
|
286
|
+
textClass?: string;
|
|
226
287
|
style?: React.CSSProperties;
|
|
227
288
|
dataContext: ControlDataContext;
|
|
228
289
|
useChildVisibility: ChildVisibilityFunc;
|
|
@@ -237,7 +298,6 @@ export interface DataRendererProps extends ParentRendererProps {
|
|
|
237
298
|
renderOptions: RenderOptions;
|
|
238
299
|
definition: DataControlDefinition;
|
|
239
300
|
field: SchemaField;
|
|
240
|
-
elementIndex?: number;
|
|
241
301
|
id: string;
|
|
242
302
|
control: Control<any>;
|
|
243
303
|
readonly: boolean;
|
|
@@ -246,15 +306,21 @@ export interface DataRendererProps extends ParentRendererProps {
|
|
|
246
306
|
hidden: boolean;
|
|
247
307
|
dataNode: SchemaDataNode;
|
|
248
308
|
displayOnly: boolean;
|
|
309
|
+
inline: boolean;
|
|
249
310
|
}
|
|
250
311
|
export interface ActionRendererProps {
|
|
251
312
|
actionId: string;
|
|
252
313
|
actionText: string;
|
|
253
314
|
actionData?: any;
|
|
315
|
+
actionStyle?: ActionStyle;
|
|
316
|
+
icon?: IconReference | null;
|
|
317
|
+
iconPlacement?: IconPlacement;
|
|
254
318
|
onClick: () => void;
|
|
255
319
|
className?: string | null;
|
|
320
|
+
textClass?: string | null;
|
|
256
321
|
style?: React.CSSProperties;
|
|
257
322
|
disabled?: boolean;
|
|
323
|
+
inline?: boolean;
|
|
258
324
|
}
|
|
259
325
|
export interface ControlRenderProps {
|
|
260
326
|
control: Control<any>;
|
|
@@ -265,25 +331,9 @@ export interface FormContextOptions {
|
|
|
265
331
|
hidden?: boolean | null;
|
|
266
332
|
disabled?: boolean | null;
|
|
267
333
|
displayOnly?: boolean;
|
|
334
|
+
inline?: boolean;
|
|
268
335
|
}
|
|
269
|
-
export
|
|
270
|
-
formNode: FormNode;
|
|
271
|
-
definition: DataControlDefinition;
|
|
272
|
-
dataContext: ControlDataContext;
|
|
273
|
-
control: Control<any>;
|
|
274
|
-
formOptions: FormContextOptions;
|
|
275
|
-
style?: React.CSSProperties | undefined;
|
|
276
|
-
renderChild: ChildRenderer;
|
|
277
|
-
elementIndex?: number;
|
|
278
|
-
allowedOptions?: Control<any[] | undefined>;
|
|
279
|
-
useChildVisibility: ChildVisibilityFunc;
|
|
280
|
-
useEvalExpression: UseEvalExpressionHook;
|
|
281
|
-
schemaInterface?: SchemaInterface;
|
|
282
|
-
designMode?: boolean;
|
|
283
|
-
styleClass?: string;
|
|
284
|
-
layoutClass?: string;
|
|
285
|
-
}
|
|
286
|
-
export type CreateDataProps = (controlProps: DataControlProps) => DataRendererProps;
|
|
336
|
+
export type CreateDataProps = (controlProps: RenderLayoutProps, definition: DataControlDefinition, control: Control<any>) => DataRendererProps;
|
|
287
337
|
export interface ControlRenderOptions extends FormContextOptions, ControlClasses {
|
|
288
338
|
useDataHook?: (c: ControlDefinition) => CreateDataProps;
|
|
289
339
|
actionOnClick?: ControlActionHandler;
|
|
@@ -293,7 +343,6 @@ export interface ControlRenderOptions extends FormContextOptions, ControlClasses
|
|
|
293
343
|
adjustLayout?: (context: ControlDataContext, layout: ControlLayoutProps) => ControlLayoutProps;
|
|
294
344
|
clearHidden?: boolean;
|
|
295
345
|
schemaInterface?: SchemaInterface;
|
|
296
|
-
elementIndex?: number;
|
|
297
346
|
formData?: FormContextData;
|
|
298
347
|
}
|
|
299
348
|
export declare function useControlRenderer(definition: ControlDefinition, fields: SchemaField[], renderer: FormRenderer, options?: ControlRenderOptions): FC<ControlRenderProps>;
|
|
@@ -312,19 +361,18 @@ export declare function NewControlRenderer({ definition, renderer, options, pare
|
|
|
312
361
|
options?: ControlRenderOptions;
|
|
313
362
|
parentDataNode: SchemaDataNode;
|
|
314
363
|
}): JSX.Element;
|
|
315
|
-
export declare function defaultDataProps({
|
|
364
|
+
export declare function defaultDataProps({ formOptions, style, allowedOptions, schemaInterface, styleClass, textClass: tc, ...props }: RenderLayoutProps, definition: DataControlDefinition, control: Control<any>): DataRendererProps;
|
|
316
365
|
export interface ChildRendererOptions {
|
|
317
|
-
elementIndex?: number;
|
|
318
366
|
parentDataNode?: SchemaDataNode;
|
|
319
367
|
formData?: FormContextData;
|
|
368
|
+
inline?: boolean;
|
|
320
369
|
displayOnly?: boolean;
|
|
321
370
|
styleClass?: string;
|
|
322
371
|
layoutClass?: string;
|
|
323
372
|
labelClass?: string;
|
|
324
373
|
}
|
|
325
374
|
export type ChildRenderer = (k: Key, child: FormNode, options?: ChildRendererOptions) => ReactNode;
|
|
326
|
-
export interface
|
|
327
|
-
definition: ControlDefinition;
|
|
375
|
+
export interface RenderLayoutProps {
|
|
328
376
|
formNode: FormNode;
|
|
329
377
|
renderer: FormRenderer;
|
|
330
378
|
renderChild: ChildRenderer;
|
|
@@ -333,7 +381,6 @@ export interface RenderControlProps {
|
|
|
333
381
|
dataContext: ControlDataContext;
|
|
334
382
|
control?: Control<any>;
|
|
335
383
|
labelText?: Control<string | null | undefined>;
|
|
336
|
-
elementIndex?: number;
|
|
337
384
|
displayControl?: Control<string | undefined>;
|
|
338
385
|
style?: React.CSSProperties;
|
|
339
386
|
allowedOptions?: Control<any[] | undefined>;
|
|
@@ -345,10 +392,12 @@ export interface RenderControlProps {
|
|
|
345
392
|
designMode?: boolean;
|
|
346
393
|
customDisplay?: (customId: string, displayProps: DisplayRendererProps) => ReactNode;
|
|
347
394
|
labelClass?: string;
|
|
395
|
+
labelTextClass?: string;
|
|
348
396
|
styleClass?: string;
|
|
397
|
+
textClass?: string;
|
|
349
398
|
}
|
|
350
|
-
export declare function renderControlLayout(props:
|
|
351
|
-
type MarkupKeys = keyof Omit<RenderedLayout, "errorControl" | "style" | "className" | "wrapLayout" | "readonly" | "disabled">;
|
|
399
|
+
export declare function renderControlLayout(props: RenderLayoutProps): ControlLayoutProps;
|
|
400
|
+
type MarkupKeys = keyof Omit<RenderedLayout, "errorControl" | "style" | "className" | "wrapLayout" | "readonly" | "disabled" | "inline">;
|
|
352
401
|
export declare function appendMarkup(k: MarkupKeys, markup: ReactNode): (layout: RenderedLayout) => void;
|
|
353
402
|
export declare function wrapMarkup(k: MarkupKeys, wrap: (ex: ReactNode) => ReactNode): (layout: RenderedLayout) => void;
|
|
354
403
|
export declare function layoutKeyForPlacement(pos: AdornmentPlacement): MarkupKeys;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Control, ControlSetup } from "@react-typed-forms/core";
|
|
2
|
-
import { EqualityFunc, FieldOption,
|
|
2
|
+
import { EqualityFunc, FieldOption, SchemaField, ValidationMessageType } from "./schemaField";
|
|
3
|
+
import { SchemaInterface } from "./schemaInterface";
|
|
4
|
+
import { SchemaDataNode } from "./schemaDataNode";
|
|
5
|
+
import { SchemaNode } from "./schemaNode";
|
|
3
6
|
export declare class DefaultSchemaInterface implements SchemaInterface {
|
|
4
7
|
protected boolStrings: [string, string];
|
|
5
8
|
protected parseDateTime: (s: string) => number;
|
|
@@ -12,7 +15,8 @@ export declare class DefaultSchemaInterface implements SchemaInterface {
|
|
|
12
15
|
getFilterOptions(array: SchemaDataNode, field: SchemaNode): FieldOption[] | undefined | null;
|
|
13
16
|
isEmptyValue(f: SchemaField, value: any): boolean;
|
|
14
17
|
searchText(field: SchemaField, value: any): string;
|
|
15
|
-
|
|
18
|
+
textValueForData(dataNode: SchemaDataNode): string | undefined;
|
|
19
|
+
textValue(field: SchemaField, value: any, element?: boolean | undefined, options?: FieldOption[] | null): string | undefined;
|
|
16
20
|
controlLength(f: SchemaField, control: Control<any>): number;
|
|
17
21
|
valueLength(field: SchemaField, value: any): number;
|
|
18
22
|
compareValue(field: SchemaField, v1: unknown, v2: unknown): number;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ControlDataContext, ControlDefinition, DataControlDefinition } from "./controlDefinition";
|
|
2
|
+
import { SchemaDataNode } from "./schemaDataNode";
|
|
3
|
+
export type ControlMap = {
|
|
4
|
+
[k: string]: ControlDefinition;
|
|
5
|
+
};
|
|
6
|
+
export declare class FormNode {
|
|
7
|
+
id: string;
|
|
8
|
+
definition: ControlDefinition;
|
|
9
|
+
tree: FormTree;
|
|
10
|
+
parent?: FormNode | undefined;
|
|
11
|
+
constructor(id: string, definition: ControlDefinition, tree: FormTree, parent?: FormNode | undefined);
|
|
12
|
+
visit<A>(visitFn: (n: FormNode) => A | undefined): A | undefined;
|
|
13
|
+
getResolvedChildren(): ControlDefinition[];
|
|
14
|
+
createChildNode(childId: string, childDef: ControlDefinition): FormNode;
|
|
15
|
+
getChildNodes(): FormNode[];
|
|
16
|
+
getUnresolvedChildNodes(): FormNode[];
|
|
17
|
+
}
|
|
18
|
+
export interface FormTreeLookup {
|
|
19
|
+
getForm(formId: string): FormTree | undefined;
|
|
20
|
+
}
|
|
21
|
+
export declare abstract class FormTree implements FormTreeLookup {
|
|
22
|
+
abstract rootNode: FormNode;
|
|
23
|
+
abstract getByRefId(id: string): ControlDefinition | undefined;
|
|
24
|
+
abstract getForm(formId: string): FormTree | undefined;
|
|
25
|
+
getChildId(parentId: string, childId: string, control: ControlDefinition): string;
|
|
26
|
+
}
|
|
27
|
+
export declare function createControlMap(control: ControlDefinition): ControlMap;
|
|
28
|
+
export declare function legacyFormNode(definition: ControlDefinition): FormNode;
|
|
29
|
+
export declare function createFormTree(controls: ControlDefinition[], getForm?: FormTreeLookup): FormTree;
|
|
30
|
+
export declare function createFormLookup<A extends Record<string, ControlDefinition[]>>(formMap: A): {
|
|
31
|
+
getForm(formId: keyof A): FormTree;
|
|
32
|
+
};
|
|
33
|
+
export declare function fieldPathForDefinition(c: ControlDefinition): string[] | undefined;
|
|
34
|
+
export declare function lookupDataNode(c: ControlDefinition, parentNode: SchemaDataNode): SchemaDataNode | undefined;
|
|
35
|
+
export declare function lookupChildDataContext(dataContext: ControlDataContext, c: ControlDefinition): ControlDataContext;
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated use visitFormNodeData instead
|
|
38
|
+
*/
|
|
39
|
+
export declare function visitControlDataArray<A>(controls: ControlDefinition[] | undefined | null, context: SchemaDataNode, cb: (definition: DataControlDefinition, node: SchemaDataNode) => A | undefined): A | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated use visitFormDataInContext instead
|
|
42
|
+
*/
|
|
43
|
+
export declare function visitControlData<A>(definition: ControlDefinition, ctx: SchemaDataNode, cb: (definition: DataControlDefinition, field: SchemaDataNode) => A | undefined): A | undefined;
|
|
44
|
+
export type ControlDataVisitor<A> = (dataNode: SchemaDataNode, definition: DataControlDefinition) => A | undefined;
|
|
45
|
+
export declare function visitFormData<A>(node: FormNode, dataNode: SchemaDataNode, cb: ControlDataVisitor<A>, notSelf?: boolean): A | undefined;
|
|
46
|
+
export declare function visitFormDataInContext<A>(parentContext: SchemaDataNode, node: FormNode, cb: ControlDataVisitor<A>): A | undefined;
|
package/lib/hooks.d.ts
CHANGED
|
@@ -3,8 +3,9 @@ import React from "react";
|
|
|
3
3
|
import { Control } from "@react-typed-forms/core";
|
|
4
4
|
import { JsonPath } from "./util";
|
|
5
5
|
import { DynamicHookGenerator } from "./dynamicHooks";
|
|
6
|
-
import { SchemaDataNode, SchemaInterface } from "./schemaField";
|
|
7
6
|
import { EntityExpression } from "./entityExpression";
|
|
7
|
+
import { SchemaInterface } from "./schemaInterface";
|
|
8
|
+
import { SchemaDataNode } from "./schemaDataNode";
|
|
8
9
|
export type EvalExpressionHook<A = any> = DynamicHookGenerator<Control<A | undefined>, ControlDataContext>;
|
|
9
10
|
export type UseEvalExpressionHook = (expr: EntityExpression | undefined | null, coerce: (v: any) => any) => DynamicHookGenerator<Control<any> | undefined, ControlDataContext>;
|
|
10
11
|
export declare function optionalHook(expr: EntityExpression | undefined | null, useHook: UseEvalExpressionHook, coerce: (v: any) => any): DynamicHookGenerator<Control<any> | undefined, ControlDataContext> | undefined;
|