@react-typed-forms/schemas 9.2.0 → 10.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/components/DefaultArrayRenderer.d.ts +16 -0
- package/lib/controlRender.d.ts +31 -20
- package/lib/createDefaultRenderers.d.ts +2 -10
- package/lib/hooks.d.ts +2 -3
- package/lib/index.js +275 -214
- package/lib/index.js.map +1 -1
- package/lib/schemaInterface.d.ts +7 -2
- package/lib/types.d.ts +10 -1
- package/lib/util.d.ts +7 -1
- package/lib/validators.d.ts +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ArrayRendererRegistration } from "../renderers";
|
|
2
|
+
import { ActionRendererProps, ArrayRendererProps } from "../controlRender";
|
|
3
|
+
import React, { ReactNode } from "react";
|
|
4
|
+
export interface DefaultArrayRendererOptions {
|
|
5
|
+
className?: string;
|
|
6
|
+
removableClass?: string;
|
|
7
|
+
childClass?: string;
|
|
8
|
+
removableChildClass?: string;
|
|
9
|
+
removeActionClass?: string;
|
|
10
|
+
addActionClass?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function createDefaultArrayRenderer(options?: DefaultArrayRendererOptions): ArrayRendererRegistration;
|
|
13
|
+
export interface DefaultArrayRendererProps extends DefaultArrayRendererOptions, ArrayRendererProps {
|
|
14
|
+
renderAction: (props: ActionRendererProps) => ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export declare function DefaultArrayRenderer(props: DefaultArrayRendererProps): React.JSX.Element;
|
package/lib/controlRender.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { CSSProperties, FC, Key, ReactNode } from "react";
|
|
2
2
|
import { Control } from "@react-typed-forms/core";
|
|
3
3
|
import { AdornmentPlacement, ControlAdornment, ControlDefinition, DataControlDefinition, DisplayData, FieldOption, GroupRenderOptions, RenderOptions, SchemaField, SchemaInterface } from "./types";
|
|
4
|
-
import { ControlDataContext } from "./util";
|
|
4
|
+
import { ControlDataContext, JsonPath } from "./util";
|
|
5
5
|
import { EvalExpressionHook, UseEvalExpressionHook } from "./hooks";
|
|
6
6
|
export interface FormRenderer {
|
|
7
7
|
renderData: (props: DataRendererProps) => (layout: ControlLayoutProps) => ControlLayoutProps;
|
|
@@ -28,12 +28,12 @@ export interface ArrayRendererProps {
|
|
|
28
28
|
addAction?: ActionRendererProps;
|
|
29
29
|
required: boolean;
|
|
30
30
|
removeAction?: (elemIndex: number) => ActionRendererProps;
|
|
31
|
-
elementCount: number;
|
|
32
31
|
renderElement: (elemIndex: number) => ReactNode;
|
|
33
|
-
elementKey: (elemIndex: number) => Key;
|
|
34
32
|
arrayControl: Control<any[] | undefined | null>;
|
|
35
33
|
className?: string;
|
|
36
34
|
style?: React.CSSProperties;
|
|
35
|
+
min?: number | null;
|
|
36
|
+
max?: number | null;
|
|
37
37
|
}
|
|
38
38
|
export interface Visibility {
|
|
39
39
|
visible: boolean;
|
|
@@ -87,21 +87,25 @@ export interface DisplayRendererProps {
|
|
|
87
87
|
className?: string;
|
|
88
88
|
style?: React.CSSProperties;
|
|
89
89
|
}
|
|
90
|
+
export type ChildVisibilityFunc = (child: ControlDefinition, context?: ControlDataContext) => EvalExpressionHook<boolean>;
|
|
90
91
|
export interface ParentRendererProps {
|
|
91
92
|
childDefinitions: ControlDefinition[];
|
|
92
93
|
renderChild: ChildRenderer;
|
|
93
94
|
className?: string;
|
|
94
95
|
style?: React.CSSProperties;
|
|
95
96
|
dataContext: ControlDataContext;
|
|
96
|
-
|
|
97
|
+
parentContext: ControlDataContext;
|
|
98
|
+
useChildVisibility: ChildVisibilityFunc;
|
|
97
99
|
}
|
|
98
100
|
export interface GroupRendererProps extends ParentRendererProps {
|
|
101
|
+
definition: ControlDefinition;
|
|
99
102
|
renderOptions: GroupRenderOptions;
|
|
100
103
|
}
|
|
101
104
|
export interface DataRendererProps extends ParentRendererProps {
|
|
102
105
|
renderOptions: RenderOptions;
|
|
103
106
|
definition: DataControlDefinition;
|
|
104
107
|
field: SchemaField;
|
|
108
|
+
elementIndex?: number;
|
|
105
109
|
id: string;
|
|
106
110
|
control: Control<any>;
|
|
107
111
|
readonly: boolean;
|
|
@@ -130,29 +134,26 @@ export interface DataControlProps {
|
|
|
130
134
|
definition: DataControlDefinition;
|
|
131
135
|
field: SchemaField;
|
|
132
136
|
dataContext: ControlDataContext;
|
|
137
|
+
parentContext: ControlDataContext;
|
|
133
138
|
control: Control<any>;
|
|
134
|
-
|
|
135
|
-
style
|
|
139
|
+
formOptions: FormContextOptions;
|
|
140
|
+
style?: React.CSSProperties | undefined;
|
|
136
141
|
renderChild: ChildRenderer;
|
|
142
|
+
elementIndex?: number;
|
|
137
143
|
allowedOptions?: Control<any[] | undefined>;
|
|
138
|
-
|
|
139
|
-
useChildVisibility: (child: number | number[]) => EvalExpressionHook<boolean>;
|
|
144
|
+
useChildVisibility: ChildVisibilityFunc;
|
|
140
145
|
}
|
|
141
146
|
export type CreateDataProps = (controlProps: DataControlProps) => DataRendererProps;
|
|
142
|
-
export type JsonPath = string | number;
|
|
143
|
-
export interface DataContext {
|
|
144
|
-
data: Control<any>;
|
|
145
|
-
path: JsonPath[];
|
|
146
|
-
}
|
|
147
147
|
export interface ControlRenderOptions extends FormContextOptions {
|
|
148
148
|
useDataHook?: (c: ControlDefinition) => CreateDataProps;
|
|
149
149
|
useEvalExpressionHook?: UseEvalExpressionHook;
|
|
150
150
|
clearHidden?: boolean;
|
|
151
151
|
schemaInterface?: SchemaInterface;
|
|
152
|
+
elementIndex?: number;
|
|
152
153
|
}
|
|
153
154
|
export declare function useControlRenderer(definition: ControlDefinition, fields: SchemaField[], renderer: FormRenderer, options?: ControlRenderOptions): FC<ControlRenderProps>;
|
|
154
155
|
export declare function lookupSchemaField(c: ControlDefinition, fields: SchemaField[]): SchemaField | undefined;
|
|
155
|
-
export declare function getControlData(schemaField: SchemaField | undefined, parentContext: ControlDataContext): [Control<any> | undefined, Control<any> | undefined, ControlDataContext];
|
|
156
|
+
export declare function getControlData(schemaField: SchemaField | undefined, parentContext: ControlDataContext, elementIndex: number | undefined): [Control<any> | undefined, Control<any> | undefined, ControlDataContext];
|
|
156
157
|
export declare function ControlRenderer({ definition, fields, renderer, options, control, parentPath, }: {
|
|
157
158
|
definition: ControlDefinition;
|
|
158
159
|
fields: SchemaField[];
|
|
@@ -161,9 +162,13 @@ export declare function ControlRenderer({ definition, fields, renderer, options,
|
|
|
161
162
|
control: Control<any>;
|
|
162
163
|
parentPath?: JsonPath[];
|
|
163
164
|
}): React.JSX.Element;
|
|
164
|
-
export declare function defaultDataProps({ definition, field, control,
|
|
165
|
-
export declare function defaultArrayProps(arrayControl: Control<any[] | undefined | null>, field: SchemaField, required: boolean, style: CSSProperties | undefined, className: string | undefined, renderElement: (elemIndex: number) => ReactNode): ArrayRendererProps;
|
|
166
|
-
export
|
|
165
|
+
export declare function defaultDataProps({ definition, field, control, formOptions, style, allowedOptions, ...props }: DataControlProps): DataRendererProps;
|
|
166
|
+
export declare function defaultArrayProps(arrayControl: Control<any[] | undefined | null>, field: SchemaField, required: boolean, style: CSSProperties | undefined, className: string | undefined, renderElement: (elemIndex: number) => ReactNode, min: number | undefined | null, max: number | undefined | null): ArrayRendererProps;
|
|
167
|
+
export interface ChildRendererOptions {
|
|
168
|
+
elementIndex?: number;
|
|
169
|
+
dataContext?: ControlDataContext;
|
|
170
|
+
}
|
|
171
|
+
export type ChildRenderer = (k: Key, child: ControlDefinition, options?: ChildRendererOptions) => ReactNode;
|
|
167
172
|
export interface RenderControlProps {
|
|
168
173
|
definition: ControlDefinition;
|
|
169
174
|
renderer: FormRenderer;
|
|
@@ -171,15 +176,17 @@ export interface RenderControlProps {
|
|
|
171
176
|
createDataProps: CreateDataProps;
|
|
172
177
|
formOptions: FormContextOptions;
|
|
173
178
|
dataContext: ControlDataContext;
|
|
179
|
+
parentContext: ControlDataContext;
|
|
174
180
|
control?: Control<any>;
|
|
175
181
|
labelText?: Control<string | null | undefined>;
|
|
176
|
-
|
|
182
|
+
field?: SchemaField;
|
|
183
|
+
elementIndex?: number;
|
|
177
184
|
displayControl?: Control<string | undefined>;
|
|
178
185
|
style?: React.CSSProperties;
|
|
179
186
|
allowedOptions?: Control<any[] | undefined>;
|
|
180
|
-
useChildVisibility:
|
|
187
|
+
useChildVisibility: ChildVisibilityFunc;
|
|
181
188
|
}
|
|
182
|
-
export declare function renderControlLayout(
|
|
189
|
+
export declare function renderControlLayout(props: RenderControlProps): ControlLayoutProps;
|
|
183
190
|
export declare function appendMarkup(k: keyof Omit<RenderedLayout, "errorControl" | "style" | "className">, markup: ReactNode): (layout: RenderedLayout) => void;
|
|
184
191
|
export declare function wrapMarkup(k: keyof Omit<RenderedLayout, "errorControl" | "style" | "className">, wrap: (ex: ReactNode) => ReactNode): (layout: RenderedLayout) => void;
|
|
185
192
|
export declare function layoutKeyForPlacement(pos: AdornmentPlacement): keyof Omit<RenderedLayout, "errorControl" | "style" | "className">;
|
|
@@ -187,3 +194,7 @@ export declare function appendMarkupAt(pos: AdornmentPlacement, markup: ReactNod
|
|
|
187
194
|
export declare function wrapMarkupAt(pos: AdornmentPlacement, wrap: (ex: ReactNode) => ReactNode): (layout: RenderedLayout) => void;
|
|
188
195
|
export declare function renderLayoutParts(props: ControlLayoutProps, renderer: FormRenderer): RenderedLayout;
|
|
189
196
|
export declare function controlTitle(title: string | undefined | null, field: SchemaField): string;
|
|
197
|
+
export declare function applyArrayLengthRestrictions({ arrayControl, min, max, addAction: aa, removeAction: ra, required, }: Pick<ArrayRendererProps, "addAction" | "removeAction" | "arrayControl" | "min" | "max" | "required">, disable?: boolean): Pick<ArrayRendererProps, "addAction" | "removeAction"> & {
|
|
198
|
+
addDisabled: boolean;
|
|
199
|
+
removeDisabled: boolean;
|
|
200
|
+
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { DefaultDisplayRendererOptions } from "./components/DefaultDisplay";
|
|
2
2
|
import { DefaultLayoutRendererOptions } from "./components/DefaultLayout";
|
|
3
|
-
import { ActionRendererRegistration, AdornmentRendererRegistration,
|
|
3
|
+
import { ActionRendererRegistration, AdornmentRendererRegistration, DataRendererRegistration, DefaultRenderers, GroupRendererRegistration, LabelRendererRegistration } from "./renderers";
|
|
4
4
|
import { CSSProperties, ReactElement, ReactNode } from "react";
|
|
5
5
|
import { FieldOption, GridRenderer } from "./types";
|
|
6
6
|
import { SelectRendererOptions } from "./components/SelectDataRenderer";
|
|
7
7
|
import { RadioRendererOptions } from "./components/RadioRenderer";
|
|
8
|
+
import { DefaultArrayRendererOptions } from "./components/DefaultArrayRenderer";
|
|
8
9
|
export interface DefaultRendererOptions {
|
|
9
10
|
data?: DefaultDataRendererOptions;
|
|
10
11
|
display?: DefaultDisplayRendererOptions;
|
|
@@ -23,15 +24,6 @@ interface DefaultActionRendererOptions {
|
|
|
23
24
|
className?: string;
|
|
24
25
|
}
|
|
25
26
|
export declare function createDefaultActionRenderer(options?: DefaultActionRendererOptions): ActionRendererRegistration;
|
|
26
|
-
interface DefaultArrayRendererOptions {
|
|
27
|
-
className?: string;
|
|
28
|
-
removableClass?: string;
|
|
29
|
-
childClass?: string;
|
|
30
|
-
removableChildClass?: string;
|
|
31
|
-
removeActionClass?: string;
|
|
32
|
-
addActionClass?: string;
|
|
33
|
-
}
|
|
34
|
-
export declare function createDefaultArrayRenderer(options?: DefaultArrayRendererOptions): ArrayRendererRegistration;
|
|
35
27
|
interface DefaultGroupRendererOptions {
|
|
36
28
|
className?: string;
|
|
37
29
|
standardClassName?: string;
|
package/lib/hooks.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ControlDefinition, DynamicPropertyType, EntityExpression, SchemaField, SchemaInterface } from "./types";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { Control } from "@react-typed-forms/core";
|
|
4
|
-
import { ControlDataContext, DynamicHookGenerator } from "./util";
|
|
5
|
-
import { DataContext } from "./controlRender";
|
|
4
|
+
import { ControlDataContext, DataContext, DynamicHookGenerator } from "./util";
|
|
6
5
|
export type EvalExpressionHook<A = any> = DynamicHookGenerator<Control<A | undefined>, ControlDataContext>;
|
|
7
6
|
export type UseEvalExpressionHook = (expr: EntityExpression | undefined) => DynamicHookGenerator<Control<any> | undefined, ControlDataContext>;
|
|
8
7
|
export declare function useEvalVisibilityHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition, schemaField?: SchemaField): EvalExpressionHook<boolean>;
|
|
@@ -11,7 +10,7 @@ export declare function useEvalStyleHook(useEvalExpressionHook: UseEvalExpressio
|
|
|
11
10
|
export declare function useEvalAllowedOptionsHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition): EvalExpressionHook<any[]>;
|
|
12
11
|
export declare function useEvalDisabledHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition): EvalExpressionHook<boolean>;
|
|
13
12
|
export declare function useEvalDisplayHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition): DynamicHookGenerator<Control<string | undefined> | undefined, ControlDataContext>;
|
|
14
|
-
export declare function useEvalDefaultValueHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition, schemaField
|
|
13
|
+
export declare function useEvalDefaultValueHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition, schemaField: SchemaField | undefined, element: boolean): EvalExpressionHook;
|
|
15
14
|
export declare function defaultEvalHooks(expr: EntityExpression, context: ControlDataContext): Control<any>;
|
|
16
15
|
export declare const defaultUseEvalExpressionHook: UseEvalExpressionHook;
|
|
17
16
|
export declare function makeEvalExpressionHook(f: (expr: EntityExpression, context: ControlDataContext) => Control<any>): UseEvalExpressionHook;
|