@antv/component 2.1.0 → 2.1.1-alpha.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 (494) hide show
  1. package/dist/component.min.js +1 -1
  2. package/esm/animation/utils.js +31 -37
  3. package/esm/animation/utils.js.map +1 -1
  4. package/esm/constant.js +1 -1
  5. package/esm/constant.js.map +1 -1
  6. package/esm/core/component.js +30 -43
  7. package/esm/core/component.js.map +1 -1
  8. package/esm/shapes/Text.js +13 -21
  9. package/esm/shapes/Text.js.map +1 -1
  10. package/esm/ui/axis/axis.js +25 -31
  11. package/esm/ui/axis/axis.js.map +1 -1
  12. package/esm/ui/axis/constant.js +11 -13
  13. package/esm/ui/axis/constant.js.map +1 -1
  14. package/esm/ui/axis/guides/grid.js +29 -34
  15. package/esm/ui/axis/guides/grid.js.map +1 -1
  16. package/esm/ui/axis/guides/labels.js +76 -83
  17. package/esm/ui/axis/guides/labels.js.map +1 -1
  18. package/esm/ui/axis/guides/line.js +74 -87
  19. package/esm/ui/axis/guides/line.js.map +1 -1
  20. package/esm/ui/axis/guides/ticks.js +31 -39
  21. package/esm/ui/axis/guides/ticks.js.map +1 -1
  22. package/esm/ui/axis/guides/title.js +33 -37
  23. package/esm/ui/axis/guides/title.js.map +1 -1
  24. package/esm/ui/axis/guides/utils.js +10 -12
  25. package/esm/ui/axis/guides/utils.js.map +1 -1
  26. package/esm/ui/axis/overlap/autoEllipsis.js +12 -19
  27. package/esm/ui/axis/overlap/autoEllipsis.js.map +1 -1
  28. package/esm/ui/axis/overlap/autoHide.js +20 -24
  29. package/esm/ui/axis/overlap/autoHide.js.map +1 -1
  30. package/esm/ui/axis/overlap/autoRotate.js +11 -25
  31. package/esm/ui/axis/overlap/autoRotate.js.map +1 -1
  32. package/esm/ui/axis/overlap/autoWrap.js +11 -14
  33. package/esm/ui/axis/overlap/autoWrap.js.map +1 -1
  34. package/esm/ui/axis/overlap/index.js +7 -7
  35. package/esm/ui/axis/overlap/index.js.map +1 -1
  36. package/esm/ui/axis/utils/bounds.js +48 -75
  37. package/esm/ui/axis/utils/bounds.js.map +1 -1
  38. package/esm/ui/axis/utils/contain.js +14 -14
  39. package/esm/ui/axis/utils/contain.js.map +1 -1
  40. package/esm/ui/axis/utils/index.js +3 -7
  41. package/esm/ui/axis/utils/index.js.map +1 -1
  42. package/esm/ui/axis/utils/intersect.js +21 -33
  43. package/esm/ui/axis/utils/intersect.js.map +1 -1
  44. package/esm/ui/axis/utils/test.js +29 -41
  45. package/esm/ui/axis/utils/test.js.map +1 -1
  46. package/esm/ui/breadcrumb/index.js +64 -72
  47. package/esm/ui/breadcrumb/index.js.map +1 -1
  48. package/esm/ui/button/constant.js +3 -3
  49. package/esm/ui/button/constant.js.map +1 -1
  50. package/esm/ui/button/index.js +81 -97
  51. package/esm/ui/button/index.js.map +1 -1
  52. package/esm/ui/checkbox/constant.js +4 -4
  53. package/esm/ui/checkbox/constant.js.map +1 -1
  54. package/esm/ui/checkbox/index.js +23 -26
  55. package/esm/ui/checkbox/index.js.map +1 -1
  56. package/esm/ui/crosshair/base.js +29 -45
  57. package/esm/ui/crosshair/base.js.map +1 -1
  58. package/esm/ui/crosshair/circle.js +25 -34
  59. package/esm/ui/crosshair/circle.js.map +1 -1
  60. package/esm/ui/crosshair/constant.js +4 -4
  61. package/esm/ui/crosshair/constant.js.map +1 -1
  62. package/esm/ui/crosshair/line.js +55 -75
  63. package/esm/ui/crosshair/line.js.map +1 -1
  64. package/esm/ui/crosshair/polygon.js +54 -70
  65. package/esm/ui/crosshair/polygon.js.map +1 -1
  66. package/esm/ui/grid/index.js +73 -95
  67. package/esm/ui/grid/index.js.map +1 -1
  68. package/esm/ui/indicator/constant.js +2 -2
  69. package/esm/ui/indicator/constant.js.map +1 -1
  70. package/esm/ui/indicator/indicator.js +58 -63
  71. package/esm/ui/indicator/indicator.js.map +1 -1
  72. package/esm/ui/layout/layout.js +52 -66
  73. package/esm/ui/layout/layout.js.map +1 -1
  74. package/esm/ui/legend/base.js +12 -13
  75. package/esm/ui/legend/base.js.map +1 -1
  76. package/esm/ui/legend/category/item.js +122 -156
  77. package/esm/ui/legend/category/item.js.map +1 -1
  78. package/esm/ui/legend/category/items.js +158 -201
  79. package/esm/ui/legend/category/items.js.map +1 -1
  80. package/esm/ui/legend/category.js +46 -56
  81. package/esm/ui/legend/category.js.map +1 -1
  82. package/esm/ui/legend/constant.js +6 -6
  83. package/esm/ui/legend/constant.js.map +1 -1
  84. package/esm/ui/legend/continuous/handle.js +28 -33
  85. package/esm/ui/legend/continuous/handle.js.map +1 -1
  86. package/esm/ui/legend/continuous/ribbon.js +34 -38
  87. package/esm/ui/legend/continuous/ribbon.js.map +1 -1
  88. package/esm/ui/legend/continuous/utils.js +10 -11
  89. package/esm/ui/legend/continuous/utils.js.map +1 -1
  90. package/esm/ui/legend/continuous.js +417 -521
  91. package/esm/ui/legend/continuous.js.map +1 -1
  92. package/esm/ui/legend/utils.js +24 -31
  93. package/esm/ui/legend/utils.js.map +1 -1
  94. package/esm/ui/marker/index.js +38 -44
  95. package/esm/ui/marker/index.js.map +1 -1
  96. package/esm/ui/marker/symbol.js +24 -24
  97. package/esm/ui/marker/symbol.js.map +1 -1
  98. package/esm/ui/marker/utils.js +2 -2
  99. package/esm/ui/marker/utils.js.map +1 -1
  100. package/esm/ui/navigator/index.js +128 -159
  101. package/esm/ui/navigator/index.js.map +1 -1
  102. package/esm/ui/poptip/constant.js +67 -68
  103. package/esm/ui/poptip/constant.js.map +1 -1
  104. package/esm/ui/poptip/index.js +95 -111
  105. package/esm/ui/poptip/index.js.map +1 -1
  106. package/esm/ui/poptip/utils.js +8 -15
  107. package/esm/ui/poptip/utils.js.map +1 -1
  108. package/esm/ui/scrollbar/index.js +102 -132
  109. package/esm/ui/scrollbar/index.js.map +1 -1
  110. package/esm/ui/select/option.js +48 -58
  111. package/esm/ui/select/option.js.map +1 -1
  112. package/esm/ui/select/select.js +142 -164
  113. package/esm/ui/select/select.js.map +1 -1
  114. package/esm/ui/slider/constant.js +4 -4
  115. package/esm/ui/slider/constant.js.map +1 -1
  116. package/esm/ui/slider/handle.js +46 -54
  117. package/esm/ui/slider/handle.js.map +1 -1
  118. package/esm/ui/slider/index.js +280 -326
  119. package/esm/ui/slider/index.js.map +1 -1
  120. package/esm/ui/sparkline/columns.js +25 -34
  121. package/esm/ui/sparkline/columns.js.map +1 -1
  122. package/esm/ui/sparkline/index.js +145 -180
  123. package/esm/ui/sparkline/index.js.map +1 -1
  124. package/esm/ui/sparkline/lines.js +37 -50
  125. package/esm/ui/sparkline/lines.js.map +1 -1
  126. package/esm/ui/sparkline/path.js +36 -40
  127. package/esm/ui/sparkline/path.js.map +1 -1
  128. package/esm/ui/sparkline/utils.js +8 -9
  129. package/esm/ui/sparkline/utils.js.map +1 -1
  130. package/esm/ui/switch/constant.js +1 -1
  131. package/esm/ui/switch/constant.js.map +1 -1
  132. package/esm/ui/switch/index.js +44 -54
  133. package/esm/ui/switch/index.js.map +1 -1
  134. package/esm/ui/tag/index.js +29 -32
  135. package/esm/ui/tag/index.js.map +1 -1
  136. package/esm/ui/timebar/controller.js +69 -79
  137. package/esm/ui/timebar/controller.js.map +1 -1
  138. package/esm/ui/timebar/handle.js +62 -71
  139. package/esm/ui/timebar/handle.js.map +1 -1
  140. package/esm/ui/timebar/icons.js +308 -478
  141. package/esm/ui/timebar/icons.js.map +1 -1
  142. package/esm/ui/timebar/timebar.js +263 -318
  143. package/esm/ui/timebar/timebar.js.map +1 -1
  144. package/esm/ui/timebar/utils.js +7 -7
  145. package/esm/ui/timebar/utils.js.map +1 -1
  146. package/esm/ui/timeline/index.js +2 -6
  147. package/esm/ui/timeline/index.js.map +1 -1
  148. package/esm/ui/title/index.js +59 -64
  149. package/esm/ui/title/index.js.map +1 -1
  150. package/esm/ui/tooltip/constant.js +26 -30
  151. package/esm/ui/tooltip/constant.js.map +1 -1
  152. package/esm/ui/tooltip/index.js +109 -126
  153. package/esm/ui/tooltip/index.js.map +1 -1
  154. package/esm/util/bbox.js +24 -47
  155. package/esm/util/bbox.js.map +1 -1
  156. package/esm/util/callback.js +1 -2
  157. package/esm/util/callback.js.map +1 -1
  158. package/esm/util/classnames.js +8 -10
  159. package/esm/util/classnames.js.map +1 -1
  160. package/esm/util/deep-assign.js +6 -14
  161. package/esm/util/deep-assign.js.map +1 -1
  162. package/esm/util/defined.js +1 -1
  163. package/esm/util/defined.js.map +1 -1
  164. package/esm/util/ellipsis.js +1 -2
  165. package/esm/util/ellipsis.js.map +1 -1
  166. package/esm/util/event.js +3 -3
  167. package/esm/util/event.js.map +1 -1
  168. package/esm/util/geometry/line-length.js +1 -4
  169. package/esm/util/geometry/line-length.js.map +1 -1
  170. package/esm/util/geometry/lines-intersection.js +5 -10
  171. package/esm/util/geometry/lines-intersection.js.map +1 -1
  172. package/esm/util/group-by.js +1 -1
  173. package/esm/util/group-by.js.map +1 -1
  174. package/esm/util/group.js +3 -3
  175. package/esm/util/group.js.map +1 -1
  176. package/esm/util/html.js +1 -1
  177. package/esm/util/html.js.map +1 -1
  178. package/esm/util/if-show.js +3 -5
  179. package/esm/util/if-show.js.map +1 -1
  180. package/esm/util/in-range.js +1 -3
  181. package/esm/util/in-range.js.map +1 -1
  182. package/esm/util/interpolate.js +12 -19
  183. package/esm/util/interpolate.js.map +1 -1
  184. package/esm/util/keyframe-interpolate.js +6 -7
  185. package/esm/util/keyframe-interpolate.js.map +1 -1
  186. package/esm/util/layout/executer.js +4 -4
  187. package/esm/util/layout/executer.js.map +1 -1
  188. package/esm/util/layout/flex/index.js +24 -26
  189. package/esm/util/layout/flex/index.js.map +1 -1
  190. package/esm/util/layout/grid/index.js +1 -1
  191. package/esm/util/layout/grid/index.js.map +1 -1
  192. package/esm/util/layout/utils/helper.js +7 -8
  193. package/esm/util/layout/utils/helper.js.map +1 -1
  194. package/esm/util/matrix.js +7 -8
  195. package/esm/util/matrix.js.map +1 -1
  196. package/esm/util/number.js +6 -7
  197. package/esm/util/number.js.map +1 -1
  198. package/esm/util/offscreen.js +9 -17
  199. package/esm/util/offscreen.js.map +1 -1
  200. package/esm/util/omit.js +3 -3
  201. package/esm/util/omit.js.map +1 -1
  202. package/esm/util/path.js +36 -41
  203. package/esm/util/path.js.map +1 -1
  204. package/esm/util/primitive.js +3 -3
  205. package/esm/util/primitive.js.map +1 -1
  206. package/esm/util/replace-children.js +3 -4
  207. package/esm/util/replace-children.js.map +1 -1
  208. package/esm/util/sampling.js +3 -3
  209. package/esm/util/sampling.js.map +1 -1
  210. package/esm/util/scale-to-pixel.js +4 -5
  211. package/esm/util/scale-to-pixel.js.map +1 -1
  212. package/esm/util/selection.js +142 -186
  213. package/esm/util/selection.js.map +1 -1
  214. package/esm/util/series.js +1 -1
  215. package/esm/util/series.js.map +1 -1
  216. package/esm/util/shape.js +15 -27
  217. package/esm/util/shape.js.map +1 -1
  218. package/esm/util/string.js +4 -5
  219. package/esm/util/string.js.map +1 -1
  220. package/esm/util/style.js +23 -29
  221. package/esm/util/style.js.map +1 -1
  222. package/esm/util/svg2marker.js +13 -16
  223. package/esm/util/svg2marker.js.map +1 -1
  224. package/esm/util/text.js +14 -14
  225. package/esm/util/text.js.map +1 -1
  226. package/esm/util/throttle.js +7 -13
  227. package/esm/util/throttle.js.map +1 -1
  228. package/esm/util/time.js +22 -24
  229. package/esm/util/time.js.map +1 -1
  230. package/esm/util/timer.js +5 -9
  231. package/esm/util/timer.js.map +1 -1
  232. package/esm/util/transform.js +5 -6
  233. package/esm/util/transform.js.map +1 -1
  234. package/esm/util/transpose.js +1 -1
  235. package/esm/util/transpose.js.map +1 -1
  236. package/esm/util/traverse.js +1 -1
  237. package/esm/util/traverse.js.map +1 -1
  238. package/esm/util/visibility.js +2 -2
  239. package/esm/util/visibility.js.map +1 -1
  240. package/esm/util/wrap.js +2 -4
  241. package/esm/util/wrap.js.map +1 -1
  242. package/lib/animation/fadeIn.js +1 -1
  243. package/lib/animation/fadeIn.js.map +1 -1
  244. package/lib/animation/fadeOut.js +1 -1
  245. package/lib/animation/fadeOut.js.map +1 -1
  246. package/lib/animation/index.js +1 -1
  247. package/lib/animation/utils.js +33 -39
  248. package/lib/animation/utils.js.map +1 -1
  249. package/lib/core/component.js +31 -43
  250. package/lib/core/component.js.map +1 -1
  251. package/lib/core/index.js +1 -1
  252. package/lib/index.js +1 -1
  253. package/lib/shapes/Text.js +15 -22
  254. package/lib/shapes/Text.js.map +1 -1
  255. package/lib/shapes/index.js +1 -1
  256. package/lib/types/index.js +1 -1
  257. package/lib/ui/axis/axis.js +34 -39
  258. package/lib/ui/axis/axis.js.map +1 -1
  259. package/lib/ui/axis/constant.js +10 -12
  260. package/lib/ui/axis/constant.js.map +1 -1
  261. package/lib/ui/axis/guides/grid.js +35 -40
  262. package/lib/ui/axis/guides/grid.js.map +1 -1
  263. package/lib/ui/axis/guides/labels.js +82 -89
  264. package/lib/ui/axis/guides/labels.js.map +1 -1
  265. package/lib/ui/axis/guides/line.js +79 -92
  266. package/lib/ui/axis/guides/line.js.map +1 -1
  267. package/lib/ui/axis/guides/ticks.js +37 -45
  268. package/lib/ui/axis/guides/ticks.js.map +1 -1
  269. package/lib/ui/axis/guides/title.js +37 -41
  270. package/lib/ui/axis/guides/title.js.map +1 -1
  271. package/lib/ui/axis/guides/utils.js +12 -14
  272. package/lib/ui/axis/guides/utils.js.map +1 -1
  273. package/lib/ui/axis/overlap/autoEllipsis.js +15 -22
  274. package/lib/ui/axis/overlap/autoEllipsis.js.map +1 -1
  275. package/lib/ui/axis/overlap/autoHide.js +23 -27
  276. package/lib/ui/axis/overlap/autoHide.js.map +1 -1
  277. package/lib/ui/axis/overlap/autoRotate.js +12 -26
  278. package/lib/ui/axis/overlap/autoRotate.js.map +1 -1
  279. package/lib/ui/axis/overlap/autoWrap.js +13 -16
  280. package/lib/ui/axis/overlap/autoWrap.js.map +1 -1
  281. package/lib/ui/axis/overlap/index.js +12 -12
  282. package/lib/ui/axis/overlap/index.js.map +1 -1
  283. package/lib/ui/axis/utils/bounds.js +49 -75
  284. package/lib/ui/axis/utils/bounds.js.map +1 -1
  285. package/lib/ui/axis/utils/contain.js +15 -15
  286. package/lib/ui/axis/utils/contain.js.map +1 -1
  287. package/lib/ui/axis/utils/index.js +4 -8
  288. package/lib/ui/axis/utils/index.js.map +1 -1
  289. package/lib/ui/axis/utils/intersect.js +22 -34
  290. package/lib/ui/axis/utils/intersect.js.map +1 -1
  291. package/lib/ui/axis/utils/test.js +35 -47
  292. package/lib/ui/axis/utils/test.js.map +1 -1
  293. package/lib/ui/breadcrumb/index.js +70 -77
  294. package/lib/ui/breadcrumb/index.js.map +1 -1
  295. package/lib/ui/button/index.js +86 -101
  296. package/lib/ui/button/index.js.map +1 -1
  297. package/lib/ui/checkbox/constant.js +2 -2
  298. package/lib/ui/checkbox/constant.js.map +1 -1
  299. package/lib/ui/checkbox/index.js +26 -28
  300. package/lib/ui/checkbox/index.js.map +1 -1
  301. package/lib/ui/crosshair/base.js +33 -48
  302. package/lib/ui/crosshair/base.js.map +1 -1
  303. package/lib/ui/crosshair/circle.js +29 -37
  304. package/lib/ui/crosshair/circle.js.map +1 -1
  305. package/lib/ui/crosshair/constant.js +1 -1
  306. package/lib/ui/crosshair/constant.js.map +1 -1
  307. package/lib/ui/crosshair/index.js +1 -1
  308. package/lib/ui/crosshair/line.js +58 -77
  309. package/lib/ui/crosshair/line.js.map +1 -1
  310. package/lib/ui/crosshair/polygon.js +57 -72
  311. package/lib/ui/crosshair/polygon.js.map +1 -1
  312. package/lib/ui/grid/index.js +76 -97
  313. package/lib/ui/grid/index.js.map +1 -1
  314. package/lib/ui/indicator/constant.js +1 -1
  315. package/lib/ui/indicator/constant.js.map +1 -1
  316. package/lib/ui/indicator/index.js +1 -1
  317. package/lib/ui/indicator/indicator.js +63 -67
  318. package/lib/ui/indicator/indicator.js.map +1 -1
  319. package/lib/ui/layout/layout.js +57 -70
  320. package/lib/ui/layout/layout.js.map +1 -1
  321. package/lib/ui/legend/base.js +14 -15
  322. package/lib/ui/legend/base.js.map +1 -1
  323. package/lib/ui/legend/category/item.js +126 -159
  324. package/lib/ui/legend/category/item.js.map +1 -1
  325. package/lib/ui/legend/category/items.js +166 -208
  326. package/lib/ui/legend/category/items.js.map +1 -1
  327. package/lib/ui/legend/category.js +51 -60
  328. package/lib/ui/legend/category.js.map +1 -1
  329. package/lib/ui/legend/constant.js +2 -2
  330. package/lib/ui/legend/constant.js.map +1 -1
  331. package/lib/ui/legend/continuous/handle.js +31 -35
  332. package/lib/ui/legend/continuous/handle.js.map +1 -1
  333. package/lib/ui/legend/continuous/ribbon.js +40 -43
  334. package/lib/ui/legend/continuous/ribbon.js.map +1 -1
  335. package/lib/ui/legend/continuous/utils.js +10 -11
  336. package/lib/ui/legend/continuous/utils.js.map +1 -1
  337. package/lib/ui/legend/continuous.js +432 -535
  338. package/lib/ui/legend/continuous.js.map +1 -1
  339. package/lib/ui/legend/index.js +2 -2
  340. package/lib/ui/legend/index.js.map +1 -1
  341. package/lib/ui/legend/utils.js +25 -32
  342. package/lib/ui/legend/utils.js.map +1 -1
  343. package/lib/ui/marker/index.js +43 -48
  344. package/lib/ui/marker/index.js.map +1 -1
  345. package/lib/ui/marker/symbol.js +22 -22
  346. package/lib/ui/marker/symbol.js.map +1 -1
  347. package/lib/ui/marker/utils.js +3 -3
  348. package/lib/ui/marker/utils.js.map +1 -1
  349. package/lib/ui/navigator/index.js +135 -165
  350. package/lib/ui/navigator/index.js.map +1 -1
  351. package/lib/ui/poptip/constant.js +65 -66
  352. package/lib/ui/poptip/constant.js.map +1 -1
  353. package/lib/ui/poptip/index.js +100 -115
  354. package/lib/ui/poptip/index.js.map +1 -1
  355. package/lib/ui/poptip/utils.js +8 -15
  356. package/lib/ui/poptip/utils.js.map +1 -1
  357. package/lib/ui/scrollbar/index.js +107 -136
  358. package/lib/ui/scrollbar/index.js.map +1 -1
  359. package/lib/ui/select/option.js +52 -61
  360. package/lib/ui/select/option.js.map +1 -1
  361. package/lib/ui/select/select.js +148 -169
  362. package/lib/ui/select/select.js.map +1 -1
  363. package/lib/ui/slider/constant.js +1 -1
  364. package/lib/ui/slider/constant.js.map +1 -1
  365. package/lib/ui/slider/handle.js +49 -56
  366. package/lib/ui/slider/handle.js.map +1 -1
  367. package/lib/ui/slider/index.js +289 -334
  368. package/lib/ui/slider/index.js.map +1 -1
  369. package/lib/ui/sparkline/columns.js +28 -36
  370. package/lib/ui/sparkline/columns.js.map +1 -1
  371. package/lib/ui/sparkline/index.js +153 -187
  372. package/lib/ui/sparkline/index.js.map +1 -1
  373. package/lib/ui/sparkline/lines.js +40 -52
  374. package/lib/ui/sparkline/lines.js.map +1 -1
  375. package/lib/ui/sparkline/path.js +38 -42
  376. package/lib/ui/sparkline/path.js.map +1 -1
  377. package/lib/ui/sparkline/utils.js +9 -10
  378. package/lib/ui/sparkline/utils.js.map +1 -1
  379. package/lib/ui/switch/index.js +49 -58
  380. package/lib/ui/switch/index.js.map +1 -1
  381. package/lib/ui/tag/index.js +34 -36
  382. package/lib/ui/tag/index.js.map +1 -1
  383. package/lib/ui/timebar/controller.js +73 -82
  384. package/lib/ui/timebar/controller.js.map +1 -1
  385. package/lib/ui/timebar/handle.js +67 -74
  386. package/lib/ui/timebar/handle.js.map +1 -1
  387. package/lib/ui/timebar/icons.js +312 -466
  388. package/lib/ui/timebar/icons.js.map +1 -1
  389. package/lib/ui/timebar/timebar.js +272 -326
  390. package/lib/ui/timebar/timebar.js.map +1 -1
  391. package/lib/ui/timebar/utils.js +8 -8
  392. package/lib/ui/timebar/utils.js.map +1 -1
  393. package/lib/ui/timeline/index.js +2 -5
  394. package/lib/ui/timeline/index.js.map +1 -1
  395. package/lib/ui/title/index.js +61 -65
  396. package/lib/ui/title/index.js.map +1 -1
  397. package/lib/ui/tooltip/constant.js +26 -30
  398. package/lib/ui/tooltip/constant.js.map +1 -1
  399. package/lib/ui/tooltip/index.js +113 -129
  400. package/lib/ui/tooltip/index.js.map +1 -1
  401. package/lib/util/bbox.js +24 -46
  402. package/lib/util/bbox.js.map +1 -1
  403. package/lib/util/callback.js +2 -3
  404. package/lib/util/callback.js.map +1 -1
  405. package/lib/util/classnames.js +8 -10
  406. package/lib/util/classnames.js.map +1 -1
  407. package/lib/util/deep-assign.js +7 -15
  408. package/lib/util/deep-assign.js.map +1 -1
  409. package/lib/util/defined.js +1 -1
  410. package/lib/util/defined.js.map +1 -1
  411. package/lib/util/ellipsis.js +2 -3
  412. package/lib/util/ellipsis.js.map +1 -1
  413. package/lib/util/event.js +3 -3
  414. package/lib/util/event.js.map +1 -1
  415. package/lib/util/extend-display-object.js +2 -2
  416. package/lib/util/extend-display-object.js.map +1 -1
  417. package/lib/util/geometry/index.js +1 -1
  418. package/lib/util/geometry/line-length.js +1 -4
  419. package/lib/util/geometry/line-length.js.map +1 -1
  420. package/lib/util/geometry/lines-intersection.js +5 -10
  421. package/lib/util/geometry/lines-intersection.js.map +1 -1
  422. package/lib/util/group-by.js +1 -1
  423. package/lib/util/group-by.js.map +1 -1
  424. package/lib/util/group.js +3 -3
  425. package/lib/util/group.js.map +1 -1
  426. package/lib/util/html.js +1 -1
  427. package/lib/util/html.js.map +1 -1
  428. package/lib/util/if-show.js +3 -5
  429. package/lib/util/if-show.js.map +1 -1
  430. package/lib/util/in-range.js +1 -3
  431. package/lib/util/in-range.js.map +1 -1
  432. package/lib/util/index.js +1 -1
  433. package/lib/util/interpolate.js +12 -19
  434. package/lib/util/interpolate.js.map +1 -1
  435. package/lib/util/keyframe-interpolate.js +7 -8
  436. package/lib/util/keyframe-interpolate.js.map +1 -1
  437. package/lib/util/layout/executer.js +6 -6
  438. package/lib/util/layout/executer.js.map +1 -1
  439. package/lib/util/layout/flex/index.js +26 -28
  440. package/lib/util/layout/flex/index.js.map +1 -1
  441. package/lib/util/layout/grid/index.js +1 -1
  442. package/lib/util/layout/grid/index.js.map +1 -1
  443. package/lib/util/layout/index.js +1 -1
  444. package/lib/util/layout/utils/helper.js +8 -9
  445. package/lib/util/layout/utils/helper.js.map +1 -1
  446. package/lib/util/matrix.js +7 -8
  447. package/lib/util/matrix.js.map +1 -1
  448. package/lib/util/number.js +6 -7
  449. package/lib/util/number.js.map +1 -1
  450. package/lib/util/offscreen.js +12 -20
  451. package/lib/util/offscreen.js.map +1 -1
  452. package/lib/util/omit.js +3 -3
  453. package/lib/util/omit.js.map +1 -1
  454. package/lib/util/path.js +37 -42
  455. package/lib/util/path.js.map +1 -1
  456. package/lib/util/primitive.js +2 -2
  457. package/lib/util/primitive.js.map +1 -1
  458. package/lib/util/replace-children.js +3 -4
  459. package/lib/util/replace-children.js.map +1 -1
  460. package/lib/util/sampling.js +3 -3
  461. package/lib/util/sampling.js.map +1 -1
  462. package/lib/util/scale-to-pixel.js +4 -5
  463. package/lib/util/scale-to-pixel.js.map +1 -1
  464. package/lib/util/selection.js +144 -187
  465. package/lib/util/selection.js.map +1 -1
  466. package/lib/util/series.js +2 -2
  467. package/lib/util/series.js.map +1 -1
  468. package/lib/util/shape.js +16 -28
  469. package/lib/util/shape.js.map +1 -1
  470. package/lib/util/string.js +4 -5
  471. package/lib/util/string.js.map +1 -1
  472. package/lib/util/style.js +24 -30
  473. package/lib/util/style.js.map +1 -1
  474. package/lib/util/svg2marker.js +15 -17
  475. package/lib/util/svg2marker.js.map +1 -1
  476. package/lib/util/text.js +16 -16
  477. package/lib/util/text.js.map +1 -1
  478. package/lib/util/throttle.js +7 -13
  479. package/lib/util/throttle.js.map +1 -1
  480. package/lib/util/time.js +22 -24
  481. package/lib/util/time.js.map +1 -1
  482. package/lib/util/timer.js +5 -9
  483. package/lib/util/timer.js.map +1 -1
  484. package/lib/util/transform.js +5 -6
  485. package/lib/util/transform.js.map +1 -1
  486. package/lib/util/transpose.js +1 -1
  487. package/lib/util/transpose.js.map +1 -1
  488. package/lib/util/traverse.js +1 -1
  489. package/lib/util/traverse.js.map +1 -1
  490. package/lib/util/visibility.js +3 -3
  491. package/lib/util/visibility.js.map +1 -1
  492. package/lib/util/wrap.js +3 -5
  493. package/lib/util/wrap.js.map +1 -1
  494. package/package.json +3 -3
