From e5e3fb69bd5dd22cdef964a41340a2e7bacdb4d4 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 13:05:42 +0800 Subject: [PATCH 01/37] chore: standardize repository setup --- .github/FUNDING.yml | 17 +- .../workflows/cloudflare-pages-preview.yml | 38 +++ .github/workflows/react-component-ci.yml | 4 +- .github/workflows/react-doctor.yml | 27 ++ .github/workflows/surge-preview.yml | 35 +++ README.md | 287 +++++++----------- now.json | 12 - package.json | 5 +- vercel.json | 6 + 9 files changed, 226 insertions(+), 205 deletions(-) create mode 100644 .github/workflows/cloudflare-pages-preview.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/.github/FUNDING.yml b/.github/FUNDING.yml index 33b1999c..758659af 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 00000000..c1738dfe --- /dev/null +++ b/.github/workflows/cloudflare-pages-preview.yml @@ -0,0 +1,38 @@ +name: Cloudflare Pages Preview + +on: + pull_request: + +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 dist --project-name=${{ env.CLOUDFLARE_PAGES_PROJECT }} --branch=${{ github.head_ref }} + gitHubToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml index 5735e2d2..f8482b63 100644 --- a/.github/workflows/react-component-ci.yml +++ b/.github/workflows/react-component-ci.yml @@ -2,5 +2,5 @@ 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 + 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 00000000..f68281c8 --- /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 00000000..1b7fc7e2 --- /dev/null +++ b/.github/workflows/surge-preview.yml @@ -0,0 +1,35 @@ +name: Surge Preview + +on: + pull_request: + +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: 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/README.md b/README.md index 1874d079..9fde5eeb 100644 --- a/README.md +++ b/README.md @@ -1,224 +1,163 @@ -# rc-image +
+

@rc-component/image

+

🖼️ Image display, fallback, and preview tooling for React.

