@alea-design/ui 0.1.1 → 0.3.0

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 (184) hide show
  1. package/README.md +7 -1
  2. package/dist/components/accordion/Accordion.js +29 -0
  3. package/dist/components/ai/AI.d.ts +5 -1
  4. package/dist/components/ai/AI.js +187 -0
  5. package/dist/components/app/AppParts.d.ts +16 -4
  6. package/dist/components/app/AppParts.js +134 -0
  7. package/dist/components/button/Button.d.ts +1 -1
  8. package/dist/components/button/Button.js +137 -0
  9. package/dist/components/button/Groups.d.ts +1 -1
  10. package/dist/components/button/Groups.js +112 -0
  11. package/dist/components/card/Card.d.ts +3 -2
  12. package/dist/components/card/Card.js +47 -0
  13. package/dist/components/chat/Chat.d.ts +4 -2
  14. package/dist/components/chat/Chat.js +275 -0
  15. package/dist/components/choice/Choice.js +69 -0
  16. package/dist/components/color/Color.d.ts +3 -3
  17. package/dist/components/color/Color.js +98 -0
  18. package/dist/components/combobox/Autocomplete.d.ts +5 -5
  19. package/dist/components/combobox/Autocomplete.js +126 -0
  20. package/dist/components/combobox/ComboBox.d.ts +4 -4
  21. package/dist/components/combobox/ComboBox.js +112 -0
  22. package/dist/components/combobox/Highlight.js +50 -0
  23. package/dist/components/command/CommandPalette.d.ts +10 -3
  24. package/dist/components/command/CommandPalette.js +56 -0
  25. package/dist/components/content/Content.d.ts +1 -1
  26. package/dist/components/content/Content.js +125 -0
  27. package/dist/components/data/Data.js +79 -0
  28. package/dist/components/date/Date.js +109 -0
  29. package/dist/components/display/Display.d.ts +5 -3
  30. package/dist/components/display/Display.js +89 -0
  31. package/dist/components/display/Display2.d.ts +3 -1
  32. package/dist/components/display/Display2.js +75 -0
  33. package/dist/components/emoji/EmojiPicker.js +52 -0
  34. package/dist/components/emoji/emoji-data.js +27 -0
  35. package/dist/components/extras/CodeSteps.d.ts +3 -0
  36. package/dist/components/extras/CodeSteps.js +19 -0
  37. package/dist/components/extras/Extras.d.ts +1 -1
  38. package/dist/components/extras/Extras.js +116 -0
  39. package/dist/components/feedback/Feedback.d.ts +11 -8
  40. package/dist/components/feedback/Feedback.js +185 -0
  41. package/dist/components/feedback/Spinner.js +18 -0
  42. package/dist/components/feedback/Status.d.ts +6 -2
  43. package/dist/components/feedback/Status.js +48 -0
  44. package/dist/components/field/Field.d.ts +1 -1
  45. package/dist/components/field/Field.js +187 -0
  46. package/dist/components/field/FieldLoading.d.ts +1 -1
  47. package/dist/components/field/FieldLoading.js +18 -0
  48. package/dist/components/filter/FilterBar.js +96 -0
  49. package/dist/components/form/Form.d.ts +5 -5
  50. package/dist/components/form/Form.js +53 -0
  51. package/dist/components/icon/Icon.d.ts +2 -2
  52. package/dist/components/icon/Icon.js +66 -0
  53. package/dist/components/icon/icon-cells.js +39 -0
  54. package/dist/components/icon/icon-contexts.d.ts +1 -1
  55. package/dist/components/icon/icon-contexts.js +38 -0
  56. package/dist/components/icon/icon-names.d.ts +1 -1
  57. package/dist/components/icon/icon-names.js +376 -0
  58. package/dist/components/layout/Bento.d.ts +1 -1
  59. package/dist/components/layout/Bento.js +38 -0
  60. package/dist/components/layout/Layout.d.ts +1 -1
  61. package/dist/components/layout/Layout.js +54 -0
  62. package/dist/components/layout/Layout2.d.ts +36 -6
  63. package/dist/components/layout/Layout2.js +105 -0
  64. package/dist/components/layout/Layout3.js +35 -0
  65. package/dist/components/layout/Responsive.d.ts +1 -1
  66. package/dist/components/layout/Responsive.js +32 -0
  67. package/dist/components/list/List.d.ts +3 -2
  68. package/dist/components/list/List.js +82 -0
  69. package/dist/components/list/Lists2.d.ts +6 -4
  70. package/dist/components/list/Lists2.js +60 -0
  71. package/dist/components/media/Media.d.ts +8 -4
  72. package/dist/components/media/Media.js +188 -0
  73. package/dist/components/menu/Menu.d.ts +23 -12
  74. package/dist/components/menu/Menu.js +68 -0
  75. package/dist/components/more/More.d.ts +7 -7
  76. package/dist/components/more/More.js +182 -0
  77. package/dist/components/navigation/Navbar.d.ts +1 -1
  78. package/dist/components/navigation/Navbar.js +27 -0
  79. package/dist/components/navigation/Navigation.js +121 -0
  80. package/dist/components/navigation/Navigation2.d.ts +6 -2
  81. package/dist/components/navigation/Navigation2.js +355 -0
  82. package/dist/components/overlay/Drawer.d.ts +11 -6
  83. package/dist/components/overlay/Drawer.js +39 -0
  84. package/dist/components/overlay/Modal.d.ts +6 -3
  85. package/dist/components/overlay/Modal.js +27 -0
  86. package/dist/components/overlay/Overlay.d.ts +14 -9
  87. package/dist/components/overlay/Overlay.js +76 -0
  88. package/dist/components/overlay/Sheet.d.ts +11 -5
  89. package/dist/components/overlay/Sheet.js +52 -0
  90. package/dist/components/page/Page.d.ts +5 -5
  91. package/dist/components/page/Page.js +132 -0
  92. package/dist/components/page/PageParts.d.ts +5 -5
  93. package/dist/components/page/PageParts.js +109 -0
  94. package/dist/components/picker/Picker.d.ts +11 -11
  95. package/dist/components/picker/Picker.js +294 -0
  96. package/dist/components/picker/Wheel.js +132 -0
  97. package/dist/components/rating/Rating.d.ts +2 -1
  98. package/dist/components/rating/Rating.js +66 -0
  99. package/dist/components/select/Select.d.ts +8 -6
  100. package/dist/components/select/Select.js +146 -0
  101. package/dist/components/shell/AppShell.d.ts +3 -3
  102. package/dist/components/shell/AppShell.js +56 -0
  103. package/dist/components/shell/AppSidebar.d.ts +5 -5
  104. package/dist/components/shell/AppSidebar.js +62 -0
  105. package/dist/components/slider/Slider.d.ts +2 -1
  106. package/dist/components/slider/Slider.js +36 -0
  107. package/dist/components/surface/Surface.d.ts +16 -0
  108. package/dist/components/surface/Surface.js +7 -0
  109. package/dist/components/table/Table.d.ts +4 -3
  110. package/dist/components/table/Table.js +58 -0
  111. package/dist/components/tabs/Tabs.d.ts +1 -0
  112. package/dist/components/tabs/Tabs.js +120 -0
  113. package/dist/components/theme/Theme.d.ts +11 -6
  114. package/dist/components/theme/Theme.js +186 -0
  115. package/dist/components/theme/lens.js +104 -0
  116. package/dist/components/tree/Tree.js +303 -0
  117. package/dist/components/typography/Typography.js +43 -0
  118. package/dist/components/upload/Upload.js +71 -0
  119. package/dist/components/work/Ops.js +24 -0
  120. package/dist/components/work/Work.d.ts +4 -2
  121. package/dist/components/work/Work.js +241 -0
  122. package/dist/css/accordion.css +1 -0
  123. package/dist/css/ai.css +1 -0
  124. package/dist/css/app.css +1 -0
  125. package/dist/css/base.css +1 -0
  126. package/dist/css/button.css +1 -0
  127. package/dist/css/card.css +1 -0
  128. package/dist/css/chat.css +1 -0
  129. package/dist/css/choice.css +1 -0
  130. package/dist/css/color.css +1 -0
  131. package/dist/css/combobox.css +1 -0
  132. package/dist/css/command.css +1 -0
  133. package/dist/css/content.css +1 -0
  134. package/dist/css/data.css +1 -0
  135. package/dist/css/date.css +1 -0
  136. package/dist/css/display.css +1 -0
  137. package/dist/css/emoji.css +1 -0
  138. package/dist/css/extras.css +1 -0
  139. package/dist/css/feedback.css +1 -0
  140. package/dist/css/field.css +1 -0
  141. package/dist/css/filter.css +1 -0
  142. package/dist/css/form.css +1 -0
  143. package/dist/css/groups.json +346 -0
  144. package/dist/css/icon.css +1 -0
  145. package/dist/css/layout.css +1 -0
  146. package/dist/css/list.css +1 -0
  147. package/dist/css/media.css +1 -0
  148. package/dist/css/menu.css +1 -0
  149. package/dist/css/more.css +1 -0
  150. package/dist/css/navigation.css +1 -0
  151. package/dist/css/overlay.css +1 -0
  152. package/dist/css/page.css +1 -0
  153. package/dist/css/picker.css +1 -0
  154. package/dist/css/rating.css +1 -0
  155. package/dist/css/select.css +1 -0
  156. package/dist/css/shell.css +1 -0
  157. package/dist/css/slider.css +1 -0
  158. package/dist/css/surface.css +1 -0
  159. package/dist/css/table.css +1 -0
  160. package/dist/css/tabs.css +1 -0
  161. package/dist/css/tree.css +1 -0
  162. package/dist/css/typography.css +1 -0
  163. package/dist/css/upload.css +1 -0
  164. package/dist/css/work.css +1 -0
  165. package/dist/i18n/strings.js +842 -0
  166. package/dist/index.d.ts +71 -70
  167. package/dist/index.js +398 -7436
  168. package/dist/styles.css +1 -1
  169. package/dist/utils/Blueprint.js +131 -0
  170. package/dist/utils/DotField.js +32 -0
  171. package/dist/utils/attr.d.ts +1 -1
  172. package/dist/utils/attr.js +18 -0
  173. package/dist/utils/blueprintScene.js +161 -0
  174. package/dist/utils/controlled.js +11 -0
  175. package/dist/utils/cx.js +11 -0
  176. package/dist/utils/inert.js +9 -0
  177. package/dist/utils/refs.d.ts +3 -0
  178. package/dist/utils/refs.js +11 -0
  179. package/dist/utils/responsive.js +12 -0
  180. package/dist/utils/scrollEdges.js +31 -0
  181. package/dist/utils/space.js +10 -0
  182. package/dist/utils/vocabulary.d.ts +6 -0
  183. package/dist/utils/vocabulary.js +17 -0
  184. package/package.json +12 -8