@@ -1,4 +1,3 @@
1
- import { __assign, __extends, __read } from "tslib";
2
1
  import { CustomEvent } from '@antv/g';
3
2
  import { clamp } from '@antv/util';
4
3
  import { transition } from '../../animation';
@@ -8,308 +7,268 @@ import { getEventPos, ifShow, parseSeriesAttr, select, subStyleProps, superStyle
8
7
  import { Sparkline } from '../sparkline';
9
8
  import { CLASS_NAMES, HANDLE_DEFAULT_CFG, HANDLE_ICON_DEFAULT_CFG, HANDLE_LABEL_DEFAULT_CFG } from './constant';
10
9
  import { Handle } from './handle';
11
- var Slider = /** @class */ (function (_super) {
12
- __extends(Slider, _super);
13
- function Slider(options) {
14
- var _this = _super.call(this, options, __assign(__assign(__assign({ x: 0, y: 0, animate: { duration: 100, fill: 'both' }, brushable: true, formatter: function (val) { return val.toString(); }, handleSpacing: 2, orientation: 'horizontal', padding: 0, autoFitLabel: true, scrollable: true, selectionFill: '#5B8FF9', selectionFillOpacity: 0.45, selectionZIndex: 2, showHandle: true, showLabel: true, slidable: true, trackFill: '#416180', trackLength: 200, trackOpacity: 0.05, trackSize: 20, trackZIndex: -1, values: [0, 1], type: 'range', selectionType: 'select', handleIconOffset: 0 }, superStyleProps(HANDLE_DEFAULT_CFG, 'handle')), superStyleProps(HANDLE_ICON_DEFAULT_CFG, 'handleIcon')), superStyleProps(HANDLE_LABEL_DEFAULT_CFG, 'handleLabel'))) || this;
15
- _this.range = [0, 1];
16
- _this.onDragStart = function (target) { return function (e) {
10
+ export class Slider extends Component {
11
+ get values() {
12
+ return this.attributes.values;
13
+ }
14
+ set values(values) {
15
+ this.attributes.values = this.clampValues(values);
16
+ }
17
+ get sparklineStyle() {
18
+ const { orientation } = this.attributes;
19
+ if (orientation !== 'horizontal')
20
+ return null;
21
+ const attr = subStyleProps(this.attributes, 'sparkline');
22
+ return Object.assign(Object.assign({ zIndex: 0 }, this.availableSpace), attr);
23
+ }
24
+ get shape() {
25
+ const { trackLength, trackSize } = this.attributes;
26
+ const [width, height] = this.getOrientVal([
27
+ [trackLength, trackSize],
28
+ [trackSize, trackLength],
29
+ ]);
30
+ return { width, height };
31
+ }
32
+ get availableSpace() {
33
+ const { x, y, padding } = this.attributes;
34
+ const [top, right, bottom, left] = parseSeriesAttr(padding);
35
+ const { width, height } = this.shape;
36
+ return {
37
+ x: left,
38
+ y: top,
39
+ width: width - (left + right),
40
+ height: height - (top + bottom),
41
+ };
42
+ }
43
+ constructor(options) {
44
+ super(options, Object.assign(Object.assign(Object.assign({ x: 0, y: 0, animate: { duration: 100, fill: 'both' }, brushable: true, formatter: (val) => val.toString(), handleSpacing: 2, orientation: 'horizontal', padding: 0, autoFitLabel: true, scrollable: true, selectionFill: '#5B8FF9', selectionFillOpacity: 0.45, selectionZIndex: 2, showHandle: true, showLabel: true, slidable: true, trackFill: '#416180', trackLength: 200, trackOpacity: 0.05, trackSize: 20, trackZIndex: -1, values: [0, 1], type: 'range', selectionType: 'select', handleIconOffset: 0 }, superStyleProps(HANDLE_DEFAULT_CFG, 'handle')), superStyleProps(HANDLE_ICON_DEFAULT_CFG, 'handleIcon')), superStyleProps(HANDLE_LABEL_DEFAULT_CFG, 'handleLabel')));
45
+ this.range = [0, 1];
46
+ this.onDragStart = (target) => (e) => {
17
47
  e.stopPropagation();
18
- _this.target = target;
19
- _this.prevPos = _this.getOrientVal(getEventPos(e));
20
- var _a = _this.availableSpace, x = _a.x, y = _a.y;
21
- var _b = _this.getBBox(), X = _b.x, Y = _b.y;
22
- _this.selectionStartPos = _this.getRatio(_this.prevPos - _this.getOrientVal([x, y]) - _this.getOrientVal([+X, +Y]));
23
- _this.selectionWidth = 0;
24
- document.addEventListener('pointermove', _this.onDragging);
25
- document.addEventListener('pointerup', _this.onDragEnd);
26
- }; };
27
- _this.onDragging = function (e) {
28
- var _a = _this.attributes, slidable = _a.slidable, brushable = _a.brushable, type = _a.type;
48
+ this.target = target;
49
+ this.prevPos = this.getOrientVal(getEventPos(e));
50
+ const { x, y } = this.availableSpace;
51
+ const { x: X, y: Y } = this.getBBox();
52
+ this.selectionStartPos = this.getRatio(this.prevPos - this.getOrientVal([x, y]) - this.getOrientVal([+X, +Y]));
53
+ this.selectionWidth = 0;
54
+ document.addEventListener('pointermove', this.onDragging);
55
+ document.addEventListener('pointerup', this.onDragEnd);
56
+ };
57
+ this.onDragging = (e) => {
58
+ const { slidable, brushable, type } = this.attributes;
29
59
  e.stopPropagation();
30
- var currPos = _this.getOrientVal(getEventPos(e));
31
- var diffPos = currPos - _this.prevPos;
60
+ const currPos = this.getOrientVal(getEventPos(e));
61
+ const diffPos = currPos - this.prevPos;
32
62
  if (!diffPos)
33
63
  return;
34
- var deltaVal = _this.getRatio(diffPos);
35
- switch (_this.target) {
64
+ const deltaVal = this.getRatio(diffPos);
65
+ switch (this.target) {
36
66
  case 'start':
37
67
  if (slidable)
38
- _this.setValuesOffset(deltaVal);
68
+ this.setValuesOffset(deltaVal);
39
69
  break;
40
70
  case 'end':
41
71
  if (slidable)
42
- _this.setValuesOffset(0, deltaVal);
72
+ this.setValuesOffset(0, deltaVal);
43
73
  break;
44
74
  case 'selection':
45
75
  if (slidable)
46
- _this.setValuesOffset(deltaVal, deltaVal);
76
+ this.setValuesOffset(deltaVal, deltaVal);
47
77
  break;
48
78
  case 'track':
49
79
  if (!brushable)
50
80
  return;
51
81
  // 绘制蒙板
52
- _this.selectionWidth += deltaVal;
82
+ this.selectionWidth += deltaVal;
53
83
  if (type === 'range') {
54
- _this.innerSetValues([_this.selectionStartPos, _this.selectionStartPos + _this.selectionWidth].sort(), true);
84
+ this.innerSetValues([this.selectionStartPos, this.selectionStartPos + this.selectionWidth].sort(), true);
55
85
  }
56
86
  else
57
- _this.innerSetValues([0, _this.selectionStartPos + _this.selectionWidth], true);
87
+ this.innerSetValues([0, this.selectionStartPos + this.selectionWidth], true);
58
88
  break;
59
89
  default:
60
90
  break;
61
91
  }
62
- _this.prevPos = currPos;
92
+ this.prevPos = currPos;
63
93
  };
64
- _this.onDragEnd = function () {
65
- document.removeEventListener('pointermove', _this.onDragging);
66
- document.removeEventListener('pointermove', _this.onDragging);
67
- document.removeEventListener('pointerup', _this.onDragEnd);
68
- _this.target = '';
94
+ this.onDragEnd = () => {
95
+ document.removeEventListener('pointermove', this.onDragging);
96
+ document.removeEventListener('pointermove', this.onDragging);
97
+ document.removeEventListener('pointerup', this.onDragEnd);
98
+ this.target = '';
69
99
  // 更新 handle 状态
70
- _this.updateHandlesPosition(false);
100
+ this.updateHandlesPosition(false);
71
101
  };
72
- _this.onValueChange = function (oldValue) {
73
- var _a = _this.attributes, onChange = _a.onChange, type = _a.type;
74
- var internalOldValue = type === 'range' ? oldValue : oldValue[1];
75
- var value = type === 'range' ? _this.getValues() : _this.getValues()[1];
76
- var evt = new CustomEvent('valuechange', {
77
- detail: { oldValue: internalOldValue, value: value },
102
+ this.onValueChange = (oldValue) => {
103
+ const { onChange, type } = this.attributes;
104
+ const internalOldValue = type === 'range' ? oldValue : oldValue[1];
105
+ const value = type === 'range' ? this.getValues() : this.getValues()[1];
106
+ const evt = new CustomEvent('valuechange', {
107
+ detail: { oldValue: internalOldValue, value },
78
108
  });
79
- _this.dispatchEvent(evt);
109
+ this.dispatchEvent(evt);
80
110
  onChange === null || onChange === void 0 ? void 0 : onChange(value);
81
111
  };
82
- _this.selectionStartPos = 0;
83
- _this.selectionWidth = 0;
84
- _this.prevPos = 0;
85
- _this.target = '';
86
- return _this;
87
- }
88
- Object.defineProperty(Slider.prototype, "values", {
89
- get: function () {
90
- return this.attributes.values;
91
- },
92
- set: function (values) {
93
- this.attributes.values = this.clampValues(values);
94
- },
95
- enumerable: false,
96
- configurable: true
97
- });
98
- Object.defineProperty(Slider.prototype, "sparklineStyle", {
99
- get: function () {
100
- var orientation = this.attributes.orientation;
101
- if (orientation !== 'horizontal')
102
- return null;
103
- var attr = subStyleProps(this.attributes, 'sparkline');
104
- return __assign(__assign({ zIndex: 0 }, this.availableSpace), attr);
105
- },
106
- enumerable: false,
107
- configurable: true
108
- });
109
- Object.defineProperty(Slider.prototype, "shape", {
110
- get: function () {
111
- var _a = this.attributes, trackLength = _a.trackLength, trackSize = _a.trackSize;
112
- var _b = __read(this.getOrientVal([
113
- [trackLength, trackSize],
114
- [trackSize, trackLength],
115
- ]), 2), width = _b[0], height = _b[1];
116
- return { width: width, height: height };
117
- },
118
- enumerable: false,
119
- configurable: true
120
- });
121
- Object.defineProperty(Slider.prototype, "availableSpace", {
122
- get: function () {
123
- var _a = this.attributes, x = _a.x, y = _a.y, padding = _a.padding;
124
- var _b = __read(parseSeriesAttr(padding), 4), top = _b[0], right = _b[1], bottom = _b[2], left = _b[3];
125
- var _c = this.shape, width = _c.width, height = _c.height;
126
- return {
127
- x: left,
128
- y: top,
129
- width: width - (left + right),
130
- height: height - (top + bottom),
131
- };
132
- },
133
- enumerable: false,
134
- configurable: true
135
- });
136
- Slider.prototype.getValues = function () {
112
+ this.selectionStartPos = 0;
113
+ this.selectionWidth = 0;
114
+ this.prevPos = 0;
115
+ this.target = '';
116
+ }
117
+ getValues() {
137
118
  return this.values;
138
- };
119
+ }
139
120
  /** 不触发重绘 */
140
- Slider.prototype.setValues = function (values, animate) {
141
- if (values === void 0) { values = [0, 0]; }
142
- if (animate === void 0) { animate = false; }
121
+ setValues(values = [0, 0], animate = false) {
143
122
  this.attributes.values = values;
144
- var animation = animate === false ? false : this.attributes.animate;
123
+ const animation = animate === false ? false : this.attributes.animate;
145
124
  this.updateSelectionArea(animation);
146
125
  this.updateHandlesPosition(animation);
147
- };
148
- Slider.prototype.updateSelectionArea = function (animation) {
149
- var newSelectionArea = this.calcSelectionArea();
126
+ }
127
+ updateSelectionArea(animation) {
128
+ const newSelectionArea = this.calcSelectionArea();
150
129
  this.foregroundGroup.selectAll(CLASS_NAMES.selection.class).each(function (datum, index) {
151
130
  transition(this, newSelectionArea[index], animation);
152
131
  });
153
- };
154
- Slider.prototype.updateHandlesPosition = function (animation) {
132
+ }
133
+ updateHandlesPosition(animation) {
155
134
  if (!this.attributes.showHandle)
156
135
  return;
157
136
  this.startHandle && transition(this.startHandle, this.getHandleStyle('start'), animation);
158
137
  this.endHandle && transition(this.endHandle, this.getHandleStyle('end'), animation);
159
- };
160
- Slider.prototype.innerSetValues = function (values, trigger) {
161
- if (values === void 0) { values = [0, 0]; }
162
- if (trigger === void 0) { trigger = false; }
163
- var oldValues = this.values;
164
- var newValues = this.clampValues(values);
138
+ }
139
+ innerSetValues(values = [0, 0], trigger = false) {
140
+ const oldValues = this.values;
141
+ const newValues = this.clampValues(values);
165
142
  this.attributes.values = newValues;
166
143
  this.setValues(newValues);
167
144
  if (trigger) {
168
145
  this.onValueChange(oldValues);
169
146
  }
170
- };
171
- Slider.prototype.renderTrack = function (container) {
172
- var _a = this.attributes, x = _a.x, y = _a.y;
173
- var style = subStyleProps(this.attributes, 'track');
147
+ }
148
+ renderTrack(container) {
149
+ const { x, y } = this.attributes;
150
+ const style = subStyleProps(this.attributes, 'track');
174
151
  this.trackShape = select(container)
175
152
  .maybeAppendByClassName(CLASS_NAMES.track, 'rect')
176
- .styles(__assign(__assign({ x: x, y: y }, this.shape), style));
177
- };
178
- Slider.prototype.renderBrushArea = function (container) {
179
- var _a = this.attributes, x = _a.x, y = _a.y, brushable = _a.brushable;
153
+ .styles(Object.assign(Object.assign({ x, y }, this.shape), style));
154
+ }
155
+ renderBrushArea(container) {
156
+ const { x, y, brushable } = this.attributes;
180
157
  this.brushArea = select(container)
181
158
  .maybeAppendByClassName(CLASS_NAMES.brushArea, 'rect')
182
- .styles(__assign({ x: x, y: y, fill: 'transparent', cursor: brushable ? 'crosshair' : 'default' }, this.shape));
183
- };
184
- Slider.prototype.renderSparkline = function (container) {
185
- var _this = this;
186
- var _a = this.attributes, x = _a.x, y = _a.y, orientation = _a.orientation;
187
- var sparklineGroup = select(container).maybeAppendByClassName(CLASS_NAMES.sparklineGroup, 'g');
188
- ifShow(orientation === 'horizontal', sparklineGroup, function (group) {
189
- var style = __assign(__assign({}, _this.sparklineStyle), { x: x, y: y });
190
- group.maybeAppendByClassName(CLASS_NAMES.sparkline, function () { return new Sparkline({ style: style }); }).update(style);
159
+ .styles(Object.assign({ x,
160
+ y, fill: 'transparent', cursor: brushable ? 'crosshair' : 'default' }, this.shape));
161
+ }
162
+ renderSparkline(container) {
163
+ const { x, y, orientation } = this.attributes;
164
+ const sparklineGroup = select(container).maybeAppendByClassName(CLASS_NAMES.sparklineGroup, 'g');
165
+ ifShow(orientation === 'horizontal', sparklineGroup, (group) => {
166
+ const style = Object.assign(Object.assign({}, this.sparklineStyle), { x, y });
167
+ group.maybeAppendByClassName(CLASS_NAMES.sparkline, () => new Sparkline({ style })).update(style);
191
168
  });
192
- };
193
- Slider.prototype.renderHandles = function () {
194
- var _this = this;
169
+ }
170
+ renderHandles() {
195
171
  var _a;
196
- var _b = this.attributes, showHandle = _b.showHandle, type = _b.type;
197
- var availableHandle = type === 'range' ? ['start', 'end'] : ['end'];
198
- var data = showHandle ? availableHandle : [];
199
- var that = this;
200
- (_a = this.foregroundGroup) === null || _a === void 0 ? void 0 : _a.selectAll(CLASS_NAMES.handle.class).data(data.map(function (type) { return ({ type: type }); }), function (d) { return d.type; }).join(function (enter) {
201
- return enter
202
- .append(function (_a) {
203
- var type = _a.type;
204
- return new Handle({ style: _this.getHandleStyle(type) });
205
- })
206
- .each(function (_a) {
207
- var type = _a.type;
208
- this.attr('class', "".concat(CLASS_NAMES.handle.name, " ").concat(type, "-handle"));
209
- var name = "".concat(type, "Handle");
210
- that[name] = this;
211
- this.addEventListener('pointerdown', that.onDragStart(type));
212
- });
213
- }, function (update) {
214
- return update.each(function (_a) {
215
- var type = _a.type;
216
- this.update(that.getHandleStyle(type));
217
- });
218
- }, function (exit) {
219
- return exit
220
- .each(function (_a) {
221
- var type = _a.type;
222
- var name = "".concat(type, "Handle");
223
- that[name] = undefined;
224
- })
225
- .remove();
226
- });
227
- };
228
- Slider.prototype.renderSelection = function (container) {
229
- var _a = this.attributes, x = _a.x, y = _a.y, type = _a.type, selectionType = _a.selectionType;
172
+ const { showHandle, type } = this.attributes;
173
+ const availableHandle = type === 'range' ? ['start', 'end'] : ['end'];
174
+ const data = showHandle ? availableHandle : [];
175
+ const that = this;
176
+ (_a = this.foregroundGroup) === null || _a === void 0 ? void 0 : _a.selectAll(CLASS_NAMES.handle.class).data(data.map((type) => ({ type })), (d) => d.type).join((enter) => enter
177
+ .append(({ type }) => new Handle({ style: this.getHandleStyle(type) }))
178
+ .each(function ({ type }) {
179
+ this.attr('class', `${CLASS_NAMES.handle.name} ${type}-handle`);
180
+ const name = `${type}Handle`;
181
+ that[name] = this;
182
+ this.addEventListener('pointerdown', that.onDragStart(type));
183
+ }), (update) => update.each(function ({ type }) {
184
+ this.update(that.getHandleStyle(type));
185
+ }), (exit) => exit
186
+ .each(({ type }) => {
187
+ const name = `${type}Handle`;
188
+ that[name] = undefined;
189
+ })
190
+ .remove());
191
+ }
192
+ renderSelection(container) {
193
+ const { x, y, type, selectionType } = this.attributes;
230
194
  this.foregroundGroup = select(container).maybeAppendByClassName(CLASS_NAMES.foreground, 'g');
231
195
  // value 类型的 slider 不渲染选区
232
- var selectionStyle = subStyleProps(this.attributes, 'selection');
233
- var applyStyle = function (selection) {
196
+ const selectionStyle = subStyleProps(this.attributes, 'selection');
197
+ const applyStyle = (selection) => {
234
198
  return selection
235
- .style('visibility', function (d) { return (d.show ? 'visible' : 'hidden'); })
236
- .style('cursor', function (d) {
199
+ .style('visibility', (d) => (d.show ? 'visible' : 'hidden'))
200
+ .style('cursor', (d) => {
237
201
  if (selectionType === 'select')
238
202
  return 'grab';
239
203
  if (selectionType === 'invert')
240
204
  return 'crosshair';
241
205
  return 'default';
242
206
  })
243
- .styles(__assign(__assign({}, selectionStyle), { transform: "translate(".concat(x, ", ").concat(y, ")") }));
207
+ .styles(Object.assign(Object.assign({}, selectionStyle), { transform: `translate(${x}, ${y})` }));
244
208
  };
245
- var that = this;
209
+ const that = this;
246
210
  this.foregroundGroup
247
211
  .selectAll(CLASS_NAMES.selection.class)
248
212
  .data(type === 'value'
249
213
  ? []
250
- : this.calcSelectionArea().map(function (area, index) { return ({
251
- style: __assign({}, area),
252
- index: index,
214
+ : this.calcSelectionArea().map((area, index) => ({
215
+ style: Object.assign({}, area),
216
+ index,
253
217
  // 是否可见
254
218
  show: selectionType === 'select' ? index === 1 : index !== 1,
255
- }); }), function (d) { return d.index; })
256
- .join(function (enter) {
257
- return enter
258
- .append('rect')
259
- .attr('className', CLASS_NAMES.selection.name)
260
- .call(applyStyle)
261
- .each(function (datum, index) {
262
- var _this = this;
263
- if (index === 1) {
264
- that.selectionShape = select(this);
265
- // 选区drag事件
266
- this.on('pointerdown', function (e) {
267
- _this.attr('cursor', 'grabbing');
268
- that.onDragStart('selection')(e);
269
- });
270
- // 选区hover事件
271
- that.dispatchCustomEvent(this, 'pointerenter', 'selectionMouseenter');
272
- that.dispatchCustomEvent(this, 'pointerleave', 'selectionMouseleave');
273
- that.dispatchCustomEvent(this, 'click', 'selectionClick');
274
- // 拖拽交互
275
- this.addEventListener('pointerdown', function () {
276
- _this.attr('cursor', 'grabbing');
277
- });
278
- this.addEventListener('pointerup', function () {
279
- _this.attr('cursor', 'pointer');
280
- });
281
- this.addEventListener('pointerover', function () {
282
- _this.attr('cursor', 'pointer');
283
- });
284
- }
285
- else {
286
- this.on('pointerdown', that.onDragStart('track'));
287
- }
288
- });
289
- }, function (update) { return update.call(applyStyle); }, function (exit) { return exit.remove(); });
219
+ })), (d) => d.index)
220
+ .join((enter) => enter
221
+ .append('rect')
222
+ .attr('className', CLASS_NAMES.selection.name)
223
+ .call(applyStyle)
224
+ .each(function (datum, index) {
225
+ if (index === 1) {
226
+ that.selectionShape = select(this);
227
+ // 选区drag事件
228
+ this.on('pointerdown', (e) => {
229
+ this.attr('cursor', 'grabbing');
230
+ that.onDragStart('selection')(e);
231
+ });
232
+ // 选区hover事件
233
+ that.dispatchCustomEvent(this, 'pointerenter', 'selectionMouseenter');
234
+ that.dispatchCustomEvent(this, 'pointerleave', 'selectionMouseleave');
235
+ that.dispatchCustomEvent(this, 'click', 'selectionClick');
236
+ // 拖拽交互
237
+ this.addEventListener('pointerdown', () => {
238
+ this.attr('cursor', 'grabbing');
239
+ });
240
+ this.addEventListener('pointerup', () => {
241
+ this.attr('cursor', 'pointer');
242
+ });
243
+ this.addEventListener('pointerover', () => {
244
+ this.attr('cursor', 'pointer');
245
+ });
246
+ }
247
+ else {
248
+ this.on('pointerdown', that.onDragStart('track'));
249
+ }
250
+ }), (update) => update.call(applyStyle), (exit) => exit.remove());
290
251
  this.updateSelectionArea(false);
291
252
  this.renderHandles();
292
- };
293
- Slider.prototype.render = function (attributes, container) {
253
+ }
254
+ render(attributes, container) {
294
255
  this.renderTrack(container);
295
256
  this.renderSparkline(container);
296
257
  this.renderBrushArea(container);
297
258
  this.renderSelection(container);
298
- };
299
- Slider.prototype.clampValues = function (values, precision) {
300
- var _a;
301
- if (precision === void 0) { precision = 4; }
302
- var _b = __read(this.range, 2), min = _b[0], max = _b[1];
303
- var _c = __read(this.getValues().map(function (num) { return toPrecision(num, precision); }), 2), prevStart = _c[0], prevEnd = _c[1];
304
- var internalValues = Array.isArray(values) ? values : [prevStart, values !== null && values !== void 0 ? values : prevEnd];
305
- var _d = __read((internalValues || [prevStart, prevEnd]).map(function (num) { return toPrecision(num, precision); }), 2), startVal = _d[0], endVal = _d[1];
259
+ }
260
+ clampValues(values, precision = 4) {
261
+ const [min, max] = this.range;
262
+ const [prevStart, prevEnd] = this.getValues().map((num) => toPrecision(num, precision));
263
+ const internalValues = Array.isArray(values) ? values : [prevStart, values !== null && values !== void 0 ? values : prevEnd];
264
+ let [startVal, endVal] = (internalValues || [prevStart, prevEnd]).map((num) => toPrecision(num, precision));
306
265
  if (this.attributes.type === 'value')
307
266
  return [0, clamp(endVal, min, max)];
308
267
  // 交换startVal endVal
309
268
  if (startVal > endVal) {
310
- _a = __read([endVal, startVal], 2), startVal = _a[0], endVal = _a[1];
269
+ [startVal, endVal] = [endVal, startVal];
311
270
  }
312
- var range = endVal - startVal;
271
+ const range = endVal - startVal;
313
272
  // 超出范围就全选
314
273
  if (range > max - min)
315
274
  return [min, max];
@@ -325,44 +284,44 @@ var Slider = /** @class */ (function (_super) {
325
284
  }
326
285
  // 保留小数
327
286
  return [startVal, endVal];
328
- };
287
+ }
329
288
  /**
330
289
  * 计算选区坐标和宽高
331
290
  * 默认用来计算前景位置大小
332
291
  */
333
- Slider.prototype.calcSelectionArea = function (values) {
334
- var _a = __read(this.clampValues(values), 2), start = _a[0], end = _a[1];
335
- var _b = this.availableSpace, x = _b.x, y = _b.y, width = _b.width, height = _b.height;
292
+ calcSelectionArea(values) {
293
+ const [start, end] = this.clampValues(values);
294
+ const { x, y, width, height } = this.availableSpace;
336
295
  // 中间为选区,两端为反选区
337
296
  return this.getOrientVal([
338
297
  [
339
- { y: y, height: height, x: x, width: start * width },
340
- { y: y, height: height, x: start * width + x, width: (end - start) * width },
341
- { y: y, height: height, x: end * width, width: (1 - end) * width },
298
+ { y, height, x, width: start * width },
299
+ { y, height, x: start * width + x, width: (end - start) * width },
300
+ { y, height, x: end * width, width: (1 - end) * width },
342
301
  ],
343
302
  [
344
- { x: x, width: width, y: y, height: start * height },
345
- { x: x, width: width, y: start * height + y, height: (end - start) * height },
346
- { x: x, width: width, y: end * height, height: (1 - end) * height },
303
+ { x, width, y, height: start * height },
304
+ { x, width, y: start * height + y, height: (end - start) * height },
305
+ { x, width, y: end * height, height: (1 - end) * height },
347
306
  ],
348
307
  ]);
349
- };
308
+ }
350
309
  /**
351
310
  * 计算手柄的x y
352
311
  */
353
- Slider.prototype.calcHandlePosition = function (handleType) {
354
- var handleIconOffset = this.attributes.handleIconOffset;
355
- var _a = this.availableSpace, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
356
- var _b = __read(this.clampValues(), 2), stVal = _b[0], endVal = _b[1];
357
- var offset = handleType === 'start' ? -handleIconOffset : handleIconOffset;
358
- var L = (handleType === 'start' ? stVal : endVal) * this.getOrientVal([width, height]) + offset;
312
+ calcHandlePosition(handleType) {
313
+ const { handleIconOffset } = this.attributes;
314
+ const { x, y, width, height } = this.availableSpace;
315
+ const [stVal, endVal] = this.clampValues();
316
+ const offset = handleType === 'start' ? -handleIconOffset : handleIconOffset;
317
+ const L = (handleType === 'start' ? stVal : endVal) * this.getOrientVal([width, height]) + offset;
359
318
  return {
360
319
  x: x + this.getOrientVal([L, width / 2]),
361
320
  y: y + this.getOrientVal([height / 2, L]),
362
321
  };
363
- };
364
- Slider.prototype.inferTextStyle = function (handleType) {
365
- var orientation = this.attributes.orientation;
322
+ }
323
+ inferTextStyle(handleType) {
324
+ const { orientation } = this.attributes;
366
325
  if (orientation === 'horizontal')
367
326
  return {};
368
327
  if (handleType === 'start')
@@ -370,54 +329,53 @@ var Slider = /** @class */ (function (_super) {
370
329
  if (handleType === 'end')
371
330
  return { transformOrigin: 'right center', transform: [['rotate', 90]], textAlign: 'end' };
372
331
  return {};
373
- };
332
+ }
374
333
  /**
375
334
  * 计算手柄应当处于的位置
376
335
  * @param handleType start手柄还是end手柄
377
336
  * @returns
378
337
  */
379
- Slider.prototype.calcHandleText = function (handleType) {
380
- var _a;
381
- var _b = this.attributes, type = _b.type, orientation = _b.orientation, formatter = _b.formatter, autoFitLabel = _b.autoFitLabel;
382
- var handleStyle = subStyleProps(this.attributes, 'handle');
383
- var labelStyle = subStyleProps(handleStyle, 'label');
384
- var spacing = handleStyle.spacing;
385
- var size = this.getHandleSize();
386
- var values = this.clampValues();
387
- var value = handleType === 'start' ? values[0] : values[1];
388
- var text = formatter(value);
389
- var temp = new Text({
390
- style: __assign(__assign(__assign({}, labelStyle), this.inferTextStyle(handleType)), { text: text }),
338
+ calcHandleText(handleType) {
339
+ const { type, orientation, formatter, autoFitLabel } = this.attributes;
340
+ const handleStyle = subStyleProps(this.attributes, 'handle');
341
+ const labelStyle = subStyleProps(handleStyle, 'label');
342
+ const { spacing } = handleStyle;
343
+ const size = this.getHandleSize();
344
+ const values = this.clampValues();
345
+ const value = handleType === 'start' ? values[0] : values[1];
346
+ const text = formatter(value);
347
+ const temp = new Text({
348
+ style: Object.assign(Object.assign(Object.assign({}, labelStyle), this.inferTextStyle(handleType)), { text }),
391
349
  });
392
350
  // 文字包围盒的宽高
393
- var _c = temp.getBBox(), textWidth = _c.width, textHeight = _c.height;
351
+ const { width: textWidth, height: textHeight } = temp.getBBox();
394
352
  temp.destroy();
395
353
  if (!autoFitLabel) {
396
354
  if (type === 'value')
397
- return { text: text, x: 0, y: -textHeight - spacing };
398
- var finaleWidth = spacing + size + (orientation === 'horizontal' ? textWidth / 2 : 0);
399
- return _a = { text: text }, _a[orientation === 'horizontal' ? 'x' : 'y'] = handleType === 'start' ? -finaleWidth : finaleWidth, _a;
355
+ return { text, x: 0, y: -textHeight - spacing };
356
+ const finaleWidth = spacing + size + (orientation === 'horizontal' ? textWidth / 2 : 0);
357
+ return { text, [orientation === 'horizontal' ? 'x' : 'y']: handleType === 'start' ? -finaleWidth : finaleWidth };
400
358
  }
401
- var x = 0;
402
- var y = 0;
359
+ let x = 0;
360
+ let y = 0;
403
361
  // 相对于获取两端可用空间
404
- var _d = this.availableSpace, iW = _d.width, iH = _d.height;
405
- var _e = this.calcSelectionArea()[1], fX = _e.x, fY = _e.y, fW = _e.width, fH = _e.height;
406
- var totalSpacing = spacing + size;
362
+ const { width: iW, height: iH } = this.availableSpace;
363
+ const { x: fX, y: fY, width: fW, height: fH } = this.calcSelectionArea()[1];
364
+ const totalSpacing = spacing + size;
407
365
  if (orientation === 'horizontal') {
408
- var finalWidth = totalSpacing + textWidth / 2;
366
+ const finalWidth = totalSpacing + textWidth / 2;
409
367
  if (handleType === 'start') {
410
- var left = fX - totalSpacing - textWidth;
368
+ const left = fX - totalSpacing - textWidth;
411
369
  x = left > 0 ? -finalWidth : finalWidth;
412
370
  }
413
371
  else {
414
- var sign = iW - fX - fW - totalSpacing > textWidth;
372
+ const sign = iW - fX - fW - totalSpacing > textWidth;
415
373
  x = sign ? finalWidth : -finalWidth;
416
374
  }
417
375
  }
418
376
  else {
419
- var positiveSize = totalSpacing;
420
- var negativeSize = textHeight + totalSpacing;
377
+ const positiveSize = totalSpacing;
378
+ const negativeSize = textHeight + totalSpacing;
421
379
  if (handleType === 'start') {
422
380
  y = fY - size > textHeight ? -negativeSize : positiveSize;
423
381
  }
@@ -425,88 +383,84 @@ var Slider = /** @class */ (function (_super) {
425
383
  y = iH - (fY + fH) - size > textHeight ? negativeSize : -positiveSize;
426
384
  }
427
385
  }
428
- return { x: x, y: y, text: text };
429
- };
430
- Slider.prototype.getHandleLabelStyle = function (handleType) {
431
- var style = subStyleProps(this.attributes, 'handleLabel');
432
- return __assign(__assign(__assign({}, style), this.calcHandleText(handleType)), this.inferTextStyle(handleType));
433
- };
434
- Slider.prototype.getHandleIconStyle = function () {
435
- var shape = this.attributes.handleIconShape;
436
- var style = subStyleProps(this.attributes, 'handleIcon');
437
- var cursor = this.getOrientVal(['ew-resize', 'ns-resize']);
438
- var size = this.getHandleSize();
439
- return __assign({ cursor: cursor, shape: shape, size: size }, style);
440
- };
441
- Slider.prototype.getHandleStyle = function (handleType) {
442
- var _a = this.attributes, ox = _a.x, oy = _a.y, showLabel = _a.showLabel, showLabelOnInteraction = _a.showLabelOnInteraction, orientation = _a.orientation;
443
- var _b = this.calcHandlePosition(handleType), x = _b.x, y = _b.y;
444
- var textStyle = this.calcHandleText(handleType);
445
- var internalShowLabel = showLabel;
386
+ return { x, y, text };
387
+ }
388
+ getHandleLabelStyle(handleType) {
389
+ const style = subStyleProps(this.attributes, 'handleLabel');
390
+ return Object.assign(Object.assign(Object.assign({}, style), this.calcHandleText(handleType)), this.inferTextStyle(handleType));
391
+ }
392
+ getHandleIconStyle() {
393
+ const { handleIconShape: shape } = this.attributes;
394
+ const style = subStyleProps(this.attributes, 'handleIcon');
395
+ const cursor = this.getOrientVal(['ew-resize', 'ns-resize']);
396
+ const size = this.getHandleSize();
397
+ return Object.assign({ cursor,
398
+ shape,
399
+ size }, style);
400
+ }
401
+ getHandleStyle(handleType) {
402
+ const { x: ox, y: oy, showLabel, showLabelOnInteraction, orientation } = this.attributes;
403
+ const { x, y } = this.calcHandlePosition(handleType);
404
+ const textStyle = this.calcHandleText(handleType);
405
+ let internalShowLabel = showLabel;
446
406
  if (!showLabel && showLabelOnInteraction) {
447
407
  if (this.target)
448
408
  internalShowLabel = true;
449
409
  else
450
410
  internalShowLabel = false;
451
411
  }
452
- return __assign(__assign(__assign({}, superStyleProps(this.getHandleIconStyle(), 'icon')), superStyleProps(__assign(__assign({}, this.getHandleLabelStyle(handleType)), textStyle), 'label')), { transform: "translate(".concat(x + ox, ", ").concat(y + oy, ")"), orientation: orientation, showLabel: internalShowLabel, type: handleType, zIndex: 3 });
453
- };
454
- Slider.prototype.getHandleSize = function () {
455
- var _a = this.attributes, size = _a.handleIconSize, width = _a.width, height = _a.height;
412
+ return Object.assign(Object.assign(Object.assign({}, superStyleProps(this.getHandleIconStyle(), 'icon')), superStyleProps(Object.assign(Object.assign({}, this.getHandleLabelStyle(handleType)), textStyle), 'label')), { transform: `translate(${x + ox}, ${y + oy})`, orientation, showLabel: internalShowLabel, type: handleType, zIndex: 3 });
413
+ }
414
+ getHandleSize() {
415
+ const { handleIconSize: size, width, height } = this.attributes;
456
416
  if (size)
457
417
  return size;
458
418
  // 没设置 size 的话,高度就取 height + 4 高度,手柄宽度是高度的 1/ 2.4
459
419
  return Math.floor((this.getOrientVal([+height, +width]) + 4) / 2.4);
460
- };
461
- Slider.prototype.getOrientVal = function (_a) {
462
- var _b = __read(_a, 2), x = _b[0], y = _b[1];
463
- var orientation = this.attributes.orientation;
420
+ }
421
+ getOrientVal([x, y]) {
422
+ const { orientation } = this.attributes;
464
423
  return orientation === 'horizontal' ? x : y;
465
- };
466
- Slider.prototype.setValuesOffset = function (stOffset, endOffset, animate) {
467
- if (endOffset === void 0) { endOffset = 0; }
468
- if (animate === void 0) { animate = false; }
469
- var type = this.attributes.type;
470
- var _a = __read(this.getValues(), 2), oldStartVal = _a[0], oldEndVal = _a[1];
471
- var internalStartOffset = type === 'range' ? stOffset : 0;
472
- var values = [oldStartVal + internalStartOffset, oldEndVal + endOffset].sort();
424
+ }
425
+ setValuesOffset(stOffset, endOffset = 0, animate = false) {
426
+ const { type } = this.attributes;
427
+ const [oldStartVal, oldEndVal] = this.getValues();
428
+ const internalStartOffset = type === 'range' ? stOffset : 0;
429
+ const values = [oldStartVal + internalStartOffset, oldEndVal + endOffset].sort();
473
430
  if (animate)
474
431
  this.setValues(values);
475
432
  else
476
433
  this.innerSetValues(values, true);
477
- };
478
- Slider.prototype.getRatio = function (val) {
479
- var _a = this.availableSpace, width = _a.width, height = _a.height;
434
+ }
435
+ getRatio(val) {
436
+ const { width, height } = this.availableSpace;
480
437
  return val / this.getOrientVal([width, height]);
481
- };
482
- Slider.prototype.dispatchCustomEvent = function (target, event, name) {
483
- var _this = this;
484
- target.on(event, function (e) {
438
+ }
439
+ dispatchCustomEvent(target, event, name) {
440
+ target.on(event, (e) => {
485
441
  e.stopPropagation();
486
- _this.dispatchEvent(new CustomEvent(name, { detail: e }));
442
+ this.dispatchEvent(new CustomEvent(name, { detail: e }));
487
443
  });
488
- };
489
- Slider.prototype.bindEvents = function () {
444
+ }
445
+ bindEvents() {
490
446
  // scroll 事件
491
447
  this.addEventListener('wheel', this.onScroll);
492
- var brushArea = this.brushArea;
448
+ const brushArea = this.brushArea;
493
449
  this.dispatchCustomEvent(brushArea, 'click', 'trackClick');
494
450
  this.dispatchCustomEvent(brushArea, 'pointerenter', 'trackMouseenter');
495
451
  this.dispatchCustomEvent(brushArea, 'pointerleave', 'trackMouseleave');
496
452
  // Drag and brush
497
453
  brushArea.on('pointerdown', this.onDragStart('track'));
498
- };
499
- Slider.prototype.onScroll = function (event) {
500
- var scrollable = this.attributes.scrollable;
454
+ }
455
+ onScroll(event) {
456
+ const { scrollable } = this.attributes;
501
457
  if (scrollable) {
502
- var deltaX = event.deltaX, deltaY = event.deltaY;
503
- var offset = deltaY || deltaX;
504
- var deltaVal = this.getRatio(offset);
458
+ const { deltaX, deltaY } = event;
459
+ const offset = deltaY || deltaX;
460
+ const deltaVal = this.getRatio(offset);
505
461
  this.setValuesOffset(deltaVal, deltaVal, true);
506
462
  }
507
- };
508
- Slider.tag = 'slider';
509
- return Slider;
510
- }(Component));
511
- export { Slider };
463
+ }
464
+ }
465
+ Slider.tag = 'slider';
512
466
  //# sourceMappingURL=index.js.map