@box/combobox-with-api 1.23.7 → 1.23.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.
- package/dist/chunks/dynamic-loading-tree.js +146 -134
- package/package.json +7 -7
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
import { LoadingIndicator as
|
|
2
|
-
import { InlineError as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { RootTreeNode as m, hasValidLevel as
|
|
5
|
-
import { t as
|
|
1
|
+
import { LoadingIndicator as $ } from "@box/blueprint-web";
|
|
2
|
+
import { InlineError as P, Tree as ee } from "@box/tree";
|
|
3
|
+
import { forwardRef as ae, useReducer as te, useState as A, useMemo as z, useCallback as u, useEffect as F } from "react";
|
|
4
|
+
import { RootTreeNode as m, hasValidLevel as le, getServiceNode as D } from "../esm/lib/components/combobox-with-api-tree-view/tree-utils.js";
|
|
5
|
+
import { t as se, i as oe, A as r } from "./treeReducer.js";
|
|
6
6
|
import { jsx as f, jsxs as ne } from "react/jsx-runtime";
|
|
7
|
-
import '../styles/dynamic-loading-tree.css';const
|
|
8
|
-
container:
|
|
9
|
-
label:
|
|
10
|
-
hiddenLabel:
|
|
11
|
-
comboboxContainer:
|
|
12
|
-
withComboboxButtons:
|
|
13
|
-
textInputWrapper:
|
|
14
|
-
textInput:
|
|
15
|
-
comboboxButtons:
|
|
16
|
-
withChips:
|
|
17
|
-
popover:
|
|
7
|
+
import '../styles/dynamic-loading-tree.css';const re = "_container_1wa8l_2", de = "_label_1wa8l_16", ie = "_hiddenLabel_1wa8l_28", ce = "_comboboxContainer_1wa8l_31", me = "_withComboboxButtons_1wa8l_47", ue = "_textInputWrapper_1wa8l_63", pe = "_textInput_1wa8l_63", be = "_comboboxButtons_1wa8l_88", ye = "_withChips_1wa8l_95", he = "_popover_1wa8l_109", _e = "_loadingIndicator_1wa8l_173", ve = "_noResultOption_1wa8l_176", L = {
|
|
8
|
+
container: re,
|
|
9
|
+
label: de,
|
|
10
|
+
hiddenLabel: ie,
|
|
11
|
+
comboboxContainer: ce,
|
|
12
|
+
withComboboxButtons: me,
|
|
13
|
+
textInputWrapper: ue,
|
|
14
|
+
textInput: pe,
|
|
15
|
+
comboboxButtons: be,
|
|
16
|
+
withChips: ye,
|
|
17
|
+
popover: he,
|
|
18
18
|
loadingIndicator: _e,
|
|
19
|
-
noResultOption:
|
|
20
|
-
},
|
|
21
|
-
const i = [...
|
|
19
|
+
noResultOption: ve
|
|
20
|
+
}, fe = (n) => {
|
|
21
|
+
const i = [...n.children], {
|
|
22
22
|
metadata: c
|
|
23
|
-
} =
|
|
23
|
+
} = n;
|
|
24
24
|
return {
|
|
25
|
-
...
|
|
25
|
+
...n,
|
|
26
26
|
children: i,
|
|
27
27
|
metadata: {
|
|
28
|
-
...
|
|
28
|
+
...n.metadata,
|
|
29
29
|
variant: c.variant,
|
|
30
|
-
isLoading:
|
|
30
|
+
isLoading: n.status === "loading" && !n.children.length,
|
|
31
31
|
labelName: c.labelName || "",
|
|
32
32
|
labelValue: c.labelValue || ""
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
},
|
|
35
|
+
}, ge = (n, i) => {
|
|
36
36
|
let c;
|
|
37
|
-
return
|
|
38
|
-
},
|
|
39
|
-
ariaLabel:
|
|
37
|
+
return n.children.length && n.status === "loading" && (c = D(i.id, i.metadata.displayValue, "loading")), n.status === "error" && (c = D(i.id, i.metadata.displayValue, "reload")), n.status === "success" && n.marker && (c = D(i.id, i.metadata.displayValue, "loadMore")), c;
|
|
38
|
+
}, Ee = /* @__PURE__ */ ae(({
|
|
39
|
+
ariaLabel: n,
|
|
40
40
|
onSelect: i,
|
|
41
41
|
selectedNodes: c,
|
|
42
42
|
defaultFetcher: b,
|
|
43
|
-
levels:
|
|
43
|
+
levels: O,
|
|
44
44
|
selectableLevels: g,
|
|
45
|
-
multiselect:
|
|
46
|
-
open:
|
|
45
|
+
multiselect: w,
|
|
46
|
+
open: V,
|
|
47
47
|
searchInput: p,
|
|
48
|
-
noResultMessage:
|
|
49
|
-
loadingAriaLabel:
|
|
50
|
-
},
|
|
51
|
-
const [_,
|
|
48
|
+
noResultMessage: q,
|
|
49
|
+
loadingAriaLabel: G
|
|
50
|
+
}, H) => {
|
|
51
|
+
const [_, s] = te(se, oe), [y, J] = A({
|
|
52
52
|
nodes: [],
|
|
53
53
|
selectedIds: []
|
|
54
|
-
}), [
|
|
54
|
+
}), [E, h] = A(!1), [S, I] = A(!1), N = z(() => Math.max(...g), [g]), k = u((e = _) => {
|
|
55
55
|
const t = [];
|
|
56
56
|
return [...Object.values(e).map((a) => {
|
|
57
|
-
const
|
|
58
|
-
return d && (t.push(d),
|
|
57
|
+
const l = fe(a), d = ge(a, l);
|
|
58
|
+
return d && (t.push(d), l.children.push(d.id)), l;
|
|
59
59
|
}), ...t];
|
|
60
|
-
}, [_]),
|
|
61
|
-
const t = e.ancestors?.find((
|
|
60
|
+
}, [_]), B = u((e) => {
|
|
61
|
+
const t = e.ancestors?.find((l) => l.level === e.level - 1), o = O.find((l) => l.level === e.level);
|
|
62
62
|
return e.level === 1 || p === "" ? e.displayValue : {
|
|
63
|
-
labelName:
|
|
63
|
+
labelName: o.displayName,
|
|
64
64
|
labelValue: t.displayName
|
|
65
65
|
};
|
|
66
|
-
}, [
|
|
66
|
+
}, [O, p]), v = u((e) => ({
|
|
67
67
|
id: e.value,
|
|
68
68
|
name: e.displayValue,
|
|
69
69
|
parent: m.id,
|
|
70
|
-
isBranch: e.level !==
|
|
70
|
+
isBranch: e.level !== N,
|
|
71
71
|
children: [],
|
|
72
72
|
metadata: {
|
|
73
73
|
variant: "content",
|
|
@@ -77,46 +77,46 @@ import '../styles/dynamic-loading-tree.css';const oe = "_container_1wa8l_2", re
|
|
|
77
77
|
marker: e.marker,
|
|
78
78
|
ancestors: e.ancestors
|
|
79
79
|
}
|
|
80
|
-
}), [
|
|
81
|
-
|
|
82
|
-
type:
|
|
80
|
+
}), [N]), T = u((e, t) => {
|
|
81
|
+
s({
|
|
82
|
+
type: r.RESET,
|
|
83
83
|
payload: {
|
|
84
84
|
id: m.id,
|
|
85
85
|
items: []
|
|
86
86
|
}
|
|
87
|
-
}),
|
|
88
|
-
type:
|
|
87
|
+
}), s({
|
|
88
|
+
type: r.LOAD_SUCCESS,
|
|
89
89
|
payload: {
|
|
90
90
|
id: m.id,
|
|
91
91
|
items: e,
|
|
92
92
|
marker: t
|
|
93
93
|
}
|
|
94
|
-
}),
|
|
95
|
-
}, [
|
|
96
|
-
|
|
97
|
-
type:
|
|
94
|
+
}), h(!1);
|
|
95
|
+
}, [s, h]), x = u(() => {
|
|
96
|
+
s({
|
|
97
|
+
type: r.LOAD_ERROR,
|
|
98
98
|
payload: {
|
|
99
99
|
id: m.id
|
|
100
100
|
}
|
|
101
|
-
}),
|
|
102
|
-
}, [
|
|
103
|
-
const
|
|
104
|
-
return t.filter((a) =>
|
|
101
|
+
}), h(!1), I(!0);
|
|
102
|
+
}, [s, h, I]), j = u((e, t) => {
|
|
103
|
+
const o = new Set(e.map((a) => a.id));
|
|
104
|
+
return t.filter((a) => a != null && o.has(a));
|
|
105
105
|
}, []);
|
|
106
|
-
|
|
107
|
-
const e =
|
|
108
|
-
|
|
106
|
+
F(() => {
|
|
107
|
+
const e = k(_);
|
|
108
|
+
J({
|
|
109
109
|
nodes: e,
|
|
110
|
-
selectedIds:
|
|
110
|
+
selectedIds: j(e, c)
|
|
111
111
|
});
|
|
112
|
-
}, [
|
|
113
|
-
if (!
|
|
112
|
+
}, [j, k, c, _, S]), F(() => {
|
|
113
|
+
if (!V)
|
|
114
114
|
return;
|
|
115
115
|
const {
|
|
116
116
|
signal: e
|
|
117
117
|
} = new AbortController();
|
|
118
|
-
|
|
119
|
-
type:
|
|
118
|
+
h(!0), I(!1), p ? (s({
|
|
119
|
+
type: r.RESET,
|
|
120
120
|
payload: {
|
|
121
121
|
id: m.id,
|
|
122
122
|
items: []
|
|
@@ -129,16 +129,16 @@ import '../styles/dynamic-loading-tree.css';const oe = "_container_1wa8l_2", re
|
|
|
129
129
|
onlySelectableOptions: !1,
|
|
130
130
|
ancestorId: null
|
|
131
131
|
}).then((t) => {
|
|
132
|
-
const
|
|
132
|
+
const o = t.options.filter((a) => a.selectable).map((a) => {
|
|
133
133
|
const {
|
|
134
|
-
labelName:
|
|
134
|
+
labelName: l,
|
|
135
135
|
labelValue: d
|
|
136
|
-
} =
|
|
136
|
+
} = B(a);
|
|
137
137
|
return {
|
|
138
138
|
id: a.value,
|
|
139
139
|
name: a.displayValue,
|
|
140
140
|
parent: m.id,
|
|
141
|
-
isBranch: a.level <
|
|
141
|
+
isBranch: a.level < N,
|
|
142
142
|
children: [],
|
|
143
143
|
metadata: {
|
|
144
144
|
variant: a.level === 1 ? "content" : "labeled",
|
|
@@ -146,22 +146,22 @@ import '../styles/dynamic-loading-tree.css';const oe = "_container_1wa8l_2", re
|
|
|
146
146
|
level: a.level,
|
|
147
147
|
selectable: a.selectable,
|
|
148
148
|
ancestors: a.ancestors,
|
|
149
|
-
labelName:
|
|
149
|
+
labelName: l,
|
|
150
150
|
labelValue: d
|
|
151
151
|
}
|
|
152
152
|
};
|
|
153
153
|
});
|
|
154
|
-
|
|
154
|
+
T(o, t.marker);
|
|
155
155
|
}).catch(() => {
|
|
156
|
-
|
|
157
|
-
})) : (
|
|
158
|
-
type:
|
|
156
|
+
x();
|
|
157
|
+
})) : (s({
|
|
158
|
+
type: r.RESET,
|
|
159
159
|
payload: {
|
|
160
160
|
id: m.id,
|
|
161
161
|
items: []
|
|
162
162
|
}
|
|
163
|
-
}),
|
|
164
|
-
type:
|
|
163
|
+
}), s({
|
|
164
|
+
type: r.LOAD_DATA,
|
|
165
165
|
payload: {
|
|
166
166
|
id: m.id
|
|
167
167
|
}
|
|
@@ -173,21 +173,21 @@ import '../styles/dynamic-loading-tree.css';const oe = "_container_1wa8l_2", re
|
|
|
173
173
|
onlySelectableOptions: !1,
|
|
174
174
|
ancestorId: null
|
|
175
175
|
}).then((t) => {
|
|
176
|
-
const
|
|
177
|
-
|
|
176
|
+
const o = t.options.map(v);
|
|
177
|
+
T(o, t.marker);
|
|
178
178
|
}).catch(() => {
|
|
179
|
-
|
|
179
|
+
x();
|
|
180
180
|
}));
|
|
181
|
-
}, [b,
|
|
181
|
+
}, [b, v, V, p, O, N, B, T, x]);
|
|
182
182
|
const K = u((e) => {
|
|
183
183
|
const {
|
|
184
184
|
isExpanded: t,
|
|
185
|
-
isDisabled:
|
|
185
|
+
isDisabled: o,
|
|
186
186
|
element: a
|
|
187
187
|
} = e;
|
|
188
|
-
if (!t ||
|
|
189
|
-
|
|
190
|
-
type:
|
|
188
|
+
if (!t || o) {
|
|
189
|
+
s({
|
|
190
|
+
type: r.RESET,
|
|
191
191
|
payload: {
|
|
192
192
|
id: a.id,
|
|
193
193
|
items: []
|
|
@@ -196,119 +196,131 @@ import '../styles/dynamic-loading-tree.css';const oe = "_container_1wa8l_2", re
|
|
|
196
196
|
return;
|
|
197
197
|
}
|
|
198
198
|
const {
|
|
199
|
-
level:
|
|
199
|
+
level: l
|
|
200
200
|
} = a.metadata, {
|
|
201
201
|
id: d,
|
|
202
202
|
marker: R
|
|
203
203
|
} = a, {
|
|
204
|
-
signal:
|
|
204
|
+
signal: C
|
|
205
205
|
} = new AbortController();
|
|
206
|
-
|
|
207
|
-
type:
|
|
206
|
+
s({
|
|
207
|
+
type: r.LOAD_DATA,
|
|
208
208
|
payload: {
|
|
209
209
|
id: d
|
|
210
210
|
}
|
|
211
211
|
}), b({
|
|
212
|
-
signal:
|
|
212
|
+
signal: C,
|
|
213
213
|
marker: R,
|
|
214
214
|
searchInput: "",
|
|
215
|
-
level:
|
|
215
|
+
level: l + 1,
|
|
216
216
|
ancestorId: d,
|
|
217
217
|
onlySelectableOptions: !1
|
|
218
|
-
}).then((
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
type:
|
|
218
|
+
}).then((U) => {
|
|
219
|
+
const Z = U.options.map((W) => (a.children.push(W.value), v(W)));
|
|
220
|
+
s({
|
|
221
|
+
type: r.LOAD_SUCCESS,
|
|
222
222
|
payload: {
|
|
223
223
|
id: d,
|
|
224
|
-
items:
|
|
225
|
-
marker:
|
|
224
|
+
items: Z,
|
|
225
|
+
marker: U.marker
|
|
226
226
|
}
|
|
227
227
|
});
|
|
228
228
|
}).catch(() => {
|
|
229
|
-
|
|
230
|
-
type:
|
|
229
|
+
s({
|
|
230
|
+
type: r.LOAD_ERROR,
|
|
231
231
|
payload: {
|
|
232
232
|
id: d
|
|
233
233
|
}
|
|
234
234
|
});
|
|
235
235
|
});
|
|
236
|
-
}, [b,
|
|
237
|
-
S && (
|
|
236
|
+
}, [b, v]), M = u((e) => {
|
|
237
|
+
S && (I(!1), h(!0));
|
|
238
238
|
const t = _[e], {
|
|
239
|
-
level:
|
|
239
|
+
level: o
|
|
240
240
|
} = t.metadata, {
|
|
241
241
|
id: a,
|
|
242
|
-
marker:
|
|
242
|
+
marker: l
|
|
243
243
|
} = t, {
|
|
244
244
|
signal: d
|
|
245
245
|
} = new AbortController();
|
|
246
|
-
|
|
247
|
-
type:
|
|
246
|
+
s({
|
|
247
|
+
type: r.LOAD_DATA,
|
|
248
248
|
payload: {
|
|
249
249
|
id: a
|
|
250
250
|
}
|
|
251
251
|
}), b({
|
|
252
252
|
signal: d,
|
|
253
|
-
marker:
|
|
253
|
+
marker: l,
|
|
254
254
|
searchInput: p,
|
|
255
|
-
level: p === "" ?
|
|
255
|
+
level: p === "" ? o + 1 : null,
|
|
256
256
|
ancestorId: a !== m.id ? a.toString() : null,
|
|
257
257
|
onlySelectableOptions: !1
|
|
258
258
|
}).then((R) => {
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
type:
|
|
259
|
+
const C = R.options.map(v);
|
|
260
|
+
s({
|
|
261
|
+
type: r.LOAD_SUCCESS,
|
|
262
262
|
payload: {
|
|
263
263
|
id: a,
|
|
264
|
-
items:
|
|
264
|
+
items: C,
|
|
265
265
|
marker: R.marker
|
|
266
266
|
}
|
|
267
|
-
}),
|
|
267
|
+
}), h(!1);
|
|
268
268
|
}).catch(() => {
|
|
269
|
-
|
|
270
|
-
type:
|
|
269
|
+
s({
|
|
270
|
+
type: r.LOAD_ERROR,
|
|
271
271
|
payload: {
|
|
272
272
|
id: a,
|
|
273
|
-
marker:
|
|
273
|
+
marker: l
|
|
274
274
|
}
|
|
275
275
|
});
|
|
276
276
|
});
|
|
277
|
-
}, [b, S,
|
|
277
|
+
}, [b, S, v, p, _]), {
|
|
278
|
+
isTreeEmpty: Q,
|
|
279
|
+
focusedId: X
|
|
280
|
+
} = z(() => {
|
|
281
|
+
const t = y.nodes.find(({
|
|
282
|
+
id: l
|
|
283
|
+
}) => l === m.id)?.children ?? [], o = t[0], a = !w && y.selectedIds.length === 0 && o != null;
|
|
284
|
+
return {
|
|
285
|
+
isTreeEmpty: y.nodes.length === 0 || t.length === 0,
|
|
286
|
+
focusedId: a ? o : void 0
|
|
287
|
+
};
|
|
288
|
+
}, [w, y.nodes, y.selectedIds.length]), Y = u((e) => {
|
|
278
289
|
const {
|
|
279
290
|
metadata: t
|
|
280
291
|
} = e.element;
|
|
281
|
-
|
|
292
|
+
le(t) && g.includes(t.level) ? i(e) : (e.isSelected = !1, e.treeState.selectedIds.delete(e.element.id));
|
|
282
293
|
}, [g, i]);
|
|
283
|
-
return S ? /* @__PURE__ */ f(
|
|
294
|
+
return S ? /* @__PURE__ */ f(P, {
|
|
284
295
|
onReload: () => {
|
|
285
|
-
|
|
296
|
+
M("root");
|
|
286
297
|
}
|
|
287
298
|
}) : /* @__PURE__ */ ne("div", {
|
|
288
|
-
children: [
|
|
289
|
-
className:
|
|
290
|
-
children: /* @__PURE__ */ f(
|
|
291
|
-
"aria-label":
|
|
292
|
-
className:
|
|
299
|
+
children: [E && /* @__PURE__ */ f("div", {
|
|
300
|
+
className: L.noResultOption,
|
|
301
|
+
children: /* @__PURE__ */ f($, {
|
|
302
|
+
"aria-label": G,
|
|
303
|
+
className: L.loadingIndicator
|
|
293
304
|
})
|
|
294
|
-
}), Q && !
|
|
295
|
-
className:
|
|
296
|
-
children:
|
|
297
|
-
}) : !
|
|
298
|
-
ref:
|
|
299
|
-
"aria-label":
|
|
300
|
-
data:
|
|
301
|
-
|
|
305
|
+
}), Q && !E ? /* @__PURE__ */ f("div", {
|
|
306
|
+
className: L.noResultOption,
|
|
307
|
+
children: q
|
|
308
|
+
}) : !E && /* @__PURE__ */ f(ee, {
|
|
309
|
+
ref: H,
|
|
310
|
+
"aria-label": n,
|
|
311
|
+
data: y.nodes,
|
|
312
|
+
focusedId: X,
|
|
313
|
+
multiSelect: w,
|
|
302
314
|
onExpand: K,
|
|
303
|
-
onLoadData:
|
|
304
|
-
onNodeSelect:
|
|
305
|
-
selectedIds:
|
|
315
|
+
onLoadData: M,
|
|
316
|
+
onNodeSelect: Y,
|
|
317
|
+
selectedIds: y.selectedIds,
|
|
306
318
|
size: "large",
|
|
307
319
|
togglableSelect: !0
|
|
308
320
|
})]
|
|
309
321
|
});
|
|
310
322
|
});
|
|
311
323
|
export {
|
|
312
|
-
|
|
313
|
-
|
|
324
|
+
Ee as D,
|
|
325
|
+
L as s
|
|
314
326
|
};
|
package/package.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/combobox-with-api",
|
|
3
|
-
"version": "1.23.
|
|
3
|
+
"version": "1.23.8",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@ariakit/react": "0.4.15",
|
|
6
|
-
"@box/blueprint-web": "^12.115.
|
|
7
|
-
"@box/blueprint-web-assets": "^4.
|
|
6
|
+
"@box/blueprint-web": "^12.115.2",
|
|
7
|
+
"@box/blueprint-web-assets": "^4.93.0",
|
|
8
8
|
"lodash": "^4.17.15",
|
|
9
9
|
"react": "^17.0.0 || ^18.0.0",
|
|
10
10
|
"react-dom": "^17.0.0 || ^18.0.0",
|
|
11
11
|
"react-intl": "^6.4.2"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@box/tree": "^1.21.
|
|
14
|
+
"@box/tree": "^1.21.8",
|
|
15
15
|
"react-accessible-treeview": "2.9.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@box/blueprint-web": "^12.115.
|
|
19
|
-
"@box/blueprint-web-assets": "^4.
|
|
20
|
-
"@box/storybook-utils": "^0.15.
|
|
18
|
+
"@box/blueprint-web": "^12.115.2",
|
|
19
|
+
"@box/blueprint-web-assets": "^4.93.0",
|
|
20
|
+
"@box/storybook-utils": "^0.15.8",
|
|
21
21
|
"react": "^18.3.0",
|
|
22
22
|
"react-dom": "^18.3.0"
|
|
23
23
|
},
|