@vtx/components 4.0.0-beta.9 → 4.0.0-beta.90

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 (188) 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 +6 -6
  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 +109 -140
  28. package/es/vtx-datagrid/ToolBar/components/ColumnSetting/index.js +7 -6
  29. package/es/vtx-datagrid/ToolBar/components/ColumnSetting/style.js +5 -2
  30. package/es/vtx-datagrid/ToolBar/index.js +2 -1
  31. package/es/vtx-datagrid/ToolBar/style.js +6 -3
  32. package/es/vtx-datagrid/columnState.js +91 -0
  33. package/es/vtx-datagrid/index.js +134 -37
  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 +108 -18
  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 +2 -2
  44. package/es/vtx-ellipsis-text/style/index.js +3 -1
  45. package/es/vtx-export/index.js +33 -38
  46. package/es/vtx-export-async/History.js +15 -7
  47. package/es/vtx-export-async/index.js +18 -8
  48. package/es/vtx-export-async/util.js +16 -5
  49. package/es/vtx-form-layout/FormItem.js +16 -16
  50. package/es/vtx-form-layout/style/index.js +6 -4
  51. package/es/vtx-icon/index.js +54 -45
  52. package/es/vtx-icon/index.js1 +90 -0
  53. package/es/vtx-image/style/index.js +0 -1
  54. package/es/vtx-import/index.js +143 -42
  55. package/es/vtx-import/result.js +28 -26
  56. package/es/vtx-import/style/index.js +16 -1
  57. package/es/vtx-import2/Content.js +2 -1
  58. package/es/vtx-import2/index.js +29 -19
  59. package/es/vtx-import2/style/index.js +59 -8
  60. package/es/vtx-modal/index.js +11 -6
  61. package/es/vtx-modal/style/index.js +5 -2
  62. package/es/vtx-page-layout/Basic.js +2 -2
  63. package/es/vtx-page-layout/TabLayout.js +6 -6
  64. package/es/vtx-page-layout/TableLayout.js +10 -10
  65. package/es/vtx-page-layout/TreeLayout.js +6 -6
  66. package/es/vtx-page-layout/container.js +2 -2
  67. package/es/vtx-page-layout/style/index.js +4 -2
  68. package/es/vtx-provider/index.js +33 -31
  69. package/es/vtx-provider/intl.js +9 -9
  70. package/es/vtx-provider/locale/en_GB.js +1 -1
  71. package/es/vtx-provider/locale/en_US.js +58 -4
  72. package/es/vtx-provider/locale/zh_CN.js +57 -3
  73. package/es/vtx-provider/useStyle/index.js +17 -17
  74. package/es/vtx-search/index.js +30 -12
  75. package/es/vtx-search/style/index.js +6 -3
  76. package/es/vtx-select/index.js +123 -40
  77. package/es/vtx-select/style/index.js +11 -56
  78. package/es/vtx-split-pane/Resizer.js +0 -1
  79. package/es/vtx-split-pane/SplitPane.js +42 -34
  80. package/es/vtx-split-pane/style/index.js +8 -112
  81. package/es/vtx-time-picker/index.js +27 -1
  82. package/es/vtx-transfer/Transfer.js +29 -0
  83. package/es/vtx-transfer/index.js +3 -0
  84. package/es/vtx-transfer/style/index.js +19 -0
  85. package/es/vtx-transfer-select/TransferSelect.js +143 -0
  86. package/es/vtx-transfer-select/index.js +3 -0
  87. package/es/vtx-transfer-select/style/index.js +19 -0
  88. package/es/vtx-tree/index.js +27 -9
  89. package/es/vtx-tree-select/index.js +81 -110
  90. package/es/vtx-tree-select/style/index.js +9 -3
  91. package/es/vtx-upload/FilePreview.js +2 -1
  92. package/es/vtx-wang-editor/index.js +41 -32
  93. package/es/vtx-wang-editor/style/index.less +12 -12
  94. package/lib/index.js +36 -0
  95. package/lib/utils/components/LabelIconTip/index.js +7 -7
  96. package/lib/utils/conversionMomentValue/index.js +25 -25
  97. package/lib/utils/filterSpecialCharacters.js +6 -6
  98. package/lib/utils/genCopyable/index.js +6 -6
  99. package/lib/utils/getFieldPropsOrFormItemProps/index.js +7 -7
  100. package/lib/utils/hooks/useDebounceFn/index.js +4 -4
  101. package/lib/utils/hooks/useDebounceValue/index.js +6 -6
  102. package/lib/utils/hooks/useDeepCompareMemo/index.js +7 -7
  103. package/lib/utils/hooks/useLatest/index.js +2 -2
  104. package/lib/utils/hooks/useRefCallback/index.js +5 -5
  105. package/lib/utils/index.js +0 -7
  106. package/lib/utils/isBrowser/index.js +7 -7
  107. package/lib/utils/isUrl/index.js +4 -4
  108. package/lib/utils/merge/index.js +4 -4
  109. package/lib/utils/nanoid/index.js +4 -4
  110. package/lib/utils/omitBoolean/index.js +4 -4
  111. package/lib/utils/parseValueToMoment/index.js +4 -4
  112. package/lib/utils/proFieldParsingText/index.js +10 -10
  113. package/lib/utils/transformKeySubmitValue/index.js +57 -57
  114. package/lib/utils/useEditableArray/index.js +46 -46
  115. package/lib/utils/useEditableMap/index.js +22 -22
  116. package/lib/utils/useMediaQuery/index.js +5 -5
  117. package/lib/vtx-combogrid/Combogrid.js +5 -4
  118. package/lib/vtx-combogrid/index.js +7 -4
  119. package/lib/vtx-datagrid/Store/Provide.js +112 -142
  120. package/lib/vtx-datagrid/ToolBar/components/ColumnSetting/index.js +7 -6
  121. package/lib/vtx-datagrid/ToolBar/components/ColumnSetting/style.js +5 -2
  122. package/lib/vtx-datagrid/ToolBar/index.js +2 -1
  123. package/lib/vtx-datagrid/ToolBar/style.js +6 -3
  124. package/lib/vtx-datagrid/columnState.js +100 -0
  125. package/lib/vtx-datagrid/index.js +134 -37
  126. package/lib/vtx-datagrid/mergeComponents.js +21 -0
  127. package/lib/vtx-datagrid/renderColumnButtons.js +30 -11
  128. package/lib/vtx-datagrid/style/index.js +108 -18
  129. package/lib/vtx-datagrid/style/index.less +242 -242
  130. package/lib/vtx-date-picker/QdatePicker.js +1 -1
  131. package/lib/vtx-date-picker/style/index.less +39 -39
  132. package/lib/vtx-descriptions/Descriptions.js +38 -0
  133. package/lib/vtx-descriptions/index.js +15 -0
  134. package/lib/vtx-descriptions/style/index.js +25 -0
  135. package/lib/vtx-ellipsis-text/index.js +2 -2
  136. package/lib/vtx-ellipsis-text/style/index.js +3 -1
  137. package/lib/vtx-export/index.js +34 -39
  138. package/lib/vtx-export-async/History.js +14 -8
  139. package/lib/vtx-export-async/index.js +18 -8
  140. package/lib/vtx-export-async/util.js +16 -5
  141. package/lib/vtx-form-layout/FormItem.js +16 -16
  142. package/lib/vtx-form-layout/style/index.js +6 -4
  143. package/lib/vtx-icon/index.js +54 -52
  144. package/lib/vtx-icon/index.js1 +90 -0
  145. package/lib/vtx-image/style/index.js +0 -1
  146. package/lib/vtx-import/index.js +141 -43
  147. package/lib/vtx-import/result.js +29 -27
  148. package/lib/vtx-import/style/index.js +16 -1
  149. package/lib/vtx-import2/Content.js +2 -1
  150. package/lib/vtx-import2/index.js +29 -19
  151. package/lib/vtx-import2/style/index.js +59 -8
  152. package/lib/vtx-modal/index.js +11 -6
  153. package/lib/vtx-modal/style/index.js +5 -2
  154. package/lib/vtx-page-layout/Basic.js +2 -2
  155. package/lib/vtx-page-layout/TabLayout.js +6 -6
  156. package/lib/vtx-page-layout/TableLayout.js +10 -10
  157. package/lib/vtx-page-layout/TreeLayout.js +6 -6
  158. package/lib/vtx-page-layout/container.js +2 -2
  159. package/lib/vtx-page-layout/style/index.js +4 -2
  160. package/lib/vtx-provider/index.js +33 -31
  161. package/lib/vtx-provider/intl.js +9 -9
  162. package/lib/vtx-provider/locale/en_GB.js +1 -1
  163. package/lib/vtx-provider/locale/en_US.js +58 -4
  164. package/lib/vtx-provider/locale/zh_CN.js +57 -3
  165. package/lib/vtx-provider/useStyle/index.js +17 -17
  166. package/lib/vtx-search/index.js +32 -12
  167. package/lib/vtx-search/style/index.js +6 -3
  168. package/lib/vtx-select/index.js +125 -42
  169. package/lib/vtx-select/style/index.js +11 -56
  170. package/lib/vtx-split-pane/Resizer.js +0 -1
  171. package/lib/vtx-split-pane/SplitPane.js +40 -31
  172. package/lib/vtx-split-pane/style/index.js +8 -112
  173. package/lib/vtx-time-picker/index.js +27 -1
  174. package/lib/vtx-transfer/Transfer.js +38 -0
  175. package/lib/vtx-transfer/index.js +15 -0
  176. package/lib/vtx-transfer/style/index.js +25 -0
  177. package/lib/vtx-transfer-select/TransferSelect.js +151 -0
  178. package/lib/vtx-transfer-select/index.js +15 -0
  179. package/lib/vtx-transfer-select/style/index.js +25 -0
  180. package/lib/vtx-tree/index.js +27 -9
  181. package/lib/vtx-tree-select/index.js +81 -112
  182. package/lib/vtx-tree-select/style/index.js +9 -3
  183. package/lib/vtx-upload/FilePreview.js +2 -1
  184. package/lib/vtx-wang-editor/index.js +39 -30
  185. package/lib/vtx-wang-editor/style/index.less +12 -12
  186. package/package.json +239 -238
  187. package/es/utils/hooks/useFetchData/index.js +0 -82
  188. package/lib/utils/hooks/useFetchData/index.js +0 -89
