@rc-component/tree-select 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/TreeSelect.js +4 -8
- package/lib/TreeSelect.js +4 -8
- package/package.json +2 -2
package/es/TreeSelect.js
CHANGED
|
@@ -2,7 +2,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
2
2
|
import { BaseSelect } from '@rc-component/select';
|
|
3
3
|
import useId from "@rc-component/util/es/hooks/useId";
|
|
4
4
|
import { conductCheck } from "@rc-component/tree/es/utils/conductUtil";
|
|
5
|
-
import
|
|
5
|
+
import useControlledState from "@rc-component/util/es/hooks/useControlledState";
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import useCache from "./hooks/useCache";
|
|
8
8
|
import useCheckedKeys from "./hooks/useCheckedKeys";
|
|
@@ -104,9 +104,7 @@ const TreeSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
104
104
|
filterTreeNode,
|
|
105
105
|
treeNodeFilterProp = 'value'
|
|
106
106
|
} = searchConfig;
|
|
107
|
-
const [internalValue, setInternalValue] =
|
|
108
|
-
value
|
|
109
|
-
});
|
|
107
|
+
const [internalValue, setInternalValue] = useControlledState(defaultValue, value);
|
|
110
108
|
|
|
111
109
|
// `multiple` && `!treeCheckable` should be show all
|
|
112
110
|
const mergedShowCheckedStrategy = React.useMemo(() => {
|
|
@@ -127,10 +125,8 @@ const TreeSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
127
125
|
/* eslint-enable react-hooks/exhaustive-deps */);
|
|
128
126
|
|
|
129
127
|
// =========================== Search ===========================
|
|
130
|
-
const [
|
|
131
|
-
|
|
132
|
-
postState: search => search || ''
|
|
133
|
-
});
|
|
128
|
+
const [internalSearchValue, setSearchValue] = useControlledState('', searchValue);
|
|
129
|
+
const mergedSearchValue = internalSearchValue || '';
|
|
134
130
|
const onInternalSearch = searchText => {
|
|
135
131
|
setSearchValue(searchText);
|
|
136
132
|
onSearch?.(searchText);
|
package/lib/TreeSelect.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
var _select = require("@rc-component/select");
|
|
8
8
|
var _useId = _interopRequireDefault(require("@rc-component/util/lib/hooks/useId"));
|
|
9
9
|
var _conductUtil = require("@rc-component/tree/lib/utils/conductUtil");
|
|
10
|
-
var
|
|
10
|
+
var _useControlledState = _interopRequireDefault(require("@rc-component/util/lib/hooks/useControlledState"));
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _useCache = _interopRequireDefault(require("./hooks/useCache"));
|
|
13
13
|
var _useCheckedKeys = _interopRequireDefault(require("./hooks/useCheckedKeys"));
|
|
@@ -113,9 +113,7 @@ const TreeSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
113
113
|
filterTreeNode,
|
|
114
114
|
treeNodeFilterProp = 'value'
|
|
115
115
|
} = searchConfig;
|
|
116
|
-
const [internalValue, setInternalValue] = (0,
|
|
117
|
-
value
|
|
118
|
-
});
|
|
116
|
+
const [internalValue, setInternalValue] = (0, _useControlledState.default)(defaultValue, value);
|
|
119
117
|
|
|
120
118
|
// `multiple` && `!treeCheckable` should be show all
|
|
121
119
|
const mergedShowCheckedStrategy = React.useMemo(() => {
|
|
@@ -136,10 +134,8 @@ const TreeSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
136
134
|
/* eslint-enable react-hooks/exhaustive-deps */);
|
|
137
135
|
|
|
138
136
|
// =========================== Search ===========================
|
|
139
|
-
const [
|
|
140
|
-
|
|
141
|
-
postState: search => search || ''
|
|
142
|
-
});
|
|
137
|
+
const [internalSearchValue, setSearchValue] = (0, _useControlledState.default)('', searchValue);
|
|
138
|
+
const mergedSearchValue = internalSearchValue || '';
|
|
143
139
|
const onInternalSearch = searchText => {
|
|
144
140
|
setSearchValue(searchText);
|
|
145
141
|
onSearch?.(searchText);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rc-component/tree-select",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "tree-select ui component for react",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"classnames": "2.x",
|
|
48
48
|
"@rc-component/select": "~1.1.0",
|
|
49
49
|
"@rc-component/tree": "~1.0.1",
|
|
50
|
-
"@rc-component/util": "^1.
|
|
50
|
+
"@rc-component/util": "^1.3.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@rc-component/father-plugin": "^2.0.2",
|