diff --git a/.dumirc.ts b/.dumirc.ts
index deac20b5a..9f5e28324 100644
--- a/.dumirc.ts
+++ b/.dumirc.ts
@@ -1,10 +1,15 @@
import { defineConfig } from 'dumi';
+const basePath = process.env.GH_PAGES ? '/select/' : '/';
+const publicPath = basePath;
+
export default defineConfig({
favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'],
themeConfig: {
name: 'Select',
logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
},
- outputPath: '.doc',
+ outputPath: 'docs-dist',
+ base: basePath,
+ publicPath,
});
diff --git a/.fatherrc.ts b/.fatherrc.ts
new file mode 100644
index 000000000..96268ae1e
--- /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 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 2cbed3ee2..3b730ef99 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -3,29 +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
- ignore:
- - dependency-name: '@types/react'
- versions:
- - 17.0.0
- - 17.0.1
- - 17.0.2
- - 17.0.3
- - dependency-name: np
- versions:
- - 7.2.0
- - 7.3.0
- - 7.4.0
- - 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
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
index 8598a777c..a3d6e349f 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/react-doctor.yml b/.github/workflows/react-doctor.yml
new file mode 100644
index 000000000..29d6f76bd
--- /dev/null
+++ b/.github/workflows/react-doctor.yml
@@ -0,0 +1,22 @@
+name: React Doctor
+
+on:
+ pull_request:
+ push:
+ branches: [master]
+
+permissions:
+ contents: read
+ pull-requests: write
+ issues: write
+ statuses: write
+
+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 000000000..394f2b02e
--- /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/.github/workflows/test.yml b/.github/workflows/test.yml
index f860ff107..36dacae47 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -1,6 +1,9 @@
name: ✅ test
on: [push, pull_request]
+permissions:
+ contents: read
jobs:
test:
- uses: react-component/rc-test/.github/workflows/test.yml@main
- secrets: inherit
+ uses: react-component/rc-test/.github/workflows/test-utoo.yml@main
+ secrets:
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
diff --git a/.gitignore b/.gitignore
index 88a192abe..7cbbac945 100644
--- a/.gitignore
+++ b/.gitignore
@@ -41,4 +41,5 @@ tsconfig.test.json
.dumi/tmp
.dumi/tmp-test
.dumi/tmp-production
-.history
\ No newline at end of file
+docs-dist
+.history
diff --git a/.husky/pre-commit b/.husky/pre-commit
index d0a778429..2312dc587 100644
--- a/.husky/pre-commit
+++ b/.husky/pre-commit
@@ -1 +1 @@
-npx lint-staged
\ No newline at end of file
+npx lint-staged
diff --git a/.prettierignore b/.prettierignore
index 214377229..f6166fa09 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -9,3 +9,15 @@ package.json
.umi
.umi-production
.umi-test
+node_modules
+coverage
+docs-dist
+dist
+.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 000000000..bd0a1f722
--- /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 8c23dd44f..e48b94edc 100644
--- a/README.md
+++ b/README.md
@@ -1,195 +1,168 @@
-# @rc-component/select
-
----
-
-React Select 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/select.svg?style=flat-square
-[npm-url]: http://npmjs.org/package/@rc-component/select
-[github-actions-image]: https://github.com/react-component/select/actions/workflows/test.yml/badge.svg
-[github-actions-url]: https://github.com/react-component/select/actions/workflows/test.yml
-[codecov-image]: https://img.shields.io/codecov/c/github/react-component/select/master.svg?style=flat-square
-[codecov-url]: https://app.codecov.io/gh/react-component/select
-[david-url]: https://david-dm.org/react-component/select
-[david-image]: https://david-dm.org/react-component/select/status.svg?style=flat-square
-[david-dev-url]: https://david-dm.org/react-component/select?type=dev
-[david-dev-image]: https://david-dm.org/react-component/select/dev-status.svg?style=flat-square
-[download-image]: https://img.shields.io/npm/dm/@rc-component/select.svg?style=flat-square
-[download-url]: https://npmjs.org/package/@rc-component/select
-[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/select
-[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/@rc-component/select
-[dumi-url]: https://github.com/umijs/dumi
-[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square
-
-## Screenshots
-
-
-
-## Feature
-
-- support IE11+,Chrome,Firefox,Safari
-
-### Keyboard
-
-- Open select (focus input || focus and click)
-- KeyDown/KeyUp/Enter to navigate menu
-
-## install
-
-[](https://npmjs.org/package/@rc-component/select)
+
Part of the Ant Design ecosystem.
🎯 Composable Select component for React, with search, async-friendly option data, custom rendering, and virtual scrolling.
+ + +English | 简体中文
+ +## Highlights + +| Area | Support | +| --------- | ---------------------------------------------------------- | +| Data | `options` data, legacy `Option` children, grouped options | +| Modes | Single select, `multiple`, `tags`, and `combobox` | +| Search | Controlled search, custom filter, custom sort | +| Rendering | Custom option, label, selected item, clear, and menu icons | +| Scale | Virtual scrolling with configurable item height | + +## Install + +```bash +npm install @rc-component/select +``` ## Usage -### basic use - -```jsx | pure -import Select, { Option } from '@rc-component/select'; +```tsx | pure +import Select from '@rc-component/select'; import '@rc-component/select/assets/index.css'; export default () => ( - + ); ``` +## Examples + +Run the local dumi site: + +```bash +npm install +npm start +``` + +Then open `http://localhost:8000`. + ## API -### Select props +### Select - -| name | description | type | default | +Select also accepts public props from `BaseSelect`, except `showSearch`, which is redefined by Select. + +| Name | Description | Type | Default | | --- | --- | --- | --- | -| id | html id to set on the component wrapper | String | '' | -| className | additional css class of root dom node | String | '' | -| data-\* | html data attributes to set on the component wrapper | String | '' | -| prefixCls | prefix class | String | '' | -| animation | dropdown animation name. only support slide-up now | String | '' | -| transitionName | dropdown css animation name | String | '' | -| choiceTransitionName | css animation name for selected items at multiple mode | String | '' | -| dropdownMatchSelectWidth | whether dropdown's width is same with select | boolean | true | -| dropdownClassName | additional className applied to dropdown | String | - | -| dropdownStyle | additional style applied to dropdown | React.CSSProperties | {} | -| dropdownAlign | additional align applied to dropdown | [AlignType](https://github.com/react-component/trigger/blob/728d7e92394aa4b3214650f743fc47e1382dfa68/src/interface.ts#L25-L80) | {} | -| dropdownMenuStyle | additional style applied to dropdown menu | Object | React.CSSProperties | -| notFoundContent | specify content to show when no result matches. | ReactNode | 'Not Found' | -| tokenSeparators | separator used to tokenize on tag/multiple mode | `string[] \| ((input: string) => string[])` | | -| open | control select open | boolean | | -| defaultOpen | control select default open | boolean | | -| placeholder | select placeholder | React Node | | -| showSearch | whether show search input in single mode | boolean \| Object | true | -| allowClear | whether allowClear | boolean | { clearIcon?: ReactNode } | false | -| tags | when tagging is enabled the user can select from pre-existing options or create a new tag by picking the first choice, which is what the user has typed into the search box so far. | boolean | false | -| tagRender | render custom tags. | (props: CustomTagProps) => ReactNode | - | -| maxTagTextLength | max tag text length to show | number | - | -| maxTagCount | max tag count to show | number | - | -| maxTagPlaceholder | placeholder for omitted values | ReactNode/function(omittedValues) | - | -| combobox | enable combobox mode(can not set multiple at the same time) | boolean | false | -| multiple | whether multiple select | boolean | false | -| disabled | whether disabled select | boolean | false | -| optionLabelProp | render option value or option children as content of select | String: 'value'/'children' | 'value' | -| defaultValue | initial selected option(s) | String \| String[] | - | -| value | current selected option(s) | String \| String[] \| {key:String, label:React.Node} \| {key:String, label:React.Node}[] | - | -| labelInValue | whether to embed label in value, see above value type. Not support `combobox` mode | boolean | false | -| backfill | whether backfill select option to search input (Only works in single and combobox mode) | boolean | false | -| onChange | called when select an option or input value change(combobox) | function(value, option:Option \| Option[]) | - | -| onBlur | called when blur | function | - | -| onFocus | called when focus | function | - | -| onPopupScroll | called when menu is scrolled | function | - | -| onSelect | called when a option is selected. param is option's value and option instance | Function(value, option:Option) | - | -| onDeselect | called when a option is deselected. param is option's value. only called for multiple or tags | Function(value, option:Option) | - | -| onInputKeyDown | called when key down on input | Function(event) | - | -| defaultActiveFirstOption | whether active first option by default | boolean | true | -| getPopupContainer | container which popup select menu rendered into | function(trigger:Node):Node | function(){return document.body;} | -| getInputElement | customize input element | function(): Element | - | -| showAction | actions trigger the dropdown to show | String[]? | - | -| autoFocus | focus select after mount | boolean | - | -| prefix | specify the select prefix icon or text | ReactNode | - | -| suffixIcon | specify the select arrow icon | ReactNode | - | -| clearIcon | specify the clear icon | ReactNode | - | -| removeIcon | specify the remove icon | ReactNode | - | -| menuItemSelectedIcon | specify the item selected icon | ReactNode \| (props: MenuItemProps) => ReactNode | - | -| dropdownRender | render custom dropdown menu | (menu: React.Node) => ReactNode | - | -| loading | show loading icon in arrow | boolean | false | -| virtual | Disable virtual scroll | boolean | true | -| direction | direction of dropdown | 'ltr' \| 'rtl' | 'ltr' | -| optionRender | Custom rendering options | (oriOption: FlattenOptionData\ Ant Design 生态的一部分。
🎯 React 选择器组件,支持单选、多选、搜索、标签和自定义渲染。
+ + +English | 简体中文
+ +## 特性 + +| 范围 | 支持 | +| ---- | -------------------------------------------- | +| 数据 | `options` 数据,旧版 `Option` 子项,分组选项 | +| 模式 | 单选、`multiple`、`tags` 和 `combobox` 模式 | +| 搜索 | 受控搜索、自定义过滤和自定义排序 | +| 渲染 | 自定义选项、标签、选中项、清除图标和菜单图标 | +| 规模 | 支持可配置项高度的虚拟滚动 | + +## 安装 + +```bash +npm install @rc-component/select +``` + +## 使用 + +```tsx | pure +import Select from '@rc-component/select'; +import '@rc-component/select/assets/index.css'; + +export default () => ( + +); +``` + +## 示例 + +运行本地 dumi 站点: + +```bash +npm install +npm start +``` + +然后打开 `http://localhost:8000`。 + +## API + +### Select + +Select 还接受来自 `BaseSelect` 的公共属性,但由 Select 重新定义的 `showSearch` 除外。 + +| 名称 | 说明 | 类型 | 默认值 | +| --- | --- | --- | --- | +| autoClearSearchValue | 已弃用。请改用 `showSearch.autoClearSearchValue`。 | boolean | true | +| backfill | 将活动选项回填到输入中。仅适用于 `combobox` 模式。 | boolean | false | +| children | 旧版选项子节点。新代码推荐使用 `options`。 | ReactNode | - | +| classNames | 语义 className。 | `Partial