@visactor/vrender-components 1.1.4 → 1.1.6-alpha.0

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.es.js CHANGED
@@ -208,7 +208,7 @@ class Node extends EventEmitter {
208
208
  constructor() {
209
209
  super(), this._uid = Generator.GenAutoIncrementId(), this._firstChild = null, this._lastChild = null, this.parent = null, this._count = 1;
210
210
  }
211
- onParentSharedStateTreeChanged(_stage, _layer) {}
211
+ onParentSharedStateTreeChanged(_stage, _layer, _inheritedSharedStateScope) {}
212
212
  forEachChildren(cb, reverse = !1) {
213
213
  if (reverse) {
214
214
  let child = this._lastChild,
@@ -4875,14 +4875,17 @@ class GraphicImpl extends Node {
4875
4875
  }
4876
4876
  return null === (_a = this.stage) || void 0 === _a ? void 0 : _a.rootSharedStateScope;
4877
4877
  }
4878
- syncSharedStateScopeBindingFromTree(markDirty = !0) {
4878
+ syncSharedStateScopeBinding(nextScope, markDirty = !0) {
4879
4879
  var _a;
4880
- const nextScope = this.resolveBoundSharedStateScope();
4881
4880
  return this.boundSharedStateScope === nextScope ? (this.syncSharedStateActiveRegistrations(), !1) : (this.boundSharedStateScope = nextScope, this.boundSharedStateRevision = void 0, this.compiledStateDefinitions = void 0, this.compiledStateDefinitionsCacheKey = void 0, this.stateEngine = void 0, this.stateEngineCompiledDefinitions = void 0, this.syncSharedStateActiveRegistrations(), markDirty && (null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) && this.markSharedStateDirty(), !0);
4882
4881
  }
4883
- syncSharedStateScopeBindingOnTreeChange(markDirty = !0) {
4882
+ syncSharedStateScopeBindingFromTree(markDirty = !0, inheritedSharedStateScope) {
4883
+ const nextScope = void 0 === inheritedSharedStateScope ? this.resolveBoundSharedStateScope() : null != inheritedSharedStateScope ? inheritedSharedStateScope : void 0;
4884
+ return this.syncSharedStateScopeBinding(nextScope, markDirty);
4885
+ }
4886
+ syncSharedStateScopeBindingOnTreeChange(markDirty = !0, inheritedSharedStateScope) {
4884
4887
  var _a, _b;
4885
- return !!((null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || this.boundSharedStateScope || (null === (_b = this.registeredActiveScopes) || void 0 === _b ? void 0 : _b.size) || this.sharedStateDirty) && this.syncSharedStateScopeBindingFromTree(markDirty);
4888
+ return !!((null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || this.boundSharedStateScope || (null === (_b = this.registeredActiveScopes) || void 0 === _b ? void 0 : _b.size) || this.sharedStateDirty) && this.syncSharedStateScopeBindingFromTree(markDirty, inheritedSharedStateScope);
4886
4889
  }
4887
4890
  syncSharedStateActiveRegistrations() {
4888
4891
  var _a;
@@ -4890,6 +4893,7 @@ class GraphicImpl extends Node {
4890
4893
  if (!(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || !this.boundSharedStateScope) return (null == previousScopes ? void 0 : previousScopes.size) && (previousScopes.forEach(scope => {
4891
4894
  scope.subtreeActiveDescendants.delete(this);
4892
4895
  }), previousScopes.clear()), void (this.registeredActiveScopes = void 0);
4896
+ if ((null == previousScopes ? void 0 : previousScopes.size) && this.isSharedStateScopeChainRegistered(previousScopes)) return;
4893
4897
  const nextScopes = new Set(collectSharedStateScopeChain(this.boundSharedStateScope));
4894
4898
  null == previousScopes || previousScopes.forEach(scope => {
4895
4899
  nextScopes.has(scope) || scope.subtreeActiveDescendants.delete(this);
@@ -4897,6 +4901,15 @@ class GraphicImpl extends Node {
4897
4901
  scope.subtreeActiveDescendants.add(this);
4898
4902
  }), this.registeredActiveScopes = nextScopes;
4899
4903
  }
4904
+ isSharedStateScopeChainRegistered(previousScopes) {
4905
+ let scope = this.boundSharedStateScope,
4906
+ scopeCount = 0;
4907
+ for (; scope;) {
4908
+ if (!previousScopes.has(scope)) return !1;
4909
+ scopeCount += 1, scope = scope.parentScope;
4910
+ }
4911
+ return scopeCount === previousScopes.size;
4912
+ }
4900
4913
  clearSharedStateActiveRegistrations() {
4901
4914
  const previousScopes = this.registeredActiveScopes;
4902
4915
  previousScopes && (previousScopes.forEach(scope => {
@@ -4906,8 +4919,8 @@ class GraphicImpl extends Node {
4906
4919
  markSharedStateDirty() {
4907
4920
  this.sharedStateDirty = !0, enqueueGraphicSharedStateRefresh(this.stage, this), scheduleStageSharedStateRefresh(this.stage);
4908
4921
  }
4909
- onParentSharedStateTreeChanged(stage, layer) {
4910
- this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange() : this.setStage(stage, layer);
4922
+ onParentSharedStateTreeChanged(stage, layer, inheritedSharedStateScope) {
4923
+ this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope) : this.setStage(stage, layer, inheritedSharedStateScope);
4911
4924
  }
4912
4925
  refreshSharedStateBeforeRender() {
4913
4926
  var _a;
@@ -5558,6 +5571,10 @@ class GraphicImpl extends Node {
5558
5571
  var _a;
5559
5572
  return null === (_a = this.states) || void 0 === _a ? void 0 : _a[stateName];
5560
5573
  }
5574
+ setStateDefinitionsWithCompiled(definitions, compiledDefinitions) {
5575
+ var _a;
5576
+ this.states = definitions, this.localStateDefinitionsSource !== definitions && (this.localStateDefinitionsSource = definitions, this.localStateDefinitionsVersion = (null !== (_a = this.localStateDefinitionsVersion) && void 0 !== _a ? _a : 0) + 1), this.compiledStateDefinitions = compiledDefinitions, this.compiledStateDefinitionsCacheKey = `local:${this.localStateDefinitionsVersion}`;
5577
+ }
5561
5578
  getStateResolveBaseAttrs() {
5562
5579
  var _a;
5563
5580
  return null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute;
@@ -5905,12 +5922,12 @@ class GraphicImpl extends Node {
5905
5922
  this._globalTransMatrix.translate(scrollX, scrollY);
5906
5923
  }
5907
5924
  }
5908
- setStage(stage, layer) {
5925
+ setStage(stage, layer, inheritedSharedStateScope) {
5909
5926
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
5910
5927
  const graphicService = null !== (_c = null !== (_a = null == stage ? void 0 : stage.graphicService) && void 0 !== _a ? _a : null === (_b = this.stage) || void 0 === _b ? void 0 : _b.graphicService) && void 0 !== _c ? _c : application.graphicService,
5911
5928
  previousStage = this.stage;
5912
5929
  if (this.stage !== stage || this.layer !== layer) {
5913
- if (this.stage = stage, this.layer = layer, ((null === (_d = this.currentStates) || void 0 === _d ? void 0 : _d.length) || this.boundSharedStateScope || (null === (_e = this.registeredActiveScopes) || void 0 === _e ? void 0 : _e.size) || this.sharedStateDirty) && this.syncSharedStateScopeBindingOnTreeChange(!0), this.setStageToShadowRoot(stage, layer), this.mayHaveTrackedAnimates() && this.hasAnyTrackedAnimate()) {
5930
+ if (this.stage = stage, this.layer = layer, ((null === (_d = this.currentStates) || void 0 === _d ? void 0 : _d.length) || this.boundSharedStateScope || (null === (_e = this.registeredActiveScopes) || void 0 === _e ? void 0 : _e.size) || this.sharedStateDirty) && this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope), this.setStageToShadowRoot(stage, layer), this.mayHaveTrackedAnimates() && this.hasAnyTrackedAnimate()) {
5914
5931
  const previousTimeline = null === (_f = null == previousStage ? void 0 : previousStage.getTimeline) || void 0 === _f ? void 0 : _f.call(previousStage),
5915
5932
  nextTimeline = null === (_g = null == stage ? void 0 : stage.getTimeline) || void 0 === _g ? void 0 : _g.call(stage),
5916
5933
  detachedStageAnimates = [];
@@ -5927,7 +5944,7 @@ class GraphicImpl extends Node {
5927
5944
  }
5928
5945
  return this._onSetStage && this._onSetStage(this, stage, layer), void (null === (_h = null == graphicService ? void 0 : graphicService.onSetStage) || void 0 === _h || _h.call(graphicService, this, stage));
5929
5946
  }
5930
- ((null === (_j = this.currentStates) || void 0 === _j ? void 0 : _j.length) || this.boundSharedStateScope || (null === (_k = this.registeredActiveScopes) || void 0 === _k ? void 0 : _k.size) || this.sharedStateDirty) && this.syncSharedStateScopeBindingOnTreeChange(!0);
5947
+ ((null === (_j = this.currentStates) || void 0 === _j ? void 0 : _j.length) || this.boundSharedStateScope || (null === (_k = this.registeredActiveScopes) || void 0 === _k ? void 0 : _k.size) || this.sharedStateDirty) && this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope);
5931
5948
  }
5932
5949
  detachStageForRelease() {
5933
5950
  var _a, _b, _c;
@@ -6349,13 +6366,13 @@ class Group extends Graphic {
6349
6366
  child.setStage(null, null);
6350
6367
  }), this.addUpdateBoundTag();
6351
6368
  }
6352
- setStage(stage, layer) {
6369
+ setStage(stage, layer, inheritedSharedStateScope) {
6353
6370
  var _a, _b, _c, _d, _e, _f;
6354
6371
  const graphicService = null !== (_c = null !== (_a = null == stage ? void 0 : stage.graphicService) && void 0 !== _a ? _a : null === (_b = this.stage) || void 0 === _b ? void 0 : _b.graphicService) && void 0 !== _c ? _c : application.graphicService,
6355
6372
  needsSharedStateTreeSync = this.hasSharedStateDefinitions() || this.sharedStateScope || (null === (_d = this.currentStates) || void 0 === _d ? void 0 : _d.length) || this.boundSharedStateScope || (null === (_e = this.registeredActiveScopes) || void 0 === _e ? void 0 : _e.size) || this.sharedStateDirty;
6356
- if (this.stage !== stage) return this.stage = stage, this.layer = layer, needsSharedStateTreeSync && (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0)), this.setStageToShadowRoot(stage, layer), this._onSetStage && this._onSetStage(this, stage, layer), null === (_f = null == graphicService ? void 0 : graphicService.onSetStage) || void 0 === _f || _f.call(graphicService, this, stage), void this.notifyChildrenSharedStateTreeChanged();
6373
+ if (this.stage !== stage) return this.stage = stage, this.layer = layer, needsSharedStateTreeSync && (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope)), this.setStageToShadowRoot(stage, layer), this._onSetStage && this._onSetStage(this, stage, layer), null === (_f = null == graphicService ? void 0 : graphicService.onSetStage) || void 0 === _f || _f.call(graphicService, this, stage), void this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope);
6357
6374
  const layerChanged = this.layer !== layer;
6358
- layerChanged && (this.layer = layer), needsSharedStateTreeSync ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0), this.notifyChildrenSharedStateTreeChanged()) : layerChanged && this.notifyChildrenSharedStateTreeChanged();
6375
+ layerChanged && (this.layer = layer), needsSharedStateTreeSync ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope), this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope)) : layerChanged && this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope);
6359
6376
  }
6360
6377
  addUpdatePositionTag() {
6361
6378
  super.addUpdatePositionTag(), this.forEachChildren(g => {
@@ -6414,17 +6431,26 @@ class Group extends Graphic {
6414
6431
  hasSharedStateDefinitions() {
6415
6432
  return !!this._sharedStateDefinitions && Object.keys(this._sharedStateDefinitions).length > 0;
6416
6433
  }
6417
- notifyChildrenSharedStateTreeChanged() {
6434
+ resolveChildSharedStateScope(inheritedSharedStateScope) {
6435
+ var _a;
6436
+ return this.sharedStateScope ? this.sharedStateScope : void 0 !== inheritedSharedStateScope ? inheritedSharedStateScope : null !== (_a = this.resolveBoundSharedStateScope()) && void 0 !== _a ? _a : null;
6437
+ }
6438
+ notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope) {
6439
+ const childSharedStateScope = this.resolveChildSharedStateScope(inheritedSharedStateScope);
6418
6440
  this.forEachChildren(item => {
6419
- this.syncChildSharedStateTreeBinding(item);
6441
+ this.setStageToChild(item, childSharedStateScope);
6420
6442
  });
6421
6443
  }
6422
- syncChildSharedStateTreeBinding(child) {
6423
- child.onParentSharedStateTreeChanged(this.stage, this.layer);
6444
+ setStageToChild(child, inheritedSharedStateScope) {
6445
+ const graphic = child;
6446
+ "function" != typeof graphic.setStage || child.onParentSharedStateTreeChanged !== Graphic.prototype.onParentSharedStateTreeChanged && child.onParentSharedStateTreeChanged !== Group.prototype.onParentSharedStateTreeChanged || graphic.stage === this.stage && graphic.layer === this.layer ? child.onParentSharedStateTreeChanged(this.stage, this.layer, inheritedSharedStateScope) : graphic.setStage(this.stage, this.layer, inheritedSharedStateScope);
6424
6447
  }
6425
- onParentSharedStateTreeChanged(stage, layer) {
6448
+ syncChildSharedStateTreeBinding(child, inheritedSharedStateScope) {
6449
+ void 0 === inheritedSharedStateScope && (inheritedSharedStateScope = this.resolveChildSharedStateScope()), this.setStageToChild(child, inheritedSharedStateScope);
6450
+ }
6451
+ onParentSharedStateTreeChanged(stage, layer, inheritedSharedStateScope) {
6426
6452
  var _a;
6427
- this.stage === stage && this.layer === layer ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!!(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length)), this.notifyChildrenSharedStateTreeChanged()) : this.setStage(stage, layer);
6453
+ this.stage === stage && this.layer === layer ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!!(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length), inheritedSharedStateScope), this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope)) : this.setStage(stage, layer, inheritedSharedStateScope);
6428
6454
  }
6429
6455
  }
6430
6456
  Group.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
@@ -8087,13 +8113,14 @@ function applyFillStyle(ctx, character, b) {
8087
8113
  }) : fillStyle, setTextStyle(ctx, character);
8088
8114
  }
8089
8115
  function applyStrokeStyle(ctx, character) {
8116
+ var _a, _b;
8090
8117
  const strokeStyle = character && character.stroke || defaultFormatting.stroke;
8091
8118
  if (!strokeStyle) return void (ctx.globalAlpha = 0);
8092
8119
  const {
8093
8120
  strokeOpacity = 1,
8094
8121
  opacity = 1
8095
8122
  } = character;
8096
- ctx.globalAlpha = strokeOpacity * opacity, ctx.lineWidth = character && "number" == typeof character.lineWidth ? character.lineWidth : 1, ctx.strokeStyle = strokeStyle, setTextStyle(ctx, character);
8123
+ ctx.globalAlpha = strokeOpacity * opacity, ctx.lineWidth = character && "number" == typeof character.lineWidth ? character.lineWidth : 1, ctx.setLineDash(null !== (_a = character.lineDash) && void 0 !== _a ? _a : []), ctx.lineDashOffset = null !== (_b = character.lineDashOffset) && void 0 !== _b ? _b : 0, ctx.strokeStyle = strokeStyle, setTextStyle(ctx, character);
8097
8124
  }
8098
8125
  function getStrByWithCanvas(desc, width, character, guessIndex, needTestLetter) {
8099
8126
  if (desc.length <= 1) return 0;
@@ -9026,8 +9053,8 @@ class RichText extends Graphic {
9026
9053
  clone() {
9027
9054
  return new RichText(Object.assign({}, this.attribute));
9028
9055
  }
9029
- setStage(stage, layer) {
9030
- super.setStage(stage, layer);
9056
+ setStage(stage, layer, inheritedSharedStateScope) {
9057
+ super.setStage(stage, layer, inheritedSharedStateScope);
9031
9058
  this.getFrameCache().icons.forEach(icon => {
9032
9059
  icon.setStage(stage, layer);
9033
9060
  });
@@ -30003,6 +30030,7 @@ class DiscreteLegend extends LegendBase {
30003
30030
  this._itemHeight = 0;
30004
30031
  this._itemMaxWidth = 0;
30005
30032
  this._contentMaxHeight = 0;
30033
+ this._stateDefinitionsCache = new WeakMap();
30006
30034
  this._onHover = (e) => {
30007
30035
  const target = e.target;
30008
30036
  if (target && target.name && target.name.startsWith(LEGEND_ELEMENT_NAME.item)) {
@@ -30089,6 +30117,7 @@ class DiscreteLegend extends LegendBase {
30089
30117
  };
30090
30118
  }
30091
30119
  render() {
30120
+ this._stateDefinitionsCache = new WeakMap();
30092
30121
  super.render();
30093
30122
  this._lastActiveItem = null;
30094
30123
  }
@@ -30367,7 +30396,7 @@ class DiscreteLegend extends LegendBase {
30367
30396
  }
30368
30397
  else {
30369
30398
  itemGroup = graphicCreator.group(Object.assign({ x: 0, y: 0 }, backgroundStyle.style));
30370
- this._appendDataToShape(itemGroup, LEGEND_ELEMENT_NAME.item, item, itemGroup, backgroundStyle.state);
30399
+ this._appendDataToShape(itemGroup, LEGEND_ELEMENT_NAME.item, item, itemGroup, backgroundStyle.state, backgroundStyle.reuseStateDefinitions);
30371
30400
  }
30372
30401
  itemGroup.id = `${id !== null && id !== void 0 ? id : label}-${index}`;
30373
30402
  itemGroup.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected);
@@ -30400,7 +30429,7 @@ class DiscreteLegend extends LegendBase {
30400
30429
  shapeStyle.state[key].stroke = color;
30401
30430
  }
30402
30431
  });
30403
- this._appendDataToShape(itemShape, LEGEND_ELEMENT_NAME.itemShape, item, itemGroup, shapeStyle.state);
30432
+ this._appendDataToShape(itemShape, LEGEND_ELEMENT_NAME.itemShape, item, itemGroup, shapeStyle.state, false);
30404
30433
  itemShape.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected);
30405
30434
  innerGroup.add(itemShape);
30406
30435
  }
@@ -30415,7 +30444,7 @@ class DiscreteLegend extends LegendBase {
30415
30444
  const text = labelAttr.formatMethod ? labelAttr.formatMethod(label, item, index) : label;
30416
30445
  const labelAttributes = Object.assign(Object.assign({ x: shapeSize / 2 + shapeSpace, y: 0, textAlign: 'start', textBaseline: 'middle', lineHeight: (_b = labelStyle.style) === null || _b === void 0 ? void 0 : _b.fontSize }, labelStyle.style), { text, _originText: labelAttr.formatMethod ? label : undefined });
30417
30446
  const labelShape = createTextGraphicByType(labelAttributes);
30418
- this._appendDataToShape(labelShape, LEGEND_ELEMENT_NAME.itemLabel, item, itemGroup, labelStyle.state);
30447
+ this._appendDataToShape(labelShape, LEGEND_ELEMENT_NAME.itemLabel, item, itemGroup, labelStyle.state, labelStyle.reuseStateDefinitions);
30419
30448
  labelShape.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected);
30420
30449
  innerGroup.add(labelShape);
30421
30450
  const labelSpace = get(labelAttr, 'space', DEFAULT_LABEL_SPACE);
@@ -30424,7 +30453,7 @@ class DiscreteLegend extends LegendBase {
30424
30453
  const valueText = valueAttr.formatMethod ? valueAttr.formatMethod(value, item, index) : value;
30425
30454
  const valueAttributes = Object.assign(Object.assign({ x: 0, y: 0, textAlign: 'start', textBaseline: 'middle', lineHeight: valueStyle.style.fontSize }, valueStyle.style), { text: valueText, _originText: valueAttr.formatMethod ? value : undefined });
30426
30455
  const valueShape = createTextGraphicByType(valueAttributes);
30427
- this._appendDataToShape(valueShape, LEGEND_ELEMENT_NAME.itemValue, item, itemGroup, valueStyle.state);
30456
+ this._appendDataToShape(valueShape, LEGEND_ELEMENT_NAME.itemValue, item, itemGroup, valueStyle.state, valueStyle.reuseStateDefinitions);
30428
30457
  valueShape.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected);
30429
30458
  if (this._itemWidthByUser) {
30430
30459
  const layoutWidth = this._itemWidthByUser -
@@ -30522,9 +30551,12 @@ class DiscreteLegend extends LegendBase {
30522
30551
  : new ScrollBar(Object.assign(Object.assign({ direction: 'vertical', width: compStyle.visible === false ? 0 : 12, range: [0, 0.5] }, compStyle), { height: compSize, disableTriggerEvent }));
30523
30552
  }
30524
30553
  _updatePositionOfPager(renderStartY, compWidth, compHeight) {
30554
+ var _a;
30525
30555
  const { pager } = this.attribute;
30526
30556
  const { totalPage, isHorizontal } = this._itemContext;
30527
30557
  const position = (pager && pager.position) || 'middle';
30558
+ const hugContent = !!(pager && pager.hugContent);
30559
+ const pagerSpace = (_a = (pager && pager.space)) !== null && _a !== void 0 ? _a : DEFAULT_PAGER_SPACE;
30528
30560
  this._pagerComponent.setTotal(totalPage);
30529
30561
  if (isHorizontal) {
30530
30562
  let y;
@@ -30537,8 +30569,12 @@ class DiscreteLegend extends LegendBase {
30537
30569
  else {
30538
30570
  y = renderStartY + compHeight / 2 - this._pagerComponent.AABBBounds.height() / 2;
30539
30571
  }
30572
+ let x = compWidth - this._pagerComponent.AABBBounds.width();
30573
+ if (hugContent) {
30574
+ x = Math.max(0, Math.min(this._itemsContainer.AABBBounds.width() + pagerSpace, x));
30575
+ }
30540
30576
  this._pagerComponent.setAttributes({
30541
- x: compWidth - this._pagerComponent.AABBBounds.width(),
30577
+ x,
30542
30578
  y
30543
30579
  });
30544
30580
  }
@@ -30553,9 +30589,13 @@ class DiscreteLegend extends LegendBase {
30553
30589
  else {
30554
30590
  x = (compWidth - this._pagerComponent.AABBBounds.width()) / 2;
30555
30591
  }
30592
+ let y = compHeight - this._pagerComponent.AABBBounds.height();
30593
+ if (hugContent) {
30594
+ y = Math.max(0, Math.min(renderStartY + this._itemsContainer.AABBBounds.height() + pagerSpace, y));
30595
+ }
30556
30596
  this._pagerComponent.setAttributes({
30557
30597
  x,
30558
- y: compHeight - this._pagerComponent.AABBBounds.height()
30598
+ y
30559
30599
  });
30560
30600
  }
30561
30601
  }
@@ -30771,11 +30811,22 @@ class DiscreteLegend extends LegendBase {
30771
30811
  itemsContainer.setAttribute('x', -(defaultCurrent - 1) * (compWidth + spaceCol));
30772
30812
  }
30773
30813
  }
30814
+ const hugContent = !!pager.hugContent;
30815
+ let clipWidth = isHorizontal ? contentWidth : compWidth;
30816
+ let clipHeight = isHorizontal ? compHeight : contentHeight;
30817
+ if (hugContent) {
30818
+ if (isHorizontal) {
30819
+ clipWidth = Math.max(0, Math.min(clipWidth, itemsContainer.AABBBounds.width()));
30820
+ }
30821
+ else {
30822
+ clipHeight = Math.max(0, Math.min(clipHeight, itemsContainer.AABBBounds.height()));
30823
+ }
30824
+ }
30774
30825
  const clipGroup = graphicCreator.group({
30775
30826
  x: 0,
30776
30827
  y: renderStartY,
30777
- width: isHorizontal ? contentWidth : compWidth,
30778
- height: isHorizontal ? compHeight : contentHeight,
30828
+ width: clipWidth,
30829
+ height: clipHeight,
30779
30830
  clip: true,
30780
30831
  pickable: false
30781
30832
  });
@@ -31054,11 +31105,29 @@ class DiscreteLegend extends LegendBase {
31054
31105
  });
31055
31106
  return selectedData;
31056
31107
  }
31057
- _appendDataToShape(shape, name, data, delegateShape, states = {}) {
31108
+ _appendDataToShape(shape, name, data, delegateShape, states, reuseStateDefinitions = true) {
31058
31109
  shape.name = name;
31059
31110
  shape.data = data;
31060
31111
  shape.delegate = delegateShape;
31061
- shape.states = merge({}, DEFAULT_STATES, states);
31112
+ if (!reuseStateDefinitions) {
31113
+ shape.states = merge({}, DEFAULT_STATES, states);
31114
+ return;
31115
+ }
31116
+ const source = states !== null && states !== void 0 ? states : DEFAULT_STATES;
31117
+ const cached = this._stateDefinitionsCache.get(source);
31118
+ if (cached) {
31119
+ shape.states = cached.definitions;
31120
+ shape.setStateDefinitionsWithCompiled(cached.definitions, cached.compiledDefinitions);
31121
+ return;
31122
+ }
31123
+ const definitions = states ? merge({}, DEFAULT_STATES, states) : DEFAULT_STATES;
31124
+ const entry = {
31125
+ definitions,
31126
+ compiledDefinitions: new StateDefinitionCompiler().compile(definitions)
31127
+ };
31128
+ this._stateDefinitionsCache.set(source, entry);
31129
+ shape.states = entry.definitions;
31130
+ shape.setStateDefinitionsWithCompiled(entry.definitions, entry.compiledDefinitions);
31062
31131
  }
31063
31132
  _dispatchLegendEvent(eventName, legendItem, event) {
31064
31133
  const currentSelectedItems = this._getSelectedLegends();
@@ -31084,21 +31153,27 @@ class DiscreteLegend extends LegendBase {
31084
31153
  }
31085
31154
  }
31086
31155
  if (config.state) {
31087
- newConfig.state = {};
31088
- Object.keys(config.state).forEach(key => {
31089
- if (config.state[key]) {
31090
- if (isFunction(config.state[key])) {
31091
- newConfig.state[key] = config.state[key](item, isSelected, index, items);
31092
- }
31093
- else {
31094
- newConfig.state[key] = config.state[key];
31156
+ const stateKeys = Object.keys(config.state);
31157
+ const hasStateFunction = stateKeys.some(key => isFunction(config.state[key]));
31158
+ newConfig.reuseStateDefinitions = !hasStateFunction;
31159
+ if (!hasStateFunction) {
31160
+ newConfig.state = config.state;
31161
+ }
31162
+ else {
31163
+ newConfig.state = {};
31164
+ stateKeys.forEach(key => {
31165
+ if (config.state[key]) {
31166
+ newConfig.state[key] = isFunction(config.state[key])
31167
+ ? config.state[key](item, isSelected, index, items)
31168
+ : config.state[key];
31095
31169
  }
31096
- }
31097
- });
31170
+ });
31171
+ }
31098
31172
  }
31099
31173
  return newConfig;
31100
31174
  }
31101
31175
  release() {
31176
+ this._stateDefinitionsCache = new WeakMap();
31102
31177
  super.release();
31103
31178
  this.removeAllEventListeners();
31104
31179
  }
@@ -36601,6 +36676,6 @@ TableSeriesNumber.defaultAttributes = {
36601
36676
  select: true
36602
36677
  };
36603
36678
 
36604
- const version = "1.1.4";
36679
+ const version = "1.1.6-alpha.0";
36605
36680
 
36606
36681
  export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GroupTransition, IDataZoomEvent, IDataZoomInteractiveEvent, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PolygonSectorCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SeriesNumberCellStateValue, SeriesNumberEvent, SizeContinuousLegend, Slider, StoryLabelItem, Switch, SymbolLabel, TableSeriesNumber, Tag, Timeline, Title, Tooltip, TopZIndex, VTag, WeatherBox, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, cartesianTicks, clampRadian, computeOffsetForlimit, continuousTicks, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, fuzzyEqualNumber, getAxisBreakSymbolAttrs, getCircleLabelPosition, getCirclePoints, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getPolygonPath, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, hasOverlap, htmlAttributeTransform, initTextMeasure, installPoptipToApp, installScrollbarToApp, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, limitShapeInBounds, linearDiscreteTicks, loadPoptip, loadScrollbar, measureTextSize, normalize, polarAngleAxisDiscreteTicks, polarTicks, reactAttributeTransform, registerArcDataLabel, registerLineDataLabel, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, registerRectDataLabel, registerSymbolDataLabel, removeRepeatPoint, richTextAttributeTransform, scale, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, textIntersect, ticks, traverseGroup, version };
package/es/axis/util.js CHANGED
@@ -98,5 +98,4 @@ export function hasOverlap(items, pad) {
98
98
  for (let b, i = 1, n = items.length, a = items[0]; i < n; a = b, ++i) if (b = items[i],
99
99
  textIntersect(a, b, pad)) return !0;
100
100
  return !1;
101
- }
102
- //# sourceMappingURL=util.js.map
101
+ }
@@ -1 +1,2 @@
1
- export { };
1
+ export { };
2
+ //# sourceMappingURL=type.js.map
package/es/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const version = "1.1.4";
1
+ export declare const version = "1.1.6-alpha.0";
2
2
  export * from './core/base';
3
3
  export { AbstractComponent } from './core/base';
4
4
  export * from './core/type';
package/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const version = "1.1.4";
1
+ export const version = "1.1.6-alpha.0";
2
2
 
3
3
  export * from "./core/base";
4
4
 
package/es/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],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c,QAAQ,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"1.1.4\";\n\nexport * from './core/base';\nexport { AbstractComponent } from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport { ScrollBar } from './scrollbar/scrollbar';\nexport { loadScrollbar } from './scrollbar/module';\nexport * from './tag';\nexport * from './poptip';\nexport { loadPoptip } from './poptip/module';\nexport * from './crosshair';\nexport { LineCrosshair } from './crosshair/line';\nexport { CircleCrosshair } from './crosshair/circle';\nexport { SectorCrosshair } from './crosshair/sector';\nexport { PolygonCrosshair } from './crosshair/polygon';\nexport * from './label';\nexport { DataLabel } from './label/dataLabel';\nexport { registerSymbolDataLabel } from './label/symbol';\nexport * from './axis';\nexport { LineAxis } from './axis/line';\nexport { CircleAxis } from './axis/circle';\nexport { continuousTicks } from './axis/tick-data/continuous';\nexport { polarAngleAxisDiscreteTicks } from './axis/tick-data/discrete/polar-angle';\nexport * from './axis/grid';\nexport { LineAxisGrid } from './axis/grid/line';\nexport { CircleAxisGrid } from './axis/grid/circle';\nexport * from './segment';\nexport { Segment } from './segment/segment';\nexport * from './data-zoom';\nexport { DataZoom } from './data-zoom/data-zoom';\nexport * from './marker';\nexport { MarkLine, registerMarkLineAnimate } from './marker/line';\nexport { MarkArea, registerMarkAreaAnimate } from './marker/area';\nexport { MarkArcLine, registerMarkArcLineAnimate } from './marker/arc-line';\nexport { MarkArcArea, registerMarkArcAreaAnimate } from './marker/arc-area';\nexport { MarkPoint, registerMarkPointAnimate } from './marker/point';\nexport * from './pager';\nexport * from './legend';\nexport { ColorContinuousLegend } from './legend/color/color';\nexport { SizeContinuousLegend } from './legend/size/size';\nexport * from './title';\nexport { Title } from './title/title';\nexport * from './indicator';\nexport { Indicator } from './indicator/indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport { DiscretePlayer } from './player/discrete-player';\nexport { ContinuousPlayer } from './player/continuous-player';\nexport { PlayerEventEnum } from './player/type/event';\nexport * from './brush';\nexport { Brush } from './brush/brush';\nexport { IOperateType } from './brush/type';\nexport * from './tooltip';\nexport * from './timeline';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './radio';\nexport * from './empty-tip';\nexport * from './weather';\nexport * from './util';\nexport { labelSmartInvert } from './util/label-smartInvert';\nexport * from './switch';\nexport * from './label-item';\nexport * from './table-series-number';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC;AAEvC,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,UA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BAA4B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"1.1.6-alpha.0\";\n\nexport * from './core/base';\nexport { AbstractComponent } from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport { ScrollBar } from './scrollbar/scrollbar';\nexport { loadScrollbar } from './scrollbar/module';\nexport * from './tag';\nexport * from './poptip';\nexport { loadPoptip } from './poptip/module';\nexport * from './crosshair';\nexport { LineCrosshair } from './crosshair/line';\nexport { CircleCrosshair } from './crosshair/circle';\nexport { SectorCrosshair } from './crosshair/sector';\nexport { PolygonCrosshair } from './crosshair/polygon';\nexport * from './label';\nexport { DataLabel } from './label/dataLabel';\nexport { registerSymbolDataLabel } from './label/symbol';\nexport * from './axis';\nexport { LineAxis } from './axis/line';\nexport { CircleAxis } from './axis/circle';\nexport { continuousTicks } from './axis/tick-data/continuous';\nexport { polarAngleAxisDiscreteTicks } from './axis/tick-data/discrete/polar-angle';\nexport * from './axis/grid';\nexport { LineAxisGrid } from './axis/grid/line';\nexport { CircleAxisGrid } from './axis/grid/circle';\nexport * from './segment';\nexport { Segment } from './segment/segment';\nexport * from './data-zoom';\nexport { DataZoom } from './data-zoom/data-zoom';\nexport * from './marker';\nexport { MarkLine, registerMarkLineAnimate } from './marker/line';\nexport { MarkArea, registerMarkAreaAnimate } from './marker/area';\nexport { MarkArcLine, registerMarkArcLineAnimate } from './marker/arc-line';\nexport { MarkArcArea, registerMarkArcAreaAnimate } from './marker/arc-area';\nexport { MarkPoint, registerMarkPointAnimate } from './marker/point';\nexport * from './pager';\nexport * from './legend';\nexport { ColorContinuousLegend } from './legend/color/color';\nexport { SizeContinuousLegend } from './legend/size/size';\nexport * from './title';\nexport { Title } from './title/title';\nexport * from './indicator';\nexport { Indicator } from './indicator/indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport { DiscretePlayer } from './player/discrete-player';\nexport { ContinuousPlayer } from './player/continuous-player';\nexport { PlayerEventEnum } from './player/type/event';\nexport * from './brush';\nexport { Brush } from './brush/brush';\nexport { IOperateType } from './brush/type';\nexport * from './tooltip';\nexport * from './timeline';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './radio';\nexport * from './empty-tip';\nexport * from './weather';\nexport * from './util';\nexport { labelSmartInvert } from './util/label-smartInvert';\nexport * from './switch';\nexport * from './label-item';\nexport * from './table-series-number';\n"]}
@@ -1,2 +1,2 @@
1
1
  export { };
2
- //# sourceMappingURL=type.js.map
2
+ //# sourceMappingURL=type.js.map
package/es/jsx/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export * from "./component-type";
2
- //# sourceMappingURL=index.js.map
2
+ //# sourceMappingURL=index.js.map
@@ -15,6 +15,7 @@ export declare class DiscreteLegend extends LegendBase<DiscreteLegendAttrs> {
15
15
  private _itemContext;
16
16
  private _scrollMask;
17
17
  private _scrollMaskContext;
18
+ private _stateDefinitionsCache;
18
19
  static defaultAttributes: Partial<DiscreteLegendAttrs>;
19
20
  constructor(attributes: DiscreteLegendAttrs, options?: ComponentOptions);
20
21
  render(): void;
@@ -10,6 +10,8 @@ var __rest = this && this.__rest || function(s, e) {
10
10
 
11
11
  import { merge, isEmpty, normalizePadding, get, isValid, isNil, isFunction, isArray, minInArray, throttle, isNumberClose, clamp, isObject } from "@visactor/vutils";
12
12
 
13
+ import { StateDefinitionCompiler } from "@visactor/vrender-core";
14
+
13
15
  import { graphicCreator } from "../../util/graphic-creator";
14
16
 
15
17
  import { LegendBase } from "../base";
@@ -40,7 +42,8 @@ export class DiscreteLegend extends LegendBase {
40
42
  constructor(attributes, options) {
41
43
  super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, DiscreteLegend.defaultAttributes, attributes)),
42
44
  this.name = "discreteLegend", this._itemsContainer = null, this._itemHeightByUser = void 0,
43
- this._itemHeight = 0, this._itemMaxWidth = 0, this._contentMaxHeight = 0, this._onHover = e => {
45
+ this._itemHeight = 0, this._itemMaxWidth = 0, this._contentMaxHeight = 0, this._stateDefinitionsCache = new WeakMap,
46
+ this._onHover = e => {
44
47
  const target = e.target;
45
48
  if (target && target.name && target.name.startsWith(LEGEND_ELEMENT_NAME.item)) {
46
49
  const legendItem = target.delegate;
@@ -88,7 +91,7 @@ export class DiscreteLegend extends LegendBase {
88
91
  };
89
92
  }
90
93
  render() {
91
- super.render(), this._lastActiveItem = null;
94
+ this._stateDefinitionsCache = new WeakMap, super.render(), this._lastActiveItem = null;
92
95
  }
93
96
  setSelected(selectedData) {
94
97
  var _a;
@@ -206,7 +209,7 @@ export class DiscreteLegend extends LegendBase {
206
209
  }), this._appendDataToShape(itemGroup, LEGEND_ELEMENT_NAME.item, item, itemGroup)) : (itemGroup = graphicCreator.group(Object.assign({
207
210
  x: 0,
208
211
  y: 0
209
- }, backgroundStyle.style)), this._appendDataToShape(itemGroup, LEGEND_ELEMENT_NAME.item, item, itemGroup, backgroundStyle.state)),
212
+ }, backgroundStyle.style)), this._appendDataToShape(itemGroup, LEGEND_ELEMENT_NAME.item, item, itemGroup, backgroundStyle.state, backgroundStyle.reuseStateDefinitions)),
210
213
  itemGroup.id = `${null != id ? id : label}-${index}`, itemGroup.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected);
