@alpic-ai/ui 0.0.0-dev.g21697c4 → 0.0.0-dev.g21e767c

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 (111) hide show
  1. package/dist/components/accordion-card.d.mts +5 -6
  2. package/dist/components/accordion.d.mts +5 -6
  3. package/dist/components/alert.d.mts +9 -11
  4. package/dist/components/area-chart.d.mts +62 -0
  5. package/dist/components/area-chart.mjs +269 -0
  6. package/dist/components/attachment-tile.d.mts +1 -3
  7. package/dist/components/avatar.d.mts +8 -10
  8. package/dist/components/badge.d.mts +3 -5
  9. package/dist/components/bar-chart.d.mts +48 -0
  10. package/dist/components/bar-chart.mjs +256 -0
  11. package/dist/components/bar-list.d.mts +28 -0
  12. package/dist/components/bar-list.mjs +98 -0
  13. package/dist/components/breadcrumb.d.mts +10 -11
  14. package/dist/components/button.d.mts +7 -9
  15. package/dist/components/card.d.mts +9 -10
  16. package/dist/components/chart-card.d.mts +25 -0
  17. package/dist/components/chart-card.mjs +48 -0
  18. package/dist/components/chart-container.d.mts +20 -0
  19. package/dist/components/chart-container.mjs +37 -0
  20. package/dist/components/chart-legend.d.mts +16 -0
  21. package/dist/components/chart-legend.mjs +26 -0
  22. package/dist/components/chart-tooltip.d.mts +33 -0
  23. package/dist/components/chart-tooltip.mjs +52 -0
  24. package/dist/components/checkbox.d.mts +2 -3
  25. package/dist/components/collapsible.d.mts +4 -5
  26. package/dist/components/combobox.d.mts +10 -11
  27. package/dist/components/command.d.mts +9 -10
  28. package/dist/components/copyable.d.mts +2 -3
  29. package/dist/components/description-list.d.mts +5 -6
  30. package/dist/components/dialog.d.mts +15 -17
  31. package/dist/components/donut-chart.d.mts +46 -0
  32. package/dist/components/donut-chart.mjs +185 -0
  33. package/dist/components/dropdown-menu.d.mts +18 -20
  34. package/dist/components/form.d.mts +38 -21
  35. package/dist/components/form.mjs +6 -6
  36. package/dist/components/github-button.d.mts +1 -2
  37. package/dist/components/grid-fx.d.mts +13 -0
  38. package/dist/components/grid-fx.mjs +188 -0
  39. package/dist/components/heatmap-chart.d.mts +40 -0
  40. package/dist/components/heatmap-chart.mjs +198 -0
  41. package/dist/components/input-group.d.mts +5 -7
  42. package/dist/components/input.d.mts +4 -5
  43. package/dist/components/input.mjs +2 -2
  44. package/dist/components/label.d.mts +2 -3
  45. package/dist/components/line-chart.d.mts +55 -0
  46. package/dist/components/line-chart.mjs +211 -0
  47. package/dist/components/page-loader.d.mts +1 -3
  48. package/dist/components/pagination.d.mts +3 -4
  49. package/dist/components/popover.d.mts +5 -6
  50. package/dist/components/radio-group.d.mts +3 -4
  51. package/dist/components/scroll-area.d.mts +3 -4
  52. package/dist/components/select-trigger-variants.d.mts +1 -3
  53. package/dist/components/select.d.mts +9 -10
  54. package/dist/components/separator.d.mts +2 -3
  55. package/dist/components/sheet.d.mts +11 -12
  56. package/dist/components/shimmer-text.d.mts +2 -2
  57. package/dist/components/sidebar.d.mts +34 -36
  58. package/dist/components/sidebar.mjs +10 -10
  59. package/dist/components/skeleton.d.mts +3 -5
  60. package/dist/components/sonner.d.mts +5 -6
  61. package/dist/components/spinner.d.mts +4 -6
  62. package/dist/components/stat.d.mts +30 -0
  63. package/dist/components/stat.mjs +107 -0
  64. package/dist/components/status-dot.d.mts +2 -4
  65. package/dist/components/switch.d.mts +2 -3
  66. package/dist/components/table.d.mts +10 -11
  67. package/dist/components/tabs.d.mts +13 -15
  68. package/dist/components/tag.d.mts +3 -5
  69. package/dist/components/task-progress.d.mts +1 -3
  70. package/dist/components/textarea.d.mts +3 -4
  71. package/dist/components/textarea.mjs +2 -2
  72. package/dist/components/toggle-group.d.mts +4 -6
  73. package/dist/components/toggle-group.mjs +3 -3
  74. package/dist/components/tooltip-icon-button.d.mts +1 -2
  75. package/dist/components/tooltip.d.mts +5 -6
  76. package/dist/components/typography.d.mts +4 -5
  77. package/dist/components/wizard.d.mts +4 -5
  78. package/dist/hooks/use-chart-theme.d.mts +18 -0
  79. package/dist/hooks/use-chart-theme.mjs +57 -0
  80. package/dist/hooks/use-mobile.mjs +3 -3
  81. package/dist/hooks/use-reduced-motion.d.mts +4 -0
  82. package/dist/hooks/use-reduced-motion.mjs +16 -0
  83. package/dist/lib/chart-palette.d.mts +4 -0
  84. package/dist/lib/chart-palette.mjs +95 -0
  85. package/dist/lib/chart.d.mts +14 -0
  86. package/dist/lib/chart.mjs +27 -0
  87. package/package.json +30 -29
  88. package/src/components/area-chart.tsx +339 -0
  89. package/src/components/bar-chart.tsx +309 -0
  90. package/src/components/bar-list.tsx +150 -0
  91. package/src/components/chart-card.tsx +63 -0
  92. package/src/components/chart-container.tsx +49 -0
  93. package/src/components/chart-legend.tsx +41 -0
  94. package/src/components/chart-tooltip.tsx +93 -0
  95. package/src/components/donut-chart.tsx +217 -0
  96. package/src/components/grid-fx.tsx +238 -0
  97. package/src/components/heatmap-chart.tsx +287 -0
  98. package/src/components/line-chart.tsx +264 -0
  99. package/src/components/stat.tsx +109 -0
  100. package/src/hooks/use-chart-theme.ts +75 -0
  101. package/src/hooks/use-reduced-motion.ts +17 -0
  102. package/src/lib/chart-palette.ts +110 -0
  103. package/src/lib/chart.ts +56 -0
  104. package/src/stories/area-chart.stories.tsx +200 -0
  105. package/src/stories/bar-chart.stories.tsx +169 -0
  106. package/src/stories/bar-list.stories.tsx +85 -0
  107. package/src/stories/donut-chart.stories.tsx +112 -0
  108. package/src/stories/heatmap-chart.stories.tsx +107 -0
  109. package/src/stories/line-chart.stories.tsx +146 -0
  110. package/src/stories/stat.stories.tsx +64 -0
  111. package/src/styles/tokens.css +63 -0
