@react-typed-forms/schemas 9.1.1 → 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/ControlInput.d.ts +9 -0
- package/lib/components/DefaultArrayRenderer.d.ts +16 -0
- package/lib/components/DefaultDisplay.d.ts +9 -0
- package/lib/components/DefaultDisplayOnly.d.ts +11 -0
- package/lib/components/DefaultLayout.d.ts +9 -0
- package/lib/components/DefaultVisibility.d.ts +4 -0
- package/lib/components/RadioRenderer.d.ts +20 -0
- package/lib/components/SelectDataRenderer.d.ts +24 -0
- package/lib/controlRender.d.ts +32 -20
- package/lib/createDefaultRenderers.d.ts +59 -0
- package/lib/createFormRenderer.d.ts +3 -0
- package/lib/hooks.d.ts +2 -3
- package/lib/index.d.ts +9 -0
- package/lib/index.js +917 -772
- package/lib/index.js.map +1 -1
- package/lib/renderers.d.ts +3 -115
- package/lib/schemaInterface.d.ts +7 -2
- package/lib/types.d.ts +18 -1
- package/lib/util.d.ts +7 -1
- package/lib/validators.d.ts +2 -2
- package/package.json +1 -1
package/lib/renderers.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ControlAdornment, FieldOption, GridRenderer, IconAdornment, SchemaField, SchemaInterface } from "./types";
|
|
1
|
+
import { ReactElement, ReactNode } from "react";
|
|
2
|
+
import { ActionRendererProps, AdornmentProps, AdornmentRenderer, ArrayRendererProps, ControlLayoutProps, DataRendererProps, DisplayRendererProps, FormRenderer, GroupRendererProps, LabelRendererProps, LabelType, RenderedControl, VisibilityRendererProps } from "./controlRender";
|
|
3
|
+
import { ControlAdornment, IconAdornment } from "./types";
|
|
5
4
|
export interface DefaultRenderers {
|
|
6
5
|
data: DataRendererRegistration;
|
|
7
6
|
label: LabelRendererRegistration;
|
|
@@ -61,86 +60,6 @@ export interface VisibilityRendererRegistration {
|
|
|
61
60
|
render: (props: VisibilityRendererProps) => ReactNode;
|
|
62
61
|
}
|
|
63
62
|
export type RendererRegistration = DataRendererRegistration | GroupRendererRegistration | DisplayRendererRegistration | ActionRendererRegistration | LabelRendererRegistration | ArrayRendererRegistration | AdornmentRendererRegistration | LayoutRendererRegistration | VisibilityRendererRegistration;
|
|
64
|
-
export declare function createFormRenderer(customRenderers?: RendererRegistration[], defaultRenderers?: DefaultRenderers): FormRenderer;
|
|
65
|
-
interface DefaultLabelRendererOptions {
|
|
66
|
-
className?: string;
|
|
67
|
-
groupLabelClass?: string;
|
|
68
|
-
controlLabelClass?: string;
|
|
69
|
-
requiredElement?: ReactNode;
|
|
70
|
-
}
|
|
71
|
-
interface DefaultActionRendererOptions {
|
|
72
|
-
className?: string;
|
|
73
|
-
}
|
|
74
|
-
export declare function createDefaultActionRenderer(options?: DefaultActionRendererOptions): ActionRendererRegistration;
|
|
75
|
-
export declare function createDefaultLabelRenderer(options?: DefaultLabelRendererOptions): LabelRendererRegistration;
|
|
76
|
-
interface DefaultArrayRendererOptions {
|
|
77
|
-
className?: string;
|
|
78
|
-
removableClass?: string;
|
|
79
|
-
childClass?: string;
|
|
80
|
-
removableChildClass?: string;
|
|
81
|
-
removeActionClass?: string;
|
|
82
|
-
addActionClass?: string;
|
|
83
|
-
}
|
|
84
|
-
export declare function createDefaultArrayRenderer(options?: DefaultArrayRendererOptions): ArrayRendererRegistration;
|
|
85
|
-
interface StyleProps {
|
|
86
|
-
className?: string;
|
|
87
|
-
style?: CSSProperties;
|
|
88
|
-
}
|
|
89
|
-
interface DefaultGroupRendererOptions {
|
|
90
|
-
className?: string;
|
|
91
|
-
standardClassName?: string;
|
|
92
|
-
gridStyles?: (columns: GridRenderer) => StyleProps;
|
|
93
|
-
gridClassName?: string;
|
|
94
|
-
defaultGridColumns?: number;
|
|
95
|
-
flexClassName?: string;
|
|
96
|
-
defaultFlexGap?: string;
|
|
97
|
-
}
|
|
98
|
-
export declare function createDefaultGroupRenderer(options?: DefaultGroupRendererOptions): GroupRendererRegistration;
|
|
99
|
-
export interface DefaultDisplayRendererOptions {
|
|
100
|
-
textClassName?: string;
|
|
101
|
-
htmlClassName?: string;
|
|
102
|
-
}
|
|
103
|
-
export declare function createDefaultDisplayRenderer(options?: DefaultDisplayRendererOptions): DisplayRendererRegistration;
|
|
104
|
-
export declare function DefaultDisplay({ data, display, className, style, ...options }: DefaultDisplayRendererOptions & DisplayRendererProps): React.JSX.Element;
|
|
105
|
-
export declare const DefaultBoolOptions: FieldOption[];
|
|
106
|
-
interface DefaultDataRendererOptions {
|
|
107
|
-
inputClass?: string;
|
|
108
|
-
displayOnlyClass?: string;
|
|
109
|
-
selectOptions?: SelectRendererOptions;
|
|
110
|
-
booleanOptions?: FieldOption[];
|
|
111
|
-
optionRenderer?: DataRendererRegistration;
|
|
112
|
-
}
|
|
113
|
-
export declare function createDefaultDataRenderer(options?: DefaultDataRendererOptions): DataRendererRegistration;
|
|
114
|
-
export declare function DefaultDisplayOnly({ control, className, emptyText, schemaInterface, field, style, }: {
|
|
115
|
-
control: Control<any>;
|
|
116
|
-
field: SchemaField;
|
|
117
|
-
schemaInterface: SchemaInterface;
|
|
118
|
-
className?: string;
|
|
119
|
-
style?: React.CSSProperties;
|
|
120
|
-
emptyText?: string | null;
|
|
121
|
-
}): React.JSX.Element;
|
|
122
|
-
export declare function ControlInput({ control, convert, ...props }: React.InputHTMLAttributes<HTMLInputElement> & {
|
|
123
|
-
control: Control<any>;
|
|
124
|
-
convert: InputConversion;
|
|
125
|
-
}): React.JSX.Element;
|
|
126
|
-
export interface DefaultAdornmentRendererOptions {
|
|
127
|
-
}
|
|
128
|
-
export declare function createDefaultAdornmentRenderer(options?: DefaultAdornmentRendererOptions): AdornmentRendererRegistration;
|
|
129
|
-
export interface DefaultLayoutRendererOptions {
|
|
130
|
-
className?: string;
|
|
131
|
-
errorClass?: string;
|
|
132
|
-
}
|
|
133
|
-
export interface DefaultRendererOptions {
|
|
134
|
-
data?: DefaultDataRendererOptions;
|
|
135
|
-
display?: DefaultDisplayRendererOptions;
|
|
136
|
-
action?: DefaultActionRendererOptions;
|
|
137
|
-
array?: DefaultArrayRendererOptions;
|
|
138
|
-
group?: DefaultGroupRendererOptions;
|
|
139
|
-
label?: DefaultLabelRendererOptions;
|
|
140
|
-
adornment?: DefaultAdornmentRendererOptions;
|
|
141
|
-
layout?: DefaultLayoutRendererOptions;
|
|
142
|
-
}
|
|
143
|
-
export declare function createDefaultRenderers(options?: DefaultRendererOptions): DefaultRenderers;
|
|
144
63
|
export declare function isIconAdornment(a: ControlAdornment): a is IconAdornment;
|
|
145
64
|
export declare function createLayoutRenderer(render: LayoutRendererRegistration["render"], options?: Partial<LayoutRendererRegistration>): LayoutRendererRegistration;
|
|
146
65
|
export declare function createArrayRenderer(render: ArrayRendererRegistration["render"], options?: Partial<ArrayRendererRegistration>): ArrayRendererRegistration;
|
|
@@ -150,34 +69,3 @@ export declare function createDisplayRenderer(render: DisplayRendererRegistratio
|
|
|
150
69
|
export declare function createLabelRenderer(render: LabelRendererRegistration["render"], options?: Omit<LabelRendererRegistration, "type">): LabelRendererRegistration;
|
|
151
70
|
export declare function createVisibilityRenderer(render: VisibilityRendererRegistration["render"], options?: Partial<VisibilityRendererRegistration>): VisibilityRendererRegistration;
|
|
152
71
|
export declare function createAdornmentRenderer(render: (props: AdornmentProps) => AdornmentRenderer, options?: Partial<AdornmentRendererRegistration>): AdornmentRendererRegistration;
|
|
153
|
-
export interface SelectRendererOptions {
|
|
154
|
-
className?: string;
|
|
155
|
-
emptyText?: string;
|
|
156
|
-
requiredText?: string;
|
|
157
|
-
}
|
|
158
|
-
export declare function createSelectRenderer(options?: SelectRendererOptions): DataRendererRegistration;
|
|
159
|
-
type SelectConversion = (a: any) => string | number;
|
|
160
|
-
interface SelectDataRendererProps {
|
|
161
|
-
id?: string;
|
|
162
|
-
className?: string;
|
|
163
|
-
options: {
|
|
164
|
-
name: string;
|
|
165
|
-
value: any;
|
|
166
|
-
disabled?: boolean;
|
|
167
|
-
}[];
|
|
168
|
-
emptyText?: string;
|
|
169
|
-
requiredText?: string;
|
|
170
|
-
required: boolean;
|
|
171
|
-
state: Control<any>;
|
|
172
|
-
convert: SelectConversion;
|
|
173
|
-
}
|
|
174
|
-
export declare function SelectDataRenderer({ state, options, className, convert, required, emptyText, requiredText, ...props }: SelectDataRendererProps): React.JSX.Element;
|
|
175
|
-
export declare function createSelectConversion(ft: string): SelectConversion;
|
|
176
|
-
type InputConversion = [string, (s: any) => any, (a: any) => string | number];
|
|
177
|
-
export declare function createInputConversion(ft: string): InputConversion;
|
|
178
|
-
export declare function createDefaultVisibilityRenderer(): VisibilityRendererRegistration;
|
|
179
|
-
export declare function DefaultVisibility({ visibility, children, className, style, divRef, }: VisibilityRendererProps): React.JSX.Element;
|
|
180
|
-
export declare function DefaultLayout({ errorClass, layout: { controlEnd, controlStart, label, children, errorControl }, }: DefaultLayoutRendererOptions & {
|
|
181
|
-
layout: RenderedLayout;
|
|
182
|
-
}): React.JSX.Element;
|
|
183
|
-
export {};
|
package/lib/schemaInterface.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { SchemaField, SchemaInterface } from "./types";
|
|
2
|
+
import { Control } from "@react-typed-forms/core";
|
|
3
|
+
export declare class DefaultSchemaInterface implements SchemaInterface {
|
|
4
|
+
isEmptyValue(f: SchemaField, value: any): boolean;
|
|
5
|
+
textValue(field: SchemaField, value: any, element?: boolean | undefined): string | undefined;
|
|
6
|
+
controlLength(f: SchemaField, control: Control<any>): number;
|
|
7
|
+
valueLength(field: SchemaField, value: any): number;
|
|
8
|
+
}
|
|
2
9
|
export declare const defaultSchemaInterface: SchemaInterface;
|
|
3
|
-
export declare function defaultIsEmpty(f: SchemaField, value: any): boolean;
|
|
4
|
-
export declare function defaultTextValue(f: SchemaField, value: any): string | undefined;
|
package/lib/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Control } from "@react-typed-forms/core";
|
|
1
2
|
export interface SchemaField {
|
|
2
3
|
type: string;
|
|
3
4
|
field: string;
|
|
@@ -36,6 +37,8 @@ export interface EntityRefField extends SchemaField {
|
|
|
36
37
|
export interface FieldOption {
|
|
37
38
|
name: string;
|
|
38
39
|
value: any;
|
|
40
|
+
description?: string | null;
|
|
41
|
+
disabled?: boolean | null;
|
|
39
42
|
}
|
|
40
43
|
export interface CompoundField extends SchemaField {
|
|
41
44
|
type: FieldType.Compound;
|
|
@@ -47,6 +50,8 @@ export type AnyControlDefinition = DataControlDefinition | GroupedControlsDefini
|
|
|
47
50
|
export interface SchemaInterface {
|
|
48
51
|
isEmptyValue(field: SchemaField, value: any): boolean;
|
|
49
52
|
textValue(field: SchemaField, value: any, element?: boolean): string | undefined;
|
|
53
|
+
controlLength(field: SchemaField, control: Control<any>): number;
|
|
54
|
+
valueLength(field: SchemaField, value: any): number;
|
|
50
55
|
}
|
|
51
56
|
export interface ControlDefinition {
|
|
52
57
|
type: string;
|
|
@@ -155,6 +160,7 @@ export interface RenderOptions {
|
|
|
155
160
|
}
|
|
156
161
|
export declare enum DataRenderType {
|
|
157
162
|
Standard = "Standard",
|
|
163
|
+
Textfield = "Textfield",
|
|
158
164
|
Radio = "Radio",
|
|
159
165
|
HtmlEditor = "HtmlEditor",
|
|
160
166
|
IconList = "IconList",
|
|
@@ -168,6 +174,10 @@ export declare enum DataRenderType {
|
|
|
168
174
|
DisplayOnly = "DisplayOnly",
|
|
169
175
|
Group = "Group"
|
|
170
176
|
}
|
|
177
|
+
export interface TextfieldRenderOptions extends RenderOptions {
|
|
178
|
+
type: DataRenderType.Textfield;
|
|
179
|
+
placeholder?: string | null;
|
|
180
|
+
}
|
|
171
181
|
export interface RadioButtonRenderOptions extends RenderOptions {
|
|
172
182
|
type: DataRenderType.Radio;
|
|
173
183
|
}
|
|
@@ -281,7 +291,8 @@ export interface ActionControlDefinition extends ControlDefinition {
|
|
|
281
291
|
}
|
|
282
292
|
export declare enum ValidatorType {
|
|
283
293
|
Jsonata = "Jsonata",
|
|
284
|
-
Date = "Date"
|
|
294
|
+
Date = "Date",
|
|
295
|
+
Length = "Length"
|
|
285
296
|
}
|
|
286
297
|
export interface SchemaValidator {
|
|
287
298
|
type: string;
|
|
@@ -290,6 +301,11 @@ export interface JsonataValidator extends SchemaValidator {
|
|
|
290
301
|
type: ValidatorType.Jsonata;
|
|
291
302
|
expression: string;
|
|
292
303
|
}
|
|
304
|
+
export interface LengthValidator extends SchemaValidator {
|
|
305
|
+
type: ValidatorType.Length;
|
|
306
|
+
min?: number | null;
|
|
307
|
+
max?: number | null;
|
|
308
|
+
}
|
|
293
309
|
export declare enum DateComparison {
|
|
294
310
|
NotBefore = "NotBefore",
|
|
295
311
|
NotAfter = "NotAfter"
|
|
@@ -314,4 +330,5 @@ export declare function visitControlDefinition<A>(x: ControlDefinition, visitor:
|
|
|
314
330
|
export declare function isGridRenderer(options: GroupRenderOptions): options is GridRenderer;
|
|
315
331
|
export declare function isFlexRenderer(options: GroupRenderOptions): options is FlexRenderer;
|
|
316
332
|
export declare function isDisplayOnlyRenderer(options: RenderOptions): options is DisplayOnlyRenderOptions;
|
|
333
|
+
export declare function isTextfieldRenderer(options: RenderOptions): options is TextfieldRenderOptions;
|
|
317
334
|
export declare function isDataGroupRenderer(options: RenderOptions): options is DataGroupRenderOptions;
|
package/lib/util.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { CompoundField, ControlDefinition, DataControlDefinition, DisplayOnlyRenderOptions, FieldOption, GroupedControlsDefinition, SchemaField, SchemaInterface } from "./types";
|
|
2
2
|
import { MutableRefObject } from "react";
|
|
3
3
|
import { Control } from "@react-typed-forms/core";
|
|
4
|
-
|
|
4
|
+
export type JsonPath = string | number;
|
|
5
|
+
export interface DataContext {
|
|
6
|
+
data: Control<any>;
|
|
7
|
+
path: JsonPath[];
|
|
8
|
+
}
|
|
5
9
|
export interface ControlDataContext extends DataContext {
|
|
6
10
|
fields: SchemaField[];
|
|
7
11
|
schemaInterface: SchemaInterface;
|
|
@@ -54,3 +58,5 @@ export declare function useDynamicHooks<P, Hooks extends Record<string, DynamicH
|
|
|
54
58
|
[K in keyof Hooks]: DynamicHookValue<Hooks[K]>;
|
|
55
59
|
};
|
|
56
60
|
export declare function toDepString(x: any): string;
|
|
61
|
+
export declare function appendElementIndex(dataContext: ControlDataContext, elementIndex: number): ControlDataContext;
|
|
62
|
+
export declare function applyLengthRestrictions<Min, Max>(length: number, min: number | null | undefined, max: number | null | undefined, minValue: Min, maxValue: Max): [Min | undefined, Max | undefined];
|
package/lib/validators.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ControlDefinition } from "./types";
|
|
1
|
+
import { ControlDefinition, SchemaField, SchemaInterface } from "./types";
|
|
2
2
|
import { Control } from "@react-typed-forms/core";
|
|
3
3
|
import { ControlDataContext } from "./util";
|
|
4
|
-
export declare function useValidationHook(definition: ControlDefinition): (control: Control<any>, hidden: boolean, groupContext: ControlDataContext) => void;
|
|
4
|
+
export declare function useValidationHook(definition: ControlDefinition, field: SchemaField | undefined): (control: Control<any>, hidden: boolean, groupContext: ControlDataContext, schemaInterface: SchemaInterface) => void;
|