@visactor/vrender-components 0.18.0-alpha.0 → 0.18.0-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.
Files changed (199) hide show
  1. package/cjs/axis/base.js +24 -24
  2. package/cjs/axis/base.js.map +1 -1
  3. package/cjs/axis/grid/base.js +1 -1
  4. package/cjs/axis/grid/base.js.map +1 -1
  5. package/cjs/axis/line.js +59 -52
  6. package/cjs/axis/line.js.map +1 -1
  7. package/cjs/axis/overlap/auto-hide.d.ts +1 -0
  8. package/cjs/axis/overlap/auto-hide.js +10 -2
  9. package/cjs/axis/overlap/auto-hide.js.map +1 -1
  10. package/cjs/axis/overlap/auto-limit.d.ts +1 -0
  11. package/cjs/axis/overlap/auto-limit.js +5 -3
  12. package/cjs/axis/overlap/auto-limit.js.map +1 -1
  13. package/cjs/axis/type.d.ts +1 -0
  14. package/cjs/axis/type.js.map +1 -1
  15. package/cjs/brush/brush.js +4 -4
  16. package/cjs/brush/brush.js.map +1 -1
  17. package/cjs/checkbox/checkbox.js +2 -1
  18. package/cjs/checkbox/checkbox.js.map +1 -1
  19. package/cjs/core/type.d.ts +10 -8
  20. package/cjs/core/type.js.map +1 -1
  21. package/cjs/data-zoom/data-zoom.d.ts +6 -1
  22. package/cjs/data-zoom/data-zoom.js +180 -118
  23. package/cjs/data-zoom/data-zoom.js.map +1 -1
  24. package/cjs/data-zoom/type.d.ts +1 -0
  25. package/cjs/data-zoom/type.js.map +1 -1
  26. package/cjs/index.d.ts +2 -1
  27. package/cjs/index.js +3 -2
  28. package/cjs/index.js.map +1 -1
  29. package/cjs/indicator/indicator.d.ts +3 -1
  30. package/cjs/indicator/indicator.js +60 -46
  31. package/cjs/indicator/indicator.js.map +1 -1
  32. package/cjs/indicator/type.d.ts +1 -0
  33. package/cjs/indicator/type.js.map +1 -1
  34. package/cjs/label/arc.d.ts +2 -2
  35. package/cjs/label/arc.js +38 -35
  36. package/cjs/label/arc.js.map +1 -1
  37. package/cjs/label/base.d.ts +6 -8
  38. package/cjs/label/base.js +92 -65
  39. package/cjs/label/base.js.map +1 -1
  40. package/cjs/label/line.js +3 -4
  41. package/cjs/label/line.js.map +1 -1
  42. package/cjs/label/type.d.ts +15 -8
  43. package/cjs/label/type.js.map +1 -1
  44. package/cjs/label/util.d.ts +4 -0
  45. package/cjs/label/util.js +24 -3
  46. package/cjs/label/util.js.map +1 -1
  47. package/cjs/legend/base.js +1 -1
  48. package/cjs/legend/base.js.map +1 -1
  49. package/cjs/legend/color/color.d.ts +7 -0
  50. package/cjs/legend/color/color.js +16 -2
  51. package/cjs/legend/color/color.js.map +1 -1
  52. package/cjs/legend/discrete/discrete.d.ts +6 -2
  53. package/cjs/legend/discrete/discrete.js +139 -69
  54. package/cjs/legend/discrete/discrete.js.map +1 -1
  55. package/cjs/legend/discrete/type.d.ts +17 -7
  56. package/cjs/legend/discrete/type.js.map +1 -1
  57. package/cjs/legend/register.js +2 -2
  58. package/cjs/legend/register.js.map +1 -1
  59. package/cjs/legend/size/size.d.ts +1 -0
  60. package/cjs/legend/size/size.js +4 -1
  61. package/cjs/legend/size/size.js.map +1 -1
  62. package/cjs/legend/type.d.ts +2 -2
  63. package/cjs/legend/type.js.map +1 -1
  64. package/cjs/marker/area.js +5 -1
  65. package/cjs/marker/area.js.map +1 -1
  66. package/cjs/marker/base.d.ts +1 -0
  67. package/cjs/marker/base.js +6 -3
  68. package/cjs/marker/base.js.map +1 -1
  69. package/cjs/marker/line.js +7 -1
  70. package/cjs/marker/line.js.map +1 -1
  71. package/cjs/marker/point.d.ts +1 -0
  72. package/cjs/marker/point.js +24 -11
  73. package/cjs/marker/point.js.map +1 -1
  74. package/cjs/marker/type.d.ts +1 -0
  75. package/cjs/marker/type.js.map +1 -1
  76. package/cjs/pager/pager.js +5 -3
  77. package/cjs/pager/pager.js.map +1 -1
  78. package/cjs/scrollbar/scrollbar.js +19 -5
  79. package/cjs/scrollbar/scrollbar.js.map +1 -1
  80. package/cjs/segment/segment.js +1 -1
  81. package/cjs/segment/segment.js.map +1 -1
  82. package/cjs/slider/slider.d.ts +27 -0
  83. package/cjs/slider/slider.js +102 -13
  84. package/cjs/slider/slider.js.map +1 -1
  85. package/cjs/slider/type.d.ts +9 -1
  86. package/cjs/slider/type.js.map +1 -1
  87. package/cjs/tag/tag.js +28 -42
  88. package/cjs/tag/tag.js.map +1 -1
  89. package/cjs/title/title.js +2 -2
  90. package/cjs/title/title.js.map +1 -1
  91. package/cjs/tooltip/tooltip.js +1 -1
  92. package/cjs/tooltip/tooltip.js.map +1 -1
  93. package/cjs/util/limit-shape.d.ts +4 -0
  94. package/cjs/util/limit-shape.js +13 -4
  95. package/cjs/util/limit-shape.js.map +1 -1
  96. package/cjs/util/text.d.ts +5 -2
  97. package/cjs/util/text.js +19 -6
  98. package/cjs/util/text.js.map +1 -1
  99. package/es/axis/base.js +22 -26
  100. package/es/axis/base.js.map +1 -1
  101. package/es/axis/grid/base.js +1 -1
  102. package/es/axis/grid/base.js.map +1 -1
  103. package/es/axis/line.js +59 -50
  104. package/es/axis/line.js.map +1 -1
  105. package/es/axis/overlap/auto-hide.d.ts +1 -0
  106. package/es/axis/overlap/auto-hide.js +10 -2
  107. package/es/axis/overlap/auto-hide.js.map +1 -1
  108. package/es/axis/overlap/auto-limit.d.ts +1 -0
  109. package/es/axis/overlap/auto-limit.js +5 -3
  110. package/es/axis/overlap/auto-limit.js.map +1 -1
  111. package/es/axis/type.d.ts +1 -0
  112. package/es/axis/type.js.map +1 -1
  113. package/es/brush/brush.js +4 -4
  114. package/es/brush/brush.js.map +1 -1
  115. package/es/checkbox/checkbox.js +2 -1
  116. package/es/checkbox/checkbox.js.map +1 -1
  117. package/es/core/type.d.ts +10 -8
  118. package/es/core/type.js.map +1 -1
  119. package/es/data-zoom/data-zoom.d.ts +6 -1
  120. package/es/data-zoom/data-zoom.js +179 -116
  121. package/es/data-zoom/data-zoom.js.map +1 -1
  122. package/es/data-zoom/type.d.ts +1 -0
  123. package/es/data-zoom/type.js.map +1 -1
  124. package/es/index.d.ts +2 -1
  125. package/es/index.js +3 -1
  126. package/es/index.js.map +1 -1
  127. package/es/indicator/indicator.d.ts +3 -1
  128. package/es/indicator/indicator.js +57 -47
  129. package/es/indicator/indicator.js.map +1 -1
  130. package/es/indicator/type.d.ts +1 -0
  131. package/es/indicator/type.js.map +1 -1
  132. package/es/label/arc.d.ts +2 -2
  133. package/es/label/arc.js +38 -35
  134. package/es/label/arc.js.map +1 -1
  135. package/es/label/base.d.ts +6 -8
  136. package/es/label/base.js +92 -65
  137. package/es/label/base.js.map +1 -1
  138. package/es/label/line.js +3 -4
  139. package/es/label/line.js.map +1 -1
  140. package/es/label/type.d.ts +15 -8
  141. package/es/label/type.js.map +1 -1
  142. package/es/label/util.d.ts +4 -0
  143. package/es/label/util.js +22 -2
  144. package/es/label/util.js.map +1 -1
  145. package/es/legend/base.js +1 -1
  146. package/es/legend/base.js.map +1 -1
  147. package/es/legend/color/color.d.ts +7 -0
  148. package/es/legend/color/color.js +17 -3
  149. package/es/legend/color/color.js.map +1 -1
  150. package/es/legend/discrete/discrete.d.ts +6 -2
  151. package/es/legend/discrete/discrete.js +141 -67
  152. package/es/legend/discrete/discrete.js.map +1 -1
  153. package/es/legend/discrete/type.d.ts +17 -7
  154. package/es/legend/discrete/type.js.map +1 -1
  155. package/es/legend/register.js +3 -1
  156. package/es/legend/register.js.map +1 -1
  157. package/es/legend/size/size.d.ts +1 -0
  158. package/es/legend/size/size.js +4 -1
  159. package/es/legend/size/size.js.map +1 -1
  160. package/es/legend/type.d.ts +2 -2
  161. package/es/legend/type.js.map +1 -1
  162. package/es/marker/area.js +6 -2
  163. package/es/marker/area.js.map +1 -1
  164. package/es/marker/base.d.ts +1 -0
  165. package/es/marker/base.js +6 -3
  166. package/es/marker/base.js.map +1 -1
  167. package/es/marker/line.js +8 -2
  168. package/es/marker/line.js.map +1 -1
  169. package/es/marker/point.d.ts +1 -0
  170. package/es/marker/point.js +25 -11
  171. package/es/marker/point.js.map +1 -1
  172. package/es/marker/type.d.ts +1 -0
  173. package/es/marker/type.js.map +1 -1
  174. package/es/pager/pager.js +4 -3
  175. package/es/pager/pager.js.map +1 -1
  176. package/es/scrollbar/scrollbar.js +19 -5
  177. package/es/scrollbar/scrollbar.js.map +1 -1
  178. package/es/segment/segment.js +1 -1
  179. package/es/segment/segment.js.map +1 -1
  180. package/es/slider/slider.d.ts +27 -0
  181. package/es/slider/slider.js +102 -13
  182. package/es/slider/slider.js.map +1 -1
  183. package/es/slider/type.d.ts +9 -1
  184. package/es/slider/type.js.map +1 -1
  185. package/es/tag/tag.js +29 -45
  186. package/es/tag/tag.js.map +1 -1
  187. package/es/title/title.js +3 -3
  188. package/es/title/title.js.map +1 -1
  189. package/es/tooltip/tooltip.js +1 -1
  190. package/es/tooltip/tooltip.js.map +1 -1
  191. package/es/util/limit-shape.d.ts +4 -0
  192. package/es/util/limit-shape.js +11 -3
  193. package/es/util/limit-shape.js.map +1 -1
  194. package/es/util/text.d.ts +5 -2
  195. package/es/util/text.js +17 -5
  196. package/es/util/text.js.map +1 -1
  197. package/package.json +3 -3
  198. package/dist/index.js +0 -29932
  199. package/dist/index.min.js +0 -1
