@visactor/react-vtable 1.19.10-alpha.2 → 1.19.10-alpha.4

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/cjs/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from './tables';
2
2
  export * from './table-components';
3
3
  export * from './components';
4
- export declare const version = "1.19.10-alpha.2";
4
+ export declare const version = "1.19.10-alpha.4";
package/cjs/index.js CHANGED
@@ -18,5 +18,5 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
18
18
  Object.defineProperty(exports, "__esModule", {
19
19
  value: !0
20
20
  }), exports.version = void 0, __exportStar(require("./tables"), exports), __exportStar(require("./table-components"), exports),
21
- __exportStar(require("./components"), exports), exports.version = "1.19.10-alpha.2";
21
+ __exportStar(require("./components"), exports), exports.version = "1.19.10-alpha.4";
22
22
  //# sourceMappingURL=index.js.map
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,qDAAmC;AACnC,+CAA6B;AAEhB,QAAA,OAAO,GAAG,iBAAiB,CAAC","file":"index.js","sourcesContent":["export * from './tables';\nexport * from './table-components';\nexport * from './components';\n\nexport const version = \"1.19.10-alpha.2\";\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,qDAAmC;AACnC,+CAA6B;AAEhB,QAAA,OAAO,GAAG,iBAAiB,CAAC","file":"index.js","sourcesContent":["export * from './tables';\nexport * from './table-components';\nexport * from './components';\n\nexport const version = \"1.19.10-alpha.4\";\n"]}
@@ -1381,7 +1381,15 @@
1381
1381
  const EnvContribution = Symbol.for("EnvContribution");
1382
1382
  const DEFAULT_TEXT_FONT_FAMILY$1 = "PingFang SC,Helvetica Neue,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif,apple color emoji,segoe ui emoji,segoe ui symbol";
1383
1383
 
1384
- class Application {}
1384
+ const container = new Container();
1385
+
1386
+ const RenderService = Symbol.for("RenderService");
1387
+
1388
+ class Application {
1389
+ get renderService() {
1390
+ return this._renderService || (this._renderService = container.get(RenderService)), this._renderService;
1391
+ }
1392
+ }
1385
1393
  const application = new Application();
1386
1394
 
1387
1395
  var MeasureModeEnum;
@@ -3749,7 +3757,8 @@
3749
3757
  y1: 0,
3750
3758
  strokeBoundsBuffer: 0,
3751
3759
  cornerRadius: 0,
3752
- cornerType: "round"
3760
+ cornerType: "round",
3761
+ drawStrokeWhenZeroWH: !1
3753
3762
  });
3754
3763
  Object.assign(Object.assign({}, DefaultAttribute), {
3755
3764
  width: 0,
@@ -3758,7 +3767,8 @@
3758
3767
  y1: 0,
3759
3768
  cornerRadius: 0,
3760
3769
  length: 0,
3761
- cornerType: "round"
3770
+ cornerType: "round",
3771
+ drawStrokeWhenZeroWH: !1
3762
3772
  });
3763
3773
  const DefaultSymbolAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
3764
3774
  symbolType: "circle",
@@ -3985,6 +3995,34 @@
3985
3995
  }
3986
3996
  return c;
3987
3997
  }
