@hexclave/dashboard-ui-components 1.0.3 → 1.0.5

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 (52) hide show
  1. package/dist/components/button.d.ts +2 -2
  2. package/dist/components/pill-toggle.js +2 -2
  3. package/dist/components/pill-toggle.js.map +1 -1
  4. package/dist/dashboard-ui-components.global.js +7447 -9242
  5. package/dist/dashboard-ui-components.global.js.map +4 -4
  6. package/dist/esm/components/button.d.ts +2 -2
  7. package/dist/esm/components/pill-toggle.js +3 -3
  8. package/dist/esm/components/pill-toggle.js.map +1 -1
  9. package/package.json +4 -3
  10. package/src/components/alert.tsx +120 -0
  11. package/src/components/analytics-chart/analytics-chart-pie.tsx +369 -0
  12. package/src/components/analytics-chart/analytics-chart.tsx +1585 -0
  13. package/src/components/analytics-chart/default-analytics-chart-tooltip.tsx +265 -0
  14. package/src/components/analytics-chart/format.ts +101 -0
  15. package/src/components/analytics-chart/index.ts +75 -0
  16. package/src/components/analytics-chart/palette.ts +68 -0
  17. package/src/components/analytics-chart/render-data-series.tsx +169 -0
  18. package/src/components/analytics-chart/state.ts +165 -0
  19. package/src/components/analytics-chart/strings.ts +72 -0
  20. package/src/components/analytics-chart/types.ts +220 -0
  21. package/src/components/badge.tsx +108 -0
  22. package/src/components/button.tsx +104 -0
  23. package/src/components/card.tsx +263 -0
  24. package/src/components/chart-card.tsx +101 -0
  25. package/src/components/chart-container.tsx +155 -0
  26. package/src/components/chart-legend.tsx +65 -0
  27. package/src/components/chart-theme.tsx +52 -0
  28. package/src/components/chart-tooltip.tsx +165 -0
  29. package/src/components/cursor-blast-effect.tsx +334 -0
  30. package/src/components/data-grid/data-grid-sizing.ts +51 -0
  31. package/src/components/data-grid/data-grid-toolbar.tsx +373 -0
  32. package/src/components/data-grid/data-grid.test.tsx +366 -0
  33. package/src/components/data-grid/data-grid.tsx +1220 -0
  34. package/src/components/data-grid/index.ts +64 -0
  35. package/src/components/data-grid/state.ts +235 -0
  36. package/src/components/data-grid/strings.ts +45 -0
  37. package/src/components/data-grid/types.ts +401 -0
  38. package/src/components/data-grid/use-data-source.ts +413 -0
  39. package/src/components/data-grid/use-url-state.test.tsx +88 -0
  40. package/src/components/data-grid/use-url-state.ts +298 -0
  41. package/src/components/dialog.tsx +207 -0
  42. package/src/components/edit-mode.tsx +17 -0
  43. package/src/components/empty-state.tsx +64 -0
  44. package/src/components/input.tsx +85 -0
  45. package/src/components/metric-card.tsx +142 -0
  46. package/src/components/pill-toggle.tsx +159 -0
  47. package/src/components/progress-bar.tsx +82 -0
  48. package/src/components/separator.tsx +36 -0
  49. package/src/components/skeleton.tsx +30 -0
  50. package/src/components/table.tsx +113 -0
  51. package/src/components/tabs.tsx +214 -0
  52. package/src/index.ts +69 -0
