fan-standard-comp 3.1.9 → 3.2.0

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 (176) hide show
  1. package/Readme.md +35 -0
  2. package/dist/fan-standard-comp.umd.js +15 -10
  3. package/es/ButtonGroup/ButtonList.js +0 -3
  4. package/es/ButtonGroup/ButtonMenu.js +0 -3
  5. package/es/ButtonGroup/PopConfirmTitle.js +5 -15
  6. package/es/ButtonGroup/index.d.ts +2 -0
  7. package/es/ButtonGroup/index.js +223 -193
  8. package/es/ButtonGroup/style/index.less +1 -1
  9. package/es/DragContent/DragBar.js +2 -6
  10. package/es/DragContent/index.js +44 -75
  11. package/es/FormComp/ChunkUploader/api.js +6 -10
  12. package/es/FormComp/ChunkUploader/index.js +105 -171
  13. package/es/FormComp/ChunkUploader/lib.js +4 -17
  14. package/es/FormComp/ChunkUploader/upload-queue.class.js +10 -45
  15. package/es/FormComp/ChunkUploader/worker.js +0 -3
  16. package/es/FormComp/EditButton/index.js +24 -49
  17. package/es/FormComp/FieldComponent/ReUpload.js +18 -38
  18. package/es/FormComp/FieldComponent/RefactorTreeSelect.js +37 -75
  19. package/es/FormComp/FieldComponent/TitleNode.js +1 -3
  20. package/es/FormComp/FieldComponent/index.js +38 -74
  21. package/es/FormComp/FieldComponent/setReadonlyValues.js +34 -63
  22. package/es/FormComp/FieldComponent/style/index.less +6 -0
  23. package/es/FormComp/RenderItemGroup/index.js +46 -74
  24. package/es/FormComp/Uploader/index.js +36 -77
  25. package/es/FormComp/Uploader/util.js +0 -6
  26. package/es/FormComp/VarTemplate/index.js +58 -96
  27. package/es/NavLeafScroll/index.js +172 -154
  28. package/es/NavLeafScroll/style/index.less +33 -1
  29. package/es/RefactorTree/index.js +36 -53
  30. package/es/RefactorTree/indexTreeNode.js +35 -68
  31. package/es/RefactorTree/util.js +9 -43
  32. package/es/SpecIcon/fonts/iconfont.js +7 -12
  33. package/es/SpecIcon/index.js +16 -25
  34. package/es/SplitterLayout/Pane.js +2 -5
  35. package/es/SplitterLayout/index.js +20 -70
  36. package/es/StandardContent/SplitterLayout/Pane.js +6 -10
  37. package/es/StandardContent/SplitterLayout/index.js +12 -63
  38. package/es/StandardContent/SubfieldContent.js +12 -14
  39. package/es/StandardContent/WrapperContent.js +8 -10
  40. package/es/StandardDragModal/ChangeStandardModal.d.ts +44 -0
  41. package/es/StandardDragModal/ChangeStandardModal.js +493 -0
  42. package/es/StandardDragModal/DraggableModal.d.ts +7 -0
  43. package/es/StandardDragModal/DraggableModal.js +31 -0
  44. package/es/StandardDragModal/DraggableModalContext.d.ts +9 -0
  45. package/es/StandardDragModal/DraggableModalContext.js +5 -0
  46. package/es/StandardDragModal/DraggableModalInner.d.ts +16 -0
  47. package/es/StandardDragModal/DraggableModalInner.js +114 -0
  48. package/es/StandardDragModal/DraggableModalProvider.d.ts +4 -0
  49. package/es/StandardDragModal/DraggableModalProvider.js +40 -0
  50. package/es/StandardDragModal/Modal.d.ts +11 -0
  51. package/es/StandardDragModal/Modal.js +24 -0
  52. package/es/StandardDragModal/ResizeHandle.d.ts +2 -0
  53. package/es/StandardDragModal/ResizeHandle.js +8 -0
  54. package/es/StandardDragModal/clamp.d.ts +1 -0
  55. package/es/StandardDragModal/clamp.js +3 -0
  56. package/es/StandardDragModal/draggableModalReducer.d.ts +66 -0
  57. package/es/StandardDragModal/draggableModalReducer.js +157 -0
  58. package/es/StandardDragModal/getWindowSize.d.ts +4 -0
  59. package/es/StandardDragModal/getWindowSize.js +6 -0
  60. package/es/StandardDragModal/index.d.ts +3 -11
  61. package/es/StandardDragModal/index.js +3 -30
  62. package/es/StandardDragModal/index.less +65 -0
  63. package/es/StandardDragModal/useDrag.d.ts +5 -0
  64. package/es/StandardDragModal/useDrag.js +66 -0
  65. package/es/StandardDragModal/usePrevious.d.ts +1 -0
  66. package/es/StandardDragModal/usePrevious.js +8 -0
  67. package/es/StandardDragModal/useResize.d.ts +7 -0
  68. package/es/StandardDragModal/useResize.js +74 -0
  69. package/es/StandardFilter/index.d.ts +1 -0
  70. package/es/StandardFilter/index.js +32 -70
  71. package/es/StandardForm/ActionList.js +5 -7
  72. package/es/StandardForm/StepForm.js +50 -71
  73. package/es/StandardForm/TabForm.js +58 -70
  74. package/es/StandardForm/index.js +37 -56
  75. package/es/StandardModal/UpdateFormRef.js +1 -4
  76. package/es/StandardModal/index.d.ts +0 -1
  77. package/es/StandardModal/index.js +115 -159
  78. package/es/StandardPanel/index.js +19 -35
  79. package/es/StandardTable/index.js +20 -30
  80. package/es/components/IconNode/index.js +0 -4
  81. package/es/index.d.ts +1 -0
  82. package/es/index.js +15 -14
  83. package/es/utils/ValueFormat.js +0 -9
  84. package/es/utils/dictSelectUtil.js +153 -0
  85. package/es/utils/filterPermission.js +16 -34
  86. package/es/utils/getParentNodes.js +24 -47
  87. package/es/utils/index.js +2 -1
  88. package/lib/ButtonGroup/ButtonList.js +1 -13
  89. package/lib/ButtonGroup/ButtonMenu.js +1 -8
  90. package/lib/ButtonGroup/PopConfirmTitle.js +3 -16
  91. package/lib/ButtonGroup/index.d.ts +2 -0
  92. package/lib/ButtonGroup/index.js +226 -216
  93. package/lib/ButtonGroup/style/index.less +1 -1
  94. package/lib/DragContent/DragBar.js +2 -10
  95. package/lib/DragContent/index.js +47 -85
  96. package/lib/FormComp/ChunkUploader/api.js +6 -15
  97. package/lib/FormComp/ChunkUploader/index.js +107 -185
  98. package/lib/FormComp/ChunkUploader/lib.js +8 -27
  99. package/lib/FormComp/ChunkUploader/upload-queue.class.js +10 -46
  100. package/lib/FormComp/ChunkUploader/worker.js +1 -5
  101. package/lib/FormComp/EditButton/index.js +26 -60
  102. package/lib/FormComp/FieldComponent/ReUpload.js +21 -50
  103. package/lib/FormComp/FieldComponent/RefactorTreeSelect.js +39 -90
  104. package/lib/FormComp/FieldComponent/TitleNode.js +1 -5
  105. package/lib/FormComp/FieldComponent/index.js +38 -110
  106. package/lib/FormComp/FieldComponent/setReadonlyValues.js +37 -79
  107. package/lib/FormComp/FieldComponent/style/index.less +6 -0
  108. package/lib/FormComp/RenderItemGroup/index.js +46 -87
  109. package/lib/FormComp/Uploader/index.js +38 -95
  110. package/lib/FormComp/Uploader/util.js +1 -9
  111. package/lib/FormComp/VarTemplate/index.js +62 -106
  112. package/lib/FormComp/index.js +0 -2
  113. package/lib/NavLeafScroll/index.js +174 -165
  114. package/lib/NavLeafScroll/style/index.less +33 -1
  115. package/lib/RefactorTree/index.js +36 -67
  116. package/lib/RefactorTree/indexTreeNode.js +37 -83
  117. package/lib/RefactorTree/util.js +11 -45
  118. package/lib/SpecIcon/fonts/iconfont.js +7 -12
  119. package/lib/SpecIcon/index.js +16 -30
  120. package/lib/SplitterLayout/Pane.js +0 -7
  121. package/lib/SplitterLayout/index.js +18 -72
  122. package/lib/StandardContent/SplitterLayout/Pane.js +6 -14
  123. package/lib/StandardContent/SplitterLayout/index.js +12 -68
  124. package/lib/StandardContent/SubfieldContent.js +12 -21
  125. package/lib/StandardContent/WrapperContent.js +8 -16
  126. package/lib/StandardDragModal/ChangeStandardModal.d.ts +44 -0
  127. package/lib/StandardDragModal/ChangeStandardModal.js +502 -0
  128. package/lib/StandardDragModal/DraggableModal.d.ts +7 -0
  129. package/lib/StandardDragModal/DraggableModal.js +40 -0
  130. package/lib/StandardDragModal/DraggableModalContext.d.ts +9 -0
  131. package/lib/StandardDragModal/DraggableModalContext.js +15 -0
  132. package/lib/StandardDragModal/DraggableModalInner.d.ts +16 -0
  133. package/lib/StandardDragModal/DraggableModalInner.js +124 -0
  134. package/lib/StandardDragModal/DraggableModalProvider.d.ts +4 -0
  135. package/lib/StandardDragModal/DraggableModalProvider.js +48 -0
  136. package/lib/StandardDragModal/Modal.d.ts +11 -0
  137. package/lib/StandardDragModal/Modal.js +32 -0
  138. package/lib/StandardDragModal/ResizeHandle.d.ts +2 -0
  139. package/lib/StandardDragModal/ResizeHandle.js +18 -0
  140. package/lib/StandardDragModal/clamp.d.ts +1 -0
  141. package/lib/StandardDragModal/clamp.js +10 -0
  142. package/lib/StandardDragModal/draggableModalReducer.d.ts +66 -0
  143. package/lib/StandardDragModal/draggableModalReducer.js +167 -0
  144. package/lib/StandardDragModal/getWindowSize.d.ts +4 -0
  145. package/lib/StandardDragModal/getWindowSize.js +13 -0
  146. package/lib/StandardDragModal/index.d.ts +3 -11
  147. package/lib/StandardDragModal/index.js +33 -38
  148. package/lib/StandardDragModal/index.less +65 -0
  149. package/lib/StandardDragModal/useDrag.d.ts +5 -0
  150. package/lib/StandardDragModal/useDrag.js +73 -0
  151. package/lib/StandardDragModal/usePrevious.d.ts +1 -0
  152. package/lib/StandardDragModal/usePrevious.js +15 -0
  153. package/lib/StandardDragModal/useResize.d.ts +7 -0
  154. package/lib/StandardDragModal/useResize.js +81 -0
  155. package/lib/StandardFilter/index.d.ts +1 -0
  156. package/lib/StandardFilter/index.js +30 -78
  157. package/lib/StandardForm/ActionList.js +5 -12
  158. package/lib/StandardForm/StepForm.js +52 -90
  159. package/lib/StandardForm/TabForm.js +61 -88
  160. package/lib/StandardForm/index.js +40 -75
  161. package/lib/StandardModal/UpdateFormRef.js +4 -12
  162. package/lib/StandardModal/index.d.ts +0 -1
  163. package/lib/StandardModal/index.js +117 -184
  164. package/lib/StandardPanel/index.js +22 -48
  165. package/lib/StandardTable/index.js +20 -39
  166. package/lib/components/IconNode/index.js +0 -7
  167. package/lib/components/index.js +0 -2
  168. package/lib/data/index.js +4 -7
  169. package/lib/index.d.ts +1 -0
  170. package/lib/index.js +50 -68
  171. package/lib/utils/ValueFormat.js +0 -10
  172. package/lib/utils/dictSelectUtil.js +161 -0
  173. package/lib/utils/filterPermission.js +15 -39
  174. package/lib/utils/getParentNodes.js +25 -52
  175. package/lib/utils/index.js +24 -9
  176. package/package.json +6 -5
