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