@antv/g-lite 1.0.37 → 1.0.39

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.
Files changed (44) hide show
  1. package/dist/css/CSSProperty.d.ts +1 -0
  2. package/dist/css/CSSProperty.d.ts.map +1 -1
  3. package/dist/css/StyleValueRegistry.d.ts.map +1 -1
  4. package/dist/css/properties/CSSPropertyAngle.d.ts +1 -0
  5. package/dist/css/properties/CSSPropertyAngle.d.ts.map +1 -1
  6. package/dist/css/properties/CSSPropertyColor.d.ts +4 -0
  7. package/dist/css/properties/CSSPropertyColor.d.ts.map +1 -1
  8. package/dist/css/properties/CSSPropertyFilter.d.ts.map +1 -1
  9. package/dist/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -0
  10. package/dist/css/properties/CSSPropertyLengthOrPercentage.d.ts.map +1 -1
  11. package/dist/css/properties/CSSPropertyNumber.d.ts +1 -0
  12. package/dist/css/properties/CSSPropertyNumber.d.ts.map +1 -1
  13. package/dist/css/properties/CSSPropertyOffsetDistance.d.ts +1 -0
  14. package/dist/css/properties/CSSPropertyOffsetDistance.d.ts.map +1 -1
  15. package/dist/css/properties/CSSPropertyOpacity.d.ts +1 -0
  16. package/dist/css/properties/CSSPropertyOpacity.d.ts.map +1 -1
  17. package/dist/css/properties/CSSPropertyPath.d.ts +1 -0
  18. package/dist/css/properties/CSSPropertyPath.d.ts.map +1 -1
  19. package/dist/css/properties/CSSPropertyTransform.d.ts +1 -0
  20. package/dist/css/properties/CSSPropertyTransform.d.ts.map +1 -1
  21. package/dist/display-objects/Circle.d.ts.map +1 -1
  22. package/dist/display-objects/CustomElement.d.ts.map +1 -1
  23. package/dist/display-objects/DisplayObject.d.ts +8 -0
  24. package/dist/display-objects/DisplayObject.d.ts.map +1 -1
  25. package/dist/display-objects/Ellipse.d.ts.map +1 -1
  26. package/dist/display-objects/Group.d.ts.map +1 -1
  27. package/dist/display-objects/HTML.d.ts.map +1 -1
  28. package/dist/display-objects/Image.d.ts.map +1 -1
  29. package/dist/display-objects/Path.d.ts.map +1 -1
  30. package/dist/display-objects/Polygon.d.ts.map +1 -1
  31. package/dist/display-objects/Polyline.d.ts.map +1 -1
  32. package/dist/display-objects/Rect.d.ts.map +1 -1
  33. package/dist/display-objects/Text.d.ts +1 -1
  34. package/dist/display-objects/Text.d.ts.map +1 -1
  35. package/dist/index.d.ts +1 -1
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.esm.js +85 -35
  38. package/dist/index.js +85 -35
  39. package/dist/index.umd.js +85 -35
  40. package/dist/index.umd.min.js +1 -1
  41. package/dist/utils/canvas.d.ts.map +1 -1
  42. package/dist/utils/string.d.ts +1 -0
  43. package/dist/utils/string.d.ts.map +1 -1
  44. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1235,6 +1235,11 @@ var camelCase = memoize(function (str) {
1235
1235
  return g[1].toUpperCase();
1236
1236
  });
1237
1237
  });
1238
+ var kebabize = function kebabize(str) {
1239
+ return str.split('').map(function (letter, idx) {
1240
+ return letter.toUpperCase() === letter ? "" + (idx !== 0 ? '-' : '') + letter.toLowerCase() : letter;
1241
+ }).join('');
1242
+ };
1238
1243
 
