@groupviz/react 2.0.0 → 2.1.1
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/API.md +358 -0
- package/README.md +47 -16
- package/components/Canvas/ActionScene.d.ts +5 -1
- package/components/Canvas/Cayley3DScene.d.ts +4 -1
- package/components/Canvas/CayleyView.d.ts +7 -1
- package/components/Canvas/CosetStripScene.d.ts +13 -1
- package/components/Canvas/CycleView.d.ts +7 -1
- package/components/Canvas/HomomorphismScene.d.ts +5 -1
- package/components/Canvas/SceneHoverBubble.d.ts +28 -0
- package/components/Canvas/SceneThemeRoot.d.ts +24 -0
- package/components/Canvas/SetView.d.ts +7 -1
- package/components/Canvas/SublatticeScene.d.ts +4 -1
- package/components/Canvas/SymmetryViewScene.d.ts +11 -1
- package/components/Canvas/TableView.d.ts +9 -1
- package/context/cayleyActions.d.ts +4 -1
- package/hooks/useSceneState.d.ts +116 -0
- package/i18n/I18nContext.d.ts +8 -2
- package/index.js +1748 -1327
- package/index.js.map +1 -1
- package/package/react.d.ts +8 -0
- package/package.json +2 -2
- package/utils/elementRef.d.ts +9 -0
|
@@ -45,6 +45,9 @@ export interface SublatticeSceneProps {
|
|
|
45
45
|
/** 渲染主题(格取色 palette)。缺省回落到 ThemeContext(无 Provider 时 'dark');
|
|
46
46
|
* 主应用壳不传即保持现状(读全局主题),包消费端显式传以与容器主题解耦 */
|
|
47
47
|
theme?: 'dark' | 'light';
|
|
48
|
+
/** 本地枚举子群格的群阶上限(`order > 该值` 且未显式传 `lattice` 时不枚举、渲染空态);
|
|
49
|
+
* 缺省 60(与 `findAllSubgroups` 内建守卫一致)。放开需自行确认性能与后端通路 */
|
|
50
|
+
maxEnumerateOrder?: number;
|
|
48
51
|
}
|
|
49
52
|
interface SeriesPanelProps {
|
|
50
53
|
group: Group;
|
|
@@ -66,5 +69,5 @@ export declare function SeriesPanel({ group, series, color, theme: themeProp }:
|
|
|
66
69
|
* 3. 省掉的文字不丢——底部 caption 行按 hover ?? 选中给出完整名片;密度真的高时
|
|
67
70
|
* 用 `mergeConjugates` 把共轭子群合成一个轨道节点(×n,n = |G : N_G(H)|)。
|
|
68
71
|
*/
|
|
69
|
-
export declare function SublatticeScene({ group, lattice, canvasTransform, availableSize, labelDetail, mergeConjugates, nodeScale, showSeriesPanel, series, centerIds, subsets, activeNodeIdx: activeNodeIdxProp, onActivateNode, noGroupText, theme: themeProp, }: SublatticeSceneProps): import("react/jsx-runtime").JSX.Element;
|
|
72
|
+
export declare function SublatticeScene({ group, lattice, canvasTransform, availableSize, labelDetail, mergeConjugates, nodeScale, showSeriesPanel, series, centerIds, subsets, activeNodeIdx: activeNodeIdxProp, onActivateNode, noGroupText, theme: themeProp, maxEnumerateOrder, }: SublatticeSceneProps): import("react/jsx-runtime").JSX.Element;
|
|
70
73
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SceneTheme } from './SceneThemeRoot.js';
|
|
1
2
|
import type { Group } from '@groupviz/core';
|
|
2
3
|
import type { SymmetryType } from '@groupviz/core';
|
|
3
4
|
export interface SymmetryViewSceneProps {
|
|
@@ -28,7 +29,16 @@ export interface SymmetryViewSceneProps {
|
|
|
28
29
|
/** 重放信号:宿主自增该值即对当前演示元素重播一次动画(姿态不改变目标,
|
|
29
30
|
* 解决同元素动画播完一次后无入口重看的缺口);缺省 0 */
|
|
30
31
|
replaySignal?: number;
|
|
32
|
+
/** 显式主题(`'dark' | 'light'`);与 `dark` 二选一,本项优先。
|
|
33
|
+
* 推荐新代码用 `theme` —— 与其余 Scene 命名统一(`dark` 作为兼容别名保留) */
|
|
34
|
+
theme?: SceneTheme;
|
|
35
|
+
/** 演示动画期间是否禁用相机旋转 / 平移;缺省 `false`。
|
|
36
|
+
* **注意行为变更**:旧实现恒等于 `true`(`enableRotate = !showAction && !locked`),
|
|
37
|
+
* 导致"演示元素未命中 / 恒等元素时动画不跑,视角却已被锁死"。需要旧行为的宿主显式传 `true`。 */
|
|
38
|
+
lockCameraOnAction?: boolean;
|
|
39
|
+
/** 演示动画播放结束(姿态落定)回调;用于宿主编排「看完自动切下一个」等自定义流程 */
|
|
40
|
+
onAnimationEnd?: () => void;
|
|
31
41
|
}
|
|
32
42
|
/** 对称性视图纯渲染核(props 化、主题解耦):Canvas + 场景 + 顶部标注 + 演示动画。
|
|
33
43
|
* 主画布经 SymmetryView 适配器接入全局 context;ViewWindow(FGVE 引擎)受控直接使用。 */
|
|
34
|
-
export declare function SymmetryViewScene({ group, symmetryType: symmetryTypeProp, dark, variant, showAction, actionElementId, rotateSpeed, showFigureTitle, locked, onHint, hintOnIdle, replaySignal, }: SymmetryViewSceneProps): import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
export declare function SymmetryViewScene({ group, symmetryType: symmetryTypeProp, dark, variant, showAction, actionElementId, rotateSpeed, showFigureTitle, locked, onHint, hintOnIdle, replaySignal, theme, lockCameraOnAction, onAnimationEnd, }: SymmetryViewSceneProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SceneTheme } from './SceneThemeRoot.js';
|
|
1
2
|
import type { CanvasTransform, Group, GroupElement, Subset } from '@groupviz/core';
|
|
2
3
|
import type { CosetInfo } from '@groupviz/core';
|
|
3
4
|
import type { TableStrategy } from '@groupviz/core';
|
|
@@ -39,5 +40,12 @@ export interface TableViewProps {
|
|
|
39
40
|
onSelect?: (elId: string, additive: boolean) => void;
|
|
40
41
|
onHover?: (el: GroupElement | null) => void;
|
|
41
42
|
noGroupText?: string;
|
|
43
|
+
/** 文字乘法表「过大」阈值覆盖(群阶 > 该值时先出告警占位);缺省 100(core.sizeLimitFor('table')) */
|
|
44
|
+
maxTableOrder?: number;
|
|
45
|
+
/** 热力图「过大」阈值覆盖;缺省 240(core.sizeLimitFor('heatmap'),聚合缩略图可承载更大群) */
|
|
46
|
+
maxHeatmapOrder?: number;
|
|
47
|
+
/** 视图主题作用域(`'dark' | 'light'`)。缺省不注入、跟随外层主题;显式传值时在本子树内
|
|
48
|
+
* 应用 `theme.css` 对应变量块(需宿主已 `import '@groupviz/react/theme.css'`) */
|
|
49
|
+
theme?: SceneTheme;
|
|
42
50
|
}
|
|
43
|
-
export declare function TableView(
|
|
51
|
+
export declare function TableView(props: TableViewProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,9 +3,12 @@ import { type CayleyShape2D } from '@groupviz/core';
|
|
|
3
3
|
import type { CayleyActionParam } from '@groupviz/core';
|
|
4
4
|
export declare function getInitialCayleyActions(group: Group): CayleyAction[];
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* 归一化凯莱视图作用边参数:解析并过滤群中不存在的元素引用,补全 enabled(默认 true)与
|
|
7
7
|
* color(默认 COLOR_PALETTE 按序)。actions 未提供时返回群生成元集合。
|
|
8
8
|
* ViewWindow 参数面板与 CayleyView 渲染共用,保证两边对「当前边集合」的判定一致。
|
|
9
|
+
*
|
|
10
|
+
* `elementId` **接受元素引用**(`id` / `label` / `value` 串,见 `core.resolveElement`):
|
|
11
|
+
* 传人类记号 `(234)` 不再被静默丢弃;确实解析不到时告警一次再忽略(不再无声无息)。
|
|
9
12
|
*/
|
|
10
13
|
export declare function normalizeCayleyActions(group: Group, actions?: CayleyActionParam[]): CayleyAction[];
|
|
11
14
|
export interface CayleyShapeConfig {
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
import type { CanvasTransform, Group, GroupElement, NodePosition } from '@groupviz/core';
|
|
3
|
+
export interface SceneStateOptions {
|
|
4
|
+
/** 初始平移 / 缩放;缺省 `{ x:0, y:0, scale:1 }` */
|
|
5
|
+
initialTransform?: CanvasTransform;
|
|
6
|
+
/** 锁定交互(透传给 Scene 的 `locked`;同时禁用本 hook 的平移缩放) */
|
|
7
|
+
locked?: boolean;
|
|
8
|
+
/** 滚轮缩放开关;缺省 `true` */
|
|
9
|
+
enableZoom?: boolean;
|
|
10
|
+
/** 拖拽平移开关;缺省 `true` */
|
|
11
|
+
enablePan?: boolean;
|
|
12
|
+
/** 缩放下限;缺省 `0.25`(与主画布一致) */
|
|
13
|
+
minScale?: number;
|
|
14
|
+
/** 缩放上限;缺省 `8` */
|
|
15
|
+
maxScale?: number;
|
|
16
|
+
/** 受控选中集合(传入即受控,配合 `onSelectionChange`) */
|
|
17
|
+
selectedElements?: Set<string>;
|
|
18
|
+
/** 选中集合变更回调(受控 / 非受控都会触发,便于宿主记录) */
|
|
19
|
+
onSelectionChange?: (next: Set<string>) => void;
|
|
20
|
+
/** ResizeObserver 首帧前的兜底尺寸;缺省 `{ width:800, height:600 }` */
|
|
21
|
+
fallbackViewBoxSize?: {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
};
|
|
25
|
+
/** 宿主容器附加样式(与内建样式合并,内建优先保证定位/尺寸) */
|
|
26
|
+
hostStyle?: CSSProperties;
|
|
27
|
+
/** hover 气泡主题;缺省 `'dark'` */
|
|
28
|
+
theme?: 'dark' | 'light';
|
|
29
|
+
/** hover 气泡自定义渲染;返回 `null` 表示禁用内建气泡 */
|
|
30
|
+
renderHoverBubble?: (el: GroupElement, anchor: {
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
|
+
} | null) => ReactNode;
|
|
34
|
+
}
|
|
35
|
+
/** 可直接 spread 到四类 2D Scene 的公共受控 props。 */
|
|
36
|
+
export interface SceneStateProps {
|
|
37
|
+
selectedElements: Set<string>;
|
|
38
|
+
canvasTransform: CanvasTransform;
|
|
39
|
+
viewBoxSize: {
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
};
|
|
43
|
+
onSelect: (elId: string, additive: boolean) => void;
|
|
44
|
+
onHover: (el: GroupElement | null, anchor?: {
|
|
45
|
+
x: number;
|
|
46
|
+
y: number;
|
|
47
|
+
} | null) => void;
|
|
48
|
+
}
|
|
49
|
+
export interface SceneState {
|
|
50
|
+
/** 容器实测尺寸(ResizeObserver;首帧为兜底值) */
|
|
51
|
+
viewBoxSize: {
|
|
52
|
+
width: number;
|
|
53
|
+
height: number;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* 宿主容器的 props —— **一次 spread 即可**:
|
|
57
|
+
*
|
|
58
|
+
* ```tsx
|
|
59
|
+
* const s = useSceneState(group)
|
|
60
|
+
* <div {...s.hostProps}><SetView group={group} {...s.sceneProps} />{s.hoverBubble}</div>
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* 内含 `ref`(回调 ref)、内建样式(定位/尺寸/`touchAction`/光标)与拖拽平移事件。
|
|
64
|
+
*
|
|
65
|
+
* ⚠️ 别在 spread 之后再写 `ref`:那会顶掉内建 ref,尺寸测量与悬浮气泡换算会静默失效。
|
|
66
|
+
* 需要 DOM 节点请用 `getHostElement()`。
|
|
67
|
+
*
|
|
68
|
+
* 设计说明:ref 只以**嵌套**形式出现在 `hostProps` 里,绝不作为顶层字段暴露。
|
|
69
|
+
* React Compiler 的 `react-hooks/refs` 规则会把「顶层返回了写 ref 的回调」的 hook
|
|
70
|
+
* 整体判为 ref 载体,此后宿主每次 `s.xxx` 读取都会报「渲染期访问 ref」;
|
|
71
|
+
* 嵌套形式不触发该判定(实测)。
|
|
72
|
+
*/
|
|
73
|
+
hostProps: {
|
|
74
|
+
ref: (el: HTMLDivElement | null) => void;
|
|
75
|
+
style: CSSProperties;
|
|
76
|
+
onMouseDown: (e: React.MouseEvent) => void;
|
|
77
|
+
onMouseMove: (e: React.MouseEvent) => void;
|
|
78
|
+
onMouseUp: () => void;
|
|
79
|
+
onMouseLeave: () => void;
|
|
80
|
+
};
|
|
81
|
+
/** 需要 DOM 节点时用(如导出 SVG):取宿主容器元素 */
|
|
82
|
+
getHostElement: () => HTMLDivElement | null;
|
|
83
|
+
canvasTransform: CanvasTransform;
|
|
84
|
+
setCanvasTransform: (t: CanvasTransform) => void;
|
|
85
|
+
selectedElements: Set<string>;
|
|
86
|
+
setSelectedElements: (next: Set<string> | ((prev: Set<string>) => Set<string>)) => void;
|
|
87
|
+
/** 选中语义:`additive`(⊕/Ctrl/⌘)→ 切换成员;否则 → 单选替换 */
|
|
88
|
+
select: (elId: string, additive?: boolean) => void;
|
|
89
|
+
clearSelection: () => void;
|
|
90
|
+
/** 当前悬停元素(`onHover` 自动维护) */
|
|
91
|
+
hovered: GroupElement | null;
|
|
92
|
+
/** 悬停锚点(viewBox 坐标系下映射到容器内的屏幕坐标) */
|
|
93
|
+
hoverAnchor: {
|
|
94
|
+
x: number;
|
|
95
|
+
y: number;
|
|
96
|
+
} | null;
|
|
97
|
+
/** 内建 hover 气泡节点(可直接 `{s.hoverBubble}`;想自己画就用 `renderHoverBubble`) */
|
|
98
|
+
hoverBubble: ReactNode;
|
|
99
|
+
/** 直接 spread 给 SetView / CycleView / CayleyView / CosetStripScene */
|
|
100
|
+
sceneProps: SceneStateProps;
|
|
101
|
+
/** 复位平移缩放 */
|
|
102
|
+
resetTransform: () => void;
|
|
103
|
+
/** 以容器中心为锚缩放(按钮用,`factor > 1` 放大) */
|
|
104
|
+
zoomBy: (factor: number) => void;
|
|
105
|
+
/** 是否锁定(= `options.locked`) */
|
|
106
|
+
locked: boolean;
|
|
107
|
+
/** 共享节点位置:接 `CycleView.getNodePosition` */
|
|
108
|
+
getNodePosition: (elId: string) => NodePosition | undefined;
|
|
109
|
+
/** 共享节点位置:接 `CycleView.onNodePositionChange` */
|
|
110
|
+
onNodePositionChange: (elId: string, x: number, y: number) => void;
|
|
111
|
+
/** 清空共享节点位置 */
|
|
112
|
+
resetNodePositions: () => void;
|
|
113
|
+
}
|
|
114
|
+
export declare function useSceneState(group?: Group | null, options?: SceneStateOptions): SceneState;
|
|
115
|
+
/** 无群 / 无操作时的稳定引用(供宿主做默认值,避免每次新建对象触发重渲染)。 */
|
|
116
|
+
export declare const SCENE_STATE_NOOP: () => void;
|
package/i18n/I18nContext.d.ts
CHANGED
|
@@ -6,6 +6,12 @@ export interface I18nContextValue {
|
|
|
6
6
|
t: (key: string, params?: Record<string, string | number>) => string;
|
|
7
7
|
}
|
|
8
8
|
export declare const I18nContext: import("react").Context<I18nContextValue>;
|
|
9
|
-
export
|
|
9
|
+
export interface I18nProviderProps {
|
|
10
10
|
children: ReactNode;
|
|
11
|
-
|
|
11
|
+
/** 初始语言;缺省按 `getDefaultLang()`(读 localStorage / 浏览器语言) */
|
|
12
|
+
lang?: Lang;
|
|
13
|
+
/** 是否把语言选择写入 `localStorage('groupviz-lang')`;缺省 `true`。
|
|
14
|
+
* 嵌入宿主不希望与主应用抢同一 key 时可传 `false`。 */
|
|
15
|
+
persist?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function I18nProvider({ children, lang: langProp, persist }: I18nProviderProps): import("react/jsx-runtime").JSX.Element;
|