import React from 'react'; import PropTypes from 'prop-types'; import { RowActionPrimaryClickHandler, RowActionSecondaryClickHandler, RowRequestToggleHandler } from '@splunk/react-ui/Table'; import { ComponentProps } from '../utils/types'; /** @public */ type RowRequestExpandHandler = (event: React.MouseEvent | React.KeyboardEvent, data?: any) => void; interface TreeGridRowPropsBase { /** * Adds primary actions. For best results, use an icon-only button style. * The `onClick` handler of each action is passed the event and the `data` prop of this row. */ actionPrimary?: React.ReactElement; /** * Adds a secondary actions dropdown menu. This prop must be a `Menu`. * The `onClick` handler of each action is passed the event and the `data` prop of this row. */ actionsSecondary?: React.ReactElement; /** * Must be `TreeGrid.Cell`. */ children?: React.ReactNode; /** * This data is returned with the row selection toggle event as the second argument. */ data?: any; /** * Indicates whether the row is disabled. */ disabled?: boolean; /** * A React ref which is set to the DOM element when the component mounts and null when it * unmounts. */ elementRef?: React.Ref; /** * Indicates whether the row is expanded. */ expanded?: boolean; /** * The row depth in the TreeGrid hierarchy. Root rows are level `1`. */ level: number; /** * Called when the expand/collapse button is clicked. Provide this prop to render the * hierarchy toggle for the row, and update the row's `expanded` state in response. */ onRequestExpand?: RowRequestExpandHandler; /** * Callback invoked when the row selection toggle is clicked. */ onRequestToggle?: RowRequestToggleHandler; /** * The row position within its current sibling set. * * TreeGrid uses this with `level` and `setSize` to expose the row's place in the hierarchy for assistive technology, * so parent, child, and sibling relationships are not conveyed only by visual indentation. * When omitted, TreeGrid infers this from the rendered rows in `TreeGrid.Body`, assuming the full sibling * set is loaded. * * Pass explicit `posInSet` values when rows are lazily loaded, virtualized, or the * rendered list omits siblings that still belong to the same set. */ posInSet?: number; /** * Indicates the row's label when selected or unselected. */ rowScreenReaderText?: string; /** * Indicates the row selection state. */ selected?: boolean | 'some'; /** * The total number of rows in the current sibling set. * * TreeGrid uses this with `level` and `posInSet` to expose the row's place in the hierarchy for assistive technology, * so parent, child, and sibling relationships are not conveyed only by visual indentation. * When omitted, TreeGrid infers this from the rendered rows in `TreeGrid.Body`, assuming the full sibling set is loaded. * * Pass explicit `setSize` values when rows are lazily loaded, virtualized, or the * rendered list omits siblings that still belong to the same set. */ setSize?: number; } type TreeGridRowProps = ComponentProps; declare function Row({ actionPrimary, actionsSecondary, children, data, disabled, elementRef, expanded, level, onRequestExpand, onRequestToggle, posInSet, rowScreenReaderText, selected, setSize, ...otherProps }: TreeGridRowProps): React.JSX.Element; declare namespace Row { var propTypes: { actionPrimary: PropTypes.Requireable; actionsSecondary: PropTypes.Requireable; children: PropTypes.Requireable; data: PropTypes.Requireable; disabled: PropTypes.Requireable; elementRef: PropTypes.Requireable; expanded: PropTypes.Requireable; level: PropTypes.Validator; onRequestExpand: PropTypes.Requireable<(...args: any[]) => any>; onRequestToggle: PropTypes.Requireable<(...args: any[]) => any>; posInSet: PropTypes.Requireable; rowScreenReaderText: PropTypes.Requireable; selected: PropTypes.Requireable; setSize: PropTypes.Requireable; }; } export default Row; export type { RowActionPrimaryClickHandler, RowActionSecondaryClickHandler, RowRequestExpandHandler, RowRequestToggleHandler, };