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