import type { IconDefinition } from '@mezzanine-ui/icons'; import type { DropdownOption } from '@mezzanine-ui/core/dropdown'; import type { Placement } from '@floating-ui/react-dom'; import type { ButtonVariant, ButtonIconType } from '@mezzanine-ui/core/button'; export declare const tablePrefix = "mzn-table"; export declare const tableLoadingPrefix = "mzn-table-loading"; export declare const tableHeaderPrefix = "mzn-table__header"; export declare const tableBodyPrefix = "mzn-table__body"; export declare const tableCellPrefix = "mzn-table__cell"; export declare const tableResizeHandlePrefix = "mzn-table__resize-handle"; export declare const tableClasses: { readonly actionsCell: "mzn-table__cell__actions"; readonly body: "mzn-table__body"; readonly bodyCell: "mzn-table__body__cell"; readonly bodyRow: "mzn-table__body__row"; readonly bodyRowAdding: "mzn-table__body__row--adding"; readonly bodyRowDeleting: "mzn-table__body__row--deleting"; readonly bodyRowDragging: "mzn-table__body__row--dragging"; readonly bodyRowFadingOut: "mzn-table__body__row--fading-out"; readonly bodyRowHighlight: "mzn-table__body__row--highlight"; readonly bodyRowSelected: "mzn-table__body__row--selected"; readonly bodyRowSeparator: "mzn-table__body__row--separator"; readonly bodyRowZebra: "mzn-table__body__row--zebra"; readonly bodyRowStateAdded: "mzn-table__body__row--state-added"; readonly bodyRowStateDeleted: "mzn-table__body__row--state-deleted"; readonly bodyRowStateDisabled: "mzn-table__body__row--state-disabled"; readonly bulkActions: "mzn-table__bulk-actions"; readonly bulkActionsFixed: "mzn-table__bulk-actions--fixed"; readonly bulkActionsSelectionSummary: "mzn-table__bulk-actions__selection-summary"; readonly bulkActionsActionArea: "mzn-table__bulk-actions__action-area"; readonly bulkActionsSeparator: "mzn-table__bulk-actions__separator"; readonly cell: "mzn-table__cell"; readonly cellAlignCenter: "mzn-table__cell--align-center"; readonly cellAlignEnd: "mzn-table__cell--align-end"; readonly cellAlignStart: "mzn-table__cell--align-start"; readonly cellContent: "mzn-table__cell__content"; readonly cellEllipsis: "mzn-table__cell--ellipsis"; readonly cellFixed: "mzn-table__cell--fixed"; readonly cellFixedEnd: "mzn-table__cell--fixed-end"; readonly cellFixedShadow: "mzn-table__cell--fixed-shadow"; readonly cellFixedStart: "mzn-table__cell--fixed-start"; readonly cellHighlight: "mzn-table__cell--highlight"; readonly main: "mzn-table--main"; readonly collectHandleIcon: "mzn-table__collect-handle-icon"; readonly dragOrPinHandle: "mzn-table__drag-or-pin-handle"; readonly dragOrPinHandleCell: "mzn-table__drag-or-pin-handle-cell"; readonly pinHandleIcon: "mzn-table__pin-handle-icon"; readonly empty: "mzn-table__empty"; readonly emptyRow: "mzn-table__empty-row"; readonly expandCell: "mzn-table__expand-cell"; readonly expandIcon: "mzn-table__expand-icon"; readonly expandIconExpanded: "mzn-table__expand-icon--expanded"; readonly expandedContent: "mzn-table__expanded-content"; readonly expandedRow: "mzn-table__expanded-row"; readonly expandedRowAdding: "mzn-table__expanded-row--adding"; readonly expandedRowCell: "mzn-table__expanded-row__cell"; readonly expandedRowDeleting: "mzn-table__expanded-row--deleting"; readonly expandedRowFadingOut: "mzn-table__expanded-row--fading-out"; readonly header: "mzn-table__header"; readonly headerCell: "mzn-table__header__cell"; readonly headerCellActions: "mzn-table__header__cell-actions"; readonly headerCellContent: "mzn-table__header__cell-content"; readonly headerCellFixed: "mzn-table__header__cell--fixed"; readonly headerCellTitle: "mzn-table__header__cell-title"; readonly headerCellIcon: "mzn-table__header__cell-icon"; readonly host: "mzn-table-host"; readonly resizeHandle: "mzn-table__resize-handle"; readonly root: "mzn-table"; readonly selectionCell: "mzn-table__selection-cell"; readonly selectionCheckbox: "mzn-table__selection-checkbox"; readonly sortIcon: "mzn-table__sort-icon"; readonly sortIconActive: "mzn-table__sort-icon--active"; readonly sortIcons: "mzn-table__sort-icons"; readonly sticky: "mzn-table--sticky"; readonly sub: "mzn-table--sub"; }; /** Generic record type for table data */ export type TableRecord = Record; /** Data source must have a unique key or id */ export interface TableDataSourceWithKey extends TableRecord { key: string; } export interface TableDataSourceWithId extends TableRecord { id: string; } export type TableDataSource = TableDataSourceWithKey | TableDataSourceWithId; /** Get row key from data source */ export declare function getRowKey(record: TableDataSource): string; /** * 欄位的排序方向。 * - `'ascend'` — 升冪排序 * - `'descend'` — 降冪排序 * - `null` — 無排序 */ export type SortOrder = 'ascend' | 'descend' | null; /** * 欄位內容的對齊方式。 * - `'start'` — 靠左對齊 * - `'center'` — 置中對齊 * - `'end'` — 靠右對齊 */ export type ColumnAlign = 'start' | 'center' | 'end'; /** * 滑鼠懸停時的高亮模式。 * - `'cell'` — 僅高亮單一儲存格 * - `'column'` — 高亮整欄 * - `'row'` — 高亮整列 * - `'cross'` — 同時高亮所在欄與列 */ export type HighlightMode = 'cell' | 'column' | 'row' | 'cross'; /** Fixed column position */ export type FixedType = boolean | 'start' | 'end'; /** * 表格的尺寸規格。 * - `'main'` — 主要尺寸(較大) * - `'sub'` — 次要尺寸(較小) */ export type TableSize = 'main' | 'sub'; /** * 資料列的語意狀態,用於覆蓋背景色。 * - `'added'` — 新增狀態 * - `'deleted'` — 刪除狀態 * - `'disabled'` — 停用狀態 */ export type TableRowState = 'added' | 'deleted' | 'disabled'; /** * Title menu configuration for table column header dropdown */ export interface TableColumnTitleMenu { /** Dropdown options */ options: DropdownOption[]; /** Callback when an option is selected */ onSelect?: (option: DropdownOption) => void; /** Maximum height of the dropdown list */ maxHeight?: number | string; /** Dropdown placement relative to trigger */ placement?: Placement; } /** * Column definition base interface */ export interface TableColumnBase { /** Column alignment */ align?: ColumnAlign; /** Custom class name for both header and body cells */ className?: string; /** Custom class name for body cells */ bodyClassName?: string; /** Data index to access the record value */ dataIndex?: string; /** Enable text ellipsis with tooltip * @default true */ ellipsis?: boolean; /** Fixed column position */ fixed?: FixedType; /** Custom class name for header cells */ headerClassName?: string; /** Unique key for the column */ key: string; /** Maximum column width */ maxWidth?: number; /** Minimum column width */ minWidth?: number; /** Callback when sort state changes */ onSort?: (key: string, order: SortOrder) => void; /** Custom render function for cell content */ render?: (record: T, index: number) => React.ReactNode; /** Controlled sort order */ sortOrder?: SortOrder; /** Column header title */ title?: React.ReactNode; /** Tooltip help text for header */ titleHelp?: React.ReactNode; /** Menu configuration for header dropdown */ titleMenu?: TableColumnTitleMenu; /** Column width in pixels */ width?: number; } export interface TableColumnBaseWithMinWidthRequired extends TableColumnBase { /** Minimum column width */ minWidth: number; } export interface TableColumnWithDataIndex extends TableColumnBase { /** Data index to access the record value */ dataIndex: string; render?: never; } export interface TableColumnWithDataIndexAndMinWidth extends TableColumnBaseWithMinWidthRequired { /** Data index to access the record value */ dataIndex: string; render?: never; } export interface TableColumnWithRender extends TableColumnBase { dataIndex?: never; /** Custom render function for cell content */ render: (record: T, index: number) => React.ReactNode; } export interface TableColumnWithRenderAndMinWidth extends TableColumnBaseWithMinWidthRequired { dataIndex?: never; /** Custom render function for cell content */ render: (record: T, index: number) => React.ReactNode; } export type TableColumn = TableColumnWithDataIndex | TableColumnWithRender; export type TableColumnWithMinWidth = TableColumnWithDataIndexAndMinWidth | TableColumnWithRenderAndMinWidth; /** * 資料列的選取模式。 * - `'checkbox'` — 多選模式 * - `'radio'` — 單選模式 */ export type TableSelectionMode = 'checkbox' | 'radio'; /** * action configuration for bulk actions (destructive or main action) */ export interface TableBulkGeneralAction { /** Icon for the destructive action button */ icon?: IconDefinition; /** Label for the destructive action button */ label: string; /** Callback when destructive action is clicked */ onClick: (selectedRowKeys: string[], selectedRows: T[]) => void; } /** * Overflow action configuration for bulk actions (dropdown menu) */ export interface TableBulkOverflowAction { /** Icon for the overflow action button */ icon?: IconDefinition; /** Label for the overflow action button */ label: string; /** Maximum height of the dropdown list */ maxHeight?: number | string; /** Callback when a dropdown option is selected */ onSelect: (option: DropdownOption, selectedRowKeys: string[], selectedRows: T[]) => void; /** Dropdown options */ options: DropdownOption[]; /** Dropdown placement relative to trigger */ placement?: Placement; } /** * Bulk actions configuration for row selection */ export interface TableBulkActions { /** Destructive action (optional, single action with separator) */ destructiveAction?: TableBulkGeneralAction; /** Main actions (required, at least one action) */ mainActions: [TableBulkGeneralAction, ...TableBulkGeneralAction[]]; /** Overflow action with dropdown menu (optional, with separator) */ overflowAction?: TableBulkOverflowAction; /** * Label for selection summary */ renderSelectionSummary?: (count: number, selectedRowKeys: string[], selectedRows: T[]) => string; } /** Base row selection configuration */ export interface TableRowSelectionBase { /** Fixed position of the selection column */ fixed?: boolean; /** Determine if the selection control is disabled for a row */ isSelectionDisabled?: (record: T) => boolean; } /** Checkbox mode row selection configuration */ export interface TableRowSelectionCheckbox extends TableRowSelectionBase { /** * Selection mode */ mode: 'checkbox'; /** Bulk actions configuration for batch operations */ bulkActions?: TableBulkActions; /** Get checkbox props for each row */ getCheckboxProps?: (record: T) => { indeterminate?: boolean; selected?: boolean; }; /** Hide select all checkbox in header */ hideSelectAll?: boolean; /** Callback when select all is triggered, function called after onChange */ onSelectAll?: (type: 'all' | 'none') => void; /** Preserve selected row keys when toggle select All even when data changes */ preserveSelectedRowKeys?: boolean; /** Callback when selection changes */ onChange: (selectedRowKeys: string[], selectedRow: T | null, selectedRows: T[]) => void; /** Array of selected row keys */ selectedRowKeys: string[]; } /** Radio mode row selection configuration */ export interface TableRowSelectionRadio extends TableRowSelectionBase { /** Selection mode */ mode: 'radio'; /** Callback when selection changes */ onChange: (selectedRowKey: string | undefined, selectedRow: T | null) => void; /** Selected row key */ selectedRowKey: string | undefined; /** Not available in radio mode */ getCheckboxProps?: never; /** Not available in radio mode */ hideSelectAll?: never; /** Not available in radio mode */ onSelectAll?: never; /** Not available in radio mode */ preserveSelectedRowKeys?: never; } /** Row selection configuration - discriminated union */ export type TableRowSelection = TableRowSelectionCheckbox | TableRowSelectionRadio; /** Scroll configuration */ export interface TableScroll { /** * Enable virtualized scrolling for large datasets. * When enabled, only visible rows are rendered for better performance. * Note: Cannot be used together with draggable rows. * @default false */ virtualized?: boolean; /** * Vertical scroll height constraint. * Sets max-height on scroll container. Required when virtualized is true. */ y?: number | string; } /** Draggable configuration */ export interface TableDraggable { /** Enable drag and drop */ enabled: boolean; /** Fixed position of drag handle column */ fixed?: boolean; /** Callback when drag ends */ onDragEnd?: (newDataSource: T[], options: { draggingId: string; fromIndex: number; toIndex: number; }) => void; } /** Pinnable configuration */ export interface TablePinnable { /** Enable pin to top functionality */ enabled: boolean; /** Fixed position of pin handle column */ fixed?: boolean; /** * Callback when pin state changes. * Users are responsible for sorting the dataSource based on pinned state. */ onPinChange: (record: T, pinned: boolean) => void; /** Array of pinned row keys */ pinnedRowKeys: string[]; } /** Toggleable configuration */ export interface TableToggleable extends Pick, 'title' | 'titleHelp' | 'titleMenu' | 'minWidth' | 'align'> { /** Enable toggle functionality */ enabled: boolean; /** Fixed position of toggle column */ fixed?: boolean; /** Check if a specific row's toggle is disabled */ isRowDisabled?: (record: T) => boolean; /** Callback when toggle state changes */ onToggleChange: (record: T, toggled: boolean) => void; /** Array of toggled row keys */ toggledRowKeys: string[]; } /** Collectable configuration */ export interface TableCollectable extends Pick, 'title' | 'titleHelp' | 'titleMenu' | 'minWidth' | 'align'> { /** Enable collect functionality */ enabled: boolean; /** Array of collected row keys */ collectedRowKeys: string[]; /** Fixed position of collect column */ fixed?: boolean; /** Check if a specific row's collect is disabled */ isRowDisabled?: (record: T) => boolean; /** Callback when collect state changes */ onCollectChange: (record: T, collected: boolean) => void; } /** Expandable configuration */ export interface TableExpandable { /** Render function for expanded row content */ expandedRowRender: (record: T) => React.ReactNode; /** Controlled expanded row keys */ expandedRowKeys?: string[]; /** Fixed position of expand icon column */ fixed?: boolean; /** Callback when single row expand state changes */ onExpand?: (expanded: boolean, record: T) => void; /** Callback when expanded rows change */ onExpandedRowsChange?: (expandedRowKeys: string[]) => void; /** Determine if a row is expandable */ rowExpandable?: (record: T) => boolean; } /** * Button action item configuration for table row actions */ export interface TableActionItemButton { /** Action type - button (default) */ type?: 'button'; /** Button label text */ name?: string; /** Button icon */ icon?: IconDefinition; /** Button icon type */ iconType?: ButtonIconType; /** Click handler - receives the row record and index */ onClick: (record: T, index: number) => void; /** Dynamic disabled state based on row data */ disabled?: (record: T) => boolean; /** Button custom variant */ variant?: ButtonVariant; } /** * Dropdown action item configuration for table row actions */ export interface TableActionItemDropdown { /** Action type - dropdown */ type: 'dropdown'; /** Button label text */ name?: string; /** Button icon * @default DotHorizontalIcon */ icon?: IconDefinition; /** Button icon type */ iconType?: ButtonIconType; /** Dropdown options */ options: DropdownOption[]; /** Callback when a dropdown option is selected */ onSelect: (option: DropdownOption, record: T, index: number) => void; /** Dynamic disabled state based on row data */ disabled?: (record: T) => boolean; /** Button custom variant */ variant?: ButtonVariant; /** Maximum height of the dropdown list */ maxHeight?: number | string; /** * Dropdown placement relative to trigger * @default 'bottom-end' */ placement?: Placement; } /** * Single action item configuration for table row actions. * Can be either a button or a dropdown. */ export type TableActionItem = TableActionItemButton | TableActionItemDropdown; /** * Base actions column configuration */ export interface TableActionsBase extends Omit, 'bodyClassName' | 'dataIndex' | 'ellipsis' | 'key' | 'onSort' | 'render' | 'sortOrder'> { /** Column alignment * @default 'end' */ align?: ColumnAlign; /** Function to generate action items for each row */ render: (record: T, index: number) => TableActionItem[]; /** Button variant for all action buttons in the group */ variant?: ButtonVariant; } /** * Actions column configuration (when resizable is false or not specified) */ export type TableActions = TableActionsBase; /** * Actions column configuration with required minWidth (when resizable is true) */ export interface TableActionsWithMinWidth extends TableActionsBase { /** Minimum column width - required when table is resizable */ minWidth: number; } export declare function getCellAlignClass(align?: ColumnAlign): string; export declare const DRAG_OR_PIN_HANDLE_KEY = "__mzn-drag-or-pin-handle__"; export declare const SELECTION_KEY = "__mzn-selection__"; export declare const EXPANSION_KEY = "__mzn-expansion__"; export declare const TOGGLEABLE_KEY = "__mzn-toggleable__"; export declare const COLLECTABLE_KEY = "__mzn-collectable__"; export declare const TABLE_ACTIONS_KEY = "__mzn-table-actions__"; export declare const DRAG_OR_PIN_HANDLE_COLUMN_WIDTH = 40; export declare const SELECTION_COLUMN_WIDTH = 40; export declare const EXPANSION_COLUMN_WIDTH = 40; export declare const TOGGLEABLE_COLUMN_WIDTH = 80; export declare const COLLECTABLE_COLUMN_WIDTH = 80;