@visactor/vrender-components 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/cjs/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const version = "1.1.4-alpha.1";
1
+ export declare const version = "1.1.4-alpha.2";
2
2
  export * from './core/base';
3
3
  export { AbstractComponent } from './core/base';
4
4
  export * from './core/type';
package/cjs/index.js CHANGED
@@ -18,7 +18,7 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
18
18
  Object.defineProperty(exports, "__esModule", {
19
19
  value: !0
20
20
  }), exports.labelSmartInvert = exports.IOperateType = exports.Brush = exports.PlayerEventEnum = exports.ContinuousPlayer = exports.DiscretePlayer = exports.Indicator = exports.Title = exports.SizeContinuousLegend = exports.ColorContinuousLegend = exports.registerMarkPointAnimate = exports.MarkPoint = exports.registerMarkArcAreaAnimate = exports.MarkArcArea = exports.registerMarkArcLineAnimate = exports.MarkArcLine = exports.registerMarkAreaAnimate = exports.MarkArea = exports.registerMarkLineAnimate = exports.MarkLine = exports.DataZoom = exports.Segment = exports.CircleAxisGrid = exports.LineAxisGrid = exports.polarAngleAxisDiscreteTicks = exports.continuousTicks = exports.CircleAxis = exports.LineAxis = exports.registerSymbolDataLabel = exports.DataLabel = exports.PolygonCrosshair = exports.SectorCrosshair = exports.CircleCrosshair = exports.LineCrosshair = exports.loadPoptip = exports.loadScrollbar = exports.ScrollBar = exports.AbstractComponent = exports.version = void 0,
21
- exports.version = "1.1.4-alpha.1", __exportStar(require("./core/base"), exports);
21
+ exports.version = "1.1.4-alpha.2", __exportStar(require("./core/base"), exports);
22
22
 
23
23
  var base_1 = require("./core/base");
