@box/combobox-with-api 1.15.7 → 1.16.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,167 +1,164 @@
1
1
  import { useComboboxStore as H, ComboboxProvider as J, PopoverAnchor as Q, Combobox as Y, ComboboxCancel as Z, ComboboxPopover as _, ComboboxItem as $ } from "@ariakit/react";
2
2
  import { useLabelable as ee, ChipsGroup as oe, InputChip as te, IconButton as le } from "@box/blueprint-web";
3
- import { XMark as ae, Search as se } from "@box/blueprint-web-assets/icons/Fill";
4
- import { IconIconOnLightSecondary as re, Size6 as w, Size1 as ne } from "@box/blueprint-web-assets/tokens/tokens";
5
- import d from "clsx";
6
- import { forwardRef as ie, useId as ce, useState as L, useRef as y } from "react";
3
+ import { XMark as ae, Search as re } from "@box/blueprint-web-assets/icons/Fill";
4
+ import { Size6 as S, Size1 as se, IconIconOnLightSecondary as ne } from "@box/blueprint-web-assets/tokens/tokens";
5
+ import p from "clsx";
6
+ import { forwardRef as ie, useId as ce, useState as w, useRef as L } from "react";
7
7
  import { useIntl as ue } from "react-intl";
8
- import N from "../combobox-with-api-pagination/messages.js";
8
+ import y from "../combobox-with-api-pagination/messages.js";
9
9
  import { useControllableState as me } from "../combobox-with-api-pagination/utils/use-controllable-state.js";
