@availity/mui-autocomplete 1.2.4 → 1.2.6
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 +12 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +17 -11
- package/dist/index.mjs +17 -11
- package/package.json +1 -1
- package/src/lib/AsyncAutocomplete.stories.tsx +0 -7
- package/src/lib/CodesAutocomplete.stories.tsx +0 -7
- package/src/lib/CodesAutocomplete.tsx +13 -4
- package/src/lib/OrganizationAutocomplete.stories.tsx +0 -7
- package/src/lib/OrganizationAutocomplete.tsx +13 -4
- package/src/lib/ProviderAutocomplete.stories.tsx +0 -7
- package/src/lib/ProviderAutocomplete.tsx +13 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [1.2.6](https://github.com/Availity/element/compare/@availity/mui-autocomplete@1.2.5...@availity/mui-autocomplete@1.2.6) (2025-10-09)
|
|
6
|
+
|
|
7
|
+
### Dependency Updates
|
|
8
|
+
|
|
9
|
+
* `@availity/mock` updated to version `1.2.5`
|
|
10
|
+
## [1.2.5](https://github.com/Availity/element/compare/@availity/mui-autocomplete@1.2.4...@availity/mui-autocomplete@1.2.5) (2025-07-17)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **mui-autocomplete:** fix the multiple prop type for async autocompletes ([3b904a4](https://github.com/Availity/element/commit/3b904a4f88b250433d75ff4a439aab10adc238e9))
|
|
16
|
+
|
|
5
17
|
## [1.2.4](https://github.com/Availity/element/compare/@availity/mui-autocomplete@1.2.3...@availity/mui-autocomplete@1.2.4) (2025-06-18)
|
|
6
18
|
|
|
7
19
|
|
package/dist/index.d.mts
CHANGED
|
@@ -56,7 +56,7 @@ interface CodesAutocompleteProps<Option = Code, Multiple extends boolean | undef
|
|
|
56
56
|
apiConfig?: ApiConfig;
|
|
57
57
|
}
|
|
58
58
|
declare const handleGetCodesOptionLabel: (option: Code) => string;
|
|
59
|
-
declare const CodesAutocomplete: ({ apiConfig, queryOptions, queryKey, list, watchParams, ...rest }: CodesAutocompleteProps) => react_jsx_runtime.JSX.Element;
|
|
59
|
+
declare const CodesAutocomplete: <Option = Code, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = "div">({ apiConfig, queryOptions, queryKey, list, watchParams, ...rest }: CodesAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>) => react_jsx_runtime.JSX.Element;
|
|
60
60
|
|
|
61
61
|
type Organization = {
|
|
62
62
|
customerId: string;
|
|
@@ -75,7 +75,7 @@ interface OrgAutocompleteProps<Option = Organization, Multiple extends boolean |
|
|
|
75
75
|
apiConfig?: ApiConfig;
|
|
76
76
|
}
|
|
77
77
|
declare const handleGetOrgOptionLabel: (org: Organization) => string;
|
|
78
|
-
declare const OrganizationAutocomplete: ({ apiConfig, queryKey, ...rest }: OrgAutocompleteProps) => react_jsx_runtime.JSX.Element;
|
|
78
|
+
declare const OrganizationAutocomplete: <Option = Organization, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = "div">({ apiConfig, queryKey, ...rest }: OrgAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>) => react_jsx_runtime.JSX.Element;
|
|
79
79
|
|
|
80
80
|
type Provider = {
|
|
81
81
|
id: string;
|
|
@@ -134,6 +134,6 @@ interface ProviderAutocompleteProps<Option = Provider, Multiple extends boolean
|
|
|
134
134
|
apiConfig?: ApiConfig;
|
|
135
135
|
}
|
|
136
136
|
declare const handleGetProviderOptionLabel: (option: Provider) => string;
|
|
137
|
-
declare const ProviderAutocomplete: ({ apiConfig, customerId, queryKey, ...rest }: ProviderAutocompleteProps) => react_jsx_runtime.JSX.Element;
|
|
137
|
+
declare const ProviderAutocomplete: <Option = Provider, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = "div">({ apiConfig, customerId, queryKey, ...rest }: ProviderAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>) => react_jsx_runtime.JSX.Element;
|
|
138
138
|
|
|
139
139
|
export { AsyncAutocomplete, type AsyncAutocompleteProps, Autocomplete, type AutocompleteProps, type Code, CodesAutocomplete, type CodesAutocompleteProps, type OrgAutocompleteProps, type Organization, OrganizationAutocomplete, type Provider, ProviderAutocomplete, type ProviderAutocompleteProps, fetchCodes, fetchOrgs, fetchProviders, handleGetCodesOptionLabel, handleGetOrgOptionLabel, handleGetProviderOptionLabel };
|
package/dist/index.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ interface CodesAutocompleteProps<Option = Code, Multiple extends boolean | undef
|
|
|
56
56
|
apiConfig?: ApiConfig;
|
|
57
57
|
}
|
|
58
58
|
declare const handleGetCodesOptionLabel: (option: Code) => string;
|
|
59
|
-
declare const CodesAutocomplete: ({ apiConfig, queryOptions, queryKey, list, watchParams, ...rest }: CodesAutocompleteProps) => react_jsx_runtime.JSX.Element;
|
|
59
|
+
declare const CodesAutocomplete: <Option = Code, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = "div">({ apiConfig, queryOptions, queryKey, list, watchParams, ...rest }: CodesAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>) => react_jsx_runtime.JSX.Element;
|
|
60
60
|
|
|
61
61
|
type Organization = {
|
|
62
62
|
customerId: string;
|
|
@@ -75,7 +75,7 @@ interface OrgAutocompleteProps<Option = Organization, Multiple extends boolean |
|
|
|
75
75
|
apiConfig?: ApiConfig;
|
|
76
76
|
}
|
|
77
77
|
declare const handleGetOrgOptionLabel: (org: Organization) => string;
|
|
78
|
-
declare const OrganizationAutocomplete: ({ apiConfig, queryKey, ...rest }: OrgAutocompleteProps) => react_jsx_runtime.JSX.Element;
|
|
78
|
+
declare const OrganizationAutocomplete: <Option = Organization, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = "div">({ apiConfig, queryKey, ...rest }: OrgAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>) => react_jsx_runtime.JSX.Element;
|
|
79
79
|
|
|
80
80
|
type Provider = {
|
|
81
81
|
id: string;
|
|
@@ -134,6 +134,6 @@ interface ProviderAutocompleteProps<Option = Provider, Multiple extends boolean
|
|
|
134
134
|
apiConfig?: ApiConfig;
|
|
135
135
|
}
|
|
136
136
|
declare const handleGetProviderOptionLabel: (option: Provider) => string;
|
|
137
|
-
declare const ProviderAutocomplete: ({ apiConfig, customerId, queryKey, ...rest }: ProviderAutocompleteProps) => react_jsx_runtime.JSX.Element;
|
|
137
|
+
declare const ProviderAutocomplete: <Option = Provider, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = "div">({ apiConfig, customerId, queryKey, ...rest }: ProviderAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>) => react_jsx_runtime.JSX.Element;
|
|
138
138
|
|
|
139
139
|
export { AsyncAutocomplete, type AsyncAutocompleteProps, Autocomplete, type AutocompleteProps, type Code, CodesAutocomplete, type CodesAutocompleteProps, type OrgAutocompleteProps, type Organization, OrganizationAutocomplete, type Provider, ProviderAutocomplete, type ProviderAutocompleteProps, fetchCodes, fetchOrgs, fetchProviders, handleGetCodesOptionLabel, handleGetOrgOptionLabel, handleGetProviderOptionLabel };
|
package/dist/index.js
CHANGED
|
@@ -195,7 +195,7 @@ var AsyncAutocomplete = (_a) => {
|
|
|
195
195
|
const debouncedInput = useDebounce(inputValue, debounceTimeout);
|
|
196
196
|
const { isLoading, isFetching, data, hasNextPage, fetchNextPage } = (0, import_react_query.useInfiniteQuery)(__spreadValues({
|
|
197
197
|
queryKey: [queryKey, limit, debouncedInput, watchParams],
|
|
198
|
-
queryFn: (_0) => __async(
|
|
198
|
+
queryFn: (_0) => __async(null, [_0], function* ({ pageParam = 0 }) {
|
|
199
199
|
return loadOptions(pageParam, limit, debouncedInput);
|
|
200
200
|
}),
|
|
201
201
|
staleTime: 1e4,
|
|
@@ -222,7 +222,7 @@ var AsyncAutocomplete = (_a) => {
|
|
|
222
222
|
loading: isFetching,
|
|
223
223
|
options,
|
|
224
224
|
ListboxProps: __spreadProps(__spreadValues({}, ListboxProps), {
|
|
225
|
-
onScroll: (event) => __async(
|
|
225
|
+
onScroll: (event) => __async(null, null, function* () {
|
|
226
226
|
const listboxNode = event.currentTarget;
|
|
227
227
|
const difference = listboxNode.scrollHeight - (listboxNode.scrollTop + listboxNode.clientHeight);
|
|
228
228
|
if (difference <= 5 && !isLoading && !isFetching && hasNextPage) {
|
|
@@ -237,7 +237,7 @@ var AsyncAutocomplete = (_a) => {
|
|
|
237
237
|
// src/lib/CodesAutocomplete.tsx
|
|
238
238
|
var import_api_axios = require("@availity/api-axios");
|
|
239
239
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
240
|
-
var fetchCodes = (config) => __async(
|
|
240
|
+
var fetchCodes = (config) => __async(null, null, function* () {
|
|
241
241
|
const resp = yield import_api_axios.avCodesApi.query(config);
|
|
242
242
|
return {
|
|
243
243
|
options: resp.data.codes,
|
|
@@ -260,11 +260,13 @@ var CodesAutocomplete = (_a) => {
|
|
|
260
260
|
"list",
|
|
261
261
|
"watchParams"
|
|
262
262
|
]);
|
|
263
|
-
const handleLoadOptions = (offset, limit, inputValue) => __async(
|
|
263
|
+
const handleLoadOptions = (offset, limit, inputValue) => __async(null, null, function* () {
|
|
264
264
|
const resp = yield fetchCodes(__spreadProps(__spreadValues({}, apiConfig), {
|
|
265
265
|
params: __spreadProps(__spreadValues({}, apiConfig.params), { list, offset, limit, q: inputValue })
|
|
266
266
|
}));
|
|
267
|
-
return resp
|
|
267
|
+
return __spreadProps(__spreadValues({}, resp), {
|
|
268
|
+
options: resp.options
|
|
269
|
+
});
|
|
268
270
|
});
|
|
269
271
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
270
272
|
AsyncAutocomplete,
|
|
@@ -283,7 +285,7 @@ var CodesAutocomplete = (_a) => {
|
|
|
283
285
|
var import_api_axios2 = require("@availity/api-axios");
|
|
284
286
|
var import_qs = __toESM(require("qs"));
|
|
285
287
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
286
|
-
var fetchOrgs = (config) => __async(
|
|
288
|
+
var fetchOrgs = (config) => __async(null, null, function* () {
|
|
287
289
|
const configWithParamsSerializer = __spreadProps(__spreadValues({}, config), {
|
|
288
290
|
paramsSerializer: {
|
|
289
291
|
serialize: (params) => import_qs.default.stringify(params, { arrayFormat: "repeat" })
|
|
@@ -305,9 +307,11 @@ var OrganizationAutocomplete = (_a) => {
|
|
|
305
307
|
"apiConfig",
|
|
306
308
|
"queryKey"
|
|
307
309
|
]);
|
|
308
|
-
const handleLoadOptions = (offset, limit) => __async(
|
|
310
|
+
const handleLoadOptions = (offset, limit) => __async(null, null, function* () {
|
|
309
311
|
const resp = yield fetchOrgs(__spreadProps(__spreadValues({}, apiConfig), { params: __spreadProps(__spreadValues({ dropdown: true }, apiConfig.params), { offset, limit }) }));
|
|
310
|
-
return resp
|
|
312
|
+
return __spreadProps(__spreadValues({}, resp), {
|
|
313
|
+
options: resp.options
|
|
314
|
+
});
|
|
311
315
|
});
|
|
312
316
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
313
317
|
AsyncAutocomplete,
|
|
@@ -323,7 +327,7 @@ var OrganizationAutocomplete = (_a) => {
|
|
|
323
327
|
// src/lib/ProviderAutocomplete.tsx
|
|
324
328
|
var import_api_axios3 = require("@availity/api-axios");
|
|
325
329
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
326
|
-
var fetchProviders = (customerId, config) => __async(
|
|
330
|
+
var fetchProviders = (customerId, config) => __async(null, null, function* () {
|
|
327
331
|
const resp = yield import_api_axios3.avProvidersApi.getProviders(customerId, config);
|
|
328
332
|
return {
|
|
329
333
|
options: resp.data.providers,
|
|
@@ -342,11 +346,13 @@ var ProviderAutocomplete = (_a) => {
|
|
|
342
346
|
"customerId",
|
|
343
347
|
"queryKey"
|
|
344
348
|
]);
|
|
345
|
-
const handleLoadOptions = (offset, limit, inputValue) => __async(
|
|
349
|
+
const handleLoadOptions = (offset, limit, inputValue) => __async(null, null, function* () {
|
|
346
350
|
const resp = yield fetchProviders(customerId, __spreadProps(__spreadValues({}, apiConfig), {
|
|
347
351
|
params: __spreadProps(__spreadValues({}, apiConfig.params), { offset, limit, q: inputValue })
|
|
348
352
|
}));
|
|
349
|
-
return resp
|
|
353
|
+
return __spreadProps(__spreadValues({}, resp), {
|
|
354
|
+
options: resp.options
|
|
355
|
+
});
|
|
350
356
|
});
|
|
351
357
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
352
358
|
AsyncAutocomplete,
|
package/dist/index.mjs
CHANGED
|
@@ -153,7 +153,7 @@ var AsyncAutocomplete = (_a) => {
|
|
|
153
153
|
const debouncedInput = useDebounce(inputValue, debounceTimeout);
|
|
154
154
|
const { isLoading, isFetching, data, hasNextPage, fetchNextPage } = useInfiniteQuery(__spreadValues({
|
|
155
155
|
queryKey: [queryKey, limit, debouncedInput, watchParams],
|
|
156
|
-
queryFn: (_0) => __async(
|
|
156
|
+
queryFn: (_0) => __async(null, [_0], function* ({ pageParam = 0 }) {
|
|
157
157
|
return loadOptions(pageParam, limit, debouncedInput);
|
|
158
158
|
}),
|
|
159
159
|
staleTime: 1e4,
|
|
@@ -180,7 +180,7 @@ var AsyncAutocomplete = (_a) => {
|
|
|
180
180
|
loading: isFetching,
|
|
181
181
|
options,
|
|
182
182
|
ListboxProps: __spreadProps(__spreadValues({}, ListboxProps), {
|
|
183
|
-
onScroll: (event) => __async(
|
|
183
|
+
onScroll: (event) => __async(null, null, function* () {
|
|
184
184
|
const listboxNode = event.currentTarget;
|
|
185
185
|
const difference = listboxNode.scrollHeight - (listboxNode.scrollTop + listboxNode.clientHeight);
|
|
186
186
|
if (difference <= 5 && !isLoading && !isFetching && hasNextPage) {
|
|
@@ -195,7 +195,7 @@ var AsyncAutocomplete = (_a) => {
|
|
|
195
195
|
// src/lib/CodesAutocomplete.tsx
|
|
196
196
|
import { avCodesApi } from "@availity/api-axios";
|
|
197
197
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
198
|
-
var fetchCodes = (config) => __async(
|
|
198
|
+
var fetchCodes = (config) => __async(null, null, function* () {
|
|
199
199
|
const resp = yield avCodesApi.query(config);
|
|
200
200
|
return {
|
|
201
201
|
options: resp.data.codes,
|
|
@@ -218,11 +218,13 @@ var CodesAutocomplete = (_a) => {
|
|
|
218
218
|
"list",
|
|
219
219
|
"watchParams"
|
|
220
220
|
]);
|
|
221
|
-
const handleLoadOptions = (offset, limit, inputValue) => __async(
|
|
221
|
+
const handleLoadOptions = (offset, limit, inputValue) => __async(null, null, function* () {
|
|
222
222
|
const resp = yield fetchCodes(__spreadProps(__spreadValues({}, apiConfig), {
|
|
223
223
|
params: __spreadProps(__spreadValues({}, apiConfig.params), { list, offset, limit, q: inputValue })
|
|
224
224
|
}));
|
|
225
|
-
return resp
|
|
225
|
+
return __spreadProps(__spreadValues({}, resp), {
|
|
226
|
+
options: resp.options
|
|
227
|
+
});
|
|
226
228
|
});
|
|
227
229
|
return /* @__PURE__ */ jsx3(
|
|
228
230
|
AsyncAutocomplete,
|
|
@@ -241,7 +243,7 @@ var CodesAutocomplete = (_a) => {
|
|
|
241
243
|
import { avOrganizationsApi } from "@availity/api-axios";
|
|
242
244
|
import qs from "qs";
|
|
243
245
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
244
|
-
var fetchOrgs = (config) => __async(
|
|
246
|
+
var fetchOrgs = (config) => __async(null, null, function* () {
|
|
245
247
|
const configWithParamsSerializer = __spreadProps(__spreadValues({}, config), {
|
|
246
248
|
paramsSerializer: {
|
|
247
249
|
serialize: (params) => qs.stringify(params, { arrayFormat: "repeat" })
|
|
@@ -263,9 +265,11 @@ var OrganizationAutocomplete = (_a) => {
|
|
|
263
265
|
"apiConfig",
|
|
264
266
|
"queryKey"
|
|
265
267
|
]);
|
|
266
|
-
const handleLoadOptions = (offset, limit) => __async(
|
|
268
|
+
const handleLoadOptions = (offset, limit) => __async(null, null, function* () {
|
|
267
269
|
const resp = yield fetchOrgs(__spreadProps(__spreadValues({}, apiConfig), { params: __spreadProps(__spreadValues({ dropdown: true }, apiConfig.params), { offset, limit }) }));
|
|
268
|
-
return resp
|
|
270
|
+
return __spreadProps(__spreadValues({}, resp), {
|
|
271
|
+
options: resp.options
|
|
272
|
+
});
|
|
269
273
|
});
|
|
270
274
|
return /* @__PURE__ */ jsx4(
|
|
271
275
|
AsyncAutocomplete,
|
|
@@ -281,7 +285,7 @@ var OrganizationAutocomplete = (_a) => {
|
|
|
281
285
|
// src/lib/ProviderAutocomplete.tsx
|
|
282
286
|
import { avProvidersApi } from "@availity/api-axios";
|
|
283
287
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
284
|
-
var fetchProviders = (customerId, config) => __async(
|
|
288
|
+
var fetchProviders = (customerId, config) => __async(null, null, function* () {
|
|
285
289
|
const resp = yield avProvidersApi.getProviders(customerId, config);
|
|
286
290
|
return {
|
|
287
291
|
options: resp.data.providers,
|
|
@@ -300,11 +304,13 @@ var ProviderAutocomplete = (_a) => {
|
|
|
300
304
|
"customerId",
|
|
301
305
|
"queryKey"
|
|
302
306
|
]);
|
|
303
|
-
const handleLoadOptions = (offset, limit, inputValue) => __async(
|
|
307
|
+
const handleLoadOptions = (offset, limit, inputValue) => __async(null, null, function* () {
|
|
304
308
|
const resp = yield fetchProviders(customerId, __spreadProps(__spreadValues({}, apiConfig), {
|
|
305
309
|
params: __spreadProps(__spreadValues({}, apiConfig.params), { offset, limit, q: inputValue })
|
|
306
310
|
}));
|
|
307
|
-
return resp
|
|
311
|
+
return __spreadProps(__spreadValues({}, resp), {
|
|
312
|
+
options: resp.options
|
|
313
|
+
});
|
|
308
314
|
});
|
|
309
315
|
return /* @__PURE__ */ jsx5(
|
|
310
316
|
AsyncAutocomplete,
|
package/package.json
CHANGED
|
@@ -37,26 +37,35 @@ export interface CodesAutocompleteProps<
|
|
|
37
37
|
|
|
38
38
|
export const handleGetCodesOptionLabel = (option: Code) => [option.code, option.value].filter(Boolean).join(' - ');
|
|
39
39
|
|
|
40
|
-
export const CodesAutocomplete =
|
|
40
|
+
export const CodesAutocomplete = <
|
|
41
|
+
Option = Code,
|
|
42
|
+
Multiple extends boolean | undefined = false,
|
|
43
|
+
DisableClearable extends boolean | undefined = false,
|
|
44
|
+
FreeSolo extends boolean | undefined = false,
|
|
45
|
+
ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent'],
|
|
46
|
+
>({
|
|
41
47
|
apiConfig = {},
|
|
42
48
|
queryOptions,
|
|
43
49
|
queryKey = 'codes-autocomplete',
|
|
44
50
|
list,
|
|
45
51
|
watchParams,
|
|
46
52
|
...rest
|
|
47
|
-
}: CodesAutocompleteProps) => {
|
|
53
|
+
}: CodesAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>) => {
|
|
48
54
|
const handleLoadOptions = async (offset: number, limit: number, inputValue: string) => {
|
|
49
55
|
const resp = await fetchCodes({
|
|
50
56
|
...apiConfig,
|
|
51
57
|
params: { ...apiConfig.params, list, offset, limit, q: inputValue },
|
|
52
58
|
});
|
|
53
59
|
|
|
54
|
-
return
|
|
60
|
+
return {
|
|
61
|
+
...resp,
|
|
62
|
+
options: resp.options as Option[],
|
|
63
|
+
};
|
|
55
64
|
};
|
|
56
65
|
|
|
57
66
|
return (
|
|
58
67
|
<AsyncAutocomplete
|
|
59
|
-
getOptionLabel={handleGetCodesOptionLabel}
|
|
68
|
+
getOptionLabel={handleGetCodesOptionLabel as (option: Option) => string}
|
|
60
69
|
queryKey={queryKey}
|
|
61
70
|
queryOptions={{ enabled: !!list, ...queryOptions }}
|
|
62
71
|
watchParams={{ list, ...watchParams }}
|
|
@@ -49,20 +49,29 @@ export interface OrgAutocompleteProps<
|
|
|
49
49
|
|
|
50
50
|
export const handleGetOrgOptionLabel = (org: Organization) => org.name;
|
|
51
51
|
|
|
52
|
-
export const OrganizationAutocomplete =
|
|
52
|
+
export const OrganizationAutocomplete = <
|
|
53
|
+
Option = Organization,
|
|
54
|
+
Multiple extends boolean | undefined = false,
|
|
55
|
+
DisableClearable extends boolean | undefined = false,
|
|
56
|
+
FreeSolo extends boolean | undefined = false,
|
|
57
|
+
ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent'],
|
|
58
|
+
>({
|
|
53
59
|
apiConfig = {},
|
|
54
60
|
queryKey = 'org-autocomplete',
|
|
55
61
|
...rest
|
|
56
|
-
}: OrgAutocompleteProps) => {
|
|
62
|
+
}: OrgAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>) => {
|
|
57
63
|
const handleLoadOptions = async (offset: number, limit: number) => {
|
|
58
64
|
const resp = await fetchOrgs({ ...apiConfig, params: { dropdown: true, ...apiConfig.params, offset, limit } });
|
|
59
65
|
|
|
60
|
-
return
|
|
66
|
+
return {
|
|
67
|
+
...resp,
|
|
68
|
+
options: resp.options as Option[],
|
|
69
|
+
};
|
|
61
70
|
};
|
|
62
71
|
|
|
63
72
|
return (
|
|
64
73
|
<AsyncAutocomplete
|
|
65
|
-
getOptionLabel={handleGetOrgOptionLabel}
|
|
74
|
+
getOptionLabel={handleGetOrgOptionLabel as (option: Option) => string}
|
|
66
75
|
queryKey={queryKey}
|
|
67
76
|
{...rest}
|
|
68
77
|
loadOptions={handleLoadOptions}
|
|
@@ -64,24 +64,33 @@ export interface ProviderAutocompleteProps<
|
|
|
64
64
|
|
|
65
65
|
export const handleGetProviderOptionLabel = (option: Provider) => option.uiDisplayName;
|
|
66
66
|
|
|
67
|
-
export const ProviderAutocomplete =
|
|
67
|
+
export const ProviderAutocomplete = <
|
|
68
|
+
Option = Provider,
|
|
69
|
+
Multiple extends boolean | undefined = false,
|
|
70
|
+
DisableClearable extends boolean | undefined = false,
|
|
71
|
+
FreeSolo extends boolean | undefined = false,
|
|
72
|
+
ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent'],
|
|
73
|
+
>({
|
|
68
74
|
apiConfig = {},
|
|
69
75
|
customerId,
|
|
70
76
|
queryKey = 'prov-autocomplete',
|
|
71
77
|
...rest
|
|
72
|
-
}: ProviderAutocompleteProps) => {
|
|
78
|
+
}: ProviderAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>) => {
|
|
73
79
|
const handleLoadOptions = async (offset: number, limit: number, inputValue: string) => {
|
|
74
80
|
const resp = await fetchProviders(customerId, {
|
|
75
81
|
...apiConfig,
|
|
76
82
|
params: { ...apiConfig.params, offset, limit, q: inputValue },
|
|
77
83
|
});
|
|
78
84
|
|
|
79
|
-
return
|
|
85
|
+
return {
|
|
86
|
+
...resp,
|
|
87
|
+
options: resp.options as Option[],
|
|
88
|
+
};
|
|
80
89
|
};
|
|
81
90
|
|
|
82
91
|
return (
|
|
83
92
|
<AsyncAutocomplete
|
|
84
|
-
getOptionLabel={handleGetProviderOptionLabel}
|
|
93
|
+
getOptionLabel={handleGetProviderOptionLabel as (option: Option) => string}
|
|
85
94
|
queryOptions={{ enabled: !!customerId }}
|
|
86
95
|
queryKey={queryKey}
|
|
87
96
|
watchParams={{ customerId }}
|