@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,277 +1,318 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Slider = void 0;
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) => {
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) {
50
20
  e.stopPropagation();
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;
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;
62
32
  e.stopPropagation();
63
- const currPos = this.getOrientVal((0, util_2.getEventPos)(e));
64
- const diffPos = currPos - this.prevPos;
33
+ var currPos = _this.getOrientVal((0, util_2.getEventPos)(e));
34
+ var diffPos = currPos - _this.prevPos;
65
35
  if (!diffPos)
66
36
  return;
67
- const deltaVal = this.getRatio(diffPos);
68
- switch (this.target) {
37
+ var deltaVal = _this.getRatio(diffPos);
38
+ switch (_this.target) {
69
39
  case 'start':
70
40
  if (slidable)
71
- this.setValuesOffset(deltaVal);
41
+ _this.setValuesOffset(deltaVal);
72
42
  break;
73
43
  case 'end':
74
44
  if (slidable)
75
- this.setValuesOffset(0, deltaVal);
45
+ _this.setValuesOffset(0, deltaVal);
76
46
  break;
77
47
  case 'selection':
78
48
  if (slidable)
79
- this.setValuesOffset(deltaVal, deltaVal);
49
+ _this.setValuesOffset(deltaVal, deltaVal);
80
50
  break;
81
51
  case 'track':
82
52
  if (!brushable)
83
53
  return;
84
54
  // 绘制蒙板
85
- this.selectionWidth += deltaVal;
55
+ _this.selectionWidth += deltaVal;
86
56
  if (type === 'range') {
87
- this.innerSetValues([this.selectionStartPos, this.selectionStartPos + this.selectionWidth].sort(), true);
57
+ _this.innerSetValues([_this.selectionStartPos, _this.selectionStartPos + _this.selectionWidth].sort(), true);
88
58
  }
89
59
  else
90
- this.innerSetValues([0, this.selectionStartPos + this.selectionWidth], true);
60
+ _this.innerSetValues([0, _this.selectionStartPos + _this.selectionWidth], true);
91
61
  break;
92
62
  default:
93
63
  break;
94
64
  }
95
- this.prevPos = currPos;
65
+ _this.prevPos = currPos;
96
66
  };
97
- this.onDragEnd = () => {
98
- document.removeEventListener('pointermove', this.onDragging);
99
- document.removeEventListener('pointermove', this.onDragging);
100
- document.removeEventListener('pointerup', this.onDragEnd);
101
- this.target = '';
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 = '';
102
72
  // 更新 handle 状态
103
- this.updateHandlesPosition(false);
73
+ _this.updateHandlesPosition(false);
104
74
  };
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 },
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 },
111
81
  });
112
- this.dispatchEvent(evt);
82
+ _this.dispatchEvent(evt);
113
83
  onChange === null || onChange === void 0 ? void 0 : onChange(value);
114
84
  };
115
- this.selectionStartPos = 0;
116
- this.selectionWidth = 0;
117
- this.prevPos = 0;
118
- this.target = '';
119
- }
120
- getValues() {
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 () {
121
140
  return this.values;
122
- }
141
+ };
123
142
  /** 不触发重绘 */
