fan-standard-comp 4.1.13 → 4.1.15

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 (74) hide show
  1. package/dist/fan-standard-comp.min.js +1 -1
  2. package/es/ButtonGroup/index.d.ts +1 -1
  3. package/es/ButtonGroup/index.js +99 -35
  4. package/es/FormComp/RenderItemGroup/index.js +25 -10
  5. package/es/FormComp/VarTemplate/index.js +15 -7
  6. package/es/Navigation/index.d.ts +10 -0
  7. package/es/Navigation/index.js +182 -0
  8. package/es/Navigation/style/index.d.ts +6 -0
  9. package/es/Navigation/style/index.js +34 -0
  10. package/es/StandardContent/WrapperContent.js +1 -1
  11. package/es/StandardContent/styles/Wrapper.js +3 -1
  12. package/es/StandardTable/index.js +5 -3
  13. package/es/StandardTable/types.d.ts +1 -0
  14. package/es/locales/bn-BD/settings.d.ts +9 -0
  15. package/es/locales/bn-BD/settings.js +10 -1
  16. package/es/locales/bn-BD.d.ts +9 -0
  17. package/es/locales/en-US/settings.d.ts +2 -0
  18. package/es/locales/en-US/settings.js +2 -0
  19. package/es/locales/en-US.d.ts +2 -0
  20. package/es/locales/fa-IR/settings.d.ts +9 -0
  21. package/es/locales/fa-IR/settings.js +10 -1
  22. package/es/locales/fa-IR.d.ts +9 -0
  23. package/es/locales/id-ID/settings.d.ts +9 -0
  24. package/es/locales/id-ID/settings.js +10 -1
  25. package/es/locales/id-ID.d.ts +9 -0
  26. package/es/locales/ja-JP/settings.d.ts +9 -0
  27. package/es/locales/ja-JP/settings.js +10 -1
  28. package/es/locales/ja-JP.d.ts +9 -0
  29. package/es/locales/pt-BR/settings.d.ts +9 -0
  30. package/es/locales/pt-BR/settings.js +10 -1
  31. package/es/locales/pt-BR.d.ts +9 -0
  32. package/es/locales/zh-CN/settings.d.ts +2 -0
  33. package/es/locales/zh-CN/settings.js +2 -0
  34. package/es/locales/zh-CN.d.ts +2 -0
  35. package/es/locales/zh-TW/settings.d.ts +9 -0
  36. package/es/locales/zh-TW/settings.js +10 -1
  37. package/es/locales/zh-TW.d.ts +9 -0
  38. package/lib/ButtonGroup/index.d.ts +1 -1
  39. package/lib/ButtonGroup/index.js +99 -35
  40. package/lib/FormComp/RenderItemGroup/index.js +25 -10
  41. package/lib/FormComp/VarTemplate/index.js +15 -7
  42. package/lib/Navigation/index.d.ts +10 -0
  43. package/lib/Navigation/index.js +192 -0
  44. package/lib/Navigation/style/index.d.ts +6 -0
  45. package/lib/Navigation/style/index.js +40 -0
  46. package/lib/StandardContent/WrapperContent.js +1 -1
  47. package/lib/StandardContent/styles/Wrapper.js +3 -1
  48. package/lib/StandardTable/index.js +5 -3
  49. package/lib/StandardTable/types.d.ts +1 -0
  50. package/lib/locales/bn-BD/settings.d.ts +9 -0
  51. package/lib/locales/bn-BD/settings.js +10 -1
  52. package/lib/locales/bn-BD.d.ts +9 -0
  53. package/lib/locales/en-US/settings.d.ts +2 -0
  54. package/lib/locales/en-US/settings.js +2 -0
  55. package/lib/locales/en-US.d.ts +2 -0
  56. package/lib/locales/fa-IR/settings.d.ts +9 -0
  57. package/lib/locales/fa-IR/settings.js +10 -1
  58. package/lib/locales/fa-IR.d.ts +9 -0
  59. package/lib/locales/id-ID/settings.d.ts +9 -0
  60. package/lib/locales/id-ID/settings.js +10 -1
  61. package/lib/locales/id-ID.d.ts +9 -0
  62. package/lib/locales/ja-JP/settings.d.ts +9 -0
  63. package/lib/locales/ja-JP/settings.js +10 -1
  64. package/lib/locales/ja-JP.d.ts +9 -0
  65. package/lib/locales/pt-BR/settings.d.ts +9 -0
  66. package/lib/locales/pt-BR/settings.js +10 -1
  67. package/lib/locales/pt-BR.d.ts +9 -0
  68. package/lib/locales/zh-CN/settings.d.ts +2 -0
  69. package/lib/locales/zh-CN/settings.js +2 -0
  70. package/lib/locales/zh-CN.d.ts +2 -0
  71. package/lib/locales/zh-TW/settings.d.ts +9 -0
  72. package/lib/locales/zh-TW/settings.js +10 -1
  73. package/lib/locales/zh-TW.d.ts +9 -0
  74. package/package.json +1 -1
