@teamix/pro 1.5.30 → 1.5.31

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 (35) hide show
  1. package/dist/pro.js +950 -568
  2. package/dist/pro.min.js +1 -1
  3. package/es/index.d.ts +1 -1
  4. package/es/index.js +1 -1
  5. package/es/table/components/Cell/index.d.ts +17 -0
  6. package/es/table/components/Cell/index.js +209 -0
  7. package/es/table/components/Layout/index.js +9 -7
  8. package/es/table/components/Pagination/index.d.ts +5 -4
  9. package/es/table/components/Pagination/index.js +5 -3
  10. package/es/table/components/TableContent/index.d.ts +7 -0
  11. package/es/table/components/TableContent/index.js +23 -0
  12. package/es/table/index.js +89 -115
  13. package/es/table/index.scss +1 -1
  14. package/es/table/typing.d.ts +2 -0
  15. package/es/table/utils/genAutoWidthColumns.js +42 -6
  16. package/es/table/utils/genProColumnToColumn.js +20 -2
  17. package/es/table/utils/processColumns.d.ts +8 -0
  18. package/es/table/utils/processColumns.js +39 -0
  19. package/lib/index.d.ts +1 -1
  20. package/lib/index.js +1 -1
  21. package/lib/table/components/Cell/index.d.ts +17 -0
  22. package/lib/table/components/Cell/index.js +214 -0
  23. package/lib/table/components/Layout/index.js +8 -6
  24. package/lib/table/components/Pagination/index.d.ts +5 -4
  25. package/lib/table/components/Pagination/index.js +4 -2
  26. package/lib/table/components/TableContent/index.d.ts +7 -0
  27. package/lib/table/components/TableContent/index.js +34 -0
  28. package/lib/table/index.js +91 -117
  29. package/lib/table/index.scss +1 -1
  30. package/lib/table/typing.d.ts +2 -0
  31. package/lib/table/utils/genAutoWidthColumns.js +42 -6
  32. package/lib/table/utils/genProColumnToColumn.js +19 -1
  33. package/lib/table/utils/processColumns.d.ts +8 -0
  34. package/lib/table/utils/processColumns.js +46 -0
  35. package/package.json +1 -1
package/es/table/index.js CHANGED
@@ -5,6 +5,9 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableTo
5
5
  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."); }
6
6
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7
7
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
8
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
9
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
11
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
9
12
  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."); }
10
13
  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); }
@@ -13,12 +16,10 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
13
16
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
17
  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; }
15
18
  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; }
16
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
18
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
- import React, { useState, useEffect, useRef, useMemo } from 'react';
19
+ import React, { useState, useEffect, useRef, useMemo, useCallback } from 'react';
20
20
  import { Table, Checkbox } from '@alicloudfe/components';
21
21
  import Pagination from './components/Pagination';
22
+ import TableContent from './components/TableContent';
22
23
  import genProColumnToColumn from './utils/genProColumnToColumn';
23
24
  import { getGlobalConfig, useRequest, request as utilResquest, getDeepValue, getMessage, pickProps, usePrefixCls, getTargetValue } from '@teamix/utils';
24
25
  import { ProSkeletonRaw as Skeleton } from '../skeleton';
@@ -26,10 +27,8 @@ import './index.scss';
26
27
  import Layout from './components/Layout';
27
28
  import { actionRefUseStateOn, emit, initActionRef, processDefaultFilter, useActionType } from './utils';
28
29
  import getTableProps from './utils/getTableProps';
29
- import getTableSortIcons from './utils/getTableSortIcons';
30
30
  import useTableSelection from './utils/useTableSelection';
31
31
  import FullScreen from './components/ToolBar/Fullscreen';
32
- import { EmptyContent } from '@teamix/pro-field';
33
32
  import { ProActionGroup } from '../actions';
34
33
  import classNames from 'classnames';
35
34
  import ProPageContainer from '../page-container';
@@ -38,42 +37,9 @@ import debounce from 'lodash.debounce';
38
37
  import CardView from './components/CardView';
39
38
  import { useUrlState } from '@teamix/hooks';
40
39
  import { getUrlStateFilter } from './utils/util';
40
+ import processColumns from './utils/processColumns';
41
41
  export * from './typing';
42
42
  var cls = usePrefixCls('teamix-pro-table');
