@nadicodeai/ui 8.1.0 → 8.2.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 (65) hide show
  1. package/LICENSES/SHADCN-HEATMAP-MIT.txt +21 -0
  2. package/NOTICE +9 -0
  3. package/dist/components/activity-calendar.d.ts +27 -0
  4. package/dist/components/activity-calendar.d.ts.map +1 -0
  5. package/dist/components/activity-calendar.js +56 -0
  6. package/dist/components/agent-orb.d.ts +22 -0
  7. package/dist/components/agent-orb.d.ts.map +1 -0
  8. package/dist/components/agent-orb.js +28 -0
  9. package/dist/components/chart-area-stacked.d.ts +1 -1
  10. package/dist/components/chart-area-stacked.d.ts.map +1 -1
  11. package/dist/components/chart-area-stacked.js +2 -2
  12. package/dist/components/chart-bar-multiple.d.ts +1 -1
  13. package/dist/components/chart-bar-multiple.d.ts.map +1 -1
  14. package/dist/components/chart-bar-multiple.js +2 -2
  15. package/dist/components/chart-bar-stacked.d.ts +1 -1
  16. package/dist/components/chart-bar-stacked.d.ts.map +1 -1
  17. package/dist/components/chart-bar-stacked.js +2 -2
  18. package/dist/components/chart-card.d.ts +24 -3
  19. package/dist/components/chart-card.d.ts.map +1 -1
  20. package/dist/components/chart-card.js +8 -3
  21. package/dist/components/heatmap/calendar-heatmap.d.ts +138 -0
  22. package/dist/components/heatmap/calendar-heatmap.d.ts.map +1 -0
  23. package/dist/components/heatmap/calendar-heatmap.js +449 -0
  24. package/dist/components/model-identity.d.ts +8 -0
  25. package/dist/components/model-identity.d.ts.map +1 -0
  26. package/dist/components/model-identity.js +8 -0
  27. package/dist/components/object-workspace.d.ts +36 -0
  28. package/dist/components/object-workspace.d.ts.map +1 -0
  29. package/dist/components/object-workspace.js +19 -0
  30. package/dist/components/progress.d.ts +2 -1
  31. package/dist/components/progress.d.ts.map +1 -1
  32. package/dist/components/progress.js +5 -4
  33. package/dist/components/settings-facts.d.ts +2 -1
  34. package/dist/components/settings-facts.d.ts.map +1 -1
  35. package/dist/components/settings-facts.js +6 -3
  36. package/dist/components/settings-section.d.ts +3 -1
  37. package/dist/components/settings-section.d.ts.map +1 -1
  38. package/dist/components/settings-section.js +2 -2
  39. package/dist/components/table-value.d.ts +7 -0
  40. package/dist/components/table-value.d.ts.map +1 -0
  41. package/dist/components/table-value.js +6 -0
  42. package/dist/components/table.d.ts +2 -1
  43. package/dist/components/table.d.ts.map +1 -1
  44. package/dist/components/table.js +4 -1
  45. package/dist/index.d.ts +5 -0
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +5 -0
  48. package/dist/internal/agent-orb-motion.d.ts +14 -0
  49. package/dist/internal/agent-orb-motion.d.ts.map +1 -0
  50. package/dist/internal/agent-orb-motion.js +120 -0
  51. package/dist/internal/agent-orb.d.ts +19 -0
  52. package/dist/internal/agent-orb.d.ts.map +1 -0
  53. package/dist/internal/agent-orb.js +151 -0
  54. package/dist/internal/object-identity-support.d.ts +6 -0
  55. package/dist/internal/object-identity-support.d.ts.map +1 -0
  56. package/dist/internal/object-identity-support.js +10 -0
  57. package/dist/lib/format-token-count.d.ts +4 -0
  58. package/dist/lib/format-token-count.d.ts.map +1 -0
  59. package/dist/lib/format-token-count.js +31 -0
  60. package/docs/activity.md +3 -1
  61. package/docs/agent-orb.md +82 -0
  62. package/docs/agent-visual.md +5 -0
  63. package/docs/contract.md +46 -3
  64. package/docs/model-identity.md +18 -0
  65. package/package.json +7 -2
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ChingRu <hello@chingru.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/NOTICE CHANGED
@@ -24,3 +24,12 @@ The marks name the maker of a model the product reports, and nothing else. They
24
24
  are generated by scripts/build-brand-icons.mjs into src/components/brand-icons/,
25
25
  so a hand edit there is lost; the allow-list in that script names the marks the
26
26
  package ships.
