From d7181f7a48bacdeeeada7d844a83cbd08d018329 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 16:25:49 +0800 Subject: [PATCH 1/6] chore: standardize repository config --- .dumirc.ts | 7 + .github/FUNDING.yml | 17 +- .github/dependabot.yml | 27 +-- .github/workflows/codeql.yml | 22 +- .github/workflows/main.yml | 6 - .github/workflows/react-component-ci.yml | 8 + .github/workflows/react-doctor.yml | 27 +++ .github/workflows/surge-preview.yml | 39 ++++ .gitignore | 2 + README.md | 250 ++++++++++------------- docs/examples/slider.tsx | 2 - docs/index.md | 2 +- now.json | 11 - package.json | 11 +- tsconfig.json | 4 +- vercel.json | 6 + 16 files changed, 229 insertions(+), 212 deletions(-) delete mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/react-component-ci.yml create mode 100644 .github/workflows/react-doctor.yml create mode 100644 .github/workflows/surge-preview.yml delete mode 100644 now.json create mode 100644 vercel.json diff --git a/.dumirc.ts b/.dumirc.ts index 105d4b032..34341ed3f 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -1,10 +1,14 @@ import { defineConfig } from 'dumi'; import path from 'path'; +const basePath = process.env.GH_PAGES ? '/slider/' : '/'; +const publicPath = process.env.GH_PAGES ? '/slider/' : '/'; + export default defineConfig({ alias: { '@rc-component/slider$': path.resolve('src'), '@rc-component/slider/es': path.resolve('src'), + '@rc-component/slider/assets': path.resolve('assets'), }, mfsu: false, favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'], @@ -12,5 +16,8 @@ export default defineConfig({ name: 'Slider', logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', }, + outputPath: 'docs-dist', + base: basePath, + publicPath, styles: [``], }); diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 33b1999c7..758659af3 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 index cb16808ab..07575c02b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,23 +1,8 @@ version: 2 updates: -- package-ecosystem: npm - directory: "/" - schedule: - interval: daily - time: "21:00" - open-pull-requests-limit: 10 - ignore: - - dependency-name: "@types/react" - versions: - - 17.0.0 - - 17.0.1 - - 17.0.2 - - 17.0.3 - - dependency-name: "@types/react-dom" - versions: - - 17.0.0 - - 17.0.1 - - 17.0.2 - - dependency-name: less - versions: - - 4.1.0 + - package-ecosystem: npm + directory: '/' + schedule: + interval: daily + time: '21:00' + open-pull-requests-limit: 10 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 095dadcde..23f424a81 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,12 +1,12 @@ -name: "CodeQL" +name: 'CodeQL' on: push: - branches: [ "master" ] + branches: ['master'] pull_request: - branches: [ "master" ] + branches: ['master'] schedule: - - cron: "17 10 * * 1" + - cron: '17 10 * * 1' jobs: analyze: @@ -20,22 +20,24 @@ jobs: strategy: fail-fast: false matrix: - language: [ javascript ] + language: [javascript] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + with: + persist-credentials: false - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e with: languages: ${{ matrix.language }} queries: +security-and-quality - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e with: - category: "/language:${{ matrix.language }}" + category: '/language:${{ matrix.language }}' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index f860ff107..000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,6 +0,0 @@ -name: ✅ test -on: [push, pull_request] -jobs: - test: - uses: react-component/rc-test/.github/workflows/test.yml@main - secrets: inherit diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml new file mode 100644 index 000000000..9503b9605 --- /dev/null +++ b/.github/workflows/react-component-ci.yml @@ -0,0 +1,8 @@ +name: ✅ test +on: [push, pull_request] +permissions: + contents: read +jobs: + test: + uses: react-component/rc-test/.github/workflows/test-utoo.yml@main + secrets: inherit diff --git a/.github/workflows/react-doctor.yml b/.github/workflows/react-doctor.yml new file mode 100644 index 000000000..f68281c8f --- /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 000000000..1b29a17bb --- /dev/null +++ b/.github/workflows/surge-preview.yml @@ -0,0 +1,39 @@ +name: Surge Preview + +on: + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +permissions: + contents: read + pull-requests: write + checks: write + statuses: write + +jobs: + preview: + runs-on: ubuntu-latest + env: + SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} + PREVIEW: true + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + with: + persist-credentials: false + - uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec + if: ${{ env.SURGE_TOKEN != '' }} + with: + surge_token: ${{ env.SURGE_TOKEN }} + github_token: ${{ secrets.GITHUB_TOKEN }} + dist: docs-dist + failOnError: true + setCommitStatus: true + build: | + npm install + npm run build + - name: Skip Surge preview + if: ${{ env.SURGE_TOKEN == '' }} + run: echo "SURGE_TOKEN is not configured; skip Surge preview." diff --git a/.gitignore b/.gitignore index fc07c1aed..0324c77aa 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,8 @@ yarn.lock package-lock.json pnpm-lock.yaml .doc +docs-dist +.vercel .storybook # umi diff --git a/README.md b/README.md index 6beb5a60f..63162056d 100644 --- a/README.md +++ b/README.md @@ -1,173 +1,143 @@ -# rc-slider - -Slider UI component for React - -[![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-slider.svg?style=flat-square -[npm-url]: http://npmjs.org/package/rc-slider -[travis-image]: https://img.shields.io/travis/react-component/slider/master?style=flat-square -[travis-url]: https://travis-ci.com/react-component/slider -[github-actions-image]: https://github.com/react-component/slider/workflows/CI/badge.svg -[github-actions-url]: https://github.com/react-component/slider/actions -[codecov-image]: https://img.shields.io/codecov/c/github/react-component/slider/master.svg?style=flat-square -[codecov-url]: https://app.codecov.io/gh/react-component/slider -[david-url]: https://david-dm.org/react-component/slider -[david-image]: https://david-dm.org/react-component/slider/status.svg?style=flat-square -[david-dev-url]: https://david-dm.org/react-component/slider?type=dev -[david-dev-image]: https://david-dm.org/react-component/slider/dev-status.svg?style=flat-square -[download-image]: https://img.shields.io/npm/dm/rc-slider.svg?style=flat-square -[download-url]: https://npmjs.org/package/rc-slider -[bundlephobia-url]: https://bundlephobia.com/package/rc-slider -[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-slider -[dumi-url]: https://github.com/umijs/dumi -[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square -## Install - -[![rc-slider](https://nodei.co/npm/rc-slider.png)](https://npmjs.org/package/rc-slider) +
+