@@ -26,7 +26,7 @@ interface CodesProps {
26
26
  [key: string]: any;
27
27
  }
28
28
  interface ButtonGroupProps {
29
- type?: 'button' | 'text';
29
+ type?: 'button' | 'text' | 'action';
30
30
  rowParams?: ButtonGroupRowParamsProps;
31
31
  codes?: CodesProps[];
32
32
  permissionCodes?: string[];
@@ -100,15 +100,19 @@ var ButtonGroup = function ButtonGroup(props) {
100
100
  confirmConfig = vItem.confirmConfig,
101
101
  render = vItem.render,
102
102
  others = _objectWithoutProperties(vItem, _excluded);
103
+ var uniqueId = "".concat(Date.now(), "_").concat(Math.random().toString(36).substr(2, 9));
103
104
  return _objectSpread(_objectSpread({}, others), {}, {
104
- key: code ? code + i : i,
105
+ key: code ? code + i + uniqueId : i + uniqueId,
106
+ // // 使用 useRef 保持 ID 的稳定性(只在组件挂载时生成一次)
105
107
  icon: icon ? /*#__PURE__*/React.createElement(IconNode, {
106
108
  icon: icon
107
109
  }) : null,
108
110
  // exName为null时,将不显示名称
109
111
  label: /*#__PURE__*/React.createElement("a", {
110
- onClick: function onClick() {
111
- return fn && fn(vItem);
112
+ onClick: function onClick(event) {
113
+ return fn && fn(_objectSpread(_objectSpread({}, vItem), {}, {
114
+ event: event
115
+ }));
112
116
  }
113
117
  }, exName || name),
114
118
  children: children && children.length > 0 ? deepTransButtonMenus(children) : undefined
@@ -181,8 +185,10 @@ var ButtonGroup = function ButtonGroup(props) {
181
185
  danger: danger,
182
186
  ghost: ghost,
183
187
  loading: loading,
184
- onClick: fn ? function () {
185
- return fn(item);
188
+ onClick: fn ? function (event) {
189
+ return fn(_objectSpread(_objectSpread({}, item), {}, {
190
+ event: event
191
+ }));
186
192
  } : null,
187
193
  size: size
188
194
  }, others, {
@@ -299,10 +305,11 @@ var ButtonGroup = function ButtonGroup(props) {
299
305
  confirmText = vItem.confirmText,
300
306
  confirmConfig = vItem.confirmConfig,
301
307
  others = _objectWithoutProperties(vItem, _excluded3);
308
+ var uniqueId = "".concat(Date.now(), "_").concat(Math.random().toString(36).substr(2, 9));
302
309
  return {
303
310
  danger: others.danger,
304
311
  disabled: btnIsDisabled(others.disabled, rowParams),
305
- key: code ? code + i : i,
312
+ key: code ? code + i + uniqueId : i + uniqueId,
306
313
  icon: icon && showTextIcon ? /*#__PURE__*/React.createElement(IconNode, {
307
314
  icon: icon,
308
315
  style: {
@@ -311,7 +318,7 @@ var ButtonGroup = function ButtonGroup(props) {
311
318
  }) : null,
312
319
  // 不显示图标
313
320
  label: /*#__PURE__*/React.createElement("a", {
314
- onClick: function onClick() {
321
+ onClick: function onClick(event) {
315
322
  // 配置二次确认
316
323
  if (vItem.hasOwnProperty('confirmText') || vItem.hasOwnProperty('confirmConfig')) {
317
324
  // @ts-ignore
@@ -319,7 +326,9 @@ var ButtonGroup = function ButtonGroup(props) {
319
326
  } else {
320
327
  fn && fn.apply(void 0, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
321
328
  return rowParams[pItem];
322
- })));
329
+ })).concat([_objectSpread(_objectSpread({}, vItem), {}, {
330
+ event: event
331
+ })]));
323
332
  }
324
333
  }
325
334
  }, renderCustomLabel(vItem, true)),
@@ -351,24 +360,42 @@ var ButtonGroup = function ButtonGroup(props) {
351
360
  title: /*#__PURE__*/React.createElement(PopConfirmTitle, _extends({}, item, {
352
361
  extraRow: rowParams
353
362
  })),
354
- onCancel: function onCancel() {
363
+ onCancel: function onCancel(event) {
355
364
  if (item.hasOwnProperty('confirmConfig') && item.confirmConfig.onCancel) {
356
- var _item$confirmConfig;
357
- (_item$confirmConfig = item.confirmConfig).onCancel.apply(_item$confirmConfig, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
358
- return rowParams[pItem];
359
- })));
365
+ if (type === 'action') {
366
+ var _item$confirmConfig;
367
+ (_item$confirmConfig = item.confirmConfig).onCancel.apply(_item$confirmConfig, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
368
+ return rowParams[pItem];
369
+ })).concat([_objectSpread(_objectSpread({}, item), {}, {
370
+ event: event
371
+ })]));
372
+ }
373
+ if (type === 'text') {
374
+ item.confirmConfig.onCancel(_objectSpread(_objectSpread({}, item), {}, {
375
+ event: event
376
+ }));
377
+ }
360
378
  }
361
379
  },
362
- onConfirm: function onConfirm() {
380
+ onConfirm: function onConfirm(event) {
363
381
  if (item.hasOwnProperty('confirmConfig') && item.confirmConfig.onConfirm) {
364
382
  var _item$confirmConfig2;
365
383
  (_item$confirmConfig2 = item.confirmConfig).onConfirm.apply(_item$confirmConfig2, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
366
384
  return rowParams[pItem];
367
385
  })));
368
386
  } else if (item.fn) {
369
- item.fn.apply(item, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
370
- return rowParams[pItem];
371
- })));
387
+ if (type === 'action') {
388
+ item.fn.apply(item, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
389
+ return rowParams[pItem];
390
+ })).concat([_objectSpread(_objectSpread({}, item), {}, {
391
+ event: event
392
+ })]));
393
+ }
394
+ if (type === 'text') {
395
+ item.fn(_objectSpread(_objectSpread({}, item), {}, {
396
+ event: event
397
+ }));
398
+ }
372
399
  }
