@kne/table-page 0.1.26 → 0.1.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -5,1941 +5,89 @@ var antd = require('antd');
5
5
  var icons = require('@ant-design/icons');
6
6
  var reactFilter = require('@kne/react-filter');
7
7
  var ScrollLoader = require('@kne/scroll-loader');
8
- var react = require('react');
8
+ var tableView = require('@kne/table-view');
9
9
  var classnames = require('classnames');
10
10
  var get = require('lodash/get');
11
- var tableView = require('@kne/table-view');
12
- var jsxRuntime = require('react/jsx-runtime');
13
- var isEmpty = require('@kne/is-empty');
14
- var responsiveUtils = require('@kne/responsive-utils');
15
11
  var useRefCallback = require('@kne/use-ref-callback');
16
- var transform = require('lodash/transform');
17
- var pick = require('lodash/pick');
18
- var findLastIndex = require('lodash/findLastIndex');
19
- var isEqual = require('lodash/isEqual');
20
- var useDebounce = require('use-debounce');
21
- var groupBy = require('lodash/groupBy');
22
- var reactSortablejs = require('react-sortablejs');
23
- var cloneDeep = require('lodash/cloneDeep');
12
+ var useControlValue = require('@kne/use-control-value');
13
+ var react = require('react');
24
14
  var reactIntl = require('@kne/react-intl');
15
+ var responsiveUtils = require('@kne/responsive-utils');
25
16
  var filterZhCN = require('@kne/react-filter/dist/locale/zh-CN');
26
17
  var filterEnUS = require('@kne/react-filter/dist/locale/en-US');
27
18
  var StickyScroller = require('@kne/react-sticky-scroller');
28
- var useControlValue = require('@kne/use-control-value');
29
19
  require('@kne/react-sticky-scroller/dist/index.css');
30
20
  require('@kne/button-group/dist/index.css');
