@visuallyjs/browser-ui 1.2.5 → 1.2.7

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 (43) hide show
  1. package/css/visuallyjs.css +16 -12
  2. package/js/visuallyjs.browser-ui.cjs.js +64 -64
  3. package/js/visuallyjs.browser-ui.esm.js +63 -63
  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/inspector/inspector.d.ts +9 -1
  8. package/types/browser-ui/components/palette/auto-edge-connect.d.ts +1 -1
  9. package/types/browser-ui/components/palette/palette-options.d.ts +11 -11
  10. package/types/browser-ui/components/palette/palette.d.ts +2 -2
  11. package/types/browser-ui/definitions.d.ts +19 -46
  12. package/types/browser-ui/edge-mappings/flowchart-basic.d.ts +28 -0
  13. package/types/browser-ui/shape-library/shape-library-definitions.d.ts +46 -8
  14. package/types/browser-ui/shape-library/shape-library.d.ts +14 -8
  15. package/types/browser-ui/surface-renderer/definitions.d.ts +7 -1
  16. package/types/browser-ui/surface-renderer/diagrams/definitions.d.ts +41 -4
  17. package/types/browser-ui/surface-renderer/plugins/palette/palette-plugin.d.ts +1 -2
  18. package/types/browser-ui/surface-renderer/plugins/resizing-tools/definitions.d.ts +64 -0
  19. package/types/browser-ui/surface-renderer/shape-palette-options.d.ts +2 -2
  20. package/types/browser-ui/surface-renderer/shape-palette.d.ts +2 -2
  21. package/types/browser-ui/surface-renderer/surface.d.ts +3 -4
  22. package/types/browser-ui/svg-element-overlay.d.ts +3 -3
  23. package/types/browser-ui/svg-util.d.ts +3 -1
  24. package/types/charts/base-chart.d.ts +2 -1
  25. package/types/charts/definitions.d.ts +1 -1
  26. package/types/charts/dual-value-chart.d.ts +2 -1
  27. package/types/charts/legend.d.ts +1 -1
  28. package/types/charts/pie/pie-chart.d.ts +2 -1
  29. package/types/charts/sankey/sankey.d.ts +2 -1
  30. package/types/charts/tooltip.d.ts +2 -1
  31. package/types/charts/util.d.ts +2 -1
  32. package/types/test-support/test-support.d.ts +3 -3
  33. package/types/ui/common/overlay.d.ts +6 -2
  34. package/types/ui/common/paint-style.d.ts +7 -0
  35. package/types/ui/core/core.d.ts +32 -1
  36. package/types/ui/core/definitions.d.ts +49 -0
  37. package/types/ui/core/overlay/custom-overlay.d.ts +2 -2
  38. package/types/ui/core/overlay/label-overlay.d.ts +6 -5
  39. package/types/ui/core/overlay/overlay.d.ts +3 -3
  40. package/types/ui/core/params.d.ts +5 -0
  41. package/types/ui/core/view/edge-options.d.ts +44 -2
  42. package/types/ui/property-mappings/definitions.d.ts +4 -0
  43. package/types/version.d.ts +1 -1
