@kne/table-page 0.1.8 → 0.1.10

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,21 @@
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 { TableView as TableView$1, isOptionsColumn, parseColumnWidth, isRenderMobileActive, resolveColumns, useSelectedRow, useSort, wrapColumnHeaderTitle, renderColumnTitle, getColumnEllipsis, computeColumnsValue, renderCellContent, computeDisplay } from '@kne/table-view';
9
+ export { RENDER_TYPE_NAMES, SIZE_NAMES, 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
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
10
11
  import { isEmpty } from '@kne/is-empty';
12
+ import { useIsMobile, usePopupContainer } from '@kne/responsive-utils';
11
13
  import useRefCallback from '@kne/use-ref-callback';
12
14
  import transform from 'lodash/transform';
13
15
  import pick from 'lodash/pick';
14
16
  import findLastIndex from 'lodash/findLastIndex';
15
17
  import isEqual from 'lodash/isEqual';
16
- import { HolderOutlined, RedoOutlined, SettingOutlined, DownOutlined } from '@ant-design/icons';
18
+ import { HolderOutlined, RedoOutlined, SettingOutlined, DownOutlined, DeleteOutlined } from '@ant-design/icons';
17
19
  import { useDebouncedCallback } from 'use-debounce';
18
20
  import groupBy from 'lodash/groupBy';
19
21
  import { ReactSortable } from 'react-sortablejs';
@@ -21,7 +23,6 @@ import cloneDeep from 'lodash/cloneDeep';
21
23
  import { createWithIntlProvider, useIntl } from '@kne/react-intl';
22
24
  import filterZhCN from '@kne/react-filter/dist/locale/zh-CN';
23
25
  import filterEnUS from '@kne/react-filter/dist/locale/en-US';
24
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
25
26
  import { createPortal } from 'react-dom';
26
27
  import '@kne/react-filter/dist/index.css';
27
28
 
@@ -44,7 +45,22 @@ 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
+ const _excluded$3 = ["renderMobile"];
49
+ const TableView = _ref => {
50
+ let {
51
+ renderMobile = true
52
+ } = _ref,
53
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
54
+ return /*#__PURE__*/jsx(TableView$1, _extends({
55
+ renderMobile: renderMobile
56
+ }, props));
57
+ };
58
+ TableView.Header = TableView$1.Header;
59
+ TableView.useSelectedRow = TableView$1.useSelectedRow;
60
+ TableView.useSort = TableView$1.useSort;
61
+ TableView.sortDataSource = TableView$1.sortDataSource;
62
+
63
+ 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
64
 
49
65
  const getColumnConfig = (config, columnName, field, defaultValue) => {
50
66
  const columnConfig = config == null ? void 0 : config[columnName];
@@ -73,8 +89,10 @@ const locale$1 = {
73
89
  Search: '搜索',
74
90
  BatchOperations: '批量操作',
75
91
  BatchOperationsWithCount: '批量操作(已选:{count}条)',
92
+ BatchOperationsMobileSelected: '已选:{count}条',
76
93
  Cancel: '取消',
77
- Confirm: '确定'
94
+ Confirm: '确定',
95
+ All: '全部'
78
96
  };
79
97
 
80
98
  const locale = {
@@ -88,8 +106,10 @@ const locale = {
88
106
  Search: 'Search',
89
107
  BatchOperations: 'Batch Actions',
90
108
  BatchOperationsWithCount: 'Batch Actions (Selected: {count})',
109
+ BatchOperationsMobileSelected: 'Selected: {count}',
91
110
  Cancel: 'Cancel',
92
- Confirm: 'Confirm'
111
+ Confirm: 'Confirm',
112
+ All: 'All'
93
113
  };
94
114
 
95
115
  const withLocale = createWithIntlProvider({
@@ -986,7 +1006,7 @@ const observeViewportIntersection = (element, onChange) => {
986
1006
  };
987
1007
  };
988
1008
 
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"],
1009
+ 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
1010
  _excluded2$2 = ["getContainer"];
991
1011
  const mapJustifyToAlign = justify => {
992
1012
  if (justify === 'center') {
@@ -1030,6 +1050,7 @@ const Table = p => {
1030
1050
  const tableRef = useRef(null);
1031
1051
  const tableWidth = useElementWidth(tableRef);
1032
1052
  const [isLayout, setIsLayout] = useState(true);
1053
+ const isMobile = useIsMobile();
1033
1054
  const props = Object.assign({}, {
1034
1055
  rowKey: 'id',
1035
1056
  valueIsEmpty: isEmpty,
@@ -1050,6 +1071,7 @@ const Table = p => {
1050
1071
  empty,
1051
1072
  onRowSelect,
1052
1073
  render,
1074
+ renderMobile = true,
1053
1075
  context,
1054
1076
  sticky,
1055
1077
  scrollTopInset,
@@ -1058,13 +1080,17 @@ const Table = p => {
1058
1080
  headerStyle,
1059
1081
  pagination = false,
1060
1082
  sortRender,
1083
+ mobileSortToolbar,
1061
1084
  name,
1062
1085
  controllerOpen,
1063
1086
  tableServerApis,
1064
1087
  scroll,
1065
- summary
1088
+ summary,
1089
+ size
1066
1090
  } = props,
1067
1091
  others = _objectWithoutPropertiesLoose(props, _excluded$2);
1092
+ const sizeClassName = size === 'small' ? style$2['is-size-small'] : size === 'large' ? style$2['is-size-large'] : null;
1093
+ const useMobileRender = isRenderMobileActive(renderMobile, isMobile);
1068
1094
  const columns = useMemo(() => resolveColumns(columnsProp), [columnsProp]);
1069
1095
  useEffect(() => {
1070
1096
  if (tableWidth) {
@@ -1240,7 +1266,8 @@ const Table = p => {
1240
1266
  }
1241
1267
  const getRowKey = record => resolveRowKey(rowKey, record);
1242
1268
  return _extends({
1243
- type: rowSelection.type === 'radio' ? 'radio' : 'checkbox'
1269
+ type: rowSelection.type === 'radio' ? 'radio' : 'checkbox',
1270
+ preserveSelectedRowKeys: true
1244
1271
  }, hasFixedColumn ? {
1245
1272
  fixed: 'left'
1246
1273
  } : {}, {
@@ -1252,14 +1279,22 @@ const Table = p => {
1252
1279
  rowSelection.onIsSelectAllChange(_checked);
1253
1280
  return;
1254
1281
  }
1282
+ const pageKeys = (dataSource || []).filter(item => !item.disabled).map(getRowKey);
1283
+ const existing = rowSelection.selectedRowKeys || [];
1255
1284
  if (!_checked) {
1256
- rowSelection.onChange([], undefined, {
1285
+ rowSelection.onChange(existing.filter(key => pageKeys.indexOf(key) === -1), undefined, {
1257
1286
  context,
1258
1287
  checked: false
1259
1288
  });
1260
1289
  return;
1261
1290
  }
1262
- rowSelection.onChange((dataSource || []).map(getRowKey), undefined, {
1291
+ const merged = existing.slice();
1292
+ pageKeys.forEach(key => {
1293
+ if (merged.indexOf(key) === -1) {
1294
+ merged.push(key);
1295
+ }
1296
+ });
1297
+ rowSelection.onChange(merged, undefined, {
1263
1298
  context,
1264
1299
  checked: true
1265
1300
  });
@@ -1345,6 +1380,25 @@ const Table = p => {
1345
1380
  '--scroll-top-inset': cssValue
1346
1381
  };
1347
1382
  }, [resolvedScrollTopInset]);
1383
+ if (useMobileRender) {
1384
+ return /*#__PURE__*/jsx(TableView, _extends({}, others, {
1385
+ className: classnames(className, style$2['is-mobile-render']),
1386
+ dataSource: dataSource,
1387
+ columns: visibleColumns,
1388
+ rowKey: rowKey,
1389
+ rowSelection: rowSelection,
1390
+ valueIsEmpty: valueIsEmpty,
1391
+ emptyIsPlaceholder: emptyIsPlaceholder,
1392
+ placeholder: placeholder,
1393
+ empty: empty,
1394
+ onRowSelect: onRowSelect,
1395
+ renderMobile: renderMobile,
1396
+ context: context,
1397
+ sortRender: sortRender,
1398
+ mobileSortToolbar: mobileSortToolbar,
1399
+ size: size
1400
+ }));
1401
+ }
1348
1402
  const tableElement = /*#__PURE__*/jsx(Table$1, _extends({}, others, {
1349
1403
  showHeader: true,
1350
1404
  dataSource: dataSource,
@@ -1389,7 +1443,7 @@ const Table = p => {
1389
1443
  }));
1390
1444
  const wrappedTable = /*#__PURE__*/jsxs("div", {
1391
1445
  ref: tableRef,
1392
- className: classnames(style$2['table'], 'info-page-table', className, {
1446
+ className: classnames(style$2['table'], 'info-page-table', sizeClassName, className, {
1393
1447
  [style$2['is-resize']]: currentMoveColumnIndex !== null,
1394
1448
  [style$2['is-computed']]: isLayout,
1395
1449
  [style$2['has-group-header']]: hasGroupHeader,
@@ -1420,7 +1474,7 @@ Table.useSelectedRow = useSelectedRow;
1420
1474
  Table.useSort = useSort;
1421
1475
  Table.sortDataSource = useSort.sortDataSource;
1422
1476
 
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"};
1477
+ 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
1478
 
1425
1479
  const BAR_HEIGHT = 15;
1426
1480
  const THUMB_MARGIN = 2;
@@ -1683,24 +1737,99 @@ const HorizontalScroller = /*#__PURE__*/forwardRef(({
1683
1737
  });
1684
1738
  });
1685
1739
 
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"};
1740
+ 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
1741
 
1688
1742
  const _excluded$1 = ["list", "displayLine", "extraExpand", "className"],
1689
1743
  _excluded2$1 = ["className", "style"];
1744
+ const TAB_ALL_KEY = '__all__';
1745
+ const getTabActiveKey = (filterValue, tabName) => {
1746
+ var _entry$value;
1747
+ if (!tabName || !Array.isArray(filterValue)) {
1748
+ return TAB_ALL_KEY;
1749
+ }
1750
+ const entry = filterValue.find(item => (item == null ? void 0 : item.name) === tabName);
1751
+ const value = entry == null || (_entry$value = entry.value) == null ? void 0 : _entry$value.value;
1752
+ return value == null || value === '' ? TAB_ALL_KEY : String(value);
1753
+ };
1754
+ const TablePageTabs = ({
1755
+ filterValue,
1756
+ onFilterChange,
1757
+ tab,
1758
+ tabProps,
1759
+ className,
1760
+ isMobileRender
1761
+ }) => {
1762
+ const {
1763
+ formatMessage
1764
+ } = useIntl();
1765
+ const showTab = !!(tab != null && tab.name && Array.isArray(tab.list) && tab.list.length > 0);
1766
+ const tabItems = useMemo(() => {
1767
+ if (!showTab) {
1768
+ return [];
1769
+ }
1770
+ return [{
1771
+ key: TAB_ALL_KEY,
1772
+ label: formatMessage({
1773
+ id: 'All'
1774
+ })
1775
+ }, ...tab.list.map(item => ({
1776
+ key: String(item.value),
1777
+ label: item.label
1778
+ }))];
1779
+ }, [showTab, tab == null ? void 0 : tab.list, formatMessage]);
1780
+ if (!showTab) {
1781
+ return null;
1782
+ }
1783
+ const handleTabChange = key => {
1784
+ const next = (Array.isArray(filterValue) ? filterValue : []).filter(item => (item == null ? void 0 : item.name) !== tab.name);
1785
+ if (key !== TAB_ALL_KEY) {
1786
+ const option = tab.list.find(item => String(item.value) === key);
1787
+ if (option) {
1788
+ next.push({
1789
+ name: tab.name,
1790
+ label: tab.label,
1791
+ value: {
1792
+ value: option.value,
1793
+ label: option.label
1794
+ }
1795
+ });
1796
+ }
1797
+ }
1798
+ onFilterChange(next);
1799
+ };
1800
+ return /*#__PURE__*/jsx("div", {
1801
+ className: classnames(style['table-page-tabs'], className, {
1802
+ [style['is-mobile-render']]: isMobileRender
1803
+ }),
1804
+ children: /*#__PURE__*/jsx(Tabs, _extends({
1805
+ size: "small"
1806
+ }, tabProps, {
1807
+ activeKey: getTabActiveKey(filterValue, tab.name),
1808
+ onChange: handleTabChange,
1809
+ items: tabItems
1810
+ }))
1811
+ });
1812
+ };
1690
1813
  const TableToolbar = ({
1691
1814
  filterValue,
1692
1815
  onFilterChange,
1693
1816
  filter,
1694
1817
  search,
1818
+ tab,
1819
+ tabProps,
1820
+ renderTab: _renderTab = true,
1695
1821
  batchActions,
1696
1822
  rowSelection,
1697
1823
  selectedRows,
1698
- batchContext
1824
+ batchContext,
1825
+ isMobileRender
1699
1826
  }) => {
1700
1827
  var _filter$list;
1701
1828
  const {
1702
1829
  formatMessage
1703
1830
  } = useIntl();
1831
+ const isMobile = useIsMobile();
1832
+ const getPopupContainer = usePopupContainer();
1704
1833
  const selectedRowKeys = (rowSelection == null ? void 0 : rowSelection.selectedRowKeys) || [];
1705
1834
  const hasSelection = selectedRowKeys.length > 0;
1706
1835
  const batchMenuItems = useMemo(() => {
@@ -1737,7 +1866,20 @@ const TableToolbar = ({
1737
1866
  const showBatch = batchMenuItems.length > 0;
1738
1867
  const showFilter = (filter == null || (_filter$list = filter.list) == null ? void 0 : _filter$list.length) > 0;
1739
1868
  const showSearch = search && search.name;
1740
- if (!showBatch && !showFilter && !showSearch) {
1869
+ const hasTab = !!(tab != null && tab.name && Array.isArray(tab.list) && tab.list.length > 0);
1870
+ const showTab = hasTab && _renderTab;
1871
+ const batchButtonLabel = hasSelection ? isMobile ? formatMessage({
1872
+ id: 'BatchOperationsMobileSelected'
1873
+ }, {
1874
+ count: selectedRowKeys.length
1875
+ }) : formatMessage({
1876
+ id: 'BatchOperationsWithCount'
1877
+ }, {
1878
+ count: selectedRowKeys.length
1879
+ }) : formatMessage({
1880
+ id: 'BatchOperations'
1881
+ });
1882
+ if (!showBatch && !showFilter && !showSearch && !showTab) {
1741
1883
  return null;
1742
1884
  }
1743
1885
  const _ref = filter || {},
@@ -1755,39 +1897,78 @@ const TableToolbar = ({
1755
1897
  } = _ref2,
1756
1898
  searchRest = _objectWithoutPropertiesLoose(_ref2, _excluded2$1);
1757
1899
  const hasValueDisplay = (filterValue == null ? void 0 : filterValue.length) > 0;
1758
- return /*#__PURE__*/jsx(FilterProvider, {
1900
+ const showMobileSearchRow = isMobile && showSearch;
1901
+ const showMainToolbar = showBatch || showFilter || !isMobile && showSearch;
1902
+ const searchInputNode = showSearch ? /*#__PURE__*/jsx(SearchInput, _extends({
1903
+ allowClear: true,
1904
+ bordered: false,
1905
+ variant: "filled",
1906
+ size: isMobile ? 'middle' : 'small',
1907
+ className: classnames(style['table-toolbar-search-input'], searchClassName),
1908
+ style: isMobile ? _extends({}, searchStyle, {
1909
+ width: '100%',
1910
+ maxWidth: '100%'
1911
+ }) : searchStyle
1912
+ }, searchRest)) : null;
1913
+ return /*#__PURE__*/jsx(FilterOuter, {
1759
1914
  value: filterValue,
1760
1915
  onChange: onFilterChange,
1761
- children: /*#__PURE__*/jsxs("div", {
1916
+ className: style['table-toolbar-filter-outer'],
1917
+ children: () => /*#__PURE__*/jsxs("div", {
1762
1918
  className: classnames(style['table-toolbar-section'], 'table-page-toolbar-section', {
1763
1919
  [style['has-value-display']]: hasValueDisplay,
1920
+ [style['has-mobile-search']]: showMobileSearchRow,
1921
+ [style['has-mobile-search-only']]: showMobileSearchRow && !showMainToolbar && !showTab,
1922
+ [style['has-tabs']]: showTab,
1923
+ [style['is-mobile-render']]: isMobileRender,
1764
1924
  'table-page-toolbar-section--has-value': hasValueDisplay
1765
1925
  }),
1766
- children: [/*#__PURE__*/jsxs("div", {
1767
- className: classnames(style['table-toolbar'], 'table-page-toolbar'),
1926
+ children: [showMobileSearchRow ? /*#__PURE__*/jsx("div", {
1927
+ className: classnames(style['table-toolbar-search-row'], style['table-toolbar-search']),
1928
+ children: searchInputNode
1929
+ }) : null, showTab ? /*#__PURE__*/jsx(TablePageTabs, {
1930
+ filterValue: filterValue,
1931
+ onFilterChange: onFilterChange,
1932
+ tab: tab,
1933
+ tabProps: tabProps,
1934
+ isMobileRender: isMobileRender
1935
+ }) : null, showMainToolbar ? /*#__PURE__*/jsxs("div", {
1936
+ className: classnames(style['table-toolbar'], 'table-page-toolbar', {
1937
+ [style['is-mobile']]: isMobile
1938
+ }),
1768
1939
  children: [showBatch ? /*#__PURE__*/jsxs(Fragment, {
1769
- children: [/*#__PURE__*/jsx("div", {
1940
+ children: [/*#__PURE__*/jsxs("div", {
1770
1941
  className: style['table-toolbar-batch'],
1771
- children: /*#__PURE__*/jsx(Dropdown, {
1942
+ children: [/*#__PURE__*/jsx(Dropdown, {
1772
1943
  disabled: !hasSelection,
1773
1944
  menu: {
1774
1945
  items: batchMenuItems
1775
1946
  },
1776
1947
  trigger: ['click'],
1948
+ getPopupContainer: getPopupContainer,
1777
1949
  children: /*#__PURE__*/jsxs(Button, {
1778
1950
  size: "small",
1779
1951
  disabled: !hasSelection,
1780
1952
  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, {})]
1953
+ children: [batchButtonLabel, /*#__PURE__*/jsx(DownOutlined, {})]
1788
1954
  })
1789
- })
1790
- }), (showFilter || showSearch) && /*#__PURE__*/jsx("span", {
1955
+ }), hasSelection ? /*#__PURE__*/jsx(Button, {
1956
+ danger: true,
1957
+ size: "small",
1958
+ icon: /*#__PURE__*/jsx(DeleteOutlined, {}),
1959
+ title: formatMessage({
1960
+ id: 'Cancel'
1961
+ }),
1962
+ "aria-label": formatMessage({
1963
+ id: 'Cancel'
1964
+ }),
1965
+ className: style['table-toolbar-batch-clear-btn'],
1966
+ onClick: () => {
1967
+ rowSelection == null || rowSelection.onChange == null || rowSelection.onChange([]);
1968
+ rowSelection == null || rowSelection.onIsSelectAllChange == null || rowSelection.onIsSelectAllChange(false);
1969
+ }
1970
+ }) : null]
1971
+ }), showFilter && /*#__PURE__*/jsx("span", {
1791
1972
  className: style['table-toolbar-divider'],
1792
1973
  "aria-hidden": true
1793
1974
  })]
@@ -1801,35 +1982,31 @@ const TableToolbar = ({
1801
1982
  label: ""
1802
1983
  }, filterRest))
1803
1984
  })
1804
- }) : null, showSearch ? /*#__PURE__*/jsxs(Fragment, {
1985
+ }) : null, !showMobileSearchRow && showSearch ? /*#__PURE__*/jsxs(Fragment, {
1805
1986
  children: [showFilter && /*#__PURE__*/jsx("span", {
1806
1987
  className: style['table-toolbar-divider'],
1807
1988
  "aria-hidden": true
1808
1989
  }), /*#__PURE__*/jsx("div", {
1809
1990
  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))
1991
+ children: searchInputNode
1818
1992
  })]
1819
1993
  }) : null]
1820
- }), hasValueDisplay ? /*#__PURE__*/jsx("div", {
1821
- className: style['table-toolbar-value-display'],
1994
+ }) : null, hasValueDisplay ? /*#__PURE__*/jsx("div", {
1995
+ className: classnames(style['table-toolbar-value-display'], {
1996
+ [style['is-mobile-render']]: isMobileRender
1997
+ }),
1822
1998
  children: /*#__PURE__*/jsx(FilterValueDisplay, {
1823
1999
  value: filterValue,
1824
2000
  onChange: onFilterChange,
1825
- extraExpand: extraExpand
2001
+ extraExpand: extraExpand,
2002
+ flush: isMobileRender
1826
2003
  })
1827
2004
  }) : null]
1828
2005
  })
1829
2006
  });
1830
2007
  };
1831
2008
 
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"],
2009
+ 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
2010
  _excluded2 = ["pagination", "horizontalScroller", "getScrollContainer"];
1834
2011
  const readPageSize = key => {
1835
2012
  try {
@@ -1854,11 +2031,14 @@ const TABLE_COMPONENTS = {
1854
2031
  Table,
1855
2032
  TableView
1856
2033
  };
1857
- const collectFilterFieldNames = (filter, search) => {
2034
+ const collectFilterFieldNames = (filter, search, tab) => {
1858
2035
  const names = new Set();
1859
2036
  if (search != null && search.name) {
1860
2037
  names.add(search.name);
1861
2038
  }
2039
+ if (tab != null && tab.name) {
2040
+ names.add(tab.name);
2041
+ }
1862
2042
  if (Array.isArray(filter == null ? void 0 : filter.list)) {
1863
2043
  filter.list.forEach(row => {
1864
2044
  if (!Array.isArray(row)) {
@@ -1914,14 +2094,19 @@ const TablePageInnerContent = withLocale(_ref => {
1914
2094
  getScrollContainer,
1915
2095
  filter,
1916
2096
  search,
2097
+ tab,
2098
+ tabProps,
1917
2099
  batchActions,
1918
2100
  selectedRows,
1919
- rowSelection
2101
+ rowSelection,
2102
+ renderMobile = true
1920
2103
  } = _ref,
1921
2104
  props = _objectWithoutPropertiesLoose(_ref, _excluded);
1922
2105
  const {
1923
2106
  formatMessage
1924
2107
  } = useIntl();
2108
+ const isMobile = useIsMobile();
2109
+ const isMobileRenderActive = isRenderMobileActive(renderMobile, isMobile);
1925
2110
  const tableContentRef = useRef(null);
1926
2111
  const pendingScrollRef = useRef(false);
1927
2112
  const handlerDataFormat = useRefCallback(dataFormat);
@@ -1932,7 +2117,7 @@ const TablePageInnerContent = withLocale(_ref => {
1932
2117
  const getFilterParams = useRefCallback(value => {
1933
2118
  return mapFilterValue(value || []);
1934
2119
  });
1935
- const filterFieldNames = useMemo(() => collectFilterFieldNames(filter, search), [filter, search]);
2120
+ const filterFieldNames = useMemo(() => collectFilterFieldNames(filter, search, tab), [filter, search, tab]);
1936
2121
  const buildRequestParamsWithFilter = useRefCallback((value, extra = {}) => {
1937
2122
  return Object.assign({}, omitFilterParams(get(requestParams, pagination.paramsType), filterFieldNames), extra, getFilterParams(value));
1938
2123
  });
@@ -1951,7 +2136,12 @@ const TablePageInnerContent = withLocale(_ref => {
1951
2136
  dataFormat,
1952
2137
  pagination
1953
2138
  }), [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);
2139
+ const hasTab = !!(tab != null && tab.name && Array.isArray(tab.list) && tab.list.length > 0);
2140
+ const hasInnerToolbar = !!(filter != null && (_filter$list = filter.list) != null && _filter$list.length || search && search.name || batchActions && batchActions.length);
2141
+ const showOuterTab = hasTab && !isMobile;
2142
+ const showInnerTab = hasTab && isMobile;
2143
+ const wrapWithToolbar = hasInnerToolbar || showInnerTab;
2144
+ const hasToolbar = wrapWithToolbar || showOuterTab;
1955
2145
  const resolvedScrollTopInset = resolveScrollTopInset(scrollTopInset, stickyOffset);
1956
2146
  const scrollTopInsetStyle = useMemo(() => {
1957
2147
  const cssValue = normalizeScrollTopInsetCSSValue(resolvedScrollTopInset);
@@ -1992,33 +2182,41 @@ const TablePageInnerContent = withLocale(_ref => {
1992
2182
  pagination.onChange(page, size);
1993
2183
  return;
1994
2184
  }
1995
- if (page !== get(requestParams, [pagination.paramsType, pagination.currentName], 1)) {
2185
+ const nextSize = Number(size);
2186
+ const currentPage = get(requestParams, [pagination.paramsType, pagination.currentName], 1);
2187
+ const currentSize = Number(get(requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize || 50;
2188
+ if (nextSize !== currentSize) {
2189
+ pagination.onShowSizeChange && pagination.onShowSizeChange(page, nextSize);
2190
+ }
2191
+ if (page !== currentPage || nextSize !== currentSize) {
1996
2192
  (pagination.requestType === 'refresh' ? refresh : reload)({
1997
2193
  [pagination.paramsType]: buildRequestParamsWithFilter(filterValue, {
1998
2194
  [pagination.currentName]: page,
1999
- [pagination.pageSizeName]: Number(size)
2195
+ [pagination.pageSizeName]: nextSize
2000
2196
  })
2001
2197
  });
2002
- } else {
2003
- pagination.onShowSizeChange && pagination.onShowSizeChange(page, Number(size));
2004
2198
  }
2005
2199
  });
2006
2200
  const paginationConfig = useMemo(() => {
2201
+ var _mobilePagination$sho;
2007
2202
  if (!pagination.open) {
2008
2203
  return null;
2009
2204
  }
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
- }),
2205
+ const defaultShowTotal = total => /*#__PURE__*/jsxs(Fragment, {
2206
+ children: [formatMessage({
2207
+ id: 'TotalText'
2208
+ }), "\xA0", /*#__PURE__*/jsx("span", {
2209
+ className: style$1['total_text'],
2210
+ children: total
2211
+ }), "\xA0", formatMessage({
2212
+ id: 'ItemText'
2213
+ })]
2214
+ });
2215
+ const baseConfig = _extends({
2216
+ total: formatData.total
2217
+ }, pagination.showTotal !== false ? {
2218
+ showTotal: typeof pagination.showTotal === 'function' ? pagination.showTotal : defaultShowTotal
2219
+ } : {}, {
2022
2220
  current: get(requestParams, [pagination.paramsType, pagination.currentName], 1),
2023
2221
  pageSize: Number(get(requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize || 50,
2024
2222
  onChange: handlePaginationChange,
@@ -2027,8 +2225,20 @@ const TablePageInnerContent = withLocale(_ref => {
2027
2225
  showSizeChanger: pagination.showSizeChanger,
2028
2226
  showQuickJumper: pagination.showQuickJumper,
2029
2227
  pageSizeOptions: pagination.pageSizeOptions
2030
- };
2031
- }, [pagination, formatData.total, requestParams, formatMessage, handlePaginationChange]);
2228
+ });
2229
+ if (!isMobileRenderActive) {
2230
+ return baseConfig;
2231
+ }
2232
+ const mobilePagination = pagination.mobile || {};
2233
+ return _extends({}, baseConfig, {
2234
+ onShowSizeChange: handlePaginationChange,
2235
+ size: mobilePagination.size,
2236
+ showSizeChanger: mobilePagination.showSizeChanger !== false && pagination.showSizeChanger !== false,
2237
+ showQuickJumper: mobilePagination.showQuickJumper === true,
2238
+ showLessItems: (_mobilePagination$sho = mobilePagination.showLessItems) != null ? _mobilePagination$sho : true,
2239
+ pageSizeOptions: pagination.pageSizeOptions || ['10', '20', '50', '100']
2240
+ });
2241
+ }, [pagination, formatData.total, requestParams, formatMessage, handlePaginationChange, isMobileRenderActive]);
2032
2242
  const batchContext = useMemo(() => ({
2033
2243
  data,
2034
2244
  fetchProps,
@@ -2046,6 +2256,7 @@ const TablePageInnerContent = withLocale(_ref => {
2046
2256
  data
2047
2257
  });
2048
2258
  const tableProps = _extends({}, props, {
2259
+ renderMobile,
2049
2260
  rowSelection,
2050
2261
  dataSource: formatData.list,
2051
2262
  pagination: false,
@@ -2053,7 +2264,8 @@ const TablePageInnerContent = withLocale(_ref => {
2053
2264
  scrollTopInset: resolvedScrollTopInset,
2054
2265
  getStickyContainer: getScrollContainer,
2055
2266
  className: classnames(className, {
2056
- [style$1['table-in-toolbar']]: hasToolbar
2267
+ [style$1['table-in-toolbar']]: wrapWithToolbar,
2268
+ [style$1['is-mobile-render']]: isMobileRenderActive
2057
2269
  }),
2058
2270
  columns: resolvedColumns,
2059
2271
  context: tableContext,
@@ -2069,28 +2281,43 @@ const TablePageInnerContent = withLocale(_ref => {
2069
2281
  return /*#__PURE__*/jsxs("div", {
2070
2282
  className: style$1['table-page'],
2071
2283
  style: scrollTopInsetStyle,
2072
- children: [/*#__PURE__*/jsx(HorizontalScroller, {
2284
+ children: [/*#__PURE__*/jsxs(HorizontalScroller, {
2073
2285
  ref: tableContentRef,
2074
2286
  enabled: horizontalScroller && renderType === 'Table',
2075
2287
  getPortalContainer: getScrollContainer,
2076
2288
  className: classnames(style$1['table-content'], 'loading-container', {
2077
2289
  'is-loading': !isComplete && !data
2078
2290
  }),
2079
- children: hasToolbar ? /*#__PURE__*/jsxs("div", {
2080
- className: style$1['table-with-toolbar'],
2291
+ children: [showOuterTab ? /*#__PURE__*/jsx(TablePageTabs, {
2292
+ filterValue: filterValue,
2293
+ onFilterChange: handleFilterChange,
2294
+ tab: tab,
2295
+ tabProps: tabProps,
2296
+ className: style$1['table-page-tabs-outer'],
2297
+ isMobileRender: isMobileRenderActive
2298
+ }) : null, wrapWithToolbar ? /*#__PURE__*/jsxs("div", {
2299
+ className: classnames(style$1['table-with-toolbar'], {
2300
+ [style$1['is-mobile-render']]: isMobileRenderActive
2301
+ }),
2081
2302
  children: [/*#__PURE__*/jsx(TableToolbar, {
2082
2303
  filterValue: filterValue,
2083
2304
  onFilterChange: handleFilterChange,
2084
2305
  filter: filter,
2085
2306
  search: search,
2307
+ tab: tab,
2308
+ tabProps: tabProps,
2309
+ renderTab: showInnerTab,
2086
2310
  batchActions: batchActions,
2087
2311
  rowSelection: rowSelection,
2088
2312
  selectedRows: selectedRows,
2089
- batchContext: batchContext
2313
+ batchContext: batchContext,
2314
+ isMobileRender: isMobileRenderActive
2090
2315
  }), tableElement]
2091
- }) : tableElement
2316
+ }) : tableElement]
2092
2317
  }), paginationConfig ? /*#__PURE__*/jsx(Pagination, _extends({
2093
- className: style$1['pagination']
2318
+ className: classnames(style$1['pagination'], {
2319
+ [style$1['is-mobile-render']]: isMobileRenderActive
2320
+ })
2094
2321
  }, paginationConfig)) : null]
2095
2322
  });
2096
2323
  });
@@ -2152,5 +2379,5 @@ const TablePage = /*#__PURE__*/forwardRef((_ref2, ref) => {
2152
2379
  }));
2153
2380
  });
2154
2381
 
2155
- export { Table, TablePage as default, tableLocalApis, useTableConfig };
2382
+ export { Table, TableView, TablePage as default, tableLocalApis, useTableConfig };
2156
2383
  //# sourceMappingURL=index.modern.js.map