@kne/table-page 0.1.8 → 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,19 +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 { useIsMobile } from '@kne/responsive-utils';
11
12
  import useRefCallback from '@kne/use-ref-callback';
12
13
  import transform from 'lodash/transform';
13
14
  import pick from 'lodash/pick';
14
15
  import findLastIndex from 'lodash/findLastIndex';
15
16
  import isEqual from 'lodash/isEqual';
16
- import { HolderOutlined, RedoOutlined, SettingOutlined, DownOutlined } from '@ant-design/icons';
17
+ import { HolderOutlined, RedoOutlined, SettingOutlined, DownOutlined, DeleteOutlined } from '@ant-design/icons';
17
18
  import { useDebouncedCallback } from 'use-debounce';
18
19
  import groupBy from 'lodash/groupBy';
19
20
  import { ReactSortable } from 'react-sortablejs';
@@ -44,7 +45,7 @@ function _objectWithoutPropertiesLoose(r, e) {
44
45
  return t;
45
46
  }
46
47
 
47
- 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","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","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"};
48
49
 
49
50
  const getColumnConfig = (config, columnName, field, defaultValue) => {
50
51
  const columnConfig = config == null ? void 0 : config[columnName];
@@ -73,8 +74,10 @@ const locale$1 = {
73
74
  Search: '搜索',
74
75
  BatchOperations: '批量操作',
75
76
  BatchOperationsWithCount: '批量操作(已选:{count}条)',
77
+ BatchOperationsMobileSelected: '已选:{count}条',
76
78
  Cancel: '取消',
77
- Confirm: '确定'
79
+ Confirm: '确定',
80
+ All: '全部'
78
81
  };
79
82
 
80
83
  const locale = {
@@ -88,8 +91,10 @@ const locale = {
88
91
  Search: 'Search',
89
92
  BatchOperations: 'Batch Actions',
90
93
  BatchOperationsWithCount: 'Batch Actions (Selected: {count})',
94
+ BatchOperationsMobileSelected: 'Selected: {count}',
91
95
  Cancel: 'Cancel',
92
- Confirm: 'Confirm'
96
+ Confirm: 'Confirm',
97
+ All: 'All'
93
98
  };
94
99
 
95
100
  const withLocale = createWithIntlProvider({
@@ -986,7 +991,7 @@ const observeViewportIntersection = (element, onChange) => {
986
991
  };
987
992
  };
988
993
 
989
- 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"],
990
995
  _excluded2$2 = ["getContainer"];
991
996
  const mapJustifyToAlign = justify => {
992
997
  if (justify === 'center') {
@@ -1030,6 +1035,7 @@ const Table = p => {
1030
1035
  const tableRef = useRef(null);
1031
1036
  const tableWidth = useElementWidth(tableRef);
1032
1037
  const [isLayout, setIsLayout] = useState(true);
1038
+ const isMobile = useIsMobile();
1033
1039
  const props = Object.assign({}, {
1034
1040
  rowKey: 'id',
1035
1041
  valueIsEmpty: isEmpty,
@@ -1050,6 +1056,7 @@ const Table = p => {
1050
1056
  empty,
1051
1057
  onRowSelect,
1052
1058
  render,
1059
+ renderMobile,
1053
1060
  context,
1054
1061
  sticky,
1055
1062
  scrollTopInset,
@@ -1058,13 +1065,17 @@ const Table = p => {
1058
1065
  headerStyle,
1059
1066
  pagination = false,
1060
1067
  sortRender,
1068
+ mobileSortToolbar,
1061
1069
  name,
1062
1070
  controllerOpen,
1063
1071
  tableServerApis,
1064
1072
  scroll,
1065
- summary
1073
+ summary,
1074
+ size
1066
1075
  } = props,
1067
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);
1068
1079
  const columns = useMemo(() => resolveColumns(columnsProp), [columnsProp]);
1069
1080
  useEffect(() => {
1070
1081
  if (tableWidth) {
@@ -1240,7 +1251,8 @@ const Table = p => {
1240
1251
  }
1241
1252
  const getRowKey = record => resolveRowKey(rowKey, record);
1242
1253
  return _extends({
1243
- type: rowSelection.type === 'radio' ? 'radio' : 'checkbox'
1254
+ type: rowSelection.type === 'radio' ? 'radio' : 'checkbox',
1255
+ preserveSelectedRowKeys: true
1244
1256
  }, hasFixedColumn ? {
1245
1257
  fixed: 'left'
1246
1258
  } : {}, {
@@ -1252,14 +1264,22 @@ const Table = p => {
1252
1264
  rowSelection.onIsSelectAllChange(_checked);
1253
1265
  return;
1254
1266
  }
1267
+ const pageKeys = (dataSource || []).filter(item => !item.disabled).map(getRowKey);
1268
+ const existing = rowSelection.selectedRowKeys || [];
1255
1269
  if (!_checked) {
1256
- rowSelection.onChange([], undefined, {
1270
+ rowSelection.onChange(existing.filter(key => pageKeys.indexOf(key) === -1), undefined, {
1257
1271
  context,
1258
1272
  checked: false
1259
1273
  });
1260
1274
  return;
1261
1275
  }
1262
- 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, {
1263
1283
  context,
1264
1284
  checked: true
1265
1285
  });
@@ -1345,6 +1365,25 @@ const Table = p => {
1345
1365
  '--scroll-top-inset': cssValue
1346
1366
  };
1347
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
+ }
1348
1387
  const tableElement = /*#__PURE__*/jsx(Table$1, _extends({}, others, {
1349
1388
  showHeader: true,
1350
1389
  dataSource: dataSource,
@@ -1389,7 +1428,7 @@ const Table = p => {
1389
1428
  }));
1390
1429
  const wrappedTable = /*#__PURE__*/jsxs("div", {
1391
1430
  ref: tableRef,
1392
- className: classnames(style$2['table'], 'info-page-table', className, {
1431
+ className: classnames(style$2['table'], 'info-page-table', sizeClassName, className, {
1393
1432
  [style$2['is-resize']]: currentMoveColumnIndex !== null,
1394
1433
  [style$2['is-computed']]: isLayout,
1395
1434
  [style$2['has-group-header']]: hasGroupHeader,
@@ -1420,7 +1459,7 @@ Table.useSelectedRow = useSelectedRow;
1420
1459
  Table.useSort = useSort;
1421
1460
  Table.sortDataSource = useSort.sortDataSource;
1422
1461
 
1423
- 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"};
1424
1463
 
1425
1464
  const BAR_HEIGHT = 15;
1426
1465
  const THUMB_MARGIN = 2;
@@ -1683,24 +1722,98 @@ const HorizontalScroller = /*#__PURE__*/forwardRef(({
1683
1722
  });
1684
1723
  });
1685
1724
 
1686
- 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"};
1687
1726
 
1688
1727
  const _excluded$1 = ["list", "displayLine", "extraExpand", "className"],
1689
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
+ };
1690
1798
  const TableToolbar = ({
1691
1799
  filterValue,
1692
1800
  onFilterChange,
1693
1801
  filter,
1694
1802
  search,
1803
+ tab,
1804
+ tabProps,
1805
+ renderTab: _renderTab = true,
1695
1806
  batchActions,
1696
1807
  rowSelection,
1697
1808
  selectedRows,
1698
- batchContext
1809
+ batchContext,
1810
+ isMobileRender
1699
1811
  }) => {
1700
1812
  var _filter$list;
1701
1813
  const {
1702
1814
  formatMessage
1703
1815
  } = useIntl();
1816
+ const isMobile = useIsMobile();
1704
1817
  const selectedRowKeys = (rowSelection == null ? void 0 : rowSelection.selectedRowKeys) || [];
1705
1818
  const hasSelection = selectedRowKeys.length > 0;
1706
1819
  const batchMenuItems = useMemo(() => {
@@ -1737,7 +1850,20 @@ const TableToolbar = ({
1737
1850
  const showBatch = batchMenuItems.length > 0;
1738
1851
  const showFilter = (filter == null || (_filter$list = filter.list) == null ? void 0 : _filter$list.length) > 0;
1739
1852
  const showSearch = search && search.name;
1740
- 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) {
1741
1867
  return null;
1742
1868
  }
1743
1869
  const _ref = filter || {},
@@ -1755,20 +1881,49 @@ const TableToolbar = ({
1755
1881
  } = _ref2,
1756
1882
  searchRest = _objectWithoutPropertiesLoose(_ref2, _excluded2$1);
1757
1883
  const hasValueDisplay = (filterValue == null ? void 0 : filterValue.length) > 0;
1758
- 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, {
1759
1898
  value: filterValue,
1760
1899
  onChange: onFilterChange,
1761
- children: /*#__PURE__*/jsxs("div", {
1900
+ className: style['table-toolbar-filter-outer'],
1901
+ children: () => /*#__PURE__*/jsxs("div", {
1762
1902
  className: classnames(style['table-toolbar-section'], 'table-page-toolbar-section', {
1763
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,
1764
1908
  'table-page-toolbar-section--has-value': hasValueDisplay
1765
1909
  }),
1766
- children: [/*#__PURE__*/jsxs("div", {
1767
- 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
+ }),
1768
1923
  children: [showBatch ? /*#__PURE__*/jsxs(Fragment, {
1769
- children: [/*#__PURE__*/jsx("div", {
1924
+ children: [/*#__PURE__*/jsxs("div", {
1770
1925
  className: style['table-toolbar-batch'],
1771
- children: /*#__PURE__*/jsx(Dropdown, {
1926
+ children: [/*#__PURE__*/jsx(Dropdown, {
1772
1927
  disabled: !hasSelection,
1773
1928
  menu: {
1774
1929
  items: batchMenuItems
@@ -1778,16 +1933,25 @@ const TableToolbar = ({
1778
1933
  size: "small",
1779
1934
  disabled: !hasSelection,
1780
1935
  className: style['table-toolbar-batch-btn'],
1781
- children: [hasSelection ? formatMessage({
1782
- id: 'BatchOperationsWithCount'
1783
- }, {
1784
- count: selectedRowKeys.length
1785
- }) : formatMessage({
1786
- id: 'BatchOperations'
1787
- }), /*#__PURE__*/jsx(DownOutlined, {})]
1936
+ children: [batchButtonLabel, /*#__PURE__*/jsx(DownOutlined, {})]
1788
1937
  })
1789
- })
1790
- }), (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", {
1791
1955
  className: style['table-toolbar-divider'],
1792
1956
  "aria-hidden": true
1793
1957
  })]
@@ -1801,35 +1965,31 @@ const TableToolbar = ({
1801
1965
  label: ""
1802
1966
  }, filterRest))
1803
1967
  })
1804
- }) : null, showSearch ? /*#__PURE__*/jsxs(Fragment, {
1968
+ }) : null, !showMobileSearchRow && showSearch ? /*#__PURE__*/jsxs(Fragment, {
1805
1969
  children: [showFilter && /*#__PURE__*/jsx("span", {
1806
1970
  className: style['table-toolbar-divider'],
1807
1971
  "aria-hidden": true
1808
1972
  }), /*#__PURE__*/jsx("div", {
1809
1973
  className: style['table-toolbar-search'],
1810
- children: /*#__PURE__*/jsx(SearchInput, _extends({
1811
- allowClear: true,
1812
- bordered: false,
1813
- variant: "filled",
1814
- size: "small",
1815
- className: classnames(style['table-toolbar-search-input'], searchClassName),
1816
- style: searchStyle
1817
- }, searchRest))
1974
+ children: searchInputNode
1818
1975
  })]
1819
1976
  }) : null]
1820
- }), hasValueDisplay ? /*#__PURE__*/jsx("div", {
1821
- 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
+ }),
1822
1981
  children: /*#__PURE__*/jsx(FilterValueDisplay, {
1823
1982
  value: filterValue,
1824
1983
  onChange: onFilterChange,
1825
- extraExpand: extraExpand
1984
+ extraExpand: extraExpand,
1985
+ flush: isMobileRender
1826
1986
  })
1827
1987
  }) : null]
1828
1988
  })
1829
1989
  });
1830
1990
  };
1831
1991
 
1832
- 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"],
1833
1993
  _excluded2 = ["pagination", "horizontalScroller", "getScrollContainer"];
1834
1994
  const readPageSize = key => {
1835
1995
  try {
@@ -1854,11 +2014,14 @@ const TABLE_COMPONENTS = {
1854
2014
  Table,
1855
2015
  TableView
1856
2016
  };
1857
- const collectFilterFieldNames = (filter, search) => {
2017
+ const collectFilterFieldNames = (filter, search, tab) => {
1858
2018
  const names = new Set();
1859
2019
  if (search != null && search.name) {
1860
2020
  names.add(search.name);
1861
2021
  }
2022
+ if (tab != null && tab.name) {
2023
+ names.add(tab.name);
2024
+ }
1862
2025
  if (Array.isArray(filter == null ? void 0 : filter.list)) {
1863
2026
  filter.list.forEach(row => {
1864
2027
  if (!Array.isArray(row)) {
@@ -1914,14 +2077,19 @@ const TablePageInnerContent = withLocale(_ref => {
1914
2077
  getScrollContainer,
1915
2078
  filter,
1916
2079
  search,
2080
+ tab,
2081
+ tabProps,
1917
2082
  batchActions,
1918
2083
  selectedRows,
1919
- rowSelection
2084
+ rowSelection,
2085
+ renderMobile
1920
2086
  } = _ref,
1921
2087
  props = _objectWithoutPropertiesLoose(_ref, _excluded);
1922
2088
  const {
1923
2089
  formatMessage
1924
2090
  } = useIntl();
2091
+ const isMobile = useIsMobile();
2092
+ const isMobileRenderActive = isRenderMobileActive(renderMobile, isMobile);
1925
2093
  const tableContentRef = useRef(null);
1926
2094
  const pendingScrollRef = useRef(false);
1927
2095
  const handlerDataFormat = useRefCallback(dataFormat);
@@ -1932,7 +2100,7 @@ const TablePageInnerContent = withLocale(_ref => {
1932
2100
  const getFilterParams = useRefCallback(value => {
1933
2101
  return mapFilterValue(value || []);
1934
2102
  });
1935
- const filterFieldNames = useMemo(() => collectFilterFieldNames(filter, search), [filter, search]);
2103
+ const filterFieldNames = useMemo(() => collectFilterFieldNames(filter, search, tab), [filter, search, tab]);
1936
2104
  const buildRequestParamsWithFilter = useRefCallback((value, extra = {}) => {
1937
2105
  return Object.assign({}, omitFilterParams(get(requestParams, pagination.paramsType), filterFieldNames), extra, getFilterParams(value));
1938
2106
  });
@@ -1951,7 +2119,12 @@ const TablePageInnerContent = withLocale(_ref => {
1951
2119
  dataFormat,
1952
2120
  pagination
1953
2121
  }), [data, fetchProps, requestParams, refresh, reload, loadMore, send, dataFormat, pagination]);
1954
- 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;
1955
2128
  const resolvedScrollTopInset = resolveScrollTopInset(scrollTopInset, stickyOffset);
1956
2129
  const scrollTopInsetStyle = useMemo(() => {
1957
2130
  const cssValue = normalizeScrollTopInsetCSSValue(resolvedScrollTopInset);
@@ -1992,33 +2165,41 @@ const TablePageInnerContent = withLocale(_ref => {
1992
2165
  pagination.onChange(page, size);
1993
2166
  return;
1994
2167
  }
1995
- 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) {
1996
2175
  (pagination.requestType === 'refresh' ? refresh : reload)({
1997
2176
  [pagination.paramsType]: buildRequestParamsWithFilter(filterValue, {
1998
2177
  [pagination.currentName]: page,
1999
- [pagination.pageSizeName]: Number(size)
2178
+ [pagination.pageSizeName]: nextSize
2000
2179
  })
2001
2180
  });
2002
- } else {
2003
- pagination.onShowSizeChange && pagination.onShowSizeChange(page, Number(size));
2004
2181
  }
2005
2182
  });
2006
2183
  const paginationConfig = useMemo(() => {
2184
+ var _mobilePagination$sho;
2007
2185
  if (!pagination.open) {
2008
2186
  return null;
2009
2187
  }
2010
- return {
2011
- total: formatData.total,
2012
- showTotal: typeof pagination.showTotal === 'function' ? pagination.showTotal : total => /*#__PURE__*/jsxs(Fragment, {
2013
- children: [formatMessage({
2014
- id: 'TotalText'
2015
- }), "\xA0", /*#__PURE__*/jsx("span", {
2016
- className: style$1['total_text'],
2017
- children: total
2018
- }), "\xA0", formatMessage({
2019
- id: 'ItemText'
2020
- })]
2021
- }),
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
+ } : {}, {
2022
2203
  current: get(requestParams, [pagination.paramsType, pagination.currentName], 1),
2023
2204
  pageSize: Number(get(requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize || 50,
2024
2205
  onChange: handlePaginationChange,
@@ -2027,8 +2208,20 @@ const TablePageInnerContent = withLocale(_ref => {
2027
2208
  showSizeChanger: pagination.showSizeChanger,
2028
2209
  showQuickJumper: pagination.showQuickJumper,
2029
2210
  pageSizeOptions: pagination.pageSizeOptions
2030
- };
2031
- }, [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]);
2032
2225
  const batchContext = useMemo(() => ({
2033
2226
  data,
2034
2227
  fetchProps,
@@ -2046,6 +2239,7 @@ const TablePageInnerContent = withLocale(_ref => {
2046
2239
  data
2047
2240
  });
2048
2241
  const tableProps = _extends({}, props, {
2242
+ renderMobile,
2049
2243
  rowSelection,
2050
2244
  dataSource: formatData.list,
2051
2245
  pagination: false,
@@ -2053,7 +2247,8 @@ const TablePageInnerContent = withLocale(_ref => {
2053
2247
  scrollTopInset: resolvedScrollTopInset,
2054
2248
  getStickyContainer: getScrollContainer,
2055
2249
  className: classnames(className, {
2056
- [style$1['table-in-toolbar']]: hasToolbar
2250
+ [style$1['table-in-toolbar']]: wrapWithToolbar,
2251
+ [style$1['is-mobile-render']]: isMobileRenderActive
2057
2252
  }),
2058
2253
  columns: resolvedColumns,
2059
2254
  context: tableContext,
@@ -2069,28 +2264,43 @@ const TablePageInnerContent = withLocale(_ref => {
2069
2264
  return /*#__PURE__*/jsxs("div", {
2070
2265
  className: style$1['table-page'],
2071
2266
  style: scrollTopInsetStyle,
2072
- children: [/*#__PURE__*/jsx(HorizontalScroller, {
2267
+ children: [/*#__PURE__*/jsxs(HorizontalScroller, {
2073
2268
  ref: tableContentRef,
2074
2269
  enabled: horizontalScroller && renderType === 'Table',
2075
2270
  getPortalContainer: getScrollContainer,
2076
2271
  className: classnames(style$1['table-content'], 'loading-container', {
2077
2272
  'is-loading': !isComplete && !data
2078
2273
  }),
2079
- children: hasToolbar ? /*#__PURE__*/jsxs("div", {
2080
- 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
+ }),
2081
2285
  children: [/*#__PURE__*/jsx(TableToolbar, {
2082
2286
  filterValue: filterValue,
2083
2287
  onFilterChange: handleFilterChange,
2084
2288
  filter: filter,
2085
2289
  search: search,
2290
+ tab: tab,
2291
+ tabProps: tabProps,
2292
+ renderTab: showInnerTab,
2086
2293
  batchActions: batchActions,
2087
2294
  rowSelection: rowSelection,
2088
2295
  selectedRows: selectedRows,
2089
- batchContext: batchContext
2296
+ batchContext: batchContext,
2297
+ isMobileRender: isMobileRenderActive
2090
2298
  }), tableElement]
2091
- }) : tableElement
2299
+ }) : tableElement]
2092
2300
  }), paginationConfig ? /*#__PURE__*/jsx(Pagination, _extends({
2093
- className: style$1['pagination']
2301
+ className: classnames(style$1['pagination'], {
2302
+ [style$1['is-mobile-render']]: isMobileRenderActive
2303
+ })
2094
2304
  }, paginationConfig)) : null]
2095
2305
  });
2096
2306
  });