{"version":3,"names":["createContext","useContext","NOOP_TOGGLE_GROUP_CONTEXT","value","setGroupValue","disabled","orientation","multiple","isValueInitialized","present","ToggleGroupContext","useToggleGroupContext"],"sources":["toggle-group-context.ts"],"sourcesContent":["import { type Accessor, createContext, useContext } from \"solid-js\";\nimport type {\n\tBaseUIChangeEventDetails,\n\tBaseUIEventReasons,\n} from \"../internals/change-event-details\";\nimport type { Orientation } from \"../internals/types\";\n\n/**\n * Change-event details handed to `setGroupValue` by child `<Toggle>` elements.\n * Mirrors `ToggleGroup.ChangeEventDetails` from the React port.\n */\nexport type ToggleGroupChangeEventDetails = BaseUIChangeEventDetails<\n\tBaseUIEventReasons[\"none\"]\n>;\n\n/**\n * The value handed down by `<ToggleGroup>` to descendant `<Toggle>` elements.\n *\n * Solid 2 adaptations from Base UI React's `ToggleGroupContext`:\n *\n * - Reactive slots (`value`, `disabled`) are `Accessor<T>` so toggles pull on\n *   demand without tripping the top-level-reactive-read rule (RFC 01).\n * - `setGroupValue` is wrapped in `createStableCallback` by the group root so\n *   toggles can capture it into closures without re-wiring across renders.\n * - `orientation` is a plain value (not an accessor) — it feeds both the\n *   composite root's keyboard dispatcher and the data-orientation projection,\n *   and changing it mid-lifetime is not supported by Base UI React either.\n * - `present` is true when a real `<ToggleGroup>` is an ancestor; child\n *   toggles branch on it to decide whether to override their own\n *   `pressed`/`onPressedChange` behaviour.\n */\nexport interface ToggleGroupContextValue<Value extends string = string> {\n\t/**\n\t * Current group value — always an array. Single-select groups carry at\n\t * most one entry; multi-select carries any subset.\n\t */\n\tvalue: Accessor<readonly Value[]>;\n\t/**\n\t * Write-through for the group's value. Receives the individual toggle's\n\t * `value` string, its `nextPressed` flag (so the group can branch on\n\t * single vs. multi select), and the change-event details. Dispatches\n\t * `onValueChange(next, details)` and honours `details.cancel()`.\n\t */\n\tsetGroupValue: (\n\t\tnewValue: Value,\n\t\tnextPressed: boolean,\n\t\tdetails: ToggleGroupChangeEventDetails,\n\t) => void;\n\t/** Whether the group is disabled — propagates to every child toggle. */\n\tdisabled: Accessor<boolean>;\n\t/** Navigation orientation. */\n\torientation: Orientation;\n\t/** When `true` the group allows multiple toggles to be pressed at once. */\n\tmultiple: Accessor<boolean>;\n\t/**\n\t * Whether the group's `value` / `defaultValue` was initialized. Children\n\t * use this to detect the \"toggle with no value inside an initialized\n\t * group\" dev-mode error path (matches React).\n\t */\n\tisValueInitialized: Accessor<boolean>;\n\t/** Marker — `true` when provided by a real `<ToggleGroup>`. */\n\treadonly present: boolean;\n}\n\n/**\n * No-op sentinel for when no `<ToggleGroup>` ancestor exists. Solid 2's\n * `useContext` throws `ContextNotFoundError` when the default is literal\n * `undefined` — same trap the checkbox-group and radio-group ports sidestep\n * via sentinel. Children branch on `.present` to decide whether to defer to\n * the group.\n */\nconst NOOP_TOGGLE_GROUP_CONTEXT: ToggleGroupContextValue<string> = {\n\tvalue: () => [],\n\tsetGroupValue: () => {},\n\tdisabled: () => false,\n\torientation: \"horizontal\",\n\tmultiple: () => false,\n\tisValueInitialized: () => false,\n\tpresent: false,\n};\n\n/**\n * Toggle-group context. Default is the NOOP sentinel so `useContext` never\n * throws. Children branch on `.present` to stay single-path.\n */\nexport const ToggleGroupContext = createContext<\n\t// biome-ignore lint/suspicious/noExplicitAny: Value is erased at the context boundary; callers narrow per-toggle.\n\tToggleGroupContextValue<any>\n>(NOOP_TOGGLE_GROUP_CONTEXT);\n\n/**\n * Read the surrounding `<ToggleGroup>` context. Always non-undefined — the\n * sentinel's `.present === false` signals no group. Child toggle branches on\n * `context.present` to decide behaviour.\n */\nexport function useToggleGroupContext<\n\tValue extends string = string,\n>(): ToggleGroupContextValue<Value> {\n\treturn useContext(ToggleGroupContext) as ToggleGroupContextValue<Value>;\n}\n"],"mappings":"AAAA,SAAwBA,aAAa,EAAEC,UAAU,QAAQ,UAAU;;AAOnE;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,yBAA0D,GAAG;EAClEC,KAAK,EAAEA,CAAA,KAAM,EAAE;EACfC,aAAa,EAAEA,CAAA,KAAM,CAAC,CAAC;EACvBC,QAAQ,EAAEA,CAAA,KAAM,KAAK;EACrBC,WAAW,EAAE,YAAY;EACzBC,QAAQ,EAAEA,CAAA,KAAM,KAAK;EACrBC,kBAAkB,EAAEA,CAAA,KAAM,KAAK;EAC/BC,OAAO,EAAE;AACV,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,GAAGV,aAAa,CAG7CE,yBAAyB,CAAC;;AAE5B;AACA;AACA;AACA;AACA;AACA,OAAO,SAASS,qBAAqBA,CAAA,EAED;EACnC,OAAOV,UAAU,CAACS,kBAAkB,CAAC;AACtC","ignoreList":[]}