24
24
 
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,eAAe,CAAC;AAEvC,8CAA4B;AAC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AE,iHAAA,wBAAwB,OAAA;AAC5C,0CAAwB;AACxB,2CAAyB;AACzB,8CAA6D;AAApD,8GAAA,qBAAqB,OAAA;AAC9B,2CAA0D;AAAjD,4GAAA,oBAAoB,OAAA;AAC7B,0CAAwB;AACxB,uCAAsC;AAA7B,8FAAA,KAAK,OAAA;AACd,8CAA4B;AAC5B,mDAAkD;AAAzC,sGAAA,SAAS,OAAA;AAClB,2CAAyB;AACzB,8CAA4B;AAC5B,2CAAyB;AACzB,4DAA0D;AAAjD,iHAAA,cAAc,OAAA;AACvB,gEAA8D;AAArD,qHAAA,gBAAgB,OAAA;AACzB,6CAAsD;AAA7C,wGAAA,eAAe,OAAA;AACxB,0CAAwB;AACxB,uCAAsC;AAA7B,8FAAA,KAAK,OAAA;AACd,qCAA4C;AAAnC,oGAAA,YAAY,OAAA;AACrB,4CAA0B;AAC1B,6CAA2B;AAC3B,8CAA4B;AAC5B,wCAAsB;AACtB,6CAA2B;AAC3B,0CAAwB;AACxB,8CAA4B;AAC5B,4CAA0B;AAC1B,yCAAuB;AACvB,8DAA4D;AAAnD,qHAAA,gBAAgB,OAAA;AACzB,2CAAyB;AACzB,+CAA6B;AAC7B,wDAAsC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"1.1.4-alpha.1\";\n\nexport * from './core/base';\nexport { AbstractComponent } from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport { ScrollBar } from './scrollbar/scrollbar';\nexport { loadScrollbar } from './scrollbar/module';\nexport * from './tag';\nexport * from './poptip';\nexport { loadPoptip } from './poptip/module';\nexport * from './crosshair';\nexport { LineCrosshair } from './crosshair/line';\nexport { CircleCrosshair } from './crosshair/circle';\nexport { SectorCrosshair } from './crosshair/sector';\nexport { PolygonCrosshair } from './crosshair/polygon';\nexport * from './label';\nexport { DataLabel } from './label/dataLabel';\nexport { registerSymbolDataLabel } from './label/symbol';\nexport * from './axis';\nexport { LineAxis } from './axis/line';\nexport { CircleAxis } from './axis/circle';\nexport { continuousTicks } from './axis/tick-data/continuous';\nexport { polarAngleAxisDiscreteTicks } from './axis/tick-data/discrete/polar-angle';\nexport * from './axis/grid';\nexport { LineAxisGrid } from './axis/grid/line';\nexport { CircleAxisGrid } from './axis/grid/circle';\nexport * from './segment';\nexport { Segment } from './segment/segment';\nexport * from './data-zoom';\nexport { DataZoom } from './data-zoom/data-zoom';\nexport * from './marker';\nexport { MarkLine, registerMarkLineAnimate } from './marker/line';\nexport { MarkArea, registerMarkAreaAnimate } from './marker/area';\nexport { MarkArcLine, registerMarkArcLineAnimate } from './marker/arc-line';\nexport { MarkArcArea, registerMarkArcAreaAnimate } from './marker/arc-area';\nexport { MarkPoint, registerMarkPointAnimate } from './marker/point';\nexport * from './pager';\nexport * from './legend';\nexport { ColorContinuousLegend } from './legend/color/color';\nexport { SizeContinuousLegend } from './legend/size/size';\nexport * from './title';\nexport { Title } from './title/title';\nexport * from './indicator';\nexport { Indicator } from './indicator/indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport { DiscretePlayer } from './player/discrete-player';\nexport { ContinuousPlayer } from './player/continuous-player';\nexport { PlayerEventEnum } from './player/type/event';\nexport * from './brush';\nexport { Brush } from './brush/brush';\nexport { IOperateType } from './brush/type';\nexport * from './tooltip';\nexport * from './timeline';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './radio';\nexport * from './empty-tip';\nexport * from './weather';\nexport * from './util';\nexport { labelSmartInvert } from './util/label-smartInvert';\nexport * from './switch';\nexport * from './label-item';\nexport * from './table-series-number';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,eAAe,CAAC;AAEvC,8CAA4B;AAC5B,oCAAgD;AAAvC,yGAAA,iBAAiB,OAAA;AAC1B,8CAA4B;AAC5B,8CAA4B;AAC5B,mDAAkD;AAAzC,sGAAA,SAAS,OAAA;AAClB,6CAAmD;AAA1C,uGAAA,aAAa,OA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AAwB;AACxB,uCAAsC;AAA7B,8FAAA,KAAK,OAAA;AACd,8CAA4B;AAC5B,mDAAkD;AAAzC,sGAAA,SAAS,OAAA;AAClB,2CAAyB;AACzB,8CAA4B;AAC5B,2CAAyB;AACzB,4DAA0D;AAAjD,iHAAA,cAAc,OAAA;AACvB,gEAA8D;AAArD,qHAAA,gBAAgB,OAAA;AACzB,6CAAsD;AAA7C,wGAAA,eAAe,OAAA;AACxB,0CAAwB;AACxB,uCAAsC;AAA7B,8FAAA,KAAK,OAAA;AACd,qCAA4C;AAAnC,oGAAA,YAAY,OAAA;AACrB,4CAA0B;AAC1B,6CAA2B;AAC3B,8CAA4B;AAC5B,wCAAsB;AACtB,6CAA2B;AAC3B,0CAAwB;AACxB,8CAA4B;AAC5B,4CAA0B;AAC1B,yCAAuB;AACvB,8DAA4D;AAAnD,qHAAA,gBAAgB,OAAA;AACzB,2CAAyB;AACzB,+CAA6B;AAC7B,wDAAsC","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"]}
@@ -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;
@@ -14,7 +14,7 @@ Object.defineProperty(exports, "__esModule", {
14
14
  value: !0
15
15
  }), exports.DiscreteLegend = void 0;
