@vtx/components 4.0.0-beta.7 → 4.0.0-beta.71

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 (212) hide show
  1. package/README.md +19 -19
  2. package/es/index.js +3 -0
  3. package/es/utils/components/LabelIconTip/index.js +7 -7
  4. package/es/utils/conversionMomentValue/index.js +25 -25
  5. package/es/utils/filterSpecialCharacters.js +53 -52
  6. package/es/utils/genCopyable/index.js +6 -6
  7. package/es/utils/getFieldPropsOrFormItemProps/index.js +7 -7
  8. package/es/utils/hooks/useDebounceFn/index.js +4 -4
  9. package/es/utils/hooks/useDebounceValue/index.js +6 -6
  10. package/es/utils/hooks/useDeepCompareMemo/index.js +7 -7
  11. package/es/utils/hooks/useLatest/index.js +2 -2
  12. package/es/utils/hooks/useRefCallback/index.js +5 -5
  13. package/es/utils/index.js +1 -2
  14. package/es/utils/isBrowser/index.js +7 -7
  15. package/es/utils/isUrl/index.js +4 -4
  16. package/es/utils/merge/index.js +4 -4
  17. package/es/utils/nanoid/index.js +4 -4
  18. package/es/utils/omitBoolean/index.js +4 -4
  19. package/es/utils/parseValueToMoment/index.js +4 -4
  20. package/es/utils/proFieldParsingText/index.js +10 -10
  21. package/es/utils/transformKeySubmitValue/index.js +57 -57
  22. package/es/utils/useEditableArray/index.js +46 -46
  23. package/es/utils/useEditableMap/index.js +22 -22
  24. package/es/utils/useMediaQuery/index.js +5 -5
  25. package/es/vtx-color-picker/index.js +138 -33
  26. package/es/vtx-color-picker/style/index.js +36 -12
  27. package/es/vtx-combogrid/Combogrid.js +16 -10
  28. package/es/vtx-combogrid/index.js +7 -4
  29. package/es/vtx-combogrid/style/index.js +4 -4
  30. package/es/vtx-datagrid/Store/Provide.js +109 -132
  31. package/es/vtx-datagrid/ToolBar/components/ColumnSetting/index.js +15 -9
  32. package/es/vtx-datagrid/ToolBar/components/ColumnSetting/style.js +5 -2
  33. package/es/vtx-datagrid/ToolBar/components/Density/index.js +3 -0
  34. package/es/vtx-datagrid/ToolBar/components/TableStyle/index.js +3 -0
  35. package/es/vtx-datagrid/ToolBar/index.js +2 -2
  36. package/es/vtx-datagrid/columnState.js +64 -0
  37. package/es/vtx-datagrid/index.js +114 -35
  38. package/es/vtx-datagrid/mergeComponents.js +15 -0
  39. package/es/vtx-datagrid/renderColumnButtons.js +30 -11
  40. package/es/vtx-datagrid/style/index.js +102 -20
  41. package/es/vtx-datagrid/style/index.less +242 -242
  42. package/es/vtx-date-picker/QdatePicker.js +1 -1
  43. package/es/vtx-date-picker/style/index.less +39 -39
  44. package/es/vtx-descriptions/Descriptions.js +29 -0
  45. package/es/vtx-descriptions/index.js +3 -0
  46. package/es/vtx-descriptions/style/index.js +19 -0
  47. package/es/vtx-ellipsis-text/index.js +7 -2
  48. package/es/vtx-ellipsis-text/style/index.js +3 -1
  49. package/es/vtx-export/index.js +33 -33
  50. package/es/vtx-export-async/History.js +11 -3
  51. package/es/vtx-export-async/index.js +45 -15
  52. package/es/vtx-form-layout/Card.js +10 -10
  53. package/es/vtx-form-layout/Divider.js +1 -1
  54. package/es/vtx-form-layout/FormItem.js +18 -17
  55. package/es/vtx-form-layout/Pane.js +23 -12
  56. package/es/vtx-icon/index.js +54 -45
  57. package/es/vtx-icon/index.js1 +90 -0
  58. package/es/vtx-image/Preview.js +11 -6
  59. package/es/vtx-image/style/index.js +0 -1
  60. package/es/vtx-import/index.js +155 -43
  61. package/es/vtx-import/result.js +6 -2
  62. package/es/vtx-import/style/index.js +16 -1
  63. package/es/vtx-import2/Content.js +2 -1
  64. package/es/vtx-import2/index.js +31 -20
  65. package/es/vtx-import2/style/index.js +60 -9
  66. package/es/vtx-input/TextArea/index.js +11 -6
  67. package/es/vtx-modal/index.js +11 -6
  68. package/es/vtx-modal/style/index.js +5 -3
  69. package/es/vtx-page-layout/Basic.js +2 -2
  70. package/es/vtx-page-layout/Content.js +1 -1
  71. package/es/vtx-page-layout/TabLayout.js +7 -13
  72. package/es/vtx-page-layout/TableLayout.js +24 -14
  73. package/es/vtx-page-layout/TableWrap.js +3 -2
  74. package/es/vtx-page-layout/TreeLayout.js +8 -14
  75. package/es/vtx-page-layout/container.js +8 -7
  76. package/es/vtx-page-layout/style/index.js +4 -2
  77. package/es/vtx-provider/index.js +50 -40
  78. package/es/vtx-provider/intl.js +9 -9
  79. package/es/vtx-provider/locale/en_US.js +65 -5
  80. package/es/vtx-provider/locale/zh_CN.js +75 -5
  81. package/es/vtx-provider/useStyle/index.js +25 -21
  82. package/es/vtx-scrollable-row/index.js +38 -28
  83. package/es/vtx-search/index.js +18 -13
  84. package/es/vtx-search/style/index.js +2 -1
  85. package/es/vtx-select/index.js +132 -46
  86. package/es/vtx-select/style/index.js +11 -56
  87. package/es/vtx-signature/index.js +5 -4
  88. package/es/vtx-signature/style/index.js +1 -1
  89. package/es/vtx-split-pane/Resizer.js +0 -1
  90. package/es/vtx-split-pane/SplitPane.js +34 -25
  91. package/es/vtx-split-pane/style/index.js +8 -112
  92. package/es/vtx-time-picker/index.js +27 -1
  93. package/es/vtx-transfer/Transfer.js +29 -0
  94. package/es/vtx-transfer/index.js +3 -0
  95. package/es/vtx-transfer/style/index.js +19 -0
  96. package/es/vtx-transfer-select/TransferSelect.js +143 -0
  97. package/es/vtx-transfer-select/index.js +3 -0
  98. package/es/vtx-transfer-select/style/index.js +19 -0
  99. package/es/vtx-tree/index.js +104 -40
  100. package/es/vtx-tree-select/index.js +75 -105
  101. package/es/vtx-tree-select/style/index.js +9 -3
  102. package/es/vtx-upload/FilePreview.js +2 -1
  103. package/es/vtx-wang-editor/index.js +291 -113
  104. package/es/vtx-wang-editor/style/index.less +12 -12
  105. package/es/vtx-wang-editor/wangEditorUtil.js +59 -9
  106. package/lib/index.js +36 -0
  107. package/lib/utils/components/LabelIconTip/index.js +7 -7
  108. package/lib/utils/conversionMomentValue/index.js +25 -25
  109. package/lib/utils/filterSpecialCharacters.js +54 -52
  110. package/lib/utils/genCopyable/index.js +6 -6
  111. package/lib/utils/getFieldPropsOrFormItemProps/index.js +7 -7
  112. package/lib/utils/hooks/useDebounceFn/index.js +4 -4
  113. package/lib/utils/hooks/useDebounceValue/index.js +6 -6
  114. package/lib/utils/hooks/useDeepCompareMemo/index.js +7 -7
  115. package/lib/utils/hooks/useLatest/index.js +2 -2
  116. package/lib/utils/hooks/useRefCallback/index.js +5 -5
  117. package/lib/utils/index.js +0 -7
  118. package/lib/utils/isBrowser/index.js +7 -7
  119. package/lib/utils/isUrl/index.js +4 -4
  120. package/lib/utils/merge/index.js +4 -4
  121. package/lib/utils/nanoid/index.js +4 -4
  122. package/lib/utils/omitBoolean/index.js +4 -4
  123. package/lib/utils/parseValueToMoment/index.js +4 -4
  124. package/lib/utils/proFieldParsingText/index.js +10 -10
  125. package/lib/utils/transformKeySubmitValue/index.js +57 -57
  126. package/lib/utils/useEditableArray/index.js +46 -46
  127. package/lib/utils/useEditableMap/index.js +22 -22
  128. package/lib/utils/useMediaQuery/index.js +5 -5
  129. package/lib/vtx-color-picker/index.js +139 -34
  130. package/lib/vtx-color-picker/style/index.js +36 -12
  131. package/lib/vtx-combogrid/Combogrid.js +16 -10
  132. package/lib/vtx-combogrid/index.js +7 -4
  133. package/lib/vtx-combogrid/style/index.js +4 -4
  134. package/lib/vtx-datagrid/Store/Provide.js +116 -138
  135. package/lib/vtx-datagrid/ToolBar/components/ColumnSetting/index.js +15 -10
  136. package/lib/vtx-datagrid/ToolBar/components/ColumnSetting/style.js +5 -2
  137. package/lib/vtx-datagrid/ToolBar/components/Density/index.js +3 -0
  138. package/lib/vtx-datagrid/ToolBar/components/TableStyle/index.js +3 -0
  139. package/lib/vtx-datagrid/ToolBar/index.js +2 -2
  140. package/lib/vtx-datagrid/columnState.js +73 -0
  141. package/lib/vtx-datagrid/index.js +115 -35
  142. package/lib/vtx-datagrid/mergeComponents.js +21 -0
  143. package/lib/vtx-datagrid/renderColumnButtons.js +30 -11
  144. package/lib/vtx-datagrid/style/index.js +102 -20
  145. package/lib/vtx-datagrid/style/index.less +242 -242
  146. package/lib/vtx-date-picker/QdatePicker.js +1 -1
  147. package/lib/vtx-date-picker/style/index.less +39 -39
  148. package/lib/vtx-descriptions/Descriptions.js +38 -0
  149. package/lib/vtx-descriptions/index.js +15 -0
  150. package/lib/vtx-descriptions/style/index.js +25 -0
  151. package/lib/vtx-ellipsis-text/index.js +7 -2
  152. package/lib/vtx-ellipsis-text/style/index.js +3 -1
  153. package/lib/vtx-export/index.js +34 -34
  154. package/lib/vtx-export-async/History.js +11 -3
  155. package/lib/vtx-export-async/index.js +43 -13
  156. package/lib/vtx-form-layout/Card.js +9 -9
  157. package/lib/vtx-form-layout/Divider.js +1 -1
  158. package/lib/vtx-form-layout/FormItem.js +18 -17
  159. package/lib/vtx-form-layout/Pane.js +22 -11
  160. package/lib/vtx-icon/index.js +54 -52
  161. package/lib/vtx-icon/index.js1 +90 -0
  162. package/lib/vtx-image/Preview.js +11 -6
  163. package/lib/vtx-image/style/index.js +0 -1
  164. package/lib/vtx-import/index.js +154 -42
  165. package/lib/vtx-import/result.js +6 -2
  166. package/lib/vtx-import/style/index.js +16 -1
  167. package/lib/vtx-import2/Content.js +2 -1
  168. package/lib/vtx-import2/index.js +30 -19
  169. package/lib/vtx-import2/style/index.js +60 -9
  170. package/lib/vtx-input/TextArea/index.js +11 -6
  171. package/lib/vtx-modal/index.js +11 -6
  172. package/lib/vtx-modal/style/index.js +5 -3
  173. package/lib/vtx-page-layout/Basic.js +2 -2
  174. package/lib/vtx-page-layout/Content.js +1 -1
  175. package/lib/vtx-page-layout/TabLayout.js +8 -14
  176. package/lib/vtx-page-layout/TableLayout.js +24 -14
  177. package/lib/vtx-page-layout/TableWrap.js +3 -2
  178. package/lib/vtx-page-layout/TreeLayout.js +9 -15
  179. package/lib/vtx-page-layout/container.js +8 -7
  180. package/lib/vtx-page-layout/style/index.js +4 -2
  181. package/lib/vtx-provider/index.js +49 -40
  182. package/lib/vtx-provider/intl.js +9 -9
  183. package/lib/vtx-provider/locale/en_US.js +65 -5
  184. package/lib/vtx-provider/locale/zh_CN.js +75 -5
  185. package/lib/vtx-provider/useStyle/index.js +25 -21
  186. package/lib/vtx-scrollable-row/index.js +38 -28
  187. package/lib/vtx-search/index.js +18 -13
  188. package/lib/vtx-search/style/index.js +2 -1
  189. package/lib/vtx-select/index.js +134 -48
  190. package/lib/vtx-select/style/index.js +11 -56
  191. package/lib/vtx-signature/index.js +4 -3
  192. package/lib/vtx-signature/style/index.js +1 -1
  193. package/lib/vtx-split-pane/Resizer.js +0 -1
  194. package/lib/vtx-split-pane/SplitPane.js +32 -23
  195. package/lib/vtx-split-pane/style/index.js +8 -112
  196. package/lib/vtx-time-picker/index.js +27 -1
  197. package/lib/vtx-transfer/Transfer.js +38 -0
  198. package/lib/vtx-transfer/index.js +15 -0
  199. package/lib/vtx-transfer/style/index.js +25 -0
  200. package/lib/vtx-transfer-select/TransferSelect.js +151 -0
  201. package/lib/vtx-transfer-select/index.js +15 -0
  202. package/lib/vtx-transfer-select/style/index.js +25 -0
  203. package/lib/vtx-tree/index.js +102 -38
  204. package/lib/vtx-tree-select/index.js +75 -105
  205. package/lib/vtx-tree-select/style/index.js +9 -3
  206. package/lib/vtx-upload/FilePreview.js +2 -1
  207. package/lib/vtx-wang-editor/index.js +289 -113
  208. package/lib/vtx-wang-editor/style/index.less +12 -12
  209. package/lib/vtx-wang-editor/wangEditorUtil.js +59 -10
  210. package/package.json +238 -222
  211. package/es/utils/hooks/useFetchData/index.js +0 -82
  212. package/lib/utils/hooks/useFetchData/index.js +0 -89
