Commit 97effd15 by zhaochengxiang

修改ts版本

parent b0d6257f
......@@ -12,9 +12,9 @@
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/jest": "^27.5.1",
"@types/node": "^17.0.35",
"@types/react": "^18.0.9",
"@types/react-dom": "^18.0.4",
"@types/node": "16.11.12",
"@types/react": "17.0.33",
"@types/react-dom": "17.0.10",
"ahooks": "^3.1.7",
"antd": "4.18.2",
"axios": "^0.19.0",
......@@ -45,7 +45,7 @@
"redux-saga": "^1.0.5",
"showdown": "^1.9.1",
"smooth-scroll": "^16.1.3",
"typescript": "^4.6.4",
"typescript": "4.4.4",
"web-vitals": "^1.0.1"
},
"scripts": {
......
......@@ -34,7 +34,7 @@ export interface RowData {
interface Props<Row> {
contextMenu?: {
id: string
menu: (row: Row | undefined) => ReactElement
menu: (row: RowData | undefined) => ReactElement
}
checkable: Boolean
gridRef?: React.RefObject<DataGridHandle>
......@@ -120,7 +120,7 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
}
const [checkAll, setCheckAll] = useState(false)
const [contextItem, setContextItem] = useState<Row|undefined>(undefined)
const [contextItem, setContextItem] = useState<RowData|undefined>(undefined)
// 初始化onRowsChange
const onRowsChange = useCallback((rows: RowData[], { indexes }: RowsChangeData<Row, SR>) => {
......@@ -174,7 +174,6 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
const cols = useMemo(() => {
if (expandRow && checkable) {
const cols: readonly Column<Row, SR>[] = [
// { ...SelectColumn, key: 'select', frozen: false },
getExpandingCol<Row, SR>({
colSpan: () => columns.length+2, expand: expandRow, expandable: rowExpandable
}),
......@@ -229,23 +228,23 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
components={{
sortIcon: SortIcon,
checkboxFormatter: CheckboxFormatter,
// rowRenderer: (props) => {
// return (
// contextMenu ? <ContextMenuTrigger
// id={contextMenuId}
// collect={() => ({ rowIdx: props?.rowIdx })}
// disable={props.row.__type__===RowType.Detail}
// >
// <GridRow
// id={props.row.id}
// onContextMenu={(e: React.MouseEvent) => {
// setContextItem(props.row);
// }}
// {...props}
// />
// </ContextMenuTrigger> : <React.Fragment></React.Fragment>
// )
// },
rowRenderer: (props) => {
return (
contextMenu ? <ContextMenuTrigger
id={contextMenuId}
collect={() => ({ rowIdx: props?.rowIdx })}
disable={props.row.__type__===RowType.Detail}
>
<GridRow
id={props.row.id}
onContextMenu={(e: React.MouseEvent) => {
setContextItem(props.row);
}}
{...props}
/>
</ContextMenuTrigger> : <React.Fragment></React.Fragment>
)
},
noRowsFallback: <div style={{ textAlign: 'center', gridColumn: '1/-1' }}>
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
</div>,
......@@ -272,14 +271,14 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
// 滚动
onScroll={loadMoreRows ? handleScroll : undefined}
/>
{/* {contextMenu && createPortal(
{contextMenu && createPortal(
<div className={classNames(css.contextMenu)}>
<ContextMenu id={contextMenuId} rtl={false}>
{contextMenu.menu(contextItem)}
</ContextMenu>
</div>,
document.body
)} */}
)}
</div>
);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment