/** * createRating - the HEADLESS core behind : a controlled star-rating * control (WAI-ARIA `slider`) with hover preview, optional half steps, keyboard * (Arrows step, Home/End jump), and readonly/disabled - exposed as **prop-getters** * you spread onto YOUR OWN markup. * * ```svelte * *
* {#each Array(5) as _, i}{/each} *
* ``` * * The styled is just one renderer over this core. */ export type RatingFill = 'full' | 'half' | 'empty'; /** Reactive inputs are passed as getters so the core tracks live prop changes. */ export type RatingConfig = { value: () => number; onChange?: (value: number) => void; max?: () => number; allowHalf?: () => boolean; readonly?: () => boolean; disabled?: () => boolean; ariaLabel?: () => string | undefined; /** Accessible label for a star given its 1-based position (localizable). */ starLabel?: (position: number) => string | undefined; id?: () => string | undefined; invalid?: () => boolean; required?: () => boolean; error?: () => string | undefined; hint?: () => string | undefined; }; export type RatingRootProps = { role: 'slider'; id: string | undefined; tabindex: number; 'aria-label': string; 'aria-invalid': 'true' | undefined; 'aria-required': 'true' | undefined; 'aria-describedby': string | undefined; 'aria-valuenow': number; 'aria-valuemin': number; 'aria-valuemax': number; 'aria-readonly': boolean; onkeydown: (e: KeyboardEvent) => void; onpointerleave: () => void; }; export type RatingStarProps = { type: 'button'; tabindex: number; disabled: boolean; 'aria-label': string; 'data-fill': RatingFill; onpointermove: (e: PointerEvent) => void; onclick: (e: MouseEvent) => void; }; export type Rating = { /** The committed value. */ readonly value: number; /** What the stars should paint right now: the hover preview, else `value`. */ readonly preview: number; readonly max: number; readonly interactive: boolean; /** Fill state of the star at `index` given the current preview. */ fillOf: (index: number) => RatingFill; /** Set the hover preview (pass null to clear). No-op when non-interactive. */ setHover: (value: number | null) => void; /** Commit a value. No-op when non-interactive. */ pick: (value: number) => void; onKeydown: (e: KeyboardEvent) => void; /** Spread onto the container element. */ rootProps: () => RatingRootProps; /** Spread onto the star element at `index`. */ starProps: (index: number) => RatingStarProps; }; export declare function createRating(config: RatingConfig): Rating;