@joint/core 4.2.0-alpha.1 → 4.2.0-beta.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/dist/geometry.js +1 -1
- package/dist/geometry.min.js +2 -3
- package/dist/joint.d.ts +321 -55
- package/dist/joint.js +2492 -853
- package/dist/joint.min.js +2 -3
- package/dist/joint.nowrap.js +2492 -853
- package/dist/joint.nowrap.min.js +2 -3
- package/dist/vectorizer.js +1 -1
- package/dist/vectorizer.min.js +2 -3
- package/dist/version.mjs +1 -1
- package/package.json +7 -7
- package/src/config/index.mjs +3 -1
- package/src/dia/Cell.mjs +77 -80
- package/src/dia/CellCollection.mjs +136 -0
- package/src/dia/CellView.mjs +1 -2
- package/src/dia/Element.mjs +2 -3
- package/src/dia/Graph.mjs +610 -317
- package/src/dia/GraphLayer.mjs +53 -0
- package/src/dia/GraphLayerCollection.mjs +313 -0
- package/src/dia/GraphLayerView.mjs +128 -0
- package/src/dia/GraphLayersController.mjs +166 -0
- package/src/dia/GraphTopologyIndex.mjs +222 -0
- package/src/dia/{layers/GridLayer.mjs → GridLayerView.mjs} +23 -16
- package/src/dia/{PaperLayer.mjs → LayerView.mjs} +52 -17
- package/src/dia/LegacyGraphLayerView.mjs +14 -0
- package/src/dia/Paper.mjs +756 -423
- package/src/dia/ToolsView.mjs +3 -3
- package/src/dia/index.mjs +6 -1
- package/src/dia/ports.mjs +11 -2
- package/src/dia/symbols.mjs +24 -0
- package/src/mvc/Collection.mjs +19 -19
- package/src/mvc/Model.mjs +13 -10
- package/types/joint.d.ts +320 -54
package/src/dia/ToolsView.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as mvc from '../mvc/index.mjs';
|
|
2
2
|
import * as util from '../util/index.mjs';
|
|
3
3
|
import { CellView } from './CellView.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import { Paper } from './Paper.mjs';
|
|
5
5
|
import { ToolView } from './ToolView.mjs';
|
|
6
6
|
|
|
7
7
|
export const ToolsView = mvc.View.extend({
|
|
@@ -14,7 +14,7 @@ export const ToolsView = mvc.View.extend({
|
|
|
14
14
|
tools: null,
|
|
15
15
|
relatedView: null,
|
|
16
16
|
name: null,
|
|
17
|
-
// layer?:
|
|
17
|
+
// layer?: Paper.Layers.TOOLS
|
|
18
18
|
// z?: number
|
|
19
19
|
},
|
|
20
20
|
|
|
@@ -139,7 +139,7 @@ export const ToolsView = mvc.View.extend({
|
|
|
139
139
|
},
|
|
140
140
|
|
|
141
141
|
getLayer() {
|
|
142
|
-
const { layer =
|
|
142
|
+
const { layer = Paper.Layers.TOOLS } = this.options;
|
|
143
143
|
return layer;
|
|
144
144
|
},
|
|
145
145
|
|
package/src/dia/index.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from './Graph.mjs';
|
|
2
2
|
export * from './attributes/index.mjs';
|
|
3
|
-
export * from './PaperLayer.mjs';
|
|
4
3
|
export * from './Cell.mjs';
|
|
5
4
|
export * from './CellView.mjs';
|
|
6
5
|
export * from './Element.mjs';
|
|
@@ -11,3 +10,9 @@ export * from './Paper.mjs';
|
|
|
11
10
|
export * from './ToolView.mjs';
|
|
12
11
|
export * from './ToolsView.mjs';
|
|
13
12
|
export * from './HighlighterView.mjs';
|
|
13
|
+
export * from './GraphLayerView.mjs';
|
|
14
|
+
export * from './LayerView.mjs';
|
|
15
|
+
export * from './GridLayerView.mjs';
|
|
16
|
+
export * from './GraphLayer.mjs';
|
|
17
|
+
export * from './GraphLayerCollection.mjs';
|
|
18
|
+
export * from './CellCollection.mjs';
|
package/src/dia/ports.mjs
CHANGED
|
@@ -350,8 +350,17 @@ PortData.prototype = {
|
|
|
350
350
|
|
|
351
351
|
export const elementPortPrototype = {
|
|
352
352
|
|
|
353
|
-
_initializePorts: function() {
|
|
354
|
-
|
|
353
|
+
_initializePorts: function(options) {
|
|
354
|
+
if (options) {
|
|
355
|
+
// Override port layout namespaces if provided in options
|
|
356
|
+
if (options.portLayoutNamespace) {
|
|
357
|
+
this.portLayoutNamespace = options.portLayoutNamespace;
|
|
358
|
+
}
|
|
359
|
+
// Override port label layout namespaces if provided in options
|
|
360
|
+
if (options.portLabelLayoutNamespace) {
|
|
361
|
+
this.portLabelLayoutNamespace = options.portLabelLayoutNamespace;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
355
364
|
this._createPortData();
|
|
356
365
|
this.on('change:ports', function() {
|
|
357
366
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Internal tags to identify objects as specific JointJS types.
|
|
2
|
+
// Used instead of `instanceof` for performance and cross-frame safety.
|
|
3
|
+
|
|
4
|
+
// dia.Cell
|
|
5
|
+
export const CELL_MARKER = Symbol('joint.cellMarker');
|
|
6
|
+
|
|
7
|
+
// dia.CellCollection
|
|
8
|
+
export const CELL_COLLECTION_MARKER = Symbol('joint.cellCollectionMarker');
|
|
9
|
+
|
|
10
|
+
// dia.GraphLayer
|
|
11
|
+
export const GRAPH_LAYER_MARKER = Symbol('joint.graphLayerMarker');
|
|
12
|
+
|
|
13
|
+
// dia.GraphLayerCollection
|
|
14
|
+
export const GRAPH_LAYER_COLLECTION_MARKER = Symbol('joint.graphLayerCollectionMarker');
|
|
15
|
+
|
|
16
|
+
// dia.CellView
|
|
17
|
+
export const CELL_VIEW_MARKER = Symbol('joint.cellViewMarker');
|
|
18
|
+
|
|
19
|
+
// dia.LayerView
|
|
20
|
+
export const LAYER_VIEW_MARKER = Symbol('joint.layerViewMarker');
|
|
21
|
+
|
|
22
|
+
// dia.GraphLayerView
|
|
23
|
+
export const GRAPH_LAYER_VIEW_MARKER = Symbol('joint.graphLayerViewMarker');
|
|
24
|
+
|
package/src/mvc/Collection.mjs
CHANGED
|
@@ -193,7 +193,7 @@ assign(Collection.prototype, Events, {
|
|
|
193
193
|
for (i = 0; i < toAdd.length; i++) {
|
|
194
194
|
if (at != null) options.index = at + i;
|
|
195
195
|
model = toAdd[i];
|
|
196
|
-
model.trigger('add', model, this, options);
|
|
196
|
+
model.trigger(model.eventPrefix + 'add', model, this, options);
|
|
197
197
|
}
|
|
198
198
|
if (sort || orderChanged) this.trigger('sort', this, options);
|
|
199
199
|
if (toAdd.length || toRemove.length || toMerge.length) {
|
|
@@ -257,9 +257,9 @@ assign(Collection.prototype, Events, {
|
|
|
257
257
|
// properties, or an attributes object that is transformed through modelId.
|
|
258
258
|
get: function(obj) {
|
|
259
259
|
if (obj == null) return void 0;
|
|
260
|
-
return this._byId
|
|
261
|
-
|
|
262
|
-
|
|
260
|
+
return this._byId.get(obj) ||
|
|
261
|
+
this._byId.get(this.modelId(this._isModel(obj) ? obj.attributes : obj, obj.idAttribute)) ||
|
|
262
|
+
obj.cid && this._byId.get(obj.cid);
|
|
263
263
|
},
|
|
264
264
|
|
|
265
265
|
// Returns `true` if the model is in the collection.
|
|
@@ -304,7 +304,7 @@ assign(Collection.prototype, Events, {
|
|
|
304
304
|
|
|
305
305
|
// Define how to uniquely identify models in the collection.
|
|
306
306
|
modelId: function(attrs, idAttribute) {
|
|
307
|
-
return attrs[idAttribute || this.model.prototype
|
|
307
|
+
return attrs[idAttribute || this.model.prototype?.idAttribute || 'id'];
|
|
308
308
|
},
|
|
309
309
|
|
|
310
310
|
// Get an iterator of all models in this collection.
|
|
@@ -375,18 +375,18 @@ assign(Collection.prototype, Events, {
|
|
|
375
375
|
_reset: function() {
|
|
376
376
|
this.length = 0;
|
|
377
377
|
this.models = [];
|
|
378
|
-
this._byId =
|
|
378
|
+
this._byId = new Map();
|
|
379
379
|
},
|
|
380
380
|
|
|
381
381
|
// Prepare a hash of attributes (or other model) to be added to this
|
|
382
382
|
// collection.
|
|
383
383
|
_prepareModel: function(attrs, options) {
|
|
384
384
|
if (this._isModel(attrs)) {
|
|
385
|
-
if (!attrs.collection) attrs.collection = this;
|
|
385
|
+
if (!options.dry && !attrs.collection) attrs.collection = this;
|
|
386
386
|
return attrs;
|
|
387
387
|
}
|
|
388
388
|
options = options ? clone(options) : {};
|
|
389
|
-
options.collection = this;
|
|
389
|
+
if (!options.dry) options.collection = this;
|
|
390
390
|
|
|
391
391
|
var model;
|
|
392
392
|
if (this.model.prototype) {
|
|
@@ -414,13 +414,13 @@ assign(Collection.prototype, Events, {
|
|
|
414
414
|
|
|
415
415
|
// Remove references before triggering 'remove' event to prevent an
|
|
416
416
|
// infinite loop. #3693
|
|
417
|
-
|
|
417
|
+
this._byId.delete(model.cid);
|
|
418
418
|
var id = this.modelId(model.attributes, model.idAttribute);
|
|
419
|
-
if (id != null)
|
|
419
|
+
if (id != null)this._byId.delete(id);
|
|
420
420
|
|
|
421
421
|
if (!options.silent) {
|
|
422
422
|
options.index = index;
|
|
423
|
-
model.trigger('remove', model, this, options);
|
|
423
|
+
model.trigger(model.eventPrefix + 'remove', model, this, options);
|
|
424
424
|
}
|
|
425
425
|
|
|
426
426
|
removed.push(model);
|
|
@@ -438,18 +438,18 @@ assign(Collection.prototype, Events, {
|
|
|
438
438
|
|
|
439
439
|
// Internal method to create a model's ties to a collection.
|
|
440
440
|
_addReference: function(model, options) {
|
|
441
|
-
this._byId
|
|
441
|
+
this._byId.set(model.cid, model);
|
|
442
442
|
var id = this.modelId(model.attributes, model.idAttribute);
|
|
443
|
-
if (id != null) this._byId
|
|
443
|
+
if (id != null) this._byId.set(id, model);
|
|
444
444
|
model.on('all', this._onModelEvent, this);
|
|
445
445
|
},
|
|
446
446
|
|
|
447
447
|
// Internal method to sever a model's ties to a collection.
|
|
448
448
|
_removeReference: function(model, options) {
|
|
449
|
-
|
|
449
|
+
this._byId.delete(model.cid);
|
|
450
450
|
var id = this.modelId(model.attributes, model.idAttribute);
|
|
451
|
-
if (id != null)
|
|
452
|
-
if (this === model.collection) delete model.collection;
|
|
451
|
+
if (id != null) this._byId.delete(id);
|
|
452
|
+
if (!options.dry && this === model.collection) delete model.collection;
|
|
453
453
|
model.off('all', this._onModelEvent, this);
|
|
454
454
|
},
|
|
455
455
|
|
|
@@ -459,12 +459,12 @@ assign(Collection.prototype, Events, {
|
|
|
459
459
|
// in other collections are ignored.
|
|
460
460
|
_onModelEvent: function(event, model, collection, options) {
|
|
461
461
|
if (model) {
|
|
462
|
-
if ((event === 'add' || event === 'remove') && collection !== this) return;
|
|
462
|
+
if ((event === model.eventPrefix + 'add' || event === model.eventPrefix + 'remove') && collection !== this) return;
|
|
463
463
|
if (event === 'changeId') {
|
|
464
464
|
var prevId = this.modelId(model.previousAttributes(), model.idAttribute);
|
|
465
465
|
var id = this.modelId(model.attributes, model.idAttribute);
|
|
466
|
-
if (prevId != null)
|
|
467
|
-
if (id != null) this._byId
|
|
466
|
+
if (prevId != null) this._byId.delete(prevId);
|
|
467
|
+
if (id != null) this._byId.set(id, model);
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
470
|
this.trigger.apply(this, arguments);
|
package/src/mvc/Model.mjs
CHANGED
|
@@ -25,17 +25,12 @@ import {
|
|
|
25
25
|
export var Model = function(attributes, options) {
|
|
26
26
|
var attrs = attributes || {};
|
|
27
27
|
options || (options = {});
|
|
28
|
+
this.eventPrefix = options.eventPrefix || '';
|
|
28
29
|
this.preinitialize.apply(this, arguments);
|
|
29
30
|
this.cid = uniqueId(this.cidPrefix);
|
|
30
31
|
this.attributes = {};
|
|
31
32
|
if (options.collection) this.collection = options.collection;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
// Just _.defaults would work fine, but the additional _.extends
|
|
35
|
-
// is in there for historical reasons. See #3843.
|
|
36
|
-
attrs = defaults(assign({}, attributeDefaults, attrs), attributeDefaults);
|
|
37
|
-
|
|
38
|
-
this.set(attrs, options);
|
|
33
|
+
this._setDefaults(attrs, options);
|
|
39
34
|
this.changed = {};
|
|
40
35
|
this.initialize.apply(this, arguments);
|
|
41
36
|
};
|
|
@@ -137,14 +132,14 @@ assign(Model.prototype, Events, {
|
|
|
137
132
|
if (this.idAttribute in attrs) {
|
|
138
133
|
var prevId = this.id;
|
|
139
134
|
this.id = this.get(this.idAttribute);
|
|
140
|
-
this.trigger('changeId', this, prevId, options);
|
|
135
|
+
this.trigger(this.eventPrefix + 'changeId', this, prevId, options);
|
|
141
136
|
}
|
|
142
137
|
|
|
143
138
|
// Trigger all relevant attribute changes.
|
|
144
139
|
if (!silent) {
|
|
145
140
|
if (changes.length) this._pending = options;
|
|
146
141
|
for (var i = 0; i < changes.length; i++) {
|
|
147
|
-
this.trigger('change:' + changes[i], this, current[changes[i]], options);
|
|
142
|
+
this.trigger(this.eventPrefix + 'change:' + changes[i], this, current[changes[i]], options);
|
|
148
143
|
}
|
|
149
144
|
}
|
|
150
145
|
|
|
@@ -155,7 +150,7 @@ assign(Model.prototype, Events, {
|
|
|
155
150
|
while (this._pending) {
|
|
156
151
|
options = this._pending;
|
|
157
152
|
this._pending = false;
|
|
158
|
-
this.trigger('change', this, options);
|
|
153
|
+
this.trigger(this.eventPrefix + 'change', this, options);
|
|
159
154
|
}
|
|
160
155
|
}
|
|
161
156
|
this._pending = false;
|
|
@@ -235,6 +230,14 @@ assign(Model.prototype, Events, {
|
|
|
235
230
|
if (!error) return true;
|
|
236
231
|
this.trigger('invalid', this, error, assign(options, { validationError: error }));
|
|
237
232
|
return false;
|
|
233
|
+
},
|
|
234
|
+
|
|
235
|
+
_setDefaults: function(ctorAttributes, options) {
|
|
236
|
+
const attributeDefaults = result(this, 'defaults');
|
|
237
|
+
// Just _.defaults would work fine, but the additional _.extends
|
|
238
|
+
// is in there for historical reasons. See #3843.
|
|
239
|
+
const attributes = defaults(assign({}, attributeDefaults, ctorAttributes), attributeDefaults);
|
|
240
|
+
this.set(attributes, options);
|
|
238
241
|
}
|
|
239
242
|
|
|
240
243
|
});
|