@opengov/form-renderer 0.0.39 → 0.0.41-config-beta.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/dist/fields/CalculatedNumber/CalculatedNumber.d.ts +13 -0
- package/dist/fields/CalculatedNumber/CalculatedNumberConfig.d.ts +3 -0
- package/dist/fields/Checkbox/Checkbox.d.ts +3 -2
- package/dist/fields/Checkbox/CheckboxConfig.d.ts +3 -0
- package/dist/fields/DateInput/DateConfig.d.ts +3 -0
- package/dist/fields/DateInput/DateInput.d.ts +2 -1
- package/dist/fields/Dropdown/Dropdown.d.ts +8 -0
- package/dist/fields/Dropdown/Dropdown.test.d.ts +1 -0
- package/dist/fields/Dropdown/DropdownConfig.d.ts +3 -0
- package/dist/fields/FormFieldLabel.d.ts +2 -1
- package/dist/fields/NonEditableField/NonEditableField.d.ts +7 -1
- package/dist/fields/Number/NumberConfig.d.ts +3 -0
- package/dist/fields/Number/NumberInput.d.ts +5 -0
- package/dist/fields/Text/TextConfig.d.ts +3 -0
- package/dist/fields/Text/TextInput.d.ts +6 -0
- package/dist/fields/defaultFields.d.ts +4 -4
- package/dist/index.d.ts +7 -7
- package/dist/lib.js +10490 -10446
- package/dist/lib.umd.cjs +72 -72
- package/dist/renderer/FormProvider.d.ts +3 -4
- package/dist/renderer/context/FormRendererContext.d.ts +76 -8
- package/dist/renderer/index.d.ts +1 -1
- package/dist/renderer/types.d.ts +40 -16
- package/dist/utils/TestWrapper.d.ts +6 -0
- package/package.json +1 -1
- package/dist/fields/CalculatedNumber.d.ts +0 -7
- package/dist/fields/NumberInput.d.ts +0 -3
- package/dist/fields/Select.d.ts +0 -7
- package/dist/fields/TextInput.d.ts +0 -4
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { LayoutState } from './context/LayoutContext';
|
|
3
|
-
import { FormTemplate,
|
|
3
|
+
import { FormTemplate, FieldTypes } from './types';
|
|
4
4
|
interface FormProviderProps {
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
layout?: LayoutState;
|
|
7
7
|
template: FormTemplate;
|
|
8
|
-
|
|
8
|
+
fieldTypes?: FieldTypes[];
|
|
9
9
|
readonly?: boolean;
|
|
10
|
-
dateFormat?: DateFormat;
|
|
11
10
|
}
|
|
12
|
-
declare function FormProvider({ children, layout, template,
|
|
11
|
+
declare function FormProvider({ children, layout, template, fieldTypes, readonly }: FormProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
13
12
|
export default FormProvider;
|
|
@@ -1,24 +1,92 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { FormTemplate, FieldTypes } from '../types';
|
|
3
3
|
export interface FormRendererContextType {
|
|
4
4
|
template: FormTemplate;
|
|
5
|
-
|
|
6
|
-
dateFormat?: string;
|
|
5
|
+
fieldTypes: FieldTypes[];
|
|
7
6
|
readonly?: boolean;
|
|
8
7
|
}
|
|
9
8
|
interface FormRendererProviderProps {
|
|
10
9
|
children: ReactNode;
|
|
11
10
|
template: FormTemplate;
|
|
12
|
-
|
|
13
|
-
dateFormat?: string;
|
|
11
|
+
fieldTypes: FieldTypes[];
|
|
14
12
|
readonly?: boolean;
|
|
15
13
|
}
|
|
16
14
|
export declare const FormRendererProvider: React.FC<FormRendererProviderProps>;
|
|
17
15
|
export declare const useFormRenderer: () => FormRendererContextType;
|
|
18
|
-
export declare const
|
|
16
|
+
export declare const useFieldType: (type?: string) => {
|
|
17
|
+
type: string;
|
|
18
|
+
name: string;
|
|
19
|
+
fullWidth: boolean;
|
|
20
|
+
renderField: ((template: import('../types').FieldTemplate, config: import('../types').FieldConfiguration, { disabled, readonly }: {
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
readonly?: boolean;
|
|
23
|
+
}) => JSX.Element) | ((template: import('../types').FieldTemplate, config: import('../types').TextConfiguration, { disabled, readonly }: {
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
readonly?: boolean;
|
|
26
|
+
}) => JSX.Element) | ((template: import('../types').FieldTemplate, config: import('../types').NumberConfiguration, { disabled, readonly }: {
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
readonly?: boolean;
|
|
29
|
+
}) => JSX.Element) | ((template: import('../types').FieldTemplate, config: import('../types').DateConfiguration, { disabled, readonly }: {
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
readonly?: boolean;
|
|
32
|
+
}) => JSX.Element);
|
|
33
|
+
} | {
|
|
34
|
+
type: "TEXTINPUT";
|
|
35
|
+
name: string;
|
|
36
|
+
fullWidth: boolean;
|
|
37
|
+
maxLength: number;
|
|
38
|
+
renderField: ((template: import('../types').FieldTemplate, config: import('../types').FieldConfiguration, { disabled, readonly }: {
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
readonly?: boolean;
|
|
41
|
+
}) => JSX.Element) | ((template: import('../types').FieldTemplate, config: import('../types').TextConfiguration, { disabled, readonly }: {
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
readonly?: boolean;
|
|
44
|
+
}) => JSX.Element) | ((template: import('../types').FieldTemplate, config: import('../types').NumberConfiguration, { disabled, readonly }: {
|
|
45
|
+
disabled?: boolean;
|
|
46
|
+
readonly?: boolean;
|
|
47
|
+
}) => JSX.Element) | ((template: import('../types').FieldTemplate, config: import('../types').DateConfiguration, { disabled, readonly }: {
|
|
48
|
+
disabled?: boolean;
|
|
49
|
+
readonly?: boolean;
|
|
50
|
+
}) => JSX.Element);
|
|
51
|
+
} | {
|
|
52
|
+
type: "NUMBER";
|
|
53
|
+
name: string;
|
|
54
|
+
fullWidth: boolean;
|
|
55
|
+
decimalPlaces: number;
|
|
56
|
+
renderField: ((template: import('../types').FieldTemplate, config: import('../types').FieldConfiguration, { disabled, readonly }: {
|
|
57
|
+
disabled?: boolean;
|
|
58
|
+
readonly?: boolean;
|
|
59
|
+
}) => JSX.Element) | ((template: import('../types').FieldTemplate, config: import('../types').TextConfiguration, { disabled, readonly }: {
|
|
60
|
+
disabled?: boolean;
|
|
61
|
+
readonly?: boolean;
|
|
62
|
+
}) => JSX.Element) | ((template: import('../types').FieldTemplate, config: import('../types').NumberConfiguration, { disabled, readonly }: {
|
|
63
|
+
disabled?: boolean;
|
|
64
|
+
readonly?: boolean;
|
|
65
|
+
}) => JSX.Element) | ((template: import('../types').FieldTemplate, config: import('../types').DateConfiguration, { disabled, readonly }: {
|
|
66
|
+
disabled?: boolean;
|
|
67
|
+
readonly?: boolean;
|
|
68
|
+
}) => JSX.Element);
|
|
69
|
+
} | {
|
|
70
|
+
type: "DATE";
|
|
71
|
+
name: string;
|
|
72
|
+
fullWidth: boolean;
|
|
73
|
+
dateFormat: import('../types').DateFormat;
|
|
74
|
+
renderField: ((template: import('../types').FieldTemplate, config: import('../types').FieldConfiguration, { disabled, readonly }: {
|
|
75
|
+
disabled?: boolean;
|
|
76
|
+
readonly?: boolean;
|
|
77
|
+
}) => JSX.Element) | ((template: import('../types').FieldTemplate, config: import('../types').TextConfiguration, { disabled, readonly }: {
|
|
78
|
+
disabled?: boolean;
|
|
79
|
+
readonly?: boolean;
|
|
80
|
+
}) => JSX.Element) | ((template: import('../types').FieldTemplate, config: import('../types').NumberConfiguration, { disabled, readonly }: {
|
|
81
|
+
disabled?: boolean;
|
|
82
|
+
readonly?: boolean;
|
|
83
|
+
}) => JSX.Element) | ((template: import('../types').FieldTemplate, config: import('../types').DateConfiguration, { disabled, readonly }: {
|
|
84
|
+
disabled?: boolean;
|
|
85
|
+
readonly?: boolean;
|
|
86
|
+
}) => JSX.Element);
|
|
87
|
+
} | null;
|
|
88
|
+
export declare const useFieldTemplate: (fieldId: string) => {
|
|
19
89
|
template: import('../types').FieldTemplate;
|
|
20
|
-
render: (field: import('../types').FieldTemplate) => JSX.Element;
|
|
21
|
-
renderReadOnly: ((field: import('../types').FieldTemplate) => JSX.Element) | undefined;
|
|
22
90
|
formattedFormula: string;
|
|
23
91
|
};
|
|
24
92
|
export {};
|
package/dist/renderer/index.d.ts
CHANGED
|
@@ -8,4 +8,4 @@ export declare function FormShell({ children, formOptions, submit, }: {
|
|
|
8
8
|
submit?: SubmitProps;
|
|
9
9
|
}): import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
export declare function Renderer({ fieldIds, formOptions, submit, readonly }: RendererProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
export default function FormRenderer({ template,
|
|
11
|
+
export default function FormRenderer({ template, fieldTypes, layout, readonly, formOptions, submit, }: FormRendererProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/renderer/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FieldValues, UseFormProps } from 'react-hook-form';
|
|
2
2
|
import { LayoutState } from './context/LayoutContext';
|
|
3
|
+
/** TEMPLATE TYPES */
|
|
3
4
|
export type SectionTemplate = FieldValues & {
|
|
4
5
|
type: 'singleEntry' | 'multiEntry';
|
|
5
6
|
id: string;
|
|
@@ -27,20 +28,7 @@ export type FieldTemplate = FieldValues & {
|
|
|
27
28
|
fullWidth?: boolean;
|
|
28
29
|
readonly?: boolean;
|
|
29
30
|
};
|
|
30
|
-
|
|
31
|
-
dependentEntityPrimaryKey: string;
|
|
32
|
-
dependentEntityType: string;
|
|
33
|
-
legacyId?: number;
|
|
34
|
-
logicTypeId: number;
|
|
35
|
-
comparate1?: string;
|
|
36
|
-
comparate2?: string;
|
|
37
|
-
};
|
|
38
|
-
export type FieldRenders = {
|
|
39
|
-
[key: string]: {
|
|
40
|
-
render: (field: FieldTemplate) => JSX.Element;
|
|
41
|
-
renderReadOnly?: (field: FieldTemplate) => JSX.Element;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
31
|
+
/** RENDERER TYPES */
|
|
44
32
|
export type FormData = Record<string, any>;
|
|
45
33
|
export type SubmitProps = {
|
|
46
34
|
onSubmit: (data: any) => void;
|
|
@@ -49,7 +37,7 @@ export type SubmitProps = {
|
|
|
49
37
|
submitOnChange?: boolean;
|
|
50
38
|
};
|
|
51
39
|
export type FormRendererProps = {
|
|
52
|
-
|
|
40
|
+
fieldTypes?: FieldTypes[];
|
|
53
41
|
template: FormTemplate;
|
|
54
42
|
layout?: LayoutState;
|
|
55
43
|
readonly?: boolean;
|
|
@@ -67,6 +55,15 @@ export type RendererProps = {
|
|
|
67
55
|
submit?: SubmitProps;
|
|
68
56
|
readonly?: boolean;
|
|
69
57
|
};
|
|
58
|
+
/** DATA TYPES */
|
|
59
|
+
export type ConditionTemplate = {
|
|
60
|
+
dependentEntityPrimaryKey: string;
|
|
61
|
+
dependentEntityType: string;
|
|
62
|
+
legacyId?: number;
|
|
63
|
+
logicTypeId: number;
|
|
64
|
+
comparate1?: string;
|
|
65
|
+
comparate2?: string;
|
|
66
|
+
};
|
|
70
67
|
export declare enum LogicTypes {
|
|
71
68
|
EQUALS = 1,
|
|
72
69
|
BETWEEN = 2,
|
|
@@ -98,7 +95,9 @@ export declare enum DayOfWeek {
|
|
|
98
95
|
SATURDAY = "SATURDAY"
|
|
99
96
|
}
|
|
100
97
|
export type DateConstraints = {
|
|
101
|
-
disableDaysOfWeek?:
|
|
98
|
+
disableDaysOfWeek?: {
|
|
99
|
+
value: DayOfWeek;
|
|
100
|
+
}[];
|
|
102
101
|
disablePastDates?: {
|
|
103
102
|
number: number;
|
|
104
103
|
unit: DateUnit;
|
|
@@ -108,3 +107,28 @@ export type DateConstraints = {
|
|
|
108
107
|
unit: DateUnit;
|
|
109
108
|
};
|
|
110
109
|
};
|
|
110
|
+
/** FIELD CONFIGURATION TYPES */
|
|
111
|
+
export type FieldConfiguration = {
|
|
112
|
+
type: string;
|
|
113
|
+
name: string;
|
|
114
|
+
fullWidth?: boolean;
|
|
115
|
+
};
|
|
116
|
+
export type TypeConfig<T extends FieldConfiguration = FieldConfiguration> = T & {
|
|
117
|
+
renderField: (template: FieldTemplate, config: T, { disabled, readonly }: {
|
|
118
|
+
disabled?: boolean;
|
|
119
|
+
readonly?: boolean;
|
|
120
|
+
}) => JSX.Element;
|
|
121
|
+
};
|
|
122
|
+
export type TextConfiguration = FieldConfiguration & {
|
|
123
|
+
type: 'TEXTINPUT';
|
|
124
|
+
maxLength: number;
|
|
125
|
+
};
|
|
126
|
+
export type NumberConfiguration = FieldConfiguration & {
|
|
127
|
+
type: 'NUMBER';
|
|
128
|
+
decimalPlaces: number;
|
|
129
|
+
};
|
|
130
|
+
export type DateConfiguration = FieldConfiguration & {
|
|
131
|
+
type: 'DATE';
|
|
132
|
+
dateFormat: DateFormat;
|
|
133
|
+
};
|
|
134
|
+
export type FieldTypes = TypeConfig | TypeConfig<TextConfiguration> | TypeConfig<NumberConfiguration> | TypeConfig<DateConfiguration>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FieldTemplate } from '../renderer/types';
|
|
2
|
+
export default function TestWrapper({ children, fieldTemplate, defaultValues, }: {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
fieldTemplate: FieldTemplate;
|
|
5
|
+
defaultValues?: Record<string, any>;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { GeneralInputProps } from './types';
|
|
2
|
-
import { FieldTemplate } from '../renderer/types';
|
|
3
|
-
declare function CalculatedNumber({ name, label, sx }: GeneralInputProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
-
export declare function CalculationWithFormula({ fieldTemplate }: {
|
|
5
|
-
fieldTemplate: FieldTemplate;
|
|
6
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
export default CalculatedNumber;
|
package/dist/fields/Select.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { GeneralInputProps } from './types';
|
|
2
|
-
export default function SelectInput({ name, label, options, sx, disabled, rules, ...rest }: GeneralInputProps & {
|
|
3
|
-
options: Array<{
|
|
4
|
-
displayValue: string;
|
|
5
|
-
key: string;
|
|
6
|
-
}>;
|
|
7
|
-
}): import("react/jsx-runtime").JSX.Element;
|