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