@rc-component/slider

+

🎚️ Accessible React slider for single values, ranges, marks, and editable handles.

+

+ Ant Design +

+

Part of the Ant Design ecosystem.

+ +

+ npm version + npm downloads + CI + Codecov + bundle size + dumi +

+
+ +## Highlights + +- Supports single-value and range sliders with one shared component. +- Provides marks, dots, keyboard interaction, reverse and vertical layouts. +- Supports editable range handles and draggable tracks through `range` config. +- Exposes semantic `classNames` and `styles` slots for tracks, rail, and handles. -## Example - -`npm start` and then go to http://localhost:8000 +## Install -Online examples: https://slider.react-component.now.sh/ +```bash +npm install @rc-component/slider +``` ## Usage -## Slider -```js +```tsx pure import Slider from '@rc-component/slider'; import '@rc-component/slider/assets/index.css'; -export default () => ( - <> - - -); +export default () => ; ``` -## Range -Please refer to [#825](https://github.com/react-component/slider/issues/825) for information regarding usage of `Range`. -An example: -```js -import Slider, { Range } from '@rc-component/slider'; +```tsx pure +import Slider from '@rc-component/slider'; import '@rc-component/slider/assets/index.css'; export default () => ( - <> - - + ); ``` -## Compatibility - -| [IE / Edge](http://godban.github.io/browsers-support-badges/)
IE / Edge | [Firefox](http://godban.github.io/browsers-support-badges/)
Firefox | [Chrome](http://godban.github.io/browsers-support-badges/)
Chrome | [Safari](http://godban.github.io/browsers-support-badges/)
Safari | [Electron](http://godban.github.io/browsers-support-badges/)
Electron | -| --- | --- | --- | --- | --- | -| IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions | +Online preview: https://slider.react-component.vercel.app/ ## API -### createSliderWithTooltip(Slider | Range) => React.Component - -An extension to make Slider or Range support Tooltip on handle. - -```js -const Slider = require('@rc-component/slider'); -const createSliderWithTooltip = Slider.createSliderWithTooltip; -const Range = createSliderWithTooltip(Slider.Range); -``` - -[Online demo](http://react-component.github.io/slider/?path=/story/rc-slider--handle) - -After Range or Slider was wrapped by createSliderWithTooltip, it will have the following props: - -| Name | Type | Default | Description | -| ------------ | ------- | ------- | ----------- | -| tipFormatter | (value: number): React.ReactNode | `value => value` | A function to format tooltip's overlay | -| tipProps | Object | `{`
`placement: 'top',`
` prefixCls: 'rc-slider-tooltip',`
`overlay: tipFormatter(value)`
`}` | A function to format tooltip's overlay | - -### Common API - -The following APIs are shared by Slider and Range. - -| Name | Type | Default | Description | -| ------------ | ------- | ------- | ----------- | -| className | string | `''` | Additional CSS class for the root DOM node | -| min | number | `0` | The minimum value of the slider | -| max | number | `100` | The maximum value of the slider | -| id | string | `''` | Unique identifier for the component, used for accessibility | -| marks | `{number: ReactNode}` or`{number: { style, label }}` | `{}` | Marks on the slider. The key determines the position, and the value determines what will show. If you want to set the style of a specific mark point, the value should be an object which contains `style` and `label` properties. | -| step | number or `null` | `1` | Value to be added or subtracted on each step the slider makes. Must be greater than zero, and `max` - `min` should be evenly divisible by the step value.
When `marks` is not an empty object, `step` can be set to `null`, to make `marks` as steps. | -| vertical | boolean | `false` | If vertical is `true`, the slider will be vertical. | -| handle | (props) => React.ReactNode | | A handle generator which could be used to customized handle. | -| included | boolean | `true` | If the value is `true`, it means a continuous value interval, otherwise, it is a independent value. | -| reverse | boolean | `false` | If the value is `true`, it means the component is rendered reverse. | -| disabled | boolean \| boolean[] | `false` | If `true`, handles can't be moved. This prop can also be an array to disable specific handles in range mode, e.g. `[true, false, true]` disables first and third handles. When any rendered handle is disabled, `editable` mode will be disabled. | -| keyboard | boolean | `true` | Support using keyboard to move handlers. | -| dots | boolean | `false` | When the `step` value is greater than 1, you can set the `dots` to `true` if you want to render the slider with dots. | -| onBeforeChange | Function | NOOP | `onBeforeChange` will be triggered when `ontouchstart` or `onmousedown` is triggered. | -| onChange | Function | NOOP | `onChange` will be triggered while the value of Slider changing. | -| onChangeComplete | Function | NOOP | `onChangeComplete` will be triggered when `ontouchend` or `onmouseup` is triggered. | -| minimumTrackStyle | Object | | please use `trackStyle` instead. (`only used for slider, just for compatibility , will be deprecate at rc-slider@9.x `) | -| maximumTrackStyle | Object | | please use `railStyle` instead (`only used for slider, just for compatibility , will be deprecate at rc-slider@9.x`) | -| handleStyle | Array[Object] \| Object | `[{}]` | The style used for handle. (`both for slider(`Object`) and range(`Array of Object`), the array will be used for multi handle following element order`) | -| trackStyle | Array[Object] \| Object | `[{}]` | The style used for track. (`both for slider(`Object`) and range(`Array of Object`), the array will be used for multi track following element order`)| -| railStyle | Object | `{}` | The style used for the track base color. | -| dotStyle | Object \| (dotValue) => Object | `{}` | The style used for the dots. | -| activeDotStyle | Object \| (dotValue) => Object | `{}` | The style used for the active dots. | - ### Slider -| Name | Type | Default | Description | -| ------------ | ------- | ------- | ----------- | -| defaultValue | number | `0` | Set initial value of slider. | -| value | number | - | Set current value of slider. | -| startPoint | number | `undefined` | Track starts from this value. If `undefined`, `min` is used. | -| tabIndex | number | `0` | Set the tabIndex of the slider handle. | -| ariaLabelForHandle | string | - | Set the `aria-label` attribute on the slider handle. | -| ariaLabelledByForHandle | string | - | Set the `aria-labelledby` attribute on the slider handle. | -| ariaRequired | boolean | - | Set the `aria-required` attribute on the slider handle. | -| ariaValueTextFormatterForHandle | (value) => string | - | A function to set the `aria-valuetext` attribute on the slider handle. It receives the current value of the slider and returns a formatted string describing the value. See [WAI-ARIA Authoring Practices 1.1](https://www.w3.org/TR/wai-aria-practices-1.1/#slider) for more information. | - -### Range - -| Name | Type | Default | Description | -| ------------ | ------- | ------- | ----------- | -| defaultValue | `number[]` | `[0, 0]` | Set initial positions of handles. | -| value | `number[]` | | Set current positions of handles. | -| tabIndex | number[] | `[0, 0]` | Set the tabIndex of each handle. | -| ariaLabelGroupForHandles | Array[string] | - | Set the `aria-label` attribute on each handle. | -| ariaLabelledByGroupForHandles | Array[string] | - | Set the `aria-labelledby` attribute on each handle. | -| ariaValueTextFormatterGroupForHandles | Array[(value) => string] | - | A function to set the `aria-valuetext` attribute on each handle. It receives the current value of the slider and returns a formatted string describing the value. See [WAI-ARIA Authoring Practices 1.1](https://www.w3.org/TR/wai-aria-practices-1.1/#slider) for more information. | -| count | number | `1` | Determine how many ranges to render, and multiple handles will be rendered (number + 1). | -| allowCross | boolean | `true` | `allowCross` could be set as `true` to allow those handles to cross. | -| pushable | boolean or number | `false` | `pushable` could be set as `true` to allow pushing of surrounding handles when moving a handle. When set to a number, the number will be the minimum ensured distance between handles. Example: ![](http://i.giphy.com/l46Cs36c9HrHMExoc.gif) | -| draggableTrack | boolean | `false` | Open the track drag. open after click on the track will be invalid. | - -### SliderTooltip - -The Tooltip Component that keep following with content. +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| `activeDotStyle` | React.CSSProperties \| `(dotValue: number) => React.CSSProperties` | - | Style for active dots. | +| `activeHandleRender` | `HandlesProps['handleRender']` | - | Render function for the active handle. | +| `allowCross` | boolean | true | Allow handles to cross in range mode. | +| `ariaLabelForHandle` | string \| string[] | - | `aria-label` for handle elements. | +| `ariaLabelledByForHandle` | string \| string[] | - | `aria-labelledby` for handle elements. | +| `ariaRequired` | boolean | - | `aria-required` for handle elements. | +| `ariaValueTextFormatterForHandle` | `(value: number) => string` \| Array function | - | Formatter for `aria-valuetext`. | +| `autoFocus` | boolean | - | Focus the slider on mount. | +| `className` | string | - | Additional class name. | +| `classNames` | Partial> | - | Semantic class names for internal slots. | +| `count` | number | - | Deprecated. Use `range.minCount` or `range.maxCount`. | +| `defaultValue` | number \| number[] | - | Initial value. | +| `disabled` | boolean \| boolean[] | false | Disable all handles or specific handles. | +| `dots` | boolean | false | Show dots when `step` is greater than 1. | +| `dotStyle` | React.CSSProperties \| `(dotValue: number) => React.CSSProperties` | - | Style for dots. | +| `handleRender` | `HandlesProps['handleRender']` | - | Custom handle renderer. | +| `handleStyle` | React.CSSProperties \| React.CSSProperties[] | - | Deprecated. Use `styles.handle`. | +| `id` | string | - | Root id. | +| `included` | boolean | true | Whether the track is rendered as a continuous selected interval. | +| `keyboard` | boolean | true | Enable keyboard interaction. | +| `marks` | Record | - | Slider marks. | +| `max` | number | 100 | Maximum value. | +| `min` | number | 0 | Minimum value. | +| `onAfterChange` | `(value) => void` | - | Deprecated. Use `onChangeComplete`. | +| `onBeforeChange` | `(value) => void` | - | Deprecated. Use `onChange`. | +| `onBlur` | `(event) => void` | - | Blur handler. | +| `onChange` | `(value) => void` | - | Triggered while value changes. | +| `onChangeComplete` | `(value) => void` | - | Triggered when interaction completes. | +| `onFocus` | `(event) => void` | - | Focus handler. | +| `prefixCls` | string | `'rc-slider'` | Prefix class name. | +| `pushable` | boolean \| number | false | Push adjacent handles in range mode. | +| `railStyle` | React.CSSProperties | - | Deprecated. Use `styles.rail`. | +| `range` | boolean \| RangeConfig | false | Enable range mode or configure editable range behavior. | +| `reverse` | boolean | false | Render in reverse direction. | +| `startPoint` | number | `min` | Start point for a single-value track. | +| `step` | number \| null | 1 | Step size. Use `null` to use marks as steps. | +| `style` | React.CSSProperties | - | Root style. | +| `styles` | Partial> | - | Semantic styles for internal slots. | +| `tabIndex` | number \| number[] | 0 | Handle tab index. | +| `track` | boolean | - | Whether to render track elements. | +| `trackStyle` | React.CSSProperties \| React.CSSProperties[] | - | Deprecated. Use `styles.track`. | +| `value` | number \| number[] | - | Controlled value. | +| `vertical` | boolean | false | Render vertically. | + +### RangeConfig + +| Name | Type | Default | Description | +| ---------------- | ------- | ------- | ---------------------------------------- | +| `draggableTrack` | boolean | false | Allow dragging the selected range track. | +| `editable` | boolean | false | Allow adding or removing range handles. | +| `maxCount` | number | - | Maximum handle count when editable. | +| `minCount` | number | - | Minimum handle count when editable. | + +### Ref + +| Name | Type | Description | +| ------- | ------------ | ----------------- | +| `blur` | `() => void` | Blur the slider. | +| `focus` | `() => void` | Focus the slider. | ## Development -``` +```bash npm install npm start +npm test +npm run tsc +npm run compile +npm run build ``` -## Test Case +## Release -`npm run test` +```bash +npm run prepublishOnly +``` -## Coverage +`prepublishOnly` builds the package with Father and publishes through `rc-np`. Run `npm run gh-pages` to deploy the dumi site. -`npm run coverage` ## License -`rc-slider` is released under the MIT license. +@rc-component/slider is released under the MIT license. diff --git a/docs/examples/slider.tsx b/docs/examples/slider.tsx index cfb0625e9..e78a6fe6b 100644 --- a/docs/examples/slider.tsx +++ b/docs/examples/slider.tsx @@ -17,8 +17,6 @@ function percentFormatter(v) { return `${v} %`; } -// const SliderWithTooltip = createSliderWithTooltip(Slider); - class NullableSlider extends React.Component { constructor(props) { super(props); diff --git a/docs/index.md b/docs/index.md index f995dd224..bffcd440c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,5 +1,5 @@ --- -title: rc-slider +title: '@rc-component/slider' --- diff --git a/now.json b/now.json deleted file mode 100644 index a23b01b82..000000000 --- a/now.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": 2, - "name": "rc-slider", - "builds": [ - { - "src": "package.json", - "use": "@now/static-build", - "config": { "distDir": "dist" } - } - ] -} \ No newline at end of file diff --git a/package.json b/package.json index a806c03ff..980b5dfc3 100644 --- a/package.json +++ b/package.json @@ -29,17 +29,18 @@ "es" ], "scripts": { + "build": "npm run docs:build", "compile": "father build && lessc assets/index.less assets/index.css", "coverage": "rc-test --coverage", "docs:build": "dumi build", - "docs:deploy": "gh-pages -d .doc", + "docs:deploy": "gh-pages -d docs-dist", + "gh-pages": "GH_PAGES=1 npm run docs:build && npm run docs:deploy", "lint": "eslint src/ --ext .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", - "tsc": "bunx tsc --noEmit" + "tsc": "tsc --noEmit" }, "dependencies": { "@rc-component/util": "^1.11.1", @@ -62,7 +63,7 @@ "cross-env": "^7.0.0", "dumi": "^2.2.10", "eslint": "^8.54.0", - "eslint-plugin-jest": "^28.2.0", + "eslint-plugin-jest": "^27.9.0", "eslint-plugin-unicorn": "^54.0.0", "father": "^4.3.5", "father-build": "^1.18.6", diff --git a/tsconfig.json b/tsconfig.json index 0e921d816..ffe9f16b0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,5 +12,7 @@ "@@/*": ["src/.umi/*"], "@rc-component/slider": ["src/index.tsx"] } - } + }, + "include": [".dumirc.ts", "src", "tests", "docs/examples"], + "exclude": ["docs-dist", "lib", "es"] } diff --git a/vercel.json b/vercel.json new file mode 100644 index 000000000..5f9139ef4 --- /dev/null +++ b/vercel.json @@ -0,0 +1,6 @@ +{ + "framework": "umijs", + "installCommand": "npm install", + "buildCommand": "npm run build", + "outputDirectory": "docs-dist" +} From 0aceb21347f015c2ee47dc5578f7ee14eef656df Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 16:30:19 +0800 Subject: [PATCH 2/6] fix: make preview build generate styles --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 980b5dfc3..ab743ba7e 100644 --- a/package.json +++ b/package.json @@ -29,12 +29,12 @@ "es" ], "scripts": { - "build": "npm run docs:build", + "build": "npm run compile && npm run docs:build", "compile": "father build && lessc assets/index.less assets/index.css", "coverage": "rc-test --coverage", "docs:build": "dumi build", "docs:deploy": "gh-pages -d docs-dist", - "gh-pages": "GH_PAGES=1 npm run docs:build && npm run docs:deploy", + "gh-pages": "GH_PAGES=1 npm run compile && npm run docs:build && npm run docs:deploy", "lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md", "prepublishOnly": "npm run compile && rc-np", "prettier": "prettier --write --ignore-unknown .", From a994169efe7c185913ce5d5e252dede86c37ed64 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 16:41:00 +0800 Subject: [PATCH 3/6] fix: address review feedback --- .github/workflows/react-component-ci.yml | 3 ++- README.md | 10 +++++----- package.json | 2 +- tsconfig.json | 5 ++++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml index 9503b9605..36dacae47 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 }} diff --git a/README.md b/README.md index 63162056d..29115db36 100644 --- a/README.md +++ b/README.md @@ -65,21 +65,21 @@ Online preview: https://slider.react-component.vercel.app/ | `ariaLabelForHandle` | string \| string[] | - | `aria-label` for handle elements. | | `ariaLabelledByForHandle` | string \| string[] | - | `aria-labelledby` for handle elements. | | `ariaRequired` | boolean | - | `aria-required` for handle elements. | -| `ariaValueTextFormatterForHandle` | `(value: number) => string` \| Array function | - | Formatter for `aria-valuetext`. | +| `ariaValueTextFormatterForHandle` | `((value: number) => string) \| ((value: number) => string)[]` | - | Formatter for `aria-valuetext`. | | `autoFocus` | boolean | - | Focus the slider on mount. | | `className` | string | - | Additional class name. | -| `classNames` | Partial> | - | Semantic class names for internal slots. | +| `classNames` | `Partial>` | - | Semantic class names for internal slots. | | `count` | number | - | Deprecated. Use `range.minCount` or `range.maxCount`. | | `defaultValue` | number \| number[] | - | Initial value. | | `disabled` | boolean \| boolean[] | false | Disable all handles or specific handles. | -| `dots` | boolean | false | Show dots when `step` is greater than 1. | +| `dots` | boolean | false | Show dots at each valid step position. | | `dotStyle` | React.CSSProperties \| `(dotValue: number) => React.CSSProperties` | - | Style for dots. | | `handleRender` | `HandlesProps['handleRender']` | - | Custom handle renderer. | | `handleStyle` | React.CSSProperties \| React.CSSProperties[] | - | Deprecated. Use `styles.handle`. | | `id` | string | - | Root id. | | `included` | boolean | true | Whether the track is rendered as a continuous selected interval. | | `keyboard` | boolean | true | Enable keyboard interaction. | -| `marks` | Record | - | Slider marks. | +| `marks` | `Record` | - | Slider marks. | | `max` | number | 100 | Maximum value. | | `min` | number | 0 | Minimum value. | | `onAfterChange` | `(value) => void` | - | Deprecated. Use `onChangeComplete`. | @@ -96,7 +96,7 @@ Online preview: https://slider.react-component.vercel.app/ | `startPoint` | number | `min` | Start point for a single-value track. | | `step` | number \| null | 1 | Step size. Use `null` to use marks as steps. | | `style` | React.CSSProperties | - | Root style. | -| `styles` | Partial> | - | Semantic styles for internal slots. | +| `styles` | `Partial>` | - | Semantic styles for internal slots. | | `tabIndex` | number \| number[] | 0 | Handle tab index. | | `track` | boolean | - | Whether to render track elements. | | `trackStyle` | React.CSSProperties \| React.CSSProperties[] | - | Deprecated. Use `styles.track`. | diff --git a/package.json b/package.json index ab743ba7e..ec0155f66 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "coverage": "rc-test --coverage", "docs:build": "dumi build", "docs:deploy": "gh-pages -d docs-dist", - "gh-pages": "GH_PAGES=1 npm run compile && npm run docs:build && npm run docs:deploy", + "gh-pages": "cross-env GH_PAGES=1 npm run compile && npm run docs:build && npm run docs:deploy", "lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md", "prepublishOnly": "npm run compile && rc-np", "prettier": "prettier --write --ignore-unknown .", diff --git a/tsconfig.json b/tsconfig.json index ffe9f16b0..600553776 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,10 @@ "paths": { "@/*": ["src/*"], "@@/*": ["src/.umi/*"], - "@rc-component/slider": ["src/index.tsx"] + "@rc-component/slider": ["src/index.tsx"], + "@rc-component/slider/es": ["src"], + "@rc-component/slider/es/*": ["src/*"], + "@rc-component/slider/assets/*": ["assets/*"] } }, "include": [".dumirc.ts", "src", "tests", "docs/examples"], From 36ad3d17e79fbb7f5cb8f02d0af17cfba3abb0ec Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 16:44:38 +0800 Subject: [PATCH 4/6] fix: keep rc-test secrets inheritance --- .github/workflows/react-component-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml index 36dacae47..9503b9605 100644 --- a/.github/workflows/react-component-ci.yml +++ b/.github/workflows/react-component-ci.yml @@ -5,5 +5,4 @@ permissions: jobs: test: uses: react-component/rc-test/.github/workflows/test-utoo.yml@main - secrets: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + secrets: inherit From 86057b872748ab38802525eb21326a430b745ef8 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 16:46:36 +0800 Subject: [PATCH 5/6] fix: align test workflow triggers --- .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 9503b9605..1ed642094 100644 --- a/.github/workflows/react-component-ci.yml +++ b/.github/workflows/react-component-ci.yml @@ -1,5 +1,9 @@ name: ✅ test -on: [push, pull_request] +on: + push: + branches: [master] + pull_request: + branches: [master] permissions: contents: read jobs: From a1c5b581d63a5aaba42c90d14c77fab4f4f30b4d Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 01:27:32 +0800 Subject: [PATCH 6/6] chore: address AI review feedback --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ec0155f66..ab61da4b4 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "coverage": "rc-test --coverage", "docs:build": "dumi build", "docs:deploy": "gh-pages -d docs-dist", - "gh-pages": "cross-env GH_PAGES=1 npm run compile && npm run docs:build && npm run docs:deploy", + "gh-pages": "npm run compile && cross-env GH_PAGES=1 npm run docs:build && npm run docs:deploy", "lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md", "prepublishOnly": "npm run compile && rc-np", "prettier": "prettier --write --ignore-unknown .",