import React from 'react'; import { UniqueIdentifier } from '@dnd-kit/core'; import PropTypes from 'prop-types'; import { HeadAutosizeColumnHandler, HeadRequestMoveColumnHandler, HeadRequestResizeColumnHandler } from './Head'; import { ComponentProps } from '../utils/types'; type HeadCellAutosizeColumnHandler = HeadAutosizeColumnHandler; type HeadCellKeyDownHandler = (event: React.KeyboardEvent, data: { columnId?: string; index: number; }) => void; type HeadCellRequestMoveColumnHandler = HeadRequestMoveColumnHandler; /** @public */ type HeadCellSortDir = 'asc' | 'desc' | 'none'; /** @public */ type HeadCellSortHandler = (event: React.MouseEvent | React.KeyboardEvent, data: { columnId?: string; id?: string; index: number; sortDir: HeadCellSortDir; sortKey?: string; }) => void; type HeadCellRequestResizeHandler = HeadRequestResizeColumnHandler; interface HeadCellPropsBase { /** Align the text in the label. */ align?: 'left' | 'center' | 'right'; /** @private Used to set the $clickable appearance without an onClick */ appearClickable?: boolean; children?: React.ReactNode; /** * An id that is passed to the `onSort` callback and as `Table`'s `onRequestResizeColumn` callback. */ columnId?: string; /** @private. */ dragId?: UniqueIdentifier; /** * A React ref which is set to the DOM element when the component mounts and null when it unmounts. */ elementRef?: React.Ref; /** * A string used to generate the `aria-label` for the head cell during column reordering. * * When the `children` prop is not a string, providing `headCellScreenReaderText` is recommended * to improve the screen reader announcements during the reordering interaction. */ headCellScreenReaderText?: string; /** @private The index of the cell, skipping the info column. */ index?: number; /** @private. */ isPinned?: boolean; /** @private. */ onAutosizeColumn?: HeadCellAutosizeColumnHandler; /** * A callback invoked when this head cell is clicked. If provided, this HeadCell is * sortable and renders the appropriate user interface. */ onSort?: HeadCellSortHandler; /** * @private. Passed through and works as expected. */ onKeyDown?: HeadCellKeyDownHandler; /** @private. */ onClick?: () => void; /** @private. */ onRequestMoveColumn?: HeadCellRequestMoveColumnHandler; /** @private. */ onRequestResize?: HeadCellRequestResizeHandler; /** * Allows the user to resize the column when onRequestResize is passed to the `Table`. Set * resizable to `false` to prevent some columns for resizing. */ resizable?: boolean; /** * The current sort direction of this column. */ sortDir?: HeadCellSortDir; /** * The `sortKey` is passed in the data object to the `onSort` callback, if provided. */ sortKey?: string; /** * Content to show in a tooltip. */ tooltip?: React.ReactNode; /** * Truncate the text in the label. */ truncate?: boolean; /** * @private * Used internally to suppress focus and id when this `HeadCell` is superseded by one in an * overlaid `HeadTable` for user interactions. */ visible?: boolean; /** * The width of the column in pixels. */ width?: number | 'auto'; /** @private. */ variant?: 'toggleAll' | 'info' | 'actions'; } type HeadCellProps = ComponentProps; declare function HeadCell({ align, appearClickable, children, columnId, elementRef, dragId, headCellScreenReaderText, id, index, isPinned, onAutosizeColumn, onClick, onKeyDown, onRequestMoveColumn, onRequestResize, onSort, resizable, sortDir, sortKey, style, tooltip, truncate: truncateProp, variant, visible, width, ...otherProps }: HeadCellProps): React.JSX.Element; declare namespace HeadCell { var propTypes: { align: PropTypes.Requireable; /** @private Used to set the $clickable appearance without an onClick */ appearClickable: PropTypes.Requireable; children: PropTypes.Requireable; columnId: PropTypes.Requireable; /** @private. */ dragId: PropTypes.Requireable>; elementRef: PropTypes.Requireable; headCellScreenReaderText: PropTypes.Requireable; /** @private The index of the cell, skipping the info column. */ index: PropTypes.Requireable; /** @private. */ isPinned: PropTypes.Requireable; /** @private. */ onAutosizeColumn: PropTypes.Requireable<(...args: any[]) => any>; /** @private. */ onClick: PropTypes.Requireable<(...args: any[]) => any>; /** * @private. Passed through and works as expected. */ onKeyDown: PropTypes.Requireable<(...args: any[]) => any>; /** @private. */ onRequestMoveColumn: PropTypes.Requireable<(...args: any[]) => any>; /** @private. */ onRequestResize: PropTypes.Requireable<(...args: any[]) => any>; onSort: PropTypes.Requireable<(...args: any[]) => any>; resizable: PropTypes.Requireable; sortDir: PropTypes.Requireable; sortKey: PropTypes.Requireable; tooltip: PropTypes.Requireable; truncate: PropTypes.Requireable; /** @private. */ variant: PropTypes.Requireable; /** * Used internally to suppress focus and id when this `HeadCell` is superseded by one in an * overlaid `HeadTable` for user interactions. * @private */ visible: PropTypes.Requireable; width: PropTypes.Requireable>; }; var splunkUiType: string; } export default HeadCell; export { HeadCellKeyDownHandler, HeadCellRequestMoveColumnHandler, HeadCellSortDir, HeadCellSortHandler, };