@teamix/pro 1.4.12 → 1.4.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 (67) hide show
  1. package/dist/pro.css +1 -1
  2. package/dist/pro.js +532 -167
  3. package/dist/pro.min.css +1 -1
  4. package/dist/pro.min.js +1 -1
  5. package/es/actions/index.scss +1 -1
  6. package/es/form/ProForm/index.js +14 -32
  7. package/es/form/ProForm/index.scss +5 -0
  8. package/es/form/ProForm/useAutoLayout.d.ts +9 -0
  9. package/es/form/ProForm/useAutoLayout.js +114 -0
  10. package/es/form/SchemaForm/index.js +12 -4
  11. package/es/form/SchemaForm/initializeDataSource.d.ts +3 -0
  12. package/es/form/SchemaForm/initializeDataSource.js +7 -0
  13. package/es/form/SchemaForm/initializeFormButton.js +4 -5
  14. package/es/form/typing.d.ts +4 -0
  15. package/es/index.d.ts +1 -1
  16. package/es/index.js +1 -1
  17. package/es/info/components/ProInfoItem/index.js +33 -4
  18. package/es/info/components/ProInfoItem/index.scss +18 -11
  19. package/es/info/components/baseInfo/index.js +4 -1
  20. package/es/info/components/baseInfo/index.scss +4 -1
  21. package/es/info/components/headerInfo/index.js +4 -1
  22. package/es/info/components/headerInfo/index.scss +3 -0
  23. package/es/info/components/tableInfo/index.js +2 -1
  24. package/es/info/index.js +6 -3
  25. package/es/info/typing.d.ts +3 -1
  26. package/es/nocode/index.scss +2 -2
  27. package/es/nocode/pages/playground.js +1 -1
  28. package/es/nocode/pages/renderer.js +1 -1
  29. package/es/nocode/playground.js +1 -1
  30. package/es/table/components/Layout/index.js +8 -4
  31. package/es/table/components/QuickAction/index.js +1 -1
  32. package/es/table/index.js +121 -54
  33. package/es/table/index.scss +5 -0
  34. package/es/table/typing.d.ts +3 -1
  35. package/es/table/utils/columnRender.js +2 -1
  36. package/lib/actions/index.scss +1 -1
  37. package/lib/form/ProForm/index.js +13 -31
  38. package/lib/form/ProForm/index.scss +5 -0
  39. package/lib/form/ProForm/useAutoLayout.d.ts +9 -0
  40. package/lib/form/ProForm/useAutoLayout.js +124 -0
  41. package/lib/form/SchemaForm/index.js +11 -3
  42. package/lib/form/SchemaForm/initializeDataSource.d.ts +3 -0
  43. package/lib/form/SchemaForm/initializeDataSource.js +10 -2
  44. package/lib/form/SchemaForm/initializeFormButton.js +3 -4
  45. package/lib/form/typing.d.ts +4 -0
  46. package/lib/index.d.ts +1 -1
  47. package/lib/index.js +1 -1
  48. package/lib/info/components/ProInfoItem/index.js +33 -4
  49. package/lib/info/components/ProInfoItem/index.scss +18 -11
  50. package/lib/info/components/baseInfo/index.js +4 -1
  51. package/lib/info/components/baseInfo/index.scss +4 -1
  52. package/lib/info/components/headerInfo/index.js +4 -1
  53. package/lib/info/components/headerInfo/index.scss +3 -0
  54. package/lib/info/components/tableInfo/index.js +3 -1
  55. package/lib/info/index.js +5 -2
  56. package/lib/info/typing.d.ts +3 -1
  57. package/lib/nocode/index.scss +2 -2
  58. package/lib/nocode/pages/playground.js +1 -1
  59. package/lib/nocode/pages/renderer.js +1 -1
  60. package/lib/nocode/playground.js +1 -1
  61. package/lib/table/components/Layout/index.js +8 -4
  62. package/lib/table/components/QuickAction/index.js +1 -1
  63. package/lib/table/index.js +120 -52
  64. package/lib/table/index.scss +5 -0
  65. package/lib/table/typing.d.ts +3 -1
  66. package/lib/table/utils/columnRender.js +2 -1
  67. package/package.json +1 -1
@@ -40,6 +40,8 @@ var _classnames = _interopRequireDefault(require("classnames"));
40
40
 
41
41
  var _pageContainer = _interopRequireDefault(require("../page-container"));
42
42
 
43
+ var _lodash = _interopRequireDefault(require("lodash.debounce"));
44
+
43
45
  var _typing = require("./typing");
44
46
 