@@ -0,0 +1,112 @@
1
+ "use client";
2
+ import { jsx as r, jsxs as S } from "react/jsx-runtime";
3
+ import { useState as P, useRef as F, useLayoutEffect as I, useEffect as K, Fragment as O } from "react";
4
+ import { Group as R, ToggleButtonGroup as j, Toolbar as z, ToggleButton as k, SelectionIndicator as q } from "react-aria-components";
5
+ import { ChevronDown as W, MoreHorizontal as H } from "lucide-react";
6
+ import { cx as N, withBase as x } from "../../utils/cx.js";
7
+ import { Button as w, IconButton as D } from "./Button.js";
8
+ import { DropdownMenu as A, MenuItem as G } from "../menu/Menu.js";
9
+ import { useStrings as M } from "../../i18n/strings.js";
10
+ import { inertProps as $ } from "../../utils/inert.js";
11
+ const J = typeof document < "u" ? I : K;
12
+ function L({ children: i, attached: l = !0, orientation: n = "horizontal", className: s, "aria-label": t }) {
13
+ return /* @__PURE__ */ r(R, { "aria-label": t, className: N("alea-btn-group", s), "data-attached": l || void 0, "data-orientation": n, children: i });
14
+ }
15
+ function ae({ children: i, actions: l, onAction: n, menuLabel: s, variant: t = "primary", size: d = "md", className: u, ...m }) {
16
+ const f = M();
17
+ return s ?? (s = f.moreOptions), /* @__PURE__ */ S(L, { className: N("alea-split-btn", u), children: [
18
+ /* @__PURE__ */ r(w, { variant: t, size: d, ...m, children: i }),
19
+ /* @__PURE__ */ r(A, { trigger: /* @__PURE__ */ r(D, { variant: t, size: d, shape: "square", "aria-label": s, isDisabled: m.isDisabled, children: /* @__PURE__ */ r(W, {}) }), placement: "bottom end", menuProps: { onAction: (c) => n == null ? void 0 : n(c) }, "aria-label": s, children: l.map((c) => /* @__PURE__ */ r(G, { id: c.id, icon: c.icon, description: c.description, children: c.label }, String(c.id))) })
20
+ ] });
21
+ }
22
+ function re({ items: i, selectionMode: l = "single", value: n, defaultValue: s, onChange: t, iconOnly: d, size: u = "md", className: m, "aria-label": f }) {
23
+ const [c, v] = P(s ?? []), p = n ?? c, e = (a, o) => /* @__PURE__ */ S(k, { id: a.id, isDisabled: a.isDisabled, "aria-label": d ? a.label : void 0, className: "alea-toggle-item alea-focus-ring", "data-icon-only": d || void 0, ...o, children: [
24
+ a.icon && /* @__PURE__ */ r("span", { className: "alea-toggle-icon", "aria-hidden": "true", children: a.icon }),
25
+ !d && /* @__PURE__ */ r("span", { className: "alea-toggle-label", children: a.label }),
26
+ !o && /* @__PURE__ */ r(q, { className: "alea-sel-indicator" })
27
+ ] }, String(a.id));
28
+ if (l === "multiple") {
29
+ const a = (o, b) => {
30
+ const g = b ? [...p, o] : p.filter((B) => B !== o);
31
+ n === void 0 && v(g), t == null || t(g);
32
+ };
33
+ return /* @__PURE__ */ r("div", { role: "group", "aria-label": f, className: N("alea-toggle-group", m), "data-size": u, "data-multiple": !0, children: i.map((o) => e(o, { isSelected: p.includes(o.id), onChange: (b) => a(o.id, b) })) });
34
+ }
35
+ return /* @__PURE__ */ r(
36
+ j,
37
+ {
38
+ "aria-label": f,
39
+ selectionMode: "single",
40
+ selectedKeys: n,
41
+ defaultSelectedKeys: s,
42
+ onSelectionChange: (a) => t == null ? void 0 : t(a === "all" ? i.map((o) => o.id) : [...a]),
43
+ className: x("alea-toggle-group", m),
44
+ "data-size": u,
45
+ children: i.map((a) => e(a))
46
+ }
47
+ );
48
+ }
49
+ function oe({ className: i, items: l, itemStyle: n = "icon", children: s, ...t }) {
50
+ const d = M(), u = F(null), [m, f] = P((l == null ? void 0 : l.length) ?? 0);
51
+ if (J(() => {
52
+ const e = u.current;
53
+ if (!l || !e) return;
54
+ const a = () => {
55
+ const b = e.querySelector(".alea-toolbar-probe");
56
+ if (!b) return;
57
+ const g = Array.from(b.children).map((h) => h.getBoundingClientRect().width + 4);
58
+ if (g.reduce((h, E) => h + E, 0) <= e.clientWidth) {
59
+ f(g.length);
60
+ return;
61
+ }
62
+ let y = 0, T = 0;
63
+ for (const h of g) {
64
+ if (y + h > e.clientWidth - 44) break;
65
+ y += h, T++;
66
+ }
67
+ f(T);
68
+ };
69
+ a();
70
+ const o = new ResizeObserver(a);
71
+ return o.observe(e), () => o.disconnect();
72
+ }, [l]), !l) return /* @__PURE__ */ r(z, { ...t, className: x("alea-toolbar", i), children: s });
73
+ const c = (e, a = !1) => {
74
+ const o = n === "label" ? /* @__PURE__ */ r(w, { size: "sm", variant: e.isSelected ? "soft" : "text", iconStart: e.icon, isDisabled: e.isDisabled, onPress: e.onAction, "aria-pressed": e.isSelected, excludeFromTabOrder: a, children: e.label }, String(e.id)) : /* @__PURE__ */ r(D, { size: "sm", variant: e.isSelected ? "soft" : "text", "aria-label": e.label, tooltip: !a, isDisabled: e.isDisabled, onPress: e.onAction, "aria-pressed": e.isSelected, excludeFromTabOrder: a, children: e.icon }, String(e.id));
75
+ return e.separatorBefore ? /* @__PURE__ */ S(O, { children: [
76
+ /* @__PURE__ */ r("span", { className: "alea-toolbar-sep", "aria-hidden": "true" }),
77
+ o
78
+ ] }, String(e.id)) : o;
79
+ }, v = l.slice(0, m), p = l.slice(m);
80
+ return /* @__PURE__ */ S("div", { ref: u, className: "alea-toolbar-fit", children: [
81
+ /* @__PURE__ */ r("div", { className: "alea-toolbar-probe", "aria-hidden": "true", ...$(!0), children: l.map((e) => c(e, !0)) }),
82
+ /* @__PURE__ */ S(z, { ...t, className: x("alea-toolbar", i), children: [
83
+ v.map((e) => c(e)),
84
+ p.length > 0 && /* @__PURE__ */ r(
85
+ A,
86
+ {
87
+ "aria-label": d.moreActions,
88
+ placement: "bottom end",
89
+ trigger: /* @__PURE__ */ r(D, { size: "sm", variant: "text", "aria-label": d.moreActions, children: /* @__PURE__ */ r(H, {}) }),
90
+ menuProps: { onAction: (e) => {
91
+ var a, o;
92
+ return (o = (a = p.find((b) => b.id === e)) == null ? void 0 : a.onAction) == null ? void 0 : o.call(a);
93
+ }, disabledKeys: p.filter((e) => e.isDisabled).map((e) => e.id) },
94
+ children: p.map((e) => /* @__PURE__ */ r(G, { id: e.id, icon: e.icon, children: e.label }, String(e.id)))
95
+ }
96
+ )
97
+ ] })
98
+ ] });
99
+ }
100
+ function le({ children: i, description: l, icon: n, className: s, size: t = "lg", variant: d = "ghost", ...u }) {
101
+ return /* @__PURE__ */ r(w, { ...u, size: t, variant: d, className: N("alea-compound-button", s), iconStart: n, children: /* @__PURE__ */ S("span", { className: "alea-compound-text", children: [
102
+ /* @__PURE__ */ r("span", { className: "alea-compound-title", children: i }),
103
+ l && /* @__PURE__ */ r("span", { className: "alea-compound-desc", children: l })
104
+ ] }) });
105
+ }
106
+ export {
107
+ L as ButtonGroup,
108
+ le as CompoundButton,
109
+ ae as SplitButton,
110
+ re as ToggleGroup,
111
+ oe as Toolbar
112
+ };
@@ -1,5 +1,6 @@
1
1
  import { type ElementType, type HTMLAttributes, type ReactNode } from 'react';
