@alea-design/ui 0.7.2 → 0.8.1

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 (41) hide show
  1. package/dist/components/button/Button.d.ts +13 -2
  2. package/dist/components/button/Button.js +144 -111
  3. package/dist/components/celebrate/Celebrate.d.ts +31 -0
  4. package/dist/components/celebrate/Celebrate.js +50 -0
  5. package/dist/components/display/Display.d.ts +6 -1
  6. package/dist/components/display/Display.js +64 -63
  7. package/dist/components/feedback/Feedback.js +23 -23
  8. package/dist/components/field/Field.d.ts +15 -2
  9. package/dist/components/field/Field.js +165 -134
  10. package/dist/components/more/More.d.ts +3 -1
  11. package/dist/components/more/More.js +53 -53
  12. package/dist/components/notification/NotificationCenter.js +15 -15
  13. package/dist/components/picker/Picker.d.ts +5 -1
  14. package/dist/components/picker/Picker.js +212 -209
  15. package/dist/components/print/PrintSheet.d.ts +18 -0
  16. package/dist/components/print/PrintSheet.js +14 -0
  17. package/dist/components/shell/AccountFooter.d.ts +31 -0
  18. package/dist/components/shell/AccountFooter.js +43 -0
  19. package/dist/components/shell/AppShell.js +18 -18
  20. package/dist/components/shell/AppSidebar.js +31 -31
  21. package/dist/components/shell/sidebar-context.d.ts +5 -0
  22. package/dist/components/shell/sidebar-context.js +6 -0
  23. package/dist/css/base.css +1 -1
  24. package/dist/css/button.css +1 -1
  25. package/dist/css/celebrate.css +1 -0
  26. package/dist/css/choice.css +1 -1
  27. package/dist/css/display.css +1 -1
  28. package/dist/css/feedback.css +1 -1
  29. package/dist/css/field.css +1 -1
  30. package/dist/css/groups.json +28 -8
  31. package/dist/css/picker.css +1 -1
  32. package/dist/css/print.css +1 -0
  33. package/dist/css/shell.css +1 -1
  34. package/dist/i18n/strings.d.ts +17 -0
  35. package/dist/i18n/strings.js +41 -7
  36. package/dist/index.d.ts +4 -0
  37. package/dist/index.js +276 -267
  38. package/dist/styles.css +1 -1
  39. package/dist/utils/announcer.d.ts +21 -0
  40. package/dist/utils/announcer.js +30 -0
  41. package/package.json +3 -3
