import type { JSX, ValidComponent } from "@solidjs/web"; import { dynamic } from "@solidjs/web"; import { createMemo, createRenderEffect, createSignal, omit } from "solid-js"; import { useCheckboxGroupContext } from "../../checkbox-group/checkbox-group-context.ts"; import { useBaseUiId } from "../../internals/base-ui-id"; import { type BaseUIChangeEventDetails, createChangeEventDetails, REASONS, } from "../../internals/change-event-details"; import { composeRefs, userRef } from "../../internals/compose-refs"; import { createControlledState } from "../../internals/create-controlled-state"; import { useFieldRootContext } from "../../internals/field-context"; import { fieldStateAttrs } from "../../internals/field-state-attrs"; import { HiddenInput } from "../../internals/hidden-input/hidden-input.tsx"; import { useAriaLabelledBy } from "../../internals/labelable-provider/use-aria-labelled-by.ts"; import { type MaybeAccessor, readOption } from "../../internals/maybe-accessor"; import { mergeRootProps } from "../../internals/merge-root-props"; import { resolveClassStyle } from "../../internals/resolve-class-style"; import { ariaLabelledBy as seedAriaLabelledBy } from "../../internals/seed-aria-attr"; import type { BaseUIComponentProps, NonNativeButtonProps, } from "../../internals/types"; import { useButton } from "../../internals/use-button/use-button"; import { useFieldControlValidation } from "../../internals/use-field-control-validation/use-field-control-validation.ts"; import { useValueChanged } from "../../internals/use-value-changed.ts"; import { CheckboxRootContext, type CheckboxRootContextValue, type CheckboxRootState, } from "../checkbox-root-context.ts"; import { createCheckbox } from "../create-checkbox.tsx"; export type { CheckboxRootState }; export type CheckboxRootChangeEventReason = typeof REASONS.none; export type CheckboxRootChangeEventDetails = BaseUIChangeEventDetails; export interface CheckboxRootProps extends NonNativeButtonProps, Omit< BaseUIComponentProps<"button", CheckboxRootState>, "onChange" | "value" > { /** * Tag/component to render. Defaults to `"button"`. Replaces the * pre-spike `render` prop (axis G). */ as?: ValidComponent; id?: string | undefined; name?: string | undefined; form?: string | undefined; /** * Controlled checked state. When provided (resolved value not * `undefined`), the consumer owns the state — pair with * {@link onCheckedChange}. When omitted, the checkbox manages its own * checked state (seeded from {@link defaultChecked}). Inside a * `` a checkbox with a `value` derives its checked state * from the group's value array instead. */ checked?: MaybeAccessor; /** * Initial checked state when uncontrolled. Read once at mount. Inside a * `` with a `defaultValue`, a checkbox with a `value` * seeds from `defaultValue.includes(value)` instead. * @default false */ defaultChecked?: MaybeAccessor; disabled?: boolean | undefined; onCheckedChange?: | ((checked: boolean, eventDetails: CheckboxRootChangeEventDetails) => void) | undefined; readOnly?: MaybeAccessor; required?: MaybeAccessor; indeterminate?: MaybeAccessor; value?: string | undefined; uncheckedValue?: string | undefined; parent?: boolean | undefined; } /** * The checkbox root. Renders a `