@box/user-selector 1.21.23 → 1.22.3
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,162 +1,163 @@
|
|
|
1
|
-
import { Popover as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import { Popover as p } from "@box/blueprint-web";
|
|
2
|
+
import W from "clsx";
|
|
3
|
+
import { forwardRef as X, useState as Y, useId as Z, useRef as _, useMemo as M, useCallback as i, useImperativeHandle as F, useEffect as P } from "react";
|
|
4
|
+
import { UserSelectorContent as U } from "./components/user-selector-content.js";
|
|
5
|
+
import { useAvatars as E } from "./hooks/use-avatars.js";
|
|
6
|
+
import { useKeyboardNavigation as C } from "./hooks/use-keyboard-navigation.js";
|
|
7
|
+
import { useSelectOptions as tt } from "./hooks/use-select-options.js";
|
|
8
|
+
import { UserSelectorContext as et } from "./user-selector-context.js";
|
|
9
|
+
import { s as R } from "../../../chunks/user-selector-headless.module.js";
|
|
10
|
+
import { jsx as a, jsxs as ot } from "react/jsx-runtime";
|
|
11
|
+
const dt = /* @__PURE__ */ X(({
|
|
12
|
+
fetchUsers: v,
|
|
13
|
+
fetchAvatarUrls: y,
|
|
14
|
+
open: I,
|
|
15
|
+
value: N,
|
|
16
|
+
rootElement: $,
|
|
17
|
+
onSelectedUserChange: f,
|
|
18
|
+
inputElementRef: A,
|
|
19
|
+
focusOnOpen: b = !1,
|
|
20
|
+
renderError: H,
|
|
21
|
+
renderEmpty: L,
|
|
22
|
+
loadingAriaLabel: V,
|
|
23
|
+
ariaRoleDescription: q,
|
|
23
24
|
nativeFocusEnabled: c = !0,
|
|
24
|
-
allowEmptyQuery:
|
|
25
|
-
onInvite:
|
|
26
|
-
popoverContentContainerProps:
|
|
27
|
-
},
|
|
28
|
-
const [
|
|
25
|
+
allowEmptyQuery: S = !1,
|
|
26
|
+
onInvite: T,
|
|
27
|
+
popoverContentContainerProps: u
|
|
28
|
+
}, z) => {
|
|
29
|
+
const [n, h] = Y(null), {
|
|
29
30
|
options: t,
|
|
30
|
-
isEmpty:
|
|
31
|
-
isLoading:
|
|
32
|
-
error:
|
|
33
|
-
} =
|
|
34
|
-
fetcher:
|
|
35
|
-
value:
|
|
36
|
-
allowEmptyQuery:
|
|
31
|
+
isEmpty: j,
|
|
32
|
+
isLoading: k,
|
|
33
|
+
error: D
|
|
34
|
+
} = tt({
|
|
35
|
+
fetcher: v,
|
|
36
|
+
value: N,
|
|
37
|
+
allowEmptyQuery: S
|
|
37
38
|
}), {
|
|
38
|
-
avatars:
|
|
39
|
-
} =
|
|
40
|
-
fetchAvatarUrls:
|
|
39
|
+
avatars: B
|
|
40
|
+
} = E({
|
|
41
|
+
fetchAvatarUrls: y,
|
|
41
42
|
options: t
|
|
42
|
-
}),
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
45
|
-
if (
|
|
46
|
-
|
|
43
|
+
}), m = Z(), x = _(/* @__PURE__ */ new Map()), K = M(() => `listbox-${m}`, [m]), o = i((e) => `${m}-option-${e.id}`, [m]), r = i((e) => {
|
|
44
|
+
const s = x.current.get(e);
|
|
45
|
+
if (s) {
|
|
46
|
+
if (h(e), c) {
|
|
47
|
+
s.focus();
|
|
47
48
|
return;
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
+
s.scrollIntoView({
|
|
50
51
|
behavior: "smooth",
|
|
51
52
|
block: "nearest",
|
|
52
53
|
inline: "nearest"
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
|
-
}, [c]), l =
|
|
56
|
-
var
|
|
57
|
-
(
|
|
58
|
-
}, [
|
|
59
|
-
if (
|
|
60
|
-
const
|
|
61
|
-
|
|
56
|
+
}, [c]), l = M(() => t.findIndex((e) => o(e) === n), [n, o, t]), d = i(() => {
|
|
57
|
+
var e;
|
|
58
|
+
(e = A.current) == null || e.focus(), h(null);
|
|
59
|
+
}, [A]), O = i(() => {
|
|
60
|
+
if (n) {
|
|
61
|
+
const e = t.find((s) => o(s) === n);
|
|
62
|
+
e && f(e);
|
|
62
63
|
}
|
|
63
|
-
}, [
|
|
64
|
+
}, [f, n, o, t]), g = i(() => {
|
|
64
65
|
if (t.length === 0)
|
|
65
66
|
return;
|
|
66
67
|
if (l < t.length - 1) {
|
|
67
|
-
const
|
|
68
|
-
|
|
68
|
+
const s = o(t[l + 1]);
|
|
69
|
+
r(s);
|
|
69
70
|
return;
|
|
70
71
|
}
|
|
71
72
|
if (c) {
|
|
72
|
-
|
|
73
|
+
d();
|
|
73
74
|
return;
|
|
74
75
|
}
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
}, [l,
|
|
76
|
+
const e = o(t[0]);
|
|
77
|
+
r(e);
|
|
78
|
+
}, [l, r, o, t, c, d]), w = i(() => {
|
|
78
79
|
if (t.length === 0)
|
|
79
80
|
return;
|
|
80
81
|
if (l > 0) {
|
|
81
|
-
const
|
|
82
|
-
|
|
82
|
+
const s = o(t[l - 1]);
|
|
83
|
+
r(s);
|
|
83
84
|
return;
|
|
84
85
|
}
|
|
85
86
|
if (c) {
|
|
86
|
-
|
|
87
|
+
d();
|
|
87
88
|
return;
|
|
88
89
|
}
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
}, [l,
|
|
92
|
-
isLoading:
|
|
93
|
-
error:
|
|
94
|
-
isEmpty:
|
|
95
|
-
open:
|
|
96
|
-
selectNext:
|
|
97
|
-
selectPrevious:
|
|
98
|
-
selectItem:
|
|
99
|
-
}),
|
|
100
|
-
|
|
101
|
-
}, [
|
|
102
|
-
|
|
90
|
+
const e = o(t[t.length - 1]);
|
|
91
|
+
r(e);
|
|
92
|
+
}, [l, r, o, t, c, d]), G = C({
|
|
93
|
+
isLoading: k,
|
|
94
|
+
error: D,
|
|
95
|
+
isEmpty: j,
|
|
96
|
+
open: I,
|
|
97
|
+
selectNext: g,
|
|
98
|
+
selectPrevious: w,
|
|
99
|
+
selectItem: O
|
|
100
|
+
}), J = i((e, s) => {
|
|
101
|
+
r(s), f(e);
|
|
102
|
+
}, [r, f]);
|
|
103
|
+
F(z, () => ({
|
|
103
104
|
focusFirstOption: () => {
|
|
104
|
-
t.length > 0 &&
|
|
105
|
+
t.length > 0 && r(o(t[0]));
|
|
105
106
|
},
|
|
106
107
|
focusLastOption: () => {
|
|
107
|
-
t.length > 0 &&
|
|
108
|
+
t.length > 0 && r(o(t[t.length - 1]));
|
|
108
109
|
},
|
|
109
|
-
selectNext:
|
|
110
|
-
selectPrevious:
|
|
111
|
-
selectItem:
|
|
112
|
-
}), [
|
|
113
|
-
t.length > 0 &&
|
|
114
|
-
}, [t,
|
|
115
|
-
const
|
|
116
|
-
fetchUsers:
|
|
117
|
-
fetchAvatarUrls:
|
|
118
|
-
onSelectedUserChange:
|
|
119
|
-
value:
|
|
120
|
-
avatars:
|
|
121
|
-
activeId:
|
|
122
|
-
setActiveId:
|
|
123
|
-
listboxId:
|
|
124
|
-
getOptionId:
|
|
110
|
+
selectNext: g,
|
|
111
|
+
selectPrevious: w,
|
|
112
|
+
selectItem: O
|
|
113
|
+
}), [r, o, t, g, w, O]), P(() => {
|
|
114
|
+
t.length > 0 && b && r(o(t[0]));
|
|
115
|
+
}, [t, I, o, r, b]);
|
|
116
|
+
const Q = {
|
|
117
|
+
fetchUsers: v,
|
|
118
|
+
fetchAvatarUrls: y,
|
|
119
|
+
onSelectedUserChange: f,
|
|
120
|
+
value: N,
|
|
121
|
+
avatars: B,
|
|
122
|
+
activeId: n,
|
|
123
|
+
setActiveId: h,
|
|
124
|
+
listboxId: K,
|
|
125
|
+
getOptionId: o
|
|
125
126
|
};
|
|
126
|
-
return /* @__PURE__ */
|
|
127
|
-
value:
|
|
128
|
-
children: /* @__PURE__ */ ot(
|
|
127
|
+
return /* @__PURE__ */ a(et.Provider, {
|
|
128
|
+
value: Q,
|
|
129
|
+
children: /* @__PURE__ */ ot(p.Root, {
|
|
129
130
|
modal: !1,
|
|
130
|
-
open:
|
|
131
|
-
children: [/* @__PURE__ */
|
|
132
|
-
children:
|
|
133
|
-
}), /* @__PURE__ */
|
|
134
|
-
...
|
|
131
|
+
open: I,
|
|
132
|
+
children: [/* @__PURE__ */ a(p.Anchor, {
|
|
133
|
+
children: $
|
|
134
|
+
}), /* @__PURE__ */ a(p.ContentContainer, {
|
|
135
|
+
...u,
|
|
135
136
|
align: "start",
|
|
136
|
-
className:
|
|
137
|
-
onOpenAutoFocus: (
|
|
138
|
-
|
|
137
|
+
className: W(R.popoverContainer, u == null ? void 0 : u.className),
|
|
138
|
+
onOpenAutoFocus: (e) => {
|
|
139
|
+
e.preventDefault();
|
|
139
140
|
},
|
|
140
|
-
children: /* @__PURE__ */
|
|
141
|
-
"aria-activedescendant":
|
|
142
|
-
"aria-owns": Array.from(
|
|
143
|
-
"aria-roledescription":
|
|
144
|
-
className:
|
|
145
|
-
id:
|
|
146
|
-
onKeyDown:
|
|
141
|
+
children: /* @__PURE__ */ a(p.MainContent, {
|
|
142
|
+
"aria-activedescendant": n,
|
|
143
|
+
"aria-owns": Array.from(x.current.values()).map((e) => e.id).join(" "),
|
|
144
|
+
"aria-roledescription": q,
|
|
145
|
+
className: R.popoverContent,
|
|
146
|
+
id: K,
|
|
147
|
+
onKeyDown: G,
|
|
147
148
|
role: "listbox",
|
|
148
149
|
tabIndex: -1,
|
|
149
|
-
children: /* @__PURE__ */
|
|
150
|
-
error:
|
|
151
|
-
handleInvite:
|
|
152
|
-
handleOptionClick:
|
|
153
|
-
isEmpty:
|
|
154
|
-
isLoading:
|
|
155
|
-
loadingAriaLabel:
|
|
156
|
-
optionRefs:
|
|
150
|
+
children: /* @__PURE__ */ a(U, {
|
|
151
|
+
error: D,
|
|
152
|
+
handleInvite: T,
|
|
153
|
+
handleOptionClick: J,
|
|
154
|
+
isEmpty: j,
|
|
155
|
+
isLoading: k,
|
|
156
|
+
loadingAriaLabel: V,
|
|
157
|
+
optionRefs: x,
|
|
157
158
|
options: t,
|
|
158
|
-
renderEmpty:
|
|
159
|
-
renderError:
|
|
159
|
+
renderEmpty: L,
|
|
160
|
+
renderError: H
|
|
160
161
|
})
|
|
161
162
|
})
|
|
162
163
|
})]
|
|
@@ -164,5 +165,5 @@ const pt = /* @__PURE__ */ J(({
|
|
|
164
165
|
});
|
|
165
166
|
});
|
|
166
167
|
export {
|
|
167
|
-
|
|
168
|
+
dt as UserSelectorHeadless
|
|
168
169
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/user-selector",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.3",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@box/blueprint-web": "^7.8.0",
|
|
6
6
|
"@box/blueprint-web-assets": "^4.16.0",
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"react-intl": "6.4.2"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@box/blueprint-web": "^12.
|
|
15
|
-
"@box/blueprint-web-assets": "^4.
|
|
16
|
-
"@box/combobox-with-api": "^0.57.
|
|
17
|
-
"@box/storybook-utils": "^0.14.
|
|
14
|
+
"@box/blueprint-web": "^12.69.1",
|
|
15
|
+
"@box/blueprint-web-assets": "^4.67.0",
|
|
16
|
+
"@box/combobox-with-api": "^0.57.27",
|
|
17
|
+
"@box/storybook-utils": "^0.14.3",
|
|
18
18
|
"@types/lodash": "^4.17.14",
|
|
19
19
|
"react": "^18.3.0",
|
|
20
20
|
"react-dom": "^18.3.0",
|