@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.
@@ -1,73 +1,73 @@
1
- import { LoadingIndicator as Z } from "@box/blueprint-web";
2
- import { InlineError as $, Tree as F } from "@box/tree";
3
- import { forwardRef as P, useReducer as ee, useState as A, useMemo as ae, useCallback as u, useEffect as U } from "react";
4
- import { RootTreeNode as m, hasValidLevel as te, getServiceNode as D } from "../esm/lib/components/combobox-with-api-tree-view/tree-utils.js";
5
- import { t as le, i as se, A as o } from "./treeReducer.js";
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 oe = "_container_1wa8l_2", re = "_label_1wa8l_16", de = "_hiddenLabel_1wa8l_28", ie = "_comboboxContainer_1wa8l_31", ce = "_withComboboxButtons_1wa8l_47", me = "_textInputWrapper_1wa8l_63", ue = "_textInput_1wa8l_63", pe = "_comboboxButtons_1wa8l_88", be = "_withChips_1wa8l_95", ye = "_popover_1wa8l_109", _e = "_loadingIndicator_1wa8l_173", he = "_noResultOption_1wa8l_176", C = {
8
- container: oe,
9
- label: re,
10
- hiddenLabel: de,
11
- comboboxContainer: ie,
12
- withComboboxButtons: ce,
13
- textInputWrapper: me,
14
- textInput: ue,
15
- comboboxButtons: pe,
16
- withChips: be,
17
- popover: ye,
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: he
20
- }, ve = (s) => {
21
- const i = [...s.children], {
19
+ noResultOption: ve
20
+ }, fe = (n) => {
21
+ const i = [...n.children], {
22
22
  metadata: c
23
- } = s;
23
+ } = n;
24
24
  return {
25
- ...s,
25
+ ...n,
26
26
  children: i,
27
27
  metadata: {
28
- ...s.metadata,
28
+ ...n.metadata,
29
29
  variant: c.variant,
30
- isLoading: s.status === "loading" && !s.children.length,
30
+ isLoading: n.status === "loading" && !n.children.length,
31
31
  labelName: c.labelName || "",
32
32
  labelValue: c.labelValue || ""
33
33
  }
34
34
  };
35
- }, fe = (s, i) => {
35
+ }, ge = (n, i) => {
36
36
  let c;
37
- return s.children.length && s.status === "loading" && (c = D(i.id, i.metadata.displayValue, "loading")), s.status === "error" && (c = D(i.id, i.metadata.displayValue, "reload")), s.status === "success" && s.marker && (c = D(i.id, i.metadata.displayValue, "loadMore")), c;
38
- }, Ie = /* @__PURE__ */ P(({
39
- ariaLabel: s,
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: w,
43
+ levels: O,
44
44
  selectableLevels: g,
45
- multiselect: W,
46
- open: L,
45
+ multiselect: w,
46
+ open: V,
47
47
  searchInput: p,
48
- noResultMessage: z,
49
- loadingAriaLabel: q
50
- }, G) => {
51
- const [_, l] = ee(le, se), [v, H] = A({
48
+ noResultMessage: q,
49
+ loadingAriaLabel: G
50
+ }, H) => {
51
+ const [_, s] = te(se, oe), [y, J] = A({
52
52
  nodes: [],
53
53
  selectedIds: []
54
- }), [I, y] = A(!1), [S, N] = A(!1), O = ae(() => Math.max(...g), [g]), V = u((e = _) => {
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 n = ve(a), d = fe(a, n);
58
- return d && (t.push(d), n.children.push(d.id)), n;
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
- }, [_]), k = u((e) => {
61
- const t = e.ancestors?.find((n) => n.level === e.level - 1), r = w.find((n) => n.level === e.level);
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: r.displayName,
63
+ labelName: o.displayName,
64
64
  labelValue: t.displayName
65
65
  };
66
- }, [w, p]), h = u((e) => ({
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 !== O,
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
- }), [O]), x = u((e, t) => {
81
- l({
82
- type: o.RESET,
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
- }), l({
88
- type: o.LOAD_SUCCESS,
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
- }), y(!1);
95
- }, [l, y]), E = u(() => {
96
- l({
97
- type: o.LOAD_ERROR,
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
- }), y(!1), N(!0);
102
- }, [l, y, N]), J = u((e, t) => {
103
- const r = new Set(e.map((a) => a.id));
104
- return t.filter((a) => r.has(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
- U(() => {
107
- const e = V(_);
108
- H({
106
+ F(() => {
107
+ const e = k(_);
108
+ J({
109
109
  nodes: e,
110
- selectedIds: J(e, c)
110
+ selectedIds: j(e, c)
111
111
  });
112
- }, [V, c, _, S]), U(() => {
113
- if (!L)
112
+ }, [j, k, c, _, S]), F(() => {
113
+ if (!V)
114
114
  return;
115
115
  const {
116
116
  signal: e
117
117
  } = new AbortController();
118
- y(!0), N(!1), p ? (l({
119
- type: o.RESET,
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 r = t.options.filter((a) => a.selectable).map((a) => {
132
+ const o = t.options.filter((a) => a.selectable).map((a) => {
133
133
  const {
134
- labelName: n,
134
+ labelName: l,
135
135
  labelValue: d
136
- } = k(a);
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 < O,
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: n,
149
+ labelName: l,
150
150
  labelValue: d
151
151
  }
152
152
  };
153
153
  });
154
- x(r, t.marker);
154
+ T(o, t.marker);
155
155
  }).catch(() => {
156
- E();
157
- })) : (l({
158
- type: o.RESET,
156
+ x();
157
+ })) : (s({
158
+ type: r.RESET,
159
159
  payload: {
160
160
  id: m.id,
161
161
  items: []
162
162
  }
163
- }), l({
164
- type: o.LOAD_DATA,
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 r = t.options.map(h);
177
- x(r, t.marker);
176
+ const o = t.options.map(v);
177
+ T(o, t.marker);
178
178
  }).catch(() => {
179
- E();
179
+ x();
180
180
  }));
181
- }, [b, h, L, p, w, O, k, x, E]);
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: r,
185
+ isDisabled: o,
186
186
  element: a
187
187
  } = e;
188
- if (!t || r) {
189
- l({
190
- type: o.RESET,
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: n
199
+ level: l
200
200
  } = a.metadata, {
201
201
  id: d,
202
202
  marker: R
203
203
  } = a, {
204
- signal: T
204
+ signal: C
205
205
  } = new AbortController();
206
- l({
207
- type: o.LOAD_DATA,
206
+ s({
207
+ type: r.LOAD_DATA,
208
208
  payload: {
209
209
  id: d
210
210
  }
211
211
  }), b({
212
- signal: T,
212
+ signal: C,
213
213
  marker: R,
214
214
  searchInput: "",
215
- level: n + 1,
215
+ level: l + 1,
216
216
  ancestorId: d,
217
217
  onlySelectableOptions: !1
218
- }).then((j) => {
219
- const Y = j.options.map((M) => (a.children.push(M.value), h(M)));
220
- l({
221
- type: o.LOAD_SUCCESS,
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: Y,
225
- marker: j.marker
224
+ items: Z,
225
+ marker: U.marker
226
226
  }
227
227
  });
228
228
  }).catch(() => {
229
- l({
230
- type: o.LOAD_ERROR,
229
+ s({
230
+ type: r.LOAD_ERROR,
231
231
  payload: {
232
232
  id: d
233
233
  }
234
234
  });
235
235
  });
236
- }, [b, h]), B = u((e) => {
237
- S && (N(!1), y(!0));
236
+ }, [b, v]), M = u((e) => {
237
+ S && (I(!1), h(!0));
238
238
  const t = _[e], {
239
- level: r
239
+ level: o
240
240
  } = t.metadata, {
241
241
  id: a,
242
- marker: n
242
+ marker: l
243
243
  } = t, {
244
244
  signal: d
245
245
  } = new AbortController();
246
- l({
247
- type: o.LOAD_DATA,
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: n,
253
+ marker: l,
254
254
  searchInput: p,
255
- level: p === "" ? r + 1 : null,
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 T = R.options.map(h);
260
- l({
261
- type: o.LOAD_SUCCESS,
259
+ const C = R.options.map(v);
260
+ s({
261
+ type: r.LOAD_SUCCESS,
262
262
  payload: {
263
263
  id: a,
264
- items: T,
264
+ items: C,
265
265
  marker: R.marker
266
266
  }
267
- }), y(!1);
267
+ }), h(!1);
268
268
  }).catch(() => {
269
- l({
270
- type: o.LOAD_ERROR,
269
+ s({
270
+ type: r.LOAD_ERROR,
271
271
  payload: {
272
272
  id: a,
273
- marker: n
273
+ marker: l
274
274
  }
275
275
  });
276
276
  });
277
- }, [b, S, h, p, _]), Q = v.nodes.length === 0 || v.nodes[0].children.length === 0 && v.nodes[0].id === m.id, X = u((e) => {
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
- te(t) && g.includes(t.level) ? i(e) : (e.isSelected = !1, e.treeState.selectedIds.delete(e.element.id));
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
- B("root");
296
+ M("root");
286
297
  }
287
298
  }) : /* @__PURE__ */ ne("div", {
288
- children: [I && /* @__PURE__ */ f("div", {
289
- className: C.noResultOption,
290
- children: /* @__PURE__ */ f(Z, {
291
- "aria-label": q,
292
- className: C.loadingIndicator
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 && !I ? /* @__PURE__ */ f("div", {
295
- className: C.noResultOption,
296
- children: z
297
- }) : !I && /* @__PURE__ */ f(F, {
298
- ref: G,
299
- "aria-label": s,
300
- data: v.nodes,
301
- multiSelect: W,
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: B,
304
- onNodeSelect: X,
305
- selectedIds: v.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
- Ie as D,
313
- C as s
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.7",
3
+ "version": "1.23.8",
4
4
  "peerDependencies": {
5
5
  "@ariakit/react": "0.4.15",
6
- "@box/blueprint-web": "^12.115.1",
7
- "@box/blueprint-web-assets": "^4.92.0",
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.7",
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.1",
19
- "@box/blueprint-web-assets": "^4.92.0",
20
- "@box/storybook-utils": "^0.15.7",
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
  },