-React Image. + + Ant Design + - -[![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] +

Part of the Ant Design ecosystem.

-[npm-image]: http://img.shields.io/npm/v/rc-image.svg?style=flat-square -[npm-url]: http://npmjs.org/package/rc-image +[![NPM version][npm-image]][npm-url] [![npm download][download-image]][download-url] [![build status][github-actions-image]][github-actions-url] [![Codecov][codecov-image]][codecov-url] [![bundle size][bundlephobia-image]][bundlephobia-url] [![dumi][dumi-image]][dumi-url] + +
+ +[npm-image]: https://img.shields.io/npm/v/@rc-component/image.svg?style=flat-square +[npm-url]: https://npmjs.org/package/@rc-component/image [github-actions-image]: https://github.com/react-component/image/actions/workflows/react-component-ci.yml/badge.svg [github-actions-url]: https://github.com/react-component/image/actions/workflows/react-component-ci.yml -[codecov-image]: https://img.shields.io/codecov/c/gh/react-component/image?style=flat-square -[codecov-url]: https://codecov.io/gh/react-component/image -[download-image]: https://img.shields.io/npm/dm/rc-image.svg?style=flat-square -[download-url]: https://npmjs.org/package/rc-image -[bundlephobia-url]: https://bundlephobia.com/result?p=rc-image -[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-image -[dumi-url]: https://github.com/umijs/dumi +[codecov-image]: https://img.shields.io/codecov/c/github/react-component/image/master.svg?style=flat-square +[codecov-url]: https://app.codecov.io/gh/react-component/image +[download-image]: https://img.shields.io/npm/dm/@rc-component/image.svg?style=flat-square +[download-url]: https://npmjs.org/package/@rc-component/image +[bundlephobia-image]: https://img.shields.io/bundlephobia/minzip/%40rc-component%2Fimage?style=flat-square +[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/image [dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square +[dumi-url]: https://github.com/umijs/dumi -## Feature +## Highlights -- [x] Placeholder -- [x] Preview -- [x] Rotate -- [x] Zoom -- [x] Flip -- [x] Fallback -- [x] Multiple Preview +- Supports placeholder, fallback, and preview. +- Preview supports zoom, rotate, flip, drag, keyboard access, and custom actions. +- `Image.PreviewGroup` supports grouped preview and custom preview items. +- Ships compiled JavaScript, TypeScript definitions, and CSS assets. -## install +## Install -[![rc-image](https://nodei.co/npm/rc-image.png)](https://npmjs.org/package/rc-image) +```bash +npm install @rc-component/image +``` ## Usage -```bash -npm install -npm start +```tsx | pure +import Image from '@rc-component/image'; +import '@rc-component/image/assets/index.css'; + +export default function App() { + return ( + + ); +} ``` -```js +## Preview Group + +```tsx | pure import Image from '@rc-component/image'; +import '@rc-component/image/assets/index.css'; + +export default function App() { + return ( + + + + + ); +} +``` + +## Examples -export default () => ( - -); +```bash +npm install +npm start ``` -## API +Then open `http://localhost:8000`. -| Name | Type | Default | Description | -| --- | --- | --- | --- | -| preview | boolean \| [PreviewType](#PreviewType) | true | Whether to show preview | -| prefixCls | string | rc-image | Classname prefix | -| placeholder | boolean \| ReactElement | - | if `true` will set default placeholder or use `ReactElement` set customize placeholder | -| fallback | string | - | Load failed src | -| previewPrefixCls | string | rc-image-preview | Preview classname prefix | -| onError | (event: Event) => void | - | Load failed callback | +## API -### PreviewType +### Image -| Name | Type | Default | Description | +| Property | Description | Type | Default | | --- | --- | --- | --- | -| open | boolean | - | Whether the preview is open or not | -| closeIcon | React.ReactNode | - | Custom close icon | -| maskClosable | boolean | true | Whether to close preview on clicking mask | -| src | string | - | Customize preview src | -| movable | boolean | true | Enable drag | -| scaleStep | number | 0.5 | The number to which the scale is increased or decreased | -| minScale | number | 1 | Min scale | -| maxScale | number | 50 | Max scale | -| forceRender | boolean | - | Force render preview | -| getContainer | string \| HTMLElement \| (() => HTMLElement) \| false | document.body | Return the mount node for preview | -| imageRender | (originalNode: React.ReactElement, info: { transform: [TransformType](#TransformType) }) => React.ReactNode | - | Customize image | -| actionsRender | (originalNode: React.ReactElement, info: Omit<[ToolbarRenderInfoType](#ToolbarRenderInfoType), 'current' \| 'total'>) => React.ReactNode | - | Customize toolbar | -| onOpenChange | (open: boolean, prevVisible: boolean) => void | - | Callback when open is changed | -| onTransform | { transform: [TransformType](#TransformType), action: [TransformAction](#TransformAction) } | - | Callback when transform is changed | - -## Image.PreviewGroup - -preview the merged src - -```js -import Image from '@rc-component/image'; +| fallback | Image source used when loading fails | string | - | +| placeholder | Placeholder before image loads | boolean \| `React.ReactElement` | - | +| prefixCls | Component class name prefix | string | `rc-image` | +| preview | Whether and how to show preview | boolean \| `PreviewConfig` | true | +| previewPrefixCls | Preview class name prefix | string | `rc-image-preview` | +| src | Image source | string | - | +| onError | Callback when image loading fails | `(event: Event) => void` | - | -export default () => ( - - - - -); -``` +Native image attributes are also supported. -### API +### PreviewConfig -| Name | Type | Default | Description | +| Property | Description | Type | Default | | --- | --- | --- | --- | -| preview | boolean \| [PreviewGroupType](#PreviewGroupType) | true | Whether to show preview,
current: If Preview the show img index, default 0 | -| previewPrefixCls | string | rc-image-preview | Preview classname prefix | -| icons | { [iconKey]?: ReactNode } | - | Icons in the top operation bar, iconKey: 'rotateLeft' \| 'rotateRight' \| 'zoomIn' \| 'zoomOut' \| 'close' \| 'left' \| 'right' | -| fallback | string | - | Load failed src | -| items | (string \| { src: string, alt: string, crossOrigin: string, ... })[] | - | preview group | - -### PreviewGroupType - -| Name | Type | Default | Description | +| actionsRender | Custom toolbar renderer | `(node: React.ReactElement, info: ToolbarRenderInfoType) => React.ReactNode` | - | +| closeIcon | Custom close icon | `React.ReactNode` | - | +| countRender | Custom count renderer | `(current: number, total: number) => React.ReactNode` | - | +| forceRender | Force render preview | boolean | false | +| getContainer | Preview container | string \| HTMLElement \| `() => HTMLElement` \| false | `document.body` | +| imageRender | Custom image renderer | `(node: React.ReactElement, info: { transform: TransformType; image: ImgInfo }) => React.ReactNode` | - | +| maskClosable | Whether clicking mask closes preview | boolean | true | +| maxScale | Max scale | number | 50 | +| minScale | Min scale | number | 1 | +| movable | Enable drag | boolean | true | +| open | Controlled preview open state | boolean | - | +| scaleStep | Scale step | number | 0.5 | +| src | Custom preview image source | string | - | +| onOpenChange | Callback when preview open state changes | `(open: boolean, prevOpen: boolean) => void` | - | +| onTransform | Callback when transform changes | `(info: { transform: TransformType; action: TransformAction }) => void` | - | + +### Image.PreviewGroup + +| Property | Description | Type | Default | | --- | --- | --- | --- | -| open | boolean | - | Whether the preview is open or not | -| movable | boolean | true | Enable drag | -| current | number | - | Current index | -| closeIcon | React.ReactNode | - | Custom close icon | -| maskClosable | boolean | true | Whether to close preview on clicking mask | -| scaleStep | number | 0.5 | The number to which the scale is increased or decreased | -| minScale | number | 1 | Min scale | -| maxScale | number | 50 | Max scale | -| forceRender | boolean | - | Force render preview | -| getContainer | string \| HTMLElement \| (() => HTMLElement) \| false | document.body | Return the mount node for preview | -| countRender | (current: number, total: number) => ReactNode | - | Customize count | -| imageRender | (originalNode: React.ReactElement, info: { transform: [TransformType](#TransformType), current: number }) => React.ReactNode | - | Customize image | -| actionsRender | (originalNode: React.ReactElement, info: [ToolbarRenderInfoType](#ToolbarRenderInfoType)) => React.ReactNode | - | Customize toolbar | -| onOpenChange | (open: boolean, prevVisible: boolean, current: number) => void | - | Callback when open is changed | -| onTransform | { transform: [TransformType](#TransformType), action: [TransformAction](#TransformAction) } | - | Callback when transform is changed | +| fallback | Image source used when loading fails | string | - | +| icons | Custom preview operation icons | `OperationIcons` | - | +| items | Preview items | `(string \| ImageElementProps)[]` | - | +| preview | Whether and how to show preview group | boolean \| `GroupPreviewConfig` | true | +| previewPrefixCls | Preview class name prefix | string | `rc-image-preview` | ### TransformType -```typescript -{ +```ts +type TransformType = { x: number; y: number; rotate: number; scale: number; flipX: boolean; flipY: boolean; -} +}; ``` -### TransformAction - -```typescript -type TransformAction = - | 'flipY' - | 'flipX' - | 'rotateLeft' - | 'rotateRight' - | 'zoomIn' - | 'zoomOut' - | 'close' - | 'prev' - | 'next' - | 'wheel' - | 'doubleClick' - | 'move' - | 'dragRebound'; -``` +## Development -### ToolbarRenderInfoType - -```typescript -{ - icons: { - prevIcon?: React.ReactNode; - nextIcon?: React.ReactNode; - flipYIcon: React.ReactNode; - flipXIcon: React.ReactNode; - rotateLeftIcon: React.ReactNode; - rotateRightIcon: React.ReactNode; - zoomOutIcon: React.ReactNode; - zoomInIcon: React.ReactNode; - }; - actions: { - onActive?: (offset: number) => void; - onFlipY: () => void; - onFlipX: () => void; - onRotateLeft: () => void; - onRotateRight: () => void; - onZoomOut: () => void; - onZoomIn: () => void; - onClose: () => void; - onReset: () => void; - }; - transform: { - x: number; - y: number; - rotate: number; - scale: number; - flipX: boolean; - flipY: boolean; - }, - current: number; - total: number; -} +```bash +npm install +npm start ``` -## Example - -http://localhost:8003/examples/ - -## Test Case - -``` +```bash npm test +npm run tsc +npm run lint +npm run compile +npm run build ``` -## Coverage +## Release -``` -npm run coverage +```bash +npm run prepublishOnly ``` -## License +The release script compiles the package and runs `rc-np`. -rc-image is released under the MIT license. - -## 🤝 Contributing +## License - - Contribution Leaderboard - +`@rc-component/image` is released under the MIT license. diff --git a/now.json b/now.json deleted file mode 100644 index 4d507fa8..00000000 --- a/now.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "version": 2, - "name": "rc-image", - "builds": [ - { - "src": "package.json", - "use": "@now/static-build", - "config": { "distDir": "dist" } - } - ], - "routes": [{ "src": "/(.*)", "dest": "/dist/$1" }] -} diff --git a/package.json b/package.json index 07a0c689..ea2c4e4a 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "lib" ], "scripts": { + "build": "npm run docs:build", "compile": "father build && lessc assets/index.less assets/index.css", "coverage": "rc-test --coverage", "docs:build": "dumi build", @@ -33,11 +34,11 @@ "lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md", "now-build": "npm run docs:build", "prepublishOnly": "npm run compile && rc-np", - "prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"", + "prettier": "prettier --write --ignore-unknown .", "start": "dumi dev", "test": "rc-test", "test:update": "rc-test -u", - "tsc": "bunx tsc --noEmit" + "tsc": "tsc --noEmit" }, "dependencies": { "@rc-component/motion": "^1.0.0", diff --git a/vercel.json b/vercel.json new file mode 100644 index 00000000..e884e1b3 --- /dev/null +++ b/vercel.json @@ -0,0 +1,6 @@ +{ + "framework": "umijs", + "installCommand": "npm install", + "buildCommand": "npm run build", + "outputDirectory": "dist" +} From 1244874f463b4aae75f7a77e51f537e3f8eba2be Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 13:14:04 +0800 Subject: [PATCH 02/37] chore: address preview review feedback --- README.md | 15 +++++++++++++++ vercel.json | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9fde5eeb..88cee948 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,21 @@ type TransformType = { flipX: boolean; flipY: boolean; }; + +type TransformAction = + | 'flipY' + | 'flipX' + | 'rotateLeft' + | 'rotateRight' + | 'zoomIn' + | 'zoomOut' + | 'close' + | 'prev' + | 'next' + | 'wheel' + | 'doubleClick' + | 'move' + | 'dragRebound'; ``` ## Development diff --git a/vercel.json b/vercel.json index e884e1b3..0cc6ea14 100644 --- a/vercel.json +++ b/vercel.json @@ -1,6 +1,6 @@ { "framework": "umijs", "installCommand": "npm install", - "buildCommand": "npm run build", - "outputDirectory": "dist" + "buildCommand": "npm run build && rm -rf docs-dist && cp -R dist docs-dist", + "outputDirectory": "docs-dist" } From c72f0498fc98beb108ac047d8534c858f72c9058 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 13:19:06 +0800 Subject: [PATCH 03/37] chore: align image preview output --- .dumirc.ts | 1 + .github/workflows/cloudflare-pages-preview.yml | 2 +- .github/workflows/surge-preview.yml | 2 +- vercel.json | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.dumirc.ts b/.dumirc.ts index 67ace038..5c97f103 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -7,6 +7,7 @@ export default defineConfig({ '@rc-component/image/es': path.resolve('src'), }, favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'], + outputPath: 'docs-dist', themeConfig: { name: 'Image', logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', diff --git a/.github/workflows/cloudflare-pages-preview.yml b/.github/workflows/cloudflare-pages-preview.yml index c1738dfe..8bafe4dc 100644 --- a/.github/workflows/cloudflare-pages-preview.yml +++ b/.github/workflows/cloudflare-pages-preview.yml @@ -34,5 +34,5 @@ jobs: with: apiToken: ${{ env.CLOUDFLARE_API_TOKEN }} accountId: ${{ env.CLOUDFLARE_ACCOUNT_ID }} - command: pages deploy dist --project-name=${{ env.CLOUDFLARE_PAGES_PROJECT }} --branch=${{ github.head_ref }} + command: pages deploy docs-dist --project-name=${{ env.CLOUDFLARE_PAGES_PROJECT }} --branch=${{ github.head_ref }} gitHubToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index 1b7fc7e2..26f79b64 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -24,7 +24,7 @@ jobs: with: surge_token: ${{ env.SURGE_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }} - dist: dist + dist: docs-dist failOnError: true setCommitStatus: true build: | diff --git a/vercel.json b/vercel.json index 0cc6ea14..5f9139ef 100644 --- a/vercel.json +++ b/vercel.json @@ -1,6 +1,6 @@ { "framework": "umijs", "installCommand": "npm install", - "buildCommand": "npm run build && rm -rf docs-dist && cp -R dist docs-dist", + "buildCommand": "npm run build", "outputDirectory": "docs-dist" } From 0b108988ec5c824bc06588cad436905e558470b5 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 13:25:57 +0800 Subject: [PATCH 04/37] docs: address image review feedback --- .../workflows/cloudflare-pages-preview.yml | 4 ++ .github/workflows/surge-preview.yml | 4 ++ README.md | 40 +++++++++++++++++-- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cloudflare-pages-preview.yml b/.github/workflows/cloudflare-pages-preview.yml index 8bafe4dc..d925f518 100644 --- a/.github/workflows/cloudflare-pages-preview.yml +++ b/.github/workflows/cloudflare-pages-preview.yml @@ -3,6 +3,10 @@ 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 diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index 26f79b64..1b29a17b 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -3,6 +3,10 @@ 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 diff --git a/README.md b/README.md index 88cee948..486387c2 100644 --- a/README.md +++ b/README.md @@ -96,8 +96,9 @@ Native image attributes are also supported. | Property | Description | Type | Default | | --- | --- | --- | --- | -| actionsRender | Custom toolbar renderer | `(node: React.ReactElement, info: ToolbarRenderInfoType) => React.ReactNode` | - | +| actionsRender | Custom toolbar renderer | `(node: React.ReactElement, info: Omit) => React.ReactNode` | - | | closeIcon | Custom close icon | `React.ReactNode` | - | +| cover | Custom preview cover | `React.ReactNode \| CoverConfig` | - | | countRender | Custom count renderer | `(current: number, total: number) => React.ReactNode` | - | | forceRender | Force render preview | boolean | false | | getContainer | Preview container | string \| HTMLElement \| `() => HTMLElement` \| false | `document.body` | @@ -109,18 +110,21 @@ Native image attributes are also supported. | open | Controlled preview open state | boolean | - | | scaleStep | Scale step | number | 0.5 | | src | Custom preview image source | string | - | -| onOpenChange | Callback when preview open state changes | `(open: boolean, prevOpen: boolean) => void` | - | +| onOpenChange | Callback when preview open state changes | `(open: boolean) => void` | - | | onTransform | Callback when transform changes | `(info: { transform: TransformType; action: TransformAction }) => void` | - | ### Image.PreviewGroup | Property | Description | Type | Default | | --- | --- | --- | --- | +| children | Image children | `React.ReactNode` | - | +| classNames | Semantic preview popup class names | `{ popup?: Partial> }` | - | | fallback | Image source used when loading fails | string | - | -| icons | Custom preview operation icons | `OperationIcons` | - | +| icons | Custom preview operation icons | `PreviewProps['icons']` | - | | items | Preview items | `(string \| ImageElementProps)[]` | - | | preview | Whether and how to show preview group | boolean \| `GroupPreviewConfig` | true | | previewPrefixCls | Preview class name prefix | string | `rc-image-preview` | +| styles | Semantic preview popup styles | `{ popup?: Partial> }` | - | ### TransformType @@ -148,6 +152,36 @@ type TransformAction = | 'doubleClick' | 'move' | 'dragRebound'; + +type Actions = { + onActive: (offset: number) => void; + onFlipY: () => void; + onFlipX: () => void; + onRotateLeft: () => void; + onRotateRight: () => void; + onZoomOut: () => void; + onZoomIn: () => void; + onClose: () => void; + onReset: () => void; +}; + +type ToolbarRenderInfoType = { + icons: { + prevIcon?: React.ReactNode; + nextIcon?: React.ReactNode; + flipYIcon: React.ReactNode; + flipXIcon: React.ReactNode; + rotateLeftIcon: React.ReactNode; + rotateRightIcon: React.ReactNode; + zoomOutIcon: React.ReactNode; + zoomInIcon: React.ReactNode; + }; + actions: Actions; + transform: TransformType; + current: number; + total: number; + image: ImgInfo; +}; ``` ## Development From e64cdbc2ef1fa4f534416a21dac9e0cc8bf28df3 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 13:36:24 +0800 Subject: [PATCH 05/37] chore: include dumi config in tsconfig --- tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index cbdc6cdf..cbe35be6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,5 +13,6 @@ "@rc-component/image": ["src/index.ts"] }, "types": ["@testing-library/jest-dom", "jest", "node"] - } + }, + "include": [".dumirc.ts", "docs", "src", "tests", "typings.d.ts"] } From 31dbc5e43da97bd25119e76a3cf7bf8dd294791a Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 15:03:58 +0800 Subject: [PATCH 06/37] 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 d925f518..00000000 --- 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 ea2c4e4a..d6831cdd 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "docs:build": "dumi build", "docs:deploy": "gh-pages -d docs-dist", "lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md", - "now-build": "npm run docs:build", "prepublishOnly": "npm run compile && rc-np", "prettier": "prettier --write --ignore-unknown .", "start": "dumi dev", From 433155df13bad2159b3336f35301d8e51f1997a8 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 00:14:29 +0800 Subject: [PATCH 07/37] chore: rerun vercel preview From 115426a3802732ff60def2166d351b26096671ed Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 01:56:47 +0800 Subject: [PATCH 08/37] docs: standardize README release details --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 486387c2..fd78ed08 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,9 @@

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] @@ -205,8 +208,8 @@ npm run build npm run prepublishOnly ``` -The release script compiles the package and runs `rc-np`. +The release flow is handled by `@rc-component/np` through the `rc-np` command after the package build. ## License -`@rc-component/image` is released under the MIT license. +@rc-component/image is released under the [MIT](./LICENSE.md) license. From 0cc3390c8b8961a7735522c276caa740651c2f1f Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 02:13:56 +0800 Subject: [PATCH 09/37] 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 1b29a17b..ad8683da 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 226d9a4202390643c1d14e6a42c9324d9b58f88a Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 02:25:41 +0800 Subject: [PATCH 10/37] 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 ad8683da..70768bf2 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 296639e39cba3c6a38770bf6264402c57191cdb5 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 13:03:59 +0800 Subject: [PATCH 11/37] docs: refine README usage and ecosystem note --- README.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fd78ed08..41db2247 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,10 @@

@rc-component/image

+

Part of the Ant Design ecosystem.

🖼️ Image display, fallback, and preview tooling for React.

- - - 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 b1f72d5e633d132f01bc859a17e888a96c4bc022 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 13:22:14 +0800 Subject: [PATCH 12/37] 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 70768bf2..faf6b8bd 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 3c53717c8ea793728098827cb9b3d12bd7e83107 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 22:19:28 +0800 Subject: [PATCH 13/37] docs: add Chinese README --- README.md | 2 + README.zh-CN.md | 213 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 215 insertions(+) create mode 100644 README.zh-CN.md diff --git a/README.md b/README.md index 41db2247..752940c2 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@

🖼️ Image display, fallback, and preview tooling for React.

+

English | 简体中文

+
diff --git a/README.zh-CN.md b/README.zh-CN.md new file mode 100644 index 00000000..3a1f0ab6 --- /dev/null +++ b/README.zh-CN.md @@ -0,0 +1,213 @@ +
+

@rc-component/image

+

Ant Design 生态的一部分。

+

🖼️ React 图片预览组件,支持预览组、缩放、旋转和自定义工具栏。

+
+ +

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] + +
+ +[npm-image]: https://img.shields.io/npm/v/@rc-component/image.svg?style=flat-square +[npm-url]: https://npmjs.org/package/@rc-component/image +[github-actions-image]: https://github.com/react-component/image/actions/workflows/react-component-ci.yml/badge.svg +[github-actions-url]: https://github.com/react-component/image/actions/workflows/react-component-ci.yml +[codecov-image]: https://img.shields.io/codecov/c/github/react-component/image/master.svg?style=flat-square +[codecov-url]: https://app.codecov.io/gh/react-component/image +[download-image]: https://img.shields.io/npm/dm/@rc-component/image.svg?style=flat-square +[download-url]: https://npmjs.org/package/@rc-component/image +[bundlephobia-image]: https://img.shields.io/bundlephobia/minzip/%40rc-component%2Fimage?style=flat-square +[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/image +[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square +[dumi-url]: https://github.com/umijs/dumi + +## 特性 + +- 支持 placeholder, fallback, and preview. +- Preview supports zoom, rotate, flip, drag, keyboard access, and custom actions. +- `Image.PreviewGroup` supports grouped preview and custom preview items. +- 提供编译后的 JavaScript、TypeScript 类型定义和 CSS 资源。 + +## 安装 + +```bash +npm install @rc-component/image +``` + +## 使用 + +```tsx | pure +import Image from '@rc-component/image'; +import '@rc-component/image/assets/index.css'; + +export default function App() { + return ( + + ); +} +``` + +## Preview Group + +```tsx | pure +import Image from '@rc-component/image'; +import '@rc-component/image/assets/index.css'; + +export default function App() { + return ( + + + + + ); +} +``` + +## 示例 + +```bash +npm install +npm start +``` + +然后打开 `http://localhost:8000`。 + +## API + +### Image + +| 参数 | 说明 | 类型 | 默认值 | +| --- | --- | --- | --- | +| fallback | Image source used when loading fails | string | - | +| placeholder | Placeholder before image loads | boolean \| `React.ReactElement` | - | +| prefixCls | Component class name prefix | string | `rc-image` | +| preview | Whether and how to show preview | boolean \| `PreviewConfig` | true | +| previewPrefixCls | Preview class name prefix | string | `rc-image-preview` | +| src | Image source | string | - | +| onError | Callback when image loading fails | `(event: Event) => void` | - | + +Native image attributes are also supported. + +### PreviewConfig + +| 参数 | 说明 | 类型 | 默认值 | +| --- | --- | --- | --- | +| actionsRender | Custom toolbar renderer | `(node: React.ReactElement, info: Omit) => React.ReactNode` | - | +| closeIcon | Custom close icon | `React.ReactNode` | - | +| cover | Custom preview cover | `React.ReactNode \| CoverConfig` | - | +| countRender | Custom count renderer | `(current: number, total: number) => React.ReactNode` | - | +| forceRender | Force render preview | boolean | false | +| getContainer | Preview container | string \| HTMLElement \| `() => HTMLElement` \| false | `document.body` | +| imageRender | Custom image renderer | `(node: React.ReactElement, info: { transform: TransformType; image: ImgInfo }) => React.ReactNode` | - | +| maskClosable | Whether clicking mask closes preview | boolean | true | +| maxScale | Max scale | number | 50 | +| minScale | Min scale | number | 1 | +| movable | Enable drag | boolean | true | +| open | Controlled preview open state | boolean | - | +| scaleStep | Scale step | number | 0.5 | +| src | Custom preview image source | string | - | +| onOpenChange | Callback when preview open state changes | `(open: boolean) => void` | - | +| onTransform | Callback when transform changes | `(info: { transform: TransformType; action: TransformAction }) => void` | - | + +### Image.PreviewGroup + +| 参数 | 说明 | 类型 | 默认值 | +| --- | --- | --- | --- | +| children | Image children | `React.ReactNode` | - | +| classNames | Semantic preview popup class names | `{ popup?: Partial> }` | - | +| fallback | Image source used when loading fails | string | - | +| icons | Custom preview operation icons | `PreviewProps['icons']` | - | +| items | Preview items | `(string \| ImageElementProps)[]` | - | +| preview | Whether and how to show preview group | boolean \| `GroupPreviewConfig` | true | +| previewPrefixCls | Preview class name prefix | string | `rc-image-preview` | +| styles | Semantic preview popup styles | `{ popup?: Partial> }` | - | + +### TransformType + +```ts +type TransformType = { + x: number; + y: number; + rotate: number; + scale: number; + flipX: boolean; + flipY: boolean; +}; + +type TransformAction = + | 'flipY' + | 'flipX' + | 'rotateLeft' + | 'rotateRight' + | 'zoomIn' + | 'zoomOut' + | 'close' + | 'prev' + | 'next' + | 'wheel' + | 'doubleClick' + | 'move' + | 'dragRebound'; + +type Actions = { + onActive: (offset: number) => void; + onFlipY: () => void; + onFlipX: () => void; + onRotateLeft: () => void; + onRotateRight: () => void; + onZoomOut: () => void; + onZoomIn: () => void; + onClose: () => void; + onReset: () => void; +}; + +type ToolbarRenderInfoType = { + icons: { + prevIcon?: React.ReactNode; + nextIcon?: React.ReactNode; + flipYIcon: React.ReactNode; + flipXIcon: React.ReactNode; + rotateLeftIcon: React.ReactNode; + rotateRightIcon: React.ReactNode; + zoomOutIcon: React.ReactNode; + zoomInIcon: React.ReactNode; + }; + actions: Actions; + transform: TransformType; + current: number; + total: number; + image: ImgInfo; +}; +``` + +## 本地开发 + +```bash +npm install +npm start +``` + +```bash +npm test +npm run tsc +npm run lint +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/image is released under the [MIT](./LICENSE.md) license. From f3f549f8ae30541cdd5dce8c1512b14e6df9b773 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 22:34:38 +0800 Subject: [PATCH 14/37] docs: add Ant Design logo to README --- README.md | 1 + README.zh-CN.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 752940c2..82efa386 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@

