@opengov/form-renderer 0.0.41 → 0.0.43

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.
@@ -1,13 +1,12 @@
1
1
  import { default as React } from 'react';
2
2
  import { LayoutState } from './context/LayoutContext';
3
- import { FormTemplate, FieldRenders, DateFormat } from './types';
3
+ import { FormTemplate, FieldTypes } from '@opengov/form-utils';
4
4
  interface FormProviderProps {
5
5
  children: React.ReactNode;
6
6
  layout?: LayoutState;
7
7
  template: FormTemplate;
8
- renderFields?: FieldRenders;
8
+ fieldTypes?: FieldTypes[];
9
9
  readonly?: boolean;
10
- dateFormat?: DateFormat;
11
10
  }
12
- declare function FormProvider({ children, layout, template, renderFields, readonly, dateFormat, }: FormProviderProps): import("react/jsx-runtime").JSX.Element;
11
+ declare function FormProvider({ children, layout, template, fieldTypes, readonly }: FormProviderProps): import("react/jsx-runtime").JSX.Element;
13
12
  export default FormProvider;
@@ -1,24 +1,108 @@
1
1
  import { ReactNode } from 'react';
2
- import { FieldRenders, FormTemplate } from '../types';
2
+ import { FormTemplate, FieldTypes } from '@opengov/form-utils';
3
3
  export interface FormRendererContextType {
4
4
  template: FormTemplate;
5
- renderFields?: FieldRenders;
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
- renderFields?: FieldRenders;
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 useFormField: (fieldId: string) => {
19
- template: import('../types').FieldTemplate;
20
- render: (field: import('../types').FieldTemplate) => JSX.Element;
21
- renderReadOnly: ((field: import('../types').FieldTemplate) => JSX.Element) | undefined;
16
+ export declare const useFieldType: (type?: string) => {
17
+ type: string;
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;
23
+ fullWidth: boolean;
24
+ renderField: ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').FieldConfiguration<import('react-hook-form').FieldValues>, { disabled, readonly }: {
25
+ disabled?: boolean;
26
+ readonly?: boolean;
27
+ }) => JSX.Element) | ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').TextConfiguration, { disabled, readonly }: {
28
+ disabled?: boolean;
29
+ readonly?: boolean;
30
+ }) => JSX.Element) | ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').NumberConfiguration, { disabled, readonly }: {
31
+ disabled?: boolean;
32
+ readonly?: boolean;
33
+ }) => JSX.Element) | ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').DateConfiguration, { disabled, readonly }: {
34
+ disabled?: boolean;
35
+ readonly?: boolean;
36
+ }) => JSX.Element);
37
+ } | {
38
+ type: string;
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;
44
+ fullWidth: boolean;
45
+ maxLength: number;
46
+ renderField: ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').FieldConfiguration<import('react-hook-form').FieldValues>, { disabled, readonly }: {
47
+ disabled?: boolean;
48
+ readonly?: boolean;
49
+ }) => JSX.Element) | ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').TextConfiguration, { disabled, readonly }: {
50
+ disabled?: boolean;
51
+ readonly?: boolean;
52
+ }) => JSX.Element) | ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').NumberConfiguration, { disabled, readonly }: {
53
+ disabled?: boolean;
54
+ readonly?: boolean;
55
+ }) => JSX.Element) | ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').DateConfiguration, { disabled, readonly }: {
56
+ disabled?: boolean;
57
+ readonly?: boolean;
58
+ }) => JSX.Element);
59
+ } | {
60
+ type: string;
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;
66
+ fullWidth: boolean;
67
+ decimalPlaces: number;
68
+ renderField: ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').FieldConfiguration<import('react-hook-form').FieldValues>, { disabled, readonly }: {
69
+ disabled?: boolean;
70
+ readonly?: boolean;
71
+ }) => JSX.Element) | ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').TextConfiguration, { disabled, readonly }: {
72
+ disabled?: boolean;
73
+ readonly?: boolean;
74
+ }) => JSX.Element) | ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').NumberConfiguration, { disabled, readonly }: {
75
+ disabled?: boolean;
76
+ readonly?: boolean;
77
+ }) => JSX.Element) | ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').DateConfiguration, { disabled, readonly }: {
78
+ disabled?: boolean;
79
+ readonly?: boolean;
80
+ }) => JSX.Element);
81
+ } | {
82
+ type: string;
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;
88
+ fullWidth: boolean;
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 }: {
91
+ disabled?: boolean;
92
+ readonly?: boolean;
93
+ }) => JSX.Element) | ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').TextConfiguration, { disabled, readonly }: {
94
+ disabled?: boolean;
95
+ readonly?: boolean;
96
+ }) => JSX.Element) | ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').NumberConfiguration, { disabled, readonly }: {
97
+ disabled?: boolean;
98
+ readonly?: boolean;
99
+ }) => JSX.Element) | ((template: import('@opengov/form-utils').FieldTemplate, config: import('@opengov/form-utils').DateConfiguration, { disabled, readonly }: {
100
+ disabled?: boolean;
101
+ readonly?: boolean;
102
+ }) => JSX.Element);
103
+ } | null;
104
+ export declare const useFieldTemplate: (fieldId: string) => {
105
+ template: import('@opengov/form-utils').FieldTemplate;
22
106
  formattedFormula: string;
23
107
  };
24
108
  export {};
