@antv/component 2.1.1-alpha.1 → 2.1.1-alpha.3

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