diff --git a/.dumirc.ts b/.dumirc.ts
index 81392343..f0dcfae4 100644
--- a/.dumirc.ts
+++ b/.dumirc.ts
@@ -1,7 +1,13 @@
import { defineConfig } from 'dumi';
import path from 'path';
+const basePath = process.env.GH_PAGES ? '/cascader/' : '/';
+const publicPath = basePath;
+
export default defineConfig({
+ outputPath: 'docs-dist',
+ base: basePath,
+ publicPath,
alias: {
'rc-cascader$': path.resolve('src'),
'rc-cascader/es': path.resolve('src'),
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/.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/dependabot.yml b/.github/dependabot.yml
index a5cb97ff..3b730ef9 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -1,37 +1,19 @@
version: 2
updates:
-- package-ecosystem: npm
- directory: "/"
- schedule:
- interval: daily
- time: "21:00"
- open-pull-requests-limit: 10
- ignore:
- - dependency-name: np
- versions:
- - 7.2.0
- - 7.3.0
- - 7.4.0
- - dependency-name: "@types/react"
- versions:
- - 17.0.0
- - 17.0.1
- - 17.0.2
- - 17.0.3
- - dependency-name: "@types/jest"
- versions:
- - 26.0.20
- - 26.0.21
- - 26.0.22
- - dependency-name: "@types/react-dom"
- versions:
- - 17.0.0
- - 17.0.1
- - 17.0.2
- - dependency-name: typescript
- versions:
- - 4.1.3
- - 4.1.4
- - 4.1.5
- - 4.2.2
- - 4.2.3
+ - package-ecosystem: npm
+ directory: '/'
+ schedule:
+ interval: weekly
+ day: monday
+ time: '21:00'
+ timezone: Asia/Shanghai
+ open-pull-requests-limit: 10
+
+ - package-ecosystem: github-actions
+ directory: '/'
+ schedule:
+ interval: weekly
+ day: monday
+ time: '21:00'
+ timezone: Asia/Shanghai
+ open-pull-requests-limit: 10
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
index 9947b182..65d90eac 100644
--- a/.github/workflows/codeql.yml
+++ b/.github/workflows/codeql.yml
@@ -24,18 +24,20 @@ jobs:
steps:
- name: Checkout
- uses: actions/checkout@v3
+ uses: actions/checkout@v7
+ 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 }}"
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 1fe5da5f..8d135ed5 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -1,6 +1,9 @@
name: ✅ test
on: [push, pull_request]
+permissions:
+ contents: read
jobs:
test:
- uses: react-component/rc-test/.github/workflows/test-npm.yml@main
- secrets: inherit
\ No newline at end of file
+ uses: react-component/rc-test/.github/workflows/test-utoo.yml@main
+ secrets:
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
\ No newline at end of file
diff --git a/.github/workflows/react-doctor.yml b/.github/workflows/react-doctor.yml
new file mode 100644
index 00000000..01760580
--- /dev/null
+++ b/.github/workflows/react-doctor.yml
@@ -0,0 +1,26 @@
+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 00000000..394f2b02
--- /dev/null
+++ b/.github/workflows/surge-preview.yml
@@ -0,0 +1,48 @@
+name: Surge Preview
+
+on:
+ pull_request:
+
+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
+ 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 2565182b..cbe08662 100644
--- a/.gitignore
+++ b/.gitignore
@@ -38,7 +38,8 @@ coverage
# dumi
.dumi/tmp
.dumi/tmp-production
+docs-dist
dist
.vscode
-bun.lockb
\ No newline at end of file
+bun.lockb
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/.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
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 b4663546..bd393a23 100644
--- a/README.md
+++ b/README.md
@@ -1,319 +1,166 @@
-# @rc-component/cascader
-
-React Cascader Component.
-
-[![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/cascader.svg?style=flat-square
-[npm-url]: https://npmjs.org/package/@rc-component/cascader
-[travis-image]: https://img.shields.io/travis/react-component/cascader/master?style=flat-square
-[travis-url]: https://travis-ci.com/react-component/cascader
-[github-actions-image]: https://github.com/react-component/cascader/actions/workflows/main.yml/badge.svg
-[github-actions-url]: https://github.com/react-component/cascader/actions/workflows/main.yml
-[codecov-image]: https://img.shields.io/codecov/c/github/react-component/cascader/master.svg?style=flat-square
-[codecov-url]: https://app.codecov.io/gh/react-component/cascader
-[david-url]: https://david-dm.org/react-component/cascader
-[david-image]: https://david-dm.org/react-component/cascader/status.svg?style=flat-square
-[david-dev-url]: https://david-dm.org/react-component/cascader?type=dev
-[david-dev-image]: https://david-dm.org/react-component/cascader/dev-status.svg?style=flat-square
-[download-image]: https://img.shields.io/npm/dm/@rc-component/cascader.svg?style=flat-square
-[download-url]: https://npmjs.org/package/@rc-component/cascader
-[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/cascader
-[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/@rc-component/cascader
-[dumi-url]: https://github.com/umijs/dumi
-[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square
-
-## Browser Support
-
-| [
](http://godban.github.io/browsers-support-badges/)
IE / Edge | [
](http://godban.github.io/browsers-support-badges/)
Firefox | [
](http://godban.github.io/browsers-support-badges/)
Chrome | [
](http://godban.github.io/browsers-support-badges/)
Safari | [
](http://godban.github.io/browsers-support-badges/)
Electron |
-| --- | --- | --- | --- | --- |
-| IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions |
-
-## Screenshots
-
-
-
-## Example
-
-https://cascader-react-component.vercel.app
+
Part of the Ant Design ecosystem.
🧭 React Cascader component for selecting values from hierarchical option trees, with search, multiple selection, async loading, and custom rendering.
+ + +English | 简体中文
+ + +## Highlights + +| Area | Support | +| --------- | ---------------------------------------------------------------- | +| Data | Nested options, field name mapping, disabled nodes | +| Selection | Single, multiple, checkable, and change-on-select flows | +| Search | Controlled search, custom filter, custom sort, custom render | +| Loading | Async option loading with `loadData` | +| Rendering | Custom option label, dropdown content, icons, and expand trigger | ## Install -[](https://npmjs.org/package/@rc-component/cascader) - ```bash -$ npm install @rc-component/cascader --save +npm install @rc-component/cascader ``` ## Usage -```js -import React from 'react'; +```tsx | pure import Cascader from '@rc-component/cascader'; -const options = [{ - 'label': '福建', - 'value': 'fj', - 'children': [{ - 'label': '福州', - 'value': 'fuzhou', - 'children': [{ - 'label': '马尾', - 'value': 'mawei', - }], - }, { - 'label': '泉州', - 'value': 'quanzhou', - }], -}, { - 'label': '浙江', - 'value': 'zj', - 'children': [{ - 'label': '杭州', - 'value': 'hangzhou', - 'children': [{ - 'label': '余杭', - 'value': 'yuhang', - }], - }], -}, { - 'label': '北京', - 'value': 'bj', - 'children': [{ - 'label': '朝阳区', - 'value': 'chaoyang', - }, { - 'label': '海淀区', - 'value': 'haidian', - }], -}]; - -React.render( +const options = [ + { + label: 'Zhejiang', + value: 'zhejiang', + children: [ + { + label: 'Hangzhou', + value: 'hangzhou', + children: [{ label: 'Xihu', value: 'xihu' }], + }, + ], + }, + { + label: 'Jiangsu', + value: 'jiangsu', + children: [{ label: 'Nanjing', value: 'nanjing' }], + }, +]; + +export default () => (| name | -type | -default | -description | -
|---|---|---|---|
| options | -Object | -- | The data options of cascade | -
| value | -Array | -- | selected value | -
| defaultValue | -Array | -- | initial selected value | -
| onChange | -Function(value, selectedOptions) | -- | callback when finishing cascader select | -
| changeOnSelect | -Boolean | -false | -change value on each selection | -
| loadData | -Function(selectedOptions) | -- | callback when click any option, use for loading more options | -
| expandTrigger | -String | -'click' | -expand current item when click or hover | -
| open | -Boolean | -- | visibility of popup overlay | -
| onPopupVisibleChange | -Function(visible) | -- | callback when popup overlay's visibility changed | -
| transitionName | -String | -- | transition className like "slide-up" | -
| prefixCls | -String | -rc-cascader | -prefix className of popup overlay | -
| popupClassName | -String | -- | additional className of popup overlay | -
| popupPlacement | -String | -bottomLeft | -use preset popup align config from builtinPlacements:bottomRight topRight bottomLeft topLeft | -
| getPopupContainer | -function(trigger:Node):Node | -() => document.body | -container which popup select menu rendered into | -
| dropdownMenuColumnStyle | -Object | -- | style object for each cascader pop menu | -
| fieldNames | -Object | -{ label: 'label', value: 'value', children: 'children' } | -custom field name for label and value and children | -
| expandIcon | -ReactNode | -> | -specific the default expand icon | -
| loadingIcon | -ReactNode | -> | -specific the default loading icon | -
| hidePopupOnSelect | -Boolean | ->true | -hide popup on select | -
| showSearch | -boolean | object | -false | -Whether show search input in single mode | -
| name | -type | -default | -description | -
|---|---|---|---|
| label | -String | -- | option text to display | -
| value | -String | -- | option value as react key | -
| disabled | -Boolean | -- | disabled option | -
| children | -Array | -- | children options | -
Ant Design 生态的一部分。
🧭 React 级联选择组件,支持层级选项、搜索、多选、异步加载和自定义渲染。
+ + +English | 简体中文
+ + +## 特性 + +| 范围 | 支持 | +| --------- | ---------------------------------------------------------------- | +| 数据 | 嵌套选项、字段名映射和禁用节点 | +| 选择 | 单选、多选、勾选和逐级选择流程 | +| 搜索 | 受控搜索、自定义过滤、自定义排序和自定义渲染 | +| 加载 | 通过 `loadData` 异步加载选项 | +| 渲染 | 自定义选项标签、下拉内容、图标和展开触发方式 | + +## 安装 + +```bash +npm install @rc-component/cascader +``` + +## 使用 + +```tsx | pure +import Cascader from '@rc-component/cascader'; + +const options = [ + { + label: 'Zhejiang', + value: 'zhejiang', + children: [ + { + label: 'Hangzhou', + value: 'hangzhou', + children: [{ label: 'Xihu', value: 'xihu' }], + }, + ], + }, + { + label: 'Jiangsu', + value: 'jiangsu', + children: [{ label: 'Nanjing', value: 'nanjing' }], + }, +]; + +export default () => ( +