UNPKG

@yamada-ui/react

Version:

React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion

115 lines (114 loc) 3.47 kB
import { HTMLProps, PropGetter } from "../../core/components/index.types.js"; import "../../core/index.js"; import { FieldProps } from "../field/field.js"; import * as react96 from "react"; //#region src/components/rating/use-rating.d.ts interface RatingContext extends Omit<UseRatingReturn, "getRootProps"> {} declare const RatingContext: react96.Context<RatingContext>, useRatingContext: () => RatingContext; interface UseRatingProps extends FieldProps, Omit<HTMLProps, "color" | "defaultValue" | "onChange"> { /** * The top-level id string that will be applied to the rating. * The index of the rating item will be appended to this top-level id. */ id?: string; /** * The name of the input element. */ name?: string; /** * Number of controls that should be rendered. * * @default 5 */ count?: number; /** * The initial value of the rating. * * @default 0 */ defaultValue?: number; /** * Number of fractions each item can be divided into, * * @default 1 */ fractions?: number; /** * If `true`, only the selected icons will be filled. * * @default false */ highlightSelectedOnly?: boolean; /** * The value of the rating. */ value?: number; /** * The callback invoked when value state changes. */ onChange?: (value: number) => void; /** * The callback invoked when hovering over the rating. */ onHover?: (value: number) => void; } declare const useRating: (props?: UseRatingProps) => { id: string; name: string; count: number; decimal: number; disabled: boolean | undefined; displayValue: number; fractions: number; highlightSelectedOnly: boolean; hoveredValue: number; interactive: boolean; outsideRef: react96.RefObject<boolean>; readOnly: boolean | undefined; required: boolean | undefined; roundedValue: number; setHoveredValue: react96.Dispatch<react96.SetStateAction<number>>; setValue: react96.Dispatch<react96.SetStateAction<number>>; value: number; ariaProps: { "aria-describedby": string; "aria-disabled": (boolean | "true" | "false") | undefined; "aria-invalid": (boolean | "true" | "false") | undefined; "aria-readonly": (boolean | "true" | "false") | undefined; "aria-required": (boolean | "true" | "false") | undefined; }; dataProps: { "data-disabled": string | undefined; "data-invalid": string | undefined; "data-readonly": string | undefined; "data-required": string | undefined; }; eventProps: { onBlur: (ev: react96.FocusEvent<HTMLDivElement, Element>) => void; onFocus: (ev: react96.FocusEvent<HTMLDivElement, Element>) => void; }; getRootProps: PropGetter<"div", undefined, undefined>; }; type UseRatingReturn = ReturnType<typeof useRating>; interface UseRatingItemProps extends HTMLProps<"label"> { groupValue: number; index: number; } declare const useRatingItem: ({ groupValue, index, ...rest }: UseRatingItemProps) => { active: boolean; checked: boolean; filled: boolean; fractionValue: number; groupValue: number; value: number; getInputProps: PropGetter<"input", undefined, undefined>; getLabelProps: PropGetter<"label", undefined, undefined>; }; type UseRatingItemReturn = ReturnType<typeof useRatingItem>; //#endregion export { RatingContext, UseRatingItemProps, UseRatingItemReturn, UseRatingProps, UseRatingReturn, useRating, useRatingContext, useRatingItem }; //# sourceMappingURL=use-rating.d.ts.map