@joint/core 4.2.0 → 4.2.2

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.
@@ -1,4 +1,4 @@
1
- /*! JointJS v4.2.0 (2025-11-10) - JavaScript diagramming library
1
+ /*! JointJS v4.2.2 (2025-12-16) - JavaScript diagramming library
2
2
 
3
3
  This Source Code Form is subject to the terms of the Mozilla Public
4
4
  License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -1,4 +1,4 @@
1
- /*! JointJS v4.2.0 (2025-11-10) - JavaScript diagramming library
1
+ /*! JointJS v4.2.2 (2025-12-16) - JavaScript diagramming library
2
2
 
3
3
  This Source Code Form is subject to the terms of the Mozilla Public
4
4
  License, v. 2.0. If a copy of the MPL was not distributed with this
package/dist/version.mjs CHANGED
@@ -1,3 +1,3 @@
1
- var version = "4.2.0";
1
+ var version = "4.2.2";
2
2
 
3
3
  export { version };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@joint/core",
3
3
  "title": "JointJS",
4
- "version": "4.2.0",
4
+ "version": "4.2.2",
5
5
  "description": "JavaScript diagramming library",
6
6
  "sideEffects": false,
7
7
  "main": "./dist/joint.min.js",
package/src/dia/Graph.mjs CHANGED
@@ -29,6 +29,13 @@ export const Graph = Model.extend({
29
29
  */
30
30
  defaultLayerId: DEFAULT_LAYER_ID,
31
31
 
