@box/metadata-editor 0.61.3 → 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,46 +1,48 @@
|
|
|
1
1
|
import "../../../../styles/combobox-with-api-pagination.css";
|
|
2
|
-
import { ComboboxItemValue as
|
|
3
|
-
import { Combobox as p, LoadingIndicator as
|
|
4
|
-
import { Search as
|
|
5
|
-
import { IconIconOnLightSecondary as
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
import a from "./messages.js";
|
|
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
|
+
errorComboboxOption: go,
|
|
20
|
+
errorComboboxOptionText: xo
|
|
21
|
+
}, V = /* @__PURE__ */ so(({
|
|
20
22
|
onTryAgain: h
|
|
21
23
|
}, f) => {
|
|
22
24
|
const {
|
|
23
25
|
formatMessage: s
|
|
24
|
-
} =
|
|
25
|
-
return /* @__PURE__ */
|
|
26
|
-
children: [/* @__PURE__ */
|
|
26
|
+
} = N();
|
|
27
|
+
return /* @__PURE__ */ T(mo, {
|
|
28
|
+
children: [/* @__PURE__ */ t(Z, {
|
|
27
29
|
variant: "error",
|
|
28
|
-
variantIconAriaLabel: s(
|
|
29
|
-
children: /* @__PURE__ */
|
|
30
|
-
...
|
|
30
|
+
variantIconAriaLabel: s(a.loadingResultsErrorIconLabel),
|
|
31
|
+
children: /* @__PURE__ */ t(M, {
|
|
32
|
+
...a.loadingResultsErrorMessage
|
|
31
33
|
})
|
|
32
|
-
}), /* @__PURE__ */
|
|
34
|
+
}), /* @__PURE__ */ t(p.Option, {
|
|
33
35
|
ref: f,
|
|
34
|
-
className:
|
|
36
|
+
className: u.errorComboboxOption,
|
|
35
37
|
onClick: h,
|
|
36
|
-
children: /* @__PURE__ */
|
|
38
|
+
children: /* @__PURE__ */ T($, {
|
|
37
39
|
as: "span",
|
|
38
|
-
className:
|
|
40
|
+
className: u.errorComboboxOptionText,
|
|
39
41
|
color: "textOnLightLink",
|
|
40
42
|
variant: "bodyDefaultBold",
|
|
41
|
-
children: [/* @__PURE__ */
|
|
42
|
-
...
|
|
43
|
-
}), /* @__PURE__ */
|
|
43
|
+
children: [/* @__PURE__ */ t(M, {
|
|
44
|
+
...a.loadingResultsErrorAction
|
|
45
|
+
}), /* @__PURE__ */ t(eo, {
|
|
44
46
|
color: "currentColor",
|
|
45
47
|
height: "12px",
|
|
46
48
|
width: "12px"
|
|
@@ -48,148 +50,157 @@ const lo = "_container_16dlc_1", co = "_highlightOptionText_16dlc_7", uo = "_opt
|
|
|
48
50
|
})
|
|
49
51
|
})]
|
|
50
52
|
});
|
|
51
|
-
}),
|
|
52
|
-
color:
|
|
53
|
-
height:
|
|
53
|
+
}), A = "__LOADING__", E = "__LOADING_ERROR__", Oo = "0px 0px 20px 0px", _o = /* @__PURE__ */ t(oo, {
|
|
54
|
+
color: ro,
|
|
55
|
+
height: I,
|
|
54
56
|
role: "presentation",
|
|
55
57
|
style: {
|
|
56
|
-
padding:
|
|
58
|
+
padding: to,
|
|
57
59
|
boxSizing: "border-box"
|
|
58
60
|
},
|
|
59
|
-
width:
|
|
60
|
-
}),
|
|
61
|
+
width: I
|
|
62
|
+
}), Do = (h) => {
|
|
61
63
|
const {
|
|
62
64
|
defaultFetcher: f,
|
|
63
65
|
onInputValueChange: s,
|
|
64
|
-
value:
|
|
65
|
-
onValueChange:
|
|
66
|
-
noResultMessage:
|
|
67
|
-
defaultValue:
|
|
68
|
-
loadingAriaLabel:
|
|
69
|
-
multiselect:
|
|
70
|
-
|
|
66
|
+
value: S,
|
|
67
|
+
onValueChange: D,
|
|
68
|
+
noResultMessage: F,
|
|
69
|
+
defaultValue: P = [],
|
|
70
|
+
loadingAriaLabel: k,
|
|
71
|
+
multiselect: l = !1,
|
|
72
|
+
disabled: w,
|
|
73
|
+
...B
|
|
71
74
|
} = h, {
|
|
72
|
-
formatMessage:
|
|
73
|
-
} =
|
|
75
|
+
formatMessage: d
|
|
76
|
+
} = N(), b = L(null), g = L(!0), o = lo({
|
|
74
77
|
async load({
|
|
75
78
|
marker: e,
|
|
76
|
-
searchInput:
|
|
77
|
-
signal:
|
|
79
|
+
searchInput: r,
|
|
80
|
+
signal: R
|
|
78
81
|
}) {
|
|
79
|
-
const
|
|
80
|
-
signal:
|
|
82
|
+
const c = await f({
|
|
83
|
+
signal: R,
|
|
81
84
|
marker: e,
|
|
82
|
-
searchInput:
|
|
85
|
+
searchInput: r
|
|
83
86
|
});
|
|
84
87
|
return {
|
|
85
|
-
items:
|
|
86
|
-
marker:
|
|
88
|
+
items: c.options,
|
|
89
|
+
marker: c.marker
|
|
87
90
|
};
|
|
88
91
|
}
|
|
89
|
-
}),
|
|
90
|
-
|
|
91
|
-
}, []), [n,
|
|
92
|
-
prop:
|
|
93
|
-
defaultProp:
|
|
94
|
-
onChange:
|
|
95
|
-
}),
|
|
96
|
-
e === void 0 ?
|
|
97
|
-
},
|
|
92
|
+
}), y = L(!1), z = ao(() => {
|
|
93
|
+
y.current || (o.reload(), y.current = !0);
|
|
94
|
+
}, []), [n, x] = co({
|
|
95
|
+
prop: S,
|
|
96
|
+
defaultProp: P,
|
|
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) => {
|
|
98
101
|
const {
|
|
99
|
-
value:
|
|
100
|
-
displayValue:
|
|
101
|
-
...
|
|
102
|
+
value: r,
|
|
103
|
+
displayValue: R,
|
|
104
|
+
...c
|
|
102
105
|
} = e;
|
|
103
|
-
if (
|
|
104
|
-
return o.hasNextPage ? /* @__PURE__ */
|
|
105
|
-
...
|
|
106
|
-
ref:
|
|
106
|
+
if (r === A)
|
|
107
|
+
return o.hasNextPage ? /* @__PURE__ */ t(p.Option, {
|
|
108
|
+
...c,
|
|
109
|
+
ref: H,
|
|
107
110
|
disabled: !0,
|
|
108
|
-
value:
|
|
109
|
-
children: /* @__PURE__ */
|
|
110
|
-
"aria-label":
|
|
111
|
+
value: r,
|
|
112
|
+
children: /* @__PURE__ */ t(Y, {
|
|
113
|
+
"aria-label": d(a.loadingMoreAriaLabel),
|
|
111
114
|
style: {
|
|
112
115
|
position: "unset"
|
|
113
116
|
}
|
|
114
117
|
})
|
|
115
118
|
}) : null;
|
|
116
|
-
if (
|
|
117
|
-
return /* @__PURE__ */
|
|
119
|
+
if (r === E && o.hasError && !o.isEmpty)
|
|
120
|
+
return /* @__PURE__ */ t(V, {
|
|
118
121
|
onTryAgain: () => {
|
|
119
|
-
var
|
|
120
|
-
o.loadMore(), (
|
|
122
|
+
var i;
|
|
123
|
+
o.loadMore(), (i = b.current) == null || i.focus();
|
|
121
124
|
}
|
|
122
125
|
});
|
|
123
|
-
if (
|
|
126
|
+
if (_.some((i) => i.value === r))
|
|
124
127
|
return null;
|
|
125
|
-
const
|
|
126
|
-
return /* @__PURE__ */
|
|
127
|
-
...
|
|
128
|
-
className:
|
|
129
|
-
disabled:
|
|
130
|
-
value:
|
|
131
|
-
children: /* @__PURE__ */
|
|
132
|
-
className:
|
|
133
|
-
value:
|
|
128
|
+
const Q = () => n.some((i) => i.value === r);
|
|
129
|
+
return /* @__PURE__ */ t(p.Option, {
|
|
130
|
+
...c,
|
|
131
|
+
className: u.option,
|
|
132
|
+
disabled: Q(),
|
|
133
|
+
value: r,
|
|
134
|
+
children: /* @__PURE__ */ t(X, {
|
|
135
|
+
className: u.highlightOptionText,
|
|
136
|
+
value: R || r
|
|
134
137
|
})
|
|
135
138
|
});
|
|
136
|
-
},
|
|
137
|
-
s == null || s(e),
|
|
138
|
-
|
|
139
|
+
}, U = (e) => {
|
|
140
|
+
if (s == null || s(e), O && e === "") {
|
|
141
|
+
g.current = !1;
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
o.search(e);
|
|
145
|
+
}, q = () => {
|
|
139
146
|
var e;
|
|
140
|
-
o.reload(), (e =
|
|
147
|
+
o.reload(), (e = b.current) == null || e.focus();
|
|
141
148
|
};
|
|
142
|
-
let
|
|
143
|
-
o.hasError && !o.isLoading ?
|
|
144
|
-
onTryAgain:
|
|
145
|
-
}) : o.isEmpty && !o.isLoading ?
|
|
146
|
-
const [
|
|
147
|
-
rootRef:
|
|
148
|
-
isVisible:
|
|
149
|
-
}] =
|
|
150
|
-
rootMargin:
|
|
149
|
+
let m;
|
|
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
|
|
151
158
|
});
|
|
152
|
-
|
|
153
|
-
if (!(
|
|
159
|
+
io(() => {
|
|
160
|
+
if (!(v && o.hasNextPage))
|
|
154
161
|
return;
|
|
155
|
-
const
|
|
162
|
+
const r = setTimeout(() => {
|
|
156
163
|
o.loadMore();
|
|
157
164
|
}, 100);
|
|
158
165
|
return () => {
|
|
159
|
-
clearTimeout(
|
|
166
|
+
clearTimeout(r);
|
|
160
167
|
};
|
|
161
|
-
}, [
|
|
162
|
-
const
|
|
168
|
+
}, [v]);
|
|
169
|
+
const K = C(() => {
|
|
163
170
|
const e = o.hasNextPage ? {
|
|
164
|
-
displayValue:
|
|
165
|
-
value:
|
|
166
|
-
} : null,
|
|
167
|
-
displayValue:
|
|
168
|
-
value:
|
|
171
|
+
displayValue: A,
|
|
172
|
+
value: A
|
|
173
|
+
} : null, r = !e && o.hasError && !o.isEmpty ? {
|
|
174
|
+
displayValue: E,
|
|
175
|
+
value: E
|
|
169
176
|
} : null;
|
|
170
|
-
return [...o.items, ...
|
|
171
|
-
}, [o.hasNextPage, o.hasError, o.isEmpty, o.items,
|
|
172
|
-
return /* @__PURE__ */
|
|
177
|
+
return [...o.items, ..._, e, r].filter(Boolean);
|
|
178
|
+
}, [o.hasNextPage, o.hasError, o.isEmpty, o.items, _]);
|
|
179
|
+
return /* @__PURE__ */ t(p, {
|
|
173
180
|
as: "input",
|
|
174
|
-
...
|
|
175
|
-
ref:
|
|
176
|
-
|
|
181
|
+
...B,
|
|
182
|
+
ref: b,
|
|
183
|
+
className: no({
|
|
184
|
+
[u.disabled]: O
|
|
185
|
+
}),
|
|
186
|
+
clearButtonAriaLabel: d(a.clearButtonAriaLabel),
|
|
187
|
+
disabled: w || O,
|
|
177
188
|
displayValue: (e) => e.displayValue || e.value,
|
|
178
|
-
endComboboxIcon:
|
|
189
|
+
endComboboxIcon: _o,
|
|
179
190
|
focusLoop: !1,
|
|
180
|
-
getPopoverRef:
|
|
191
|
+
getPopoverRef: J,
|
|
181
192
|
loading: o.isReloading,
|
|
182
|
-
loadingAriaLabel:
|
|
183
|
-
multiselect:
|
|
184
|
-
noResultMessage:
|
|
185
|
-
onFocus:
|
|
186
|
-
onInputValueChange:
|
|
187
|
-
onValueChange:
|
|
188
|
-
options:
|
|
189
|
-
renderOption:
|
|
190
|
-
value:
|
|
193
|
+
loadingAriaLabel: k || d(a.loadingAriaLabel),
|
|
194
|
+
multiselect: l,
|
|
195
|
+
noResultMessage: m,
|
|
196
|
+
onFocus: z,
|
|
197
|
+
onInputValueChange: U,
|
|
198
|
+
onValueChange: G,
|
|
199
|
+
options: K,
|
|
200
|
+
renderOption: j,
|
|
201
|
+
value: W
|
|
191
202
|
});
|
|
192
203
|
};
|
|
193
204
|
export {
|
|
194
|
-
|
|
205
|
+
Do as ComboboxWithApiPagination
|
|
195
206
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/metadata-editor",
|
|
3
|
-
"version": "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": "
|
|
56
|
+
"gitHead": "ed629b47ecaf845602ef01a10843bf1831b8c028"
|
|
57
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._container_181ao_1{display:flex;gap:var(--space-1);justify-content:center}._disabled_181ao_7._disabled_181ao_7{opacity:unset}._highlightOptionText_181ao_11 [data-user-value]{font-weight:700;font-size:.875rem;font-family:Lato,-apple-system,BlinkMacSystemFont,San Francisco,Segoe UI,Roboto,Helvetica Neue,sans-serif;line-height:1.25rem;letter-spacing:.01875rem;text-transform:none;text-decoration:none}._highlightOptionText_181ao_11 [data-autocomplete-value]{color:var(--text-text-on-light-secondary)}._option_181ao_24:nth-last-child(1 of._option_181ao_24){scroll-margin-block-end:var(--space-12)}._errorComboboxOption_181ao_28[role=option]{display:flex;align-items:center;justify-content:center}._errorComboboxOption_181ao_28[role=option] ._errorComboboxOptionText_181ao_33{display:flex;gap:var(--space-1);align-items:center}
|
|
@@ -24,6 +24,7 @@ interface BaseComboboxProps<T extends BaseOptionType, M extends boolean> {
|
|
|
24
24
|
onValueChange?: (selectedOptions: T[]) => void;
|
|
25
25
|
value?: T[];
|
|
26
26
|
defaultValue?: T[];
|
|
27
|
+
disabled?: boolean;
|
|
27
28
|
label: string;
|
|
28
29
|
loadingAriaLabel?: string;
|
|
29
30
|
portalElement?: HTMLElement | (() => HTMLElement);
|