react-star-picker
Version:
A star-rating component made with React
31 lines (26 loc) • 1.19 kB
TypeScript
import * as React from 'react';
type StarRendererFunction = (StarRendererProps: any) => React.ReactNode;
type SharedProps = {
/** if provided, replaces the default star-renderer */
starRenderer: StarRendererFunction;
/** whether to use half-star precision */
halfStars: boolean;
/** whether the input is disabled */
disabled: boolean;
};
type StarPickerProps = Partial<SharedProps> & {
/** function called with the selected value (and the input name) after a new pick */
onChange: (value: number | null, name?: string) => void;
/** current value of the input */
value: number | null;
/** input's name, supplied to the onChange function if provided */
name?: string;
className?: string;
/** number of stars in the input */
starCount?: number;
/** When true, selecting the existing rating clears the input */
resettable?: boolean;
};
declare const StarPicker: ({ value, onChange, name, className, starCount, disabled, halfStars, resettable, starRenderer, }: StarPickerProps) => React.JSX.Element;
declare const defaultStarRenderer: () => React.ReactNode;
export { StarPicker, StarPicker as default, defaultStarRenderer };