31
- require('@kne/react-filter/dist/index.css');
32
- var ButtonGroup = require('@kne/button-group');
33
-
34
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
35
-
36
- var ScrollLoader__default = /*#__PURE__*/_interopDefaultLegacy(ScrollLoader);
37
- var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
38
- var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
39
- var useRefCallback__default = /*#__PURE__*/_interopDefaultLegacy(useRefCallback);
40
- var transform__default = /*#__PURE__*/_interopDefaultLegacy(transform);
41
- var pick__default = /*#__PURE__*/_interopDefaultLegacy(pick);
42
- var findLastIndex__default = /*#__PURE__*/_interopDefaultLegacy(findLastIndex);
43
- var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
44
- var groupBy__default = /*#__PURE__*/_interopDefaultLegacy(groupBy);
45
- var cloneDeep__default = /*#__PURE__*/_interopDefaultLegacy(cloneDeep);
46
- var filterZhCN__default = /*#__PURE__*/_interopDefaultLegacy(filterZhCN);
47
- var filterEnUS__default = /*#__PURE__*/_interopDefaultLegacy(filterEnUS);
48
- var StickyScroller__default = /*#__PURE__*/_interopDefaultLegacy(StickyScroller);
49
- var useControlValue__default = /*#__PURE__*/_interopDefaultLegacy(useControlValue);
50
- var ButtonGroup__default = /*#__PURE__*/_interopDefaultLegacy(ButtonGroup);
51
-
52
- function _extends() {
53
- return _extends = Object.assign ? Object.assign.bind() : function (n) {
54
- for (var e = 1; e < arguments.length; e++) {
55
- var t = arguments[e];
56
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
57
- }
58
- return n;
59
- }, _extends.apply(null, arguments);
60
- }
61
- function _objectWithoutPropertiesLoose(r, e) {
62
- if (null == r) return {};
63
- var t = {};
64
- for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
65
- if (-1 !== e.indexOf(n)) continue;
66
- t[n] = r[n];
67
- }
68
- return t;
69
- }
70
-
71
- const _excluded$2 = ["renderMobile"];
72
- const TableView = _ref => {
73
- let _ref$renderMobile = _ref.renderMobile,
74
- renderMobile = _ref$renderMobile === void 0 ? true : _ref$renderMobile,
75
- props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
76
- return /*#__PURE__*/jsxRuntime.jsx(tableView.TableView, _extends({
77
- renderMobile: renderMobile
78
- }, props));
79
- };
80
- TableView.Header = tableView.TableView.Header;
81
- TableView.useSelectedRow = tableView.TableView.useSelectedRow;
82
- TableView.useSort = tableView.TableView.useSort;
83
- TableView.sortDataSource = tableView.TableView.sortDataSource;
84
-
85
- 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","tree-expand-col":"kne-table-page_gG4Je","is-tree-table":"kne-table-page_-sVbY","radio-col":"kne-table-page_df9z3","tree-selection-content":"kne-table-page_21SJy","tree-indent":"kne-table-page_S2ObB","tree-expand":"kne-table-page_gbOhK","is-expanded":"kne-table-page_tPfuu","is-loading":"kne-table-page_ySG8v","tree-leaf-placeholder":"kne-table-page_lJF37","tree-selection-control":"kne-table-page_MFctL","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"};
86
-
87
- const getColumnConfig = (config, columnName, field, defaultValue) => {
88
- const columnConfig = config?.[columnName];
89
- if (columnConfig != null && columnConfig[field] !== undefined) {
90
- return columnConfig[field];
91
- }
92
- const legacyValue = get__default["default"](config, `${columnName}.${field}`);
93
- return legacyValue === undefined ? defaultValue : legacyValue;
94
- };
95
- const setColumnConfig = (config, columnName, updates) => {
96
- return Object.assign({}, config, {
97
- [columnName]: Object.assign({}, config?.[columnName], updates)
98
- });
99
- };
100
-
101
- var configStyle = {"cell-resize-bar":"kne-table-page_PNaAP","table-changer-setting":"kne-table-page_B0U-O","is-active":"kne-table-page_vHrQo","table-config-header":"kne-table-page_Zp8MN","table-config-header-title":"kne-table-page_Pc6jR","columns-control-content":"kne-table-page_saJmr","columns-control-content-title":"kne-table-page_YmHni","columns-control-content-scroller":"kne-table-page_rgqWB","columns-control-sortable-list":"kne-table-page_JRcBW","columns-control-content-footer":"kne-table-page_nLwW1","columns-control-content-input":"kne-table-page_9qyJs","columns-control-content-list":"kne-table-page_Sslzr","columns-control-content-item":"kne-table-page_7CamD","is-drag":"kne-table-page_X18rq","columns-control-content-item-icon":"kne-table-page_Eab-e","columns-control-overlay":"kne-table-page_eT4HV","header-col":"kne-table-page_bjDly","header-cell-inner":"kne-table-page_9FKgD"};
102
-
103
- const locale$1 = {
104
- TotalText: '共',
105
- ItemText: '条',
106
- UnnamedColumn: '未命名列',
107
- EditTable: '编辑表格',
108
- RestoreDefault: '恢复默认',
109
- VisibleInfo: '显示的信息',
110
- HiddenInfo: '隐藏的信息',
111
- Search: '搜索',
112
- BatchOperations: '批量操作',
113
- BatchOperationsWithCount: '已选:{count}条',
114
- Cancel: '取消',
115
- Confirm: '确定',
116
- All: '全部',
117
- SwitchToCardView: '切换为卡片视图',
118
- SwitchToTableView: '切换为表格视图'
119
- };
120
-
121
- const locale = {
122
- TotalText: 'Total',
123
- ItemText: 'items',
124
- UnnamedColumn: 'Unnamed',
125
- EditTable: 'Edit Table',
126
- RestoreDefault: 'Restore Default',
127
- VisibleInfo: 'Visible Columns',
128
- HiddenInfo: 'Hidden Columns',
129
- Search: 'Search',
130
- BatchOperations: 'Batch Actions',
131
- BatchOperationsWithCount: 'Selected: {count}',
132
- Cancel: 'Cancel',
133
- Confirm: 'Confirm',
134
- All: 'All',
135
- SwitchToCardView: 'Switch to card view',
136
- SwitchToTableView: 'Switch to table view'
137
- };
138
-
139
- const withLocale = reactIntl.createWithIntlProvider({
140
- defaultLocale: 'zh-CN',
141
- messages: {
142
- 'zh-CN': {
143
- ...filterZhCN__default["default"],
144
- ...locale$1
145
- },
146
- 'en-US': {
147
- ...filterEnUS__default["default"],
148
- ...locale
149
- }
150
- },
151
- namespace: 'table-page'
152
- });
153
-
154
- function _finallyRethrows(body, finalizer) {
155
- try {
156
- var result = body();
157
- } catch (e) {
158
- return finalizer(true, e);
159
- }
160
- if (result && result.then) {
161
- return result.then(finalizer.bind(null, false), finalizer.bind(null, true));
162
- }
163
- return finalizer(false, result);
164
- }
165
- const ColumnsControlContent = withLocale(({
166
- close,
167
- onConfirm,
168
- columns,
169
- config: defaultValue
170
- }) => {
171
- const {
172
- formatMessage
173
- } = reactIntl.useIntl();
174
- const [config, onChange] = react.useState(defaultValue || {});
175
- const [searchText, setSearchText] = react.useState('');
176
- const [confirmLoading, setConfirmLoading] = react.useState(false);
177
- const [scrollEl, setScrollEl] = react.useState(null);
178
- const {
179
- leftFixedColumns,
180
- rightFixedColumns,
181
- visibleColumns,
182
- hiddenColumns
183
- } = react.useMemo(() => {
184
- return transform__default["default"](Object.assign({
185
- leftFixedColumns: [],
186
- rightFixedColumns: [],
187
- visibleColumns: [],
188
- hiddenColumns: []
189
- }, groupBy__default["default"](columns, item => {
190
- if (item.fixed === 'right') {
191
- return 'rightFixedColumns';
192
- }
193
- if (item.fixed === true || item.fixed === 'left') {
194
- return 'leftFixedColumns';
195
- }
196
- return getColumnConfig(config, item.name, 'visible') !== true && item.hidden || getColumnConfig(config, item.name, 'visible') === false ? 'hiddenColumns' : 'visibleColumns';
197
- })), (result, value, key) => {
198
- result[key] = value.sort((a, b) => getColumnConfig(config, a.name, 'rank', 0) - getColumnConfig(config, b.name, 'rank', 0));
199
- }, {});
200
- }, [columns, config]);
201
- const sortableVisibleColumns = react.useMemo(() => {
202
- return visibleColumns.map(column => Object.assign({}, column, {
203
- id: column.name
204
- }));
205
- }, [visibleColumns]);
206
- const handlerColumnsChange = columnsState => {
207
- const newConfig = cloneDeep__default["default"](config);
208
- const columnsList = [].concat(columnsState.leftFixedColumns, columnsState.visibleColumns, columnsState.rightFixedColumns);
209
- (columnsState.hiddenColumns || []).forEach(col => {
210
- Object.assign(newConfig, setColumnConfig(newConfig, col.name, {
211
- visible: false
212
- }));
213
- });
214
- columnsList.forEach((col, index) => {
215
- Object.assign(newConfig, setColumnConfig(newConfig, col.name, {
216
- rank: index + 1
217
- }));
218
- });
219
- onChange(newConfig);
220
- };
221
- const renderColumn = item => {
222
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
223
- children: [item.titleText || item.title || formatMessage({
224
- id: 'UnnamedColumn'
225
- }), item.groupHeader && item.groupHeader.length > 0 ? `(${item.groupHeader.map(({
226
- title
227
- }) => title).join('-')})` : '']
228
- });
229
- };
230
- const collapseItems = react.useMemo(() => {
231
- return [{
232
- key: 'active',
233
- label: formatMessage({
234
- id: 'VisibleInfo'
235
- }),
236
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
237
- className: configStyle['columns-control-content-list'],
238
- children: [leftFixedColumns.map((item, index) => /*#__PURE__*/jsxRuntime.jsx("div", {
239
- className: configStyle['columns-control-content-item'],
240
- children: /*#__PURE__*/jsxRuntime.jsx(antd.Checkbox, {
241
- checked: true,
242
- disabled: true,
243
- children: renderColumn(item)
244
- })
245
- }, item.name || `left-${index}`)), /*#__PURE__*/jsxRuntime.jsx(reactSortablejs.ReactSortable, {
246
- tag: "div",
247
- className: configStyle['columns-control-sortable-list'],
248
- list: sortableVisibleColumns,
249
- filter: ".ignore-elements",
250
- dragClass: "table-page-sortable-drag",
251
- ghostClass: "table-page-sortable-ghost",
252
- chosenClass: "table-page-sortable-chosen",
253
- forceFallback: true,
254
- fallbackOnBody: true,
255
- scroll: scrollEl || true,
256
- bubbleScroll: true,
257
- setList: nextVisibleColumns => {
258
- handlerColumnsChange({
259
- leftFixedColumns,
260
- visibleColumns: nextVisibleColumns,
261
- hiddenColumns,
262
- rightFixedColumns
263
- });
264
- },
265
- animation: 300,
266
- delayOnTouchStart: true,
267
- delay: 2,
268
- children: sortableVisibleColumns.map(item => /*#__PURE__*/jsxRuntime.jsxs("div", {
269
- className: classnames__default["default"](configStyle['columns-control-content-item'], configStyle['is-drag']),
270
- children: [/*#__PURE__*/jsxRuntime.jsx(icons.HolderOutlined, {
271
- className: configStyle['columns-control-content-item-icon']
272
- }), /*#__PURE__*/jsxRuntime.jsx(antd.Checkbox, {
273
- checked: true,
274
- disabled: item.fixed || leftFixedColumns.length + visibleColumns.length + rightFixedColumns.length <= 1,
275
- onChange: e => {
276
- e.stopPropagation();
277
- e.preventDefault();
278
- const newConfig = Object.assign({}, config);
279
- newConfig[item.name] = Object.assign({}, newConfig[item.name], {
280
- visible: false
281
- });
282
- onChange(newConfig);
283
- },
284
- children: renderColumn(item)
285
- })]
286
- }, item.id))
287
- }), rightFixedColumns.map((item, index) => /*#__PURE__*/jsxRuntime.jsx("div", {
288
- className: configStyle['columns-control-content-item'],
289
- children: /*#__PURE__*/jsxRuntime.jsx(antd.Checkbox, {
290
- checked: true,
291
- disabled: true,
292
- children: item.titleText || item.title || formatMessage({
293
- id: 'UnnamedColumn'
294
- })
295
- })
296
- }, item.name || `right-${index}`))]
297
- })
298
- }, {
299
- key: 'un-active',
300
- label: /*#__PURE__*/jsxRuntime.jsxs(antd.Row, {
301
- wrap: false,
302
- justify: "space-between",
303
- children: [/*#__PURE__*/jsxRuntime.jsx(antd.Col, {
304
- children: formatMessage({
305
- id: 'HiddenInfo'
306
- })
307
- }), /*#__PURE__*/jsxRuntime.jsx(antd.Col, {
308
- onClick: e => {
309
- e.stopPropagation();
310
- e.preventDefault();
311
- },
312
- children: /*#__PURE__*/jsxRuntime.jsx(antd.Input.Search, {
313
- placeholder: formatMessage({
314
- id: 'Search'
315
- }),
316
- onSearch: value => setSearchText(value),
317
- className: configStyle['columns-control-content-input'],
318
- size: "small",
319
- allowClear: true
320
- })
321
- })]
322
- }),
323
- children: /*#__PURE__*/jsxRuntime.jsx(antd.List, {
324
- dataSource: hiddenColumns.filter(item => {
325
- const title = item.titleText || item.title;
326
- return typeof title === 'string' && title.indexOf(searchText) > -1;
327
- }),
328
- renderItem: item => /*#__PURE__*/jsxRuntime.jsx(antd.List.Item, {
329
- className: configStyle['columns-control-content-item'],
330
- children: /*#__PURE__*/jsxRuntime.jsx(antd.Checkbox, {
331
- checked: false,
332
- onChange: e => {
333
- e.stopPropagation();
334
- e.preventDefault();
335
- const newConfig = Object.assign({}, config);
336
- newConfig[item.name] = Object.assign({}, newConfig[item.name], {
337
- visible: true
338
- });
339
- onChange(newConfig);
340
- },
341
- children: item.titleText || item.title || formatMessage({
342
- id: 'UnnamedColumn'
343
- })
344
- })
345
- }, item.name)
346
- })
347
- }];
348
- }, [config, formatMessage, hiddenColumns, leftFixedColumns, onChange, rightFixedColumns, scrollEl, searchText, sortableVisibleColumns, visibleColumns.length]);
349
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
350
- className: configStyle['columns-control-content'],
351
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
352
- className: configStyle['columns-control-content-title'],
353
- children: /*#__PURE__*/jsxRuntime.jsxs(antd.Row, {
354
- align: "middle",
355
- justify: "space-between",
356
- children: [/*#__PURE__*/jsxRuntime.jsx(antd.Col, {
357
- children: formatMessage({
358
- id: 'EditTable'
359
- })
360
- }), /*#__PURE__*/jsxRuntime.jsx(antd.Col, {
361
- children: /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
362
- title: formatMessage({
363
- id: 'RestoreDefault'
364
- }),
365
- children: /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
366
- type: "text",
367
- icon: /*#__PURE__*/jsxRuntime.jsx(icons.RedoOutlined, {}),
368
- onClick: function () {
369
- try {
370
- function _temp(_onConfirm) {
371
- _onConfirm;
372
- close();
373
- }
374
- return Promise.resolve(onConfirm ? Promise.resolve(onConfirm({})).then(_temp) : _temp(onConfirm));
375
- } catch (e) {
376
- return Promise.reject(e);
377
- }
378
- }
379
- })
380
- })
381
- })]
382
- })
383
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
384
- className: configStyle['columns-control-content-scroller'],
385
- ref: setScrollEl,
386
- children: /*#__PURE__*/jsxRuntime.jsx(antd.Collapse, {
387
- defaultActiveKey: ['active', 'un-active'],
388
- ghost: true,
389
- bordered: true,
390
- items: collapseItems
391
- })
392
- }), /*#__PURE__*/jsxRuntime.jsxs(antd.Row, {
393
- className: configStyle['columns-control-content-footer'],
394
- justify: "end",
395
- gutter: 10,
396
- children: [/*#__PURE__*/jsxRuntime.jsx(antd.Col, {
397
- children: /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
398
- size: "small",
399
- onClick: () => {
400
- onChange(defaultValue || {});
401
- close();
402
- },
403
- children: formatMessage({
404
- id: 'Cancel'
405
- })
406
- })
407
- }), /*#__PURE__*/jsxRuntime.jsx(antd.Col, {
408
- children: /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
409
- type: "primary",
410
- size: "small",
411
- loading: confirmLoading,
412
- onClick: function () {
413
- try {
414
- setConfirmLoading(true);
415
- const _temp3 = _finallyRethrows(function () {
416
- function _temp2(_onConfirm2) {
417
- _onConfirm2;
418
- close();
419
- }
420
- return onConfirm ? Promise.resolve(onConfirm(config)).then(_temp2) : _temp2(onConfirm);
421
- }, function (_wasThrown, _result) {
422
- setConfirmLoading(false);
423
- if (_wasThrown) throw _result;
424
- return _result;
425
- });
426
- return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(function () {}) : void 0);
427
- } catch (e) {
428
- return Promise.reject(e);
429
- }
430
- },
431
- children: formatMessage({
432
- id: 'Confirm'
433
- })
434
- })
435
- })]
436
- })]
437
- });
438
- });
439
-
440
- const storageKey = 'TABLE_PAGE_TABLE_CONFIG';
441
- const readStorage = () => {
442
- try {
443
- return JSON.parse(localStorage.getItem(storageKey) || '{}');
444
- } catch (_unused) {
445
- return {};
446
- }
447
- };
448
- const writeStorage = data => {
449
- try {
450
- localStorage.setItem(storageKey, JSON.stringify(data));
451
- } catch (_unused2) {
452
- // ignore quota errors
453
- }
454
- };
455
- const getData = name => {
456
- if (!name) {
457
- return {};
458
- }
459
- return get__default["default"](readStorage(), name, {});
460
- };
461
- const setData = (name, data) => {
462
- if (!name) {
463
- return;
464
- }
465
- writeStorage(Object.assign({}, readStorage(), {
466
- [name]: data
467
- }));
468
- };
469
- const tableLocalApis = {
470
- getData,
471
- setData
472
- };
473
-
474
- const TABLE_CONFIG_COLUMN_EXTRA_WIDTH = 48;
475
-
476
- const DEFAULT_WIDTH = 160;
477
- const DEFAULT_MIN = 80;
478
- const DEFAULT_MAX = 600;
479
- const getColumnSize = column => {
480
- var _column$min, _column$max;
481
- const width = tableView.parseColumnWidth(column.width) || DEFAULT_WIDTH;
482
- return {
483
- width,
484
- min: (_column$min = column.min) != null ? _column$min : DEFAULT_MIN,
485
- max: (_column$max = column.max) != null ? _column$max : DEFAULT_MAX
486
- };
487
- };
488
- const getConfigColumnExtraWidth = (index, columnCount, controllerOpen) => {
489
- if (!controllerOpen || index !== columnCount - 1) {
490
- return 0;
491
- }
492
- return TABLE_CONFIG_COLUMN_EXTRA_WIDTH;
493
- };
494
- const withConfigColumnExtra = (contentWidth, index, columnCount, controllerOpen) => {
495
- return contentWidth + getConfigColumnExtraWidth(index, columnCount, controllerOpen);
496
- };
497
- const TableConfigButton = _ref => {
498
- let title = _ref.title,
499
- columns = _ref.columns,
500
- config = _ref.config,
501
- setConfig = _ref.setConfig;
502
- const _useState = react.useState(false),
503
- open = _useState[0],
504
- setOpen = _useState[1];
505
- return /*#__PURE__*/jsxRuntime.jsxs(antd.Row, {
506
- wrap: false,
507
- align: "middle",
508
- className: configStyle['table-config-header'],
509
- children: [/*#__PURE__*/jsxRuntime.jsx(antd.Col, {
510
- flex: 1,
511
- className: configStyle['table-config-header-title'],
512
- children: title
513
- }), /*#__PURE__*/jsxRuntime.jsx(antd.Col, {
514
- flex: "none",
515
- children: /*#__PURE__*/jsxRuntime.jsx(antd.Popover, {
516
- open: open,
517
- onOpenChange: setOpen,
518
- trigger: "click",
519
- placement: "bottomLeft",
520
- rootClassName: configStyle['columns-control-overlay'],
521
- styles: {
522
- container: {
523
- padding: 0
524
- }
525
- },
526
- content: /*#__PURE__*/jsxRuntime.jsx(ColumnsControlContent, {
527
- columns: columns,
528
- config: config,
529
- close: () => setOpen(false),
530
- onConfirm: newConfig => {
531
- setConfig(configValue => {
532
- return transform__default["default"](newConfig, (result, value, key) => {
533
- result[key] = Object.assign({}, configValue[key], pick__default["default"](value, ['visible', 'rank']));
534
- }, {});
535
- });
536
- }
537
- }),
538
- children: /*#__PURE__*/jsxRuntime.jsx("span", {
539
- className: classnames__default["default"](configStyle['table-changer-setting'], open && configStyle['is-active']),
540
- children: /*#__PURE__*/jsxRuntime.jsx(icons.SettingOutlined, {})
541
- })
542
- })
543
- })]
544
- });
545
- };
546
- const useTableConfig = _ref2 => {
547
- let columns = _ref2.columns,
548
- name = _ref2.name,
549
- _ref2$controllerOpen = _ref2.controllerOpen,
550
- controllerOpen = _ref2$controllerOpen === void 0 ? true : _ref2$controllerOpen,
551
- _ref2$tableWidth = _ref2.tableWidth,
552
- tableWidth = _ref2$tableWidth === void 0 ? 0 : _ref2$tableWidth,
553
- rowKey = _ref2.rowKey,
554
- _ref2$tableServerApis = _ref2.tableServerApis,
555
- tableServerApis = _ref2$tableServerApis === void 0 ? tableLocalApis : _ref2$tableServerApis;
556
- const _useState2 = react.useState(null),
557
- currentMoveColumnIndex = _useState2[0],
558
- setCurrentMoveColumnIndex = _useState2[1];
559
- const currentMoveColumnIndexRef = react.useRef(currentMoveColumnIndex);
560
- currentMoveColumnIndexRef.current = currentMoveColumnIndex;
561
- const currentMoveColumnRef = react.useRef(null);
562
- const startPointRef = react.useRef(null);
563
- const _useState3 = react.useState({}),
564
- config = _useState3[0],
565
- setConfigBase = _useState3[1];
566
- const saveConfig = useDebounce.useDebouncedCallback((tableName, target) => {
567
- tableServerApis == null || tableServerApis.setData(tableName, target);
568
- }, 500);
569
- const setConfig = react.useCallback(newConfig => {
570
- setConfigBase(prevConfig => {
571
- const target = typeof newConfig === 'function' ? newConfig(prevConfig) : newConfig;
572
- if (name && controllerOpen) {
573
- saveConfig(name, target);
574
- }
575
- return target;
576
- });
577
- }, [name, controllerOpen, saveConfig]);
578
- react.useEffect(() => {
579
- if (name && controllerOpen) {
580
- setConfigBase(Object.assign({}, tableServerApis.getData(name)));
581
- }
582
- }, [name, controllerOpen, tableServerApis]);
583
- const visibleColumns = react.useMemo(() => {
584
- return columns.filter(col => !(getColumnConfig(config, col.name, 'visible') === false || getColumnConfig(config, col.name, 'visible') !== true && col.hidden === true)).sort((a, b) => {
585
- const computedIndex = item => getColumnConfig(config, item.name, 'rank', 0) + (item.fixed === 'left' || item.fixed === true ? -10000 : 0) + (item.fixed === 'right' ? 10000 : 0);
586
- return computedIndex(a) - computedIndex(b);
587
- });
588
- }, [columns, config]);
589
- const columnCount = visibleColumns.length;
590
- const hasFixedColumn = react.useMemo(() => visibleColumns.some(col => col.fixed === 'right' || col.fixed === 'left' || col.fixed === true), [visibleColumns]);
591
- const lastNotFixedColumnIndex = react.useMemo(() => {
592
- return findLastIndex__default["default"](visibleColumns, col => col.fixed !== 'right' && !tableView.isOptionsColumn(col));
593
- }, [visibleColumns]);
594
- const totalWidth = react.useMemo(() => {
595
- return visibleColumns.reduce((sum, col, index) => {
596
- const _getColumnSize = getColumnSize(col),
597
- width = _getColumnSize.width;
598
- const contentWidth = getColumnConfig(config, col.name, 'width') || width;
599
- return sum + withConfigColumnExtra(contentWidth, index, columnCount, controllerOpen);
600
- }, 0);
601
- }, [visibleColumns, config, columnCount, controllerOpen]);
602
- const computedRealWidth = react.useCallback(_ref3 => {
603
- let width = _ref3.width,
604
- index = _ref3.index;
605
- const contentWidth = width;
606
- if (currentMoveColumnIndex !== null && currentMoveColumnIndex === index) {
607
- return withConfigColumnExtra(contentWidth, index, columnCount, controllerOpen);
608
- }
609
- if (hasFixedColumn || lastNotFixedColumnIndex !== index) {
610
- return withConfigColumnExtra(contentWidth, index, columnCount, controllerOpen);
611
- }
612
- return withConfigColumnExtra(contentWidth, index, columnCount, controllerOpen) + Math.max(tableWidth - totalWidth - 2, 0);
613
- }, [hasFixedColumn, lastNotFixedColumnIndex, tableWidth, totalWidth, currentMoveColumnIndex, columnCount, controllerOpen]);
614
- const getConfigWidth = react.useCallback(column => {
615
- const _getColumnSize2 = getColumnSize(column),
616
- width = _getColumnSize2.width,
617
- min = _getColumnSize2.min,
618
- max = _getColumnSize2.max;
619
- const currentWidth = Math.min(Math.max(getColumnConfig(config, column.name, 'width') || width, min), max);
620
- return {
621
- currentWidth,
622
- min,
623
- max
624
- };
625
- }, [config]);
626
- const resizeBarRender = react.useCallback((column, index) => {
627
- return /*#__PURE__*/jsxRuntime.jsx("span", {
628
- className: classnames__default["default"](configStyle['cell-resize-bar'], 'table-cell-resize-bar'),
629
- onMouseDown: e => {
630
- e.stopPropagation();
631
- const _getConfigWidth = getConfigWidth(column),
632
- currentWidth = _getConfigWidth.currentWidth,
633
- min = _getConfigWidth.min,
634
- max = _getConfigWidth.max;
635
- currentMoveColumnRef.current = Object.assign({}, column, {
636
- index,
637
- width: currentWidth,
638
- min,
639
- max
640
- });
641
- startPointRef.current = e.clientX;
642
- setCurrentMoveColumnIndex(index);
643
- },
644
- children: /*#__PURE__*/jsxRuntime.jsx(icons.HolderOutlined, {})
645
- });
646
- }, [getConfigWidth]);
647
- const resize = useRefCallback__default["default"](delta => {
648
- if (currentMoveColumnIndexRef.current === null || !currentMoveColumnRef.current) {
649
- return;
650
- }
651
- const _currentMoveColumnRef = currentMoveColumnRef.current,
652
- colName = _currentMoveColumnRef.name,
653
- width = _currentMoveColumnRef.width,
654
- min = _currentMoveColumnRef.min,
655
- max = _currentMoveColumnRef.max;
656
- const currentWidth = Math.min(Math.max(width + delta, min), max);
657
- if (currentWidth < min) {
658
- return;
659
- }
660
- setConfig(prevConfig => Object.assign({}, prevConfig, {
661
- [colName]: Object.assign({}, prevConfig[colName], {
662
- width: currentWidth
663
- })
664
- }));
665
- });
666
- const renderColumnTitle = react.useCallback(function (title, column, index, _temp) {
667
- let _ref4 = _temp === void 0 ? {} : _temp,
668
- _ref4$withResize = _ref4.withResize,
669
- withResize = _ref4$withResize === void 0 ? true : _ref4$withResize,
670
- _ref4$withConfig = _ref4.withConfig,
671
- withConfig = _ref4$withConfig === void 0 ? false : _ref4$withConfig;
672
- const titleNode = withConfig ? /*#__PURE__*/jsxRuntime.jsx(TableConfigButton, {
673
- title: title,
674
- columns: columns,
675
- config: config,
676
- setConfig: setConfig
677
- }) : title;
678
- const content = /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
679
- children: [titleNode, withResize && controllerOpen && resizeBarRender(column, index)]
680
- });
681
- if (!withResize || !controllerOpen) {
682
- return content;
683
- }
684
- return /*#__PURE__*/jsxRuntime.jsx("span", {
685
- className: configStyle['header-cell-inner'],
686
- children: content
687
- });
688
- }, [columns, config, controllerOpen, resizeBarRender, setConfig]);
689
- const getHeaderCellClassName = react.useCallback(index => classnames__default["default"](configStyle['header-col'], {
690
- 'is-moving': currentMoveColumnIndexRef.current === index
691
- }), []);
692
- const computedColumnProps = react.useCallback((column, index, _ref5) => {
693
- let title = _ref5.title;
694
- const _getConfigWidth2 = getConfigWidth(column),
695
- currentWidth = _getConfigWidth2.currentWidth;
696
- const realWidth = computedRealWidth({
697
- width: currentWidth,
698
- index
699
- });
700
- const isLastColumn = index === columnCount - 1;
701
- const movingClass = () => ({
702
- className: classnames__default["default"]({
703
- 'is-moving': currentMoveColumnIndex === index,
704
- 'has-config-btn': isLastColumn && controllerOpen
705
- })
706
- });
707
- return {
708
- onHeaderCell: movingClass,
709
- onCell: movingClass,
710
- width: realWidth,
711
- shouldCellUpdate: (record, prevRecord) => {
712
- const itemKey = typeof rowKey === 'function' ? rowKey(record) : record[rowKey];
713
- const prevItemKey = typeof rowKey === 'function' ? rowKey(prevRecord) : prevRecord[rowKey];
714
- return currentMoveColumnIndexRef.current === null || currentMoveColumnIndexRef.current === index || !(itemKey === prevItemKey && isEqual__default["default"](record[column.name], prevRecord[column.name]));
715
- },
716
- title: renderColumnTitle(title, column, index, {
717
- withResize: true,
718
- withConfig: isLastColumn && controllerOpen
719
- })
720
- };
721
- }, [columnCount, controllerOpen, computedRealWidth, getConfigWidth, renderColumnTitle, rowKey, currentMoveColumnIndex]);
722
- react.useEffect(() => {
723
- const handlerCancelResize = () => {
724
- setCurrentMoveColumnIndex(null);
725
- startPointRef.current = null;
726
- currentMoveColumnRef.current = null;
727
- };
728
- const handlerResize = e => {
729
- if (currentMoveColumnIndexRef.current === null || currentMoveColumnRef.current === null || startPointRef.current === null) {
730
- return;
731
- }
732
- resize(e.clientX - startPointRef.current);
733
- };
734
- document.documentElement.addEventListener('mouseup', handlerCancelResize, true);
735
- document.documentElement.addEventListener('mousemove', handlerResize, true);
736
- return () => {
737
- document.documentElement.removeEventListener('mouseup', handlerCancelResize, true);
738
- document.documentElement.removeEventListener('mousemove', handlerResize, true);
739
- };
740
- }, [resize]);
741
- return {
742
- visibleColumns,
743
- columnsConfig: config,
744
- setConfig,
745
- currentMoveColumnIndex,
746
- totalWidth,
747
- hasFixedColumn,
748
- computedColumnProps,
749
- renderColumnTitle,
750
- getHeaderCellClassName,
751
- getConfigWidth,
752
- computedRealWidth,
753
- resizeBarRender
754
- };
755
- };
756
-
757
- const useGroupHeader = columns => {
758
- return react.useMemo(() => {
759
- const groupHeaderColumns = columns.filter(item => item.groupHeader && item.groupHeader.length > 0);
760
- if (groupHeaderColumns.length > 0) {
761
- const newColumns = columns.slice(0);
762
- const group = [];
763
- const appendGroupHeader = column => {
764
- const {
765
- groupHeader
766
- } = column;
767
- if (!(groupHeader && groupHeader.length > 0)) {
768
- return;
769
- }
770
- const columnIndex = newColumns.indexOf(column);
771
- const core = (groupHeader, groupList) => {
772
- const [targetHeader, ...otherHeader] = groupHeader;
773
- let currentGroup = groupList.find(item => item.name === targetHeader.name);
774
- if (!currentGroup) {
775
- currentGroup = Object.assign({
776
- startIndex: columnIndex
777
- }, targetHeader, {
778
- children: []
779
- });
780
- groupList.push(currentGroup);
781
- }
782
- if (otherHeader.length > 0) {
783
- core(otherHeader, currentGroup.children);
784
- } else {
785
- currentGroup.children.push(column);
786
- }
787
- };
788
- core(groupHeader, group);
789
- newColumns.splice(columnIndex, 1);
790
- };
791
- groupHeaderColumns.forEach(appendGroupHeader);
792
- group.forEach((groupColumn, index) => {
793
- newColumns.splice(groupColumn.startIndex + index, 0, groupColumn);
794
- });
795
- return {
796
- columns: newColumns,
797
- hasGroupHeader: true
798
- };
799
- }
800
- return {
801
- columns,
802
- hasGroupHeader: false
803
- };
804
- }, [columns]);
805
- };
806
-
807
- const useElementWidth = ref => {
808
- const [width, setWidth] = react.useState(0);
809
- react.useEffect(() => {
810
- const el = ref.current;
811
- if (!el) {
812
- return;
813
- }
814
- const update = () => setWidth(el.clientWidth);
815
- const resizeObserver = new ResizeObserver(update);
816
- resizeObserver.observe(el);
817
- update();
818
- return () => resizeObserver.disconnect();
819
- }, [ref]);
820
- return width;
821
- };
822
-
823
- const parsePixelValue = value => {
824
- const num = parseFloat(value);
825
- return Number.isNaN(num) ? 0 : num;
826
- };
827
- const normalizeScrollTopInsetCSSValue = value => {
828
- if (value == null) {
829
- return undefined;
830
- }
831
- if (typeof value === 'number') {
832
- return `${value}px`;
833
- }
834
- return String(value);
835
- };
836
- const resolveScrollTopInset = (scrollTopInset, stickyOffset) => scrollTopInset ?? stickyOffset;
837
- const parseInsetPixels = (inset, element) => {
838
- if (inset == null) {
839
- return 0;
840
- }
841
- if (typeof inset === 'number') {
842
- return inset;
843
- }
844
- if (typeof inset === 'string') {
845
- const trimmed = inset.trim();
846
- if (trimmed.endsWith('px')) {
847
- return parsePixelValue(trimmed);
848
- }
849
- const variableMatch = trimmed.match(/var\(\s*(--[^,\s)]+)/);
850
- if (variableMatch) {
851
- return readCssVariableLength(element, variableMatch[1], '0px');
852
- }
853
- }
854
- return 0;
855
- };
856
- const readScrollTopInsetPixels = element => {
857
- const fromVar = readCssVariableLength(element, '--scroll-top-inset', '0px') || readCssVariableLength(element, '--sticky-offset', '0px') || readCssVariableLength(element, '--nav-height', '0px');
858
- return fromVar;
859
- };
860
- const getTableElement = root => {
861
- if (!root) {
862
- return null;
863
- }
864
- return root.querySelector('.info-page-table') || root;
865
- };
866
- const getScrollAnchorElement = (root, {
867
- preferToolbar = false
868
- } = {}) => {
869
- if (!root) {
870
- return null;
871
- }
872
- if (preferToolbar) {
873
- return root.querySelector('.table-page-toolbar-section') || root.querySelector('.table-with-toolbar') || getTableElement(root);
874
- }
875
- return getTableElement(root);
876
- };
877
- const readCssVariableLength = (element, variableName, fallback = '0px') => {
878
- if (typeof document === 'undefined') {
879
- return 0;
880
- }
881
- const host = element || document.documentElement;
882
- const probe = document.createElement('div');
883
- probe.style.cssText = 'position:absolute;visibility:hidden;pointer-events:none;height:0;width:0;overflow:hidden;';
884
- probe.style.marginTop = `var(${variableName}, ${fallback})`;
885
- host.appendChild(probe);
886
- const value = parsePixelValue(getComputedStyle(probe).marginTop);
887
- host.removeChild(probe);
888
- return value;
889
- };
890
- const resolveScrollContainer = (element, getScrollContainer) => {
891
- const explicitContainer = typeof getScrollContainer === 'function' ? getScrollContainer() : null;
892
- if (explicitContainer) {
893
- return explicitContainer;
894
- }
895
- let parent = element?.parentElement;
896
- while (parent) {
897
- const {
898
- overflowY
899
- } = getComputedStyle(parent);
900
- if (/(auto|scroll|overlay)/.test(overflowY) && parent.scrollHeight > parent.clientHeight + 1) {
901
- return parent;
902
- }
903
- parent = parent.parentElement;
904
- }
905
- return document.scrollingElement || document.documentElement;
906
- };
907
- const scrollToElement = (element, {
908
- offsetTop = 0,
909
- getScrollContainer
910
- } = {}) => {
911
- const scrollContainer = resolveScrollContainer(element, getScrollContainer);
912
- const targetRect = element.getBoundingClientRect();
913
- if (scrollContainer === document.scrollingElement || scrollContainer === document.documentElement || scrollContainer === document.body) {
914
- const scrollTop = window.pageYOffset + targetRect.top - offsetTop;
915
- window.scrollTo({
916
- top: Math.max(0, scrollTop),
917
- behavior: 'auto'
918
- });
919
- return;
920
- }
921
- const containerRect = scrollContainer.getBoundingClientRect();
922
- const nextScrollTop = scrollContainer.scrollTop + targetRect.top - containerRect.top - offsetTop;
923
- scrollContainer.scrollTo({
924
- top: Math.max(0, nextScrollTop),
925
- behavior: 'auto'
926
- });
927
- };
928
- const scrollAnchorIntoView = (root, {
929
- getScrollContainer,
930
- preferToolbar = false
931
- } = {}) => {
932
- const target = getScrollAnchorElement(root, {
933
- preferToolbar
934
- });
935
- if (!target) {
936
- return;
937
- }
938
- const offsetTop = readScrollTopInsetPixels(target);
939
- requestAnimationFrame(() => {
940
- requestAnimationFrame(() => {
941
- if (isTopEdgeInViewport(target, offsetTop, getScrollContainer)) {
942
- return;
943
- }
944
- scrollToElement(target, {
945
- offsetTop,
946
- getScrollContainer
947
- });
948
- });
949
- });
950
- };
951
- const isTopEdgeInViewport = (element, scrollMarginTop = 0, getScrollContainer) => {
952
- if (!element) {
953
- return true;
954
- }
955
- const rect = element.getBoundingClientRect();
956
- const explicitContainer = typeof getScrollContainer === 'function' ? getScrollContainer() : null;
957
- if (!StickyScroller.isDocumentScrollContainer(explicitContainer)) {
958
- const containerRect = explicitContainer.getBoundingClientRect();
959
- const viewportTop = containerRect.top + scrollMarginTop;
960
- return rect.top >= viewportTop && rect.top < containerRect.bottom;
961
- }
962
- const viewport = StickyScroller.getViewportRect();
963
- const viewportTop = viewport.top + scrollMarginTop;
964
- return rect.top >= viewportTop && rect.top < viewport.bottom;
965
- };
966
-
967
- /** 叶子去掉空 children,懒加载节点保留 [],避免 antd 把所有节点当成可展开 */
968
- const prepareAntdTreeNodes = (nodes, {
969
- childrenKey = 'children',
970
- hasChildrenKey = 'hasChildren'
971
- } = {}) => (nodes || []).map(item => {
972
- const children = get__default["default"](item, childrenKey);
973
- const next = Object.assign({}, item);
974
- if (Array.isArray(children) && children.length > 0) {
975
- next[childrenKey] = prepareAntdTreeNodes(children, {
976
- childrenKey,
977
- hasChildrenKey
978
- });
979
- return next;
980
- }
981
- if (get__default["default"](item, hasChildrenKey) === true) {
982
- next[childrenKey] = [];
983
- return next;
984
- }
985
- if (Object.prototype.hasOwnProperty.call(next, childrenKey)) {
986
- delete next[childrenKey];
987
- }
988
- return next;
989
- });
990
- const prepareAntdTreeData = (dataSource, {
991
- dataType = 'list',
992
- rowKey = 'id',
993
- parentKey = 'parentId',
994
- childrenKey = 'children',
995
- hasChildrenKey = 'hasChildren'
996
- } = {}) => {
997
- const isTree = tableView.isTreeDataType(dataType);
998
- if (!isTree) {
999
- return {
1000
- isTree: false,
1001
- treeData: dataSource,
1002
- expandableKeys: [],
1003
- treeKeyMaps: null
1004
- };
1005
- }
1006
- const tree = tableView.normalizeTreeData(dataSource, {
1007
- dataType,
1008
- rowKey,
1009
- parentKey,
1010
- childrenKey
1011
- });
1012
- const treeData = prepareAntdTreeNodes(tree, {
1013
- childrenKey,
1014
- hasChildrenKey
1015
- });
1016
- const expandableKeys = tableView.collectExpandableKeys(treeData, {
1017
- rowKey,
1018
- childrenKey,
1019
- hasChildrenKey
1020
- });
1021
- const treeKeyMaps = tableView.buildTreeKeyMaps(treeData, {
1022
- rowKey,
1023
- childrenKey
1024
- });
1025
- return {
1026
- isTree: true,
1027
- treeData,
1028
- expandableKeys,
1029
- treeKeyMaps
1030
- };
1031
- };
1032
- const resolveExpandedRowKeys = (expandedKeys, expandableKeys = []) => {
1033
- if (expandedKeys === true) {
1034
- return expandableKeys.slice();
1035
- }
1036
- if (expandedKeys === false || expandedKeys == null) {
1037
- return [];
1038
- }
1039
- return Array.isArray(expandedKeys) ? expandedKeys.slice() : [];
1040
- };
1041
- const shouldLoadTreeChildren = (item, {
1042
- key,
1043
- childrenKey = 'children',
1044
- hasChildrenKey = 'hasChildren',
1045
- loadingKeys,
1046
- loadedKeys
1047
- }) => {
1048
- if (get__default["default"](item, hasChildrenKey) !== true) {
1049
- return false;
1050
- }
1051
- const children = get__default["default"](item, childrenKey);
1052
- if (Array.isArray(children) && children.length > 0) {
1053
- return false;
1054
- }
1055
- if (loadingKeys?.has?.(key) || loadedKeys?.has?.(key)) {
1056
- return false;
1057
- }
1058
- return tableView.nodeCanExpand(item, {
1059
- childrenKey,
1060
- hasChildrenKey
1061
- });
1062
- };
1063
-
1064
- const TreeExpandContent = ({
1065
- level = 0,
1066
- indentSize = 16,
1067
- hasChildren,
1068
- expanded,
1069
- loading,
1070
- onExpand,
1071
- selection,
1072
- className
1073
- }) => /*#__PURE__*/jsxRuntime.jsxs("span", {
1074
- className: classnames__default["default"](style$2['tree-selection-content'], className, 'info-page-table-col-content'),
1075
- children: [/*#__PURE__*/jsxRuntime.jsx("span", {
1076
- className: style$2['tree-indent'],
1077
- style: {
1078
- width: level * indentSize,
1079
- minWidth: level * indentSize
1080
- }
1081
- }), hasChildren ? /*#__PURE__*/jsxRuntime.jsx("button", {
1082
- type: "button",
1083
- className: classnames__default["default"](style$2['tree-expand'], {
1084
- [style$2['is-expanded']]: expanded && !loading,
1085
- [style$2['is-loading']]: loading
1086
- }),
1087
- "aria-expanded": !!expanded,
1088
- disabled: !!loading,
1089
- onClick: event => {
1090
- event.stopPropagation();
1091
- if (loading) {
1092
- return;
1093
- }
1094
- onExpand?.(event);
1095
- },
1096
- children: loading ? /*#__PURE__*/jsxRuntime.jsx(icons.LoadingOutlined, {
1097
- spin: true
1098
- }) : /*#__PURE__*/jsxRuntime.jsx(icons.CaretRightOutlined, {})
1099
- }) : /*#__PURE__*/jsxRuntime.jsx("span", {
1100
- className: style$2['tree-leaf-placeholder']
1101
- }), selection ? /*#__PURE__*/jsxRuntime.jsx("span", {
1102
- className: style$2['tree-selection-control'],
1103
- children: selection
1104
- }) : null]
1105
- });
1106
-
1107
- const _excluded$1 = ["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", "dataType", "parentKey", "childrenKey", "hasChildrenKey", "treeTitleKey", "onLoadChildren", "expandedKeys", "defaultExpandedKeys", "onExpandedKeysChange", "indentSize"],
1108
- _excluded2$1 = ["y"],
1109
- _excluded3$1 = ["getContainer"];
1110
- const mapJustifyToAlign = justify => {
1111
- if (justify === 'center') {
1112
- return 'center';
1113
- }
1114
- if (justify === 'flex-end') {
1115
- return 'right';
1116
- }
1117
- return 'left';
1118
- };
1119
- const resolveRowKey = (rowKey, record) => get__default["default"](record, typeof rowKey === 'function' ? rowKey(record) : rowKey);
1120
- const toAntdWidth = width => {
1121
- if (width == null) {
1122
- return undefined;
1123
- }
1124
- if (typeof width === 'number') {
1125
- return width;
1126
- }
1127
- const parsed = tableView.parseColumnWidth(width);
1128
- return parsed || width;
1129
- };
1130
- const toAntdFixed = fixed => {
1131
- if (fixed === 'right') {
1132
- return 'right';
1133
- }
1134
- if (fixed === true || fixed === 'left') {
1135
- return 'left';
1136
- }
1137
- return undefined;
1138
- };
1139
- const getColCellStyle = column => ({
1140
- textAlign: mapJustifyToAlign(column.justify),
1141
- verticalAlign: column.align === 'middle' ? 'middle' : column.align === 'bottom' ? 'bottom' : 'top'
1142
- });
1143
- const getAntCellClassName = function () {
1144
- return classnames__default["default"](style$2['table-cell'], 'info-page-table-col', ...[].slice.call(arguments));
1145
- };
1146
- const wrapColContent = node => /*#__PURE__*/jsxRuntime.jsx("span", {
1147
- className: style$2['col-content'],
1148
- children: node
1149
- });
1150
- const Table = p => {
1151
- const tableRef = react.useRef(null);
1152
- const tableWidth = useElementWidth(tableRef);
1153
- // controllerOpen 默认 true:需等列宽计算;骨架屏等场景显式 false 时可立即渲染
1154
- const _useState = react.useState(() => p.controllerOpen !== false),
1155
- isLayout = _useState[0],
1156
- setIsLayout = _useState[1];
1157
- const isMobile = responsiveUtils.useIsMobile();
1158
- const props = Object.assign({}, {
1159
- rowKey: 'id',
1160
- valueIsEmpty: isEmpty.isEmpty,
1161
- placeholder: '-',
1162
- emptyIsPlaceholder: true,
1163
- empty: /*#__PURE__*/jsxRuntime.jsx(antd.Empty, {}),
1164
- controllerOpen: true,
1165
- dataType: 'list',
1166
- parentKey: 'parentId',
1167
- childrenKey: 'children',
1168
- hasChildrenKey: 'hasChildren',
1169
- treeTitleKey: 'name',
1170
- defaultExpandedKeys: false,
1171
- indentSize: 16
1172
- }, p);
1173
- const className = props.className,
1174
- dataSource = props.dataSource,
1175
- columnsProp = props.columns,
1176
- rowKey = props.rowKey,
1177
- rowSelection = props.rowSelection,
1178
- valueIsEmpty = props.valueIsEmpty,
1179
- emptyIsPlaceholder = props.emptyIsPlaceholder,
1180
- placeholder = props.placeholder,
1181
- empty = props.empty,
1182
- onRowSelect = props.onRowSelect,
1183
- render = props.render,
1184
- _props$renderMobile = props.renderMobile,
1185
- renderMobile = _props$renderMobile === void 0 ? true : _props$renderMobile,
1186
- context = props.context,
1187
- sticky = props.sticky,
1188
- scrollTopInset = props.scrollTopInset,
1189
- stickyOffset = props.stickyOffset,
1190
- getStickyContainer = props.getStickyContainer,
1191
- headerStyle = props.headerStyle,
1192
- _props$pagination = props.pagination,
1193
- pagination = _props$pagination === void 0 ? false : _props$pagination,
1194
- sortRender = props.sortRender,
1195
- mobileSortToolbar = props.mobileSortToolbar,
1196
- name = props.name,
1197
- controllerOpen = props.controllerOpen,
1198
- tableServerApis = props.tableServerApis,
1199
- scroll = props.scroll,
1200
- summary = props.summary,
1201
- size = props.size,
1202
- dataType = props.dataType,
1203
- parentKey = props.parentKey,
1204
- childrenKey = props.childrenKey,
1205
- hasChildrenKey = props.hasChildrenKey,
1206
- treeTitleKey = props.treeTitleKey,
1207
- onLoadChildren = props.onLoadChildren,
1208
- expandedKeysProp = props.expandedKeys,
1209
- defaultExpandedKeys = props.defaultExpandedKeys,
1210
- onExpandedKeysChange = props.onExpandedKeysChange,
1211
- indentSize = props.indentSize,
1212
- others = _objectWithoutPropertiesLoose(props, _excluded$1);
1213
- const sizeClassName = size === 'small' ? style$2['is-size-small'] : size === 'large' ? style$2['is-size-large'] : null;
1214
- const useMobileRender = tableView.isRenderMobileActive(renderMobile, isMobile);
1215
- const isExpandedControlled = Object.prototype.hasOwnProperty.call(p, 'expandedKeys');
1216
- const _useState2 = react.useState(defaultExpandedKeys),
1217
- innerExpandedKeys = _useState2[0],
1218
- setInnerExpandedKeys = _useState2[1];
1219
- const expandedKeys = isExpandedControlled ? expandedKeysProp : innerExpandedKeys;
1220
- const _useState3 = react.useState(() => new Set()),
1221
- loadingKeys = _useState3[0],
1222
- setLoadingKeys = _useState3[1];
1223
- const loadedKeysRef = react.useRef(new Set());
1224
- const columns = react.useMemo(() => tableView.resolveColumns(columnsProp), [columnsProp]);
1225
- const _useMemo = react.useMemo(() => prepareAntdTreeData(dataSource, {
1226
- dataType,
1227
- rowKey,
1228
- parentKey,
1229
- childrenKey,
1230
- hasChildrenKey
1231
- }), [dataSource, dataType, rowKey, parentKey, childrenKey, hasChildrenKey]),
1232
- isTree = _useMemo.isTree,
1233
- treeData = _useMemo.treeData,
1234
- expandableKeys = _useMemo.expandableKeys,
1235
- treeKeyMaps = _useMemo.treeKeyMaps;
1236
- const checkRelation = tableView.resolveCheckRelation(rowSelection == null ? void 0 : rowSelection.checkRelation, {
1237
- isTree,
1238
- selectionType: rowSelection == null ? void 0 : rowSelection.type
1239
- });
1240
- const tableDataSource = isTree ? treeData : dataSource;
1241
- const handleExpandedChange = react.useCallback(nextKeys => {
1242
- if (!isExpandedControlled) {
1243
- setInnerExpandedKeys(nextKeys);
1244
- }
1245
- onExpandedKeysChange && onExpandedKeysChange(nextKeys);
1246
- }, [isExpandedControlled, onExpandedKeysChange]);
1247
- const clearLoadingKey = key => {
1248
- setLoadingKeys(prev => {
1249
- if (!prev.has(key)) {
1250
- return prev;
1251
- }
1252
- const next = new Set(prev);
1253
- next.delete(key);
1254
- return next;
1255
- });
1256
- };
1257
- const handleLoadChildren = react.useCallback(record => {
1258
- if (typeof onLoadChildren !== 'function') {
1259
- return;
1260
- }
1261
- const key = resolveRowKey(rowKey, record);
1262
- if (!shouldLoadTreeChildren(record, {
1263
- key,
1264
- childrenKey,
1265
- hasChildrenKey,
1266
- loadingKeys,
1267
- loadedKeys: loadedKeysRef.current
1268
- })) {
1269
- return;
1270
- }
1271
- setLoadingKeys(prev => new Set(prev).add(key));
1272
- Promise.resolve(onLoadChildren(record, {
1273
- key
1274
- })).catch(() => {}).finally(() => {
1275
- loadedKeysRef.current.add(key);
1276
- clearLoadingKey(key);
1277
- });
1278
- }, [onLoadChildren, rowKey, childrenKey, hasChildrenKey, loadingKeys]);
1279
- const expandedRowKeys = react.useMemo(() => isTree ? resolveExpandedRowKeys(expandedKeys, expandableKeys) : undefined, [isTree, expandedKeys, expandableKeys]);
1280
- const maxTreeLevel = react.useMemo(() => {
1281
- if (!isTree) {
1282
- return 0;
1283
- }
1284
- const displayRows = tableView.flattenVisibleTree(treeData, {
1285
- rowKey,
1286
- childrenKey,
1287
- hasChildrenKey,
1288
- expandedKeys
1289
- });
1290
- return displayRows.reduce((max, row) => Math.max(max, row.level || 0), 0);
1291
- }, [isTree, treeData, rowKey, childrenKey, hasChildrenKey, expandedKeys]);
1292
- const selectionColumnWidth = react.useMemo(() => tableView.getTreeSelectionColumnWidth({
1293
- indentSize,
1294
- maxLevel: maxTreeLevel,
1295
- rowSelection,
1296
- isTree
1297
- }), [indentSize, maxTreeLevel, rowSelection, isTree]);
1298
- // antd 单元格会裁剪 overflow,树形选择列多留 2px 避免 checkbox 右边框被切
1299
- const antdSelectionColumnWidth = isTree && selectionColumnWidth > 0 ? selectionColumnWidth + 2 : selectionColumnWidth;
1300
- const handleToggleExpand = react.useCallback((key, record) => {
1301
- const wasExpanded = (expandedRowKeys || []).indexOf(key) > -1;
1302
- const nextKeys = tableView.toggleExpandedKey(expandedKeys, key, expandableKeys);
1303
- handleExpandedChange(nextKeys);
1304
- if (!wasExpanded) {
1305
- handleLoadChildren(record);
1306
- }
1307
- }, [expandedRowKeys, expandedKeys, expandableKeys, handleExpandedChange, handleLoadChildren]);
1308
- const getTreeRowMeta = react.useCallback(record => {
1309
- var _treeKeyMaps$getAnces;
1310
- const key = resolveRowKey(rowKey, record);
1311
- const level = (treeKeyMaps == null || (_treeKeyMaps$getAnces = treeKeyMaps.getAncestorKeys(key)) == null ? void 0 : _treeKeyMaps$getAnces.length) || 0;
1312
- return {
1313
- key,
1314
- level,
1315
- hasChildren: tableView.nodeCanExpand(record, {
1316
- childrenKey,
1317
- hasChildrenKey
1318
- }),
1319
- expanded: (expandedRowKeys || []).indexOf(key) > -1
1320
- };
1321
- }, [rowKey, treeKeyMaps, childrenKey, hasChildrenKey, expandedRowKeys]);
1322
- const antdExpandable = react.useMemo(() => {
1323
- if (!isTree) {
1324
- return others.expandable;
1325
- }
1326
- // 隐藏 antd 默认展开列,改用与 TableView 一致的自绘三角
1327
- return Object.assign({}, others.expandable, {
1328
- childrenColumnName: childrenKey,
1329
- showExpandColumn: false,
1330
- expandIcon: () => null,
1331
- indentSize: 0,
1332
- expandedRowKeys,
1333
- onExpandedRowsChange: keys => {
1334
- var _others$expandable;
1335
- (_others$expandable = others.expandable) == null || _others$expandable.onExpandedRowsChange == null || _others$expandable.onExpandedRowsChange(keys);
1336
- handleExpandedChange(keys);
1337
- }
1338
- });
1339
- }, [isTree, others.expandable, childrenKey, expandedRowKeys, handleExpandedChange]);
1340
- react.useEffect(() => {
1341
- if (tableWidth) {
1342
- setTimeout(() => setIsLayout(false), 0);
1343
- }
1344
- }, [tableWidth]);
1345
- const _useTableConfig = useTableConfig({
1346
- columns,
1347
- name,
1348
- controllerOpen,
1349
- tableWidth,
1350
- rowKey,
1351
- tableServerApis
1352
- }),
1353
- visibleColumns = _useTableConfig.visibleColumns,
1354
- columnsConfig = _useTableConfig.columnsConfig,
1355
- currentMoveColumnIndex = _useTableConfig.currentMoveColumnIndex,
1356
- totalWidth = _useTableConfig.totalWidth,
1357
- computedColumnProps = _useTableConfig.computedColumnProps,
1358
- hasFixedColumn = _useTableConfig.hasFixedColumn;
1359
- const _useState4 = react.useState(null),
1360
- resizeGuideStyle = _useState4[0],
1361
- setResizeGuideStyle = _useState4[1];
1362
- const updateResizeGuide = react.useCallback(() => {
1363
- var _barRect$right;
1364
- if (currentMoveColumnIndex === null || !tableRef.current) {
1365
- setResizeGuideStyle(null);
1366
- return;
1367
- }
1368
- const root = tableRef.current;
1369
- const headerCell = root.querySelector('.ant-table-thead .ant-table-cell.is-moving');
1370
- const tableContainer = root.querySelector('.ant-table-container');
1371
- if (!headerCell || !tableContainer) {
1372
- setResizeGuideStyle(null);
1373
- return;
1374
- }
1375
- const wrapperRect = root.getBoundingClientRect();
1376
- const headerRect = headerCell.getBoundingClientRect();
1377
- const resizeBar = headerCell.querySelector('.table-cell-resize-bar');
1378
- const barRect = resizeBar == null ? void 0 : resizeBar.getBoundingClientRect();
1379
- const containerRect = tableContainer.getBoundingClientRect();
1380
- setResizeGuideStyle({
1381
- left: Math.round(((_barRect$right = barRect == null ? void 0 : barRect.right) != null ? _barRect$right : headerRect.right) - wrapperRect.left),
1382
- top: Math.round(containerRect.top - wrapperRect.top),
1383
- height: Math.round(containerRect.height)
1384
- });
1385
- }, [currentMoveColumnIndex]);
1386
- react.useLayoutEffect(() => {
1387
- updateResizeGuide();
1388
- }, [updateResizeGuide, columnsConfig, tableWidth, dataSource, isLayout]);
1389
- react.useEffect(() => {
1390
- if (currentMoveColumnIndex === null) {
1391
- return;
1392
- }
1393
- const handleUpdate = () => updateResizeGuide();
1394
- window.addEventListener('mousemove', handleUpdate);
1395
- window.addEventListener('scroll', handleUpdate, true);
1396
- const resizeObserver = new ResizeObserver(handleUpdate);
1397
- if (tableRef.current) {
1398
- resizeObserver.observe(tableRef.current);
1399
- }
1400
- return () => {
1401
- window.removeEventListener('mousemove', handleUpdate);
1402
- window.removeEventListener('scroll', handleUpdate, true);
1403
- resizeObserver.disconnect();
1404
- };
1405
- }, [currentMoveColumnIndex, updateResizeGuide]);
1406
- const targetColumns = react.useMemo(() => visibleColumns.map((column, index) => Object.assign({}, column, {
1407
- __index: index
1408
- })), [visibleColumns]);
1409
- const _useGroupHeader = useGroupHeader(targetColumns),
1410
- groupedColumns = _useGroupHeader.columns,
1411
- hasGroupHeader = _useGroupHeader.hasGroupHeader;
1412
- const antdColumns = react.useMemo(() => {
1413
- const buildLeafColumn = (column, index) => {
1414
- const colName = column.name,
1415
- title = column.title,
1416
- width = column.width,
1417
- justify = column.justify,
1418
- fixed = column.fixed;
1419
- const baseColumn = {
1420
- key: colName,
1421
- dataIndex: colName,
1422
- title: /*#__PURE__*/jsxRuntime.jsx("span", {
1423
- className: style$2['col-content'],
1424
- children: tableView.renderColumnTitle(title, column, sortRender)
1425
- }),
1426
- width: toAntdWidth(width),
1427
- fixed: toAntdFixed(fixed),
1428
- align: mapJustifyToAlign(justify),
1429
- ellipsis: tableView.getColumnEllipsis(column),
1430
- onHeaderCell: () => ({
1431
- className: getAntCellClassName(),
1432
- style: getColCellStyle(column)
1433
- }),
1434
- onCell: () => ({
1435
- className: getAntCellClassName(),
1436
- style: getColCellStyle(column)
1437
- }),
1438
- render: (_, record) => {
1439
- const _computeColumnsValue = tableView.computeColumnsValue({
1440
- columns: [column],
1441
- emptyIsPlaceholder,
1442
- valueIsEmpty,
1443
- removeEmpty: false,
1444
- dataSource: record,
1445
- placeholder,
1446
- context
1447
- }),
1448
- computedColumn = _computeColumnsValue[0];
1449
- if (!computedColumn) {
1450
- return null;
1451
- }
1452
- return tableView.renderCellContent(tableView.computeDisplay({
1453
- column: computedColumn,
1454
- placeholder,
1455
- dataSource: record,
1456
- context
1457
- }), computedColumn, style$2['col-content']);
1458
- }
1459
- };
1460
- if (!controllerOpen) {
1461
- return baseColumn;
1462
- }
1463
- const configProps = computedColumnProps(column, index, {
1464
- title: /*#__PURE__*/jsxRuntime.jsx("span", {
1465
- className: style$2['col-content'],
1466
- children: tableView.renderColumnTitle(title, column, sortRender)
1467
- })
1468
- });
1469
- const antdFixed = toAntdFixed(fixed);
1470
- return Object.assign({}, baseColumn, configProps, {
1471
- width: configProps.width,
1472
- fixed: antdFixed,
1473
- onHeaderCell: () => ({
1474
- className: getAntCellClassName(configProps.onHeaderCell == null ? void 0 : configProps.onHeaderCell().className),
1475
- style: getColCellStyle(column)
1476
- }),
1477
- onCell: () => ({
1478
- className: getAntCellClassName(configProps.onCell == null ? void 0 : configProps.onCell().className),
1479
- style: getColCellStyle(column)
1480
- })
1481
- });
1482
- };
1483
- const mapColumn = column => {
1484
- if (column.children && column.children.length > 0) {
1485
- return {
1486
- key: column.name,
1487
- title: /*#__PURE__*/jsxRuntime.jsx("span", {
1488
- className: style$2['col-content'],
1489
- children: tableView.wrapColumnHeaderTitle(column.title)
1490
- }),
1491
- onHeaderCell: () => ({
1492
- className: getAntCellClassName(),
1493
- style: {
1494
- textAlign: 'center',
1495
- verticalAlign: 'middle'
1496
- }
1497
- }),
1498
- children: column.children.map(mapColumn)
1499
- };
1500
- }
1501
- return buildLeafColumn(column, column.__index);
1502
- };
1503
- const mapped = groupedColumns.map(mapColumn);
1504
- if (!isTree || rowSelection) {
1505
- return mapped;
1506
- }
1507
- const expandColumn = {
1508
- key: '__tree_expand__',
1509
- width: antdSelectionColumnWidth,
1510
- fixed: hasFixedColumn ? 'left' : undefined,
1511
- title: /*#__PURE__*/jsxRuntime.jsx(TreeExpandContent, {
1512
- level: 0,
1513
- indentSize: indentSize,
1514
- hasChildren: false
1515
- }),
1516
- onHeaderCell: () => ({
1517
- className: getAntCellClassName(style$2['tree-expand-col'])
1518
- }),
1519
- onCell: () => ({
1520
- className: getAntCellClassName(style$2['tree-expand-col'])
1521
- }),
1522
- render: (_, record) => {
1523
- const meta = getTreeRowMeta(record);
1524
- return /*#__PURE__*/jsxRuntime.jsx(TreeExpandContent, {
1525
- level: meta.level,
1526
- indentSize: indentSize,
1527
- hasChildren: meta.hasChildren,
1528
- expanded: meta.expanded,
1529
- loading: loadingKeys.has(meta.key),
1530
- onExpand: () => handleToggleExpand(meta.key, record)
1531
- });
1532
- }
1533
- };
1534
- return [expandColumn, ...mapped];
1535
- }, [groupedColumns, context, emptyIsPlaceholder, placeholder, sortRender, valueIsEmpty, controllerOpen, computedColumnProps, currentMoveColumnIndex, isTree, rowSelection, antdSelectionColumnWidth, hasFixedColumn, indentSize, getTreeRowMeta, loadingKeys, handleToggleExpand]);
1536
- const antdRowSelection = react.useMemo(() => {
1537
- if (!rowSelection) {
1538
- return undefined;
1539
- }
1540
- const getRowKey = record => resolveRowKey(rowKey, record);
1541
- // 全选判断/操作只针对可勾选行,排除 disabled
1542
- const allKeys = isTree ? ((treeKeyMaps == null ? void 0 : treeKeyMaps.allKeys) || []).filter(key => {
1543
- var _treeKeyMaps$nodeMap$;
1544
- return !((_treeKeyMaps$nodeMap$ = treeKeyMaps.nodeMap.get(key)) != null && _treeKeyMaps$nodeMap$.disabled);
1545
- }) : (dataSource || []).filter(item => !item.disabled).map(getRowKey);
1546
- const useTreeCheck = isTree && rowSelection.type === 'checkbox' && checkRelation !== 'independent' && treeKeyMaps;
1547
- const renderSelectAllNode = () => {
1548
- if (rowSelection.type !== 'checkbox') {
1549
- return null;
1550
- }
1551
- if (!rowSelection.allowSelectedAll) {
1552
- return /*#__PURE__*/jsxRuntime.jsx(antd.Checkbox, {
1553
- style: {
1554
- visibility: 'hidden'
1555
- }
1556
- });
1557
- }
1558
- if (useTreeCheck) {
1559
- const checkedAll = rowSelection.isSelectedAll ? true : tableView.isAllTreeSelected({
1560
- mode: checkRelation,
1561
- maps: treeKeyMaps,
1562
- selectedKeys: rowSelection.selectedRowKeys
1563
- });
1564
- const indeterminate = rowSelection.isSelectedAll ? false : !checkedAll && tableView.hasAnyTreeSelected({
1565
- mode: checkRelation,
1566
- maps: treeKeyMaps,
1567
- selectedKeys: rowSelection.selectedRowKeys
1568
- });
1569
- return /*#__PURE__*/jsxRuntime.jsx(antd.Checkbox, {
1570
- checked: checkedAll,
1571
- indeterminate: indeterminate,
1572
- onChange: e => {
1573
- const checked = e.target.checked;
1574
- if (typeof rowSelection.onIsSelectAllChange === 'function') {
1575
- rowSelection.onIsSelectAllChange(checked);
1576
- return;
1577
- }
1578
- const existing = rowSelection.selectedRowKeys || [];
1579
- rowSelection.onChange(checked ? tableView.buildSelectAllKeys({
1580
- mode: checkRelation,
1581
- maps: treeKeyMaps,
1582
- existingKeys: existing
1583
- }) : tableView.buildClearSelectAllKeys({
1584
- mode: checkRelation,
1585
- maps: treeKeyMaps,
1586
- existingKeys: existing
1587
- }), undefined, {
1588
- context,
1589
- checked
1590
- });
1591
- }
1592
- });
1593
- }
1594
- const checkedAll = rowSelection.isSelectedAll || allKeys.length > 0 && allKeys.every(key => (rowSelection.selectedRowKeys || []).indexOf(key) > -1);
1595
- const indeterminate = !checkedAll && allKeys.some(key => (rowSelection.selectedRowKeys || []).indexOf(key) > -1);
1596
- return /*#__PURE__*/jsxRuntime.jsx(antd.Checkbox, {
1597
- checked: checkedAll,
1598
- indeterminate: indeterminate,
1599
- onChange: e => {
1600
- const checked = e.target.checked;
1601
- if (typeof rowSelection.onIsSelectAllChange === 'function') {
1602
- rowSelection.onIsSelectAllChange(checked);
1603
- return;
1604
- }
1605
- const existing = rowSelection.selectedRowKeys || [];
1606
- if (!checked) {
1607
- rowSelection.onChange(existing.filter(key => allKeys.indexOf(key) === -1), undefined, {
1608
- context,
1609
- checked: false
1610
- });
1611
- return;
1612
- }
1613
- if (allKeys.length === 0) {
1614
- return;
1615
- }
1616
- const merged = existing.slice();
1617
- allKeys.forEach(key => {
1618
- if (merged.indexOf(key) === -1) {
1619
- merged.push(key);
1620
- }
1621
- });
1622
- rowSelection.onChange(merged, undefined, {
1623
- context,
1624
- checked: true
1625
- });
1626
- }
1627
- });
1628
- };
1629
- const renderTreeSelectionControl = record => {
1630
- const id = getRowKey(record);
1631
- if (rowSelection.type === 'checkbox') {
1632
- const state = useTreeCheck ? tableView.getTreeCheckState(id, rowSelection.selectedRowKeys, checkRelation, treeKeyMaps) : {
1633
- checked: (rowSelection.selectedRowKeys || []).indexOf(id) > -1,
1634
- indeterminate: false
1635
- };
1636
- return /*#__PURE__*/jsxRuntime.jsx(antd.Checkbox, {
1637
- disabled: record.disabled || rowSelection.isSelectedAll,
1638
- checked: rowSelection.isSelectedAll && !record.disabled || state.checked,
1639
- indeterminate: !rowSelection.isSelectedAll && !!state.indeterminate,
1640
- onChange: e => {
1641
- const nextChecked = e.target.checked;
1642
- if (useTreeCheck) {
1643
- const nextKeys = tableView.toggleTreeCheck({
1644
- key: id,
1645
- checked: nextChecked,
1646
- selectedKeys: rowSelection.selectedRowKeys || [],
1647
- mode: checkRelation,
1648
- maps: treeKeyMaps
1649
- });
1650
- rowSelection.onChange(nextKeys, id, {
1651
- context,
1652
- checked: nextChecked
1653
- });
1654
- return;
1655
- }
1656
- const selectedRowKeys = (rowSelection.selectedRowKeys || []).slice();
1657
- if (nextChecked) {
1658
- if (selectedRowKeys.indexOf(id) === -1) {
1659
- selectedRowKeys.push(id);
1660
- }
1661
- } else {
1662
- const index = selectedRowKeys.indexOf(id);
1663
- if (index > -1) {
1664
- selectedRowKeys.splice(index, 1);
1665
- }
1666
- }
1667
- rowSelection.onChange(selectedRowKeys, id, {
1668
- context,
1669
- checked: nextChecked
1670
- });
1671
- }
1672
- });
1673
- }
1674
- if (rowSelection.type === 'radio') {
1675
- const checked = (rowSelection.selectedRowKeys || [])[0] === id;
1676
- return /*#__PURE__*/jsxRuntime.jsx(antd.Radio, {
1677
- disabled: record.disabled,
1678
- checked: checked,
1679
- onChange: () => {
1680
- rowSelection.onChange(checked ? [] : [id], id, {
1681
- context,
1682
- checked: !checked
1683
- });
1684
- }
1685
- });
1686
- }
1687
- return null;
1688
- };
1689
- if (isTree) {
1690
- const selectAllNode = rowSelection.type === 'checkbox' ? renderSelectAllNode() : null;
1691
- return _extends({
1692
- type: rowSelection.type === 'radio' ? 'radio' : 'checkbox',
1693
- preserveSelectedRowKeys: true,
1694
- checkStrictly: true,
1695
- hideSelectAll: true,
1696
- columnWidth: antdSelectionColumnWidth
1697
- }, hasFixedColumn ? {
1698
- fixed: 'left'
1699
- } : {}, {
1700
- selectedRowKeys: rowSelection.isSelectedAll ? allKeys : rowSelection.selectedRowKeys,
1701
- onChange: () => {},
1702
- getCheckboxProps: record => ({
1703
- disabled: record.disabled || rowSelection.isSelectedAll
1704
- }),
1705
- columnTitle: /*#__PURE__*/jsxRuntime.jsx(TreeExpandContent, {
1706
- level: 0,
1707
- indentSize: indentSize,
1708
- hasChildren: false,
1709
- selection: selectAllNode
1710
- }),
1711
- renderCell: (checked, record) => {
1712
- const meta = getTreeRowMeta(record);
1713
- return /*#__PURE__*/jsxRuntime.jsx(TreeExpandContent, {
1714
- level: meta.level,
1715
- indentSize: indentSize,
1716
- hasChildren: meta.hasChildren,
1717
- expanded: meta.expanded,
1718
- loading: loadingKeys.has(meta.key),
1719
- onExpand: () => handleToggleExpand(meta.key, record),
1720
- selection: renderTreeSelectionControl(record)
1721
- });
1722
- },
1723
- onCell: () => ({
1724
- className: getAntCellClassName(style$2['selection-col'])
1725
- })
1726
- });
1727
- }
1728
- return _extends({
1729
- type: rowSelection.type === 'radio' ? 'radio' : 'checkbox',
1730
- preserveSelectedRowKeys: true,
1731
- hideSelectAll: true
1732
- }, hasFixedColumn ? {
1733
- fixed: 'left'
1734
- } : {}, {
1735
- selectedRowKeys: rowSelection.isSelectedAll ? allKeys : rowSelection.selectedRowKeys,
1736
- onChange: (selectedRowKeys, selectedRows) => {
1737
- const currentKey = selectedRows.length > 0 ? getRowKey(selectedRows[selectedRows.length - 1]) : selectedRowKeys[selectedRowKeys.length - 1];
1738
- const checked = selectedRowKeys.indexOf(currentKey) > -1;
1739
- rowSelection.onChange(selectedRowKeys, currentKey, {
1740
- context,
1741
- checked
1742
- });
1743
- },
1744
- getCheckboxProps: record => ({
1745
- disabled: record.disabled || rowSelection.isSelectedAll
1746
- })
1747
- }, rowSelection.type === 'checkbox' ? {
1748
- columnWidth: antdSelectionColumnWidth || 48,
1749
- columnTitle: wrapColContent(renderSelectAllNode()),
1750
- renderCell: (checked, record, index, originNode) => wrapColContent(originNode),
1751
- onCell: () => ({
1752
- className: getAntCellClassName(style$2['selection-col'])
1753
- })
1754
- } : {
1755
- columnWidth: antdSelectionColumnWidth || 48,
1756
- renderCell: (checked, record, index, originNode) => wrapColContent(originNode),
1757
- onCell: () => ({
1758
- className: getAntCellClassName(style$2['radio-col'])
1759
- })
1760
- });
1761
- }, [context, dataSource, rowKey, rowSelection, hasFixedColumn, isTree, treeKeyMaps, checkRelation, antdSelectionColumnWidth, indentSize, getTreeRowMeta, loadingKeys, handleToggleExpand]);
1762
- const hasData = Array.isArray(tableDataSource) && tableDataSource.length > 0;
1763
- const tableScroll = react.useMemo(() => {
1764
- let x;
1765
- if (hasFixedColumn) {
1766
- x = totalWidth;
1767
- } else if (controllerOpen) {
1768
- x = Math.max(tableWidth, totalWidth);
1769
- } else if (tableWidth && totalWidth > tableWidth) {
1770
- // controllerOpen 关闭时列总宽超出容器也要开启横向滚动,避免列溢出
1771
- x = totalWidth;
1772
- }
1773
- if (x != null && isTree && antdSelectionColumnWidth) {
1774
- x += antdSelectionColumnWidth;
1775
- }
1776
- const nextScroll = Object.assign({}, x != null ? {
1777
- x
1778
- } : {}, scroll);
1779
- if (!hasData && nextScroll.y != null) {
1780
- const rest = _objectWithoutPropertiesLoose(nextScroll, _excluded2$1);
1781
- return rest;
1782
- }
1783
- return nextScroll;
1784
- }, [hasFixedColumn, controllerOpen, totalWidth, tableWidth, scroll, hasData, isTree, antdSelectionColumnWidth]);
1785
- const hasScrollY = hasData && (scroll == null ? void 0 : scroll.y) != null && (scroll == null ? void 0 : scroll.y) !== false;
1786
- const isStickyViewport = !!sticky && !hasScrollY;
1787
- const resolvedScrollTopInset = resolveScrollTopInset(scrollTopInset, stickyOffset);
1788
- const stickyGetContainer = react.useMemo(() => {
1789
- if (!getStickyContainer || hasScrollY) {
1790
- return undefined;
1791
- }
1792
- return () => getStickyContainer() || window;
1793
- }, [getStickyContainer, hasScrollY]);
1794
- const parsedScrollTopInset = react.useMemo(() => {
1795
- if (!sticky || hasScrollY) {
1796
- return 0;
1797
- }
1798
- return parseInsetPixels(resolvedScrollTopInset, tableRef.current);
1799
- }, [sticky, hasScrollY, resolvedScrollTopInset, isLayout, dataSource]);
1800
- const antdSticky = react.useMemo(() => {
1801
- if (!sticky) {
1802
- return undefined;
1803
- }
1804
- const config = typeof sticky === 'object' ? Object.assign({}, sticky) : {};
1805
- if (hasScrollY) {
1806
- const scrollSticky = _objectWithoutPropertiesLoose(config, _excluded3$1);
1807
- return Object.assign({
1808
- offsetHeader: 0
1809
- }, scrollSticky);
1810
- }
1811
- return Object.assign({
1812
- offsetHeader: parsedScrollTopInset
1813
- }, config, stickyGetContainer ? {
1814
- getContainer: stickyGetContainer
1815
- } : null);
1816
- }, [sticky, stickyGetContainer, hasScrollY, parsedScrollTopInset]);
1817
- const tableWrapperStyle = react.useMemo(() => {
1818
- const next = {};
1819
- const cssValue = normalizeScrollTopInsetCSSValue(resolvedScrollTopInset);
1820
- if (cssValue) {
1821
- next['--scroll-top-inset'] = cssValue;
1822
- }
1823
- if (antdSelectionColumnWidth) {
1824
- next['--selection-col-width'] = antdSelectionColumnWidth + "px";
1825
- }
1826
- return Object.keys(next).length > 0 ? next : undefined;
1827
- }, [resolvedScrollTopInset, antdSelectionColumnWidth]);
1828
- const useTreeCheckForRow = isTree && (rowSelection == null ? void 0 : rowSelection.type) === 'checkbox' && checkRelation !== 'independent' && treeKeyMaps;
1829
- if (useMobileRender) {
1830
- return /*#__PURE__*/jsxRuntime.jsx(TableView, _extends({}, others, {
1831
- className: classnames__default["default"](className, style$2['is-mobile-render']),
1832
- dataSource: dataSource,
1833
- columns: visibleColumns,
1834
- rowKey: rowKey,
1835
- rowSelection: rowSelection,
1836
- valueIsEmpty: valueIsEmpty,
1837
- emptyIsPlaceholder: emptyIsPlaceholder,
1838
- placeholder: placeholder,
1839
- empty: empty,
1840
- onRowSelect: onRowSelect,
1841
- renderMobile: renderMobile,
1842
- context: context,
1843
- sortRender: sortRender,
1844
- mobileSortToolbar: mobileSortToolbar,
1845
- size: size,
1846
- dataType: dataType,
1847
- parentKey: parentKey,
1848
- childrenKey: childrenKey,
1849
- hasChildrenKey: hasChildrenKey,
1850
- treeTitleKey: treeTitleKey,
1851
- onLoadChildren: onLoadChildren,
1852
- expandedKeys: expandedKeysProp,
1853
- defaultExpandedKeys: defaultExpandedKeys,
1854
- onExpandedKeysChange: onExpandedKeysChange,
1855
- indentSize: indentSize
1856
- }));
1857
- }
1858
- const tableElement = /*#__PURE__*/jsxRuntime.jsx(antd.Table, _extends({}, others, {
1859
- showHeader: true,
1860
- dataSource: tableDataSource,
1861
- columns: antdColumns,
1862
- rowKey: typeof rowKey === 'function' ? rowKey : record => get__default["default"](record, rowKey),
1863
- rowSelection: antdRowSelection,
1864
- expandable: antdExpandable,
1865
- pagination: pagination,
1866
- summary: typeof summary === 'function' ? function (pageData) {
1867
- return summary(pageData, ...[].slice.call(arguments, 1));
1868
- } : undefined,
1869
- sticky: antdSticky,
1870
- tableLayout: controllerOpen || hasFixedColumn ? 'fixed' : undefined,
1871
- scroll: tableScroll,
1872
- onHeaderRow: () => ({
1873
- className: 'info-page-table-header',
1874
- style: headerStyle
1875
- }),
1876
- locale: {
1877
- emptyText: /*#__PURE__*/jsxRuntime.jsx("div", {
1878
- className: style$2['empty'],
1879
- children: empty
1880
- })
1881
- },
1882
- rowClassName: record => {
1883
- var _treeKeyMaps$getAnces2;
1884
- const id = resolveRowKey(rowKey, record);
1885
- const level = isTree ? (treeKeyMaps == null || (_treeKeyMaps$getAnces2 = treeKeyMaps.getAncestorKeys(id)) == null ? void 0 : _treeKeyMaps$getAnces2.length) || 0 : 0;
1886
- const isChecked = useTreeCheckForRow ? tableView.getTreeCheckState(id, rowSelection == null ? void 0 : rowSelection.selectedRowKeys, checkRelation, treeKeyMaps).checked : (rowSelection == null ? void 0 : rowSelection.selectedRowKeys) && rowSelection.selectedRowKeys.indexOf(id) > -1;
1887
- return classnames__default["default"]('info-page-table-row', {
1888
- [style$2['is-selected-all']]: rowSelection == null ? void 0 : rowSelection.isSelectedAll,
1889
- [style$2['is-selected']]: isChecked,
1890
- [style$2['is-disabled']]: record.disabled,
1891
- [style$2['is-tree']]: isTree,
1892
- [style$2['is-tree-child']]: isTree && level > 0
1893
- });
1894
- },
1895
- onRow: onRowSelect ? record => ({
1896
- onClick: () => {
1897
- if (record.disabled) {
1898
- return;
1899
- }
1900
- onRowSelect(record, {
1901
- columns: visibleColumns,
1902
- dataSource
1903
- });
1904
- }
1905
- }) : undefined
1906
- }));
1907
- const wrappedTable = /*#__PURE__*/jsxRuntime.jsxs("div", {
1908
- ref: tableRef,
1909
- className: classnames__default["default"](style$2['table'], 'info-page-table', sizeClassName, className, {
1910
- [style$2['is-resize']]: currentMoveColumnIndex !== null,
1911
- [style$2['is-computed']]: isLayout,
1912
- [style$2['has-group-header']]: hasGroupHeader,
1913
- [style$2['has-summary']]: typeof summary === 'function',
1914
- [style$2['is-sticky']]: !!sticky,
1915
- [style$2['is-sticky-scroll-y']]: !!sticky && hasScrollY,
1916
- [style$2['is-sticky-viewport']]: isStickyViewport,
1917
- [style$2['is-tree-table']]: isTree
1918
- }),
1919
- style: tableWrapperStyle,
1920
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
1921
- className: "info-page-table-body",
1922
- children: !isLayout && tableElement
1923
- }), currentMoveColumnIndex !== null && resizeGuideStyle && /*#__PURE__*/jsxRuntime.jsx("span", {
1924
- className: style$2['column-resize-guide'],
1925
- style: resizeGuideStyle,
1926
- "aria-hidden": true
1927
- })]
1928
- });
1929
- if (typeof render === 'function') {
1930
- return render(_extends({}, others, {
1931
- header: null,
1932
- renderBody: () => wrappedTable
1933
- }));
1934
- }
1935
- return wrappedTable;
1936
- };
1937
- Table.useSelectedRow = tableView.useSelectedRow;
1938
- Table.useSort = tableView.useSort;
1939
- Table.sortDataSource = tableView.useSort.sortDataSource;
21
+ require('@kne/react-filter/dist/index.css');
22
+ var ButtonGroup = require('@kne/button-group');
23
+ var jsxRuntime = require('react/jsx-runtime');
24
+
25
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
26
+
27
+ var ScrollLoader__default = /*#__PURE__*/_interopDefaultLegacy(ScrollLoader);
28
+ var tableView__default = /*#__PURE__*/_interopDefaultLegacy(tableView);
29
+ var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
30
+ var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
31
+ var useRefCallback__default = /*#__PURE__*/_interopDefaultLegacy(useRefCallback);
32
+ var useControlValue__default = /*#__PURE__*/_interopDefaultLegacy(useControlValue);
33
+ var filterZhCN__default = /*#__PURE__*/_interopDefaultLegacy(filterZhCN);
34
+ var filterEnUS__default = /*#__PURE__*/_interopDefaultLegacy(filterEnUS);
35
+ var StickyScroller__default = /*#__PURE__*/_interopDefaultLegacy(StickyScroller);
36
+ var ButtonGroup__default = /*#__PURE__*/_interopDefaultLegacy(ButtonGroup);
1940
37
 
