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/.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/workflows/codeql.yml b/.github/workflows/codeql.yml
index 8598a777c..585a5e837 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@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 }}'
diff --git a/.github/workflows/react-doctor.yml b/.github/workflows/react-doctor.yml
new file mode 100644
index 000000000..07884617c
--- /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@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..50782cc0a
--- /dev/null
+++ b/.github/workflows/surge-preview.yml
@@ -0,0 +1,45 @@
+name: Surge Preview
+
+on:
+ pull_request:
+
+permissions:
+ contents: read
+ pull-requests: write
+ checks: write
+
+jobs:
+ preview:
+ runs-on: ubuntu-latest
+ steps:
+ - 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: ${{ 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..f8482b632 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -2,5 +2,5 @@ name: ✅ test
on: [push, pull_request]
jobs:
test:
- uses: react-component/rc-test/.github/workflows/test.yml@main
+ uses: react-component/rc-test/.github/workflows/test-utoo.yml@main
secrets: inherit
diff --git a/README.md b/README.md
index 8c23dd44f..4ea5aeea3 100644
--- a/README.md
+++ b/README.md
@@ -1,195 +1,167 @@
-# @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 () => ( - + ); ``` -## API +## Examples -### Select props +Run the local dumi site: - -| 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` 子项,分组选项 | +| Modes | 单选、`multiple`、`tags` 和 `combobox` 模式 | +| 搜索 | 受控搜索、自定义过滤和自定义排序 | +| Rendering | 自定义选项、标签、选中项、清除图标和菜单图标 | +| Scale | 支持可配置项高度的虚拟滚动 | + +## 安装 + +```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