@canvas-components/react-list-table 0.3.77 → 0.3.79
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 +77 -0
- package/dist/index.cjs +1041 -246
- package/dist/index.d.cts +15 -4
- package/dist/index.d.ts +15 -4
- package/dist/index.js +1042 -247
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -538,3 +538,80 @@ import {
|
|
|
538
538
|
禁用的原生按钮内容(`type: "button", disabled: true`)不会触发内容、单元格、行或列的点击回调,也不会改变活动单元格和鼠标选区;同一单元格内其他启用按钮仍可独立交互。
|
|
539
539
|
|
|
540
540
|
共享设置变更同步适用的已挂载表格及其他标签页;单表覆盖不受影响。取消缓存删除所选范围的记录,当前运行时配置保留;重新挂载时按单表、共享、外部输入回退。也可调用 `setPaginationConfig(value, { enabled: true, scope: "table" | "all" })` 保存配置。
|
|
541
|
+
|
|
542
|
+
### 重复项高亮与大数据示例
|
|
543
|
+
|
|
544
|
+
React 通过顶层 `duplicateHighlight` 传入表格级配置,`columnKeys` 对应列 key,多字段全部匹配才属于同一重复组。每组使用独立颜色,支持单元格和整行效果。
|
|
545
|
+
|
|
546
|
+
```tsx
|
|
547
|
+
<ReactListTable
|
|
548
|
+
columns={columns}
|
|
549
|
+
dataSource={records}
|
|
550
|
+
rowKey="id"
|
|
551
|
+
storageKey="inspection-records"
|
|
552
|
+
duplicateHighlight={{ columnKeys: ["name", "dept"], scope: "cell" }}
|
|
553
|
+
onDuplicateHighlightChange={(config) => console.log(config)}
|
|
554
|
+
/>
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
`onDuplicateHighlightChange` 仅通知有效配置变化,不要求业务回写。ref 提供 `getDuplicateHighlightConfig`、`setDuplicateHighlightConfig`、`clearDuplicateHighlight`。弹窗内可勾选“缓存配置到本地”,按 storageKey 独立恢复;也可在传入配置中使用 `cacheToLocal: true`。不缓存业务数据、组色或统计索引。
|
|
558
|
+
|
|
559
|
+
文档站 `/components/list-table/duplicate-highlight` 提供5万、10万、20万条记录示例,以左侧实际渲染、右侧源码展示。默认10万条、32个组合重复组,支持跨页统计、单元格/整行切换、右键配置与清除。大数据计算按批次让出主线程;远程模式仅统计已加载的主表记录。
|
|
560
|
+
|
|
561
|
+
右键相关功能在一级菜单中相邻平铺,不建立“功能”或“设置”分组;复制、导出、重复项等操作自身的子菜单保留。
|
|
562
|
+
|
|
563
|
+
### 点击选中高亮配置
|
|
564
|
+
|
|
565
|
+
右键“高亮配置”打开弹窗,可设置单元格、行、列、行+列四种模式,以及高亮背景色和文字颜色;确认前只改变预览。相关菜单入口仍平铺,可通过 `contextMenu` 的 `highlight` feature 控制。
|
|
566
|
+
|
|
567
|
+
```tsx
|
|
568
|
+
<ReactListTable
|
|
569
|
+
columns={columns}
|
|
570
|
+
dataSource={records}
|
|
571
|
+
storageKey="member-table"
|
|
572
|
+
highlight={{
|
|
573
|
+
mode: "cross", // cell / row / column / cross
|
|
574
|
+
backgroundColor: "#dbeafe",
|
|
575
|
+
textColor: "#1f2329",
|
|
576
|
+
cacheToLocal: true,
|
|
577
|
+
cacheScope: "table", // table / all
|
|
578
|
+
}}
|
|
579
|
+
onHighlightChange={(config) => console.log(config)}
|
|
580
|
+
/>
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
`highlight.mode` 优先于兼容属性 `highlightMode`。普通父组件重渲染不回滚当前会话右键修改,外部配置值实际改变时同步;ref 提供 `getHighlightConfig()`、`setHighlightConfig(value)`。
|
|
584
|
+
|
|
585
|
+
弹窗最前方可选择“缓存到本地”和缓存范围。优先级为当前表格缓存 > 表格传入配置 > 全局缓存 > 默认值;当前会话内已经手动修改的配置也会保留。没有自身配置的已挂载表格会随共享缓存更新;其他表格的独立配置不被全局设置覆盖。当前表格缓存需要 storageKey,所有表格缓存不需要。取消勾选后确定会删除所选范围的缓存,但保留当前会话设置。
|
|
586
|
+
|
|
587
|
+
### 组合公式
|
|
588
|
+
|
|
589
|
+
React 复用核心公式模型,辅助函数从核心包导入,无需额外插件或 DOM 公式库。
|
|
590
|
+
|
|
591
|
+
```tsx
|
|
592
|
+
import { useRef } from "react";
|
|
593
|
+
import type { ReactListTableRef } from "@canvas-components/react-list-table";
|
|
594
|
+
import { ReactListTable } from "@canvas-components/react-list-table";
|
|
595
|
+
import { listTableFormula as math } from "@canvas-components/list-table";
|
|
596
|
+
|
|
597
|
+
function FormulaTable() {
|
|
598
|
+
const ref = useRef<ReactListTableRef<{ id: number; radius: number }>>(null);
|
|
599
|
+
return <ReactListTable
|
|
600
|
+
ref={ref}
|
|
601
|
+
rowKey="id"
|
|
602
|
+
rowHeight="auto"
|
|
603
|
+
dataSource={[{ id: 1, radius: 3 }]}
|
|
604
|
+
columns={[{
|
|
605
|
+
key: "formula", dataIndex: "radius", title: "面积公式", width: 280,
|
|
606
|
+
render: (_value, record) => ({
|
|
607
|
+
type: "formula",
|
|
608
|
+
expression: math.row("A", "=", "π", "×", math.pow(record.radius, 2)),
|
|
609
|
+
fontSize: 20,
|
|
610
|
+
copyable: true,
|
|
611
|
+
}),
|
|
612
|
+
}]}
|
|
613
|
+
/>;
|
|
614
|
+
}
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
`frac/root/pow/sum/matrix/cases/aligned` 等积木支持递归组合;公式只展示,不自动求值。复杂内容用自动行高,固定行高可设置 `overflow: "shrink"`;大数据示例使用固定行高,避免初始测量全部记录。字体手动加载后可调用 `ref.current?.refreshFormulaLayout()`。静态表达式建议复用引用,动态更新创建新树。
|