@felix-hz/seamount 0.0.0-stage → 0.1.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 (80) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +150 -2
  3. package/THIRD_PARTY_NOTICES.md +37 -0
  4. package/dist/css/base.css +75 -0
  5. package/dist/css/components.css +1107 -0
  6. package/dist/css/fonts.css +136 -0
  7. package/dist/css/seamount.css +1483 -0
  8. package/dist/css/tailwind.css +64 -0
  9. package/dist/css/tokens.css +159 -0
  10. package/dist/fonts/DepartureMono-OFL.txt +93 -0
  11. package/dist/fonts/InstrumentSans-OFL.txt +93 -0
  12. package/dist/fonts/JetBrainsMono-OFL.txt +93 -0
  13. package/dist/fonts/Newsreader-OFL.txt +93 -0
  14. package/dist/fonts/departure-mono.woff2 +0 -0
  15. package/dist/fonts/instrument-sans.woff2 +0 -0
  16. package/dist/fonts/jetbrains-mono.woff2 +0 -0
  17. package/dist/fonts/newsreader-display.woff2 +0 -0
  18. package/dist/fonts/newsreader-italic.woff2 +0 -0
  19. package/dist/fonts/newsreader-semibold.woff2 +0 -0
  20. package/dist/fonts/newsreader.woff2 +0 -0
  21. package/dist/lib/format.d.ts +23 -0
  22. package/dist/lib/format.js +88 -0
  23. package/dist/lib/format.js.map +1 -0
  24. package/dist/lib/theme.d.ts +20 -0
  25. package/dist/lib/theme.js +53 -0
  26. package/dist/lib/theme.js.map +1 -0
  27. package/dist/react/button.d.ts +12 -0
  28. package/dist/react/button.js +19 -0
  29. package/dist/react/button.js.map +1 -0
  30. package/dist/react/cn.d.ts +4 -0
  31. package/dist/react/cn.js +10 -0
  32. package/dist/react/cn.js.map +1 -0
  33. package/dist/react/controls.d.ts +23 -0
  34. package/dist/react/controls.js +50 -0
  35. package/dist/react/controls.js.map +1 -0
  36. package/dist/react/dialog.d.ts +40 -0
  37. package/dist/react/dialog.js +102 -0
  38. package/dist/react/dialog.js.map +1 -0
  39. package/dist/react/feedback.d.ts +31 -0
  40. package/dist/react/feedback.js +86 -0
  41. package/dist/react/feedback.js.map +1 -0
  42. package/dist/react/field.d.ts +38 -0
  43. package/dist/react/field.js +81 -0
  44. package/dist/react/field.js.map +1 -0
  45. package/dist/react/hooks.d.ts +24 -0
  46. package/dist/react/hooks.js +58 -0
  47. package/dist/react/hooks.js.map +1 -0
  48. package/dist/react/index.d.ts +19 -0
  49. package/dist/react/index.js +19 -0
  50. package/dist/react/label.d.ts +28 -0
  51. package/dist/react/label.js +91 -0
  52. package/dist/react/label.js.map +1 -0
  53. package/dist/react/menu.d.ts +21 -0
  54. package/dist/react/menu.js +72 -0
  55. package/dist/react/menu.js.map +1 -0
  56. package/dist/react/overlay.d.ts +19 -0
  57. package/dist/react/overlay.js +47 -0
  58. package/dist/react/overlay.js.map +1 -0
  59. package/dist/react/row.d.ts +14 -0
  60. package/dist/react/row.js +35 -0
  61. package/dist/react/row.js.map +1 -0
  62. package/dist/react/section.d.ts +20 -0
  63. package/dist/react/section.js +72 -0
  64. package/dist/react/section.js.map +1 -0
  65. package/dist/react/select.d.ts +11 -0
  66. package/dist/react/select.js +59 -0
  67. package/dist/react/select.js.map +1 -0
  68. package/dist/react/spec.d.ts +10 -0
  69. package/dist/react/spec.js +25 -0
  70. package/dist/react/spec.js.map +1 -0
  71. package/dist/react/stat.d.ts +37 -0
  72. package/dist/react/stat.js +115 -0
  73. package/dist/react/stat.js.map +1 -0
  74. package/dist/react/tabs.d.ts +7 -0
  75. package/dist/react/tabs.js +30 -0
  76. package/dist/react/tabs.js.map +1 -0
  77. package/dist/react/toast.d.ts +51 -0
  78. package/dist/react/toast.js +122 -0
  79. package/dist/react/toast.js.map +1 -0
  80. package/package.json +100 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"row.js","names":[],"sources":["../../src/react/row.tsx"],"sourcesContent":["import type * as React from \"react\";\nimport { cn } from \"./cn\";\n\nexport type RowProps = Omit<React.ComponentProps<\"div\">, \"children\"> & {\n name: React.ReactNode;\n help?: React.ReactNode;\n /** Third line in mono for live state (\"Reading…\", \"Reverted by MSI Center\"); accent when it is a warning. */\n state?: React.ReactNode;\n warning?: boolean;\n /** The id of the control, so the name labels it. */\n htmlFor?: string;\n children?: React.ReactNode;\n};\n\n/** A setting: name in the sans 500, one line of help, control on the right, rule under. */\nexport function Row({\n name,\n help,\n state,\n warning,\n htmlFor,\n className,\n children,\n ...props\n}: RowProps): React.JSX.Element {\n const Name = htmlFor ? \"label\" : \"div\";\n return (\n <div data-slot=\"row\" className={cn(\"sm-row\", className)} {...props}>\n <div className=\"sm-row-text\">\n <Name className=\"sm-row-name\" htmlFor={htmlFor}>\n {name}\n </Name>\n {help && <p className=\"sm-row-help\">{help}</p>}\n {state && (\n <p className=\"sm-row-state\" data-tone={warning ? \"accent\" : undefined}>\n {state}\n </p>\n )}\n </div>\n {children}\n </div>\n );\n}\n"],"mappings":";;;;;AAeA,SAAgB,IAAI,EAClB,MACA,MACA,OACA,SACA,SACA,WACA,UACA,GAAG,SAC2B;CAC9B,MAAM,OAAO,UAAU,UAAU;CACjC,OACE,qBAAC,OAAD;EAAK,aAAU;EAAM,WAAW,GAAG,UAAU,SAAS;EAAG,GAAI;EAA7D,UAAA,CACE,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA;IACE,oBAAC,MAAD;KAAM,WAAU;KAAuB;KACpC,UAAA;IACG,CAAA;IACL,QAAQ,oBAAC,KAAD;KAAG,WAAU;KAAe,UAAA;IAAQ,CAAA;IAC5C,SACC,oBAAC,KAAD;KAAG,WAAU;KAAe,aAAW,UAAU,WAAW,KAAA;KACzD,UAAA;IACA,CAAA;GAEF;EACJ,CAAA,GAAA,QACE;;AAET"}
