@alea-design/ui 0.7.2 → 0.8.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 (41) hide show
  1. package/dist/components/button/Button.d.ts +13 -2
  2. package/dist/components/button/Button.js +126 -104
  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,21 @@
1
+ import { type ReactNode } from 'react';
2
+ export interface ThrottledAnnouncerOptions {
3
+ /** The least time between two announcements, in ms. Default 3000. */
4
+ interval?: number;
5
+ /** polite (default) waits for the reader to finish; assertive interrupts. */
6
+ politeness?: 'polite' | 'assertive';
7
+ }
8
+ export interface ThrottledAnnouncer {
9
+ /** Says something. The first call speaks at once; calls that come before the interval is over are joined into one sentence and spoken when it ends. */
10
+ announce: (message: string) => void;
11
+ /** Drops what is waiting and silences the region. */
12
+ clear: () => void;
13
+ /** Render this once, anywhere: the visually hidden live region the messages go to. */
14
+ region: ReactNode;
15
+ }
16
+ /**
17
+ * A live region that does not talk over itself. Presence, review and sync changes can arrive many times a second; a screen reader that
18
+ * speaks each one falls behind and the person loses the thread. The first message is spoken now, the ones that follow inside the
19
+ * interval are queued and spoken together, so nothing is lost and nothing piles up.
20
+ */
21
+ export declare function useThrottledAnnouncer({ interval, politeness }?: ThrottledAnnouncerOptions): ThrottledAnnouncer;
@@ -0,0 +1,30 @@
1
+ "use client";
2
+ import { jsx as d } from "react/jsx-runtime";
3
+ import { useState as T, useRef as s, useCallback as u, useEffect as v } from "react";
4
+ function w({ interval: r = 3e3, politeness: i = "polite" } = {}) {
5
+ const [a, l] = T({ text: "", n: 0 }), n = s([]), f = s(0), e = s(void 0), c = u((t) => {
6
+ f.current = Date.now(), l((x) => ({ text: t, n: x.n + 1 }));
7
+ }, []), o = u(() => {
8
+ e.current = void 0;
9
+ const t = n.current.join(" ");
10
+ n.current = [], t && (c(t), e.current = setTimeout(o, r));
11
+ }, [r, c]), m = u((t) => {
12
+ if (t) {
13
+ if (e.current === void 0 && Date.now() - f.current >= r) {
14
+ c(t), e.current = setTimeout(o, r);
15
+ return;
16
+ }
17
+ n.current.push(t);
18
+ }
19
+ }, [o, r, c]), p = u(() => {
20
+ n.current = [], e.current && clearTimeout(e.current), e.current = void 0, l((t) => ({ text: "", n: t.n + 1 }));
21
+ }, []);
22
+ v(() => () => {
23
+ e.current && clearTimeout(e.current);
24
+ }, []);
25
+ const h = /* @__PURE__ */ d("span", { className: "alea-visually-hidden", role: i === "assertive" ? "alert" : "status", "aria-live": i, "aria-atomic": "true", children: /* @__PURE__ */ d("span", { children: a.text }, a.n) });
26
+ return { announce: m, clear: p, region: h };
27
+ }
28
+ export {
29
+ w as useThrottledAnnouncer
30
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alea-design/ui",
3
- "version": "0.7.2",
3
+ "version": "0.8.0",
4
4
  "description": "Alea: the complete React design system. Accessible components from forms to AI, charts and editors, Alea Motion, and W3C design tokens for dark, light and high contrast.",
5
5
  "keywords": [
6
6
  "react",
@@ -61,8 +61,8 @@
61
61
  "react-dom": ">=18.3"
62
62
  },
63
63
  "dependencies": {
64
- "@alea-design/motion": "0.7.2",
65
- "@alea-design/tokens": "0.7.2",
64
+ "@alea-design/motion": "0.8.0",
65
+ "@alea-design/tokens": "0.8.0",
66
66
  "@internationalized/date": "^3.8.0",
67
67
  "lucide-react": "^0.525.0",
68
68
  "qrcode-generator": "^1.5.2",