27
+
28
+ @nadicodeai/ui includes a modified CalendarHeatmap from shadcn-heatmap.
29
+
30
+ shadcn-heatmap
31
+ Copyright (c) 2026 ChingRu <hello@chingru.com>
32
+
33
+ Licensed under the MIT License; the full text ships as
34
+ LICENSES/SHADCN-HEATMAP-MIT.txt. The source is adapted to distinguish missing
35
+ coverage from a measured zero and is composed by the shared ActivityCalendar.
@@ -0,0 +1,27 @@
1
+ import type { HTMLAttributes } from "react";
2
+ import { type Activity } from "./heatmap/calendar-heatmap.js";
3
+ type ActivityCalendarDatum = {
4
+ date: string;
5
+ value: number;
6
+ };
7
+ type ActivityCalendarLabels = {
8
+ ariaLabel: string;
9
+ unavailable: string;
10
+ legend: string;
11
+ legendLevel: string;
12
+ less: string;
13
+ more: string;
14
+ };
15
+ type ActivityCalendarProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> & {
16
+ data: readonly ActivityCalendarDatum[];
17
+ from: string;
18
+ to: string;
19
+ locale?: string;
20
+ labels: ActivityCalendarLabels;
21
+ valueFormatter?: (value: number) => string;
22
+ };
23
+ declare function activityCalendarData(data: readonly ActivityCalendarDatum[], from: string, to: string): Activity[];
24
+ declare function ActivityCalendar({ data, from, to, locale, labels, valueFormatter, className, ...props }: ActivityCalendarProps): import("react").JSX.Element;
25
+ export { ActivityCalendar, activityCalendarData };
26
+ export type { ActivityCalendarDatum, ActivityCalendarLabels, ActivityCalendarProps };
27
+ //# sourceMappingURL=activity-calendar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activity-calendar.d.ts","sourceRoot":"","sources":["../../src/components/activity-calendar.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAML,KAAK,QAAQ,EACd,MAAM,uCAAuC,CAAC;AAG/C,KAAK,qBAAqB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D,KAAK,sBAAsB,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,KAAK,qBAAqB,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC,GAAG;IAC9E,IAAI,EAAE,SAAS,qBAAqB,EAAE,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,sBAAsB,CAAC;IAC/B,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CAC5C,CAAC;AAwBF,iBAAS,oBAAoB,CAC3B,IAAI,EAAE,SAAS,qBAAqB,EAAE,EACtC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT,QAAQ,EAAE,CAKZ;AAeD,iBAAS,gBAAgB,CAAC,EACxB,IAAI,EACJ,IAAI,EACJ,EAAE,EACF,MAAM,EACN,MAAM,EACN,cAAuE,EACvE,SAAS,EACT,GAAG,KAAK,EACT,EAAE,qBAAqB,+BAwCvB;AAED,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,CAAC;AAClD,YAAY,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,CAAC"}
@@ -0,0 +1,56 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { CalendarHeatmap, CalendarHeatmapBlock, CalendarHeatmapBody, CalendarHeatmapFooter, CalendarHeatmapLegend, } from "./heatmap/calendar-heatmap.js";
4
+ import { cn } from "../lib/utils.js";
5
+ const ISO_DAY = /^\d{4}-\d{2}-\d{2}$/;
6
+ function utcDay(day) {
7
+ if (!ISO_DAY.test(day))
8
+ throw new RangeError(`${day} is not an ISO day`);
9
+ const date = new Date(`${day}T00:00:00.000Z`);
10
+ if (Number.isNaN(date.getTime()) || date.toISOString().slice(0, 10) !== day) {
11
+ throw new RangeError(`${day} is not an ISO day`);
12
+ }
13
+ return date;
14
+ }
15
+ function activityDays(from, to) {
16
+ const start = utcDay(from).getTime();
17
+ const end = utcDay(to).getTime();
18
+ if (end < start)
19
+ throw new RangeError("Activity range ends before it starts");
20
+ const days = Math.floor((end - start) / 86_400_000) + 1;
21
+ return Array.from({ length: days }, (_, index) => new Date(start + index * 86_400_000).toISOString().slice(0, 10));
22
+ }
23
+ function activityCalendarData(data, from, to) {
24
+ const values = new Map(data.map((entry) => [entry.date, Number.isFinite(entry.value) ? entry.value : null]));
25
+ return activityDays(from, to).map((date) => ({ date, value: values.get(date) ?? null }));
26
+ }
27
+ function localizedCalendarLabels(locale) {
28
+ const months = new Intl.DateTimeFormat(locale, { month: "short", timeZone: "UTC" });
29
+ const weekdays = new Intl.DateTimeFormat(locale, { weekday: "short", timeZone: "UTC" });
30
+ return {
31
+ months: Array.from({ length: 12 }, (_, month) => months.format(new Date(Date.UTC(2024, month, 1)))),
32
+ weekdays: Array.from({ length: 7 }, (_, day) => weekdays.format(new Date(Date.UTC(2024, 0, 7 + day)))),
33
+ };
34
+ }
35
+ function ActivityCalendar({ data, from, to, locale, labels, valueFormatter = (value) => new Intl.NumberFormat(locale).format(value), className, ...props }) {
36
+ const calendarData = activityCalendarData(data, from, to);
37
+ const dateFormatter = new Intl.DateTimeFormat(locale, {
38
+ dateStyle: "medium",
39
+ timeZone: "UTC",
40
+ });
41
+ const localizedLabels = localizedCalendarLabels(locale);
42
+ return (_jsxs(CalendarHeatmap, { data: calendarData, weekStart: 1, continuousMonths: true, singleRow: true, className: cn("w-full p-0", className), labels: {
43
+ ...localizedLabels,
44
+ unavailable: labels.unavailable,
45
+ heatmapLabel: labels.ariaLabel,
46
+ legendLabel: labels.legend,
47
+ legendLevelLabel: labels.legendLevel,
48
+ cellLabel: (activity) => {
49
+ const date = dateFormatter.format(utcDay(activity.date));
50
+ return activity.value === null
51
+ ? `${date}: ${labels.unavailable}`
52
+ : `${date}: ${valueFormatter(activity.value)}`;
53
+ },
54
+ }, ...props, children: [_jsx(CalendarHeatmapBody, { hideYearLabels: true, children: ({ activity, dayIndex, weekIndex }) => (_jsx(CalendarHeatmapBlock, { activity: activity, dayIndex: dayIndex, weekIndex: weekIndex })) }), _jsx(CalendarHeatmapFooter, { children: _jsx(CalendarHeatmapLegend, { labels: { less: labels.less, more: labels.more } }) })] }));
55
+ }
56
+ export { ActivityCalendar, activityCalendarData };
@@ -0,0 +1,22 @@
1
+ import { type CSSProperties } from "react";
2
+ import { type AgentOrbForm, type AgentOrbSize } from "../internal/agent-orb.js";
3
+ export type { AgentOrbForm, AgentOrbSize } from "../internal/agent-orb.js";
4
+ import type { AgentOrbState } from "../internal/agent-orb-motion.js";
5
+ export type { AgentOrbState } from "../internal/agent-orb-motion.js";
6
+ export type AgentOrbProps = {
7
+ form: AgentOrbForm;
8
+ color?: CSSProperties["color"];
9
+ size?: AgentOrbSize;
10
+ paused?: boolean;
11
+ state?: AgentOrbState;
12
+ motionKey?: number;
13
+ className?: string;
14
+ } & ({
15
+ decorative: true;
16
+ label?: never;
17
+ } | {
18
+ decorative?: false;
19
+ label: string;
20
+ });
21
+ export declare function AgentOrb({ form, color, size, paused, state, motionKey, decorative, label, className, }: AgentOrbProps): import("react").JSX.Element;
22
+ //# sourceMappingURL=agent-orb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-orb.d.ts","sourceRoot":"","sources":["../../src/components/agent-orb.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAqB,MAAM,OAAO,CAAC;AAE9D,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAiB,MAAM,uBAAuB,CAAC;AAG5F,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAExE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,YAAY,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC/B,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,CAAC;IAAE,UAAU,EAAE,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,GAAG;IAAE,UAAU,CAAC,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAElF,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,KAAK,EACL,IAAS,EACT,MAAc,EACd,KAAc,EACd,SAAa,EACb,UAAkB,EAClB,KAAK,EACL,SAAS,GACV,EAAE,aAAa,+BAyCf"}
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useEffect, useRef } from "react";
4
+ import { mountAgentOrb } from "../internal/agent-orb.js";
5
+ import { cn } from "../lib/utils.js";
6
+ export function AgentOrb({ form, color, size = 32, paused = false, state = "idle", motionKey = 0, decorative = false, label, className, }) {
7
+ const canvas = useRef(null);
8
+ const renderer = useRef(null);
9
+ const pause = useRef(paused);
10
+ useEffect(() => {
11
+ if (!canvas.current)
12
+ return;
13
+ const mounted = mountAgentOrb(canvas.current, form, size, pause.current);
14
+ renderer.current = mounted;
15
+ return () => {
16
+ mounted.destroy();
17
+ renderer.current = null;
18
+ };
19
+ }, [form, size]);
20
+ useEffect(() => {
21
+ pause.current = paused;
22
+ renderer.current?.setPaused(paused);
23
+ }, [paused, form, size]);
24
+ useEffect(() => {
25
+ renderer.current?.setState(state);
26
+ }, [state, motionKey, form, size]);
27
+ return (_jsx("canvas", { ref: canvas, "data-slot": "agent-orb", "data-form": form, "data-state": state, role: decorative ? undefined : "img", "aria-hidden": decorative || undefined, "aria-label": decorative ? undefined : label, className: cn("inline-block shrink-0 align-middle", className), width: size, height: size, style: { color, width: size, height: size }, children: decorative ? null : label }));
28
+ }
@@ -1,4 +1,4 @@
1
1
  import { type ChartCardProps } from "./chart-card.js";