124
- setValues(values = [0, 0], animate = false) {
143
+ Slider.prototype.setValues = function (values, animate) {
144
+ if (values === void 0) { values = [0, 0]; }
145
+ if (animate === void 0) { animate = false; }
125
146
  this.attributes.values = values;
126
- const animation = animate === false ? false : this.attributes.animate;
147
+ var animation = animate === false ? false : this.attributes.animate;
127
148
  this.updateSelectionArea(animation);
128
149
  this.updateHandlesPosition(animation);
129
- }
130
- updateSelectionArea(animation) {
131
- const newSelectionArea = this.calcSelectionArea();
150
+ };
151
+ Slider.prototype.updateSelectionArea = function (animation) {
152
+ var newSelectionArea = this.calcSelectionArea();
132
153
  this.foregroundGroup.selectAll(constant_1.CLASS_NAMES.selection.class).each(function (datum, index) {
133
154
  (0, animation_1.transition)(this, newSelectionArea[index], animation);
134
155
  });
135
- }
136
- updateHandlesPosition(animation) {
156
+ };
157
+ Slider.prototype.updateHandlesPosition = function (animation) {
137
158
  if (!this.attributes.showHandle)
138
159
  return;
139
160
  this.startHandle && (0, animation_1.transition)(this.startHandle, this.getHandleStyle('start'), animation);
140
161
  this.endHandle && (0, animation_1.transition)(this.endHandle, this.getHandleStyle('end'), animation);
141
- }
142
- innerSetValues(values = [0, 0], trigger = false) {
143
- const oldValues = this.values;
144
- const newValues = this.clampValues(values);
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);
145
168
  this.attributes.values = newValues;
146
169
  this.setValues(newValues);
147
170
  if (trigger) {
148
171
  this.onValueChange(oldValues);
149
172
  }
150
- }
151
- renderTrack(container) {
152
- const { x, y } = this.attributes;
153
- const style = (0, util_2.subStyleProps)(this.attributes, 'track');
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');
154
177
  this.trackShape = (0, util_2.select)(container)
155
178
  .maybeAppendByClassName(constant_1.CLASS_NAMES.track, 'rect')
156
- .styles(Object.assign(Object.assign({ x, y }, this.shape), style));
157
- }
158
- renderBrushArea(container) {
159
- const { x, y, brushable } = this.attributes;
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;
160
183
  this.brushArea = (0, util_2.select)(container)
161
184
  .maybeAppendByClassName(constant_1.CLASS_NAMES.brushArea, 'rect')
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);
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);
171
194
  });
172
- }
173
- renderHandles() {
195
+ };
196
+ Slider.prototype.renderHandles = function () {
197
+ var _this = this;
174
198
  var _a;
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;
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;
197
233
  this.foregroundGroup = (0, util_2.select)(container).maybeAppendByClassName(constant_1.CLASS_NAMES.foreground, 'g');
198
234
  // value 类型的 slider 不渲染选区
199
- const selectionStyle = (0, util_2.subStyleProps)(this.attributes, 'selection');
200
- const applyStyle = (selection) => {
235
+ var selectionStyle = (0, util_2.subStyleProps)(this.attributes, 'selection');
236
+ var applyStyle = function (selection) {
201
237
  return selection
202
- .style('visibility', (d) => (d.show ? 'visible' : 'hidden'))
203
- .style('cursor', (d) => {
238
+ .style('visibility', function (d) { return (d.show ? 'visible' : 'hidden'); })
239
+ .style('cursor', function (d) {
204
240
  if (selectionType === 'select')
205
241
  return 'grab';
206
242
  if (selectionType === 'invert')
207
243
  return 'crosshair';
208
244
  return 'default';
209
245
  })
210
- .styles(Object.assign(Object.assign({}, selectionStyle), { transform: `translate(${x}, ${y})` }));
246
+ .styles(tslib_1.__assign(tslib_1.__assign({}, selectionStyle), { transform: "translate(".concat(x, ", ").concat(y, ")") }));
211
247
  };
212
- const that = this;
248
+ var that = this;
213
249
  this.foregroundGroup
214
250
  .selectAll(constant_1.CLASS_NAMES.selection.class)
215
251
  .data(type === 'value'
216
252
  ? []
217
- : this.calcSelectionArea().map((area, index) => ({
218
- style: Object.assign({}, area),
219
- index,
253
+ : this.calcSelectionArea().map(function (area, index) { return ({
254
+ style: tslib_1.__assign({}, area),
255
+ index: index,
220
256
  // 是否可见
221
257
  show: selectionType === 'select' ? index === 1 : index !== 1,
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());
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(); });
254
293
  this.updateSelectionArea(false);
255
294
  this.renderHandles();
256
- }
257
- render(attributes, container) {
295
+ };
296
+ Slider.prototype.render = function (attributes, container) {
258
297
  this.renderTrack(container);
259
298
  this.renderSparkline(container);
260
299
  this.renderBrushArea(container);
261
300
  this.renderSelection(container);
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));
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];
268
309
  if (this.attributes.type === 'value')
269
310
  return [0, (0, util_1.clamp)(endVal, min, max)];
270
311
  // 交换startVal endVal
271
312
  if (startVal > endVal) {
272
- [startVal, endVal] = [endVal, startVal];
313
+ _a = tslib_1.__read([endVal, startVal], 2), startVal = _a[0], endVal = _a[1];
273
314
  }
274
- const range = endVal - startVal;
315
+ var range = endVal - startVal;
275
316
  // 超出范围就全选
276
317
  if (range > max - min)
277
318
  return [min, max];
@@ -287,98 +328,99 @@ class Slider extends core_1.Component {
287
328
  }
288
329
  // 保留小数
289
330
  return [startVal, endVal];
290
- }
331
+ };
291
332
  /**
292
333
  * 计算选区坐标和宽高
293
334
  * 默认用来计算前景位置大小
294
335
  */
295
- calcSelectionArea(values) {
296
- const [start, end] = this.clampValues(values);
297
- const { x, y, width, height } = this.availableSpace;
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;
298
339
  // 中间为选区,两端为反选区
299
340
  return this.getOrientVal([
300
341
  [
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 },
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 },
304
345
  ],
305
346
  [
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 },
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 },
309
350
  ],
310
351
  ]);
311
- }
352
+ };
312
353
  /**
313
354
  * 计算手柄的x y
314
355
  */
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;
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;
321
362
  return {
322
363
  x: x + this.getOrientVal([L, width / 2]),
323
364
  y: y + this.getOrientVal([height / 2, L]),
324
365
  };
