import type { JSX, ValidComponent } from "@solidjs/web"; import { type BaseUIChangeEventDetails, REASONS } from "../internals/change-event-details.js"; import { type MaybeAccessor } from "../internals/maybe-accessor.js"; import type { BaseUIComponentProps, NativeButtonProps } from "../internals/types.js"; /** * The reason string attached to every `onPressedChange` event details object. * Matches Base UI React's `Toggle.ChangeEventReason`. */ export type ToggleChangeEventReason = typeof REASONS.none; /** * Shape of the details bag handed to `onPressedChange`. */ export type ToggleChangeEventDetails = BaseUIChangeEventDetails; /** * The state object exposed through `data-*` projection and the `class` / * `style` callback surfaces. */ export interface ToggleState { /** Whether the toggle is currently pressed. */ pressed: boolean; /** Whether the toggle ignores user interaction. */ disabled: boolean; } export interface ToggleProps extends NativeButtonProps, BaseUIComponentProps<"button", ToggleState> { /** * Tag/component to render. Defaults to `"button"`. Replaces the * pre-spike `render` prop (axis G). */ as?: ValidComponent; /** * Controlled pressed state. When provided (resolved value not * `undefined`), the consumer owns the state — pair with * {@link onPressedChange}. When omitted, the toggle manages its own * pressed state (seeded from {@link defaultPressed}). Inside a * `` the group's `value` array owns the state instead. */ pressed?: MaybeAccessor; /** * Initial pressed state when uncontrolled. Read once at mount. * Ignored inside a `` (use the group's `defaultValue`). * @default false */ defaultPressed?: MaybeAccessor; /** @default false */ disabled?: boolean | undefined; onPressedChange?: ((pressed: boolean, eventDetails: ToggleChangeEventDetails) => void) | undefined; /** * Identifier used when the toggle participates in a ``. * Standalone toggles ignore this prop. */ value?: Value | undefined; } /** * A two-state button that can be on or off. Renders a `