2
- declare function ChartAreaStacked({ title, description, action, footer, headingLevel, data, xKey, series, entityColorMap, valueFormatter, axisFormatter, otherLabel, emptyState, size, className, }: ChartCardProps): import("react").JSX.Element;
2
+ declare function ChartAreaStacked({ title, description, action, summary, aside, footer, headingLevel, data, xKey, series, entityColorMap, valueFormatter, axisFormatter, otherLabel, emptyState, size, className, }: ChartCardProps): import("react").JSX.Element;
3
3
  export { ChartAreaStacked };
4
4
  //# sourceMappingURL=chart-area-stacked.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chart-area-stacked.d.ts","sourceRoot":"","sources":["../../src/components/chart-area-stacked.tsx"],"names":[],"mappings":"AAcA,OAAO,EAOL,KAAK,cAAc,EACpB,MAAM,yBAAyB,CAAC;AAGjC,iBAAS,gBAAgB,CAAC,EACxB,KAAK,EACL,WAAW,EACX,MAAM,EACN,MAAM,EACN,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,cAAc,EACd,cAAsC,EACtC,aAAa,EACb,UAAoB,EACpB,UAAU,EACV,IAAgB,EAChB,SAAS,GACV,EAAE,cAAc,+BAwEhB;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"chart-area-stacked.d.ts","sourceRoot":"","sources":["../../src/components/chart-area-stacked.tsx"],"names":[],"mappings":"AAcA,OAAO,EAOL,KAAK,cAAc,EACpB,MAAM,yBAAyB,CAAC;AAGjC,iBAAS,gBAAgB,CAAC,EACxB,KAAK,EACL,WAAW,EACX,MAAM,EACN,OAAO,EACP,KAAK,EACL,MAAM,EACN,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,cAAc,EACd,cAAsC,EACtC,aAAa,EACb,UAAoB,EACpB,UAAU,EACV,IAAgB,EAChB,SAAS,GACV,EAAE,cAAc,+BA0EhB;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -7,11 +7,11 @@ import { ChartContainer, ChartLegend, ChartLegendContent, ChartTooltip, ChartToo
7
7
  import { CHART_Y_AXIS_TICK_COUNT, niceAxisTicks, stackedAxisMax } from "./chart-axis.js";
8
8
  import { CHART_LEGEND_CLASS, ChartCard, chartPlotClassName, chartSeriesConfig, defaultValueFormatter, foldOtherSeries, } from "./chart-card.js";
9
9
  import { entityColor } from "./chart-entity-colors.js";
