parent
a9006f2954
commit
9e0634f449
@ -0,0 +1,64 @@
|
||||
import { DownOutlined, RightOutlined } from '@ant-design/icons';
|
||||
import { Button, Checkbox } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import React from 'react';
|
||||
|
||||
interface RowPrefixProps {
|
||||
expandable?: boolean | React.ReactNode;
|
||||
enableSelection?: boolean;
|
||||
expanded?: boolean;
|
||||
checked?: boolean;
|
||||
handleRowExpand?: () => void;
|
||||
handleSelectChange?: (e: any) => void;
|
||||
}
|
||||
|
||||
const RowPrefix: React.FC<RowPrefixProps> = (props) => {
|
||||
const {
|
||||
expandable,
|
||||
enableSelection,
|
||||
expanded,
|
||||
checked,
|
||||
handleRowExpand,
|
||||
handleSelectChange
|
||||
} = props;
|
||||
|
||||
if (expandable && enableSelection) {
|
||||
return (
|
||||
<div className="row-prefix-wrapper">
|
||||
<span style={{ marginRight: 5 }}>
|
||||
{_.isBoolean(expandable) ? (
|
||||
<Button type="text" size="small" onClick={handleRowExpand}>
|
||||
{expanded ? <DownOutlined /> : <RightOutlined />}
|
||||
</Button>
|
||||
) : (
|
||||
expandable
|
||||
)}
|
||||
</span>
|
||||
<Checkbox onChange={handleSelectChange} checked={checked}></Checkbox>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (expandable) {
|
||||
return (
|
||||
<div className="row-prefix-wrapper">
|
||||
{_.isBoolean(expandable) ? (
|
||||
<Button type="text" size="small" onClick={handleRowExpand}>
|
||||
{expanded ? <DownOutlined /> : <RightOutlined />}
|
||||
</Button>
|
||||
) : (
|
||||
expandable
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (enableSelection) {
|
||||
return (
|
||||
<div className="row-prefix-wrapper">
|
||||
{<Checkbox onChange={handleSelectChange} checked={checked}></Checkbox>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
export default RowPrefix;
|
||||
@ -1,13 +0,0 @@
|
||||
import { Checkbox } from 'antd';
|
||||
import '../styles/skeleton.less';
|
||||
|
||||
const RowSkeleton = () => {
|
||||
return (
|
||||
<div className="row-skeleton">
|
||||
<div className="holder"></div>
|
||||
<Checkbox></Checkbox>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default RowSkeleton;
|
||||
@ -0,0 +1,32 @@
|
||||
import { Checkbox } from 'antd';
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import '../styles/skeleton.less';
|
||||
|
||||
const SkeletonItem = () => {
|
||||
return (
|
||||
<div className="row-skeleton">
|
||||
<div className="holder"></div>
|
||||
<Checkbox></Checkbox>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const Wrapper = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
`;
|
||||
|
||||
const TableSkeleton = () => {
|
||||
const dataSource = Array.from({ length: 5 });
|
||||
return (
|
||||
<Wrapper>
|
||||
{dataSource.map((item, index) => (
|
||||
<SkeletonItem key={index} />
|
||||
))}
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
export default React.memo(TableSkeleton);
|
||||
Loading…
Reference in new issue