@box/combobox-with-api 1.42.33 → 1.42.35
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/dist/chunks/combobox-with-api-error.js +18 -0
- package/dist/chunks/combobox-with-api-pagination.js +168 -0
- package/dist/chunks/combobox-with-api-pagination2.js +229 -0
- package/dist/chunks/combobox-with-api-tree-view.js +423 -0
- package/dist/chunks/dynamic-loading-tree.js +299 -326
- package/dist/chunks/treeReducer.js +60 -78
- package/dist/esm/index.js +6 -16
- package/dist/esm/lib/components/combobox-with-api/combobox-with-api-container.js +47 -52
- package/dist/esm/lib/components/combobox-with-api/combobox-with-api-error.js +2 -26
- package/dist/esm/lib/components/combobox-with-api/combobox-with-api.js +16 -36
- package/dist/esm/lib/components/combobox-with-api/messages.js +6 -10
- package/dist/esm/lib/components/combobox-with-api-pagination/combobox-with-api-pagination.js +2 -214
- package/dist/esm/lib/components/combobox-with-api-pagination/index.js +3 -205
- package/dist/esm/lib/components/combobox-with-api-pagination/messages.js +31 -33
- package/dist/esm/lib/components/combobox-with-api-pagination/request.js +4 -6
- package/dist/esm/lib/components/combobox-with-api-pagination/use-async-list.js +113 -128
- package/dist/esm/lib/components/combobox-with-api-pagination/utils/is-abort-error.js +8 -10
- package/dist/esm/lib/components/combobox-with-api-pagination/utils/use-controllable-state.js +32 -34
- package/dist/esm/lib/components/combobox-with-api-pagination/utils/use-intersection-observer.js +72 -82
- package/dist/esm/lib/components/combobox-with-api-tree-view/combobox-with-api-tree-view.js +133 -174
- package/dist/esm/lib/components/combobox-with-api-tree-view/dynamic-loading-tree.js +2 -10
- package/dist/esm/lib/components/combobox-with-api-tree-view/index.js +3 -464
- package/dist/esm/lib/components/combobox-with-api-tree-view/tree-utils.js +17 -26
- package/dist/esm/lib/components/combobox-with-api-tree-view/treeReducer.js +2 -6
- package/dist/styles/combobox-with-api-error.css +1 -1
- package/dist/styles/combobox-with-api-pagination.css +1 -1
- package/dist/styles/dynamic-loading-tree.css +1 -1
- package/package.json +7 -7
package/dist/esm/lib/components/combobox-with-api-pagination/utils/use-intersection-observer.js
CHANGED
|
@@ -1,85 +1,75 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
n?.entryCallbacks.delete(e), n?.observer.unobserve(e);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
getObserver: a
|
|
43
|
-
};
|
|
1
|
+
import { useCallback as e, useRef as t, useState as n } from "react";
|
|
2
|
+
var r = "0px", i = [0];
|
|
3
|
+
function a() {
|
|
4
|
+
let e = /* @__PURE__ */ new Map();
|
|
5
|
+
function t({ root: t, rootMargin: n, threshold: r }) {
|
|
6
|
+
let i = e.get(t);
|
|
7
|
+
i || (i = /* @__PURE__ */ new Map(), e.set(t, i));
|
|
8
|
+
let a = JSON.stringify({
|
|
9
|
+
rootMargin: n,
|
|
10
|
+
threshold: r
|
|
11
|
+
}), o = i.get(a);
|
|
12
|
+
if (!o) {
|
|
13
|
+
let e = /* @__PURE__ */ new Map();
|
|
14
|
+
o = {
|
|
15
|
+
observer: new IntersectionObserver((t) => {
|
|
16
|
+
t.forEach((t) => {
|
|
17
|
+
e.get(t.target)?.(t);
|
|
18
|
+
});
|
|
19
|
+
}, {
|
|
20
|
+
root: t,
|
|
21
|
+
rootMargin: n,
|
|
22
|
+
threshold: r
|
|
23
|
+
}),
|
|
24
|
+
entryCallbacks: e
|
|
25
|
+
}, i.set(a, o);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
observe: (e, t) => {
|
|
29
|
+
o?.entryCallbacks.set(e, t), o?.observer.observe(e);
|
|
30
|
+
},
|
|
31
|
+
unobserve: (e) => {
|
|
32
|
+
o?.entryCallbacks.delete(e), o?.observer.unobserve(e);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return { getObserver: t };
|
|
44
37
|
}
|
|
45
|
-
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
38
|
+
var o = a();
|
|
39
|
+
function s(a) {
|
|
40
|
+
let s = a?.rootMargin ?? r, c = a?.threshold ?? i, l = t(null), u = t(null), d = t(null), [f, p] = n(), m = e(() => {
|
|
41
|
+
let e = l.current;
|
|
42
|
+
if (!e) {
|
|
43
|
+
p(void 0);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
let t = o.getObserver({
|
|
47
|
+
root: u.current,
|
|
48
|
+
rootMargin: s,
|
|
49
|
+
threshold: c
|
|
50
|
+
});
|
|
51
|
+
t.observe(e, (e) => {
|
|
52
|
+
p(e);
|
|
53
|
+
}), d.current = t;
|
|
54
|
+
}, [s, c]), h = e(() => {
|
|
55
|
+
let e = d.current, t = l.current;
|
|
56
|
+
t && e?.unobserve(t), d.current = null;
|
|
57
|
+
}, []);
|
|
58
|
+
return [e((e) => {
|
|
59
|
+
h(), l.current = e, m();
|
|
60
|
+
}, [m, h]), {
|
|
61
|
+
entry: f,
|
|
62
|
+
rootRef: e((e) => {
|
|
63
|
+
h(), u.current = e, m();
|
|
64
|
+
}, [m, h])
|
|
65
|
+
}];
|
|
73
66
|
}
|
|
74
|
-
function
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
67
|
+
function c(e) {
|
|
68
|
+
let [t, r] = s(e), i = !!r.entry?.isIntersecting, [a, o] = n(i);
|
|
69
|
+
return i && !a && o(!0), [t, {
|
|
70
|
+
...r,
|
|
71
|
+
isVisible: i,
|
|
72
|
+
wasEverVisible: a
|
|
73
|
+
}];
|
|
81
74
|
}
|
|
82
|
-
export {
|
|
83
|
-
C as createObserverCache,
|
|
84
|
-
w as useTrackVisibility
|
|
85
|
-
};
|
|
75
|
+
export { a as createObserverCache, c as useTrackVisibility };
|
|
@@ -1,175 +1,134 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}),
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
children: /* @__PURE__ */ o(se, {
|
|
134
|
-
onFocusVisible: (e) => {
|
|
135
|
-
m.current?.firstChild?.focus();
|
|
136
|
-
},
|
|
137
|
-
onKeyDown: (e) => {
|
|
138
|
-
if (e.key === "ArrowUp") {
|
|
139
|
-
const l = m.current?.firstChild;
|
|
140
|
-
document.activeElement === l && (l.blur(), V.current?.focus());
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
children: /* @__PURE__ */ o(ge, {
|
|
144
|
-
ref: m,
|
|
145
|
-
ariaLabel: H,
|
|
146
|
-
defaultFetcher: z,
|
|
147
|
-
levels: W,
|
|
148
|
-
loadingAriaLabel: F || g(O.loadingAriaLabel),
|
|
149
|
-
multiselect: C,
|
|
150
|
-
noResultMessage: j || g(O.noResults),
|
|
151
|
-
onSelect: (e) => {
|
|
152
|
-
const {
|
|
153
|
-
metadata: l
|
|
154
|
-
} = e.element;
|
|
155
|
-
let s = [];
|
|
156
|
-
e.isSelected ? (C && (s = a.filter((p) => p.value !== e.element.id)), s.push({
|
|
157
|
-
value: e.element.id,
|
|
158
|
-
displayValue: l.displayValue,
|
|
159
|
-
level: l.level,
|
|
160
|
-
selectable: l.selectable,
|
|
161
|
-
ancestors: l.ancestors
|
|
162
|
-
}), E && s.length > a.length && x(!1)) : s = a.filter((p) => p.value !== e.element.id), c(s), S("");
|
|
163
|
-
},
|
|
164
|
-
open: v,
|
|
165
|
-
searchInput: L.current,
|
|
166
|
-
selectableLevels: q,
|
|
167
|
-
selectedNodes: a.map((e) => e.value)
|
|
168
|
-
})
|
|
169
|
-
})
|
|
170
|
-
})]
|
|
171
|
-
});
|
|
1
|
+
import e from "../combobox-with-api-pagination/messages.js";
|
|
2
|
+
import { useControllableState as t } from "../combobox-with-api-pagination/utils/use-controllable-state.js";
|
|
3
|
+
import { n, t as r } from "../../../../chunks/dynamic-loading-tree.js";
|
|
4
|
+
import { Combobox as i, ComboboxCancel as a, ComboboxItem as ee, ComboboxPopover as o, ComboboxProvider as s, PopoverAnchor as c, useComboboxStore as l } from "@ariakit/react";
|
|
5
|
+
import { ChipsGroup as te, IconButton as ne, InputChip as re, useLabelable as ie } from "@box/blueprint-web";
|
|
6
|
+
import { Search as u, XMark as d } from "@box/blueprint-web-assets/icons/Fill";
|
|
7
|
+
import { IconIconOnLightSecondary as f, Size1 as p, Size6 as m } from "@box/blueprint-web-assets/tokens/tokens";
|
|
8
|
+
import h from "clsx";
|
|
9
|
+
import { forwardRef as g, useCallback as _, useId as v, useRef as y, useState as b } from "react";
|
|
10
|
+
import { useIntl as ae } from "react-intl";
|
|
11
|
+
import { jsx as x, jsxs as S } from "react/jsx-runtime";
|
|
12
|
+
var oe = () => /* @__PURE__ */ x(u, {
|
|
13
|
+
color: f,
|
|
14
|
+
height: m,
|
|
15
|
+
role: "presentation",
|
|
16
|
+
style: {
|
|
17
|
+
padding: p,
|
|
18
|
+
boxSizing: "border-box"
|
|
19
|
+
},
|
|
20
|
+
width: m
|
|
21
|
+
}), C = /* @__PURE__ */ g(function(u, f) {
|
|
22
|
+
let { className: p, closeOnSelection: m = !1, dataTargetId: g, defaultFetcher: C, defaultValue: se = [], disabled: w, hideLabel: T, initialOpen: E = !1, label: D, levels: O, loadingAriaLabel: k, multiselect: A = !1, noResultMessage: j, onValueChange: M, onOpenChange: N, placeholder: P, portalElement: F, selectableLevels: I, treeAriaLabel: L, value: R } = u, { formatMessage: z } = ae(), B = v(), [V, H] = b(E), [U, W] = t({
|
|
23
|
+
prop: R,
|
|
24
|
+
defaultProp: se,
|
|
25
|
+
onChange: M
|
|
26
|
+
}), [G, K] = b(""), q = y(null), [ce, J] = b(!1), le = _(() => J(!0), []), ue = _(() => J(!1), []), Y = y("");
|
|
27
|
+
ce || (Y.current = G.trimStart());
|
|
28
|
+
let X = l({
|
|
29
|
+
includesBaseElement: !0,
|
|
30
|
+
virtualFocus: !1,
|
|
31
|
+
value: G,
|
|
32
|
+
setValue: (e) => {
|
|
33
|
+
K(e);
|
|
34
|
+
},
|
|
35
|
+
open: V,
|
|
36
|
+
setOpen: (e) => {
|
|
37
|
+
H(e), N?.(e);
|
|
38
|
+
}
|
|
39
|
+
}), Z = U.length > 0, Q = U.length > 0, de = ie(D, B), $ = y(null);
|
|
40
|
+
return /* @__PURE__ */ S(s, {
|
|
41
|
+
store: X,
|
|
42
|
+
children: [/* @__PURE__ */ x(c, { children: /* @__PURE__ */ S("div", {
|
|
43
|
+
className: h(n.container, p, { [n.disabled]: w }),
|
|
44
|
+
children: [/* @__PURE__ */ x(de, {
|
|
45
|
+
className: h(n.label, { [n.hiddenLabel]: T }),
|
|
46
|
+
hideLabel: T
|
|
47
|
+
}), /* @__PURE__ */ x("div", { children: /* @__PURE__ */ S("div", {
|
|
48
|
+
className: h(n.comboboxContainer, {
|
|
49
|
+
[n.withChips]: Q,
|
|
50
|
+
[n.withComboboxButtons]: Z
|
|
51
|
+
}),
|
|
52
|
+
children: [Q && /* @__PURE__ */ x(te, { children: U.map((e) => /* @__PURE__ */ x(re, {
|
|
53
|
+
label: e.displayValue,
|
|
54
|
+
onDelete: () => {
|
|
55
|
+
w || W(U.filter((t) => t.value !== e.value));
|
|
56
|
+
},
|
|
57
|
+
tooltip: e.displayValue
|
|
58
|
+
}, e.value)) }), /* @__PURE__ */ S("div", {
|
|
59
|
+
className: n.textInputWrapper,
|
|
60
|
+
children: [/* @__PURE__ */ x(i, {
|
|
61
|
+
ref: q,
|
|
62
|
+
"aria-haspopup": "tree",
|
|
63
|
+
className: n.textInput,
|
|
64
|
+
"data-target-id": g,
|
|
65
|
+
disabled: w,
|
|
66
|
+
id: B,
|
|
67
|
+
onCompositionEnd: ue,
|
|
68
|
+
onCompositionStart: le,
|
|
69
|
+
placeholder: P,
|
|
70
|
+
store: X
|
|
71
|
+
}), /* @__PURE__ */ x("div", {
|
|
72
|
+
className: n.comboboxButtons,
|
|
73
|
+
children: Z ? /* @__PURE__ */ x(a, {
|
|
74
|
+
disabled: w,
|
|
75
|
+
onClick: () => {
|
|
76
|
+
W([]);
|
|
77
|
+
},
|
|
78
|
+
render: (e) => /* @__PURE__ */ x(ne, {
|
|
79
|
+
...e,
|
|
80
|
+
"aria-label": "Clear selection",
|
|
81
|
+
icon: d,
|
|
82
|
+
size: "x-small"
|
|
83
|
+
}),
|
|
84
|
+
store: X
|
|
85
|
+
}) : /* @__PURE__ */ x(oe, {})
|
|
86
|
+
})]
|
|
87
|
+
})]
|
|
88
|
+
}) })]
|
|
89
|
+
}) }), /* @__PURE__ */ x(o, {
|
|
90
|
+
"aria-labelledby": B,
|
|
91
|
+
className: n.popover,
|
|
92
|
+
fitViewport: !0,
|
|
93
|
+
gutter: 8,
|
|
94
|
+
portal: !0,
|
|
95
|
+
portalElement: F,
|
|
96
|
+
sameWidth: !0,
|
|
97
|
+
children: /* @__PURE__ */ x(ee, {
|
|
98
|
+
onFocusVisible: (e) => {
|
|
99
|
+
($.current?.firstChild)?.focus();
|
|
100
|
+
},
|
|
101
|
+
onKeyDown: (e) => {
|
|
102
|
+
if (e.key === "ArrowUp") {
|
|
103
|
+
let e = $.current?.firstChild;
|
|
104
|
+
document.activeElement === e && (e.blur(), q.current?.focus());
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
children: /* @__PURE__ */ x(r, {
|
|
108
|
+
ref: $,
|
|
109
|
+
ariaLabel: L,
|
|
110
|
+
defaultFetcher: C,
|
|
111
|
+
levels: O,
|
|
112
|
+
loadingAriaLabel: k || z(e.loadingAriaLabel),
|
|
113
|
+
multiselect: A,
|
|
114
|
+
noResultMessage: j || z(e.noResults),
|
|
115
|
+
onSelect: (e) => {
|
|
116
|
+
let { metadata: t } = e.element, n = [];
|
|
117
|
+
e.isSelected ? (A && (n = U.filter((t) => t.value !== e.element.id)), n.push({
|
|
118
|
+
value: e.element.id,
|
|
119
|
+
displayValue: t.displayValue,
|
|
120
|
+
level: t.level,
|
|
121
|
+
selectable: t.selectable,
|
|
122
|
+
ancestors: t.ancestors
|
|
123
|
+
}), m && n.length > U.length && H(!1)) : n = U.filter((t) => t.value !== e.element.id), W(n), K("");
|
|
124
|
+
},
|
|
125
|
+
open: V,
|
|
126
|
+
searchInput: Y.current,
|
|
127
|
+
selectableLevels: I,
|
|
128
|
+
selectedNodes: U.map((e) => e.value)
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
})]
|
|
132
|
+
});
|
|
172
133
|
});
|
|
173
|
-
export {
|
|
174
|
-
ze as ComboboxWithApiTreeView
|
|
175
|
-
};
|
|
134
|
+
export { C as ComboboxWithApiTreeView };
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
import "
|
|
2
|
-
|
|
3
|
-
import "react";
|
|
4
|
-
import "./tree-utils.js";
|
|
5
|
-
import "../../../../chunks/treeReducer.js";
|
|
6
|
-
import { D as n } from "../../../../chunks/dynamic-loading-tree.js";
|
|
7
|
-
import "react/jsx-runtime";
|
|
8
|
-
export {
|
|
9
|
-
n as DynamicLoadingTree
|
|
10
|
-
};
|
|
1
|
+
import { t as e } from "../../../../chunks/dynamic-loading-tree.js";
|
|
2
|
+
export { e as DynamicLoadingTree };
|