{"version":3,"names":["createContext","useContext","NOOP_CHECKBOX_GROUP_CONTEXT","Object","freeze","present","CheckboxGroupContext","useCheckboxGroupContext"],"sources":["checkbox-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 { UseCheckboxGroupParentReturnValue } from \"./use-checkbox-group-parent.ts\";\n\n/**\n * Change-event details handed to `setValue` by child checkboxes / the\n * parent-indicator helper. Mirrors\n * `CheckboxGroup.ChangeEventDetails` from the React port.\n */\nexport type CheckboxGroupChangeEventDetails = BaseUIChangeEventDetails<\n\tBaseUIEventReasons[\"none\"]\n>;\n\n/**\n * The value handed down by `<CheckboxGroup>` to its descendant\n * `<Checkbox.Root>` elements.\n *\n * Solid 2 adaptations from Base UI React's `CheckboxGroupContext`:\n *\n * - Every reactive slot is an `Accessor<T>` so child checkboxes pull on\n *   demand without tripping the top-level-reactive-read rule (RFC 01).\n * - `setValue` is wrapped in `createStableCallback` by the group root so\n *   children can capture it into closures / refs without re-wiring.\n * - `parent` carries the `useCheckboxGroupParent` return value. Its own\n *   callbacks are stable too (wrapped inside the helper).\n * - `present` is true when a real `<CheckboxGroup>` is an ancestor; child\n *   checkboxes branch on it to decide whether to override their internal\n *   `checked`/`onClick` behaviour.\n */\nexport interface CheckboxGroupContextValue {\n\t/** Current group value. */\n\tvalue: Accessor<readonly string[] | undefined>;\n\t/**\n\t * The group's `defaultValue` while the group is uncontrolled,\n\t * `undefined` while controlled (mirrors React Base UI's\n\t * `CheckboxGroupContext.defaultValue`). Child checkboxes use it to seed\n\t * their own uncontrolled state (`defaultGroupValue.includes(value)`).\n\t */\n\tdefaultValue: Accessor<readonly string[] | undefined>;\n\t/** Names of all checkboxes in the group — used by the parent-indicator helper. */\n\tallValues: Accessor<readonly string[] | undefined>;\n\t/** Write to the group value. Fires `onValueChange` and respects `details.cancel()`. */\n\tsetValue: (next: string[], details: CheckboxGroupChangeEventDetails) => void;\n\t/** Parent-indicator bundle (checked / indeterminate / child+parent props factories). */\n\tparent: UseCheckboxGroupParentReturnValue;\n\t/** Whether the group is disabled — propagates to every child. */\n\tdisabled: Accessor<boolean>;\n\t/** Marker — `true` when provided by a real `<CheckboxGroup>`. */\n\treadonly present: boolean;\n}\n\n/**\n * Sentinel used as the context's default so `useContext` returns a real\n * value instead of throwing a `ContextNotFoundError` (Solid 2 beta throws\n * when the default is literal `undefined`). Callers branch on `.present`\n * rather than the identity of this value.\n */\nconst NOOP_CHECKBOX_GROUP_CONTEXT = Object.freeze({\n\tpresent: false,\n}) as CheckboxGroupContextValue;\n\n/**\n * Checkbox-group context. The default is a frozen sentinel whose `.present`\n * is false, so `useCheckboxGroupContext` can always return a safe value and\n * children branch on `present` to decide whether to override their internal\n * behaviour.\n */\nexport const CheckboxGroupContext = createContext<CheckboxGroupContextValue>(\n\tNOOP_CHECKBOX_GROUP_CONTEXT,\n);\n\n/**\n * Read the surrounding `<CheckboxGroup>` context. Returns a noop (with\n * `present: false`) when no group is an ancestor — the child checkbox-root\n * branches on `.present` rather than nullishness.\n */\nexport function useCheckboxGroupContext(): CheckboxGroupContextValue {\n\treturn useContext(CheckboxGroupContext);\n}\n"],"mappings":"AAAA,SAAwBA,aAAa,EAAEC,UAAU,QAAQ,UAAU;;AAOnE;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuBA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,2BAA2B,GAAGC,MAAM,CAACC,MAAM,CAAC;EACjDC,OAAO,EAAE;AACV,CAAC,CAA8B;;AAE/B;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,GAAGN,aAAa,CAChDE,2BACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,SAASK,uBAAuBA,CAAA,EAA8B;EACpE,OAAON,UAAU,CAACK,oBAAoB,CAAC;AACxC","ignoreList":[]}