@box/combobox-with-api 0.35.2 → 0.36.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.
- package/dist/chunks/dynamic-loading-tree.js +176 -244
- package/dist/chunks/treeReducer.js +78 -0
- package/dist/esm/lib/components/combobox-with-api-tree-view/combobox-with-api-tree-view.js +24 -24
- package/dist/esm/lib/components/combobox-with-api-tree-view/dynamic-loading-tree.js +3 -2
- package/dist/esm/lib/components/combobox-with-api-tree-view/tree-utils.js +9 -8
- package/dist/esm/lib/components/combobox-with-api-tree-view/treeReducer.js +6 -0
- package/dist/types/lib/components/combobox-with-api-tree-view/tree-utils.d.ts +6 -0
- package/dist/types/lib/components/combobox-with-api-tree-view/treeReducer.d.ts +3 -0
- package/package.json +1 -1
|
@@ -1,148 +1,77 @@
|
|
|
1
|
-
import { LoadingIndicator as
|
|
2
|
-
import { Tree as
|
|
3
|
-
import { useReducer as
|
|
4
|
-
import { RootTreeNode as
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
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
|
-
|
|
38
|
-
case t.LOAD_DATA:
|
|
39
|
-
return {
|
|
40
|
-
...n,
|
|
41
|
-
[i]: {
|
|
42
|
-
...n[i],
|
|
43
|
-
status: "loading"
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
case t.LOAD_ERROR:
|
|
47
|
-
return {
|
|
48
|
-
...n,
|
|
49
|
-
[i]: {
|
|
50
|
-
...n[i],
|
|
51
|
-
marker: b,
|
|
52
|
-
status: "error"
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
case t.LOAD_SUCCESS: {
|
|
56
|
-
const {
|
|
57
|
-
itemsWithParent: h,
|
|
58
|
-
itemsIds: v
|
|
59
|
-
} = u.reduce((f, c) => ({
|
|
60
|
-
itemsWithParent: {
|
|
61
|
-
...f.itemsWithParent,
|
|
62
|
-
[c.id]: {
|
|
63
|
-
...c,
|
|
64
|
-
parent: i,
|
|
65
|
-
children: []
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
itemsIds: [...f.itemsIds, c.id]
|
|
69
|
-
}), {
|
|
70
|
-
itemsWithParent: {},
|
|
71
|
-
itemsIds: []
|
|
72
|
-
});
|
|
73
|
-
return {
|
|
74
|
-
...n,
|
|
75
|
-
[i]: {
|
|
76
|
-
...n[i],
|
|
77
|
-
status: "success",
|
|
78
|
-
marker: b,
|
|
79
|
-
children: [...n[i].children || [], ...v]
|
|
80
|
-
},
|
|
81
|
-
...h
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
case t.RESET:
|
|
85
|
-
return {
|
|
86
|
-
...n,
|
|
87
|
-
[i]: {
|
|
88
|
-
...n[i],
|
|
89
|
-
status: "success",
|
|
90
|
-
marker: b,
|
|
91
|
-
children: []
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
default:
|
|
95
|
-
return n;
|
|
96
|
-
}
|
|
97
|
-
}, xe = ({
|
|
98
|
-
ariaLabel: n,
|
|
99
|
-
onSelect: A,
|
|
100
|
-
selectedNodes: i,
|
|
101
|
-
defaultFetcher: u,
|
|
102
|
-
levels: b,
|
|
103
|
-
selectableLevels: h,
|
|
104
|
-
multiselect: v,
|
|
105
|
-
open: f,
|
|
106
|
-
searchInput: c,
|
|
1
|
+
import { LoadingIndicator as H } from "@box/blueprint-web";
|
|
2
|
+
import { Tree as J } from "@box/tree";
|
|
3
|
+
import { useReducer as K, useState as L, useMemo as Q, useCallback as y, useEffect as T } from "react";
|
|
4
|
+
import { getServiceNode as g, RootTreeNode as i, hasValidLevel as X } from "../esm/lib/components/combobox-with-api-tree-view/tree-utils.js";
|
|
5
|
+
import { t as Y, i as Z, A as o } from "./treeReducer.js";
|
|
6
|
+
import { jsxs as $, jsx as v } from "react/jsx-runtime";
|
|
7
|
+
import '../styles/dynamic-loading-tree.css';const P = "_container_xz6fa_1", F = "_disabled_xz6fa_12", ee = "_label_xz6fa_15", ae = "_hiddenLabel_xz6fa_27", te = "_comboboxContainer_xz6fa_30", le = "_withComboboxButtons_xz6fa_46", ne = "_error_xz6fa_54", oe = "_textInputWrapper_xz6fa_62", se = "_textInput_xz6fa_62", ie = "_errorIcon_xz6fa_84", re = "_comboboxButtons_xz6fa_87", de = "_withChips_xz6fa_94", ce = "_inlineError_xz6fa_104", pe = "_popover_xz6fa_108", me = "_option_xz6fa_134", _e = "_indicator_xz6fa_157", ue = "_indicatorIcon_xz6fa_166", ye = "_optionWithIndicator_xz6fa_169", be = "_loadingIndicator_xz6fa_172", fe = "_noResultOption_xz6fa_175", I = {
|
|
8
|
+
container: P,
|
|
9
|
+
disabled: F,
|
|
10
|
+
label: ee,
|
|
11
|
+
hiddenLabel: ae,
|
|
12
|
+
comboboxContainer: te,
|
|
13
|
+
withComboboxButtons: le,
|
|
14
|
+
error: ne,
|
|
15
|
+
textInputWrapper: oe,
|
|
16
|
+
textInput: se,
|
|
17
|
+
errorIcon: ie,
|
|
18
|
+
comboboxButtons: re,
|
|
19
|
+
withChips: de,
|
|
20
|
+
inlineError: ce,
|
|
21
|
+
popover: pe,
|
|
22
|
+
option: me,
|
|
23
|
+
indicator: _e,
|
|
24
|
+
indicatorIcon: ue,
|
|
25
|
+
optionWithIndicator: ye,
|
|
26
|
+
loadingIndicator: be,
|
|
27
|
+
noResultOption: fe
|
|
28
|
+
}, Ie = ({
|
|
29
|
+
ariaLabel: k,
|
|
30
|
+
onSelect: R,
|
|
31
|
+
selectedNodes: E,
|
|
32
|
+
defaultFetcher: m,
|
|
33
|
+
levels: S,
|
|
34
|
+
selectableLevels: x,
|
|
35
|
+
multiselect: V,
|
|
36
|
+
open: N,
|
|
37
|
+
searchInput: p,
|
|
107
38
|
noResultMessage: w,
|
|
108
|
-
loadingAriaLabel:
|
|
39
|
+
loadingAriaLabel: B
|
|
109
40
|
}) => {
|
|
110
|
-
const [
|
|
111
|
-
[r.id]: r
|
|
112
|
-
}), [D, B] = k({
|
|
41
|
+
const [_, l] = K(Y, Z), [b, W] = L({
|
|
113
42
|
nodes: [],
|
|
114
43
|
selectedIds: []
|
|
115
|
-
}), [
|
|
116
|
-
const
|
|
44
|
+
}), [O, f] = L(!1), h = Q(() => Math.max(...x), [x]), A = y((a = _) => {
|
|
45
|
+
const t = [];
|
|
117
46
|
return [...Object.values(a).map((e) => {
|
|
118
|
-
const
|
|
119
|
-
metadata:
|
|
120
|
-
} = e,
|
|
47
|
+
const r = [...e.children], {
|
|
48
|
+
metadata: n
|
|
49
|
+
} = e, s = {
|
|
121
50
|
...e,
|
|
122
|
-
children:
|
|
51
|
+
children: r,
|
|
123
52
|
metadata: {
|
|
124
53
|
...e.metadata,
|
|
125
|
-
variant:
|
|
54
|
+
variant: n.variant,
|
|
126
55
|
isLoading: e.status === "loading" && !e.children.length,
|
|
127
|
-
labelName:
|
|
128
|
-
labelValue:
|
|
56
|
+
labelName: n.labelName || "",
|
|
57
|
+
labelValue: n.labelValue || ""
|
|
129
58
|
}
|
|
130
59
|
};
|
|
131
|
-
let
|
|
132
|
-
return e.children.length && e.status === "loading" && (
|
|
133
|
-
}), ...
|
|
134
|
-
}, [
|
|
135
|
-
var
|
|
136
|
-
const
|
|
137
|
-
return a.level === 1 ||
|
|
138
|
-
labelName:
|
|
139
|
-
labelValue:
|
|
60
|
+
let c;
|
|
61
|
+
return e.children.length && e.status === "loading" && (c = g(s.id, s.metadata.displayValue, "loading")), e.status === "error" && (c = g(s.id, s.metadata.displayValue, "reload")), e.status === "success" && e.marker && (c = g(s.id, s.metadata.displayValue, "loadMore")), c && (t.push(c), s.children.push(c.id)), s;
|
|
62
|
+
}), ...t];
|
|
63
|
+
}, [_]), D = y((a) => {
|
|
64
|
+
var r;
|
|
65
|
+
const t = (r = a.ancestors) == null ? void 0 : r.find((n) => n.level === a.level - 1), d = S.find((n) => n.level === a.level);
|
|
66
|
+
return a.level === 1 || p === "" ? a.displayValue : {
|
|
67
|
+
labelName: d.displayName,
|
|
68
|
+
labelValue: t.displayName
|
|
140
69
|
};
|
|
141
|
-
}, [
|
|
70
|
+
}, [S, p]), u = y((a) => ({
|
|
142
71
|
id: a.value,
|
|
143
72
|
name: a.displayValue,
|
|
144
|
-
parent:
|
|
145
|
-
isBranch: a.level !==
|
|
73
|
+
parent: i.id,
|
|
74
|
+
isBranch: a.level !== h,
|
|
146
75
|
children: [],
|
|
147
76
|
metadata: {
|
|
148
77
|
variant: "content",
|
|
@@ -152,42 +81,42 @@ const ue = (n, A) => {
|
|
|
152
81
|
marker: a.marker,
|
|
153
82
|
ancestors: a.ancestors
|
|
154
83
|
}
|
|
155
|
-
}), [
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
nodes:
|
|
159
|
-
selectedIds:
|
|
84
|
+
}), [h]);
|
|
85
|
+
T(() => {
|
|
86
|
+
W({
|
|
87
|
+
nodes: A(_),
|
|
88
|
+
selectedIds: E
|
|
160
89
|
});
|
|
161
|
-
}, [
|
|
162
|
-
if (!
|
|
90
|
+
}, [A, E, _]), T(() => {
|
|
91
|
+
if (!N)
|
|
163
92
|
return;
|
|
164
93
|
const {
|
|
165
94
|
signal: a
|
|
166
95
|
} = new AbortController();
|
|
167
|
-
|
|
168
|
-
type:
|
|
96
|
+
f(!0), p ? (l({
|
|
97
|
+
type: o.RESET,
|
|
169
98
|
payload: {
|
|
170
|
-
id:
|
|
99
|
+
id: i.id,
|
|
171
100
|
items: []
|
|
172
101
|
}
|
|
173
|
-
}),
|
|
102
|
+
}), m({
|
|
174
103
|
signal: a,
|
|
175
104
|
marker: null,
|
|
176
|
-
searchInput:
|
|
105
|
+
searchInput: p,
|
|
177
106
|
level: null,
|
|
178
107
|
onlySelectableOptions: !1,
|
|
179
108
|
ancestorId: null
|
|
180
|
-
}).then((
|
|
181
|
-
const
|
|
109
|
+
}).then((t) => {
|
|
110
|
+
const d = t.options.map((e) => {
|
|
182
111
|
const {
|
|
183
|
-
labelName:
|
|
184
|
-
labelValue:
|
|
185
|
-
} =
|
|
112
|
+
labelName: r,
|
|
113
|
+
labelValue: n
|
|
114
|
+
} = D(e);
|
|
186
115
|
return {
|
|
187
116
|
id: e.value,
|
|
188
117
|
name: e.displayValue,
|
|
189
|
-
parent:
|
|
190
|
-
isBranch: e.level <
|
|
118
|
+
parent: i.id,
|
|
119
|
+
isBranch: e.level < h,
|
|
191
120
|
children: [],
|
|
192
121
|
metadata: {
|
|
193
122
|
variant: e.level === 1 ? "content" : "labeled",
|
|
@@ -195,84 +124,84 @@ const ue = (n, A) => {
|
|
|
195
124
|
level: e.level,
|
|
196
125
|
selectable: e.selectable,
|
|
197
126
|
ancestors: e.ancestors,
|
|
198
|
-
labelName:
|
|
199
|
-
labelValue:
|
|
127
|
+
labelName: r,
|
|
128
|
+
labelValue: n
|
|
200
129
|
}
|
|
201
130
|
};
|
|
202
131
|
});
|
|
203
132
|
l({
|
|
204
|
-
type:
|
|
133
|
+
type: o.RESET,
|
|
205
134
|
payload: {
|
|
206
|
-
id:
|
|
135
|
+
id: i.id,
|
|
207
136
|
items: []
|
|
208
137
|
}
|
|
209
138
|
}), l({
|
|
210
|
-
type:
|
|
139
|
+
type: o.LOAD_SUCCESS,
|
|
211
140
|
payload: {
|
|
212
|
-
id:
|
|
213
|
-
items:
|
|
214
|
-
marker:
|
|
141
|
+
id: i.id,
|
|
142
|
+
items: d,
|
|
143
|
+
marker: t.marker
|
|
215
144
|
}
|
|
216
|
-
}),
|
|
145
|
+
}), f(!1);
|
|
217
146
|
}).catch(() => {
|
|
218
147
|
l({
|
|
219
|
-
type:
|
|
148
|
+
type: o.LOAD_ERROR,
|
|
220
149
|
payload: {
|
|
221
|
-
id:
|
|
150
|
+
id: i.id
|
|
222
151
|
}
|
|
223
|
-
}),
|
|
152
|
+
}), f(!1);
|
|
224
153
|
})) : (l({
|
|
225
|
-
type:
|
|
154
|
+
type: o.RESET,
|
|
226
155
|
payload: {
|
|
227
|
-
id:
|
|
156
|
+
id: i.id,
|
|
228
157
|
items: []
|
|
229
158
|
}
|
|
230
159
|
}), l({
|
|
231
|
-
type:
|
|
160
|
+
type: o.LOAD_DATA,
|
|
232
161
|
payload: {
|
|
233
|
-
id:
|
|
162
|
+
id: i.id
|
|
234
163
|
}
|
|
235
|
-
}),
|
|
164
|
+
}), m({
|
|
236
165
|
signal: a,
|
|
237
166
|
marker: null,
|
|
238
167
|
searchInput: "",
|
|
239
168
|
level: 1,
|
|
240
169
|
onlySelectableOptions: !1,
|
|
241
170
|
ancestorId: null
|
|
242
|
-
}).then((
|
|
243
|
-
const
|
|
171
|
+
}).then((t) => {
|
|
172
|
+
const d = t.options.map(u);
|
|
244
173
|
l({
|
|
245
|
-
type:
|
|
174
|
+
type: o.RESET,
|
|
246
175
|
payload: {
|
|
247
|
-
id:
|
|
176
|
+
id: i.id,
|
|
248
177
|
items: []
|
|
249
178
|
}
|
|
250
179
|
}), l({
|
|
251
|
-
type:
|
|
180
|
+
type: o.LOAD_SUCCESS,
|
|
252
181
|
payload: {
|
|
253
|
-
id:
|
|
254
|
-
items:
|
|
255
|
-
marker:
|
|
182
|
+
id: i.id,
|
|
183
|
+
items: d,
|
|
184
|
+
marker: t.marker
|
|
256
185
|
}
|
|
257
|
-
}),
|
|
186
|
+
}), f(!1);
|
|
258
187
|
}).catch(() => {
|
|
259
188
|
l({
|
|
260
|
-
type:
|
|
189
|
+
type: o.LOAD_ERROR,
|
|
261
190
|
payload: {
|
|
262
|
-
id:
|
|
191
|
+
id: i.id
|
|
263
192
|
}
|
|
264
|
-
}),
|
|
193
|
+
}), f(!1);
|
|
265
194
|
}));
|
|
266
|
-
}, [
|
|
267
|
-
const U =
|
|
195
|
+
}, [m, u, N, p, S, h, D]);
|
|
196
|
+
const U = y((a) => {
|
|
268
197
|
const {
|
|
269
|
-
isExpanded:
|
|
270
|
-
isDisabled:
|
|
198
|
+
isExpanded: t,
|
|
199
|
+
isDisabled: d,
|
|
271
200
|
element: e
|
|
272
201
|
} = a;
|
|
273
|
-
if (!
|
|
202
|
+
if (!t || d) {
|
|
274
203
|
l({
|
|
275
|
-
type:
|
|
204
|
+
type: o.RESET,
|
|
276
205
|
payload: {
|
|
277
206
|
id: e.id,
|
|
278
207
|
items: []
|
|
@@ -281,110 +210,113 @@ const ue = (n, A) => {
|
|
|
281
210
|
return;
|
|
282
211
|
}
|
|
283
212
|
const {
|
|
284
|
-
level:
|
|
213
|
+
level: r
|
|
285
214
|
} = e.metadata, {
|
|
286
|
-
id:
|
|
287
|
-
marker:
|
|
215
|
+
id: n,
|
|
216
|
+
marker: s
|
|
288
217
|
} = e, {
|
|
289
|
-
signal:
|
|
218
|
+
signal: c
|
|
290
219
|
} = new AbortController();
|
|
291
220
|
l({
|
|
292
|
-
type:
|
|
221
|
+
type: o.LOAD_DATA,
|
|
293
222
|
payload: {
|
|
294
|
-
id:
|
|
223
|
+
id: n
|
|
295
224
|
}
|
|
296
|
-
}),
|
|
297
|
-
signal:
|
|
298
|
-
marker:
|
|
225
|
+
}), m({
|
|
226
|
+
signal: c,
|
|
227
|
+
marker: s,
|
|
299
228
|
searchInput: "",
|
|
300
|
-
level:
|
|
301
|
-
ancestorId:
|
|
229
|
+
level: r + 1,
|
|
230
|
+
ancestorId: n,
|
|
302
231
|
onlySelectableOptions: !1
|
|
303
232
|
}).then((z) => {
|
|
304
|
-
const
|
|
233
|
+
const G = z.options.map((C) => (e.children.push(C.value), u(C)));
|
|
305
234
|
l({
|
|
306
|
-
type:
|
|
235
|
+
type: o.LOAD_SUCCESS,
|
|
307
236
|
payload: {
|
|
308
|
-
id:
|
|
309
|
-
items:
|
|
237
|
+
id: n,
|
|
238
|
+
items: G,
|
|
310
239
|
marker: z.marker
|
|
311
240
|
}
|
|
312
241
|
});
|
|
313
242
|
}).catch(() => {
|
|
314
243
|
l({
|
|
315
|
-
type:
|
|
244
|
+
type: o.LOAD_ERROR,
|
|
316
245
|
payload: {
|
|
317
|
-
id:
|
|
246
|
+
id: n
|
|
318
247
|
}
|
|
319
248
|
});
|
|
320
249
|
});
|
|
321
|
-
}, [
|
|
322
|
-
const
|
|
323
|
-
level:
|
|
324
|
-
} =
|
|
250
|
+
}, [m, u]), j = y((a) => {
|
|
251
|
+
const t = _[a], {
|
|
252
|
+
level: d
|
|
253
|
+
} = t.metadata, {
|
|
325
254
|
id: e,
|
|
326
|
-
marker:
|
|
327
|
-
} =
|
|
328
|
-
signal:
|
|
255
|
+
marker: r
|
|
256
|
+
} = t, {
|
|
257
|
+
signal: n
|
|
329
258
|
} = new AbortController();
|
|
330
259
|
l({
|
|
331
|
-
type:
|
|
260
|
+
type: o.LOAD_DATA,
|
|
332
261
|
payload: {
|
|
333
262
|
id: e
|
|
334
263
|
}
|
|
335
|
-
}),
|
|
336
|
-
signal:
|
|
337
|
-
marker:
|
|
338
|
-
searchInput:
|
|
339
|
-
level:
|
|
340
|
-
ancestorId: e !==
|
|
264
|
+
}), m({
|
|
265
|
+
signal: n,
|
|
266
|
+
marker: r,
|
|
267
|
+
searchInput: p,
|
|
268
|
+
level: p === "" ? d + 1 : null,
|
|
269
|
+
ancestorId: e !== i.id ? e.toString() : null,
|
|
341
270
|
onlySelectableOptions: !1
|
|
342
|
-
}).then((
|
|
343
|
-
const
|
|
271
|
+
}).then((s) => {
|
|
272
|
+
const c = s.options.map(u);
|
|
344
273
|
l({
|
|
345
|
-
type:
|
|
274
|
+
type: o.LOAD_SUCCESS,
|
|
346
275
|
payload: {
|
|
347
276
|
id: e,
|
|
348
|
-
items:
|
|
349
|
-
marker:
|
|
277
|
+
items: c,
|
|
278
|
+
marker: s.marker
|
|
350
279
|
}
|
|
351
280
|
});
|
|
352
281
|
}).catch(() => {
|
|
353
282
|
l({
|
|
354
|
-
type:
|
|
283
|
+
type: o.LOAD_ERROR,
|
|
355
284
|
payload: {
|
|
356
285
|
id: e,
|
|
357
|
-
marker:
|
|
286
|
+
marker: r
|
|
358
287
|
}
|
|
359
288
|
});
|
|
360
289
|
});
|
|
361
|
-
}, [
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
290
|
+
}, [m, u, p, _]), M = b.nodes.length === 0 || b.nodes[0].children.length === 0 && b.nodes[0].id === i.id, q = y((a) => {
|
|
291
|
+
const {
|
|
292
|
+
metadata: t
|
|
293
|
+
} = a.element;
|
|
294
|
+
X(t) && x.includes(t.level) ? R(a) : (a.isSelected = !1, a.treeState.selectedIds.delete(a.element.id));
|
|
295
|
+
}, [x, R]);
|
|
296
|
+
return /* @__PURE__ */ $("div", {
|
|
297
|
+
children: [O && /* @__PURE__ */ v("div", {
|
|
298
|
+
className: I.noResultOption,
|
|
299
|
+
children: /* @__PURE__ */ v(H, {
|
|
300
|
+
"aria-label": B,
|
|
301
|
+
className: I.loadingIndicator
|
|
368
302
|
})
|
|
369
|
-
}), M && !
|
|
370
|
-
className:
|
|
303
|
+
}), M && !O ? /* @__PURE__ */ v("div", {
|
|
304
|
+
className: I.noResultOption,
|
|
371
305
|
children: w
|
|
372
|
-
}) : /* @__PURE__ */
|
|
373
|
-
"aria-label":
|
|
374
|
-
data:
|
|
375
|
-
multiSelect:
|
|
306
|
+
}) : !O && /* @__PURE__ */ v(J, {
|
|
307
|
+
"aria-label": k,
|
|
308
|
+
data: b.nodes,
|
|
309
|
+
multiSelect: V,
|
|
376
310
|
onExpand: U,
|
|
377
|
-
onLoadData:
|
|
378
|
-
onNodeSelect:
|
|
379
|
-
|
|
380
|
-
},
|
|
311
|
+
onLoadData: j,
|
|
312
|
+
onNodeSelect: q,
|
|
313
|
+
selectedIds: b.selectedIds,
|
|
381
314
|
size: "large",
|
|
382
|
-
togglableSelect: !0
|
|
383
|
-
withIcons: !1
|
|
315
|
+
togglableSelect: !0
|
|
384
316
|
})]
|
|
385
317
|
});
|
|
386
318
|
};
|
|
387
319
|
export {
|
|
388
|
-
|
|
389
|
-
|
|
320
|
+
Ie as D,
|
|
321
|
+
I as s
|
|
390
322
|
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { RootTreeNode as n } from "../esm/lib/components/combobox-with-api-tree-view/tree-utils.js";
|
|
2
|
+
let s = /* @__PURE__ */ function(r) {
|
|
3
|
+
return r.LOAD_DATA = "LOAD_DATA", r.LOAD_ERROR = "LOAD_DATA_ERROR", r.LOAD_SUCCESS = "LOAD_DATA_SUCCESS", r.LOAD_MORE = "LOAD_DATA_SUCCESS", r.RESET = "RESET", r;
|
|
4
|
+
}({});
|
|
5
|
+
const R = (r, A) => {
|
|
6
|
+
const {
|
|
7
|
+
id: e,
|
|
8
|
+
items: D,
|
|
9
|
+
marker: t
|
|
10
|
+
} = A.payload;
|
|
11
|
+
switch (A.type) {
|
|
12
|
+
case s.LOAD_DATA:
|
|
13
|
+
return {
|
|
14
|
+
...r,
|
|
15
|
+
[e]: {
|
|
16
|
+
...r[e],
|
|
17
|
+
status: "loading"
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
case s.LOAD_ERROR:
|
|
21
|
+
return {
|
|
22
|
+
...r,
|
|
23
|
+
[e]: {
|
|
24
|
+
...r[e],
|
|
25
|
+
marker: t,
|
|
26
|
+
status: "error"
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
case s.LOAD_SUCCESS: {
|
|
30
|
+
const {
|
|
31
|
+
itemsWithParent: u,
|
|
32
|
+
itemsIds: S
|
|
33
|
+
} = D.reduce((d, i) => ({
|
|
34
|
+
itemsWithParent: {
|
|
35
|
+
...d.itemsWithParent,
|
|
36
|
+
[i.id]: {
|
|
37
|
+
...i,
|
|
38
|
+
parent: e,
|
|
39
|
+
children: []
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
itemsIds: [...d.itemsIds, i.id]
|
|
43
|
+
}), {
|
|
44
|
+
itemsWithParent: {},
|
|
45
|
+
itemsIds: []
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
...r,
|
|
49
|
+
[e]: {
|
|
50
|
+
...r[e],
|
|
51
|
+
status: "success",
|
|
52
|
+
marker: t,
|
|
53
|
+
children: [...r[e].children || [], ...S]
|
|
54
|
+
},
|
|
55
|
+
...u
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
case s.RESET:
|
|
59
|
+
return {
|
|
60
|
+
...r,
|
|
61
|
+
[e]: {
|
|
62
|
+
...r[e],
|
|
63
|
+
status: "success",
|
|
64
|
+
marker: t,
|
|
65
|
+
children: []
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
default:
|
|
69
|
+
return r;
|
|
70
|
+
}
|
|
71
|
+
}, E = {
|
|
72
|
+
[n.id]: n
|
|
73
|
+
};
|
|
74
|
+
export {
|
|
75
|
+
s as A,
|
|
76
|
+
E as i,
|
|
77
|
+
R as t
|
|
78
|
+
};
|
|
@@ -8,7 +8,7 @@ import { useIntl as re } from "react-intl";
|
|
|
8
8
|
import I from "../combobox-with-api-pagination/messages.js";
|
|
9
9
|
import { useControllableState as ne } from "../combobox-with-api-pagination/utils/use-controllable-state.js";
|
|
10
10
|
import { s as l, D as ie } from "../../../../chunks/dynamic-loading-tree.js";
|
|
11
|
-
import { jsxs as
|
|
11
|
+
import { jsxs as r, jsx as o } from "react/jsx-runtime";
|
|
12
12
|
const ce = () => /* @__PURE__ */ o($, {
|
|
13
13
|
color: ee,
|
|
14
14
|
height: g,
|
|
@@ -38,31 +38,31 @@ const ce = () => /* @__PURE__ */ o($, {
|
|
|
38
38
|
disabled: D
|
|
39
39
|
} = S, {
|
|
40
40
|
formatMessage: d
|
|
41
|
-
} = re(),
|
|
41
|
+
} = re(), n = te(), [h, T] = V(!1), [t, i] = ne({
|
|
42
42
|
prop: L,
|
|
43
43
|
defaultProp: A,
|
|
44
44
|
onChange: N
|
|
45
45
|
}), [f, x] = V(""), j = ae(null), E = se((e) => {
|
|
46
46
|
x(e);
|
|
47
|
-
}, [x]),
|
|
47
|
+
}, [x]), c = G({
|
|
48
48
|
includesBaseElement: !0,
|
|
49
49
|
virtualFocus: !1,
|
|
50
50
|
value: f,
|
|
51
51
|
setValue: E,
|
|
52
52
|
open: h,
|
|
53
53
|
setOpen: T
|
|
54
|
-
}), C = t.length > 0, v = t.length > 0, F = Q(O,
|
|
55
|
-
return /* @__PURE__ */
|
|
56
|
-
store:
|
|
54
|
+
}), C = t.length > 0, v = t.length > 0, F = Q(O, n);
|
|
55
|
+
return /* @__PURE__ */ r(X, {
|
|
56
|
+
store: c,
|
|
57
57
|
children: [/* @__PURE__ */ o(q, {
|
|
58
|
-
children: /* @__PURE__ */
|
|
58
|
+
children: /* @__PURE__ */ r("div", {
|
|
59
59
|
className: m(l.container, B),
|
|
60
60
|
children: [/* @__PURE__ */ o(F, {
|
|
61
61
|
className: m(l.label, {
|
|
62
62
|
[l.hiddenLabel]: b
|
|
63
63
|
}),
|
|
64
64
|
hideLabel: b
|
|
65
|
-
}), /* @__PURE__ */
|
|
65
|
+
}), /* @__PURE__ */ r("div", {
|
|
66
66
|
className: m(l.comboboxContainer, {
|
|
67
67
|
[l.withChips]: v,
|
|
68
68
|
[l.withComboboxButtons]: C
|
|
@@ -71,25 +71,25 @@ const ce = () => /* @__PURE__ */ o($, {
|
|
|
71
71
|
children: t.map((e) => /* @__PURE__ */ o(Y, {
|
|
72
72
|
label: e.displayValue,
|
|
73
73
|
onDelete: () => {
|
|
74
|
-
const a = t.filter((
|
|
75
|
-
|
|
74
|
+
const a = t.filter((s) => s.value !== e.value);
|
|
75
|
+
i(a);
|
|
76
76
|
},
|
|
77
77
|
tooltip: e.displayValue
|
|
78
78
|
}, e.value))
|
|
79
|
-
}), /* @__PURE__ */
|
|
79
|
+
}), /* @__PURE__ */ r("div", {
|
|
80
80
|
className: l.textInputWrapper,
|
|
81
81
|
children: [/* @__PURE__ */ o(H, {
|
|
82
82
|
ref: j,
|
|
83
83
|
className: l.textInput,
|
|
84
84
|
disabled: D,
|
|
85
|
-
id:
|
|
85
|
+
id: n,
|
|
86
86
|
placeholder: k,
|
|
87
|
-
store:
|
|
87
|
+
store: c
|
|
88
88
|
}), /* @__PURE__ */ o("div", {
|
|
89
89
|
className: l.comboboxButtons,
|
|
90
90
|
children: C ? /* @__PURE__ */ o(J, {
|
|
91
91
|
onClick: () => {
|
|
92
|
-
|
|
92
|
+
i([]);
|
|
93
93
|
},
|
|
94
94
|
render: (e) => /* @__PURE__ */ o(Z, {
|
|
95
95
|
...e,
|
|
@@ -97,14 +97,14 @@ const ce = () => /* @__PURE__ */ o($, {
|
|
|
97
97
|
icon: _,
|
|
98
98
|
size: "x-small"
|
|
99
99
|
}),
|
|
100
|
-
store:
|
|
100
|
+
store: c
|
|
101
101
|
}) : /* @__PURE__ */ o(ce, {})
|
|
102
102
|
})]
|
|
103
103
|
})]
|
|
104
104
|
})]
|
|
105
105
|
})
|
|
106
106
|
}), /* @__PURE__ */ o(K, {
|
|
107
|
-
"aria-labelledby":
|
|
107
|
+
"aria-labelledby": n,
|
|
108
108
|
className: l.popover,
|
|
109
109
|
fitViewport: !0,
|
|
110
110
|
gutter: 8,
|
|
@@ -121,16 +121,16 @@ const ce = () => /* @__PURE__ */ o($, {
|
|
|
121
121
|
noResultMessage: y || d(I.noResults),
|
|
122
122
|
onSelect: (e) => {
|
|
123
123
|
const {
|
|
124
|
-
metadata:
|
|
124
|
+
metadata: a
|
|
125
125
|
} = e.element;
|
|
126
|
-
let
|
|
127
|
-
e.isSelected ? (p && (
|
|
126
|
+
let s = [];
|
|
127
|
+
e.isSelected ? (p && (s = t.filter((u) => u.value !== e.element.id)), s.push({
|
|
128
128
|
value: e.element.id,
|
|
129
|
-
displayValue:
|
|
130
|
-
level:
|
|
131
|
-
selectable:
|
|
132
|
-
ancestors:
|
|
133
|
-
})) :
|
|
129
|
+
displayValue: a.displayValue,
|
|
130
|
+
level: a.level,
|
|
131
|
+
selectable: a.selectable,
|
|
132
|
+
ancestors: a.ancestors
|
|
133
|
+
})) : s = t.filter((u) => u.value !== e.element.id), i(s);
|
|
134
134
|
},
|
|
135
135
|
open: h,
|
|
136
136
|
searchInput: f.trimStart(),
|
|
@@ -2,8 +2,9 @@ import "@box/blueprint-web";
|
|
|
2
2
|
import "@box/tree";
|
|
3
3
|
import "react";
|
|
4
4
|
import "./tree-utils.js";
|
|
5
|
-
import
|
|
5
|
+
import "../../../../chunks/treeReducer.js";
|
|
6
|
+
import { D as n } from "../../../../chunks/dynamic-loading-tree.js";
|
|
6
7
|
import "react/jsx-runtime";
|
|
7
8
|
export {
|
|
8
|
-
|
|
9
|
+
n as DynamicLoadingTree
|
|
9
10
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const r = (
|
|
2
|
-
const
|
|
1
|
+
const r = (e, n, o) => {
|
|
2
|
+
const t = {
|
|
3
3
|
name: n,
|
|
4
|
-
id: `${
|
|
5
|
-
parent:
|
|
4
|
+
id: `${e}_${o}`,
|
|
5
|
+
parent: e,
|
|
6
6
|
children: [],
|
|
7
7
|
metadata: {
|
|
8
|
-
variant:
|
|
8
|
+
variant: o
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
|
-
return
|
|
12
|
-
}, d = {
|
|
11
|
+
return t;
|
|
12
|
+
}, l = (e) => e && typeof e.level == "number", d = {
|
|
13
13
|
name: "Root",
|
|
14
14
|
id: "root",
|
|
15
15
|
parent: null,
|
|
@@ -22,5 +22,6 @@ const r = (t, n, e) => {
|
|
|
22
22
|
};
|
|
23
23
|
export {
|
|
24
24
|
d as RootTreeNode,
|
|
25
|
-
r as getServiceNode
|
|
25
|
+
r as getServiceNode,
|
|
26
|
+
l as hasValidLevel
|
|
26
27
|
};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { LoadingNode, LoadMoreNode, ReloadNode } from '@box/tree';
|
|
2
2
|
import { NodeId } from './types';
|
|
3
|
+
interface Metadata {
|
|
4
|
+
level: number;
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}
|
|
3
7
|
export declare const getServiceNode: (parentId: NodeId, parentName: string, variant: "reload" | "loadMore" | "loading") => LoadMoreNode | ReloadNode | LoadingNode | {
|
|
4
8
|
name: string;
|
|
5
9
|
id: string;
|
|
@@ -9,6 +13,7 @@ export declare const getServiceNode: (parentId: NodeId, parentName: string, vari
|
|
|
9
13
|
variant: "loading" | "loadMore" | "reload";
|
|
10
14
|
};
|
|
11
15
|
};
|
|
16
|
+
export declare const hasValidLevel: (metadata: any) => metadata is Metadata;
|
|
12
17
|
export declare const RootTreeNode: {
|
|
13
18
|
name: string;
|
|
14
19
|
id: string;
|
|
@@ -20,3 +25,4 @@ export declare const RootTreeNode: {
|
|
|
20
25
|
displayValue: string;
|
|
21
26
|
};
|
|
22
27
|
};
|
|
28
|
+
export {};
|