import { Schema as S } from 'effect'; import { type Update } from 'foldkit'; import { type ChildAttribute, type Html } from 'foldkit/html'; import { type Reflect } from 'foldkit/submodel'; import * as Subscription from 'foldkit/subscription'; /** Schema for the slider component's private interaction state. The current * value is owned by the parent and passed in via `ViewInputs.value`, so it is * not stored here. `min`/`max`/`step` are configuration the drag subscription * reads to map pointer positions into values. `dragState` tracks the active * drag phase and captures the pre-drag value so Escape can restore it. */ export declare const Model: S.Struct<{ readonly id: S.String; readonly min: S.Number; readonly max: S.Number; readonly step: S.Number; readonly dragState: S.Union, import("foldkit/schema").CallableTaggedStruct<"Dragging", { originValue: S.Number; }>]>; }>; export type Model = typeof Model.Type; /** Union of all messages the slider component can produce. */ export declare const Message: import("foldkit/message").MessageUnion<{ readonly PressedThumb: { readonly originValue: S.Number; }; readonly PressedPointer: { readonly value: S.Number; readonly originValue: S.Number; }; readonly MovedDragPointer: { readonly value: S.Number; }; readonly ReleasedDragPointer: {}; readonly CancelledDrag: {}; readonly PressedKeyboardNavigation: { readonly direction: S.Literals; readonly value: S.Number; }; }>; export type Message = typeof Message.Type; export type PressedThumb = typeof Message.PressedThumb.Type; export type PressedPointer = typeof Message.PressedPointer.Type; export type MovedDragPointer = typeof Message.MovedDragPointer.Type; export type ReleasedDragPointer = typeof Message.ReleasedDragPointer.Type; export type CancelledDrag = typeof Message.CancelledDrag.Type; export type PressedKeyboardNavigation = typeof Message.PressedKeyboardNavigation.Type; /** Union of all out-messages the slider component can emit to its parent. */ export declare const OutMessage: import("foldkit/message").MessageUnion<{ readonly ChangedValue: { readonly value: S.Number; }; }>; export type OutMessage = typeof OutMessage.Type; /** Configuration for creating a slider model with `init`. */ export type InitConfig = Readonly<{ id: string; min: number; max: number; step: number; }>; /** Creates an initial slider model from a config. The value lives in the * parent Model; initialize it there and snap it with {@link snapAndClamp}. */ export declare const init: (config: InitConfig) => Model; /** Snaps a value to the nearest step and clamps it into `[min, max]`. Exported * so a parent can conform the value it owns to the slider's range, for example * when seeding the initial value or reacting to an external update. */ export declare const snapAndClamp: (value: number, min: number, max: number, step: number) => number; /** Computes the fraction (0–1) of a value between min and max. Returns 0 when * the range has zero width. */ export declare const fractionOfValue: (value: number, min: number, max: number) => number; /** Processes a Slider Message and returns the next Model, optional Commands, * and an optional OutMessage for the parent. The value lives in the parent * Model: the view supplies the current value on the Messages that need it, * and value changes surface as `ChangedValue` rather than mutating this * Model. */ export declare const update: (model: Model, message: Message) => Readonly<{ model: { readonly id: string; readonly min: number; readonly max: number; readonly step: number; readonly dragState: { readonly _tag: "Idle"; } | { readonly _tag: "Dragging"; readonly originValue: number; }; }; commands?: Update.Commands<{ readonly _tag: "CancelledDrag"; } | { readonly _tag: "PressedThumb"; readonly originValue: number; } | { readonly _tag: "PressedPointer"; readonly value: number; readonly originValue: number; } | { readonly _tag: "MovedDragPointer"; readonly value: number; } | { readonly _tag: "ReleasedDragPointer"; } | { readonly _tag: "PressedKeyboardNavigation"; readonly direction: "Max" | "Min" | "StepDecrement" | "StepIncrement" | "PageDecrement" | "PageIncrement"; readonly value: number; }, never>; outMessage?: { readonly _tag: "ChangedValue"; readonly value: number; }; }>; /** Reflects an externally-driven range onto the slider. Use this when min/max * derive from external state (e.g. a bounded buffer whose first/last index * shifts over time). The parent owns the value, so conform it to the new range * in the same update with {@link snapAndClamp}. */ export declare const reflectRange: Reflect>; /** Builds slider drag subscriptions, looking up the track * element through the supplied root resolver. Use this when the slider is * rendered inside a Shadow DOM. The root is read lazily so consumers can * resolve it at subscription time. */ export declare const subscriptionsForRoot: (getTrackRoot: () => Document | ShadowRoot) => { readonly dragPointer: Subscription.EntryWithoutKeepAlive<{ readonly id: string; readonly min: number; readonly max: number; readonly step: number; readonly dragState: { readonly _tag: "Idle"; } | { readonly _tag: "Dragging"; readonly originValue: number; }; }, { readonly _tag: "CancelledDrag"; } | { readonly _tag: "PressedThumb"; readonly originValue: number; } | { readonly _tag: "PressedPointer"; readonly value: number; readonly originValue: number; } | { readonly _tag: "MovedDragPointer"; readonly value: number; } | { readonly _tag: "ReleasedDragPointer"; } | { readonly _tag: "PressedKeyboardNavigation"; readonly direction: "Max" | "Min" | "StepDecrement" | "StepIncrement" | "PageDecrement" | "PageIncrement"; readonly value: number; }, { readonly dragActivity: "Idle" | "Active"; readonly id: string; readonly min: number; readonly max: number; }, never> & { readonly __subscription: never; }; readonly dragEscape: Subscription.EntryWithoutKeepAlive<{ readonly id: string; readonly min: number; readonly max: number; readonly step: number; readonly dragState: { readonly _tag: "Idle"; } | { readonly _tag: "Dragging"; readonly originValue: number; }; }, { readonly _tag: "CancelledDrag"; } | { readonly _tag: "PressedThumb"; readonly originValue: number; } | { readonly _tag: "PressedPointer"; readonly value: number; readonly originValue: number; } | { readonly _tag: "MovedDragPointer"; readonly value: number; } | { readonly _tag: "ReleasedDragPointer"; } | { readonly _tag: "PressedKeyboardNavigation"; readonly direction: "Max" | "Min" | "StepDecrement" | "StepIncrement" | "PageDecrement" | "PageIncrement"; readonly value: number; }, { readonly dragActivity: "Idle" | "Active"; }, never> & { readonly __subscription: never; }; }; /** Default drag subscriptions, with the track looked up via `document`. */ export declare const subscriptions: { readonly dragPointer: Subscription.EntryWithoutKeepAlive<{ readonly id: string; readonly min: number; readonly max: number; readonly step: number; readonly dragState: { readonly _tag: "Idle"; } | { readonly _tag: "Dragging"; readonly originValue: number; }; }, { readonly _tag: "CancelledDrag"; } | { readonly _tag: "PressedThumb"; readonly originValue: number; } | { readonly _tag: "PressedPointer"; readonly value: number; readonly originValue: number; } | { readonly _tag: "MovedDragPointer"; readonly value: number; } | { readonly _tag: "ReleasedDragPointer"; } | { readonly _tag: "PressedKeyboardNavigation"; readonly direction: "Max" | "Min" | "StepDecrement" | "StepIncrement" | "PageDecrement" | "PageIncrement"; readonly value: number; }, { readonly dragActivity: "Idle" | "Active"; readonly id: string; readonly min: number; readonly max: number; }, never> & { readonly __subscription: never; }; readonly dragEscape: Subscription.EntryWithoutKeepAlive<{ readonly id: string; readonly min: number; readonly max: number; readonly step: number; readonly dragState: { readonly _tag: "Idle"; } | { readonly _tag: "Dragging"; readonly originValue: number; }; }, { readonly _tag: "CancelledDrag"; } | { readonly _tag: "PressedThumb"; readonly originValue: number; } | { readonly _tag: "PressedPointer"; readonly value: number; readonly originValue: number; } | { readonly _tag: "MovedDragPointer"; readonly value: number; } | { readonly _tag: "ReleasedDragPointer"; } | { readonly _tag: "PressedKeyboardNavigation"; readonly direction: "Max" | "Min" | "StepDecrement" | "StepIncrement" | "PageDecrement" | "PageIncrement"; readonly value: number; }, { readonly dragActivity: "Idle" | "Active"; }, never> & { readonly __subscription: never; }; }; /** Attribute groups the slider component provides to the consumer's `toView` * callback. Each bundle carries the boundary's captured dispatch, so the * consumer can spread it directly into element attributes without manual * Message wrapping. */ export type SliderAttributes = Readonly<{ root: ReadonlyArray; track: ReadonlyArray; filledTrack: ReadonlyArray; thumb: ReadonlyArray; label: ReadonlyArray; hiddenInput: ReadonlyArray; }>; /** Per-render view inputs passed to `view` via `h.submodel`'s `viewInputs` field. */ export type ViewInputs = Readonly<{ /** The current value, read straight from the parent Model. The thumb * position, `aria-valuenow`, and the filled track all derive from it. */ value: number; toView: (attributes: SliderAttributes) => Html; ariaLabel?: string; ariaLabelledBy?: string; formatValue?: (value: number) => string; /** Marks the Slider unavailable with `aria-disabled="true"` and * `data-disabled`. The thumb remains focusable, following Foldkit's * convention that unavailable controls stay discoverable by keyboard and * assistive technology. */ isDisabled?: boolean; /** Prevents value changes while exposing read-only semantics with * `aria-readonly="true"` and `data-readonly`. The thumb remains focusable. * Independent of `isDisabled`: setting both emits both attribute sets, and * either one removes the pointer and keyboard handlers. * * A drag already in flight is not interrupted. The handlers this flag * removes are what start a drag, and the pointermove Subscription runs off * `dragState` in the Model until pointerup. `isDisabled` behaves the same * way. */ isReadOnly?: boolean; name?: string; /** Resolves the root that holds the slider track when looking it up by its * `data-slider-track-id` attribute. Defaults to `document`. Provide a * ShadowRoot when rendering the slider inside a shadow tree so pointer * events on the track can map clientX into a value. */ getTrackRoot?: () => Document | ShadowRoot; }>; /** Renders an accessible slider by building ARIA attribute groups and * delegating layout to the consumer's `toView` callback. Follows the * WAI-ARIA slider pattern: role="slider" on the thumb, aria-valuemin / * aria-valuemax / aria-valuenow, keyboard navigation by step / page / home / * end. Pointer drag is handled by the component's drag subscriptions. */ export declare const view: import("foldkit/submodel").View<{ readonly id: string; readonly min: number; readonly max: number; readonly step: number; readonly dragState: { readonly _tag: "Idle"; } | { readonly _tag: "Dragging"; readonly originValue: number; }; }, { readonly _tag: "CancelledDrag"; } | { readonly _tag: "PressedThumb"; readonly originValue: number; } | { readonly _tag: "PressedPointer"; readonly value: number; readonly originValue: number; } | { readonly _tag: "MovedDragPointer"; readonly value: number; } | { readonly _tag: "ReleasedDragPointer"; } | { readonly _tag: "PressedKeyboardNavigation"; readonly direction: "Max" | "Min" | "StepDecrement" | "StepIncrement" | "PageDecrement" | "PageIncrement"; readonly value: number; }, Readonly<{ /** The current value, read straight from the parent Model. The thumb * position, `aria-valuenow`, and the filled track all derive from it. */ value: number; toView: (attributes: SliderAttributes) => Html; ariaLabel?: string; ariaLabelledBy?: string; formatValue?: (value: number) => string; /** Marks the Slider unavailable with `aria-disabled="true"` and * `data-disabled`. The thumb remains focusable, following Foldkit's * convention that unavailable controls stay discoverable by keyboard and * assistive technology. */ isDisabled?: boolean; /** Prevents value changes while exposing read-only semantics with * `aria-readonly="true"` and `data-readonly`. The thumb remains focusable. * Independent of `isDisabled`: setting both emits both attribute sets, and * either one removes the pointer and keyboard handlers. * * A drag already in flight is not interrupted. The handlers this flag * removes are what start a drag, and the pointermove Subscription runs off * `dragState` in the Model until pointerup. `isDisabled` behaves the same * way. */ isReadOnly?: boolean; name?: string; /** Resolves the root that holds the slider track when looking it up by its * `data-slider-track-id` attribute. Defaults to `document`. Provide a * ShadowRoot when rendering the slider inside a shadow tree so pointer * events on the track can map clientX into a value. */ getTrackRoot?: () => Document | ShadowRoot; }>>; //# sourceMappingURL=index.d.ts.map