@visactor/vrender-components 1.1.4-alpha.2 → 1.1.4-alpha.3

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, _inheritedSharedStateScope) {}
211
+ onParentSharedStateTreeChanged(_stage, _layer) {}
212
212
  forEachChildren(cb, reverse = !1) {
213
213
  if (reverse) {
214
214
  let child = this._lastChild,
@@ -4449,8 +4449,6 @@ class StateEngine {
4449
4449
  this.graphic === graphic && this.baseAttributes === baseAttributes || this.invalidateResolverCache(), this.graphic = graphic, this.baseAttributes = baseAttributes;
4450
4450
  }
4451
4451
  applyStates(stateNames) {
4452
- const singleStaticStateResult = this.tryApplySingleStaticState(stateNames);
4453
- if (singleStaticStateResult) return singleStaticStateResult;
4454
4452
  const uniqueStates = Array.from(new Set(stateNames)),
4455
4453
  sortedStates = this.sortStates(uniqueStates),
4456
4454
  adjudicated = this.adjudicate(sortedStates),
@@ -4465,19 +4463,6 @@ class StateEngine {
4465
4463
  suppressed: [...this._suppressed]
4466
4464
  };
4467
4465
  }
4468
- tryApplySingleStaticState(stateNames) {
4469
- if (1 !== stateNames.length || "shallow" !== this.mergeMode) return;
4470
- const stateName = stateNames[0],
4471
- definition = this.compiledDefinitions.get(stateName);
4472
- if (definition && (definition.hasResolver || definition.exclude.size || definition.suppress.size)) return;
4473
- const changed = 1 !== this._activeStates.length || this._activeStates[0] !== stateName || 1 !== this._effectiveStates.length || this._effectiveStates[0] !== stateName || 0 !== this._suppressed.length;
4474
- 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) : {}), {
4475
- changed: changed,
4476
- activeStates: [...this._activeStates],
4477
- effectiveStates: [...this._effectiveStates],
4478
- suppressed: []
4479
- };
4480
- }
4481
4466
  addState(stateName, keepCurrentStates) {
4482
4467
  if (this._activeStates.includes(stateName) && (keepCurrentStates || 1 === this._activeStates.length)) return {
4483
4468
  changed: !1,
@@ -4890,17 +4875,14 @@ class GraphicImpl extends Node {
4890
4875
  }
4891
4876
  return null === (_a = this.stage) || void 0 === _a ? void 0 : _a.rootSharedStateScope;
4892
4877
  }
4893
- syncSharedStateScopeBinding(nextScope, markDirty = !0) {
4878
+ syncSharedStateScopeBindingFromTree(markDirty = !0) {
4894
4879
  var _a;
4880
+ const nextScope = this.resolveBoundSharedStateScope();
4895
4881
  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);
4896
4882
  }
4897
- syncSharedStateScopeBindingFromTree(markDirty = !0, inheritedSharedStateScope) {
4898
- const nextScope = void 0 === inheritedSharedStateScope ? this.resolveBoundSharedStateScope() : null != inheritedSharedStateScope ? inheritedSharedStateScope : void 0;
4899
- return this.syncSharedStateScopeBinding(nextScope, markDirty);
4900
- }
4901
- syncSharedStateScopeBindingOnTreeChange(markDirty = !0, inheritedSharedStateScope) {
4883
+ syncSharedStateScopeBindingOnTreeChange(markDirty = !0) {
4902
4884
  var _a, _b;
4903
- 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);
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);
4904
4886
  }
