@box/metadata-editor 0.61.3 → 0.62.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
|
-
|
20
|
-
|
21
|
-
},
|
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";
|
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,
|
19
|
+
errorComboboxOption: go,
|
20
|
+
errorComboboxOptionText: fo
|
21
|
+
}, T = /* @__PURE__ */ io(({
|
22
|
+
onTryAgain: b
|
23
|
+
}, h) => {
|
22
24
|
const {
|
23
25
|
formatMessage: s
|
24
|
-
} =
|
25
|
-
return /* @__PURE__ */
|
26
|
-
children: [/* @__PURE__ */ r(
|
26
|
+
} = V();
|
27
|
+
return /* @__PURE__ */ M(uo, {
|
28
|
+
children: [/* @__PURE__ */ r(Y, {
|
27
29
|
variant: "error",
|
28
|
-
variantIconAriaLabel: s(
|
29
|
-
children: /* @__PURE__ */ r(
|
30
|
-
...
|
30
|
+
variantIconAriaLabel: s(a.loadingResultsErrorIconLabel),
|
31
|
+
children: /* @__PURE__ */ r(I, {
|
32
|
+
...a.loadingResultsErrorMessage
|
31
33
|
})
|
32
34
|
}), /* @__PURE__ */ r(p.Option, {
|
33
|
-
ref:
|
34
|
-
className:
|
35
|
-
onClick:
|
36
|
-
children: /* @__PURE__ */
|
35
|
+
ref: h,
|
36
|
+
className: u.errorComboboxOption,
|
37
|
+
onClick: b,
|
38
|
+
children: /* @__PURE__ */ M(Z, {
|
37
39
|
as: "span",
|
38
|
-
className:
|
40
|
+
className: u.errorComboboxOptionText,
|
39
41
|
color: "textOnLightLink",
|
40
42
|
variant: "bodyDefaultBold",
|
41
|
-
children: [/* @__PURE__ */ r(
|
42
|
-
...
|
43
|
-
}), /* @__PURE__ */ r(
|
43
|
+
children: [/* @__PURE__ */ r(I, {
|
44
|
+
...a.loadingResultsErrorAction
|
45
|
+
}), /* @__PURE__ */ r(oo, {
|
44
46
|
color: "currentColor",
|
45
47
|
height: "12px",
|
46
48
|
width: "12px"
|
@@ -48,108 +50,109 @@ const lo = "_container_16dlc_1", co = "_highlightOptionText_16dlc_7", uo = "_opt
|
|
48
50
|
})
|
49
51
|
})]
|
50
52
|
});
|
51
|
-
}), R = "__LOADING__", L = "__LOADING_ERROR__",
|
52
|
-
color:
|
53
|
-
height:
|
53
|
+
}), R = "__LOADING__", L = "__LOADING_ERROR__", xo = "0px 0px 20px 0px", Oo = /* @__PURE__ */ r($, {
|
54
|
+
color: eo,
|
55
|
+
height: y,
|
54
56
|
role: "presentation",
|
55
57
|
style: {
|
56
|
-
padding:
|
58
|
+
padding: to,
|
57
59
|
boxSizing: "border-box"
|
58
60
|
},
|
59
|
-
width:
|
60
|
-
}),
|
61
|
+
width: y
|
62
|
+
}), So = (b) => {
|
61
63
|
const {
|
62
|
-
defaultFetcher:
|
64
|
+
defaultFetcher: h,
|
63
65
|
onInputValueChange: s,
|
64
|
-
value:
|
65
|
-
onValueChange:
|
66
|
-
noResultMessage:
|
67
|
-
defaultValue:
|
68
|
-
loadingAriaLabel:
|
69
|
-
multiselect:
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
66
|
+
value: N,
|
67
|
+
onValueChange: S,
|
68
|
+
noResultMessage: D,
|
69
|
+
defaultValue: P = [],
|
70
|
+
loadingAriaLabel: k,
|
71
|
+
multiselect: l = !1,
|
72
|
+
disabled: F,
|
73
|
+
...w
|
74
|
+
} = b, {
|
75
|
+
formatMessage: d
|
76
|
+
} = V(), g = v(null), o = so({
|
74
77
|
async load({
|
75
78
|
marker: e,
|
76
79
|
searchInput: t,
|
77
80
|
signal: O
|
78
81
|
}) {
|
79
|
-
const
|
82
|
+
const c = await h({
|
80
83
|
signal: O,
|
81
84
|
marker: e,
|
82
85
|
searchInput: t
|
83
86
|
});
|
84
87
|
return {
|
85
|
-
items:
|
86
|
-
marker:
|
88
|
+
items: c.options,
|
89
|
+
marker: c.marker
|
87
90
|
};
|
88
91
|
}
|
89
|
-
}), C =
|
92
|
+
}), C = v(!1), B = no(() => {
|
90
93
|
C.current || (o.reload(), C.current = !0);
|
91
|
-
}, []), [n,
|
92
|
-
prop:
|
93
|
-
defaultProp:
|
94
|
-
onChange:
|
95
|
-
}),
|
96
|
-
e === void 0 ?
|
97
|
-
},
|
94
|
+
}, []), [n, f] = lo({
|
95
|
+
prop: N,
|
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) => {
|
98
101
|
const {
|
99
102
|
value: t,
|
100
103
|
displayValue: O,
|
101
|
-
...
|
104
|
+
...c
|
102
105
|
} = e;
|
103
106
|
if (t === R)
|
104
107
|
return o.hasNextPage ? /* @__PURE__ */ r(p.Option, {
|
105
|
-
...
|
106
|
-
ref:
|
108
|
+
...c,
|
109
|
+
ref: q,
|
107
110
|
disabled: !0,
|
108
111
|
value: t,
|
109
|
-
children: /* @__PURE__ */ r(
|
110
|
-
"aria-label":
|
112
|
+
children: /* @__PURE__ */ r(X, {
|
113
|
+
"aria-label": d(a.loadingMoreAriaLabel),
|
111
114
|
style: {
|
112
115
|
position: "unset"
|
113
116
|
}
|
114
117
|
})
|
115
118
|
}) : null;
|
116
119
|
if (t === L && o.hasError && !o.isEmpty)
|
117
|
-
return /* @__PURE__ */ r(
|
120
|
+
return /* @__PURE__ */ r(T, {
|
118
121
|
onTryAgain: () => {
|
119
|
-
var
|
120
|
-
o.loadMore(), (
|
122
|
+
var i;
|
123
|
+
o.loadMore(), (i = g.current) == null || i.focus();
|
121
124
|
}
|
122
125
|
});
|
123
|
-
if (x.some((
|
126
|
+
if (x.some((i) => i.value === t))
|
124
127
|
return null;
|
125
|
-
const
|
128
|
+
const K = () => n.some((i) => i.value === t);
|
126
129
|
return /* @__PURE__ */ r(p.Option, {
|
127
|
-
...
|
128
|
-
className:
|
129
|
-
disabled:
|
130
|
+
...c,
|
131
|
+
className: u.option,
|
132
|
+
disabled: K(),
|
130
133
|
value: t,
|
131
|
-
children: /* @__PURE__ */ r(
|
132
|
-
className:
|
134
|
+
children: /* @__PURE__ */ r(Q, {
|
135
|
+
className: u.highlightOptionText,
|
133
136
|
value: O || t
|
134
137
|
})
|
135
138
|
});
|
136
|
-
},
|
139
|
+
}, j = (e) => {
|
137
140
|
s == null || s(e), o.search(e);
|
138
|
-
},
|
141
|
+
}, U = () => {
|
139
142
|
var e;
|
140
143
|
o.reload(), (e = g.current) == null || e.focus();
|
141
144
|
};
|
142
|
-
let
|
143
|
-
o.hasError && !o.isLoading ?
|
144
|
-
onTryAgain:
|
145
|
-
}) : o.isEmpty && !o.isLoading ?
|
146
|
-
const [
|
147
|
-
rootRef:
|
145
|
+
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,
|
148
151
|
isVisible: A
|
149
|
-
}] =
|
150
|
-
rootMargin:
|
152
|
+
}] = co({
|
153
|
+
rootMargin: xo
|
151
154
|
});
|
152
|
-
|
155
|
+
ao(() => {
|
153
156
|
if (!(A && o.hasNextPage))
|
154
157
|
return;
|
155
158
|
const t = setTimeout(() => {
|
@@ -159,7 +162,7 @@ const lo = "_container_16dlc_1", co = "_highlightOptionText_16dlc_7", uo = "_opt
|
|
159
162
|
clearTimeout(t);
|
160
163
|
};
|
161
164
|
}, [A]);
|
162
|
-
const
|
165
|
+
const J = _(() => {
|
163
166
|
const e = o.hasNextPage ? {
|
164
167
|
displayValue: R,
|
165
168
|
value: R
|
@@ -168,28 +171,32 @@ const lo = "_container_16dlc_1", co = "_highlightOptionText_16dlc_7", uo = "_opt
|
|
168
171
|
value: L
|
169
172
|
} : null;
|
170
173
|
return [...o.items, ...x, e, t].filter(Boolean);
|
171
|
-
}, [o.hasNextPage, o.hasError, o.isEmpty, o.items, x]);
|
174
|
+
}, [o.hasNextPage, o.hasError, o.isEmpty, o.items, x]), E = !l && n.length === 1;
|
172
175
|
return /* @__PURE__ */ r(p, {
|
173
176
|
as: "input",
|
174
|
-
...
|
177
|
+
...w,
|
175
178
|
ref: g,
|
176
|
-
|
179
|
+
className: ro({
|
180
|
+
[u.disabled]: E
|
181
|
+
}),
|
182
|
+
clearButtonAriaLabel: d(a.clearButtonAriaLabel),
|
183
|
+
disabled: F || E,
|
177
184
|
displayValue: (e) => e.displayValue || e.value,
|
178
|
-
endComboboxIcon:
|
185
|
+
endComboboxIcon: Oo,
|
179
186
|
focusLoop: !1,
|
180
|
-
getPopoverRef:
|
187
|
+
getPopoverRef: H,
|
181
188
|
loading: o.isReloading,
|
182
|
-
loadingAriaLabel:
|
183
|
-
multiselect:
|
184
|
-
noResultMessage:
|
185
|
-
onFocus:
|
186
|
-
onInputValueChange:
|
187
|
-
onValueChange:
|
188
|
-
options:
|
189
|
-
renderOption:
|
190
|
-
value:
|
189
|
+
loadingAriaLabel: k || d(a.loadingAriaLabel),
|
190
|
+
multiselect: l,
|
191
|
+
noResultMessage: m,
|
192
|
+
onFocus: B,
|
193
|
+
onInputValueChange: j,
|
194
|
+
onValueChange: z,
|
195
|
+
options: J,
|
196
|
+
renderOption: W,
|
197
|
+
value: G
|
191
198
|
});
|
192
199
|
};
|
193
200
|
export {
|
194
|
-
|
201
|
+
So as ComboboxWithApiPagination
|
195
202
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@box/metadata-editor",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.62.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": "ab664c931e214b862035e211809f92f711a0a2d4"
|
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);
|