@@ -1,5 +1,6 @@
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 = ["type", "size", "className", "style", "color", "fileType"];
2
+ var _excluded = ["width", "height", "style", "className"],
3
+ _excluded2 = ["type", "size", "className", "style", "color", "fileType"];
3
4
  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; }
4
5
  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; }
5
6
  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; }
@@ -7,62 +8,70 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
7
8
  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); }
8
9
  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; }
9
10
  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; }
10
- import { lazy, memo, Suspense, useMemo } from 'react';
11
+ import { memo } from 'react';
12
+ import AlignRightOutlined from "./svg/alignRightOutlined.js";
13
+ import ColumnHeightOutlined from "./svg/columnHeightOutlined.js";
14
+ import DownOutlined from "./svg/downOutlined.js";
15
+ import Fullscreen from "./svg/fullscreen.js";
16
+ import RedoOutlined from "./svg/redoOutlined.js";
17
+ import RightOutlined from "./svg/rightOutlined.js";
18
+ import SettingOutlined from "./svg/settingOutlined.js";
11
19
  import { jsx as _jsx } from "react/jsx-runtime";
12
20
  import { Fragment as _Fragment } from "react/jsx-runtime";
13
- var VtxIcon = /*#__PURE__*/memo(function (_ref) {
14
- var type = _ref.type,
15
- _ref$size = _ref.size,
16
- size = _ref$size === void 0 ? 16 : _ref$size,
17
- _ref$className = _ref.className,
18
- className = _ref$className === void 0 ? '' : _ref$className,
19
- _ref$style = _ref.style,
20
- style = _ref$style === void 0 ? {} : _ref$style,
21
- color = _ref.color,
22
- _ref$fileType = _ref.fileType,
23
- fileType = _ref$fileType === void 0 ? 'webp' : _ref$fileType,
21
+ var iconComponents = {
22
+ alignRightOutlined: AlignRightOutlined,
23
+ columnHeightOutlined: ColumnHeightOutlined,
24
+ downOutlined: DownOutlined,
25
+ fullscreen: Fullscreen,
26
+ redoOutlined: RedoOutlined,
27
+ rightOutlined: RightOutlined,
28
+ settingOutlined: SettingOutlined
29
+ // 低频图标如果确实需要,可以再考虑 lazy
30
+ };
31
+ var EmptySvg = function EmptySvg(_ref) {
32
+ var width = _ref.width,
33
+ height = _ref.height,
34
+ style = _ref.style,
35
+ className = _ref.className,
24
36
  props = _objectWithoutProperties(_ref, _excluded);
37
+ return /*#__PURE__*/_jsx("svg", _objectSpread({
38
+ width: width,
39
+ height: height,
40
+ style: style,
41
+ className: className
42
+ }, props));
43
+ };
44
+ var VtxIcon = /*#__PURE__*/memo(function (_ref2) {
45
+ var type = _ref2.type,
46
+ _ref2$size = _ref2.size,
47
+ size = _ref2$size === void 0 ? 16 : _ref2$size,
48
+ _ref2$className = _ref2.className,
49
+ className = _ref2$className === void 0 ? '' : _ref2$className,
50
+ _ref2$style = _ref2.style,
51
+ style = _ref2$style === void 0 ? {} : _ref2$style,
52
+ color = _ref2.color,
53
+ _ref2$fileType = _ref2.fileType,
54
+ fileType = _ref2$fileType === void 0 ? 'webp' : _ref2$fileType,
55
+ props = _objectWithoutProperties(_ref2, _excluded2);
25
56
  var width = props.width || size;
26
57
  var height = props.height || size;
27
58
  if (!type) {
28
59
  return null;
29
60
  }
30
- var SvgComponent = useMemo(function () {
31
- // 动态导入并缓存结果
32
- return /*#__PURE__*/lazy(function () {
33
- return import( /* @vite-ignore */"./svg/".concat(type, ".js"));
34
- });
35
- }, [type]);
36
61
 
37
62
  // 默认返回空元素
38
63
  if (fileType == 'svg') {
39
- try {
40
- // const SvgComponent = lazy(() => import(`./svg/${type}.js`));
41
- return /*#__PURE__*/_jsx(Suspense, {
42
- fallback: /*#__PURE__*/_jsx("div", {
43
- style: _objectSpread({
44
- width: width,
45
- height: height
46
- }, style)
47
- }),
48
- children: /*#__PURE__*/_jsx(SvgComponent, _objectSpread({
49
- className: className,
50
- style: _objectSpread({
51
- width: width,
52
- height: height
53
- }, style),
54
- fill: color
55
- }, props))
56
- });
57
- } catch (error) {
58
- // 如果动态导入失败,返回空的 SVG 元素
59
- return /*#__PURE__*/_jsx("svg", _objectSpread({
64
+ var SvgComponent = iconComponents[type] || EmptySvg;
65
+ return /*#__PURE__*/_jsx(SvgComponent, _objectSpread({
66
+ className: className,
67
+ style: _objectSpread({
60
68
  width: width,
61
- height: height,
62
- style: style,
63
- className: className
64
- }, props));
65
- }
69
+ height: height
70
+ }, style),
71
+ width: width,
72
+ height: height,
73
+ fill: color
74
+ }, props));
66
75
  } else {
67
76
  return (
68
77
  /*#__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;
@@ -20,7 +20,6 @@ var center = function center() {
20
20
  };
21
21
  var genVtxImageStyle = function genVtxImageStyle(token) {
22
22
  var componentCls = token.componentCls;
23
- console.log('componentCls', componentCls);
24
23
  return _defineProperty(_defineProperty(_defineProperty({}, componentCls, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, '&-aspectFit', {
25
24
  position: 'relative',
26
25
  height: '100%',
@@ -1,30 +1,37 @@
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
- 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; }
3
- 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; }
4
- 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; }
5
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
- 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); }
7
2
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
3
  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."); }
9
4
  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); }
10
5
  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; }
11
6
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
7
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
- import React, { useRef, useEffect, useContext } from 'react';
14
- import { ConfigProvider, message, Button, Modal } from 'antd';
8
+ 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; }
9
+ 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; }
10
+ 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
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
+ 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); }
13
+ import { useContext, useEffect, useRef } from 'react';
14
+ import { getSignature, getVtxToken } from '@vtx/utils';
15
+ import { Button, Tooltip, message } from 'antd';
16
+ import md5 from 'md5';
15
17
  import PropTypes from 'prop-types';
18
+ import { useMemo } from 'react';
19
+ import getToken from "../utils/getToken";
16
20
  import useSet from "../utils/useSet";
21
+ import VtxModal from "../vtx-modal";
22
+ import { VtxProvider, useIntl } from "../vtx-provider";
17
23
  import VtxImportResult from "./result";
18
- import getToken from "../utils/getToken";
19
- var token = getToken();
20
- import md5 from 'md5';
21
- import { getVtxToken, getSignature } from '@vtx/utils';
22
- import classnames from 'classnames';
23
24
  import { useStyle } from "./style/index";
24
- import { VtxProvider, useIntl } from "../vtx-provider";
25
- import { jsx as _jsx } from "react/jsx-runtime";
26
25
  import { jsxs as _jsxs } from "react/jsx-runtime";
26
+ import { jsx as _jsx } from "react/jsx-runtime";
27
27
  function VtxImport(props) {
28
+ var templateURL = props.templateURL,
29
+ uploadURL = props.uploadURL,
30
+ afterUpload = props.afterUpload,
31
+ beforeUpload = props.beforeUpload;
32
+ var token = useMemo(function () {
33
+ return props.token || getToken();
34
+ }, [props.token]);
28
35
  var intl = useIntl();
29
36
  var _useContext = useContext(VtxProvider),
30
37
  getPrefixCls = _useContext.getPrefixCls;
@@ -32,6 +39,22 @@ function VtxImport(props) {
32
39
  var _useStyle = useStyle(prefixCls),
33
40
  wrapSSR = _useStyle.wrapSSR,
34
41
  hashId = _useStyle.hashId;
42
+ var TextEnum = _objectSpread({
43
+ rowNumberText: intl.getMessage('import.rowNumber', '行号'),
44
+ errorMessageText: intl.getMessage('import.errorMessage', '错误说明'),
45
+ resultTitleText: intl.getMessage('import.result', '导入结果'),
46
+ btnCloseText: intl.getMessage('switch.close', '关闭'),
47
+ operationText: intl.getMessage('import.operation', '导入'),
48
+ uploadFailedText: intl.getMessage('import.error', '上传失败'),
49
+ parseResponseFailedText: intl.getMessage('import.error', '解析响应失败'),
50
+ uploadSuccessText: intl.getMessage('import.success', '上传成功'),
51
+ parseResponseDataFailedText: intl.getMessage('import.error', '解析响应数据失败'),
52
+ downloadTemplateText: intl.getMessage('import.downloadTemplate', '下载模板'),
53
+ pleaseSelectFileText: intl.getMessage('import.pleaseSelectFile', '请选择需要上传的文件'),
54
+ uploadText: intl.getMessage('import.upload', '上传'),
55
+ selectFileText: intl.getMessage('import.selectFile', '选择文件'),
56
+ noFileSelectedText: intl.getMessage('import.noFileSelected', '未选择任何文件')
57
+ }, props.customEnumText);
35
58
 
36
59
  // 用 useRef 管理 DOM 引用,而不是 state
37
60
  var fileInputRef = useRef(null);
@@ -58,13 +81,22 @@ function VtxImport(props) {
58
81
  // 导入结果查看
59
82
  modalWidth: props.modalWidth || 800,
60
83
  columns: props.columns || [{
61
- title: '行号',
84
+ title: TextEnum.rowNumberText,
62
85
  dataIndex: 'lineNum',
63
86
  key: 'lineNum'
64
87
  }, {
65
- title: '错误说明',
88
+ title: TextEnum.errorMessageText,
66
89
  dataIndex: 'messages',
67
- key: 'messages'
90
+ key: 'messages',
91
+ render: function render(val) {
92
+ return /*#__PURE__*/_jsxs("div", {
93
+ style: {
94
+ display: 'flex',
95
+ width: 600
96
+ },
97
+ children: [" ", val]
98
+ });
99
+ }
68
100
  }],
69
101
  step: 1,
70
102
  chunkSize: props.chunkSize || 10 * 1024 * 1024,
@@ -72,7 +104,8 @@ function VtxImport(props) {
72
104
  currentIndex: 0,
73
105
  chunkId: '',
74
106
  chunks: [],
75
- operation: props.operation || intl.getMessage('import.operation', '导入')
107
+ operation: props.operation || TextEnum.operationText,
108
+ fileName: ''
76
109
  }),
77
110
  _useSet2 = _slicedToArray(_useSet, 2),
78
111
  state = _useSet2[0],
@@ -128,10 +161,12 @@ function VtxImport(props) {
128
161
  }
129
162
  };
130
163
  xhr.onerror = function () {
131
- message.error(intl.getMessage('import.error', '上传失败'));
164
+ message.error(TextEnum.uploadFailedText);
132
165
  };
133
166
  // 发送请求
134
167
  xhr.open('POST', '/cloudFile/common/uploadChunk', true);
168
+ xhr.setRequestHeader('Authorization', token ? "Bearer ".concat(token) : '');
169
+ xhr.setRequestHeader('access_token', token ? "".concat(token) : '');
135
170
  xhr.send(list[indexRef.current]);
136
171
  } else {
137
172
  mergeFile();
@@ -150,26 +185,28 @@ function VtxImport(props) {
150
185
  try {
151
186
  res = JSON.parse(xhr.responseText);
152
187
  } catch (e) {
153
- message.error(intl.getMessage('import.error', '解析响应失败'));
188
+ message.error(TextEnum.parseResponseFailedText);
154
189
  setState({
155
190
  uploading: false
156
191
  });
157
192
  return;
158
193
  }
159
194
  if (((_res = res) === null || _res === void 0 ? void 0 : _res.result) == 0) {
160
- message.success(intl.getMessage('import.success', '上传成功'));
195
+ message.success(TextEnum.uploadSuccessText);
161
196
  chunkUpload(res.data);
162
197
  } else {
163
198
  var _res2;
164
- message.error(((_res2 = res) === null || _res2 === void 0 ? void 0 : _res2.msg) || intl.getMessage('import.error', '上传失败'));
199
+ message.error(((_res2 = res) === null || _res2 === void 0 ? void 0 : _res2.msg) || TextEnum.uploadFailedText);
165
200
  }
166
201
  }
167
202
  };