43
- /**
44
- * 处理原生传入的 columns 以便于 选择列 方便处理
45
- * @param columns 原生传入的 columns
46
- * @returns
47
- */
48
- var processColumns = function processColumns(columns, initialColumns) {
49
- var _getGlobalConfig;
50
- var globalFilterColumns = (_getGlobalConfig = getGlobalConfig('ProTable')) === null || _getGlobalConfig === void 0 ? void 0 : _getGlobalConfig.filterColumns;
51
- var filterColumns = columns.filter(function (item) {
52
- return item.columnFilters !== false && (item === null || item === void 0 ? void 0 : item.hidden) !== true && (!globalFilterColumns || globalFilterColumns(_objectSpread({}, item)));
53
- });
54
- // 处理只剩一列批量选择的情况下宽度错乱问题
55
- if (filterColumns === null || filterColumns === void 0 ? void 0 : filterColumns.length) {
56
- var _initialColumns$;
57
- if ((filterColumns === null || filterColumns === void 0 ? void 0 : filterColumns.length) === 1) {
58
- var _filterColumns$, _filterColumns$2;
59
- if ((_filterColumns$ = filterColumns[0]) === null || _filterColumns$ === void 0 ? void 0 : _filterColumns$.width) {
60
- delete filterColumns[0].width;
61
- }
62
- if ((_filterColumns$2 = filterColumns[0]) === null || _filterColumns$2 === void 0 ? void 0 : _filterColumns$2.lock) {
63
- filterColumns[0].lock = false;
64
- }
65
- } else if (((_initialColumns$ = initialColumns[0]) === null || _initialColumns$ === void 0 ? void 0 : _initialColumns$.columnFilters) !== false) {
66
- var _initialColumns$2, _initialColumns$3;
67
- if ((_initialColumns$2 = initialColumns[0]) === null || _initialColumns$2 === void 0 ? void 0 : _initialColumns$2.width) {
68
- filterColumns[0].width = initialColumns[0].width;
69
- }
70
- if ((_initialColumns$3 = initialColumns[0]) === null || _initialColumns$3 === void 0 ? void 0 : _initialColumns$3.lock) {
71
- filterColumns[0].lock = initialColumns[0].lock;
72
- }
73
- }
74
- }
75
- return filterColumns;
76
- };
77
43
  /** 默认请求翻页参数 */
78
44
  var globalPageKey = 'currentPage';
79
45
  var globalPageSizeKey = 'pageSize';
@@ -198,7 +164,9 @@ var ProTable = function ProTable(props) {
198
164
  _useState12 = _slicedToArray(_useState11, 2),
199
165
  showSkeleton = _useState12[0],
200
166
  setShowSkeleton = _useState12[1]; // 首次加载,渲染骨架屏
201
- var skeletonDataSource = new Array(skeletonSize).fill({});
167
+ var skeletonDataSource = useMemo(function () {
168
+ return new Array(skeletonSize).fill({});
169
+ }, [skeletonSize]);
202
170
  var requestDataKey = method.toLowerCase() === 'get' ? 'params' : 'data';
203
171
  // 如果使用 customRequest 的话,内置 loading
204
172
  var _useState13 = useState(requestWhenMount),
@@ -214,8 +182,8 @@ var ProTable = function ProTable(props) {
214
182
  setFilteredColumns = _useState16[1];
215
183
  // 全局状态 : 自适应表格
216
184
  var autoWidth = useMemo(function () {
217
- var _getGlobalConfig2;
218
- return ((_getGlobalConfig2 = getGlobalConfig('ProTable')) === null || _getGlobalConfig2 === void 0 ? void 0 : _getGlobalConfig2.autoWidth) || autoWidthProp;
185
+ var _getGlobalConfig;
186
+ return ((_getGlobalConfig = getGlobalConfig('ProTable')) === null || _getGlobalConfig === void 0 ? void 0 : _getGlobalConfig.autoWidth) || autoWidthProp;
219
187
  }, [autoWidthProp]);
220
188
  // 判断是否有操作列,有的话则渲染一个 shadow dom
221
189
  var hasActionColumn = false;
@@ -405,8 +373,8 @@ var ProTable = function ProTable(props) {
405
373
  });
406
374
  // 全局状态 : 大数据截断
407
375
  var globalUseMaxData = useMemo(function () {
408
- var _getGlobalConfig3;
409
- return (_getGlobalConfig3 = getGlobalConfig('ProTable')) === null || _getGlobalConfig3 === void 0 ? void 0 : _getGlobalConfig3.useMaxData;
376
+ var _getGlobalConfig2;
377
+ return (_getGlobalConfig2 = getGlobalConfig('ProTable')) === null || _getGlobalConfig2 === void 0 ? void 0 : _getGlobalConfig2.useMaxData;
410
378
  }, []);
411
379
  // 非全屏状态下的
412
380
  var normalDataFilterFormRef = useRef();
@@ -745,7 +713,9 @@ var ProTable = function ProTable(props) {
745
713
  if (Number.isInteger(time) && time >= 1000) {
746
714
  autoRefreshTimerRef.current = setTimeout(function () {
747
715
  // 自动刷新不显示 loading
748
- _request({}, true);
716
+ // 当表格自适应时,自动刷新要显示 loading ,否则表格自适应会出问题
717
+ // setShowLoading(true)
718
+ _request({}, !autoWidth);
749
719
  }, Number(time));
750
720
  emit('PRO_TABLE_REFRESH_TIMER_FLAG', Number(time));
751
721
  }
@@ -830,7 +800,7 @@ var ProTable = function ProTable(props) {
830
800
  }
831
801
  });