@@ -4,106 +4,93 @@ import "antd/es/empty/style";
4
4
  import _Empty from "antd/es/empty";
5
5
  import "antd/es/popconfirm/style";
6
6
  import _Popconfirm from "antd/es/popconfirm";
7
-
8
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
-
10
- import { __rest } from "tslib"; // 重构树控件,可直接配置数据
11
-
7
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
8
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
10
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
11
+ import { __rest } from "tslib";
12
+ // 重构树控件,可直接配置数据
12
13
  import React, { useMemo } from 'react';
13
14
  import SpecIcon from '../SpecIcon/index';
14
15
  import { transDataParam, resetDataWithLimit, resetDataWithDisabled } from './util';
15
16
  import './style/index.less';
16
-
17
17
  var RefactorTree = function RefactorTree(props) {
18
18
  var treeData = props.treeData,
19
- rootName = props.rootName,
20
- rootKey = props.rootKey,
21
- emptyDescription = props.emptyDescription,
22
- _props$optionName = props.optionName,
23
- optionName = _props$optionName === void 0 ? {
24
- value: 'value',
25
- title: 'title',
26
- children: 'children',
27
- disabled: 'disabled'
28
- } : _props$optionName,
29
- defaultSelectedKeys = props.defaultSelectedKeys,
30
- nodeExtra = props.nodeExtra,
31
- _props$selectable = props.selectable,
32
- selectable = _props$selectable === void 0 ? true : _props$selectable,
33
- nodeControl = props.nodeControl,
34
- limitKey = props.limitKey,
35
- checkedKeys = props.checkedKeys,
36
- checkStrictly = props.checkStrictly,
37
- onSelect = props.onSelect,
38
- onCheck = props.onCheck,
39
- titleRender = props.titleRender,
40
- disabledFields = props.disabledFields,
41
- otherProps = __rest(props, ["treeData", "rootName", "rootKey", "emptyDescription", "optionName", "defaultSelectedKeys", "nodeExtra", "selectable", "nodeControl", "limitKey", "checkedKeys", "checkStrictly", "onSelect", "onCheck", "titleRender", "disabledFields"]); // const { title, value, children, disabled } = { value: 'value', title: 'title', children: 'children', disabled: 'disabled', ...optionName }
19
+ rootName = props.rootName,
20
+ rootKey = props.rootKey,
21
+ emptyDescription = props.emptyDescription,
22
+ _props$optionName = props.optionName,
23
+ optionName = _props$optionName === void 0 ? {
24
+ value: 'value',
25
+ title: 'title',
26
+ children: 'children',
27
+ disabled: 'disabled'
28
+ } : _props$optionName,
29
+ defaultSelectedKeys = props.defaultSelectedKeys,
30
+ nodeExtra = props.nodeExtra,
31
+ _props$selectable = props.selectable,
32
+ selectable = _props$selectable === void 0 ? true : _props$selectable,
33
+ nodeControl = props.nodeControl,
34
+ limitKey = props.limitKey,
35
+ checkedKeys = props.checkedKeys,
36
+ checkStrictly = props.checkStrictly,
37
+ onSelect = props.onSelect,
38
+ onCheck = props.onCheck,
39
+ titleRender = props.titleRender,
40
+ disabledFields = props.disabledFields,
41
+ otherProps = __rest(props, ["treeData", "rootName", "rootKey", "emptyDescription", "optionName", "defaultSelectedKeys", "nodeExtra", "selectable", "nodeControl", "limitKey", "checkedKeys", "checkStrictly", "onSelect", "onCheck", "titleRender", "disabledFields"]); // const { title, value, children, disabled } = { value: 'value', title: 'title', children: 'children', disabled: 'disabled', ...optionName }
42
42
  // 重新组合指定数据源字段
43
-
44
-
45
43
  var transTreeData = useMemo(function () {
46
44
  var _ref;
47
-
48
45
  var afterTransData = transDataParam(treeData, optionName); // 通过转换后的数据
49
-
50
- var resultData; // 如果有配置根节点,则添加 一个根节点数据
51
-
52
- resultData = rootName ? [(_ref = {}, _defineProperty(_ref, optionName.title || 'title', rootName), _defineProperty(_ref, optionName.key || 'key', rootKey || '0'), _defineProperty(_ref, 'children', afterTransData), _ref)] : afterTransData; // 有配置limitKey指定限制同级节点时,添加判断节点选择限制(在父子节点不相关联条件下使用checkStrictly=true)
53
-
46
+ var resultData;
47
+ // 如果有配置根节点,则添加 一个根节点数据
48
+ resultData = rootName ? [(_ref = {}, _defineProperty(_ref, optionName.title || 'title', rootName), _defineProperty(_ref, optionName.key || 'key', rootKey || '0'), _defineProperty(_ref, 'children', afterTransData), _ref)] : afterTransData;
49
+ // 有配置limitKey指定限制同级节点时,添加判断节点选择限制(在父子节点不相关联条件下使用checkStrictly=true)
54
50
  if (checkStrictly && limitKey && checkedKeys) {
55
51
  if (Array.isArray(checkedKeys) && checkedKeys.length > 0 || checkedKeys && Array.isArray(checkedKeys.checked) && checkedKeys.checked.length > 0) {
56
52
  resultData = resetDataWithLimit(Array.isArray(checkedKeys) ? checkedKeys : checkedKeys.checked, resultData, optionName, limitKey);
57
53
  }
58
54
  }
59
-
60
55
  if (disabledFields && Array.isArray(disabledFields)) {
61
56
  resultData = resetDataWithDisabled(resultData, optionName, disabledFields);
62
57
  }
63
-
64
58
  return resultData;
65
- }, [treeData, optionName, checkStrictly, limitKey, checkedKeys, disabledFields]); // console.log('重置后的数据', transTreeData)
66
-
59
+ }, [treeData, optionName, checkStrictly, limitKey, checkedKeys, disabledFields]);
60
+ // console.log('重置后的数据', transTreeData)
67
61
  var handleToSelectTreeNode = function handleToSelectTreeNode(key, e) {
68
62
  var currentData = e.node;
69
63
  var multiSelectedData = [];
70
64
  e.selectedNodes.map(function (item) {
71
65
  return multiSelectedData.push(item);
72
66
  }); // 多选条件下,当前选中所有节点数据
73
-
74
67
  onSelect && onSelect(key, {
75
68
  currentData: currentData,
76
69
  multiData: multiSelectedData
77
70
  }, e);
78
71
  };
