"use client"; import { cn } from "@/lib/utils"; import { TreemapContext, type TreemapProps, useTreemapModel } from "./treemap/context"; import { TreemapLegend } from "./treemap/legend"; import { TreemapPlot } from "./treemap/plot"; import { TreemapTooltip } from "./treemap/tooltip"; /** Compose Plot, Tooltip and Legend, or omit children for the complete chart. */ export function Treemap({ data, label, formatValue, colors, textColor, activeId, defaultActiveId, onActiveChange, labels, className, children, ...props }: TreemapProps) { const model = useTreemapModel({ data, label, formatValue, colors, textColor, activeId, defaultActiveId, onActiveChange, labels, }); const { t } = model; return (
{children === undefined ? ( <> ) : ( children )}
{model.items.map((item) => ( ))}
{t("tableCaption", { label: model.label })}
{t("item")} {t("value")} {t("share")} {t("details")}
{item.path.join(" / ")} {model.formatValue(item.value)} {(item.share * 100).toFixed(1)}% {item.description ?? ""}
); } export type { TreemapProps } from "./treemap/context"; export { useTreemap } from "./treemap/context"; export type { TreemapLegendProps } from "./treemap/legend"; export { TreemapLegend } from "./treemap/legend"; export { type TreemapMessages, treemapMessages } from "./treemap/messages"; export type { TreemapGroup, TreemapItem, TreemapLeaf, TreemapNode, TreemapTile, } from "./treemap/model"; export type { TreemapPlotProps } from "./treemap/plot"; export { TreemapPlot } from "./treemap/plot"; export type { TreemapTooltipProps } from "./treemap/tooltip"; export { TreemapTooltip } from "./treemap/tooltip";