@visuallyjs/browser-ui 1.2.6 → 1.2.8

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.
Files changed (53) hide show
  1. package/css/visuallyjs.css +16 -12
  2. package/js/visuallyjs.browser-ui.cjs.js +70 -70
  3. package/js/visuallyjs.browser-ui.esm.js +67 -67
  4. package/package.json +1 -1
  5. package/types/browser-ui/browser-visuallyjs-instance.d.ts +1 -3
  6. package/types/browser-ui/components/edge-type-picker/edge-type-picker.d.ts +6 -2
  7. package/types/browser-ui/components/index.d.ts +1 -0
  8. package/types/browser-ui/components/inspector/index.d.ts +0 -1
  9. package/types/browser-ui/components/inspector/inspector.d.ts +9 -1
  10. package/types/browser-ui/components/palette/auto-edge-connect.d.ts +1 -1
  11. package/types/browser-ui/components/palette/palette-options.d.ts +11 -11
  12. package/types/browser-ui/components/palette/palette.d.ts +2 -2
  13. package/types/browser-ui/components/shape-type-inspector/index.d.ts +1 -0
  14. package/types/browser-ui/components/{inspector → shape-type-inspector}/shape-type-inspector.d.ts +2 -2
  15. package/types/browser-ui/definitions.d.ts +10 -45
  16. package/types/browser-ui/edge-mappings/flowchart-basic.d.ts +28 -0
  17. package/types/browser-ui/plugins/graph-propagation/index.d.ts +26 -0
  18. package/types/browser-ui/plugins/index.d.ts +1 -0
  19. package/types/browser-ui/shape-library/shape-library-definitions.d.ts +25 -4
  20. package/types/browser-ui/shape-library/shape-library.d.ts +1 -1
  21. package/types/browser-ui/surface-renderer/definitions.d.ts +7 -1
  22. package/types/browser-ui/surface-renderer/diagrams/definitions.d.ts +123 -3
  23. package/types/browser-ui/surface-renderer/diagrams/diagram.d.ts +1 -0
  24. package/types/browser-ui/surface-renderer/plugins/palette/palette-plugin.d.ts +1 -2
  25. package/types/browser-ui/surface-renderer/plugins/resizing-tools/definitions.d.ts +64 -0
  26. package/types/browser-ui/surface-renderer/shape-palette-options.d.ts +2 -2
  27. package/types/browser-ui/surface-renderer/shape-palette.d.ts +3 -2
  28. package/types/browser-ui/surface-renderer/surface.d.ts +3 -4
  29. package/types/browser-ui/svg-element-overlay.d.ts +3 -3
  30. package/types/charts/base-chart.d.ts +2 -1
  31. package/types/charts/definitions.d.ts +1 -1
  32. package/types/charts/dual-value-chart.d.ts +2 -1
  33. package/types/charts/legend.d.ts +1 -1
  34. package/types/charts/pie/pie-chart.d.ts +2 -1
  35. package/types/charts/sankey/sankey.d.ts +2 -1
  36. package/types/charts/tooltip.d.ts +2 -1
  37. package/types/charts/util.d.ts +2 -1
  38. package/types/core/graph-propagation/definitions.d.ts +41 -0
  39. package/types/core/graph-propagation/engine.d.ts +63 -0
  40. package/types/core/graph-propagation/index.d.ts +2 -0
  41. package/types/core/index.d.ts +1 -0
  42. package/types/test-support/test-support.d.ts +3 -3
  43. package/types/ui/common/overlay.d.ts +6 -2
  44. package/types/ui/common/paint-style.d.ts +7 -0
  45. package/types/ui/core/core.d.ts +32 -1
  46. package/types/ui/core/definitions.d.ts +49 -0
  47. package/types/ui/core/overlay/custom-overlay.d.ts +2 -2
  48. package/types/ui/core/overlay/label-overlay.d.ts +6 -5
  49. package/types/ui/core/overlay/overlay.d.ts +3 -3
  50. package/types/ui/core/params.d.ts +5 -0
  51. package/types/ui/core/view/edge-options.d.ts +44 -2
  52. package/types/ui/property-mappings/definitions.d.ts +4 -0
  53. package/types/version.d.ts +1 -1
@@ -1,7 +1,8 @@
1
1
  import { LabelBackgroundOptions, LabelPosition, ShapeSet } from "../../shape-library";
2
2
  import { Group, ObjectData, PointXY, Size, Vertex, Node, BeforeConnectInterceptor } from "../../../core";
3
3
  import { DiagramCell } from "./diagram-cell";
