Skip to content

refactor: table #2473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions src/packages/table/demos/h5/demo14.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,22 @@ const Demo14 = () => {
text: '这里是自定义行',
Component: (props: any) => {
return (
<div style={{ height: props.height }}>
<div
style={{
position: 'absolute',
height: props.height,
width: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
borderBottom:
'1px solid var(--nutui-table-border-color, var(--nutui-black-3, rgba(0, 0, 0, 0.06)))',
}}
>
{props.text}
<div className="nut-table-main-body-tr">
<div style={{ height: props.height }}>
<div
style={{
position: 'absolute',
height: props.height,
width: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
borderBottom:
'1px solid var(--nutui-table-border-color, var(--nutui-black-3, rgba(0, 0, 0, 0.06)))',
}}
>
{props.text}
</div>
</div>
</div>
)
Expand Down
30 changes: 16 additions & 14 deletions src/packages/table/demos/taro/demo14.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,22 @@ const Demo14 = () => {
text: '这里是自定义行',
Component: (props: any) => {
return (
<div style={{ height: props.height }}>
<div
style={{
position: 'absolute',
height: props.height,
width: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
borderBottom:
'1px solid var(--nutui-table-border-color, var(--nutui-black-3, rgba(0, 0, 0, 0.06)))',
}}
>
{props.text}
<div className="nut-table-main-body-tr">
<div style={{ height: props.height }}>
<div
style={{
position: 'absolute',
height: props.height,
width: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
borderBottom:
'1px solid var(--nutui-table-border-color, var(--nutui-black-3, rgba(0, 0, 0, 0.06)))',
}}
>
{props.text}
</div>
</div>
</div>
)
Expand Down
11 changes: 6 additions & 5 deletions src/packages/table/table.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ export const Table: FunctionComponent<
}

const renderBodyTds = (item: any, rowIndex: number) => {
const { rowRender } = item
if (rowRender && typeof rowRender === 'function') {
return rowRender(item, rowIndex)
}
return sortDataItem().map(([value, render]) => {
return (
<div
Expand All @@ -152,9 +148,14 @@ export const Table: FunctionComponent<

const renderBodyTrs = () => {
return innerValue.map((item, index) => {
const inner = renderBodyTds(item, index)
const { rowRender } = item
if (rowRender && typeof rowRender === 'function') {
return rowRender(item, index, { inner })
}
return (
<div className={bodyClassPrefix} key={index}>
{renderBodyTds(item, index)}
{inner}
</div>
)
})
Expand Down
11 changes: 6 additions & 5 deletions src/packages/table/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@ export const Table: FunctionComponent<
}

const renderBodyTds = (item: any, rowIndex: number) => {
const { rowRender } = item
if (rowRender && typeof rowRender === 'function') {
return rowRender(item, rowIndex)
}
return sortDataItem().map(([value, render]) => {
return (
<div
Expand All @@ -149,9 +145,14 @@ export const Table: FunctionComponent<

const renderBodyTrs = () => {
return innerValue.map((item, index) => {
const inner = renderBodyTds(item, index)
const { rowRender } = item
if (rowRender && typeof rowRender === 'function') {
return rowRender(item, index, { inner })
}
return (
<div className={bodyClassPrefix} key={index}>
{renderBodyTds(item, index)}
{inner}
</div>
)
})
Expand Down
Loading