@@ -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, renderFields, layout, readonly, formOptions, submit, dateFormat, }: FormRendererProps): import("react/jsx-runtime").JSX.Element;
11
+ export default function FormRenderer({ template, fieldTypes, layout, readonly, formOptions, submit, }: FormRendererProps): import("react/jsx-runtime").JSX.Element;
@@ -1,46 +1,6 @@
1
- import { FieldValues, UseFormProps } from 'react-hook-form';
1
+ import { UseFormProps } from 'react-hook-form';
2
2
  import { LayoutState } from './context/LayoutContext';
3
- export type SectionTemplate = FieldValues & {
4
- type: 'singleEntry' | 'multiEntry';
5
- id: string;
6
- label: string;
7
- helpText?: string;
8
- internal: boolean;
9
- required?: boolean;
10
- fields: string[];
11
- sectionConditions: {
12
- logicalOperator?: 'ALL' | 'ANY';
13
- conditions?: ConditionTemplate[];
14
- };
15
- };
16
- export type FormTemplate = {
17
- fields: Record<string, FieldTemplate>;
18
- sections: SectionTemplate[];
19
- };
20
- export type FieldTemplate = FieldValues & {
21
- id: string;
22
- label: string;
23
- helpText?: string;
24
- internal?: boolean;
25
- required?: boolean;
26
- visibleId?: string;
27
- fullWidth?: boolean;
28
- readonly?: boolean;
29
- };
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
- };
3
+ import { FieldTypes, FormTemplate, DateFormat } from '@opengov/form-utils';
44
4
  export type FormData = Record<string, any>;
45
5
  export type SubmitProps = {
46
6
  onSubmit: (data: any) => void;
@@ -49,7 +9,7 @@ export type SubmitProps = {
49
9
  submitOnChange?: boolean;
50
10
  };
51
11
  export type FormRendererProps = {
52
- renderFields?: FieldRenders;
12
+ fieldTypes?: FieldTypes[];
53
13
  template: FormTemplate;
54
14
  layout?: LayoutState;
55
15
  readonly?: boolean;
@@ -67,44 +27,3 @@ export type RendererProps = {
67
27
  submit?: SubmitProps;
68
28
  readonly?: boolean;
69
29
  };
70
- export declare enum LogicTypes {
71
- EQUALS = 1,
72
- BETWEEN = 2,
73
- LESS_THAN = 3,
74
- GREATER_THAN = 4,
75
- LESS_THAN_OR_EQUAL = 5,
76
- GREATER_THAN_OR_EQUAL = 6,
77
- HAS_FLAGS = 7,
78
- IS_RENEWAL = 8,
79
- IS_NOT = 9,
80
- TIME_AFTER_MORE_THAN = 10,
81
- TIME_BEFORE_MORE_THAN = 11,
82
- DATETIME_BETWEEN = 12
83
- }
84
- 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';
85
- export declare enum DateUnit {
86
- DAY = "DAY",
87
- WEEK = "WEEK",
88
- MONTH = "MONTH",
89
- YEAR = "YEAR"
90
- }
91
- export declare enum DayOfWeek {
92
- SUNDAY = "SUNDAY",
93
- MONDAY = "MONDAY",
94
- TUESDAY = "TUESDAY",
95
- WEDNESDAY = "WEDNESDAY",
96
- THURSDAY = "THURSDAY",
97
- FRIDAY = "FRIDAY",
98
- SATURDAY = "SATURDAY"
99
- }
100
- export type DateConstraints = {
101
- disableDaysOfWeek?: DayOfWeek[];
102
- disablePastDates?: {
103
- number: number;
104
- unit: DateUnit;
105
- };
106
- disableFutureDates?: {
107
- number: number;
108
- unit: DateUnit;
109
- };
110
- };
@@ -1,2 +1,2 @@
1
- import { FormTemplate } from '../renderer/types';
1
+ import { FormTemplate } from '@opengov/form-utils';
2
2
  export declare const basicTemplate: FormTemplate;
@@ -1,2 +1,2 @@
1
- import { FormTemplate } from '../renderer/types';
1
+ import { FormTemplate } from '@opengov/form-utils';
2
2
  export declare const complexTemplate: FormTemplate;
@@ -1,4 +1,4 @@
1
- import { FieldTemplate } from '../renderer/types';
1
+ import { FieldTemplate } from '@opengov/form-utils';
2
2
  export default function TestWrapper({ children, fieldTemplate, defaultValues, }: {
3
3
  children: React.ReactNode;
4
4
  fieldTemplate: FieldTemplate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengov/form-renderer",
3
- "version": "0.0.41",
3
+ "version": "0.0.43",
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.2",
29
30
  "date-fns": "^4.1.0",
30
31
  "sanitize-html": "^2.14.0"
31
32
  },
@@ -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;
@@ -1,3 +0,0 @@
1
- import { TextFieldProps } from '@mui/material';
2
- import { GeneralInputProps } from './types';
3
- export default function NumberInput(props: Omit<GeneralInputProps & TextFieldProps, 'type'>): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +0,0 @@
1
- import { TextFieldProps } from '@mui/material';
2
- import { GeneralInputProps } from './types';
3
- declare function TextInput({ name, label, rules, sx, ...rest }: GeneralInputProps & TextFieldProps): import("react/jsx-runtime").JSX.Element;
4
- export default TextInput;