@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visuallyjs/browser-ui",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "license": "Commercial",
5
5
  "main": "js/visuallyjs.browser-ui.cjs.js",
6
6
  "module": "js/visuallyjs.browser-ui.esm.js",
@@ -13,10 +13,8 @@ import { BrowserUIClipboard } from "./copy-paste";
13
13
  */
14
14
  export type BrowserUIEvent = typeof EVENT_EDGE_MOUSEUP | typeof EVENT_EDGE_MOUSEDOWN | typeof EVENT_VERTEX_CLICK | typeof EVENT_VERTEX_DBLCLICK | typeof EVENT_EDGE_CONTEXTMENU | typeof EVENT_EDGE_CLICK | typeof EVENT_EDGE_DBLCLICK | typeof EVENT_VERTEX_DBLTAP | typeof EVENT_VERTEX_TAP | typeof EVENT_VERTEX_MOUSEOVER | typeof EVENT_VERTEX_MOUSEOUT | typeof EVENT_VERTEX_MOUSEMOVE | typeof EVENT_VERTEX_MOUSEDOWN | typeof EVENT_VERTEX_MOUSEUP | typeof EVENT_VERTEX_CONTEXTMENU | typeof EVENT_VERTEX_MOUSEOVER | typeof EVENT_EDGE_MOUSEOVER | typeof EVENT_EDGE_MOUSEOUT | typeof EVENT_GROUP_MOVE | typeof EVENT_EDGE_DRAG_START | typeof EVENT_EDGE_DRAG | typeof EVENT_EDGE_DRAG_END | typeof EVENT_EDGE_DRAG_ABORT;
15
15
  /**
16
- * Subclass of UICore that renders to the DOM in a browser, and supports dragging of elements/connections.
16
+ * Subclass of UICore that renders to the DOM in a browser, and supports dragging of elements/connections. This class is abstract and is not something users of the API will instantiate.
17
17
  * @group Components
18
- * @internal
19
- *
20
18
  */