16
16
 
17
- const vutils_1 = require("@visactor/vutils"), graphic_creator_1 = require("../../util/graphic-creator"), base_1 = require("../base"), pager_1 = require("../../pager"), constant_1 = require("../constant"), register_1 = require("../register"), util_1 = require("../../util"), scrollbar_1 = require("../../scrollbar"), static_truth_1 = require("../../animation/static-truth"), DEFAULT_STATES = {
17
+ const vutils_1 = require("@visactor/vutils"), vrender_core_1 = require("@visactor/vrender-core"), graphic_creator_1 = require("../../util/graphic-creator"), base_1 = require("../base"), pager_1 = require("../../pager"), constant_1 = require("../constant"), register_1 = require("../register"), util_1 = require("../../util"), scrollbar_1 = require("../../scrollbar"), static_truth_1 = require("../../animation/static-truth"), DEFAULT_STATES = {
18
18
  [constant_1.LegendStateValue.focus]: {},
19
19
  [constant_1.LegendStateValue.selected]: {},
20
20
  [constant_1.LegendStateValue.selectedHover]: {},
@@ -28,7 +28,8 @@ class DiscreteLegend extends base_1.LegendBase {
28
28
  constructor(attributes, options) {
29
29
  super((null == options ? void 0 : options.skipDefault) ? attributes : (0, vutils_1.merge)({}, DiscreteLegend.defaultAttributes, attributes)),
30
30
  this.name = "discreteLegend", this._itemsContainer = null, this._itemHeightByUser = void 0,
31
- this._itemHeight = 0, this._itemMaxWidth = 0, this._contentMaxHeight = 0, this._onHover = e => {
31
+ this._itemHeight = 0, this._itemMaxWidth = 0, this._contentMaxHeight = 0, this._stateDefinitionsCache = new WeakMap,
32
+ this._onHover = e => {
32
33
  const target = e.target;
33
34
  if (target && target.name && target.name.startsWith(constant_1.LEGEND_ELEMENT_NAME.item)) {
34
35
  const legendItem = target.delegate;
@@ -78,7 +79,7 @@ class DiscreteLegend extends base_1.LegendBase {
78
79
  };
79
80
  }
80
81
  render() {
81
- super.render(), this._lastActiveItem = null;
82
+ this._stateDefinitionsCache = new WeakMap, super.render(), this._lastActiveItem = null;
82
83
  }
83
84
  setSelected(selectedData) {
84
85
  var _a;
@@ -199,7 +200,7 @@ class DiscreteLegend extends base_1.LegendBase {
199
200
  }), this._appendDataToShape(itemGroup, constant_1.LEGEND_ELEMENT_NAME.item, item, itemGroup)) : (itemGroup = graphic_creator_1.graphicCreator.group(Object.assign({
200
201
  x: 0,
201
202
  y: 0
202
- }, backgroundStyle.style)), this._appendDataToShape(itemGroup, constant_1.LEGEND_ELEMENT_NAME.item, item, itemGroup, backgroundStyle.state)),
203
+ }, backgroundStyle.style)), this._appendDataToShape(itemGroup, constant_1.LEGEND_ELEMENT_NAME.item, item, itemGroup, backgroundStyle.state, backgroundStyle.reuseStateDefinitions)),
203
204
  itemGroup.id = `${null != id ? id : label}-${index}`, itemGroup.addState(isSelected ? constant_1.LegendStateValue.selected : constant_1.LegendStateValue.unSelected);
204
205
  const innerGroup = graphic_creator_1.graphicCreator.group({
205
206
  x: 0,
@@ -216,12 +217,16 @@ class DiscreteLegend extends base_1.LegendBase {
216
217
  y: 0,
217
218
  symbolType: "circle",
218
219
  strokeBoundsBuffer: 0
219
- }, shape), shapeStyle.style));
220
- Object.keys(shapeStyle.state || {}).forEach((key => {
221
- const color = shapeStyle.state[key].fill || shapeStyle.state[key].stroke;
222
- shape.fill && (0, vutils_1.isNil)(shapeStyle.state[key].fill) && color && (shapeStyle.state[key].fill = color),
223
- shape.stroke && (0, vutils_1.isNil)(shapeStyle.state[key].stroke) && color && (shapeStyle.state[key].stroke = color);
224
- })), this._appendDataToShape(itemShape, constant_1.LEGEND_ELEMENT_NAME.itemShape, item, itemGroup, shapeStyle.state),
220
+ }, shape), shapeStyle.style)), shapeStateNeedsItemColor = Object.keys(shapeStyle.state || {}).some((key => {
221
+ const state = shapeStyle.state[key];
222
+ return !!(state.fill || state.stroke) && (!!shape.fill && (0, vutils_1.isNil)(state.fill) || !!shape.stroke && (0,
223
+ vutils_1.isNil)(state.stroke));
224
+ })), shapeStates = shapeStateNeedsItemColor ? (0, vutils_1.merge)({}, shapeStyle.state) : shapeStyle.state;
225
+ Object.keys(shapeStates || {}).forEach((key => {
226
+ const state = shapeStates[key], color = state.fill || state.stroke;
227
+ shape.fill && (0, vutils_1.isNil)(state.fill) && color && (state.fill = color),
228
+ shape.stroke && (0, vutils_1.isNil)(state.stroke) && color && (state.stroke = color);
229
+ })), this._appendDataToShape(itemShape, constant_1.LEGEND_ELEMENT_NAME.itemShape, item, itemGroup, shapeStates, !shapeStateNeedsItemColor && !1 !== shapeStyle.reuseStateDefinitions),
225
230
  itemShape.addState(isSelected ? constant_1.LegendStateValue.selected : constant_1.LegendStateValue.unSelected),
