@box/combobox-with-api 0.45.8 → 0.46.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.
|
@@ -1,45 +1,51 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import
|
|
3
|
-
import { ComboboxWithApi as
|
|
4
|
-
import { jsx as
|
|
5
|
-
const
|
|
1
|
+
import { useState as s, useMemo as d, useCallback as Q, useEffect as T } from "react";
|
|
2
|
+
import w from "lodash/debounce";
|
|
3
|
+
import { ComboboxWithApi as D } from "./combobox-with-api.js";
|
|
4
|
+
import { jsx as W } from "react/jsx-runtime";
|
|
5
|
+
const j = "AbortError", _ = (E) => {
|
|
6
6
|
const {
|
|
7
|
-
debounceTime:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
debounceTime: u = 250,
|
|
8
|
+
defaultOptions: n,
|
|
9
|
+
fetcher: f,
|
|
10
|
+
includeTextInputOption: m = !1,
|
|
11
|
+
onInputValueChange: i,
|
|
12
|
+
...O
|
|
13
|
+
} = E, [p, h] = s(!1), [x, g] = s(!1), [A, y] = s(!1), [e, C] = s(""), [b, a] = s([]), c = d(() => w(C, u), [u]), I = (o) => {
|
|
14
|
+
c(o), i == null || i(o);
|
|
15
|
+
}, l = Q(async (o) => {
|
|
16
|
+
const r = o.trim();
|
|
17
|
+
if (r) {
|
|
18
|
+
g(!1), h(!0);
|
|
18
19
|
try {
|
|
19
|
-
const t = await
|
|
20
|
-
if ((t.length > 0 ? typeof t[0] == "string" : !0) &&
|
|
21
|
-
const
|
|
22
|
-
|
|
20
|
+
const t = await f(r);
|
|
21
|
+
if ((t.length > 0 ? typeof t[0] == "string" : !0) && m) {
|
|
22
|
+
const V = r.toLocaleLowerCase();
|
|
23
|
+
a([V, ...t]);
|
|
23
24
|
} else
|
|
24
|
-
|
|
25
|
+
y((t == null ? void 0 : t.length) === 0), a(t);
|
|
25
26
|
} catch (t) {
|
|
26
|
-
(t == null ? void 0 : t.name) !==
|
|
27
|
+
(t == null ? void 0 : t.name) !== j && g(!0);
|
|
27
28
|
} finally {
|
|
28
|
-
|
|
29
|
+
h(!1);
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
|
-
}, [
|
|
32
|
-
|
|
32
|
+
}, [f, m]), L = () => {
|
|
33
|
+
l(e);
|
|
33
34
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
T(() => (e.trim().length ? l(e) : (a([]), y(!1)), () => c.cancel()), [c, l, e]);
|
|
36
|
+
const S = d(() => {
|
|
37
|
+
const o = e.trim().length > 0;
|
|
38
|
+
return (n == null ? void 0 : n.length) > 0 && !o ? n : b;
|
|
39
|
+
}, [e, n, b]);
|
|
40
|
+
return /* @__PURE__ */ W(D, {
|
|
41
|
+
...O,
|
|
42
|
+
isEmpty: A,
|
|
43
|
+
isError: x,
|
|
44
|
+
isLoading: p,
|
|
45
|
+
loading: p,
|
|
46
|
+
onInputValueChange: I,
|
|
47
|
+
onTryAgain: L,
|
|
48
|
+
options: S
|
|
43
49
|
});
|
|
44
50
|
};
|
|
45
51
|
export {
|
|
@@ -30,6 +30,10 @@ export type ComboboxWithApiContainerProps<Multiple extends boolean, FreeInput ex
|
|
|
30
30
|
* Boolean to show a dropdown option for text input
|
|
31
31
|
*/
|
|
32
32
|
includeTextInputOption?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Default options to show when the input is empty
|
|
35
|
+
*/
|
|
36
|
+
defaultOptions?: T[];
|
|
33
37
|
};
|
|
34
38
|
export type ComboboxWithApiErrorProps = {
|
|
35
39
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/combobox-with-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@ariakit/react": "0.4.15",
|
|
6
6
|
"@box/blueprint-web": "^10.3.1",
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
"react-intl": "^6.4.2"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@box/tree": "^0.51.
|
|
14
|
+
"@box/tree": "^0.51.5",
|
|
15
15
|
"react-accessible-treeview": "2.9.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@box/blueprint-web": "^12.
|
|
18
|
+
"@box/blueprint-web": "^12.19.0",
|
|
19
19
|
"@box/blueprint-web-assets": "^4.55.0",
|
|
20
20
|
"@box/storybook-utils": "^0.13.8",
|
|
21
21
|
"react": "^18.3.0",
|