832
802
  // 请求函数
833
- function _request(params, noLoading, filterParams, isReset) {
803
+ var _request = useCallback(function (params, noLoading, filterParams, isReset) {
834
804
  var _dataFilterFormRef$cu2, _actionRef$current$ge, _actionRef$current6, _actionRef$current6$g, _objectSpread3;
835
805
  // 首次渲染表格,获取 urlState 上的 表头 filter 数据
836
806
  if (bindUrl && (bindUrlProps === null || bindUrlProps === void 0 ? void 0 : bindUrlProps.headerFilters) !== false && dataRef.current.flag) {
@@ -934,7 +904,7 @@ var ProTable = function ProTable(props) {
934
904
  if (Number.isInteger(time) && time >= 1000) {
935
905
  autoRefreshTimerRef.current = setTimeout(function () {
936
906
  // 自动刷新不显示 loading
937
- _request(params, true);
907
+ _request(params, !autoWidth);
938
908
  }, Number(time));
939
909
  emit('PRO_TABLE_REFRESH_TIMER_FLAG', Number(time));
940
910
  }
@@ -945,57 +915,63 @@ var ProTable = function ProTable(props) {
945
915
  getData.run(requestData);
946
916
  }
947
917
  }
948
- }
949
- function onSort(dataIndex, order) {
918
+ }, [bindUrl, bindUrlProps, dataRef, url, customRequest]);
919
+ var onSort = useCallback(function (dataIndex, order) {
950
920
  var nextSort = _defineProperty({}, dataIndex, order);
951
921
  setSort(nextSort);
952
922
  _request(targetFormatSort(nextSort));
953
- }
923
+ }, [_request, targetFormatSort]);
954
924
  // 处理 dataFilter 中的 onFilter、onReset
955
- var dataFilter = _objectSpread(_objectSpread({
956
- mode: 'inline',
957
- forceClear: true
958
- }, propsDataFilter), {}, {
959
- onInit: (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onInit) || requestWhenMount ? function (values) {
960
- var _propsDataFilter$onIn;
961
- // 表单初始化请求处理
962
- propsDataFilter === null || propsDataFilter === void 0 ? void 0 : (_propsDataFilter$onIn = propsDataFilter.onInit) === null || _propsDataFilter$onIn === void 0 ? void 0 : _propsDataFilter$onIn.call(propsDataFilter, values);
963
- !fullscreenState && requestWhenMount && _request({}, false, values);
964
- return true;
965
- } : undefined,
966
- onFilter: function onFilter(values) {
967
- var _actionRef$current7, _actionRef$current7$c;
968
- // 全屏状态,判断全屏表单onFilter是否禁用
969
- if (fullscreenState && !filterEnableRef.current.fullscreen) {
970
- filterEnableRef.current.fullscreen = true;
971
- return;
972
- }
973
- // 非全屏状态,判断普通表单onFiler是否禁用
974
- if (!fullscreenState && !filterEnableRef.current.normal) {
975
- filterEnableRef.current.normal = true;
976
- return;
925
+ var dataFilter = useMemo(function () {
926
+ return _objectSpread(_objectSpread({
927
+ mode: 'inline',
928
+ forceClear: true
929
+ }, propsDataFilter), {}, {
930
+ onInit: (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onInit) || requestWhenMount ? function (values) {
931
+ var _propsDataFilter$onIn;
932
+ // 表单初始化请求处理
933
+ propsDataFilter === null || propsDataFilter === void 0 ? void 0 : (_propsDataFilter$onIn = propsDataFilter.onInit) === null || _propsDataFilter$onIn === void 0 ? void 0 : _propsDataFilter$onIn.call(propsDataFilter, values);
934
+ !fullscreenState && requestWhenMount && _request({}, false, values);
935
+ return true;
936
+ } : undefined,
937
+ onFilter: function onFilter(values) {
938
+ var _actionRef$current7, _actionRef$current7$c;
939
+ // 全屏状态,判断全屏表单onFilter是否禁用
940
+ if (fullscreenState && !filterEnableRef.current.fullscreen) {
941
+ filterEnableRef.current.fullscreen = true;
942
+ return;
943
+ }
944
+ // 非全屏状态,判断普通表单onFiler是否禁用
945
+ if (!fullscreenState && !filterEnableRef.current.normal) {
946
+ filterEnableRef.current.normal = true;
947
+ return;
948
+ }
949
+ (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onFilter) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onFilter(values));
950
+ // 搜索变化时,暂时先清空选择
951
+ (_actionRef$current7 = actionRef.current) === null || _actionRef$current7 === void 0 ? void 0 : (_actionRef$current7$c = _actionRef$current7.clearRowSelection) === null || _actionRef$current7$c === void 0 ? void 0 : _actionRef$current7$c.call(_actionRef$current7);
952
+ setCurrentPage(1);
953
+ _request(_defineProperty({}, targetPageKey, 1), false, values);
954
+ },
955
+ onReset: function onReset(values) {
956
+ var _dataFilterFormRef$cu3;
957
+ (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset());
958
+ (_dataFilterFormRef$cu3 = dataFilterFormRef.current) === null || _dataFilterFormRef$cu3 === void 0 ? void 0 : _dataFilterFormRef$cu3.reset();
959
+ setCurrentPage(1);
960
+ _request(_defineProperty({}, targetPageKey, 1), false, values);
977
961
  }
978
- (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onFilter) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onFilter(values));
979
- // 搜索变化时,暂时先清空选择
980
- (_actionRef$current7 = actionRef.current) === null || _actionRef$current7 === void 0 ? void 0 : (_actionRef$current7$c = _actionRef$current7.clearRowSelection) === null || _actionRef$current7$c === void 0 ? void 0 : _actionRef$current7$c.call(_actionRef$current7);
981
- setCurrentPage(1);
982
- _request(_defineProperty({}, targetPageKey, 1), false, values);
983
- },
984
- onReset: function onReset(values) {
985
- var _dataFilterFormRef$cu3;
986
- (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset());
987
- (_dataFilterFormRef$cu3 = dataFilterFormRef.current) === null || _dataFilterFormRef$cu3 === void 0 ? void 0 : _dataFilterFormRef$cu3.reset();
988
- setCurrentPage(1);
989
- _request(_defineProperty({}, targetPageKey, 1), false, values);
990
- }
991
- });
992
- var getTableLoading = function getTableLoading() {
962
+ });
963
+ }, [propsDataFilter, fullscreenState, filterEnableRef, actionRef]);
964
+ var isLoading = useMemo(function () {
993
965
  if (!customRequest) {
994
966
  return showLoading && !showSkeleton && (getData.loading || props.loading);
995
967
  } else {
996
968
  return showLoading && !showSkeleton && (customTableLoading || props.loading);
997
969
  }
998
- };
970
+ }, [customRequest, showLoading, showSkeleton, customTableLoading, props.loading, getData]);
971
+ var memorizedGenProColumnToColumn = useMemo(function () {
972
+ var result = genProColumnToColumn(filteredColumns, showSkeleton, actionRef, context, dataTeamixSpm, bindUrl, bindUrlProps);
973
+ return result;
974
+ }, [filteredColumns, showSkeleton, actionRef, context, dataTeamixSpm, bindUrl, bindUrlProps]);
999
975
  var renderTable = function renderTable(isFullScreen) {
1000
976
  if (propsColumns) {
1001
977
  return /*#__PURE__*/React.createElement("div", {
@@ -1022,11 +998,11 @@ var ProTable = function ProTable(props) {
1022
998
  autoRefreshProps: autoRefreshProps,
1023
999
  bindUrlProps: bindUrlProps,
1024
1000
  bindUrl: bindUrl
1025
- }), switchViewState === 'table' && /*#__PURE__*/React.createElement(Table.StickyLock, _objectSpread({
1001
+ }), switchViewState === 'table' && /*#__PURE__*/React.createElement(TableContent, _objectSpread({
1026
1002
  hasBorder: false,
1027
1003
  dataSource: showSkeleton ? skeletonDataSource : data || props.dataSource,
1028
- columns: genProColumnToColumn(filteredColumns, showSkeleton, actionRef, context, dataTeamixSpm, bindUrl, bindUrlProps),
1029
- loading: getTableLoading(),
1004
+ columns: memorizedGenProColumnToColumn,
1005
+ loading: isLoading,
1030
1006
  className: classNames('teamix-pro-table', tableClassName, {
1031
1007
  'with-row-select': rowSelection,
1032
1008
  'teamix-pro-tree-table': isTree
@@ -1037,14 +1013,12 @@ var ProTable = function ProTable(props) {
1037
1013
  sort: sort,
1038
1014
  primaryKey: primaryKey,
1039
1015
  rowSelection: rowSelection,
1040
- emptyContent: /*#__PURE__*/React.createElement(EmptyContent, _objectSpread({}, emptyProps)),
1041
- sortIcons: getTableSortIcons(),
1042
1016
  fixedHeader: fullscreenState || fixedTableBody,
1043
1017
  maxBodyHeight: "calc(100vh - ".concat(headerHeight, "px)")
1044
1018
  }, pickProps(getTableProps(), otherProps))), switchViewState === 'card' && /*#__PURE__*/React.createElement(CardView, {
1045
1019
  dataSource: showSkeleton ? skeletonDataSource : data || props.dataSource,
1046
1020
  showSkeleton: showSkeleton,
1047
- loading: getTableLoading(),
1021
+ loading: isLoading,
1048
1022
  originColumns: propsColumns,
1049
1023
  cardViewProps: cardViewProps,
1050
1024
  scrollHeight: fullscreenState || fixedTableBody ? "calc(100vh - ".concat(headerHeight, "px)") : undefined,
@@ -1086,28 +1060,28 @@ var ProTable = function ProTable(props) {
1086
1060
  })));
1087
1061
  } else return footerAction;
1088
1062
  };
1089
- var renderFooter = function renderFooter() {
1090
- function onChangePagination(currentPage) {
1091
- var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1092
- // 翻页默认清空选择
1093
- if (!reserveSelectedRecords) {
1094
- var _actionRef$current8, _actionRef$current8$c;
1095
- (_actionRef$current8 = actionRef.current) === null || _actionRef$current8 === void 0 ? void 0 : (_actionRef$current8$c = _actionRef$current8.clearRowSelection) === null || _actionRef$current8$c === void 0 ? void 0 : _actionRef$current8$c.call(_actionRef$current8);
1096
- }
1097
- setCurrentPage(currentPage);
1098
- _request(_objectSpread(_defineProperty({}, targetPageKey, currentPage), params));
1063
+ var onChangePagination = useCallback(function (currentPage) {
1064
+ var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1065
+ // 翻页默认清空选择
1066
+ if (!reserveSelectedRecords) {
1067
+ var _actionRef$current8, _actionRef$current8$c;
1068
+ (_actionRef$current8 = actionRef.current) === null || _actionRef$current8 === void 0 ? void 0 : (_actionRef$current8$c = _actionRef$current8.clearRowSelection) === null || _actionRef$current8$c === void 0 ? void 0 : _actionRef$current8$c.call(_actionRef$current8);
1099
1069
  }
1100
- function onChangePaginationSize(currentPageSize) {
1101
- var _request10;
1102
- // 翻页默认清空选择
1103
- if (!reserveSelectedRecords) {
1104
- var _actionRef$current9, _actionRef$current9$c;
1105
- (_actionRef$current9 = actionRef.current) === null || _actionRef$current9 === void 0 ? void 0 : (_actionRef$current9$c = _actionRef$current9.clearRowSelection) === null || _actionRef$current9$c === void 0 ? void 0 : _actionRef$current9$c.call(_actionRef$current9);
1106
- }
1107
- setPageSize(currentPageSize);
1108
- setCurrentPage(1);
1109
- _request((_request10 = {}, _defineProperty(_request10, targetPageSizeKey, currentPageSize), _defineProperty(_request10, targetPageKey, 1), _request10));
1070
+ setCurrentPage(currentPage);
1071
+ _request(_objectSpread(_defineProperty({}, targetPageKey, currentPage), params));
1072
+ }, [reserveSelectedRecords, targetPageKey, actionRef]);
1073
+ var onChangePaginationSize = useCallback(function (currentPageSize) {
1074
+ var _request10;
1075
+ // 翻页默认清空选择
1076
+ if (!reserveSelectedRecords) {
1077
+ var _actionRef$current9, _actionRef$current9$c;
1078
+ (_actionRef$current9 = actionRef.current) === null || _actionRef$current9 === void 0 ? void 0 : (_actionRef$current9$c = _actionRef$current9.clearRowSelection) === null || _actionRef$current9$c === void 0 ? void 0 : _actionRef$current9$c.call(_actionRef$current9);
1110
1079
  }
1080
+ setPageSize(currentPageSize);
1081
+ setCurrentPage(1);
1082
+ _request((_request10 = {}, _defineProperty(_request10, targetPageSizeKey, currentPageSize), _defineProperty(_request10, targetPageKey, 1), _request10));
1083
+ }, [reserveSelectedRecords, actionRef, targetPageSizeKey, targetPageKey]);
1084
+ var renderFooter = function renderFooter() {
1111
1085
  function renderRowSelection() {
1112
1086
  if (rowSelection) {
1113
1087
  if (showSkeleton) {
@@ -103,7 +103,7 @@ $fullscreenPadding: 24px;
103
103
  pointer-events: none;
104
104
  display: flex;
105
105
  }
106
-
106
+
107
107
  // sort icon
108
108
  .next-table-sort.next-table-header-icon {
109
109
  line-height: 16px;
@@ -24,6 +24,8 @@ declare type TDataService = {
24
24
  };
25
25
  export declare type responsivePaginationType = 'mini' | 'small' | 'simple' | 'normal';
26
26
  export declare type ProTableColumnProps = {
27
+ /** 是否开启了自动计算宽度 */
28
+ isAutoWidth?: boolean;
27
29
  /** 自动计算宽度时的被挤占的情况 */
28
30
  shrink?: number;
29
31
  /** 是否自动适应该列宽度 */
@@ -36,11 +36,12 @@ export function genAutoWidthColumns(fileteredColumns, ref, data, size, useRowSel
36
36
  var childNodes = dom.children;
37
37
  var finalColumns = [];
38
38
  fileteredColumns.forEach(function (column, index) {
39
+ var _childNodes$index;
39
40
  var render = column.render,
40
41
  _column$valueType = column.valueType,
41
42
  valueType = _column$valueType === void 0 ? 'text' : _column$valueType,
42
- _column$autoWidth = column.autoWidth,
43
- autoWidth = _column$autoWidth === void 0 ? true : _column$autoWidth,
43
+ _column$isAutoWidth = column.isAutoWidth,
44
+ isAutoWidth = _column$isAutoWidth === void 0 ? true : _column$isAutoWidth,
44
45
  actionSchema = column.actionSchema,
45
46
  sortable = column.sortable,
46
47
  lock = column.lock;
@@ -52,6 +53,17 @@ export function genAutoWidthColumns(fileteredColumns, ref, data, size, useRowSel
52
53
  var finalType = type || valueType || '';
53
54
  var shrink = fieldTypeShrink[finalType];
54
55
  column.shrink = column.shrink || (shrink !== undefined ? shrink : 1);
56
+ if ((column === null || column === void 0 ? void 0 : column.isAutoWidth) === false) {
57
+ // console.log(column.title, 'isAutoWidth')
58
+ finalColumns.push(column);
59
+ return;
60
+ }
61
+ ;
62
+ if ((column === null || column === void 0 ? void 0 : column.columnFilters) === false) {
63
+ finalColumns.push(column);
64
+ return;
65
+ }
66
+ // column.isAutoWidth = true
55
67
  //@ts-ignore
56
68
  // if (!autoWidth) {
57
69
  // finalColumns.push(column);
@@ -72,13 +84,20 @@ export function genAutoWidthColumns(fileteredColumns, ref, data, size, useRowSel
72
84
  if (width >= 280) {
73
85
  width = 280;
74
86
  }
87
+ column.isAutoWidth = false;
75
88
  column.width = defaultPaddingFixer(width, size, false);
76
89
  }
77
90
  finalColumns.push(column);
78
91
  return;
79
92
  }
93
+ // 当列没出来的时候不比较
80
94
  // @ts-ignore
81
- var titleWidth = childNodes[index].children[0].scrollWidth;
95
+ if ((column === null || column === void 0 ? void 0 : column.columnFilters) === false) {
96
+ finalColumns.push(column);
97
+ return;
98
+ }
99
+ // @ts-ignore
100
+ var titleWidth = (_childNodes$index = childNodes[index]) === null || _childNodes$index === void 0 ? void 0 : _childNodes$index.children[0].scrollWidth;
82
101
  // @ts-ignore
83
102
  if (fixedWidthTypeList[finalType]) {
84
103
  // console.log(
@@ -86,20 +105,32 @@ export function genAutoWidthColumns(fileteredColumns, ref, data, size, useRowSel
86
105
  // fixedWidthTypeList[finalType],
87
106
  // );
88
107
  // 固定宽度
108
+ // console.log(column.title, '固定宽度')
109
+ column.isAutoWidth = false;
89
110
  column.width = defaultPaddingFixer(
90
111
  // @ts-ignore
91
112
  Math.max(titleWidth, fixedWidthTypeList[finalType]), size, index === 0 && useRowSelection);
92
113
  // @ts-ignore
93
114
  } else if (computeableWidthTypeList[finalType]) {
94
115
  // 可计算宽度
116
+ // console.log(column.title, '可计算宽度')
117
+ column.isAutoWidth = false;
95
118
  column.width = defaultPaddingFixer(
96
119
  // @ts-ignore
97
120
  Math.max(titleWidth, computeableWidthTypeList[finalType](data, render)), size, index === 0 && useRowSelection);
98
121
  } else {
99
122
  // 直接根据 dom 计算
123
+ // console.log(column.title, '可计算 dom')
124
+ column.isAutoWidth = false;
100
125
  column.width = defaultPaddingFixer(Math.max(titleWidth,
101
126
  // @ts-ignore
102
127
  calcWidthWithParentDOM(childNodes[index], column.shrink)), size, index === 0 && useRowSelection);
128
+ if ((column === null || column === void 0 ? void 0 : column.sortable) && ((column === null || column === void 0 ? void 0 : column.tooltip) || (column === null || column === void 0 ? void 0 : column.filters))) {
129
+ // 检测有 sortable 和 tooltip 的时候增加宽度
130
+ column.width = column.width + 40;
131
+ } else if (column === null || column === void 0 ? void 0 : column.sortable) {
132
+ column.width = column.width + 24;
133
+ }
103
134
  }
104
135
  if (index === 0) {
105
136
  // 首列不会被挤占
@@ -136,8 +167,12 @@ export var shadowContainer = function shadowContainer(props) {
136
167
  //@ts-ignore
137
168
  !fixedWidthTypeList[valueType] && data.map(function (item, index) {
138
169
  // @ts-ignore
139
- column.smartWidth = renderCellSmartWidth(getValueFromRecord(dataIndex, item), column, index, item);
140
- return renderCell(getValueFromRecord(dataIndex, item), column, index, item);
170
+ var newColumn = _.cloneDeep(column);
171
+ newColumn.smartWidth = renderCellSmartWidth(getValueFromRecord(dataIndex, item), column, index, item);
172
+ newColumn.render = _objectSpread(_objectSpread({}, column.render), {}, {
173
+ description: ''
174
+ });
175
+ return renderCell(getValueFromRecord(dataIndex, item), newColumn, index, item);
141
176
  }));
142
177
  }
143
178
  }));
@@ -300,7 +335,8 @@ function defaultPaddingFixer(width) {
300
335
  }
301
336
  function sum() {
302
337
  var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
303
- return list.reduce(function (a, b) {
338
+ if (list.length === 0) return 0;
339
+ return list === null || list === void 0 ? void 0 : list.reduce(function (a, b) {
304
340
  return a + b;
305
341
  });
306
342
  }
@@ -5,9 +5,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
5
5
  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; }
6
6
  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; }
7
7
  import React from 'react';
8
- import { renderColumnsTitle, renderCell } from './columnRender';
8
+ import { renderColumnsTitle } from './columnRender';
9
9
  import { ProSkeletonRaw as Skeleton } from '../../skeleton';
10
10
  import { getLanguage } from '@teamix/utils';
11
+ import Cell from '../components/Cell';
11
12
  /**
12
13
  * ProColumn => Column
13
14
  */
@@ -44,7 +45,24 @@ showSkeleton, actionRef) {
44
45
  dataIndex: dataIndex === null || dataIndex === void 0 ? void 0 : dataIndex.toString(),
45
46
  title: renderColumnsTitle(columnProps, actionRef, bindUrl, bindUrlProps),
46
47
  cell: function cell(value, index, record) {
47
- return renderCell(value, columnProps, index, record, actionRef, context, dataTeamixSpm);
48
+ return /*#__PURE__*/React.createElement(Cell, {
49
+ value: value,
50
+ item: columnProps,
51
+ index: index,
52
+ record: record,
53
+ actionRef: actionRef,
54
+ context: context,
55
+ dataTeamixSpm: dataTeamixSpm
56
+ });
57
+ // return renderCell(
58
+ // value,
59
+ // columnProps,
60
+ // index,
61
+ // record,
62
+ // actionRef,
63
+ // context,
64
+ // dataTeamixSpm
65
+ // )
48
66
  }
49
67
  });
50
68
  });
@@ -0,0 +1,8 @@
1
+ import { ProTableColumnProps } from '../typing';
2
+ /**
3
+ * 处理原生传入的 columns 以便于 选择列 方便处理
4
+ * @param columns 原生传入的 columns
5
+ * @returns
6
+ */
7
+ declare const processColumns: (columns: ProTableColumnProps[], initialColumns: ProTableColumnProps[]) => ProTableColumnProps[];
8
+ export default processColumns;
@@ -0,0 +1,39 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ import { getGlobalConfig } from '@teamix/utils';
5
+ /**
6
+ * 处理原生传入的 columns 以便于 选择列 方便处理
7
+ * @param columns 原生传入的 columns
8
+ * @returns
9
+ */
10
+ var processColumns = function processColumns(columns, initialColumns) {
11
+ var _getGlobalConfig;
12
+ var globalFilterColumns = (_getGlobalConfig = getGlobalConfig('ProTable')) === null || _getGlobalConfig === void 0 ? void 0 : _getGlobalConfig.filterColumns;
13
+ var filterColumns = columns.filter(function (item) {
14
+ return item.columnFilters !== false && (item === null || item === void 0 ? void 0 : item.hidden) !== true && (!globalFilterColumns || globalFilterColumns(_objectSpread({}, item)));
15
+ });
16
+ // 处理只剩一列批量选择的情况下宽度错乱问题
17
+ if (filterColumns === null || filterColumns === void 0 ? void 0 : filterColumns.length) {
18
+ var _initialColumns$;
19
+ if ((filterColumns === null || filterColumns === void 0 ? void 0 : filterColumns.length) === 1) {
20
+ var _filterColumns$, _filterColumns$2;
21
+ if ((_filterColumns$ = filterColumns[0]) === null || _filterColumns$ === void 0 ? void 0 : _filterColumns$.width) {
22
+ delete filterColumns[0].width;
23
+ }
24
+ if ((_filterColumns$2 = filterColumns[0]) === null || _filterColumns$2 === void 0 ? void 0 : _filterColumns$2.lock) {
25
+ filterColumns[0].lock = false;
26
+ }
27
+ } else if (((_initialColumns$ = initialColumns[0]) === null || _initialColumns$ === void 0 ? void 0 : _initialColumns$.columnFilters) !== false) {
28
+ var _initialColumns$2, _initialColumns$3;
29
+ if ((_initialColumns$2 = initialColumns[0]) === null || _initialColumns$2 === void 0 ? void 0 : _initialColumns$2.width) {
30
+ filterColumns[0].width = initialColumns[0].width;
31
+ }
32
+ if ((_initialColumns$3 = initialColumns[0]) === null || _initialColumns$3 === void 0 ? void 0 : _initialColumns$3.lock) {
33
+ filterColumns[0].lock = initialColumns[0].lock;
34
+ }
35
+ }
36
+ }
37
+ return filterColumns;
38
+ };
39
+ export default processColumns;
package/lib/index.d.ts CHANGED
@@ -30,5 +30,5 @@ export * from './sidebar';
30
30
  export * from './utils';
31
31
  export * from './timeline';
32
32
  export * from './image';
33
- declare const version = "1.5.30";
33
+ declare const version = "1.5.31";
34
34
  export { version, ProAction, ProCard, ProField, ProForm, ProInfo, ProPageContainer, ProPageHeader, ProSkeleton, ProTable, ProSidebar, ProTimeline, TeamixIcon, ProImage, hooks, nocode, templates, utils, };
package/lib/index.js CHANGED
@@ -299,7 +299,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
299
299
  if (!((_window = window) === null || _window === void 0 ? void 0 : _window.TEAMIXPRO_WITHOUT_ICON)) {
300
300
  _icon.default.setConfig(_utils.default.getTeamixIconConfig());
301
301
  }
302
- var version = '1.5.30';
302
+ var version = '1.5.31';
303
303
  // By TeamixTest
304
304
  exports.version = version;
305
305
  window.postMessage({
@@ -0,0 +1,17 @@
1
+ /**
2
+ * 渲染列的逻辑函数
3
+ */
4
+ import React from 'react';
5
+ import { ProTableColumnProps, ProTableActionType } from '../../typing';
6
+ interface ICellProps {
7
+ value: any;
8
+ item: ProTableColumnProps;
9
+ index: number;
10
+ record: any;
11
+ actionRef: React.MutableRefObject<ProTableActionType | undefined>;
12
+ /** 接收外部比如 dialog-table 传过来的 context,用于弹窗关闭等 */
13
+ context?: any;
14
+ dataTeamixSpm?: string;
15
+ }
16
+ declare const _default: React.MemoExoticComponent<(props: ICellProps) => JSX.Element>;
17
+ export default _default;