Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump @rc-component deps #631

Merged
merged 8 commits into from
Feb 25, 2025
Merged
Changes from all commits
Commits
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
104 changes: 52 additions & 52 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/select.less
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@import '~rc-select/assets/index';
@import '~@rc-component/select/assets/index';

@select-prefix: ~'rc-tree-select';
12 changes: 6 additions & 6 deletions examples/basic.tsx
Original file line number Diff line number Diff line change
@@ -124,7 +124,7 @@ class Demo extends React.Component {
console.log(args);
};

onDropdownVisibleChange = visible => {
onPopupVisibleChange = visible => {
const { value } = this.state;
console.log(visible, value);
if (Array.isArray(value) && value.length > 1 && value.length < 3) {
@@ -205,8 +205,8 @@ class Demo extends React.Component {
console.log('onChange', val, ...args);
this.setState({ value: val });
}}
onDropdownVisibleChange={v => {
console.log('single onDropdownVisibleChange', v);
onPopupVisibleChange={v => {
console.log('single onPopupVisibleChange', v);
this.setState({
tsOpen: v,
});
@@ -259,11 +259,11 @@ class Demo extends React.Component {
choiceTransitionName="rc-tree-select-selection__choice-zoom"
style={{ width: 300 }}
// dropdownStyle={{ height: 200, overflow: 'auto' }}
dropdownAlign={{
popupAlign={{
overflow: { adjustY: 0, adjustX: 0 },
offset: [0, 2],
}}
onDropdownVisibleChange={this.onDropdownVisibleChange}
onPopupVisibleChange={this.onPopupVisibleChange}
placeholder={<i>请下拉选择</i>}
treeLine
maxTagTextLength={10}
@@ -327,7 +327,7 @@ class Demo extends React.Component {
<h2>Testing in extreme conditions (Boundary conditions test) </h2>
<TreeSelect
style={{ width: 200 }}
dropdownStyle={{ maxHeight: 200, overflow: 'auto' }}
popupStyle={{ maxHeight: 200, overflow: 'auto' }}
defaultValue="leaf1"
multiple
treeCheckable
4 changes: 2 additions & 2 deletions examples/custom-icons.tsx
Original file line number Diff line number Diff line change
@@ -86,7 +86,7 @@ function Demo() {
placeholder={<span>Please Select</span>}
transitionName="rc-tree-select-dropdown-slide-up"
style={{ width: 300 }}
dropdownStyle={{ maxHeight: 200, overflow: 'auto', zIndex: 1500 }}
popupStyle={{ maxHeight: 200, overflow: 'auto', zIndex: 1500 }}
showSearch
allowClear
{...iconProps}
@@ -99,7 +99,7 @@ function Demo() {
placeholder={<span>Please Select</span>}
transitionName="rc-tree-select-dropdown-slide-up"
style={{ width: 300 }}
dropdownStyle={{ maxHeight: 200, overflow: 'auto', zIndex: 1500 }}
popupStyle={{ maxHeight: 200, overflow: 'auto', zIndex: 1500 }}
showSearch
allowClear
{...iconPropsFunction}
2 changes: 1 addition & 1 deletion examples/filter.tsx
Original file line number Diff line number Diff line change
@@ -82,7 +82,7 @@ class Demo extends React.Component {
<h2>use treeDataSimpleMode</h2>
<TreeSelect
style={{ width: 300 }}
dropdownStyle={{ maxHeight: 200, overflow: 'auto' }}
popupStyle={{ maxHeight: 200, overflow: 'auto' }}
placeholder={<i>请下拉选择</i>}
treeLine
maxTagTextLength={10}
4 changes: 2 additions & 2 deletions examples/form.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { Component } from 'react';
import Select from 'rc-select';
import Select from '@rc-component/select';
import Form, { useForm, Field } from 'rc-field-form';
import TreeSelect from '../src';
import 'rc-select/assets/index.less';
import '@rc-component/select/assets/index.less';
import '../assets/index.less';
import { gData } from './utils/dataUtil';

2 changes: 1 addition & 1 deletion examples/width.tsx
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import TreeSelect, { TreeNode } from '../src';

function Demo() {
return (
<TreeSelect style={{ width: 120 }} dropdownMatchSelectWidth={false} treeDefaultExpandAll>
<TreeSelect style={{ width: 120 }} popupMatchSelectWidth={false} treeDefaultExpandAll>
<TreeNode value="parent 1" title="parent 1">
<TreeNode value="parent 1-0 sdfsdfsdsdfsd" title="parent 1-0 sdfsdfsd">
<TreeNode value="leaf1 sdfsdf" title="leaf1" />
11 changes: 0 additions & 11 deletions now.json

This file was deleted.

19 changes: 9 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rc-tree-select",
"version": "5.27.0",
"name": "@rc-component/tree-select",
"version": "1.0.0",
"description": "tree-select ui component for react",
"keywords": [
"react",
@@ -35,7 +35,7 @@
"lint": "eslint src/ examples/ --ext .tsx,.ts,.jsx,.js",
"now-build": "npm run build",
"prepare": "husky && dumi setup",
"prepublishOnly": "npm run compile && np --yolo --no-publish --any-branch",
"prepublishOnly": "npm run compile && rc-np",
"prettier": "prettier '{src,tests}/**/*.{ts,tsx}' 'tests/**/*.js' --write",
"start": "dumi dev",
"test": "rc-test"
@@ -44,15 +44,15 @@
"*": "prettier --write --ignore-unknown"
},
"dependencies": {
"@babel/runtime": "^7.25.7",
"classnames": "2.x",
"rc-select": "~14.16.2",
"rc-tree": "~5.13.0",
"rc-util": "^5.43.0"
"@rc-component/select": "~1.0.0",
"rc-tree": "~5.13.1",
"@rc-component/util": "^1.2.1"
},
"devDependencies": {
"@rc-component/father-plugin": "^1.1.0",
"@rc-component/trigger": "^1.18.3",
"@rc-component/father-plugin": "^2.0.2",
"@rc-component/np": "^1.0.3",
"@rc-component/trigger": "^3.0.0",
"@testing-library/react": "^12.1.5",
"@types/jest": "^29.5.13",
"@types/node": "^22.7.5",
@@ -73,7 +73,6 @@
"glob": "^11.0.0",
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
"np": "^10.0.7",
"prettier": "^3.3.3",
"rc-dialog": "^9.6.0",
"rc-field-form": "^2.4.0",
16 changes: 9 additions & 7 deletions src/OptionList.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { useBaseProps } from 'rc-select';
import type { RefOptionListProps } from 'rc-select/lib/OptionList';
import { useBaseProps } from '@rc-component/select';
import type { RefOptionListProps } from '@rc-component/select/lib/OptionList';
import type { TreeProps } from 'rc-tree';
import Tree from 'rc-tree';
import { UnstableContext } from 'rc-tree';
import type { EventDataNode, ScrollTo } from 'rc-tree/lib/interface';
import KeyCode from 'rc-util/lib/KeyCode';
import useMemo from 'rc-util/lib/hooks/useMemo';
import KeyCode from '@rc-component/util/lib/KeyCode';
import useMemo from '@rc-component/util/lib/hooks/useMemo';
import * as React from 'react';
import LegacyContext from './LegacyContext';
import TreeSelectContext from './TreeSelectContext';
import type { DataNode, Key, SafeKey } from './interface';
import { getAllKeys, isCheckDisabled } from './utils/valueUtil';
import { useEvent } from 'rc-util';
import { useEvent } from '@rc-component/util';

const HIDDEN_STYLE = {
width: 0,
@@ -43,7 +43,7 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,
treeData,
fieldNames,
onSelect,
dropdownMatchSelectWidth,
popupMatchSelectWidth,
treeExpandAction,
treeTitleRender,
onPopupScroll,
@@ -263,6 +263,7 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,
}

setActiveKey(nextActiveKey);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [open, searchValue]);

// ========================= Keyboard =========================
@@ -305,6 +306,7 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,

const hasLoadDataFn = useMemo(
() => (searchValue ? false : true),
// eslint-disable-next-line react-hooks/exhaustive-deps
[searchValue, treeExpandedKeys || expandedKeys],
([preSearchValue], [nextSearchValue, nextExcludeSearchExpandedKeys]) =>
preSearchValue !== nextSearchValue && !!(nextSearchValue || nextExcludeSearchExpandedKeys),
@@ -347,7 +349,7 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,
height={listHeight}
itemHeight={listItemHeight}
itemScrollOffset={listItemScrollOffset}
virtual={virtual !== false && dropdownMatchSelectWidth !== false}
virtual={virtual !== false && popupMatchSelectWidth !== false}
multiple={multiple}
icon={treeIcon}
showIcon={showTreeIcon}
40 changes: 15 additions & 25 deletions src/TreeSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type { BaseSelectPropsWithoutPrivate, BaseSelectRef } from 'rc-select';
import { BaseSelect } from 'rc-select';
import useId from 'rc-select/lib/hooks/useId';
import type { BaseSelectPropsWithoutPrivate, BaseSelectRef } from '@rc-component/select';
import { BaseSelect } from '@rc-component/select';
import useId from '@rc-component/select/lib/hooks/useId';
import type { IconType } from 'rc-tree/lib/interface';
import type { ExpandAction } from 'rc-tree/lib/Tree';
import { conductCheck } from 'rc-tree/lib/utils/conductUtil';
import useMergedState from 'rc-util/lib/hooks/useMergedState';
import warning from 'rc-util/lib/warning';
import useMergedState from '@rc-component/util/lib/hooks/useMergedState';
import * as React from 'react';
import useCache from './hooks/useCache';
import useCheckedKeys from './hooks/useCheckedKeys';
@@ -93,7 +92,7 @@
listHeight?: number;
listItemHeight?: number;
listItemScrollOffset?: number;
onDropdownVisibleChange?: (open: boolean) => void;
onPopupVisibleChange?: (open: boolean) => void;
treeTitleRender?: (node: OptionType) => React.ReactNode;

// >>> Tree
@@ -163,8 +162,8 @@
listItemHeight = 20,
listItemScrollOffset = 0,

onDropdownVisibleChange,
dropdownMatchSelectWidth = true,
onPopupVisibleChange,
popupMatchSelectWidth = true,

// Tree
treeLine,
@@ -582,22 +581,13 @@
);

// ========================== Dropdown ==========================
const onInternalDropdownVisibleChange = React.useCallback(
const onInternalPopupVisibleChange = React.useCallback(
(open: boolean) => {
if (onDropdownVisibleChange) {
const legacyParam = {};

Object.defineProperty(legacyParam, 'documentClickClose', {
get() {
warning(false, 'Second param of `onDropdownVisibleChange` has been removed.');
return false;
},
});

(onDropdownVisibleChange as any)(open, legacyParam);
if (onPopupVisibleChange) {
onPopupVisibleChange(open);

Check warning on line 587 in src/TreeSelect.tsx

Codecov / codecov/patch

src/TreeSelect.tsx#L587

Added line #L587 was not covered by tests
}
},
[onDropdownVisibleChange],
[onPopupVisibleChange],
);

// ====================== Display Change ========================
@@ -619,7 +609,7 @@
const treeSelectContext = React.useMemo<TreeSelectContextProps>(() => {
return {
virtual,
dropdownMatchSelectWidth,
popupMatchSelectWidth,
listHeight,
listItemHeight,
listItemScrollOffset,
@@ -636,7 +626,7 @@
};
}, [
virtual,
dropdownMatchSelectWidth,
popupMatchSelectWidth,
listHeight,
listItemHeight,
listItemScrollOffset,
@@ -716,8 +706,8 @@
// >>> Options
OptionList={OptionList}
emptyOptions={!mergedTreeData.length}
onDropdownVisibleChange={onInternalDropdownVisibleChange}
dropdownMatchSelectWidth={dropdownMatchSelectWidth}
onPopupVisibleChange={onInternalPopupVisibleChange}
popupMatchSelectWidth={popupMatchSelectWidth}
/>
</LegacyContext.Provider>
</TreeSelectContext.Provider>
2 changes: 1 addition & 1 deletion src/TreeSelectContext.ts
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import type useDataEntities from './hooks/useDataEntities';

export interface TreeSelectContextProps {
virtual?: boolean;
dropdownMatchSelectWidth?: boolean | number;
popupMatchSelectWidth?: boolean | number;
listHeight: number;
listItemHeight: number;
listItemScrollOffset?: number;
2 changes: 1 addition & 1 deletion src/hooks/useDataEntities.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
import { convertDataToEntities } from 'rc-tree/lib/utils/treeUtil';
import type { DataEntity } from 'rc-tree/lib/interface';
import type { SafeKey, FieldNames } from '../interface';
import warning from 'rc-util/lib/warning';
import warning from '@rc-component/util/lib/warning';
import { isNil } from '../utils/valueUtil';

export default (treeData: any, fieldNames: FieldNames) =>
4 changes: 2 additions & 2 deletions src/utils/legacyUtil.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import toArray from 'rc-util/lib/Children/toArray';
import warning from 'rc-util/lib/warning';
import toArray from '@rc-component/util/lib/Children/toArray';
import warning from '@rc-component/util/lib/warning';
import type {
DataNode,
ChangeEventExtra,
2 changes: 1 addition & 1 deletion src/utils/warningPropsUtil.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import warning from 'rc-util/lib/warning';
import warning from '@rc-component/util/lib/warning';
import type { TreeSelectProps } from '../TreeSelect';
import { toArray } from './valueUtil';

2 changes: 1 addition & 1 deletion tests/Select.SearchInput.spec.js
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import React, { useState } from 'react';
import { mount } from 'enzyme';
import { render, fireEvent } from '@testing-library/react';
import TreeSelect, { TreeNode } from '../src';
import KeyCode from 'rc-util/lib/KeyCode';
import KeyCode from '@rc-component/util/lib/KeyCode';

describe('TreeSelect.SearchInput', () => {
it('select item will clean searchInput', () => {
6 changes: 3 additions & 3 deletions tests/Select.maxCount.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { render, fireEvent, within } from '@testing-library/react';
import KeyCode from 'rc-util/lib/KeyCode';
import KeyCode from '@rc-component/util/lib/KeyCode';
import { keyDown, keyUp } from './util';
import React from 'react';
import TreeSelect from '../src';
@@ -104,7 +104,7 @@ describe('TreeSelect.maxCount', () => {
});

it('should respect maxCount when checking parent node in treeCheckable mode', () => {
const treeData = [
const data = [
{
key: '0',
value: '0',
@@ -120,7 +120,7 @@ describe('TreeSelect.maxCount', () => {
const handleChange = jest.fn();
const { container } = render(
<TreeSelect
treeData={treeData}
treeData={data}
treeCheckable
multiple
maxCount={2}
2 changes: 1 addition & 1 deletion tests/Select.multiple.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-undef */
import { render, fireEvent, within } from '@testing-library/react';
import { mount } from 'enzyme';
import KeyCode from 'rc-util/lib/KeyCode';
import KeyCode from '@rc-component/util/lib/KeyCode';
import React from 'react';
import TreeSelect, { TreeNode } from '../src';
import focusTest from './shared/focusTest';
Loading