@visactor/vrender-components 1.1.8-alpha.0 → 1.1.8-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/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/legend/discrete/discrete.d.ts +1 -0
- package/cjs/legend/discrete/discrete.js +30 -15
- package/cjs/legend/discrete/discrete.js.map +1 -1
- package/dist/index.es.js +117 -56
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/legend/discrete/discrete.d.ts +1 -0
- package/es/legend/discrete/discrete.js +29 -13
- package/es/legend/discrete/discrete.js.map +1 -1
- package/package.json +4 -4
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,
|
|
@@ -4887,14 +4887,17 @@ class GraphicImpl extends Node {
|
|
|
4887
4887
|
}
|
|
4888
4888
|
return null === (_a = this.stage) || void 0 === _a ? void 0 : _a.rootSharedStateScope;
|
|
4889
4889
|
}
|
|
4890
|
-
|
|
4890
|
+
syncSharedStateScopeBinding(nextScope, markDirty = !0) {
|
|
4891
4891
|
var _a;
|
|
4892
|
-
const nextScope = this.resolveBoundSharedStateScope();
|
|
4893
4892
|
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);
|
|
4894
4893
|
}
|
|
4895
|
-
|
|
4894
|
+
syncSharedStateScopeBindingFromTree(markDirty = !0, inheritedSharedStateScope) {
|
|
4895
|
+
const nextScope = void 0 === inheritedSharedStateScope ? this.resolveBoundSharedStateScope() : null != inheritedSharedStateScope ? inheritedSharedStateScope : void 0;
|
|
4896
|
+
return this.syncSharedStateScopeBinding(nextScope, markDirty);
|
|
4897
|
+
}
|
|
4898
|
+
syncSharedStateScopeBindingOnTreeChange(markDirty = !0, inheritedSharedStateScope) {
|
|
4896
4899
|
var _a, _b;
|
|
4897
|
-
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);
|
|
4900
|
+
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);
|
|
4898
4901
|
}
|
|
4899
4902
|
syncSharedStateActiveRegistrations() {
|
|
4900
4903
|
var _a;
|
|
@@ -4902,6 +4905,7 @@ class GraphicImpl extends Node {
|
|
|
4902
4905
|
if (!(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || !this.boundSharedStateScope) return (null == previousScopes ? void 0 : previousScopes.size) && (previousScopes.forEach(scope => {
|
|
4903
4906
|
scope.subtreeActiveDescendants.delete(this);
|
|
4904
4907
|
}), previousScopes.clear()), void (this.registeredActiveScopes = void 0);
|
|
4908
|
+
if ((null == previousScopes ? void 0 : previousScopes.size) && this.isSharedStateScopeChainRegistered(previousScopes)) return;
|
|
4905
4909
|
const nextScopes = new Set(collectSharedStateScopeChain(this.boundSharedStateScope));
|
|
4906
4910
|
null == previousScopes || previousScopes.forEach(scope => {
|
|
4907
4911
|
nextScopes.has(scope) || scope.subtreeActiveDescendants.delete(this);
|
|
@@ -4909,6 +4913,15 @@ class GraphicImpl extends Node {
|
|
|
4909
4913
|
scope.subtreeActiveDescendants.add(this);
|
|
4910
4914
|
}), this.registeredActiveScopes = nextScopes;
|
|
4911
4915
|
}
|
|
4916
|
+
isSharedStateScopeChainRegistered(previousScopes) {
|
|
4917
|
+
let scope = this.boundSharedStateScope,
|
|
4918
|
+
scopeCount = 0;
|
|
4919
|
+
for (; scope;) {
|
|
4920
|
+
if (!previousScopes.has(scope)) return !1;
|
|
4921
|
+
scopeCount += 1, scope = scope.parentScope;
|
|
4922
|
+
}
|
|
4923
|
+
return scopeCount === previousScopes.size;
|
|
4924
|
+
}
|
|
4912
4925
|
clearSharedStateActiveRegistrations() {
|
|
4913
4926
|
const previousScopes = this.registeredActiveScopes;
|
|
4914
4927
|
previousScopes && (previousScopes.forEach(scope => {
|
|
@@ -4918,8 +4931,8 @@ class GraphicImpl extends Node {
|
|
|
4918
4931
|
markSharedStateDirty() {
|
|
4919
4932
|
this.sharedStateDirty = !0, enqueueGraphicSharedStateRefresh(this.stage, this), scheduleStageSharedStateRefresh(this.stage);
|
|
4920
4933
|
}
|
|
4921
|
-
onParentSharedStateTreeChanged(stage, layer) {
|
|
4922
|
-
this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange() : this.setStage(stage, layer);
|
|
4934
|
+
onParentSharedStateTreeChanged(stage, layer, inheritedSharedStateScope) {
|
|
4935
|
+
this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope) : this.setStage(stage, layer, inheritedSharedStateScope);
|
|
4923
4936
|
}
|
|
4924
4937
|
refreshSharedStateBeforeRender() {
|
|
4925
4938
|
var _a;
|
|
@@ -5569,6 +5582,10 @@ class GraphicImpl extends Node {
|
|
|
5569
5582
|
var _a;
|
|
5570
5583
|
return null === (_a = this.states) || void 0 === _a ? void 0 : _a[stateName];
|
|
5571
5584
|
}
|
|
5585
|
+
setStateDefinitionsWithCompiled(definitions, compiledDefinitions) {
|
|
5586
|
+
var _a;
|
|
5587
|
+
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}`;
|
|
5588
|
+
}
|
|
5572
5589
|
getStateResolveBaseAttrs() {
|
|
5573
5590
|
var _a;
|
|
5574
5591
|
return null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute;
|
|
@@ -5688,6 +5705,11 @@ class GraphicImpl extends Node {
|
|
|
5688
5705
|
}
|
|
5689
5706
|
return !0;
|
|
5690
5707
|
}
|
|
5708
|
+
hasStatePatch(patch) {
|
|
5709
|
+
if (!patch) return !1;
|
|
5710
|
+
for (const key in patch) if (Object.prototype.hasOwnProperty.call(patch, key)) return !0;
|
|
5711
|
+
return !1;
|
|
5712
|
+
}
|
|
5691
5713
|
commitSameStatePatchRefresh(states, hasAnimation, animateSameStatePatchChange = !1) {
|
|
5692
5714
|
var _a;
|
|
5693
5715
|
const previousStates = null !== (_a = this.currentStates) && void 0 !== _a ? _a : EMPTY_STATE_NAMES,
|
|
@@ -5755,15 +5777,17 @@ class GraphicImpl extends Node {
|
|
|
5755
5777
|
transition = this.resolveClearStatesTransition();
|
|
5756
5778
|
if (!transition.changed && 0 === previousStates.length) return this.currentStates = [], this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1, void this.clearSharedStateActiveRegistrations();
|
|
5757
5779
|
const resolvedStateAttrs = hasAnimation || this.hasCustomEvent("beforeStateUpdate") ? cloneAttributeValue(null !== (_b = this.baseAttributes) && void 0 !== _b ? _b : {}) : null !== (_c = this.baseAttributes) && void 0 !== _c ? _c : {};
|
|
5758
|
-
if (!transition.changed || this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !0)) if (this.currentStates = transition.states, this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1, this.clearSharedStateActiveRegistrations(),
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5780
|
+
if (!transition.changed || this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !0)) if (this.currentStates = transition.states, this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1, this.clearSharedStateActiveRegistrations(), this.attributeMayContainTransientAttrs || this.hasStatePatch(previousResolvedStatePatch)) {
|
|
5781
|
+
if (hasAnimation) {
|
|
5782
|
+
this._syncFinalAttributeFromStaticTruth();
|
|
5783
|
+
const removedStateAnimationAttrs = this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch);
|
|
5784
|
+
this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0, void 0, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.extraAttrs, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.stateTransitionTargetAttrs);
|
|
5785
|
+
} else this.stopStateAnimates(), this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
|
|
5786
|
+
type: AttributeUpdateType.STATE
|
|
5787
|
+
}) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, void 0, {
|
|
5788
|
+
type: AttributeUpdateType.STATE
|
|
5789
|
+
}), this.emitStateUpdateEvent();
|
|
5790
|
+
} else this.emitStateUpdateEvent();
|
|
5767
5791
|
}
|
|
5768
5792
|
removeState(stateName, hasAnimation) {
|
|
5769
5793
|
const transition = this.resolveRemoveStateTransition(stateName);
|
|
@@ -5804,15 +5828,17 @@ class GraphicImpl extends Node {
|
|
|
5804
5828
|
effectiveStates: effectiveStates,
|
|
5805
5829
|
resolvedStateAttrs: resolvedStateAttrs
|
|
5806
5830
|
} = this.resolveGraphicStateTransition(states);
|
|
5807
|
-
if ((transition.changed || !this.sameStateNames(previousStates, transition.states)) && this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1)) if (this.currentStates = transition.states, this.effectiveStates = [...effectiveStates], this.resolvedStatePatch = resolvedStateAttrs, this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(),
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5831
|
+
if ((transition.changed || !this.sameStateNames(previousStates, transition.states)) && this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1)) if (this.currentStates = transition.states, this.effectiveStates = [...effectiveStates], this.resolvedStatePatch = resolvedStateAttrs, this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), this.attributeMayContainTransientAttrs || this.hasStatePatch(previousResolvedStatePatch) || this.hasStatePatch(resolvedStateAttrs)) {
|
|
5832
|
+
if (hasAnimation) {
|
|
5833
|
+
this._syncFinalAttributeFromStaticTruth();
|
|
5834
|
+
const removedStateAnimationAttrs = this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch);
|
|
5835
|
+
this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.extraAttrs, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.stateTransitionTargetAttrs);
|
|
5836
|
+
} else this.stopStateAnimates(), this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
|
|
5837
|
+
type: AttributeUpdateType.STATE
|
|
5838
|
+
}) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, this.resolvedStatePatch, {
|
|
5839
|
+
type: AttributeUpdateType.STATE
|
|
5840
|
+
}), this.emitStateUpdateEvent();
|
|
5841
|
+
} else this.emitStateUpdateEvent();
|
|
5816
5842
|
}
|
|
5817
5843
|
invalidateResolver() {
|
|
5818
5844
|
var _a, _b;
|
|
@@ -5932,12 +5958,12 @@ class GraphicImpl extends Node {
|
|
|
5932
5958
|
this._globalTransMatrix.translate(scrollX, scrollY);
|
|
5933
5959
|
}
|
|
5934
5960
|
}
|
|
5935
|
-
setStage(stage, layer) {
|
|
5961
|
+
setStage(stage, layer, inheritedSharedStateScope) {
|
|
5936
5962
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
5937
5963
|
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,
|
|
5938
5964
|
previousStage = this.stage;
|
|
5939
5965
|
if (this.stage !== stage || this.layer !== layer) {
|
|
5940
|
-
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()) {
|
|
5966
|
+
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()) {
|
|
5941
5967
|
const previousTimeline = null === (_f = null == previousStage ? void 0 : previousStage.getTimeline) || void 0 === _f ? void 0 : _f.call(previousStage),
|
|
5942
5968
|
nextTimeline = null === (_g = null == stage ? void 0 : stage.getTimeline) || void 0 === _g ? void 0 : _g.call(stage),
|
|
5943
5969
|
detachedStageAnimates = [];
|
|
@@ -5954,7 +5980,7 @@ class GraphicImpl extends Node {
|
|
|
5954
5980
|
}
|
|
5955
5981
|
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));
|
|
5956
5982
|
}
|
|
5957
|
-
((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);
|
|
5983
|
+
((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);
|
|
5958
5984
|
}
|
|
5959
5985
|
detachStageForRelease() {
|
|
5960
5986
|
var _a, _b, _c;
|
|
@@ -6376,13 +6402,13 @@ class Group extends Graphic {
|
|
|
6376
6402
|
child.setStage(null, null);
|
|
6377
6403
|
}), this.addUpdateBoundTag();
|
|
6378
6404
|
}
|
|
6379
|
-
setStage(stage, layer) {
|
|
6405
|
+
setStage(stage, layer, inheritedSharedStateScope) {
|
|
6380
6406
|
var _a, _b, _c, _d, _e, _f;
|
|
6381
6407
|
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,
|
|
6382
6408
|
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;
|
|
6383
|
-
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();
|
|
6409
|
+
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);
|
|
6384
6410
|
const layerChanged = this.layer !== layer;
|
|
6385
|
-
layerChanged && (this.layer = layer), needsSharedStateTreeSync ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0), this.notifyChildrenSharedStateTreeChanged()) : layerChanged && this.notifyChildrenSharedStateTreeChanged();
|
|
6411
|
+
layerChanged && (this.layer = layer), needsSharedStateTreeSync ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope), this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope)) : layerChanged && this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope);
|
|
6386
6412
|
}
|
|
6387
6413
|
addUpdatePositionTag() {
|
|
6388
6414
|
super.addUpdatePositionTag(), this.forEachChildren(g => {
|
|
@@ -6441,17 +6467,26 @@ class Group extends Graphic {
|
|
|
6441
6467
|
hasSharedStateDefinitions() {
|
|
6442
6468
|
return !!this._sharedStateDefinitions && Object.keys(this._sharedStateDefinitions).length > 0;
|
|
6443
6469
|
}
|
|
6444
|
-
|
|
6470
|
+
resolveChildSharedStateScope(inheritedSharedStateScope) {
|
|
6471
|
+
var _a;
|
|
6472
|
+
return this.sharedStateScope ? this.sharedStateScope : void 0 !== inheritedSharedStateScope ? inheritedSharedStateScope : null !== (_a = this.resolveBoundSharedStateScope()) && void 0 !== _a ? _a : null;
|
|
6473
|
+
}
|
|
6474
|
+
notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope) {
|
|
6475
|
+
const childSharedStateScope = this.resolveChildSharedStateScope(inheritedSharedStateScope);
|
|
6445
6476
|
this.forEachChildren(item => {
|
|
6446
|
-
this.
|
|
6477
|
+
this.setStageToChild(item, childSharedStateScope);
|
|
6447
6478
|
});
|
|
6448
6479
|
}
|
|
6449
|
-
|
|
6450
|
-
child
|
|
6480
|
+
setStageToChild(child, inheritedSharedStateScope) {
|
|
6481
|
+
const graphic = child;
|
|
6482
|
+
"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);
|
|
6483
|
+
}
|
|
6484
|
+
syncChildSharedStateTreeBinding(child, inheritedSharedStateScope) {
|
|
6485
|
+
void 0 === inheritedSharedStateScope && (inheritedSharedStateScope = this.resolveChildSharedStateScope()), this.setStageToChild(child, inheritedSharedStateScope);
|
|
6451
6486
|
}
|
|
6452
|
-
onParentSharedStateTreeChanged(stage, layer) {
|
|
6487
|
+
onParentSharedStateTreeChanged(stage, layer, inheritedSharedStateScope) {
|
|
6453
6488
|
var _a;
|
|
6454
|
-
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);
|
|
6489
|
+
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);
|
|
6455
6490
|
}
|
|
6456
6491
|
}
|
|
6457
6492
|
Group.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
|
|
@@ -9061,8 +9096,8 @@ class RichText extends Graphic {
|
|
|
9061
9096
|
clone() {
|
|
9062
9097
|
return new RichText(Object.assign({}, this.attribute));
|
|
9063
9098
|
}
|
|
9064
|
-
setStage(stage, layer) {
|
|
9065
|
-
super.setStage(stage, layer);
|
|
9099
|
+
setStage(stage, layer, inheritedSharedStateScope) {
|
|
9100
|
+
super.setStage(stage, layer, inheritedSharedStateScope);
|
|
9066
9101
|
this.getFrameCache().icons.forEach(icon => {
|
|
9067
9102
|
icon.setStage(stage, layer);
|
|
9068
9103
|
});
|
|
@@ -30266,6 +30301,7 @@ class DiscreteLegend extends LegendBase {
|
|
|
30266
30301
|
this._itemHeight = 0;
|
|
30267
30302
|
this._itemMaxWidth = 0;
|
|
30268
30303
|
this._contentMaxHeight = 0;
|
|
30304
|
+
this._stateDefinitionsCache = new WeakMap();
|
|
30269
30305
|
this._onHover = (e) => {
|
|
30270
30306
|
const target = e.target;
|
|
30271
30307
|
if (target && target.name && target.name.startsWith(LEGEND_ELEMENT_NAME.item)) {
|
|
@@ -30352,6 +30388,7 @@ class DiscreteLegend extends LegendBase {
|
|
|
30352
30388
|
};
|
|
30353
30389
|
}
|
|
30354
30390
|
render() {
|
|
30391
|
+
this._stateDefinitionsCache = new WeakMap();
|
|
30355
30392
|
super.render();
|
|
30356
30393
|
this._lastActiveItem = null;
|
|
30357
30394
|
}
|
|
@@ -30630,7 +30667,7 @@ class DiscreteLegend extends LegendBase {
|
|
|
30630
30667
|
}
|
|
30631
30668
|
else {
|
|
30632
30669
|
itemGroup = graphicCreator.group(Object.assign({ x: 0, y: 0 }, backgroundStyle.style));
|
|
30633
|
-
this._appendDataToShape(itemGroup, LEGEND_ELEMENT_NAME.item, item, itemGroup, backgroundStyle.state);
|
|
30670
|
+
this._appendDataToShape(itemGroup, LEGEND_ELEMENT_NAME.item, item, itemGroup, backgroundStyle.state, backgroundStyle.reuseStateDefinitions);
|
|
30634
30671
|
}
|
|
30635
30672
|
itemGroup.id = `${id !== null && id !== void 0 ? id : label}-${index}`;
|
|
30636
30673
|
itemGroup.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected);
|
|
@@ -30663,7 +30700,7 @@ class DiscreteLegend extends LegendBase {
|
|
|
30663
30700
|
shapeStyle.state[key].stroke = color;
|
|
30664
30701
|
}
|
|
30665
30702
|
});
|
|
30666
|
-
this._appendDataToShape(itemShape, LEGEND_ELEMENT_NAME.itemShape, item, itemGroup, shapeStyle.state);
|
|
30703
|
+
this._appendDataToShape(itemShape, LEGEND_ELEMENT_NAME.itemShape, item, itemGroup, shapeStyle.state, false);
|
|
30667
30704
|
itemShape.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected);
|
|
30668
30705
|
innerGroup.add(itemShape);
|
|
30669
30706
|
}
|
|
@@ -30678,7 +30715,7 @@ class DiscreteLegend extends LegendBase {
|
|
|
30678
30715
|
const text = labelAttr.formatMethod ? labelAttr.formatMethod(label, item, index) : label;
|
|
30679
30716
|
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 });
|
|
30680
30717
|
const labelShape = createTextGraphicByType(labelAttributes);
|
|
30681
|
-
this._appendDataToShape(labelShape, LEGEND_ELEMENT_NAME.itemLabel, item, itemGroup, labelStyle.state);
|
|
30718
|
+
this._appendDataToShape(labelShape, LEGEND_ELEMENT_NAME.itemLabel, item, itemGroup, labelStyle.state, labelStyle.reuseStateDefinitions);
|
|
30682
30719
|
labelShape.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected);
|
|
30683
30720
|
innerGroup.add(labelShape);
|
|
30684
30721
|
const labelSpace = get(labelAttr, 'space', DEFAULT_LABEL_SPACE);
|
|
@@ -30687,7 +30724,7 @@ class DiscreteLegend extends LegendBase {
|
|
|
30687
30724
|
const valueText = valueAttr.formatMethod ? valueAttr.formatMethod(value, item, index) : value;
|
|
30688
30725
|
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 });
|
|
30689
30726
|
const valueShape = createTextGraphicByType(valueAttributes);
|
|
30690
|
-
this._appendDataToShape(valueShape, LEGEND_ELEMENT_NAME.itemValue, item, itemGroup, valueStyle.state);
|
|
30727
|
+
this._appendDataToShape(valueShape, LEGEND_ELEMENT_NAME.itemValue, item, itemGroup, valueStyle.state, valueStyle.reuseStateDefinitions);
|
|
30691
30728
|
valueShape.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected);
|
|
30692
30729
|
if (this._itemWidthByUser) {
|
|
30693
30730
|
const layoutWidth = this._itemWidthByUser -
|
|
@@ -31339,11 +31376,29 @@ class DiscreteLegend extends LegendBase {
|
|
|
31339
31376
|
});
|
|
31340
31377
|
return selectedData;
|
|
31341
31378
|
}
|
|
31342
|
-
_appendDataToShape(shape, name, data, delegateShape, states =
|
|
31379
|
+
_appendDataToShape(shape, name, data, delegateShape, states, reuseStateDefinitions = true) {
|
|
31343
31380
|
shape.name = name;
|
|
31344
31381
|
shape.data = data;
|
|
31345
31382
|
shape.delegate = delegateShape;
|
|
31346
|
-
|
|
31383
|
+
if (!reuseStateDefinitions) {
|
|
31384
|
+
shape.states = merge({}, DEFAULT_STATES, states);
|
|
31385
|
+
return;
|
|
31386
|
+
}
|
|
31387
|
+
const source = states !== null && states !== void 0 ? states : DEFAULT_STATES;
|
|
31388
|
+
const cached = this._stateDefinitionsCache.get(source);
|
|
31389
|
+
if (cached) {
|
|
31390
|
+
shape.states = cached.definitions;
|
|
31391
|
+
shape.setStateDefinitionsWithCompiled(cached.definitions, cached.compiledDefinitions);
|
|
31392
|
+
return;
|
|
31393
|
+
}
|
|
31394
|
+
const definitions = states ? merge({}, DEFAULT_STATES, states) : DEFAULT_STATES;
|
|
31395
|
+
const entry = {
|
|
31396
|
+
definitions,
|
|
31397
|
+
compiledDefinitions: new StateDefinitionCompiler().compile(definitions)
|
|
31398
|
+
};
|
|
31399
|
+
this._stateDefinitionsCache.set(source, entry);
|
|
31400
|
+
shape.states = entry.definitions;
|
|
31401
|
+
shape.setStateDefinitionsWithCompiled(entry.definitions, entry.compiledDefinitions);
|
|
31347
31402
|
}
|
|
31348
31403
|
_dispatchLegendEvent(eventName, legendItem, event) {
|
|
31349
31404
|
const currentSelectedItems = this._getSelectedLegends();
|
|
@@ -31369,21 +31424,27 @@ class DiscreteLegend extends LegendBase {
|
|
|
31369
31424
|
}
|
|
31370
31425
|
}
|
|
31371
31426
|
if (config.state) {
|
|
31372
|
-
|
|
31373
|
-
|
|
31374
|
-
|
|
31375
|
-
|
|
31376
|
-
|
|
31377
|
-
|
|
31378
|
-
|
|
31379
|
-
|
|
31427
|
+
const stateKeys = Object.keys(config.state);
|
|
31428
|
+
const hasStateFunction = stateKeys.some(key => isFunction(config.state[key]));
|
|
31429
|
+
newConfig.reuseStateDefinitions = !hasStateFunction;
|
|
31430
|
+
if (!hasStateFunction) {
|
|
31431
|
+
newConfig.state = config.state;
|
|
31432
|
+
}
|
|
31433
|
+
else {
|
|
31434
|
+
newConfig.state = {};
|
|
31435
|
+
stateKeys.forEach(key => {
|
|
31436
|
+
if (config.state[key]) {
|
|
31437
|
+
newConfig.state[key] = isFunction(config.state[key])
|
|
31438
|
+
? config.state[key](item, isSelected, index, items)
|
|
31439
|
+
: config.state[key];
|
|
31380
31440
|
}
|
|
31381
|
-
}
|
|
31382
|
-
}
|
|
31441
|
+
});
|
|
31442
|
+
}
|
|
31383
31443
|
}
|
|
31384
31444
|
return newConfig;
|
|
31385
31445
|
}
|
|
31386
31446
|
release() {
|
|
31447
|
+
this._stateDefinitionsCache = new WeakMap();
|
|
31387
31448
|
super.release();
|
|
31388
31449
|
this.removeAllEventListeners();
|
|
31389
31450
|
}
|
|
@@ -36886,6 +36947,6 @@ TableSeriesNumber.defaultAttributes = {
|
|
|
36886
36947
|
select: true
|
|
36887
36948
|
};
|
|
36888
36949
|
|
|
36889
|
-
const version = "1.1.8-alpha.
|
|
36950
|
+
const version = "1.1.8-alpha.2";
|
|
36890
36951
|
|
|
36891
36952
|
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
package/es/index.js
CHANGED
package/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC;AAEvC,cAAc,aAAa,CAAC;AAC5B,OAAO,E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AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"1.1.8-alpha.
|
|
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,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,uCAAuC,CAAC;AACpF,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAo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Aa,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.8-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"]}
|
|
@@ -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.
|
|
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;
|
|
@@ -614,8 +617,16 @@ export class DiscreteLegend extends LegendBase {
|
|
|
614
617
|
item.hasState(LegendStateValue.selected) && selectedData.push(item.data);
|
|
615
618
|
})), selectedData;
|
|
616
619
|
}
|
|
617
|
-
_appendDataToShape(shape, name, data, delegateShape, states =
|
|
618
|
-
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);
|
|
619
630
|
}
|
|
620
631
|
_dispatchLegendEvent(eventName, legendItem, event) {
|
|
621
632
|
const currentSelectedItems = this._getSelectedLegends();
|
|
@@ -632,13 +643,18 @@ export class DiscreteLegend extends LegendBase {
|
|
|
632
643
|
}
|
|
633
644
|
_handleStyle(config, item, isSelected, index, items) {
|
|
634
645
|
const newConfig = {};
|
|
635
|
-
|
|
636
|
-
config.state
|
|
637
|
-
|
|
638
|
-
|
|
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;
|
|
639
655
|
}
|
|
640
656
|
release() {
|
|
641
|
-
super.release(), this.removeAllEventListeners();
|
|
657
|
+
this._stateDefinitionsCache = new WeakMap, super.release(), this.removeAllEventListeners();
|
|
642
658
|
}
|
|
643
659
|
}
|
|
644
660
|
|