4
- import { GridOptions, UIExportOptions, UICoreDefaults, EdgeEventOptions, OverlaySpec, ConnectorSpec, NodeEventOptions, GroupMapping, NodeMapping, AnchorSpec, EdgePropertyMappings, MagnetizeOptions, PaintStyle, OverlayVisibility, EdgeDeleteConfirmationFunction } from "../../../ui";
4
+ import { GridOptions, UIExportOptions, UICoreDefaults, EdgeEventOptions, OverlaySpec, ConnectorSpec, NodeEventOptions, GroupMapping, NodeMapping, AnchorSpec, EdgePropertyMappings, MagnetizeOptions, PaintStyle, OverlayVisibility, EdgeDeleteConfirmationFunction, LabelBackgroundStyle, FontSpec } from "../../../ui";
5
+ import type { BindableViewEvent } from "../../../ui";
5
6
  import { SurfaceSaveData } from "../definitions";
6
7
  import { BrowserElement } from "../../util";
7
8
  import { PaletteMode, AutoEdgeConnectOptions, CanDropOnEdgeFilter } from "../../components/palette/palette-options";
@@ -9,8 +10,67 @@ import { PanOptions, WheelOptions, ZoomOptions } from "../../pan-zoom-options";
9
10
  import { MiniviewPluginOptions, LassoPluginOptions, ResizingToolsModelUpdater, ResizingToolsHandlerFactory, DragGroupsPluginOptions, ResizingToolsResizeMethod, SnaplinesPluginOptions, PanButtonsPluginOptions, LineCrossingsPluginOptions } from "../plugins";
10
11
  import { EdgeSnapOptions, EdgeInputMethod } from "../../edge-handler-base";
11
12
  import { DiagramActionMediator } from "./mediator";
12
- import { OnVertexAddedCallback, FontSpec } from "../../definitions";
13
+ import { OnVertexAddedCallback } from "../../definitions";
13
14
  import { PreparedShape } from "../shape-palette-options";
15
+ import { GraphPropagationEnginePluginOptions } from "../../plugins";
16
+ import type { BrowserUIModel } from "../../browser-ui";
17
+ import type { BrowserUI } from "../../browser-visuallyjs-instance";
18
+ import type { Diagram } from "./diagram";
19
+ /**
20
+ * Payload passed to a cell template event callback.
21
+ * @group Diagrams
22
+ * @category Events
23
+ */
24
+ export interface DiagramCellTemplateEventCallbackPayload<E extends Event = Event> {
25
+ /**
26
+ * The diagram cell whose rendered template contained the matching event target.
27
+ */
28
+ cell: DiagramCell;
29
+ /**
30
+ * The backing vertex for the cell.
31
+ */
32
+ vertex: Node | Group;
33
+ /**
34
+ * The original browser event.
35
+ */
36
+ event: E;
37
+ /**
38
+ * The element inside the rendered shape template that matched the configured selector.
39
+ */
40
+ eventTarget: BrowserElement;
41
+ /**
42
+ * The diagram that owns the cell.
43
+ */
44
+ diagram: Diagram;
45
+ /**
46
+ * The underlying VisuallyJs model.
47
+ */
48
+ model: BrowserUIModel;
49
+ /**
50
+ * The UI that rendered the diagram.
51
+ */
52
+ ui: BrowserUI;
53
+ }
54
+ /**
55
+ * Callback invoked for an event on an element inside a rendered cell template.
56
+ * @group Diagrams
57
+ * @category Events
58
+ */
59
+ export type DiagramCellTemplateEventCallback<E extends Event = Event> = (p: DiagramCellTemplateEventCallbackPayload<E>) => any;
60
+ /**
61
+ * A map of event names to callbacks for a single selector inside a rendered cell template.
62
+ * @group Diagrams
63
+ * @category Events
64
+ */
65
+ export type DiagramCellTemplateEventMap = {
66
+ [K in BindableViewEvent]?: DiagramCellTemplateEventCallback;
67
+ } & Record<string, DiagramCellTemplateEventCallback | undefined>;
68
+ /**
69
+ * A map of CSS selectors to event/callback maps for elements inside rendered cell templates.
70
+ * @group Diagrams
71
+ * @category Events
72
+ */
73
+ export type DiagramCellTemplateEvents = Record<string, DiagramCellTemplateEventMap>;
14
74
  /**
15
75
  * Options for the {@link Diagram.addLink method}
16
76
  * @group Diagrams
@@ -172,6 +232,10 @@ export interface DiagramOptions {
172
232
  * Optional font for edge labels.
173
233
  */
174
234
  labelFont?: FontSpec;
235
+ /**
236
+ * Optional style for the label's background.
237
+ */
238
+ labelBackgroundStyle?: LabelBackgroundStyle;
175
239
  /**
176
240
  * Optional map of event handlers for edges.
177
241
  */
