@canvas-components/react-list-table 0.3.65 → 0.3.67

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/README.md CHANGED
@@ -65,9 +65,9 @@ const rows = [
65
65
  ## 属性更新与性能
66
66
 
67
67
  - 相同属性引用的父组件重渲染由 `React.memo` 跳过;组件内部交互仍正常更新。
68
- - `onChange`、`onRow` 以及查询、分页、行选择、展开、拖拽和性能通知等事件使用稳定入口,调用时读取最近一次已提交的回调,避免仅回调引用变化就重置底层查询。
68
+ - `onChange` 以及查询、分页、行选择、展开、拖拽和性能通知等事件使用稳定入口,调用时读取最近一次已提交的回调,避免仅回调引用变化就重置底层查询。
69
69
  - `scroll`、`theme`、`pagination` 等常用配置进行第一层字段比较,内容相同的新对象复用之前的配置。嵌套对象和数组仍按引用判断。
70
- - `columns`、`dataSource`、受控选中/展开数组,以及 `rowKey`、列渲染、`getCheckboxProps` 等影响数据或展示的函数,变化时继续刷新。大数据数组不做深比较,建议用 `useMemo` 或稳定状态保存,并在内容改变时更新引用。
70
+ - `columns`、`dataSource`、受控选中/展开数组,以及 `rowKey`、`onRow`、列渲染、`getCheckboxProps` 等影响数据或展示的函数,变化时继续刷新。大数据数组不做深比较,建议用 `useMemo` 或稳定状态保存,并在内容改变时更新引用。
71
71
 
72
72
  ## 示例效果
73
73
 
@@ -474,3 +474,5 @@ import {
474
474
  过滤面板勾选或取消过滤项并即时应用时,会立即清空全部已选行,不保留仍在过滤结果中的勾选。
475
475
 
476
476
  调用 `tableRef.current?.setSelectedRowKeys(["1", "2", "3"])` 可以主动设置勾选;单选模式只保留第一个 key。设置后触发 `onChange`,传入空数组等同清空。
477
+
478
+ `onRow(record, rowIndex)` 可返回 `style: { backgroundColor, color }` 实现受控业务高亮;建议用 `useCallback` 维护依赖,业务选中变化时会刷新 Canvas。列权限使用 `hidden: true`,用户默认隐藏使用 `initialHide: true`。
package/dist/index.cjs CHANGED
@@ -957,6 +957,7 @@ function ReactTableContextMenuView(props) {
957
957
  onOpenSettings: openScrollbarSettings
958
958
  }
959
959
  ),
960
+ /* @__PURE__ */ jsxRuntime.jsx(StickToBottomMenu, { request }),
960
961
  /* @__PURE__ */ jsxRuntime.jsx(
961
962
  MenuAction,
962
963
  {
@@ -1219,6 +1220,7 @@ function ReactTableContextMenuView(props) {
1219
1220
  ]
1220
1221
  }
1221
1222
  ),
1223
+ /* @__PURE__ */ jsxRuntime.jsx(StickToBottomMenu, { request }),
1222
1224
  /* @__PURE__ */ jsxRuntime.jsx(
1223
1225
  MenuAction,
1224
1226
  {
@@ -1566,6 +1568,74 @@ function CustomContextMenuItem(props) {
1566
1568
  }
1567
1569
  );
1568
1570
  }
1571
+ function StickToBottomMenu({ request }) {
1572
+ const [seconds, setSeconds] = react.useState(
1573
+ (request.stickToBottomResumeDelay ?? 3e3) / 1e3
1574
+ );
1575
+ if (!request.onToggleStickToBottom && !request.onChangeStickToBottomResumeDelay)
1576
+ return null;
1577
+ return /* @__PURE__ */ jsxRuntime.jsx(
1578
+ "div",
1579
+ {
1580
+ onMouseDownCapture: (event) => {
1581
+ if (event.target.closest("button"))
1582
+ event.preventDefault();
1583
+ },
1584
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1585
+ MenuSubmenu,
1586
+ {
1587
+ label: "\u5438\u5E95",
1588
+ items: [
1589
+ {
1590
+ key: "stick-enable",
1591
+ label: "\u5F00\u542F\u5438\u5E95",
1592
+ selected: request.stickToBottom ?? false,
1593
+ onClick: request.onToggleStickToBottom
1594
+ },
1595
+ ...[1, 3, 5, 10].map((delay, index) => ({
1596
+ key: `stick-delay-${delay}`,
1597
+ label: `\u505C\u6B62\u6EDA\u52A8 ${delay} \u79D2\u540E\u6062\u590D`,
1598
+ selected: (request.stickToBottomResumeDelay ?? 3e3) === delay * 1e3,
1599
+ separatorBefore: index === 0,
1600
+ onClick: request.onChangeStickToBottomResumeDelay ? () => request.onChangeStickToBottomResumeDelay?.(delay * 1e3) : void 0
1601
+ }))
1602
+ ],
1603
+ footer: request.onChangeStickToBottomResumeDelay ? /* @__PURE__ */ jsxRuntime.jsxs(
1604
+ "div",
1605
+ {
1606
+ style: {
1607
+ display: "flex",
1608
+ flexDirection: "column",
1609
+ gap: 6,
1610
+ padding: 8
1611
+ },
1612
+ onClick: (event) => event.stopPropagation(),
1613
+ children: [
1614
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\u81EA\u5B9A\u4E49\u6062\u590D\u7B49\u5F85\u65F6\u95F4" }),
1615
+ /* @__PURE__ */ jsxRuntime.jsx(
1616
+ reactComponents.ReactInputNumber,
1617
+ {
1618
+ "aria-label": "\u5438\u5E95\u6062\u590D\u7B49\u5F85\u79D2\u6570",
1619
+ value: seconds,
1620
+ min: 0,
1621
+ max: 600,
1622
+ step: 0.5,
1623
+ addonAfter: "\u79D2",
1624
+ onChange: (value) => setSeconds(value ?? 0),
1625
+ onCommit: (value) => {
1626
+ if (value != null && value * 1e3 !== (request.stickToBottomResumeDelay ?? 3e3))
1627
+ request.onChangeStickToBottomResumeDelay?.(value * 1e3);
1628
+ }
1629
+ }
1630
+ )
1631
+ ]
1632
+ }
1633
+ ) : void 0
1634
+ }
1635
+ )
1636
+ }
1637
+ );
1638
+ }
1569
1639
  function MenuSubmenu(props) {
1570
1640
  const { label, items, header, footer, children, minWidth = 220 } = props;
1571
1641
  const menuItems = items.filter((item) => item.onClick || item.disabled);
@@ -5609,7 +5679,7 @@ function ToolButton(props) {
5609
5679
  }
5610
5680
  function flattenColumns(columns, parentKey = "root", level = 0) {
5611
5681
  return columns.flatMap((column) => {
5612
- if (column.hideInSetting) {
5682
+ if (column.hideInSetting || listTable.isListTableColumnHiddenBySource(column)) {
5613
5683
  return [];
5614
5684
  }
5615
5685
  const key = String(column.key ?? column.dataIndex);
@@ -5784,6 +5854,7 @@ var CONFIG_KEYS = [
5784
5854
  "expandable",
5785
5855
  "pagination",
5786
5856
  "scrollbar",
5857
+ "stickToBottom",
5787
5858
  "carouselScroll",
5788
5859
  "cachePreferences",
5789
5860
  "rowDrag",
@@ -5818,7 +5889,7 @@ function useStableTableProps(props) {
5818
5889
  }
5819
5890
  return handler;
5820
5891
  };
5821
- for (const key of ["onChange", "onRow"]) {
5892
+ for (const key of ["onChange"]) {
5822
5893
  if (typeof props[key] === "function") next[key] = event(void 0, key);
5823
5894
  }
5824
5895
  for (const key of CONFIG_KEYS) {
@@ -5900,17 +5971,16 @@ function resolveFullscreenPortalContainer(host) {
5900
5971
  const fullscreenElement = document.fullscreenElement;
5901
5972
  return fullscreenElement instanceof HTMLElement && host && fullscreenElement.contains(host) ? fullscreenElement : document.body;
5902
5973
  }
5903
-
5904
- // src/components/column-manager-state.ts
5905
5974
  function applyColumnManagerState(columns, visibility, orders, config, parentKey = "root") {
5906
5975
  const order = orders.get(parentKey);
5907
5976
  const sortedColumns = order ? applyManagedColumnOrder(columns, order) : columns;
5908
5977
  return sortedColumns.map((column) => {
5978
+ column = listTable.withListTableColumnVisibility(column);
5909
5979
  const key = resolveColumnKey(column);
5910
5980
  const managedConfig = config.get(key);
5911
5981
  return {
5912
5982
  ...column,
5913
- hidden: visibility.has(key) ? visibility.get(key) === false : column.hidden ?? column.initialHide,
5983
+ hidden: listTable.isListTableColumnHiddenBySource(column) ? true : visibility.has(key) ? visibility.get(key) === false : column.hidden ?? column.initialHide,
5914
5984
  width: managedConfig?.width ?? column.width,
5915
5985
  minWidth: column.minWidth,
5916
5986
  maxWidth: column.maxWidth,
@@ -5944,7 +6014,7 @@ function normalizeUniqueColumnKeys(columns) {
5944
6014
  }
5945
6015
  usedKeys.add(key);
5946
6016
  return {
5947
- ...column,
6017
+ ...listTable.withListTableColumnVisibility(column),
5948
6018
  key,
5949
6019
  children: column.children ? visit(column.children) : void 0
5950
6020
  };
@@ -6043,6 +6113,7 @@ function ReactListTableInner(props, ref) {
6043
6113
  expandable,
6044
6114
  pagination,
6045
6115
  scrollbar,
6116
+ stickToBottom,
6046
6117
  carouselScroll,
6047
6118
  stretchColumns,
6048
6119
  resizable,
@@ -6119,10 +6190,7 @@ function ReactListTableInner(props, ref) {
6119
6190
  densityOverride,
6120
6191
  headerRowHeight
6121
6192
  );
6122
- const resolvedSummaryRowHeight = resolveDensityLinkedHeight(
6123
- densityOverride,
6124
- summaryRowHeight
6125
- );
6193
+ const resolvedSummaryRowHeight = summaryRowHeight == null || summaryRowHeight === 0 ? summaryRowHeight : resolveDensityLinkedHeight(densityOverride, summaryRowHeight);
6126
6194
  const queryRef = react.useRef(query);
6127
6195
  queryRef.current = retainEqualQueryOption(queryRef.current, query);
6128
6196
  const stableQuery = queryRef.current;
@@ -6159,6 +6227,7 @@ function ReactListTableInner(props, ref) {
6159
6227
  expandable,
6160
6228
  pagination,
6161
6229
  scrollbar: effectiveScrollbar,
6230
+ stickToBottom,
6162
6231
  carouselScroll,
6163
6232
  stretchColumns,
6164
6233
  resizable,
@@ -6243,6 +6312,7 @@ function ReactListTableInner(props, ref) {
6243
6312
  expandable,
6244
6313
  pagination,
6245
6314
  effectiveScrollbar,
6315
+ stickToBottom,
6246
6316
  carouselScroll,
6247
6317
  stretchColumns,
6248
6318
  resizable,
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createContext, memo, forwardRef, useMemo, useRef, useState, useEffect, useImperativeHandle, useLayoutEffect, useContext, useId, Fragment as Fragment$1 } from 'react';
2
2
  import { createPortal } from 'react-dom';
3
3
  import { getSharedScrollbarSettings, subscribeSharedScrollbarSettings, ReactTooltip, ReactImagePreview, ReactCheckbox, ReactSortableList, ReactInputNumber, ReactSelect, ReactPagination, ReactFilterPanel, ReactPopup, ReactModal, ReactInput, ReactPopconfirm, ReactContentScaleProvider, ReactScrollbarSettingsDialog, ReactScrollbarPositionDialog, setSharedScrollbarSettings, ReactButton, ReactColorPicker, resolveReactScrollbarMode, ReactAutoComplete, ReactTimeRangePicker, ReactDateTimeRangePicker, ReactDateTimePicker, ReactTimePicker, ReactDateRangePicker, ReactDatePicker, ReactMonthPicker, ReactQuarterPicker, ReactYearPicker, ReactInputRange, ReactCascader, ReactTreeSelect } from '@canvas-components/react-components';
4
- import { EXPAND_COLUMN, SELECTION_COLUMN, ROW_SELECTION_COLUMN, resetListTableStoredColumnConfig, ListTable, getListTableStoredColumnConfig, saveListTableStoredColumnConfig } from '@canvas-components/list-table';
4
+ import { EXPAND_COLUMN, SELECTION_COLUMN, ROW_SELECTION_COLUMN, resetListTableStoredColumnConfig, withListTableColumnVisibility, isListTableColumnHiddenBySource, ListTable, getListTableStoredColumnConfig, saveListTableStoredColumnConfig } from '@canvas-components/list-table';
5
5
  export { EXPAND_COLUMN, ROW_SELECTION_COLUMN, SELECTION_COLUMN, getListTableStoredPageSize } from '@canvas-components/list-table';
6
6
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
7
7
  import { CanvasChart } from '@canvas-components/chart';
@@ -956,6 +956,7 @@ function ReactTableContextMenuView(props) {
956
956
  onOpenSettings: openScrollbarSettings
957
957
  }
958
958
  ),
959
+ /* @__PURE__ */ jsx(StickToBottomMenu, { request }),
959
960
  /* @__PURE__ */ jsx(
960
961
  MenuAction,
961
962
  {
@@ -1218,6 +1219,7 @@ function ReactTableContextMenuView(props) {
1218
1219
  ]
1219
1220
  }
1220
1221
  ),
1222
+ /* @__PURE__ */ jsx(StickToBottomMenu, { request }),
1221
1223
  /* @__PURE__ */ jsx(
1222
1224
  MenuAction,
1223
1225
  {
@@ -1565,6 +1567,74 @@ function CustomContextMenuItem(props) {
1565
1567
  }
1566
1568
  );
1567
1569
  }
1570
+ function StickToBottomMenu({ request }) {
1571
+ const [seconds, setSeconds] = useState(
1572
+ (request.stickToBottomResumeDelay ?? 3e3) / 1e3
1573
+ );
1574
+ if (!request.onToggleStickToBottom && !request.onChangeStickToBottomResumeDelay)
1575
+ return null;
1576
+ return /* @__PURE__ */ jsx(
1577
+ "div",
1578
+ {
1579
+ onMouseDownCapture: (event) => {
1580
+ if (event.target.closest("button"))
1581
+ event.preventDefault();
1582
+ },
1583
+ children: /* @__PURE__ */ jsx(
1584
+ MenuSubmenu,
1585
+ {
1586
+ label: "\u5438\u5E95",
1587
+ items: [
1588
+ {
1589
+ key: "stick-enable",
1590
+ label: "\u5F00\u542F\u5438\u5E95",
1591
+ selected: request.stickToBottom ?? false,
1592
+ onClick: request.onToggleStickToBottom
1593
+ },
1594
+ ...[1, 3, 5, 10].map((delay, index) => ({
1595
+ key: `stick-delay-${delay}`,
1596
+ label: `\u505C\u6B62\u6EDA\u52A8 ${delay} \u79D2\u540E\u6062\u590D`,
1597
+ selected: (request.stickToBottomResumeDelay ?? 3e3) === delay * 1e3,
1598
+ separatorBefore: index === 0,
1599
+ onClick: request.onChangeStickToBottomResumeDelay ? () => request.onChangeStickToBottomResumeDelay?.(delay * 1e3) : void 0
1600
+ }))
1601
+ ],
1602
+ footer: request.onChangeStickToBottomResumeDelay ? /* @__PURE__ */ jsxs(
1603
+ "div",
1604
+ {
1605
+ style: {
1606
+ display: "flex",
1607
+ flexDirection: "column",
1608
+ gap: 6,
1609
+ padding: 8
1610
+ },
1611
+ onClick: (event) => event.stopPropagation(),
1612
+ children: [
1613
+ /* @__PURE__ */ jsx("span", { children: "\u81EA\u5B9A\u4E49\u6062\u590D\u7B49\u5F85\u65F6\u95F4" }),
1614
+ /* @__PURE__ */ jsx(
1615
+ ReactInputNumber,
1616
+ {
1617
+ "aria-label": "\u5438\u5E95\u6062\u590D\u7B49\u5F85\u79D2\u6570",
1618
+ value: seconds,
1619
+ min: 0,
1620
+ max: 600,
1621
+ step: 0.5,
1622
+ addonAfter: "\u79D2",
1623
+ onChange: (value) => setSeconds(value ?? 0),
1624
+ onCommit: (value) => {
1625
+ if (value != null && value * 1e3 !== (request.stickToBottomResumeDelay ?? 3e3))
1626
+ request.onChangeStickToBottomResumeDelay?.(value * 1e3);
1627
+ }
1628
+ }
1629
+ )
1630
+ ]
1631
+ }
1632
+ ) : void 0
1633
+ }
1634
+ )
1635
+ }
1636
+ );
1637
+ }
1568
1638
  function MenuSubmenu(props) {
1569
1639
  const { label, items, header, footer, children, minWidth = 220 } = props;
1570
1640
  const menuItems = items.filter((item) => item.onClick || item.disabled);
@@ -5608,7 +5678,7 @@ function ToolButton(props) {
5608
5678
  }
5609
5679
  function flattenColumns(columns, parentKey = "root", level = 0) {
5610
5680
  return columns.flatMap((column) => {
5611
- if (column.hideInSetting) {
5681
+ if (column.hideInSetting || isListTableColumnHiddenBySource(column)) {
5612
5682
  return [];
5613
5683
  }
5614
5684
  const key = String(column.key ?? column.dataIndex);
@@ -5783,6 +5853,7 @@ var CONFIG_KEYS = [
5783
5853
  "expandable",
5784
5854
  "pagination",
5785
5855
  "scrollbar",
5856
+ "stickToBottom",
5786
5857
  "carouselScroll",
5787
5858
  "cachePreferences",
5788
5859
  "rowDrag",
@@ -5817,7 +5888,7 @@ function useStableTableProps(props) {
5817
5888
  }
5818
5889
  return handler;
5819
5890
  };
5820
- for (const key of ["onChange", "onRow"]) {
5891
+ for (const key of ["onChange"]) {
5821
5892
  if (typeof props[key] === "function") next[key] = event(void 0, key);
5822
5893
  }
5823
5894
  for (const key of CONFIG_KEYS) {
@@ -5899,17 +5970,16 @@ function resolveFullscreenPortalContainer(host) {
5899
5970
  const fullscreenElement = document.fullscreenElement;
5900
5971
  return fullscreenElement instanceof HTMLElement && host && fullscreenElement.contains(host) ? fullscreenElement : document.body;
5901
5972
  }
5902
-
5903
- // src/components/column-manager-state.ts
5904
5973
  function applyColumnManagerState(columns, visibility, orders, config, parentKey = "root") {
5905
5974
  const order = orders.get(parentKey);
5906
5975
  const sortedColumns = order ? applyManagedColumnOrder(columns, order) : columns;
5907
5976
  return sortedColumns.map((column) => {
5977
+ column = withListTableColumnVisibility(column);
5908
5978
  const key = resolveColumnKey(column);
5909
5979
  const managedConfig = config.get(key);
5910
5980
  return {
5911
5981
  ...column,
5912
- hidden: visibility.has(key) ? visibility.get(key) === false : column.hidden ?? column.initialHide,
5982
+ hidden: isListTableColumnHiddenBySource(column) ? true : visibility.has(key) ? visibility.get(key) === false : column.hidden ?? column.initialHide,
5913
5983
  width: managedConfig?.width ?? column.width,
5914
5984
  minWidth: column.minWidth,
5915
5985
  maxWidth: column.maxWidth,
@@ -5943,7 +6013,7 @@ function normalizeUniqueColumnKeys(columns) {
5943
6013
  }
5944
6014
  usedKeys.add(key);
5945
6015
  return {
5946
- ...column,
6016
+ ...withListTableColumnVisibility(column),
5947
6017
  key,
5948
6018
  children: column.children ? visit(column.children) : void 0
5949
6019
  };
@@ -6042,6 +6112,7 @@ function ReactListTableInner(props, ref) {
6042
6112
  expandable,
6043
6113
  pagination,
6044
6114
  scrollbar,
6115
+ stickToBottom,
6045
6116
  carouselScroll,
6046
6117
  stretchColumns,
6047
6118
  resizable,
@@ -6118,10 +6189,7 @@ function ReactListTableInner(props, ref) {
6118
6189
  densityOverride,
6119
6190
  headerRowHeight
6120
6191
  );
6121
- const resolvedSummaryRowHeight = resolveDensityLinkedHeight(
6122
- densityOverride,
6123
- summaryRowHeight
6124
- );
6192
+ const resolvedSummaryRowHeight = summaryRowHeight == null || summaryRowHeight === 0 ? summaryRowHeight : resolveDensityLinkedHeight(densityOverride, summaryRowHeight);
6125
6193
  const queryRef = useRef(query);
6126
6194
  queryRef.current = retainEqualQueryOption(queryRef.current, query);
6127
6195
  const stableQuery = queryRef.current;
@@ -6158,6 +6226,7 @@ function ReactListTableInner(props, ref) {
6158
6226
  expandable,
6159
6227
  pagination,
6160
6228
  scrollbar: effectiveScrollbar,
6229
+ stickToBottom,
6161
6230
  carouselScroll,
6162
6231
  stretchColumns,
6163
6232
  resizable,
@@ -6242,6 +6311,7 @@ function ReactListTableInner(props, ref) {
6242
6311
  expandable,
6243
6312
  pagination,
6244
6313
  effectiveScrollbar,
6314
+ stickToBottom,
6245
6315
  carouselScroll,
6246
6316
  stretchColumns,
6247
6317
  resizable,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canvas-components/react-list-table",
3
- "version": "0.3.65",
3
+ "version": "0.3.67",
4
4
  "description": "React adapter for the list table core engine.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -39,15 +39,15 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@canvas-components/chart": "0.3.9",
42
- "@canvas-components/list-table": "0.3.47",
43
42
  "@canvas-components/react-components": "0.3.28",
44
- "@canvas-components/react-print-design": "0.1.18",
45
- "@canvas-components/print-design-plugin": "^0.1.11",
46
- "@canvas-components/utils": "0.2.9"
43
+ "@canvas-components/list-table": "0.3.49",
44
+ "@canvas-components/print-design-plugin": "^0.1.13",
45
+ "@canvas-components/utils": "0.2.9",
46
+ "@canvas-components/react-print-design": "0.1.18"
47
47
  },
48
48
  "devDependencies": {
49
- "@canvas-components/print-design": "0.1.13",
50
- "@canvas-components/print": "0.1.1"
49
+ "@canvas-components/print": "0.1.1",
50
+ "@canvas-components/print-design": "0.1.13"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@canvas-components/print": ">=0.1.0",