325
- }
326
- inferTextStyle(handleType) {
327
- const { orientation } = this.attributes;
366
+ };
367
+ Slider.prototype.inferTextStyle = function (handleType) {
368
+ var orientation = this.attributes.orientation;
328
369
  if (orientation === 'horizontal')
329
370
  return {};
330
371
  if (handleType === 'start')
331
- return { transformOrigin: 'left center', transform: [['rotate', 90]], textAlign: 'start' };
372
+ return { transformOrigin: 'left center', transform: 'rotate(90)', textAlign: 'start' };
332
373
  if (handleType === 'end')
333
- return { transformOrigin: 'right center', transform: [['rotate', 90]], textAlign: 'end' };
374
+ return { transformOrigin: 'right center', transform: 'rotate(90)', textAlign: 'end' };
334
375
  return {};
335
- }
376
+ };
336
377
  /**
337
378
  * 计算手柄应当处于的位置
338
379
  * @param handleType start手柄还是end手柄
339
380
  * @returns
340
381
  */
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 }),
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 }),
352
394
  });
353
395
  // 文字包围盒的宽高
354
- const { width: textWidth, height: textHeight } = temp.getBBox();
396
+ var _c = temp.getBBox(), textWidth = _c.width, textHeight = _c.height;
355
397
  temp.destroy();
356
398
  if (!autoFitLabel) {
357
399
  if (type === 'value')
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 };
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;
361
403
  }
362
- let x = 0;
363
- let y = 0;
404
+ var x = 0;
405
+ var y = 0;
364
406
  // 相对于获取两端可用空间
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;
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;
368
410
  if (orientation === 'horizontal') {
369
- const finalWidth = totalSpacing + textWidth / 2;
411
+ var finalWidth = totalSpacing + textWidth / 2;
370
412
  if (handleType === 'start') {
371
- const left = fX - totalSpacing - textWidth;
413
+ var left = fX - totalSpacing - textWidth;
372
414
  x = left > 0 ? -finalWidth : finalWidth;
373
415
  }
374
416
  else {
375
- const sign = iW - fX - fW - totalSpacing > textWidth;
417
+ var sign = iW - fX - fW - totalSpacing > textWidth;
376
418
  x = sign ? finalWidth : -finalWidth;
377
419
  }
378
420
  }
