UNPKG

primereact

Version:

PrimeReact is an open source UI library for React featuring a rich set of 90+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with Prime

211 lines (203 loc) 6.41 kB
/** * * SelectButton is used to choose single or multiple items from a list using buttons. * * [Live Demo](https://www.primereact.org/selectbutton/) * * @module selectbutton * */ import * as React from 'react'; import { ComponentHooks } from '../componentbase/componentbase'; import { PassThroughOptions } from '../passthrough'; import { SelectItemOptionsType } from '../selectitem/selectitem'; import { TooltipPassThroughOptions } from '../tooltip/tooltip'; import { TooltipOptions } from '../tooltip/tooltipoptions'; import { FormEvent } from '../ts-helpers'; import { PassThroughType } from '../utils/utils'; export declare type SelectButtonPassThroughType<T> = PassThroughType<T, SelectButtonPassThroughMethodOptions>; /** * Custom passthrough(pt) option method. */ export interface SelectButtonPassThroughMethodOptions { props: SelectButtonProps; context: SelectButtonContext; } /** * Custom passthrough(pt) options. * @see {@link SelectButtonProps.pt} */ export interface SelectButtonPassThroughOptions { /** * Uses to pass attributes to the root's DOM element. */ root?: SelectButtonPassThroughType<React.HTMLAttributes<HTMLDivElement>>; /** * Uses to pass attributes to the button's DOM element. */ button?: SelectButtonPassThroughType<React.HTMLAttributes<HTMLDivElement>>; /** * Uses to pass attributes to the label's DOM element. */ label?: SelectButtonPassThroughType<React.HTMLAttributes<HTMLSpanElement>>; /** * Uses to pass attributes tooltip's DOM element. * @type {TooltipPassThroughOptions} */ tooltip?: TooltipPassThroughOptions; /** * Used to manage all lifecycle hooks * @see {@link ComponentHooks} */ hooks?: ComponentHooks; } /** * Defines current options in SelectButton component. */ export interface SelectButtonContext { /** * Current selected value of the item as a boolean. * @defaultValue false */ selected: boolean; /** * Current disabled value of option or disabled property as a boolean. * @defaultValue false */ disabled: boolean; /** * Available option. */ option: any; } /** * Custom change event. * @see {@link SelectButtonProps.onChange} * @extends {FormEvent} * @event */ interface SelectButtonChangeEvent extends FormEvent {} /** * Defines valid properties in SelectButton component. In addition to these, all properties of HTMLDivElement can be used in this component. * @group Properties */ export interface SelectButtonProps extends Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'unselectable' | 'onChange' | 'ref' | 'pt'> { /** * Value of the component. */ value?: any | undefined; /** * An array of objects to display as the available options. */ options?: SelectItemOptionsType | undefined; /** * Name of the label field of an option when an arbitrary objects instead of SelectItems are used as options. */ optionLabel?: string | undefined; /** * Name of the value field of an option when arbitrary objects are used as options instead of SelectItems. */ optionValue?: string | undefined; /** * Property name or getter function to use as the disabled flag of an option, defaults to false when not defined. */ optionDisabled?: string | ((option: any) => boolean); /** * Index of the element in tabbing order. */ tabIndex?: number | undefined; /** * When specified, allows selecting multiple values. * @defaultValue false */ multiple?: boolean | undefined; /** * When present, it specifies that the component should have invalid state style. * @defaultValue false */ invalid?: boolean | undefined; /** * Whether selection can be cleared. * @deprecated Use 'allowEmpty' property instead. * @defaultValue true */ unselectable?: boolean | undefined; /** * Whether selection can not be cleared. * @defaultValue true */ allowEmpty?: boolean | undefined; /** * When present, it specifies that the element should be disabled. * @defaultValue false */ disabled?: boolean | undefined; /** * A property to uniquely match the value in options for better performance. */ dataKey?: string | undefined; /** * Content of the tooltip. */ tooltip?: string | undefined; /** * Configuration of the tooltip, refer to the tooltip documentation for more information. */ tooltipOptions?: TooltipOptions | undefined; /** * Establishes relationships between the component and label(s) where its value should be one or more element IDs. */ ariaLabelledBy?: string | undefined; /** * Function that gets the option and returns the content. * @param {*} item - Current item */ itemTemplate?(item: any): React.ReactNode; /** * Callback to invoke on value change. * @param {SelectButtonChangeEvent} event - Custom change event. */ onChange?(event: SelectButtonChangeEvent): void; /** * Used to get the child elements of the component. * @readonly */ children?: React.ReactNode | undefined; /** * Uses to pass attributes to DOM elements inside the component. * @type {SelectButtonPassThroughOptions} */ pt?: SelectButtonPassThroughOptions; /** * Used to configure passthrough(pt) options of the component. * @type {PassThroughOptions} */ ptOptions?: PassThroughOptions; /** * When enabled, it removes component related styles in the core. * @defaultValue false */ unstyled?: boolean; } /** * **PrimeReact - SelectButton** * * _SelectButton is used to choose single or multiple items from a list using buttons._ * * [Live Demo](https://www.primereact.org/selectbutton/) * --- --- * ![PrimeReact](https://primefaces.org/cdn/primereact/images/logo-100.png) * * @group Component */ export declare class SelectButton extends React.Component<SelectButtonProps, any> { /** * Used to get container element. * @return {HTMLDivElement | null} Container element */ public getElement(): HTMLDivElement | null; /** * Used to focus the component. */ public focus(): void; }