@carbon/react
Version:
React components for the Carbon Design System
40 lines (39 loc) • 1.5 kB
TypeScript
/**
* 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 React from 'react';
interface UseSelectionProps<ItemType> {
disabled?: boolean;
filteredItems?: ItemType[];
initialSelectedItems?: ItemType[];
onChange?: (data: {
selectedItems: ItemType[];
}) => void;
selectAll?: boolean;
selectedItems?: ItemType[];
}
export declare const useSelection: <ItemType>({ disabled, onChange, initialSelectedItems, selectedItems: controlledItems, selectAll, filteredItems, }: UseSelectionProps<ItemType>) => {
clearSelection: () => void;
onItemChange: (item: ItemType) => void;
toggleAll: (items: ItemType[]) => void;
selectedItems: ItemType[];
};
interface SelectionRenderProps<ItemType> {
clearSelection: () => void;
onItemChange: (item: ItemType) => void;
selectedItems: ItemType[];
}
interface SelectionProps<ItemType> {
children?: (renderProps: SelectionRenderProps<ItemType>) => React.ReactNode;
disabled?: boolean;
initialSelectedItems: ItemType[];
onChange?: (state: {
selectedItems: ItemType[];
}) => void;
render?: (renderProps: SelectionRenderProps<ItemType>) => React.ReactNode;
}
export declare const Selection: <ItemType>({ children, disabled, initialSelectedItems, onChange, render, }: SelectionProps<ItemType>) => import("react/jsx-runtime").JSX.Element | null;
export {};