@react-typed-forms/schemas 15.1.3 → 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 -7
- package/lib/controlRender.d.ts +35 -64
- package/lib/index.cjs +438 -2189
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +3 -13
- package/lib/index.js +303 -1681
- package/lib/index.js.map +1 -1
- package/lib/renderers.d.ts +3 -2
- package/lib/types.d.ts +31 -0
- package/lib/util.d.ts +4 -48
- package/package.json +5 -4
- package/src/RenderForm.tsx +301 -0
- package/src/controlBuilder.ts +16 -19
- package/src/controlRender.tsx +109 -449
- package/src/createFormRenderer.tsx +3 -3
- package/src/index.ts +3 -13
- package/src/renderers.tsx +2 -2
- package/src/types.ts +52 -0
- package/src/util.ts +52 -113
- package/lib/controlDefinition.d.ts +0 -392
- package/lib/defaultSchemaInterface.d.ts +0 -28
- package/lib/dynamicHooks.d.ts +0 -54
- package/lib/entityExpression.d.ts +0 -32
- package/lib/formNode.d.ts +0 -46
- package/lib/hooks.d.ts +0 -29
- package/lib/schemaBuilder.d.ts +0 -67
- package/lib/schemaDataNode.d.ts +0 -31
- package/lib/schemaField.d.ts +0 -120
- package/lib/schemaInterface.d.ts +0 -102
- package/lib/schemaNode.d.ts +0 -54
- package/lib/schemaValidator.d.ts +0 -27
- package/lib/validators.d.ts +0 -19
- package/src/controlDefinition.ts +0 -621
- package/src/defaultSchemaInterface.ts +0 -201
- package/src/dynamicHooks.ts +0 -98
- package/src/entityExpression.ts +0 -38
- package/src/formNode.ts +0 -253
- package/src/hooks.tsx +0 -469
- package/src/schemaBuilder.ts +0 -318
- package/src/schemaDataNode.ts +0 -129
- package/src/schemaField.ts +0 -153
- package/src/schemaInterface.ts +0 -135
- package/src/schemaNode.ts +0 -279
- package/src/schemaValidator.ts +0 -32
- package/src/validators.ts +0 -217
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ControlRenderOptions, ControlRenderProps, FormRenderer } from "./controlRender";
|
|
2
|
+
import React, { FC } from "react";
|
|
3
|
+
import { ControlDefinition, FormNode, JsonPath, SchemaDataNode, SchemaField } from "@astroapps/forms-core";
|
|
4
|
+
import { Control } from "@react-typed-forms/core";
|
|
5
|
+
export interface RenderFormProps {
|
|
6
|
+
data: SchemaDataNode;
|
|
7
|
+
form: FormNode;
|
|
8
|
+
renderer: FormRenderer;
|
|
9
|
+
options?: ControlRenderOptions;
|
|
10
|
+
}
|
|
11
|
+
export declare function RenderForm({ data, form, renderer, options, }: RenderFormProps): React.ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Use RenderForm instead.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useControlRendererComponent(controlOrFormNode: ControlDefinition | FormNode, renderer: FormRenderer, options: ControlRenderOptions | undefined, parentDataNode: SchemaDataNode): FC<{}>;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use RenderForm instead.
|
|
18
|
+
*/
|
|
19
|
+
export declare function ControlRenderer({ definition, fields, renderer, options, control, parentPath, }: {
|
|
20
|
+
definition: ControlDefinition;
|
|
21
|
+
fields: SchemaField[];
|
|
22
|
+
renderer: FormRenderer;
|
|
23
|
+
options?: ControlRenderOptions;
|
|
24
|
+
control: Control<any>;
|
|
25
|
+
parentPath?: JsonPath[];
|
|
26
|
+
}): JSX.Element;
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated Use RenderForm instead.
|
|
29
|
+
*/
|
|
30
|
+
export declare function NewControlRenderer({ definition, renderer, options, parentDataNode, }: {
|
|
31
|
+
definition: ControlDefinition | FormNode;
|
|
32
|
+
renderer: FormRenderer;
|
|
33
|
+
options?: ControlRenderOptions;
|
|
34
|
+
parentDataNode: SchemaDataNode;
|
|
35
|
+
}): JSX.Element;
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated Use RenderForm instead.
|
|
38
|
+
*/
|
|
39
|
+
export declare function useControlRenderer(definition: ControlDefinition, fields: SchemaField[], renderer: FormRenderer, options?: ControlRenderOptions): FC<ControlRenderProps>;
|
package/lib/controlBuilder.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { AccordionAdornment, ActionControlDefinition, AutocompleteRenderOptions, CheckListRenderOptions, ControlAdornmentType, ControlDefinition, DataControlDefinition, DataRenderType, DisplayControlDefinition, DisplayOnlyRenderOptions, DynamicProperty, GroupedControlsDefinition, JsonataRenderOptions, RadioButtonRenderOptions, RenderOptions, TextfieldRenderOptions } from "
|
|
2
|
-
import { ActionRendererProps } from "./
|
|
3
|
-
import { DateValidator, JsonataValidator, LengthValidator, ValidatorType } from "./schemaValidator";
|
|
4
|
-
import { SchemaField, SchemaMap } from "./schemaField";
|
|
5
|
-
import { DataExpression, DataMatchExpression, EntityExpression, JsonataExpression } from "./entityExpression";
|
|
6
|
-
import { SchemaNode } from "./schemaNode";
|
|
1
|
+
import { AccordionAdornment, ActionControlDefinition, AutocompleteRenderOptions, CheckListRenderOptions, ControlAdornmentType, ControlDefinition, DataControlDefinition, DataExpression, DataMatchExpression, DataRenderType, DateValidator, DisplayControlDefinition, DisplayOnlyRenderOptions, DynamicProperty, EntityExpression, GroupedControlsDefinition, JsonataExpression, JsonataRenderOptions, JsonataValidator, LengthValidator, RadioButtonRenderOptions, RenderOptions, SchemaField, SchemaMap, SchemaNode, TextfieldRenderOptions, ValidatorType } from "@astroapps/forms-core";
|
|
2
|
+
import { ActionRendererProps } from "./types";
|
|
7
3
|
export declare function dataControl(field: string, title?: string | null, options?: Partial<DataControlDefinition>): DataControlDefinition;
|
|
8
4
|
export declare function validatorOptions<A extends {
|
|
9
5
|
type: string;
|
|
@@ -48,7 +44,7 @@ export declare function jsonataExpr(expression: string): JsonataExpression;
|
|
|
48
44
|
export declare function groupedControl(children: ControlDefinition[], title?: string, options?: Partial<GroupedControlsDefinition>): GroupedControlsDefinition;
|
|
49
45
|
export declare function compoundControl(field: string, title: string | undefined, children: ControlDefinition[], options?: Partial<DataControlDefinition>): DataControlDefinition;
|
|
50
46
|
export declare function actionControl(actionText: string, actionId: string, options?: Partial<ActionControlDefinition>): ActionControlDefinition;
|
|
51
|
-
export declare function createAction(actionId: string, onClick: () => void, actionText?: string, options?: Partial<ActionRendererProps>): ActionRendererProps;
|
|
47
|
+
export declare function createAction(actionId: string, onClick: () => void, actionText?: string | null, options?: Partial<ActionRendererProps>): ActionRendererProps;
|
|
52
48
|
export declare const emptyGroupDefinition: GroupedControlsDefinition;
|
|
53
49
|
export declare function useControlDefinitionForSchema(sf: SchemaField[], definition?: GroupedControlsDefinition): GroupedControlsDefinition;
|
|
54
50
|
export interface EditorGroup {
|
package/lib/controlRender.d.ts
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import React, { ComponentType, ElementType,
|
|
1
|
+
import React, { ComponentType, ElementType, HTMLAttributes, Key, ReactElement, ReactNode } from "react";
|
|
2
2
|
import { Control } from "@react-typed-forms/core";
|
|
3
|
-
import {
|
|
4
|
-
import { ControlClasses
|
|
5
|
-
import {
|
|
6
|
-
import { ValidationContext } from "./validators";
|
|
7
|
-
import { SchemaValidator } from "./schemaValidator";
|
|
8
|
-
import { FieldOption, SchemaField } from "./schemaField";
|
|
9
|
-
import { FormNode } from "./formNode";
|
|
10
|
-
import { SchemaInterface } from "./schemaInterface";
|
|
11
|
-
import { SchemaDataNode } from "./schemaDataNode";
|
|
3
|
+
import { AdornmentPlacement, ArrayActionOptions, ControlAdornment, ControlDefinition, ControlState, DataControlDefinition, DisplayData, FieldOption, FormContextOptions, FormNode, FormState, GroupRenderOptions, JsonPath, RenderOptions, SchemaDataNode, SchemaField, SchemaInterface } from "@astroapps/forms-core";
|
|
4
|
+
import { ControlClasses } from "./util";
|
|
5
|
+
import { ActionRendererProps, ControlActionHandler, ControlDataContext, RunExpression } from "./types";
|
|
12
6
|
export interface HtmlIconProperties {
|
|
13
7
|
className?: string;
|
|
14
8
|
style?: React.CSSProperties;
|
|
@@ -57,6 +51,10 @@ export interface HtmlButtonProperties {
|
|
|
57
51
|
onClick?: () => void;
|
|
58
52
|
inline?: boolean;
|
|
59
53
|
children?: ReactNode;
|
|
54
|
+
title?: string;
|
|
55
|
+
notWrapInText?: boolean;
|
|
56
|
+
androidRippleColor?: string;
|
|
57
|
+
nonTextContent?: boolean;
|
|
60
58
|
}
|
|
61
59
|
export interface HtmlComponents {
|
|
62
60
|
Div: ComponentType<HtmlDivProperties>;
|
|
@@ -139,7 +137,7 @@ export interface FormRenderer {
|
|
|
139
137
|
export interface AdornmentProps {
|
|
140
138
|
adornment: ControlAdornment;
|
|
141
139
|
dataContext: ControlDataContext;
|
|
142
|
-
|
|
140
|
+
runExpression?: RunExpression;
|
|
143
141
|
designMode?: boolean;
|
|
144
142
|
formOptions: FormContextOptions;
|
|
145
143
|
}
|
|
@@ -278,17 +276,18 @@ export interface DisplayRendererProps {
|
|
|
278
276
|
style?: React.CSSProperties;
|
|
279
277
|
inline?: boolean;
|
|
280
278
|
}
|
|
281
|
-
export type ChildVisibilityFunc = (child: ControlDefinition, parentNode?: SchemaDataNode, dontOverride?: boolean) => EvalExpressionHook<boolean>;
|
|
282
279
|
export interface ParentRendererProps {
|
|
283
280
|
formNode: FormNode;
|
|
281
|
+
state: ControlState;
|
|
284
282
|
renderChild: ChildRenderer;
|
|
285
283
|
className?: string;
|
|
286
284
|
textClass?: string;
|
|
287
285
|
style?: React.CSSProperties;
|
|
288
286
|
dataContext: ControlDataContext;
|
|
289
|
-
|
|
290
|
-
|
|
287
|
+
getChildState(node: FormNode, parent?: SchemaDataNode): ControlState;
|
|
288
|
+
runExpression: RunExpression;
|
|
291
289
|
designMode?: boolean;
|
|
290
|
+
actionOnClick?: ControlActionHandler;
|
|
292
291
|
}
|
|
293
292
|
export interface GroupRendererProps extends ParentRendererProps {
|
|
294
293
|
definition: ControlDefinition;
|
|
@@ -308,85 +307,54 @@ export interface DataRendererProps extends ParentRendererProps {
|
|
|
308
307
|
displayOnly: boolean;
|
|
309
308
|
inline: boolean;
|
|
310
309
|
}
|
|
311
|
-
export interface ActionRendererProps {
|
|
312
|
-
actionId: string;
|
|
313
|
-
actionText: string;
|
|
314
|
-
actionData?: any;
|
|
315
|
-
actionStyle?: ActionStyle;
|
|
316
|
-
icon?: IconReference | null;
|
|
317
|
-
iconPlacement?: IconPlacement;
|
|
318
|
-
onClick: () => void;
|
|
319
|
-
className?: string | null;
|
|
320
|
-
textClass?: string | null;
|
|
321
|
-
style?: React.CSSProperties;
|
|
322
|
-
disabled?: boolean;
|
|
323
|
-
inline?: boolean;
|
|
324
|
-
}
|
|
325
310
|
export interface ControlRenderProps {
|
|
326
311
|
control: Control<any>;
|
|
327
312
|
parentPath?: JsonPath[];
|
|
328
313
|
}
|
|
329
|
-
export interface FormContextOptions {
|
|
330
|
-
readonly?: boolean | null;
|
|
331
|
-
hidden?: boolean | null;
|
|
332
|
-
disabled?: boolean | null;
|
|
333
|
-
displayOnly?: boolean;
|
|
334
|
-
inline?: boolean;
|
|
335
|
-
}
|
|
336
314
|
export type CreateDataProps = (controlProps: RenderLayoutProps, definition: DataControlDefinition, control: Control<any>) => DataRendererProps;
|
|
337
|
-
export interface ControlRenderOptions extends
|
|
315
|
+
export interface ControlRenderOptions extends ControlClasses {
|
|
316
|
+
formState?: FormState;
|
|
338
317
|
useDataHook?: (c: ControlDefinition) => CreateDataProps;
|
|
339
318
|
actionOnClick?: ControlActionHandler;
|
|
340
319
|
customDisplay?: (customId: string, displayProps: DisplayRendererProps) => ReactNode;
|
|
341
|
-
useValidationHook?: (validator: SchemaValidator, ctx: ValidationContext) => void;
|
|
342
|
-
useEvalExpressionHook?: UseEvalExpressionHook;
|
|
343
320
|
adjustLayout?: (context: ControlDataContext, layout: ControlLayoutProps) => ControlLayoutProps;
|
|
321
|
+
readonly?: boolean | null;
|
|
322
|
+
hidden?: boolean | null;
|
|
323
|
+
disabled?: boolean | null;
|
|
324
|
+
displayOnly?: boolean;
|
|
325
|
+
inline?: boolean;
|
|
344
326
|
clearHidden?: boolean;
|
|
327
|
+
stateKey?: string;
|
|
345
328
|
schemaInterface?: SchemaInterface;
|
|
346
|
-
|
|
329
|
+
variables?: Record<string, any>;
|
|
347
330
|
}
|
|
348
|
-
export declare function
|
|
349
|
-
export declare function useControlRendererComponent(controlOrFormNode: ControlDefinition | FormNode, renderer: FormRenderer, options: ControlRenderOptions | undefined, parentDataNode: SchemaDataNode): FC<{}>;
|
|
350
|
-
export declare function ControlRenderer({ definition, fields, renderer, options, control, parentPath, }: {
|
|
351
|
-
definition: ControlDefinition;
|
|
352
|
-
fields: SchemaField[];
|
|
353
|
-
renderer: FormRenderer;
|
|
354
|
-
options?: ControlRenderOptions;
|
|
355
|
-
control: Control<any>;
|
|
356
|
-
parentPath?: JsonPath[];
|
|
357
|
-
}): JSX.Element;
|
|
358
|
-
export declare function NewControlRenderer({ definition, renderer, options, parentDataNode, }: {
|
|
359
|
-
definition: ControlDefinition | FormNode;
|
|
360
|
-
renderer: FormRenderer;
|
|
361
|
-
options?: ControlRenderOptions;
|
|
362
|
-
parentDataNode: SchemaDataNode;
|
|
363
|
-
}): JSX.Element;
|
|
364
|
-
export declare function defaultDataProps({ formOptions, style, allowedOptions, schemaInterface, styleClass, textClass: tc, ...props }: RenderLayoutProps, definition: DataControlDefinition, control: Control<any>): DataRendererProps;
|
|
331
|
+
export declare function defaultDataProps({ formOptions, style, allowedOptions, schemaInterface, styleClass, textClass: tc, displayOnly, inline, ...props }: RenderLayoutProps, definition: DataControlDefinition, control: Control<any>): DataRendererProps;
|
|
365
332
|
export interface ChildRendererOptions {
|
|
366
333
|
parentDataNode?: SchemaDataNode;
|
|
367
|
-
formData?: FormContextData;
|
|
368
334
|
inline?: boolean;
|
|
369
335
|
displayOnly?: boolean;
|
|
370
336
|
styleClass?: string;
|
|
371
337
|
layoutClass?: string;
|
|
372
338
|
labelClass?: string;
|
|
339
|
+
labelTextClass?: string;
|
|
340
|
+
actionOnClick?: ControlActionHandler;
|
|
341
|
+
stateKey?: string;
|
|
342
|
+
variables?: Record<string, any>;
|
|
373
343
|
}
|
|
374
344
|
export type ChildRenderer = (k: Key, child: FormNode, options?: ChildRendererOptions) => ReactNode;
|
|
375
345
|
export interface RenderLayoutProps {
|
|
376
346
|
formNode: FormNode;
|
|
377
347
|
renderer: FormRenderer;
|
|
348
|
+
state: ControlState;
|
|
378
349
|
renderChild: ChildRenderer;
|
|
379
350
|
createDataProps: CreateDataProps;
|
|
380
351
|
formOptions: FormContextOptions;
|
|
381
352
|
dataContext: ControlDataContext;
|
|
382
353
|
control?: Control<any>;
|
|
383
|
-
labelText?: Control<string | null | undefined>;
|
|
384
|
-
displayControl?: Control<string | undefined>;
|
|
385
354
|
style?: React.CSSProperties;
|
|
386
|
-
allowedOptions?:
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
useEvalExpression: UseEvalExpressionHook;
|
|
355
|
+
allowedOptions?: any[];
|
|
356
|
+
getChildState(node: FormNode, parent?: SchemaDataNode): ControlState;
|
|
357
|
+
runExpression: RunExpression;
|
|
390
358
|
actionOnClick?: ControlActionHandler;
|
|
391
359
|
schemaInterface?: SchemaInterface;
|
|
392
360
|
designMode?: boolean;
|
|
@@ -395,6 +363,8 @@ export interface RenderLayoutProps {
|
|
|
395
363
|
labelTextClass?: string;
|
|
396
364
|
styleClass?: string;
|
|
397
365
|
textClass?: string;
|
|
366
|
+
inline?: boolean;
|
|
367
|
+
displayOnly?: boolean;
|
|
398
368
|
}
|
|
399
369
|
export declare function renderControlLayout(props: RenderLayoutProps): ControlLayoutProps;
|
|
400
370
|
type MarkupKeys = keyof Omit<RenderedLayout, "errorControl" | "style" | "className" | "wrapLayout" | "readonly" | "disabled" | "inline">;
|
|
@@ -415,5 +385,6 @@ export declare function applyArrayLengthRestrictions({ arrayControl, min, max, e
|
|
|
415
385
|
addDisabled: boolean;
|
|
416
386
|
removeDisabled: boolean;
|
|
417
387
|
};
|
|
418
|
-
export declare function fieldOptionAdornment(p: DataRendererProps): (o: FieldOption,
|
|
388
|
+
export declare function fieldOptionAdornment(p: DataRendererProps): (o: FieldOption, fieldIndex: number, selected: boolean) => JSX.Element;
|
|
389
|
+
export declare function lookupChildDataContext(dataContext: ControlDataContext, c: ControlDefinition): ControlDataContext;
|
|
419
390
|
export {};
|