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

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 (135) hide show
  1. package/es/index.js +3 -0
  2. package/es/utils/filterSpecialCharacters.js +47 -46
  3. package/es/utils/index.js +1 -2
  4. package/es/vtx-combogrid/Combogrid.js +5 -4
  5. package/es/vtx-combogrid/index.js +7 -4
  6. package/es/vtx-datagrid/Store/Provide.js +106 -137
  7. package/es/vtx-datagrid/ToolBar/components/ColumnSetting/index.js +7 -3
  8. package/es/vtx-datagrid/ToolBar/components/ColumnSetting/style.js +5 -2
  9. package/es/vtx-datagrid/ToolBar/components/Density/index.js +3 -0
  10. package/es/vtx-datagrid/ToolBar/components/TableStyle/index.js +3 -0
  11. package/es/vtx-datagrid/columnState.js +91 -0
  12. package/es/vtx-datagrid/index.js +124 -32
  13. package/es/vtx-datagrid/mergeComponents.js +15 -0
  14. package/es/vtx-datagrid/renderColumnButtons.js +30 -11
  15. package/es/vtx-datagrid/style/index.js +102 -20
  16. package/es/vtx-date-picker/QdatePicker.js +1 -1
  17. package/es/vtx-descriptions/Descriptions.js +29 -0
  18. package/es/vtx-descriptions/index.js +3 -0
  19. package/es/vtx-descriptions/style/index.js +19 -0
  20. package/es/vtx-ellipsis-text/index.js +7 -2
  21. package/es/vtx-ellipsis-text/style/index.js +3 -1
  22. package/es/vtx-export/index.js +25 -25
  23. package/es/vtx-export-async/History.js +11 -3
  24. package/es/vtx-export-async/index.js +45 -15
  25. package/es/vtx-export-async/util.js +16 -5
  26. package/es/vtx-form-layout/Card.js +10 -10
  27. package/es/vtx-form-layout/Divider.js +1 -1
  28. package/es/vtx-form-layout/FormItem.js +16 -16
  29. package/es/vtx-form-layout/Pane.js +23 -12
  30. package/es/vtx-icon/index.js +54 -45
  31. package/es/vtx-icon/index.js1 +90 -0
  32. package/es/vtx-image/Preview.js +11 -6
  33. package/es/vtx-image/style/index.js +0 -1
  34. package/es/vtx-import/index.js +207 -65
  35. package/es/vtx-import/result.js +28 -26
  36. package/es/vtx-import/style/index.js +16 -1
  37. package/es/vtx-import2/Content.js +2 -1
  38. package/es/vtx-import2/index.js +30 -19
  39. package/es/vtx-import2/style/index.js +60 -9
  40. package/es/vtx-modal/index.js +9 -4
  41. package/es/vtx-page-layout/style/index.js +4 -2
  42. package/es/vtx-provider/index.js +7 -3
  43. package/es/vtx-provider/locale/en_US.js +57 -3
  44. package/es/vtx-provider/locale/zh_CN.js +57 -3
  45. package/es/vtx-search/index.js +13 -9
  46. package/es/vtx-search/style/index.js +2 -1
  47. package/es/vtx-select/index.js +102 -36
  48. package/es/vtx-select/style/index.js +11 -56
  49. package/es/vtx-signature/index.js +5 -4
  50. package/es/vtx-signature/style/index.js +1 -1
  51. package/es/vtx-split-pane/Resizer.js +0 -1
  52. package/es/vtx-split-pane/SplitPane.js +42 -34
  53. package/es/vtx-split-pane/style/index.js +8 -112
  54. package/es/vtx-time-picker/index.js +27 -1
  55. package/es/vtx-transfer/Transfer.js +29 -0
  56. package/es/vtx-transfer/index.js +3 -0
  57. package/es/vtx-transfer/style/index.js +19 -0
  58. package/es/vtx-transfer-select/TransferSelect.js +143 -0
  59. package/es/vtx-transfer-select/index.js +3 -0
  60. package/es/vtx-transfer-select/style/index.js +19 -0
  61. package/es/vtx-tree/index.js +98 -35
  62. package/es/vtx-tree-select/index.js +71 -105
  63. package/es/vtx-tree-select/style/index.js +9 -3
  64. package/es/vtx-upload/FilePreview.js +2 -1
  65. package/es/vtx-wang-editor/index.js +93 -39
  66. package/es/vtx-wang-editor/wangEditorUtil.js +4 -0
  67. package/lib/index.js +36 -0
  68. package/lib/utils/filterSpecialCharacters.js +48 -46
  69. package/lib/utils/index.js +0 -7
  70. package/lib/vtx-combogrid/Combogrid.js +5 -4
  71. package/lib/vtx-combogrid/index.js +7 -4
  72. package/lib/vtx-datagrid/Store/Provide.js +113 -143
  73. package/lib/vtx-datagrid/ToolBar/components/ColumnSetting/index.js +7 -3
  74. package/lib/vtx-datagrid/ToolBar/components/ColumnSetting/style.js +5 -2
  75. package/lib/vtx-datagrid/ToolBar/components/Density/index.js +3 -0
  76. package/lib/vtx-datagrid/ToolBar/components/TableStyle/index.js +3 -0
  77. package/lib/vtx-datagrid/columnState.js +100 -0
  78. package/lib/vtx-datagrid/index.js +124 -32
  79. package/lib/vtx-datagrid/mergeComponents.js +21 -0
  80. package/lib/vtx-datagrid/renderColumnButtons.js +30 -11
  81. package/lib/vtx-datagrid/style/index.js +102 -20
  82. package/lib/vtx-date-picker/QdatePicker.js +1 -1
  83. package/lib/vtx-descriptions/Descriptions.js +38 -0
  84. package/lib/vtx-descriptions/index.js +15 -0
  85. package/lib/vtx-descriptions/style/index.js +25 -0
  86. package/lib/vtx-ellipsis-text/index.js +7 -2
  87. package/lib/vtx-ellipsis-text/style/index.js +3 -1
  88. package/lib/vtx-export/index.js +26 -26
  89. package/lib/vtx-export-async/History.js +11 -3
  90. package/lib/vtx-export-async/index.js +43 -13
  91. package/lib/vtx-export-async/util.js +16 -5
  92. package/lib/vtx-form-layout/Card.js +9 -9
  93. package/lib/vtx-form-layout/Divider.js +1 -1
  94. package/lib/vtx-form-layout/FormItem.js +16 -16
  95. package/lib/vtx-form-layout/Pane.js +22 -11
  96. package/lib/vtx-icon/index.js +54 -52
  97. package/lib/vtx-icon/index.js1 +90 -0
  98. package/lib/vtx-image/Preview.js +11 -6
  99. package/lib/vtx-image/style/index.js +0 -1
  100. package/lib/vtx-import/index.js +205 -63
  101. package/lib/vtx-import/result.js +29 -27
  102. package/lib/vtx-import/style/index.js +16 -1
  103. package/lib/vtx-import2/Content.js +2 -1
  104. package/lib/vtx-import2/index.js +29 -18
  105. package/lib/vtx-import2/style/index.js +60 -9
  106. package/lib/vtx-modal/index.js +9 -4
  107. package/lib/vtx-page-layout/style/index.js +4 -2
  108. package/lib/vtx-provider/index.js +7 -3
  109. package/lib/vtx-provider/locale/en_US.js +57 -3
  110. package/lib/vtx-provider/locale/zh_CN.js +57 -3
  111. package/lib/vtx-search/index.js +13 -9
  112. package/lib/vtx-search/style/index.js +2 -1
  113. package/lib/vtx-select/index.js +104 -38
  114. package/lib/vtx-select/style/index.js +11 -56
  115. package/lib/vtx-signature/index.js +4 -3
  116. package/lib/vtx-signature/style/index.js +1 -1
  117. package/lib/vtx-split-pane/Resizer.js +0 -1
  118. package/lib/vtx-split-pane/SplitPane.js +40 -31
  119. package/lib/vtx-split-pane/style/index.js +8 -112
  120. package/lib/vtx-time-picker/index.js +27 -1
  121. package/lib/vtx-transfer/Transfer.js +38 -0
  122. package/lib/vtx-transfer/index.js +15 -0
  123. package/lib/vtx-transfer/style/index.js +25 -0
  124. package/lib/vtx-transfer-select/TransferSelect.js +151 -0
  125. package/lib/vtx-transfer-select/index.js +15 -0
  126. package/lib/vtx-transfer-select/style/index.js +25 -0
  127. package/lib/vtx-tree/index.js +96 -33
  128. package/lib/vtx-tree-select/index.js +71 -105
  129. package/lib/vtx-tree-select/style/index.js +9 -3
  130. package/lib/vtx-upload/FilePreview.js +2 -1
  131. package/lib/vtx-wang-editor/index.js +91 -37
  132. package/lib/vtx-wang-editor/wangEditorUtil.js +4 -0
  133. package/package.json +47 -32
  134. package/es/utils/hooks/useFetchData/index.js +0 -82
  135. package/lib/utils/hooks/useFetchData/index.js +0 -89