79
-
80
72
  var handleToCheckTreeNode = function handleToCheckTreeNode(keys, e) {
81
73
  var currentData = e.node;
82
74
  var multiCheckedData = [];
83
75
  e.checkedNodes.map(function (item) {
84
76
  return multiCheckedData.push(item);
85
77
  }); // 多选条件下,当前选中所有节点数据
86
-
87
78
  onCheck && onCheck(keys, {
88
79
  currentData: currentData,
89
80
  multiData: multiCheckedData
90
81
  }, e);
91
82
  };
92
-
93
83
  var handleNodeControl = function handleNodeControl(e, type, nodeData) {
94
84
  e.stopPropagation();
95
85
  var onEdit = nodeControl.onEdit,
96
- onDelete = nodeControl.onDelete;
97
-
86
+ onDelete = nodeControl.onDelete;
98
87
  if (type === 'edit') {
99
88
  onEdit && onEdit(nodeData);
100
89
  }
101
-
102
90
  if (type === 'delete') {
103
91
  onDelete && onDelete(nodeData);
104
92
  }
105
93
  };
106
-
107
94
  var renderNodeTitle = function renderNodeTitle(item) {
108
95
  if (titleRender) return titleRender(item);
109
96
  return /*#__PURE__*/React.createElement(React.Fragment, null, item[optionName.title || 'title'], nodeControl ? /*#__PURE__*/React.createElement("span", {
@@ -131,7 +118,6 @@ var RefactorTree = function RefactorTree(props) {
131
118
  name: 'delete'
132
119
  })))) : null, nodeExtra && nodeExtra(item));
