@nice2dev/ui-diagrams 1.3.12 → 1.3.14

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @nice2dev/ui-diagrams — Changelog
2
2
 
3
+ ## 1.3.14
4
+
5
+ No changes in this release.
6
+
7
+ ## 1.3.13
8
+
9
+ No changes in this release.
10
+
3
11
  ## 1.3.12
4
12
 
5
13
  No changes in this release.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice2dev/ui-diagrams",
3
- "version": "1.3.12",
3
+ "version": "1.3.14",
4
4
  "description": "Nice2Dev Diagram Editor & Viewer — flowcharts, org charts, BPMN, ER diagrams with animations, data binding, and custom .ndd.json format",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -40,7 +40,7 @@
40
40
  "react-dom": ">=17.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@nice2dev/ui": "^1.3.12",
43
+ "@nice2dev/ui": "^1.3.14",
44
44
  "@testing-library/jest-dom": "^7.0.1",
45
45
  "@testing-library/react": "^16.3.3",
46
46
  "@types/react": "^19.2.18",
@@ -1 +0,0 @@
1
- export {};
@@ -1,251 +0,0 @@
1
- import { default as React } from 'react';
2
- import { NiceDiagramDocument, DiagramNode, DiagramEdge, DiagramGroup } from '../types/diagramTypes';
3
- export interface YDoc {
4
- getMap<T>(name: string): YMap<T>;
5
- getArray<T>(name: string): YArray<T>;
6
- getText(name: string): YText;
7
- on(event: 'update' | 'destroy', callback: (update: Uint8Array, origin: unknown) => void): void;
8
- off(event: 'update' | 'destroy', callback: (update: Uint8Array, origin: unknown) => void): void;
9
- transact(fn: () => void, origin?: unknown): void;
10
- destroy(): void;
11
- guid: string;
12
- clientID: number;
13
- }
14
- export interface YMap<T> {
15
- get(key: string): T | undefined;
16
- set(key: string, value: T): void;
17
- delete(key: string): void;
18
- has(key: string): boolean;
19
- keys(): IterableIterator<string>;
20
- values(): IterableIterator<T>;
21
- entries(): IterableIterator<[string, T]>;
22
- forEach(fn: (value: T, key: string, map: YMap<T>) => void): void;
23
- toJSON(): Record<string, T>;
24
- observe(fn: (event: YMapEvent<T>) => void): void;
25
- unobserve(fn: (event: YMapEvent<T>) => void): void;
26
- size: number;
27
- }
28
- export interface YArray<T> {
29
- get(index: number): T | undefined;
30
- insert(index: number, content: T[]): void;
31
- delete(index: number, length: number): void;
32
- push(content: T[]): void;
33
- unshift(content: T[]): void;
34
- slice(start?: number, end?: number): T[];
35
- toArray(): T[];
36
- toJSON(): T[];
37
- length: number;
38
- observe(fn: (event: YArrayEvent<T>) => void): void;
39
- unobserve(fn: (event: YArrayEvent<T>) => void): void;
40
- forEach(fn: (item: T, index: number, array: YArray<T>) => void): void;
41
- }
42
- export interface YText {
43
- insert(index: number, content: string): void;
44
- delete(index: number, length: number): void;
45
- toString(): string;
46
- length: number;
47
- observe(fn: (event: YTextEvent) => void): void;
48
- unobserve(fn: (event: YTextEvent) => void): void;
49
- }
50
- export interface YMapEvent<T> {
51
- target: YMap<T>;
52
- keysChanged: Set<string>;
53
- changes: {
54
- keys: Map<string, {
55
- action: 'add' | 'update' | 'delete';
56
- oldValue?: T;
57
- }>;
58
- };
59
- }
60
- export interface YArrayEvent<T> {
61
- target: YArray<T>;
62
- delta: Array<{
63
- insert?: T[];
64
- delete?: number;
65
- retain?: number;
66
- }>;
67
- }
68
- export interface YTextEvent {
69
- target: YText;
70
- delta: Array<{
71
- insert?: string;
72
- delete?: number;
73
- retain?: number;
74
- }>;
75
- }
76
- export interface AwarenessState {
77
- user: CollaboratorInfo;
78
- cursor?: CursorPosition;
79
- selection?: string[];
80
- viewport?: ViewportState;
81
- }
82
- export interface CollaboratorInfo {
83
- id: string;
84
- name: string;
85
- color: string;
86
- avatar?: string;
87
- }
88
- export interface CursorPosition {
89
- x: number;
90
- y: number;
91
- timestamp: number;
92
- }
93
- export interface ViewportState {
94
- x: number;
95
- y: number;
96
- scale: number;
97
- }
98
- export interface Awareness {
99
- clientID: number;
100
- getLocalState(): AwarenessState | null;
101
- setLocalState(state: Partial<AwarenessState>): void;
102
- setLocalStateField(field: string, value: unknown): void;
103
- getStates(): Map<number, AwarenessState>;
104
- on(event: 'change' | 'update', callback: (changes: AwarenessChanges) => void): void;
105
- off(event: 'change' | 'update', callback: (changes: AwarenessChanges) => void): void;
106
- destroy(): void;
107
- }
108
- export interface AwarenessChanges {
109
- added: number[];
110
- updated: number[];
111
- removed: number[];
112
- }
113
- export interface WebsocketProviderLike {
114
- awareness: Awareness;
115
- on(event: 'sync' | 'connection-error' | 'connection-close', callback: (synced: boolean) => void): void;
116
- off(event: 'sync' | 'connection-error' | 'connection-close', callback: (synced: boolean) => void): void;
117
- connect(): void;
118
- disconnect(): void;
119
- destroy(): void;
120
- connected: boolean;
121
- }
122
- export interface CollaborationProvider {
123
- type: 'websocket' | 'webrtc' | 'indexed-db';
124
- url?: string;
125
- room: string;
126
- password?: string;
127
- }
128
- export interface CollaborativeDiagramState {
129
- document: NiceDiagramDocument | null;
130
- collaborators: CollaboratorInfo[];
131
- cursors: Map<string, CursorPosition>;
132
- selections: Map<string, string[]>;
133
- isConnected: boolean;
134
- isSynced: boolean;
135
- localUser: CollaboratorInfo | null;
136
- undoManager: UndoManagerLike | null;
137
- }
138
- export interface UndoManagerLike {
139
- undo(): void;
140
- redo(): void;
141
- canUndo(): boolean;
142
- canRedo(): boolean;
143
- on(event: 'stack-item-added' | 'stack-item-popped', fn: (event: unknown) => void): void;
144
- stopCapturing(): void;
145
- clear(): void;
146
- }
147
- export interface CollaborativeActions {
148
- addNode: (node: DiagramNode) => void;
149
- updateNode: (id: string, updates: Partial<DiagramNode>) => void;
150
- deleteNode: (id: string) => void;
151
- moveNode: (id: string, x: number, y: number) => void;
152
- addEdge: (edge: DiagramEdge) => void;
153
- updateEdge: (id: string, updates: Partial<DiagramEdge>) => void;
154
- deleteEdge: (id: string) => void;
155
- addGroup: (group: DiagramGroup) => void;
156
- updateGroup: (id: string, updates: Partial<DiagramGroup>) => void;
157
- deleteGroup: (id: string) => void;
158
- setSelection: (nodeIds: string[]) => void;
159
- setCursor: (position: CursorPosition | null) => void;
160
- setViewport: (viewport: ViewportState) => void;
161
- undo: () => void;
162
- redo: () => void;
163
- connect: () => void;
164
- disconnect: () => void;
165
- setDocument: (doc: NiceDiagramDocument) => void;
166
- getDocument: () => NiceDiagramDocument | null;
167
- }
168
- export interface CollaborativeDiagramContextValue {
169
- state: CollaborativeDiagramState;
170
- actions: CollaborativeActions;
171
- }
172
- export declare function syncYjsToDiagram(nodesMap: YMap<DiagramNode>, edgesMap: YMap<DiagramEdge>, groupsMap: YMap<DiagramGroup>, metaMap: YMap<unknown>): NiceDiagramDocument;
173
- export declare function syncDiagramToYjs(document: NiceDiagramDocument, nodesMap: YMap<DiagramNode>, edgesMap: YMap<DiagramEdge>, groupsMap: YMap<DiagramGroup>, metaMap: YMap<unknown>, ydoc: YDoc): void;
174
- export interface UseCollaborativeDiagramOptions {
175
- provider?: CollaborationProvider;
176
- user: CollaboratorInfo;
177
- initialDocument?: NiceDiagramDocument;
178
- onSync?: (document: NiceDiagramDocument) => void;
179
- onUserJoin?: (user: CollaboratorInfo) => void;
180
- onUserLeave?: (user: CollaboratorInfo) => void;
181
- onConnectionChange?: (connected: boolean) => void;
182
- createYDoc?: () => YDoc;
183
- createProvider?: (ydoc: YDoc, config: CollaborationProvider) => WebsocketProviderLike;
184
- createUndoManager?: (ydoc: YDoc, trackedTypes: unknown[]) => UndoManagerLike;
185
- }
186
- export declare function useCollaborativeDiagram(options: UseCollaborativeDiagramOptions): CollaborativeDiagramContextValue;
187
- export interface CollaborativeDiagramProviderProps {
188
- children: React.ReactNode;
189
- options: UseCollaborativeDiagramOptions;
190
- }
191
- export declare function CollaborativeDiagramProvider({ children, options, }: CollaborativeDiagramProviderProps): React.ReactElement;
192
- export declare function useCollaborativeDiagramContext(): CollaborativeDiagramContextValue;
193
- export declare function useCollaborators(): CollaboratorInfo[];
194
- export declare function useCursors(): Map<string, CursorPosition>;
195
- export declare function useSelections(): Map<string, string[]>;
196
- export declare function useConnectionState(): {
197
- isConnected: boolean;
198
- isSynced: boolean;
199
- };
200
- export declare function useUndoRedo(): {
201
- undo: () => void;
202
- redo: () => void;
203
- canUndo: boolean;
204
- canRedo: boolean;
205
- };
206
- export interface CollaboratorCursorsProps {
207
- scale?: number;
208
- offsetX?: number;
209
- offsetY?: number;
210
- showLabels?: boolean;
211
- fadeTimeout?: number;
212
- }
213
- export declare function CollaboratorCursors({ scale, offsetX, offsetY, showLabels, fadeTimeout, }: CollaboratorCursorsProps): React.ReactElement | null;
214
- export interface CollaboratorSelectionsProps {
215
- getNodeBounds: (id: string) => {
216
- x: number;
217
- y: number;
218
- width: number;
219
- height: number;
220
- } | null;
221
- scale?: number;
222
- offsetX?: number;
223
- offsetY?: number;
224
- }
225
- export declare function CollaboratorSelections({ getNodeBounds, scale, offsetX, offsetY, }: CollaboratorSelectionsProps): React.ReactElement | null;
226
- export interface PresenceAvatarsProps {
227
- maxVisible?: number;
228
- size?: number;
229
- className?: string;
230
- }
231
- export declare function PresenceAvatars({ maxVisible, size, className, }: PresenceAvatarsProps): React.ReactElement;
232
- export interface ConnectionStatusProps {
233
- showLabel?: boolean;
234
- className?: string;
235
- }
236
- export declare function ConnectionStatus({ showLabel, className, }: ConnectionStatusProps): React.ReactElement;
237
- declare const _default: {
238
- CollaborativeDiagramProvider: typeof CollaborativeDiagramProvider;
239
- useCollaborativeDiagram: typeof useCollaborativeDiagram;
240
- useCollaborativeDiagramContext: typeof useCollaborativeDiagramContext;
241
- useCollaborators: typeof useCollaborators;
242
- useCursors: typeof useCursors;
243
- useSelections: typeof useSelections;
244
- useConnectionState: typeof useConnectionState;
245
- useUndoRedo: typeof useUndoRedo;
246
- CollaboratorCursors: typeof CollaboratorCursors;
247
- CollaboratorSelections: typeof CollaboratorSelections;
248
- PresenceAvatars: typeof PresenceAvatars;
249
- ConnectionStatus: typeof ConnectionStatus;
250
- };
251
- export default _default;
@@ -1,60 +0,0 @@
1
- import { NiceDiagramDocument } from '../types/diagramTypes';
2
- export interface DiagramTemplate {
3
- id: string;
4
- name: string;
5
- description: string;
6
- category: DiagramTemplateCategory;
7
- thumbnail?: string;
8
- tags: string[];
9
- document: NiceDiagramDocument;
10
- }
11
- export type DiagramTemplateCategory = 'flowchart' | 'organizational' | 'technical' | 'business' | 'software' | 'network' | 'planning';
12
- export interface TemplateMetadata {
13
- author?: string;
14
- version?: string;
15
- license?: string;
16
- source?: string;
17
- }
18
- export declare const diagramTemplates: DiagramTemplate[];
19
- /**
20
- * Get all templates
21
- */
22
- export declare function getAllTemplates(): DiagramTemplate[];
23
- /**
24
- * Get template by ID
25
- */
26
- export declare function getTemplateById(id: string): DiagramTemplate | undefined;
27
- /**
28
- * Get templates by category
29
- */
30
- export declare function getTemplatesByCategory(category: DiagramTemplateCategory): DiagramTemplate[];
31
- /**
32
- * Search templates by name or tags
33
- */
34
- export declare function searchTemplates(query: string): DiagramTemplate[];
35
- /**
36
- * Get all template categories with counts
37
- */
38
- export declare function getTemplateCategories(): Array<{
39
- category: DiagramTemplateCategory;
40
- count: number;
41
- }>;
42
- /**
43
- * Create a new document from a template
44
- */
45
- export declare function createFromTemplate(templateId: string, title?: string): NiceDiagramDocument;
46
- /**
47
- * Get suggested templates based on diagram type
48
- */
49
- export declare function getSuggestedTemplates(diagramType: NiceDiagramDocument['diagramType']): DiagramTemplate[];
50
- declare const _default: {
51
- getAllTemplates: typeof getAllTemplates;
52
- getTemplateById: typeof getTemplateById;
53
- getTemplatesByCategory: typeof getTemplatesByCategory;
54
- searchTemplates: typeof searchTemplates;
55
- getTemplateCategories: typeof getTemplateCategories;
56
- createFromTemplate: typeof createFromTemplate;
57
- getSuggestedTemplates: typeof getSuggestedTemplates;
58
- diagramTemplates: DiagramTemplate[];
59
- };
60
- export default _default;
@@ -1,132 +0,0 @@
1
- import { default as React } from 'react';
2
- export interface ShapeDefinition {
3
- /** Unique shape identifier */
4
- id: string;
5
- /** Display name */
6
- name: string;
7
- /** Category for organization */
8
- category: ShapeCategory;
9
- /** Description */
10
- description?: string;
11
- /** SVG path data (for simple shapes) */
12
- pathData?: string;
13
- /** Full SVG content (for complex shapes) */
14
- svgContent?: string;
15
- /** Default width */
16
- defaultWidth: number;
17
- /** Default height */
18
- defaultHeight: number;
19
- /** SVG viewBox dimensions */
20
- viewBox: {
21
- x: number;
22
- y: number;
23
- width: number;
24
- height: number;
25
- };
26
- /** Connection points (anchors) as percentages */
27
- anchors: ShapeAnchor[];
28
- /** Whether shape maintains aspect ratio */
29
- preserveAspectRatio?: boolean;
30
- /** Default fill color */
31
- defaultFill?: string;
32
- /** Default stroke color */
33
- defaultStroke?: string;
34
- /** Default stroke width */
35
- defaultStrokeWidth?: number;
36
- /** Tags for searching */
37
- tags?: string[];
38
- /** Custom metadata */
39
- metadata?: Record<string, unknown>;
40
- /** Author/source */
41
- author?: string;
42
- /** License */
43
- license?: string;
44
- }
45
- export interface ShapeAnchor {
46
- id: string;
47
- name?: string;
48
- x: number;
49
- y: number;
50
- direction?: 'top' | 'bottom' | 'left' | 'right' | 'any';
51
- }
52
- export type ShapeCategory = 'basic' | 'flowchart' | 'arrows' | 'connectors' | 'containers' | 'icons' | 'network' | 'database' | 'uml' | 'bpmn' | 'custom';
53
- export interface ShapeStyle {
54
- fill?: string;
55
- stroke?: string;
56
- strokeWidth?: number;
57
- opacity?: number;
58
- strokeDasharray?: string;
59
- strokeLinecap?: 'butt' | 'round' | 'square';
60
- strokeLinejoin?: 'miter' | 'round' | 'bevel';
61
- }
62
- export interface ShapeRenderOptions {
63
- width: number;
64
- height: number;
65
- style?: ShapeStyle;
66
- className?: string;
67
- selected?: boolean;
68
- hovered?: boolean;
69
- }
70
- export interface ShapeRegistryValue {
71
- shapes: Map<string, ShapeDefinition>;
72
- categories: Map<ShapeCategory, ShapeDefinition[]>;
73
- registerShape: (shape: ShapeDefinition) => void;
74
- registerShapes: (shapes: ShapeDefinition[]) => void;
75
- unregisterShape: (id: string) => void;
76
- getShape: (id: string) => ShapeDefinition | undefined;
77
- getShapesByCategory: (category: ShapeCategory) => ShapeDefinition[];
78
- searchShapes: (query: string) => ShapeDefinition[];
79
- getAllShapes: () => ShapeDefinition[];
80
- getAllCategories: () => ShapeCategory[];
81
- }
82
- export interface ShapeRegistryProviderProps {
83
- children: React.ReactNode;
84
- customShapes?: ShapeDefinition[];
85
- includeBuiltIn?: boolean;
86
- }
87
- export declare function ShapeRegistryProvider({ children, customShapes, includeBuiltIn, }: ShapeRegistryProviderProps): React.ReactElement;
88
- export declare function useShapeRegistry(): ShapeRegistryValue;
89
- export declare function useShape(id: string): ShapeDefinition | undefined;
90
- export declare function useShapesByCategory(category: ShapeCategory): ShapeDefinition[];
91
- export interface ShapeRendererProps {
92
- shape: ShapeDefinition;
93
- options: ShapeRenderOptions;
94
- }
95
- export declare function renderShape(props: ShapeRendererProps): React.ReactElement;
96
- export interface ShapeProps {
97
- shapeId: string;
98
- width: number;
99
- height: number;
100
- style?: ShapeStyle;
101
- className?: string;
102
- selected?: boolean;
103
- hovered?: boolean;
104
- onClick?: () => void;
105
- onDoubleClick?: () => void;
106
- }
107
- export declare function Shape({ shapeId, width, height, style, className, selected, hovered, onClick, onDoubleClick, }: ShapeProps): React.ReactElement | null;
108
- export declare const builtInShapes: {
109
- basic: ShapeDefinition[];
110
- flowchart: ShapeDefinition[];
111
- database: ShapeDefinition[];
112
- network: ShapeDefinition[];
113
- uml: ShapeDefinition[];
114
- bpmn: ShapeDefinition[];
115
- };
116
- declare const _default: {
117
- ShapeRegistryProvider: typeof ShapeRegistryProvider;
118
- useShapeRegistry: typeof useShapeRegistry;
119
- useShape: typeof useShape;
120
- useShapesByCategory: typeof useShapesByCategory;
121
- Shape: typeof Shape;
122
- renderShape: typeof renderShape;
123
- builtInShapes: {
124
- basic: ShapeDefinition[];
125
- flowchart: ShapeDefinition[];
126
- database: ShapeDefinition[];
127
- network: ShapeDefinition[];
128
- uml: ShapeDefinition[];
129
- bpmn: ShapeDefinition[];
130
- };
131
- };
132
- export default _default;
@@ -1,165 +0,0 @@
1
- import { default as React } from 'react';
2
- export interface Point {
3
- x: number;
4
- y: number;
5
- }
6
- export interface Rect {
7
- x: number;
8
- y: number;
9
- width: number;
10
- height: number;
11
- }
12
- export interface SnapConfig {
13
- /** Enable grid snapping */
14
- gridSnap: boolean;
15
- /** Grid size in pixels */
16
- gridSize: number;
17
- /** Enable snap to objects */
18
- objectSnap: boolean;
19
- /** Snap threshold distance in pixels */
20
- snapThreshold: number;
21
- /** Show alignment guides */
22
- showGuides: boolean;
23
- /** Guide line color */
24
- guideColor: string;
25
- /** Guide line width */
26
- guideWidth: number;
27
- /** Enable smart distribution guides */
28
- distributionGuides: boolean;
29
- /** Enable center alignment guides */
30
- centerGuides: boolean;
31
- /** Enable edge alignment guides */
32
- edgeGuides: boolean;
33
- }
34
- export interface Guide {
35
- id: string;
36
- type: 'horizontal' | 'vertical';
37
- position: number;
38
- start: number;
39
- end: number;
40
- label?: string;
41
- }
42
- export interface SnapResult {
43
- point: Point;
44
- snappedX: boolean;
45
- snappedY: boolean;
46
- guides: Guide[];
47
- }
48
- export interface AlignmentInfo {
49
- type: 'left' | 'right' | 'top' | 'bottom' | 'centerX' | 'centerY';
50
- position: number;
51
- nodeIds: string[];
52
- }
53
- export interface DistributionInfo {
54
- type: 'horizontal' | 'vertical';
55
- spacing: number;
56
- nodeIds: string[];
57
- }
58
- export interface NodeBounds {
59
- id: string;
60
- rect: Rect;
61
- }
62
- export declare const defaultSnapConfig: SnapConfig;
63
- /**
64
- * Snap a value to the nearest grid point
65
- */
66
- export declare function snapToGrid(value: number, gridSize: number): number;
67
- /**
68
- * Snap a point to the grid
69
- */
70
- export declare function snapPointToGrid(point: Point, gridSize: number): Point;
71
- /**
72
- * Snap a rect position to the grid
73
- */
74
- export declare function snapRectToGrid(rect: Rect, gridSize: number): Rect;
75
- /**
76
- * Calculate snap result for a moving node against other nodes
77
- */
78
- export declare function calculateSnap(movingRect: Rect, otherNodes: NodeBounds[], config: SnapConfig): SnapResult;
79
- /**
80
- * Calculate equal distribution spacing between nodes
81
- */
82
- export declare function calculateDistribution(nodes: NodeBounds[], direction: 'horizontal' | 'vertical'): DistributionInfo | null;
83
- /**
84
- * Distribute nodes evenly
85
- */
86
- export declare function distributeNodes(nodes: NodeBounds[], direction: 'horizontal' | 'vertical'): NodeBounds[];
87
- export type AlignmentType = 'left' | 'right' | 'top' | 'bottom' | 'centerX' | 'centerY';
88
- /**
89
- * Align nodes to a specific edge or center
90
- */
91
- export declare function alignNodes(nodes: NodeBounds[], alignment: AlignmentType, reference?: number): NodeBounds[];
92
- /**
93
- * Match node sizes
94
- */
95
- export declare function matchSizes(nodes: NodeBounds[], dimension: 'width' | 'height' | 'both', reference?: 'min' | 'max' | 'avg' | number): NodeBounds[];
96
- export interface SnapContextValue {
97
- config: SnapConfig;
98
- setConfig: (config: Partial<SnapConfig>) => void;
99
- guides: Guide[];
100
- setGuides: (guides: Guide[]) => void;
101
- calculateSnap: (movingRect: Rect, excludeId: string) => SnapResult;
102
- registerNode: (node: NodeBounds) => void;
103
- unregisterNode: (id: string) => void;
104
- updateNode: (node: NodeBounds) => void;
105
- clearGuides: () => void;
106
- }
107
- export interface SnapProviderProps {
108
- children: React.ReactNode;
109
- initialConfig?: Partial<SnapConfig>;
110
- }
111
- export declare function SnapProvider({ children, initialConfig }: SnapProviderProps): React.ReactElement;
112
- export declare function useSnapContext(): SnapContextValue;
113
- export declare function useSnapConfig(): [SnapConfig, (config: Partial<SnapConfig>) => void];
114
- export declare function useGuides(): Guide[];
115
- export declare function useNodeSnap(nodeId: string, initialRect: Rect): {
116
- position: Point;
117
- updatePosition: (newPosition: Point) => Point;
118
- startDrag: () => void;
119
- endDrag: () => void;
120
- };
121
- export interface AlignmentGuidesProps {
122
- scale?: number;
123
- offsetX?: number;
124
- offsetY?: number;
125
- }
126
- export declare function AlignmentGuides({ scale, offsetX, offsetY, }: AlignmentGuidesProps): React.ReactElement | null;
127
- export interface GridBackgroundProps {
128
- gridSize: number;
129
- scale?: number;
130
- offsetX?: number;
131
- offsetY?: number;
132
- majorGridInterval?: number;
133
- minorGridColor?: string;
134
- majorGridColor?: string;
135
- showGrid?: boolean;
136
- }
137
- export declare function GridBackground({ gridSize, scale, offsetX, offsetY, majorGridInterval, minorGridColor, majorGridColor, showGrid, }: GridBackgroundProps): React.ReactElement | null;
138
- export interface AlignmentToolbarProps {
139
- selectedIds: string[];
140
- onAlign: (type: AlignmentType) => void;
141
- onDistribute: (direction: 'horizontal' | 'vertical') => void;
142
- onMatchSize: (dimension: 'width' | 'height' | 'both') => void;
143
- className?: string;
144
- }
145
- export declare function AlignmentToolbar({ selectedIds, onAlign, onDistribute, onMatchSize, className, }: AlignmentToolbarProps): React.ReactElement;
146
- declare const _default: {
147
- SnapProvider: typeof SnapProvider;
148
- useSnapContext: typeof useSnapContext;
149
- useSnapConfig: typeof useSnapConfig;
150
- useGuides: typeof useGuides;
151
- useNodeSnap: typeof useNodeSnap;
152
- AlignmentGuides: typeof AlignmentGuides;
153
- GridBackground: typeof GridBackground;
154
- AlignmentToolbar: typeof AlignmentToolbar;
155
- snapToGrid: typeof snapToGrid;
156
- snapPointToGrid: typeof snapPointToGrid;
157
- snapRectToGrid: typeof snapRectToGrid;
158
- calculateSnap: typeof calculateSnap;
159
- calculateDistribution: typeof calculateDistribution;
160
- distributeNodes: typeof distributeNodes;
161
- alignNodes: typeof alignNodes;
162
- matchSizes: typeof matchSizes;
163
- defaultSnapConfig: SnapConfig;
164
- };
165
- export default _default;
@@ -1,278 +0,0 @@
1
- import { WorkflowData } from './NiceWorkflowVisualizer';
2
- export interface BPMNDefinitions {
3
- process?: BPMNProcess | BPMNProcess[];
4
- collaboration?: BPMNCollaboration;
5
- message?: BPMNMessage[];
6
- signal?: BPMNSignal[];
7
- error?: BPMNError[];
8
- }
9
- export interface BPMNProcess {
10
- id: string;
11
- name?: string;
12
- isExecutable?: boolean;
13
- flowElement?: BPMNFlowElement[];
14
- sequenceFlow?: BPMNSequenceFlow[];
15
- laneSet?: BPMNLaneSet;
16
- }
17
- export interface BPMNCollaboration {
18
- id: string;
19
- participant?: BPMNParticipant[];
20
- messageFlow?: BPMNMessageFlow[];
21
- }
22
- export interface BPMNParticipant {
23
- id: string;
24
- name?: string;
25
- processRef?: string;
26
- }
27
- export interface BPMNFlowElement {
28
- $type: string;
29
- id: string;
30
- name?: string;
31
- incoming?: string[];
32
- outgoing?: string[];
33
- default?: string;
34
- loopCharacteristics?: BPMNLoopCharacteristics;
35
- boundaryEventRef?: string;
36
- attachedToRef?: string;
37
- timerEventDefinition?: BPMNTimerEventDefinition;
38
- messageEventDefinition?: BPMNMessageEventDefinition;
39
- errorEventDefinition?: BPMNErrorEventDefinition;
40
- signalEventDefinition?: BPMNSignalEventDefinition;
41
- conditionExpression?: BPMNExpression;
42
- sourceRef?: string;
43
- targetRef?: string;
44
- }
45
- export interface BPMNSequenceFlow {
46
- id: string;
47
- name?: string;
48
- sourceRef: string;
49
- targetRef: string;
50
- conditionExpression?: BPMNExpression;
51
- }
52
- export interface BPMNExpression {
53
- $type?: string;
54
- body?: string;
55
- language?: string;
56
- }
57
- export interface BPMNLaneSet {
58
- lane?: BPMNLane[];
59
- }
60
- export interface BPMNLane {
61
- id: string;
62
- name?: string;
63
- flowNodeRef?: string[];
64
- }
65
- export interface BPMNLoopCharacteristics {
66
- $type: string;
67
- isSequential?: boolean;
68
- }
69
- export interface BPMNTimerEventDefinition {
70
- timeDuration?: BPMNExpression;
71
- timeCycle?: BPMNExpression;
72
- timeDate?: BPMNExpression;
73
- }
74
- export interface BPMNMessageEventDefinition {
75
- messageRef?: string;
76
- }
77
- export interface BPMNErrorEventDefinition {
78
- errorRef?: string;
79
- }
80
- export interface BPMNSignalEventDefinition {
81
- signalRef?: string;
82
- }
83
- export interface BPMNMessage {
84
- id: string;
85
- name?: string;
86
- }
87
- export interface BPMNSignal {
88
- id: string;
89
- name?: string;
90
- }
91
- export interface BPMNError {
92
- id: string;
93
- name?: string;
94
- errorCode?: string;
95
- }
96
- export interface BPMNMessageFlow {
97
- id: string;
98
- sourceRef: string;
99
- targetRef: string;
100
- name?: string;
101
- }
102
- export interface CamundaProcessInstance {
103
- id: string;
104
- processDefinitionId: string;
105
- processDefinitionKey: string;
106
- processDefinitionName?: string;
107
- businessKey?: string;
108
- state: 'ACTIVE' | 'SUSPENDED' | 'COMPLETED' | 'EXTERNALLY_TERMINATED' | 'INTERNALLY_TERMINATED';
109
- startDate: string;
110
- endDate?: string;
111
- tenantId?: string;
112
- }
113
- export interface CamundaActivityInstance {
114
- id: string;
115
- activityId: string;
116
- activityName?: string;
117
- activityType: string;
118
- processInstanceId: string;
119
- processDefinitionId: string;
120
- startDate: string;
121
- endDate?: string;
122
- canceled: boolean;
123
- completeScope: boolean;
124
- }
125
- export interface CamundaIncident {
126
- id: string;
127
- processInstanceId: string;
128
- processDefinitionId: string;
129
- activityId: string;
130
- incidentType: string;
131
- incidentMessage?: string;
132
- incidentTimestamp: string;
133
- state: 'ACTIVE' | 'RESOLVED' | 'DELETED';
134
- }
135
- export interface CamundaTask {
136
- id: string;
137
- processInstanceId: string;
138
- processDefinitionId: string;
139
- taskDefinitionKey: string;
140
- name?: string;
141
- assignee?: string;
142
- creationDate: string;
143
- dueDate?: string;
144
- followUpDate?: string;
145
- priority: number;
146
- delegation?: 'PENDING' | 'RESOLVED';
147
- state: 'CREATED' | 'COMPLETED' | 'CANCELED';
148
- }
149
- export interface CamundaHistoryData {
150
- processInstance: CamundaProcessInstance;
151
- activityInstances: CamundaActivityInstance[];
152
- incidents?: CamundaIncident[];
153
- tasks?: CamundaTask[];
154
- }
155
- export interface N8nWorkflow {
156
- id?: string;
157
- name: string;
158
- active?: boolean;
159
- nodes: N8nNode[];
160
- connections: N8nConnections;
161
- settings?: N8nWorkflowSettings;
162
- staticData?: unknown;
163
- tags?: N8nTag[];
164
- createdAt?: string;
165
- updatedAt?: string;
166
- }
167
- export interface N8nNode {
168
- id?: string;
169
- name: string;
170
- type: string;
171
- typeVersion?: number;
172
- position: [number, number];
173
- parameters?: Record<string, unknown>;
174
- credentials?: Record<string, N8nCredentialRef>;
175
- disabled?: boolean;
176
- notes?: string;
177
- notesInFlow?: boolean;
178
- webhookId?: string;
179
- color?: string;
180
- }
181
- export interface N8nCredentialRef {
182
- id: string;
183
- name: string;
184
- }
185
- export interface N8nConnections {
186
- [nodeName: string]: {
187
- [outputType: string]: Array<Array<{
188
- node: string;
189
- type: string;
190
- index: number;
191
- }>>;
192
- };
193
- }
194
- export interface N8nWorkflowSettings {
195
- executionOrder?: 'v0' | 'v1';
196
- saveDataErrorExecution?: 'all' | 'none';
197
- saveDataSuccessExecution?: 'all' | 'none';
198
- saveManualExecutions?: boolean;
199
- callerPolicy?: 'any' | 'none' | 'workflowsFromAList' | 'workflowsFromSameOwner';
200
- timezone?: string;
201
- errorWorkflow?: string;
202
- }
203
- export interface N8nTag {
204
- id?: string;
205
- name: string;
206
- createdAt?: string;
207
- updatedAt?: string;
208
- }
209
- export interface N8nExecution {
210
- id: string;
211
- workflowId: string;
212
- finished: boolean;
213
- mode: 'cli' | 'error' | 'integrated' | 'internal' | 'manual' | 'retry' | 'trigger' | 'webhook';
214
- startedAt: string;
215
- stoppedAt?: string;
216
- workflowData: N8nWorkflow;
217
- data?: N8nExecutionData;
218
- status: 'canceled' | 'crashed' | 'error' | 'new' | 'running' | 'success' | 'unknown' | 'waiting';
219
- retryOf?: string;
220
- retrySuccessId?: string;
221
- }
222
- export interface N8nExecutionData {
223
- resultData: {
224
- runData: Record<string, N8nNodeRunData[]>;
225
- lastNodeExecuted?: string;
226
- error?: {
227
- message: string;
228
- stack?: string;
229
- node?: N8nNode;
230
- };
231
- };
232
- executionData?: {
233
- contextData?: Record<string, unknown>;
234
- waitingExecution?: Record<string, unknown>;
235
- waitingExecutionSource?: Record<string, unknown>;
236
- };
237
- }
238
- export interface N8nNodeRunData {
239
- startTime: number;
240
- executionTime?: number;
241
- executionStatus?: 'success' | 'error' | 'canceled' | 'waiting';
242
- data?: {
243
- main?: Array<Array<{
244
- json: Record<string, unknown>;
245
- }>>;
246
- };
247
- error?: {
248
- message: string;
249
- stack?: string;
250
- };
251
- }
252
- /**
253
- * Convert BPMN 2.0 definitions to WorkflowData format.
254
- */
255
- export declare function convertBPMNToWorkflow(definitions: BPMNDefinitions, processId?: string): WorkflowData;
256
- /**
257
- * Convert Camunda process history to WorkflowData with execution state.
258
- */
259
- export declare function convertCamundaToWorkflow(bpmnWorkflow: WorkflowData, historyData: CamundaHistoryData): WorkflowData;
260
- /**
261
- * Convert n8n workflow to WorkflowData format.
262
- */
263
- export declare function convertN8nToWorkflow(workflow: N8nWorkflow): WorkflowData;
264
- /**
265
- * Apply n8n execution data to update step statuses.
266
- */
267
- export declare function applyN8nExecution(workflow: WorkflowData, execution: N8nExecution): WorkflowData;
268
- export type WorkflowEngineType = 'bpmn' | 'camunda' | 'n8n';
269
- export interface WorkflowEngineConfig {
270
- type: WorkflowEngineType;
271
- apiUrl?: string;
272
- apiKey?: string;
273
- processDefinitionId?: string;
274
- }
275
- /**
276
- * Detect workflow engine type from data structure.
277
- */
278
- export declare function detectWorkflowEngine(data: unknown): WorkflowEngineType | null;
@@ -1,49 +0,0 @@
1
- import { Point, Size } from '../types/diagramTypes';
2
- export interface GridConfig {
3
- /** Grid cell size in px (default 20) */
4
- size: number;
5
- /** Whether snap-to-grid is enabled */
6
- enabled: boolean;
7
- /** Alignment guide threshold in px */
8
- guideThreshold: number;
9
- /** Show guides while dragging */
10
- showGuides: boolean;
11
- }
12
- export declare const DEFAULT_GRID_CONFIG: GridConfig;
13
- /**
14
- * Snap a single value to the nearest grid line.
15
- */
16
- export declare function snapToGrid(value: number, gridSize: number): number;
17
- /**
18
- * Snap a point to the grid.
19
- */
20
- export declare function snapPointToGrid(point: Point, gridSize: number): Point;
21
- /**
22
- * Snap a node's position considering its size so edges stay grid-aligned.
23
- */
24
- export declare function snapNodePosition(position: Point, _size: Size, gridSize: number): Point;
25
- export type GuideAxis = 'horizontal' | 'vertical';
26
- export interface AlignmentGuide {
27
- axis: GuideAxis;
28
- position: number;
29
- /** Source node IDs that contribute to this guide */
30
- sourceNodeIds: string[];
31
- /** Alignment type */
32
- type: 'center' | 'edge';
33
- }
34
- /**
35
- * Compute alignment guides between the dragged node and all other nodes.
36
- */
37
- export declare function computeAlignmentGuides(draggedNodeId: string, dragPosition: Point, dragSize: Size, otherNodes: ReadonlyArray<{
38
- id: string;
39
- position: Point;
40
- size: Size;
41
- }>, threshold?: number): AlignmentGuide[];
42
- /**
43
- * Apply the nearest alignment guide snapping to a position.
44
- * Returns the snapped position and active guides.
45
- */
46
- export declare function applyAlignmentSnap(position: Point, size: Size, guides: AlignmentGuide[]): {
47
- snappedPosition: Point;
48
- activeGuides: AlignmentGuide[];
49
- };