@@ -0,0 +1,26 @@
1
+ "use client";
2
+ import { cn } from "../lib/cn.mjs";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ //#region src/components/chart-legend.tsx
5
+ function Swatch({ color, dashed }) {
6
+ return /* @__PURE__ */ jsx("span", {
7
+ "aria-hidden": true,
8
+ className: "size-2 shrink-0 rounded-full",
9
+ style: dashed ? { border: `1.5px solid ${color}` } : { background: color }
10
+ });
11
+ }
12
+ function ChartLegend({ items, className, ...props }) {
13
+ return /* @__PURE__ */ jsx("div", {
14
+ className: cn("flex flex-wrap gap-x-4 gap-y-1.5", className),
15
+ ...props,
16
+ children: items.map((item) => /* @__PURE__ */ jsxs("span", {
17
+ className: "inline-flex items-center gap-1.5 font-mono text-[10px] text-muted-foreground uppercase tracking-[0.12em]",
18
+ children: [/* @__PURE__ */ jsx(Swatch, {
19
+ color: item.color,
20
+ dashed: item.dashed
21
+ }), item.name]
22
+ }, item.name))
23
+ });
24
+ }
25
+ //#endregion
26
+ export { ChartLegend };
@@ -0,0 +1,33 @@
1
+ //#region src/components/chart-tooltip.d.ts
2
+ interface ChartTooltipItem {
3
+ name?: string | number;
4
+ value?: number | string;
5
+ color?: string;
6
+ stroke?: string;
7
+ fill?: string;
8
+ dataKey?: string | number;
9
+ }
10
+ interface ChartTooltipContentProps {
11
+ active?: boolean;
12
+ payload?: ChartTooltipItem[];
13
+ label?: string | number;
14
+ valueFormatter?: (value: number) => string;
15
+ labelFormatter?: (label: string | number) => string;
16
+ hideLabel?: boolean;
17
+ showTotal?: boolean;
18
+ totalLabel?: string;
19
+ className?: string;
20
+ }
21
+ declare function ChartTooltipContent({
22
+ active,
23
+ payload,
24
+ label,
25
+ valueFormatter,
26
+ labelFormatter,
27
+ hideLabel,
28
+ showTotal,
29
+ totalLabel,
30
+ className
31
+ }: ChartTooltipContentProps): import("react").JSX.Element | null;
32
+ //#endregion
33
+ export { ChartTooltipContent, ChartTooltipContentProps, ChartTooltipItem };
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ import { cn } from "../lib/cn.mjs";
3
+ import { useChartContext } from "./chart-container.mjs";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ //#region src/components/chart-tooltip.tsx
6
+ function ChartTooltipContent({ active, payload, label, valueFormatter = (value) => value.toLocaleString("en-US"), labelFormatter, hideLabel, showTotal, totalLabel = "Total", className }) {
7
+ const { theme } = useChartContext();
8
+ if (!active || !payload?.length) return null;
9
+ const total = payload.reduce((sum, item) => sum + (typeof item.value === "number" ? item.value : Number(item.value ?? 0)), 0);
10
+ return /* @__PURE__ */ jsxs("div", {
11
+ className: cn("min-w-[130px] rounded-lg border px-3 py-2.5 shadow-lg", "border-border bg-popover text-popover-foreground", className),
12
+ children: [!hideLabel && label !== void 0 && /* @__PURE__ */ jsx("p", {
13
+ className: "font-mono text-[10px] uppercase tracking-wider text-quaternary-foreground mb-1.5",
14
+ children: labelFormatter ? labelFormatter(label) : label
15
+ }), /* @__PURE__ */ jsxs("div", {
16
+ className: "flex flex-col gap-1",
17
+ children: [payload.map((item, index) => {
18
+ const swatch = [
19
+ item.color,
20
+ item.stroke,
21
+ item.fill
22
+ ].find((candidate) => typeof candidate === "string" && candidate.length > 0 && !candidate.startsWith("url(")) ?? theme.mutedForeground;
23
+ const numeric = typeof item.value === "number" ? item.value : Number(item.value ?? 0);
24
+ return /* @__PURE__ */ jsxs("div", {
25
+ className: "flex items-center justify-between gap-4 text-text-xs",
26
+ children: [/* @__PURE__ */ jsxs("span", {
27
+ className: "inline-flex items-center gap-2 text-muted-foreground",
28
+ children: [/* @__PURE__ */ jsx("span", {
29
+ "aria-hidden": true,
30
+ className: "size-2 shrink-0 rounded-[2px]",
31
+ style: { background: swatch }
32
+ }), item.name]
33
+ }), /* @__PURE__ */ jsx("span", {
34
+ className: "font-mono font-semibold tabular-nums text-foreground",
35
+ children: valueFormatter(numeric)
36
+ })]
37
+ }, `${item.dataKey ?? index}`);
38
+ }), showTotal && /* @__PURE__ */ jsxs("div", {
39
+ className: "mt-1 flex items-center justify-between gap-4 border-border border-t pt-1.5 text-text-xs",
40
+ children: [/* @__PURE__ */ jsx("span", {
41
+ className: "font-mono text-quaternary-foreground uppercase tracking-wider text-[10px]",
42
+ children: totalLabel
43
+ }), /* @__PURE__ */ jsx("span", {
44
+ className: "font-mono font-semibold tabular-nums text-foreground",
45
+ children: valueFormatter(total)
46
+ })]
47
+ })]
48
+ })]
49
+ });
50
+ }
51
+ //#endregion
52
+ export { ChartTooltipContent };
@@ -1,11 +1,10 @@
1
- import * as _$react_jsx_runtime0 from "react/jsx-runtime";
2
- import * as React from "react";
1
+ import * as React$1 from "react";
3
2
  import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
