@opengov/form-renderer 0.2.19 → 0.2.20

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.
Files changed (50) hide show
  1. package/README.md +111 -0
  2. package/index.js +99 -0
  3. package/package.json +8 -50
  4. package/scripts/deploy.js +82 -0
  5. package/dist/fields/CalculatedNumber/CalculatedNumber.d.ts +0 -2
  6. package/dist/fields/CalculatedNumber/CalculatedNumberConfig.d.ts +0 -3
  7. package/dist/fields/Checkbox/Checkbox.d.ts +0 -2
  8. package/dist/fields/Checkbox/Checkbox.test.d.ts +0 -1
  9. package/dist/fields/Checkbox/CheckboxConfig.d.ts +0 -3
  10. package/dist/fields/DateInput/DateConfig.d.ts +0 -3
  11. package/dist/fields/DateInput/DateInput.d.ts +0 -9
  12. package/dist/fields/DateInput/DateInput.test.d.ts +0 -1
  13. package/dist/fields/Dropdown/Dropdown.d.ts +0 -6
  14. package/dist/fields/Dropdown/Dropdown.test.d.ts +0 -1
  15. package/dist/fields/Dropdown/DropdownConfig.d.ts +0 -3
  16. package/dist/fields/ErrorMessage.d.ts +0 -5
  17. package/dist/fields/FormFieldLabel.d.ts +0 -13
  18. package/dist/fields/Number/NumberConfig.d.ts +0 -3
  19. package/dist/fields/Number/NumberInput.d.ts +0 -5
  20. package/dist/fields/Number/NumberInput.test.d.ts +0 -1
  21. package/dist/fields/ReadOnlyField/LabelWithChildren.d.ts +0 -10
  22. package/dist/fields/ReadOnlyField/ReadOnlyField.test.d.ts +0 -1
  23. package/dist/fields/ReadOnlyField/index.d.ts +0 -10
  24. package/dist/fields/Text/TextConfig.d.ts +0 -3
  25. package/dist/fields/Text/TextInput.d.ts +0 -6
  26. package/dist/fields/Text/TextInput.test.d.ts +0 -1
  27. package/dist/fields/defaultFields.d.ts +0 -4
  28. package/dist/fields/types.d.ts +0 -10
  29. package/dist/index.d.ts +0 -17
  30. package/dist/index.test.d.ts +0 -0
  31. package/dist/lib.js +0 -21030
  32. package/dist/lib.umd.cjs +0 -164
  33. package/dist/renderer/AutosaveForm.d.ts +0 -12
  34. package/dist/renderer/AutosaveForm.test.d.ts +0 -1
  35. package/dist/renderer/Field.d.ts +0 -26
  36. package/dist/renderer/Form.d.ts +0 -17
  37. package/dist/renderer/RendererProvider.d.ts +0 -11
  38. package/dist/renderer/Section.d.ts +0 -24
  39. package/dist/renderer/context/FormRendererContext.d.ts +0 -16
  40. package/dist/renderer/context/FormRendererContext.test.d.ts +0 -1
  41. package/dist/renderer/context/LayoutContext.d.ts +0 -18
  42. package/dist/renderer/types.d.ts +0 -19
  43. package/dist/stories/Basic.d.ts +0 -1
  44. package/dist/stories/Compound.d.ts +0 -1
  45. package/dist/stories/FormRenderer.stories.d.ts +0 -6
  46. package/dist/stories/basicForm.d.ts +0 -2
  47. package/dist/stories/basicTemplate.d.ts +0 -2
  48. package/dist/stories/complexForm.d.ts +0 -2
  49. package/dist/stories/complexTemplate.d.ts +0 -2
  50. package/dist/utils/TestWrapper.d.ts +0 -6
