diff --git a/.dumirc.ts b/.dumirc.ts
index 36947e0..0fdcb39 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 = basePath;
+
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/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
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
new file mode 100644
index 0000000..22583e1
--- /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@v7
+ 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..36dacae
--- /dev/null
+++ b/.github/workflows/react-component-ci.yml
@@ -0,0 +1,9 @@
+name: ✅ test
+on: [push, pull_request]
+permissions:
+ contents: read
+jobs:
+ test:
+ uses: react-component/rc-test/.github/workflows/test-utoo.yml@main
+ secrets:
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
diff --git a/.github/workflows/react-doctor.yml b/.github/workflows/react-doctor.yml
new file mode 100644
index 0000000..097eb88
--- /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@v7
+ 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..4c2f17e
--- /dev/null
+++ b/.github/workflows/surge-preview.yml
@@ -0,0 +1,54 @@
+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
+
+jobs:
+ preview:
+ runs-on: ubuntu-latest
+ concurrency:
+ group: surge-preview-${{ github.event.pull_request.number }}
+ cancel-in-progress: true
+ env:
+ PREVIEW: true
+ 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: Build preview
+ if: ${{ steps.surge-token.outputs.enabled == 'true' }}
+ run: |
+ npm install
+ npm run build
+ - uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec
+ if: ${{ steps.surge-token.outputs.enabled == 'true' }}
+ env:
+ SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
+ with:
+ surge_token: ${{ env.SURGE_TOKEN }}
+ github_token: ${{ secrets.GITHUB_TOKEN }}
+ dist: docs-dist
+ failOnError: false
+ setCommitStatus: false
+ - name: Skip Surge preview
+ if: ${{ steps.surge-token.outputs.enabled != 'true' }}
+ 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/.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/.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
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 3ab5c4f..f3de7d7 100644
--- a/README.md
+++ b/README.md
@@ -1,95 +1,148 @@
-# @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
-
-React lifecycle controlled motion library.
-
-## Live Demo
-
-https://react-component.github.io/motion/
+
+
@rc-component/motion
+
Part of the Ant Design ecosystem.
+
🎞️ Lifecycle-driven motion primitives for React enter, leave, and list animations.
+
+
+
+
+
+
+
+
+
+
+
+English | 简体中文
+
+## Highlights
+
+- 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
-[](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: string[] }) => (
+
+ {({ key, className, style }, ref) => (
+
+ {key}
+
+ )}
+
+);
+```
+
+## Examples
+
+Run the local dumi site:
+
+```bash
+npm install
+npm start
+```
+
+Then open `http://localhost:8000`.
+
## 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 |
-| --------- | ----------------------------- | ------- | ----------------- |
-| keys | React.Key[] | - | Motion list keys |
-| component | string \| React.ComponentType | div | wrapper component |
+| 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
+
+| 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
```
+The dumi site runs at `http://localhost:8000` by default.
+
+## Release
+
+```bash
+npm run prepublishOnly
+```
+
+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) license.
diff --git a/README.zh-CN.md b/README.zh-CN.md
new file mode 100644
index 0000000..ee7045a
--- /dev/null
+++ b/README.zh-CN.md
@@ -0,0 +1,148 @@
+
+
@rc-component/motion
+
Ant Design 生态的一部分。
+
🎞️ React 动效基础组件,封装 CSS 动画、过渡和生命周期状态。
+
+
+
+
+
+
+
+
+
+
+
+English | 简体中文
+
+## 特性
+
+- 用于出现、进入和离开状态的声明性 `CSSMotion` 组件。
+- `CSSMotionList` 用于键控列表转换。
+- CSS 类生命周期挂钩和内联样式修补回调。
+- 当过渡或动画事件未触发时,可以使用 `deadline` 兜底。
+- TypeScript 定义和 React ref 支持。
+- 被 Ant Design 使用需要可预测运动生命周期的组件。
+
+## 安装
+
+```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}
+
+ )}
+
+);
+```
+
+## 示例
+
+运行本地 dumi 站点:
+
+```bash
+npm install
+npm start
+```
+
+然后打开 `http://localhost:8000`。
+
+## API
+
+### CSSMotion
+
+| 参数 | 类型 | 默认值 | 说明 |
+| --- | --- | --- | --- |
+| 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` 时忽略。 |
+| visible | `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` 接受上述动画属性,但 `children` 是列表渲染函数。
+
+| 参数 | 类型 | 默认值 | 说明 |
+| --- | --- | --- | --- |
+| children | `(props, ref) => ReactElement` | - | 每个关键项目的渲染函数。 |
+| component | `string \| ComponentType \| false` | `div` | 包装组件。设为 `false` 时不渲染包装节点。 |
+| keys | `(React.Key \| { key: React.Key })[]` | - | Keys to animate. |
+| onAllRemoved | `() => void` | - | 在移除每个留下的项目后触发。 |
+| onVisibleChanged | `(visible, info: { key: React.Key }) => void` | - | 项目可见性更改后触发。 |
+
+### Ref
+
+| Ref method | 类型 | 说明 |
+| --------------- | --------------- | ---------------------------- |
+| `enableMotion` | `() => boolean` | 当前是否启用运动。 |
+| `inMotion` | `() => boolean` | 元素是否处于运动生命周期中。 |
+| `nativeElement` | `HTMLElement` | 当前 DOM 元素。 |
+
+## 本地开发
+
+```bash
+npm install
+npm start
+npm test
+npm run tsc
+npm run compile
+npm run build
+```
+
+dumi 站点默认运行在 `http://localhost:8000`。
+
+## 发布
+
+```bash
+npm run prepublishOnly
+```
+
+包构建完成后,发布流程由 `@rc-component/np` 通过 `rc-np` 命令处理。
+
+## 许可证
+
+@rc-component/motion 基于 [MIT](./LICENSE) 许可证发布。
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..a43afdd 100644
--- a/package.json
+++ b/package.json
@@ -12,39 +12,37 @@
],
"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",
"module": "./es/index",
- "typings": "es/index.d.ts",
"files": [
"es",
"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": "cross-env 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",
+ "prepare": "husky",
"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": {
"@types/minimatch": "5.1.2"
@@ -55,25 +53,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",
- "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",
@@ -84,5 +83,9 @@
},
"tnpm": {
"mode": "npm"
- }
+ },
+ "publishConfig": {
+ "access": "public"
+ },
+ "types": "./es/index.d.ts"
}
diff --git a/tsconfig.json b/tsconfig.json
index 6ff0503..fbc3458 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -8,9 +8,32 @@
"skipLibCheck": true,
"esModuleInterop": true,
"paths": {
- "@/*": ["src/*"],
- "@@/*": ["src/.umi/*"],
- "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"
+ ]
}
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"
+}