@@ -0,0 +1,20 @@
1
+
2
+ import * as React from "react";
3
+ export type SectionProps = Omit<React.ComponentProps<"section">, "title"> & {
4
+ title: React.ReactNode;
5
+ /** `01` renders `[ 01 ]`; only when sections are a real sequence. */
6
+ n?: string;
7
+ /** A plain mono label instead of a number. */
8
+ label?: string;
9
+ /** Heading level of the title. */
10
+ as?: "h2" | "h3" | "h4";
11
+ /** Collapsible sections toggle from the heading with a `›` that turns 90°. */
12
+ collapsible?: boolean;
13
+ open?: boolean;
14
+ defaultOpen?: boolean;
15
+ onOpenChange?: (open: boolean) => void;
16
+ /** Right-aligned content in the heading row (a count, an action). */
17
+ aside?: React.ReactNode;
18
+ };
19
+ /** Mono label, display serif title, ink rule above. */
20
+ export declare function Section({ title, n, label, as: Heading, collapsible, open, defaultOpen, onOpenChange, aside, className, children, ...props }: SectionProps): React.JSX.Element;
@@ -0,0 +1,72 @@
1
+ "use client";
2
+ import { Collapsible } from "radix-ui";
3
+ import { cn } from "./cn.js";
4
+ import { Label } from "./label.js";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ // src/react/section.tsx
7
+ /** Mono label, display serif title, ink rule above. */
8
+ function Section({ title, n, label, as: Heading = "h2", collapsible = false, open, defaultOpen = true, onOpenChange, aside, className, children, ...props }) {
9
+ const marker = n ? /* @__PURE__ */ jsxs(Label, {
10
+ tone: "accent",
11
+ children: [
12
+ "[\xA0",
13
+ n,
14
+ "\xA0]"
15
+ ]
16
+ }) : label ? /* @__PURE__ */ jsx(Label, { children: label }) : null;
17
+ if (!collapsible) return /* @__PURE__ */ jsxs("section", {
18
+ "data-slot": "section",
19
+ className: cn("sm-section", className),
20
+ ...props,
21
+ children: [/* @__PURE__ */ jsxs("div", {
22
+ className: "sm-section-head",
23
+ children: [
24
+ marker,
25
+ /* @__PURE__ */ jsx(Heading, {
26
+ className: "sm-section-title",
27
+ children: title
28
+ }),
29
+ aside && /* @__PURE__ */ jsx("div", {
30
+ style: { marginLeft: "auto" },
31
+ children: aside
32
+ })
33
+ ]
34
+ }), children]
35
+ });
36
+ return /* @__PURE__ */ jsx(Collapsible.Root, {
37
+ asChild: true,
38
+ open,
39
+ defaultOpen,
40
+ onOpenChange,
41
+ children: /* @__PURE__ */ jsxs("section", {
42
+ "data-slot": "section",
43
+ className: cn("sm-section", className),
44
+ ...props,
45
+ children: [
46
+ /* @__PURE__ */ jsx(Heading, {
47
+ className: "sm-section-head",
48
+ children: /* @__PURE__ */ jsxs(Collapsible.Trigger, {
49
+ className: "sm-section-trigger",
50
+ children: [
51
+ marker,
52
+ /* @__PURE__ */ jsx("span", {
53
+ className: "sm-section-title",
54
+ children: title
55
+ }),
56
+ /* @__PURE__ */ jsx("span", {
57
+ className: "sm-chevron",
58
+ "aria-hidden": "true",
59
+ children: "›"
60
+ })
61
+ ]
62
+ })
63
+ }),
64
+ aside,
65
+ /* @__PURE__ */ jsx(Collapsible.Content, { children })
66
+ ]
67
+ })
68
+ });
69
+ }
70
+ export { Section };
71
+
72
+ //# sourceMappingURL=section.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"section.js","names":[],"sources":["../../src/react/section.tsx"],"sourcesContent":["import { Collapsible } from \"radix-ui\";\nimport type * as React from \"react\";\nimport { cn } from \"./cn\";\nimport { Label } from \"./label\";\n\nexport type SectionProps = Omit<React.ComponentProps<\"section\">, \"title\"> & {\n title: React.ReactNode;\n /** `01` renders `[ 01 ]`; only when sections are a real sequence. */\n n?: string;\n /** A plain mono label instead of a number. */\n label?: string;\n /** Heading level of the title. */\n as?: \"h2\" | \"h3\" | \"h4\";\n /** Collapsible sections toggle from the heading with a `›` that turns 90°. */\n collapsible?: boolean;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /** Right-aligned content in the heading row (a count, an action). */\n aside?: React.ReactNode;\n};\n\n/** Mono label, display serif title, ink rule above. */\nexport function Section({\n title,\n n,\n label,\n as: Heading = \"h2\",\n collapsible = false,\n open,\n defaultOpen = true,\n onOpenChange,\n aside,\n className,\n children,\n ...props\n}: SectionProps): React.JSX.Element {\n const marker = n ? <Label tone=\"accent\">[&nbsp;{n}&nbsp;]</Label> : label ? <Label>{label}</Label> : null;\n\n if (!collapsible) {\n return (\n <section data-slot=\"section\" className={cn(\"sm-section\", className)} {...props}>\n <div className=\"sm-section-head\">\n {marker}\n <Heading className=\"sm-section-title\">{title}</Heading>\n {aside && <div style={{ marginLeft: \"auto\" }}>{aside}</div>}\n </div>\n {children}\n </section>\n );\n }\n\n return (\n <Collapsible.Root asChild open={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange}>\n <section data-slot=\"section\" className={cn(\"sm-section\", className)} {...props}>\n <Heading className=\"sm-section-head\">\n <Collapsible.Trigger className=\"sm-section-trigger\">\n {marker}\n <span className=\"sm-section-title\">{title}</span>\n <span className=\"sm-chevron\" aria-hidden=\"true\">\n ›\n </span>\n </Collapsible.Trigger>\n </Heading>\n {aside}\n <Collapsible.Content>{children}</Collapsible.Content>\n </section>\n </Collapsible.Root>\n );\n}\n"],"mappings":";;;;;;;AAuBA,SAAgB,QAAQ,EACtB,OACA,GACA,OACA,IAAI,UAAU,MACd,cAAc,OACd,MACA,cAAc,MACd,cACA,OACA,WACA,UACA,GAAG,SAC+B;CAClC,MAAM,SAAS,IAAI,qBAAC,OAAD;EAAO,MAAK;EAAZ,UAAA;GAAqB;GAAQ;GAAE;EAAc;CAAI,CAAA,IAAA,QAAQ,oBAAC,OAAD,EAAA,UAAQ,MAAa,CAAA,IAAI;CAErG,IAAI,CAAC,aACH,OACE,qBAAC,WAAD;EAAS,aAAU;EAAU,WAAW,GAAG,cAAc,SAAS;EAAG,GAAI;EAAzE,UAAA,CACE,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA;IACG;IACD,oBAAC,SAAD;KAAS,WAAU;KAAoB,UAAA;IAAe,CAAA;IACrD,SAAS,oBAAC,OAAD;KAAK,OAAO,EAAE,YAAY,OAAO;KAAI,UAAA;IAAW,CAAA;GACvD;EACJ,CAAA,GAAA,QACM;;CAIb,OACE,oBAAC,YAAY,MAAb;EAAkB,SAAA;EAAc;EAAmB;EAA2B;EAC5E,UAAA,qBAAC,WAAD;GAAS,aAAU;GAAU,WAAW,GAAG,cAAc,SAAS;GAAG,GAAI;GAAzE,UAAA;IACE,oBAAC,SAAD;KAAS,WAAU;KACjB,UAAA,qBAAC,YAAY,SAAb;MAAqB,WAAU;MAA/B,UAAA;OACG;OACD,oBAAC,QAAD;QAAM,WAAU;QAAoB,UAAA;OAAY,CAAA;OAChD,oBAAC,QAAD;QAAM,WAAU;QAAa,eAAY;QAAO,UAAA;OAE1C,CAAA;MACa;;IACd,CAAA;IACR;IACD,oBAAC,YAAY,SAAb,EAAsB,SAA8B,CAAA;GAC7C;;CACO,CAAA;AAEtB"}
@@ -0,0 +1,11 @@
1
+
2
+ import { Select as Select$1 } from "radix-ui";
3
+ import * as React from "react";
4
+ export declare const Select: typeof Select$1.Root;
5
+ export declare const SelectGroup: typeof Select$1.Group;
6
+ export declare const SelectValue: typeof Select$1.Value;
7
+ export declare function SelectTrigger({ className, children, ...props }: React.ComponentProps<typeof Select$1.Trigger>): React.JSX.Element;
8
+ export declare function SelectContent({ className, children, position, sideOffset, style, ...props }: React.ComponentProps<typeof Select$1.Content>): React.JSX.Element;
9
+ export declare function SelectItem({ className, children, ...props }: React.ComponentProps<typeof Select$1.Item>): React.JSX.Element;
10
+ export declare function SelectLabel({ className, ...props }: React.ComponentProps<typeof Select$1.Label>): React.JSX.Element;
11
+ export declare function SelectSeparator({ className, ...props }: React.ComponentProps<typeof Select$1.Separator>): React.JSX.Element;
@@ -0,0 +1,59 @@
1
+ "use client";
2
+ import { Select as Select$1 } from "radix-ui";
3
+ import { cn } from "./cn.js";
4
+ import { useFieldControlProps } from "./field.js";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ // src/react/select.tsx
7
+ const Select = Select$1.Root;
8
+ const SelectGroup = Select$1.Group;
9
+ const SelectValue = Select$1.Value;
10
+ function SelectTrigger({ className, children, ...props }) {
11
+ const wired = useFieldControlProps(props);
12
+ return /* @__PURE__ */ jsx(Select$1.Trigger, {
13
+ "data-slot": "select-trigger",
14
+ className: cn("sm-select-trigger", className),
15
+ ...props,
16
+ ...wired,
17
+ children
18
+ });
19
+ }
20
+ function SelectContent({ className, children, position = "popper", sideOffset = 4, style, ...props }) {
21
+ return /* @__PURE__ */ jsx(Select$1.Portal, { children: /* @__PURE__ */ jsx(Select$1.Content, {
22
+ "data-slot": "select-content",
23
+ className: cn("sm-menu", className),
24
+ position,
25
+ sideOffset,
26
+ style: position === "popper" ? {
27
+ minWidth: "var(--radix-select-trigger-width)",
28
+ ...style
29
+ } : style,
30
+ ...props,
31
+ children: /* @__PURE__ */ jsx(Select$1.Viewport, { children })
32
+ }) });
33
+ }
34
+ function SelectItem({ className, children, ...props }) {
35
+ return /* @__PURE__ */ jsxs(Select$1.Item, {
36
+ "data-slot": "select-item",
37
+ className: cn("sm-menu-item", className),
38
+ ...props,
39
+ children: [/* @__PURE__ */ jsx(Select$1.ItemIndicator, {
40
+ className: "sm-menu-indicator",
41
+ children: "✓"
42
+ }), /* @__PURE__ */ jsx(Select$1.ItemText, { children })]
43
+ });
44
+ }
45
+ function SelectLabel({ className, ...props }) {
46
+ return /* @__PURE__ */ jsx(Select$1.Label, {
47
+ className: cn("sm-menu-label", className),
48
+ ...props
49
+ });
50
+ }
51
+ function SelectSeparator({ className, ...props }) {
52
+ return /* @__PURE__ */ jsx(Select$1.Separator, {
53
+ className: cn("sm-menu-separator", className),
54
+ ...props
55
+ });
56
+ }
57
+ export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue };
58
+
59
+ //# sourceMappingURL=select.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select.js","names":["SelectPrimitive"],"sources":["../../src/react/select.tsx"],"sourcesContent":["import { Select as SelectPrimitive } from \"radix-ui\";\nimport type * as React from \"react\";\nimport { cn } from \"./cn\";\nimport { useFieldControlProps } from \"./field\";\n\nexport const Select: typeof SelectPrimitive.Root = SelectPrimitive.Root;\nexport const SelectGroup: typeof SelectPrimitive.Group = SelectPrimitive.Group;\nexport const SelectValue: typeof SelectPrimitive.Value = SelectPrimitive.Value;\n\nexport function SelectTrigger({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Trigger>): React.JSX.Element {\n const wired = useFieldControlProps(props);\n return (\n <SelectPrimitive.Trigger\n data-slot=\"select-trigger\"\n className={cn(\"sm-select-trigger\", className)}\n {...props}\n {...wired}\n >\n {children}\n </SelectPrimitive.Trigger>\n );\n}\n\nexport function SelectContent({\n className,\n children,\n position = \"popper\",\n sideOffset = 4,\n style,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Content>): React.JSX.Element {\n return (\n <SelectPrimitive.Portal>\n <SelectPrimitive.Content\n data-slot=\"select-content\"\n className={cn(\"sm-menu\", className)}\n position={position}\n sideOffset={sideOffset}\n style={position === \"popper\" ? { minWidth: \"var(--radix-select-trigger-width)\", ...style } : style}\n {...props}\n >\n <SelectPrimitive.Viewport>{children}</SelectPrimitive.Viewport>\n </SelectPrimitive.Content>\n </SelectPrimitive.Portal>\n );\n}\n\nexport function SelectItem({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Item>): React.JSX.Element {\n return (\n <SelectPrimitive.Item data-slot=\"select-item\" className={cn(\"sm-menu-item\", className)} {...props}>\n <SelectPrimitive.ItemIndicator className=\"sm-menu-indicator\">✓</SelectPrimitive.ItemIndicator>\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </SelectPrimitive.Item>\n );\n}\n\nexport function SelectLabel({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Label>): React.JSX.Element {\n return <SelectPrimitive.Label className={cn(\"sm-menu-label\", className)} {...props} />;\n}\n\nexport function SelectSeparator({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Separator>): React.JSX.Element {\n return <SelectPrimitive.Separator className={cn(\"sm-menu-separator\", className)} {...props} />;\n}\n"],"mappings":";;;;;;AAKA,MAAa,SAAsCA,SAAgB;AACnE,MAAa,cAA4CA,SAAgB;AACzE,MAAa,cAA4CA,SAAgB;AAEzE,SAAgB,cAAc,EAC5B,WACA,UACA,GAAG,SACuE;CAC1E,MAAM,QAAQ,qBAAqB,KAAK;CACxC,OACE,oBAACA,SAAgB,SAAjB;EACE,aAAU;EACV,WAAW,GAAG,qBAAqB,SAAS;EAC5C,GAAI;EACJ,GAAI;EAEH;CACsB,CAAA;AAE7B;AAEA,SAAgB,cAAc,EAC5B,WACA,UACA,WAAW,UACX,aAAa,GACb,OACA,GAAG,SACuE;CAC1E,OACE,oBAACA,SAAgB,QAAjB,EAAA,UACE,oBAACA,SAAgB,SAAjB;EACE,aAAU;EACV,WAAW,GAAG,WAAW,SAAS;EACxB;EACE;EACZ,OAAO,aAAa,WAAW;GAAE,UAAU;GAAqC,GAAG;EAAM,IAAI;EAC7F,GAAI;EAEJ,UAAA,oBAACA,SAAgB,UAAjB,EAA2B,SAAmC,CAAA;CACvC,CAAA,EACH,CAAA;AAE5B;AAEA,SAAgB,WAAW,EACzB,WACA,UACA,GAAG,SACoE;CACvE,OACE,qBAACA,SAAgB,MAAjB;EAAsB,aAAU;EAAc,WAAW,GAAG,gBAAgB,SAAS;EAAG,GAAI;EAA5F,UAAA,CACE,oBAACA,SAAgB,eAAjB;GAA+B,WAAU;GAAoB,UAAA;EAAgC,CAAA,GAC7F,oBAACA,SAAgB,UAAjB,EAA2B,SAAmC,CAAA,CAC1C;;AAE1B;AAEA,SAAgB,YAAY,EAC1B,WACA,GAAG,SACqE;CACxE,OAAO,oBAACA,SAAgB,OAAjB;EAAuB,WAAW,GAAG,iBAAiB,SAAS;EAAG,GAAI;CAAQ,CAAA;AACvF;AAEA,SAAgB,gBAAgB,EAC9B,WACA,GAAG,SACyE;CAC5E,OAAO,oBAACA,SAAgB,WAAjB;EAA2B,WAAW,GAAG,qBAAqB,SAAS;EAAG,GAAI;CAAQ,CAAA;AAC/F"}
@@ -0,0 +1,10 @@
1
+
2
+ import * as React from "react";
3
+ /** Label and value pairs: mono caps label left, value right, ink rule on top, hairlines between. */
4
+ export declare function SpecList({ className, items, children, ...props }: React.ComponentProps<"dl"> & {
5
+ items?: ReadonlyArray<readonly [label: React.ReactNode, value: React.ReactNode]>;
6
+ }): React.JSX.Element;
7
+ export declare function SpecItem({ label, children }: {
8
+ label: React.ReactNode;
9
+ children?: React.ReactNode;
10
+ }): React.JSX.Element;
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { cn } from "./cn.js";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ // src/react/spec.tsx
5
+ /** Label and value pairs: mono caps label left, value right, ink rule on top, hairlines between. */
6
+ function SpecList({ className, items, children, ...props }) {
7
+ return /* @__PURE__ */ jsxs("dl", {
8
+ "data-slot": "spec",
9
+ className: cn("sm-spec", className),
10
+ ...props,
11
+ children: [items?.map(([label, value], i) => /* @__PURE__ */ jsx(SpecItem, {
12
+ label,
13
+ children: value
14
+ }, i)), children]
15
+ });
16
+ }
17
+ function SpecItem({ label, children }) {
18
+ return /* @__PURE__ */ jsxs("div", {
19
+ "data-slot": "spec-item",
20
+ children: [/* @__PURE__ */ jsx("dt", { children: label }), /* @__PURE__ */ jsx("dd", { children: children ?? "–" })]
21
+ });
22
+ }
23
+ export { SpecItem, SpecList };
24
+
25
+ //# sourceMappingURL=spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec.js","names":[],"sources":["../../src/react/spec.tsx"],"sourcesContent":["import type * as React from \"react\";\nimport { cn } from \"./cn\";\n\n/** Label and value pairs: mono caps label left, value right, ink rule on top, hairlines between. */\nexport function SpecList({\n className,\n items,\n children,\n ...props\n}: React.ComponentProps<\"dl\"> & {\n items?: ReadonlyArray<readonly [label: React.ReactNode, value: React.ReactNode]>;\n}): React.JSX.Element {\n return (\n <dl data-slot=\"spec\" className={cn(\"sm-spec\", className)} {...props}>\n {items?.map(([label, value], i) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: rows are positional and never reorder\n <SpecItem key={i} label={label}>\n {value}\n </SpecItem>\n ))}\n {children}\n </dl>\n );\n}\n\nexport function SpecItem({\n label,\n children,\n}: {\n label: React.ReactNode;\n children?: React.ReactNode;\n}): React.JSX.Element {\n return (\n <div data-slot=\"spec-item\">\n <dt>{label}</dt>\n <dd>{children ?? \"–\"}</dd>\n </div>\n );\n}\n"],"mappings":";;;;;AAIA,SAAgB,SAAS,EACvB,WACA,OACA,UACA,GAAG,SAGiB;CACpB,OACE,qBAAC,MAAD;EAAI,aAAU;EAAO,WAAW,GAAG,WAAW,SAAS;EAAG,GAAI;EAA9D,UAAA,CACG,OAAO,KAAK,CAAC,OAAO,QAAQ,MAE3B,oBAAC,UAAD;GAAyB;GACtB,UAAA;EACO,GAFK,CAEL,CACX,GACA,QACC;;AAER;AAEA,SAAgB,SAAS,EACvB,OACA,YAIoB;CACpB,OACE,qBAAC,OAAD;EAAK,aAAU;EAAf,UAAA,CACE,oBAAC,MAAD,EAAA,UAAK,MAAU,CAAA,GACf,oBAAC,MAAD,EAAA,UAAK,YAAY,IAAQ,CAAA,CACtB;;AAET"}
@@ -0,0 +1,37 @@
1
+
2
+ import * as React from "react";
3
+ export type SparklineProps = Omit<React.ComponentProps<"svg">, "values"> & {
4
+ values: ReadonlyArray<number | null>;
5
+ width?: number;
6
+ height?: number;
7
+ /** Read aloud in place of the drawing: "Spending fell over 12 weeks". */
8
+ label?: string;
9
+ };
10
+ /** ink-3 line with the current point in cobalt; gaps where a value is missing. */
11
+ export declare function Sparkline({ values, width, height, label, className, ...props }: SparklineProps): React.JSX.Element | null;
12
+ /** Path data for a sparkline, with an inset so the end mark is never clipped. */
13
+ export declare function sparklineGeometry(values: ReadonlyArray<number | null>, width: number, height: number): {
14
+ path: string;
15
+ end: [number, number] | null;
16
+ } | null;
17
+ export type StatTileProps = Omit<React.ComponentProps<"div">, "children"> & {
18
+ label: React.ReactNode;
19
+ value: React.ReactNode;
20
+ unit?: React.ReactNode;
21
+ /** The change against a named period, in words: "12% less than October". */
22
+ change?: React.ReactNode;
23
+ spark?: ReadonlyArray<number | null>;
24
+ sparkLabel?: string;
25
+ };
26
+ /** A single number is a stat tile, not a chart. */
27
+ export declare function StatTile({ label, value, unit, change, spark, sparkLabel, className, ...props }: StatTileProps): React.JSX.Element;
28
+ export type MeterProps = Omit<React.ComponentProps<"div">, "children"> & {
29
+ value: number;
30
+ max: number;
31
+ /** Names what is measured: "Groceries budget used". */
32
+ label: string;
33
+ /** Text for assistive tech, e.g. "$412 of $500". */
34
+ valueText?: string;
35
+ };
36
+ /** A share of a whole. Over the limit the fill turns ink; say so in words beside it, never by colour alone. */
37
+ export declare function Meter({ value, max, label, valueText, className, ...props }: MeterProps): React.JSX.Element;
@@ -0,0 +1,115 @@
1
+ "use client";
2
+ import * as React from "react";
3
+ import { cn } from "./cn.js";
4
+ import { Label } from "./label.js";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ // src/react/stat.tsx
7
+ /** ink-3 line with the current point in cobalt; gaps where a value is missing. */
8
+ function Sparkline({ values, width = 96, height = 24, label, className, ...props }) {
9
+ const geometry = React.useMemo(() => sparklineGeometry(values, width, height), [
10
+ values,
11
+ width,
12
+ height
13
+ ]);
14
+ if (!geometry) return null;
15
+ return /* @__PURE__ */ jsxs("svg", {
16
+ "data-slot": "sparkline",
17
+ className: cn("sm-sparkline", className),
18
+ width,
19
+ height,
20
+ viewBox: `0 0 ${width} ${height}`,
21
+ role: label ? "img" : void 0,
22
+ "aria-label": label,
23
+ "aria-hidden": label ? void 0 : true,
24
+ ...props,
25
+ children: [/* @__PURE__ */ jsx("path", {
26
+ className: "sm-sparkline-line",
27
+ d: geometry.path
28
+ }), geometry.end && /* @__PURE__ */ jsx("rect", {
29
+ className: "sm-sparkline-end",
30
+ x: geometry.end[0] - 2,
31
+ y: geometry.end[1] - 2,
32
+ width: 4,
33
+ height: 4
34
+ })]
35
+ });
36
+ }
37
+ /** Path data for a sparkline, with an inset so the end mark is never clipped. */
38
+ function sparklineGeometry(values, width, height) {
39
+ const present = values.filter((v) => v !== null && Number.isFinite(v));
40
+ if (present.length === 0) return null;
41
+ const inset = 2;
42
+ const min = Math.min(...present);
43
+ const max = Math.max(...present);
44
+ const span = max - min || 1;
45
+ const step = values.length > 1 ? (width - 4) / (values.length - 1) : 0;
46
+ let path = "";
47
+ let pen = false;
48
+ let end = null;
49
+ values.forEach((v, i) => {
50
+ if (v === null || !Number.isFinite(v)) {
51
+ pen = false;
52
+ return;
53
+ }
54
+ const x = inset + i * step;
55
+ const y = max === min ? height / 2 : inset + (1 - (v - min) / span) * (height - 4);
56
+ path += `${pen ? "L" : "M"}${x.toFixed(2)} ${y.toFixed(2)}`;
57
+ pen = true;
58
+ end = [x, y];
59
+ });
60
+ return {
61
+ path,
62
+ end
63
+ };
64
+ }
65
+ /** A single number is a stat tile, not a chart. */
66
+ function StatTile({ label, value, unit, change, spark, sparkLabel, className, ...props }) {
67
+ return /* @__PURE__ */ jsxs("div", {
68
+ "data-slot": "stat",
69
+ className: cn("sm-stat", className),
70
+ ...props,
71
+ children: [
72
+ /* @__PURE__ */ jsx(Label, { children: label }),
73
+ /* @__PURE__ */ jsxs("div", {
74
+ className: "sm-stat-value",
75
+ children: [value, unit && /* @__PURE__ */ jsx("span", {
76
+ className: "sm-stat-unit",
77
+ children: unit
78
+ })]
79
+ }),
80
+ (change || spark) && /* @__PURE__ */ jsxs("div", {
81
+ className: "sm-stat-foot",
82
+ children: [change && /* @__PURE__ */ jsx("span", {
83
+ className: "sm-stat-change",
84
+ children: change
85
+ }), spark && /* @__PURE__ */ jsx(Sparkline, {
86
+ values: spark,
87
+ label: sparkLabel
88
+ })]
89
+ })
90
+ ]
91
+ });
92
+ }
93
+ /** A share of a whole. Over the limit the fill turns ink; say so in words beside it, never by colour alone. */
94
+ function Meter({ value, max, label, valueText, className, ...props }) {
95
+ const share = max > 0 ? Math.min(value / max, 1) : 0;
96
+ return /* @__PURE__ */ jsx("div", {
97
+ "data-slot": "meter",
98
+ role: "meter",
99
+ "aria-label": label,
100
+ "aria-valuemin": 0,
101
+ "aria-valuemax": max,
102
+ "aria-valuenow": value,
103
+ "aria-valuetext": valueText,
104
+ "data-over": value > max || void 0,
105
+ className: cn("sm-meter", className),
106
+ ...props,
107
+ children: /* @__PURE__ */ jsx("div", {
108
+ className: "sm-meter-fill",
109
+ style: { width: `${share * 100}%` }
110
+ })
111
+ });
112
+ }
113
+ export { Meter, Sparkline, StatTile, sparklineGeometry };
114
+
115
+ //# sourceMappingURL=stat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stat.js","names":[],"sources":["../../src/react/stat.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"./cn\";\nimport { Label } from \"./label\";\n\nexport type SparklineProps = Omit<React.ComponentProps<\"svg\">, \"values\"> & {\n values: ReadonlyArray<number | null>;\n width?: number;\n height?: number;\n /** Read aloud in place of the drawing: \"Spending fell over 12 weeks\". */\n label?: string;\n};\n\n/** ink-3 line with the current point in cobalt; gaps where a value is missing. */\nexport function Sparkline({\n values,\n width = 96,\n height = 24,\n label,\n className,\n ...props\n}: SparklineProps): React.JSX.Element | null {\n const geometry = React.useMemo(() => sparklineGeometry(values, width, height), [values, width, height]);\n if (!geometry) return null;\n return (\n <svg\n data-slot=\"sparkline\"\n className={cn(\"sm-sparkline\", className)}\n width={width}\n height={height}\n viewBox={`0 0 ${width} ${height}`}\n role={label ? \"img\" : undefined}\n aria-label={label}\n aria-hidden={label ? undefined : true}\n {...props}\n >\n <path className=\"sm-sparkline-line\" d={geometry.path} />\n {geometry.end && (\n <rect className=\"sm-sparkline-end\" x={geometry.end[0] - 2} y={geometry.end[1] - 2} width={4} height={4} />\n )}\n </svg>\n );\n}\n\n/** Path data for a sparkline, with an inset so the end mark is never clipped. */\nexport function sparklineGeometry(\n values: ReadonlyArray<number | null>,\n width: number,\n height: number,\n): { path: string; end: [number, number] | null } | null {\n const present = values.filter((v): v is number => v !== null && Number.isFinite(v));\n if (present.length === 0) return null;\n const inset = 2;\n const min = Math.min(...present);\n const max = Math.max(...present);\n const span = max - min || 1;\n const step = values.length > 1 ? (width - inset * 2) / (values.length - 1) : 0;\n let path = \"\";\n let pen = false;\n let end: [number, number] | null = null;\n values.forEach((v, i) => {\n if (v === null || !Number.isFinite(v)) {\n pen = false;\n return;\n }\n const x = inset + i * step;\n // A flat series sits on the midline rather than the floor\n const y = max === min ? height / 2 : inset + (1 - (v - min) / span) * (height - inset * 2);\n path += `${pen ? \"L\" : \"M\"}${x.toFixed(2)} ${y.toFixed(2)}`;\n pen = true;\n end = [x, y];\n });\n return { path, end };\n}\n\nexport type StatTileProps = Omit<React.ComponentProps<\"div\">, \"children\"> & {\n label: React.ReactNode;\n value: React.ReactNode;\n unit?: React.ReactNode;\n /** The change against a named period, in words: \"12% less than October\". */\n change?: React.ReactNode;\n spark?: ReadonlyArray<number | null>;\n sparkLabel?: string;\n};\n\n/** A single number is a stat tile, not a chart. */\nexport function StatTile({\n label,\n value,\n unit,\n change,\n spark,\n sparkLabel,\n className,\n ...props\n}: StatTileProps): React.JSX.Element {\n return (\n <div data-slot=\"stat\" className={cn(\"sm-stat\", className)} {...props}>\n <Label>{label}</Label>\n <div className=\"sm-stat-value\">\n {value}\n {unit && <span className=\"sm-stat-unit\">{unit}</span>}\n </div>\n {(change || spark) && (\n <div className=\"sm-stat-foot\">\n {change && <span className=\"sm-stat-change\">{change}</span>}\n {spark && <Sparkline values={spark} label={sparkLabel} />}\n </div>\n )}\n </div>\n );\n}\n\nexport type MeterProps = Omit<React.ComponentProps<\"div\">, \"children\"> & {\n value: number;\n max: number;\n /** Names what is measured: \"Groceries budget used\". */\n label: string;\n /** Text for assistive tech, e.g. \"$412 of $500\". */\n valueText?: string;\n};\n\n/** A share of a whole. Over the limit the fill turns ink; say so in words beside it, never by colour alone. */\nexport function Meter({ value, max, label, valueText, className, ...props }: MeterProps): React.JSX.Element {\n const share = max > 0 ? Math.min(value / max, 1) : 0;\n return (\n // biome-ignore lint/a11y/useSemanticElements: a native <meter> cannot be styled consistently across engines\n <div\n data-slot=\"meter\"\n role=\"meter\"\n aria-label={label}\n aria-valuemin={0}\n aria-valuemax={max}\n aria-valuenow={value}\n aria-valuetext={valueText}\n data-over={value > max || undefined}\n className={cn(\"sm-meter\", className)}\n {...props}\n >\n <div className=\"sm-meter-fill\" style={{ width: `${share * 100}%` }} />\n </div>\n );\n}\n"],"mappings":";;;;;;;AAaA,SAAgB,UAAU,EACxB,QACA,QAAQ,IACR,SAAS,IACT,OACA,WACA,GAAG,SACwC;CAC3C,MAAM,WAAW,MAAM,cAAc,kBAAkB,QAAQ,OAAO,MAAM,GAAG;EAAC;EAAQ;EAAO;CAAM,CAAC;CACtG,IAAI,CAAC,UAAU,OAAO;CACtB,OACE,qBAAC,OAAD;EACE,aAAU;EACV,WAAW,GAAG,gBAAgB,SAAS;EAChC;EACC;EACR,SAAS,OAAO,MAAM,GAAG;EACzB,MAAM,QAAQ,QAAQ,KAAA;EACtB,cAAY;EACZ,eAAa,QAAQ,KAAA,IAAY;EACjC,GAAI;EATN,UAAA,CAWE,oBAAC,QAAD;GAAM,WAAU;GAAoB,GAAG,SAAS;EAAO,CAAA,GACtD,SAAS,OACR,oBAAC,QAAD;GAAM,WAAU;GAAmB,GAAG,SAAS,IAAI,KAAK;GAAG,GAAG,SAAS,IAAI,KAAK;GAAG,OAAO;GAAG,QAAQ;EAAI,CAAA,CAExG;;AAET;;AAGA,SAAgB,kBACd,QACA,OACA,QACuD;CACvD,MAAM,UAAU,OAAO,QAAQ,MAAmB,MAAM,QAAQ,OAAO,SAAS,CAAC,CAAC;CAClF,IAAI,QAAQ,WAAW,GAAG,OAAO;CACjC,MAAM,QAAQ;CACd,MAAM,MAAM,KAAK,IAAI,GAAG,OAAO;CAC/B,MAAM,MAAM,KAAK,IAAI,GAAG,OAAO;CAC/B,MAAM,OAAO,MAAM,OAAO;CAC1B,MAAM,OAAO,OAAO,SAAS,KAAK,QAAQ,MAAc,OAAO,SAAS,KAAK;CAC7E,IAAI,OAAO;CACX,IAAI,MAAM;CACV,IAAI,MAA+B;CACnC,OAAO,SAAS,GAAG,MAAM;EACvB,IAAI,MAAM,Q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,OAAO,EAAE,OAAO,GAAG,QAAQ,IAAI,GAAG;EAAI,CAAA;CAClE,CAAA;AAET"}
@@ -0,0 +1,7 @@
1
+
2
+ import { Tabs as Tabs$1 } from "radix-ui";
3
+ import * as React from "react";
4
+ export declare const Tabs: typeof Tabs$1.Root;
5
+ export declare function TabsList({ className, ...props }: React.ComponentProps<typeof Tabs$1.List>): React.JSX.Element;
6
+ export declare function TabsTrigger({ className, ...props }: React.ComponentProps<typeof Tabs$1.Trigger>): React.JSX.Element;
7
+ export declare function TabsContent({ className, ...props }: React.ComponentProps<typeof Tabs$1.Content>): React.JSX.Element;
@@ -0,0 +1,30 @@
1
+ "use client";
2
+ import { Tabs as Tabs$1 } from "radix-ui";
3
+ import { cn } from "./cn.js";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/react/tabs.tsx
6
+ const Tabs = Tabs$1.Root;
7
+ function TabsList({ className, ...props }) {
8
+ return /* @__PURE__ */ jsx(Tabs$1.List, {
9
+ "data-slot": "tabs-list",
10
+ className: cn("sm-tabs-list", className),
11
+ ...props
12
+ });
13
+ }
14
+ function TabsTrigger({ className, ...props }) {
15
+ return /* @__PURE__ */ jsx(Tabs$1.Trigger, {
16
+ "data-slot": "tabs-trigger",
17
+ className: cn("sm-tabs-trigger", className),
18
+ ...props
19
+ });
20
+ }
21
+ function TabsContent({ className, ...props }) {
22
+ return /* @__PURE__ */ jsx(Tabs$1.Content, {
23
+ "data-slot": "tabs-content",
24
+ className: cn("sm-tabs-content", className),
25
+ ...props
26
+ });
27
+ }
28
+ export { Tabs, TabsContent, TabsList, TabsTrigger };
29
+
30
+ //# sourceMappingURL=tabs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabs.js","names":["TabsPrimitive"],"sources":["../../src/react/tabs.tsx"],"sourcesContent":["import { Tabs as TabsPrimitive } from \"radix-ui\";\nimport type * as React from \"react\";\nimport { cn } from \"./cn\";\n\nexport const Tabs: typeof TabsPrimitive.Root = TabsPrimitive.Root;\n\nexport function TabsList({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.List>): React.JSX.Element {\n return <TabsPrimitive.List data-slot=\"tabs-list\" className={cn(\"sm-tabs-list\", className)} {...props} />;\n}\n\nexport function TabsTrigger({\n className,\n ...props\n}: React.ComponentProps<typeof TabsPrimitive.Trigger>): React.JSX.Element {\n return <TabsPrimitive.Trigger data-slot=\"tabs-trigger\" className={cn(\"sm-tabs-trigger\", className)} {...props} />;\n}\n\nexport function TabsContent({\n className,\n ...props\n}: React.ComponentProps<typeof TabsPrimitive.Content>): React.JSX.Element {\n return <TabsPrimitive.Content data-slot=\"tabs-content\" className={cn(\"sm-tabs-content\", className)} {...props} />;\n}\n"],"mappings":";;;;;AAIA,MAAa,OAAkCA,OAAc;AAE7D,SAAgB,SAAS,EAAE,WAAW,GAAG,SAA6E;CACpH,OAAO,oBAACA,OAAc,MAAf;EAAoB,aAAU;EAAY,WAAW,GAAG,gBAAgB,SAAS;EAAG,GAAI;CAAQ,CAAA;AACzG;AAEA,SAAgB,YAAY,EAC1B,WACA,GAAG,SACqE;CACxE,OAAO,oBAACA,OAAc,SAAf;EAAuB,aAAU;EAAe,WAAW,GAAG,mBAAmB,SAAS;EAAG,GAAI;CAAQ,CAAA;AAClH;AAEA,SAAgB,YAAY,EAC1B,WACA,GAAG,SACqE;CACxE,OAAO,oBAACA,OAAc,SAAf;EAAuB,aAAU;EAAe,WAAW,GAAG,mBAAmB,SAAS;EAAG,GAAI;CAAQ,CAAA;AAClH"}
@@ -0,0 +1,51 @@
1
+
2
+ import * as React from "react";
3
+ export type ToastKind = "success" | "info" | "progress" | "error";
4
+ export type ToastInput = {
5
+ /** The result in the past tense with its object: "Applied Gaming. 3 changes." */
6
+ title: React.ReactNode;
7
+ description?: React.ReactNode;
8
+ /** One action: Undo for a reversible change, the fix for an error (Retry, Open settings). */
9
+ action?: {
10
+ label: string;
11
+ onClick: () => void;
12
+ };
13
+ /** Progress only: "3/7"; omitted it prints "...". */
14
+ step?: string;
15
+ /** Milliseconds; Infinity stays until dismissed. Defaults follow the kind. */
16
+ duration?: number;
17
+ };
18
+ export type ToastRecord = ToastInput & {
19
+ id: number;
20
+ kind: ToastKind;
21
+ };
22
+ /** Success 4 s (8 s with Undo), info 6 s, progress and errors until done or dismissed. */
23
+ export declare function defaultDuration(kind: ToastKind, hasAction: boolean): number;
24
+ export type ToastApi = {
25
+ (input: ToastInput): number;
26
+ success: (input: ToastInput) => number;
27
+ info: (input: ToastInput) => number;
28
+ error: (input: ToastInput) => number;
29
+ /** Starts a progress toast; finish it with update(id, ...) as success or error. */
30
+ progress: (input: ToastInput) => number;
31
+ /** Changes the toast in place (progress steps, or finishing a progress toast). */
32
+ update: (id: number, input: Partial<ToastInput> & {
33
+ kind?: ToastKind;
34
+ }) => void;
35
+ dismiss: (id?: number) => void;
36
+ };
37
+ export declare const toast: ToastApi;
38
+ /** The toast on screen, for apps that render their own. */
39
+ export declare function useToastState(): ToastRecord | null;
40
+ export type ToasterProps = {
41
+ /** Bottom centre in apps, bottom left on the web. */
42
+ position?: "bottom-center" | "bottom-left";
43
+ /** Label of the viewport landmark; F8 moves focus to it. */
44
+ label?: string;
45
+ className?: string;
46
+ };
47
+ /**
48
+ * Mount once near the root. Errors announce assertively, everything else politely. Timers pause on hover and
49
+ * focus, Esc dismisses, and a toast never takes focus.
50
+ */
51
+ export declare function Toaster({ position, label, className }: ToasterProps): React.JSX.Element;
@@ -0,0 +1,122 @@
1
+ "use client";
2
+ import { Toast } from "radix-ui";
3
+ import * as React from "react";
4
+ import { cn } from "./cn.js";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ // src/react/toast.tsx
7
+ const TAGS = {
8
+ success: "OK",
9
+ info: "INFO",
10
+ error: "ERROR"
11
+ };
12
+ /** Success 4 s (8 s with Undo), info 6 s, progress and errors until done or dismissed. */
13
+ function defaultDuration(kind, hasAction) {
14
+ if (kind === "success") return hasAction ? 8e3 : 4e3;
15
+ if (kind === "info") return 6e3;
16
+ return Number.POSITIVE_INFINITY;
17
+ }
18
+ let current = null;
19
+ let nextId = 1;
20
+ const listeners = /* @__PURE__ */ new Set();
21
+ const emit = () => {
22
+ for (const listener of listeners) listener();
23
+ };
24
+ function show(kind, input) {
25
+ if (current?.kind === "error" && kind === "success") return current.id;
26
+ current = {
27
+ ...input,
28
+ kind,
29
+ id: nextId++
30
+ };
31
+ emit();
32
+ return current.id;
33
+ }
34
+ const toast = Object.assign((input) => show("success", input), {
35
+ success: (input) => show("success", input),
36
+ info: (input) => show("info", input),
37
+ error: (input) => show("error", input),
38
+ progress: (input) => show("progress", input),
39
+ update: (id, input) => {
40
+ if (current?.id !== id) return;
41
+ current = {
42
+ ...current,
43
+ ...input
44
+ };
45
+ emit();
46
+ },
47
+ dismiss: (id) => {
48
+ if (!current || id !== void 0 && current.id !== id) return;
49
+ current = null;
50
+ emit();
51
+ }
52
+ });
53
+ const subscribe = (listener) => {
54
+ listeners.add(listener);
55
+ return () => listeners.delete(listener);
56
+ };
57
+ /** The toast on screen, for apps that render their own. */
58
+ function useToastState() {
59
+ return React.useSyncExternalStore(subscribe, () => current, () => null);
60
+ }
61
+ /**
62
+ * Mount once near the root. Errors announce assertively, everything else politely. Timers pause on hover and
63
+ * focus, Esc dismisses, and a toast never takes focus.
64
+ */
65
+ function Toaster({ position = "bottom-center", label = "Notifications", className }) {
66
+ const record = useToastState();
67
+ return /* @__PURE__ */ jsxs(Toast.Provider, {
68
+ swipeDirection: position === "bottom-left" ? "left" : "down",
69
+ label,
70
+ children: [record && /* @__PURE__ */ jsx(ToastView, { record }, record.id), /* @__PURE__ */ jsx(Toast.Viewport, {
71
+ "data-position": position,
72
+ className: cn("sm-toast-viewport", className)
73
+ })]
74
+ });
75
+ }
76
+ function ToastView({ record }) {
77
+ const duration = record.duration ?? defaultDuration(record.kind, Boolean(record.action));
78
+ const tag = record.kind === "progress" ? record.step ?? "..." : TAGS[record.kind];
79
+ return /* @__PURE__ */ jsxs(Toast.Root, {
80
+ "data-slot": "toast",
81
+ "data-kind": record.kind,
82
+ className: "sm-toast",
83
+ type: record.kind === "error" ? "foreground" : "background",
84
+ duration,
85
+ onOpenChange: (open) => {
86
+ if (!open) toast.dismiss(record.id);
87
+ },
88
+ children: [
89
+ /* @__PURE__ */ jsxs("span", {
90
+ className: "sm-toast-tag",
91
+ children: [
92
+ "[\xA0",
93
+ tag,
94
+ "\xA0]"
95
+ ]
96
+ }),
97
+ /* @__PURE__ */ jsxs("div", {
98
+ className: "sm-toast-body",
99
+ children: [/* @__PURE__ */ jsx(Toast.Title, {
100
+ className: "sm-toast-title",
101
+ children: record.title
102
+ }), record.description && /* @__PURE__ */ jsx(Toast.Description, {
103
+ className: "sm-toast-description",
104
+ children: record.description
105
+ })]
106
+ }),
107
+ record.action && /* @__PURE__ */ jsx(Toast.Action, {
108
+ asChild: true,
109
+ altText: record.action.label,
110
+ children: /* @__PURE__ */ jsx("button", {
111
+ type: "button",
112
+ className: "sm-toast-action",
113
+ onClick: record.action.onClick,
114
+ children: record.action.label
115
+ })
116
+ })
117
+ ]
118
+ });
119
+ }
120
+ export { Toaster, defaultDuration, toast, useToastState };
121
+
122
+ //# sourceMappingURL=toast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toast.js","names":["ToastPrimitive"],"sources":["../../src/react/toast.tsx"],"sourcesContent":["import { Toast as ToastPrimitive } from \"radix-ui\";\nimport * as React from \"react\";\nimport { cn } from \"./cn\";\n\nexport type ToastKind = \"success\" | \"info\" | \"progress\" | \"error\";\n\nexport type ToastInput = {\n /** The result in the past tense with its object: \"Applied Gaming. 3 changes.\" */\n title: React.ReactNode;\n description?: React.ReactNode;\n /** One action: Undo for a reversible change, the fix for an error (Retry, Open settings). */\n action?: { label: string; onClick: () => void };\n /** Progress only: \"3/7\"; omitted it prints \"...\". */\n step?: string;\n /** Milliseconds; Infinity stays until dismissed. Defaults follow the kind. */\n duration?: number;\n};\n\nexport type ToastRecord = ToastInput & { id: number; kind: ToastKind };\n\nconst TAGS: Record<Exclude<ToastKind, \"progress\">, string> = {\n success: \"OK\",\n info: \"INFO\",\n error: \"ERROR\",\n};\n\n/** Success 4 s (8 s with Undo), info 6 s, progress and errors until done or dismissed. */\nexport function defaultDuration(kind: ToastKind, hasAction: boolean): number {\n if (kind === \"success\") return hasAction ? 8000 : 4000;\n if (kind === \"info\") return 6000;\n return Number.POSITIVE_INFINITY;\n}\n\n// One toast at a time: a new one replaces the old, except that an error is never replaced by a success.\nlet current: ToastRecord | null = null;\nlet nextId = 1;\nconst listeners = new Set<() => void>();\nconst emit = (): void => {\n for (const listener of listeners) listener();\n};\n\nfunction show(kind: ToastKind, input: ToastInput): number {\n if (current?.kind === \"error\" && kind === \"success\") return current.id;\n current = { ...input, kind, id: nextId++ };\n emit();\n return current.id;\n}\n\nexport type ToastApi = {\n (input: ToastInput): number;\n success: (input: ToastInput) => number;\n info: (input: ToastInput) => number;\n error: (input: ToastInput) => number;\n /** Starts a progress toast; finish it with update(id, ...) as success or error. */\n progress: (input: ToastInput) => number;\n /** Changes the toast in place (progress steps, or finishing a progress toast). */\n update: (id: number, input: Partial<ToastInput> & { kind?: ToastKind }) => void;\n dismiss: (id?: number) => void;\n};\n\nexport const toast: ToastApi = Object.assign((input: ToastInput) => show(\"success\", input), {\n success: (input: ToastInput) => show(\"success\", input),\n info: (input: ToastInput) => show(\"info\", input),\n error: (input: ToastInput) => show(\"error\", input),\n progress: (input: ToastInput) => show(\"progress\", input),\n update: (id: number, input: Partial<ToastInput> & { kind?: ToastKind }) => {\n if (current?.id !== id) return;\n current = { ...current, ...input };\n emit();\n },\n dismiss: (id?: number) => {\n if (!current || (id !== undefined && current.id !== id)) return;\n current = null;\n emit();\n },\n});\n\nconst subscribe = (listener: () => void): (() => void) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n};\n\n/** The toast on screen, for apps that render their own. */\nexport function useToastState(): ToastRecord | null {\n return React.useSyncExternalStore(\n subscribe,\n () => current,\n () => null,\n );\n}\n\nexport type ToasterProps = {\n /** Bottom centre in apps, bottom left on the web. */\n position?: \"bottom-center\" | \"bottom-left\";\n /** Label of the viewport landmark; F8 moves focus to it. */\n label?: string;\n className?: string;\n};\n\n/**\n * Mount once near the root. Errors announce assertively, everything else politely. Timers pause on hover and\n * focus, Esc dismisses, and a toast never takes focus.\n */\nexport function Toaster({\n position = \"bottom-center\",\n label = \"Notifications\",\n className,\n}: ToasterProps): React.JSX.Element {\n const record = useToastState();\n return (\n <ToastPrimitive.Provider swipeDirection={position === \"bottom-left\" ? \"left\" : \"down\"} label={label}>\n {record && <ToastView key={record.id} record={record} />}\n <ToastPrimitive.Viewport data-position={position} className={cn(\"sm-toast-viewport\", className)} />\n </ToastPrimitive.Provider>\n );\n}\n\nfunction ToastView({ record }: { record: ToastRecord }): React.JSX.Element {\n const duration = record.duration ?? defaultDuration(record.kind, Boolean(record.action));\n const tag = record.kind === \"progress\" ? (record.step ?? \"...\") : TAGS[record.kind];\n return (\n <ToastPrimitive.Root\n data-slot=\"toast\"\n data-kind={record.kind}\n className=\"sm-toast\"\n type={record.kind === \"error\" ? \"foreground\" : \"background\"}\n duration={duration}\n onOpenChange={(open) => {\n if (!open) toast.dismiss(record.id);\n }}\n >\n <span className=\"sm-toast-tag\">[&nbsp;{tag}&nbsp;]</span>\n <div className=\"sm-toast-body\">\n <ToastPrimitive.Title className=\"sm-toast-title\">{record.title}</ToastPrimitive.Title>\n {record.description && (\n <ToastPrimitive.Description className=\"sm-toast-description\">{record.description}</ToastPrimitive.Description>\n )}\n </div>\n {record.action && (\n <ToastPrimitive.Action asChild altText={record.action.label}>\n <button type=\"button\" className=\"sm-toast-action\" onClick={record.action.onClick}>\n {record.action.label}\n </button>\n </ToastPrimitive.Action>\n )}\n </ToastPrimitive.Root>\n );\n}\n"],"mappings":";;;;;;AAoBA,MAAM,OAAuD;CAC3D,SAAS;CACT,MAAM;CACN,OAAO;AACT;;AAGA,SAAgB,gBAAgB,MAAiB,WAA4B;CAC3E,IAAI,SAAS,WAAW,O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