Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
22f29ec
chore: update maintenance dependencies
afc163 Jun 29, 2026
26d3e8e
fix: align TypeScript and ESLint compatibility
afc163 Jun 30, 2026
d0b16cc
chore: use testing-library dom events
afc163 Jun 30, 2026
5f5786a
test: keep react testing event behavior
afc163 Jun 30, 2026
2bc3527
chore: address review comments
afc163 Jun 30, 2026
bc8c10a
fix: keep compatible eslint export rule
afc163 Jun 30, 2026
95dcb86
chore: address review suggestion
afc163 Jun 30, 2026
1dada04
chore: preserve local eslint rule overrides
afc163 Jul 1, 2026
86f3ad8
Merge remote-tracking branch 'origin/master' into codex/update-mainte…
afc163 Jul 1, 2026
6b7805d
chore: remove react type compatibility shim
afc163 Jul 1, 2026
bcda87e
docs: use ut install for local setup
afc163 Jul 1, 2026
99ae61f
chore: restore vercel install command
afc163 Jul 1, 2026
ff1ee1b
chore: align maintenance dependencies
afc163 Jul 1, 2026
ea11748
chore: fix upgraded test tooling
afc163 Jul 1, 2026
3c21a6c
fix: preserve React peer dependency range
afc163 Jul 1, 2026
3c898ad
docs: use npm install in README
afc163 Jul 1, 2026
ec51695
chore: remove redundant strict tsconfig flags
afc163 Jul 1, 2026
30f21bd
chore: remove manual global test declarations
afc163 Jul 1, 2026
43a1b5e
fix: address review type compatibility
afc163 Jul 1, 2026
c9818b5
chore: simplify eslint flat config
afc163 Jul 2, 2026
5a201f4
chore: inline eslint rule filtering
afc163 Jul 2, 2026
930593b
fix: avoid new react doctor warning
afc163 Jul 2, 2026
e244b02
chore: migrate to eslint flat config
afc163 Jul 2, 2026
393f3ec
fix: support typed eslint checks in flat config
afc163 Jul 2, 2026
48b5e30
chore: migrate to native eslint flat config
afc163 Jul 2, 2026
04bd7b7
chore: address review comments
afc163 Jul 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .eslintrc.js

This file was deleted.

8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ updates:
time: '21:00'
timezone: Asia/Shanghai
open-pull-requests-limit: 10
groups:
npm-dependencies:
patterns:
- '*'

- package-ecosystem: github-actions
directory: '/'
Expand All @@ -17,3 +21,7 @@ updates:
time: '21:00'
timezone: Asia/Shanghai
open-pull-requests-limit: 10
groups:
github-actions:
patterns:
- '*'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div align="center">
<h1>@rc-component/select</h1>
<p><sub><img alt="Ant Design" height="14" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style="vertical-align: -0.125em;" /> Part of the Ant Design ecosystem.</sub></p>
<p><sub><a href="https://ant.design"><img alt="Ant Design" height="14" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style="vertical-align: -0.125em;" /></a> Part of the Ant Design ecosystem.</sub></p>
<p>🎯 Composable Select component for React, with search, async-friendly option data, custom rendering, and virtual scrolling.</p>

<p>
Expand Down
2 changes: 1 addition & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div align="center">
<h1>@rc-component/select</h1>
<p><sub><img alt="Ant Design" height="14" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style="vertical-align: -0.125em;" /> Ant Design 生态的一部分。</sub></p>
<p><sub><a href="https://ant.design"><img alt="Ant Design" height="14" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style="vertical-align: -0.125em;" /></a> Ant Design 生态的一部分。</sub></p>
<p>🎯 React 选择器组件,支持单选、多选、搜索、标签和自定义渲染。</p>

<p>
Expand Down
115 changes: 115 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import js from '@eslint/js';
import { defineConfig } from 'eslint/config';
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import prettier from 'eslint-config-prettier';
import jest from 'eslint-plugin-jest';
import react from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import globals from 'globals';
import tseslint from 'typescript-eslint';

const tsconfigRootDir = dirname(fileURLToPath(import.meta.url));