@@ -1,12 +0,0 @@
1
- import { default as React } from 'react';
2
- import { FieldValues, UseFormProps } from 'react-hook-form';
3
- import { FormData } from './types';
4
- export default function Form({ children, formOptions, submitOptions, }: {
5
- children: React.ReactNode;
6
- formOptions?: UseFormProps<FieldValues>;
7
- submitOptions: {
8
- onBlur?: (data: FormData) => void;
9
- onSubmit?: (data: FormData) => void;
10
- formId?: string;
11
- };
12
- }): import("react/jsx-runtime").JSX.Element;
@@ -1 +0,0 @@
1
- export {};
@@ -1,26 +0,0 @@
1
- import { SxProps } from '@mui/material';
2
- import { FieldTemplate, FieldRules } from '@opengov/form-utils';
3
- /**
4
- * Field is a component that renders a field.
5
- * It takes a fieldId and readonly.
6
- * It uses the field template and the field type to render a field.
7
- * The field is wrapped in a Box that can be styled by the layout object passed to the RendererProvider.
8
- * @param id - The fieldId to render.
9
- * @param name - The name of the field within the form.
10
- * @param readonly - Whether the field is readonly.
11
- * @param disabled - Whether the field is disabled.
12
- * @returns A Field component.
13
- */
14
- export default function Field({ id, name, readonly, disabled, wrapper, icons, rules, }: {
15
- id: string;
16
- name?: string;
17
- readonly?: boolean;
18
- disabled?: boolean;
19
- wrapper?: React.ComponentType<{
20
- children: React.ReactNode;
21
- field: FieldTemplate;
22
- sx?: SxProps;
23
- }>;
24
- icons?: React.ReactNode;
25
- rules?: FieldRules;
26
- }): import("react/jsx-runtime").JSX.Element;
@@ -1,17 +0,0 @@
1
- import { UseFormProps } from 'react-hook-form';
2
- import { SubmitOptions } from './types';
3
- /**
4
- * Form is a component that renders a form.
5
- * It takes children, formOptions, and submitOptions.
6
- * It renders a FormProvider with the formOptions.
7
- * It renders a form with the submitOptions.
8
- * @param children - The children to render.
9
- * @param formOptions - The form options to use.
10
- * @param submitOptions - The submit options to use.
11
- * @returns A Form component.
12
- */
13
- export default function Form({ children, formOptions, submitOptions, }: {
14
- children: React.ReactNode;
15
- formOptions?: UseFormProps;
16
- submitOptions?: SubmitOptions;
17
- }): import("react/jsx-runtime").JSX.Element;
@@ -1,11 +0,0 @@
1
- import { default as React } from 'react';
2
- import { LayoutState } from './context/LayoutContext';
3
- import { FormTemplate, FieldTypes } from '@opengov/form-utils';
4
- interface RendererProviderProps {
5
- children: React.ReactNode;
6
- template: FormTemplate;
7
- fieldTypes?: FieldTypes[];
8
- layout?: LayoutState;
9
- }
10
- export default function RendererProvider({ children, template, fieldTypes, layout, }: RendererProviderProps): import("react/jsx-runtime").JSX.Element;
11
- export {};
@@ -1,24 +0,0 @@
1
- import { SxProps } from '@mui/material';
2
- import { FieldTemplate, SectionTemplate } from '@opengov/form-utils';
3
- /**
4
- * Section is a component that renders a section.
5
- * It takes a section template, a list of fields, and readonly.
6
- * It renders a Box with the section layout.
7
- * It maps every field to a Field component, passing the readonly prop.
8
- * @param section - The section template to render.
9
- * @param fields - The fields to render.
10
- * @param readonly - Whether the section is readonly.
11
- * @returns A Section component.
12
- */
13
- export default function Section({ section, fields, fieldNames, readonly, disabled, fieldWrapper, }: {
14
- section: SectionTemplate;
15
- fields: string[];
16
- fieldNames?: string[];
17
- readonly?: boolean;
18
- disabled?: boolean;
19
- fieldWrapper?: React.ComponentType<{
20
- children: React.ReactNode;
21
- field: FieldTemplate;
22
- sx?: SxProps;
23
- }>;
24
- }): import("react/jsx-runtime").JSX.Element;
@@ -1,16 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { FormTemplate, FieldTypes } from '@opengov/form-utils';
3
- export interface FormRendererContextType {
4
- template: FormTemplate;
5
- fieldTypes: FieldTypes[];
6
- }
7
- interface FormRendererProviderProps {
8
- children: ReactNode;
9
- template: FormTemplate;
10
- fieldTypes: FieldTypes[];
11
- }
12
- export declare const FormRendererProvider: React.FC<FormRendererProviderProps>;
13
- export declare const useFormRenderer: () => FormRendererContextType;
14
- export declare const useFieldType: (type?: string) => FieldTypes | null;
15
- export declare const useFieldTemplate: (fieldId: string) => import('@opengov/form-utils').FieldTemplate;
16
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,18 +0,0 @@
1
- import { SxProps, Theme } from '@mui/material';
2
- import { FieldConfiguration, FieldTemplate, SectionTemplate } from '@opengov/form-utils';
3
- import { default as React, ReactNode } from 'react';
4
- export interface LayoutState {
5
- section?: (template: SectionTemplate) => SxProps<Theme>;
6
- field?: (template: FieldTemplate, config?: FieldConfiguration) => SxProps<Theme>;
7
- }
8
- interface FormLayoutContextProps {
9
- layout: LayoutState;
10
- }
11
- declare const FormLayoutContext: React.Context<FormLayoutContextProps | undefined>;
12
- interface FormLayoutProviderProps {
13
- children: ReactNode;
14
- layout?: LayoutState;
15
- }
16
- export declare const FormLayoutProvider: React.FC<FormLayoutProviderProps>;
17
- export declare const useFormLayout: () => LayoutState;
18
- export default FormLayoutContext;
@@ -1,19 +0,0 @@
1
- import { UseFormProps } from 'react-hook-form';
2
- import { LayoutState } from './context/LayoutContext';
3
- import { FieldTypes, FormTemplate } from '@opengov/form-utils';
4
- export type FormData = Record<string, any>;
5
- export type SubmitOptions = {
6
- onSubmit?: (data: FormData) => void | Promise<void>;
7
- onReset?: () => void | Promise<void>;
8
- formId?: string;
9
- submitOnChange?: boolean;
10
- registerForm?: (ref: HTMLFormElement | null) => void;
11
- };
12
- export type FormRendererProps = {
13
- fieldTypes?: FieldTypes[];
14
- template: FormTemplate;
15
- layout?: LayoutState;
16
- readonly?: boolean;
17
- formOptions?: UseFormProps;
18
- submitOptions?: SubmitOptions;
19
- };
@@ -1 +0,0 @@
1
- export default function BasicExample(): import("react/jsx-runtime").JSX.Element;
@@ -1 +0,0 @@
1
- export default function CompoundExample(): import("react/jsx-runtime").JSX.Element;
@@ -1,6 +0,0 @@
1
- import { Meta, StoryObj } from '@storybook/react';
2
- declare const meta: Meta;
3
- export default meta;
4
- type Story = StoryObj<typeof meta>;
5
- export declare const Basic: Story;
6
- export declare const Compound: Story;
@@ -1,2 +0,0 @@
1
- import { FormData } from '../renderer/types';
2
- export declare const basicForm: FormData;
@@ -1,2 +0,0 @@
1
- import { FormTemplate } from '@opengov/form-utils';
2
- export declare const basicTemplate: FormTemplate;
@@ -1,2 +0,0 @@
1
- import { FormData } from '../renderer/types';
2
- export declare const complexForm: FormData;
@@ -1,2 +0,0 @@
1
- import { FormTemplate } from '@opengov/form-utils';
2
- export declare const complexTemplate: FormTemplate;
@@ -1,6 +0,0 @@
1
- import { FieldTemplate } from '@opengov/form-utils';
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;