32
+ /**
33
+ * @protected
34
+ * @description If `true`, layer functionality is disabled
35
+ * and all cells are assigned to the default layer.
36
+ */
37
+ ignoreLayers: false,
38
+
32
39
  initialize: function(attrs, options = {}) {
33
40
 
34
41
  const layerCollection = this.layerCollection = new GraphLayerCollection([], {
@@ -52,6 +59,11 @@ export const Graph = Model.extend({
52
59
  // Controller that manages communication between the graph and its layers.
53
60
  this.layersController = new GraphLayersController({ graph: this });
54
61
 
62
+ // Option to ignore layers altogether.
63
+ if (options.ignoreLayers) {
64
+ this.ignoreLayers = true;
65
+ }
66
+
55
67
  // `Graph` keeps an internal data structure (an adjacency list)
56
68
  // for fast graph queries. All changes that affect the structure of the graph
57
69
  // must be reflected in the `al` object. This object provides fast answers to
@@ -156,7 +168,7 @@ export const Graph = Model.extend({
156
168
  // Backward compatibility: prior v4.2, z-index was not set during reset.
157
169
  if (opt && opt.ensureZIndex) {
158
170
  if (cellAttributes.z === undefined) {
159
- const layerId = cellAttributes[config.layerAttribute] || this.defaultLayerId;
171
+ const layerId = this.getCellLayerId(cellInit);
160
172
  const zIndex = this.maxZIndex(layerId) + 1;
161
173
  if (cellInit[CELL_MARKER]) {
162
174
  // Set with event in case there is a listener
@@ -268,6 +280,10 @@ export const Graph = Model.extend({
268
280
  if (!cellInit) {
269
281
  throw new Error('dia.Graph: No cell provided.');
270
282
  }
283
+ if (this.ignoreLayers) {
284
+ // When layers are ignored, all cells belong to the default layer.
285
+ return this.defaultLayerId;
286
+ }
271
287
  const cellAttributes = cellInit[CELL_MARKER]
272
288
  ? cellInit.attributes
273
289
  : cellInit;
package/types/joint.d.ts CHANGED
@@ -25,6 +25,11 @@ type _DeepPartial<T> = {
25
25
 
26
26
  type DeepPartial<T> = _DeepPartial<_DeepRequired<T>>;
27
27
 
28
+ /**
29
+ * A type that makes all properties of T nullable.
30
+ */
31
+ type Nullable<T> = { [K in keyof T]: T[K] | null };
32
+
28
33
  // We use `DOMElement` later in the code, to avoid conflicts with the `dia.Element` type.
29
34
  type DOMElement = Element;
30
35
 
@@ -318,6 +323,7 @@ export namespace dia {
318
323
  constructor(attributes?: Graph.Attributes, opt?: {
319
324
  cellNamespace?: any,
320
325
  layerNamespace?: any,
326
+ ignoreLayers?: boolean,
321
327
  /** @deprecated use cellNamespace instead */
322
328
  cellModel?: typeof Cell
323
329
  });
@@ -493,7 +499,7 @@ export namespace dia {
493
499
  }
494
500
 
495
501
  interface Selectors {
496
- [selector: string]: attributes.SVGAttributes | undefined;
502
+ [selector: string]: Nullable<attributes.SVGAttributes> | undefined;
497
503
  }
498
504
 
499
505
  interface Attributes extends GenericAttributes<Selectors> {
@@ -546,7 +552,7 @@ export namespace dia {
546
552
  }
547
553
 
548
554
  interface ExportOptions {
549
- ignoreDefault?: boolean | string[];
555
+ ignoreDefaults?: boolean | string[];
550
556
  ignoreEmptyAttributes?: boolean;
551
557
  }
552
558
 
@@ -918,18 +924,7 @@ export namespace dia {
918
924
  connector?: connectors.Connector | connectors.ConnectorJSON;
919
925
  }
920
926
 
921
- interface LinkSelectors extends Cell.Selectors {
922
- '.connection'?: attributes.SVGPathAttributes;
923
- '.connection-wrap'?: attributes.SVGPathAttributes;
924
- '.marker-source'?: attributes.SVGPathAttributes;
925
- '.marker-target'?: attributes.SVGPathAttributes;
926
- '.labels'?: attributes.SVGAttributes;
927
- '.marker-vertices'?: attributes.SVGAttributes;
928
- '.marker-arrowheads'?: attributes.SVGAttributes;
929
- '.link-tools'?: attributes.SVGAttributes;
930
- }
931
-
932
- interface Attributes extends Cell.GenericAttributes<LinkSelectors> {
927
+ interface Attributes extends Cell.GenericAttributes<Cell.Selectors> {
933
928
  }
934
929
 
935
930
  interface LabelPosition {
@@ -2740,43 +2735,43 @@ export namespace highlighters {
2740
2735
  export namespace shapes {
2741
2736
 
2742
2737
  interface SVGTextSelector extends dia.Cell.Selectors {
2743
- text?: attributes.SVGTextAttributes;
2738
+ text?: Nullable<attributes.SVGTextAttributes>;
2744
2739
  }
2745
2740
 
2746
2741
  interface SVGRectSelector extends dia.Cell.Selectors {
2747
- rect?: attributes.SVGRectAttributes;
2742
+ rect?: Nullable<attributes.SVGRectAttributes>;
2748
2743
  }
2749
2744
 
2750
2745
  interface SVGCircleSelector extends dia.Cell.Selectors {
2751
- circle?: attributes.SVGCircleAttributes;
2746
+ circle?: Nullable<attributes.SVGCircleAttributes>;
2752
2747
  }
2753
2748
 
2754
2749
  interface SVGEllipseSelector extends dia.Cell.Selectors {
2755
- ellipse?: attributes.SVGEllipseAttributes;
2750
+ ellipse?: Nullable<attributes.SVGEllipseAttributes>;
2756
2751
  }
2757
2752
 
2758
2753
  interface SVGPolygonSelector extends dia.Cell.Selectors {
2759
- polygon?: attributes.SVGPolygonAttributes;
2754
+ polygon?: Nullable<attributes.SVGPolygonAttributes>;
2760
2755
  }
2761
2756
 
2762
2757
  interface SVGPolylineSelector extends dia.Cell.Selectors {
2763
- polyline?: attributes.SVGPolylineAttributes;
2758
+ polyline?: Nullable<attributes.SVGPolylineAttributes>;
2764
2759
  }
2765
2760
 
2766
2761
  interface SVGImageSelector extends dia.Cell.Selectors {
2767
- image?: attributes.SVGImageAttributes;
2762
+ image?: Nullable<attributes.SVGImageAttributes>;
2768
2763
  }
2769
2764
 
2770
2765
  interface SVGPathSelector extends dia.Cell.Selectors {
2771
- path?: attributes.SVGPathAttributes;
2766
+ path?: Nullable<attributes.SVGPathAttributes>;
2772
2767
  }
2773
2768
 
2774
2769
  namespace standard {
2775
2770
 
2776
2771
  interface RectangleSelectors extends dia.Cell.Selectors {
2777
- root?: attributes.SVGAttributes;
2778
- body?: attributes.SVGRectAttributes;
2779
- label?: attributes.SVGTextAttributes;
2772
+ root?: Nullable<attributes.SVGAttributes>;
2773
+ body?: Nullable<attributes.SVGRectAttributes>;
2774
+ label?: Nullable<attributes.SVGTextAttributes>;
2780
2775
  }
2781
2776
 
2782
2777
  type RectangleAttributes = dia.Element.GenericAttributes<RectangleSelectors>;
@@ -2785,9 +2780,9 @@ export namespace shapes {
2785
2780
  }
2786
2781
 
2787
2782
  interface CircleSelectors extends dia.Cell.Selectors {
2788
- root?: attributes.SVGAttributes;
2789
- body?: attributes.SVGCircleAttributes;
2790
- label?: attributes.SVGTextAttributes;
2783
+ root?: Nullable<attributes.SVGAttributes>;
2784
+ body?: Nullable<attributes.SVGCircleAttributes>;
2785
+ label?: Nullable<attributes.SVGTextAttributes>;
2791
2786
  }
2792
2787
 
2793
2788
  type CircleAttributes = dia.Element.GenericAttributes<CircleSelectors>;
@@ -2796,9 +2791,9 @@ export namespace shapes {
2796
2791
  }
2797
2792
 
2798
2793
  interface EllipseSelectors extends dia.Cell.Selectors {
2799
- root?: attributes.SVGAttributes;
2800
- body?: attributes.SVGEllipseAttributes;
2801
- label?: attributes.SVGTextAttributes;
2794
+ root?: Nullable<attributes.SVGAttributes>;
2795
+ body?: Nullable<attributes.SVGEllipseAttributes>;
2796
+ label?: Nullable<attributes.SVGTextAttributes>;
2802
2797
  }
2803
2798
 
2804
2799
  type EllipseAttributes = dia.Element.GenericAttributes<EllipseSelectors>;
@@ -2807,9 +2802,9 @@ export namespace shapes {
2807
2802
  }
2808
2803
 
2809
2804
  interface PathSelectors extends dia.Cell.Selectors {
2810
- root?: attributes.SVGAttributes;
2811
- body?: attributes.SVGPathAttributes;
2812
- label?: attributes.SVGTextAttributes;
2805
+ root?: Nullable<attributes.SVGAttributes>;
2806
+ body?: Nullable<attributes.SVGPathAttributes>;
2807
+ label?: Nullable<attributes.SVGTextAttributes>;
2813
2808
  }
2814
2809
 
2815
2810
  type PathAttributes = dia.Element.GenericAttributes<PathSelectors>;
@@ -2818,9 +2813,9 @@ export namespace shapes {
2818
2813
  }
2819
2814
 
2820
2815
  interface PolygonSelectors extends dia.Cell.Selectors {
2821
- root?: attributes.SVGAttributes;
2822
- body?: attributes.SVGPolygonAttributes;
2823
- label?: attributes.SVGTextAttributes;
2816
+ root?: Nullable<attributes.SVGAttributes>;
2817
+ body?: Nullable<attributes.SVGPolygonAttributes>;
2818
+ label?: Nullable<attributes.SVGTextAttributes>;
2824
2819
  }
2825
2820
 
2826
2821
  type PolygonAttributes = dia.Element.GenericAttributes<PolygonSelectors>;
@@ -2829,9 +2824,9 @@ export namespace shapes {
2829
2824
  }
2830
2825
 
2831
2826
  interface PolylineSelectors extends dia.Cell.Selectors {
2832
- root?: attributes.SVGAttributes;
2833
- body?: attributes.SVGPolylineAttributes;
2834
- label?: attributes.SVGTextAttributes;
2827
+ root?: Nullable<attributes.SVGAttributes>;
2828
+ body?: Nullable<attributes.SVGPolylineAttributes>;
2829
+ label?: Nullable<attributes.SVGTextAttributes>;
2835
2830
  }
2836
2831
 
2837
2832
  type PolylineAttributes = dia.Element.GenericAttributes<PolylineSelectors>;
@@ -2840,9 +2835,9 @@ export namespace shapes {
2840
2835
  }
2841
2836
 
2842
2837
  interface ImageSelectors extends dia.Cell.Selectors {
2843
- root?: attributes.SVGAttributes;
2844
- image?: attributes.SVGImageAttributes;
2845
- label?: attributes.SVGTextAttributes;
2838
+ root?: Nullable<attributes.SVGAttributes>;
2839
+ image?: Nullable<attributes.SVGImageAttributes>;
2840
+ label?: Nullable<attributes.SVGTextAttributes>;
2846
2841
  }
2847
2842
 
2848
2843
  type ImageAttributes = dia.Element.GenericAttributes<ImageSelectors>;
@@ -2851,11 +2846,11 @@ export namespace shapes {
2851
2846
  }
2852
2847
 
2853
2848
  interface BorderedImageSelectors extends dia.Cell.Selectors {
2854
- root?: attributes.SVGAttributes;
2855
- border?: attributes.SVGRectAttributes;
2856
- background?: attributes.SVGRectAttributes;
2857
- image?: attributes.SVGImageAttributes;
2858
- label?: attributes.SVGTextAttributes;
2849
+ root?: Nullable<attributes.SVGAttributes>;
2850
+ border?: Nullable<attributes.SVGRectAttributes>;
2851
+ background?: Nullable<attributes.SVGRectAttributes>;
2852
+ image?: Nullable<attributes.SVGImageAttributes>;
2853
+ label?: Nullable<attributes.SVGTextAttributes>;
2859
2854
  }
2860
2855
 
2861
2856
  type BorderedImageAttributes = dia.Element.GenericAttributes<BorderedImageSelectors>;
@@ -2864,10 +2859,10 @@ export namespace shapes {
2864
2859
  }
2865
2860
 
2866
2861
  interface EmbeddedImageSelectors extends dia.Cell.Selectors {
2867
- root?: attributes.SVGAttributes;
2868
- body?: attributes.SVGRectAttributes;
2869
- image?: attributes.SVGImageAttributes;
2870
- label?: attributes.SVGTextAttributes;
2862
+ root?: Nullable<attributes.SVGAttributes>;
2863
+ body?: Nullable<attributes.SVGRectAttributes>;
2864
+ image?: Nullable<attributes.SVGImageAttributes>;
2865
+ label?: Nullable<attributes.SVGTextAttributes>;
2871
2866
  }
2872
2867
 
2873
2868
  type EmbeddedImageAttributes = dia.Element.GenericAttributes<EmbeddedImageSelectors>;
@@ -2876,11 +2871,11 @@ export namespace shapes {
2876
2871
  }
2877
2872
 
2878
2873
  interface InscribedImageSelectors extends dia.Cell.Selectors {
2879
- root?: attributes.SVGAttributes;
2880
- border?: attributes.SVGEllipseAttributes;
2881
- background?: attributes.SVGEllipseAttributes;
2882
- image?: attributes.SVGImageAttributes;
2883
- label?: attributes.SVGTextAttributes;
2874
+ root?: Nullable<attributes.SVGAttributes>;
2875
+ border?: Nullable<attributes.SVGEllipseAttributes>;
2876
+ background?: Nullable<attributes.SVGEllipseAttributes>;
2877
+ image?: Nullable<attributes.SVGImageAttributes>;
2878
+ label?: Nullable<attributes.SVGTextAttributes>;
2884
2879
  }
2885
2880
 
2886
2881
  type InscribedImageAttributes = dia.Element.GenericAttributes<InscribedImageSelectors>;
@@ -2889,11 +2884,11 @@ export namespace shapes {
2889
2884
  }
2890
2885
 
2891
2886
  interface HeaderedRectangleSelectors extends dia.Cell.Selectors {
2892
- root?: attributes.SVGAttributes;
2893
- body?: attributes.SVGRectAttributes;
2894
- header?: attributes.SVGRectAttributes;
2895
- headerText?: attributes.SVGTextAttributes;
2896
- bodyText?: attributes.SVGTextAttributes;
2887
+ root?: Nullable<attributes.SVGAttributes>;
2888
+ body?: Nullable<attributes.SVGRectAttributes>;
2889
+ header?: Nullable<attributes.SVGRectAttributes>;
2890
+ headerText?: Nullable<attributes.SVGTextAttributes>;
2891
+ bodyText?: Nullable<attributes.SVGTextAttributes>;
2897
2892
  }
2898
2893
 
2899
2894
  type HeaderedRectangleAttributes = dia.Element.GenericAttributes<HeaderedRectangleSelectors>;
@@ -2906,9 +2901,9 @@ export namespace shapes {
2906
2901
  }
2907
2902
 
2908
2903
  interface CylinderSelectors extends dia.Cell.Selectors {
2909
- root?: attributes.SVGAttributes;
2904
+ root?: Nullable<attributes.SVGAttributes>;
2910
2905
  body?: CylinderBodyAttributes;
2911
- top?: attributes.SVGEllipseAttributes;
2906
+ top?: Nullable<attributes.SVGEllipseAttributes>;
2912
2907
  }
2913
2908
 
2914
2909
  type CylinderAttributes = dia.Element.GenericAttributes<CylinderSelectors>;
@@ -2919,13 +2914,13 @@ export namespace shapes {
2919
2914
  }
2920
2915
 
2921
2916
  interface TextBlockSelectors extends dia.Cell.Selectors {
2922
- root?: attributes.SVGAttributes;
2923
- body?: attributes.SVGRectAttributes;
2924
- label?: {
2917
+ root?: Nullable<attributes.SVGAttributes>;
2918
+ body?: Nullable<attributes.SVGRectAttributes>;
2919
+ label?: Nullable<{
2925
2920
  text?: string;
2926
2921
  style?: { [key: string]: any };
2927
2922
  [key: string]: any;
2928
- };
2923
+ }>;
2929
2924
  }
2930
2925
 
2931
2926
  type TextBlockAttributes = dia.Element.GenericAttributes<TextBlockSelectors>;
@@ -2934,9 +2929,9 @@ export namespace shapes {
2934
2929
  }
2935
2930
 
2936
2931
  interface LinkSelectors extends dia.Cell.Selectors {
2937
- root?: attributes.SVGAttributes;
2938
- line?: attributes.SVGPathAttributes;
2939
- wrapper?: attributes.SVGPathAttributes;
2932
+ root?: Nullable<attributes.SVGAttributes>;
2933
+ line?: Nullable<attributes.SVGPathAttributes>;
2934
+ wrapper?: Nullable<attributes.SVGPathAttributes>;
2940
2935
  }
2941
2936
 
2942
2937
  type LinkAttributes = dia.Link.GenericAttributes<LinkSelectors>;
@@ -2945,9 +2940,9 @@ export namespace shapes {
2945
2940
  }
2946
2941
 
2947
2942
  interface DoubleLinkSelectors extends dia.Cell.Selectors {
2948
- root?: attributes.SVGAttributes;
2949
- line?: attributes.SVGPathAttributes;
2950
- outline?: attributes.SVGPathAttributes;
2943
+ root?: Nullable<attributes.SVGAttributes>;
2944
+ line?: Nullable<attributes.SVGPathAttributes>;
2945
+ outline?: Nullable<attributes.SVGPathAttributes>;
2951
2946
  }
2952
2947
 
2953
2948
  type DoubleLinkAttributes = dia.Link.GenericAttributes<DoubleLinkSelectors>;
@@ -2956,9 +2951,9 @@ export namespace shapes {
2956
2951
  }
2957
2952
 
2958
2953
  interface ShadowLinkSelectors extends dia.Cell.Selectors {
2959
- root?: attributes.SVGAttributes;
2960
- line?: attributes.SVGPathAttributes;
2961
- shadow?: attributes.SVGPathAttributes;
2954
+ root?: Nullable<attributes.SVGAttributes>;
2955
+ line?: Nullable<attributes.SVGPathAttributes>;
2956
+ shadow?: Nullable<attributes.SVGPathAttributes>;
2962
2957
  }
2963
2958
 
2964
2959
  type ShadowLinkAttributes = dia.Link.GenericAttributes<ShadowLinkSelectors>;
@@ -2966,52 +2961,6 @@ export namespace shapes {
2966
2961
  class ShadowLink extends dia.Link<ShadowLinkAttributes> {
2967
2962
  }
2968
2963
  }
2969
-
2970
- namespace devs {
2971
-
2972
- interface ModelSelectors extends dia.Cell.Selectors {
2973
- '.label'?: attributes.SVGTextAttributes;
2974
- '.body'?: attributes.SVGRectAttributes;
2975
- }
2976
-
2977
- interface ModelAttributes extends dia.Element.GenericAttributes<ModelSelectors> {
2978
- inPorts?: string[];
2979
- outPorts?: string[];
2980
- }
2981
-
2982
- class Model extends dia.Element {
2983
-
2984
- constructor(attributes?: ModelAttributes, opt?: { [key: string]: any });
2985
-
2986
- changeInGroup(properties: any, opt?: any): boolean;
2987
-
2988
- changeOutGroup(properties: any, opt?: any): boolean;
2989
-
2990
- createPortItem(group: string, port: string): any;
2991
-
2992
- createPortItems(group: string, ports: string[]): any[];
2993
-
2994
- addOutPort(port: string, opt?: any): this;
2995
-
2996
- addInPort(port: string, opt?: any): this;
2997
-
2998
- removeOutPort(port: string, opt?: any): this;
2999
-
3000
- removeInPort(port: string, opt?: any): this;
3001
- }
3002
-
3003
- class Coupled extends Model {
3004
-
3005
- }
3006
-
3007
- class Atomic extends Model {
3008
-
3009
- }
3010
-
3011
- class Link extends dia.Link {
3012
-
3013
- }
3014
- }
3015
2964
  }
3016
2965
 
3017
2966
  // util
@@ -3370,9 +3319,17 @@ export namespace layout {
3370
3319
  angle: number;
3371
3320
  };
3372
3321
 
3373
- type LayoutFunction = (ports: Array<dia.Element.Port>, elBBox: g.Rect, opt: Options) => Array<Transformation>;
3322
+ interface LayoutOptions {
3323
+ [key: string]: any;
3324
+ }
3374
3325
 
3375
- interface Options {
3326
+ type LayoutFunction<T = LayoutOptions> = (
3327
+ portsArgs: Array<T>,
3328
+ elBBox: g.Rect,
3329
+ portGroupArgs: LayoutOptions
3330
+ ) => Array<Partial<Transformation>>;
3331
+
3332
+ interface Options extends LayoutOptions {
3376
3333
  x?: number | string;
3377
3334
  y?: number | string;
3378
3335
  dx?: number;
@@ -3383,19 +3340,20 @@ export namespace layout {
3383
3340
  startAngle?: number;
3384
3341
  step?: number;
3385
3342
  compensateRotation?: boolean;
3386
- [key: string]: any;
3387
3343
  }
3388
3344
 
3389
- export var absolute: LayoutFunction;
3345
+ /** @todo define Options types per-layout */
3346
+ export var absolute: LayoutFunction<Options>;
3347
+ export var line: LayoutFunction<Options>;
3348
+ export var left: LayoutFunction<Options>;
3349
+ export var right: LayoutFunction<Options>;
3350
+ export var top: LayoutFunction<Options>;
3351
+ export var bottom: LayoutFunction<Options>;
3352
+ export var ellipseSpread: LayoutFunction<Options>;
3353
+ export var ellipse: LayoutFunction<Options>;
3354
+
3390
3355
  /** @deprecated */
3391
- export var fn: LayoutFunction;
3392
- export var line: LayoutFunction;
3393
- export var left: LayoutFunction;
3394
- export var right: LayoutFunction;
3395
- export var top: LayoutFunction;
3396
- export var bottom: LayoutFunction;
3397
- export var ellipseSpread: LayoutFunction;
3398
- export var ellipse: LayoutFunction;
3356
+ export var fn: LayoutFunction<Options>;
3399
3357
  }
3400
3358
 
3401
3359
  export namespace PortLabel {