@visactor/vrender-components 0.21.0-alpha.3 → 0.21.0-vstory.1

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.
Files changed (50) hide show
  1. package/cjs/index.d.ts +2 -1
  2. package/cjs/index.js +2 -2
  3. package/cjs/index.js.map +1 -1
  4. package/cjs/interface.d.ts +2 -1
  5. package/cjs/interface.js.map +1 -1
  6. package/cjs/label/base.js +3 -8
  7. package/cjs/label/base.js.map +1 -1
  8. package/cjs/legend/discrete/discrete.d.ts +0 -7
  9. package/cjs/legend/discrete/discrete.js +23 -106
  10. package/cjs/legend/discrete/discrete.js.map +1 -1
  11. package/cjs/legend/discrete/type.d.ts +3 -15
  12. package/cjs/legend/discrete/type.js.map +1 -1
  13. package/cjs/weather/index.d.ts +1 -0
  14. package/cjs/weather/index.js +21 -0
  15. package/cjs/weather/index.js.map +1 -0
  16. package/cjs/weather/register.d.ts +1 -0
  17. package/cjs/weather/register.js +14 -0
  18. package/cjs/weather/register.js.map +1 -0
  19. package/cjs/weather/type.d.ts +24 -0
  20. package/cjs/weather/type.js +6 -0
  21. package/cjs/weather/type.js.map +1 -0
  22. package/cjs/weather/weather-box.d.ts +13 -0
  23. package/cjs/weather/weather-box.js +129 -0
  24. package/cjs/weather/weather-box.js.map +1 -0
  25. package/dist/index.es.js +5751 -5396
  26. package/es/index.d.ts +2 -1
  27. package/es/index.js +3 -1
  28. package/es/index.js.map +1 -1
  29. package/es/interface.d.ts +2 -1
  30. package/es/interface.js.map +1 -1
  31. package/es/label/base.js +2 -8
  32. package/es/label/base.js.map +1 -1
  33. package/es/legend/discrete/discrete.d.ts +0 -7
  34. package/es/legend/discrete/discrete.js +24 -106
  35. package/es/legend/discrete/discrete.js.map +1 -1
  36. package/es/legend/discrete/type.d.ts +3 -15
  37. package/es/legend/discrete/type.js.map +1 -1
  38. package/es/weather/index.d.ts +1 -0
  39. package/es/weather/index.js +2 -0
  40. package/es/weather/index.js.map +1 -0
  41. package/es/weather/register.d.ts +1 -0
  42. package/es/weather/register.js +6 -0
  43. package/es/weather/register.js.map +1 -0
  44. package/es/weather/type.d.ts +24 -0
  45. package/es/weather/type.js +2 -0
  46. package/es/weather/type.js.map +1 -0
  47. package/es/weather/weather-box.d.ts +13 -0
  48. package/es/weather/weather-box.js +127 -0
  49. package/es/weather/weather-box.js.map +1 -0
  50. package/package.json +5 -5
@@ -146,8 +146,7 @@ class DiscreteLegend extends base_1.LegendBase {
146
146
  items: legendItems,
147
147
  isHorizontal: isHorizontal,
148
148
  totalPage: 1 / 0,
149
- isScrollbar: pager && "scrollbar" === pager.type,
150
- clipContainer: void 0
149
+ isScrollbar: pager && "scrollbar" === pager.type
151
150
  }, this._itemContext = this._renderItems();
152
151
  let pagerRendered = !1;
153
152
  this._itemContext.doWrap && autoPage && this._itemContext.pages > this._itemContext.maxPages && (pagerRendered = this._renderPagerComponent()),
@@ -158,16 +157,8 @@ class DiscreteLegend extends base_1.LegendBase {
158
157
  if (this.attribute.disableTriggerEvent) return;
159
158
  if (!this._itemsContainer) return;
160
159
  const {hover: hover = !0, select: select = !0} = this.attribute;
161
- if (hover) {
162
- let trigger = "pointermove", triggerOff = "pointerleave";
163
- (0, vutils_1.isObject)(hover) && (hover.trigger && (trigger = hover.trigger), hover.triggerOff && (triggerOff = hover.triggerOff)),
164
- this._itemsContainer.addEventListener(trigger, this._onHover), this._itemsContainer.addEventListener(triggerOff, this._onUnHover);
165
- }
166
- if (select) {
167
- let trigger = "pointerdown";
168
- (0, vutils_1.isObject)(select) && select.trigger && (trigger = select.trigger),
169
- this._itemsContainer.addEventListener(trigger, this._onClick);
170
- }
160
+ hover && (this._itemsContainer.addEventListener("pointermove", this._onHover), this._itemsContainer.addEventListener("pointerleave", this._onUnHover)),
161
+ select && this._itemsContainer.addEventListener("pointerdown", this._onClick);
171
162
  }
