@box/combobox-with-api 0.44.4 → 0.44.8
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,313 +1,319 @@
|
|
|
1
|
-
import { LoadingIndicator as
|
|
2
|
-
import { InlineError as
|
|
3
|
-
import { useReducer as
|
|
4
|
-
import {
|
|
5
|
-
import { t as
|
|
6
|
-
import { jsx as
|
|
7
|
-
import '../styles/dynamic-loading-tree.css';const
|
|
8
|
-
container:
|
|
9
|
-
disabled:
|
|
10
|
-
label:
|
|
11
|
-
hiddenLabel:
|
|
12
|
-
comboboxContainer:
|
|
13
|
-
withComboboxButtons:
|
|
14
|
-
error:
|
|
15
|
-
textInputWrapper:
|
|
16
|
-
textInput:
|
|
17
|
-
errorIcon:
|
|
18
|
-
comboboxButtons:
|
|
19
|
-
withChips:
|
|
20
|
-
inlineError:
|
|
21
|
-
popover:
|
|
22
|
-
option:
|
|
23
|
-
indicator:
|
|
24
|
-
indicatorIcon:
|
|
25
|
-
optionWithIndicator:
|
|
26
|
-
loadingIndicator:
|
|
27
|
-
noResultOption:
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
import { LoadingIndicator as Y } from "@box/blueprint-web";
|
|
2
|
+
import { InlineError as Z, Tree as $ } from "@box/tree";
|
|
3
|
+
import { forwardRef as F, useReducer as P, useState as A, useMemo as ee, useCallback as p, useEffect as j } from "react";
|
|
4
|
+
import { RootTreeNode as u, hasValidLevel as te, getServiceNode as D } from "../esm/lib/components/combobox-with-api-tree-view/tree-utils.js";
|
|
5
|
+
import { t as ae, i as oe, A as r } from "./treeReducer.js";
|
|
6
|
+
import { jsx as v, jsxs as ne } from "react/jsx-runtime";
|
|
7
|
+
import '../styles/dynamic-loading-tree.css';const le = "_container_z81ug_1", se = "_disabled_z81ug_12", re = "_label_z81ug_15", ie = "_hiddenLabel_z81ug_27", de = "_comboboxContainer_z81ug_30", ce = "_withComboboxButtons_z81ug_46", ue = "_error_z81ug_54", me = "_textInputWrapper_z81ug_62", pe = "_textInput_z81ug_62", _e = "_errorIcon_z81ug_84", be = "_comboboxButtons_z81ug_87", ge = "_withChips_z81ug_94", ye = "_inlineError_z81ug_104", he = "_popover_z81ug_108", ve = "_option_z81ug_134", fe = "_indicator_z81ug_157", Ie = "_indicatorIcon_z81ug_166", Se = "_optionWithIndicator_z81ug_169", Ee = "_loadingIndicator_z81ug_172", Oe = "_noResultOption_z81ug_175", C = {
|
|
8
|
+
container: le,
|
|
9
|
+
disabled: se,
|
|
10
|
+
label: re,
|
|
11
|
+
hiddenLabel: ie,
|
|
12
|
+
comboboxContainer: de,
|
|
13
|
+
withComboboxButtons: ce,
|
|
14
|
+
error: ue,
|
|
15
|
+
textInputWrapper: me,
|
|
16
|
+
textInput: pe,
|
|
17
|
+
errorIcon: _e,
|
|
18
|
+
comboboxButtons: be,
|
|
19
|
+
withChips: ge,
|
|
20
|
+
inlineError: ye,
|
|
21
|
+
popover: he,
|
|
22
|
+
option: ve,
|
|
23
|
+
indicator: fe,
|
|
24
|
+
indicatorIcon: Ie,
|
|
25
|
+
optionWithIndicator: Se,
|
|
26
|
+
loadingIndicator: Ee,
|
|
27
|
+
noResultOption: Oe
|
|
28
|
+
}, Re = (l) => {
|
|
29
|
+
const i = [...l.children], {
|
|
30
|
+
metadata: d
|
|
31
|
+
} = l;
|
|
32
|
+
return {
|
|
33
|
+
...l,
|
|
34
|
+
children: i,
|
|
35
|
+
metadata: {
|
|
36
|
+
...l.metadata,
|
|
37
|
+
variant: d.variant,
|
|
38
|
+
isLoading: l.status === "loading" && !l.children.length,
|
|
39
|
+
labelName: d.labelName || "",
|
|
40
|
+
labelValue: d.labelValue || ""
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}, Ne = (l, i) => {
|
|
44
|
+
let d;
|
|
45
|
+
return l.children.length && l.status === "loading" && (d = D(i.id, i.metadata.displayValue, "loading")), l.status === "error" && (d = D(i.id, i.metadata.displayValue, "reload")), l.status === "success" && l.marker && (d = D(i.id, i.metadata.displayValue, "loadMore")), d;
|
|
46
|
+
}, Le = /* @__PURE__ */ F(({
|
|
47
|
+
ariaLabel: l,
|
|
48
|
+
onSelect: i,
|
|
49
|
+
selectedNodes: d,
|
|
50
|
+
defaultFetcher: _,
|
|
51
|
+
levels: R,
|
|
52
|
+
selectableLevels: f,
|
|
35
53
|
multiselect: M,
|
|
36
|
-
open:
|
|
37
|
-
searchInput:
|
|
54
|
+
open: L,
|
|
55
|
+
searchInput: m,
|
|
38
56
|
noResultMessage: U,
|
|
39
57
|
loadingAriaLabel: q
|
|
40
|
-
}) => {
|
|
41
|
-
const [
|
|
58
|
+
}, G) => {
|
|
59
|
+
const [g, n] = P(ae, oe), [h, H] = A({
|
|
42
60
|
nodes: [],
|
|
43
61
|
selectedIds: []
|
|
44
|
-
}), [
|
|
45
|
-
const
|
|
46
|
-
return [...Object.values(
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
labelName: o.labelName || "",
|
|
57
|
-
labelValue: o.labelValue || ""
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
let d;
|
|
61
|
-
return e.children.length && e.status === "loading" && (d = R(l.id, l.metadata.displayValue, "loading")), e.status === "error" && (d = R(l.id, l.metadata.displayValue, "reload")), e.status === "success" && e.marker && (d = R(l.id, l.metadata.displayValue, "loadMore")), d && (t.push(d), l.children.push(d.id)), l;
|
|
62
|
-
}), ...t];
|
|
63
|
-
}, [b]), C = p((a) => {
|
|
64
|
-
var r;
|
|
65
|
-
const t = (r = a.ancestors) == null ? void 0 : r.find((o) => o.level === a.level - 1), i = S.find((o) => o.level === a.level);
|
|
66
|
-
return a.level === 1 || u === "" ? a.displayValue : {
|
|
67
|
-
labelName: i.displayName,
|
|
68
|
-
labelValue: t.displayName
|
|
62
|
+
}), [N, b] = A(!1), [I, S] = A(!1), E = ee(() => Math.max(...f), [f]), k = p((e = g) => {
|
|
63
|
+
const a = [];
|
|
64
|
+
return [...Object.values(e).map((t) => {
|
|
65
|
+
const s = Re(t), o = Ne(t, s);
|
|
66
|
+
return o && (a.push(o), s.children.push(o.id)), s;
|
|
67
|
+
}), ...a];
|
|
68
|
+
}, [g]), V = p((e) => {
|
|
69
|
+
var s;
|
|
70
|
+
const a = (s = e.ancestors) == null ? void 0 : s.find((o) => o.level === e.level - 1), c = R.find((o) => o.level === e.level);
|
|
71
|
+
return e.level === 1 || m === "" ? e.displayValue : {
|
|
72
|
+
labelName: c.displayName,
|
|
73
|
+
labelValue: a.displayName
|
|
69
74
|
};
|
|
70
|
-
}, [
|
|
71
|
-
id:
|
|
72
|
-
name:
|
|
73
|
-
parent:
|
|
74
|
-
isBranch:
|
|
75
|
+
}, [R, m]), y = p((e) => ({
|
|
76
|
+
id: e.value,
|
|
77
|
+
name: e.displayValue,
|
|
78
|
+
parent: u.id,
|
|
79
|
+
isBranch: e.level !== E,
|
|
75
80
|
children: [],
|
|
76
81
|
metadata: {
|
|
77
82
|
variant: "content",
|
|
78
|
-
displayValue:
|
|
79
|
-
level:
|
|
80
|
-
selectable:
|
|
81
|
-
marker:
|
|
82
|
-
ancestors:
|
|
83
|
+
displayValue: e.displayValue,
|
|
84
|
+
level: e.level,
|
|
85
|
+
selectable: e.selectable,
|
|
86
|
+
marker: e.marker,
|
|
87
|
+
ancestors: e.ancestors
|
|
83
88
|
}
|
|
84
|
-
}), [
|
|
89
|
+
}), [E]), x = p((e, a) => {
|
|
85
90
|
n({
|
|
86
|
-
type:
|
|
91
|
+
type: r.RESET,
|
|
87
92
|
payload: {
|
|
88
|
-
id:
|
|
93
|
+
id: u.id,
|
|
89
94
|
items: []
|
|
90
95
|
}
|
|
91
96
|
}), n({
|
|
92
|
-
type:
|
|
97
|
+
type: r.LOAD_SUCCESS,
|
|
93
98
|
payload: {
|
|
94
|
-
id:
|
|
95
|
-
items:
|
|
96
|
-
marker:
|
|
99
|
+
id: u.id,
|
|
100
|
+
items: e,
|
|
101
|
+
marker: a
|
|
97
102
|
}
|
|
98
|
-
}),
|
|
99
|
-
}, [n,
|
|
103
|
+
}), b(!1);
|
|
104
|
+
}, [n, b]), T = p(() => {
|
|
100
105
|
n({
|
|
101
|
-
type:
|
|
106
|
+
type: r.LOAD_ERROR,
|
|
102
107
|
payload: {
|
|
103
|
-
id:
|
|
108
|
+
id: u.id
|
|
104
109
|
}
|
|
105
|
-
}),
|
|
106
|
-
}, [n,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
nodes:
|
|
110
|
-
selectedIds:
|
|
110
|
+
}), b(!1), S(!0);
|
|
111
|
+
}, [n, b, S]);
|
|
112
|
+
j(() => {
|
|
113
|
+
H({
|
|
114
|
+
nodes: k(g),
|
|
115
|
+
selectedIds: d
|
|
111
116
|
});
|
|
112
|
-
}, [
|
|
113
|
-
if (!
|
|
117
|
+
}, [k, d, g, I]), j(() => {
|
|
118
|
+
if (!L)
|
|
114
119
|
return;
|
|
115
120
|
const {
|
|
116
|
-
signal:
|
|
121
|
+
signal: e
|
|
117
122
|
} = new AbortController();
|
|
118
|
-
|
|
119
|
-
type:
|
|
123
|
+
b(!0), S(!1), m ? (n({
|
|
124
|
+
type: r.RESET,
|
|
120
125
|
payload: {
|
|
121
|
-
id:
|
|
126
|
+
id: u.id,
|
|
122
127
|
items: []
|
|
123
128
|
}
|
|
124
|
-
}),
|
|
125
|
-
signal:
|
|
129
|
+
}), _({
|
|
130
|
+
signal: e,
|
|
126
131
|
marker: null,
|
|
127
|
-
searchInput:
|
|
132
|
+
searchInput: m,
|
|
128
133
|
level: null,
|
|
129
134
|
onlySelectableOptions: !1,
|
|
130
135
|
ancestorId: null
|
|
131
|
-
}).then((
|
|
132
|
-
const
|
|
136
|
+
}).then((a) => {
|
|
137
|
+
const c = a.options.filter((t) => t.selectable).map((t) => {
|
|
133
138
|
const {
|
|
134
|
-
labelName:
|
|
139
|
+
labelName: s,
|
|
135
140
|
labelValue: o
|
|
136
|
-
} =
|
|
141
|
+
} = V(t);
|
|
137
142
|
return {
|
|
138
|
-
id:
|
|
139
|
-
name:
|
|
140
|
-
parent:
|
|
141
|
-
isBranch:
|
|
143
|
+
id: t.value,
|
|
144
|
+
name: t.displayValue,
|
|
145
|
+
parent: u.id,
|
|
146
|
+
isBranch: t.level < E,
|
|
142
147
|
children: [],
|
|
143
148
|
metadata: {
|
|
144
|
-
variant:
|
|
145
|
-
displayValue:
|
|
146
|
-
level:
|
|
147
|
-
selectable:
|
|
148
|
-
ancestors:
|
|
149
|
-
labelName:
|
|
149
|
+
variant: t.level === 1 ? "content" : "labeled",
|
|
150
|
+
displayValue: t.displayValue,
|
|
151
|
+
level: t.level,
|
|
152
|
+
selectable: t.selectable,
|
|
153
|
+
ancestors: t.ancestors,
|
|
154
|
+
labelName: s,
|
|
150
155
|
labelValue: o
|
|
151
156
|
}
|
|
152
157
|
};
|
|
153
158
|
});
|
|
154
|
-
|
|
159
|
+
x(c, a.marker);
|
|
155
160
|
}).catch(() => {
|
|
156
|
-
|
|
161
|
+
T();
|
|
157
162
|
})) : (n({
|
|
158
|
-
type:
|
|
163
|
+
type: r.RESET,
|
|
159
164
|
payload: {
|
|
160
|
-
id:
|
|
165
|
+
id: u.id,
|
|
161
166
|
items: []
|
|
162
167
|
}
|
|
163
168
|
}), n({
|
|
164
|
-
type:
|
|
169
|
+
type: r.LOAD_DATA,
|
|
165
170
|
payload: {
|
|
166
|
-
id:
|
|
171
|
+
id: u.id
|
|
167
172
|
}
|
|
168
|
-
}),
|
|
169
|
-
signal:
|
|
173
|
+
}), _({
|
|
174
|
+
signal: e,
|
|
170
175
|
marker: null,
|
|
171
176
|
searchInput: "",
|
|
172
177
|
level: 1,
|
|
173
178
|
onlySelectableOptions: !1,
|
|
174
179
|
ancestorId: null
|
|
175
|
-
}).then((
|
|
176
|
-
const
|
|
177
|
-
|
|
180
|
+
}).then((a) => {
|
|
181
|
+
const c = a.options.map(y);
|
|
182
|
+
x(c, a.marker);
|
|
178
183
|
}).catch(() => {
|
|
179
|
-
|
|
184
|
+
T();
|
|
180
185
|
}));
|
|
181
|
-
}, [
|
|
182
|
-
const
|
|
186
|
+
}, [_, y, L, m, R, E, V, x, T]);
|
|
187
|
+
const J = p((e) => {
|
|
183
188
|
const {
|
|
184
|
-
isExpanded:
|
|
185
|
-
isDisabled:
|
|
186
|
-
element:
|
|
187
|
-
} =
|
|
188
|
-
if (!
|
|
189
|
+
isExpanded: a,
|
|
190
|
+
isDisabled: c,
|
|
191
|
+
element: t
|
|
192
|
+
} = e;
|
|
193
|
+
if (!a || c) {
|
|
189
194
|
n({
|
|
190
|
-
type:
|
|
195
|
+
type: r.RESET,
|
|
191
196
|
payload: {
|
|
192
|
-
id:
|
|
197
|
+
id: t.id,
|
|
193
198
|
items: []
|
|
194
199
|
}
|
|
195
200
|
});
|
|
196
201
|
return;
|
|
197
202
|
}
|
|
198
203
|
const {
|
|
199
|
-
level:
|
|
200
|
-
} =
|
|
204
|
+
level: s
|
|
205
|
+
} = t.metadata, {
|
|
201
206
|
id: o,
|
|
202
|
-
marker:
|
|
203
|
-
} =
|
|
204
|
-
signal:
|
|
207
|
+
marker: O
|
|
208
|
+
} = t, {
|
|
209
|
+
signal: z
|
|
205
210
|
} = new AbortController();
|
|
206
211
|
n({
|
|
207
|
-
type:
|
|
212
|
+
type: r.LOAD_DATA,
|
|
208
213
|
payload: {
|
|
209
214
|
id: o
|
|
210
215
|
}
|
|
211
|
-
}),
|
|
212
|
-
signal:
|
|
213
|
-
marker:
|
|
216
|
+
}), _({
|
|
217
|
+
signal: z,
|
|
218
|
+
marker: O,
|
|
214
219
|
searchInput: "",
|
|
215
|
-
level:
|
|
220
|
+
level: s + 1,
|
|
216
221
|
ancestorId: o,
|
|
217
222
|
onlySelectableOptions: !1
|
|
218
|
-
}).then((
|
|
219
|
-
const
|
|
223
|
+
}).then((B) => {
|
|
224
|
+
const X = B.options.map((W) => (t.children.push(W.value), y(W)));
|
|
220
225
|
n({
|
|
221
|
-
type:
|
|
226
|
+
type: r.LOAD_SUCCESS,
|
|
222
227
|
payload: {
|
|
223
228
|
id: o,
|
|
224
|
-
items:
|
|
225
|
-
marker:
|
|
229
|
+
items: X,
|
|
230
|
+
marker: B.marker
|
|
226
231
|
}
|
|
227
232
|
});
|
|
228
233
|
}).catch(() => {
|
|
229
234
|
n({
|
|
230
|
-
type:
|
|
235
|
+
type: r.LOAD_ERROR,
|
|
231
236
|
payload: {
|
|
232
237
|
id: o
|
|
233
238
|
}
|
|
234
239
|
});
|
|
235
240
|
});
|
|
236
|
-
}, [
|
|
237
|
-
|
|
238
|
-
const
|
|
239
|
-
level:
|
|
240
|
-
} =
|
|
241
|
-
id:
|
|
242
|
-
marker:
|
|
243
|
-
} =
|
|
241
|
+
}, [_, y]), w = p((e) => {
|
|
242
|
+
I && (S(!1), b(!0));
|
|
243
|
+
const a = g[e], {
|
|
244
|
+
level: c
|
|
245
|
+
} = a.metadata, {
|
|
246
|
+
id: t,
|
|
247
|
+
marker: s
|
|
248
|
+
} = a, {
|
|
244
249
|
signal: o
|
|
245
250
|
} = new AbortController();
|
|
246
251
|
n({
|
|
247
|
-
type:
|
|
252
|
+
type: r.LOAD_DATA,
|
|
248
253
|
payload: {
|
|
249
|
-
id:
|
|
254
|
+
id: t
|
|
250
255
|
}
|
|
251
|
-
}),
|
|
256
|
+
}), _({
|
|
252
257
|
signal: o,
|
|
253
|
-
marker:
|
|
254
|
-
searchInput:
|
|
255
|
-
level:
|
|
256
|
-
ancestorId:
|
|
258
|
+
marker: s,
|
|
259
|
+
searchInput: m,
|
|
260
|
+
level: m === "" ? c + 1 : null,
|
|
261
|
+
ancestorId: t !== u.id ? t.toString() : null,
|
|
257
262
|
onlySelectableOptions: !1
|
|
258
|
-
}).then((
|
|
259
|
-
const
|
|
263
|
+
}).then((O) => {
|
|
264
|
+
const z = O.options.map(y);
|
|
260
265
|
n({
|
|
261
|
-
type:
|
|
266
|
+
type: r.LOAD_SUCCESS,
|
|
262
267
|
payload: {
|
|
263
|
-
id:
|
|
264
|
-
items:
|
|
265
|
-
marker:
|
|
268
|
+
id: t,
|
|
269
|
+
items: z,
|
|
270
|
+
marker: O.marker
|
|
266
271
|
}
|
|
267
|
-
}),
|
|
272
|
+
}), b(!1);
|
|
268
273
|
}).catch(() => {
|
|
269
274
|
n({
|
|
270
|
-
type:
|
|
275
|
+
type: r.LOAD_ERROR,
|
|
271
276
|
payload: {
|
|
272
|
-
id:
|
|
273
|
-
marker:
|
|
277
|
+
id: t,
|
|
278
|
+
marker: s
|
|
274
279
|
}
|
|
275
280
|
});
|
|
276
281
|
});
|
|
277
|
-
}, [
|
|
282
|
+
}, [_, I, y, m, g]), K = h.nodes.length === 0 || h.nodes[0].children.length === 0 && h.nodes[0].id === u.id, Q = p((e) => {
|
|
278
283
|
const {
|
|
279
|
-
metadata:
|
|
280
|
-
} =
|
|
281
|
-
|
|
282
|
-
}, [
|
|
283
|
-
return
|
|
284
|
+
metadata: a
|
|
285
|
+
} = e.element;
|
|
286
|
+
te(a) && f.includes(a.level) ? i(e) : (e.isSelected = !1, e.treeState.selectedIds.delete(e.element.id));
|
|
287
|
+
}, [f, i]);
|
|
288
|
+
return I ? /* @__PURE__ */ v(Z, {
|
|
284
289
|
onReload: () => {
|
|
285
|
-
|
|
290
|
+
w("root");
|
|
286
291
|
}
|
|
287
|
-
}) : /* @__PURE__ */
|
|
288
|
-
children: [
|
|
289
|
-
className:
|
|
290
|
-
children: /* @__PURE__ */
|
|
292
|
+
}) : /* @__PURE__ */ ne("div", {
|
|
293
|
+
children: [N && /* @__PURE__ */ v("div", {
|
|
294
|
+
className: C.noResultOption,
|
|
295
|
+
children: /* @__PURE__ */ v(Y, {
|
|
291
296
|
"aria-label": q,
|
|
292
|
-
className:
|
|
297
|
+
className: C.loadingIndicator
|
|
293
298
|
})
|
|
294
|
-
}),
|
|
295
|
-
className:
|
|
299
|
+
}), K && !N ? /* @__PURE__ */ v("div", {
|
|
300
|
+
className: C.noResultOption,
|
|
296
301
|
children: U
|
|
297
|
-
}) : !
|
|
298
|
-
|
|
299
|
-
|
|
302
|
+
}) : !N && /* @__PURE__ */ v($, {
|
|
303
|
+
ref: G,
|
|
304
|
+
"aria-label": l,
|
|
305
|
+
data: h.nodes,
|
|
300
306
|
multiSelect: M,
|
|
301
|
-
onExpand:
|
|
302
|
-
onLoadData:
|
|
303
|
-
onNodeSelect:
|
|
304
|
-
selectedIds:
|
|
307
|
+
onExpand: J,
|
|
308
|
+
onLoadData: w,
|
|
309
|
+
onNodeSelect: Q,
|
|
310
|
+
selectedIds: h.selectedIds,
|
|
305
311
|
size: "large",
|
|
306
312
|
togglableSelect: !0
|
|
307
313
|
})]
|
|
308
314
|
});
|
|
309
|
-
};
|
|
315
|
+
});
|
|
310
316
|
export {
|
|
311
|
-
|
|
312
|
-
|
|
317
|
+
Le as D,
|
|
318
|
+
C as s
|
|
313
319
|
};
|
|
@@ -1,147 +1,162 @@
|
|
|
1
|
-
import { useComboboxStore as X, ComboboxProvider as q, PopoverAnchor as H, Combobox as J, ComboboxCancel as
|
|
2
|
-
import { useLabelable as
|
|
3
|
-
import { XMark as
|
|
4
|
-
import { IconIconOnLightSecondary as
|
|
5
|
-
import
|
|
6
|
-
import { forwardRef as
|
|
7
|
-
import { useIntl as
|
|
8
|
-
import
|
|
9
|
-
import { useControllableState as
|
|
10
|
-
import { s as
|
|
11
|
-
import { jsxs as
|
|
12
|
-
const
|
|
13
|
-
color:
|
|
14
|
-
height:
|
|
1
|
+
import { useComboboxStore as X, ComboboxProvider as q, PopoverAnchor as H, Combobox as J, ComboboxCancel as Q, ComboboxPopover as Y, ComboboxItem as Z } from "@ariakit/react";
|
|
2
|
+
import { useLabelable as _, ChipsGroup as $, InputChip as ee, IconButton as oe } from "@box/blueprint-web";
|
|
3
|
+
import { XMark as te, Search as le } from "@box/blueprint-web-assets/icons/Fill";
|
|
4
|
+
import { IconIconOnLightSecondary as ae, Size6 as V, Size1 as se } from "@box/blueprint-web-assets/tokens/tokens";
|
|
5
|
+
import b from "clsx";
|
|
6
|
+
import { forwardRef as re, useId as ne, useState as w, useRef as S, useCallback as ie } from "react";
|
|
7
|
+
import { useIntl as ce } from "react-intl";
|
|
8
|
+
import L from "../combobox-with-api-pagination/messages.js";
|
|
9
|
+
import { useControllableState as ue } from "../combobox-with-api-pagination/utils/use-controllable-state.js";
|
|
10
|
+
import { s as a, D as me } from "../../../../chunks/dynamic-loading-tree.js";
|
|
11
|
+
import { jsxs as n, jsx as t } from "react/jsx-runtime";
|
|
12
|
+
const pe = () => /* @__PURE__ */ t(le, {
|
|
13
|
+
color: ae,
|
|
14
|
+
height: V,
|
|
15
15
|
role: "presentation",
|
|
16
16
|
style: {
|
|
17
|
-
padding:
|
|
17
|
+
padding: se,
|
|
18
18
|
boxSizing: "border-box"
|
|
19
19
|
},
|
|
20
|
-
width:
|
|
21
|
-
}),
|
|
20
|
+
width: V
|
|
21
|
+
}), ye = /* @__PURE__ */ re(function(y, de) {
|
|
22
22
|
const {
|
|
23
|
-
className:
|
|
24
|
-
dataTargetId:
|
|
25
|
-
defaultFetcher:
|
|
26
|
-
defaultValue:
|
|
27
|
-
disabled:
|
|
23
|
+
className: N,
|
|
24
|
+
dataTargetId: A,
|
|
25
|
+
defaultFetcher: R,
|
|
26
|
+
defaultValue: B = [],
|
|
27
|
+
disabled: k,
|
|
28
28
|
hideLabel: d,
|
|
29
|
-
label:
|
|
30
|
-
levels:
|
|
31
|
-
loadingAriaLabel:
|
|
32
|
-
multiselect:
|
|
33
|
-
noResultMessage:
|
|
34
|
-
onValueChange:
|
|
35
|
-
placeholder:
|
|
36
|
-
portalElement:
|
|
37
|
-
selectableLevels:
|
|
38
|
-
treeAriaLabel:
|
|
39
|
-
value:
|
|
40
|
-
} =
|
|
41
|
-
formatMessage:
|
|
42
|
-
} =
|
|
43
|
-
prop:
|
|
44
|
-
defaultProp:
|
|
45
|
-
onChange:
|
|
46
|
-
}), [x,
|
|
47
|
-
|
|
48
|
-
}, [
|
|
29
|
+
label: z,
|
|
30
|
+
levels: D,
|
|
31
|
+
loadingAriaLabel: M,
|
|
32
|
+
multiselect: h = !1,
|
|
33
|
+
noResultMessage: O,
|
|
34
|
+
onValueChange: P,
|
|
35
|
+
placeholder: T,
|
|
36
|
+
portalElement: W,
|
|
37
|
+
selectableLevels: E,
|
|
38
|
+
treeAriaLabel: F,
|
|
39
|
+
value: j
|
|
40
|
+
} = y, {
|
|
41
|
+
formatMessage: f
|
|
42
|
+
} = ce(), i = ne(), [C, G] = w(!1), [s, c] = ue({
|
|
43
|
+
prop: j,
|
|
44
|
+
defaultProp: B,
|
|
45
|
+
onChange: P
|
|
46
|
+
}), [x, u] = w(""), v = S(null), K = ie((e) => {
|
|
47
|
+
u(e);
|
|
48
|
+
}, [u]), m = X({
|
|
49
49
|
includesBaseElement: !0,
|
|
50
50
|
virtualFocus: !1,
|
|
51
51
|
value: x,
|
|
52
|
-
setValue:
|
|
53
|
-
open:
|
|
54
|
-
setOpen:
|
|
55
|
-
}),
|
|
56
|
-
return /* @__PURE__ */
|
|
57
|
-
store:
|
|
58
|
-
children: [/* @__PURE__ */
|
|
59
|
-
children: /* @__PURE__ */
|
|
60
|
-
className:
|
|
61
|
-
children: [/* @__PURE__ */
|
|
62
|
-
className:
|
|
63
|
-
[
|
|
52
|
+
setValue: K,
|
|
53
|
+
open: C,
|
|
54
|
+
setOpen: G
|
|
55
|
+
}), g = s.length > 0, I = s.length > 0, U = _(z, i), p = S(null);
|
|
56
|
+
return /* @__PURE__ */ n(q, {
|
|
57
|
+
store: m,
|
|
58
|
+
children: [/* @__PURE__ */ t(H, {
|
|
59
|
+
children: /* @__PURE__ */ n("div", {
|
|
60
|
+
className: b(a.container, N),
|
|
61
|
+
children: [/* @__PURE__ */ t(U, {
|
|
62
|
+
className: b(a.label, {
|
|
63
|
+
[a.hiddenLabel]: d
|
|
64
64
|
}),
|
|
65
65
|
hideLabel: d
|
|
66
|
-
}), /* @__PURE__ */
|
|
67
|
-
className:
|
|
68
|
-
[
|
|
69
|
-
[
|
|
66
|
+
}), /* @__PURE__ */ n("div", {
|
|
67
|
+
className: b(a.comboboxContainer, {
|
|
68
|
+
[a.withChips]: I,
|
|
69
|
+
[a.withComboboxButtons]: g
|
|
70
70
|
}),
|
|
71
|
-
children: [
|
|
72
|
-
children:
|
|
71
|
+
children: [I && /* @__PURE__ */ t($, {
|
|
72
|
+
children: s.map((e) => /* @__PURE__ */ t(ee, {
|
|
73
73
|
label: e.displayValue,
|
|
74
74
|
onDelete: () => {
|
|
75
|
-
const
|
|
76
|
-
|
|
75
|
+
const o = s.filter((l) => l.value !== e.value);
|
|
76
|
+
c(o);
|
|
77
77
|
},
|
|
78
78
|
tooltip: e.displayValue
|
|
79
79
|
}, e.value))
|
|
80
|
-
}), /* @__PURE__ */
|
|
81
|
-
className:
|
|
82
|
-
children: [/* @__PURE__ */
|
|
83
|
-
ref:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
80
|
+
}), /* @__PURE__ */ n("div", {
|
|
81
|
+
className: a.textInputWrapper,
|
|
82
|
+
children: [/* @__PURE__ */ t(J, {
|
|
83
|
+
ref: v,
|
|
84
|
+
"aria-haspopup": "tree",
|
|
85
|
+
className: a.textInput,
|
|
86
|
+
"data-target-id": A,
|
|
87
|
+
disabled: k,
|
|
88
|
+
id: i,
|
|
89
|
+
placeholder: T,
|
|
90
|
+
store: m
|
|
91
|
+
}), /* @__PURE__ */ t("div", {
|
|
92
|
+
className: a.comboboxButtons,
|
|
93
|
+
children: g ? /* @__PURE__ */ t(Q, {
|
|
93
94
|
onClick: () => {
|
|
94
|
-
|
|
95
|
+
c([]);
|
|
95
96
|
},
|
|
96
|
-
render: (e) => /* @__PURE__ */
|
|
97
|
+
render: (e) => /* @__PURE__ */ t(oe, {
|
|
97
98
|
...e,
|
|
98
99
|
"aria-label": "Clear selection",
|
|
99
|
-
icon:
|
|
100
|
+
icon: te,
|
|
100
101
|
size: "x-small"
|
|
101
102
|
}),
|
|
102
|
-
store:
|
|
103
|
-
}) : /* @__PURE__ */
|
|
103
|
+
store: m
|
|
104
|
+
}) : /* @__PURE__ */ t(pe, {})
|
|
104
105
|
})]
|
|
105
106
|
})]
|
|
106
107
|
})]
|
|
107
108
|
})
|
|
108
|
-
}), /* @__PURE__ */
|
|
109
|
-
"aria-labelledby":
|
|
110
|
-
className:
|
|
109
|
+
}), /* @__PURE__ */ t(Y, {
|
|
110
|
+
"aria-labelledby": i,
|
|
111
|
+
className: a.popover,
|
|
111
112
|
fitViewport: !0,
|
|
112
113
|
gutter: 8,
|
|
113
|
-
modal: !0,
|
|
114
114
|
portal: !0,
|
|
115
|
-
portalElement:
|
|
115
|
+
portalElement: W,
|
|
116
116
|
sameWidth: !0,
|
|
117
|
-
children: /* @__PURE__ */
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
multiselect: b,
|
|
123
|
-
noResultMessage: M || h(V.noResults),
|
|
124
|
-
onSelect: (e) => {
|
|
125
|
-
const {
|
|
126
|
-
metadata: a
|
|
127
|
-
} = e.element;
|
|
128
|
-
let s = [];
|
|
129
|
-
e.isSelected ? (b && (s = l.filter((m) => m.value !== e.element.id)), s.push({
|
|
130
|
-
value: e.element.id,
|
|
131
|
-
displayValue: a.displayValue,
|
|
132
|
-
level: a.level,
|
|
133
|
-
selectable: a.selectable,
|
|
134
|
-
ancestors: a.ancestors
|
|
135
|
-
})) : s = l.filter((m) => m.value !== e.element.id), i(s), c("");
|
|
117
|
+
children: /* @__PURE__ */ t(Z, {
|
|
118
|
+
onFocusVisible: (e) => {
|
|
119
|
+
var l;
|
|
120
|
+
const o = (l = p.current) == null ? void 0 : l.firstChild;
|
|
121
|
+
o == null || o.focus();
|
|
136
122
|
},
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
123
|
+
onKeyDown: (e) => {
|
|
124
|
+
var o, l;
|
|
125
|
+
if (e.key === "ArrowUp") {
|
|
126
|
+
const r = (o = p.current) == null ? void 0 : o.firstChild;
|
|
127
|
+
document.activeElement === r && (r.blur(), (l = v.current) == null || l.focus());
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
children: /* @__PURE__ */ t(me, {
|
|
131
|
+
ref: p,
|
|
132
|
+
ariaLabel: F,
|
|
133
|
+
defaultFetcher: R,
|
|
134
|
+
levels: D,
|
|
135
|
+
loadingAriaLabel: M || f(L.loadingAriaLabel),
|
|
136
|
+
multiselect: h,
|
|
137
|
+
noResultMessage: O || f(L.noResults),
|
|
138
|
+
onSelect: (e) => {
|
|
139
|
+
const {
|
|
140
|
+
metadata: o
|
|
141
|
+
} = e.element;
|
|
142
|
+
let l = [];
|
|
143
|
+
e.isSelected ? (h && (l = s.filter((r) => r.value !== e.element.id)), l.push({
|
|
144
|
+
value: e.element.id,
|
|
145
|
+
displayValue: o.displayValue,
|
|
146
|
+
level: o.level,
|
|
147
|
+
selectable: o.selectable,
|
|
148
|
+
ancestors: o.ancestors
|
|
149
|
+
})) : l = s.filter((r) => r.value !== e.element.id), c(l), u("");
|
|
150
|
+
},
|
|
151
|
+
open: C,
|
|
152
|
+
searchInput: x.trimStart(),
|
|
153
|
+
selectableLevels: E,
|
|
154
|
+
selectedNodes: s.map((e) => e.value)
|
|
155
|
+
})
|
|
141
156
|
})
|
|
142
157
|
})]
|
|
143
158
|
});
|
|
144
159
|
});
|
|
145
160
|
export {
|
|
146
|
-
|
|
161
|
+
ye as ComboboxWithApiTreeView
|
|
147
162
|
};
|
|
@@ -14,4 +14,4 @@ export interface DynamicLoadingTreeProps {
|
|
|
14
14
|
noResultMessage: string | React.ReactElement;
|
|
15
15
|
loadingAriaLabel: string;
|
|
16
16
|
}
|
|
17
|
-
export declare const DynamicLoadingTree: (
|
|
17
|
+
export declare const DynamicLoadingTree: import('react').ForwardRefExoticComponent<DynamicLoadingTreeProps & import('react').RefAttributes<HTMLDivElement>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/combobox-with-api",
|
|
3
|
-
"version": "0.44.
|
|
3
|
+
"version": "0.44.8",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@ariakit/react": "0.4.15",
|
|
6
6
|
"@box/blueprint-web": "^10.3.1",
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
"react-intl": "^6.4.2"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@box/tree": "^0.50.
|
|
14
|
+
"@box/tree": "^0.50.4",
|
|
15
15
|
"react-accessible-treeview": "2.9.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@box/blueprint-web": "^12.
|
|
19
|
-
"@box/blueprint-web-assets": "^4.
|
|
20
|
-
"@box/storybook-utils": "^0.13.
|
|
18
|
+
"@box/blueprint-web": "^12.10.0",
|
|
19
|
+
"@box/blueprint-web-assets": "^4.53.0",
|
|
20
|
+
"@box/storybook-utils": "^0.13.6",
|
|
21
21
|
"react": "^18.3.0",
|
|
22
22
|
"react-dom": "^18.3.0"
|
|
23
23
|
},
|