@zat-design/sisyphus-react 3.0.13 → 3.0.16-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.css +2726 -1876
- package/es/ProDownload/DownloadHelper.js +2 -0
- package/es/ProDrawerForm/components/ProDrawer/index.js +5 -3
- package/es/ProDrawerForm/components/ProModal/index.js +15 -5
- package/es/ProDrawerForm/index.js +1 -1
- package/es/ProDrawerForm/propsType.d.ts +4 -0
- package/es/ProDrawerForm/style/index.less +88 -55
- package/es/ProEditLabel/components/RenderProForm.d.ts +4 -0
- package/es/ProEditLabel/components/RenderProForm.js +70 -0
- package/es/ProEditLabel/index.js +104 -141
- package/es/ProEditLabel/propsType.d.ts +7 -4
- package/es/ProEditLabel/style/index.less +33 -2
- package/es/ProEditLabel/utils/index.d.ts +5 -7
- package/es/ProEditLabel/utils/index.js +11 -27
- package/es/ProEditTable/components/ActionButton/index.d.ts +2 -1
- package/es/ProEditTable/components/ActionButton/index.js +20 -4
- package/es/ProEditTable/components/RenderField/index.d.ts +2 -1
- package/es/ProEditTable/components/RenderField/index.js +1 -2
- package/es/ProEditTable/components/RenderToolbar/index.d.ts +2 -1
- package/es/ProEditTable/components/Summary/index.d.ts +2 -1
- package/es/ProEditTable/propsType.d.ts +5 -0
- package/es/ProEditTable/style/index.less +16 -13
- package/es/ProEditTable/utils/config.d.ts +2 -1
- package/es/ProEditTable/utils/config.js +25 -14
- package/es/ProEditTable/utils/index.js +5 -3
- package/es/ProEnum/getEnumLabel.d.ts +2 -1
- package/es/ProEnum/index.d.ts +3 -2
- package/es/ProEnum/useEnumRequest.js +6 -11
- package/es/ProForm/components/base/DatePicker/index.js +1 -1
- package/es/ProForm/components/base/FormList/components/ActionButton.js +4 -5
- package/es/ProForm/components/base/FormList/index.d.ts +1 -0
- package/es/ProForm/components/base/FormList/index.js +10 -5
- package/es/ProForm/components/base/FormList/style/index.less +3 -0
- package/es/ProForm/components/base/Input/index.d.ts +2 -1
- package/es/ProForm/components/base/InputNumber/index.js +24 -0
- package/es/ProForm/components/base/RangePicker/index.js +2 -2
- package/es/ProForm/components/combination/ProAddressBar/index.d.ts +1 -1
- package/es/ProForm/components/combination/ProAddressBar/index.js +2 -1
- package/es/ProForm/components/combination/ProCombination/index.js +3 -3
- package/es/ProForm/components/combination/ProModalSelect/index.d.ts +1 -1
- package/es/ProForm/components/combination/ProModalSelect/index.js +3 -2
- package/es/ProForm/components/combination/ProModalSelect/propsType.d.ts +7 -6
- package/es/ProForm/components/combination/ProModalSelect/style/index.less +45 -36
- package/es/ProForm/components/combination/ProRangeLimit/index.js +13 -15
- package/es/ProForm/components/combination/ProTimeLimit/index.d.ts +1 -1
- package/es/ProForm/components/index.d.ts +2 -0
- package/es/ProForm/components/index.js +2 -0
- package/es/ProForm/components/old/CertNo/index.d.ts +2 -1
- package/es/ProForm/components/old/InputRange/index.d.ts +2 -1
- package/es/ProForm/components/old/InputWithSuffix/index.d.ts +2 -1
- package/es/ProForm/components/old/ProAddress/index.d.ts +2 -1
- package/es/ProForm/components/old/ProCertValidity/index.js +1 -1
- package/es/ProForm/components/old/ProRangeBox/index.d.ts +2 -1
- package/es/ProForm/components/render/Render.js +6 -22
- package/es/ProForm/components/render/propsType.d.ts +4 -0
- package/es/ProForm/index.js +3 -1
- package/es/ProForm/style/index.less +12 -5
- package/es/ProForm/utils/index.d.ts +5 -2
- package/es/ProForm/utils/index.js +7 -12
- package/es/ProForm/utils/transformValue.js +4 -2
- package/es/ProForm/utils/useShouldUpdate.js +1 -0
- package/es/ProForm/utils/valueType.d.ts +4 -4
- package/es/ProIcon/index.d.ts +1 -0
- package/es/ProIcon/index.js +35 -5
- package/es/ProIcon/propsTypes.d.ts +9 -9
- package/es/ProIcon/symbolIcon.js +43 -0
- package/es/ProLayout/components/Layout/Header/style/index.less +1 -2
- package/es/ProLayout/components/Layout/Menu/OpenMenu/index.d.ts +2 -1
- package/es/ProLayout/components/Layout/Menu/OpenMenu/index.js +1 -1
- package/es/ProLayout/components/Layout/Menu/OpenMenu/style/index.less +3 -0
- package/es/ProLayout/components/ProCollapse/index.d.ts +2 -1
- package/es/ProLayout/components/ProCollapse/style/index.less +1 -0
- package/es/ProLayout/components/ProFooter/index.d.ts +1 -1
- package/es/ProLayout/components/ProHeader/components/Copy/index.d.ts +2 -1
- package/es/ProLayout/components/ProHeader/index.d.ts +1 -1
- package/es/ProLayout/components/ProHeader/index.js +2 -4
- package/es/ProLayout/components/ProHeader/style/index.less +3 -3
- package/es/ProLayout/index.d.ts +4 -4
- package/es/ProLayout/index.js +5 -6
- package/es/ProLayout/propTypes.d.ts +2 -5
- package/es/ProLayout/style/index.less +7 -1
- package/es/ProSelect/index.d.ts +1 -1
- package/es/ProSelect/index.js +1 -1
- package/es/ProSelect/propsType.d.ts +7 -0
- package/es/ProStep/components/Anchor/index.d.ts +2 -1
- package/es/ProStep/components/Item/index.d.ts +2 -1
- package/es/ProStep/components/Step/index.d.ts +2 -1
- package/es/ProStep/components/Step/index.js +12 -10
- package/es/ProStep/index.d.ts +2 -2
- package/es/ProStep/style/index.less +1 -1
- package/es/ProTable/components/ResizableLine/index.d.ts +2 -1
- package/es/ProTable/components/TableResizable/index.d.ts +2 -1
- package/es/ProTable/index.d.ts +1 -1
- package/es/ProTable/index.js +1 -1
- package/es/ProTable/propsType.d.ts +3 -2
- package/es/ProTable/style/index.less +12 -17
- package/es/ProTable/useAntdTable.d.ts +4 -4
- package/es/ProTable/useAntdTable.js +54 -34
- package/es/ProTable/utils.js +24 -5
- package/es/ProTabs/components/Card/index.d.ts +4 -0
- package/es/ProTabs/components/Card/index.js +24 -0
- package/es/ProTabs/components/index.d.ts +1 -0
- package/es/ProTabs/components/index.js +1 -0
- package/es/ProTabs/index.d.ts +4 -0
- package/es/ProTabs/index.js +98 -0
- package/es/ProTabs/propType.d.ts +31 -0
- package/es/ProTabs/propType.js +1 -0
- package/es/ProTabs/style/index.less +68 -0
- package/es/ProThemeTools/component/PrdTools/index.d.ts +4 -0
- package/es/ProThemeTools/component/PrdTools/index.js +200 -0
- package/es/ProThemeTools/component/PrdTools/style/index.less +164 -0
- package/es/ProThemeTools/component/index.d.ts +2 -0
- package/es/ProThemeTools/component/index.js +2 -0
- package/es/ProThemeTools/index.d.ts +14 -0
- package/es/ProThemeTools/index.js +179 -0
- package/es/ProThemeTools/propsType.d.ts +30 -0
- package/es/ProThemeTools/propsType.js +1 -0
- package/es/ProThemeTools/style/index.less +55 -0
- package/es/ProThemeTools/utils/index.d.ts +14 -0
- package/es/ProThemeTools/utils/index.js +54 -0
- package/es/ProTooltip/index.d.ts +2 -1
- package/es/ProTransferModal/components/SortableItem/index.js +2 -2
- package/es/ProTransferModal/style/index.less +9 -1
- package/es/ProTreeModal/components/CloseIcon.d.ts +3 -0
- package/es/ProTreeModal/components/CloseIcon.js +25 -0
- package/es/ProTreeModal/components/List.d.ts +13 -0
- package/es/ProTreeModal/components/List.js +52 -0
- package/es/ProTreeModal/components/SearchTitle.d.ts +7 -0
- package/es/ProTreeModal/components/SearchTitle.js +14 -0
- package/es/ProTreeModal/components/Tree.d.ts +15 -0
- package/es/ProTreeModal/components/Tree.js +149 -0
- package/es/ProTreeModal/components/Trigger.d.ts +10 -0
- package/es/ProTreeModal/components/Trigger.js +32 -0
- package/es/ProTreeModal/components/index.d.ts +5 -0
- package/es/ProTreeModal/components/index.js +5 -0
- package/es/ProTreeModal/data/datasource.d.ts +5 -0
- package/es/ProTreeModal/data/datasource.js +17 -0
- package/es/ProTreeModal/data/mock.d.ts +9 -0
- package/es/ProTreeModal/data/mock.js +39 -0
- package/es/ProTreeModal/index.d.ts +5 -0
- package/es/ProTreeModal/index.js +333 -0
- package/es/ProTreeModal/propsType.d.ts +26 -0
- package/es/ProTreeModal/propsType.js +1 -0
- package/es/ProTreeModal/style/index.less +105 -0
- package/es/ProTreeModal/utils.d.ts +26 -0
- package/es/ProTreeModal/utils.js +136 -0
- package/es/ProTreeSelect/index.d.ts +5 -0
- package/es/ProTreeSelect/index.js +404 -0
- package/es/ProTreeSelect/propsType.d.ts +95 -0
- package/es/ProTreeSelect/propsType.js +1 -0
- package/es/ProTreeSelect/style/index.less +109 -0
- package/es/ProUpload/index.d.ts +0 -1
- package/es/ProUpload/index.js +8 -2
- package/es/ProUpload/style/fileItem.less +3 -1
- package/es/ProUpload/style/index.less +8 -1
- package/es/ProWaterMark/index.js +1 -1
- package/es/assets/close.svg +1 -0
- package/es/index.d.ts +3 -0
- package/es/index.js +4 -8
- package/es/old/ProCertValidity/index.js +1 -1
- package/es/style/components.less +25 -9
- package/es/style/theme/antd.less +60 -29
- package/es/style/theme/index.less +154 -176
- package/es/tokens.js +85 -0
- package/lib/ProDrawerForm/components/ProDrawer/index.js +5 -3
- package/lib/ProDrawerForm/components/ProModal/index.js +13 -5
- package/lib/ProDrawerForm/index.js +1 -1
- package/lib/ProDrawerForm/propsType.d.ts +4 -0
- package/lib/ProDrawerForm/style/index.less +88 -55
- package/lib/ProEditLabel/components/RenderProForm.d.ts +4 -0
- package/lib/ProEditLabel/components/RenderProForm.js +78 -0
- package/lib/ProEditLabel/index.js +102 -137
- package/lib/ProEditLabel/propsType.d.ts +7 -4
- package/lib/ProEditLabel/style/index.less +33 -2
- package/lib/ProEditLabel/utils/index.d.ts +5 -7
- package/lib/ProEditLabel/utils/index.js +14 -31
- package/lib/ProEditTable/components/ActionButton/index.d.ts +2 -1
- package/lib/ProEditTable/components/ActionButton/index.js +20 -4
- package/lib/ProEditTable/components/RenderField/index.d.ts +2 -1
- package/lib/ProEditTable/components/RenderField/index.js +3 -2
- package/lib/ProEditTable/components/RenderToolbar/index.d.ts +2 -1
- package/lib/ProEditTable/components/Summary/index.d.ts +2 -1
- package/lib/ProEditTable/propsType.d.ts +5 -0
- package/lib/ProEditTable/style/index.less +16 -13
- package/lib/ProEditTable/utils/config.d.ts +2 -1
- package/lib/ProEditTable/utils/config.js +24 -13
- package/lib/ProEditTable/utils/index.js +5 -3
- package/lib/ProEnum/getEnumLabel.d.ts +2 -1
- package/lib/ProEnum/index.d.ts +3 -2
- package/lib/ProEnum/useEnumRequest.js +6 -11
- package/lib/ProForm/components/base/DatePicker/index.js +1 -1
- package/lib/ProForm/components/base/FormList/components/ActionButton.js +4 -5
- package/lib/ProForm/components/base/FormList/index.d.ts +1 -0
- package/lib/ProForm/components/base/FormList/index.js +10 -5
- package/lib/ProForm/components/base/FormList/style/index.less +3 -0
- package/lib/ProForm/components/base/Input/index.d.ts +2 -1
- package/lib/ProForm/components/base/InputNumber/index.js +24 -0
- package/lib/ProForm/components/base/RangePicker/index.js +2 -2
- package/lib/ProForm/components/combination/ProAddressBar/index.d.ts +1 -1
- package/lib/ProForm/components/combination/ProAddressBar/index.js +2 -1
- package/lib/ProForm/components/combination/ProCombination/index.js +3 -3
- package/lib/ProForm/components/combination/ProModalSelect/index.d.ts +1 -1
- package/lib/ProForm/components/combination/ProModalSelect/index.js +3 -2
- package/lib/ProForm/components/combination/ProModalSelect/propsType.d.ts +7 -6
- package/lib/ProForm/components/combination/ProModalSelect/style/index.less +45 -36
- package/lib/ProForm/components/combination/ProRangeLimit/index.js +13 -15
- package/lib/ProForm/components/combination/ProTimeLimit/index.d.ts +1 -1
- package/lib/ProForm/components/index.d.ts +2 -0
- package/lib/ProForm/components/index.js +14 -0
- package/lib/ProForm/components/old/CertNo/index.d.ts +2 -1
- package/lib/ProForm/components/old/InputRange/index.d.ts +2 -1
- package/lib/ProForm/components/old/InputWithSuffix/index.d.ts +2 -1
- package/lib/ProForm/components/old/ProAddress/index.d.ts +2 -1
- package/lib/ProForm/components/old/ProCertValidity/index.js +1 -1
- package/lib/ProForm/components/old/ProRangeBox/index.d.ts +2 -1
- package/lib/ProForm/components/render/Render.js +4 -20
- package/lib/ProForm/components/render/propsType.d.ts +4 -0
- package/lib/ProForm/index.js +2 -0
- package/lib/ProForm/style/index.less +12 -5
- package/lib/ProForm/utils/index.d.ts +5 -2
- package/lib/ProForm/utils/index.js +10 -14
- package/lib/ProForm/utils/transformValue.js +4 -2
- package/lib/ProForm/utils/useShouldUpdate.js +1 -0
- package/lib/ProForm/utils/valueType.d.ts +4 -4
- package/lib/ProIcon/index.d.ts +1 -0
- package/lib/ProIcon/index.js +36 -5
- package/lib/ProIcon/propsTypes.d.ts +9 -9
- package/lib/ProIcon/symbolIcon.js +45 -0
- package/lib/ProLayout/components/Layout/Header/style/index.less +1 -2
- package/lib/ProLayout/components/Layout/Menu/OpenMenu/index.d.ts +2 -1
- package/lib/ProLayout/components/Layout/Menu/OpenMenu/index.js +1 -1
- package/lib/ProLayout/components/Layout/Menu/OpenMenu/style/index.less +3 -0
- package/lib/ProLayout/components/ProCollapse/index.d.ts +2 -1
- package/lib/ProLayout/components/ProCollapse/style/index.less +1 -0
- package/lib/ProLayout/components/ProFooter/index.d.ts +1 -1
- package/lib/ProLayout/components/ProHeader/components/Copy/index.d.ts +2 -1
- package/lib/ProLayout/components/ProHeader/index.d.ts +1 -1
- package/lib/ProLayout/components/ProHeader/index.js +1 -4
- package/lib/ProLayout/components/ProHeader/style/index.less +3 -3
- package/lib/ProLayout/index.d.ts +4 -4
- package/lib/ProLayout/index.js +5 -6
- package/lib/ProLayout/propTypes.d.ts +2 -5
- package/lib/ProLayout/style/index.less +7 -1
- package/lib/ProSelect/index.d.ts +1 -1
- package/lib/ProSelect/index.js +1 -1
- package/lib/ProSelect/propsType.d.ts +7 -0
- package/lib/ProStep/components/Anchor/index.d.ts +2 -1
- package/lib/ProStep/components/Item/index.d.ts +2 -1
- package/lib/ProStep/components/Step/index.d.ts +2 -1
- package/lib/ProStep/components/Step/index.js +11 -9
- package/lib/ProStep/index.d.ts +2 -2
- package/lib/ProStep/style/index.less +1 -1
- package/lib/ProTable/components/ResizableLine/index.d.ts +2 -1
- package/lib/ProTable/components/TableResizable/index.d.ts +2 -1
- package/lib/ProTable/components/TableResizable/index.js +8 -0
- package/lib/ProTable/index.d.ts +1 -1
- package/lib/ProTable/index.js +1 -1
- package/lib/ProTable/propsType.d.ts +3 -2
- package/lib/ProTable/style/index.less +12 -17
- package/lib/ProTable/useAntdTable.d.ts +4 -4
- package/lib/ProTable/useAntdTable.js +53 -33
- package/lib/ProTable/utils.js +24 -5
- package/lib/ProTabs/components/Card/index.d.ts +4 -0
- package/lib/ProTabs/components/Card/index.js +31 -0
- package/lib/ProTabs/components/index.d.ts +1 -0
- package/lib/ProTabs/components/index.js +13 -0
- package/lib/ProTabs/index.d.ts +4 -0
- package/lib/ProTabs/index.js +106 -0
- package/lib/ProTabs/propType.d.ts +31 -0
- package/lib/ProTabs/propType.js +5 -0
- package/lib/ProTabs/style/index.less +68 -0
- package/lib/ProThemeTools/component/PrdTools/index.d.ts +4 -0
- package/lib/ProThemeTools/component/PrdTools/index.js +202 -0
- package/lib/ProThemeTools/component/PrdTools/style/index.less +164 -0
- package/lib/ProThemeTools/component/index.d.ts +2 -0
- package/lib/ProThemeTools/component/index.js +13 -0
- package/lib/ProThemeTools/index.d.ts +14 -0
- package/lib/ProThemeTools/index.js +185 -0
- package/lib/ProThemeTools/propsType.d.ts +30 -0
- package/lib/ProThemeTools/propsType.js +5 -0
- package/lib/ProThemeTools/style/index.less +55 -0
- package/lib/ProThemeTools/utils/index.d.ts +14 -0
- package/lib/ProThemeTools/utils/index.js +63 -0
- package/lib/ProTooltip/index.d.ts +2 -1
- package/lib/ProTransferModal/components/SortableItem/index.js +2 -2
- package/lib/ProTransferModal/style/index.less +9 -1
- package/lib/ProTreeModal/components/CloseIcon.d.ts +3 -0
- package/lib/ProTreeModal/components/CloseIcon.js +33 -0
- package/lib/ProTreeModal/components/List.d.ts +13 -0
- package/lib/ProTreeModal/components/List.js +59 -0
- package/lib/ProTreeModal/components/SearchTitle.d.ts +7 -0
- package/lib/ProTreeModal/components/SearchTitle.js +22 -0
- package/lib/ProTreeModal/components/Tree.d.ts +15 -0
- package/lib/ProTreeModal/components/Tree.js +157 -0
- package/lib/ProTreeModal/components/Trigger.d.ts +10 -0
- package/lib/ProTreeModal/components/Trigger.js +39 -0
- package/lib/ProTreeModal/components/index.d.ts +5 -0
- package/lib/ProTreeModal/components/index.js +41 -0
- package/lib/ProTreeModal/data/datasource.d.ts +5 -0
- package/lib/ProTreeModal/data/datasource.js +24 -0
- package/lib/ProTreeModal/data/mock.d.ts +9 -0
- package/lib/ProTreeModal/data/mock.js +47 -0
- package/lib/ProTreeModal/index.d.ts +5 -0
- package/lib/ProTreeModal/index.js +340 -0
- package/lib/ProTreeModal/propsType.d.ts +26 -0
- package/lib/ProTreeModal/propsType.js +5 -0
- package/lib/ProTreeModal/style/index.less +105 -0
- package/lib/ProTreeModal/utils.d.ts +26 -0
- package/lib/ProTreeModal/utils.js +148 -0
- package/lib/ProTreeSelect/index.d.ts +5 -0
- package/lib/ProTreeSelect/index.js +411 -0
- package/lib/ProTreeSelect/propsType.d.ts +95 -0
- package/lib/ProTreeSelect/propsType.js +5 -0
- package/lib/ProTreeSelect/style/index.less +109 -0
- package/lib/ProUpload/index.d.ts +0 -1
- package/lib/ProUpload/index.js +8 -2
- package/lib/ProUpload/style/fileItem.less +3 -1
- package/lib/ProUpload/style/index.less +8 -1
- package/lib/ProWaterMark/index.js +1 -1
- package/lib/assets/close.svg +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +28 -0
- package/lib/old/ProCertValidity/index.js +1 -1
- package/lib/style/components.less +25 -9
- package/lib/style/theme/antd.less +60 -29
- package/lib/style/theme/index.less +154 -176
- package/lib/tokens.js +87 -0
- package/package.json +7 -8
- package/typings.d.ts +4 -0
- package/es/ProEditLabel/components/RenderForm.d.ts +0 -3
- package/es/ProEditLabel/components/RenderForm.js +0 -65
- package/lib/ProEditLabel/components/RenderForm.d.ts +0 -3
- package/lib/ProEditLabel/components/RenderForm.js +0 -75
- package/source-code/package.json +0 -16
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import "antd/es/message/style";
|
|
3
|
+
import _message from "antd/es/message";
|
|
4
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
5
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
|
+
import "antd/es/input/style";
|
|
7
|
+
import _Input from "antd/es/input";
|
|
8
|
+
/* eslint-disable jsx-a11y/anchor-is-valid */
|
|
9
|
+
import React, { useEffect } from 'react';
|
|
10
|
+
import { useDeepCompareEffect, useSetState, useRequest as useRequestFunc } from 'ahooks';
|
|
11
|
+
import { ProDrawerForm, useProConfig } from 'zat-design-pro-component';
|
|
12
|
+
import { cloneDeep, isFunction } from 'lodash';
|
|
13
|
+
import { Trigger, ListView, TreeView } from './components';
|
|
14
|
+
import { getFlatTreeData, filterCheckedNodes, getChildrenKeys, findTreeNodeByKey } from './utils';
|
|
15
|
+
import './style/index.less';
|
|
16
|
+
var Search = _Input.Search;
|
|
17
|
+
var ProTreeModal = function ProTreeModal(props) {
|
|
18
|
+
var _useProConfig = useProConfig('ProEnum'),
|
|
19
|
+
_useProConfig$dics = _useProConfig.dics,
|
|
20
|
+
dics = _useProConfig$dics === void 0 ? {} : _useProConfig$dics;
|
|
21
|
+
var value = props.value,
|
|
22
|
+
onChange = props.onChange,
|
|
23
|
+
dataSource = props.dataSource,
|
|
24
|
+
trigger = props.trigger,
|
|
25
|
+
_props$mode = props.mode,
|
|
26
|
+
mode = _props$mode === void 0 ? 'list' : _props$mode,
|
|
27
|
+
enumCode = props.code,
|
|
28
|
+
_props$title = props.title,
|
|
29
|
+
title = _props$title === void 0 ? '请选择' : _props$title,
|
|
30
|
+
useRequest = props.useRequest,
|
|
31
|
+
_props$showCodeName = props.showCodeName,
|
|
32
|
+
showCodeName = _props$showCodeName === void 0 ? false : _props$showCodeName,
|
|
33
|
+
_props$disabled = props.disabled,
|
|
34
|
+
disabled = _props$disabled === void 0 ? !!props.isView || !!props.disabled : _props$disabled,
|
|
35
|
+
transformResponse = props.transformResponse;
|
|
36
|
+
var _useSetState = useSetState({
|
|
37
|
+
open: false,
|
|
38
|
+
checkedValues: [],
|
|
39
|
+
treeData: [],
|
|
40
|
+
treeViewData: [],
|
|
41
|
+
originalTreeData: [],
|
|
42
|
+
flatTreeData: [],
|
|
43
|
+
searchStr: ''
|
|
44
|
+
}),
|
|
45
|
+
_useSetState2 = _slicedToArray(_useSetState, 2),
|
|
46
|
+
state = _useSetState2[0],
|
|
47
|
+
setState = _useSetState2[1];
|
|
48
|
+
var fetchFunction = useRequestFunc(useRequest === null || useRequest === void 0 ? void 0 : useRequest.service, _objectSpread({
|
|
49
|
+
manual: true,
|
|
50
|
+
onSuccess: function onSuccess(res) {
|
|
51
|
+
if (transformResponse && typeof transformResponse === 'function') {
|
|
52
|
+
var responseData = transformResponse(res);
|
|
53
|
+
setState({
|
|
54
|
+
treeData: responseData,
|
|
55
|
+
originalTreeData: responseData,
|
|
56
|
+
flatTreeData: getFlatTreeData(responseData)
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
var _res$status = res.status,
|
|
60
|
+
status = _res$status === void 0 ? 200 : _res$status,
|
|
61
|
+
msg = res.message,
|
|
62
|
+
data = res.data;
|
|
63
|
+
if (status !== 200) {
|
|
64
|
+
_message.error(msg);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
setState({
|
|
68
|
+
treeData: data,
|
|
69
|
+
originalTreeData: data,
|
|
70
|
+
flatTreeData: getFlatTreeData(data)
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
debounceWait: 300
|
|
75
|
+
}, useRequest === null || useRequest === void 0 ? void 0 : useRequest.options));
|
|
76
|
+
useDeepCompareEffect(function () {
|
|
77
|
+
if (dataSource && dataSource.length) {
|
|
78
|
+
setState({
|
|
79
|
+
treeData: dataSource,
|
|
80
|
+
originalTreeData: cloneDeep(dataSource),
|
|
81
|
+
flatTreeData: getFlatTreeData(dataSource)
|
|
82
|
+
});
|
|
83
|
+
} else if (enumCode) {
|
|
84
|
+
var dictEnum = dics[enumCode] || [];
|
|
85
|
+
// transform dictEnum
|
|
86
|
+
if (transformResponse && isFunction(transformResponse)) {
|
|
87
|
+
dictEnum = transformResponse(dictEnum);
|
|
88
|
+
}
|
|
89
|
+
// check dictEnum isArray
|
|
90
|
+
if (!dictEnum || !Array.isArray(dictEnum)) {
|
|
91
|
+
console.error('请返回有效的数组');
|
|
92
|
+
dictEnum = [];
|
|
93
|
+
}
|
|
94
|
+
setState({
|
|
95
|
+
treeData: dictEnum,
|
|
96
|
+
originalTreeData: cloneDeep(dictEnum),
|
|
97
|
+
flatTreeData: getFlatTreeData(dictEnum)
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}, [dataSource, enumCode]);
|
|
101
|
+
useDeepCompareEffect(function () {
|
|
102
|
+
if (enumCode) {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
if (dataSource) {
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
var _ref = (useRequest === null || useRequest === void 0 ? void 0 : useRequest.options) || {},
|
|
109
|
+
defaultParams = _ref.defaultParams,
|
|
110
|
+
manual = _ref.manual;
|
|
111
|
+
if (manual) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
// 执行用户配置的枚举服务,拉取枚举数据进行更新
|
|
115
|
+
fetchFunction.run(defaultParams);
|
|
116
|
+
}, [useRequest === null || useRequest === void 0 ? void 0 : useRequest.options]);
|
|
117
|
+
useEffect(function () {
|
|
118
|
+
setState({
|
|
119
|
+
checkedValues: value || []
|
|
120
|
+
});
|
|
121
|
+
}, [value]);
|
|
122
|
+
var handleClick = function handleClick() {
|
|
123
|
+
setState({
|
|
124
|
+
open: true
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
var handleClearValue = function handleClearValue() {};
|
|
128
|
+
/**
|
|
129
|
+
* close Drawer and onChange(values)
|
|
130
|
+
*/
|
|
131
|
+
var handleFinish = function handleFinish() {
|
|
132
|
+
onChange && onChange(state.checkedValues);
|
|
133
|
+
setState({
|
|
134
|
+
open: false
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Drawer close
|
|
139
|
+
*/
|
|
140
|
+
var handleClose = function handleClose() {
|
|
141
|
+
setState({
|
|
142
|
+
open: false
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* checkbox/tree selected change values
|
|
147
|
+
* @param values
|
|
148
|
+
*/
|
|
149
|
+
var handleOnChange = function handleOnChange(e, code) {
|
|
150
|
+
var checkedValues = _toConsumableArray(state.checkedValues);
|
|
151
|
+
var checked = e.target.checked;
|
|
152
|
+
if (!checked) {
|
|
153
|
+
checkedValues = checkedValues.filter(function (value) {
|
|
154
|
+
return value !== code;
|
|
155
|
+
});
|
|
156
|
+
} else {
|
|
157
|
+
checkedValues.push(code);
|
|
158
|
+
}
|
|
159
|
+
setState({
|
|
160
|
+
checkedValues: checkedValues
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
var onCheck = function onCheck(checkedKeys, info) {
|
|
164
|
+
var checkedValues = _toConsumableArray(state.checkedValues);
|
|
165
|
+
// 此时应该取消掉自身并包含它所有的子集
|
|
166
|
+
if (!info.checked) {
|
|
167
|
+
checkedValues = checkedValues.filter(function (key) {
|
|
168
|
+
return key !== info.node.key && !info.halfCheckedKeys.includes(key);
|
|
169
|
+
});
|
|
170
|
+
// 把所有的子节点也要取消
|
|
171
|
+
var childrenkeys = [];
|
|
172
|
+
getChildrenKeys(info.node, childrenkeys);
|
|
173
|
+
checkedValues = checkedValues.filter(function (key) {
|
|
174
|
+
return !childrenkeys.includes(key);
|
|
175
|
+
});
|
|
176
|
+
} else {
|
|
177
|
+
checkedKeys.forEach(function (key) {
|
|
178
|
+
var exist = checkedValues.includes(key);
|
|
179
|
+
if (info.checked && !exist) {
|
|
180
|
+
checkedValues.push(key);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
// 根据选中的筛选出 viewTreeData
|
|
185
|
+
var originalTreeData = state.originalTreeData;
|
|
186
|
+
var treeViewData = filterCheckedNodes(originalTreeData, checkedValues);
|
|
187
|
+
setState({
|
|
188
|
+
checkedValues: checkedValues,
|
|
189
|
+
treeViewData: treeViewData
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* filter checkbox by fileNameValue
|
|
194
|
+
* @param fileNameValue
|
|
195
|
+
*/
|
|
196
|
+
var handleFilterClose = function handleFilterClose(fileNameValue) {
|
|
197
|
+
setState({
|
|
198
|
+
checkedValues: state.checkedValues.filter(function (value) {
|
|
199
|
+
return value !== fileNameValue;
|
|
200
|
+
})
|
|
201
|
+
});
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* tree close
|
|
205
|
+
* @param fileNamekey
|
|
206
|
+
* @param node
|
|
207
|
+
*/
|
|
208
|
+
var treeFilterClose = function treeFilterClose(fileNamekey, node) {
|
|
209
|
+
var checkedValues = _toConsumableArray(state.checkedValues);
|
|
210
|
+
var originalTreeData = state.originalTreeData;
|
|
211
|
+
// 1. 取消自身
|
|
212
|
+
// checkedValues = checkedValues.filter((key) => key !== fileNamekey);
|
|
213
|
+
// 2. 把所有的子节点也要取消
|
|
214
|
+
var childrenkeys = [];
|
|
215
|
+
getChildrenKeys(node, childrenkeys);
|
|
216
|
+
checkedValues = checkedValues.filter(function (key) {
|
|
217
|
+
return !childrenkeys.includes(key);
|
|
218
|
+
});
|
|
219
|
+
// 3. 取消父节点
|
|
220
|
+
var parentNodes = findTreeNodeByKey(originalTreeData, fileNamekey);
|
|
221
|
+
var parentKeys = parentNodes.reduce(function (prev, curr) {
|
|
222
|
+
return prev.concat(curr.key);
|
|
223
|
+
}, []);
|
|
224
|
+
checkedValues = checkedValues.filter(function (key) {
|
|
225
|
+
return !parentKeys.includes(key);
|
|
226
|
+
});
|
|
227
|
+
// 根据选中的筛选出 viewTreeData
|
|
228
|
+
var treeViewData = filterCheckedNodes(originalTreeData, checkedValues);
|
|
229
|
+
setState({
|
|
230
|
+
checkedValues: checkedValues,
|
|
231
|
+
treeViewData: treeViewData
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* clear all checked
|
|
236
|
+
*/
|
|
237
|
+
var handleClearAll = function handleClearAll() {
|
|
238
|
+
setState({
|
|
239
|
+
checkedValues: [],
|
|
240
|
+
treeViewData: []
|
|
241
|
+
});
|
|
242
|
+
};
|
|
243
|
+
var onSearch = function onSearch(str) {
|
|
244
|
+
if (mode === 'list') {
|
|
245
|
+
var data = state.originalTreeData.filter(function (item) {
|
|
246
|
+
return item.title.includes(str);
|
|
247
|
+
});
|
|
248
|
+
setState({
|
|
249
|
+
searchStr: str,
|
|
250
|
+
treeData: data
|
|
251
|
+
});
|
|
252
|
+
} else {
|
|
253
|
+
setState({
|
|
254
|
+
searchStr: str
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* Trigger the container opened by Drawer
|
|
260
|
+
* default example and you can customize trigger={<Button>打开</Button>}
|
|
261
|
+
* @returns
|
|
262
|
+
*/
|
|
263
|
+
var renderTrigger = function renderTrigger() {
|
|
264
|
+
if (trigger && /*#__PURE__*/React.isValidElement(trigger)) {
|
|
265
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
266
|
+
onClick: handleClick
|
|
267
|
+
}, trigger);
|
|
268
|
+
}
|
|
269
|
+
return /*#__PURE__*/React.createElement(Trigger, {
|
|
270
|
+
checkedValues: state.checkedValues,
|
|
271
|
+
value: value,
|
|
272
|
+
handleClick: handleClick,
|
|
273
|
+
handleClearAll: handleClearAll
|
|
274
|
+
});
|
|
275
|
+
};
|
|
276
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
277
|
+
className: "pro-tree-modal"
|
|
278
|
+
}, renderTrigger(), /*#__PURE__*/React.createElement(ProDrawerForm, {
|
|
279
|
+
onOk: handleFinish,
|
|
280
|
+
onCancel: handleClose,
|
|
281
|
+
open: state.open,
|
|
282
|
+
title: title,
|
|
283
|
+
showType: "Modal"
|
|
284
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
285
|
+
className: "pro-tree-modal-content"
|
|
286
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
287
|
+
className: "pro-tree-modal-box"
|
|
288
|
+
}, /*#__PURE__*/React.createElement(Search, {
|
|
289
|
+
disabled: disabled,
|
|
290
|
+
allowClear: true,
|
|
291
|
+
className: "pro-tree-modal-search",
|
|
292
|
+
onSearch: onSearch
|
|
293
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
294
|
+
className: "pro-tree-modal-tree-warp"
|
|
295
|
+
}, mode === 'list' ? /*#__PURE__*/React.createElement(ListView, {
|
|
296
|
+
treeData: state.treeData,
|
|
297
|
+
checkedValues: state.checkedValues,
|
|
298
|
+
handleOnChange: handleOnChange,
|
|
299
|
+
searchStr: state.searchStr,
|
|
300
|
+
showCodeName: showCodeName,
|
|
301
|
+
disabled: disabled
|
|
302
|
+
}) : /*#__PURE__*/React.createElement(TreeView, {
|
|
303
|
+
treeData: state.treeData,
|
|
304
|
+
originalTreeData: state.originalTreeData,
|
|
305
|
+
flatTreeData: state.flatTreeData,
|
|
306
|
+
checkedValues: state.checkedValues,
|
|
307
|
+
onCheck: onCheck,
|
|
308
|
+
searchStr: state.searchStr,
|
|
309
|
+
showCodeName: showCodeName,
|
|
310
|
+
disabled: disabled
|
|
311
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
312
|
+
className: "pro-tree-modal-box"
|
|
313
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
314
|
+
className: "pro-tree-modal-box-header"
|
|
315
|
+
}, /*#__PURE__*/React.createElement("span", null, "\u5DF2\u9009 (", state.checkedValues.length, ") "), /*#__PURE__*/React.createElement("a", {
|
|
316
|
+
onClick: handleClearAll
|
|
317
|
+
}, "\u6E05\u7A7A\u5168\u90E8")), /*#__PURE__*/React.createElement("div", {
|
|
318
|
+
className: "pro-tree-modal-tree-warp"
|
|
319
|
+
}, mode === 'list' ? /*#__PURE__*/React.createElement(ListView, {
|
|
320
|
+
mode: "view",
|
|
321
|
+
showCodeName: showCodeName,
|
|
322
|
+
treeData: state.originalTreeData.filter(function (item) {
|
|
323
|
+
return state.checkedValues.includes(item.value);
|
|
324
|
+
}),
|
|
325
|
+
handleFilterClose: handleFilterClose
|
|
326
|
+
}) : /*#__PURE__*/React.createElement(TreeView, {
|
|
327
|
+
mode: "view",
|
|
328
|
+
showCodeName: showCodeName,
|
|
329
|
+
treeData: state.treeViewData,
|
|
330
|
+
handleFilterClose: treeFilterClose
|
|
331
|
+
}))))));
|
|
332
|
+
};
|
|
333
|
+
export default ProTreeModal;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Service, Options } from 'ahooks/lib/useRequest/src/types';
|
|
3
|
+
export interface ProTreeModalProps {
|
|
4
|
+
value?: string[];
|
|
5
|
+
open: boolean;
|
|
6
|
+
mode?: 'tree' | 'list';
|
|
7
|
+
isView?: string;
|
|
8
|
+
code?: string;
|
|
9
|
+
trigger: string | ReactNode;
|
|
10
|
+
showCodeName?: boolean;
|
|
11
|
+
dataSource: any[];
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
readOnly?: boolean;
|
|
14
|
+
title?: string | ReactNode;
|
|
15
|
+
checkStrictly?: boolean;
|
|
16
|
+
onChange?: (values: string[]) => void;
|
|
17
|
+
/** 自定义展示 */
|
|
18
|
+
optionRender: (item: any) => string | ReactNode;
|
|
19
|
+
/** 对后台返回数据进行格式化 */
|
|
20
|
+
transformResponse?: (data: any) => any[];
|
|
21
|
+
/** 远程请求接口 */
|
|
22
|
+
useRequest?: {
|
|
23
|
+
service: Service<any, any>;
|
|
24
|
+
options?: Options<any, any>;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
.pro-modal .ant-modal-body {
|
|
2
|
+
max-height: 100%;
|
|
3
|
+
}
|
|
4
|
+
.pro-tree-modal {
|
|
5
|
+
.ant-input-group-wrapper {
|
|
6
|
+
.ant-input-suffix {
|
|
7
|
+
display: none;
|
|
8
|
+
}
|
|
9
|
+
&:hover .ant-input-suffix {
|
|
10
|
+
display: block;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
&-placeholder {
|
|
14
|
+
color: #939499;
|
|
15
|
+
}
|
|
16
|
+
&-content {
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: row;
|
|
19
|
+
height: 482px;
|
|
20
|
+
|
|
21
|
+
.ant-tree-checkbox {
|
|
22
|
+
margin-top: 2px;
|
|
23
|
+
}
|
|
24
|
+
.ant-tree-switcher {
|
|
25
|
+
width: 20px;
|
|
26
|
+
line-height: 20px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.ant-tree-treenode {
|
|
30
|
+
width: 100%;
|
|
31
|
+
padding: 0;
|
|
32
|
+
padding-bottom: 12px;
|
|
33
|
+
color: var(--zaui-text);
|
|
34
|
+
font-size: var(--zaui-font-size);
|
|
35
|
+
font-family: PingFangSC-Regular, PingFang SC;
|
|
36
|
+
line-height: 20px;
|
|
37
|
+
}
|
|
38
|
+
.ant-tree-node-content-wrapper {
|
|
39
|
+
min-height: 20px;
|
|
40
|
+
line-height: 20px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.ant-tree-node-content-wrapper {
|
|
44
|
+
width: 100%;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
&-box {
|
|
48
|
+
width: 456px;
|
|
49
|
+
height: 100%;
|
|
50
|
+
overflow-y: auto;
|
|
51
|
+
color: var(--zaui-text);
|
|
52
|
+
font-size: var(--zaui-font-size);
|
|
53
|
+
font-family: PingFangSC-Regular, PingFang SC;
|
|
54
|
+
line-height: 20px;
|
|
55
|
+
border: 1px solid #e6e6e6;
|
|
56
|
+
border-radius: 5px;
|
|
57
|
+
&:first-child {
|
|
58
|
+
margin-right: var(--zaui-space-size-md);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&-search {
|
|
63
|
+
padding: var(--zaui-space-size-sm);
|
|
64
|
+
padding-bottom: 0;
|
|
65
|
+
}
|
|
66
|
+
&-box-header {
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
justify-content: space-between;
|
|
70
|
+
height: 40px;
|
|
71
|
+
padding: 0 12px;
|
|
72
|
+
background: #fafafa;
|
|
73
|
+
span {
|
|
74
|
+
color: #616161;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&-tree-warp {
|
|
79
|
+
margin: var(--zaui-space-size-md);
|
|
80
|
+
}
|
|
81
|
+
&-checkbox-content {
|
|
82
|
+
display: flex;
|
|
83
|
+
flex-direction: row;
|
|
84
|
+
align-items: center;
|
|
85
|
+
justify-content: space-between;
|
|
86
|
+
margin-bottom: 12px;
|
|
87
|
+
line-height: 20px;
|
|
88
|
+
cursor: pointer;
|
|
89
|
+
&-look {
|
|
90
|
+
color: #333;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
&-tree-content {
|
|
95
|
+
margin-bottom: 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
&-search-value {
|
|
99
|
+
color: var(--zaui-brand);
|
|
100
|
+
}
|
|
101
|
+
&-checkbox-close {
|
|
102
|
+
padding-left: var(--zaui-space-size-sm);
|
|
103
|
+
font-size: 12px;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare function getFlatTreeData(originalTreeData: any[]): any[];
|
|
2
|
+
export declare const getParentKey: (key: string, tree: any[]) => string;
|
|
3
|
+
interface TreeNode {
|
|
4
|
+
title: string;
|
|
5
|
+
key: string;
|
|
6
|
+
children?: TreeNode[];
|
|
7
|
+
}
|
|
8
|
+
export declare function findTreeNodeByKey(treeData: TreeNode[], key: string): TreeNode[];
|
|
9
|
+
/**
|
|
10
|
+
* 根据所选的 checkedKeys 筛选出展示的 treeData
|
|
11
|
+
* @param data
|
|
12
|
+
* @param checkedKeys
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export declare function filterCheckedNodes(data: any, checkedKeys: any): any[];
|
|
16
|
+
/**
|
|
17
|
+
* 获取 tree 当前选中节点下的所有子节点的 keys
|
|
18
|
+
* @param node
|
|
19
|
+
* @param childrenKeys
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
export declare function getChildrenKeys<T extends {
|
|
23
|
+
key: string;
|
|
24
|
+
children?: T[];
|
|
25
|
+
}>(node: T, childrenKeys: string[]): string[];
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
3
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
4
|
+
/* eslint-disable no-restricted-syntax */
|
|
5
|
+
export function getFlatTreeData(originalTreeData) {
|
|
6
|
+
var dataList = [];
|
|
7
|
+
function loop(data) {
|
|
8
|
+
for (var i = 0; i < data.length; i++) {
|
|
9
|
+
var node = data[i];
|
|
10
|
+
var value = node.value,
|
|
11
|
+
key = node.key,
|
|
12
|
+
title = node.title;
|
|
13
|
+
dataList.push({
|
|
14
|
+
key: key || value,
|
|
15
|
+
title: title
|
|
16
|
+
});
|
|
17
|
+
if (node.children) {
|
|
18
|
+
loop(node.children);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
loop(originalTreeData);
|
|
23
|
+
return dataList;
|
|
24
|
+
}
|
|
25
|
+
export var getParentKey = function getParentKey(key, tree) {
|
|
26
|
+
var parentKey;
|
|
27
|
+
for (var i = 0; i < tree.length; i++) {
|
|
28
|
+
var node = tree[i];
|
|
29
|
+
if (node.children) {
|
|
30
|
+
if (node.children.some(function (item) {
|
|
31
|
+
return item.key === key;
|
|
32
|
+
})) {
|
|
33
|
+
parentKey = node.key;
|
|
34
|
+
} else if (getParentKey(key, node.children)) {
|
|
35
|
+
parentKey = getParentKey(key, node.children);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return parentKey;
|
|
40
|
+
};
|
|
41
|
+
export function findTreeNodeByKey(treeData, key) {
|
|
42
|
+
var result = [];
|
|
43
|
+
var traverse = function traverse(node, parents) {
|
|
44
|
+
if (node.key === key) {
|
|
45
|
+
result.push.apply(result, [node].concat(_toConsumableArray(parents)));
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
var children = node.children || [];
|
|
49
|
+
var _iterator = _createForOfIteratorHelper(children),
|
|
50
|
+
_step;
|
|
51
|
+
try {
|
|
52
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
53
|
+
var child = _step.value;
|
|
54
|
+
if (traverse(child, [node].concat(_toConsumableArray(parents)))) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
} catch (err) {
|
|
59
|
+
_iterator.e(err);
|
|
60
|
+
} finally {
|
|
61
|
+
_iterator.f();
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
};
|
|
65
|
+
var _iterator2 = _createForOfIteratorHelper(treeData),
|
|
66
|
+
_step2;
|
|
67
|
+
try {
|
|
68
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
69
|
+
var node = _step2.value;
|
|
70
|
+
traverse(node, []);
|
|
71
|
+
}
|
|
72
|
+
} catch (err) {
|
|
73
|
+
_iterator2.e(err);
|
|
74
|
+
} finally {
|
|
75
|
+
_iterator2.f();
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* 根据所选的 checkedKeys 筛选出展示的 treeData
|
|
81
|
+
* @param data
|
|
82
|
+
* @param checkedKeys
|
|
83
|
+
* @returns
|
|
84
|
+
*/
|
|
85
|
+
export function filterCheckedNodes(data, checkedKeys) {
|
|
86
|
+
var result = [];
|
|
87
|
+
var traverse = function traverse(node) {
|
|
88
|
+
var _node$children2;
|
|
89
|
+
if (checkedKeys.includes(node.key)) {
|
|
90
|
+
var _node$children;
|
|
91
|
+
var _children = ((_node$children = node.children) === null || _node$children === void 0 ? void 0 : _node$children.map(traverse).filter(Boolean)) || [];
|
|
92
|
+
return _objectSpread(_objectSpread({}, node), {}, {
|
|
93
|
+
children: _children
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
var children = (_node$children2 = node.children) === null || _node$children2 === void 0 ? void 0 : _node$children2.map(traverse).filter(Boolean);
|
|
97
|
+
if (children && children.length > 0) {
|
|
98
|
+
return _objectSpread(_objectSpread({}, node), {}, {
|
|
99
|
+
children: children
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return null;
|
|
103
|
+
};
|
|
104
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
105
|
+
var _iterator3 = _createForOfIteratorHelper(data),
|
|
106
|
+
_step3;
|
|
107
|
+
try {
|
|
108
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
109
|
+
var node = _step3.value;
|
|
110
|
+
var filtered = traverse(node);
|
|
111
|
+
if (filtered) {
|
|
112
|
+
result.push(filtered);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
} catch (err) {
|
|
116
|
+
_iterator3.e(err);
|
|
117
|
+
} finally {
|
|
118
|
+
_iterator3.f();
|
|
119
|
+
}
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* 获取 tree 当前选中节点下的所有子节点的 keys
|
|
124
|
+
* @param node
|
|
125
|
+
* @param childrenKeys
|
|
126
|
+
* @returns
|
|
127
|
+
*/
|
|
128
|
+
export function getChildrenKeys(node, childrenKeys) {
|
|
129
|
+
node.children.forEach(function (item) {
|
|
130
|
+
childrenKeys.push(item.key);
|
|
131
|
+
if (item.children && item.children.length > 0) {
|
|
132
|
+
getChildrenKeys(item, childrenKeys);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
return childrenKeys;
|
|
136
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PropTreeSelectProps } from './propsType';
|
|
3
|
+
export declare const ProTreeSelect: (props: PropTreeSelectProps, ref: React.Ref<unknown> | undefined) => React.JSX.Element;
|
|
4
|
+
declare const _default: React.ForwardRefExoticComponent<PropTreeSelectProps & React.RefAttributes<unknown>>;
|
|
5
|
+
export default _default;
|