172
163
  _autoEllipsis(autoEllipsisStrategy, layoutWidth, labelShape, valueShape) {
173
164
  var _a, _b;
@@ -310,12 +301,12 @@ class DiscreteLegend extends base_1.LegendBase {
310
301
  direction: "horizontal",
311
302
  disableTriggerEvent: disableTriggerEvent,
312
303
  range: [ 0, .5 ],
313
- height: !1 === compStyle.visible ? 0 : 12
304
+ height: 12
314
305
  }, compStyle), {
315
306
  width: compSize
316
307
  })) : new scrollbar_1.ScrollBar(Object.assign(Object.assign({
317
308
  direction: "vertical",
318
- width: !1 === compStyle.visible ? 0 : 12,
309
+ width: 12,
319
310
  range: [ 0, .5 ]
320
311
  }, compStyle), {
321
312
  height: compSize,
@@ -340,15 +331,9 @@ class DiscreteLegend extends base_1.LegendBase {
340
331
  });
341
332
  }
342
333
  }
343
- _computeScrollbarDelta() {
344
- const {isHorizontal: isHorizontal, clipContainer: clipContainer} = this._itemContext, itemContainerBounds = this._itemsContainer.AABBBounds, clipContainerBounds = clipContainer.AABBBounds;
345
- let delta, innerViewSize;
346
- return isHorizontal ? (innerViewSize = clipContainerBounds.width(), delta = innerViewSize / itemContainerBounds.width()) : (innerViewSize = clipContainerBounds.height(),
347
- delta = innerViewSize / itemContainerBounds.height()), delta;
348
- }
349
334
  _updatePositionOfScrollbar(contentWidth, contentHeight, renderStartY) {
350
- const {isHorizontal: isHorizontal, currentPage: currentPage, totalPage: totalPage} = this._itemContext, start = (currentPage - 1) / totalPage;
351
- this._pagerComponent.setScrollRange([ start, start + this._computeScrollbarDelta() ]),
335
+ const {currentPage: currentPage, totalPage: totalPage, isHorizontal: isHorizontal} = this._itemContext;
336
+ this._pagerComponent.setScrollRange([ (currentPage - 1) / totalPage, currentPage / totalPage ]),
352
337
  isHorizontal ? this._pagerComponent.setAttributes({
353
338
  x: 0,
354
339
  y: renderStartY + contentHeight
@@ -361,32 +346,20 @@ class DiscreteLegend extends base_1.LegendBase {
361
346
  const pager = this.attribute.pager || {}, {animation: animation = !0, animationDuration: animationDuration = 450, animationEasing: animationEasing = "quadIn"} = pager, pageParser = this._itemContext.isScrollbar ? e => {
362
347
  const {value: value} = e.detail;
363
348
  let newPage;
364
- return newPage = 0 === value[0] ? 1 : 1 === value[1] ? this._itemContext.totalPage : value[0] * this._itemContext.totalPage + 1,
365
- newPage;
349
+ return 0 === value[0] ? newPage = 1 : 1 === value[1] ? newPage = this._itemContext.totalPage : (newPage = value[0] * this._itemContext.totalPage,
350
+ pager.scrollByPosition ? newPage += 1 : newPage = Math.floor(newPage) + 1), newPage;
366
351
  } : e => e.detail.current, onScroll = e => {
367
352
  const scrollComponent = this._pagerComponent, preScrollRange = scrollComponent.getScrollRange(), {direction: direction} = scrollComponent.attribute, {width: width, height: height} = scrollComponent.getSliderRenderBounds(), currentScrollValue = "vertical" === direction ? e.deltaY / height : e.deltaX / width;
368
- scrollComponent.setScrollRange([ preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue ], !0),
369
- this.updateScrollMask();
353
+ scrollComponent.setScrollRange([ preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue ], !0);
370
354
  }, onPaging = e => {
371
355
  const newPage = pageParser(e);
372
356
  if (newPage !== this._itemContext.currentPage) {
373
357
  if (this._itemContext.currentPage = newPage, this._itemContext && this._itemContext.startIndex < this._itemContext.items.length) {
374
358
  this._renderItems();
375
359
  const newTotalPage = Math.ceil(this._itemContext.pages / this._itemContext.maxPages);
376
- if (this._itemContext.totalPage = newTotalPage, this._itemContext.isScrollbar && this._pagerComponent) {
377
- const newDelta = this._computeScrollbarDelta(), [start] = this._pagerComponent.getScrollRange();
378
- this._pagerComponent.setScrollRange([ start, start + newDelta ]);
379
- }
360
+ this._itemContext.totalPage = newTotalPage, this._pagerComponent.setScrollRange([ (newPage - 1) / newTotalPage, newPage / newTotalPage ]);
380
361
  }
381
- if (this._itemContext.isScrollbar) {
382
- const [start] = this._pagerComponent.getScrollRange();
383
- let containerSize;
384
- containerSize = this._itemContext.isHorizontal ? this._itemsContainer.AABBBounds.width() : this._itemsContainer.AABBBounds.height();
385
- const startOffset = containerSize * start;
386
- this.updateScrollMask(), animation ? this._itemsContainer.animate().to({
387
- [channel]: -startOffset
388
- }, animationDuration, animationEasing) : this._itemsContainer.setAttribute(channel, -startOffset);
389
- } else animation ? this._itemsContainer.animate().to({
362
+ animation ? this._itemsContainer.animate().to({
390
363
  [channel]: -(newPage - 1) * pageSize
391
364
  }, animationDuration, animationEasing) : this._itemsContainer.setAttribute(channel, -(newPage - 1) * pageSize);
392
365
  }
@@ -443,20 +416,18 @@ class DiscreteLegend extends base_1.LegendBase {
443
416
  clip: !0,
444
417
  pickable: !1
445
418
  });
446
- return clipGroup.add(itemsContainer), this._innerView.add(clipGroup), this._itemContext.clipContainer = clipGroup,
447
- this._bindEventsOfPager(isHorizontal ? compHeight + spaceRow : compWidth + spaceCol, isHorizontal ? "y" : "x"),
419
+ return clipGroup.add(itemsContainer), this._innerView.add(clipGroup), this._bindEventsOfPager(isHorizontal ? compHeight + spaceRow : compWidth + spaceCol, isHorizontal ? "y" : "x"),
448
420
  !0;
449
421
  }
450
422
  _renderScrollbar() {
451
- var _a;
452
423
  const renderStartY = this._title ? this._title.AABBBounds.height() + (0, vutils_1.get)(this.attribute, "title.space", 8) : 0, {maxWidth: maxWidth, item: item = {}, pager: pager = {}} = this.attribute, {spaceCol: spaceCol = constant_1.DEFAULT_ITEM_SPACE_COL, spaceRow: spaceRow = constant_1.DEFAULT_ITEM_SPACE_ROW} = item, itemsContainer = this._itemsContainer, {space: pagerSpace = constant_1.DEFAULT_PAGER_SPACE, defaultCurrent: defaultCurrent = 1} = pager, compStyle = __rest(pager, [ "space", "defaultCurrent" ]), {isHorizontal: isHorizontal} = this._itemContext, maxHeight = this._contentMaxHeight;
453
- let comp, contentWidth = 0, contentHeight = 0, startY = 0, pages = 1;
454
- if (isHorizontal) contentWidth = maxWidth, contentHeight = this._itemHeight, comp = this._createScrollbar(compStyle, contentWidth),
455
- this._pagerComponent = comp, this._innerView.add(comp); else {
456
- if (contentHeight = maxHeight - renderStartY, contentWidth = this._itemMaxWidth,
457
- comp = this._createScrollbar(compStyle, contentHeight), this._pagerComponent = comp,
458
- this._innerView.add(comp), contentHeight <= 0) return this._innerView.removeChild(comp),
459
- !1;
424
+ let comp, compSize = 0, contentWidth = 0, contentHeight = 0, startY = 0, pages = 1;
425
+ if (isHorizontal) compSize = maxWidth, contentWidth = maxWidth, contentHeight = this._itemHeight,
426
+ comp = this._createScrollbar(compStyle, compSize), this._pagerComponent = comp,
427
+ this._innerView.add(comp), this._updatePositionOfScrollbar(contentWidth, contentHeight, renderStartY); else {
428
+ if (compSize = maxHeight, comp = this._createScrollbar(compStyle, compSize), this._pagerComponent = comp,
429
+ this._innerView.add(comp), contentHeight = maxHeight - renderStartY, contentWidth = this._itemMaxWidth,
430
+ contentHeight <= 0) return this._innerView.removeChild(comp), !1;
460
431
  const items = itemsContainer.getChildren(), itemsHeightArr = items.map((item => item.attribute.height));
461
432
  if (1 === itemsHeightArr.length || itemsHeightArr.every((entry => entry === itemsHeightArr[0]))) {
462
433
  const itemHeight = itemsHeightArr[0], maxContentHeight = contentHeight, pageItemsCount = Math.floor(maxContentHeight / (spaceRow + itemHeight));
@@ -467,15 +438,9 @@ class DiscreteLegend extends base_1.LegendBase {
467
438
  prePages !== pages && index === itemsContainer.getChildren().length - 1 && startY - contentHeight >= 1 / 3 * height && (contentHeight = preStartY + height,
468
439
  pages -= 1);
469
440
  }));
470
- this._itemContext.totalPage = pages, this._itemContext.pages = pages;
471
- }
472
- if (defaultCurrent > 1) if (isHorizontal) {
473
- const maxOffset = this._itemsContainer.AABBBounds.width() - contentWidth;
474
- itemsContainer.setAttribute("x", -Math.min((defaultCurrent - 1) * (contentWidth + spaceCol), maxOffset));
475
- } else {
476
- const maxOffset = this._itemsContainer.AABBBounds.height() - contentHeight;
477
- itemsContainer.setAttribute("y", -Math.min((defaultCurrent - 1) * (contentHeight + spaceRow), maxOffset));
441
+ this._itemContext.totalPage = pages, this._itemContext.pages = pages, this._updatePositionOfScrollbar(contentWidth, contentHeight, renderStartY);
478
442
  }
443
+ defaultCurrent > 1 && (isHorizontal ? itemsContainer.setAttribute("x", -(defaultCurrent - 1) * (contentWidth + spaceCol)) : itemsContainer.setAttribute("y", -(defaultCurrent - 1) * (contentHeight + spaceRow)));
479
444
  const clipGroup = vrender_core_1.graphicCreator.group({
480
445
  x: 0,
481
446
  y: renderStartY,
@@ -484,57 +449,9 @@ class DiscreteLegend extends base_1.LegendBase {
484
449
  clip: !0,
485
450
  pickable: !1
486
451
  });
487
- return clipGroup.add(itemsContainer), this._innerView.add(clipGroup), this._itemContext.clipContainer = clipGroup,
488
- this._updatePositionOfScrollbar(contentWidth, contentHeight, renderStartY), (null === (_a = pager.scrollMask) || void 0 === _a ? void 0 : _a.visible) && this.renderScrollMask(clipGroup),
489
- this._bindEventsOfPager(isHorizontal ? contentWidth : contentHeight, isHorizontal ? "x" : "y"),
452
+ return clipGroup.add(itemsContainer), this._innerView.add(clipGroup), this._bindEventsOfPager(isHorizontal ? contentWidth : contentHeight, isHorizontal ? "x" : "y"),
490
453
  !0;
491
454
  }
492
- renderScrollMask(clipGroup) {
493
- const {scrollMask: scrollMask = {}} = this.attribute.pager, {visible: visible = !0, gradientLength: gradientLength = 16, gradientStops: gradientStops} = scrollMask;
494
- if (!visible || !gradientStops) return;
495
- const width = clipGroup.AABBBounds.width(), height = clipGroup.AABBBounds.height(), totalLength = this._itemContext.isHorizontal ? width : height, startStops = gradientStops.map((stop => ({
496
- offset: gradientLength * stop.offset / totalLength,
497
- color: stop.color
498
- }))), endStops = gradientStops.map((stop => ({
499
- offset: (totalLength - gradientLength * stop.offset) / totalLength,
500
- color: stop.color
501
- }))), mask = vrender_core_1.graphicCreator.rect({
502
- x: 0,
503
- y: 0,
504
- width: width,
505
- height: height
506
- });
507
- this._scrollMask = mask, this._scrollMaskContext = {
508
- startStops: startStops,
509
- endStops: endStops
510
- }, this.updateScrollMask(), clipGroup.add(mask);
511
- }
512
- updateScrollMask() {
513
- if (!this._scrollMask || !this._pagerComponent) return;
514
- if (!this._itemContext.isScrollbar) return;
515
- const [start, end] = this._pagerComponent.getScrollRange(), stops = [];
516
- (0, vutils_1.isNumberClose)((0, vutils_1.clamp)(end, 0, 1), 1) || stops.push(...this._scrollMaskContext.endStops),
517
- (0, vutils_1.isNumberClose)((0, vutils_1.clamp)(start, 0, 1), 0) || stops.push(...this._scrollMaskContext.startStops),
518
- stops.length && (this._itemContext.isHorizontal ? this._scrollMask.setAttributes({
519
- fill: {
520
- gradient: "linear",
521
- x0: 0,
522
- y0: 0,
523
- x1: 1,
524
- y1: 0,
525
- stops: stops
526
- }
527
- }) : this._scrollMask.setAttributes({
528
- fill: {
529
- gradient: "linear",
530
- x0: 0,
531
- y0: 0,
532
- x1: 0,
533
- y1: 1,
534
- stops: stops
535
- }
536
- }));
537
- }
538
455
  _renderPagerComponent() {
539
456
  return this._itemContext.isScrollbar ? this._renderScrollbar() : this._renderPager(),
540
457
  !0;