@para-ui/core 4.0.16 → 4.0.18
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/Cascader/index.js +4 -3
- package/ComboSelect/index.js +4 -7
- package/CycleSelector/index.js +3 -1
- package/DatePicker/index.js +2 -1
- package/DynamicMultiBox/index.js +5 -7
- package/Form/index.js +3 -6
- package/FormItem/index.js +3 -6
- package/FunctionModal/index.js +2 -2
- package/Modal/index.js +1 -1
- package/README.md +8 -0
- package/TimePicker/index.js +2 -1
- package/Tree/index.js +5 -8
- package/Upload/index.js +625 -408
- package/_verture/{defineProperty-51493dbe.js → defineProperty-1d116156.js} +2 -10
- package/_verture/{index-0ad6af26.js → index-02b7a0b7.js} +313 -394
- package/_verture/{index-782e05bf.js → index-cc76d8d5.js} +2 -1
- package/_verture/typeof-adeedc13.js +11 -0
- package/index.js +6 -5
- package/package.json +1 -1
- package/umd/CycleSelector.js +1 -1
- package/umd/FunctionModal.js +1 -1
- package/umd/Modal.js +1 -1
- package/umd/Upload.js +1 -1
- /package/_verture/{index-06069532.js → index-10792f39.js} +0 -0
- /package/_verture/{modalContext-b101ffaa.js → modalContext-3ba6ca8f.js} +0 -0
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import { _ as _toConsumableArray } from './toConsumableArray-8f4c9589.js';
|
|
2
|
-
import { a as _typeof, _ as _defineProperty } from './defineProperty-51493dbe.js';
|
|
3
|
-
import { _ as _slicedToArray } from './slicedToArray-a8206399.js';
|
|
4
|
-
import { r as regenerator } from './index-287ae1b3.js';
|
|
5
1
|
import { _ as __rest, a as __awaiter } from './tslib.es6-55ed4bd2.js';
|
|
6
2
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
7
3
|
import React__default, { isValidElement, cloneElement, useRef, useState, useImperativeHandle, useEffect, useMemo } from 'react';
|
|
8
4
|
import RcTree from 'rc-tree';
|
|
9
5
|
import clsx from 'clsx';
|
|
6
|
+
import { _ as _typeof } from './typeof-adeedc13.js';
|
|
10
7
|
import LoadingOutlined from '@para-ui/icons/LoadingF';
|
|
11
8
|
import FileOutlined from '@para-ui/icons/Document';
|
|
12
9
|
import SolidArrowDown from '@para-ui/icons/DownTriangleF';
|
|
13
10
|
import { Radio } from '../Radio/index.js';
|
|
14
11
|
import { $ as $prefixCls } from './constant-5317fc89.js';
|
|
12
|
+
import { _ as _slicedToArray } from './slicedToArray-a8206399.js';
|
|
15
13
|
import ReactDOM from 'react-dom';
|
|
16
14
|
import EditOutlinedIcon from '@para-ui/icons/EditFile';
|
|
17
15
|
import AddOutlinedIcon from '@para-ui/icons/PlusCircle';
|
|
@@ -565,129 +563,110 @@ var OperateBar = function OperateBar(props) {
|
|
|
565
563
|
};
|
|
566
564
|
|
|
567
565
|
//默认分页信息
|
|
568
|
-
|
|
566
|
+
const defaultPageSize = {
|
|
569
567
|
page: 1,
|
|
570
568
|
size: 10
|
|
571
569
|
};
|
|
572
570
|
//tree 组件
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
params =
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
_props$replaceFields = props.replaceFields,
|
|
584
|
-
replaceFields = _props$replaceFields === void 0 ? {
|
|
571
|
+
const Tree = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
572
|
+
const {
|
|
573
|
+
url,
|
|
574
|
+
ctx,
|
|
575
|
+
params = null,
|
|
576
|
+
method = 'GET',
|
|
577
|
+
headers,
|
|
578
|
+
requestCallback,
|
|
579
|
+
refresh,
|
|
580
|
+
replaceFields = {
|
|
585
581
|
key: 'key',
|
|
586
582
|
parentId: 'parentId',
|
|
587
583
|
children: 'children',
|
|
588
584
|
title: 'title',
|
|
589
585
|
loadKey: 'key'
|
|
590
|
-
}
|
|
591
|
-
originTreeData
|
|
592
|
-
className
|
|
593
|
-
showIcon
|
|
594
|
-
|
|
595
|
-
showLine
|
|
596
|
-
|
|
597
|
-
blockNode
|
|
598
|
-
checkable
|
|
599
|
-
selectable
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
setInCheckedKeys = _useState4[1]; //选中keys
|
|
649
|
-
var _useState5 = useState([]),
|
|
650
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
651
|
-
inExpandedKeysKeys = _useState6[0],
|
|
652
|
-
setInExpandedKeys = _useState6[1]; //展开keys
|
|
653
|
-
var opRef = useRef({}); //操作栏
|
|
654
|
-
var mouseInSectorRef = useRef(false); //是否鼠标进入扇形
|
|
655
|
-
var timeSectorRef = useRef(-1); //定时显示扇形
|
|
656
|
-
var nodesRef = useRef([]); //保存节点状态
|
|
657
|
-
var prefixCls = "".concat($prefixCls, "-tree"); //tree容器前缀
|
|
658
|
-
var treeMapRef = useRef({}); //tree map
|
|
659
|
-
var treeOriDataRef = useRef([]); //tree origin data
|
|
660
|
-
var nPageSize = Object.assign(Object.assign({}, defaultPageSize), pageSize);
|
|
661
|
-
var halfCheckedKeys = useRef([]); //半选keys
|
|
662
|
-
var intl = useFormatMessage('Tree', localeJson);
|
|
663
|
-
var _useState7 = useState(false),
|
|
664
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
665
|
-
loading = _useState8[0],
|
|
666
|
-
setLoading = _useState8[1];
|
|
667
|
-
var firstRender = useRef(true); //是否第一次渲染
|
|
668
|
-
var _useState9 = useState([]),
|
|
669
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
670
|
-
inLoadedKeys = _useState10[0],
|
|
671
|
-
setInLoadKeys = _useState10[1];
|
|
586
|
+
},
|
|
587
|
+
treeData: originTreeData,
|
|
588
|
+
className,
|
|
589
|
+
showIcon,
|
|
590
|
+
icon,
|
|
591
|
+
showLine,
|
|
592
|
+
switcherIcon,
|
|
593
|
+
blockNode,
|
|
594
|
+
checkable,
|
|
595
|
+
selectable,
|
|
596
|
+
radioable = false,
|
|
597
|
+
showRadio = true,
|
|
598
|
+
checkStrictly = false,
|
|
599
|
+
actionsCallback,
|
|
600
|
+
showActions,
|
|
601
|
+
checkedKeys,
|
|
602
|
+
defaultCheckedKeys,
|
|
603
|
+
expandedKeys,
|
|
604
|
+
defaultExpandedKeys,
|
|
605
|
+
loadedKeys,
|
|
606
|
+
onCheck,
|
|
607
|
+
onExpand,
|
|
608
|
+
asyncLoad = false,
|
|
609
|
+
pagination = false,
|
|
610
|
+
pageSize = defaultPageSize,
|
|
611
|
+
loadData,
|
|
612
|
+
localFilter = false,
|
|
613
|
+
localParams,
|
|
614
|
+
onFilter,
|
|
615
|
+
loadMoreNode = null,
|
|
616
|
+
paramsCallback,
|
|
617
|
+
titleRender,
|
|
618
|
+
emptyProps,
|
|
619
|
+
emptyClassName,
|
|
620
|
+
notFoundContent,
|
|
621
|
+
wrapperClassName,
|
|
622
|
+
wrapperStyle,
|
|
623
|
+
showLoading = true,
|
|
624
|
+
loadingNode,
|
|
625
|
+
onLoadedKey,
|
|
626
|
+
tipMaxWidth = 500
|
|
627
|
+
} = props;
|
|
628
|
+
const [treeData, setTreeData] = useState([]); //树数据
|
|
629
|
+
const [inCheckedKeys, setInCheckedKeys] = useState([]); //选中keys
|
|
630
|
+
const [inExpandedKeysKeys, setInExpandedKeys] = useState([]); //展开keys
|
|
631
|
+
const opRef = useRef({}); //操作栏
|
|
632
|
+
const mouseInSectorRef = useRef(false); //是否鼠标进入扇形
|
|
633
|
+
const timeSectorRef = useRef(-1); //定时显示扇形
|
|
634
|
+
const nodesRef = useRef([]); //保存节点状态
|
|
635
|
+
const prefixCls = "".concat($prefixCls, "-tree"); //tree容器前缀
|
|
636
|
+
const treeMapRef = useRef({}); //tree map
|
|
637
|
+
const treeOriDataRef = useRef([]); //tree origin data
|
|
638
|
+
const nPageSize = Object.assign(Object.assign({}, defaultPageSize), pageSize);
|
|
639
|
+
const halfCheckedKeys = useRef([]); //半选keys
|
|
640
|
+
const intl = useFormatMessage('Tree', localeJson);
|
|
641
|
+
const [loading, setLoading] = useState(false);
|
|
642
|
+
const firstRender = useRef(true); //是否第一次渲染
|
|
643
|
+
const [inLoadedKeys, setInLoadKeys] = useState([]);
|
|
672
644
|
//新属性
|
|
673
|
-
|
|
645
|
+
const newProps = Object.assign(Object.assign({}, props), {
|
|
674
646
|
showLine: Boolean(showLine),
|
|
675
647
|
checkStrictly: radioable || checkStrictly,
|
|
676
648
|
showIcon: radioable || showIcon
|
|
677
649
|
});
|
|
678
650
|
//生成class
|
|
679
|
-
|
|
680
|
-
return clsx(
|
|
651
|
+
const makeCls = () => {
|
|
652
|
+
return clsx({
|
|
653
|
+
["".concat(prefixCls, "-icon-hide")]: !showIcon,
|
|
654
|
+
["".concat(prefixCls, "-block-node")]: blockNode,
|
|
655
|
+
["".concat(prefixCls, "-unselectable")]: !selectable,
|
|
656
|
+
["".concat(prefixCls, "-radioable")]: radioable,
|
|
657
|
+
["".concat(prefixCls, "-radioable-showradio")]: radioable && showRadio
|
|
658
|
+
}, className);
|
|
681
659
|
};
|
|
682
660
|
//格式化treeData 替换显示字段
|
|
683
|
-
|
|
661
|
+
const formatTreeData = treeData => {
|
|
684
662
|
function recursive(dataList) {
|
|
685
|
-
|
|
686
|
-
key
|
|
687
|
-
title
|
|
688
|
-
children
|
|
689
|
-
parentId
|
|
690
|
-
|
|
663
|
+
const {
|
|
664
|
+
key,
|
|
665
|
+
title,
|
|
666
|
+
children,
|
|
667
|
+
parentId
|
|
668
|
+
} = replaceFields || {};
|
|
669
|
+
dataList.forEach(item => {
|
|
691
670
|
var _a;
|
|
692
671
|
if (key) item.key = item[key];
|
|
693
672
|
if (title) item.title = item[title];
|
|
@@ -700,7 +679,7 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
700
679
|
return treeData;
|
|
701
680
|
};
|
|
702
681
|
//内部 tree title render
|
|
703
|
-
|
|
682
|
+
const internalTitleRender = nodeData => {
|
|
704
683
|
if (nodeData.moreFlag) {
|
|
705
684
|
//加载更多节点
|
|
706
685
|
return jsx("span", Object.assign({
|
|
@@ -729,9 +708,7 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
729
708
|
children: typeof titleRender === 'function' ? titleRender(nodeData) : nodeData.title
|
|
730
709
|
})), !!showActions && jsx("div", Object.assign({
|
|
731
710
|
className: "sector-anchor",
|
|
732
|
-
onMouseEnter:
|
|
733
|
-
return handleSectorMEnter(nodeData, evt);
|
|
734
|
-
},
|
|
711
|
+
onMouseEnter: evt => handleSectorMEnter(nodeData, evt),
|
|
735
712
|
onMouseLeave: handleSectorMLeave
|
|
736
713
|
}, {
|
|
737
714
|
children: jsx(MoreOutlinedIcon, {
|
|
@@ -741,44 +718,44 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
741
718
|
}));
|
|
742
719
|
};
|
|
743
720
|
//tree node mouse enter
|
|
744
|
-
|
|
721
|
+
const handleTreeNodeMEnter = evt => {
|
|
745
722
|
evt.stopPropagation();
|
|
746
723
|
clearNodesState();
|
|
747
|
-
|
|
724
|
+
const _currTarget = evt.currentTarget;
|
|
748
725
|
if (_currTarget) {
|
|
749
|
-
|
|
750
|
-
|
|
726
|
+
const pClsx = ".".concat($prefixCls, "-tree-node-content-wrapper");
|
|
727
|
+
const cParentEl = _currTarget.closest(pClsx);
|
|
751
728
|
nodesRef.current.push(cParentEl);
|
|
752
729
|
showMoreActionIcon(cParentEl, true);
|
|
753
730
|
}
|
|
754
731
|
};
|
|
755
732
|
//tree node mouse leave
|
|
756
|
-
|
|
733
|
+
const handleTreeNodeMLeave = evt => {
|
|
757
734
|
evt.stopPropagation();
|
|
758
735
|
clearNodesState();
|
|
759
|
-
|
|
736
|
+
const _currTarget = evt.currentTarget;
|
|
760
737
|
if (_currTarget) {
|
|
761
|
-
|
|
762
|
-
|
|
738
|
+
const pClsx = ".".concat($prefixCls, "-tree-node-content-wrapper");
|
|
739
|
+
const cParentEl = _currTarget.closest(pClsx);
|
|
763
740
|
showMoreActionIcon(cParentEl, false);
|
|
764
741
|
}
|
|
765
742
|
};
|
|
766
743
|
// Tree node Click
|
|
767
|
-
|
|
744
|
+
const handleTreeNodeClick = () => {
|
|
768
745
|
var _a;
|
|
769
746
|
if (!showActions) return;
|
|
770
747
|
// 点击tree node 的时候 rc 内部会把node节点的样式重写,导致之前逻辑添加的样式不存在,需要点击的时候加上样式
|
|
771
748
|
if (((_a = nodesRef.current) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
772
749
|
// 需要滞后到下次事件循环
|
|
773
|
-
setTimeout(
|
|
774
|
-
nodesRef.current.forEach(
|
|
750
|
+
setTimeout(() => {
|
|
751
|
+
nodesRef.current.forEach(el => {
|
|
775
752
|
showMoreActionIcon(el, true);
|
|
776
753
|
});
|
|
777
754
|
});
|
|
778
755
|
}
|
|
779
756
|
};
|
|
780
757
|
//节点显示更多图标
|
|
781
|
-
|
|
758
|
+
const showMoreActionIcon = (cParentEl, isShow) => {
|
|
782
759
|
if (!cParentEl) return;
|
|
783
760
|
if (isShow) {
|
|
784
761
|
cParentEl === null || cParentEl === void 0 ? void 0 : cParentEl.classList.add("".concat($prefixCls, "-tree-node-content-wrapper--active"));
|
|
@@ -787,21 +764,21 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
787
764
|
}
|
|
788
765
|
};
|
|
789
766
|
//mouse enter sector
|
|
790
|
-
|
|
767
|
+
const handleSectorMEnter = (nodeData, evt) => {
|
|
791
768
|
evt.stopPropagation();
|
|
792
|
-
|
|
769
|
+
const _currTarget = evt.currentTarget;
|
|
793
770
|
opRef.current.anchorEl = _currTarget;
|
|
794
|
-
timeSectorRef.current = setTimeout(
|
|
771
|
+
timeSectorRef.current = setTimeout(() => {
|
|
795
772
|
clearTimeout(timeSectorRef.current);
|
|
796
773
|
showSector(_currTarget, nodeData);
|
|
797
774
|
}, 300);
|
|
798
775
|
};
|
|
799
776
|
//mouse sector leave
|
|
800
|
-
|
|
777
|
+
const handleSectorMLeave = evt => {
|
|
801
778
|
evt.stopPropagation();
|
|
802
779
|
clearTimeout(timeSectorRef.current);
|
|
803
|
-
|
|
804
|
-
|
|
780
|
+
const _anchor = evt.currentTarget;
|
|
781
|
+
const timer = setTimeout(() => {
|
|
805
782
|
clearTimeout(timer);
|
|
806
783
|
if (!mouseInSectorRef.current) {
|
|
807
784
|
removeSector(_anchor);
|
|
@@ -809,19 +786,19 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
809
786
|
}, 300);
|
|
810
787
|
};
|
|
811
788
|
//显示扇形
|
|
812
|
-
|
|
789
|
+
const showSector = (anchorEl, nodeData) => {
|
|
813
790
|
var _a, _b;
|
|
814
|
-
|
|
791
|
+
const portalRoot = document.getElementById(opRef.current.uid);
|
|
815
792
|
anchorEl.classList.add('sector-anchor--active');
|
|
816
793
|
if (portalRoot) {
|
|
817
|
-
|
|
794
|
+
const container = portalRoot.querySelector('.sector-container');
|
|
818
795
|
if (container) {
|
|
819
796
|
(_b = (_a = opRef.current) === null || _a === void 0 ? void 0 : _a.onShowSector) === null || _b === void 0 ? void 0 : _b.call(_a, nodeData, true);
|
|
820
797
|
}
|
|
821
798
|
}
|
|
822
799
|
};
|
|
823
800
|
//移除扇形
|
|
824
|
-
|
|
801
|
+
const removeSector = anchorEl => {
|
|
825
802
|
var _a, _b;
|
|
826
803
|
if (anchorEl) {
|
|
827
804
|
anchorEl.classList.remove('sector-anchor--active');
|
|
@@ -829,19 +806,19 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
829
806
|
}
|
|
830
807
|
};
|
|
831
808
|
//离开扇形回调
|
|
832
|
-
|
|
809
|
+
const handleOnRemove = anchorEl => {
|
|
833
810
|
if (anchorEl) {
|
|
834
|
-
|
|
835
|
-
|
|
811
|
+
const pCls = ".".concat($prefixCls, "-tree-node-content-wrapper");
|
|
812
|
+
const cParentEl = anchorEl.closest(pCls);
|
|
836
813
|
showMoreActionIcon(cParentEl, false);
|
|
837
814
|
removeSector(anchorEl);
|
|
838
815
|
}
|
|
839
816
|
};
|
|
840
817
|
//清除节点状态
|
|
841
|
-
|
|
818
|
+
const clearNodesState = () => {
|
|
842
819
|
var _a;
|
|
843
820
|
if ((_a = nodesRef.current) === null || _a === void 0 ? void 0 : _a.length) {
|
|
844
|
-
nodesRef.current.forEach(
|
|
821
|
+
nodesRef.current.forEach(el => {
|
|
845
822
|
var _a;
|
|
846
823
|
(_a = el === null || el === void 0 ? void 0 : el.classList) === null || _a === void 0 ? void 0 : _a.remove("".concat($prefixCls, "-tree-node-content-wrapper--active"));
|
|
847
824
|
});
|
|
@@ -849,14 +826,14 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
849
826
|
}
|
|
850
827
|
};
|
|
851
828
|
//内部check
|
|
852
|
-
|
|
829
|
+
const internalCheck = (checkedKeys, e) => {
|
|
853
830
|
var _a;
|
|
854
|
-
|
|
855
|
-
|
|
831
|
+
let temp = [];
|
|
832
|
+
let halfChecked = [];
|
|
856
833
|
if (radioable) {
|
|
857
834
|
//单选
|
|
858
|
-
|
|
859
|
-
|
|
835
|
+
const node = e.node;
|
|
836
|
+
const key = (_a = replaceFields.key) !== null && _a !== void 0 ? _a : 'key';
|
|
860
837
|
if (e.checked) temp = [node[key]];
|
|
861
838
|
} else if (checkStrictly) {
|
|
862
839
|
//严格模式
|
|
@@ -873,59 +850,38 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
873
850
|
onCheck === null || onCheck === void 0 ? void 0 : onCheck(temp, e, halfChecked);
|
|
874
851
|
};
|
|
875
852
|
//展开节点
|
|
876
|
-
|
|
853
|
+
const internalExpand = (expandedKeys, e) => {
|
|
877
854
|
if (!('expandedKeys' in props)) {
|
|
878
|
-
setInExpandedKeys(
|
|
855
|
+
setInExpandedKeys([...expandedKeys]);
|
|
879
856
|
}
|
|
880
857
|
onExpand === null || onExpand === void 0 ? void 0 : onExpand(expandedKeys, e);
|
|
881
858
|
};
|
|
882
859
|
//请求树数据
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
return __awaiter(void 0, void 0, void 0,
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
_context.next = 9;
|
|
906
|
-
return Request(opts);
|
|
907
|
-
case 9:
|
|
908
|
-
_yield$Request = _context.sent;
|
|
909
|
-
data = _yield$Request.data;
|
|
910
|
-
err = _yield$Request.err;
|
|
911
|
-
//分页数据格式 {list,page,size,total},否则 []
|
|
912
|
-
showLoading && setLoading(false);
|
|
913
|
-
if (!err) {
|
|
914
|
-
_context.next = 15;
|
|
915
|
-
break;
|
|
916
|
-
}
|
|
917
|
-
return _context.abrupt("return", pagination ? {} : []);
|
|
918
|
-
case 15:
|
|
919
|
-
return _context.abrupt("return", pagination ? data.data || {} : data.data || []);
|
|
920
|
-
case 16:
|
|
921
|
-
case "end":
|
|
922
|
-
return _context.stop();
|
|
923
|
-
}
|
|
924
|
-
}, _callee);
|
|
925
|
-
}));
|
|
860
|
+
const requestTreeData = function () {
|
|
861
|
+
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
862
|
+
return __awaiter(void 0, void 0, void 0, function* () {
|
|
863
|
+
if (!url) return [];
|
|
864
|
+
showLoading && setLoading(true);
|
|
865
|
+
const tParams = (paramsCallback === null || paramsCallback === void 0 ? void 0 : paramsCallback(params)) || params;
|
|
866
|
+
const m = method === null || method === void 0 ? void 0 : method.toUpperCase();
|
|
867
|
+
const opts = {
|
|
868
|
+
url,
|
|
869
|
+
ctx,
|
|
870
|
+
method: m,
|
|
871
|
+
[m === 'GET' ? 'params' : 'data']: tParams || {}
|
|
872
|
+
};
|
|
873
|
+
if (headers) opts.headers = headers;
|
|
874
|
+
const {
|
|
875
|
+
data,
|
|
876
|
+
err
|
|
877
|
+
} = yield Request(opts); //分页数据格式 {list,page,size,total},否则 []
|
|
878
|
+
showLoading && setLoading(false);
|
|
879
|
+
if (err) return pagination ? {} : [];
|
|
880
|
+
return pagination ? data.data || {} : data.data || [];
|
|
881
|
+
});
|
|
926
882
|
};
|
|
927
883
|
//加载更多节点数据
|
|
928
|
-
|
|
884
|
+
const getLoadMoreData = () => {
|
|
929
885
|
return {
|
|
930
886
|
key: String((Math.random() * 1000000 | 0) + Date.now()),
|
|
931
887
|
title: intl({
|
|
@@ -940,10 +896,10 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
940
896
|
};
|
|
941
897
|
};
|
|
942
898
|
//渲染加载更多节点
|
|
943
|
-
|
|
899
|
+
const renderLoadMoreNode = dataNode => {
|
|
944
900
|
return jsx("span", Object.assign({
|
|
945
901
|
className: "".concat($prefixCls, "-tree-treenode-more-wrapper"),
|
|
946
|
-
onClick:
|
|
902
|
+
onClick: e => {
|
|
947
903
|
e.stopPropagation();
|
|
948
904
|
onLoadData(dataNode);
|
|
949
905
|
}
|
|
@@ -952,24 +908,24 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
952
908
|
}));
|
|
953
909
|
};
|
|
954
910
|
//更新tree数据
|
|
955
|
-
|
|
911
|
+
const updateTreeData = (list, key, children, moreFlag) => {
|
|
956
912
|
//root节点
|
|
957
913
|
if (key === 'ROOT_KEY') {
|
|
958
914
|
list.pop(); //删除加载更多节点
|
|
959
915
|
return list.concat(children);
|
|
960
916
|
}
|
|
961
|
-
return list.map(
|
|
917
|
+
return list.map(node => {
|
|
962
918
|
if (node.key === key) {
|
|
963
919
|
if (moreFlag) {
|
|
964
920
|
//加载更多
|
|
965
|
-
|
|
921
|
+
const child = node.children || [];
|
|
966
922
|
child.pop();
|
|
967
923
|
return Object.assign(Object.assign({}, node), {
|
|
968
924
|
children: child.concat(children)
|
|
969
925
|
});
|
|
970
926
|
}
|
|
971
927
|
return Object.assign(Object.assign({}, node), {
|
|
972
|
-
children
|
|
928
|
+
children
|
|
973
929
|
});
|
|
974
930
|
}
|
|
975
931
|
if (node.children) {
|
|
@@ -981,112 +937,101 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
981
937
|
});
|
|
982
938
|
};
|
|
983
939
|
//异步数据加载 [moreFlag]:加载更多标识
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
940
|
+
const onLoadData = dataNode => {
|
|
941
|
+
const {
|
|
942
|
+
key,
|
|
943
|
+
children,
|
|
944
|
+
parentId,
|
|
945
|
+
moreFlag
|
|
946
|
+
} = dataNode;
|
|
947
|
+
setInLoadKeys([...inLoadedKeys, key]);
|
|
990
948
|
onLoadedKey === null || onLoadedKey === void 0 ? void 0 : onLoadedKey(key, dataNode);
|
|
991
|
-
return new Promise(function (
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
//根节点加载更多,不需要key
|
|
1016
|
-
delete loadParams[loadKey];
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1019
|
-
//分页参数
|
|
1020
|
-
loadParams.page = treeMapRef.current[tKey].page;
|
|
1021
|
-
loadParams.size = treeMapRef.current[tKey].size;
|
|
1022
|
-
}
|
|
1023
|
-
_context2.next = 9;
|
|
1024
|
-
return requestTreeData(loadParams);
|
|
1025
|
-
case 9:
|
|
1026
|
-
treeData = _context2.sent;
|
|
1027
|
-
_context2.next = 12;
|
|
1028
|
-
return requestCallback === null || requestCallback === void 0 ? void 0 : requestCallback(treeData);
|
|
1029
|
-
case 12:
|
|
1030
|
-
handledData = _context2.sent;
|
|
1031
|
-
if (handledData) treeData = handledData;
|
|
1032
|
-
pageInfo = {}; //分页信息
|
|
1033
|
-
if (!pagination) {
|
|
1034
|
-
_context2.next = 22;
|
|
1035
|
-
break;
|
|
1036
|
-
}
|
|
1037
|
-
if (Object.keys(treeData).length) {
|
|
1038
|
-
_context2.next = 19;
|
|
1039
|
-
break;
|
|
1040
|
-
}
|
|
1041
|
-
resolve();
|
|
1042
|
-
return _context2.abrupt("return");
|
|
1043
|
-
case 19:
|
|
1044
|
-
_treeData = treeData, _treeData$list = _treeData.list, list = _treeData$list === void 0 ? [] : _treeData$list, page = _treeData.page, size = _treeData.size, total = _treeData.total;
|
|
1045
|
-
treeData = list;
|
|
1046
|
-
pageInfo = {
|
|
1047
|
-
page: page,
|
|
1048
|
-
size: size,
|
|
1049
|
-
total: total
|
|
1050
|
-
};
|
|
1051
|
-
case 22:
|
|
1052
|
-
if (treeData === null || treeData === void 0 ? void 0 : treeData.length) {
|
|
1053
|
-
treeData = formatTreeData(treeData);
|
|
1054
|
-
if (pagination) {
|
|
1055
|
-
//是否分页
|
|
1056
|
-
treeData = transformTreeData(treeData, pageInfo, tKey);
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
if (Array.isArray(treeData)) setTreeData(function (origin) {
|
|
1060
|
-
return updateTreeData(origin, tKey, treeData, moreFlag);
|
|
1061
|
-
});
|
|
1062
|
-
resolve();
|
|
1063
|
-
case 25:
|
|
1064
|
-
case "end":
|
|
1065
|
-
return _context2.stop();
|
|
949
|
+
return new Promise(resolve => __awaiter(void 0, void 0, void 0, function* () {
|
|
950
|
+
var _a;
|
|
951
|
+
if (children) {
|
|
952
|
+
resolve();
|
|
953
|
+
return;
|
|
954
|
+
}
|
|
955
|
+
//当前节点key
|
|
956
|
+
let tKey = key;
|
|
957
|
+
//参数动态字段
|
|
958
|
+
const loadKey = (_a = replaceFields.loadKey) !== null && _a !== void 0 ? _a : 'key';
|
|
959
|
+
//加载节点时参数
|
|
960
|
+
const loadParams = Object.assign({
|
|
961
|
+
[loadKey]: tKey
|
|
962
|
+
}, params);
|
|
963
|
+
//是否分页
|
|
964
|
+
if (pagination) {
|
|
965
|
+
if (moreFlag) {
|
|
966
|
+
//是否加载更多
|
|
967
|
+
tKey = parentId;
|
|
968
|
+
treeMapRef.current[tKey].page += 1;
|
|
969
|
+
loadParams[loadKey] = tKey;
|
|
970
|
+
if (tKey === 'ROOT_KEY') {
|
|
971
|
+
//根节点加载更多,不需要key
|
|
972
|
+
delete loadParams[loadKey];
|
|
1066
973
|
}
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
|
|
974
|
+
}
|
|
975
|
+
//分页参数
|
|
976
|
+
loadParams.page = treeMapRef.current[tKey].page;
|
|
977
|
+
loadParams.size = treeMapRef.current[tKey].size;
|
|
978
|
+
}
|
|
979
|
+
let treeData = yield requestTreeData(loadParams);
|
|
980
|
+
//透传数据
|
|
981
|
+
const handledData = yield requestCallback === null || requestCallback === void 0 ? void 0 : requestCallback(treeData);
|
|
982
|
+
if (handledData) treeData = handledData;
|
|
983
|
+
let pageInfo = {}; //分页信息
|
|
984
|
+
if (pagination) {
|
|
985
|
+
//分页数据格式 {list,page,size,total}
|
|
986
|
+
if (!Object.keys(treeData).length) {
|
|
987
|
+
resolve();
|
|
988
|
+
return;
|
|
989
|
+
}
|
|
990
|
+
const {
|
|
991
|
+
list = [],
|
|
992
|
+
page,
|
|
993
|
+
size,
|
|
994
|
+
total
|
|
995
|
+
} = treeData;
|
|
996
|
+
treeData = list;
|
|
997
|
+
pageInfo = {
|
|
998
|
+
page,
|
|
999
|
+
size,
|
|
1000
|
+
total
|
|
1001
|
+
};
|
|
1002
|
+
}
|
|
1003
|
+
if (treeData === null || treeData === void 0 ? void 0 : treeData.length) {
|
|
1004
|
+
treeData = formatTreeData(treeData);
|
|
1005
|
+
if (pagination) {
|
|
1006
|
+
//是否分页
|
|
1007
|
+
treeData = transformTreeData(treeData, pageInfo, tKey);
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
if (Array.isArray(treeData)) setTreeData(origin => updateTreeData(origin, tKey, treeData, moreFlag));
|
|
1011
|
+
resolve();
|
|
1012
|
+
}));
|
|
1070
1013
|
};
|
|
1071
1014
|
//转化tree数据
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1015
|
+
const transformTreeData = (treeData, pageInfo, parentId) => {
|
|
1016
|
+
const newTreeData = convert(treeData); //tree结构
|
|
1017
|
+
const {
|
|
1018
|
+
page,
|
|
1019
|
+
size,
|
|
1020
|
+
total
|
|
1021
|
+
} = pageInfo;
|
|
1077
1022
|
//计算分页,是否显示加载更多
|
|
1078
1023
|
if (page * size < total) {
|
|
1079
|
-
|
|
1024
|
+
const loadMoreData = getLoadMoreData();
|
|
1080
1025
|
loadMoreData.parentId = parentId || 'ROOT_KEY';
|
|
1081
1026
|
loadMoreData.title = renderLoadMoreNode(loadMoreData);
|
|
1082
1027
|
newTreeData.push(loadMoreData);
|
|
1083
1028
|
}
|
|
1084
1029
|
treeMapRef.current = _toObject(newTreeData);
|
|
1085
1030
|
function _toObject(data) {
|
|
1086
|
-
|
|
1031
|
+
const obj = treeMapRef.current;
|
|
1087
1032
|
if (!(data === null || data === void 0 ? void 0 : data.length)) return obj;
|
|
1088
|
-
data.forEach(
|
|
1089
|
-
|
|
1033
|
+
data.forEach(item => {
|
|
1034
|
+
const tKey = item.moreFlag ? item.parentId : item.key;
|
|
1090
1035
|
if (!obj[tKey]) {
|
|
1091
1036
|
obj[tKey] = Object.assign(Object.assign({}, item), nPageSize);
|
|
1092
1037
|
}
|
|
@@ -1096,73 +1041,49 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
1096
1041
|
return newTreeData;
|
|
1097
1042
|
};
|
|
1098
1043
|
//初始化树
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
//clean treeMapRef
|
|
1140
|
-
treeMapRef.current = {};
|
|
1141
|
-
case 17:
|
|
1142
|
-
if (treeData === null || treeData === void 0 ? void 0 : treeData.length) {
|
|
1143
|
-
_context3.next = 19;
|
|
1144
|
-
break;
|
|
1145
|
-
}
|
|
1146
|
-
return _context3.abrupt("return", setTreeData([]));
|
|
1147
|
-
case 19:
|
|
1148
|
-
treeData = formatTreeData(treeData);
|
|
1149
|
-
if (localFilter)
|
|
1150
|
-
//本地过滤
|
|
1151
|
-
treeOriDataRef.current = deepCopy(treeData);
|
|
1152
|
-
if (pagination)
|
|
1153
|
-
//是否分页
|
|
1154
|
-
treeData = transformTreeData(treeData, pageInfo);
|
|
1155
|
-
setTreeData(_toConsumableArray(treeData));
|
|
1156
|
-
case 23:
|
|
1157
|
-
case "end":
|
|
1158
|
-
return _context3.stop();
|
|
1159
|
-
}
|
|
1160
|
-
}, _callee3);
|
|
1161
|
-
}));
|
|
1162
|
-
};
|
|
1044
|
+
const initTree = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1045
|
+
const tParams = Object.assign({}, params);
|
|
1046
|
+
if (pagination) {
|
|
1047
|
+
//分页参数
|
|
1048
|
+
tParams.page = nPageSize.page;
|
|
1049
|
+
tParams.size = nPageSize.size;
|
|
1050
|
+
}
|
|
1051
|
+
let treeData = yield requestTreeData(tParams);
|
|
1052
|
+
let pageInfo = {}; //分页信息
|
|
1053
|
+
//透传数据
|
|
1054
|
+
const handledData = yield requestCallback === null || requestCallback === void 0 ? void 0 : requestCallback(treeData);
|
|
1055
|
+
if (handledData) treeData = handledData;
|
|
1056
|
+
if (pagination) {
|
|
1057
|
+
//分页数据格式 {list,page,size,total}
|
|
1058
|
+
if (!Object.keys(treeData).length) return setTreeData([]);
|
|
1059
|
+
const {
|
|
1060
|
+
list = [],
|
|
1061
|
+
page,
|
|
1062
|
+
size,
|
|
1063
|
+
total
|
|
1064
|
+
} = treeData;
|
|
1065
|
+
treeData = list;
|
|
1066
|
+
pageInfo = {
|
|
1067
|
+
page,
|
|
1068
|
+
size,
|
|
1069
|
+
total
|
|
1070
|
+
};
|
|
1071
|
+
//clean treeMapRef
|
|
1072
|
+
treeMapRef.current = {};
|
|
1073
|
+
}
|
|
1074
|
+
if (!(treeData === null || treeData === void 0 ? void 0 : treeData.length)) return setTreeData([]);
|
|
1075
|
+
treeData = formatTreeData(treeData);
|
|
1076
|
+
if (localFilter)
|
|
1077
|
+
//本地过滤
|
|
1078
|
+
treeOriDataRef.current = deepCopy(treeData);
|
|
1079
|
+
if (pagination)
|
|
1080
|
+
//是否分页
|
|
1081
|
+
treeData = transformTreeData(treeData, pageInfo);
|
|
1082
|
+
setTreeData([...treeData]);
|
|
1083
|
+
});
|
|
1163
1084
|
//额外的属性
|
|
1164
|
-
|
|
1165
|
-
|
|
1085
|
+
const getAdditionProps = () => {
|
|
1086
|
+
const additionProps = {};
|
|
1166
1087
|
if (asyncLoad)
|
|
1167
1088
|
//异步加载
|
|
1168
1089
|
additionProps.loadData = onLoadData;
|
|
@@ -1170,44 +1091,44 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
1170
1091
|
additionProps.titleRender = internalTitleRender;
|
|
1171
1092
|
return additionProps;
|
|
1172
1093
|
};
|
|
1173
|
-
useEffect(
|
|
1094
|
+
useEffect(() => {
|
|
1174
1095
|
if (defaultCheckedKeys) {
|
|
1175
1096
|
//默认值checked
|
|
1176
|
-
setInCheckedKeys(
|
|
1097
|
+
setInCheckedKeys([...defaultCheckedKeys]);
|
|
1177
1098
|
}
|
|
1178
1099
|
if (defaultExpandedKeys) {
|
|
1179
1100
|
//默认值expanded
|
|
1180
|
-
setInExpandedKeys(
|
|
1101
|
+
setInExpandedKeys([...defaultExpandedKeys]);
|
|
1181
1102
|
}
|
|
1182
1103
|
}, [defaultCheckedKeys, defaultExpandedKeys]);
|
|
1183
|
-
useEffect(
|
|
1104
|
+
useEffect(() => {
|
|
1184
1105
|
if (checkedKeys) {
|
|
1185
1106
|
//选中keys
|
|
1186
|
-
setInCheckedKeys(
|
|
1107
|
+
setInCheckedKeys([...getCheckedKeys(checkedKeys)]);
|
|
1187
1108
|
halfCheckedKeys.current = getHalfCheckedKeys(checkedKeys);
|
|
1188
1109
|
}
|
|
1189
1110
|
if (expandedKeys) {
|
|
1190
1111
|
//展开keys
|
|
1191
|
-
setInExpandedKeys(
|
|
1112
|
+
setInExpandedKeys([...expandedKeys]);
|
|
1192
1113
|
}
|
|
1193
1114
|
}, [checkedKeys, expandedKeys]);
|
|
1194
|
-
useEffect(
|
|
1115
|
+
useEffect(() => {
|
|
1195
1116
|
if (loadedKeys) {
|
|
1196
1117
|
//loadedKeys
|
|
1197
1118
|
if (loadedKeys.length === 0) {
|
|
1198
1119
|
setInLoadKeys([]);
|
|
1199
1120
|
setInExpandedKeys([]);
|
|
1200
1121
|
} else {
|
|
1201
|
-
setInLoadKeys(
|
|
1122
|
+
setInLoadKeys([...loadedKeys]);
|
|
1202
1123
|
}
|
|
1203
1124
|
}
|
|
1204
1125
|
}, [loadedKeys]);
|
|
1205
|
-
useEffect(
|
|
1126
|
+
useEffect(() => {
|
|
1206
1127
|
//默认展开所有
|
|
1207
1128
|
function _expandAllNode(newTreeData) {
|
|
1208
|
-
|
|
1129
|
+
const keys = [];
|
|
1209
1130
|
function recursive(dataList) {
|
|
1210
|
-
dataList.forEach(
|
|
1131
|
+
dataList.forEach(item => {
|
|
1211
1132
|
var _a;
|
|
1212
1133
|
if ((_a = item.children) === null || _a === void 0 ? void 0 : _a.length) {
|
|
1213
1134
|
keys.push(item.key);
|
|
@@ -1222,51 +1143,51 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
1222
1143
|
}
|
|
1223
1144
|
//tree 初始化
|
|
1224
1145
|
if (Array.isArray(originTreeData)) {
|
|
1225
|
-
|
|
1146
|
+
const newTreeData = formatTreeData(originTreeData);
|
|
1226
1147
|
//本地过滤
|
|
1227
1148
|
if (localFilter) treeOriDataRef.current = deepCopy(newTreeData);
|
|
1228
1149
|
if (newProps.defaultExpandAll) {
|
|
1229
1150
|
//默认展开所有
|
|
1230
1151
|
_expandAllNode(newTreeData);
|
|
1231
1152
|
}
|
|
1232
|
-
setTreeData(
|
|
1153
|
+
setTreeData([...newTreeData]);
|
|
1233
1154
|
} else {
|
|
1234
1155
|
initTree();
|
|
1235
1156
|
}
|
|
1236
1157
|
}, [url, ctx, params, method, refresh, originTreeData]);
|
|
1237
|
-
useEffect(
|
|
1158
|
+
useEffect(() => {
|
|
1238
1159
|
//过滤数据
|
|
1239
|
-
function _filterData(
|
|
1240
|
-
|
|
1241
|
-
|
|
1160
|
+
function _filterData(_ref) {
|
|
1161
|
+
let {
|
|
1162
|
+
searchKey,
|
|
1163
|
+
searchValue
|
|
1164
|
+
} = _ref;
|
|
1242
1165
|
if (!searchKey) return;
|
|
1243
1166
|
if (searchValue === '') {
|
|
1244
1167
|
setTreeData(treeOriDataRef.current);
|
|
1245
|
-
|
|
1246
|
-
setInExpandedKeys(
|
|
1168
|
+
const tKeys = expandedKeys || defaultExpandedKeys;
|
|
1169
|
+
setInExpandedKeys([...(tKeys || [])]);
|
|
1247
1170
|
return;
|
|
1248
1171
|
}
|
|
1249
|
-
|
|
1172
|
+
const flatData = flatten(treeOriDataRef.current);
|
|
1250
1173
|
//匹配数据
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1174
|
+
const filterTreeData = flatData.reduce((acc, curr) => {
|
|
1175
|
+
const title = String(curr[searchKey]).toLowerCase();
|
|
1176
|
+
const isMatch = title.includes(searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase());
|
|
1254
1177
|
return isMatch ? acc.concat(curr) : acc;
|
|
1255
1178
|
}, []);
|
|
1256
|
-
|
|
1179
|
+
const newTreeData = convertByFilter(deepCopy(flatData), filterTreeData);
|
|
1257
1180
|
setTreeData(newTreeData);
|
|
1258
1181
|
setInExpandedKeys(_handleExpendKey(newTreeData));
|
|
1259
1182
|
}
|
|
1260
1183
|
//处理展开key
|
|
1261
1184
|
function _handleExpendKey(list) {
|
|
1262
|
-
return list.reduce(
|
|
1263
|
-
return acc.concat(curr.key, _handleExpendKey(curr.children || []));
|
|
1264
|
-
}, []);
|
|
1185
|
+
return list.reduce((acc, curr) => acc.concat(curr.key, _handleExpendKey(curr.children || [])), []);
|
|
1265
1186
|
}
|
|
1266
1187
|
if (localFilter) {
|
|
1267
1188
|
//开启本地过滤
|
|
1268
1189
|
if (onFilter) {
|
|
1269
|
-
|
|
1190
|
+
const fData = onFilter(treeOriDataRef.current);
|
|
1270
1191
|
if (!fData) return;
|
|
1271
1192
|
setTreeData(fData);
|
|
1272
1193
|
return;
|
|
@@ -1275,7 +1196,7 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
1275
1196
|
}
|
|
1276
1197
|
}, [localFilter, localParams]);
|
|
1277
1198
|
//渲染空状态
|
|
1278
|
-
|
|
1199
|
+
const renderEmpty = jsx("div", Object.assign({
|
|
1279
1200
|
className: clsx("".concat($prefixCls, "-tree ").concat($prefixCls, "-tree-empty"), className, emptyClassName),
|
|
1280
1201
|
style: props.style
|
|
1281
1202
|
}, {
|
|
@@ -1284,14 +1205,14 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
1284
1205
|
}, emptyProps))
|
|
1285
1206
|
}));
|
|
1286
1207
|
//tree memo
|
|
1287
|
-
|
|
1208
|
+
const treeMemo = useMemo(() => {
|
|
1288
1209
|
if (!(treeData === null || treeData === void 0 ? void 0 : treeData.length) && firstRender.current) {
|
|
1289
1210
|
firstRender.current = false;
|
|
1290
1211
|
return null;
|
|
1291
1212
|
} else if (!(treeData === null || treeData === void 0 ? void 0 : treeData.length)) {
|
|
1292
1213
|
return !loading ? renderEmpty : null;
|
|
1293
1214
|
}
|
|
1294
|
-
|
|
1215
|
+
let tCheckedKeys = inCheckedKeys;
|
|
1295
1216
|
if (checkStrictly) {
|
|
1296
1217
|
tCheckedKeys = {
|
|
1297
1218
|
checked: inCheckedKeys,
|
|
@@ -1308,9 +1229,7 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
1308
1229
|
className: "".concat(prefixCls, "-checkbox-inner")
|
|
1309
1230
|
}) : checkable,
|
|
1310
1231
|
selectable: radioable ? false : selectable,
|
|
1311
|
-
switcherIcon:
|
|
1312
|
-
return renderSwitcherIcon(prefixCls, _switcherIcon, showLine, nodeProps);
|
|
1313
|
-
}
|
|
1232
|
+
switcherIcon: nodeProps => renderSwitcherIcon(prefixCls, switcherIcon, showLine, nodeProps)
|
|
1314
1233
|
}, getAdditionProps(), {
|
|
1315
1234
|
treeData: treeData,
|
|
1316
1235
|
checkedKeys: tCheckedKeys,
|
|
@@ -1318,9 +1237,9 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
1318
1237
|
loadedKeys: inLoadedKeys,
|
|
1319
1238
|
onCheck: internalCheck,
|
|
1320
1239
|
onExpand: internalExpand,
|
|
1321
|
-
icon:
|
|
1322
|
-
if (
|
|
1323
|
-
return typeof
|
|
1240
|
+
icon: nodeProps => {
|
|
1241
|
+
if (icon) {
|
|
1242
|
+
return typeof icon === 'function' ? icon(nodeProps) : icon;
|
|
1324
1243
|
}
|
|
1325
1244
|
if (nodeProps.checkable === false) return null;
|
|
1326
1245
|
if (!radioable) {
|
|
@@ -1331,7 +1250,7 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
1331
1250
|
}));
|
|
1332
1251
|
}, [treeData, inCheckedKeys, inExpandedKeysKeys, newProps.selectedKeys, inLoadedKeys]);
|
|
1333
1252
|
//OperateBar render
|
|
1334
|
-
|
|
1253
|
+
const renderOperateBar = () => {
|
|
1335
1254
|
return !!showActions ? jsx(OperateBar, {
|
|
1336
1255
|
opRef: opRef,
|
|
1337
1256
|
mouseInRef: mouseInSectorRef,
|