@para-ui/core 4.0.27 → 4.0.29
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 +5 -4
- package/ComboSelect/index.js +4 -7
- package/ContentBox/index.d.ts +33 -0
- package/ContentBox/index.js +89 -0
- package/CycleSelector/index.js +2 -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/Image/index.js +3 -2
- package/README.md +6 -0
- package/Selector/index.js +325 -2
- package/SelectorPicker/index.js +0 -1
- package/TimePicker/index.js +2 -1
- package/Title/index.d.ts +2 -0
- package/Title/index.js +19 -10
- package/Tooltip/index.js +26 -27
- package/Tree/index.js +5 -8
- package/Upload/index.js +3 -2
- package/_verture/{Portal-5bf66fed.js → Portal-5bd49559.js} +2 -1
- package/_verture/{defineProperty-f0e15205.js → defineProperty-6f62bb2a.js} +2 -10
- package/_verture/{index-8ec857b4.js → index-68f0506c.js} +3 -2
- package/_verture/{index-28edf318.js → index-e9405e35.js} +314 -395
- package/_verture/typeof-adeedc13.js +11 -0
- package/index.d.ts +2 -0
- package/index.js +8 -7
- package/package.json +2 -1
- package/umd/ContentBox.js +28 -0
- package/umd/Descriptions.js +2 -2
- package/umd/Title.js +6 -6
- package/_verture/index-8ac46bd9.js +0 -327
- /package/_verture/{index-33866394.js → index-15a0b6a6.js} +0 -0
- /package/_verture/{modalContext-c57b51b7.js → modalContext-10f0c5aa.js} +0 -0
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import { _ as _toConsumableArray } from './toConsumableArray-8f4c9589.js';
|
|
2
|
-
import { _ as _typeof, a as _defineProperty } from './defineProperty-f0e15205.js';
|
|
3
|
-
import { _ as _slicedToArray } from './slicedToArray-a8206399.js';
|
|
4
|
-
import { r as regenerator } from './index-8ac46bd9.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 PlusCircle 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,48 +718,48 @@ 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
|
var _a;
|
|
746
|
-
|
|
723
|
+
const spanClass = "".concat($prefixCls, "-tree-title-wrapper");
|
|
747
724
|
if (((_a = evt.target) === null || _a === void 0 ? void 0 : _a.className.indexOf(spanClass)) > -1) {
|
|
748
725
|
evt.stopPropagation();
|
|
749
726
|
}
|
|
750
727
|
clearNodesState();
|
|
751
|
-
|
|
728
|
+
const _currTarget = evt.currentTarget;
|
|
752
729
|
if (_currTarget) {
|
|
753
|
-
|
|
754
|
-
|
|
730
|
+
const pClsx = ".".concat($prefixCls, "-tree-node-content-wrapper");
|
|
731
|
+
const cParentEl = _currTarget.closest(pClsx);
|
|
755
732
|
nodesRef.current.push(cParentEl);
|
|
756
733
|
showMoreActionIcon(cParentEl, true);
|
|
757
734
|
}
|
|
758
735
|
};
|
|
759
736
|
//tree node mouse leave
|
|
760
|
-
|
|
737
|
+
const handleTreeNodeMLeave = evt => {
|
|
761
738
|
evt.stopPropagation();
|
|
762
739
|
clearNodesState();
|
|
763
|
-
|
|
740
|
+
const _currTarget = evt.currentTarget;
|
|
764
741
|
if (_currTarget) {
|
|
765
|
-
|
|
766
|
-
|
|
742
|
+
const pClsx = ".".concat($prefixCls, "-tree-node-content-wrapper");
|
|
743
|
+
const cParentEl = _currTarget.closest(pClsx);
|
|
767
744
|
showMoreActionIcon(cParentEl, false);
|
|
768
745
|
}
|
|
769
746
|
};
|
|
770
747
|
// Tree node Click
|
|
771
|
-
|
|
748
|
+
const handleTreeNodeClick = () => {
|
|
772
749
|
var _a;
|
|
773
750
|
if (!showActions) return;
|
|
774
751
|
// 点击tree node 的时候 rc 内部会把node节点的样式重写,导致之前逻辑添加的样式不存在,需要点击的时候加上样式
|
|
775
752
|
if (((_a = nodesRef.current) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
776
753
|
// 需要滞后到下次事件循环
|
|
777
|
-
setTimeout(
|
|
778
|
-
nodesRef.current.forEach(
|
|
754
|
+
setTimeout(() => {
|
|
755
|
+
nodesRef.current.forEach(el => {
|
|
779
756
|
showMoreActionIcon(el, true);
|
|
780
757
|
});
|
|
781
758
|
});
|
|
782
759
|
}
|
|
783
760
|
};
|
|
784
761
|
//节点显示更多图标
|
|
785
|
-
|
|
762
|
+
const showMoreActionIcon = (cParentEl, isShow) => {
|
|
786
763
|
if (!cParentEl) return;
|
|
787
764
|
if (isShow) {
|
|
788
765
|
cParentEl === null || cParentEl === void 0 ? void 0 : cParentEl.classList.add("".concat($prefixCls, "-tree-node-content-wrapper--active"));
|
|
@@ -791,21 +768,21 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
791
768
|
}
|
|
792
769
|
};
|
|
793
770
|
//mouse enter sector
|
|
794
|
-
|
|
771
|
+
const handleSectorMEnter = (nodeData, evt) => {
|
|
795
772
|
evt.stopPropagation();
|
|
796
|
-
|
|
773
|
+
const _currTarget = evt.currentTarget;
|
|
797
774
|
opRef.current.anchorEl = _currTarget;
|
|
798
|
-
timeSectorRef.current = setTimeout(
|
|
775
|
+
timeSectorRef.current = setTimeout(() => {
|
|
799
776
|
clearTimeout(timeSectorRef.current);
|
|
800
777
|
showSector(_currTarget, nodeData);
|
|
801
778
|
}, 300);
|
|
802
779
|
};
|
|
803
780
|
//mouse sector leave
|
|
804
|
-
|
|
781
|
+
const handleSectorMLeave = evt => {
|
|
805
782
|
evt.stopPropagation();
|
|
806
783
|
clearTimeout(timeSectorRef.current);
|
|
807
|
-
|
|
808
|
-
|
|
784
|
+
const _anchor = evt.currentTarget;
|
|
785
|
+
const timer = setTimeout(() => {
|
|
809
786
|
clearTimeout(timer);
|
|
810
787
|
if (!mouseInSectorRef.current) {
|
|
811
788
|
removeSector(_anchor);
|
|
@@ -813,19 +790,19 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
813
790
|
}, 300);
|
|
814
791
|
};
|
|
815
792
|
//显示扇形
|
|
816
|
-
|
|
793
|
+
const showSector = (anchorEl, nodeData) => {
|
|
817
794
|
var _a, _b;
|
|
818
|
-
|
|
795
|
+
const portalRoot = document.getElementById(opRef.current.uid);
|
|
819
796
|
anchorEl.classList.add('sector-anchor--active');
|
|
820
797
|
if (portalRoot) {
|
|
821
|
-
|
|
798
|
+
const container = portalRoot.querySelector('.sector-container');
|
|
822
799
|
if (container) {
|
|
823
800
|
(_b = (_a = opRef.current) === null || _a === void 0 ? void 0 : _a.onShowSector) === null || _b === void 0 ? void 0 : _b.call(_a, nodeData, true);
|
|
824
801
|
}
|
|
825
802
|
}
|
|
826
803
|
};
|
|
827
804
|
//移除扇形
|
|
828
|
-
|
|
805
|
+
const removeSector = anchorEl => {
|
|
829
806
|
var _a, _b;
|
|
830
807
|
if (anchorEl) {
|
|
831
808
|
anchorEl.classList.remove('sector-anchor--active');
|
|
@@ -833,19 +810,19 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
833
810
|
}
|
|
834
811
|
};
|
|
835
812
|
//离开扇形回调
|
|
836
|
-
|
|
813
|
+
const handleOnRemove = anchorEl => {
|
|
837
814
|
if (anchorEl) {
|
|
838
|
-
|
|
839
|
-
|
|
815
|
+
const pCls = ".".concat($prefixCls, "-tree-node-content-wrapper");
|
|
816
|
+
const cParentEl = anchorEl.closest(pCls);
|
|
840
817
|
showMoreActionIcon(cParentEl, false);
|
|
841
818
|
removeSector(anchorEl);
|
|
842
819
|
}
|
|
843
820
|
};
|
|
844
821
|
//清除节点状态
|
|
845
|
-
|
|
822
|
+
const clearNodesState = () => {
|
|
846
823
|
var _a;
|
|
847
824
|
if ((_a = nodesRef.current) === null || _a === void 0 ? void 0 : _a.length) {
|
|
848
|
-
nodesRef.current.forEach(
|
|
825
|
+
nodesRef.current.forEach(el => {
|
|
849
826
|
var _a;
|
|
850
827
|
(_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"));
|
|
851
828
|
});
|
|
@@ -853,14 +830,14 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
853
830
|
}
|
|
854
831
|
};
|
|
855
832
|
//内部check
|
|
856
|
-
|
|
833
|
+
const internalCheck = (checkedKeys, e) => {
|
|
857
834
|
var _a;
|
|
858
|
-
|
|
859
|
-
|
|
835
|
+
let temp = [];
|
|
836
|
+
let halfChecked = [];
|
|
860
837
|
if (radioable) {
|
|
861
838
|
//单选
|
|
862
|
-
|
|
863
|
-
|
|
839
|
+
const node = e.node;
|
|
840
|
+
const key = (_a = replaceFields.key) !== null && _a !== void 0 ? _a : 'key';
|
|
864
841
|
if (e.checked) temp = [node[key]];
|
|
865
842
|
} else if (checkStrictly) {
|
|
866
843
|
//严格模式
|
|
@@ -877,59 +854,38 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
877
854
|
onCheck === null || onCheck === void 0 ? void 0 : onCheck(temp, e, halfChecked);
|
|
878
855
|
};
|
|
879
856
|
//展开节点
|
|
880
|
-
|
|
857
|
+
const internalExpand = (expandedKeys, e) => {
|
|
881
858
|
if (!('expandedKeys' in props)) {
|
|
882
|
-
setInExpandedKeys(
|
|
859
|
+
setInExpandedKeys([...expandedKeys]);
|
|
883
860
|
}
|
|
884
861
|
onExpand === null || onExpand === void 0 ? void 0 : onExpand(expandedKeys, e);
|
|
885
862
|
};
|
|
886
863
|
//请求树数据
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
return __awaiter(void 0, void 0, void 0,
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
_context.next = 9;
|
|
910
|
-
return Request(opts);
|
|
911
|
-
case 9:
|
|
912
|
-
_yield$Request = _context.sent;
|
|
913
|
-
data = _yield$Request.data;
|
|
914
|
-
err = _yield$Request.err;
|
|
915
|
-
//分页数据格式 {list,page,size,total},否则 []
|
|
916
|
-
showLoading && setLoading(false);
|
|
917
|
-
if (!err) {
|
|
918
|
-
_context.next = 15;
|
|
919
|
-
break;
|
|
920
|
-
}
|
|
921
|
-
return _context.abrupt("return", pagination ? {} : []);
|
|
922
|
-
case 15:
|
|
923
|
-
return _context.abrupt("return", pagination ? data.data || {} : data.data || []);
|
|
924
|
-
case 16:
|
|
925
|
-
case "end":
|
|
926
|
-
return _context.stop();
|
|
927
|
-
}
|
|
928
|
-
}, _callee);
|
|
929
|
-
}));
|
|
864
|
+
const requestTreeData = function () {
|
|
865
|
+
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
866
|
+
return __awaiter(void 0, void 0, void 0, function* () {
|
|
867
|
+
if (!url) return [];
|
|
868
|
+
showLoading && setLoading(true);
|
|
869
|
+
const tParams = (paramsCallback === null || paramsCallback === void 0 ? void 0 : paramsCallback(params)) || params;
|
|
870
|
+
const m = method === null || method === void 0 ? void 0 : method.toUpperCase();
|
|
871
|
+
const opts = {
|
|
872
|
+
url,
|
|
873
|
+
ctx,
|
|
874
|
+
method: m,
|
|
875
|
+
[m === 'GET' ? 'params' : 'data']: tParams || {}
|
|
876
|
+
};
|
|
877
|
+
if (headers) opts.headers = headers;
|
|
878
|
+
const {
|
|
879
|
+
data,
|
|
880
|
+
err
|
|
881
|
+
} = yield Request(opts); //分页数据格式 {list,page,size,total},否则 []
|
|
882
|
+
showLoading && setLoading(false);
|
|
883
|
+
if (err) return pagination ? {} : [];
|
|
884
|
+
return pagination ? data.data || {} : data.data || [];
|
|
885
|
+
});
|
|
930
886
|
};
|
|
931
887
|
//加载更多节点数据
|
|
932
|
-
|
|
888
|
+
const getLoadMoreData = () => {
|
|
933
889
|
return {
|
|
934
890
|
key: String((Math.random() * 1000000 | 0) + Date.now()),
|
|
935
891
|
title: intl({
|
|
@@ -944,10 +900,10 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
944
900
|
};
|
|
945
901
|
};
|
|
946
902
|
//渲染加载更多节点
|
|
947
|
-
|
|
903
|
+
const renderLoadMoreNode = dataNode => {
|
|
948
904
|
return jsx("span", Object.assign({
|
|
949
905
|
className: "".concat($prefixCls, "-tree-treenode-more-wrapper"),
|
|
950
|
-
onClick:
|
|
906
|
+
onClick: e => {
|
|
951
907
|
e.stopPropagation();
|
|
952
908
|
onLoadData(dataNode);
|
|
953
909
|
}
|
|
@@ -956,24 +912,24 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
956
912
|
}));
|
|
957
913
|
};
|
|
958
914
|
//更新tree数据
|
|
959
|
-
|
|
915
|
+
const updateTreeData = (list, key, children, moreFlag) => {
|
|
960
916
|
//root节点
|
|
961
917
|
if (key === 'ROOT_KEY') {
|
|
962
918
|
list.pop(); //删除加载更多节点
|
|
963
919
|
return list.concat(children);
|
|
964
920
|
}
|
|
965
|
-
return list.map(
|
|
921
|
+
return list.map(node => {
|
|
966
922
|
if (node.key === key) {
|
|
967
923
|
if (moreFlag) {
|
|
968
924
|
//加载更多
|
|
969
|
-
|
|
925
|
+
const child = node.children || [];
|
|
970
926
|
child.pop();
|
|
971
927
|
return Object.assign(Object.assign({}, node), {
|
|
972
928
|
children: child.concat(children)
|
|
973
929
|
});
|
|
974
930
|
}
|
|
975
931
|
return Object.assign(Object.assign({}, node), {
|
|
976
|
-
children
|
|
932
|
+
children
|
|
977
933
|
});
|
|
978
934
|
}
|
|
979
935
|
if (node.children) {
|
|
@@ -985,112 +941,101 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
985
941
|
});
|
|
986
942
|
};
|
|
987
943
|
//异步数据加载 [moreFlag]:加载更多标识
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
944
|
+
const onLoadData = dataNode => {
|
|
945
|
+
const {
|
|
946
|
+
key,
|
|
947
|
+
children,
|
|
948
|
+
parentId,
|
|
949
|
+
moreFlag
|
|
950
|
+
} = dataNode;
|
|
951
|
+
setInLoadKeys([...inLoadedKeys, key]);
|
|
994
952
|
onLoadedKey === null || onLoadedKey === void 0 ? void 0 : onLoadedKey(key, dataNode);
|
|
995
|
-
return new Promise(function (
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
//根节点加载更多,不需要key
|
|
1020
|
-
delete loadParams[loadKey];
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
//分页参数
|
|
1024
|
-
loadParams.page = treeMapRef.current[tKey].page;
|
|
1025
|
-
loadParams.size = treeMapRef.current[tKey].size;
|
|
1026
|
-
}
|
|
1027
|
-
_context2.next = 9;
|
|
1028
|
-
return requestTreeData(loadParams);
|
|
1029
|
-
case 9:
|
|
1030
|
-
treeData = _context2.sent;
|
|
1031
|
-
_context2.next = 12;
|
|
1032
|
-
return requestCallback === null || requestCallback === void 0 ? void 0 : requestCallback(treeData);
|
|
1033
|
-
case 12:
|
|
1034
|
-
handledData = _context2.sent;
|
|
1035
|
-
if (handledData) treeData = handledData;
|
|
1036
|
-
pageInfo = {}; //分页信息
|
|
1037
|
-
if (!pagination) {
|
|
1038
|
-
_context2.next = 22;
|
|
1039
|
-
break;
|
|
1040
|
-
}
|
|
1041
|
-
if (Object.keys(treeData).length) {
|
|
1042
|
-
_context2.next = 19;
|
|
1043
|
-
break;
|
|
1044
|
-
}
|
|
1045
|
-
resolve();
|
|
1046
|
-
return _context2.abrupt("return");
|
|
1047
|
-
case 19:
|
|
1048
|
-
_treeData = treeData, _treeData$list = _treeData.list, list = _treeData$list === void 0 ? [] : _treeData$list, page = _treeData.page, size = _treeData.size, total = _treeData.total;
|
|
1049
|
-
treeData = list;
|
|
1050
|
-
pageInfo = {
|
|
1051
|
-
page: page,
|
|
1052
|
-
size: size,
|
|
1053
|
-
total: total
|
|
1054
|
-
};
|
|
1055
|
-
case 22:
|
|
1056
|
-
if (treeData === null || treeData === void 0 ? void 0 : treeData.length) {
|
|
1057
|
-
treeData = formatTreeData(treeData);
|
|
1058
|
-
if (pagination) {
|
|
1059
|
-
//是否分页
|
|
1060
|
-
treeData = transformTreeData(treeData, pageInfo, tKey);
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
if (Array.isArray(treeData)) setTreeData(function (origin) {
|
|
1064
|
-
return updateTreeData(origin, tKey, treeData, moreFlag);
|
|
1065
|
-
});
|
|
1066
|
-
resolve();
|
|
1067
|
-
case 25:
|
|
1068
|
-
case "end":
|
|
1069
|
-
return _context2.stop();
|
|
953
|
+
return new Promise(resolve => __awaiter(void 0, void 0, void 0, function* () {
|
|
954
|
+
var _a;
|
|
955
|
+
if (children) {
|
|
956
|
+
resolve();
|
|
957
|
+
return;
|
|
958
|
+
}
|
|
959
|
+
//当前节点key
|
|
960
|
+
let tKey = key;
|
|
961
|
+
//参数动态字段
|
|
962
|
+
const loadKey = (_a = replaceFields.loadKey) !== null && _a !== void 0 ? _a : 'key';
|
|
963
|
+
//加载节点时参数
|
|
964
|
+
const loadParams = Object.assign({
|
|
965
|
+
[loadKey]: tKey
|
|
966
|
+
}, params);
|
|
967
|
+
//是否分页
|
|
968
|
+
if (pagination) {
|
|
969
|
+
if (moreFlag) {
|
|
970
|
+
//是否加载更多
|
|
971
|
+
tKey = parentId;
|
|
972
|
+
treeMapRef.current[tKey].page += 1;
|
|
973
|
+
loadParams[loadKey] = tKey;
|
|
974
|
+
if (tKey === 'ROOT_KEY') {
|
|
975
|
+
//根节点加载更多,不需要key
|
|
976
|
+
delete loadParams[loadKey];
|
|
1070
977
|
}
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
|
-
|
|
978
|
+
}
|
|
979
|
+
//分页参数
|
|
980
|
+
loadParams.page = treeMapRef.current[tKey].page;
|
|
981
|
+
loadParams.size = treeMapRef.current[tKey].size;
|
|
982
|
+
}
|
|
983
|
+
let treeData = yield requestTreeData(loadParams);
|
|
984
|
+
//透传数据
|
|
985
|
+
const handledData = yield requestCallback === null || requestCallback === void 0 ? void 0 : requestCallback(treeData);
|
|
986
|
+
if (handledData) treeData = handledData;
|
|
987
|
+
let pageInfo = {}; //分页信息
|
|
988
|
+
if (pagination) {
|
|
989
|
+
//分页数据格式 {list,page,size,total}
|
|
990
|
+
if (!Object.keys(treeData).length) {
|
|
991
|
+
resolve();
|
|
992
|
+
return;
|
|
993
|
+
}
|
|
994
|
+
const {
|
|
995
|
+
list = [],
|
|
996
|
+
page,
|
|
997
|
+
size,
|
|
998
|
+
total
|
|
999
|
+
} = treeData;
|
|
1000
|
+
treeData = list;
|
|
1001
|
+
pageInfo = {
|
|
1002
|
+
page,
|
|
1003
|
+
size,
|
|
1004
|
+
total
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
1007
|
+
if (treeData === null || treeData === void 0 ? void 0 : treeData.length) {
|
|
1008
|
+
treeData = formatTreeData(treeData);
|
|
1009
|
+
if (pagination) {
|
|
1010
|
+
//是否分页
|
|
1011
|
+
treeData = transformTreeData(treeData, pageInfo, tKey);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
if (Array.isArray(treeData)) setTreeData(origin => updateTreeData(origin, tKey, treeData, moreFlag));
|
|
1015
|
+
resolve();
|
|
1016
|
+
}));
|
|
1074
1017
|
};
|
|
1075
1018
|
//转化tree数据
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1019
|
+
const transformTreeData = (treeData, pageInfo, parentId) => {
|
|
1020
|
+
const newTreeData = convert(treeData); //tree结构
|
|
1021
|
+
const {
|
|
1022
|
+
page,
|
|
1023
|
+
size,
|
|
1024
|
+
total
|
|
1025
|
+
} = pageInfo;
|
|
1081
1026
|
//计算分页,是否显示加载更多
|
|
1082
1027
|
if (page * size < total) {
|
|
1083
|
-
|
|
1028
|
+
const loadMoreData = getLoadMoreData();
|
|
1084
1029
|
loadMoreData.parentId = parentId || 'ROOT_KEY';
|
|
1085
1030
|
loadMoreData.title = renderLoadMoreNode(loadMoreData);
|
|
1086
1031
|
newTreeData.push(loadMoreData);
|
|
1087
1032
|
}
|
|
1088
1033
|
treeMapRef.current = _toObject(newTreeData);
|
|
1089
1034
|
function _toObject(data) {
|
|
1090
|
-
|
|
1035
|
+
const obj = treeMapRef.current;
|
|
1091
1036
|
if (!(data === null || data === void 0 ? void 0 : data.length)) return obj;
|
|
1092
|
-
data.forEach(
|
|
1093
|
-
|
|
1037
|
+
data.forEach(item => {
|
|
1038
|
+
const tKey = item.moreFlag ? item.parentId : item.key;
|
|
1094
1039
|
if (!obj[tKey]) {
|
|
1095
1040
|
obj[tKey] = Object.assign(Object.assign({}, item), nPageSize);
|
|
1096
1041
|
}
|
|
@@ -1100,73 +1045,49 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
1100
1045
|
return newTreeData;
|
|
1101
1046
|
};
|
|
1102
1047
|
//初始化树
|
|
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
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
//clean treeMapRef
|
|
1144
|
-
treeMapRef.current = {};
|
|
1145
|
-
case 17:
|
|
1146
|
-
if (treeData === null || treeData === void 0 ? void 0 : treeData.length) {
|
|
1147
|
-
_context3.next = 19;
|
|
1148
|
-
break;
|
|
1149
|
-
}
|
|
1150
|
-
return _context3.abrupt("return", setTreeData([]));
|
|
1151
|
-
case 19:
|
|
1152
|
-
treeData = formatTreeData(treeData);
|
|
1153
|
-
if (localFilter)
|
|
1154
|
-
//本地过滤
|
|
1155
|
-
treeOriDataRef.current = deepCopy(treeData);
|
|
1156
|
-
if (pagination)
|
|
1157
|
-
//是否分页
|
|
1158
|
-
treeData = transformTreeData(treeData, pageInfo);
|
|
1159
|
-
setTreeData(_toConsumableArray(treeData));
|
|
1160
|
-
case 23:
|
|
1161
|
-
case "end":
|
|
1162
|
-
return _context3.stop();
|
|
1163
|
-
}
|
|
1164
|
-
}, _callee3);
|
|
1165
|
-
}));
|
|
1166
|
-
};
|
|
1048
|
+
const initTree = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1049
|
+
const tParams = Object.assign({}, params);
|
|
1050
|
+
if (pagination) {
|
|
1051
|
+
//分页参数
|
|
1052
|
+
tParams.page = nPageSize.page;
|
|
1053
|
+
tParams.size = nPageSize.size;
|
|
1054
|
+
}
|
|
1055
|
+
let treeData = yield requestTreeData(tParams);
|
|
1056
|
+
let pageInfo = {}; //分页信息
|
|
1057
|
+
//透传数据
|
|
1058
|
+
const handledData = yield requestCallback === null || requestCallback === void 0 ? void 0 : requestCallback(treeData);
|
|
1059
|
+
if (handledData) treeData = handledData;
|
|
1060
|
+
if (pagination) {
|
|
1061
|
+
//分页数据格式 {list,page,size,total}
|
|
1062
|
+
if (!Object.keys(treeData).length) return setTreeData([]);
|
|
1063
|
+
const {
|
|
1064
|
+
list = [],
|
|
1065
|
+
page,
|
|
1066
|
+
size,
|
|
1067
|
+
total
|
|
1068
|
+
} = treeData;
|
|
1069
|
+
treeData = list;
|
|
1070
|
+
pageInfo = {
|
|
1071
|
+
page,
|
|
1072
|
+
size,
|
|
1073
|
+
total
|
|
1074
|
+
};
|
|
1075
|
+
//clean treeMapRef
|
|
1076
|
+
treeMapRef.current = {};
|
|
1077
|
+
}
|
|
1078
|
+
if (!(treeData === null || treeData === void 0 ? void 0 : treeData.length)) return setTreeData([]);
|
|
1079
|
+
treeData = formatTreeData(treeData);
|
|
1080
|
+
if (localFilter)
|
|
1081
|
+
//本地过滤
|
|
1082
|
+
treeOriDataRef.current = deepCopy(treeData);
|
|
1083
|
+
if (pagination)
|
|
1084
|
+
//是否分页
|
|
1085
|
+
treeData = transformTreeData(treeData, pageInfo);
|
|
1086
|
+
setTreeData([...treeData]);
|
|
1087
|
+
});
|
|
1167
1088
|
//额外的属性
|
|
1168
|
-
|
|
1169
|
-
|
|
1089
|
+
const getAdditionProps = () => {
|
|
1090
|
+
const additionProps = {};
|
|
1170
1091
|
if (asyncLoad)
|
|
1171
1092
|
//异步加载
|
|
1172
1093
|
additionProps.loadData = onLoadData;
|
|
@@ -1174,44 +1095,44 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
1174
1095
|
additionProps.titleRender = internalTitleRender;
|
|
1175
1096
|
return additionProps;
|
|
1176
1097
|
};
|
|
1177
|
-
useEffect(
|
|
1098
|
+
useEffect(() => {
|
|
1178
1099
|
if (defaultCheckedKeys) {
|
|
1179
1100
|
//默认值checked
|
|
1180
|
-
setInCheckedKeys(
|
|
1101
|
+
setInCheckedKeys([...defaultCheckedKeys]);
|
|
1181
1102
|
}
|
|
1182
1103
|
if (defaultExpandedKeys) {
|
|
1183
1104
|
//默认值expanded
|
|
1184
|
-
setInExpandedKeys(
|
|
1105
|
+
setInExpandedKeys([...defaultExpandedKeys]);
|
|
1185
1106
|
}
|
|
1186
1107
|
}, [defaultCheckedKeys, defaultExpandedKeys]);
|
|
1187
|
-
useEffect(
|
|
1108
|
+
useEffect(() => {
|
|
1188
1109
|
if (checkedKeys) {
|
|
1189
1110
|
//选中keys
|
|
1190
|
-
setInCheckedKeys(
|
|
1111
|
+
setInCheckedKeys([...getCheckedKeys(checkedKeys)]);
|
|
1191
1112
|
halfCheckedKeys.current = getHalfCheckedKeys(checkedKeys);
|
|
1192
1113
|
}
|
|
1193
1114
|
if (expandedKeys) {
|
|
1194
1115
|
//展开keys
|
|
1195
|
-
setInExpandedKeys(
|
|
1116
|
+
setInExpandedKeys([...expandedKeys]);
|
|
1196
1117
|
}
|
|
1197
1118
|
}, [checkedKeys, expandedKeys]);
|
|
1198
|
-
useEffect(
|
|
1119
|
+
useEffect(() => {
|
|
1199
1120
|
if (loadedKeys) {
|
|
1200
1121
|
//loadedKeys
|
|
1201
1122
|
if (loadedKeys.length === 0) {
|
|
1202
1123
|
setInLoadKeys([]);
|
|
1203
1124
|
setInExpandedKeys([]);
|
|
1204
1125
|
} else {
|
|
1205
|
-
setInLoadKeys(
|
|
1126
|
+
setInLoadKeys([...loadedKeys]);
|
|
1206
1127
|
}
|
|
1207
1128
|
}
|
|
1208
1129
|
}, [loadedKeys]);
|
|
1209
|
-
useEffect(
|
|
1130
|
+
useEffect(() => {
|
|
1210
1131
|
//默认展开所有
|
|
1211
1132
|
function _expandAllNode(newTreeData) {
|
|
1212
|
-
|
|
1133
|
+
const keys = [];
|
|
1213
1134
|
function recursive(dataList) {
|
|
1214
|
-
dataList.forEach(
|
|
1135
|
+
dataList.forEach(item => {
|
|
1215
1136
|
var _a;
|
|
1216
1137
|
if ((_a = item.children) === null || _a === void 0 ? void 0 : _a.length) {
|
|
1217
1138
|
keys.push(item.key);
|
|
@@ -1226,51 +1147,51 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
1226
1147
|
}
|
|
1227
1148
|
//tree 初始化
|
|
1228
1149
|
if (Array.isArray(originTreeData)) {
|
|
1229
|
-
|
|
1150
|
+
const newTreeData = formatTreeData(originTreeData);
|
|
1230
1151
|
//本地过滤
|
|
1231
1152
|
if (localFilter) treeOriDataRef.current = deepCopy(newTreeData);
|
|
1232
1153
|
if (newProps.defaultExpandAll) {
|
|
1233
1154
|
//默认展开所有
|
|
1234
1155
|
_expandAllNode(newTreeData);
|
|
1235
1156
|
}
|
|
1236
|
-
setTreeData(
|
|
1157
|
+
setTreeData([...newTreeData]);
|
|
1237
1158
|
} else {
|
|
1238
1159
|
initTree();
|
|
1239
1160
|
}
|
|
1240
1161
|
}, [url, ctx, params, method, refresh, originTreeData]);
|
|
1241
|
-
useEffect(
|
|
1162
|
+
useEffect(() => {
|
|
1242
1163
|
//过滤数据
|
|
1243
|
-
function _filterData(
|
|
1244
|
-
|
|
1245
|
-
|
|
1164
|
+
function _filterData(_ref) {
|
|
1165
|
+
let {
|
|
1166
|
+
searchKey,
|
|
1167
|
+
searchValue
|
|
1168
|
+
} = _ref;
|
|
1246
1169
|
if (!searchKey) return;
|
|
1247
1170
|
if (searchValue === '') {
|
|
1248
1171
|
setTreeData(treeOriDataRef.current);
|
|
1249
|
-
|
|
1250
|
-
setInExpandedKeys(
|
|
1172
|
+
const tKeys = expandedKeys || defaultExpandedKeys;
|
|
1173
|
+
setInExpandedKeys([...(tKeys || [])]);
|
|
1251
1174
|
return;
|
|
1252
1175
|
}
|
|
1253
|
-
|
|
1176
|
+
const flatData = flatten(treeOriDataRef.current);
|
|
1254
1177
|
//匹配数据
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1178
|
+
const filterTreeData = flatData.reduce((acc, curr) => {
|
|
1179
|
+
const title = String(curr[searchKey]).toLowerCase();
|
|
1180
|
+
const isMatch = title.includes(searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase());
|
|
1258
1181
|
return isMatch ? acc.concat(curr) : acc;
|
|
1259
1182
|
}, []);
|
|
1260
|
-
|
|
1183
|
+
const newTreeData = convertByFilter(deepCopy(flatData), filterTreeData);
|
|
1261
1184
|
setTreeData(newTreeData);
|
|
1262
1185
|
setInExpandedKeys(_handleExpendKey(newTreeData));
|
|
1263
1186
|
}
|
|
1264
1187
|
//处理展开key
|
|
1265
1188
|
function _handleExpendKey(list) {
|
|
1266
|
-
return list.reduce(
|
|
1267
|
-
return acc.concat(curr.key, _handleExpendKey(curr.children || []));
|
|
1268
|
-
}, []);
|
|
1189
|
+
return list.reduce((acc, curr) => acc.concat(curr.key, _handleExpendKey(curr.children || [])), []);
|
|
1269
1190
|
}
|
|
1270
1191
|
if (localFilter) {
|
|
1271
1192
|
//开启本地过滤
|
|
1272
1193
|
if (onFilter) {
|
|
1273
|
-
|
|
1194
|
+
const fData = onFilter(treeOriDataRef.current);
|
|
1274
1195
|
if (!fData) return;
|
|
1275
1196
|
setTreeData(fData);
|
|
1276
1197
|
return;
|
|
@@ -1279,7 +1200,7 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
1279
1200
|
}
|
|
1280
1201
|
}, [localFilter, localParams]);
|
|
1281
1202
|
//渲染空状态
|
|
1282
|
-
|
|
1203
|
+
const renderEmpty = jsx("div", Object.assign({
|
|
1283
1204
|
className: clsx("".concat($prefixCls, "-tree ").concat($prefixCls, "-tree-empty"), className, emptyClassName),
|
|
1284
1205
|
style: props.style
|
|
1285
1206
|
}, {
|
|
@@ -1288,14 +1209,14 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
1288
1209
|
}, emptyProps))
|
|
1289
1210
|
}));
|
|
1290
1211
|
//tree memo
|
|
1291
|
-
|
|
1212
|
+
const treeMemo = useMemo(() => {
|
|
1292
1213
|
if (!(treeData === null || treeData === void 0 ? void 0 : treeData.length) && firstRender.current) {
|
|
1293
1214
|
firstRender.current = false;
|
|
1294
1215
|
return null;
|
|
1295
1216
|
} else if (!(treeData === null || treeData === void 0 ? void 0 : treeData.length)) {
|
|
1296
1217
|
return !loading ? renderEmpty : null;
|
|
1297
1218
|
}
|
|
1298
|
-
|
|
1219
|
+
let tCheckedKeys = inCheckedKeys;
|
|
1299
1220
|
if (checkStrictly) {
|
|
1300
1221
|
tCheckedKeys = {
|
|
1301
1222
|
checked: inCheckedKeys,
|
|
@@ -1312,9 +1233,7 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
1312
1233
|
className: "".concat(prefixCls, "-checkbox-inner")
|
|
1313
1234
|
}) : checkable,
|
|
1314
1235
|
selectable: radioable ? false : selectable,
|
|
1315
|
-
switcherIcon:
|
|
1316
|
-
return renderSwitcherIcon(prefixCls, _switcherIcon, showLine, nodeProps);
|
|
1317
|
-
}
|
|
1236
|
+
switcherIcon: nodeProps => renderSwitcherIcon(prefixCls, switcherIcon, showLine, nodeProps)
|
|
1318
1237
|
}, getAdditionProps(), {
|
|
1319
1238
|
treeData: treeData,
|
|
1320
1239
|
checkedKeys: tCheckedKeys,
|
|
@@ -1322,9 +1241,9 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
1322
1241
|
loadedKeys: inLoadedKeys,
|
|
1323
1242
|
onCheck: internalCheck,
|
|
1324
1243
|
onExpand: internalExpand,
|
|
1325
|
-
icon:
|
|
1326
|
-
if (
|
|
1327
|
-
return typeof
|
|
1244
|
+
icon: nodeProps => {
|
|
1245
|
+
if (icon) {
|
|
1246
|
+
return typeof icon === 'function' ? icon(nodeProps) : icon;
|
|
1328
1247
|
}
|
|
1329
1248
|
if (nodeProps.checkable === false) return null;
|
|
1330
1249
|
if (!radioable) {
|
|
@@ -1335,7 +1254,7 @@ var Tree = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
1335
1254
|
}));
|
|
1336
1255
|
}, [treeData, inCheckedKeys, inExpandedKeysKeys, newProps.selectedKeys, inLoadedKeys]);
|
|
1337
1256
|
//OperateBar render
|
|
1338
|
-
|
|
1257
|
+
const renderOperateBar = () => {
|
|
1339
1258
|
return !!showActions ? jsx(OperateBar, {
|
|
1340
1259
|
opRef: opRef,
|
|
1341
1260
|
mouseInRef: mouseInSectorRef,
|