@availity/mui-controlled-form 0.2.6 → 0.3.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 +7 -0
- package/README.md +2 -2
- package/dist/index.d.mts +122 -26
- package/dist/index.d.ts +122 -26
- package/dist/index.js +174 -132
- package/dist/index.mjs +174 -131
- package/package.json +2 -2
- package/src/index.ts +47 -0
- package/src/lib/AsyncAutocomplete.stories.tsx +21 -36
- package/src/lib/AsyncAutocomplete.test.tsx +17 -53
- package/src/lib/AsyncAutocomplete.tsx +13 -6
- package/src/lib/Autocomplete.stories.tsx +20 -33
- package/src/lib/Autocomplete.test.tsx +7 -37
- package/src/lib/Autocomplete.tsx +21 -16
- package/src/lib/Checkbox.stories.tsx +48 -46
- package/src/lib/Checkbox.test.tsx +14 -46
- package/src/lib/Checkbox.tsx +19 -16
- package/src/lib/CodesAutocomplete.stories.tsx +21 -35
- package/src/lib/CodesAutocomplete.test.tsx +20 -54
- package/src/lib/CodesAutocomplete.tsx +13 -6
- package/src/lib/ControlledForm.stories.tsx +1 -0
- package/src/lib/ControlledForm.tsx +7 -3
- package/src/lib/Datepicker.stories.tsx +19 -32
- package/src/lib/Datepicker.test.tsx +3 -35
- package/src/lib/Datepicker.tsx +18 -8
- package/src/lib/Input.stories.tsx +32 -38
- package/src/lib/Input.test.tsx +71 -7
- package/src/lib/Input.tsx +30 -15
- package/src/lib/OrganizationAutocomplete.stories.tsx +30 -35
- package/src/lib/OrganizationAutocomplete.test.tsx +23 -57
- package/src/lib/OrganizationAutocomplete.tsx +14 -9
- package/src/lib/ProviderAutocomplete.stories.tsx +20 -35
- package/src/lib/ProviderAutocomplete.test.tsx +29 -63
- package/src/lib/ProviderAutocomplete.tsx +11 -5
- package/src/lib/RadioGroup.stories.tsx +41 -36
- package/src/lib/RadioGroup.test.tsx +3 -35
- package/src/lib/RadioGroup.tsx +31 -20
- package/src/lib/Select.stories.tsx +66 -93
- package/src/lib/Select.test.tsx +8 -36
- package/src/lib/Select.tsx +30 -15
- package/src/lib/TextField.stories.tsx +26 -39
- package/src/lib/TextField.test.tsx +71 -5
- package/src/lib/TextField.tsx +32 -17
- package/src/lib/Types.tsx +2489 -0
- package/src/lib/UtilComponents.tsx +52 -0
- package/docs/propDefinitions.tsx +0 -31
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.3.0](https://github.com/Availity/element/compare/@availity/mui-controlled-form@0.2.6...@availity/mui-controlled-form@0.3.0) (2025-02-17)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **mui-block-ui:** collapsing individual rule props, deprecate individual rules and controlledform ([c559d83](https://github.com/Availity/element/commit/c559d83629f0cda74d52f3fb8bbeb0d22bfb933c))
|
|
11
|
+
|
|
5
12
|
## [0.2.6](https://github.com/Availity/element/compare/@availity/mui-controlled-form@0.2.5...@availity/mui-controlled-form@0.2.6) (2025-02-07)
|
|
6
13
|
|
|
7
14
|
|
package/README.md
CHANGED
|
@@ -51,13 +51,13 @@ yarn add @availity/mui-controlled-form
|
|
|
51
51
|
#### Import through @availity/element
|
|
52
52
|
|
|
53
53
|
```tsx
|
|
54
|
-
import {
|
|
54
|
+
import { ControlledTextField } from '@availity/element';
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
#### Direct import
|
|
58
58
|
|
|
59
59
|
```tsx
|
|
60
|
-
import {
|
|
60
|
+
import { ControlledTextField } from '@availity/mui-controlled-form';
|
|
61
61
|
```
|
|
62
62
|
|
|
63
63
|
### Form Validation
|
package/dist/index.d.mts
CHANGED
|
@@ -1,26 +1,87 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { FormHTMLAttributes } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import { RegisterOptions, FieldValues, ControllerProps, SubmitHandler, Resolver } from 'react-hook-form';
|
|
4
|
+
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';
|
|
6
|
+
export { FormProvider, SubmitHandler, UseFormProps, UseFormReturn, useForm, useFormContext } from 'react-hook-form';
|
|
6
7
|
import { ChipTypeMap } from '@mui/material/Chip';
|
|
7
8
|
import { CheckboxProps } from '@availity/mui-checkbox';
|
|
8
9
|
import { DatepickerProps } from '@availity/mui-datepicker';
|
|
9
10
|
import { InputProps, RadioGroupProps, SelectProps } from '@availity/mui-form-utils';
|
|
10
11
|
import { TextFieldProps } from '@availity/mui-textfield';
|
|
11
12
|
|
|
12
|
-
type
|
|
13
|
-
declare const
|
|
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;
|
|
14
15
|
|
|
15
|
-
type
|
|
16
|
-
|
|
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
|
+
type ControllerProps = {
|
|
57
|
+
/** Unique name of your input */
|
|
58
|
+
name: ControllerProps$1["name"];
|
|
59
|
+
/** **Important**: Can not apply undefined to defaultValue or defaultValues at useForm.
|
|
60
|
+
* - You need to either set defaultValue at the field-level or useForm's defaultValues. undefined is not a valid value.
|
|
61
|
+
* - If your form will invoke reset with default values, you will need to provide useForm with defaultValues.
|
|
62
|
+
* - 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"];
|
|
64
|
+
/** If the input is disabled */
|
|
65
|
+
disabled?: ControllerProps$1["disabled"];
|
|
66
|
+
/** 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
|
+
* required, min, max, minLength, maxLength, pattern, validate
|
|
68
|
+
*
|
|
69
|
+
* Not used if 3rd party schema/resolver used. */
|
|
70
|
+
rules?: ControllerProps$1["rules"];
|
|
71
|
+
/** Input will be unregistered after unmount and defaultValues will be removed as well. */
|
|
72
|
+
shouldUnregister?: ControllerProps$1["shouldUnregister"];
|
|
73
|
+
};
|
|
17
74
|
|
|
18
|
-
type
|
|
19
|
-
declare const
|
|
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;
|
|
20
77
|
|
|
21
|
-
type
|
|
22
|
-
declare const
|
|
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;
|
|
23
80
|
|
|
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;
|
|
83
|
+
|
|
84
|
+
/** @deprecated Use `UseFormProps` directly with `useForm` and `FormProvider` */
|
|
24
85
|
type ControlledFormProps = {
|
|
25
86
|
/** This function will receive the form data if form validation is successful. */
|
|
26
87
|
onSubmit: SubmitHandler<any>;
|
|
@@ -33,32 +94,67 @@ type ControlledFormProps = {
|
|
|
33
94
|
* found here: https://github.com/react-hook-form/resolvers#quickstart
|
|
34
95
|
*/
|
|
35
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'>;
|
|
36
99
|
} & FormHTMLAttributes<HTMLFormElement>;
|
|
37
|
-
|
|
100
|
+
/** @deprecated Use `FormProvider` and `useForm` directly. */
|
|
101
|
+
declare const ControlledForm: ({ onSubmit, values, schema, validationResolver, additionalUseFormOptions, ...rest }: ControlledFormProps) => react_jsx_runtime.JSX.Element;
|
|
38
102
|
|
|
39
|
-
type ControlledDatepickerProps =
|
|
40
|
-
declare const ControlledDatepicker: ({ name, defaultValue, deps, max, maxLength, min, minLength, onBlur, onChange, pattern, required, shouldUnregister, validate, value, FieldProps, ...rest }: ControlledDatepickerProps) => react_jsx_runtime.JSX.Element;
|
|
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;
|
|
41
105
|
|
|
42
|
-
type ControlledInputProps = Omit<InputProps, '
|
|
43
|
-
|
|
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;
|
|
44
116
|
|
|
45
|
-
type ControlledOrgAutocompleteProps = Omit<OrgAutocompleteProps, 'name'> &
|
|
46
|
-
declare const ControlledOrganizationAutocomplete: ({ name, defaultValue, deps, onBlur, onChange, pattern, required, shouldUnregister, validate, value, FieldProps, ...rest }: ControlledOrgAutocompleteProps) => react_jsx_runtime.JSX.Element;
|
|
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;
|
|
47
119
|
|
|
48
|
-
type ControlledProviderAutocompleteProps = Omit<ProviderAutocompleteProps, '
|
|
49
|
-
declare const ControlledProviderAutocomplete: ({ name, defaultValue, deps, max, maxLength, min, minLength, onBlur, onChange, pattern, required, shouldUnregister, validate, value, FieldProps, ...rest }: ControlledProviderAutocompleteProps) => react_jsx_runtime.JSX.Element;
|
|
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;
|
|
50
122
|
|
|
51
|
-
type ControlledRadioGroupProps =
|
|
123
|
+
type ControlledRadioGroupProps = {
|
|
52
124
|
name: string;
|
|
53
125
|
label: string;
|
|
54
126
|
helperText?: string;
|
|
55
|
-
} & Omit<RegisterOptions<FieldValues, string>, '
|
|
56
|
-
|
|
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;
|
|
57
137
|
|
|
58
|
-
type ControlledSelectProps = Omit<SelectProps, '
|
|
59
|
-
|
|
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;
|
|
60
148
|
|
|
61
|
-
type ControlledTextFieldProps = Omit<TextFieldProps, '
|
|
62
|
-
|
|
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;
|
|
63
159
|
|
|
64
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,26 +1,87 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { FormHTMLAttributes } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import { RegisterOptions, FieldValues, ControllerProps, SubmitHandler, Resolver } from 'react-hook-form';
|
|
4
|
+
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';
|
|
6
|
+
export { FormProvider, SubmitHandler, UseFormProps, UseFormReturn, useForm, useFormContext } from 'react-hook-form';
|
|
6
7
|
import { ChipTypeMap } from '@mui/material/Chip';
|
|
7
8
|
import { CheckboxProps } from '@availity/mui-checkbox';
|
|
8
9
|
import { DatepickerProps } from '@availity/mui-datepicker';
|
|
9
10
|
import { InputProps, RadioGroupProps, SelectProps } from '@availity/mui-form-utils';
|
|
10
11
|
import { TextFieldProps } from '@availity/mui-textfield';
|
|
11
12
|
|
|
12
|
-
type
|
|
13
|
-
declare const
|
|
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;
|
|
14
15
|
|
|
15
|
-
type
|
|
16
|
-
|
|
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
|
+
type ControllerProps = {
|
|
57
|
+
/** Unique name of your input */
|
|
58
|
+
name: ControllerProps$1["name"];
|
|
59
|
+
/** **Important**: Can not apply undefined to defaultValue or defaultValues at useForm.
|
|
60
|
+
* - You need to either set defaultValue at the field-level or useForm's defaultValues. undefined is not a valid value.
|
|
61
|
+
* - If your form will invoke reset with default values, you will need to provide useForm with defaultValues.
|
|
62
|
+
* - 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"];
|
|
64
|
+
/** If the input is disabled */
|
|
65
|
+
disabled?: ControllerProps$1["disabled"];
|
|
66
|
+
/** 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
|
+
* required, min, max, minLength, maxLength, pattern, validate
|
|
68
|
+
*
|
|
69
|
+
* Not used if 3rd party schema/resolver used. */
|
|
70
|
+
rules?: ControllerProps$1["rules"];
|
|
71
|
+
/** Input will be unregistered after unmount and defaultValues will be removed as well. */
|
|
72
|
+
shouldUnregister?: ControllerProps$1["shouldUnregister"];
|
|
73
|
+
};
|
|
17
74
|
|
|
18
|
-
type
|
|
19
|
-
declare const
|
|
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;
|
|
20
77
|
|
|
21
|
-
type
|
|
22
|
-
declare const
|
|
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;
|
|
23
80
|
|
|
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;
|
|
83
|
+
|
|
84
|
+
/** @deprecated Use `UseFormProps` directly with `useForm` and `FormProvider` */
|
|
24
85
|
type ControlledFormProps = {
|
|
25
86
|
/** This function will receive the form data if form validation is successful. */
|
|
26
87
|
onSubmit: SubmitHandler<any>;
|
|
@@ -33,32 +94,67 @@ type ControlledFormProps = {
|
|
|
33
94
|
* found here: https://github.com/react-hook-form/resolvers#quickstart
|
|
34
95
|
*/
|
|
35
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'>;
|
|
36
99
|
} & FormHTMLAttributes<HTMLFormElement>;
|
|
37
|
-
|
|
100
|
+
/** @deprecated Use `FormProvider` and `useForm` directly. */
|
|
101
|
+
declare const ControlledForm: ({ onSubmit, values, schema, validationResolver, additionalUseFormOptions, ...rest }: ControlledFormProps) => react_jsx_runtime.JSX.Element;
|
|
38
102
|
|
|
39
|
-
type ControlledDatepickerProps =
|
|
40
|
-
declare const ControlledDatepicker: ({ name, defaultValue, deps, max, maxLength, min, minLength, onBlur, onChange, pattern, required, shouldUnregister, validate, value, FieldProps, ...rest }: ControlledDatepickerProps) => react_jsx_runtime.JSX.Element;
|
|
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;
|
|
41
105
|
|
|
42
|
-
type ControlledInputProps = Omit<InputProps, '
|
|
43
|
-
|
|
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;
|
|
44
116
|
|
|
45
|
-
type ControlledOrgAutocompleteProps = Omit<OrgAutocompleteProps, 'name'> &
|
|
46
|
-
declare const ControlledOrganizationAutocomplete: ({ name, defaultValue, deps, onBlur, onChange, pattern, required, shouldUnregister, validate, value, FieldProps, ...rest }: ControlledOrgAutocompleteProps) => react_jsx_runtime.JSX.Element;
|
|
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;
|
|
47
119
|
|
|
48
|
-
type ControlledProviderAutocompleteProps = Omit<ProviderAutocompleteProps, '
|
|
49
|
-
declare const ControlledProviderAutocomplete: ({ name, defaultValue, deps, max, maxLength, min, minLength, onBlur, onChange, pattern, required, shouldUnregister, validate, value, FieldProps, ...rest }: ControlledProviderAutocompleteProps) => react_jsx_runtime.JSX.Element;
|
|
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;
|
|
50
122
|
|
|
51
|
-
type ControlledRadioGroupProps =
|
|
123
|
+
type ControlledRadioGroupProps = {
|
|
52
124
|
name: string;
|
|
53
125
|
label: string;
|
|
54
126
|
helperText?: string;
|
|
55
|
-
} & Omit<RegisterOptions<FieldValues, string>, '
|
|
56
|
-
|
|
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;
|
|
57
137
|
|
|
58
|
-
type ControlledSelectProps = Omit<SelectProps, '
|
|
59
|
-
|
|
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;
|
|
60
148
|
|
|
61
|
-
type ControlledTextFieldProps = Omit<TextFieldProps, '
|
|
62
|
-
|
|
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;
|
|
63
159
|
|
|
64
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 };
|