@joint/core 4.0.4 → 4.1.0
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/README.md +0 -8
- package/dist/geometry.js +4962 -6132
- package/dist/geometry.min.js +2 -2
- package/dist/joint.d.ts +328 -50
- package/dist/joint.js +34067 -37565
- package/dist/joint.min.js +2 -2
- package/dist/joint.nowrap.js +34067 -37565
- package/dist/joint.nowrap.min.js +2 -2
- package/dist/vectorizer.js +7288 -8907
- package/dist/vectorizer.min.js +2 -2
- package/dist/version.mjs +1 -1
- package/package.json +10 -15
- package/src/{linkTools → cellTools}/Button.mjs +8 -6
- package/src/{elementTools → cellTools}/Control.mjs +3 -3
- package/src/{linkTools → cellTools}/HoverConnect.mjs +1 -1
- package/src/dia/Cell.mjs +60 -33
- package/src/dia/CellView.mjs +75 -8
- package/src/dia/ElementView.mjs +13 -8
- package/src/dia/Graph.mjs +148 -40
- package/src/dia/HighlighterView.mjs +8 -4
- package/src/dia/LinkView.mjs +42 -3
- package/src/dia/Paper.mjs +84 -0
- package/src/dia/ToolView.mjs +29 -4
- package/src/dia/ToolsView.mjs +25 -10
- package/src/dia/attributes/connection.mjs +5 -0
- package/src/dia/attributes/defs.mjs +3 -0
- package/src/dia/attributes/eval.mjs +3 -3
- package/src/dia/attributes/index.mjs +3 -0
- package/src/dia/attributes/shape.mjs +4 -0
- package/src/dia/attributes/text.mjs +15 -5
- package/src/dia/ports.mjs +4 -0
- package/src/elementTools/HoverConnect.mjs +5 -5
- package/src/elementTools/index.mjs +5 -4
- package/src/g/rect.mjs +13 -5
- package/src/layout/ports/port.mjs +4 -5
- package/src/linkTools/Anchor.mjs +1 -1
- package/src/linkTools/Arrowhead.mjs +2 -1
- package/src/linkTools/RotateLabel.mjs +110 -0
- package/src/linkTools/Segments.mjs +1 -1
- package/src/linkTools/Vertices.mjs +41 -4
- package/src/linkTools/index.mjs +7 -4
- package/src/mvc/View.mjs +0 -1
- package/src/mvc/ViewBase.mjs +2 -1
- package/src/routers/rightAngle.mjs +538 -140
- package/src/shapes/standard.mjs +8 -1
- package/src/{dia/attributes → util}/calc.mjs +24 -12
- package/src/util/index.mjs +1 -0
- package/src/util/util.mjs +39 -0
- package/src/util/utilHelpers.mjs +2 -1
- package/types/geometry.d.ts +6 -1
- package/types/joint.d.ts +321 -48
- /package/src/{linkTools → cellTools}/Boundary.mjs +0 -0
- /package/src/{linkTools → cellTools}/Connect.mjs +0 -0
- /package/src/{linkTools → cellTools}/helpers.mjs +0 -0
package/src/shapes/standard.mjs
CHANGED
|
@@ -530,7 +530,8 @@ export const Cylinder = Element.define('standard.Cylinder', {
|
|
|
530
530
|
'Z'
|
|
531
531
|
];
|
|
532
532
|
return { d: data.join(' ') };
|
|
533
|
-
}
|
|
533
|
+
},
|
|
534
|
+
unset: 'd'
|
|
534
535
|
}
|
|
535
536
|
}
|
|
536
537
|
});
|
|
@@ -613,6 +614,12 @@ export const TextBlock = Element.define('standard.TextBlock', {
|
|
|
613
614
|
return { fill: style.color || null };
|
|
614
615
|
}
|
|
615
616
|
},
|
|
617
|
+
unset: function(node) {
|
|
618
|
+
node.textContent = '';
|
|
619
|
+
if (node instanceof SVGElement) {
|
|
620
|
+
return 'fill';
|
|
621
|
+
}
|
|
622
|
+
},
|
|
616
623
|
position: function(text, refBBox, node) {
|
|
617
624
|
// No foreign object
|
|
618
625
|
if (node instanceof SVGElement) return refBBox.center();
|
|
@@ -10,18 +10,22 @@ const props = {
|
|
|
10
10
|
const propsList = Object.keys(props).map(key => props[key]).join('');
|
|
11
11
|
const numberPattern = '[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?';
|
|
12
12
|
const findSpacesRegex = /\s/g;
|
|
13
|
-
const
|
|
13
|
+
const parseFormulaRegExp = new RegExp(`^(${numberPattern}\\*)?([${propsList}])(/${numberPattern})?([-+]{1,2}${numberPattern})?$`, 'g');
|
|
14
14
|
|
|
15
15
|
function throwInvalid(expression) {
|
|
16
16
|
throw new Error(`Invalid calc() expression: ${expression}`);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
/*
|
|
20
|
+
* Evaluate the given calc formula.
|
|
21
|
+
* e.g. 'w + 10' in a rect 100x100 -> 110
|
|
22
|
+
*/
|
|
23
|
+
export function evalCalcFormula(formula, rect) {
|
|
24
|
+
const match = parseFormulaRegExp.exec(formula.replace(findSpacesRegex, ''));
|
|
25
|
+
if (!match) throwInvalid(formula);
|
|
26
|
+
parseFormulaRegExp.lastIndex = 0; // reset regex results for the next run
|
|
23
27
|
const [,multiply, property, divide, add] = match;
|
|
24
|
-
const { x, y, width, height } =
|
|
28
|
+
const { x, y, width, height } = rect;
|
|
25
29
|
let value = 0;
|
|
26
30
|
switch (property) {
|
|
27
31
|
case props.width: {
|
|
@@ -81,15 +85,23 @@ function evalAddExpression(addExpression) {
|
|
|
81
85
|
return parseFloat(addExpression);
|
|
82
86
|
}
|
|
83
87
|
|
|
84
|
-
|
|
88
|
+
/*
|
|
89
|
+
* Check if the given value is a calc expression.
|
|
90
|
+
* e.g. 'calc(10 + 100)' -> true
|
|
91
|
+
*/
|
|
92
|
+
export function isCalcExpression(value) {
|
|
85
93
|
return typeof value === 'string' && value.includes('calc');
|
|
86
94
|
}
|
|
87
95
|
|
|
88
96
|
const calcStart = 'calc(';
|
|
89
97
|
const calcStartOffset = calcStart.length;
|
|
90
98
|
|
|
91
|
-
|
|
92
|
-
|
|
99
|
+
/*
|
|
100
|
+
* Evaluate all calc formulas in the given expression.
|
|
101
|
+
* e.g. 'calc(w + 10)' in rect 100x100 -> '110'
|
|
102
|
+
*/
|
|
103
|
+
export function evalCalcExpression(expression, rect) {
|
|
104
|
+
let value = expression;
|
|
93
105
|
let startSearchIndex = 0;
|
|
94
106
|
do {
|
|
95
107
|
let calcIndex = value.indexOf(calcStart, startSearchIndex);
|
|
@@ -116,11 +128,11 @@ export function evalCalcAttribute(attributeValue, refBBox) {
|
|
|
116
128
|
} while (true);
|
|
117
129
|
// Get the calc() expression without nested calcs (recursion)
|
|
118
130
|
let expression = value.slice(calcIndex + calcStartOffset, calcEndIndex);
|
|
119
|
-
if (
|
|
120
|
-
expression =
|
|
131
|
+
if (isCalcExpression(expression)) {
|
|
132
|
+
expression = evalCalcExpression(expression, rect);
|
|
121
133
|
}
|
|
122
134
|
// Eval the calc() expression without nested calcs.
|
|
123
|
-
const calcValue = String(
|
|
135
|
+
const calcValue = String(evalCalcFormula(expression, rect));
|
|
124
136
|
// Replace the calc() expression and continue search
|
|
125
137
|
value = value.slice(0, calcIndex) + calcValue + value.slice(calcEndIndex + 1);
|
|
126
138
|
startSearchIndex = calcIndex + calcValue.length;
|
package/src/util/index.mjs
CHANGED
package/src/util/util.mjs
CHANGED
|
@@ -1708,6 +1708,45 @@ export const toggleFullScreen = function(el) {
|
|
|
1708
1708
|
}
|
|
1709
1709
|
};
|
|
1710
1710
|
|
|
1711
|
+
function findDifference(obj, baseObj, currentDepth, maxDepth) {
|
|
1712
|
+
|
|
1713
|
+
if (currentDepth === maxDepth) {
|
|
1714
|
+
return {};
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
const diff = {};
|
|
1718
|
+
|
|
1719
|
+
Object.keys(obj).forEach((key) => {
|
|
1720
|
+
|
|
1721
|
+
const objValue = obj[key];
|
|
1722
|
+
const baseValue = baseObj[key];
|
|
1723
|
+
|
|
1724
|
+
if (!Array.isArray(objValue) && !Array.isArray(baseValue) && isObject(objValue) && isObject(baseValue)) {
|
|
1725
|
+
|
|
1726
|
+
const nestedDepth = currentDepth + 1;
|
|
1727
|
+
const nestedDiff = findDifference(objValue, baseValue, nestedDepth, maxDepth);
|
|
1728
|
+
|
|
1729
|
+
if (Object.keys(nestedDiff).length > 0) {
|
|
1730
|
+
diff[key] = nestedDiff;
|
|
1731
|
+
} else if ((currentDepth === 0 || nestedDepth === maxDepth)) {
|
|
1732
|
+
diff[key] = {};
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
} else if (!isEqual(objValue, baseValue)) {
|
|
1736
|
+
diff[key] = objValue;
|
|
1737
|
+
}
|
|
1738
|
+
});
|
|
1739
|
+
|
|
1740
|
+
return diff;
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
export function objectDifference(object, base, opt) {
|
|
1744
|
+
|
|
1745
|
+
const { maxDepth = Number.POSITIVE_INFINITY } = opt || {};
|
|
1746
|
+
|
|
1747
|
+
return findDifference(object, base, 0, maxDepth);
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1711
1750
|
export {
|
|
1712
1751
|
isBoolean,
|
|
1713
1752
|
isObject,
|
package/src/util/utilHelpers.mjs
CHANGED
|
@@ -678,7 +678,8 @@ const equalByTag = (object, other, tag, equalFunc, stack) => {
|
|
|
678
678
|
case stringTag:
|
|
679
679
|
return object == `${other}`;
|
|
680
680
|
case mapTag:
|
|
681
|
-
|
|
681
|
+
// This use of 'var' is intentional. Don't remove if replacing all instances.
|
|
682
|
+
var convert = mapToArray;
|
|
682
683
|
// Intentional fallthrough
|
|
683
684
|
// eslint-disable-next-line no-fallthrough
|
|
684
685
|
case setTag:
|
package/types/geometry.d.ts
CHANGED
|
@@ -37,6 +37,11 @@ export namespace g {
|
|
|
37
37
|
precision?: number;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
export interface StrictOpt {
|
|
41
|
+
|
|
42
|
+
strict?: boolean;
|
|
43
|
+
}
|
|
44
|
+
|
|
40
45
|
export interface SubdivisionsOpt extends PrecisionOpt {
|
|
41
46
|
|
|
42
47
|
subdivisions?: Curve[];
|
|
@@ -644,7 +649,7 @@ export namespace g {
|
|
|
644
649
|
|
|
645
650
|
clone(): Rect;
|
|
646
651
|
|
|
647
|
-
containsPoint(p: PlainPoint | string): boolean;
|
|
652
|
+
containsPoint(p: PlainPoint | string, opt?: StrictOpt): boolean;
|
|
648
653
|
|
|
649
654
|
containsRect(r: PlainRect): boolean;
|
|
650
655
|
|