zrender-nightly 5.4.4-dev.20231115 → 5.4.4-dev.20231116

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/zrender.js CHANGED
@@ -4053,6 +4053,26 @@
4053
4053
  Math.round(Math.random() * 255),
4054
4054
  Math.round(Math.random() * 255)
4055
4055
  ], 'rgb');
4056
+ }
4057
+ var liftedColorCache = new LRU(100);
4058
+ function liftColor(color) {
4059
+ if (isString(color)) {
4060
+ var liftedColor = liftedColorCache.get(color);
4061
+ if (!liftedColor) {
4062
+ liftedColor = lift(color, -0.1);
4063
+ liftedColorCache.put(color, liftedColor);
4064
+ }
4065
+ return liftedColor;
4066
+ }
4067
+ else if (isGradientObject(color)) {
4068
+ var ret = extend({}, color);
4069
+ ret.colorStops = map(color.colorStops, function (stop) { return ({
4070
+ offset: stop.offset,
4071
+ color: lift(stop.color, -0.1)
4072
+ }); });
4073
+ return ret;
4074
+ }
4075
+ return color;
4056
4076
  }
4057
4077
 
4058
4078
  var color = /*#__PURE__*/Object.freeze({
@@ -4068,7 +4088,8 @@
4068
4088
  modifyAlpha: modifyAlpha,
4069
4089
  stringify: stringify,
4070
4090
  lum: lum,
4071
- random: random
4091
+ random: random,
4092
+ liftColor: liftColor
4072
4093
  });
4073
4094
 
4074
4095
  var mathRound = Math.round;
@@ -6180,6 +6201,18 @@
6180
6201
  }
6181
6202
  }
6182
6203
  };
6204
+ Element.prototype.isSilent = function () {
6205
+ var isSilent = this.silent;
6206
+ var ancestor = this.parent;
6207
+ while (!isSilent && ancestor) {
6208
+ if (ancestor.silent) {
6209
+ isSilent = true;
6210
+ break;
6211
+ }
6212
+ ancestor = ancestor.parent;
6213
+ }
6214
+ return isSilent;
6215
+ };
6183
6216
  Element.prototype._updateAnimationTargets = function () {
6184
6217
  for (var i = 0; i < this.animators.length; i++) {
6185
6218
  var animator = this.animators[i];
@@ -7243,7 +7276,18 @@
7243
7276
  function registerPainter(name, Ctor) {
7244
7277
  painterCtors[name] = Ctor;
7245
7278
  }
7246
- var version = '5.4.4-dev.20231115';
7279
+ var ssrDataGetter = function (el) {
7280
+ return null;
7281
+ };
7282
+ function getElementSSRData(el) {
7283
+ if (typeof ssrDataGetter === 'function') {
7284
+ return ssrDataGetter(el);
7285
+ }
7286
+ }
7287
+ function registerSSRDataGetter(getter) {
7288
+ ssrDataGetter = getter;
7289
+ }
7290
+ var version = '5.4.4-dev.20231116';
7247
7291
 
7248
7292
  var STYLE_MAGIC_KEY = '__zr_style_' + Math.round((Math.random() * 10));
7249
7293
  var DEFAULT_COMMON_STYLE = {
@@ -15875,6 +15919,7 @@
15875
15919
  var XLINKNS = 'http://www.w3.org/1999/xlink';
15876
15920
  var XMLNS = 'http://www.w3.org/2000/xmlns/';
15877
15921
  var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
15922
+ var META_DATA_PREFIX = 'ecmeta_';
15878
15923
  function createElement(name) {
15879
15924
  return document.createElementNS(SVGNS, name);
15880
15925
  }
@@ -15955,7 +16000,7 @@
15955
16000
  defs: {},
15956
16001
  cssNodes: {},
15957
16002
  cssAnims: {},
15958
- cssClassIdx: 0,
16003
+ cssStyleCache: {},
15959
16004
  cssAnimIdx: 0,
15960
16005
  shadowIdx: 0,
15961
16006
  gradientIdx: 0,
@@ -15975,6 +16020,11 @@
15975
16020
  }, children);
15976
16021
  }
