@metadev/daga 5.1.0 → 5.1.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metadev/daga",
3
- "version": "5.1.0",
3
+ "version": "5.1.1",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "dependencies": {},
6
6
  "peerDependencies": {
@@ -26,6 +26,7 @@ export declare const setCursorStyle: (style?: CursorStyle) => void;
26
26
  export declare const getRelatedNodeOrItself: (element: DiagramNode | DiagramSection | DiagramPort | DiagramField) => DiagramNode | DiagramSection | DiagramPort | DiagramField;
27
27
  export declare const needsResizerX: (element: DiagramNode | DiagramSection) => boolean;
28
28
  export declare const needsResizerY: (element: DiagramNode | DiagramSection) => boolean;
29
+ export declare const needsResizerXY: (element: DiagramNode | DiagramSection) => boolean;
29
30
  export declare const initializeLook: (selection: d3.Selection<SVGGElement, DiagramNode | DiagramSection | DiagramPort, d3.BaseType, unknown>) => void;
30
31
  export declare const SHAPED_LOOK_DEFAULTS: {
31
32
  fillColor: string;
@@ -37,7 +38,7 @@ export declare const updateLook: (selection: d3.Selection<SVGGElement, DiagramNo
37
38
  export declare const BACKGROUND_DEFAULTS: SolidBackgroundConfig;
38
39
  export declare const GRID_DEFAULTS: EmptyGridConfig;
39
40
  export declare const DOTS_GRID_DEFAULTS: DotsGridConfig;
40
- export declare const initializeBackground: (canvas: DiagramCanvas, canvasView: d3.Selection<SVGGElement, unknown, null, unknown>, backgroundConfig: BackgroundConfig | undefined | null) => d3.Selection<SVGRectElement, unknown, null, unknown> | d3.Selection<SVGImageElement, unknown, null, unknown>;
41
+ export declare const initializeBackground: (canvasView: d3.Selection<SVGGElement, unknown, null, unknown>, backgroundConfig: BackgroundConfig | undefined | null) => d3.Selection<SVGRectElement, unknown, null, unknown> | d3.Selection<SVGImageElement, unknown, null, unknown>;
41
42
  export declare const applyGridDefaults: (gridConfig?: GridConfig) => GridConfig;
42
43
  export declare const initializeGrid: (canvas: DiagramCanvas, canvasView: d3.Selection<SVGGElement, unknown, null, unknown>, canvasDefs: d3.Selection<SVGDefsElement, unknown, null, unknown>, gridPatternId: string, gridConfig: GridConfig) => d3.Selection<SVGRectElement, unknown, null, unknown> | undefined;
43
44
  export declare const getGridSpacingX: (gridConfig: GridConfig) => number;
@@ -19,11 +19,6 @@ import { DiagramUserSelection } from './diagram-user-selection';
19
19
  * @private
20
20
  */
21
21
  export declare const CONNECTION_PATH_BOX_THICKNESS = 12;
22
- /**
23
- * Thickness of the resizer line used to resize nodes and sections on drag, in diagram units.
24
- * @private
25
- */
26
- export declare const RESIZER_THICKNESS = 6;
27
22
  /**
28
23
  * Maximum number of user actions that can be recorded in the user action stack.
29
24
  * @private
@@ -4,7 +4,7 @@ import { DiagramActions } from '../diagram-action';
4
4
  import { Property } from '../property/property';
5
5
  import { CanvasConfig } from './diagram-canvas-config';
6
6
  import { ComponentsConfig } from './diagram-components-config';
7
- import { ConnectionLookConfig, FieldLookConfig, ImageLookConfig, MarkerImageLookConfig, ShapedLookConfig, StretchableImageLookConfig } from './diagram-look-config';
7
+ import { ConnectionLookConfig, FieldLookConfig, ImageLookConfig, MarkerImageLookConfig, ResizerLookConfig, ShapedLookConfig, StretchableImageLookConfig } from './diagram-look-config';
8
8
  /**
9
9
  * The configuration for a diagram.
10
10
  * @public
@@ -171,15 +171,20 @@ export interface NodeTypeConfig {
171
171
  */
172
172
  minHeight?: number;
173
173
  /**
174
- * Whether the user can resize nodes of this type along the x axis.
174
+ * Whether the user can resize nodes of this type horizontally.
175
175
  * @default false
176
176
  */
177
- resizableX?: boolean | ResizableMode;
177
+ resizableX?: boolean | ResizableMode | ResizerConfig;
178
178
  /**
179
- * Whether the user can resize nodes of this type along the y axis.
179
+ * Whether the user can resize nodes of this type vertically.
180
180
  * @default false
181
181
  */
182
- resizableY?: boolean | ResizableMode;
182
+ resizableY?: boolean | ResizableMode | ResizerConfig;
183
+ /**
184
+ * Whether the user can resize nodes of this type diagonally.
185
+ * @default false
186
+ */
187
+ resizableXY?: boolean | ResizableMode | ResizerConfig;
183
188
  /**
184
189
  * By how much the location of nodes of this type should be offset when snapping to grid in diagram units.
185
190
  * Each value corresponds to left, top, right and bottom respectively.
@@ -187,10 +192,11 @@ export interface NodeTypeConfig {
187
192
  */
188
193
  snapToGridOffset?: [number, number, number, number];
189
194
  /**
190
- * The padding between the node and its children in diagram units if children are present. May be a single value or an array, in which case the value is interpreted in the same way as in CSS padding.
195
+ * The padding between the node and its children in diagram units if children are present.
196
+ * May be a single number or an array of up to four numbers, in which case the value is interpreted in the same way as in CSS padding.
191
197
  * @default 0
192
198
  */
193
- padding?: number | number[];
199
+ padding?: number | [number] | [number, number] | [number, number, number] | [number, number, number, number];
194
200
  /**
195
201
  * Configuration for the label of nodes of this type.
196
202
  * @default null
@@ -347,15 +353,17 @@ export interface FieldConfig {
347
353
  */
348
354
  shrink?: boolean;
349
355
  /**
350
- * The margin around the field in diagram units. May be a single value or an array, in which case the value is interpreted in the same way as in CSS margin.
356
+ * The margin around the field in diagram units.
357
+ * May be a single number or an array of up to four numbers, in which case the value is interpreted in the same way as in CSS margin.
351
358
  * @default 0
352
359
  */
353
- margin?: number | number[];
360
+ margin?: number | [number] | [number, number] | [number, number, number] | [number, number, number, number];
354
361
  /**
355
- * The padding around the field in diagram units. May be a single value or an array, in which case the value is interpreted in the same way as in CSS padding.
362
+ * The padding around the field in diagram units.
363
+ * May be a single number or an array of up to four numbers, in which case the value is interpreted in the same way as in CSS padding.
356
364
  * @default 0
357
365
  */
358
- padding?: number | number[];
366
+ padding?: number | [number] | [number, number] | [number, number, number] | [number, number, number, number];
359
367
  /**
360
368
  * The horizontal alignment of the text of this field.
361
369
  * @default 'center'
@@ -487,13 +495,19 @@ export interface SectionConfig {
487
495
  * If undefined, inherits from the parent node's resizableX setting.
488
496
  * @default undefined
489
497
  */
490
- resizableX?: boolean | ResizableMode;
498
+ resizableX?: boolean | ResizableMode | ResizerConfig;
491
499
  /**
492
500
  * Whether this section can be resized vertically.
493
501
  * If undefined, inherits from the parent node's resizableY setting.
494
502
  * @default undefined
495
503
  */
496
- resizableY?: boolean | ResizableMode;
504
+ resizableY?: boolean | ResizableMode | ResizerConfig;
505
+ /**
506
+ * Whether this section can be resized diagonally.
507
+ * If undefined, inherits from the parent node's resizableXY setting.
508
+ * @default undefined
509
+ */
510
+ resizableXY?: boolean | ResizableMode | ResizerConfig;
497
511
  }
498
512
  /**
499
513
  * Configuration for a type of connection.
@@ -544,6 +558,51 @@ export interface ConnectionTypeConfig {
544
558
  */
545
559
  properties?: Property[];
546
560
  }
561
+ /**
562
+ * Configuration for the resizers of a node or section.
563
+ * @public
564
+ * @see DiagramNode
565
+ * @see DiagramSection
566
+ */
567
+ export interface ResizerConfig {
568
+ /**
569
+ * Mode of the resizer.
570
+ * @default ResizableMode.Never
571
+ */
572
+ mode?: ResizableMode;
573
+ /**
574
+ * Thickness of the resizer.
575
+ * @default 10
576
+ */
577
+ thickness?: number;
578
+ /**
579
+ * The margin around the resizer in diagram units. Used to shift the resizer relative to its default position.
580
+ * @default 0
581
+ */
582
+ outerMargin?: number;
583
+ /**
584
+ * Configuration of the look of the resizer.
585
+ * @default { fillColor: 'transparent' }
586
+ */
587
+ look?: ResizerLookConfig;
588
+ }
589
+ /**
590
+ * The different modes for when a node or section can be resized.
591
+ * @public
592
+ * @see DiagramNode
593
+ * @see DiagramSection
594
+ */
547
595
  export declare enum ResizableMode {
548
- OnlyWhenSelected = 0
596
+ /**
597
+ * Resizable mode for always being resizable.
598
+ */
599
+ Always = 0,
600
+ /**
601
+ * Resizable mode for only being resizable while selected.
602
+ */
603
+ OnlyWhenSelected = 1,
604
+ /**
605
+ * Resizable mode for never being resizable.
606
+ */
607
+ Never = 2
549
608
  }
@@ -65,11 +65,18 @@ export interface ConnectionLookConfig extends ConnectionLook, LookConfig<Connect
65
65
  */
66
66
  export interface FieldLookConfig extends FieldLook, LookConfig<FieldLook> {
67
67
  }
68
+ /**
69
+ * Configuration for a look for a resizer.
70
+ * @public
71
+ * @see ResizerLook
72
+ */
73
+ export interface ResizerLookConfig extends ResizerLook, LookConfig<ResizerLook> {
74
+ }
68
75
  export interface Look {
69
76
  /**
70
- * String used to discern the type of look this is.
77
+ * String used to discern the type of look this is in cases where different types of looks can be used.
71
78
  */
72
- lookType: string;
79
+ lookType?: string;
73
80
  }
74
81
  /**
75
82
  * Configuration for a look given by a shape.
@@ -178,7 +185,6 @@ export interface StretchableImageLook extends Look {
178
185
  * @public
179
186
  */
180
187
  export interface MarkerImageLook extends Look {
181
- lookType: 'marker-image-look';
182
188
  /**
183
189
  * File path to the image used for the marker.
184
190
  */
@@ -213,7 +219,6 @@ export interface MarkerImageLook extends Look {
213
219
  * @public
214
220
  */
215
221
  export interface ConnectionLook extends Look {
216
- lookType: 'connection-look';
217
222
  /**
218
223
  * Color of the line of connections of this type.
219
224
  * @default '#000000'
@@ -240,7 +245,6 @@ export interface ConnectionLook extends Look {
240
245
  * @public
241
246
  */
242
247
  export interface FieldLook extends Look {
243
- lookType: 'field-look';
244
248
  /**
245
249
  * Background color of this look.
246
250
  * @default '#FFFFFF'
@@ -259,12 +263,33 @@ export interface FieldLook extends Look {
259
263
  fontFamily?: string | null;
260
264
  /**
261
265
  * Font size of this field.
262
- * @default 0
266
+ * @default 10
263
267
  */
264
268
  fontSize?: number;
265
269
  /**
266
270
  * Font weight of this field.
267
- * @default 0
271
+ * @default 400
268
272
  */
269
273
  fontWeight?: number;
270
274
  }
275
+ /**
276
+ * Configuration for a look for a resizer.
277
+ * @public
278
+ */
279
+ export interface ResizerLook extends Look {
280
+ /**
281
+ * Color of this resizer.
282
+ * @default 'transparent'
283
+ */
284
+ fillColor?: string;
285
+ /**
286
+ * Border color of this resizer.
287
+ * @default 'transparent'
288
+ */
289
+ borderColor?: string;
290
+ /**
291
+ * Border thickness of this resizer in diagram units.
292
+ * @default 0
293
+ */
294
+ borderThickness?: number;
295
+ }
@@ -3,12 +3,12 @@ import { LineShape, LineStyle } from '../../util/line';
3
3
  import { Side } from '../../util/svg-util';
4
4
  import { ConnectionTypeConfig, FieldConfig } from '../config/diagram-config';
5
5
  import { ConnectionLook, ConnectionLookConfig, MarkerImageLook, MarkerImageLookConfig } from '../config/diagram-look-config';
6
+ import { PropertySet } from '../property/property';
7
+ import { ValueSet } from '../property/value';
6
8
  import { DiagramElement, DiagramElementSet } from './diagram-element';
7
9
  import { DiagramEntity, DiagramEntitySet } from './diagram-entity';
8
10
  import { DiagramModel } from './diagram-model';
9
11
  import { DiagramPort } from './diagram-port';
10
- import { PropertySet } from '../property/property';
11
- import { ValueSet } from '../property/value';
12
12
  /**
13
13
  * Default values of the parameters of a diagram connection.
14
14
  * @private
@@ -18,7 +18,6 @@ export declare const DIAGRAM_CONNECTION_TYPE_DEFAULTS: {
18
18
  name: string;
19
19
  label: null;
20
20
  look: {
21
- lookType: string;
22
21
  color: string;
23
22
  thickness: number;
24
23
  shape: LineShape;
@@ -21,7 +21,6 @@ export declare const DIAGRAM_FIELD_DEFAULTS: {
21
21
  fit: boolean;
22
22
  shrink: boolean;
23
23
  look: {
24
- lookType: "field-look";
25
24
  fillColor: string;
26
25
  fontColor: string;
27
26
  fontFamily: string;
@@ -1,7 +1,7 @@
1
1
  import { Point } from '../../util/canvas-util';
2
2
  import { Side } from '../../util/svg-util';
3
3
  import { CollabTimestamp } from '../collab/primitives';
4
- import { DecoratorConfig, FieldConfig, NodeTypeConfig, PortConfig, ResizableMode } from '../config/diagram-config';
4
+ import { DecoratorConfig, FieldConfig, NodeTypeConfig, PortConfig } from '../config/diagram-config';
5
5
  import { ImageLook, ImageLookConfig, ShapedLook, ShapedLookConfig, StretchableImageLook, StretchableImageLookConfig } from '../config/diagram-look-config';
6
6
  import { PropertySet } from '../property/property';
7
7
  import { ValueSet } from '../property/value';
@@ -12,6 +12,7 @@ import { DiagramEntity, DiagramEntitySet } from './diagram-entity';
12
12
  import { DiagramField, LabeledElement } from './diagram-field';
13
13
  import { DiagramModel } from './diagram-model';
14
14
  import { DiagramPort } from './diagram-port';
15
+ import { DiagramResizer } from './diagram-resizer';
15
16
  import { DiagramSection, DiagramSectionGeometry, DiagramSectionGrid } from './diagram-section';
16
17
  /**
17
18
  * Default values of the look of a diagram node.
@@ -75,8 +76,9 @@ export declare class DiagramNodeType implements DiagramEntity {
75
76
  defaultHeight: number;
76
77
  minWidth: number;
77
78
  minHeight: number;
78
- resizableX: boolean | ResizableMode;
79
- resizableY: boolean | ResizableMode;
79
+ resizerX: DiagramResizer;
80
+ resizerY: DiagramResizer;
81
+ resizerXY: DiagramResizer;
80
82
  snapToGridOffset: [number, number, number, number];
81
83
  bottomPadding: number;
82
84
  leftPadding: number;
@@ -182,7 +184,7 @@ export declare class DiagramNode extends DiagramElement implements LabeledElemen
182
184
  private _highlightedLook?;
183
185
  private _selectedAndHighlightedLook?;
184
186
  /**
185
- * Current look of this port.
187
+ * Current look of this node.
186
188
  * @private
187
189
  */
188
190
  get look(): NodeLook;
@@ -207,6 +209,21 @@ export declare class DiagramNode extends DiagramElement implements LabeledElemen
207
209
  updateInView(): void;
208
210
  raise(): void;
209
211
  getPriority(): number;
212
+ /**
213
+ * Returns the horizontal resizer of this node.
214
+ * @public
215
+ */
216
+ getResizerX(): DiagramResizer;
217
+ /**
218
+ * Returns the vertical resizer of this node.
219
+ * @public
220
+ */
221
+ getResizerY(): DiagramResizer;
222
+ /**
223
+ * Returns the diagonal resizer of this node.
224
+ * @public
225
+ */
226
+ getResizerXY(): DiagramResizer;
210
227
  /**
211
228
  * Returns whether this node can be resized horizontally.
212
229
  * @public
@@ -217,6 +234,11 @@ export declare class DiagramNode extends DiagramElement implements LabeledElemen
217
234
  * @public
218
235
  */
219
236
  getResizableY(): boolean;
237
+ /**
238
+ * Returns whether this node can be resized diagonally.
239
+ * @public
240
+ */
241
+ getResizableXY(): boolean;
220
242
  /**
221
243
  * Get the port of this node which is closest to the given coordinates.
222
244
  * @param coords A point in the diagram.
@@ -0,0 +1,32 @@
1
+ import { ResizableMode, ResizerConfig } from '../config/diagram-config';
2
+ import { ResizerLook } from '../config/diagram-look-config';
3
+ import { DiagramNode } from './diagram-node';
4
+ import { DiagramSection } from './diagram-section';
5
+ /**
6
+ * Default values of the parameters of a diagram field.
7
+ * @private
8
+ * @see ResizerConfig
9
+ */
10
+ export declare const DIAGRAM_RESIZER_DEFAULTS: ResizerConfig;
11
+ /**
12
+ * Holds the data for the resizers of a type of node or section.
13
+ * @public
14
+ * @see DiagramNode
15
+ * @see DiagramSection
16
+ */
17
+ export declare class DiagramResizer {
18
+ mode: ResizableMode;
19
+ thickness: number;
20
+ outerMargin: number;
21
+ defaultLook: ResizerLook;
22
+ selectedLook: ResizerLook;
23
+ highlightedLook: ResizerLook;
24
+ selectedAndHighlightedLook: ResizerLook;
25
+ constructor(options: boolean | ResizableMode | ResizerConfig);
26
+ /**
27
+ * Current look of this resizer.
28
+ * @private
29
+ */
30
+ getLook(rootElement?: DiagramNode | DiagramSection): ResizerLook;
31
+ }
32
+ export declare const DIAGRAM_DEFAULT_RESIZER: DiagramResizer;
@@ -1,6 +1,6 @@
1
1
  import { Point } from '../../util/canvas-util';
2
2
  import { Side } from '../../util/svg-util';
3
- import { FieldConfig, PortConfig, ResizableMode, SectionConfig, SectionGridConfig } from '../config/diagram-config';
3
+ import { FieldConfig, PortConfig, SectionConfig, SectionGridConfig } from '../config/diagram-config';
4
4
  import { ImageLookConfig, ShapedLookConfig, StretchableImageLookConfig } from '../config/diagram-look-config';
5
5
  import { DiagramConnection } from './diagram-connection';
6
6
  import { DiagramDecorator } from './diagram-decorator';
@@ -9,6 +9,7 @@ import { DiagramField, LabeledElement } from './diagram-field';
9
9
  import { DiagramModel } from './diagram-model';
10
10
  import { DiagramNode, NodeLook } from './diagram-node';
11
11
  import { DiagramPort } from './diagram-port';
12
+ import { DiagramResizer } from './diagram-resizer';
12
13
  /**
13
14
  * Default value of the default width of a diagram section.
14
15
  * @private
@@ -61,8 +62,9 @@ export declare class DiagramSectionType {
61
62
  highlightedLook: NodeLook;
62
63
  selectedAndHighlightedLook: NodeLook;
63
64
  priority: number;
64
- resizableX: boolean | ResizableMode | undefined;
65
- resizableY: boolean | ResizableMode | undefined;
65
+ resizerX: DiagramResizer | undefined;
66
+ resizerY: DiagramResizer | undefined;
67
+ resizerXY: DiagramResizer | undefined;
66
68
  constructor(options: SectionConfig);
67
69
  }
68
70
  /**
@@ -156,6 +158,21 @@ export declare class DiagramSection extends DiagramElement implements LabeledEle
156
158
  getMinWidth(): number;
157
159
  getMinHeight(): number;
158
160
  getPriority(): number;
161
+ /**
162
+ * Returns the horizontal resizer of this section.
163
+ * @public
164
+ */
165
+ getResizerX(): DiagramResizer;
166
+ /**
167
+ * Returns the vertical resizer of this section.
168
+ * @public
169
+ */
170
+ getResizerY(): DiagramResizer;
171
+ /**
172
+ * Returns the diagonal resizer of this section.
173
+ * @public
174
+ */
175
+ getResizerXY(): DiagramResizer;
159
176
  /**
160
177
  * Returns whether this section can be resized horizontally.
161
178
  * If the section has a specific resizableX setting, it uses that.
@@ -170,6 +187,13 @@ export declare class DiagramSection extends DiagramElement implements LabeledEle
170
187
  * @public
171
188
  */
172
189
  getResizableY(): boolean;
190
+ /**
191
+ * Returns whether this section can be resized diagonally.
192
+ * If the section has a specific resizableXY setting, it uses that.
193
+ * Otherwise, it inherits from the parent node's resizableXY setting.
194
+ * @public
195
+ */
196
+ getResizableXY(): boolean;
173
197
  /**
174
198
  * Get the port of this section which is closest to the given coordinates.
175
199
  * @param coords A point in the diagram.
@@ -7,7 +7,9 @@ export declare enum CursorStyle {
7
7
  Grabbing = "grabbing",
8
8
  Move = "move",
9
9
  NoDrop = "no-drop",
10
+ NESWResize = "nesw-resize",
10
11
  NSResize = "ns-resize",
12
+ NWSEResize = "nwse-resize",
11
13
  NotAllowed = "not-allowed",
12
14
  ZoomIn = "zoom-in",
13
15
  ZoomOut = "zoom-out"