'use client'; import * as React from 'react'; import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group'; import { type VariantProps } from 'class-variance-authority'; import { cn } from '../../shared/utils'; import { toggleVariants } from '../toggle'; const ToggleGroupContext = React.createContext>({ size: 'default', variant: 'default', }); /** * Visual group of two-state toggle buttons (Button Group / Toolbar). * * @description * Allows single or multiple active selection from a compact group of toggle buttons. * Handles shared variant/size context for all child `` components. * * @ai-rules * 1. `type` is REQUIRED — must be `"single"` (exclusive) or `"multiple"` (any number active). * 2. In `type="single"`, ToggleGroup guarantees exclusive selection automatically. * 3. Control value via `value`/`onValueChange` — value is a `string` (single) or `string[]` (multiple). */ const ToggleGroup = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef & VariantProps >(({ className, variant, size, children, ...props }, ref) => ( {children} )); ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName; const ToggleGroupItem = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef & VariantProps >(({ className, children, variant, size, ...props }, ref) => { const context = React.useContext(ToggleGroupContext); return ( {children} ); }); ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName; export { ToggleGroup, ToggleGroupItem };