@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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.PROPERTY_HANDLERS = exports.DefaultStyleValueRegistry = exports.BUILT_IN_PROPERTIES = void 0;
|
|
7
7
|
|
|
8
8
|
var _tslib = require("tslib");
|
|
9
9
|
|
|
@@ -31,20 +31,14 @@ var _shapes = require("../shapes");
|
|
|
31
31
|
|
|
32
32
|
var _interfaces2 = require("./interfaces");
|
|
33
33
|
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
NUMBER: '<number>',
|
|
38
|
-
LENGTH: '<length>',
|
|
39
|
-
PERCENTAGE: '<percentage>',
|
|
40
|
-
LENGTH_PERCENTAGE: '<length> | <percentage>',
|
|
41
|
-
LIST_OF_POINTS: '<list-of-points>'
|
|
42
|
-
};
|
|
34
|
+
var _a;
|
|
35
|
+
|
|
36
|
+
var PROPERTY_HANDLERS = (_a = {}, _a[_interfaces2.PropertySyntax.COORDINATE] = _properties.CSSPropertyLocalPosition, _a[_interfaces2.PropertySyntax.COLOR] = _properties.CSSPropertyColor, _a[_interfaces2.PropertySyntax.PAINT] = _properties.CSSPropertyColor, _a[_interfaces2.PropertySyntax.OPACITY_VALUE] = _properties.CSSPropertyOpacity, _a[_interfaces2.PropertySyntax.LENGTH_PERCENTAGE] = _properties.CSSPropertyLengthOrPercentage, _a[_interfaces2.PropertySyntax.LENGTH_PERCENTAGE_12] = _properties.CSSPropertyLengthOrPercentage12, _a[_interfaces2.PropertySyntax.LENGTH_PERCENTAGE_14] = _properties.CSSPropertyLengthOrPercentage14, _a[_interfaces2.PropertySyntax.SHADOW_BLUR] = _properties.CSSPropertyShadowBlur, _a[_interfaces2.PropertySyntax.LIST_OF_POINTS] = _properties.CSSPropertyPoints, _a[_interfaces2.PropertySyntax.PATH] = _properties.CSSPropertyPath, _a[_interfaces2.PropertySyntax.FILTER] = _properties.CSSPropertyFilter, _a[_interfaces2.PropertySyntax.Z_INDEX] = _properties.CSSPropertyZIndex, _a[_interfaces2.PropertySyntax.OFFSET_PATH] = _properties.CSSPropertyOffsetPath, _a[_interfaces2.PropertySyntax.OFFSET_DISTANCE] = _properties.CSSPropertyOffsetDistance, _a[_interfaces2.PropertySyntax.CLIP_PATH] = _properties.CSSPropertyClipPath, _a[_interfaces2.PropertySyntax.TRANSFORM] = _properties.CSSPropertyTransform, _a[_interfaces2.PropertySyntax.TRANSFORM_ORIGIN] = _properties.CSSPropertyTransformOrigin, _a[_interfaces2.PropertySyntax.TEXT] = _properties.CSSPropertyText, _a[_interfaces2.PropertySyntax.TEXT_TRANSFORM] = _properties.CSSPropertyTextTransform, _a);
|
|
43
37
|
/**
|
|
44
38
|
* Blink used them in code generation(css_properties.json5)
|
|
45
39
|
*/
|
|
46
40
|
|
|
47
|
-
exports.
|
|
41
|
+
exports.PROPERTY_HANDLERS = PROPERTY_HANDLERS;
|
|
48
42
|
var BUILT_IN_PROPERTIES = [{
|
|
49
43
|
/**
|
|
50
44
|
* used in CSS Layout API
|
|
@@ -60,8 +54,7 @@ var BUILT_IN_PROPERTIES = [{
|
|
|
60
54
|
name: 'opacity',
|
|
61
55
|
interpolable: true,
|
|
62
56
|
defaultValue: '1',
|
|
63
|
-
syntax: PropertySyntax.
|
|
64
|
-
handler: _properties.CSSPropertyOpacity
|
|
57
|
+
syntax: _interfaces2.PropertySyntax.OPACITY_VALUE
|
|
65
58
|
}, {
|
|
66
59
|
/**
|
|
67
60
|
* range [0.0, 1.0]
|
|
@@ -71,8 +64,7 @@ var BUILT_IN_PROPERTIES = [{
|
|
|
71
64
|
interpolable: true,
|
|
72
65
|
inherited: true,
|
|
73
66
|
defaultValue: '1',
|
|
74
|
-
syntax: PropertySyntax.
|
|
75
|
-
handler: _properties.CSSPropertyOpacity
|
|
67
|
+
syntax: _interfaces2.PropertySyntax.OPACITY_VALUE
|
|
76
68
|
}, {
|
|
77
69
|
/**
|
|
78
70
|
* range [0.0, 1.0]
|
|
@@ -82,8 +74,7 @@ var BUILT_IN_PROPERTIES = [{
|
|
|
82
74
|
interpolable: true,
|
|
83
75
|
inherited: true,
|
|
84
76
|
defaultValue: '1',
|
|
85
|
-
syntax: PropertySyntax.
|
|
86
|
-
handler: _properties.CSSPropertyOpacity
|
|
77
|
+
syntax: _interfaces2.PropertySyntax.OPACITY_VALUE
|
|
87
78
|
}, {
|
|
88
79
|
/**
|
|
89
80
|
* background-color is not inheritable
|
|
@@ -93,37 +84,32 @@ var BUILT_IN_PROPERTIES = [{
|
|
|
93
84
|
interpolable: true,
|
|
94
85
|
keywords: ['none'],
|
|
95
86
|
defaultValue: 'none',
|
|
96
|
-
syntax: PropertySyntax.PAINT
|
|
97
|
-
handler: _properties.CSSPropertyColor
|
|
87
|
+
syntax: _interfaces2.PropertySyntax.PAINT
|
|
98
88
|
}, {
|
|
99
89
|
name: 'stroke',
|
|
100
90
|
interpolable: true,
|
|
101
91
|
keywords: ['none'],
|
|
102
92
|
defaultValue: 'none',
|
|
103
|
-
syntax: PropertySyntax.PAINT
|
|
104
|
-
handler: _properties.CSSPropertyColor
|
|
93
|
+
syntax: _interfaces2.PropertySyntax.PAINT
|
|
105
94
|
}, {
|
|
106
95
|
name: 'shadowColor',
|
|
107
96
|
interpolable: true,
|
|
108
|
-
syntax: PropertySyntax.COLOR
|
|
109
|
-
handler: _properties.CSSPropertyColor
|
|
97
|
+
syntax: _interfaces2.PropertySyntax.COLOR
|
|
110
98
|
}, {
|
|
111
99
|
name: 'shadowOffsetX',
|
|
112
100
|
interpolable: true,
|
|
113
101
|
layoutDependent: true,
|
|
114
|
-
syntax: PropertySyntax.LENGTH_PERCENTAGE
|
|
115
|
-
handler: _properties.CSSPropertyLengthOrPercentage
|
|
102
|
+
syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
|
|
116
103
|
}, {
|
|
117
104
|
name: 'shadowOffsetY',
|
|
118
105
|
interpolable: true,
|
|
119
106
|
layoutDependent: true,
|
|
120
|
-
syntax: PropertySyntax.LENGTH_PERCENTAGE
|
|
121
|
-
handler: _properties.CSSPropertyLengthOrPercentage
|
|
107
|
+
syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
|
|
122
108
|
}, {
|
|
123
109
|
name: 'shadowBlur',
|
|
124
110
|
interpolable: true,
|
|
125
111
|
layoutDependent: true,
|
|
126
|
-
|
|
112
|
+
syntax: _interfaces2.PropertySyntax.SHADOW_BLUR
|
|
127
113
|
}, {
|
|
128
114
|
/**
|
|
129
115
|
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-width
|
|
@@ -134,15 +120,13 @@ var BUILT_IN_PROPERTIES = [{
|
|
|
134
120
|
defaultValue: '1',
|
|
135
121
|
layoutDependent: true,
|
|
136
122
|
alias: ['strokeWidth'],
|
|
137
|
-
syntax: PropertySyntax.LENGTH_PERCENTAGE
|
|
138
|
-
handler: _properties.CSSPropertyLengthOrPercentage
|
|
123
|
+
syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
|
|
139
124
|
}, {
|
|
140
125
|
name: 'increasedLineWidthForHitTesting',
|
|
141
126
|
inherited: true,
|
|
142
127
|
defaultValue: '0',
|
|
143
128
|
layoutDependent: true,
|
|
144
|
-
syntax: PropertySyntax.LENGTH_PERCENTAGE
|
|
145
|
-
handler: _properties.CSSPropertyLengthOrPercentage
|
|
129
|
+
syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
|
|
146
130
|
}, {
|
|
147
131
|
name: 'lineJoin',
|
|
148
132
|
inherited: true,
|
|
@@ -163,40 +147,40 @@ var BUILT_IN_PROPERTIES = [{
|
|
|
163
147
|
inherited: true,
|
|
164
148
|
keywords: ['none'],
|
|
165
149
|
alias: ['strokeDasharray'],
|
|
166
|
-
|
|
150
|
+
syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE_12
|
|
167
151
|
}, {
|
|
168
152
|
name: 'lineDashOffset',
|
|
169
153
|
interpolable: true,
|
|
170
154
|
inherited: true,
|
|
171
155
|
defaultValue: '0',
|
|
172
156
|
alias: ['strokeDashoffset'],
|
|
173
|
-
|
|
157
|
+
syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
|
|
174
158
|
}, {
|
|
175
159
|
name: 'offsetPath',
|
|
176
|
-
|
|
160
|
+
syntax: _interfaces2.PropertySyntax.OFFSET_PATH
|
|
177
161
|
}, {
|
|
178
162
|
name: 'offsetDistance',
|
|
179
163
|
interpolable: true,
|
|
180
|
-
|
|
164
|
+
syntax: _interfaces2.PropertySyntax.OFFSET_DISTANCE
|
|
181
165
|
}, {
|
|
182
166
|
name: 'dx',
|
|
183
167
|
interpolable: true,
|
|
184
168
|
layoutDependent: true,
|
|
185
169
|
defaultValue: '0',
|
|
186
|
-
|
|
170
|
+
syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
|
|
187
171
|
}, {
|
|
188
172
|
name: 'dy',
|
|
189
173
|
interpolable: true,
|
|
190
174
|
layoutDependent: true,
|
|
191
175
|
defaultValue: '0',
|
|
192
|
-
|
|
176
|
+
syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
|
|
193
177
|
}, {
|
|
194
178
|
name: 'zIndex',
|
|
195
179
|
independent: true,
|
|
196
180
|
interpolable: true,
|
|
197
181
|
defaultValue: '0',
|
|
198
182
|
keywords: ['auto'],
|
|
199
|
-
|
|
183
|
+
syntax: _interfaces2.PropertySyntax.Z_INDEX
|
|
200
184
|
}, {
|
|
201
185
|
name: 'visibility',
|
|
202
186
|
keywords: ['visible', 'hidden'],
|
|
@@ -218,82 +202,77 @@ var BUILT_IN_PROPERTIES = [{
|
|
|
218
202
|
name: 'filter',
|
|
219
203
|
independent: true,
|
|
220
204
|
layoutDependent: true,
|
|
221
|
-
|
|
205
|
+
syntax: _interfaces2.PropertySyntax.FILTER
|
|
222
206
|
}, {
|
|
223
207
|
name: 'clipPath',
|
|
224
|
-
|
|
208
|
+
syntax: _interfaces2.PropertySyntax.CLIP_PATH
|
|
225
209
|
}, {
|
|
226
210
|
name: 'transform',
|
|
227
211
|
parsePriority: 100,
|
|
228
212
|
interpolable: true,
|
|
229
213
|
keywords: ['none'],
|
|
230
214
|
defaultValue: 'none',
|
|
231
|
-
|
|
215
|
+
syntax: _interfaces2.PropertySyntax.TRANSFORM
|
|
232
216
|
}, {
|
|
233
217
|
name: 'transformOrigin',
|
|
234
218
|
parsePriority: 100,
|
|
235
219
|
// interpolable: true,
|
|
236
220
|
defaultValue: 'left top',
|
|
237
221
|
layoutDependent: true,
|
|
238
|
-
|
|
222
|
+
syntax: _interfaces2.PropertySyntax.TRANSFORM_ORIGIN
|
|
239
223
|
}, {
|
|
240
224
|
name: 'anchor',
|
|
241
225
|
parsePriority: 99,
|
|
242
226
|
layoutDependent: true,
|
|
243
|
-
|
|
227
|
+
syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE_12
|
|
244
228
|
}, // <circle> & <ellipse>
|
|
245
229
|
{
|
|
246
230
|
name: 'cx',
|
|
247
231
|
interpolable: true,
|
|
248
232
|
defaultValue: '0',
|
|
249
|
-
syntax: PropertySyntax.
|
|
250
|
-
handler: _properties.CSSPropertyLocalPosition
|
|
233
|
+
syntax: _interfaces2.PropertySyntax.COORDINATE
|
|
251
234
|
}, {
|
|
252
235
|
name: 'cy',
|
|
253
236
|
interpolable: true,
|
|
254
237
|
defaultValue: '0',
|
|
255
|
-
syntax: PropertySyntax.
|
|
256
|
-
handler: _properties.CSSPropertyLocalPosition
|
|
238
|
+
syntax: _interfaces2.PropertySyntax.COORDINATE
|
|
257
239
|
}, {
|
|
258
240
|
name: 'r',
|
|
259
241
|
interpolable: true,
|
|
260
242
|
layoutDependent: true,
|
|
261
243
|
defaultValue: '0',
|
|
262
|
-
|
|
244
|
+
syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
|
|
263
245
|
}, {
|
|
264
246
|
name: 'rx',
|
|
265
247
|
interpolable: true,
|
|
266
248
|
layoutDependent: true,
|
|
267
249
|
defaultValue: 'auto',
|
|
268
|
-
|
|
250
|
+
syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
|
|
269
251
|
}, {
|
|
270
252
|
name: 'ry',
|
|
271
253
|
interpolable: true,
|
|
272
254
|
layoutDependent: true,
|
|
273
255
|
defaultValue: 'auto',
|
|
274
|
-
|
|
256
|
+
syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
|
|
275
257
|
}, // Rect Image Group
|
|
276
258
|
{
|
|
277
259
|
// x in local space
|
|
278
260
|
name: 'x',
|
|
279
261
|
interpolable: true,
|
|
280
262
|
defaultValue: '0',
|
|
281
|
-
syntax: PropertySyntax.
|
|
282
|
-
handler: _properties.CSSPropertyLocalPosition
|
|
263
|
+
syntax: _interfaces2.PropertySyntax.COORDINATE
|
|
283
264
|
}, {
|
|
284
265
|
// y in local space
|
|
285
266
|
name: 'y',
|
|
286
267
|
interpolable: true,
|
|
287
268
|
defaultValue: '0',
|
|
288
|
-
syntax: PropertySyntax.
|
|
289
|
-
handler: _properties.CSSPropertyLocalPosition
|
|
269
|
+
syntax: _interfaces2.PropertySyntax.COORDINATE
|
|
290
270
|
}, {
|
|
291
271
|
// z in local space
|
|
292
272
|
name: 'z',
|
|
293
273
|
interpolable: true,
|
|
294
274
|
defaultValue: '0',
|
|
295
|
-
syntax: PropertySyntax.
|
|
296
|
-
handler: _properties.CSSPropertyLocalPosition
|
|
275
|
+
syntax: _interfaces2.PropertySyntax.COORDINATE
|
|
297
276
|
}, {
|
|
298
277
|
name: 'width',
|
|
299
278
|
interpolable: true,
|
|
@@ -303,8 +282,8 @@ var BUILT_IN_PROPERTIES = [{
|
|
|
303
282
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/width
|
|
304
283
|
*/
|
|
305
284
|
keywords: ['auto', 'fit-content', 'min-content', 'max-content'],
|
|
306
|
-
defaultValue: '
|
|
307
|
-
|
|
285
|
+
defaultValue: 'auto',
|
|
286
|
+
syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
|
|
308
287
|
}, {
|
|
309
288
|
name: 'height',
|
|
310
289
|
interpolable: true,
|
|
@@ -314,45 +293,45 @@ var BUILT_IN_PROPERTIES = [{
|
|
|
314
293
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/height
|
|
315
294
|
*/
|
|
316
295
|
keywords: ['auto', 'fit-content', 'min-content', 'max-content'],
|
|
317
|
-
defaultValue: '
|
|
318
|
-
|
|
296
|
+
defaultValue: 'auto',
|
|
297
|
+
syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
|
|
319
298
|
}, {
|
|
320
299
|
name: 'radius',
|
|
321
300
|
interpolable: true,
|
|
322
301
|
layoutDependent: true,
|
|
323
302
|
defaultValue: '0',
|
|
324
|
-
|
|
303
|
+
syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE_14
|
|
325
304
|
}, // Line
|
|
326
305
|
{
|
|
327
306
|
name: 'x1',
|
|
328
307
|
interpolable: true,
|
|
329
308
|
layoutDependent: true,
|
|
330
|
-
|
|
309
|
+
syntax: _interfaces2.PropertySyntax.COORDINATE
|
|
331
310
|
}, {
|
|
332
311
|
name: 'y1',
|
|
333
312
|
interpolable: true,
|
|
334
313
|
layoutDependent: true,
|
|
335
|
-
|
|
314
|
+
syntax: _interfaces2.PropertySyntax.COORDINATE
|
|
336
315
|
}, {
|
|
337
316
|
name: 'z1',
|
|
338
317
|
interpolable: true,
|
|
339
318
|
layoutDependent: true,
|
|
340
|
-
|
|
319
|
+
syntax: _interfaces2.PropertySyntax.COORDINATE
|
|
341
320
|
}, {
|
|
342
321
|
name: 'x2',
|
|
343
322
|
interpolable: true,
|
|
344
323
|
layoutDependent: true,
|
|
345
|
-
|
|
324
|
+
syntax: _interfaces2.PropertySyntax.COORDINATE
|
|
346
325
|
}, {
|
|
347
326
|
name: 'y2',
|
|
348
327
|
interpolable: true,
|
|
349
328
|
layoutDependent: true,
|
|
350
|
-
|
|
329
|
+
syntax: _interfaces2.PropertySyntax.COORDINATE
|
|
351
330
|
}, {
|
|
352
331
|
name: 'z2',
|
|
353
332
|
interpolable: true,
|
|
354
333
|
layoutDependent: true,
|
|
355
|
-
|
|
334
|
+
syntax: _interfaces2.PropertySyntax.COORDINATE
|
|
356
335
|
}, // Path
|
|
357
336
|
{
|
|
358
337
|
name: 'path',
|
|
@@ -360,26 +339,25 @@ var BUILT_IN_PROPERTIES = [{
|
|
|
360
339
|
layoutDependent: true,
|
|
361
340
|
defaultValue: '',
|
|
362
341
|
alias: ['d'],
|
|
363
|
-
|
|
342
|
+
syntax: _interfaces2.PropertySyntax.PATH
|
|
364
343
|
}, // Polyline & Polygon
|
|
365
344
|
{
|
|
366
345
|
name: 'points',
|
|
367
346
|
layoutDependent: true,
|
|
368
|
-
syntax: PropertySyntax.LIST_OF_POINTS
|
|
369
|
-
handler: _properties.CSSPropertyPoints
|
|
347
|
+
syntax: _interfaces2.PropertySyntax.LIST_OF_POINTS
|
|
370
348
|
}, // Text
|
|
371
349
|
{
|
|
372
350
|
name: 'text',
|
|
373
351
|
layoutDependent: true,
|
|
374
|
-
|
|
375
|
-
|
|
352
|
+
defaultValue: '',
|
|
353
|
+
syntax: _interfaces2.PropertySyntax.TEXT
|
|
376
354
|
}, {
|
|
377
355
|
name: 'textTransform',
|
|
378
356
|
layoutDependent: true,
|
|
379
357
|
inherited: true,
|
|
380
358
|
keywords: ['capitalize', 'uppercase', 'lowercase', 'none'],
|
|
381
359
|
defaultValue: 'none',
|
|
382
|
-
|
|
360
|
+
syntax: _interfaces2.PropertySyntax.TEXT_TRANSFORM
|
|
383
361
|
}, {
|
|
384
362
|
name: 'font',
|
|
385
363
|
layoutDependent: true
|
|
@@ -393,7 +371,7 @@ var BUILT_IN_PROPERTIES = [{
|
|
|
393
371
|
*/
|
|
394
372
|
defaultValue: '16px',
|
|
395
373
|
layoutDependent: true,
|
|
396
|
-
|
|
374
|
+
syntax: _interfaces2.PropertySyntax.LENGTH_PERCENTAGE
|
|
397
375
|
}, {
|
|
398
376
|
name: 'fontFamily',
|
|
399
377
|
layoutDependent: true,
|
|
@@ -511,6 +489,10 @@ function () {
|
|
|
511
489
|
});
|
|
512
490
|
};
|
|
513
491
|
|
|
492
|
+
DefaultStyleValueRegistry.prototype.unregisterMetadata = function (name) {
|
|
493
|
+
delete this.cache[name];
|
|
494
|
+
};
|
|
495
|
+
|
|
514
496
|
DefaultStyleValueRegistry.prototype.getMetadata = function (name) {
|
|
515
497
|
return this.cache[name];
|
|
516
498
|
};
|
|
@@ -619,7 +601,8 @@ function () {
|
|
|
619
601
|
} else {
|
|
620
602
|
if (metadata) {
|
|
621
603
|
var keywords = metadata.keywords,
|
|
622
|
-
|
|
604
|
+
syntax = metadata.syntax;
|
|
605
|
+
var handler = syntax && PROPERTY_HANDLERS[syntax]; // use keywords
|
|
623
606
|
|
|
624
607
|
if (keywords && keywords.indexOf(value) > -1) {
|
|
625
608
|
computed = new _cssom.CSSKeywordValue(value);
|
|
@@ -648,7 +631,7 @@ function () {
|
|
|
648
631
|
var used = computed instanceof _cssom.CSSStyleValue ? computed.clone() : computed;
|
|
649
632
|
|
|
650
633
|
if (metadata) {
|
|
651
|
-
var
|
|
634
|
+
var syntax = metadata.syntax,
|
|
652
635
|
inherited = metadata.inherited,
|
|
653
636
|
defaultValue = metadata.defaultValue;
|
|
654
637
|
|
|
@@ -688,6 +671,8 @@ function () {
|
|
|
688
671
|
}
|
|
689
672
|
}
|
|
690
673
|
|
|
674
|
+
var handler = syntax && PROPERTY_HANDLERS[syntax];
|
|
675
|
+
|
|
691
676
|
if (handler) {
|
|
692
677
|
var propertyHandler = _manaSyringe.GlobalContainer.get(handler); // convert computed value to used value
|
|
693
678
|
|
|
@@ -710,8 +695,10 @@ function () {
|
|
|
710
695
|
DefaultStyleValueRegistry.prototype.postProcessProperty = function (name, object) {
|
|
711
696
|
var metadata = this.getMetadata(name);
|
|
712
697
|
|
|
713
|
-
if (metadata && metadata.
|
|
714
|
-
var
|
|
698
|
+
if (metadata && metadata.syntax) {
|
|
699
|
+
var handler = metadata.syntax && PROPERTY_HANDLERS[metadata.syntax];
|
|
700
|
+
|
|
701
|
+
var propertyHandler = _manaSyringe.GlobalContainer.get(handler);
|
|
715
702
|
|
|
716
703
|
if (propertyHandler && propertyHandler.postProcessor) {
|
|
717
704
|
propertyHandler.postProcessor(object);
|
package/lib/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
|
}
|
package/lib/css/interfaces.js
CHANGED
|
@@ -3,10 +3,85 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.StyleValueRegistry = void 0;
|
|
6
|
+
exports.StyleValueRegistry = exports.PropertySyntax = void 0;
|
|
7
7
|
|
|
8
8
|
var _manaSyringe = require("mana-syringe");
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type
|
|
12
|
+
*/
|
|
13
|
+
var PropertySyntax;
|
|
14
|
+
exports.PropertySyntax = PropertySyntax;
|
|
15
|
+
|
|
16
|
+
(function (PropertySyntax) {
|
|
17
|
+
/**
|
|
18
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#coordinate
|
|
19
|
+
*/
|
|
20
|
+
PropertySyntax["COORDINATE"] = "<coordinate>";
|
|
21
|
+
/**
|
|
22
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#color
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
PropertySyntax["COLOR"] = "<color>";
|
|
26
|
+
/**
|
|
27
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#paint
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
PropertySyntax["PAINT"] = "<paint>";
|
|
31
|
+
/**
|
|
32
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#number
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
PropertySyntax["NUMBER"] = "<number>";
|
|
36
|
+
/**
|
|
37
|
+
* <number> with range 0..1
|
|
38
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#opacity_value
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
PropertySyntax["OPACITY_VALUE"] = "<opacity-value>";
|
|
42
|
+
/**
|
|
43
|
+
* <number> with range 0..Infinity
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
PropertySyntax["SHADOW_BLUR"] = "<shadow-blur>";
|
|
47
|
+
/**
|
|
48
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#length
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
PropertySyntax["LENGTH"] = "<length>";
|
|
52
|
+
/**
|
|
53
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#percentage
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
PropertySyntax["PERCENTAGE"] = "<percentage>";
|
|
57
|
+
PropertySyntax["LENGTH_PERCENTAGE"] = "<length> | <percentage>";
|
|
58
|
+
PropertySyntax["LENGTH_PERCENTAGE_12"] = "[<length> | <percentage>]{1,2}";
|
|
59
|
+
/**
|
|
60
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin#formal_syntax
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
PropertySyntax["LENGTH_PERCENTAGE_14"] = "[<length> | <percentage>]{1,4}";
|
|
64
|
+
/**
|
|
65
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
PropertySyntax["LIST_OF_POINTS"] = "<list-of-points>";
|
|
69
|
+
PropertySyntax["PATH"] = "<path>";
|
|
70
|
+
/**
|
|
71
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
PropertySyntax["FILTER"] = "<filter>";
|
|
75
|
+
PropertySyntax["Z_INDEX"] = "<z-index>";
|
|
76
|
+
PropertySyntax["OFFSET_PATH"] = "<offset-path>";
|
|
77
|
+
PropertySyntax["OFFSET_DISTANCE"] = "<offset-distance>";
|
|
78
|
+
PropertySyntax["CLIP_PATH"] = "<clip-path>";
|
|
79
|
+
PropertySyntax["TRANSFORM"] = "<transform>";
|
|
80
|
+
PropertySyntax["TRANSFORM_ORIGIN"] = "<transform-origin>";
|
|
81
|
+
PropertySyntax["TEXT"] = "<text>";
|
|
82
|
+
PropertySyntax["TEXT_TRANSFORM"] = "<text-transform>";
|
|
83
|
+
})(PropertySyntax || (exports.PropertySyntax = PropertySyntax = {}));
|
|
84
|
+
|
|
10
85
|
var StyleValueRegistry = _manaSyringe.Syringe.defineToken('StyleValueRegistry');
|
|
11
86
|
|
|
12
87
|
exports.StyleValueRegistry = 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
|
}
|