@mathwiz/ui-components 0.1.28 → 0.1.29
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/components/Button/Button.css +100 -32
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Button/types.d.ts +19 -0
- package/dist/components/Button/types.d.ts.map +1 -1
- package/dist/components/MathCardV2/modules/SolveModule/SolveModule.d.ts.map +1 -1
- package/dist/components/MathCardV2/scenes/ExplanationScene/ExplanationScene.d.ts.map +1 -1
- package/dist/components/MathCardV2/scenes/QuestionScene/QuestionScene.d.ts.map +1 -1
- package/dist/components/MathCardV2/scenes/SuccessScene/SuccessScene.d.ts.map +1 -1
- package/dist/components/StatBlock/StatBlock.css +331 -0
- package/dist/components/StatBlock/StatBlock.d.ts +7 -0
- package/dist/components/StatBlock/StatBlock.d.ts.map +1 -0
- package/dist/components/StatBlock/index.d.ts +5 -0
- package/dist/components/StatBlock/index.d.ts.map +1 -0
- package/dist/components/StatBlock/types.d.ts +116 -0
- package/dist/components/StatBlock/types.d.ts.map +1 -0
- package/dist/components/Table/Table.d.ts +14 -0
- package/dist/components/Table/Table.d.ts.map +1 -0
- package/dist/components/Table/hooks/useTableCore.d.ts +13 -0
- package/dist/components/Table/hooks/useTableCore.d.ts.map +1 -0
- package/dist/components/Table/hooks/useTableState.d.ts +10 -0
- package/dist/components/Table/hooks/useTableState.d.ts.map +1 -0
- package/dist/components/Table/index.d.ts +7 -0
- package/dist/components/Table/index.d.ts.map +1 -0
- package/dist/components/Table/types.d.ts +179 -0
- package/dist/components/Table/types.d.ts.map +1 -0
- package/dist/components/Table/utils/flattenData.d.ts +15 -0
- package/dist/components/Table/utils/flattenData.d.ts.map +1 -0
- package/dist/components/Table/utils/mergeClass.d.ts +6 -0
- package/dist/components/Table/utils/mergeClass.d.ts.map +1 -0
- package/dist/data/GeometryProblemAdapterV4/jsondata/right-triangle-v4.json +595 -0
- package/dist/data/GeometryProblemAdapterV4/jsondata/triangle-v4-final.json +2 -2
- package/dist/data/TriangleAdapterV3/resolvers/transformRefResolver.d.ts +4 -0
- package/dist/data/TriangleAdapterV3/resolvers/transformRefResolver.d.ts.map +1 -1
- package/dist/data/TriangleAdapterV3/transformers/geometryTransformTransformer.d.ts.map +1 -1
- package/dist/index.cjs +13 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +309 -237
- package/dist/index.mjs.map +1 -1
- package/dist/mathwiz-ui.css +1 -1
- package/dist/pages/GradeUnitBrowserPage/GradeUnitBrowserPage.d.ts.map +1 -1
- package/dist/pages/MathSessionPage/MathSessionPage.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/dist/styles/index.css +34 -0
- package/package.json +5 -3
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { StatBlock } from './StatBlock';
|
|
2
|
+
export type { StatBlockProps, RenderProps, TimeValue } from './types';
|
|
3
|
+
export { IconPosition, ContentType, StatBlockDefaults } from './types';
|
|
4
|
+
export type { IconPositionType, ContentTypeType } from './types';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/StatBlock/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACvE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { ReactNode, CSSProperties } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* 图标位置常量定义
|
|
4
|
+
* 符合 erasableSyntaxOnly 约束,不使用 enum
|
|
5
|
+
*/
|
|
6
|
+
export declare const IconPosition: {
|
|
7
|
+
readonly LEFT: "left";
|
|
8
|
+
readonly RIGHT: "right";
|
|
9
|
+
readonly TOP: "top";
|
|
10
|
+
readonly BOTTOM: "bottom";
|
|
11
|
+
};
|
|
12
|
+
export type IconPositionType = typeof IconPosition[keyof typeof IconPosition];
|
|
13
|
+
/**
|
|
14
|
+
* 内容类型常量定义
|
|
15
|
+
* 支持不同的内容展示模式
|
|
16
|
+
*/
|
|
17
|
+
export declare const ContentType: {
|
|
18
|
+
readonly NUMBER: "number";
|
|
19
|
+
readonly TIME: "time";
|
|
20
|
+
readonly CUSTOM: "custom";
|
|
21
|
+
};
|
|
22
|
+
export type ContentTypeType = typeof ContentType[keyof typeof ContentType];
|
|
23
|
+
/**
|
|
24
|
+
* 时间值对象接口
|
|
25
|
+
* 用于时间显示模式
|
|
26
|
+
*/
|
|
27
|
+
export interface TimeValue {
|
|
28
|
+
hours: number;
|
|
29
|
+
minutes: number;
|
|
30
|
+
seconds: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 渲染函数接收的参数接口
|
|
34
|
+
*/
|
|
35
|
+
export interface RenderProps {
|
|
36
|
+
/** 组件标签 */
|
|
37
|
+
label: ReactNode;
|
|
38
|
+
/** 主数值 */
|
|
39
|
+
value: ReactNode;
|
|
40
|
+
/** 单位 */
|
|
41
|
+
unit?: ReactNode;
|
|
42
|
+
/** 图标 */
|
|
43
|
+
icon?: ReactNode;
|
|
44
|
+
/** 图标位置 */
|
|
45
|
+
iconPosition: IconPositionType;
|
|
46
|
+
/** 背景颜色 */
|
|
47
|
+
color?: string;
|
|
48
|
+
/** 是否可交互 */
|
|
49
|
+
interactive: boolean;
|
|
50
|
+
/** 自定义类名 */
|
|
51
|
+
className?: string;
|
|
52
|
+
/** 自定义样式 */
|
|
53
|
+
style?: CSSProperties;
|
|
54
|
+
/** 副标题(可选) */
|
|
55
|
+
subtitle?: ReactNode;
|
|
56
|
+
/** 是否显示帮助图标 */
|
|
57
|
+
showHelpIcon?: boolean;
|
|
58
|
+
/** 内容类型 */
|
|
59
|
+
contentType?: ContentTypeType;
|
|
60
|
+
/** 时间值(当contentType为'time'时使用) */
|
|
61
|
+
timeValue?: TimeValue;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* StatBlock 组件属性接口
|
|
65
|
+
*/
|
|
66
|
+
export interface StatBlockProps {
|
|
67
|
+
/** 标签/标题文本 */
|
|
68
|
+
label: ReactNode;
|
|
69
|
+
/** 主数值内容 */
|
|
70
|
+
value: ReactNode;
|
|
71
|
+
/** 单位文本(可选) */
|
|
72
|
+
unit?: ReactNode;
|
|
73
|
+
/** 背景颜色(支持CSS颜色值、Tailwind类名) */
|
|
74
|
+
color?: string;
|
|
75
|
+
/** 图标组件(React节点) */
|
|
76
|
+
icon?: ReactNode;
|
|
77
|
+
/** 图标位置(默认左侧) */
|
|
78
|
+
iconPosition?: IconPositionType;
|
|
79
|
+
/** 自定义渲染函数,传入渲染参数返回自定义UI */
|
|
80
|
+
render?: (props: RenderProps) => ReactNode;
|
|
81
|
+
/** 点击事件处理器 */
|
|
82
|
+
onClick?: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
83
|
+
/** 自定义CSS类名 */
|
|
84
|
+
className?: string;
|
|
85
|
+
/** 自定义内联样式 */
|
|
86
|
+
style?: CSSProperties;
|
|
87
|
+
/** 是否启用点击交互(显示为可点击样式) */
|
|
88
|
+
interactive?: boolean;
|
|
89
|
+
/** ARIA标签(无障碍访问) */
|
|
90
|
+
'aria-label'?: string;
|
|
91
|
+
/** ARIA角色 */
|
|
92
|
+
'aria-role'?: string;
|
|
93
|
+
/** 测试标识符 */
|
|
94
|
+
'data-testid'?: string;
|
|
95
|
+
/** 副标题(可选) */
|
|
96
|
+
subtitle?: ReactNode;
|
|
97
|
+
/** 是否显示帮助图标 */
|
|
98
|
+
showHelpIcon?: boolean;
|
|
99
|
+
/** 帮助图标提示文本 */
|
|
100
|
+
helpIconTitle?: string;
|
|
101
|
+
/** 内容类型 */
|
|
102
|
+
contentType?: ContentTypeType;
|
|
103
|
+
/** 时间值(当contentType为'time'时使用) */
|
|
104
|
+
timeValue?: TimeValue;
|
|
105
|
+
/** 主题色CSS变量名(如:--mathwiz-statblock-theme-blue) */
|
|
106
|
+
themeColorVar?: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 组件默认配置
|
|
110
|
+
*/
|
|
111
|
+
export declare const StatBlockDefaults: {
|
|
112
|
+
readonly iconPosition: "left";
|
|
113
|
+
readonly interactive: false;
|
|
114
|
+
readonly contentType: "number";
|
|
115
|
+
};
|
|
116
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/StatBlock/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;CAKf,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,OAAO,YAAY,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE9E;;;GAGG;AACH,eAAO,MAAM,WAAW;;;;CAId,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,OAAO,WAAW,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAE3E;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,WAAW;IACX,KAAK,EAAE,SAAS,CAAC;IACjB,UAAU;IACV,KAAK,EAAE,SAAS,CAAC;IACjB,SAAS;IACT,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,SAAS;IACT,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,WAAW;IACX,YAAY,EAAE,gBAAgB,CAAC;IA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ACrB,eAAe;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW;IACX,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,kCAAkC;IAClC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,kDAAkD;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;CAIpB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { TableProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Table 主组件
|
|
5
|
+
* 采用"数据遍历 + 渲染委托"模式
|
|
6
|
+
*
|
|
7
|
+
* @template T - 行数据类型
|
|
8
|
+
* @param props - TableProps<T>
|
|
9
|
+
* @returns React.ReactElement
|
|
10
|
+
*/
|
|
11
|
+
export declare function Table<T>({ data, renderGroupHeader, renderCategoryHeader, renderRow, renderCell, onCellClick, onRowClick, columns, enableTanStack, className, getRowKey, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, }: TableProps<T>): React.ReactElement;
|
|
12
|
+
declare const _default: typeof Table;
|
|
13
|
+
export default _default;
|
|
14
|
+
//# sourceMappingURL=Table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../src/components/Table/Table.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqC,MAAM,OAAO,CAAC;AAC1D,OAAO,KAAK,EACV,UAAU,EAIX,MAAM,SAAS,CAAC;AAGjB;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,EACvB,IAAI,EACJ,iBAAiB,EACjB,oBAAoB,EACpB,SAAS,EACT,UAAU,EACV,WAAW,EACX,UAAU,EACV,OAAO,EACP,cAAsB,EACtB,SAAS,EACT,SAAS,EACT,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,GAClC,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,YAAY,CAgJpC;wBAG6B,OAAO,KAAK;AAA1C,wBAA2C"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ColumnDef } from '../types';
|
|
2
|
+
interface UseTableCoreOptions<T> {
|
|
3
|
+
data: T[];
|
|
4
|
+
columns?: ColumnDef<T>[];
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* TanStack Table 核心集成 Hook
|
|
9
|
+
* 提供排序、分页、过滤等数据处理能力
|
|
10
|
+
*/
|
|
11
|
+
export declare function useTableCore<T>({ data, columns, enabled }: UseTableCoreOptions<T>): import("@tanstack/table-core").Table<T> | null;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=useTableCore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTableCore.d.ts","sourceRoot":"","sources":["../../../../src/components/Table/hooks/useTableCore.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,UAAU,mBAAmB,CAAC,CAAC;IAC7B,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAe,EAAE,EAAE,mBAAmB,CAAC,CAAC,CAAC,kDAezF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TableState, TableStateActions, TableGroup } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* 表格状态管理 Hook
|
|
4
|
+
* 管理分组/分类的展开收起状态
|
|
5
|
+
*/
|
|
6
|
+
export declare function useTableState<T>(data: TableGroup<T>[]): {
|
|
7
|
+
state: TableState;
|
|
8
|
+
actions: TableStateActions;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=useTableState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTableState.d.ts","sourceRoot":"","sources":["../../../../src/components/Table/hooks/useTableState.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE1E;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE;;;EAkGrD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { Table } from './Table';
|
|
2
|
+
export { useTableState } from './hooks/useTableState';
|
|
3
|
+
export { useTableCore } from './hooks/useTableCore';
|
|
4
|
+
export { flattenData, getTotalRowCount, findGroupByCategory } from './utils/flattenData';
|
|
5
|
+
export { mergeClass } from './utils/mergeClass';
|
|
6
|
+
export type { TableProps, TableGroup, TableCategory, RowContext, TableState, TableStateActions, ColumnDef, RowKeyGenerator, HeaderRenderContext, TableGroupHeaderProps, TableCategoryHeaderProps, } from './types';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Table/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,YAAY,EACV,UAAU,EACV,UAAU,EACV,aAAa,EACb,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,SAAS,EACT,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ColumnDef as TanStackColumnDef } from '@tanstack/react-table';
|
|
3
|
+
/**
|
|
4
|
+
* 表格分组数据结构
|
|
5
|
+
* 对应 PRD 中的 Group 层级
|
|
6
|
+
*/
|
|
7
|
+
export interface TableGroup<T> {
|
|
8
|
+
/** 分组唯一标识 */
|
|
9
|
+
id: string;
|
|
10
|
+
/** 分组标题 */
|
|
11
|
+
title: string;
|
|
12
|
+
/** 子分类列表 */
|
|
13
|
+
categories: TableCategory<T>[];
|
|
14
|
+
/** 分组级元数据(可选) */
|
|
15
|
+
meta?: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 表格子分类数据结构
|
|
19
|
+
* 对应 PRD 中的 Category 层级
|
|
20
|
+
*/
|
|
21
|
+
export interface TableCategory<T> {
|
|
22
|
+
/** 分类唯一标识 */
|
|
23
|
+
id: string;
|
|
24
|
+
/** 分类标题 */
|
|
25
|
+
title: string;
|
|
26
|
+
/** 行数据列表 */
|
|
27
|
+
items: T[];
|
|
28
|
+
/** 分类级元数据(可选) */
|
|
29
|
+
meta?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 表格列定义
|
|
33
|
+
* 继承 TanStack Table 的 ColumnDef
|
|
34
|
+
*/
|
|
35
|
+
export type ColumnDef<T> = TanStackColumnDef<T, unknown>;
|
|
36
|
+
/**
|
|
37
|
+
* 表格行标识符生成函数
|
|
38
|
+
*/
|
|
39
|
+
export type RowKeyGenerator<T> = (row: T, index: number) => string;
|
|
40
|
+
/**
|
|
41
|
+
* 行上下文信息
|
|
42
|
+
*/
|
|
43
|
+
export interface RowContext<T> {
|
|
44
|
+
/** 行索引(在当前 Category 内) */
|
|
45
|
+
index: number;
|
|
46
|
+
/** 所属 Category */
|
|
47
|
+
category: TableCategory<T>;
|
|
48
|
+
/** 所属 Group */
|
|
49
|
+
group: TableGroup<T>;
|
|
50
|
+
/** 是否为 Category 内第一行 */
|
|
51
|
+
isFirst: boolean;
|
|
52
|
+
/** 是否为 Category 内最后一行 */
|
|
53
|
+
isLast: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Header 渲染函数上下文
|
|
57
|
+
*/
|
|
58
|
+
export interface HeaderRenderContext {
|
|
59
|
+
/** 是否展开 */
|
|
60
|
+
isExpanded: boolean;
|
|
61
|
+
/** 切换展开状态的回调 */
|
|
62
|
+
onToggle: () => void;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Table 组件 Props 接口
|
|
66
|
+
* @template T - 行数据类型
|
|
67
|
+
*/
|
|
68
|
+
export interface TableProps<T> {
|
|
69
|
+
/** 表格数据:Group → Category → Row 三层结构 */
|
|
70
|
+
data: TableGroup<T>[];
|
|
71
|
+
/**
|
|
72
|
+
* 自定义 Group Header 渲染
|
|
73
|
+
* @param group - 分组数据
|
|
74
|
+
* @param context - 展开状态和切换回调
|
|
75
|
+
* @returns React 节点
|
|
76
|
+
*/
|
|
77
|
+
renderGroupHeader?: (group: TableGroup<T>, context: HeaderRenderContext) => ReactNode;
|
|
78
|
+
/**
|
|
79
|
+
* 自定义 Category Header 渲染
|
|
80
|
+
* @param category - 分类数据
|
|
81
|
+
* @param context - 展开状态和切换回调
|
|
82
|
+
* @returns React 节点
|
|
83
|
+
*/
|
|
84
|
+
renderCategoryHeader?: (category: TableCategory<T>, context: HeaderRenderContext) => ReactNode;
|
|
85
|
+
/**
|
|
86
|
+
* 自定义行渲染
|
|
87
|
+
* @param row - 行数据
|
|
88
|
+
* @param context - 行上下文信息
|
|
89
|
+
* @returns React 节点(通常是多个 <td> 元素)
|
|
90
|
+
*/
|
|
91
|
+
renderRow?: (row: T, context: RowContext<T>) => ReactNode;
|
|
92
|
+
/**
|
|
93
|
+
* 自定义单元格渲染
|
|
94
|
+
* @param value - 单元格值
|
|
95
|
+
* @param row - 行数据
|
|
96
|
+
* @param column - 列定义
|
|
97
|
+
* @returns React 节点
|
|
98
|
+
*/
|
|
99
|
+
renderCell?: (value: unknown, row: T, column: ColumnDef<T>) => ReactNode;
|
|
100
|
+
/**
|
|
101
|
+
* 单元格点击事件
|
|
102
|
+
* @param row - 行数据
|
|
103
|
+
* @param columnKey - 列标识
|
|
104
|
+
*/
|
|
105
|
+
onCellClick?: (row: T, columnKey: string) => void;
|
|
106
|
+
/**
|
|
107
|
+
* 行点击事件
|
|
108
|
+
* @param row - 行数据
|
|
109
|
+
*/
|
|
110
|
+
onRowClick?: (row: T) => void;
|
|
111
|
+
/**
|
|
112
|
+
* 列定义(用于 TanStack Table 集成)
|
|
113
|
+
* 当提供 columns 时,可使用 TanStack Table 的排序/分页/过滤功能
|
|
114
|
+
*/
|
|
115
|
+
columns?: ColumnDef<T>[];
|
|
116
|
+
/**
|
|
117
|
+
* 是否启用 TanStack Table 的数据处理
|
|
118
|
+
* @default false
|
|
119
|
+
*/
|
|
120
|
+
enableTanStack?: boolean;
|
|
121
|
+
/** 根容器类名 */
|
|
122
|
+
className?: string;
|
|
123
|
+
/**
|
|
124
|
+
* 行 Key 生成函数
|
|
125
|
+
* 用于优化 React diff 性能
|
|
126
|
+
*/
|
|
127
|
+
getRowKey?: RowKeyGenerator<T>;
|
|
128
|
+
/** 表格 aria-label */
|
|
129
|
+
'aria-label'?: string;
|
|
130
|
+
/** 表格 aria-labelledby */
|
|
131
|
+
'aria-labelledby'?: string;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* 表格状态(用于 useTableState Hook)
|
|
135
|
+
*/
|
|
136
|
+
export interface TableState {
|
|
137
|
+
/** 展开的分组 ID 集合 */
|
|
138
|
+
expandedGroups: Set<string>;
|
|
139
|
+
/** 展开的分类 ID 集合 */
|
|
140
|
+
expandedCategories: Set<string>;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* 表格状态操作
|
|
144
|
+
*/
|
|
145
|
+
export interface TableStateActions {
|
|
146
|
+
/** 切换分组展开状态 */
|
|
147
|
+
toggleGroup: (groupId: string) => void;
|
|
148
|
+
/** 切换分类展开状态 */
|
|
149
|
+
toggleCategory: (categoryId: string) => void;
|
|
150
|
+
/** 展开指定分组 */
|
|
151
|
+
expandGroup: (groupId: string) => void;
|
|
152
|
+
/** 收起指定分组 */
|
|
153
|
+
collapseGroup: (groupId: string) => void;
|
|
154
|
+
/** 展开指定分类 */
|
|
155
|
+
expandCategory: (categoryId: string) => void;
|
|
156
|
+
/** 收起指定分类 */
|
|
157
|
+
collapseCategory: (categoryId: string) => void;
|
|
158
|
+
/** 展开所有分组和分类 */
|
|
159
|
+
expandAll: () => void;
|
|
160
|
+
/** 收起所有分组和分类 */
|
|
161
|
+
collapseAll: () => void;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* TableGroupHeader 组件 Props
|
|
165
|
+
*/
|
|
166
|
+
export interface TableGroupHeaderProps<T> {
|
|
167
|
+
group: TableGroup<T>;
|
|
168
|
+
isExpanded: boolean;
|
|
169
|
+
onToggle: () => void;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* TableCategoryHeader 组件 Props
|
|
173
|
+
*/
|
|
174
|
+
export interface TableCategoryHeaderProps<T> {
|
|
175
|
+
category: TableCategory<T>;
|
|
176
|
+
isExpanded: boolean;
|
|
177
|
+
onToggle: () => void;
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Table/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CA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B;IAClB,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5B,kBAAkB;IAClB,kBAAkB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,eAAe;IACf,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,eAAe;IACf,cAAc,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,aAAa;IACb,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,aAAa;IACb,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,aAAa;IACb,cAAc,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,aAAa;IACb,gBAAgB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,gBAAgB;IAChB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,gBAAgB;IAChB,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACtC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB,CAAC,CAAC;IACzC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAC3B,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TableGroup } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* 将嵌套的 Group → Category → Row 结构扁平化为 Row 数组
|
|
4
|
+
* 用于 TanStack Table 数据处理
|
|
5
|
+
*/
|
|
6
|
+
export declare function flattenData<T>(groups: TableGroup<T>[]): T[];
|
|
7
|
+
/**
|
|
8
|
+
* 计算总行数
|
|
9
|
+
*/
|
|
10
|
+
export declare function getTotalRowCount<T>(groups: TableGroup<T>[]): number;
|
|
11
|
+
/**
|
|
12
|
+
* 根据 Category ID 查找所属的 Group
|
|
13
|
+
*/
|
|
14
|
+
export declare function findGroupByCategory<T>(groups: TableGroup<T>[], categoryId: string): TableGroup<T> | undefined;
|
|
15
|
+
//# sourceMappingURL=flattenData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flattenData.d.ts","sourceRoot":"","sources":["../../../../src/components/Table/utils/flattenData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAiB,MAAM,UAAU,CAAC;AAE1D;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAU3D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,CAMnE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,EACvB,UAAU,EAAE,MAAM,GACjB,UAAU,CAAC,CAAC,CAAC,GAAG,SAAS,CAI3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeClass.d.ts","sourceRoot":"","sources":["../../../../src/components/Table/utils/mergeClass.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,OAAO,EAAE,CAAC,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,KAAK,CAAC,EAAE,GAAG,MAAM,CAEpF"}
|