21
19
  export declare abstract class BrowserUI<EVT = any> extends UICore<BrowserElement, EVT | BrowserUIEvent> {
22
20
  protected $suspendRendering: boolean;
@@ -14,8 +14,7 @@ export declare const CLASS_EDGE_TYPE_PICKER = "vjs-edge-type-picker";
14
14
  */
15
15
  export declare const CLASS_EDGE_TYPE_PICKER_SELECTED = "vjs-edge-type-picker-selected";
16
16
  /**
17
- * Helper class that renders a set of edge styles to the DOM and offers a callback method for when one is selected
18
- * via a mouse click.
17
+ * Helper class that renders a set of edge styles to the DOM and offers a callback method for when one is selected via a mouse click.
19
18
  * @group Components
20
19
  * @category Edge Type Picker
21
20
  */
@@ -34,4 +33,9 @@ export declare class EdgeTypePicker {
34
33
  * @param value
35
34
  */
36
35
  select(property: string, value: string): void;
36
+ /**
37
+ * Clears the visible selection state
38
+ * @internal
39
+ */
40
+ reset(): void;
37
41
  }
@@ -35,6 +35,14 @@ export declare const CLASS_INSPECTOR = "vjs-inspector";
35
35
  * @context inspector
36
36
  */
37
37
  export declare const CLASS_INSPECTOR_CLOSE = "vjs-inspector-close";
38
+ /**
39
+ * Assigned to sections drawn inside an inspector by certain helper inspector components
40
+ * @group Components
41
+ * @category Inspector
42
+ * @cssClass
43
+ * @context inspector
44
+ */
45
+ export declare const CLASS_INSPECTOR_SECTION = "vjs-inspector-section";
38
46
  /**
39
47
  * Fired by an Inspector when its contents have changed.
40
48
  * @group Components
@@ -107,7 +115,7 @@ export declare class Inspector extends VjsContext {
107
115
  * @param value
108
116
  *
109
117
  */
110
- setValue(key: string, value: any, portId: string, repaintAfterwards?: boolean): void;
118
+ setValue(key: string, value: any, portId: string | null, repaintAfterwards?: boolean): void;
111
119
  /**
112
120
  * @internal
113
121
  * @param b
@@ -41,7 +41,7 @@ export declare class AutoEdgeConnectManager {
41
41
  private _transientEdges;
42
42
  private _keyListener;
43
43
  private _getSourceTargetElements;
44
- constructor(ui: UICore<any>, palette: Palette<any>, activeClass: string, mode: "eager" | "onDemand", lineStyle: LineStyle, key: string);
44
+ constructor(ui: UICore<any>, palette: Palette, activeClass: string, mode: "eager" | "onDemand", lineStyle: LineStyle, key: string);
45
45
  private _clearProximityState;
46
46
  private _toggleCssClasses;
47
47
  private _setStatus;
@@ -6,7 +6,7 @@ export declare const PALETTE_MODE_DRAG = "drag";
6
6
  export declare const PALETTE_MODE_TAP = "tap";
7
7
  export declare const PALETTE_MODE_DRAW = "draw";
8
8
  export type PaletteMode = typeof PALETTE_MODE_TAP | typeof PALETTE_MODE_DRAG | typeof PALETTE_MODE_DRAW;
9
- export type CanDropOnEdgeFilter<T> = (d: T) => boolean;
9
+ export type CanDropOnEdgeFilter = (d: ObjectData) => boolean;
10
10
  /**
11
11
  * Defines the source/target port ids to use on a vertex dropped on an edge.
12
12
  * @group Components
@@ -23,7 +23,7 @@ export type EdgeDropInfo = {
23
23
  * @group Components
24
24
  * @category Palette
25
25
  */
26
- export interface PaletteOptions<T> {
26
+ export interface PaletteOptions {
27
27
  /**
28
28
  * The element containing things that will be dragged/tapped.
29
29
  */
@@ -35,23 +35,23 @@ export interface PaletteOptions<T> {
35
35
  /**
36
36
  * Optional function to generate the size to use for some object that is being dragged.
37
37
  */
38
- dragSizeGenerator?: (payload: T, el: BrowserElement) => Size;
38
+ dragSizeGenerator?: (payload: ObjectData, el: BrowserElement) => Size;
39
39
  /**
40
40
  * Optional function to generate an initial payload from an element that has started to be dragged/has been tapped.
41
41
  */
42
- dataGenerator?: DataGeneratorFunction<T>;
42
+ dataGenerator?: DataGeneratorFunction;
43
43
  /**
44
44
  * Optional function to determine the type of the data object from an element that is being dragged (in drag mode) or has been tapped (in draw/tap mode)
45
45
  */
46
- typeGenerator?: TypeGeneratorFunction<T>;
46
+ typeGenerator?: TypeGeneratorFunction;
47
47
  /**
48
48
  * Optional function to use to determine if the element being dragged/has been tapped represents a group. If you do not provide this, the default behaviour is to check for the presence of a `data-vjs-is-group` attribute on the element, with a value of `true`.
49
49
  */
50
- groupIdentifier?: GroupIdentifierFunction<T>;
50
+ groupIdentifier?: GroupIdentifierFunction;
51
51
  /**
52
52
  * Defaults to false. Allows items to be dropped onto edges in the canvas. A drop on an edge causes that edge to be split, with one edge having the new vertex as a target, and another edge with the new vertex as source.
53
53
  */
54
- allowDropOnEdge?: boolean | CanDropOnEdgeFilter<T>;
54
+ allowDropOnEdge?: boolean | CanDropOnEdgeFilter;
55
55
  /**
56
56
  * If `allowDropOnEdge` is true, this function can be provided, to customise the behaviour of the drop. By default, the new vertex is used as the target of the original edge and the source of the new edge. But you might want to connect to ports on the new vertex, and this method allows you to do that: you can return the ID of a port to use for the existing edge's target, a port ID to use for the new edge's source, a source anchor or a target anchor.
57
57
  * @param newVertex The newly dropped vertex
@@ -106,7 +106,7 @@ export interface PaletteOptions<T> {
106
106
  /**
107
107
  * Optional function that you can use to inform the Palette that drop should be aborted. This method is invoked at the start of a drag (in drag mode) or when an item is tapped (in tap/draw mode) and is passed the candidate drag object's data.
108
108
  */
109
- canvasDropFilter?: CanvasDropFilter<T>;
109
+ canvasDropFilter?: CanvasDropFilter;
110
110
  /**
111
111
  * Mode to operate in - 'drag', 'tap' or 'draw'. Defaults to 'drag'.
112
112
  */
@@ -127,7 +127,7 @@ export interface PaletteOptions<T> {
127
127
  * @param p Location on the canvas where the mousedown event occurred.
128
128
  * @param e Mouse down event
129
129
  */
130
- vertexPreviewGenerator?: (objectType: string, type: string, data: T, p: PointXY, e: MouseEvent) => BrowserElement;
130
+ vertexPreviewGenerator?: (objectType: string, type: string, data: ObjectData, p: PointXY, e: MouseEvent) => BrowserElement;
131
131
  /**
132
132
  * When in draw mode this function is repeatedly called as the mouse is dragging a new shape. It provides a hook for you to update the element's appearance. This is only called if you provided a vertexPreviewGenerator and it has returned a valid DOM element at the start of a drag.
133
133
  * @param el The element you returned from vertexPreviewGenerator.
@@ -135,7 +135,7 @@ export interface PaletteOptions<T> {
135
135
  * @param size The current size of the new vertex.
136
136
  * @param data The return value from the dataGenerator
137
137
  */
138
- vertexPreviewUpdater?: (el: BrowserElement, origin: PointXY, size: Size, data: T) => any;
138
+ vertexPreviewUpdater?: (el: BrowserElement, origin: PointXY, size: Size, data: ObjectData) => any;
139
139
  /**
140
140
  * When in 'draw' mode, you can optionally provide a class to set on the lasso used by the vertex drawing plugin.
141
141
  */
@@ -175,7 +175,7 @@ export interface PaletteOptions<T> {
175
175
  /**
176
176
  * Optional function to invoke as the user is dragging a new element, or has tapped an element and is moving the mouse over the canvas.
177
177
  */
178
- onDrag?: DragFunction<T>;
178
+ onDrag?: DragFunction;
179
179
  /**
180
180
  * Optional template that will be used in conjunction with `data` to generate the HTML content of the palette. The template can return any number of elements (ie. you're not limited to just a single root node)
181
181
  */
@@ -9,7 +9,7 @@ import { BrowserUI } from "../../browser-visuallyjs-instance";
9
9
  * @group Components
10
10
  * @category Palette
11
11
  */
12
- export declare class Palette<T> {
12
+ export declare class Palette {
13
13
  private readonly ui;
14
14
  private readonly _$_mode;
15
15
  readonly source: BrowserElement;
@@ -96,7 +96,7 @@ export declare class Palette<T> {
96
96
  private _rotationSpeed;
97
97
  private readonly _autoEdgeConnect;
98
98
  private _autoEdgeConnectManager;
99
- constructor(ui: BrowserUI, options: PaletteOptions<T>);
99
+ constructor(ui: BrowserUI, options: PaletteOptions);
100
100
  /**
101
101
  * Sets the enabled state of the palette
102
102
  *
@@ -1,9 +1,9 @@
1
1
  import { BrowserElement } from "./util";
2
2
  import { BoundingBox, Edge, Group, Node, ObjectData, Port, Vertex, VisuallyJsModel, VisuallyJsSelection } from "../core";
3
3
  import { PointXY, Size } from "../core";
4
- import { UICoreDefaults, UICoreOptions, UIEdgeOptions, DragOptions, Overlay, Connection, EdgePropertyMappings, AlignContentOptions } from "../ui";
4
+ import { UICoreDefaults, UICoreOptions, UIEdgeOptions, DragOptions, Overlay, Connection, EdgePropertyMappings, AlignContentOptions, FontSpec } from "../ui";
5
5
  import { EdgeInputMethod } from "./edge-handler-base";
6
- import { ShapeLibrary, ShapeSet } from "./shape-library/shape-library-definitions";
6
+ import { LabelBackgroundOptions, LabelPosition, ShapeLibrary, ShapeSet } from "./shape-library/shape-library-definitions";
7
7
  import { VisuallyJSDOMElement } from "./element-facade";
8
8
  import { VertexMapping } from "../ui";
9
9
  import { BrowserUI } from "./browser-visuallyjs-instance";
@@ -13,58 +13,58 @@ import { ConnectorEditorActivateParams } from "./connector-editor";
13
13
  * @group Components
14
14
  * @category Palette
15
15
  */
16
- export type CanvasDropFilter<T> = (data: T) => boolean;
16
+ export type CanvasDropFilter = (data: ObjectData) => boolean;
17
17
  /**
18
18
  * Defines a function used to filter drop on an edge.
19
19
  * @group Components
20
20
  * @category Palette
21
21
  */
22
- export type EdgeDropFilter<T> = (data: T, target: Edge) => boolean;
22
+ export type EdgeDropFilterObjectData = (data: ObjectData, target: Edge) => boolean;
23
23
  /**
24
24
  * Defines the callback function invoked when an item is being dragged.
25
25
  * @group Components
26
26
  * @category Palette
27
27
  */
28
- export type DragFunction<T> = (data: T, el: BrowserElement, e: Event) => any;
28
+ export type DragFunction = (data: ObjectData, el: BrowserElement, e: Event) => any;
29
29
  /**
30
30
  * Defines the function invoked when an item is dropped onto an existing vertex.
31
31
  * @group Components
32
32
  * @category Palette
33
33
  */
34
- export type DropFunction<T> = (data: T, target: Node | Group, draggedElement?: BrowserElement, e?: Event, position?: PointXY, canvasLocation?: PointXY, targetLocation?: PointXY, locationOnTarget?: PointXY) => void;
34
+ export type DropFunction = (data: ObjectData, target: Node | Group, draggedElement?: BrowserElement, e?: Event, position?: PointXY, canvasLocation?: PointXY, targetLocation?: PointXY, locationOnTarget?: PointXY) => void;
35
35
  /**
36
36
  * Defines the function invoked when an item is dropped on an edge.
37
37
  * @group Components
38
38
  * @category Palette
39
39
  */
40
- export type EdgeDropFunction<T> = (data: T, target: Edge, draggedElement?: BrowserElement, e?: Event, position?: PointXY, canvasLocation?: PointXY) => void;
40
+ export type EdgeDropFunction = (data: ObjectData, target: Edge, draggedElement?: BrowserElement, e?: Event, position?: PointXY, canvasLocation?: PointXY) => void;
41
41
  /**
42
42
  * Defines the function invoked when an item is dropped onto whitespace in the canvas.
43
43
  * @group Components
44
44
  * @category Palette
45
45
  */
46
- export type CanvasDropFunction<T> = (data: T, canvasPosition: PointXY, draggedElement?: BrowserElement, e?: Event, position?: PointXY, elementSize?: Size) => void;
46
+ export type CanvasDropFunction = (data: ObjectData, canvasPosition: PointXY, draggedElement?: BrowserElement, e?: Event, position?: PointXY, elementSize?: Size) => void;
47
47
  /**
48
48
  * Defines the function that is invoked to gather a dataset to associate with an item that is being dragged.
49
49
  * @group Components
50
50
  * @category Palette
51
51
  * @typeParam T Defines the type of the object that will be created.
52
52
  */
53
- export type DataGeneratorFunction<T> = (el: BrowserElement) => T;
53
+ export type DataGeneratorFunction = (el: BrowserElement) => ObjectData;
54
54
  /**
55
55
  * Defines the function invoked to determine the type of some item that is about to be dragged.
56
56
  * @group Components
57
57
  * @category Palette
58
58
  * @typeParam T Defines the kind of the object from which to extract the type id.
59
59
  */
60
- export type TypeGeneratorFunction<T> = (d: T) => string;
60
+ export type TypeGeneratorFunction = (d: ObjectData) => string;
61
61
  /**
62
62
  * Defines the function that is invoked to determine whether an item that is about to be dragged represents a group.
63
63
  * @group Components
64
64
  * @category Palette
65
65
  * @typeParam T Defines the kind of the associated data object.
66
66
  */
67
- export type GroupIdentifierFunction<T> = (d: T, el: BrowserElement) => boolean;
67
+ export type GroupIdentifierFunction = (d: ObjectData, el: BrowserElement) => boolean;
68
68
  /**
69
69
  * Defines the method signature for the `onVertexAdded` callback.
70
70
  * @group Components
@@ -235,6 +235,14 @@ export interface ShapesOptions {
235
235
  * The attribute containing each vertex's label. Defaults to 'label'
236
236
  */
237
237
  labelAttribute?: string;
238
+ /**
239
+ * Position for labels. Defaults to "center".
240
+ */
241
+ labelPosition?: LabelPosition;
242
+ /**
243
+ * Options for label background. Use `true` for defaults, or supply your own values (which will be merged on top of the defaults)
244
+ */
245
+ labelBackground?: boolean | LabelBackgroundOptions;
238
246
  /**
239
247
  * Whether or not to show labels. Defaults to true.
240
248
  */
@@ -358,41 +366,6 @@ export interface Background {
358
366
  export interface ImageBackground extends Background {
359
367
  setUrl(url: string): void;
360
368
  }
361
- /**
362
- * Style for a font - oblique, italic or normal.
363
- * @group UI
364
- * @category Definitions
365
- */
366
- export type FontStyle = "normal" | "oblique" | "italic";
367
- /**
368
- * Font weight to use (e.g., "normal", "bold", "100", "300").
369
- * @group UI
370
- * @category Definitions
371
- */
372
- export type FontWeight = string | number;
373
- /**
374
- * Specs for a font. The default values depend on the context.
375
- * @group UI
376
- * @category Definitions
377
- */
378
- export interface FontSpec {
379
- /**
380
- * Size of the font. Default value depends on the context this spec occurs in.
381
- */
382
- size?: number;
383
- /**
384
- * Font style to use. Default value depends on the context this spec occurs in.
385
- */
386
- style?: FontStyle;
387
- /**
388
- * Font weight to use (e.g., "normal", "bold", "100", "300"). Defaults to null, which browsers treat as "normal".
389
- */
390
- weight?: FontWeight;
391
- /**
392
- * Font family to use.
393
- */
394
- family?: string;
395
- }
396
369
  /**
397
370
  * @internal
398
371
  * @param o
@@ -3,11 +3,36 @@ export declare const DEFAULT_FLOWCHART_ARROW_WIDTH = 15;
3
3
  export declare const DEFAULT_FLOWCHART_ARROW_LENGTH = 10;
4
4
  export declare const DEFAULT_FLOWCHART_PROPERTY_MARKERS = "markers";
5
5
  export declare const DEFAULT_FLOWCHART_PROPERTY_LINE_STYLE = "lineStyle";
6
+ export declare const DEFAULT_FLOWCHART_PROPERTY_THICKNESS = "thickness";
6
7
  export declare const FLOWCHART_EDGE_TYPE_SOURCE_ARROW = "sourceArrow";
7
8
  export declare const FLOWCHART_EDGE_TYPE_TARGET_ARROW = "targetArrow";
8
9
  export declare const FLOWCHART_EDGE_TYPE_BOTH_ARROWS = "bothArrows";
9
10
  export declare const FLOWCHART_EDGE_TYPE_PLAIN = "plain";
10
11
  export declare const FLOWCHART_EDGE_TYPE_DASHED = "dashed";
12
+ /**
13
+ * Config for line thickness option in flowchart edge mappings.
14
+ */
15
+ export type LineThicknessMappingsConfig = {
16
+ /**
17
+ * Whether or not to enable the 'thickness' property mapping. Defaults to false, for backwards compatibility reasons, will likely default to true in v2.
18
+ */
19
+ enabled?: boolean;
20
+ /**
21
+ * Defaults to "thickness"
22
+ */
23
+ propertyName?: string;
24
+ /**
25
+ * Defaults to "Line Thickness" - a name for the mapping that can be used in an inspector.
26
+ */
27
+ mappingName?: string;
28
+ /**
29
+ * List of thicknesses to support, and their keys. Defaults to [1:thin, 3:medium, 5:thick]
30
+ */
31
+ values?: Array<{
32
+ key: string;
33
+ value: number;
34
+ }>;
35
+ };
11
36
  /**
12
37
  * Basic edge mappings for flowcharts - a 'dashed' or 'plain' line style, and source/target/both/none arrow markers, with a configurable width/height
13
38
  * @param options
@@ -20,4 +45,7 @@ export declare function FlowchartBasicEdgeMappings(options?: {
20
45
  markersProperty?: string;
21
46
  arrowWidth?: number;
22
47
  arrowLength?: number;
48
+ lineStyleMappingName?: string;
49
+ markersMappingName?: string;
50
+ lineThickness?: boolean | LineThicknessMappingsConfig;
23
51
  }): EdgePropertyMappings;
@@ -1,8 +1,8 @@
1
- import { Size, Group, Node, ObjectData, AbstractEntry, CustomTagOptions } from "../../core";
1
+ import { Size, Group, Node, ObjectData, AbstractEntry, CustomTagOptions, PointXY } from "../../core";
2
2
  import { BrowserElement } from "../util";
3
3
  import { IconDefinition } from "../icons";
4
- import { FontSpec } from "../definitions";
5
4
  import { GroupTemplate } from "../../core/model/group-template";
5
+ import { FontSpec } from "../../ui";
6
6
  /**
7
7
  * Default fill/stroke/text color for items in ShapeLibrary.
8
8
  * @internal
@@ -171,7 +171,7 @@ export interface ShapeLibrary<T extends ObjectData> {
171
171
  getShapeDefinition(type: string, set?: string): RealisedShapeType;
172
172
  renderCompiledShape(data: T, strokeWidth?: number): BrowserElement;
173
173
  renderShapeLabel(data: ObjectData, labelProperty: string, strokeWidth: string, label: string, fill: string, stroke: string, font: FontSpec): SVGTextElement;
174
- getShapeTagDefinition(isSvgContainer: boolean, strokeWidth?: number, includeLabel?: boolean, fontSpec?: FontSpec, labelAttribute?: string, defaultFillColor?: string, defaultOutlineColor?: string, defaultColor?: string): CustomTagOptions;
174
+ getShapeTagDefinition(isSvgContainer: boolean, strokeWidth?: number, includeLabel?: boolean, fontSpec?: FontSpec, labelAttribute?: string, labelPosition?: LabelPosition, defaultFillColor?: string, defaultOutlineColor?: string, defaultColor?: string): CustomTagOptions;
175
175
  getShapeSet(id: string): RenderedShapeSet;
176
176
  getShapeSets(): Array<RenderedShapeSet>;
177
177
  rootSet: RenderedShapeSet;
@@ -179,7 +179,7 @@ export interface ShapeLibrary<T extends ObjectData> {
179
179
  getSvgDefsElement(): SVGElement;
180
180
  parseDefs(): Array<Array<AbstractEntry>>;
181
181
  useMultilineLabels(): boolean;
182
- $applyMultilineLabel(el: Element, data: ObjectData, labelAttribute: string): void;
182
+ $applyMultilineLabel(el: Element, data: ObjectData, labelAttribute: string, labelPosition: LabelPosition): void;
183
183
  typeParameter: string;
184
184
  categoryParameter: string;
185
185
  defaultCategoryId: string;
@@ -189,7 +189,7 @@ export interface ShapeLibrary<T extends ObjectData> {
189
189
  * @param data The data associated with the element.
190
190
  * @param labelAttribute The attribute to use for the label.
191
191
  */
192
- refresh(el: BrowserElement, data: T, labelAttribute?: string): void;
192
+ refresh(el: BrowserElement, data: T, labelAttribute: string, labelPosition: LabelPosition): void;
193
193
  }
194
194
  /**
195
195
  * Defines a function that can take a vertex's data object and return a document fragment with it rendered.
@@ -222,6 +222,14 @@ export declare const TAG_SHAPE = "vjs-shape";
222
222
  * @context shape-library
223
223
  */
224
224
  export declare const CLASS_SHAPE_LABEL = "vjs-shape-label";
225
+ /**
226
+ * This class is assigned to svg rect elements serving as the background for shape labels. By default it is an empty rectangle with no fill, and is not visible in the UI. If you supply a `labelBackground` config, this element will use it.
227
+ * @group Nodes and Groups
228
+ * @category CSS Classes
229
+ * @cssClass
230
+ * @context shape-library
231
+ */
232
+ export declare const CLASS_SHAPE_LABEL_BG = "vjs-shape-label-bg";
225
233
  /**
226
234
  * This class is assigned to the parent SVG elements for shapes.
227
235
  * @group Nodes and Groups
@@ -235,7 +243,16 @@ export declare const CLASS_SHAPE = "vjs-shape";
235
243
  * @group Diagrams
236
244
  * @category Shapes
237
245
  */
238
- export type ShapePropertyType = "string" | "number" | "boolean" | "color" | "font";
246
+ export type ShapePropertyType = "string" | "number" | "boolean" | "color" | "font" | "text";
247
+ /**
248
+ * Definition of a value in a shape property's list of allowed values.
249
+ * @group Diagrams
250
+ * @category Shapes
251
+ */
252
+ export type ShapePropertyValueDefinition = {
253
+ label: string;
254
+ value: any;
255
+ };
239
256
  /**
240
257
  * Defines a single configurable property exposed by a shape.
241
258
  * @group Diagrams
@@ -251,7 +268,7 @@ export interface ShapePropertyDefinition {
251
268
  */
252
269
  label: string;
253
270
  /**
254
- * The data type of the property, telling the inspector which UI control to render.
271
+ * The data type of the property, telling the inspector which UI control to render by default. For properties that include a `values` array (and also properties of type boolean) you can override the choice of UI control via the `editor` option.
255
272
  */
256
273
  type: ShapePropertyType;
257
274
  /**
@@ -273,6 +290,27 @@ export interface ShapePropertyDefinition {
273
290
  /**
274
291
  * Optional set of values to pick current value from
275
292
  */
276
- values?: Array<any>;
293
+ values?: Array<string | ShapePropertyValueDefinition>;
294
+ /**
295
+ * Specifies the type of UI input to use to manage the property. Only used if you have supplied `values`, or if the property type is "boolean" (since in that case the property's values are implicitly a list, containing true and false values).
296
+ */
297
+ editor?: null | "radio" | "select";
298
+ /**
299
+ * Specifies the labels to use for this property if it is a boolean and you've specified you want a 'radio' or 'select' editor. You could use this, for example, to show "On/Off" or "Yes/No" labels in the UI, rather than "True/False".
300
+ */
301
+ booleanLabels?: [string, string];
277
302
  }
278
303
  export type LabelPosition = "top" | "bottom" | "center";
304
+ /**
305
+ * Options for the label background on a shape.
306
+ * @group Diagrams
307
+ * @category Shapes
308
+ */
309
+ export interface LabelBackgroundOptions {
310
+ stroke?: string;
311
+ strokeWidth?: number;
312
+ fill?: string;
313
+ padding?: PointXY;
314
+ rx?: number;
315
+ opacity?: number;
316
+ }
@@ -1,8 +1,8 @@
1
- import { RenderedShapeSet, ShapeGeneratorFunction, ShapeLibrary, ShapeSet, LabelPosition, RealisedShapeType } from "./shape-library-definitions";
1
+ import { RenderedShapeSet, ShapeGeneratorFunction, ShapeLibrary, ShapeSet, LabelPosition, RealisedShapeType, LabelBackgroundOptions } from "./shape-library-definitions";
2
+ import { FontSpec } from "../../ui";
2
3
  import { BrowserElement } from "../util";
3
4
  import { CustomTagOptions, Recado, AbstractEntry, ObjectData } from "../../core";
4
5
  import { IconDefinition } from "../icons";
5
- import { FontSpec } from "../definitions";
6
6
  export declare const ATTRIBUTE_ORIGIN = "origin";
7
7
  export declare const ATTRIBUTE_ORIGIN_X = "originX";
8
8
  export declare const ATTRIBUTE_ORIGIN_Y = "originY";
@@ -122,6 +122,10 @@ export interface ShapeLibraryOptions {
122
122
  * Default position for labels (will be overridden by a shape that defines its own position. Defaults to "center"
123
123
  */
124
124
  labelPosition?: LabelPosition;
125
+ /**
126
+ * Options for label background. Use `true` for defaults, or supply your own values (which will be merged on top of the defaults)
127
+ */
128
+ labelBackground?: boolean | LabelBackgroundOptions;
125
129
  /**
126
130
  * Optional default for fill color. If not provided, fill is set to #FFFFFF.
127
131
  */
@@ -142,6 +146,8 @@ export declare class ShapeLibraryImpl<T extends ObjectData> implements ShapeLibr
142
146
  shapeSets: Map<string, RenderedShapeSet>;
143
147
  defaultCategoryId: string;
144
148
  private labelPosition;
149
+ private _showLabelBackgrounds;
150
+ private _labelBackgroundOptions;
145
151
  rootSet: RenderedShapeSet;
146
152
  iconContainerTemplate: string;
147
153
  iconContainerAst: Array<AbstractEntry>;
@@ -177,8 +183,9 @@ export declare class ShapeLibraryImpl<T extends ObjectData> implements ShapeLibr
177
183
  * @param el
178
184
  * @param data
179
185
  * @param labelAttribute
186
+ * @param labelPosition
180
187
  */
181
- refresh(el: BrowserElement, data: ObjectData, labelAttribute?: string): void;
188
+ refresh(el: BrowserElement, data: ObjectData, labelAttribute: string, labelPosition: LabelPosition): void;
182
189
  private _processShapeSets;
183
190
  getShapeSet(id: string): RenderedShapeSet;
184
191
  getShapeSets(): Array<RenderedShapeSet>;
@@ -211,7 +218,6 @@ export declare class ShapeLibraryImpl<T extends ObjectData> implements ShapeLibr
211
218
  * @param el
212
219
  * @private
213
220
  */
214
- private _applyVectorEffect;
215
221
  /**
216
222
  * Render the given data with the appropriate template. A `fill` value is set on the resulting element, and the `vector-effect` attribute is set to 'non scaling stroke', ie. when the shape is scaled due to the element dimensions differing from the viewbox, the stroke does not change.
217
223
  * @param data
@@ -242,7 +248,7 @@ export declare class ShapeLibraryImpl<T extends ObjectData> implements ShapeLibr
242
248
  * Returns a tag definition that can be used in a Surface's `tags` declaration. Note that this method returns an object containing the tag's implementation, but not the name of the tag. You can call the tag whatever you like.
243
249
  * @internal
244
250
  */
245
- getShapeTagDefinition(isSvgContainer: boolean, strokeWidth?: number, includeLabel?: boolean, fontSpec?: FontSpec, labelAttribute?: string, defaultFillColor?: string, defaultOutlineColor?: string, defaultColor?: string, defaultOutlineWidth?: number): CustomTagOptions;
251
+ getShapeTagDefinition(isSvgContainer: boolean, strokeWidth?: number, includeLabel?: boolean, fontSpec?: FontSpec, labelAttribute?: string, labelPosition?: LabelPosition, defaultFillColor?: string, defaultOutlineColor?: string, defaultColor?: string, defaultOutlineWidth?: number): CustomTagOptions;
246
252
  /**
247
253
  * @internal
248
254
  */
@@ -256,14 +262,14 @@ export declare class ShapeLibraryImpl<T extends ObjectData> implements ShapeLibr
256
262
  */
257
263
  private _resolveIcon;
258
264
  /**
259
- * Converts text element labels to multiline tspans, if multilineLabels is set to true (which is
260
- * the default).
265
+ * Converts text element labels to multiline tspans, if multilineLabels is set to true (which is the default).
261
266
  * @param labelElement
262
267
  * @param data
263
268
  * @param labelAttribute
269
+ * @param labelPosition
264
270
  * @internal
265
271
  */
266
- $applyMultilineLabel(labelElement: SVGTextElement, data: ObjectData, labelAttribute: string): void;
272
+ $applyMultilineLabel(labelElement: SVGTextElement, data: ObjectData, labelAttribute: string, labelPosition: LabelPosition): void;
267
273
  /**
268
274
  * Check for any icons that were declared and render them.
269
275
  * @param el
@@ -84,11 +84,17 @@ export interface SurfaceVertexCloneOptions extends VertexCloneOptions {
84
84
  flash?: boolean;
85
85
  }
86
86
  /**
87
- * Definition of the payload returned from the Surface's exportData method.
87
+ * Definition of the payload returned from the Surface's `save` method.
88
88
  * @group Components
89
89
  * @category Input and Output
90
90
  */
91
91
  export interface SurfaceSaveData extends UISaveData {
92
+ /**
93
+ * The current pan position of the surface canvas
94
+ */
92
95
  pan: PointXY;
96
+ /**
97
+ * The current position of the surface's transform origin.
98
+ */
93
99
  transformOrigin: PointXY;
94
100
  }
@@ -1,7 +1,7 @@
1
- import { LabelPosition, ShapeSet } from "../../shape-library";
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
5
  import { SurfaceSaveData } from "../definitions";
6
6
  import { BrowserElement } from "../../util";
7
7
  import { PaletteMode, AutoEdgeConnectOptions, CanDropOnEdgeFilter } from "../../components/palette/palette-options";
@@ -9,7 +9,7 @@ import { PanOptions, WheelOptions, ZoomOptions } from "../../pan-zoom-options";
9
9
  import { MiniviewPluginOptions, LassoPluginOptions, ResizingToolsModelUpdater, ResizingToolsHandlerFactory, DragGroupsPluginOptions, ResizingToolsResizeMethod, SnaplinesPluginOptions, PanButtonsPluginOptions, LineCrossingsPluginOptions } from "../plugins";
10
10
  import { EdgeSnapOptions, EdgeInputMethod } from "../../edge-handler-base";
11
11
  import { DiagramActionMediator } from "./mediator";
12
- import { OnVertexAddedCallback, FontSpec } from "../../definitions";
12
+ import { OnVertexAddedCallback } from "../../definitions";
13
13
  import { PreparedShape } from "../shape-palette-options";
14
14
  /**
15
15
  * Options for the {@link Diagram.addLink method}
@@ -172,6 +172,10 @@ export interface DiagramOptions {
172
172
  * Optional font for edge labels.
173
173
  */
174
174
  labelFont?: FontSpec;
175
+ /**
176
+ * Optional style for the label's background.
177
+ */
178
+ labelBackgroundStyle?: LabelBackgroundStyle;
175
179
  /**
176
180
  * Optional map of event handlers for edges.
177
181
  */
@@ -192,6 +196,35 @@ export interface DiagramOptions {
192
196
  * Styles for the edge highlight box.
193
197
  */
194
198
  highlightStyle?: PaintStyle;
199
+ /**
200
+ * Optional default styles for edges. These are overwritten by edges that have values in their backing data.
201
+ */
202
+ lineStyle?: {
203
+ /**
204
+ * Width of the edge path
205
+ */
206
+ lineWidth?: number;
207
+ /**
208
+ * Width to draw the edge's outline path
209
+ */
210
+ outlineWidth?: number;
211
+ /**
212
+ * Color to paint the edge's path
213
+ */
214
+ color?: string;
215
+ /**
216
+ * Color to paint the edge's outline path
217
+ */
218
+ outlineColor?: string;
219
+ /**
220
+ * Definition of dash pattern to use to draw the edge path
221
+ */
222
+ dashArray?: string;
223
+ /**
224
+ * An array of color stops to use as a linear gradient for the edge path. When this is set, `color` is ignored.
225
+ */
226
+ gradient?: Array<[number, string]>;
227
+ };
195
228
  };
196
229
  /**
197
230
  * Defaults to #FFFFFF
@@ -312,6 +345,10 @@ export interface DiagramOptions {
312
345
  * Default position for labels (will be overridden by a shape that defines its own position. Defaults to "center"
313
346
  */
314
347
  labelPosition?: LabelPosition;
348
+ /**
349
+ * Options for label background. Use `true` for defaults, or supply your own values (which will be merged on top of the defaults)
350
+ */
351
+ labelBackground?: boolean | LabelBackgroundOptions;
315
352
  /**
316
353
  * Optional event mappings for all cells.
317
354
  */
@@ -510,7 +547,7 @@ export interface DiagramPaletteOptions {
510
547
  /**
511
548
  * 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.
512
549
  */
513
- allowDropOnEdge?: boolean | CanDropOnEdgeFilter<BrowserElement>;
550
+ allowDropOnEdge?: boolean | CanDropOnEdgeFilter;
514
551
  /**
515
552
  * 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.
516
553
  * @advanced