10
- function ChartAreaStacked({ title, description, action, footer, headingLevel, data, xKey, series, entityColorMap, valueFormatter = defaultValueFormatter, axisFormatter, otherLabel = "Other", emptyState, size = "default", className, }) {
10
+ function ChartAreaStacked({ title, description, action, summary, aside, footer, headingLevel, data, xKey, series, entityColorMap, valueFormatter = defaultValueFormatter, axisFormatter, otherLabel = "Other", emptyState, size = "default", className, }) {
11
11
  const folded = foldOtherSeries(series, data, entityColorMap, otherLabel);
12
12
  const chartConfig = chartSeriesConfig(folded.series, entityColorMap);
13
13
  const domainMax = stackedAxisMax(folded.data, folded.series.map((entry) => entry.id));
14
- return (_jsx(ChartCard, { title: title, description: description, action: action, footer: footer, ...(headingLevel ? { headingLevel } : {}), className: className, children: (titleId) => emptyState && data.length === 0 ? (emptyState) : (_jsx(ChartContainer, { config: chartConfig, className: chartPlotClassName(size), children: _jsxs(AreaChart, { accessibilityLayer: true, "aria-labelledby": titleId, data: folded.data, margin: {
14
+ return (_jsx(ChartCard, { title: title, description: description, action: action, summary: summary, aside: aside, footer: footer, ...(headingLevel ? { headingLevel } : {}), className: className, children: (titleId) => emptyState && data.length === 0 ? (emptyState) : (_jsx(ChartContainer, { config: chartConfig, className: chartPlotClassName(size), children: _jsxs(AreaChart, { accessibilityLayer: true, "aria-labelledby": titleId, data: folded.data, margin: {
15
15
  left: 12,
16
16
  right: 12,
17
17
  }, children: [_jsx(CartesianGrid, { strokeDasharray: "3 3" }), _jsx(XAxis, { dataKey: xKey, tickLine: false, axisLine: false, tickMargin: 8 }), _jsx(YAxis, { width: "auto", tickLine: false, axisLine: false, tickMargin: 8, tickCount: CHART_Y_AXIS_TICK_COUNT, ...(domainMax === undefined
@@ -4,6 +4,6 @@ import { type ChartCardProps } from "./chart-card.js";
4
4
  * one unit. A rate over those measures (a margin percentage) is a KPI card, not
5
5
  * a second axis on this plot.
6
6
  */
7
- declare function ChartBarMultiple({ title, description, action, footer, headingLevel, data, xKey, series, entityColorMap, valueFormatter, axisFormatter, otherLabel, emptyState, size, className, }: ChartCardProps): import("react").JSX.Element;
7
+ declare function ChartBarMultiple({ title, description, action, summary, aside, footer, headingLevel, data, xKey, series, entityColorMap, valueFormatter, axisFormatter, otherLabel, emptyState, size, className, }: ChartCardProps): import("react").JSX.Element;
8
8
  export { ChartBarMultiple };
9
9
  //# sourceMappingURL=chart-bar-multiple.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chart-bar-multiple.d.ts","sourceRoot":"","sources":["../../src/components/chart-bar-multiple.tsx"],"names":[],"mappings":"AAcA,OAAO,EAOL,KAAK,cAAc,EACpB,MAAM,yBAAyB,CAAC;AAGjC;;;;GAIG;AACH,iBAAS,gBAAgB,CAAC,EACxB,KAAK,EACL,WAAW,EACX,MAAM,EACN,MAAM,EACN,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,cAAc,EACd,cAAsC,EACtC,aAAa,EACb,UAAoB,EACpB,UAAU,EACV,IAAgB,EAChB,SAAS,GACV,EAAE,cAAc,+BA8DhB;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"chart-bar-multiple.d.ts","sourceRoot":"","sources":["../../src/components/chart-bar-multiple.tsx"],"names":[],"mappings":"AAcA,OAAO,EAOL,KAAK,cAAc,EACpB,MAAM,yBAAyB,CAAC;AAGjC;;;;GAIG;AACH,iBAAS,gBAAgB,CAAC,EACxB,KAAK,EACL,WAAW,EACX,MAAM,EACN,OAAO,EACP,KAAK,EACL,MAAM,EACN,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,cAAc,EACd,cAAsC,EACtC,aAAa,EACb,UAAoB,EACpB,UAAU,EACV,IAAgB,EAChB,SAAS,GACV,EAAE,cAAc,+BAgEhB;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -12,11 +12,11 @@ import { entityColor } from "./chart-entity-colors.js";
12
12
  * one unit. A rate over those measures (a margin percentage) is a KPI card, not
13
13
  * a second axis on this plot.
14
14
  */
15
- function ChartBarMultiple({ title, description, action, footer, headingLevel, data, xKey, series, entityColorMap, valueFormatter = defaultValueFormatter, axisFormatter, otherLabel = "Other", emptyState, size = "default", className, }) {
15
+ function ChartBarMultiple({ title, description, action, summary, aside, footer, headingLevel, data, xKey, series, entityColorMap, valueFormatter = defaultValueFormatter, axisFormatter, otherLabel = "Other", emptyState, size = "default", className, }) {
16
16
  const folded = foldOtherSeries(series, data, entityColorMap, otherLabel);
17
17
  const chartConfig = chartSeriesConfig(folded.series, entityColorMap);
18
18
  const domainMax = seriesAxisMax(folded.data, folded.series.map((entry) => entry.id));
19
- return (_jsx(ChartCard, { title: title, description: description, action: action, footer: footer, ...(headingLevel ? { headingLevel } : {}), className: className, children: (titleId) => emptyState && data.length === 0 ? (emptyState) : (_jsx(ChartContainer, { config: chartConfig, className: chartPlotClassName(size), children: _jsxs(BarChart, { accessibilityLayer: true, "aria-labelledby": titleId, data: folded.data, children: [_jsx(CartesianGrid, { strokeDasharray: "3 3" }), _jsx(XAxis, { dataKey: xKey, tickLine: false, tickMargin: 10, axisLine: false }), _jsx(YAxis, { width: "auto", tickLine: false, axisLine: false, tickMargin: 8, tickCount: CHART_Y_AXIS_TICK_COUNT, ...(domainMax === undefined
19
+ return (_jsx(ChartCard, { title: title, description: description, action: action, summary: summary, aside: aside, footer: footer, ...(headingLevel ? { headingLevel } : {}), className: className, children: (titleId) => emptyState && data.length === 0 ? (emptyState) : (_jsx(ChartContainer, { config: chartConfig, className: chartPlotClassName(size), children: _jsxs(BarChart, { accessibilityLayer: true, "aria-labelledby": titleId, data: folded.data, children: [_jsx(CartesianGrid, { strokeDasharray: "3 3" }), _jsx(XAxis, { dataKey: xKey, tickLine: false, tickMargin: 10, axisLine: false }), _jsx(YAxis, { width: "auto", tickLine: false, axisLine: false, tickMargin: 8, tickCount: CHART_Y_AXIS_TICK_COUNT, ...(domainMax === undefined
20
20
  ? {}
21
21
  : {
22
22
  domain: [0, domainMax],
@@ -1,5 +1,5 @@
1
1
  import { type ChartCardProps } from "./chart-card.js";
2
- declare function ChartBarStacked({ title, description, action, footer, headingLevel, data, xKey, series, entityColorMap, valueFormatter, axisFormatter, otherLabel, emptyState, size, share, className, }: ChartCardProps & {
2
+ declare function ChartBarStacked({ title, description, action, summary, aside, footer, headingLevel, data, xKey, series, entityColorMap, valueFormatter, axisFormatter, otherLabel, emptyState, size, share, className, }: ChartCardProps & {
3
3
  /**
4
4
  * One bar across the card, each entity a segment of 100%: the share of a
5
5
  * total with no time axis. `data` is then a single row keyed by series id.
@@ -1 +1 @@
1
- {"version":3,"file":"chart-bar-stacked.d.ts","sourceRoot":"","sources":["../../src/components/chart-bar-stacked.tsx"],"names":[],"mappings":"AAcA,OAAO,EAOL,KAAK,cAAc,EACpB,MAAM,yBAAyB,CAAC;AAmBjC,iBAAS,eAAe,CAAC,EACvB,KAAK,EACL,WAAW,EACX,MAAM,EACN,MAAM,EACN,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,cAAc,EACd,cAAsC,EACtC,aAAa,EACb,UAAoB,EACpB,UAAU,EACV,IAAgB,EAChB,KAAa,EACb,SAAS,GACV,EAAE,cAAc,GAAG;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,+BA8FA;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"chart-bar-stacked.d.ts","sourceRoot":"","sources":["../../src/components/chart-bar-stacked.tsx"],"names":[],"mappings":"AAcA,OAAO,EAOL,KAAK,cAAc,EACpB,MAAM,yBAAyB,CAAC;AAmBjC,iBAAS,eAAe,CAAC,EACvB,KAAK,EACL,WAAW,EACX,MAAM,EACN,OAAO,EACP,KAAK,EACL,MAAM,EACN,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,cAAc,EACd,cAAsC,EACtC,aAAa,EACb,UAAoB,EACpB,UAAU,EACV,IAAgB,EAChB,KAAa,EACb,SAAS,GACV,EAAE,cAAc,GAAG;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,+BAgGA;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -27,11 +27,11 @@ function shareRadius(index, count) {
27
27
  return [0, 4, 4, 0];
28
28
  return [0, 0, 0, 0];
29
29
  }
30
- function ChartBarStacked({ title, description, action, footer, headingLevel, data, xKey, series, entityColorMap, valueFormatter = defaultValueFormatter, axisFormatter, otherLabel = "Other", emptyState, size = "default", share = false, className, }) {
30
+ function ChartBarStacked({ title, description, action, summary, aside, footer, headingLevel, data, xKey, series, entityColorMap, valueFormatter = defaultValueFormatter, axisFormatter, otherLabel = "Other", emptyState, size = "default", share = false, className, }) {
31
31
  const folded = foldOtherSeries(series, data, entityColorMap, otherLabel);
32
32
  const chartConfig = chartSeriesConfig(folded.series, entityColorMap);
33
33
  const domainMax = stackedAxisMax(folded.data, folded.series.map((entry) => entry.id));
34
- return (_jsx(ChartCard, { title: title, description: description, action: action, footer: footer, ...(headingLevel ? { headingLevel } : {}), className: className, children: (titleId) => emptyState && data.length === 0 ? (emptyState) : share ? (_jsx(ChartContainer, { config: chartConfig, className: "aspect-auto h-16 w-full", children: _jsxs(BarChart, { accessibilityLayer: true, "aria-labelledby": titleId, data: folded.data, layout: "vertical", stackOffset: "expand", children: [_jsx(XAxis, { type: "number", hide: true }), _jsx(YAxis, { type: "category", dataKey: xKey, hide: true }), _jsx(ChartTooltip, { cursor: false, content: _jsx(ChartTooltipContent, { hideLabel: true, indicator: "line", valueFormatter: valueFormatter }) }), _jsx(ChartLegend, { itemSorter: null, content: _jsx(ChartLegendContent, { className: CHART_LEGEND_CLASS }) }), folded.series.map((entry, index) => (_jsx(Bar, { dataKey: entry.id, stackId: "a", fill: entityColor(entityColorMap, entry.id), radius: shareRadius(index, folded.series.length) }, entry.id)))] }) })) : (_jsx(ChartContainer, { config: chartConfig, className: chartPlotClassName(size), children: _jsxs(BarChart, { accessibilityLayer: true, "aria-labelledby": titleId, data: folded.data, children: [_jsx(CartesianGrid, { strokeDasharray: "3 3" }), _jsx(XAxis, { dataKey: xKey, tickLine: false, tickMargin: 10, axisLine: false }), _jsx(YAxis, { width: "auto", tickLine: false, axisLine: false, tickMargin: 8, tickCount: CHART_Y_AXIS_TICK_COUNT, ...(domainMax === undefined
34
+ return (_jsx(ChartCard, { title: title, description: description, action: action, summary: summary, aside: aside, footer: footer, ...(headingLevel ? { headingLevel } : {}), className: className, children: (titleId) => emptyState && data.length === 0 ? (emptyState) : share ? (_jsx(ChartContainer, { config: chartConfig, className: "aspect-auto h-16 w-full", children: _jsxs(BarChart, { accessibilityLayer: true, "aria-labelledby": titleId, data: folded.data, layout: "vertical", stackOffset: "expand", children: [_jsx(XAxis, { type: "number", hide: true }), _jsx(YAxis, { type: "category", dataKey: xKey, hide: true }), _jsx(ChartTooltip, { cursor: false, content: _jsx(ChartTooltipContent, { hideLabel: true, indicator: "line", valueFormatter: valueFormatter }) }), _jsx(ChartLegend, { itemSorter: null, content: _jsx(ChartLegendContent, { className: CHART_LEGEND_CLASS }) }), folded.series.map((entry, index) => (_jsx(Bar, { dataKey: entry.id, stackId: "a", fill: entityColor(entityColorMap, entry.id), radius: shareRadius(index, folded.series.length) }, entry.id)))] }) })) : (_jsx(ChartContainer, { config: chartConfig, className: chartPlotClassName(size), children: _jsxs(BarChart, { accessibilityLayer: true, "aria-labelledby": titleId, data: folded.data, children: [_jsx(CartesianGrid, { strokeDasharray: "3 3" }), _jsx(XAxis, { dataKey: xKey, tickLine: false, tickMargin: 10, axisLine: false }), _jsx(YAxis, { width: "auto", tickLine: false, axisLine: false, tickMargin: 8, tickCount: CHART_Y_AXIS_TICK_COUNT, ...(domainMax === undefined
35
35
  ? {}
36
36
  : {
37
37
  domain: [0, domainMax],
@@ -1,6 +1,7 @@
1
1
  import * as React from "react";
2
2
  import type { ChartConfig } from "./chart.js";
3
3
  import { type EntityColorMap } from "./chart-entity-colors.js";
4
+ import { type TrendDirection, type TrendTone } from "./trend-badge.js";
4
5
  /**
5
6
  * chart-card — the Card frame and series plumbing every chart in this kit
6
7
  * renders, so the four registry blocks (`chart-bar-stacked`,
@@ -17,6 +18,21 @@ type ChartSeries = {
17
18
  };
18
19
  type ChartDatum = Record<string, number | string>;
19
20
  type ChartCardSize = "default" | "lg";
21
+ type ChartSummaryTrend = {
22
+ value: React.ReactNode;
23
+ direction: TrendDirection;
24
+ tone: TrendTone;
25
+ comparison: React.ReactNode;
26
+ directionLabel?: string;
27
+ };
28
+ type ChartSummaryProps = {
29
+ label: React.ReactNode;
30
+ value: React.ReactNode;
31
+ valueTitle?: string;
32
+ valueSize?: ChartCardSize;
33
+ trend?: ChartSummaryTrend;
34
+ status?: React.ReactNode;
35
+ };
20
36
  type ChartCardProps = {
21
37
  title: React.ReactNode;
22
38
  description?: React.ReactNode;
@@ -24,6 +40,10 @@ type ChartCardProps = {
24
40
  headingLevel?: 2 | 3 | 4;
25
41
  /** Trailing header slot, e.g. an "Explore" link. */
26
42
  action?: React.ReactNode;
43
+ /** A measured summary between the header and plot. */
44
+ summary?: React.ReactNode;
45
+ /** Related ranking or breakdown beside the plot on wide cards. */
46
+ aside?: React.ReactNode;
27
47
  footer?: React.ReactNode;
28
48
  data: readonly ChartDatum[];
29
49
  /** The datum key carrying the category or period. */
@@ -56,10 +76,11 @@ declare function foldOtherSeries(series: readonly ChartSeries[], data: readonly
56
76
  series: ChartSeries[];
57
77
  data: ChartDatum[];
58
78
  };
59
- declare function ChartCard({ title, description, action, footer, headingLevel, className, children, }: Pick<ChartCardProps, "title" | "description" | "action" | "footer" | "headingLevel" | "className"> & {
79
+ declare function ChartCard({ title, description, action, summary, aside, footer, headingLevel, className, children, }: Pick<ChartCardProps, "title" | "description" | "action" | "summary" | "aside" | "footer" | "headingLevel" | "className"> & {
60
80
  /** Receives the title's id, which the plot takes as `aria-labelledby`. */
61
81
  children: (titleId: string) => React.ReactNode;
62
82
  }): React.JSX.Element;
83
+ declare function ChartSummary({ label, value, valueTitle, valueSize, trend, status, }: ChartSummaryProps): React.JSX.Element;
63
84
  /** The plot frame class: fixed height, no aspect ratio, full width. */
64
85
  declare function chartPlotClassName(size: ChartCardSize): string;
65
86
  /**
@@ -70,6 +91,6 @@ declare function chartPlotClassName(size: ChartCardSize): string;
70
91
  declare const CHART_FOCUS_CLASS = "[&_.recharts-surface:focus-visible]:nc-focus-outline [&_.recharts-surface:focus-visible]:outline-ring";
71
92
  /** Legend below the plot, left-aligned, wrapping to a second line. */
72
93
  declare const CHART_LEGEND_CLASS = "flex-wrap justify-start";
73
- export { CHART_FOCUS_CLASS, CHART_LEGEND_CLASS, ChartCard, chartPlotClassName, chartSeriesConfig, defaultValueFormatter, foldOtherSeries, };
74
- export type { ChartCardProps, ChartCardSize, ChartDatum, ChartSeries };
94
+ export { CHART_FOCUS_CLASS, CHART_LEGEND_CLASS, ChartCard, ChartSummary, chartPlotClassName, chartSeriesConfig, defaultValueFormatter, foldOtherSeries, };
95
+ export type { ChartCardProps, ChartCardSize, ChartDatum, ChartSeries, ChartSummaryProps, ChartSummaryTrend, };
75
96
  //# sourceMappingURL=chart-card.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chart-card.d.ts","sourceRoot":"","sources":["../../src/components/chart-card.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,kCAAkC,CAAC;AAE1C;;;;;;;;GAQG;AAEH,KAAK,WAAW,GAAG;IACjB,0EAA0E;IAC1E,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;AAElD,KAAK,aAAa,GAAG,SAAS,GAAG,IAAI,CAAC;AAWtC,KAAK,cAAc,GAAG;IACpB,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,oEAAoE;IACpE,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC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B,CAAC;AAErD,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,EACT,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,GAChB,CAAC;AACF,YAAY,EACV,cAAc,EACd,aAAa,EACb,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,iBAAiB,GAClB,CAAC"}
@@ -4,6 +4,7 @@ import * as React from "react";
4
4
  import { cn } from "../lib/utils.js";
5
5
  import { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "./card.js";
6
6
  import { CHART_ENTITY_OTHER_COLOR, entityColor, } from "./chart-entity-colors.js";
7
+ import { TrendBadge } from "./trend-badge.js";
7
8
  /** Fixed plot heights, so charts on a page share one register. */
8
9
  const chartSizes = {
9
10
  default: "h-64",
@@ -52,9 +53,13 @@ function foldOtherSeries(series, data, entityColorMap, otherLabel) {
52
53
  });
53
54
  return { series: folded, data: foldedData };
54
55
  }
55
- function ChartCard({ title, description, action, footer, headingLevel = 2, className, children, }) {
56
+ function ChartCard({ title, description, action, summary, aside, footer, headingLevel = 2, className, children, }) {
56
57
  const titleId = React.useId();
57
- return (_jsxs(Card, { "data-slot": "chart-card", className: className, children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { id: titleId, role: "heading", "aria-level": headingLevel, children: title }), description ? _jsx(CardDescription, { children: description }) : null, action ? _jsx(CardAction, { children: action }) : null] }), _jsx(CardContent, { children: children(titleId) }), footer ? (_jsx(CardFooter, { className: "flex-col items-start gap-2 text-sm", children: footer })) : null] }));
58
+ return (_jsxs(Card, { "data-slot": "chart-card", className: cn("@container/chart-card", className), children: [_jsxs(CardHeader, { className: "has-data-[slot=card-action]:grid-cols-1 [&>[data-slot=card-action]]:col-start-1 [&>[data-slot=card-action]]:row-span-1 [&>[data-slot=card-action]]:row-start-3 [&>[data-slot=card-action]]:justify-self-start @md/chart-card:has-data-[slot=card-action]:grid-cols-[1fr_auto] @md/chart-card:[&>[data-slot=card-action]]:col-start-2 @md/chart-card:[&>[data-slot=card-action]]:row-span-2 @md/chart-card:[&>[data-slot=card-action]]:row-start-1 @md/chart-card:[&>[data-slot=card-action]]:justify-self-end", children: [_jsx(CardTitle, { id: titleId, role: "heading", "aria-level": headingLevel, children: title }), description ? _jsx(CardDescription, { children: description }) : null, action ? _jsx(CardAction, { children: action }) : null] }), summary ? (_jsx("div", { "data-slot": "chart-card-summary", className: "px-(--card-spacing)", children: summary })) : null, _jsxs(CardContent, { className: cn(aside &&
59
+ "grid min-w-0 gap-(--card-spacing) lg:grid-cols-[minmax(0,2fr)_minmax(16rem,1fr)]"), children: [_jsx("div", { className: "min-w-0", children: children(titleId) }), aside ? (_jsx("aside", { "data-slot": "chart-card-aside", className: "min-w-0 border-t border-border pt-(--card-spacing) lg:border-t-0 lg:border-l lg:pt-0 lg:pl-(--card-spacing)", children: aside })) : null] }), footer ? (_jsx(CardFooter, { className: "flex-col items-start gap-2 text-sm", children: footer })) : null] }));
60
+ }
61
+ function ChartSummary({ label, value, valueTitle, valueSize = "default", trend, status, }) {
62
+ return (_jsxs("div", { "data-slot": "chart-summary", className: "flex flex-col items-start gap-2", children: [_jsx("div", { className: "text-muted-foreground text-sm", children: label }), _jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-3", children: [_jsx("div", { "data-slot": "chart-summary-value", className: cn("truncate font-semibold tracking-tight tabular-nums", valueSize === "lg" ? "text-3xl" : "text-2xl"), title: valueTitle, children: value }), trend ? (_jsx(TrendBadge, { direction: trend.direction, directionLabel: trend.directionLabel, tone: trend.tone, value: trend.value })) : null, status] }), trend ? (_jsx("div", { "data-slot": "chart-summary-comparison", className: "text-muted-foreground text-sm", children: trend.comparison })) : null] }));
58
63
  }
59
64
  /** The plot frame class: fixed height, no aspect ratio, full width. */
60
65
  function chartPlotClassName(size) {
@@ -68,4 +73,4 @@ function chartPlotClassName(size) {
68
73
  const CHART_FOCUS_CLASS = "[&_.recharts-surface:focus-visible]:nc-focus-outline [&_.recharts-surface:focus-visible]:outline-ring";
69
74
  /** Legend below the plot, left-aligned, wrapping to a second line. */
70
75
  const CHART_LEGEND_CLASS = "flex-wrap justify-start";
71
- export { CHART_FOCUS_CLASS, CHART_LEGEND_CLASS, ChartCard, chartPlotClassName, chartSeriesConfig, defaultValueFormatter, foldOtherSeries, };
76
+ export { CHART_FOCUS_CLASS, CHART_LEGEND_CLASS, ChartCard, ChartSummary, chartPlotClassName, chartSeriesConfig, defaultValueFormatter, foldOtherSeries, };
@@ -0,0 +1,138 @@
1
+ import type { Locale, Day as WeekDay } from "date-fns";
2
+ import type { CSSProperties, HTMLAttributes, ReactNode } from "react";
3
+ export type Activity = {
4
+ date: string;
5
+ value: number | null;
6
+ };
7
+ type ActivityWithLevel = Activity & {
8
+ level: number;
9
+ measured: boolean;
10
+ };
11
+ export type Labels = {
12
+ months?: string[];
13
+ weekdays?: string[];
14
+ stat?: string;
15
+ cellLabel?: string | ((activity: Activity) => string);
16
+ unavailable?: string;
17
+ heatmapLabel?: string;
18
+ legendLabel?: string;
19
+ legendLevelLabel?: string;
20
+ };
21
+ export type ColorConfig = {
22
+ empty?: string;
23
+ scale?: string;
24
+ unavailable?: string;
25
+ };
26
+ export type CalendarHeatmapProps = HTMLAttributes<HTMLDivElement> & {
27
+ data: Activity[];
28
+ weekStart?: WeekDay;
29
+ continuousMonths?: boolean;
30
+ singleRow?: boolean;
31
+ hasEmptyColumn?: boolean;
32
+ blockSize?: number;
33
+ blockMargin?: number;
34
+ blockRadius?: number;
35
+ blockAspectRatio?: number;
36
+ levels?: number;
37
+ isNormalized?: boolean;
38
+ colors?: ColorConfig;
39
+ locale?: Locale;
40
+ labels?: Labels;
41
+ fontSize?: number;
42
+ emptyState?: ReactNode;
43
+ totalCount?: number;
44
+ style?: CSSProperties;
45
+ className?: string;
46
+ children: ReactNode;
47
+ };
48
+ /**
49
+ * Calendar Heatmap
50
+ *
51
+ * A GitHub-style contribution calendar showing daily activity over months and years.
52
+ * Each cell represents one day, arranged in weeks (rows) and months (columns).
53
+ *
54
+ * @example
55
+ * ```tsx
56
+ * <CalendarHeatmap data={data} weekStart={1} continuousMonths>
57
+ * <CalendarHeatmapBody>
58
+ * {({ activity, dayIndex, weekIndex }) => (
59
+ * <CalendarHeatmapBlock
60
+ * activity={activity}
61
+ * dayIndex={dayIndex}
62
+ * weekIndex={weekIndex}
63
+ * />
64
+ * )}
65
+ * </CalendarHeatmapBody>
66
+ * <CalendarHeatmapFooter>
67
+ * <CalendarHeatmapStat />
68
+ * <CalendarHeatmapLegend />
69
+ * </CalendarHeatmapFooter>
70
+ * </CalendarHeatmap>
71
+ * ```
72
+ *
73
+ * @param data - Array of activities with date (YYYY-MM-DD) and value
74
+ * @param weekStart - First day of week (0=Sunday, 1=Monday). Default: 0
75
+ * @param continuousMonths - Display months continuously vs. grouped by year. Default: true
76
+ * @param singleRow - Keep a continuous range in one row across year boundaries. Default: false
77
+ * @param hasEmptyColumn - Add empty column between months. Default: false
78
+ * @param blockAspectRatio - Width/height ratio of blocks. Default: 1
79
+ * @param levels - Total number of legend cells (including empty when not normalized). Default: 5
80
+ * @param isNormalized - When true, uses min-max normalization across the dataset (suitable for signed values). When false (default), treats 0 as empty and scales from 0 to max.
81
+ */
82
+ export declare const CalendarHeatmap: ({ data, weekStart, continuousMonths, singleRow, hasEmptyColumn, blockSize, blockMargin, blockRadius, blockAspectRatio, levels: levelsProp, isNormalized, colors, locale, labels: labelsProp, fontSize, emptyState, totalCount: totalCountProp, style, className, children, ...props }: CalendarHeatmapProps) => string | number | bigint | true | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null;
83
+ export type CalendarHeatmapBlockProps = HTMLAttributes<SVGRectElement> & {
84
+ activity: ActivityWithLevel;
85
+ dayIndex: number;
86
+ weekIndex: number;
87
+ highlighted?: boolean;
88
+ onCellClick?: (activity: ActivityWithLevel) => void;
89
+ onCellHover?: (activity: ActivityWithLevel | null) => void;
90
+ };
91
+ export declare const CalendarHeatmapBlock: {
92
+ ({ ref, activity, dayIndex, weekIndex, highlighted, onCellClick, onCellHover, onClick, onKeyDown, onMouseEnter, onMouseLeave, className, style: styleProp, ...props }: CalendarHeatmapBlockProps & {
93
+ ref?: React.RefObject<SVGRectElement | null>;
94
+ }): import("react").JSX.Element;
95
+ displayName: string;
96
+ };
97
+ export type CalendarHeatmapBodyProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> & {
98
+ hideMonthLabels?: boolean;
99
+ hideWeekdayLabels?: boolean;
100
+ hideYearLabels?: boolean;
101
+ className?: string;
102
+ labelClassName?: string;
103
+ yearClassName?: string;
104
+ children: (props: {
105
+ activity: ActivityWithLevel;
106
+ dayIndex: number;
107
+ weekIndex: number;
108
+ }) => ReactNode;
109
+ renderYearFooter?: (props: {
110
+ year: number;
111
+ totalCount: number;
112
+ }) => ReactNode;
113
+ };
114
+ export declare const CalendarHeatmapBody: ({ hideMonthLabels, hideWeekdayLabels, hideYearLabels, className, labelClassName, yearClassName, children, renderYearFooter, ...props }: CalendarHeatmapBodyProps) => import("react").JSX.Element;
115
+ export type CalendarHeatmapFooterProps = HTMLAttributes<HTMLDivElement>;
116
+ export declare const CalendarHeatmapFooter: ({ className, ...props }: CalendarHeatmapFooterProps) => import("react").JSX.Element;
117
+ export type CalendarHeatmapStatProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> & {
118
+ compute?: (data: ActivityWithLevel[]) => number | string;
119
+ label?: string;
120
+ children?: (result: {
121
+ value: number | string;
122
+ data: ActivityWithLevel[];
123
+ year: number;
124
+ }) => ReactNode;
125
+ };
126
+ export declare const CalendarHeatmapStat: ({ compute, label, className, children, ...props }: CalendarHeatmapStatProps) => import("react").JSX.Element;
127
+ export type CalendarHeatmapLegendProps = Omit<HTMLAttributes<HTMLFieldSetElement>, "children"> & {
128
+ labels?: {
129
+ less?: string;
130
+ more?: string;
131
+ };
132
+ children?: (props: {
133
+ level: number;
134
+ }) => ReactNode;
135
+ };
136
+ export declare const CalendarHeatmapLegend: ({ labels: labelsProp, className, children, ...props }: CalendarHeatmapLegendProps) => import("react").JSX.Element;
137
+ export {};
138
+ //# sourceMappingURL=calendar-heatmap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar-heatmap.d.ts","sourceRoot":"","sources":["../../../src/components/heatmap/calendar-heatmap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,UAAU,CAAC;AAavD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAItE,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAC;AAEF,KAAK,iBAAiB,GAAG,QAAQ,GAAG;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAUF,MAAM,MAAM,MAAM,GAAG;IACnB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,QAAQ,EAAE,QAAQ,KAAK,MAAM,CAAC,CAAC;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;A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