@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
@@ -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.6";
1
+ export declare const VERSION = "1.2.8";