168
203
  xhr.onerror = function () {
169
- message.error(intl.getMessage('import.error', '上传失败'));
204
+ message.error(TextEnum.uploadFailedText);
170
205
  };
171
206
  // 发送请求
172
207
  xhr.open('POST', '/cloudFile/common/mergeChunk', true);
208
+ xhr.setRequestHeader('Authorization', token ? "Bearer ".concat(token) : '');
209
+ xhr.setRequestHeader('access_token', token ? "".concat(token) : '');
173
210
  var data = new FormData();
174
211
  data.append('chunkId', state.chunkId);
175
212
  data.append('tenantId', getVtxToken('tenantId'));
@@ -291,7 +328,7 @@ function VtxImport(props) {
291
328
  try {
292
329
  parseData = JSON.parse(data);
293
330
  } catch (e) {
294
- message.error(intl.getMessage('import.error', '解析响应数据失败'));
331
+ message.error(TextEnum.parseResponseDataFailedText);
295
332
  return;
296
333
  }
297
334
  if (typeof props.afterUpload === 'function') {
@@ -313,27 +350,26 @@ function VtxImport(props) {
313
350
  // 新增其他错误提示
314
351
  if (parseData.result !== 0) {
315
352
  var _parseData2;
316
- message.error(((_parseData2 = parseData) === null || _parseData2 === void 0 ? void 0 : _parseData2.msg) || intl.getMessage('import.success', '上传成功'));
353
+ message.error(((_parseData2 = parseData) === null || _parseData2 === void 0 ? void 0 : _parseData2.msg) || TextEnum.uploadSuccessText);
317
354
  }
318
355
  }
319
356
  };
320
- var templateURL = props.templateURL,
321
- uploadURL = props.uploadURL,
322
- afterUpload = props.afterUpload,
323
- beforeUpload = props.beforeUpload;
324
357
  var modalProps = {
325
358
  className: "".concat(prefixCls, "-modal"),
326
359
  open: state.visible,
327
- title: intl.getMessage('import.operation', '导入'),
360
+ title: TextEnum.operationText,
328
361
  onCancel: function onCancel() {
329
362
  return closeModal();
330
363
  },
331
- maskClosable: false,
364
+ // maskClosable: false,
365
+ mask: {
366
+ closable: false
367
+ },
332
368
  footer: [templateURL ? /*#__PURE__*/_jsx(Button, {
333
369
  onClick: function onClick() {
334
370
  window.open(templateURL);
335
371
  },
336
- children: intl.getMessage('import.downloadTemplate', '下载模板')
372
+ children: TextEnum.downloadTemplateText
337
373
  }, "downloadTemple") : null, /*#__PURE__*/_jsx(Button, {
338
374
  type: "primary",
339
375
  loading: state.uploading,
@@ -372,16 +408,17 @@ function VtxImport(props) {
372
408
  // request.send(fmd);
373
409
  // }
374
410
  } else {
375
- message.info(intl.getMessage('import.pleaseSelectFile', '请选择需要上传的文件'));
411
+ message.info(TextEnum.pleaseSelectFileText);
376
412
  }
377
413
  },
378
- children: intl.getMessage('import.upload', '上传')
414
+ children: TextEnum.uploadText
379
415
  }, "uploadSubmit"), /*#__PURE__*/_jsx(Button, {
380
416
  onClick: function onClick() {
381
417
  closeModal();
382
418
  },
383
- children: intl.getMessage('switch.close', '关闭')
384
- }, "closeWindow")]
419
+ children: TextEnum.btnCloseText
420
+ }, "closeWindow")],
421
+ width: 520
385
422
  };