@@ -22,7 +22,7 @@ function VtxDivider(props) {
22
22
  var prefixCls = getPrefixCls('', 'vtx-form-layout-divider');
23
23
  var size = props.size;
24
24
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Divider, {
25
- className: (0, _classnames2.default)(prefixCls, _defineProperty({}, "".concat(prefixCls, "--small'"), size === 'small'))
25
+ className: (0, _classnames2.default)(prefixCls, _defineProperty({}, "".concat(prefixCls, "--small"), size === 'small'))
26
26
  });
27
27
  }
28
28
  VtxDivider.propTypes = {
@@ -10,6 +10,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
10
10
  var _antd = require("antd");
11
11
  var _classnames7 = _interopRequireDefault(require("classnames"));
12
12
  var _context = require("./context");
13
+ var _vtxProvider = require("../vtx-provider");
13
14
  var _jsxRuntime = require("react/jsx-runtime");
14
15
  var _excluded = ["weights", "label", "inline", "hideTooltip", "disableHtmlFor", "tooltip", "hidden", "nameExtra"]; // 24 栅格
15
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -25,6 +26,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
25
26
  var SPAN = 24;
26
27
  function FormItem(props) {
27
28
  var _rest$rules;
29
+ var intl = (0, _vtxProvider.useIntl)();
28
30
  var _useContext = (0, _react.useContext)(_antd.ConfigProvider.ConfigContext),
29
31
  getPrefixCls = _useContext.getPrefixCls;
30
32
  var prefixCls = getPrefixCls('', 'vtx-form-layout-item');
@@ -68,27 +70,25 @@ function FormItem(props) {
68
70
  if (placeholder) {
69
71
  return placeholder;
70
72
  }
71
- if (typeof label === 'string') {
72
- if (!['Input', 'Select', 'RangePicker', 'VtxInput', 'InputNumber', 'VtxSelect', 'TextArea'].includes(type === null || type === void 0 ? void 0 : type.displayName)) {
73
- // console.log(type?.displayName)
74
- }
75
- if (['Input', 'InputNumber', 'VtxInput', 'TextArea'].includes(type === null || type === void 0 ? void 0 : type.displayName)) {
76
- return '请输入' + label;
77
- }
78
- if (['Select', 'VtxColorPicker', 'VtxSelect', 'VtxCombogrid'].includes(type === null || type === void 0 ? void 0 : type.displayName)) {
79
- return '请选择' + label;
80
- }
81
- if (['RangePicker'].includes(type === null || type === void 0 ? void 0 : type.displayName)) {
82
- return undefined;
83
- }
73
+ if (['Input', 'InputNumber', 'VtxInput', 'TextArea', 'VtxEditor'].includes(type === null || type === void 0 ? void 0 : type.displayName)) {
74
+ // return '请输入' + label
75
+ return intl.getMessage('tableForm.inputPlaceholder', '请输入');
76
+ }
77
+ if (['Select', 'VtxColorPicker', 'VtxSelect', 'VtxCombogrid', 'VtxTreeSelect', 'VtxZtreeSelect', 'VtxSearchMapInput'].includes(type === null || type === void 0 ? void 0 : type.displayName)) {
78
+ // return '请选择' + label
79
+ return intl.getMessage('tableForm.selectPlaceholder', '请选择');
80
+ }
81
+ if (['DatePicker', 'RangePicker', 'TimePicker', 'VtxDatePicker', 'VtxRangePicker', 'VtxTimePicker', 'VtxTimeRangePicker'].includes(type === null || type === void 0 ? void 0 : type.displayName)) {
82
+ return undefined;
84
83
  }
85
84
  return null;
86
85
  };
87
86
  var renderItem = function renderItem(child) {
88
87
  if ( /*#__PURE__*/(0, _react.isValidElement)(child)) {
89
- return /*#__PURE__*/_react.default.cloneElement(child, {
90
- placeholder: initPlaceholder(props.placeholder, label, child === null || child === void 0 ? void 0 : child.type)
91
- });
88
+ var _child$props;
89
+ return /*#__PURE__*/_react.default.cloneElement(child, _objectSpread(_objectSpread({}, child.props), {}, {
90
+ placeholder: initPlaceholder(child === null || child === void 0 || (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.placeholder, label, child === null || child === void 0 ? void 0 : child.type)
91
+ }));
92
92
  }
93
93
  return child;
94
94
  };
@@ -17,18 +17,29 @@ function Pane(props) {
17
17
  var _useContext = (0, _react.useContext)(_antd.ConfigProvider.ConfigContext),
18
18
  getPrefixCls = _useContext.getPrefixCls;
19
19
  var prefixCls = getPrefixCls('', 'vtx-form-layout-pane');
20
- var title = props.title;
21
- var items = [{
22
- key: '1',
23
- label: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
24
- className: "".concat(prefixCls, "-title"),
25
- children: title
26
- }),
27
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
20
+ var title = props.title,
21
+ children = props.children;
22
+
23
+ // 无标题时直接渲染内容
24
+ if (!title) {
25
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
28
26
  className: "".concat(prefixCls, "-content"),
29
- children: props.children
30
- })
31
- }];
27
+ children: children
28
+ });
29
+ }
30
+ var items = (0, _react.useMemo)(function () {
31
+ return [{
32
+ key: '1',
33
+ label: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
34
+ className: "".concat(prefixCls, "-title"),
35
+ children: title
36
+ }),
37
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
38
+ className: "".concat(prefixCls, "-content"),
39
+ children: children
40
+ })
41
+ }];
42
+ }, [title, children, prefixCls]);
32
43
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Collapse, {
33
44
  className: prefixCls,
34
45
  bordered: false,
@@ -6,76 +6,78 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = exports.VtxIcon = void 0;
8
8
  var _react = require("react");
9
+ var _alignRightOutlined = _interopRequireDefault(require("./svg/alignRightOutlined.js"));
10
+ var _columnHeightOutlined = _interopRequireDefault(require("./svg/columnHeightOutlined.js"));
11
+ var _downOutlined = _interopRequireDefault(require("./svg/downOutlined.js"));
12
+ var _fullscreen = _interopRequireDefault(require("./svg/fullscreen.js"));
13
+ var _redoOutlined = _interopRequireDefault(require("./svg/redoOutlined.js"));
14
+ var _rightOutlined = _interopRequireDefault(require("./svg/rightOutlined.js"));
15
+ var _settingOutlined = _interopRequireDefault(require("./svg/settingOutlined.js"));
9
16
  var _jsxRuntime = require("react/jsx-runtime");
10
- var _excluded = ["type", "size", "className", "style", "color", "fileType"];
17
+ var _excluded = ["width", "height", "style", "className"],
18
+ _excluded2 = ["type", "size", "className", "style", "color", "fileType"];
19
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
20
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
21
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
22
  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; }
