@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/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/es/css/CSS.js
CHANGED
|
@@ -94,12 +94,16 @@ export var CSS = {
|
|
|
94
94
|
registerProperty: function registerProperty(definition) {
|
|
95
95
|
var name = definition.name,
|
|
96
96
|
inherits = definition.inherits,
|
|
97
|
-
|
|
97
|
+
interpolable = definition.interpolable,
|
|
98
|
+
initialValue = definition.initialValue,
|
|
99
|
+
syntax = definition.syntax;
|
|
98
100
|
var registry = GlobalContainer.get(StyleValueRegistry);
|
|
99
101
|
registry.registerMetadata({
|
|
100
102
|
name: name,
|
|
101
103
|
inherited: inherits,
|
|
102
|
-
|
|
104
|
+
interpolable: interpolable,
|
|
105
|
+
defaultValue: initialValue,
|
|
106
|
+
syntax: syntax
|
|
103
107
|
});
|
|
104
108
|
},
|
|
105
109
|
|
|
@@ -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.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
|
|
1
3
|
import { __decorate, __metadata, __read, __spreadArray } from "tslib";
|
|
2
4
|
import { postConstruct, singleton, GlobalContainer } from 'mana-syringe';
|
|
3
5
|
import { vec3 } from 'gl-matrix';
|
|
@@ -7,19 +9,11 @@ import { ElementEvent } from '../dom';
|
|
|
7
9
|
import { Shape } from '../types';
|
|
8
10
|
import { CSSKeywordValue, CSSStyleValue, CSSUnitValue } from './cssom';
|
|
9
11
|
import { convertPercentUnit } from './parser';
|
|
10
|
-
import { CSSPropertyLocalPosition, CSSPropertyOpacity, CSSPropertyColor, CSSPropertyFilter, CSSPropertyLengthOrPercentage,
|
|
12
|
+
import { CSSPropertyLocalPosition, CSSPropertyOpacity, CSSPropertyColor, CSSPropertyFilter, CSSPropertyLengthOrPercentage, CSSPropertyLengthOrPercentage12, CSSPropertyLengthOrPercentage14, CSSPropertyShadowBlur, CSSPropertyOffsetPath, CSSPropertyOffsetDistance, CSSPropertyZIndex, CSSPropertyTransform, CSSPropertyTransformOrigin, CSSPropertyPath, CSSPropertyClipPath, CSSPropertyPoints, CSSPropertyText, CSSPropertyTextTransform } from './properties';
|
|
11
13
|
import { formatAttribute, isNil } from '../utils';
|
|
12
14
|
import { AABB } from '../shapes';
|
|
13
|
-
import { StyleValueRegistry } from './interfaces';
|
|
14
|
-
export var PropertySyntax =
|
|
15
|
-
COLOR: '<color>',
|
|
16
|
-
PAINT: '<paint>',
|
|
17
|
-
NUMBER: '<number>',
|
|
18
|
-
LENGTH: '<length>',
|
|
19
|
-
PERCENTAGE: '<percentage>',
|
|
20
|
-
LENGTH_PERCENTAGE: '<length> | <percentage>',
|
|
21
|
-
LIST_OF_POINTS: '<list-of-points>'
|
|
22
|
-
};
|
|
15
|
+
import { StyleValueRegistry, PropertySyntax } from './interfaces';
|
|
16
|
+
export var PROPERTY_HANDLERS = (_a = {}, _a[PropertySyntax.COORDINATE] = CSSPropertyLocalPosition, _a[PropertySyntax.COLOR] = CSSPropertyColor, _a[PropertySyntax.PAINT] = CSSPropertyColor, _a[PropertySyntax.OPACITY_VALUE] = CSSPropertyOpacity, _a[PropertySyntax.LENGTH_PERCENTAGE] = CSSPropertyLengthOrPercentage, _a[PropertySyntax.LENGTH_PERCENTAGE_12] = CSSPropertyLengthOrPercentage12, _a[PropertySyntax.LENGTH_PERCENTAGE_14] = CSSPropertyLengthOrPercentage14, _a[PropertySyntax.SHADOW_BLUR] = CSSPropertyShadowBlur, _a[PropertySyntax.LIST_OF_POINTS] = CSSPropertyPoints, _a[PropertySyntax.PATH] = CSSPropertyPath, _a[PropertySyntax.FILTER] = CSSPropertyFilter, _a[PropertySyntax.Z_INDEX] = CSSPropertyZIndex, _a[PropertySyntax.OFFSET_PATH] = CSSPropertyOffsetPath, _a[PropertySyntax.OFFSET_DISTANCE] = CSSPropertyOffsetDistance, _a[PropertySyntax.CLIP_PATH] = CSSPropertyClipPath, _a[PropertySyntax.TRANSFORM] = CSSPropertyTransform, _a[PropertySyntax.TRANSFORM_ORIGIN] = CSSPropertyTransformOrigin, _a[PropertySyntax.TEXT] = CSSPropertyText, _a[PropertySyntax.TEXT_TRANSFORM] = CSSPropertyTextTransform, _a);
|
|
23
17
|
/**
|
|
24
18
|
* Blink used them in code generation(css_properties.json5)
|
|
25
19
|
*/
|
|
@@ -39,8 +33,7 @@ export var BUILT_IN_PROPERTIES = [{
|
|
|
39
33
|
name: 'opacity',
|
|
40
34
|
interpolable: true,
|
|
41
35
|
defaultValue: '1',
|
|
42
|
-
syntax: PropertySyntax.
|
|
43
|
-
handler: CSSPropertyOpacity
|
|
36
|
+
syntax: PropertySyntax.OPACITY_VALUE
|
|
44
37
|
}, {
|
|
45
38
|
/**
|
|
46
39
|
* range [0.0, 1.0]
|
|
@@ -50,8 +43,7 @@ export var BUILT_IN_PROPERTIES = [{
|
|
|
50
43
|
interpolable: true,
|
|
51
44
|
inherited: true,
|
|
52
45
|
defaultValue: '1',
|
|
53
|
-
syntax: PropertySyntax.
|
|
54
|
-
handler: CSSPropertyOpacity
|
|
46
|
+
syntax: PropertySyntax.OPACITY_VALUE
|
|
55
47
|
}, {
|
|
56
48
|
/**
|
|
57
49
|
* range [0.0, 1.0]
|
|
@@ -61,8 +53,7 @@ export var BUILT_IN_PROPERTIES = [{
|
|
|
61
53
|
interpolable: true,
|
|
62
54
|
inherited: true,
|
|
63
55
|
defaultValue: '1',
|
|
64
|
-
syntax: PropertySyntax.
|
|
65
|
-
handler: CSSPropertyOpacity
|
|
56
|
+
syntax: PropertySyntax.OPACITY_VALUE
|
|
66
57
|
}, {
|
|
67
58
|
/**
|
|
68
59
|
* background-color is not inheritable
|
|
@@ -72,37 +63,32 @@ export var BUILT_IN_PROPERTIES = [{
|
|
|
72
63
|
interpolable: true,
|
|
73
64
|
keywords: ['none'],
|
|
74
65
|
defaultValue: 'none',
|
|
75
|
-
syntax: PropertySyntax.PAINT
|
|
76
|
-
handler: CSSPropertyColor
|
|
66
|
+
syntax: PropertySyntax.PAINT
|
|
77
67
|
}, {
|
|
78
68
|
name: 'stroke',
|
|
79
69
|
interpolable: true,
|
|
80
70
|
keywords: ['none'],
|
|
81
71
|
defaultValue: 'none',
|
|
82
|
-
syntax: PropertySyntax.PAINT
|
|
83
|
-
handler: CSSPropertyColor
|
|
72
|
+
syntax: PropertySyntax.PAINT
|
|
84
73
|
}, {
|
|
85
74
|
name: 'shadowColor',
|
|
86
75
|
interpolable: true,
|
|
87
|
-
syntax: PropertySyntax.COLOR
|
|
88
|
-
handler: CSSPropertyColor
|
|
76
|
+
syntax: PropertySyntax.COLOR
|
|
89
77
|
}, {
|
|
90
78
|
name: 'shadowOffsetX',
|
|
91
79
|
interpolable: true,
|
|
92
80
|
layoutDependent: true,
|
|
93
|
-
syntax: PropertySyntax.LENGTH_PERCENTAGE
|
|
94
|
-
handler: CSSPropertyLengthOrPercentage
|
|
81
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE
|
|
95
82
|
}, {
|
|
96
83
|
name: 'shadowOffsetY',
|
|
97
84
|
interpolable: true,
|
|
98
85
|
layoutDependent: true,
|
|
99
|
-
syntax: PropertySyntax.LENGTH_PERCENTAGE
|
|
100
|
-
handler: CSSPropertyLengthOrPercentage
|
|
86
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE
|
|
101
87
|
}, {
|
|
102
88
|
name: 'shadowBlur',
|
|
103
89
|
interpolable: true,
|
|
104
90
|
layoutDependent: true,
|
|
105
|
-
|
|
91
|
+
syntax: PropertySyntax.SHADOW_BLUR
|
|
106
92
|
}, {
|
|
107
93
|
/**
|
|
108
94
|
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-width
|
|
@@ -113,15 +99,13 @@ export var BUILT_IN_PROPERTIES = [{
|
|
|
113
99
|
defaultValue: '1',
|
|
114
100
|
layoutDependent: true,
|
|
115
101
|
alias: ['strokeWidth'],
|
|
116
|
-
syntax: PropertySyntax.LENGTH_PERCENTAGE
|
|
117
|
-
handler: CSSPropertyLengthOrPercentage
|
|
102
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE
|
|
118
103
|
}, {
|
|
119
104
|
name: 'increasedLineWidthForHitTesting',
|
|
120
105
|
inherited: true,
|
|
121
106
|
defaultValue: '0',
|
|
122
107
|
layoutDependent: true,
|
|
123
|
-
syntax: PropertySyntax.LENGTH_PERCENTAGE
|
|
124
|
-
handler: CSSPropertyLengthOrPercentage
|
|
108
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE
|
|
125
109
|
}, {
|
|
126
110
|
name: 'lineJoin',
|
|
127
111
|
inherited: true,
|
|
@@ -142,40 +126,40 @@ export var BUILT_IN_PROPERTIES = [{
|
|
|
142
126
|
inherited: true,
|
|
143
127
|
keywords: ['none'],
|
|
144
128
|
alias: ['strokeDasharray'],
|
|
145
|
-
|
|
129
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE_12
|
|
146
130
|
}, {
|
|
147
131
|
name: 'lineDashOffset',
|
|
148
132
|
interpolable: true,
|
|
149
133
|
inherited: true,
|
|
150
134
|
defaultValue: '0',
|
|
151
135
|
alias: ['strokeDashoffset'],
|
|
152
|
-
|
|
136
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE
|
|
153
137
|
}, {
|
|
154
138
|
name: 'offsetPath',
|
|
155
|
-
|
|
139
|
+
syntax: PropertySyntax.OFFSET_PATH
|
|
156
140
|
}, {
|
|
157
141
|
name: 'offsetDistance',
|
|
158
142
|
interpolable: true,
|
|
159
|
-
|
|
143
|
+
syntax: PropertySyntax.OFFSET_DISTANCE
|
|
160
144
|
}, {
|
|
161
145
|
name: 'dx',
|
|
162
146
|
interpolable: true,
|
|
163
147
|
layoutDependent: true,
|
|
164
148
|
defaultValue: '0',
|
|
165
|
-
|
|
149
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE
|
|
166
150
|
}, {
|
|
167
151
|
name: 'dy',
|
|
168
152
|
interpolable: true,
|
|
169
153
|
layoutDependent: true,
|
|
170
154
|
defaultValue: '0',
|
|
171
|
-
|
|
155
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE
|
|
172
156
|
}, {
|
|
173
157
|
name: 'zIndex',
|
|
174
158
|
independent: true,
|
|
175
159
|
interpolable: true,
|
|
176
160
|
defaultValue: '0',
|
|
177
161
|
keywords: ['auto'],
|
|
178
|
-
|
|
162
|
+
syntax: PropertySyntax.Z_INDEX
|
|
179
163
|
}, {
|
|
180
164
|
name: 'visibility',
|
|
181
165
|
keywords: ['visible', 'hidden'],
|
|
@@ -197,82 +181,77 @@ export var BUILT_IN_PROPERTIES = [{
|
|
|
197
181
|
name: 'filter',
|
|
198
182
|
independent: true,
|
|
199
183
|
layoutDependent: true,
|
|
200
|
-
|
|
184
|
+
syntax: PropertySyntax.FILTER
|
|
201
185
|
}, {
|
|
202
186
|
name: 'clipPath',
|
|
203
|
-
|
|
187
|
+
syntax: PropertySyntax.CLIP_PATH
|
|
204
188
|
}, {
|
|
205
189
|
name: 'transform',
|
|
206
190
|
parsePriority: 100,
|
|
207
191
|
interpolable: true,
|
|
208
192
|
keywords: ['none'],
|
|
209
193
|
defaultValue: 'none',
|
|
210
|
-
|
|
194
|
+
syntax: PropertySyntax.TRANSFORM
|
|
211
195
|
}, {
|
|
212
196
|
name: 'transformOrigin',
|
|
213
197
|
parsePriority: 100,
|
|
214
198
|
// interpolable: true,
|
|
215
199
|
defaultValue: 'left top',
|
|
216
200
|
layoutDependent: true,
|
|
217
|
-
|
|
201
|
+
syntax: PropertySyntax.TRANSFORM_ORIGIN
|
|
218
202
|
}, {
|
|
219
203
|
name: 'anchor',
|
|
220
204
|
parsePriority: 99,
|
|
221
205
|
layoutDependent: true,
|
|
222
|
-
|
|
206
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE_12
|
|
223
207
|
}, // <circle> & <ellipse>
|
|
224
208
|
{
|
|
225
209
|
name: 'cx',
|
|
226
210
|
interpolable: true,
|
|
227
211
|
defaultValue: '0',
|
|
228
|
-
syntax: PropertySyntax.
|
|
229
|
-
handler: CSSPropertyLocalPosition
|
|
212
|
+
syntax: PropertySyntax.COORDINATE
|
|
230
213
|
}, {
|
|
231
214
|
name: 'cy',
|
|
232
215
|
interpolable: true,
|
|
233
216
|
defaultValue: '0',
|
|
234
|
-
syntax: PropertySyntax.
|
|
235
|
-
handler: CSSPropertyLocalPosition
|
|
217
|
+
syntax: PropertySyntax.COORDINATE
|
|
236
218
|
}, {
|
|
237
219
|
name: 'r',
|
|
238
220
|
interpolable: true,
|
|
239
221
|
layoutDependent: true,
|
|
240
222
|
defaultValue: '0',
|
|
241
|
-
|
|
223
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE
|
|
242
224
|
}, {
|
|
243
225
|
name: 'rx',
|
|
244
226
|
interpolable: true,
|
|
245
227
|
layoutDependent: true,
|
|
246
228
|
defaultValue: 'auto',
|
|
247
|
-
|
|
229
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE
|
|
248
230
|
}, {
|
|
249
231
|
name: 'ry',
|
|
250
232
|
interpolable: true,
|
|
251
233
|
layoutDependent: true,
|
|
252
234
|
defaultValue: 'auto',
|
|
253
|
-
|
|
235
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE
|
|
254
236
|
}, // Rect Image Group
|
|
255
237
|
{
|
|
256
238
|
// x in local space
|
|
257
239
|
name: 'x',
|
|
258
240
|
interpolable: true,
|
|
259
241
|
defaultValue: '0',
|
|
260
|
-
syntax: PropertySyntax.
|
|
261
|
-
handler: CSSPropertyLocalPosition
|
|
242
|
+
syntax: PropertySyntax.COORDINATE
|
|
262
243
|
}, {
|
|
263
244
|
// y in local space
|
|
264
245
|
name: 'y',
|
|
265
246
|
interpolable: true,
|
|
266
247
|
defaultValue: '0',
|
|
267
|
-
syntax: PropertySyntax.
|
|
268
|
-
handler: CSSPropertyLocalPosition
|
|
248
|
+
syntax: PropertySyntax.COORDINATE
|
|
269
249
|
}, {
|
|
270
250
|
// z in local space
|
|
271
251
|
name: 'z',
|
|
272
252
|
interpolable: true,
|
|
273
253
|
defaultValue: '0',
|
|
274
|
-
syntax: PropertySyntax.
|
|
275
|
-
handler: CSSPropertyLocalPosition
|
|
254
|
+
syntax: PropertySyntax.COORDINATE
|
|
276
255
|
}, {
|
|
277
256
|
name: 'width',
|
|
278
257
|
interpolable: true,
|
|
@@ -282,8 +261,8 @@ export var BUILT_IN_PROPERTIES = [{
|
|
|
282
261
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/width
|
|
283
262
|
*/
|
|
284
263
|
keywords: ['auto', 'fit-content', 'min-content', 'max-content'],
|
|
285
|
-
defaultValue: '
|
|
286
|
-
|
|
264
|
+
defaultValue: 'auto',
|
|
265
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE
|
|
287
266
|
}, {
|
|
288
267
|
name: 'height',
|
|
289
268
|
interpolable: true,
|
|
@@ -293,45 +272,45 @@ export var BUILT_IN_PROPERTIES = [{
|
|
|
293
272
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/height
|
|
294
273
|
*/
|
|
295
274
|
keywords: ['auto', 'fit-content', 'min-content', 'max-content'],
|
|
296
|
-
defaultValue: '
|
|
297
|
-
|
|
275
|
+
defaultValue: 'auto',
|
|
276
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE
|
|
298
277
|
}, {
|
|
299
278
|
name: 'radius',
|
|
300
279
|
interpolable: true,
|
|
301
280
|
layoutDependent: true,
|
|
302
281
|
defaultValue: '0',
|
|
303
|
-
|
|
282
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE_14
|
|
304
283
|
}, // Line
|
|
305
284
|
{
|
|
306
285
|
name: 'x1',
|
|
307
286
|
interpolable: true,
|
|
308
287
|
layoutDependent: true,
|
|
309
|
-
|
|
288
|
+
syntax: PropertySyntax.COORDINATE
|
|
310
289
|
}, {
|
|
311
290
|
name: 'y1',
|
|
312
291
|
interpolable: true,
|
|
313
292
|
layoutDependent: true,
|
|
314
|
-
|
|
293
|
+
syntax: PropertySyntax.COORDINATE
|
|
315
294
|
}, {
|
|
316
295
|
name: 'z1',
|
|
317
296
|
interpolable: true,
|
|
318
297
|
layoutDependent: true,
|
|
319
|
-
|
|
298
|
+
syntax: PropertySyntax.COORDINATE
|
|
320
299
|
}, {
|
|
321
300
|
name: 'x2',
|
|
322
301
|
interpolable: true,
|
|
323
302
|
layoutDependent: true,
|
|
324
|
-
|
|
303
|
+
syntax: PropertySyntax.COORDINATE
|
|
325
304
|
}, {
|
|
326
305
|
name: 'y2',
|
|
327
306
|
interpolable: true,
|
|
328
307
|
layoutDependent: true,
|
|
329
|
-
|
|
308
|
+
syntax: PropertySyntax.COORDINATE
|
|
330
309
|
}, {
|
|
331
310
|
name: 'z2',
|
|
332
311
|
interpolable: true,
|
|
333
312
|
layoutDependent: true,
|
|
334
|
-
|
|
313
|
+
syntax: PropertySyntax.COORDINATE
|
|
335
314
|
}, // Path
|
|
336
315
|
{
|
|
337
316
|
name: 'path',
|
|
@@ -339,26 +318,25 @@ export var BUILT_IN_PROPERTIES = [{
|
|
|
339
318
|
layoutDependent: true,
|
|
340
319
|
defaultValue: '',
|
|
341
320
|
alias: ['d'],
|
|
342
|
-
|
|
321
|
+
syntax: PropertySyntax.PATH
|
|
343
322
|
}, // Polyline & Polygon
|
|
344
323
|
{
|
|
345
324
|
name: 'points',
|
|
346
325
|
layoutDependent: true,
|
|
347
|
-
syntax: PropertySyntax.LIST_OF_POINTS
|
|
348
|
-
handler: CSSPropertyPoints
|
|
326
|
+
syntax: PropertySyntax.LIST_OF_POINTS
|
|
349
327
|
}, // Text
|
|
350
328
|
{
|
|
351
329
|
name: 'text',
|
|
352
330
|
layoutDependent: true,
|
|
353
|
-
|
|
354
|
-
|
|
331
|
+
defaultValue: '',
|
|
332
|
+
syntax: PropertySyntax.TEXT
|
|
355
333
|
}, {
|
|
356
334
|
name: 'textTransform',
|
|
357
335
|
layoutDependent: true,
|
|
358
336
|
inherited: true,
|
|
359
337
|
keywords: ['capitalize', 'uppercase', 'lowercase', 'none'],
|
|
360
338
|
defaultValue: 'none',
|
|
361
|
-
|
|
339
|
+
syntax: PropertySyntax.TEXT_TRANSFORM
|
|
362
340
|
}, {
|
|
363
341
|
name: 'font',
|
|
364
342
|
layoutDependent: true
|
|
@@ -372,7 +350,7 @@ export var BUILT_IN_PROPERTIES = [{
|
|
|
372
350
|
*/
|
|
373
351
|
defaultValue: '16px',
|
|
374
352
|
layoutDependent: true,
|
|
375
|
-
|
|
353
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE
|
|
376
354
|
}, {
|
|
377
355
|
name: 'fontFamily',
|
|
378
356
|
layoutDependent: true,
|
|
@@ -489,6 +467,10 @@ function () {
|
|
|
489
467
|
});
|
|
490
468
|
};
|
|
491
469
|
|
|
470
|
+
DefaultStyleValueRegistry.prototype.unregisterMetadata = function (name) {
|
|
471
|
+
delete this.cache[name];
|
|
472
|
+
};
|
|
473
|
+
|
|
492
474
|
DefaultStyleValueRegistry.prototype.getMetadata = function (name) {
|
|
493
475
|
return this.cache[name];
|
|
494
476
|
};
|
|
@@ -597,7 +579,8 @@ function () {
|
|
|
597
579
|
} else {
|
|
598
580
|
if (metadata) {
|
|
599
581
|
var keywords = metadata.keywords,
|
|
600
|
-
|
|
582
|
+
syntax = metadata.syntax;
|
|
583
|
+
var handler = syntax && PROPERTY_HANDLERS[syntax]; // use keywords
|
|
601
584
|
|
|
602
585
|
if (keywords && keywords.indexOf(value) > -1) {
|
|
603
586
|
computed = new CSSKeywordValue(value);
|
|
@@ -626,7 +609,7 @@ function () {
|
|
|
626
609
|
var used = computed instanceof CSSStyleValue ? computed.clone() : computed;
|
|
627
610
|
|
|
628
611
|
if (metadata) {
|
|
629
|
-
var
|
|
612
|
+
var syntax = metadata.syntax,
|
|
630
613
|
inherited = metadata.inherited,
|
|
631
614
|
defaultValue = metadata.defaultValue;
|
|
632
615
|
|
|
@@ -666,6 +649,8 @@ function () {
|
|
|
666
649
|
}
|
|
667
650
|
}
|
|
668
651
|
|
|
652
|
+
var handler = syntax && PROPERTY_HANDLERS[syntax];
|
|
653
|
+
|
|
669
654
|
if (handler) {
|
|
670
655
|
var propertyHandler = GlobalContainer.get(handler); // convert computed value to used value
|
|
671
656
|
|
|
@@ -687,8 +672,9 @@ function () {
|
|
|
687
672
|
DefaultStyleValueRegistry.prototype.postProcessProperty = function (name, object) {
|
|
688
673
|
var metadata = this.getMetadata(name);
|
|
689
674
|
|
|
690
|
-
if (metadata && metadata.
|
|
691
|
-
var
|
|
675
|
+
if (metadata && metadata.syntax) {
|
|
676
|
+
var handler = metadata.syntax && PROPERTY_HANDLERS[metadata.syntax];
|
|
677
|
+
var propertyHandler = GlobalContainer.get(handler);
|
|
692
678
|
|
|
693
679
|
if (propertyHandler && propertyHandler.postProcessor) {
|
|
694
680
|
propertyHandler.postProcessor(object);
|
package/es/css/interfaces.d.ts
CHANGED
|
@@ -1,6 +1,116 @@
|
|
|
1
1
|
import { Syringe } from 'mana-syringe';
|
|
2
2
|
import type { DisplayObject } from '../display-objects';
|
|
3
|
+
/**
|
|
4
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type
|
|
5
|
+
*/
|
|
6
|
+
export declare enum PropertySyntax {
|
|
7
|
+
/**
|
|
8
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#coordinate
|
|
9
|
+
*/
|
|
10
|
+
COORDINATE = "<coordinate>",
|
|
11
|
+
/**
|
|
12
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#color
|
|
13
|
+
*/
|
|
14
|
+
COLOR = "<color>",
|
|
15
|
+
/**
|
|
16
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#paint
|
|
17
|
+
*/
|
|
18
|
+
PAINT = "<paint>",
|
|
19
|
+
/**
|
|
20
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#number
|
|
21
|
+
*/
|
|
22
|
+
NUMBER = "<number>",
|
|
23
|
+
/**
|
|
24
|
+
* <number> with range 0..1
|
|
25
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#opacity_value
|
|
26
|
+
*/
|
|
27
|
+
OPACITY_VALUE = "<opacity-value>",
|
|
28
|
+
/**
|
|
29
|
+
* <number> with range 0..Infinity
|
|
30
|
+
*/
|
|
31
|
+
SHADOW_BLUR = "<shadow-blur>",
|
|
32
|
+
/**
|
|
33
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#length
|
|
34
|
+
*/
|
|
35
|
+
LENGTH = "<length>",
|
|
36
|
+
/**
|
|
37
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#percentage
|
|
38
|
+
*/
|
|
39
|
+
PERCENTAGE = "<percentage>",
|
|
40
|
+
LENGTH_PERCENTAGE = "<length> | <percentage>",
|
|
41
|
+
LENGTH_PERCENTAGE_12 = "[<length> | <percentage>]{1,2}",
|
|
42
|
+
/**
|
|
43
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin#formal_syntax
|
|
44
|
+
*/
|
|
45
|
+
LENGTH_PERCENTAGE_14 = "[<length> | <percentage>]{1,4}",
|
|
46
|
+
/**
|
|
47
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts
|
|
48
|
+
*/
|
|
49
|
+
LIST_OF_POINTS = "<list-of-points>",
|
|
50
|
+
PATH = "<path>",
|
|
51
|
+
/**
|
|
52
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax
|
|
53
|
+
*/
|
|
54
|
+
FILTER = "<filter>",
|
|
55
|
+
Z_INDEX = "<z-index>",
|
|
56
|
+
OFFSET_PATH = "<offset-path>",
|
|
57
|
+
OFFSET_DISTANCE = "<offset-distance>",
|
|
58
|
+
CLIP_PATH = "<clip-path>",
|
|
59
|
+
TRANSFORM = "<transform>",
|
|
60
|
+
TRANSFORM_ORIGIN = "<transform-origin>",
|
|
61
|
+
TEXT = "<text>",
|
|
62
|
+
TEXT_TRANSFORM = "<text-transform>"
|
|
63
|
+
}
|
|
64
|
+
export interface PropertyMetadata {
|
|
65
|
+
name: string;
|
|
66
|
+
/**
|
|
67
|
+
* The interpolable flag indicates whether a property can be animated smoothly.
|
|
68
|
+
* Default to `false`.
|
|
69
|
+
*/
|
|
70
|
+
interpolable?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* The property will inherit by default if no value is specified.
|
|
73
|
+
* Default to `false`.
|
|
74
|
+
*/
|
|
75
|
+
inherited?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* This property affects only one field on ComputedStyle, and can be set
|
|
78
|
+
* directly during inheritance instead of forcing a recalc.
|
|
79
|
+
*/
|
|
80
|
+
independent?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* This specifies the default value for this field.
|
|
83
|
+
* - for keyword fields, this is the initial keyword
|
|
84
|
+
* - for other fields, this is a string containg the C++ expression that is used to initialise the field.
|
|
85
|
+
*/
|
|
86
|
+
defaultValue?: string;
|
|
87
|
+
/**
|
|
88
|
+
* The resolved value used for getComputedStyle() depends on layout for this
|
|
89
|
+
* property, which means we may need to update layout to return the correct
|
|
90
|
+
* value from getComputedStyle().
|
|
91
|
+
*/
|
|
92
|
+
layoutDependent?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* This specifies all valid keyword values for the property.
|
|
95
|
+
*/
|
|
96
|
+
keywords?: string[];
|
|
97
|
+
/**
|
|
98
|
+
* eg. strokeWidth is an alias of lineWidth
|
|
99
|
+
*/
|
|
100
|
+
alias?: string[];
|
|
101
|
+
/**
|
|
102
|
+
* sort before init attributes according to this priority
|
|
103
|
+
*/
|
|
104
|
+
parsePriority?: number;
|
|
105
|
+
/**
|
|
106
|
+
* eg. <color> <paint> <number>
|
|
107
|
+
*/
|
|
108
|
+
syntax?: string;
|
|
109
|
+
}
|
|
3
110
|
export declare const StyleValueRegistry: Syringe.DefinedToken;
|
|
4
111
|
export interface StyleValueRegistry {
|
|
5
112
|
recalc: (displayObject: DisplayObject) => void;
|
|
113
|
+
registerMetadata: (metadata: PropertyMetadata) => void;
|
|
114
|
+
unregisterMetadata: (name: string) => void;
|
|
115
|
+
getMetadata: (name: string) => PropertyMetadata;
|
|
6
116
|
}
|