@weasel-js/diagram 1.9.1 → 1.9.3
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 +53 -7
- package/dist/{chunk-6VYT4WCM.js → chunk-ERT3XWBS.js} +286 -110
- package/dist/chunk-ERT3XWBS.js.map +1 -0
- package/dist/index.d.ts +229 -28
- package/dist/index.js +363 -78
- package/dist/index.js.map +1 -1
- package/dist/layout.d.ts +1 -1
- package/dist/{layout.entry-ClWUwH16.d.ts → layout.entry-KHbx5uGC.d.ts} +338 -275
- package/dist/layout.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-6VYT4WCM.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { P as Port, a as PortsOptions, D as DiagramNodeLike, b as DiagramNodeReader, c as DiagramNode, L as LayoutFn,
|
|
2
|
-
export {
|
|
3
|
-
import { Vec2, DerivedDep, Path, SceneRegistry, PoseDescriptor, ChromeState, FillStyle, Stroke, CursorSpec, Affordance, InvocationCtx, GestureBinding, Action, Contribution, RenderLayer, AddNodeSpec, RectPose, EasingFn, NodeId,
|
|
1
|
+
import { P as Port, a as PortsOptions, D as DiagramNodeLike, b as DiagramNodeReader, c as PortAnchor, d as DiagramGroup, R as Row, O as Outline, e as PortSpec, B as BodySpec, f as DiagramNode, L as LayoutFn, g as LayoutOptions, M as MeasureRowText, G as GraphSource, F as ForceOptions, h as LayoutResult, i as Graph } from './layout.entry-KHbx5uGC.js';
|
|
2
|
+
export { j as BodyFloor, k as BodyNodeSpec, l as Bounds, m as BuildBodyOptions, n as BuildGraphOptions, C as COMPASS, o as DEFAULT_GROUP_INSET, p as DEFAULT_NODE_GAP, q as DEFAULT_PORTS, r as DEFAULT_RANK_GAP, s as DIAGRAM_TRAIT_KEY, t as DiagramNodeEntry, u as ForceBody, v as ForceRelaxation, w as GraphEdge, x as GraphGroup, y as GraphNode, z as GraphNodeLike, A as GroupInset, E as LayoutAxes, H as LayoutDirection, I as RowBox, J as RowNodeData, K as RowPort, N as RowPortBox, Q as RowTextStyle, S as Slot, T as axesFor, U as backEdges, V as bodyOutline, W as bodyTrait, X as boxForContent, Y as buildBody, Z as buildGraph, _ as canvasMeasure, $ as contentBox, a0 as createDiagramNodes, a1 as dataKeyReader, a2 as diagramNodeOf, a3 as expandGroupEdges, a4 as force, a5 as forceRelaxation, a6 as forestOf, a7 as graphOrder, a8 as insetOf, a9 as isPinned, aa as layered, ab as layoutBody, ac as layoutRowPorts, ad as measureBody, ae as outlinePath, af as outlinePolyline, ag as packAcross, ah as packClusters, ai as pinnedSet, aj as portOf, ak as portsOf, al as portsOnOutline, am as rankGaps, an as ranksOf, ao as rayHit, ap as seededOrder, aq as settle, ar as sizeToBody, as as translated, at as tree } from './layout.entry-KHbx5uGC.js';
|
|
3
|
+
import { Vec2, DerivedDep, Path, SceneRegistry, PoseDescriptor, ChromeState, FillStyle, Stroke, CursorSpec, Affordance, InvocationCtx, GestureBinding, Action, Contribution, RenderLayer, MarkerRef, AddNodeSpec, RectPose, Scene, EasingFn, NodeId, NodeShapeEntry, View, SelectionApi } from '@weasel-js/core';
|
|
4
|
+
import { Vec2 as Vec2$1 } from '@weasel-js/core/math';
|
|
4
5
|
import * as react from 'react';
|
|
5
6
|
import '@weasel-js/geom';
|
|
6
|
-
import '@weasel-js/core/math';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* `DiagramEdge` — a connection between two participants.
|
|
@@ -54,9 +54,9 @@ interface RouteRequest {
|
|
|
54
54
|
/** A router returns the points the edge runs through, `from.point` first and
|
|
55
55
|
* `to.point` last. Turning those into a `Path` is `edgePath`'s job, so a
|
|
56
56
|
* router never has to know about path encodings. */
|
|
57
|
-
type Router = (req: RouteRequest) => readonly Vec2[];
|
|
57
|
+
type Router$1 = (req: RouteRequest) => readonly Vec2[];
|
|
58
58
|
/** The straight run between the two ends, through any waypoints. */
|
|
59
|
-
declare const straight: Router;
|
|
59
|
+
declare const straight: Router$1;
|
|
60
60
|
/**
|
|
61
61
|
* An axis-aligned route: leave along the departing end's normal and arrive
|
|
62
62
|
* against the receiving one's.
|
|
@@ -67,7 +67,7 @@ declare const straight: Router;
|
|
|
67
67
|
* shape — a route that lands on a west-facing port from above puts its marker
|
|
68
68
|
* across the corner, which reads as aimed at nothing.
|
|
69
69
|
*/
|
|
70
|
-
declare const orthogonal: Router;
|
|
70
|
+
declare const orthogonal: Router$1;
|
|
71
71
|
/**
|
|
72
72
|
* A smooth route, sampled into points.
|
|
73
73
|
*
|
|
@@ -79,9 +79,9 @@ declare const orthogonal: Router;
|
|
|
79
79
|
* every router returns the same thing; `edgePath` is free to emit curves later
|
|
80
80
|
* without changing the contract.
|
|
81
81
|
*/
|
|
82
|
-
declare const bezier: Router;
|
|
82
|
+
declare const bezier: Router$1;
|
|
83
83
|
/** The routers this package ships. A consumer's own go in the same shape. */
|
|
84
|
-
declare const ROUTERS: Readonly<Record<string, Router>>;
|
|
84
|
+
declare const ROUTERS: Readonly<Record<string, Router$1>>;
|
|
85
85
|
/** The edge trait on a node's data, or `null`. */
|
|
86
86
|
declare function diagramEdgeOf(node: {
|
|
87
87
|
data: unknown;
|
|
@@ -98,7 +98,7 @@ declare function resolveEnd<TPose>(end: EdgeEnd, dep: DerivedDep<TPose>, toward:
|
|
|
98
98
|
/** Options for {@link edgeDerivePath}. */
|
|
99
99
|
interface EdgeRouteOptions<TPose> extends PortsOptions<TPose> {
|
|
100
100
|
/** Routers by key. Defaults to {@link ROUTERS}. */
|
|
101
|
-
routers?: Readonly<Record<string, Router>>;
|
|
101
|
+
routers?: Readonly<Record<string, Router$1>>;
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
104
|
* A `derivePath` that routes an edge between its two dependencies.
|
|
@@ -272,7 +272,7 @@ interface ConnectActionOptions<TPose> {
|
|
|
272
272
|
/** Registry key the new edge names, and the router the preview draws with.
|
|
273
273
|
* Default `'straight'`. */
|
|
274
274
|
router?: string;
|
|
275
|
-
routers?: Readonly<Record<string, Router>>;
|
|
275
|
+
routers?: Readonly<Record<string, Router$1>>;
|
|
276
276
|
/**
|
|
277
277
|
* Mints and commits the edge. Called once, on release over a valid port.
|
|
278
278
|
*
|
|
@@ -417,66 +417,215 @@ declare const LABEL_DERIVE_POSE: (node: {
|
|
|
417
417
|
data: unknown;
|
|
418
418
|
}, deps: readonly (DerivedDep<unknown, unknown, string> | undefined)[]) => unknown;
|
|
419
419
|
|
|
420
|
+
/**
|
|
421
|
+
* A group's box, and anything pinned to a point on another node.
|
|
422
|
+
*
|
|
423
|
+
* The box is an ordinary node that depends on its members and derives its pose
|
|
424
|
+
* from theirs: their union, grown by the inset. Drag a member and the box
|
|
425
|
+
* follows; lay the diagram out and the box lands around wherever the members
|
|
426
|
+
* went. Nothing has to keep it in sync, because nothing stores it.
|
|
427
|
+
*
|
|
428
|
+
* An anchored node — a group's title is the first — derives its pose from one
|
|
429
|
+
* dependency's bounds the same way, so it travels with the box it labels.
|
|
430
|
+
*/
|
|
431
|
+
|
|
432
|
+
/** Where an anchored node sits on its dependency. */
|
|
433
|
+
interface DiagramAnchor {
|
|
434
|
+
/** The point on the dependency's bounds, normalized as a port's is. */
|
|
435
|
+
at: PortAnchor;
|
|
436
|
+
/** The point on the node's own bounds that lands there. Default `at`, so
|
|
437
|
+
* `{ u: 0, v: 0 }` puts the node's top-left on the dependency's. */
|
|
438
|
+
self?: PortAnchor;
|
|
439
|
+
/** Then moved by this much, in world units. */
|
|
440
|
+
offset?: Vec2$1;
|
|
441
|
+
}
|
|
442
|
+
/** The group trait on a node's data, or `null`. */
|
|
443
|
+
declare function diagramGroupOf(node: {
|
|
444
|
+
data: unknown;
|
|
445
|
+
}): DiagramGroup | null;
|
|
446
|
+
/** The anchor trait on a node's data, or `null`. */
|
|
447
|
+
declare function diagramAnchorOf(node: {
|
|
448
|
+
data: unknown;
|
|
449
|
+
}): DiagramAnchor | null;
|
|
450
|
+
/** Options for {@link groupDerivePose} and {@link anchorDerivePose}.
|
|
451
|
+
* `geometry` defaults to the kit's `AUTO_POSE_DESCRIPTOR`. */
|
|
452
|
+
interface GroupPoseOptions<TPose> {
|
|
453
|
+
geometry?: PoseDescriptor<TPose>;
|
|
454
|
+
}
|
|
455
|
+
type DerivePose<TPose> = (node: {
|
|
456
|
+
pose: TPose;
|
|
457
|
+
data: unknown;
|
|
458
|
+
}, deps: readonly (DerivedDep<TPose> | undefined)[]) => TPose | null;
|
|
459
|
+
/**
|
|
460
|
+
* A `derivePose` that draws a group's box around its members: their union,
|
|
461
|
+
* grown by the trait's inset. `null` — the authored pose stands — when the node
|
|
462
|
+
* carries no group trait or every member is gone.
|
|
463
|
+
*/
|
|
464
|
+
declare function groupDerivePose<TPose>(opts?: GroupPoseOptions<TPose>): DerivePose<TPose>;
|
|
465
|
+
/**
|
|
466
|
+
* A `derivePose` that keeps a node at a point on its dependency's bounds.
|
|
467
|
+
* `null` when the node carries no anchor trait or the dependency is gone.
|
|
468
|
+
*/
|
|
469
|
+
declare function anchorDerivePose<TPose>(opts?: GroupPoseOptions<TPose>): DerivePose<TPose>;
|
|
470
|
+
/** Registry key for {@link GROUP_DERIVE_POSE}. */
|
|
471
|
+
declare const DIAGRAM_GROUP = "diagram:group";
|
|
472
|
+
/** Registry key for {@link ANCHOR_DERIVE_POSE}. */
|
|
473
|
+
declare const DIAGRAM_ANCHOR = "diagram:anchor";
|
|
474
|
+
/** The default derivations, as stable references so `toJSON` can find their keys. */
|
|
475
|
+
declare const GROUP_DERIVE_POSE: DerivePose<unknown>;
|
|
476
|
+
declare const ANCHOR_DERIVE_POSE: DerivePose<unknown>;
|
|
477
|
+
|
|
420
478
|
/**
|
|
421
479
|
* `diagramScene` — a laid-out diagram from plain `{ nodes, edges }`.
|
|
422
480
|
*
|
|
423
|
-
*
|
|
424
|
-
*
|
|
481
|
+
* Every box is a `buildBody` body, so a data node can say anything a body
|
|
482
|
+
* can: outline, rows, padding, ports. Sizes are estimated from character
|
|
483
|
+
* counts unless `measure` is given, so layout runs without a canvas and gives
|
|
484
|
+
* the same answer in node and in a browser.
|
|
425
485
|
*/
|
|
426
486
|
|
|
427
487
|
interface DataNode {
|
|
428
488
|
id: string;
|
|
429
|
-
|
|
489
|
+
/** Shorthand for one `label` row per line. Ignored when `rows` is given. */
|
|
490
|
+
lines?: readonly string[];
|
|
491
|
+
rows?: readonly Row[];
|
|
492
|
+
/** Default `DiagramSceneOptions.outline`, which defaults to `'rect'`. */
|
|
493
|
+
outline?: Outline;
|
|
494
|
+
/** Perimeter ports, replacing the four compass midpoints. */
|
|
495
|
+
ports?: readonly PortSpec[];
|
|
496
|
+
/** Layout leaves this node at `at`. */
|
|
497
|
+
pinned?: boolean;
|
|
498
|
+
/** Where the node starts, before layout. Unset, nodes start on the
|
|
499
|
+
* diagonal in source order, which is what within-rank order is seeded
|
|
500
|
+
* from. */
|
|
501
|
+
at?: Vec2$1;
|
|
502
|
+
/** The smallest the box may be. Its content grows it past this. */
|
|
503
|
+
width?: number;
|
|
504
|
+
height?: number;
|
|
505
|
+
/** Default `DiagramSceneOptions.padding`. */
|
|
506
|
+
padding?: number;
|
|
507
|
+
/** Default `DiagramSceneOptions.gap`. */
|
|
508
|
+
gap?: number;
|
|
509
|
+
/** Default `DiagramSceneOptions.verticalAlign`. */
|
|
510
|
+
verticalAlign?: BodySpec['verticalAlign'];
|
|
430
511
|
}
|
|
431
512
|
interface DataEdge {
|
|
513
|
+
/** A node's id, or a group's: an edge naming a group meets its box. */
|
|
432
514
|
from: string;
|
|
433
515
|
to: string;
|
|
516
|
+
/** The port to leave from or arrive at. Unset, the end facing the other
|
|
517
|
+
* node most directly. */
|
|
518
|
+
fromPort?: string;
|
|
519
|
+
toPort?: string;
|
|
520
|
+
label?: string;
|
|
521
|
+
/** Where along the edge the label sits. Default `DiagramSceneOptions.labelPlacement`. */
|
|
522
|
+
labelPlacement?: DiagramLabel;
|
|
523
|
+
/** Default `DiagramSceneOptions.router`. */
|
|
524
|
+
router?: Router;
|
|
525
|
+
/** World points the route passes through. Layout does not move them. */
|
|
526
|
+
waypoints?: readonly Vec2$1[];
|
|
527
|
+
}
|
|
528
|
+
/** A box drawn around some nodes, which layout keeps together. */
|
|
529
|
+
interface DataGroup {
|
|
530
|
+
/** Shares one namespace with node ids. */
|
|
531
|
+
id: string;
|
|
532
|
+
/** Node ids. A node a later group also names stays in this one, and an id
|
|
533
|
+
* that is not a node is ignored. */
|
|
534
|
+
members: readonly string[];
|
|
535
|
+
/** Drawn inside the box, above its members. */
|
|
434
536
|
label?: string;
|
|
537
|
+
/** Between the box and its members, and around the label. Default
|
|
538
|
+
* `DiagramSceneOptions.groupPadding`. */
|
|
539
|
+
padding?: number;
|
|
435
540
|
}
|
|
436
541
|
interface DiagramData {
|
|
437
542
|
nodes: readonly DataNode[];
|
|
438
543
|
edges: readonly DataEdge[];
|
|
544
|
+
/** Flat: a group is never a member of another. `layered` and `tree` keep
|
|
545
|
+
* each group's members together; `force` and `'none'` ignore groups but
|
|
546
|
+
* still draw them. */
|
|
547
|
+
groups?: readonly DataGroup[];
|
|
439
548
|
}
|
|
440
549
|
interface NodeStyle {
|
|
441
550
|
fill: string;
|
|
442
551
|
stroke: string;
|
|
443
552
|
text: string;
|
|
444
553
|
strokeWidth?: number;
|
|
554
|
+
dash?: number[];
|
|
445
555
|
}
|
|
446
556
|
interface EdgeStyle {
|
|
447
557
|
stroke: string;
|
|
448
558
|
width?: number;
|
|
559
|
+
dash?: number[];
|
|
560
|
+
/** `null` for none. Default none. */
|
|
561
|
+
markerStart?: MarkerRef | null;
|
|
562
|
+
/** `null` for none. Default `'arrow'`. */
|
|
563
|
+
markerEnd?: MarkerRef | null;
|
|
564
|
+
/** Default `stroke`. */
|
|
565
|
+
label?: string;
|
|
449
566
|
}
|
|
567
|
+
type Router = 'straight' | 'bezier' | 'orthogonal';
|
|
568
|
+
type TextStyle = {
|
|
569
|
+
fontFamily: string;
|
|
570
|
+
fontSize: number;
|
|
571
|
+
fontWeight?: number;
|
|
572
|
+
};
|
|
450
573
|
interface DiagramSceneData {
|
|
451
574
|
diagram?: DiagramNode | DiagramEdge | {
|
|
452
575
|
label: DiagramLabel;
|
|
576
|
+
} | {
|
|
577
|
+
anchor: DiagramAnchor;
|
|
453
578
|
};
|
|
454
579
|
fill?: {
|
|
455
580
|
color: string;
|
|
456
581
|
};
|
|
457
582
|
stroke?: Stroke;
|
|
458
583
|
text?: string;
|
|
459
|
-
style?:
|
|
460
|
-
fontFamily: string;
|
|
461
|
-
fontSize: number;
|
|
462
|
-
};
|
|
584
|
+
style?: TextStyle;
|
|
463
585
|
}
|
|
464
586
|
type DiagramSpec = AddNodeSpec<DiagramSceneData, 'main', RectPose>;
|
|
465
587
|
interface DiagramSceneOptions {
|
|
466
|
-
layout
|
|
588
|
+
/** A layout by name, or any `LayoutFn`. Default `'layered'`. `'none'`
|
|
589
|
+
* leaves every node at its `at`. */
|
|
590
|
+
layout?: 'layered' | 'tree' | 'force' | 'none' | LayoutFn;
|
|
591
|
+
/** Merged over `{ order: 'barycenter' }`. */
|
|
467
592
|
layoutOptions?: LayoutOptions;
|
|
468
|
-
|
|
593
|
+
/** Default `'bezier'`. */
|
|
594
|
+
router?: Router;
|
|
595
|
+
/** The text style rows fall back on. Default 12px sans-serif. */
|
|
469
596
|
font?: {
|
|
470
597
|
fontFamily: string;
|
|
471
598
|
fontSize: number;
|
|
472
599
|
};
|
|
600
|
+
/** Measures one run of text. Default an estimate from character count, so
|
|
601
|
+
* layout needs no canvas; pass `canvasMeasure(ctx)` for real widths. */
|
|
602
|
+
measure?: MeasureRowText;
|
|
603
|
+
/** Default `'rect'`. */
|
|
604
|
+
outline?: Outline;
|
|
605
|
+
/** Between a box's outline and its rows. Default 8. */
|
|
606
|
+
padding?: number;
|
|
607
|
+
/** Between adjacent rows. Default 4. */
|
|
608
|
+
gap?: number;
|
|
609
|
+
/** Where a box's rows sit when it is taller than they need. Default `'center'`. */
|
|
610
|
+
verticalAlign?: BodySpec['verticalAlign'];
|
|
611
|
+
/** The narrowest a box may be. Default 64. */
|
|
612
|
+
minWidth?: number;
|
|
613
|
+
/** Where edge labels sit. Default `{ at: 'mid', offset: 9 }`. */
|
|
614
|
+
labelPlacement?: DiagramLabel;
|
|
473
615
|
nodeStyle?: (node: DataNode) => NodeStyle;
|
|
616
|
+
/** Default 12. */
|
|
617
|
+
groupPadding?: number;
|
|
618
|
+
/** A group's box and label. `text` colors the label. */
|
|
619
|
+
groupStyle?: (group: DataGroup) => NodeStyle;
|
|
474
620
|
edgeStyle?: (edge: DataEdge) => EdgeStyle;
|
|
475
621
|
}
|
|
476
622
|
declare const edgeIdOf: (e: DataEdge) => string;
|
|
477
|
-
/**
|
|
623
|
+
/** Every spec carries an id — a node's own, `<id>/<k>` for its text,
|
|
624
|
+
* `<edge id>/label`, a group's own and `<group id>/label` — so a later call's
|
|
625
|
+
* specs can be reconciled against this one's. Throws on a repeated id among
|
|
626
|
+
* nodes and groups, which names two things as one. An edge whose
|
|
478
627
|
* end is not a node is dropped, and so is a repeat of an earlier edge with
|
|
479
|
-
* the same ends and label: it would draw exactly on top of the first. */
|
|
628
|
+
* the same ends, ports and label: it would draw exactly on top of the first. */
|
|
480
629
|
declare function diagramScene(data: DiagramData, opts?: DiagramSceneOptions): DiagramSpec[];
|
|
481
630
|
|
|
482
631
|
/** What a live producer is told, and what it answers with. */
|
|
@@ -752,7 +901,17 @@ declare function diagramShape<TPose>(opts?: DiagramShapeOptions<TPose>): NodeSha
|
|
|
752
901
|
*/
|
|
753
902
|
declare function registerDiagramShape<TPose>(opts?: DiagramShapeOptions<TPose>): () => void;
|
|
754
903
|
|
|
904
|
+
/** Where a moved node now stands. */
|
|
905
|
+
interface NodeMove {
|
|
906
|
+
id: string;
|
|
907
|
+
x: number;
|
|
908
|
+
y: number;
|
|
909
|
+
}
|
|
755
910
|
interface DiagramViewProps {
|
|
911
|
+
/** Every spec needs an id, which `diagramScene` gives them. A new array is
|
|
912
|
+
* reconciled into the scene the view already holds, so the view, the
|
|
913
|
+
* selection and anything moved since stay put unless the new specs change
|
|
914
|
+
* them. Pass a new `key` to start over instead. */
|
|
756
915
|
specs: readonly DiagramSpec[];
|
|
757
916
|
width: number;
|
|
758
917
|
height: number;
|
|
@@ -762,20 +921,62 @@ interface DiagramViewProps {
|
|
|
762
921
|
* picked node reports it again. The canvas keeps the pick even if
|
|
763
922
|
* `selected` does not follow it; only a change to `selected` is pushed in. */
|
|
764
923
|
onSelect?: (id: string | null) => void;
|
|
924
|
+
/** Set to let nodes be dragged. Reports every node a drag or a layout run
|
|
925
|
+
* moved. Store each as the data node's `at` with `pinned: true`, or the
|
|
926
|
+
* next `diagramScene` lays it out again. */
|
|
927
|
+
onMove?: (moves: readonly NodeMove[]) => void;
|
|
928
|
+
/** Set to make ports grabbable. Dragging one port onto another reports the
|
|
929
|
+
* edge it describes and draws nothing; add it to the data to keep it. */
|
|
930
|
+
onConnect?: (edge: DataEdge) => void;
|
|
931
|
+
/** Whether the canvas's keyboard shortcuts — held Space to pan among them —
|
|
932
|
+
* run. They listen page-wide, so a view-only diagram beside other UI would
|
|
933
|
+
* claim keys meant for the page. Default: on when `onMove` or `onConnect`
|
|
934
|
+
* is set. */
|
|
935
|
+
enableKeybindings?: boolean;
|
|
936
|
+
/** Which ports may be joined. Default: a port may not join itself, and two
|
|
937
|
+
* typed ports must share a type. */
|
|
938
|
+
canConnect?: CanConnect;
|
|
939
|
+
/** How ports look and answer the pointer, and the router a connect's
|
|
940
|
+
* preview draws with. */
|
|
941
|
+
portOptions?: Pick<DiagramContributionOptions<RectPose>, 'fill' | 'stroke' | 'sizePx' | 'hitRadiusPx' | 'cursor' | 'shows' | 'snapRadius' | 'router'>;
|
|
942
|
+
/** How a layout run from {@link DiagramViewApi.layout} behaves: its forces,
|
|
943
|
+
* how many frames an eased layout takes, its easing. */
|
|
944
|
+
live?: Omit<UseLiveLayoutOptions<RectPose>, 'scene' | 'source' | 'algorithm'>;
|
|
765
945
|
/** The smallest scale the initial fit may use. Unset, the whole diagram fits
|
|
766
946
|
* however small that makes it; set, it stops here and the rest is a pan away. */
|
|
767
947
|
minScale?: number;
|
|
948
|
+
/** The largest scale the initial fit may use. Default 1, so a small
|
|
949
|
+
* diagram opens at its own size rather than blown up. */
|
|
950
|
+
maxScale?: number;
|
|
768
951
|
/** Which part of a diagram too big for the box it opens on: its middle
|
|
769
952
|
* (default) or its top-left, where a layered flow begins. */
|
|
770
953
|
anchor?: 'center' | 'start';
|
|
954
|
+
/** Space kept clear around the diagram by the initial fit, in CSS pixels.
|
|
955
|
+
* Default 16. */
|
|
956
|
+
fitPadding?: number;
|
|
957
|
+
/** What the canvas paints behind the diagram. Unset, it is transparent. */
|
|
958
|
+
background?: FillStyle;
|
|
959
|
+
/** The view, controlled. Set it and the initial fit is skipped; pair it
|
|
960
|
+
* with `onViewChange` or panning does nothing. */
|
|
961
|
+
view?: View;
|
|
962
|
+
/** Every view change, from a pan, a zoom or the initial fit. */
|
|
963
|
+
onViewChange?: (view: View) => void;
|
|
771
964
|
className?: string;
|
|
772
965
|
}
|
|
773
|
-
/**
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
966
|
+
/** What a `ref` on `DiagramView` holds. */
|
|
967
|
+
interface DiagramViewApi {
|
|
968
|
+
/** Lay the diagram out again from where its nodes stand, animated. `'force'`
|
|
969
|
+
* (default) relaxes until it settles; any other layout eases to its answer.
|
|
970
|
+
* What moved is reported to `onMove` once the run settles. */
|
|
971
|
+
layout(algorithm?: 'layered' | 'tree' | 'force' | LayoutFn): void;
|
|
972
|
+
/** The run `layout` started: stop it where it stands, or cancel it. */
|
|
973
|
+
live: LiveLayout;
|
|
974
|
+
}
|
|
975
|
+
/** A diagram: drag or wheel to pan, zoom, and pick a node; drag nodes with
|
|
976
|
+
* `onMove`, join ports with `onConnect`. Labels paint only in a registered
|
|
977
|
+
* font family; `diagramScene` defaults to sans-serif, so call
|
|
777
978
|
* `registerCanvasFont('sans-serif')` or text renders blank. */
|
|
778
|
-
declare
|
|
979
|
+
declare const DiagramView: react.ForwardRefExoticComponent<DiagramViewProps & react.RefAttributes<DiagramViewApi>>;
|
|
779
980
|
|
|
780
981
|
/** Keeps a canvas selection and a controlled `selected` prop in step: a prop
|
|
781
982
|
* change is pushed in, and every click reports what the selection holds after
|
|
@@ -783,4 +984,4 @@ declare function DiagramView(props: DiagramViewProps): react.JSX.Element;
|
|
|
783
984
|
* `<SceneCanvas onClick>`. */
|
|
784
985
|
declare function useMirroredSelection(selection: Pick<SelectionApi, 'get' | 'set'>, selected: string | null | undefined, onSelect: ((id: string | null) => void) | undefined): () => void;
|
|
785
986
|
|
|
786
|
-
export { type ApplyLayoutOptions, CONNECT_ACTION_ID, type CanConnect, type ConnectActionOptions, DEFAULT_EDGE_STROKE, DIAGRAM_EDGE, DIAGRAM_LABEL, type DataEdge, type DataNode, type DiagramContributionOptions, type DiagramData, type DiagramEdge, type DiagramLabel, DiagramNode, DiagramNodeLike, DiagramNodeReader, type DiagramSceneData, type DiagramSceneOptions, type DiagramShapeOptions, type DiagramSpec, DiagramView, type DiagramViewProps, EASED_LAYOUTS, EDGE_DERIVE_PATH, type EasedProducerOptions, type EdgeEnd, type EdgeRouteOptions, type EdgeStyle, ForceOptions, type ForceProducerOptions, GRAB_PORT_ACTION_ID, Graph, GraphSource, LABEL_DERIVE_POSE, LAYOUTS, LAYOUT_ACTION_ID, type LabelPoseOptions, type LayoutActionOptions, LayoutFn, LayoutOptions, LayoutResult, type LiveLayout, type LiveLayoutCtx, type LiveLayoutFrame, type LiveLayoutProducer, type NodeStyle, PORT_AFFORDANCE_KIND, PORT_LAYER_ID, type ParticipantPose, type ParticipantScene, type ParticipantSource, type PendingEdge, Port, type PortAffordanceOptions, type PortScratch, PortsOptions, ROUTERS, type RouteRequest, type Router, type UseLiveLayoutOptions, applyLayout, bezier, commitEdgeToScene, connectBinding, createConnectAction, createDiagramContribution, createLayoutAction, createPortAffordance, defaultCanConnect, diagramEdgeOf, diagramLabelOf, diagramPorts, diagramScene, diagramShape, easedProducer, edgeDerivePath, edgeIdOf, forceProducer, grabPortAction, grabPortBindings, labelDerivePose, layoutPoses, orthogonal, portLayer, portScratchOf, registerDiagramShape, resolveEnd, sceneParticipants, straight, useLiveLayout, useMirroredSelection, withDiagramRegistry };
|
|
987
|
+
export { ANCHOR_DERIVE_POSE, type ApplyLayoutOptions, BodySpec, CONNECT_ACTION_ID, type CanConnect, type ConnectActionOptions, DEFAULT_EDGE_STROKE, DIAGRAM_ANCHOR, DIAGRAM_EDGE, DIAGRAM_GROUP, DIAGRAM_LABEL, type DataEdge, type DataGroup, type DataNode, type DiagramAnchor, type DiagramContributionOptions, type DiagramData, type DiagramEdge, DiagramGroup, type DiagramLabel, DiagramNode, DiagramNodeLike, DiagramNodeReader, type DiagramSceneData, type DiagramSceneOptions, type DiagramShapeOptions, type DiagramSpec, DiagramView, type DiagramViewApi, type DiagramViewProps, EASED_LAYOUTS, EDGE_DERIVE_PATH, type EasedProducerOptions, type EdgeEnd, type EdgeRouteOptions, type EdgeStyle, ForceOptions, type ForceProducerOptions, GRAB_PORT_ACTION_ID, GROUP_DERIVE_POSE, Graph, GraphSource, type GroupPoseOptions, LABEL_DERIVE_POSE, LAYOUTS, LAYOUT_ACTION_ID, type LabelPoseOptions, type LayoutActionOptions, LayoutFn, LayoutOptions, LayoutResult, type LiveLayout, type LiveLayoutCtx, type LiveLayoutFrame, type LiveLayoutProducer, MeasureRowText, type NodeMove, type NodeStyle, Outline, PORT_AFFORDANCE_KIND, PORT_LAYER_ID, type ParticipantPose, type ParticipantScene, type ParticipantSource, type PendingEdge, Port, type PortAffordanceOptions, PortAnchor, type PortScratch, PortSpec, PortsOptions, ROUTERS, type RouteRequest, type Router$1 as Router, Row, type UseLiveLayoutOptions, anchorDerivePose, applyLayout, bezier, commitEdgeToScene, connectBinding, createConnectAction, createDiagramContribution, createLayoutAction, createPortAffordance, defaultCanConnect, diagramAnchorOf, diagramEdgeOf, diagramGroupOf, diagramLabelOf, diagramPorts, diagramScene, diagramShape, easedProducer, edgeDerivePath, edgeIdOf, forceProducer, grabPortAction, grabPortBindings, groupDerivePose, labelDerivePose, layoutPoses, orthogonal, portLayer, portScratchOf, registerDiagramShape, resolveEnd, sceneParticipants, straight, useLiveLayout, useMirroredSelection, withDiagramRegistry };
|