From 91124d3ff9a1a9376fd9ff4255c60f2dd7a07beb Mon Sep 17 00:00:00 2001 From: DBSDs <379712747@qq.com> Date: Thu, 16 Nov 2023 00:29:42 +0800 Subject: [PATCH 1/5] chore: bump dumi@2.x.x --- .dumirc.ts | 21 +++++++++++++++++++++ .github/workflows/main.yml | 4 ++-- .gitignore | 11 +++++------ .umirc.ts | 22 ---------------------- docs/demo/animate.md | 9 +++++++-- docs/demo/basic.md | 9 +++++++-- docs/demo/height.md | 9 +++++++-- docs/demo/horizontal-scroll.md | 9 +++++++-- docs/demo/no-virtual.md | 9 +++++++-- docs/demo/switch.md | 9 +++++++-- docs/index.md | 4 +++- package.json | 9 +++++---- update-demo.js => script/update-content.js | 9 +++++++-- tsconfig.json | 2 +- 14 files changed, 86 insertions(+), 50 deletions(-) create mode 100644 .dumirc.ts delete mode 100644 .umirc.ts rename update-demo.js => script/update-content.js (83%) diff --git a/.dumirc.ts b/.dumirc.ts new file mode 100644 index 00000000..2902a869 --- /dev/null +++ b/.dumirc.ts @@ -0,0 +1,21 @@ +// more config: https://d.umijs.org/config +import { defineConfig } from 'dumi'; + +export default defineConfig({ + favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'], + themeConfig: { + name: 'virtual-list', + logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', + }, + outputPath: '.doc', + base: '/rc-virtual-list/', + publicPath: '/rc-virtual-list/', + exportStatic: {}, + styles: [ + ` + .markdown table { + width: auto !important; + } + `, + ], +}); diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3571ed27..5c704561 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/setup-node@v1 with: - node-version: '12' + node-version: '18' - name: cache package-lock.json uses: actions/cache@v2 @@ -24,7 +24,7 @@ jobs: key: lock-${{ github.sha }} - name: create package-lock.json - run: npm i --package-lock-only + run: npm i --package-lock-only --ignore-scripts - name: hack for singe file run: | diff --git a/.gitignore b/.gitignore index 8c1834c2..5a81ecf4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -.storybook .doc node_modules coverage/ @@ -9,8 +8,8 @@ yarn.lock package-lock.json !tests/__mocks__/rc-util/lib -# umi -.umi -.umi-production -.umi-test -.env.local +# dumi +.dumi/tmp +.dumi/tmp-test +.dumi/tmp-production +.env.local \ No newline at end of file diff --git a/.umirc.ts b/.umirc.ts deleted file mode 100644 index b5a40158..00000000 --- a/.umirc.ts +++ /dev/null @@ -1,22 +0,0 @@ -// more config: https://d.umijs.org/config -import { defineConfig } from 'dumi'; - -export default defineConfig({ - title: 'rc-virtual-list', - 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: {}, - resolve: { - examples: ['none'], - }, - styles: [ - ` - .markdown table { - width: auto !important; - } - `, - ] -}); diff --git a/docs/demo/animate.md b/docs/demo/animate.md index 61b8fb5d..56fc4dc2 100644 --- a/docs/demo/animate.md +++ b/docs/demo/animate.md @@ -1,3 +1,8 @@ -## animate +--- +title: animate +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/basic.md b/docs/demo/basic.md index 806f1426..edb9e624 100644 --- a/docs/demo/basic.md +++ b/docs/demo/basic.md @@ -1,3 +1,8 @@ -## basic +--- +title: basic +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/height.md b/docs/demo/height.md index 7c041406..fa2f6955 100644 --- a/docs/demo/height.md +++ b/docs/demo/height.md @@ -1,3 +1,8 @@ -## height +--- +title: height +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/horizontal-scroll.md b/docs/demo/horizontal-scroll.md index ab538a0e..ee24e3b7 100644 --- a/docs/demo/horizontal-scroll.md +++ b/docs/demo/horizontal-scroll.md @@ -1,3 +1,8 @@ -## horizontal scroll +--- +title: horizontal-scroll +nav: + title: Demo + path: /demo +--- - \ No newline at end of file + diff --git a/docs/demo/no-virtual.md b/docs/demo/no-virtual.md index d139d2aa..7339a136 100644 --- a/docs/demo/no-virtual.md +++ b/docs/demo/no-virtual.md @@ -1,3 +1,8 @@ -## no-virtual +--- +title: no-virtual +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/switch.md b/docs/demo/switch.md index b80f4038..6a6f356e 100644 --- a/docs/demo/switch.md +++ b/docs/demo/switch.md @@ -1,3 +1,8 @@ -## switch +--- +title: switch +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/index.md b/docs/index.md index 8eb92fd2..6c7a801a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,5 +1,7 @@ --- -title: rc-virtual-list +hero: + title: rc-virtual-list + description: React Virtual List Component --- diff --git a/package.json b/package.json index 500bd1e7..def6ff53 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "start": "dumi dev", "build": "dumi build", "compile": "father build", + "prepare": "dumi setup", "prepublishOnly": "npm run compile && np --no-cleanup --yolo --no-publish", "lint": "eslint src/ --ext .tsx,.ts", "test": "father test", @@ -51,18 +52,18 @@ "@types/react-dom": "^18.0.3", "@types/warning": "^3.0.0", "cross-env": "^5.2.0", - "dumi": "^1.1.12", + "dumi": "^2.0.0", "enzyme": "^3.1.0", "enzyme-adapter-react-16": "^1.0.2", "enzyme-to-json": "^3.1.4", "eslint": "^7.6.0", - "father": "^2.29.10", - "glob": "^7.1.6", + "father": "^4.0.0", + "glob": "^10.0.0", "np": "^5.0.3", "rc-animate": "^2.9.1", "react": "^v16.9.0-alpha.0", "react-dom": "^v16.9.0-alpha.0", - "typescript": "^4.0.0" + "typescript": "^5.0.0" }, "dependencies": { "@babel/runtime": "^7.20.0", diff --git a/update-demo.js b/script/update-content.js similarity index 83% rename from update-demo.js rename to script/update-content.js index 57d561c0..60452da0 100644 --- a/update-demo.js +++ b/script/update-content.js @@ -13,9 +13,14 @@ paths.forEach(path => { const name = path.split('/').pop().split('.')[0]; fs.writeFile( `./docs/demo/${name}.md`, - `## ${name} + `--- +title: ${name} +nav: + title: Demo + path: /demo +--- - + `, 'utf8', function(error) { diff --git a/tsconfig.json b/tsconfig.json index 6be0af1a..19aed7c5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,7 @@ "esModuleInterop": true, "paths": { "@/*": ["src/*"], - "@@/*": ["src/.umi/*"], + "@@/*": [".dumi/tmp/*"], "rc-virtual-list": ["src/index.ts"] } } From a40597ababc07605fd0eab538139f84afa09bf5d Mon Sep 17 00:00:00 2001 From: DBSDs <379712747@qq.com> Date: Thu, 16 Nov 2023 21:28:26 +0800 Subject: [PATCH 2/5] chore: fix father 4.x compile && remove base path --- .dumirc.ts | 2 -- .fatherrc.js | 9 --------- .fatherrc.ts | 5 +++++ package.json | 2 ++ 4 files changed, 7 insertions(+), 11 deletions(-) delete mode 100644 .fatherrc.js create mode 100644 .fatherrc.ts diff --git a/.dumirc.ts b/.dumirc.ts index 2902a869..74c1ed52 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -8,8 +8,6 @@ export default defineConfig({ logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', }, outputPath: '.doc', - base: '/rc-virtual-list/', - publicPath: '/rc-virtual-list/', exportStatic: {}, styles: [ ` diff --git a/.fatherrc.js b/.fatherrc.js deleted file mode 100644 index db0dff5f..00000000 --- a/.fatherrc.js +++ /dev/null @@ -1,9 +0,0 @@ -export default { - cjs: 'babel', - esm: { type: 'babel', importLibToEs: true }, - runtimeHelpers: true, - preCommit: { - eslint: true, - prettier: true, - }, -}; \ No newline at end of file diff --git a/.fatherrc.ts b/.fatherrc.ts new file mode 100644 index 00000000..96268ae1 --- /dev/null +++ b/.fatherrc.ts @@ -0,0 +1,5 @@ +import { defineConfig } from 'father'; + +export default defineConfig({ + plugins: ['@rc-component/father-plugin'], +}); diff --git a/package.json b/package.json index def6ff53..be87daf0 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "react-dom": "*" }, "devDependencies": { + "@rc-component/father-plugin": "^1.0.0", "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^12.1.5", "@types/classnames": "^2.2.10", @@ -51,6 +52,7 @@ "@types/react": "^18.0.8", "@types/react-dom": "^18.0.3", "@types/warning": "^3.0.0", + "@umijs/fabric": "^3.0.0", "cross-env": "^5.2.0", "dumi": "^2.0.0", "enzyme": "^3.1.0", From 73d83df3573bcdc81b7d0b912e6430807d12901b Mon Sep 17 00:00:00 2001 From: DBSDs <379712747@qq.com> Date: Wed, 22 Nov 2023 23:41:21 +0800 Subject: [PATCH 3/5] refactor: use rc-test --- package.json | 7 ++++--- tsconfig.json | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index be87daf0..bfe24559 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "prepare": "dumi setup", "prepublishOnly": "npm run compile && np --no-cleanup --yolo --no-publish", "lint": "eslint src/ --ext .tsx,.ts", - "test": "father test", + "test": "rc-test", "now-build": "npm run build" }, "peerDependencies": { @@ -56,13 +56,14 @@ "cross-env": "^5.2.0", "dumi": "^2.0.0", "enzyme": "^3.1.0", - "enzyme-adapter-react-16": "^1.0.2", + "enzyme-adapter-react-16": "^1.15.6", "enzyme-to-json": "^3.1.4", "eslint": "^7.6.0", "father": "^4.0.0", "glob": "^10.0.0", "np": "^5.0.3", "rc-animate": "^2.9.1", + "rc-test": "^7.0.15", "react": "^v16.9.0-alpha.0", "react-dom": "^v16.9.0-alpha.0", "typescript": "^5.0.0" @@ -73,4 +74,4 @@ "rc-resize-observer": "^1.0.0", "rc-util": "^5.36.0" } -} +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 19aed7c5..236ebc9d 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, From fa846963918998010042a8a81ad51e4391acd905 Mon Sep 17 00:00:00 2001 From: tanghui Date: Fri, 15 Dec 2023 10:34:11 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/scroll.test.js | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/tests/scroll.test.js b/tests/scroll.test.js index fb06d5d2..4fdb6667 100644 --- a/tests/scroll.test.js +++ b/tests/scroll.test.js @@ -1,12 +1,12 @@ +import '@testing-library/jest-dom'; +import { createEvent, fireEvent, render } from '@testing-library/react'; +import { mount } from 'enzyme'; +import { _rs as onLibResize } from 'rc-resize-observer/lib/utils/observerUtil'; +import { resetWarned } from 'rc-util/lib/warning'; import React from 'react'; import { act } from 'react-dom/test-utils'; -import { mount } from 'enzyme'; -import { spyElementPrototypes } from './utils/domHook'; import List from '../src'; -import { createEvent, fireEvent, render } from '@testing-library/react'; -import { resetWarned } from 'rc-util/lib/warning'; -import { _rs as onLibResize } from 'rc-resize-observer/lib/utils/observerUtil'; -import '@testing-library/jest-dom'; +import { spyElementPrototypes } from './utils/domHook'; function genData(count) { return new Array(count).fill(null).map((_, index) => ({ id: String(index) })); @@ -181,13 +181,20 @@ describe('List.Scroll', () => { expect(preventDefault).toHaveBeenCalled(); }); - describe('scrollbar', () => { - it('moving', () => { + const genScrollbarMovingTestFn = (direction) => { + return () => { const listRef = React.createRef(); - const wrapper = genList({ itemHeight: 20, height: 100, data: genData(100), ref: listRef }); + const wrapper = genList({ + itemHeight: 20, + height: 100, + data: genData(100), + ref: listRef, + direction, + scrollWidth: 1000, + }); // Mouse down - wrapper.find('.rc-virtual-list-scrollbar-thumb').simulate('mousedown', { + wrapper.find('.rc-virtual-list-scrollbar-thumb').first().simulate('mousedown', { pageY: 0, }); @@ -211,7 +218,11 @@ describe('List.Scroll', () => { }); expect(wrapper.find('ul').instance().scrollTop > 10).toBeTruthy(); - }); + }; + }; + + describe('scrollbar', () => { + it('moving', genScrollbarMovingTestFn()); describe('not show scrollbar when disabled virtual', () => { [ @@ -238,6 +249,10 @@ describe('List.Scroll', () => { }); }); + describe('scrollbar rtl', () => { + it('moving', genScrollbarMovingTestFn('rtl')); + }); + it('no bubble', () => { const wrapper = genList({ itemHeight: 20, height: 100, data: genData(100) }); From 8a40f3d199c3ceb389a0f34a2f6befefd19b4a57 Mon Sep 17 00:00:00 2001 From: tanghui Date: Fri, 15 Dec 2023 10:41:24 +0800 Subject: [PATCH 5/5] =?UTF-8?q?scrollWidth=20=E6=94=B9=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/scroll.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scroll.test.js b/tests/scroll.test.js index 4fdb6667..a6f4d604 100644 --- a/tests/scroll.test.js +++ b/tests/scroll.test.js @@ -190,7 +190,7 @@ describe('List.Scroll', () => { data: genData(100), ref: listRef, direction, - scrollWidth: 1000, + scrollWidth: 10, }); // Mouse down