379
421
  else {
380
- const positiveSize = totalSpacing;
381
- const negativeSize = textHeight + totalSpacing;
422
+ var positiveSize = totalSpacing;
423
+ var negativeSize = textHeight + totalSpacing;
382
424
  if (handleType === 'start') {
383
425
  y = fY - size > textHeight ? -negativeSize : positiveSize;
384
426
  }
@@ -386,85 +428,88 @@ class Slider extends core_1.Component {
386
428
  y = iH - (fY + fH) - size > textHeight ? negativeSize : -positiveSize;
387
429
  }
388
430
  }
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;
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;
409
449
  if (!showLabel && showLabelOnInteraction) {
410
450
  if (this.target)
411
451
  internalShowLabel = true;
412
452
  else
413
453
  internalShowLabel = false;
414
454
  }
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;
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;
419
459
  if (size)
420
460
  return size;
421
461
  // 没设置 size 的话,高度就取 height + 4 高度,手柄宽度是高度的 1/ 2.4
422
462
  return Math.floor((this.getOrientVal([+height, +width]) + 4) / 2.4);
423
- }
424
- getOrientVal([x, y]) {
425
- const { orientation } = this.attributes;
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;
426
467
  return orientation === 'horizontal' ? x : y;
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();
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();
433
476
  if (animate)
434
477
  this.setValues(values);
435
478
  else
436
479
  this.innerSetValues(values, true);
437
- }
438
- getRatio(val) {
439
- const { width, height } = this.availableSpace;
480
+ };
481
+ Slider.prototype.getRatio = function (val) {
482
+ var _a = this.availableSpace, width = _a.width, height = _a.height;
440
483
  return val / this.getOrientVal([width, height]);
441
- }
442
- dispatchCustomEvent(target, event, name) {
443
- target.on(event, (e) => {
484
+ };
485
+ Slider.prototype.dispatchCustomEvent = function (target, event, name) {
486
+ var _this = this;
487
+ target.on(event, function (e) {
444
488
  e.stopPropagation();
445
- this.dispatchEvent(new g_1.CustomEvent(name, { detail: e }));
489
+ _this.dispatchEvent(new g_1.CustomEvent(name, { detail: e }));
446
490
  });
447
- }
448
- bindEvents() {
491
+ };
492
+ Slider.prototype.bindEvents = function () {
449
493
  // scroll 事件
450
494
  this.addEventListener('wheel', this.onScroll);
451
- const brushArea = this.brushArea;
495
+ var brushArea = this.brushArea;
452
496
  this.dispatchCustomEvent(brushArea, 'click', 'trackClick');
453
497
  this.dispatchCustomEvent(brushArea, 'pointerenter', 'trackMouseenter');
454
498
  this.dispatchCustomEvent(brushArea, 'pointerleave', 'trackMouseleave');
455
499
  // Drag and brush
456
500
  brushArea.on('pointerdown', this.onDragStart('track'));
457
- }
458
- onScroll(event) {
459
- const { scrollable } = this.attributes;
501
+ };
502
+ Slider.prototype.onScroll = function (event) {
503
+ var scrollable = this.attributes.scrollable;
460
504
  if (scrollable) {
461
- const { deltaX, deltaY } = event;
462
- const offset = deltaY || deltaX;
463
- const deltaVal = this.getRatio(offset);
505
+ var deltaX = event.deltaX, deltaY = event.deltaY;
506
+ var offset = deltaY || deltaX;
507
+ var deltaVal = this.getRatio(offset);
464
508
  this.setValuesOffset(deltaVal, deltaVal, true);
465
509
  }
466
- }
467
- }
510
+ };
511
+ Slider.tag = 'slider';
512
+ return Slider;
513
+ }(core_1.Component));
468
514
  exports.Slider = Slider;
469
- Slider.tag = 'slider';
470
515
  //# sourceMappingURL=index.js.map