226
231
  innerGroup.add(itemShape);
227
232
  }
@@ -249,7 +254,7 @@ class DiscreteLegend extends base_1.LegendBase {
249
254
  text: text,
250
255
  _originText: labelAttr.formatMethod ? label : void 0
251
256
  }), labelShape = (0, util_1.createTextGraphicByType)(labelAttributes);
252
- this._appendDataToShape(labelShape, constant_1.LEGEND_ELEMENT_NAME.itemLabel, item, itemGroup, labelStyle.state),
257
+ this._appendDataToShape(labelShape, constant_1.LEGEND_ELEMENT_NAME.itemLabel, item, itemGroup, labelStyle.state, labelStyle.reuseStateDefinitions),
253
258
  labelShape.addState(isSelected ? constant_1.LegendStateValue.selected : constant_1.LegendStateValue.unSelected),
254
259
  innerGroup.add(labelShape);
255
260
  const labelSpace = (0, vutils_1.get)(labelAttr, "space", constant_1.DEFAULT_LABEL_SPACE);
@@ -264,7 +269,7 @@ class DiscreteLegend extends base_1.LegendBase {
264
269
  text: valueText,
265
270
  _originText: valueAttr.formatMethod ? value : void 0
266
271
  }), valueShape = (0, util_1.createTextGraphicByType)(valueAttributes);
267
- if (this._appendDataToShape(valueShape, constant_1.LEGEND_ELEMENT_NAME.itemValue, item, itemGroup, valueStyle.state),
272
+ if (this._appendDataToShape(valueShape, constant_1.LEGEND_ELEMENT_NAME.itemValue, item, itemGroup, valueStyle.state, valueStyle.reuseStateDefinitions),
268
273
  valueShape.addState(isSelected ? constant_1.LegendStateValue.selected : constant_1.LegendStateValue.unSelected),
269
274
  this._itemWidthByUser) {
270
275
  const layoutWidth = this._itemWidthByUser - parsedPadding[1] - parsedPadding[3] - shapeSize - shapeSpace - labelSpace - focusSpace - valueSpace;
@@ -335,20 +340,25 @@ class DiscreteLegend extends base_1.LegendBase {
335
340
  }));