211
214
  const innerGroup = graphicCreator.group({
212
215
  x: 0,
@@ -228,7 +231,7 @@ export class DiscreteLegend extends LegendBase {
228
231
  const color = shapeStyle.state[key].fill || shapeStyle.state[key].stroke;
229
232
  shape.fill && isNil(shapeStyle.state[key].fill) && color && (shapeStyle.state[key].fill = color),
230
233
  shape.stroke && isNil(shapeStyle.state[key].stroke) && color && (shapeStyle.state[key].stroke = color);
231
- })), this._appendDataToShape(itemShape, LEGEND_ELEMENT_NAME.itemShape, item, itemGroup, shapeStyle.state),
234
+ })), this._appendDataToShape(itemShape, LEGEND_ELEMENT_NAME.itemShape, item, itemGroup, shapeStyle.state, !1),
232
235
  itemShape.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected),
233
236
  innerGroup.add(itemShape);
234
237
  }
@@ -256,7 +259,7 @@ export class DiscreteLegend extends LegendBase {
256
259
  text: text,
257
260
  _originText: labelAttr.formatMethod ? label : void 0
258
261
  }), labelShape = createTextGraphicByType(labelAttributes);
259
- this._appendDataToShape(labelShape, LEGEND_ELEMENT_NAME.itemLabel, item, itemGroup, labelStyle.state),
262
+ this._appendDataToShape(labelShape, LEGEND_ELEMENT_NAME.itemLabel, item, itemGroup, labelStyle.state, labelStyle.reuseStateDefinitions),
260
263
  labelShape.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected),
