@siyahi/ui 0.0.0-stage → 0.1.0-next.3
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.
- package/LICENSE +21 -0
- package/README.md +174 -2
- package/THIRD_PARTY_NOTICES.md +51 -0
- package/dist/components/registry/dashboard-01/section-cards.d.ts +17 -0
- package/dist/components/registry/dashboard-01/section-cards.js +39 -0
- package/dist/components/registry/dashboardcn/bar-list.d.ts +24 -0
- package/dist/components/registry/dashboardcn/bar-list.js +71 -0
- package/dist/components/registry/heatmap/calendar-heatmap.d.ts +134 -0
- package/dist/components/registry/heatmap/calendar-heatmap.js +497 -0
- package/dist/components/registry/heatmap/status-heatmap.d.ts +120 -0
- package/dist/components/registry/heatmap/status-heatmap.js +330 -0
- package/dist/components/registry/heatmap/weekday-heatmap.d.ts +145 -0
- package/dist/components/registry/heatmap/weekday-heatmap.js +489 -0
- package/dist/components/registry/niko-table/components/data-table-column-actions.d.ts +26 -0
- package/dist/components/registry/niko-table/components/data-table-column-actions.js +32 -0
- package/dist/components/registry/niko-table/components/data-table-column-filter.d.ts +13 -0
- package/dist/components/registry/niko-table/components/data-table-column-filter.js +17 -0
- package/dist/components/registry/niko-table/components/data-table-column-header.d.ts +30 -0
- package/dist/components/registry/niko-table/components/data-table-column-header.js +35 -0
- package/dist/components/registry/niko-table/components/data-table-column-sort.d.ts +21 -0
- package/dist/components/registry/niko-table/components/data-table-column-sort.js +36 -0
- package/dist/components/registry/niko-table/components/data-table-column-title.d.ts +12 -0
- package/dist/components/registry/niko-table/components/data-table-column-title.js +18 -0
- package/dist/components/registry/niko-table/components/data-table-empty-state.d.ts +108 -0
- package/dist/components/registry/niko-table/components/data-table-empty-state.js +148 -0
- package/dist/components/registry/niko-table/components/data-table-faceted-filter.d.ts +46 -0
- package/dist/components/registry/niko-table/components/data-table-faceted-filter.js +133 -0
- package/dist/components/registry/niko-table/components/data-table-grouped-rows.d.ts +111 -0
- package/dist/components/registry/niko-table/components/data-table-grouped-rows.js +77 -0
- package/dist/components/registry/niko-table/components/data-table-row-context-menu-slot.d.ts +65 -0
- package/dist/components/registry/niko-table/components/data-table-row-context-menu-slot.js +65 -0
- package/dist/components/registry/niko-table/components/data-table-row-context-menu.d.ts +50 -0
- package/dist/components/registry/niko-table/components/data-table-row-context-menu.js +42 -0
- package/dist/components/registry/niko-table/components/data-table-row-menu.d.ts +51 -0
- package/dist/components/registry/niko-table/components/data-table-row-menu.js +65 -0
- package/dist/components/registry/niko-table/components/data-table-toolbar-section.d.ts +7 -0
- package/dist/components/registry/niko-table/components/data-table-toolbar-section.js +63 -0
- package/dist/components/registry/niko-table/config/data-table.d.ts +156 -0
- package/dist/components/registry/niko-table/config/data-table.js +279 -0
- package/dist/components/registry/niko-table/config/feature-detection.d.ts +39 -0
- package/dist/components/registry/niko-table/config/feature-detection.js +174 -0
- package/dist/components/registry/niko-table/core/data-table-context.d.ts +157 -0
- package/dist/components/registry/niko-table/core/data-table-context.js +326 -0
- package/dist/components/registry/niko-table/core/data-table-error-boundary.d.ts +85 -0
- package/dist/components/registry/niko-table/core/data-table-error-boundary.js +116 -0
- package/dist/components/registry/niko-table/core/data-table-grouped-row.d.ts +49 -0
- package/dist/components/registry/niko-table/core/data-table-grouped-row.js +112 -0
- package/dist/components/registry/niko-table/core/data-table-root.d.ts +62 -0
- package/dist/components/registry/niko-table/core/data-table-root.js +406 -0
- package/dist/components/registry/niko-table/core/data-table-structure.d.ts +153 -0
- package/dist/components/registry/niko-table/core/data-table-structure.js +370 -0
- package/dist/components/registry/niko-table/core/data-table.d.ts +30 -0
- package/dist/components/registry/niko-table/core/data-table.js +126 -0
- package/dist/components/registry/niko-table/filters/table-column-actions.d.ts +49 -0
- package/dist/components/registry/niko-table/filters/table-column-actions.js +48 -0
- package/dist/components/registry/niko-table/filters/table-column-sort.d.ts +51 -0
- package/dist/components/registry/niko-table/filters/table-column-sort.js +184 -0
- package/dist/components/registry/niko-table/filters/table-column-title.d.ts +17 -0
- package/dist/components/registry/niko-table/filters/table-column-title.js +20 -0
- package/dist/components/registry/niko-table/filters/table-faceted-filter.d.ts +40 -0
- package/dist/components/registry/niko-table/filters/table-faceted-filter.js +210 -0
- package/dist/components/registry/niko-table/hooks/use-derived-column-title.d.ts +29 -0
- package/dist/components/registry/niko-table/hooks/use-derived-column-title.js +40 -0
- package/dist/components/registry/niko-table/hooks/use-generated-options.d.ts +49 -0
- package/dist/components/registry/niko-table/hooks/use-generated-options.js +144 -0
- package/dist/components/registry/niko-table/lib/build-faceted-options.d.ts +59 -0
- package/dist/components/registry/niko-table/lib/build-faceted-options.js +82 -0
- package/dist/components/registry/niko-table/lib/column-resize-handle.d.ts +33 -0
- package/dist/components/registry/niko-table/lib/column-resize-handle.js +175 -0
- package/dist/components/registry/niko-table/lib/constants.d.ts +128 -0
- package/dist/components/registry/niko-table/lib/constants.js +123 -0
- package/dist/components/registry/niko-table/lib/create-scroll-handler.d.ts +35 -0
- package/dist/components/registry/niko-table/lib/create-scroll-handler.js +63 -0
- package/dist/components/registry/niko-table/lib/data-table-features.d.ts +218 -0
- package/dist/components/registry/niko-table/lib/data-table-features.js +127 -0
- package/dist/components/registry/niko-table/lib/filter-functions.d.ts +47 -0
- package/dist/components/registry/niko-table/lib/filter-functions.js +309 -0
- package/dist/components/registry/niko-table/lib/filter-rows.d.ts +14 -0
- package/dist/components/registry/niko-table/lib/filter-rows.js +28 -0
- package/dist/components/registry/niko-table/lib/flex-columns.d.ts +48 -0
- package/dist/components/registry/niko-table/lib/flex-columns.js +65 -0
- package/dist/components/registry/niko-table/lib/format.d.ts +33 -0
- package/dist/components/registry/niko-table/lib/format.js +99 -0
- package/dist/components/registry/niko-table/lib/render-cell-content.d.ts +17 -0
- package/dist/components/registry/niko-table/lib/render-cell-content.js +65 -0
- package/dist/components/registry/niko-table/lib/row-click.d.ts +67 -0
- package/dist/components/registry/niko-table/lib/row-click.js +28 -0
- package/dist/components/registry/niko-table/lib/styles.d.ts +6 -0
- package/dist/components/registry/niko-table/lib/styles.js +24 -0
- package/dist/components/registry/niko-table/lib/use-header-min-widths.d.ts +17 -0
- package/dist/components/registry/niko-table/lib/use-header-min-widths.js +82 -0
- package/dist/components/registry/niko-table/types/index.d.ts +141 -0
- package/dist/components/registry/niko-table/types/index.js +2 -0
- package/dist/components/registry/niko-table/ui/table.d.ts +13 -0
- package/dist/components/registry/niko-table/ui/table.js +74 -0
- package/dist/components/registry/sidebar-07/app-sidebar.d.ts +18 -0
- package/dist/components/registry/sidebar-07/app-sidebar.js +26 -0
- package/dist/components/registry/sidebar-07/nav-main.d.ts +15 -0
- package/dist/components/registry/sidebar-07/nav-main.js +25 -0
- package/dist/components/registry/sidebar-07/nav-projects.d.ts +9 -0
- package/dist/components/registry/sidebar-07/nav-projects.js +43 -0
- package/dist/components/registry/sidebar-07/nav-user.d.ts +9 -0
- package/dist/components/registry/sidebar-07/nav-user.js +70 -0
- package/dist/components/registry/sidebar-07/team-switcher.d.ts +10 -0
- package/dist/components/registry/sidebar-07/team-switcher.js +70 -0
- package/dist/components/siyahi/delta.d.ts +10 -0
- package/dist/components/siyahi/delta.js +27 -0
- package/dist/components/siyahi/local-time.d.ts +7 -0
- package/dist/components/siyahi/local-time.js +22 -0
- package/dist/components/siyahi/price-chart.d.ts +12 -0
- package/dist/components/siyahi/price-chart.js +80 -0
- package/dist/components/siyahi/siyahi-provider.d.ts +12 -0
- package/dist/components/siyahi/siyahi-provider.js +31 -0
- package/dist/components/siyahi/treemap.d.ts +14 -0
- package/dist/components/siyahi/treemap.js +58 -0
- package/dist/components/ui/alert.d.ts +12 -0
- package/dist/components/ui/alert.js +43 -0
- package/dist/components/ui/avatar.d.ts +13 -0
- package/dist/components/ui/avatar.js +50 -0
- package/dist/components/ui/badge.d.ts +9 -0
- package/dist/components/ui/badge.js +29 -0
- package/dist/components/ui/breadcrumb.d.ts +12 -0
- package/dist/components/ui/breadcrumb.js +72 -0
- package/dist/components/ui/button.d.ts +10 -0
- package/dist/components/ui/button.js +44 -0
- package/dist/components/ui/calendar.d.ts +12 -0
- package/dist/components/ui/calendar.js +107 -0
- package/dist/components/ui/card.d.ts +13 -0
- package/dist/components/ui/card.js +56 -0
- package/dist/components/ui/chart.d.ts +46 -0
- package/dist/components/ui/chart.js +149 -0
- package/dist/components/ui/collapsible.d.ts +7 -0
- package/dist/components/ui/collapsible.js +24 -0
- package/dist/components/ui/command.d.ts +21 -0
- package/dist/components/ui/command.js +88 -0
- package/dist/components/ui/context-menu.d.ts +31 -0
- package/dist/components/ui/context-menu.js +132 -0
- package/dist/components/ui/dialog.d.ts +19 -0
- package/dist/components/ui/dialog.js +91 -0
- package/dist/components/ui/dropdown-menu.d.ts +31 -0
- package/dist/components/ui/dropdown-menu.js +136 -0
- package/dist/components/ui/input-group.d.ts +20 -0
- package/dist/components/ui/input-group.js +79 -0
- package/dist/components/ui/input.d.ts +5 -0
- package/dist/components/ui/input.js +15 -0
- package/dist/components/ui/popover.d.ts +11 -0
- package/dist/components/ui/popover.js +55 -0
- package/dist/components/ui/progress.d.ts +9 -0
- package/dist/components/ui/progress.js +43 -0
- package/dist/components/ui/scroll-area.d.ts +7 -0
- package/dist/components/ui/scroll-area.js +36 -0
- package/dist/components/ui/select.d.ts +17 -0
- package/dist/components/ui/select.js +97 -0
- package/dist/components/ui/separator.d.ts +5 -0
- package/dist/components/ui/separator.js +15 -0
- package/dist/components/ui/sheet.d.ts +16 -0
- package/dist/components/ui/sheet.js +89 -0
- package/dist/components/ui/sidebar.d.ts +65 -0
- package/dist/components/ui/sidebar.js +385 -0
- package/dist/components/ui/skeleton.d.ts +4 -0
- package/dist/components/ui/skeleton.js +12 -0
- package/dist/components/ui/slider.d.ts +5 -0
- package/dist/components/ui/slider.js +33 -0
- package/dist/components/ui/table.d.ts +12 -0
- package/dist/components/ui/table.js +66 -0
- package/dist/components/ui/tabs.d.ts +12 -0
- package/dist/components/ui/tabs.js +45 -0
- package/dist/components/ui/textarea.d.ts +5 -0
- package/dist/components/ui/textarea.js +13 -0
- package/dist/components/ui/toggle-group.d.ts +13 -0
- package/dist/components/ui/toggle-group.js +52 -0
- package/dist/components/ui/toggle.d.ts +10 -0
- package/dist/components/ui/toggle.js +36 -0
- package/dist/components/ui/tooltip.d.ts +8 -0
- package/dist/components/ui/tooltip.js +41 -0
- package/dist/hooks/use-mobile.d.ts +3 -0
- package/dist/hooks/use-mobile.js +18 -0
- package/dist/index.d.ts +73 -0
- package/dist/index.js +71 -0
- package/dist/lib/format.d.ts +24 -0
- package/dist/lib/format.js +58 -0
- package/dist/lib/locale.d.ts +12 -0
- package/dist/lib/locale.js +8 -0
- package/dist/lib/recharts.d.ts +2 -0
- package/dist/lib/recharts.js +1 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +1 -0
- package/package.json +78 -3
- package/registry.lock.json +413 -0
- package/report.css +129 -0
- package/styles/shadcn.css +643 -0
- package/styles/siyahi.css +189 -0
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
import { cn } from "../../../lib/utils.js";
|
|
2
|
+
import { Fragment, createContext, use, useMemo } from "react";
|
|
3
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { format } from "date-fns";
|
|
5
|
+
//#region src/components/registry/heatmap/weekday-heatmap.tsx
|
|
6
|
+
const colorStepCount = (levels, isNormalized) => Math.max(1, isNormalized ? levels : levels - 1);
|
|
7
|
+
const calculateLevel = (value, minValue, maxValue, levels, isNormalized) => {
|
|
8
|
+
const steps = colorStepCount(levels, isNormalized);
|
|
9
|
+
if (!Number.isFinite(value)) return isNormalized ? 1 : 0;
|
|
10
|
+
if (isNormalized) {
|
|
11
|
+
if (maxValue <= minValue) return 1;
|
|
12
|
+
const percentage = (value - minValue) / (maxValue - minValue);
|
|
13
|
+
return Math.max(1, Math.min(steps, Math.ceil(percentage * steps)));
|
|
14
|
+
}
|
|
15
|
+
if (value <= 0 || maxValue <= 0) return 0;
|
|
16
|
+
const percentage = value / maxValue;
|
|
17
|
+
return Math.max(1, Math.min(steps, Math.ceil(percentage * steps)));
|
|
18
|
+
};
|
|
19
|
+
const getLevelFill = (level, levels, isNormalized, highlighted = false, colors) => {
|
|
20
|
+
const emptyColor = colors?.empty ?? "var(--color-secondary)";
|
|
21
|
+
const scaleColor = colors?.scale ?? "var(--color-chart-1)";
|
|
22
|
+
if (level === 0) return emptyColor;
|
|
23
|
+
const steps = colorStepCount(levels, isNormalized);
|
|
24
|
+
const opacity = steps === 1 ? 100 : Math.round(20 + (level - 1) * 80 / (steps - 1));
|
|
25
|
+
return `color-mix(in oklch, ${scaleColor} ${highlighted ? Math.round(opacity * .6) : opacity}%, transparent)`;
|
|
26
|
+
};
|
|
27
|
+
const DEFAULT_HOUR_LABELS = Array.from({ length: 24 }, (_, i) => i.toString().padStart(2, "0"));
|
|
28
|
+
const TWELVE_HOUR_LABELS = Array.from({ length: 24 }, (_, i) => {
|
|
29
|
+
if (i === 0) return "AM";
|
|
30
|
+
if (i < 12) return String(i);
|
|
31
|
+
if (i === 12) return "PM";
|
|
32
|
+
return String(i - 12);
|
|
33
|
+
});
|
|
34
|
+
const HOURS = Array.from({ length: 24 }, (_, i) => i);
|
|
35
|
+
const DEFAULT_WEEKDAY_LABELS = [
|
|
36
|
+
"Sun",
|
|
37
|
+
"Mon",
|
|
38
|
+
"Tue",
|
|
39
|
+
"Wed",
|
|
40
|
+
"Thu",
|
|
41
|
+
"Fri",
|
|
42
|
+
"Sat"
|
|
43
|
+
];
|
|
44
|
+
const generateWeekdayLabels = (locale) => Array.from({ length: 7 }, (_, i) => {
|
|
45
|
+
const date = new Date(2e3, 0, 2 + i);
|
|
46
|
+
return format(date, "EEE", { locale });
|
|
47
|
+
});
|
|
48
|
+
const EMPTY_STYLE = {};
|
|
49
|
+
const LABEL_MARGIN = 8;
|
|
50
|
+
const WeekdayHeatmapContext = createContext(null);
|
|
51
|
+
const useWeekdayHeatmap = () => {
|
|
52
|
+
const context = use(WeekdayHeatmapContext);
|
|
53
|
+
if (!context) throw new Error("WeekdayHeatmap components must be used within a WeekdayHeatmap");
|
|
54
|
+
return context;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Weekday Heatmap
|
|
58
|
+
*
|
|
59
|
+
* A GitHub punch card style heatmap showing activity distribution by weekday (rows) and hour (columns).
|
|
60
|
+
* Renders a 7 × 24 grid with optional extra row (aggregated per hour) and extra column (aggregated per weekday).
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```tsx
|
|
64
|
+
* <WeekdayHeatmap data={data} weekStart={1} use12Hour>
|
|
65
|
+
* <WeekdayHeatmapBody>
|
|
66
|
+
* {({ activity }) => (
|
|
67
|
+
* <WeekdayHeatmapBlock activity={activity} />
|
|
68
|
+
* )}
|
|
69
|
+
* </WeekdayHeatmapBody>
|
|
70
|
+
* <WeekdayHeatmapFooter>
|
|
71
|
+
* <WeekdayHeatmapStat />
|
|
72
|
+
* <WeekdayHeatmapLegend />
|
|
73
|
+
* </WeekdayHeatmapFooter>
|
|
74
|
+
* </WeekdayHeatmap>
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @param data - Array of activities with weekday (0-6 for Sun-Sat), hour (0-23), and numeric value
|
|
78
|
+
* @param weekStart - First day of week (0=Sunday, 1=Monday). Default: 0
|
|
79
|
+
* @param use12Hour - Use 12-hour format for hour labels. Default: false
|
|
80
|
+
* @param blockSize - Block height in pixels. Default: 24
|
|
81
|
+
* @param blockAspectRatio - Block width/height ratio. Default: 1 (square)
|
|
82
|
+
* @param levels - Total number of legend cells (including empty when not normalized). Default: 5
|
|
83
|
+
* @param isNormalized - When true, uses min-max normalization across the dataset (suitable for signed values like temperature). When false (default), treats 0 as empty and scales from 0 to max.
|
|
84
|
+
* @param extraRow - Appends an aggregated row below the grid. `compute` receives all activities and must return 24 values (one per hour). Rendered through `renderExtraRow` on the body, or falls back to `children`.
|
|
85
|
+
* @param extraColumn - Appends an aggregated column to the right of the grid. `compute` receives all activities and must return 7 values indexed by weekday 0–6. Rendered through `renderExtraColumn` on the body, or falls back to `children`.
|
|
86
|
+
*/
|
|
87
|
+
const WeekdayHeatmap = ({ data, weekStart = 0, use12Hour = false, blockSize = 24, blockMargin = 4, blockRadius = 2, blockAspectRatio = 1, levels: levelsProp = 5, isNormalized = false, colors, locale, labels: labelsProp, fontSize = 14, emptyState, totalCount: totalCountProp, extraRow, extraColumn, style = EMPTY_STYLE, className, children, ...props }) => {
|
|
88
|
+
const levels = Math.max(1, levelsProp);
|
|
89
|
+
const dataWithLevels = useMemo(() => {
|
|
90
|
+
if (data.length === 0) return [];
|
|
91
|
+
const maxRegular = data.reduce((m, d) => Math.max(m, d.value), 1);
|
|
92
|
+
const minRegular = isNormalized ? data.reduce((m, d) => Math.min(m, d.value), Infinity) : 0;
|
|
93
|
+
return data.map((activity) => ({
|
|
94
|
+
...activity,
|
|
95
|
+
level: calculateLevel(activity.value, minRegular, maxRegular, levels, isNormalized)
|
|
96
|
+
}));
|
|
97
|
+
}, [
|
|
98
|
+
data,
|
|
99
|
+
levels,
|
|
100
|
+
isNormalized
|
|
101
|
+
]);
|
|
102
|
+
const resolvedExtraRow = useMemo(() => {
|
|
103
|
+
if (!extraRow) return null;
|
|
104
|
+
const values = extraRow.compute(data);
|
|
105
|
+
const maxVal = values.reduce((m, v) => Math.max(m, v), 1);
|
|
106
|
+
const minVal = isNormalized ? values.reduce((m, v) => Math.min(m, v), Infinity) : 0;
|
|
107
|
+
return {
|
|
108
|
+
label: extraRow.label,
|
|
109
|
+
values: values.map((value, hour) => ({
|
|
110
|
+
hour,
|
|
111
|
+
value,
|
|
112
|
+
level: calculateLevel(value, minVal, maxVal, levels, isNormalized)
|
|
113
|
+
}))
|
|
114
|
+
};
|
|
115
|
+
}, [
|
|
116
|
+
extraRow,
|
|
117
|
+
data,
|
|
118
|
+
levels,
|
|
119
|
+
isNormalized
|
|
120
|
+
]);
|
|
121
|
+
const resolvedExtraColumn = useMemo(() => {
|
|
122
|
+
if (!extraColumn) return null;
|
|
123
|
+
const values = extraColumn.compute(data);
|
|
124
|
+
const maxVal = values.reduce((m, v) => Math.max(m, v), 1);
|
|
125
|
+
const minVal = isNormalized ? values.reduce((m, v) => Math.min(m, v), Infinity) : 0;
|
|
126
|
+
return {
|
|
127
|
+
label: extraColumn.label,
|
|
128
|
+
values: values.map((value, weekday) => ({
|
|
129
|
+
weekday,
|
|
130
|
+
value,
|
|
131
|
+
level: calculateLevel(value, minVal, maxVal, levels, isNormalized)
|
|
132
|
+
}))
|
|
133
|
+
};
|
|
134
|
+
}, [
|
|
135
|
+
extraColumn,
|
|
136
|
+
data,
|
|
137
|
+
levels,
|
|
138
|
+
isNormalized
|
|
139
|
+
]);
|
|
140
|
+
const labels = useMemo(() => {
|
|
141
|
+
const weekdayLabels = locale ? generateWeekdayLabels(locale) : DEFAULT_WEEKDAY_LABELS;
|
|
142
|
+
return {
|
|
143
|
+
hours: use12Hour ? TWELVE_HOUR_LABELS : DEFAULT_HOUR_LABELS,
|
|
144
|
+
endHour: use12Hour ? "12" : "00",
|
|
145
|
+
weekdays: weekdayLabels,
|
|
146
|
+
cellLabel: "{{weekday}} {{hour}}: {{value}}",
|
|
147
|
+
heatmapLabel: "Activity heatmap by weekday and hour",
|
|
148
|
+
legendLabel: "Activity intensity legend",
|
|
149
|
+
legendLevelLabel: "{{level}} contributions",
|
|
150
|
+
...labelsProp
|
|
151
|
+
};
|
|
152
|
+
}, [
|
|
153
|
+
locale,
|
|
154
|
+
use12Hour,
|
|
155
|
+
labelsProp
|
|
156
|
+
]);
|
|
157
|
+
const labelWidth = fontSize * 3.5 + LABEL_MARGIN;
|
|
158
|
+
const totalCount = typeof totalCountProp === "number" ? totalCountProp : dataWithLevels.reduce((sum, a) => sum + a.value, 0);
|
|
159
|
+
const blockWidth = blockSize * blockAspectRatio;
|
|
160
|
+
const labelHeight = fontSize + LABEL_MARGIN;
|
|
161
|
+
const hasExtraColumn = resolvedExtraColumn !== null;
|
|
162
|
+
const hasExtraRow = resolvedExtraRow !== null;
|
|
163
|
+
const width = 24 * (blockWidth + blockMargin) + (hasExtraColumn ? blockSize / 2 + (blockWidth + blockMargin) * 2 : 0) - blockMargin + labelWidth;
|
|
164
|
+
const rowCount = hasExtraRow ? 8 : 7;
|
|
165
|
+
const extraRowGap = hasExtraRow ? blockSize + blockMargin : 0;
|
|
166
|
+
const height = rowCount * (blockSize + blockMargin) + extraRowGap - blockMargin + labelHeight;
|
|
167
|
+
const contextValue = useMemo(() => ({
|
|
168
|
+
data: dataWithLevels,
|
|
169
|
+
extraRow: resolvedExtraRow,
|
|
170
|
+
extraColumn: resolvedExtraColumn,
|
|
171
|
+
blockMargin,
|
|
172
|
+
blockRadius,
|
|
173
|
+
blockSize,
|
|
174
|
+
blockAspectRatio,
|
|
175
|
+
blockWidth,
|
|
176
|
+
fontSize,
|
|
177
|
+
labels,
|
|
178
|
+
labelWidth,
|
|
179
|
+
labelHeight,
|
|
180
|
+
levels,
|
|
181
|
+
isNormalized,
|
|
182
|
+
totalCount,
|
|
183
|
+
width,
|
|
184
|
+
height,
|
|
185
|
+
weekStart,
|
|
186
|
+
colors
|
|
187
|
+
}), [
|
|
188
|
+
dataWithLevels,
|
|
189
|
+
resolvedExtraRow,
|
|
190
|
+
resolvedExtraColumn,
|
|
191
|
+
blockMargin,
|
|
192
|
+
blockRadius,
|
|
193
|
+
blockSize,
|
|
194
|
+
blockAspectRatio,
|
|
195
|
+
blockWidth,
|
|
196
|
+
fontSize,
|
|
197
|
+
labels,
|
|
198
|
+
labelWidth,
|
|
199
|
+
labelHeight,
|
|
200
|
+
levels,
|
|
201
|
+
isNormalized,
|
|
202
|
+
totalCount,
|
|
203
|
+
width,
|
|
204
|
+
height,
|
|
205
|
+
weekStart,
|
|
206
|
+
colors
|
|
207
|
+
]);
|
|
208
|
+
if (data.length === 0) return emptyState ? emptyState : null;
|
|
209
|
+
return /* @__PURE__ */ jsx(WeekdayHeatmapContext, {
|
|
210
|
+
value: contextValue,
|
|
211
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
212
|
+
"data-slot": "weekday-heatmap",
|
|
213
|
+
className: cn("flex w-max max-w-full flex-col gap-2 p-4", className),
|
|
214
|
+
style: {
|
|
215
|
+
fontSize,
|
|
216
|
+
...style
|
|
217
|
+
},
|
|
218
|
+
...props,
|
|
219
|
+
children
|
|
220
|
+
})
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
const WeekdayHeatmapBlock = ({ ref, activity, extra, highlighted = false, onCellClick, onCellHover, onClick, onKeyDown, onMouseEnter, onMouseLeave, className, style: styleProp, ...props }) => {
|
|
224
|
+
const { blockSize, blockWidth, blockMargin, blockRadius, labelWidth, labelHeight, levels, isNormalized, weekStart, labels, colors } = useWeekdayHeatmap();
|
|
225
|
+
const level = Math.max(0, Math.min(colorStepCount(levels, isNormalized), activity.level));
|
|
226
|
+
const isExtraRow = extra === "row";
|
|
227
|
+
const isExtraColumn = extra === "column";
|
|
228
|
+
const rowIndex = isExtraRow ? 7 : (activity.weekday - weekStart + 7) % 7;
|
|
229
|
+
const extraRowGap = isExtraRow ? blockSize + blockMargin : 0;
|
|
230
|
+
const yPosition = labelHeight + (blockSize + blockMargin) * rowIndex + extraRowGap;
|
|
231
|
+
const extraColumnGap = isExtraColumn ? blockWidth + blockMargin : 0;
|
|
232
|
+
const xPosition = isExtraColumn ? labelWidth + 24 * (blockWidth + blockMargin) + blockSize / 2 + extraColumnGap : labelWidth + (blockWidth + blockMargin) * activity.hour;
|
|
233
|
+
const weekdayToken = isExtraRow ? "extra" : labels.weekdays?.[activity.weekday] ?? String(activity.weekday);
|
|
234
|
+
const hourToken = isExtraColumn ? "extra" : `${String(activity.hour).padStart(2, "0")}:00`;
|
|
235
|
+
const ariaLabel = (labels.cellLabel ?? "{{weekday}} {{hour}}: {{value}}").replace("{{weekday}}", weekdayToken).replace("{{hour}}", hourToken).replace("{{value}}", String(activity.value));
|
|
236
|
+
return /* @__PURE__ */ jsx("rect", {
|
|
237
|
+
ref,
|
|
238
|
+
"data-slot": "weekday-heatmap-block",
|
|
239
|
+
role: onCellClick ? "button" : "img",
|
|
240
|
+
tabIndex: onCellClick ? 0 : -1,
|
|
241
|
+
"aria-label": ariaLabel,
|
|
242
|
+
className: cn("motion-safe:transition-opacity motion-safe:hover:opacity-70", onCellClick && "cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", className),
|
|
243
|
+
"data-value": activity.value,
|
|
244
|
+
"data-weekday": isExtraRow ? "extra" : activity.weekday,
|
|
245
|
+
"data-hour": isExtraColumn ? "extra" : activity.hour,
|
|
246
|
+
"data-level": level,
|
|
247
|
+
"data-highlighted": highlighted || void 0,
|
|
248
|
+
height: blockSize,
|
|
249
|
+
rx: blockRadius,
|
|
250
|
+
ry: blockRadius,
|
|
251
|
+
width: blockWidth,
|
|
252
|
+
x: xPosition,
|
|
253
|
+
y: yPosition,
|
|
254
|
+
style: {
|
|
255
|
+
fill: getLevelFill(level, levels, isNormalized, highlighted, colors),
|
|
256
|
+
...styleProp
|
|
257
|
+
},
|
|
258
|
+
onClick: (event) => {
|
|
259
|
+
onCellClick?.(activity);
|
|
260
|
+
onClick?.(event);
|
|
261
|
+
},
|
|
262
|
+
onKeyDown: (event) => {
|
|
263
|
+
if (onCellClick && (event.key === "Enter" || event.key === " ")) {
|
|
264
|
+
event.preventDefault();
|
|
265
|
+
onCellClick(activity);
|
|
266
|
+
}
|
|
267
|
+
onKeyDown?.(event);
|
|
268
|
+
},
|
|
269
|
+
onMouseEnter: (event) => {
|
|
270
|
+
onCellHover?.(activity);
|
|
271
|
+
onMouseEnter?.(event);
|
|
272
|
+
},
|
|
273
|
+
onMouseLeave: (event) => {
|
|
274
|
+
onCellHover?.(null);
|
|
275
|
+
onMouseLeave?.(event);
|
|
276
|
+
},
|
|
277
|
+
...props
|
|
278
|
+
});
|
|
279
|
+
};
|
|
280
|
+
WeekdayHeatmapBlock.displayName = "WeekdayHeatmapBlock";
|
|
281
|
+
const WeekdayHeatmapBody = ({ hideHourLabels = false, hideWeekdayLabels = false, className, labelClassName, children, renderExtraRow, renderExtraColumn, ...props }) => {
|
|
282
|
+
const { data, extraRow, extraColumn, blockSize, blockWidth, blockMargin, labels, labelWidth, labelHeight, fontSize, weekStart } = useWeekdayHeatmap();
|
|
283
|
+
const hasExtraRow = extraRow !== null;
|
|
284
|
+
const hasExtraColumn = extraColumn !== null;
|
|
285
|
+
const activityMap = useMemo(() => {
|
|
286
|
+
const map = /* @__PURE__ */ new Map();
|
|
287
|
+
data.forEach((activity) => {
|
|
288
|
+
map.set(`${activity.weekday}-${activity.hour}`, activity);
|
|
289
|
+
});
|
|
290
|
+
return map;
|
|
291
|
+
}, [data]);
|
|
292
|
+
const extraColumnMap = useMemo(() => {
|
|
293
|
+
if (!extraColumn) return null;
|
|
294
|
+
const map = /* @__PURE__ */ new Map();
|
|
295
|
+
extraColumn.values.forEach((v) => {
|
|
296
|
+
map.set(v.weekday, v);
|
|
297
|
+
});
|
|
298
|
+
return map;
|
|
299
|
+
}, [extraColumn]);
|
|
300
|
+
const regularActivities = useMemo(() => {
|
|
301
|
+
const activities = [];
|
|
302
|
+
for (let di = 0; di < 7; di++) {
|
|
303
|
+
const weekday = (weekStart + di) % 7;
|
|
304
|
+
for (let hour = 0; hour < 24; hour++) activities.push({
|
|
305
|
+
activity: activityMap.get(`${weekday}-${hour}`) ?? {
|
|
306
|
+
weekday,
|
|
307
|
+
hour,
|
|
308
|
+
value: 0,
|
|
309
|
+
level: 0
|
|
310
|
+
},
|
|
311
|
+
weekdayIndex: di
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
return activities;
|
|
315
|
+
}, [activityMap, weekStart]);
|
|
316
|
+
const extraColumnActivities = useMemo(() => {
|
|
317
|
+
if (!extraColumnMap) return [];
|
|
318
|
+
return Array.from({ length: 7 }, (_, di) => {
|
|
319
|
+
const weekday = (weekStart + di) % 7;
|
|
320
|
+
const entry = extraColumnMap.get(weekday);
|
|
321
|
+
return entry ? {
|
|
322
|
+
activity: {
|
|
323
|
+
weekday,
|
|
324
|
+
hour: 0,
|
|
325
|
+
value: entry.value,
|
|
326
|
+
level: entry.level
|
|
327
|
+
},
|
|
328
|
+
weekdayIndex: di
|
|
329
|
+
} : null;
|
|
330
|
+
}).filter((a) => a !== null);
|
|
331
|
+
}, [extraColumnMap, weekStart]);
|
|
332
|
+
const extraRowActivities = useMemo(() => {
|
|
333
|
+
if (!extraRow) return [];
|
|
334
|
+
return extraRow.values.map(({ hour, value, level }) => ({
|
|
335
|
+
activity: {
|
|
336
|
+
weekday: 0,
|
|
337
|
+
hour,
|
|
338
|
+
value,
|
|
339
|
+
level
|
|
340
|
+
},
|
|
341
|
+
weekdayIndex: 7
|
|
342
|
+
}));
|
|
343
|
+
}, [extraRow]);
|
|
344
|
+
const rowCount = hasExtraRow ? 8 : 7;
|
|
345
|
+
const extraRowGap = hasExtraRow ? blockSize + blockMargin : 0;
|
|
346
|
+
const svgHeight = rowCount * (blockSize + blockMargin) + extraRowGap - blockMargin + labelHeight;
|
|
347
|
+
const extraColumnGap = hasExtraColumn ? blockWidth + blockMargin : 0;
|
|
348
|
+
const svgWidth = hasExtraColumn ? labelWidth + 24 * (blockWidth + blockMargin) + blockSize / 2 + (blockWidth + blockMargin) + extraColumnGap : labelWidth + 24 * (blockWidth + blockMargin) - blockMargin;
|
|
349
|
+
const orderedWeekdayIndices = Array.from({ length: 7 }, (_, i) => (weekStart + i) % 7);
|
|
350
|
+
return /* @__PURE__ */ jsx("div", {
|
|
351
|
+
"data-slot": "weekday-heatmap-body",
|
|
352
|
+
className: cn("max-w-full overflow-x-auto overflow-y-hidden", className),
|
|
353
|
+
...props,
|
|
354
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
355
|
+
role: "img",
|
|
356
|
+
"aria-label": labels.heatmapLabel ?? "Activity heatmap by weekday and hour",
|
|
357
|
+
className: "block overflow-visible rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
358
|
+
height: svgHeight + 40,
|
|
359
|
+
viewBox: `-20 -20 ${svgWidth + 40} ${svgHeight + 40}`,
|
|
360
|
+
width: svgWidth + 40,
|
|
361
|
+
children: [
|
|
362
|
+
!hideHourLabels && /* @__PURE__ */ jsxs("g", {
|
|
363
|
+
className: cn("fill-current font-mono", labelClassName),
|
|
364
|
+
children: [
|
|
365
|
+
HOURS.map((hour) => {
|
|
366
|
+
const label = labels.hours?.[hour] ?? "";
|
|
367
|
+
return /* @__PURE__ */ jsx("text", {
|
|
368
|
+
x: labelWidth + (blockWidth + blockMargin) * hour,
|
|
369
|
+
y: 0,
|
|
370
|
+
textAnchor: "middle",
|
|
371
|
+
dominantBaseline: "hanging",
|
|
372
|
+
style: { fontSize: `${fontSize * .75}px` },
|
|
373
|
+
children: label
|
|
374
|
+
}, `hour-${hour}`);
|
|
375
|
+
}),
|
|
376
|
+
labels.endHour != null && /* @__PURE__ */ jsx("text", {
|
|
377
|
+
x: labelWidth + (blockWidth + blockMargin) * 24,
|
|
378
|
+
y: 0,
|
|
379
|
+
textAnchor: "middle",
|
|
380
|
+
dominantBaseline: "hanging",
|
|
381
|
+
style: { fontSize: `${fontSize * .75}px` },
|
|
382
|
+
children: labels.endHour
|
|
383
|
+
}, "hour-end"),
|
|
384
|
+
hasExtraColumn && /* @__PURE__ */ jsx("text", {
|
|
385
|
+
x: labelWidth + 24 * (blockWidth + blockMargin) + blockSize / 2 + (blockWidth + blockMargin) + blockWidth / 2,
|
|
386
|
+
y: 0,
|
|
387
|
+
textAnchor: "middle",
|
|
388
|
+
dominantBaseline: "hanging",
|
|
389
|
+
style: { fontSize: `${fontSize * .75}px` },
|
|
390
|
+
children: extraColumn?.label
|
|
391
|
+
}, "extra-col-label")
|
|
392
|
+
]
|
|
393
|
+
}),
|
|
394
|
+
!hideWeekdayLabels && /* @__PURE__ */ jsxs("g", {
|
|
395
|
+
className: cn("fill-current font-mono", labelClassName),
|
|
396
|
+
children: [orderedWeekdayIndices.map((weekday, displayIndex) => {
|
|
397
|
+
const label = labels.weekdays?.[weekday] ?? "";
|
|
398
|
+
const yPosition = labelHeight + (blockSize + blockMargin) * displayIndex + blockSize / 2;
|
|
399
|
+
return /* @__PURE__ */ jsx("text", {
|
|
400
|
+
x: labelWidth - 8,
|
|
401
|
+
y: yPosition,
|
|
402
|
+
dominantBaseline: "middle",
|
|
403
|
+
textAnchor: "end",
|
|
404
|
+
style: { fontSize: `${fontSize * .75}px` },
|
|
405
|
+
children: label
|
|
406
|
+
}, `weekday-${weekday}`);
|
|
407
|
+
}), hasExtraRow && /* @__PURE__ */ jsx("text", {
|
|
408
|
+
x: labelWidth - 8,
|
|
409
|
+
y: labelHeight + (blockSize + blockMargin) * 7 + (blockSize + blockMargin) + blockSize / 2,
|
|
410
|
+
dominantBaseline: "middle",
|
|
411
|
+
textAnchor: "end",
|
|
412
|
+
style: { fontSize: `${fontSize * .75}px` },
|
|
413
|
+
children: extraRow?.label
|
|
414
|
+
}, "weekday-extra")]
|
|
415
|
+
}),
|
|
416
|
+
regularActivities.map(({ activity, weekdayIndex }) => /* @__PURE__ */ jsx(Fragment, { children: children({
|
|
417
|
+
activity,
|
|
418
|
+
weekdayIndex
|
|
419
|
+
}) }, `${activity.weekday}-${activity.hour}`)),
|
|
420
|
+
extraColumnActivities.map(({ activity, weekdayIndex }) => /* @__PURE__ */ jsx(Fragment, { children: (renderExtraColumn ?? children)({
|
|
421
|
+
activity,
|
|
422
|
+
weekdayIndex
|
|
423
|
+
}) }, `extra-column-${activity.weekday}`)),
|
|
424
|
+
extraRowActivities.map(({ activity, weekdayIndex }) => /* @__PURE__ */ jsx(Fragment, { children: (renderExtraRow ?? children)({
|
|
425
|
+
activity,
|
|
426
|
+
weekdayIndex
|
|
427
|
+
}) }, `extra-row-${activity.hour}`))
|
|
428
|
+
]
|
|
429
|
+
})
|
|
430
|
+
});
|
|
431
|
+
};
|
|
432
|
+
const WeekdayHeatmapFooter = ({ className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
433
|
+
"data-slot": "weekday-heatmap-footer",
|
|
434
|
+
className: cn("flex flex-wrap gap-1 whitespace-nowrap sm:gap-x-4", className),
|
|
435
|
+
...props
|
|
436
|
+
});
|
|
437
|
+
const WeekdayHeatmapStat = ({ compute, label, className, children, ...props }) => {
|
|
438
|
+
const { data, totalCount, labels } = useWeekdayHeatmap();
|
|
439
|
+
const value = compute ? compute(data) : totalCount;
|
|
440
|
+
if (children) return /* @__PURE__ */ jsx(Fragment$1, { children: children({
|
|
441
|
+
value,
|
|
442
|
+
data
|
|
443
|
+
}) });
|
|
444
|
+
const template = label ?? labels.stat ?? "{{value}} contributions";
|
|
445
|
+
return /* @__PURE__ */ jsx("div", {
|
|
446
|
+
"data-slot": "weekday-heatmap-stat",
|
|
447
|
+
className: cn("text-muted-foreground tabular-nums", className),
|
|
448
|
+
...props,
|
|
449
|
+
children: template.replace("{{value}}", String(value))
|
|
450
|
+
});
|
|
451
|
+
};
|
|
452
|
+
const WeekdayHeatmapLegend = ({ labels: labelsProp, className, children, ...props }) => {
|
|
453
|
+
const { levels, isNormalized, blockSize, blockWidth, blockRadius, colors, labels } = useWeekdayHeatmap();
|
|
454
|
+
const lessLabel = labelsProp?.less ?? "Less";
|
|
455
|
+
const moreLabel = labelsProp?.more ?? "More";
|
|
456
|
+
const legendLevels = Array.from({ length: levels }, (_, i) => isNormalized ? i + 1 : i);
|
|
457
|
+
return /* @__PURE__ */ jsxs("fieldset", {
|
|
458
|
+
"data-slot": "weekday-heatmap-legend",
|
|
459
|
+
"aria-label": labels.legendLabel ?? "Activity intensity legend",
|
|
460
|
+
className: cn("ml-auto flex items-center gap-1 text-muted-foreground", className),
|
|
461
|
+
...props,
|
|
462
|
+
children: [
|
|
463
|
+
/* @__PURE__ */ jsx("span", {
|
|
464
|
+
className: "mr-1 font-medium text-xs",
|
|
465
|
+
children: lessLabel
|
|
466
|
+
}),
|
|
467
|
+
legendLevels.map((level) => children ? /* @__PURE__ */ jsx(Fragment, { children: children({ level }) }, `legend-level-${level}`) : /* @__PURE__ */ jsx("svg", {
|
|
468
|
+
role: "img",
|
|
469
|
+
"aria-label": (labels.legendLevelLabel ?? "{{level}} contributions").replace("{{level}}", String(level)),
|
|
470
|
+
height: blockSize,
|
|
471
|
+
width: blockWidth,
|
|
472
|
+
children: /* @__PURE__ */ jsx("rect", {
|
|
473
|
+
"data-level": level,
|
|
474
|
+
height: blockSize,
|
|
475
|
+
rx: blockRadius,
|
|
476
|
+
ry: blockRadius,
|
|
477
|
+
width: blockWidth,
|
|
478
|
+
style: { fill: getLevelFill(level, levels, isNormalized, false, colors) }
|
|
479
|
+
})
|
|
480
|
+
}, `legend-level-${level}`)),
|
|
481
|
+
/* @__PURE__ */ jsx("span", {
|
|
482
|
+
className: "ml-1 font-medium text-xs",
|
|
483
|
+
children: moreLabel
|
|
484
|
+
})
|
|
485
|
+
]
|
|
486
|
+
});
|
|
487
|
+
};
|
|
488
|
+
//#endregion
|
|
489
|
+
export { WeekdayHeatmap, WeekdayHeatmapBlock, WeekdayHeatmapBody, WeekdayHeatmapFooter, WeekdayHeatmapLegend, WeekdayHeatmapStat };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { TableColumnActions } from "../filters/table-column-actions.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { RowData } from "@tanstack/react-table";
|
|
4
|
+
//#region src/components/registry/niko-table/components/data-table-column-actions.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Composable container for column actions.
|
|
7
|
+
*
|
|
8
|
+
* Uses column context to automatically detect active states (pinned, sorted, etc.).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <DataTableColumnActions>
|
|
13
|
+
* <DataTableColumnSortOptions />
|
|
14
|
+
* <DataTableColumnPinOptions />
|
|
15
|
+
* <DataTableColumnHideOptions />
|
|
16
|
+
* </DataTableColumnActions>
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function DataTableColumnActions<TData extends RowData, TValue>(props: Omit<React.ComponentProps<typeof TableColumnActions>, "isActive"> & {
|
|
20
|
+
/** Override to manually set active state */
|
|
21
|
+
isActive?: boolean;
|
|
22
|
+
}): React.JSX.Element;
|
|
23
|
+
export declare namespace DataTableColumnActions {
|
|
24
|
+
var displayName: string;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { TableColumnActions } from "../filters/table-column-actions.js";
|
|
3
|
+
import { useColumnHeaderContext } from "./data-table-column-header.js";
|
|
4
|
+
import "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/registry/niko-table/components/data-table-column-actions.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Composable container for column actions.
|
|
9
|
+
*
|
|
10
|
+
* Uses column context to automatically detect active states (pinned, sorted, etc.).
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <DataTableColumnActions>
|
|
15
|
+
* <DataTableColumnSortOptions />
|
|
16
|
+
* <DataTableColumnPinOptions />
|
|
17
|
+
* <DataTableColumnHideOptions />
|
|
18
|
+
* </DataTableColumnActions>
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
function DataTableColumnActions(props) {
|
|
22
|
+
const context = useColumnHeaderContext(false);
|
|
23
|
+
const autoIsActive = context?.column ? !!(context.column.getIsSorted() || context.column.getIsPinned() || context.column.getIsFiltered()) : false;
|
|
24
|
+
const isActive = props.isActive ?? autoIsActive;
|
|
25
|
+
return /* @__PURE__ */ jsx(TableColumnActions, {
|
|
26
|
+
...props,
|
|
27
|
+
isActive
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
DataTableColumnActions.displayName = "DataTableColumnActions";
|
|
31
|
+
//#endregion
|
|
32
|
+
export { DataTableColumnActions };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
//#region src/components/registry/niko-table/components/data-table-column-filter.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Wrapper for groups of column filters.
|
|
5
|
+
*/
|
|
6
|
+
export declare function DataTableColumnFilter({ children, className }: {
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
}): React.JSX.Element | null;
|
|
10
|
+
export declare namespace DataTableColumnFilter {
|
|
11
|
+
var displayName: string;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { cn } from "../../../../lib/utils.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/registry/niko-table/components/data-table-column-filter.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Wrapper for groups of column filters.
|
|
7
|
+
*/
|
|
8
|
+
function DataTableColumnFilter({ children, className }) {
|
|
9
|
+
if (children) return /* @__PURE__ */ jsx("div", {
|
|
10
|
+
className: cn("flex items-center", className),
|
|
11
|
+
children
|
|
12
|
+
});
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
DataTableColumnFilter.displayName = "DataTableColumnFilter";
|
|
16
|
+
//#endregion
|
|
17
|
+
export { DataTableColumnFilter };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { DataTableColumn } from "../types/index.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { RowData } from "@tanstack/react-table";
|
|
4
|
+
//#region src/components/registry/niko-table/components/data-table-column-header.d.ts
|
|
5
|
+
interface TableColumnHeaderContextValue<TData extends RowData, TValue> {
|
|
6
|
+
column: DataTableColumn<TData, TValue>;
|
|
7
|
+
}
|
|
8
|
+
export declare function useColumnHeaderContext<TData extends RowData, TValue>(required: true): TableColumnHeaderContextValue<TData, TValue>;
|
|
9
|
+
export declare function useColumnHeaderContext<TData extends RowData, TValue>(required: false): TableColumnHeaderContextValue<TData, TValue> | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Provider for column header context.
|
|
12
|
+
* Used internally by DataTableHeader to provide context to composable header components.
|
|
13
|
+
*/
|
|
14
|
+
export declare function DataTableColumnHeaderRoot<TData extends RowData, TValue>({ column, children }: {
|
|
15
|
+
column: DataTableColumn<TData, TValue>;
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
}): React.JSX.Element;
|
|
18
|
+
export declare namespace DataTableColumnHeaderRoot {
|
|
19
|
+
var displayName: string;
|
|
20
|
+
}
|
|
21
|
+
export type DataTableColumnHeaderProps = React.HTMLAttributes<HTMLDivElement>;
|
|
22
|
+
/**
|
|
23
|
+
* Composable Column Header container.
|
|
24
|
+
*/
|
|
25
|
+
export declare function DataTableColumnHeader({ className, children, ...props }: DataTableColumnHeaderProps): React.JSX.Element;
|
|
26
|
+
export declare namespace DataTableColumnHeader {
|
|
27
|
+
var displayName: string;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { cn } from "../../../../lib/utils.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/registry/niko-table/components/data-table-column-header.tsx
|
|
5
|
+
const TableColumnHeaderContext = React.createContext(void 0);
|
|
6
|
+
function useColumnHeaderContext(required = true) {
|
|
7
|
+
const context = React.useContext(TableColumnHeaderContext);
|
|
8
|
+
if (required && !context) throw new Error("useColumnHeaderContext must be used within DataTableColumnHeaderRoot");
|
|
9
|
+
return context;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Provider for column header context.
|
|
13
|
+
* Used internally by DataTableHeader to provide context to composable header components.
|
|
14
|
+
*/
|
|
15
|
+
function DataTableColumnHeaderRoot({ column, children }) {
|
|
16
|
+
const contextValue = React.useMemo(() => ({ column }), [column]);
|
|
17
|
+
return /* @__PURE__ */ jsx(TableColumnHeaderContext.Provider, {
|
|
18
|
+
value: contextValue,
|
|
19
|
+
children
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Composable Column Header container.
|
|
24
|
+
*/
|
|
25
|
+
function DataTableColumnHeader({ className, children, ...props }) {
|
|
26
|
+
return /* @__PURE__ */ jsx("div", {
|
|
27
|
+
className: cn("group flex w-full min-w-0 items-center justify-between gap-1", className),
|
|
28
|
+
...props,
|
|
29
|
+
children
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
DataTableColumnHeaderRoot.displayName = "DataTableColumnHeaderRoot";
|
|
33
|
+
DataTableColumnHeader.displayName = "DataTableColumnHeader";
|
|
34
|
+
//#endregion
|
|
35
|
+
export { DataTableColumnHeader, DataTableColumnHeaderRoot, useColumnHeaderContext };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TableColumnSortMenu, TableColumnSortOptions } from "../filters/table-column-sort.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { RowData } from "@tanstack/react-table";
|
|
4
|
+
//#region src/components/registry/niko-table/components/data-table-column-sort.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Sorting options for column header menu using context.
|
|
7
|
+
*/
|
|
8
|
+
export declare function DataTableColumnSortOptions<TData extends RowData, TValue>(props: Omit<React.ComponentProps<typeof TableColumnSortOptions>, "column" | "table">): React.JSX.Element;
|
|
9
|
+
export declare namespace DataTableColumnSortOptions {
|
|
10
|
+
var displayName: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Sorting menu for column header using context.
|
|
14
|
+
*
|
|
15
|
+
* Standalone button variant for inline use outside dropdown menus.
|
|
16
|
+
*/
|
|
17
|
+
export declare function DataTableColumnSortMenu<TData extends RowData, TValue>(props: Omit<React.ComponentProps<typeof TableColumnSortMenu>, "column" | "table">): React.JSX.Element;
|
|
18
|
+
export declare namespace DataTableColumnSortMenu {
|
|
19
|
+
var displayName: string;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|