3998
+ static processColorStops(colorStops) {
3999
+ if (!colorStops || 0 === colorStops.length) return [];
4000
+ if (colorStops.some(item => item.length)) {
4001
+ const stops = colorStops.map(item => ({
4002
+ color: item.value,
4003
+ offset: item.length ? parseFloat(item.length.value) / 100 : -1
4004
+ }));
4005
+ stops[0].offset < 0 && (stops[0].offset = 0), stops[stops.length - 1].offset < 0 && (stops[stops.length - 1].offset = 1);
4006
+ for (let i = 1; i < stops.length - 1; i++) if (stops[i].offset < 0) {
4007
+ const prevWithOffsetIdx = i - 1;
4008
+ let nextWithOffsetIdx = i + 1;
4009
+ for (; nextWithOffsetIdx < stops.length && stops[nextWithOffsetIdx].offset < 0;) nextWithOffsetIdx++;
4010
+ const startOffset = stops[prevWithOffsetIdx].offset,
4011
+ endOffset = stops[nextWithOffsetIdx].offset,
4012
+ unspecCount = nextWithOffsetIdx - prevWithOffsetIdx;
4013
+ for (let j = 1; j < unspecCount; j++) stops[prevWithOffsetIdx + j].offset = startOffset + (endOffset - startOffset) * j / unspecCount;
4014
+ i = nextWithOffsetIdx - 1;
4015
+ }
4016
+ return stops;
4017
+ }
4018
+ return colorStops.map((item, index) => {
4019
+ const offset = colorStops.length > 1 ? index / (colorStops.length - 1) : 0;
4020
+ return {
4021
+ color: item.value,
4022
+ offset: offset
4023
+ };
4024
+ });
4025
+ }
3988
4026
  static ParseConic(datum) {
3989
4027
  const {
3990
4028
  orientation: orientation,
@@ -3998,10 +4036,7 @@
3998
4036
  y: .5,
3999
4037
  startAngle: sa,
4000
4038
  endAngle: sa + pi2,
4001
- stops: colorStops.map(item => ({
4002
- color: item.value,
4003
- offset: parseFloat(item.length.value) / 100
4004
- }))
4039
+ stops: GradientParser.processColorStops(colorStops)
4005
4040
  };
4006
4041
  }
4007
4042
  static ParseRadial(datum) {
@@ -4016,10 +4051,7 @@
4016
4051
  y1: .5,
4017
4052
  r0: 0,
4018
4053
  r1: 1,
4019
- stops: colorStops.map(item => ({
4020
- color: item.value,
4021
- offset: parseFloat(item.length.value) / 100
4022
- }))
4054
+ stops: GradientParser.processColorStops(colorStops)
4023
4055
  };
4024
4056
  }
4025
4057
  static ParseLinear(datum) {
@@ -4041,10 +4073,7 @@
4041
4073
  y0: y0,
4042
4074
  x1: x1,
4043
4075
  y1: y1,
4044
- stops: colorStops.map(item => ({
4045
- color: item.value,
4046
- offset: parseFloat(item.length.value) / 100
4047
- }))
4076
+ stops: GradientParser.processColorStops(colorStops)
4048
4077
  };
4049
4078
  }
4050
4079
  }
@@ -4232,8 +4261,6 @@
4232
4261
  return result.width += space, result;
4233
4262
  }
4234
4263
 
4235
- const container = new Container();
4236
-
4237
4264
  const CanvasFactory = Symbol.for("CanvasFactory");
4238
4265
 
4239
4266
  function wrapCanvas(params) {
@@ -6727,7 +6754,7 @@
6727
6754
  });
6728
6755
  }