261
264
  innerGroup.add(labelShape);
262
265
  const labelSpace = get(labelAttr, "space", DEFAULT_LABEL_SPACE);
@@ -271,7 +274,7 @@ export class DiscreteLegend extends LegendBase {
271
274
  text: valueText,
272
275
  _originText: valueAttr.formatMethod ? value : void 0
273
276
  }), valueShape = createTextGraphicByType(valueAttributes);
274
- if (this._appendDataToShape(valueShape, LEGEND_ELEMENT_NAME.itemValue, item, itemGroup, valueStyle.state),
277
+ if (this._appendDataToShape(valueShape, LEGEND_ELEMENT_NAME.itemValue, item, itemGroup, valueStyle.state, valueStyle.reuseStateDefinitions),
275
278
  valueShape.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected),
276
279
  this._itemWidthByUser) {
277
280
  const layoutWidth = this._itemWidthByUser - parsedPadding[1] - parsedPadding[3] - shapeSize - shapeSpace - labelSpace - focusSpace - valueSpace;
@@ -342,20 +345,25 @@ export class DiscreteLegend extends LegendBase {
342
345
  }));
343
346
  }
344
347
  _updatePositionOfPager(renderStartY, compWidth, compHeight) {
345
- const {pager: pager} = this.attribute, {totalPage: totalPage, isHorizontal: isHorizontal} = this._itemContext, position = pager && pager.position || "middle";
348
+ var _a;
349
+ const {pager: pager} = this.attribute, {totalPage: totalPage, isHorizontal: isHorizontal} = this._itemContext, position = pager && pager.position || "middle", hugContent = !(!pager || !pager.hugContent), pagerSpace = null !== (_a = pager && pager.space) && void 0 !== _a ? _a : DEFAULT_PAGER_SPACE;
346
350
  if (this._pagerComponent.setTotal(totalPage), isHorizontal) {
347
351
  let y;
348
- y = "start" === position ? renderStartY : "end" === position ? renderStartY + compHeight - this._pagerComponent.AABBBounds.height() / 2 : renderStartY + compHeight / 2 - this._pagerComponent.AABBBounds.height() / 2,
352
+ y = "start" === position ? renderStartY : "end" === position ? renderStartY + compHeight - this._pagerComponent.AABBBounds.height() / 2 : renderStartY + compHeight / 2 - this._pagerComponent.AABBBounds.height() / 2;
353
+ let x = compWidth - this._pagerComponent.AABBBounds.width();
354
+ hugContent && (x = Math.max(0, Math.min(this._itemsContainer.AABBBounds.width() + pagerSpace, x))),
349
355
  this._pagerComponent.setAttributes({
350
- x: compWidth - this._pagerComponent.AABBBounds.width(),
356
+ x: x,
351
357
  y: y
352
358
  });
353
359
  } else {
354
360
  let x;
355
- x = "start" === position ? 0 : "end" === position ? compWidth - this._pagerComponent.AABBBounds.width() : (compWidth - this._pagerComponent.AABBBounds.width()) / 2,
361
+ x = "start" === position ? 0 : "end" === position ? compWidth - this._pagerComponent.AABBBounds.width() : (compWidth - this._pagerComponent.AABBBounds.width()) / 2;
362
+ let y = compHeight - this._pagerComponent.AABBBounds.height();
363
+ hugContent && (y = Math.max(0, Math.min(renderStartY + this._itemsContainer.AABBBounds.height() + pagerSpace, y))),
356
364
  this._pagerComponent.setAttributes({
357
365
  x: x,
358
- y: compHeight - this._pagerComponent.AABBBounds.height()
366
+ y: y
359
367
  });
360
368
  }
361
369
  }
