@kne/table-page 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,20 +1,20 @@
1
1
  import '@kne/table-view/dist/index.css';
2
2
  import { withFetch } from '@kne/react-fetch';
3
- import { Checkbox, Row, Col, Input, List, Tooltip, Button, Collapse, Popover, Empty, Table as Table$1, Dropdown, Pagination } from 'antd';
4
- import { FilterProvider, FilterLines, SearchInput, FilterValueDisplay, getFilterValue } from '@kne/react-filter';
3
+ import { Checkbox, Row, Col, Input, List, Tooltip, Button, Collapse, Popover, Empty, Table as Table$1, Tabs, Dropdown, Pagination } from 'antd';
4
+ import { SearchInput, FilterOuter, FilterLines, FilterValueDisplay, getFilterValue } from '@kne/react-filter';
5
5
  import { useState, useMemo, useRef, useCallback, useEffect, useLayoutEffect, forwardRef } from 'react';
6
6
  import classnames from 'classnames';
7
7
  import get from 'lodash/get';
8
- import { isOptionsColumn, parseColumnWidth, resolveColumns, useSelectedRow, useSort, wrapColumnHeaderTitle, renderColumnTitle, getColumnEllipsis, computeColumnsValue, renderCellContent, computeDisplay, TableView } from '@kne/table-view';
9
- export { RENDER_TYPE_NAMES, SIZE_NAMES, TableView, calcArgs, computeColumnsDisplay, computeColumnsValue, computeDisplay, defaultFormat, formatView, getColumnEllipsis, getColumnLayout, getColumnRender, getGridTemplateColumns, getRenderTypeDimensions, getRenderTypeNames, getStatusType, getTagColor, globalParams, hasColumnSpan, hasColumnWidth, isOptionsColumn, parseColumnWidth, parseRenderType, preset, renderCellContent, renderStatusItem, renderTagItem, renderTagList, resolveColumn, resolveColumnDimensions, resolveColumns, resolveRenderType, sortDataSource, useSelectedRow, useSort, wrapColumnHeaderTitle } from '@kne/table-view';
8
+ import { isOptionsColumn, parseColumnWidth, isRenderMobileActive, resolveColumns, TableView, useSelectedRow, useSort, wrapColumnHeaderTitle, renderColumnTitle, getColumnEllipsis, computeColumnsValue, renderCellContent, computeDisplay } from '@kne/table-view';
9
+ export { RENDER_TYPE_NAMES, SIZE_NAMES, TableView, calcArgs, computeColumnsDisplay, computeColumnsValue, computeDisplay, defaultFormat, formatView, getColumnEllipsis, getColumnLayout, getColumnRender, getGridTemplateColumns, getRenderTypeDimensions, getRenderTypeNames, getStatusType, getTagColor, globalParams, hasColumnSpan, hasColumnWidth, isOptionsColumn, isRenderMobileActive, parseColumnWidth, parseRenderType, preset, renderCellContent, renderStatusItem, renderTagItem, renderTagList, resolveColumn, resolveColumnDimensions, resolveColumns, resolveRenderMobile, resolveRenderType, sortDataSource, useSelectedRow, useSort, wrapColumnHeaderTitle } from '@kne/table-view';
10
10
  import { isEmpty } from '@kne/is-empty';
11
- import viewStyle from '@kne/table-view/src/TableView/style.module.scss';
11
+ import { useIsMobile } from '@kne/responsive-utils';
12
12
  import useRefCallback from '@kne/use-ref-callback';
13
13
  import transform from 'lodash/transform';
14
14
  import pick from 'lodash/pick';
15
15
  import findLastIndex from 'lodash/findLastIndex';
16
16
  import isEqual from 'lodash/isEqual';
17
- import { HolderOutlined, RedoOutlined, SettingOutlined, DownOutlined } from '@ant-design/icons';
17
+ import { HolderOutlined, RedoOutlined, SettingOutlined, DownOutlined, DeleteOutlined } from '@ant-design/icons';
18
18
  import { useDebouncedCallback } from 'use-debounce';
19
19
  import groupBy from 'lodash/groupBy';
20
20
  import { ReactSortable } from 'react-sortablejs';
@@ -45,7 +45,7 @@ function _objectWithoutPropertiesLoose(r, e) {
45
45
  return t;
46
46
  }
47
47
 
48
- var style$2 = {"table":"kne-table-page_awa1L","is-selected-all":"kne-table-page_692q3","is-selected":"kne-table-page_IWgjl","is-disabled":"kne-table-page_YUG4k","has-summary":"kne-table-page_Cb-du","has-group-header":"kne-table-page_7qTC5","is-sticky":"kne-table-page_jGzIR","is-sticky-scroll-y":"kne-table-page_P6lxG","is-sticky-viewport":"kne-table-page_Kr-p6","table-cell":"kne-table-page_HPmr3","selection-col":"kne-table-page_D7YhS","radio-col":"kne-table-page_df9z3","is-computed":"kne-table-page_ZA1Je","is-resize":"kne-table-page_CA0uL","column-resize-guide":"kne-table-page_JARA2"};
48
+ var style$2 = {"table":"kne-table-page_awa1L","is-size-small":"kne-table-page_C1bom","is-size-large":"kne-table-page_xEu6c","is-selected-all":"kne-table-page_692q3","is-selected":"kne-table-page_IWgjl","is-disabled":"kne-table-page_YUG4k","has-summary":"kne-table-page_Cb-du","has-group-header":"kne-table-page_7qTC5","is-sticky":"kne-table-page_jGzIR","is-sticky-scroll-y":"kne-table-page_P6lxG","is-sticky-viewport":"kne-table-page_Kr-p6","col-content":"kne-table-page_CWr3V","empty":"kne-table-page_BoatL","table-cell":"kne-table-page_HPmr3","selection-col":"kne-table-page_D7YhS","radio-col":"kne-table-page_df9z3","is-computed":"kne-table-page_ZA1Je","is-resize":"kne-table-page_CA0uL","is-mobile-render":"kne-table-page_Jy4md","column-resize-guide":"kne-table-page_JARA2"};
49
49
 
