diff --git a/.dumirc.ts b/.dumirc.ts index 37524183..1151616f 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -1,8 +1,21 @@ import { defineConfig } from 'dumi'; +import path from 'path'; + +const basePath = process.env.GH_PAGES ? '/virtual-list/' : '/'; +const publicPath = basePath; export default defineConfig({ + alias: { + '@rc-component/virtual-list$': path.resolve(__dirname, 'src'), + '@rc-component/virtual-list/es': path.resolve(__dirname, 'src'), + }, + mfsu: false, + favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'], themeConfig: { - name: 'Tree', + name: 'Virtual List', + logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', }, - outputPath: '.doc', + outputPath: 'docs-dist', + base: basePath, + publicPath, }); 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/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..758659af --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: ant-design +open_collective: ant-design diff --git a/.github/dependabot.yml b/.github/dependabot.yml index dc675c37..3b730ef9 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,41 +1,19 @@ version: 2 updates: -- package-ecosystem: npm - directory: "/" - schedule: - interval: daily - time: "21:00" - open-pull-requests-limit: 10 - ignore: - - dependency-name: np - versions: - - 7.2.0 - - 7.3.0 - - 7.4.0 - - dependency-name: "@types/react" - versions: - - 17.0.0 - - 17.0.1 - - 17.0.2 - - 17.0.3 - - dependency-name: "@types/jest" - versions: - - 26.0.20 - - 26.0.21 - - 26.0.22 - - dependency-name: react - versions: - - 16.14.0 - - 17.0.1 - - dependency-name: "@types/react-dom" - versions: - - 17.0.0 - - 17.0.1 - - 17.0.2 - - dependency-name: typescript - versions: - - 4.1.3 - - 4.1.4 - - 4.1.5 - - 4.2.2 - - 4.2.3 + - package-ecosystem: npm + directory: '/' + schedule: + interval: weekly + day: monday + time: '21:00' + timezone: Asia/Shanghai + open-pull-requests-limit: 10 + + - package-ecosystem: github-actions + directory: '/' + schedule: + interval: weekly + day: monday + time: '21:00' + timezone: Asia/Shanghai + open-pull-requests-limit: 10 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index f06c552e..4ddf3594 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,12 +1,12 @@ -name: "CodeQL" +name: CodeQL on: push: - branches: [ "master" ] + branches: [master] pull_request: - branches: [ "master" ] + branches: [master] schedule: - - cron: "48 4 * * 3" + - cron: '40 12 * * 0' jobs: analyze: @@ -20,22 +20,24 @@ jobs: strategy: fail-fast: false matrix: - language: [ javascript ] + language: [javascript] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v7 + with: + persist-credentials: false - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e with: languages: ${{ matrix.language }} queries: +security-and-quality - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e with: - category: "/language:${{ matrix.language }}" + category: '/language:${{ matrix.language }}' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 716559ca..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,6 +0,0 @@ -name: test -on: [push, pull_request] -jobs: - test: - uses: react-component/rc-test/.github/workflows/test.yml@main - secrets: inherit diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml new file mode 100644 index 00000000..1d160790 --- /dev/null +++ b/.github/workflows/react-component-ci.yml @@ -0,0 +1,16 @@ +name: ✅ test + +on: + push: + branches: [master] + pull_request: + branches: [master] + +permissions: + contents: read + +jobs: + test: + uses: react-component/rc-test/.github/workflows/test-utoo.yml@main + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/react-doctor.yml b/.github/workflows/react-doctor.yml new file mode 100644 index 00000000..56430b6e --- /dev/null +++ b/.github/workflows/react-doctor.yml @@ -0,0 +1,24 @@ +name: React Doctor + +on: + pull_request: + branches: [master] + +permissions: + contents: read + pull-requests: write + +concurrency: + group: react-doctor-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + react-doctor: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + - uses: millionco/react-doctor@0b4f4f4bd248a154e64eb508a48347f71154b3f3 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml new file mode 100644 index 00000000..1a44351c --- /dev/null +++ b/.github/workflows/surge-preview.yml @@ -0,0 +1,47 @@ +name: Surge Preview + +on: + pull_request: + branches: [master] + +permissions: + contents: read + pull-requests: write + statuses: write + +concurrency: + group: surge-preview-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + preview: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + - name: Check Surge token + id: surge-token + env: + SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} + run: | + if [ -n "$SURGE_TOKEN" ]; then + echo "enabled=true" >> "$GITHUB_OUTPUT" + else + echo "enabled=false" >> "$GITHUB_OUTPUT" + fi + - name: Install dependencies + if: ${{ steps.surge-token.outputs.enabled == 'true' }} + run: npm install --ignore-scripts --no-audit --loglevel=warn + - name: Build preview + if: ${{ steps.surge-token.outputs.enabled == 'true' }} + run: npm run build + - uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec + if: ${{ steps.surge-token.outputs.enabled == 'true' }} + env: + SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} + with: + dist: docs-dist + failOnError: false + github_token: ${{ secrets.GITHUB_TOKEN }} + surge_token: ${{ env.SURGE_TOKEN }} diff --git a/.gitignore b/.gitignore index 615c9938..d7e5aee8 100644 --- a/.gitignore +++ b/.gitignore @@ -11,11 +11,15 @@ pnpm-lock.yaml !tests/__mocks__/rc-util/lib !tests/__mocks__/@rc-component/util/lib bun.lockb - # umi .umi .umi-production .umi-test .env.local - -.dumi \ No newline at end of file +.dumi/tmp +.dumi/tmp-production +lib +es +coverage +docs-dist +.vercel diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 00000000..2312dc58 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +npx lint-staged diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..c466d872 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,14 @@ +node_modules +coverage +docs-dist +dist +es +lib +.dumi/tmp +.dumi/tmp-production +.vercel +package-lock.json +pnpm-lock.yaml +yarn.lock +bun.lockb +*.log diff --git a/README.md b/README.md index fa110e03..0d63d5f0 100644 --- a/README.md +++ b/README.md @@ -1,79 +1,99 @@ -# @rc-component/virtual-list - -React Virtual List Component which works with animation. - -[![NPM version][npm-image]][npm-url] -[![npm download][download-image]][download-url] -[![build status][github-actions-image]][github-actions-url] -[![Codecov][codecov-image]][codecov-url] -[![bundle size][bundlephobia-image]][bundlephobia-url] -[![dumi][dumi-image]][dumi-url] - -[npm-image]: https://img.shields.io/npm/v/@rc-component/virtual-list.svg?style=flat-square -[npm-url]: https://npmjs.org/package/@rc-component/virtual-list -[travis-image]: https://img.shields.io/travis/react-component/virtual-list/master?style=flat-square -[travis-url]: https://travis-ci.com/react-component/virtual-list -[github-actions-image]: https://github.com/react-component/virtual-list/actions/workflows/main.yml/badge.svg -[github-actions-url]: https://github.com/react-component/virtual-list/actions/workflows/main.yml -[codecov-image]: https://img.shields.io/codecov/c/github/react-component/virtual-list/master.svg?style=flat-square -[codecov-url]: https://app.codecov.io/gh/react-component/virtual-list -[david-url]: https://david-dm.org/react-component/virtual-list -[david-image]: https://david-dm.org/react-component/virtual-list/status.svg?style=flat-square -[david-dev-url]: https://david-dm.org/react-component/virtual-list?type=dev -[david-dev-image]: https://david-dm.org/react-component/virtual-list/dev-status.svg?style=flat-square -[download-image]: https://img.shields.io/npm/dm/@rc-component/virtual-list.svg?style=flat-square -[download-url]: https://npmjs.org/package/@rc-component/virtual-list -[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/virtual-list -[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/@rc-component/virtual-list -[dumi-url]: https://github.com/umijs/dumi -[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square - -## Online Preview - -https://virtual-list-react-component.vercel.app/ +
Part of the Ant Design ecosystem.
📜 Virtual scrolling list component for React.
-## Development + +English | 简体中文
-```bash -npm install -npm start -open http://localhost:8000/ -``` -## Feature +## Highlights -- Support react.js -- Support animation -- Support IE11+ +- Built for React and maintained by the rc-component team. +- Used by Ant Design and other React component libraries. +- Ships TypeScript declarations with both ES module and CommonJS outputs. +- Keeps examples, tests, and preview builds aligned with the package source. ## Install -[](https://npmjs.org/package/@rc-component/virtual-list) +```bash +npm install @rc-component/virtual-list +``` ## Usage ```tsx import List from '@rc-component/virtual-list'; -English | 简体中文
+ + +## 特性 + +- 面向 React 构建,并由 rc-component 团队维护。 +- 被 Ant Design 使用和其他 React 组件库使用。 +- 提供 TypeScript 类型声明,同时输出 ES module 和 CommonJS 产物。 +- 示例、测试和预览构建与包源码保持一致。 + +## 安装 + +```bash +npm install @rc-component/virtual-list +``` + +## 使用 + +```tsx +import List from '@rc-component/virtual-list'; + +const data = Array.from({ length: 1000 }).map((_, index) => ({ + id: index, + label: `Item ${index}`, +})); + +export default () => ( +
\ No newline at end of file
+
diff --git a/docs/index.md b/docs/index.md
index 8eb92fd2..501296b5 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -1,5 +1,5 @@
---
-title: rc-virtual-list
+title: '@rc-component/virtual-list'
---
diff --git a/package.json b/package.json
index 2ed54719..62e4e0d9 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "@rc-component/virtual-list",
"version": "1.2.0",
- "description": "React Virtual List Component",
+ "description": "Virtual scrolling list component for React.",
"engines": {
"node": ">=8.x"
},
@@ -10,7 +10,7 @@
"react-component",
"virtual-list"
],
- "homepage": "https://github.com/react-component/virtual-list",
+ "homepage": "https://react-component.github.io/virtual-list",
"author": "smith3816@gmail.com",
"repository": {
"type": "git",
@@ -28,38 +28,50 @@
"main": "./lib/index",
"module": "./es/index",
"scripts": {
- "start": "dumi dev",
- "build": "dumi build",
+ "build": "npm run compile && npm run docs:build",
"compile": "father build",
- "prepublishOnly": "npm run compile && rc-np",
+ "coverage": "rc-test --coverage",
+ "docs:build": "dumi build",
+ "docs:deploy": "gh-pages -d docs-dist",
+ "deploy": "npm run gh-pages",
+ "gh-pages": "npm run compile && cross-env GH_PAGES=1 npm run docs:build && npm run docs:deploy",
"lint": "eslint src/ --ext .tsx,.ts",
+ "prepublishOnly": "npm run compile && rc-np",
+ "prettier": "prettier --write --ignore-unknown .",
+ "start": "dumi dev",
"test": "rc-test",
- "now-build": "npm run build"
+ "tsc": "tsc --noEmit",
+ "prepare": "husky"
},
"peerDependencies": {
"react": ">=18.0.0",
"react-dom": ">=18.0.0"
},
"devDependencies": {
- "@rc-component/father-plugin": "^2.1.3",
+ "@rc-component/father-plugin": "^2.2.0",
"@rc-component/np": "^1.0.4",
- "@testing-library/jest-dom": "^5.17.0",
- "@testing-library/react": "^13.4.0",
- "@types/jest": "^30.0.0",
- "@types/node": "^24.10.1",
- "@types/react": "^18.0.8",
- "@types/react-dom": "^18.0.3",
- "@types/warning": "^3.0.0",
- "dumi": "^2.2.17",
- "eslint": "^8.56.0",
- "eslint-plugin-unicorn": "^55.0.0",
- "father": "^4.4.0",
- "glob": "^7.1.6",
+ "@testing-library/jest-dom": "^6.9.1",
+ "@testing-library/react": "^15.0.7",
+ "@types/jest": "^29.5.14",
+ "@types/node": "^26.0.1",
+ "@types/react": "^18.3.31",
+ "@types/react-dom": "^18.3.7",
+ "@types/warning": "^3.0.4",
+ "dumi": "^2.4.35",
+ "eslint": "^8.57.1",
+ "eslint-plugin-unicorn": "^56.0.1",
+ "father": "^4.6.23",
+ "glob": "^13.0.6",
"rc-animate": "^2.9.1",
"rc-test": "^7.1.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
- "typescript": "^5.0.0"
+ "typescript": "^5.9.3",
+ "cross-env": "^10.1.0",
+ "gh-pages": "^6.3.0",
+ "prettier": "^3.9.0",
+ "husky": "^9.1.7",
+ "lint-staged": "^16.4.0"
},
"dependencies": {
"@babel/runtime": "^7.20.0",
@@ -69,5 +81,9 @@
},
"publishConfig": {
"access": "public"
- }
+ },
+ "lint-staged": {
+ "*": "prettier --write --ignore-unknown"
+ },
+ "types": "./es/index.d.ts"
}
diff --git a/tsconfig.json b/tsconfig.json
index 30faa7c5..edc503cd 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -12,11 +12,30 @@
"src/*"
],
"@@/*": [
- "src/.umi/*"
+ ".dumi/tmp/*"
],
- "rc-virtual-list": [
+ "@rc-component/virtual-list": [
"src/index.ts"
+ ],
+ "@rc-component/virtual-list/es": [
+ "src"
+ ],
+ "@rc-component/virtual-list/es/*": [
+ "src/*"
]
- }
- }
-}
\ No newline at end of file
+ },
+ "ignoreDeprecations": "5.0"
+ },
+ "include": [
+ ".dumirc.ts",
+ ".fatherrc.ts",
+ "src",
+ "tests",
+ "examples"
+ ],
+ "exclude": [
+ "docs-dist",
+ "lib",
+ "es"
+ ]
+}
diff --git a/vercel.json b/vercel.json
index 57c51ac8..5f9139ef 100644
--- a/vercel.json
+++ b/vercel.json
@@ -1,3 +1,6 @@
{
- "framework": "umijs"
-}
\ No newline at end of file
+ "framework": "umijs",
+ "installCommand": "npm install",
+ "buildCommand": "npm run build",
+ "outputDirectory": "docs-dist"
+}