@box/combobox-with-api 0.41.2 → 0.42.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,48 +1,48 @@
1
- import { ComboboxItemValue as te } from "@ariakit/react";
2
- import { Combobox as m, useForkRef as re, LoadingIndicator as ne, InlineNotice as ie, Text as se } from "@box/blueprint-web";
3
- import { Search as ae, Loader as le } from "@box/blueprint-web-assets/icons/Fill";
4
- import { IconIconOnLightSecondary as ce, Size6 as T, Size1 as ue } from "@box/blueprint-web-assets/tokens/tokens";
1
+ import { ComboboxItemValue as re } from "@ariakit/react";
2
+ import { Combobox as m, useForkRef as ne, LoadingIndicator as ae, InlineNotice as ie, Text as se } from "@box/blueprint-web";
3
+ import { Search as le, Loader as ce } from "@box/blueprint-web-assets/icons/Fill";
4
+ import { IconIconOnLightSecondary as ue, Size6 as T, Size1 as de } from "@box/blueprint-web-assets/tokens/tokens";
5
5
  import S from "clsx";
6
- import { forwardRef as F, useRef as v, useCallback as de, useMemo as R, useEffect as me } from "react";
6
+ import { forwardRef as F, useRef as v, useCallback as me, useMemo as R, useEffect as pe } from "react";
7
7
  import { useIntl as P, FormattedMessage as V } from "react-intl";
