@box/user-selector 1.74.32 → 1.74.34

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.
Files changed (29) hide show
  1. package/dist/chunks/buildOptionsWithOverlay.js +21 -22
  2. package/dist/chunks/user-selector-headless.module.js +13 -14
  3. package/dist/chunks/user-selector-list-item.js +84 -0
  4. package/dist/chunks/user-selector.js +89 -0
  5. package/dist/esm/index.js +4 -9
  6. package/dist/esm/lib/messages.js +42 -44
  7. package/dist/esm/lib/shared.js +6 -8
  8. package/dist/esm/lib/user-selector-container.js +29 -42
  9. package/dist/esm/lib/user-selector-headless/components/user-avatar.js +25 -31
  10. package/dist/esm/lib/user-selector-headless/components/user-selector-content.js +27 -50
  11. package/dist/esm/lib/user-selector-headless/components/user-selector-default-empty.js +34 -42
  12. package/dist/esm/lib/user-selector-headless/components/user-selector-default-error.js +13 -19
  13. package/dist/esm/lib/user-selector-headless/components/user-selector-skeleton.js +19 -25
  14. package/dist/esm/lib/user-selector-headless/hooks/use-avatars.js +13 -21
  15. package/dist/esm/lib/user-selector-headless/hooks/use-keyboard-navigation.js +25 -27
  16. package/dist/esm/lib/user-selector-headless/hooks/use-select-options.js +24 -27
  17. package/dist/esm/lib/user-selector-headless/user-selector-context.js +6 -10
  18. package/dist/esm/lib/user-selector-headless/user-selector-headless.js +171 -167
  19. package/dist/esm/lib/user-selector-list-item.js +2 -113
  20. package/dist/esm/lib/user-selector.js +2 -108
  21. package/dist/esm/lib/utils/VariantsAggregator.js +26 -45
  22. package/dist/esm/lib/utils/buildOptionsWithOverlay.js +2 -4
  23. package/dist/esm/lib/utils/defaultRenderCustomOption.js +10 -11
  24. package/dist/esm/lib/utils/getInitials.js +4 -6
  25. package/dist/esm/lib/utils/isUserContactType.js +3 -5
  26. package/dist/styles/user-selector-headless.css +1 -1
  27. package/dist/styles/user-selector-list-item.css +1 -1
  28. package/dist/styles/user-selector.css +1 -1
  29. package/package.json +8 -8
