@vtx/components 4.0.0-beta.8 → 4.0.0-beta.81

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 (196) 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-combogrid/Combogrid.js +5 -4
  26. package/es/vtx-combogrid/index.js +7 -4
  27. package/es/vtx-datagrid/Store/Provide.js +106 -137
  28. package/es/vtx-datagrid/ToolBar/components/ColumnSetting/index.js +11 -7
  29. package/es/vtx-datagrid/ToolBar/components/ColumnSetting/style.js +5 -2
  30. package/es/vtx-datagrid/ToolBar/components/Density/index.js +3 -0
  31. package/es/vtx-datagrid/ToolBar/components/TableStyle/index.js +3 -0
  32. package/es/vtx-datagrid/columnState.js +91 -0
  33. package/es/vtx-datagrid/index.js +124 -32
  34. package/es/vtx-datagrid/mergeComponents.js +15 -0
  35. package/es/vtx-datagrid/renderColumnButtons.js +30 -11
  36. package/es/vtx-datagrid/style/index.js +102 -20
  37. package/es/vtx-datagrid/style/index.less +242 -242
  38. package/es/vtx-date-picker/QdatePicker.js +1 -1
  39. package/es/vtx-date-picker/style/index.less +39 -39
  40. package/es/vtx-descriptions/Descriptions.js +29 -0
  41. package/es/vtx-descriptions/index.js +3 -0
  42. package/es/vtx-descriptions/style/index.js +19 -0
  43. package/es/vtx-ellipsis-text/index.js +7 -2
  44. package/es/vtx-ellipsis-text/style/index.js +3 -1
  45. package/es/vtx-export/index.js +33 -33
  46. package/es/vtx-export-async/History.js +15 -7
  47. package/es/vtx-export-async/index.js +45 -15
  48. package/es/vtx-export-async/util.js +16 -5
  49. package/es/vtx-form-layout/Card.js +10 -10
  50. package/es/vtx-form-layout/Divider.js +1 -1
  51. package/es/vtx-form-layout/FormItem.js +16 -16
  52. package/es/vtx-form-layout/Pane.js +23 -12
  53. package/es/vtx-icon/index.js +54 -45
  54. package/es/vtx-icon/index.js1 +90 -0
  55. package/es/vtx-image/Preview.js +11 -6
  56. package/es/vtx-image/style/index.js +0 -1
  57. package/es/vtx-import/index.js +211 -70
  58. package/es/vtx-import/result.js +28 -26
  59. package/es/vtx-import/style/index.js +16 -1
  60. package/es/vtx-import2/Content.js +2 -1
  61. package/es/vtx-import2/index.js +30 -19
  62. package/es/vtx-import2/style/index.js +60 -9
  63. package/es/vtx-modal/index.js +11 -6
  64. package/es/vtx-page-layout/Basic.js +2 -2
  65. package/es/vtx-page-layout/TabLayout.js +6 -6
  66. package/es/vtx-page-layout/TableLayout.js +10 -10
  67. package/es/vtx-page-layout/TreeLayout.js +6 -6
  68. package/es/vtx-page-layout/container.js +2 -2
  69. package/es/vtx-page-layout/style/index.js +4 -2
  70. package/es/vtx-provider/index.js +37 -33
  71. package/es/vtx-provider/intl.js +9 -9
  72. package/es/vtx-provider/locale/en_US.js +57 -3
  73. package/es/vtx-provider/locale/zh_CN.js +57 -3
  74. package/es/vtx-provider/useStyle/index.js +17 -17
  75. package/es/vtx-search/index.js +13 -9
  76. package/es/vtx-search/style/index.js +2 -1
  77. package/es/vtx-select/index.js +102 -36
  78. package/es/vtx-select/style/index.js +11 -56
  79. package/es/vtx-signature/index.js +5 -4
  80. package/es/vtx-signature/style/index.js +1 -1
  81. package/es/vtx-split-pane/Resizer.js +0 -1
  82. package/es/vtx-split-pane/SplitPane.js +42 -34
  83. package/es/vtx-split-pane/style/index.js +8 -112
  84. package/es/vtx-time-picker/index.js +27 -1
  85. package/es/vtx-transfer/Transfer.js +29 -0
  86. package/es/vtx-transfer/index.js +3 -0
  87. package/es/vtx-transfer/style/index.js +19 -0
  88. package/es/vtx-transfer-select/TransferSelect.js +143 -0
  89. package/es/vtx-transfer-select/index.js +3 -0
  90. package/es/vtx-transfer-select/style/index.js +19 -0
  91. package/es/vtx-tree/index.js +98 -35
  92. package/es/vtx-tree-select/index.js +71 -105
  93. package/es/vtx-tree-select/style/index.js +9 -3
  94. package/es/vtx-upload/FilePreview.js +2 -1
  95. package/es/vtx-wang-editor/index.js +93 -39
  96. package/es/vtx-wang-editor/style/index.less +12 -12
  97. package/es/vtx-wang-editor/wangEditorUtil.js +4 -0
  98. package/lib/index.js +36 -0
  99. package/lib/utils/components/LabelIconTip/index.js +7 -7
  100. package/lib/utils/conversionMomentValue/index.js +25 -25
  101. package/lib/utils/filterSpecialCharacters.js +54 -52
  102. package/lib/utils/genCopyable/index.js +6 -6
  103. package/lib/utils/getFieldPropsOrFormItemProps/index.js +7 -7
  104. package/lib/utils/hooks/useDebounceFn/index.js +4 -4
  105. package/lib/utils/hooks/useDebounceValue/index.js +6 -6
  106. package/lib/utils/hooks/useDeepCompareMemo/index.js +7 -7
  107. package/lib/utils/hooks/useLatest/index.js +2 -2
  108. package/lib/utils/hooks/useRefCallback/index.js +5 -5
  109. package/lib/utils/index.js +0 -7
  110. package/lib/utils/isBrowser/index.js +7 -7
  111. package/lib/utils/isUrl/index.js +4 -4
  112. package/lib/utils/merge/index.js +4 -4
  113. package/lib/utils/nanoid/index.js +4 -4
  114. package/lib/utils/omitBoolean/index.js +4 -4
  115. package/lib/utils/parseValueToMoment/index.js +4 -4
  116. package/lib/utils/proFieldParsingText/index.js +10 -10
  117. package/lib/utils/transformKeySubmitValue/index.js +57 -57
  118. package/lib/utils/useEditableArray/index.js +46 -46
  119. package/lib/utils/useEditableMap/index.js +22 -22
  120. package/lib/utils/useMediaQuery/index.js +5 -5
  121. package/lib/vtx-combogrid/Combogrid.js +5 -4
  122. package/lib/vtx-combogrid/index.js +7 -4
  123. package/lib/vtx-datagrid/Store/Provide.js +113 -143
  124. package/lib/vtx-datagrid/ToolBar/components/ColumnSetting/index.js +11 -7
  125. package/lib/vtx-datagrid/ToolBar/components/ColumnSetting/style.js +5 -2
  126. package/lib/vtx-datagrid/ToolBar/components/Density/index.js +3 -0
  127. package/lib/vtx-datagrid/ToolBar/components/TableStyle/index.js +3 -0
  128. package/lib/vtx-datagrid/columnState.js +100 -0
  129. package/lib/vtx-datagrid/index.js +124 -32
  130. package/lib/vtx-datagrid/mergeComponents.js +21 -0
  131. package/lib/vtx-datagrid/renderColumnButtons.js +30 -11
  132. package/lib/vtx-datagrid/style/index.js +102 -20
  133. package/lib/vtx-datagrid/style/index.less +242 -242
  134. package/lib/vtx-date-picker/QdatePicker.js +1 -1
  135. package/lib/vtx-date-picker/style/index.less +39 -39
  136. package/lib/vtx-descriptions/Descriptions.js +38 -0
  137. package/lib/vtx-descriptions/index.js +15 -0
  138. package/lib/vtx-descriptions/style/index.js +25 -0
  139. package/lib/vtx-ellipsis-text/index.js +7 -2
  140. package/lib/vtx-ellipsis-text/style/index.js +3 -1
  141. package/lib/vtx-export/index.js +34 -34
  142. package/lib/vtx-export-async/History.js +14 -8
  143. package/lib/vtx-export-async/index.js +43 -13
  144. package/lib/vtx-export-async/util.js +16 -5
  145. package/lib/vtx-form-layout/Card.js +9 -9
  146. package/lib/vtx-form-layout/Divider.js +1 -1
  147. package/lib/vtx-form-layout/FormItem.js +16 -16
  148. package/lib/vtx-form-layout/Pane.js +22 -11
  149. package/lib/vtx-icon/index.js +54 -52
  150. package/lib/vtx-icon/index.js1 +90 -0
  151. package/lib/vtx-image/Preview.js +11 -6
  152. package/lib/vtx-image/style/index.js +0 -1
  153. package/lib/vtx-import/index.js +209 -71
  154. package/lib/vtx-import/result.js +29 -27
  155. package/lib/vtx-import/style/index.js +16 -1
  156. package/lib/vtx-import2/Content.js +2 -1
  157. package/lib/vtx-import2/index.js +29 -18
  158. package/lib/vtx-import2/style/index.js +60 -9
  159. package/lib/vtx-modal/index.js +11 -6
  160. package/lib/vtx-page-layout/Basic.js +2 -2
  161. package/lib/vtx-page-layout/TabLayout.js +6 -6
  162. package/lib/vtx-page-layout/TableLayout.js +10 -10
  163. package/lib/vtx-page-layout/TreeLayout.js +6 -6
  164. package/lib/vtx-page-layout/container.js +2 -2
  165. package/lib/vtx-page-layout/style/index.js +4 -2
  166. package/lib/vtx-provider/index.js +37 -33
  167. package/lib/vtx-provider/intl.js +9 -9
  168. package/lib/vtx-provider/locale/en_US.js +57 -3
  169. package/lib/vtx-provider/locale/zh_CN.js +57 -3
  170. package/lib/vtx-provider/useStyle/index.js +17 -17
  171. package/lib/vtx-search/index.js +13 -9
  172. package/lib/vtx-search/style/index.js +2 -1
  173. package/lib/vtx-select/index.js +104 -38
  174. package/lib/vtx-select/style/index.js +11 -56
  175. package/lib/vtx-signature/index.js +4 -3
  176. package/lib/vtx-signature/style/index.js +1 -1
  177. package/lib/vtx-split-pane/Resizer.js +0 -1
  178. package/lib/vtx-split-pane/SplitPane.js +40 -31
  179. package/lib/vtx-split-pane/style/index.js +8 -112
  180. package/lib/vtx-time-picker/index.js +27 -1
  181. package/lib/vtx-transfer/Transfer.js +38 -0
  182. package/lib/vtx-transfer/index.js +15 -0
  183. package/lib/vtx-transfer/style/index.js +25 -0
  184. package/lib/vtx-transfer-select/TransferSelect.js +151 -0
  185. package/lib/vtx-transfer-select/index.js +15 -0
  186. package/lib/vtx-transfer-select/style/index.js +25 -0
  187. package/lib/vtx-tree/index.js +96 -33
  188. package/lib/vtx-tree-select/index.js +71 -105
  189. package/lib/vtx-tree-select/style/index.js +9 -3
  190. package/lib/vtx-upload/FilePreview.js +2 -1
  191. package/lib/vtx-wang-editor/index.js +91 -37
  192. package/lib/vtx-wang-editor/style/index.less +12 -12
  193. package/lib/vtx-wang-editor/wangEditorUtil.js +4 -0
  194. package/package.json +240 -225
  195. package/es/utils/hooks/useFetchData/index.js +0 -82
  196. 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,18 +194,33 @@ var VtxTree = /*#__PURE__*/forwardRef(function (propsAll, ref) {
190
194
  };
191
195
  });