8
- import i from "./messages.js";
9
- import { useAsyncList as pe } from "./use-async-list.js";
10
- import { useControllableState as he } from "./utils/use-controllable-state.js";
11
- import { useTrackVisibility as fe } from "./utils/use-intersection-observer.js";
12
- import { jsx as r, jsxs as N, Fragment as ge } from "react/jsx-runtime";
13
- import '../../../../styles/combobox-with-api-pagination.css';const be = "_container_syvk5_1", xe = "_disabled_syvk5_7", Oe = "_highlightOptionText_syvk5_11", _e = "_selected_syvk5_23", ye = "_option_syvk5_34", ve = "_errorComboboxOption_syvk5_38", Re = "_errorComboboxOptionText_syvk5_43", a = {
14
- container: be,
15
- disabled: xe,
16
- highlightOptionText: Oe,
17
- selected: _e,
18
- option: ye,
19
- errorComboboxOption: ve,
20
- errorComboboxOptionText: Re
8
+ import a from "./messages.js";
9
+ import { useAsyncList as he } from "./use-async-list.js";
10
+ import { useControllableState as fe } from "./utils/use-controllable-state.js";
11
+ import { useTrackVisibility as ge } from "./utils/use-intersection-observer.js";
12
+ import { jsx as r, jsxs as N, Fragment as be } from "react/jsx-runtime";
13
+ import '../../../../styles/combobox-with-api-pagination.css';const xe = "_container_syvk5_1", Oe = "_disabled_syvk5_7", _e = "_highlightOptionText_syvk5_11", ye = "_selected_syvk5_23", ve = "_option_syvk5_34", Re = "_errorComboboxOption_syvk5_38", Ce = "_errorComboboxOptionText_syvk5_43", s = {
14
+ container: xe,
15
+ disabled: Oe,
16
+ highlightOptionText: _e,
17
+ selected: ye,
18
+ option: ve,
19
+ errorComboboxOption: Re,
20
+ errorComboboxOptionText: Ce
21
21
  }, k = /* @__PURE__ */ F(({
22
22
  onTryAgain: L
23
23
  }, p) => {
24
24
  const {
25
25
  formatMessage: h
26
26
  } = P();
27
- return /* @__PURE__ */ N(ge, {
27
+ return /* @__PURE__ */ N(be, {
28
28
  children: [/* @__PURE__ */ r(ie, {
29
29
  variant: "error",
30
- variantIconAriaLabel: h(i.loadingResultsErrorIconLabel),
30
+ variantIconAriaLabel: h(a.loadingResultsErrorIconLabel),
31
31
  children: /* @__PURE__ */ r(V, {
32
- ...i.loadingResultsErrorMessage
32
+ ...a.loadingResultsErrorMessage
33
33
  })
34
34
  }), /* @__PURE__ */ r(m.Option, {
35
35
  ref: p,
36
- className: a.errorComboboxOption,
36
+ className: s.errorComboboxOption,
37
37
  onClick: L,
38
38
  children: /* @__PURE__ */ N(se, {
39
39
  as: "span",
40
- className: a.errorComboboxOptionText,
40
+ className: s.errorComboboxOptionText,
41
41
  color: "textOnLightLink",
42
42
  variant: "bodyDefaultBold",
43
43
  children: [/* @__PURE__ */ r(V, {
44
- ...i.loadingResultsErrorAction
45
- }), /* @__PURE__ */ r(le, {
44
+ ...a.loadingResultsErrorAction
45
+ }), /* @__PURE__ */ r(ce, {
46
46
  color: "currentColor",
47
47
  height: "12px",
48
48
  width: "12px"
@@ -50,38 +50,39 @@ import '../../../../styles/combobox-with-api-pagination.css';const be = "_contai
50
50
  })
51
51
  })]
52
52
  });
53
- }), C = "__LOADING__", A = "__LOADING_ERROR__", Ce = "0px 0px 20px 0px", Ae = /* @__PURE__ */ r(ae, {
54
- color: ce,
53
+ }), C = "__LOADING__", A = "__LOADING_ERROR__", Ae = "0px 0px 20px 0px", Le = /* @__PURE__ */ r(le, {
54
+ color: ue,
55
55
  height: T,
56
56
  role: "presentation",
57
57
  style: {
58
- padding: ue,
58
+ padding: de,
59
59
  boxSizing: "border-box"
60
60
  },
61
61
  width: T
62
- }), Be = /* @__PURE__ */ F(function(p, h) {
62
+ }), we = /* @__PURE__ */ F(function(p, h) {
63
63
  const {
64
- defaultFetcher: D,
64
+ dataTargetId: D,
65
+ defaultFetcher: B,
65
66
  onInputValueChange: f,
66
- value: B,
67
- onValueChange: w,
68
- noResultMessage: W,
69
- defaultValue: z = [],
70
- loadingAriaLabel: G,
67
+ value: w,
68
+ onValueChange: W,
69
+ noResultMessage: z,
70
+ defaultValue: G = [],
71
+ loadingAriaLabel: j,
71
72
  multiselect: l = !1,
72
- disabled: j,
73
- className: U,
73
+ disabled: U,
74
+ className: q,
74
75
  displaySingleSelectionAsChip: E = !0,
75
- ...q
76
+ ...H
76
77
  } = p, {
77
78
  formatMessage: u
78
- } = P(), g = v(null), b = v(!0), e = pe({
79
+ } = P(), g = v(null), b = v(!0), e = he({
79
80
  async load({
80
81
  marker: o,
81
82
  searchInput: t,
82
83
  signal: y
83
84
  }) {
84
- const c = await D({
85
+ const c = await B({
85
86
  signal: y,
86
87
  marker: o,
87
88
  searchInput: t
@@ -91,15 +92,15 @@ import '../../../../styles/combobox-with-api-pagination.css';const be = "_contai
91
92
  marker: c.marker
92
93
  };
93
94
  }
94
- }), I = v(!1), H = de(() => {
95
+ }), I = v(!1), J = me(() => {
95
96
  I.current || (e.reload(), I.current = !0);
96
- }, []), [n, x] = he({
97
- prop: B,
98
- defaultProp: z,
99
- onChange: w
100
- }), O = !l && n.length === 1, J = (o) => {
97
+ }, []), [n, x] = fe({
98
+ prop: w,
99
+ defaultProp: G,
100
+ onChange: W
101
+ }), O = !l && n.length === 1, K = (o) => {
101
102
  o === void 0 ? (x([]), b.current || (e.search(""), b.current = !0)) : Array.isArray(o) ? x(o) : x([o]);
102
- }, K = R(() => n.length === 0 ? l ? [] : void 0 : l ? n : n[0], [l, n]), _ = R(() => n.filter((o) => !e.items.some((t) => t.value === o.value)), [n, e.items]), Q = (o) => {
103
+ }, Q = R(() => n.length === 0 ? l ? [] : void 0 : l ? n : n[0], [l, n]), _ = R(() => n.filter((o) => !e.items.some((t) => t.value === o.value)), [n, e.items]), X = (o) => {
103
104
  const {
104
105
  value: t,
105
106
  displayValue: y,
@@ -108,11 +109,11 @@ import '../../../../styles/combobox-with-api-pagination.css';const be = "_contai
108
109
  if (t === C)
109
110
  return e.hasNextPage ? /* @__PURE__ */ r(m.Option, {
110
111
  ...c,
111
- ref: Z,
112
+ ref: $,
112
113
  disabled: !0,
113
114
  value: t,
114
- children: /* @__PURE__ */ r(ne, {
115
- "aria-label": u(i.loadingMoreAriaLabel),
115
+ children: /* @__PURE__ */ r(ae, {
116
+ "aria-label": u(a.loadingMoreAriaLabel),
116
117
  style: {
117
118
  position: "unset"
118
119
  }
@@ -121,43 +122,43 @@ import '../../../../styles/combobox-with-api-pagination.css';const be = "_contai
121
122
  if (t === A && e.hasError && !e.isEmpty)
122
123
  return /* @__PURE__ */ r(k, {
123
124
  onTryAgain: () => {
124
- var s;
125
- e.loadMore(), (s = g.current) == null || s.focus();
125
+ var i;
126
+ e.loadMore(), (i = g.current) == null || i.focus();
126
127
  }
127
128
  });
128
- if (_.some((s) => s.value === t))
129
+ if (_.some((i) => i.value === t))
129
130
  return null;
130
- const oe = n.some((s) => s.value === t);
131
+ const te = n.some((i) => i.value === t);
131
132
  return /* @__PURE__ */ r(m.Option, {
132
133
  ...c,
133
- className: a.option,
134
+ className: s.option,
134
135
  value: t,
135
- children: /* @__PURE__ */ r(te, {
136
- className: S(a.highlightOptionText, oe && a.selected),
136
+ children: /* @__PURE__ */ r(re, {
137
+ className: S(s.highlightOptionText, te && s.selected),
137
138
  value: y || t
138
139
  })
139
140
  });
140
- }, X = (o) => {
141
+ }, Y = (o) => {
141
142
  if (f == null || f(o), O && o === "") {
142
143
  b.current = !1;
143
144
  return;
144
145
  }
145
146
  e.search(o);
146
- }, Y = () => {
147
+ }, Z = () => {
147
148
  var o;
148
149
  e.reload(), (o = g.current) == null || o.focus();
149
150
  };
150
151
  let d;
151
152
  e.hasError && !e.isLoading ? d = /* @__PURE__ */ r(k, {
152
- onTryAgain: Y
153
- }) : e.isEmpty && !e.isLoading ? d = W || u(i.noResults) : d = void 0;
154
- const [Z, {
155
- rootRef: $,
153
+ onTryAgain: Z
154
+ }) : e.isEmpty && !e.isLoading ? d = z || u(a.noResults) : d = void 0;
155
+ const [$, {
156
+ rootRef: ee,
156
157
  isVisible: M
157
- }] = fe({
158
- rootMargin: Ce
158
+ }] = ge({
159
+ rootMargin: Ae
159
160
  });
160
- me(() => {
161
+ pe(() => {
161
162
  if (!(M && e.hasNextPage))
162
163
  return;
163
164
  const t = setTimeout(() => {
@@ -167,7 +168,7 @@ import '../../../../styles/combobox-with-api-pagination.css';const be = "_contai
167
168
  clearTimeout(t);
168
169
  };
169
170
  }, [M]);
170
- const ee = R(() => {
171
+ const oe = R(() => {
171
172
  const o = e.hasNextPage ? {
172
173
  displayValue: C,
173
174
  value: C
@@ -178,32 +179,33 @@ import '../../../../styles/combobox-with-api-pagination.css';const be = "_contai
178
179
  return [...e.items, ..._, o, t].filter(Boolean);
179
180
  }, [e.hasNextPage, e.hasError, e.isEmpty, e.items, _]);
180
181
  return /* @__PURE__ */ r(m, {
181
- ...q,
182
- ref: re(g, h),
182
+ ...H,
183
+ ref: ne(g, h),
183
184
  as: "input",
184
185
  className: S({
185
- [a.disabled]: O
186
- }, U),
187
- clearButtonAriaLabel: u(i.clearButtonAriaLabel),
186
+ [s.disabled]: O
187
+ }, q),
188
+ clearButtonAriaLabel: u(a.clearButtonAriaLabel),
188
189
  clearOnBlur: !1,
189
- disabled: j || O && E,
190
+ "data-target-id": D,
191
+ disabled: U || O && E,
190
192
  displaySingleSelectionAsChip: E,
191
193
  displayValue: (o) => o.displayValue || o.value,
192
- endComboboxIcon: Ae,
194
+ endComboboxIcon: Le,
193
195
  focusLoop: !1,
194
- getPopoverRef: $,
196
+ getPopoverRef: ee,
195
197
  loading: e.isReloading,
196
- loadingAriaLabel: G || u(i.loadingAriaLabel),
198
+ loadingAriaLabel: j || u(a.loadingAriaLabel),
197
199
  multiselect: l,
198
200
  noResultMessage: d,
199
- onFocus: H,
200
- onInputValueChange: X,
201
- onValueChange: J,
202
- options: ee,
203
- renderOption: Q,
204
- value: K
201
+ onFocus: J,
202
+ onInputValueChange: Y,
203
+ onValueChange: K,
204
+ options: oe,
205
+ renderOption: X,
206
+ value: Q
205
207
  });
206
208
  });
207
209
  export {
208
- Be as ComboboxWithApiPagination
210
+ we as ComboboxWithApiPagination
209
211
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/combobox-with-api",
3
- "version": "0.41.2",
3
+ "version": "0.42.0",
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.13",
14
+ "@box/tree": "^0.48.14",
15
15
  "react-accessible-treeview": "2.9.0"
16
16
  },
17
17
  "devDependencies": {
18
- "@box/blueprint-web": "^12.5.1",
18
+ "@box/blueprint-web": "^12.6.0",
19
19
  "@box/blueprint-web-assets": "^4.48.0",
20
20
  "@box/storybook-utils": "^0.13.1",
21
21
  "react": "^18.3.0",