@@ -459,11 +467,14 @@ export class DiscreteLegend extends LegendBase {
459
467
  this._itemContext.totalPage = total, this._updatePositionOfPager(renderStartY, compWidth, compHeight);
460
468
  }
461
469
  defaultCurrent > 1 && (isHorizontal ? itemsContainer.setAttribute("y", -(defaultCurrent - 1) * (compHeight + spaceRow)) : itemsContainer.setAttribute("x", -(defaultCurrent - 1) * (compWidth + spaceCol)));
470
+ const hugContent = !!pager.hugContent;
471
+ let clipWidth = isHorizontal ? contentWidth : compWidth, clipHeight = isHorizontal ? compHeight : contentHeight;
472
+ hugContent && (isHorizontal ? clipWidth = Math.max(0, Math.min(clipWidth, itemsContainer.AABBBounds.width())) : clipHeight = Math.max(0, Math.min(clipHeight, itemsContainer.AABBBounds.height())));
462
473
  const clipGroup = graphicCreator.group({
463
474
  x: 0,
464
475
  y: renderStartY,
465
- width: isHorizontal ? contentWidth : compWidth,
466
- height: isHorizontal ? compHeight : contentHeight,
476
+ width: clipWidth,
477
+ height: clipHeight,
467
478
  clip: !0,
468
479
  pickable: !1
469
480
  });