@@ -1,5 +1,5 @@
1
1
  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); }
2
- var _excluded = ["showSearch", "treeData", "searchPlaceholder", "renderMenuList", "fieldNames", "titleClassName", "expandAction"];
2
+ var _excluded = ["showSearch", "treeData", "searchPlaceholder", "renderMenuList", "fieldNames", "titleClassName", "expandAction", "maxButtonCount"];
3
3
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
4
  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."); }
5
5
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
@@ -20,26 +20,27 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
20
20
  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; }
21
21
  import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState, useContext } from 'react';
22
22
  import PropTypes from 'prop-types';
23
- import { ConfigProvider, Input, Tooltip, Tree } from 'antd';
24
- import { DownOutlined } from '@ant-design/icons';
23
+ import { Dropdown, ConfigProvider, Input, Menu, Tooltip, Tree } from 'antd';
24
+ import { DownOutlined, EllipsisOutlined } from '@ant-design/icons';
25
25
  import { calcRangeKeys, convertDirectoryKeysToNodes } from "./utils";
26
26
  import { useDebounceFn, useMemoizedFn } from 'ahooks';
27
27
  import { parseTreeData } from '@vtx/utils';
28
28
  import classnames from 'classnames';
29
29
  import { useStyle } from "./style/index";
30
30
  import { VtxProvider, useIntl } from "../vtx-provider";