4
3
 
5
4
  //#region src/components/checkbox.d.ts
6
5
  declare function Checkbox({
7
6
  className,
8
7
  ...props
9
- }: React.ComponentProps<typeof CheckboxPrimitive.Root>): _$react_jsx_runtime0.JSX.Element;
8
+ }: React$1.ComponentProps<typeof CheckboxPrimitive.Root>): React$1.JSX.Element;
10
9
  //#endregion
11
10
  export { Checkbox };
@@ -1,16 +1,15 @@
1
- import * as _$react_jsx_runtime0 from "react/jsx-runtime";
2
- import * as React from "react";
1
+ import * as React$1 from "react";
3
2
  import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
4
3
 
5
4
  //#region src/components/collapsible.d.ts
6
5
  declare function Collapsible({
7
6
  ...props
8
- }: React.ComponentProps<typeof CollapsiblePrimitive.Root>): _$react_jsx_runtime0.JSX.Element;
7
+ }: React$1.ComponentProps<typeof CollapsiblePrimitive.Root>): React$1.JSX.Element;
9
8
  declare function CollapsibleTrigger({
10
9
  ...props
11
- }: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>): _$react_jsx_runtime0.JSX.Element;
10
+ }: React$1.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>): React$1.JSX.Element;
12
11
  declare function CollapsibleContent({
13
12
  ...props
14
- }: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>): _$react_jsx_runtime0.JSX.Element;
13
+ }: React$1.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>): React$1.JSX.Element;
15
14
  //#endregion
16
15
  export { Collapsible, CollapsibleContent, CollapsibleTrigger };
@@ -1,6 +1,5 @@
1
1
  import { PopoverContent } from "./popover.mjs";
2
2
  import { selectTriggerVariants } from "./select-trigger-variants.mjs";
3
- import * as _$react_jsx_runtime0 from "react/jsx-runtime";
4
3
  import { VariantProps } from "class-variance-authority";
5
4
  import { ReactNode } from "react";
6
5
  import { Command } from "cmdk";
@@ -27,7 +26,7 @@ interface ComboboxMultipleProps extends ComboboxBaseProps {
27
26
  onValueChange?: (value: string[]) => void;
28
27
  }
29
28
  type ComboboxProps = ComboboxSingleProps | ComboboxMultipleProps;
