@para-ui/core 3.0.0 → 3.0.1

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.
Files changed (45) hide show
  1. package/Button/index.d.ts +8 -0
  2. package/Button/index.js +67 -28
  3. package/ComboSelect/index.js +122 -43
  4. package/ComboSelect/interface.d.ts +2 -0
  5. package/ComboSelect/lang/en_US.d.ts +1 -0
  6. package/ComboSelect/lang/index.d.ts +2 -0
  7. package/ComboSelect/lang/zh_CN.d.ts +1 -0
  8. package/Container/index.js +4 -9
  9. package/Form/index.js +2 -2
  10. package/FormItem/index.js +2 -2
  11. package/FunctionModal/index.js +2 -2
  12. package/GlobalContext/componentsProps.d.ts +2 -0
  13. package/Loading/index.js +1 -1
  14. package/PageHeader/index.js +5 -6
  15. package/PopConfirm/index.d.ts +2 -0
  16. package/README.md +13 -1
  17. package/Select/index.d.ts +2 -0
  18. package/Select/index.js +4 -2
  19. package/Selector/index.d.ts +3 -19
  20. package/Selector/index.js +1993 -212
  21. package/Selector/interface.d.ts +355 -0
  22. package/Selector/lang/en_US.d.ts +8 -0
  23. package/Selector/lang/index.d.ts +17 -0
  24. package/Selector/lang/zh_CN.d.ts +8 -0
  25. package/Selector/selectorData/index.d.ts +10 -0
  26. package/Selector/selectorMain/index.d.ts +2 -9
  27. package/Selector/selectorNode/index.d.ts +10 -0
  28. package/Selector/util.d.ts +15 -0
  29. package/SelectorPicker/index.d.ts +49 -0
  30. package/SelectorPicker/index.js +316 -0
  31. package/Table/index.js +22 -19
  32. package/TextField/index.d.ts +2 -0
  33. package/TextField/index.js +4 -3
  34. package/Tree/index.js +2 -2
  35. package/Tree/interface.d.ts +0 -2
  36. package/_verture/{index-ce3860a0.js → index-5bb4b5d7.js} +0 -4
  37. package/_verture/{index-3d26f6a5.js → index-abfdd262.js} +0 -0
  38. package/_verture/{modalContext-fc19f4ae.js → modalContext-59669f93.js} +0 -0
  39. package/index.d.ts +2 -0
  40. package/index.js +6 -4
  41. package/package.json +7 -5
  42. package/Selector/branchNode/index.d.ts +0 -32
  43. package/Selector/leafNode/index.d.ts +0 -34
  44. package/Selector/selectorRight/index.d.ts +0 -16
  45. package/Selector/selectorTop/index.d.ts +0 -16
package/Selector/index.js CHANGED
@@ -1,49 +1,54 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import 'react';
3
- import '../Tooltip/index.js';
4
- import '@para-ui/icons/Help';
5
- import 'clsx';
6
- import '../Help/index.js';
7
- import '../Label/index.js';
1
+ import { _ as _toConsumableArray } from '../_verture/toConsumableArray-f8047a75.js';
2
+ import { _ as _slicedToArray } from '../_verture/slicedToArray-d7722f4b.js';
3
+ import { r as regenerator } from '../_verture/index-342379c6.js';
4
+ import { a as __awaiter, _ as __rest } from '../_verture/tslib.es6-55ed4bd2.js';
5
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
6
+ import { useState, useRef, useEffect, Fragment as Fragment$1 } from 'react';
8
7
  import { Radio } from '../Radio/index.js';
9
8
  import { Checkbox } from '../Checkbox/index.js';
9
+ import { Popover } from '../Popover/index.js';
10
+ import { Loading } from '../Loading/index.js';
10
11
  import CloseIcon from '@para-ui/icons/Close';
11
12
  import { s as styleInject } from '../_verture/style-inject.es-300983ab.js';
12
13
  import { Search } from '../Search/index.js';
13
14
  import { Breadcrumbs } from '../Breadcrumbs/index.js';
14
- import '../_verture/slicedToArray-d7722f4b.js';
15
- import '../_verture/tslib.es6-55ed4bd2.js';
15
+ import Empty from '../Empty/index.js';
16
+ import SearchIcon from '@para-ui/icons/Search';
17
+ import Refresh from '@para-ui/icons/Refresh';
18
+ import { ArrayToObject, Get, Post, Cancel } from '@paraview/lib';
19
+ import { u as useFormatMessage } from '../_verture/useFormatMessage-ac9d6acf.js';
20
+ import { u as useGlobalProps } from '../_verture/useGlobalProps-af9a2af6.js';
21
+ import '../Label/index.js';
22
+ import '../Help/index.js';
23
+ import '../Tooltip/index.js';
16
24
  import 'rc-tooltip';
17
25
  import 'rc-tooltip/lib/placements';
26
+ import 'clsx';
27
+ import '@para-ui/icons/Help';
28
+ import '@para-ui/icons/LoadingF';
18
29
  import '../TextField/index.js';
19
30
  import '../_verture/typeof-498dd2b1.js';
20
- import '@paraview/lib';
21
31
  import '@para-ui/icons/PreviewClose';
22
32
  import '@para-ui/icons/PreviewOpen';
23
33
  import '@para-ui/icons/CloseCircle';
24
34
  import '../AutoTips/index.js';
25
- import '../Loading/index.js';
26
- import '@para-ui/icons/LoadingF';
27
35
  import '../HelperText/index.js';
28
- import '../_verture/useGlobalProps-af9a2af6.js';
29
- import '@para-ui/core/GlobalContext';
30
36
  import '../Dropdown/index.js';
31
37
  import 'rc-dropdown';
32
38
  import '../Button/index.js';
33
39
  import '@para-ui/icons/Forbid';
34
40
  import '@para-ui/icons/Down';
35
- import '../_verture/useFormatMessage-ac9d6acf.js';
36
- import '@para-ui/icons/Search';
37
- import '../_verture/toConsumableArray-f8047a75.js';
38
- import '../Popover/index.js';
41
+ import '@para-ui/core/GlobalContext';
39
42
  import '@para-ui/icons/More';
40
43
 