373
400
  }
374
401
  }), /*#__PURE__*/React.createElement("a", {
@@ -385,10 +412,19 @@ var ButtonGroup = function ButtonGroup(props) {
385
412
  // @ts-ignore
386
413
  ,
387
414
  disabled: btnIsDisabled(item.disabled, rowParams),
388
- onClick: item.fn ? function () {
389
- return item.fn.apply(item, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
390
- return rowParams[pItem];
391
- })));
415
+ onClick: item.fn ? function (event) {
416
+ if (type === 'action') {
417
+ item.fn.apply(item, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
418
+ return rowParams[pItem];
419
+ })).concat([_objectSpread(_objectSpread({}, item), {}, {
420
+ event: event
421
+ })]));
422
+ }
423
+ if (type === 'text') {
424
+ item.fn(_objectSpread(_objectSpread({}, item), {}, {
425
+ event: event
426
+ }));
427
+ }
392
428
  } : undefined
393
429
  }, renderCustomLabel(item)));
394
430
  };
@@ -421,7 +457,8 @@ var ButtonGroup = function ButtonGroup(props) {
421
457
  rowParams: rowParams
422
458
  }));
423
459
  }
424
- /*渲染文本形式*/
460
+
461
+ /*渲染文本形式(包含表格操作列的按钮)type='text' 或 type='action'*/
425
462
  return /*#__PURE__*/React.createElement(RenderTextList, _extends({
426
463
  key: index
427
464
  }, item));
@@ -463,28 +500,55 @@ var ButtonGroup = function ButtonGroup(props) {
463
500
  title: /*#__PURE__*/React.createElement(PopConfirmTitle, _extends({}, popRow, {
464
501
  extraRow: rowParams
465
502
  })),
466
- onCancel: function onCancel() {
503
+ onCancel: function onCancel(event) {
467
504
  setPopVisibleIndex(-1);
468
505
  // 优先调用其 confirmConfig 配置的 onCancel 事件
469
506
  if (popRow.hasOwnProperty('confirmConfig') && popRow.confirmConfig.onCancel) {
470
- var _popRow$confirmConfig;
471
- (_popRow$confirmConfig = popRow.confirmConfig).onCancel.apply(_popRow$confirmConfig, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
472
- return rowParams[pItem];
473
- })));
507
+ if (type === 'action') {
508
+ var _popRow$confirmConfig;
509
+ (_popRow$confirmConfig = popRow.confirmConfig).onCancel.apply(_popRow$confirmConfig, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
510
+ return rowParams[pItem];
511
+ })).concat([_objectSpread(_objectSpread({}, popRow), {}, {
512
+ event: event
513
+ })]));
514
+ }
515
+ if (type === 'text') {
516
+ popRow.confirmConfig.onCancel(_objectSpread(_objectSpread({}, popRow), {}, {
517
+ event: event
518
+ }));
519
+ }
474
520
  }
