@availity/mui-controlled-form 0.3.1 → 1.0.0-alpha.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/CHANGELOG.md CHANGED
@@ -2,6 +2,33 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [1.0.0-alpha.0](https://github.com/Availity/element/compare/@availity/mui-controlled-form@0.3.2...@availity/mui-controlled-form@1.0.0-alpha.0) (2025-02-24)
6
+
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ * upgraded to @mui/material v6
11
+ * **element:** upgraded to @mui/material v6
12
+
13
+ ### Features
14
+
15
+ * **element:** upgrade to @mui/material v6 ([cb958bb](https://github.com/Availity/element/commit/cb958bba99a4f1ee6dab323f0ff54b69e6fd3493))
16
+ * **mui-controlled-form:** remove deprecated props and controlledform ([43e376f](https://github.com/Availity/element/commit/43e376fed54eb2f31d7dcdad382987aa1faac94c))
17
+ * upgrade @mui/material ([571453a](https://github.com/Availity/element/commit/571453a34b21c344594ab4c03bc497d19aba942b))
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **mui-controlled-form:** forward rules.required ([a70fa6a](https://github.com/Availity/element/commit/a70fa6a33fbdaa2ecf471896faabcbed523f3a8d))
23
+
24
+ ## [0.3.2](https://github.com/Availity/element/compare/@availity/mui-controlled-form@0.3.1...@availity/mui-controlled-form@0.3.2) (2025-02-18)
25
+
26
+ ### Dependency Updates
27
+
28
+ * `mui-autocomplete` updated to version `0.3.1`
29
+ * `mui-datepicker` updated to version `0.3.1`
30
+ * `mui-form-utils` updated to version `0.3.1`
31
+ * `mui-textfield` updated to version `0.3.1`
5
32
  ## [0.3.1](https://github.com/Availity/element/compare/@availity/mui-controlled-form@0.3.0...@availity/mui-controlled-form@0.3.1) (2025-02-17)
6
33
 
7
34
 
package/dist/index.d.mts CHANGED
@@ -1,160 +1,67 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as react from 'react';
3
- import { FormHTMLAttributes } from 'react';
4
2
  import { AutocompleteProps, AsyncAutocompleteProps, CodesAutocompleteProps, OrgAutocompleteProps, ProviderAutocompleteProps } from '@availity/mui-autocomplete';
5
- import { RegisterOptions, FieldValues, ControllerProps as ControllerProps$1, SubmitHandler, Resolver, UseFormProps } from 'react-hook-form';
3
+ import { RegisterOptions, FieldValues, ControllerProps as ControllerProps$1 } from 'react-hook-form';
6
4
  export { FormProvider, SubmitHandler, UseFormProps, UseFormReturn, useForm, useFormContext } from 'react-hook-form';
7
5
  import { ChipTypeMap } from '@mui/material/Chip';
8
6
  import { CheckboxProps } from '@availity/mui-checkbox';
9
7
  import { DatepickerProps } from '@availity/mui-datepicker';
10
- import { InputProps, RadioGroupProps, SelectProps } from '@availity/mui-form-utils';
8
+ import { InputProps, RadioGroupProps, FormControlProps, SelectProps } from '@availity/mui-form-utils';
11
9
  import { TextFieldProps } from '@availity/mui-textfield';
12
10
 
13
- type ControlledAutocompleteProps<T, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> = Omit<AutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps & DeprecatedRulesProps;
14
- declare const ControlledAutocomplete: <T, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends react.ElementType<any, keyof react.JSX.IntrinsicElements> = "div">({ name, FieldProps, defaultValue, rules, deps, max, maxLength, min, minLength, onBlur, onChange, pattern, required, shouldUnregister, validate, value, ...rest }: ControlledAutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>) => react_jsx_runtime.JSX.Element;
11
+ type ControlledAutocompleteProps<T, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> = Omit<AutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps;
12
+ declare const ControlledAutocomplete: <T, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = "div">({ name, FieldProps, defaultValue, rules, onBlur, onChange, shouldUnregister, value, ...rest }: ControlledAutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>) => react_jsx_runtime.JSX.Element;
15
13
 
16
- type DeprecatedRulesProps = {
17
- /** @deprecated moved to `rules` prop. */
18
- deps?: RegisterOptions<FieldValues, string>["deps"];
19
- /** The maximum value to accept for this input.
20
- *
21
- * @deprecated moved to `rules` prop.
22
- `*/
23
- max?: RegisterOptions<FieldValues, string>["max"];
24
- /** The maximum length of the value to accept for this input.
25
- *
26
- * @deprecated moved to `rules` prop.
27
- */
28
- maxLength?: RegisterOptions<FieldValues, string>["maxLength"];
29
- /** The minimum value to accept for this input.
30
- *
31
- * @deprecated moved to `rules` prop.
32
- */
33
- min?: RegisterOptions<FieldValues, string>["min"];
34
- /** The minimum length of the value to accept for this input.
35
- *
36
- * @deprecated moved to `rules` prop.
37
- */
38
- minLength?: RegisterOptions<FieldValues, string>["minLength"];
39
- /** The regex pattern for the input.
40
- *
41
- * @deprecated moved to `rules` prop.
42
- */
43
- pattern?: RegisterOptions<FieldValues, string>["pattern"];
44
- /** A Boolean which, if true, indicates that the input must have a value before
45
- * the form can be submitted. You can assign a string to return an error message
46
- * in the errors object.
47
- * Note: This config aligns with web constrained API for required input validation,
48
- * for object or array type of input use validate function instead.
49
- *
50
- * @deprecated moved to `rules` prop.
51
- */
52
- required?: RegisterOptions<FieldValues, string>["required"];
53
- /** @deprecated moved to `rules` prop. */
54
- validate?: RegisterOptions<FieldValues, string>["validate"];
55
- };
56
14
  type ControllerProps = {
57
15
  /** Unique name of your input */
58
- name: ControllerProps$1["name"];
16
+ name: ControllerProps$1['name'];
59
17
  /** **Important**: Can not apply undefined to defaultValue or defaultValues at useForm.
60
18
  * - You need to either set defaultValue at the field-level or useForm's defaultValues. undefined is not a valid value.
61
19
  * - If your form will invoke reset with default values, you will need to provide useForm with defaultValues.
62
20
  * - Calling onChange with undefined is not valid. You should use null or the empty string as your default/cleared value instead. */
63
- defaultValue?: ControllerProps$1["defaultValue"];
21
+ defaultValue?: ControllerProps$1['defaultValue'];
64
22
  /** If the input is disabled */
65
- disabled?: ControllerProps$1["disabled"];
23
+ disabled?: ControllerProps$1['disabled'];
66
24
  /** react-hook-form internal validation rules in the same format as [register options](https://react-hook-form.com/docs/useform/register#options), which includes:
67
25
  * required, min, max, minLength, maxLength, pattern, validate
68
26
  *
69
27
  * Not used if 3rd party schema/resolver used. */
70
- rules?: ControllerProps$1["rules"];
28
+ rules?: ControllerProps$1['rules'];
71
29
  /** Input will be unregistered after unmount and defaultValues will be removed as well. */
72
- shouldUnregister?: ControllerProps$1["shouldUnregister"];
30
+ shouldUnregister?: ControllerProps$1['shouldUnregister'];
73
31
  };
74
32
 
75
- type ControlledAsyncAutocompleteProps<Option, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> = Omit<AsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps & DeprecatedRulesProps;
76
- declare const ControlledAsyncAutocomplete: <Option, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends react.ElementType<any, keyof react.JSX.IntrinsicElements> = "div">({ name, deps, max, maxLength, min, minLength, onBlur, onChange, pattern, required, rules, shouldUnregister, validate, value, FieldProps, ...rest }: ControlledAsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>) => react_jsx_runtime.JSX.Element;
77
-
78
- type ControlledCheckboxProps = Omit<CheckboxProps, 'disabled' | 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'disabled' | 'onBlur' | 'onChange' | 'value'> & ControllerProps & Omit<DeprecatedRulesProps, 'required' | 'max' | 'maxLength' | 'min' | 'minLength' | 'pattern'>;
79
- declare const ControlledCheckbox: ({ name, disabled, onChange, onBlur, value, defaultValue, rules, shouldUnregister, deps, validate, ...rest }: ControlledCheckboxProps) => react_jsx_runtime.JSX.Element;
33
+ type ControlledAsyncAutocompleteProps<Option, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> = Omit<AsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps;
34
+ declare const ControlledAsyncAutocomplete: <Option, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = "div">({ name, onBlur, onChange, rules, shouldUnregister, value, FieldProps, ...rest }: ControlledAsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>) => react_jsx_runtime.JSX.Element;
80
35
 
81
- type ControlledCodesAutocompleteProps = Omit<CodesAutocompleteProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps & DeprecatedRulesProps;
82
- declare const ControlledCodesAutocomplete: ({ name, defaultValue, deps, max, maxLength, onBlur, onChange, pattern, required, rules, shouldUnregister, validate, value, FieldProps, ...rest }: ControlledCodesAutocompleteProps) => react_jsx_runtime.JSX.Element;
36
+ type ControlledCheckboxProps = Omit<CheckboxProps, 'disabled' | 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'disabled' | 'onBlur' | 'onChange' | 'value'> & ControllerProps;
37
+ declare const ControlledCheckbox: ({ name, disabled, onChange, onBlur, value, defaultValue, rules, shouldUnregister, ...rest }: ControlledCheckboxProps) => react_jsx_runtime.JSX.Element;
83
38
 
84
- /** @deprecated Use `UseFormProps` directly with `useForm` and `FormProvider` */
85
- type ControlledFormProps = {
86
- /** This function will receive the form data if form validation is successful. */
87
- onSubmit: SubmitHandler<any>;
88
- /** Reactive values to update the form values. */
89
- values: Record<string, any>;
90
- /** The schema used by the validationResolver. */
91
- schema?: unknown;
92
- /** Integrates with your preferred schema validation library.
93
- * More information on react-hook-form's resolvers can be
94
- * found here: https://github.com/react-hook-form/resolvers#quickstart
95
- */
96
- validationResolver?: (schema: unknown) => Resolver;
97
- /** Additional react-hook-form `useForm` options, like `defaultValues` and validation `mode`. For more information see the [react-hook-form useForm docs](https://react-hook-form.com/docs/useform) */
98
- additionalUseFormOptions?: Omit<UseFormProps, 'values' | 'resolver'>;
99
- } & FormHTMLAttributes<HTMLFormElement>;
100
- /** @deprecated Use `FormProvider` and `useForm` directly. */
101
- declare const ControlledForm: ({ onSubmit, values, schema, validationResolver, additionalUseFormOptions, ...rest }: ControlledFormProps) => react_jsx_runtime.JSX.Element;
39
+ type ControlledCodesAutocompleteProps = Omit<CodesAutocompleteProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps;
40
+ declare const ControlledCodesAutocomplete: ({ name, defaultValue, onBlur, onChange, rules, shouldUnregister, value, FieldProps, ...rest }: ControlledCodesAutocompleteProps) => react_jsx_runtime.JSX.Element;
102
41
 
103
- type ControlledDatepickerProps = Omit<DatepickerProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps & DeprecatedRulesProps;
104
- declare const ControlledDatepicker: ({ name, defaultValue, deps, max, maxLength, min, minLength, onBlur, onChange, pattern, required, rules, shouldUnregister, validate, value, FieldProps, ...rest }: ControlledDatepickerProps) => react_jsx_runtime.JSX.Element;
42
+ type ControlledDatepickerProps = Omit<DatepickerProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps;
43
+ declare const ControlledDatepicker: ({ name, defaultValue, onBlur, onChange, rules, shouldUnregister, value, FieldProps, ...rest }: ControlledDatepickerProps) => react_jsx_runtime.JSX.Element;
105
44
 
106
- type ControlledInputProps = Omit<InputProps, 'onBlur' | 'onChange' | 'value' | 'name' | 'required'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps & Omit<DeprecatedRulesProps, 'required'> & {
107
- /** If `true`, will add `aria-required` to `input`.
108
- *
109
- * @deprecated There has been a collision of properties. The boolean value
110
- * to mark the input as required will remain in future versions, but the
111
- * required object for `react-hook-form` has been moved to the `rules` prop.
112
- */
113
- required?: boolean | RegisterOptions['required'];
114
- };
115
- declare const ControlledInput: ({ name, defaultValue, deps, disabled, max, maxLength, min, minLength, onBlur, onChange, pattern, required, rules, shouldUnregister, validate, value, ...rest }: ControlledInputProps) => react_jsx_runtime.JSX.Element;
45
+ type ControlledInputProps = Omit<InputProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps;
46
+ declare const ControlledInput: ({ name, defaultValue, disabled, onBlur, onChange, rules, shouldUnregister, value, ...rest }: ControlledInputProps) => react_jsx_runtime.JSX.Element;
116
47
 
117
- type ControlledOrgAutocompleteProps = Omit<OrgAutocompleteProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps & Omit<DeprecatedRulesProps, 'max' | 'maxLength' | 'min' | 'minLength'>;
118
- declare const ControlledOrganizationAutocomplete: ({ name, defaultValue, deps, onBlur, onChange, pattern, required, rules, shouldUnregister, validate, value, FieldProps, ...rest }: ControlledOrgAutocompleteProps) => react_jsx_runtime.JSX.Element;
48
+ type ControlledOrgAutocompleteProps = Omit<OrgAutocompleteProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps;
49
+ declare const ControlledOrganizationAutocomplete: ({ name, defaultValue, onBlur, onChange, rules, shouldUnregister, value, FieldProps, ...rest }: ControlledOrgAutocompleteProps) => react_jsx_runtime.JSX.Element;
119
50
 
120
- type ControlledProviderAutocompleteProps = Omit<ProviderAutocompleteProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps & DeprecatedRulesProps;
121
- declare const ControlledProviderAutocomplete: ({ name, defaultValue, deps, max, maxLength, min, minLength, onBlur, onChange, pattern, required, rules, shouldUnregister, validate, value, FieldProps, ...rest }: ControlledProviderAutocompleteProps) => react_jsx_runtime.JSX.Element;
51
+ type ControlledProviderAutocompleteProps = Omit<ProviderAutocompleteProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps;
52
+ declare const ControlledProviderAutocomplete: ({ name, defaultValue, onBlur, onChange, rules, shouldUnregister, value, FieldProps, ...rest }: ControlledProviderAutocompleteProps) => react_jsx_runtime.JSX.Element;
122
53
 
123
54
  type ControlledRadioGroupProps = {
124
55
  name: string;
125
56
  label: string;
126
57
  helperText?: string;
127
- } & Omit<RadioGroupProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps & Omit<DeprecatedRulesProps, 'max' | 'maxLength' | 'min' | 'minLength' | 'pattern' | 'required' | 'validate'> & {
128
- /** If `true`, will add `aria-required` to `input`.
129
- *
130
- * @deprecated There has been a collision of properties. The boolean value
131
- * to mark the input as required will remain in future versions, but the
132
- * required object for `react-hook-form` has been moved to the `rules` prop.
133
- */
134
- required?: boolean | RegisterOptions['required'];
135
- };
136
- declare const ControlledRadioGroup: ({ name, helperText, label, defaultValue, deps, onBlur, onChange, required, rules, shouldUnregister, value, ...rest }: ControlledRadioGroupProps) => react_jsx_runtime.JSX.Element;
58
+ } & Omit<RadioGroupProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps & Pick<FormControlProps, 'required'>;
59
+ declare const ControlledRadioGroup: ({ name, helperText, label, defaultValue, onBlur, onChange, required, rules, shouldUnregister, value, ...rest }: ControlledRadioGroupProps) => react_jsx_runtime.JSX.Element;
137
60
 
138
- type ControlledSelectProps = Omit<SelectProps, 'onBlur' | 'onChange' | 'value' | 'name' | 'required'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps & Omit<DeprecatedRulesProps, 'required'> & {
139
- /** If `true`, will add `aria-required` to `input`.
140
- *
141
- * @deprecated There has been a collision of properties. The boolean value
142
- * to mark the input as required will remain in future versions, but the
143
- * required object for `react-hook-form` has been moved to the `rules` prop.
144
- */
145
- required?: boolean | RegisterOptions['required'];
146
- };
147
- declare const ControlledSelect: ({ name, defaultValue, deps, disabled, max, maxLength, min, minLength, onBlur, onChange, pattern, required, rules, shouldUnregister, validate, value, ...rest }: ControlledSelectProps) => react_jsx_runtime.JSX.Element;
61
+ type ControlledSelectProps = Omit<SelectProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps;
62
+ declare const ControlledSelect: ({ name, defaultValue, disabled, onBlur, onChange, rules, shouldUnregister, value, ...rest }: ControlledSelectProps) => react_jsx_runtime.JSX.Element;
148
63
 
149
- type ControlledTextFieldProps = Omit<TextFieldProps, 'onBlur' | 'onChange' | 'value' | 'name' | 'required'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps & Omit<DeprecatedRulesProps, 'required'> & {
150
- /** If `true`, will add required asterisk to `label` and `aria-required` to `input`.
151
- *
152
- * @deprecated There has been a collision of properties. The boolean value
153
- * to mark the input as required will remain in future versions, but the
154
- * required object for `react-hook-form` has been moved to the `rules` prop.
155
- */
156
- required?: boolean | RegisterOptions['required'];
157
- };
158
- declare const ControlledTextField: ({ name, defaultValue, deps, disabled, helperText, max, maxLength, min, minLength, onBlur, onChange, pattern, required, rules, shouldUnregister, validate, value, ...rest }: ControlledTextFieldProps) => react_jsx_runtime.JSX.Element;
64
+ type ControlledTextFieldProps = Omit<TextFieldProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps;
65
+ declare const ControlledTextField: ({ name, defaultValue, disabled, helperText, onBlur, onChange, rules, shouldUnregister, value, ...rest }: ControlledTextFieldProps) => react_jsx_runtime.JSX.Element;
159
66
 
160
- export { ControlledAsyncAutocomplete, type ControlledAsyncAutocompleteProps, ControlledAutocomplete, type ControlledAutocompleteProps, ControlledCheckbox, type ControlledCheckboxProps, ControlledCodesAutocomplete, type ControlledCodesAutocompleteProps, ControlledDatepicker, type ControlledDatepickerProps, ControlledForm, type ControlledFormProps, ControlledInput, type ControlledInputProps, type ControlledOrgAutocompleteProps, ControlledOrganizationAutocomplete, ControlledProviderAutocomplete, type ControlledProviderAutocompleteProps, ControlledRadioGroup, type ControlledRadioGroupProps, ControlledSelect, type ControlledSelectProps, ControlledTextField, type ControlledTextFieldProps };
67
+ export { ControlledAsyncAutocomplete, type ControlledAsyncAutocompleteProps, ControlledAutocomplete, type ControlledAutocompleteProps, ControlledCheckbox, type ControlledCheckboxProps, ControlledCodesAutocomplete, type ControlledCodesAutocompleteProps, ControlledDatepicker, type ControlledDatepickerProps, ControlledInput, type ControlledInputProps, type ControlledOrgAutocompleteProps, ControlledOrganizationAutocomplete, ControlledProviderAutocomplete, type ControlledProviderAutocompleteProps, ControlledRadioGroup, type ControlledRadioGroupProps, ControlledSelect, type ControlledSelectProps, ControlledTextField, type ControlledTextFieldProps };
package/dist/index.d.ts CHANGED
@@ -1,160 +1,67 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as react from 'react';
3
- import { FormHTMLAttributes } from 'react';
4
2
  import { AutocompleteProps, AsyncAutocompleteProps, CodesAutocompleteProps, OrgAutocompleteProps, ProviderAutocompleteProps } from '@availity/mui-autocomplete';
5
- import { RegisterOptions, FieldValues, ControllerProps as ControllerProps$1, SubmitHandler, Resolver, UseFormProps } from 'react-hook-form';
3
+ import { RegisterOptions, FieldValues, ControllerProps as ControllerProps$1 } from 'react-hook-form';
6
4
  export { FormProvider, SubmitHandler, UseFormProps, UseFormReturn, useForm, useFormContext } from 'react-hook-form';
7
5
  import { ChipTypeMap } from '@mui/material/Chip';
8
6
  import { CheckboxProps } from '@availity/mui-checkbox';
9
7
  import { DatepickerProps } from '@availity/mui-datepicker';
10
- import { InputProps, RadioGroupProps, SelectProps } from '@availity/mui-form-utils';
8
+ import { InputProps, RadioGroupProps, FormControlProps, SelectProps } from '@availity/mui-form-utils';
11
9
  import { TextFieldProps } from '@availity/mui-textfield';
12
10
 
13
- type ControlledAutocompleteProps<T, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> = Omit<AutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps & DeprecatedRulesProps;
14
- declare const ControlledAutocomplete: <T, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends react.ElementType<any, keyof react.JSX.IntrinsicElements> = "div">({ name, FieldProps, defaultValue, rules, deps, max, maxLength, min, minLength, onBlur, onChange, pattern, required, shouldUnregister, validate, value, ...rest }: ControlledAutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>) => react_jsx_runtime.JSX.Element;
11
+ type ControlledAutocompleteProps<T, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> = Omit<AutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps;
12
+ declare const ControlledAutocomplete: <T, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = "div">({ name, FieldProps, defaultValue, rules, onBlur, onChange, shouldUnregister, value, ...rest }: ControlledAutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>) => react_jsx_runtime.JSX.Element;
15
13
 
16
- type DeprecatedRulesProps = {
17
- /** @deprecated moved to `rules` prop. */
18
- deps?: RegisterOptions<FieldValues, string>["deps"];
19
- /** The maximum value to accept for this input.
20
- *
21
- * @deprecated moved to `rules` prop.
22
- `*/
23
- max?: RegisterOptions<FieldValues, string>["max"];
24
- /** The maximum length of the value to accept for this input.
25
- *
26
- * @deprecated moved to `rules` prop.
27
- */
28
- maxLength?: RegisterOptions<FieldValues, string>["maxLength"];
29
- /** The minimum value to accept for this input.
30
- *
31
- * @deprecated moved to `rules` prop.
32
- */
33
- min?: RegisterOptions<FieldValues, string>["min"];
34
- /** The minimum length of the value to accept for this input.
35
- *
36
- * @deprecated moved to `rules` prop.
37
- */
38
- minLength?: RegisterOptions<FieldValues, string>["minLength"];
39
- /** The regex pattern for the input.
40
- *
41
- * @deprecated moved to `rules` prop.
42
- */
43
- pattern?: RegisterOptions<FieldValues, string>["pattern"];
44
- /** A Boolean which, if true, indicates that the input must have a value before
45
- * the form can be submitted. You can assign a string to return an error message
46
- * in the errors object.
47
- * Note: This config aligns with web constrained API for required input validation,
48
- * for object or array type of input use validate function instead.
49
- *
50
- * @deprecated moved to `rules` prop.
51
- */
52
- required?: RegisterOptions<FieldValues, string>["required"];
53
- /** @deprecated moved to `rules` prop. */
54
- validate?: RegisterOptions<FieldValues, string>["validate"];
55
- };
56
14
  type ControllerProps = {
57
15
  /** Unique name of your input */
58
- name: ControllerProps$1["name"];
16
+ name: ControllerProps$1['name'];
59
17
  /** **Important**: Can not apply undefined to defaultValue or defaultValues at useForm.
60
18
  * - You need to either set defaultValue at the field-level or useForm's defaultValues. undefined is not a valid value.
61
19
  * - If your form will invoke reset with default values, you will need to provide useForm with defaultValues.
62
20
  * - Calling onChange with undefined is not valid. You should use null or the empty string as your default/cleared value instead. */
63
- defaultValue?: ControllerProps$1["defaultValue"];
21
+ defaultValue?: ControllerProps$1['defaultValue'];
64
22
  /** If the input is disabled */
65
- disabled?: ControllerProps$1["disabled"];
23
+ disabled?: ControllerProps$1['disabled'];
66
24
  /** react-hook-form internal validation rules in the same format as [register options](https://react-hook-form.com/docs/useform/register#options), which includes:
67
25
  * required, min, max, minLength, maxLength, pattern, validate
68
26
  *
69
27
  * Not used if 3rd party schema/resolver used. */
70
- rules?: ControllerProps$1["rules"];
28
+ rules?: ControllerProps$1['rules'];
71
29
  /** Input will be unregistered after unmount and defaultValues will be removed as well. */
72
- shouldUnregister?: ControllerProps$1["shouldUnregister"];
30
+ shouldUnregister?: ControllerProps$1['shouldUnregister'];
73
31
  };
74
32
 
75
- type ControlledAsyncAutocompleteProps<Option, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> = Omit<AsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps & DeprecatedRulesProps;
76
- declare const ControlledAsyncAutocomplete: <Option, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends react.ElementType<any, keyof react.JSX.IntrinsicElements> = "div">({ name, deps, max, maxLength, min, minLength, onBlur, onChange, pattern, required, rules, shouldUnregister, validate, value, FieldProps, ...rest }: ControlledAsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>) => react_jsx_runtime.JSX.Element;
77
-
78
- type ControlledCheckboxProps = Omit<CheckboxProps, 'disabled' | 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'disabled' | 'onBlur' | 'onChange' | 'value'> & ControllerProps & Omit<DeprecatedRulesProps, 'required' | 'max' | 'maxLength' | 'min' | 'minLength' | 'pattern'>;
79
- declare const ControlledCheckbox: ({ name, disabled, onChange, onBlur, value, defaultValue, rules, shouldUnregister, deps, validate, ...rest }: ControlledCheckboxProps) => react_jsx_runtime.JSX.Element;
33
+ type ControlledAsyncAutocompleteProps<Option, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> = Omit<AsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps;
34
+ declare const ControlledAsyncAutocomplete: <Option, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = "div">({ name, onBlur, onChange, rules, shouldUnregister, value, FieldProps, ...rest }: ControlledAsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>) => react_jsx_runtime.JSX.Element;
80
35
 
81
- type ControlledCodesAutocompleteProps = Omit<CodesAutocompleteProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps & DeprecatedRulesProps;
82
- declare const ControlledCodesAutocomplete: ({ name, defaultValue, deps, max, maxLength, onBlur, onChange, pattern, required, rules, shouldUnregister, validate, value, FieldProps, ...rest }: ControlledCodesAutocompleteProps) => react_jsx_runtime.JSX.Element;
36
+ type ControlledCheckboxProps = Omit<CheckboxProps, 'disabled' | 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'disabled' | 'onBlur' | 'onChange' | 'value'> & ControllerProps;
37
+ declare const ControlledCheckbox: ({ name, disabled, onChange, onBlur, value, defaultValue, rules, shouldUnregister, ...rest }: ControlledCheckboxProps) => react_jsx_runtime.JSX.Element;
83
38
 
84
- /** @deprecated Use `UseFormProps` directly with `useForm` and `FormProvider` */
85
- type ControlledFormProps = {
86
- /** This function will receive the form data if form validation is successful. */
87
- onSubmit: SubmitHandler<any>;
88
- /** Reactive values to update the form values. */
89
- values: Record<string, any>;
90
- /** The schema used by the validationResolver. */
91
- schema?: unknown;
92
- /** Integrates with your preferred schema validation library.
93
- * More information on react-hook-form's resolvers can be
94
- * found here: https://github.com/react-hook-form/resolvers#quickstart
95
- */
96
- validationResolver?: (schema: unknown) => Resolver;
97
- /** Additional react-hook-form `useForm` options, like `defaultValues` and validation `mode`. For more information see the [react-hook-form useForm docs](https://react-hook-form.com/docs/useform) */
98
- additionalUseFormOptions?: Omit<UseFormProps, 'values' | 'resolver'>;
99
- } & FormHTMLAttributes<HTMLFormElement>;
100
- /** @deprecated Use `FormProvider` and `useForm` directly. */
101
- declare const ControlledForm: ({ onSubmit, values, schema, validationResolver, additionalUseFormOptions, ...rest }: ControlledFormProps) => react_jsx_runtime.JSX.Element;
39
+ type ControlledCodesAutocompleteProps = Omit<CodesAutocompleteProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps;
40
+ declare const ControlledCodesAutocomplete: ({ name, defaultValue, onBlur, onChange, rules, shouldUnregister, value, FieldProps, ...rest }: ControlledCodesAutocompleteProps) => react_jsx_runtime.JSX.Element;
102
41
 
103
- type ControlledDatepickerProps = Omit<DatepickerProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps & DeprecatedRulesProps;
104
- declare const ControlledDatepicker: ({ name, defaultValue, deps, max, maxLength, min, minLength, onBlur, onChange, pattern, required, rules, shouldUnregister, validate, value, FieldProps, ...rest }: ControlledDatepickerProps) => react_jsx_runtime.JSX.Element;
42
+ type ControlledDatepickerProps = Omit<DatepickerProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps;
43
+ declare const ControlledDatepicker: ({ name, defaultValue, onBlur, onChange, rules, shouldUnregister, value, FieldProps, ...rest }: ControlledDatepickerProps) => react_jsx_runtime.JSX.Element;
105
44
 
106
- type ControlledInputProps = Omit<InputProps, 'onBlur' | 'onChange' | 'value' | 'name' | 'required'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps & Omit<DeprecatedRulesProps, 'required'> & {
107
- /** If `true`, will add `aria-required` to `input`.
108
- *
109
- * @deprecated There has been a collision of properties. The boolean value
110
- * to mark the input as required will remain in future versions, but the
111
- * required object for `react-hook-form` has been moved to the `rules` prop.
112
- */
113
- required?: boolean | RegisterOptions['required'];
114
- };
115
- declare const ControlledInput: ({ name, defaultValue, deps, disabled, max, maxLength, min, minLength, onBlur, onChange, pattern, required, rules, shouldUnregister, validate, value, ...rest }: ControlledInputProps) => react_jsx_runtime.JSX.Element;
45
+ type ControlledInputProps = Omit<InputProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps;
46
+ declare const ControlledInput: ({ name, defaultValue, disabled, onBlur, onChange, rules, shouldUnregister, value, ...rest }: ControlledInputProps) => react_jsx_runtime.JSX.Element;
116
47
 
117
- type ControlledOrgAutocompleteProps = Omit<OrgAutocompleteProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps & Omit<DeprecatedRulesProps, 'max' | 'maxLength' | 'min' | 'minLength'>;
118
- declare const ControlledOrganizationAutocomplete: ({ name, defaultValue, deps, onBlur, onChange, pattern, required, rules, shouldUnregister, validate, value, FieldProps, ...rest }: ControlledOrgAutocompleteProps) => react_jsx_runtime.JSX.Element;
48
+ type ControlledOrgAutocompleteProps = Omit<OrgAutocompleteProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps;
49
+ declare const ControlledOrganizationAutocomplete: ({ name, defaultValue, onBlur, onChange, rules, shouldUnregister, value, FieldProps, ...rest }: ControlledOrgAutocompleteProps) => react_jsx_runtime.JSX.Element;
119
50
 
120
- type ControlledProviderAutocompleteProps = Omit<ProviderAutocompleteProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps & DeprecatedRulesProps;
121
- declare const ControlledProviderAutocomplete: ({ name, defaultValue, deps, max, maxLength, min, minLength, onBlur, onChange, pattern, required, rules, shouldUnregister, validate, value, FieldProps, ...rest }: ControlledProviderAutocompleteProps) => react_jsx_runtime.JSX.Element;
51
+ type ControlledProviderAutocompleteProps = Omit<ProviderAutocompleteProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps;
52
+ declare const ControlledProviderAutocomplete: ({ name, defaultValue, onBlur, onChange, rules, shouldUnregister, value, FieldProps, ...rest }: ControlledProviderAutocompleteProps) => react_jsx_runtime.JSX.Element;
122
53
 
123
54
  type ControlledRadioGroupProps = {
124
55
  name: string;
125
56
  label: string;
126
57
  helperText?: string;
127
- } & Omit<RadioGroupProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps & Omit<DeprecatedRulesProps, 'max' | 'maxLength' | 'min' | 'minLength' | 'pattern' | 'required' | 'validate'> & {
128
- /** If `true`, will add `aria-required` to `input`.
129
- *
130
- * @deprecated There has been a collision of properties. The boolean value
131
- * to mark the input as required will remain in future versions, but the
132
- * required object for `react-hook-form` has been moved to the `rules` prop.
133
- */
134
- required?: boolean | RegisterOptions['required'];
135
- };
136
- declare const ControlledRadioGroup: ({ name, helperText, label, defaultValue, deps, onBlur, onChange, required, rules, shouldUnregister, value, ...rest }: ControlledRadioGroupProps) => react_jsx_runtime.JSX.Element;
58
+ } & Omit<RadioGroupProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps & Pick<FormControlProps, 'required'>;
59
+ declare const ControlledRadioGroup: ({ name, helperText, label, defaultValue, onBlur, onChange, required, rules, shouldUnregister, value, ...rest }: ControlledRadioGroupProps) => react_jsx_runtime.JSX.Element;
137
60
 
138
- type ControlledSelectProps = Omit<SelectProps, 'onBlur' | 'onChange' | 'value' | 'name' | 'required'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps & Omit<DeprecatedRulesProps, 'required'> & {
139
- /** If `true`, will add `aria-required` to `input`.
140
- *
141
- * @deprecated There has been a collision of properties. The boolean value
142
- * to mark the input as required will remain in future versions, but the
143
- * required object for `react-hook-form` has been moved to the `rules` prop.
144
- */
145
- required?: boolean | RegisterOptions['required'];
146
- };
147
- declare const ControlledSelect: ({ name, defaultValue, deps, disabled, max, maxLength, min, minLength, onBlur, onChange, pattern, required, rules, shouldUnregister, validate, value, ...rest }: ControlledSelectProps) => react_jsx_runtime.JSX.Element;
61
+ type ControlledSelectProps = Omit<SelectProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps;
62
+ declare const ControlledSelect: ({ name, defaultValue, disabled, onBlur, onChange, rules, shouldUnregister, value, ...rest }: ControlledSelectProps) => react_jsx_runtime.JSX.Element;
148
63
 
149
- type ControlledTextFieldProps = Omit<TextFieldProps, 'onBlur' | 'onChange' | 'value' | 'name' | 'required'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps & Omit<DeprecatedRulesProps, 'required'> & {
150
- /** If `true`, will add required asterisk to `label` and `aria-required` to `input`.
151
- *
152
- * @deprecated There has been a collision of properties. The boolean value
153
- * to mark the input as required will remain in future versions, but the
154
- * required object for `react-hook-form` has been moved to the `rules` prop.
155
- */
156
- required?: boolean | RegisterOptions['required'];
157
- };
158
- declare const ControlledTextField: ({ name, defaultValue, deps, disabled, helperText, max, maxLength, min, minLength, onBlur, onChange, pattern, required, rules, shouldUnregister, validate, value, ...rest }: ControlledTextFieldProps) => react_jsx_runtime.JSX.Element;
64
+ type ControlledTextFieldProps = Omit<TextFieldProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps;
65
+ declare const ControlledTextField: ({ name, defaultValue, disabled, helperText, onBlur, onChange, rules, shouldUnregister, value, ...rest }: ControlledTextFieldProps) => react_jsx_runtime.JSX.Element;
159
66
 
160
- export { ControlledAsyncAutocomplete, type ControlledAsyncAutocompleteProps, ControlledAutocomplete, type ControlledAutocompleteProps, ControlledCheckbox, type ControlledCheckboxProps, ControlledCodesAutocomplete, type ControlledCodesAutocompleteProps, ControlledDatepicker, type ControlledDatepickerProps, ControlledForm, type ControlledFormProps, ControlledInput, type ControlledInputProps, type ControlledOrgAutocompleteProps, ControlledOrganizationAutocomplete, ControlledProviderAutocomplete, type ControlledProviderAutocompleteProps, ControlledRadioGroup, type ControlledRadioGroupProps, ControlledSelect, type ControlledSelectProps, ControlledTextField, type ControlledTextFieldProps };
67
+ export { ControlledAsyncAutocomplete, type ControlledAsyncAutocompleteProps, ControlledAutocomplete, type ControlledAutocompleteProps, ControlledCheckbox, type ControlledCheckboxProps, ControlledCodesAutocomplete, type ControlledCodesAutocompleteProps, ControlledDatepicker, type ControlledDatepickerProps, ControlledInput, type ControlledInputProps, type ControlledOrgAutocompleteProps, ControlledOrganizationAutocomplete, ControlledProviderAutocomplete, type ControlledProviderAutocompleteProps, ControlledRadioGroup, type ControlledRadioGroupProps, ControlledSelect, type ControlledSelectProps, ControlledTextField, type ControlledTextFieldProps };