@@ -192,6 +256,35 @@ export interface DiagramOptions {
192
256
  * Styles for the edge highlight box.
193
257
  */
194
258
  highlightStyle?: PaintStyle;
259
+ /**
260
+ * Optional default styles for edges. These are overwritten by edges that have values in their backing data.
261
+ */
262
+ lineStyle?: {
263
+ /**
264
+ * Width of the edge path
265
+ */
266
+ lineWidth?: number;
267
+ /**
268
+ * Width to draw the edge's outline path
269
+ */
270
+ outlineWidth?: number;
271
+ /**
272
+ * Color to paint the edge's path
273
+ */
274
+ color?: string;
275
+ /**
276
+ * Color to paint the edge's outline path
277
+ */
278
+ outlineColor?: string;
279
+ /**
280
+ * Definition of dash pattern to use to draw the edge path
281
+ */
282
+ dashArray?: string;
283
+ /**
284
+ * An array of color stops to use as a linear gradient for the edge path. When this is set, `color` is ignored.
285
+ */
286
+ gradient?: Array<[number, string]>;
287
+ };
195
288
  };
196
289
  /**
197
290
  * Defaults to #FFFFFF
@@ -320,6 +413,26 @@ export interface DiagramOptions {
320
413
  * Optional event mappings for all cells.
321
414
  */
322
415
  events?: NodeEventOptions<any>;
416
+ /**
417
+ * Optional delegated event mappings for elements inside rendered cell templates. Keys are CSS selectors
418
+ * that match elements inside a shape template, and values are maps of event names to callbacks.
419
+ *
420
+ * The callback receives the {@link DiagramCell} associated with the matching element, plus the backing
421
+ * vertex, the original browser event, the matching element, the diagram, the model and the UI.
422
+ *
423
+ * For example:
424
+ *
425
+ * ```ts
426
+ * cells:{
427
+ * templateEvents:{
428
+ * ".delete":{
429
+ * tap:({cell}) => cell.remove()
430
+ * }
431
+ * }
432
+ * }
433
+ * ```
434
+ */
435
+ templateEvents?: DiagramCellTemplateEvents;
323
436
  /**
324
437
  * Optional behaviour mapping for groups in the diagram. For many setups, you won't need to use this, as the other options in the `cells` config are quite extensive and can be used to configure many things. For some setups you may need to provide config for group behaviour, such as whether or not vertices can be dragged in/out, whether the group should be resizable, etc. You can also provide group-specific event mappings here. Any `events` you provide here will be merged with the internal event registrations made by the diagram, but if you provide a `template` it will be ignored.
325
438
  */
