UNPKG

@carbon/react

Version:

React components for the Carbon Design System

79 lines (78 loc) 3.04 kB
/** * Copyright IBM Corp. 2016, 2025 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ import PropTypes from 'prop-types'; import { KeyboardEvent, MouseEvent } from 'react'; import type { TranslateWithId } from '../../types/common'; export interface ListBoxSelectionProps extends TranslateWithId<TranslationKey> { /** * Specify a function to be invoked when a user interacts with the clear * selection element. */ clearSelection(event: MouseEvent<HTMLDivElement> | KeyboardEvent<HTMLDivElement>): void; /** * Specify whether or not the clear selection element should be disabled */ disabled?: boolean; /** * Specify an optional `onClearSelection` handler that is called when the underlying * element is cleared */ onClearSelection?(event: MouseEvent<HTMLDivElement> | KeyboardEvent<HTMLDivElement>): void; /** * Whether or not the Dropdown is readonly */ readOnly?: boolean; /** * Specify an optional `selectionCount` value that will be used to determine * whether the selection should display a badge or a single clear icon. */ selectionCount?: number; } export type ListBoxSelectionComponent = typeof ListBoxSelection; declare const translationIds: { readonly 'clear.all': "clear.all"; readonly 'clear.selection': "clear.selection"; }; type TranslationKey = keyof typeof translationIds; /** * `ListBoxSelection` is used to provide controls for clearing a selection, in * addition to conditionally rendering a badge if the control has more than one * selection. */ declare const ListBoxSelection: { ({ clearSelection, selectionCount, translateWithId: t, disabled, onClearSelection, readOnly, }: ListBoxSelectionProps): import("react/jsx-runtime").JSX.Element; propTypes: { /** * Specify a function to be invoked when a user interacts with the clear * selection element. */ clearSelection: PropTypes.Validator<(...args: any[]) => any>; /** * Specify whether or not the clear selection element should be disabled */ disabled: PropTypes.Requireable<boolean>; /** * Specify an optional `onClearSelection` handler that is called when the underlying * element is cleared */ onClearSelection: PropTypes.Requireable<(...args: any[]) => any>; /** * Whether or not the Dropdown is readonly */ readOnly: PropTypes.Requireable<boolean>; /** * Specify an optional `selectionCount` value that will be used to determine * whether the selection should display a badge or a single clear icon. */ selectionCount: PropTypes.Requireable<number>; /** * Translates component strings using your i18n tool. */ translateWithId: PropTypes.Requireable<(...args: any[]) => any>; }; }; export default ListBoxSelection;