@@ -1,43 +1,35 @@
1
- import { Text as c } from "@box/blueprint-web";
2
- import { AvatarPlusBadge as n } from "@box/blueprint-web-assets/icons/Line";
3
- import { useCallback as i } from "react";
4
- import { useIntl as p } from "react-intl";
5
- import a from "../../messages.js";
6
- import { useUserSelector as u } from "../user-selector-context.js";
7
- import { s as e } from "../../../../chunks/user-selector-headless.module.js";
8
- import { jsxs as m, jsx as t } from "react/jsx-runtime";
9
- const C = ({
10
- handleInvite: r
11
- }) => {
12
- const {
13
- formatMessage: s
14
- } = p(), {
15
- value: o
16
- } = u(), l = i(() => {
17
- r?.(o);
18
- }, [r, o]);
19
- return /* @__PURE__ */ m("div", {
20
- className: e.userSelectorEmptyContainer,
21
- children: [/* @__PURE__ */ t("div", {
22
- className: e.userSelectorEmptyText,
23
- children: s(a.emptyMessage)
24
- }), r && /* @__PURE__ */ m("button", {
25
- className: e.userSelectorInviteRow,
26
- onClick: l,
27
- tabIndex: 0,
28
- type: "button",
29
- children: [/* @__PURE__ */ t("span", {
30
- className: e.userSelectorInviteButtonIcon,
31
- children: /* @__PURE__ */ t(n, {})
32
- }), /* @__PURE__ */ t(c, {
33
- as: "span",
34
- className: e.userName,
35
- variant: "bodyDefault",
36
- children: s(a.inviteCollaborators)
37
- })]
38
- })]
39
- });
40
- };
41
- export {
42
- C as UserSelectorDefaultEmpty
1
+ import e from "../../messages.js";
2
+ import { useUserSelector as t } from "../user-selector-context.js";
3
+ import { t as n } from "../../../../chunks/user-selector-headless.module.js";
4
+ import { useCallback as r } from "react";
5
+ import { useIntl as i } from "react-intl";
6
+ import { Text as a } from "@box/blueprint-web";
7
+ import { AvatarPlusBadge as o } from "@box/blueprint-web-assets/icons/Line";
8
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
9
+ var l = ({ handleInvite: l }) => {
10
+ let { formatMessage: u } = i(), { value: d } = t(), f = r(() => {
11
+ l?.(d);
12
+ }, [l, d]);
13
+ return /* @__PURE__ */ c("div", {
14
+ className: n.userSelectorEmptyContainer,
15
+ children: [/* @__PURE__ */ s("div", {
16
+ className: n.userSelectorEmptyText,
17
+ children: u(e.emptyMessage)
18
+ }), l && /* @__PURE__ */ c("button", {
19
+ className: n.userSelectorInviteRow,
20
+ onClick: f,
21
+ tabIndex: 0,
22
+ type: "button",
23
+ children: [/* @__PURE__ */ s("span", {
24
+ className: n.userSelectorInviteButtonIcon,
25
+ children: /* @__PURE__ */ s(o, {})
26
+ }), /* @__PURE__ */ s(a, {
27
+ as: "span",
28
+ className: n.userName,
29
+ variant: "bodyDefault",
30
+ children: u(e.inviteCollaborators)
31
+ })]
32
+ })]
33
+ });
43
34
  };
35
+ export { l as UserSelectorDefaultEmpty };
@@ -1,20 +1,14 @@
1
- import { InlineNotice as t } from "@box/blueprint-web";
2
- import { useIntl as s, FormattedMessage as a } from "react-intl";
3
- import r from "../../messages.js";
4
- import { jsx as e } from "react/jsx-runtime";
5
- const l = () => {
6
- const {
7
- formatMessage: o
8
- } = s();
9
- return /* @__PURE__ */ e(t, {
10
- title: o(r.errorMessage),
11
- variant: "error",
12
- variantIconAriaLabel: "error",
13
- children: /* @__PURE__ */ e(a, {
14
- ...r.errorMessageDescription
15
- })
16
- });
17
- };
18
- export {
19
- l as UserSelectorDefaultError
1
+ import e from "../../messages.js";
2
+ import { FormattedMessage as t, useIntl as n } from "react-intl";
3
+ import { InlineNotice as r } from "@box/blueprint-web";
4
+ import { jsx as i } from "react/jsx-runtime";
5
+ var a = () => {
6
+ let { formatMessage: a } = n();
7
+ return /* @__PURE__ */ i(r, {
8
+ title: a(e.errorMessage),
9
+ variant: "error",
10
+ variantIconAriaLabel: "error",
11
+ children: /* @__PURE__ */ i(t, { ...e.errorMessageDescription })
12
+ });
20
13
  };
14
+ export { a as UserSelectorDefaultError };
@@ -1,27 +1,21 @@
1
+ import { t as e } from "../../../../chunks/user-selector-headless.module.js";
1
2
  import { Ghost as t } from "@box/blueprint-web";
2
- import { Size8 as r, Size5 as a } from "@box/blueprint-web-assets/tokens/tokens";
3
- import { s as i } from "../../../../chunks/user-selector-headless.module.js";
4
- import { jsx as e, jsxs as l } from "react/jsx-runtime";
5
- const S = ({
6
- loadingAriaLabel: o
7
- }) => /* @__PURE__ */ e("div", {
8
- "aria-label": o,
9
- children: Array.from({
10
- length: 4
11
- }, (h, s) => /* @__PURE__ */ l("div", {
12
- className: i.userSelectorGhostStateItem,
13
- children: [/* @__PURE__ */ e(t, {
14
- className: i.titleGhost,
15
- height: r,
16
- variant: "rectangle",
17
- width: r
18
- }), /* @__PURE__ */ e(t, {
19
- height: a,
20
- variant: "rectangle",
21
- width: "100%"
22
- })]
23
- }, s))
3
+ import { jsx as n, jsxs as r } from "react/jsx-runtime";
4
+ import { Size5 as i, Size8 as a } from "@box/blueprint-web-assets/tokens/tokens";
5
+ var o = ({ loadingAriaLabel: o }) => /* @__PURE__ */ n("div", {
6
+ "aria-label": o,
7
+ children: Array.from({ length: 4 }, (o, s) => /* @__PURE__ */ r("div", {
8
+ className: e.userSelectorGhostStateItem,
9
+ children: [/* @__PURE__ */ n(t, {
10
+ className: e.titleGhost,
11
+ height: a,
12
+ variant: "rectangle",
13
+ width: a
14
+ }), /* @__PURE__ */ n(t, {
15
+ height: i,
16
+ variant: "rectangle",
17
+ width: "100%"
18
+ })]
19
+ }, s))
24
20
  });
25
- export {
26
- S as UserSelectorSkeleton
27
- };
21
+ export { o as UserSelectorSkeleton };
@@ -1,22 +1,14 @@
1
- import { useState as u, useCallback as l, useEffect as v } from "react";
2
- const o = ({
3
- fetchAvatarUrls: s,
4
- options: a
5
- }) => {
6
- const [e, t] = u({}), r = l(async (c) => {
7
- try {
8
- const n = await s(c);
9
- t(n);
10
- } catch {
11
- t({});
12
- }
13
- }, [s, t]);
14
- return v(() => {
15
- a.length > 0 && r(a);
16
- }, [a, r]), {
17
- avatars: e
18
- };
19
- };
20
- export {
21
- o as useAvatars
1
+ import { useCallback as e, useEffect as t, useState as n } from "react";
2
+ var r = ({ fetchAvatarUrls: r, options: i }) => {
3
+ let [a, o] = n({}), s = e(async (e) => {
4
+ try {
5
+ o(await r(e));
6
+ } catch {
7
+ o({});
8
+ }
9
+ }, [r, o]);
10
+ return t(() => {
11
+ i.length > 0 && s(i);
12
+ }, [i, s]), { avatars: a };
22
13
  };
14
+ export { r as useAvatars };
@@ -1,27 +1,25 @@
1
- import { useCallback as t } from "react";
2
- const n = ({
3
- isLoading: a,
4
- error: e,
5
- isEmpty: u,
6
- open: b,
7
- selectNext: f,
8
- selectPrevious: k,
9
- selectItem: o
10
- }) => t((r) => {
11
- if (!(!b || a || e || u))
12
- switch (r.key) {
13
- case "ArrowDown":
14
- r.preventDefault(), f();
15
- break;
16
- case "ArrowUp":
17
- r.preventDefault(), k();
18
- break;
19
- case "Enter":
20
- case " ":
21
- r.preventDefault(), o();
22
- break;
23
- }
24
- }, [e, u, a, b, f, k, o]);
25
- export {
26
- n as useKeyboardNavigation
27
- };
1
+ import { useCallback as e } from "react";
2
+ var t = ({ isLoading: t, error: n, isEmpty: r, open: i, selectNext: a, selectPrevious: o, selectItem: s }) => e((e) => {
3
+ if (!(!i || t || n || r)) switch (e.key) {
4
+ case "ArrowDown":
5
+ e.preventDefault(), a();
6
+ break;
7
+ case "ArrowUp":
8
+ e.preventDefault(), o();
9
+ break;
10
+ case "Enter":
11
+ case " ":
12
+ e.preventDefault(), s();
13
+ break;
14
+ default: break;
15
+ }
16
+ }, [
17
+ n,
18
+ r,
19
+ t,
20
+ i,
21
+ a,
22
+ o,
23
+ s
24
+ ]);
25
+ export { t as useKeyboardNavigation };
@@ -1,28 +1,25 @@
1
- import O from "lodash/debounce";
2
- import { useState as e, useCallback as y, useMemo as E, useEffect as b } from "react";
3
- const S = ({
4
- fetcher: a,
5
- value: n,
6
- debounceTime: r = 250,
7
- allowEmptyQuery: f = !1
8
- }) => {
9
- const [u, o] = e(!1), [d, c] = e(!1), [m, l] = e(null), [g, i] = e([]), p = y(async (h) => {
10
- try {
11
- const t = await a(h);
12
- c(t?.length === 0), i(t);
13
- } catch (t) {
14
- l(t);
15
- } finally {
16
- o(!1);
17
- }
18
- }, [a]), s = E(() => O(p, r), [p, r]);
19
- return b(() => (n.length || f ? (o(!0), l(null), c(!1), s(n)) : (s.cancel(), o(!1), i([]), l(null), c(!1)), () => s.cancel()), [n, s, f]), {
20
- isLoading: u,
21
- isEmpty: d,
22
- error: m,
23
- options: g
24
- };
25
- };
26
- export {
27
- S as useSelectOptions
1
+ import { useCallback as e, useEffect as t, useMemo as n, useState as r } from "react";
2
+ import i from "lodash/debounce";
3
+ var a = ({ fetcher: a, value: o, debounceTime: s = 250, allowEmptyQuery: c = !1 }) => {
4
+ let [l, u] = r(!1), [d, f] = r(!1), [p, m] = r(null), [h, g] = r([]), _ = e(async (e) => {
5
+ try {
6
+ let t = await a(e);
7
+ f(t?.length === 0), g(t);
8
+ } catch (e) {
9
+ m(e);
10
+ } finally {
11
+ u(!1);
12
+ }
13
+ }, [a]), v = n(() => i(_, s), [_, s]);
14
+ return t(() => (o.length || c ? (u(!0), m(null), f(!1), v(o)) : (v.cancel(), u(!1), g([]), m(null), f(!1)), () => v.cancel()), [
15
+ o,
16
+ v,
17
+ c
18
+ ]), {
19
+ isLoading: l,
20
+ isEmpty: d,
21
+ error: p,
22
+ options: h
23
+ };
28
24
  };
25
+ export { a as useSelectOptions };
@@ -1,11 +1,7 @@
1
- import { createContext as t, useContext as r } from "react";
2
- const o = /* @__PURE__ */ t(null), n = () => {
3
- const e = r(o);
4
- if (!e)
5
- throw new Error("useUserSelector must be used within a UserSelectorProvider");
6
- return e;
7
- };
8
- export {
9
- o as UserSelectorContext,
10
- n as useUserSelector
1
+ import { createContext as e, useContext as t } from "react";
2
+ var n = /* @__PURE__ */ e(null), r = () => {
3
+ let e = t(n);
4
+ if (!e) throw Error("useUserSelector must be used within a UserSelectorProvider");
5
+ return e;
11
6
  };
7
+ export { n as UserSelectorContext, r as useUserSelector };