design-react-kit
Version:
Componenti React per Bootstrap 5
37 lines (36 loc) • 1.96 kB
TypeScript
import { FC, ReactNode } from 'react';
import type { InputProps } from '../Input/Input';
type UnusedProps = 'bsSize' | 'size' | 'static' | 'plaintext' | 'normalized' | 'addon' | 'placeholder' | 'label' | 'value' | 'type';
export interface RatingProps extends Omit<InputProps, UnusedProps> {
/** La lista di 5 id, per ciascun elemento intero del Rating. La lista deve essere ordinata dal rating 1 al rating 5. */
inputs: string[];
/** Il campo "label" è impostato di default su "Valuta ${n} stelle su 5", ma può essere personalizzato con questa funzione che riceve il numero input come argomento `function (n: number) => string`. */
labelTemplate?: (value: 1 | 2 | 3 | 4 | 5) => string;
/** Da utilizzare in caso legenda principale del Rating. Passare una componente React da mostrare come legenda (all'interno del tag `<legend>`). È possibile mostrare la leggenda solo ai dispositivi screen reader */
legend?: ReactNode | {
content: ReactNode;
srOnly: boolean;
};
/** Parametro name da dare all'input */
name: string;
/** Classi aggiuntive da usare per il componente wrapper del Rating */
wrapperClassName?: string;
/** Classi aggiuntive da usare per ciascun elemento all'interno del componente Rating */
className?: string;
/** Callback chiamata ad ogni cambio di valore di rating. Il nuovo valore ed il name verranno passati: `function (n, name) => void` */
onChangeRating?: (value: 1 | 2 | 3 | 4 | 5 | number, name: string) => void;
/** Rende il componente read-only */
readOnly?: boolean;
/** Il valore corrente del componente: deve essere compreso tra 1 e 5 */
value?: 1 | 2 | 3 | 4 | 5 | number;
testId?: string;
}
export declare const isCustomLegendObject: (legend: ReactNode | {
content: ReactNode;
srOnly: boolean;
}) => legend is {
content: ReactNode;
srOnly: boolean;
};
export declare const Rating: FC<RatingProps>;
export {};