diff --git a/.dumirc.ts b/.dumirc.ts
index 8b56eeb..0b34af3 100644
--- a/.dumirc.ts
+++ b/.dumirc.ts
@@ -2,7 +2,7 @@ import { defineConfig } from 'dumi';
import path from 'path';
const basePath = process.env.GH_PAGES ? '/segmented/' : '/';
-const publicPath = process.env.GH_PAGES ? '/segmented/' : '/';
+const publicPath = basePath;
export default defineConfig({
favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'],
@@ -10,11 +10,13 @@ export default defineConfig({
name: 'Segmented',
logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
},
- outputPath: '.doc',
+ outputPath: 'docs-dist',
exportStatic: {},
base: basePath,
publicPath,
alias: {
- 'rc-segmented': path.resolve(__dirname, 'src/index.tsx'),
+ '@rc-component/segmented$': path.resolve(__dirname, 'src/index.tsx'),
+ '@rc-component/segmented/es': path.resolve(__dirname, 'src'),
+ '@rc-component/segmented/assets': path.resolve(__dirname, 'assets'),
},
});
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 0000000..758659a
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,2 @@
+github: ant-design
+open_collective: ant-design
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 07575c0..3b730ef 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -3,6 +3,17 @@ updates:
- package-ecosystem: npm
directory: '/'
schedule:
- interval: daily
+ interval: weekly
+ day: monday
time: '21:00'
+ timezone: Asia/Shanghai
+ open-pull-requests-limit: 10
+
+ - package-ecosystem: github-actions
+ directory: '/'
+ schedule:
+ interval: weekly
+ day: monday
+ time: '21:00'
+ timezone: Asia/Shanghai
open-pull-requests-limit: 10
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
deleted file mode 100644
index f860ff1..0000000
--- a/.github/workflows/main.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-name: ✅ test
-on: [push, pull_request]
-jobs:
- test:
- uses: react-component/rc-test/.github/workflows/test.yml@main
- secrets: inherit
diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml
deleted file mode 100644
index d02059a..0000000
--- a/.github/workflows/preview.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-name: 🔂 Surge PR Preview
-
-on: [pull_request]
-
-jobs:
- preview:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - uses: afc163/surge-preview@v1
- id: preview_step
- with:
- surge_token: ${{ secrets.SURGE_TOKEN }}
- github_token: ${{ secrets.GITHUB_TOKEN }}
- dist: .doc
- build: |
- npm install
- npm run docs:build
- - name: Get the preview_url
- run: echo "url => ${{ steps.preview_step.outputs.preview_url }}"
diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml
new file mode 100644
index 0000000..bb86720
--- /dev/null
+++ b/.github/workflows/react-component-ci.yml
@@ -0,0 +1,13 @@
+name: ✅ test
+on:
+ push:
+ branches: [master]
+ pull_request:
+ branches: [master]
+permissions:
+ contents: read
+jobs:
+ test:
+ uses: react-component/rc-test/.github/workflows/test-utoo.yml@main
+ secrets:
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
diff --git a/.github/workflows/react-doctor.yml b/.github/workflows/react-doctor.yml
new file mode 100644
index 0000000..097eb88
--- /dev/null
+++ b/.github/workflows/react-doctor.yml
@@ -0,0 +1,27 @@
+name: React Doctor
+
+on:
+ pull_request:
+ types: [opened, synchronize, reopened, ready_for_review]
+ push:
+ branches: [master]
+
+permissions:
+ contents: read
+ pull-requests: write
+ issues: write
+ statuses: write
+
+concurrency:
+ group: react-doctor-${{ github.event.pull_request.number || github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ react-doctor:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v7
+ with:
+ fetch-depth: 0
+ persist-credentials: false
+ - uses: millionco/react-doctor@0b4f4f4bd248a154e64eb508a48347f71154b3f3
diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml
new file mode 100644
index 0000000..4c2f17e
--- /dev/null
+++ b/.github/workflows/surge-preview.yml
@@ -0,0 +1,54 @@
+name: Surge Preview
+
+on:
+ pull_request:
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
+ cancel-in-progress: true
+
+permissions:
+ contents: read
+ pull-requests: write
+ checks: write
+
+jobs:
+ preview:
+ runs-on: ubuntu-latest
+ concurrency:
+ group: surge-preview-${{ github.event.pull_request.number }}
+ cancel-in-progress: true
+ env:
+ PREVIEW: true
+ steps:
+ - uses: actions/checkout@v7
+ with:
+ persist-credentials: false
+ - name: Check Surge token
+ id: surge-token
+ env:
+ SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
+ run: |
+ if [ -n "$SURGE_TOKEN" ]; then
+ echo "enabled=true" >> "$GITHUB_OUTPUT"
+ else
+ echo "enabled=false" >> "$GITHUB_OUTPUT"
+ fi
+ - name: Build preview
+ if: ${{ steps.surge-token.outputs.enabled == 'true' }}
+ run: |
+ npm install
+ npm run build
+ - uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec
+ if: ${{ steps.surge-token.outputs.enabled == 'true' }}
+ env:
+ SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
+ with:
+ surge_token: ${{ env.SURGE_TOKEN }}
+ github_token: ${{ secrets.GITHUB_TOKEN }}
+ dist: docs-dist
+ failOnError: false
+ setCommitStatus: false
+ - name: Skip Surge preview
+ if: ${{ steps.surge-token.outputs.enabled != 'true' }}
+ run: echo "SURGE_TOKEN is not configured; skip Surge preview."
diff --git a/.gitignore b/.gitignore
index e65506a..14aa70a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,6 +30,8 @@ package-lock.json
pnpm-lock.yaml
coverage/
.doc
+docs-dist
+.vercel
# umi
.umi
diff --git a/.husky/pre-commit b/.husky/pre-commit
index 0da96d6..2312dc5 100755
--- a/.husky/pre-commit
+++ b/.husky/pre-commit
@@ -1,4 +1 @@
-#!/usr/bin/env sh
-. "$(dirname -- "$0")/_/husky.sh"
-
-npx pretty-quick --staged
+npx lint-staged
diff --git a/.prettierignore b/.prettierignore
index 32cb484..e0de014 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -11,3 +11,13 @@ _site
.umi
.doc
README.md
+coverage
+docs-dist
+dist
+.dumi/tmp
+.dumi/tmp-production
+.vercel
+pnpm-lock.yaml
+yarn.lock
+bun.lockb
+*.log
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..bd0a1f7
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2019-present react-component
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
index 6972128..921d2c5 100644
--- a/README.md
+++ b/README.md
@@ -1,79 +1,119 @@
-# @rc-component/segmented
+
+
@rc-component/segmented
+
Part of the Ant Design ecosystem.
+
🧩 React segmented control for switching between compact options.
-[![NPM version][npm-image]][npm-url] [![npm download][download-image]][download-url] [](https://github.com/umijs/dumi) [![build status][github-actions-image]][github-actions-url] [![Codecov][codecov-image]][codecov-url] [![bundle size][bundlephobia-image]][bundlephobia-url]
+
+
+
+
+
+
+
+
+
-[npm-image]: http://img.shields.io/npm/v/@rc-component/segmented.svg?style=flat-square
-[npm-url]: http://npmjs.org/package/@rc-component/segmented
-[github-actions-image]: https://github.com/react-component/segmented/actions/workflows/main.yml/badge.svg
-[github-actions-url]: https://github.com/react-component/segmented/actions/workflows/main.yml
-[codecov-image]: https://codecov.io/gh/react-component/segmented/branch/master/graph/badge.svg
-[codecov-url]: https://codecov.io/gh/react-component/segmented/branch/master
-[download-image]: https://img.shields.io/npm/dm/@rc-component/segmented.svg?style=flat-square
-[download-url]: https://npmjs.org/package/@rc-component/segmented
-[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/segmented
-[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/@rc-component/segmented
+English | 简体中文
-React Segmented Control.
-
+## Highlights
-## Live Demo
-
-https://react-component.github.io/segmented/
+- Supports string, number, and labeled option records.
+- Provides controlled and uncontrolled value flows.
+- Includes keyboard navigation, RTL, vertical layout, and disabled options.
+- Exposes semantic `classNames` and `styles` slots for item and label customization.
## Install
-[](https://npmjs.org/package/@rc-component/segmented)
+```bash
+npm install @rc-component/segmented
+```
## Usage
-```js
+```tsx pure
import Segmented from '@rc-component/segmented';
-import '@rc-component/segmented/assets/index.css'; // import '@rc-component/segmented/assets/index.less';
-import { render } from 'react-dom';
+import '@rc-component/segmented/assets/index.css';
-render(
+export default () => (
handleValueChange(value)}
- />,
- mountNode,
+ options={['Daily', 'Weekly', 'Monthly']}
+ defaultValue="Weekly"
+ onChange={(value) => {
+ console.log(value);
+ }}
+ />
);
```
+Online preview: https://segmented.react-component.vercel.app/
+
+## Examples
+
+Run the local dumi site:
+
+```bash
+npm install
+npm start
+```
+
+Then open `http://localhost:8000`.
+
## API
-Please note that **onChange** API
- changed on v2.0.0+
-
-| Property | Type | Default | Description |
-| --------- | --------- | --------- | --------- |
-| prefixCls | string | `rc-segmented` | prefixCls of this component |
-| className | string | '' | additional class name of segmented |
-| style | React.CSSProperties | | style properties of segmented |
-| options | Array | [] | options for choices |
-| value | string \| number | | value of segmented |
-| defaultValue | string \| number | | defaultValue of segmented |
-| value | string \| number | | currently selected value of segmented |
-| onChange | (value: string \| number) => void | | defaultValue of segmented |
-| disabled | boolean | false | disabled status of segmented |
-
-### SegmentedOption
-
-| Property | Type | Default | Description |
-| --------- | --------- | --------- | --------- |
-| label | ReactNode | | label of segmented option |
-| value | string \| number | | value of segmented option |
-| className | string | '' | additional class name of segmented option |
-| disabled | boolean | false | disabled status of segmented option |
+### Segmented
+
+| Name | Type | Default | Description |
+| --- | --- | --- | --- |
+| `className` | string | `''` | Additional class name. |
+| `classNames` | Partial> | - | Semantic class names for internal slots. |
+| `defaultValue` | string \| number | first option value | Initial selected value. |
+| `direction` | `'ltr'` \| `'rtl'` | - | Layout direction. |
+| `disabled` | boolean | false | Disable all options. |
+| `itemRender` | `(node: ReactNode, info: { item: SegmentedLabeledOption }) => ReactNode` | identity | Custom option item renderer. |
+| `motionName` | string | `'thumb-motion'` | Motion class name for the active thumb. |
+| `name` | string | - | Radio group name. |
+| `onChange` | `(value: string \| number) => void` | - | Triggered when the selected value changes. |
+| `options` | Array | - | Available options. Required. |
+| `prefixCls` | string | `'rc-segmented'` | Prefix class name. |
+| `style` | React.CSSProperties | - | Root style. |
+| `styles` | Partial> | - | Semantic styles for internal slots. |
+| `value` | string \| number | - | Controlled selected value. |
+| `vertical` | boolean | false | Render options vertically. |
+
+Additional valid `div` props are passed to the root element.
+
+### SegmentedLabeledOption
+
+| Name | Type | Default | Description |
+| --- | --- | --- | --- |
+| `className` | string | - | Option class name. |
+| `disabled` | boolean | false | Disable this option. |
+| `label` | ReactNode | - | Displayed option content. |
+| `title` | string | derived from label | Native title for the label. |
+| `value` | string \| number | - | Option value. |
## Development
-```
+```bash
npm install
npm start
+npm test
+npm run tsc
+npm run compile
+npm run build
+```
+
+The dumi site runs at `http://localhost:8000` by default.
+
+## Release
+
+```bash
+npm run prepublishOnly
```
+The release flow is handled by `@rc-component/np` through the `rc-np` command after the package build.
+
## License
-@rc-component/segmented is released under the MIT license.
+@rc-component/segmented is released under the [MIT](./LICENSE) license.
diff --git a/README.zh-CN.md b/README.zh-CN.md
new file mode 100644
index 0000000..940adc2
--- /dev/null
+++ b/README.zh-CN.md
@@ -0,0 +1,118 @@
+
+
@rc-component/segmented
+
Ant Design 生态的一部分。
+
🧩 React 分段控制器组件。
+
+
+
+
+
+
+
+
+
+
+
+English | 简体中文
+
+## 特性
+
+- 支持字符串、数字和带标签的选项记录。
+- 支持受控和非受控的取值流程。
+- 包括键盘导航、RTL、垂直布局和禁用选项。
+- 引入用于项目和标签定制的语义 `classNames` 和 `styles` 插槽。
+
+## 安装
+
+```bash
+npm install @rc-component/segmented
+```
+
+## 使用
+
+```tsx pure
+import Segmented from '@rc-component/segmented';
+import '@rc-component/segmented/assets/index.css';
+
+export default () => (
+ {
+ console.log(value);
+ }}
+ />
+);
+```
+
+在线预览:https://segmented.react-component.vercel.app/
+
+## 示例
+
+运行本地 dumi 站点:
+
+```bash
+npm install
+npm start
+```
+
+然后打开 `http://localhost:8000`。
+
+## API
+
+### Segmented
+
+| 名称 | 类型 | 默认值 | 说明 |
+| -------------- | ------------------------------------------------------------------------ | ---------------- | ---------------------------- |
+| `className` | string | `''` | 附加 className。 |
+| `classNames` | Partial> | - | 内部插槽的语义化 className。 |
+| `defaultValue` | string \| number | 第一个选项值 | 初始选中值。 |
+| `direction` | `'ltr'` \| `'rtl'` | - | 布局方向。 |
+| `disabled` | boolean | false | 禁用所有选项。 |
+| `itemRender` | `(node: ReactNode, info: { item: SegmentedLabeledOption }) => ReactNode` | identity | 自定义选项项渲染器。 |
+| `motionName` | string | `'thumb-motion'` | 活动拇指的动画 className。 |
+| `name` | string | - | 单选组名称。 |
+| `onChange` | `(value: string \| number) => void` | - | 当所选值更改时触发。 |
+| `options` | Array | - | 可用选项,必填。 |
+| `prefixCls` | string | `'rc-segmented'` | className 前缀。 |
+| `style` | React.CSSProperties | - | 根样式。 |
+| `styles` | Partial> | - | 内部插槽的语义化样式。 |
+| `value` | string \| number | - | 受控选中值。 |
+| `vertical` | boolean | false | 垂直渲染选项。 |
+
+其他合法的 `div` 属性会透传给根元素。
+
+### SegmentedLabeledOption
+
+| 名称 | 类型 | 默认值 | 说明 |
+| ----------- | ---------------- | -------- | ---------------- |
+| `className` | string | - | 选项 className。 |
+| `disabled` | boolean | false | 禁用此选项。 |
+| `label` | ReactNode | - | 展示的选项内容。 |
+| `title` | string | 源自标签 | 标签的原生标题。 |
+| `value` | string \| number | - | 选项值。 |
+
+## 本地开发
+
+```bash
+npm install
+npm start
+npm test
+npm run tsc
+npm run compile
+npm run build
+```
+
+dumi 站点默认运行在 `http://localhost:8000`。
+
+## 发布
+
+```bash
+npm run prepublishOnly
+```
+
+包构建完成后,发布流程由 `@rc-component/np` 通过 `rc-np` 命令处理。
+
+## 许可证
+
+@rc-component/segmented 基于 [MIT](./LICENSE) 许可证发布。
diff --git a/docs/demo/basic.tsx b/docs/demo/basic.tsx
index db4d63d..712276d 100644
--- a/docs/demo/basic.tsx
+++ b/docs/demo/basic.tsx
@@ -1,4 +1,4 @@
-import Segmented from 'rc-segmented';
+import Segmented from '@rc-component/segmented';
import React from 'react';
import '../../assets/style.less';
diff --git a/docs/demo/controlled.tsx b/docs/demo/controlled.tsx
index 2546819..b3890a2 100644
--- a/docs/demo/controlled.tsx
+++ b/docs/demo/controlled.tsx
@@ -1,7 +1,7 @@
-import '../../assets/style.less';
+import type { SegmentedValue } from '@rc-component/segmented';
+import Segmented from '@rc-component/segmented';
import React from 'react';
-import Segmented from 'rc-segmented';
-import type { SegmentedValue } from 'rc-segmented';
+import '../../assets/style.less';
export default class Demo extends React.Component<
unknown,
diff --git a/docs/demo/custom-render.tsx b/docs/demo/custom-render.tsx
index fd39b23..eb41dcb 100644
--- a/docs/demo/custom-render.tsx
+++ b/docs/demo/custom-render.tsx
@@ -1,6 +1,6 @@
-import '../../assets/style.less';
+import Segmented from '@rc-component/segmented';
import * as React from 'react';
-import Segmented from 'rc-segmented';
+import '../../assets/style.less';
const options = [
{
diff --git a/docs/demo/dynamic.tsx b/docs/demo/dynamic.tsx
index c350d9f..3cfe13c 100644
--- a/docs/demo/dynamic.tsx
+++ b/docs/demo/dynamic.tsx
@@ -1,6 +1,6 @@
-import '../../assets/style.less';
+import Segmented from '@rc-component/segmented';
import * as React from 'react';
-import Segmented from 'rc-segmented';
+import '../../assets/style.less';
const defaultOptions1 = ['iOS', 'Android', 'Web'];
const defaultOptions2 = [
diff --git a/docs/demo/html-title.tsx b/docs/demo/html-title.tsx
index 394141d..6feb647 100644
--- a/docs/demo/html-title.tsx
+++ b/docs/demo/html-title.tsx
@@ -1,6 +1,6 @@
-import '../../assets/style.less';
+import Segmented from '@rc-component/segmented';
import React from 'react';
-import Segmented from 'rc-segmented';
+import '../../assets/style.less';
export default function App() {
return (
diff --git a/docs/demo/name.tsx b/docs/demo/name.tsx
index d62fe30..260be39 100644
--- a/docs/demo/name.tsx
+++ b/docs/demo/name.tsx
@@ -1,4 +1,4 @@
-import Segmented from 'rc-segmented';
+import Segmented from '@rc-component/segmented';
import React from 'react';
import '../../assets/style.less';
diff --git a/docs/demo/refs.tsx b/docs/demo/refs.tsx
index 5a7e345..45e5e22 100644
--- a/docs/demo/refs.tsx
+++ b/docs/demo/refs.tsx
@@ -1,6 +1,6 @@
-import '../../assets/style.less';
+import Segmented from '@rc-component/segmented';
import React from 'react';
-import Segmented from 'rc-segmented';
+import '../../assets/style.less';
class ClassComponentWithStringRef extends React.Component {
componentDidMount() {
diff --git a/docs/demo/rtl.tsx b/docs/demo/rtl.tsx
index 91c3761..12fd8b4 100644
--- a/docs/demo/rtl.tsx
+++ b/docs/demo/rtl.tsx
@@ -1,6 +1,6 @@
-import '../../assets/style.less';
+import Segmented from '@rc-component/segmented';
import React, { useState } from 'react';
-import Segmented from 'rc-segmented';
+import '../../assets/style.less';
export default function App() {
const [direction, setDirection] = useState<'rtl' | 'ltr'>('rtl');
diff --git a/docs/index.md b/docs/index.md
index e718ed5..afdba56 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -1,6 +1,6 @@
---
hero:
- title: rc-segmented
+ title: '@rc-component/segmented'
description: React segmented controls used in ant.design
---
diff --git a/package.json b/package.json
index 688930d..fce0965 100644
--- a/package.json
+++ b/package.json
@@ -24,26 +24,27 @@
"homepage": "https://react-component.github.io/segmented",
"repository": {
"type": "git",
- "url": "git@github.com:react-component/segmented.git"
+ "url": "https://github.com/react-component/segmented.git"
},
"bugs": {
- "url": "http://github.com/react-component/segmented/issues"
+ "url": "https://github.com/react-component/segmented/issues"
},
"license": "MIT",
"scripts": {
"start": "dumi dev",
+ "build": "npm run compile && npm run docs:build",
+ "tsc": "tsc --noEmit",
"type:check": "tsc --noEmit",
"docs:build": "dumi build",
- "docs:deploy": "gh-pages -d .doc",
+ "docs:deploy": "gh-pages -d docs-dist",
"compile": "father build && lessc assets/index.less assets/index.css",
- "gh-pages": "GH_PAGES=1 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",
"prepublishOnly": "npm run compile && rc-np",
"lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md",
- "prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
- "pretty-quick": "pretty-quick",
+ "prettier": "prettier --write --ignore-unknown .",
"test": "jest",
"coverage": "jest --coverage",
- "prepare": "husky install"
+ "prepare": "husky"
},
"dependencies": {
"@babel/runtime": "^7.11.1",
@@ -53,30 +54,31 @@
},
"devDependencies": {
"@rc-component/father-plugin": "^2.2.0",
- "@rc-component/np": "^1.0.0",
+ "@rc-component/np": "^1.0.4",
"@testing-library/jest-dom": "^6.9.1",
- "@testing-library/react": "^14.2.1",
- "@testing-library/user-event": "^14.5.2",
- "@types/jest": "^29.2.4",
- "@types/node": "^24.5.2",
- "@types/react": "^18.3.11",
- "@types/react-dom": "^18.3.1",
- "@umijs/fabric": "^3.0.0",
- "@umijs/test": "^4.0.36",
- "dumi": "^2.1.2",
- "eslint": "^7.0.0",
- "father": "^4.1.1",
- "gh-pages": "^3.1.0",
- "husky": "^8.0.0",
- "jest": "^29.3.1",
- "jest-environment-jsdom": "^29.3.1",
- "less": "^3.10.3",
- "prettier": "^2.0.5",
- "pretty-quick": "^3.0.0",
- "react": "^18.0.0",
- "react-dom": "^18.0.0",
+ "@testing-library/react": "^15.0.7",
+ "@testing-library/user-event": "14.5.2",
+ "@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",
+ "@umijs/test": "^4.6.68",
+ "cross-env": "^10.1.0",
+ "dumi": "^2.4.35",
+ "eslint": "^8.57.1",
+ "father": "^4.6.23",
+ "gh-pages": "^6.3.0",
+ "husky": "^9.1.7",
+ "jest": "^29.7.0",
+ "jest-environment-jsdom": "^29.7.0",
+ "less": "^4.6.7",
+ "prettier": "^3.9.0",
+ "react": "^18.3.1",
+ "react-dom": "^18.3.1",
"ts-node": "^10.9.1",
- "typescript": "^5.3.0"
+ "typescript": "^5.9.3",
+ "lint-staged": "^16.4.0"
},
"peerDependencies": {
"react": ">=16.0.0",
@@ -90,5 +92,8 @@
},
"tnpm": {
"mode": "npm"
+ },
+ "lint-staged": {
+ "*": "prettier --write --ignore-unknown"
}
}
diff --git a/tsconfig.json b/tsconfig.json
index 1cbc5ac..9d43c37 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -4,7 +4,10 @@
"module": "ESNext",
"moduleResolution": "node",
"baseUrl": "./",
- "lib": ["dom", "es2017"],
+ "lib": [
+ "dom",
+ "es2017"
+ ],
"jsx": "react",
"strict": true,
"esModuleInterop": true,
@@ -12,12 +15,43 @@
"emitDecoratorMetadata": true,
"skipLibCheck": true,
"declaration": true,
- "types": ["jest", "node", "@testing-library/jest-dom"],
+ "types": [
+ "jest",
+ "node",
+ "@testing-library/jest-dom"
+ ],
"paths": {
- "@/*": ["src/*"],
- "@@/*": [".dumi/tmp/*"],
- "rc-segmented": ["src/index.tsx"]
- }
+ "@/*": [
+ "src/*"
+ ],
+ "@@/*": [
+ ".dumi/tmp/*"
+ ],
+ "@rc-component/segmented": [
+ "src/index.tsx"
+ ],
+ "@rc-component/segmented/es": [
+ "src"
+ ],
+ "@rc-component/segmented/es/*": [
+ "src/*"
+ ],
+ "@rc-component/segmented/assets/*": [
+ "assets/*"
+ ]
+ },
+ "ignoreDeprecations": "5.0"
},
- "include": [".dumi/**/*", ".dumirc.ts", "src", "tests", "docs/demo"]
+ "include": [
+ ".fatherrc.ts",
+ ".dumirc.ts",
+ "src",
+ "tests",
+ "docs/demo"
+ ],
+ "exclude": [
+ "docs-dist",
+ "lib",
+ "es"
+ ]
}
diff --git a/vercel.json b/vercel.json
new file mode 100644
index 0000000..5f9139e
--- /dev/null
+++ b/vercel.json
@@ -0,0 +1,6 @@
+{
+ "framework": "umijs",
+ "installCommand": "npm install",
+ "buildCommand": "npm run build",
+ "outputDirectory": "docs-dist"
+}