@visactor/vrender 1.1.4-alpha.1 → 1.1.4-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
@@ -2728,7 +2728,7 @@
2728
2728
  constructor() {
2729
2729
  super(), this._uid = Generator.GenAutoIncrementId(), this._firstChild = null, this._lastChild = null, this.parent = null, this._count = 1;
2730
2730
  }
2731
- onParentSharedStateTreeChanged(_stage, _layer) {}
2731
+ onParentSharedStateTreeChanged(_stage, _layer, _inheritedSharedStateScope) {}
2732
2732
  forEachChildren(cb, reverse = !1) {
2733
2733
  if (reverse) {
2734
2734
  let child = this._lastChild,
@@ -8038,6 +8038,8 @@
8038
8038
  this.graphic === graphic && this.baseAttributes === baseAttributes || this.invalidateResolverCache(), this.graphic = graphic, this.baseAttributes = baseAttributes;
8039
8039
  }
8040
8040
  applyStates(stateNames) {
8041
+ const singleStaticStateResult = this.tryApplySingleStaticState(stateNames);
8042
+ if (singleStaticStateResult) return singleStaticStateResult;
8041
8043
  const uniqueStates = Array.from(new Set(stateNames)),
8042
8044
  sortedStates = this.sortStates(uniqueStates),
8043
8045
  adjudicated = this.adjudicate(sortedStates),
@@ -8052,6 +8054,19 @@
8052
8054
  suppressed: [...this._suppressed]
8053
8055
  };
8054
8056
  }
8057
+ tryApplySingleStaticState(stateNames) {
8058
+ if (1 !== stateNames.length || "shallow" !== this.mergeMode) return;
8059
+ const stateName = stateNames[0],
8060
+ definition = this.compiledDefinitions.get(stateName);
8061
+ if (definition && (definition.hasResolver || definition.exclude.size || definition.suppress.size)) return;
8062
+ const changed = 1 !== this._activeStates.length || this._activeStates[0] !== stateName || 1 !== this._effectiveStates.length || this._effectiveStates[0] !== stateName || 0 !== this._suppressed.length;
8063
+ return this._activeStates = [stateName], this._effectiveStates = [stateName], this._suppressed = [], !changed && this.resolverCacheValid || (this.resolverPatchCache.clear(), this.resolverCacheKey = stateName, this.resolverCacheValid = !0, this._resolvedPatch = (null == definition ? void 0 : definition.patch) ? cloneValue(definition.patch) : {}), {
8064
+ changed: changed,
8065
+ activeStates: [...this._activeStates],
8066
+ effectiveStates: [...this._effectiveStates],
8067
+ suppressed: []
8068
+ };
8069
+ }
8055
8070
  addState(stateName, keepCurrentStates) {
8056
8071
  if (this._activeStates.includes(stateName) && (keepCurrentStates || 1 === this._activeStates.length)) return {
8057
8072
  changed: !1,
@@ -8487,14 +8502,17 @@
8487
8502
  }
8488
8503
  return null === (_a = this.stage) || void 0 === _a ? void 0 : _a.rootSharedStateScope;
8489
8504
  }
8490
- syncSharedStateScopeBindingFromTree(markDirty = !0) {
8505
+ syncSharedStateScopeBinding(nextScope, markDirty = !0) {
8491
8506
  var _a;
8492
- const nextScope = this.resolveBoundSharedStateScope();
8493
8507
  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);
8494
8508
  }
8495
- syncSharedStateScopeBindingOnTreeChange(markDirty = !0) {
8509
+ syncSharedStateScopeBindingFromTree(markDirty = !0, inheritedSharedStateScope) {
8510
+ const nextScope = void 0 === inheritedSharedStateScope ? this.resolveBoundSharedStateScope() : null != inheritedSharedStateScope ? inheritedSharedStateScope : void 0;
8511
+ return this.syncSharedStateScopeBinding(nextScope, markDirty);
8512
+ }
8513
+ syncSharedStateScopeBindingOnTreeChange(markDirty = !0, inheritedSharedStateScope) {
8496
8514
  var _a, _b;
8497
- 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);
8515
+ 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);
8498
8516
  }
