@visuallyjs/browser-ui 1.2.5 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/js/visuallyjs.browser-ui.cjs.js +53 -53
- package/js/visuallyjs.browser-ui.esm.js +60 -60
- package/package.json +1 -1
- package/types/browser-ui/definitions.d.ts +9 -1
- package/types/browser-ui/shape-library/shape-library-definitions.d.ts +25 -4
- package/types/browser-ui/shape-library/shape-library.d.ts +13 -7
- package/types/browser-ui/surface-renderer/diagrams/definitions.d.ts +5 -1
- package/types/browser-ui/svg-util.d.ts +3 -1
- package/types/version.d.ts +1 -1
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import { BoundingBox, Edge, Group, Node, ObjectData, Port, Vertex, VisuallyJsMod
|
|
|
3
3
|
import { PointXY, Size } from "../core";
|
|
4
4
|
import { UICoreDefaults, UICoreOptions, UIEdgeOptions, DragOptions, Overlay, Connection, EdgePropertyMappings, AlignContentOptions } 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";
|
|
@@ -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
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
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
4
|
import { FontSpec } from "../definitions";
|
|
@@ -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
|
|
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
|
|
@@ -276,3 +284,16 @@ export interface ShapePropertyDefinition {
|
|
|
276
284
|
values?: Array<any>;
|
|
277
285
|
}
|
|
278
286
|
export type LabelPosition = "top" | "bottom" | "center";
|
|
287
|
+
/**
|
|
288
|
+
* Options for the label background on a shape.
|
|
289
|
+
* @group Diagrams
|
|
290
|
+
* @category Shapes
|
|
291
|
+
*/
|
|
292
|
+
export interface LabelBackgroundOptions {
|
|
293
|
+
stroke?: string;
|
|
294
|
+
strokeWidth?: number;
|
|
295
|
+
fill?: string;
|
|
296
|
+
padding?: PointXY;
|
|
297
|
+
rx?: number;
|
|
298
|
+
opacity?: number;
|
|
299
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
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
2
|
import { BrowserElement } from "../util";
|
|
3
3
|
import { CustomTagOptions, Recado, AbstractEntry, ObjectData } from "../../core";
|
|
4
4
|
import { IconDefinition } from "../icons";
|
|
@@ -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
|
|
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
|
|
@@ -1,4 +1,4 @@
|
|
|
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
4
|
import { GridOptions, UIExportOptions, UICoreDefaults, EdgeEventOptions, OverlaySpec, ConnectorSpec, NodeEventOptions, GroupMapping, NodeMapping, AnchorSpec, EdgePropertyMappings, MagnetizeOptions, PaintStyle, OverlayVisibility, EdgeDeleteConfirmationFunction } from "../../../ui";
|
|
@@ -312,6 +312,10 @@ export interface DiagramOptions {
|
|
|
312
312
|
* Default position for labels (will be overridden by a shape that defines its own position. Defaults to "center"
|
|
313
313
|
*/
|
|
314
314
|
labelPosition?: LabelPosition;
|
|
315
|
+
/**
|
|
316
|
+
* Options for label background. Use `true` for defaults, or supply your own values (which will be merged on top of the defaults)
|
|
317
|
+
*/
|
|
318
|
+
labelBackground?: boolean | LabelBackgroundOptions;
|
|
315
319
|
/**
|
|
316
320
|
* Optional event mappings for all cells.
|
|
317
321
|
*/
|
|
@@ -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;
|
package/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.2.
|
|
1
|
+
export declare const VERSION = "1.2.6";
|