@antv/g 5.1.1 → 5.1.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.
- package/dist/index.umd.min.js +2 -2
- package/es/css/CSS.d.ts +4 -2
- package/es/css/CSS.js +6 -2
- package/es/css/StyleValueRegistry.d.ts +23 -55
- package/es/css/StyleValueRegistry.js +65 -79
- package/es/css/interfaces.d.ts +110 -0
- package/es/css/interfaces.js +75 -0
- package/es/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -2
- package/es/css/properties/CSSPropertyLengthOrPercentage.js +34 -14
- package/es/css/properties/CSSPropertyLengthOrPercentage12.d.ts +15 -0
- package/es/css/properties/CSSPropertyLengthOrPercentage12.js +38 -0
- package/es/css/properties/CSSPropertyLengthOrPercentage14.d.ts +25 -0
- package/es/css/properties/CSSPropertyLengthOrPercentage14.js +42 -0
- package/es/css/properties/CSSPropertyPath.d.ts +1 -1
- package/es/css/properties/CSSPropertyPath.js +9 -6
- package/es/css/properties/CSSPropertyPoints.js +7 -4
- package/es/css/properties/index.d.ts +2 -2
- package/es/css/properties/index.js +2 -2
- package/es/display-objects/Path.d.ts +2 -2
- package/es/display-objects/Rect.d.ts +5 -2
- package/es/display-objects/Text.js +2 -2
- package/es/global-module.js +4 -4
- package/es/utils/interpolation.js +3 -2
- package/es/utils/path.js +15 -2
- package/lib/css/CSS.d.ts +4 -2
- package/lib/css/CSS.js +6 -2
- package/lib/css/StyleValueRegistry.d.ts +23 -55
- package/lib/css/StyleValueRegistry.js +66 -79
- package/lib/css/interfaces.d.ts +110 -0
- package/lib/css/interfaces.js +76 -1
- package/lib/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -2
- package/lib/css/properties/CSSPropertyLengthOrPercentage.js +34 -14
- package/lib/css/properties/CSSPropertyLengthOrPercentage12.d.ts +15 -0
- package/lib/css/properties/CSSPropertyLengthOrPercentage12.js +48 -0
- package/lib/css/properties/CSSPropertyLengthOrPercentage14.d.ts +25 -0
- package/lib/css/properties/CSSPropertyLengthOrPercentage14.js +52 -0
- package/lib/css/properties/CSSPropertyPath.d.ts +1 -1
- package/lib/css/properties/CSSPropertyPath.js +10 -6
- package/lib/css/properties/CSSPropertyPoints.js +8 -4
- package/lib/css/properties/index.d.ts +2 -2
- package/lib/css/properties/index.js +17 -17
- package/lib/display-objects/Path.d.ts +2 -2
- package/lib/display-objects/Rect.d.ts +5 -2
- package/lib/display-objects/Text.js +2 -2
- package/lib/global-module.js +3 -3
- package/lib/utils/interpolation.js +4 -2
- package/lib/utils/path.js +15 -2
- package/package.json +3 -3
- package/es/css/properties/CSSPropertyAnchor.d.ts +0 -8
- package/es/css/properties/CSSPropertyAnchor.js +0 -25
- package/es/css/properties/CSSPropertyLineDash.d.ts +0 -9
- package/es/css/properties/CSSPropertyLineDash.js +0 -25
- package/lib/css/properties/CSSPropertyAnchor.d.ts +0 -8
- package/lib/css/properties/CSSPropertyAnchor.js +0 -35
- package/lib/css/properties/CSSPropertyLineDash.d.ts +0 -9
- package/lib/css/properties/CSSPropertyLineDash.js +0 -34
package/es/css/interfaces.js
CHANGED
|
@@ -1,2 +1,77 @@
|
|
|
1
1
|
import { Syringe } from 'mana-syringe';
|
|
2
|
+
/**
|
|
3
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export var PropertySyntax;
|
|
7
|
+
|
|
8
|
+
(function (PropertySyntax) {
|
|
9
|
+
/**
|
|
10
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#coordinate
|
|
11
|
+
*/
|
|
12
|
+
PropertySyntax["COORDINATE"] = "<coordinate>";
|
|
13
|
+
/**
|
|
14
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#color
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
PropertySyntax["COLOR"] = "<color>";
|
|
18
|
+
/**
|
|
19
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#paint
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
PropertySyntax["PAINT"] = "<paint>";
|
|
23
|
+
/**
|
|
24
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#number
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
PropertySyntax["NUMBER"] = "<number>";
|
|
28
|
+
/**
|
|
29
|
+
* <number> with range 0..1
|
|
30
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#opacity_value
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
PropertySyntax["OPACITY_VALUE"] = "<opacity-value>";
|
|
34
|
+
/**
|
|
35
|
+
* <number> with range 0..Infinity
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
PropertySyntax["SHADOW_BLUR"] = "<shadow-blur>";
|
|
39
|
+
/**
|
|
40
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#length
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
PropertySyntax["LENGTH"] = "<length>";
|
|
44
|
+
/**
|
|
45
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#percentage
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
PropertySyntax["PERCENTAGE"] = "<percentage>";
|
|
49
|
+
PropertySyntax["LENGTH_PERCENTAGE"] = "<length> | <percentage>";
|
|
50
|
+
PropertySyntax["LENGTH_PERCENTAGE_12"] = "[<length> | <percentage>]{1,2}";
|
|
51
|
+
/**
|
|
52
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin#formal_syntax
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
PropertySyntax["LENGTH_PERCENTAGE_14"] = "[<length> | <percentage>]{1,4}";
|
|
56
|
+
/**
|
|
57
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
PropertySyntax["LIST_OF_POINTS"] = "<list-of-points>";
|
|
61
|
+
PropertySyntax["PATH"] = "<path>";
|
|
62
|
+
/**
|
|
63
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
PropertySyntax["FILTER"] = "<filter>";
|
|
67
|
+
PropertySyntax["Z_INDEX"] = "<z-index>";
|
|
68
|
+
PropertySyntax["OFFSET_PATH"] = "<offset-path>";
|
|
69
|
+
PropertySyntax["OFFSET_DISTANCE"] = "<offset-distance>";
|
|
70
|
+
PropertySyntax["CLIP_PATH"] = "<clip-path>";
|
|
71
|
+
PropertySyntax["TRANSFORM"] = "<transform>";
|
|
72
|
+
PropertySyntax["TRANSFORM_ORIGIN"] = "<transform-origin>";
|
|
73
|
+
PropertySyntax["TEXT"] = "<text>";
|
|
74
|
+
PropertySyntax["TEXT_TRANSFORM"] = "<text-transform>";
|
|
75
|
+
})(PropertySyntax || (PropertySyntax = {}));
|
|
76
|
+
|
|
2
77
|
export var StyleValueRegistry = Syringe.defineToken('StyleValueRegistry');
|
|
@@ -16,6 +16,5 @@ export declare class CSSPropertyLengthOrPercentage implements Partial<CSSPropert
|
|
|
16
16
|
* CSS.percent(50) -> CSS.px(0.5 * parent.width)
|
|
17
17
|
*/
|
|
18
18
|
calculator(name: string, oldParsed: CSSUnitValue, computed: CSSUnitValue, object: DisplayObject, registry: StyleValueRegistry): CSSUnitValue;
|
|
19
|
-
private
|
|
20
|
-
private calculateUsedValueWithParentBounds;
|
|
19
|
+
private getFontSize;
|
|
21
20
|
}
|
|
@@ -11,7 +11,22 @@ var CSSPropertyLengthOrPercentage =
|
|
|
11
11
|
function () {
|
|
12
12
|
function CSSPropertyLengthOrPercentage() {
|
|
13
13
|
this.parser = parseLengthOrPercentage;
|
|
14
|
-
this.mixer = mergeDimensions;
|
|
14
|
+
this.mixer = mergeDimensions; // private nameToBoundsIndex(name: string): number {
|
|
15
|
+
// if (name === 'x' || name === 'cx' || name === 'width') {
|
|
16
|
+
// return 0;
|
|
17
|
+
// } else if (name === 'y' || name === 'cy' || name === 'height') {
|
|
18
|
+
// return 1;
|
|
19
|
+
// }
|
|
20
|
+
// return 2;
|
|
21
|
+
// }
|
|
22
|
+
// private calculateUsedValueWithParentBounds(object: DisplayObject, name: string) {
|
|
23
|
+
// const bounds = (object.parentElement as DisplayObject).getGeometryBounds();
|
|
24
|
+
// const computedValue = object.computedStyle[name].value;
|
|
25
|
+
// return new CSSUnitValue(
|
|
26
|
+
// (bounds.halfExtents[this.nameToBoundsIndex(name)] * 2 * computedValue) / 100,
|
|
27
|
+
// 'px',
|
|
28
|
+
// );
|
|
29
|
+
// }
|
|
15
30
|
}
|
|
16
31
|
/**
|
|
17
32
|
* according to parent's bounds
|
|
@@ -22,6 +37,8 @@ function () {
|
|
|
22
37
|
|
|
23
38
|
|
|
24
39
|
CSSPropertyLengthOrPercentage.prototype.calculator = function (name, oldParsed, computed, object, registry) {
|
|
40
|
+
var _a;
|
|
41
|
+
|
|
25
42
|
if (CSSUnitValue.isRelativeUnit(computed.unit)) {
|
|
26
43
|
if (computed.unit === UnitType.kPercentage) {
|
|
27
44
|
// try to resolve according to parent's geometry bounds
|
|
@@ -41,7 +58,16 @@ function () {
|
|
|
41
58
|
// }
|
|
42
59
|
return new CSSUnitValue(0, 'px');
|
|
43
60
|
} else if (computed.unit === UnitType.kEms) {
|
|
44
|
-
|
|
61
|
+
if (object.parentNode) {
|
|
62
|
+
return this.getFontSize(object.parentNode);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return new CSSUnitValue(0, 'px');
|
|
66
|
+
} else if (computed.unit === UnitType.kRems) {
|
|
67
|
+
if ((_a = object === null || object === void 0 ? void 0 : object.ownerDocument) === null || _a === void 0 ? void 0 : _a.documentElement) {
|
|
68
|
+
return this.getFontSize(object.ownerDocument.documentElement);
|
|
69
|
+
}
|
|
70
|
+
|
|
45
71
|
return new CSSUnitValue(0, 'px');
|
|
46
72
|
}
|
|
47
73
|
} else {
|
|
@@ -52,20 +78,14 @@ function () {
|
|
|
52
78
|
}
|
|
53
79
|
};
|
|
54
80
|
|
|
55
|
-
CSSPropertyLengthOrPercentage.prototype.
|
|
56
|
-
|
|
57
|
-
return 0;
|
|
58
|
-
} else if (name === 'y' || name === 'cy' || name === 'height') {
|
|
59
|
-
return 1;
|
|
60
|
-
}
|
|
81
|
+
CSSPropertyLengthOrPercentage.prototype.getFontSize = function (object) {
|
|
82
|
+
var fontSize = object.parsedStyle.fontSize;
|
|
61
83
|
|
|
62
|
-
|
|
63
|
-
|
|
84
|
+
if (fontSize && !CSSUnitValue.isRelativeUnit(fontSize.unit)) {
|
|
85
|
+
return fontSize.clone();
|
|
86
|
+
}
|
|
64
87
|
|
|
65
|
-
|
|
66
|
-
var bounds = object.parentElement.getGeometryBounds();
|
|
67
|
-
var computedValue = object.computedStyle[name].value;
|
|
68
|
-
return new CSSUnitValue(bounds.halfExtents[this.nameToBoundsIndex(name)] * 2 * computedValue / 100, 'px');
|
|
88
|
+
return new CSSUnitValue(0, 'px');
|
|
69
89
|
};
|
|
70
90
|
|
|
71
91
|
CSSPropertyLengthOrPercentage = __decorate([singleton()], CSSPropertyLengthOrPercentage);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CSSProperty } from '../CSSProperty';
|
|
2
|
+
import type { CSSUnitValue } from '../cssom';
|
|
3
|
+
import { mergeDimensionList } from '../parser';
|
|
4
|
+
/**
|
|
5
|
+
* format to Tuple2<CSSUnitValue>
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* rect.style.lineDash = 10;
|
|
9
|
+
* rect.style.lineDash = [10, 10];
|
|
10
|
+
* rect.style.lineDash = '10 10';
|
|
11
|
+
*/
|
|
12
|
+
export declare class CSSPropertyLengthOrPercentage12 implements Partial<CSSProperty<[CSSUnitValue, CSSUnitValue], [CSSUnitValue, CSSUnitValue]>> {
|
|
13
|
+
parser(radius: string | number | number[]): [CSSUnitValue, CSSUnitValue];
|
|
14
|
+
mixer: typeof mergeDimensionList;
|
|
15
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { singleton } from 'mana-syringe';
|
|
3
|
+
import { parseDimensionArray, mergeDimensionList } from '../parser';
|
|
4
|
+
import { isNumber } from '../../utils';
|
|
5
|
+
/**
|
|
6
|
+
* format to Tuple2<CSSUnitValue>
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* rect.style.lineDash = 10;
|
|
10
|
+
* rect.style.lineDash = [10, 10];
|
|
11
|
+
* rect.style.lineDash = '10 10';
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
var CSSPropertyLengthOrPercentage12 =
|
|
15
|
+
/** @class */
|
|
16
|
+
function () {
|
|
17
|
+
function CSSPropertyLengthOrPercentage12() {
|
|
18
|
+
this.mixer = mergeDimensionList;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
CSSPropertyLengthOrPercentage12.prototype.parser = function (radius) {
|
|
22
|
+
var parsed = parseDimensionArray(isNumber(radius) ? [radius] : radius);
|
|
23
|
+
var formatted;
|
|
24
|
+
|
|
25
|
+
if (parsed.length === 1) {
|
|
26
|
+
formatted = [parsed[0], parsed[0]];
|
|
27
|
+
} else {
|
|
28
|
+
formatted = [parsed[0], parsed[1]];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return formatted;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
CSSPropertyLengthOrPercentage12 = __decorate([singleton()], CSSPropertyLengthOrPercentage12);
|
|
35
|
+
return CSSPropertyLengthOrPercentage12;
|
|
36
|
+
}();
|
|
37
|
+
|
|
38
|
+
export { CSSPropertyLengthOrPercentage12 };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CSSProperty } from '../CSSProperty';
|
|
2
|
+
import type { CSSUnitValue } from '../cssom';
|
|
3
|
+
import { mergeDimensionList } from '../parser';
|
|
4
|
+
/**
|
|
5
|
+
* used in rounded rect
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* rect.style.radius = 10;
|
|
9
|
+
* rect.style.radius = '10 10';
|
|
10
|
+
* rect.style.radius = '10 10 10 10';
|
|
11
|
+
*/
|
|
12
|
+
export declare class CSSPropertyLengthOrPercentage14 implements Partial<CSSProperty<[
|
|
13
|
+
CSSUnitValue,
|
|
14
|
+
CSSUnitValue,
|
|
15
|
+
CSSUnitValue,
|
|
16
|
+
CSSUnitValue
|
|
17
|
+
], [
|
|
18
|
+
CSSUnitValue,
|
|
19
|
+
CSSUnitValue,
|
|
20
|
+
CSSUnitValue,
|
|
21
|
+
CSSUnitValue
|
|
22
|
+
]>> {
|
|
23
|
+
parser(radius: string | number | number[]): [CSSUnitValue, CSSUnitValue, CSSUnitValue, CSSUnitValue];
|
|
24
|
+
mixer: typeof mergeDimensionList;
|
|
25
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { singleton } from 'mana-syringe';
|
|
3
|
+
import { parseDimensionArray, mergeDimensionList } from '../parser';
|
|
4
|
+
import { isNumber } from '../../utils';
|
|
5
|
+
/**
|
|
6
|
+
* used in rounded rect
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* rect.style.radius = 10;
|
|
10
|
+
* rect.style.radius = '10 10';
|
|
11
|
+
* rect.style.radius = '10 10 10 10';
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
var CSSPropertyLengthOrPercentage14 =
|
|
15
|
+
/** @class */
|
|
16
|
+
function () {
|
|
17
|
+
function CSSPropertyLengthOrPercentage14() {
|
|
18
|
+
this.mixer = mergeDimensionList;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
CSSPropertyLengthOrPercentage14.prototype.parser = function (radius) {
|
|
22
|
+
var parsed = parseDimensionArray(isNumber(radius) ? [radius] : radius);
|
|
23
|
+
var formatted; // format to Tuple<CSSUnitValue>
|
|
24
|
+
|
|
25
|
+
if (parsed.length === 1) {
|
|
26
|
+
formatted = [parsed[0], parsed[0], parsed[0], parsed[0]];
|
|
27
|
+
} else if (parsed.length === 2) {
|
|
28
|
+
formatted = [parsed[0], parsed[1], parsed[0], parsed[1]];
|
|
29
|
+
} else if (parsed.length === 3) {
|
|
30
|
+
formatted = [parsed[0], parsed[1], parsed[2], parsed[1]];
|
|
31
|
+
} else {
|
|
32
|
+
formatted = [parsed[0], parsed[1], parsed[2], parsed[3]];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return formatted;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
CSSPropertyLengthOrPercentage14 = __decorate([singleton()], CSSPropertyLengthOrPercentage14);
|
|
39
|
+
return CSSPropertyLengthOrPercentage14;
|
|
40
|
+
}();
|
|
41
|
+
|
|
42
|
+
export { CSSPropertyLengthOrPercentage14 };
|
|
@@ -10,7 +10,7 @@ export declare class CSSPropertyPath implements Partial<CSSProperty<ParsedPathSt
|
|
|
10
10
|
calculator(name: string, oldParsed: ParsedPathStyleProps['path'], parsed: ParsedPathStyleProps['path']): {
|
|
11
11
|
absolutePath: import("../..").PathCommand[];
|
|
12
12
|
hasArc: boolean;
|
|
13
|
-
segments: import("
|
|
13
|
+
segments: import("../..").PathSegment[];
|
|
14
14
|
polygons: [number, number][][];
|
|
15
15
|
polylines: [number, number][][];
|
|
16
16
|
curve: import("../..").PathCommand[];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { singleton } from 'mana-syringe';
|
|
3
|
+
import { Shape } from '../..';
|
|
3
4
|
import { Rectangle } from '../../shapes';
|
|
4
5
|
import { CSSKeywordValue } from '../cssom';
|
|
5
6
|
import { parsePath, mergePaths } from '../parser';
|
|
@@ -40,12 +41,14 @@ function () {
|
|
|
40
41
|
|
|
41
42
|
|
|
42
43
|
CSSPropertyPath.prototype.postProcessor = function (object) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
if (object.nodeName === Shape.PATH) {
|
|
45
|
+
var _a = object.parsedStyle,
|
|
46
|
+
_b = _a.defX,
|
|
47
|
+
defX = _b === void 0 ? 0 : _b,
|
|
48
|
+
_c = _a.defY,
|
|
49
|
+
defY = _c === void 0 ? 0 : _c;
|
|
50
|
+
object.setLocalPosition(defX, defY);
|
|
51
|
+
}
|
|
49
52
|
};
|
|
50
53
|
|
|
51
54
|
CSSPropertyPath = __decorate([singleton()], CSSPropertyPath);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { singleton } from 'mana-syringe';
|
|
3
|
+
import { Shape } from '../..';
|
|
3
4
|
import { parsePoints } from '../parser';
|
|
4
5
|
|
|
5
6
|
var CSSPropertyPoints =
|
|
@@ -14,10 +15,12 @@ function () {
|
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
CSSPropertyPoints.prototype.postProcessor = function (object) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
if (object.nodeName === Shape.POLYGON || object.nodeName === Shape.POLYLINE) {
|
|
19
|
+
var _a = object.parsedStyle,
|
|
20
|
+
defX = _a.defX,
|
|
21
|
+
defY = _a.defY;
|
|
22
|
+
object.setLocalPosition(defX, defY);
|
|
23
|
+
}
|
|
21
24
|
};
|
|
22
25
|
|
|
23
26
|
CSSPropertyPoints = __decorate([singleton()], CSSPropertyPoints);
|
|
@@ -3,11 +3,11 @@ export * from './CSSPropertyLocalPosition';
|
|
|
3
3
|
export * from './CSSPropertyOpacity';
|
|
4
4
|
export * from './CSSPropertyColor';
|
|
5
5
|
export * from './CSSPropertyFilter';
|
|
6
|
-
export * from './
|
|
6
|
+
export * from './CSSPropertyLengthOrPercentage12';
|
|
7
|
+
export * from './CSSPropertyLengthOrPercentage14';
|
|
7
8
|
export * from './CSSPropertyShadowBlur';
|
|
8
9
|
export * from './CSSPropertyOffsetPath';
|
|
9
10
|
export * from './CSSPropertyOffsetDistance';
|
|
10
|
-
export * from './CSSPropertyAnchor';
|
|
11
11
|
export * from './CSSPropertyZIndex';
|
|
12
12
|
export * from './CSSPropertyTransform';
|
|
13
13
|
export * from './CSSPropertyTransformOrigin';
|
|
@@ -3,11 +3,11 @@ export * from './CSSPropertyLocalPosition';
|
|
|
3
3
|
export * from './CSSPropertyOpacity';
|
|
4
4
|
export * from './CSSPropertyColor';
|
|
5
5
|
export * from './CSSPropertyFilter';
|
|
6
|
-
export * from './
|
|
6
|
+
export * from './CSSPropertyLengthOrPercentage12';
|
|
7
|
+
export * from './CSSPropertyLengthOrPercentage14';
|
|
7
8
|
export * from './CSSPropertyShadowBlur';
|
|
8
9
|
export * from './CSSPropertyOffsetPath';
|
|
9
10
|
export * from './CSSPropertyOffsetDistance';
|
|
10
|
-
export * from './CSSPropertyAnchor';
|
|
11
11
|
export * from './CSSPropertyZIndex';
|
|
12
12
|
export * from './CSSPropertyTransform';
|
|
13
13
|
export * from './CSSPropertyTransformOrigin';
|
|
@@ -4,8 +4,8 @@ import type { DisplayObjectConfig } from '../dom';
|
|
|
4
4
|
import { Point } from '../shapes';
|
|
5
5
|
import type { Rectangle } from '../shapes/Rectangle';
|
|
6
6
|
export interface PathStyleProps extends BaseStyleProps {
|
|
7
|
-
path?: string | PathCommand[]
|
|
8
|
-
d?: string | PathCommand[]
|
|
7
|
+
path?: string | PathCommand[];
|
|
8
|
+
d?: string | PathCommand[];
|
|
9
9
|
}
|
|
10
10
|
export interface PathSegment {
|
|
11
11
|
command: PathCommand[0];
|
|
@@ -7,14 +7,17 @@ export interface RectStyleProps extends BaseStyleProps {
|
|
|
7
7
|
y?: number | string;
|
|
8
8
|
width: number | string;
|
|
9
9
|
height: number | string;
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* top-left, top-right, bottom-right, bottom-left
|
|
12
|
+
*/
|
|
13
|
+
radius?: number | string | number[];
|
|
11
14
|
}
|
|
12
15
|
export interface ParsedRectStyleProps extends ParsedBaseStyleProps {
|
|
13
16
|
x: CSSUnitValue;
|
|
14
17
|
y: CSSUnitValue;
|
|
15
18
|
width: CSSUnitValue;
|
|
16
19
|
height: CSSUnitValue;
|
|
17
|
-
radius?: CSSUnitValue;
|
|
20
|
+
radius?: [CSSUnitValue, CSSUnitValue, CSSUnitValue, CSSUnitValue];
|
|
18
21
|
}
|
|
19
22
|
export declare class Rect extends DisplayObject<RectStyleProps, ParsedRectStyleProps> {
|
|
20
23
|
constructor({ style, ...rest }?: DisplayObjectConfig<RectStyleProps>);
|
package/es/global-module.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Module, injectable, decorate } from 'mana-syringe';
|
|
|
3
3
|
import { EventEmitter } from 'eventemitter3';
|
|
4
4
|
import { DisplayObjectPool } from './DisplayObjectPool';
|
|
5
5
|
import { CircleUpdater, EllipseUpdater, GeometryAABBUpdater, GeometryUpdaterFactory, LineUpdater, PathUpdater, PolylineUpdater, RectUpdater, TextUpdater, TextService, OffscreenCanvasCreator, DefaultSceneGraphService, DefaultSceneGraphSelector, SceneGraphSelector, SceneGraphSelectorFactory } from './services';
|
|
6
|
-
import { LayoutRegistry, CSSPropertyLocalPosition, CSSPropertyLengthOrPercentage,
|
|
6
|
+
import { LayoutRegistry, CSSPropertyLocalPosition, CSSPropertyLengthOrPercentage, CSSPropertyClipPath, CSSPropertyColor, CSSPropertyFilter, CSSPropertyLengthOrPercentage12, CSSPropertyOffsetDistance, CSSPropertyOffsetPath, CSSPropertyOpacity, CSSPropertyPath, CSSPropertyPoints, CSSPropertyText, CSSPropertyTextTransform, CSSPropertyTransform, CSSPropertyTransformOrigin, CSSPropertyZIndex, CSSPropertyShadowBlur, CSSPropertyLengthOrPercentage14, DefaultStyleValueRegistry } from './css';
|
|
7
7
|
import { ContextNode, FragmentResult, FragmentResultFactory, FragmentResultOptions, LayoutChildren, LayoutChildrenFactory, LayoutChildrenOptions, LayoutContext, LayoutContextFactory, LayoutContextOptions, LayoutEdges, LayoutEdgesFactory, LayoutEdgesOptions, LayoutEngine, LayoutFragment, LayoutFragmentFactory, LayoutFragmentOptions } from './css/layout';
|
|
8
8
|
export var containerModule = Module(function (register) {
|
|
9
9
|
decorate(injectable(), EventEmitter); // bind DisplayObject pool
|
|
@@ -55,11 +55,10 @@ export var containerModule = Module(function (register) {
|
|
|
55
55
|
register(CSSPropertyOpacity);
|
|
56
56
|
register(CSSPropertyColor);
|
|
57
57
|
register(CSSPropertyFilter);
|
|
58
|
-
register(
|
|
58
|
+
register(CSSPropertyLengthOrPercentage12);
|
|
59
59
|
register(CSSPropertyShadowBlur);
|
|
60
60
|
register(CSSPropertyOffsetPath);
|
|
61
61
|
register(CSSPropertyOffsetDistance);
|
|
62
|
-
register(CSSPropertyAnchor);
|
|
63
62
|
register(CSSPropertyZIndex);
|
|
64
63
|
register(CSSPropertyTransform);
|
|
65
64
|
register(CSSPropertyTransformOrigin);
|
|
@@ -67,7 +66,8 @@ export var containerModule = Module(function (register) {
|
|
|
67
66
|
register(CSSPropertyPoints);
|
|
68
67
|
register(CSSPropertyClipPath);
|
|
69
68
|
register(CSSPropertyText);
|
|
70
|
-
register(CSSPropertyTextTransform);
|
|
69
|
+
register(CSSPropertyTextTransform);
|
|
70
|
+
register(CSSPropertyLengthOrPercentage14); // bind layout engine
|
|
71
71
|
|
|
72
72
|
register(LayoutEngine);
|
|
73
73
|
register(LayoutEdges);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __read, __spreadArray } from "tslib";
|
|
2
2
|
import { GlobalContainer } from 'mana-syringe';
|
|
3
3
|
import { StyleValueRegistry } from '../css/interfaces';
|
|
4
|
+
import { PROPERTY_HANDLERS } from '../css/StyleValueRegistry';
|
|
4
5
|
import { parseEasingFunction } from './animation';
|
|
5
6
|
import { camelCase } from './string';
|
|
6
7
|
export function convertEffectInput(keyframes, timing, target) {
|
|
@@ -116,8 +117,8 @@ function propertyInterpolation(property, left, right, target) {
|
|
|
116
117
|
var registry = GlobalContainer.get(StyleValueRegistry);
|
|
117
118
|
var metadata = registry.getMetadata(property);
|
|
118
119
|
|
|
119
|
-
if (metadata && metadata.
|
|
120
|
-
var propertyHandler = GlobalContainer.get(metadata.
|
|
120
|
+
if (metadata && metadata.syntax && metadata.interpolable && PROPERTY_HANDLERS[metadata.syntax]) {
|
|
121
|
+
var propertyHandler = GlobalContainer.get(PROPERTY_HANDLERS[metadata.syntax]);
|
|
121
122
|
|
|
122
123
|
if (propertyHandler) {
|
|
123
124
|
if (propertyHandler.parser) {
|
package/es/utils/path.js
CHANGED
|
@@ -290,7 +290,15 @@ function polygonToCommands(points, closed) {
|
|
|
290
290
|
function rectToCommands(width, height, x, y, radius) {
|
|
291
291
|
// @see https://gist.github.com/danielpquinn/dd966af424030d47e476
|
|
292
292
|
if (radius) {
|
|
293
|
-
|
|
293
|
+
var _a = __read(radius, 4),
|
|
294
|
+
tlr = _a[0],
|
|
295
|
+
trr = _a[1],
|
|
296
|
+
brr = _a[2],
|
|
297
|
+
blr = _a[3];
|
|
298
|
+
|
|
299
|
+
return [['M', x, tlr + y], tlr ? ['A', tlr, tlr, 0, 0, 1, tlr + x, y] : null, ['L', width - trr + x, y], trr ? ['A', trr, trr, 0, 0, 1, width + x, trr + y] : null, ['L', width + x, height - brr + y], brr ? ['A', brr, brr, 0, 0, 1, width - brr + x, height + y] : null, ['L', blr + x, height + y], blr ? ['A', blr, blr, 0, 0, 1, x, height - blr + y] : null, ['Z']].filter(function (command) {
|
|
300
|
+
return command;
|
|
301
|
+
});
|
|
294
302
|
}
|
|
295
303
|
|
|
296
304
|
return [['M', x, y], ['L', x + width, y], ['L', x + width, y + height], ['L', x, y + height], ['Z']];
|
|
@@ -354,7 +362,12 @@ export function convertToPath(object, applyLocalTransform) {
|
|
|
354
362
|
x = _d.x,
|
|
355
363
|
y = _d.y,
|
|
356
364
|
radius = _d.radius;
|
|
357
|
-
|
|
365
|
+
var hasRadius = radius && radius.some(function (r) {
|
|
366
|
+
return r.value !== 0;
|
|
367
|
+
});
|
|
368
|
+
commands = rectToCommands(width.value, height.value, x.value, y.value, hasRadius && radius.map(function (r) {
|
|
369
|
+
return r.value;
|
|
370
|
+
}));
|
|
358
371
|
break;
|
|
359
372
|
|
|
360
373
|
case Shape.PATH:
|
package/lib/css/CSS.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CSSUnitValue } from './cssom';
|
|
2
|
+
import type { PropertySyntax } from './interfaces';
|
|
2
3
|
import type { LayoutDefinitionCtor } from './layout';
|
|
3
4
|
/**
|
|
4
5
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSS/RegisterProperty#parameters
|
|
@@ -8,11 +9,12 @@ export interface PropertyDefinition {
|
|
|
8
9
|
/**
|
|
9
10
|
* representing the expected syntax of the defined property. Defaults to "*".
|
|
10
11
|
*/
|
|
11
|
-
syntax
|
|
12
|
+
syntax: PropertySyntax;
|
|
12
13
|
/**
|
|
13
14
|
* A boolean value defining whether the defined property should be inherited (true), or not (false). Defaults to false.
|
|
14
15
|
*/
|
|
15
|
-
inherits
|
|
16
|
+
inherits?: boolean;
|
|
17
|
+
interpolable?: boolean;
|
|
16
18
|
initialValue?: string;
|
|
17
19
|
}
|
|
18
20
|
/**
|
package/lib/css/CSS.js
CHANGED
|
@@ -104,14 +104,18 @@ var CSS = {
|
|
|
104
104
|
registerProperty: function registerProperty(definition) {
|
|
105
105
|
var name = definition.name,
|
|
106
106
|
inherits = definition.inherits,
|
|
107
|
-
|
|
107
|
+
interpolable = definition.interpolable,
|
|
108
|
+
initialValue = definition.initialValue,
|
|
109
|
+
syntax = definition.syntax;
|
|
108
110
|
|
|
109
111
|
var registry = _manaSyringe.GlobalContainer.get(_interfaces.StyleValueRegistry);
|
|
110
112
|
|
|
111
113
|
registry.registerMetadata({
|
|
112
114
|
name: name,
|
|
113
115
|
inherited: inherits,
|
|
114
|
-
|
|
116
|
+
interpolable: interpolable,
|
|
117
|
+
defaultValue: initialValue,
|
|
118
|
+
syntax: syntax
|
|
115
119
|
});
|
|
116
120
|
},
|
|
117
121
|
|
|
@@ -1,68 +1,35 @@
|
|
|
1
1
|
import type { DisplayObject } from '../display-objects';
|
|
2
2
|
import type { BaseStyleProps } from '../types';
|
|
3
3
|
import { CSSStyleValue } from './cssom';
|
|
4
|
+
import { CSSPropertyLocalPosition, CSSPropertyOpacity, CSSPropertyColor, CSSPropertyFilter, CSSPropertyLengthOrPercentage, CSSPropertyLengthOrPercentage12, CSSPropertyLengthOrPercentage14, CSSPropertyShadowBlur, CSSPropertyOffsetPath, CSSPropertyOffsetDistance, CSSPropertyZIndex, CSSPropertyTransform, CSSPropertyTransformOrigin, CSSPropertyPath, CSSPropertyClipPath, CSSPropertyPoints, CSSPropertyText, CSSPropertyTextTransform } from './properties';
|
|
5
|
+
import type { PropertyMetadata } from './interfaces';
|
|
4
6
|
import { StyleValueRegistry } from './interfaces';
|
|
5
7
|
export declare type CSSGlobalKeywords = 'unset' | 'initial' | 'inherit' | '';
|
|
6
8
|
export interface PropertyParseOptions {
|
|
7
9
|
skipUpdateAttribute: boolean;
|
|
8
10
|
skipParse: boolean;
|
|
9
11
|
}
|
|
10
|
-
export declare const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
export declare const PROPERTY_HANDLERS: {
|
|
13
|
+
"<coordinate>": typeof CSSPropertyLocalPosition;
|
|
14
|
+
"<color>": typeof CSSPropertyColor;
|
|
15
|
+
"<paint>": typeof CSSPropertyColor;
|
|
16
|
+
"<opacity-value>": typeof CSSPropertyOpacity;
|
|
17
|
+
"<length> | <percentage>": typeof CSSPropertyLengthOrPercentage;
|
|
18
|
+
"[<length> | <percentage>]{1,2}": typeof CSSPropertyLengthOrPercentage12;
|
|
19
|
+
"[<length> | <percentage>]{1,4}": typeof CSSPropertyLengthOrPercentage14;
|
|
20
|
+
"<shadow-blur>": typeof CSSPropertyShadowBlur;
|
|
21
|
+
"<list-of-points>": typeof CSSPropertyPoints;
|
|
22
|
+
"<path>": typeof CSSPropertyPath;
|
|
23
|
+
"<filter>": typeof CSSPropertyFilter;
|
|
24
|
+
"<z-index>": typeof CSSPropertyZIndex;
|
|
25
|
+
"<offset-path>": typeof CSSPropertyOffsetPath;
|
|
26
|
+
"<offset-distance>": typeof CSSPropertyOffsetDistance;
|
|
27
|
+
"<clip-path>": typeof CSSPropertyClipPath;
|
|
28
|
+
"<transform>": typeof CSSPropertyTransform;
|
|
29
|
+
"<transform-origin>": typeof CSSPropertyTransformOrigin;
|
|
30
|
+
"<text>": typeof CSSPropertyText;
|
|
31
|
+
"<text-transform>": typeof CSSPropertyTextTransform;
|
|
18
32
|
};
|
|
19
|
-
export interface PropertyMetadata {
|
|
20
|
-
name: string;
|
|
21
|
-
/**
|
|
22
|
-
* The interpolable flag indicates whether a property can be animated smoothly.
|
|
23
|
-
* Default to `false`.
|
|
24
|
-
*/
|
|
25
|
-
interpolable?: boolean;
|
|
26
|
-
/**
|
|
27
|
-
* The property will inherit by default if no value is specified.
|
|
28
|
-
* Default to `false`.
|
|
29
|
-
*/
|
|
30
|
-
inherited?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* This property affects only one field on ComputedStyle, and can be set
|
|
33
|
-
* directly during inheritance instead of forcing a recalc.
|
|
34
|
-
*/
|
|
35
|
-
independent?: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* This specifies the default value for this field.
|
|
38
|
-
* - for keyword fields, this is the initial keyword
|
|
39
|
-
* - for other fields, this is a string containg the C++ expression that is used to initialise the field.
|
|
40
|
-
*/
|
|
41
|
-
defaultValue?: string;
|
|
42
|
-
/**
|
|
43
|
-
* The resolved value used for getComputedStyle() depends on layout for this
|
|
44
|
-
* property, which means we may need to update layout to return the correct
|
|
45
|
-
* value from getComputedStyle().
|
|
46
|
-
*/
|
|
47
|
-
layoutDependent?: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* This specifies all valid keyword values for the property.
|
|
50
|
-
*/
|
|
51
|
-
keywords?: string[];
|
|
52
|
-
/**
|
|
53
|
-
* eg. strokeWidth is an alias of lineWidth
|
|
54
|
-
*/
|
|
55
|
-
alias?: string[];
|
|
56
|
-
/**
|
|
57
|
-
* sort before init attributes according to this priority
|
|
58
|
-
*/
|
|
59
|
-
parsePriority?: number;
|
|
60
|
-
/**
|
|
61
|
-
* eg. <color> <paint> <number>
|
|
62
|
-
*/
|
|
63
|
-
syntax?: string;
|
|
64
|
-
handler?: any;
|
|
65
|
-
}
|
|
66
33
|
/**
|
|
67
34
|
* Blink used them in code generation(css_properties.json5)
|
|
68
35
|
*/
|
|
@@ -86,6 +53,7 @@ export declare class DefaultStyleValueRegistry implements StyleValueRegistry {
|
|
|
86
53
|
private cascadeProperties;
|
|
87
54
|
init(): void;
|
|
88
55
|
registerMetadata(metadata: PropertyMetadata): void;
|
|
56
|
+
unregisterMetadata(name: string): void;
|
|
89
57
|
getMetadata(name: string): PropertyMetadata;
|
|
90
58
|
/**
|
|
91
59
|
* * parse value, eg.
|