"use client"; import * as React from "react"; import { Button, Field } from "../../primitives"; import { ControlFieldLabel } from "../../control-layout"; import { hoverImportantSelectedItemBorderClassName, hoverImportantSelectedItemSurfaceClassName, importantSelectedItemBorderClassName, importantSelectedItemSurfaceClassName, } from "../../primitives/selection-state"; import { cn } from "../../../lib/utils"; export type AnchorGridValue = | "bottom-center" | "bottom-left" | "bottom-right" | "center" | "center-left" | "center-right" | "top-center" | "top-left" | "top-right"; export type AnchorGridControlProps = { name: string; onValueChange?: (value: AnchorGridValue) => void; value?: AnchorGridValue; }; const anchorOptions = [ "top-left", "top-center", "top-right", "center-left", "center", "center-right", "bottom-left", "bottom-center", "bottom-right", ] as const satisfies readonly AnchorGridValue[]; const anchorLabels = { "bottom-center": "Bottom Center", "bottom-left": "Bottom Left", "bottom-right": "Bottom Right", center: "Center", "center-left": "Center Left", "center-right": "Center Right", "top-center": "Top Center", "top-left": "Top Left", "top-right": "Top Right", } as const satisfies Record; export function AnchorGridControl({ name, onValueChange, value = "center", }: AnchorGridControlProps): React.JSX.Element { const [currentValue, setCurrentValue] = React.useState(value); React.useEffect(() => { setCurrentValue(value); }, [value]); function updateValue(nextValue: AnchorGridValue): void { setCurrentValue(nextValue); onValueChange?.(nextValue); } return ( {name}
{anchorOptions.map((option) => ( ))}
); }