import { ContextTrinity } from "../createTrinity/index.mjs"; import { ComputedRef, MaybeRefOrGetter, Ref, ShallowRef, WritableComputedRef } from "vue"; //#region src/composables/createRating/index.d.ts type RatingItemState = 'full' | 'half' | 'empty'; interface RatingItemDescriptor { /** 1-based position */ value: number; /** Derived visual state */ state: RatingItemState; } interface RatingContext { /** Current rating, clamped to 0–size */ value: WritableComputedRef; /** Total items */ size: number; /** Whether half-steps are enabled */ half: boolean; /** Array of items with computed state */ items: ComputedRef; /** Whether value is at minimum (0) */ isFirst: Readonly>; /** Whether value is at maximum (size) */ isLast: Readonly>; /** Set rating to specific value */ select: (value: number) => void; /** Increment by step (1 or 0.5) */ next: () => void; /** Decrement by step (1 or 0.5) */ prev: () => void; /** Set to 0 */ first: () => void; /** Set to size */ last: () => void; } interface RatingOptions { /** Initial value or ref for v-model. @default 0 */ value?: number | ShallowRef; /** Total items. @default 5 */ size?: MaybeRefOrGetter; /** Enable 0.5 step increments. @default false */ half?: MaybeRefOrGetter; } interface RatingContextOptions extends RatingOptions { /** Namespace for dependency injection */ namespace?: string; } /** * Creates a rating instance. * * @param options The options for the rating instance. * @returns A rating context with navigation methods. * * @example * ```ts * import { createRating } from '@vuetify/v0' * * // Basic usage * const rating = createRating() * rating.select(3) * rating.items.value // [{ value: 1, state: 'full' }, ...] * * // With v-model (pass a ref) * const value = shallowRef(0) * const rating = createRating({ value }) * ``` */ declare function createRating(_options?: RatingOptions): R; /** * Creates a rating context for dependency injection. * * @param options The options including namespace. * @returns A trinity: [useRating, provideRating, defaultContext] * * @example * ```ts * const [useRating, provideRatingContext] = createRatingContext({ size: 5 }) * * // Parent component * provideRatingContext() * * // Child component * const rating = useRating() * rating.select(4) * ``` */ declare function createRatingContext(_options?: RatingContextOptions): ContextTrinity; /** * Returns the current rating instance from context. * * @param namespace The namespace. @default 'v0:rating' * @returns The rating context. * * @example * ```vue * * * * ``` */ declare function useRating(namespace?: string): R; //#endregion export { RatingContext, RatingContextOptions, RatingItemDescriptor, RatingItemState, RatingOptions, createRating, createRatingContext, useRating };