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