@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.
@@ -1,148 +1,77 @@
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
- container: Q,
8
- disabled: X,
9
- label: Y,
10
- hiddenLabel: Z,
11
- comboboxContainer: $,
12
- withComboboxButtons: F,
13
- error: ee,
14
- textInputWrapper: ae,
15
- textInput: te,
16
- errorIcon: ne,
17
- comboboxButtons: le,
18
- withChips: oe,
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
- };
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
- }({});
31
- const ue = (n, A) => {
32
- const {
33
- id: i,
34
- items: u,
35
- marker: b
36
- } = A.payload;
37
- switch (A.type) {
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: W
39
+ loadingAriaLabel: B
109
40
  }) => {
110
- const [y, l] = H(ue, {
111
- [r.id]: r
112
- }), [D, B] = k({
41
+ const [_, l] = K(Y, Z), [b, W] = L({
113
42
  nodes: [],
114
43
  selectedIds: []
115
- }), [I, x] = k(!1), E = J(() => Math.max(...h), [h]), g = O((a = y) => {
116
- const s = [];
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 _ = [...e.children], {
119
- metadata: o
120
- } = e, d = {
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: o.variant,
54
+ variant: n.variant,
126
55
  isLoading: e.status === "loading" && !e.children.length,
127
- labelName: o.labelName || "",
128
- labelValue: o.labelValue || ""
56
+ labelName: n.labelName || "",
57
+ labelValue: n.labelValue || ""
129
58
  }
130
59
  };
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) => {
135
- var _;
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
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
- }, [b, c]), S = O((a) => ({
70
+ }, [S, p]), u = y((a) => ({
142
71
  id: a.value,
143
72
  name: a.displayValue,
144
- parent: r.id,
145
- isBranch: a.level !== E,
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
- }), [E]);
156
- V(() => {
157
- B({
158
- nodes: g(y),
159
- selectedIds: i
84
+ }), [h]);
85
+ T(() => {
86
+ W({
87
+ nodes: A(_),
88
+ selectedIds: E
160
89
  });
161
- }, [g, i, y]), V(() => {
162
- if (!f)
90
+ }, [A, E, _]), T(() => {
91
+ if (!N)
163
92
  return;
164
93
  const {
165
94
  signal: a
166
95
  } = new AbortController();
167
- x(!0), c ? (l({
168
- type: t.RESET,
96
+ f(!0), p ? (l({
97
+ type: o.RESET,
169
98
  payload: {
170
- id: r.id,
99
+ id: i.id,
171
100
  items: []
172
101
  }
173
- }), u({
102
+ }), m({
174
103
  signal: a,
175
104
  marker: null,
176
- searchInput: c,
105
+ searchInput: p,
177
106
  level: null,
178
107
  onlySelectableOptions: !1,
179
108
  ancestorId: null
180
- }).then((s) => {
181
- const m = s.options.map((e) => {
109
+ }).then((t) => {
110
+ const d = t.options.map((e) => {
182
111
  const {
183
- labelName: _,
184
- labelValue: o
185
- } = N(e);
112
+ labelName: r,
113
+ labelValue: n
114
+ } = D(e);
186
115
  return {
187
116
  id: e.value,
188
117
  name: e.displayValue,
189
- parent: r.id,
190
- isBranch: e.level < E,
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: o
127
+ labelName: r,
128
+ labelValue: n
200
129
  }
201
130
  };
202
131
  });
203
132
  l({
204
- type: t.RESET,
133
+ type: o.RESET,
205
134
  payload: {
206
- id: r.id,
135
+ id: i.id,
207
136
  items: []
208
137
  }
209
138
  }), l({
210
- type: t.LOAD_SUCCESS,
139
+ type: o.LOAD_SUCCESS,
211
140
  payload: {
212
- id: r.id,
213
- items: m,
214
- marker: s.marker
141
+ id: i.id,
142
+ items: d,
143
+ marker: t.marker
215
144
  }
216
- }), x(!1);
145
+ }), f(!1);
217
146
  }).catch(() => {
218
147
  l({
219
- type: t.LOAD_ERROR,
148
+ type: o.LOAD_ERROR,
220
149
  payload: {
221
- id: r.id
150
+ id: i.id
222
151
  }
223
- }), x(!1);
152
+ }), f(!1);
224
153
  })) : (l({
225
- type: t.RESET,
154
+ type: o.RESET,
226
155
  payload: {
227
- id: r.id,
156
+ id: i.id,
228
157
  items: []
229
158
  }
230
159
  }), l({
231
- type: t.LOAD_DATA,
160
+ type: o.LOAD_DATA,
232
161
  payload: {
233
- id: r.id
162
+ id: i.id
234
163
  }
235
- }), u({
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((s) => {
243
- const m = s.options.map(S);
171
+ }).then((t) => {
172
+ const d = t.options.map(u);
244
173
  l({
245
- type: t.RESET,
174
+ type: o.RESET,
246
175
  payload: {
247
- id: r.id,
176
+ id: i.id,
248
177
  items: []
249
178
  }
250
179
  }), l({
251
- type: t.LOAD_SUCCESS,
180
+ type: o.LOAD_SUCCESS,
252
181
  payload: {
253
- id: r.id,
254
- items: m,
255
- marker: s.marker
182
+ id: i.id,
183
+ items: d,
184
+ marker: t.marker
256
185
  }
257
- }), x(!1);
186
+ }), f(!1);
258
187
  }).catch(() => {
259
188
  l({
260
- type: t.LOAD_ERROR,
189
+ type: o.LOAD_ERROR,
261
190
  payload: {
262
- id: r.id
191
+ id: i.id
263
192
  }
264
- }), x(!1);
193
+ }), f(!1);
265
194
  }));
266
- }, [u, S, f, c, b, E, N]);
267
- const U = O((a) => {
195
+ }, [m, u, N, p, S, h, D]);
196
+ const U = y((a) => {
268
197
  const {
269
- isExpanded: s,
270
- isDisabled: m,
198
+ isExpanded: t,
199
+ isDisabled: d,
271
200
  element: e
272
201
  } = a;
273
- if (!s || m) {
202
+ if (!t || d) {
274
203
  l({
275
- type: t.RESET,
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: o,
287
- marker: d
215
+ id: n,
216
+ marker: s
288
217
  } = e, {
289
- signal: p
218
+ signal: c
290
219
  } = new AbortController();
291
220
  l({
292
- type: t.LOAD_DATA,
221
+ type: o.LOAD_DATA,
293
222
  payload: {
294
- id: o
223
+ id: n
295
224
  }
296
- }), u({
297
- signal: p,
298
- marker: d,
225
+ }), m({
226
+ signal: c,
227
+ marker: s,
299
228
  searchInput: "",
300
- level: _ + 1,
301
- ancestorId: o,
229
+ level: r + 1,
230
+ ancestorId: n,
302
231
  onlySelectableOptions: !1
303
232
  }).then((z) => {
304
- const j = z.options.map((T) => (e.children.push(T.value), S(T)));
233
+ const G = z.options.map((C) => (e.children.push(C.value), u(C)));
305
234
  l({
306
- type: t.LOAD_SUCCESS,
235
+ type: o.LOAD_SUCCESS,
307
236
  payload: {
308
- id: o,
309
- items: j,
237
+ id: n,
238
+ items: G,
310
239
  marker: z.marker
311
240
  }
312
241
  });
313
242
  }).catch(() => {
314
243
  l({
315
- type: t.LOAD_ERROR,
244
+ type: o.LOAD_ERROR,
316
245
  payload: {
317
- id: o
246
+ id: n
318
247
  }
319
248
  });
320
249
  });
321
- }, [u, S]), P = O((a) => {
322
- const s = y[a], {
323
- level: m
324
- } = s.metadata, {
250
+ }, [m, u]), j = y((a) => {
251
+ const t = _[a], {
252
+ level: d
253
+ } = t.metadata, {
325
254
  id: e,
326
- marker: _
327
- } = s, {
328
- signal: o
255
+ marker: r
256
+ } = t, {
257
+ signal: n
329
258
  } = new AbortController();
330
259
  l({
331
- type: t.LOAD_DATA,
260
+ type: o.LOAD_DATA,
332
261
  payload: {
333
262
  id: e
334
263
  }
335
- }), u({
336
- signal: o,
337
- marker: _,
338
- searchInput: c,
339
- level: c === "" ? m + 1 : null,
340
- ancestorId: e !== r.id ? e.toString() : null,
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((d) => {
343
- const p = d.options.map(S);
271
+ }).then((s) => {
272
+ const c = s.options.map(u);
344
273
  l({
345
- type: t.LOAD_SUCCESS,
274
+ type: o.LOAD_SUCCESS,
346
275
  payload: {
347
276
  id: e,
348
- items: p,
349
- marker: d.marker
277
+ items: c,
278
+ marker: s.marker
350
279
  }
351
280
  });
352
281
  }).catch(() => {
353
282
  l({
354
- type: t.LOAD_ERROR,
283
+ type: o.LOAD_ERROR,
355
284
  payload: {
356
285
  id: e,
357
- marker: _
286
+ marker: r
358
287
  }
359
288
  });
360
289
  });
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", {
364
- className: C.noResultOption,
365
- children: /* @__PURE__ */ R(q, {
366
- "aria-label": W,
367
- className: C.loadingIndicator
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 && !I ? /* @__PURE__ */ R("div", {
370
- className: C.noResultOption,
303
+ }), M && !O ? /* @__PURE__ */ v("div", {
304
+ className: I.noResultOption,
371
305
  children: w
372
- }) : /* @__PURE__ */ R(G, {
373
- "aria-label": n,
374
- data: D.nodes,
375
- multiSelect: v,
306
+ }) : !O && /* @__PURE__ */ v(J, {
307
+ "aria-label": k,
308
+ data: b.nodes,
309
+ multiSelect: V,
376
310
  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));
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
- xe as D,
389
- C as s
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 n, jsx as o } from "react/jsx-runtime";
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(), i = te(), [h, T] = V(!1), [t, c] = ne({
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]), u = G({
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, i);
55
- return /* @__PURE__ */ n(X, {
56
- store: u,
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__ */ n("div", {
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__ */ n("div", {
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((r) => r.value !== e.value);
75
- c(a);
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__ */ n("div", {
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: i,
85
+ id: n,
86
86
  placeholder: k,
87
- store: u
87
+ store: c
88
88
  }), /* @__PURE__ */ o("div", {
89
89
  className: l.comboboxButtons,
90
90
  children: C ? /* @__PURE__ */ o(J, {
91
91
  onClick: () => {
92
- c([]);
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: u
100
+ store: c
101
101
  }) : /* @__PURE__ */ o(ce, {})
102
102
  })]
103
103
  })]
104
104
  })]
105
105
  })
106
106
  }), /* @__PURE__ */ o(K, {
107
- "aria-labelledby": i,
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: s
124
+ metadata: a
125
125
  } = e.element;
126
- let a = [];
127
- e.isSelected ? (p && (a = t.filter((r) => r.value !== e.element.id)), a.push({
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: s.displayValue,
130
- level: s.level,
131
- selectable: s.selectable,
132
- ancestors: s.ancestors
133
- })) : a = t.filter((r) => r.value !== e.element.id), c(a);
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 { D as e } from "../../../../chunks/dynamic-loading-tree.js";
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
- e as DynamicLoadingTree
9
+ n as DynamicLoadingTree
9
10
  };
@@ -1,15 +1,15 @@
1
- const r = (t, n, e) => {
2
- const o = {
1
+ const r = (e, n, o) => {
2
+ const t = {
3
3
  name: n,
4
- id: `${t}_${e}`,
5
- parent: t,
4
+ id: `${e}_${o}`,
5
+ parent: e,
6
6
  children: [],
7
7
  metadata: {
8
- variant: e
8
+ variant: o
9
9
  }
10
10
  };
11
- return o;
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
  };
@@ -0,0 +1,6 @@
1
+ import { i, t as a } from "../../../../chunks/treeReducer.js";
2
+ import "./tree-utils.js";
3
+ export {
4
+ i as initialTreeState,
5
+ a as treeReducer
6
+ };
@@ -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 {};
@@ -0,0 +1,3 @@
1
+ import { TreeState, TreeStateUpdateAction } from './types';
2
+ export declare const treeReducer: (state: TreeState, action: TreeStateUpdateAction) => TreeState;
3
+ export declare const initialTreeState: TreeState;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/combobox-with-api",
3
- "version": "0.35.2",
3
+ "version": "0.36.0",
4
4
  "peerDependencies": {
5
5
  "@ariakit/react": "0.4.15",
6
6
  "@box/blueprint-web": "^10.3.1",