diff --git a/.umirc.ts b/.dumirc.ts similarity index 53% rename from .umirc.ts rename to .dumirc.ts index b5a40158..74c1ed52 100644 --- a/.umirc.ts +++ b/.dumirc.ts @@ -2,21 +2,18 @@ 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', + 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', exportStatic: {}, - resolve: { - examples: ['none'], - }, styles: [ ` .markdown table { width: auto !important; } `, - ] + ], }); 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/.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/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..bfe24559 100644 --- a/package.json +++ b/package.json @@ -32,9 +32,10 @@ "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", + "test": "rc-test", "now-build": "npm run build" }, "peerDependencies": { @@ -42,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", @@ -50,19 +52,21 @@ "@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": "^1.1.12", + "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": "^2.29.10", - "glob": "^7.1.6", + "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": "^4.0.0" + "typescript": "^5.0.0" }, "dependencies": { "@babel/runtime": "^7.20.0", @@ -70,4 +74,4 @@ "rc-resize-observer": "^1.0.0", "rc-util": "^5.36.0" } -} +} \ No newline at end of file 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/tests/scroll.test.js b/tests/scroll.test.js index fb06d5d2..a6f4d604 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: 10, + }); // 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) }); diff --git a/tsconfig.json b/tsconfig.json index 6be0af1a..236ebc9d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,13 +3,13 @@ "target": "esnext", "moduleResolution": "node", "baseUrl": "./", - "jsx": "preserve", + "jsx": "react", "declaration": true, "skipLibCheck": true, "esModuleInterop": true, "paths": { "@/*": ["src/*"], - "@@/*": ["src/.umi/*"], + "@@/*": [".dumi/tmp/*"], "rc-virtual-list": ["src/index.ts"] } }