133
120
  };
134
-
135
121
  if (transTreeData.length == 0) {
136
122
  return /*#__PURE__*/React.createElement(_Empty, {
137
123
  image: _Empty.PRESENTED_IMAGE_SIMPLE,
@@ -139,13 +125,11 @@ var RefactorTree = function RefactorTree(props) {
139
125
  });
140
126
  } else {
141
127
  var defExpand = [];
142
-
143
128
  if (defaultSelectedKeys && defaultSelectedKeys.length > 0) {
144
129
  defExpand = defaultSelectedKeys;
145
130
  } else {
146
131
  defExpand = rootKey ? [rootKey] : ['0'];
147
132
  }
148
-
149
133
  return /*#__PURE__*/React.createElement(_Tree, Object.assign({}, otherProps, {
150
134
  onSelect: function onSelect(keys, e) {
151
135
  return handleToSelectTreeNode(keys, e);
@@ -163,5 +147,4 @@ var RefactorTree = function RefactorTree(props) {
163
147
  }));
164
148
  }
165
149
  };
166
-
167
150
  export default RefactorTree;
@@ -4,60 +4,48 @@ import "antd/es/popconfirm/style";
4
4
  import _Popconfirm from "antd/es/popconfirm";
5
5
  import "antd/es/tree/style";
6
6
  import _Tree from "antd/es/tree";
7
-
8
7
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
9
-
10
8
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
-
12
9
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
-
14
10
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
15
-
16
- function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
17
-
11
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) { ; } } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
18
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
-
20
- import { __rest } from "tslib"; // 重构树控件,可直接配置数据
21
-
13
+ import { __rest } from "tslib";
14
+ // 重构树控件,可直接配置数据
22
15
  import React, { useEffect, useState } from 'react';
