@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.
Files changed (91) hide show
  1. package/es/utils/filterSpecialCharacters.js +47 -46
  2. package/es/vtx-color-picker/index.js +138 -33
  3. package/es/vtx-color-picker/style/index.js +36 -12
  4. package/es/vtx-combogrid/Combogrid.js +11 -6
  5. package/es/vtx-combogrid/style/index.js +4 -4
  6. package/es/vtx-datagrid/Store/Provide.js +5 -4
  7. package/es/vtx-datagrid/ToolBar/components/ColumnSetting/index.js +8 -3
  8. package/es/vtx-datagrid/ToolBar/components/Density/index.js +3 -0
  9. package/es/vtx-datagrid/ToolBar/components/TableStyle/index.js +3 -0
  10. package/es/vtx-datagrid/ToolBar/index.js +2 -2
  11. package/es/vtx-datagrid/index.js +14 -9
  12. package/es/vtx-datagrid/style/index.js +2 -2
  13. package/es/vtx-ellipsis-text/index.js +6 -1
  14. package/es/vtx-export/index.js +5 -0
  15. package/es/vtx-export-async/index.js +28 -8
  16. package/es/vtx-form-layout/Card.js +10 -10
  17. package/es/vtx-form-layout/Divider.js +1 -1
  18. package/es/vtx-form-layout/FormItem.js +2 -1
  19. package/es/vtx-form-layout/Pane.js +23 -12
  20. package/es/vtx-image/Preview.js +11 -6
  21. package/es/vtx-import/index.js +73 -33
  22. package/es/vtx-import2/index.js +2 -1
  23. package/es/vtx-import2/style/index.js +1 -1
  24. package/es/vtx-input/TextArea/index.js +11 -6
  25. package/es/vtx-modal/style/index.js +5 -3
  26. package/es/vtx-page-layout/Content.js +1 -1
  27. package/es/vtx-page-layout/TabLayout.js +1 -7
  28. package/es/vtx-page-layout/TableLayout.js +14 -4
  29. package/es/vtx-page-layout/TableWrap.js +3 -2
  30. package/es/vtx-page-layout/TreeLayout.js +2 -8
  31. package/es/vtx-page-layout/container.js +6 -5
  32. package/es/vtx-provider/index.js +18 -10
  33. package/es/vtx-provider/locale/en_US.js +10 -2
  34. package/es/vtx-provider/locale/zh_CN.js +20 -2
  35. package/es/vtx-provider/useStyle/index.js +8 -4
  36. package/es/vtx-scrollable-row/index.js +38 -28
  37. package/es/vtx-search/index.js +5 -4
  38. package/es/vtx-search/style/index.js +2 -1
  39. package/es/vtx-select/index.js +25 -11
  40. package/es/vtx-signature/index.js +5 -4
  41. package/es/vtx-signature/style/index.js +1 -1
  42. package/es/vtx-tree/index.js +80 -34
  43. package/es/vtx-tree-select/index.js +4 -0
  44. package/es/vtx-wang-editor/index.js +278 -108
  45. package/es/vtx-wang-editor/wangEditorUtil.js +59 -9
  46. package/lib/utils/filterSpecialCharacters.js +48 -46
  47. package/lib/vtx-color-picker/index.js +139 -34
  48. package/lib/vtx-color-picker/style/index.js +36 -12
  49. package/lib/vtx-combogrid/Combogrid.js +11 -6
  50. package/lib/vtx-combogrid/style/index.js +4 -4
  51. package/lib/vtx-datagrid/Store/Provide.js +5 -4
  52. package/lib/vtx-datagrid/ToolBar/components/ColumnSetting/index.js +8 -4
  53. package/lib/vtx-datagrid/ToolBar/components/Density/index.js +3 -0
  54. package/lib/vtx-datagrid/ToolBar/components/TableStyle/index.js +3 -0
  55. package/lib/vtx-datagrid/ToolBar/index.js +2 -2
  56. package/lib/vtx-datagrid/index.js +15 -9
  57. package/lib/vtx-datagrid/style/index.js +2 -2
  58. package/lib/vtx-ellipsis-text/index.js +6 -1
  59. package/lib/vtx-export/index.js +5 -0
  60. package/lib/vtx-export-async/index.js +26 -6
  61. package/lib/vtx-form-layout/Card.js +9 -9
  62. package/lib/vtx-form-layout/Divider.js +1 -1
  63. package/lib/vtx-form-layout/FormItem.js +2 -1
  64. package/lib/vtx-form-layout/Pane.js +22 -11
  65. package/lib/vtx-image/Preview.js +11 -6
  66. package/lib/vtx-import/index.js +73 -33
  67. package/lib/vtx-import2/index.js +2 -1
  68. package/lib/vtx-import2/style/index.js +1 -1
  69. package/lib/vtx-input/TextArea/index.js +11 -6
  70. package/lib/vtx-modal/style/index.js +5 -3
  71. package/lib/vtx-page-layout/Content.js +1 -1
  72. package/lib/vtx-page-layout/TabLayout.js +3 -9
  73. package/lib/vtx-page-layout/TableLayout.js +14 -4
  74. package/lib/vtx-page-layout/TableWrap.js +3 -2
  75. package/lib/vtx-page-layout/TreeLayout.js +4 -10
  76. package/lib/vtx-page-layout/container.js +6 -5
  77. package/lib/vtx-provider/index.js +17 -10
  78. package/lib/vtx-provider/locale/en_US.js +10 -2
  79. package/lib/vtx-provider/locale/zh_CN.js +20 -2
  80. package/lib/vtx-provider/useStyle/index.js +8 -4
  81. package/lib/vtx-scrollable-row/index.js +38 -28
  82. package/lib/vtx-search/index.js +5 -4
  83. package/lib/vtx-search/style/index.js +2 -1
  84. package/lib/vtx-select/index.js +25 -11
  85. package/lib/vtx-signature/index.js +4 -3
  86. package/lib/vtx-signature/style/index.js +1 -1
  87. package/lib/vtx-tree/index.js +78 -32
  88. package/lib/vtx-tree-select/index.js +4 -0
  89. package/lib/vtx-wang-editor/index.js +277 -109
  90. package/lib/vtx-wang-editor/wangEditorUtil.js +59 -10
  91. package/package.json +38 -23