14
23
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
15
24
  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); }
16
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
17
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
25
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
19
26
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
20
- var VtxIcon = exports.VtxIcon = /*#__PURE__*/(0, _react.memo)(function (_ref) {
21
- var type = _ref.type,
22
- _ref$size = _ref.size,
23
- size = _ref$size === void 0 ? 16 : _ref$size,
24
- _ref$className = _ref.className,
25
- className = _ref$className === void 0 ? '' : _ref$className,
26
- _ref$style = _ref.style,
27
- style = _ref$style === void 0 ? {} : _ref$style,
28
- color = _ref.color,
29
- _ref$fileType = _ref.fileType,
30
- fileType = _ref$fileType === void 0 ? 'webp' : _ref$fileType,
27
+ var iconComponents = {
28
+ alignRightOutlined: _alignRightOutlined.default,
29
+ columnHeightOutlined: _columnHeightOutlined.default,
30
+ downOutlined: _downOutlined.default,
31
+ fullscreen: _fullscreen.default,
32
+ redoOutlined: _redoOutlined.default,
33
+ rightOutlined: _rightOutlined.default,
34
+ settingOutlined: _settingOutlined.default
35
+ // 低频图标如果确实需要,可以再考虑 lazy
36
+ };
37
+ var EmptySvg = function EmptySvg(_ref) {
38
+ var width = _ref.width,
39
+ height = _ref.height,
40
+ style = _ref.style,
41
+ className = _ref.className,
31
42
  props = _objectWithoutProperties(_ref, _excluded);
43
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", _objectSpread({
44
+ width: width,
45
+ height: height,
46
+ style: style,
47
+ className: className
48
+ }, props));
49
+ };
50
+ var VtxIcon = exports.VtxIcon = /*#__PURE__*/(0, _react.memo)(function (_ref2) {
51
+ var type = _ref2.type,
52
+ _ref2$size = _ref2.size,
53
+ size = _ref2$size === void 0 ? 16 : _ref2$size,
54
+ _ref2$className = _ref2.className,
55
+ className = _ref2$className === void 0 ? '' : _ref2$className,
56
+ _ref2$style = _ref2.style,
57
+ style = _ref2$style === void 0 ? {} : _ref2$style,
58
+ color = _ref2.color,
59
+ _ref2$fileType = _ref2.fileType,
60
+ fileType = _ref2$fileType === void 0 ? 'webp' : _ref2$fileType,
61
+ props = _objectWithoutProperties(_ref2, _excluded2);
32
62
  var width = props.width || size;
33
63
  var height = props.height || size;
34
64
  if (!type) {
35
65
  return null;
36
66
  }
37
- var SvgComponent = (0, _react.useMemo)(function () {
38
- // 动态导入并缓存结果
39
- return /*#__PURE__*/(0, _react.lazy)(function () {
40
- return function (specifier) {
41
- return new Promise(function (r) {
42
- return r(specifier);
43
- }).then(function (s) {
44
- return _interopRequireWildcard(require(s));
45
- });
46
- }( /* @vite-ignore */"./svg/".concat(type, ".js"));
47
- });
48
- }, [type]);
49
67
 
50
68
  // 默认返回空元素
51
69
  if (fileType == 'svg') {
52
- try {
53
- // const SvgComponent = lazy(() => import(`./svg/${type}.js`));
54
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Suspense, {
55
- fallback: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
56
- style: _objectSpread({
57
- width: width,
58
- height: height
59
- }, style)
60
- }),
61
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(SvgComponent, _objectSpread({
62
- className: className,
63
- style: _objectSpread({
64
- width: width,
65
- height: height
66
- }, style),
67
- fill: color
68
- }, props))
69
- });
70
- } catch (error) {
71
- // 如果动态导入失败,返回空的 SVG 元素
72
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", _objectSpread({
70
+ var SvgComponent = iconComponents[type] || EmptySvg;
71
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(SvgComponent, _objectSpread({
72
+ className: className,
73
+ style: _objectSpread({
73
74
  width: width,
74
- height: height,
75
- style: style,
76
- className: className
77
- }, props));
78
- }
75
+ height: height
76
+ }, style),
77
+ width: width,
78
+ height: height,
79
+ fill: color
80
+ }, props));
79
81
  } else {
80
82
  return (
81
83
  /*#__PURE__*/
@@ -0,0 +1,90 @@
1
+ import { lazy, memo, Suspense, useMemo } from 'react';
2
+ import AlignRightOutlined from './svg/alignRightOutlined.js';
3
+ import ColumnHeightOutlined from './svg/columnHeightOutlined.js';
4
+ import DownOutlined from './svg/downOutlined.js';
5
+ import Fullscreen from './svg/fullscreen.js';
6
+ import RedoOutlined from './svg/redoOutlined.js';
7
+ import RightOutlined from './svg/rightOutlined.js';
8
+ import SettingOutlined from './svg/settingOutlined.js';
9
+
10
+
11
+ const iconComponents = {
12
+ alignRightOutlined: AlignRightOutlined,
13
+ columnHeightOutlined: ColumnHeightOutlined,
14
+ downOutlined: DownOutlined,
15
+ fullscreen: Fullscreen,
16
+ redoOutlined: RedoOutlined,
17
+ rightOutlined: RightOutlined,
18
+ settingOutlined: SettingOutlined,
19
+ // 低频图标如果确实需要,可以再考虑 lazy
20
+ };
21
+
22
+ // const iconComponents = {
23
+ // // 核心:添加你需要的所有图标, 动态导入有的组件会失败
24
+ // alignRightOutlined: lazy(() => import('./svg/alignRightOutlined.js')),
25
+ // columnHeightOutlined: lazy(() => import('./svg/columnHeightOutlined.js')),
26
+ // downOutlined: lazy(() => import('./svg/downOutlined.js')),
27
+ // fullscreen: lazy(() => import('./svg/fullscreen.js')),
28
+ // redoOutlined: lazy(() => import('./svg/redoOutlined.js')),
29
+ // rightOutlined: lazy(() => import('./svg/rightOutlined.js')),
30
+ // settingOutlined: lazy(() => import('./svg/settingOutlined.js')),
31
+ // // 新增其他图标...
32
+ // };
33
+
34
+
35
+ const VtxIcon = memo(({
36
+ type,
37
+ size = 16,
38
+ className = '',
39
+ style = {},
40
+ color,
41
+ fileType = 'webp',
42
+ ...props
43
+ }) => {
44
+ const width = props.width || size;
45
+ const height = props.height || size;
46
+ if (!type) {
47
+ return null;
48
+ }
49
+ // const SvgComponent = useMemo(() => {
50
+ // // 动态导入并缓存结果
51
+ // return lazy(() => import(/* @vite-ignore */`./svg/${type}.js`));
52
+ // }, [type]);
53
+
54
+ const SvgComponent = useMemo(() => {
55
+ // 兜底:找不到对应图标时,返回一个空组件(避免报错)
56
+ return iconComponents[type] || lazy(() => Promise.resolve({ default: () => <svg width={width} height={height} /> }));
57
+ }, [type, width, height]);
58
+
59
+ // 默认返回空元素
60
+ if (fileType == 'svg') {
61
+ try {
62
+ // const SvgComponent = lazy(() => import(`./svg/${type}.js`));
63
+ return (
64
+ <Suspense fallback={<div style={{ width, height, ...style }} />}>
65
+ <SvgComponent
66
+ className={className}
67
+ style={{ width, height, ...style }}
68
+ fill={color}
69
+ {...props}
70
+ />
71
+ </Suspense>
72
+ );
73
+ } catch (error) {
74
+ // 如果动态导入失败,返回空的 SVG 元素
75
+ return (
76
+ <svg width={width} height={height} style={style} className={className} {...props} />
77
+ );
78
+ }
79
+ } else {
80
+ return (
81
+ // <img
82
+ // src={require(`./assets/${type}.${fileType}`)}
83
+ // style={{ width, height, ...style }}
84
+ // />
85
+ <></>
86
+ );
87
+ }
88
+ });
89
+ export { VtxIcon }
90
+ export default VtxIcon;
@@ -28,15 +28,12 @@ var VIEWER = 'viewer';
28
28
  // 多张
29
29
  var GALLERY = 'gallery';
30
30
  function checkMode(x) {
31
- var mode = '';
32
- if ((0, _utils.isObject)(x)) {
33
- mode = VIEWER;
34
- }
35
31
  if (Array.isArray(x)) {
36
32
  var len = x.length;
37
- mode = len == 0 ? '' : len == 1 ? VIEWER : GALLERY;
33
+ if (len === 0) return null;
34
+ return len === 1 ? VIEWER : GALLERY;
38
35
  }
39
- return mode;
36
+ return (0, _utils.isObject)(x) ? VIEWER : null;
40
37
  }
41
38
  function Preview(props) {
42
39
  var _useState = (0, _react.useState)(),
@@ -93,6 +90,9 @@ function Preview(props) {
93
90
  setContainer(container);
94
91
  setViewer(viewer);
95
92
  return function () {
93
+ if (container) {
94
+ container.innerHTML = '';
95
+ }
96
96
  viewer && viewer.destroy();
97
97
  };
98
98
  }, []);
@@ -102,6 +102,7 @@ function Preview(props) {
102
102
  container.innerHTML = '';
103
103
  }
104
104
  var mode = checkMode(photo);
105
+ if (!mode) return null;
105
106
  var newIndex = index;
106
107
  // 单张
107
108
  if (mode === VIEWER) {
@@ -132,6 +133,10 @@ function Preview(props) {
132
133
  }
133
134
  viewer.update();
134
135
  viewer.view(newIndex);
136
+ } else {
137
+ if (container) {
138
+ container.innerHTML = '';
139
+ }
135
140
  }
136
141
  }, [visible]);
137
142
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {});
@@ -26,7 +26,6 @@ var center = function center() {
26
26
  };
27
27
  var genVtxImageStyle = function genVtxImageStyle(token) {
28
28
  var componentCls = token.componentCls;
29
- console.log('componentCls', componentCls);
30
29
  return _defineProperty(_defineProperty(_defineProperty({}, componentCls, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, '&-aspectFit', {
31
30
  position: 'relative',
32
31
  height: '100%',