import type { JSX } from "@solidjs/web"; import { type Accessor } from "solid-js"; import { type BaseUIEventReasons } from "../internals/change-event-details.js"; import { type MaybeAccessor } from "../internals/maybe-accessor.js"; /** * Why the value array changed. CheckboxGroup carries the `"none"` reason — * children dispatch via plain clicks; the group itself doesn't distinguish * navigation/key/imperative origins in its public surface (matches React's * `CheckboxGroup.ChangeEventDetails`). */ export type CheckboxGroupChangeReason = BaseUIEventReasons["none"]; import type { CheckboxGroupChangeEventDetails } from "./checkbox-group-context.js"; export type { CheckboxGroupChangeEventDetails }; /** * Options for {@link createCheckboxGroup}. Every reactive input is * `MaybeAccessor`; pass an accessor to make the value reactive. * * Design notes: * * - `value` is `MaybeAccessor`; the consumer always owns * the signal. Internal storage is the consumer's accessor — no defaultValue. * - `allValues` is the universe of child values for the parent-indicator * helper (all/none/mixed math). Optional; the parent helper degrades to * `false`/`false` when absent. * - `onValueChange(next, event, reason)` is **pre-change**. The consumer's * signal write is the only writer. Post-change observation is via * `createEffect(c.value, ...)` on the api. * * **Solid-native shape (2026-04-30).** No internal state. `value` is * required and the consumer always owns the signal. See `solidify.md` §6. */ export interface CreateCheckboxGroupOptions { /** Selected-value array. Consumer-owned signal. Pair with {@link onValueChange}. */ value: MaybeAccessor; /** * The group's `defaultValue` while the group is uncontrolled, exposed to * descendant `` elements through the legacy context so * they can mirror Base UI's seed derivation * (`defaultGroupValue.includes(value)`). `undefined` while the group is * controlled. Purely informational — the primitive itself never reads it. */ defaultValue?: MaybeAccessor; /** Universe of child values used by the parent-indicator helper. */ allValues?: MaybeAccessor; /** Whether the group (and every descendant checkbox) is disabled. */ disabled?: MaybeAccessor; /** Whether the group is read-only. */ readOnly?: MaybeAccessor; /** Whether the group is required for form submission. */ required?: MaybeAccessor; /** Form-control name for the group. */ name?: MaybeAccessor; /** * Pre-change callback. `event.preventDefault()` is now a no-op for * the primitive (the consumer's signal write is the only writer). */ onValueChange?: (value: string[], event: Event, reason: CheckboxGroupChangeReason) => void; } /** Slot props emitted by `c.group()`. */ export interface CheckboxGroupSlotProps { role: "group"; "data-disabled": "" | undefined; "data-readonly": "" | undefined; "data-required": "" | undefined; } /** Parent-indicator bundle returned by {@link CheckboxGroupApi.parent}. */ export interface CheckboxGroupParentApi { /** True when every value in `allValues` is also in `value`. */ checked: Accessor; /** True when `value` is non-empty but doesn't cover all `allValues`. */ indeterminate: Accessor; /** * Plain `Map` (not reactive) of `childValue → disabled?`. Children push * into it during setup so the parent's flip-all math can skip disabled * entries that weren't checked. Mirrors React's `disabledStatesRef`. */ disabledStates: Map; /** * Click-the-parent flip helper. Cycles all-on / all-off / restore-mixed * on each call. The returned descriptor exposes the current `checked` / * `indeterminate` and an `onCheckedChange(next, event?, reason?)` setter * the wrapper invokes from the parent checkbox's onClick. */ getParentProps: () => { checked: boolean; indeterminate: boolean; onCheckedChange: (next: boolean, event?: Event, reason?: CheckboxGroupChangeReason) => void; }; } /** Public api returned by {@link createCheckboxGroup}. */ export interface CheckboxGroupApi { value: Accessor; allValues: Accessor; disabled: Accessor; readOnly: Accessor; required: Accessor; name: Accessor; /** * Pure event-emitter: fires `onValueChange(next, event, reason)`. * The consumer's signal write (in their handler) is the only writer. * No-op while `disabled` or `readOnly`. */ setValue: (next: readonly string[], event?: Event, reason?: CheckboxGroupChangeReason) => void; /** Parent-indicator helper bundle. */ parent: CheckboxGroupParentApi; /** Slot function for the group root element. */ group: (userProps?: U) => CheckboxGroupSlotProps & (U extends object ? U : object); /** Context provider. Also publishes the legacy `CheckboxGroupContext`. */ Provider: (props: { children: JSX.Element; }) => JSX.Element; } /** * Read the nearest {@link CheckboxGroupApi} provided by `c.Provider`. Throws * when used outside the Provider. */ export declare function useCheckboxGroup(): CheckboxGroupApi; /** * Solid 2.0-native compound primitive for CheckboxGroup. Owns the selected * value array and the parent-indicator (all/none/mixed) bundle. Form wiring * (field registration, hidden inputs, name resolution) and rendering live in * the `` wrapper — those are integration concerns layered on * top of this primitive. * * Embeds cleanly with ``: the wrapper reads the legacy * {@link CheckboxGroupContext} (also published by `c.Provider`), routes * clicks through `groupContext.setValue(...)`, and derives each child's * `checked` from `groupContext.value().includes(childValue)`. The bypass * pattern in `checkbox-root.tsx`'s onClick keeps that interface unchanged. */ export declare function createCheckboxGroup(options: CreateCheckboxGroupOptions): CheckboxGroupApi; //# sourceMappingURL=create-checkbox-group.d.ts.map