45
47
  Object.keys(_typing).forEach(function (key) {
@@ -257,7 +259,7 @@ var ProTable = function ProTable(props) {
257
259
  var skeletonDataSource = new Array(skeletonSize).fill({});
258
260
  var requestDataKey = method.toLowerCase() === 'get' ? 'params' : 'data'; // 如果使用 customRequest 的话,内置 loading
259
261
 
260
- var _useState13 = (0, _react.useState)(true),
262
+ var _useState13 = (0, _react.useState)(requestWhenMount),
261
263
  _useState14 = _slicedToArray(_useState13, 2),
262
264
  customTableLoading = _useState14[0],
263
265
  setCustomTableLoading = _useState14[1];
@@ -301,21 +303,45 @@ var ProTable = function ProTable(props) {
301
303
  var autoRefreshTimerRef = (0, _react.useRef)();
302
304
  var onResize = null;
303
305
  (0, _react.useEffect)(function () {
306
+ var _propsDataFilter$sche, _propsDataFilter$sche2;
307
+
304
308
  getHeaderHeight(fullscreenState);
309
+ getFooterSuctionState();
305
310
 
306
311
  if (window.onresize) {
307
312
  onResize = window.onresize;
308
-
309
- window.onresize = function () {
313
+ window.onresize = (0, _lodash.default)(function () {
310
314
  var _onResize;
311
315
 
312
316
  (_onResize = onResize) === null || _onResize === void 0 ? void 0 : _onResize();
313
- getHeaderHeight(fullscreenState);
314
- };
317
+
318
+ if (footerSuction) {
319
+ getFooterSuctionState();
320
+ }
321
+
322
+ if (fixedTableBody) {
323
+ getHeaderHeight(fullscreenState);
324
+ }
325
+ }, 500);
315
326
  } else {
316
- window.onresize = function () {
317
- getHeaderHeight(fullscreenState);
318
- };
327
+ window.onresize = (0, _lodash.default)(function () {
328
+ if (footerSuction) {
329
+ getFooterSuctionState();
330
+ }
331
+
332
+ if (fixedTableBody) {
333
+ getHeaderHeight(fullscreenState);
334
+ }
335
+ }, 500);
336
+ } // 如果不传 dataFilter,则在这里初始化请求
337
+
338
+
339
+ var hasDataFilter = (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : (_propsDataFilter$sche = propsDataFilter.schema) === null || _propsDataFilter$sche === void 0 ? void 0 : _propsDataFilter$sche.length) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : (_propsDataFilter$sche2 = propsDataFilter.schema) === null || _propsDataFilter$sche2 === void 0 ? void 0 : _propsDataFilter$sche2.length) > 0;
340
+
341
+ if (requestWhenMount && !hasDataFilter) {
342
+ (0, _utils2.processDefaultFilter)(propsColumns, actionRef, defaultFilterParams);
343
+
344
+ _request();
319
345
  }
320
346
 
321
347
  return function () {
@@ -324,11 +350,21 @@ var ProTable = function ProTable(props) {
324
350
  } else {
325
351
  window.onresize = null;
326
352
  }
353
+
354
+ if (autoRefreshTimerRef.current) {
355
+ clearTimeout(autoRefreshTimerRef.current);
356
+ }
357
+
358
+ actionRef.current = undefined;
327
359
  };
328
360
  }, []); // 获取header高度,用作全屏吸底吸底高度计算以及固定body高度计算(滚动条在底部)
329
361
 
330
362
  var getHeaderHeight = function getHeaderHeight(isFullscreen, offset) {
331
- var _tableDom$getElements, _tableDom$getElements2;
363
+ var _tableDom$getElements, _tableDom$getElements2, _document$querySelect, _document$querySelect2, _document$querySelect3;
364
+
365
+ if (!fixedTableBody) {
366
+ return;
367
+ }
332
368
 
333
369
  var tableDom = tableRef.current;
334
370
  var headerDom = tableDom === null || tableDom === void 0 ? void 0 : (_tableDom$getElements = tableDom.getElementsByClassName('teamix-pro-table-layout')) === null || _tableDom$getElements === void 0 ? void 0 : _tableDom$getElements[0];
@@ -338,7 +374,10 @@ var ProTable = function ProTable(props) {
338
374
  var tableHeaderDom = tableDom === null || tableDom === void 0 ? void 0 : (_tableDom$getElements2 = tableDom.getElementsByClassName(basePrefix('table-header-inner'))) === null || _tableDom$getElements2 === void 0 ? void 0 : _tableDom$getElements2[0];
339
375
  var pageContainerDom = document.querySelector('.teamix-pro-page-container-header');
340
376
  var teamixNavDom = document.querySelector('.teamix-nav-console');
341
- var footerRowSelectionDom = document.querySelector('.teamix-pro-page-container-footer');
377
+ var footerRowSelectionDom = document.querySelector('.teamix-pro-page-container-footer'); // 这边不能直接取 next-table-body
378
+
379
+ var tableBodyDom = (_document$querySelect = document.querySelector('.teamix-pro-table')) === null || _document$querySelect === void 0 ? void 0 : (_document$querySelect2 = _document$querySelect.getElementsByTagName('table')) === null || _document$querySelect2 === void 0 ? void 0 : (_document$querySelect3 = _document$querySelect2[1]) === null || _document$querySelect3 === void 0 ? void 0 : _document$querySelect3.parentNode;
380
+ var headerFixedTopSectionDom = document.querySelector('.teamix-pro-page-container-fixed-top');
342
381
  setTimeout(function () {
343
382
  var _headerDom$offsetHeig, _tableHeaderDom$offse;
344
383
 
@@ -352,11 +391,31 @@ var ProTable = function ProTable(props) {
352
391
 
353
392
  // 16px 为 padding
354
393
  var pageHeaderHeight = ((_pageContainerDom$off = pageContainerDom === null || pageContainerDom === void 0 ? void 0 : pageContainerDom.offsetHeight) !== null && _pageContainerDom$off !== void 0 ? _pageContainerDom$off : 0) + 16;
355
- var teamixNavHeight = (_teamixNavDom$offsetH = teamixNavDom === null || teamixNavDom === void 0 ? void 0 : teamixNavDom.offsetHeight) !== null && _teamixNavDom$offsetH !== void 0 ? _teamixNavDom$offsetH : 0;
356
- setHeaderHeight(headerHeight + tableHeaderHeight + pageHeaderHeight + teamixNavHeight + footerRowSelectionHeight + 16 + (offset !== null && offset !== void 0 ? offset : 0));
394
+ var teamixNavHeight = (_teamixNavDom$offsetH = teamixNavDom === null || teamixNavDom === void 0 ? void 0 : teamixNavDom.offsetHeight) !== null && _teamixNavDom$offsetH !== void 0 ? _teamixNavDom$offsetH : 0; // 1 为预留值,js无法取出精确高度,会被四舍五入
395
+
396
+ var offsetHeaderHeight = headerHeight + tableHeaderHeight + pageHeaderHeight + teamixNavHeight + footerRowSelectionHeight + 16 + (offset !== null && offset !== void 0 ? offset : 0) + 1;
397
+
398
+ if (tableBodyDom.clientHeight < tableBodyDom.scrollHeight) {
399
+ setFooterSuctionState(true);
400
+ } else {
401
+ setFooterSuctionState(false);
402
+ } // 如果有切换区tab,那么重新计算
403
+
404
+
405
+ if (headerFixedTopSectionDom.clientHeight) {
406
+ var _headerFixedTopSectio;
407
+
408
+ var headerFixedTopSectionHeight = (_headerFixedTopSectio = headerFixedTopSectionDom.clientHeight) !== null && _headerFixedTopSectio !== void 0 ? _headerFixedTopSectio : 0; // const clientTableBodyHeight =
409
+ // document.body.clientHeight - offsetHeaderHeight;
410
+
411
+ setHeaderHeight(headerFixedTopSectionHeight + teamixNavHeight + footerRowSelectionHeight + tableHeaderHeight + 1);
412
+ return;
413
+ }
414
+
415
+ setHeaderHeight(offsetHeaderHeight);
357
416
  } else {
358
417
  // 24px 为 padding
359
- setHeaderHeight(headerHeight + tableHeaderHeight + footerRowSelectionHeight + 24 + (offset !== null && offset !== void 0 ? offset : 0));
418
+ setHeaderHeight(headerHeight + tableHeaderHeight + footerRowSelectionHeight + 24 + (offset !== null && offset !== void 0 ? offset : 0) + 1);
360
419
  }
361
420
  }, 50);
362
421
  }; // header 区域高度。用作全屏计算吸顶吸底高度。默认不做计算
@@ -394,6 +453,10 @@ var ProTable = function ProTable(props) {
394
453
 
395
454
 
396
455
  var getFooterSuctionState = function getFooterSuctionState() {
456
+ if (!footerSuction) {
457
+ return;
458
+ }
459
+
397
460
  var containerDom = document.querySelector('.teamix-pro-page-container-scroll-container');
398
461
 
399
462
  if (containerDom) {
@@ -695,6 +758,10 @@ var ProTable = function ProTable(props) {
695
758
  if (footerSuction) {
696
759
  getFooterSuctionState();
697
760
  }
761
+
762
+ if (fixedTableBody) {
763
+ getHeaderHeight(fullscreenState);
764
+ }
698
765
  },
699
766
  onError: function onError(error) {
700
767
  setShowSkeleton(false);
@@ -708,6 +775,10 @@ var ProTable = function ProTable(props) {
708
775
  if (footerSuction) {
709
776
  getFooterSuctionState();
710
777
  }
778
+
779
+ if (fixedTableBody) {
780
+ getHeaderHeight(fullscreenState);
781
+ }
711
782
  }
712
783
  }); // 请求函数
713
784
 
@@ -773,6 +844,20 @@ var ProTable = function ProTable(props) {
773
844
  if (footerSuction) {
774
845
  getFooterSuctionState();
775
846
  }
847
+
848
+ if (fixedTableBody) {
849
+ getHeaderHeight(fullscreenState);
850
+ } // customRequest 中支持 autoRefresh
851
+
852
+
853
+ var time = autoRefresh ? autoRefresh(data) : false;
854
+
855
+ if (Number.isInteger(time) && time >= 1000) {
856
+ autoRefreshTimerRef.current = setTimeout(function () {
857
+ // 自动刷新不显示 loading
858
+ _request(requestData, true);
859
+ }, Number(time));
860
+ }
776
861
  });
777
862
  } else {
778
863
  getData.run(requestData);
@@ -780,40 +865,6 @@ var ProTable = function ProTable(props) {
780
865
  }
781
866
  }
782
867
 
783
- (0, _react.useEffect)(function () {
784
- var _propsDataFilter$sche, _propsDataFilter$sche2;
785
-
786
- // 监听 浏览器变化 更吸底状态
787
- if (footerSuction) {
788
- getFooterSuctionState();
789
-
790
- window.onresize = function () {
791
- getFooterSuctionState();
792
- };
793
- } // 如果不传 dataFilter,则在这里初始化请求
794
-
795
-
796
- var hasDataFilter = (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : (_propsDataFilter$sche = propsDataFilter.schema) === null || _propsDataFilter$sche === void 0 ? void 0 : _propsDataFilter$sche.length) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : (_propsDataFilter$sche2 = propsDataFilter.schema) === null || _propsDataFilter$sche2 === void 0 ? void 0 : _propsDataFilter$sche2.length) > 0;
797
-
798
- if (requestWhenMount && !hasDataFilter) {
799
- (0, _utils2.processDefaultFilter)(propsColumns, actionRef, defaultFilterParams);
800
-
801
- _request();
802
- }
803
-
804
- return function () {
805
- if (autoRefreshTimerRef.current) {
806
- clearTimeout(autoRefreshTimerRef.current);
807
- }
808
-
809
- if (window.onresize) {
810
- window.onresize = null;
811
- }
812
-
813
- actionRef.current = undefined;
814
- };
815
- }, []);
816
-
817
868
  function onSort(dataIndex, order) {
818
869
  var nextSort = _defineProperty({}, dataIndex, order);
819
870
 
@@ -879,7 +930,10 @@ var ProTable = function ProTable(props) {
879
930
  var renderTable = function renderTable(isFullScreen) {
880
931
  if (propsColumns) {
881
932
  return /*#__PURE__*/_react.default.createElement("div", {
882
- className: (0, _classnames.default)('teamix-pro-table-container', className)
933
+ className: (0, _classnames.default)('teamix-pro-table-container', className, 'teamix-test-request'),
934
+ "data-teamix-test-request": "url=".concat(url, "&formatResult=").concat(!!formatResult),
935
+ "data-teamix-test-params": (0, _utils.getTestRequestParams)(propsParams),
936
+ "data-teamix-test-data": (0, _utils.getTestRequestData)(propsColumns)
883
937
  }, /*#__PURE__*/_react.default.createElement(_Layout.default, {
884
938
  header: header,
885
939
  mainAction: mainAction,
@@ -1005,7 +1059,7 @@ var ProTable = function ProTable(props) {
1005
1059
  })
1006
1060
  }, renderRowSelection(), /*#__PURE__*/_react.default.createElement("div", {
1007
1061
  className: cls('footer-right-wrapper')
1008
- }, showSkeleton ? /*#__PURE__*/_react.default.createElement(_skeleton.ProSkeletonRaw.Footer.Pagination, null) : /*#__PURE__*/_react.default.createElement(_Pagination.default, _objectSpread({
1062
+ }, showSkeleton ? /*#__PURE__*/_react.default.createElement(_skeleton.ProSkeletonRaw.Footer.Pagination, null) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, data.length > 0 && /*#__PURE__*/_react.default.createElement(_Pagination.default, _objectSpread({
1009
1063
  className: cls('pagination'),
1010
1064
  onChange: function onChange(number) {
1011
1065
  return onChangePagination(number);
@@ -1027,7 +1081,7 @@ var ProTable = function ProTable(props) {
1027
1081
  onPageSizeChange: function onPageSizeChange(number) {
1028
1082
  return onChangePaginationSize(number);
1029
1083
  }
1030
- }, props.paginationProps))));
1084
+ }, props.paginationProps)))));
1031
1085
  } else if (!showPagination) {
1032
1086
  return /*#__PURE__*/_react.default.createElement("div", {
1033
1087
  className: cls('footer', {
@@ -1037,8 +1091,22 @@ var ProTable = function ProTable(props) {
1037
1091
  className: cls('footer-right-wrapper')
1038
1092
  }, showSkeleton ? /*#__PURE__*/_react.default.createElement(_skeleton.ProSkeletonRaw.Footer.Pagination, null) : footer));
1039
1093
  }
1040
- };
1094
+ }; // 判断是否需要吸底
1041
1095
 
1096
+
1097
+ var fixFooterState = (0, _react.useMemo)(function () {
1098
+ if (fullscreenState) {
1099
+ return true;
1100
+ }
1101
+
1102
+ if (fixedTableBody || footerSuction) {
1103
+ if (footerSuctionState) {
1104
+ return true;
1105
+ }
1106
+ }
1107
+
1108
+ return false;
1109
+ }, [fullscreenState, fixedTableBody, footerSuction, footerSuctionState]);
1042
1110
  return /*#__PURE__*/_react.default.createElement(_Fullscreen.default, {
1043
1111
  visible: fullscreenState,
1044
1112
  actionRef: actionRef
@@ -1050,7 +1118,7 @@ var ProTable = function ProTable(props) {
1050
1118
 
1051
1119
  }),
1052
1120
  ref: tableRef
1053
- }, renderTable(isFullScreen), (footerSuctionState && footerSuction && !fullscreenState || fixedTableBody) && /*#__PURE__*/_react.default.createElement(_pageContainer.default.FixedFooter, null, renderFooter()), !(footerSuctionState && footerSuction) && !fullscreenState && !fixedTableBody && renderFooter(), fullscreenState && renderFooter());
1121
+ }, renderTable(isFullScreen), fixFooterState && /*#__PURE__*/_react.default.createElement(_pageContainer.default.FixedFooter, null, renderFooter()), !fixFooterState && renderFooter());
1054
1122
  });