export default defineConfig([
{
plugins: {
'@typescript-eslint': tseslint.plugin,
},
},
{
linterOptions: {
reportUnusedDisableDirectives: 'warn',
},
},
{
ignores: [
'node_modules/',
'coverage/',
'es/',
'lib/',
'dist/',
'docs-dist/',
'.docs-dist/',
'.dumi/',
'.doc/',
'.vercel/',
],
},
{
files: ['**/*.{js,jsx,ts,tsx}'],
extends: [
js.configs.recommended,
react.configs.flat.recommended,
react.configs.flat['jsx-runtime'],
prettier,
],
plugins: {
'react-hooks': reactHooks,
},
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
},
settings: {
react: {
version: 'detect',
},
},
rules: {
'no-async-promise-executor': 'off',
'no-empty-pattern': 'off',
'no-irregular-whitespace': 'off',
'no-prototype-builtins': 'off',
'no-useless-escape': 'off',
'no-extra-boolean-cast': 'off',
'no-undef': 'off',
'no-unused-vars': 'off',
'react/no-find-dom-node': 'off',
'react/display-name': 'off',
'react/no-unknown-property': 'off',
'react/prop-types': 'off',
'react-hooks/exhaustive-deps': 'warn',
'react-hooks/rules-of-hooks': 'error',
},
},
{
files: ['**/*.{ts,tsx}'],
extends: [...tseslint.configs.recommended],
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'@typescript-eslint/no-unnecessary-type-constraint': 'off',
'@typescript-eslint/no-unused-vars': 'off',
},
},
{
files: ['src/**/*.{ts,tsx}'],
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir,
},
},
},
{
files: ['tests/**/*.{js,jsx,ts,tsx}', '**/*.{test,spec}.{js,jsx,ts,tsx}'],
extends: [jest.configs['flat/recommended']],
rules: {
'jest/no-disabled-tests': 'off',
'jest/no-done-callback': 'off',
'jest/no-identical-title': 'off',
'jest/expect-expect': 'off',
'jest/no-alias-methods': 'off',
'jest/no-conditional-expect': 'off',
'jest/no-export': 'off',
'jest/no-standalone-expect': 'off',
'jest/valid-expect': 'off',
'jest/valid-title': 'off',
},
},
]);
11 changes: 11 additions & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// <reference types="jest" />
/// <reference types="node" />
/// <reference types="react" />
/// <reference types="react-dom" />
/// <reference types="@testing-library/jest-dom" />

declare module '*.css';
declare module '*.less';
declare module 'jsonp';