4905
4887
  syncSharedStateActiveRegistrations() {
4906
4888
  var _a;
@@ -4908,7 +4890,6 @@ class GraphicImpl extends Node {
4908
4890
  if (!(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || !this.boundSharedStateScope) return (null == previousScopes ? void 0 : previousScopes.size) && (previousScopes.forEach(scope => {
4909
4891
  scope.subtreeActiveDescendants.delete(this);
4910
4892
  }), previousScopes.clear()), void (this.registeredActiveScopes = void 0);
4911
- if ((null == previousScopes ? void 0 : previousScopes.size) && this.isSharedStateScopeChainRegistered(previousScopes)) return;
4912
4893
  const nextScopes = new Set(collectSharedStateScopeChain(this.boundSharedStateScope));
4913
4894
  null == previousScopes || previousScopes.forEach(scope => {
4914
4895
  nextScopes.has(scope) || scope.subtreeActiveDescendants.delete(this);
@@ -4916,15 +4897,6 @@ class GraphicImpl extends Node {
4916
4897
  scope.subtreeActiveDescendants.add(this);
4917
4898
  }), this.registeredActiveScopes = nextScopes;
4918
4899
  }
4919
- isSharedStateScopeChainRegistered(previousScopes) {
4920
- let scope = this.boundSharedStateScope,
4921
- scopeCount = 0;
4922
- for (; scope;) {
4923
- if (!previousScopes.has(scope)) return !1;
4924
- scopeCount += 1, scope = scope.parentScope;
4925
- }
4926
- return scopeCount === previousScopes.size;
4927
- }
4928
4900
  clearSharedStateActiveRegistrations() {
4929
4901
  const previousScopes = this.registeredActiveScopes;
4930
4902
  previousScopes && (previousScopes.forEach(scope => {
@@ -4934,8 +4906,8 @@ class GraphicImpl extends Node {
4934
4906
  markSharedStateDirty() {
4935
4907
  this.sharedStateDirty = !0, enqueueGraphicSharedStateRefresh(this.stage, this), scheduleStageSharedStateRefresh(this.stage);
4936
4908
  }
4937
- onParentSharedStateTreeChanged(stage, layer, inheritedSharedStateScope) {
4938
- this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope) : this.setStage(stage, layer, inheritedSharedStateScope);
4909
+ onParentSharedStateTreeChanged(stage, layer) {
4910
+ this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange() : this.setStage(stage, layer);
4939
4911
  }
4940
4912
  refreshSharedStateBeforeRender() {
4941
4913
  var _a;
@@ -5586,10 +5558,6 @@ class GraphicImpl extends Node {
5586
5558
  var _a;
5587
5559
  return null === (_a = this.states) || void 0 === _a ? void 0 : _a[stateName];
5588
5560
  }
5589
- setStateDefinitionsWithCompiled(definitions, compiledDefinitions) {
5590
- var _a;
5591
- 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}`;
5592
- }
5593
5561
  getStateResolveBaseAttrs() {
5594
5562
  var _a;
5595
5563
  return null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute;
@@ -5783,10 +5751,8 @@ class GraphicImpl extends Node {
5783
5751
  transition.changed && this.useStates(transition.states, hasAnimation);
5784
5752
  }
5785
5753
  addState(stateName, keepCurrentStates, hasAnimation) {
5786
- const currentStates = this.currentStates;
5787
- if ((null == currentStates ? void 0 : currentStates.includes(stateName)) && (keepCurrentStates || 1 === currentStates.length)) return;
5788
- const nextStates = keepCurrentStates && (null == currentStates ? void 0 : currentStates.length) ? currentStates.concat([stateName]) : [stateName];
5789
- this.useStates(nextStates, hasAnimation);
5754
+ const transition = this.resolveAddStateTransition(stateName, keepCurrentStates);
5755
+ transition.changed && this.useStates(transition.states, hasAnimation);
5790
5756
  }
5791
5757
  setStates(states, options) {
5792
5758
  var _a, _b, _c;
@@ -5939,12 +5905,12 @@ class GraphicImpl extends Node {
5939
5905
  this._globalTransMatrix.translate(scrollX, scrollY);
5940
5906
  }
5941
5907
  }
5942
- setStage(stage, layer, inheritedSharedStateScope) {
5908
+ setStage(stage, layer) {
5943
5909
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
5944
5910
  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,
5945
5911
  previousStage = this.stage;
5946
5912
  if (this.stage !== stage || this.layer !== layer) {
5947
- 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()) {
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()) {
5948
5914
  const previousTimeline = null === (_f = null == previousStage ? void 0 : previousStage.getTimeline) || void 0 === _f ? void 0 : _f.call(previousStage),
5949
5915
  nextTimeline = null === (_g = null == stage ? void 0 : stage.getTimeline) || void 0 === _g ? void 0 : _g.call(stage),
5950
5916
  detachedStageAnimates = [];
@@ -5961,7 +5927,7 @@ class GraphicImpl extends Node {
5961
5927
  }
5962
5928
  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));
5963
5929
  }
5964
- ((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);
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);
5965
5931
  }
5966
5932
  detachStageForRelease() {
5967
5933
  var _a, _b, _c;
@@ -6350,17 +6316,17 @@ class Group extends Graphic {
6350
6316
  }
6351
6317
  incrementalAppendChild(node) {
6352
6318
  const data = super.appendChild(node);
6353
- return data && this.shouldSyncChildSharedStateTreeBinding(data) && this.syncChildSharedStateTreeBinding(data), this.addUpdateBoundTag(), this.getGraphicService().onAddIncremental(node, this, this.stage), data;
6319
+ return data && this.syncChildSharedStateTreeBinding(data), this.addUpdateBoundTag(), this.getGraphicService().onAddIncremental(node, this, this.stage), data;
6354
6320
  }
6355
6321
  incrementalClearChild() {
6356
6322
  super.removeAllChild(), this.addUpdateBoundTag(), this.getGraphicService().onClearIncremental(this, this.stage);
6357
6323
  }
6358
6324
  _updateChildToStage(child) {
6359
- return child && this.shouldSyncChildSharedStateTreeBinding(child) && this.syncChildSharedStateTreeBinding(child), this.addUpdateBoundTag(), child;
6325
+ return child && this.syncChildSharedStateTreeBinding(child), this.addUpdateBoundTag(), child;
6360
6326
  }
6361
6327
  appendChild(node, addStage = !0) {
6362
6328
  const data = super.appendChild(node);
6363
- return data && addStage && this.shouldSyncChildSharedStateTreeBinding(data) && this.syncChildSharedStateTreeBinding(data), this.addUpdateBoundTag(), data;
6329
+ return data && addStage && this.syncChildSharedStateTreeBinding(data), this.addUpdateBoundTag(), data;
6364
6330
  }
6365
6331
  insertBefore(newNode, referenceNode) {
6366
6332
  return this._updateChildToStage(super.insertBefore(newNode, referenceNode));
@@ -6383,13 +6349,13 @@ class Group extends Graphic {
6383
6349
  child.setStage(null, null);
6384
6350
  }), this.addUpdateBoundTag();
6385
6351
  }
6386
- setStage(stage, layer, inheritedSharedStateScope) {
6352
+ setStage(stage, layer) {
6387
6353
  var _a, _b, _c, _d, _e, _f;
6388
6354
  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,
6389
6355
  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;
6390
- 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);
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();
6391
6357
  const layerChanged = this.layer !== layer;
6392
- layerChanged && (this.layer = layer), needsSharedStateTreeSync ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope), this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope)) : layerChanged && this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope);
6358
+ layerChanged && (this.layer = layer), needsSharedStateTreeSync ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0), this.notifyChildrenSharedStateTreeChanged()) : layerChanged && this.notifyChildrenSharedStateTreeChanged();
6393
6359
  }
6394
6360
  addUpdatePositionTag() {
6395
6361
  super.addUpdatePositionTag(), this.forEachChildren(g => {
@@ -6448,29 +6414,17 @@ class Group extends Graphic {
6448
6414
  hasSharedStateDefinitions() {
6449
6415
  return !!this._sharedStateDefinitions && Object.keys(this._sharedStateDefinitions).length > 0;
6450
6416
  }
6451
- resolveChildSharedStateScope(inheritedSharedStateScope) {
6452
- var _a;
6453
- return this.sharedStateScope ? this.sharedStateScope : void 0 !== inheritedSharedStateScope ? inheritedSharedStateScope : null !== (_a = this.resolveBoundSharedStateScope()) && void 0 !== _a ? _a : null;
6454
- }
6455
- notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope) {
6456
- const childSharedStateScope = this.resolveChildSharedStateScope(inheritedSharedStateScope);
6417
+ notifyChildrenSharedStateTreeChanged() {
6457
6418
  this.forEachChildren(item => {
6458
- this.setStageToChild(item, childSharedStateScope);
6419
+ this.syncChildSharedStateTreeBinding(item);
6459
6420
  });
6460
6421
  }
6461
- shouldSyncChildSharedStateTreeBinding(child) {
6462
- return !(!this.stage && !this.layer) || child.onParentSharedStateTreeChanged !== Graphic.prototype.onParentSharedStateTreeChanged && child.onParentSharedStateTreeChanged !== Group.prototype.onParentSharedStateTreeChanged;
6463
- }
6464
- setStageToChild(child, inheritedSharedStateScope) {
6465
- const graphic = child;
6466
- "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);
6422
+ syncChildSharedStateTreeBinding(child) {
6423
+ child.onParentSharedStateTreeChanged(this.stage, this.layer);
6467
6424
  }
6468
- syncChildSharedStateTreeBinding(child, inheritedSharedStateScope) {
6469
- void 0 === inheritedSharedStateScope && (inheritedSharedStateScope = this.resolveChildSharedStateScope()), this.setStageToChild(child, inheritedSharedStateScope);
6470
- }
6471
- onParentSharedStateTreeChanged(stage, layer, inheritedSharedStateScope) {
6425
+ onParentSharedStateTreeChanged(stage, layer) {
6472
6426
  var _a;
6473
- 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);
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);
6474
6428
  }
6475
6429
  }
6476
6430
  Group.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
@@ -9073,8 +9027,8 @@ class RichText extends Graphic {
9073
9027
  clone() {
9074
9028
  return new RichText(Object.assign({}, this.attribute));
9075
9029
  }
9076
- setStage(stage, layer, inheritedSharedStateScope) {
9077
- super.setStage(stage, layer, inheritedSharedStateScope);
9030
+ setStage(stage, layer) {
9031
+ super.setStage(stage, layer);
9078
9032
  this.getFrameCache().icons.forEach(icon => {
9079
9033
  icon.setStage(stage, layer);
9080
9034
  });
@@ -30050,7 +30004,6 @@ class DiscreteLegend extends LegendBase {
30050
30004
  this._itemHeight = 0;
30051
30005
  this._itemMaxWidth = 0;
30052
30006
  this._contentMaxHeight = 0;
30053
- this._stateDefinitionsCache = new WeakMap();
30054
30007
  this._onHover = (e) => {
30055
30008
  const target = e.target;
30056
30009
  if (target && target.name && target.name.startsWith(LEGEND_ELEMENT_NAME.item)) {
@@ -30137,7 +30090,6 @@ class DiscreteLegend extends LegendBase {
30137
30090
  };
30138
30091
  }
30139
30092
  render() {
30140
- this._stateDefinitionsCache = new WeakMap();
30141
30093
  super.render();
30142
30094
  this._lastActiveItem = null;
30143
30095
  }
@@ -30416,7 +30368,7 @@ class DiscreteLegend extends LegendBase {
30416
30368
  }
30417
30369
  else {
30418
30370
  itemGroup = graphicCreator.group(Object.assign({ x: 0, y: 0 }, backgroundStyle.style));
30419
- this._appendDataToShape(itemGroup, LEGEND_ELEMENT_NAME.item, item, itemGroup, backgroundStyle.state, backgroundStyle.reuseStateDefinitions);
30371
+ this._appendDataToShape(itemGroup, LEGEND_ELEMENT_NAME.item, item, itemGroup, backgroundStyle.state);
30420
30372
  }
30421
30373
  itemGroup.id = `${id !== null && id !== void 0 ? id : label}-${index}`;
30422
30374
  itemGroup.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected);
@@ -30439,23 +30391,17 @@ class DiscreteLegend extends LegendBase {
30439
30391
  }
30440
30392
  shapeSpace = get(shapeAttr, 'space', DEFAULT_SHAPE_SPACE);
30441
30393
  const itemShape = graphicCreator.symbol(Object.assign(Object.assign({ x: 0, y: 0, symbolType: 'circle', strokeBoundsBuffer: 0 }, shape), shapeStyle.style));
30442
- const shapeStateNeedsItemColor = Object.keys(shapeStyle.state || {}).some(key => {
30443
- const state = shapeStyle.state[key];
30444
- const color = state.fill || state.stroke;
30445
- return !!color && ((!!shape.fill && isNil(state.fill)) || (!!shape.stroke && isNil(state.stroke)));
30446
- });
30447
- const shapeStates = shapeStateNeedsItemColor ? merge({}, shapeStyle.state) : shapeStyle.state;
30448
- Object.keys(shapeStates || {}).forEach(key => {
30449
- const state = shapeStates[key];
30450
- const color = state.fill || state.stroke;
30451
- if (shape.fill && isNil(state.fill) && color) {
30452
- state.fill = color;
30394
+ Object.keys(shapeStyle.state || {}).forEach(key => {
30395
+ const color = shapeStyle.state[key].fill ||
30396
+ shapeStyle.state[key].stroke;
30397
+ if (shape.fill && isNil(shapeStyle.state[key].fill) && color) {
30398
+ shapeStyle.state[key].fill = color;
30453
30399
  }
30454
- if (shape.stroke && isNil(state.stroke) && color) {
30455
- state.stroke = color;
30400
+ if (shape.stroke && isNil(shapeStyle.state[key].stroke) && color) {
30401
+ shapeStyle.state[key].stroke = color;
30456
30402
  }
30457
30403
  });
30458
- this._appendDataToShape(itemShape, LEGEND_ELEMENT_NAME.itemShape, item, itemGroup, shapeStates, !shapeStateNeedsItemColor && shapeStyle.reuseStateDefinitions !== false);
30404
+ this._appendDataToShape(itemShape, LEGEND_ELEMENT_NAME.itemShape, item, itemGroup, shapeStyle.state);
30459
30405
  itemShape.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected);
30460
30406
  innerGroup.add(itemShape);
30461
30407
  }
@@ -30470,7 +30416,7 @@ class DiscreteLegend extends LegendBase {
30470
30416
  const text = labelAttr.formatMethod ? labelAttr.formatMethod(label, item, index) : label;
30471
30417
  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 });
30472
30418
  const labelShape = createTextGraphicByType(labelAttributes);
30473
- this._appendDataToShape(labelShape, LEGEND_ELEMENT_NAME.itemLabel, item, itemGroup, labelStyle.state, labelStyle.reuseStateDefinitions);
30419
+ this._appendDataToShape(labelShape, LEGEND_ELEMENT_NAME.itemLabel, item, itemGroup, labelStyle.state);
30474
30420
  labelShape.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected);
30475
30421
  innerGroup.add(labelShape);
30476
30422
  const labelSpace = get(labelAttr, 'space', DEFAULT_LABEL_SPACE);
@@ -30479,7 +30425,7 @@ class DiscreteLegend extends LegendBase {
30479
30425
  const valueText = valueAttr.formatMethod ? valueAttr.formatMethod(value, item, index) : value;
30480
30426
  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 });
30481
30427
  const valueShape = createTextGraphicByType(valueAttributes);
30482
- this._appendDataToShape(valueShape, LEGEND_ELEMENT_NAME.itemValue, item, itemGroup, valueStyle.state, valueStyle.reuseStateDefinitions);
30428
+ this._appendDataToShape(valueShape, LEGEND_ELEMENT_NAME.itemValue, item, itemGroup, valueStyle.state);
30483
30429
  valueShape.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected);
30484
30430
  if (this._itemWidthByUser) {
30485
30431
  const layoutWidth = this._itemWidthByUser -
@@ -31131,29 +31077,11 @@ class DiscreteLegend extends LegendBase {
31131
31077
  });
31132
31078
  return selectedData;
31133
31079
  }
31134
- _appendDataToShape(shape, name, data, delegateShape, states, reuseStateDefinitions = true) {
31080
+ _appendDataToShape(shape, name, data, delegateShape, states = {}) {
31135
31081
  shape.name = name;
31136
31082
  shape.data = data;
31137
31083
  shape.delegate = delegateShape;
31138
- if (!reuseStateDefinitions) {
31139
- shape.states = merge({}, DEFAULT_STATES, states);
31140
- return;
31141
- }
31142
- const source = states !== null && states !== void 0 ? states : DEFAULT_STATES;
31143
- const cached = this._stateDefinitionsCache.get(source);
31144
- if (cached) {
31145
- shape.states = cached.definitions;
31146
- shape.setStateDefinitionsWithCompiled(cached.definitions, cached.compiledDefinitions);
31147
- return;
31148
- }
31149
- const definitions = states ? merge({}, DEFAULT_STATES, states) : DEFAULT_STATES;
31150
- const entry = {
31151
- definitions,
31152
- compiledDefinitions: new StateDefinitionCompiler().compile(definitions)
31153
- };
31154
- this._stateDefinitionsCache.set(source, entry);
31155
- shape.states = entry.definitions;
31156
- shape.setStateDefinitionsWithCompiled(entry.definitions, entry.compiledDefinitions);
31084
+ shape.states = merge({}, DEFAULT_STATES, states);
31157
31085
  }
31158
31086
  _dispatchLegendEvent(eventName, legendItem, event) {
31159
31087
  const currentSelectedItems = this._getSelectedLegends();
@@ -31179,27 +31107,21 @@ class DiscreteLegend extends LegendBase {
31179
31107
  }
31180
31108
  }
31181
31109
  if (config.state) {
31182
- const stateKeys = Object.keys(config.state);
31183
- const hasStateFunction = stateKeys.some(key => isFunction(config.state[key]));
31184
- newConfig.reuseStateDefinitions = !hasStateFunction;
31185
- if (!hasStateFunction) {
31186
- newConfig.state = config.state;
31187
- }
31188
- else {
31189
- newConfig.state = {};
31190
- stateKeys.forEach(key => {
31191
- if (config.state[key]) {
31192
- newConfig.state[key] = isFunction(config.state[key])
31193
- ? config.state[key](item, isSelected, index, items)
31194
- : config.state[key];
31110
+ newConfig.state = {};
31111
+ Object.keys(config.state).forEach(key => {
31112
+ if (config.state[key]) {
31113
+ if (isFunction(config.state[key])) {
31114
+ newConfig.state[key] = config.state[key](item, isSelected, index, items);
31195
31115
  }
31196
- });
31197
- }
31116
+ else {
31117
+ newConfig.state[key] = config.state[key];
31118
+ }
31119
+ }
31120
+ });
31198
31121
  }
31199
31122
  return newConfig;
31200
31123
  }
31201
31124
  release() {
31202
- this._stateDefinitionsCache = new WeakMap();
31203
31125
  super.release();
31204
31126
  this.removeAllEventListeners();
31205
31127
  }
@@ -36702,6 +36624,6 @@ TableSeriesNumber.defaultAttributes = {
36702
36624
  select: true
36703
36625
  };
36704
36626
 
36705
- const version = "1.1.4-alpha.2";
36627
+ const version = "1.1.4-alpha.3";
36706
36628
 
36707
36629
  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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const version = "1.1.4-alpha.2";
1
+ export declare const version = "1.1.4-alpha.3";
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-alpha.2";
1
+ export const version = "1.1.4-alpha.3";
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":[],"mappings":"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","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"1.1.4-alpha.2\";\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":"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","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"1.1.4-alpha.3\";\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"]}
@@ -15,7 +15,6 @@ export declare class DiscreteLegend extends LegendBase<DiscreteLegendAttrs> {
15
15
  private _itemContext;
16
16
  private _scrollMask;
17
17
  private _scrollMaskContext;
18
- private _stateDefinitionsCache;
19
18
  static defaultAttributes: Partial<DiscreteLegendAttrs>;
20
19
  constructor(attributes: DiscreteLegendAttrs, options?: ComponentOptions);
21
20
  render(): void;
@@ -10,8 +10,6 @@ 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
-
15
13
  import { graphicCreator } from "../../util/graphic-creator";
16
14
 
17
15
  import { LegendBase } from "../base";
@@ -42,8 +40,7 @@ export class DiscreteLegend extends LegendBase {
42
40
  constructor(attributes, options) {
43
41
  super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, DiscreteLegend.defaultAttributes, attributes)),
44
42
  this.name = "discreteLegend", this._itemsContainer = null, this._itemHeightByUser = void 0,
45
- this._itemHeight = 0, this._itemMaxWidth = 0, this._contentMaxHeight = 0, this._stateDefinitionsCache = new WeakMap,
46
- this._onHover = e => {
43
+ this._itemHeight = 0, this._itemMaxWidth = 0, this._contentMaxHeight = 0, this._onHover = e => {
47
44
  const target = e.target;
48
45
  if (target && target.name && target.name.startsWith(LEGEND_ELEMENT_NAME.item)) {
49
46
  const legendItem = target.delegate;
@@ -91,7 +88,7 @@ export class DiscreteLegend extends LegendBase {
91
88
  };
92
89
  }
93
90
  render() {
94
- this._stateDefinitionsCache = new WeakMap, super.render(), this._lastActiveItem = null;
91
+ super.render(), this._lastActiveItem = null;
95
92
  }
96
93
  setSelected(selectedData) {
97
94
  var _a;
@@ -209,7 +206,7 @@ export class DiscreteLegend extends LegendBase {
209
206
  }), this._appendDataToShape(itemGroup, LEGEND_ELEMENT_NAME.item, item, itemGroup)) : (itemGroup = graphicCreator.group(Object.assign({
210
207
  x: 0,
211
208
  y: 0
212
- }, backgroundStyle.style)), this._appendDataToShape(itemGroup, LEGEND_ELEMENT_NAME.item, item, itemGroup, backgroundStyle.state, backgroundStyle.reuseStateDefinitions)),
209
+ }, backgroundStyle.style)), this._appendDataToShape(itemGroup, LEGEND_ELEMENT_NAME.item, item, itemGroup, backgroundStyle.state)),
213
210
  itemGroup.id = `${null != id ? id : label}-${index}`, itemGroup.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected);
214
211
  const innerGroup = graphicCreator.group({
215
212
  x: 0,
@@ -226,14 +223,12 @@ export class DiscreteLegend extends LegendBase {
226
223
  y: 0,
227
224
  symbolType: "circle",
228
225
  strokeBoundsBuffer: 0
229
- }, shape), shapeStyle.style)), shapeStateNeedsItemColor = Object.keys(shapeStyle.state || {}).some((key => {
230
- const state = shapeStyle.state[key];
231
- return !!(state.fill || state.stroke) && (!!shape.fill && isNil(state.fill) || !!shape.stroke && isNil(state.stroke));
232
- })), shapeStates = shapeStateNeedsItemColor ? merge({}, shapeStyle.state) : shapeStyle.state;
233
- Object.keys(shapeStates || {}).forEach((key => {
234
- const state = shapeStates[key], color = state.fill || state.stroke;
235
- shape.fill && isNil(state.fill) && color && (state.fill = color), shape.stroke && isNil(state.stroke) && color && (state.stroke = color);
236
- })), this._appendDataToShape(itemShape, LEGEND_ELEMENT_NAME.itemShape, item, itemGroup, shapeStates, !shapeStateNeedsItemColor && !1 !== shapeStyle.reuseStateDefinitions),
226
+ }, shape), shapeStyle.style));
227
+ Object.keys(shapeStyle.state || {}).forEach((key => {
228
+ const color = shapeStyle.state[key].fill || shapeStyle.state[key].stroke;
229
+ shape.fill && isNil(shapeStyle.state[key].fill) && color && (shapeStyle.state[key].fill = color),
230
+ 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),
237
232
  itemShape.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected),
238
233
  innerGroup.add(itemShape);
239
234
  }
@@ -261,7 +256,7 @@ export class DiscreteLegend extends LegendBase {
261
256
  text: text,
262
257
  _originText: labelAttr.formatMethod ? label : void 0
263
258
  }), labelShape = createTextGraphicByType(labelAttributes);
264
- this._appendDataToShape(labelShape, LEGEND_ELEMENT_NAME.itemLabel, item, itemGroup, labelStyle.state, labelStyle.reuseStateDefinitions),
259
+ this._appendDataToShape(labelShape, LEGEND_ELEMENT_NAME.itemLabel, item, itemGroup, labelStyle.state),
265
260
  labelShape.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected),
266
261
  innerGroup.add(labelShape);
267
262
  const labelSpace = get(labelAttr, "space", DEFAULT_LABEL_SPACE);
@@ -276,7 +271,7 @@ export class DiscreteLegend extends LegendBase {
276
271
  text: valueText,
277
272
  _originText: valueAttr.formatMethod ? value : void 0
278
273
  }), valueShape = createTextGraphicByType(valueAttributes);
279
- if (this._appendDataToShape(valueShape, LEGEND_ELEMENT_NAME.itemValue, item, itemGroup, valueStyle.state, valueStyle.reuseStateDefinitions),
274
+ if (this._appendDataToShape(valueShape, LEGEND_ELEMENT_NAME.itemValue, item, itemGroup, valueStyle.state),
280
275
  valueShape.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected),
281
276
  this._itemWidthByUser) {
282
277
  const layoutWidth = this._itemWidthByUser - parsedPadding[1] - parsedPadding[3] - shapeSize - shapeSpace - labelSpace - focusSpace - valueSpace;
@@ -619,16 +614,8 @@ export class DiscreteLegend extends LegendBase {
619
614
  item.hasState(LegendStateValue.selected) && selectedData.push(item.data);
620
615
  })), selectedData;
621
616
  }
622
- _appendDataToShape(shape, name, data, delegateShape, states, reuseStateDefinitions = !0) {
623
- if (shape.name = name, shape.data = data, shape.delegate = delegateShape, !reuseStateDefinitions) return void (shape.states = merge({}, DEFAULT_STATES, states));
624
- const source = null != states ? states : DEFAULT_STATES, cached = this._stateDefinitionsCache.get(source);
625
- if (cached) return shape.states = cached.definitions, void shape.setStateDefinitionsWithCompiled(cached.definitions, cached.compiledDefinitions);
626
- const definitions = states ? merge({}, DEFAULT_STATES, states) : DEFAULT_STATES, entry = {
627
- definitions: definitions,
628
- compiledDefinitions: (new StateDefinitionCompiler).compile(definitions)
629
- };
630
- this._stateDefinitionsCache.set(source, entry), shape.states = entry.definitions,
631
- shape.setStateDefinitionsWithCompiled(entry.definitions, entry.compiledDefinitions);
617
+ _appendDataToShape(shape, name, data, delegateShape, states = {}) {
618
+ shape.name = name, shape.data = data, shape.delegate = delegateShape, shape.states = merge({}, DEFAULT_STATES, states);
632
619
  }
633
620
  _dispatchLegendEvent(eventName, legendItem, event) {
634
621
  const currentSelectedItems = this._getSelectedLegends();
@@ -645,18 +632,13 @@ export class DiscreteLegend extends LegendBase {
645
632
  }
646
633
  _handleStyle(config, item, isSelected, index, items) {
647
634
  const newConfig = {};
648
- if (config.style && (isFunction(config.style) ? newConfig.style = config.style(item, isSelected, index, items) : newConfig.style = config.style),
649
- config.state) {
650
- const stateKeys = Object.keys(config.state), hasStateFunction = stateKeys.some((key => isFunction(config.state[key])));
651
- newConfig.reuseStateDefinitions = !hasStateFunction, hasStateFunction ? (newConfig.state = {},
652
- stateKeys.forEach((key => {
653
- config.state[key] && (newConfig.state[key] = isFunction(config.state[key]) ? config.state[key](item, isSelected, index, items) : config.state[key]);
654
- }))) : newConfig.state = config.state;
655
- }
656
- return newConfig;
635
+ return config.style && (isFunction(config.style) ? newConfig.style = config.style(item, isSelected, index, items) : newConfig.style = config.style),
636
+ config.state && (newConfig.state = {}, Object.keys(config.state).forEach((key => {
637
+ config.state[key] && (isFunction(config.state[key]) ? newConfig.state[key] = config.state[key](item, isSelected, index, items) : newConfig.state[key] = config.state[key]);
638
+ }))), newConfig;
657
639
  }
658
640
  release() {
659
- this._stateDefinitionsCache = new WeakMap, super.release(), this.removeAllEventListeners();
641
+ super.release(), this.removeAllEventListeners();
660
642
  }
661
643
  }
662
644