6729
6756
  setAttributes(params, forceUpdateTag = !1, context) {
6730
- (params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background ? this.loadImage(params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context);
6757
+ params && ((params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background ? this.loadImage(params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context));
6731
6758
  }
6732
6759
  _setAttributes(params, forceUpdateTag = !1, context) {
6733
6760
  const keys = Object.keys(params);
@@ -7362,8 +7389,8 @@
7362
7389
  function strokeVisible(opacity, strokeOpacity) {
7363
7390
  return opacity * strokeOpacity > 0;
7364
7391
  }
7365
- function rectStrokeVisible(opacity, strokeOpacity, width, height) {
7366
- return opacity * strokeOpacity > 0 && 0 !== width && 0 !== height;
7392
+ function rectStrokeVisible(opacity, strokeOpacity, width, height, drawStrokeWhenZeroWH) {
7393
+ return drawStrokeWhenZeroWH ? opacity * strokeOpacity > 0 : opacity * strokeOpacity > 0 && 0 !== width && 0 !== height;
7367
7394
  }
7368
7395
 
7369
7396
  const ImageRenderContribution = Symbol.for("ImageRenderContribution");
@@ -7725,7 +7752,7 @@
7725
7752
  this.cache.layoutData.lines.forEach(item => {
7726
7753
  mergedText += item.str;
7727
7754
  });
7728
- return (Array.isArray(text) ? text.join("") : text) !== mergedText;
7755
+ return (Array.isArray(text) ? text.join("") : text).toString() !== mergedText;
7729
7756
  }
7730
7757
  return "vertical" === attribute.direction && this.cache.verticalList && this.cache.verticalList[0] ? this.cache.verticalList[0].map(item => item.text).join("") !== attribute.text.toString() : null != this.clipedText && this.clipedText !== attribute.text.toString();
7731
7758
  }
@@ -7824,7 +7851,7 @@
7824
7851
  return fontSize ? .1 * fontSize : 0;
7825
7852
  }
7826
7853
  updateHorizontalMultilineAABBBounds(text) {
7827
- var _a;
7854
+ var _a, _b;
7828
7855
  const textTheme = this.getGraphicTheme(),
7829
7856
  attribute = this.attribute,
7830
7857
  {
@@ -7851,7 +7878,7 @@
7851
7878
  const bbox = this.cache.layoutData.bbox;
7852
7879
  return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
7853
7880
  }
7854
- const textMeasure = application.graphicUtil.textMeasure,
7881
+ const textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || (null === (_b = this.stage) || void 0 === _b ? void 0 : _b.textMeasureId)),
7855
7882
  layoutData = new CanvasTextLayout(fontFamily, {
7856
7883
  fontSize: fontSize,
7857
7884
  fontWeight: fontWeight,
@@ -7869,7 +7896,7 @@
7869
7896
  return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
7870
7897
  }
7871
7898
  updateWrapAABBBounds(text) {
7872
- var _a, _b, _c;
7899
+ var _a, _b, _c, _d;
7873
7900
  const textTheme = this.getGraphicTheme(),
7874
7901
  {
7875
7902
  fontFamily = textTheme.fontFamily,
@@ -7895,7 +7922,7 @@
7895
7922
  const bbox = this.cache.layoutData.bbox;
7896
7923
  return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
7897
7924
  }
7898
- const textMeasure = application.graphicUtil.textMeasure,
7925
+ const textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || (null === (_b = this.stage) || void 0 === _b ? void 0 : _b.textMeasureId)),
7899
7926
  textOptions = {
7900
7927
  fontSize: fontSize,
7901
7928
  fontWeight: fontWeight,
@@ -7927,7 +7954,7 @@
7927
7954
  if ("" !== str && "" === clip.str || clip.wordBreaked) {
7928
7955
  if (ellipsis) {
7929
7956
  const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
7930
- clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
7957
+ clip.str = null !== (_c = clipEllipsis.str) && void 0 !== _c ? _c : "", clip.width = null !== (_d = clipEllipsis.width) && void 0 !== _d ? _d : 0;
7931
7958
  } else clip.str = "", clip.width = 0;
7932
7959
  needCut = !1;
7933
7960
  }
@@ -7990,9 +8017,9 @@
7990
8017
  return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
7991
8018
  }
7992
8019
  updateVerticalMultilineAABBBounds(text) {
7993
- var _a, _b;
8020
+ var _a, _b, _c;
7994
8021
  const textTheme = this.getGraphicTheme(),
7995
- textMeasure = application.graphicUtil.textMeasure;
8022
+ textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || (null === (_a = this.stage) || void 0 === _a ? void 0 : _a.textMeasureId));
7996
8023
  let width;
7997
8024
  const attribute = this.attribute,
7998
8025
  {
@@ -8013,7 +8040,7 @@
8013
8040
  } = attribute;
8014
8041
  if (!verticalMode) {
8015
8042
  const t = textAlign;
8016
- textAlign = null !== (_a = Text.baselineMapAlign[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = Text.alignMapBaseline[t]) && void 0 !== _b ? _b : "top";
8043
+ textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
8017
8044
  }
8018
8045
  if (width = 0, !this.shouldUpdateShape() && this.cache) {
8019
8046
  this.cache.verticalList.forEach(item => {
@@ -8127,7 +8154,7 @@
8127
8154
  return isArray$1(text) ? !text.every(t => null == t || "" === t) : null != text && "" !== text;
8128
8155
  }
8129
8156
  updateMultilineAABBBounds(text) {
8130
- var _a, _b, _c, _d;
8157
+ var _a, _b, _c, _d, _e;
8131
8158
  const textTheme = this.getGraphicTheme(),
8132
8159
  {
8133
8160
  fontFamily = textTheme.fontFamily,
@@ -8151,7 +8178,7 @@
8151
8178
  const bbox = this.cache.layoutData.bbox;
8152
8179
  return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
8153
8180
  }
8154
- const textMeasure = application.graphicUtil.textMeasure,
8181
+ const textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || (null === (_c = this.stage) || void 0 === _c ? void 0 : _c.textMeasureId)),
8155
8182
  layoutObj = new CanvasTextLayout(fontFamily, {
8156
8183
  fontSize: fontSize,
8157
8184
  fontWeight: fontWeight,
@@ -8180,7 +8207,7 @@
8180
8207
  if ("" !== str && "" === clip.str) {
8181
8208
  if (ellipsis) {
8182
8209
  const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
8183
- clip.str = null !== (_c = clipEllipsis.str) && void 0 !== _c ? _c : "", clip.width = null !== (_d = clipEllipsis.width) && void 0 !== _d ? _d : 0;
8210
+ clip.str = null !== (_d = clipEllipsis.str) && void 0 !== _d ? _d : "", clip.width = null !== (_e = clipEllipsis.width) && void 0 !== _e ? _e : 0;
8184
8211
  } else clip.str = "", clip.width = 0;
8185
8212
  needCut = !1;
8186
8213
  }
@@ -9194,7 +9221,7 @@
9194
9221
  case "right":
9195
9222
  deltaX = -aabbBounds.width();
9196
9223
  }
9197
- return aabbBounds.translate(deltaX, deltaY), application.graphicService.updateTempAABBBounds(aabbBounds), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, richtextTheme, aabbBounds), this.widthWithoutTransform = aabbBounds.x2 - aabbBounds.x1, this.heightWithoutTransform = aabbBounds.y2 - aabbBounds.y1, application.graphicService.transformAABBBounds(attribute, aabbBounds, richtextTheme, !1, this), 0 === aabbBounds.width() && 0 === aabbBounds.height() && aabbBounds.clear(), aabbBounds;
9224
+ return height || ("middle" === this.verticalDirection ? deltaY -= aabbBounds.height() / 2 : "bottom" === this.verticalDirection && (deltaY -= aabbBounds.height())), aabbBounds.translate(deltaX, deltaY), application.graphicService.updateTempAABBBounds(aabbBounds), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, richtextTheme, aabbBounds), this.widthWithoutTransform = aabbBounds.x2 - aabbBounds.x1, this.heightWithoutTransform = aabbBounds.y2 - aabbBounds.y1, application.graphicService.transformAABBBounds(attribute, aabbBounds, richtextTheme, !1, this), 0 === aabbBounds.width() && 0 === aabbBounds.height() && aabbBounds.clear(), aabbBounds;
9198
9225
  }
9199
9226
  needUpdateTags(keys) {
9200
9227
  return super.needUpdateTags(keys, RICHTEXT_UPDATE_TAG_KEY);
@@ -10408,7 +10435,8 @@
10408
10435
  y1: y1,
10409
10436
  x: originX = rectAttribute.x,
10410
10437
  y: originY = rectAttribute.y,
10411
- fillStrokeOrder = rectAttribute.fillStrokeOrder
10438
+ fillStrokeOrder = rectAttribute.fillStrokeOrder,
10439
+ drawStrokeWhenZeroWH = rectAttribute.drawStrokeWhenZeroWH
10412
10440
  } = rect.attribute;
10413
10441
  let {
10414
10442
  width: width,
@@ -10416,7 +10444,7 @@
10416
10444
  } = rect.attribute;
10417
10445
  width = (null != width ? width : x1 - originX) || 0, height = (null != height ? height : y1 - originY) || 0;
10418
10446
  const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill),
10419
- sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height),
10447
+ sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height, drawStrokeWhenZeroWH),
10420
10448
  doFill = runFill(fill, background),
10421
10449
  doStroke = runStroke(stroke, lineWidth);
10422
10450
  if (!rect.valid || !visible) return;
@@ -19788,7 +19816,7 @@
19788
19816
  const Checkbox = React.forwardRef(CheckboxComponent);
19789
19817
  Checkbox.displayName = 'Checkbox';
19790
19818
 
19791
- const version = "1.19.10-alpha.2";
19819
+ const version = "1.19.10-alpha.4";
19792
19820
 
19793
19821
  Object.defineProperty(exports, 'register', {
19794
19822
  enumerable: true,