Commit 97effd15 by zhaochengxiang

修改ts版本

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