192
196
  useEffect(function () {
193
- if (!treeRef.current) return;
194
- var resizeObserver = new ResizeObserver(function () {
195
- setHeight(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
+ }
196
213
  });
197
- resizeObserver.observe(treeRef.current, {
214
+ resizeObserver.observe(element, {
198
215
  box: 'border-box'
199
216
  });
217
+
218
+ // 初始化高度
219
+ setHeight(element.offsetHeight);
200
220
  return function () {
201
- return resizeObserver.disconnect();
221
+ resizeObserver.disconnect();
202
222
  };
203
- }, [treeRef]); // 添加依赖
204
-
223
+ }, []);
205
224
  var onSelect = function onSelect(keys, event) {
206
225
  var _props$onSelect;
207
226
  var multiple = props.multiple;
@@ -249,6 +268,21 @@ var VtxTree = /*#__PURE__*/forwardRef(function (propsAll, ref) {
249
268
  setSelectedKeys(newSelectedKeys);
250
269
  }
251
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
+ };
252
286
  return wrapSSR( /*#__PURE__*/_jsxs("div", {
253
287
  className: classnames("".concat(prefixCls, "-wraaper"), hashId),
254
288
  children: [showSearch && /*#__PURE__*/_jsx(Input, {
@@ -265,7 +299,10 @@ var VtxTree = /*#__PURE__*/forwardRef(function (propsAll, ref) {
265
299
  ref: treeRef,
266
300
  children: /*#__PURE__*/_jsx(Tree, _objectSpread(_objectSpread(_objectSpread({}, props), {}, {
267
301
  height: height,
268
- switcherIcon: /*#__PURE__*/_jsx(DownOutlined, {}),
302
+ switcherIcon: /*#__PURE__*/_jsx(VtxIcon, {
303
+ type: "downOutlined",
304
+ fileType: "svg"
305
+ }),
269
306
  showLine: {
270
307
  showLeafIcon: false
271
308
  },
@@ -284,28 +321,54 @@ var VtxTree = /*#__PURE__*/forwardRef(function (propsAll, ref) {
284
321
  var titleKey = (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.title) || 'title';
285
322
  var title = nodeData[titleKey];
286
323
  if (renderMenuList) {
287
- 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
+ }
288
364
  return /*#__PURE__*/_jsxs("div", {
289
365
  className: classnames("".concat(prefixCls, "-menu-wrap"), hashId),
290
366
  children: [/*#__PURE__*/_jsx("span", {
291
367
  children: title
292
368
  }), /*#__PURE__*/_jsx("div", {
293
369
  className: classnames("".concat(prefixCls, "-menu-list"), hashId),
294
- children: menuList.filter(function (item) {
295
- return item.visible;
296
- }).map(function (item) {
297
- return /*#__PURE__*/_jsx(Tooltip, {
298
- title: item.label,
299
- children: /*#__PURE__*/_jsx("span", {
300
- className: classnames("".concat(prefixCls, "-menu-item-icon"), hashId),
301
- onClick: function onClick(e) {
302
- e.stopPropagation();
303
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
304
- item.onClick && item.onClick(nodeData);
305
- },
306
- children: item.icon
307
- })
308
- }, item.label);
370
+ children: /*#__PURE__*/_jsxs("div", {
371
+ children: [arr, " "]
309
372
  })
310
373
  })]
311
374
  });
@@ -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;
@@ -64,11 +75,9 @@ var VtxTreeSelect = function VtxTreeSelect(_ref) {
64
75
  }
65
76
  (function genNodes(nodes) {
66
77
  nodes.map(function (item) {
67
- var children = item.children,
68
- rest = _objectWithoutProperties(item, _excluded2);
69
- keyNodesMapping[item.value || item.key] = _objectSpread(_objectSpread({}, rest), {}, {
70
- id: item.value || item.key
71
- });
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]));
72
81
  if (Array.isArray(children) && children.length > 0) {
73
82
  genNodes(children);
74
83
  }
@@ -77,19 +86,17 @@ var VtxTreeSelect = function VtxTreeSelect(_ref) {
77
86
  return keyNodesMapping;
78
87
  }, [treeData]);
79
88
  var clear = function clear() {
80
- var _props$onChange;
81
- (_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, [], [], {});
89
+ onChangeTreeSelect === null || onChangeTreeSelect === void 0 || onChangeTreeSelect([], [], {});
82
90
  };
83
91
  var clearKey = function clearKey(id) {
84
- var _props$onChange2;
85
92
  var newValue = _toConsumableArray(props.value);
86
93
  pull(newValue, id);
87
94
  var label = newValue.map(function (item) {
88
- return keyNodesMapping[item].title;
95
+ return keyNodesMapping[item[fieldNames.label]];
89
96
  });
90
- (_props$onChange2 = props.onChange) === null || _props$onChange2 === void 0 || _props$onChange2.call(props, newValue, label, {});
97
+ onChangeTreeSelect === null || onChangeTreeSelect === void 0 || onChangeTreeSelect(newValue, label, {});
91
98
  };
92
- var selectedNodes = useMemo(function () {
99
+ var getSelectedNodes = function getSelectedNodes(value) {
93
100
  var value_arr = function (val) {
94
101
  if (Array.isArray(val)) {
95
102
  return val;
@@ -98,90 +105,29 @@ var VtxTreeSelect = function VtxTreeSelect(_ref) {
98
105
  } else {
99
106
  return [];
100
107
  }
101
- }(props.value);
108
+ }(value);
102
109
  var selectedNodes = value_arr.filter(function (k) {
103
- return k in keyNodesMapping;
110
+ if (_labelInValue) {
111
+ return k.value in keyNodesMapping;
112
+ } else {
113
+ return k in keyNodesMapping;
114
+ }
104
115
  }).map(function (item) {
105
- return {
106
- id: item,
107
- name: keyNodesMapping[item].title
108
- };
116
+ if (_labelInValue) {
117
+ return _objectSpread({}, keyNodesMapping[item.value]);
118
+ }
119
+ return _objectSpread({}, keyNodesMapping[item]);
109
120
  });
110
121
  return selectedNodes;
122
+ };
123
+ var selectedNodes = useMemo(function () {
124
+ return getSelectedNodes(props.value);
111
125
  }, [props.value, keyNodesMapping]);
112
126
  useEffect(function () {
113
127
  if (size !== null && size !== void 0 && size.width) {
114
128
  setPopWidth(size === null || size === void 0 ? void 0 : size.width);
115
129
  }
116
130
  }, [size === null || size === void 0 ? void 0 : size.width]);
117
-
118
- // let suffixIconObj = {};
119
- // if (multiple || treeCheckable) {
120
- // suffixIconObj.suffixIcon = (
121
- // <Popover
122
- // content={
123
- // <>
124
- // <div
125
- // className={classnames(`${prefixCls}-count-head`, hashId,)}
126
-
127
- // >
128
- // <span>已选择:{selectedNodes.length}</span>
129
- // <span
130
- // className={classnames(
131
- // selectedNodes.length > 0 && !disabled
132
- // ? 'clear-count'
133
- // : 'disabled-count',
134
- // )}
135
- // onClick={e => {
136
- // if (!disabled) {
137
- // e.stopPropagation();
138
- // clear();
139
- // }
140
- // }}
141
- // >
142
- // 清空已选项
143
- // </span>
144
- // </div>
145
- // {selectedNodes.length > 0 ? (
146
- // selectedNodes.map(item => (
147
- // <Tag
148
- // key={`tab-${item.id}`}
149
- // closable={!disabled}
150
- // onClose={e => {
151
- // e.stopPropagation();
152
- // clearKey(item.id);
153
- // }}
154
- // style={{ marginBottom: '5px' }}
155
- // >
156
- // {item.name && item.name.length > 20
157
- // ? `${item.name.slice(0, 20)}...`
158
- // : item.name}
159
- // </Tag>
160
- // ))
161
- // ) : (
162
- // <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
163
- // )}
164
- // </>
165
- // }
166
- // placement="bottomRight"
167
- // trigger="click"
168
- // // overlayStyle={{ width: popWidth }}
169
- // styles={{ root: { width: popWidth } }}
170
- // >
171
- // <Button
172
- // className={classnames(`${prefixCls}-count`, hashId,)}
173
-
174
- // icon={<MoreOutlined />}
175
- // size="default"
176
- // onClick={e => {
177
- // console.log('click', e)
178
- // e.stopPropagation();
179
- // }}
180
- // />
181
- // </Popover>
182
- // );
183
- // }
184
-
185
131
  var popoverContent = /*#__PURE__*/_jsxs(_Fragment, {
186
132
  children: [/*#__PURE__*/_jsxs("div", {
187
133
  className: classnames("".concat(prefixCls, "-count-head"), hashId),
@@ -197,22 +143,33 @@ var VtxTreeSelect = function VtxTreeSelect(_ref) {
197
143
  },
198
144
  children: intl.getMessage('treeSelect.clearSelectedItems', '清空已选项')
199
145
  })]
200
- }), selectedNodes.length > 0 ? selectedNodes.map(function (item) {
201
- return /*#__PURE__*/_jsx(Tag, {
202
- closable: !disabled,
203
- onClose: function onClose(e) {
204
- e.stopPropagation();
205
- clearKey(item.id);
206
- },
207
- style: {
208
- marginBottom: 5
209
- },
210
- children: item.name.length > 20 ? "".concat(item.name.slice(0, 20), "...") : item.name
211
- }, "tab-".concat(item.id));
212
- }) : /*#__PURE__*/_jsx(Empty, {
213
- 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
+ })
214
167
  })]
215
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
+ };
216
173
  return wrapSSR( /*#__PURE__*/_jsx("div", {
217
174
  ref: ref,
218
175
  style: style,
@@ -221,8 +178,10 @@ var VtxTreeSelect = function VtxTreeSelect(_ref) {
221
178
  style: {
222
179
  width: '100%'
223
180
  },
224
- children: [/*#__PURE__*/_jsx(TreeSelect, _objectSpread({
225
- showSearch: true,
181
+ children: [/*#__PURE__*/_jsx(TreeSelect, _objectSpread(_objectSpread({
182
+ showSearch: {
183
+ treeNodeFilterProp: fieldNames.label
184
+ },
226
185
  placeholder: placeholder,
227
186
  treeData: treeData,
228
187
  treeLine: {
@@ -245,8 +204,15 @@ var VtxTreeSelect = function VtxTreeSelect(_ref) {
245
204
  popup: classnames("".concat(prefixCls, "-popup"), hashId)
246
205
  },
247
206
  maxTagCount: "responsive",
248
- treeDefaultExpandAll: true
249
- }, 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, {
250
216
  open: popOpen,
251
217
  onOpenChange: setPopOpen,
252
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: {