1239
1244
  function DCHECK(bool) {
1240
1245
  if (!bool) {
@@ -5923,6 +5928,7 @@ function convertKeyword2Percent(keyword) {
5923
5928
  var CSSPropertyAngle = /*#__PURE__*/function () {
5924
5929
  function CSSPropertyAngle() {
5925
5930
  this.parser = parseAngle;
5931
+ this.parserWithCSSDisabled = null;
5926
5932
  this.mixer = mergeNumbers;
5927
5933
  }
5928
5934
  var _proto = CSSPropertyAngle.prototype;
@@ -5960,6 +5966,7 @@ var CSSPropertyClipPath = /*#__PURE__*/function () {
5960
5966
  var CSSPropertyColor = /*#__PURE__*/function () {
5961
5967
  function CSSPropertyColor() {
5962
5968
  this.parser = parseColor;
5969
+ this.parserWithCSSDisabled = parseColor;
5963
5970
  this.mixer = mergeColors;
5964
5971
  }
5965
5972
  var _proto = CSSPropertyColor.prototype;
@@ -5998,6 +6005,7 @@ function getFontSize(object) {
5998
6005
  var CSSPropertyLengthOrPercentage = /*#__PURE__*/function () {
5999
6006
  function CSSPropertyLengthOrPercentage() {
6000
6007
  this.parser = parseLengthOrPercentage;
6008
+ this.parserWithCSSDisabled = null;
6001
6009
  this.mixer = mergeNumbers;
6002
6010
  }
6003
6011
  var _proto = CSSPropertyLengthOrPercentage.prototype;
@@ -6221,6 +6229,7 @@ var CSSPropertyNumber = /*#__PURE__*/function () {
6221
6229
  function CSSPropertyNumber() {
6222
6230
  this.mixer = mergeNumbers;
6223
6231
  this.parser = parseNumber;
6232
+ this.parserWithCSSDisabled = null;
6224
6233
  }
6225
6234
  var _proto = CSSPropertyNumber.prototype;
6226
6235
  _proto.calculator = function calculator(name, oldParsed, computed) {
@@ -6232,6 +6241,7 @@ var CSSPropertyNumber = /*#__PURE__*/function () {
6232
6241
  var CSSPropertyOffsetDistance = /*#__PURE__*/function () {
6233
6242
  function CSSPropertyOffsetDistance() {
6234
6243
  this.parser = parseNumber;
6244
+ this.parserWithCSSDisabled = null;
6235
6245
  this.mixer = clampedMergeNumbers(0, 1);
6236
6246
  }
6237
6247
  var _proto = CSSPropertyOffsetDistance.prototype;
@@ -6265,6 +6275,7 @@ var CSSPropertyOffsetDistance = /*#__PURE__*/function () {
6265
6275
  var CSSPropertyOpacity = /*#__PURE__*/function () {
6266
6276
  function CSSPropertyOpacity() {
6267
6277
  this.parser = parseNumber;
6278
+ this.parserWithCSSDisabled = null;
6268
6279
  this.mixer = clampedMergeNumbers(0, 1);
6269
6280
  }
6270
6281
  var _proto = CSSPropertyOpacity.prototype;
@@ -6277,6 +6288,7 @@ var CSSPropertyOpacity = /*#__PURE__*/function () {
6277
6288
  var CSSPropertyPath = /*#__PURE__*/function () {
6278
6289
  function CSSPropertyPath() {
6279
6290
  this.parser = parsePath;
6291
+ this.parserWithCSSDisabled = parsePath;
6280
6292
  this.mixer = mergePaths;
6281
6293
  }
6282
6294
  var _proto = CSSPropertyPath.prototype;
@@ -6423,6 +6435,7 @@ var CSSPropertyTextTransform = /*#__PURE__*/function () {
6423
6435
  var CSSPropertyTransform = /*#__PURE__*/function () {
6424
6436
  function CSSPropertyTransform() {
6425
6437
  this.parser = parseTransform;
6438
+ this.parserWithCSSDisabled = parseTransform;
6426
6439
  this.mixer = mergeTransforms;
6427
6440
  }
6428
6441
  var _proto = CSSPropertyTransform.prototype;
@@ -8335,7 +8348,8 @@ var DEFAULT_PARSED_STYLE_PROPS = {
8335
8348
  transform: [],
8336
8349
  zIndex: 0,
8337
8350
  filter: [],
8338
- shadowType: 'outer'
8351
+ shadowType: 'outer',
8352
+ miterLimit: 10
8339
8353
  };
8340
8354
  var DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED = _extends({}, DEFAULT_PARSED_STYLE_PROPS, {
8341
8355
  opacity: 1,
@@ -8353,6 +8367,7 @@ var DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED = _extends({}, DEFAULT_PARSED_STYLE_
8353
8367
 
8354
8368
  var INHERITABLE_BASE_STYLE_PROPS = ['opacity', 'fillOpacity', 'strokeOpacity', 'transformOrigin', 'visibility', 'pointerEvents', 'lineWidth', 'lineCap', 'lineJoin', 'increasedLineWidthForHitTesting'];
8355
8369
  var INHERITABLE_STYLE_PROPS = [].concat(INHERITABLE_BASE_STYLE_PROPS, ['fontSize', 'fontFamily', 'fontStyle', 'fontWeight', 'fontVariant', 'textAlign', 'textBaseline', 'textTransform']);
8370
+ var DATASET_PREFIX = 'data-';
8356
8371
  /**
8357
8372
  * prototype chains: DisplayObject -> Element -> Node -> EventTarget
8358
8373
  *
@@ -8381,6 +8396,14 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
8381
8396
  * push to active animations after calling `animate()`
8382
8397
  */
8383
8398
 
8399
+ /**
8400
+ * Use data-* attribute.
8401
+ * @see https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes
8402
+ * @example
8403
+ * group.dataset.prop1 = 1;
8404
+ * group.getAttribute('data-prop1'); // 1
8405
+ */
8406
+
8384
8407
  function DisplayObject(config) {
8385
8408
  var _this$config$capture;
8386
8409
  var _this;
@@ -8391,6 +8414,7 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
8391
8414
  _this.isCustomElement = false;
8392
8415
  _this.isMutationObserved = false;
8393
8416
  _this.activeAnimations = [];
8417
+ _this.dataset = void 0;
8394
8418
  _this.getClip = function () {
8395
8419
  return this.style.clipPath || null;
8396
8420
  };
@@ -8425,6 +8449,19 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
8425
8449
  }
8426
8450
  // start to process attributes
8427
8451
  _this.initAttributes(_this.config.style);
8452
+ _this.dataset = new Proxy({}, {
8453
+ get: function get(target, name) {
8454
+ var formattedName = "" + DATASET_PREFIX + kebabize(name);
8455
+ if (target[formattedName] !== undefined) {
8456
+ return target[formattedName];
8457
+ }
8458
+ return _this.getAttribute(formattedName);
8459
+ },
8460
+ set: function set(_, prop, value) {
8461
+ _this.setAttribute("" + DATASET_PREFIX + kebabize(prop), value);
8462
+ return true;
8463
+ }
8464
+ });
8428
8465
  _this.style = new Proxy(
8429
8466
  // @ts-ignore
8430
8467
  {
@@ -9082,11 +9119,11 @@ var Circle = /*#__PURE__*/function (_DisplayObject) {
9082
9119
  rest = _objectWithoutPropertiesLoose(_ref, _excluded);
9083
9120
  return _DisplayObject.call(this, _extends({
9084
9121
  type: exports.Shape.CIRCLE,
9085
- style: _extends({
9122
+ style: runtime.enableCSSParsing ? _extends({
9086
9123
  cx: '',
9087
9124
  cy: '',
9088
9125
  r: ''
9089
- }, style),
9126
+ }, style) : _extends({}, style),
9090
9127
  initialParsedStyle: {
9091
9128
  anchor: [0.5, 0.5],
9092
9129
  transformOrigin: runtime.enableCSSParsing ? null : [getOrCreateUnitValue(50, '%'), getOrCreateUnitValue(50, '%')]
@@ -9114,10 +9151,10 @@ var CustomElement = /*#__PURE__*/function (_DisplayObject) {
9114
9151
  style = _ref.style,
9115
9152
  rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
9116
9153
  _this = _DisplayObject.call(this, _extends({
9117
- style: _extends({
9154
+ style: runtime.enableCSSParsing ? _extends({
9118
9155
  x: '',
9119
9156
  y: ''
9120
- }, style)
9157
+ }, style) : _extends({}, style)
9121
9158
  }, rest)) || this;
9122
9159
  _this.isCustomElement = true;
9123
9160
  return _this;
@@ -9169,12 +9206,12 @@ var Ellipse = /*#__PURE__*/function (_DisplayObject) {
9169
9206
  rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
9170
9207
  return _DisplayObject.call(this, _extends({
9171
9208
  type: exports.Shape.ELLIPSE,
9172
- style: _extends({
9209
+ style: runtime.enableCSSParsing ? _extends({
9173
9210
  cx: '',
9174
9211
  cy: '',
9175
9212
  rx: '',
9176
9213
  ry: ''
9177
- }, style),
9214
+ }, style) : _extends({}, style),
9178
9215
  initialParsedStyle: {
9179
9216
  anchor: [0.5, 0.5],
9180
9217
  transformOrigin: runtime.enableCSSParsing ? null : [getOrCreateUnitValue(50, '%'), getOrCreateUnitValue(50, '%')]
@@ -9203,12 +9240,12 @@ var Group = /*#__PURE__*/function (_DisplayObject) {
9203
9240
  rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
9204
9241
  return _DisplayObject.call(this, _extends({
9205
9242
  type: exports.Shape.GROUP,
9206
- style: _extends({
9243
+ style: runtime.enableCSSParsing ? _extends({
9207
9244
  x: '',
9208
9245
  y: '',
9209
9246
  width: '',
9210
9247
  height: ''
9211
- }, style)
9248
+ }, style) : _extends({}, style)
9212
9249
  }, rest)) || this;
9213
9250
  }
9214
9251
  return Group;
@@ -9228,13 +9265,13 @@ var HTML = /*#__PURE__*/function (_DisplayObject) {
9228
9265
  rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
9229
9266
  _this = _DisplayObject.call(this, _extends({
9230
9267
  type: exports.Shape.HTML,
9231
- style: _extends({
9268
+ style: runtime.enableCSSParsing ? _extends({
9232
9269
  x: '',
9233
9270
  y: '',
9234
9271
  width: 'auto',
9235
9272
  height: 'auto',
9236
9273
  innerHTML: ''
9237
- }, style)
9274
+ }, style) : _extends({}, style)
9238
9275
  }, rest)) || this;
9239
9276
  _this.cullable.enable = false;
9240
9277
  return _this;
@@ -9301,13 +9338,13 @@ var Image = /*#__PURE__*/function (_DisplayObject) {
9301
9338
  rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
9302
9339
  return _DisplayObject.call(this, _extends({
9303
9340
  type: exports.Shape.IMAGE,
9304
- style: _extends({
9341
+ style: runtime.enableCSSParsing ? _extends({
9305
9342
  x: '',
9306
9343
  y: '',
9307
9344
  img: '',
9308
9345
  width: '',
9309
9346
  height: ''
9310
- }, style)
9347
+ }, style) : _extends({}, style)
9311
9348
  }, rest)) || this;
9312
9349
  }
9313
9350
  return Image;
@@ -9493,6 +9530,7 @@ var Path = /*#__PURE__*/function (_DisplayObject) {
9493
9530
  miterLimit: ''
9494
9531
  }, style),
9495
9532
  initialParsedStyle: runtime.enableCSSParsing ? null : {
9533
+ miterLimit: 4,
9496
9534
  path: _extends({}, EMPTY_PARSED_PATH)
9497
9535
  }
9498
9536
  }, rest)) || this;
@@ -9719,7 +9757,10 @@ var Polygon = /*#__PURE__*/function (_DisplayObject) {
9719
9757
  points: '',
9720
9758
  miterLimit: '',
9721
9759
  isClosed: true
9722
- }, style)
9760
+ }, style),
9761
+ initialParsedStyle: runtime.enableCSSParsing ? null : {
9762
+ miterLimit: 4
9763
+ }
9723
9764
  }, rest)) || this;
9724
9765
  _this.markerStartAngle = 0;
9725
9766
  _this.markerEndAngle = 0;
@@ -9865,7 +9906,10 @@ var Polyline = /*#__PURE__*/function (_Polygon) {
9865
9906
  points: '',
9866
9907
  miterLimit: '',
9867
9908
  isClosed: false
9868
- }, style)
9909
+ }, style),
9910
+ initialParsedStyle: runtime.enableCSSParsing ? null : {
9911
+ miterLimit: 4
9912
+ }
9869
9913
  }, rest)) || this;
9870
9914
  }
9871
9915
  var _proto = Polyline.prototype;
@@ -9930,13 +9974,13 @@ var Rect = /*#__PURE__*/function (_DisplayObject) {
9930
9974
  rest = _objectWithoutPropertiesLoose(_ref, _excluded$a);
9931
9975
  return _DisplayObject.call(this, _extends({
9932
9976
  type: exports.Shape.RECT,
9933
- style: _extends({
9977
+ style: runtime.enableCSSParsing ? _extends({
9934
9978
  x: '',
9935
9979
  y: '',
9936
9980
  width: '',
9937
9981
  height: '',
9938
9982
  radius: ''
9939
- }, style)
9983
+ }, style) : _extends({}, style)
9940
9984
  }, rest)) || this;
9941
9985
  }
9942
9986
  return Rect;
@@ -9982,9 +10026,12 @@ var Text = /*#__PURE__*/function (_DisplayObject) {
9982
10026
  leading: 0,
9983
10027
  dx: '',
9984
10028
  dy: ''
9985
- }, style) : _extends({}, style),
10029
+ }, style) : _extends({
10030
+ fill: 'black'
10031
+ }, style),
9986
10032
  initialParsedStyle: runtime.enableCSSParsing ? {} : {
9987
- fill: 'black',
10033
+ x: 0,
10034
+ y: 0,
9988
10035
  fontSize: 16,
9989
10036
  fontFamily: 'sans-serif',
9990
10037
  fontStyle: 'normal',
@@ -9994,7 +10041,6 @@ var Text = /*#__PURE__*/function (_DisplayObject) {
9994
10041
  letterSpacing: 0,
9995
10042
  textBaseline: 'alphabetic',
9996
10043
  textAlign: 'start',
9997
- miterLimit: 10,
9998
10044
  wordWrap: false,
9999
10045
  wordWrapWidth: 0,
10000
10046
  leading: 0,
@@ -10638,14 +10684,14 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
10638
10684
  }
10639
10685
  // Rect
10640
10686
  // @ts-ignore
10641
- if (attributes.radius) {
10687
+ if (!util.isNil(attributes.radius)) {
10642
10688
  // @ts-ignore
10643
10689
  object.parsedStyle.radius = parseDimensionArrayFormat(
10644
10690
  // @ts-ignore
10645
10691
  attributes.radius, 4);
10646
10692
  }
10647
10693
  // Polyline
10648
- if (attributes.lineDash) {
10694
+ if (!util.isNil(attributes.lineDash)) {
10649
10695
  object.parsedStyle.lineDash = parseDimensionArrayFormat(attributes.lineDash, 2);
10650
10696
  }
10651
10697
  // @ts-ignore
@@ -10716,31 +10762,35 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
10716
10762
  attributes.markerMid, null, null);
10717
10763
  }
10718
10764
  if (
10765
+ // Circle & Ellipse
10766
+ (object.nodeName === exports.Shape.CIRCLE || object.nodeName === exports.Shape.ELLIPSE) && (
10719
10767
  // @ts-ignore
10720
- attributes.cx ||
10768
+ !util.isNil(attributes.cx) ||
10721
10769
  // @ts-ignore
10722
- attributes.cy ||
10770
+ !util.isNil(attributes.cy)) || (object.nodeName === exports.Shape.RECT || object.nodeName === exports.Shape.IMAGE || object.nodeName === exports.Shape.GROUP || object.nodeName === exports.Shape.HTML || object.nodeName === exports.Shape.TEXT || object.nodeName === exports.Shape.MESH) && (
10723
10771
  // @ts-ignore
10724
- attributes.x ||
10772
+ !util.isNil(attributes.x) ||
10725
10773
  // @ts-ignore
10726
- attributes.y ||
10774
+ !util.isNil(attributes.y) ||
10727
10775
  // @ts-ignore
10728
- attributes.z ||
10776
+ !util.isNil(attributes.z)) ||
10777
+ // Line
10778
+ object.nodeName === exports.Shape.LINE && (
10729
10779
  // @ts-ignore
10730
- attributes.x1 ||
10780
+ !util.isNil(attributes.x1) ||
10731
10781
  // @ts-ignore
10732
- attributes.y1 ||
10782
+ !util.isNil(attributes.y1) ||
10733
10783
  // @ts-ignore
10734
- attributes.z1 ||
10784
+ !util.isNil(attributes.z1) ||
10735
10785
  // @ts-ignore
10736
- attributes.x2 ||
10786
+ !util.isNil(attributes.x2) ||
10737
10787
  // @ts-ignore
10738
- attributes.y2 ||
10788
+ !util.isNil(attributes.y2) ||
10739
10789
  // @ts-ignore
10740
- attributes.z2) {
10790
+ !util.isNil(attributes.z2))) {
10741
10791
  runtime.CSSPropertySyntaxFactory['<coordinate>'].postProcessor(object, _attributeNames);
10742
10792
  }
10743
- if (attributes.zIndex) {
10793
+ if (!util.isNil(attributes.zIndex)) {
10744
10794
  runtime.CSSPropertySyntaxFactory['<z-index>'].postProcessor(object, _attributeNames);
10745
10795
  }
10746
10796
  // @ts-ignore
@@ -10751,7 +10801,7 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
10751
10801
  if (attributes.points) {
10752
10802
  runtime.CSSPropertySyntaxFactory['<list-of-points>'].postProcessor(object, _attributeNames);
10753
10803
  }
10754
- if (attributes.offsetDistance) {
10804
+ if (!util.isNil(attributes.offsetDistance)) {
10755
10805
  runtime.CSSPropertySyntaxFactory['<offset-distance>'].postProcessor(object, _attributeNames);
10756
10806
  }
10757
10807
  if (attributes.transform) {