@opengov/form-renderer 0.0.41-config-beta.1 → 0.0.41
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.d.ts +7 -0
- package/dist/fields/Checkbox/Checkbox.d.ts +1 -3
- package/dist/fields/DateInput/DateInput.d.ts +1 -2
- package/dist/fields/Dropdown/Dropdown.d.ts +1 -2
- package/dist/fields/NonEditableField/NonEditableField.d.ts +1 -3
- package/dist/fields/NumberInput.d.ts +3 -0
- package/dist/fields/TextInput.d.ts +4 -0
- package/dist/fields/defaultFields.d.ts +3 -3
- package/dist/index.d.ts +5 -7
- package/dist/lib.js +10839 -10871
- package/dist/lib.umd.cjs +72 -72
- package/dist/renderer/FormProvider.d.ts +4 -3
- package/dist/renderer/context/FormRendererContext.d.ts +8 -76
- package/dist/renderer/index.d.ts +1 -1
- package/dist/renderer/types.d.ts +16 -40
- package/package.json +1 -1
- package/dist/fields/CalculatedNumber/CalculatedNumber.d.ts +0 -13
- package/dist/fields/CalculatedNumber/CalculatedNumberConfig.d.ts +0 -3
- package/dist/fields/Checkbox/CheckboxConfig.d.ts +0 -3
- package/dist/fields/DateInput/DateConfig.d.ts +0 -3
- package/dist/fields/Dropdown/DropdownConfig.d.ts +0 -3
- package/dist/fields/Number/NumberConfig.d.ts +0 -3
- package/dist/fields/Number/NumberInput.d.ts +0 -5
- package/dist/fields/Text/TextConfig.d.ts +0 -3
- package/dist/fields/Text/TextInput.d.ts +0 -6
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { LayoutState } from './context/LayoutContext';
|
|
3
|
-
import { FormTemplate,
|
|
3
|
+
import { FormTemplate, FieldRenders, DateFormat } from './types';
|
|
4
4
|
interface FormProviderProps {
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
layout?: LayoutState;
|
|
7
7
|
template: FormTemplate;
|
|
8
|
-
|
|
8
|
+
renderFields?: FieldRenders;
|
|
9
9
|
readonly?: boolean;
|
|
10
|
+
dateFormat?: DateFormat;
|
|
10
11
|
}
|
|
11
|
-
declare function FormProvider({ children, layout, template,
|
|
12
|
+
declare function FormProvider({ children, layout, template, renderFields, readonly, dateFormat, }: FormProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
12
13
|
export default FormProvider;
|
|
@@ -1,92 +1,24 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { FieldRenders, FormTemplate } from '../types';
|
|
3
3
|
export interface FormRendererContextType {
|
|
4
4
|
template: FormTemplate;
|
|
5
|
-
|
|
5
|
+
renderFields?: FieldRenders;
|
|
6
|
+
dateFormat?: string;
|
|
6
7
|
readonly?: boolean;
|
|
7
8
|
}
|
|
8
9
|
interface FormRendererProviderProps {
|
|
9
10
|
children: ReactNode;
|
|
10
11
|
template: FormTemplate;
|
|
11
|
-
|
|
12
|
+
renderFields?: FieldRenders;
|
|
13
|
+
dateFormat?: string;
|
|
12
14
|
readonly?: boolean;
|
|
13
15
|
}
|
|
14
16
|
export declare const FormRendererProvider: React.FC<FormRendererProviderProps>;
|
|
15
17
|
export declare const useFormRenderer: () => FormRendererContextType;
|
|
16
|
-
export declare const
|
|
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) => {
|
|
18
|
+
export declare const useFormField: (fieldId: string) => {
|
|
89
19
|
template: import('../types').FieldTemplate;
|
|
20
|
+
render: (field: import('../types').FieldTemplate) => JSX.Element;
|
|
21
|
+
renderReadOnly: ((field: import('../types').FieldTemplate) => JSX.Element) | undefined;
|
|
90
22
|
formattedFormula: string;
|
|
91
23
|
};
|
|
92
24
|
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, renderFields, layout, readonly, formOptions, submit, dateFormat, }: FormRendererProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/renderer/types.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { FieldValues, UseFormProps } from 'react-hook-form';
|
|
2
2
|
import { LayoutState } from './context/LayoutContext';
|
|
3
|
-
/** TEMPLATE TYPES */
|
|
4
3
|
export type SectionTemplate = FieldValues & {
|
|
5
4
|
type: 'singleEntry' | 'multiEntry';
|
|
6
5
|
id: string;
|
|
@@ -28,7 +27,20 @@ export type FieldTemplate = FieldValues & {
|
|
|
28
27
|
fullWidth?: boolean;
|
|
29
28
|
readonly?: boolean;
|
|
30
29
|
};
|
|
31
|
-
|
|
30
|
+
export type ConditionTemplate = {
|
|
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
|
+
};
|
|
32
44
|
export type FormData = Record<string, any>;
|
|
33
45
|
export type SubmitProps = {
|
|
34
46
|
onSubmit: (data: any) => void;
|
|
@@ -37,7 +49,7 @@ export type SubmitProps = {
|
|
|
37
49
|
submitOnChange?: boolean;
|
|
38
50
|
};
|
|
39
51
|
export type FormRendererProps = {
|
|
40
|
-
|
|
52
|
+
renderFields?: FieldRenders;
|
|
41
53
|
template: FormTemplate;
|
|
42
54
|
layout?: LayoutState;
|
|
43
55
|
readonly?: boolean;
|
|
@@ -55,15 +67,6 @@ export type RendererProps = {
|
|
|
55
67
|
submit?: SubmitProps;
|
|
56
68
|
readonly?: boolean;
|
|
57
69
|
};
|
|
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
|
-
};
|
|
67
70
|
export declare enum LogicTypes {
|
|
68
71
|
EQUALS = 1,
|
|
69
72
|
BETWEEN = 2,
|
|
@@ -95,9 +98,7 @@ export declare enum DayOfWeek {
|
|
|
95
98
|
SATURDAY = "SATURDAY"
|
|
96
99
|
}
|
|
97
100
|
export type DateConstraints = {
|
|
98
|
-
disableDaysOfWeek?:
|
|
99
|
-
value: DayOfWeek;
|
|
100
|
-
}[];
|
|
101
|
+
disableDaysOfWeek?: DayOfWeek[];
|
|
101
102
|
disablePastDates?: {
|
|
102
103
|
number: number;
|
|
103
104
|
unit: DateUnit;
|
|
@@ -107,28 +108,3 @@ export type DateConstraints = {
|
|
|
107
108
|
unit: DateUnit;
|
|
108
109
|
};
|
|
109
110
|
};
|
|
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>;
|
package/package.json
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { GeneralInputProps } from '../types';
|
|
2
|
-
import { FieldTemplate, FieldConfiguration } from '../../renderer/types';
|
|
3
|
-
export declare function CalculatedNumberInput({ name, label, sx }: GeneralInputProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
-
export declare function CalculationWithFormula({ template, readonly }: {
|
|
5
|
-
template: FieldTemplate;
|
|
6
|
-
readonly?: boolean;
|
|
7
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
export default function CalculatedNumber({ template, disabled, readonly, }: {
|
|
9
|
-
template: FieldTemplate;
|
|
10
|
-
config: FieldConfiguration;
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
readonly?: boolean;
|
|
13
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { TextFieldProps } from '@mui/material';
|
|
2
|
-
import { GeneralInputProps } from '../types';
|
|
3
|
-
declare function TextInput({ name, label, rules, sx, ...rest }: GeneralInputProps & TextFieldProps & {
|
|
4
|
-
readonly?: boolean;
|
|
5
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
export default TextInput;
|