30
- declare function Combobox(props: ComboboxProps): _$react_jsx_runtime0.JSX.Element;
29
+ declare function Combobox(props: ComboboxProps): import("react").JSX.Element;
31
30
  interface ComboboxTriggerProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "size">, VariantProps<typeof selectTriggerVariants> {
32
31
  placeholder?: string;
33
32
  }
@@ -37,7 +36,7 @@ declare function ComboboxTrigger({
37
36
  placeholder,
38
37
  children,
39
38
  ...props
40
- }: ComboboxTriggerProps): _$react_jsx_runtime0.JSX.Element;
39
+ }: ComboboxTriggerProps): import("react").JSX.Element;
41
40
  interface ComboboxContentProps extends React.ComponentProps<typeof PopoverContent> {
42
41
  className?: string;
43
42
  children?: ReactNode;
@@ -48,27 +47,27 @@ declare function ComboboxContent({
48
47
  children,
49
48
  filter,
50
49
  ...props
51
- }: ComboboxContentProps): _$react_jsx_runtime0.JSX.Element;
50
+ }: ComboboxContentProps): import("react").JSX.Element;
52
51
  declare function ComboboxSearch({
53
52
  className,
54
53
  ...props
55
- }: React.ComponentProps<typeof Command.Input>): _$react_jsx_runtime0.JSX.Element;
54
+ }: React.ComponentProps<typeof Command.Input>): import("react").JSX.Element;
56
55
  declare function ComboboxList({
57
56
  className,
58
57
  ...props
59
- }: React.ComponentProps<typeof Command.List>): _$react_jsx_runtime0.JSX.Element;
58
+ }: React.ComponentProps<typeof Command.List>): import("react").JSX.Element;
60
59
  declare function ComboboxEmpty({
61
60
  className,
62
61
  ...props
63
- }: React.ComponentProps<typeof Command.Empty>): _$react_jsx_runtime0.JSX.Element;
62
+ }: React.ComponentProps<typeof Command.Empty>): import("react").JSX.Element;
64
63
  declare function ComboboxGroup({
65
64
  className,
66
65
  ...props
67
- }: React.ComponentProps<typeof Command.Group>): _$react_jsx_runtime0.JSX.Element;
66
+ }: React.ComponentProps<typeof Command.Group>): import("react").JSX.Element;
68
67
  declare function ComboboxSeparator({
69
68
  className,
70
69
  ...props
71
- }: React.ComponentProps<typeof Command.Separator>): _$react_jsx_runtime0.JSX.Element;
70
+ }: React.ComponentProps<typeof Command.Separator>): import("react").JSX.Element;
72
71
  interface ComboboxItemProps extends Omit<React.ComponentProps<typeof Command.Item>, "onSelect"> {
73
72
  /** The value stored when this item is selected */
74
73
  itemValue: string;
@@ -78,11 +77,11 @@ declare function ComboboxItem({
78
77
  children,
79
78
  itemValue,
80
79
  ...props
81
- }: ComboboxItemProps): _$react_jsx_runtime0.JSX.Element;
80
+ }: ComboboxItemProps): import("react").JSX.Element;
82
81
  declare function ComboboxItemText({
83
82
  className,
84
83
  children,
85
84
  ...props
86
- }: React.HTMLAttributes<HTMLSpanElement>): _$react_jsx_runtime0.JSX.Element;
85
+ }: React.HTMLAttributes<HTMLSpanElement>): import("react").JSX.Element;
87
86
  //#endregion
88
87
  export { Combobox, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxItem, ComboboxItemText, ComboboxList, ComboboxSearch, ComboboxSeparator, ComboboxTrigger };
@@ -1,38 +1,37 @@
1
- import * as _$react_jsx_runtime0 from "react/jsx-runtime";
2
- import * as React from "react";
1
+ import * as React$1 from "react";
3
2
  import { Command as Command$1 } from "cmdk";
4
3
 
5
4
  //#region src/components/command.d.ts