336
341
  }
337
342
  _updatePositionOfPager(renderStartY, compWidth, compHeight) {
338
- const {pager: pager} = this.attribute, {totalPage: totalPage, isHorizontal: isHorizontal} = this._itemContext, position = pager && pager.position || "middle";
343
+ var _a;
344
+ const {pager: pager} = this.attribute, {totalPage: totalPage, isHorizontal: isHorizontal} = this._itemContext, position = pager && pager.position || "middle", hugContent = !(!pager || !pager.hugContent), pagerSpace = null !== (_a = pager && pager.space) && void 0 !== _a ? _a : constant_1.DEFAULT_PAGER_SPACE;
339
345
  if (this._pagerComponent.setTotal(totalPage), isHorizontal) {
340
346
  let y;
341
- y = "start" === position ? renderStartY : "end" === position ? renderStartY + compHeight - this._pagerComponent.AABBBounds.height() / 2 : renderStartY + compHeight / 2 - this._pagerComponent.AABBBounds.height() / 2,
347
+ y = "start" === position ? renderStartY : "end" === position ? renderStartY + compHeight - this._pagerComponent.AABBBounds.height() / 2 : renderStartY + compHeight / 2 - this._pagerComponent.AABBBounds.height() / 2;
348
+ let x = compWidth - this._pagerComponent.AABBBounds.width();
349
+ hugContent && (x = Math.max(0, Math.min(this._itemsContainer.AABBBounds.width() + pagerSpace, x))),
342
350
  this._pagerComponent.setAttributes({
343
- x: compWidth - this._pagerComponent.AABBBounds.width(),
351
+ x: x,
344
352
  y: y
345
353
  });
346
354
  } else {
347
355
  let x;
348
- x = "start" === position ? 0 : "end" === position ? compWidth - this._pagerComponent.AABBBounds.width() : (compWidth - this._pagerComponent.AABBBounds.width()) / 2,
356
+ x = "start" === position ? 0 : "end" === position ? compWidth - this._pagerComponent.AABBBounds.width() : (compWidth - this._pagerComponent.AABBBounds.width()) / 2;
357
+ let y = compHeight - this._pagerComponent.AABBBounds.height();
358
+ hugContent && (y = Math.max(0, Math.min(renderStartY + this._itemsContainer.AABBBounds.height() + pagerSpace, y))),
349
359
  this._pagerComponent.setAttributes({
350
360
  x: x,
351
- y: compHeight - this._pagerComponent.AABBBounds.height()
361
+ y: y
352
362
  });
353
363
  }
354
364
  }
@@ -453,11 +463,14 @@ class DiscreteLegend extends base_1.LegendBase {
453
463
  this._itemContext.totalPage = total, this._updatePositionOfPager(renderStartY, compWidth, compHeight);
454
464
  }
455
465
  defaultCurrent > 1 && (isHorizontal ? itemsContainer.setAttribute("y", -(defaultCurrent - 1) * (compHeight + spaceRow)) : itemsContainer.setAttribute("x", -(defaultCurrent - 1) * (compWidth + spaceCol)));
466
+ const hugContent = !!pager.hugContent;
467
+ let clipWidth = isHorizontal ? contentWidth : compWidth, clipHeight = isHorizontal ? compHeight : contentHeight;
468
+ hugContent && (isHorizontal ? clipWidth = Math.max(0, Math.min(clipWidth, itemsContainer.AABBBounds.width())) : clipHeight = Math.max(0, Math.min(clipHeight, itemsContainer.AABBBounds.height())));
456
469
  const clipGroup = graphic_creator_1.graphicCreator.group({
457
470
  x: 0,
458
471
  y: renderStartY,
459
- width: isHorizontal ? contentWidth : compWidth,
460
- height: isHorizontal ? compHeight : contentHeight,
472
+ width: clipWidth,
473
+ height: clipHeight,
461
474
  clip: !0,
462
475
  pickable: !1
463
476
  });