@@ -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 } from "@visactor/vutils";
11
+ import { merge, isEmpty, normalizePadding, get, isValid, isNil, isFunction, isArray } from "@visactor/vutils";
12
12
 
13
13
  import { graphicCreator } from "@visactor/vrender-core";
14
14
 
@@ -20,6 +20,10 @@ import { DEFAULT_TITLE_SPACE, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DE
20
20
 
21
21
  import { loadDiscreteLegendComponent } from "../register";
22
22
 
23
+ import { isRichText, richTextAttributeTransform } from "../../util";
24
+
25
+ import { ScrollBar } from "../../scrollbar";
26
+
23
27
  const DEFAULT_STATES = {
24
28
  [LegendStateValue.focus]: {},
25
29
  [LegendStateValue.selected]: {},
@@ -140,10 +144,11 @@ export class DiscreteLegend extends LegendBase {
140
144
  startY: 0,
141
145
  startIndex: 0,
142
146
  items: legendItems,
143
- isHorizontal: isHorizontal
147
+ isHorizontal: isHorizontal,
148
+ totalPage: 1 / 0
144
149
  }, this._itemContext = this._renderItems();
145
150
  let pagerRendered = !1;
146
- this._itemContext.doWrap && autoPage && this._itemContext.pages > this._itemContext.maxPages && (pagerRendered = this._renderPager(isHorizontal)),
151
+ this._itemContext.doWrap && autoPage && this._itemContext.pages > this._itemContext.maxPages && (pagerRendered = this._renderPagerComponent(isHorizontal)),
147
152
  pagerRendered || (itemsContainer.setAttribute("y", this._title ? this._title.AABBBounds.height() + get(this.attribute, "title.space", 8) : 0),
148
153
  this._innerView.add(itemsContainer));
149
154
  }
@@ -156,7 +161,7 @@ export class DiscreteLegend extends LegendBase {
156
161
  }
157
162
  _renderEachItem(item, isSelected, index, items) {
158
163
  var _a, _b;
159
- const {id: id, label: label, value: value, shape: shape} = item, {padding: padding = 0, focus: focus, focusIconStyle: focusIconStyle} = this.attribute.item, {shape: shapeAttr, label: labelAttr, value: valueAttr, background: background} = this.attribute.item, shapeStyle = this._handleStyle(shapeAttr, item, isSelected, index, items), labelStyle = this._handleStyle(labelAttr, item, isSelected, index, items), valueStyle = this._handleStyle(valueAttr, item, isSelected, index, items), backgroundStyle = this._handleStyle(background, item, isSelected, index, items), parsedPadding = normalizePadding(padding);
164
+ const {id: id, label: label, value: value, shape: shape} = item, {padding: padding = 0, focus: focus, focusIconStyle: focusIconStyle, align: align} = this.attribute.item, {shape: shapeAttr, label: labelAttr, value: valueAttr, background: background} = this.attribute.item, shapeStyle = this._handleStyle(shapeAttr, item, isSelected, index, items), labelStyle = this._handleStyle(labelAttr, item, isSelected, index, items), valueStyle = this._handleStyle(valueAttr, item, isSelected, index, items), backgroundStyle = this._handleStyle(background, item, isSelected, index, items), parsedPadding = normalizePadding(padding);
160
165
  let itemGroup;
161
166
  !1 === background.visible ? (itemGroup = graphicCreator.group({
162
167
  x: 0,
@@ -175,7 +180,8 @@ export class DiscreteLegend extends LegendBase {
175
180
  itemGroup.add(innerGroup);
176
181
  let focusShape, focusStartX = 0, shapeSize = 0, shapeSpace = 0;
177
182
  if (shapeAttr && !1 !== shapeAttr.visible) {
178
- shapeSize = get(shapeStyle, "style.size", DEFAULT_SHAPE_SIZE), shapeSpace = get(shapeAttr, "space", DEFAULT_SHAPE_SPACE);
183
+ const s = get(shapeStyle, "style.size", DEFAULT_SHAPE_SIZE);
184
+ shapeSize = isArray(s) ? s[0] || 0 : s, shapeSpace = get(shapeAttr, "space", DEFAULT_SHAPE_SPACE);
179
185
  const itemShape = graphicCreator.symbol(Object.assign(Object.assign({
180
186
  x: 0,
181
187
  y: 0,
@@ -190,7 +196,7 @@ export class DiscreteLegend extends LegendBase {
190
196
  itemShape.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected),
191
197
  innerGroup.add(itemShape);
192
198
  }
193
- let focusSpace = 0;
199
+ let labelShape, focusSpace = 0;
194
200
  if (focus) {
195
201
  const focusSize = get(focusIconStyle, "size", DEFAULT_SHAPE_SIZE);
196
202
  focusShape = graphicCreator.symbol(Object.assign(Object.assign({
@@ -204,30 +210,33 @@ export class DiscreteLegend extends LegendBase {
204
210
  })), this._appendDataToShape(focusShape, LEGEND_ELEMENT_NAME.focus, item, itemGroup),
205
211
  focusSpace = focusSize;
206
212
  }
207
- const labelShape = graphicCreator.text(Object.assign(Object.assign({
213
+ const text = labelAttr.formatMethod ? labelAttr.formatMethod(label, item, index) : label, labelAttributes = Object.assign(Object.assign({
208
214
  x: shapeSize / 2 + shapeSpace,
209
215
  y: 0,
210
216
  textAlign: "start",
211
217
  textBaseline: "middle",
212
218
  lineHeight: null === (_b = labelStyle.style) || void 0 === _b ? void 0 : _b.fontSize
213
219
  }, labelStyle.style), {
214
- text: labelAttr.formatMethod ? labelAttr.formatMethod(label, item, index) : label
215
- }));
220
+ text: text
221
+ });
222
+ labelShape = isRichText(labelAttributes) ? graphicCreator.richtext(richTextAttributeTransform(labelAttributes)) : graphicCreator.text(labelAttributes),
216
223
  this._appendDataToShape(labelShape, LEGEND_ELEMENT_NAME.itemLabel, item, itemGroup, labelStyle.state),
217
224
  labelShape.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected),
218
225
  innerGroup.add(labelShape);
219
226
  const labelSpace = get(labelAttr, "space", DEFAULT_LABEL_SPACE);
220
227
  if (isValid(value)) {
221
- const valueSpace = get(valueAttr, "space", focus ? DEFAULT_VALUE_SPACE : 0), valueShape = graphicCreator.text(Object.assign(Object.assign({
228
+ const valueSpace = get(valueAttr, "space", focus ? DEFAULT_VALUE_SPACE : 0), valueText = valueAttr.formatMethod ? valueAttr.formatMethod(value, item, index) : value, valueAttributes = Object.assign(Object.assign({
222
229
  x: 0,
223
230
  y: 0,
224
231
  textAlign: "start",
225
232
  textBaseline: "middle",
226
233
  lineHeight: valueStyle.style.fontSize
227
234
  }, valueStyle.style), {
228
- text: valueAttr.formatMethod ? valueAttr.formatMethod(value, item, index) : value
229
- }));
230
- if (this._appendDataToShape(valueShape, LEGEND_ELEMENT_NAME.itemValue, item, itemGroup, valueStyle.state),
235
+ text: valueText
236
+ });
237
+ let valueShape;
238
+ if (valueShape = isRichText(valueAttributes) ? graphicCreator.richtext(richTextAttributeTransform(valueAttributes)) : graphicCreator.text(valueAttributes),
239
+ this._appendDataToShape(valueShape, LEGEND_ELEMENT_NAME.itemValue, item, itemGroup, valueStyle.state),
231
240
  valueShape.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected),
232
241
  this._itemWidthByUser) {
233
242
  const layoutWidth = this._itemWidthByUser - parsedPadding[1] - parsedPadding[3] - shapeSize - shapeSpace - labelSpace - focusSpace - valueSpace, valueBounds = valueShape.AABBBounds, labelBounds = labelShape.AABBBounds, valueWidth = valueBounds.width(), labelWidth = labelBounds.width();
@@ -242,85 +251,150 @@ export class DiscreteLegend extends LegendBase {
242
251
  } else this._itemWidthByUser ? (labelShape.setAttribute("maxLineWidth", this._itemWidthByUser - parsedPadding[1] - parsedPadding[3] - shapeSize - shapeSpace - focusSpace),
243
252
  focusStartX = labelShape.AABBBounds.x2 + labelSpace) : focusStartX = labelShape.AABBBounds.x2 + labelSpace;
244
253
  focusShape && (focusShape.setAttribute("x", focusStartX), innerGroup.add(focusShape));
245
- const innerGroupBounds = innerGroup.AABBBounds, innerGroupWidth = innerGroupBounds.width(), innerGroupHeight = innerGroupBounds.height(), itemGroupWidth = isValid(this.attribute.item.width) ? this.attribute.item.width : innerGroupWidth + parsedPadding[1] + parsedPadding[3], itemGroupHeight = this._itemHeightByUser || innerGroupHeight + parsedPadding[0] + parsedPadding[2];
254
+ const innerGroupBounds = innerGroup.AABBBounds, innerGroupWidth = innerGroupBounds.width();
255
+ if ("right" === align) {
256
+ const x2 = innerGroupBounds.x2, x1 = innerGroupBounds.x1;
257
+ innerGroup.forEachChildren(((child, index) => {
258
+ "symbol" !== child.type && "right" !== child.attribute.textAlign || child === focusShape ? child.setAttribute("x", x1 + x2 - child.attribute.x - child.AABBBounds.width()) : "symbol" !== child.type ? child.setAttributes({
259
+ x: x1 + x2 - child.attribute.x,
260
+ textAlign: "left"
261
+ }) : child.setAttribute("x", x1 + x2 - child.attribute.x);
262
+ }));
263
+ }
264
+ const innerGroupHeight = innerGroupBounds.height(), itemGroupWidth = isValid(this.attribute.item.width) ? this.attribute.item.width : innerGroupWidth + parsedPadding[1] + parsedPadding[3], itemGroupHeight = this._itemHeightByUser || innerGroupHeight + parsedPadding[0] + parsedPadding[2];
246
265
  return itemGroup.attribute.width = itemGroupWidth, itemGroup.attribute.height = itemGroupHeight,
247
266
  focusShape && focusShape.setAttribute("visible", !1), innerGroup.translateTo(-innerGroupBounds.x1 + parsedPadding[3], -innerGroupBounds.y1 + parsedPadding[0]),
248
267
  itemGroup;
249
268
  }
250
- _renderPager(isHorizontal) {
251
- const renderStartY = this._title ? this._title.AABBBounds.height() + get(this.attribute, "title.space", 8) : 0, {maxWidth: maxWidth, maxHeight: maxHeight, maxCol: maxCol = 1, maxRow: maxRow = 2, item: item = {}, pager: pager = {}, disableTriggerEvent: disableTriggerEvent} = this.attribute, {spaceCol: spaceCol = DEFAULT_ITEM_SPACE_COL, spaceRow: spaceRow = DEFAULT_ITEM_SPACE_ROW} = item, itemsContainer = this._itemsContainer, {animation: animation = !0, animationDuration: animationDuration = 450, animationEasing: animationEasing = "quadIn", space: pagerSpace = DEFAULT_PAGER_SPACE, position: position = "middle"} = pager, pageStyle = __rest(pager, [ "animation", "animationDuration", "animationEasing", "space", "position" ]);
252
- let pagerComp, pageHeight = 0, pageWidth = 0, startX = 0, startY = 0, pages = 1;
253
- if (isHorizontal) {
254
- if (pagerComp = new Pager(Object.assign(Object.assign({
255
- layout: 1 === maxRow ? "horizontal" : "vertical",
256
- total: 99
257
- }, merge({
258
- handler: {
259
- preShape: "triangleUp",
260
- nextShape: "triangleDown"
269
+ _createPager(isScrollbar, isHorizontal, compStyle, compSize) {
270
+ var _a, _b;
271
+ const {disableTriggerEvent: disableTriggerEvent, maxRow: maxRow} = this.attribute;
272
+ return isScrollbar ? new ScrollBar(isHorizontal ? Object.assign(Object.assign({
273
+ direction: "vertical",
274
+ width: 12,
275
+ range: [ 0, .5 ]
276
+ }, compStyle), {
277
+ height: compSize,
278
+ disableTriggerEvent: disableTriggerEvent
279
+ }) : Object.assign(Object.assign({
280
+ direction: "horizontal",
281
+ disableTriggerEvent: disableTriggerEvent,
282
+ range: [ 0, .5 ],
283
+ height: 12
284
+ }, compStyle), {
285
+ width: compSize
286
+ })) : new Pager(isHorizontal ? Object.assign(Object.assign({
287
+ layout: 1 === maxRow ? "horizontal" : "vertical",
288
+ total: 99
289
+ }, merge({
290
+ handler: {
291
+ preShape: "triangleUp",
292
+ nextShape: "triangleDown"
293
+ }
294
+ }, compStyle)), {
295
+ defaultCurrent: null === (_a = this.attribute.pager) || void 0 === _a ? void 0 : _a.defaultCurrent,
296
+ disableTriggerEvent: disableTriggerEvent
297
+ }) : Object.assign({
298
+ layout: "horizontal",
299
+ total: 99,
300
+ disableTriggerEvent: disableTriggerEvent,
301
+ defaultCurrent: null === (_b = this.attribute.pager) || void 0 === _b ? void 0 : _b.defaultCurrent
302
+ }, compStyle));
303
+ }
304
+ _updatePositionOfPager(isScrollbar, isHorizontal, contentSize, renderStartY, compSize) {
305
+ const {maxHeight: maxHeight, pager: pager} = this.attribute, {currentPage: currentPage, totalPage: totalPage} = this._itemContext;
306
+ if (isScrollbar) this._pagerComponent.setScrollRange([ (currentPage - 1) / totalPage, currentPage / totalPage ]),
307
+ isHorizontal ? this._pagerComponent.setAttributes({
308
+ x: contentSize,
309
+ y: renderStartY
310
+ }) : this._pagerComponent.setAttributes({
311
+ x: 0,
312
+ y: maxHeight - this._pagerComponent.AABBBounds.height()
313
+ }); else {
314
+ const position = pager && pager.position || "middle";
315
+ if (this._pagerComponent.setTotal(totalPage), isHorizontal) {
316
+ let y;
317
+ y = "start" === position ? renderStartY : "end" === position ? renderStartY + compSize - this._pagerComponent.AABBBounds.height() / 2 : renderStartY + compSize / 2 - this._pagerComponent.AABBBounds.height() / 2,
318
+ this._pagerComponent.setAttributes({
319
+ x: contentSize,
320
+ y: y
321
+ });
322
+ } else {
323
+ let x;
324
+ x = "start" === position ? 0 : "end" === position ? compSize - this._pagerComponent.AABBBounds.width() : (compSize - this._pagerComponent.AABBBounds.width()) / 2,
325
+ this._pagerComponent.setAttributes({
326
+ x: x,
327
+ y: maxHeight - this._pagerComponent.AABBBounds.height()
328
+ });
329
+ }
330
+ }
331
+ }
332
+ _bindEventsOfPager(isScrollbar, isHorizontal, compSize, spaceSize) {
333
+ const pager = this.attribute.pager || {}, {animation: animation = !0, animationDuration: animationDuration = 450, animationEasing: animationEasing = "quadIn"} = pager, pageParser = isScrollbar ? e => {
334
+ const {value: value} = e.detail;
335
+ let newPage = value[0] * this._itemContext.totalPage;
336
+ return pager.scrollByPosition ? newPage += 1 : newPage = Math.floor(newPage) + 1,
337
+ newPage;
338
+ } : e => e.detail.current, onPaging = e => {
339
+ const newPage = pageParser(e);
340
+ if (newPage !== this._itemContext.currentPage) {
341
+ if (this._itemContext.currentPage = newPage, this._itemContext && this._itemContext.startIndex < this._itemContext.items.length) {
342
+ this._renderItems();
343
+ const newTotalPage = Math.ceil(this._itemContext.pages / this._itemContext.maxPages);
344
+ this._itemContext.totalPage = newTotalPage, this._pagerComponent.setScrollRange([ (newPage - 1) / newTotalPage, newPage / newTotalPage ]);
261
345
  }
262
- }, pageStyle)), {
263
- disableTriggerEvent: disableTriggerEvent
264
- })), this._pager = pagerComp, this._innerView.add(pagerComp), pageHeight = (maxRow - 1) * spaceRow + this._itemHeight * maxRow,
265
- pageWidth = maxWidth - pagerComp.AABBBounds.width() - pagerSpace, pageWidth <= 0) return this._innerView.removeChild(pagerComp),
266
- !1;
267
- let y;
346
+ animation ? this._itemsContainer.animate().to(isHorizontal ? {
347
+ y: -(newPage - 1) * (compSize + spaceSize)
348
+ } : {
349
+ x: -(newPage - 1) * (compSize + spaceSize)
350
+ }, animationDuration, animationEasing) : isHorizontal ? this._itemsContainer.setAttribute("y", -(newPage - 1) * (compSize + spaceSize)) : this._itemsContainer.setAttribute("x", -(newPage - 1) * (compSize + spaceSize));
351
+ }
352
+ };
353
+ isScrollbar ? (this._pagerComponent.addEventListener("scrollDrag", onPaging), this._pagerComponent.addEventListener("scrollUp", onPaging)) : (this._pagerComponent.addEventListener("toPrev", onPaging),
354
+ this._pagerComponent.addEventListener("toNext", onPaging));
355
+ }
356
+ _renderPagerComponent(isHorizontal) {
357
+ const renderStartY = this._title ? this._title.AABBBounds.height() + get(this.attribute, "title.space", 8) : 0, {maxWidth: maxWidth, maxHeight: maxHeight, maxCol: maxCol = 1, maxRow: maxRow = 2, 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" ]), isScrollbar = "scrollbar" === pager.type;
358
+ let comp, compSize = 0, contentSize = 0, startX = 0, startY = 0, pages = 1;
359
+ if (isHorizontal) {
360
+ if (compSize = (maxRow - 1) * spaceRow + this._itemHeight * maxRow, comp = this._createPager(isScrollbar, isHorizontal, compStyle, compSize),
361
+ this._pagerComponent = comp, this._innerView.add(comp), contentSize = maxWidth - comp.AABBBounds.width() - pagerSpace,
362
+ contentSize <= 0) return this._innerView.removeChild(comp), !1;
268
363
  itemsContainer.getChildren().forEach(((item, index) => {
269
364
  const {width: width, height: height} = item.attribute;
270
- pageWidth < startX + width && (startX = 0, startY += height + spaceRow, pages += 1),
365
+ contentSize < startX + width && (startX = 0, startY += height + spaceRow, pages += 1),
271
366
  index > 0 && item.setAttributes({
272
367
  x: startX,
273
368
  y: startY
274
369
  }), startX += spaceCol + width;
275
- })), this._itemContext.startX = startX, this._itemContext.startY = startY, this._itemContext.pages = pages,
276
- pagerComp.setTotal(Math.ceil(pages / maxRow)), y = "start" === position ? renderStartY : "end" === position ? renderStartY + pageHeight - pagerComp.AABBBounds.height() / 2 : renderStartY + pageHeight / 2 - pagerComp.AABBBounds.height() / 2,
277
- pagerComp.setAttributes({
278
- x: pageWidth,
279
- y: y
280
- });
370
+ })), this._itemContext.startX = startX, this._itemContext.startY = startY, this._itemContext.pages = pages;
371
+ const total = Math.ceil(pages / maxRow);
372
+ this._itemContext.totalPage = total, this._updatePositionOfPager(isScrollbar, isHorizontal, contentSize, renderStartY, compSize);
281
373
  } else {
282
- if (pagerComp = new Pager(Object.assign({
283
- layout: "horizontal",
284
- total: 99,
285
- disableTriggerEvent: disableTriggerEvent
286
- }, pageStyle)), this._pager = pagerComp, this._innerView.add(pagerComp), pageWidth = this._itemMaxWidth * maxCol + (maxCol - 1) * spaceCol,
287
- pageHeight = maxHeight - pagerComp.AABBBounds.height() - pagerSpace - renderStartY,
288
- pageHeight <= 0) return this._innerView.removeChild(pagerComp), !1;
289
- let x;
374
+ if (compSize = this._itemMaxWidth * maxCol + (maxCol - 1) * spaceCol, comp = this._createPager(isScrollbar, isHorizontal, compStyle, compSize),
375
+ this._pagerComponent = comp, this._innerView.add(comp), contentSize = maxHeight - comp.AABBBounds.height() - pagerSpace - renderStartY,
376
+ contentSize <= 0) return this._innerView.removeChild(comp), !1;
290
377
  itemsContainer.getChildren().forEach(((item, index) => {
291
378
  const {height: height} = item.attribute;
292
- pageHeight < startY + height && (startY = 0, startX += this._itemMaxWidth + spaceCol,
379
+ contentSize < startY + height && (startY = 0, startX += this._itemMaxWidth + spaceCol,
293
380
  pages += 1), index > 0 && item.setAttributes({
294
381
  x: startX,
295
382
  y: startY
296
383
  }), startY += spaceRow + height;
297
- })), pagerComp.setTotal(Math.ceil(pages / maxCol)), x = "start" === position ? 0 : "end" === position ? pageWidth - pagerComp.AABBBounds.width() : (pageWidth - pagerComp.AABBBounds.width()) / 2,
298
- pagerComp.setAttributes({
299
- x: x,
300
- y: maxHeight - pagerComp.AABBBounds.height()
301
- });
384
+ }));
385
+ const total = Math.ceil(pages / maxCol);
386
+ this._itemContext.totalPage = total, this._updatePositionOfPager(isScrollbar, isHorizontal, contentSize, renderStartY, compSize);
302
387
  }
303
- pager.defaultCurrent > 1 && (isHorizontal ? itemsContainer.setAttribute("y", -(pager.defaultCurrent - 1) * (pageHeight + spaceRow)) : itemsContainer.setAttribute("x", -(pager.defaultCurrent - 1) * (pageWidth + spaceCol)));
388
+ defaultCurrent > 1 && (isHorizontal ? itemsContainer.setAttribute("y", -(defaultCurrent - 1) * (compSize + spaceRow)) : itemsContainer.setAttribute("x", -(defaultCurrent - 1) * (compSize + spaceCol)));
304
389
  const clipGroup = graphicCreator.group({
305
390
  x: 0,
306
391
  y: renderStartY,
307
- width: pageWidth,
308
- height: pageHeight,
392
+ width: isHorizontal ? contentSize : compSize,
393
+ height: isHorizontal ? compSize : contentSize,
309
394
  clip: !0,
310
395
  pickable: !1
311
396
  });
312
- clipGroup.add(itemsContainer), this._innerView.add(clipGroup);
313
- const onPaging = e => {
314
- const {current: current} = e.detail;
315
- this._itemContext.currentPage = current, this._itemContext && this._itemContext.startIndex < this._itemContext.items.length && (this._renderItems(),
316
- pagerComp.setTotal(Math.ceil(this._itemContext.pages / this._itemContext.maxPages))),
317
- animation ? itemsContainer.animate().to(isHorizontal ? {
318
- y: -(current - 1) * (pageHeight + spaceRow)
319
- } : {
320
- x: -(current - 1) * (pageWidth + spaceCol)
321
- }, animationDuration, animationEasing) : isHorizontal ? itemsContainer.setAttribute("y", -(current - 1) * (pageHeight + spaceRow)) : itemsContainer.setAttribute("x", -(current - 1) * (pageWidth + spaceCol));
322
- };
323
- return this._pager.addEventListener("toPrev", onPaging), this._pager.addEventListener("toNext", onPaging),
397
+ return clipGroup.add(itemsContainer), this._innerView.add(clipGroup), this._bindEventsOfPager(isScrollbar, isHorizontal, compSize, isHorizontal ? spaceRow : spaceCol),
324
398
  !0;
325
399
  }
326
400
  _hover(legendItem, e) {