475
521
  },
476
- onConfirm: function onConfirm() {
522
+ onConfirm: function onConfirm(event) {
477
523
  setPopVisibleIndex(-1);
478
524
  // 优先调用其 confirmConfig 配置的 onConfirm 事件
479
525
  if (popRow.hasOwnProperty('confirmConfig') && popRow.confirmConfig.onConfirm) {
480
- var _popRow$confirmConfig2;
481
- (_popRow$confirmConfig2 = popRow.confirmConfig).onConfirm.apply(_popRow$confirmConfig2, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
482
- return rowParams[pItem];
483
- })));
526
+ if (type === 'action') {
527
+ var _popRow$confirmConfig2;
528
+ (_popRow$confirmConfig2 = popRow.confirmConfig).onConfirm.apply(_popRow$confirmConfig2, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
529
+ return rowParams[pItem];
530
+ })).concat([_objectSpread(_objectSpread({}, popRow), {}, {
531
+ event: event
532
+ })]));
533
+ }
534
+ if (type === 'text') {
535
+ popRow.confirmConfig.onCancel(_objectSpread(_objectSpread({}, popRow), {}, {
536
+ event: event
537
+ }));
538
+ }
484
539
  } else if (popRow.fn) {
485
- popRow.fn.apply(popRow, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
486
- return rowParams[pItem];
487
- })));
540
+ if (type === 'action') {
541
+ popRow.fn.apply(popRow, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
542
+ return rowParams[pItem];
543
+ })).concat([_objectSpread(_objectSpread({}, popRow), {}, {
544
+ event: event
545
+ })]));
546
+ }
547
+ if (type === 'text') {
548
+ popRow.fn(_objectSpread(_objectSpread({}, popRow), {}, {
549
+ event: event
550
+ }));
551
+ }
488
552
  }
489
553
  }
