@box/combobox-with-api 0.34.2 → 0.34.5
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 +248 -267
- package/dist/esm/lib/components/combobox-with-api-tree-view/dynamic-loading-tree.js +2 -3
- package/dist/esm/lib/components/combobox-with-api-tree-view/index.js +25 -14
- package/dist/types/lib/components/combobox-with-api-tree-view/dynamic-loading-tree.d.ts +0 -6
- package/package.json +3 -3
|
@@ -1,298 +1,280 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Tree as
|
|
3
|
-
import { useReducer as
|
|
4
|
-
import { RootTreeNode as
|
|
5
|
-
import { jsxs as
|
|
6
|
-
import '../styles/dynamic-loading-tree.css';const Q = "_container_xz6fa_1", X = "_disabled_xz6fa_12", Y = "_label_xz6fa_15", Z = "_hiddenLabel_xz6fa_27",
|
|
1
|
+
import { LoadingIndicator as q } from "@box/blueprint-web";
|
|
2
|
+
import { Tree as G } from "@box/tree";
|
|
3
|
+
import { useReducer as H, useState as k, useMemo as J, useCallback as O, useEffect as V } from "react";
|
|
4
|
+
import { RootTreeNode as r, getServiceNode as L } from "../esm/lib/components/combobox-with-api-tree-view/tree-utils.js";
|
|
5
|
+
import { jsxs as K, jsx as R } from "react/jsx-runtime";
|
|
6
|
+
import '../styles/dynamic-loading-tree.css';const Q = "_container_xz6fa_1", X = "_disabled_xz6fa_12", Y = "_label_xz6fa_15", Z = "_hiddenLabel_xz6fa_27", $ = "_comboboxContainer_xz6fa_30", F = "_withComboboxButtons_xz6fa_46", ee = "_error_xz6fa_54", ae = "_textInputWrapper_xz6fa_62", te = "_textInput_xz6fa_62", ne = "_errorIcon_xz6fa_84", le = "_comboboxButtons_xz6fa_87", oe = "_withChips_xz6fa_94", se = "_inlineError_xz6fa_104", re = "_popover_xz6fa_108", ie = "_option_xz6fa_134", de = "_indicator_xz6fa_157", ce = "_indicatorIcon_xz6fa_166", _e = "_optionWithIndicator_xz6fa_169", me = "_loadingIndicator_xz6fa_172", pe = "_noResultOption_xz6fa_175", C = {
|
|
7
7
|
container: Q,
|
|
8
8
|
disabled: X,
|
|
9
9
|
label: Y,
|
|
10
10
|
hiddenLabel: Z,
|
|
11
|
-
comboboxContainer:
|
|
12
|
-
withComboboxButtons:
|
|
13
|
-
error:
|
|
14
|
-
textInputWrapper:
|
|
15
|
-
textInput:
|
|
16
|
-
errorIcon:
|
|
17
|
-
comboboxButtons:
|
|
11
|
+
comboboxContainer: $,
|
|
12
|
+
withComboboxButtons: F,
|
|
13
|
+
error: ee,
|
|
14
|
+
textInputWrapper: ae,
|
|
15
|
+
textInput: te,
|
|
16
|
+
errorIcon: ne,
|
|
17
|
+
comboboxButtons: le,
|
|
18
18
|
withChips: oe,
|
|
19
|
-
inlineError:
|
|
20
|
-
popover:
|
|
21
|
-
option:
|
|
22
|
-
indicator:
|
|
23
|
-
indicatorIcon:
|
|
24
|
-
optionWithIndicator:
|
|
25
|
-
loadingIndicator:
|
|
26
|
-
noResultOption:
|
|
19
|
+
inlineError: se,
|
|
20
|
+
popover: re,
|
|
21
|
+
option: ie,
|
|
22
|
+
indicator: de,
|
|
23
|
+
indicatorIcon: ce,
|
|
24
|
+
optionWithIndicator: _e,
|
|
25
|
+
loadingIndicator: me,
|
|
26
|
+
noResultOption: pe
|
|
27
27
|
};
|
|
28
|
-
let
|
|
29
|
-
return
|
|
28
|
+
let t = /* @__PURE__ */ function(n) {
|
|
29
|
+
return n.LOAD_DATA = "LOAD_DATA", n.LOAD_ERROR = "LOAD_DATA_ERROR", n.LOAD_SUCCESS = "LOAD_DATA_SUCCESS", n.LOAD_MORE = "LOAD_DATA_SUCCESS", n.RESET = "RESET", n;
|
|
30
30
|
}({});
|
|
31
|
-
const
|
|
32
|
-
levelName: t,
|
|
33
|
-
parentDisplayValue: h,
|
|
34
|
-
displayValue: o
|
|
35
|
-
}) => /* @__PURE__ */ N("div", {
|
|
36
|
-
style: {
|
|
37
|
-
display: "flex",
|
|
38
|
-
alignItems: "flex-start",
|
|
39
|
-
flexDirection: "column"
|
|
40
|
-
},
|
|
41
|
-
children: [/* @__PURE__ */ N("div", {
|
|
42
|
-
style: {
|
|
43
|
-
display: "flex",
|
|
44
|
-
alignItems: "flex-start"
|
|
45
|
-
},
|
|
46
|
-
children: [/* @__PURE__ */ u(L, {
|
|
47
|
-
as: "span",
|
|
48
|
-
variant: "labelBold",
|
|
49
|
-
children: `${t}`
|
|
50
|
-
}), /* @__PURE__ */ u(L, {
|
|
51
|
-
as: "span",
|
|
52
|
-
variant: "label",
|
|
53
|
-
children: `/${h}`
|
|
54
|
-
})]
|
|
55
|
-
}), /* @__PURE__ */ u(L, {
|
|
56
|
-
as: "span",
|
|
57
|
-
variant: "bodyDefault",
|
|
58
|
-
children: o
|
|
59
|
-
})]
|
|
60
|
-
}), he = (t, h) => {
|
|
31
|
+
const ue = (n, A) => {
|
|
61
32
|
const {
|
|
62
|
-
id:
|
|
63
|
-
items:
|
|
64
|
-
marker:
|
|
65
|
-
} =
|
|
66
|
-
switch (
|
|
67
|
-
case
|
|
33
|
+
id: i,
|
|
34
|
+
items: u,
|
|
35
|
+
marker: b
|
|
36
|
+
} = A.payload;
|
|
37
|
+
switch (A.type) {
|
|
38
|
+
case t.LOAD_DATA:
|
|
68
39
|
return {
|
|
69
|
-
...
|
|
70
|
-
[
|
|
71
|
-
...
|
|
40
|
+
...n,
|
|
41
|
+
[i]: {
|
|
42
|
+
...n[i],
|
|
72
43
|
status: "loading"
|
|
73
44
|
}
|
|
74
45
|
};
|
|
75
|
-
case
|
|
46
|
+
case t.LOAD_ERROR:
|
|
76
47
|
return {
|
|
77
|
-
...
|
|
78
|
-
[
|
|
79
|
-
...
|
|
80
|
-
marker:
|
|
48
|
+
...n,
|
|
49
|
+
[i]: {
|
|
50
|
+
...n[i],
|
|
51
|
+
marker: b,
|
|
81
52
|
status: "error"
|
|
82
53
|
}
|
|
83
54
|
};
|
|
84
|
-
case
|
|
55
|
+
case t.LOAD_SUCCESS: {
|
|
85
56
|
const {
|
|
86
|
-
itemsWithParent:
|
|
57
|
+
itemsWithParent: h,
|
|
87
58
|
itemsIds: v
|
|
88
|
-
} =
|
|
59
|
+
} = u.reduce((f, c) => ({
|
|
89
60
|
itemsWithParent: {
|
|
90
|
-
...
|
|
91
|
-
[
|
|
92
|
-
...
|
|
93
|
-
parent:
|
|
61
|
+
...f.itemsWithParent,
|
|
62
|
+
[c.id]: {
|
|
63
|
+
...c,
|
|
64
|
+
parent: i,
|
|
94
65
|
children: []
|
|
95
66
|
}
|
|
96
67
|
},
|
|
97
|
-
itemsIds: [...
|
|
68
|
+
itemsIds: [...f.itemsIds, c.id]
|
|
98
69
|
}), {
|
|
99
70
|
itemsWithParent: {},
|
|
100
71
|
itemsIds: []
|
|
101
72
|
});
|
|
102
73
|
return {
|
|
103
|
-
...
|
|
104
|
-
[
|
|
105
|
-
...
|
|
74
|
+
...n,
|
|
75
|
+
[i]: {
|
|
76
|
+
...n[i],
|
|
106
77
|
status: "success",
|
|
107
|
-
marker:
|
|
108
|
-
children: [...
|
|
78
|
+
marker: b,
|
|
79
|
+
children: [...n[i].children || [], ...v]
|
|
109
80
|
},
|
|
110
|
-
...
|
|
81
|
+
...h
|
|
111
82
|
};
|
|
112
83
|
}
|
|
113
|
-
case
|
|
84
|
+
case t.RESET:
|
|
114
85
|
return {
|
|
115
|
-
...
|
|
116
|
-
[
|
|
117
|
-
...
|
|
86
|
+
...n,
|
|
87
|
+
[i]: {
|
|
88
|
+
...n[i],
|
|
118
89
|
status: "success",
|
|
119
|
-
marker:
|
|
90
|
+
marker: b,
|
|
120
91
|
children: []
|
|
121
92
|
}
|
|
122
93
|
};
|
|
123
94
|
default:
|
|
124
|
-
return
|
|
95
|
+
return n;
|
|
125
96
|
}
|
|
126
|
-
},
|
|
127
|
-
ariaLabel:
|
|
128
|
-
onSelect:
|
|
129
|
-
selectedNodes:
|
|
130
|
-
defaultFetcher:
|
|
131
|
-
levels:
|
|
132
|
-
selectableLevels:
|
|
97
|
+
}, xe = ({
|
|
98
|
+
ariaLabel: n,
|
|
99
|
+
onSelect: A,
|
|
100
|
+
selectedNodes: i,
|
|
101
|
+
defaultFetcher: u,
|
|
102
|
+
levels: b,
|
|
103
|
+
selectableLevels: h,
|
|
133
104
|
multiselect: v,
|
|
134
|
-
open:
|
|
135
|
-
searchInput:
|
|
136
|
-
noResultMessage:
|
|
137
|
-
loadingAriaLabel:
|
|
105
|
+
open: f,
|
|
106
|
+
searchInput: c,
|
|
107
|
+
noResultMessage: w,
|
|
108
|
+
loadingAriaLabel: W
|
|
138
109
|
}) => {
|
|
139
|
-
const [
|
|
140
|
-
[
|
|
141
|
-
}), [
|
|
110
|
+
const [y, l] = H(ue, {
|
|
111
|
+
[r.id]: r
|
|
112
|
+
}), [D, B] = k({
|
|
142
113
|
nodes: [],
|
|
143
114
|
selectedIds: []
|
|
144
|
-
}), [
|
|
145
|
-
const
|
|
146
|
-
return [...Object.values(
|
|
147
|
-
const _ = [...
|
|
148
|
-
|
|
115
|
+
}), [I, x] = k(!1), E = J(() => Math.max(...h), [h]), g = O((a = y) => {
|
|
116
|
+
const s = [];
|
|
117
|
+
return [...Object.values(a).map((e) => {
|
|
118
|
+
const _ = [...e.children], {
|
|
119
|
+
metadata: o
|
|
120
|
+
} = e, d = {
|
|
121
|
+
...e,
|
|
149
122
|
children: _,
|
|
150
123
|
metadata: {
|
|
151
|
-
...
|
|
152
|
-
variant:
|
|
153
|
-
isLoading:
|
|
124
|
+
...e.metadata,
|
|
125
|
+
variant: o.variant,
|
|
126
|
+
isLoading: e.status === "loading" && !e.children.length,
|
|
127
|
+
labelName: o.labelName || "",
|
|
128
|
+
labelValue: o.labelValue || ""
|
|
154
129
|
}
|
|
155
130
|
};
|
|
156
|
-
let
|
|
157
|
-
return
|
|
158
|
-
}), ...
|
|
159
|
-
}, [
|
|
131
|
+
let p;
|
|
132
|
+
return e.children.length && e.status === "loading" && (p = L(d.id, d.metadata.displayValue, "loading")), e.status === "error" && (p = L(d.id, d.metadata.displayValue, "reload")), e.status === "success" && e.marker && (p = L(d.id, d.metadata.displayValue, "loadMore")), p && (s.push(p), d.children.push(p.id)), d;
|
|
133
|
+
}), ...s];
|
|
134
|
+
}, [y]), N = O((a) => {
|
|
160
135
|
var _;
|
|
161
|
-
const
|
|
162
|
-
return
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
isBranch: e.level !== E,
|
|
136
|
+
const s = (_ = a.ancestors) == null ? void 0 : _.find((o) => o.level === a.level - 1), m = b.find((o) => o.level === a.level);
|
|
137
|
+
return a.level === 1 || c === "" ? a.displayValue : {
|
|
138
|
+
labelName: m.displayName,
|
|
139
|
+
labelValue: s.displayName
|
|
140
|
+
};
|
|
141
|
+
}, [b, c]), S = O((a) => ({
|
|
142
|
+
id: a.value,
|
|
143
|
+
name: a.displayValue,
|
|
144
|
+
parent: r.id,
|
|
145
|
+
isBranch: a.level !== E,
|
|
172
146
|
children: [],
|
|
173
147
|
metadata: {
|
|
174
148
|
variant: "content",
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
marker:
|
|
179
|
-
ancestors:
|
|
149
|
+
displayValue: a.displayValue,
|
|
150
|
+
level: a.level,
|
|
151
|
+
selectable: a.selectable,
|
|
152
|
+
marker: a.marker,
|
|
153
|
+
ancestors: a.ancestors
|
|
180
154
|
}
|
|
181
|
-
}), [
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
nodes:
|
|
185
|
-
selectedIds:
|
|
155
|
+
}), [E]);
|
|
156
|
+
V(() => {
|
|
157
|
+
B({
|
|
158
|
+
nodes: g(y),
|
|
159
|
+
selectedIds: i
|
|
186
160
|
});
|
|
187
|
-
}, [
|
|
188
|
-
if (!
|
|
161
|
+
}, [g, i, y]), V(() => {
|
|
162
|
+
if (!f)
|
|
189
163
|
return;
|
|
190
164
|
const {
|
|
191
|
-
signal:
|
|
165
|
+
signal: a
|
|
192
166
|
} = new AbortController();
|
|
193
|
-
|
|
194
|
-
type:
|
|
167
|
+
x(!0), c ? (l({
|
|
168
|
+
type: t.RESET,
|
|
195
169
|
payload: {
|
|
196
|
-
id:
|
|
170
|
+
id: r.id,
|
|
197
171
|
items: []
|
|
198
172
|
}
|
|
199
|
-
}),
|
|
200
|
-
signal:
|
|
173
|
+
}), u({
|
|
174
|
+
signal: a,
|
|
201
175
|
marker: null,
|
|
202
|
-
searchInput:
|
|
176
|
+
searchInput: c,
|
|
203
177
|
level: null,
|
|
204
178
|
onlySelectableOptions: !1,
|
|
205
179
|
ancestorId: null
|
|
206
|
-
}).then((
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
180
|
+
}).then((s) => {
|
|
181
|
+
const m = s.options.map((e) => {
|
|
182
|
+
const {
|
|
183
|
+
labelName: _,
|
|
184
|
+
labelValue: o
|
|
185
|
+
} = N(e);
|
|
186
|
+
return {
|
|
187
|
+
id: e.value,
|
|
188
|
+
name: e.displayValue,
|
|
189
|
+
parent: r.id,
|
|
190
|
+
isBranch: e.level < E,
|
|
191
|
+
children: [],
|
|
192
|
+
metadata: {
|
|
193
|
+
variant: e.level === 1 ? "content" : "labeled",
|
|
194
|
+
displayValue: e.displayValue,
|
|
195
|
+
level: e.level,
|
|
196
|
+
selectable: e.selectable,
|
|
197
|
+
ancestors: e.ancestors,
|
|
198
|
+
labelName: _,
|
|
199
|
+
labelValue: o
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
});
|
|
203
|
+
l({
|
|
204
|
+
type: t.RESET,
|
|
223
205
|
payload: {
|
|
224
|
-
id:
|
|
206
|
+
id: r.id,
|
|
225
207
|
items: []
|
|
226
208
|
}
|
|
227
|
-
}),
|
|
228
|
-
type:
|
|
209
|
+
}), l({
|
|
210
|
+
type: t.LOAD_SUCCESS,
|
|
229
211
|
payload: {
|
|
230
|
-
id:
|
|
231
|
-
items:
|
|
232
|
-
marker:
|
|
212
|
+
id: r.id,
|
|
213
|
+
items: m,
|
|
214
|
+
marker: s.marker
|
|
233
215
|
}
|
|
234
|
-
}),
|
|
216
|
+
}), x(!1);
|
|
235
217
|
}).catch(() => {
|
|
236
|
-
|
|
237
|
-
type:
|
|
218
|
+
l({
|
|
219
|
+
type: t.LOAD_ERROR,
|
|
238
220
|
payload: {
|
|
239
|
-
id:
|
|
221
|
+
id: r.id
|
|
240
222
|
}
|
|
241
|
-
}),
|
|
242
|
-
})) : (
|
|
243
|
-
type:
|
|
223
|
+
}), x(!1);
|
|
224
|
+
})) : (l({
|
|
225
|
+
type: t.RESET,
|
|
244
226
|
payload: {
|
|
245
|
-
id:
|
|
227
|
+
id: r.id,
|
|
246
228
|
items: []
|
|
247
229
|
}
|
|
248
|
-
}),
|
|
249
|
-
type:
|
|
230
|
+
}), l({
|
|
231
|
+
type: t.LOAD_DATA,
|
|
250
232
|
payload: {
|
|
251
|
-
id:
|
|
233
|
+
id: r.id
|
|
252
234
|
}
|
|
253
|
-
}),
|
|
254
|
-
signal:
|
|
235
|
+
}), u({
|
|
236
|
+
signal: a,
|
|
255
237
|
marker: null,
|
|
256
238
|
searchInput: "",
|
|
257
239
|
level: 1,
|
|
258
240
|
onlySelectableOptions: !1,
|
|
259
241
|
ancestorId: null
|
|
260
|
-
}).then((
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
type:
|
|
242
|
+
}).then((s) => {
|
|
243
|
+
const m = s.options.map(S);
|
|
244
|
+
l({
|
|
245
|
+
type: t.RESET,
|
|
264
246
|
payload: {
|
|
265
|
-
id:
|
|
247
|
+
id: r.id,
|
|
266
248
|
items: []
|
|
267
249
|
}
|
|
268
|
-
}),
|
|
269
|
-
type:
|
|
250
|
+
}), l({
|
|
251
|
+
type: t.LOAD_SUCCESS,
|
|
270
252
|
payload: {
|
|
271
|
-
id:
|
|
272
|
-
items:
|
|
273
|
-
marker:
|
|
253
|
+
id: r.id,
|
|
254
|
+
items: m,
|
|
255
|
+
marker: s.marker
|
|
274
256
|
}
|
|
275
|
-
}),
|
|
257
|
+
}), x(!1);
|
|
276
258
|
}).catch(() => {
|
|
277
|
-
|
|
278
|
-
type:
|
|
259
|
+
l({
|
|
260
|
+
type: t.LOAD_ERROR,
|
|
279
261
|
payload: {
|
|
280
|
-
id:
|
|
262
|
+
id: r.id
|
|
281
263
|
}
|
|
282
|
-
}),
|
|
264
|
+
}), x(!1);
|
|
283
265
|
}));
|
|
284
|
-
}, [
|
|
285
|
-
const
|
|
266
|
+
}, [u, S, f, c, b, E, N]);
|
|
267
|
+
const U = O((a) => {
|
|
286
268
|
const {
|
|
287
|
-
isExpanded:
|
|
288
|
-
isDisabled:
|
|
289
|
-
element:
|
|
290
|
-
} =
|
|
291
|
-
if (!
|
|
292
|
-
|
|
293
|
-
type:
|
|
269
|
+
isExpanded: s,
|
|
270
|
+
isDisabled: m,
|
|
271
|
+
element: e
|
|
272
|
+
} = a;
|
|
273
|
+
if (!s || m) {
|
|
274
|
+
l({
|
|
275
|
+
type: t.RESET,
|
|
294
276
|
payload: {
|
|
295
|
-
id:
|
|
277
|
+
id: e.id,
|
|
296
278
|
items: []
|
|
297
279
|
}
|
|
298
280
|
});
|
|
@@ -300,101 +282,101 @@ const ye = ({
|
|
|
300
282
|
}
|
|
301
283
|
const {
|
|
302
284
|
level: _
|
|
303
|
-
} =
|
|
304
|
-
id:
|
|
305
|
-
marker:
|
|
306
|
-
} =
|
|
307
|
-
signal:
|
|
285
|
+
} = e.metadata, {
|
|
286
|
+
id: o,
|
|
287
|
+
marker: d
|
|
288
|
+
} = e, {
|
|
289
|
+
signal: p
|
|
308
290
|
} = new AbortController();
|
|
309
|
-
|
|
310
|
-
type:
|
|
291
|
+
l({
|
|
292
|
+
type: t.LOAD_DATA,
|
|
311
293
|
payload: {
|
|
312
|
-
id:
|
|
294
|
+
id: o
|
|
313
295
|
}
|
|
314
|
-
}),
|
|
315
|
-
signal:
|
|
316
|
-
marker:
|
|
296
|
+
}), u({
|
|
297
|
+
signal: p,
|
|
298
|
+
marker: d,
|
|
317
299
|
searchInput: "",
|
|
318
300
|
level: _ + 1,
|
|
319
|
-
ancestorId:
|
|
301
|
+
ancestorId: o,
|
|
320
302
|
onlySelectableOptions: !1
|
|
321
|
-
}).then((
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
type:
|
|
303
|
+
}).then((z) => {
|
|
304
|
+
const j = z.options.map((T) => (e.children.push(T.value), S(T)));
|
|
305
|
+
l({
|
|
306
|
+
type: t.LOAD_SUCCESS,
|
|
325
307
|
payload: {
|
|
326
|
-
id:
|
|
327
|
-
items:
|
|
328
|
-
marker:
|
|
308
|
+
id: o,
|
|
309
|
+
items: j,
|
|
310
|
+
marker: z.marker
|
|
329
311
|
}
|
|
330
312
|
});
|
|
331
313
|
}).catch(() => {
|
|
332
|
-
|
|
333
|
-
type:
|
|
314
|
+
l({
|
|
315
|
+
type: t.LOAD_ERROR,
|
|
334
316
|
payload: {
|
|
335
|
-
id:
|
|
317
|
+
id: o
|
|
336
318
|
}
|
|
337
319
|
});
|
|
338
320
|
});
|
|
339
|
-
}, [
|
|
340
|
-
const
|
|
341
|
-
level:
|
|
342
|
-
} =
|
|
343
|
-
id:
|
|
321
|
+
}, [u, S]), P = O((a) => {
|
|
322
|
+
const s = y[a], {
|
|
323
|
+
level: m
|
|
324
|
+
} = s.metadata, {
|
|
325
|
+
id: e,
|
|
344
326
|
marker: _
|
|
345
|
-
} =
|
|
346
|
-
signal:
|
|
327
|
+
} = s, {
|
|
328
|
+
signal: o
|
|
347
329
|
} = new AbortController();
|
|
348
|
-
|
|
349
|
-
type:
|
|
330
|
+
l({
|
|
331
|
+
type: t.LOAD_DATA,
|
|
350
332
|
payload: {
|
|
351
|
-
id:
|
|
333
|
+
id: e
|
|
352
334
|
}
|
|
353
|
-
}),
|
|
354
|
-
signal:
|
|
335
|
+
}), u({
|
|
336
|
+
signal: o,
|
|
355
337
|
marker: _,
|
|
356
|
-
searchInput:
|
|
357
|
-
level:
|
|
358
|
-
ancestorId:
|
|
338
|
+
searchInput: c,
|
|
339
|
+
level: c === "" ? m + 1 : null,
|
|
340
|
+
ancestorId: e !== r.id ? e.toString() : null,
|
|
359
341
|
onlySelectableOptions: !1
|
|
360
|
-
}).then((
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
type:
|
|
342
|
+
}).then((d) => {
|
|
343
|
+
const p = d.options.map(S);
|
|
344
|
+
l({
|
|
345
|
+
type: t.LOAD_SUCCESS,
|
|
364
346
|
payload: {
|
|
365
|
-
id:
|
|
366
|
-
items:
|
|
367
|
-
marker:
|
|
347
|
+
id: e,
|
|
348
|
+
items: p,
|
|
349
|
+
marker: d.marker
|
|
368
350
|
}
|
|
369
351
|
});
|
|
370
352
|
}).catch(() => {
|
|
371
|
-
|
|
372
|
-
type:
|
|
353
|
+
l({
|
|
354
|
+
type: t.LOAD_ERROR,
|
|
373
355
|
payload: {
|
|
374
|
-
id:
|
|
356
|
+
id: e,
|
|
375
357
|
marker: _
|
|
376
358
|
}
|
|
377
359
|
});
|
|
378
360
|
});
|
|
379
|
-
}, [
|
|
380
|
-
return /* @__PURE__ */
|
|
381
|
-
children: [
|
|
361
|
+
}, [u, S, c, y]), M = D.nodes.length === 0 || D.nodes[0].children.length === 0 && D.nodes[0].id === r.id;
|
|
362
|
+
return /* @__PURE__ */ K("div", {
|
|
363
|
+
children: [I && /* @__PURE__ */ R("div", {
|
|
382
364
|
className: C.noResultOption,
|
|
383
|
-
children: /* @__PURE__ */
|
|
384
|
-
"aria-label":
|
|
365
|
+
children: /* @__PURE__ */ R(q, {
|
|
366
|
+
"aria-label": W,
|
|
385
367
|
className: C.loadingIndicator
|
|
386
368
|
})
|
|
387
|
-
}),
|
|
369
|
+
}), M && !I ? /* @__PURE__ */ R("div", {
|
|
388
370
|
className: C.noResultOption,
|
|
389
|
-
children:
|
|
390
|
-
}) : /* @__PURE__ */
|
|
391
|
-
"aria-label":
|
|
392
|
-
data:
|
|
371
|
+
children: w
|
|
372
|
+
}) : /* @__PURE__ */ R(G, {
|
|
373
|
+
"aria-label": n,
|
|
374
|
+
data: D.nodes,
|
|
393
375
|
multiSelect: v,
|
|
394
|
-
onExpand:
|
|
395
|
-
onLoadData:
|
|
396
|
-
onNodeSelect: (
|
|
397
|
-
|
|
376
|
+
onExpand: U,
|
|
377
|
+
onLoadData: P,
|
|
378
|
+
onNodeSelect: (a) => {
|
|
379
|
+
h.includes(a.element.metadata.level) ? A(a) : (a.isSelected = !1, a.treeState.selectedIds.delete(a.element.id));
|
|
398
380
|
},
|
|
399
381
|
size: "large",
|
|
400
382
|
togglableSelect: !0,
|
|
@@ -403,7 +385,6 @@ const ye = ({
|
|
|
403
385
|
});
|
|
404
386
|
};
|
|
405
387
|
export {
|
|
406
|
-
|
|
407
|
-
ye as S,
|
|
388
|
+
xe as D,
|
|
408
389
|
C as s
|
|
409
390
|
};
|
|
@@ -2,9 +2,8 @@ import "@box/blueprint-web";
|
|
|
2
2
|
import "@box/tree";
|
|
3
3
|
import "react";
|
|
4
4
|
import "./tree-utils.js";
|
|
5
|
-
import { D as
|
|
5
|
+
import { D as e } from "../../../../chunks/dynamic-loading-tree.js";
|
|
6
6
|
import "react/jsx-runtime";
|
|
7
7
|
export {
|
|
8
|
-
|
|
9
|
-
s as SearchResultsName
|
|
8
|
+
e as DynamicLoadingTree
|
|
10
9
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComboboxWithApiTreeView as I } from "./combobox-with-api-tree-view.js";
|
|
2
|
-
const
|
|
2
|
+
const u = [
|
|
3
3
|
// Level 1
|
|
4
4
|
{
|
|
5
5
|
id: "japan-l1-id",
|
|
@@ -203,6 +203,17 @@ const y = [
|
|
|
203
203
|
level: 3,
|
|
204
204
|
selectable: !0
|
|
205
205
|
},
|
|
206
|
+
{
|
|
207
|
+
id: "long-option-l3-id",
|
|
208
|
+
ancestors: [{
|
|
209
|
+
id: "long-option-l1-id",
|
|
210
|
+
displayName: "Long child node",
|
|
211
|
+
level: 1
|
|
212
|
+
}],
|
|
213
|
+
displayName: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
|
|
214
|
+
level: 2,
|
|
215
|
+
selectable: !0
|
|
216
|
+
},
|
|
206
217
|
// Japan L2
|
|
207
218
|
{
|
|
208
219
|
id: "hokkaido-l2-id",
|
|
@@ -359,8 +370,8 @@ const y = [
|
|
|
359
370
|
level: 2,
|
|
360
371
|
selectable: !0
|
|
361
372
|
}
|
|
362
|
-
],
|
|
363
|
-
const a = parseInt(l, 10) || 0, i = a +
|
|
373
|
+
], y = 5, j = (l, e) => {
|
|
374
|
+
const a = parseInt(l, 10) || 0, i = a + y;
|
|
364
375
|
return e.slice(a, i).map(({
|
|
365
376
|
displayName: s,
|
|
366
377
|
id: t,
|
|
@@ -371,7 +382,7 @@ const y = [
|
|
|
371
382
|
...n
|
|
372
383
|
}));
|
|
373
384
|
}, U = (l, e) => {
|
|
374
|
-
const i = (parseInt(l, 10) || 0) +
|
|
385
|
+
const i = (parseInt(l, 10) || 0) + y;
|
|
375
386
|
return i < e.length ? i.toString() : void 0;
|
|
376
387
|
}, x = /* @__PURE__ */ (() => {
|
|
377
388
|
let l = 0, e = 0;
|
|
@@ -382,17 +393,17 @@ const y = [
|
|
|
382
393
|
searchInput: t,
|
|
383
394
|
ancestorId: n,
|
|
384
395
|
marker: o,
|
|
385
|
-
failOnLoadMore:
|
|
386
|
-
options: v =
|
|
396
|
+
failOnLoadMore: N,
|
|
397
|
+
options: v = u,
|
|
387
398
|
failOnLoadMoreTimes: b = Number.MAX_SAFE_INTEGER,
|
|
388
|
-
failOnLoadLevel:
|
|
389
|
-
failOnLoadLevelTimes:
|
|
399
|
+
failOnLoadLevel: g,
|
|
400
|
+
failOnLoadLevelTimes: k = Number.MAX_SAFE_INTEGER
|
|
390
401
|
}) => {
|
|
391
402
|
if (i.aborted)
|
|
392
403
|
return Promise.reject(new DOMException("Aborted", "AbortError"));
|
|
393
|
-
if (
|
|
404
|
+
if (N && o != null && l < b)
|
|
394
405
|
return l += 1, Promise.reject();
|
|
395
|
-
if (s ===
|
|
406
|
+
if (s === g && e < k)
|
|
396
407
|
return e += 1, Promise.reject();
|
|
397
408
|
a && await new Promise((r) => setTimeout(r, a));
|
|
398
409
|
const m = v.filter((r) => {
|
|
@@ -407,11 +418,11 @@ const y = [
|
|
|
407
418
|
return s && c && c !== s && (d = !1), t && (d = d && h.toLowerCase().includes(t.toLowerCase())), n && (d = d && (p == null ? void 0 : p.some(({
|
|
408
419
|
id: S
|
|
409
420
|
}) => S === n))), d;
|
|
410
|
-
}),
|
|
421
|
+
}), f = Promise.resolve({
|
|
411
422
|
marker: U(o, m),
|
|
412
423
|
options: j(o, m)
|
|
413
424
|
});
|
|
414
|
-
return w(await
|
|
425
|
+
return w(await f);
|
|
415
426
|
};
|
|
416
427
|
})();
|
|
417
428
|
function w(l) {
|
|
@@ -432,7 +443,7 @@ function w(l) {
|
|
|
432
443
|
};
|
|
433
444
|
}
|
|
434
445
|
const J = (l) => {
|
|
435
|
-
const e =
|
|
446
|
+
const e = u.find((a) => a.displayName === l);
|
|
436
447
|
return e ? {
|
|
437
448
|
value: e.id,
|
|
438
449
|
displayValue: e.displayName,
|
|
@@ -443,7 +454,7 @@ const J = (l) => {
|
|
|
443
454
|
};
|
|
444
455
|
export {
|
|
445
456
|
I as ComboboxWithApiTreeView,
|
|
446
|
-
|
|
457
|
+
u as apiResponse,
|
|
447
458
|
J as findNode,
|
|
448
459
|
x as mockTreeFetcher
|
|
449
460
|
};
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { NodeId, TreeProps } from '@box/tree';
|
|
2
2
|
import { TreeOptionType } from '../combobox-with-api-pagination/types';
|
|
3
3
|
import { ComboboxWithApiTreeViewProps, Level } from './types';
|
|
4
|
-
export interface SearchResultsNameProps {
|
|
5
|
-
levelName: string;
|
|
6
|
-
parentDisplayValue: string;
|
|
7
|
-
displayValue: string;
|
|
8
|
-
}
|
|
9
|
-
export declare const SearchResultsName: ({ levelName, parentDisplayValue, displayValue }: SearchResultsNameProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
4
|
export interface DynamicLoadingTreeProps {
|
|
11
5
|
ariaLabel: string;
|
|
12
6
|
onSelect: TreeProps['onNodeSelect'];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/combobox-with-api",
|
|
3
|
-
"version": "0.34.
|
|
3
|
+
"version": "0.34.5",
|
|
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.45.
|
|
14
|
+
"@box/tree": "^0.45.2",
|
|
15
15
|
"react-accessible-treeview": "2.9.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@box/blueprint-web": "^11.
|
|
18
|
+
"@box/blueprint-web": "^11.9.0",
|
|
19
19
|
"@box/blueprint-web-assets": "^4.41.1",
|
|
20
20
|
"@box/storybook-utils": "^0.12.0",
|
|
21
21
|
"react": "^18.3.0",
|