41
- var css_248z$3 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/\n.paraui-branch-node {\n display: flex;\n justify-content: space-between;\n align-items: center;\n height: 36px;\n cursor: pointer;\n padding: 0 16px;\n}\n.paraui-branch-node:hover {\n background-color: rgba(171, 176, 185, 0.12);\n}\n.paraui-branch-node > .paraui-branch-node-left {\n display: flex;\n align-items: center;\n}\n.paraui-branch-node > .paraui-branch-node-left > .paraui-radio {\n margin-right: 8px;\n display: flex;\n align-items: center;\n}\n.paraui-branch-node > .paraui-branch-node-left > .paraui-radio .paraui-radio-box {\n top: 0;\n}\n.paraui-branch-node > .paraui-branch-node-left > .paraui-check-box {\n margin-right: 8px;\n display: flex;\n align-items: center;\n}\n.paraui-branch-node > .paraui-branch-node-left > .paraui-check-box .paraui-checkbox-box {\n top: 0;\n}\n.paraui-branch-node > .paraui-branch-node-left > .node-img {\n display: inline-block;\n width: 30px;\n height: 30px;\n margin-right: 8px;\n}\n.paraui-branch-node > .paraui-branch-node-left > .node-img img {\n width: 100%;\n height: 100%;\n border-radius: 50%;\n}\n.paraui-branch-node > .paraui-branch-node-left > .main-title {\n font-size: 14px;\n color: rgb(46, 55, 67);\n white-space: nowrap;\n height: 20px;\n}\n.paraui-branch-node > .paraui-branch-node-left > .sub-title {\n margin-left: 8px;\n font-size: 14px;\n color: rgba(46, 55, 67, 0.4);\n white-space: nowrap;\n height: 20px;\n}\n.paraui-branch-node > .paraui-branch-node-left > .tag {\n margin-left: 8px;\n background-color: rgba(54, 102, 214, 0.05);\n color: rgb(54, 102, 214);\n border-radius: 2px;\n font-size: 12px;\n padding: 0px 6px;\n white-space: nowrap;\n height: 17px;\n}\n.paraui-branch-node > .paraui-branch-node-right {\n display: flex;\n align-items: center;\n height: 100%;\n}\n.paraui-branch-node > .paraui-branch-node-right > .detail {\n font-size: 14px;\n color: rgb(54, 102, 214);\n white-space: nowrap;\n padding: 0 4px;\n cursor: pointer;\n height: 24px;\n line-height: 24px;\n border-radius: 2px;\n}\n.paraui-branch-node > .paraui-branch-node-right > .detail:hover {\n background-color: rgba(54, 102, 214, 0.05);\n}\n.paraui-branch-node > .paraui-branch-node-right > .line {\n border-left: 1px solid rgba(171, 176, 185, 0.2);\n margin: 0 8px;\n content: \"\";\n display: inline-block;\n height: 12px;\n}\n.paraui-branch-node > .paraui-branch-node-right > .lower-level {\n font-size: 14px;\n color: rgb(54, 102, 214);\n white-space: nowrap;\n padding: 0 4px;\n cursor: pointer;\n height: 24px;\n line-height: 24px;\n border-radius: 2px;\n}\n.paraui-branch-node > .paraui-branch-node-right > .lower-level:hover {\n background-color: rgba(54, 102, 214, 0.05);\n}\n.paraui-branch-node > .paraui-branch-node-right > .close {\n display: flex;\n align-items: center;\n color: rgb(54, 102, 214);\n white-space: nowrap;\n padding: 0 4px;\n cursor: pointer;\n height: 24px;\n line-height: 24px;\n border-radius: 2px;\n}\n.paraui-branch-node > .paraui-branch-node-right > .close:hover {\n background-color: rgba(54, 102, 214, 0.05);\n}\n.paraui-branch-node > .paraui-branch-node-right > .close:hover > svg {\n color: rgb(54, 102, 214);\n}\n.paraui-branch-node > .paraui-branch-node-right > .close > svg {\n font-size: 16px;\n color: rgba(46, 55, 67, 0.7);\n}\n.paraui-branch-node.paraui-branch-node-edit > .paraui-branch-node-right > .detail, .paraui-branch-node.paraui-branch-node-edit > .paraui-branch-node-right > .lower-level {\n color: rgba(46, 55, 67, 0.7);\n}\n.paraui-branch-node.paraui-branch-node-edit > .paraui-branch-node-right > .detail:hover, .paraui-branch-node.paraui-branch-node-edit > .paraui-branch-node-right > .lower-level:hover {\n color: rgb(54, 102, 214);\n}";
44
+ var css_248z$3 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/\n.paraui-selector-node {\n display: flex;\n justify-content: space-between;\n align-items: center;\n cursor: pointer;\n}\n.paraui-selector-node:hover {\n background-color: rgba(171, 176, 185, 0.12);\n}\n.paraui-selector-node > .paraui-selector-node-left {\n display: flex;\n align-items: center;\n flex: 1;\n overflow: hidden;\n padding-right: 16px;\n}\n.paraui-selector-node > .paraui-selector-node-left > .paraui-radio {\n margin-right: 8px;\n display: flex;\n align-items: center;\n}\n.paraui-selector-node > .paraui-selector-node-left > .paraui-radio .paraui-radio-box {\n top: 0;\n}\n.paraui-selector-node > .paraui-selector-node-left > .paraui-check-box {\n margin-right: 8px;\n display: flex;\n align-items: center;\n}\n.paraui-selector-node > .paraui-selector-node-left > .paraui-check-box .paraui-checkbox-box {\n top: 0;\n}\n.paraui-selector-node > .paraui-selector-node-left > .node-img {\n display: inline-block;\n width: 30px;\n height: 30px;\n margin-right: 8px;\n}\n.paraui-selector-node > .paraui-selector-node-left > .node-img img {\n width: 30px;\n height: 30px;\n border-radius: 50%;\n}\n.paraui-selector-node.paraui-selector-node-branch {\n height: 36px;\n padding: 0 16px;\n}\n.paraui-selector-node.paraui-selector-node-branch > .paraui-selector-node-left > .main-title {\n font-size: 14px;\n color: rgb(46, 55, 67);\n white-space: nowrap;\n height: 20px;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.paraui-selector-node.paraui-selector-node-branch > .paraui-selector-node-left > .sub-title {\n margin-left: 8px;\n font-size: 14px;\n color: rgba(46, 55, 67, 0.4);\n white-space: nowrap;\n height: 20px;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.paraui-selector-node.paraui-selector-node-branch > .paraui-selector-node-left > .tag {\n margin-left: 8px;\n background-color: rgba(54, 102, 214, 0.05);\n color: rgb(54, 102, 214);\n border-radius: 2px;\n font-size: 12px;\n padding: 0px 6px;\n white-space: nowrap;\n height: 17px;\n}\n.paraui-selector-node.paraui-selector-node-leaf {\n padding: 6px 16px;\n height: 48px;\n}\n.paraui-selector-node.paraui-selector-node-leaf > .paraui-selector-node-left > .title-box {\n flex: 1;\n overflow: hidden;\n}\n.paraui-selector-node.paraui-selector-node-leaf > .paraui-selector-node-left > .title-box > .main-title-box {\n display: flex;\n white-space: nowrap;\n}\n.paraui-selector-node.paraui-selector-node-leaf > .paraui-selector-node-left > .title-box > .main-title-box > .main-title {\n font-size: 14px;\n color: rgb(46, 55, 67);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.paraui-selector-node.paraui-selector-node-leaf > .paraui-selector-node-left > .title-box > .main-title-box > .tag {\n margin-left: 8px;\n background-color: rgba(54, 102, 214, 0.05);\n color: rgb(54, 102, 214);\n border-radius: 2px;\n font-size: 12px;\n padding: 1px 6px;\n white-space: nowrap;\n}\n.paraui-selector-node.paraui-selector-node-leaf > .paraui-selector-node-left > .title-box > .sub-title {\n font-size: 12px;\n color: rgba(46, 55, 67, 0.4);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.paraui-selector-node > .paraui-selector-node-right {\n display: flex;\n align-items: center;\n height: 100%;\n}\n.paraui-selector-node > .paraui-selector-node-right > .detail {\n font-size: 14px;\n color: rgb(54, 102, 214);\n white-space: nowrap;\n padding: 0 4px;\n cursor: pointer;\n height: 24px;\n line-height: 24px;\n border-radius: 2px;\n}\n.paraui-selector-node > .paraui-selector-node-right > .detail:hover {\n background-color: rgba(54, 102, 214, 0.05);\n}\n.paraui-selector-node > .paraui-selector-node-right > .line {\n border-left: 1px solid rgba(171, 176, 185, 0.2);\n margin: 0 8px;\n content: \"\";\n display: inline-block;\n height: 12px;\n}\n.paraui-selector-node > .paraui-selector-node-right > .lower-child {\n font-size: 14px;\n color: rgb(54, 102, 214);\n white-space: nowrap;\n padding: 0 4px;\n cursor: pointer;\n height: 24px;\n line-height: 24px;\n border-radius: 2px;\n}\n.paraui-selector-node > .paraui-selector-node-right > .lower-child:hover {\n background-color: rgba(54, 102, 214, 0.05);\n}\n.paraui-selector-node > .paraui-selector-node-right > .close {\n display: flex;\n align-items: center;\n color: rgb(54, 102, 214);\n white-space: nowrap;\n padding: 0 4px;\n cursor: pointer;\n height: 24px;\n line-height: 24px;\n border-radius: 2px;\n}\n.paraui-selector-node > .paraui-selector-node-right > .close:hover {\n background-color: rgba(54, 102, 214, 0.05);\n}\n.paraui-selector-node > .paraui-selector-node-right > .close:hover > svg {\n color: rgb(54, 102, 214);\n}\n.paraui-selector-node > .paraui-selector-node-right > .close > svg {\n font-size: 16px;\n color: rgba(46, 55, 67, 0.7);\n}\n.paraui-selector-node.paraui-selector-node-edit > .paraui-selector-node-right > .detail, .paraui-selector-node.paraui-selector-node-edit > .paraui-selector-node-right > .lower-child {\n color: rgba(46, 55, 67, 0.7);\n}\n.paraui-selector-node.paraui-selector-node-edit > .paraui-selector-node-right > .detail:hover, .paraui-selector-node.paraui-selector-node-edit > .paraui-selector-node-right > .lower-child:hover {\n color: rgb(54, 102, 214);\n}\n.paraui-selector-node.paraui-selector-node-disabled {\n cursor: not-allowed;\n}\n.paraui-selector-node.paraui-selector-node-disabled.paraui-selector-node-branch > .paraui-selector-node-left > .main-title {\n color: rgba(46, 55, 67, 0.4);\n}\n.paraui-selector-node.paraui-selector-node-disabled.paraui-selector-node-leaf > .paraui-selector-node-left > .title-box > .main-title-box > .main-title {\n color: rgba(46, 55, 67, 0.4);\n}\n.paraui-selector-node.paraui-selector-node-disabled > .paraui-selector-node-right > .lower-child {\n cursor: not-allowed;\n color: rgba(46, 55, 67, 0.4);\n}\n\n.paraui-selector-detail-popover-content.paraui-selector-detail-popover-content-loading {\n min-width: 100px;\n min-height: 50px;\n}";
42
45
  styleInject(css_248z$3);
43
46
 
44
- var BranchNode = function BranchNode(props) {
47
+ var SelectorNode = function SelectorNode(props) {
45
48
  var className = props.className,
46
49
  style = props.style,
50
+ _props$nodeMode = props.nodeMode,
51
+ nodeMode = _props$nodeMode === void 0 ? 'branch' : _props$nodeMode,
47
52
  _props$useCase = props.useCase,
48
53
  useCase = _props$useCase === void 0 ? 'view' : _props$useCase,
49
54
  img = props.img,
@@ -52,99 +57,105 @@ var BranchNode = function BranchNode(props) {
52
57
  subTitle = props.subTitle,
53
58
  tag = props.tag,
54
59
  detail = props.detail,
55
- level = props.level,
56
- close = props.close; // 处理头像
60
+ detailRender = props.detailRender,
61
+ child = props.child,
62
+ close = props.close,
63
+ checked = props.checked,
64
+ indeterminate = props.indeterminate,
65
+ disabled = props.disabled,
66
+ onLevel = props.onLevel,
67
+ onSelect = props.onSelect,
68
+ onClose = props.onClose;
57
69
 
58
- var handImg = function handImg() {
59
- if (!img) return null;
60
- var imgDom = img;
61
- if (typeof img === "string") imgDom = jsx("img", {
62
- src: img
63
- });
64
- return jsx("span", Object.assign({
65
- className: "node-img"
66
- }, {
67
- children: imgDom
68
- }));
70
+ var _useState = useState(),
71
+ _useState2 = _slicedToArray(_useState, 2),
72
+ detailDom = _useState2[0],
73
+ setDetailDom = _useState2[1]; // 详情内容
74
+
75
+
76
+ var _useState3 = useState(false),
77
+ _useState4 = _slicedToArray(_useState3, 2),
78
+ detailDomLoading = _useState4[0],
79
+ setDetailDomLoading = _useState4[1]; // 详情loading
80
+
81
+
82
+ var detailRef = useRef();
83
+ /** 点击节点 */
84
+
85
+ var onClickNode = function onClickNode() {
86
+ if (disabled) return;
87
+ onSelect && onSelect();
69
88
  };
89
+ /** 点击下级 */
70
90
 
71
- var handSelectDom = function handSelectDom() {
72
- if (selectMode === 'radio') return jsx(Radio, {
73
- size: "small"
74
- });
75
- if (selectMode === 'check') return jsx(Checkbox, {
76
- size: "small"
77
- });
78
- return null;
91
+
92
+ var onLevelBtn = function onLevelBtn(e) {
93
+ e.stopPropagation();
94
+ if (disabled) return;
95
+ onLevel && onLevel();
79
96
  };
97
+ /** 点击详情 */
80
98
 
81
- var handClass = function handClass() {
82
- var str = 'paraui-branch-node';
83
- if (className) str += ' ' + className;
84
- str += ' paraui-branch-node-' + useCase;
85
- return str;
99
+
100
+ var onClickDetail = function onClickDetail(e) {
101
+ e.stopPropagation();
86
102
  };
103
+ /** 点击× */
87
104
 
88
- return jsxs("div", Object.assign({
89
- className: handClass(),
90
- style: style
91
- }, {
92
- children: [jsxs("div", Object.assign({
93
- className: "paraui-branch-node-left"
94
- }, {
95
- children: [handSelectDom(), handImg(), mainTitle && jsx("span", Object.assign({
96
- className: "main-title"
97
- }, {
98
- children: mainTitle
99
- })), subTitle && jsx("span", Object.assign({
100
- className: "sub-title"
101
- }, {
102
- children: subTitle
103
- })), tag && jsx("span", Object.assign({
104
- className: "tag"
105
- }, {
106
- children: tag
107
- }))]
108
- })), jsxs("div", Object.assign({
109
- className: "paraui-branch-node-right"
110
- }, {
111
- children: [detail && jsx("span", Object.assign({
112
- className: "detail"
113
- }, {
114
- children: "\u8BE6\u60C5"
115
- })), detail && level && jsx("span", {
116
- className: "line"
117
- }), level && jsx("span", Object.assign({
118
- className: "lower-level"
119
- }, {
120
- children: "\u4E0B\u7EA7"
121
- })), detail && close && jsx("span", {
122
- className: "line"
123
- }), close && jsx("span", Object.assign({
124
- className: "close"
125
- }, {
126
- children: jsx(CloseIcon, {})
127
- }))]
128
- }))]
129
- }));
130
- };
131
105
 
132
- var css_248z$2 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/\n.paraui-leaf-node {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 6px 16px;\n height: 48px;\n cursor: pointer;\n}\n.paraui-leaf-node:hover {\n background-color: rgba(171, 176, 185, 0.12);\n}\n.paraui-leaf-node > .paraui-leaf-node-left {\n display: flex;\n align-items: center;\n}\n.paraui-leaf-node > .paraui-leaf-node-left > .paraui-radio {\n margin-right: 8px;\n display: flex;\n align-items: center;\n}\n.paraui-leaf-node > .paraui-leaf-node-left > .paraui-radio .paraui-radio-box {\n top: 0;\n}\n.paraui-leaf-node > .paraui-leaf-node-left > .paraui-check-box {\n margin-right: 8px;\n display: flex;\n align-items: center;\n}\n.paraui-leaf-node > .paraui-leaf-node-left > .paraui-check-box .paraui-checkbox-box {\n top: 0;\n}\n.paraui-leaf-node > .paraui-leaf-node-left > .node-img {\n display: inline-block;\n width: 30px;\n height: 30px;\n margin-right: 8px;\n}\n.paraui-leaf-node > .paraui-leaf-node-left > .node-img img {\n width: 100%;\n height: 100%;\n border-radius: 50%;\n}\n.paraui-leaf-node > .paraui-leaf-node-left > .title-box > .main-title-box {\n white-space: nowrap;\n}\n.paraui-leaf-node > .paraui-leaf-node-left > .title-box > .main-title-box > .main-title {\n font-size: 14px;\n color: rgb(46, 55, 67);\n white-space: nowrap;\n}\n.paraui-leaf-node > .paraui-leaf-node-left > .title-box > .main-title-box > .tag {\n margin-left: 8px;\n background-color: rgba(54, 102, 214, 0.05);\n color: rgb(54, 102, 214);\n border-radius: 2px;\n font-size: 12px;\n padding: 1px 6px;\n white-space: nowrap;\n}\n.paraui-leaf-node > .paraui-leaf-node-left > .title-box > .sub-title {\n font-size: 12px;\n color: rgba(46, 55, 67, 0.4);\n white-space: nowrap;\n}\n.paraui-leaf-node > .paraui-leaf-node-right {\n display: flex;\n align-items: center;\n height: 100%;\n}\n.paraui-leaf-node > .paraui-leaf-node-right > .detail {\n font-size: 14px;\n color: rgb(54, 102, 214);\n white-space: nowrap;\n padding: 0 4px;\n cursor: pointer;\n height: 24px;\n line-height: 24px;\n border-radius: 2px;\n}\n.paraui-leaf-node > .paraui-leaf-node-right > .detail:hover {\n background-color: rgba(54, 102, 214, 0.05);\n}\n.paraui-leaf-node > .paraui-leaf-node-right > .line {\n border-left: 1px solid rgba(171, 176, 185, 0.2);\n margin: 0 8px;\n content: \"\";\n display: inline-block;\n height: 12px;\n}\n.paraui-leaf-node > .paraui-leaf-node-right > .lower-level {\n font-size: 14px;\n color: rgb(54, 102, 214);\n white-space: nowrap;\n padding: 0 4px;\n cursor: pointer;\n height: 24px;\n line-height: 24px;\n border-radius: 2px;\n}\n.paraui-leaf-node > .paraui-leaf-node-right > .lower-level:hover {\n background-color: rgba(54, 102, 214, 0.05);\n}\n.paraui-leaf-node > .paraui-leaf-node-right > .close {\n display: flex;\n align-items: center;\n color: rgb(54, 102, 214);\n white-space: nowrap;\n padding: 0 4px;\n cursor: pointer;\n height: 24px;\n line-height: 24px;\n border-radius: 2px;\n}\n.paraui-leaf-node > .paraui-leaf-node-right > .close:hover {\n background-color: rgba(54, 102, 214, 0.05);\n}\n.paraui-leaf-node > .paraui-leaf-node-right > .close:hover > svg {\n color: rgb(54, 102, 214);\n}\n.paraui-leaf-node > .paraui-leaf-node-right > .close > svg {\n font-size: 16px;\n color: rgba(46, 55, 67, 0.7);\n}\n.paraui-leaf-node.paraui-leaf-node-edit > .paraui-leaf-node-right > .detail, .paraui-leaf-node.paraui-leaf-node-edit > .paraui-leaf-node-right > .lower-level {\n color: rgba(46, 55, 67, 0.7);\n}\n.paraui-leaf-node.paraui-leaf-node-edit > .paraui-leaf-node-right > .detail:hover, .paraui-leaf-node.paraui-leaf-node-edit > .paraui-leaf-node-right > .lower-level:hover {\n color: rgb(54, 102, 214);\n}";
133
- styleInject(css_248z$2);
106
+ var onCloseCom = function onCloseCom(e) {
107
+ e.stopPropagation();
108
+ onClose && onClose();
109
+ };
110
+ /** 详情显示隐藏 */
111
+
112
+
113
+ var onVisibleChange = function onVisibleChange(bol) {
114
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee() {
115
+ var Dom;
116
+ return regenerator.wrap(function _callee$(_context) {
117
+ while (1) {
118
+ switch (_context.prev = _context.next) {
119
+ case 0:
120
+ if (detailRender) {
121
+ _context.next = 2;
122
+ break;
123
+ }
124
+
125
+ return _context.abrupt("return");
126
+
127
+ case 2:
128
+ setDetailDomLoading(false);
129
+
130
+ if (bol) {
131
+ _context.next = 5;
132
+ break;
133
+ }
134
+
135
+ return _context.abrupt("return", setDetailDom(null));
136
+
137
+ case 5:
138
+ setDetailDomLoading(true);
139
+ detailRef.current && detailRef.current.classList.add('paraui-selector-detail-popover-content-loading');
140
+ _context.next = 9;
141
+ return detailRender();
142
+
143
+ case 9:
144
+ Dom = _context.sent;
145
+ detailRef.current && detailRef.current.classList.remove('paraui-selector-detail-popover-content-loading');
146
+ setDetailDomLoading(false);
147
+ setDetailDom(Dom);
148
+
149
+ case 13:
150
+ case "end":
151
+ return _context.stop();
152
+ }
153
+ }
154
+ }, _callee);
155
+ }));
156
+ };
157
+ /** 处理头像 */
134
158
 
135
- var LeafNode = function LeafNode(props) {
136
- var className = props.className,
137
- style = props.style,
138
- _props$useCase = props.useCase,
139
- useCase = _props$useCase === void 0 ? 'view' : _props$useCase,
140
- img = props.img,
141
- selectMode = props.selectMode,
142
- mainTitle = props.mainTitle,
143
- subTitle = props.subTitle,
144
- tag = props.tag,
145
- detail = props.detail,
146
- level = props.level,
147
- close = props.close; // 处理头像
148
159
 
149
160
  var handImg = function handImg() {
150
161
  if (!img) return null;
@@ -157,34 +168,78 @@ var LeafNode = function LeafNode(props) {
157
168
  }, {
158
169
  children: imgDom
159
170
  }));
160
- }; // 处理 选择框
171
+ };
172
+ /** 处理选择框 */
161
173
 
162
174
 
163
175
  var handSelectDom = function handSelectDom() {
164
176
  if (selectMode === 'radio') return jsx(Radio, {
165
- size: "small"
177
+ size: "small",
178
+ checked: checked,
179
+ disabled: disabled
166
180
  });
167
181
  if (selectMode === 'check') return jsx(Checkbox, {
168
- size: "small"
182
+ size: "small",
183
+ checked: checked,
184
+ disabled: disabled,
185
+ indeterminate: indeterminate
169
186
  });
170
187
  return null;
171
188
  };
189
+ /** 处理详情弹窗 */
172
190
 
173
- var handClass = function handClass() {
174
- var str = 'paraui-leaf-node';
175
- if (className) str += ' ' + className;
176
- str += ' paraui-leaf-node-' + useCase;
177
- return str;
191
+
192
+ var handDetailDom = function handDetailDom() {
193
+ return jsxs("div", Object.assign({
194
+ className: "paraui-selector-detail-popover-content",
195
+ ref: detailRef
196
+ }, {
197
+ children: [detailDom, detailDomLoading && jsx(Loading, {})]
198
+ }));
178
199
  };
200
+ /** 处理详情 */
179
201
 
180
- return jsxs("div", Object.assign({
181
- className: handClass(),
182
- style: style
183
- }, {
184
- children: [jsxs("div", Object.assign({
185
- className: "paraui-leaf-node-left"
202
+
203
+ var handDetail = function handDetail() {
204
+ if (!detail) return null;
205
+ return jsx(Popover, Object.assign({
206
+ content: handDetailDom(),
207
+ trigger: 'hover',
208
+ placement: 'bottomRight',
209
+ onVisibleChange: onVisibleChange
186
210
  }, {
187
- children: [handSelectDom(), handImg(), jsxs("div", Object.assign({
211
+ children: jsx("span", Object.assign({
212
+ className: "detail",
213
+ onClick: onClickDetail
214
+ }, {
215
+ children: "\u8BE6\u60C5"
216
+ }))
217
+ }));
218
+ };
219
+ /** 处理标签内容 */
220
+
221
+
222
+ var handNodeLeft = function handNodeLeft() {
223
+ if (nodeMode === 'branch') {
224
+ return jsxs(Fragment, {
225
+ children: [mainTitle && jsx("span", Object.assign({
226
+ className: "main-title"
227
+ }, {
228
+ children: mainTitle
229
+ })), subTitle && jsx("span", Object.assign({
230
+ className: "sub-title"
231
+ }, {
232
+ children: subTitle
233
+ })), tag && jsx("span", Object.assign({
234
+ className: "tag"
235
+ }, {
236
+ children: tag
237
+ }))]
238
+ });
239
+ }
240
+
241
+ if (nodeMode === 'leaf') {
242
+ return jsxs("div", Object.assign({
188
243
  className: "title-box"
189
244
  }, {
190
245
  children: [jsxs("div", Object.assign({
@@ -204,24 +259,45 @@ var LeafNode = function LeafNode(props) {
204
259
  }, {
205
260
  children: subTitle
206
261
  }))]
207
- }))]
262
+ }));
263
+ }
264
+ };
265
+ /** 处理className */
266
+
267
+
268
+ var handClass = function handClass() {
269
+ var str = 'paraui-selector-node';
270
+ str += ' paraui-selector-node-' + useCase;
271
+ str += ' paraui-selector-node-' + nodeMode;
272
+ if (disabled) str += ' paraui-selector-node-disabled';
273
+ if (className) str += ' ' + className;
274
+ return str;
275
+ };
276
+
277
+ return jsxs("div", Object.assign({
278
+ className: handClass(),
279
+ style: style,
280
+ onClick: onClickNode
281
+ }, {
282
+ children: [jsxs("div", Object.assign({
283
+ className: "paraui-selector-node-left"
284
+ }, {
285
+ children: [handSelectDom(), handImg(), handNodeLeft()]
208
286
  })), jsxs("div", Object.assign({
209
- className: "paraui-leaf-node-right"
287
+ className: "paraui-selector-node-right"
210
288
  }, {
211
- children: [detail && jsx("span", Object.assign({
212
- className: "detail"
213
- }, {
214
- children: "\u8BE6\u60C5"
215
- })), detail && level && jsx("span", {
289
+ children: [handDetail(), detail && child && jsx("span", {
216
290
  className: "line"
217
- }), level && jsx("span", Object.assign({
218
- className: "lower-level"
291
+ }), child && jsx("span", Object.assign({
292
+ className: "lower-child",
293
+ onClick: onLevelBtn
219
294
  }, {
220
295
  children: "\u4E0B\u7EA7"
221
296
  })), detail && close && jsx("span", {
222
297
  className: "line"
223
298
  }), close && jsx("span", Object.assign({
224
- className: "close"
299
+ className: "close",
300
+ onClick: onCloseCom
225
301
  }, {
226
302
  children: jsx(CloseIcon, {})
227
303
  }))]
@@ -229,114 +305,1819 @@ var LeafNode = function LeafNode(props) {
229
305
  }));
230
306
  };
231
307
 
232
- var css_248z$1 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/\n.paraui-selector-main {\n padding: 16px 0;\n border: 1px solid;\n}\n.paraui-selector-main > .paraui-search {\n padding: 0 16px;\n margin-bottom: 16px;\n}\n.paraui-selector-main > .nav-box {\n padding: 0 16px;\n margin-bottom: 12px;\n line-height: 0;\n}\n.paraui-selector-main > .paraui-selector-main-list > .paraui-selector-main-list-more {\n padding: 0 16px;\n cursor: pointer;\n font-size: 14px;\n color: rgb(54, 102, 214);\n line-height: 36px;\n}\n.paraui-selector-main > .paraui-selector-main-list > .paraui-selector-main-list-more:hover {\n background-color: rgba(171, 176, 185, 0.12);\n}\n.paraui-selector-main.paraui-selector-main-select > .paraui-selector-main-list > .paraui-selector-main-list-more {\n padding-left: 38px;\n}";
233
- styleInject(css_248z$1);
308
+ var en = {
309
+ root: 'root',
310
+ selectAll: 'Select all',
311
+ seeMore: 'See more',
312
+ selected: 'Selected',
313
+ pleaseEnter: 'Please enter'
314
+ };
234
315
 
235
- var list = [{
236
- label: '主页'
237
- }, {
238
- label: '管理'
239
- }, {
240
- label: '新建'
241
- }];
316
+ var zh = {
317
+ root: '',
318
+ selectAll: '全选',
319
+ seeMore: '查看更多',
320
+ selected: '已选',
321
+ pleaseEnter: '请输入'
322
+ };
242
323
 
243
- var SelectorMain = function SelectorMain(props) {
324
+ var localeJson = {
325
+ zh: zh,
326
+ en: en
327
+ };
328
+
329
+ var css_248z$2 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/\n.paraui-selector-main {\n padding: 16px 0 0 0;\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n}\n.paraui-selector-main > .paraui-search {\n padding: 0 16px;\n margin-bottom: 16px;\n}\n.paraui-selector-main > .paraui-selector-main-box {\n position: relative;\n width: 100%;\n height: 100%;\n}\n.paraui-selector-main > .paraui-selector-main-box > .paraui-selector-main-content {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n}\n.paraui-selector-main > .paraui-selector-main-box > .paraui-selector-main-content > .nav-box {\n padding: 0 16px;\n margin-bottom: 12px;\n line-height: 0;\n}\n.paraui-selector-main > .paraui-selector-main-box > .paraui-selector-main-content > .paraui-selector-main-list {\n flex: 1;\n overflow-y: auto;\n padding-bottom: 16px;\n}\n.paraui-selector-main > .paraui-selector-main-box > .paraui-selector-main-content > .paraui-selector-main-list > .paraui-selector-main-list-no-data {\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.paraui-selector-main > .paraui-selector-main-box > .paraui-selector-main-content > .paraui-selector-main-list > .paraui-selector-all-check + .paraui-selector-group-title.paraui-selector-group-title-first {\n margin-top: 4px;\n}\n.paraui-selector-main > .paraui-selector-main-box > .paraui-selector-main-content > .paraui-selector-main-list > .paraui-selector-group-title {\n padding: 0 12px;\n margin-top: 24px;\n margin-bottom: 12px;\n font-size: 14px;\n color: rgba(46, 55, 67, 0.4);\n}\n.paraui-selector-main > .paraui-selector-main-box > .paraui-selector-main-content > .paraui-selector-main-list > .paraui-selector-group-title.paraui-selector-group-title-first {\n margin-top: 0;\n}\n.paraui-selector-main > .paraui-selector-main-box > .paraui-selector-main-content > .paraui-selector-main-list > .paraui-selector-main-list-more {\n padding: 0 16px;\n cursor: pointer;\n font-size: 14px;\n color: rgb(54, 102, 214);\n line-height: 36px;\n}\n.paraui-selector-main > .paraui-selector-main-box > .paraui-selector-main-content > .paraui-selector-main-list > .paraui-selector-main-list-more:hover {\n background-color: rgba(171, 176, 185, 0.12);\n}\n.paraui-selector-main > .paraui-selector-main-box > .paraui-selector-main-content.paraui-selector-main-search-content {\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n background-color: white;\n}\n.paraui-selector-main > .paraui-selector-main-box > .paraui-selector-main-content.paraui-selector-main-search-content > .paraui-selector-main-list {\n padding-bottom: 16px;\n}\n.paraui-selector-main.paraui-selector-main-select > .paraui-selector-main-box > .paraui-selector-main-content > .paraui-selector-main-list > .paraui-selector-main-list-more {\n padding-left: 38px;\n}\n.paraui-selector-main.paraui-selector-main-show-search > .paraui-selector-main-box {\n height: calc(100% - 52px);\n}\n.paraui-selector-main.paraui-selector-main-show-search > .paraui-selector-main-box > .paraui-selector-main-content.paraui-selector-main-list-box {\n display: none;\n}\n.paraui-selector-main.paraui-selector-main-search > .paraui-selector-main-box {\n height: calc(100% - 52px);\n}";
330
+ styleInject(css_248z$2);
331
+
332
+ var SelectorMainContent = function SelectorMainContent(props) {
244
333
  var className = props.className,
245
- style = props.style;
334
+ value = props.value,
335
+ _props$rowKey = props.rowKey,
336
+ rowKey = _props$rowKey === void 0 ? 'key' : _props$rowKey,
337
+ _props$nodeMode = props.nodeMode,
338
+ nodeMode = _props$nodeMode === void 0 ? 'branch' : _props$nodeMode,
339
+ selectMode = props.selectMode,
340
+ _props$loadMore = props.loadMore,
341
+ loadMore = _props$loadMore === void 0 ? false : _props$loadMore,
342
+ _props$isAllCheck = props.isAllCheck,
343
+ isAllCheck = _props$isAllCheck === void 0 ? false : _props$isAllCheck,
344
+ detail = props.detail,
345
+ detailRender = props.detailRender,
346
+ isLazy = props.isLazy,
347
+ list = props.list,
348
+ groupType = props.groupType,
349
+ breadcrumbs = props.breadcrumbs,
350
+ _props$breadcrumbsSep = props.breadcrumbsSeparator,
351
+ breadcrumbsSeparator = _props$breadcrumbsSep === void 0 ? '-' : _props$breadcrumbsSep,
352
+ _props$breadcrumbsLis = props.breadcrumbsList,
353
+ breadcrumbsList = _props$breadcrumbsLis === void 0 ? [] : _props$breadcrumbsLis,
354
+ fieldConfig = props.fieldConfig,
355
+ disabled = props.disabled,
356
+ emptyProps = props.emptyProps,
357
+ loading = props.loading,
358
+ onClickBreadcrumbs = props.onClickBreadcrumbs,
359
+ _onLevel = props.onLevel,
360
+ _onSelect = props.onSelect,
361
+ onLoad = props.onLoad,
362
+ onAllCheck = props.onAllCheck;
363
+ var intl = useFormatMessage('Selector', localeJson);
364
+
365
+ var _useState = useState({}),
366
+ _useState2 = _slicedToArray(_useState, 2),
367
+ listCom = _useState2[0],
368
+ setListCom = _useState2[1];
369
+
370
+ var constData = useRef({
371
+ listTypeJson: {},
372
+ fieldConfig: {}
373
+ });
374
+ constData.current.listTypeJson = ArrayToObject('value', groupType);
375
+ constData.current.fieldConfig = fieldConfig || {};
376
+ useEffect(function () {
377
+ if (list && groupType && groupType.length > 0) {
378
+ var json = {};
379
+
380
+ for (var i = 0, l = list.length; i < l; i++) {
381
+ var item = list[i];
382
+ var type = item[constData.current.fieldConfig.type || ''];
383
+ if (!json[type]) json[type] = [];
384
+ json[type].push(item);
385
+ }
386
+
387
+ setListCom(json);
388
+ }
389
+ }, [list]);
390
+ /** 判断是否全选,半选 */
391
+
392
+ var handAllCheckFunc = function handAllCheckFunc() {
393
+ var json = {
394
+ checked: false,
395
+ indeterminate: false
396
+ }; // 不存在value, 没有数据, 全选没转态
397
+
398
+ if (!value || !list || list.length === 0) return json;
399
+
400
+ for (var i = 0, l = list.length; i < l; i++) {
401
+ var item = list[i];
402
+ var key = item[rowKey];
403
+ var disabledItem = handDisabled(item);
404
+
405
+ if (disabledItem) {
406
+ if (value[key]) json.checked = true;
407
+ continue;
408
+ }
409
+
410
+ if (value[key]) {
411
+ json.checked = true;
412
+ } else {
413
+ json.indeterminate = true;
414
+ }
415
+ } // 半选
416
+
417
+
418
+ if (json.checked && json.indeterminate) {
419
+ json.checked = false;
420
+ return json;
421
+ } // 全不选
422
+
423
+
424
+ if (!json.checked && json.indeterminate) {
425
+ json.indeterminate = false;
426
+ return json;
427
+ }
428
+
429
+ return json;
430
+ };
431
+ /** 处理禁用状态 */
432
+
433
+
434
+ var handDisabled = function handDisabled(item) {
435
+ if (disabled) {
436
+ if (disabled === true) return true;
437
+
438
+ if (disabled instanceof Array) {
439
+ if (item.key && disabled.indexOf(item.key) !== -1) {
440
+ return true;
441
+ }
442
+ }
443
+ }
444
+
445
+ if (item.disabled) return true;
446
+ return false;
447
+ };
448
+ /** 全选 */
449
+
450
+
451
+ var handAllCheck = function handAllCheck() {
452
+ // 只存在复选框模式
453
+ if (!isAllCheck || selectMode !== "check") return null;
454
+ var checkJson = handAllCheckFunc();
455
+
456
+ var onAllCheckCom = function onAllCheckCom() {
457
+ var bol = true;
458
+ if (checkJson.checked) bol = false;
459
+ onAllCheck && onAllCheck(bol);
460
+ };
461
+
462
+ return jsx(SelectorNode, Object.assign({
463
+ disabled: disabled === true,
464
+ nodeMode: 'branch',
465
+ mainTitle: intl({
466
+ id: 'selectAll'
467
+ }),
468
+ selectMode: 'check'
469
+ }, checkJson, {
470
+ onSelect: onAllCheckCom,
471
+ className: 'paraui-selector-all-check'
472
+ }));
473
+ };
474
+ /** 点击查看更多 */
475
+
476
+
477
+ var clickLoad = function clickLoad() {
478
+ onLoad && onLoad();
479
+ };
480
+ /** 查看更多 */
481
+
482
+
483
+ var handLoadMore = function handLoadMore() {
484
+ if (!loadMore) return null;
485
+ return jsx("div", Object.assign({
486
+ className: "paraui-selector-main-list-more",
487
+ onClick: clickLoad
488
+ }, {
489
+ children: jsx("span", Object.assign({
490
+ className: "more-btn"
491
+ }, {
492
+ children: intl({
493
+ id: 'seeMore'
494
+ })
495
+ }))
496
+ }));
497
+ };
498
+ /** 判断是否选中 */
499
+
500
+
501
+ var handCheck = function handCheck(item) {
502
+ var bol = false;
503
+ if (value && value[item[rowKey]]) bol = true;
504
+ return bol;
505
+ };
506
+ /** 处理每个节点的配置 */
507
+
508
+
509
+ var handNodeConfig = function handNodeConfig(item) {
510
+ var json = {
511
+ useCase: 'view',
512
+ detail: detail,
513
+ nodeMode: nodeMode,
514
+ disabled: handDisabled(item),
515
+ onLevel: function onLevel() {
516
+ return _onLevel && _onLevel(item);
517
+ },
518
+ onSelect: function onSelect() {
519
+ return _onSelect && _onSelect(item);
520
+ },
521
+ checked: handCheck(item)
522
+ };
523
+ /** 节点类型 */
524
+
525
+ if (item.leaf !== undefined) json.nodeMode = item.leaf ? 'leaf' : 'branch';
526
+ /** 渲染字段 */
527
+
528
+ var arr = ['img', 'mainTitle', 'subTitle', 'tag'];
529
+
530
+ for (var i = 0, l = arr.length; i < l; i++) {
531
+ var key = arr[i];
532
+ json[key] = item[key];
533
+ }
534
+ /** 判断是否具有选择 */
535
+
536
+
537
+ if (item.choice !== false) {
538
+ // 当前节点可选择
539
+ if (selectMode) json.selectMode = selectMode;
540
+ }
541
+ /** 判断是否具有下级 */
542
+
543
+
544
+ if (isLazy) {
545
+ // 懒加载
546
+ json.child = item.child;
547
+ } else {
548
+ // 全量数据
549
+ var children = item.children || [];
550
+
551
+ if (children && children.length > 0) {
552
+ json.child = true;
553
+ } // 强制设置下级
554
+
555
+
556
+ if (item.child !== undefined) json.child = item.child;
557
+ }
558
+ /** 详情render */
559
+
560
+
561
+ if (detailRender) {
562
+ json.detailRender = function () {
563
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee() {
564
+ var Dom;
565
+ return regenerator.wrap(function _callee$(_context) {
566
+ while (1) {
567
+ switch (_context.prev = _context.next) {
568
+ case 0:
569
+ _context.next = 2;
570
+ return detailRender(item, true);
571
+
572
+ case 2:
573
+ Dom = _context.sent;
574
+ return _context.abrupt("return", Dom);
575
+
576
+ case 4:
577
+ case "end":
578
+ return _context.stop();
579
+ }
580
+ }
581
+ }, _callee);
582
+ }));
583
+ };
584
+ }
585
+
586
+ return json;
587
+ };
588
+ /** 渲染list节点 */
589
+
590
+
591
+ var handListNode = function handListNode(arr) {
592
+ return arr === null || arr === void 0 ? void 0 : arr.map(function (item, index) {
593
+ return jsx(SelectorNode, Object.assign({}, handNodeConfig(item)), index);
594
+ });
595
+ };
596
+ /** 处理节点dom */
597
+
598
+
599
+ var handNode = function handNode() {
600
+ // 分组渲染
601
+ if (groupType && groupType.length > 0) {
602
+ return jsx(Fragment, {
603
+ children: groupType.map(function (item, index) {
604
+ var type = item.value;
605
+ var listData = listCom[type] || [];
606
+ var str = 'paraui-selector-group-title';
607
+ if (index === 0) str += ' paraui-selector-group-title-first';
608
+ return jsxs(Fragment$1, {
609
+ children: [listData.length > 0 && jsx("div", Object.assign({
610
+ className: str
611
+ }, {
612
+ children: item.label || type
613
+ })), handListNode(listData)]
614
+ }, index);
615
+ })
616
+ });
617
+ }
618
+
619
+ return handListNode(list || []);
620
+ };
621
+ /** 点击面包屑 */
622
+
623
+
624
+ var onClickBreadcrums = function onClickBreadcrums(item) {
625
+ onClickBreadcrumbs && onClickBreadcrumbs(item);
626
+ };
627
+ /** 面包屑dom */
628
+
629
+
630
+ var handBreadcrumbs = function handBreadcrumbs() {
631
+ if (!breadcrumbs || breadcrumbsList.length === 0) return null;
632
+ return jsx("div", Object.assign({
633
+ className: "nav-box"
634
+ }, {
635
+ children: jsx(Breadcrumbs, {
636
+ list: breadcrumbsList,
637
+ separator: breadcrumbsSeparator,
638
+ onClickItem: onClickBreadcrums
639
+ })
640
+ }));
641
+ };
642
+ /** 处理内容 */
643
+
644
+
645
+ var handContent = function handContent() {
646
+ if ((list === null || list === void 0 ? void 0 : list.length) === 0 && !loading) {
647
+ // 空状态
648
+ return jsx("div", Object.assign({
649
+ className: "paraui-selector-main-list-no-data"
650
+ }, {
651
+ children: jsx(Empty, Object.assign({}, emptyProps, {
652
+ size: (emptyProps === null || emptyProps === void 0 ? void 0 : emptyProps.size) || "small"
653
+ }))
654
+ }));
655
+ }
656
+
657
+ return jsxs(Fragment, {
658
+ children: [handAllCheck(), handNode(), handLoadMore()]
659
+ });
660
+ };
246
661
 
247
662
  var handClass = function handClass() {
248
- var str = 'paraui-selector-main paraui-selector-main-select';
663
+ var str = 'paraui-selector-main-content';
249
664
  if (className) str += ' ' + className;
665
+ if (disabled) str += ' paraui-selector-main-content-disabled';
250
666
  return str;
251
667
  };
252
668
 
253
669
  return jsxs("div", Object.assign({
254
- className: handClass(),
255
- style: style
670
+ className: handClass()
256
671
  }, {
257
- children: [jsx(Search, {
258
- btnType: "inside"
259
- }), jsx("div", Object.assign({
260
- className: 'nav-box'
261
- }, {
262
- children: jsx(Breadcrumbs, {
263
- list: list,
264
- separator: '-'
265
- })
266
- })), jsxs("div", Object.assign({
672
+ children: [handBreadcrumbs(), jsx("div", Object.assign({
267
673
  className: "paraui-selector-main-list"
268
674
  }, {
269
- children: [jsx(BranchNode, {
270
- mainTitle: '全选',
271
- selectMode: 'check'
272
- }), jsx(LeafNode, {
273
- selectMode: 'check',
274
- mainTitle: "\u4E3B\u8981\u4FE1\u606F",
275
- subTitle: "\u8F85\u52A9\u4FE1\u606F",
276
- tag: "\u6807\u7B7E"
277
- }), jsx(LeafNode, {
278
- selectMode: 'check',
279
- mainTitle: "\u4E3B\u8981\u4FE1\u606F",
280
- subTitle: "\u8F85\u52A9\u4FE1\u606F",
281
- tag: "\u6807\u7B7E"
282
- }), jsx(BranchNode, {
283
- selectMode: 'check',
284
- mainTitle: '主要信息',
285
- subTitle: "\u8F85\u52A9\u4FE1\u606F",
286
- tag: "\u6807\u7B7E"
287
- }), jsx(LeafNode, {
288
- selectMode: 'check',
289
- mainTitle: "\u4E3B\u8981\u4FE1\u606F",
290
- subTitle: "\u8F85\u52A9\u4FE1\u606F",
291
- tag: "\u6807\u7B7E"
292
- }), jsx(BranchNode, {
293
- selectMode: 'check',
294
- mainTitle: '主要信息',
295
- subTitle: "\u8F85\u52A9\u4FE1\u606F",
296
- tag: "\u6807\u7B7E"
297
- }), jsx(BranchNode, {
298
- selectMode: 'check',
299
- mainTitle: '主要信息',
300
- subTitle: "\u8F85\u52A9\u4FE1\u606F",
301
- tag: "\u6807\u7B7E"
302
- }), jsx("div", Object.assign({
303
- className: "paraui-selector-main-list-more"
304
- }, {
305
- children: jsx("span", Object.assign({
306
- className: "more-btn"
307
- }, {
308
- children: "\u67E5\u770B\u66F4\u591A"
309
- }))
310
- }))]
675
+ children: handContent()
311
676
  }))]
312
677
  }));
313
678
  };
314
679
 
315
- var css_248z = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/";
316
- styleInject(css_248z);
317
-
318
- var Selector = function Selector(props) {
680
+ var SelectorMain = function SelectorMain(props) {
319
681
  var className = props.className,
320
682
  style = props.style,
321
- _props$layout = props.layout,
322
- layout = _props$layout === void 0 ? 'lr' : _props$layout;
323
- props.ctx;
324
- props.url;
325
- props.data; // 处理className
683
+ value = props.value,
684
+ _props$rowKey2 = props.rowKey,
685
+ rowKey = _props$rowKey2 === void 0 ? 'key' : _props$rowKey2,
686
+ _props$nodeMode2 = props.nodeMode,
687
+ nodeMode = _props$nodeMode2 === void 0 ? 'branch' : _props$nodeMode2,
688
+ selectMode = props.selectMode,
689
+ _props$loadMore2 = props.loadMore,
690
+ loadMore = _props$loadMore2 === void 0 ? false : _props$loadMore2,
691
+ _props$isAllCheck2 = props.isAllCheck,
692
+ isAllCheck = _props$isAllCheck2 === void 0 ? false : _props$isAllCheck2,
693
+ disabled = props.disabled,
694
+ detail = props.detail,
695
+ detailRender = props.detailRender,
696
+ isLazy = props.isLazy,
697
+ list = props.list,
698
+ groupType = props.groupType,
699
+ groupRange = props.groupRange,
700
+ search = props.search,
701
+ searchPlaceholder = props.searchPlaceholder,
702
+ searchTrigger = props.searchTrigger,
703
+ searchLoading = props.searchLoading,
704
+ searchList = props.searchList,
705
+ loading = props.loading,
706
+ breadcrumbs = props.breadcrumbs,
707
+ _props$breadcrumbsSep2 = props.breadcrumbsSeparator,
708
+ breadcrumbsSeparator = _props$breadcrumbsSep2 === void 0 ? '-' : _props$breadcrumbsSep2,
709
+ _props$breadcrumbsLis2 = props.breadcrumbsList,
710
+ breadcrumbsList = _props$breadcrumbsLis2 === void 0 ? [] : _props$breadcrumbsLis2,
711
+ fieldConfig = props.fieldConfig,
712
+ onClickBreadcrumbs = props.onClickBreadcrumbs,
713
+ onLevel = props.onLevel,
714
+ onSelect = props.onSelect,
715
+ onLoad = props.onLoad,
716
+ onAllCheck = props.onAllCheck,
717
+ onSearch = props.onSearch;
718
+ var intl = useFormatMessage('Selector', localeJson);
326
719
 
327
- var handClass = function handClass() {
328
- var str = 'paraui-selector';
329
- if (className) str += ' ' + className;
330
- if (layout) str += ' paraui-selector-' + layout;
331
- return str;
720
+ var _useState3 = useState(false),
721
+ _useState4 = _slicedToArray(_useState3, 2),
722
+ showSearch = _useState4[0],
723
+ setShowSearch = _useState4[1];
724
+
725
+ var _useState5 = useState(''),
726
+ _useState6 = _slicedToArray(_useState5, 2),
727
+ searchStr = _useState6[0],
728
+ setSearchStr = _useState6[1];
729
+
730
+ var constData = useRef({
731
+ searchTimer: null,
732
+ searchStr: ''
733
+ });
734
+ /** 改变搜索框 */
735
+
736
+ var changeSearch = function changeSearch(val) {
737
+ setSearchStr(val);
738
+ constData.current.searchStr = val;
739
+ if (searchTrigger !== 'onEnter') onSearchCom();
332
740
  };
741
+ /** 搜索框回车事件 */
333
742
 
334
- return jsx("div", Object.assign({
743
+
744
+ var onEnterSearch = function onEnterSearch() {
745
+ onSearchCom(true);
746
+ };
747
+ /** 点击搜索按钮 */
748
+
749
+
750
+ var onClickRightIcon = function onClickRightIcon() {
751
+ onSearchCom(true);
752
+ };
753
+ /** 向外抛出搜索事件 */
754
+
755
+
756
+ var onSearchCom = function onSearchCom(bol) {
757
+ clearTimeout(constData.current.searchTimer);
758
+ constData.current.searchTimer = setTimeout(function () {
759
+ setShowSearch(!!constData.current.searchStr);
760
+ onSearch && onSearch(constData.current.searchStr, !!bol);
761
+ }, 100);
762
+ };
763
+ /** 搜索dom */
764
+
765
+
766
+ var handSearchDom = function handSearchDom() {
767
+ var handSearchIcon = function handSearchIcon() {
768
+ if (!searchStr) return jsx(Refresh, {});
769
+ return jsx(SearchIcon, {});
770
+ };
771
+
772
+ return jsx(Fragment, {
773
+ children: search && jsx(Search, {
774
+ value: searchStr,
775
+ rightIconExist: true,
776
+ showBtn: false,
777
+ rightIcon: handSearchIcon(),
778
+ btnType: "inside",
779
+ onChange: changeSearch,
780
+ onEnter: onEnterSearch,
781
+ placeholder: searchPlaceholder || intl({
782
+ id: 'pleaseEnter'
783
+ }),
784
+ onClickRightIcon: onClickRightIcon
785
+ })
786
+ });
787
+ };
788
+ /** 渲染列表 */
789
+
790
+
791
+ var handListDom = function handListDom() {
792
+ return jsx(SelectorMainContent, {
793
+ className: "paraui-selector-main-list-box",
794
+ value: value,
795
+ rowKey: rowKey,
796
+ nodeMode: nodeMode,
797
+ selectMode: selectMode,
798
+ loadMore: loadMore,
799
+ isAllCheck: isAllCheck,
800
+ disabled: disabled,
801
+ detail: detail,
802
+ detailRender: detailRender,
803
+ isLazy: isLazy,
804
+ list: list,
805
+ loading: loading,
806
+ groupType: groupRange === 'list' || groupRange === 'searchList' ? groupType : undefined,
807
+ breadcrumbs: breadcrumbs,
808
+ breadcrumbsSeparator: breadcrumbsSeparator,
809
+ breadcrumbsList: breadcrumbsList,
810
+ fieldConfig: fieldConfig,
811
+ onClickBreadcrumbs: onClickBreadcrumbs,
812
+ onLevel: onLevel,
813
+ onSelect: onSelect,
814
+ onLoad: onLoad,
815
+ onAllCheck: onAllCheck
816
+ }, "list");
817
+ };
818
+ /** 渲染搜索列表 */
819
+
820
+
821
+ var handSearchList = function handSearchList() {
822
+ if (!showSearch) return;
823
+ return jsx(SelectorMainContent, {
824
+ className: 'paraui-selector-main-search-content',
825
+ value: value,
826
+ rowKey: rowKey,
827
+ nodeMode: nodeMode,
828
+ selectMode: selectMode,
829
+ loadMore: false,
830
+ isAllCheck: false,
831
+ disabled: disabled,
832
+ detail: detail,
833
+ detailRender: detailRender,
834
+ isLazy: false,
835
+ list: searchList,
836
+ groupType: groupRange === 'search' || groupRange === 'searchList' ? groupType : undefined,
837
+ fieldConfig: fieldConfig,
838
+ loading: searchLoading,
839
+ onSelect: onSelect
840
+ }, "search");
841
+ };
842
+ /** 处理loading */
843
+
844
+
845
+ var handLoading = function handLoading() {
846
+ if (searchLoading || loading) {
847
+ return jsx(Loading, {});
848
+ }
849
+ }; // 处理class
850
+
851
+
852
+ var handClass = function handClass() {
853
+ var str = 'paraui-selector-main';
854
+ if (className) str += ' ' + className;
855
+ if (selectMode === 'check') str += ' paraui-selector-main-select';
856
+ if (showSearch) str += ' paraui-selector-main-show-search';
857
+ if (search) str += ' paraui-selector-main-search';
858
+ if (disabled === true) str += ' paraui-selector-main-disabled';
859
+ return str;
860
+ };
861
+
862
+ return jsxs("div", Object.assign({
863
+ className: handClass(),
864
+ style: style
865
+ }, {
866
+ children: [handSearchDom(), jsxs("div", Object.assign({
867
+ className: "paraui-selector-main-box"
868
+ }, {
869
+ children: [handListDom(), handSearchList(), handLoading()]
870
+ }))]
871
+ }));
872
+ };
873
+
874
+ var css_248z$1 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/\n.paraui-selector-data.paraui-selector-data-node > .paraui-selector-data-node-box {\n padding: 24px 0 16px 0;\n display: flex;\n flex-direction: column;\n height: 100%;\n}\n.paraui-selector-data.paraui-selector-data-node > .paraui-selector-data-node-box > .title {\n font-size: 14px;\n color: rgb(46, 55, 67);\n padding: 0 16px;\n margin-bottom: 16px;\n}\n.paraui-selector-data.paraui-selector-data-node > .paraui-selector-data-node-box > .title > .title-content {\n margin-left: 8px;\n}\n.paraui-selector-data.paraui-selector-data-node > .paraui-selector-data-node-box > .content {\n overflow-y: auto;\n}\n.paraui-selector-data.paraui-selector-data-tag > .paraui-selector-data-tag-box {\n padding-top: 12px;\n height: 100%;\n display: flex;\n flex-direction: column;\n}\n.paraui-selector-data.paraui-selector-data-tag > .paraui-selector-data-tag-box > .title {\n font-size: 14px;\n color: rgb(46, 55, 67);\n padding: 0 16px;\n}\n.paraui-selector-data.paraui-selector-data-tag > .paraui-selector-data-tag-box > .content {\n padding: 0 16px 12px 16px;\n overflow: auto;\n}\n.paraui-selector-data.paraui-selector-data-tag > .paraui-selector-data-tag-box > .content > .content-tag {\n display: inline-flex;\n height: 24px;\n align-items: center;\n padding: 0 8px;\n border-radius: 2px;\n background-color: rgba(171, 176, 185, 0.2);\n margin-right: 8px;\n margin-top: 6px;\n}\n.paraui-selector-data.paraui-selector-data-tag > .paraui-selector-data-tag-box > .content > .content-tag > span {\n font-size: 12px;\n color: rgb(46, 55, 67);\n}\n.paraui-selector-data.paraui-selector-data-tag > .paraui-selector-data-tag-box > .content > .content-tag > svg {\n font-size: 16px;\n margin-left: 4px;\n color: rgba(46, 55, 67, 0.7);\n cursor: pointer;\n}";
875
+ styleInject(css_248z$1);
876
+
877
+ var SelectorData = function SelectorData(props) {
878
+ var className = props.className,
879
+ _props$layout = props.layout,
880
+ layout = _props$layout === void 0 ? 'node' : _props$layout,
881
+ style = props.style,
882
+ list = props.list,
883
+ groupType = props.groupType,
884
+ nodeMode = props.nodeMode,
885
+ backDataFieldConfig = props.backDataFieldConfig,
886
+ detail = props.detail,
887
+ detailRender = props.detailRender,
888
+ disabled = props.disabled,
889
+ handSelectorNodeInfo = props.handSelectorNodeInfo,
890
+ selectDataTitleRender = props.selectDataTitleRender,
891
+ _onClose = props.onClose;
892
+ var intl = useFormatMessage('Selector', localeJson);
893
+
894
+ var _useState = useState({}),
895
+ _useState2 = _slicedToArray(_useState, 2),
896
+ listCom = _useState2[0],
897
+ setListCom = _useState2[1];
898
+
899
+ var constData = useRef({
900
+ listTypeJson: {},
901
+ backDataFieldConfig: {}
902
+ });
903
+ constData.current.listTypeJson = ArrayToObject('value', groupType);
904
+ constData.current.backDataFieldConfig = backDataFieldConfig || {};
905
+ useEffect(function () {
906
+ if (list && groupType && groupType.length > 0) {
907
+ var json = {};
908
+
909
+ for (var i = 0, l = list.length; i < l; i++) {
910
+ var item = list[i];
911
+ var type = item[constData.current.backDataFieldConfig.type || ''];
912
+ if (!json[type]) json[type] = [];
913
+ json[type].push(item);
914
+ }
915
+
916
+ setListCom(json);
917
+ }
918
+ }, [list]);
919
+ /** 处理禁用 */
920
+
921
+ var handDisabled = function handDisabled(itemConfig) {
922
+ if (disabled) {
923
+ if (disabled === true) return true;
924
+
925
+ if (disabled instanceof Array) {
926
+ var keyStr = (backDataFieldConfig === null || backDataFieldConfig === void 0 ? void 0 : backDataFieldConfig.key) || '';
927
+ var val = itemConfig[keyStr];
928
+
929
+ if (disabled.indexOf(val) !== -1) {
930
+ return true;
931
+ }
932
+ }
933
+ }
934
+
935
+ return false;
936
+ };
937
+ /** 处理每个节点的配置 */
938
+
939
+
940
+ var handNodeConfig = function handNodeConfig(itemConfig, index) {
941
+ var item = itemConfig;
942
+ if (handSelectorNodeInfo) item = handSelectorNodeInfo(itemConfig);
943
+ var disabledItem = handDisabled(itemConfig);
944
+ var json = {
945
+ useCase: 'edit',
946
+ close: !disabledItem,
947
+ detail: detail,
948
+ data: item,
949
+ nodeMode: nodeMode,
950
+ onClose: function onClose() {
951
+ return _onClose && _onClose(item, index);
952
+ },
953
+ disabled: handDisabled(itemConfig)
954
+ };
955
+ /** 节点类型 */
956
+
957
+ if (item.leaf !== undefined) json.nodeMode = item.leaf ? 'leaf' : 'branch';
958
+ /** 渲染字段 */
959
+
960
+ var arr = ['img', 'mainTitle', 'subTitle', 'tag'];
961
+
962
+ for (var i = 0, l = arr.length; i < l; i++) {
963
+ var key = arr[i] || '';
964
+ var backName = backDataFieldConfig && backDataFieldConfig[key] || '';
965
+ json[key] = item[backName];
966
+ }
967
+ /** 详情render */
968
+
969
+
970
+ if (detailRender) {
971
+ json.detailRender = function () {
972
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee() {
973
+ var Dom;
974
+ return regenerator.wrap(function _callee$(_context) {
975
+ while (1) {
976
+ switch (_context.prev = _context.next) {
977
+ case 0:
978
+ _context.next = 2;
979
+ return detailRender(item, false);
980
+
981
+ case 2:
982
+ Dom = _context.sent;
983
+ return _context.abrupt("return", Dom);
984
+
985
+ case 4:
986
+ case "end":
987
+ return _context.stop();
988
+ }
989
+ }
990
+ }, _callee);
991
+ }));
992
+ };
993
+ }
994
+ /** 是否具有删除 */
995
+
996
+
997
+ if (item.close !== undefined) json.close = item.close;
998
+ return json;
999
+ };
1000
+ /** 处理节点 */
1001
+
1002
+
1003
+ var handNode = function handNode() {
1004
+ return list === null || list === void 0 ? void 0 : list.map(function (item, index) {
1005
+ return jsx(SelectorNode, Object.assign({}, handNodeConfig(item, index)), index);
1006
+ });
1007
+ };
1008
+ /** 处理标题 */
1009
+
1010
+
1011
+ var handTitle = function handTitle() {
1012
+ var handTitleTag = function handTitleTag() {
1013
+ if (selectDataTitleRender) return selectDataTitleRender(list);
1014
+
1015
+ if (groupType) {
1016
+ return jsx(Fragment, {
1017
+ children: groupType.map(function (item, index) {
1018
+ var num = 0;
1019
+ var val = item.value;
1020
+ if (listCom[val]) num = listCom[val].length;
1021
+ if (num === 0) return;
1022
+ return jsxs("span", Object.assign({
1023
+ className: "title-content"
1024
+ }, {
1025
+ children: [num, "\u4E2A", item.label || item.value]
1026
+ }), index);
1027
+ })
1028
+ });
1029
+ }
1030
+ };
1031
+
1032
+ return jsxs("div", Object.assign({
1033
+ className: "title"
1034
+ }, {
1035
+ children: [jsxs("span", Object.assign({
1036
+ className: "title-tip"
1037
+ }, {
1038
+ children: [intl({
1039
+ id: 'selected'
1040
+ }), ":"]
1041
+ })), handTitleTag()]
1042
+ }));
1043
+ }; // 处理节点内容
1044
+
1045
+
1046
+ var handContentNode = function handContentNode() {
1047
+ return jsxs("div", Object.assign({
1048
+ className: "paraui-selector-data-node-box"
1049
+ }, {
1050
+ children: [handTitle(), jsx("div", Object.assign({
1051
+ className: "content"
1052
+ }, {
1053
+ children: handNode()
1054
+ }))]
1055
+ }));
1056
+ }; // 处理tag内容
1057
+
1058
+
1059
+ var handContentTag = function handContentTag() {
1060
+ return jsxs("div", Object.assign({
1061
+ className: "paraui-selector-data-tag-box"
1062
+ }, {
1063
+ children: [handTitle(), jsx("div", Object.assign({
1064
+ className: "content"
1065
+ }, {
1066
+ children: list === null || list === void 0 ? void 0 : list.map(function (item, index) {
1067
+ var disabledItem = handDisabled(item);
1068
+ return jsxs("span", Object.assign({
1069
+ className: "content-tag"
1070
+ }, {
1071
+ children: [jsx("span", {
1072
+ children: item[(backDataFieldConfig === null || backDataFieldConfig === void 0 ? void 0 : backDataFieldConfig.mainTitle) || ''] || item[(backDataFieldConfig === null || backDataFieldConfig === void 0 ? void 0 : backDataFieldConfig.key) || '']
1073
+ }), !disabledItem && jsx(CloseIcon, {
1074
+ onClick: function onClick() {
1075
+ return _onClose && _onClose(item, index);
1076
+ }
1077
+ })]
1078
+ }), index);
1079
+ })
1080
+ }))]
1081
+ }));
1082
+ };
1083
+
1084
+ var handClass = function handClass() {
1085
+ var str = 'paraui-selector-data';
1086
+ if (layout) str += ' paraui-selector-data-' + layout;
1087
+ if (disabled === true) str += ' paraui-selector-data-disabled';
1088
+ if (className) str += ' ' + className;
1089
+ return str;
1090
+ };
1091
+
1092
+ return jsx("div", Object.assign({
1093
+ className: handClass(),
1094
+ style: style
1095
+ }, {
1096
+ children: layout === 'node' ? handContentNode() : handContentTag()
1097
+ }));
1098
+ };
1099
+
1100
+ /**
1101
+ * 发送请求
1102
+ * @param obj {ReqFuncProps} 请求信息
1103
+ */
1104
+
1105
+ var reqFunc = function reqFunc(obj) {
1106
+ var method = obj.method,
1107
+ data = obj.data,
1108
+ otherProps = __rest(obj, ["method", "data"]);
1109
+
1110
+ if (method === 'Get') {
1111
+ return Get(Object.assign({
1112
+ params: data
1113
+ }, otherProps));
1114
+ }
1115
+
1116
+ if (method === 'Post') {
1117
+ return Post(Object.assign({
1118
+ data: data
1119
+ }, otherProps));
1120
+ }
1121
+ };
1122
+
1123
+ var css_248z = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/\n.paraui-selector {\n border: 1px solid rgba(171, 176, 185, 0.4);\n border-radius: 4px;\n display: flex;\n height: 100%;\n width: 100%;\n}\n.paraui-selector.paraui-selector-lr > .paraui-selector-main {\n width: 50%;\n}\n.paraui-selector.paraui-selector-lr > .paraui-selector-data {\n width: 50%;\n border-left: 1px solid rgba(171, 176, 185, 0.4);\n}\n.paraui-selector.paraui-selector-tb {\n flex-direction: column;\n}\n.paraui-selector.paraui-selector-tb > .paraui-selector-data {\n border-bottom: 1px solid rgba(171, 176, 185, 0.4);\n max-height: 106px;\n}\n.paraui-selector.paraui-selector-tb > .paraui-selector-main {\n overflow-y: auto;\n height: auto;\n flex: 1;\n}";
1124
+ styleInject(css_248z);
1125
+
1126
+ var handFieldConfig = function handFieldConfig(fieldConfig, rowKey) {
1127
+ var json = Object.assign({
1128
+ mainTitle: 'label',
1129
+ children: 'children',
1130
+ parentId: 'parentId',
1131
+ key: rowKey,
1132
+ type: 'type'
1133
+ }, fieldConfig);
1134
+ return json;
1135
+ };
1136
+
1137
+ var Selector = function Selector(props) {
1138
+ var _useGlobalProps = useGlobalProps(props, 'Selector'),
1139
+ className = _useGlobalProps.className,
1140
+ style = _useGlobalProps.style,
1141
+ _useGlobalProps$rowKe = _useGlobalProps.rowKey,
1142
+ rowKey = _useGlobalProps$rowKe === void 0 ? 'key' : _useGlobalProps$rowKe,
1143
+ _useGlobalProps$layou = _useGlobalProps.layout,
1144
+ layout = _useGlobalProps$layou === void 0 ? 'lr' : _useGlobalProps$layou,
1145
+ _useGlobalProps$nodeM = _useGlobalProps.nodeMode,
1146
+ nodeMode = _useGlobalProps$nodeM === void 0 ? 'branch' : _useGlobalProps$nodeM,
1147
+ selectMode = _useGlobalProps.selectMode,
1148
+ refresh = _useGlobalProps.refresh,
1149
+ ctx = _useGlobalProps.ctx,
1150
+ url = _useGlobalProps.url,
1151
+ _useGlobalProps$metho = _useGlobalProps.method,
1152
+ method = _useGlobalProps$metho === void 0 ? 'Get' : _useGlobalProps$metho,
1153
+ value = _useGlobalProps.value,
1154
+ defaultValue = _useGlobalProps.defaultValue,
1155
+ data = _useGlobalProps.data,
1156
+ _useGlobalProps$pagin = _useGlobalProps.pagination,
1157
+ pagination = _useGlobalProps$pagin === void 0 ? false : _useGlobalProps$pagin,
1158
+ _useGlobalProps$size = _useGlobalProps.size,
1159
+ size = _useGlobalProps$size === void 0 ? 10 : _useGlobalProps$size,
1160
+ _useGlobalProps$isLaz = _useGlobalProps.isLazy,
1161
+ isLazy = _useGlobalProps$isLaz === void 0 ? false : _useGlobalProps$isLaz,
1162
+ _useGlobalProps$isAll = _useGlobalProps.isAllCheck,
1163
+ isAllCheck = _useGlobalProps$isAll === void 0 ? true : _useGlobalProps$isAll,
1164
+ disabled = _useGlobalProps.disabled,
1165
+ detail = _useGlobalProps.detail,
1166
+ detailRender = _useGlobalProps.detailRender,
1167
+ backDataFieldConfig = _useGlobalProps.backDataFieldConfig,
1168
+ search = _useGlobalProps.search,
1169
+ searchPlaceholder = _useGlobalProps.searchPlaceholder,
1170
+ _useGlobalProps$searc = _useGlobalProps.searchTrigger,
1171
+ searchTrigger = _useGlobalProps$searc === void 0 ? 'onChange' : _useGlobalProps$searc,
1172
+ _useGlobalProps$bread = _useGlobalProps.breadcrumbs,
1173
+ breadcrumbs = _useGlobalProps$bread === void 0 ? true : _useGlobalProps$bread,
1174
+ breadcrumbsSeparator = _useGlobalProps.breadcrumbsSeparator,
1175
+ breadcrumbsHead = _useGlobalProps.breadcrumbsHead,
1176
+ _useGlobalProps$showb = _useGlobalProps.showbreadcrumbsHead,
1177
+ showbreadcrumbsHead = _useGlobalProps$showb === void 0 ? true : _useGlobalProps$showb,
1178
+ groupType = _useGlobalProps.groupType,
1179
+ _useGlobalProps$group = _useGlobalProps.groupRange,
1180
+ groupRange = _useGlobalProps$group === void 0 ? 'search' : _useGlobalProps$group,
1181
+ emptyProps = _useGlobalProps.emptyProps,
1182
+ onChange = _useGlobalProps.onChange,
1183
+ onSelect = _useGlobalProps.onSelect,
1184
+ onSearch = _useGlobalProps.onSearch;
1185
+
1186
+ var intl = useFormatMessage('Selector', localeJson);
1187
+ var fieldConfigHand = handFieldConfig(props.fieldConfig, rowKey); // 字段配置,对应数据字段
1188
+
1189
+ var selectorFieldConfigHand = Object.assign(Object.assign({}, fieldConfigHand), backDataFieldConfig); // 选中值字段配置,对应数据字段
1190
+
1191
+ var _useState = useState([]),
1192
+ _useState2 = _slicedToArray(_useState, 2),
1193
+ currentData = _useState2[0],
1194
+ setCurrentData = _useState2[1]; // 当前展示的数据
1195
+
1196
+
1197
+ var _useState3 = useState(false),
1198
+ _useState4 = _slicedToArray(_useState3, 2),
1199
+ loadMore = _useState4[0],
1200
+ setLoadMore = _useState4[1]; // 加载更多
1201
+
1202
+
1203
+ var _useState5 = useState([]),
1204
+ _useState6 = _slicedToArray(_useState5, 2),
1205
+ valueCom = _useState6[0],
1206
+ setValueCom = _useState6[1]; // 绑定的值
1207
+
1208
+
1209
+ var _useState7 = useState({}),
1210
+ _useState8 = _slicedToArray(_useState7, 2),
1211
+ valueJsonCom = _useState8[0],
1212
+ setValueJsonCom = _useState8[1]; // 绑定的值,json
1213
+
1214
+
1215
+ var _useState9 = useState([]),
1216
+ _useState10 = _slicedToArray(_useState9, 2),
1217
+ breadcrumbsList = _useState10[0],
1218
+ setBreadcrumbsList = _useState10[1]; // 面包屑
1219
+
1220
+
1221
+ var _useState11 = useState(false),
1222
+ _useState12 = _slicedToArray(_useState11, 2),
1223
+ searchLoading = _useState12[0],
1224
+ setSearchLoading = _useState12[1]; // 搜索loading
1225
+
1226
+
1227
+ var _useState13 = useState([]),
1228
+ _useState14 = _slicedToArray(_useState13, 2),
1229
+ searchList = _useState14[0],
1230
+ setSearchList = _useState14[1]; // 搜索数据
1231
+
1232
+
1233
+ var _useState15 = useState(true),
1234
+ _useState16 = _slicedToArray(_useState15, 2),
1235
+ loadingCom = _useState16[0],
1236
+ setLoadingCom = _useState16[1];
1237
+
1238
+ var _useState17 = useState(),
1239
+ _useState18 = _slicedToArray(_useState17, 2),
1240
+ refreshCom = _useState18[0],
1241
+ setRefreshCom = _useState18[1];
1242
+
1243
+ var constData = useRef({
1244
+ /** 对象集合 所有的 */
1245
+ jsonData: {},
1246
+
1247
+ /** 浅拷贝对象 所有的 */
1248
+ jsonDataCopy: {},
1249
+
1250
+ /** 第一层数据 */
1251
+ oneDataList: [],
1252
+
1253
+ /** 当前页数据源 本地数据为当前页所有的数据,请求数据为当前展示的数据 */
1254
+ currentSourceData: [],
1255
+
1256
+ /** 当前选中值的mapping */
1257
+ selectValueJson: {},
1258
+
1259
+ /** 面包屑数据 */
1260
+ breadcrumbsList: [],
1261
+
1262
+ /** 接口id */
1263
+ reqId: Math.random().toString(),
1264
+
1265
+ /** 请求数据 */
1266
+ reqParams: {
1267
+ size: 10,
1268
+ pagination: false,
1269
+ isLazy: false
1270
+ },
1271
+
1272
+ /** 不是懒加载, 是否请求过 */
1273
+ noLazyReq: false,
1274
+
1275
+ /** 更改数据定时器 */
1276
+ reqTimer: null,
1277
+
1278
+ /** 页数 */
1279
+ page: 1
1280
+ }); // 常量
1281
+
1282
+ constData.current.reqParams.size = size;
1283
+ constData.current.reqParams.pagination = pagination;
1284
+ constData.current.reqParams.isLazy = isLazy; // 本地数据 有接口的全量数据 -> 走本地数据逻辑
1285
+
1286
+ var isReqLocalData = props.data || !constData.current.reqParams.isLazy && constData.current.noLazyReq;
1287
+ useEffect(function () {
1288
+ if (defaultValue !== undefined) handValue(defaultValue);
1289
+ return function () {
1290
+ clearTimeout(constData.current.reqTimer);
1291
+ };
1292
+ }, []);
1293
+ useEffect(function () {
1294
+ if (value !== undefined) handValue(value);
1295
+ }, [value]); // 处理源数据
1296
+
1297
+ useEffect(function () {
1298
+ if (data) {
1299
+ var treeData = convertTree(data, false);
1300
+ constData.current.oneDataList = treeData;
1301
+ constData.current.currentSourceData = treeData;
1302
+ setBreadcrumbsList([]);
1303
+ handInitCurrent();
1304
+ }
1305
+ }, [data]);
1306
+ useEffect(function () {
1307
+ if (url) {
1308
+ setBreadcrumbsList([]);
1309
+ handInitCurrent();
1310
+ }
1311
+ }, [url]); // 请求数据
1312
+
1313
+ useEffect(function () {
1314
+ clearTimeout(constData.current.reqTimer);
1315
+ if (props.url) Cancel(constData.current.reqId);
1316
+ constData.current.reqTimer = setTimeout(function () {
1317
+ // 本地数据 不是懒加载的全量接口数据
1318
+ if (isReqLocalData) {
1319
+ var currentSourceData = constData.current.currentSourceData;
1320
+
1321
+ if (constData.current.reqParams.pagination) {
1322
+ // 分页
1323
+ var sliceData = currentSourceData.slice(0, constData.current.page * constData.current.reqParams.size);
1324
+ setCurrentData(sliceData); // 没有加载更多
1325
+
1326
+ if (constData.current.page * constData.current.reqParams.size >= currentSourceData.length) {
1327
+ setLoadMore(false);
1328
+ } else {
1329
+ setLoadMore(true);
1330
+ }
1331
+ } else {
1332
+ // 不分页
1333
+ setCurrentData(currentSourceData);
1334
+ }
1335
+
1336
+ setLoadingCom(false);
1337
+ } // 远程数据
1338
+
1339
+
1340
+ if (props.url) {
1341
+ var obj = {
1342
+ method: method,
1343
+ url: props.url,
1344
+ ctx: ctx,
1345
+ uuid: constData.current.reqId,
1346
+ data: Object.assign({
1347
+ parentId: handParentId()
1348
+ }, props.params)
1349
+ }; // 懒加载
1350
+
1351
+ if (constData.current.reqParams.isLazy) {
1352
+ // 分页
1353
+ if (constData.current.reqParams.pagination) {
1354
+ obj.data.size = constData.current.reqParams.size;
1355
+ obj.data.page = constData.current.page;
1356
+ }
1357
+
1358
+ handReq(props.paramsCallback ? props.paramsCallback(obj) : obj);
1359
+ } else {
1360
+ // 不是懒加载 全量数据 只请求一次
1361
+ if (!constData.current.noLazyReq) handReq(props.paramsCallback ? props.paramsCallback(obj) : obj);
1362
+ }
1363
+ }
1364
+ }, 50);
1365
+ }, [refreshCom]);
1366
+ useEffect(function () {
1367
+ if (refresh) refreshFunc();
1368
+ }, [refresh]);
1369
+ /** 刷新 */
1370
+
1371
+ var refreshFunc = function refreshFunc() {
1372
+ if (!isReqLocalData) {
1373
+ constData.current.currentSourceData = [];
1374
+ }
1375
+
1376
+ handInitCurrent();
1377
+ };
1378
+ /**
1379
+ * 处理节点数据
1380
+ * @param item 节点数据
1381
+ * @param bol 是否是搜索
1382
+ * */
1383
+
1384
+
1385
+ var handNodeData = function handNodeData(item, bol) {
1386
+ var itemData = {
1387
+ key: item[rowKey],
1388
+ parentId: item[fieldConfigHand.parentId],
1389
+ type: item[fieldConfigHand.type],
1390
+ img: item[fieldConfigHand.img],
1391
+ mainTitle: item[fieldConfigHand.mainTitle],
1392
+ subTitle: item[fieldConfigHand.subTitle],
1393
+ tag: item[fieldConfigHand.tag],
1394
+ children: [],
1395
+ disabled: false,
1396
+ choice: selectMode !== undefined,
1397
+ detail: detail,
1398
+ leaf: nodeMode === 'leaf',
1399
+ //child: false,
1400
+ data: item
1401
+ }; // 如果外部存在节点回调
1402
+
1403
+ if (props.handNodeInfo) itemData = props.handNodeInfo(itemData);
1404
+ return itemData;
1405
+ };
1406
+ /**
1407
+ * 转换树结构 记录原始数据,跟处理过的数据
1408
+ * @param arr 数据源
1409
+ * @param bol true不生成树
1410
+ * */
1411
+
1412
+
1413
+ var convertTree = function convertTree(arr, bol) {
1414
+ var handArr = [];
1415
+ var json = {}; // 生成mappingd对象
1416
+
1417
+ var recurrence = function recurrence(list) {
1418
+ for (var i = 0, l = list.length; i < l; i++) {
1419
+ var item = list[i];
1420
+ var keyStr = item[rowKey];
1421
+ var itemData = handNodeData(item);
1422
+ json[keyStr] = itemData;
1423
+ var childrenName = fieldConfigHand.children;
1424
+ constData.current.jsonDataCopy[keyStr] = item; // 原始数据
1425
+
1426
+ constData.current.jsonData[keyStr] = itemData; // 处理过的数据
1427
+
1428
+ if (item[childrenName]) {
1429
+ recurrence(item[childrenName]);
1430
+ }
1431
+ }
1432
+ };
1433
+
1434
+ recurrence(arr); // 生成tree数据
1435
+
1436
+ var arrKey = Object.keys(json);
1437
+
1438
+ for (var i = 0, l = arrKey.length; i < l; i++) {
1439
+ var keyStr = arrKey[i];
1440
+ var item = json[keyStr];
1441
+ var parentId = item.parentId || '';
1442
+
1443
+ if (bol) {
1444
+ handArr.push(item);
1445
+ continue;
1446
+ }
1447
+
1448
+ if (parentId && json[parentId]) {
1449
+ if (!json[parentId].children) json[parentId].children = [];
1450
+ json[parentId].children.push(item);
1451
+ } else {
1452
+ handArr.push(item);
1453
+ }
1454
+ }
1455
+
1456
+ return handArr;
1457
+ };
1458
+ /** 处理parentId */
1459
+
1460
+
1461
+ var handParentId = function handParentId() {
1462
+ var parentId = undefined;
1463
+ if (props.breadcrumbsHead) parentId = props.breadcrumbsHead.value;
1464
+
1465
+ if (constData.current.breadcrumbsList.length > 1) {
1466
+ // 包含了根,所以要多加1
1467
+ var item = constData.current.breadcrumbsList[constData.current.breadcrumbsList.length - 1];
1468
+ parentId = item.value;
1469
+ }
1470
+
1471
+ return parentId;
1472
+ };
1473
+ /** 请求 */
1474
+
1475
+
1476
+ var handReq = function handReq(obj) {
1477
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee() {
1478
+ var _yield$reqFunc, data, err;
1479
+
1480
+ return regenerator.wrap(function _callee$(_context) {
1481
+ while (1) {
1482
+ switch (_context.prev = _context.next) {
1483
+ case 0:
1484
+ setLoadingCom(true);
1485
+ _context.next = 3;
1486
+ return reqFunc(obj);
1487
+
1488
+ case 3:
1489
+ _yield$reqFunc = _context.sent;
1490
+ data = _yield$reqFunc.data;
1491
+ err = _yield$reqFunc.err;
1492
+
1493
+ if (!err) {
1494
+ _context.next = 10;
1495
+ break;
1496
+ }
1497
+
1498
+ setLoadingCom(false); // cancel的接口不清除上次展示的数据
1499
+
1500
+ if (!err.__CANCEL__) {
1501
+ if (constData.current.reqParams.isLazy) {
1502
+ // 懒加载
1503
+ if (constData.current.reqParams.pagination) {
1504
+ // 分页 第一页不处理
1505
+ if (constData.current.page !== 1) constData.current.page = constData.current.page - 1;
1506
+ }
1507
+ }
1508
+ }
1509
+
1510
+ return _context.abrupt("return");
1511
+
1512
+ case 10:
1513
+ if (!props.requestCallback) {
1514
+ _context.next = 13;
1515
+ break;
1516
+ }
1517
+
1518
+ props.requestCallback(data, function (handData) {
1519
+ setLoadingCom(false);
1520
+ handReqData(data);
1521
+ });
1522
+ return _context.abrupt("return");
1523
+
1524
+ case 13:
1525
+ setLoadingCom(false);
1526
+ handReqData(data);
1527
+
1528
+ case 15:
1529
+ case "end":
1530
+ return _context.stop();
1531
+ }
1532
+ }
1533
+ }, _callee);
1534
+ }));
1535
+ };
1536
+ /** 接口回来处理数据 */
1537
+
1538
+
1539
+ var handReqData = function handReqData(resultData) {
1540
+ if (constData.current.reqParams.isLazy) {
1541
+ // 懒加载
1542
+ if (constData.current.reqParams.pagination) {
1543
+ // 分页
1544
+ var result = resultData.data || {};
1545
+ var arr = result.list || [];
1546
+ var total = result.total;
1547
+ var arrHand = convertTree(arr, true);
1548
+ var currentD = [].concat(_toConsumableArray(constData.current.currentSourceData), _toConsumableArray(arrHand));
1549
+ constData.current.currentSourceData = currentD;
1550
+ setCurrentData(currentD);
1551
+
1552
+ if (constData.current.page * constData.current.reqParams.size >= total) {
1553
+ setLoadMore(false);
1554
+ } else {
1555
+ setLoadMore(true);
1556
+ }
1557
+ } else {
1558
+ // 不分页 必须返回平铺的数组
1559
+ var _arr = resultData.data || [];
1560
+
1561
+ var treeData = convertTree(_arr, true);
1562
+ constData.current.currentSourceData = treeData;
1563
+ setCurrentData(treeData);
1564
+ }
1565
+ } else {
1566
+ // 不是懒加载 只请求一次
1567
+ constData.current.noLazyReq = true;
1568
+
1569
+ var _arr2 = resultData.data || [];
1570
+
1571
+ var _treeData = convertTree(_arr2, false);
1572
+
1573
+ constData.current.oneDataList = _treeData; // 第一层数据
1574
+
1575
+ constData.current.currentSourceData = _treeData;
1576
+ handInitCurrent();
1577
+ }
1578
+ };
1579
+ /** 当前页初始更新 */
1580
+
1581
+
1582
+ var handInitCurrent = function handInitCurrent() {
1583
+ constData.current.page = 1;
1584
+ setRefreshCom(Math.random());
1585
+ };
1586
+ /** 处理value */
1587
+
1588
+
1589
+ var handValue = function handValue(val) {
1590
+ var handVal = !val ? [] : [val];
1591
+
1592
+ if (val instanceof Array) {
1593
+ handVal = _toConsumableArray(val);
1594
+ }
1595
+
1596
+ var json = ArrayToObject(selectorFieldConfigHand.key, handVal);
1597
+ constData.current.selectValueJson = json;
1598
+ setValueJsonCom(json);
1599
+ setValueCom(handVal);
1600
+ };
1601
+ /** 点击下级,添加面包屑 */
1602
+
1603
+
1604
+ var onLevelAddBreadcrumbs = function onLevelAddBreadcrumbs(item) {
1605
+ breadcrumbsList.push({
1606
+ label: item.mainTitle,
1607
+ value: item.key || ''
1608
+ });
1609
+ setBreadcrumbsList(_toConsumableArray(breadcrumbsList));
1610
+ };
1611
+ /** 点击下级 */
1612
+
1613
+
1614
+ var onLevelCom = function onLevelCom(item) {
1615
+ onLevelAddBreadcrumbs(item);
1616
+
1617
+ if (isReqLocalData) {
1618
+ // 本地数据
1619
+ constData.current.currentSourceData = item.children || [];
1620
+ handInitCurrent();
1621
+ } else {
1622
+ // 请求数据
1623
+ if (constData.current.reqParams.isLazy) {
1624
+ // 懒加载
1625
+ if (constData.current.reqParams.pagination) {
1626
+ // 分页
1627
+ constData.current.currentSourceData = [];
1628
+ }
1629
+
1630
+ handInitCurrent();
1631
+ }
1632
+ }
1633
+ };
1634
+ /** 处理抛出去的数据 */
1635
+
1636
+
1637
+ var handEmitValue = function handEmitValue(item) {
1638
+ var arr = ['key', 'img', 'mainTitle', 'subTitle', 'tag'];
1639
+
1640
+ if (props.groupType && props.groupType.length > 0) {
1641
+ arr.push('type');
1642
+ }
1643
+
1644
+ var json = {};
1645
+
1646
+ for (var i = 0, l = arr.length; i < l; i++) {
1647
+ var arrItem = arr[i];
1648
+ var name = selectorFieldConfigHand[arrItem];
1649
+ if (name) json[name] = item[arrItem];
1650
+ }
1651
+
1652
+ return json;
1653
+ };
1654
+ /**
1655
+ * 向外触发onchane事件
1656
+ * @param val 向外抛的值
1657
+ * @param valCom 设置组件的值
1658
+ * @param node 处理过的节点数据
1659
+ * @param rowData 原始数据节点
1660
+ * */
1661
+
1662
+
1663
+ var onChangeEmit = function onChangeEmit(val, valCom, node, rowData) {
1664
+ onChange && onChange(val, node, rowData);
1665
+
1666
+ if (value == undefined) {
1667
+ handValue(!val ? [] : val);
1668
+ }
1669
+ };
1670
+ /** 选择数据 */
1671
+
1672
+
1673
+ var onSelectCom = function onSelectCom(item) {
1674
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee2() {
1675
+ var keyStr, selectVal, bol, json, arr, node, rowData, i, l, valueComItem, valueComItemId, _json;
1676
+
1677
+ return regenerator.wrap(function _callee2$(_context2) {
1678
+ while (1) {
1679
+ switch (_context2.prev = _context2.next) {
1680
+ case 0:
1681
+ keyStr = item.key || ''; // key
1682
+ // 单选且选中,点击不触发
1683
+
1684
+ if (!(selectMode === 'radio' && valueJsonCom[keyStr])) {
1685
+ _context2.next = 3;
1686
+ break;
1687
+ }
1688
+
1689
+ return _context2.abrupt("return");
1690
+
1691
+ case 3:
1692
+ selectVal = constData.current.selectValueJson[keyStr]; // 存在选中值当中 -> 选中变不选中
1693
+
1694
+ if (!onSelect) {
1695
+ _context2.next = 10;
1696
+ break;
1697
+ }
1698
+
1699
+ _context2.next = 7;
1700
+ return onSelect(item, selectMode === 'radio' ? true : !selectVal, false);
1701
+
1702
+ case 7:
1703
+ bol = _context2.sent;
1704
+
1705
+ if (!bol) {
1706
+ _context2.next = 10;
1707
+ break;
1708
+ }
1709
+
1710
+ return _context2.abrupt("return");
1711
+
1712
+ case 10:
1713
+ // 单选
1714
+ if (selectMode === 'radio') {
1715
+ json = handEmitValue(item);
1716
+ onChangeEmit(json, [json], constData.current.jsonData[keyStr], constData.current.jsonDataCopy[keyStr]);
1717
+ } // 多选
1718
+
1719
+
1720
+ if (selectMode === 'check') {
1721
+ arr = [];
1722
+ node = {}; // 处理过得数据
1723
+
1724
+ rowData = {}; // 原始数据
1725
+ // 把即将不选中的值,从valueCom里面拿掉
1726
+
1727
+ for (i = 0, l = valueCom.length; i < l; i++) {
1728
+ valueComItem = valueCom[i]; // 选中valueCom都保留
1729
+ // 不选中 保留valueCom里面的key不等于当前的key
1730
+
1731
+ if (!selectVal || item.key !== valueComItem[selectorFieldConfigHand.key]) {
1732
+ valueComItemId = valueComItem[selectorFieldConfigHand.key];
1733
+ node[valueComItemId] = constData.current.jsonData[valueComItemId];
1734
+ rowData[valueComItemId] = constData.current.jsonDataCopy[valueComItemId];
1735
+ arr.push(valueComItem);
1736
+ }
1737
+ } // 不选中 -> 选中
1738
+
1739
+
1740
+ if (!selectVal) {
1741
+ _json = handEmitValue(item);
1742
+ node[keyStr] = constData.current.jsonData[keyStr];
1743
+ rowData[keyStr] = constData.current.jsonDataCopy[keyStr];
1744
+ arr.push(_json);
1745
+ }
1746
+
1747
+ onChangeEmit(arr, arr, node, rowData);
1748
+ }
1749
+
1750
+ case 12:
1751
+ case "end":
1752
+ return _context2.stop();
1753
+ }
1754
+ }
1755
+ }, _callee2);
1756
+ }));
1757
+ };
1758
+ /** 处理禁用状态 */
1759
+
1760
+
1761
+ var handDisabled = function handDisabled(item) {
1762
+ if (disabled) {
1763
+ if (disabled === true) return true;
1764
+
1765
+ if (disabled instanceof Array) {
1766
+ if (item.key && disabled.indexOf(item.key) !== -1) {
1767
+ return true;
1768
+ }
1769
+ }
1770
+ }
1771
+
1772
+ if (item.disabled) return true;
1773
+ return false;
1774
+ };
1775
+ /**
1776
+ * 点击全选
1777
+ * @param bol true全选
1778
+ * */
1779
+
1780
+
1781
+ var onAllCheckCom = function onAllCheckCom(bol) {
1782
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee3() {
1783
+ var arrList, arrVal, arrval1, node, rowData, selectArr, selectEmitData, i, l, item, keyStr, disabledItem, _i, _l, _item, _keyStr, emitArr, flag;
1784
+
1785
+ return regenerator.wrap(function _callee3$(_context3) {
1786
+ while (1) {
1787
+ switch (_context3.prev = _context3.next) {
1788
+ case 0:
1789
+ arrList = _toConsumableArray(currentData); // 当前列的数据
1790
+
1791
+ arrVal = _toConsumableArray(valueCom); // 全选 绑定的值
1792
+
1793
+ arrval1 = []; // 全不选 绑定的值
1794
+
1795
+ node = {}; // 处理过得数据
1796
+
1797
+ rowData = {}; // 原始数据
1798
+
1799
+ selectArr = []; // 全不选 - 当前列选中值
1800
+
1801
+ selectEmitData = []; // 选择事件抛出去的值
1802
+ // 循环当前列数据
1803
+
1804
+ i = 0, l = arrList.length;
1805
+
1806
+ case 8:
1807
+ if (!(i < l)) {
1808
+ _context3.next = 18;
1809
+ break;
1810
+ }
1811
+
1812
+ item = arrList[i];
1813
+ keyStr = item.key || '';
1814
+ disabledItem = handDisabled(item);
1815
+
1816
+ if (!disabledItem) {
1817
+ _context3.next = 14;
1818
+ break;
1819
+ }
1820
+
1821
+ return _context3.abrupt("continue", 15);
1822
+
1823
+ case 14:
1824
+ if (bol) {
1825
+ // 全选
1826
+ if (!constData.current.selectValueJson[keyStr]) {
1827
+ // 不存在选中值中
1828
+ arrVal.push(handEmitValue(item));
1829
+ selectEmitData.push(item);
1830
+ }
1831
+ } else {
1832
+ // 全不选
1833
+ if (constData.current.selectValueJson[keyStr]) {
1834
+ // 存在选中值中,拿掉
1835
+ selectArr.push(keyStr);
1836
+ selectEmitData.push(item);
1837
+ }
1838
+ }
1839
+
1840
+ case 15:
1841
+ i++;
1842
+ _context3.next = 8;
1843
+ break;
1844
+
1845
+ case 18:
1846
+ for (_i = 0, _l = arrVal.length; _i < _l; _i++) {
1847
+ _item = arrVal[_i];
1848
+ _keyStr = _item[selectorFieldConfigHand.key];
1849
+
1850
+ if (bol) {
1851
+ // 全选
1852
+ node[_keyStr] = constData.current.jsonData[_keyStr];
1853
+ rowData[_keyStr] = constData.current.jsonDataCopy[_keyStr];
1854
+ } else {
1855
+ // 全不选
1856
+ if (selectArr.indexOf(_keyStr) === -1) {
1857
+ // 不存在 全不选 - 当前列选中值
1858
+ node[_keyStr] = constData.current.jsonData[_keyStr];
1859
+ rowData[_keyStr] = constData.current.jsonDataCopy[_keyStr];
1860
+ arrval1.push(_item);
1861
+ }
1862
+ }
1863
+ }
1864
+
1865
+ emitArr = bol ? arrVal : arrval1;
1866
+
1867
+ if (!onSelect) {
1868
+ _context3.next = 26;
1869
+ break;
1870
+ }
1871
+
1872
+ _context3.next = 23;
1873
+ return onSelect(selectEmitData, !!bol, false);
1874
+
1875
+ case 23:
1876
+ flag = _context3.sent;
1877
+
1878
+ if (!flag) {
1879
+ _context3.next = 26;
1880
+ break;
1881
+ }
1882
+
1883
+ return _context3.abrupt("return");
1884
+
1885
+ case 26:
1886
+ onChangeEmit(emitArr, emitArr, node, rowData);
1887
+
1888
+ case 27:
1889
+ case "end":
1890
+ return _context3.stop();
1891
+ }
1892
+ }
1893
+ }, _callee3);
1894
+ }));
1895
+ };
1896
+ /** 点击查看更多 */
1897
+
1898
+
1899
+ var onLoadCom = function onLoadCom() {
1900
+ constData.current.page = constData.current.page + 1;
1901
+ setRefreshCom(Math.random());
1902
+ };
1903
+ /** 处理面包屑数组 */
1904
+
1905
+
1906
+ var handBreadcrumbsList = function handBreadcrumbsList() {
1907
+ var arr = _toConsumableArray(breadcrumbsList);
1908
+
1909
+ var oneItem = breadcrumbsHead || {
1910
+ label: intl({
1911
+ id: 'root'
1912
+ }),
1913
+ value: '_paraui_first_floor'
1914
+ };
1915
+ if (showbreadcrumbsHead) arr.unshift(oneItem);
1916
+ constData.current.breadcrumbsList = arr;
1917
+ return arr;
1918
+ };
1919
+ /** 截取面包屑数据 */
1920
+
1921
+
1922
+ var spliceBreadcrumbs = function spliceBreadcrumbs(item) {
1923
+ var arr = [];
1924
+
1925
+ for (var i = 0, l = breadcrumbsList.length; i < l; i++) {
1926
+ var itemB = breadcrumbsList[i];
1927
+ arr.push(itemB);
1928
+
1929
+ if (itemB.value === item.value) {
1930
+ break;
1931
+ }
1932
+ }
1933
+
1934
+ return arr;
1935
+ };
1936
+ /** 点击面包屑 */
1937
+
1938
+
1939
+ var onClickBreadcrumbsCom = function onClickBreadcrumbsCom(item) {
1940
+ var list = constData.current.breadcrumbsList; // 点击最后一层,不触发数据变更
1941
+
1942
+ if (list.length === 0 || item.value === list[list.length - 1].value) {
1943
+ return;
1944
+ }
1945
+
1946
+ var keyStr = item.value || '';
1947
+ var oneValue = breadcrumbsHead ? breadcrumbsHead.value : '_paraui_first_floor'; // 设置面包屑
1948
+
1949
+ if (keyStr === oneValue) {
1950
+ // 第一层
1951
+ setBreadcrumbsList([]);
1952
+ } else {
1953
+ // 除了第一级,最后一级
1954
+ setBreadcrumbsList(spliceBreadcrumbs(item));
1955
+ }
1956
+
1957
+ if (isReqLocalData) {
1958
+ if (keyStr === oneValue) {
1959
+ // 第一层
1960
+ constData.current.currentSourceData = _toConsumableArray(constData.current.oneDataList);
1961
+ } else {
1962
+ // 除了第一级,最后一级
1963
+ var itemData = constData.current.jsonData[keyStr];
1964
+ constData.current.currentSourceData = itemData[fieldConfigHand.children];
1965
+ }
1966
+ } else {
1967
+ // 请求数据
1968
+ if (constData.current.reqParams.isLazy) {
1969
+ // 懒加载
1970
+ if (constData.current.reqParams.pagination) {
1971
+ // 分页
1972
+ constData.current.currentSourceData = [];
1973
+ }
1974
+ }
1975
+ }
1976
+
1977
+ handInitCurrent();
1978
+ };
1979
+ /** 搜索回调 */
1980
+
1981
+
1982
+ var onSearchCom = function onSearchCom(val, bol) {
1983
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee4() {
1984
+ var result, arr;
1985
+ return regenerator.wrap(function _callee4$(_context4) {
1986
+ while (1) {
1987
+ switch (_context4.prev = _context4.next) {
1988
+ case 0:
1989
+ if (!(val === '')) {
1990
+ _context4.next = 5;
1991
+ break;
1992
+ }
1993
+
1994
+ setSearchList([]);
1995
+ setSearchLoading(false);
1996
+
1997
+ if (bol) {
1998
+ // 当前页刷新
1999
+ refreshFunc();
2000
+ }
2001
+
2002
+ return _context4.abrupt("return");
2003
+
2004
+ case 5:
2005
+ if (!onSearch) {
2006
+ _context4.next = 13;
2007
+ break;
2008
+ }
2009
+
2010
+ setSearchLoading(true);
2011
+ _context4.next = 9;
2012
+ return onSearch(val);
2013
+
2014
+ case 9:
2015
+ result = _context4.sent;
2016
+ arr = convertTree(result || [], true);
2017
+ setSearchList(arr);
2018
+ setSearchLoading(false);
2019
+
2020
+ case 13:
2021
+ case "end":
2022
+ return _context4.stop();
2023
+ }
2024
+ }
2025
+ }, _callee4);
2026
+ }));
2027
+ };
2028
+ /** 删除数据 */
2029
+
2030
+
2031
+ var onCloseCom = function onCloseCom(item, index) {
2032
+ if (selectMode === 'radio') {
2033
+ onChangeEmit(null, [], {}, {});
2034
+ }
2035
+
2036
+ if (selectMode === 'check') {
2037
+ var arr = _toConsumableArray(valueCom);
2038
+
2039
+ arr.splice(index, 1);
2040
+ var node = {}; // 处理过得数据
2041
+
2042
+ var rowData = {}; // 原始数据
2043
+
2044
+ for (var i = 0, l = arr.length; i < l; i++) {
2045
+ var _item2 = arr[i];
2046
+ var keyStr = _item2[selectorFieldConfigHand.key];
2047
+ node[keyStr] = constData.current.jsonData[keyStr];
2048
+ rowData[keyStr] = constData.current.jsonDataCopy[keyStr];
2049
+ }
2050
+
2051
+ onChangeEmit(arr, arr, node, rowData);
2052
+ }
2053
+ };
2054
+ /** 处理返回数据dom配置 */
2055
+
2056
+
2057
+ var handSelectorData = function handSelectorData() {
2058
+ return jsx(SelectorData, {
2059
+ layout: layout === 'tb' ? 'tag' : 'node',
2060
+ backDataFieldConfig: selectorFieldConfigHand,
2061
+ groupType: groupType,
2062
+ handSelectorNodeInfo: props.handSelectorNodeInfo,
2063
+ list: valueCom,
2064
+ nodeMode: nodeMode,
2065
+ detail: detail,
2066
+ detailRender: detailRender,
2067
+ emptyProps: emptyProps,
2068
+ onClose: onCloseCom,
2069
+ selectDataTitleRender: props.selectDataTitleRender,
2070
+ disabled: disabled
2071
+ });
2072
+ }; // 处理className
2073
+
2074
+
2075
+ var handClass = function handClass() {
2076
+ var str = 'paraui-selector';
2077
+ if (className) str += ' ' + className;
2078
+ if (layout) str += ' paraui-selector-' + layout;
2079
+ if (selectMode) str += ' paraui-selector-' + selectMode;
2080
+ if (disabled === true) str += ' paraui-selector-disabled';
2081
+ return str;
2082
+ };
2083
+
2084
+ return jsxs("div", Object.assign({
335
2085
  className: handClass(),
336
2086
  style: style
337
2087
  }, {
338
- children: jsx(SelectorMain, {})
2088
+ children: [layout === 'tb' && handSelectorData(), jsx(SelectorMain, {
2089
+ rowKey: rowKey,
2090
+ value: valueJsonCom,
2091
+ loadMore: loadMore,
2092
+ isAllCheck: isAllCheck,
2093
+ list: currentData,
2094
+ groupType: groupType,
2095
+ groupRange: groupRange,
2096
+ fieldConfig: fieldConfigHand,
2097
+ nodeMode: nodeMode,
2098
+ selectMode: selectMode,
2099
+ isLazy: isLazy,
2100
+ detail: detail,
2101
+ detailRender: detailRender,
2102
+ search: search,
2103
+ searchTrigger: searchTrigger,
2104
+ searchPlaceholder: searchPlaceholder,
2105
+ searchLoading: searchLoading,
2106
+ disabled: disabled,
2107
+ loading: loadingCom,
2108
+ searchList: searchList,
2109
+ breadcrumbs: breadcrumbs,
2110
+ breadcrumbsSeparator: breadcrumbsSeparator,
2111
+ breadcrumbsList: handBreadcrumbsList(),
2112
+ emptyProps: emptyProps,
2113
+ onLevel: onLevelCom,
2114
+ onSelect: onSelectCom,
2115
+ onLoad: onLoadCom,
2116
+ onAllCheck: onAllCheckCom,
2117
+ onClickBreadcrumbs: onClickBreadcrumbsCom,
2118
+ onSearch: onSearchCom
2119
+ }), layout === 'lr' && handSelectorData()]
339
2120
  }));
340
2121
  };
341
2122
 
342
- export { Selector as default };
2123
+ export { Selector as default, handFieldConfig };