10
- import { s as a, D as pe } from "../../../../chunks/dynamic-loading-tree.js";
11
- import { jsxs as n, jsx as l } from "react/jsx-runtime";
12
- const de = () => /* @__PURE__ */ l(se, {
13
- color: re,
14
- height: w,
10
+ import { s as l, D as pe } from "../../../../chunks/dynamic-loading-tree.js";
11
+ import { jsxs as s, jsx as o } from "react/jsx-runtime";
12
+ const de = () => /* @__PURE__ */ o(re, {
13
+ color: ne,
14
+ height: S,
15
15
  role: "presentation",
16
16
  style: {
17
- padding: ne,
17
+ padding: se,
18
18
  boxSizing: "border-box"
19
19
  },
20
- width: w
21
- }), Re = /* @__PURE__ */ ie(function(A, he) {
20
+ width: S
21
+ }), Oe = /* @__PURE__ */ ie(function(N, he) {
22
22
  const {
23
- className: R,
23
+ className: A,
24
24
  closeOnSelection: O = !1,
25
- dataTargetId: B,
26
- defaultFetcher: z,
27
- defaultValue: D = [],
28
- disabled: M,
29
- hideLabel: b,
30
- initialOpen: P = !1,
31
- label: T,
32
- levels: W,
33
- loadingAriaLabel: k,
34
- multiselect: h = !1,
35
- noResultMessage: E,
36
- onValueChange: F,
37
- onOpenChange: i,
25
+ dataTargetId: R,
26
+ defaultFetcher: T,
27
+ defaultValue: B = [],
28
+ disabled: z,
29
+ hideLabel: d,
30
+ initialOpen: D = !1,
31
+ label: M,
32
+ levels: P,
33
+ loadingAriaLabel: W,
34
+ multiselect: b = !1,
35
+ noResultMessage: k,
36
+ onValueChange: E,
37
+ onOpenChange: F,
38
38
  placeholder: j,
39
39
  portalElement: G,
40
40
  selectableLevels: K,
41
41
  treeAriaLabel: U,
42
42
  value: X
43
- } = A, {
44
- formatMessage: f
45
- } = ue(), c = ce(), [C, g] = L(P), [s, u] = me({
43
+ } = N, {
44
+ formatMessage: h
45
+ } = ue(), n = ce(), [f, C] = w(D), [a, i] = me({
46
46
  prop: X,
47
- defaultProp: D,
48
- onChange: F
49
- }), [x, v] = L(""), V = y(null), m = H({
47
+ defaultProp: B,
48
+ onChange: E
49
+ }), [g, x] = w(""), v = L(null), c = H({
50
50
  includesBaseElement: !0,
51
51
  virtualFocus: !1,
52
- value: x,
52
+ value: g,
53
53
  setValue: (e) => {
54
- v(e);
54
+ x(e);
55
55
  },
56
- open: C,
56
+ open: f,
57
57
  setOpen: (e) => {
58
- g(e), i == null || i(e);
58
+ C(e), F?.(e);
59
59
  }
60
- }), I = s.length > 0, S = s.length > 0, q = ee(T, c), p = y(null);
61
- return /* @__PURE__ */ n(J, {
62
- store: m,
63
- children: [/* @__PURE__ */ l(Q, {
64
- children: /* @__PURE__ */ n("div", {
65
- className: d(a.container, R),
66
- children: [/* @__PURE__ */ l(q, {
67
- className: d(a.label, {
68
- [a.hiddenLabel]: b
60
+ }), I = a.length > 0, V = a.length > 0, q = ee(M, n), u = L(null);
61
+ return /* @__PURE__ */ s(J, {
62
+ store: c,
63
+ children: [/* @__PURE__ */ o(Q, {
64
+ children: /* @__PURE__ */ s("div", {
65
+ className: p(l.container, A),
66
+ children: [/* @__PURE__ */ o(q, {
67
+ className: p(l.label, {
68
+ [l.hiddenLabel]: d
69
69
  }),
70
- hideLabel: b
71
- }), /* @__PURE__ */ n("div", {
72
- className: d(a.comboboxContainer, {
73
- [a.withChips]: S,
74
- [a.withComboboxButtons]: I
70
+ hideLabel: d
71
+ }), /* @__PURE__ */ s("div", {
72
+ className: p(l.comboboxContainer, {
73
+ [l.withChips]: V,
74
+ [l.withComboboxButtons]: I
75
75
  }),
76
- children: [S && /* @__PURE__ */ l(oe, {
77
- children: s.map((e) => /* @__PURE__ */ l(te, {
76
+ children: [V && /* @__PURE__ */ o(oe, {
77
+ children: a.map((e) => /* @__PURE__ */ o(te, {
78
78
  label: e.displayValue,
79
79
  onDelete: () => {
80
- const o = s.filter((t) => t.value !== e.value);
81
- u(o);
80
+ const t = a.filter((r) => r.value !== e.value);
81
+ i(t);
82
82
  },
83
83
  tooltip: e.displayValue
84
84
  }, e.value))
85
- }), /* @__PURE__ */ n("div", {
86
- className: a.textInputWrapper,
87
- children: [/* @__PURE__ */ l(Y, {
88
- ref: V,
85
+ }), /* @__PURE__ */ s("div", {
86
+ className: l.textInputWrapper,
87
+ children: [/* @__PURE__ */ o(Y, {
88
+ ref: v,
89
89
  "aria-haspopup": "tree",
90
- className: a.textInput,
91
- "data-target-id": B,
92
- disabled: M,
93
- id: c,
90
+ className: l.textInput,
91
+ "data-target-id": R,
92
+ disabled: z,
93
+ id: n,
94
94
  placeholder: j,
95
- store: m
96
- }), /* @__PURE__ */ l("div", {
97
- className: a.comboboxButtons,
98
- children: I ? /* @__PURE__ */ l(Z, {
95
+ store: c
96
+ }), /* @__PURE__ */ o("div", {
97
+ className: l.comboboxButtons,
98
+ children: I ? /* @__PURE__ */ o(Z, {
99
99
  onClick: () => {
100
- u([]);
100
+ i([]);
101
101
  },
102
- render: (e) => /* @__PURE__ */ l(le, {
102
+ render: (e) => /* @__PURE__ */ o(le, {
103
103
  ...e,
104
104
  "aria-label": "Clear selection",
105
105
  icon: ae,
106
106
  size: "x-small"
107
107
  }),
108
- store: m
109
- }) : /* @__PURE__ */ l(de, {})
108
+ store: c
109
+ }) : /* @__PURE__ */ o(de, {})
110
110
  })]
111
111
  })]
112
112
  })]
113
113
  })
114
- }), /* @__PURE__ */ l(_, {
115
- "aria-labelledby": c,
116
- className: a.popover,
114
+ }), /* @__PURE__ */ o(_, {
115
+ "aria-labelledby": n,
116
+ className: l.popover,
117
117
  fitViewport: !0,
118
118
  gutter: 8,
119
119
  portal: !0,
120
120
  portalElement: G,
121
121
  sameWidth: !0,
122
- children: /* @__PURE__ */ l($, {
122
+ children: /* @__PURE__ */ o($, {
123
123
  onFocusVisible: (e) => {
124
- var t;
125
- const o = (t = p.current) == null ? void 0 : t.firstChild;
126
- o == null || o.focus();
124
+ u.current?.firstChild?.focus();
127
125
  },
128
126
  onKeyDown: (e) => {
129
- var o, t;
130
127
  if (e.key === "ArrowUp") {
131
- const r = (o = p.current) == null ? void 0 : o.firstChild;
132
- document.activeElement === r && (r.blur(), (t = V.current) == null || t.focus());
128
+ const t = u.current?.firstChild;
129
+ document.activeElement === t && (t.blur(), v.current?.focus());
133
130
  }
134
131
  },
135
- children: /* @__PURE__ */ l(pe, {
136
- ref: p,
132
+ children: /* @__PURE__ */ o(pe, {
133
+ ref: u,
137
134
  ariaLabel: U,
138
- defaultFetcher: z,
139
- levels: W,
140
- loadingAriaLabel: k || f(N.loadingAriaLabel),
141
- multiselect: h,
142
- noResultMessage: E || f(N.noResults),
135
+ defaultFetcher: T,
136
+ levels: P,
137
+ loadingAriaLabel: W || h(y.loadingAriaLabel),
138
+ multiselect: b,
139
+ noResultMessage: k || h(y.noResults),
143
140
  onSelect: (e) => {
144
141
  const {
145
- metadata: o
142
+ metadata: t
146
143
  } = e.element;
147
- let t = [];
148
- e.isSelected ? (h && (t = s.filter((r) => r.value !== e.element.id)), t.push({
144
+ let r = [];
145
+ e.isSelected ? (b && (r = a.filter((m) => m.value !== e.element.id)), r.push({
149
146
  value: e.element.id,
150
- displayValue: o.displayValue,
151
- level: o.level,
152
- selectable: o.selectable,
153
- ancestors: o.ancestors
154
- }), O && t.length > s.length && g(!1)) : t = s.filter((r) => r.value !== e.element.id), u(t), v("");
147
+ displayValue: t.displayValue,
148
+ level: t.level,
149
+ selectable: t.selectable,
150
+ ancestors: t.ancestors
151
+ }), O && r.length > a.length && C(!1)) : r = a.filter((m) => m.value !== e.element.id), i(r), x("");
155
152
  },
156
- open: C,
157
- searchInput: x.trimStart(),
153
+ open: f,
154
+ searchInput: g.trimStart(),
158
155
  selectableLevels: K,
159
- selectedNodes: s.map((e) => e.value)
156
+ selectedNodes: a.map((e) => e.value)
160
157
  })
161
158
  })
162
159
  })]
163
160
  });
164
161
  });
165
162
  export {
166
- Re as ComboboxWithApiTreeView
163
+ Oe as ComboboxWithApiTreeView
167
164
  };
@@ -1,5 +1,5 @@
1
1
  import { ComboboxWithApiTreeView as I } from "./combobox-with-api-tree-view.js";
2
- const m = [
2
+ const p = [
3
3
  // Level 1
4
4
  {
5
5
  id: "japan-l1-id",
@@ -370,8 +370,8 @@ const m = [
370
370
  level: 2,
371
371
  selectable: !0
372
372
  }
373
- ], y = 5, j = (l, e) => {
374
- const a = parseInt(l, 10) || 0, i = a + y;
373
+ ], u = 5, j = (l, e) => {
374
+ const a = parseInt(l, 10) || 0, i = a + u;
375
375
  return e.slice(a, i).map(({
376
376
  displayName: s,
377
377
  id: t,
@@ -382,7 +382,7 @@ const m = [
382
382
  ...n
383
383
  }));
384
384
  }, U = (l, e) => {
385
- const i = (parseInt(l, 10) || 0) + y;
385
+ const i = (parseInt(l, 10) || 0) + u;
386
386
  return i < e.length ? i.toString() : void 0;
387
387
  }, x = /* @__PURE__ */ (() => {
388
388
  let l = 0, e = 0;
@@ -393,36 +393,36 @@ const m = [
393
393
  searchInput: t,
394
394
  ancestorId: n,
395
395
  marker: o,
396
- failOnLoadMore: N,
397
- options: v = m,
398
- failOnLoadMoreTimes: b = Number.MAX_SAFE_INTEGER,
399
- failOnLoadLevel: g,
400
- failOnLoadLevelTimes: k = Number.MAX_SAFE_INTEGER
396
+ failOnLoadMore: y,
397
+ options: N = p,
398
+ failOnLoadMoreTimes: v = Number.MAX_SAFE_INTEGER,
399
+ failOnLoadLevel: b,
400
+ failOnLoadLevelTimes: g = Number.MAX_SAFE_INTEGER
401
401
  }) => {
402
402
  if (i.aborted)
403
403
  return Promise.reject(new DOMException("Aborted", "AbortError"));
404
- if (N && o != null && l < b)
404
+ if (y && o != null && l < v)
405
405
  return l += 1, Promise.reject();
406
- if (s === g && e < k)
406
+ if (s === b && e < g)
407
407
  return e += 1, Promise.reject();
408
408
  a && await new Promise((r) => setTimeout(r, a));
409
- const c = v.filter((r) => {
409
+ const c = N.filter((r) => {
410
410
  const {
411
- displayName: h,
412
- level: u,
413
- ancestors: p
411
+ displayName: f,
412
+ level: m,
413
+ ancestors: h
414
414
  } = {
415
415
  ...r
416
416
  };
417
417
  let d = !0;
418
- return s && u && u !== s && (d = !1), t && (d = d && h.toLowerCase().includes(t.toLowerCase())), n && (d = d && (p == null ? void 0 : p.some(({
418
+ return s && m && m !== s && (d = !1), t && (d = d && f.toLowerCase().includes(t.toLowerCase())), n && (d = d && h?.some(({
419
419
  id: S
420
- }) => S === n))), d;
421
- }), f = Promise.resolve({
420
+ }) => S === n)), d;
421
+ }), k = Promise.resolve({
422
422
  marker: U(o, c),
423
423
  options: j(o, c)
424
424
  });
425
- return w(await f);
425
+ return w(await k);
426
426
  };
427
427
  })();
428
428
  function w(l) {
@@ -443,7 +443,7 @@ function w(l) {
443
443
  };
444
444
  }
445
445
  const J = (l) => {
446
- const e = m.find((a) => a.displayName === l);
446
+ const e = p.find((a) => a.displayName === l);
447
447
  return e ? {
448
448
  value: e.id,
449
449
  displayValue: e.displayName,
@@ -452,13 +452,13 @@ const J = (l) => {
452
452
  ancestors: e.ancestors
453
453
  } : null;
454
454
  };
455
- m.map((l) => ({
455
+ p.map((l) => ({
456
456
  ...l,
457
457
  selectable: l.level === 2
458
458
  }));
459
459
  export {
460
460
  I as ComboboxWithApiTreeView,
461
- m as apiResponse,
461
+ p as apiResponse,
462
462
  J as findNode,
463
463
  x as mockTreeFetcher
464
464
  };
@@ -1,10 +1,10 @@
1
1
  export default {
2
- "comboboxWithApi.apiError": "⟦萬萬萬萬萬萬萬萬萬萬萬萬 Čоùĺďп'ţ ĺøáď ŕēŝůļτş. Čľιćκ ţó ŧяÿ αğāίʼn. 國國國國國國國國國國國國⟧",
3
- "comboboxWithApiPagination.clearButtonAriaLabel": "⟦萬萬萬萬萬萬萬 Ćļēάř ïńΡųτ äйď śêĺēċťíôи 國國國國國國國⟧",
4
- "comboboxWithApiPagination.errorAction": "⟦萬 Ŗěĺőåď 國⟧",
5
- "comboboxWithApiPagination.errorIconLabel": "⟦萬 Èŕřőг 國⟧",
6
- "comboboxWithApiPagination.errorMessage": "⟦萬萬萬萬萬萬 ₣ąîļëď τо ľøǻď óΡţϊóиş 國國國國國國⟧",
7
- "comboboxWithApiPagination.loadingAriaLabel": "⟦萬萬 Ľòāďίηĝ... 國國⟧",
8
- "comboboxWithApiPagination.loadingMoreAriaLabel": "⟦萬萬萬萬 Ļσàďϊиĝ möѓė... 國國國國⟧",
9
- "comboboxWithApiPagination.noResults": "⟦萬萬萬萬 Ñο ŗéѕµļτş ƒóűйď 國國國國⟧"
2
+ "comboboxWithApi.apiError": "⟦萬萬萬萬萬萬萬萬萬萬萬萬 Čòцľďň'ŧ ĺőąď яėѕűľτş. Ĉļîсĸ τõ ţяУ āğäїŋ. 國國國國國國國國國國國國⟧",
3
+ "comboboxWithApiPagination.clearButtonAriaLabel": "⟦萬萬萬萬萬萬萬 Ćľêäŗ іηΡùτ ăʼnď ŝέľêсŧĭόй 國國國國國國國⟧",
4
+ "comboboxWithApiPagination.errorAction": "⟦萬 Ŗεĺοāď 國⟧",
5
+ "comboboxWithApiPagination.errorIconLabel": "⟦萬 Εřѓόѓ 國⟧",
6
+ "comboboxWithApiPagination.errorMessage": "⟦萬萬萬萬萬萬 ₣ąïĺēď το ļόαď σΡτίοņѕ 國國國國國國⟧",
7
+ "comboboxWithApiPagination.loadingAriaLabel": "⟦萬萬 Ŀσåďïńğ... 國國⟧",
8
+ "comboboxWithApiPagination.loadingMoreAriaLabel": "⟦萬萬萬萬 Ľőαďĩπġ mόŗĕ... 國國國國⟧",
9
+ "comboboxWithApiPagination.noResults": "⟦萬萬萬萬 Ņó ŗėѕцľτŝ ƒóŭпď 國國國國⟧"
10
10
  }
@@ -1,16 +1,16 @@
1
1
  # Error message displayed as combobox item when an API failed and the suggestions could not load
2
- comboboxWithApi.apiError = ⟦萬萬萬萬萬萬萬萬萬萬萬萬 Čоùĺďп'ţ ĺøáď ŕēŝůļτş. Čľιćκ ţó ŧяÿ αğāίʼn. 國國國國國國國國國國國國⟧
2
+ comboboxWithApi.apiError = ⟦萬萬萬萬萬萬萬萬萬萬萬萬 Čòцľďň'ŧ ĺőąď яėѕűľτş. Ĉļîсĸ τõ ţяУ āğäїŋ. 國國國國國國國國國國國國⟧
3
3
  # Aria label for the clear button visible at the end of the combobox. When clicked, it will clear all text in the input, as well as the current selection.
4
- comboboxWithApiPagination.clearButtonAriaLabel = ⟦萬萬萬萬萬萬萬 Ćļēάř ïńΡųτ äйď śêĺēċťíôи 國國國國國國國⟧
4
+ comboboxWithApiPagination.clearButtonAriaLabel = ⟦萬萬萬萬萬萬萬 Ćľêäŗ іηΡùτ ăʼnď ŝέľêсŧĭόй 國國國國國國國⟧
5
5
  # Error message displayed resembling button that calls to action to reload the results
6
- comboboxWithApiPagination.errorAction = ⟦萬 Ŗěĺőåď 國⟧
6
+ comboboxWithApiPagination.errorAction = ⟦萬 Ŗεĺοāď 國⟧
7
7
  # Aria-label text for the error icon in the loading results error message
8
- comboboxWithApiPagination.errorIconLabel = ⟦萬 Èŕřőг 國⟧
8
+ comboboxWithApiPagination.errorIconLabel = ⟦萬 Εřѓόѓ 國⟧
9
9
  # Error message displayed as inline notice that informs the user that the options failed to load
10
- comboboxWithApiPagination.errorMessage = ⟦萬萬萬萬萬萬 ₣ąîļëď τо ľøǻď óΡţϊóиş 國國國國國國⟧
10
+ comboboxWithApiPagination.errorMessage = ⟦萬萬萬萬萬萬 ₣ąïĺēď το ļόαď σΡτίοņѕ 國國國國國國⟧
11
11
  # Visually hidden aria-label text for the loading spinner
12
- comboboxWithApiPagination.loadingAriaLabel = ⟦萬萬 Ľòāďίηĝ... 國國⟧
12
+ comboboxWithApiPagination.loadingAriaLabel = ⟦萬萬 Ŀσåďïńğ... 國國⟧
13
13
  # Visually hidden aria-label text for the loading spinner show when loading more results from infinite scrolling list
14
- comboboxWithApiPagination.loadingMoreAriaLabel = ⟦萬萬萬萬 Ļσàďϊиĝ möѓė... 國國國國⟧
14
+ comboboxWithApiPagination.loadingMoreAriaLabel = ⟦萬萬萬萬 Ľőαďĩπġ mόŗĕ... 國國國國⟧
15
15
  # Message displayed when no results are found in the combobox
16
- comboboxWithApiPagination.noResults = ⟦萬萬萬萬 Ñο ŗéѕµļτş ƒóűйď 國國國國⟧
16
+ comboboxWithApiPagination.noResults = ⟦萬萬萬萬 Ņó ŗėѕцľτŝ ƒóŭпď 國國國國⟧
package/package.json CHANGED
@@ -1,23 +1,23 @@
1
1
  {
2
2
  "name": "@box/combobox-with-api",
3
- "version": "1.15.7",
3
+ "version": "1.16.0",
4
4
  "peerDependencies": {
5
5
  "@ariakit/react": "0.4.15",
6
- "@box/blueprint-web": "^10.3.1",
7
- "@box/blueprint-web-assets": "^4.16.0",
6
+ "@box/blueprint-web": "^12.103.3",
7
+ "@box/blueprint-web-assets": "^4.86.3",
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.14.3",
14
+ "@box/tree": "^1.15.0",
15
15
  "react-accessible-treeview": "2.9.0"
16
16
  },
17
17
  "devDependencies": {
18
- "@box/blueprint-web": "^12.103.1",
19
- "@box/blueprint-web-assets": "^4.86.0",
20
- "@box/storybook-utils": "^0.14.23",
18
+ "@box/blueprint-web": "^12.103.3",
19
+ "@box/blueprint-web-assets": "^4.86.3",
20
+ "@box/storybook-utils": "^0.14.24",
21
21
  "react": "^18.3.0",
22
22
  "react-dom": "^18.3.0"
23
23
  },