@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.
@@ -1,77 +1,77 @@
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 b, useEffect as T } from "react";
4
- import { getServiceNode as R, 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 S } from "react/jsx-runtime";
7
- import '../styles/dynamic-loading-tree.css';const P = "_container_z81ug_1", F = "_disabled_z81ug_12", ee = "_label_z81ug_15", ae = "_hiddenLabel_z81ug_27", te = "_comboboxContainer_z81ug_30", le = "_withComboboxButtons_z81ug_46", ne = "_error_z81ug_54", oe = "_textInputWrapper_z81ug_62", se = "_textInput_z81ug_62", ie = "_errorIcon_z81ug_84", re = "_comboboxButtons_z81ug_87", de = "_withChips_z81ug_94", ce = "_inlineError_z81ug_104", ue = "_popover_z81ug_108", pe = "_option_z81ug_134", me = "_indicator_z81ug_157", _e = "_indicatorIcon_z81ug_166", be = "_optionWithIndicator_z81ug_169", ye = "_loadingIndicator_z81ug_172", ge = "_noResultOption_z81ug_175", E = {
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: ue,
22
- option: pe,
23
- indicator: me,
24
- indicatorIcon: _e,
25
- optionWithIndicator: be,
26
- loadingIndicator: ye,
27
- noResultOption: ge
28
- }, Ee = ({
29
- ariaLabel: k,
30
- onSelect: N,
31
- selectedNodes: f,
32
- defaultFetcher: p,
33
- levels: O,
34
- selectableLevels: h,
35
- multiselect: V,
36
- open: x,
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: w,
39
- loadingAriaLabel: B
38
+ noResultMessage: U,
39
+ loadingAriaLabel: q
40
40
  }) => {
41
- const [m, l] = K(Y, Z), [y, W] = L({
41
+ const [b, n] = $(ee, ae), [y, G] = O({
42
42
  nodes: [],
43
43
  selectedIds: []
44
- }), [I, g] = L(!1), v = Q(() => Math.max(...h), [h]), A = b((a = m) => {
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: n
49
- } = e, s = {
48
+ metadata: o
49
+ } = e, l = {
50
50
  ...e,
51
51
  children: r,
52
52
  metadata: {
53
53
  ...e.metadata,
54
- variant: n.variant,
54
+ variant: o.variant,
55
55
  isLoading: e.status === "loading" && !e.children.length,
56
- labelName: n.labelName || "",
57
- labelValue: n.labelValue || ""
56
+ labelName: o.labelName || "",
57
+ labelValue: o.labelValue || ""
58
58
  }
59
59
  };
60
- let c;
61
- return e.children.length && e.status === "loading" && (c = R(s.id, s.metadata.displayValue, "loading")), e.status === "error" && (c = R(s.id, s.metadata.displayValue, "reload")), e.status === "success" && e.marker && (c = R(s.id, s.metadata.displayValue, "loadMore")), c && (t.push(c), s.children.push(c.id)), s;
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
- }, [m]), D = b((a) => {
63
+ }, [b]), C = p((a) => {
64
64
  var r;
65
- const t = (r = a.ancestors) == null ? void 0 : r.find((n) => n.level === a.level - 1), d = O.find((n) => n.level === a.level);
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: d.displayName,
67
+ labelName: i.displayName,
68
68
  labelValue: t.displayName
69
69
  };
70
- }, [O, u]), _ = b((a) => ({
70
+ }, [S, u]), g = p((a) => ({
71
71
  id: a.value,
72
72
  name: a.displayValue,
73
- parent: i.id,
74
- isBranch: a.level !== v,
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
- }), [v]);
85
- T(() => {
86
- W({
87
- nodes: A(m),
88
- selectedIds: f
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
- }, [A, f, m]), T(() => {
91
- if (!x)
112
+ }, [D, T, b, N]), W(() => {
113
+ if (!A)
92
114
  return;
93
115
  const {
94
116
  signal: a
95
117
  } = new AbortController();
96
- g(!0), u ? (l({
97
- type: o.RESET,
118
+ _(!0), I(!1), u ? (n({
119
+ type: s.RESET,
98
120
  payload: {
99
- id: i.id,
121
+ id: c.id,
100
122
  items: []
101
123
  }
102
- }), p({
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 d = t.options.filter((e) => e.selectable).map((e) => {
132
+ const i = t.options.filter((e) => e.selectable).map((e) => {
111
133
  const {
112
134
  labelName: r,
113
- labelValue: n
114
- } = D(e);
135
+ labelValue: o
136
+ } = C(e);
115
137
  return {
116
138
  id: e.value,
117
139
  name: e.displayValue,
118
- parent: i.id,
119
- isBranch: e.level < v,
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: n
150
+ labelValue: o
129
151
  }
130
152
  };
131
153
  });
132
- l({
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
- l({
148
- type: o.LOAD_ERROR,
149
- payload: {
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: i.id,
160
+ id: c.id,
157
161
  items: []
158
162
  }
159
- }), l({
160
- type: o.LOAD_DATA,
163
+ }), n({
164
+ type: s.LOAD_DATA,
161
165
  payload: {
162
- id: i.id
166
+ id: c.id
163
167
  }
164
- }), p({
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 d = t.options.map(_);
173
- l({
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
- l({
189
- type: o.LOAD_ERROR,
190
- payload: {
191
- id: i.id
192
- }
193
- }), g(!1);
179
+ k();
194
180
  }));
195
- }, [p, _, x, u, O, v, D]);
196
- const U = b((a) => {
181
+ }, [m, g, A, u, S, f, C]);
182
+ const H = p((a) => {
197
183
  const {
198
184
  isExpanded: t,
199
- isDisabled: d,
185
+ isDisabled: i,
200
186
  element: e
201
187
  } = a;
202
- if (!t || d) {
203
- l({
204
- type: o.RESET,
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: n,
216
- marker: s
201
+ id: o,
202
+ marker: l
217
203
  } = e, {
218
- signal: c
204
+ signal: d
219
205
  } = new AbortController();
220
- l({
221
- type: o.LOAD_DATA,
206
+ n({
207
+ type: s.LOAD_DATA,
222
208
  payload: {
223
- id: n
209
+ id: o
224
210
  }
225
- }), p({
226
- signal: c,
227
- marker: s,
211
+ }), m({
212
+ signal: d,
213
+ marker: l,
228
214
  searchInput: "",
229
215
  level: r + 1,
230
- ancestorId: n,
216
+ ancestorId: o,
231
217
  onlySelectableOptions: !1
232
- }).then((z) => {
233
- const G = z.options.map((C) => (e.children.push(C.value), _(C)));
234
- l({
235
- type: o.LOAD_SUCCESS,
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: n,
238
- items: G,
239
- marker: z.marker
223
+ id: o,
224
+ items: Q,
225
+ marker: w.marker
240
226
  }
241
227
  });
242
228
  }).catch(() => {
243
- l({
244
- type: o.LOAD_ERROR,
229
+ n({
230
+ type: s.LOAD_ERROR,
245
231
  payload: {
246
- id: n
232
+ id: o
247
233
  }
248
234
  });
249
235
  });
250
- }, [p, _]), j = b((a) => {
251
- const t = m[a], {
252
- level: d
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: n
244
+ signal: o
258
245
  } = new AbortController();
259
- l({
260
- type: o.LOAD_DATA,
246
+ n({
247
+ type: s.LOAD_DATA,
261
248
  payload: {
262
249
  id: e
263
250
  }
264
- }), p({
265
- signal: n,
251
+ }), m({
252
+ signal: o,
266
253
  marker: r,
267
254
  searchInput: u,
268
- level: u === "" ? d + 1 : null,
269
- ancestorId: e !== i.id ? e.toString() : null,
255
+ level: u === "" ? i + 1 : null,
256
+ ancestorId: e !== c.id ? e.toString() : null,
270
257
  onlySelectableOptions: !1
271
- }).then((s) => {
272
- const c = s.options.map(_);
273
- l({
274
- type: o.LOAD_SUCCESS,
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: c,
278
- marker: s.marker
264
+ items: d,
265
+ marker: l.marker
279
266
  }
280
- });
267
+ }), _(!1);
281
268
  }).catch(() => {
282
- l({
283
- type: o.LOAD_ERROR,
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
- }, [p, _, u, m]), M = y.nodes.length === 0 || y.nodes[0].children.length === 0 && y.nodes[0].id === i.id, q = b((a) => {
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
- X(t) && h.includes(t.level) ? N(a) : (a.isSelected = !1, a.treeState.selectedIds.delete(a.element.id));
295
- }, [h, N]);
296
- return /* @__PURE__ */ $("div", {
297
- children: [I && /* @__PURE__ */ S("div", {
298
- className: E.noResultOption,
299
- children: /* @__PURE__ */ S(H, {
300
- "aria-label": B,
301
- className: E.loadingIndicator
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
- }), M && !I ? /* @__PURE__ */ S("div", {
304
- className: E.noResultOption,
305
- children: w
306
- }) : !I && /* @__PURE__ */ S(J, {
307
- "aria-label": k,
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: V,
310
- onExpand: U,
311
- onLoadData: j,
312
- onNodeSelect: q,
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
- Ee as D,
321
- E as s
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.5",
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.5",
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.2",
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",