@opengov/form-renderer 0.0.41-config-beta.0 → 0.0.41-config-beta.2
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 +1 -1
- package/dist/fields/CalculatedNumber/CalculatedNumberConfig.d.ts +1 -1
- package/dist/fields/Checkbox/CheckboxConfig.d.ts +1 -1
- package/dist/fields/DateInput/DateConfig.d.ts +1 -1
- package/dist/fields/DateInput/DateInput.d.ts +1 -1
- package/dist/fields/Dropdown/Dropdown.d.ts +2 -4
- package/dist/fields/Dropdown/DropdownConfig.d.ts +1 -1
- package/dist/fields/NonEditableField/NonEditableField.d.ts +1 -1
- package/dist/fields/Number/NumberConfig.d.ts +1 -1
- package/dist/fields/Text/TextConfig.d.ts +1 -1
- package/dist/fields/defaultFields.d.ts +1 -1
- package/dist/lib.js +206 -200
- package/dist/lib.umd.cjs +26 -26
- package/dist/renderer/FormProvider.d.ts +1 -1
- package/dist/renderer/context/FormRendererContext.d.ts +35 -19
- package/dist/renderer/types.d.ts +2 -107
- package/dist/stories/basicTemplate.d.ts +1 -1
- package/dist/stories/complexTemplate.d.ts +1 -1
- package/dist/utils/TestWrapper.d.ts +1 -1
- package/package.json +2 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { LayoutState } from './context/LayoutContext';
|
|
3
|
-
import { FormTemplate, FieldTypes } from '
|
|
3
|
+
import { FormTemplate, FieldTypes } from '@opengov/form-utils';
|
|
4
4
|
interface FormProviderProps {
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
layout?: LayoutState;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { FormTemplate, FieldTypes } from '
|
|
2
|
+
import { FormTemplate, FieldTypes } from '@opengov/form-utils';
|
|
3
3
|
export interface FormRendererContextType {
|
|
4
4
|
template: FormTemplate;
|
|
5
5
|
fieldTypes: FieldTypes[];
|
|
@@ -16,77 +16,93 @@ export declare const useFormRenderer: () => FormRendererContextType;
|
|
|
16
16
|
export declare const useFieldType: (type?: string) => {
|
|
17
17
|
type: string;
|
|
18
18
|
name: string;
|
|
19
|
+
Icon?: React.ElementType;
|
|
20
|
+
icon?: string;
|
|
21
|
+
groups: import('@opengov/form-utils').ConfigurationGroup<import('react-hook-form').FieldValues>[];
|
|
22
|
+
omitLabelConfiguration?: boolean;
|
|
19
23
|
fullWidth: boolean;
|
|
20
|
-
renderField: ((template: import('
|
|
24
|
+
renderField: ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').FieldConfiguration<import('react-hook-form').FieldValues>, { disabled, readonly }: {
|
|
21
25
|
disabled?: boolean;
|
|
22
26
|
readonly?: boolean;
|
|
23
|
-
}) => JSX.Element) | ((template: import('
|
|
27
|
+
}) => JSX.Element) | ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').TextConfiguration, { disabled, readonly }: {
|
|
24
28
|
disabled?: boolean;
|
|
25
29
|
readonly?: boolean;
|
|
26
|
-
}) => JSX.Element) | ((template: import('
|
|
30
|
+
}) => JSX.Element) | ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').NumberConfiguration, { disabled, readonly }: {
|
|
27
31
|
disabled?: boolean;
|
|
28
32
|
readonly?: boolean;
|
|
29
|
-
}) => JSX.Element) | ((template: import('
|
|
33
|
+
}) => JSX.Element) | ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').DateConfiguration, { disabled, readonly }: {
|
|
30
34
|
disabled?: boolean;
|
|
31
35
|
readonly?: boolean;
|
|
32
36
|
}) => JSX.Element);
|
|
33
37
|
} | {
|
|
34
38
|
type: "TEXTINPUT";
|
|
35
39
|
name: string;
|
|
40
|
+
Icon?: React.ElementType;
|
|
41
|
+
icon?: string;
|
|
42
|
+
groups: import('@opengov/form-utils').ConfigurationGroup<import('react-hook-form').FieldValues>[];
|
|
43
|
+
omitLabelConfiguration?: boolean;
|
|
36
44
|
fullWidth: boolean;
|
|
37
45
|
maxLength: number;
|
|
38
|
-
renderField: ((template: import('
|
|
46
|
+
renderField: ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').FieldConfiguration<import('react-hook-form').FieldValues>, { disabled, readonly }: {
|
|
39
47
|
disabled?: boolean;
|
|
40
48
|
readonly?: boolean;
|
|
41
|
-
}) => JSX.Element) | ((template: import('
|
|
49
|
+
}) => JSX.Element) | ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').TextConfiguration, { disabled, readonly }: {
|
|
42
50
|
disabled?: boolean;
|
|
43
51
|
readonly?: boolean;
|
|
44
|
-
}) => JSX.Element) | ((template: import('
|
|
52
|
+
}) => JSX.Element) | ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').NumberConfiguration, { disabled, readonly }: {
|
|
45
53
|
disabled?: boolean;
|
|
46
54
|
readonly?: boolean;
|
|
47
|
-
}) => JSX.Element) | ((template: import('
|
|
55
|
+
}) => JSX.Element) | ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').DateConfiguration, { disabled, readonly }: {
|
|
48
56
|
disabled?: boolean;
|
|
49
57
|
readonly?: boolean;
|
|
50
58
|
}) => JSX.Element);
|
|
51
59
|
} | {
|
|
52
60
|
type: "NUMBER";
|
|
53
61
|
name: string;
|
|
62
|
+
Icon?: React.ElementType;
|
|
63
|
+
icon?: string;
|
|
64
|
+
groups: import('@opengov/form-utils').ConfigurationGroup<import('react-hook-form').FieldValues>[];
|
|
65
|
+
omitLabelConfiguration?: boolean;
|
|
54
66
|
fullWidth: boolean;
|
|
55
67
|
decimalPlaces: number;
|
|
56
|
-
renderField: ((template: import('
|
|
68
|
+
renderField: ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').FieldConfiguration<import('react-hook-form').FieldValues>, { disabled, readonly }: {
|
|
57
69
|
disabled?: boolean;
|
|
58
70
|
readonly?: boolean;
|
|
59
|
-
}) => JSX.Element) | ((template: import('
|
|
71
|
+
}) => JSX.Element) | ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').TextConfiguration, { disabled, readonly }: {
|
|
60
72
|
disabled?: boolean;
|
|
61
73
|
readonly?: boolean;
|
|
62
|
-
}) => JSX.Element) | ((template: import('
|
|
74
|
+
}) => JSX.Element) | ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').NumberConfiguration, { disabled, readonly }: {
|
|
63
75
|
disabled?: boolean;
|
|
64
76
|
readonly?: boolean;
|
|
65
|
-
}) => JSX.Element) | ((template: import('
|
|
77
|
+
}) => JSX.Element) | ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').DateConfiguration, { disabled, readonly }: {
|
|
66
78
|
disabled?: boolean;
|
|
67
79
|
readonly?: boolean;
|
|
68
80
|
}) => JSX.Element);
|
|
69
81
|
} | {
|
|
70
82
|
type: "DATE";
|
|
71
83
|
name: string;
|
|
84
|
+
Icon?: React.ElementType;
|
|
85
|
+
icon?: string;
|
|
86
|
+
groups: import('@opengov/form-utils').ConfigurationGroup<import('react-hook-form').FieldValues>[];
|
|
87
|
+
omitLabelConfiguration?: boolean;
|
|
72
88
|
fullWidth: boolean;
|
|
73
|
-
dateFormat: import('
|
|
74
|
-
renderField: ((template: import('
|
|
89
|
+
dateFormat: import('@opengov/form-utils').DateFormat;
|
|
90
|
+
renderField: ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').FieldConfiguration<import('react-hook-form').FieldValues>, { disabled, readonly }: {
|
|
75
91
|
disabled?: boolean;
|
|
76
92
|
readonly?: boolean;
|
|
77
|
-
}) => JSX.Element) | ((template: import('
|
|
93
|
+
}) => JSX.Element) | ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').TextConfiguration, { disabled, readonly }: {
|
|
78
94
|
disabled?: boolean;
|
|
79
95
|
readonly?: boolean;
|
|
80
|
-
}) => JSX.Element) | ((template: import('
|
|
96
|
+
}) => JSX.Element) | ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').NumberConfiguration, { disabled, readonly }: {
|
|
81
97
|
disabled?: boolean;
|
|
82
98
|
readonly?: boolean;
|
|
83
|
-
}) => JSX.Element) | ((template: import('
|
|
99
|
+
}) => JSX.Element) | ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').DateConfiguration, { disabled, readonly }: {
|
|
84
100
|
disabled?: boolean;
|
|
85
101
|
readonly?: boolean;
|
|
86
102
|
}) => JSX.Element);
|
|
87
103
|
} | null;
|
|
88
104
|
export declare const useFieldTemplate: (fieldId: string) => {
|
|
89
|
-
template: import('
|
|
105
|
+
template: import('@opengov/form-utils').FieldTemplate;
|
|
90
106
|
formattedFormula: string;
|
|
91
107
|
};
|
|
92
108
|
export {};
|
package/dist/renderer/types.d.ts
CHANGED
|
@@ -1,34 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UseFormProps } from 'react-hook-form';
|
|
2
2
|
import { LayoutState } from './context/LayoutContext';
|
|
3
|
-
|
|
4
|
-
export type SectionTemplate = FieldValues & {
|
|
5
|
-
type: 'singleEntry' | 'multiEntry';
|
|
6
|
-
id: string;
|
|
7
|
-
label: string;
|
|
8
|
-
helpText?: string;
|
|
9
|
-
internal: boolean;
|
|
10
|
-
required?: boolean;
|
|
11
|
-
fields: string[];
|
|
12
|
-
sectionConditions: {
|
|
13
|
-
logicalOperator?: 'ALL' | 'ANY';
|
|
14
|
-
conditions?: ConditionTemplate[];
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
export type FormTemplate = {
|
|
18
|
-
fields: Record<string, FieldTemplate>;
|
|
19
|
-
sections: SectionTemplate[];
|
|
20
|
-
};
|
|
21
|
-
export type FieldTemplate = FieldValues & {
|
|
22
|
-
id: string;
|
|
23
|
-
label: string;
|
|
24
|
-
helpText?: string;
|
|
25
|
-
internal?: boolean;
|
|
26
|
-
required?: boolean;
|
|
27
|
-
visibleId?: string;
|
|
28
|
-
fullWidth?: boolean;
|
|
29
|
-
readonly?: boolean;
|
|
30
|
-
};
|
|
31
|
-
/** RENDERER TYPES */
|
|
3
|
+
import { FieldTypes, FormTemplate, DateFormat } from '@opengov/form-utils';
|
|
32
4
|
export type FormData = Record<string, any>;
|
|
33
5
|
export type SubmitProps = {
|
|
34
6
|
onSubmit: (data: any) => void;
|
|
@@ -55,80 +27,3 @@ export type RendererProps = {
|
|
|
55
27
|
submit?: SubmitProps;
|
|
56
28
|
readonly?: boolean;
|
|
57
29
|
};
|
|
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
|
-
export declare enum LogicTypes {
|
|
68
|
-
EQUALS = 1,
|
|
69
|
-
BETWEEN = 2,
|
|
70
|
-
LESS_THAN = 3,
|
|
71
|
-
GREATER_THAN = 4,
|
|
72
|
-
LESS_THAN_OR_EQUAL = 5,
|
|
73
|
-
GREATER_THAN_OR_EQUAL = 6,
|
|
74
|
-
HAS_FLAGS = 7,
|
|
75
|
-
IS_RENEWAL = 8,
|
|
76
|
-
IS_NOT = 9,
|
|
77
|
-
TIME_AFTER_MORE_THAN = 10,
|
|
78
|
-
TIME_BEFORE_MORE_THAN = 11,
|
|
79
|
-
DATETIME_BETWEEN = 12
|
|
80
|
-
}
|
|
81
|
-
export type DateFormat = 'yyyy-MM-dd' | 'MM/dd/yyyy' | 'dd/MM/yyyy' | 'yyyy/MM/dd' | 'dd MMM yyyy' | 'dd MMMM yyyy' | 'EEE, dd MMM yyyy' | 'EEEE, dd MMM yyyy';
|
|
82
|
-
export declare enum DateUnit {
|
|
83
|
-
DAY = "DAY",
|
|
84
|
-
WEEK = "WEEK",
|
|
85
|
-
MONTH = "MONTH",
|
|
86
|
-
YEAR = "YEAR"
|
|
87
|
-
}
|
|
88
|
-
export declare enum DayOfWeek {
|
|
89
|
-
SUNDAY = "SUNDAY",
|
|
90
|
-
MONDAY = "MONDAY",
|
|
91
|
-
TUESDAY = "TUESDAY",
|
|
92
|
-
WEDNESDAY = "WEDNESDAY",
|
|
93
|
-
THURSDAY = "THURSDAY",
|
|
94
|
-
FRIDAY = "FRIDAY",
|
|
95
|
-
SATURDAY = "SATURDAY"
|
|
96
|
-
}
|
|
97
|
-
export type DateConstraints = {
|
|
98
|
-
disableDaysOfWeek?: {
|
|
99
|
-
value: DayOfWeek;
|
|
100
|
-
}[];
|
|
101
|
-
disablePastDates?: {
|
|
102
|
-
number: number;
|
|
103
|
-
unit: DateUnit;
|
|
104
|
-
};
|
|
105
|
-
disableFutureDates?: {
|
|
106
|
-
number: number;
|
|
107
|
-
unit: DateUnit;
|
|
108
|
-
};
|
|
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>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { FormTemplate } from '
|
|
1
|
+
import { FormTemplate } from '@opengov/form-utils';
|
|
2
2
|
export declare const basicTemplate: FormTemplate;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { FormTemplate } from '
|
|
1
|
+
import { FormTemplate } from '@opengov/form-utils';
|
|
2
2
|
export declare const complexTemplate: FormTemplate;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengov/form-renderer",
|
|
3
|
-
"version": "0.0.41-config-beta.
|
|
3
|
+
"version": "0.0.41-config-beta.2",
|
|
4
4
|
"description": "OpenGov Smart Forms form renderer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"@mdi/js": "^7.4.47",
|
|
27
27
|
"@mdi/react": "^1.6.1",
|
|
28
28
|
"@mui/icons-material": "^6.1.1",
|
|
29
|
+
"@opengov/form-utils": "^0.0.1-beta.1",
|
|
29
30
|
"date-fns": "^4.1.0",
|
|
30
31
|
"sanitize-html": "^2.14.0"
|
|
31
32
|
},
|