6
5
  declare function Command({
7
6
  className,
8
7
  ...props
9
- }: React.ComponentProps<typeof Command$1>): _$react_jsx_runtime0.JSX.Element;
8
+ }: React$1.ComponentProps<typeof Command$1>): React$1.JSX.Element;
10
9
  declare function CommandInput({
11
10
  className,
12
11
  ...props
13
- }: React.ComponentProps<typeof Command$1.Input>): _$react_jsx_runtime0.JSX.Element;
12
+ }: React$1.ComponentProps<typeof Command$1.Input>): React$1.JSX.Element;
14
13
  declare function CommandList({
15
14
  className,
16
15
  ...props
17
- }: React.ComponentProps<typeof Command$1.List>): _$react_jsx_runtime0.JSX.Element;
16
+ }: React$1.ComponentProps<typeof Command$1.List>): React$1.JSX.Element;
18
17
  declare function CommandEmpty({
19
18
  ...props
20
- }: React.ComponentProps<typeof Command$1.Empty>): _$react_jsx_runtime0.JSX.Element;
19
+ }: React$1.ComponentProps<typeof Command$1.Empty>): React$1.JSX.Element;
21
20
  declare function CommandGroup({
22
21
  className,
23
22
  ...props
24
- }: React.ComponentProps<typeof Command$1.Group>): _$react_jsx_runtime0.JSX.Element;
23
+ }: React$1.ComponentProps<typeof Command$1.Group>): React$1.JSX.Element;
25
24
  declare function CommandSeparator({
26
25
  className,
27
26
  ...props
28
- }: React.ComponentProps<typeof Command$1.Separator>): _$react_jsx_runtime0.JSX.Element;
27
+ }: React$1.ComponentProps<typeof Command$1.Separator>): React$1.JSX.Element;
29
28
  declare function CommandItem({
30
29
  className,
31
30
  ...props
32
- }: React.ComponentProps<typeof Command$1.Item>): _$react_jsx_runtime0.JSX.Element;
31
+ }: React$1.ComponentProps<typeof Command$1.Item>): React$1.JSX.Element;
33
32
  declare function CommandShortcut({
34
33
  className,
35
34
  ...props
36
- }: React.ComponentProps<"span">): _$react_jsx_runtime0.JSX.Element;
35
+ }: React$1.ComponentProps<"span">): React$1.JSX.Element;
37
36
  //#endregion
38
37
  export { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut };
@@ -1,4 +1,3 @@
1
- import * as _$react_jsx_runtime0 from "react/jsx-runtime";
2
1
  import { ReactNode } from "react";
3
2
 
4
3
  //#region src/components/copyable.d.ts
@@ -11,12 +10,12 @@ declare function Copyable({
11
10
  content,
12
11
  children,
13
12
  className
14
- }: CopyableProps): _$react_jsx_runtime0.JSX.Element;
13
+ }: CopyableProps): import("react").JSX.Element;
15
14
  interface CopyableUrlProps {
16
15
  url: URL;
17
16
  }
18
17
  declare function CopyableUrl({
19
18
  url
20
- }: CopyableUrlProps): _$react_jsx_runtime0.JSX.Element;
19
+ }: CopyableUrlProps): import("react").JSX.Element;
21
20
  //#endregion
22
21
  export { Copyable, type CopyableProps, CopyableUrl, type CopyableUrlProps };
@@ -1,22 +1,21 @@
1
- import * as _$react_jsx_runtime0 from "react/jsx-runtime";
2
- import * as React from "react";
1
+ import * as React$1 from "react";
3
2
 
4
3
  //#region src/components/description-list.d.ts
5
4
  declare function DescriptionList({
6
5
  className,
7
6
  ...props
8
- }: React.ComponentProps<"dl">): _$react_jsx_runtime0.JSX.Element;
7
+ }: React$1.ComponentProps<"dl">): React$1.JSX.Element;
9
8
  declare function DescriptionItem({
10
9
  className,
11
10
  ...props
12
- }: React.ComponentProps<"div">): _$react_jsx_runtime0.JSX.Element;
11
+ }: React$1.ComponentProps<"div">): React$1.JSX.Element;
13
12
  declare function DescriptionTitle({
14
13
  className,
15
14
  ...props
16
- }: React.ComponentProps<"dt">): _$react_jsx_runtime0.JSX.Element;
15
+ }: React$1.ComponentProps<"dt">): React$1.JSX.Element;
17
16
  declare function DescriptionValue({
18
17
  className,
19
18
  ...props
20
- }: React.ComponentProps<"dd">): _$react_jsx_runtime0.JSX.Element;
19
+ }: React$1.ComponentProps<"dd">): React$1.JSX.Element;
21
20
  //#endregion
22
21
  export { DescriptionItem, DescriptionList, DescriptionTitle, DescriptionValue };
@@ -1,28 +1,26 @@
1
1
  import { ButtonProps } from "./button.mjs";
2
- import * as _$react_jsx_runtime0 from "react/jsx-runtime";
3
2
  import { VariantProps } from "class-variance-authority";
4
- import * as React from "react";
3
+ import * as React$1 from "react";
5
4
  import * as DialogPrimitive from "@radix-ui/react-dialog";
6
- import * as _$class_variance_authority_types0 from "class-variance-authority/types";
7
5
 
8
6
  //#region src/components/dialog.d.ts
