"use client"; import { Fragment, useMemo, type ReactNode } from "react"; import classNames from "@calcom/ui/classNames"; import { PanelCard } from "@calcom/ui/components/card"; import { Tooltip } from "@calcom/ui/components/tooltip"; type PanelCardProps = React.ComponentProps; type LegendItem = { label: string; color: string; // hex format }; export type LegendSize = "sm" | "default"; export function ChartCard({ legend, legendSize, enabledLegend, onSeriesToggle, ...panelCardProps }: PanelCardProps & { legend?: Array; legendSize?: LegendSize; enabledLegend?: Array; onSeriesToggle?: (label: string) => void; }) { const legendComponent = legend && legend.length > 0 ? ( ) : null; return ( {panelCardProps.headerContent} {legendComponent} ) : ( legendComponent ) }> {panelCardProps.children} ); } export function ChartCardItem({ count, className, children, }: { count?: number | string; className?: string; children: ReactNode; }) { return (
{children}
{count !== undefined &&
{count}
}
); } function Legend({ items, size = "default", enabledItems, onItemToggle, }: { items: LegendItem[]; size?: LegendSize; enabledItems?: LegendItem[]; onItemToggle?: (label: string) => void; }) { const enabledSet = useMemo(() => new Set((enabledItems ?? []).map((i) => i.label)), [enabledItems]); const isClickable = Boolean(onItemToggle); return (
{items.map((item, index) => { const isEnabled = enabledItems ? enabledSet.has(item.label) : true; return ( {index < items.length - 1 &&
} ); })}
); }