@teamix/pro 1.5.0 → 1.5.1
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.
- package/dist/pro.css +1 -1
- package/dist/pro.js +1103 -123
- package/dist/pro.min.css +1 -1
- package/dist/pro.min.js +1 -1
- package/es/actions/index.d.ts +4 -0
- package/es/actions/index.js +34 -9
- package/es/actions/index.scss +5 -0
- package/es/card/index.scss +7 -0
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/sidebar/components/tree-node/components/IconSwitch/index.d.ts +2 -2
- package/es/sidebar/components/tree-node/components/IconSwitch/index.scss +1 -1
- package/es/sidebar/index.d.ts +2 -0
- package/es/sidebar/index.js +3 -1
- package/es/table/components/CardView/index.d.ts +5 -0
- package/es/table/components/CardView/index.js +446 -0
- package/es/table/components/CardView/index.scss +46 -0
- package/es/table/components/Filter/index.d.ts +1 -0
- package/es/table/components/Filter/index.js +21 -14
- package/es/table/components/Layout/index.js +4 -2
- package/es/table/components/LoadMore/index.d.ts +20 -0
- package/es/table/components/LoadMore/index.js +107 -0
- package/es/table/components/LoadMore/index.scss +19 -0
- package/es/table/components/QuickAction/index.d.ts +1 -0
- package/es/table/components/ToolBar/CardSwitch.d.ts +8 -0
- package/es/table/components/ToolBar/CardSwitch.js +63 -0
- package/es/table/components/ToolBar/FilterColumnIcon.js +13 -2
- package/es/table/components/ToolBar/Fullscreen.js +15 -2
- package/es/table/components/ToolBar/index.js +64 -33
- package/es/table/components/ToolBar/index.scss +10 -1
- package/es/table/index.js +132 -34
- package/es/table/typing.d.ts +69 -0
- package/es/table/utils/columnRender.d.ts +1 -1
- package/es/table/utils/columnRender.js +4 -2
- package/es/table/utils/genProColumnToColumn.d.ts +1 -1
- package/es/table/utils/genProColumnToColumn.js +3 -1
- package/lib/actions/index.d.ts +4 -0
- package/lib/actions/index.js +33 -9
- package/lib/actions/index.scss +5 -0
- package/lib/card/index.scss +7 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/sidebar/components/tree-node/components/IconSwitch/index.d.ts +2 -2
- package/lib/sidebar/components/tree-node/components/IconSwitch/index.scss +1 -1
- package/lib/sidebar/index.d.ts +2 -0
- package/lib/sidebar/index.js +12 -1
- package/lib/table/components/CardView/index.d.ts +5 -0
- package/lib/table/components/CardView/index.js +468 -0
- package/lib/table/components/CardView/index.scss +46 -0
- package/lib/table/components/Filter/index.d.ts +1 -0
- package/lib/table/components/Filter/index.js +21 -14
- package/lib/table/components/Layout/index.js +4 -2
- package/lib/table/components/LoadMore/index.d.ts +20 -0
- package/lib/table/components/LoadMore/index.js +128 -0
- package/lib/table/components/LoadMore/index.scss +19 -0
- package/lib/table/components/QuickAction/index.d.ts +1 -0
- package/lib/table/components/ToolBar/CardSwitch.d.ts +8 -0
- package/lib/table/components/ToolBar/CardSwitch.js +82 -0
- package/lib/table/components/ToolBar/FilterColumnIcon.js +13 -2
- package/lib/table/components/ToolBar/Fullscreen.js +15 -2
- package/lib/table/components/ToolBar/index.js +65 -32
- package/lib/table/components/ToolBar/index.scss +10 -1
- package/lib/table/index.js +134 -34
- package/lib/table/typing.d.ts +69 -0
- package/lib/table/utils/columnRender.d.ts +1 -1
- package/lib/table/utils/columnRender.js +4 -2
- package/lib/table/utils/genProColumnToColumn.d.ts +1 -1
- package/lib/table/utils/genProColumnToColumn.js +3 -1
- package/package.json +1 -1
package/es/table/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
var _excluded = ["header", "className", "tableClassName", "mainAction", "extra", "dataFilter", "afterDataFilter", "toolBar", "columns", "useRowSelection", "rowSelection", "onChangeRowSelection", "getRowSelection", "primaryKey", "footerAction", "footer", "url", "pageKey", "pageSizeKey", "method", "params", "formatSort", "formatParams", "formatResult", "requestConfig", "requestWhenMount", "showPagination", "pageSizeList", "responsivePaginationType", "showSkeleton", "skeletonSize", "actionRef", "dataSource", "filterDebounce", "footerSuction", "autoRefresh", "customRequest", "filterColumnType", "defaultFilterParams", "reserveSelectedRecords", "size", "disableSelectAll", "context", "fixedTableBody", "isTree"];
|
1
|
+
var _excluded = ["header", "className", "tableClassName", "mainAction", "extra", "dataFilter", "afterDataFilter", "toolBar", "columns", "useRowSelection", "rowSelection", "onChangeRowSelection", "getRowSelection", "primaryKey", "footerAction", "footer", "url", "pageKey", "pageSizeKey", "method", "params", "formatSort", "formatParams", "formatResult", "requestConfig", "requestWhenMount", "showPagination", "pageSizeList", "responsivePaginationType", "showSkeleton", "skeletonSize", "actionRef", "dataSource", "filterDebounce", "footerSuction", "autoRefresh", "customRequest", "filterColumnType", "defaultFilterParams", "reserveSelectedRecords", "size", "disableSelectAll", "context", "fixedTableBody", "isTree", "toolBarAutoWidth", "data-teamix-spm", "switchCardView", "cardViewProps", "defaultView"];
|
2
2
|
|
3
3
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
4
4
|
|
@@ -50,6 +50,8 @@ import { ProActionGroup } from '../actions';
|
|
50
50
|
import classNames from 'classnames';
|
51
51
|
import ProPageContainer from '../page-container';
|
52
52
|
import debounce from 'lodash.debounce';
|
53
|
+
import CardView from './components/CardView';
|
54
|
+
import columns from '../../demos/table/columns';
|
53
55
|
export * from './typing';
|
54
56
|
var cls = usePrefixCls('teamix-pro-table');
|
55
57
|
/**
|
@@ -177,6 +179,14 @@ var ProTable = function ProTable(props) {
|
|
177
179
|
_props$fixedTableBody = props.fixedTableBody,
|
178
180
|
fixedTableBody = _props$fixedTableBody === void 0 ? false : _props$fixedTableBody,
|
179
181
|
isTree = props.isTree,
|
182
|
+
_props$toolBarAutoWid = props.toolBarAutoWidth,
|
183
|
+
toolBarAutoWidth = _props$toolBarAutoWid === void 0 ? true : _props$toolBarAutoWid,
|
184
|
+
dataTeamixSpm = props['data-teamix-spm'],
|
185
|
+
_props$switchCardView = props.switchCardView,
|
186
|
+
switchCardView = _props$switchCardView === void 0 ? false : _props$switchCardView,
|
187
|
+
cardViewProps = props.cardViewProps,
|
188
|
+
_props$defaultView = props.defaultView,
|
189
|
+
defaultView = _props$defaultView === void 0 ? 'table' : _props$defaultView,
|
180
190
|
otherProps = _objectWithoutProperties(props, _excluded);
|
181
191
|
|
182
192
|
var targetPageKey = pageKey || globalPageKey;
|
@@ -201,7 +211,7 @@ var ProTable = function ProTable(props) {
|
|
201
211
|
var _useState7 = useState(propsDataSource !== null && propsDataSource !== void 0 ? propsDataSource : []),
|
202
212
|
_useState8 = _slicedToArray(_useState7, 2),
|
203
213
|
data = _useState8[0],
|
204
|
-
|
214
|
+
_setData = _useState8[1];
|
205
215
|
|
206
216
|
var _useState9 = useState(props.sort || {}),
|
207
217
|
_useState10 = _slicedToArray(_useState9, 2),
|
@@ -353,7 +363,11 @@ var ProTable = function ProTable(props) {
|
|
353
363
|
|
354
364
|
var offsetHeaderHeight = headerHeight + tableHeaderHeight + pageHeaderHeight + teamixNavHeight + footerRowSelectionHeight + 16 + (offset !== null && offset !== void 0 ? offset : 0) + 1;
|
355
365
|
|
356
|
-
if (
|
366
|
+
if (switchViewState === 'card') {
|
367
|
+
offsetHeaderHeight = offsetHeaderHeight - tableHeaderHeight - footerRowSelectionHeight;
|
368
|
+
}
|
369
|
+
|
370
|
+
if ((tableBodyDom === null || tableBodyDom === void 0 ? void 0 : tableBodyDom.clientHeight) < (tableBodyDom === null || tableBodyDom === void 0 ? void 0 : tableBodyDom.scrollHeight)) {
|
357
371
|
setFooterSuctionState(true);
|
358
372
|
} else {
|
359
373
|
setFooterSuctionState(false);
|
@@ -388,7 +402,13 @@ var ProTable = function ProTable(props) {
|
|
388
402
|
var _useState27 = useState(false),
|
389
403
|
_useState28 = _slicedToArray(_useState27, 2),
|
390
404
|
fullscreenState = _useState28[0],
|
391
|
-
setFullscreenState = _useState28[1]; //
|
405
|
+
setFullscreenState = _useState28[1]; // 切换视角
|
406
|
+
|
407
|
+
|
408
|
+
var _useState29 = useState(defaultView !== null && defaultView !== void 0 ? defaultView : 'table'),
|
409
|
+
_useState30 = _slicedToArray(_useState29, 2),
|
410
|
+
switchViewState = _useState30[0],
|
411
|
+
setSwitchViewState = _useState30[1]; // 切换全屏搜索开关
|
392
412
|
|
393
413
|
|
394
414
|
var filterEnableRef = useRef({
|
@@ -404,10 +424,10 @@ var ProTable = function ProTable(props) {
|
|
404
424
|
var dataFilterFormRef = !fullscreenState ? normalDataFilterFormRef : fullscreenDataFilterFormRef; // let dataFilterForm = dataFilterFormRef.current;
|
405
425
|
// 整个内容区是否超过一屏。用于表格在非全屏模式下的吸底
|
406
426
|
|
407
|
-
var
|
408
|
-
|
409
|
-
footerSuctionState =
|
410
|
-
setFooterSuctionState =
|
427
|
+
var _useState31 = useState(false),
|
428
|
+
_useState32 = _slicedToArray(_useState31, 2),
|
429
|
+
footerSuctionState = _useState32[0],
|
430
|
+
setFooterSuctionState = _useState32[1]; // TODO 获取内容区是否超出一屏(暂时仅支持全家桶)
|
411
431
|
|
412
432
|
|
413
433
|
var getFooterSuctionState = function getFooterSuctionState() {
|
@@ -532,7 +552,7 @@ var ProTable = function ProTable(props) {
|
|
532
552
|
|
533
553
|
useEffect(function () {
|
534
554
|
if (propsDataSource) {
|
535
|
-
|
555
|
+
_setData(propsDataSource);
|
536
556
|
}
|
537
557
|
}, [propsDataSource]); // 初始化 ActionRef。
|
538
558
|
|
@@ -599,7 +619,16 @@ var ProTable = function ProTable(props) {
|
|
599
619
|
_setSize(mode);
|
600
620
|
},
|
601
621
|
refresh: function refresh(params) {
|
602
|
-
|
622
|
+
// card视角的刷新等于重新请求
|
623
|
+
if (switchViewState === 'card') {
|
624
|
+
setCurrentPage(1);
|
625
|
+
|
626
|
+
_request(_objectSpread(_objectSpread({}, params), {}, _defineProperty({}, targetPageKey, 1)));
|
627
|
+
|
628
|
+
setShowSkeleton(true);
|
629
|
+
} else {
|
630
|
+
_request(params);
|
631
|
+
}
|
603
632
|
},
|
604
633
|
request: function request(params) {
|
605
634
|
// 如果请求中还有翻页相关信息,需要自动设置到指定页
|
@@ -627,6 +656,12 @@ var ProTable = function ProTable(props) {
|
|
627
656
|
resetPage: function resetPage() {
|
628
657
|
setCurrentPage(1);
|
629
658
|
},
|
659
|
+
nextPage: function nextPage() {
|
660
|
+
var newCurrentPage = currentPage + 1;
|
661
|
+
setCurrentPage(newCurrentPage);
|
662
|
+
|
663
|
+
_request(_defineProperty({}, targetPageKey, newCurrentPage));
|
664
|
+
},
|
630
665
|
rowSelection: rowSelection,
|
631
666
|
clearRowSelection: function clearRowSelection() {
|
632
667
|
rowSelectionHook.setSelectedRowKeys([]);
|
@@ -646,8 +681,34 @@ var ProTable = function ProTable(props) {
|
|
646
681
|
normalDataFilterForm: normalDataFilterForm,
|
647
682
|
fullscreenDataFilterForm: fullscreenDataFilterForm,
|
648
683
|
filterEnableRef: filterEnableRef,
|
684
|
+
setData: function setData(data) {
|
685
|
+
_setData(data);
|
686
|
+
},
|
649
687
|
resetTableMaxBodyHeight: function resetTableMaxBodyHeight(offset) {
|
650
688
|
getHeaderHeight(fullscreenState, offset);
|
689
|
+
},
|
690
|
+
switchView: function switchView(view) {
|
691
|
+
setSwitchViewState(view);
|
692
|
+
setShowSkeleton(true);
|
693
|
+
setCurrentPage(1);
|
694
|
+
|
695
|
+
if (view === 'table') {
|
696
|
+
var _request4;
|
697
|
+
|
698
|
+
setPageSize(pageSize !== null && pageSize !== void 0 ? pageSize : 20);
|
699
|
+
|
700
|
+
_request((_request4 = {}, _defineProperty(_request4, targetPageSizeKey, pageSize !== null && pageSize !== void 0 ? pageSize : 20), _defineProperty(_request4, targetPageKey, 1), _request4));
|
701
|
+
}
|
702
|
+
|
703
|
+
if (view === 'card') {
|
704
|
+
var _cardViewProps$pageSi, _cardViewProps$pageSi2, _request5;
|
705
|
+
|
706
|
+
setPageSize((_cardViewProps$pageSi = cardViewProps === null || cardViewProps === void 0 ? void 0 : cardViewProps.pageSize) !== null && _cardViewProps$pageSi !== void 0 ? _cardViewProps$pageSi : 12);
|
707
|
+
|
708
|
+
_request((_request5 = {}, _defineProperty(_request5, targetPageSizeKey, (_cardViewProps$pageSi2 = cardViewProps === null || cardViewProps === void 0 ? void 0 : cardViewProps.pageSize) !== null && _cardViewProps$pageSi2 !== void 0 ? _cardViewProps$pageSi2 : 12), _defineProperty(_request5, targetPageKey, 1), _request5));
|
709
|
+
}
|
710
|
+
|
711
|
+
getHeaderHeight(fullscreenState);
|
651
712
|
}
|
652
713
|
}); // 将 Actions 绑定到传入的 propsActionRef 中
|
653
714
|
|
@@ -656,8 +717,6 @@ var ProTable = function ProTable(props) {
|
|
656
717
|
}
|
657
718
|
|
658
719
|
function onFormatResult(next) {
|
659
|
-
var _next$data;
|
660
|
-
|
661
720
|
props.onFormatResult && props.onFormatResult(next);
|
662
721
|
var time = autoRefresh ? autoRefresh(next.data) : false;
|
663
722
|
|
@@ -669,8 +728,22 @@ var ProTable = function ProTable(props) {
|
|
669
728
|
} // 设置 dataSource、total
|
670
729
|
|
671
730
|
|
672
|
-
|
673
|
-
|
731
|
+
if (switchViewState === 'table' || currentPage === 1) {
|
732
|
+
var _next$data;
|
733
|
+
|
734
|
+
_setData(next.data || []);
|
735
|
+
|
736
|
+
setTotal(next.total || ((_next$data = next.data) === null || _next$data === void 0 ? void 0 : _next$data.length));
|
737
|
+
}
|
738
|
+
|
739
|
+
if (switchViewState === 'card' && currentPage !== 1) {
|
740
|
+
var _next$data2;
|
741
|
+
|
742
|
+
_setData([].concat(_toConsumableArray(data), _toConsumableArray(next.data || [])));
|
743
|
+
|
744
|
+
setTotal(total + (next.total || ((_next$data2 = next.data) === null || _next$data2 === void 0 ? void 0 : _next$data2.length)));
|
745
|
+
}
|
746
|
+
|
674
747
|
setShowSkeleton(false);
|
675
748
|
} // 请求表格数据工具函数
|
676
749
|
|
@@ -742,7 +815,7 @@ var ProTable = function ProTable(props) {
|
|
742
815
|
}); // 请求函数
|
743
816
|
|
744
817
|
function _request(params, noLoading, filterParams) {
|
745
|
-
var _dataFilterFormRef$cu2, _actionRef$current$ge, _actionRef$current5, _actionRef$current5$g,
|
818
|
+
var _dataFilterFormRef$cu2, _actionRef$current$ge, _actionRef$current5, _actionRef$current5$g, _objectSpread3;
|
746
819
|
|
747
820
|
// 如果没有传 url 且没有 customRequest,直接返回
|
748
821
|
if (!url && !customRequest) {
|
@@ -759,7 +832,7 @@ var ProTable = function ProTable(props) {
|
|
759
832
|
|
760
833
|
var columnsFilterParams = (_actionRef$current$ge = (_actionRef$current5 = actionRef.current) === null || _actionRef$current5 === void 0 ? void 0 : (_actionRef$current5$g = _actionRef$current5.getFilterRules) === null || _actionRef$current5$g === void 0 ? void 0 : _actionRef$current5$g.call(_actionRef$current5)) !== null && _actionRef$current$ge !== void 0 ? _actionRef$current$ge : {}; // 格式化后的请求参数
|
761
834
|
|
762
|
-
var requestData = formatParams(_objectSpread(_objectSpread({}, !showPagination ? _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, dataFilterParams), propsParams), sortParams), columnsFilterParams) : _objectSpread(_objectSpread(_objectSpread(_objectSpread((
|
835
|
+
var requestData = formatParams(_objectSpread(_objectSpread({}, !showPagination ? _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, dataFilterParams), propsParams), sortParams), columnsFilterParams) : _objectSpread(_objectSpread(_objectSpread(_objectSpread((_objectSpread3 = {}, _defineProperty(_objectSpread3, targetPageKey, currentPage), _defineProperty(_objectSpread3, targetPageSizeKey, pageSize), _objectSpread3), dataFilterParams), propsParams), sortParams), columnsFilterParams)), params));
|
763
836
|
|
764
837
|
if (requestData) {
|
765
838
|
if (autoRefreshTimerRef.current) {
|
@@ -787,14 +860,24 @@ var ProTable = function ProTable(props) {
|
|
787
860
|
if (customRequest && typeof customRequest === 'function') {
|
788
861
|
setCustomTableLoading(true);
|
789
862
|
customRequest(requestData).then(function (res) {
|
790
|
-
var
|
791
|
-
|
863
|
+
var dataRes = res.data,
|
864
|
+
totalRes = res.total,
|
792
865
|
success = res.success;
|
793
866
|
|
794
867
|
if (success === true) {
|
795
868
|
// 设置 dataSource、total
|
796
|
-
|
797
|
-
|
869
|
+
if (switchViewState === 'table' || params['targetPageKey'] === 1) {
|
870
|
+
_setData(dataRes || []);
|
871
|
+
|
872
|
+
setTotal(totalRes || (dataRes === null || dataRes === void 0 ? void 0 : dataRes.length));
|
873
|
+
}
|
874
|
+
|
875
|
+
if (switchViewState === 'card' && params['targetPageKey'] !== 1) {
|
876
|
+
_setData([].concat(_toConsumableArray(data), _toConsumableArray(dataRes || [])));
|
877
|
+
|
878
|
+
setTotal(total + (totalRes || (dataRes === null || dataRes === void 0 ? void 0 : dataRes.length)));
|
879
|
+
}
|
880
|
+
|
798
881
|
setShowSkeleton(false);
|
799
882
|
setCustomTableLoading(false);
|
800
883
|
} // 重新计算是否需要吸底
|
@@ -864,7 +947,6 @@ var ProTable = function ProTable(props) {
|
|
864
947
|
|
865
948
|
(_actionRef$current6 = actionRef.current) === null || _actionRef$current6 === void 0 ? void 0 : (_actionRef$current6$c = _actionRef$current6.clearRowSelection) === null || _actionRef$current6$c === void 0 ? void 0 : _actionRef$current6$c.call(_actionRef$current6);
|
866
949
|
setCurrentPage(1);
|
867
|
-
console.log('currentPageSize1', pageSize);
|
868
950
|
|
869
951
|
_request(_defineProperty({}, targetPageKey, 1), false, values);
|
870
952
|
},
|
@@ -874,7 +956,6 @@ var ProTable = function ProTable(props) {
|
|
874
956
|
(propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset());
|
875
957
|
(_dataFilterFormRef$cu3 = dataFilterFormRef.current) === null || _dataFilterFormRef$cu3 === void 0 ? void 0 : _dataFilterFormRef$cu3.reset();
|
876
958
|
setCurrentPage(1);
|
877
|
-
console.log('currentPageSize2', pageSize);
|
878
959
|
|
879
960
|
_request(_defineProperty({}, targetPageKey, 1), false, values);
|
880
961
|
}
|
@@ -894,7 +975,8 @@ var ProTable = function ProTable(props) {
|
|
894
975
|
className: classNames('teamix-pro-table-container', className, 'teamix-test-request'),
|
895
976
|
"data-teamix-test-request": "url=".concat(url, "&formatResult=").concat(!!formatResult),
|
896
977
|
"data-teamix-test-params": getTestRequestParams(propsParams),
|
897
|
-
"data-teamix-test-data": getTestRequestData(propsColumns)
|
978
|
+
"data-teamix-test-data": getTestRequestData(propsColumns),
|
979
|
+
"data-teamix-spm": dataTeamixSpm
|
898
980
|
}, /*#__PURE__*/React.createElement(Layout, {
|
899
981
|
header: header,
|
900
982
|
mainAction: mainAction,
|
@@ -907,11 +989,15 @@ var ProTable = function ProTable(props) {
|
|
907
989
|
dataFilterFormRef: isFullScreen ? fullscreenDataFilterFormRef : normalDataFilterFormRef,
|
908
990
|
rowSelection: rowSelection,
|
909
991
|
filterColumnType: filterColumnType,
|
910
|
-
fullScreenState: isFullScreen
|
911
|
-
|
992
|
+
fullScreenState: isFullScreen,
|
993
|
+
toolBarAutoWidth: toolBarAutoWidth,
|
994
|
+
dataTeamixSpm: dataTeamixSpm,
|
995
|
+
switchCardView: switchCardView,
|
996
|
+
defaultView: defaultView
|
997
|
+
}), switchViewState === 'table' && /*#__PURE__*/React.createElement(Table.StickyLock, _objectSpread({
|
912
998
|
hasBorder: false,
|
913
999
|
dataSource: showSkeleton ? skeletonDataSource : data || props.dataSource,
|
914
|
-
columns: genProColumnToColumn(filteredColumns, showSkeleton, actionRef, context),
|
1000
|
+
columns: genProColumnToColumn(filteredColumns, showSkeleton, actionRef, context, dataTeamixSpm),
|
915
1001
|
loading: getTableLoading(),
|
916
1002
|
className: classNames('teamix-pro-table', tableClassName, {
|
917
1003
|
'with-row-select': rowSelection,
|
@@ -927,7 +1013,17 @@ var ProTable = function ProTable(props) {
|
|
927
1013
|
sortIcons: getTableSortIcons(),
|
928
1014
|
fixedHeader: fullscreenState || fixedTableBody,
|
929
1015
|
maxBodyHeight: "calc(100vh - ".concat(headerHeight, "px)")
|
930
|
-
}, pickProps(getTableProps(), otherProps)))
|
1016
|
+
}, pickProps(getTableProps(), otherProps))), switchViewState === 'card' && /*#__PURE__*/React.createElement(CardView, {
|
1017
|
+
dataSource: showSkeleton ? skeletonDataSource : data || props.dataSource,
|
1018
|
+
showSkeleton: showSkeleton,
|
1019
|
+
loading: getTableLoading(),
|
1020
|
+
originColumns: columns,
|
1021
|
+
cardViewProps: cardViewProps,
|
1022
|
+
scrollHeight: fullscreenState || fixedTableBody ? "calc(100vh - ".concat(headerHeight, "px)") : undefined,
|
1023
|
+
actionRef: actionRef,
|
1024
|
+
context: context,
|
1025
|
+
columns: genProColumnToColumn(filteredColumns, showSkeleton, actionRef, context)
|
1026
|
+
}));
|
931
1027
|
} else {
|
932
1028
|
// 不传 columns 直接返回原始 Table
|
933
1029
|
return /*#__PURE__*/React.createElement(Table, _objectSpread({
|
@@ -959,7 +1055,8 @@ var ProTable = function ProTable(props) {
|
|
959
1055
|
return /*#__PURE__*/React.createElement("div", {
|
960
1056
|
className: cls('footer-action')
|
961
1057
|
}, /*#__PURE__*/React.createElement(ProActionGroup, _objectSpread(_objectSpread({}, targetFooterActions), {}, {
|
962
|
-
context: _objectSpread(_objectSpread({}, defaultContext), targetFooterActions === null || targetFooterActions === void 0 ? void 0 : targetFooterActions.context)
|
1058
|
+
context: _objectSpread(_objectSpread({}, defaultContext), targetFooterActions === null || targetFooterActions === void 0 ? void 0 : targetFooterActions.context),
|
1059
|
+
"data-teamix-spm": dataTeamixSpm ? "".concat(dataTeamixSpm, "-footerAction") : undefined
|
963
1060
|
})));
|
964
1061
|
} else return footerAction;
|
965
1062
|
};
|
@@ -981,7 +1078,7 @@ var ProTable = function ProTable(props) {
|
|
981
1078
|
}
|
982
1079
|
|
983
1080
|
function onChangePaginationSize(currentPageSize) {
|
984
|
-
var
|
1081
|
+
var _request8;
|
985
1082
|
|
986
1083
|
// 翻页默认清空选择
|
987
1084
|
if (!reserveSelectedRecords) {
|
@@ -993,7 +1090,7 @@ var ProTable = function ProTable(props) {
|
|
993
1090
|
setPageSize(currentPageSize);
|
994
1091
|
setCurrentPage(1);
|
995
1092
|
|
996
|
-
_request((
|
1093
|
+
_request((_request8 = {}, _defineProperty(_request8, targetPageSizeKey, currentPageSize), _defineProperty(_request8, targetPageKey, 1), _request8));
|
997
1094
|
}
|
998
1095
|
|
999
1096
|
function renderRowSelection() {
|
@@ -1005,13 +1102,13 @@ var ProTable = function ProTable(props) {
|
|
1005
1102
|
} else {
|
1006
1103
|
return /*#__PURE__*/React.createElement("div", {
|
1007
1104
|
className: cls('footer-left-wrapper')
|
1008
|
-
}, rowSelection.mode !== 'single' && /*#__PURE__*/React.createElement(Checkbox, _objectSpread({
|
1105
|
+
}, /*#__PURE__*/React.createElement(React.Fragment, null, rowSelection.mode !== 'single' && /*#__PURE__*/React.createElement(Checkbox, _objectSpread({
|
1009
1106
|
className: cls("footer-checkbox-".concat(size))
|
1010
1107
|
}, getCheckAllProps())), footerAction && renderFooterAction(), /*#__PURE__*/React.createElement("span", {
|
1011
1108
|
className: cls('selected-msg')
|
1012
1109
|
}, getMessage('selected', {
|
1013
1110
|
count: selectedCount
|
1014
|
-
})));
|
1111
|
+
}))));
|
1015
1112
|
}
|
1016
1113
|
} else if (footerAction) {
|
1017
1114
|
if (showSkeleton) {
|
@@ -1026,7 +1123,7 @@ var ProTable = function ProTable(props) {
|
|
1026
1123
|
}
|
1027
1124
|
}
|
1028
1125
|
|
1029
|
-
if (showPagination) {
|
1126
|
+
if (showPagination && switchViewState === 'table') {
|
1030
1127
|
return /*#__PURE__*/React.createElement("div", {
|
1031
1128
|
className: cls('footer', {
|
1032
1129
|
'footer-has-rowSelection': rowSelection,
|
@@ -1057,7 +1154,7 @@ var ProTable = function ProTable(props) {
|
|
1057
1154
|
return onChangePaginationSize(number);
|
1058
1155
|
}
|
1059
1156
|
}, props.paginationProps)))));
|
1060
|
-
} else if (!showPagination) {
|
1157
|
+
} else if (!showPagination && (footerAction || rowSelection || useRowSelection)) {
|
1061
1158
|
return /*#__PURE__*/React.createElement("div", {
|
1062
1159
|
className: cls('footer', {
|
1063
1160
|
'footer-has-rowSelection': rowSelection
|
@@ -1071,6 +1168,7 @@ var ProTable = function ProTable(props) {
|
|
1071
1168
|
|
1072
1169
|
var fixFooterState = useMemo(function () {
|
1073
1170
|
if (fullscreenState) {
|
1171
|
+
// TODO XXX
|
1074
1172
|
return false;
|
1075
1173
|
}
|
1076
1174
|
|
package/es/table/typing.d.ts
CHANGED
@@ -9,6 +9,7 @@ import { PaginationProps } from '@alicloudfe/components/types/pagination';
|
|
9
9
|
import { HeaderProps as ProTableHeaderProps } from '../field';
|
10
10
|
import { Method, AxiosRequestConfig } from 'axios';
|
11
11
|
import React from 'react';
|
12
|
+
import { ProCardProps } from '../card';
|
12
13
|
declare type IFieldRenderProps = keyof ProFieldRenderProps;
|
13
14
|
/** 列record函数 */
|
14
15
|
declare type ProTableCellFunProp = (value: any, index: number, record: any, ...others: any) => any;
|
@@ -147,6 +148,14 @@ export declare type ProTableProps = {
|
|
147
148
|
context?: any;
|
148
149
|
/** 是否固定表格主体(开启后横向滚动条会固定在底部) */
|
149
150
|
fixedTableBody?: boolean;
|
151
|
+
/** 用于埋点 */
|
152
|
+
'data-teamix-spm'?: string;
|
153
|
+
/** 是否切换卡片视角 **/
|
154
|
+
switchCardView?: boolean;
|
155
|
+
/** 卡片视角配置 **/
|
156
|
+
cardViewProps?: ProTableCardProps;
|
157
|
+
/** 默认展示维度 **/
|
158
|
+
defaultView?: 'table' | 'card';
|
150
159
|
} & Omit<TableProps, 'columns'> & ProTableTopAreaProps;
|
151
160
|
export declare type rowSelectionType = {
|
152
161
|
getProps?: (record: any, index: number) => any;
|
@@ -203,6 +212,7 @@ export declare type ProTableActionType = {
|
|
203
212
|
};
|
204
213
|
/** 重置翻页器为1,不发送请求 */
|
205
214
|
resetPage?: () => void;
|
215
|
+
nextPage?: () => void;
|
206
216
|
/** 获取数据过滤区表单实例 */
|
207
217
|
dataFilterForm?: ProFormType;
|
208
218
|
/** 用于在 mount 的时候获取到表单 ref */
|
@@ -212,6 +222,11 @@ export declare type ProTableActionType = {
|
|
212
222
|
filterEnableRef?: any;
|
213
223
|
/** 表格当前的数据 */
|
214
224
|
data?: any[];
|
225
|
+
/** 切换视角 **/
|
226
|
+
switchView?: (view: 'card' | 'table') => void;
|
227
|
+
/** 设置数据源 **/
|
228
|
+
setData?: (data: any[]) => void;
|
229
|
+
setCardViewScrollPosition?: (scrollTop: number) => void;
|
215
230
|
} & ProTableActionTypeMutations;
|
216
231
|
/** action State 定义 */
|
217
232
|
export declare type ProTableActionTypeMutations = {
|
@@ -258,6 +273,8 @@ export declare type ProTableTopAreaProps = {
|
|
258
273
|
mainAction?: ProActionGroupProps | React.ReactNode;
|
259
274
|
/** 工具栏区 */
|
260
275
|
toolBar?: boolean | ProTableToolBarItem[];
|
276
|
+
/** 是否开启工具栏自适应 */
|
277
|
+
toolBarAutoWidth?: boolean;
|
261
278
|
/** 快捷操作区 */
|
262
279
|
extra?: ProActionButtonProps | React.ReactNode | React.ReactNode[];
|
263
280
|
/** 数据过滤区 */
|
@@ -277,6 +294,9 @@ export declare type ProTableLayoutProps = {
|
|
277
294
|
columns?: ProTableColumnProps[];
|
278
295
|
rowSelection?: innerRowSelectionType | rowSelectionType;
|
279
296
|
fullScreenState?: boolean;
|
297
|
+
dataTeamixSpm?: string;
|
298
|
+
switchCardView?: boolean;
|
299
|
+
defaultView?: 'table' | 'card';
|
280
300
|
} & ProTableTopAreaProps;
|
281
301
|
/** columns 列过滤 */
|
282
302
|
export declare type ProTableColumnsFilterItemProps = {
|
@@ -299,4 +319,53 @@ export declare type parentPositionProps = {
|
|
299
319
|
offsetLeft: number;
|
300
320
|
offsetRight: number;
|
301
321
|
};
|
322
|
+
/** card props **/
|
323
|
+
export declare type ProTableCardProps = {
|
324
|
+
/** 标题 dataIndex **/
|
325
|
+
title?: (ProTableColumnProps['dataIndex'] | ProTableColumnProps) | ((index: number, record: any) => ProTableColumnProps['dataIndex'] | ProTableColumnProps);
|
326
|
+
/** 副标题 dataIndex **/
|
327
|
+
subTitle?: (ProTableColumnProps['dataIndex'] | ProTableColumnProps) | ((index: number, record: any) => ProTableColumnProps['dataIndex'] | ProTableColumnProps);
|
328
|
+
/** 内容区域 dataIndex **/
|
329
|
+
content?: (ProTableColumnProps['dataIndex'] | ProTableColumnProps)[] | ((index: number, record: any) => (ProTableColumnProps['dataIndex'] | ProTableColumnProps)[]);
|
330
|
+
/** extra 区域 **/
|
331
|
+
extra?: (ProActionGroupProps | React.ReactNode | ProTableColumnProps['dataIndex'])[] | ((index: number, record: any) => (ProActionGroupProps | React.ReactNode | ProTableColumnProps['dataIndex'])[]);
|
332
|
+
/** 标签区域 **/
|
333
|
+
tags?: (ProTableColumnProps['dataIndex'] | ProTableColumnProps)[] | ((index: number, record: any) => (ProTableColumnProps['dataIndex'] | ProTableColumnProps)[]);
|
334
|
+
/** 分页器条数 **/
|
335
|
+
pageSize?: 12 | 24 | 48 | 96 | number;
|
336
|
+
/** 卡片区域滚动高度 **/
|
337
|
+
scrollHeight?: number | string;
|
338
|
+
/** 自动加载下一页 **/
|
339
|
+
autoLoadNextPage?: boolean;
|
340
|
+
/** 滚动容器 用于监听触底事件 **/
|
341
|
+
scrollDom?: HTMLElement;
|
342
|
+
/** 触底事件 **/
|
343
|
+
onScrollBottom?: () => void;
|
344
|
+
/** 卡片配置 **/
|
345
|
+
cardProps?: {
|
346
|
+
[key in keyof ProCardProps]?: ProCardProps[key] | ((index: number, record: any) => ProCardProps[key]);
|
347
|
+
};
|
348
|
+
};
|
349
|
+
/** card 视角 Props (内部组件) **/
|
350
|
+
export declare type ProTableCardViewProps = {
|
351
|
+
/** 卡片视角配置 **/
|
352
|
+
cardViewProps?: ProTableCardProps;
|
353
|
+
/** 数据源 **/
|
354
|
+
dataSource?: any[];
|
355
|
+
/** 原始 columns **/
|
356
|
+
originColumns?: any[];
|
357
|
+
/** 处理过后的 columns **/
|
358
|
+
columns?: any[];
|
359
|
+
/** 加载动画 **/
|
360
|
+
loading?: boolean;
|
361
|
+
/** 上下文 **/
|
362
|
+
context?: any;
|
363
|
+
actionRef?: React.MutableRefObject<ProTableActionType | undefined>;
|
364
|
+
/** 卡片区域滚动高度 **/
|
365
|
+
scrollHeight?: number | string;
|
366
|
+
/** 骨架屏状态 **/
|
367
|
+
showSkeleton?: boolean;
|
368
|
+
/** ProCard 卡片配置 **/
|
369
|
+
cardProps?: ProTableCardProps['cardProps'];
|
370
|
+
};
|
302
371
|
export {};
|
@@ -10,4 +10,4 @@ export declare const renderColumnsTitle: (item: ProTableColumnProps, actionRef:
|
|
10
10
|
/**
|
11
11
|
* 负责单元格的具体渲染
|
12
12
|
*/
|
13
|
-
export declare const renderCell: (value: any, item: ProTableColumnProps, index: number, record: any, actionRef: React.MutableRefObject<ProTableActionType | undefined>, context?: any) => JSX.Element;
|
13
|
+
export declare const renderCell: (value: any, item: ProTableColumnProps, index: number, record: any, actionRef: React.MutableRefObject<ProTableActionType | undefined>, context?: any, dataTeamixSpm?: string | undefined) => JSX.Element;
|
@@ -111,7 +111,8 @@ export var renderColumnsTitle = function renderColumnsTitle(item, actionRef) {
|
|
111
111
|
|
112
112
|
export var renderCell = function renderCell(value, item, index, record, actionRef,
|
113
113
|
/** 接收外部比如 dialog-table 传过来的 context,用于弹窗关闭等 */
|
114
|
-
context
|
114
|
+
context, // 用于埋点
|
115
|
+
dataTeamixSpm) {
|
115
116
|
var _actionSchema$actions;
|
116
117
|
|
117
118
|
var _item$valueType = item.valueType,
|
@@ -182,7 +183,8 @@ context) {
|
|
182
183
|
return /*#__PURE__*/React.createElement(ProActionGroup, _objectSpread(_objectSpread({
|
183
184
|
type: "text"
|
184
185
|
}, actionSchema), {}, {
|
185
|
-
context: _objectSpread(_objectSpread({}, defaultContext), actionSchema.context)
|
186
|
+
context: _objectSpread(_objectSpread({}, defaultContext), actionSchema.context),
|
187
|
+
"data-teamix-spm": dataTeamixSpm ? "".concat(dataTeamixSpm, "-columnAction") : undefined
|
186
188
|
}));
|
187
189
|
} // dataSource可传函数
|
188
190
|
|
@@ -9,5 +9,5 @@ declare type FixedColumnProps = ColumnProps & {
|
|
9
9
|
*/
|
10
10
|
export default function genProColumnToColumn(columns: ProTableColumnProps[],
|
11
11
|
/** 是否渲染骨架屏 */
|
12
|
-
showSkeleton: boolean, actionRef: React.MutableRefObject<ProTableActionType | undefined>, context?: any): FixedColumnProps[];
|
12
|
+
showSkeleton: boolean, actionRef: React.MutableRefObject<ProTableActionType | undefined>, context?: any, dataTeamixSpm?: string): FixedColumnProps[];
|
13
13
|
export {};
|
@@ -22,6 +22,8 @@ export default function genProColumnToColumn(columns,
|
|
22
22
|
/** 是否渲染骨架屏 */
|
23
23
|
showSkeleton, actionRef) {
|
24
24
|
var context = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
25
|
+
var // 用于埋点
|
26
|
+
dataTeamixSpm = arguments.length > 4 ? arguments[4] : undefined;
|
25
27
|
return columns.map(function (columnProps) {
|
26
28
|
var filters = columnProps.filters,
|
27
29
|
dataIndex = columnProps.dataIndex,
|
@@ -47,7 +49,7 @@ showSkeleton, actionRef) {
|
|
47
49
|
dataIndex: dataIndex === null || dataIndex === void 0 ? void 0 : dataIndex.toString(),
|
48
50
|
title: renderColumnsTitle(columnProps, actionRef),
|
49
51
|
cell: function cell(value, index, record) {
|
50
|
-
return renderCell(value, columnProps, index, record, actionRef, context);
|
52
|
+
return renderCell(value, columnProps, index, record, actionRef, context, dataTeamixSpm);
|
51
53
|
}
|
52
54
|
});
|
53
55
|
});
|
package/lib/actions/index.d.ts
CHANGED
@@ -41,11 +41,13 @@ export interface ProActionCommonProps {
|
|
41
41
|
key?: string | number;
|
42
42
|
visible?: any;
|
43
43
|
context?: any;
|
44
|
+
'data-teamix-spm'?: string;
|
44
45
|
}
|
45
46
|
export interface ProActionMenuButtonProps extends ProActionCommonProps, Omit<MenuButtonProps, 'visible'> {
|
46
47
|
actions: ProActionProps[];
|
47
48
|
icon?: string;
|
48
49
|
noArrow?: boolean;
|
50
|
+
'data-teamix-spm'?: string;
|
49
51
|
}
|
50
52
|
export declare const ProActionMenuButton: (props: ProActionMenuButtonProps) => JSX.Element;
|
51
53
|
export interface ProActionDividerProps extends ProActionCommonProps {
|
@@ -69,6 +71,8 @@ export declare type ProActionGroupProps = {
|
|
69
71
|
more?: string | Omit<ProActionMenuButtonProps, 'actions'>;
|
70
72
|
/** 是否有分割线,只有type="text"时生效,默认有分割线 */
|
71
73
|
divider?: boolean;
|
74
|
+
/** 用于埋点 */
|
75
|
+
['data-teamix-spm']?: string;
|
72
76
|
} & React.HTMLAttributes<HTMLElement>;
|
73
77
|
export declare function ProActionGroup(props: ProActionGroupProps): JSX.Element;
|
74
78
|
declare const ProAction: (props: ProActionProps) => JSX.Element;
|