@@ -606,8 +617,16 @@ export class DiscreteLegend extends LegendBase {
606
617
  item.hasState(LegendStateValue.selected) && selectedData.push(item.data);
607
618
  })), selectedData;
608
619
  }
609
- _appendDataToShape(shape, name, data, delegateShape, states = {}) {
610
- shape.name = name, shape.data = data, shape.delegate = delegateShape, shape.states = merge({}, DEFAULT_STATES, states);
620
+ _appendDataToShape(shape, name, data, delegateShape, states, reuseStateDefinitions = !0) {
621
+ if (shape.name = name, shape.data = data, shape.delegate = delegateShape, !reuseStateDefinitions) return void (shape.states = merge({}, DEFAULT_STATES, states));
622
+ const source = null != states ? states : DEFAULT_STATES, cached = this._stateDefinitionsCache.get(source);
623
+ if (cached) return shape.states = cached.definitions, void shape.setStateDefinitionsWithCompiled(cached.definitions, cached.compiledDefinitions);
624
+ const definitions = states ? merge({}, DEFAULT_STATES, states) : DEFAULT_STATES, entry = {
625
+ definitions: definitions,
626
+ compiledDefinitions: (new StateDefinitionCompiler).compile(definitions)
627
+ };
628
+ this._stateDefinitionsCache.set(source, entry), shape.states = entry.definitions,
629
+ shape.setStateDefinitionsWithCompiled(entry.definitions, entry.compiledDefinitions);
611
630
  }
612
631
  _dispatchLegendEvent(eventName, legendItem, event) {
613
632
  const currentSelectedItems = this._getSelectedLegends();
@@ -624,13 +643,18 @@ export class DiscreteLegend extends LegendBase {
624
643
  }
625
644
  _handleStyle(config, item, isSelected, index, items) {
626
645
  const newConfig = {};
627
- return config.style && (isFunction(config.style) ? newConfig.style = config.style(item, isSelected, index, items) : newConfig.style = config.style),
628
- config.state && (newConfig.state = {}, Object.keys(config.state).forEach((key => {
629
- config.state[key] && (isFunction(config.state[key]) ? newConfig.state[key] = config.state[key](item, isSelected, index, items) : newConfig.state[key] = config.state[key]);
630
- }))), newConfig;
646
+ if (config.style && (isFunction(config.style) ? newConfig.style = config.style(item, isSelected, index, items) : newConfig.style = config.style),
647
+ config.state) {
648
+ const stateKeys = Object.keys(config.state), hasStateFunction = stateKeys.some((key => isFunction(config.state[key])));
649
+ newConfig.reuseStateDefinitions = !hasStateFunction, hasStateFunction ? (newConfig.state = {},
650
+ stateKeys.forEach((key => {
651
+ config.state[key] && (newConfig.state[key] = isFunction(config.state[key]) ? config.state[key](item, isSelected, index, items) : config.state[key]);
652
+ }))) : newConfig.state = config.state;
653
+ }
654
+ return newConfig;
631
655
  }
632
656
  release() {
633
- super.release(), this.removeAllEventListeners();
657
+ this._stateDefinitionsCache = new WeakMap, super.release(), this.removeAllEventListeners();
634
658
  }
635
659
  }
636
660