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