@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.
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +2 -2
- package/cjs/index.js.map +1 -1
- package/cjs/interface.d.ts +2 -1
- package/cjs/interface.js.map +1 -1
- package/cjs/label/base.js +3 -8
- package/cjs/label/base.js.map +1 -1
- package/cjs/legend/discrete/discrete.d.ts +0 -7
- package/cjs/legend/discrete/discrete.js +23 -106
- package/cjs/legend/discrete/discrete.js.map +1 -1
- package/cjs/legend/discrete/type.d.ts +3 -15
- package/cjs/legend/discrete/type.js.map +1 -1
- package/cjs/weather/index.d.ts +1 -0
- package/cjs/weather/index.js +21 -0
- package/cjs/weather/index.js.map +1 -0
- package/cjs/weather/register.d.ts +1 -0
- package/cjs/weather/register.js +14 -0
- package/cjs/weather/register.js.map +1 -0
- package/cjs/weather/type.d.ts +24 -0
- package/cjs/weather/type.js +6 -0
- package/cjs/weather/type.js.map +1 -0
- package/cjs/weather/weather-box.d.ts +13 -0
- package/cjs/weather/weather-box.js +129 -0
- package/cjs/weather/weather-box.js.map +1 -0
- package/dist/index.es.js +5751 -5396
- package/es/index.d.ts +2 -1
- package/es/index.js +3 -1
- package/es/index.js.map +1 -1
- package/es/interface.d.ts +2 -1
- package/es/interface.js.map +1 -1
- package/es/label/base.js +2 -8
- package/es/label/base.js.map +1 -1
- package/es/legend/discrete/discrete.d.ts +0 -7
- package/es/legend/discrete/discrete.js +24 -106
- package/es/legend/discrete/discrete.js.map +1 -1
- package/es/legend/discrete/type.d.ts +3 -15
- package/es/legend/discrete/type.js.map +1 -1
- package/es/weather/index.d.ts +1 -0
- package/es/weather/index.js +2 -0
- package/es/weather/index.js.map +1 -0
- package/es/weather/register.d.ts +1 -0
- package/es/weather/register.js +6 -0
- package/es/weather/register.js.map +1 -0
- package/es/weather/type.d.ts +24 -0
- package/es/weather/type.js +2 -0
- package/es/weather/type.js.map +1 -0
- package/es/weather/weather-box.d.ts +13 -0
- package/es/weather/weather-box.js +127 -0
- package/es/weather/weather-box.js.map +1 -0
- package/package.json +5 -5
|
@@ -8,7 +8,7 @@ var __rest = this && this.__rest || function(s, e) {
|
|
|
8
8
|
return t;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
import { merge, isEmpty, normalizePadding, get, isValid, isNil, isFunction, isArray, minInArray, throttle
|
|
11
|
+
import { merge, isEmpty, normalizePadding, get, isValid, isNil, isFunction, isArray, minInArray, throttle } from "@visactor/vutils";
|
|
12
12
|
|
|
13
13
|
import { graphicCreator } from "@visactor/vrender-core";
|
|
14
14
|
|
|
@@ -153,8 +153,7 @@ export class DiscreteLegend extends LegendBase {
|
|
|
153
153
|
items: legendItems,
|
|
154
154
|
isHorizontal: isHorizontal,
|
|
155
155
|
totalPage: 1 / 0,
|
|
156
|
-
isScrollbar: pager && "scrollbar" === pager.type
|
|
157
|
-
clipContainer: void 0
|
|
156
|
+
isScrollbar: pager && "scrollbar" === pager.type
|
|
158
157
|
}, this._itemContext = this._renderItems();
|
|
159
158
|
let pagerRendered = !1;
|
|
160
159
|
this._itemContext.doWrap && autoPage && this._itemContext.pages > this._itemContext.maxPages && (pagerRendered = this._renderPagerComponent()),
|
|
@@ -165,15 +164,8 @@ export class DiscreteLegend extends LegendBase {
|
|
|
165
164
|
if (this.attribute.disableTriggerEvent) return;
|
|
166
165
|
if (!this._itemsContainer) return;
|
|
167
166
|
const {hover: hover = !0, select: select = !0} = this.attribute;
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
isObject(hover) && (hover.trigger && (trigger = hover.trigger), hover.triggerOff && (triggerOff = hover.triggerOff)),
|
|
171
|
-
this._itemsContainer.addEventListener(trigger, this._onHover), this._itemsContainer.addEventListener(triggerOff, this._onUnHover);
|
|
172
|
-
}
|
|
173
|
-
if (select) {
|
|
174
|
-
let trigger = "pointerdown";
|
|
175
|
-
isObject(select) && select.trigger && (trigger = select.trigger), this._itemsContainer.addEventListener(trigger, this._onClick);
|
|
176
|
-
}
|
|
167
|
+
hover && (this._itemsContainer.addEventListener("pointermove", this._onHover), this._itemsContainer.addEventListener("pointerleave", this._onUnHover)),
|
|
168
|
+
select && this._itemsContainer.addEventListener("pointerdown", this._onClick);
|
|
177
169
|
}
|
|
178
170
|
_autoEllipsis(autoEllipsisStrategy, layoutWidth, labelShape, valueShape) {
|
|
179
171
|
var _a, _b;
|
|
@@ -315,12 +307,12 @@ export class DiscreteLegend extends LegendBase {
|
|
|
315
307
|
direction: "horizontal",
|
|
316
308
|
disableTriggerEvent: disableTriggerEvent,
|
|
317
309
|
range: [ 0, .5 ],
|
|
318
|
-
height:
|
|
310
|
+
height: 12
|
|
319
311
|
}, compStyle), {
|
|
320
312
|
width: compSize
|
|
321
313
|
})) : new ScrollBar(Object.assign(Object.assign({
|
|
322
314
|
direction: "vertical",
|
|
323
|
-
width:
|
|
315
|
+
width: 12,
|
|
324
316
|
range: [ 0, .5 ]
|
|
325
317
|
}, compStyle), {
|
|
326
318
|
height: compSize,
|
|
@@ -345,15 +337,9 @@ export class DiscreteLegend extends LegendBase {
|
|
|
345
337
|
});
|
|
346
338
|
}
|
|
347
339
|
}
|
|
348
|
-
_computeScrollbarDelta() {
|
|
349
|
-
const {isHorizontal: isHorizontal, clipContainer: clipContainer} = this._itemContext, itemContainerBounds = this._itemsContainer.AABBBounds, clipContainerBounds = clipContainer.AABBBounds;
|
|
350
|
-
let delta, innerViewSize;
|
|
351
|
-
return isHorizontal ? (innerViewSize = clipContainerBounds.width(), delta = innerViewSize / itemContainerBounds.width()) : (innerViewSize = clipContainerBounds.height(),
|
|
352
|
-
delta = innerViewSize / itemContainerBounds.height()), delta;
|
|
353
|
-
}
|
|
354
340
|
_updatePositionOfScrollbar(contentWidth, contentHeight, renderStartY) {
|
|
355
|
-
const {
|
|
356
|
-
this._pagerComponent.setScrollRange([
|
|
341
|
+
const {currentPage: currentPage, totalPage: totalPage, isHorizontal: isHorizontal} = this._itemContext;
|
|
342
|
+
this._pagerComponent.setScrollRange([ (currentPage - 1) / totalPage, currentPage / totalPage ]),
|
|
357
343
|
isHorizontal ? this._pagerComponent.setAttributes({
|
|
358
344
|
x: 0,
|
|
359
345
|
y: renderStartY + contentHeight
|
|
@@ -366,32 +352,20 @@ export class DiscreteLegend extends LegendBase {
|
|
|
366
352
|
const pager = this.attribute.pager || {}, {animation: animation = !0, animationDuration: animationDuration = 450, animationEasing: animationEasing = "quadIn"} = pager, pageParser = this._itemContext.isScrollbar ? e => {
|
|
367
353
|
const {value: value} = e.detail;
|
|
368
354
|
let newPage;
|
|
369
|
-
return
|
|
370
|
-
newPage;
|
|
355
|
+
return 0 === value[0] ? newPage = 1 : 1 === value[1] ? newPage = this._itemContext.totalPage : (newPage = value[0] * this._itemContext.totalPage,
|
|
356
|
+
pager.scrollByPosition ? newPage += 1 : newPage = Math.floor(newPage) + 1), newPage;
|
|
371
357
|
} : e => e.detail.current, onScroll = e => {
|
|
372
358
|
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;
|
|
373
|
-
scrollComponent.setScrollRange([ preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue ], !0)
|
|
374
|
-
this.updateScrollMask();
|
|
359
|
+
scrollComponent.setScrollRange([ preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue ], !0);
|
|
375
360
|
}, onPaging = e => {
|
|
376
361
|
const newPage = pageParser(e);
|
|
377
362
|
if (newPage !== this._itemContext.currentPage) {
|
|
378
363
|
if (this._itemContext.currentPage = newPage, this._itemContext && this._itemContext.startIndex < this._itemContext.items.length) {
|
|
379
364
|
this._renderItems();
|
|
380
365
|
const newTotalPage = Math.ceil(this._itemContext.pages / this._itemContext.maxPages);
|
|
381
|
-
|
|
382
|
-
const newDelta = this._computeScrollbarDelta(), [start] = this._pagerComponent.getScrollRange();
|
|
383
|
-
this._pagerComponent.setScrollRange([ start, start + newDelta ]);
|
|
384
|
-
}
|
|
366
|
+
this._itemContext.totalPage = newTotalPage, this._pagerComponent.setScrollRange([ (newPage - 1) / newTotalPage, newPage / newTotalPage ]);
|
|
385
367
|
}
|
|
386
|
-
|
|
387
|
-
const [start] = this._pagerComponent.getScrollRange();
|
|
388
|
-
let containerSize;
|
|
389
|
-
containerSize = this._itemContext.isHorizontal ? this._itemsContainer.AABBBounds.width() : this._itemsContainer.AABBBounds.height();
|
|
390
|
-
const startOffset = containerSize * start;
|
|
391
|
-
this.updateScrollMask(), animation ? this._itemsContainer.animate().to({
|
|
392
|
-
[channel]: -startOffset
|
|
393
|
-
}, animationDuration, animationEasing) : this._itemsContainer.setAttribute(channel, -startOffset);
|
|
394
|
-
} else animation ? this._itemsContainer.animate().to({
|
|
368
|
+
animation ? this._itemsContainer.animate().to({
|
|
395
369
|
[channel]: -(newPage - 1) * pageSize
|
|
396
370
|
}, animationDuration, animationEasing) : this._itemsContainer.setAttribute(channel, -(newPage - 1) * pageSize);
|
|
397
371
|
}
|
|
@@ -447,20 +421,18 @@ export class DiscreteLegend extends LegendBase {
|
|
|
447
421
|
clip: !0,
|
|
448
422
|
pickable: !1
|
|
449
423
|
});
|
|
450
|
-
return clipGroup.add(itemsContainer), this._innerView.add(clipGroup), this.
|
|
451
|
-
this._bindEventsOfPager(isHorizontal ? compHeight + spaceRow : compWidth + spaceCol, isHorizontal ? "y" : "x"),
|
|
424
|
+
return clipGroup.add(itemsContainer), this._innerView.add(clipGroup), this._bindEventsOfPager(isHorizontal ? compHeight + spaceRow : compWidth + spaceCol, isHorizontal ? "y" : "x"),
|
|
452
425
|
!0;
|
|
453
426
|
}
|
|
454
427
|
_renderScrollbar() {
|
|
455
|
-
var _a;
|
|
456
428
|
const renderStartY = this._title ? this._title.AABBBounds.height() + get(this.attribute, "title.space", 8) : 0, {maxWidth: maxWidth, item: item = {}, pager: pager = {}} = this.attribute, {spaceCol: spaceCol = DEFAULT_ITEM_SPACE_COL, spaceRow: spaceRow = DEFAULT_ITEM_SPACE_ROW} = item, itemsContainer = this._itemsContainer, {space: pagerSpace = DEFAULT_PAGER_SPACE, defaultCurrent: defaultCurrent = 1} = pager, compStyle = __rest(pager, [ "space", "defaultCurrent" ]), {isHorizontal: isHorizontal} = this._itemContext, maxHeight = this._contentMaxHeight;
|
|
457
|
-
let comp, contentWidth = 0, contentHeight = 0, startY = 0, pages = 1;
|
|
458
|
-
if (isHorizontal)
|
|
459
|
-
this._pagerComponent = comp,
|
|
460
|
-
|
|
461
|
-
comp = this._createScrollbar(compStyle,
|
|
462
|
-
this._innerView.add(comp), contentHeight
|
|
463
|
-
!1;
|
|
429
|
+
let comp, compSize = 0, contentWidth = 0, contentHeight = 0, startY = 0, pages = 1;
|
|
430
|
+
if (isHorizontal) compSize = maxWidth, contentWidth = maxWidth, contentHeight = this._itemHeight,
|
|
431
|
+
comp = this._createScrollbar(compStyle, compSize), this._pagerComponent = comp,
|
|
432
|
+
this._innerView.add(comp), this._updatePositionOfScrollbar(contentWidth, contentHeight, renderStartY); else {
|
|
433
|
+
if (compSize = maxHeight, comp = this._createScrollbar(compStyle, compSize), this._pagerComponent = comp,
|
|
434
|
+
this._innerView.add(comp), contentHeight = maxHeight - renderStartY, contentWidth = this._itemMaxWidth,
|
|
435
|
+
contentHeight <= 0) return this._innerView.removeChild(comp), !1;
|
|
464
436
|
const items = itemsContainer.getChildren(), itemsHeightArr = items.map((item => item.attribute.height));
|
|
465
437
|
if (1 === itemsHeightArr.length || itemsHeightArr.every((entry => entry === itemsHeightArr[0]))) {
|
|
466
438
|
const itemHeight = itemsHeightArr[0], maxContentHeight = contentHeight, pageItemsCount = Math.floor(maxContentHeight / (spaceRow + itemHeight));
|
|
@@ -471,15 +443,9 @@ export class DiscreteLegend extends LegendBase {
|
|
|
471
443
|
prePages !== pages && index === itemsContainer.getChildren().length - 1 && startY - contentHeight >= 1 / 3 * height && (contentHeight = preStartY + height,
|
|
472
444
|
pages -= 1);
|
|
473
445
|
}));
|
|
474
|
-
this._itemContext.totalPage = pages, this._itemContext.pages = pages;
|
|
475
|
-
}
|
|
476
|
-
if (defaultCurrent > 1) if (isHorizontal) {
|
|
477
|
-
const maxOffset = this._itemsContainer.AABBBounds.width() - contentWidth;
|
|
478
|
-
itemsContainer.setAttribute("x", -Math.min((defaultCurrent - 1) * (contentWidth + spaceCol), maxOffset));
|
|
479
|
-
} else {
|
|
480
|
-
const maxOffset = this._itemsContainer.AABBBounds.height() - contentHeight;
|
|
481
|
-
itemsContainer.setAttribute("y", -Math.min((defaultCurrent - 1) * (contentHeight + spaceRow), maxOffset));
|
|
446
|
+
this._itemContext.totalPage = pages, this._itemContext.pages = pages, this._updatePositionOfScrollbar(contentWidth, contentHeight, renderStartY);
|
|
482
447
|
}
|
|
448
|
+
defaultCurrent > 1 && (isHorizontal ? itemsContainer.setAttribute("x", -(defaultCurrent - 1) * (contentWidth + spaceCol)) : itemsContainer.setAttribute("y", -(defaultCurrent - 1) * (contentHeight + spaceRow)));
|
|
483
449
|
const clipGroup = graphicCreator.group({
|
|
484
450
|
x: 0,
|
|
485
451
|
y: renderStartY,
|
|
@@ -488,57 +454,9 @@ export class DiscreteLegend extends LegendBase {
|
|
|
488
454
|
clip: !0,
|
|
489
455
|
pickable: !1
|
|
490
456
|
});
|
|
491
|
-
return clipGroup.add(itemsContainer), this._innerView.add(clipGroup), this.
|
|
492
|
-
this._updatePositionOfScrollbar(contentWidth, contentHeight, renderStartY), (null === (_a = pager.scrollMask) || void 0 === _a ? void 0 : _a.visible) && this.renderScrollMask(clipGroup),
|
|
493
|
-
this._bindEventsOfPager(isHorizontal ? contentWidth : contentHeight, isHorizontal ? "x" : "y"),
|
|
457
|
+
return clipGroup.add(itemsContainer), this._innerView.add(clipGroup), this._bindEventsOfPager(isHorizontal ? contentWidth : contentHeight, isHorizontal ? "x" : "y"),
|
|
494
458
|
!0;
|
|
495
459
|
}
|
|
496
|
-
renderScrollMask(clipGroup) {
|
|
497
|
-
const {scrollMask: scrollMask = {}} = this.attribute.pager, {visible: visible = !0, gradientLength: gradientLength = 16, gradientStops: gradientStops} = scrollMask;
|
|
498
|
-
if (!visible || !gradientStops) return;
|
|
499
|
-
const width = clipGroup.AABBBounds.width(), height = clipGroup.AABBBounds.height(), totalLength = this._itemContext.isHorizontal ? width : height, startStops = gradientStops.map((stop => ({
|
|
500
|
-
offset: gradientLength * stop.offset / totalLength,
|
|
501
|
-
color: stop.color
|
|
502
|
-
}))), endStops = gradientStops.map((stop => ({
|
|
503
|
-
offset: (totalLength - gradientLength * stop.offset) / totalLength,
|
|
504
|
-
color: stop.color
|
|
505
|
-
}))), mask = graphicCreator.rect({
|
|
506
|
-
x: 0,
|
|
507
|
-
y: 0,
|
|
508
|
-
width: width,
|
|
509
|
-
height: height
|
|
510
|
-
});
|
|
511
|
-
this._scrollMask = mask, this._scrollMaskContext = {
|
|
512
|
-
startStops: startStops,
|
|
513
|
-
endStops: endStops
|
|
514
|
-
}, this.updateScrollMask(), clipGroup.add(mask);
|
|
515
|
-
}
|
|
516
|
-
updateScrollMask() {
|
|
517
|
-
if (!this._scrollMask || !this._pagerComponent) return;
|
|
518
|
-
if (!this._itemContext.isScrollbar) return;
|
|
519
|
-
const [start, end] = this._pagerComponent.getScrollRange(), stops = [];
|
|
520
|
-
isNumberClose(clamp(end, 0, 1), 1) || stops.push(...this._scrollMaskContext.endStops),
|
|
521
|
-
isNumberClose(clamp(start, 0, 1), 0) || stops.push(...this._scrollMaskContext.startStops),
|
|
522
|
-
stops.length && (this._itemContext.isHorizontal ? this._scrollMask.setAttributes({
|
|
523
|
-
fill: {
|
|
524
|
-
gradient: "linear",
|
|
525
|
-
x0: 0,
|
|
526
|
-
y0: 0,
|
|
527
|
-
x1: 1,
|
|
528
|
-
y1: 0,
|
|
529
|
-
stops: stops
|
|
530
|
-
}
|
|
531
|
-
}) : this._scrollMask.setAttributes({
|
|
532
|
-
fill: {
|
|
533
|
-
gradient: "linear",
|
|
534
|
-
x0: 0,
|
|
535
|
-
y0: 0,
|
|
536
|
-
x1: 0,
|
|
537
|
-
y1: 1,
|
|
538
|
-
stops: stops
|
|
539
|
-
}
|
|
540
|
-
}));
|
|
541
|
-
}
|
|
542
460
|
_renderPagerComponent() {
|
|
543
461
|
return this._itemContext.isScrollbar ? this._renderScrollbar() : this._renderPager(),
|
|
544
462
|
!0;
|