15977
16022
 
16023
+ var cssClassIdx = 0;
16024
+ function getClassId() {
16025
+ return cssClassIdx++;
16026
+ }
16027
+
15978
16028
  var EASING_MAP = {
15979
16029
  cubicIn: '0.32,0,0.67,0',
15980
16030
  cubicOut: '0.33,1,0.68,1',
@@ -16233,7 +16283,7 @@
16233
16283
  }
16234
16284
  }
16235
16285
  if (cssAnimations.length) {
16236
- var className = scope.zrId + '-cls-' + scope.cssClassIdx++;
16286
+ var className = scope.zrId + '-cls-' + getClassId();
16237
16287
  scope.cssNodes['.' + className] = {
16238
16288
  animation: cssAnimations.join(',')
16239
16289
  };
@@ -16241,6 +16291,65 @@
16241
16291
  }
16242
16292
  }
16243
16293
 
16294
+ function createCSSEmphasis(el, attrs, scope) {
16295
+ if (!el.ignore) {
16296
+ if (el.isSilent()) {
16297
+ var style = {
16298
+ 'pointer-events': 'none'
16299
+ };
16300
+ setClassAttribute(style, attrs, scope, true);
16301
+ }
16302
+ else {
16303
+ var emphasisStyle = el.states.emphasis && el.states.emphasis.style
16304
+ ? el.states.emphasis.style
16305
+ : {};
16306
+ var fill = emphasisStyle.fill;
16307
+ if (!fill) {
16308
+ var normalFill = el.style && el.style.fill;
16309
+ var selectFill = el.states.select
16310
+ && el.states.select.style
16311
+ && el.states.select.style.fill;
16312
+ var fromFill = el.currentStates.indexOf('select') >= 0
16313
+ ? (selectFill || normalFill)
16314
+ : normalFill;
16315
+ if (fromFill) {
16316
+ fill = liftColor(fromFill);
16317
+ }
16318
+ }
16319
+ var lineWidth = emphasisStyle.lineWidth;
16320
+ if (lineWidth) {
16321
+ var scaleX = (!emphasisStyle.strokeNoScale && el.transform)
16322
+ ? el.transform[0]
16323
+ : 1;
16324
+ lineWidth = lineWidth / scaleX;
16325
+ }
16326
+ var style = {
16327
+ cursor: 'pointer',
16328
+ };
16329
+ if (fill) {
16330
+ style.fill = fill;
16331
+ }
16332
+ if (emphasisStyle.stroke) {
16333
+ style.stroke = emphasisStyle.stroke;
16334
+ }
16335
+ if (lineWidth) {
16336
+ style['stroke-width'] = lineWidth;
16337
+ }
16338
+ setClassAttribute(style, attrs, scope, true);
16339
+ }
16340
+ }
16341
+ }
16342
+ function setClassAttribute(style, attrs, scope, withHover) {
16343
+ var styleKey = JSON.stringify(style);
16344
+ var className = scope.cssStyleCache[styleKey];
16345
+ if (!className) {
16346
+ className = scope.zrId + '-cls-' + getClassId();
16347
+ scope.cssStyleCache[styleKey] = className;
16348
+ scope.cssNodes['.' + className + (withHover ? ':hover' : '')] = style;
16349
+ }
16350
+ attrs["class"] = attrs["class"] ? (attrs["class"] + ' ' + className) : className;
16351
+ }
16352
+
16244
16353
  var round$1 = Math.round;
16245
16354
  function isImageLike$1(val) {
16246
16355
  return val && isString(val.src);
@@ -16257,12 +16366,27 @@
16257
16366
  else if (isFillStroke && isPattern(val)) {
16258
16367
  setPattern(el, attrs, key, scope);
16259
16368
  }
16369
+ else if (isFillStroke && val === 'none') {
16370
+ attrs[key] = 'transparent';
16371
+ }
16260
16372
  else {
16261
16373
  attrs[key] = val;
16262
16374
  }
16263
16375
  }, style, el, false);
