@box/metadata-editor 0.62.0 → 0.63.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
1
  import "../../../../styles/combobox-with-api-pagination.css";
2
- import { ComboboxItemValue as Q } from "@ariakit/react";
3
- import { Combobox as p, LoadingIndicator as X, InlineNotice as Y, Text as Z } from "@box/blueprint-web";
4
- import { Search as $, Loader as oo } from "@box/blueprint-web-assets/icons/Fill";
5
- import { IconIconOnLightSecondary as eo, Size6 as y, Size1 as to } from "@box/blueprint-web-assets/tokens/tokens";
6
- import ro from "clsx";
7
- import { useRef as v, useCallback as no, useMemo as _, useEffect as ao, forwardRef as io } from "react";
8
- import { useIntl as V, FormattedMessage as I } from "react-intl";
2
+ import { ComboboxItemValue as X } from "@ariakit/react";
3
+ import { Combobox as p, LoadingIndicator as Y, InlineNotice as Z, Text as $ } from "@box/blueprint-web";
4
+ import { Search as oo, Loader as eo } from "@box/blueprint-web-assets/icons/Fill";
5
+ import { IconIconOnLightSecondary as ro, Size6 as I, Size1 as to } from "@box/blueprint-web-assets/tokens/tokens";
6
+ import no from "clsx";
7
+ import { useRef as L, useCallback as ao, useMemo as C, useEffect as io, forwardRef as so } from "react";
8
+ import { useIntl as N, FormattedMessage as M } from "react-intl";
9
9
  import a from "./messages.js";
