@availity/mui-autocomplete 2.2.6 → 3.0.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 +37 -0
- package/README.md +1 -1
- package/dist/index.d.ts +18 -23
- package/dist/index.js +169 -279
- package/introduction.mdx +1 -1
- package/package.json +24 -25
- package/project.json +5 -6
- package/src/lib/AsyncAutocomplete.stories.tsx +1 -1
- package/src/lib/AsyncAutocomplete.test.tsx +6 -8
- package/src/lib/AsyncAutocomplete.tsx +11 -5
- package/src/lib/Autocomplete.stories.tsx +4 -4
- package/src/lib/Autocomplete.tsx +1 -3
- package/src/lib/CodesAutocomplete.stories.tsx +1 -1
- package/src/lib/CodesAutocomplete.test.tsx +1 -2
- package/src/lib/CodesAutocomplete.tsx +5 -5
- package/src/lib/OrganizationAutocomplete.stories.tsx +1 -1
- package/src/lib/OrganizationAutocomplete.test.tsx +1 -2
- package/src/lib/OrganizationAutocomplete.tsx +6 -12
- package/src/lib/ProviderAutocomplete.stories.tsx +1 -1
- package/src/lib/ProviderAutocomplete.test.tsx +2 -3
- package/src/lib/ProviderAutocomplete.tsx +6 -9
- package/dist/index.d.mts +0 -141
- package/dist/index.mjs +0 -363
- package/jest.config.js +0 -17
- package/tsconfig.spec.json +0 -10
package/dist/index.js
CHANGED
|
@@ -1,157 +1,64 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defProps = Object.defineProperties;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
-
var __spreadValues = (a, b) => {
|
|
14
|
-
for (var prop in b || (b = {}))
|
|
15
|
-
if (__hasOwnProp.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
if (__getOwnPropSymbols)
|
|
18
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
-
if (__propIsEnum.call(b, prop))
|
|
20
|
-
__defNormalProp(a, prop, b[prop]);
|
|
21
|
-
}
|
|
22
|
-
return a;
|
|
23
|
-
};
|
|
24
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
-
var __objRest = (source, exclude) => {
|
|
26
|
-
var target = {};
|
|
27
|
-
for (var prop in source)
|
|
28
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
-
target[prop] = source[prop];
|
|
30
|
-
if (source != null && __getOwnPropSymbols)
|
|
31
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
-
target[prop] = source[prop];
|
|
34
|
-
}
|
|
35
|
-
return target;
|
|
36
|
-
};
|
|
37
|
-
var __export = (target, all) => {
|
|
38
|
-
for (var name in all)
|
|
39
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
40
|
-
};
|
|
41
|
-
var __copyProps = (to, from, except, desc) => {
|
|
42
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
43
|
-
for (let key of __getOwnPropNames(from))
|
|
44
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
45
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
46
|
-
}
|
|
47
|
-
return to;
|
|
48
|
-
};
|
|
49
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
50
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
51
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
52
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
53
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
54
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
55
|
-
mod
|
|
56
|
-
));
|
|
57
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
58
|
-
var __async = (__this, __arguments, generator) => {
|
|
59
|
-
return new Promise((resolve, reject) => {
|
|
60
|
-
var fulfilled = (value) => {
|
|
61
|
-
try {
|
|
62
|
-
step(generator.next(value));
|
|
63
|
-
} catch (e) {
|
|
64
|
-
reject(e);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
var rejected = (value) => {
|
|
68
|
-
try {
|
|
69
|
-
step(generator.throw(value));
|
|
70
|
-
} catch (e) {
|
|
71
|
-
reject(e);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
75
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
// src/index.ts
|
|
80
|
-
var index_exports = {};
|
|
81
|
-
__export(index_exports, {
|
|
82
|
-
AsyncAutocomplete: () => AsyncAutocomplete,
|
|
83
|
-
Autocomplete: () => Autocomplete,
|
|
84
|
-
CodesAutocomplete: () => CodesAutocomplete,
|
|
85
|
-
OrganizationAutocomplete: () => OrganizationAutocomplete,
|
|
86
|
-
ProviderAutocomplete: () => ProviderAutocomplete,
|
|
87
|
-
createFilterOptions: () => import_Autocomplete2.createFilterOptions,
|
|
88
|
-
fetchCodes: () => fetchCodes,
|
|
89
|
-
fetchOrgs: () => fetchOrgs,
|
|
90
|
-
fetchProviders: () => fetchProviders,
|
|
91
|
-
handleGetCodesOptionLabel: () => handleGetCodesOptionLabel,
|
|
92
|
-
handleGetOrgOptionLabel: () => handleGetOrgOptionLabel,
|
|
93
|
-
handleGetProviderOptionLabel: () => handleGetProviderOptionLabel
|
|
94
|
-
});
|
|
95
|
-
module.exports = __toCommonJS(index_exports);
|
|
96
|
-
|
|
97
1
|
// src/lib/Autocomplete.tsx
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import {
|
|
4
|
+
default as MuiAutocomplete
|
|
5
|
+
} from "@mui/material/Autocomplete";
|
|
6
|
+
import CircularProgress from "@mui/material/CircularProgress";
|
|
7
|
+
import { default as MuiIconButton } from "@mui/material/IconButton";
|
|
8
|
+
import { TextField } from "@availity/mui-textfield";
|
|
9
|
+
import { SelectDivider, SelectExpandIcon } from "@availity/mui-form-utils";
|
|
10
|
+
import { createFilterOptions } from "@mui/material/Autocomplete";
|
|
11
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
var PopupIndicatorWrapper = forwardRef((props, ref) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
13
|
+
/* @__PURE__ */ jsx(SelectDivider, { orientation: "vertical", className: "MuiSelect-avEndAdornmentDivider" }),
|
|
14
|
+
/* @__PURE__ */ jsx(MuiIconButton, { ...props, ref })
|
|
109
15
|
] }));
|
|
110
16
|
var progressSx = { marginRight: ".5rem" };
|
|
111
|
-
var LoadingIndicator = () => /* @__PURE__ */
|
|
112
|
-
var Autocomplete = (
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
"FieldProps"
|
|
117
|
-
]);
|
|
17
|
+
var LoadingIndicator = () => /* @__PURE__ */ jsx(CircularProgress, { "aria-label": "Loading", size: 20, sx: progressSx });
|
|
18
|
+
var Autocomplete = ({
|
|
19
|
+
FieldProps,
|
|
20
|
+
...props
|
|
21
|
+
}) => {
|
|
118
22
|
const defaultProps = {
|
|
119
23
|
fullWidth: true,
|
|
120
24
|
size: "small"
|
|
121
25
|
};
|
|
122
26
|
const resolvedProps = (params) => ({
|
|
123
|
-
InputProps:
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
27
|
+
InputProps: {
|
|
28
|
+
...params?.InputProps,
|
|
29
|
+
...FieldProps?.InputProps,
|
|
30
|
+
endAdornment: props.loading ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
31
|
+
params?.InputProps.endAdornment || null,
|
|
32
|
+
/* @__PURE__ */ jsx(LoadingIndicator, {})
|
|
33
|
+
] }) : params?.InputProps.endAdornment || null
|
|
34
|
+
},
|
|
35
|
+
inputProps: {
|
|
36
|
+
...params?.inputProps,
|
|
130
37
|
// appease the Level Access scanning tools
|
|
131
|
-
"aria-controls":
|
|
132
|
-
}
|
|
38
|
+
"aria-controls": params?.inputProps["aria-controls"] || ""
|
|
39
|
+
}
|
|
133
40
|
});
|
|
134
|
-
return /* @__PURE__ */
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
renderInput: (params) => {
|
|
138
|
-
|
|
139
|
-
},
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
41
|
+
return /* @__PURE__ */ jsx(
|
|
42
|
+
MuiAutocomplete,
|
|
43
|
+
{
|
|
44
|
+
renderInput: (params) => /* @__PURE__ */ jsx(TextField, { ...params, ...FieldProps, ...resolvedProps(params) }),
|
|
45
|
+
popupIcon: /* @__PURE__ */ jsx(SelectExpandIcon, { className: "MuiSelect-avExpandIcon" }),
|
|
46
|
+
slotProps: { popupIndicator: { component: PopupIndicatorWrapper } },
|
|
47
|
+
...props,
|
|
48
|
+
...defaultProps
|
|
49
|
+
}
|
|
143
50
|
);
|
|
144
51
|
};
|
|
145
52
|
|
|
146
53
|
// src/lib/AsyncAutocomplete.tsx
|
|
147
|
-
|
|
148
|
-
|
|
54
|
+
import { useState as useState2, useRef, useEffect as useEffect2, useCallback } from "react";
|
|
55
|
+
import { useInfiniteQuery } from "@tanstack/react-query";
|
|
149
56
|
|
|
150
57
|
// src/lib/util.tsx
|
|
151
|
-
|
|
58
|
+
import { useEffect, useState } from "react";
|
|
152
59
|
var useDebounce = (value, delay) => {
|
|
153
|
-
const [debouncedValue, setDebouncedValue] =
|
|
154
|
-
|
|
60
|
+
const [debouncedValue, setDebouncedValue] = useState("");
|
|
61
|
+
useEffect(() => {
|
|
155
62
|
const timer = setTimeout(() => {
|
|
156
63
|
setDebouncedValue(value);
|
|
157
64
|
}, delay);
|
|
@@ -163,51 +70,39 @@ var useDebounce = (value, delay) => {
|
|
|
163
70
|
};
|
|
164
71
|
|
|
165
72
|
// src/lib/AsyncAutocomplete.tsx
|
|
166
|
-
|
|
167
|
-
var AsyncAutocomplete = (
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
"ListboxProps",
|
|
184
|
-
"queryOptions",
|
|
185
|
-
"watchParams",
|
|
186
|
-
"debounceTimeout",
|
|
187
|
-
"FieldProps",
|
|
188
|
-
"onInputChange",
|
|
189
|
-
"prependOptions"
|
|
190
|
-
]);
|
|
191
|
-
const [inputValue, setInputValue] = (0, import_react3.useState)("");
|
|
192
|
-
const listboxRef = (0, import_react3.useRef)(null);
|
|
193
|
-
const setListboxRef = (0, import_react3.useCallback)((node) => {
|
|
73
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
74
|
+
var AsyncAutocomplete = ({
|
|
75
|
+
loadOptions,
|
|
76
|
+
limit = 50,
|
|
77
|
+
queryKey,
|
|
78
|
+
ListboxProps,
|
|
79
|
+
queryOptions,
|
|
80
|
+
watchParams,
|
|
81
|
+
debounceTimeout = 350,
|
|
82
|
+
FieldProps,
|
|
83
|
+
onInputChange,
|
|
84
|
+
prependOptions = [],
|
|
85
|
+
...rest
|
|
86
|
+
}) => {
|
|
87
|
+
const [inputValue, setInputValue] = useState2("");
|
|
88
|
+
const listboxRef = useRef(null);
|
|
89
|
+
const setListboxRef = useCallback((node) => {
|
|
194
90
|
listboxRef.current = node;
|
|
195
91
|
}, []);
|
|
196
92
|
const handleInputPropsOnChange = (event) => {
|
|
197
|
-
var _a2;
|
|
198
93
|
setInputValue(event.target.value);
|
|
199
|
-
if (
|
|
94
|
+
if (FieldProps?.InputProps?.onChange) FieldProps.InputProps.onChange(event);
|
|
200
95
|
};
|
|
201
96
|
const debouncedInput = useDebounce(inputValue, debounceTimeout);
|
|
202
|
-
const { isLoading, isFetching, data, hasNextPage, fetchNextPage } =
|
|
97
|
+
const { isLoading, isFetching, data, hasNextPage, fetchNextPage } = useInfiniteQuery({
|
|
203
98
|
queryKey: [queryKey, limit, debouncedInput, watchParams],
|
|
204
|
-
queryFn: (
|
|
205
|
-
|
|
206
|
-
}),
|
|
99
|
+
queryFn: ({ pageParam }) => loadOptions(pageParam, limit, debouncedInput),
|
|
100
|
+
initialPageParam: 0,
|
|
207
101
|
staleTime: 1e4,
|
|
208
|
-
getNextPageParam: (lastPage) => lastPage.hasMore ? lastPage.offset + limit : void 0
|
|
209
|
-
|
|
210
|
-
|
|
102
|
+
getNextPageParam: (lastPage) => lastPage.hasMore ? lastPage.offset + limit : void 0,
|
|
103
|
+
...queryOptions
|
|
104
|
+
});
|
|
105
|
+
const options = data?.pages ? data.pages.flatMap((page) => page.options) : [];
|
|
211
106
|
const finalOptions = prependOptions.length > 0 ? [
|
|
212
107
|
...prependOptions,
|
|
213
108
|
...options.filter(
|
|
@@ -218,179 +113,174 @@ var AsyncAutocomplete = (_a) => {
|
|
|
218
113
|
] : options;
|
|
219
114
|
const handleOnInputChange = (event, value, reason) => {
|
|
220
115
|
if (reason === "clear") {
|
|
221
|
-
setInputValue(
|
|
116
|
+
setInputValue(value);
|
|
222
117
|
} else if (reason === "blur") {
|
|
223
118
|
setInputValue(value);
|
|
224
119
|
}
|
|
225
120
|
if (onInputChange) onInputChange(event, value, reason);
|
|
226
121
|
};
|
|
227
|
-
const handleAddingOptions = (event) =>
|
|
122
|
+
const handleAddingOptions = async (event) => {
|
|
228
123
|
const listboxNode = event.currentTarget;
|
|
229
124
|
const difference = listboxNode.scrollHeight - (listboxNode.scrollTop + listboxNode.clientHeight);
|
|
230
125
|
if (difference <= 10 && !isLoading && !isFetching && hasNextPage) {
|
|
231
126
|
fetchNextPage();
|
|
232
127
|
}
|
|
233
|
-
}
|
|
234
|
-
(
|
|
235
|
-
var _a2;
|
|
128
|
+
};
|
|
129
|
+
useEffect2(() => {
|
|
236
130
|
if (hasNextPage) {
|
|
237
|
-
|
|
131
|
+
listboxRef.current?.dispatchEvent(new UIEvent("scroll"));
|
|
238
132
|
}
|
|
239
|
-
}, [data
|
|
240
|
-
return /* @__PURE__ */ (
|
|
133
|
+
}, [data?.pages.length, hasNextPage]);
|
|
134
|
+
return /* @__PURE__ */ jsx2(
|
|
241
135
|
Autocomplete,
|
|
242
|
-
|
|
136
|
+
{
|
|
137
|
+
...rest,
|
|
243
138
|
onInputChange: handleOnInputChange,
|
|
244
|
-
FieldProps:
|
|
245
|
-
|
|
139
|
+
FieldProps: {
|
|
140
|
+
...FieldProps,
|
|
141
|
+
InputProps: {
|
|
142
|
+
...FieldProps?.InputProps,
|
|
246
143
|
onChange: handleInputPropsOnChange
|
|
247
|
-
}
|
|
248
|
-
}
|
|
144
|
+
}
|
|
145
|
+
},
|
|
249
146
|
loading: isFetching,
|
|
250
147
|
options: finalOptions,
|
|
251
|
-
ListboxProps:
|
|
148
|
+
ListboxProps: {
|
|
149
|
+
...ListboxProps,
|
|
252
150
|
ref: setListboxRef,
|
|
253
151
|
onScroll: handleAddingOptions,
|
|
254
152
|
onPointerEnter: handleAddingOptions
|
|
255
|
-
}
|
|
256
|
-
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
257
155
|
);
|
|
258
156
|
};
|
|
259
157
|
|
|
260
158
|
// src/lib/CodesAutocomplete.tsx
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
var fetchCodes = (config) =>
|
|
264
|
-
const resp =
|
|
159
|
+
import { avCodesApi } from "@availity/api-axios";
|
|
160
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
161
|
+
var fetchCodes = async (config) => {
|
|
162
|
+
const resp = await avCodesApi.query(config);
|
|
265
163
|
return {
|
|
266
164
|
options: resp.data.codes,
|
|
267
165
|
hasMore: config.params.offset + config.params.limit < resp.data.totalCount,
|
|
268
166
|
offset: config.params.offset
|
|
269
167
|
};
|
|
270
|
-
}
|
|
168
|
+
};
|
|
271
169
|
var handleGetCodesOptionLabel = (option) => [option.code, option.value].filter(Boolean).join(" - ");
|
|
272
|
-
var CodesAutocomplete = (
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
"watchParams"
|
|
285
|
-
]);
|
|
286
|
-
const handleLoadOptions = (offset, limit, inputValue) => __async(null, null, function* () {
|
|
287
|
-
const resp = yield fetchCodes(__spreadProps(__spreadValues({}, apiConfig), {
|
|
288
|
-
params: __spreadProps(__spreadValues({}, apiConfig.params), { list, offset, limit, q: inputValue })
|
|
289
|
-
}));
|
|
290
|
-
return __spreadProps(__spreadValues({}, resp), {
|
|
291
|
-
options: resp.options
|
|
170
|
+
var CodesAutocomplete = ({
|
|
171
|
+
apiConfig = {},
|
|
172
|
+
queryOptions,
|
|
173
|
+
queryKey = "codes-autocomplete",
|
|
174
|
+
list,
|
|
175
|
+
watchParams,
|
|
176
|
+
...rest
|
|
177
|
+
}) => {
|
|
178
|
+
const handleLoadOptions = async (offset, limit, inputValue) => {
|
|
179
|
+
const resp = await fetchCodes({
|
|
180
|
+
...apiConfig,
|
|
181
|
+
params: { ...apiConfig.params, list, offset, limit, q: inputValue }
|
|
292
182
|
});
|
|
293
|
-
|
|
294
|
-
|
|
183
|
+
return {
|
|
184
|
+
...resp,
|
|
185
|
+
options: resp.options
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
return /* @__PURE__ */ jsx3(
|
|
295
189
|
AsyncAutocomplete,
|
|
296
|
-
|
|
190
|
+
{
|
|
297
191
|
getOptionLabel: handleGetCodesOptionLabel,
|
|
298
192
|
queryKey,
|
|
299
|
-
queryOptions:
|
|
300
|
-
watchParams:
|
|
301
|
-
|
|
193
|
+
queryOptions: { enabled: !!list, ...queryOptions },
|
|
194
|
+
watchParams: { list, ...watchParams },
|
|
195
|
+
...rest,
|
|
302
196
|
loadOptions: handleLoadOptions
|
|
303
|
-
}
|
|
197
|
+
}
|
|
304
198
|
);
|
|
305
199
|
};
|
|
306
200
|
|
|
307
201
|
// src/lib/OrganizationAutocomplete.tsx
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
var fetchOrgs = (config) =>
|
|
312
|
-
const configWithParamsSerializer =
|
|
202
|
+
import { avOrganizationsApi } from "@availity/api-axios";
|
|
203
|
+
import qs from "qs";
|
|
204
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
205
|
+
var fetchOrgs = async (config) => {
|
|
206
|
+
const configWithParamsSerializer = {
|
|
207
|
+
...config,
|
|
313
208
|
paramsSerializer: {
|
|
314
|
-
serialize: (params) =>
|
|
209
|
+
serialize: (params) => qs.stringify(params, { arrayFormat: "repeat" })
|
|
315
210
|
}
|
|
316
|
-
}
|
|
317
|
-
const resp =
|
|
211
|
+
};
|
|
212
|
+
const resp = await avOrganizationsApi.getOrganizations(configWithParamsSerializer);
|
|
318
213
|
return {
|
|
319
214
|
options: resp.data.organizations,
|
|
320
215
|
hasMore: config.params.offset + config.params.limit < resp.data.totalCount,
|
|
321
216
|
offset: config.params.offset
|
|
322
217
|
};
|
|
323
|
-
}
|
|
218
|
+
};
|
|
324
219
|
var handleGetOrgOptionLabel = (org) => org.name;
|
|
325
|
-
var OrganizationAutocomplete = (
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
const resp = yield fetchOrgs(__spreadProps(__spreadValues({}, apiConfig), { params: __spreadProps(__spreadValues({ dropdown: true }, apiConfig.params), { offset, limit }) }));
|
|
335
|
-
return __spreadProps(__spreadValues({}, resp), {
|
|
220
|
+
var OrganizationAutocomplete = ({
|
|
221
|
+
apiConfig = {},
|
|
222
|
+
queryKey = "org-autocomplete",
|
|
223
|
+
...rest
|
|
224
|
+
}) => {
|
|
225
|
+
const handleLoadOptions = async (offset, limit) => {
|
|
226
|
+
const resp = await fetchOrgs({ ...apiConfig, params: { dropdown: true, ...apiConfig.params, offset, limit } });
|
|
227
|
+
return {
|
|
228
|
+
...resp,
|
|
336
229
|
options: resp.options
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
return /* @__PURE__ */ (
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
return /* @__PURE__ */ jsx4(
|
|
340
233
|
AsyncAutocomplete,
|
|
341
|
-
|
|
234
|
+
{
|
|
342
235
|
getOptionLabel: handleGetOrgOptionLabel,
|
|
343
|
-
queryKey
|
|
344
|
-
|
|
236
|
+
queryKey,
|
|
237
|
+
...rest,
|
|
345
238
|
loadOptions: handleLoadOptions
|
|
346
|
-
}
|
|
239
|
+
}
|
|
347
240
|
);
|
|
348
241
|
};
|
|
349
242
|
|
|
350
243
|
// src/lib/ProviderAutocomplete.tsx
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
var fetchProviders = (customerId, config) =>
|
|
354
|
-
const resp =
|
|
244
|
+
import { avProvidersApi } from "@availity/api-axios";
|
|
245
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
246
|
+
var fetchProviders = async (customerId, config) => {
|
|
247
|
+
const resp = await avProvidersApi.getProviders(customerId, config);
|
|
355
248
|
return {
|
|
356
249
|
options: resp.data.providers,
|
|
357
250
|
hasMore: config.params.offset + config.params.limit < resp.data.totalCount,
|
|
358
251
|
offset: config.params.offset
|
|
359
252
|
};
|
|
360
|
-
}
|
|
253
|
+
};
|
|
361
254
|
var handleGetProviderOptionLabel = (option) => option.uiDisplayName;
|
|
362
|
-
var ProviderAutocomplete = (
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
const handleLoadOptions = (offset, limit, inputValue) => __async(null, null, function* () {
|
|
373
|
-
const resp = yield fetchProviders(customerId, __spreadProps(__spreadValues({}, apiConfig), {
|
|
374
|
-
params: __spreadProps(__spreadValues({}, apiConfig.params), { offset, limit, q: inputValue })
|
|
375
|
-
}));
|
|
376
|
-
return __spreadProps(__spreadValues({}, resp), {
|
|
377
|
-
options: resp.options
|
|
255
|
+
var ProviderAutocomplete = ({
|
|
256
|
+
apiConfig = {},
|
|
257
|
+
customerId,
|
|
258
|
+
queryKey = "prov-autocomplete",
|
|
259
|
+
...rest
|
|
260
|
+
}) => {
|
|
261
|
+
const handleLoadOptions = async (offset, limit, inputValue) => {
|
|
262
|
+
const resp = await fetchProviders(customerId, {
|
|
263
|
+
...apiConfig,
|
|
264
|
+
params: { ...apiConfig.params, offset, limit, q: inputValue }
|
|
378
265
|
});
|
|
379
|
-
|
|
380
|
-
|
|
266
|
+
return {
|
|
267
|
+
...resp,
|
|
268
|
+
options: resp.options
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
return /* @__PURE__ */ jsx5(
|
|
381
272
|
AsyncAutocomplete,
|
|
382
|
-
|
|
273
|
+
{
|
|
383
274
|
getOptionLabel: handleGetProviderOptionLabel,
|
|
384
275
|
queryOptions: { enabled: !!customerId },
|
|
385
276
|
queryKey,
|
|
386
|
-
watchParams: { customerId }
|
|
387
|
-
|
|
277
|
+
watchParams: { customerId },
|
|
278
|
+
...rest,
|
|
388
279
|
loadOptions: handleLoadOptions
|
|
389
|
-
}
|
|
280
|
+
}
|
|
390
281
|
);
|
|
391
282
|
};
|
|
392
|
-
|
|
393
|
-
0 && (module.exports = {
|
|
283
|
+
export {
|
|
394
284
|
AsyncAutocomplete,
|
|
395
285
|
Autocomplete,
|
|
396
286
|
CodesAutocomplete,
|
|
@@ -403,4 +293,4 @@ var ProviderAutocomplete = (_a) => {
|
|
|
403
293
|
handleGetCodesOptionLabel,
|
|
404
294
|
handleGetOrgOptionLabel,
|
|
405
295
|
handleGetProviderOptionLabel
|
|
406
|
-
}
|
|
296
|
+
};
|
package/introduction.mdx
CHANGED
|
@@ -2,7 +2,7 @@ import { Markdown, Meta } from '@storybook/addon-docs/blocks';
|
|
|
2
2
|
import ReadMe from './README.md?raw';
|
|
3
3
|
import CHANGELOG from './CHANGELOG.md?raw';
|
|
4
4
|
|
|
5
|
-
<Meta title="Form Components/Autocomplete/
|
|
5
|
+
<Meta title="Form Components/Uncontrolled Fields/Autocomplete/README" />
|
|
6
6
|
|
|
7
7
|
<Markdown>{ReadMe}</Markdown>
|
|
8
8
|
|