1055
1123
  };
1056
1124
 
@@ -32,6 +32,11 @@ $fullscreenPadding: 24px;
32
32
  display: flex;
33
33
  justify-content: flex-end;
34
34
  width: 100%;
35
+ & > span {
36
+ display: flex;
37
+ justify-content: flex-end;
38
+ width: 100%;
39
+ }
35
40
  }
36
41
  &-footer-action {
37
42
  margin-left: 16px;
@@ -69,7 +69,9 @@ export declare type ProTableProps = {
69
69
  /** 请求方法 */
70
70
  method?: Method;
71
71
  /** 请求参数 */
72
- params?: object;
72
+ params?: {
73
+ [propName: string]: any;
74
+ };
73
75
  /** sort 排序请求参数处理函数 */
74
76
  formatSort?: (sort: object) => object;
75
77
  /** 如需自定义调用参数格式,则可以设定此值在请求前对 params 进行自定义,如果返回false则可以阻止请求 */
@@ -55,8 +55,9 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
55
55
  var renderColumnsTitle = function renderColumnsTitle(item, actionRef) {
56
56
  var filterMode = item.filterMode,
57
57
  filters = item.filters,
58
+ dataSource = item.dataSource,
58
59
  dataIndex = item.dataIndex,
59
- dataSource = item.dataSource; // 为列过滤添加状态标题
60
+ valueType = item.valueType; // 为列过滤添加状态标题
60
61
 
61
62
  var getItemLabel = function getItemLabel() {
62
63
  if (filters && filterMode !== 'multiple') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamix/pro",
3
- "version": "1.4.12",
3
+ "version": "1.4.15",
4
4
  "description": "TeamixPro大包",
5
5
  "keywords": [
6
6
  "aliyun",