@kne/table-page 0.1.12 → 0.1.14

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,11 +1,14 @@
1
1
  import '@kne/table-view/dist/index.css';
2
+ import '@kne/scroll-loader/dist/index.css';
2
3
  import { withFetch } from '@kne/react-fetch';
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';
4
+ import { Checkbox, Row, Col, Input, List, Tooltip, Button, Collapse, Popover, Empty, Table as Table$1, Tabs, Dropdown, Segmented, Pagination } from 'antd';
5
+ import { HolderOutlined, RedoOutlined, SettingOutlined, DownOutlined, DeleteOutlined, TableOutlined, AppstoreOutlined } from '@ant-design/icons';
6
+ import { SearchInput, FilterLines, FilterOuter, FilterValueDisplay, getFilterValue } from '@kne/react-filter';
7
+ import ScrollLoader from '@kne/scroll-loader';
5
8
  import { useState, useMemo, useRef, useCallback, useEffect, useLayoutEffect, forwardRef } from 'react';
6
9
  import classnames from 'classnames';
7
10
  import get from 'lodash/get';
8
- import { TableView as TableView$1, isOptionsColumn, parseColumnWidth, isRenderMobileActive, resolveColumns, useSelectedRow, useSort, wrapColumnHeaderTitle, renderColumnTitle, getColumnEllipsis, computeColumnsValue, renderCellContent, computeDisplay } from '@kne/table-view';
11
+ import { TableView as TableView$1, isOptionsColumn, parseColumnWidth, isRenderMobileActive, resolveColumns, useSelectedRow, useSort, wrapColumnHeaderTitle, renderColumnTitle, getColumnEllipsis, computeColumnsValue, renderCellContent, computeDisplay, globalParams } from '@kne/table-view';
9
12
  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
13
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
11
14
  import { isEmpty } from '@kne/is-empty';
@@ -15,7 +18,6 @@ import transform from 'lodash/transform';
15
18
  import pick from 'lodash/pick';
16
19
  import findLastIndex from 'lodash/findLastIndex';
17
20
  import isEqual from 'lodash/isEqual';
18
- import { HolderOutlined, RedoOutlined, SettingOutlined, DownOutlined, DeleteOutlined } from '@ant-design/icons';
19
21
  import { useDebouncedCallback } from 'use-debounce';
20
22
  import groupBy from 'lodash/groupBy';
21
23
  import { ReactSortable } from 'react-sortablejs';
@@ -24,7 +26,9 @@ import { createWithIntlProvider, useIntl } from '@kne/react-intl';
24
26
  import filterZhCN from '@kne/react-filter/dist/locale/zh-CN';
25
27
  import filterEnUS from '@kne/react-filter/dist/locale/en-US';
26
28
  import { createPortal } from 'react-dom';
29
+ import '@kne/button-group/dist/index.css';
27
30
  import '@kne/react-filter/dist/index.css';
31
+ import ButtonGroup from '@kne/button-group';
28
32
 