23
16
  import SpecIcon from '../SpecIcon/index';
24
17
  var TreeNode = _Tree.TreeNode;
25
18
  import './style/index.less';
26
-
27
19
  var RefactorTree = function RefactorTree(props) {
28
20
  var treeData = props.treeData,
29
- rootName = props.rootName,
30
- rootKey = props.rootKey,
31
- rootIcon = props.rootIcon,
32
- emptyDescription = props.emptyDescription,
33
- _props$optionName = props.optionName,
34
- optionName = _props$optionName === void 0 ? {
35
- value: 'value',
36
- title: 'title',
37
- children: 'children',
38
- disabled: 'disabled'
39
- } : _props$optionName,
40
- defaultSelectedKeys = props.defaultSelectedKeys,
41
- nodeItemReset = props.nodeItemReset,
42
- nodeExtra = props.nodeExtra,
43
- _props$selectable = props.selectable,
44
- selectable = _props$selectable === void 0 ? true : _props$selectable,
45
- nodeControl = props.nodeControl,
46
- limitKey = props.limitKey,
47
- checkedKeys = props.checkedKeys,
48
- checkStrictly = props.checkStrictly,
49
- onSelect = props.onSelect,
50
- onCheck = props.onCheck,
51
- otherProps = __rest(props, ["treeData", "rootName", "rootKey", "rootIcon", "emptyDescription", "optionName", "defaultSelectedKeys", "nodeItemReset", "nodeExtra", "selectable", "nodeControl", "limitKey", "checkedKeys", "checkStrictly", "onSelect", "onCheck"]); // 重新组合指定数据源字段 (limitKey:用于限制只能选择指定同一层级的数据)
21
+ rootName = props.rootName,
22
+ rootKey = props.rootKey,
23
+ rootIcon = props.rootIcon,
24
+ emptyDescription = props.emptyDescription,
25
+ _props$optionName = props.optionName,
26
+ optionName = _props$optionName === void 0 ? {
27
+ value: 'value',
28
+ title: 'title',
29
+ children: 'children',
30
+ disabled: 'disabled'
31
+ } : _props$optionName,
32
+ defaultSelectedKeys = props.defaultSelectedKeys,
33
+ nodeItemReset = props.nodeItemReset,
34
+ nodeExtra = props.nodeExtra,
35
+ _props$selectable = props.selectable,
36
+ selectable = _props$selectable === void 0 ? true : _props$selectable,
37
+ nodeControl = props.nodeControl,
38
+ limitKey = props.limitKey,
39
+ checkedKeys = props.checkedKeys,
40
+ checkStrictly = props.checkStrictly,
41
+ onSelect = props.onSelect,
42
+ onCheck = props.onCheck,
43
+ otherProps = __rest(props, ["treeData", "rootName", "rootKey", "rootIcon", "emptyDescription", "optionName", "defaultSelectedKeys", "nodeItemReset", "nodeExtra", "selectable", "nodeControl", "limitKey", "checkedKeys", "checkStrictly", "onSelect", "onCheck"]); // 重新组合指定数据源字段 (limitKey:用于限制只能选择指定同一层级的数据)
52
44
  // const { title, value, children, disabled } = { value: 'value', title: 'title', children: 'children', disabled: 'disabled', ...optionName }
53
-
54
-
55
45
  var _useState = useState([]),
56
- _useState2 = _slicedToArray(_useState, 2),
57
- dataList = _useState2[0],
58
- setDataList = _useState2[1]; // 限制节点选中条件下更新列表数据
59
-
60
-
46
+ _useState2 = _slicedToArray(_useState, 2),
47
+ dataList = _useState2[0],
48
+ setDataList = _useState2[1]; // 限制节点选中条件下更新列表数据
61
49
  var resetDataWithLimit = function resetDataWithLimit(hasKeys, list, resultList) {
62
50
  // 利用ID匹配对应选中的完整节点数据
63
51
  var filterCheckedNode = function filterCheckedNode(ids, preList, matchList) {
@@ -66,34 +54,28 @@ var RefactorTree = function RefactorTree(props) {
66
54
  if (ids.includes(item[optionName.value])) {
67
55
  matchList.push(Object.assign({}, item));
68
56
  }
69
-
70
57
  filterCheckedNode(ids, item[optionName.children || 'children'], matchList);
71
58
  });
72
59
  }
73
- }; // 筛选同一层级可选择,其他层级数据不可选择(限制按指定字段名的层级数据)
74
-
75
-
60
+ };
61
+ // 筛选同一层级可选择,其他层级数据不可选择(限制按指定字段名的层级数据)
76
62
  var filterResetSameLevel = function filterResetSameLevel(preList, resData, matchData) {
77
63
  if (Array.isArray(preList) && preList.length > 0) {
78
64
  preList.forEach(function (item, i) {
79
65
  resData[i] = Object.assign({}, item);
80
66
  resData[i].isLimit = item[limitKey] !== matchData; // [limitKey];
81
-
82
67
  var newDeepArr = [];
83
68
  filterResetSameLevel(item[optionName.children || 'children'], newDeepArr, matchData);
84
69
  resData[i][optionName.children || 'children'] = newDeepArr;
85
70
  });
86
71
  }
87
72
  };
