@availity/mui-controlled-form 1.1.2 → 1.2.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 +17 -0
- package/dist/index.d.mts +28 -9
- package/dist/index.d.ts +28 -9
- package/dist/index.js +136 -131
- package/dist/index.mjs +148 -143
- package/package.json +5 -4
- package/src/lib/AsyncAutocomplete.stories.tsx +57 -33
- package/src/lib/AsyncAutocomplete.tsx +19 -9
- package/src/lib/CodesAutocomplete.tsx +47 -42
- package/src/lib/OrganizationAutocomplete.tsx +36 -42
- package/src/lib/ProviderAutocomplete.tsx +44 -44
- package/src/lib/TextField.stories.tsx +53 -6
- package/src/lib/TextField.test.tsx +8 -4
- package/src/lib/TextField.tsx +1 -1
- package/src/lib/Types.tsx +9 -0
- package/src/lib/utils.tsx +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [1.2.0](https://github.com/Availity/element/compare/@availity/mui-controlled-form@1.1.3...@availity/mui-controlled-form@1.2.0) (2025-03-31)
|
|
6
|
+
|
|
7
|
+
### Dependency Updates
|
|
8
|
+
|
|
9
|
+
* `mui-autocomplete` updated to version `1.1.3`
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **mui-controlled-form:** add defaultToFirstOption and defaultToOnlyOption in Autocomplete ([fa9f67a](https://github.com/Availity/element/commit/fa9f67ab1a5086f07f97b85aedf2eb8568b7beba))
|
|
14
|
+
|
|
15
|
+
## [1.1.3](https://github.com/Availity/element/compare/@availity/mui-controlled-form@1.1.2...@availity/mui-controlled-form@1.1.3) (2025-03-27)
|
|
16
|
+
|
|
17
|
+
### Dependency Updates
|
|
18
|
+
|
|
19
|
+
* `mui-autocomplete` updated to version `1.1.2`
|
|
20
|
+
* `mui-datepicker` updated to version `1.1.2`
|
|
21
|
+
* `mui-textfield` updated to version `1.1.2`
|
|
5
22
|
## [1.1.2](https://github.com/Availity/element/compare/@availity/mui-controlled-form@1.1.1...@availity/mui-controlled-form@1.1.2) (2025-03-25)
|
|
6
23
|
|
|
7
24
|
### Dependency Updates
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { AutocompleteProps, AsyncAutocompleteProps,
|
|
2
|
+
import { AutocompleteProps, AsyncAutocompleteProps, Code, Organization, Provider } from '@availity/mui-autocomplete';
|
|
3
3
|
import { RegisterOptions, FieldValues, ControllerProps as ControllerProps$1 } from 'react-hook-form';
|
|
4
4
|
export { FormProvider, SubmitHandler, UseFormProps, UseFormReturn, useForm, useFormContext } from 'react-hook-form';
|
|
5
5
|
import { ChipTypeMap } from '@mui/material/Chip';
|
|
6
6
|
import { CheckboxProps } from '@availity/mui-checkbox';
|
|
7
|
+
import { ApiConfig } from '@availity/api-axios';
|
|
7
8
|
import { DatepickerProps } from '@availity/mui-datepicker';
|
|
8
9
|
import { InputProps, RadioGroupProps, FormControlProps, SelectProps } from '@availity/mui-form-utils';
|
|
9
10
|
import { TextFieldProps } from '@availity/mui-textfield';
|
|
@@ -30,14 +31,24 @@ type ControllerProps = {
|
|
|
30
31
|
shouldUnregister?: ControllerProps$1['shouldUnregister'];
|
|
31
32
|
};
|
|
32
33
|
|
|
33
|
-
type ControlledAsyncAutocompleteProps<Option, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> =
|
|
34
|
-
|
|
34
|
+
type ControlledAsyncAutocompleteProps<Option, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> = {
|
|
35
|
+
defaultToFirstOption?: boolean;
|
|
36
|
+
defaultToOnlyOption?: boolean;
|
|
37
|
+
} & Omit<AsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps;
|
|
38
|
+
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, defaultToFirstOption, defaultToOnlyOption, ...rest }: ControlledAsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>) => react_jsx_runtime.JSX.Element;
|
|
35
39
|
|
|
36
40
|
type ControlledCheckboxProps = Omit<CheckboxProps, 'disabled' | 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'disabled' | 'onBlur' | 'onChange' | 'value'> & ControllerProps;
|
|
37
41
|
declare const ControlledCheckbox: ({ name, disabled, onChange, onBlur, value, defaultValue, rules, shouldUnregister, ...rest }: ControlledCheckboxProps) => react_jsx_runtime.JSX.Element;
|
|
38
42
|
|
|
39
|
-
type
|
|
40
|
-
|
|
43
|
+
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
44
|
+
|
|
45
|
+
interface ControlledCodesAutocompleteProps<Option = Code, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> extends Omit<Optional<ControlledAsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'queryKey'>, 'loadOptions'> {
|
|
46
|
+
/** The code list id. */
|
|
47
|
+
list: string;
|
|
48
|
+
/** Config passed to the AvCodesApi.query function */
|
|
49
|
+
apiConfig?: ApiConfig;
|
|
50
|
+
}
|
|
51
|
+
declare const ControlledCodesAutocomplete: ({ name, defaultValue, onBlur, onChange, rules, shouldUnregister, value, FieldProps, apiConfig, queryOptions, queryKey, list, watchParams, ...rest }: ControlledCodesAutocompleteProps) => react_jsx_runtime.JSX.Element;
|
|
41
52
|
|
|
42
53
|
type ControlledDatepickerProps = Omit<DatepickerProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps;
|
|
43
54
|
declare const ControlledDatepicker: ({ name, defaultValue, onBlur, onChange, rules, shouldUnregister, value, FieldProps, ...rest }: ControlledDatepickerProps) => react_jsx_runtime.JSX.Element;
|
|
@@ -45,11 +56,19 @@ declare const ControlledDatepicker: ({ name, defaultValue, onBlur, onChange, rul
|
|
|
45
56
|
type ControlledInputProps = Omit<InputProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps;
|
|
46
57
|
declare const ControlledInput: ({ name, defaultValue, disabled, onBlur, onChange, rules, shouldUnregister, value, ...rest }: ControlledInputProps) => react_jsx_runtime.JSX.Element;
|
|
47
58
|
|
|
48
|
-
|
|
49
|
-
|
|
59
|
+
interface ControlledOrgAutocompleteProps<Option = Organization, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> extends Omit<Optional<ControlledAsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'queryKey'>, 'loadOptions'> {
|
|
60
|
+
/** Axios ApiConfig */
|
|
61
|
+
apiConfig?: ApiConfig;
|
|
62
|
+
}
|
|
63
|
+
declare const ControlledOrganizationAutocomplete: ({ name, defaultValue, onBlur, onChange, rules, shouldUnregister, value, FieldProps, queryKey, apiConfig, ...rest }: ControlledOrgAutocompleteProps) => react_jsx_runtime.JSX.Element;
|
|
50
64
|
|
|
51
|
-
|
|
52
|
-
|
|
65
|
+
interface ControlledProviderAutocompleteProps<Option = Provider, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> extends Omit<Optional<ControlledAsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'queryKey'>, 'loadOptions'> {
|
|
66
|
+
/** Customer ID of the Organization you are requesting the providers for */
|
|
67
|
+
customerId: string;
|
|
68
|
+
/** Config passed to the AvProvidersApi.getProviders function */
|
|
69
|
+
apiConfig?: ApiConfig;
|
|
70
|
+
}
|
|
71
|
+
declare const ControlledProviderAutocomplete: ({ name, defaultValue, onBlur, onChange, rules, shouldUnregister, value, FieldProps, apiConfig, customerId, queryKey, ...rest }: ControlledProviderAutocompleteProps) => react_jsx_runtime.JSX.Element;
|
|
53
72
|
|
|
54
73
|
type ControlledRadioGroupProps = {
|
|
55
74
|
name: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { AutocompleteProps, AsyncAutocompleteProps,
|
|
2
|
+
import { AutocompleteProps, AsyncAutocompleteProps, Code, Organization, Provider } from '@availity/mui-autocomplete';
|
|
3
3
|
import { RegisterOptions, FieldValues, ControllerProps as ControllerProps$1 } from 'react-hook-form';
|
|
4
4
|
export { FormProvider, SubmitHandler, UseFormProps, UseFormReturn, useForm, useFormContext } from 'react-hook-form';
|
|
5
5
|
import { ChipTypeMap } from '@mui/material/Chip';
|
|
6
6
|
import { CheckboxProps } from '@availity/mui-checkbox';
|
|
7
|
+
import { ApiConfig } from '@availity/api-axios';
|
|
7
8
|
import { DatepickerProps } from '@availity/mui-datepicker';
|
|
8
9
|
import { InputProps, RadioGroupProps, FormControlProps, SelectProps } from '@availity/mui-form-utils';
|
|
9
10
|
import { TextFieldProps } from '@availity/mui-textfield';
|
|
@@ -30,14 +31,24 @@ type ControllerProps = {
|
|
|
30
31
|
shouldUnregister?: ControllerProps$1['shouldUnregister'];
|
|
31
32
|
};
|
|
32
33
|
|
|
33
|
-
type ControlledAsyncAutocompleteProps<Option, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> =
|
|
34
|
-
|
|
34
|
+
type ControlledAsyncAutocompleteProps<Option, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> = {
|
|
35
|
+
defaultToFirstOption?: boolean;
|
|
36
|
+
defaultToOnlyOption?: boolean;
|
|
37
|
+
} & Omit<AsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps;
|
|
38
|
+
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, defaultToFirstOption, defaultToOnlyOption, ...rest }: ControlledAsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>) => react_jsx_runtime.JSX.Element;
|
|
35
39
|
|
|
36
40
|
type ControlledCheckboxProps = Omit<CheckboxProps, 'disabled' | 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'disabled' | 'onBlur' | 'onChange' | 'value'> & ControllerProps;
|
|
37
41
|
declare const ControlledCheckbox: ({ name, disabled, onChange, onBlur, value, defaultValue, rules, shouldUnregister, ...rest }: ControlledCheckboxProps) => react_jsx_runtime.JSX.Element;
|
|
38
42
|
|
|
39
|
-
type
|
|
40
|
-
|
|
43
|
+
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
44
|
+
|
|
45
|
+
interface ControlledCodesAutocompleteProps<Option = Code, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> extends Omit<Optional<ControlledAsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'queryKey'>, 'loadOptions'> {
|
|
46
|
+
/** The code list id. */
|
|
47
|
+
list: string;
|
|
48
|
+
/** Config passed to the AvCodesApi.query function */
|
|
49
|
+
apiConfig?: ApiConfig;
|
|
50
|
+
}
|
|
51
|
+
declare const ControlledCodesAutocomplete: ({ name, defaultValue, onBlur, onChange, rules, shouldUnregister, value, FieldProps, apiConfig, queryOptions, queryKey, list, watchParams, ...rest }: ControlledCodesAutocompleteProps) => react_jsx_runtime.JSX.Element;
|
|
41
52
|
|
|
42
53
|
type ControlledDatepickerProps = Omit<DatepickerProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps;
|
|
43
54
|
declare const ControlledDatepicker: ({ name, defaultValue, onBlur, onChange, rules, shouldUnregister, value, FieldProps, ...rest }: ControlledDatepickerProps) => react_jsx_runtime.JSX.Element;
|
|
@@ -45,11 +56,19 @@ declare const ControlledDatepicker: ({ name, defaultValue, onBlur, onChange, rul
|
|
|
45
56
|
type ControlledInputProps = Omit<InputProps, 'onBlur' | 'onChange' | 'value' | 'name'> & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> & ControllerProps;
|
|
46
57
|
declare const ControlledInput: ({ name, defaultValue, disabled, onBlur, onChange, rules, shouldUnregister, value, ...rest }: ControlledInputProps) => react_jsx_runtime.JSX.Element;
|
|
47
58
|
|
|
48
|
-
|
|
49
|
-
|
|
59
|
+
interface ControlledOrgAutocompleteProps<Option = Organization, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> extends Omit<Optional<ControlledAsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'queryKey'>, 'loadOptions'> {
|
|
60
|
+
/** Axios ApiConfig */
|
|
61
|
+
apiConfig?: ApiConfig;
|
|
62
|
+
}
|
|
63
|
+
declare const ControlledOrganizationAutocomplete: ({ name, defaultValue, onBlur, onChange, rules, shouldUnregister, value, FieldProps, queryKey, apiConfig, ...rest }: ControlledOrgAutocompleteProps) => react_jsx_runtime.JSX.Element;
|
|
50
64
|
|
|
51
|
-
|
|
52
|
-
|
|
65
|
+
interface ControlledProviderAutocompleteProps<Option = Provider, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> extends Omit<Optional<ControlledAsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'queryKey'>, 'loadOptions'> {
|
|
66
|
+
/** Customer ID of the Organization you are requesting the providers for */
|
|
67
|
+
customerId: string;
|
|
68
|
+
/** Config passed to the AvProvidersApi.getProviders function */
|
|
69
|
+
apiConfig?: ApiConfig;
|
|
70
|
+
}
|
|
71
|
+
declare const ControlledProviderAutocomplete: ({ name, defaultValue, onBlur, onChange, rules, shouldUnregister, value, FieldProps, apiConfig, customerId, queryKey, ...rest }: ControlledProviderAutocompleteProps) => react_jsx_runtime.JSX.Element;
|
|
53
72
|
|
|
54
73
|
type ControlledRadioGroupProps = {
|
|
55
74
|
name: string;
|
package/dist/index.js
CHANGED
|
@@ -45,6 +45,26 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
45
45
|
return to;
|
|
46
46
|
};
|
|
47
47
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
48
|
+
var __async = (__this, __arguments, generator) => {
|
|
49
|
+
return new Promise((resolve, reject) => {
|
|
50
|
+
var fulfilled = (value) => {
|
|
51
|
+
try {
|
|
52
|
+
step(generator.next(value));
|
|
53
|
+
} catch (e) {
|
|
54
|
+
reject(e);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var rejected = (value) => {
|
|
58
|
+
try {
|
|
59
|
+
step(generator.throw(value));
|
|
60
|
+
} catch (e) {
|
|
61
|
+
reject(e);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
65
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
66
|
+
});
|
|
67
|
+
};
|
|
48
68
|
|
|
49
69
|
// src/index.ts
|
|
50
70
|
var index_exports = {};
|
|
@@ -60,9 +80,9 @@ __export(index_exports, {
|
|
|
60
80
|
ControlledRadioGroup: () => ControlledRadioGroup,
|
|
61
81
|
ControlledSelect: () => ControlledSelect,
|
|
62
82
|
ControlledTextField: () => ControlledTextField,
|
|
63
|
-
FormProvider: () =>
|
|
64
|
-
useForm: () =>
|
|
65
|
-
useFormContext: () =>
|
|
83
|
+
FormProvider: () => import_react_hook_form9.FormProvider,
|
|
84
|
+
useForm: () => import_react_hook_form9.useForm,
|
|
85
|
+
useFormContext: () => import_react_hook_form9.useFormContext
|
|
66
86
|
});
|
|
67
87
|
module.exports = __toCommonJS(index_exports);
|
|
68
88
|
|
|
@@ -78,7 +98,9 @@ var ControlledAsyncAutocomplete = (_a) => {
|
|
|
78
98
|
rules = {},
|
|
79
99
|
shouldUnregister,
|
|
80
100
|
value,
|
|
81
|
-
FieldProps
|
|
101
|
+
FieldProps,
|
|
102
|
+
defaultToFirstOption,
|
|
103
|
+
defaultToOnlyOption
|
|
82
104
|
} = _b, rest = __objRest(_b, [
|
|
83
105
|
"name",
|
|
84
106
|
"onBlur",
|
|
@@ -86,19 +108,17 @@ var ControlledAsyncAutocomplete = (_a) => {
|
|
|
86
108
|
"rules",
|
|
87
109
|
"shouldUnregister",
|
|
88
110
|
"value",
|
|
89
|
-
"FieldProps"
|
|
111
|
+
"FieldProps",
|
|
112
|
+
"defaultToFirstOption",
|
|
113
|
+
"defaultToOnlyOption"
|
|
90
114
|
]);
|
|
115
|
+
const { setValue } = (0, import_react_hook_form.useFormContext)();
|
|
91
116
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
92
117
|
import_react_hook_form.Controller,
|
|
93
118
|
{
|
|
94
119
|
name,
|
|
95
120
|
defaultValue: rest.defaultValue,
|
|
96
|
-
rules: __spreadValues({
|
|
97
|
-
onBlur,
|
|
98
|
-
onChange,
|
|
99
|
-
shouldUnregister,
|
|
100
|
-
value
|
|
101
|
-
}, rules),
|
|
121
|
+
rules: __spreadValues({ onBlur, onChange, shouldUnregister, value }, rules),
|
|
102
122
|
shouldUnregister,
|
|
103
123
|
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2, ref }, fieldState: { error } }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
104
124
|
import_mui_autocomplete.AsyncAutocomplete,
|
|
@@ -121,7 +141,17 @@ var ControlledAsyncAutocomplete = (_a) => {
|
|
|
121
141
|
onChange2(value3);
|
|
122
142
|
},
|
|
123
143
|
onBlur: onBlur2,
|
|
124
|
-
value: value2 || null
|
|
144
|
+
value: value2 || null,
|
|
145
|
+
loadOptions: (offset, limit, inputValue) => __async(void 0, null, function* () {
|
|
146
|
+
const { options, hasMore, offset: returnedOffsetValue } = yield rest.loadOptions(offset, limit, inputValue);
|
|
147
|
+
if (defaultToFirstOption && offset === 0) {
|
|
148
|
+
setValue(name, options[0]);
|
|
149
|
+
}
|
|
150
|
+
if (defaultToOnlyOption && offset === 0 && options.length === 1) {
|
|
151
|
+
setValue(name, options[0]);
|
|
152
|
+
}
|
|
153
|
+
return { options, hasMore, offset: returnedOffsetValue };
|
|
154
|
+
})
|
|
125
155
|
})
|
|
126
156
|
)
|
|
127
157
|
}
|
|
@@ -244,7 +274,6 @@ var ControlledCheckbox = (_a) => {
|
|
|
244
274
|
|
|
245
275
|
// src/lib/CodesAutocomplete.tsx
|
|
246
276
|
var import_mui_autocomplete3 = require("@availity/mui-autocomplete");
|
|
247
|
-
var import_react_hook_form4 = require("react-hook-form");
|
|
248
277
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
249
278
|
var ControlledCodesAutocomplete = (_a) => {
|
|
250
279
|
var _b = _a, {
|
|
@@ -255,7 +284,12 @@ var ControlledCodesAutocomplete = (_a) => {
|
|
|
255
284
|
rules = {},
|
|
256
285
|
shouldUnregister,
|
|
257
286
|
value,
|
|
258
|
-
FieldProps
|
|
287
|
+
FieldProps,
|
|
288
|
+
apiConfig = {},
|
|
289
|
+
queryOptions,
|
|
290
|
+
queryKey = "codes-autocomplete",
|
|
291
|
+
list,
|
|
292
|
+
watchParams
|
|
259
293
|
} = _b, rest = __objRest(_b, [
|
|
260
294
|
"name",
|
|
261
295
|
"defaultValue",
|
|
@@ -264,51 +298,43 @@ var ControlledCodesAutocomplete = (_a) => {
|
|
|
264
298
|
"rules",
|
|
265
299
|
"shouldUnregister",
|
|
266
300
|
"value",
|
|
267
|
-
"FieldProps"
|
|
301
|
+
"FieldProps",
|
|
302
|
+
"apiConfig",
|
|
303
|
+
"queryOptions",
|
|
304
|
+
"queryKey",
|
|
305
|
+
"list",
|
|
306
|
+
"watchParams"
|
|
268
307
|
]);
|
|
308
|
+
const handleLoadOptions = (offset, limit, inputValue) => __async(void 0, null, function* () {
|
|
309
|
+
const resp = yield (0, import_mui_autocomplete3.fetchCodes)(__spreadProps(__spreadValues({}, apiConfig), {
|
|
310
|
+
params: __spreadProps(__spreadValues({}, apiConfig.params), { list, offset, limit, q: inputValue })
|
|
311
|
+
}));
|
|
312
|
+
return resp;
|
|
313
|
+
});
|
|
269
314
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
270
|
-
|
|
271
|
-
{
|
|
315
|
+
ControlledAsyncAutocomplete,
|
|
316
|
+
__spreadProps(__spreadValues({
|
|
272
317
|
name,
|
|
273
318
|
defaultValue,
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
shouldUnregister,
|
|
278
|
-
value
|
|
279
|
-
}, rules),
|
|
319
|
+
onBlur,
|
|
320
|
+
onChange,
|
|
321
|
+
rules,
|
|
280
322
|
shouldUnregister,
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("br", {}),
|
|
291
|
-
FieldProps == null ? void 0 : FieldProps.helperText
|
|
292
|
-
] }) : FieldProps == null ? void 0 : FieldProps.helperText,
|
|
293
|
-
inputRef: ref
|
|
294
|
-
}),
|
|
295
|
-
onChange: (event, value3, reason) => {
|
|
296
|
-
if (reason === "clear") {
|
|
297
|
-
onChange2(null);
|
|
298
|
-
}
|
|
299
|
-
onChange2(value3);
|
|
300
|
-
},
|
|
301
|
-
onBlur: onBlur2,
|
|
302
|
-
value: value2 || null
|
|
303
|
-
})
|
|
304
|
-
)
|
|
305
|
-
}
|
|
323
|
+
value,
|
|
324
|
+
FieldProps,
|
|
325
|
+
getOptionLabel: import_mui_autocomplete3.handleGetCodesOptionLabel,
|
|
326
|
+
queryKey,
|
|
327
|
+
queryOptions: __spreadValues({ enabled: !!list }, queryOptions),
|
|
328
|
+
watchParams: __spreadValues({ list }, watchParams)
|
|
329
|
+
}, rest), {
|
|
330
|
+
loadOptions: handleLoadOptions
|
|
331
|
+
})
|
|
306
332
|
);
|
|
307
333
|
};
|
|
308
334
|
|
|
309
335
|
// src/lib/Datepicker.tsx
|
|
310
336
|
var import_mui_datepicker = require("@availity/mui-datepicker");
|
|
311
|
-
var
|
|
337
|
+
var import_react_hook_form4 = require("react-hook-form");
|
|
312
338
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
313
339
|
var ControlledDatepicker = (_a) => {
|
|
314
340
|
var _b = _a, {
|
|
@@ -331,7 +357,7 @@ var ControlledDatepicker = (_a) => {
|
|
|
331
357
|
"FieldProps"
|
|
332
358
|
]);
|
|
333
359
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
334
|
-
|
|
360
|
+
import_react_hook_form4.Controller,
|
|
335
361
|
{
|
|
336
362
|
name,
|
|
337
363
|
defaultValue,
|
|
@@ -369,7 +395,7 @@ var ControlledDatepicker = (_a) => {
|
|
|
369
395
|
|
|
370
396
|
// src/lib/Input.tsx
|
|
371
397
|
var import_mui_form_utils = require("@availity/mui-form-utils");
|
|
372
|
-
var
|
|
398
|
+
var import_react_hook_form5 = require("react-hook-form");
|
|
373
399
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
374
400
|
var ControlledInput = (_a) => {
|
|
375
401
|
var _b = _a, {
|
|
@@ -392,7 +418,7 @@ var ControlledInput = (_a) => {
|
|
|
392
418
|
"value"
|
|
393
419
|
]);
|
|
394
420
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
395
|
-
|
|
421
|
+
import_react_hook_form5.Controller,
|
|
396
422
|
{
|
|
397
423
|
name,
|
|
398
424
|
defaultValue,
|
|
@@ -418,7 +444,6 @@ var ControlledInput = (_a) => {
|
|
|
418
444
|
|
|
419
445
|
// src/lib/OrganizationAutocomplete.tsx
|
|
420
446
|
var import_mui_autocomplete4 = require("@availity/mui-autocomplete");
|
|
421
|
-
var import_react_hook_form7 = require("react-hook-form");
|
|
422
447
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
423
448
|
var ControlledOrganizationAutocomplete = (_a) => {
|
|
424
449
|
var _b = _a, {
|
|
@@ -429,7 +454,9 @@ var ControlledOrganizationAutocomplete = (_a) => {
|
|
|
429
454
|
rules = {},
|
|
430
455
|
shouldUnregister,
|
|
431
456
|
value,
|
|
432
|
-
FieldProps
|
|
457
|
+
FieldProps,
|
|
458
|
+
queryKey = "org-autocomplete",
|
|
459
|
+
apiConfig = {}
|
|
433
460
|
} = _b, rest = __objRest(_b, [
|
|
434
461
|
"name",
|
|
435
462
|
"defaultValue",
|
|
@@ -438,51 +465,35 @@ var ControlledOrganizationAutocomplete = (_a) => {
|
|
|
438
465
|
"rules",
|
|
439
466
|
"shouldUnregister",
|
|
440
467
|
"value",
|
|
441
|
-
"FieldProps"
|
|
468
|
+
"FieldProps",
|
|
469
|
+
"queryKey",
|
|
470
|
+
"apiConfig"
|
|
442
471
|
]);
|
|
472
|
+
const handleLoadOptions = (offset, limit) => __async(void 0, null, function* () {
|
|
473
|
+
const resp = yield (0, import_mui_autocomplete4.fetchOrgs)(__spreadProps(__spreadValues({}, apiConfig), { params: __spreadProps(__spreadValues({ dropdown: true }, apiConfig.params), { offset, limit }) }));
|
|
474
|
+
return resp;
|
|
475
|
+
});
|
|
443
476
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
444
|
-
|
|
445
|
-
{
|
|
477
|
+
ControlledAsyncAutocomplete,
|
|
478
|
+
__spreadProps(__spreadValues({
|
|
446
479
|
name,
|
|
447
480
|
defaultValue,
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
shouldUnregister,
|
|
452
|
-
value
|
|
453
|
-
}, rules),
|
|
481
|
+
onBlur,
|
|
482
|
+
onChange,
|
|
483
|
+
rules,
|
|
454
484
|
shouldUnregister,
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
helperText: (error == null ? void 0 : error.message) ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
463
|
-
error.message,
|
|
464
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("br", {}),
|
|
465
|
-
FieldProps == null ? void 0 : FieldProps.helperText
|
|
466
|
-
] }) : FieldProps == null ? void 0 : FieldProps.helperText,
|
|
467
|
-
inputRef: ref
|
|
468
|
-
}),
|
|
469
|
-
onChange: (event, value3, reason) => {
|
|
470
|
-
if (reason === "clear") {
|
|
471
|
-
onChange2(null);
|
|
472
|
-
}
|
|
473
|
-
onChange2(value3);
|
|
474
|
-
},
|
|
475
|
-
onBlur: onBlur2,
|
|
476
|
-
value: value2 || null
|
|
477
|
-
})
|
|
478
|
-
)
|
|
479
|
-
}
|
|
485
|
+
value,
|
|
486
|
+
FieldProps,
|
|
487
|
+
getOptionLabel: import_mui_autocomplete4.handleGetOrgOptionLabel,
|
|
488
|
+
queryKey
|
|
489
|
+
}, rest), {
|
|
490
|
+
loadOptions: handleLoadOptions
|
|
491
|
+
})
|
|
480
492
|
);
|
|
481
493
|
};
|
|
482
494
|
|
|
483
495
|
// src/lib/ProviderAutocomplete.tsx
|
|
484
496
|
var import_mui_autocomplete5 = require("@availity/mui-autocomplete");
|
|
485
|
-
var import_react_hook_form8 = require("react-hook-form");
|
|
486
497
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
487
498
|
var ControlledProviderAutocomplete = (_a) => {
|
|
488
499
|
var _b = _a, {
|
|
@@ -493,7 +504,10 @@ var ControlledProviderAutocomplete = (_a) => {
|
|
|
493
504
|
rules = {},
|
|
494
505
|
shouldUnregister,
|
|
495
506
|
value,
|
|
496
|
-
FieldProps
|
|
507
|
+
FieldProps,
|
|
508
|
+
apiConfig = {},
|
|
509
|
+
customerId,
|
|
510
|
+
queryKey = "prov-autocomplete"
|
|
497
511
|
} = _b, rest = __objRest(_b, [
|
|
498
512
|
"name",
|
|
499
513
|
"defaultValue",
|
|
@@ -502,50 +516,41 @@ var ControlledProviderAutocomplete = (_a) => {
|
|
|
502
516
|
"rules",
|
|
503
517
|
"shouldUnregister",
|
|
504
518
|
"value",
|
|
505
|
-
"FieldProps"
|
|
519
|
+
"FieldProps",
|
|
520
|
+
"apiConfig",
|
|
521
|
+
"customerId",
|
|
522
|
+
"queryKey"
|
|
506
523
|
]);
|
|
524
|
+
const handleLoadOptions = (offset, limit, inputValue) => __async(void 0, null, function* () {
|
|
525
|
+
const resp = yield (0, import_mui_autocomplete5.fetchProviders)(customerId, __spreadProps(__spreadValues({}, apiConfig), {
|
|
526
|
+
params: __spreadProps(__spreadValues({}, apiConfig.params), { offset, limit, q: inputValue })
|
|
527
|
+
}));
|
|
528
|
+
return resp;
|
|
529
|
+
});
|
|
507
530
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
508
|
-
|
|
509
|
-
{
|
|
531
|
+
ControlledAsyncAutocomplete,
|
|
532
|
+
__spreadProps(__spreadValues({
|
|
510
533
|
name,
|
|
511
534
|
defaultValue,
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
shouldUnregister,
|
|
516
|
-
value
|
|
517
|
-
}, rules),
|
|
535
|
+
onBlur,
|
|
536
|
+
onChange,
|
|
537
|
+
rules,
|
|
518
538
|
shouldUnregister,
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("br", {}),
|
|
529
|
-
FieldProps == null ? void 0 : FieldProps.helperText
|
|
530
|
-
] }) : FieldProps == null ? void 0 : FieldProps.helperText
|
|
531
|
-
}),
|
|
532
|
-
onChange: (event, value3, reason) => {
|
|
533
|
-
if (reason === "clear") {
|
|
534
|
-
onChange2(null);
|
|
535
|
-
}
|
|
536
|
-
onChange2(value3);
|
|
537
|
-
},
|
|
538
|
-
onBlur: onBlur2,
|
|
539
|
-
value: value2 || null
|
|
540
|
-
})
|
|
541
|
-
)
|
|
542
|
-
}
|
|
539
|
+
value,
|
|
540
|
+
FieldProps,
|
|
541
|
+
getOptionLabel: import_mui_autocomplete5.handleGetProviderOptionLabel,
|
|
542
|
+
queryOptions: { enabled: !!customerId },
|
|
543
|
+
queryKey,
|
|
544
|
+
watchParams: { customerId }
|
|
545
|
+
}, rest), {
|
|
546
|
+
loadOptions: handleLoadOptions
|
|
547
|
+
})
|
|
543
548
|
);
|
|
544
549
|
};
|
|
545
550
|
|
|
546
551
|
// src/lib/RadioGroup.tsx
|
|
547
552
|
var import_mui_form_utils2 = require("@availity/mui-form-utils");
|
|
548
|
-
var
|
|
553
|
+
var import_react_hook_form6 = require("react-hook-form");
|
|
549
554
|
var import_mui_form_utils3 = require("@availity/mui-form-utils");
|
|
550
555
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
551
556
|
var ControlledRadioGroup = (_a) => {
|
|
@@ -573,7 +578,7 @@ var ControlledRadioGroup = (_a) => {
|
|
|
573
578
|
"value"
|
|
574
579
|
]);
|
|
575
580
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
576
|
-
|
|
581
|
+
import_react_hook_form6.Controller,
|
|
577
582
|
{
|
|
578
583
|
name,
|
|
579
584
|
defaultValue,
|
|
@@ -605,7 +610,7 @@ var ControlledRadioGroup = (_a) => {
|
|
|
605
610
|
|
|
606
611
|
// src/lib/Select.tsx
|
|
607
612
|
var import_mui_form_utils4 = require("@availity/mui-form-utils");
|
|
608
|
-
var
|
|
613
|
+
var import_react_hook_form7 = require("react-hook-form");
|
|
609
614
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
610
615
|
var ControlledSelect = (_a) => {
|
|
611
616
|
var _b = _a, {
|
|
@@ -628,7 +633,7 @@ var ControlledSelect = (_a) => {
|
|
|
628
633
|
"value"
|
|
629
634
|
]);
|
|
630
635
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
631
|
-
|
|
636
|
+
import_react_hook_form7.Controller,
|
|
632
637
|
{
|
|
633
638
|
name,
|
|
634
639
|
defaultValue,
|
|
@@ -654,7 +659,7 @@ var ControlledSelect = (_a) => {
|
|
|
654
659
|
|
|
655
660
|
// src/lib/TextField.tsx
|
|
656
661
|
var import_mui_textfield = require("@availity/mui-textfield");
|
|
657
|
-
var
|
|
662
|
+
var import_react_hook_form8 = require("react-hook-form");
|
|
658
663
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
659
664
|
var ControlledTextField = (_a) => {
|
|
660
665
|
var _b = _a, {
|
|
@@ -679,7 +684,7 @@ var ControlledTextField = (_a) => {
|
|
|
679
684
|
"value"
|
|
680
685
|
]);
|
|
681
686
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
682
|
-
|
|
687
|
+
import_react_hook_form8.Controller,
|
|
683
688
|
{
|
|
684
689
|
name,
|
|
685
690
|
defaultValue,
|
|
@@ -701,7 +706,7 @@ var ControlledTextField = (_a) => {
|
|
|
701
706
|
}, field), rest), {
|
|
702
707
|
slotProps: __spreadProps(__spreadValues({}, rest.slotProps), {
|
|
703
708
|
htmlInput: __spreadValues({
|
|
704
|
-
maxLength: rules.maxLength
|
|
709
|
+
maxLength: typeof rules.maxLength === "object" ? rules.maxLength.value : rules.maxLength
|
|
705
710
|
}, (_a3 = rest.slotProps) == null ? void 0 : _a3.htmlInput)
|
|
706
711
|
}),
|
|
707
712
|
inputRef: ref,
|
|
@@ -719,7 +724,7 @@ var ControlledTextField = (_a) => {
|
|
|
719
724
|
};
|
|
720
725
|
|
|
721
726
|
// src/index.ts
|
|
722
|
-
var
|
|
727
|
+
var import_react_hook_form9 = require("react-hook-form");
|
|
723
728
|
// Annotate the CommonJS export names for ESM import in node:
|
|
724
729
|
0 && (module.exports = {
|
|
725
730
|
ControlledAsyncAutocomplete,
|