@rc-component/image

Part of the Ant Design ecosystem.

+ Ant Design

🖼️ Image display, fallback, and preview tooling for React.

diff --git a/README.zh-CN.md b/README.zh-CN.md index 3a1f0ab6..9d27c720 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -1,6 +1,7 @@

@rc-component/image

Ant Design 生态的一部分。

+ Ant Design

🖼️ React 图片预览组件,支持预览组、缩放、旋转和自定义工具栏。

From 30471d1d3f8e88aed8d20a07368a0e13564f4165 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 23:03:03 +0800 Subject: [PATCH 15/37] docs: refine bilingual README branding --- README.md | 3 +-- README.zh-CN.md | 69 ++++++++++++++++++++++++------------------------- 2 files changed, 35 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 82efa386..7beb7e51 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@

@rc-component/image

-

Part of the Ant Design ecosystem.

- Ant Design +

Ant Design Part of the Ant Design ecosystem.

🖼️ Image display, fallback, and preview tooling for React.

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

@rc-component/image

-

Ant Design 生态的一部分。

- Ant Design +

Ant Design Ant Design 生态的一部分。

🖼️ React 图片预览组件,支持预览组、缩放、旋转和自定义工具栏。

@@ -29,9 +28,9 @@ ## 特性 -- 支持 placeholder, fallback, and preview. -- Preview supports zoom, rotate, flip, drag, keyboard access, and custom actions. -- `Image.PreviewGroup` supports grouped preview and custom preview items. +- 支持占位符、后备和预览。 +- 预览支持缩放、旋转、翻转、拖动、键盘访问和自定义操作。 +- `Image.PreviewGroup` 支持分组预览和自定义预览项。 - 提供编译后的 JavaScript、TypeScript 类型定义和 CSS 资源。 ## 安装 @@ -84,49 +83,49 @@ npm start | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | -| fallback | Image source used when loading fails | string | - | -| placeholder | Placeholder before image loads | boolean \| `React.ReactElement` | - | -| prefixCls | Component class name prefix | string | `rc-image` | -| preview | Whether and how to show preview | boolean \| `PreviewConfig` | true | -| previewPrefixCls | Preview class name prefix | string | `rc-image-preview` | +| fallback | 加载失败时使用的图片源 | string | - | +| placeholder | 图片加载前的占位内容 | boolean \| `React.ReactElement` | - | +| prefixCls | 组件className前缀 | string | `rc-image` | +| preview | 是否以及如何显示预览 | boolean \| `PreviewConfig` | true | +| previewPrefixCls | 预览className前缀 | string | `rc-image-preview` | | src | Image source | string | - | -| onError | Callback when image loading fails | `(event: Event) => void` | - | +| onError | 图片加载失败时的回调 | `(event: Event) => void` | - | -Native image attributes are also supported. +也支持原生图片属性。 ### PreviewConfig | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | -| actionsRender | Custom toolbar renderer | `(node: React.ReactElement, info: Omit) => React.ReactNode` | - | -| closeIcon | Custom close icon | `React.ReactNode` | - | -| cover | Custom preview cover | `React.ReactNode \| CoverConfig` | - | -| countRender | Custom count renderer | `(current: number, total: number) => React.ReactNode` | - | -| forceRender | Force render preview | boolean | false | -| getContainer | Preview container | string \| HTMLElement \| `() => HTMLElement` \| false | `document.body` | -| imageRender | Custom image renderer | `(node: React.ReactElement, info: { transform: TransformType; image: ImgInfo }) => React.ReactNode` | - | -| maskClosable | Whether clicking mask closes preview | boolean | true | +| actionsRender | 自定义工具栏渲染器 | `(node: React.ReactElement, info: Omit) => React.ReactNode` | - | +| closeIcon | 自定义关闭图标 | `React.ReactNode` | - | +| cover | 自定义预览封面 | `React.ReactNode \| CoverConfig` | - | +| countRender | 自定义计数渲染器 | `(current: number, total: number) => React.ReactNode` | - | +| forceRender | 强制渲染预览 | boolean | false | +| getContainer | 预览容器 | string \| HTMLElement \| `() => HTMLElement` \| false | `document.body` | +| imageRender | 自定义图像渲染器 | `(node: React.ReactElement, info: { transform: TransformType; image: ImgInfo }) => React.ReactNode` | - | +| maskClosable | 单击蒙版是否关闭预览 | boolean | true | | maxScale | Max scale | number | 50 | | minScale | Min scale | number | 1 | -| movable | Enable drag | boolean | true | -| open | Controlled preview open state | boolean | - | +| movable | 启用拖动 | boolean | true | +| 打开 | 受控预览打开状态 | boolean | - | | scaleStep | Scale step | number | 0.5 | -| src | Custom preview image source | string | - | -| onOpenChange | Callback when preview open state changes | `(open: boolean) => void` | - | -| onTransform | Callback when transform changes | `(info: { transform: TransformType; action: TransformAction }) => void` | - | +| src | 自定义预览图像源 | string | - | +| onOpenChange | 预览打开状态变化时回调 | `(open: boolean) => void` | - | +| onTransform | 变换变化时的回调 | `(info: { transform: TransformType; action: TransformAction }) => void` | - | ### Image.PreviewGroup | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | -| children | Image children | `React.ReactNode` | - | -| classNames | Semantic preview popup class names | `{ popup?: Partial> }` | - | -| fallback | Image source used when loading fails | string | - | -| icons | Custom preview operation icons | `PreviewProps['icons']` | - | -| items | Preview items | `(string \| ImageElementProps)[]` | - | -| preview | Whether and how to show preview group | boolean \| `GroupPreviewConfig` | true | -| previewPrefixCls | Preview class name prefix | string | `rc-image-preview` | -| styles | Semantic preview popup styles | `{ popup?: Partial> }` | - | +| children们 | 儿童形象 | `React.ReactNode` | - | +| classNames | 语义预览弹层className称 | `{ popup?: Partial> }` | - | +| fallback | 加载失败时使用的图片源 | string | - | +| icons | 自定义预览操作图标 | `PreviewProps['icons']` | - | +| 项目 | 预览项目 | `(string \| ImageElementProps)[]` | - | +| preview | 是否以及如何显示预览 group | boolean \| `GroupPreviewConfig` | true | +| previewPrefixCls | 预览className前缀 | string | `rc-image-preview` | +| styles | 语义预览弹层样式 | `{ popup?: Partial> }` | - | ### TransformType @@ -207,8 +206,8 @@ 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/image is released under the [MIT](./LICENSE.md) license. +@rc-component/image 基于 [MIT](./LICENSE.md) 许可证发布。 From a9da01ac3418d0f62ed0fb6219a01a3ab24b12c8 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 01:28:39 +0800 Subject: [PATCH 16/37] chore: standardize rc tooling and docs --- .dumirc.ts | 5 +++++ README.md | 2 ++ README.zh-CN.md | 2 ++ package.json | 32 ++++++++++++++++---------------- tsconfig.json | 27 ++++++++++++++++++++++----- 5 files changed, 47 insertions(+), 21 deletions(-) diff --git a/.dumirc.ts b/.dumirc.ts index 5c97f103..7cae344c 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -1,6 +1,9 @@ import { defineConfig } from 'dumi'; import path from 'path'; +const basePath = process.env.GH_PAGES ? '/image/' : '/'; +const publicPath = basePath; + export default defineConfig({ alias: { '@rc-component/image$': path.resolve('src'), @@ -8,6 +11,8 @@ export default defineConfig({ }, favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'], outputPath: 'docs-dist', + base: basePath, + publicPath, themeConfig: { name: 'Image', logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', diff --git a/README.md b/README.md index 7beb7e51..ebc83895 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,8 @@ export default function App() { ## Examples +Run the local dumi site: + ```bash npm install npm start diff --git a/README.zh-CN.md b/README.zh-CN.md index f4cdd5c6..0a0667de 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -70,6 +70,8 @@ export default function App() { ## 示例 +运行本地 dumi 站点: + ```bash npm install npm start diff --git a/package.json b/package.json index d6831cdd..63343a11 100644 --- a/package.json +++ b/package.json @@ -49,23 +49,23 @@ "@ant-design/icons": "^5.0.1", "@rc-component/dialog": "^1.7.0", "@rc-component/father-plugin": "^2.2.0", - "@rc-component/np": "^1.0.0", - "@testing-library/jest-dom": "^6.4.0", - "@testing-library/react": "^15.0.6", - "@types/jest": "^30.0.0", - "@types/node": "^24.5.2", - "@types/react": "^18.0.0", - "@types/react-dom": "^18.0.0", + "@rc-component/np": "^1.0.4", + "@testing-library/jest-dom": "^6.9.1", + "@testing-library/react": "^15.0.7", + "@types/jest": "^29.5.14", + "@types/node": "^26.0.1", + "@types/react": "^18.3.31", + "@types/react-dom": "^18.3.7", "@umijs/fabric": "^4.0.1", - "dumi": "^2.1.4", - "eslint": "^8.57.0", - "father": "^4.0.0", - "glob": "^11.0.3", - "less": "^4.1.3", - "rc-test": "^7.0.3", - "react": "^18.0.0", - "react-dom": "^18.0.0", - "typescript": "^5.3.3" + "dumi": "^2.4.35", + "eslint": "^8.57.1", + "father": "^4.6.23", + "glob": "^13.0.6", + "less": "^4.6.7", + "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 cbe35be6..ebc95c56 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,11 +8,28 @@ "skipLibCheck": true, "esModuleInterop": true, "paths": { - "@/*": ["src/*"], - "@@/*": [".dumi/tmp/*"], - "@rc-component/image": ["src/index.ts"] + "@/*": [ + "src/*" + ], + "@@/*": [ + ".dumi/tmp/*" + ], + "@rc-component/image": [ + "src/index.ts" + ] }, - "types": ["@testing-library/jest-dom", "jest", "node"] + "types": [ + "@testing-library/jest-dom", + "jest", + "node" + ], + "ignoreDeprecations": "5.0" }, - "include": [".dumirc.ts", "docs", "src", "tests", "typings.d.ts"] + "include": [ + ".dumirc.ts", + "docs", + "src", + "tests", + "typings.d.ts" + ] } From 607912f82094e4060f48816c056e7aa66ae1c4cd Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 02:01:05 +0800 Subject: [PATCH 17/37] chore: address standardization review comments --- .github/workflows/surge-preview.yml | 16 +++++++++++++--- package.json | 3 ++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index faf6b8bd..cb6c8c4a 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." diff --git a/package.json b/package.json index 63343a11..36b595fe 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "start": "dumi dev", "test": "rc-test", "test:update": "rc-test -u", - "tsc": "tsc --noEmit" + "tsc": "tsc --noEmit", + "docs:build:gh-pages": "GH_PAGES=1 npm run docs:build" }, "dependencies": { "@rc-component/motion": "^1.0.0", From f6bb4cf2b4335f7343ccc4e76fa874cf91d2d9bf Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 13:14:22 +0800 Subject: [PATCH 18/37] chore: ignore dumi build output --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fe8ecdaf..cfa2eab2 100644 --- a/.gitignore +++ b/.gitignore @@ -43,6 +43,7 @@ es/ # dumi .dumi/tmp .dumi/tmp-production +docs-dist bun.lockb -.vscode \ No newline at end of file +.vscode From 47c44bbfad7eeca19fbee10bdb72926a9a7206a5 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 13:27:09 +0800 Subject: [PATCH 19/37] 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 00000000..bd0a1f72 --- /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 ebc83895..bbe17335 100644 --- a/README.md +++ b/README.md @@ -212,4 +212,4 @@ The release flow is handled by `@rc-component/np` through the `rc-np` command af ## License -@rc-component/image is released under the [MIT](./LICENSE.md) license. +@rc-component/image is released under the [MIT](./LICENSE) license. diff --git a/README.zh-CN.md b/README.zh-CN.md index 0a0667de..b58c19e6 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -212,4 +212,4 @@ npm run prepublishOnly ## 许可证 -@rc-component/image 基于 [MIT](./LICENSE.md) 许可证发布。 +@rc-component/image 基于 [MIT](./LICENSE) 许可证发布。 From 49ac320f7855857685466e03d1780ad7c40621b9 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 14:00:04 +0800 Subject: [PATCH 20/37] ci: use actions checkout v7 --- .github/workflows/react-doctor.yml | 2 +- .github/workflows/surge-preview.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/react-doctor.yml b/.github/workflows/react-doctor.yml index f68281c8..097eb883 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 cb6c8c4a..ebfecd53 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 64cbe5d2bec8fd1011669a8ab2d3c694ac24cc18 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 14:30:41 +0800 Subject: [PATCH 21/37] chore: standardize package metadata --- package.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 36b595fe..bd90ed7a 100644 --- a/package.json +++ b/package.json @@ -8,13 +8,13 @@ "react-image", "image" ], - "homepage": "http://github.com/react-component/image", + "homepage": "https://react-component.github.io/image", "bugs": { - "url": "http://github.com/react-component/image/issues" + "url": "https://github.com/react-component/image/issues" }, "repository": { "type": "git", - "url": "git@github.com:react-component/image.git" + "url": "https://github.com/react-component/image.git" }, "license": "MIT", "main": "./lib/index", @@ -71,5 +71,8 @@ "peerDependencies": { "react": ">=16.9.0", "react-dom": ">=16.9.0" + }, + "publishConfig": { + "access": "public" } } From 2540b0dd5be33e86ee4796772035261a590fa93e Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 14:37:07 +0800 Subject: [PATCH 22/37] ci: standardize dependabot updates --- .github/dependabot.yml | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 01619035..3b730ef9 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,26 +1,19 @@ version: 2 updates: -- package-ecosystem: npm - directory: "/" - schedule: - interval: daily - time: "21:00" - open-pull-requests-limit: 10 - ignore: - - dependency-name: "@types/react-dom" - versions: - - 17.0.0 - - 17.0.1 - - 17.0.2 - - dependency-name: "@types/react" - versions: - - 17.0.0 - - 17.0.1 - - 17.0.2 - - 17.0.3 - - dependency-name: react - versions: - - 17.0.1 - - dependency-name: less - versions: - - 4.1.0 + - 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 ea3ac6ca93edf55a8d4b4f37b273bda82b218528 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 16:25:22 +0800 Subject: [PATCH 23/37] docs: fix Chinese README API names --- README.zh-CN.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.zh-CN.md b/README.zh-CN.md index b58c19e6..b732b304 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -107,11 +107,11 @@ npm start | getContainer | 预览容器 | string \| HTMLElement \| `() => HTMLElement` \| false | `document.body` | | imageRender | 自定义图像渲染器 | `(node: React.ReactElement, info: { transform: TransformType; image: ImgInfo }) => React.ReactNode` | - | | maskClosable | 单击蒙版是否关闭预览 | boolean | true | -| maxScale | Max scale | number | 50 | -| minScale | Min scale | number | 1 | +| maxScale | 最大缩放比例 | number | 50 | +| minScale | 最小缩放比例 | number | 1 | | movable | 启用拖动 | boolean | true | -| 打开 | 受控预览打开状态 | boolean | - | -| scaleStep | Scale step | number | 0.5 | +| open | 受控预览打开状态 | boolean | - | +| scaleStep | 缩放步长 | number | 0.5 | | src | 自定义预览图像源 | string | - | | onOpenChange | 预览打开状态变化时回调 | `(open: boolean) => void` | - | | onTransform | 变换变化时的回调 | `(info: { transform: TransformType; action: TransformAction }) => void` | - | @@ -120,11 +120,11 @@ npm start | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | -| children们 | 儿童形象 | `React.ReactNode` | - | +| children | 儿童形象 | `React.ReactNode` | - | | classNames | 语义预览弹层className称 | `{ popup?: Partial> }` | - | | fallback | 加载失败时使用的图片源 | string | - | | icons | 自定义预览操作图标 | `PreviewProps['icons']` | - | -| 项目 | 预览项目 | `(string \| ImageElementProps)[]` | - | +| items | 预览项目 | `(string \| ImageElementProps)[]` | - | | preview | 是否以及如何显示预览 group | boolean \| `GroupPreviewConfig` | true | | previewPrefixCls | 预览className前缀 | string | `rc-image-preview` | | styles | 语义预览弹层样式 | `{ popup?: Partial> }` | - | From 8e2f91ab5bcae7fb6f59764522a4dbb397b8928f Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 17:14:53 +0800 Subject: [PATCH 24/37] 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 ebfecd53..eaff160a 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 00000000..c466d872 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,14 @@ +node_modules +coverage +docs-dist +dist +es +lib +.dumi/tmp +.dumi/tmp-production +.vercel +package-lock.json +pnpm-lock.yaml +yarn.lock +bun.lockb +*.log From 0e65534d1875521cc388b3eb6af5d55296f650fa Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 17:35:47 +0800 Subject: [PATCH 25/37] docs: polish Chinese README wording --- README.zh-CN.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.zh-CN.md b/README.zh-CN.md index b732b304..00deb11a 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -87,9 +87,9 @@ npm start | --- | --- | --- | --- | | fallback | 加载失败时使用的图片源 | string | - | | placeholder | 图片加载前的占位内容 | boolean \| `React.ReactElement` | - | -| prefixCls | 组件className前缀 | string | `rc-image` | +| prefixCls | 组件 className 前缀 | string | `rc-image` | | preview | 是否以及如何显示预览 | boolean \| `PreviewConfig` | true | -| previewPrefixCls | 预览className前缀 | string | `rc-image-preview` | +| previewPrefixCls | 预览 className 前缀 | string | `rc-image-preview` | | src | Image source | string | - | | onError | 图片加载失败时的回调 | `(event: Event) => void` | - | @@ -121,12 +121,12 @@ npm start | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | children | 儿童形象 | `React.ReactNode` | - | -| classNames | 语义预览弹层className称 | `{ popup?: Partial> }` | - | +| classNames | 语义预览弹层 className | `{ popup?: Partial> }` | - | | fallback | 加载失败时使用的图片源 | string | - | | icons | 自定义预览操作图标 | `PreviewProps['icons']` | - | | items | 预览项目 | `(string \| ImageElementProps)[]` | - | | preview | 是否以及如何显示预览 group | boolean \| `GroupPreviewConfig` | true | -| previewPrefixCls | 预览className前缀 | string | `rc-image-preview` | +| previewPrefixCls | 预览 className 前缀 | string | `rc-image-preview` | | styles | 语义预览弹层样式 | `{ popup?: Partial> }` | - | ### TransformType From fa537894bb372c202ec12f28ea4a81cacd381c87 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 18:19:21 +0800 Subject: [PATCH 26/37] chore: add missing prettier dependency --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index bd90ed7a..b032285d 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "@ant-design/icons": "^5.0.1", "@rc-component/dialog": "^1.7.0", "@rc-component/father-plugin": "^2.2.0", + "prettier": "^3.9.0", "@rc-component/np": "^1.0.4", "@testing-library/jest-dom": "^6.9.1", "@testing-library/react": "^15.0.7", From e5c1d723e224dc88046abb8cecd2e1ab579dcc0b Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 18:26:55 +0800 Subject: [PATCH 27/37] docs: fix 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 00deb11a..e89d3340 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -90,7 +90,7 @@ npm start | prefixCls | 组件 className 前缀 | string | `rc-image` | | preview | 是否以及如何显示预览 | boolean \| `PreviewConfig` | true | | previewPrefixCls | 预览 className 前缀 | string | `rc-image-preview` | -| src | Image source | string | - | +| src | 图片地址 | string | - | | onError | 图片加载失败时的回调 | `(event: Event) => void` | - | 也支持原生图片属性。 @@ -120,7 +120,7 @@ npm start | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | -| children | 儿童形象 | `React.ReactNode` | - | +| children | 子元素 | `React.ReactNode` | - | | classNames | 语义预览弹层 className | `{ popup?: Partial> }` | - | | fallback | 加载失败时使用的图片源 | string | - | | icons | 自定义预览操作图标 | `PreviewProps['icons']` | - | From 82b6a3c018f5ac3353c4ba3bfd29858f435e0d4a Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 18:53:21 +0800 Subject: [PATCH 28/37] chore: add missing gh-pages dependency --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index b032285d..56b0e9c1 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,7 @@ "dumi": "^2.4.35", "eslint": "^8.57.1", "father": "^4.6.23", + "gh-pages": "^6.3.0", "glob": "^13.0.6", "less": "^4.6.7", "rc-test": "^7.1.3", From 47626b9fa931808ca640aa82561b8554146a8d07 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 19:13:19 +0800 Subject: [PATCH 29/37] chore: add father config --- .fatherrc.ts | 5 +++++ tsconfig.json | 1 + 2 files changed, 6 insertions(+) create mode 100644 .fatherrc.ts diff --git a/.fatherrc.ts b/.fatherrc.ts new file mode 100644 index 00000000..96268ae1 --- /dev/null +++ b/.fatherrc.ts @@ -0,0 +1,5 @@ +import { defineConfig } from 'father'; + +export default defineConfig({ + plugins: ['@rc-component/father-plugin'], +}); diff --git a/tsconfig.json b/tsconfig.json index ebc95c56..f17405ba 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -27,6 +27,7 @@ }, "include": [ ".dumirc.ts", + ".fatherrc.ts", "docs", "src", "tests", From c0c39232af23641189e122b2c6ca7517edef3ad4 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 19:38:16 +0800 Subject: [PATCH 30/37] docs: document dumi dev server port --- README.md | 2 ++ README.zh-CN.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index bbe17335..6bbfb120 100644 --- a/README.md +++ b/README.md @@ -194,6 +194,8 @@ npm install npm start ``` +The dumi site runs at `http://localhost:8000` by default. + ```bash npm test npm run tsc diff --git a/README.zh-CN.md b/README.zh-CN.md index e89d3340..90034e5d 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -194,6 +194,8 @@ npm install npm start ``` +dumi 站点默认运行在 `http://localhost:8000`。 + ```bash npm test npm run tsc From 887e9d963e45f28864decdd28d9bc2c3c6526022 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 19:57:31 +0800 Subject: [PATCH 31/37] chore: standardize husky configuration --- .husky/pre-commit | 1 + package.json | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100755 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 00000000..2312dc58 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +npx lint-staged diff --git a/package.json b/package.json index 56b0e9c1..61e2970f 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ "test": "rc-test", "test:update": "rc-test -u", "tsc": "tsc --noEmit", - "docs:build:gh-pages": "GH_PAGES=1 npm run docs:build" + "docs:build:gh-pages": "GH_PAGES=1 npm run docs:build", + "prepare": "husky" }, "dependencies": { "@rc-component/motion": "^1.0.0", @@ -68,7 +69,9 @@ "rc-test": "^7.1.3", "react": "^18.3.1", "react-dom": "^18.3.1", - "typescript": "^5.9.3" + "typescript": "^5.9.3", + "husky": "^9.1.7", + "lint-staged": "^16.4.0" }, "peerDependencies": { "react": ">=16.9.0", @@ -76,5 +79,8 @@ }, "publishConfig": { "access": "public" + }, + "lint-staged": { + "*": "prettier --write --ignore-unknown" } } From 7de4e1c3c8c34b060b9831eab25fc6803d08493f Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 20:06:02 +0800 Subject: [PATCH 32/37] docs: align readme badge layout --- README.md | 29 +++++++++-------------------- README.zh-CN.md | 29 +++++++++-------------------- 2 files changed, 18 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 6bbfb120..2a2cde2f 100644 --- a/README.md +++ b/README.md @@ -2,29 +2,18 @@

