"use client"; import { Check, ChevronDown } from "lucide-react"; import { motion, useReducedMotion } from "motion/react"; import { createContext, type KeyboardEvent, type ReactNode, type RefObject, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, } from "react"; import { cn } from "@/lib/utils"; const EASE = [0.23, 1, 0.32, 1] as const; // The menu opens in 150ms and closes a little faster, scaling a touch from the // trigger edge so it stays visually connected to the button. const OPEN = { duration: 0.15, ease: EASE } as const; const CLOSE = { duration: 0.1, ease: EASE } as const; interface SelectContextValue { value: string | undefined; open: boolean; setOpen: (open: boolean) => void; choose: (value: string) => void; labelOf: (value: string | undefined) => string | undefined; setLabel: (value: string, label: string) => void; triggerRef: RefObject; listRef: RefObject; triggerId: string; listId: string; disabled: boolean; } const SelectContext = createContext(null); function useSelect(part: string) { const ctx = useContext(SelectContext); if (!ctx) throw new Error(`${part} must be used inside