UNPKG

@carbon/react

Version:

React components for the Carbon Design System

51 lines (50 loc) 1.83 kB
/** * Copyright IBM Corp. 2016, 2023 * * 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 React from 'react'; import { KeyboardEvent, MouseEvent } from 'react'; import { 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 = React.FC<ListBoxSelectionProps>; export declare const translationIds: { readonly 'clear.all': "clear.all"; readonly 'clear.selection': "clear.selection"; }; /** * Message ids that will be passed to translateWithId(). */ 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: ListBoxSelectionComponent; export default ListBoxSelection;