9
7
  declare function Dialog({
10
8
  ...props
11
- }: React.ComponentProps<typeof DialogPrimitive.Root>): _$react_jsx_runtime0.JSX.Element;
9
+ }: React$1.ComponentProps<typeof DialogPrimitive.Root>): React$1.JSX.Element;
12
10
  declare function DialogTrigger({
13
11
  ...props
14
- }: React.ComponentProps<typeof DialogPrimitive.Trigger>): _$react_jsx_runtime0.JSX.Element;
12
+ }: React$1.ComponentProps<typeof DialogPrimitive.Trigger>): React$1.JSX.Element;
15
13
  declare function DialogPortal({
16
14
  ...props
17
- }: React.ComponentProps<typeof DialogPrimitive.Portal>): _$react_jsx_runtime0.JSX.Element;
15
+ }: React$1.ComponentProps<typeof DialogPrimitive.Portal>): React$1.JSX.Element;
18
16
  declare function DialogOverlay({
19
17
  className,
20
18
  ...props
21
- }: React.ComponentProps<typeof DialogPrimitive.Overlay>): _$react_jsx_runtime0.JSX.Element;
19
+ }: React$1.ComponentProps<typeof DialogPrimitive.Overlay>): React$1.JSX.Element;
22
20
  declare const dialogContentVariants: (props?: ({
23
21
  size?: "sm" | "lg" | null | undefined;
24
- } & _$class_variance_authority_types0.ClassProp) | undefined) => string;
25
- interface DialogContentProps extends React.ComponentProps<typeof DialogPrimitive.Content>, VariantProps<typeof dialogContentVariants> {
22
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
23
+ interface DialogContentProps extends React$1.ComponentProps<typeof DialogPrimitive.Content>, VariantProps<typeof dialogContentVariants> {
26
24
  showCloseButton?: boolean;
27
25
  }
28
26
  declare function DialogContent({
@@ -31,31 +29,31 @@ declare function DialogContent({
31
29
  size,
32
30
  showCloseButton,
33
31
  ...props
34
- }: DialogContentProps): _$react_jsx_runtime0.JSX.Element;
32
+ }: DialogContentProps): React$1.JSX.Element;
35
33
  declare function DialogHeader({
36
34
  className,
37
35
  ...props
38
- }: React.ComponentProps<"div">): _$react_jsx_runtime0.JSX.Element;
36
+ }: React$1.ComponentProps<"div">): React$1.JSX.Element;
39
37
  declare const dialogFooterVariants: (props?: ({
40
38
  layout?: "horizontal" | "vertical" | null | undefined;
41
- } & _$class_variance_authority_types0.ClassProp) | undefined) => string;
42
- interface DialogFooterProps extends React.ComponentProps<"div">, VariantProps<typeof dialogFooterVariants> {}
39
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
40
+ interface DialogFooterProps extends React$1.ComponentProps<"div">, VariantProps<typeof dialogFooterVariants> {}
43
41
  declare function DialogFooter({
44
42
  className,
45
43
  layout,
46
44
  ...props
47
- }: DialogFooterProps): _$react_jsx_runtime0.JSX.Element;
45
+ }: DialogFooterProps): React$1.JSX.Element;
48
46
  declare function DialogTitle({
49
47
  className,
50
48
  ...props
51
- }: React.ComponentProps<typeof DialogPrimitive.Title>): _$react_jsx_runtime0.JSX.Element;
49
+ }: React$1.ComponentProps<typeof DialogPrimitive.Title>): React$1.JSX.Element;
52
50
  declare function DialogClose({
53
51
  children,
54
52
  ...props
55
- }: Omit<ButtonProps, "variant" | "asChild">): _$react_jsx_runtime0.JSX.Element;
53
+ }: Omit<ButtonProps, "variant" | "asChild">): React$1.JSX.Element;
56
54
  declare function DialogDescription({
57
55
  className,
58
56
  ...props
59
- }: React.ComponentProps<typeof DialogPrimitive.Description>): _$react_jsx_runtime0.JSX.Element;
57
+ }: React$1.ComponentProps<typeof DialogPrimitive.Description>): React$1.JSX.Element;
60
58
  //#endregion
61
59
  export { Dialog, DialogClose, DialogContent, type DialogContentProps, DialogDescription, DialogFooter, type DialogFooterProps, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, dialogContentVariants, dialogFooterVariants };