@@ -124,15 +124,25 @@ Content.propTypes = {
124
124
  */
125
125
  var Table = function Table(props) {
126
126
  var className = props.className,
127
- style = props.style;
127
+ style = props.style,
128
+ children = props.children;
128
129
  var _useContext3 = useContext(StoreCtx),
129
130
  searchCollapseEvent$ = _useContext3.searchCollapseEvent$;
131
+
132
+ // 安全检查:如果不是有效的 React 元素,直接渲染不注入 props
133
+ if (! /*#__PURE__*/React.isValidElement(children)) {
134
+ return /*#__PURE__*/_jsx("div", {
135
+ className: classsnames('vtx-page-table-wrap', className),
136
+ style: style,
137
+ children: children
138
+ });
139
+ }
130
140
  return /*#__PURE__*/_jsx("div", {
131
- className: classsnames('vtx-page-table-wrap', className ? className : ''),
141
+ className: classsnames('vtx-page-table-wrap', className),
132
142
  style: style,
133
- children: /*#__PURE__*/React.cloneElement(props.children, _objectSpread(_objectSpread({}, props.children.props), {}, {
143
+ children: /*#__PURE__*/React.cloneElement(children, {
134
144
  searchCollapseEvent$: searchCollapseEvent$
135
- }))
145
+ })
136
146
  });
137
147
  };
138
148
  Table.propTypes = {
@@ -12,7 +12,8 @@ function TableWrap(props) {
12
12
  var relative = props.relative,
13
13
  height = props.height,
14
14
  style = props.style,
15
- className = props.className;
15
+ className = props.className,
16
+ children = props.children;
16
17
  var tableClass = classnames(_defineProperty(_defineProperty({}, 'vtx-table-wrapper-absolute', !relative), 'vtx-table-wrapper-relative', relative), className);
17
18
  var newStyle = style;
18
19
  if (relative && 'height' in props) {
@@ -23,7 +24,7 @@ function TableWrap(props) {
23
24
  return /*#__PURE__*/_jsx("div", {
24
25
  className: tableClass,
25
26
  style: newStyle,
26
- children: props.children
27
+ children: children
27
28
  });
28
29
  }
29
30
  export default TableWrap;
@@ -1,9 +1,3 @@
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
1
  import classsnames from 'classnames';
8
2
  import PropTypes from 'prop-types';
9
3
  import { useContext } from 'react';
@@ -49,7 +43,7 @@ var Content = function Content(props) {
49
43
  hashId = _useStyle2.hashId;
50
44
  return wrapSSR( /*#__PURE__*/_jsx("div", {
51
45
  className: classsnames("".concat(prefix, "-tree-content"), className, hashId),
52
- style: _objectSpread({}, style),
46
+ style: style,
53
47
  children: props.children
54
48
  }));
55
49
  };
@@ -62,7 +56,7 @@ var Tree = function Tree(props) {
62
56
  var className = props.className,
63
57
  style = props.style;
64
58
  return /*#__PURE__*/_jsx("div", {
65
- className: classsnames('vtx-page-tree-wrap', className ? className : ''),
59
+ className: classsnames('vtx-page-tree-wrap', className),
66
60
  style: style,
67
61
  children: props.children
68
62
  });
@@ -44,11 +44,12 @@ function Container() {
44
44
  className = _this$props.className,
45
45
  top = _this$props.top,
46
46
  space = _this$props.space;
47
- var wrapClass = classnames(_defineProperty({}, componentClass, true), className);
48
- var newStyle = _objectSpread({
49
- top: top,
47
+ var wrapClass = classnames(_defineProperty({}, componentClass, !!componentClass), className);
48
+ var newStyle = _objectSpread(_objectSpread(_objectSpread({}, top !== undefined && {
49
+ top: top
50
+ }), space !== undefined && {
50
51
  padding: space
51
- }, style);
52
+ }), style);
52
53
  var newProps = {
53
54
  className: wrapClass,
54
55
  style: newStyle
@@ -59,7 +60,7 @@ function Container() {
59
60
  return HOC;
60
61
  }(React.Component), _defineProperty(_class, "displayName", "HOC(".concat(getDisplayName(WrappedComponend), ")")), _defineProperty(_class, "propTypes", {
61
62
  top: PropTypes.number,
62
- space: PropTypes.number || PropTypes.string,
63
+ space: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
63
64
  style: PropTypes.object,
64
65
  className: PropTypes.string
65
66
  }), _class;
@@ -31,6 +31,8 @@ import { Fragment as _Fragment } from "react/jsx-runtime";
31
31
  import { jsxs as _jsxs } from "react/jsx-runtime";
32
32
  export * from "./intl";
33
33
  export * from "./useStyle";
34
+
35
+ // 调接口前剔除无效字段,节省流量
34
36
  var omitUndefined = function omitUndefined(obj) {
35
37
  var newObj = {};
36
38
  Object.keys(obj || {}).forEach(function (key) {
@@ -67,7 +69,7 @@ export var VtxConfigContext = /*#__PURE__*/React.createContext({
67
69
  hashed: true,
68
70
  dark: false,
69
71
  token: _objectSpread(_objectSpread({}, antdTheme.getDesignToken()), {}, {
70
- proComponentsCls: '.ant-pro',
72
+ vtxComponentsCls: '.vtx',
71
73
  antCls: '.ant',
72
74
  themeId: 0
73
75
  }),
@@ -128,9 +130,9 @@ var ConfigProviderContainer = function ConfigProviderContainer(props) {
128
130
  * @example .ant-pro
129
131
  */
130
132
 
131
- var proComponentsCls = prefixCls ? ".".concat(prefixCls) : ".".concat(getPrefixCls(), "-pro");
133
+ var vtxComponentsCls = prefixCls ? ".".concat(prefixCls) : ".vtx";
132
134
  var antCls = '.' + getPrefixCls();
133
- var salt = "".concat(proComponentsCls);
135
+ var salt = "".concat(vtxComponentsCls);
134
136
  /**
135
137
  * 合并一下token,不然导致嵌套 token 失效
136
138
  */
@@ -141,21 +143,22 @@ var ConfigProviderContainer = function ConfigProviderContainer(props) {
141
143
  var _proProvide$intl;
142
144
  var localeName = locale === null || locale === void 0 ? void 0 : locale.locale;
143
145
  var key = findIntlKeyByAntdLocaleKey(localeName);
146
+
144
147
  // antd 的 key 存在的时候以 antd 的为主
145
148
  var resolvedIntl = intl !== null && intl !== void 0 ? intl : localeName && ((_proProvide$intl = proProvide.intl) === null || _proProvide$intl === void 0 ? void 0 : _proProvide$intl.locale) === 'default' ? intlMap[key] : proProvide.intl || intlMap[key];
146
149
  return _objectSpread(_objectSpread({}, proProvide), {}, {
147
150
  dark: dark !== null && dark !== void 0 ? dark : proProvide.dark,
148
151
  token: merge(proProvide.token, tokenContext.token, {
149
- proComponentsCls: proComponentsCls,
152
+ vtxComponentsCls: vtxComponentsCls,
150
153
  antCls: antCls,
151
154
  themeId: tokenContext.theme.id,
152
155
  layout: proLayoutTokenMerge
153
156
  }),
154
157
  intl: resolvedIntl || zhCNIntl
155
158
  });
156
- }, [locale === null || locale === void 0 ? void 0 : locale.locale, proProvide, dark, tokenContext.token, tokenContext.theme.id, proComponentsCls, antCls, proLayoutTokenMerge, intl]);
159
+ }, [locale === null || locale === void 0 ? void 0 : locale.locale, proProvide, dark, tokenContext.token, tokenContext.theme.id, antCls, proLayoutTokenMerge, intl]);
157
160
  var finalToken = _objectSpread(_objectSpread({}, proProvideValue.token || {}), {}, {
158
- proComponentsCls: proComponentsCls
161
+ vtxComponentsCls: vtxComponentsCls
159
162
  });
160
163
  var _useCacheToken = useCacheToken(tokenContext.theme, [tokenContext.token, finalToken !== null && finalToken !== void 0 ? finalToken : {}], {
161
164
  salt: salt,
@@ -234,7 +237,7 @@ var ConfigProviderContainer = function ConfigProviderContainer(props) {
234
237
  * @returns
235
238
  */
236
239
  export var VtxConfigProvider = function VtxConfigProvider(props) {
237
- var _theme$components;
240
+ var _theme$components, _theme$components2;
238
241
  var propsTheme = props.theme,
239
242
  propsLocale = props.locale,
240
243
  needDeps = props.needDeps,
@@ -261,18 +264,23 @@ export var VtxConfigProvider = function VtxConfigProvider(props) {
261
264
  borderRadius: 8,
262
265
  borderRadiusLG: 12,
263
266
  borderRadiusSM: 4
264
- }, dark ? {} : _defineProperty(_defineProperty(_defineProperty(_defineProperty({
267
+ }, dark ? {
268
+ colorBgLayoutTable: '#111'
269
+ } : _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
265
270
  colorPrimary: '#3A6DFF',
266
271
  colorText: '#29343D',
267
272
  colorTextSecondary: '#78829D',
268
273
  colorBorder: '#DCDFE6',
269
274
  colorTextPlaceholder: '#BFC3CB',
270
275
  colorFillAlter: '#F5F7FA'
271
- }, "colorFillAlter", '#F5F7FA'), "colorTextPlaceholder", '#BFC3CB'), "colorFillAlterSolid", '#F5F7FA'), "colorBgLayout", '#FAFAFA')), theme.token);
276
+ }, "colorFillAlter", '#F5F7FA'), "colorTextPlaceholder", '#BFC3CB'), "colorFillAlterSolid", '#F5F7FA'), "colorBgLayout", '#F0F2F5'), "colorBgLayoutTable", '#FAFAFA')), theme.token);
272
277
  theme.components = _objectSpread(_objectSpread({}, theme.components), {}, {
273
278
  Table: _objectSpread({
274
279
  headerBorderRadius: 0
275
- }, (_theme$components = theme.components) === null || _theme$components === void 0 ? void 0 : _theme$components.Table)
280
+ }, (_theme$components = theme.components) === null || _theme$components === void 0 ? void 0 : _theme$components.Table),
281
+ Modal: _objectSpread({
282
+ contentPadding: 0
283
+ }, (_theme$components2 = theme.components) === null || _theme$components2 === void 0 ? void 0 : _theme$components2.Modal)
276
284
  });
277
285
 
278
286
  // 自动注入 antd 的配置
@@ -42,6 +42,7 @@ export default {
42
42
  noFixedTitle: 'Not Fixed',
43
43
  reset: 'Reset',
44
44
  columnDisplay: 'Column Display',
45
+ columnAll: 'All',
45
46
  columnSetting: 'Table Settings',
46
47
  fullScreen: 'Full Screen',
47
48
  exitFullScreen: 'Exit Full Screen',
@@ -50,7 +51,12 @@ export default {
50
51
  densityDefault: 'Default',
51
52
  densityLarger: 'Larger',
52
53
  densityMiddle: 'Middle',
53
- densitySmall: 'Compact'
54
+ densitySmall: 'Compact',
55
+ messageWarningOneText: 'Please select at least one column to save',
56
+ messageSuccessText: 'Operation successful',
57
+ striped: 'Striped',
58
+ border: 'Border',
59
+ headerBackground: 'Header Background'
54
60
  },
55
61
  stepsForm: {
56
62
  next: 'Next',
@@ -142,7 +148,9 @@ export default {
142
148
  delete: 'Delete',
143
149
  add: 'Add',
144
150
  import: 'Import',
145
- export: 'Export'
151
+ export: 'Export',
152
+ queryResults: 'Query results',
153
+ deleteConfirm: 'Are you sure you want to delete'
146
154
  },
147
155
  select: {
148
156
  selectAll: 'Select All',
@@ -53,7 +53,10 @@ export default {
53
53
  densityMiddle: '中等',
54
54
  densitySmall: '紧凑',
55
55
  messageWarningOneText: '至少勾选一列保存',
56
- messageSuccessText: '操作成功'
56
+ messageSuccessText: '操作成功',
57
+ striped: '斑马纹',
58
+ border: '边框',
59
+ headerBackground: '表头背景'
57
60
  },
58
61
  stepsForm: {
59
62
  next: '下一步',
@@ -144,7 +147,9 @@ export default {
144
147
  delete: '删除',
145
148
  add: '新增',
146
149
  import: '导入',
147
- export: '导出'
150
+ export: '导出',
151
+ queryResults: '查询结果',
152
+ deleteConfirm: '是否确认删除'
148
153
  },
149
154
  select: {
150
155
  selectAll: '全选',
@@ -179,5 +184,18 @@ export default {
179
184
  imageInsertionFailed: '插入图片失败',
180
185
  videoInsertionFailed: '插入视频失败',
181
186
  attachmentInsertionFailed: '插入附件失败'
187
+ },
188
+ colorPicker: {
189
+ primary: '主要',
190
+ // 主色调
191
+ danger: '红色',
192
+ // 危险/错误
193
+ success: '绿色',
194
+ // 成功
195
+ info: '青色',
196
+ // 信息/提示
197
+ basic: '基础颜色',
198
+ // 基础色板
199
+ chart: '图表颜色' // 图表专用色
182
200
  }
183
201
  };
@@ -9,7 +9,6 @@ import { TinyColor } from '@ctrl/tinycolor';
9
9
  import { ConfigProvider as AntdConfigProvider, theme as antdTheme } from 'antd';
10
10
  import { useContext } from 'react';
11
11
  import { VtxProvider } from "../index";
12
- import { merge } from "../utils/merge";
13
12
 
14
13
  /**
15
14
  * 把一个颜色设置一下透明度
@@ -69,7 +68,7 @@ export var operationUnit = function operationUnit(token) {
69
68
  * @returns UseStyleResult
70
69
  */
71
70
  export function useStyle(componentName, styleFn) {
72
- var _token$proComponentsC;
71
+ var _token$vtxComponentsC;
73
72
  // eslint-disable-next-line prefer-const
74
73
  var _useContext = useContext(VtxProvider),
75
74
  _useContext$token = _useContext.token,
@@ -87,8 +86,13 @@ export function useStyle(componentName, styleFn) {
87
86
  if (!token.layout) {
88
87
  token = _objectSpread({}, antdToken);
89
88
  }
90
- token.proComponentsCls = (_token$proComponentsC = token.proComponentsCls) !== null && _token$proComponentsC !== void 0 ? _token$proComponentsC : ".".concat(getPrefixCls('pro'));
89
+ token.vtxComponentsCls = (_token$vtxComponentsC = token.vtxComponentsCls) !== null && _token$vtxComponentsC !== void 0 ? _token$vtxComponentsC : ".vtx";
91
90
  token.antCls = ".".concat(getPrefixCls());
91
+ // wrapSSR 样式注入器 支持 SSR
92
+ // useStyleRegister 生成注入器的工厂
93
+ // nonce CSP 通行证 把生成的 <style> 标签加上 nonce="xxx",防止内联样式被 CSP 拦截
94
+ // path 缓存键 相同 path 就复用已编译的 CSS,避免重复生成样式
95
+ // layer @layer 名称:把全部规则包进 @layer vtx- { ... },方便后续层叠控制与覆盖
92
96
  return {
93
97
  wrapSSR: useStyleRegister({
94
98
  theme: theme,
@@ -96,7 +100,7 @@ export function useStyle(componentName, styleFn) {
96
100
  path: [componentName],
97
101
  nonce: csp === null || csp === void 0 ? void 0 : csp.nonce,
98
102
  layer: {
99
- name: 'vtx-'
103
+ name: 'vtx'
100
104
  }
101
105
  }, function () {
102
106
  return styleFn(token);
@@ -52,44 +52,54 @@ function VtxScrollableRow(props) {
52
52
  setNextPrev();
53
53
  }, 200);
54
54
  window.addEventListener('resize', debouncedResize);
55
- setNextPrev();
55
+ // 使用 requestAnimationFrame 确保 DOM 已渲染
56
+ requestAnimationFrame(function () {
57
+ setNextPrev();
58
+ });
56
59
  return function () {
60
+ debouncedResize.cancel();
57
61
  window.removeEventListener('resize', debouncedResize);
58
62
  };
59
- }, [navRef === null || navRef === void 0 ? void 0 : navRef.current, containerRef.current, navWrapRef.current]);
63
+ }, []);
60
64
  function setNextPrev() {
61
65
  if (navRef !== null && navRef !== void 0 && navRef.current && containerRef.current && navWrapRef.current) {
62
66
  var navNodeW = navRef.current.scrollWidth;
63
67
  var containerW = containerRef.current.offsetWidth;
64
68
  var navWrapNodeW = navWrapRef.current.offsetWidth;
65
69
  var minOffset = containerW - navNodeW;
66
- var _next = state.next,
67
- _prev = state.prev;
68
- if (minOffset >= 0) {
69
- _next = false;
70
- setOffset(0, false);
71
- offset.current = 0;
72
- } else if (minOffset < offset.current) {
73
- _next = true;
74
- } else {
75
- _next = false;
76
- var realOffset = navWrapNodeW - navNodeW;
77
- setOffset(realOffset, false);
78
- offset.current = realOffset;
79
- }
80
- if (offset.current < 0) {
81
- _prev = true;
82
- } else {
83
- _prev = false;
84
- }
85
- setState({
86
- next: _next,
87
- prev: _prev
70
+
71
+ // 使用函数式更新确保状态一致性
72
+ setState(function (prevState) {
73
+ var next = prevState.next,
74
+ prev = prevState.prev;
75
+ var newOffset = offset.current;
76
+ if (minOffset >= 0) {
77
+ next = false;
78
+ setOffset(0, false);
79
+ newOffset = 0;
80
+ } else if (minOffset < newOffset) {
81
+ next = true;
82
+ } else {
83
+ next = false;
84
+ var realOffset = navWrapNodeW - navNodeW;
85
+ setOffset(realOffset, false);
86
+ newOffset = realOffset;
87
+ }
88
+ if (newOffset < 0) {
89
+ prev = true;
90
+ } else {
91
+ prev = false;
92
+ }
93
+
94
+ // 同步更新 ref 值
95
+ offset.current = newOffset;
96
+
97
+ // 返回新的状态对象
98
+ return {
99
+ next: next,
100
+ prev: prev
101
+ };
88
102
  });
89
- return {
90
- next: _next,
91
- prev: _prev
92
- };
93
103
  }
94
104
  }
95
105
  var setOffset = function setOffset(os) {
@@ -94,7 +94,7 @@ function VtxSearch(props) {
94
94
  return !!item;
95
95
  }) : props === null || props === void 0 ? void 0 : props.children;
96
96
  var grid = useMemo(function () {
97
- var weightArr = props.gridWeight.filter(function (item) {
97
+ var weightArr = (props.gridWeight || []).filter(function (item) {
98
98
  return !!item;
99
99
  });
100
100
  var sum = 0;
@@ -121,7 +121,7 @@ function VtxSearch(props) {
121
121
  cumulative: cumulative,
122
122
  // 总数量
123
123
  len: cumulative[cumulative.length - 1],
124
- lenWeight: cumulativeWeight[cumulative.length - 2] + weightArr[(weightArr === null || weightArr === void 0 ? void 0 : weightArr.length) - 1],
124
+ lenWeight: cumulativeWeight[Math.max(0, cumulative.length - 2)] + (weightArr[(weightArr === null || weightArr === void 0 ? void 0 : weightArr.length) - 1] || 0),
125
125
  // 几个children
126
126
  count: count,
127
127
  // 兼容的处理
@@ -218,12 +218,13 @@ function VtxSearch(props) {
218
218
  } else {
219
219
  var chData = [];
220
220
  cData.forEach(function (item) {
221
- if (typeof item == 'function') {
221
+ if (typeof item === 'function') {
222
222
  var ite = item();
223
223
  if (Array.isArray(ite)) {
224
224
  chData.push.apply(chData, _toConsumableArray(ite));
225
+ } else {
226
+ chData.push(ite);
225
227
  }
226
- chData.push(ite);
227
228
  return;
228
229
  }
229
230
  if (Array.isArray(item)) {
@@ -16,7 +16,8 @@ var genVtxStyle = function genVtxStyle(token) {
16
16
  transitionDuration: token.toggleSpeed,
17
17
  transitionProperty: 'height',
18
18
  boxSizing: 'border-box',
19
- overflow: 'hidden'
19
+ overflow: 'hidden',
20
+ color: token.colorText
20
21
  }, "".concat(componentCls, "-element"), {}), "".concat(componentCls, "-label_v"), {
21
22
  overflow: 'hidden',
22
23
  lineHeight: 1,
@@ -3,6 +3,7 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableTo
3
3
  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."); }
4
4
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
5
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
6
7
  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; }
7
8
  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; }
8
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; }
@@ -31,7 +32,7 @@ var VtxSelect = /*#__PURE__*/forwardRef(function (props, ref) {
31
32
  popWidth = _useState2[0],
32
33
  setPopWidth = _useState2[1];
33
34
  var elRef = useRef();
34
- var elId = useRef("vtx-select-".concat(Date.now()));
35
+ var elId = useRef("vtx-select-".concat(Math.random().toString(36).substr(2, 9)));
35
36
  var _useState3 = useState(''),
36
37
  _useState4 = _slicedToArray(_useState3, 2),
37
38
  searchValue = _useState4[0],
@@ -64,20 +65,33 @@ var VtxSelect = /*#__PURE__*/forwardRef(function (props, ref) {
64
65
  emptyDescriptionText: intl.getMessage('select.empty', '暂无数据')
65
66
  }, customEnumText);
66
67
  useEffect(function () {
67
- if (mode === 'multiple' || mode === 'tags') {
68
- var timer = setInterval(function () {
69
- var _elRef$current;
70
- var _width = (_elRef$current = elRef.current) === null || _elRef$current === void 0 ? void 0 : _elRef$current.clientWidth;
71
- if (_width > 0) {
72
- setPopWidth(_width);
73
- clearInterval(timer);
68
+ if ((mode === 'multiple' || mode === 'tags') && elRef.current) {
69
+ var element = elRef.current;
70
+
71
+ // 立即设置一次
72
+ setPopWidth(element.clientWidth);
73
+
74
+ // 使用 ResizeObserver 监听尺寸变化
75
+ var resizeObserver = new ResizeObserver(function (entries) {
76
+ var _iterator = _createForOfIteratorHelper(entries),
77
+ _step;
78
+ try {
79
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
80
+ var entry = _step.value;
81
+ setPopWidth(entry.contentRect.width);
82
+ }
83
+ } catch (err) {
84
+ _iterator.e(err);
85
+ } finally {
86
+ _iterator.f();
74
87
  }
75
- }, 1000);
88
+ });
89
+ resizeObserver.observe(element);
76
90
  return function () {
77
- return clearInterval(timer);
91
+ resizeObserver.disconnect();
78
92
  };
79
93
  }
80
- }, []);
94
+ }, [mode]);
81
95
  var newChildren = props.children ? Array.isArray(props.children) ? props.children : [props.children] : [];
82
96
  var getContent = function getContent() {
83
97
  var child = {};
@@ -1,4 +1,4 @@
1
- import React, { forwardRef, useRef, useEffect, useContext } from 'react';
1
+ import React, { forwardRef, useRef, useLayoutEffect, useContext } from 'react';
2
2
  import SignaturePad from 'signature_pad';
3
3
  import debounce from 'lodash-es/debounce';
4
4
  import PropTypes from 'prop-types';
@@ -44,7 +44,7 @@ var VtxSignature = /*#__PURE__*/forwardRef(function (props, ref) {
44
44
  clear();
45
45
  }
46
46
  }
47
- useEffect(function () {
47
+ useLayoutEffect(function () {
48
48
  signaturePad.current = new SignaturePad(canvasRef.current, {
49
49
  dotSize: dotSize,
50
50
  minWidth: minWidth,
@@ -65,7 +65,9 @@ var VtxSignature = /*#__PURE__*/forwardRef(function (props, ref) {
65
65
  _onEnd && _onEnd();
66
66
  }
67
67
  });
68
- resizeCanvas();
68
+ setTimeout(function () {
69
+ resizeCanvas();
70
+ }, 0);
69
71
  window.addEventListener('resize', debounce(resizeCanvas, 150));
70
72
  return function () {
71
73
  window.removeEventListener('resize', debounce(resizeCanvas, 150));
@@ -82,7 +84,6 @@ var VtxSignature = /*#__PURE__*/forwardRef(function (props, ref) {
82
84
  };
83
85
  return wrapSSR( /*#__PURE__*/_jsxs("div", {
84
86
  className: classnames(prefixCls, hashId),
85
- ref: ref,
86
87
  children: [/*#__PURE__*/_jsx("div", {
87
88
  className: classnames("".concat(prefixCls, "--body")),
88
89
  children: /*#__PURE__*/_jsx("canvas", {
@@ -11,7 +11,7 @@ var genVtxSignatureStyle = function genVtxSignatureStyle(token) {
11
11
  position: 'relative',
12
12
  display: 'flex',
13
13
  flexDirection: 'column',
14
- height: '300px',
14
+ height: 300,
15
15
  padding: '16px',
16
16
  backgroundColor: token.colorBgBase,
17
17
  border: "1px solid ".concat(token.colorBorder),