31
+ import VtxIcon from "../vtx-icon";
31
32
  import { jsx as _jsx } from "react/jsx-runtime";
32
33
  import { jsxs as _jsxs } from "react/jsx-runtime";
33
- var getParentKey = function getParentKey(key, tree) {
34
- var parentKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
34
+ var getParentKey = function getParentKey(keyValue, key, tree) {
35
+ var parentKey = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
35
36
  var _iterator = _createForOfIteratorHelper(tree),
36
37
  _step;
37
38
  try {
38
39
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
39
40
  var node = _step.value;
40
- if (node.key === key) return parentKey;
41
+ if (node[keyValue] === key) return parentKey;
41
42
  if (node.children) {
42
- var found = getParentKey(key, node.children, node.key);
43
+ var found = getParentKey(keyValue, key, node.children, node[keyValue]);
43
44
  if (found !== undefined) return found;
44
45
  }
45
46
  }
@@ -63,6 +64,8 @@ var VtxTree = /*#__PURE__*/forwardRef(function (propsAll, ref) {
63
64
  titleClassName = propsAll.titleClassName,
64
65
  _propsAll$expandActio = propsAll.expandAction,
65
66
  expandAction = _propsAll$expandActio === void 0 ? 'click' : _propsAll$expandActio,
67
+ _propsAll$maxButtonCo = propsAll.maxButtonCount,
68
+ maxButtonCount = _propsAll$maxButtonCo === void 0 ? 3 : _propsAll$maxButtonCo,
66
69
  props = _objectWithoutProperties(propsAll, _excluded);
67
70
  var _useContext = useContext(VtxProvider),
68
71
  getPrefixCls = _useContext.getPrefixCls;
@@ -93,12 +96,12 @@ var VtxTree = /*#__PURE__*/forwardRef(function (propsAll, ref) {
93
96
  var dataList = useMemo(function () {
94
97
  var dataList = [];
95
98
  var titleKey = (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.title) || 'title';
99
+ var keyName = (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.key) || 'key';
96
100
  var generateList = function generateList(data) {
97
101
  for (var i = 0; i < data.length; i++) {
98
102
  var node = data[i];
99
- var key = node.key;
100
103
  dataList.push({
101
- key: key,
104
+ key: node[keyName],
102
105
  title: node[titleKey]
103
106
  });
104
107
  if (node.children) {
@@ -141,6 +144,7 @@ var VtxTree = /*#__PURE__*/forwardRef(function (propsAll, ref) {
141
144
  var newTreeData = parseTreeData(treeData, {
142
145
  renderNode: function renderNode(item) {
143
146
  var titleKey = (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.title) || 'title';
147
+ var keyName = (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.key) || 'key';
144
148
  var strTitle = item[titleKey] || '';
145
149
  var index = strTitle.indexOf(searchValue);
146
150
  var beforeStr = strTitle.substring(0, index);
@@ -156,7 +160,7 @@ var VtxTree = /*#__PURE__*/forwardRef(function (propsAll, ref) {
156
160
  className: className,
157
161
  children: strTitle
158
162
  });
159
- return _objectSpread(_objectSpread({}, item), {}, _defineProperty(_defineProperty(_defineProperty({}, titleKey, title), "key", item.key), "strTitle", strTitle));
163
+ return _objectSpread(_objectSpread({}, item), {}, _defineProperty(_defineProperty(_defineProperty({}, titleKey, title), keyName, item[keyName]), "strTitle", strTitle));
160
164
  },
161
165
  filterNode: function filterNode(item) {
162
166
  return item.strTitle.indexOf(searchValue) > -1;
@@ -168,7 +172,7 @@ var VtxTree = /*#__PURE__*/forwardRef(function (propsAll, ref) {
168
172
  var _props$onExpand2;
169
173
  var newExpandedKeys = dataList.map(function (item) {
170
174
  if (item.title.indexOf(value) > -1) {
171
- return getParentKey(item.key, treeData);
175
+ return getParentKey((fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.key) || 'key', item.key, treeData);
172
176
  }
173
177
  return null;
174
178
  }).filter(function (item, i, self) {
@@ -190,17 +194,29 @@ var VtxTree = /*#__PURE__*/forwardRef(function (propsAll, ref) {
190
194
  };
191
195
  });
192
196
  useEffect(function () {
193
- var _treeRef$current2;
194
- var resizeObserver = new ResizeObserver(function () {
195
- var _treeRef$current;
196
- setHeight(treeRef === null || treeRef === void 0 || (_treeRef$current = treeRef.current) === null || _treeRef$current === void 0 ? void 0 : _treeRef$current.offsetHeight);
197
+ var element = treeRef.current;
198
+ if (!element) return; // 提前返回,避免后续问题
199
+
200
+ var resizeObserver = new ResizeObserver(function (entries) {
201
+ var _iterator2 = _createForOfIteratorHelper(entries),
202
+ _step2;
203
+ try {
204
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
205
+ var entry = _step2.value;
206
+ setHeight(entry.contentRect.height);
207
+ }
208
+ } catch (err) {
209
+ _iterator2.e(err);
210
+ } finally {
211
+ _iterator2.f();
212
+ }
197
213
  });
198
- if (treeRef.current) {
199
- resizeObserver.observe(treeRef === null || treeRef === void 0 ? void 0 : treeRef.current, {
200
- box: 'border-box'
201
- });
202
- }
203
- setHeight(treeRef === null || treeRef === void 0 || (_treeRef$current2 = treeRef.current) === null || _treeRef$current2 === void 0 ? void 0 : _treeRef$current2.offsetHeight);
214
+ resizeObserver.observe(element, {
215
+ box: 'border-box'
216
+ });
217
+
218
+ // 初始化高度
219
+ setHeight(element.offsetHeight);
204
220
  return function () {
205
221
  resizeObserver.disconnect();
206
222
  };
@@ -252,6 +268,21 @@ var VtxTree = /*#__PURE__*/forwardRef(function (propsAll, ref) {
252
268
  setSelectedKeys(newSelectedKeys);
253
269
  }
254
270
  };
271
+ var renderMenuIcon = function renderMenuIcon(arr, nodeData) {
272
+ return arr.map(function (item) {
273
+ return /*#__PURE__*/_jsx(Tooltip, {
274
+ title: item.label,
275
+ children: /*#__PURE__*/_jsx("span", {
276
+ className: "".concat(prefixCls, "-menu-item-icon"),
277
+ onClick: function onClick(e) {
278
+ e.stopPropagation();
279
+ item.onClick && item.onClick(nodeData);
280
+ },
281
+ children: item.icon
282
+ })
283
+ }, item.label);
284
+ });
285
+ };
255
286
  return wrapSSR( /*#__PURE__*/_jsxs("div", {
256
287
  className: classnames("".concat(prefixCls, "-wraaper"), hashId),
257
288
  children: [showSearch && /*#__PURE__*/_jsx(Input, {
@@ -268,7 +299,10 @@ var VtxTree = /*#__PURE__*/forwardRef(function (propsAll, ref) {
268
299
  ref: treeRef,
269
300
  children: /*#__PURE__*/_jsx(Tree, _objectSpread(_objectSpread(_objectSpread({}, props), {}, {
270
301
  height: height,
271
- switcherIcon: /*#__PURE__*/_jsx(DownOutlined, {}),
302
+ switcherIcon: /*#__PURE__*/_jsx(VtxIcon, {
303
+ type: "downOutlined",
304
+ fileType: "svg"
305
+ }),
272
306
  showLine: {
273
307
  showLeafIcon: false
274
308
  },
@@ -287,28 +321,54 @@ var VtxTree = /*#__PURE__*/forwardRef(function (propsAll, ref) {
287
321
  var titleKey = (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.title) || 'title';
288
322
  var title = nodeData[titleKey];
289
323
  if (renderMenuList) {
290
- var menuList = renderMenuList(nodeData);
324
+ var menuList = renderMenuList(nodeData).filter(function (item) {
325
+ return item.visible;
326
+ });
327
+ var arr = [];
328
+ if (menuList.length > maxButtonCount) {
329
+ arr = arr.concat(renderMenuIcon(menuList.slice(0, maxButtonCount - 1), nodeData));
330
+ arr.push( /*#__PURE__*/_jsx(Dropdown, {
331
+ placement: "bottom",
332
+ menu: {
333
+ items: menuList.slice(maxButtonCount - 1).map(function (item) {
334
+ return {
335
+ key: item.label,
336
+ label: /*#__PURE__*/_jsxs("div", {
337
+ className: "".concat(prefixCls, "-menu-item-label"),
338
+ children: [item.icon, item.label]
339
+ })
340
+ };
341
+ }),
342
+ onClick: function onClick(obj) {
343
+ var key = obj.key,
344
+ domEvent = obj.domEvent;
345
+ domEvent.stopPropagation();
346
+ var temp = menuList.find(function (v) {
347
+ return v.label == key;
348
+ });
349
+ (temp === null || temp === void 0 ? void 0 : temp.onClick) && temp.onClick(nodeData);
350
+ }
351
+ },
352
+ trigger: ['click'],
353
+ children: /*#__PURE__*/_jsx("span", {
354
+ className: "".concat(prefixCls, "-menu-item-icon"),
355
+ onClick: function onClick(e) {
356
+ e.stopPropagation();
357
+ },
358
+ children: /*#__PURE__*/_jsx(EllipsisOutlined, {})
359
+ })
360
+ }));
361
+ } else {
362
+ arr = arr.concat(renderMenuIcon(menuList, nodeData));
363
+ }
291
364
  return /*#__PURE__*/_jsxs("div", {
292
365
  className: classnames("".concat(prefixCls, "-menu-wrap"), hashId),
293
366
  children: [/*#__PURE__*/_jsx("span", {
294
367
  children: title
295
368
  }), /*#__PURE__*/_jsx("div", {
296
369
  className: classnames("".concat(prefixCls, "-menu-list"), hashId),
297
- children: menuList.filter(function (item) {
298
- return item.visible;
299
- }).map(function (item) {
300
- return /*#__PURE__*/_jsx(Tooltip, {
301
- title: item.label,
302
- children: /*#__PURE__*/_jsx("span", {
303
- className: classnames("".concat(prefixCls, "-menu-item-icon"), hashId),
304
- onClick: function onClick(e) {
305
- e.stopPropagation();
306
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
307
- item.onClick && item.onClick(nodeData);
308
- },
309
- children: item.icon
310
- })
311
- }, item.label);
370
+ children: /*#__PURE__*/_jsxs("div", {
371
+ children: [arr, " "]
312
372
  })
313
373
  })]
314
374
  });
@@ -325,7 +385,7 @@ VtxTree.propTypes = {
325
385
  treeData: PropTypes.array,
326
386
  selectedKeys: PropTypes.array,
327
387
  defaultSelectedKeys: PropTypes.array,
328
- expandedKeys: PropTypes.bool,
388
+ expandedKeys: PropTypes.array,
329
389
  onExpand: PropTypes.func,
330
390
  multiple: PropTypes.bool,
331
391
  autoExpandParent: PropTypes.bool,
@@ -333,7 +393,11 @@ VtxTree.propTypes = {
333
393
  searchPlaceholder: PropTypes.string,
334
394
  renderMenuList: PropTypes.func,
335
395
  titleClassName: PropTypes.func,
336
- fieldNames: PropTypes.array,
396
+ fieldNames: PropTypes.shape({
397
+ title: PropTypes.string,
398
+ key: PropTypes.string,
399
+ children: PropTypes.string
400
+ }),
337
401
  defaultExpandAll: PropTypes.bool,
338
402
  expandAction: PropTypes.oneOfType([PropTypes.string, PropTypes.bool])
339
403
  };
@@ -1,6 +1,5 @@
1
1
  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); }
2
- var _excluded = ["multiple", "treeData", "placeholder", "treeCheckable", "disabled", "style"],
3
- _excluded2 = ["children"];
2
+ var _excluded = ["multiple", "treeData", "placeholder", "treeCheckable", "disabled", "style", "fieldNames", "onChange", "labelInValue"];
4
3
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
5
4
  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."); }
6
5
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
@@ -10,6 +9,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
10
9
  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; }
11
10
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
11
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
12
+ function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure " + obj); }
13
13
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14
14
  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."); }
15
15
  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); }
@@ -38,7 +38,18 @@ var VtxTreeSelect = function VtxTreeSelect(_ref) {
38
38
  _ref$disabled = _ref.disabled,
39
39
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
40
40
  style = _ref.style,
41
+ _ref$fieldNames = _ref.fieldNames,
42
+ fieldNames = _ref$fieldNames === void 0 ? {
43
+ label: "title",
44
+ value: "value",
45
+ key: "value",
46
+ children: 'children'
47
+ } : _ref$fieldNames,
48
+ onChange = _ref.onChange,
49
+ labelInValue = _ref.labelInValue,
41
50
  props = _objectWithoutProperties(_ref, _excluded);
51
+ // checkable 状态下节点选择完全受控(父子节点选中状态不再关联),会使得 labelInValue 强制为 true
52
+ var _labelInValue = treeCheckable && props.treeCheckStrictly ? true : labelInValue;
42
53
  var intl = useIntl();
43
54
  var _useContext = useContext(VtxProvider),
44
55
  getPrefixCls = _useContext.getPrefixCls;
@@ -58,13 +69,15 @@ var VtxTreeSelect = function VtxTreeSelect(_ref) {
58
69
  var size = useSize(ref);
59
70
  var keyNodesMapping = useMemo(function () {
60
71
  var keyNodesMapping = {};
72
+ // 建议:添加树数据有效性检查
73
+ if (!treeData || !Array.isArray(treeData)) {
74
+ return keyNodesMapping;
75
+ }
61
76
  (function genNodes(nodes) {
62
77
  nodes.map(function (item) {
63
- var children = item.children,
64
- rest = _objectWithoutProperties(item, _excluded2);
65
- keyNodesMapping[item.value || item.key] = _objectSpread(_objectSpread({}, rest), {}, {
66
- id: item.value || item.key
67
- });
78
+ var rest = Object.assign({}, (_objectDestructuringEmpty(item), item));
79
+ var children = item[fieldNames.children];
80
+ keyNodesMapping[item[fieldNames.value]] = _objectSpread(_objectSpread({}, rest), {}, _defineProperty(_defineProperty({}, fieldNames.value, item[fieldNames.value]), fieldNames.label, item[fieldNames.label]));
68
81
  if (Array.isArray(children) && children.length > 0) {
69
82
  genNodes(children);
70
83
  }
@@ -73,19 +86,17 @@ var VtxTreeSelect = function VtxTreeSelect(_ref) {
73
86
  return keyNodesMapping;
74
87
  }, [treeData]);
75
88
  var clear = function clear() {
76
- var _props$onChange;
77
- (_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, [], [], {});
89
+ onChangeTreeSelect === null || onChangeTreeSelect === void 0 || onChangeTreeSelect([], [], {});
78
90
  };
79
91
  var clearKey = function clearKey(id) {
80
- var _props$onChange2;
81
92
  var newValue = _toConsumableArray(props.value);
82
93
  pull(newValue, id);
83
94
  var label = newValue.map(function (item) {
84
- return keyNodesMapping[item].title;
95
+ return keyNodesMapping[item[fieldNames.label]];
85
96
  });
86
- (_props$onChange2 = props.onChange) === null || _props$onChange2 === void 0 || _props$onChange2.call(props, newValue, label, {});
97
+ onChangeTreeSelect === null || onChangeTreeSelect === void 0 || onChangeTreeSelect(newValue, label, {});
87
98
  };
88
- var selectedNodes = useMemo(function () {
99
+ var getSelectedNodes = function getSelectedNodes(value) {
89
100
  var value_arr = function (val) {
90
101
  if (Array.isArray(val)) {
91
102
  return val;
@@ -94,90 +105,29 @@ var VtxTreeSelect = function VtxTreeSelect(_ref) {
94
105
  } else {
95
106
  return [];
96
107
  }
97
- }(props.value);
108
+ }(value);
98
109
  var selectedNodes = value_arr.filter(function (k) {
99
- return k in keyNodesMapping;
110
+ if (_labelInValue) {
111
+ return k.value in keyNodesMapping;
112
+ } else {
113
+ return k in keyNodesMapping;
114
+ }
100
115
  }).map(function (item) {
101
- return {
102
- id: item,
103
- name: keyNodesMapping[item].title
104
- };
116
+ if (_labelInValue) {
117
+ return _objectSpread({}, keyNodesMapping[item.value]);
118
+ }
119
+ return _objectSpread({}, keyNodesMapping[item]);
105
120
  });
106
121
  return selectedNodes;
122
+ };
123
+ var selectedNodes = useMemo(function () {
124
+ return getSelectedNodes(props.value);
107
125
  }, [props.value, keyNodesMapping]);
108
126
  useEffect(function () {
109
127
  if (size !== null && size !== void 0 && size.width) {
110
128
  setPopWidth(size === null || size === void 0 ? void 0 : size.width);
111
129
  }
112
130
  }, [size === null || size === void 0 ? void 0 : size.width]);
113
-
114
- // let suffixIconObj = {};
115
- // if (multiple || treeCheckable) {
116
- // suffixIconObj.suffixIcon = (
117
- // <Popover
118
- // content={
119
- // <>
120
- // <div
121
- // className={classnames(`${prefixCls}-count-head`, hashId,)}
122
-
123
- // >
124
- // <span>已选择:{selectedNodes.length}</span>
125
- // <span
126
- // className={classnames(
127
- // selectedNodes.length > 0 && !disabled
128
- // ? 'clear-count'
129
- // : 'disabled-count',
130
- // )}
131
- // onClick={e => {
132
- // if (!disabled) {
133
- // e.stopPropagation();
134
- // clear();
135
- // }
136
- // }}
137
- // >
138
- // 清空已选项
139
- // </span>
140
- // </div>
141
- // {selectedNodes.length > 0 ? (
142
- // selectedNodes.map(item => (
143
- // <Tag
144
- // key={`tab-${item.id}`}
145
- // closable={!disabled}
146
- // onClose={e => {
147
- // e.stopPropagation();
148
- // clearKey(item.id);
149
- // }}
150
- // style={{ marginBottom: '5px' }}
151
- // >
152
- // {item.name && item.name.length > 20
153
- // ? `${item.name.slice(0, 20)}...`
154
- // : item.name}
155
- // </Tag>
156
- // ))
157
- // ) : (
158
- // <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
159
- // )}
160
- // </>
161
- // }
162
- // placement="bottomRight"
163
- // trigger="click"
164
- // // overlayStyle={{ width: popWidth }}
165
- // styles={{ root: { width: popWidth } }}
166
- // >
167
- // <Button
168
- // className={classnames(`${prefixCls}-count`, hashId,)}
169
-
170
- // icon={<MoreOutlined />}
171
- // size="default"
172
- // onClick={e => {
173
- // console.log('click', e)
174
- // e.stopPropagation();
175
- // }}
176
- // />
177
- // </Popover>
178
- // );
179
- // }
180
-
181
131
  var popoverContent = /*#__PURE__*/_jsxs(_Fragment, {
182
132
  children: [/*#__PURE__*/_jsxs("div", {
183
133
  className: classnames("".concat(prefixCls, "-count-head"), hashId),
@@ -193,22 +143,33 @@ var VtxTreeSelect = function VtxTreeSelect(_ref) {
193
143
  },
194
144
  children: intl.getMessage('treeSelect.clearSelectedItems', '清空已选项')
195
145
  })]
196
- }), selectedNodes.length > 0 ? selectedNodes.map(function (item) {
197
- return /*#__PURE__*/_jsx(Tag, {
198
- closable: !disabled,
199
- onClose: function onClose(e) {
200
- e.stopPropagation();
201
- clearKey(item.id);
202
- },
203
- style: {
204
- marginBottom: 5
205
- },
206
- children: item.name.length > 20 ? "".concat(item.name.slice(0, 20), "...") : item.name
207
- }, "tab-".concat(item.id));
208
- }) : /*#__PURE__*/_jsx(Empty, {
209
- image: Empty.PRESENTED_IMAGE_SIMPLE
146
+ }), /*#__PURE__*/_jsx("div", {
147
+ className: classnames("".concat(prefixCls, "-all-list"), hashId),
148
+ children: selectedNodes.length > 0 ? selectedNodes.map(function (item) {
149
+ var _item$fieldNames$labe;
150
+ return /*#__PURE__*/_jsx(Tag, {
151
+ closable: !disabled,
152
+ onClose: function onClose(e) {
153
+ e.stopPropagation();
154
+ clearKey(item[fieldNames.value]);
155
+ },
156
+ styles: {
157
+ root: {
158
+ marginBottom: 5,
159
+ marginRight: 5
160
+ }
161
+ },
162
+ children: ((_item$fieldNames$labe = item[fieldNames.label]) === null || _item$fieldNames$labe === void 0 ? void 0 : _item$fieldNames$labe.length) > 20 ? "".concat(item[fieldNames.label].slice(0, 20), "...") : item[fieldNames.label]
163
+ }, "tab-".concat(item[fieldNames.value]));
164
+ }) : /*#__PURE__*/_jsx(Empty, {
165
+ image: Empty.PRESENTED_IMAGE_SIMPLE
166
+ })
210
167
  })]
211
168
  });
169
+ var onChangeTreeSelect = function onChangeTreeSelect(value, label, extra) {
170
+ extra.list = getSelectedNodes(value);
171
+ onChange === null || onChange === void 0 || onChange(value, label, extra);
172
+ };
212
173
  return wrapSSR( /*#__PURE__*/_jsx("div", {
213
174
  ref: ref,
214
175
  style: style,
@@ -217,8 +178,10 @@ var VtxTreeSelect = function VtxTreeSelect(_ref) {
217
178
  style: {
218
179
  width: '100%'
219
180
  },
220
- children: [/*#__PURE__*/_jsx(TreeSelect, _objectSpread({
221
- showSearch: true,
181
+ children: [/*#__PURE__*/_jsx(TreeSelect, _objectSpread(_objectSpread({
182
+ showSearch: {
183
+ treeNodeFilterProp: fieldNames.label
184
+ },
222
185
  placeholder: placeholder,
223
186
  treeData: treeData,
224
187
  treeLine: {
@@ -241,8 +204,15 @@ var VtxTreeSelect = function VtxTreeSelect(_ref) {
241
204
  popup: classnames("".concat(prefixCls, "-popup"), hashId)
242
205
  },
243
206
  maxTagCount: "responsive",
244
- treeDefaultExpandAll: true
245
- }, props)), (multiple || treeCheckable) && /*#__PURE__*/_jsx(Popover, {
207
+ treeDefaultExpandAll: true,
208
+ fieldNames: fieldNames,
209
+ labelInValue: _labelInValue,
210
+ disabled: disabled
211
+ }, props), {}, {
212
+ onChange: function onChange(value, label, extra) {
213
+ return onChangeTreeSelect(value, label, extra, selectedNodes);
214
+ }
215
+ })), (multiple || treeCheckable) && /*#__PURE__*/_jsx(Popover, {
246
216
  open: popOpen,
247
217
  onOpenChange: setPopOpen,
248
218
  placement: "bottomRight",
@@ -7,7 +7,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
7
7
  import { useStyle as useAntdStyle } from "../../vtx-provider";
8
8
  var genVtxTreeSelectStyle = function genVtxTreeSelectStyle(token) {
9
9
  var componentCls = token.componentCls;
10
- return _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, componentCls, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, '&-popover', {
10
+ return _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, componentCls, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, '&-popover', {
11
11
  minWidth: '200px',
12
12
  height: '300px',
13
13
  overflow: 'auto',
@@ -28,14 +28,16 @@ var genVtxTreeSelectStyle = function genVtxTreeSelectStyle(token) {
28
28
  color: '@input-placeholder-color'
29
29
  }), '&-count', {
30
30
  marginRight: '-12px'
31
- })), "".concat(componentCls, "-popup"), _defineProperty({}, '&', _defineProperty(_defineProperty({}, '.ant-select-tree .ant-select-tree-treenode:not(.ant-select-tree .ant-select-tree-treenode-disabled).filter-node .ant-select-tree-title', {
31
+ })), "".concat(componentCls, "-popup"), _defineProperty({}, '&', _defineProperty(_defineProperty(_defineProperty({}, '.ant-select-tree .ant-select-tree-treenode:not(.ant-select-tree .ant-select-tree-treenode-disabled).filter-node .ant-select-tree-title', {
32
32
  color: '#1890ff'
33
33
  }), '.ant-select-tree .ant-select-tree-node-content-wrapper .ant-select-tree-node-selected', {
34
34
  backgroundColor: '#e6f7ff'
35
+ }), '.ant-select-tree .ant-select-tree-list-holder-inner .ant-select-tree-treenode .ant-select-tree-node-content-wrapper', {
36
+ flex: 1
35
37
  }))), "".concat(componentCls, "-count-head"), {
36
38
  display: 'flex',
37
39
  justifyContent: 'space-between',
38
- marginBottom: '5px',
40
+ marginBottom: 5,
39
41
  '.disabled-count': {
40
42
  color: '#aaa',
41
43
  cursor: 'not-allowed'
@@ -45,6 +47,9 @@ var genVtxTreeSelectStyle = function genVtxTreeSelectStyle(token) {
45
47
  }, '&:hover', {
46
48
  color: '#40a9ff'
47
49
  })
50
+ }), "".concat(componentCls, "-all-list"), {
51
+ maxHeight: 300,
52
+ overflowY: "auto"
48
53
  }), "".concat(componentCls, "-outer"), {
49
54
  position: 'relative',
50
55
  display: 'inline-flex',
@@ -57,6 +62,7 @@ var genVtxTreeSelectStyle = function genVtxTreeSelectStyle(token) {
57
62
  color: token.colorTextDescription,
58
63
  display: 'inline-flex',
59
64
  alignItems: 'center',
65
+ width: token.controlHeight,
60
66
  '&:hover': {
61
67
  color: token.colorPrimary
62
68
  }
@@ -10,6 +10,7 @@ import PropTypes from 'prop-types';
10
10
  // import { volume, playbackRate } from 'xgplayer/dist/controls';
11
11
  import { Modal, Button } from 'antd';
12
12
  import { VtxProvider, useIntl } from "../vtx-provider";
13
+ import VtxModal from "../vtx-modal";
13
14
  import { jsx as _jsx } from "react/jsx-runtime";
14
15
  import { jsxs as _jsxs } from "react/jsx-runtime";
15
16
  function Preview(props) {
@@ -77,7 +78,7 @@ function Preview(props) {
77
78
  timer && clearTimeout(timer);
78
79
  onCancel();
79
80
  };
80
- return /*#__PURE__*/_jsxs(Modal, _objectSpread(_objectSpread({}, modalProps), {}, {
81
+ return /*#__PURE__*/_jsxs(VtxModal, _objectSpread(_objectSpread({}, modalProps), {}, {
81
82
  children: [type == 'file' ? /*#__PURE__*/_jsx("iframe", {
82
83
  src: url,
83
84
  style: {