@cqsjjb/jjb-react-admin-component 3.3.1-beta.5 → 3.3.1-beta.7
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/AdaptiveTree/index.js +16 -2
- package/package.json +1 -1
package/AdaptiveTree/index.js
CHANGED
|
@@ -41,7 +41,7 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
41
41
|
* titleIcon={(node) => <FolderOpenOutlined />}
|
|
42
42
|
* />
|
|
43
43
|
*/
|
|
44
|
-
import React from 'react';
|
|
44
|
+
import React, { useState } from 'react';
|
|
45
45
|
import { Tree, Space } from "antd";
|
|
46
46
|
import { styled } from 'styled-components';
|
|
47
47
|
export default props => {
|
|
@@ -52,6 +52,8 @@ export default props => {
|
|
|
52
52
|
...rest
|
|
53
53
|
} = props;
|
|
54
54
|
const prefixCls = window.process.env.app.antd['ant-prefix'];
|
|
55
|
+
const [expandedKeys, setExpandedKeys] = useState([]);
|
|
56
|
+
const [selectedKeys, setSelectedKeys] = useState([]);
|
|
55
57
|
const StyledAntdComponents = styled.div`
|
|
56
58
|
.${prefixCls}-tree {
|
|
57
59
|
width: 100%;
|
|
@@ -175,11 +177,23 @@ export default props => {
|
|
|
175
177
|
}, item?.content || '');
|
|
176
178
|
}) : ''));
|
|
177
179
|
};
|
|
180
|
+
const onExpand = keys => {
|
|
181
|
+
setExpandedKeys(keys);
|
|
182
|
+
props.onExpand && props.onExpand(keys);
|
|
183
|
+
};
|
|
184
|
+
const onSelect = keys => {
|
|
185
|
+
setSelectedKeys(keys);
|
|
186
|
+
props.onSelect && props.onSelect(keys);
|
|
187
|
+
};
|
|
178
188
|
return /*#__PURE__*/React.createElement(StyledAntdComponents, null, /*#__PURE__*/React.createElement(Tree, _extends({
|
|
179
189
|
draggable: draggable ? {
|
|
180
190
|
icon: false
|
|
181
191
|
} : false,
|
|
182
192
|
titleRender: titleRender,
|
|
183
|
-
onCheck: onCheck
|
|
193
|
+
onCheck: onCheck,
|
|
194
|
+
expandedKeys: props?.expandedKeys || expandedKeys,
|
|
195
|
+
onExpand: onExpand,
|
|
196
|
+
selectedKeys: props?.selectedKeys || selectedKeys,
|
|
197
|
+
onSelect: onSelect
|
|
184
198
|
}, rest)));
|
|
185
199
|
};
|