import { type Accessor, createContext, useContext } from "solid-js"; import type { BaseUIChangeEventDetails, BaseUIGenericEventDetails, REASONS, } from "../internals/change-event-details"; import type { CompositeMetadata } from "../internals/composite/composite-context.ts"; import type { FieldRootState } from "../internals/field-constants"; import type { ThumbCollisionBehavior } from "../internals/slider-utils/resolve-thumb-collision.ts"; import type { Orientation } from "../internals/types"; /** * Custom event-details properties carried on every slider `onValueChange`. */ export interface SliderRootChangeEventCustomProperties { activeThumbIndex: number; } export type SliderRootChangeEventReason = | typeof REASONS.inputChange | typeof REASONS.trackPress | typeof REASONS.drag | typeof REASONS.keyboard | typeof REASONS.none; export type SliderRootChangeEventDetails = BaseUIChangeEventDetails< SliderRootChangeEventReason, SliderRootChangeEventCustomProperties >; export type SliderRootCommitEventReason = SliderRootChangeEventReason; export type SliderRootCommitEventDetails = BaseUIGenericEventDetails; /** * State surface projected to `data-*` and visible to `class` / `style` / * `render` callbacks across every slider part. */ export interface SliderRootState extends FieldRootState { activeThumbIndex: number; disabled: boolean; dragging: boolean; max: number; min: number; minStepsBetweenValues: number; orientation: Orientation; step: number; values: readonly number[]; } /** * Per-thumb metadata carried through the CompositeList. The `inputId` lets * `` build a space-separated `htmlFor` list. */ export interface ThumbMetadata { inputId: string | undefined; } /** * Two-element tuple capturing the pixel-percent position of the first and * last thumb relative to the control's `getBoundingClientRect()`. Each slot * is `undefined` until the corresponding thumb has been measured. Only used * when `thumbAlignment !== 'center'` — center-mode sliders derive positions * from value math and skip the ResizeObserver pipeline entirely. */ export type IndicatorPosition = readonly [ number | undefined, number | undefined, ]; /** * Value handed down by `` to its compound parts. Reactive reads * are `Accessor` so descendants can subscribe precisely. * * The `inset` / `renderBeforeHydration` / `indicatorPosition` / * `setIndicatorPosition` fields match React's edge-alignment context surface. * The only piece still deferred is the pre-hydration `