mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
* feat(components): [auto-resizer] new component - Add new component AutoResizer for skip passing width/height. - Update documentation for AutoResizer. - Update FAQs for TableV2. - Update interfaces for TableV2. * Fix linter error * Fix linter issue
90 lines
2.2 KiB
TypeScript
90 lines
2.2 KiB
TypeScript
import { buildProps, definePropType } from '@element-plus/utils'
|
|
import { virtualizedGridProps } from '@element-plus/components/virtual-list'
|
|
import { columns, expandColumnKey, rowKey } from './common'
|
|
|
|
import type { CSSProperties, ExtractPropTypes } from 'vue'
|
|
import type { FixedDirection, KeyType, RowCommonParams } from './types'
|
|
|
|
export type RowExpandParams = {
|
|
expanded: boolean
|
|
rowKey: KeyType
|
|
} & RowCommonParams
|
|
|
|
export type RowHoverParams = {
|
|
event: MouseEvent
|
|
hovered: boolean
|
|
rowKey: KeyType
|
|
} & RowCommonParams
|
|
|
|
export type RowEventHandlerParams = {
|
|
rowKey: KeyType
|
|
event: Event
|
|
} & RowCommonParams
|
|
|
|
export type RowHeightChangedParams = {
|
|
rowKey: KeyType
|
|
height: number
|
|
rowIndex: number
|
|
}
|
|
|
|
export type RowExpandHandler = (params: RowExpandParams) => void
|
|
export type RowHoverHandler = (params: RowHoverParams) => void
|
|
export type RowEventHandler = (params: RowEventHandlerParams) => void
|
|
export type RowHeightChangeHandler = (
|
|
row: RowHeightChangedParams,
|
|
fixedDirection: boolean | FixedDirection | undefined
|
|
) => void
|
|
|
|
export type RowEventHandlers = {
|
|
onClick?: RowEventHandler
|
|
onContextmenu?: RowEventHandler
|
|
onDblclick?: RowEventHandler
|
|
onMouseenter?: RowEventHandler
|
|
onMouseleave?: RowEventHandler
|
|
}
|
|
|
|
export const tableV2RowProps = buildProps({
|
|
class: String,
|
|
columns,
|
|
columnsStyles: {
|
|
type: definePropType<Record<KeyType, CSSProperties>>(Object),
|
|
required: true,
|
|
},
|
|
depth: Number,
|
|
expandColumnKey,
|
|
estimatedRowHeight: {
|
|
...virtualizedGridProps.estimatedRowHeight,
|
|
default: undefined,
|
|
},
|
|
isScrolling: Boolean,
|
|
onRowExpand: {
|
|
type: definePropType<RowExpandHandler>(Function),
|
|
},
|
|
onRowHover: {
|
|
type: definePropType<RowHoverHandler>(Function),
|
|
},
|
|
onRowHeightChange: {
|
|
type: definePropType<RowHeightChangeHandler>(Function),
|
|
},
|
|
rowData: {
|
|
type: definePropType<any>(Object),
|
|
required: true,
|
|
},
|
|
rowEventHandlers: {
|
|
type: definePropType<RowEventHandlers>(Object),
|
|
},
|
|
rowIndex: {
|
|
type: Number,
|
|
required: true,
|
|
},
|
|
/**
|
|
* Unique item key
|
|
*/
|
|
rowKey,
|
|
style: {
|
|
type: definePropType<CSSProperties>(Object),
|
|
},
|
|
} as const)
|
|
|
|
export type TableV2RowProps = ExtractPropTypes<typeof tableV2RowProps>
|