@visactor/vrender-components 0.16.17-alpha.1 → 0.16.17-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.js CHANGED
@@ -7715,7 +7715,7 @@
7715
7715
 
7716
7716
  var tempMatrix = new vutils.Matrix(),
7717
7717
  tempBounds$1 = new vutils.AABBBounds();
7718
- var GRAPHIC_UPDATE_TAG_KEY = ["lineWidth", "scaleX", "scaleY", "angle", "anchor", "visible"];
7718
+ var GRAPHIC_UPDATE_TAG_KEY = ["lineWidth", "lineCap", "lineJoin", "miterLimit", "scaleX", "scaleY", "angle", "anchor"];
7719
7719
  var tempConstantXYKey = ["x", "y"],
7720
7720
  tempConstantScaleXYKey = ["scaleX", "scaleY"],
7721
7721
  tempConstantAngleKey = ["angle"],
@@ -13526,7 +13526,6 @@
13526
13526
  }, {
13527
13527
  key: "updateRectAABBBounds",
13528
13528
  value: function updateRectAABBBounds(attribute, rectTheme, aabbBounds, graphic) {
13529
- if (!this._validCheck(attribute, rectTheme, aabbBounds, graphic)) return aabbBounds;
13530
13529
  if (!this.updatePathProxyAABBBounds(aabbBounds, graphic)) {
13531
13530
  var _attribute$width = attribute.width,
13532
13531
  width = _attribute$width === void 0 ? rectTheme.width : _attribute$width,
@@ -13560,14 +13559,13 @@
13560
13559
  }, {
13561
13560
  key: "updateGlyphAABBBounds",
13562
13561
  value: function updateGlyphAABBBounds(attribute, theme, aabbBounds, graphic) {
13563
- return this._validCheck(attribute, theme, aabbBounds, graphic) ? (graphic.getSubGraphic().forEach(function (node) {
13562
+ return graphic.getSubGraphic().forEach(function (node) {
13564
13563
  aabbBounds.union(node.AABBBounds);
13565
- }), aabbBounds) : aabbBounds;
13564
+ }), aabbBounds;
13566
13565
  }
13567
13566
  }, {
13568
13567
  key: "updateRichTextAABBBounds",
13569
13568
  value: function updateRichTextAABBBounds(attribute, richtextTheme, aabbBounds, graphic) {
13570
- if (!this._validCheck(attribute, richtextTheme, aabbBounds, graphic)) return aabbBounds;
13571
13569
  if (!graphic) return aabbBounds;
13572
13570
  var _attribute$width2 = attribute.width,
13573
13571
  width = _attribute$width2 === void 0 ? richtextTheme.width : _attribute$width2,
@@ -13620,7 +13618,6 @@
13620
13618
  }, {
13621
13619
  key: "updateTextAABBBounds",
13622
13620
  value: function updateTextAABBBounds(attribute, textTheme, aabbBounds, graphic) {
13623
- if (!this._validCheck(attribute, textTheme, aabbBounds, graphic)) return aabbBounds;
13624
13621
  if (!graphic) return aabbBounds;
13625
13622
  var _graphic$attribute$te = graphic.attribute.text,
13626
13623
  text = _graphic$attribute$te === void 0 ? textTheme.text : _graphic$attribute$te;
@@ -13645,7 +13642,6 @@
13645
13642
  }, {
13646
13643
  key: "updatePathAABBBounds",
13647
13644
  value: function updatePathAABBBounds(attribute, pathTheme, aabbBounds, graphic) {
13648
- if (!this._validCheck(attribute, pathTheme, aabbBounds, graphic)) return aabbBounds;
13649
13645
  this.updatePathProxyAABBBounds(aabbBounds, graphic) || this.updatePathAABBBoundsImprecise(attribute, pathTheme, aabbBounds, graphic);
13650
13646
  var tb1 = this.tempAABBBounds1,
13651
13647
  tb2 = this.tempAABBBounds2;
@@ -13697,7 +13693,6 @@
13697
13693
  }, {
13698
13694
  key: "updatePolygonAABBBounds",
13699
13695
  value: function updatePolygonAABBBounds(attribute, polygonTheme, aabbBounds, graphic) {
13700
- if (!this._validCheck(attribute, polygonTheme, aabbBounds, graphic)) return aabbBounds;
13701
13696
  this.updatePathProxyAABBBounds(aabbBounds, graphic) || this.updatePolygonAABBBoundsImprecise(attribute, polygonTheme, aabbBounds, graphic);
13702
13697
  var tb1 = this.tempAABBBounds1,
13703
13698
  tb2 = this.tempAABBBounds2;
@@ -13718,7 +13713,6 @@
13718
13713
  }, {
13719
13714
  key: "updateLineAABBBounds",
13720
13715
  value: function updateLineAABBBounds(attribute, lineTheme, aabbBounds, graphic) {
13721
- if (!this._validCheck(attribute, lineTheme, aabbBounds, graphic)) return aabbBounds;
13722
13716
  this.updatePathProxyAABBBounds(aabbBounds, graphic) || (attribute.segments ? this.updateLineAABBBoundsBySegments(attribute, lineTheme, aabbBounds, graphic) : this.updateLineAABBBoundsByPoints(attribute, lineTheme, aabbBounds, graphic));
13723
13717
  var tb1 = this.tempAABBBounds1,
13724
13718
  tb2 = this.tempAABBBounds2;
@@ -13752,7 +13746,6 @@
13752
13746
  }, {
13753
13747
  key: "updateAreaAABBBounds",
13754
13748
  value: function updateAreaAABBBounds(attribute, areaTheme, aabbBounds, graphic) {
13755
- if (!this._validCheck(attribute, areaTheme, aabbBounds, graphic)) return aabbBounds;
13756
13749
  this.updatePathProxyAABBBounds(aabbBounds, graphic) || (attribute.segments ? this.updateAreaAABBBoundsBySegments(attribute, areaTheme, aabbBounds, graphic) : this.updateAreaAABBBoundsByPoints(attribute, areaTheme, aabbBounds, graphic));
13757
13750
  var tb1 = this.tempAABBBounds1,
13758
13751
  tb2 = this.tempAABBBounds2;
@@ -13788,7 +13781,6 @@
13788
13781
  }, {
13789
13782
  key: "updateCircleAABBBounds",
13790
13783
  value: function updateCircleAABBBounds(attribute, circleTheme, aabbBounds, full, graphic) {
13791
- if (!this._validCheck(attribute, circleTheme, aabbBounds, graphic)) return aabbBounds;
13792
13784
  this.updatePathProxyAABBBounds(aabbBounds, graphic) || (full ? this.updateCircleAABBBoundsImprecise(attribute, circleTheme, aabbBounds, graphic) : this.updateCircleAABBBoundsAccurate(attribute, circleTheme, aabbBounds, graphic));
13793
13785
  var tb1 = this.tempAABBBounds1,
13794
13786
  tb2 = this.tempAABBBounds2;
@@ -13817,7 +13809,6 @@
13817
13809
  }, {
13818
13810
  key: "updateArcAABBBounds",
13819
13811
  value: function updateArcAABBBounds(attribute, arcTheme, aabbBounds, full, graphic) {
13820
- if (!this._validCheck(attribute, arcTheme, aabbBounds, graphic)) return aabbBounds;
13821
13812
  this.updatePathProxyAABBBounds(aabbBounds, graphic) || (full ? this.updateArcAABBBoundsImprecise(attribute, arcTheme, aabbBounds, graphic) : this.updateArcAABBBoundsAccurate(attribute, arcTheme, aabbBounds, graphic));
13822
13813
  var tb1 = this.tempAABBBounds1,
13823
13814
  tb2 = this.tempAABBBounds2;
@@ -13859,7 +13850,6 @@
13859
13850
  }, {
13860
13851
  key: "updateSymbolAABBBounds",
13861
13852
  value: function updateSymbolAABBBounds(attribute, symbolTheme, aabbBounds, full, graphic) {
13862
- if (!this._validCheck(attribute, symbolTheme, aabbBounds, graphic)) return aabbBounds;
13863
13853
  this.updatePathProxyAABBBounds(aabbBounds, graphic) || (full ? this.updateSymbolAABBBoundsImprecise(attribute, symbolTheme, aabbBounds, graphic) : this.updateSymbolAABBBoundsAccurate(attribute, symbolTheme, aabbBounds, graphic));
13864
13854
  var tb1 = this.tempAABBBounds1,
13865
13855
  tb2 = this.tempAABBBounds2;
@@ -13892,7 +13882,6 @@
13892
13882
  }, {
13893
13883
  key: "updateImageAABBBounds",
13894
13884
  value: function updateImageAABBBounds(attribute, imageTheme, aabbBounds, graphic) {
13895
- if (!this._validCheck(attribute, imageTheme, aabbBounds, graphic)) return aabbBounds;
13896
13885
  if (!this.updatePathProxyAABBBounds(aabbBounds, graphic)) {
13897
13886
  var _attribute$width3 = attribute.width,
13898
13887
  width = _attribute$width3 === void 0 ? imageTheme.width : _attribute$width3,
@@ -13939,15 +13928,6 @@
13939
13928
  }
13940
13929
  this.combindShadowAABBBounds(aabbBounds, graphic), vutils.transformBoundsWithMatrix(aabbBounds, aabbBounds, graphic.transMatrix);
13941
13930
  }
13942
- }, {
13943
- key: "_validCheck",
13944
- value: function _validCheck(attribute, theme, aabbBounds, graphic) {
13945
- if (!graphic) return !0;
13946
- if (!graphic.valid) return aabbBounds.clear(), !1;
13947
- var _attribute$visible = attribute.visible,
13948
- visible = _attribute$visible === void 0 ? theme.visible : _attribute$visible;
13949
- return !!visible || (aabbBounds.clear(), !1);
13950
- }
13951
13931
  }]);
13952
13932
  return DefaultGraphicService;
13953
13933
  }();
@@ -20815,18 +20795,18 @@
20815
20795
 
20816
20796
  const defaultAlternativeColors = ['#ffffff', '#000000'];
20817
20797
  const { Color } = vutils.ColorUtil;
20818
- function labelSmartInvert(foregroundColorOrigin, backgroundColorOrogin, textType, contrastRatiosThreshold, alternativeColors) {
20798
+ function labelSmartInvert(foregroundColorOrigin, backgroundColorOrogin, textType, contrastRatiosThreshold, alternativeColors, mode) {
20819
20799
  if (typeof foregroundColorOrigin !== 'string' || typeof backgroundColorOrogin !== 'string') {
20820
20800
  return foregroundColorOrigin;
20821
20801
  }
20822
20802
  const foregroundColor = new Color(foregroundColorOrigin).toHex();
20823
20803
  const backgroundColor = new Color(backgroundColorOrogin).toHex();
20824
- if (!contrastAccessibilityChecker(foregroundColor, backgroundColor, textType, contrastRatiosThreshold)) {
20825
- return improveContrastReverse(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors);
20804
+ if (!contrastAccessibilityChecker(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, mode)) {
20805
+ return improveContrastReverse(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors, mode);
20826
20806
  }
20827
20807
  return foregroundColor;
20828
20808
  }
20829
- function improveContrastReverse(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors) {
20809
+ function improveContrastReverse(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors, mode) {
20830
20810
  const alternativeColorPalletes = [];
20831
20811
  if (alternativeColors) {
20832
20812
  if (alternativeColors instanceof Array) {
@@ -20841,13 +20821,27 @@
20841
20821
  if (foregroundColor === alternativeColor) {
20842
20822
  continue;
20843
20823
  }
20844
- if (contrastAccessibilityChecker(alternativeColor, backgroundColor, textType, contrastRatiosThreshold)) {
20824
+ if (contrastAccessibilityChecker(alternativeColor, backgroundColor, textType, contrastRatiosThreshold, mode)) {
20845
20825
  return alternativeColor;
20846
20826
  }
20847
20827
  }
20848
20828
  return undefined;
20849
20829
  }
20850
- function contrastAccessibilityChecker(foregroundColor, backgroundColor, textType, contrastRatiosThreshold) {
20830
+ function contrastAccessibilityChecker(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, mode) {
20831
+ if (mode === 'lightness') {
20832
+ const backgroundColorLightness = Color.getColorBrightness(new Color(backgroundColor));
20833
+ const foregroundColorLightness = Color.getColorBrightness(new Color(foregroundColor));
20834
+ if (foregroundColorLightness < 0.5) {
20835
+ if (backgroundColorLightness >= 0.5) {
20836
+ return true;
20837
+ }
20838
+ return false;
20839
+ }
20840
+ if (backgroundColorLightness < 0.5) {
20841
+ return true;
20842
+ }
20843
+ return false;
20844
+ }
20851
20845
  if (contrastRatiosThreshold) {
20852
20846
  if (contrastRatios(foregroundColor, backgroundColor) > contrastRatiosThreshold) {
20853
20847
  return true;
@@ -22745,7 +22739,7 @@
22745
22739
  _smartInvert(labels) {
22746
22740
  var _a, _b, _c, _d, _e;
22747
22741
  const option = (this.attribute.smartInvert || {});
22748
- const { textType, contrastRatiosThreshold, alternativeColors } = option;
22742
+ const { textType, contrastRatiosThreshold, alternativeColors, mode } = option;
22749
22743
  const fillStrategy = (_a = option.fillStrategy) !== null && _a !== void 0 ? _a : 'invertBase';
22750
22744
  const strokeStrategy = (_b = option.strokeStrategy) !== null && _b !== void 0 ? _b : 'base';
22751
22745
  const brightColor = (_c = option.brightColor) !== null && _c !== void 0 ? _c : '#ffffff';
@@ -22763,7 +22757,7 @@
22763
22757
  const backgroundColor = baseMark.attribute.fill;
22764
22758
  const foregroundColor = label.attribute.fill;
22765
22759
  const baseColor = backgroundColor;
22766
- const invertColor = labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors);
22760
+ const invertColor = labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors, mode);
22767
22761
  const similarColor = contrastAccessibilityChecker(invertColor, brightColor) ? brightColor : darkColor;
22768
22762
  if (outsideEnable) {
22769
22763
  const fill = smartInvertStrategy(fillStrategy, baseColor, invertColor, similarColor);
@@ -22791,7 +22785,7 @@
22791
22785
  }
22792
22786
  if (label.attribute.stroke) {
22793
22787
  label.setAttributes({
22794
- fill: labelSmartInvert(label.attribute.fill, label.attribute.stroke, textType, contrastRatiosThreshold, alternativeColors)
22788
+ fill: labelSmartInvert(label.attribute.fill, label.attribute.stroke, textType, contrastRatiosThreshold, alternativeColors, mode)
22795
22789
  });
22796
22790
  continue;
22797
22791
  }
@@ -22955,7 +22949,7 @@
22955
22949
  }
22956
22950
  getGraphicBounds(graphic, point = {}) {
22957
22951
  var _a;
22958
- if (!graphic || graphic.type !== 'line') {
22952
+ if (graphic.type !== 'line') {
22959
22953
  return super.getGraphicBounds(graphic, point);
22960
22954
  }
22961
22955
  const { position = 'end' } = this.attribute;
@@ -28111,7 +28105,7 @@
28111
28105
  let focusSpace = 0;
28112
28106
  if (focus) {
28113
28107
  const focusSize = vutils.get(focusIconStyle, 'size', DEFAULT_SHAPE_SIZE);
28114
- focusShape = createSymbol(Object.assign(Object.assign({ x: 0, y: -focusSize / 2 - 1, strokeBoundsBuffer: 0 }, focusIconStyle), { visible: true, pickMode: 'imprecise', boundsPadding: parsedPadding }));
28108
+ focusShape = createSymbol(Object.assign(Object.assign({ x: 0, y: -focusSize / 2 - 1, strokeBoundsBuffer: 0 }, focusIconStyle), { visible: false, pickMode: 'imprecise', boundsPadding: parsedPadding }));
28115
28109
  this._appendDataToShape(focusShape, exports.LEGEND_ELEMENT_NAME.focus, item, itemGroup);
28116
28110
  focusSpace = focusSize;
28117
28111
  }
@@ -28186,7 +28180,6 @@
28186
28180
  const itemGroupHeight = this._itemHeightByUser || innerGroupHeight + parsedPadding[0] + parsedPadding[2];
28187
28181
  itemGroup.attribute.width = itemGroupWidth;
28188
28182
  itemGroup.attribute.height = itemGroupHeight;
28189
- focusShape && focusShape.setAttribute('visible', false);
28190
28183
  innerGroup.translateTo(-innerGroupBounds.x1 + parsedPadding[3], -innerGroupBounds.y1 + parsedPadding[0]);
28191
28184
  return itemGroup;
28192
28185
  }
@@ -31538,7 +31531,7 @@
31538
31531
  }
31539
31532
  };
31540
31533
 
31541
- const version = "0.16.17-alpha.1";
31534
+ const version = "0.16.17-alpha.2";
31542
31535
 
31543
31536
  exports.AbstractComponent = AbstractComponent;
31544
31537
  exports.ArcInfo = ArcInfo;