@box/metadata-editor 0.108.3 → 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.
- package/dist/esm/lib/components/combobox-with-api-pagination/combobox-with-api-pagination.js +72 -70
- package/dist/types/lib/components/combobox-with-api-pagination/combobox-with-api-pagination.d.ts +1 -0
- package/dist/types/lib/components/combobox-with-api-pagination/types.d.ts +1 -0
- package/package.json +2 -2
package/dist/esm/lib/components/combobox-with-api-pagination/combobox-with-api-pagination.js
CHANGED
@@ -1,48 +1,48 @@
|
|
1
|
-
import { ComboboxItemValue as
|
2
|
-
import { Combobox as m, useForkRef as
|
3
|
-
import { Search as
|
4
|
-
import { IconIconOnLightSecondary as
|
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
|
7
|
-
import { useIntl as F, FormattedMessage as
|
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
|
10
|
-
import { useControllableState as
|
11
|
-
import { useTrackVisibility as
|
12
|
-
import { jsx as r, jsxs as
|
13
|
-
import '../../../../styles/combobox-with-api-pagination.css';const be = "_container_syvk5_1",
|
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:
|
16
|
-
highlightOptionText:
|
17
|
-
selected:
|
18
|
-
option:
|
19
|
-
errorComboboxOption:
|
20
|
-
errorComboboxOptionText:
|
21
|
-
},
|
22
|
-
onTryAgain:
|
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__ */
|
28
|
-
children: [/* @__PURE__ */ r(
|
27
|
+
return /* @__PURE__ */ V(ge, {
|
28
|
+
children: [/* @__PURE__ */ r(ie, {
|
29
29
|
variant: "error",
|
30
30
|
variantIconAriaLabel: h(i.loadingResultsErrorIconLabel),
|
31
|
-
children: /* @__PURE__ */ r(
|
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:
|
38
|
-
children: /* @__PURE__ */
|
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(
|
43
|
+
children: [/* @__PURE__ */ r(S, {
|
44
44
|
...i.loadingResultsErrorAction
|
45
|
-
}), /* @__PURE__ */ r(
|
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__",
|
54
|
-
color:
|
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:
|
58
|
+
padding: ue,
|
59
59
|
boxSizing: "border-box"
|
60
60
|
},
|
61
61
|
width: M
|
62
|
-
}),
|
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
|
-
|
74
|
+
displaySingleSelectionAsChip: U = !0,
|
75
|
+
...q
|
75
76
|
} = p, {
|
76
77
|
formatMessage: u
|
77
|
-
} = F(),
|
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),
|
94
|
+
}), E = v(!1), H = de(() => {
|
94
95
|
E.current || (e.reload(), E.current = !0);
|
95
|
-
}, []), [n, x] =
|
96
|
+
}, []), [n, x] = he({
|
96
97
|
prop: D,
|
97
98
|
defaultProp: W,
|
98
99
|
onChange: w
|
99
|
-
}), _ = !l && n.length === 1,
|
100
|
-
o === void 0 ? (x([]),
|
101
|
-
},
|
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:
|
111
|
+
ref: Z,
|
111
112
|
disabled: !0,
|
112
113
|
value: t,
|
113
|
-
children: /* @__PURE__ */ r(
|
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 ===
|
121
|
-
return /* @__PURE__ */ r(
|
121
|
+
if (t === A && e.hasError && !e.isEmpty)
|
122
|
+
return /* @__PURE__ */ r(N, {
|
122
123
|
onTryAgain: () => {
|
123
124
|
var s;
|
124
|
-
e.loadMore(), (s =
|
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
|
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(
|
135
|
-
className: T(a.highlightOptionText,
|
135
|
+
children: /* @__PURE__ */ r(te, {
|
136
|
+
className: T(a.highlightOptionText, oe && a.selected),
|
136
137
|
value: y || t
|
137
138
|
})
|
138
139
|
});
|
139
|
-
},
|
140
|
+
}, X = (o) => {
|
140
141
|
if (f == null || f(o), _ && o === "") {
|
141
|
-
|
142
|
+
b.current = !1;
|
142
143
|
return;
|
143
144
|
}
|
144
145
|
e.search(o);
|
145
|
-
},
|
146
|
+
}, Y = () => {
|
146
147
|
var o;
|
147
|
-
e.reload(), (o =
|
148
|
+
e.reload(), (o = g.current) == null || o.focus();
|
148
149
|
};
|
149
150
|
let d;
|
150
|
-
e.hasError && !e.isLoading ? d = /* @__PURE__ */ r(
|
151
|
-
onTryAgain:
|
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 [
|
154
|
-
rootRef:
|
154
|
+
const [Z, {
|
155
|
+
rootRef: $,
|
155
156
|
isVisible: I
|
156
|
-
}] =
|
157
|
-
rootMargin:
|
157
|
+
}] = fe({
|
158
|
+
rootMargin: Ce
|
158
159
|
});
|
159
|
-
|
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
|
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:
|
175
|
-
value:
|
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
|
-
...
|
182
|
-
ref:
|
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:
|
191
|
+
endComboboxIcon: Ae,
|
190
192
|
focusLoop: !1,
|
191
|
-
getPopoverRef:
|
193
|
+
getPopoverRef: $,
|
192
194
|
loading: e.isReloading,
|
193
195
|
loadingAriaLabel: z || u(i.loadingAriaLabel),
|
194
196
|
multiselect: l,
|
195
197
|
noResultMessage: d,
|
196
|
-
onFocus:
|
197
|
-
onInputValueChange:
|
198
|
-
onValueChange:
|
199
|
-
options:
|
200
|
-
renderOption:
|
201
|
-
value:
|
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
|
-
|
207
|
+
we as ComboboxWithApiPagination
|
206
208
|
};
|
package/dist/types/lib/components/combobox-with-api-pagination/combobox-with-api-pagination.d.ts
CHANGED
@@ -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>>;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@box/metadata-editor",
|
3
|
-
"version": "0.
|
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.
|
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",
|