@@ -0,0 +1,46 @@
1
+ import { ChartPaletteName } from "../lib/chart-palette.mjs";
2
+ import * as React$1 from "react";
3
+
4
+ //#region src/components/donut-chart.d.ts
5
+ declare const GEOMETRY: {
6
+ readonly donut: {
7
+ readonly inner: "64%";
8
+ readonly outer: "92%";
9
+ };
10
+ readonly ring: {
11
+ readonly inner: "78%";
12
+ readonly outer: "92%";
13
+ };
14
+ };
15
+ interface DonutChartProps {
16
+ data: ReadonlyArray<Record<string, string | number | null | undefined>>;
17
+ index: string;
18
+ dataKey?: string;
19
+ variant?: keyof typeof GEOMETRY;
20
+ legend?: boolean;
21
+ paddingAngle?: number;
22
+ height?: number;
23
+ palette?: ChartPaletteName;
24
+ centerLabel?: string;
25
+ loading?: boolean;
26
+ valueFormatter?: (value: number) => string;
27
+ labelFormatter?: (label: string | number) => string;
28
+ className?: string;
29
+ }
30
+ declare function DonutChart({
31
+ data,
32
+ index,
33
+ dataKey,
34
+ variant,
35
+ legend,
36
+ paddingAngle,
37
+ height,
38
+ palette,
39
+ centerLabel,
40
+ loading,
41
+ valueFormatter,
42
+ labelFormatter,
43
+ className
44
+ }: DonutChartProps): React$1.JSX.Element;
45
+ //#endregion
46
+ export { DonutChart, DonutChartProps };
@@ -0,0 +1,185 @@
1
+ "use client";
2
+ import { cn } from "../lib/cn.mjs";
3
+ import { useReducedMotion } from "../hooks/use-reduced-motion.mjs";
4
+ import { paletteColor } from "../lib/chart-palette.mjs";
5
+ import { formatShare } from "../lib/chart.mjs";
6
+ import { useChartContext } from "./chart-container.mjs";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ import * as React$1 from "react";
9
+ import { Cell, Pie, PieChart, ResponsiveContainer } from "recharts";
10
+ //#region src/components/donut-chart.tsx
11
+ const GEOMETRY = {
12
+ donut: {
13
+ inner: "64%",
14
+ outer: "92%"
15
+ },
16
+ ring: {
17
+ inner: "78%",
18
+ outer: "92%"
19
+ }
20
+ };
21
+ function DonutChart({ data, index, dataKey = "value", variant = "donut", legend = false, paddingAngle = 1, height = 220, palette, centerLabel = "total", loading = false, valueFormatter = (value) => value.toLocaleString("en-US"), labelFormatter, className }) {
22
+ const { palette: paletteColors, theme } = useChartContext(palette);
23
+ const reactId = React$1.useId().replace(/:/g, "");
24
+ const animated = !useReducedMotion();
25
+ const [active, setActive] = React$1.useState(null);
26
+ const rowRefs = React$1.useRef([]);
27
+ const slices = React$1.useMemo(() => {
28
+ const mapped = data.map((row) => ({
29
+ name: String(row[index] ?? ""),
30
+ value: Number(row[dataKey]) || 0
31
+ }));
32
+ mapped.sort((lower, upper) => upper.value - lower.value);
33
+ return mapped.map((slice, rank) => ({
34
+ ...slice,
35
+ color: paletteColor(paletteColors, rank)
36
+ }));
37
+ }, [
38
+ data,
39
+ index,
40
+ dataKey,
41
+ paletteColors
42
+ ]);
43
+ const total = slices.reduce((sum, slice) => sum + slice.value, 0);
44
+ const maxValue = slices.reduce((max, slice) => slice.value > max ? slice.value : max, 0);
45
+ const geometry = GEOMETRY[variant] ?? GEOMETRY.donut;
46
+ const formatName = (name) => labelFormatter ? labelFormatter(name) : name;
47
+ const isEmpty = slices.length === 0 || total <= 0;
48
+ const activeSlice = active !== null ? slices[active] : void 0;
49
+ const centerTitle = activeSlice ? formatName(activeSlice.name) : centerLabel;
50
+ const centerValue = valueFormatter(activeSlice ? activeSlice.value : total);
51
+ React$1.useEffect(() => {
52
+ if (active !== null) rowRefs.current[active]?.scrollIntoView({ block: "nearest" });
53
+ }, [active]);
54
+ return /* @__PURE__ */ jsx("div", {
55
+ "data-slot": "donut-chart",
56
+ className: cn("@container flex w-full flex-col gap-3", className),
57
+ children: loading ? /* @__PURE__ */ jsxs("div", {
58
+ className: "flex items-center justify-center gap-2.5 font-mono text-quaternary-foreground text-text-xs",
59
+ style: { height },
60
+ children: [/* @__PURE__ */ jsx("span", { className: "size-4 animate-spin rounded-full border-2 border-border border-t-foreground" }), "loading…"]
61
+ }) : isEmpty ? /* @__PURE__ */ jsx("div", {
62
+ className: "flex items-center justify-center rounded-lg border border-border border-dashed font-mono text-quaternary-foreground text-text-xs",
63
+ style: { height },
64
+ children: "no data in range"
65
+ }) : /* @__PURE__ */ jsxs("div", {
66
+ className: "flex flex-col items-center gap-5 @md:flex-row",
67
+ children: [/* @__PURE__ */ jsxs("div", {
68
+ className: "relative shrink-0",
69
+ style: {
70
+ width: height,
71
+ height
72
+ },
73
+ children: [/* @__PURE__ */ jsx(ResponsiveContainer, {
74
+ width: "100%",
75
+ height: "100%",
76
+ children: /* @__PURE__ */ jsxs(PieChart, { children: [/* @__PURE__ */ jsx("defs", { children: slices.map((slice, slot) => /* @__PURE__ */ jsxs("linearGradient", {
77
+ id: `donut-${reactId}-${slot}`,
78
+ x1: "0",
79
+ y1: "0",
80
+ x2: "0",
81
+ y2: "1",
82
+ children: [/* @__PURE__ */ jsx("stop", {
83
+ offset: "0%",
84
+ stopColor: slice.color,
85
+ stopOpacity: 1
86
+ }), /* @__PURE__ */ jsx("stop", {
87
+ offset: "100%",
88
+ stopColor: slice.color,
89
+ stopOpacity: .7
90
+ })]
91
+ }, slice.name)) }), /* @__PURE__ */ jsx(Pie, {
92
+ data: slices,
93
+ dataKey: "value",
94
+ nameKey: "name",
95
+ innerRadius: geometry.inner,
96
+ outerRadius: geometry.outer,
97
+ paddingAngle,
98
+ startAngle: 90,
99
+ endAngle: -270,
100
+ cornerRadius: 2,
101
+ stroke: theme.card,
102
+ strokeWidth: 1.5,
103
+ isAnimationActive: animated,
104
+ animationDuration: 650,
105
+ animationEasing: "ease-out",
106
+ onMouseEnter: (_entry, sliceIndex) => setActive(sliceIndex),
107
+ onMouseLeave: () => setActive(null),
108
+ children: slices.map((slice, slot) => /* @__PURE__ */ jsx(Cell, {
109
+ className: "motion-safe:[transition:fill-opacity_180ms_ease-out]",
110
+ fill: `url(#donut-${reactId}-${slot})`,
111
+ fillOpacity: active === null || active === slot ? 1 : .55,
112
+ stroke: theme.card,
113
+ strokeWidth: 1.5
114
+ }, slice.name))
115
+ })] })
116
+ }), /* @__PURE__ */ jsxs("div", {
117
+ className: "pointer-events-none absolute inset-0 flex flex-col items-center justify-center gap-1 text-center",
118
+ children: [
119
+ /* @__PURE__ */ jsx("span", {
120
+ className: "max-w-[72%] truncate font-mono text-[10px] text-quaternary-foreground uppercase tracking-[0.18em]",
121
+ children: centerTitle
122
+ }),
123
+ /* @__PURE__ */ jsx("span", {
124
+ className: "font-mono font-semibold text-[28px] text-foreground leading-none tabular-nums",
125
+ children: centerValue
126
+ }),
127
+ activeSlice && /* @__PURE__ */ jsx("span", {
128
+ className: "font-mono font-medium text-[11px] tabular-nums",
129
+ style: { color: activeSlice.color },
130
+ children: formatShare(activeSlice.value / total)
131
+ })
132
+ ]
133
+ })]
134
+ }), legend && /* @__PURE__ */ jsx("div", {
135
+ "data-slot": "donut-readout",
136
+ className: "flex min-w-0 flex-1 flex-col overflow-y-auto pr-1",
137
+ style: { maxHeight: height },
138
+ children: slices.map((slice, slot) => /* @__PURE__ */ jsxs("div", {
139
+ ref: (node) => {
140
+ rowRefs.current[slot] = node;
141
+ },
142
+ onMouseEnter: () => setActive(slot),
143
+ onMouseLeave: () => setActive(null),
144
+ className: cn("flex flex-col gap-1.5 border-border/40 border-b px-2 py-2 text-text-xs last:border-b-0 motion-safe:transition-colors", active === slot ? "bg-muted/50" : "bg-transparent"),
145
+ children: [/* @__PURE__ */ jsxs("div", {
146
+ className: "flex items-center justify-between gap-3",
147
+ children: [/* @__PURE__ */ jsxs("span", {
148
+ className: "inline-flex min-w-0 items-center gap-2 text-muted-foreground",
149
+ children: [/* @__PURE__ */ jsx("span", {
150
+ "aria-hidden": true,
151
+ className: "h-2 w-2.5 shrink-0 rounded-[3px]",
152
+ style: { background: slice.color }
153
+ }), /* @__PURE__ */ jsx("span", {
154
+ className: "truncate",
155
+ children: formatName(slice.name)
156
+ })]
157
+ }), /* @__PURE__ */ jsxs("span", {
158
+ className: "flex shrink-0 items-center gap-3 font-mono tabular-nums",
159
+ children: [/* @__PURE__ */ jsx("span", {
160
+ className: "min-w-[3.5rem] text-right font-semibold text-foreground",
161
+ children: valueFormatter(slice.value)
162
+ }), /* @__PURE__ */ jsx("span", {
163
+ className: "w-10 text-right text-quaternary-foreground",
164
+ children: formatShare(slice.value / total)
165
+ })]
166
+ })]
167
+ }), /* @__PURE__ */ jsx("span", {
168
+ "aria-hidden": true,
169
+ className: "relative block h-[2px] w-full overflow-hidden rounded-full bg-border/40",
170
+ children: /* @__PURE__ */ jsx("span", {
171
+ className: "absolute inset-y-0 left-0 rounded-full motion-safe:transition-[width] motion-safe:duration-500",
172
+ style: {
173
+ width: `${maxValue > 0 ? slice.value / maxValue * 100 : 0}%`,
174
+ background: slice.color,
175
+ opacity: active === null || active === slot ? 1 : .45
176
+ }
177
+ })
178
+ })]
179
+ }, slice.name))
180
+ })]
181
+ })
182
+ });
183
+ }
184
+ //#endregion
185
+ export { DonutChart };