386
423
  var resultProps = {
387
424
  visible: state.resultVisible,
@@ -392,7 +429,8 @@ function VtxImport(props) {
392
429
  resultVisible: false
393
430
  });
394
431
  },
395
- modalWidth: state.modalWidth
432
+ modalWidth: state.modalWidth,
433
+ TextEnum: TextEnum
396
434
  };
397
435
 
398
436
  // 组件卸载时清理
@@ -414,19 +452,80 @@ function VtxImport(props) {
414
452
  startUpload();
415
453
  }
416
454
  }, [state.chunkId]);
417
- return wrapSSR( /*#__PURE__*/_jsxs(Modal, _objectSpread(_objectSpread({}, modalProps), {}, {
418
- children: [props.children, /*#__PURE__*/_jsx("form", {
455
+ var truncateFileName = function truncateFileName(fileName) {
456
+ var maxLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 28;
457
+ if (fileName.length <= maxLength) return fileName;
458
+ var extIndex = fileName.lastIndexOf('.');
459
+ var ext = extIndex !== -1 ? fileName.slice(extIndex) : '';
460
+ var name = extIndex !== -1 ? fileName.slice(0, extIndex) : fileName;
461
+ var availableLength = maxLength - ext.length - 3; // 3 是 "..."
462
+ if (availableLength <= 0) return "...".concat(ext);
463
+ var startLength = Math.ceil(availableLength / 2);
464
+ var endLength = Math.floor(availableLength / 2);
465
+ var start = name.slice(0, startLength);
466
+ var end = name.slice(-endLength);
467
+ return "".concat(start, "...").concat(end).concat(ext);
468
+ };
469
+
470
+ // 处理文件选择变化
471
+ var handleFileChange = function handleFileChange(event) {
472
+ var _event$target$files;
473
+ var file = (_event$target$files = event.target.files) === null || _event$target$files === void 0 ? void 0 : _event$target$files[0];
474
+ if (file) {
475
+ setState(function (prev) {
476
+ return _objectSpread(_objectSpread({}, prev), {}, {
477
+ fileName: truncateFileName(file.name)
478
+ });
479
+ });
480
+ // 这里可以添加文件上传或其他处理逻辑
481
+ // 例如:uploadFile(file);
482
+ } else {
483
+ setState(function (prev) {
484
+ return _objectSpread(_objectSpread({}, prev), {}, {
485
+ fileName: ''
486
+ });
487
+ });
488
+ }
489
+ };
490
+ var handleSelectFile = function handleSelectFile() {
491
+ var _fileInputRef$current3;
492
+ (_fileInputRef$current3 = fileInputRef.current) === null || _fileInputRef$current3 === void 0 || _fileInputRef$current3.click();
493
+ };
494
+ return wrapSSR( /*#__PURE__*/_jsxs(VtxModal, _objectSpread(_objectSpread({}, modalProps), {}, {
495
+ children: [props.children, /*#__PURE__*/_jsxs("form", {
419
496
  encType: "multipart/form-data",
420
497
  method: "post",
421
498
  target: "tmp",
422
499
  action: uploadURL,
423
500
  ref: formRef,
424
- children: /*#__PURE__*/_jsx("input", {
501
+ children: [/*#__PURE__*/_jsxs("div", {
502
+ className: "".concat(prefixCls, "-btn"),
503
+ children: [/*#__PURE__*/_jsx(Button, {
504
+ onClick: handleSelectFile,
505
+ children: /*#__PURE__*/_jsx("span", {
506
+ className: "".concat(prefixCls, "-label"),
507
+ children: TextEnum.selectFileText
508
+ })
509
+ }), state.fileName ? /*#__PURE__*/_jsx(Tooltip, {
510
+ title: state.fileName,
511
+ children: /*#__PURE__*/_jsx("div", {
512
+ className: "".concat(prefixCls, "-file-name"),
513
+ children: state.fileName
514
+ })
515
+ }) : /*#__PURE__*/_jsx("div", {
516
+ className: "".concat(prefixCls, "-file-name"),
517
+ children: TextEnum.noFileSelectedText
518
+ })]
519
+ }), /*#__PURE__*/_jsx("input", {
425
520
  type: "file",
426
521
  name: state.fileKey,
427
522
  accept: state.accept,
428
- ref: fileInputRef
429
- })
523
+ ref: fileInputRef,
524
+ style: {
525
+ display: 'none'
526
+ },
527
+ onChange: handleFileChange
528
+ })]
430
529
  }), /*#__PURE__*/_jsx("iframe", {
431
530
  name: "tmp",
432
531
  style: {
@@ -443,11 +542,13 @@ VtxImport.propTypes = {
443
542
  postData: PropTypes.object,
444
543
  fileKey: PropTypes.string,
445
544
  accept: PropTypes.string,
545
+ token: PropTypes.string,
446
546
  operation: PropTypes.string,
447
547
  close: PropTypes.func,
448
548
  afterUpload: PropTypes.func,
449
549
  modalWidth: PropTypes.number,
450
550
  columns: PropTypes.array,
551
+ customEnumText: PropTypes.object,
451
552
  children: PropTypes.object,
452
553
  beforeUpload: PropTypes.func,
453
554
  chunkSize: PropTypes.number