From 932df1b3a21ea62a8e023139ef5462b44457a93e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E7=88=B1=E5=90=83=E7=99=BD=E8=90=9D?= =?UTF-8?q?=E5=8D=9C?= Date: Tue, 27 Dec 2022 17:03:29 +0800 Subject: [PATCH] refactor: drop shallowequal (#917) * chore: drop shalloweqal * docs: dumi2 * docs: dumi2 * docs: update now --- .dumirc.ts | 9 +++++++++ .gitignore | 3 ++- .umirc.ts | 21 --------------------- docs/demo/animation.md | 9 +++++++-- docs/demo/aria.md | 9 +++++++-- docs/demo/caption.md | 9 +++++++-- docs/demo/childrenIndent.md | 9 +++++++-- docs/demo/className.md | 9 +++++++-- docs/demo/colspan-rowspan-legacy.md | 9 +++++++-- docs/demo/colspan-rowspan.md | 9 +++++++-- docs/demo/column-resize.md | 9 +++++++-- docs/demo/dropdown.md | 9 +++++++-- docs/demo/ellipsis-custom-tooltip.md | 9 +++++++-- docs/demo/ellipsis.md | 9 +++++++-- docs/demo/expandIcon.md | 9 +++++++-- docs/demo/expandedRowRender.md | 9 +++++++-- docs/demo/fixedColumns-auto-height.md | 9 +++++++-- docs/demo/fixedColumns-resize.md | 9 +++++++-- docs/demo/fixedColumns.md | 9 +++++++-- docs/demo/fixedColumnsAndHeader.md | 9 +++++++-- docs/demo/fixedColumnsAndHeaderRtl.md | 9 +++++++-- docs/demo/grouping-columns.md | 9 +++++++-- docs/demo/hide-header.md | 9 +++++++-- docs/demo/jsx.md | 9 +++++++-- docs/demo/key.md | 9 +++++++-- docs/demo/nested.md | 9 +++++++-- docs/demo/no-data.md | 9 +++++++-- docs/demo/react-dnd.md | 9 +++++++-- docs/demo/rowAndCellClick.md | 9 +++++++-- docs/demo/scopeCol.md | 9 +++++++-- docs/demo/scopeRow.md | 9 +++++++-- docs/demo/scrollX.md | 9 +++++++-- docs/demo/scrollXY.md | 9 +++++++-- docs/demo/scrollY.md | 9 +++++++-- docs/demo/simple.md | 9 +++++++-- docs/demo/stickyHeader.md | 9 +++++++-- docs/demo/stickyHeaderAndSummary.md | 9 +++++++-- docs/demo/styled-components.md | 9 +++++++-- docs/demo/subTable.md | 9 +++++++-- docs/demo/title-and-footer.md | 9 +++++++-- docs/demo/virtual-list-grid.md | 9 +++++++-- docs/demo/virtual-list.md | 9 +++++++-- docs/examples/scopeCol.tsx | 1 + docs/examples/scopeRow.tsx | 1 + now.json | 2 +- package.json | 9 +++------ src/Cell/index.tsx | 4 ++-- src/Table.tsx | 4 ++-- tsconfig.json | 2 +- 49 files changed, 295 insertions(+), 112 deletions(-) create mode 100644 .dumirc.ts delete mode 100644 .umirc.ts diff --git a/.dumirc.ts b/.dumirc.ts new file mode 100644 index 000000000..39feb20b7 --- /dev/null +++ b/.dumirc.ts @@ -0,0 +1,9 @@ +// more config: https://d.umijs.org/config +import { defineConfig } from 'dumi'; + +export default defineConfig({ + themeConfig: { + name: 'Table', + }, + mfsu: false, +}); \ No newline at end of file diff --git a/.gitignore b/.gitignore index e13cc6d69..c34bcf4fc 100644 --- a/.gitignore +++ b/.gitignore @@ -40,4 +40,5 @@ examples/debug.tsx .umi .umi-production .umi-test -.env.local \ No newline at end of file +.env.local +.dumi \ No newline at end of file diff --git a/.umirc.ts b/.umirc.ts deleted file mode 100644 index b9a34c928..000000000 --- a/.umirc.ts +++ /dev/null @@ -1,21 +0,0 @@ -// more config: https://d.umijs.org/config -import { defineConfig } from 'dumi'; - -const name = 'rc-table'; - -export default defineConfig({ - title: name, - favicon: - 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', - logo: - 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', - outputPath: '.doc', - exportStatic: {}, - styles: [ - ` - .markdown table { - width: auto !important; - } - `, - ] -}); diff --git a/docs/demo/animation.md b/docs/demo/animation.md index 66f414a64..2568b01d2 100644 --- a/docs/demo/animation.md +++ b/docs/demo/animation.md @@ -1,3 +1,8 @@ -## animation +--- +title: animation +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/aria.md b/docs/demo/aria.md index 1a5f53d41..56e3573ea 100644 --- a/docs/demo/aria.md +++ b/docs/demo/aria.md @@ -1,3 +1,8 @@ -## aria-label +--- +title: aria-label +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/caption.md b/docs/demo/caption.md index f25ca915d..3e3c3d1d3 100644 --- a/docs/demo/caption.md +++ b/docs/demo/caption.md @@ -1,3 +1,8 @@ -## caption +--- +title: caption +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/childrenIndent.md b/docs/demo/childrenIndent.md index dc04fd20d..f0f3489c8 100644 --- a/docs/demo/childrenIndent.md +++ b/docs/demo/childrenIndent.md @@ -1,3 +1,8 @@ -## childrenIndent +--- +title: childrenIndent +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/className.md b/docs/demo/className.md index d495e2f92..22e96fccd 100644 --- a/docs/demo/className.md +++ b/docs/demo/className.md @@ -1,3 +1,8 @@ -## className +--- +title: className +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/colspan-rowspan-legacy.md b/docs/demo/colspan-rowspan-legacy.md index 11809cef6..8bd151666 100644 --- a/docs/demo/colspan-rowspan-legacy.md +++ b/docs/demo/colspan-rowspan-legacy.md @@ -1,3 +1,8 @@ -## colspan-rowspan-legacy +--- +title: colspan-rowspan-legacy +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/colspan-rowspan.md b/docs/demo/colspan-rowspan.md index 5814b497e..479d9d4ff 100644 --- a/docs/demo/colspan-rowspan.md +++ b/docs/demo/colspan-rowspan.md @@ -1,3 +1,8 @@ -## colspan-rowspan +--- +title: colspan-rowspan +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/column-resize.md b/docs/demo/column-resize.md index 181a04c24..683860606 100644 --- a/docs/demo/column-resize.md +++ b/docs/demo/column-resize.md @@ -1,3 +1,8 @@ -## column-resize +--- +title: column-resize +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/dropdown.md b/docs/demo/dropdown.md index 33d3beaee..430576a58 100644 --- a/docs/demo/dropdown.md +++ b/docs/demo/dropdown.md @@ -1,3 +1,8 @@ -## dropdown +--- +title: dropdown +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/ellipsis-custom-tooltip.md b/docs/demo/ellipsis-custom-tooltip.md index 8554c3bf7..3473d5843 100644 --- a/docs/demo/ellipsis-custom-tooltip.md +++ b/docs/demo/ellipsis-custom-tooltip.md @@ -1,3 +1,8 @@ -## ellipsis-custom-tooltip +--- +title: ellipsis-custom-tooltip +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/ellipsis.md b/docs/demo/ellipsis.md index 63ce1ff46..6c6fd86ca 100644 --- a/docs/demo/ellipsis.md +++ b/docs/demo/ellipsis.md @@ -1,3 +1,8 @@ -## ellipsis +--- +title: ellipsis +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/expandIcon.md b/docs/demo/expandIcon.md index 1355de39f..fd3914964 100644 --- a/docs/demo/expandIcon.md +++ b/docs/demo/expandIcon.md @@ -1,3 +1,8 @@ -## expandIcon +--- +title: expandIcon +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/expandedRowRender.md b/docs/demo/expandedRowRender.md index 92904ae5e..ef3a21487 100644 --- a/docs/demo/expandedRowRender.md +++ b/docs/demo/expandedRowRender.md @@ -1,3 +1,8 @@ -## expandedRowRender +--- +title: expandedRowRender +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/fixedColumns-auto-height.md b/docs/demo/fixedColumns-auto-height.md index 4c474f678..273c6a2e8 100644 --- a/docs/demo/fixedColumns-auto-height.md +++ b/docs/demo/fixedColumns-auto-height.md @@ -1,3 +1,8 @@ -## fixedColumns-auto-height +--- +title: fixedColumns-auto-height +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/fixedColumns-resize.md b/docs/demo/fixedColumns-resize.md index 4fc7cb6e5..a6e84f8ef 100644 --- a/docs/demo/fixedColumns-resize.md +++ b/docs/demo/fixedColumns-resize.md @@ -1,3 +1,8 @@ -## fixedColumns-resize +--- +title: fixedColumns-resize +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/fixedColumns.md b/docs/demo/fixedColumns.md index f29a7dcdb..f717d24ad 100644 --- a/docs/demo/fixedColumns.md +++ b/docs/demo/fixedColumns.md @@ -1,3 +1,8 @@ -## fixedColumns +--- +title: fixedColumns +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/fixedColumnsAndHeader.md b/docs/demo/fixedColumnsAndHeader.md index 76656d9e5..8e5c507f9 100644 --- a/docs/demo/fixedColumnsAndHeader.md +++ b/docs/demo/fixedColumnsAndHeader.md @@ -1,3 +1,8 @@ -## fixedColumnsAndHeader +--- +title: fixedColumnsAndHeader +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/fixedColumnsAndHeaderRtl.md b/docs/demo/fixedColumnsAndHeaderRtl.md index 8ea2f344f..749283459 100644 --- a/docs/demo/fixedColumnsAndHeaderRtl.md +++ b/docs/demo/fixedColumnsAndHeaderRtl.md @@ -1,3 +1,8 @@ -## fixedColumnsAndHeaderRtl +--- +title: fixedColumnsAndHeaderRtl +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/grouping-columns.md b/docs/demo/grouping-columns.md index b16c2f0fd..d82ad8ba8 100644 --- a/docs/demo/grouping-columns.md +++ b/docs/demo/grouping-columns.md @@ -1,3 +1,8 @@ -## grouping-columns +--- +title: grouping-columns +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/hide-header.md b/docs/demo/hide-header.md index ac3547b86..6a2bb3af8 100644 --- a/docs/demo/hide-header.md +++ b/docs/demo/hide-header.md @@ -1,3 +1,8 @@ -## hide-header +--- +title: hide-header +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/jsx.md b/docs/demo/jsx.md index 07b012e74..d3be128a0 100644 --- a/docs/demo/jsx.md +++ b/docs/demo/jsx.md @@ -1,3 +1,8 @@ -## Hover Perf +--- +title: Hover Perf +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/key.md b/docs/demo/key.md index 3e47c0565..58e17bb22 100644 --- a/docs/demo/key.md +++ b/docs/demo/key.md @@ -1,3 +1,8 @@ -## key +--- +title: key +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/nested.md b/docs/demo/nested.md index 79d6e8eec..807281b56 100644 --- a/docs/demo/nested.md +++ b/docs/demo/nested.md @@ -1,3 +1,8 @@ -## nested +--- +title: nested +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/no-data.md b/docs/demo/no-data.md index 8704a2863..da87e7c0d 100644 --- a/docs/demo/no-data.md +++ b/docs/demo/no-data.md @@ -1,3 +1,8 @@ -## no-data +--- +title: no-data +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/react-dnd.md b/docs/demo/react-dnd.md index 4ed1804d0..eac087e66 100644 --- a/docs/demo/react-dnd.md +++ b/docs/demo/react-dnd.md @@ -1,3 +1,8 @@ -## react-dnd +--- +title: react-dnd +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/rowAndCellClick.md b/docs/demo/rowAndCellClick.md index 834a66cb3..7c5f04622 100644 --- a/docs/demo/rowAndCellClick.md +++ b/docs/demo/rowAndCellClick.md @@ -1,3 +1,8 @@ -## rowAndCellClick +--- +title: rowAndCellClick +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/scopeCol.md b/docs/demo/scopeCol.md index 23bd86ad5..cd5261efa 100644 --- a/docs/demo/scopeCol.md +++ b/docs/demo/scopeCol.md @@ -1,3 +1,8 @@ -## scopeCol +--- +title: scopeCol +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/scopeRow.md b/docs/demo/scopeRow.md index f11554b68..213f7e7c2 100644 --- a/docs/demo/scopeRow.md +++ b/docs/demo/scopeRow.md @@ -1,3 +1,8 @@ -## scopeRow +--- +title: scopeRow +nav: + title: Demo + path: /demo +--- - \ No newline at end of file + \ No newline at end of file diff --git a/docs/demo/scrollX.md b/docs/demo/scrollX.md index e823ad24e..848db222d 100644 --- a/docs/demo/scrollX.md +++ b/docs/demo/scrollX.md @@ -1,3 +1,8 @@ -## scrollX +--- +title: scrollX +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/scrollXY.md b/docs/demo/scrollXY.md index 74fef71a3..4c35d4401 100644 --- a/docs/demo/scrollXY.md +++ b/docs/demo/scrollXY.md @@ -1,3 +1,8 @@ -## scrollXY +--- +title: scrollXY +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/scrollY.md b/docs/demo/scrollY.md index f66ace137..6aa778d72 100644 --- a/docs/demo/scrollY.md +++ b/docs/demo/scrollY.md @@ -1,3 +1,8 @@ -## scrollY +--- +title: scrollY +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/simple.md b/docs/demo/simple.md index efaf04c4e..64848ae0c 100644 --- a/docs/demo/simple.md +++ b/docs/demo/simple.md @@ -1,3 +1,8 @@ -## simple +--- +title: simple +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/stickyHeader.md b/docs/demo/stickyHeader.md index b7839176b..dad3b939f 100644 --- a/docs/demo/stickyHeader.md +++ b/docs/demo/stickyHeader.md @@ -1,3 +1,8 @@ -## stickyHeader +--- +title: stickyHeader +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/stickyHeaderAndSummary.md b/docs/demo/stickyHeaderAndSummary.md index 8558ebf5a..9dfcc923e 100644 --- a/docs/demo/stickyHeaderAndSummary.md +++ b/docs/demo/stickyHeaderAndSummary.md @@ -1,3 +1,8 @@ -## Sticky Header and Summary +--- +title: Sticky Header and Summary +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/styled-components.md b/docs/demo/styled-components.md index 4cfd3410a..2c06789f8 100644 --- a/docs/demo/styled-components.md +++ b/docs/demo/styled-components.md @@ -1,3 +1,8 @@ -## styled-components +--- +title: styled-components +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/subTable.md b/docs/demo/subTable.md index 1efbe8a61..c76cfed07 100644 --- a/docs/demo/subTable.md +++ b/docs/demo/subTable.md @@ -1,3 +1,8 @@ -## subTable +--- +title: subTable +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/title-and-footer.md b/docs/demo/title-and-footer.md index 36de38329..3a9ef6f60 100644 --- a/docs/demo/title-and-footer.md +++ b/docs/demo/title-and-footer.md @@ -1,3 +1,8 @@ -## title-and-footer +--- +title: title-and-footer +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/virtual-list-grid.md b/docs/demo/virtual-list-grid.md index 1b2bffb0c..e50682bd5 100644 --- a/docs/demo/virtual-list-grid.md +++ b/docs/demo/virtual-list-grid.md @@ -1,3 +1,8 @@ -## virtual-list-grid +--- +title: virtual-list-grid +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/virtual-list.md b/docs/demo/virtual-list.md index 54e8348c0..3a9bd2e51 100644 --- a/docs/demo/virtual-list.md +++ b/docs/demo/virtual-list.md @@ -1,3 +1,8 @@ -## virtual-list +--- +title: virtual-list +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/examples/scopeCol.tsx b/docs/examples/scopeCol.tsx index 50de0f200..b108fc03e 100644 --- a/docs/examples/scopeCol.tsx +++ b/docs/examples/scopeCol.tsx @@ -1,5 +1,6 @@ import type { ColumnsType } from '@/interface'; import Table from 'rc-table'; +import React from 'react'; import '../../assets/index.less'; interface FirstTableRecordType { diff --git a/docs/examples/scopeRow.tsx b/docs/examples/scopeRow.tsx index f43a59a17..6f59028ea 100644 --- a/docs/examples/scopeRow.tsx +++ b/docs/examples/scopeRow.tsx @@ -1,5 +1,6 @@ import type { ColumnsType } from '@/interface'; import Table from 'rc-table'; +import React from 'react'; import '../../assets/index.less'; interface FirstTableRecordType { diff --git a/now.json b/now.json index c1deaee89..5060a6c12 100644 --- a/now.json +++ b/now.json @@ -5,7 +5,7 @@ { "src": "package.json", "use": "@now/static-build", - "config": { "distDir": ".doc" } + "config": { "distDir": "dist" } } ], "routes": [ diff --git a/package.json b/package.json index ddeb2e522..15975d153 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,6 @@ ], "files": [ "assets/*.css", - "dist", "es", "lib" ], @@ -57,8 +56,7 @@ "@rc-component/context": "^1.0.0", "classnames": "^2.2.5", "rc-resize-observer": "^1.1.0", - "rc-util": "^5.22.5", - "shallowequal": "^1.1.0" + "rc-util": "^5.27.0" }, "devDependencies": { "@types/enzyme": "^3.10.5", @@ -66,15 +64,14 @@ "@types/react": "^17.0.35", "@types/react-dom": "^18.0.5", "@types/responselike": "^1.0.0", - "@types/shallowequal": "^1.1.1", "@umijs/fabric": "^3.0.0", "cross-env": "^7.0.0", - "dumi": "^1.1.9", + "dumi": "^2.0.0", "enzyme": "^3.1.0", "enzyme-adapter-react-16": "^1.0.1", "enzyme-to-json": "^3.1.2", "eslint": "^7.1.0", - "father": "^4.0.0-rc.8", + "father": "^4.0.0", "gh-pages": "^3.1.0", "glob": "^7.1.6", "immutability-helper": "^3.0.0", diff --git a/src/Cell/index.tsx b/src/Cell/index.tsx index 4d57c3b7f..487daba87 100644 --- a/src/Cell/index.tsx +++ b/src/Cell/index.tsx @@ -2,7 +2,7 @@ import classNames from 'classnames'; import { supportRef } from 'rc-util/lib/ref'; import warning from 'rc-util/lib/warning'; import * as React from 'react'; -import shallowEqual from 'shallowequal'; +import isEqual from 'rc-util/lib/isEqual'; import BodyContext from '../context/BodyContext'; import type { HoverContextProps } from '../context/HoverContext'; import HoverContext from '../context/HoverContext'; @@ -330,7 +330,7 @@ const MemoCell = React.memo( ); } - return shallowEqual(prev, next); + return isEqual(prev, next, true); }, ); diff --git a/src/Table.tsx b/src/Table.tsx index 340ece652..3226b7bd3 100644 --- a/src/Table.tsx +++ b/src/Table.tsx @@ -32,7 +32,7 @@ import { getTargetScrollBarSize } from 'rc-util/lib/getScrollBarSize'; import pickAttrs from 'rc-util/lib/pickAttrs'; import warning from 'rc-util/lib/warning'; import * as React from 'react'; -import shallowEqual from 'shallowequal'; +import isEqual from 'rc-util/lib/isEqual'; import Body from './Body'; import ColGroup from './ColGroup'; import { EXPAND_COLUMN } from './constant'; @@ -98,7 +98,7 @@ const MemoTableContent = React.memo( ({ children }) => children as React.ReactElement, (prev, next) => { - if (!shallowEqual(prev.props, next.props)) { + if (!isEqual(prev.props, next.props, true)) { return false; } diff --git a/tsconfig.json b/tsconfig.json index 35ec7c4a3..f7b47e467 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "target": "esnext", "moduleResolution": "node", "baseUrl": "./", - "jsx": "preserve", + "jsx": "react", "declaration": true, "skipLibCheck": true, "esModuleInterop": true,