1941
38
  var style$1 = {"table-page":"kne-table-page_ut9rJ","fetch-stack":"kne-table-page_dpy7d","toolbar-height-reserve":"kne-table-page_daceW","table-page-tabs-outer":"kne-table-page_IowJl","table-content":"kne-table-page_dxN6N","table-with-toolbar":"kne-table-page_sf06r","is-sticky":"kne-table-page_7lYyk","is-loading-shell":"kne-table-page_LY8zA","is-mobile-render":"kne-table-page_D6KGb","has-summary":"kne-table-page_IRdzb","table-cell-skeleton":"kne-table-page_--DrO","table-skeleton-spin":"kne-table-page_cZ1zq","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"};
1942
39
 
40
+ const locale$1 = {
41
+ TotalText: '共',
42
+ ItemText: '条',
43
+ UnnamedColumn: '未命名列',
44
+ EditTable: '编辑表格',
45
+ RestoreDefault: '恢复默认',
46
+ VisibleInfo: '显示的信息',
47
+ HiddenInfo: '隐藏的信息',
48
+ Search: '搜索',
49
+ BatchOperations: '批量操作',
50
+ BatchOperationsWithCount: '已选:{count}条',
51
+ Cancel: '取消',
52
+ Confirm: '确定',
53
+ All: '全部',
54
+ SwitchToCardView: '切换为卡片视图',
55
+ SwitchToTableView: '切换为表格视图'
56
+ };
57
+
58
+ const locale = {
59
+ TotalText: 'Total',
60
+ ItemText: 'items',
61
+ UnnamedColumn: 'Unnamed',
62
+ EditTable: 'Edit Table',
63
+ RestoreDefault: 'Restore Default',
64
+ VisibleInfo: 'Visible Columns',
65
+ HiddenInfo: 'Hidden Columns',
66
+ Search: 'Search',
67
+ BatchOperations: 'Batch Actions',
68
+ BatchOperationsWithCount: 'Selected: {count}',
69
+ Cancel: 'Cancel',
70
+ Confirm: 'Confirm',
71
+ All: 'All',
72
+ SwitchToCardView: 'Switch to card view',
73
+ SwitchToTableView: 'Switch to table view'
74
+ };
75
+
76
+ const withLocale = reactIntl.createWithIntlProvider({
77
+ defaultLocale: 'zh-CN',
78
+ messages: {
79
+ 'zh-CN': {
80
+ ...filterZhCN__default["default"],
81
+ ...locale$1
82
+ },
83
+ 'en-US': {
84
+ ...filterEnUS__default["default"],
85
+ ...locale
86
+ }
87
+ },
88
+ namespace: 'table-page'
89
+ });
90
+
1943
91
  const hasButtonGroupList = buttonGroup => Array.isArray(buttonGroup?.list) && buttonGroup.list.length > 0;