50
50
  const getColumnConfig = (config, columnName, field, defaultValue) => {
51
51
  const columnConfig = config == null ? void 0 : config[columnName];
@@ -74,8 +74,10 @@ const locale$1 = {
74
74
  Search: '搜索',
75
75
  BatchOperations: '批量操作',
76
76
  BatchOperationsWithCount: '批量操作(已选:{count}条)',
77
+ BatchOperationsMobileSelected: '已选:{count}条',
77
78
  Cancel: '取消',
78
- Confirm: '确定'
79
+ Confirm: '确定',
80
+ All: '全部'
79
81
  };
80
82
 
81
83
  const locale = {
@@ -89,8 +91,10 @@ const locale = {
89
91
  Search: 'Search',
90
92
  BatchOperations: 'Batch Actions',
91
93
  BatchOperationsWithCount: 'Batch Actions (Selected: {count})',
94
+ BatchOperationsMobileSelected: 'Selected: {count}',
92
95
  Cancel: 'Cancel',
93
- Confirm: 'Confirm'
96
+ Confirm: 'Confirm',
97
+ All: 'All'
94
98
  };
95
99
 
96
100
  const withLocale = createWithIntlProvider({
@@ -987,7 +991,7 @@ const observeViewportIntersection = (element, onChange) => {
987
991
  };
988
992
  };
989
993
 
990
- const _excluded$2 = ["className", "dataSource", "columns", "rowKey", "rowSelection", "valueIsEmpty", "emptyIsPlaceholder", "placeholder", "empty", "onRowSelect", "render", "context", "sticky", "scrollTopInset", "stickyOffset", "getStickyContainer", "headerStyle", "pagination", "sortRender", "name", "controllerOpen", "tableServerApis", "scroll", "summary"],
994
+ const _excluded$2 = ["className", "dataSource", "columns", "rowKey", "rowSelection", "valueIsEmpty", "emptyIsPlaceholder", "placeholder", "empty", "onRowSelect", "render", "renderMobile", "context", "sticky", "scrollTopInset", "stickyOffset", "getStickyContainer", "headerStyle", "pagination", "sortRender", "mobileSortToolbar", "name", "controllerOpen", "tableServerApis", "scroll", "summary", "size"],
991
995
  _excluded2$2 = ["getContainer"];
992
996
  const mapJustifyToAlign = justify => {
993
997
  if (justify === 'center') {
@@ -1024,13 +1028,14 @@ const getColCellStyle = column => ({
1024
1028
  });
1025
1029
  const getAntCellClassName = (...extra) => classnames(style$2['table-cell'], 'info-page-table-col', ...extra);
1026
1030
  const wrapColContent = node => /*#__PURE__*/jsx("span", {
1027
- className: viewStyle['col-content'],
1031
+ className: style$2['col-content'],
1028
1032
  children: node
1029
1033
  });
1030
1034
  const Table = p => {
1031
1035
  const tableRef = useRef(null);
1032
1036
  const tableWidth = useElementWidth(tableRef);
1033
1037
  const [isLayout, setIsLayout] = useState(true);
1038
+ const isMobile = useIsMobile();
1034
1039
  const props = Object.assign({}, {
1035
1040
  rowKey: 'id',
1036
1041
  valueIsEmpty: isEmpty,
@@ -1051,6 +1056,7 @@ const Table = p => {
1051
1056
  empty,
1052
1057
  onRowSelect,
1053
1058
  render,
1059
+ renderMobile,
1054
1060
  context,
1055
1061
  sticky,
1056
1062
  scrollTopInset,
@@ -1059,13 +1065,17 @@ const Table = p => {
1059
1065
  headerStyle,
1060
1066
  pagination = false,
1061
1067
  sortRender,
1068
+ mobileSortToolbar,
1062
1069
  name,
1063
1070
  controllerOpen,
1064
1071
  tableServerApis,
1065
1072
  scroll,
1066
- summary
1073
+ summary,
1074
+ size
1067
1075
  } = props,
1068
1076
  others = _objectWithoutPropertiesLoose(props, _excluded$2);
1077
+ const sizeClassName = size === 'small' ? style$2['is-size-small'] : size === 'large' ? style$2['is-size-large'] : null;
1078
+ const useMobileRender = isRenderMobileActive(renderMobile, isMobile);
1069
1079
  const columns = useMemo(() => resolveColumns(columnsProp), [columnsProp]);
1070
1080
  useEffect(() => {
1071
1081
  if (tableWidth) {
@@ -1154,7 +1164,7 @@ const Table = p => {
1154
1164
  key: colName,
1155
1165
  dataIndex: colName,
1156
1166
  title: /*#__PURE__*/jsx("span", {
1157
- className: viewStyle['col-content'],
1167
+ className: style$2['col-content'],
1158
1168
  children: renderColumnTitle(title, column, sortRender)
1159
1169
  }),
1160
1170
  width: toAntdWidth(width),
@@ -1187,7 +1197,7 @@ const Table = p => {
1187
1197
  placeholder,
1188
1198
  dataSource: record,
1189
1199
  context
1190
- }), computedColumn, viewStyle['col-content']);
1200
+ }), computedColumn, style$2['col-content']);
1191
1201
  }
1192
1202
  };
1193
1203
  if (!controllerOpen) {
@@ -1195,7 +1205,7 @@ const Table = p => {
1195
1205
  }
1196
1206
  const configProps = computedColumnProps(column, index, {
1197
1207
  title: /*#__PURE__*/jsx("span", {
1198
- className: viewStyle['col-content'],
1208
+ className: style$2['col-content'],
1199
1209
  children: renderColumnTitle(title, column, sortRender)
1200
1210
  })
1201
1211
  });
@@ -1218,7 +1228,7 @@ const Table = p => {
1218
1228
  return {
1219
1229
  key: column.name,
1220
1230
  title: /*#__PURE__*/jsx("span", {
1221
- className: viewStyle['col-content'],
1231
+ className: style$2['col-content'],
1222
1232
  children: wrapColumnHeaderTitle(column.title)
1223
1233
  }),
1224
1234
  onHeaderCell: () => ({
@@ -1241,7 +1251,8 @@ const Table = p => {
1241
1251
  }
1242
1252
  const getRowKey = record => resolveRowKey(rowKey, record);
1243
1253
  return _extends({
1244
- type: rowSelection.type === 'radio' ? 'radio' : 'checkbox'
1254
+ type: rowSelection.type === 'radio' ? 'radio' : 'checkbox',
1255
+ preserveSelectedRowKeys: true
1245
1256
  }, hasFixedColumn ? {
1246
1257
  fixed: 'left'
1247
1258
  } : {}, {
@@ -1253,14 +1264,22 @@ const Table = p => {
1253
1264
  rowSelection.onIsSelectAllChange(_checked);
1254
1265
  return;
1255
1266
  }
1267
+ const pageKeys = (dataSource || []).filter(item => !item.disabled).map(getRowKey);
1268
+ const existing = rowSelection.selectedRowKeys || [];
1256
1269
  if (!_checked) {
1257
- rowSelection.onChange([], undefined, {
1270
+ rowSelection.onChange(existing.filter(key => pageKeys.indexOf(key) === -1), undefined, {
1258
1271
  context,
1259
1272
  checked: false
1260
1273
  });
1261
1274
  return;
1262
1275
  }
1263
- rowSelection.onChange((dataSource || []).map(getRowKey), undefined, {
1276
+ const merged = existing.slice();
1277
+ pageKeys.forEach(key => {
1278
+ if (merged.indexOf(key) === -1) {
1279
+ merged.push(key);
1280
+ }
1281
+ });
1282
+ rowSelection.onChange(merged, undefined, {
1264
1283
  context,
1265
1284
  checked: true
1266
1285
  });
@@ -1346,6 +1365,25 @@ const Table = p => {
1346
1365
  '--scroll-top-inset': cssValue
1347
1366
  };
1348
1367
  }, [resolvedScrollTopInset]);
1368
+ if (useMobileRender) {
1369
+ return /*#__PURE__*/jsx(TableView, _extends({}, others, {
1370
+ className: classnames(className, style$2['is-mobile-render']),
1371
+ dataSource: dataSource,
1372
+ columns: visibleColumns,
1373
+ rowKey: rowKey,
1374
+ rowSelection: rowSelection,
1375
+ valueIsEmpty: valueIsEmpty,
1376
+ emptyIsPlaceholder: emptyIsPlaceholder,
1377
+ placeholder: placeholder,
1378
+ empty: empty,
1379
+ onRowSelect: onRowSelect,
1380
+ renderMobile: renderMobile,
1381
+ context: context,
1382
+ sortRender: sortRender,
1383
+ mobileSortToolbar: mobileSortToolbar,
1384
+ size: size
1385
+ }));
1386
+ }
1349
1387
  const tableElement = /*#__PURE__*/jsx(Table$1, _extends({}, others, {
1350
1388
  showHeader: true,
1351
1389
  dataSource: dataSource,
@@ -1358,22 +1396,22 @@ const Table = p => {
1358
1396
  tableLayout: controllerOpen || hasFixedColumn ? 'fixed' : undefined,
1359
1397
  scroll: tableScroll,
1360
1398
  onHeaderRow: () => ({
1361
- className: classnames(viewStyle['header'], 'info-page-table-header'),
1399
+ className: 'info-page-table-header',
1362
1400
  style: headerStyle
1363
1401
  }),
1364
1402
  locale: {
1365
1403
  emptyText: /*#__PURE__*/jsx("div", {
1366
- className: viewStyle['empty'],
1404
+ className: style$2['empty'],
1367
1405
  children: empty
1368
1406
  })
1369
1407
  },
1370
1408
  rowClassName: record => {
1371
1409
  const id = resolveRowKey(rowKey, record);
1372
1410
  const isChecked = (rowSelection == null ? void 0 : rowSelection.selectedRowKeys) && rowSelection.selectedRowKeys.indexOf(id) > -1;
1373
- return classnames(viewStyle['body'], 'info-page-table-row', {
1374
- [viewStyle['is-selected-all']]: rowSelection == null ? void 0 : rowSelection.isSelectedAll,
1375
- [viewStyle['is-selected']]: isChecked,
1376
- [viewStyle['is-disabled']]: record.disabled
1411
+ return classnames('info-page-table-row', {
1412
+ [style$2['is-selected-all']]: rowSelection == null ? void 0 : rowSelection.isSelectedAll,
1413
+ [style$2['is-selected']]: isChecked,
1414
+ [style$2['is-disabled']]: record.disabled
1377
1415
  });
1378
1416
  },
1379
1417
  onRow: onRowSelect ? record => ({
@@ -1390,7 +1428,7 @@ const Table = p => {
1390
1428
  }));
1391
1429
  const wrappedTable = /*#__PURE__*/jsxs("div", {
1392
1430
  ref: tableRef,
1393
- className: classnames(style$2['table'], 'info-page-table', className, {
1431
+ className: classnames(style$2['table'], 'info-page-table', sizeClassName, className, {
1394
1432
  [style$2['is-resize']]: currentMoveColumnIndex !== null,
1395
1433
  [style$2['is-computed']]: isLayout,
1396
1434
  [style$2['has-group-header']]: hasGroupHeader,
@@ -1421,7 +1459,7 @@ Table.useSelectedRow = useSelectedRow;
1421
1459
  Table.useSort = useSort;
1422
1460
  Table.sortDataSource = useSort.sortDataSource;
1423
1461
 
1424
- var style$1 = {"table-page":"kne-table-page_ut9rJ","table-content":"kne-table-page_dxN6N","table-with-toolbar":"kne-table-page_sf06r","has-summary":"kne-table-page_IRdzb","table-in-toolbar":"kne-table-page_sawIT","pagination":"kne-table-page_DSTEf","total_text":"kne-table-page_pJhKr","floating-scrollbar":"kne-table-page_iu8E1","floating-scrollbar-embedded":"kne-table-page_PIv-C","floating-scrollbar-thumb":"kne-table-page_RjZsu","is-moving":"kne-table-page_y-4Ou"};
1462
+ var style$1 = {"table-page":"kne-table-page_ut9rJ","table-page-tabs-outer":"kne-table-page_IowJl","table-content":"kne-table-page_dxN6N","table-with-toolbar":"kne-table-page_sf06r","is-mobile-render":"kne-table-page_D6KGb","has-summary":"kne-table-page_IRdzb","table-in-toolbar":"kne-table-page_sawIT","pagination":"kne-table-page_DSTEf","total_text":"kne-table-page_pJhKr","floating-scrollbar":"kne-table-page_iu8E1","floating-scrollbar-embedded":"kne-table-page_PIv-C","floating-scrollbar-thumb":"kne-table-page_RjZsu","is-moving":"kne-table-page_y-4Ou"};
1425
1463
 
1426
1464
  const BAR_HEIGHT = 15;
1427
1465
  const THUMB_MARGIN = 2;
@@ -1684,24 +1722,98 @@ const HorizontalScroller = /*#__PURE__*/forwardRef(({
1684
1722
  });
1685
1723
  });
1686
1724
 
1687
- var style = {"table-toolbar-section":"kne-table-page_I21Xn","has-value-display":"kne-table-page_COnMY","table-toolbar":"kne-table-page_x6mv7","table-toolbar-value-display":"kne-table-page_vbwMg","table-toolbar-batch":"kne-table-page_k8-Ku","table-toolbar-search":"kne-table-page_pB5en","table-toolbar-batch-btn":"kne-table-page_gZtbT","table-toolbar-filter":"kne-table-page_Jyfm7","table-toolbar-divider":"kne-table-page_z--2N","table-toolbar-filter-inner":"kne-table-page_AX3aK"};
1725
+ var style = {"kne-responsive-boundary":"kne-table-page_u90lj","kne-responsive-scroll":"kne-table-page_bSj1H","table-toolbar-section":"kne-table-page_I21Xn","has-value-display":"kne-table-page_COnMY","table-toolbar":"kne-table-page_x6mv7","table-toolbar-value-display":"kne-table-page_vbwMg","table-toolbar-batch":"kne-table-page_k8-Ku","table-toolbar-batch-btn":"kne-table-page_gZtbT","table-toolbar-batch-clear-btn":"kne-table-page_o6Oml","table-toolbar-search":"kne-table-page_pB5en","table-page-tabs":"kne-table-page_UTy3R","is-mobile-render":"kne-table-page_J-AEV","has-mobile-search":"kne-table-page_14SJt","table-toolbar-search-row":"kne-table-page_zuGJv","is-mobile":"kne-table-page_n9eAS","has-mobile-search-only":"kne-table-page_Y5IR1","has-tabs":"kne-table-page_EImBh","table-toolbar-search-input":"kne-table-page_t60hK","table-toolbar-filter":"kne-table-page_Jyfm7","table-toolbar-divider":"kne-table-page_z--2N","table-toolbar-filter-outer":"kne-table-page_PiWGM","table-toolbar-filter-inner":"kne-table-page_AX3aK"};
1688
1726
 
1689
1727
  const _excluded$1 = ["list", "displayLine", "extraExpand", "className"],
1690
1728
  _excluded2$1 = ["className", "style"];
1729
+ const TAB_ALL_KEY = '__all__';
1730
+ const getTabActiveKey = (filterValue, tabName) => {
1731
+ var _entry$value;
1732
+ if (!tabName || !Array.isArray(filterValue)) {
1733
+ return TAB_ALL_KEY;
1734
+ }
1735
+ const entry = filterValue.find(item => (item == null ? void 0 : item.name) === tabName);
1736
+ const value = entry == null || (_entry$value = entry.value) == null ? void 0 : _entry$value.value;
1737
+ return value == null || value === '' ? TAB_ALL_KEY : String(value);
1738
+ };
1739
+ const TablePageTabs = ({
1740
+ filterValue,
1741
+ onFilterChange,
1742
+ tab,
1743
+ tabProps,
1744
+ className,
1745
+ isMobileRender
1746
+ }) => {
1747
+ const {
1748
+ formatMessage
1749
+ } = useIntl();
1750
+ const showTab = !!(tab != null && tab.name && Array.isArray(tab.list) && tab.list.length > 0);
1751
+ const tabItems = useMemo(() => {
1752
+ if (!showTab) {
1753
+ return [];
1754
+ }
1755
+ return [{
1756
+ key: TAB_ALL_KEY,
1757
+ label: formatMessage({
1758
+ id: 'All'
1759
+ })
1760
+ }, ...tab.list.map(item => ({
1761
+ key: String(item.value),
1762
+ label: item.label
1763
+ }))];
1764
+ }, [showTab, tab == null ? void 0 : tab.list, formatMessage]);
1765
+ if (!showTab) {
1766
+ return null;
1767
+ }
1768
+ const handleTabChange = key => {
1769
+ const next = (Array.isArray(filterValue) ? filterValue : []).filter(item => (item == null ? void 0 : item.name) !== tab.name);
1770
+ if (key !== TAB_ALL_KEY) {
1771
+ const option = tab.list.find(item => String(item.value) === key);
1772
+ if (option) {
1773
+ next.push({
1774
+ name: tab.name,
1775
+ label: tab.label,
1776
+ value: {
1777
+ value: option.value,
1778
+ label: option.label
1779
+ }
1780
+ });
1781
+ }
1782
+ }
1783
+ onFilterChange(next);
1784
+ };
1785
+ return /*#__PURE__*/jsx("div", {
1786
+ className: classnames(style['table-page-tabs'], className, {
1787
+ [style['is-mobile-render']]: isMobileRender
1788
+ }),
1789
+ children: /*#__PURE__*/jsx(Tabs, _extends({
1790
+ size: "small"
1791
+ }, tabProps, {
1792
+ activeKey: getTabActiveKey(filterValue, tab.name),
1793
+ onChange: handleTabChange,
1794
+ items: tabItems
1795
+ }))
1796
+ });
1797
+ };
1691
1798
  const TableToolbar = ({
1692
1799
  filterValue,
1693
1800
  onFilterChange,
1694
1801
  filter,
1695
1802
  search,
1803
+ tab,
1804
+ tabProps,
1805
+ renderTab: _renderTab = true,
1696
1806
  batchActions,
1697
1807
  rowSelection,
1698
1808
  selectedRows,
1699
- batchContext
1809
+ batchContext,
1810
+ isMobileRender
1700
1811
  }) => {
1701
1812
  var _filter$list;
1702
1813
  const {
1703
1814
  formatMessage
1704
1815
  } = useIntl();
1816
+ const isMobile = useIsMobile();
1705
1817
  const selectedRowKeys = (rowSelection == null ? void 0 : rowSelection.selectedRowKeys) || [];
1706
1818
  const hasSelection = selectedRowKeys.length > 0;
1707
1819
  const batchMenuItems = useMemo(() => {
@@ -1738,7 +1850,20 @@ const TableToolbar = ({
1738
1850
  const showBatch = batchMenuItems.length > 0;
1739
1851
  const showFilter = (filter == null || (_filter$list = filter.list) == null ? void 0 : _filter$list.length) > 0;
1740
1852
  const showSearch = search && search.name;
1741
- if (!showBatch && !showFilter && !showSearch) {
1853
+ const hasTab = !!(tab != null && tab.name && Array.isArray(tab.list) && tab.list.length > 0);
1854
+ const showTab = hasTab && _renderTab;
1855
+ const batchButtonLabel = hasSelection ? isMobile ? formatMessage({
1856
+ id: 'BatchOperationsMobileSelected'
1857
+ }, {
1858
+ count: selectedRowKeys.length
1859
+ }) : formatMessage({
1860
+ id: 'BatchOperationsWithCount'
1861
+ }, {
1862
+ count: selectedRowKeys.length
1863
+ }) : formatMessage({
1864
+ id: 'BatchOperations'
1865
+ });
1866
+ if (!showBatch && !showFilter && !showSearch && !showTab) {
1742
1867
  return null;
1743
1868
  }
1744
1869
  const _ref = filter || {},
@@ -1756,20 +1881,49 @@ const TableToolbar = ({
1756
1881
  } = _ref2,
1757
1882
  searchRest = _objectWithoutPropertiesLoose(_ref2, _excluded2$1);
1758
1883
  const hasValueDisplay = (filterValue == null ? void 0 : filterValue.length) > 0;
1759
- return /*#__PURE__*/jsx(FilterProvider, {
1884
+ const showMobileSearchRow = isMobile && showSearch;
1885
+ const showMainToolbar = showBatch || showFilter || !isMobile && showSearch;
1886
+ const searchInputNode = showSearch ? /*#__PURE__*/jsx(SearchInput, _extends({
1887
+ allowClear: true,
1888
+ bordered: false,
1889
+ variant: "filled",
1890
+ size: isMobile ? 'middle' : 'small',
1891
+ className: classnames(style['table-toolbar-search-input'], searchClassName),
1892
+ style: isMobile ? _extends({}, searchStyle, {
1893
+ width: '100%',
1894
+ maxWidth: '100%'
1895
+ }) : searchStyle
1896
+ }, searchRest)) : null;
1897
+ return /*#__PURE__*/jsx(FilterOuter, {
1760
1898
  value: filterValue,
1761
1899
  onChange: onFilterChange,
1762
- children: /*#__PURE__*/jsxs("div", {
1900
+ className: style['table-toolbar-filter-outer'],
1901
+ children: () => /*#__PURE__*/jsxs("div", {
1763
1902
  className: classnames(style['table-toolbar-section'], 'table-page-toolbar-section', {
1764
1903
  [style['has-value-display']]: hasValueDisplay,
1904
+ [style['has-mobile-search']]: showMobileSearchRow,
1905
+ [style['has-mobile-search-only']]: showMobileSearchRow && !showMainToolbar && !showTab,
1906
+ [style['has-tabs']]: showTab,
1907
+ [style['is-mobile-render']]: isMobileRender,
1765
1908
  'table-page-toolbar-section--has-value': hasValueDisplay
1766
1909
  }),
1767
- children: [/*#__PURE__*/jsxs("div", {
1768
- className: classnames(style['table-toolbar'], 'table-page-toolbar'),
1910
+ children: [showMobileSearchRow ? /*#__PURE__*/jsx("div", {
1911
+ className: classnames(style['table-toolbar-search-row'], style['table-toolbar-search']),
1912
+ children: searchInputNode
1913
+ }) : null, showTab ? /*#__PURE__*/jsx(TablePageTabs, {
1914
+ filterValue: filterValue,
1915
+ onFilterChange: onFilterChange,
1916
+ tab: tab,
1917
+ tabProps: tabProps,
1918
+ isMobileRender: isMobileRender
1919
+ }) : null, showMainToolbar ? /*#__PURE__*/jsxs("div", {
1920
+ className: classnames(style['table-toolbar'], 'table-page-toolbar', {
1921
+ [style['is-mobile']]: isMobile
1922
+ }),
1769
1923
  children: [showBatch ? /*#__PURE__*/jsxs(Fragment, {
1770
- children: [/*#__PURE__*/jsx("div", {
1924
+ children: [/*#__PURE__*/jsxs("div", {
1771
1925
  className: style['table-toolbar-batch'],
1772
- children: /*#__PURE__*/jsx(Dropdown, {
1926
+ children: [/*#__PURE__*/jsx(Dropdown, {
1773
1927
  disabled: !hasSelection,
1774
1928
  menu: {
1775
1929
  items: batchMenuItems
@@ -1779,16 +1933,25 @@ const TableToolbar = ({
1779
1933
  size: "small",
1780
1934
  disabled: !hasSelection,
1781
1935
  className: style['table-toolbar-batch-btn'],
1782
- children: [hasSelection ? formatMessage({
1783
- id: 'BatchOperationsWithCount'
1784
- }, {
1785
- count: selectedRowKeys.length
1786
- }) : formatMessage({
1787
- id: 'BatchOperations'
1788
- }), /*#__PURE__*/jsx(DownOutlined, {})]
1936
+ children: [batchButtonLabel, /*#__PURE__*/jsx(DownOutlined, {})]
1789
1937
  })
1790
- })
1791
- }), (showFilter || showSearch) && /*#__PURE__*/jsx("span", {
1938
+ }), hasSelection ? /*#__PURE__*/jsx(Button, {
1939
+ danger: true,
1940
+ size: "small",
1941
+ icon: /*#__PURE__*/jsx(DeleteOutlined, {}),
1942
+ title: formatMessage({
1943
+ id: 'Cancel'
1944
+ }),
1945
+ "aria-label": formatMessage({
1946
+ id: 'Cancel'
1947
+ }),
1948
+ className: style['table-toolbar-batch-clear-btn'],
1949
+ onClick: () => {
1950
+ rowSelection == null || rowSelection.onChange == null || rowSelection.onChange([]);
1951
+ rowSelection == null || rowSelection.onIsSelectAllChange == null || rowSelection.onIsSelectAllChange(false);
1952
+ }
1953
+ }) : null]
1954
+ }), showFilter && /*#__PURE__*/jsx("span", {
1792
1955
  className: style['table-toolbar-divider'],
1793
1956
  "aria-hidden": true
1794
1957
  })]
@@ -1802,35 +1965,31 @@ const TableToolbar = ({
1802
1965
  label: ""
1803
1966
  }, filterRest))
1804
1967
  })
1805
- }) : null, showSearch ? /*#__PURE__*/jsxs(Fragment, {
1968
+ }) : null, !showMobileSearchRow && showSearch ? /*#__PURE__*/jsxs(Fragment, {
1806
1969
  children: [showFilter && /*#__PURE__*/jsx("span", {
1807
1970
  className: style['table-toolbar-divider'],
1808
1971
  "aria-hidden": true
1809
1972
  }), /*#__PURE__*/jsx("div", {
1810
1973
  className: style['table-toolbar-search'],
1811
- children: /*#__PURE__*/jsx(SearchInput, _extends({
1812
- allowClear: true,
1813
- bordered: false,
1814
- variant: "filled",
1815
- size: "small",
1816
- className: classnames(style['table-toolbar-search-input'], searchClassName),
1817
- style: searchStyle
1818
- }, searchRest))
1974
+ children: searchInputNode
1819
1975
  })]
1820
1976
  }) : null]
1821
- }), hasValueDisplay ? /*#__PURE__*/jsx("div", {
1822
- className: style['table-toolbar-value-display'],
1977
+ }) : null, hasValueDisplay ? /*#__PURE__*/jsx("div", {
1978
+ className: classnames(style['table-toolbar-value-display'], {
1979
+ [style['is-mobile-render']]: isMobileRender
1980
+ }),
1823
1981
  children: /*#__PURE__*/jsx(FilterValueDisplay, {
1824
1982
  value: filterValue,
1825
1983
  onChange: onFilterChange,
1826
- extraExpand: extraExpand
1984
+ extraExpand: extraExpand,
1985
+ flush: isMobileRender
1827
1986
  })
1828
1987
  }) : null]
1829
1988
  })
1830
1989
  });
1831
1990
  };
1832
1991
 
1833
- const _excluded = ["data", "refresh", "reload", "requestParams", "fetchProps", "isComplete", "loadMore", "send", "dataFormat", "className", "columns", "getColumns", "pagination", "columnRenderProps", "summary", "sticky", "scrollTopInset", "stickyOffset", "renderType", "horizontalScroller", "getScrollContainer", "filter", "search", "batchActions", "selectedRows", "rowSelection"],
1992
+ const _excluded = ["data", "refresh", "reload", "requestParams", "fetchProps", "isComplete", "loadMore", "send", "dataFormat", "className", "columns", "getColumns", "pagination", "columnRenderProps", "summary", "sticky", "scrollTopInset", "stickyOffset", "renderType", "horizontalScroller", "getScrollContainer", "filter", "search", "tab", "tabProps", "batchActions", "selectedRows", "rowSelection", "renderMobile"],
1834
1993
  _excluded2 = ["pagination", "horizontalScroller", "getScrollContainer"];
1835
1994
  const readPageSize = key => {
1836
1995
  try {
@@ -1855,11 +2014,14 @@ const TABLE_COMPONENTS = {
1855
2014
  Table,
1856
2015
  TableView
1857
2016
  };
1858
- const collectFilterFieldNames = (filter, search) => {
2017
+ const collectFilterFieldNames = (filter, search, tab) => {
1859
2018
  const names = new Set();
1860
2019
  if (search != null && search.name) {
1861
2020
  names.add(search.name);
1862
2021
  }
2022
+ if (tab != null && tab.name) {
2023
+ names.add(tab.name);
2024
+ }
1863
2025
  if (Array.isArray(filter == null ? void 0 : filter.list)) {
1864
2026
  filter.list.forEach(row => {
1865
2027
  if (!Array.isArray(row)) {
@@ -1915,14 +2077,19 @@ const TablePageInnerContent = withLocale(_ref => {
1915
2077
  getScrollContainer,
1916
2078
  filter,
1917
2079
  search,
2080
+ tab,
2081
+ tabProps,
1918
2082
  batchActions,
1919
2083
  selectedRows,
1920
- rowSelection
2084
+ rowSelection,
2085
+ renderMobile
1921
2086
  } = _ref,
1922
2087
  props = _objectWithoutPropertiesLoose(_ref, _excluded);
1923
2088
  const {
1924
2089
  formatMessage
1925
2090
  } = useIntl();
2091
+ const isMobile = useIsMobile();
2092
+ const isMobileRenderActive = isRenderMobileActive(renderMobile, isMobile);
1926
2093
  const tableContentRef = useRef(null);
1927
2094
  const pendingScrollRef = useRef(false);
1928
2095
  const handlerDataFormat = useRefCallback(dataFormat);
@@ -1933,7 +2100,7 @@ const TablePageInnerContent = withLocale(_ref => {
1933
2100
  const getFilterParams = useRefCallback(value => {
1934
2101
  return mapFilterValue(value || []);
1935
2102
  });
1936
- const filterFieldNames = useMemo(() => collectFilterFieldNames(filter, search), [filter, search]);
2103
+ const filterFieldNames = useMemo(() => collectFilterFieldNames(filter, search, tab), [filter, search, tab]);
1937
2104
  const buildRequestParamsWithFilter = useRefCallback((value, extra = {}) => {
1938
2105
  return Object.assign({}, omitFilterParams(get(requestParams, pagination.paramsType), filterFieldNames), extra, getFilterParams(value));
1939
2106
  });
@@ -1952,7 +2119,12 @@ const TablePageInnerContent = withLocale(_ref => {
1952
2119
  dataFormat,
1953
2120
  pagination
1954
2121
  }), [data, fetchProps, requestParams, refresh, reload, loadMore, send, dataFormat, pagination]);
1955
- const hasToolbar = !!(filter != null && (_filter$list = filter.list) != null && _filter$list.length || search && search.name || batchActions && batchActions.length);
2122
+ const hasTab = !!(tab != null && tab.name && Array.isArray(tab.list) && tab.list.length > 0);
2123
+ const hasInnerToolbar = !!(filter != null && (_filter$list = filter.list) != null && _filter$list.length || search && search.name || batchActions && batchActions.length);
2124
+ const showOuterTab = hasTab && !isMobile;
2125
+ const showInnerTab = hasTab && isMobile;
2126
+ const wrapWithToolbar = hasInnerToolbar || showInnerTab;
2127
+ const hasToolbar = wrapWithToolbar || showOuterTab;
1956
2128
  const resolvedScrollTopInset = resolveScrollTopInset(scrollTopInset, stickyOffset);
1957
2129
  const scrollTopInsetStyle = useMemo(() => {
1958
2130
  const cssValue = normalizeScrollTopInsetCSSValue(resolvedScrollTopInset);
@@ -1993,33 +2165,41 @@ const TablePageInnerContent = withLocale(_ref => {
1993
2165
  pagination.onChange(page, size);
1994
2166
  return;
1995
2167
  }
1996
- if (page !== get(requestParams, [pagination.paramsType, pagination.currentName], 1)) {
2168
+ const nextSize = Number(size);
2169
+ const currentPage = get(requestParams, [pagination.paramsType, pagination.currentName], 1);
2170
+ const currentSize = Number(get(requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize || 50;
2171
+ if (nextSize !== currentSize) {
2172
+ pagination.onShowSizeChange && pagination.onShowSizeChange(page, nextSize);
2173
+ }
2174
+ if (page !== currentPage || nextSize !== currentSize) {
1997
2175
  (pagination.requestType === 'refresh' ? refresh : reload)({
1998
2176
  [pagination.paramsType]: buildRequestParamsWithFilter(filterValue, {
1999
2177
  [pagination.currentName]: page,
2000
- [pagination.pageSizeName]: Number(size)
2178
+ [pagination.pageSizeName]: nextSize
2001
2179
  })
2002
2180
  });
2003
- } else {
2004
- pagination.onShowSizeChange && pagination.onShowSizeChange(page, Number(size));
2005
2181
  }
2006
2182
  });
2007
2183
  const paginationConfig = useMemo(() => {
2184
+ var _mobilePagination$sho;
2008
2185
  if (!pagination.open) {
2009
2186
  return null;
2010
2187
  }
2011
- return {
2012
- total: formatData.total,
2013
- showTotal: typeof pagination.showTotal === 'function' ? pagination.showTotal : total => /*#__PURE__*/jsxs(Fragment, {
2014
- children: [formatMessage({
2015
- id: 'TotalText'
2016
- }), "\xA0", /*#__PURE__*/jsx("span", {
2017
- className: style$1['total_text'],
2018
- children: total
2019
- }), "\xA0", formatMessage({
2020
- id: 'ItemText'
2021
- })]
2022
- }),
2188
+ const defaultShowTotal = total => /*#__PURE__*/jsxs(Fragment, {
2189
+ children: [formatMessage({
2190
+ id: 'TotalText'
2191
+ }), "\xA0", /*#__PURE__*/jsx("span", {
2192
+ className: style$1['total_text'],
2193
+ children: total
2194
+ }), "\xA0", formatMessage({
2195
+ id: 'ItemText'
2196
+ })]
2197
+ });
2198
+ const baseConfig = _extends({
2199
+ total: formatData.total
2200
+ }, pagination.showTotal !== false ? {
2201
+ showTotal: typeof pagination.showTotal === 'function' ? pagination.showTotal : defaultShowTotal
2202
+ } : {}, {
2023
2203
  current: get(requestParams, [pagination.paramsType, pagination.currentName], 1),
2024
2204
  pageSize: Number(get(requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize || 50,
2025
2205
  onChange: handlePaginationChange,
@@ -2028,8 +2208,20 @@ const TablePageInnerContent = withLocale(_ref => {
2028
2208
  showSizeChanger: pagination.showSizeChanger,
2029
2209
  showQuickJumper: pagination.showQuickJumper,
2030
2210
  pageSizeOptions: pagination.pageSizeOptions
2031
- };
2032
- }, [pagination, formatData.total, requestParams, formatMessage, handlePaginationChange]);
2211
+ });
2212
+ if (!isMobileRenderActive) {
2213
+ return baseConfig;
2214
+ }
2215
+ const mobilePagination = pagination.mobile || {};
2216
+ return _extends({}, baseConfig, {
2217
+ onShowSizeChange: handlePaginationChange,
2218
+ size: mobilePagination.size,
2219
+ showSizeChanger: mobilePagination.showSizeChanger !== false && pagination.showSizeChanger !== false,
2220
+ showQuickJumper: mobilePagination.showQuickJumper === true,
2221
+ showLessItems: (_mobilePagination$sho = mobilePagination.showLessItems) != null ? _mobilePagination$sho : true,
2222
+ pageSizeOptions: pagination.pageSizeOptions || ['10', '20', '50', '100']
2223
+ });
2224
+ }, [pagination, formatData.total, requestParams, formatMessage, handlePaginationChange, isMobileRenderActive]);
2033
2225
  const batchContext = useMemo(() => ({
2034
2226
  data,
2035
2227
  fetchProps,
@@ -2047,6 +2239,7 @@ const TablePageInnerContent = withLocale(_ref => {
2047
2239
  data
2048
2240
  });
2049
2241
  const tableProps = _extends({}, props, {
2242
+ renderMobile,
2050
2243
  rowSelection,
2051
2244
  dataSource: formatData.list,
2052
2245
  pagination: false,
@@ -2054,7 +2247,8 @@ const TablePageInnerContent = withLocale(_ref => {
2054
2247
  scrollTopInset: resolvedScrollTopInset,
2055
2248
  getStickyContainer: getScrollContainer,
2056
2249
  className: classnames(className, {
2057
- [style$1['table-in-toolbar']]: hasToolbar
2250
+ [style$1['table-in-toolbar']]: wrapWithToolbar,
2251
+ [style$1['is-mobile-render']]: isMobileRenderActive
2058
2252
  }),
2059
2253
  columns: resolvedColumns,
2060
2254
  context: tableContext,
@@ -2070,28 +2264,43 @@ const TablePageInnerContent = withLocale(_ref => {
2070
2264
  return /*#__PURE__*/jsxs("div", {
2071
2265
  className: style$1['table-page'],
2072
2266
  style: scrollTopInsetStyle,
2073
- children: [/*#__PURE__*/jsx(HorizontalScroller, {
2267
+ children: [/*#__PURE__*/jsxs(HorizontalScroller, {
2074
2268
  ref: tableContentRef,
2075
2269
  enabled: horizontalScroller && renderType === 'Table',
2076
2270
  getPortalContainer: getScrollContainer,
2077
2271
  className: classnames(style$1['table-content'], 'loading-container', {
2078
2272
  'is-loading': !isComplete && !data
2079
2273
  }),
2080
- children: hasToolbar ? /*#__PURE__*/jsxs("div", {
2081
- className: style$1['table-with-toolbar'],
2274
+ children: [showOuterTab ? /*#__PURE__*/jsx(TablePageTabs, {
2275
+ filterValue: filterValue,
2276
+ onFilterChange: handleFilterChange,
2277
+ tab: tab,
2278
+ tabProps: tabProps,
2279
+ className: style$1['table-page-tabs-outer'],
2280
+ isMobileRender: isMobileRenderActive
2281
+ }) : null, wrapWithToolbar ? /*#__PURE__*/jsxs("div", {
2282
+ className: classnames(style$1['table-with-toolbar'], {
2283
+ [style$1['is-mobile-render']]: isMobileRenderActive
2284
+ }),
2082
2285
  children: [/*#__PURE__*/jsx(TableToolbar, {
2083
2286
  filterValue: filterValue,
2084
2287
  onFilterChange: handleFilterChange,
2085
2288
  filter: filter,
2086
2289
  search: search,
2290
+ tab: tab,
2291
+ tabProps: tabProps,
2292
+ renderTab: showInnerTab,
2087
2293
  batchActions: batchActions,
2088
2294
  rowSelection: rowSelection,
2089
2295
  selectedRows: selectedRows,
2090
- batchContext: batchContext
2296
+ batchContext: batchContext,
2297
+ isMobileRender: isMobileRenderActive
2091
2298
  }), tableElement]
2092
- }) : tableElement
2299
+ }) : tableElement]
2093
2300
  }), paginationConfig ? /*#__PURE__*/jsx(Pagination, _extends({
2094
- className: style$1['pagination']
2301
+ className: classnames(style$1['pagination'], {
2302
+ [style$1['is-mobile-render']]: isMobileRenderActive
2303
+ })
2095
2304
  }, paginationConfig)) : null]
2096
2305
  });
2097
2306
  });