declare module 'moment/locale/zh-cn';
35 changes: 21 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,30 +55,37 @@
"clsx": "^2.1.1"
},
"devDependencies": {
"@eslint/js": "^9.39.4",
"@rc-component/dialog": "^1.10.0",
"@rc-component/father-plugin": "^2.2.0",
"@rc-component/np": "^1.0.4",
"@testing-library/dom": "^10.4.1",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^15.0.7",
"@types/jest": "^29.5.14",
"@testing-library/react": "^16.3.2",
"@types/jest": "^30.0.0",
"@types/node": "^26.0.1",
"@types/react": "^18.3.31",
"@types/react-dom": "^18.3.7",
"@umijs/fabric": "^4.0.1",
"babel-jest": "^29.7.0",
"dumi": "^2.4.35",
"eslint": "^8.57.1",
"father": "^4.6.23",
"@types/react": "^19.2.17",
"@types/react-dom": "^19.2.3",
"babel-jest": "^30.4.1",
"dumi": "^2.4.38",
"eslint": "^9.39.4",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-jest": "^29.15.4",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^7.1.1",
"father": "^4.6.24",
"globals": "^17.7.0",
"husky": "^9.1.7",
"jsonp": "^0.2.1",
"less": "^4.6.7",
"lint-staged": "^16.4.0",
"prettier": "^3.9.0",
"lint-staged": "^17.0.8",
"prettier": "^3.9.4",
"querystring": "^0.2.1",
"rc-test": "^7.1.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"typescript": "^5.9.3"
"react": "^19.2.7",
"react-dom": "^19.2.7",
"typescript": "^6.0.3",
"typescript-eslint": "^8.62.1"
},
"publishConfig": {
"access": "public"
Expand Down
4 changes: 2 additions & 2 deletions src/BaseSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ export interface BaseSelectProps

// >>> Customize Input
/** @private Internal usage. Do not use in your production. */
getInputElement?: () => JSX.Element;
getInputElement?: () => React.ReactElement;
/** @private Internal usage. Do not use in your production. */
getRawInputElement?: () => JSX.Element;
getRawInputElement?: () => React.ReactElement;

// >>> Selector
maxTagTextLength?: number;
Expand Down
2 changes: 1 addition & 1 deletion src/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
const mergedDefaultActiveFirstOption =
defaultActiveFirstOption !== undefined ? defaultActiveFirstOption : mode !== 'combobox';

const activeEventRef = React.useRef<Promise<void>>();
const activeEventRef = React.useRef<Promise<void> | undefined>(undefined);

const onActiveValue: OnActiveValue = React.useCallback(
(active, index, { source = 'keyboard' } = {}) => {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useRefFunc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as React from 'react';
* but redirect to real function.
*/
export default function useRefFunc<T extends (...args: any[]) => any>(callback: T): T {
const funcRef = React.useRef<T>();
const funcRef = React.useRef<T>(callback);
funcRef.current = callback;

const cacheFn = React.useCallback((...args: any[]) => {
Expand Down
8 changes: 4 additions & 4 deletions src/utils/legacyUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { toArray } from '@rc-component/util';
import type { BaseOptionType, DefaultOptionType } from '../Select';

function convertNodeToOption<OptionType extends BaseOptionType = DefaultOptionType>(
node: React.ReactElement,
node: React.ReactElement<any>,
): OptionType {
const {
key,
props: { children, value, ...restProps },
} = node as React.ReactElement;
} = node;

return { key, value: value !== undefined ? value : key, children, ...restProps };
}
Expand All @@ -18,7 +18,7 @@ export function convertChildrenToData<OptionType extends BaseOptionType = Defaul
optionOnly: boolean = false,
): OptionType[] {
return toArray(nodes)
.map((node: React.ReactElement, index: number): OptionType | null => {
.map((node: React.ReactElement<any>, index: number): OptionType | null => {
if (!React.isValidElement(node) || !node.type) {
return null;
}
Expand All @@ -27,7 +27,7 @@ export function convertChildrenToData<OptionType extends BaseOptionType = Defaul
type: { isSelectOptGroup },
key,
props: { children, ...restProps },
} = node as React.ReactElement & { type: { isSelectOptGroup?: boolean } };
} = node as React.ReactElement<any> & { type: { isSelectOptGroup?: boolean } };

if (optionOnly || !isSelectOptGroup) {
return convertNodeToOption(node);
Expand Down
26 changes: 13 additions & 13 deletions src/utils/warningPropsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,19 @@ function warningProps(props: SelectProps) {
return false;
}
if (type.isSelectOptGroup) {
const allChildrenValid = toNodeArray(node.props.children).every(
(subNode: React.ReactElement) => {
if (
!React.isValidElement(subNode) ||
!node.type ||
(subNode.type as { isSelectOption?: boolean }).isSelectOption
) {
return true;
}
invalidateChildType = subNode.type;
return false;
},
);
const allChildrenValid = toNodeArray(
(node as React.ReactElement<any>).props.children,
).every((subNode: React.ReactElement) => {
if (
!React.isValidElement(subNode) ||
!node.type ||
(subNode.type as { isSelectOption?: boolean }).isSelectOption
) {
return true;
}
invalidateChildType = subNode.type;
return false;
});

if (allChildrenValid) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshots__/Combobox.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`Select.Combobox renders controlled correctly 1`] = `
<div
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshots__/Multiple.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`Select.Multiple max tag render truncates values by maxTagTextLength 1`] = `
[
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshots__/OptionList.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`OptionList renders correctly virtual 1`] = `
<div>
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshots__/Select.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`Select.Basic does not filter when filterOption value is false 1`] = `
<div
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshots__/Tags.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`Select.Tags OptGroup renders correctly 1`] = `
<div>
Expand Down
4 changes: 2 additions & 2 deletions tests/__snapshots__/ssr.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`Select.SSR should work 1`] = `"<div class="rc-select rc-select-single"><div class="rc-select-content"><div class="rc-select-placeholder"></div><input id="test-id" type="text" readonly="" autoComplete="new-password" class="rc-select-input" role="combobox" aria-expanded="false" aria-haspopup="listbox" aria-autocomplete="list" value=""/></div></div>"`;
exports[`Select.SSR should work 1`] = `"<div class="rc-select rc-select-single"><div class="rc-select-content"><div class="rc-select-placeholder"></div><input id="test-id" type="text" readOnly="" autoComplete="new-password" class="rc-select-input" role="combobox" aria-expanded="false" aria-haspopup="listbox" aria-autocomplete="list" value=""/></div></div>"`;
14 changes: 7 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"compilerOptions": {
"target": "esnext",
"moduleResolution": "node",
"baseUrl": "./",
"moduleResolution": "bundler",
"jsx": "preserve",
"declaration": true,
"skipLibCheck": true,
"esModuleInterop": true,
"paths": {
"@/*": ["src/*"],
"@@/*": [".dumi/tmp/*"],
"@rc-component/select": ["src/index.ts"]
"@/*": ["./src/*"],
"@@/*": ["./.dumi/tmp/*"],
"@rc-component/select": ["./src/index.ts"]
},
"ignoreDeprecations": "5.0"
"strict": false,
Comment thread
coderabbitai[bot] marked this conversation as resolved.
"module": "ESNext"
},
"include": [".dumirc.ts", ".fatherrc.ts", "src", "tests", "docs"]
"include": ["global.d.ts", ".dumirc.ts", ".fatherrc.ts", "src", "tests", "docs"]
}
Loading