UNPKG

mithril-materialized

Version:
66 lines (65 loc) 2.46 kB
import m, { FactoryComponent, Attributes } from 'mithril'; /** Rating component size options */ export type RatingSize = 'small' | 'medium' | 'large'; /** Rating component density options */ export type RatingDensity = 'compact' | 'standard' | 'comfortable'; /** Custom icon configuration */ export interface RatingIconConfig { /** Custom filled icon component or string */ filled?: string | m.Component; /** Custom empty icon component or string */ empty?: string | m.Component; /** Custom half-filled icon component or string (for fractional ratings) */ half?: string | m.Component; } /** Rating component attributes */ export interface RatingAttrs extends Attributes { /** Current rating value */ value?: number; /** Maximum rating value (default: 5) */ max?: number; /** Step size for rating increments (default: 1, can be 0.5 for half-steps) */ step?: number; /** Initial value for uncontrolled mode */ defaultValue?: number; /** Whether the rating is read-only */ readonly?: boolean; /** Whether the rating is disabled */ disabled?: boolean; /** Whether the rating can be cleared/reset to 0 */ clearable?: boolean; /** Size variant */ size?: RatingSize; /** Density variant */ density?: RatingDensity; /** Custom icon configuration */ icon?: RatingIconConfig; /** Class name for the container */ className?: string; /** Additional CSS styles */ style?: any; /** Callback when rating changes */ onchange?: (value: number) => void; /** Callback when rating is hovered (preview mode) */ onmouseover?: (value: number) => void; /** Function to get label text for accessibility */ getLabelText?: (value: number, max: number) => string; /** Whether to show tooltips on hover */ showTooltips?: boolean; /** Custom tooltip labels for each rating value */ tooltipLabels?: string[]; /** Whether to allow fractional display (e.g., 3.5 stars) */ allowHalfSteps?: boolean; /** Name for form submission */ name?: string; /** HTML ID for the component */ id?: string; /** ARIA label for the component */ 'aria-label'?: string; /** ARIA label for the component (camelCase alternative) */ ariaLabel?: string; /** ARIA labelledby reference */ 'aria-labelledby'?: string; } /** Create a Rating component */ export declare const Rating: FactoryComponent<RatingAttrs>;