16264
16376
  setShadow(el, attrs, scope);
16265
16377
  }
16378
+ function setMetaData(attrs, el) {
16379
+ var metaData = getElementSSRData(el);
16380
+ if (metaData) {
16381
+ metaData.each(function (val, key) {
16382
+ attrs[(META_DATA_PREFIX + key).toLowerCase()]
16383
+ = val + '';
16384
+ });
16385
+ if (el.isSilent()) {
16386
+ attrs[META_DATA_PREFIX + 'silent'] = 'true';
16387
+ }
16388
+ }
16389
+ }
16266
16390
  function noRotateScale(m) {
16267
16391
  return isAroundZero$1(m[0] - 1)
16268
16392
  && isAroundZero$1(m[1])
@@ -16367,7 +16491,9 @@
16367
16491
  }
16368
16492
  setTransform(attrs, el.transform);
16369
16493
  setStyleAttrs(attrs, style, el, scope);
16494
+ setMetaData(attrs, el);
16370
16495
  scope.animation && createCSSAnimation(el, attrs, scope);
16496
+ scope.emphasis && createCSSEmphasis(el, attrs, scope);
16371
16497
  return createVNode(svgElType, el.id + '', attrs);
16372
16498
  }
16373
16499
  function brushSVGImage(el, scope) {
@@ -16401,6 +16527,7 @@
16401
16527
  }
16402
16528
  setTransform(attrs, el.transform);
16403
16529
  setStyleAttrs(attrs, style, el, scope);
16530
+ setMetaData(attrs, el);
16404
16531
  scope.animation && createCSSAnimation(el, attrs, scope);
16405
16532
  return createVNode('image', el.id + '', attrs);
16406
16533
  }
@@ -16452,6 +16579,7 @@
16452
16579
  }
16453
16580
  setTransform(attrs, el.transform);
16454
16581
  setStyleAttrs(attrs, style, el, scope);
16582
+ setMetaData(attrs, el);
16455
16583
  scope.animation && createCSSAnimation(el, attrs, scope);
16456
16584
  return createVNode('text', el.id + '', attrs, undefined, text);
16457
16585
  }
@@ -17022,6 +17150,7 @@
17022
17150
  scope.animation = opts.animation;
17023
17151
  scope.willUpdate = opts.willUpdate;
17024
17152
  scope.compress = opts.compress;
17153
+ scope.emphasis = opts.emphasis;
17025
17154
  var children = [];
17026
17155
  var bgVNode = this._bgVNode = createBackgroundVNode(width, height, this._backgroundColor, scope);
17027
17156
  bgVNode && children.push(bgVNode);
@@ -17046,6 +17175,7 @@
17046
17175
  opts = opts || {};
17047
17176
  return vNodeToString(this.renderToVNode({
17048
17177
  animation: retrieve2(opts.cssAnimation, true),
17178
+ emphasis: retrieve2(opts.cssEmphasis, true),
17049
17179
  willUpdate: false,
17050
17180
  compress: true,
17051
17181
  useViewBox: retrieve2(opts.useViewBox, true)
@@ -17259,6 +17389,7 @@
17259
17389
  exports.color = color;
17260
17390
  exports.dispose = dispose;
17261
17391
  exports.disposeAll = disposeAll;
17392
+ exports.getElementSSRData = getElementSSRData;
17262
17393
  exports.getInstance = getInstance;
17263
17394
  exports.init = init;
17264
17395
  exports.matrix = matrix;
@@ -17266,6 +17397,7 @@
17266
17397
  exports.parseSVG = parseSVG;
17267
17398
  exports.path = path;
17268
17399
  exports.registerPainter = registerPainter;
17400
+ exports.registerSSRDataGetter = registerSSRDataGetter;
17269
17401
  exports.setPlatformAPI = setPlatformAPI;
17270
17402
  exports.showDebugDirtyRect = showDebugDirtyRect;
17271
17403
  exports.util = util;