@pixerate/editor-react 0.108.0 → 0.109.0
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/canvas/index.cjs +767 -692
- package/dist/canvas/index.d.cts +4 -2
- package/dist/canvas/index.d.ts +4 -2
- package/dist/canvas/index.js +285 -208
- package/dist/canvas/useCanvasExplosion.d.cts +23 -5
- package/dist/canvas/useCanvasExplosion.d.ts +23 -5
- package/dist/canvas/useCanvasExplosionState.d.cts +17 -0
- package/dist/canvas/useCanvasExplosionState.d.ts +17 -0
- package/package.json +3 -3
|
@@ -1,16 +1,34 @@
|
|
|
1
|
-
import { type CanvasEdge, type CanvasNode, type CollapseNodeOptions, type ExplodeNodeOptions, type ExplosionSnapshot } from '@pixerate/editor/canvas';
|
|
1
|
+
import { type CanvasEdge, type CanvasNode, type CollapseNodeOptions, type ExplodeNodeOptions, type ExplosionSnapshot, type Rect } from '@pixerate/editor/canvas';
|
|
2
2
|
export interface CanvasGraphTarget<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge> {
|
|
3
3
|
nodes: TNode[];
|
|
4
4
|
edges: TEdge[];
|
|
5
5
|
setNodes: (updater: TNode[] | ((prev: TNode[]) => TNode[])) => void;
|
|
6
6
|
setEdges: (updater: TEdge[] | ((prev: TEdge[]) => TEdge[])) => void;
|
|
7
|
+
/** Builds a parent-to-child edge. Default `{ id: 'explode:<parent>:<child>', source, target }`. */
|
|
8
|
+
createEdge?: (sourceId: string, targetId: string) => TEdge;
|
|
9
|
+
}
|
|
10
|
+
export interface UseCanvasExplosionOptions<TNode extends CanvasNode = CanvasNode> {
|
|
11
|
+
/** Bounds of a set of nodes (e.g. React Flow's `getNodesBounds`). Default: measured sizes. */
|
|
12
|
+
getNodesBounds?: (nodes: TNode[]) => Rect;
|
|
13
|
+
/** Called after an explosion or collapse finishes (e.g. to persist). */
|
|
14
|
+
onSave?: () => void;
|
|
7
15
|
}
|
|
8
16
|
/**
|
|
9
|
-
*
|
|
17
|
+
* Imperative explosion coordinator for a React Flow graph held in state (whiteboards, diagrams):
|
|
18
|
+
* adds child nodes and edges, animates them out along a trajectory while surrounding nodes slide
|
|
19
|
+
* aside, and collapses back exactly. The layout math is `computeCanvasExplosionLayout`; several
|
|
20
|
+
* nodes can be exploded at once. The same API as the Svelte `createCanvasExplosion`. For a canvas
|
|
21
|
+
* derived from state (`useMemo`), use `useCanvasExplosionState` and the layout functions instead.
|
|
22
|
+
*
|
|
23
|
+
* `explodeNode` throws when a child id is already on the canvas or repeated.
|
|
10
24
|
*/
|
|
11
|
-
export declare function useCanvasExplosion<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(target: CanvasGraphTarget<TNode, TEdge>): {
|
|
12
|
-
|
|
13
|
-
|
|
25
|
+
export declare function useCanvasExplosion<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(target: CanvasGraphTarget<TNode, TEdge>, hookOptions?: UseCanvasExplosionOptions<TNode>): {
|
|
26
|
+
/** Ids of nodes whose explosion animation has finished (and not yet collapsed). */
|
|
27
|
+
explodedNodeIds: string[];
|
|
28
|
+
explodeNode: (parentNodeId: string, options: ExplodeNodeOptions<TNode, TEdge>) => boolean;
|
|
29
|
+
collapseNode: (parentNodeId: string, options?: CollapseNodeOptions) => boolean;
|
|
30
|
+
toggleExplode: (parentNodeId: string, explodeOptions: ExplodeNodeOptions<TNode, TEdge>, collapseOptions?: CollapseNodeOptions) => boolean;
|
|
31
|
+
/** True once the node's explosion has finished, until a collapse finishes. */
|
|
14
32
|
isExploded: (parentNodeId: string) => boolean;
|
|
15
33
|
getSnapshot: (parentNodeId: string) => ExplosionSnapshot<TNode, TEdge> | undefined;
|
|
16
34
|
};
|
|
@@ -1,16 +1,34 @@
|
|
|
1
|
-
import { type CanvasEdge, type CanvasNode, type CollapseNodeOptions, type ExplodeNodeOptions, type ExplosionSnapshot } from '@pixerate/editor/canvas';
|
|
1
|
+
import { type CanvasEdge, type CanvasNode, type CollapseNodeOptions, type ExplodeNodeOptions, type ExplosionSnapshot, type Rect } from '@pixerate/editor/canvas';
|
|
2
2
|
export interface CanvasGraphTarget<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge> {
|
|
3
3
|
nodes: TNode[];
|
|
4
4
|
edges: TEdge[];
|
|
5
5
|
setNodes: (updater: TNode[] | ((prev: TNode[]) => TNode[])) => void;
|
|
6
6
|
setEdges: (updater: TEdge[] | ((prev: TEdge[]) => TEdge[])) => void;
|
|
7
|
+
/** Builds a parent-to-child edge. Default `{ id: 'explode:<parent>:<child>', source, target }`. */
|
|
8
|
+
createEdge?: (sourceId: string, targetId: string) => TEdge;
|
|
9
|
+
}
|
|
10
|
+
export interface UseCanvasExplosionOptions<TNode extends CanvasNode = CanvasNode> {
|
|
11
|
+
/** Bounds of a set of nodes (e.g. React Flow's `getNodesBounds`). Default: measured sizes. */
|
|
12
|
+
getNodesBounds?: (nodes: TNode[]) => Rect;
|
|
13
|
+
/** Called after an explosion or collapse finishes (e.g. to persist). */
|
|
14
|
+
onSave?: () => void;
|
|
7
15
|
}
|
|
8
16
|
/**
|
|
9
|
-
*
|
|
17
|
+
* Imperative explosion coordinator for a React Flow graph held in state (whiteboards, diagrams):
|
|
18
|
+
* adds child nodes and edges, animates them out along a trajectory while surrounding nodes slide
|
|
19
|
+
* aside, and collapses back exactly. The layout math is `computeCanvasExplosionLayout`; several
|
|
20
|
+
* nodes can be exploded at once. The same API as the Svelte `createCanvasExplosion`. For a canvas
|
|
21
|
+
* derived from state (`useMemo`), use `useCanvasExplosionState` and the layout functions instead.
|
|
22
|
+
*
|
|
23
|
+
* `explodeNode` throws when a child id is already on the canvas or repeated.
|
|
10
24
|
*/
|
|
11
|
-
export declare function useCanvasExplosion<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(target: CanvasGraphTarget<TNode, TEdge>): {
|
|
12
|
-
|
|
13
|
-
|
|
25
|
+
export declare function useCanvasExplosion<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(target: CanvasGraphTarget<TNode, TEdge>, hookOptions?: UseCanvasExplosionOptions<TNode>): {
|
|
26
|
+
/** Ids of nodes whose explosion animation has finished (and not yet collapsed). */
|
|
27
|
+
explodedNodeIds: string[];
|
|
28
|
+
explodeNode: (parentNodeId: string, options: ExplodeNodeOptions<TNode, TEdge>) => boolean;
|
|
29
|
+
collapseNode: (parentNodeId: string, options?: CollapseNodeOptions) => boolean;
|
|
30
|
+
toggleExplode: (parentNodeId: string, explodeOptions: ExplodeNodeOptions<TNode, TEdge>, collapseOptions?: CollapseNodeOptions) => boolean;
|
|
31
|
+
/** True once the node's explosion has finished, until a collapse finishes. */
|
|
14
32
|
isExploded: (parentNodeId: string) => boolean;
|
|
15
33
|
getSnapshot: (parentNodeId: string) => ExplosionSnapshot<TNode, TEdge> | undefined;
|
|
16
34
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type CanvasExplosionState, type CanvasExplosionStateController, type CanvasExplosionStateOptions } from '@pixerate/editor/canvas';
|
|
2
|
+
export type { CanvasExplosionState, CanvasExplosionStateOptions };
|
|
3
|
+
export interface CanvasExplosionStateHandle extends CanvasExplosionState {
|
|
4
|
+
/** The framework-free controller underneath (for `canvasExplosionToolTarget` and agent tools). */
|
|
5
|
+
readonly controller: CanvasExplosionStateController;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Headless, declarative explosion state as a React hook: which node is exploded (`activeId`),
|
|
9
|
+
* which is still collapsing (`collapsingId`, so its children can play a collapse animation
|
|
10
|
+
* before unmounting), and the collapse timer. It never touches a graph: derive the canvas from
|
|
11
|
+
* it with `useMemo` and `computeCanvasExplosionLayout` / `calculateDirectionalDisplacement`.
|
|
12
|
+
* The same API and lifecycle as the Svelte `createCanvasExplosionState`.
|
|
13
|
+
*
|
|
14
|
+
* `collapseDurationMs` and `initialActiveId` are read once; the callbacks always call the latest
|
|
15
|
+
* props. A running collapse ends (and its timer is cleared) on unmount.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useCanvasExplosionState(options?: CanvasExplosionStateOptions): CanvasExplosionStateHandle;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type CanvasExplosionState, type CanvasExplosionStateController, type CanvasExplosionStateOptions } from '@pixerate/editor/canvas';
|
|
2
|
+
export type { CanvasExplosionState, CanvasExplosionStateOptions };
|
|
3
|
+
export interface CanvasExplosionStateHandle extends CanvasExplosionState {
|
|
4
|
+
/** The framework-free controller underneath (for `canvasExplosionToolTarget` and agent tools). */
|
|
5
|
+
readonly controller: CanvasExplosionStateController;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Headless, declarative explosion state as a React hook: which node is exploded (`activeId`),
|
|
9
|
+
* which is still collapsing (`collapsingId`, so its children can play a collapse animation
|
|
10
|
+
* before unmounting), and the collapse timer. It never touches a graph: derive the canvas from
|
|
11
|
+
* it with `useMemo` and `computeCanvasExplosionLayout` / `calculateDirectionalDisplacement`.
|
|
12
|
+
* The same API and lifecycle as the Svelte `createCanvasExplosionState`.
|
|
13
|
+
*
|
|
14
|
+
* `collapseDurationMs` and `initialActiveId` are read once; the callbacks always call the latest
|
|
15
|
+
* props. A running collapse ends (and its timer is cleared) on unmount.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useCanvasExplosionState(options?: CanvasExplosionStateOptions): CanvasExplosionStateHandle;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.109.0",
|
|
4
4
|
"description": "React bindings and prompt/rich-text components for @pixerate/editor",
|
|
5
5
|
"author": "Pixerate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -258,7 +258,7 @@
|
|
|
258
258
|
},
|
|
259
259
|
"peerDependencies": {
|
|
260
260
|
"@dagrejs/dagre": "^1.1.8",
|
|
261
|
-
"@pixerate/editor": ">=0.
|
|
261
|
+
"@pixerate/editor": ">=0.164.0 <1.0.0-0",
|
|
262
262
|
"@tiptap/core": "^2.27.3",
|
|
263
263
|
"@tiptap/pm": "^2.27.3",
|
|
264
264
|
"@tiptap/react": "^2.27.3",
|
|
@@ -285,7 +285,7 @@
|
|
|
285
285
|
"tsup": "^9.0.0",
|
|
286
286
|
"typescript": "^5.7.3",
|
|
287
287
|
"vitest": "^5.0.5",
|
|
288
|
-
"@pixerate/editor": "0.
|
|
288
|
+
"@pixerate/editor": "0.164.0"
|
|
289
289
|
},
|
|
290
290
|
"scripts": {
|
|
291
291
|
"build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",
|