element-plus
Version:
A Component Library for Vue 3
1 lines • 6.1 kB
Source Map (JSON)
{"version":3,"file":"table.mjs","names":[],"sources":["../../../../../../packages/components/table-v2/src/table.ts"],"sourcesContent":["import { buildProps, definePropType } from '@element-plus/utils'\nimport {\n virtualizedGridProps,\n virtualizedScrollbarProps,\n} from '@element-plus/components/virtual-list'\nimport {\n classType,\n columns,\n dataType,\n expandKeys,\n fixedDataType,\n requiredNumber,\n rowKey,\n} from './common'\nimport { tableV2RowProps } from './row'\nimport { tableV2HeaderProps } from './header'\nimport { tableV2GridProps } from './grid'\n\nimport type {\n CSSProperties,\n ExtractPropTypes,\n ExtractPublicPropTypes,\n} from 'vue'\nimport type { SortOrder } from './constants'\nimport type {\n Column,\n ColumnCommonParams,\n DataGetter,\n KeyType,\n RowCommonParams,\n SortBy,\n SortState,\n} from './types'\n\n/**\n * Param types\n */\nexport type ColumnSortParams<T> = {\n column: Column<T>\n key: KeyType\n order: SortOrder\n}\n\n/**\n * Renderer/Getter types\n */\n\nexport type ExtraCellPropGetter<T> = (\n params: ColumnCommonParams<T> &\n RowCommonParams & { cellData: T; rowData: any }\n) => any\n\nexport type ExtractHeaderPropGetter<T> = (params: {\n columns: Column<T>[]\n headerIndex: number\n}) => any\n\nexport type ExtractHeaderCellPropGetter<T> = (\n params: ColumnCommonParams<T> & { headerIndex: number }\n) => any\n\nexport type ExtractRowPropGetter<T> = (\n params: { columns: Column<T>[] } & RowCommonParams\n) => any\n\nexport type HeaderClassNameGetter<T> = (params: {\n columns: Column<T>[]\n headerIndex: number\n}) => string\n\nexport type RowClassNameGetter<T> = (\n params: { columns: Column<T>[] } & RowCommonParams\n) => string\n\n/**\n * Handler types\n */\nexport type ColumnSortHandler<T> = (params: ColumnSortParams<T>) => void\nexport type ColumnResizeHandler<T> = (column: Column<T>, width: number) => void\nexport type ExpandedRowsChangeHandler = (expandedRowKeys: KeyType[]) => void\n\nexport const tableV2Props = buildProps({\n cache: tableV2GridProps.cache,\n estimatedRowHeight: tableV2RowProps.estimatedRowHeight,\n rowKey,\n // Header attributes\n headerClass: {\n type: definePropType<string | HeaderClassNameGetter<any>>([\n String,\n Function,\n ]),\n },\n headerProps: {\n type: definePropType<any | ExtractHeaderPropGetter<any>>([\n Object,\n Function,\n ]),\n },\n headerCellProps: {\n type: definePropType<any | ExtractHeaderCellPropGetter<any>>([\n Object,\n Function,\n ]),\n },\n headerHeight: tableV2HeaderProps.headerHeight,\n /**\n * Footer attributes\n */\n footerHeight: {\n type: Number,\n default: 0,\n },\n /**\n * Row attributes\n */\n rowClass: {\n type: definePropType<string | RowClassNameGetter<any>>([String, Function]),\n },\n rowProps: {\n type: definePropType<ExtractRowPropGetter<any> | any>([Object, Function]),\n },\n rowHeight: {\n type: Number,\n default: 50,\n },\n\n /**\n * Cell attributes\n */\n cellProps: {\n type: definePropType<Record<string, any> | ExtraCellPropGetter<any>>([\n Object,\n Function,\n ]),\n },\n /**\n * Data models\n */\n columns,\n data: dataType,\n dataGetter: {\n type: definePropType<DataGetter<any>>(Function),\n },\n fixedData: fixedDataType,\n /**\n * Expanded keys\n */\n expandColumnKey: tableV2RowProps.expandColumnKey,\n expandedRowKeys: expandKeys,\n defaultExpandedRowKeys: expandKeys,\n\n /**\n * Attributes\n */\n class: classType,\n // disabled: Boolean,\n fixed: Boolean,\n style: {\n type: definePropType<CSSProperties>(Object),\n },\n width: requiredNumber,\n height: requiredNumber,\n maxHeight: Number,\n useIsScrolling: Boolean,\n indentSize: {\n type: Number,\n default: 12,\n },\n iconSize: {\n type: Number,\n default: 12,\n },\n hScrollbarSize: virtualizedGridProps.hScrollbarSize,\n vScrollbarSize: virtualizedGridProps.vScrollbarSize,\n scrollbarAlwaysOn: virtualizedScrollbarProps.alwaysOn,\n\n /**\n * Sorting\n */\n sortBy: {\n type: definePropType<SortBy>(Object),\n default: () => ({}) as { key: KeyType; order: SortOrder },\n },\n sortState: {\n type: definePropType<SortState>(Object),\n default: undefined,\n },\n\n /**\n * Handlers\n */\n onColumnSort: {\n type: definePropType<ColumnSortHandler<any>>(Function),\n },\n onExpandedRowsChange: {\n type: definePropType<ExpandedRowsChangeHandler>(Function),\n },\n onEndReached: {\n type: definePropType<(remainDistance: number) => void>(Function),\n },\n onRowExpand: tableV2RowProps.onRowExpand,\n onScroll: tableV2GridProps.onScroll,\n onRowsRendered: tableV2GridProps.onRowsRendered,\n rowEventHandlers: tableV2RowProps.rowEventHandlers,\n} as const)\n\nexport type TableV2Props = ExtractPropTypes<typeof tableV2Props>\nexport type TableV2PropsPublic = ExtractPublicPropTypes<typeof tableV2Props>\n"],"mappings":";;;;;;;;AAiFA,MAAa,eAAe,WAAW;CACrC,OAAO,iBAAiB;CACxB,oBAAoB,gBAAgB;CACpC;CAEA,aAAa,EACX,MAAM,eAAoD,CACxD,QACA,SACD,CAAC,EACH;CACD,aAAa,EACX,MAAM,eAAmD,CACvD,QACA,SACD,CAAC,EACH;CACD,iBAAiB,EACf,MAAM,eAAuD,CAC3D,QACA,SACD,CAAC,EACH;CACD,cAAc,mBAAmB;CAIjC,cAAc;EACZ,MAAM;EACN,SAAS;EACV;CAID,UAAU,EACR,MAAM,eAAiD,CAAC,QAAQ,SAAS,CAAC,EAC3E;CACD,UAAU,EACR,MAAM,eAAgD,CAAC,QAAQ,SAAS,CAAC,EAC1E;CACD,WAAW;EACT,MAAM;EACN,SAAS;EACV;CAKD,WAAW,EACT,MAAM,eAA+D,CACnE,QACA,SACD,CAAC,EACH;CAID;CACA,MAAM;CACN,YAAY,EACV,MAAM,eAAgC,SAAS,EAChD;CACD,WAAW;CAIX,iBAAiB,gBAAgB;CACjC,iBAAiB;CACjB,wBAAwB;CAKxB,OAAO;CAEP,OAAO;CACP,OAAO,EACL,MAAM,eAA8B,OAAO,EAC5C;CACD,OAAO;CACP,QAAQ;CACR,WAAW;CACX,gBAAgB;CAChB,YAAY;EACV,MAAM;EACN,SAAS;EACV;CACD,UAAU;EACR,MAAM;EACN,SAAS;EACV;CACD,gBAAgB,qBAAqB;CACrC,gBAAgB,qBAAqB;CACrC,mBAAmB,0BAA0B;CAK7C,QAAQ;EACN,MAAM,eAAuB,OAAO;EACpC,gBAAgB,EAAE;EACnB;CACD,WAAW;EACT,MAAM,eAA0B,OAAO;EACvC,SAAS;EACV;CAKD,cAAc,EACZ,MAAM,eAAuC,SAAS,EACvD;CACD,sBAAsB,EACpB,MAAM,eAA0C,SAAS,EAC1D;CACD,cAAc,EACZ,MAAM,eAAiD,SAAS,EACjE;CACD,aAAa,gBAAgB;CAC7B,UAAU,iBAAiB;CAC3B,gBAAgB,iBAAiB;CACjC,kBAAkB,gBAAgB;CACnC,CAAU"}