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

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
@@ -4,6 +4,21 @@
4
4
 
5
5
  通过顶层 `loading` 属性控制数据加载状态:`<ReactListTable loading={loading} dataSource={rows} columns={columns} />`。加载期间展示加载提示并保留汇总标题;加载完成后,组件自动计算并统一展示完整汇总结果。服务端汇总可通过 `query.summaryValues` 提供,业务侧无需单独管理汇总计算状态。
6
6
 
7
+ ## 通过 ref 读取数据
8
+
9
+ ```tsx
10
+ const tableRef = useRef<ReactListTableRef<Row>>(null);
11
+
12
+ <ReactListTable ref={tableRef} columns={columns} dataSource={rows} />;
13
+
14
+ // 获取当前原始数据,包含表格内编辑后的记录。
15
+ const allRows = tableRef.current?.getDataSource() ?? [];
16
+ // 获取过滤后的完整结果,保留当前排序,不受分页、滚动窗口或分组折叠影响。
17
+ const filteredRows = tableRef.current?.getFilteredData() ?? [];
18
+ ```
19
+
20
+ 从 `react` 导入 `useRef`,从本包导入 `ReactListTable` 和 `ReactListTableRef`;`Row` 为业务行类型。两个方法均返回数组浅拷贝,行对象仍与表格共享,请勿直接修改记录。未建立原生实例时返回空数组。异步过滤或排序期间,`getFilteredData()` 返回最近已完成的异步查询结果;尚无此结果时回退当前原始数据。需读取新结果时,请等待 `onChange` 通知。远程查询模式只返回宿主当前传入的 `dataSource`,不会获取服务端全部记录。原生 `ListTable` 实例也提供同名方法。
21
+
7
22
  ## 自定义条件格式
8
23
 
9
24
  可在列配置的 `conditionalFormats` 中传入默认规则。规则按数组顺序匹配当前列的原始值,首条命中规则设置该单元格的背景色和文字颜色;例如:
package/dist/index.cjs CHANGED
@@ -6309,6 +6309,8 @@ function ReactListTableInner(props, ref) {
6309
6309
  react.useImperativeHandle(
6310
6310
  ref,
6311
6311
  () => ({
6312
+ getDataSource: () => tableRef.current?.getDataSource() ?? [],
6313
+ getFilteredData: () => tableRef.current?.getFilteredData() ?? [],
6312
6314
  validate: () => tableRef.current?.validate() ?? Promise.resolve([]),
6313
6315
  setValidationErrors: (errors) => {
6314
6316
  tableRef.current?.setValidationErrors(errors);
package/dist/index.d.cts CHANGED
@@ -60,6 +60,10 @@ interface ReactListTableToolbarOptions {
60
60
  * React 表格实例透出方法。
61
61
  */
62
62
  interface ReactListTableRef<RecordType = Record<string, unknown>> {
63
+ /** 获取当前原始数据的数组浅拷贝,包含实例内编辑后的记录。 */
64
+ getDataSource: () => RecordType[];
65
+ /** 获取过滤并排序后的完整数据浅拷贝;不受分页影响,查询期间返回已有异步结果或原始数据。 */
66
+ getFilteredData: () => RecordType[];
63
67
  validate: () => Promise<RecordType[]>;
64
68
  setValidationErrors: (errors: ListTableExternalValidationError[]) => void;
65
69
  clearValidationErrors: (targets?: ListTableValidationErrorTarget[]) => void;
package/dist/index.d.ts CHANGED
@@ -60,6 +60,10 @@ interface ReactListTableToolbarOptions {
60
60
  * React 表格实例透出方法。
61
61
  */
62
62
  interface ReactListTableRef<RecordType = Record<string, unknown>> {
63
+ /** 获取当前原始数据的数组浅拷贝,包含实例内编辑后的记录。 */
64
+ getDataSource: () => RecordType[];
65
+ /** 获取过滤并排序后的完整数据浅拷贝;不受分页影响,查询期间返回已有异步结果或原始数据。 */
66
+ getFilteredData: () => RecordType[];
63
67
  validate: () => Promise<RecordType[]>;
64
68
  setValidationErrors: (errors: ListTableExternalValidationError[]) => void;
65
69
  clearValidationErrors: (targets?: ListTableValidationErrorTarget[]) => void;
package/dist/index.js CHANGED
@@ -6308,6 +6308,8 @@ function ReactListTableInner(props, ref) {
6308
6308
  useImperativeHandle(
6309
6309
  ref,
6310
6310
  () => ({
6311
+ getDataSource: () => tableRef.current?.getDataSource() ?? [],
6312
+ getFilteredData: () => tableRef.current?.getFilteredData() ?? [],
6311
6313
  validate: () => tableRef.current?.validate() ?? Promise.resolve([]),
6312
6314
  setValidationErrors: (errors) => {
6313
6315
  tableRef.current?.setValidationErrors(errors);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canvas-components/react-list-table",
3
- "version": "0.3.63",
3
+ "version": "0.3.65",
4
4
  "description": "React adapter for the list table core engine.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -39,18 +39,19 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@canvas-components/chart": "0.3.9",
42
- "@canvas-components/list-table": "0.3.45",
43
- "@canvas-components/react-components": "0.3.27",
44
- "@canvas-components/print-design-plugin": "^0.1.9",
45
- "@canvas-components/react-print-design": "0.1.17"
42
+ "@canvas-components/list-table": "0.3.47",
43
+ "@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"
46
47
  },
47
48
  "devDependencies": {
48
- "@canvas-components/print": "0.1.1",
49
- "@canvas-components/print-design": "0.1.12"
49
+ "@canvas-components/print-design": "0.1.13",
50
+ "@canvas-components/print": "0.1.1"
50
51
  },
51
52
  "peerDependencies": {
52
53
  "@canvas-components/print": ">=0.1.0",
53
- "@canvas-components/print-design": ">=0.1.12",
54
+ "@canvas-components/print-design": ">=0.1.13",
54
55
  "react": ">=16.8.0",
55
56
  "react-dom": ">=16.8.0"
56
57
  },