2
- export interface CardProps extends HTMLAttributes<HTMLElement> {
2
+ import { type SurfaceProps } from '../surface/Surface.js';
3
+ export interface CardProps extends HTMLAttributes<HTMLElement>, SurfaceProps {
3
4
  /** default: the surface with the soft ring; deep: a darker inset panel; outline: border only; glass: frosted glass over what is behind it. */
4
5
  variant?: 'default' | 'deep' | 'outline' | 'glass';
5
6
  /** tight uses less padding and a smaller radius. */
@@ -15,7 +16,7 @@ export interface CardProps extends HTMLAttributes<HTMLElement> {
15
16
  children?: ReactNode;
16
17
  }
17
18
  /** The Alea panel: rounded surface with the soft inner ring. Header, media and footer parts, side by side or stacked, and a loading state. */
18
- export declare function Card({ variant, padding, interactive, as, orientation, isLoading, className, children, ...props }: CardProps): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
19
+ export declare function Card({ variant, padding, interactive, as, orientation, isLoading, surface, radius, className, children, ...props }: CardProps): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
19
20
  export interface CardTitleProps extends HTMLAttributes<HTMLHeadingElement> {
20
21
  /** The heading element. Default h3; match the page outline. */
21
22
  as?: ElementType;
@@ -0,0 +1,47 @@
1
+ "use client";
2
+ import { jsx as r, jsxs as c } from "react/jsx-runtime";
3
+ import { createElement as n } from "react";
4
+ import { cx as d } from "../../utils/cx.js";
5
+ import { surfaceAttrs as f } from "../surface/Surface.js";
6
+ function g({ variant: e = "default", padding: a = "normal", interactive: t, as: i = "div", orientation: l, isLoading: s, surface: o, radius: m, className: h, children: u, ...p }) {
7
+ const N = s ? /* @__PURE__ */ c("div", { className: "alea-card-loading", "aria-hidden": "true", children: [
8
+ /* @__PURE__ */ r("span", { className: "alea-skeleton", "data-shape": "rect", style: { height: 120 } }),
9
+ /* @__PURE__ */ r("span", { className: "alea-skeleton", "data-shape": "text", style: { width: "70%" } }),
10
+ /* @__PURE__ */ r("span", { className: "alea-skeleton", "data-shape": "text", style: { width: "45%" } })
11
+ ] }) : u;
12
+ return n(i, { ...p, "aria-busy": s || void 0, className: d("alea-card", h), "data-variant": e, "data-padding": a, "data-interactive": t || void 0, "data-orientation": l, ...f({ surface: o, radius: m }) }, N);
13
+ }
14
+ function k({ as: e = "h3", className: a, ...t }) {
15
+ return n(e, { ...t, className: d("alea-card-title", a) });
16
+ }
17
+ function j({ className: e, ...a }) {
18
+ return /* @__PURE__ */ r("p", { ...a, className: d("alea-card-description", e) });
19
+ }
20
+ function w({ className: e, ...a }) {
21
+ return /* @__PURE__ */ r("a", { ...a, className: d("alea-card-link alea-focus-ring", e) });
22
+ }
23
+ function b({ title: e, subtitle: a, media: t, actions: i, headingLevel: l = 3, className: s }) {
24
+ return /* @__PURE__ */ c("div", { className: d("alea-card-header", s), children: [
25
+ t && /* @__PURE__ */ r("span", { className: "alea-card-header-media", children: t }),
26
+ /* @__PURE__ */ c("div", { className: "alea-card-header-text", children: [
27
+ n(`h${l}`, { className: "alea-card-title" }, e),
28
+ a && /* @__PURE__ */ r("p", { className: "alea-card-description", children: a })
29
+ ] }),
30
+ i && /* @__PURE__ */ r("div", { className: "alea-card-header-actions", children: i })
31
+ ] });
32
+ }
33
+ function z({ src: e, alt: a = "", ratio: t = 16 / 9, children: i, className: l }) {
34
+ return /* @__PURE__ */ r("div", { className: d("alea-card-media", l), style: { aspectRatio: String(t) }, children: i ?? /* @__PURE__ */ r("img", { src: e, alt: a, loading: "lazy" }) });
35
+ }
36
+ function A({ children: e, className: a, divider: t = !0 }) {
37
+ return /* @__PURE__ */ r("div", { className: d("alea-card-footer", a), "data-divider": t || void 0, children: e });
38
+ }
39
+ export {
40
+ g as Card,
41
+ j as CardDescription,
42
+ A as CardFooter,
43
+ b as CardHeader,
44
+ w as CardLink,
45
+ z as CardMedia,
46
+ k as CardTitle
47
+ };
@@ -165,7 +165,9 @@ export interface ThreadViewProps {
165
165
  /** The replies, oldest first. */
166
166
  replies: ChatItem[];
167
167
  /** Called when the thread is closed: the close button or Escape. */
168
- onClose: () => void;
168
+ onDismiss?: () => void;
169
+ /** @deprecated Use onDismiss. */
170
+ onClose?: () => void;
169
171
  /** Called when a reaction is toggled on the parent or a reply. */
170
172
  onReact?: (messageId: string, emoji: string) => void;
171
173
  /** Emoji offered as one-press reactions on hover and focus, with onReact. */
@@ -188,4 +190,4 @@ export interface ThreadViewProps {
188
190
  className?: string;
189
191
  }
190
192
  /** A thread on its own: the parent message, the replies in a log, a reply box, and a close button. When it opens focus moves to its title and Escape closes it, returning focus to the message link that opened it. */
191
- export declare function ThreadView({ parent, replies, onClose, onReact, quickReactions, renderActions, typing, children, variant, height, headingLevel, autoFocus, className }: ThreadViewProps): import("react").JSX.Element;
193
+ export declare function ThreadView({ parent, replies, onClose: oldOnClose, onDismiss, onReact, quickReactions, renderActions, typing, children, variant, height, headingLevel, autoFocus, className }: ThreadViewProps): import("react").JSX.Element;
@@ -0,0 +1,275 @@
1
+ "use client";
2
+ import { jsxs as n, jsx as a, Fragment as K } from "react/jsx-runtime";
3
+ import { useRef as M, useState as W, useEffect as L, Fragment as J, useId as Q } from "react";
4
+ import { useLocale as $, DialogTrigger as U, Button as V } from "react-aria-components";
5
+ import { AlertCircle as Y, CheckCheck as O, Check as Z, Clock as G, MessageSquare as X, SmilePlus as R, ChevronRight as q, X as ee } from "lucide-react";
6
+ import { renamed as ae } from "../../utils/vocabulary.js";
7
+ import { cx as E } from "../../utils/cx.js";
8
+ import { Avatar as te, AvatarGroup as le } from "../display/Display.js";
9
+ import { IconButton as re } from "../button/Button.js";
10
+ import { Popover as ne, PopoverDialog as ie } from "../overlay/Overlay.js";
11
+ import { EmojiPicker as se } from "../emoji/EmojiPicker.js";
12
+ import { useStrings as z } from "../../i18n/strings.js";
13
+ function oe({ names: l, className: i }) {
14
+ const c = z();
15
+ return /* @__PURE__ */ a("div", { className: E("alea-typing", i), role: "status", "aria-live": "polite", children: l.length > 0 && /* @__PURE__ */ n(K, { children: [
16
+ /* @__PURE__ */ n("span", { className: "alea-typing-dots", "aria-hidden": "true", children: [
17
+ /* @__PURE__ */ a("span", {}),
18
+ /* @__PURE__ */ a("span", {}),
19
+ /* @__PURE__ */ a("span", {})
20
+ ] }),
21
+ /* @__PURE__ */ a("span", { className: "alea-typing-text", children: c.typing(l) })
22
+ ] }) });
23
+ }
24
+ function B({ reactions: l, onToggle: i, allowAdd: c = !0, quick: r, size: g = "md", className: h }) {
25
+ const s = z(), { direction: y } = $(), o = M(/* @__PURE__ */ new Map()), m = new Set(l.filter((e) => o.current.has(e.emoji) && o.current.get(e.emoji) !== e.count).map((e) => e.emoji));
26
+ L(() => {
27
+ o.current = new Map(l.map((e) => [e.emoji, e.count]));
28
+ });
29
+ const v = (e) => {
30
+ const f = y === "rtl" ? "ArrowLeft" : "ArrowRight";
31
+ if (![f, y === "rtl" ? "ArrowRight" : "ArrowLeft", "Home", "End"].includes(e.key)) return;
32
+ const d = [...e.currentTarget.querySelectorAll("button:not(:disabled)")], p = d.indexOf(document.activeElement);
33
+ p < 0 || (e.preventDefault(), d[e.key === "Home" ? 0 : e.key === "End" ? d.length - 1 : (p + (e.key === f ? 1 : -1) + d.length) % d.length].focus());
34
+ }, C = new Set(l.filter((e) => e.count > 0).map((e) => e.emoji));
35
+ return /* @__PURE__ */ n("div", { className: E("alea-reactions", h), "data-size": g, role: "group", "aria-label": s.reactions, onKeyDown: v, children: [
36
+ l.filter((e) => e.count > 0).map((e) => /* @__PURE__ */ n("button", { type: "button", className: "alea-reaction alea-focus-ring", "aria-pressed": !!e.mine, "aria-label": s.reactionCount(e.emoji, e.count, !!e.mine), onClick: () => i(e.emoji), children: [
37
+ /* @__PURE__ */ a("span", { "aria-hidden": "true", children: e.emoji }),
38
+ /* @__PURE__ */ a("span", { className: "alea-reaction-count", "data-pop": m.has(e.emoji) || void 0, "aria-hidden": "true", children: e.count })
39
+ ] }, e.emoji)),
40
+ r == null ? void 0 : r.filter((e) => !C.has(e)).map((e) => /* @__PURE__ */ a("button", { type: "button", className: "alea-reaction alea-reaction-quick alea-focus-ring", "aria-label": s.reactWith(e), onClick: () => i(e), children: /* @__PURE__ */ a("span", { "aria-hidden": "true", children: e }) }, e)),
41
+ c && /* @__PURE__ */ n(U, { children: [
42
+ /* @__PURE__ */ a(V, { className: "alea-reaction alea-reaction-add alea-focus-ring", "aria-label": s.addReaction, children: /* @__PURE__ */ a(R, { size: 16, "aria-hidden": "true" }) }),
43
+ /* @__PURE__ */ a(ne, { placement: "top start", className: "alea-popover alea-emoji-popover", children: /* @__PURE__ */ a(ie, { "aria-label": s.addReaction, children: ({ close: e }) => /* @__PURE__ */ a(se, { onSelect: (f) => {
44
+ i(f), e();
45
+ } }) }) })
46
+ ] })
47
+ ] });
48
+ }
49
+ function de(l, i) {
50
+ const c = new Intl.RelativeTimeFormat(i, { numeric: "auto" }), r = Math.round((Date.now() - l.getTime()) / 1e3);
51
+ return r < 45 ? c.format(0, "second") : r < 3600 ? c.format(-Math.round(r / 60), "minute") : r < 86400 ? c.format(-Math.round(r / 3600), "hour") : r < 86400 * 30 ? c.format(-Math.round(r / 86400), "day") : new Intl.DateTimeFormat(i, { day: "numeric", month: "short", year: "numeric" }).format(l);
52
+ }
53
+ function ce({ replyCount: l = 0, participants: i, lastReplyAt: c, lastReply: r, unread: g, onOpen: h, children: s, isExpanded: y, defaultExpanded: o, onExpandedChange: m, className: v }) {
54
+ const C = z(), { locale: e } = $(), f = Q(), [S, d] = W(!!o), p = s != null && s !== !1, w = p && (y ?? S), T = () => {
55
+ const I = !w;
56
+ y === void 0 && d(I), m == null || m(I);
57
+ };
58
+ return /* @__PURE__ */ n("div", { className: E("alea-thread", v), "data-expanded": w || void 0, "data-unread": g ? !0 : void 0, children: [
59
+ /* @__PURE__ */ n(
60
+ "button",
61
+ {
62
+ type: "button",
63
+ className: "alea-thread-head alea-focus-ring",
64
+ onClick: p ? T : h,
65
+ "aria-expanded": p ? w : void 0,
66
+ "aria-controls": p ? `${f}-replies` : void 0,
67
+ "aria-describedby": r && !w ? `${f}-last` : void 0,
68
+ children: [
69
+ i != null && i.length ? /* @__PURE__ */ a(le, { people: i, size: "xs", max: 3, "aria-hidden": "true" }) : /* @__PURE__ */ a(X, { size: 16, "aria-hidden": "true" }),
70
+ /* @__PURE__ */ a("span", { className: "alea-thread-count", children: C.replies(l) }),
71
+ g ? /* @__PURE__ */ a("span", { className: "alea-thread-unread", children: C.newReplies(g) }) : null,
72
+ c && /* @__PURE__ */ a("span", { className: "alea-thread-time", children: C.lastReply(de(c, e)) }),
73
+ /* @__PURE__ */ a(q, { size: 16, className: "alea-thread-chevron", "aria-hidden": "true" })
74
+ ]
75
+ }
76
+ ),
77
+ r && !w && /* @__PURE__ */ n("p", { className: "alea-thread-last", id: `${f}-last`, children: [
78
+ /* @__PURE__ */ a("strong", { children: r.author }),
79
+ " ",
80
+ r.text
81
+ ] }),
82
+ p && /* @__PURE__ */ a("div", { className: "alea-thread-body", "data-expanded": w || void 0, children: /* @__PURE__ */ n("div", { className: "alea-thread-body-inner", id: `${f}-replies`, role: "region", "aria-label": C.threadReplies, children: [
83
+ s,
84
+ h && /* @__PURE__ */ a("button", { type: "button", className: "alea-thread-open alea-focus-ring", onClick: h, children: C.openThread })
85
+ ] }) })
86
+ ] });
87
+ }
88
+ const he = { sending: G, sent: Z, delivered: O, read: O, failed: Y };
89
+ function H({ author: l, avatarSrc: i, children: c, time: r, isOwn: g, isGrouped: h, status: s, isEdited: y, reactions: o, onReact: m, quickReactions: v, replyCount: C, thread: e, threadVariant: f = "link", threadReplies: S, isThreadExpanded: d, onThreadExpandedChange: p, onOpenThread: w, actions: T, variant: I = "bubble", className: b }) {
90
+ const D = z(), { locale: t } = $(), N = s ? he[s] : null, u = r ? new Intl.DateTimeFormat(t, { hour: "numeric", minute: "2-digit" }).format(r) : null, j = (e == null ? void 0 : e.replyCount) ?? C;
91
+ return /* @__PURE__ */ n(
92
+ "article",
93
+ {
94
+ className: E("alea-msg", b),
95
+ "data-own": g || void 0,
96
+ "data-grouped": h || void 0,
97
+ "data-variant": I,
98
+ "data-status": s,
99
+ "aria-label": `${g ? D.you : l}${u ? `, ${u}` : ""}`,
100
+ children: [
101
+ /* @__PURE__ */ a("div", { className: "alea-msg-avatar", children: !h && /* @__PURE__ */ a(te, { name: l, src: i, size: "sm" }) }),
102
+ /* @__PURE__ */ n("div", { className: "alea-msg-main", children: [
103
+ !h && /* @__PURE__ */ n("header", { className: "alea-msg-head", children: [
104
+ /* @__PURE__ */ a("span", { className: "alea-msg-author", children: g ? D.you : l }),
105
+ r && /* @__PURE__ */ a("time", { className: "alea-msg-time", dateTime: r.toISOString(), title: r.toLocaleString(t), children: u })
106
+ ] }),
107
+ /* @__PURE__ */ n("div", { className: "alea-msg-body", children: [
108
+ /* @__PURE__ */ a("div", { className: "alea-msg-bubble", children: c }),
109
+ (T || m && ((v == null ? void 0 : v.length) || !(o != null && o.length))) && /* @__PURE__ */ n("div", { className: "alea-msg-actions", children: [
110
+ m && (v != null && v.length || !(o != null && o.length)) ? /* @__PURE__ */ a(B, { reactions: [], quick: v, onToggle: m, size: "sm" }) : null,
111
+ T
112
+ ] })
113
+ ] }),
114
+ (y || N || h && u) && /* @__PURE__ */ n("div", { className: "alea-msg-meta", children: [
115
+ h && u && /* @__PURE__ */ a("time", { dateTime: r.toISOString(), children: u }),
116
+ y && /* @__PURE__ */ a("span", { children: D.edited2 }),
117
+ N && s && /* @__PURE__ */ n("span", { className: "alea-msg-status", "data-status": s, children: [
118
+ /* @__PURE__ */ a(N, { size: 14, "aria-hidden": "true" }),
119
+ D.messageStatus[s]
120
+ ] })
121
+ ] }),
122
+ o != null && o.length ? /* @__PURE__ */ a(B, { reactions: o, onToggle: (P) => m == null ? void 0 : m(P), allowAdd: !!m, size: "sm" }) : null,
123
+ j ? f === "preview" ? /* @__PURE__ */ a(ce, { ...e, replyCount: j, onOpen: w, isExpanded: d, onExpandedChange: p, children: S }) : /* @__PURE__ */ n("button", { type: "button", className: "alea-msg-thread alea-focus-ring", onClick: w, children: [
124
+ /* @__PURE__ */ a(X, { size: 14, "aria-hidden": "true" }),
125
+ D.replies(j),
126
+ e != null && e.unread ? /* @__PURE__ */ a("span", { className: "alea-thread-unread", children: D.newReplies(e.unread) }) : null
127
+ ] }) : null
128
+ ] })
129
+ ]
130
+ }
131
+ );
132
+ }
133
+ const k = (l, i) => l.toDateString() === i.toDateString();
134
+ function me({ messages: l, groupMinutes: i = 5, firstUnreadId: c, onReact: r, quickReactions: g, onOpenThread: h, threadVariant: s = "link", renderActions: y, typing: o = [], variant: m = "bubble", header: v, height: C = 420, className: e, "aria-label": f }) {
135
+ const S = z(), { locale: d } = $(), p = M(null), w = M(!0), [T, I] = W(/* @__PURE__ */ new Set());
136
+ L(() => {
137
+ const t = p.current;
138
+ t && w.current && (t.scrollTop = t.scrollHeight);
139
+ }, [l.length, o.length]);
140
+ const b = (t) => {
141
+ const N = /* @__PURE__ */ new Date(), u = new Date(N);
142
+ return u.setDate(N.getDate() - 1), k(t, N) ? S.today : k(t, u) ? S.yesterday : new Intl.DateTimeFormat(d, { weekday: "long", day: "numeric", month: "long" }).format(t);
143
+ }, D = (t, N) => I((u) => {
144
+ const j = new Set(u);
145
+ return N ? j.add(t) : j.delete(t), j;
146
+ });
147
+ return /* @__PURE__ */ n(
148
+ "div",
149
+ {
150
+ ref: p,
151
+ className: E("alea-msglist", e),
152
+ style: { height: C },
153
+ tabIndex: 0,
154
+ role: "log",
155
+ "aria-label": f ?? S.messages,
156
+ onScroll: (t) => {
157
+ const N = t.currentTarget;
158
+ w.current = N.scrollHeight - N.scrollTop - N.clientHeight < 48;
159
+ },
160
+ children: [
161
+ v,
162
+ l.map((t, N) => {
163
+ var A, F;
164
+ const u = l[N - 1], j = !u || !k(u.time, t.time), P = !!u && !j && u.author === t.author && t.id !== c && (t.time.getTime() - u.time.getTime()) / 6e4 <= i;
165
+ return /* @__PURE__ */ n(J, { children: [
166
+ j && /* @__PURE__ */ a("div", { className: "alea-msglist-day", role: "separator", "aria-label": b(t.time), children: /* @__PURE__ */ a("span", { "aria-hidden": "true", children: b(t.time) }) }),
167
+ t.id === c && /* @__PURE__ */ a("div", { className: "alea-msglist-new", role: "separator", "aria-label": S.newMessages, children: /* @__PURE__ */ a("span", { "aria-hidden": "true", children: S.newMessages }) }),
168
+ /* @__PURE__ */ a(
169
+ H,
170
+ {
171
+ author: t.author,
172
+ avatarSrc: t.avatarSrc,
173
+ time: t.time,
174
+ isOwn: t.isOwn,
175
+ isGrouped: P,
176
+ status: t.status,
177
+ isEdited: t.isEdited,
178
+ variant: m,
179
+ reactions: t.reactions,
180
+ onReact: r ? (x) => r(t.id, x) : void 0,
181
+ quickReactions: g,
182
+ replyCount: t.replyCount ?? ((A = t.replies) == null ? void 0 : A.length),
183
+ thread: t.thread,
184
+ threadVariant: s,
185
+ onOpenThread: () => h == null ? void 0 : h(t.id),
186
+ threadReplies: s === "preview" && ((F = t.replies) != null && F.length) ? t.replies.map((x) => /* @__PURE__ */ a(H, { author: x.author, avatarSrc: x.avatarSrc, time: x.time, isOwn: x.isOwn, isEdited: x.isEdited, variant: "plain", reactions: x.reactions, onReact: r ? (_) => r(x.id, _) : void 0, children: x.text }, x.id)) : void 0,
187
+ isThreadExpanded: s === "preview" ? T.has(t.id) : void 0,
188
+ onThreadExpandedChange: (x) => D(t.id, x),
189
+ actions: y == null ? void 0 : y(t),
190
+ children: t.text
191
+ }
192
+ )
193
+ ] }, t.id);
194
+ }),
195
+ /* @__PURE__ */ a(oe, { names: o })
196
+ ]
197
+ }
198
+ );
199
+ }
200
+ function Te({ parent: l, replies: i, onClose: c, onDismiss: r, onReact: g, quickReactions: h, renderActions: s, typing: y, children: o, variant: m = "plain", height: v = 520, headingLevel: C = 2, autoFocus: e = !0, className: f }) {
201
+ const S = ae("ThreadView", "onClose", c, "onDismiss", r) ?? (() => {
202
+ }), d = z(), p = M(null), w = M(S);
203
+ w.current = S, L(() => {
204
+ var D;
205
+ const b = document.activeElement;
206
+ return e && ((D = p.current) == null || D.focus()), () => {
207
+ e && b && b !== document.body && b.isConnected && b.focus();
208
+ };
209
+ }, [e]);
210
+ const T = i.length, I = `h${C}`;
211
+ return /* @__PURE__ */ n(
212
+ "section",
213
+ {
214
+ className: E("alea-thread-view", f),
215
+ style: { height: v },
216
+ "aria-label": d.replyingIn(l.author),
217
+ onKeyDown: (b) => {
218
+ b.key === "Escape" && !b.defaultPrevented && (b.stopPropagation(), w.current());
219
+ },
220
+ children: [
221
+ /* @__PURE__ */ n("header", { className: "alea-thread-view-head", children: [
222
+ /* @__PURE__ */ n("div", { className: "alea-thread-view-titles", children: [
223
+ /* @__PURE__ */ a(I, { className: "alea-thread-view-title", ref: p, tabIndex: -1, children: d.thread }),
224
+ /* @__PURE__ */ n("p", { className: "alea-thread-view-sub", children: [
225
+ d.replyingIn(l.author),
226
+ T ? ` · ${d.replies(T)}` : ""
227
+ ] })
228
+ ] }),
229
+ /* @__PURE__ */ a(re, { "aria-label": d.closeThread, size: "sm", onPress: S, children: /* @__PURE__ */ a(ee, {}) })
230
+ ] }),
231
+ /* @__PURE__ */ a(
232
+ me,
233
+ {
234
+ className: "alea-thread-view-list",
235
+ height: "auto",
236
+ "aria-label": d.threadReplies,
237
+ variant: m,
238
+ messages: i,
239
+ typing: y,
240
+ onReact: g,
241
+ quickReactions: h,
242
+ renderActions: s,
243
+ header: /* @__PURE__ */ n(K, { children: [
244
+ /* @__PURE__ */ a(
245
+ H,
246
+ {
247
+ author: l.author,
248
+ avatarSrc: l.avatarSrc,
249
+ time: l.time,
250
+ isOwn: l.isOwn,
251
+ isEdited: l.isEdited,
252
+ variant: m,
253
+ reactions: l.reactions,
254
+ onReact: g ? (b) => g(l.id, b) : void 0,
255
+ quickReactions: h,
256
+ children: l.text
257
+ }
258
+ ),
259
+ /* @__PURE__ */ a("div", { className: "alea-thread-view-divider", role: "separator", "aria-label": T ? d.replies(T) : d.noReplies, children: /* @__PURE__ */ a("span", { "aria-hidden": "true", children: T ? d.replies(T) : d.noReplies }) })
260
+ ] })
261
+ }
262
+ ),
263
+ o && /* @__PURE__ */ a("div", { className: "alea-thread-view-reply", children: o })
264
+ ]
265
+ }
266
+ );
267
+ }
268
+ export {
269
+ H as ChatMessage,
270
+ me as MessageList,
271
+ B as ReactionBar,
272
+ ce as ThreadPreview,
273
+ Te as ThreadView,
274
+ oe as TypingIndicator
275
+ };
@@ -0,0 +1,69 @@
1
+ "use client";
2
+ import { jsx as a, jsxs as o, Fragment as b } from "react/jsx-runtime";
3
+ import { Check as $, X as j } from "lucide-react";
4
+ import { useControlled as B } from "../../utils/controlled.js";
5
+ import { Spinner as M } from "../feedback/Spinner.js";
6
+ import { Checkbox as w, CheckboxGroup as W, CheckboxGroupStateContext as F, Radio as O, RadioGroup as q, Switch as E } from "react-aria-components";
7
+ import { withBase as N } from "../../utils/cx.js";
8
+ import { Label as g, Description as D, FieldError as R } from "../field/Field.js";
9
+ import { useBusy as V } from "../field/FieldLoading.js";
10
+ function X({ children: t, description: e, size: h, variant: r, labelPosition: i, className: c, ...s }) {
11
+ return /* @__PURE__ */ a(w, { ...s, className: N("alea-check", c), "data-size": h, "data-variant": r !== "filled" ? r : void 0, "data-label-position": i !== "end" ? i : void 0, children: ({ isIndeterminate: d }) => /* @__PURE__ */ o(b, { children: [
12
+ /* @__PURE__ */ a("span", { className: "alea-check-box", "aria-hidden": "true", children: /* @__PURE__ */ a("svg", { viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round", children: d ? /* @__PURE__ */ a("path", { d: "M4 8h8", pathLength: 1 }) : /* @__PURE__ */ a("path", { d: "M3.5 8.5l3 3 6-7", pathLength: 1 }) }) }),
13
+ (t || e) && /* @__PURE__ */ o("span", { className: "alea-check-text", children: [
14
+ t,
15
+ e && /* @__PURE__ */ a("span", { className: "alea-check-desc", children: e })
16
+ ] })
17
+ ] }) });
18
+ }
19
+ function Z({ label: t, description: e, errorMessage: h, orientation: r = "vertical", appearance: i = "default", items: c, size: s, variant: d, selectAllLabel: u, children: m, className: p, value: n, defaultValue: z, onChange: G, ...f }) {
20
+ const [k, x] = B(n, z ?? [], G), v = (c || []).filter((l) => !l.isDisabled).map((l) => l.value), C = v.length > 0 && v.every((l) => k.includes(l)), S = !C && v.some((l) => k.includes(l));
21
+ return /* @__PURE__ */ o(W, { ...f, value: k, onChange: x, className: N("alea-field alea-choice-group", p), "data-orientation": r, "data-appearance": i, "data-size": s, "data-variant": d, children: [
22
+ t && /* @__PURE__ */ a(g, { children: t }),
23
+ c && u && // outside the group's value: it only sets the others
24
+ /* @__PURE__ */ a(F.Provider, { value: null, children: /* @__PURE__ */ a(w, { slot: null, className: "alea-check alea-check-all", isSelected: C, isIndeterminate: S, isDisabled: f.isDisabled, onChange: (l) => x(l ? [.../* @__PURE__ */ new Set([...k, ...v])] : k.filter((y) => !v.includes(y))), children: ({ isIndeterminate: l }) => /* @__PURE__ */ o(b, { children: [
25
+ /* @__PURE__ */ a("span", { className: "alea-check-box", "aria-hidden": "true", children: /* @__PURE__ */ a("svg", { viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round", children: l ? /* @__PURE__ */ a("path", { d: "M4 8h8", pathLength: 1 }) : /* @__PURE__ */ a("path", { d: "M3.5 8.5l3 3 6-7", pathLength: 1 }) }) }),
26
+ /* @__PURE__ */ a("span", { className: "alea-check-text", children: u })
27
+ ] }) }) }),
28
+ /* @__PURE__ */ a("div", { className: "alea-choice-items", "data-nested": c && u ? !0 : void 0, children: c ? c.map((l) => /* @__PURE__ */ a(X, { value: l.value, description: l.description, isDisabled: l.isDisabled, children: l.label }, l.value)) : m }),
29
+ e && /* @__PURE__ */ a(D, { children: e }),
30
+ /* @__PURE__ */ a(R, { children: h })
31
+ ] });
32
+ }
33
+ function H({ children: t, description: e, size: h, variant: r, labelPosition: i, className: c, ...s }) {
34
+ return /* @__PURE__ */ o(O, { ...s, className: N("alea-check alea-radio", c), "data-size": h, "data-variant": r !== "filled" ? r : void 0, "data-label-position": i !== "end" ? i : void 0, children: [
35
+ /* @__PURE__ */ a("span", { className: "alea-check-box", "aria-hidden": "true", children: /* @__PURE__ */ a("span", { className: "alea-radio-dot" }) }),
36
+ (t || e) && /* @__PURE__ */ o("span", { className: "alea-check-text", children: [
37
+ t,
38
+ e && /* @__PURE__ */ a("span", { className: "alea-check-desc", children: e })
39
+ ] })
40
+ ] });
41
+ }
42
+ function _({ label: t, description: e, errorMessage: h, orientation: r = "vertical", appearance: i = "default", items: c, size: s, variant: d, children: u, className: m, ...p }) {
43
+ return /* @__PURE__ */ o(q, { ...p, orientation: i === "buttons" ? "horizontal" : r, className: N("alea-field alea-choice-group", m), "data-appearance": i, "data-size": s, "data-variant": d, children: [
44
+ t && /* @__PURE__ */ a(g, { children: t }),
45
+ /* @__PURE__ */ a("div", { className: "alea-choice-items", children: c ? c.map((n) => /* @__PURE__ */ a(H, { value: n.value, description: i === "buttons" ? void 0 : n.description, isDisabled: n.isDisabled, children: n.label }, n.value)) : u }),
46
+ e && /* @__PURE__ */ a(D, { children: e }),
47
+ /* @__PURE__ */ a(R, { children: h })
48
+ ] });
49
+ }
50
+ function P({ children: t, description: e, size: h = "md", labelPosition: r = "end", onLabel: i, offLabel: c, thumbIcon: s, isLoading: d, className: u, ...m }) {
51
+ const p = V(d, (n) => n.querySelector("input"));
52
+ return /* @__PURE__ */ a(E, { ...m, ref: p, isReadOnly: m.isReadOnly || d, className: N("alea-check alea-switch", u), "data-size": h, "data-label-position": r, "data-labels": i || c ? !0 : void 0, "data-loading": d || void 0, children: ({ isSelected: n }) => /* @__PURE__ */ o(b, { children: [
53
+ /* @__PURE__ */ o("span", { className: "alea-switch-track", "aria-hidden": "true", children: [
54
+ (i || c) && /* @__PURE__ */ a("span", { className: "alea-switch-label", children: n ? i : c }),
55
+ /* @__PURE__ */ a("span", { className: "alea-switch-thumb", children: d ? /* @__PURE__ */ a(M, { size: "sm", "aria-label": "" }) : s === !0 ? n ? /* @__PURE__ */ a($, { strokeWidth: 3 }) : /* @__PURE__ */ a(j, { strokeWidth: 3 }) : s || null })
56
+ ] }),
57
+ (t || e) && /* @__PURE__ */ o("span", { className: "alea-check-text", children: [
58
+ t,
59
+ e && /* @__PURE__ */ a("span", { className: "alea-check-desc", children: e })
60
+ ] })
61
+ ] }) });
62
+ }
63
+ export {
64
+ X as Checkbox,
65
+ Z as CheckboxGroup,
66
+ H as Radio,
67
+ _ as RadioGroup,
68
+ P as Switch
69
+ };
@@ -1,4 +1,4 @@
1
- import type { ReactNode } from 'react';
1
+ import { type HTMLAttributes, type ReactNode } from 'react';
2
2
  import { type ColorPickerProps as RACColorPickerProps, type ColorAreaProps as RACColorAreaProps, type ColorSliderProps as RACColorSliderProps, type ColorWheelProps as RACColorWheelProps, type ColorFieldProps as RACColorFieldProps, type ColorSwatchPickerProps as RACColorSwatchPickerProps, type ValidationResult } from 'react-aria-components';
3
3
  export interface ColorPickerProps extends Omit<RACColorPickerProps, 'children'> {
4
4
  /** The visible label above the picker. */
@@ -16,7 +16,7 @@ export interface ColorPickerProps extends Omit<RACColorPickerProps, 'children'>
16
16
  export declare function ColorPicker({ label, swatches, showField, contrastWith, className, ...props }: ColorPickerProps): import("react").JSX.Element;
17
17
  /** The WCAG 2 contrast ratio between two colors (1 to 21). */
18
18
  export declare function contrastRatio(a: string, b: string): number;
19
- export interface ContrastBadgeProps {
19
+ export interface ContrastBadgeProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'color'> {
20
20
  /** The text color (any CSS color). */
21
21
  foreground: string;
22
22
  /** The background color (any CSS color). */
@@ -27,7 +27,7 @@ export interface ContrastBadgeProps {
27
27
  showSample?: boolean;
28
28
  }
29
29
  /** The contrast of a color pair with its WCAG verdict: AAA, AA, AA large or fail. */
30
- export declare function ContrastBadge({ foreground, background, large, showSample }: ContrastBadgeProps): import("react").JSX.Element;
30
+ export declare const ContrastBadge: import("react").ForwardRefExoticComponent<ContrastBadgeProps & import("react").RefAttributes<HTMLSpanElement>>;
31
31
  export interface ColorAreaProps extends Omit<RACColorAreaProps, 'children'> {
32
32
  /** Width and height in px. Default 240 × 180; set the width with style for a fluid area. */
33
33
  size?: number;