8499
8517
  syncSharedStateActiveRegistrations() {
8500
8518
  var _a;
@@ -8502,6 +8520,7 @@
8502
8520
  if (!(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || !this.boundSharedStateScope) return (null == previousScopes ? void 0 : previousScopes.size) && (previousScopes.forEach(scope => {
8503
8521
  scope.subtreeActiveDescendants.delete(this);
8504
8522
  }), previousScopes.clear()), void (this.registeredActiveScopes = void 0);
8523
+ if ((null == previousScopes ? void 0 : previousScopes.size) && this.isSharedStateScopeChainRegistered(previousScopes)) return;
8505
8524
  const nextScopes = new Set(collectSharedStateScopeChain(this.boundSharedStateScope));
8506
8525
  null == previousScopes || previousScopes.forEach(scope => {
8507
8526
  nextScopes.has(scope) || scope.subtreeActiveDescendants.delete(this);
@@ -8509,6 +8528,15 @@
8509
8528
  scope.subtreeActiveDescendants.add(this);
8510
8529
  }), this.registeredActiveScopes = nextScopes;
8511
8530
  }
8531
+ isSharedStateScopeChainRegistered(previousScopes) {
8532
+ let scope = this.boundSharedStateScope,
8533
+ scopeCount = 0;
8534
+ for (; scope;) {
8535
+ if (!previousScopes.has(scope)) return !1;
8536
+ scopeCount += 1, scope = scope.parentScope;
8537
+ }
8538
+ return scopeCount === previousScopes.size;
8539
+ }
8512
8540
  clearSharedStateActiveRegistrations() {
8513
8541
  const previousScopes = this.registeredActiveScopes;
8514
8542
  previousScopes && (previousScopes.forEach(scope => {
@@ -8518,8 +8546,8 @@
8518
8546
  markSharedStateDirty() {
8519
8547
  this.sharedStateDirty = !0, enqueueGraphicSharedStateRefresh(this.stage, this), scheduleStageSharedStateRefresh(this.stage);
8520
8548
  }
8521
- onParentSharedStateTreeChanged(stage, layer) {
8522
- this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange() : this.setStage(stage, layer);
8549
+ onParentSharedStateTreeChanged(stage, layer, inheritedSharedStateScope) {
8550
+ this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope) : this.setStage(stage, layer, inheritedSharedStateScope);
8523
8551
  }
8524
8552
  refreshSharedStateBeforeRender() {
8525
8553
  var _a;
@@ -9170,6 +9198,10 @@
9170
9198
  var _a;
9171
9199
  return null === (_a = this.states) || void 0 === _a ? void 0 : _a[stateName];
9172
9200
  }
9201
+ setStateDefinitionsWithCompiled(definitions, compiledDefinitions) {
9202
+ var _a;
9203
+ 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}`;
9204
+ }
9173
9205
  getStateResolveBaseAttrs() {
9174
9206
  var _a;
9175
9207
  return null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute;
@@ -9363,8 +9395,10 @@
9363
9395
  transition.changed && this.useStates(transition.states, hasAnimation);
9364
9396
  }
9365
9397
  addState(stateName, keepCurrentStates, hasAnimation) {
9366
- const transition = this.resolveAddStateTransition(stateName, keepCurrentStates);
9367
- transition.changed && this.useStates(transition.states, hasAnimation);
9398
+ const currentStates = this.currentStates;
9399
+ if ((null == currentStates ? void 0 : currentStates.includes(stateName)) && (keepCurrentStates || 1 === currentStates.length)) return;
9400
+ const nextStates = keepCurrentStates && (null == currentStates ? void 0 : currentStates.length) ? currentStates.concat([stateName]) : [stateName];
9401
+ this.useStates(nextStates, hasAnimation);
9368
9402
  }
9369
9403
  setStates(states, options) {
9370
9404
  var _a, _b, _c;
@@ -9517,12 +9551,12 @@
9517
9551
  this._globalTransMatrix.translate(scrollX, scrollY);
9518
9552
  }
9519
9553
  }
9520
- setStage(stage, layer) {
9554
+ setStage(stage, layer, inheritedSharedStateScope) {
9521
9555
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
9522
9556
  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,
9523
9557
  previousStage = this.stage;
9524
9558
  if (this.stage !== stage || this.layer !== layer) {
9525
- 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()) {
9559
+ 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()) {
9526
9560
  const previousTimeline = null === (_f = null == previousStage ? void 0 : previousStage.getTimeline) || void 0 === _f ? void 0 : _f.call(previousStage),
9527
9561
  nextTimeline = null === (_g = null == stage ? void 0 : stage.getTimeline) || void 0 === _g ? void 0 : _g.call(stage),
9528
9562
  detachedStageAnimates = [];
@@ -9539,7 +9573,7 @@
9539
9573
  }
9540
9574
  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));
9541
9575
  }
9542
- ((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);
9576
+ ((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);
9543
9577
  }
9544
9578
  detachStageForRelease() {
9545
9579
  var _a, _b, _c;
@@ -11163,13 +11197,14 @@
11163
11197
  }) : fillStyle, setTextStyle(ctx, character);
11164
11198
  }
11165
11199
  function applyStrokeStyle(ctx, character) {
11200
+ var _a, _b;
11166
11201
  const strokeStyle = character && character.stroke || defaultFormatting.stroke;
11167
11202
  if (!strokeStyle) return void (ctx.globalAlpha = 0);
11168
11203
  const {
11169
11204
  strokeOpacity = 1,
11170
11205
  opacity = 1
11171
11206
  } = character;
11172
- ctx.globalAlpha = strokeOpacity * opacity, ctx.lineWidth = character && "number" == typeof character.lineWidth ? character.lineWidth : 1, ctx.strokeStyle = strokeStyle, setTextStyle(ctx, character);
11207
+ 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);
11173
11208
  }
11174
11209
  function getStrByWithCanvas(desc, width, character, guessIndex, needTestLetter) {
11175
11210
  if (desc.length <= 1) return 0;
@@ -12112,8 +12147,8 @@
12112
12147
  clone() {
12113
12148
  return new RichText(Object.assign({}, this.attribute));
12114
12149
  }
12115
- setStage(stage, layer) {
12116
- super.setStage(stage, layer);
12150
+ setStage(stage, layer, inheritedSharedStateScope) {
12151
+ super.setStage(stage, layer, inheritedSharedStateScope);
12117
12152
  this.getFrameCache().icons.forEach(icon => {
12118
12153
  icon.setStage(stage, layer);
12119
12154
  });
@@ -12784,17 +12819,17 @@
12784
12819
  }
12785
12820
  incrementalAppendChild(node) {
12786
12821
  const data = super.appendChild(node);
12787
- return data && this.syncChildSharedStateTreeBinding(data), this.addUpdateBoundTag(), this.getGraphicService().onAddIncremental(node, this, this.stage), data;
12822
+ return data && this.shouldSyncChildSharedStateTreeBinding(data) && this.syncChildSharedStateTreeBinding(data), this.addUpdateBoundTag(), this.getGraphicService().onAddIncremental(node, this, this.stage), data;
12788
12823
  }
12789
12824
  incrementalClearChild() {
12790
12825
  super.removeAllChild(), this.addUpdateBoundTag(), this.getGraphicService().onClearIncremental(this, this.stage);
12791
12826
  }
12792
12827
  _updateChildToStage(child) {
12793
- return child && this.syncChildSharedStateTreeBinding(child), this.addUpdateBoundTag(), child;
12828
+ return child && this.shouldSyncChildSharedStateTreeBinding(child) && this.syncChildSharedStateTreeBinding(child), this.addUpdateBoundTag(), child;
12794
12829
  }
12795
12830
  appendChild(node, addStage = !0) {
12796
12831
  const data = super.appendChild(node);
12797
- return data && addStage && this.syncChildSharedStateTreeBinding(data), this.addUpdateBoundTag(), data;
12832
+ return data && addStage && this.shouldSyncChildSharedStateTreeBinding(data) && this.syncChildSharedStateTreeBinding(data), this.addUpdateBoundTag(), data;
12798
12833
  }
12799
12834
  insertBefore(newNode, referenceNode) {
12800
12835
  return this._updateChildToStage(super.insertBefore(newNode, referenceNode));
@@ -12817,13 +12852,13 @@
12817
12852
  child.setStage(null, null);
12818
12853
  }), this.addUpdateBoundTag();
12819
12854
  }
12820
- setStage(stage, layer) {
12855
+ setStage(stage, layer, inheritedSharedStateScope) {
12821
12856
  var _a, _b, _c, _d, _e, _f;
12822
12857
  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,
12823
12858
  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;
12824
- 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();
12859
+ 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);
12825
12860
  const layerChanged = this.layer !== layer;
12826
- layerChanged && (this.layer = layer), needsSharedStateTreeSync ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0), this.notifyChildrenSharedStateTreeChanged()) : layerChanged && this.notifyChildrenSharedStateTreeChanged();
12861
+ layerChanged && (this.layer = layer), needsSharedStateTreeSync ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope), this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope)) : layerChanged && this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope);
12827
12862
  }
12828
12863
  addUpdatePositionTag() {
12829
12864
  super.addUpdatePositionTag(), this.forEachChildren(g => {
@@ -12882,17 +12917,29 @@
12882
12917
  hasSharedStateDefinitions() {
12883
12918
  return !!this._sharedStateDefinitions && Object.keys(this._sharedStateDefinitions).length > 0;
12884
12919
  }
12885
- notifyChildrenSharedStateTreeChanged() {
12920
+ resolveChildSharedStateScope(inheritedSharedStateScope) {
12921
+ var _a;
12922
+ return this.sharedStateScope ? this.sharedStateScope : void 0 !== inheritedSharedStateScope ? inheritedSharedStateScope : null !== (_a = this.resolveBoundSharedStateScope()) && void 0 !== _a ? _a : null;
12923
+ }
12924
+ notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope) {
12925
+ const childSharedStateScope = this.resolveChildSharedStateScope(inheritedSharedStateScope);
12886
12926
  this.forEachChildren(item => {
12887
- this.syncChildSharedStateTreeBinding(item);
12927
+ this.setStageToChild(item, childSharedStateScope);
12888
12928
  });
12889
12929
  }
12890
- syncChildSharedStateTreeBinding(child) {
12891
- child.onParentSharedStateTreeChanged(this.stage, this.layer);
12930
+ shouldSyncChildSharedStateTreeBinding(child) {
12931
+ return !(!this.stage && !this.layer) || child.onParentSharedStateTreeChanged !== Graphic.prototype.onParentSharedStateTreeChanged && child.onParentSharedStateTreeChanged !== Group.prototype.onParentSharedStateTreeChanged;
12932
+ }
12933
+ setStageToChild(child, inheritedSharedStateScope) {
12934
+ const graphic = child;
12935
+ "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);
12936
+ }
12937
+ syncChildSharedStateTreeBinding(child, inheritedSharedStateScope) {
12938
+ void 0 === inheritedSharedStateScope && (inheritedSharedStateScope = this.resolveChildSharedStateScope()), this.setStageToChild(child, inheritedSharedStateScope);
12892
12939
  }
12893
- onParentSharedStateTreeChanged(stage, layer) {
12940
+ onParentSharedStateTreeChanged(stage, layer, inheritedSharedStateScope) {
12894
12941
  var _a;
12895
- 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);
12942
+ 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);
12896
12943
  }
12897
12944
  }
12898
12945
  Group.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
@@ -49944,7 +49991,7 @@
49944
49991
  loadDiscreteLegendComponent();
49945
49992
  class DiscreteLegend extends LegendBase {
49946
49993
  constructor(attributes, options) {
49947
- super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, DiscreteLegend.defaultAttributes, attributes)), this.name = "discreteLegend", this._itemsContainer = null, this._itemHeightByUser = void 0, this._itemHeight = 0, this._itemMaxWidth = 0, this._contentMaxHeight = 0, this._onHover = e => {
49994
+ super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, DiscreteLegend.defaultAttributes, attributes)), this.name = "discreteLegend", this._itemsContainer = null, this._itemHeightByUser = void 0, this._itemHeight = 0, this._itemMaxWidth = 0, this._contentMaxHeight = 0, this._stateDefinitionsCache = new WeakMap(), this._onHover = e => {
49948
49995
  const target = e.target;
49949
49996
  if (target && target.name && target.name.startsWith(exports.LEGEND_ELEMENT_NAME.item)) {
49950
49997
  const legendItem = target.delegate;
@@ -49992,7 +50039,7 @@
49992
50039
  };
49993
50040
  }
49994
50041
  render() {
49995
- super.render(), this._lastActiveItem = null;
50042
+ this._stateDefinitionsCache = new WeakMap(), super.render(), this._lastActiveItem = null;
49996
50043
  }
49997
50044
  setSelected(selectedData) {
49998
50045
  var _a;
@@ -50172,7 +50219,7 @@
50172
50219
  }), this._appendDataToShape(itemGroup, exports.LEGEND_ELEMENT_NAME.item, item, itemGroup)) : (itemGroup = graphicCreator.group(Object.assign({
50173
50220
  x: 0,
50174
50221
  y: 0
50175
- }, backgroundStyle.style)), this._appendDataToShape(itemGroup, exports.LEGEND_ELEMENT_NAME.item, item, itemGroup, backgroundStyle.state)), itemGroup.id = `${null != id ? id : label}-${index}`, itemGroup.addState(isSelected ? exports.LegendStateValue.selected : exports.LegendStateValue.unSelected);
50222
+ }, backgroundStyle.style)), this._appendDataToShape(itemGroup, exports.LEGEND_ELEMENT_NAME.item, item, itemGroup, backgroundStyle.state, backgroundStyle.reuseStateDefinitions)), itemGroup.id = `${null != id ? id : label}-${index}`, itemGroup.addState(isSelected ? exports.LegendStateValue.selected : exports.LegendStateValue.unSelected);
50176
50223
  const innerGroup = graphicCreator.group({
50177
50224
  x: 0,
50178
50225
  y: 0,
@@ -50187,15 +50234,21 @@
50187
50234
  const s = get$1(shapeStyle, "style.size", DEFAULT_SHAPE_SIZE);
50188
50235
  shapeSize = isArray$1(s) ? s[0] || 0 : s, shapeSpace = get$1(shapeAttr, "space", DEFAULT_SHAPE_SPACE);
50189
50236
  const itemShape = graphicCreator.symbol(Object.assign(Object.assign({
50190
- x: 0,
50191
- y: 0,
50192
- symbolType: "circle",
50193
- strokeBoundsBuffer: 0
50194
- }, shape), shapeStyle.style));
50195
- Object.keys(shapeStyle.state || {}).forEach(key => {
50196
- const color = shapeStyle.state[key].fill || shapeStyle.state[key].stroke;
50197
- shape.fill && isNil$1(shapeStyle.state[key].fill) && color && (shapeStyle.state[key].fill = color), shape.stroke && isNil$1(shapeStyle.state[key].stroke) && color && (shapeStyle.state[key].stroke = color);
50198
- }), this._appendDataToShape(itemShape, exports.LEGEND_ELEMENT_NAME.itemShape, item, itemGroup, shapeStyle.state), itemShape.addState(isSelected ? exports.LegendStateValue.selected : exports.LegendStateValue.unSelected), innerGroup.add(itemShape);
50237
+ x: 0,
50238
+ y: 0,
50239
+ symbolType: "circle",
50240
+ strokeBoundsBuffer: 0
50241
+ }, shape), shapeStyle.style)),
50242
+ shapeStateNeedsItemColor = Object.keys(shapeStyle.state || {}).some(key => {
50243
+ const state = shapeStyle.state[key];
50244
+ return !!(state.fill || state.stroke) && (!!shape.fill && isNil$1(state.fill) || !!shape.stroke && isNil$1(state.stroke));
50245
+ }),
50246
+ shapeStates = shapeStateNeedsItemColor ? merge({}, shapeStyle.state) : shapeStyle.state;
50247
+ Object.keys(shapeStates || {}).forEach(key => {
50248
+ const state = shapeStates[key],
50249
+ color = state.fill || state.stroke;
50250
+ shape.fill && isNil$1(state.fill) && color && (state.fill = color), shape.stroke && isNil$1(state.stroke) && color && (state.stroke = color);
50251
+ }), this._appendDataToShape(itemShape, exports.LEGEND_ELEMENT_NAME.itemShape, item, itemGroup, shapeStates, !shapeStateNeedsItemColor && !1 !== shapeStyle.reuseStateDefinitions), itemShape.addState(isSelected ? exports.LegendStateValue.selected : exports.LegendStateValue.unSelected), innerGroup.add(itemShape);
50199
50252
  }
50200
50253
  let focusSpace = 0;
50201
50254
  if (focus) {
@@ -50222,7 +50275,7 @@
50222
50275
  _originText: labelAttr.formatMethod ? label : void 0
50223
50276
  }),
50224
50277
  labelShape = createTextGraphicByType(labelAttributes);
50225
- this._appendDataToShape(labelShape, exports.LEGEND_ELEMENT_NAME.itemLabel, item, itemGroup, labelStyle.state), labelShape.addState(isSelected ? exports.LegendStateValue.selected : exports.LegendStateValue.unSelected), innerGroup.add(labelShape);
50278
+ this._appendDataToShape(labelShape, exports.LEGEND_ELEMENT_NAME.itemLabel, item, itemGroup, labelStyle.state, labelStyle.reuseStateDefinitions), labelShape.addState(isSelected ? exports.LegendStateValue.selected : exports.LegendStateValue.unSelected), innerGroup.add(labelShape);
50226
50279
  const labelSpace = get$1(labelAttr, "space", DEFAULT_LABEL_SPACE);
50227
50280
  if (isValid$1(value)) {
50228
50281
  const valueSpace = get$1(valueAttr, "space", focus ? DEFAULT_VALUE_SPACE : 0),
@@ -50238,7 +50291,7 @@
50238
50291
  _originText: valueAttr.formatMethod ? value : void 0
50239
50292
  }),
50240
50293
  valueShape = createTextGraphicByType(valueAttributes);
50241
- if (this._appendDataToShape(valueShape, exports.LEGEND_ELEMENT_NAME.itemValue, item, itemGroup, valueStyle.state), valueShape.addState(isSelected ? exports.LegendStateValue.selected : exports.LegendStateValue.unSelected), this._itemWidthByUser) {
50294
+ if (this._appendDataToShape(valueShape, exports.LEGEND_ELEMENT_NAME.itemValue, item, itemGroup, valueStyle.state, valueStyle.reuseStateDefinitions), valueShape.addState(isSelected ? exports.LegendStateValue.selected : exports.LegendStateValue.unSelected), this._itemWidthByUser) {
50242
50295
  const layoutWidth = this._itemWidthByUser - parsedPadding[1] - parsedPadding[3] - shapeSize - shapeSpace - labelSpace - focusSpace - valueSpace;
50243
50296
  this._autoEllipsis(autoEllipsisStrategy, layoutWidth, labelShape, valueShape), valueAttr.alignRight ? valueShape.setAttributes({
50244
50297
  textAlign: "right",
@@ -50314,6 +50367,7 @@
50314
50367
  }));
50315
50368
  }
50316
50369
  _updatePositionOfPager(renderStartY, compWidth, compHeight) {
50370
+ var _a;
50317
50371
  const {
50318
50372
  pager: pager
50319
50373
  } = this.attribute,
@@ -50321,18 +50375,24 @@
50321
50375
  totalPage: totalPage,
50322
50376
  isHorizontal: isHorizontal
50323
50377
  } = this._itemContext,
50324
- position = pager && pager.position || "middle";
50378
+ position = pager && pager.position || "middle",
50379
+ hugContent = !(!pager || !pager.hugContent),
50380
+ pagerSpace = null !== (_a = pager && pager.space) && void 0 !== _a ? _a : DEFAULT_PAGER_SPACE;
50325
50381
  if (this._pagerComponent.setTotal(totalPage), isHorizontal) {
50326
50382
  let y;
50327
- y = "start" === position ? renderStartY : "end" === position ? renderStartY + compHeight - this._pagerComponent.AABBBounds.height() / 2 : renderStartY + compHeight / 2 - this._pagerComponent.AABBBounds.height() / 2, this._pagerComponent.setAttributes({
50328
- x: compWidth - this._pagerComponent.AABBBounds.width(),
50383
+ y = "start" === position ? renderStartY : "end" === position ? renderStartY + compHeight - this._pagerComponent.AABBBounds.height() / 2 : renderStartY + compHeight / 2 - this._pagerComponent.AABBBounds.height() / 2;
50384
+ let x = compWidth - this._pagerComponent.AABBBounds.width();
50385
+ hugContent && (x = Math.max(0, Math.min(this._itemsContainer.AABBBounds.width() + pagerSpace, x))), this._pagerComponent.setAttributes({
50386
+ x: x,
50329
50387
  y: y
50330
50388
  });
50331
50389
  } else {
50332
50390
  let x;
50333
- x = "start" === position ? 0 : "end" === position ? compWidth - this._pagerComponent.AABBBounds.width() : (compWidth - this._pagerComponent.AABBBounds.width()) / 2, this._pagerComponent.setAttributes({
50391
+ x = "start" === position ? 0 : "end" === position ? compWidth - this._pagerComponent.AABBBounds.width() : (compWidth - this._pagerComponent.AABBBounds.width()) / 2;
50392
+ let y = compHeight - this._pagerComponent.AABBBounds.height();
50393
+ hugContent && (y = Math.max(0, Math.min(renderStartY + this._itemsContainer.AABBBounds.height() + pagerSpace, y))), this._pagerComponent.setAttributes({
50334
50394
  x: x,
50335
- y: compHeight - this._pagerComponent.AABBBounds.height()
50395
+ y: y
50336
50396
  });
50337
50397
  }
50338
50398
  }
@@ -50487,11 +50547,15 @@
50487
50547
  this._itemContext.totalPage = total, this._updatePositionOfPager(renderStartY, compWidth, compHeight);
50488
50548
  }
50489
50549
  defaultCurrent > 1 && (isHorizontal ? itemsContainer.setAttribute("y", -(defaultCurrent - 1) * (compHeight + spaceRow)) : itemsContainer.setAttribute("x", -(defaultCurrent - 1) * (compWidth + spaceCol)));
50550
+ const hugContent = !!pager.hugContent;
50551
+ let clipWidth = isHorizontal ? contentWidth : compWidth,
50552
+ clipHeight = isHorizontal ? compHeight : contentHeight;
50553
+ hugContent && (isHorizontal ? clipWidth = Math.max(0, Math.min(clipWidth, itemsContainer.AABBBounds.width())) : clipHeight = Math.max(0, Math.min(clipHeight, itemsContainer.AABBBounds.height())));
50490
50554
  const clipGroup = graphicCreator.group({
50491
50555
  x: 0,
50492
50556
  y: renderStartY,
50493
- width: isHorizontal ? contentWidth : compWidth,
50494
- height: isHorizontal ? compHeight : contentHeight,
50557
+ width: clipWidth,
50558
+ height: clipHeight,
50495
50559
  clip: !0,
50496
50560
  pickable: !1
50497
50561
  });
@@ -50657,8 +50721,17 @@
50657
50721
  item.hasState(exports.LegendStateValue.selected) && selectedData.push(item.data);
50658
50722
  }), selectedData;
50659
50723
  }
50660
- _appendDataToShape(shape, name, data, delegateShape, states = {}) {
50661
- shape.name = name, shape.data = data, shape.delegate = delegateShape, shape.states = merge({}, DEFAULT_STATES, states);
50724
+ _appendDataToShape(shape, name, data, delegateShape, states, reuseStateDefinitions = !0) {
50725
+ if (shape.name = name, shape.data = data, shape.delegate = delegateShape, !reuseStateDefinitions) return void (shape.states = merge({}, DEFAULT_STATES, states));
50726
+ const source = null != states ? states : DEFAULT_STATES,
50727
+ cached = this._stateDefinitionsCache.get(source);
50728
+ if (cached) return shape.states = cached.definitions, void shape.setStateDefinitionsWithCompiled(cached.definitions, cached.compiledDefinitions);
50729
+ const definitions = states ? merge({}, DEFAULT_STATES, states) : DEFAULT_STATES,
50730
+ entry = {
50731
+ definitions: definitions,
50732
+ compiledDefinitions: new StateDefinitionCompiler().compile(definitions)
50733
+ };
50734
+ this._stateDefinitionsCache.set(source, entry), shape.states = entry.definitions, shape.setStateDefinitionsWithCompiled(entry.definitions, entry.compiledDefinitions);
50662
50735
  }
50663
50736
  _dispatchLegendEvent(eventName, legendItem, event) {
50664
50737
  const currentSelectedItems = this._getSelectedLegends();
@@ -50675,12 +50748,17 @@
50675
50748
  }
50676
50749
  _handleStyle(config, item, isSelected, index, items) {
50677
50750
  const newConfig = {};
50678
- return config.style && (isFunction$1(config.style) ? newConfig.style = config.style(item, isSelected, index, items) : newConfig.style = config.style), config.state && (newConfig.state = {}, Object.keys(config.state).forEach(key => {
50679
- config.state[key] && (isFunction$1(config.state[key]) ? newConfig.state[key] = config.state[key](item, isSelected, index, items) : newConfig.state[key] = config.state[key]);
50680
- })), newConfig;
50751
+ if (config.style && (isFunction$1(config.style) ? newConfig.style = config.style(item, isSelected, index, items) : newConfig.style = config.style), config.state) {
50752
+ const stateKeys = Object.keys(config.state),
50753
+ hasStateFunction = stateKeys.some(key => isFunction$1(config.state[key]));
50754
+ newConfig.reuseStateDefinitions = !hasStateFunction, hasStateFunction ? (newConfig.state = {}, stateKeys.forEach(key => {
50755
+ config.state[key] && (newConfig.state[key] = isFunction$1(config.state[key]) ? config.state[key](item, isSelected, index, items) : config.state[key]);
50756
+ })) : newConfig.state = config.state;
50757
+ }
50758
+ return newConfig;
50681
50759
  }
50682
50760
  release() {
50683
- super.release(), this.removeAllEventListeners();
50761
+ this._stateDefinitionsCache = new WeakMap(), super.release(), this.removeAllEventListeners();
50684
50762
  }
50685
50763
  }
50686
50764
  DiscreteLegend.defaultAttributes = {
@@ -55562,7 +55640,7 @@
55562
55640
  return resolveLegacyApp().createStage(params);
55563
55641
  }
55564
55642
 
55565
- const version = "1.1.4-alpha.1";
55643
+ const version = "1.1.4-alpha.2";
55566
55644
 
55567
55645
  exports.AComponentAnimate = AComponentAnimate;
55568
55646
  exports.ACustomAnimate = ACustomAnimate;