88
-
89
73
  var matchItems = [];
90
74
  filterCheckedNode(hasKeys, list, matchItems); // 先筛选出来选中节点的数据,取其中的 level 层级的值(数据必须保证同级类型值一致)
91
-
92
75
  if (matchItems.length > 0) {
93
76
  filterResetSameLevel(list, resultList, matchItems[0][limitKey]);
94
77
  }
95
78
  };
96
-
97
79
  useEffect(function () {
98
80
  // 有配置limitKey指定限制同级节点时,添加判断节点选择限制(在父子节点不相关联条件下使用checkStrictly=true)
99
81
  if (checkStrictly && limitKey && checkedKeys) {
@@ -108,48 +90,40 @@ var RefactorTree = function RefactorTree(props) {
108
90
  setDataList(treeData || []); // 默认状态直接赋值传进来的数据
109
91
  }
110
92
  }, [treeData, checkedKeys]);
111
-
112
93
  var handleToSelectTreeNode = function handleToSelectTreeNode(key, e) {
113
94
  var currentData = e.node.dataRef;
114
95
  var multiSelectedData = [];
115
96
  e.selectedNodes.map(function (item) {
116
97
  return multiSelectedData.push(item.dataRef);
117
98
  }); // 多选条件下,当前选中所有节点数据
118
-
119
99
  onSelect && onSelect(key, {
120
100
  currentData: currentData,
121
101
  multiData: multiSelectedData
122
102
  }, e);
123
103
  };
124
-
125
104
  var handleToCheckTreeNode = function handleToCheckTreeNode(keys, e) {
126
105
  var currentData = e.node.dataRef;
127
106
  var multiCheckedData = [];
128
107
  e.checkedNodes.map(function (item) {
129
108
  return multiCheckedData.push(item.dataRef);
130
109
  }); // 多选条件下,当前选中所有节点数据
131
-
132
110
  onCheck && onCheck(keys, {
133
111
  currentData: currentData,
134
112
  multiData: multiCheckedData
135
113
  }, e);
136
114
  };
137
-
138
115
  var handleNodeControl = function handleNodeControl(e, type, nodeData) {
139
116
  e.stopPropagation();
140
117
  var onEdit = nodeControl.onEdit,
141
- onDelete = nodeControl.onDelete;
142
-
118
+ onDelete = nodeControl.onDelete;
143
119
  if (type === 'edit') {
144
120
  onEdit && onEdit(nodeData);
145
121
  }
146
-
147
122
  if (type === 'delete') {
148
123
  onDelete && onDelete(nodeData);
149
124
  }
150
- }; // const <Icon type={selected ? 'frown' : 'frown-o'} />
151
-
152
-
125
+ };
126
+ // const <Icon type={selected ? 'frown' : 'frown-o'} />
153
127
  var renderNodeTitle = function renderNodeTitle(item) {
154
128
  return /*#__PURE__*/React.createElement(React.Fragment, null, nodeItemReset && nodeItemReset(item).icon || (item.icon ? /*#__PURE__*/React.createElement(SpecIcon, {
155
129
  name: item.icon
@@ -178,7 +152,6 @@ var RefactorTree = function RefactorTree(props) {
178
152
  name: 'delete'
179
153
  })))) : null, nodeExtra && nodeExtra);
