import { type Accessor, createContext, useContext } from "solid-js"; /** * Context value handed down by `` so nested controls can inherit * the item-level `disabled` override without walking back to the root. * * Mirrors Base UI React's `FieldItemContext` — a narrow per-item scope used * when a single `` contains multiple logical sub-controls (e.g. * a `` with per-checkbox labels + descriptions). */ export interface FieldItemContextValue { disabled: Accessor; readonly present: boolean; } export const NOOP_FIELD_ITEM_CONTEXT: FieldItemContextValue = { disabled: () => false, present: false, }; export const FieldItemContext = createContext( NOOP_FIELD_ITEM_CONTEXT, ); /** * Read the nearest `` context. Returns the noop context when no * item is above — callers can branch on `.present` if they need to detect * the "not in an item" case. */ export function useFieldItemContext(): FieldItemContextValue { return useContext(FieldItemContext); }