@rc-component/image

Ant Design Part of the Ant Design ecosystem.

🖼️ Image display, fallback, and preview tooling for React.

-
- -

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] +

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

-[npm-image]: https://img.shields.io/npm/v/@rc-component/image.svg?style=flat-square -[npm-url]: https://npmjs.org/package/@rc-component/image -[github-actions-image]: https://github.com/react-component/image/actions/workflows/react-component-ci.yml/badge.svg -[github-actions-url]: https://github.com/react-component/image/actions/workflows/react-component-ci.yml -[codecov-image]: https://img.shields.io/codecov/c/github/react-component/image/master.svg?style=flat-square -[codecov-url]: https://app.codecov.io/gh/react-component/image -[download-image]: https://img.shields.io/npm/dm/@rc-component/image.svg?style=flat-square -[download-url]: https://npmjs.org/package/@rc-component/image -[bundlephobia-image]: https://img.shields.io/bundlephobia/minzip/%40rc-component%2Fimage?style=flat-square -[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/image -[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square -[dumi-url]: https://github.com/umijs/dumi +

English | 简体中文

## Highlights diff --git a/README.zh-CN.md b/README.zh-CN.md index 90034e5d..e512d438 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -2,29 +2,18 @@

@rc-component/image

Ant Design Ant Design 生态的一部分。