@@ -0,0 +1,31 @@
1
+ import { type HTMLAttributes, type ReactNode } from 'react';
2
+ import { type DropdownMenuProps } from '../menu/Menu.js';
3
+ export type AccountConnection = 'online' | 'offline' | 'syncing' | 'error';
4
+ export interface AccountFooterProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
5
+ /** The person's name: the avatar's initials and the first line. */
6
+ name: string;
7
+ /** A second line under the name: a role, a plan, an email. */
8
+ secondary?: ReactNode;
9
+ /** The photo. Initials show without it. */
10
+ src?: string;
11
+ /** The account menu items (MenuItem, MenuSection, MenuSeparator), passed by the product. Without them the person is plain text, not a button. */
12
+ children?: DropdownMenuProps<object>['children'];
13
+ /** Called with the id of the menu item picked. */
14
+ onAction?: (key: string | number) => void;
15
+ /** Replaces the accessible name of the person's button, and with it the menu's. Default: the name, role and connection as they show. */
16
+ menuLabel?: string;
17
+ /** Where the menu opens. Default top start, since the footer is at the bottom of the screen. */
18
+ placement?: DropdownMenuProps<object>['placement'];
19
+ /** A second action beside the person: usually an IconButton (settings). It keeps a 44 px target. It hides while the sidebar is collapsed to icons. */
20
+ action?: ReactNode;
21
+ /** A small dot on the avatar for the state of the connection, so the footer does not grow a row for it. The state is also spoken ("Online"). */
22
+ connection?: AccountConnection;
23
+ /** The spoken text of the connection. Default: Online, Offline, Syncing or Connection problem. */
24
+ connectionLabel?: string;
25
+ }
26
+ /**
27
+ * The bottom of an AppSidebar for the signed-in person: a small avatar with the name and role (or plan) that opens the account menu, an optional second action such as
28
+ * settings, and a dot for the connection on the avatar. It stays one compact row, with 44 px targets, and the text and the action wrap onto a second line instead of being
29
+ * cut when the text is scaled up. Pass it as the sidebar's `footer`.
30
+ */
31
+ export declare function AccountFooter({ name, secondary, src, children, onAction, menuLabel, placement, action, connection, connectionLabel, className, ...props }: AccountFooterProps): import("react").JSX.Element;
@@ -0,0 +1,43 @@
1
+ "use client";
2
+ import { jsxs as o, jsx as a, Fragment as p } from "react/jsx-runtime";
3
+ import { useContext as C } from "react";
4
+ import { Button as S } from "react-aria-components";
5
+ import { ChevronDown as b } from "lucide-react";
6
+ import { cx as j } from "../../utils/cx.js";
7
+ import { useStrings as w } from "../../i18n/strings.js";
8
+ import { Avatar as y } from "../display/Display.js";
9
+ import { DropdownMenu as A } from "../menu/Menu.js";
10
+ import { SidebarCtx as D } from "./sidebar-context.js";
11
+ function G({ name: t, secondary: s, src: f, children: r, onAction: c, menuLabel: n, placement: h = "top start", action: l, connection: e, connectionLabel: v, className: N, ...x }) {
12
+ const i = w(), { collapsed: d } = C(D), m = e ? v ?? i.connectionState[e] : void 0, u = /* @__PURE__ */ o(p, { children: [
13
+ /* @__PURE__ */ o("span", { className: "alea-account-footer-avatar", children: [
14
+ /* @__PURE__ */ a("span", { "aria-hidden": "true", children: /* @__PURE__ */ a(y, { name: t, src: f, size: "sm" }) }),
15
+ e && /* @__PURE__ */ a("span", { className: "alea-status-dot alea-account-footer-dot", "data-connection": e, "data-pulse": e === "syncing" || void 0, "aria-hidden": "true" })
16
+ ] }),
17
+ /* @__PURE__ */ o("span", { className: "alea-account-footer-text", children: [
18
+ /* @__PURE__ */ a("span", { className: "alea-account-footer-name", children: t }),
19
+ s && /* @__PURE__ */ o(p, { children: [
20
+ " ",
21
+ /* @__PURE__ */ a("span", { className: "alea-account-footer-secondary", children: s })
22
+ ] }),
23
+ m && /* @__PURE__ */ a("span", { className: "alea-visually-hidden", children: m })
24
+ ] }),
25
+ r && /* @__PURE__ */ a(b, { className: "alea-account-footer-chevron", "aria-hidden": "true" })
26
+ ] });
27
+ return /* @__PURE__ */ o("div", { ...x, className: j("alea-account-footer", N), "data-collapsed": d || void 0, children: [
28
+ r ? /* @__PURE__ */ a(
29
+ A,
30
+ {
31
+ "aria-label": n ?? i.accountMenuOf(t),
32
+ placement: h,
33
+ menuProps: c ? { onAction: (g) => c(g) } : void 0,
34
+ trigger: /* @__PURE__ */ a(S, { className: "alea-account-footer-person alea-focus-ring", "aria-label": n, children: u }),
35
+ children: r
36
+ }
37
+ ) : /* @__PURE__ */ a("div", { className: "alea-account-footer-person", "data-static": !0, children: u }),
38
+ l && !d && /* @__PURE__ */ a("span", { className: "alea-account-footer-action", children: l })
39
+ ] });
40
+ }
41
+ export {
42
+ G as AccountFooter
43
+ };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { jsxs as t, jsx as a, Fragment as y } from "react/jsx-runtime";
2
+ import { jsxs as d, jsx as a, Fragment as C } from "react/jsx-runtime";
3
3
  import { useState as M, forwardRef as O } from "react";
4
4
  import { Link as j } from "react-aria-components";
5
5
  import { Menu as D } from "lucide-react";
@@ -10,42 +10,42 @@ import { Drawer as A } from "../overlay/Drawer.js";
10
10
  import { Dialog as F } from "../overlay/Overlay.js";
11
11
  import { useStrings as g } from "../../i18n/strings.js";
