UNPKG

ukelli-ui

Version:

Base on React's UI lib. Make frontend's dev simpler and faster.

167 lines (166 loc) 5.83 kB
import React from 'react'; import MapperFilter, { MapperFilterProps, Column, Records } from './mapper-filter'; import { Children } from '../utils/props'; export interface TableColumn extends Column { /** 点击表头排序的回调 */ onSort?: (record: any, isDescOutside: any) => void; /** 是否固定 */ fixed?: 'left' | 'right'; } export declare type TableColumns = TableColumn[]; /** 兼容旧的 TableKeyMapperItem */ export declare type TableKeyMapperItem = TableColumn; /** 兼容旧的 TableKeyMapper */ export declare type TableKeyMapper = TableKeyMapperItem[]; export declare type TableRecords = Records; export declare type CheckedOverlay = (params: { /** 已选择的项 */ checkedItems: {}; /** 取消选择 */ clearCheckeds: () => void; }) => any; export interface TableProps extends MapperFilterProps { /** 需要重命名为 columns */ keyMapper?: TableKeyMapper; /** 定义 table 的 columns */ columns: TableColumns; /** 数据源 */ records: TableRecords; /** 是否需要统计 */ needCount?: boolean; /** 是否需要内部排序 */ needInnerSort?: boolean; /** 是否多选 */ needCheck?: boolean; /** 表格的数据源,用于每一行(row)的数据填充 */ clickToHighlight?: boolean; /** 用于获取 row key */ rowKey?: (record: any, recordIdx: any) => string; /** 需要右对齐的 record 的类型 */ alignRightTypes?: string[]; /** 是否固定头部 */ fixHead?: boolean; /** 右边固定表格的列的集合 */ fixedRightKeys?: string[]; /** 左边固定表格的列的集合 */ fixedLeftKeys?: string[]; /** checkbox 的宽度 */ checkWidth?: number; /** 监听器的 timer */ watcherTimer?: number; /** 表格的高度,用于固定表头 */ height?: number | string; /** 无视的排序字段 */ sortIgnores?: string[]; /** 当选中时往表格顶部嵌入的内容,即将废弃,改用 checkedOverlay */ whenCheckAction?: CheckedOverlay | Children; /** 当选中时往表格顶部嵌入的内容 */ checkedOverlay?: CheckedOverlay | Children; /** 选中项时的回调 */ onCheck?: (nextChecked: any, idx?: any) => void; } interface State { headerWidthMapper: number[]; tableWidth: string | number; sortField: string; sortOutsideField: string; isDescInner: boolean; isDescOutside?: boolean; isAutoWidth?: boolean; hoveringRow?: number; highlightRow: {}; checkedItems: {}; } /** * 提供一个快速的表格数据渲染容器,不需要关注具体如何渲染,只需要传入对应的数据和过滤器 * * @export * @class Table * @extends {MapperFilter} */ export default class Table extends MapperFilter<TableProps, State> { static defaultProps: { sortIgnores: never[]; fixedLeftKeys: never[]; fixedRightKeys: never[]; alignRightTypes: string[]; needCheck: boolean; clickToHighlight: boolean; height: string; needInnerSort: boolean; watcherTimer: number; fixHead: boolean; checkWidth: number; needCount: boolean; }; excludeFilterField: string[]; firstTDDOMs: {}; firstRowNodes: {}; sameSortTime: number; fixedLeftGroup: TableKeyMapperItem[]; fixedRightGroup: TableKeyMapperItem[]; columnHeightInfo: {}; mainTableBody: any; checkedItems: any; hadSaved: any; tableContainer: any; tableContainerWidth: any; desplayWatcher: any; leftFixedTable: any; rightFixedTable: any; mainTable: any; lastScrollTop: any; lastScrollLeft: any; constructor(props: any); componentDidMount(): void; componentWillUnmount(): void; /** * 清除所有已选择的内容 * * @memberof TableBody * @public */ clearCheckeds: () => void; handleClickToHighlight: (e: React.MouseEvent<Element, MouseEvent>, rowIdx: any) => void; toggleSelectItem: (item: any, idx: any) => void; toggleAllItems(allCheck: any): void; selectItems(nextState: any, idx?: any): void; getCheckbox: (str: any, item: any, mapper: any, idx: any) => JSX.Element; getKeyMapper: () => TableColumn[] & Column[]; saveFixedGroup: (columns: any) => void; setTableContainerClass: (isAutoWidth: any) => void; calcSize(firstRowNodes: any): void; resetTableDOMInfo: () => void; resizeCalcSize: () => void; onChangeRecords: () => void; ignoreFilter(str: any): boolean; recordsOrderFilter(): import("./mapper-filter").RecordItem[]; orderRecord(_orderKey: any): void; isHidden: (el: any) => boolean; initTableContainer: (e: any) => void; clearWatch: () => void; saveContainer: (e: any) => void; getRowKey: (record: any, idx: any) => any; saveCell: (idx: any, isMain: any, rowKey: any) => (tdDOM: any) => void; checkRightAlign: (mapperItem: any) => true | undefined; renderCell(options: any): any[] | null; handleHoverRow: (idx: any) => void; renderRow: (options: any) => any; calcTableWidth: (columns: any) => number | null; renderTableHeader: (options: any) => JSX.Element; reSaveFirstRow: () => void; saveTableBody: (t: any) => void; hasFixedGroup: () => any; renderTableBody: (options: any) => JSX.Element; renderTable: (options: any, key: any) => JSX.Element; saveDOM: (ref: any) => (e: any) => void; saveLeftFixed: (e: any) => void; saveRightFixed: (e: any) => void; saveMainTable: (e: any) => void; renderFixedGroup: (options: any) => (false | JSX.Element)[] | null; renderMainTable: (options: any) => JSX.Element; handleTableScroll: (e: any) => void; handleScrollHor: (e: any) => void; render(): JSX.Element; } export {};