490
554
  }), /*#__PURE__*/React.createElement(Dropdown, _extends({
@@ -24,6 +24,23 @@ var FormItem = Form.Item;
24
24
 
25
25
  // 单个控件配置参数
26
26
 
27
+ var DescriptionTooltip = function DescriptionTooltip(props) {
28
+ var label = props.label,
29
+ description = props.description;
30
+ return /*#__PURE__*/React.createElement("span", {
31
+ className: 'spec-item-group-label',
32
+ style: {
33
+ display: 'inline-flex'
34
+ }
35
+ }, label, description && /*#__PURE__*/React.createElement(Tooltip, {
36
+ title: description
37
+ }, /*#__PURE__*/React.createElement(SpecIcon, {
38
+ name: "info",
39
+ style: {
40
+ marginLeft: label ? '4px' : 0
41
+ }
42
+ })));
43
+ };
27
44
  var RenderItemGroup = function RenderItemGroup(props) {
28
45
  var itemGroup = props.itemGroup,
29
46
  _props$size = props.size,
@@ -231,11 +248,10 @@ var RenderItemGroup = function RenderItemGroup(props) {
231
248
  }, item.protoCol), /*#__PURE__*/React.createElement(FormItem, _extends({
232
249
  name: type !== 'custom' && (filedName || fieldName),
233
250
  className: classNames(fieldStatus === 'viewOnly' ? 'form-item-view-only' : '', 'spec-item-group-form-item'),
234
- label: description ? /*#__PURE__*/React.createElement("span", null, label, /*#__PURE__*/React.createElement(Tooltip, {
235
- title: description
236
- }, /*#__PURE__*/React.createElement(SpecIcon, {
237
- name: "info"
238
- }))) : label,
251
+ label: description ? /*#__PURE__*/React.createElement(DescriptionTooltip, {
252
+ label: label,
253
+ description: description
254
+ }) : label,
239
255
  rules: item.preExtra || item.extra ? [] : item.rules || (item.fieldOptions ? item.fieldOptions.rules : []),
240
256
  required: item.rules && item.rules.filter(function (rItem) {
241
257
  return rItem.required;
@@ -248,11 +264,10 @@ var RenderItemGroup = function RenderItemGroup(props) {
248
264
  key: index,
249
265
  name: type !== 'custom' && (filedName || fieldName),
250
266
  className: classNames(fieldStatus === 'viewOnly' ? 'form-item-view-only' : '', 'spec-item-group-form-item'),
251
- label: description ? /*#__PURE__*/React.createElement("span", null, label, /*#__PURE__*/React.createElement(Tooltip, {
252
- title: description
253
- }, /*#__PURE__*/React.createElement(SpecIcon, {
254
- name: "info"
255
- }))) : label,
267
+ label: description ? /*#__PURE__*/React.createElement(DescriptionTooltip, {
268
+ label: label,
269
+ description: description
270
+ }) : label,
256
271
  rules: item.rules || (item.fieldOptions ? item.fieldOptions.rules : [])
257
272
  }, formLayout, item.protoFormItem),
258
273
  // type === 'custom' && customRender ? customRender(form, { ...item }, fieldStatus) : type === 'FormList' ? <CustomFormList name={filedName || fieldName} {...item}/> : renderFormField({ ...item })
@@ -32,7 +32,8 @@ var VarTemplate = function VarTemplate(props) {
32
32
  value: 'value'
33
33
  } : _props$tagsOptionName,
34
34
  showCountTip = props.showCountTip,
35
- onChange = props.onChange;
35
+ onChange = props.onChange,
36
+ maxLength = props.maxLength;
36
37
  var lang = useLanguageObject(); // 当前使用的语言包
37
38
  var contentRef = useRef();
38
39
  var _useState = useState({
@@ -65,19 +66,25 @@ var VarTemplate = function VarTemplate(props) {
65
66
  var currentContent = vartData.currentContent,
66
67
  startNum = vartData.startNum,
67
68
  endNum = vartData.endNum;
69
+ var insert = insertContent(currentContent, key, startNum, endNum);
70
+ var newContent = insert.length > maxLength ? insert.substring(0, maxLength) : insert;
71
+ // if (newContent.length > maxLength) {
72
+ // console.log('字数超出了', newContent, newContent.substring(0, maxLength))
73
+ // }
74
+ // 数字超出需要截取
68
75
  setVartData({
69
- currentContent: insertContent(currentContent, key, startNum, endNum),
76
+ currentContent: newContent,
70
77
  startNum: startNum + key.length,
71
78
  // 光标起始位置累加
72
79
  endNum: endNum + key.length,
73
80
  // 光标起始位置累加
74
- wordCount: insertContent(currentContent, key, startNum, endNum).length
81
+ wordCount: newContent.length
75
82
  });
76
- if (onChange) onChange(insertContent(currentContent, key, startNum, endNum));
83
+ if (onChange) onChange(newContent);
77
84
  setTimeout(function () {
78
85
  moveToCursor(key.length); // 重新定位光标
79
86
  });
80
- }, [vartData]);
87
+ }, [vartData, maxLength]);
81
88
 
82
89
  /**
83
90
  * 指定位置插入标签占位符字符串,当光标有选中一段字符时,会将直接将其替换
@@ -266,13 +273,14 @@ var VarTemplate = function VarTemplate(props) {
266
273
  onChange: function onChange(e) {
267
274
  return handleInputChange(e);
268
275
  },
269
- disabled: disabled || fieldStatus === 'disabled'
276
+ disabled: disabled || fieldStatus === 'disabled',
277
+ maxLength: maxLength
270
278
  })), showCountTip && /*#__PURE__*/React.createElement("div", {
271
279
  className: "spec-vart-desc",
272
280
  style: {
273
281
  marginTop: '4px',
274
282
  fontSize: '12px'
275
283
  }
276
- }, (lang === null || lang === void 0 ? void 0 : lang['filed.varTemplate.enter']) || '您已录入', " ", /*#__PURE__*/React.createElement("b", null, vartData.wordCount), " ", (lang === null || lang === void 0 ? void 0 : lang['filed.varTemplate.words']) || '个字'));
284
+ }, (lang === null || lang === void 0 ? void 0 : lang['filed.varTemplate.enter']) || '您已录入', " ", /*#__PURE__*/React.createElement("b", null, vartData.wordCount, maxLength ? "/".concat(maxLength) : ''), " ", (lang === null || lang === void 0 ? void 0 : lang['filed.varTemplate.words']) || '个字'));
277
285
  };
278
286
  export default VarTemplate;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ interface NavigationProps {
3
+ items: MenuItem[];
4
+ }
5
+ interface MenuItem {
6
+ id: number;
7
+ label: string;
8
+ }
9
+ declare const Navigation: React.FC<NavigationProps>;
10
+ export default Navigation;
@@ -0,0 +1,182 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ 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."); }
3
+ 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); }
4
+ 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; }
5
+ 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; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import React, { useState, useEffect, useRef } from 'react';
8
+ import useStyle from "./style";
9
+ import classNames from 'classnames';
10
+ import _ from 'lodash';
11
+ //
12
+ // const useDebounce = (value, wait: number) => {
13
+ // const [debounceValue, setDebounceValue] = useState(value)
14
+ // useEffect(() => {
15
+ // const timer = setTimeout(() => setDebounceValue(value), wait)
16
+ // return () => clearTimeout(timer)
17
+ // }, [value, wait])
18
+ // return debounceValue
19
+ // }
20
+
21
+ var Navigation = function Navigation(props) {
22
+ var componentName = 'spec-navigation';
23
+ var _useStyle = useStyle(componentName),
24
+ _useStyle2 = _slicedToArray(_useStyle, 2),
25
+ wrapSSR = _useStyle2[0],
26
+ hashId = _useStyle2[1];
27
+ var items = props.items;
28
+ var _useState = useState([]),
29
+ _useState2 = _slicedToArray(_useState, 2),
30
+ visibleItems = _useState2[0],
31
+ setVisibleItems = _useState2[1];
32
+ var _useState3 = useState([]),
33
+ _useState4 = _slicedToArray(_useState3, 2),
34
+ hiddenItems = _useState4[0],
35
+ setHiddenItems = _useState4[1];
36
+ var _useState5 = useState(false),
37
+ _useState6 = _slicedToArray(_useState5, 2),
38
+ showMore = _useState6[0],
39
+ setShowMore = _useState6[1];
40
+ var listRef = useRef(null);
41
+ var containerRef = useRef(null);
42
+ var itemsRef = useRef([]);
43
+ var moreButtonRef = useRef(null);
44
+ var _useState7 = useState(0),
45
+ _useState8 = _slicedToArray(_useState7, 2),
46
+ containerWidth = _useState8[0],
47
+ setContainerWidth = _useState8[1];
48
+ var _useState9 = useState(0),
49
+ _useState10 = _slicedToArray(_useState9, 2),
50
+ moreButtonWidth = _useState10[0],
51
+ setMoreButtonWidth = _useState10[1];
52
+ // 使用lodash的debounce函数
53
+ var debouncedHandleChange = _.debounce(function (_ref) {
54
+ var visible = _ref.visible,
55
+ hidden = _ref.hidden;
56
+ // console.log(event.target.value);
57
+ setVisibleItems(visible);
58
+ setHiddenItems(hidden);
59
+ }, 100); // 延迟500毫秒执行
60
+
61
+ useEffect(function () {
62
+ var calculateLayout = function calculateLayout() {
63
+ if (!containerRef.current) return;
64
+
65
+ // const containerWidth = containerRef.current.offsetWidth;
66
+ // const moreButtonWidth = moreButtonRef.current?.offsetWidth || 0;
67
+ var totalWidth = 0;
68
+ var visible = []; // 显示的
69
+ var hidden = []; // 隐藏的
70
+
71
+ itemsRef.current.forEach(function (itemEl, index) {
72
+ if (!itemEl) return;
73
+ var itemWidth = itemEl.offsetWidth;
74
+ var remainingWidth = containerWidth - totalWidth - moreButtonWidth;
75
+ if (remainingWidth >= itemWidth && !hidden.length) {
76
+ totalWidth += itemWidth;
77
+ visible.push(items[index]);
78
+ } else {
79
+ hidden.push(items[index]);
80
+ }
81
+ });
82
+ debouncedHandleChange({
83
+ visible: visible,
84
+ hidden: hidden
85
+ });
86
+ // setVisibleItems(visible);
87
+ // setHiddenItems(hidden);
88
+ };
89
+
90
+ // 初始计算
91
+ calculateLayout();
92
+
93
+ // 添加窗口resize监听
94
+ var handleResize = function handleResize() {
95
+ calculateLayout();
96
+ setShowMore(false); // 窗口resize时关闭下拉菜单
97
+ };
98
+ window.addEventListener('resize', handleResize);
99
+ return function () {
100
+ return window.removeEventListener('resize', handleResize);
101
+ };
102
+ }, [items, containerWidth, moreButtonWidth]);
103
+ useEffect(function () {
104
+ var container = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current; // ?.offsetWidth;
105
+ setContainerWidth((container === null || container === void 0 ? void 0 : container.clientWidth) || 0);
106
+ var button = moreButtonRef === null || moreButtonRef === void 0 ? void 0 : moreButtonRef.current; // ?.offsetWidth;
107
+ setMoreButtonWidth((button === null || button === void 0 ? void 0 : button.clientWidth) || 0);
108
+ }, [containerRef === null || containerRef === void 0 ? void 0 : containerRef.current, moreButtonRef === null || moreButtonRef === void 0 ? void 0 : moreButtonRef.current, hiddenItems]);
109
+ // useEffect(() => {
110
+ // const button = moreButtonRef?.current // ?.offsetWidth;
111
+ // setMoreButtonWidth(button?.clientWidth || 0)
112
+ // }, [moreButtonRef?.current, hiddenItems])
113
+ // console.log(containerWidth, moreButtonWidth)
114
+ return wrapSSR( /*#__PURE__*/React.createElement("div", {
115
+ style: {
116
+ width: '100%'
117
+ }
118
+ }, /*#__PURE__*/React.createElement("div", {
119
+ ref: listRef,
120
+ style: {
121
+ width: '100%',
122
+ height: '20px',
123
+ backgroundColor: '#ff1133'
124
+ }
125
+ }), /*#__PURE__*/React.createElement("div", {
126
+ ref: containerRef,
127
+ className: classNames(componentName, hashId, "spec-navigation-container"),
128
+ style: {
129
+ // display: 'flex',
130
+ width: '100%'
131
+ // // overflow: 'hidden',
132
+ // boxSizing: "border-box",
133
+ // position: 'relative',
134
+ // paddingRight: '80px', // 为更多按钮预留空间
135
+ }
136
+ }, items.map(function (item, index) {
137
+ return /*#__PURE__*/React.createElement("div", {
138
+ className: 'spec-navigation-item',
139
+ key: item.id,
140
+ ref: function ref(el) {
141
+ return el && (itemsRef.current[index] = el);
142
+ },
143
+ style: {
144
+ opacity: visibleItems.includes(item) ? '1' : '0'
145
+ }
146
+ }, item.label);
147
+ }), /*#__PURE__*/React.createElement("div", {
148
+ className: 'spec-navigation-item more-item',
149
+ style: {
150
+ position: 'relative',
151
+ flexShrink: 0,
152
+ display: hiddenItems.length > 0 ? 'block' : 'none'
153
+ }
154
+ }, /*#__PURE__*/React.createElement("button", {
155
+ ref: moreButtonRef,
156
+ onClick: function onClick() {
157
+ return setShowMore(!showMore);
158
+ },
159
+ style: {
160
+ marginLeft: '8px'
161
+ }
162
+ }, "\u66F4\u591A"), showMore && /*#__PURE__*/React.createElement("div", {
163
+ style: {
164
+ position: 'absolute',
165
+ top: '100%',
166
+ right: 0,
167
+ backgroundColor: 'white',
168
+ border: '1px solid #ccc',
169
+ boxShadow: '0 2px 4px rgba(0,0,0,0.1)',
170
+ zIndex: 100
171
+ }
172
+ }, hiddenItems.map(function (item) {
173
+ return /*#__PURE__*/React.createElement("div", {
174
+ key: item.id,
175
+ style: {
176
+ padding: '8px 16px',
177
+ whiteSpace: 'nowrap'
178
+ }
179
+ }, item.label);
180
+ }))))));
181
+ };
182
+ export default Navigation;
@@ -0,0 +1,6 @@
1
+ import { GlobalToken } from "antd";
2
+ export interface NavLeafScrollTokenType extends GlobalToken {
3
+ [k: string]: any;
4
+ }
5
+ declare const NavLeafScrollStyleFunc: (prefix: string) => any;
6
+ export default NavLeafScrollStyleFunc;
@@ -0,0 +1,34 @@
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 _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; }
3
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
4
+ 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); }
5
+ import { createStyleHook } from "../../theme/utils/genStyleHook";
6
+ var NavLeafScrollStyleFunc = function NavLeafScrollStyleFunc(prefix) {
7
+ var prepareComponentToken = function prepareComponentToken(token) {
8
+ return {
9
+ fontWeight: 400
10
+ };
11
+ };
12
+ return createStyleHook(prefix, function (token) {
13
+ var prefixCls = ".".concat(prefix);
14
+ return [_defineProperty({}, prefixCls, {
15
+ display: 'flex',
16
+ width: '100%',
17
+ overflow: 'hidden',
18
+ boxSizing: "border-box",
19
+ // position: 'relative',
20
+ // paddingRight: '80px',
21
+
22
+ outline: 'none',
23
+ '.spec-navigation-item': {
24
+ position: 'relative',
25
+ display: 'inline-block',
26
+ flexShrink: 0,
27
+ padding: '0 16px',
28
+ whiteSpace: 'nowrap'
29
+ }
30
+ })];
31
+ }, prepareComponentToken // 当前组件扩展的变量
32
+ );
33
+ };
34
+ export default NavLeafScrollStyleFunc;
@@ -59,7 +59,7 @@ var WrapperContent = /*#__PURE__*/forwardRef(function (props, ref) {
59
59
  }
60
60
  });
