import * as React from "react" import { cn } from "@/lib/utils" const defaultStates = [ "default", "hover", "focus", "active", "disabled", ] as const export function StateMatrix({ rows, states = defaultStates, render, className, }: { rows: readonly Row[] states?: readonly string[] render: (row: Row, state: string) => React.ReactNode className?: string }) { return (
))} {rows.map((row) => ( {states.map((state) => ( ))} ))}
{states.map((state) => ( {state}
{row} {render(row, state)}
) } // Spread onto a component to pin a state without interaction. export function previewState(state: string) { if (state === "disabled") { return { disabled: true } } if (["hover", "focus", "active"].includes(state)) { return { "data-preview": state } } return {} }