180
154
  };
181
-
182
155
  var renderTreeNodes = function renderTreeNodes(data) {
183
156
  return data.map(function (item) {
184
157
  if (item[optionName.children || 'children']) {
@@ -190,7 +163,6 @@ var RefactorTree = function RefactorTree(props) {
190
163
  dataRef: item
191
164
  }), renderTreeNodes(item[optionName.children || 'children']));
192
165
  }
193
-
194
166
  return /*#__PURE__*/React.createElement(TreeNode, Object.assign({}, item, {
195
167
  title: renderNodeTitle(item),
196
168
  key: item[optionName.value || 'value'],
@@ -200,21 +172,17 @@ var RefactorTree = function RefactorTree(props) {
200
172
  }));
201
173
  });
202
174
  };
203
-
204
175
  if (dataList.length == 0 && !rootName) return /*#__PURE__*/React.createElement(_Empty, {
205
176
  image: _Empty.PRESENTED_IMAGE_SIMPLE,
206
177
  description: emptyDescription
207
178
  });
208
179
  var defExpand = [];
209
-
210
180
  if (defaultSelectedKeys && defaultSelectedKeys.length > 0) {
211
181
  defExpand = defaultSelectedKeys;
212
182
  } else {
213
183
  defExpand = rootKey ? [rootKey] : ['0'];
214
184
  }
