@vtx/components 4.0.0-beta.7 → 4.0.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/utils/filterSpecialCharacters.js +47 -46
- package/es/vtx-color-picker/index.js +138 -33
- package/es/vtx-color-picker/style/index.js +36 -12
- package/es/vtx-combogrid/Combogrid.js +11 -6
- package/es/vtx-combogrid/style/index.js +4 -4
- package/es/vtx-datagrid/Store/Provide.js +5 -4
- package/es/vtx-datagrid/ToolBar/components/ColumnSetting/index.js +8 -3
- package/es/vtx-datagrid/ToolBar/components/Density/index.js +3 -0
- package/es/vtx-datagrid/ToolBar/components/TableStyle/index.js +3 -0
- package/es/vtx-datagrid/ToolBar/index.js +2 -2
- package/es/vtx-datagrid/index.js +14 -9
- package/es/vtx-datagrid/style/index.js +2 -2
- package/es/vtx-ellipsis-text/index.js +6 -1
- package/es/vtx-export/index.js +5 -0
- package/es/vtx-export-async/index.js +28 -8
- package/es/vtx-form-layout/Card.js +10 -10
- package/es/vtx-form-layout/Divider.js +1 -1
- package/es/vtx-form-layout/FormItem.js +2 -1
- package/es/vtx-form-layout/Pane.js +23 -12
- package/es/vtx-image/Preview.js +11 -6
- package/es/vtx-import/index.js +73 -33
- package/es/vtx-import2/index.js +2 -1
- package/es/vtx-import2/style/index.js +1 -1
- package/es/vtx-input/TextArea/index.js +11 -6
- package/es/vtx-modal/style/index.js +5 -3
- package/es/vtx-page-layout/Content.js +1 -1
- package/es/vtx-page-layout/TabLayout.js +1 -7
- package/es/vtx-page-layout/TableLayout.js +14 -4
- package/es/vtx-page-layout/TableWrap.js +3 -2
- package/es/vtx-page-layout/TreeLayout.js +2 -8
- package/es/vtx-page-layout/container.js +6 -5
- package/es/vtx-provider/index.js +18 -10
- package/es/vtx-provider/locale/en_US.js +10 -2
- package/es/vtx-provider/locale/zh_CN.js +20 -2
- package/es/vtx-provider/useStyle/index.js +8 -4
- package/es/vtx-scrollable-row/index.js +38 -28
- package/es/vtx-search/index.js +5 -4
- package/es/vtx-search/style/index.js +2 -1
- package/es/vtx-select/index.js +25 -11
- package/es/vtx-signature/index.js +5 -4
- package/es/vtx-signature/style/index.js +1 -1
- package/es/vtx-tree/index.js +80 -34
- package/es/vtx-tree-select/index.js +4 -0
- package/es/vtx-wang-editor/index.js +278 -108
- package/es/vtx-wang-editor/wangEditorUtil.js +59 -9
- package/lib/utils/filterSpecialCharacters.js +48 -46
- package/lib/vtx-color-picker/index.js +139 -34
- package/lib/vtx-color-picker/style/index.js +36 -12
- package/lib/vtx-combogrid/Combogrid.js +11 -6
- package/lib/vtx-combogrid/style/index.js +4 -4
- package/lib/vtx-datagrid/Store/Provide.js +5 -4
- package/lib/vtx-datagrid/ToolBar/components/ColumnSetting/index.js +8 -4
- package/lib/vtx-datagrid/ToolBar/components/Density/index.js +3 -0
- package/lib/vtx-datagrid/ToolBar/components/TableStyle/index.js +3 -0
- package/lib/vtx-datagrid/ToolBar/index.js +2 -2
- package/lib/vtx-datagrid/index.js +15 -9
- package/lib/vtx-datagrid/style/index.js +2 -2
- package/lib/vtx-ellipsis-text/index.js +6 -1
- package/lib/vtx-export/index.js +5 -0
- package/lib/vtx-export-async/index.js +26 -6
- package/lib/vtx-form-layout/Card.js +9 -9
- package/lib/vtx-form-layout/Divider.js +1 -1
- package/lib/vtx-form-layout/FormItem.js +2 -1
- package/lib/vtx-form-layout/Pane.js +22 -11
- package/lib/vtx-image/Preview.js +11 -6
- package/lib/vtx-import/index.js +73 -33
- package/lib/vtx-import2/index.js +2 -1
- package/lib/vtx-import2/style/index.js +1 -1
- package/lib/vtx-input/TextArea/index.js +11 -6
- package/lib/vtx-modal/style/index.js +5 -3
- package/lib/vtx-page-layout/Content.js +1 -1
- package/lib/vtx-page-layout/TabLayout.js +3 -9
- package/lib/vtx-page-layout/TableLayout.js +14 -4
- package/lib/vtx-page-layout/TableWrap.js +3 -2
- package/lib/vtx-page-layout/TreeLayout.js +4 -10
- package/lib/vtx-page-layout/container.js +6 -5
- package/lib/vtx-provider/index.js +17 -10
- package/lib/vtx-provider/locale/en_US.js +10 -2
- package/lib/vtx-provider/locale/zh_CN.js +20 -2
- package/lib/vtx-provider/useStyle/index.js +8 -4
- package/lib/vtx-scrollable-row/index.js +38 -28
- package/lib/vtx-search/index.js +5 -4
- package/lib/vtx-search/style/index.js +2 -1
- package/lib/vtx-select/index.js +25 -11
- package/lib/vtx-signature/index.js +4 -3
- package/lib/vtx-signature/style/index.js +1 -1
- package/lib/vtx-tree/index.js +78 -32
- package/lib/vtx-tree-select/index.js +4 -0
- package/lib/vtx-wang-editor/index.js +277 -109
- package/lib/vtx-wang-editor/wangEditorUtil.js +59 -10
- package/package.json +38 -23
package/es/vtx-tree/index.js
CHANGED
|
@@ -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,8 +20,8 @@ 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';
|
|
@@ -30,16 +30,16 @@ import { useStyle } from "./style/index";
|
|
|
30
30
|
import { VtxProvider, useIntl } from "../vtx-provider";
|
|
31
31
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
32
32
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
33
|
-
var getParentKey = function getParentKey(key, tree) {
|
|
34
|
-
var parentKey = arguments.length >
|
|
33
|
+
var getParentKey = function getParentKey(keyValue, key, tree) {
|
|
34
|
+
var parentKey = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
35
35
|
var _iterator = _createForOfIteratorHelper(tree),
|
|
36
36
|
_step;
|
|
37
37
|
try {
|
|
38
38
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
39
39
|
var node = _step.value;
|
|
40
|
-
if (node
|
|
40
|
+
if (node[keyValue] === key) return parentKey;
|
|
41
41
|
if (node.children) {
|
|
42
|
-
var found = getParentKey(key, node.children, node
|
|
42
|
+
var found = getParentKey(keyValue, key, node.children, node[keyValue]);
|
|
43
43
|
if (found !== undefined) return found;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -63,6 +63,8 @@ var VtxTree = /*#__PURE__*/forwardRef(function (propsAll, ref) {
|
|
|
63
63
|
titleClassName = propsAll.titleClassName,
|
|
64
64
|
_propsAll$expandActio = propsAll.expandAction,
|
|
65
65
|
expandAction = _propsAll$expandActio === void 0 ? 'click' : _propsAll$expandActio,
|
|
66
|
+
_propsAll$maxButtonCo = propsAll.maxButtonCount,
|
|
67
|
+
maxButtonCount = _propsAll$maxButtonCo === void 0 ? 3 : _propsAll$maxButtonCo,
|
|
66
68
|
props = _objectWithoutProperties(propsAll, _excluded);
|
|
67
69
|
var _useContext = useContext(VtxProvider),
|
|
68
70
|
getPrefixCls = _useContext.getPrefixCls;
|
|
@@ -93,12 +95,12 @@ var VtxTree = /*#__PURE__*/forwardRef(function (propsAll, ref) {
|
|
|
93
95
|
var dataList = useMemo(function () {
|
|
94
96
|
var dataList = [];
|
|
95
97
|
var titleKey = (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.title) || 'title';
|
|
98
|
+
var keyName = (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.key) || 'key';
|
|
96
99
|
var generateList = function generateList(data) {
|
|
97
100
|
for (var i = 0; i < data.length; i++) {
|
|
98
101
|
var node = data[i];
|
|
99
|
-
var key = node.key;
|
|
100
102
|
dataList.push({
|
|
101
|
-
key:
|
|
103
|
+
key: node[keyName],
|
|
102
104
|
title: node[titleKey]
|
|
103
105
|
});
|
|
104
106
|
if (node.children) {
|
|
@@ -141,6 +143,7 @@ var VtxTree = /*#__PURE__*/forwardRef(function (propsAll, ref) {
|
|
|
141
143
|
var newTreeData = parseTreeData(treeData, {
|
|
142
144
|
renderNode: function renderNode(item) {
|
|
143
145
|
var titleKey = (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.title) || 'title';
|
|
146
|
+
var keyName = (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.key) || 'key';
|
|
144
147
|
var strTitle = item[titleKey] || '';
|
|
145
148
|
var index = strTitle.indexOf(searchValue);
|
|
146
149
|
var beforeStr = strTitle.substring(0, index);
|
|
@@ -156,7 +159,7 @@ var VtxTree = /*#__PURE__*/forwardRef(function (propsAll, ref) {
|
|
|
156
159
|
className: className,
|
|
157
160
|
children: strTitle
|
|
158
161
|
});
|
|
159
|
-
return _objectSpread(_objectSpread({}, item), {}, _defineProperty(_defineProperty(_defineProperty({}, titleKey, title),
|
|
162
|
+
return _objectSpread(_objectSpread({}, item), {}, _defineProperty(_defineProperty(_defineProperty({}, titleKey, title), keyName, item[keyName]), "strTitle", strTitle));
|
|
160
163
|
},
|
|
161
164
|
filterNode: function filterNode(item) {
|
|
162
165
|
return item.strTitle.indexOf(searchValue) > -1;
|
|
@@ -168,7 +171,7 @@ var VtxTree = /*#__PURE__*/forwardRef(function (propsAll, ref) {
|
|
|
168
171
|
var _props$onExpand2;
|
|
169
172
|
var newExpandedKeys = dataList.map(function (item) {
|
|
170
173
|
if (item.title.indexOf(value) > -1) {
|
|
171
|
-
return getParentKey(item.key, treeData);
|
|
174
|
+
return getParentKey((fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.key) || 'key', item.key, treeData);
|
|
172
175
|
}
|
|
173
176
|
return null;
|
|
174
177
|
}).filter(function (item, i, self) {
|
|
@@ -190,17 +193,15 @@ var VtxTree = /*#__PURE__*/forwardRef(function (propsAll, ref) {
|
|
|
190
193
|
};
|
|
191
194
|
});
|
|
192
195
|
useEffect(function () {
|
|
193
|
-
var _treeRef$current2;
|
|
194
196
|
var resizeObserver = new ResizeObserver(function () {
|
|
195
|
-
|
|
196
|
-
setHeight(treeRef === null || treeRef === void 0 || (_treeRef$current = treeRef.current) === null || _treeRef$current === void 0 ? void 0 : _treeRef$current.offsetHeight);
|
|
197
|
+
setHeight(treeRef.current.offsetHeight);
|
|
197
198
|
});
|
|
198
199
|
if (treeRef.current) {
|
|
199
|
-
resizeObserver.observe(treeRef
|
|
200
|
+
resizeObserver.observe(treeRef.current, {
|
|
200
201
|
box: 'border-box'
|
|
201
202
|
});
|
|
202
203
|
}
|
|
203
|
-
setHeight(treeRef
|
|
204
|
+
setHeight(treeRef.current.offsetHeight);
|
|
204
205
|
return function () {
|
|
205
206
|
resizeObserver.disconnect();
|
|
206
207
|
};
|
|
@@ -252,6 +253,21 @@ var VtxTree = /*#__PURE__*/forwardRef(function (propsAll, ref) {
|
|
|
252
253
|
setSelectedKeys(newSelectedKeys);
|
|
253
254
|
}
|
|
254
255
|
};
|
|
256
|
+
var renderMenuIcon = function renderMenuIcon(arr, nodeData) {
|
|
257
|
+
return arr.map(function (item) {
|
|
258
|
+
return /*#__PURE__*/_jsx(Tooltip, {
|
|
259
|
+
title: item.label,
|
|
260
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
261
|
+
className: "".concat(prefixCls, "-menu-item-icon"),
|
|
262
|
+
onClick: function onClick(e) {
|
|
263
|
+
e.stopPropagation();
|
|
264
|
+
item.onClick && item.onClick(nodeData);
|
|
265
|
+
},
|
|
266
|
+
children: item.icon
|
|
267
|
+
})
|
|
268
|
+
}, item.label);
|
|
269
|
+
});
|
|
270
|
+
};
|
|
255
271
|
return wrapSSR( /*#__PURE__*/_jsxs("div", {
|
|
256
272
|
className: classnames("".concat(prefixCls, "-wraaper"), hashId),
|
|
257
273
|
children: [showSearch && /*#__PURE__*/_jsx(Input, {
|
|
@@ -287,28 +303,54 @@ var VtxTree = /*#__PURE__*/forwardRef(function (propsAll, ref) {
|
|
|
287
303
|
var titleKey = (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.title) || 'title';
|
|
288
304
|
var title = nodeData[titleKey];
|
|
289
305
|
if (renderMenuList) {
|
|
290
|
-
var menuList = renderMenuList(nodeData)
|
|
306
|
+
var menuList = renderMenuList(nodeData).filter(function (item) {
|
|
307
|
+
return item.visible;
|
|
308
|
+
});
|
|
309
|
+
var arr = [];
|
|
310
|
+
if (menuList.length > maxButtonCount) {
|
|
311
|
+
arr = arr.concat(renderMenuIcon(menuList.slice(0, maxButtonCount - 1), nodeData));
|
|
312
|
+
arr.push( /*#__PURE__*/_jsx(Dropdown, {
|
|
313
|
+
placement: "bottom",
|
|
314
|
+
menu: {
|
|
315
|
+
items: menuList.slice(maxButtonCount - 1).map(function (item) {
|
|
316
|
+
return {
|
|
317
|
+
key: item.label,
|
|
318
|
+
label: /*#__PURE__*/_jsxs("div", {
|
|
319
|
+
className: "".concat(prefixCls, "-menu-item-label"),
|
|
320
|
+
children: [item.icon, item.label]
|
|
321
|
+
})
|
|
322
|
+
};
|
|
323
|
+
}),
|
|
324
|
+
onClick: function onClick(obj) {
|
|
325
|
+
var key = obj.key,
|
|
326
|
+
domEvent = obj.domEvent;
|
|
327
|
+
domEvent.stopPropagation();
|
|
328
|
+
var temp = menuList.find(function (v) {
|
|
329
|
+
return v.label == key;
|
|
330
|
+
});
|
|
331
|
+
(temp === null || temp === void 0 ? void 0 : temp.onClick) && temp.onClick(nodeData);
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
trigger: ['click'],
|
|
335
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
336
|
+
className: "".concat(prefixCls, "-menu-item-icon"),
|
|
337
|
+
onClick: function onClick(e) {
|
|
338
|
+
e.stopPropagation();
|
|
339
|
+
},
|
|
340
|
+
children: /*#__PURE__*/_jsx(EllipsisOutlined, {})
|
|
341
|
+
})
|
|
342
|
+
}));
|
|
343
|
+
} else {
|
|
344
|
+
arr = arr.concat(renderMenuIcon(menuList, nodeData));
|
|
345
|
+
}
|
|
291
346
|
return /*#__PURE__*/_jsxs("div", {
|
|
292
347
|
className: classnames("".concat(prefixCls, "-menu-wrap"), hashId),
|
|
293
348
|
children: [/*#__PURE__*/_jsx("span", {
|
|
294
349
|
children: title
|
|
295
350
|
}), /*#__PURE__*/_jsx("div", {
|
|
296
351
|
className: classnames("".concat(prefixCls, "-menu-list"), hashId),
|
|
297
|
-
children:
|
|
298
|
-
|
|
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);
|
|
352
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
353
|
+
children: [arr, " "]
|
|
312
354
|
})
|
|
313
355
|
})]
|
|
314
356
|
});
|
|
@@ -325,7 +367,7 @@ VtxTree.propTypes = {
|
|
|
325
367
|
treeData: PropTypes.array,
|
|
326
368
|
selectedKeys: PropTypes.array,
|
|
327
369
|
defaultSelectedKeys: PropTypes.array,
|
|
328
|
-
expandedKeys: PropTypes.
|
|
370
|
+
expandedKeys: PropTypes.array,
|
|
329
371
|
onExpand: PropTypes.func,
|
|
330
372
|
multiple: PropTypes.bool,
|
|
331
373
|
autoExpandParent: PropTypes.bool,
|
|
@@ -333,7 +375,11 @@ VtxTree.propTypes = {
|
|
|
333
375
|
searchPlaceholder: PropTypes.string,
|
|
334
376
|
renderMenuList: PropTypes.func,
|
|
335
377
|
titleClassName: PropTypes.func,
|
|
336
|
-
fieldNames: PropTypes.
|
|
378
|
+
fieldNames: PropTypes.shape({
|
|
379
|
+
title: PropTypes.string,
|
|
380
|
+
key: PropTypes.string,
|
|
381
|
+
children: PropTypes.string
|
|
382
|
+
}),
|
|
337
383
|
defaultExpandAll: PropTypes.bool,
|
|
338
384
|
expandAction: PropTypes.oneOfType([PropTypes.string, PropTypes.bool])
|
|
339
385
|
};
|
|
@@ -58,6 +58,10 @@ var VtxTreeSelect = function VtxTreeSelect(_ref) {
|
|
|
58
58
|
var size = useSize(ref);
|
|
59
59
|
var keyNodesMapping = useMemo(function () {
|
|
60
60
|
var keyNodesMapping = {};
|
|
61
|
+
// 建议:添加树数据有效性检查
|
|
62
|
+
if (!treeData || !Array.isArray(treeData)) {
|
|
63
|
+
return keyNodesMapping;
|
|
64
|
+
}
|
|
61
65
|
(function genNodes(nodes) {
|
|
62
66
|
nodes.map(function (item) {
|
|
63
67
|
var children = item.children,
|