@@ -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
@@ -16,8 +16,8 @@ export declare const ATTRIBUTE_DATA_SHAPE_ID = "data-shape-id";
16
16
  export declare class ShapePalette<T extends ObjectData> {
17
17
  private ui;
18
18
  _$_templateEngine: BrowserUiRecado;
19
- _$_palette: Palette<ObjectData>;
20
- _$_userDataGenerator: DataGeneratorFunction<T>;
19
+ _$_palette: Palette;
20
+ _$_userDataGenerator: DataGeneratorFunction;
21
21
  _$_showGroups: boolean;
22
22
  /**
23
23
  * @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 { BrowserElement } from "./util";
2
2
  import { GradientSpec } from "../core";
3
3
  import { SvgConnector } from "./svg-element-connector";
4
+ import { LabelPosition } from "./shape-library";
4
5
  export type ElementAttributes = Record<string, string | number | object>;
5
6
  export declare function $attr(node: BrowserElement, attributes: ElementAttributes): void;
6
7
  export declare function $svgNode(name: string, attributes?: ElementAttributes, style?: Record<string, any>, clazz?: string): SVGElement;
@@ -22,6 +23,7 @@ export declare function $appendAtIndex(svg: SVGElement, path: SVGElement, idx: n
22
23
  * @param textElement
23
24
  * @param text
24
25
  * @param maxWidth
26
+ * @param textPosition Where the text is placed relative to its context. This has a bearing on how we adjust the `dy` attribute of the initial span.
25
27
  * @internal
26
28
  */
27
- export declare function convertToMultilineText(textElement: SVGTextElement, text: string, maxWidth: number): SVGTextElement;
29
+ export declare function convertToMultilineText(textElement: SVGTextElement, text: string, maxWidth: number, textPosition: LabelPosition): SVGTextElement;
@@ -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.
@@ -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;
@@ -15,7 +15,7 @@ import { GroupMapping, NodeMapping, NodeOrGroupMapping, PortMapping, VertexMappi
15
15
  import { Magnetizer, MagnetizeResult } from "../../core/magnetizer";
16
16
  import { AbstractLayout, LayoutParameters, LayoutResultSet } from "../../core/layout/abstract-layout";
17
17
  import { DataSource, EdgeAddedParams, EdgeRemovedParams, EdgeSourceChangedParams, EdgeTargetChangedParams, Extents, FilterableDataset, Grid, GroupAddedParams, GroupMemberAddedParams, GroupMemberRemovedParams, GroupRemovedParams, NodeAddedParams, NodeRemovedParams, OptimisticEventGenerator, PointXY, RectangleXY, VisuallyJsSelection, Size, VisuallyJsRenderer, VertexUpdatedParams, VisuallyJsModel, SaveOptions, Rotations, AbstractLayoutAdapter } from "../../core";
18
- import { DataHook, ElementType, EnclosedVerticesOptions, GroupContentAreaInfo, GroupResizeResult, IntersectingVerticesOptions, UICapabilities, UIExportOptions, UISaveData, ViewportBounds, ZoomToElementsOptions, ZoomToFitIfNecessaryOptions, ZoomToFitOptions } from "./definitions";
18
+ import { DataHook, ElementType, EnclosedVerticesOptions, FontStyle, GroupContentAreaInfo, GroupResizeResult, IntersectingVerticesOptions, UICapabilities, UIExportOptions, UISaveData, ViewportBounds, ZoomToElementsOptions, ZoomToFitIfNecessaryOptions, ZoomToFitOptions } from "./definitions";
19
19
  import { GridProfile } from "./grid-profile";
20
20
  import { MagnetizeProfile } from "./magnetize-profile";
21
21
  import { UIPlugin, UIPluginOptions, UIPluginSpec } from "../plugins/definitions";
@@ -78,6 +78,30 @@ export interface LineStyle {
78
78
  * Definition of dash pattern to use to draw the edge path
79
79
  */
80
80
  dashArray?: string;
81
+ /**
82
+ * An array of color stops to use as a linear gradient for the edge path. When this is set, `color` is ignored.
83
+ */
84
+ gradient?: Array<[number, string]>;
85
+ /**
86
+ * Label to show on the edge
87
+ */
88
+ label?: string;
89
+ /**
90
+ * Location for the label, defaults to 0.5
91
+ */
92
+ labelLocation?: number;
93
+ /**
94
+ * Font size to use; defaults to whatever the browser decides given the context
95
+ */
96
+ fontSize?: number;
97
+ /**
98
+ * Font style to use; defaults to whatever the browser decides given the context
99
+ */
100
+ fontStyle?: FontStyle;
101
+ /**
102
+ * Font size to use; defaults to whatever the browser decides given the context
103
+ */
104
+ fontFamily?: string;
81
105
  }
82
106
  /**
83
107
  * Base UI for apps and diagrams.
@@ -375,6 +399,13 @@ export declare abstract class UICore<EL, EVT = CoreUIEvent> extends OptimisticEv
375
399
  */
376
400
  $_extractSimpleEdgeStyles(data: ObjectData, o: Record<string, any>): boolean;
377
401
  private _doRenderEdgeNew;
402
+ /**
403
+ * If simple edge styles are active, merge properties from the edge data on top of the given paint style.
404
+ * @param edge
405
+ * @param paintStyle
406
+ * @internal
407
+ */
408
+ $realiseEdgePaintStyle(edge: Edge, paintStyle: PaintStyle): PaintStyle;
378
409
  /**
379
410
  * @internal
380
411
  */
@@ -243,7 +243,13 @@ export interface UIExportOptions extends ExportOptions {
243
243
  * @category Input and Output
244
244
  */
245
245
  export interface UISaveData {
246
+ /**
247
+ * The current zoom level
248
+ */
246
249
  zoom: number;
250
+ /**
251
+ * Data exported from the model
252
+ */
247
253
  data: any;
248
254
  }
249
255
  /**
@@ -292,7 +298,15 @@ export interface ViewportBounds {
292
298
  * @category Model
293
299
  */
294
300
  export interface DataHook {
301
+ /**
302
+ * Notification that data has been loaded.
303
+ * @param d
304
+ */
295
305
  load: (d: UISaveData) => any;
306
+ /**
307
+ * Notification that data is being saved. Your hook can write its data to `d`.
308
+ * @param d
309
+ */
296
310
  save: (d: UISaveData) => any;
297
311
  }
298
312
  /**
@@ -578,4 +592,39 @@ export declare enum UICapabilities {
578
592
  vertexResize = "vertexResize",
579
593
  vertexDrawing = "vertexDrawing"
580
594
  }
595
+ /**
596
+ * Style for a font - oblique, italic or normal.
597
+ * @group UI
598
+ * @category Definitions
599
+ */
600
+ export type FontStyle = "normal" | "oblique" | "italic";
601
+ /**
602
+ * Font weight to use (e.g., "normal", "bold", "100", "300").
603
+ * @group UI
604
+ * @category Definitions
605
+ */
606
+ export type FontWeight = string | number;
607
+ /**
608
+ * Specs for a font. The default values depend on the context.
609
+ * @group UI
610
+ * @category Definitions
611
+ */
612
+ export interface FontSpec {
613
+ /**
614
+ * Size of the font. Default value depends on the context this spec occurs in.
615
+ */
616
+ size?: number;
617
+ /**
618
+ * Font style to use. Default value depends on the context this spec occurs in.
619
+ */
620
+ style?: FontStyle;
621
+ /**
622
+ * Font weight to use (e.g., "normal", "bold", "100", "300"). Defaults to null, which browsers treat as "normal".
623
+ */
624
+ weight?: FontWeight;
625
+ /**
626
+ * Font family to use.
627
+ */
628
+ family?: string;
629
+ }
581
630
  export {};
@@ -1,6 +1,6 @@
1
1
  import { Overlay } from "./overlay";
2
2
  import { UICore } from "../core";
3
- import { OverlayOptions } from "../../common";
3
+ import { InternalOverlayOptions, OverlayOptions } from "../../common";
4
4
  import { Connection } from "../connector/connection-impl";
5
5
  import { Edge, ObjectData, VisuallyJsModel } from "../../../core";
6
6
  import { BrowserUI } from "../../../browser-ui";
@@ -45,7 +45,7 @@ export declare class CustomOverlayImpl<EL> extends Overlay<EL> implements Custom
45
45
  rotatable: boolean | "strict" | "legible" | null;
46
46
  constructor(instance: UICore<EL>, connection: Connection<EL>, p: CustomOverlayOptions<EL>);
47
47
  type: string;
48
- updateFrom(d: any, context: ObjectData): void;
48
+ updateFrom(d: InternalOverlayOptions, context: ObjectData): void;
49
49
  }
50
50
  export interface CustomOverlayHolder<EL> extends CustomOverlayImpl<EL> {
51
51
  contentElement: EL;
@@ -1,15 +1,15 @@
1
1
  import { Overlay } from "./overlay";
2
- import { UICore } from "../core";
2
+ import { LineStyle, UICore } from "../core";
3
3
  import { LabelOverlayOptions } from "../../common";
4
4
  import { Connection } from "../connector/connection-impl";
5
5
  import { ObjectData } from "../../../core";
6
- import { FontSpec } from "../../../browser-ui";
6
+ import { FontSpec } from "../definitions";
7
7
  /**
8
8
  * An overlay that draws some text. By default this overlay will use an HTML element, and that element's parent will be the surface canvas, unless the container is an SVG element, in which case the overlay will use an SVG element. You can set `useHTMLElement:false` in the options if you want the overlay to use an SVG element regardless of the container element type.
9
9
  * @group Edges
10
10
  * @category Overlays
11
11
  */
12
- export declare class LabelOverlay<EL> extends Overlay<EL> {
12
+ export declare class LabelOverlay<EL> extends Overlay<EL, LabelOverlayOptions> {
13
13
  private instance;
14
14
  connection: Connection<EL>;
15
15
  label: string | Function;
@@ -18,11 +18,12 @@ export declare class LabelOverlay<EL> extends Overlay<EL> {
18
18
  useHTMLElement: boolean;
19
19
  rotatable: boolean | string;
20
20
  font: FontSpec;
21
+ backgroundStyle: any;
21
22
  constructor(instance: UICore<EL>, connection: Connection<EL>, p: LabelOverlayOptions);
22
23
  isSimpleShape: boolean;
23
24
  getLabel(): string;
24
25
  setLabel(l: string | Function): void;
25
- updateFrom(d: any, context: ObjectData): void;
26
+ updateFrom(d: LabelOverlayOptions, context: ObjectData): void;
26
27
  }
27
28
  /**
28
29
  * @internal
@@ -35,4 +36,4 @@ export declare function isLabelOverlay<EL>(o: Overlay<EL>): o is LabelOverlay<EL
35
36
  * @param data
36
37
  * @internal
37
38
  */
38
- export declare function $updateLabelOverlayFont(lo: LabelOverlay<any>, data: ObjectData): void;
39
+ export declare function $updateLabelOverlayFont(lo: LabelOverlay<any>, data: ObjectData & LineStyle): void;
@@ -62,7 +62,7 @@ export declare function setOverlayLocation(o: Overlay<any>, l: number | string):
62
62
  * @category Overlays
63
63
  * @internal
64
64
  */
65
- export declare abstract class Overlay<EL> {
65
+ export declare abstract class Overlay<EL, O extends OverlayOptions = OverlayOptions> {
66
66
  connection: Connection<EL>;
67
67
  id: string;
68
68
  abstract type: string;
@@ -81,8 +81,8 @@ export declare abstract class Overlay<EL> {
81
81
  * @param p
82
82
  */
83
83
  ignoreTypes: boolean;
84
- constructor(connection: Connection<EL>, p: OverlayOptions);
85
- abstract updateFrom(opts: any, context: ObjectData): void;
84
+ constructor(connection: Connection<EL>, p: O);
85
+ abstract updateFrom(opts: O, context: ObjectData): void;
86
86
  abstract isSimpleShape: boolean;
87
87
  }
88
88
  /**
@@ -1,5 +1,6 @@
1
1
  import { ConnectorSpec, PaintStyle, OverlaySpec, AnchorSpec, LightweightAnchor } from "../common";
2
2
  import { Extents, PointXY, Size, Edge, Group, Node, AbstractLayout, GradientSpec } from "../../core";
3
+ import { LabelBackgroundStyle } from "./view";
3
4
  /**
4
5
  * Options for the `connect` call on a UICore
5
6
  * @internal
@@ -41,6 +42,10 @@ export interface ConnectParams<E> {
41
42
  * When true, the label will be rotated so that it is at the same angle as the slope of the connector at the point at which the label is located.
42
43
  */
43
44
  labelsRotatable?: boolean | "strict" | "legible" | null;
45
+ /**
46
+ * Optional style for the label's background. This is ignored if `useHTMLLabel` is set to true.
47
+ */
48
+ labelBackgroundStyle?: LabelBackgroundStyle;
44
49
  /**
45
50
  * Spec for the connector used to paint the connection.
46
51
  */
@@ -4,7 +4,45 @@ import { AnchorSpec, ConnectorSpec, OverlaySpec, PaintStyle } from "../../common
4
4
  import { OverlayVisibility } from "../overlay/overlay";
5
5
  import { EdgeEventOptions } from "./events";
6
6
  import { LineStyle } from "../core";
7
- import { FontSpec } from "../../../browser-ui";
7
+ import { FontSpec } from "../definitions";
8
+ /**
9
+ * Defines the style for the background of a label overlay.
10
+ * @group Edges
11
+ */
12
+ export interface LabelBackgroundStyle {
13
+ /**
14
+ * Fill color for the background.
15
+ */
16
+ fill?: string;
17
+ /**
18
+ * Opacity for the background.
19
+ */
20
+ opacity?: number;
21
+ /**
22
+ * Padding to leave around the label. Defaults to 5.
23
+ */
24
+ padding?: number;
25
+ /**
26
+ * Horizontal radius for the background rectangle's corners.
27
+ */
28
+ rx?: number;
29
+ /**
30
+ * Vertical radius for the background rectangle's corners. If you provide `rx` but not this, `ry` will take the value of `rx`.
31
+ */
32
+ ry?: number;
33
+ /**
34
+ * Stroke color for the background.
35
+ */
36
+ stroke?: string;
37
+ /**
38
+ * Stroke width for the background.
39
+ */
40
+ strokeWidth?: number;
41
+ /**
42
+ * Stroke opacity for the background.
43
+ */
44
+ strokeOpacity?: number;
45
+ }
8
46
  /**
9
47
  * Definition of the function you can provide as `deleteConfirm` on an edge definition. VisuallyJs gives you the edge to be possibly deleted and the pointer event that instigated the deletion. If you wish to delete the edge you must invoke the `proceed()` function.
10
48
  * @group Edges
@@ -18,7 +56,7 @@ export type EdgeDeleteConfirmationFunction = (params: {
18
56
  * @group Components
19
57
  * @category View
20
58
  */
21
- export interface EdgeMapping extends BaseViewObjectMapping, LineStyle {
59
+ export interface EdgeMapping extends BaseViewObjectMapping, Omit<LineStyle, 'fontSize' | 'fontStyle' | 'fontFamily'> {
22
60
  /**
23
61
  * Name/definition of the connector to use. If you omit this, the default connector will be used.
24
62
  */
@@ -79,6 +117,10 @@ export interface EdgeMapping extends BaseViewObjectMapping, LineStyle {
79
117
  * Optional spec for label font. Will use browser defaults if not specified (or CSS, but remember that CSS is not taken into account when you export an SVG from a diagram or an app using an SVG container)
80
118
  */
81
119
  labelFont?: FontSpec;
120
+ /**
121
+ * Optional style for the label's background. This is ignored if `useHTMLLabel` is set to true.
122
+ */
123
+ labelBackgroundStyle?: LabelBackgroundStyle;
82
124
  /**
83
125
  * 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.
84
126
  */
@@ -10,6 +10,10 @@ export interface PropertyMapping<D> {
10
10
  * Property or properties to map. If an array is provided, values are matched against all properties in the order given.
11
11
  */
12
12
  property: string | Array<string>;
13
+ /**
14
+ * Optional name to use for the mapping in the UI (for example, in an inspector)
15
+ */
16
+ name?: string;
13
17
  /**
14
18
  * A map whose keys are expected values for the given property (or a space-separated string of values if an array of properties was provided), and the values are the type to apply.
15
19
  */
@@ -1 +1 @@
1
- export declare const VERSION = "1.2.5";
1
+ export declare const VERSION = "1.2.7";