🖼️ React 图片预览组件,支持预览组、缩放、旋转和自定义工具栏。

-
- -

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] +

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

-[npm-image]: https://img.shields.io/npm/v/@rc-component/image.svg?style=flat-square -[npm-url]: https://npmjs.org/package/@rc-component/image -[github-actions-image]: https://github.com/react-component/image/actions/workflows/react-component-ci.yml/badge.svg -[github-actions-url]: https://github.com/react-component/image/actions/workflows/react-component-ci.yml -[codecov-image]: https://img.shields.io/codecov/c/github/react-component/image/master.svg?style=flat-square -[codecov-url]: https://app.codecov.io/gh/react-component/image -[download-image]: https://img.shields.io/npm/dm/@rc-component/image.svg?style=flat-square -[download-url]: https://npmjs.org/package/@rc-component/image -[bundlephobia-image]: https://img.shields.io/bundlephobia/minzip/%40rc-component%2Fimage?style=flat-square -[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/image -[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square -[dumi-url]: https://github.com/umijs/dumi +

English | 简体中文

## 特性 From 1078197338900721186aa9da4bbd66c8d58e1799 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 20:32:13 +0800 Subject: [PATCH 33/37] chore: standardize package type entry --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 61e2970f..355d10cf 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "license": "MIT", "main": "./lib/index", "module": "./es/index", - "types": "./lib/index.d.ts", + "types": "./es/index.d.ts", "files": [ "assets/*.css", "es", From 587596cd2723610b4145f45072fb8c8619d09309 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 21:19:50 +0800 Subject: [PATCH 34/37] ci: limit reusable workflow secrets --- .github/workflows/react-component-ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml index f8482b63..75e70549 100644 --- a/.github/workflows/react-component-ci.yml +++ b/.github/workflows/react-component-ci.yml @@ -1,6 +1,10 @@ name: ✅ test on: [push, pull_request] +permissions: + contents: read jobs: test: uses: react-component/rc-test/.github/workflows/test-utoo.yml@main - secrets: inherit + secrets: + + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} From 66b3639d23b032ecac85d749f6e9db23f26e9cd7 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 21:29:35 +0800 Subject: [PATCH 35/37] ci: restore reusable workflow compatibility --- .github/workflows/react-component-ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml index 75e70549..9503b960 100644 --- a/.github/workflows/react-component-ci.yml +++ b/.github/workflows/react-component-ci.yml @@ -5,6 +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 d8c0b9fac251379462cc12a4484a339ea16cd625 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 29 Jun 2026 00:46:49 +0800 Subject: [PATCH 36/37] 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 eaff160a..4c2f17ed 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 edb63633f8f15b5037935678df205befc1d6b48b Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 29 Jun 2026 14:25:19 +0800 Subject: [PATCH 37/37] 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 9503b960..8d135ed5 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 }} \ No newline at end of file