61
61
  return wrapSSR( /*#__PURE__*/React.createElement("div", {
62
- className: classNames(componentName, className, noMargin ? 'has-margin' : '', proLayoutProps !== null && proLayoutProps !== void 0 && (_proLayoutProps$heade = proLayoutProps.header) !== null && _proLayoutProps$heade !== void 0 && _proLayoutProps$heade.fixed || header !== null && header !== void 0 && header.fixed ? componentName + '-fixed' : '', hashId),
62
+ className: classNames(componentName, className, noMargin ? 'has-no-margin' : '', proLayoutProps !== null && proLayoutProps !== void 0 && (_proLayoutProps$heade = proLayoutProps.header) !== null && _proLayoutProps$heade !== void 0 && _proLayoutProps$heade.fixed || header !== null && header !== void 0 && header.fixed ? componentName + '-fixed' : '', hashId),
63
63
  style: style,
64
64
  ref: contentRef
65
65
  }, proLayoutProps !== null && proLayoutProps !== void 0 && proLayoutProps.header || header ? /*#__PURE__*/React.createElement(ContentHeader
@@ -14,7 +14,7 @@ var WrapperContentStyleFunc = function WrapperContentStyleFunc(prefix) {
14
14
  };
15
15
  return createStyleHook(prefix, function (token) {
16
16
  var prefixCls = ".".concat(prefix);
17
- return [_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, prefixCls, _objectSpread(_objectSpread({
17
+ return [_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, prefixCls, _objectSpread(_objectSpread({
18
18
  position: 'relative',
19
19
  // padding: token.paddingMD,
20
20
  // margin: -token.marginMD,
@@ -51,6 +51,8 @@ var WrapperContentStyleFunc = function WrapperContentStyleFunc(prefix) {
51
51
  height: '100%'
52
52
  }
53
53
  }
54
+ }), '&.has-no-margin', {
55
+ margin: 0
54
56
  }), '.spec-wrapper-content-spinning', {
55
57
  // width: '100%',
56
58
  // height: '100%'
@@ -83,8 +83,10 @@ var StandardTable = function StandardTable(props) {
83
83
  showSizeChanger: true,
84
84
  pageSizeOptions: ['5', '10', '15', '20', '30', '50'],
85
85
  showTotal: function showTotal(total, range) {
86
- return "".concat(range[0], "-").concat(range[1], "\u6761 \u5171").concat(total, "\u6761");
86
+ var unitKey = "".concat((lang === null || lang === void 0 ? void 0 : lang['table.pagination.unit']) || '条');
87
+ return "".concat(range[0], "-").concat(range[1], " ").concat(unitKey, ",").concat((lang === null || lang === void 0 ? void 0 : lang['table.pagination.total']) || '共', " ").concat(total, " ").concat(unitKey);
87
88
  },
89
+ // Total ${total} items
88
90
  pageSize: (pagination === null || pagination === void 0 ? void 0 : pagination.pageSize) || (pagination === null || pagination === void 0 ? void 0 : pagination.size)
89
91
  }, paginationConfig), pagination);
90
92
  if (columns) {
@@ -115,7 +117,7 @@ var StandardTable = function StandardTable(props) {
115
117
  var _colItem4, _colItem5, _colItem6;
116
118
  if (recombinationGroup.length === 0) return '-';
117
119
  return /*#__PURE__*/React.createElement(ButtonGroup, _extends({
118
- type: "text",
120
+ type: "action",
119
121
  min: colItem.min || 2 // 配置按钮展示最少数量,其他的将会被折叠
120
122
  ,
121
123
  options: recombinationGroup,
@@ -195,7 +197,7 @@ var StandardTable = function StandardTable(props) {
195
197
  var notShowHead = !extra && !placeButtonGroup && !placeTitle; // 不显示ant-card-head
196
198
  return wrapSSR( /*#__PURE__*/React.createElement(Card, {
197
199
  className: classNames(componentName, 'standard-table', className, hashId),
198
- bordered: false,
200
+ variant: 'borderless',
199
201
  title: notShowHead ? null : buttonGroupPlacement === 'left' ? /*#__PURE__*/React.createElement(React.Fragment, null, placeTitle, placeButtonGroup) : placeTitle,
200
202
  extra: notShowHead ? null : buttonGroupPlacement === 'left' ? extra : /*#__PURE__*/React.createElement(React.Fragment, null, placeButtonGroup, extra)
201
203
  }, /*#__PURE__*/React.createElement(Table, _extends({
@@ -3,6 +3,7 @@ import type { ButtonGroupOptionsProps } from "../ButtonGroup";
3
3
  export interface StandardTableDataProps {
4
4
  list?: object[];
5
5
  pagination?: any;
6
+ [k: string]: any;
6
7
  }
7
8
  export interface ExButtonGroupProps {
8
9
  buttonGroup?: ButtonGroupOptionsProps[];