import React from 'react'; import '../../styles/base.module.css'; import { AllElementPropsWithoutRef } from '../../utils/elementTypings'; type Header = { /** * Boolean indicating whether a column is sortable */ isSortable?: boolean; /** * Key of header. Maps with the corresponding row data keys. */ key: string; /** * Visible header name that is rendered. */ headerName: string; /** * Sort icon type to be used in sorting. Use type string if the content is a string, otherwise use type other. * @default 'string' */ sortIconType?: 'string' | 'other'; /** * Transform function for the corresponding row data. Use this to render custom content inside the table cell. */ transform?: ({ args }: any) => string | React.JSX.Element; }; export interface TableCustomTheme { /** * Custom background color for the table caption. The caption needs a background of its own, so * that the horizontal scroll shadows are not shown through it. * @default 'var(--color-white)' */ '--caption-background-color'?: string; /** * Custom background color for table headers. */ '--header-background-color'?: string; /** * Custom background color for the table content. * @default 'var(--color-white)' */ '--content-background-color'?: string; } type SelectedRow = string | number; export type TableProps = AllElementPropsWithoutRef<'table'> & { /** * Aria-label for checkbox selection. * @default 'Rivin valinta' */ ariaLabelCheckboxSelection?: string; /** * Aria-label for sort button in ascending state. * @default 'Järjestetty nousevaan järjestykseen' */ ariaLabelSortButtonAscending?: string; /** * Aria-label for sort button in descending state. * @default 'Järjestetty laskevaan järjestykseen' */ ariaLabelSortButtonDescending?: string; /** * Aria-label for sort button in the unordered state. * @default '' */ ariaLabelSortButtonUnset?: string; /** * Caption of the table. */ caption?: string | React.ReactNode; /** * Boolean indicating whether the table has the checkbox selection column to select rows. * @default false */ checkboxSelection?: boolean; /** * Text for clear selected rows button. * @default 'Tyhjennä valinnat' */ clearSelectionsText?: string; /** * Columns of the table header row. Defines header name, optional sort icon type and optional cell row transform function. */ cols: Array
; /** * Custom action buttons to place on top of the table. */ customActionButtons?: React.ReactNode[]; /** * Boolean indicating whether to use the dense variant of the table. * @default false */ dense?: boolean; /** * Table heading. */ heading?: string; /** * Table heading aria level. */ headingAriaLevel?: number; /** * A custom class name passed to table heading. */ headingClassName?: string; /** * Table heading id. Used to name table to assistive technologies. Only applicable when heading prop is used. An id is created from the `id` prop or with `lodash.uniqueId`, if a value is not passed. */ headingId?: string; /** * Id that is passed to the native html table element and used as a prefix for the `id` attribute of the Checkbox component, if `checkboxSelection` is `true`. An unique id for the checkbox is created, if a value is not passed. */ id?: string; /** * Column key used as a unique identifier for a row */ indexKey: string; /** * Key indicating a column that you wish to be initially sorted. Use undefined to have no column initially sorted. */ initialSortingColumnKey?: string; /** * Sorting order applied for initial sorting. */ initialSortingOrder?: 'asc' | 'desc'; /** * Function for providing side effects before or after the sort. If you want to use the component's own sorting function, call the handleSort callback function. * @param order * @param colKey * @param handleSort */ onSort?: (order: 'asc' | 'desc', colKey: string, handleSort: () => void) => void; /** * Boolean indicating whether index column is rendered in the table. * @default true */ renderIndexCol?: boolean; /** * Table rows. An array of objects where keys map with the keys of col. */ rows: Array; /** * Text for the select all rows button. * @default 'Valitse kaikki rivit' */ selectAllRowsText?: string; /** * Selected table rows. */ selectedRows?: SelectedRow[]; /** * Callback that updates selected rows. */ setSelectedRows?: React.Dispatch>; /** * Boolean indicating whether table data cell text content is aligned right. Default is false -> text is aligned left. * @default false */ textAlignContentRight?: boolean; /** * Custom theme to change table header background color. */ theme?: TableCustomTheme; /** * Table variant. Use dark for dark brand background colors, and light for light brand background colors. * @default 'dark' */ variant?: 'dark' | 'light'; /** * Vertical headers of the table. */ verticalHeaders?: Array
; /** * Boolean indicating whether the table has vertical lines on columns */ verticalLines?: boolean; /** * Boolean indicating whether the outer border of the table is left out. The lines inside the * table are not affected. Use this when the table is placed inside an element that already has a * border of its own. * @default false */ withoutOuterBorder?: boolean; /** * Boolean indicating whether the table has alternating row colors zebra style. */ zebra?: boolean; }; export declare const Table: ({ ariaLabelCheckboxSelection, ariaLabelSortButtonAscending, ariaLabelSortButtonDescending, ariaLabelSortButtonUnset, caption, checkboxSelection, clearSelectionsText, cols, customActionButtons, "data-testid": dataTestId, dense, heading, headingAriaLevel, headingClassName, headingId, id, indexKey, initialSortingColumnKey, initialSortingOrder, onSort, renderIndexCol, rows, selectAllRowsText, selectedRows, setSelectedRows, textAlignContentRight, theme, variant, verticalHeaders, verticalLines, withoutOuterBorder, zebra, ...rest }: TableProps) => React.JSX.Element; export {};