-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(comp: table): add customAdditional to support cosutom row and cell
BREAKING CHANGE: `tags` was deprecated, please use `customAdditional` instead
- Loading branch information
Showing
30 changed files
with
353 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
packages/components/list/__tests__/__snapshots__/listItem.spec.ts.snap
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
title: | ||
zh: 斑马纹表格 | ||
en: Striped Table | ||
order: 1 | ||
--- | ||
|
||
## zh | ||
|
||
使用 `customAdditional` 来自定义表格元素的属性。 | ||
|
||
## en | ||
|
||
Via `customAdditional` to customize the attributes of the table element. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<template> | ||
<IxTable | ||
class="custom-additional-demo-table" | ||
:columns="columns" | ||
:customAdditional="customAdditional" | ||
:dataSource="data" | ||
:pagination="false" | ||
> | ||
<template #name="{ value }"> | ||
<a>{{ value }}</a> | ||
</template> | ||
</IxTable> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { TableColumn, TableCustomAdditional } from '@idux/components/table' | ||
interface Data { | ||
key: number | ||
name: string | ||
age: number | ||
address: string | ||
} | ||
const customAdditional: TableCustomAdditional<Data> = { | ||
bodyCell: ({ record }) => { | ||
return { | ||
class: 'custom-class', | ||
onClick: () => console.log('cell click', record.key), | ||
} | ||
}, | ||
bodyRow: ({ record, rowIndex }) => { | ||
return { | ||
class: (rowIndex + 1) % 2 === 0 ? 'even-row' : 'odd-row', | ||
onClick: () => console.log('row click', record.key), | ||
} | ||
}, | ||
} | ||
const columns: TableColumn<Data>[] = [ | ||
{ | ||
title: 'Name', | ||
dataKey: 'name', | ||
customCell: 'name', | ||
}, | ||
{ | ||
title: 'Age', | ||
dataKey: 'age', | ||
}, | ||
{ | ||
title: 'Address', | ||
dataKey: 'address', | ||
}, | ||
] | ||
const data: Data[] = [] | ||
for (let index = 0; index < 4; index++) { | ||
data.push({ | ||
key: index, | ||
name: `Edrward ${index}`, | ||
age: 18 + index, | ||
address: `London Park no. ${index}`, | ||
}) | ||
} | ||
</script> | ||
|
||
<style scoped lang="less"> | ||
.custom-additional-demo-table { | ||
:deep(.even-row) td { | ||
background-color: #fafafa; | ||
} | ||
:deep(.odd-row) td { | ||
background-color: #fff; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.