@react-typed-forms/schemas 5.0.3 → 6.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/controlBuilder.d.ts +2 -2
- package/lib/controlRender.d.ts +63 -16
- package/lib/hooks.d.ts +10 -6
- package/lib/index.d.ts +1 -0
- package/lib/index.js +433 -162
- package/lib/index.js.map +1 -1
- package/lib/internal.d.ts +1 -0
- package/lib/renderers.d.ts +20 -10
- package/lib/schemaInterface.d.ts +4 -0
- package/lib/types.d.ts +47 -8
- package/lib/util.d.ts +7 -5
- package/lib/validators.d.ts +2 -2
- package/package.json +2 -2
- package/src/controlBuilder.ts +3 -3
- package/src/controlRender.tsx +198 -82
- package/src/hooks.tsx +101 -16
- package/src/index.ts +1 -0
- package/src/internal.ts +4 -0
- package/src/renderers.tsx +196 -65
- package/src/schemaInterface.ts +31 -0
- package/src/tailwind.tsx +5 -1
- package/src/types.ts +61 -5
- package/src/util.ts +24 -8
- package/src/validators.ts +3 -3
package/lib/controlBuilder.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ControlDefinition, DataControlDefinition, DisplayControlDefinition, DynamicProperty, EntityExpression,
|
|
1
|
+
import { ControlDefinition, DataControlDefinition, DataMatchExpression, DisplayControlDefinition, DynamicProperty, EntityExpression, GroupedControlsDefinition, JsonataExpression, SchemaField } from "./types";
|
|
2
2
|
import { ActionRendererProps } from "./controlRender";
|
|
3
3
|
export declare function dataControl(field: string, title?: string | null, options?: Partial<DataControlDefinition>): DataControlDefinition;
|
|
4
4
|
export declare function textDisplayControl(text: string, options?: Partial<DisplayControlDefinition>): DisplayControlDefinition;
|
|
@@ -7,7 +7,7 @@ export declare function dynamicDefaultValue(expr: EntityExpression): DynamicProp
|
|
|
7
7
|
export declare function dynamicReadonly(expr: EntityExpression): DynamicProperty;
|
|
8
8
|
export declare function dynamicVisibility(expr: EntityExpression): DynamicProperty;
|
|
9
9
|
export declare function dynamicDisabled(expr: EntityExpression): DynamicProperty;
|
|
10
|
-
export declare function fieldEqExpr(field: string, value: any):
|
|
10
|
+
export declare function fieldEqExpr(field: string, value: any): DataMatchExpression;
|
|
11
11
|
export declare function jsonataExpr(expression: string): JsonataExpression;
|
|
12
12
|
export declare function groupedControl(children: ControlDefinition[], title?: string, options?: Partial<GroupedControlsDefinition>): GroupedControlsDefinition;
|
|
13
13
|
export declare function compoundControl(field: string, title: string | undefined, children: ControlDefinition[], options?: Partial<DataControlDefinition>): DataControlDefinition;
|
package/lib/controlRender.d.ts
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import { FC, Key, ReactNode } from "react";
|
|
1
|
+
import React, { FC, Key, ReactNode } from "react";
|
|
2
2
|
import { Control } from "@react-typed-forms/core";
|
|
3
|
-
import { AdornmentPlacement, ControlAdornment, ControlDefinition, DataControlDefinition, DisplayData, FieldOption, GroupRenderOptions, RenderOptions, SchemaField } from "./types";
|
|
4
|
-
import {
|
|
3
|
+
import { AdornmentPlacement, ControlAdornment, ControlDefinition, DataControlDefinition, DisplayData, FieldOption, GroupRenderOptions, RenderOptions, SchemaField, SchemaInterface } from "./types";
|
|
4
|
+
import { ControlDataContext } from "./util";
|
|
5
5
|
import { UseEvalExpressionHook } from "./hooks";
|
|
6
6
|
export interface FormRenderer {
|
|
7
7
|
renderData: (props: DataRendererProps, asArray: (() => ReactNode) | undefined) => (layout: ControlLayoutProps) => ControlLayoutProps;
|
|
8
|
-
renderGroup: (props: GroupRendererProps) =>
|
|
8
|
+
renderGroup: (props: GroupRendererProps) => (layout: ControlLayoutProps) => ControlLayoutProps;
|
|
9
9
|
renderDisplay: (props: DisplayRendererProps) => ReactNode;
|
|
10
10
|
renderAction: (props: ActionRendererProps) => ReactNode;
|
|
11
11
|
renderArray: (props: ArrayRendererProps) => ReactNode;
|
|
12
12
|
renderAdornment: (props: AdornmentProps) => AdornmentRenderer;
|
|
13
13
|
renderLabel: (props: LabelRendererProps, labelStart: ReactNode, labelEnd: ReactNode) => ReactNode;
|
|
14
|
-
renderLayout: (props: ControlLayoutProps) =>
|
|
15
|
-
renderVisibility: (
|
|
16
|
-
}
|
|
17
|
-
export interface DisplayRendererProps {
|
|
18
|
-
data: DisplayData;
|
|
14
|
+
renderLayout: (props: ControlLayoutProps) => RenderedControl;
|
|
15
|
+
renderVisibility: (props: VisibilityRendererProps) => ReactNode;
|
|
19
16
|
}
|
|
20
17
|
export interface AdornmentProps {
|
|
21
18
|
adornment: ControlAdornment;
|
|
@@ -35,6 +32,8 @@ export interface ArrayRendererProps {
|
|
|
35
32
|
renderChild: (childIndex: number) => ReactNode;
|
|
36
33
|
childKey: (childIndex: number) => Key;
|
|
37
34
|
arrayControl?: Control<any[] | undefined | null>;
|
|
35
|
+
className?: string;
|
|
36
|
+
style?: React.CSSProperties;
|
|
38
37
|
}
|
|
39
38
|
export interface Visibility {
|
|
40
39
|
visible: boolean;
|
|
@@ -48,6 +47,17 @@ export interface RenderedLayout {
|
|
|
48
47
|
label?: ReactNode;
|
|
49
48
|
children?: ReactNode;
|
|
50
49
|
errorControl?: Control<any>;
|
|
50
|
+
className?: string;
|
|
51
|
+
style?: React.CSSProperties;
|
|
52
|
+
}
|
|
53
|
+
export interface RenderedControl {
|
|
54
|
+
children: ReactNode;
|
|
55
|
+
className?: string;
|
|
56
|
+
style?: React.CSSProperties;
|
|
57
|
+
divRef?: (cb: HTMLElement | null) => void;
|
|
58
|
+
}
|
|
59
|
+
export interface VisibilityRendererProps extends RenderedControl {
|
|
60
|
+
visibility: Control<Visibility | undefined>;
|
|
51
61
|
}
|
|
52
62
|
export interface ControlLayoutProps {
|
|
53
63
|
label?: LabelRendererProps;
|
|
@@ -55,6 +65,8 @@ export interface ControlLayoutProps {
|
|
|
55
65
|
adornments?: AdornmentRenderer[];
|
|
56
66
|
children?: ReactNode;
|
|
57
67
|
processLayout?: (props: ControlLayoutProps) => ControlLayoutProps;
|
|
68
|
+
className?: string | null;
|
|
69
|
+
style?: React.CSSProperties;
|
|
58
70
|
}
|
|
59
71
|
export declare enum LabelType {
|
|
60
72
|
Control = 0,
|
|
@@ -67,10 +79,18 @@ export interface LabelRendererProps {
|
|
|
67
79
|
required?: boolean | null;
|
|
68
80
|
forId?: string;
|
|
69
81
|
}
|
|
82
|
+
export interface DisplayRendererProps {
|
|
83
|
+
data: DisplayData;
|
|
84
|
+
display?: Control<string | undefined>;
|
|
85
|
+
className?: string;
|
|
86
|
+
style?: React.CSSProperties;
|
|
87
|
+
}
|
|
70
88
|
export interface GroupRendererProps {
|
|
71
89
|
renderOptions: GroupRenderOptions;
|
|
72
90
|
childCount: number;
|
|
73
91
|
renderChild: (child: number) => ReactNode;
|
|
92
|
+
className?: string;
|
|
93
|
+
style?: React.CSSProperties;
|
|
74
94
|
}
|
|
75
95
|
export interface DataRendererProps {
|
|
76
96
|
renderOptions: RenderOptions;
|
|
@@ -81,11 +101,16 @@ export interface DataRendererProps {
|
|
|
81
101
|
required: boolean;
|
|
82
102
|
options: FieldOption[] | undefined | null;
|
|
83
103
|
hidden: boolean;
|
|
104
|
+
className?: string;
|
|
105
|
+
style?: React.CSSProperties;
|
|
106
|
+
dataContext: ControlDataContext;
|
|
84
107
|
}
|
|
85
108
|
export interface ActionRendererProps {
|
|
86
109
|
actionId: string;
|
|
87
110
|
actionText: string;
|
|
88
111
|
onClick: () => void;
|
|
112
|
+
className?: string;
|
|
113
|
+
style?: React.CSSProperties;
|
|
89
114
|
}
|
|
90
115
|
export interface ControlRenderProps {
|
|
91
116
|
control: Control<any>;
|
|
@@ -95,21 +120,43 @@ export interface FormContextOptions {
|
|
|
95
120
|
hidden?: boolean | null;
|
|
96
121
|
disabled?: boolean | null;
|
|
97
122
|
}
|
|
98
|
-
export
|
|
123
|
+
export interface DataControlProps {
|
|
124
|
+
definition: DataControlDefinition;
|
|
125
|
+
field: SchemaField;
|
|
126
|
+
dataContext: ControlDataContext;
|
|
127
|
+
control: Control<any>;
|
|
128
|
+
options: FormContextOptions;
|
|
129
|
+
style: React.CSSProperties | undefined;
|
|
130
|
+
}
|
|
131
|
+
export type CreateDataProps = (controlProps: DataControlProps) => DataRendererProps;
|
|
99
132
|
export interface ControlRenderOptions extends FormContextOptions {
|
|
100
133
|
useDataHook?: (c: ControlDefinition) => CreateDataProps;
|
|
101
134
|
useEvalExpressionHook?: UseEvalExpressionHook;
|
|
102
135
|
clearHidden?: boolean;
|
|
136
|
+
schemaInterface?: SchemaInterface;
|
|
103
137
|
}
|
|
104
138
|
export declare function useControlRenderer(definition: ControlDefinition, fields: SchemaField[], renderer: FormRenderer, options?: ControlRenderOptions): FC<ControlRenderProps>;
|
|
105
139
|
export declare function lookupSchemaField(c: ControlDefinition, fields: SchemaField[]): SchemaField | undefined;
|
|
106
|
-
export declare function getControlData(schemaField: SchemaField | undefined, parentContext:
|
|
107
|
-
export declare
|
|
140
|
+
export declare function getControlData(schemaField: SchemaField | undefined, parentContext: ControlDataContext): [Control<any> | undefined, ControlDataContext];
|
|
141
|
+
export declare function defaultDataProps({ definition, field, dataContext, control, options, style, }: DataControlProps): DataRendererProps;
|
|
108
142
|
export type ChildRenderer = (k: Key, childIndex: number, props: ControlRenderProps) => ReactNode;
|
|
109
|
-
export
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
143
|
+
export interface RenderControlProps {
|
|
144
|
+
definition: ControlDefinition;
|
|
145
|
+
renderer: FormRenderer;
|
|
146
|
+
childCount: number;
|
|
147
|
+
renderChild: ChildRenderer;
|
|
148
|
+
createDataProps: CreateDataProps;
|
|
149
|
+
formOptions: FormContextOptions;
|
|
150
|
+
dataContext: ControlDataContext;
|
|
151
|
+
control?: Control<any>;
|
|
152
|
+
schemaField?: SchemaField;
|
|
153
|
+
displayControl?: Control<string | undefined>;
|
|
154
|
+
style?: React.CSSProperties;
|
|
155
|
+
}
|
|
156
|
+
export declare function renderControlLayout({ definition: c, renderer, childCount, renderChild: childRenderer, control: childControl, schemaField, dataContext, formOptions: dataOptions, createDataProps: dataProps, displayControl, style, }: RenderControlProps): ControlLayoutProps;
|
|
157
|
+
export declare function appendMarkup(k: keyof Omit<RenderedLayout, "errorControl" | "style" | "className">, markup: ReactNode): (layout: RenderedLayout) => void;
|
|
158
|
+
export declare function wrapMarkup(k: keyof Omit<RenderedLayout, "errorControl" | "style" | "className">, wrap: (ex: ReactNode) => ReactNode): (layout: RenderedLayout) => void;
|
|
159
|
+
export declare function layoutKeyForPlacement(pos: AdornmentPlacement): keyof Omit<RenderedLayout, "errorControl" | "style" | "className">;
|
|
113
160
|
export declare function appendMarkupAt(pos: AdornmentPlacement, markup: ReactNode): (layout: RenderedLayout) => void;
|
|
114
161
|
export declare function wrapMarkupAt(pos: AdornmentPlacement, wrap: (ex: ReactNode) => ReactNode): (layout: RenderedLayout) => void;
|
|
115
162
|
export declare function renderLayoutParts(props: ControlLayoutProps, renderer: FormRenderer): RenderedLayout;
|
package/lib/hooks.d.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ControlDefinition, DynamicPropertyType, EntityExpression, SchemaField, SchemaInterface } from "./types";
|
|
2
3
|
import { Control } from "@react-typed-forms/core";
|
|
3
|
-
import {
|
|
4
|
+
import { ControlDataContext } from "./util";
|
|
4
5
|
export type UseEvalExpressionHook = (expr: EntityExpression | undefined) => EvalExpressionHook | undefined;
|
|
5
6
|
export declare function useEvalVisibilityHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition, schemaField?: SchemaField): EvalExpressionHook<boolean>;
|
|
6
7
|
export declare function useEvalReadonlyHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition): EvalExpressionHook<boolean>;
|
|
8
|
+
export declare function useEvalStyleHook(useEvalExpressionHook: UseEvalExpressionHook, property: DynamicPropertyType, definition: ControlDefinition): EvalExpressionHook<React.CSSProperties>;
|
|
7
9
|
export declare function useEvalDisabledHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition): EvalExpressionHook<boolean>;
|
|
10
|
+
export declare function useEvalDisplayHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition): (groupContext: ControlDataContext) => Control<string | undefined> | undefined;
|
|
8
11
|
export declare function useEvalDefaultValueHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition, schemaField?: SchemaField): EvalExpressionHook;
|
|
9
|
-
export type EvalExpressionHook<A = any> = (groupContext:
|
|
10
|
-
export declare function defaultEvalHooks(expr: EntityExpression, context:
|
|
12
|
+
export type EvalExpressionHook<A = any> = (groupContext: ControlDataContext) => Control<A | undefined>;
|
|
13
|
+
export declare function defaultEvalHooks(expr: EntityExpression, context: ControlDataContext): Control<any>;
|
|
11
14
|
export declare const defaultUseEvalExpressionHook: (expr: EntityExpression | undefined) => EvalExpressionHook | undefined;
|
|
12
|
-
export declare function makeEvalExpressionHook(f: (expr: EntityExpression, context:
|
|
15
|
+
export declare function makeEvalExpressionHook(f: (expr: EntityExpression, context: ControlDataContext) => Control<any>): (expr: EntityExpression | undefined) => EvalExpressionHook | undefined;
|
|
13
16
|
export declare function useEvalDynamicHook(definition: ControlDefinition, type: DynamicPropertyType, useEvalExpressionHook: (expr: EntityExpression | undefined) => EvalExpressionHook | undefined): EvalExpressionHook | undefined;
|
|
14
|
-
export declare function matchesType(context:
|
|
17
|
+
export declare function matchesType(context: ControlDataContext, types?: string[] | null): boolean | undefined;
|
|
18
|
+
export declare function hideDisplayOnly(context: ControlDataContext, field: SchemaField, definition: ControlDefinition, schemaInterface: SchemaInterface): boolean | undefined;
|
|
15
19
|
export declare function useJsonataExpression(jExpr: string, data: Control<any>): Control<any>;
|
package/lib/index.d.ts
CHANGED