29
33
  function _extends() {
30
34
  return _extends = Object.assign ? Object.assign.bind() : function (n) {
@@ -45,12 +49,12 @@ function _objectWithoutPropertiesLoose(r, e) {
45
49
  return t;
46
50
  }
47
51
 
48
- const _excluded$3 = ["renderMobile"];
52
+ const _excluded$4 = ["renderMobile"];
49
53
  const TableView = _ref => {
50
54
  let {
51
55
  renderMobile = true
52
56
  } = _ref,
53
- props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
57
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
54
58
  return /*#__PURE__*/jsx(TableView$1, _extends({
55
59
  renderMobile: renderMobile
56
60
  }, props));
@@ -92,7 +96,9 @@ const locale$1 = {
92
96
  BatchOperationsMobileSelected: '已选:{count}条',
93
97
  Cancel: '取消',
94
98
  Confirm: '确定',
95
- All: '全部'
99
+ All: '全部',
100
+ SwitchToCardView: '切换为卡片视图',
101
+ SwitchToTableView: '切换为表格视图'
96
102
  };
97
103
 
98
104
  const locale = {
@@ -109,7 +115,9 @@ const locale = {
109
115
  BatchOperationsMobileSelected: 'Selected: {count}',
110
116
  Cancel: 'Cancel',
111
117
  Confirm: 'Confirm',
112
- All: 'All'
118
+ All: 'All',
119
+ SwitchToCardView: 'Switch to card view',
120
+ SwitchToTableView: 'Switch to table view'
113
121
  };
114
122
 
115
123
  const withLocale = createWithIntlProvider({
@@ -1006,7 +1014,7 @@ const observeViewportIntersection = (element, onChange) => {
1006
1014
  };
1007
1015
  };
1008
1016
 
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"],
1017
+ const _excluded$3 = ["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"],
1010
1018
  _excluded2$2 = ["y"],
1011
1019
  _excluded3 = ["getContainer"];
1012
1020
  const mapJustifyToAlign = justify => {
@@ -1089,7 +1097,7 @@ const Table = p => {
1089
1097
  summary,
1090
1098
  size
1091
1099
  } = props,
1092
- others = _objectWithoutPropertiesLoose(props, _excluded$2);
1100
+ others = _objectWithoutPropertiesLoose(props, _excluded$3);
1093
1101
  const sizeClassName = size === 'small' ? style$2['is-size-small'] : size === 'large' ? style$2['is-size-large'] : null;
1094
1102
  const useMobileRender = isRenderMobileActive(renderMobile, isMobile);
1095
1103
  const columns = useMemo(() => resolveColumns(columnsProp), [columnsProp]);
@@ -1336,6 +1344,9 @@ const Table = p => {
1336
1344
  x = totalWidth;
1337
1345
  } else if (controllerOpen) {
1338
1346
  x = Math.max(tableWidth, totalWidth);
1347
+ } else if (tableWidth && totalWidth > tableWidth) {
1348
+ // controllerOpen 关闭时列总宽超出容器也要开启横向滚动,避免列溢出
1349
+ x = totalWidth;
1339
1350
  }
1340
1351
  const nextScroll = Object.assign({}, x != null ? {
1341
1352
  x
@@ -1481,7 +1492,7 @@ Table.useSelectedRow = useSelectedRow;
1481
1492
  Table.useSort = useSort;
1482
1493
  Table.sortDataSource = useSort.sortDataSource;
1483
1494
 
1484
- 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"};
1495
+ 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","is-card-mode":"kne-table-page_kH6wM","is-card-render":"kne-table-page_-WbMN","card-mode-toggle":"kne-table-page_ostpI","mobile-load-more":"kne-table-page_UqVnb","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"};
1485
1496
 
1486
1497
  const BAR_HEIGHT = 15;
1487
1498
  const THUMB_MARGIN = 2;
@@ -1744,7 +1755,63 @@ const HorizontalScroller = /*#__PURE__*/forwardRef(({
1744
1755
  });
1745
1756
  });
1746
1757
 
1747
- 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"};
1758
+ const _excluded$2 = ["size", "moreType", "showLength", "list", "getPopupContainer"];
1759
+ const hasButtonGroupList = buttonGroup => Array.isArray(buttonGroup == null ? void 0 : buttonGroup.list) && buttonGroup.list.length > 0;
1760
+ const normalizeButtonGroupList = (list, defaultSize) => {
1761
+ if (!Array.isArray(list)) {
1762
+ return list;
1763
+ }
1764
+ return list.map(item => {
1765
+ var _item$size;
1766
+ if (typeof item === 'function') {
1767
+ return item;
1768
+ }
1769
+ if (defaultSize === undefined) {
1770
+ return _extends({}, item);
1771
+ }
1772
+ return _extends({}, item, {
1773
+ size: (_item$size = item.size) != null ? _item$size : defaultSize
1774
+ });
1775
+ });
1776
+ };
1777
+ const resolveButtonGroupProps = (buttonGroup, getPopupContainer, {
1778
+ defaultSize,
1779
+ defaultShowLength,
1780
+ minShowLength
1781
+ }) => {
1782
+ if (!buttonGroup) {
1783
+ return {};
1784
+ }
1785
+ const {
1786
+ size,
1787
+ moreType,
1788
+ showLength,
1789
+ list,
1790
+ getPopupContainer: userGetPopupContainer
1791
+ } = buttonGroup,
1792
+ rest = _objectWithoutPropertiesLoose(buttonGroup, _excluded$2);
1793
+ const resolvedShowLength = Number.isInteger(showLength) ? Math.max(minShowLength, showLength) : defaultShowLength;
1794
+ return _extends({}, rest, {
1795
+ list: normalizeButtonGroupList(list, defaultSize)
1796
+ }, defaultSize !== undefined ? {
1797
+ size: size != null ? size : defaultSize
1798
+ } : size !== undefined ? {
1799
+ size
1800
+ } : {}, {
1801
+ moreType: moreType != null ? moreType : 'link',
1802
+ showLength: resolvedShowLength,
1803
+ getPopupContainer: userGetPopupContainer != null ? userGetPopupContainer : getPopupContainer
1804
+ });
1805
+ };
1806
+ const resolveToolbarButtonGroupProps = (buttonGroup, getPopupContainer) => {
1807
+ return resolveButtonGroupProps(buttonGroup, getPopupContainer, {
1808
+ defaultSize: 'small',
1809
+ defaultShowLength: 1,
1810
+ minShowLength: 1
1811
+ });
1812
+ };
1813
+
1814
+ 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-actions":"kne-table-page_t3-57","table-toolbar-button-group":"kne-table-page_2sdSC","table-toolbar-search":"kne-table-page_pB5en","table-page-tabs":"kne-table-page_UTy3R","is-mobile-render":"kne-table-page_J-AEV","is-mobile":"kne-table-page_n9eAS","table-toolbar-mobile-actions":"kne-table-page_I--A1","table-toolbar-mobile-filter-row":"kne-table-page_Qo5Zl","table-toolbar-filter":"kne-table-page_Jyfm7","has-mobile-search":"kne-table-page_14SJt","table-toolbar-search-row":"kne-table-page_zuGJv","has-mobile-search-only":"kne-table-page_Y5IR1","has-tabs":"kne-table-page_EImBh","table-toolbar-search-input":"kne-table-page_t60hK","table-toolbar-divider":"kne-table-page_z--2N","table-toolbar-filter-outer":"kne-table-page_PiWGM","table-toolbar-filter-inner":"kne-table-page_AX3aK"};
1748
1815
 
1749
1816
  const _excluded$1 = ["list", "displayLine", "extraExpand", "className"],
1750
1817
  _excluded2$1 = ["className", "style"];
@@ -1817,21 +1884,13 @@ const TablePageTabs = ({
1817
1884
  }))
1818
1885
  });
1819
1886
  };
1820
- const TableToolbar = ({
1821
- filterValue,
1822
- onFilterChange,
1823
- filter,
1824
- search,
1825
- tab,
1826
- tabProps,
1827
- renderTab: _renderTab = true,
1887
+ const BatchActions = ({
1828
1888
  batchActions,
1829
1889
  rowSelection,
1830
1890
  selectedRows,
1831
1891
  batchContext,
1832
- isMobileRender
1892
+ className
1833
1893
  }) => {
1834
- var _filter$list;
1835
1894
  const {
1836
1895
  formatMessage
1837
1896
  } = useIntl();
@@ -1870,11 +1929,9 @@ const TableToolbar = ({
1870
1929
  };
1871
1930
  });
1872
1931
  }, [batchActions, batchContext, hasSelection, rowSelection, selectedRowKeys, selectedRows]);
1873
- const showBatch = batchMenuItems.length > 0;
1874
- const showFilter = (filter == null || (_filter$list = filter.list) == null ? void 0 : _filter$list.length) > 0;
1875
- const showSearch = search && search.name;
1876
- const hasTab = !!(tab != null && tab.name && Array.isArray(tab.list) && tab.list.length > 0);
1877
- const showTab = hasTab && _renderTab;
1932
+ if (batchMenuItems.length === 0) {
1933
+ return null;
1934
+ }
1878
1935
  const batchButtonLabel = hasSelection ? isMobile ? formatMessage({
1879
1936
  id: 'BatchOperationsMobileSelected'
1880
1937
  }, {
@@ -1886,7 +1943,68 @@ const TableToolbar = ({
1886
1943
  }) : formatMessage({
1887
1944
  id: 'BatchOperations'
1888
1945
  });
1889
- if (!showBatch && !showFilter && !showSearch && !showTab) {
1946
+ return /*#__PURE__*/jsxs("div", {
1947
+ className: classnames(style['table-toolbar-batch'], className),
1948
+ children: [/*#__PURE__*/jsx(Dropdown, {
1949
+ disabled: !hasSelection,
1950
+ menu: {
1951
+ items: batchMenuItems
1952
+ },
1953
+ trigger: ['click'],
1954
+ getPopupContainer: getPopupContainer,
1955
+ children: /*#__PURE__*/jsxs(Button, {
1956
+ size: "small",
1957
+ disabled: !hasSelection,
1958
+ className: style['table-toolbar-batch-btn'],
1959
+ children: [batchButtonLabel, /*#__PURE__*/jsx(DownOutlined, {})]
1960
+ })
1961
+ }), hasSelection ? /*#__PURE__*/jsx(Button, {
1962
+ danger: true,
1963
+ size: "small",
1964
+ icon: /*#__PURE__*/jsx(DeleteOutlined, {}),
1965
+ title: formatMessage({
1966
+ id: 'Cancel'
1967
+ }),
1968
+ "aria-label": formatMessage({
1969
+ id: 'Cancel'
1970
+ }),
1971
+ className: style['table-toolbar-batch-clear-btn'],
1972
+ onClick: () => {
1973
+ rowSelection == null || rowSelection.onChange == null || rowSelection.onChange([]);
1974
+ rowSelection == null || rowSelection.onIsSelectAllChange == null || rowSelection.onIsSelectAllChange(false);
1975
+ }
1976
+ }) : null]
1977
+ });
1978
+ };
1979
+ const TableToolbar = ({
1980
+ filterValue,
1981
+ onFilterChange,
1982
+ filter,
1983
+ search,
1984
+ tab,
1985
+ tabProps,
1986
+ renderTab: _renderTab = true,
1987
+ batchActions,
1988
+ buttonGroup,
1989
+ rowSelection,
1990
+ selectedRows,
1991
+ batchContext,
1992
+ isMobileRender,
1993
+ cardModeToggle
1994
+ }) => {
1995
+ var _filter$list;
1996
+ const isMobile = useIsMobile();
1997
+ const getPopupContainer = usePopupContainer();
1998
+ const showBatch = Array.isArray(batchActions) && batchActions.length > 0;
1999
+ // 移动端卡片模式下批量操作渲染在「全选/排序」行(排序后面),不在工具栏中
2000
+ const showBatchInToolbar = showBatch && !isMobileRender;
2001
+ const showFilter = (filter == null || (_filter$list = filter.list) == null ? void 0 : _filter$list.length) > 0;
2002
+ const showSearch = search && search.name;
2003
+ const showButtonGroup = hasButtonGroupList(buttonGroup);
2004
+ const showCardModeToggle = !isMobile && !!cardModeToggle;
2005
+ const hasTab = !!(tab != null && tab.name && Array.isArray(tab.list) && tab.list.length > 0);
2006
+ const showTab = hasTab && _renderTab;
2007
+ if (!showBatchInToolbar && !showFilter && !showSearch && !showTab && !showButtonGroup && !showCardModeToggle) {
1890
2008
  return null;
1891
2009
  }
1892
2010
  const _ref = filter || {},
@@ -1903,9 +2021,18 @@ const TableToolbar = ({
1903
2021
  style: searchStyle
1904
2022
  } = _ref2,
1905
2023
  searchRest = _objectWithoutPropertiesLoose(_ref2, _excluded2$1);
1906
- const hasValueDisplay = (filterValue == null ? void 0 : filterValue.length) > 0;
2024
+
2025
+ // tab 已有选中态展示,已选筛选标签中不再重复显示 tab 的值
2026
+ const displayFilterValue = hasTab ? (filterValue || []).filter(item => (item == null ? void 0 : item.name) !== tab.name) : filterValue || [];
2027
+ const handleValueDisplayChange = next => {
2028
+ const tabEntry = hasTab ? (filterValue || []).find(item => (item == null ? void 0 : item.name) === tab.name) : null;
2029
+ onFilterChange(tabEntry ? [...(next || []), tabEntry] : next);
2030
+ };
2031
+ const hasValueDisplay = displayFilterValue.length > 0;
1907
2032
  const showMobileSearchRow = isMobile && showSearch;
1908
- const showMainToolbar = showBatch || showFilter || !isMobile && showSearch;
2033
+ const showMainToolbar = showBatchInToolbar || showFilter || showButtonGroup || !isMobile && (showSearch || showCardModeToggle);
2034
+ const showDesktopActions = !isMobile && (showSearch || showButtonGroup || showCardModeToggle);
2035
+ const showActionsDivider = showDesktopActions && (showBatchInToolbar || showFilter);
1909
2036
  const searchInputNode = showSearch ? /*#__PURE__*/jsx(SearchInput, _extends({
1910
2037
  allowClear: true,
1911
2038
  bordered: false,
@@ -1917,6 +2044,27 @@ const TableToolbar = ({
1917
2044
  maxWidth: '100%'
1918
2045
  }) : searchStyle
1919
2046
  }, searchRest)) : null;
2047
+ const buttonGroupNode = showButtonGroup ? /*#__PURE__*/jsx("div", {
2048
+ className: style['table-toolbar-button-group'],
2049
+ children: /*#__PURE__*/jsx(ButtonGroup, _extends({}, resolveToolbarButtonGroupProps(buttonGroup, getPopupContainer)))
2050
+ }) : null;
2051
+ const batchActionsNode = showBatchInToolbar ? /*#__PURE__*/jsx(BatchActions, {
2052
+ batchActions: batchActions,
2053
+ rowSelection: rowSelection,
2054
+ selectedRows: selectedRows,
2055
+ batchContext: batchContext
2056
+ }) : null;
2057
+ const filterNode = showFilter ? /*#__PURE__*/jsx("div", {
2058
+ className: style['table-toolbar-filter'],
2059
+ children: /*#__PURE__*/jsx("div", {
2060
+ className: classnames(style['table-toolbar-filter-inner'], filterClassName),
2061
+ children: /*#__PURE__*/jsx(FilterLines, _extends({
2062
+ list: filterList,
2063
+ displayLine: displayLine,
2064
+ label: ""
2065
+ }, filterRest))
2066
+ })
2067
+ }) : null;
1920
2068
  return /*#__PURE__*/jsx(FilterOuter, {
1921
2069
  value: filterValue,
1922
2070
  onChange: onFilterChange,
@@ -1939,72 +2087,44 @@ const TableToolbar = ({
1939
2087
  tab: tab,
1940
2088
  tabProps: tabProps,
1941
2089
  isMobileRender: isMobileRender
1942
- }) : null, showMainToolbar ? /*#__PURE__*/jsxs("div", {
2090
+ }) : null, showMainToolbar ? /*#__PURE__*/jsx("div", {
1943
2091
  className: classnames(style['table-toolbar'], 'table-page-toolbar', {
1944
2092
  [style['is-mobile']]: isMobile
1945
2093
  }),
1946
- children: [showBatch ? /*#__PURE__*/jsxs(Fragment, {
1947
- children: [/*#__PURE__*/jsxs("div", {
1948
- className: style['table-toolbar-batch'],
1949
- children: [/*#__PURE__*/jsx(Dropdown, {
1950
- disabled: !hasSelection,
1951
- menu: {
1952
- items: batchMenuItems
1953
- },
1954
- trigger: ['click'],
1955
- getPopupContainer: getPopupContainer,
1956
- children: /*#__PURE__*/jsxs(Button, {
1957
- size: "small",
1958
- disabled: !hasSelection,
1959
- className: style['table-toolbar-batch-btn'],
1960
- children: [batchButtonLabel, /*#__PURE__*/jsx(DownOutlined, {})]
1961
- })
1962
- }), hasSelection ? /*#__PURE__*/jsx(Button, {
1963
- danger: true,
1964
- size: "small",
1965
- icon: /*#__PURE__*/jsx(DeleteOutlined, {}),
1966
- title: formatMessage({
1967
- id: 'Cancel'
1968
- }),
1969
- "aria-label": formatMessage({
1970
- id: 'Cancel'
1971
- }),
1972
- className: style['table-toolbar-batch-clear-btn'],
1973
- onClick: () => {
1974
- rowSelection == null || rowSelection.onChange == null || rowSelection.onChange([]);
1975
- rowSelection == null || rowSelection.onIsSelectAllChange == null || rowSelection.onIsSelectAllChange(false);
1976
- }
1977
- }) : null]
1978
- }), showFilter && /*#__PURE__*/jsx("span", {
1979
- className: style['table-toolbar-divider'],
1980
- "aria-hidden": true
1981
- })]
1982
- }) : null, showFilter ? /*#__PURE__*/jsx("div", {
1983
- className: style['table-toolbar-filter'],
1984
- children: /*#__PURE__*/jsx("div", {
1985
- className: classnames(style['table-toolbar-filter-inner'], filterClassName),
1986
- children: /*#__PURE__*/jsx(FilterLines, _extends({
1987
- list: filterList,
1988
- displayLine: displayLine,
1989
- label: ""
1990
- }, filterRest))
1991
- })
1992
- }) : null, !showMobileSearchRow && showSearch ? /*#__PURE__*/jsxs(Fragment, {
1993
- children: [showFilter && /*#__PURE__*/jsx("span", {
1994
- className: style['table-toolbar-divider'],
1995
- "aria-hidden": true
1996
- }), /*#__PURE__*/jsx("div", {
1997
- className: style['table-toolbar-search'],
1998
- children: searchInputNode
1999
- })]
2000
- }) : null]
2094
+ children: isMobile ? /*#__PURE__*/jsxs(Fragment, {
2095
+ children: [batchActionsNode ? /*#__PURE__*/jsx("div", {
2096
+ className: style['table-toolbar-mobile-actions'],
2097
+ children: batchActionsNode
2098
+ }) : null, showFilter || showButtonGroup ? /*#__PURE__*/jsxs("div", {
2099
+ className: style['table-toolbar-mobile-filter-row'],
2100
+ children: [filterNode, buttonGroupNode]
2101
+ }) : null]
2102
+ }) : /*#__PURE__*/jsxs(Fragment, {
2103
+ children: [batchActionsNode ? /*#__PURE__*/jsxs(Fragment, {
2104
+ children: [batchActionsNode, showFilter && /*#__PURE__*/jsx("span", {
2105
+ className: style['table-toolbar-divider'],
2106
+ "aria-hidden": true
2107
+ })]
2108
+ }) : null, filterNode, showDesktopActions ? /*#__PURE__*/jsxs(Fragment, {
2109
+ children: [showActionsDivider ? /*#__PURE__*/jsx("span", {
2110
+ className: style['table-toolbar-divider'],
2111
+ "aria-hidden": true
2112
+ }) : null, /*#__PURE__*/jsxs("div", {
2113
+ className: style['table-toolbar-actions'],
2114
+ children: [showSearch ? /*#__PURE__*/jsx("div", {
2115
+ className: style['table-toolbar-search'],
2116
+ children: searchInputNode
2117
+ }) : null, showCardModeToggle ? cardModeToggle : null, buttonGroupNode]
2118
+ })]
2119
+ }) : null]
2120
+ })
2001
2121
  }) : null, hasValueDisplay ? /*#__PURE__*/jsx("div", {
2002
2122
  className: classnames(style['table-toolbar-value-display'], {
2003
2123
  [style['is-mobile-render']]: isMobileRender
2004
2124
  }),
2005
2125
  children: /*#__PURE__*/jsx(FilterValueDisplay, {
2006
- value: filterValue,
2007
- onChange: onFilterChange,
2126
+ value: displayFilterValue,
2127
+ onChange: handleValueDisplayChange,
2008
2128
  extraExpand: extraExpand,
2009
2129
  flush: isMobileRender
2010
2130
  })
@@ -2013,8 +2133,13 @@ const TableToolbar = ({
2013
2133
  });
2014
2134
  };
2015
2135
 
2016
- 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"],
2136
+ 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", "buttonGroup", "selectedRows", "rowSelection", "renderMobile", "renderCard", "forceCard", "mobileSortToolbar"],
2017
2137
  _excluded2 = ["pagination", "horizontalScroller", "getScrollContainer"];
2138
+ const defaultMergeList = (data, newData) => {
2139
+ return Object.assign({}, newData, {
2140
+ pageData: [...((data == null ? void 0 : data.pageData) || []), ...((newData == null ? void 0 : newData.pageData) || [])]
2141
+ });
2142
+ };
2018
2143
  const readPageSize = key => {
2019
2144
  try {
2020
2145
  const value = localStorage.getItem(key);
@@ -2034,6 +2159,34 @@ const writePageSize = (key, size) => {
2034
2159
  // ignore quota errors
2035
2160
  }
2036
2161
  };
2162
+
2163
+ // renderCard 与 renderMobile 一致:支持 true / function / preset 字符串(从 preset({ renderCard }) 按名称取)
2164
+ const resolveRenderCard = renderCard => {
2165
+ if (renderCard === true || typeof renderCard === 'function') {
2166
+ return renderCard;
2167
+ }
2168
+ if (typeof renderCard === 'string') {
2169
+ var _globalParams$renderC;
2170
+ const name = renderCard.trim();
2171
+ const renderFn = name ? (_globalParams$renderC = globalParams.renderCard) == null ? void 0 : _globalParams$renderC[name] : null;
2172
+ return typeof renderFn === 'function' ? renderFn : null;
2173
+ }
2174
+ return null;
2175
+ };
2176
+ const readCardMode = key => {
2177
+ try {
2178
+ return localStorage.getItem(key) === 'card';
2179
+ } catch (_unused3) {
2180
+ return false;
2181
+ }
2182
+ };
2183
+ const writeCardMode = (key, isCard) => {
2184
+ try {
2185
+ localStorage.setItem(key, isCard ? 'card' : 'table');
2186
+ } catch (_unused4) {
2187
+ // ignore quota errors
2188
+ }
2189
+ };
2037
2190
  const TABLE_COMPONENTS = {
2038
2191
  Table,
2039
2192
  TableView
@@ -2104,9 +2257,13 @@ const TablePageInnerContent = withLocale(_ref => {
2104
2257
  tab,
2105
2258
  tabProps,
2106
2259
  batchActions,
2260
+ buttonGroup,
2107
2261
  selectedRows,
2108
2262
  rowSelection,
2109
- renderMobile = true
2263
+ renderMobile = true,
2264
+ renderCard,
2265
+ forceCard = false,
2266
+ mobileSortToolbar
2110
2267
  } = _ref,
2111
2268
  props = _objectWithoutPropertiesLoose(_ref, _excluded);
2112
2269
  const {
@@ -2114,6 +2271,15 @@ const TablePageInnerContent = withLocale(_ref => {
2114
2271
  } = useIntl();
2115
2272
  const isMobile = useIsMobile();
2116
2273
  const isMobileRenderActive = isRenderMobileActive(renderMobile, isMobile);
2274
+ const showButtonGroup = hasButtonGroupList(buttonGroup);
2275
+ // renderCard 仅 PC 端生效;默认可切换,forceCard 强制卡片且隐藏切换按钮
2276
+ const resolvedRenderCard = useMemo(() => resolveRenderCard(renderCard), [renderCard]);
2277
+ const renderCardEnabled = resolvedRenderCard != null && !isMobile;
2278
+ // 未传 name 时不持久化切换状态
2279
+ const cardModeKey = props.name ? `${props.name.toUpperCase()}_TABLE_PAGE_CARD_MODE` : null;
2280
+ const [cardMode, setCardMode] = useState(() => cardModeKey ? readCardMode(cardModeKey) : false);
2281
+ const isCardModeActive = renderCardEnabled && (forceCard || cardMode);
2282
+ const showCardModeToggle = renderCardEnabled && !forceCard;
2117
2283
  const tableContentRef = useRef(null);
2118
2284
  const pendingScrollRef = useRef(false);
2119
2285
  const handlerDataFormat = useRefCallback(dataFormat);
@@ -2144,7 +2310,7 @@ const TablePageInnerContent = withLocale(_ref => {
2144
2310
  pagination
2145
2311
  }), [data, fetchProps, requestParams, refresh, reload, loadMore, send, dataFormat, pagination]);
2146
2312
  const hasTab = !!(tab != null && tab.name && Array.isArray(tab.list) && tab.list.length > 0);
2147
- const hasInnerToolbar = !!(filter != null && (_filter$list = filter.list) != null && _filter$list.length || search && search.name || batchActions && batchActions.length);
2313
+ const hasInnerToolbar = !!(filter != null && (_filter$list = filter.list) != null && _filter$list.length || search && search.name || batchActions && batchActions.length || showButtonGroup || showCardModeToggle);
2148
2314
  const showOuterTab = hasTab && !isMobile;
2149
2315
  const showInnerTab = hasTab && isMobile;
2150
2316
  const wrapWithToolbar = hasInnerToolbar || showInnerTab;
@@ -2204,9 +2370,25 @@ const TablePageInnerContent = withLocale(_ref => {
2204
2370
  });
2205
2371
  }
2206
2372
  });
2373
+ const useMobileLoadMore = isMobileRenderActive && pagination.open && !pagination.forcePagination;
2374
+ // PC 卡片模式默认下拉加载,pagination.forcePagination 为 true 时仍用分页
2375
+ const useCardLoadMore = isCardModeActive && pagination.open && !pagination.forcePagination;
2376
+ const useLoadMoreMode = useMobileLoadMore || useCardLoadMore;
2377
+ const currentPage = get(requestParams, [pagination.paramsType, pagination.currentName], 1);
2378
+ const currentPageSize = Number(get(requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize || 50;
2379
+ const loadMoreNoMore = !formatData.total || currentPage * currentPageSize >= formatData.total;
2380
+ const handleLoadMore = useRefCallback(async () => {
2381
+ const mergeList = pagination.mergeList || defaultMergeList;
2382
+ await loadMore({
2383
+ [pagination.paramsType]: buildRequestParamsWithFilter(filterValue, {
2384
+ [pagination.currentName]: currentPage + 1,
2385
+ [pagination.pageSizeName]: currentPageSize
2386
+ })
2387
+ }, mergeList);
2388
+ });
2207
2389
  const paginationConfig = useMemo(() => {
2208
2390
  var _mobilePagination$sho;
2209
- if (!pagination.open || !(formatData.total > 0)) {
2391
+ if (useLoadMoreMode || !pagination.open || !(formatData.total > 0)) {
2210
2392
  return null;
2211
2393
  }
2212
2394
  const defaultShowTotal = total => /*#__PURE__*/jsxs(Fragment, {
@@ -2245,7 +2427,7 @@ const TablePageInnerContent = withLocale(_ref => {
2245
2427
  showLessItems: (_mobilePagination$sho = mobilePagination.showLessItems) != null ? _mobilePagination$sho : true,
2246
2428
  pageSizeOptions: pagination.pageSizeOptions || ['10', '20', '50', '100']
2247
2429
  });
2248
- }, [pagination, formatData.total, requestParams, formatMessage, handlePaginationChange, isMobileRenderActive]);
2430
+ }, [pagination, formatData.total, requestParams, formatMessage, handlePaginationChange, isMobileRenderActive, useLoadMoreMode]);
2249
2431
  const batchContext = useMemo(() => ({
2250
2432
  data,
2251
2433
  fetchProps,
@@ -2262,8 +2444,20 @@ const TablePageInnerContent = withLocale(_ref => {
2262
2444
  fetchProps,
2263
2445
  data
2264
2446
  });
2447
+
2448
+ // 移动端卡片模式下批量操作渲染在「全选/排序」行的排序后面
2449
+ const showMobileBatchInCardToolbar = isMobileRenderActive && Array.isArray(batchActions) && batchActions.length > 0;
2450
+ const resolvedMobileSortToolbar = showMobileBatchInCardToolbar ? args => /*#__PURE__*/jsxs(Fragment, {
2451
+ children: [typeof mobileSortToolbar === 'function' ? mobileSortToolbar(args) : null, /*#__PURE__*/jsx(BatchActions, {
2452
+ batchActions: batchActions,
2453
+ rowSelection: rowSelection,
2454
+ selectedRows: selectedRows,
2455
+ batchContext: batchContext
2456
+ })]
2457
+ }) : mobileSortToolbar;
2265
2458
  const tableProps = _extends({}, props, {
2266
2459
  renderMobile,
2460
+ mobileSortToolbar: resolvedMobileSortToolbar,
2267
2461
  rowSelection,
2268
2462
  dataSource: formatData.list,
2269
2463
  pagination: false,
@@ -2284,48 +2478,94 @@ const TablePageInnerContent = withLocale(_ref => {
2284
2478
  } : null
2285
2479
  });
2286
2480
  const TableComponent = TABLE_COMPONENTS[renderType] || Table;
2287
- const tableElement = /*#__PURE__*/jsx(TableComponent, _extends({}, tableProps));
2288
- return /*#__PURE__*/jsxs("div", {
2289
- className: style$1['table-page'],
2290
- style: scrollTopInsetStyle,
2291
- children: [/*#__PURE__*/jsxs(HorizontalScroller, {
2292
- ref: tableContentRef,
2293
- enabled: horizontalScroller && renderType === 'Table',
2294
- getPortalContainer: getScrollContainer,
2295
- className: classnames(style$1['table-content'], 'loading-container', {
2296
- 'is-loading': !isComplete && !data
2481
+
2482
+ // PC 卡片模式直接走 TableView 的卡片渲染(forceCardRender 在非移动端强制生效)
2483
+ const tableElement = isCardModeActive ? /*#__PURE__*/jsx(TableView, _extends({}, tableProps, {
2484
+ className: classnames(tableProps.className, style$1['is-card-render']),
2485
+ renderMobile: resolvedRenderCard,
2486
+ forceCardRender: true
2487
+ })) : /*#__PURE__*/jsx(TableComponent, _extends({}, tableProps));
2488
+ const cardModeToggleNode = showCardModeToggle ? /*#__PURE__*/jsx(Segmented, {
2489
+ className: style$1['card-mode-toggle'],
2490
+ size: "small",
2491
+ value: cardMode ? 'card' : 'table',
2492
+ options: [{
2493
+ value: 'table',
2494
+ icon: /*#__PURE__*/jsx(TableOutlined, {}),
2495
+ title: formatMessage({
2496
+ id: 'SwitchToTableView'
2497
+ })
2498
+ }, {
2499
+ value: 'card',
2500
+ icon: /*#__PURE__*/jsx(AppstoreOutlined, {}),
2501
+ title: formatMessage({
2502
+ id: 'SwitchToCardView'
2503
+ })
2504
+ }],
2505
+ onChange: value => {
2506
+ const next = value === 'card';
2507
+ if (cardModeKey) {
2508
+ writeCardMode(cardModeKey, next);
2509
+ }
2510
+ setCardMode(next);
2511
+ }
2512
+ }) : null;
2513
+ const tableMain = /*#__PURE__*/jsxs(HorizontalScroller, {
2514
+ ref: tableContentRef,
2515
+ enabled: horizontalScroller && renderType === 'Table' && !isCardModeActive,
2516
+ getPortalContainer: getScrollContainer,
2517
+ className: classnames(style$1['table-content'], 'loading-container', {
2518
+ 'is-loading': !isComplete && !data
2519
+ }),
2520
+ children: [showOuterTab ? /*#__PURE__*/jsx(TablePageTabs, {
2521
+ filterValue: filterValue,
2522
+ onFilterChange: handleFilterChange,
2523
+ tab: tab,
2524
+ tabProps: tabProps,
2525
+ className: style$1['table-page-tabs-outer'],
2526
+ isMobileRender: isMobileRenderActive
2527
+ }) : null, wrapWithToolbar ? /*#__PURE__*/jsxs("div", {
2528
+ className: classnames(style$1['table-with-toolbar'], {
2529
+ [style$1['is-mobile-render']]: isMobileRenderActive,
2530
+ [style$1['is-card-mode']]: isCardModeActive
2297
2531
  }),
2298
- children: [showOuterTab ? /*#__PURE__*/jsx(TablePageTabs, {
2532
+ children: [/*#__PURE__*/jsx(TableToolbar, {
2299
2533
  filterValue: filterValue,
2300
2534
  onFilterChange: handleFilterChange,
2535
+ filter: filter,
2536
+ search: search,
2301
2537
  tab: tab,
2302
2538
  tabProps: tabProps,
2303
- className: style$1['table-page-tabs-outer'],
2304
- isMobileRender: isMobileRenderActive
2305
- }) : null, wrapWithToolbar ? /*#__PURE__*/jsxs("div", {
2306
- className: classnames(style$1['table-with-toolbar'], {
2539
+ renderTab: showInnerTab,
2540
+ batchActions: batchActions,
2541
+ buttonGroup: buttonGroup,
2542
+ rowSelection: rowSelection,
2543
+ selectedRows: selectedRows,
2544
+ batchContext: batchContext,
2545
+ isMobileRender: isMobileRenderActive,
2546
+ cardModeToggle: cardModeToggleNode
2547
+ }), tableElement]
2548
+ }) : tableElement]
2549
+ });
2550
+ return /*#__PURE__*/jsx("div", {
2551
+ className: style$1['table-page'],
2552
+ style: scrollTopInsetStyle,
2553
+ children: useLoadMoreMode ? /*#__PURE__*/jsx(ScrollLoader, _extends({
2554
+ className: style$1['mobile-load-more'],
2555
+ completeTips: formatData.total > 0 ? undefined : null
2556
+ }, pagination.loadMore || {}, {
2557
+ useSimpleBar: false,
2558
+ isLoading: !isComplete,
2559
+ noMore: loadMoreNoMore,
2560
+ onLoader: handleLoadMore,
2561
+ children: tableMain
2562
+ })) : /*#__PURE__*/jsxs(Fragment, {
2563
+ children: [tableMain, paginationConfig ? /*#__PURE__*/jsx(Pagination, _extends({
2564
+ className: classnames(style$1['pagination'], {
2307
2565
  [style$1['is-mobile-render']]: isMobileRenderActive
2308
- }),
2309
- children: [/*#__PURE__*/jsx(TableToolbar, {
2310
- filterValue: filterValue,
2311
- onFilterChange: handleFilterChange,
2312
- filter: filter,
2313
- search: search,
2314
- tab: tab,
2315
- tabProps: tabProps,
2316
- renderTab: showInnerTab,
2317
- batchActions: batchActions,
2318
- rowSelection: rowSelection,
2319
- selectedRows: selectedRows,
2320
- batchContext: batchContext,
2321
- isMobileRender: isMobileRenderActive
2322
- }), tableElement]
2323
- }) : tableElement]
2324
- }), paginationConfig ? /*#__PURE__*/jsx(Pagination, _extends({
2325
- className: classnames(style$1['pagination'], {
2326
- [style$1['is-mobile-render']]: isMobileRenderActive
2327
- })
2328
- }, paginationConfig)) : null]
2566
+ })
2567
+ }, paginationConfig)) : null]
2568
+ })
2329
2569
  });
2330
2570
  });
2331
2571
  const TablePageInner = withFetch(TablePageInnerContent);