From 409bb9b44937a0e0bd8c5bb823befca4800a8f89 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 14:38:28 +0800 Subject: [PATCH 01/34] chore: standardize repository maintenance --- .dumirc.ts | 7 +- .github/FUNDING.yml | 17 +- .../workflows/cloudflare-pages-preview.yml | 42 ++++ .github/workflows/codeql.yml | 43 ++++ .github/workflows/main.yml | 6 - .github/workflows/react-component-ci.yml | 8 + .github/workflows/react-doctor.yml | 27 +++ .github/workflows/surge-preview.yml | 39 ++++ .gitignore | 4 +- README.md | 195 ++++++++++++------ now.json | 11 - package.json | 14 +- tsconfig.json | 7 +- vercel.json | 6 + 14 files changed, 322 insertions(+), 104 deletions(-) create mode 100644 .github/workflows/cloudflare-pages-preview.yml create mode 100644 .github/workflows/codeql.yml delete mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/react-component-ci.yml create mode 100644 .github/workflows/react-doctor.yml create mode 100644 .github/workflows/surge-preview.yml delete mode 100644 now.json create mode 100644 vercel.json diff --git a/.dumirc.ts b/.dumirc.ts index 36947e0..e9f7604 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -2,6 +2,9 @@ import { defineConfig } from 'dumi'; import path from 'path'; +const basePath = process.env.GH_PAGES ? '/motion/' : '/'; +const publicPath = process.env.GH_PAGES ? '/motion/' : '/'; + export default defineConfig({ alias: { 'rc-motion$': path.resolve('src'), @@ -12,6 +15,8 @@ export default defineConfig({ name: 'Motion', logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', }, - outputPath: '.doc', + outputPath: 'docs-dist', + base: basePath, + publicPath, exportStatic: {}, }); diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 33b1999..758659a 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,15 +1,2 @@ -# These are supported funding model platforms - -github: ant-design # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] -patreon: # Replace with a single Patreon username -open_collective: ant-design # Replace with a single Open Collective username -ko_fi: # Replace with a single Ko-fi username -tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -liberapay: # Replace with a single Liberapay username -issuehunt: # Replace with a single IssueHunt username -lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry -polar: # Replace with a single Polar username -buy_me_a_coffee: # Replace with a single Buy Me a Coffee username -thanks_dev: # Replace with a single thanks.dev username -custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] +github: ant-design +open_collective: ant-design diff --git a/.github/workflows/cloudflare-pages-preview.yml b/.github/workflows/cloudflare-pages-preview.yml new file mode 100644 index 0000000..d925f51 --- /dev/null +++ b/.github/workflows/cloudflare-pages-preview.yml @@ -0,0 +1,42 @@ +name: Cloudflare Pages Preview + +on: + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +permissions: + contents: read + deployments: write + +jobs: + preview: + runs-on: ubuntu-latest + env: + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + CLOUDFLARE_PAGES_PROJECT: ${{ vars.CLOUDFLARE_PAGES_PROJECT }} + PREVIEW: true + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + with: + persist-credentials: false + - name: Skip Cloudflare Pages preview + if: ${{ env.CLOUDFLARE_API_TOKEN == '' || env.CLOUDFLARE_ACCOUNT_ID == '' || env.CLOUDFLARE_PAGES_PROJECT == '' }} + run: echo "Cloudflare Pages preview is not configured; skip deployment." + - name: Install dependencies + if: ${{ env.CLOUDFLARE_API_TOKEN != '' && env.CLOUDFLARE_ACCOUNT_ID != '' && env.CLOUDFLARE_PAGES_PROJECT != '' }} + run: npm install + - name: Build site + if: ${{ env.CLOUDFLARE_API_TOKEN != '' && env.CLOUDFLARE_ACCOUNT_ID != '' && env.CLOUDFLARE_PAGES_PROJECT != '' }} + run: npm run build + - name: Deploy preview + if: ${{ env.CLOUDFLARE_API_TOKEN != '' && env.CLOUDFLARE_ACCOUNT_ID != '' && env.CLOUDFLARE_PAGES_PROJECT != '' }} + uses: cloudflare/wrangler-action@ebbaa1584979971c8614a24965b4405ff95890e0 + with: + apiToken: ${{ env.CLOUDFLARE_API_TOKEN }} + accountId: ${{ env.CLOUDFLARE_ACCOUNT_ID }} + command: pages deploy docs-dist --project-name=${{ env.CLOUDFLARE_PAGES_PROJECT }} --branch=${{ github.head_ref }} + gitHubToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..27f7a7d --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,43 @@ +name: 'CodeQL' + +on: + push: + branches: ['master'] + pull_request: + branches: ['master'] + schedule: + - cron: '24 18 * * 1' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [javascript] + + steps: + - name: Checkout + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + with: + persist-credentials: false + + - name: Initialize CodeQL + uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + with: + languages: ${{ matrix.language }} + queries: +security-and-quality + + - name: Autobuild + uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + with: + category: '/language:${{ matrix.language }}' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 5735e2d..0000000 --- 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 \ No newline at end of file diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml new file mode 100644 index 0000000..9503b96 --- /dev/null +++ b/.github/workflows/react-component-ci.yml @@ -0,0 +1,8 @@ +name: ✅ test +on: [push, pull_request] +permissions: + contents: read +jobs: + test: + uses: react-component/rc-test/.github/workflows/test-utoo.yml@main + secrets: inherit diff --git a/.github/workflows/react-doctor.yml b/.github/workflows/react-doctor.yml new file mode 100644 index 0000000..f68281c --- /dev/null +++ b/.github/workflows/react-doctor.yml @@ -0,0 +1,27 @@ +name: React Doctor + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + push: + branches: [master] + +permissions: + contents: read + pull-requests: write + issues: write + statuses: 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@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + with: + fetch-depth: 0 + persist-credentials: false + - uses: millionco/react-doctor@0b4f4f4bd248a154e64eb508a48347f71154b3f3 diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml new file mode 100644 index 0000000..1b29a17 --- /dev/null +++ b/.github/workflows/surge-preview.yml @@ -0,0 +1,39 @@ +name: Surge Preview + +on: + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +permissions: + contents: read + pull-requests: write + checks: write + statuses: write + +jobs: + preview: + runs-on: ubuntu-latest + env: + SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} + PREVIEW: true + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + with: + persist-credentials: false + - uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec + if: ${{ env.SURGE_TOKEN != '' }} + with: + surge_token: ${{ env.SURGE_TOKEN }} + github_token: ${{ secrets.GITHUB_TOKEN }} + dist: docs-dist + failOnError: true + setCommitStatus: true + build: | + npm install + npm run build + - name: Skip Surge preview + if: ${{ env.SURGE_TOKEN == '' }} + run: echo "SURGE_TOKEN is not configured; skip Surge preview." diff --git a/.gitignore b/.gitignore index 0bba155..5047112 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ package-lock.json pnpm-lock.yaml coverage/ .doc +docs-dist/ # dumi .dumi/tmp @@ -37,4 +38,5 @@ coverage/ .dumi/tmp-test .node -bun.lockb \ No newline at end of file +bun.lockb +.vercel diff --git a/README.md b/README.md index 3ab5c4f..db16a2a 100644 --- a/README.md +++ b/README.md @@ -1,95 +1,166 @@ -# @rc-component/motion - - -[![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]: http://img.shields.io/npm/v/@rc-component/motion.svg?style=flat-square -[npm-url]: http://npmjs.org/package/@rc-component/motion -[travis-image]: https://img.shields.io/travis/react-component/motion/master?style=flat-square -[travis-url]: https://travis-ci.com/react-component/motion -[github-actions-image]: https://github.com/react-component/motion/actions/workflows/main.yml/badge.svg -[github-actions-url]: https://github.com/react-component/motion/actions/workflows/main.yml -[codecov-image]: https://img.shields.io/codecov/c/github/react-component/motion/master.svg?style=flat-square -[codecov-url]: https://app.codecov.io/gh/react-component/motion -[david-url]: https://david-dm.org/react-component/motion -[david-image]: https://david-dm.org/react-component/motion/status.svg?style=flat-square -[david-dev-url]: https://david-dm.org/react-component/motion?type=dev -[david-dev-image]: https://david-dm.org/react-component/motion/dev-status.svg?style=flat-square -[download-image]: https://img.shields.io/npm/dm/@rc-component/motion.svg?style=flat-square -[download-url]: https://npmjs.org/package/@rc-component/motion -[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/motion -[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/@rc-component/motion -[dumi-url]: https://github.com/umijs/dumi -[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square +
+

@rc-component/motion

+

🎞️ Lifecycle-driven motion primitives for React enter, leave, and list animations.

+
+ +
+ +[![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] + +
-React lifecycle controlled motion library. +
+ + Part of the Ant Design ecosystem + Ant Design + +
-## Live Demo +## Highlights -https://react-component.github.io/motion/ +- Declarative `CSSMotion` component for appear, enter, and leave states. +- `CSSMotionList` for keyed list transitions. +- CSS class lifecycle hooks and inline style patching callbacks. +- Optional deadline fallback when transition or animation events do not fire. +- TypeScript definitions and React ref support. +- Used by Ant Design components that need predictable motion lifecycles. ## Install -[![@rc-component/motion](https://nodei.co/npm/@rc-component/motion.png)](https://npmjs.org/package/@rc-component/motion) +```bash +npm install @rc-component/motion +``` -## Example +## Usage -```js +```tsx | pure import CSSMotion from '@rc-component/motion'; -export default ({ visible }) => ( - - {({ className, style }) =>
} +export default ({ visible }: { visible: boolean }) => ( + + {({ className, style }, ref) => ( +
+ Content +
+ )}
); ``` +```tsx | pure +import { CSSMotionList } from '@rc-component/motion'; + +export default ({ keys }: { keys: React.Key[] }) => ( + + {({ key, className, style }, ref) => ( +
+ {key} +
+ )} +
+); +``` + +## Examples + +Run the examples locally: + +```bash +npm install +npm start +``` + +Then open the dumi dev server in your browser. + ## API ### CSSMotion | Property | Type | Default | Description | | --- | --- | --- | --- | -| motionName | string | - | Config motion name, will dynamic update when status changed | -| visible | boolean | true | Trigger motion events | -| motionAppear | boolean | true | Use motion when appear | -| motionEnter | boolean | true | Use motion when enter | -| motionLeave | boolean | true | Use motion when leave | -| motionLeaveImmediately | boolean | - | Will trigger leave even on mount | -| motionDeadline | number | - | Trigger motion status change even when motion event not fire | -| removeOnLeave | boolean | true | Remove element when motion leave end | -| leavedClassName | string | - | Set leaved element className | -| onAppearStart | (HTMLElement, Event) => CSSProperties \| void; | - | Trigger when appear start, return style will patch to element | -| onEnterStart | (HTMLElement, Event) => CSSProperties \| void; | - | Trigger when enter start, return style will patch to element | -| onLeaveStart | (HTMLElement, Event) => CSSProperties \| void; | - | Trigger when leave start, return style will patch to element | -| onAppearActive | (HTMLElement, Event) => CSSProperties \| void; | - | Trigger when appear active, return style will patch to element | -| onEnterActive | (HTMLElement, Event) => CSSProperties \| void; | - | Trigger when enter active, return style will patch to element | -| onLeaveActive | (HTMLElement, Event) => CSSProperties \| void; | - | Trigger when leave active, return style will patch to element | -| onAppearEnd | (HTMLElement, Event) => boolean \| void; | - | Trigger when appear end, will not finish when return false | -| onEnterEnd | (HTMLElement, Event) => boolean \| void; | - | Trigger when enter end, will not finish when return false | -| onLeaveEnd | (HTMLElement, Event) => boolean \| void; | - | Trigger when leave end, will not finish when return false | +| children | `(props, ref) => ReactElement` | - | Render function that receives motion class, style, and ref. | +| forceRender | `boolean` | `false` | Keep the element rendered even when invisible. | +| leavedClassName | `string` | - | Class name applied after leave when the element remains. | +| motionAppear | `boolean` | `true` | Enable appear motion. | +| motionDeadline | `number` | - | Fallback timeout in milliseconds for motion completion. | +| motionEnter | `boolean` | `true` | Enable enter motion. | +| motionLeave | `boolean` | `true` | Enable leave motion. | +| motionLeaveImmediately | `boolean` | - | Trigger leave immediately after mount. | +| motionName | `string \| MotionName` | - | CSS class name prefix or per-phase class names. | +| removeOnLeave | `boolean` | `true` | Remove the element after leave. Ignored when `forceRender` is set. | +| visible | `boolean` | `true` | Controls whether the element is visible. | +| onAppearActive | `MotionEventHandler` | - | Triggered during appear active phase. | +| onAppearEnd | `MotionEndEventHandler` | - | Triggered when appear finishes. Return `false` to keep waiting. | +| onAppearPrepare | `MotionPrepareEventHandler` | - | Prepare callback before appear starts. | +| onAppearStart | `MotionEventHandler` | - | Triggered when appear starts. | +| onEnterActive | `MotionEventHandler` | - | Triggered during enter active phase. | +| onEnterEnd | `MotionEndEventHandler` | - | Triggered when enter finishes. Return `false` to keep waiting. | +| onEnterPrepare | `MotionPrepareEventHandler` | - | Prepare callback before enter starts. | +| onEnterStart | `MotionEventHandler` | - | Triggered when enter starts. | +| onLeaveActive | `MotionEventHandler` | - | Triggered during leave active phase. | +| onLeaveEnd | `MotionEndEventHandler` | - | Triggered when leave finishes. Return `false` to keep waiting. | +| onLeavePrepare | `MotionPrepareEventHandler` | - | Prepare callback before leave starts. | +| onLeaveStart | `MotionEventHandler` | - | Triggered when leave starts. | +| onVisibleChanged | `(visible: boolean) => void` | - | Triggered after the final visible state changes. | ### CSSMotionList -extends all the props from [CSSMotion](#CSSMotion) +`CSSMotionList` accepts the motion props above, except `children` is a list render function. + +| Property | Type | Default | Description | +| --- | --- | --- | --- | +| children | `(props, ref) => ReactElement` | - | Render function for each keyed item. | +| component | `string \| ComponentType \| false` | `div` | Wrapper component. Use `false` for no wrapper. | +| keys | `(React.Key \| { key: React.Key })[]` | - | Keys to animate. | +| onAllRemoved | `() => void` | - | Triggered after every leaving item is removed. | +| onVisibleChanged | `(visible, info: { key: React.Key }) => void` | - | Triggered after an item visibility changes. | + +### Ref -| Property | Type | Default | Description | -| --------- | ----------------------------- | ------- | ----------------- | -| keys | React.Key[] | - | Motion list keys | -| component | string \| React.ComponentType | div | wrapper component | +| Ref method | Type | Description | +| --- | --- | --- | +| `enableMotion` | `() => boolean` | Whether motion is currently enabled. | +| `inMotion` | `() => boolean` | Whether the element is in a motion lifecycle. | +| `nativeElement` | `HTMLElement` | Current DOM element. | ## Development -``` +```bash npm install npm start +npm test +npm run tsc +npm run compile +npm run build +``` + +## Release + +The package is published with [`@rc-component/np`](https://github.com/react-component/np): + +```bash +npm run prepublishOnly ``` +This runs the package build before the release helper. The `postpublish` script builds and deploys the documentation site. + ## License -@rc-component/motion is released under the MIT license. +`@rc-component/motion` is released under the MIT license. + +[npm-image]: https://img.shields.io/npm/v/@rc-component/motion.svg?style=flat-square +[npm-url]: https://npmjs.org/package/@rc-component/motion +[github-actions-image]: https://github.com/react-component/motion/actions/workflows/react-component-ci.yml/badge.svg +[github-actions-url]: https://github.com/react-component/motion/actions/workflows/react-component-ci.yml +[codecov-image]: https://img.shields.io/codecov/c/github/react-component/motion/master.svg?style=flat-square +[codecov-url]: https://app.codecov.io/gh/react-component/motion +[download-image]: https://img.shields.io/npm/dm/@rc-component/motion.svg?style=flat-square +[download-url]: https://npmjs.org/package/@rc-component/motion +[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/motion +[bundlephobia-image]: https://img.shields.io/bundlephobia/minzip/@rc-component/motion?style=flat-square +[dumi-url]: https://github.com/umijs/dumi +[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square diff --git a/now.json b/now.json deleted file mode 100644 index 4234570..0000000 --- a/now.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": 2, - "name": "rc-motion", - "builds": [ - { - "src": "package.json", - "use": "@now/static-build", - "config": { "distDir": ".doc" } - } - ] -} diff --git a/package.json b/package.json index 00f9231..a29e1e0 100644 --- a/package.json +++ b/package.json @@ -27,23 +27,25 @@ "lib" ], "scripts": { + "build": "npm run docs:build", "compile": "father build", "docs:build": "dumi build", - "docs:deploy": "gh-pages -d .doc", + "docs:deploy": "gh-pages -d docs-dist", + "gh-pages": "GH_PAGES=1 npm run docs:build && npm run docs:deploy", "lint": "eslint src/ --ext .tsx,.ts", "lint:tsc": "tsc --noEmit", "now-build": "npm run docs:build", "prepare": "husky install", "prepublishOnly": "npm run compile && rc-np", - "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"", - "postpublish": "npm run docs:build && npm run docs:deploy", + "prettier": "prettier --write --ignore-unknown .", + "postpublish": "npm run gh-pages", "start": "dumi dev", - "test": "rc-test" + "test": "rc-test", + "tsc": "tsc --noEmit" }, "lint-staged": { "**/*.{js,jsx,tsx,ts,md,json}": [ - "prettier --write", - "git add" + "prettier --write --ignore-unknown" ] }, "resolutions": { diff --git a/tsconfig.json b/tsconfig.json index 6ff0503..facff75 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,8 +9,11 @@ "esModuleInterop": true, "paths": { "@/*": ["src/*"], - "@@/*": ["src/.umi/*"], + "@@/*": [".dumi/tmp/*"], + "@rc-component/motion": ["src/index.tsx"], "rc-motion": ["src/index.tsx"] } - } + }, + "include": ["src", "docs", ".dumirc.ts", ".fatherrc.ts"], + "exclude": ["node_modules", "lib", "es", "dist", "docs-dist", ".dumi"] } diff --git a/vercel.json b/vercel.json new file mode 100644 index 0000000..5f9139e --- /dev/null +++ b/vercel.json @@ -0,0 +1,6 @@ +{ + "framework": "umijs", + "installCommand": "npm install", + "buildCommand": "npm run build", + "outputDirectory": "docs-dist" +} From b42150ecc75f752504a8a661dfdb4c2abeeb78eb Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 15:04:22 +0800 Subject: [PATCH 02/34] chore: remove cloudflare preview and now-build --- .../workflows/cloudflare-pages-preview.yml | 42 ------------------- package.json | 1 - 2 files changed, 43 deletions(-) delete mode 100644 .github/workflows/cloudflare-pages-preview.yml diff --git a/.github/workflows/cloudflare-pages-preview.yml b/.github/workflows/cloudflare-pages-preview.yml deleted file mode 100644 index d925f51..0000000 --- a/.github/workflows/cloudflare-pages-preview.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Cloudflare Pages Preview - -on: - pull_request: - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number }} - cancel-in-progress: true - -permissions: - contents: read - deployments: write - -jobs: - preview: - runs-on: ubuntu-latest - env: - CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} - CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - CLOUDFLARE_PAGES_PROJECT: ${{ vars.CLOUDFLARE_PAGES_PROJECT }} - PREVIEW: true - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 - with: - persist-credentials: false - - name: Skip Cloudflare Pages preview - if: ${{ env.CLOUDFLARE_API_TOKEN == '' || env.CLOUDFLARE_ACCOUNT_ID == '' || env.CLOUDFLARE_PAGES_PROJECT == '' }} - run: echo "Cloudflare Pages preview is not configured; skip deployment." - - name: Install dependencies - if: ${{ env.CLOUDFLARE_API_TOKEN != '' && env.CLOUDFLARE_ACCOUNT_ID != '' && env.CLOUDFLARE_PAGES_PROJECT != '' }} - run: npm install - - name: Build site - if: ${{ env.CLOUDFLARE_API_TOKEN != '' && env.CLOUDFLARE_ACCOUNT_ID != '' && env.CLOUDFLARE_PAGES_PROJECT != '' }} - run: npm run build - - name: Deploy preview - if: ${{ env.CLOUDFLARE_API_TOKEN != '' && env.CLOUDFLARE_ACCOUNT_ID != '' && env.CLOUDFLARE_PAGES_PROJECT != '' }} - uses: cloudflare/wrangler-action@ebbaa1584979971c8614a24965b4405ff95890e0 - with: - apiToken: ${{ env.CLOUDFLARE_API_TOKEN }} - accountId: ${{ env.CLOUDFLARE_ACCOUNT_ID }} - command: pages deploy docs-dist --project-name=${{ env.CLOUDFLARE_PAGES_PROJECT }} --branch=${{ github.head_ref }} - gitHubToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index a29e1e0..07cb552 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,6 @@ "gh-pages": "GH_PAGES=1 npm run docs:build && npm run docs:deploy", "lint": "eslint src/ --ext .tsx,.ts", "lint:tsc": "tsc --noEmit", - "now-build": "npm run docs:build", "prepare": "husky install", "prepublishOnly": "npm run compile && rc-np", "prettier": "prettier --write --ignore-unknown .", From ebde91f67473495707491672ce37e8e6ae506a4f Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 00:42:17 +0800 Subject: [PATCH 03/34] docs: add Ant Design logo to README header --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index db16a2a..abdb6ba 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@

@rc-component/motion

+ Ant Design

🎞️ Lifecycle-driven motion primitives for React enter, leave, and list animations.

From c8982e6956955358f01e82455d794e88e0126d39 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 01:27:21 +0800 Subject: [PATCH 04/34] chore: address AI review feedback --- package.json | 3 ++- tsconfig.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 07cb552..5d62e27 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "compile": "father build", "docs:build": "dumi build", "docs:deploy": "gh-pages -d docs-dist", - "gh-pages": "GH_PAGES=1 npm run docs:build && npm run docs:deploy", + "gh-pages": "cross-env GH_PAGES=1 npm run docs:build && npm run docs:deploy", "lint": "eslint src/ --ext .tsx,.ts", "lint:tsc": "tsc --noEmit", "prepare": "husky install", @@ -64,6 +64,7 @@ "@types/react": "^18.0.0", "@types/react-dom": "^18.0.0", "@umijs/fabric": "^4.0.0", + "cross-env": "^7.0.0", "dumi": "^2.0.18", "eslint": "^8.0.0", "father": "^4.1.2", diff --git a/tsconfig.json b/tsconfig.json index facff75..344468c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,5 +15,5 @@ } }, "include": ["src", "docs", ".dumirc.ts", ".fatherrc.ts"], - "exclude": ["node_modules", "lib", "es", "dist", "docs-dist", ".dumi"] + "exclude": ["node_modules", "lib", "es", "dist", "docs-dist"] } From 72f390c3caf9e39adb2dde9f9840efa39d764c91 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 01:56:48 +0800 Subject: [PATCH 05/34] docs: standardize README release details --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index abdb6ba..4092f2b 100644 --- a/README.md +++ b/README.md @@ -141,17 +141,15 @@ npm run build ## Release -The package is published with [`@rc-component/np`](https://github.com/react-component/np): - ```bash npm run prepublishOnly ``` -This runs the package build before the release helper. The `postpublish` script builds and deploys the documentation site. +The release flow is handled by `@rc-component/np` through the `rc-np` command after the package build. ## License -`@rc-component/motion` is released under the MIT license. +@rc-component/motion is released under the [MIT](./LICENSE.md) license. [npm-image]: https://img.shields.io/npm/v/@rc-component/motion.svg?style=flat-square [npm-url]: https://npmjs.org/package/@rc-component/motion From b0deaca18e3c7f5d6a705e0b7fbad00f23c1f95a Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 02:13:57 +0800 Subject: [PATCH 06/34] ci: make surge preview non-blocking --- .github/workflows/surge-preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index 1b29a17..ad8683d 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -29,7 +29,7 @@ jobs: surge_token: ${{ env.SURGE_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }} dist: docs-dist - failOnError: true + failOnError: false setCommitStatus: true build: | npm install From 493fb36fd84ead3ff0afeea8bdc35dbf334b01a6 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 02:17:44 +0800 Subject: [PATCH 07/34] docs: clarify Ant Design ecosystem note --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 4092f2b..1fa0a0d 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,15 @@

🎞️ Lifecycle-driven motion primitives for React enter, leave, and list animations.

+

+ + + Ant Design + + Part of the Ant Design ecosystem. + +

+
[![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] From 98189eeec40974bc72b8dfef2377aefb42d0aeb5 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 02:25:41 +0800 Subject: [PATCH 08/34] ci: keep surge preview as fallback --- .github/workflows/surge-preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index ad8683d..70768bf 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -30,7 +30,7 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} dist: docs-dist failOnError: false - setCommitStatus: true + setCommitStatus: false build: | npm install npm run build From 1f67062dc26be5af7ead60145473abc5d481062c Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 13:04:01 +0800 Subject: [PATCH 09/34] docs: refine README usage and ecosystem note --- README.md | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 1fa0a0d..d742979 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,10 @@

@rc-component/motion

+

Part of the Ant Design ecosystem.

Ant Design

🎞️ Lifecycle-driven motion primitives for React enter, leave, and list animations.

-

- - - Ant Design - - Part of the Ant Design ecosystem. - -

@@ -64,7 +57,7 @@ export default ({ visible }: { visible: boolean }) => ( ```tsx | pure import { CSSMotionList } from '@rc-component/motion'; -export default ({ keys }: { keys: React.Key[] }) => ( +export default ({ keys }: { keys: string[] }) => ( {({ key, className, style }, ref) => (
From 0c9f411389e67d6cfc33590862b50fcf005b6b14 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 13:22:16 +0800 Subject: [PATCH 10/34] ci: isolate surge preview token --- .github/workflows/surge-preview.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index 70768bf..faf6b8b 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -17,23 +17,26 @@ jobs: preview: runs-on: ubuntu-latest env: - SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} PREVIEW: true steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 with: persist-credentials: false + - name: Build preview + if: ${{ secrets.SURGE_TOKEN != '' }} + run: | + npm install + npm run build - uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec - if: ${{ env.SURGE_TOKEN != '' }} + if: ${{ secrets.SURGE_TOKEN != '' }} + env: + SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} with: surge_token: ${{ env.SURGE_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }} dist: docs-dist failOnError: false setCommitStatus: false - build: | - npm install - npm run build - name: Skip Surge preview - if: ${{ env.SURGE_TOKEN == '' }} + if: ${{ secrets.SURGE_TOKEN == '' }} run: echo "SURGE_TOKEN is not configured; skip Surge preview." From f345e3faff5d248cdb5034e18a3f8d2f0accb392 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 13:50:54 +0800 Subject: [PATCH 11/34] chore: address review comments --- README.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/README.md b/README.md index d742979..87bf56f 100644 --- a/README.md +++ b/README.md @@ -12,16 +12,6 @@
-
- - Part of the Ant Design ecosystem - Ant Design - -
## Highlights From 275becbb41ac5c22e5467135d10036d6114cbb4b Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 22:00:53 +0800 Subject: [PATCH 12/34] docs: update Ant Design logo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 87bf56f..c750279 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

@rc-component/motion

Part of the Ant Design ecosystem.

- Ant Design + Ant Design

🎞️ Lifecycle-driven motion primitives for React enter, leave, and list animations.

From e9ccf0247f70a06095e8abbf575629133a8053d8 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 22:19:42 +0800 Subject: [PATCH 13/34] docs: add Chinese README --- README.md | 2 + README.zh-CN.md | 159 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 161 insertions(+) create mode 100644 README.zh-CN.md diff --git a/README.md b/README.md index c750279..f5febf0 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@

🎞️ Lifecycle-driven motion primitives for React enter, leave, and list animations.

+

English | 简体中文

+
diff --git a/README.zh-CN.md b/README.zh-CN.md new file mode 100644 index 0000000..8b00a98 --- /dev/null +++ b/README.zh-CN.md @@ -0,0 +1,159 @@ +
+

@rc-component/motion

+

Ant Design 生态的一部分。

+ Ant Design +

🎞️ React 动效基础组件,封装 CSS 动画、过渡和生命周期状态。

+
+ +

English | 简体中文

+ + +
+ +[![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] + +
+ + +## 特性 + +- Declarative `CSSMotion` component for appear, enter, and leave states. +- `CSSMotionList` for keyed list transitions. +- CSS class lifecycle hooks and inline style patching callbacks. +- Optional deadline fallback when transition or animation events do not fire. +- TypeScript definitions and React ref support. +- 被 Ant Design 使用 components that need predictable motion lifecycles. + +## 安装 + +```bash +npm install @rc-component/motion +``` + +## 使用 + +```tsx | pure +import CSSMotion from '@rc-component/motion'; + +export default ({ visible }: { visible: boolean }) => ( + + {({ className, style }, ref) => ( +
+ Content +
+ )} +
+); +``` + +```tsx | pure +import { CSSMotionList } from '@rc-component/motion'; + +export default ({ keys }: { keys: string[] }) => ( + + {({ key, className, style }, ref) => ( +
+ {key} +
+ )} +
+); +``` + +## 示例 + +本地运行示例: + +```bash +npm install +npm start +``` + +然后在浏览器中打开 dumi 开发服务地址。 + +## API + +### CSSMotion + +| 参数 | 类型 | 默认值 | 说明 | +| --- | --- | --- | --- | +| children | `(props, ref) => ReactElement` | - | Render function that receives motion class, style, and ref. | +| forceRender | `boolean` | `false` | Keep the element rendered even when invisible. | +| leavedClassName | `string` | - | Class name applied after leave when the element remains. | +| motionAppear | `boolean` | `true` | Enable appear motion. | +| motionDeadline | `number` | - | Fallback timeout in milliseconds for motion completion. | +| motionEnter | `boolean` | `true` | Enable enter motion. | +| motionLeave | `boolean` | `true` | Enable leave motion. | +| motionLeaveImmediately | `boolean` | - | Trigger leave immediately after mount. | +| motionName | `string \| MotionName` | - | CSS class name prefix or per-phase class names. | +| removeOnLeave | `boolean` | `true` | Remove the element after leave. Ignored when `forceRender` is set. | +| visible | `boolean` | `true` | Controls whether the element is visible. | +| onAppearActive | `MotionEventHandler` | - | Triggered during appear active phase. | +| onAppearEnd | `MotionEndEventHandler` | - | Triggered when appear finishes. Return `false` to keep waiting. | +| onAppearPrepare | `MotionPrepareEventHandler` | - | Prepare callback before appear starts. | +| onAppearStart | `MotionEventHandler` | - | Triggered when appear starts. | +| onEnterActive | `MotionEventHandler` | - | Triggered during enter active phase. | +| onEnterEnd | `MotionEndEventHandler` | - | Triggered when enter finishes. Return `false` to keep waiting. | +| onEnterPrepare | `MotionPrepareEventHandler` | - | Prepare callback before enter starts. | +| onEnterStart | `MotionEventHandler` | - | Triggered when enter starts. | +| onLeaveActive | `MotionEventHandler` | - | Triggered during leave active phase. | +| onLeaveEnd | `MotionEndEventHandler` | - | Triggered when leave finishes. Return `false` to keep waiting. | +| onLeavePrepare | `MotionPrepareEventHandler` | - | Prepare callback before leave starts. | +| onLeaveStart | `MotionEventHandler` | - | Triggered when leave starts. | +| onVisibleChanged | `(visible: boolean) => void` | - | Triggered after the final visible state changes. | + +### CSSMotionList + +`CSSMotionList` accepts the motion props above, except `children` is a list render function. + +| 参数 | 类型 | 默认值 | 说明 | +| --- | --- | --- | --- | +| children | `(props, ref) => ReactElement` | - | Render function for each keyed item. | +| component | `string \| ComponentType \| false` | `div` | Wrapper component. Use `false` for no wrapper. | +| keys | `(React.Key \| { key: React.Key })[]` | - | Keys to animate. | +| onAllRemoved | `() => void` | - | Triggered after every leaving item is removed. | +| onVisibleChanged | `(visible, info: { key: React.Key }) => void` | - | Triggered after an item visibility changes. | + +### Ref + +| Ref method | 类型 | 说明 | +| --- | --- | --- | +| `enableMotion` | `() => boolean` | Whether motion is currently enabled. | +| `inMotion` | `() => boolean` | Whether the element is in a motion lifecycle. | +| `nativeElement` | `HTMLElement` | Current DOM element. | + +## 本地开发 + +```bash +npm install +npm start +npm test +npm run tsc +npm run compile +npm run build +``` + +## 发布 + +```bash +npm run prepublishOnly +``` + +The release flow is handled by `@rc-component/np` through the `rc-np` command after the package build. + +## 许可证 + +@rc-component/motion is released under the [MIT](./LICENSE.md) license. + +[npm-image]: https://img.shields.io/npm/v/@rc-component/motion.svg?style=flat-square +[npm-url]: https://npmjs.org/package/@rc-component/motion +[github-actions-image]: https://github.com/react-component/motion/actions/workflows/react-component-ci.yml/badge.svg +[github-actions-url]: https://github.com/react-component/motion/actions/workflows/react-component-ci.yml +[codecov-image]: https://img.shields.io/codecov/c/github/react-component/motion/master.svg?style=flat-square +[codecov-url]: https://app.codecov.io/gh/react-component/motion +[download-image]: https://img.shields.io/npm/dm/@rc-component/motion.svg?style=flat-square +[download-url]: https://npmjs.org/package/@rc-component/motion +[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/motion +[bundlephobia-image]: https://img.shields.io/bundlephobia/minzip/@rc-component/motion?style=flat-square +[dumi-url]: https://github.com/umijs/dumi +[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square From 49a5d96732587e0d5356a55e1800465fd36f4b08 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 23:03:18 +0800 Subject: [PATCH 14/34] docs: refine bilingual README branding --- README.md | 3 +- README.zh-CN.md | 81 ++++++++++++++++++++++++------------------------- 2 files changed, 41 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index f5febf0..146a2a3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@

@rc-component/motion

-

Part of the Ant Design ecosystem.

- Ant Design +

Ant Design Part of the Ant Design ecosystem.

🎞️ Lifecycle-driven motion primitives for React enter, leave, and list animations.

diff --git a/README.zh-CN.md b/README.zh-CN.md index 8b00a98..9f23bcc 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -1,7 +1,6 @@

@rc-component/motion

-

Ant Design 生态的一部分。

- Ant Design +

Ant Design Ant Design 生态的一部分。

🎞️ React 动效基础组件,封装 CSS 动画、过渡和生命周期状态。

@@ -17,12 +16,12 @@ ## 特性 -- Declarative `CSSMotion` component for appear, enter, and leave states. -- `CSSMotionList` for keyed list transitions. -- CSS class lifecycle hooks and inline style patching callbacks. -- Optional deadline fallback when transition or animation events do not fire. -- TypeScript definitions and React ref support. -- 被 Ant Design 使用 components that need predictable motion lifecycles. +- 用于出现、进入和离开状态的声明性 `CSSMotion` 组件。 +- `CSSMotionList` 用于键控列表转换。 +- CSS 类生命周期挂钩和内联样式修补回调。 +- 当过渡或动画事件未触发时,可以使用 `deadline` 兜底。 +- TypeScript 定义和 React ref 支持。 +- 被 Ant Design 使用需要可预测运动生命周期的组件。 ## 安装 @@ -77,50 +76,50 @@ npm start | 参数 | 类型 | 默认值 | 说明 | | --- | --- | --- | --- | -| children | `(props, ref) => ReactElement` | - | Render function that receives motion class, style, and ref. | -| forceRender | `boolean` | `false` | Keep the element rendered even when invisible. | -| leavedClassName | `string` | - | Class name applied after leave when the element remains. | -| motionAppear | `boolean` | `true` | Enable appear motion. | -| motionDeadline | `number` | - | Fallback timeout in milliseconds for motion completion. | -| motionEnter | `boolean` | `true` | Enable enter motion. | -| motionLeave | `boolean` | `true` | Enable leave motion. | -| motionLeaveImmediately | `boolean` | - | Trigger leave immediately after mount. | -| motionName | `string \| MotionName` | - | CSS class name prefix or per-phase class names. | -| removeOnLeave | `boolean` | `true` | Remove the element after leave. Ignored when `forceRender` is set. | -| visible | `boolean` | `true` | Controls whether the element is visible. | -| onAppearActive | `MotionEventHandler` | - | Triggered during appear active phase. | -| onAppearEnd | `MotionEndEventHandler` | - | Triggered when appear finishes. Return `false` to keep waiting. | -| onAppearPrepare | `MotionPrepareEventHandler` | - | Prepare callback before appear starts. | -| onAppearStart | `MotionEventHandler` | - | Triggered when appear starts. | -| onEnterActive | `MotionEventHandler` | - | Triggered during enter active phase. | -| onEnterEnd | `MotionEndEventHandler` | - | Triggered when enter finishes. Return `false` to keep waiting. | -| onEnterPrepare | `MotionPrepareEventHandler` | - | Prepare callback before enter starts. | -| onEnterStart | `MotionEventHandler` | - | Triggered when enter starts. | -| onLeaveActive | `MotionEventHandler` | - | Triggered during leave active phase. | -| onLeaveEnd | `MotionEndEventHandler` | - | Triggered when leave finishes. Return `false` to keep waiting. | -| onLeavePrepare | `MotionPrepareEventHandler` | - | Prepare callback before leave starts. | -| onLeaveStart | `MotionEventHandler` | - | Triggered when leave starts. | -| onVisibleChanged | `(visible: boolean) => void` | - | Triggered after the final visible state changes. | +| children们 | `(props, ref) => ReactElement` | - | 接收运动类、样式和引用的渲染函数。 | +| forceRender | `boolean` | `false` | 即使元素不可见也保持渲染。 | +| leavedClassName | `string` | - | 当元素保留时,在离开后应用className称。 | +| motionAppear | `boolean` | `true` | 启用出现运动。 | +| motionDeadline | `number` | - | 运动完成的回退超时(以毫秒为单位)。 | +| motionEnter | `boolean` | `true` | 启用进入运动。 | +| motionLeave | `boolean` | `true` | 启用离开动作。 | +| motionLeaveImmediately | `boolean` | - | 安装后立即触发离开。 | +| motionName | `string \| MotionName` | - | CSS className前缀或每阶段className。 | +| removeOnLeave | `boolean` | `true` | 离开后删除该元素。设置 `forceRender` 时忽略。 | +| 可见的 | `boolean` | `true` | 控制元素是否可见。 | +| onAppearActive | `MotionEventHandler` | - | 在出现活跃阶段期间触发。 | +| onAppearEnd | `MotionEndEventHandler` | - | 出现完成时触发。返回`false`继续等待。 | +| onAppearPrepare | `MotionPrepareEventHandler` | - | 在出现开始之前准备回调。 | +| onAppearStart | `MotionEventHandler` | - | 出现开始时触发。 | +| onEnterActive | `MotionEventHandler` | - | 在进入活动阶段期间触发。 | +| onEnterEnd | `MotionEndEventHandler` | - | 输入完成时触发。返回`false`继续等待。 | +| onEnterPrepare | `MotionPrepareEventHandler` | - | 在输入开始之前准备回调。 | +| onEnterStart | `MotionEventHandler` | - | 输入开始时触发。 | +| onLeaveActive | `MotionEventHandler` | - | 在离开活动阶段触发。 | +| onLeaveEnd | `MotionEndEventHandler` | - | 休假结束时触发。返回`false`继续等待。 | +| onLeavePrepare | `MotionPrepareEventHandler` | - | 在休假开始前准备回调。 | +| onLeaveStart | `MotionEventHandler` | - | 休假开始时触发。 | +| onVisibleChanged | `(visible: boolean) => void` | - | 最终可见状态改变后触发。 | ### CSSMotionList -`CSSMotionList` accepts the motion props above, except `children` is a list render function. +`CSSMotionList` 接受上述动画属性,但 `children` 是列表渲染函数。 | 参数 | 类型 | 默认值 | 说明 | | --- | --- | --- | --- | -| children | `(props, ref) => ReactElement` | - | Render function for each keyed item. | +| children们 | `(props, ref) => ReactElement` | - | 每个关键项目的渲染函数。 | | component | `string \| ComponentType \| false` | `div` | Wrapper component. Use `false` for no wrapper. | | keys | `(React.Key \| { key: React.Key })[]` | - | Keys to animate. | -| onAllRemoved | `() => void` | - | Triggered after every leaving item is removed. | -| onVisibleChanged | `(visible, info: { key: React.Key }) => void` | - | Triggered after an item visibility changes. | +| onAllRemoved | `() => void` | - | 在移除每个留下的项目后触发。 | +| onVisibleChanged | `(visible, info: { key: React.Key }) => void` | - | 项目可见性更改后触发。 | ### Ref | Ref method | 类型 | 说明 | | --- | --- | --- | -| `enableMotion` | `() => boolean` | Whether motion is currently enabled. | -| `inMotion` | `() => boolean` | Whether the element is in a motion lifecycle. | -| `nativeElement` | `HTMLElement` | Current DOM element. | +| `enableMotion` | `() => boolean` | 当前是否启用运动。 | +| `inMotion` | `() => boolean` | 元素是否处于运动生命周期中。 | +| `nativeElement` | `HTMLElement` | 当前 DOM 元素。 | ## 本地开发 @@ -139,11 +138,11 @@ npm run build npm run prepublishOnly ``` -The release flow is handled by `@rc-component/np` through the `rc-np` command after the package build. +包构建完成后,发布流程由 `@rc-component/np` 通过 `rc-np` 命令处理。 ## 许可证 -@rc-component/motion is released under the [MIT](./LICENSE.md) license. +@rc-component/motion 基于 [MIT](./LICENSE.md) 许可证发布。 [npm-image]: https://img.shields.io/npm/v/@rc-component/motion.svg?style=flat-square [npm-url]: https://npmjs.org/package/@rc-component/motion From da9762f6b5f8929f5ccef15cf033439cfd33d0d2 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 01:28:40 +0800 Subject: [PATCH 15/34] chore: standardize rc tooling and docs --- .dumirc.ts | 2 +- README.md | 4 ++-- README.zh-CN.md | 4 ++-- package.json | 38 +++++++++++++++++++------------------- tsconfig.json | 34 +++++++++++++++++++++++++++------- 5 files changed, 51 insertions(+), 31 deletions(-) diff --git a/.dumirc.ts b/.dumirc.ts index e9f7604..0fdcb39 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -3,7 +3,7 @@ import { defineConfig } from 'dumi'; import path from 'path'; const basePath = process.env.GH_PAGES ? '/motion/' : '/'; -const publicPath = process.env.GH_PAGES ? '/motion/' : '/'; +const publicPath = basePath; export default defineConfig({ alias: { diff --git a/README.md b/README.md index 146a2a3..1815d5e 100644 --- a/README.md +++ b/README.md @@ -61,14 +61,14 @@ export default ({ keys }: { keys: string[] }) => ( ## Examples -Run the examples locally: +Run the local dumi site: ```bash npm install npm start ``` -Then open the dumi dev server in your browser. +Then open `http://localhost:8000`. ## API diff --git a/README.zh-CN.md b/README.zh-CN.md index 9f23bcc..768be2a 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -61,14 +61,14 @@ export default ({ keys }: { keys: string[] }) => ( ## 示例 -本地运行示例: +运行本地 dumi 站点: ```bash npm install npm start ``` -然后在浏览器中打开 dumi 开发服务地址。 +然后打开 `http://localhost:8000`。 ## API diff --git a/package.json b/package.json index 5d62e27..78aa166 100644 --- a/package.json +++ b/package.json @@ -56,26 +56,26 @@ }, "devDependencies": { "@rc-component/father-plugin": "^2.2.0", - "@rc-component/np": "^1.0.3", - "@testing-library/jest-dom": "^5.16.4", + "@rc-component/np": "^1.0.4", + "@testing-library/jest-dom": "^6.9.1", "@testing-library/react": "^15.0.7", - "@types/jest": "^26.0.8", - "@types/node": "^24.5.2", - "@types/react": "^18.0.0", - "@types/react-dom": "^18.0.0", - "@umijs/fabric": "^4.0.0", - "cross-env": "^7.0.0", - "dumi": "^2.0.18", - "eslint": "^8.0.0", - "father": "^4.1.2", - "gh-pages": "^6.0.0", - "husky": "^8.0.3", - "lint-staged": "^14.0.1", - "prettier": "^2.1.1", - "rc-test": "^7.0.14", - "react": "^18.3.0", - "react-dom": "^18.3.0", - "typescript": "^4.0.3" + "@types/jest": "^29.5.14", + "@types/node": "^26.0.1", + "@types/react": "^18.3.31", + "@types/react-dom": "^18.3.7", + "@umijs/fabric": "^4.0.1", + "cross-env": "^10.1.0", + "dumi": "^2.4.35", + "eslint": "^8.57.1", + "father": "^4.6.23", + "gh-pages": "^6.3.0", + "husky": "^9.1.7", + "lint-staged": "^16.4.0", + "prettier": "^3.9.0", + "rc-test": "^7.1.3", + "react": "^18.3.1", + "react-dom": "^18.3.1", + "typescript": "^5.9.3" }, "peerDependencies": { "react": ">=16.9.0", diff --git a/tsconfig.json b/tsconfig.json index 344468c..fbc3458 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,12 +8,32 @@ "skipLibCheck": true, "esModuleInterop": true, "paths": { - "@/*": ["src/*"], - "@@/*": [".dumi/tmp/*"], - "@rc-component/motion": ["src/index.tsx"], - "rc-motion": ["src/index.tsx"] - } + "@/*": [ + "src/*" + ], + "@@/*": [ + ".dumi/tmp/*" + ], + "@rc-component/motion": [ + "src/index.tsx" + ], + "rc-motion": [ + "src/index.tsx" + ] + }, + "ignoreDeprecations": "5.0" }, - "include": ["src", "docs", ".dumirc.ts", ".fatherrc.ts"], - "exclude": ["node_modules", "lib", "es", "dist", "docs-dist"] + "include": [ + "src", + "docs", + ".dumirc.ts", + ".fatherrc.ts" + ], + "exclude": [ + "node_modules", + "lib", + "es", + "dist", + "docs-dist" + ] } From e8c64f77dae47393281c8bd534c5201191543349 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 02:01:06 +0800 Subject: [PATCH 16/34] chore: address standardization review comments --- .github/workflows/surge-preview.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index faf6b8b..cb6c8c4 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -22,13 +22,23 @@ jobs: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 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: Build preview - if: ${{ secrets.SURGE_TOKEN != '' }} + if: ${{ steps.surge-token.outputs.enabled == 'true' }} run: | npm install npm run build - uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec - if: ${{ secrets.SURGE_TOKEN != '' }} + if: ${{ steps.surge-token.outputs.enabled == 'true' }} env: SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} with: @@ -38,5 +48,5 @@ jobs: failOnError: false setCommitStatus: false - name: Skip Surge preview - if: ${{ secrets.SURGE_TOKEN == '' }} + if: ${{ steps.surge-token.outputs.enabled != 'true' }} run: echo "SURGE_TOKEN is not configured; skip Surge preview." From 1e067578179f6e440bdbef9eafbe31c703f059de Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 12:24:02 +0800 Subject: [PATCH 17/34] ci: update GitHub Actions versions --- .github/workflows/codeql.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 27f7a7d..42a9a3f 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -29,15 +29,15 @@ jobs: persist-credentials: false - name: Initialize CodeQL - uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + uses: github/codeql-action/init@a0853c24544627f65ddf259abe73b1d18a591444 with: languages: ${{ matrix.language }} queries: +security-and-quality - name: Autobuild - uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + uses: github/codeql-action/autobuild@a0853c24544627f65ddf259abe73b1d18a591444 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + uses: github/codeql-action/analyze@a0853c24544627f65ddf259abe73b1d18a591444 with: category: '/language:${{ matrix.language }}' From b16af05cdc213fb704dbf5c3736ade1d4e001d10 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 12:29:26 +0800 Subject: [PATCH 18/34] ci: use resolvable CodeQL action ref --- .github/workflows/codeql.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 42a9a3f..27f7a7d 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -29,15 +29,15 @@ jobs: persist-credentials: false - name: Initialize CodeQL - uses: github/codeql-action/init@a0853c24544627f65ddf259abe73b1d18a591444 + uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e with: languages: ${{ matrix.language }} queries: +security-and-quality - name: Autobuild - uses: github/codeql-action/autobuild@a0853c24544627f65ddf259abe73b1d18a591444 + uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@a0853c24544627f65ddf259abe73b1d18a591444 + uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e with: category: '/language:${{ matrix.language }}' From 981ffa2f120042ee599b3b6db12166c51f179c3b Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 13:27:29 +0800 Subject: [PATCH 19/34] docs: add license file --- LICENSE | 21 +++++++++++++++++++++ README.md | 2 +- README.zh-CN.md | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..bd0a1f7 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019-present react-component + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 1815d5e..a5f2778 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,7 @@ The release flow is handled by `@rc-component/np` through the `rc-np` command af ## License -@rc-component/motion is released under the [MIT](./LICENSE.md) license. +@rc-component/motion is released under the [MIT](./LICENSE) license. [npm-image]: https://img.shields.io/npm/v/@rc-component/motion.svg?style=flat-square [npm-url]: https://npmjs.org/package/@rc-component/motion diff --git a/README.zh-CN.md b/README.zh-CN.md index 768be2a..6ce478b 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -142,7 +142,7 @@ npm run prepublishOnly ## 许可证 -@rc-component/motion 基于 [MIT](./LICENSE.md) 许可证发布。 +@rc-component/motion 基于 [MIT](./LICENSE) 许可证发布。 [npm-image]: https://img.shields.io/npm/v/@rc-component/motion.svg?style=flat-square [npm-url]: https://npmjs.org/package/@rc-component/motion From a4af4b80d5109ba1c861fa1b62c5d17afe592a3b Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 14:00:32 +0800 Subject: [PATCH 20/34] ci: use actions checkout v7 --- .github/workflows/codeql.yml | 2 +- .github/workflows/react-doctor.yml | 2 +- .github/workflows/surge-preview.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 27f7a7d..22583e1 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -24,7 +24,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + uses: actions/checkout@v7 with: persist-credentials: false diff --git a/.github/workflows/react-doctor.yml b/.github/workflows/react-doctor.yml index f68281c..097eb88 100644 --- a/.github/workflows/react-doctor.yml +++ b/.github/workflows/react-doctor.yml @@ -20,7 +20,7 @@ jobs: react-doctor: runs-on: ubuntu-latest steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + - uses: actions/checkout@v7 with: fetch-depth: 0 persist-credentials: false diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index cb6c8c4..ebfecd5 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -19,7 +19,7 @@ jobs: env: PREVIEW: true steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + - uses: actions/checkout@v7 with: persist-credentials: false - name: Check Surge token From e92b2ee30a4b5061bad5cf27fbc4d1bb4402147d Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 14:31:08 +0800 Subject: [PATCH 21/34] chore: standardize package metadata --- package.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 78aa166..fe564c2 100644 --- a/package.json +++ b/package.json @@ -12,11 +12,11 @@ ], "homepage": "https://react-component.github.io/motion", "bugs": { - "url": "http://github.com/react-component/motion/issues" + "url": "https://github.com/react-component/motion/issues" }, "repository": { "type": "git", - "url": "git@github.com:react-component/motion.git" + "url": "https://github.com/react-component/motion.git" }, "license": "MIT", "main": "./lib/index", @@ -86,5 +86,8 @@ }, "tnpm": { "mode": "npm" + }, + "publishConfig": { + "access": "public" } } From 730a87bb1fd92b450f6708c25dbbe306cc8270fd Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 14:37:28 +0800 Subject: [PATCH 22/34] ci: standardize dependabot updates --- .github/dependabot.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..3b730ef --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,19 @@ +version: 2 +updates: + - 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 From 0302f8f092db80fc7d898a42e3500269e7c1950f Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 16:27:07 +0800 Subject: [PATCH 23/34] docs: fix Chinese README API names --- README.zh-CN.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/README.zh-CN.md b/README.zh-CN.md index 6ce478b..fcfdad7 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -6,14 +6,12 @@

English | 简体中文

-
[![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]
- ## 特性 - 用于出现、进入和离开状态的声明性 `CSSMotion` 组件。 @@ -76,7 +74,7 @@ npm start | 参数 | 类型 | 默认值 | 说明 | | --- | --- | --- | --- | -| children们 | `(props, ref) => ReactElement` | - | 接收运动类、样式和引用的渲染函数。 | +| children | `(props, ref) => ReactElement` | - | 接收运动类、样式和引用的渲染函数。 | | forceRender | `boolean` | `false` | 即使元素不可见也保持渲染。 | | leavedClassName | `string` | - | 当元素保留时,在离开后应用className称。 | | motionAppear | `boolean` | `true` | 启用出现运动。 | @@ -86,7 +84,7 @@ npm start | motionLeaveImmediately | `boolean` | - | 安装后立即触发离开。 | | motionName | `string \| MotionName` | - | CSS className前缀或每阶段className。 | | removeOnLeave | `boolean` | `true` | 离开后删除该元素。设置 `forceRender` 时忽略。 | -| 可见的 | `boolean` | `true` | 控制元素是否可见。 | +| visible | `boolean` | `true` | 控制元素是否可见。 | | onAppearActive | `MotionEventHandler` | - | 在出现活跃阶段期间触发。 | | onAppearEnd | `MotionEndEventHandler` | - | 出现完成时触发。返回`false`继续等待。 | | onAppearPrepare | `MotionPrepareEventHandler` | - | 在出现开始之前准备回调。 | @@ -107,7 +105,7 @@ npm start | 参数 | 类型 | 默认值 | 说明 | | --- | --- | --- | --- | -| children们 | `(props, ref) => ReactElement` | - | 每个关键项目的渲染函数。 | +| children | `(props, ref) => ReactElement` | - | 每个关键项目的渲染函数。 | | component | `string \| ComponentType \| false` | `div` | Wrapper component. Use `false` for no wrapper. | | keys | `(React.Key \| { key: React.Key })[]` | - | Keys to animate. | | onAllRemoved | `() => void` | - | 在移除每个留下的项目后触发。 | @@ -115,11 +113,11 @@ npm start ### Ref -| Ref method | 类型 | 说明 | -| --- | --- | --- | -| `enableMotion` | `() => boolean` | 当前是否启用运动。 | -| `inMotion` | `() => boolean` | 元素是否处于运动生命周期中。 | -| `nativeElement` | `HTMLElement` | 当前 DOM 元素。 | +| Ref method | 类型 | 说明 | +| --------------- | --------------- | ---------------------------- | +| `enableMotion` | `() => boolean` | 当前是否启用运动。 | +| `inMotion` | `() => boolean` | 元素是否处于运动生命周期中。 | +| `nativeElement` | `HTMLElement` | 当前 DOM 元素。 | ## 本地开发 From fd26cf3846f3441ffa58f8b9b17d23c1f1e23e47 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 16:52:09 +0800 Subject: [PATCH 24/34] docs: localize Chinese README descriptions --- README.zh-CN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.zh-CN.md b/README.zh-CN.md index fcfdad7..b107009 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -106,7 +106,7 @@ npm start | 参数 | 类型 | 默认值 | 说明 | | --- | --- | --- | --- | | children | `(props, ref) => ReactElement` | - | 每个关键项目的渲染函数。 | -| component | `string \| ComponentType \| false` | `div` | Wrapper component. Use `false` for no wrapper. | +| component | `string \| ComponentType \| false` | `div` | 包装组件。设为 `false` 时不渲染包装节点。 | | keys | `(React.Key \| { key: React.Key })[]` | - | Keys to animate. | | onAllRemoved | `() => void` | - | 在移除每个留下的项目后触发。 | | onVisibleChanged | `(visible, info: { key: React.Key }) => void` | - | 项目可见性更改后触发。 | From b7de87ac51387f67a04e8227ae04634accaa7622 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 17:15:12 +0800 Subject: [PATCH 25/34] chore: refine preview workflow ignores --- .github/workflows/surge-preview.yml | 3 +++ .prettierignore | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 .prettierignore diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index ebfecd5..eaff160 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -16,6 +16,9 @@ permissions: jobs: preview: runs-on: ubuntu-latest + concurrency: + group: surge-preview-${{ github.event.pull_request.number }} + cancel-in-progress: true env: PREVIEW: true steps: diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..c466d87 --- /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 From 8470b643f9261f149121820bf28ee61aaabf732b Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 17:36:18 +0800 Subject: [PATCH 26/34] docs: polish Chinese README wording --- README.zh-CN.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.zh-CN.md b/README.zh-CN.md index b107009..fc9c575 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -76,13 +76,13 @@ npm start | --- | --- | --- | --- | | children | `(props, ref) => ReactElement` | - | 接收运动类、样式和引用的渲染函数。 | | forceRender | `boolean` | `false` | 即使元素不可见也保持渲染。 | -| leavedClassName | `string` | - | 当元素保留时,在离开后应用className称。 | +| leavedClassName | `string` | - | 当元素保留时,在离开后应用 className。 | | motionAppear | `boolean` | `true` | 启用出现运动。 | | motionDeadline | `number` | - | 运动完成的回退超时(以毫秒为单位)。 | | motionEnter | `boolean` | `true` | 启用进入运动。 | | motionLeave | `boolean` | `true` | 启用离开动作。 | | motionLeaveImmediately | `boolean` | - | 安装后立即触发离开。 | -| motionName | `string \| MotionName` | - | CSS className前缀或每阶段className。 | +| motionName | `string \| MotionName` | - | CSS className 前缀或每阶段 className。 | | removeOnLeave | `boolean` | `true` | 离开后删除该元素。设置 `forceRender` 时忽略。 | | visible | `boolean` | `true` | 控制元素是否可见。 | | onAppearActive | `MotionEventHandler` | - | 在出现活跃阶段期间触发。 | From fa588ad1d8c7fe8486a9966d7c0ed4b7e82edfe3 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 19:38:36 +0800 Subject: [PATCH 27/34] docs: document dumi dev server port --- README.md | 4 ++-- README.zh-CN.md | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a5f2778..f700842 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,12 @@

English | 简体中文

-
[![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]
- ## Highlights - Declarative `CSSMotion` component for appear, enter, and leave states. @@ -132,6 +130,8 @@ npm run compile npm run build ``` +The dumi site runs at `http://localhost:8000` by default. + ## Release ```bash diff --git a/README.zh-CN.md b/README.zh-CN.md index fc9c575..453c80b 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -130,6 +130,8 @@ npm run compile npm run build ``` +dumi 站点默认运行在 `http://localhost:8000`。 + ## 发布 ```bash From a50c7cef110f904f45e9d8ebf6143b9adadd4500 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 19:57:55 +0800 Subject: [PATCH 28/34] chore: standardize husky configuration --- .husky/pre-commit | 3 --- package.json | 6 ++---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index d24fdfc..2312dc5 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - npx lint-staged diff --git a/package.json b/package.json index fe564c2..f01034f 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "gh-pages": "cross-env GH_PAGES=1 npm run docs:build && npm run docs:deploy", "lint": "eslint src/ --ext .tsx,.ts", "lint:tsc": "tsc --noEmit", - "prepare": "husky install", + "prepare": "husky", "prepublishOnly": "npm run compile && rc-np", "prettier": "prettier --write --ignore-unknown .", "postpublish": "npm run gh-pages", @@ -43,9 +43,7 @@ "tsc": "tsc --noEmit" }, "lint-staged": { - "**/*.{js,jsx,tsx,ts,md,json}": [ - "prettier --write --ignore-unknown" - ] + "*": "prettier --write --ignore-unknown" }, "resolutions": { "@types/minimatch": "5.1.2" From db88a32ee8e29e59d26f709907cde0393dfabd46 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 20:06:21 +0800 Subject: [PATCH 29/34] docs: align readme badge layout --- README.md | 28 +++++++++------------------- README.zh-CN.md | 28 +++++++++------------------- 2 files changed, 18 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index f700842..f3de7d7 100644 --- a/README.md +++ b/README.md @@ -2,16 +2,19 @@

@rc-component/motion

Ant Design Part of the Ant Design ecosystem.

🎞️ Lifecycle-driven motion primitives for React enter, leave, and list animations.

+ +

+ NPM version + npm downloads + build status + Codecov + bundle size + dumi +

English | 简体中文

-
- -[![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] - -
- ## Highlights - Declarative `CSSMotion` component for appear, enter, and leave states. @@ -143,16 +146,3 @@ The release flow is handled by `@rc-component/np` through the `rc-np` command af ## License @rc-component/motion is released under the [MIT](./LICENSE) license. - -[npm-image]: https://img.shields.io/npm/v/@rc-component/motion.svg?style=flat-square -[npm-url]: https://npmjs.org/package/@rc-component/motion -[github-actions-image]: https://github.com/react-component/motion/actions/workflows/react-component-ci.yml/badge.svg -[github-actions-url]: https://github.com/react-component/motion/actions/workflows/react-component-ci.yml -[codecov-image]: https://img.shields.io/codecov/c/github/react-component/motion/master.svg?style=flat-square -[codecov-url]: https://app.codecov.io/gh/react-component/motion -[download-image]: https://img.shields.io/npm/dm/@rc-component/motion.svg?style=flat-square -[download-url]: https://npmjs.org/package/@rc-component/motion -[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/motion -[bundlephobia-image]: https://img.shields.io/bundlephobia/minzip/@rc-component/motion?style=flat-square -[dumi-url]: https://github.com/umijs/dumi -[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square diff --git a/README.zh-CN.md b/README.zh-CN.md index 453c80b..ee7045a 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -2,16 +2,19 @@

@rc-component/motion

Ant Design Ant Design 生态的一部分。

🎞️ React 动效基础组件,封装 CSS 动画、过渡和生命周期状态。

+ +

+ NPM version + npm downloads + build status + Codecov + bundle size + dumi +

English | 简体中文

-
- -[![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] - -
- ## 特性 - 用于出现、进入和离开状态的声明性 `CSSMotion` 组件。 @@ -143,16 +146,3 @@ npm run prepublishOnly ## 许可证 @rc-component/motion 基于 [MIT](./LICENSE) 许可证发布。 - -[npm-image]: https://img.shields.io/npm/v/@rc-component/motion.svg?style=flat-square -[npm-url]: https://npmjs.org/package/@rc-component/motion -[github-actions-image]: https://github.com/react-component/motion/actions/workflows/react-component-ci.yml/badge.svg -[github-actions-url]: https://github.com/react-component/motion/actions/workflows/react-component-ci.yml -[codecov-image]: https://img.shields.io/codecov/c/github/react-component/motion/master.svg?style=flat-square -[codecov-url]: https://app.codecov.io/gh/react-component/motion -[download-image]: https://img.shields.io/npm/dm/@rc-component/motion.svg?style=flat-square -[download-url]: https://npmjs.org/package/@rc-component/motion -[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/motion -[bundlephobia-image]: https://img.shields.io/bundlephobia/minzip/@rc-component/motion?style=flat-square -[dumi-url]: https://github.com/umijs/dumi -[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square From 6e91a9f47bc1fd672023d507e2435fdabcc153c5 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 20:32:30 +0800 Subject: [PATCH 30/34] chore: standardize package type entry --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f01034f..a43afdd 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,6 @@ "license": "MIT", "main": "./lib/index", "module": "./es/index", - "typings": "es/index.d.ts", "files": [ "es", "lib" @@ -87,5 +86,6 @@ }, "publishConfig": { "access": "public" - } + }, + "types": "./es/index.d.ts" } From 8925a1d9b46851363d8204b75773bd22d976af54 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 21:20:17 +0800 Subject: [PATCH 31/34] ci: limit reusable workflow secrets --- .github/workflows/react-component-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml index 9503b96..36dacae 100644 --- a/.github/workflows/react-component-ci.yml +++ b/.github/workflows/react-component-ci.yml @@ -5,4 +5,5 @@ permissions: jobs: test: uses: react-component/rc-test/.github/workflows/test-utoo.yml@main - secrets: inherit + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} From 4465c753e9fc75a38a6cdefacf3da0a813a1498c Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 21:33:07 +0800 Subject: [PATCH 32/34] ci: restore reusable workflow compatibility --- .github/workflows/react-component-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml index 36dacae..9503b96 100644 --- a/.github/workflows/react-component-ci.yml +++ b/.github/workflows/react-component-ci.yml @@ -5,5 +5,4 @@ permissions: jobs: test: uses: react-component/rc-test/.github/workflows/test-utoo.yml@main - secrets: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + secrets: inherit From e1e4655fc02fa1f374c9cbf1bd69db9db19591b3 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 29 Jun 2026 00:47:23 +0800 Subject: [PATCH 33/34] ci: narrow surge preview permissions --- .github/workflows/surge-preview.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index eaff160..4c2f17e 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -11,7 +11,6 @@ permissions: contents: read pull-requests: write checks: write - statuses: write jobs: preview: From 237a85c4163a83773304a033c64c0959d053bb57 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 29 Jun 2026 14:25:40 +0800 Subject: [PATCH 34/34] chore: limit reusable workflow secrets --- .github/workflows/react-component-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml index 9503b96..36dacae 100644 --- a/.github/workflows/react-component-ci.yml +++ b/.github/workflows/react-component-ci.yml @@ -5,4 +5,5 @@ permissions: jobs: test: uses: react-component/rc-test/.github/workflows/test-utoo.yml@main - secrets: inherit + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}