@@ -0,0 +1,214 @@
1
+ "use client";
2
+
3
+ import { useState, type ReactNode } from "react";
4
+ import { cn, Spinner } from "@hexclave/ui";
5
+ import { runAsynchronouslyWithAlert } from "@hexclave/shared/dist/utils/promises";
6
+ import { useGlassmorphicDefault } from "./card";
7
+
8
+ type DesignTabsSize = "sm" | "md";
9
+ type DesignTabsGradient = "blue" | "cyan" | "purple" | "green" | "orange" | "default";
10
+
11
+ export type DesignCategoryTabItem = {
12
+ id: string,
13
+ label: string,
14
+ count?: number,
15
+ badgeCount?: number,
16
+ icon?: React.ComponentType<React.SVGProps<SVGSVGElement>>,
17
+ };
18
+
19
+ export type DesignCategoryTabsProps = Omit<React.ComponentProps<"div">, "onSelect"> & {
20
+ categories: DesignCategoryTabItem[],
21
+ selectedCategory: string,
22
+ onSelect: (id: string) => void | Promise<void>,
23
+ showBadge?: boolean,
24
+ size?: DesignTabsSize,
25
+ glassmorphic?: boolean,
26
+ gradient?: DesignTabsGradient,
27
+ /** Renders inside the tab bar after the tab buttons (not a tab). */
28
+ trailing?: ReactNode,
29
+ };
30
+
31
+ type TabSizeClass = {
32
+ button: string,
33
+ badge: string,
34
+ };
35
+
36
+ type GradientClass = {
37
+ activeText: string,
38
+ activeBadge: string,
39
+ underline: string,
40
+ };
41
+
42
+ const tabSizeClasses = new Map<DesignTabsSize, TabSizeClass>([
43
+ ["sm", { button: "px-3 py-2 text-xs", badge: "text-[10px] px-1.5 py-0.5" }],
44
+ ["md", { button: "px-4 py-3 text-sm", badge: "text-xs px-1.5 py-0.5" }],
45
+ ]);
46
+
47
+ const gradientClasses = new Map<DesignTabsGradient, GradientClass>([
48
+ [
49
+ "blue",
50
+ {
51
+ activeText: "text-blue-700 dark:text-blue-400",
52
+ activeBadge: "bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400",
53
+ underline: "bg-blue-700 dark:bg-blue-400",
54
+ },
55
+ ],
56
+ [
57
+ "cyan",
58
+ {
59
+ activeText: "text-cyan-700 dark:text-cyan-300",
60
+ activeBadge: "bg-cyan-100 dark:bg-cyan-900/30 text-cyan-700 dark:text-cyan-300",
61
+ underline: "bg-cyan-600 dark:bg-cyan-400",
62
+ },
63
+ ],
64
+ [
65
+ "purple",
66
+ {
67
+ activeText: "text-purple-700 dark:text-purple-300",
68
+ activeBadge: "bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300",
69
+ underline: "bg-purple-600 dark:bg-purple-400",
70
+ },
71
+ ],
72
+ [
73
+ "green",
74
+ {
75
+ activeText: "text-emerald-700 dark:text-emerald-300",
76
+ activeBadge: "bg-emerald-100 dark:bg-emerald-900/30 text-emerald-700 dark:text-emerald-300",
77
+ underline: "bg-emerald-600 dark:bg-emerald-400",
78
+ },
79
+ ],
80
+ [
81
+ "orange",
82
+ {
83
+ activeText: "text-amber-700 dark:text-amber-300",
84
+ activeBadge: "bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-300",
85
+ underline: "bg-amber-600 dark:bg-amber-400",
86
+ },
87
+ ],
88
+ [
89
+ "default",
90
+ {
91
+ activeText: "text-foreground",
92
+ activeBadge: "bg-foreground/10 text-foreground",
93
+ underline: "bg-foreground/80",
94
+ },
95
+ ],
96
+ ]);
97
+
98
+ function getMapValueOrThrow<TKey, TValue>(map: Map<TKey, TValue>, key: TKey, mapName: string) {
99
+ const value = map.get(key);
100
+ if (!value) {
101
+ throw new Error(`Missing ${mapName} entry for key "${String(key)}"`);
102
+ }
103
+ return value;
104
+ }
105
+
106
+ export function DesignCategoryTabs({
107
+ categories,
108
+ selectedCategory,
109
+ onSelect,
110
+ showBadge = true,
111
+ size = "sm",
112
+ glassmorphic: glassmorphicProp,
113
+ gradient = "blue",
114
+ trailing,
115
+ className,
116
+ ...props
117
+ }: DesignCategoryTabsProps) {
118
+ const glassmorphic = useGlassmorphicDefault(glassmorphicProp);
119
+ const sizeClass = getMapValueOrThrow(tabSizeClasses, size, "tabSizeClasses");
120
+ const gradientClass = getMapValueOrThrow(gradientClasses, gradient, "gradientClasses");
121
+ const [loadingCategoryId, setLoadingCategoryId] = useState<string | null>(null);
122
+
123
+ const handleSelect = (categoryId: string) => {
124
+ const result = onSelect(categoryId);
125
+ if (result && typeof (result as Promise<void>).then === "function") {
126
+ setLoadingCategoryId(categoryId);
127
+ runAsynchronouslyWithAlert(
128
+ Promise.resolve(result).finally(() => setLoadingCategoryId(null))
129
+ );
130
+ }
131
+ };
132
+
133
+ return (
134
+ <div
135
+ className={cn(
136
+ "flex w-full min-w-0 items-center gap-2",
137
+ glassmorphic
138
+ ? "rounded-xl bg-black/[0.08] dark:bg-white/[0.04] p-1 backdrop-blur-sm"
139
+ : "border-b border-gray-300 dark:border-gray-800",
140
+ className
141
+ )}
142
+ {...props}
143
+ >
144
+ <div
145
+ className={cn(
146
+ "flex min-h-0 min-w-0 items-center gap-1 overflow-x-auto flex-nowrap [&::-webkit-scrollbar]:hidden",
147
+ )}
148
+ >
149
+ {categories.map((category) => {
150
+ const isActive = selectedCategory === category.id;
151
+ const badgeValue = category.badgeCount ?? category.count;
152
+ const shouldShowBadge = showBadge && badgeValue !== undefined;
153
+
154
+ return (
155
+ <button
156
+ key={category.id}
157
+ onClick={() => handleSelect(category.id)}
158
+ disabled={loadingCategoryId !== null}
159
+ className={cn(
160
+ "font-medium transition-all duration-150 hover:transition-none relative flex flex-shrink-0 items-center justify-center gap-2 whitespace-nowrap",
161
+ "hover:text-gray-900 dark:hover:text-gray-100",
162
+ sizeClass.button,
163
+ glassmorphic ? "rounded-lg" : "",
164
+ isActive
165
+ ? cn(
166
+ gradientClass.activeText,
167
+ glassmorphic && "bg-background shadow-sm ring-1 ring-black/[0.12] dark:ring-white/[0.06]"
168
+ )
169
+ : "text-gray-700 dark:text-gray-400"
170
+ )}
171
+ >
172
+ {loadingCategoryId === category.id && (
173
+ <Spinner
174
+ size={12}
175
+ className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 pointer-events-none"
176
+ />
177
+ )}
178
+ <span className={cn(
179
+ "flex items-center gap-2",
180
+ loadingCategoryId === category.id && "invisible"
181
+ )}>
182
+ {category.icon && (
183
+ <category.icon className="h-4 w-4 shrink-0" aria-hidden />
184
+ )}
185
+ {category.label}
186
+ {shouldShowBadge && (
187
+ <span
188
+ className={cn(
189
+ "rounded-full",
190
+ sizeClass.badge,
191
+ isActive
192
+ ? gradientClass.activeBadge
193
+ : "bg-gray-200 dark:bg-gray-800 text-gray-600 dark:text-gray-400"
194
+ )}
195
+ >
196
+ {badgeValue}
197
+ </span>
198
+ )}
199
+ </span>
200
+ {!glassmorphic && isActive && (
201
+ <div className={cn("absolute bottom-0 left-0 right-0 h-0.5", gradientClass.underline)} />
202
+ )}
203
+ </button>
204
+ );
205
+ })}
206
+ </div>
207
+ {trailing != null ? (
208
+ <div className="flex shrink-0 items-center">
209
+ {trailing}
210
+ </div>
211
+ ) : null}
212
+ </div>
213
+ );
214
+ }
package/src/index.ts ADDED
@@ -0,0 +1,69 @@
1
+ export { DesignAlert } from "./components/alert";
2
+ export type { DesignAlertProps } from "./components/alert";
3
+
4
+ export { DesignBadge } from "./components/badge";
5
+ export type { DesignBadgeColor, DesignBadgeSize, DesignBadgeContentMode, DesignBadgeProps } from "./components/badge";
6
+
7
+ export { DesignButton } from "./components/button";
8
+ export type { DesignOriginalButtonProps, DesignButtonProps } from "./components/button";
9
+
10
+ export { DesignCard, DesignCardTint, useInsideDesignCard, useGlassmorphicDefault } from "./components/card";
11
+ export type { DesignCardProps, DesignCardTintProps } from "./components/card";
12
+
13
+ export { CursorBlastEffect } from "./components/cursor-blast-effect";
14
+ export type { CursorBlastEffectProps } from "./components/cursor-blast-effect";
15
+
16
+ export {
17
+ DesignDialog,
18
+ DesignDialogClose,
19
+ DesignDialogDescription,
20
+ DesignDialogRoot,
21
+ DesignDialogTitle,
22
+ DesignDialogTrigger,
23
+ } from "./components/dialog";
24
+ export type { DesignDialogProps, DesignDialogSize, DesignDialogVariant } from "./components/dialog";
25
+
26
+ export { DesignEditMode, useDesignEditMode } from "./components/edit-mode";
27
+
28
+ export { DesignInput } from "./components/input";
29
+ export type { DesignInputProps } from "./components/input";
30
+
31
+ export { DesignPillToggle } from "./components/pill-toggle";
32
+ export type { DesignPillToggleOption, DesignPillToggleProps } from "./components/pill-toggle";
33
+
34
+ export { DesignSeparator } from "./components/separator";
35
+ export type { DesignSeparatorProps } from "./components/separator";
36
+
37
+ export { DesignSkeleton } from "./components/skeleton";
38
+ export type { DesignSkeletonProps } from "./components/skeleton";
39
+
40
+ export { DesignTable, DesignTableHeader, DesignTableBody, DesignTableRow, DesignTableHead, DesignTableCell } from "./components/table";
41
+
42
+ export { DesignCategoryTabs } from "./components/tabs";
43
+ export type { DesignCategoryTabItem, DesignCategoryTabsProps } from "./components/tabs";
44
+
45
+ export { DESIGN_CHART_COLORS, getDesignChartColor, DESIGN_CHART_GRID_COLOR, DESIGN_CHART_AXIS_TICK_STYLE } from "./components/chart-theme";
46
+ export type { DesignChartColorEntry, DesignChartColorName } from "./components/chart-theme";
47
+
48
+ export { DesignChartContainer, DesignChartStyle, useDesignChart, getPayloadConfigFromPayload } from "./components/chart-container";
49
+ export type { DesignChartConfig } from "./components/chart-container";
50
+
51
+ export { DesignChartTooltip, DesignChartTooltipContent } from "./components/chart-tooltip";
52
+
53
+ export { DesignChartLegendContent } from "./components/chart-legend";
54
+
55
+ export { DesignChartCard } from "./components/chart-card";
56
+ export type { DesignChartCardProps } from "./components/chart-card";
57
+
58
+ export { DesignMetricCard } from "./components/metric-card";
59
+ export type { DesignMetricCardProps, DesignMetricCardTrend } from "./components/metric-card";
60
+
61
+ export { DesignProgressBar } from "./components/progress-bar";
62
+ export type { DesignProgressBarProps } from "./components/progress-bar";
63
+
64
+ export { DesignEmptyState } from "./components/empty-state";
65
+ export type { DesignEmptyStateProps } from "./components/empty-state";
66
+
67
+ export * from "./components/analytics-chart";
68
+
69
+ export * from "./components/data-grid";