12
12
  import { SkipLink as P } from "../more/More.js";
13
- function X({ brand: s, headerEnd: l, sidebar: e, children: r, sidebarWidth: d = 248, collapseBelow: n = 900, mainAs: c = "main", layout: o = "header", contentSize: m, skipLink: i, bottomBar: p, className: b }) {
14
- const f = g(), x = c, [S, h] = M(!1), C = I(`(max-width: ${n - 0.02}px)`), v = /* @__PURE__ */ t("header", { className: "alea-shell-header", children: [
13
+ function X({ brand: r, headerEnd: l, sidebar: e, children: s, sidebarWidth: t = 248, collapseBelow: n = 900, mainAs: c = "main", layout: o = "header", contentSize: m, skipLink: i, bottomBar: p, className: b }) {
14
+ const f = g(), x = c, [S, h] = M(!1), w = I(`(max-width: ${n - 0.02}px)`), v = /* @__PURE__ */ d("header", { className: "alea-shell-header", children: [
15
15
  e && /* @__PURE__ */ a($, { "aria-label": f.openNavigation, className: "alea-shell-menu", onPress: () => h(!0), children: /* @__PURE__ */ a(D, {}) }),
16
- s && /* @__PURE__ */ a("div", { className: "alea-shell-brand", children: s }),
16
+ r && /* @__PURE__ */ a("div", { className: "alea-shell-brand", children: r }),
17
17
  l && /* @__PURE__ */ a("div", { className: "alea-shell-end", children: l })
18
- ] }), N = /* @__PURE__ */ a(x, { id: "alea-main", className: "alea-shell-main", tabIndex: -1, children: m && m !== "full" ? /* @__PURE__ */ a("div", { className: "alea-shell-content", "data-size": m, children: r }) : r });
19
- return /* @__PURE__ */ t("div", { className: u("alea-shell", b), style: { "--alea-shell-sidebar": `${d}px` }, "data-layout": o, "data-collapse": n, "data-collapsed": C || void 0, "data-custom-collapse": n !== 900 || void 0, children: [
18
+ ] }), N = /* @__PURE__ */ a(x, { id: "alea-main", className: "alea-shell-main", tabIndex: -1, children: m && m !== "full" ? /* @__PURE__ */ a("div", { className: "alea-shell-content", "data-size": m, children: s }) : s });
19
+ return /* @__PURE__ */ d("div", { className: u("alea-shell", b), style: { "--alea-shell-sidebar": `${t}px` }, "data-layout": o, "data-collapse": n, "data-collapsed": w || void 0, "data-custom-collapse": n !== 900 || void 0, children: [
20
20
  i !== !1 && /* @__PURE__ */ a(P, { target: (i == null ? void 0 : i.target) ?? "alea-main", children: i == null ? void 0 : i.label }),
21
21
  o === "header" && v,
22
- /* @__PURE__ */ t("div", { className: "alea-shell-body", children: [
22
+ /* @__PURE__ */ d("div", { className: "alea-shell-body", children: [
23
23
  e && /* @__PURE__ */ a("aside", { className: "alea-shell-sidebar", children: e }),
24
- o === "sidebar" ? /* @__PURE__ */ t("div", { className: "alea-shell-panel", children: [
24
+ o === "sidebar" ? /* @__PURE__ */ d("div", { className: "alea-shell-panel", children: [
25
25
  v,
26
26
  N
27
27
  ] }) : N
28
28
  ] }),
29
29
  p && /* @__PURE__ */ a("div", { className: "alea-shell-bottom", children: p }),
30
- e && /* @__PURE__ */ a(A, { isOpen: S, onOpenChange: h, placement: "start", size: 300, children: /* @__PURE__ */ a(F, { "aria-label": f.navigation, hideClose: !0, className: "alea-shell-drawer", children: () => /* @__PURE__ */ a("div", { onClickCapture: (w) => {
31
- w.target.closest("a") && h(!1);
30
+ e && /* @__PURE__ */ a(A, { isOpen: S, onOpenChange: h, placement: "start", size: 300, children: /* @__PURE__ */ a(F, { "aria-label": f.navigation, hideClose: !0, className: "alea-shell-drawer", children: () => /* @__PURE__ */ a("div", { className: "alea-shell-drawer-body", onClickCapture: (y) => {
31
+ y.target.closest("a") && h(!1);
32
32
  }, children: e }) }) })
33
33
  ] });
34
34
  }
35
- function Y({ children: s, className: l, "aria-label": e }) {
36
- const r = g();
37
- return e ?? (e = r.mainNav), /* @__PURE__ */ a("nav", { "aria-label": e, className: u("alea-sidenav", l), children: s });
35
+ function Y({ children: r, className: l, "aria-label": e }) {
36
+ const s = g();
37
+ return e ?? (e = s.mainNav), /* @__PURE__ */ a("nav", { "aria-label": e, className: u("alea-sidenav", l), children: r });
38
38
  }
39
- const Z = O(function({ title: l, children: e, className: r, ...d }, n) {
40
- return /* @__PURE__ */ t("div", { ref: n, ...d, className: u("alea-sidenav-group", r), children: [
39
+ const Z = O(function({ title: l, children: e, className: s, ...t }, n) {
40
+ return /* @__PURE__ */ d("div", { ref: n, ...t, className: u("alea-sidenav-group", s), children: [
41
41
  l && /* @__PURE__ */ a("p", { className: "alea-sidenav-title", children: l }),
42
42
  /* @__PURE__ */ a("ul", { children: e })
43
43
  ] });
44
44
  });
45
- function _({ isCurrent: s, icon: l, end: e, children: r, className: d, ...n }) {
46
- return /* @__PURE__ */ a("li", { children: /* @__PURE__ */ a(j, { ...n, "aria-current": s ? "page" : void 0, className: G("alea-sidenav-link alea-focus-ring", d), children: (c) => /* @__PURE__ */ t(y, { children: [
45
+ function _({ isCurrent: r, icon: l, end: e, children: s, className: t, ...n }) {
46
+ return /* @__PURE__ */ a("li", { children: /* @__PURE__ */ a(j, { ...n, "aria-current": r ? "page" : void 0, className: G("alea-sidenav-link alea-focus-ring", t), children: (c) => /* @__PURE__ */ d(C, { children: [
47
47
  l && /* @__PURE__ */ a("span", { className: "alea-sidenav-icon", "aria-hidden": "true", children: l }),
48
- /* @__PURE__ */ a("span", { className: "alea-sidenav-label", children: typeof r == "function" ? r(c) : r }),
48
+ /* @__PURE__ */ a("span", { className: "alea-sidenav-label", children: typeof s == "function" ? s(c) : s }),
49
49
  e && /* @__PURE__ */ a("span", { className: "alea-sidenav-end", children: e })
50
50
  ] }) }) });
51
51
  }
@@ -1,63 +1,63 @@
1
1
  "use client";
2
2
  import { jsx as a, jsxs as l, Fragment as g } from "react/jsx-runtime";
3
- import { useContext as y, forwardRef as k, useState as S, useId as w, createContext as C } from "react";
4
- import { Link as A, Button as I } from "react-aria-components";
5
- import { ChevronRight as T, ChevronDown as W } from "lucide-react";
6
- import { withBase as j, cx as h } from "../../utils/cx.js";
7
- import { navIcon as B } from "../icon/icon-contexts.js";
8
- import { DropdownMenu as D } from "../menu/Menu.js";
9
- import { TooltipTrigger as P, Tooltip as R } from "../overlay/Overlay.js";
10
- import { useStrings as $ } from "../../i18n/strings.js";
11
- const f = C({ collapsed: !1, size: "md" });
12
- function J({ header: c, children: e, footer: s, className: n, collapsed: i = !1, size: r = "md", "aria-label": o }) {
13
- const t = $();
14
- return /* @__PURE__ */ a(f.Provider, { value: { collapsed: i, size: r }, children: /* @__PURE__ */ l("div", { className: h("alea-appnav", n), "data-collapsed": i || void 0, "data-size": r === "touch" ? "touch" : void 0, children: [
3
+ import { useContext as y, forwardRef as k, useState as x, useId as w } from "react";
4
+ import { Link as A, Button as C } from "react-aria-components";
5
+ import { ChevronRight as I, ChevronDown as T } from "lucide-react";
6
+ import { withBase as W, cx as h } from "../../utils/cx.js";
7
+ import { navIcon as j } from "../icon/icon-contexts.js";
8
+ import { DropdownMenu as B } from "../menu/Menu.js";
9
+ import { TooltipTrigger as D, Tooltip as P } from "../overlay/Overlay.js";
10
+ import { useStrings as R } from "../../i18n/strings.js";
11
+ import { SidebarCtx as f } from "./sidebar-context.js";
12
+ function J({ header: c, children: e, footer: r, className: n, collapsed: i = !1, size: s = "md", "aria-label": o }) {
13
+ const t = R();
14
+ return /* @__PURE__ */ a(f.Provider, { value: { collapsed: i, size: s }, children: /* @__PURE__ */ l("div", { className: h("alea-appnav", n), "data-collapsed": i || void 0, "data-size": s === "touch" ? "touch" : void 0, children: [
15
15
  c && /* @__PURE__ */ a("div", { className: "alea-appnav-header", children: c }),
16
16
  /* @__PURE__ */ a("nav", { "aria-label": o ?? t.mainNav, className: "alea-appnav-body", children: e }),
17
- s && /* @__PURE__ */ a("div", { className: "alea-appnav-footer", children: s })
17
+ r && /* @__PURE__ */ a("div", { className: "alea-appnav-footer", children: r })
18
18
  ] }) });
19
19
  }
20
- const K = k(function({ name: e, logo: s, children: n, actions: i, onAction: r, "aria-label": o, className: t, ...p }, v) {
20
+ const K = k(function({ name: e, logo: r, children: n, actions: i, onAction: s, "aria-label": o, className: t, ...p }, v) {
21
21
  const d = /* @__PURE__ */ l(g, { children: [
22
- s && /* @__PURE__ */ a("span", { className: "alea-ws-logo", "aria-hidden": "true", children: s }),
22
+ r && /* @__PURE__ */ a("span", { className: "alea-ws-logo", "aria-hidden": "true", children: r }),
23
23
  /* @__PURE__ */ a("span", { className: "alea-ws-name", children: e }),
24
- n && /* @__PURE__ */ a(W, { className: "alea-ws-chevron", "aria-hidden": "true" })
24
+ n && /* @__PURE__ */ a(T, { className: "alea-ws-chevron", "aria-hidden": "true" })
25
25
  ] });
26
26
  return /* @__PURE__ */ l("div", { ref: v, ...p, className: h("alea-ws", t), children: [
27
27
  n ? /* @__PURE__ */ a(
28
- D,
28
+ B,
29
29
  {
30
30
  "aria-label": o ?? (typeof e == "string" ? `${e}, workspace menu` : "Workspace menu"),
31
31
  placement: "bottom start",
32
- menuProps: r ? { onAction: (u) => r(u) } : void 0,
33
- trigger: /* @__PURE__ */ a(I, { className: "alea-ws-button alea-focus-ring", "aria-label": o ?? (typeof e == "string" ? `${e}, workspace menu` : void 0), children: d }),
32
+ menuProps: s ? { onAction: (u) => s(u) } : void 0,
33
+ trigger: /* @__PURE__ */ a(C, { className: "alea-ws-button alea-focus-ring", "aria-label": o ?? (typeof e == "string" ? `${e}, workspace menu` : void 0), children: d }),
34
34
  children: n
35
35
  }
36
36
  ) : /* @__PURE__ */ a("span", { className: "alea-ws-button", "data-static": !0, children: d }),
37
37
  i && /* @__PURE__ */ a("span", { className: "alea-ws-actions", children: i })
38
38
  ] });
39
- }), Q = k(function({ title: e, children: s, collapsible: n = !!e, defaultExpanded: i = !0, action: r, appearance: o = "default", className: t, ...p }, v) {
40
- const [d, u] = S(i), N = w(), b = w(), { collapsed: m } = y(f);
39
+ }), Q = k(function({ title: e, children: r, collapsible: n = !!e, defaultExpanded: i = !0, action: s, appearance: o = "default", className: t, ...p }, v) {
40
+ const [d, u] = x(i), N = w(), b = w(), { collapsed: m } = y(f);
41
41
  return /* @__PURE__ */ l("div", { ref: v, ...p, className: h("alea-navsec", t), "data-open": d || void 0, "data-appearance": o === "eyebrow" ? "eyebrow" : void 0, "data-titled": e ? !0 : void 0, children: [
42
42
  e && !m && /* @__PURE__ */ l("div", { className: "alea-navsec-head", children: [
43
- n ? /* @__PURE__ */ l("button", { type: "button", className: "alea-navsec-title alea-focus-ring", "aria-expanded": d, "aria-controls": N, onClick: () => u((x) => !x), children: [
43
+ n ? /* @__PURE__ */ l("button", { type: "button", className: "alea-navsec-title alea-focus-ring", "aria-expanded": d, "aria-controls": N, onClick: () => u((S) => !S), children: [
44
44
  e,
45
- /* @__PURE__ */ a(T, { className: "alea-navsec-chevron", "aria-hidden": "true" })
45
+ /* @__PURE__ */ a(I, { className: "alea-navsec-chevron", "aria-hidden": "true" })
46
46
  ] }) : /* @__PURE__ */ a("span", { id: b, className: "alea-navsec-title", children: e }),
47
- r && /* @__PURE__ */ a("span", { className: "alea-navsec-action", children: r })
47
+ s && /* @__PURE__ */ a("span", { className: "alea-navsec-action", children: s })
48
48
  ] }),
49
- /* @__PURE__ */ a("ul", { id: N, className: "alea-navsec-list", hidden: n && !d && !m, "aria-labelledby": e && !n && !m ? b : void 0, "aria-label": e && m && typeof e == "string" ? e : void 0, children: s })
49
+ /* @__PURE__ */ a("ul", { id: N, className: "alea-navsec-list", hidden: n && !d && !m, "aria-labelledby": e && !n && !m ? b : void 0, "aria-label": e && m && typeof e == "string" ? e : void 0, children: r })
50
50
  ] });
51
51
  });
52
- function U({ isCurrent: c, icon: e, end: s, children: n, className: i, ...r }) {
53
- const { collapsed: o } = y(f), t = /* @__PURE__ */ a(A, { ...r, "aria-current": c ? "page" : void 0, className: j("alea-navitem alea-focus-ring", i), children: (p) => /* @__PURE__ */ l(g, { children: [
54
- e && /* @__PURE__ */ a("span", { className: "alea-navitem-icon", "aria-hidden": "true", ...B(c), children: e }),
52
+ function U({ isCurrent: c, icon: e, end: r, children: n, className: i, ...s }) {
53
+ const { collapsed: o } = y(f), t = /* @__PURE__ */ a(A, { ...s, "aria-current": c ? "page" : void 0, className: W("alea-navitem alea-focus-ring", i), children: (p) => /* @__PURE__ */ l(g, { children: [
54
+ e && /* @__PURE__ */ a("span", { className: "alea-navitem-icon", "aria-hidden": "true", ...j(c), children: e }),
55
55
  /* @__PURE__ */ a("span", { className: "alea-navitem-label", children: typeof n == "function" ? n(p) : n }),
56
- s != null && /* @__PURE__ */ a("span", { className: "alea-navitem-end", children: s })
56
+ r != null && /* @__PURE__ */ a("span", { className: "alea-navitem-end", children: r })
57
57
  ] }) });
58
- return o && e && typeof n != "function" ? /* @__PURE__ */ a("li", { children: /* @__PURE__ */ l(P, { children: [
58
+ return o && e && typeof n != "function" ? /* @__PURE__ */ a("li", { children: /* @__PURE__ */ l(D, { children: [
59
59
  t,
60
- /* @__PURE__ */ a(R, { placement: "end", children: n })
60
+ /* @__PURE__ */ a(P, { placement: "end", children: n })
61
61
  ] }) }) : /* @__PURE__ */ a("li", { children: t });
62
62
  }
63
63
  export {
@@ -0,0 +1,5 @@
1
+ export interface SidebarContext {
2
+ collapsed: boolean;
3
+ size: 'md' | 'touch';
4
+ }
5
+ export declare const SidebarCtx: import("react").Context<SidebarContext>;
@@ -0,0 +1,6 @@
1
+ "use client";
2
+ import { createContext as e } from "react";
3
+ const o = e({ collapsed: !1, size: "md" });
4
+ export {
5
+ o as SidebarCtx
6
+ };