feat(components): [virtual-table] TableHeaderCell (#7075)

- Add TableHeaderCell props definition
- Implement TableHeaderCell
- Extract some common props
- Fix components' name
This commit is contained in:
JeremyWuuuuu
2022-04-09 18:48:03 +08:00
committed by GitHub
parent d9e493f4cf
commit bf14b8f25f
6 changed files with 42 additions and 5 deletions

View File

@@ -2,9 +2,17 @@ import { definePropType } from '@element-plus/utils'
import type { Column } from './types'
export const expandColumnKey = String
type AnyColumn = Column<any>
export const classType = String
export const columns = {
type: definePropType<Column<any>[]>(Array),
type: definePropType<AnyColumn[]>(Array),
required: true,
} as const
export const column = {
type: definePropType<AnyColumn>(Object),
}
export const expandColumnKey = String

View File

@@ -0,0 +1,12 @@
import { buildProps } from '@element-plus/utils'
import { classType, column } from './common'
import type { ExtractPropTypes } from 'vue'
export const tableV2HeaderCell = buildProps({
class: classType,
columnIndex: Number,
column,
})
export type TableV2HeaderCell = ExtractPropTypes<typeof tableV2HeaderCell>

View File

@@ -12,6 +12,6 @@ const TableV2Cell = defineComponent((props: TableV2CellProps, { slots }) => {
)
})
TableV2Cell.name = 'TableV2Cell'
TableV2Cell.name = 'ElTableV2Cell'
export default TableV2Cell

View File

@@ -0,0 +1,15 @@
import { defineComponent } from 'vue'
import type { TableV2HeaderCell } from './header-cell'
const HeaderCell = defineComponent((props: TableV2HeaderCell, { slots }) =>
slots.default ? (
slots.default(props)
) : (
<div class={props.class}>{props.column?.title}</div>
)
)
HeaderCell.name = 'ElTableV2HeaderCell'
export default HeaderCell

View File

@@ -5,7 +5,7 @@ import { tableV2HeaderProps } from './header'
import type { CSSProperties } from 'vue'
const COMPONENT_NAME = 'TableV2Header'
const COMPONENT_NAME = 'ElTableV2Header'
const TableV2Header = defineComponent({
name: COMPONENT_NAME,
props: tableV2HeaderProps,

View File

@@ -124,8 +124,10 @@ const useTableRow = (props: TableV2RowProps) => {
return { isScrolling, measurable, measured, rowRef, eventHandlers, onExpand }
}
const COMPONENT_NAME = 'ElTableV2TableRow'
const TableV2Row = defineComponent({
name: '',
name: COMPONENT_NAME,
props: tableV2RowProps,
setup(props, { expose, slots }) {
const {