10
- import { useAsyncList as so } from "./use-async-list.js";
11
- import { useControllableState as lo } from "./utils/use-controllable-state.js";
12
- import { useTrackVisibility as co } from "./utils/use-intersection-observer.js";
13
- import { jsx as r, jsxs as M, Fragment as uo } from "react/jsx-runtime";
14
- const mo = "_container_181ao_1", po = "_disabled_181ao_7", bo = "_highlightOptionText_181ao_11", ho = "_option_181ao_24", go = "_errorComboboxOption_181ao_28", fo = "_errorComboboxOptionText_181ao_33", u = {
15
- container: mo,
16
- disabled: po,
17
- highlightOptionText: bo,
18
- option: ho,
10
+ import { useAsyncList as lo } from "./use-async-list.js";
11
+ import { useControllableState as co } from "./utils/use-controllable-state.js";
12
+ import { useTrackVisibility as uo } from "./utils/use-intersection-observer.js";
13
+ import { jsx as t, jsxs as T, Fragment as mo } from "react/jsx-runtime";
14
+ const po = "_container_181ao_1", ho = "_disabled_181ao_7", fo = "_highlightOptionText_181ao_11", bo = "_option_181ao_24", go = "_errorComboboxOption_181ao_28", xo = "_errorComboboxOptionText_181ao_33", u = {
15
+ container: po,
16
+ disabled: ho,
17
+ highlightOptionText: fo,
18
+ option: bo,
19
19
  errorComboboxOption: go,
20
- errorComboboxOptionText: fo
21
- }, T = /* @__PURE__ */ io(({
22
- onTryAgain: b
23
- }, h) => {
20
+ errorComboboxOptionText: xo
21
+ }, V = /* @__PURE__ */ so(({
22
+ onTryAgain: h
23
+ }, f) => {
24
24
  const {
25
25
  formatMessage: s
26
- } = V();
27
- return /* @__PURE__ */ M(uo, {
28
- children: [/* @__PURE__ */ r(Y, {
26
+ } = N();
27
+ return /* @__PURE__ */ T(mo, {
28
+ children: [/* @__PURE__ */ t(Z, {
29
29
  variant: "error",
30
30
  variantIconAriaLabel: s(a.loadingResultsErrorIconLabel),
31
- children: /* @__PURE__ */ r(I, {
31
+ children: /* @__PURE__ */ t(M, {
32
32
  ...a.loadingResultsErrorMessage
33
33
  })
34
- }), /* @__PURE__ */ r(p.Option, {
35
- ref: h,
34
+ }), /* @__PURE__ */ t(p.Option, {
35
+ ref: f,
36
36
  className: u.errorComboboxOption,
37
- onClick: b,
38
- children: /* @__PURE__ */ M(Z, {
37
+ onClick: h,
38
+ children: /* @__PURE__ */ T($, {
39
39
  as: "span",
40
40
  className: u.errorComboboxOptionText,
41
41
  color: "textOnLightLink",
42
42
  variant: "bodyDefaultBold",
43
- children: [/* @__PURE__ */ r(I, {
43
+ children: [/* @__PURE__ */ t(M, {
44
44
  ...a.loadingResultsErrorAction
45
- }), /* @__PURE__ */ r(oo, {
45
+ }), /* @__PURE__ */ t(eo, {
46
46
  color: "currentColor",
47
47
  height: "12px",
48
48
  width: "12px"
@@ -50,153 +50,157 @@ const mo = "_container_181ao_1", po = "_disabled_181ao_7", bo = "_highlightOptio
50
50
  })
51
51
  })]
52
52
  });
53
- }), R = "__LOADING__", L = "__LOADING_ERROR__", xo = "0px 0px 20px 0px", Oo = /* @__PURE__ */ r($, {
54
- color: eo,
55
- height: y,
53
+ }), A = "__LOADING__", E = "__LOADING_ERROR__", Oo = "0px 0px 20px 0px", _o = /* @__PURE__ */ t(oo, {
54
+ color: ro,
55
+ height: I,
56
56
  role: "presentation",
57
57
  style: {
58
58
  padding: to,
59
59
  boxSizing: "border-box"
60
60
  },
61
- width: y
62
- }), So = (b) => {
61
+ width: I
62
+ }), Do = (h) => {
63
63
  const {
64
- defaultFetcher: h,
64
+ defaultFetcher: f,
65
65
  onInputValueChange: s,
66
- value: N,
67
- onValueChange: S,
68
- noResultMessage: D,
66
+ value: S,
67
+ onValueChange: D,
68
+ noResultMessage: F,
69
69
  defaultValue: P = [],
70
70
  loadingAriaLabel: k,
71
71
  multiselect: l = !1,
72
- disabled: F,
73
- ...w
74
- } = b, {
72
+ disabled: w,
73
+ ...B
74
+ } = h, {
75
75
  formatMessage: d
76
- } = V(), g = v(null), o = so({
76
+ } = N(), b = L(null), g = L(!0), o = lo({
77
77
  async load({
78
78
  marker: e,
79
- searchInput: t,
80
- signal: O
79
+ searchInput: r,
80
+ signal: R
81
81
  }) {
82
- const c = await h({
83
- signal: O,
82
+ const c = await f({
83
+ signal: R,
84
84
  marker: e,
85
- searchInput: t
85
+ searchInput: r
86
86
  });
87
87
  return {
88
88
  items: c.options,
89
89
  marker: c.marker
90
90
  };
91
91
  }
92
- }), C = v(!1), B = no(() => {
93
- C.current || (o.reload(), C.current = !0);
94
- }, []), [n, f] = lo({
95
- prop: N,
92
+ }), y = L(!1), z = ao(() => {
93
+ y.current || (o.reload(), y.current = !0);
94
+ }, []), [n, x] = co({
95
+ prop: S,
96
96
  defaultProp: P,
97
- onChange: S
98
- }), z = (e) => {
99
- e === void 0 ? f([]) : Array.isArray(e) ? f(e) : f([e]);
100
- }, G = _(() => n.length === 0 ? l ? [] : void 0 : l ? n : n[0], [l, n]), x = _(() => n.filter((e) => !o.items.some((t) => t.value === e.value)), [n, o.items]), W = (e) => {
97
+ onChange: D
98
+ }), O = !l && n.length === 1, G = (e) => {
99
+ e === void 0 ? (x([]), g.current || (o.search(""), g.current = !0)) : Array.isArray(e) ? x(e) : x([e]);
100
+ }, W = C(() => n.length === 0 ? l ? [] : void 0 : l ? n : n[0], [l, n]), _ = C(() => n.filter((e) => !o.items.some((r) => r.value === e.value)), [n, o.items]), j = (e) => {
101
101
  const {
102
- value: t,
103
- displayValue: O,
102
+ value: r,
103
+ displayValue: R,
104
104
  ...c
105
105
  } = e;
106
- if (t === R)
107
- return o.hasNextPage ? /* @__PURE__ */ r(p.Option, {
106
+ if (r === A)
107
+ return o.hasNextPage ? /* @__PURE__ */ t(p.Option, {
108
108
  ...c,
109
- ref: q,
109
+ ref: H,
110
110
  disabled: !0,
111
- value: t,
112
- children: /* @__PURE__ */ r(X, {
111
+ value: r,
112
+ children: /* @__PURE__ */ t(Y, {
113
113
  "aria-label": d(a.loadingMoreAriaLabel),
114
114
  style: {
115
115
  position: "unset"
116
116
  }
117
117
  })
118
118
  }) : null;
119
- if (t === L && o.hasError && !o.isEmpty)
120
- return /* @__PURE__ */ r(T, {
119
+ if (r === E && o.hasError && !o.isEmpty)
120
+ return /* @__PURE__ */ t(V, {
121
121
  onTryAgain: () => {
122
122
  var i;
123
- o.loadMore(), (i = g.current) == null || i.focus();
123
+ o.loadMore(), (i = b.current) == null || i.focus();
124
124
  }
125
125
  });
126
- if (x.some((i) => i.value === t))
126
+ if (_.some((i) => i.value === r))
127
127
  return null;
128
- const K = () => n.some((i) => i.value === t);
129
- return /* @__PURE__ */ r(p.Option, {
128
+ const Q = () => n.some((i) => i.value === r);
129
+ return /* @__PURE__ */ t(p.Option, {
130
130
  ...c,
131
131
  className: u.option,
132
- disabled: K(),
133
- value: t,
134
- children: /* @__PURE__ */ r(Q, {
132
+ disabled: Q(),
133
+ value: r,
134
+ children: /* @__PURE__ */ t(X, {
135
135
  className: u.highlightOptionText,
136
- value: O || t
136
+ value: R || r
137
137
  })
138
138
  });
139
- }, j = (e) => {
140
- s == null || s(e), o.search(e);
141
- }, U = () => {
139
+ }, U = (e) => {
140
+ if (s == null || s(e), O && e === "") {
141
+ g.current = !1;
142
+ return;
143
+ }
144
+ o.search(e);
145
+ }, q = () => {
142
146
  var e;
143
- o.reload(), (e = g.current) == null || e.focus();
147
+ o.reload(), (e = b.current) == null || e.focus();
144
148
  };
145
149
  let m;
146
- o.hasError && !o.isLoading ? m = /* @__PURE__ */ r(T, {
147
- onTryAgain: U
148
- }) : o.isEmpty && !o.isLoading ? m = D || d(a.noResults) : m = void 0;
149
- const [q, {
150
- rootRef: H,
151
- isVisible: A
152
- }] = co({
153
- rootMargin: xo
150
+ o.hasError && !o.isLoading ? m = /* @__PURE__ */ t(V, {
151
+ onTryAgain: q
152
+ }) : o.isEmpty && !o.isLoading ? m = F || d(a.noResults) : m = void 0;
153
+ const [H, {
154
+ rootRef: J,
155
+ isVisible: v
156
+ }] = uo({
157
+ rootMargin: Oo
154
158
  });
155
- ao(() => {
156
- if (!(A && o.hasNextPage))
159
+ io(() => {
160
+ if (!(v && o.hasNextPage))
157
161
  return;
158
- const t = setTimeout(() => {
162
+ const r = setTimeout(() => {
159
163
  o.loadMore();
160
164
  }, 100);
161
165
  return () => {
162
- clearTimeout(t);
166
+ clearTimeout(r);
163
167
  };
164
- }, [A]);
165
- const J = _(() => {
168
+ }, [v]);
169
+ const K = C(() => {
166
170
  const e = o.hasNextPage ? {
167
- displayValue: R,
168
- value: R
169
- } : null, t = !e && o.hasError && !o.isEmpty ? {
170
- displayValue: L,
171
- value: L
171
+ displayValue: A,
172
+ value: A
173
+ } : null, r = !e && o.hasError && !o.isEmpty ? {
174
+ displayValue: E,
175
+ value: E
172
176
  } : null;
173
- return [...o.items, ...x, e, t].filter(Boolean);
174
- }, [o.hasNextPage, o.hasError, o.isEmpty, o.items, x]), E = !l && n.length === 1;
175
- return /* @__PURE__ */ r(p, {
177
+ return [...o.items, ..._, e, r].filter(Boolean);
178
+ }, [o.hasNextPage, o.hasError, o.isEmpty, o.items, _]);
179
+ return /* @__PURE__ */ t(p, {
176
180
  as: "input",
177
- ...w,
178
- ref: g,
179
- className: ro({
180
- [u.disabled]: E
181
+ ...B,
182
+ ref: b,
183
+ className: no({
184
+ [u.disabled]: O
181
185
  }),
182
186
  clearButtonAriaLabel: d(a.clearButtonAriaLabel),
183
- disabled: F || E,
187
+ disabled: w || O,
184
188
  displayValue: (e) => e.displayValue || e.value,
185
- endComboboxIcon: Oo,
189
+ endComboboxIcon: _o,
186
190
  focusLoop: !1,
187
- getPopoverRef: H,
191
+ getPopoverRef: J,
188
192
  loading: o.isReloading,
189
193
  loadingAriaLabel: k || d(a.loadingAriaLabel),
190
194
  multiselect: l,
191
195
  noResultMessage: m,
192
- onFocus: B,
193
- onInputValueChange: j,
194
- onValueChange: z,
195
- options: J,
196
- renderOption: W,
197
- value: G
196
+ onFocus: z,
197
+ onInputValueChange: U,
198
+ onValueChange: G,
199
+ options: K,
200
+ renderOption: j,
201
+ value: W
198
202
  });
199
203
  };
200
204
  export {
201
- So as ComboboxWithApiPagination
205
+ Do as ComboboxWithApiPagination
202
206
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/metadata-editor",
3
- "version": "0.62.0",
3
+ "version": "0.63.0",
4
4
  "peerDependencies": {
5
5
  "@ariakit/react": "0.4.5",
6
6
  "@box/blueprint-web": "^7.30.3",
@@ -53,5 +53,5 @@
53
53
  "**/*.css"
54
54
  ],
55
55
  "license": "SEE LICENSE IN LICENSE",
56
- "gitHead": "ab664c931e214b862035e211809f92f711a0a2d4"
56
+ "gitHead": "ed629b47ecaf845602ef01a10843bf1831b8c028"
57
57
  }