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