@@ -333,6 +446,9 @@ export interface DiagramOptions {
333
446
  * Optional mapping for nodes in the diagram. For many setups, you won't need to use this, as the other options in the `cells` config are quite extensive and can be used to configure many things. Any `events` you provide here will be merged with the internal event registrations made by the diagram, but if you provide a `template` it will be ignored.
334
447
  */
335
448
  nodes?: DiagramNodeMapping;
449
+ /**
450
+ * Options controlling how resize functions.
451
+ */
336
452
  resize?: {
337
453
  /**
338
454
  * Width/height to use for resize handles. Defaults to 20 pixels.
@@ -450,6 +566,10 @@ export interface DiagramOptions {
450
566
  * Controls whether line crossings are shown by a visual cue. Defaults to false. You can either supply a boolean and have the panbuttons plugin initialize with its default settings, or supply your own settings.
451
567
  */
452
568
  lineCrossings?: boolean | LineCrossingsPluginOptions;
569
+ /**
570
+ * If provided, a graph propagation engine will be used to propagate changes to the graph.
571
+ */
572
+ graphPropagation?: GraphPropagationEnginePluginOptions<any>;
453
573
  }
454
574
  /**
455
575
  * Options for a palette for a diagram.
@@ -514,7 +634,7 @@ export interface DiagramPaletteOptions {
514
634
  /**
515
635
  * If true, shapes can be dropped on edges in the canvas. The edge on which the shape was dropped has its target set to be the new node, and a new edge is added with the new node as source and the original edge's target as target.
516
636
  */
517
- allowDropOnEdge?: boolean | CanDropOnEdgeFilter<BrowserElement>;
637
+ allowDropOnEdge?: boolean | CanDropOnEdgeFilter;
518
638
  /**
519
639
  * If `allowDropOnEdge` is also true, this flag instructs the shape palette to provide a default `edgeDropHandler` to the underlying palette which will attempt to find a source and target port on the new vertex, and connect to those instead of to the vertex itself. Defaults to true.
520
640
  * @advanced
@@ -33,6 +33,7 @@ export declare class Diagram {
33
33
  _mediator: DiagramActionMediator;
34
34
  constructor(model: BrowserUIModel, container: BrowserElement, options: DiagramOptions);
35
35
  private _createView;
36
+ private _bindTemplateEvents;
36
37
  /**
37
38
  * @internal
38
39
  * @param v
@@ -1,13 +1,12 @@
1
1
  import { BaseBrowserUIPlugin, BrowserUIPlugin } from "../../../plugins";
2
2
  import { PaletteOptions } from "../../../components";
3
- import { BrowserElement } from "../../../util";
4
3
  import { BrowserUI } from "../../../browser-visuallyjs-instance";
5
4
  /**
6
5
  * Options for the palette plugin
7
6
  * @group Plugins
8
7
  * @category Palette
9
8
  */
10
- export interface PalettePluginOptions extends PaletteOptions<BrowserElement> {
9
+ export interface PalettePluginOptions extends PaletteOptions {
11
10
  }
12
11
  export declare class PalettePlugin extends BaseBrowserUIPlugin implements BrowserUIPlugin<PalettePluginOptions> {
13
12
  static type: string;
@@ -372,6 +372,70 @@ export declare const ATT_VJS_RESIZABLE = "data-vjs-resizable";
372
372
  * @context resizingTools
373
373
  */
374
374
  export declare const ATT_VJS_ROTATABLE = "data-vjs-rotatable";
375
+ /**
376
+ * The color to use as the stroke for a resize handle
377
+ * @group Plugins
378
+ * @category Resizing Tools
379
+ * @cssVariable
380
+ * @context resizingTools
381
+ */
382
+ export declare const CSS_VARIABLE_RESIZE_HANDLE_COLOR = "--vjs-resize-handle-color";
383
+ /**
384
+ * The color to use as the stroke for a resize handle when it is in use
385
+ * @group Plugins
386
+ * @category Resizing Tools
387
+ * @cssVariable
388
+ * @context resizingTools
389
+ */
390
+ export declare const CSS_VARIABLE_RESIZE_ACTIVE_COLOR = "--vjs-resize-active-color";
391
+ /**
392
+ * The size to use for a resize handle. For circles this denotes the diameter; for rectangles it denotes the side length.
393
+ * @group Plugins
394
+ * @category Resizing Tools
395
+ * @cssVariable
396
+ * @context resizingTools
397
+ */
398
+ export declare const CSS_VARIABLE_RESIZE_HANDLE_SIZE = "--vjs-resize-handle-size";
399
+ /**
400
+ * The color to use as the fill for a resize handle
401
+ * @group Plugins
402
+ * @category Resizing Tools
403
+ * @cssVariable
404
+ * @context resizingTools
405
+ */
406
+ export declare const CSS_VARIABLE_RESIZE_HANDLE_FILL_COLOR = "--vjs-resize-handle-fill-color";
407
+ /**
408
+ * The stroke width to use on the resize frame
409
+ * @group Plugins
410
+ * @category Resizing Tools
411
+ * @cssVariable
412
+ * @context resizingTools
413
+ */
414
+ export declare const CSS_VARIABLE_RESIZE_FRAME_LINE_WIDTH = "--vjs-resize-frame-line-width";
415
+ /**
416
+ * The length of the leader line for the rotate handle
417
+ * @group Plugins
418
+ * @category Resizing Tools
419
+ * @cssVariable
420
+ * @context resizingTools
421
+ */
422
+ export declare const CSS_VARIABLE_RESIZE_ROTATE_LEADER_LENGTH = "--vjs-resize-rotate-leader-length";
423
+ /**
424
+ * The stroke width of the leader line for the rotate handle
425
+ * @group Plugins
426
+ * @category Resizing Tools
427
+ * @cssVariable
428
+ * @context resizingTools
429
+ */
430
+ export declare const CSS_VARIABLE_RESIZE_ROTATE_LEADER_WIDTH = "--vjs-resize-rotate-leader-width";
431
+ /**
432
+ * The diameter of the rotate handle
433
+ * @group Plugins
434
+ * @category Resizing Tools
435
+ * @cssVariable
436
+ * @context resizingTools
437
+ */
438
+ export declare const CSS_VARIABLE_RESIZE_ROTATE_HANDLE_SIZE = "--vjs-resize-rotate-handle-size";
375
439
  /** @internal */
376
440
  export declare const ATT_DATA_DIR = "data-dir";
377
441
  /**
@@ -55,7 +55,7 @@ export interface ShapePaletteOptions<T extends ObjectData> {
55
55
  /**
56
56
  * Optional data generator to allow you to specify initial data for some element to be dragged. Note that you cannot override the object's `type` with this function. The palette will set the new object's type to match the type of the element that the user is dragging from the palette.
57
57
  */
58
- dataGenerator?: DataGeneratorFunction<T>;
58
+ dataGenerator?: DataGeneratorFunction;
59
59
  /**
60
60
  * Optional size to use for icons. Defaults to 150x100 pixels. If you provide this but not `dragSize` this size will also be used for an icon that is being dragged.
61
61
  */
@@ -102,7 +102,7 @@ export interface ShapePaletteOptions<T extends ObjectData> {
102
102
  /**
103
103
  * If true, shapes can be dropped on edges in the canvas. The edge on which the shape was dropped has its target set to be the new node, and a new edge is added with the new node as source and the original edge's target as target.
104
104
  */
105
- allowDropOnEdge?: boolean | CanDropOnEdgeFilter<T>;
105
+ allowDropOnEdge?: boolean | CanDropOnEdgeFilter;
106
106
  /**`
107
107
  * If `allowDropOnEdge` is also true, this flag instructs the shape palette to provide a default `edgeDropHandler` to the underlying palette which will attempt to find a source and target port on the new vertex, and connect to those instead of to the vertex itself. Defaults to true.
108
108
  * @advanced
@@ -15,9 +15,10 @@ export declare const ATTRIBUTE_DATA_SHAPE_ID = "data-shape-id";
15
15
  */
16
16
  export declare class ShapePalette<T extends ObjectData> {
17
17
  private ui;
18
+ _$_iconTemplateEngine: BrowserUiRecado;
18
19
  _$_templateEngine: BrowserUiRecado;
19
- _$_palette: Palette<ObjectData>;
20
- _$_userDataGenerator: DataGeneratorFunction<T>;
20
+ _$_palette: Palette;
21
+ _$_userDataGenerator: DataGeneratorFunction;
21
22
  _$_showGroups: boolean;
22
23
  /**
23
24
  * @internal
@@ -206,27 +206,26 @@ export declare class Surface extends BrowserUI<SurfaceEvents> implements Support
206
206
  }): void;
207
207
  $selectionCleared(sel: VisuallyJsSelection): any;
208
208
  /**
209
- * Save the dataset and the current state of the Surface - its pan and zoom settings.
209
+ * Save the dataset and the current state of the Surface - its pan and zoom settings, as well as data for any registered data hooks.
210
210
  * @param options
211
211
  * @tags input/output
212
212
  */
213
213
  save(options?: UIExportOptions): SurfaceSaveData;
214
214
  /**
215
- * Load the dataset and the current state of the Surface - its pan and zoom settings.
215
+ * Load the dataset and the current state of the Surface - its pan and zoom settings, as well as data for any registered data hooks.
216
216
  * @param data
217
217
  * @param onload Optional function to invoke after load.
218
+ * @tags input/output
218
219
  */
219
220
  load(data: SurfaceSaveData, onload?: Function): void;
220
221
  /**
221
222
  * Start editing the given edge or connection, optionally with the given edit parameters.
222
223
  * @param edgeOrConnection
223
224
  * @param params
224
- *
225
225
  */
226
226
  startEditingPath<T extends ConnectorEditorActivateParams<BrowserElement>>(edgeOrConnection: Edge | Connection<BrowserElement>, params?: T): void;
227
227
  /**
228
228
  * Stop editing any connector paths.
229
- *
230
229
  */
231
230
  stopEditingPath(): void;
232
231
  /**
@@ -1,4 +1,4 @@
1
- import { LabelOverlay, PaintStyle, Overlay, OverlayPaintParams, SimpleShapeOverlay } from "../ui";
1
+ import { LabelOverlay, PaintStyle, Overlay, OverlayPaintParams, SimpleShapeOverlay, OverlayOptions, LabelOverlayOptions } from "../ui";
2
2
  import { Extents, PointXY } from "../core";
3
3
  import { BrowserUI } from "./browser-visuallyjs-instance";
4
4
  /**
@@ -46,11 +46,11 @@ export declare function paintSVGLabelOverlay(instance: BrowserUI, o: SVGLabelOve
46
46
  * @internal
47
47
  */
48
48
  export declare function destroySVGOverlay(o: SVGElementOverlay<any>, force?: boolean): void;
49
- export declare abstract class SVGElementOverlay<EL> extends Overlay<EL> {
49
+ export declare abstract class SVGElementOverlay<EL, O extends OverlayOptions = OverlayOptions> extends Overlay<EL, O> {
50
50
  contentElements: Array<SVGElement>;
51
51
  backgroundContentElements: Array<SVGElement>;
52
52
  }
53
- export interface SVGLabelOverlay<EL> extends SVGElementOverlay<EL>, LabelOverlay<EL> {
53
+ export interface SVGLabelOverlay<EL> extends SVGElementOverlay<EL, LabelOverlayOptions>, LabelOverlay<EL> {
54
54
  textElement: SVGTextElement;
55
55
  bgElement: SVGRectElement;
56
56
  }
@@ -1,6 +1,7 @@
1
1
  import { OptimisticEventGenerator, ColorGenerator, PointXY, ObjectData, DataSource, Node, Group } from "../core";
2
- import { EventManager, BrowserElement, FontSpec, ImageExportOptions, ImageReadyFunction } from "../browser-ui";
2
+ import { EventManager, BrowserElement, ImageExportOptions, ImageReadyFunction } from "../browser-ui";
3
3
  import { ChartSVGElement } from "./util";
4
+ import { FontSpec } from "../ui";
4
5
  import { ChartLegend, LegendSpec } from "./legend";
5
6
  import { TooltipOptions } from "./tooltip";
6
7
  import { ChartDimensions } from "./definitions";
@@ -3,7 +3,7 @@ import { AxisTitleAlignment, AxisTitleSpec } from "./base-chart";
3
3
  import { ChartSVGElement, SteppedScale } from "./util";
4
4
  import { XYChartOptions } from "./base-xy-chart";
5
5
  import { DualValueSeriesOptions } from "./series";
6
- import { FontSpec } from "../browser-ui";
6
+ import { FontSpec } from "../ui";
7
7
  /**
8
8
  * @internal
9
9
  */
@@ -1,8 +1,9 @@
1
1
  import { XYChart } from "./base-xy-chart";
2
2
  import { DualValueChartOptions, ValueAxis, ValueAxisDefinition } from "./definitions";
3
3
  import { ObjectData } from "../core";
4
- import { BrowserElement, FontSpec } from "../browser-ui";
4
+ import { BrowserElement } from "../browser-ui";
5
5
  import { ChartSVGElement } from "./util";
6
+ import { FontSpec } from "../ui";
6
7
  import { DualValueChartSeries, DualValueSeriesOptions } from "./series";
7
8
  import { DualValueAxisTooltip, TooltipOptions } from "./tooltip";
8
9
  /**
@@ -1,4 +1,4 @@
1
- import { FontSpec } from "../browser-ui";
1
+ import { FontSpec } from "../ui";
2
2
  /**
3
3
  * Constant identifying vertically stacked legend
4
4
  * @group Charts
@@ -1,7 +1,8 @@
1
1
  import { SeriesBasedChart, SeriesBasedChartOptions } from "../series-based-chart";
2
2
  import { ObjectData } from "../../core";
3
3
  import { ChartSVGElement } from "../util";
4
- import { BrowserElement, FontSpec } from "../../browser-ui";
4
+ import { BrowserElement } from "../../browser-ui";
5
+ import { FontSpec } from "../../ui";
5
6
  import { ChartDimensions } from "../definitions";
6
7
  import { RealisedSeries, RecordBasedSeriesOptions } from "../series";
7
8
  import { CategoryValueTooltip, TooltipOptions } from "../tooltip";
@@ -1,6 +1,7 @@
1
1
  import { SankeyLayer } from './preprocessor';
2
2
  import { Node, Edge, Vertex, DataSource, VisuallyJsDefaultJSON } from "../../core";
3
- import { BrowserElement, BrowserUIModel, FontSpec } from "../../browser-ui";
3
+ import { FontSpec } from "../../ui";
4
+ import { BrowserElement, BrowserUIModel } from "../../browser-ui";
4
5
  import { ChartSVGElement } from "../util";
5
6
  import { BaseChart, BaseChartOptions } from "../base-chart";
6
7
  import { Tooltip, TooltipOptions } from "../tooltip";
@@ -1,5 +1,6 @@
1
1
  import { PointXY, ElementFacade, AbstractEntry, ObjectData } from "../core";
2
- import { BrowserUiRecado, BrowserElement, FontSpec } from "../browser-ui";
2
+ import { BrowserUiRecado, BrowserElement } from "../browser-ui";
3
+ import { FontSpec } from "../ui";
3
4
  import { RealisedSeries } from "./series/definitions";
4
5
  import { DualValueChartSeries } from "./series";
5
6
  /**
@@ -1,6 +1,7 @@
1
- import { BrowserElement, FontSpec, FontStyle } from "../browser-ui";
1
+ import { BrowserElement } from "../browser-ui";
2
2
  import { BaseChart } from "./base-chart";
3
3
  import { RectangleXY } from "../core";
4
+ import { FontSpec, FontStyle } from "../ui";
4
5
  import { AxisCommon, CategoryAxis, ValueAxis } from "./definitions";
5
6
  /**
6
7
  * internal candidate for a stepped scale.
@@ -0,0 +1,41 @@
1
+ import { Node } from "../model/graph";
2
+ /**
3
+ * Terminal id used when an edge connects directly to a node or group instead of a named port.
4
+ * For example, junctions and probes use this as their implicit input/output terminal.
5
+ */
6
+ export declare const DEFAULT_TERMINAL = "default";
7
+ /**
8
+ * Result returned by a node calculator.
9
+ * @typeParam ValueType Defines the type of the node's output values.
10
+ * @typeParam StateType Defines the type of the node's internal state.
11
+ */
12
+ export type NodeEvaluation<ValueType, StateType = unknown> = {
13
+ /**
14
+ * Values made available to downstream edges, keyed by terminal id. Keys are port ids such as"out"`, or `DEFAULT_TERMINAL` for direct node connections
15
+ */
16
+ outputs?: Record<string, ValueType | undefined>;
17
+ /**
18
+ * Derived node state (such as display text, validation details, or cached intermediate results) written to the node's configured state property.
19
+ */
20
+ state?: StateType;
21
+ };
22
+ /**
23
+ * Helper API passed to calculators so they can read upstream values without knowing graph details.
24
+ * @typeParam ValueType Defines the type of the node's output values.
25
+ */
26
+ export interface EvaluationContext<ValueType> {
27
+ /**
28
+ * Reads the value connected to one input terminal. Omit `terminalId` or pass `DEFAULT_TERMINAL` for direct node-body connections. Otherwise terminalId is assumed to map to a port ID on the node.
29
+ */
30
+ input: (terminalId?: string) => ValueType | undefined;
31
+ /**
32
+ * Reads named input terminals in order. When omitted, reads every edge connected directly to the node body, in edge order.
33
+ */
34
+ inputs: (terminalIds?: string[]) => Array<ValueType | undefined>;
35
+ }
36
+ /**
37
+ * Evaluates a node from its current upstream inputs - the function has access to the `input(...)` and `inputs(..)` methods on the evaluation context that is passed in, for resolving the input values on the node.
38
+ * @typeParam ValueType Defines the type of the node's output values.
39
+ * @typeParam StateType Defines the type of the node's internal state.
40
+ */
41
+ export type Calculator<ValueType, StateType = unknown> = (node: Node, context: EvaluationContext<ValueType>) => NodeEvaluation<ValueType, StateType> | undefined;
@@ -0,0 +1,63 @@
1
+ import { VisuallyJsModel } from "../toolkit";
2
+ import { Calculator } from "./definitions";
3
+ /**
4
+ * Full calculation output before it is written back to the model.
5
+ */
6
+ type CalculationResult<ValueType, StateType> = {
7
+ /** Propagated values keyed by concrete vertex id, for example `nodeId.out`. */
8
+ values: Map<string, ValueType>;
9
+ /** Computed node states keyed by node or group id. */
10
+ states: Map<string, StateType>;
11
+ };
12
+ /**
13
+ * Propagates computed values through a VisuallyJS graph.
14
+ *
15
+ * The engine treats each node or group as the unit of computation. A calculator is registered per
16
+ * vertex type, reads upstream values through an `EvaluationContext`, and returns output terminal
17
+ * values plus optional internal state for that vertex.
18
+ *
19
+ * Output keys are terminal ids: use a port id for named ports, or `DEFAULT_TERMINAL` for edges
20
+ * connected directly to the node/group body. During propagation, the engine maps those terminal ids
21
+ * back to concrete graph vertices and writes propagated values to `property` on target vertices.
22
+ *
23
+ * Calculator `state` is not propagated across edges. It is written to the owning node/group under
24
+ * `stateProperty`, making it suitable for display data, validation results, summaries, or cached
25
+ * derived values.
26
+ *
27
+ * To integrate, define calculators keyed by node/group type, construct the engine with a
28
+ * `VisuallyJsModel`, and read propagated values from vertices using `property` and computed state
29
+ * from nodes/groups using `stateProperty`.
30
+ */
31
+ export declare class GraphPropagationEngine<ValueType, StateType = unknown> {
32
+ private model;
33
+ private calculators;
34
+ private _suspended;
35
+ private _property;
36
+ private _stateProperty;
37
+ /**
38
+ * Creates a propagation engine and binds it to model update events.
39
+ *
40
+ * Edge additions/removals and data updates on connected vertices trigger recalculation on the
41
+ * next animation frame. Updates produced by the engine are applied in one model transaction.
42
+ *
43
+ * @param model Model whose nodes, groups, ports, and edges should participate in propagation.
44
+ * @param calculators Calculator functions keyed by node/group type.
45
+ * @param property Data property used for propagated vertex values. Defaults to `"value"`.
46
+ * @param stateProperty Data property used for computed node/group state. Defaults to `"computed"`.
47
+ */
48
+ constructor(model: VisuallyJsModel, calculators: Record<string, Calculator<ValueType, StateType>>, property?: string, stateProperty?: string);
49
+ /**
50
+ * Runs propagation immediately and writes the result back to the model.
51
+ *
52
+ * `knownValues` can seed the value cache for this run. Keys must be concrete vertex ids, such
53
+ * as a node id or full port id. This is useful when an edited source value is already known and
54
+ * should be used before the model has been fully re-read.
55
+ */
56
+ calculate(knownValues?: Record<string, ValueType>): CalculationResult<ValueType, StateType>;
57
+ /**
58
+ * The main entry point for the calculation. Iterates through all nodes, resolves their new state, and updates the model if the state has changed.
59
+ */
60
+ private _calculate;
61
+ private _apply;
62
+ }
63
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from "./definitions";
2
+ export * from "./engine";
@@ -8,6 +8,7 @@ export * from './model/path';
8
8
  export * from './model/anchor';
9
9
  export * from './datamodel/data-model';
10
10
  export * from './datamodel/vertex-definition';
11
+ export * from './graph-propagation';
11
12
  export * from './layout';
12
13
  export * from "./geom";
13
14
  export * from './color-generator';
@@ -788,9 +788,9 @@ export declare class TestHarness {
788
788
  private _addFromPaletteInit;
789
789
  private _addFromPalette;
790
790
  private _addFromPaletteASync;
791
- dragFromPalette(palette: Palette<any>, selector: string, options?: any, metaKeys?: Record<string, boolean>): void;
792
- dragFromPaletteAsync(palette: Palette<any>, selector: string, options?: any, metaKeys?: Record<string, boolean>): PaletteDragHarness;
793
- tapFromPalette(palette: Palette<any>, selector: string, options?: any): void;
791
+ dragFromPalette(palette: Palette, selector: string, options?: any, metaKeys?: Record<string, boolean>): void;
792
+ dragFromPaletteAsync(palette: Palette, selector: string, options?: any, metaKeys?: Record<string, boolean>): PaletteDragHarness;
793
+ tapFromPalette(palette: Palette, selector: string, options?: any): void;
794
794
  /**
795
795
  * Trigger a mousedown event on the edge with the given id.
796
796
  * @param edgeId
@@ -1,7 +1,7 @@
1
1
  import { PaintStyle } from './paint-style';
2
2
  import { OverlayEvents, OverlayVisibility } from "../core/overlay/overlay";
3
- import { FontSpec } from "../../browser-ui";
4
3
  import { Edge } from "../../core";
4
+ import { FontSpec, LabelBackgroundStyle } from "../core";
5
5
  /**
6
6
  * Base options for an overlay.
7
7
  * @group Edges
@@ -93,7 +93,11 @@ export interface LabelOverlayOptions extends OverlayOptions {
93
93
  */
94
94
  font?: FontSpec;
95
95
  /**
96
- * Sets whether the label can be rotated to match the gradient of the connector at that location at which it is positioned. If you supply boolean true here, the label will be made rotatable in "legible" mode, in which VisuallyJs ensures that the label is always easy to read, by avoiding rotating the text so that it is upside down or other awkward to read. You can set "strict" mode, which will rotate the label to the appropriate angle regardless of whether or not it will make the label difficult to read.
96
+ * Optional style for the label's background.
97
+ */
98
+ backgroundStyle?: LabelBackgroundStyle;
99
+ /**
100
+ * Sets whether the label can be rotated to match the gradient of the connector at that location at which it is positioned. If you supply boolean true here, the label will be made rotatable, in "legible" mode - in which VisuallyJs ensures that the label is legible by avoiding rotating the text so that it is upside down or otherwise awkward to read. You can set "strict" mode, which will rotate the label to the appropriate angle regardless of whether or not it will make the label difficult to read. If you supply boolean false, the label will not be rotatable in any situation.
97
101
  */
98
102
  rotatable?: boolean | "legible" | "strict" | null;
99
103
  }
@@ -1,3 +1,4 @@
1
+ import { LineStyle } from "../core";
1
2
  /**
2
3
  * Basic style definition for an edge
3
4
  * @group UI
@@ -33,3 +34,9 @@ export interface PaintStyle {
33
34
  */
34
35
  gradient?: Array<[number, string]>;
35
36
  }
37
+ /**
38
+ * @internal
39
+ * @param ls
40
+ * @param p
41
+ */
42
+ export declare function $transferLineStyleToPaintStyle(ls: LineStyle, p: PaintStyle): void;