1944
92
  const normalizeButtonGroupList = (list, defaultSize) => {
1945
93
  if (!Array.isArray(list)) {
@@ -1976,7 +124,7 @@ const resolveButtonGroupProps = (buttonGroup, getPopupContainer, {
1976
124
  getPopupContainer: userGetPopupContainer,
1977
125
  ...rest
1978
126
  } = buttonGroup;
1979
- const resolvedShowLength = Number.isInteger(showLength) ? Math.max(minShowLength, showLength) : defaultShowLength;
127
+ const resolvedShowLength = Number.isInteger(showLength) ? Math.max(minShowLength, showLength) : Number.isInteger(defaultShowLength) ? defaultShowLength : undefined;
1980
128
  return {
1981
129
  ...rest,
1982
130
  list: normalizeButtonGroupList(list, defaultSize),
@@ -1986,14 +134,17 @@ const resolveButtonGroupProps = (buttonGroup, getPopupContainer, {
1986
134
  size
1987
135
  } : {}),
1988
136
  moreType: moreType ?? 'link',
1989
- showLength: resolvedShowLength,
137
+ ...(resolvedShowLength !== undefined ? {
138
+ showLength: resolvedShowLength
139
+ } : {}),
1990
140
  getPopupContainer: userGetPopupContainer ?? getPopupContainer
1991
141
  };
1992
142
  };
1993
143
  const resolveToolbarButtonGroupProps = (buttonGroup, getPopupContainer) => {
1994
144
  return resolveButtonGroupProps(buttonGroup, getPopupContainer, {
1995
145
  defaultSize: 'small',
1996
- defaultShowLength: 1,
146
+ // 未显式传 showLength 时走 ButtonGroup 自适应测宽(@kne/overflow-items)
147
+ defaultShowLength: undefined,
1997
148
  minShowLength: 1
1998
149
  });
1999
150
  };
@@ -2336,6 +487,131 @@ const TableToolbar = ({
2336
487
  });
2337
488
  };
2338
489
 
490
+ const parsePixelValue = value => {
491
+ const num = parseFloat(value);
492
+ return Number.isNaN(num) ? 0 : num;
493
+ };
494
+ const normalizeScrollTopInsetCSSValue = value => {
495
+ if (value == null) {
496
+ return undefined;
497
+ }
498
+ if (typeof value === 'number') {
499
+ return `${value}px`;
500
+ }
501
+ return String(value);
502
+ };
503
+ const resolveScrollTopInset = (scrollTopInset, stickyOffset) => scrollTopInset ?? stickyOffset;
504
+ const readScrollTopInsetPixels = element => {
505
+ const fromVar = readCssVariableLength(element, '--scroll-top-inset', '0px') || readCssVariableLength(element, '--sticky-offset', '0px') || readCssVariableLength(element, '--nav-height', '0px');
506
+ return fromVar;
507
+ };
508
+ const getTableElement = root => {
509
+ if (!root) {
510
+ return null;
511
+ }
512
+ return root.querySelector('.info-page-table') || root;
513
+ };
514
+ const getScrollAnchorElement = (root, {
515
+ preferToolbar = false
516
+ } = {}) => {
517
+ if (!root) {
518
+ return null;
519
+ }
520
+ if (preferToolbar) {
521
+ return root.querySelector('.table-page-toolbar-section') || root.querySelector('.table-with-toolbar') || getTableElement(root);
522
+ }
523
+ return getTableElement(root);
524
+ };
525
+ const readCssVariableLength = (element, variableName, fallback = '0px') => {
526
+ if (typeof document === 'undefined') {
527
+ return 0;
528
+ }
529
+ const host = element || document.documentElement;
530
+ const probe = document.createElement('div');
531
+ probe.style.cssText = 'position:absolute;visibility:hidden;pointer-events:none;height:0;width:0;overflow:hidden;';
532
+ probe.style.marginTop = `var(${variableName}, ${fallback})`;
533
+ host.appendChild(probe);
534
+ const value = parsePixelValue(getComputedStyle(probe).marginTop);
535
+ host.removeChild(probe);
536
+ return value;
537
+ };
538
+ const resolveScrollContainer = (element, getScrollContainer) => {
539
+ const explicitContainer = typeof getScrollContainer === 'function' ? getScrollContainer() : null;
540
+ if (explicitContainer) {
541
+ return explicitContainer;
542
+ }
543
+ let parent = element?.parentElement;
544
+ while (parent) {
545
+ const {
546
+ overflowY
547
+ } = getComputedStyle(parent);
548
+ if (/(auto|scroll|overlay)/.test(overflowY) && parent.scrollHeight > parent.clientHeight + 1) {
549
+ return parent;
550
+ }
551
+ parent = parent.parentElement;
552
+ }
553
+ return document.scrollingElement || document.documentElement;
554
+ };
555
+ const scrollToElement = (element, {
556
+ offsetTop = 0,
557
+ getScrollContainer
558
+ } = {}) => {
559
+ const scrollContainer = resolveScrollContainer(element, getScrollContainer);
560
+ const targetRect = element.getBoundingClientRect();
561
+ if (scrollContainer === document.scrollingElement || scrollContainer === document.documentElement || scrollContainer === document.body) {
562
+ const scrollTop = window.pageYOffset + targetRect.top - offsetTop;
563
+ window.scrollTo({
564
+ top: Math.max(0, scrollTop),
565
+ behavior: 'auto'
566
+ });
567
+ return;
568
+ }
569
+ const containerRect = scrollContainer.getBoundingClientRect();
570
+ const nextScrollTop = scrollContainer.scrollTop + targetRect.top - containerRect.top - offsetTop;
571
+ scrollContainer.scrollTo({
572
+ top: Math.max(0, nextScrollTop),
573
+ behavior: 'auto'
574
+ });
575
+ };
576
+ const scrollAnchorIntoView = (root, {
577
+ getScrollContainer,
578
+ preferToolbar = false
579
+ } = {}) => {
580
+ const target = getScrollAnchorElement(root, {
581
+ preferToolbar
582
+ });
583
+ if (!target) {
584
+ return;
585
+ }
586
+ const offsetTop = readScrollTopInsetPixels(target);
587
+ requestAnimationFrame(() => {
588
+ requestAnimationFrame(() => {
589
+ if (isTopEdgeInViewport(target, offsetTop, getScrollContainer)) {
590
+ return;
591
+ }
592
+ scrollToElement(target, {
593
+ offsetTop,
594
+ getScrollContainer
595
+ });
596
+ });
597
+ });
598
+ };
599
+ const isTopEdgeInViewport = (element, scrollMarginTop = 0, getScrollContainer) => {
600
+ if (!element) {
601
+ return true;
602
+ }
603
+ const rect = element.getBoundingClientRect();
604
+ const explicitContainer = typeof getScrollContainer === 'function' ? getScrollContainer() : null;
605
+ if (!StickyScroller.isDocumentScrollContainer(explicitContainer)) {
606
+ const containerRect = explicitContainer.getBoundingClientRect();
607
+ const viewportTop = containerRect.top + scrollMarginTop;
608
+ return rect.top >= viewportTop && rect.top < containerRect.bottom;
609
+ }
610
+ const viewport = StickyScroller.getViewportRect();
611
+ const viewportTop = viewport.top + scrollMarginTop;
612
+ return rect.top >= viewportTop && rect.top < viewport.bottom;
613
+ };
614
+
2339
615
  /**
2340
616
  * 与 @kne/react-filter useSearchParamsValue 内部解析保持一致(不从该包导出)。
2341
617
  *
@@ -2502,26 +778,23 @@ const isPaginationSearchParamsEnabled = pagination => {
2502
778
  return !!(pagination?.searchParams && typeof pagination.setSearchParams === 'function');
2503
779
  };
2504
780
 
2505
- 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", "filterSeedParams", "filterFetchApiRef"],
2506
- _excluded2 = ["loading"],
2507
- _excluded3 = ["pagination", "horizontalScroller", "getScrollContainer", "filter"],
2508
- _excluded4 = ["searchParamsValue"];
2509
781
  const noop = () => {};
2510
782
  const SKELETON_ROW_COUNT = 8;
2511
783
  const FALLBACK_SKELETON_COLUMNS = 5;
2512
784
 
2513
785
  /** 是否存在工具栏 / Filter 区域(首屏 loading 需占位保高) */
2514
786
  const hasToolbarArea = (_ref, isMobile) => {
2515
- var _filter$list;
2516
- let filter = _ref.filter,
2517
- search = _ref.search,
2518
- tab = _ref.tab,
2519
- batchActions = _ref.batchActions,
2520
- buttonGroup = _ref.buttonGroup,
2521
- renderCard = _ref.renderCard,
2522
- forceCard = _ref.forceCard;
2523
- const hasTab = !!(tab != null && tab.name && Array.isArray(tab.list) && tab.list.length > 0);
2524
- const hasFilter = !!((filter == null || (_filter$list = filter.list) == null ? void 0 : _filter$list.length) > 0);
787
+ let {
788
+ filter,
789
+ search,
790
+ tab,
791
+ batchActions,
792
+ buttonGroup,
793
+ renderCard,
794
+ forceCard
795
+ } = _ref;
796
+ const hasTab = !!(tab?.name && Array.isArray(tab.list) && tab.list.length > 0);
797
+ const hasFilter = !!(filter?.list?.length > 0);
2525
798
  const hasSearch = !!(search && search.name);
2526
799
  const hasBatch = Array.isArray(batchActions) && batchActions.length > 0;
2527
800
  const hasBtn = hasButtonGroupList(buttonGroup);
@@ -2533,7 +806,7 @@ const flattenLeafColumns = function (columns, output) {
2533
806
  output = [];
2534
807
  }
2535
808
  (columns || []).forEach(column => {
2536
- if (Array.isArray(column == null ? void 0 : column.children) && column.children.length > 0) {
809
+ if (Array.isArray(column?.children) && column.children.length > 0) {
2537
810
  flattenLeafColumns(column.children, output);
2538
811
  return;
2539
812
  }
@@ -2572,26 +845,23 @@ const buildSkeletonTableColumns = leafColumns => {
2572
845
  const source = leafColumns && leafColumns.length > 0 ? leafColumns : Array.from({
2573
846
  length: FALLBACK_SKELETON_COLUMNS
2574
847
  }, (_, index) => ({
2575
- name: "__skeleton_col_" + index,
848
+ name: `__skeleton_col_${index}`,
2576
849
  title: ' '
2577
850
  }));
2578
- return source.map((column, index) => {
2579
- var _column$title;
2580
- return {
2581
- name: column.name || column.key || "__skeleton_col_" + index,
2582
- title: typeof column.title === 'function' ? ' ' : (_column$title = column.title) != null ? _column$title : ' ',
2583
- width: column.width,
2584
- min: column.min,
2585
- max: column.max,
2586
- fixed: column.fixed,
2587
- justify: column.justify,
2588
- align: column.align,
2589
- span: column.span,
2590
- valueIsEmpty: () => false,
2591
- getValueOf: () => '__skeleton__',
2592
- render: () => /*#__PURE__*/jsxRuntime.jsx(CellSkeleton, {})
2593
- };
2594
- });
851
+ return source.map((column, index) => ({
852
+ name: column.name || column.key || `__skeleton_col_${index}`,
853
+ title: typeof column.title === 'function' ? ' ' : column.title ?? ' ',
854
+ width: column.width,
855
+ min: column.min,
856
+ max: column.max,
857
+ fixed: column.fixed,
858
+ justify: column.justify,
859
+ align: column.align,
860
+ span: column.span,
861
+ valueIsEmpty: () => false,
862
+ getValueOf: () => '__skeleton__',
863
+ render: () => /*#__PURE__*/jsxRuntime.jsx(CellSkeleton, {})
864
+ }));
2595
865
  };
2596
866
  const buildSkeletonDataSource = function (rowCount) {
2597
867
  if (rowCount === void 0) {
@@ -2600,7 +870,7 @@ const buildSkeletonDataSource = function (rowCount) {
2600
870
  return Array.from({
2601
871
  length: rowCount
2602
872
  }, (_, index) => ({
2603
- id: "__skeleton_row_" + index
873
+ id: `__skeleton_row_${index}`
2604
874
  }));
2605
875
  };
2606
876
 
@@ -2609,41 +879,38 @@ const buildSkeletonDataSource = function (rowCount) {
2609
879
  * 复用正式表格样式,避免全局绝对定位 Spin 把高度塌成 0。
2610
880
  */
2611
881
  const TablePageLoadingShell = withLocale(_ref2 => {
2612
- var _filter$list2;
2613
- let filter = _ref2.filter,
2614
- search = _ref2.search,
2615
- tab = _ref2.tab,
2616
- tabProps = _ref2.tabProps,
2617
- batchActions = _ref2.batchActions,
2618
- buttonGroup = _ref2.buttonGroup,
2619
- rowSelection = _ref2.rowSelection,
2620
- selectedRows = _ref2.selectedRows,
2621
- _ref2$renderMobile = _ref2.renderMobile,
2622
- renderMobile = _ref2$renderMobile === void 0 ? true : _ref2$renderMobile,
2623
- renderCard = _ref2.renderCard,
2624
- _ref2$forceCard = _ref2.forceCard,
2625
- forceCard = _ref2$forceCard === void 0 ? false : _ref2$forceCard,
2626
- columns = _ref2.columns,
2627
- getColumns = _ref2.getColumns,
2628
- _ref2$pagination = _ref2.pagination,
2629
- pagination = _ref2$pagination === void 0 ? {} : _ref2$pagination,
2630
- className = _ref2.className,
2631
- size = _ref2.size,
2632
- _ref2$renderType = _ref2.renderType,
2633
- renderType = _ref2$renderType === void 0 ? 'Table' : _ref2$renderType;
882
+ let {
883
+ filter,
884
+ search,
885
+ tab,
886
+ tabProps,
887
+ batchActions,
888
+ buttonGroup,
889
+ rowSelection,
890
+ selectedRows,
891
+ renderMobile = true,
892
+ renderCard,
893
+ forceCard = false,
894
+ columns,
895
+ getColumns,
896
+ pagination = {},
897
+ className,
898
+ size,
899
+ renderType = 'Table'
900
+ } = _ref2;
2634
901
  const isMobile = responsiveUtils.useIsMobile();
2635
902
  const isMobileRenderActive = tableView.isRenderMobileActive(renderMobile, isMobile);
2636
903
  const showButtonGroup = hasButtonGroupList(buttonGroup);
2637
904
  const resolvedRenderCard = resolveRenderCard(renderCard);
2638
905
  const showCardModeToggle = resolvedRenderCard != null && !isMobile && !forceCard;
2639
- const hasTab = !!(tab != null && tab.name && Array.isArray(tab.list) && tab.list.length > 0);
2640
- const hasInnerToolbar = !!(filter != null && (_filter$list2 = filter.list) != null && _filter$list2.length || search && search.name || batchActions && batchActions.length || showButtonGroup || showCardModeToggle);
906
+ const hasTab = !!(tab?.name && Array.isArray(tab.list) && tab.list.length > 0);
907
+ const hasInnerToolbar = !!(filter?.list?.length || search && search.name || batchActions && batchActions.length || showButtonGroup || showCardModeToggle);
2641
908
  const showOuterTab = hasTab && !isMobile;
2642
909
  const showInnerTab = hasTab && isMobile;
2643
910
  const wrapWithToolbar = hasInnerToolbar || showInnerTab;
2644
911
  const filterValue = resolveInitialFilterValue(filter);
2645
- const SkeletonTableComponent = TABLE_COMPONENTS[renderType] || Table;
2646
- const useAntdTable = SkeletonTableComponent === Table;
912
+ const SkeletonTableComponent = TABLE_COMPONENTS[renderType] || tableView.Table;
913
+ const useAntdTable = SkeletonTableComponent === tableView.Table;
2647
914
  const skeletonRowCount = Math.min(Math.max(Number(pagination.pageSize) || SKELETON_ROW_COUNT, 3), SKELETON_ROW_COUNT);
2648
915
  const skeletonColumns = react.useMemo(() => buildSkeletonTableColumns(resolveLoadingColumns(columns, getColumns)), [columns, getColumns]);
2649
916
  const skeletonDataSource = react.useMemo(() => buildSkeletonDataSource(skeletonRowCount), [skeletonRowCount]);
@@ -2677,23 +944,23 @@ const TablePageLoadingShell = withLocale(_ref2 => {
2677
944
 
2678
945
  // renderType=TableView 时骨架也用 TableView;桌面端 Table 可透传 loading,其余外层 Spin
2679
946
  const showOuterSpin = isMobileRenderActive || !useAntdTable;
2680
- const tableSkeleton = /*#__PURE__*/jsxRuntime.jsx(SkeletonTableComponent, _extends({
947
+ const tableSkeleton = /*#__PURE__*/jsxRuntime.jsx(SkeletonTableComponent, {
2681
948
  className: classnames__default["default"]({
2682
949
  [style$1['table-in-toolbar']]: wrapWithToolbar
2683
950
  }, className),
2684
951
  columns: skeletonColumns,
2685
952
  dataSource: skeletonDataSource,
2686
- rowSelection: skeletonRowSelection
2687
- }, useAntdTable ? {
2688
- loading: !showOuterSpin,
2689
- controllerOpen: false,
2690
- pagination: false
2691
- } : null, {
953
+ rowSelection: skeletonRowSelection,
954
+ ...(useAntdTable ? {
955
+ loading: !showOuterSpin,
956
+ controllerOpen: false,
957
+ pagination: false
958
+ } : null),
2692
959
  rowKey: "id",
2693
960
  size: size,
2694
961
  renderMobile: renderMobile,
2695
962
  empty: null
2696
- }), "skeleton-" + renderType);
963
+ }, `skeleton-${renderType}`);
2697
964
  const skeletonNode = showOuterSpin ? /*#__PURE__*/jsxRuntime.jsx(antd.Spin, {
2698
965
  spinning: true,
2699
966
  className: style$1['table-skeleton-spin'],
@@ -2736,7 +1003,7 @@ const TablePageLoadingShell = withLocale(_ref2 => {
2736
1003
  });
2737
1004
  const defaultMergeList = (data, newData) => {
2738
1005
  return Object.assign({}, newData, {
2739
- pageData: [...((data == null ? void 0 : data.pageData) || []), ...((newData == null ? void 0 : newData.pageData) || [])]
1006
+ pageData: [...(data?.pageData || []), ...(newData?.pageData || [])]
2740
1007
  });
2741
1008
  };
2742
1009
 
@@ -2758,14 +1025,14 @@ const readPageSize = key => {
2758
1025
  }
2759
1026
  const num = Number(value);
2760
1027
  return Number.isNaN(num) ? null : num;
2761
- } catch (_unused) {
1028
+ } catch {
2762
1029
  return null;
2763
1030
  }
2764
1031
  };
2765
1032
  const writePageSize = (key, size) => {
2766
1033
  try {
2767
1034
  localStorage.setItem(key, String(size));
2768
- } catch (_unused2) {
1035
+ } catch {
2769
1036
  // ignore quota errors
2770
1037
  }
2771
1038
  };
@@ -2776,9 +1043,8 @@ const resolveRenderCard = renderCard => {
2776
1043
  return renderCard;
2777
1044
  }
2778
1045
  if (typeof renderCard === 'string') {
2779
- var _globalParams$renderC;
2780
1046
  const name = renderCard.trim();
2781
- const renderFn = name ? (_globalParams$renderC = tableView.globalParams.renderCard) == null ? void 0 : _globalParams$renderC[name] : null;
1047
+ const renderFn = name ? tableView.globalParams.renderCard?.[name] : null;
2782
1048
  return typeof renderFn === 'function' ? renderFn : null;
2783
1049
  }
2784
1050
  return null;
@@ -2786,43 +1052,41 @@ const resolveRenderCard = renderCard => {
2786
1052
  const readCardMode = key => {
2787
1053
  try {
2788
1054
  return localStorage.getItem(key) === 'card';
2789
- } catch (_unused3) {
1055
+ } catch {
2790
1056
  return false;
2791
1057
  }
2792
1058
  };
2793
1059
  const writeCardMode = (key, isCard) => {
2794
1060
  try {
2795
1061
  localStorage.setItem(key, isCard ? 'card' : 'table');
2796
- } catch (_unused4) {
1062
+ } catch {
2797
1063
  // ignore quota errors
2798
1064
  }
2799
1065
  };
2800
1066
  const TABLE_COMPONENTS = {
2801
- Table,
2802
- TableView
1067
+ Table: tableView.Table,
1068
+ TableView: tableView.TableView
2803
1069
  };
2804
1070
  const collectFilterFieldNames = (filter, search, tab) => {
2805
1071
  const names = new Set();
2806
- if (search != null && search.name) {
1072
+ if (search?.name) {
2807
1073
  names.add(search.name);
2808
1074
  }
2809
- if (tab != null && tab.name) {
1075
+ if (tab?.name) {
2810
1076
  names.add(tab.name);
2811
1077
  }
2812
- if (Array.isArray(filter == null ? void 0 : filter.list)) {
1078
+ if (Array.isArray(filter?.list)) {
2813
1079
  filter.list.forEach(row => {
2814
1080
  // 兼容扁平 list:[{ type, props }];以及分组 list:[[item, item]]
2815
1081
  if (!Array.isArray(row)) {
2816
- var _row$props;
2817
- const name = row == null || (_row$props = row.props) == null ? void 0 : _row$props.name;
1082
+ const name = row?.props?.name;
2818
1083
  if (name) {
2819
1084
  names.add(name);
2820
1085
  }
2821
1086
  return;
2822
1087
  }
2823
1088
  row.forEach(item => {
2824
- var _item$props;
2825
- const name = item == null || (_item$props = item.props) == null ? void 0 : _item$props.name;
1089
+ const name = item?.props?.name;
2826
1090
  if (name) {
2827
1091
  names.add(name);
2828
1092
  }
@@ -2867,59 +1131,53 @@ const withNestedClears = (prevParams, nextParams) => {
2867
1131
  return result;
2868
1132
  };
2869
1133
  const TablePageInnerContent = withLocale(_ref3 => {
2870
- var _filter$list3;
2871
- let data = _ref3.data,
2872
- refresh = _ref3.refresh,
2873
- reload = _ref3.reload,
2874
- requestParams = _ref3.requestParams,
2875
- fetchProps = _ref3.fetchProps,
2876
- isComplete = _ref3.isComplete,
2877
- loadMore = _ref3.loadMore,
2878
- send = _ref3.send,
2879
- _ref3$dataFormat = _ref3.dataFormat,
2880
- dataFormat = _ref3$dataFormat === void 0 ? data => {
1134
+ let {
1135
+ data,
1136
+ refresh,
1137
+ reload,
1138
+ requestParams,
1139
+ fetchProps,
1140
+ isComplete,
1141
+ loadMore,
1142
+ send,
1143
+ dataFormat = data => {
2881
1144
  return {
2882
1145
  list: data.pageData,
2883
1146
  total: data.totalCount,
2884
1147
  data
2885
1148
  };
2886
- } : _ref3$dataFormat,
2887
- className = _ref3.className,
2888
- columns = _ref3.columns,
2889
- getColumns = _ref3.getColumns,
2890
- _ref3$pagination = _ref3.pagination,
2891
- pagination = _ref3$pagination === void 0 ? {} : _ref3$pagination,
2892
- _ref3$columnRenderPro = _ref3.columnRenderProps,
2893
- columnRenderProps = _ref3$columnRenderPro === void 0 ? {} : _ref3$columnRenderPro,
2894
- summary = _ref3.summary,
2895
- sticky = _ref3.sticky,
2896
- scrollTopInset = _ref3.scrollTopInset,
2897
- stickyOffset = _ref3.stickyOffset,
2898
- _ref3$renderType = _ref3.renderType,
2899
- renderType = _ref3$renderType === void 0 ? 'Table' : _ref3$renderType,
2900
- _ref3$horizontalScrol = _ref3.horizontalScroller,
2901
- horizontalScroller = _ref3$horizontalScrol === void 0 ? true : _ref3$horizontalScrol,
2902
- getScrollContainer = _ref3.getScrollContainer,
2903
- filter = _ref3.filter,
2904
- search = _ref3.search,
2905
- tab = _ref3.tab,
2906
- tabProps = _ref3.tabProps,
2907
- batchActions = _ref3.batchActions,
2908
- buttonGroup = _ref3.buttonGroup,
2909
- selectedRows = _ref3.selectedRows,
2910
- rowSelection = _ref3.rowSelection,
2911
- _ref3$renderMobile = _ref3.renderMobile,
2912
- renderMobile = _ref3$renderMobile === void 0 ? true : _ref3$renderMobile,
2913
- renderCard = _ref3.renderCard,
2914
- _ref3$forceCard = _ref3.forceCard,
2915
- forceCard = _ref3$forceCard === void 0 ? false : _ref3$forceCard,
2916
- mobileSortToolbar = _ref3.mobileSortToolbar,
2917
- _ref3$filterSeedParam = _ref3.filterSeedParams,
2918
- filterSeedParams = _ref3$filterSeedParam === void 0 ? {} : _ref3$filterSeedParam,
2919
- filterFetchApiRef = _ref3.filterFetchApiRef,
2920
- props = _objectWithoutPropertiesLoose(_ref3, _excluded);
2921
- const _useIntl = reactIntl.useIntl(),
2922
- formatMessage = _useIntl.formatMessage;
1149
+ },
1150
+ className,
1151
+ columns,
1152
+ getColumns,
1153
+ pagination = {},
1154
+ columnRenderProps = {},
1155
+ summary,
1156
+ sticky,
1157
+ scrollTopInset,
1158
+ stickyOffset,
1159
+ renderType = 'Table',
1160
+ horizontalScroller = true,
1161
+ getScrollContainer,
1162
+ filter,
1163
+ search,
1164
+ tab,
1165
+ tabProps,
1166
+ batchActions,
1167
+ buttonGroup,
1168
+ selectedRows,
1169
+ rowSelection,
1170
+ renderMobile = true,
1171
+ renderCard,
1172
+ forceCard = false,
1173
+ mobileSortToolbar,
1174
+ filterSeedParams = {},
1175
+ filterFetchApiRef,
1176
+ ...props
1177
+ } = _ref3;
1178
+ const {
1179
+ formatMessage
1180
+ } = reactIntl.useIntl();
2923
1181
  const isMobile = responsiveUtils.useIsMobile();
2924
1182
  const isMobileRenderActive = tableView.isRenderMobileActive(renderMobile, isMobile);
2925
1183
  const showButtonGroup = hasButtonGroupList(buttonGroup);
@@ -2927,21 +1185,17 @@ const TablePageInnerContent = withLocale(_ref3 => {
2927
1185
  const resolvedRenderCard = react.useMemo(() => resolveRenderCard(renderCard), [renderCard]);
2928
1186
  const renderCardEnabled = resolvedRenderCard != null && !isMobile;
2929
1187
  // 未传 name 时不持久化切换状态
2930
- const cardModeKey = props.name ? props.name.toUpperCase() + "_TABLE_PAGE_CARD_MODE" : null;
2931
- const _useState = react.useState(() => cardModeKey ? readCardMode(cardModeKey) : false),
2932
- cardMode = _useState[0],
2933
- setCardMode = _useState[1];
1188
+ const cardModeKey = props.name ? `${props.name.toUpperCase()}_TABLE_PAGE_CARD_MODE` : null;
1189
+ const [cardMode, setCardMode] = react.useState(() => cardModeKey ? readCardMode(cardModeKey) : false);
2934
1190
  const isCardModeActive = renderCardEnabled && (forceCard || cardMode);
2935
1191
  const showCardModeToggle = renderCardEnabled && !forceCard;
2936
1192
  const tableContentRef = react.useRef(null);
2937
1193
  const pendingScrollRef = react.useRef(false);
2938
1194
  const handlerDataFormat = useRefCallback__default["default"](dataFormat);
2939
- const _useControlValue = useControlValue__default["default"](Object.assign({
2940
- defaultValue: []
2941
- }, filter)),
2942
- filterValue = _useControlValue[0],
2943
- setFilterValue = _useControlValue[1];
2944
- const mapFilterValue = (filter == null ? void 0 : filter.mapFilterValue) || reactFilter.getFilterValue;
1195
+ const [filterValue, setFilterValue] = useControlValue__default["default"](Object.assign({
1196
+ defaultValue: []
1197
+ }, filter));
1198
+ const mapFilterValue = filter?.mapFilterValue || reactFilter.getFilterValue;
2945
1199
  const getFilterParams = useRefCallback__default["default"](value => {
2946
1200
  return mapFilterValue(value || []);
2947
1201
  });
@@ -3049,8 +1303,8 @@ const TablePageInnerContent = withLocale(_ref3 => {
3049
1303
  dataFormat,
3050
1304
  pagination
3051
1305
  }), [data, fetchProps, requestParams, refreshWithFilter, reloadWithFilter, loadMoreWithFilter, sendWithFilter, dataFormat, pagination]);
3052
- const hasTab = !!(tab != null && tab.name && Array.isArray(tab.list) && tab.list.length > 0);
3053
- const hasInnerToolbar = !!(filter != null && (_filter$list3 = filter.list) != null && _filter$list3.length || search && search.name || batchActions && batchActions.length || showButtonGroup || showCardModeToggle);
1306
+ const hasTab = !!(tab?.name && Array.isArray(tab.list) && tab.list.length > 0);
1307
+ const hasInnerToolbar = !!(filter?.list?.length || search && search.name || batchActions && batchActions.length || showButtonGroup || showCardModeToggle);
3054
1308
  const showOuterTab = hasTab && !isMobile;
3055
1309
  const showInnerTab = hasTab && isMobile;
3056
1310
  const wrapWithToolbar = hasInnerToolbar || showInnerTab;
@@ -3147,7 +1401,6 @@ const TablePageInnerContent = withLocale(_ref3 => {
3147
1401
  }
3148
1402
  });
3149
1403
  const paginationConfig = react.useMemo(() => {
3150
- var _mobilePagination$sho;
3151
1404
  if (useLoadMoreMode || !pagination.open || !(formatData.total > 0)) {
3152
1405
  return null;
3153
1406
  }
@@ -3161,11 +1414,11 @@ const TablePageInnerContent = withLocale(_ref3 => {
3161
1414
  id: 'ItemText'
3162
1415
  })]
3163
1416
  });
3164
- const baseConfig = _extends({
3165
- total: formatData.total
3166
- }, pagination.showTotal !== false ? {
3167
- showTotal: typeof pagination.showTotal === 'function' ? pagination.showTotal : defaultShowTotal
3168
- } : {}, {
1417
+ const baseConfig = {
1418
+ total: formatData.total,
1419
+ ...(pagination.showTotal !== false ? {
1420
+ showTotal: typeof pagination.showTotal === 'function' ? pagination.showTotal : defaultShowTotal
1421
+ } : {}),
3169
1422
  current: get__default["default"](requestParams, [pagination.paramsType, pagination.currentName], 1),
3170
1423
  pageSize: Number(get__default["default"](requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize || 20,
3171
1424
  onChange: handlePaginationChange,
@@ -3174,19 +1427,20 @@ const TablePageInnerContent = withLocale(_ref3 => {
3174
1427
  showSizeChanger: pagination.showSizeChanger,
3175
1428
  showQuickJumper: pagination.showQuickJumper,
3176
1429
  pageSizeOptions: pagination.pageSizeOptions
3177
- });
1430
+ };
3178
1431
  if (!isMobileRenderActive) {
3179
1432
  return baseConfig;
3180
1433
  }
3181
1434
  const mobilePagination = pagination.mobile || {};
3182
- return _extends({}, baseConfig, {
1435
+ return {
1436
+ ...baseConfig,
3183
1437
  onShowSizeChange: handlePaginationChange,
3184
1438
  size: mobilePagination.size,
3185
1439
  showSizeChanger: mobilePagination.showSizeChanger !== false && pagination.showSizeChanger !== false,
3186
1440
  showQuickJumper: mobilePagination.showQuickJumper === true,
3187
- showLessItems: (_mobilePagination$sho = mobilePagination.showLessItems) != null ? _mobilePagination$sho : true,
1441
+ showLessItems: mobilePagination.showLessItems ?? true,
3188
1442
  pageSizeOptions: pagination.pageSizeOptions || ['10', '20', '50', '100']
3189
- });
1443
+ };
3190
1444
  }, [pagination, formatData.total, requestParams, formatMessage, handlePaginationChange, isMobileRenderActive, useLoadMoreMode]);
3191
1445
  const batchContext = react.useMemo(() => ({
3192
1446
  data,
@@ -3199,11 +1453,12 @@ const TablePageInnerContent = withLocale(_ref3 => {
3199
1453
  dataFormat,
3200
1454
  pagination
3201
1455
  }), [data, fetchProps, requestParams, refreshWithFilter, reloadWithFilter, loadMoreWithFilter, sendWithFilter, dataFormat, pagination]);
3202
- const tableContext = _extends({}, columnRenderProps, {
1456
+ const tableContext = {
1457
+ ...columnRenderProps,
3203
1458
  requestParams,
3204
1459
  fetchProps,
3205
1460
  data
3206
- });
1461
+ };
3207
1462
 
3208
1463
  // 移动端卡片模式下批量操作渲染在「全选/排序」行的排序后面
3209
1464
  const showMobileBatchInCardToolbar = isMobileRenderActive && Array.isArray(batchActions) && batchActions.length > 0;
@@ -3215,7 +1470,8 @@ const TablePageInnerContent = withLocale(_ref3 => {
3215
1470
  batchContext: batchContext
3216
1471
  })]
3217
1472
  }) : mobileSortToolbar;
3218
- const tableProps = _extends({}, props, {
1473
+ const tableProps = {
1474
+ ...props,
3219
1475
  renderMobile,
3220
1476
  mobileSortToolbar: resolvedMobileSortToolbar,
3221
1477
  rowSelection,
@@ -3236,15 +1492,18 @@ const TablePageInnerContent = withLocale(_ref3 => {
3236
1492
  pageData
3237
1493
  }, ...[].slice.call(arguments, 1)));
3238
1494
  } : null
3239
- });
3240
- const TableComponent = TABLE_COMPONENTS[renderType] || Table;
1495
+ };
1496
+ const TableComponent = TABLE_COMPONENTS[renderType] || tableView.Table;
3241
1497
 
3242
1498
  // PC 卡片模式直接走 TableView 的卡片渲染(forceCardRender 在非移动端强制生效)
3243
- const tableElement = isCardModeActive ? /*#__PURE__*/jsxRuntime.jsx(TableView, _extends({}, tableProps, {
1499
+ const tableElement = isCardModeActive ? /*#__PURE__*/jsxRuntime.jsx(tableView.TableView, {
1500
+ ...tableProps,
3244
1501
  className: classnames__default["default"](tableProps.className, style$1['is-card-render']),
3245
1502
  renderMobile: resolvedRenderCard,
3246
1503
  forceCardRender: true
3247
- })) : /*#__PURE__*/jsxRuntime.jsx(TableComponent, _extends({}, tableProps));
1504
+ }) : /*#__PURE__*/jsxRuntime.jsx(TableComponent, {
1505
+ ...tableProps
1506
+ });
3248
1507
  const cardModeToggleNode = showCardModeToggle ? /*#__PURE__*/jsxRuntime.jsx(antd.Segmented, {
3249
1508
  className: style$1['card-mode-toggle'],
3250
1509
  size: "small",
@@ -3312,21 +1571,22 @@ const TablePageInnerContent = withLocale(_ref3 => {
3312
1571
  'is-loading': !isComplete
3313
1572
  }),
3314
1573
  style: scrollTopInsetStyle,
3315
- children: useLoadMoreMode ? /*#__PURE__*/jsxRuntime.jsx(ScrollLoader__default["default"], _extends({
1574
+ children: useLoadMoreMode ? /*#__PURE__*/jsxRuntime.jsx(ScrollLoader__default["default"], {
3316
1575
  className: style$1['mobile-load-more'],
3317
- completeTips: formatData.total > 0 ? undefined : null
3318
- }, pagination.loadMore || {}, {
1576
+ completeTips: formatData.total > 0 ? undefined : null,
1577
+ ...(pagination.loadMore || {}),
3319
1578
  useSimpleBar: false,
3320
1579
  isLoading: !isComplete,
3321
1580
  noMore: loadMoreNoMore,
3322
1581
  onLoader: handleLoadMore,
3323
1582
  children: tableMain
3324
- })) : /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
3325
- children: [tableMain, paginationConfig ? /*#__PURE__*/jsxRuntime.jsx(antd.Pagination, _extends({
1583
+ }) : /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
1584
+ children: [tableMain, paginationConfig ? /*#__PURE__*/jsxRuntime.jsx(antd.Pagination, {
3326
1585
  className: classnames__default["default"](style$1['pagination'], {
3327
1586
  [style$1['is-mobile-render']]: isMobileRenderActive
3328
- })
3329
- }, paginationConfig)) : null]
1587
+ }),
1588
+ ...paginationConfig
1589
+ }) : null]
3330
1590
  })
3331
1591
  });
3332
1592
  });
@@ -3335,59 +1595,54 @@ const TablePageFetched = reactFetch.withFetch(TablePageInnerContent);
3335
1595
  // 首包 / refresh loading:Toolbar 占位 + cell 骨架屏 + Spin;外层 grid 再垫一层,盖住首帧 null
3336
1596
  const TablePageInner = /*#__PURE__*/react.forwardRef((props, ref) => {
3337
1597
  const isMobile = responsiveUtils.useIsMobile();
3338
- const loadingProp = props.loading,
3339
- rest = _objectWithoutPropertiesLoose(props, _excluded2);
1598
+ const {
1599
+ loading: loadingProp,
1600
+ ...rest
1601
+ } = props;
3340
1602
  const fetchRef = react.useRef(null);
3341
1603
  const filterFetchApiRef = react.useRef(null);
3342
1604
  const reserveToolbar = hasToolbarArea(props, isMobile);
3343
- const loading = loadingProp !== undefined ? loadingProp : /*#__PURE__*/jsxRuntime.jsx(TablePageLoadingShell, _extends({}, props));
1605
+ const loading = loadingProp !== undefined ? loadingProp : /*#__PURE__*/jsxRuntime.jsx(TablePageLoadingShell, {
1606
+ ...props
1607
+ });
3344
1608
  react.useImperativeHandle(ref, () => ({
3345
1609
  get isLoading() {
3346
- var _fetchRef$current;
3347
- return (_fetchRef$current = fetchRef.current) == null ? void 0 : _fetchRef$current.isLoading;
1610
+ return fetchRef.current?.isLoading;
3348
1611
  },
3349
1612
  get isComplete() {
3350
- var _fetchRef$current2;
3351
- return (_fetchRef$current2 = fetchRef.current) == null ? void 0 : _fetchRef$current2.isComplete;
1613
+ return fetchRef.current?.isComplete;
3352
1614
  },
3353
1615
  get data() {
3354
- var _fetchRef$current3;
3355
- return (_fetchRef$current3 = fetchRef.current) == null ? void 0 : _fetchRef$current3.data;
1616
+ return fetchRef.current?.data;
3356
1617
  },
3357
1618
  get requestParams() {
3358
- var _fetchRef$current4;
3359
- return (_fetchRef$current4 = fetchRef.current) == null ? void 0 : _fetchRef$current4.requestParams;
1619
+ return fetchRef.current?.requestParams;
3360
1620
  },
3361
1621
  get error() {
3362
- var _fetchRef$current5;
3363
- return (_fetchRef$current5 = fetchRef.current) == null ? void 0 : _fetchRef$current5.error;
1622
+ return fetchRef.current?.error;
3364
1623
  },
3365
1624
  get setData() {
3366
- var _fetchRef$current6;
3367
- return (_fetchRef$current6 = fetchRef.current) == null ? void 0 : _fetchRef$current6.setData;
1625
+ return fetchRef.current?.setData;
3368
1626
  },
3369
1627
  send: function () {
3370
- var _ref4, _filterFetchApiRef$cu, _fetchRef$current7;
3371
- return (_ref4 = ((_filterFetchApiRef$cu = filterFetchApiRef.current) == null ? void 0 : _filterFetchApiRef$cu.send) || ((_fetchRef$current7 = fetchRef.current) == null ? void 0 : _fetchRef$current7.send)) == null ? void 0 : _ref4(...[].slice.call(arguments));
1628
+ return (filterFetchApiRef.current?.send || fetchRef.current?.send)?.(...[].slice.call(arguments));
3372
1629
  },
3373
1630
  refresh: function () {
3374
- var _ref5, _filterFetchApiRef$cu2, _fetchRef$current8;
3375
- return (_ref5 = ((_filterFetchApiRef$cu2 = filterFetchApiRef.current) == null ? void 0 : _filterFetchApiRef$cu2.refresh) || ((_fetchRef$current8 = fetchRef.current) == null ? void 0 : _fetchRef$current8.refresh)) == null ? void 0 : _ref5(...[].slice.call(arguments));
1631
+ return (filterFetchApiRef.current?.refresh || fetchRef.current?.refresh)?.(...[].slice.call(arguments));
3376
1632
  },
3377
1633
  reload: function () {
3378
- var _ref6, _filterFetchApiRef$cu3, _fetchRef$current9;
3379
- return (_ref6 = ((_filterFetchApiRef$cu3 = filterFetchApiRef.current) == null ? void 0 : _filterFetchApiRef$cu3.reload) || ((_fetchRef$current9 = fetchRef.current) == null ? void 0 : _fetchRef$current9.reload)) == null ? void 0 : _ref6(...[].slice.call(arguments));
1634
+ return (filterFetchApiRef.current?.reload || fetchRef.current?.reload)?.(...[].slice.call(arguments));
3380
1635
  },
3381
1636
  loadMore: function () {
3382
- var _ref7, _filterFetchApiRef$cu4, _fetchRef$current0;
3383
- return (_ref7 = ((_filterFetchApiRef$cu4 = filterFetchApiRef.current) == null ? void 0 : _filterFetchApiRef$cu4.loadMore) || ((_fetchRef$current0 = fetchRef.current) == null ? void 0 : _fetchRef$current0.loadMore)) == null ? void 0 : _ref7(...[].slice.call(arguments));
1637
+ return (filterFetchApiRef.current?.loadMore || fetchRef.current?.loadMore)?.(...[].slice.call(arguments));
3384
1638
  }
3385
1639
  }));
3386
- const fetched = /*#__PURE__*/jsxRuntime.jsx(TablePageFetched, _extends({}, rest, {
1640
+ const fetched = /*#__PURE__*/jsxRuntime.jsx(TablePageFetched, {
1641
+ ...rest,
3387
1642
  loading: loading,
3388
1643
  ref: fetchRef,
3389
1644
  filterFetchApiRef: filterFetchApiRef
3390
- }));
1645
+ });
3391
1646
  if (!reserveToolbar) {
3392
1647
  return fetched;
3393
1648
  }
@@ -3399,13 +1654,14 @@ const TablePageInner = /*#__PURE__*/react.forwardRef((props, ref) => {
3399
1654
  }), fetched]
3400
1655
  });
3401
1656
  });
3402
- const TablePage = /*#__PURE__*/react.forwardRef((_ref8, ref) => {
3403
- let pagination = _ref8.pagination,
3404
- _ref8$horizontalScrol = _ref8.horizontalScroller,
3405
- horizontalScroller = _ref8$horizontalScrol === void 0 ? true : _ref8$horizontalScrol,
3406
- getScrollContainer = _ref8.getScrollContainer,
3407
- filterProp = _ref8.filter,
3408
- props = _objectWithoutPropertiesLoose(_ref8, _excluded3);
1657
+ const TablePage = /*#__PURE__*/react.forwardRef((_ref4, ref) => {
1658
+ let {
1659
+ pagination,
1660
+ horizontalScroller = true,
1661
+ getScrollContainer,
1662
+ filter: filterProp,
1663
+ ...props
1664
+ } = _ref4;
3409
1665
  pagination = Object.assign({}, {
3410
1666
  showSizeChanger: true,
3411
1667
  showQuickJumper: true,
@@ -3417,37 +1673,34 @@ const TablePage = /*#__PURE__*/react.forwardRef((_ref8, ref) => {
3417
1673
  pageSizeName: 'perPage',
3418
1674
  pageSize: 20
3419
1675
  }, pagination);
3420
- const pageSizeKey = (props.name || 'common').toUpperCase() + "_TABLE_PAGE_SIZE";
1676
+ const pageSizeKey = `${(props.name || 'common').toUpperCase()}_TABLE_PAGE_SIZE`;
3421
1677
  const cachePageSize = pagination.cachePageSize !== false;
3422
1678
  const paginationUrlEnabled = isPaginationSearchParamsEnabled(pagination);
3423
- const _useState2 = react.useState(() => paginationUrlEnabled ? parsePaginationSearchParams(pagination.searchParams, {
3424
- currentName: pagination.currentName,
3425
- pageSizeName: pagination.pageSizeName
3426
- }) : {}),
3427
- urlPagination = _useState2[0];
3428
- const _useState3 = react.useState(() => {
3429
- var _ref9, _urlPagination$pageSi;
3430
- return (_ref9 = (_urlPagination$pageSi = urlPagination.pageSize) != null ? _urlPagination$pageSi : cachePageSize ? readPageSize(pageSizeKey) : null) != null ? _ref9 : pagination.pageSize;
3431
- }),
3432
- pageSize = _useState3[0],
3433
- setPageSize = _useState3[1];
3434
- const _useState4 = react.useState(() => {
3435
- if (urlPagination.current != null) {
3436
- return urlPagination.current;
3437
- }
3438
- const fromProps = Number(get__default["default"](props[pagination.paramsType], pagination.currentName));
3439
- return Number.isFinite(fromProps) && fromProps > 0 ? fromProps : 1;
3440
- }),
3441
- initialCurrent = _useState4[0];
3442
- const _useState5 = react.useState(() => parseSearchParamsValue(filterProp == null ? void 0 : filterProp.searchParamsValue)),
3443
- searchParamsSnapshot = _useState5[0];
3444
- const fromUrl = searchParamsSnapshot.items,
3445
- consumedKeys = searchParamsSnapshot.consumedKeys;
1679
+ const [urlPagination] = react.useState(() => paginationUrlEnabled ? parsePaginationSearchParams(pagination.searchParams, {
1680
+ currentName: pagination.currentName,
1681
+ pageSizeName: pagination.pageSizeName
1682
+ }) : {});
1683
+ const [pageSize, setPageSize] = react.useState(() => urlPagination.pageSize ?? (cachePageSize ? readPageSize(pageSizeKey) : null) ?? pagination.pageSize);
1684
+ const [initialCurrent] = react.useState(() => {
1685
+ if (urlPagination.current != null) {
1686
+ return urlPagination.current;
1687
+ }
1688
+ const fromProps = Number(get__default["default"](props[pagination.paramsType], pagination.currentName));
1689
+ return Number.isFinite(fromProps) && fromProps > 0 ? fromProps : 1;
1690
+ });
1691
+ const [searchParamsSnapshot] = react.useState(() => parseSearchParamsValue(filterProp?.searchParamsValue));
1692
+ const {
1693
+ items: fromUrl,
1694
+ consumedKeys
1695
+ } = searchParamsSnapshot;
3446
1696
  const filter = react.useMemo(() => {
3447
1697
  if (!filterProp) {
3448
1698
  return filterProp;
3449
1699
  }
3450
- const rest = _objectWithoutPropertiesLoose(filterProp, _excluded4);
1700
+ const {
1701
+ searchParamsValue: _searchParamsValue,
1702
+ ...rest
1703
+ } = filterProp;
3451
1704
  if ('value' in filterProp) {
3452
1705
  return rest;
3453
1706
  }
@@ -3457,27 +1710,25 @@ const TablePage = /*#__PURE__*/react.forwardRef((_ref8, ref) => {
3457
1710
  }, [filterProp, fromUrl]);
3458
1711
  const params = props[pagination.paramsType];
3459
1712
  // 仅作首包种子;后续筛选走 handleFilterChange → reload,避免受控 value 变化改 requestToken 触发 refresh 卸载表格
3460
- const _useState6 = react.useState(() => {
3461
- if (!filterProp) {
3462
- return {};
3463
- }
3464
- const mapFn = filterProp.mapFilterValue || reactFilter.getFilterValue;
3465
- const initialValue = 'value' in filterProp ? mergeFilterByName(filterProp.value || [], fromUrl) : mergeFilterByName(filterProp.defaultValue || [], fromUrl);
3466
- if (!initialValue.length && !filterProp.mapFilterValue) {
3467
- return {};
3468
- }
3469
- return mapFn(initialValue) || {};
3470
- }),
3471
- filterDefaultParams = _useState6[0];
1713
+ const [filterDefaultParams] = react.useState(() => {
1714
+ if (!filterProp) {
1715
+ return {};
1716
+ }
1717
+ const mapFn = filterProp.mapFilterValue || reactFilter.getFilterValue;
1718
+ const initialValue = 'value' in filterProp ? mergeFilterByName(filterProp.value || [], fromUrl) : mergeFilterByName(filterProp.defaultValue || [], fromUrl);
1719
+ if (!initialValue.length && !filterProp.mapFilterValue) {
1720
+ return {};
1721
+ }
1722
+ return mapFn(initialValue) || {};
1723
+ });
3472
1724
  const urlStrippedRef = react.useRef(false);
3473
1725
  react.useEffect(() => {
3474
- var _filterProp$searchPar, _filterProp$searchPar2;
3475
1726
  if (urlStrippedRef.current) {
3476
1727
  return;
3477
1728
  }
3478
1729
  urlStrippedRef.current = true;
3479
- const setSearchParams = filterProp == null || (_filterProp$searchPar = filterProp.searchParamsValue) == null ? void 0 : _filterProp$searchPar.setSearchParams;
3480
- const searchParams = filterProp == null || (_filterProp$searchPar2 = filterProp.searchParamsValue) == null ? void 0 : _filterProp$searchPar2.searchParams;
1730
+ const setSearchParams = filterProp?.searchParamsValue?.setSearchParams;
1731
+ const searchParams = filterProp?.searchParamsValue?.searchParams;
3481
1732
  if (typeof setSearchParams !== 'function') {
3482
1733
  return;
3483
1734
  }
@@ -3490,14 +1741,17 @@ const TablePage = /*#__PURE__*/react.forwardRef((_ref8, ref) => {
3490
1741
  }, [filterProp, consumedKeys]);
3491
1742
  const fetchParams = react.useMemo(() => {
3492
1743
  return {
3493
- [pagination.paramsType]: Object.assign({}, params, filterDefaultParams, _extends({}, paginationUrlEnabled ? {
3494
- [pagination.currentName]: initialCurrent
3495
- } : null, {
1744
+ [pagination.paramsType]: Object.assign({}, params, filterDefaultParams, {
1745
+ ...(paginationUrlEnabled ? {
1746
+ [pagination.currentName]: initialCurrent
1747
+ } : null),
3496
1748
  [pagination.pageSizeName]: pageSize
3497
- }))
1749
+ })
3498
1750
  };
3499
1751
  }, [params, pagination.pageSizeName, pagination.paramsType, pagination.currentName, pageSize, filterDefaultParams, paginationUrlEnabled, initialCurrent]);
3500
- return /*#__PURE__*/jsxRuntime.jsx(TablePageInner, _extends({}, props, fetchParams, {
1752
+ return /*#__PURE__*/jsxRuntime.jsx(TablePageInner, {
1753
+ ...props,
1754
+ ...fetchParams,
3501
1755
  filter: filter,
3502
1756
  filterSeedParams: filterDefaultParams,
3503
1757
  horizontalScroller: horizontalScroller,
@@ -3513,7 +1767,7 @@ const TablePage = /*#__PURE__*/react.forwardRef((_ref8, ref) => {
3513
1767
  }
3514
1768
  }),
3515
1769
  ref: ref
3516
- }));
1770
+ });
3517
1771
  });
3518
1772
 
3519
1773
  Object.defineProperty(exports, 'CHECK_RELATION', {
@@ -3528,6 +1782,14 @@ Object.defineProperty(exports, 'SIZE_NAMES', {
3528
1782
  enumerable: true,
3529
1783
  get: function () { return tableView.SIZE_NAMES; }
3530
1784
  });
1785
+ Object.defineProperty(exports, 'Table', {
1786
+ enumerable: true,
1787
+ get: function () { return tableView.Table; }
1788
+ });
1789
+ Object.defineProperty(exports, 'TableView', {
1790
+ enumerable: true,
1791
+ get: function () { return tableView__default["default"]; }
1792
+ });
3531
1793
  Object.defineProperty(exports, 'buildClearSelectAllKeys', {
3532
1794
  enumerable: true,
3533
1795
  get: function () { return tableView.buildClearSelectAllKeys; }
@@ -3724,6 +1986,10 @@ Object.defineProperty(exports, 'sortDataSource', {
3724
1986
  enumerable: true,
3725
1987
  get: function () { return tableView.sortDataSource; }
3726
1988
  });
1989
+ Object.defineProperty(exports, 'tableLocalApis', {
1990
+ enumerable: true,
1991
+ get: function () { return tableView.tableLocalApis; }
1992
+ });
3727
1993
  Object.defineProperty(exports, 'toggleExpandedKey', {
3728
1994
  enumerable: true,
3729
1995
  get: function () { return tableView.toggleExpandedKey; }
@@ -3740,13 +2006,13 @@ Object.defineProperty(exports, 'useSort', {
3740
2006
  enumerable: true,
3741
2007
  get: function () { return tableView.useSort; }
3742
2008
  });
2009
+ Object.defineProperty(exports, 'useTableConfig', {
2010
+ enumerable: true,
2011
+ get: function () { return tableView.useTableConfig; }
2012
+ });
3743
2013
  Object.defineProperty(exports, 'wrapColumnHeaderTitle', {
3744
2014
  enumerable: true,
3745
2015
  get: function () { return tableView.wrapColumnHeaderTitle; }
3746
2016
  });
3747
- exports.Table = Table;
3748
- exports.TableView = TableView;
3749
2017
  exports["default"] = TablePage;
3750
- exports.tableLocalApis = tableLocalApis;
3751
- exports.useTableConfig = useTableConfig;
3752
2018
  //# sourceMappingURL=index.js.map