@antv/g 5.0.23-alpha.0 → 5.0.23-alpha.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/cssom/CSSKeywordValue.d.ts +1 -1
- package/es/css/cssom/CSSNumericSumValue.d.ts +1 -1
- package/es/css/cssom/CSSNumericValue.d.ts +108 -4
- package/es/css/cssom/CSSNumericValue.js +908 -5
- package/es/css/cssom/CSSNumericValueType.d.ts +1 -1
- package/es/css/cssom/CSSNumericValueType.js +1 -1
- package/es/css/cssom/CSSTransformValue.d.ts +1 -1
- package/es/css/cssom/index.d.ts +0 -9
- package/es/css/cssom/index.js +1 -10
- package/lib/css/cssom/CSSKeywordValue.d.ts +1 -1
- package/lib/css/cssom/CSSNumericSumValue.d.ts +1 -1
- package/lib/css/cssom/CSSNumericValue.d.ts +108 -4
- package/lib/css/cssom/CSSNumericValue.js +965 -52
- package/lib/css/cssom/CSSNumericValueType.d.ts +1 -1
- package/lib/css/cssom/CSSNumericValueType.js +59 -59
- package/lib/css/cssom/CSSTransformValue.d.ts +1 -1
- package/lib/css/cssom/index.d.ts +0 -9
- package/lib/css/cssom/index.js +0 -117
- package/package.json +3 -3
- package/es/css/cssom/CSSMathInvert.d.ts +0 -14
- package/es/css/cssom/CSSMathInvert.js +0 -84
- package/es/css/cssom/CSSMathMax.d.ts +0 -17
- package/es/css/cssom/CSSMathMax.js +0 -118
- package/es/css/cssom/CSSMathMin.d.ts +0 -17
- package/es/css/cssom/CSSMathMin.js +0 -119
- package/es/css/cssom/CSSMathNegate.d.ts +0 -14
- package/es/css/cssom/CSSMathNegate.js +0 -80
- package/es/css/cssom/CSSMathProduct.d.ts +0 -16
- package/es/css/cssom/CSSMathProduct.js +0 -109
- package/es/css/cssom/CSSMathSum.d.ts +0 -17
- package/es/css/cssom/CSSMathSum.js +0 -117
- package/es/css/cssom/CSSMathValue.d.ts +0 -11
- package/es/css/cssom/CSSMathValue.js +0 -27
- package/es/css/cssom/CSSMathVariadic.d.ts +0 -9
- package/es/css/cssom/CSSMathVariadic.js +0 -44
- package/es/css/cssom/CSSUnitValue.d.ts +0 -33
- package/es/css/cssom/CSSUnitValue.js +0 -252
- package/lib/css/cssom/CSSMathInvert.d.ts +0 -14
- package/lib/css/cssom/CSSMathInvert.js +0 -94
- package/lib/css/cssom/CSSMathMax.d.ts +0 -17
- package/lib/css/cssom/CSSMathMax.js +0 -128
- package/lib/css/cssom/CSSMathMin.d.ts +0 -17
- package/lib/css/cssom/CSSMathMin.js +0 -128
- package/lib/css/cssom/CSSMathNegate.d.ts +0 -14
- package/lib/css/cssom/CSSMathNegate.js +0 -89
- package/lib/css/cssom/CSSMathProduct.d.ts +0 -16
- package/lib/css/cssom/CSSMathProduct.js +0 -119
- package/lib/css/cssom/CSSMathSum.d.ts +0 -17
- package/lib/css/cssom/CSSMathSum.js +0 -129
- package/lib/css/cssom/CSSMathValue.d.ts +0 -11
- package/lib/css/cssom/CSSMathValue.js +0 -35
- package/lib/css/cssom/CSSMathVariadic.d.ts +0 -9
- package/lib/css/cssom/CSSMathVariadic.js +0 -55
- package/lib/css/cssom/CSSUnitValue.d.ts +0 -33
- package/lib/css/cssom/CSSUnitValue.js +0 -267
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CSSUnitValue = void 0;
|
|
7
|
-
|
|
8
|
-
var _tslib = require("tslib");
|
|
9
|
-
|
|
10
|
-
var _utils = require("../../utils");
|
|
11
|
-
|
|
12
|
-
var _CSSMathInvert = require("./CSSMathInvert");
|
|
13
|
-
|
|
14
|
-
var _CSSNumericValue = require("./CSSNumericValue");
|
|
15
|
-
|
|
16
|
-
var _CSSNumericValueType = require("./CSSNumericValueType");
|
|
17
|
-
|
|
18
|
-
var _ = require(".");
|
|
19
|
-
|
|
20
|
-
var _CSSStyleValue = require("./CSSStyleValue");
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The CSSUnitValue interface of the CSS_Object_Model represents values that contain a single unit type.
|
|
24
|
-
* For example, "42px" would be represented by a CSSNumericValue.
|
|
25
|
-
*
|
|
26
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSUnitValue
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Represents numeric values that can be expressed as a single number plus a
|
|
31
|
-
* unit (or a naked number or percentage).
|
|
32
|
-
* @see https://drafts.css-houdini.org/css-typed-om/#cssunitvalue
|
|
33
|
-
*/
|
|
34
|
-
var CSSUnitValue =
|
|
35
|
-
/** @class */
|
|
36
|
-
function (_super) {
|
|
37
|
-
(0, _tslib.__extends)(CSSUnitValue, _super);
|
|
38
|
-
|
|
39
|
-
function CSSUnitValue(value, unitOrName) {
|
|
40
|
-
if (unitOrName === void 0) {
|
|
41
|
-
unitOrName = _.UnitType.kNumber;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
var _this = this;
|
|
45
|
-
|
|
46
|
-
var unit;
|
|
47
|
-
|
|
48
|
-
if (typeof unitOrName === 'string') {
|
|
49
|
-
unit = CSSUnitValue.unitFromName(unitOrName);
|
|
50
|
-
} else {
|
|
51
|
-
unit = unitOrName;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
(0, _utils.DCHECK)(CSSUnitValue.isValidUnit(unit));
|
|
55
|
-
_this = _super.call(this, new _CSSNumericValueType.CSSNumericValueType(unit)) || this;
|
|
56
|
-
_this.unit = unit;
|
|
57
|
-
_this.value = value;
|
|
58
|
-
return _this;
|
|
59
|
-
} // static fromCSSValue(value: CSSNumericLiteralValue) {
|
|
60
|
-
// let unit = value.type;
|
|
61
|
-
// if (unit === UnitType.kInteger) unit = UnitType.kNumber;
|
|
62
|
-
// if (!this.isValidUnit(unit)) return null;
|
|
63
|
-
// return new CSSUnitValue(value.getDoubleValue(), unit);
|
|
64
|
-
// }
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
CSSUnitValue.toCanonicalUnit = function (unit) {
|
|
68
|
-
return this.canonicalUnitTypeForCategory(this.unitTypeToUnitCategory(unit));
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
CSSUnitValue.toCanonicalUnitIfPossible = function (unit) {
|
|
72
|
-
var canonical_unit = this.toCanonicalUnit(unit);
|
|
73
|
-
if (canonical_unit === _.UnitType.kUnknown) return unit;
|
|
74
|
-
return canonical_unit;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
CSSUnitValue.formatInfinityOrNaN = function (number, suffix) {
|
|
78
|
-
if (suffix === void 0) {
|
|
79
|
-
suffix = '';
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
var result = '';
|
|
83
|
-
|
|
84
|
-
if (!Number.isFinite(number)) {
|
|
85
|
-
if (number > 0) result = 'infinity';else result = '-infinity';
|
|
86
|
-
} else {
|
|
87
|
-
(0, _utils.DCHECK)(Number.isNaN(number));
|
|
88
|
-
result = 'NaN';
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return result += suffix;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
CSSUnitValue.formatNumber = function (number, suffix) {
|
|
95
|
-
if (suffix === void 0) {
|
|
96
|
-
suffix = '';
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return number + suffix;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
CSSUnitValue.prototype.clone = function () {
|
|
103
|
-
return new CSSUnitValue(this.value, this.unit);
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
CSSUnitValue.prototype.convertTo = function (target_unit) {
|
|
107
|
-
if (this.unit === target_unit) {
|
|
108
|
-
return new CSSUnitValue(this.value, this.unit);
|
|
109
|
-
} // Instead of defining the scale factors for every unit to every other unit,
|
|
110
|
-
// we simply convert to the canonical unit and back since we already have
|
|
111
|
-
// the scale factors for canonical units.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
var canonical_unit = CSSUnitValue.toCanonicalUnit(this.unit);
|
|
115
|
-
|
|
116
|
-
if (canonical_unit !== CSSUnitValue.toCanonicalUnit(target_unit) || canonical_unit === _.UnitType.kUnknown) {
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
var scale_factor = _CSSStyleValue.CSSStyleValue.conversionToCanonicalUnitsScaleFactor(this.unit) / _CSSStyleValue.CSSStyleValue.conversionToCanonicalUnitsScaleFactor(target_unit);
|
|
121
|
-
|
|
122
|
-
return new CSSUnitValue(this.value * scale_factor, target_unit);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
CSSUnitValue.prototype.equals = function (other) {
|
|
126
|
-
var other_unit_value = other;
|
|
127
|
-
return this.value === other_unit_value.value && this.unit === other_unit_value.unit;
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
CSSUnitValue.prototype.getType = function () {
|
|
131
|
-
return _.CSSStyleValueType.kUnitType;
|
|
132
|
-
}; // toCSSValue() {
|
|
133
|
-
// return new CSSNumericLiteralValue(this.value, this.unit);
|
|
134
|
-
// }
|
|
135
|
-
// // const CSSPrimitiveValue* ToCSSValueWithProperty(CSSPropertyID) const final;
|
|
136
|
-
// toCalcExpressionNode() {
|
|
137
|
-
// return CSSMathExpressionNumericLiteral.create(
|
|
138
|
-
// new CSSNumericLiteralValue(this.value, this.unit),
|
|
139
|
-
// );
|
|
140
|
-
// }
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
CSSUnitValue.prototype.sumValue = function () {
|
|
144
|
-
var sum = [];
|
|
145
|
-
var unit_map = {};
|
|
146
|
-
|
|
147
|
-
if (this.unit !== _.UnitType.kNumber) {
|
|
148
|
-
unit_map[CSSUnitValue.toCanonicalUnitIfPossible(this.unit)] = 1;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
sum.push({
|
|
152
|
-
value: this.value * _CSSStyleValue.CSSStyleValue.conversionToCanonicalUnitsScaleFactor(this.unit),
|
|
153
|
-
units: unit_map
|
|
154
|
-
});
|
|
155
|
-
return sum;
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
CSSUnitValue.prototype.negate = function () {
|
|
159
|
-
return new CSSUnitValue(-this.value, this.unit);
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
CSSUnitValue.prototype.invert = function () {
|
|
163
|
-
if (this.unit === _.UnitType.kNumber) {
|
|
164
|
-
if (this.value === 0) return null;
|
|
165
|
-
return new CSSUnitValue(1.0 / this.value, this.unit);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return _CSSMathInvert.CSSMathInvert.create(this);
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
CSSUnitValue.prototype.buildCSSText = function (n, p, result) {
|
|
172
|
-
var text;
|
|
173
|
-
|
|
174
|
-
switch (this.unit) {
|
|
175
|
-
case _.UnitType.kUnknown:
|
|
176
|
-
// FIXME
|
|
177
|
-
break;
|
|
178
|
-
|
|
179
|
-
case _.UnitType.kInteger:
|
|
180
|
-
text = Number(this.value).toFixed(0);
|
|
181
|
-
break;
|
|
182
|
-
|
|
183
|
-
case _.UnitType.kNumber:
|
|
184
|
-
case _.UnitType.kPercentage:
|
|
185
|
-
case _.UnitType.kEms:
|
|
186
|
-
case _.UnitType.kQuirkyEms:
|
|
187
|
-
case _.UnitType.kExs:
|
|
188
|
-
case _.UnitType.kRems:
|
|
189
|
-
case _.UnitType.kChs:
|
|
190
|
-
case _.UnitType.kPixels:
|
|
191
|
-
case _.UnitType.kCentimeters:
|
|
192
|
-
case _.UnitType.kDotsPerPixel:
|
|
193
|
-
case _.UnitType.kDotsPerInch:
|
|
194
|
-
case _.UnitType.kDotsPerCentimeter:
|
|
195
|
-
case _.UnitType.kMillimeters:
|
|
196
|
-
case _.UnitType.kQuarterMillimeters:
|
|
197
|
-
case _.UnitType.kInches:
|
|
198
|
-
case _.UnitType.kPoints:
|
|
199
|
-
case _.UnitType.kPicas:
|
|
200
|
-
case _.UnitType.kUserUnits:
|
|
201
|
-
case _.UnitType.kDegrees:
|
|
202
|
-
case _.UnitType.kRadians:
|
|
203
|
-
case _.UnitType.kGradians:
|
|
204
|
-
case _.UnitType.kMilliseconds:
|
|
205
|
-
case _.UnitType.kSeconds:
|
|
206
|
-
case _.UnitType.kHertz:
|
|
207
|
-
case _.UnitType.kKilohertz:
|
|
208
|
-
case _.UnitType.kTurns:
|
|
209
|
-
case _.UnitType.kFraction:
|
|
210
|
-
case _.UnitType.kViewportWidth:
|
|
211
|
-
case _.UnitType.kViewportHeight:
|
|
212
|
-
case _.UnitType.kViewportInlineSize:
|
|
213
|
-
case _.UnitType.kViewportBlockSize:
|
|
214
|
-
case _.UnitType.kViewportMin:
|
|
215
|
-
case _.UnitType.kViewportMax:
|
|
216
|
-
case _.UnitType.kSmallViewportWidth:
|
|
217
|
-
case _.UnitType.kSmallViewportHeight:
|
|
218
|
-
case _.UnitType.kSmallViewportInlineSize:
|
|
219
|
-
case _.UnitType.kSmallViewportBlockSize:
|
|
220
|
-
case _.UnitType.kSmallViewportMin:
|
|
221
|
-
case _.UnitType.kSmallViewportMax:
|
|
222
|
-
case _.UnitType.kLargeViewportWidth:
|
|
223
|
-
case _.UnitType.kLargeViewportHeight:
|
|
224
|
-
case _.UnitType.kLargeViewportInlineSize:
|
|
225
|
-
case _.UnitType.kLargeViewportBlockSize:
|
|
226
|
-
case _.UnitType.kLargeViewportMin:
|
|
227
|
-
case _.UnitType.kLargeViewportMax:
|
|
228
|
-
case _.UnitType.kDynamicViewportWidth:
|
|
229
|
-
case _.UnitType.kDynamicViewportHeight:
|
|
230
|
-
case _.UnitType.kDynamicViewportInlineSize:
|
|
231
|
-
case _.UnitType.kDynamicViewportBlockSize:
|
|
232
|
-
case _.UnitType.kDynamicViewportMin:
|
|
233
|
-
case _.UnitType.kDynamicViewportMax:
|
|
234
|
-
case _.UnitType.kContainerWidth:
|
|
235
|
-
case _.UnitType.kContainerHeight:
|
|
236
|
-
case _.UnitType.kContainerInlineSize:
|
|
237
|
-
case _.UnitType.kContainerBlockSize:
|
|
238
|
-
case _.UnitType.kContainerMin:
|
|
239
|
-
case _.UnitType.kContainerMax:
|
|
240
|
-
{
|
|
241
|
-
var kMinInteger = -999999;
|
|
242
|
-
var kMaxInteger = 999999;
|
|
243
|
-
var value = this.value;
|
|
244
|
-
var unit = CSSUnitValue.unitTypeToString(this.unit);
|
|
245
|
-
|
|
246
|
-
if (value < kMinInteger || value > kMaxInteger) {
|
|
247
|
-
var unit_1 = CSSUnitValue.unitTypeToString(this.unit);
|
|
248
|
-
|
|
249
|
-
if (!Number.isFinite(value) || Number.isNaN(value)) {
|
|
250
|
-
text = CSSUnitValue.formatInfinityOrNaN(value, unit_1);
|
|
251
|
-
} else {
|
|
252
|
-
text = CSSUnitValue.formatNumber(value, unit_1);
|
|
253
|
-
}
|
|
254
|
-
} else {
|
|
255
|
-
text = "".concat(value).concat(unit);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
result += text;
|
|
261
|
-
return result;
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
return CSSUnitValue;
|
|
265
|
-
}(_CSSNumericValue.CSSNumericValue);
|
|
266
|
-
|
|
267
|
-
exports.CSSUnitValue = CSSUnitValue;
|