215
-
216
- return /*#__PURE__*/React.createElement(_Tree, // switcherIcon={<Icon type="down" />}
217
- Object.assign({}, otherProps, {
185
+ return /*#__PURE__*/React.createElement(_Tree, Object.assign({}, otherProps, {
218
186
  onSelect: function onSelect(keys, e) {
219
187
  return handleToSelectTreeNode(keys, e);
220
188
  },
@@ -233,5 +201,4 @@ var RefactorTree = function RefactorTree(props) {
233
201
  icon: rootIcon || null
234
202
  }, renderTreeNodes(dataList)) : renderTreeNodes(dataList));
235
203
  };
236
-
237
204
  export default RefactorTree;
@@ -1,15 +1,9 @@
1
1
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
-
3
2
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
-
5
3
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
-
7
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
8
-
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
9
5
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
-
11
6
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
12
-
13
7
  import { __rest } from "tslib";
14
8
  /**
15
9
  * transDataParam 根据指定选项字段名重组数据
@@ -18,7 +12,6 @@ import { __rest } from "tslib";
18
12
  * @params {object} optionName 选项字段值
19
13
  *
20
14
  * */
21
-
22
15
  export function transDataParam(array) {
23
16
  var optionName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
24
17
  key: 'key',
@@ -28,29 +21,24 @@ export function transDataParam(array) {
28
21
  disabled: 'disabled',
29
22
  selectable: 'selectable'
30
23
  };
31
-
32
24
  var trans = function trans(list) {
33
25
  if (!list) return null;
34
26
  return list.map(function (item) {
35
27
  if (item.hasOwnProperty(optionName.disabled || 'disabled')) {
36
28
  item.disabled = item[optionName.disabled || 'disabled'];
37
29
  }
38
-
39
30
  if (item.hasOwnProperty(optionName.selectable || 'selectable')) {
40
31
  item.selectable = item[optionName.selectable || 'selectable'];
41
32
  }
42
-
43
33
  if (item.hasOwnProperty(optionName.children || 'children')) {
44
34
  item.children = item[optionName.children || 'children'] ? trans(item[optionName.children || 'children']) : [];
45
35
  }
46
-
47
36
  return Object.assign(Object.assign({}, item), {
48
37
  key: item[optionName.value || optionName.key || 'key'],
49
38
  title: item[optionName.title || 'title']
50
39
  });
51
40
  });
52
41
  };
53
-
54
42
  return trans(array);
55
43
  }
56
44
  /**
@@ -64,7 +52,6 @@ export function transDataParam(array) {
64
52
  * @Return {array} 返回结果数据
65
53
  *
66
54
  * */
67
-
68
55
  export function resetDataWithLimit(hasKeys, list) {
69
56
  var optionName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
70
57
  key: 'key',
@@ -75,57 +62,45 @@ export function resetDataWithLimit(hasKeys, list) {
75
62
  selectable: 'selectable'
76
63
  };
77
64
  var limitKey = arguments.length > 3 ? arguments[3] : undefined;
78
-
79
65
  // 利用ID匹配对应选中的完整节点数据
80
66
  var filterCheckedNode = function filterCheckedNode(ids, preList) {
81
67
  var matchList = [];
82
-
83
68
  if (Array.isArray(preList) && preList.length > 0) {
84
69
  preList.forEach(function (item, i) {
85
70
  if (ids.includes(item[optionName.value || 'value'])) {
86
71
  matchList.push(Object.assign({}, item));
87
72
  }
88
-
89
73
  if (item[optionName.children || 'children']) {
90
74
  matchList = matchList.concat(filterCheckedNode(ids, item[optionName.children || 'children']));
91
75
  }
92
76
  });
93
77
  }
94
-
95
78
  return matchList;
96
- }; // 筛选同一层级可选择,其他层级数据不可选择(限制按指定字段名的层级数据)
97
-
98
-
79
+ };
80
+ // 筛选同一层级可选择,其他层级数据不可选择(限制按指定字段名的层级数据)
99
81
  var filterResetSameLevel = function filterResetSameLevel(preList, matchDataValue) {
100
82
  if (!preList) return [];
101
83
  if (!matchDataValue) return preList;
102
84
  return preList === null || preList === void 0 ? void 0 : preList.map(function (preItem) {
103
85
  var oldItem = Object.assign({}, preItem);
104
-
105
86
  var item = __rest(oldItem, []);
106
-
107
87
  if (item[limitKey] !== matchDataValue) {
108
88
  item.disabled = true;
109
89
  } else if (item.hasOwnProperty(optionName.disabled || 'disabled')) {
110
90
  item.disabled = item[optionName.disabled || 'disabled'];
111
- } // item.disabled = item[limitKey] !== matchDataValue || item[optionName.disabled || 'disabled']
112
-
113
-
91
+ }
92
+ // item.disabled = item[limitKey] !== matchDataValue || item[optionName.disabled || 'disabled']
114
93
  item.isLimit = item[limitKey] !== matchDataValue;
115
94
  item.children = filterResetSameLevel(item['children'], matchDataValue);
116
95
  item[optionName.children || 'children'] = filterResetSameLevel(item[optionName.children || 'children'], matchDataValue);
117
96
  return Object.assign({}, item);
118
97
  });
119
- }; // 先筛选出来选中节点的数据,取其中的 level 层级的值(数据必须保证同级类型值一致)
120
-
121
-
98
+ };
99
+ // 先筛选出来选中节点的数据,取其中的 level 层级的值(数据必须保证同级类型值一致)
122
100
  var prevList = list && Array.isArray(list) ? _toConsumableArray(list) : [];
123
-
124
101
  var _ref = _toConsumableArray(prevList),
125
- newList = _ref.slice(0);
126
-
102
+ newList = _ref.slice(0);
127
103
  var filterLimitData = filterCheckedNode(hasKeys, newList);
128
-
129
104
  if (filterLimitData.length > 0) {
130
105
  return filterResetSameLevel(newList, filterLimitData[0][limitKey]);
131
106
  } else {
@@ -144,23 +119,18 @@ export function resetDataWithLimit(hasKeys, list) {
144
119
  * @Return {array} 返回结果数据
145
120
  *
146
121
  * */
147
-
148
122
  export function resetDataWithDisabled(list, optionName, disabledFields) {
149
123
  // 筛选与禁用字段内值相同的节点进行禁用
150
124
  var filterResetTargetFields = function filterResetTargetFields(preList, fields) {
151
125
  if (!preList) return [];
152
126
  return preList.map(function (preItem) {
153
127
  var oldItem = Object.assign({}, preItem);
154
-
155
128
  var item = __rest(oldItem, []);
156
-
157
129
  Object.keys(item).forEach(function (itemKeyName) {
158
130
  var _a;
159
-
160
131
  var isMatch = fields.find(function (fItem) {
161
132
  return fItem.key === itemKeyName;
162
133
  });
163
-
164
134
  if (isMatch) {
165
135
  // 确认是否匹配数据,进行设置 disabled
166
136
  if ((_a = isMatch.value.split(',')) === null || _a === void 0 ? void 0 : _a.includes(item[itemKeyName])) {
@@ -169,7 +139,6 @@ export function resetDataWithDisabled(list, optionName, disabledFields) {
169
139
  item.disabled = item[optionName.disabled || 'disabled'];
170
140
  }
171
141
  }
172
-
173
142
  if (itemKeyName === 'children') {
174
143
  item.children = filterResetTargetFields(item[itemKeyName], fields);
175
144
  }
@@ -177,11 +146,8 @@ export function resetDataWithDisabled(list, optionName, disabledFields) {
177
146
  return Object.assign({}, item);
178
147
  });
179
148
  };
180
-
181
149
  var prevList = list && Array.isArray(list) ? _toConsumableArray(list) : [];
182
-
183
150
  var _ref2 = _toConsumableArray(prevList),
184
- newList = _ref2.slice(0);
185
-
151
+ newList = _ref2.slice(0);
186
152
  return filterResetTargetFields(newList, disabledFields);
187
153
  }