@@ -600,9 +613,17 @@ class DiscreteLegend extends base_1.LegendBase {
600
613
  item.hasState(constant_1.LegendStateValue.selected) && selectedData.push(item.data);
601
614
  })), selectedData;
602
615
  }
603
- _appendDataToShape(shape, name, data, delegateShape, states = {}) {
604
- shape.name = name, shape.data = data, shape.delegate = delegateShape, shape.states = (0,
605
- vutils_1.merge)({}, DEFAULT_STATES, states);
616
+ _appendDataToShape(shape, name, data, delegateShape, states, reuseStateDefinitions = !0) {
617
+ if (shape.name = name, shape.data = data, shape.delegate = delegateShape, !reuseStateDefinitions) return void (shape.states = (0,
618
+ vutils_1.merge)({}, DEFAULT_STATES, states));
619
+ const source = null != states ? states : DEFAULT_STATES, cached = this._stateDefinitionsCache.get(source);
620
+ if (cached) return shape.states = cached.definitions, void shape.setStateDefinitionsWithCompiled(cached.definitions, cached.compiledDefinitions);
621
+ const definitions = states ? (0, vutils_1.merge)({}, DEFAULT_STATES, states) : DEFAULT_STATES, entry = {
622
+ definitions: definitions,
623
+ compiledDefinitions: (new vrender_core_1.StateDefinitionCompiler).compile(definitions)
624
+ };
625
+ this._stateDefinitionsCache.set(source, entry), shape.states = entry.definitions,
626
+ shape.setStateDefinitionsWithCompiled(entry.definitions, entry.compiledDefinitions);
606
627
  }
607
628
  _dispatchLegendEvent(eventName, legendItem, event) {
608
629
  const currentSelectedItems = this._getSelectedLegends();
@@ -619,13 +640,19 @@ class DiscreteLegend extends base_1.LegendBase {
619
640
  }
620
641
  _handleStyle(config, item, isSelected, index, items) {
621
642
  const newConfig = {};
622
- return config.style && ((0, vutils_1.isFunction)(config.style) ? newConfig.style = config.style(item, isSelected, index, items) : newConfig.style = config.style),
623
- config.state && (newConfig.state = {}, Object.keys(config.state).forEach((key => {
624
- config.state[key] && ((0, vutils_1.isFunction)(config.state[key]) ? newConfig.state[key] = config.state[key](item, isSelected, index, items) : newConfig.state[key] = config.state[key]);
625
- }))), newConfig;
643
+ if (config.style && ((0, vutils_1.isFunction)(config.style) ? newConfig.style = config.style(item, isSelected, index, items) : newConfig.style = config.style),
644
+ config.state) {
645
+ const stateKeys = Object.keys(config.state), hasStateFunction = stateKeys.some((key => (0,
646
+ vutils_1.isFunction)(config.state[key])));
647
+ newConfig.reuseStateDefinitions = !hasStateFunction, hasStateFunction ? (newConfig.state = {},
648
+ stateKeys.forEach((key => {
649
+ config.state[key] && (newConfig.state[key] = (0, vutils_1.isFunction)(config.state[key]) ? config.state[key](item, isSelected, index, items) : config.state[key]);
650
+ }))) : newConfig.state = config.state;
651
+ }
652
+ return newConfig;
626
653
  }
627
654
  release() {
628
- super.release(), this.removeAllEventListeners();
655
+ this._stateDefinitionsCache = new WeakMap, super.release(), this.removeAllEventListeners();
629
656
  }
630
657
  }
631
658