naive-ui 2.20.3 → 2.21.0

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 (332) hide show
  1. package/es/_internal/select-menu/src/SelectMenu.d.ts +3 -0
  2. package/es/_internal/selection/src/Selection.d.ts +3 -0
  3. package/es/_internal/suffix/src/Suffix.d.ts +4 -1
  4. package/es/_internal/suffix/src/Suffix.js +4 -1
  5. package/es/_styles/common/dark.js +1 -1
  6. package/es/_styles/common/light.d.ts +3 -0
  7. package/es/_styles/common/light.js +5 -2
  8. package/es/_styles/global/index.cssr.js +9 -4
  9. package/es/_styles/transitions/icon-switch.cssr.js +6 -2
  10. package/es/_utils/naive/extract-public-props.d.ts +1 -1
  11. package/es/alert/src/Alert.d.ts +3 -0
  12. package/es/auto-complete/src/AutoComplete.d.ts +8 -1
  13. package/es/auto-complete/src/AutoComplete.js +2 -2
  14. package/es/avatar/src/Avatar.d.ts +8 -1
  15. package/es/avatar/src/Avatar.js +41 -9
  16. package/es/avatar/src/styles/index.cssr.js +2 -2
  17. package/es/button/src/Button.d.ts +149 -52
  18. package/es/button/src/Button.js +128 -56
  19. package/es/button/src/interface.d.ts +1 -1
  20. package/es/button/styles/dark.js +3 -0
  21. package/es/button/styles/light.d.ts +14 -5
  22. package/es/button/styles/light.js +10 -3
  23. package/es/calendar/src/Calendar.d.ts +143 -50
  24. package/es/calendar/styles/light.d.ts +14 -5
  25. package/es/card/src/Card.d.ts +3 -0
  26. package/es/cascader/src/Cascader.d.ts +3 -0
  27. package/es/cascader/src/CascaderOption.d.ts +3 -0
  28. package/es/cascader/src/CascaderSelectMenu.d.ts +3 -0
  29. package/es/cascader/src/CascaderSubmenu.d.ts +3 -0
  30. package/es/checkbox/src/Checkbox.d.ts +8 -5
  31. package/es/checkbox/src/Checkbox.js +3 -3
  32. package/es/collapse/src/Collapse.d.ts +3 -0
  33. package/es/color-picker/src/ColorInputUnit.d.ts +17 -5
  34. package/es/color-picker/src/ColorPicker.d.ts +126 -45
  35. package/es/color-picker/styles/light.d.ts +14 -5
  36. package/es/data-table/src/DataTable.d.ts +183 -51
  37. package/es/data-table/src/DataTable.js +11 -6
  38. package/es/data-table/src/HeaderButton/FilterButton.d.ts +20 -5
  39. package/es/data-table/src/HeaderButton/FilterMenu.d.ts +20 -5
  40. package/es/data-table/src/TableParts/Body.d.ts +25 -6
  41. package/es/data-table/src/TableParts/Body.js +60 -22
  42. package/es/data-table/src/TableParts/BodyCheckbox.js +1 -1
  43. package/es/data-table/src/TableParts/Cell.d.ts +40 -10
  44. package/es/data-table/src/TableParts/Header.d.ts +20 -5
  45. package/es/data-table/src/TableParts/Header.js +1 -1
  46. package/es/data-table/src/interface.d.ts +4 -1
  47. package/es/data-table/src/styles/index.cssr.js +8 -9
  48. package/es/data-table/styles/light.d.ts +20 -5
  49. package/es/data-table/styles/light.js +3 -3
  50. package/es/date-picker/src/DatePicker.d.ts +298 -105
  51. package/es/date-picker/src/panel/date.d.ts +45 -15
  52. package/es/date-picker/src/panel/daterange.d.ts +45 -15
  53. package/es/date-picker/src/panel/datetime.d.ts +45 -15
  54. package/es/date-picker/src/panel/datetimerange.d.ts +45 -15
  55. package/es/date-picker/src/panel/month.d.ts +45 -15
  56. package/es/date-picker/src/panel/use-calendar.d.ts +45 -15
  57. package/es/date-picker/src/panel/use-dual-calendar.d.ts +45 -15
  58. package/es/date-picker/src/panel/use-panel-common.d.ts +45 -15
  59. package/es/date-picker/styles/light.d.ts +28 -10
  60. package/es/dialog/src/Dialog.d.ts +101 -35
  61. package/es/dialog/styles/light.d.ts +14 -5
  62. package/es/drawer/src/Drawer.d.ts +3 -0
  63. package/es/drawer/src/DrawerBodyWrapper.d.ts +3 -0
  64. package/es/drawer/src/DrawerContent.d.ts +3 -0
  65. package/es/dropdown/index.d.ts +1 -1
  66. package/es/dropdown/src/Dropdown.d.ts +5 -2
  67. package/es/dropdown/src/DropdownGroup.d.ts +2 -3
  68. package/es/dropdown/src/DropdownMenu.d.ts +3 -4
  69. package/es/dropdown/src/DropdownMenu.js +5 -4
  70. package/es/dropdown/src/DropdownOption.d.ts +3 -4
  71. package/es/dropdown/src/DropdownOption.js +2 -2
  72. package/es/dropdown/src/DropdownRenderOption.d.ts +2 -3
  73. package/es/dropdown/src/interface.d.ts +9 -30
  74. package/es/dropdown/src/utils.d.ts +1 -0
  75. package/es/dropdown/src/utils.js +10 -0
  76. package/es/dynamic-input/src/DynamicInput.d.ts +143 -50
  77. package/es/dynamic-input/src/InputPreset.d.ts +17 -5
  78. package/es/dynamic-input/src/PairPreset.d.ts +17 -5
  79. package/es/dynamic-input/styles/light.d.ts +14 -5
  80. package/es/dynamic-tags/src/DynamicTags.d.ts +144 -50
  81. package/es/dynamic-tags/styles/light.d.ts +14 -5
  82. package/es/ellipsis/src/Ellipsis.d.ts +3 -0
  83. package/es/global-style/src/GlobalStyle.js +2 -0
  84. package/es/input/src/Input.d.ts +4 -0
  85. package/es/input/src/Input.js +6 -0
  86. package/es/input/src/interface.d.ts +1 -0
  87. package/es/input-number/src/InputNumber.d.ts +144 -50
  88. package/es/input-number/styles/light.d.ts +14 -5
  89. package/es/layout/src/Layout.d.ts +6 -0
  90. package/es/layout/src/LayoutContent.d.ts +3 -0
  91. package/es/layout/src/LayoutSider.d.ts +3 -0
  92. package/es/log/src/Log.d.ts +3 -0
  93. package/es/mention/src/Mention.d.ts +4 -0
  94. package/es/menu/index.d.ts +1 -1
  95. package/es/menu/src/Menu.d.ts +19 -6
  96. package/es/menu/src/Menu.js +2 -1
  97. package/es/menu/src/MenuDivider.d.ts +2 -0
  98. package/es/menu/src/MenuDivider.js +11 -0
  99. package/es/menu/src/MenuOption.d.ts +8 -1
  100. package/es/menu/src/MenuOptionContent.d.ts +4 -1
  101. package/es/menu/src/Submenu.d.ts +18 -16
  102. package/es/menu/src/interface.d.ts +23 -4
  103. package/es/menu/src/styles/index.cssr.js +6 -1
  104. package/es/menu/src/utils.d.ts +4 -2
  105. package/es/menu/src/utils.js +16 -2
  106. package/es/menu/styles/light.d.ts +2 -0
  107. package/es/menu/styles/light.js +3 -2
  108. package/es/modal/src/BodyWrapper.d.ts +31 -10
  109. package/es/modal/src/Modal.d.ts +168 -60
  110. package/es/modal/styles/light.d.ts +14 -5
  111. package/es/notification/src/NotificationContainer.d.ts +3 -0
  112. package/es/pagination/src/Pagination.d.ts +4 -0
  113. package/es/popconfirm/src/Popconfirm.d.ts +143 -50
  114. package/es/popconfirm/styles/light.d.ts +14 -5
  115. package/es/popselect/src/Popselect.d.ts +3 -0
  116. package/es/popselect/src/PopselectPanel.d.ts +3 -0
  117. package/es/radio/src/Radio.d.ts +3 -0
  118. package/es/radio/src/RadioButton.d.ts +3 -0
  119. package/es/radio/src/use-radio.d.ts +2 -0
  120. package/es/radio/src/use-radio.js +6 -3
  121. package/es/select/src/Select.d.ts +3 -0
  122. package/es/slider/src/Slider.d.ts +70 -91
  123. package/es/slider/src/Slider.js +326 -583
  124. package/es/slider/src/interface.d.ts +1 -1
  125. package/es/slider/src/styles/index.cssr.js +86 -16
  126. package/es/slider/src/utils.d.ts +10 -1
  127. package/es/slider/src/utils.js +9 -0
  128. package/es/slider/styles/_common.d.ts +1 -0
  129. package/es/slider/styles/_common.js +1 -0
  130. package/es/slider/styles/light.d.ts +1 -0
  131. package/es/space/src/Space.js +2 -0
  132. package/es/steps/src/Step.js +1 -1
  133. package/es/table/src/Table.d.ts +35 -0
  134. package/es/table/src/Table.js +8 -4
  135. package/es/table/src/styles/index.cssr.js +1 -1
  136. package/es/table/styles/light.d.ts +3 -0
  137. package/es/table/styles/light.js +2 -2
  138. package/es/tabs/index.d.ts +2 -0
  139. package/es/tabs/index.js +1 -0
  140. package/es/tabs/src/Tab.d.ts +35 -18
  141. package/es/tabs/src/Tab.js +11 -12
  142. package/es/tabs/src/Tabs.js +58 -18
  143. package/es/tag/src/Tag.d.ts +8 -3
  144. package/es/tag/src/Tag.js +10 -2
  145. package/es/tag/src/styles/index.cssr.js +10 -5
  146. package/es/tag/src/styles/rtl.cssr.js +7 -1
  147. package/es/theme-editor/src/ThemeEditor.d.ts +3 -0
  148. package/es/time-picker/src/Panel.d.ts +17 -5
  149. package/es/time-picker/src/TimePicker.d.ts +144 -50
  150. package/es/time-picker/styles/light.d.ts +14 -5
  151. package/es/tooltip/src/Tooltip.d.ts +3 -0
  152. package/es/transfer/src/Transfer.d.ts +143 -50
  153. package/es/transfer/src/TransferFilter.d.ts +17 -5
  154. package/es/transfer/src/TransferList.d.ts +17 -5
  155. package/es/transfer/src/TransferListItem.d.ts +17 -5
  156. package/es/transfer/styles/light.d.ts +14 -5
  157. package/es/tree/src/Tree.d.ts +3 -0
  158. package/es/tree/src/TreeNodeCheckbox.d.ts +3 -0
  159. package/es/tree-select/src/TreeSelect.d.ts +3 -0
  160. package/es/upload/src/Upload.d.ts +143 -50
  161. package/es/upload/src/UploadFile.d.ts +18 -6
  162. package/es/upload/src/UploadProgress.d.ts +17 -5
  163. package/es/upload/styles/light.d.ts +14 -5
  164. package/es/version.d.ts +1 -1
  165. package/es/version.js +1 -1
  166. package/lib/_internal/select-menu/src/SelectMenu.d.ts +3 -0
  167. package/lib/_internal/selection/src/Selection.d.ts +3 -0
  168. package/lib/_internal/suffix/src/Suffix.d.ts +4 -1
  169. package/lib/_internal/suffix/src/Suffix.js +4 -1
  170. package/lib/_styles/common/dark.js +1 -1
  171. package/lib/_styles/common/light.d.ts +3 -0
  172. package/lib/_styles/common/light.js +5 -2
  173. package/lib/_styles/global/index.cssr.js +10 -5
  174. package/lib/_styles/transitions/icon-switch.cssr.js +7 -2
  175. package/lib/_utils/naive/extract-public-props.d.ts +1 -1
  176. package/lib/alert/src/Alert.d.ts +3 -0
  177. package/lib/auto-complete/src/AutoComplete.d.ts +8 -1
  178. package/lib/auto-complete/src/AutoComplete.js +2 -2
  179. package/lib/avatar/src/Avatar.d.ts +8 -1
  180. package/lib/avatar/src/Avatar.js +40 -8
  181. package/lib/avatar/src/styles/index.cssr.js +2 -2
  182. package/lib/button/src/Button.d.ts +149 -52
  183. package/lib/button/src/Button.js +126 -54
  184. package/lib/button/src/interface.d.ts +1 -1
  185. package/lib/button/styles/dark.js +3 -0
  186. package/lib/button/styles/light.d.ts +14 -5
  187. package/lib/button/styles/light.js +10 -3
  188. package/lib/calendar/src/Calendar.d.ts +143 -50
  189. package/lib/calendar/styles/light.d.ts +14 -5
  190. package/lib/card/src/Card.d.ts +3 -0
  191. package/lib/cascader/src/Cascader.d.ts +3 -0
  192. package/lib/cascader/src/CascaderOption.d.ts +3 -0
  193. package/lib/cascader/src/CascaderSelectMenu.d.ts +3 -0
  194. package/lib/cascader/src/CascaderSubmenu.d.ts +3 -0
  195. package/lib/checkbox/src/Checkbox.d.ts +8 -5
  196. package/lib/checkbox/src/Checkbox.js +3 -3
  197. package/lib/collapse/src/Collapse.d.ts +3 -0
  198. package/lib/color-picker/src/ColorInputUnit.d.ts +17 -5
  199. package/lib/color-picker/src/ColorPicker.d.ts +126 -45
  200. package/lib/color-picker/styles/light.d.ts +14 -5
  201. package/lib/data-table/src/DataTable.d.ts +183 -51
  202. package/lib/data-table/src/DataTable.js +11 -6
  203. package/lib/data-table/src/HeaderButton/FilterButton.d.ts +20 -5
  204. package/lib/data-table/src/HeaderButton/FilterMenu.d.ts +20 -5
  205. package/lib/data-table/src/TableParts/Body.d.ts +25 -6
  206. package/lib/data-table/src/TableParts/Body.js +60 -22
  207. package/lib/data-table/src/TableParts/BodyCheckbox.js +1 -1
  208. package/lib/data-table/src/TableParts/Cell.d.ts +40 -10
  209. package/lib/data-table/src/TableParts/Header.d.ts +20 -5
  210. package/lib/data-table/src/TableParts/Header.js +1 -1
  211. package/lib/data-table/src/interface.d.ts +4 -1
  212. package/lib/data-table/src/styles/index.cssr.js +8 -9
  213. package/lib/data-table/styles/light.d.ts +20 -5
  214. package/lib/data-table/styles/light.js +3 -3
  215. package/lib/date-picker/src/DatePicker.d.ts +298 -105
  216. package/lib/date-picker/src/panel/date.d.ts +45 -15
  217. package/lib/date-picker/src/panel/daterange.d.ts +45 -15
  218. package/lib/date-picker/src/panel/datetime.d.ts +45 -15
  219. package/lib/date-picker/src/panel/datetimerange.d.ts +45 -15
  220. package/lib/date-picker/src/panel/month.d.ts +45 -15
  221. package/lib/date-picker/src/panel/use-calendar.d.ts +45 -15
  222. package/lib/date-picker/src/panel/use-dual-calendar.d.ts +45 -15
  223. package/lib/date-picker/src/panel/use-panel-common.d.ts +45 -15
  224. package/lib/date-picker/styles/light.d.ts +28 -10
  225. package/lib/dialog/src/Dialog.d.ts +101 -35
  226. package/lib/dialog/styles/light.d.ts +14 -5
  227. package/lib/drawer/src/Drawer.d.ts +3 -0
  228. package/lib/drawer/src/DrawerBodyWrapper.d.ts +3 -0
  229. package/lib/drawer/src/DrawerContent.d.ts +3 -0
  230. package/lib/dropdown/index.d.ts +1 -1
  231. package/lib/dropdown/src/Dropdown.d.ts +5 -2
  232. package/lib/dropdown/src/DropdownGroup.d.ts +2 -3
  233. package/lib/dropdown/src/DropdownMenu.d.ts +3 -4
  234. package/lib/dropdown/src/DropdownMenu.js +5 -4
  235. package/lib/dropdown/src/DropdownOption.d.ts +3 -4
  236. package/lib/dropdown/src/DropdownOption.js +1 -1
  237. package/lib/dropdown/src/DropdownRenderOption.d.ts +2 -3
  238. package/lib/dropdown/src/interface.d.ts +9 -30
  239. package/lib/dropdown/src/utils.d.ts +1 -0
  240. package/lib/dropdown/src/utils.js +12 -1
  241. package/lib/dynamic-input/src/DynamicInput.d.ts +143 -50
  242. package/lib/dynamic-input/src/InputPreset.d.ts +17 -5
  243. package/lib/dynamic-input/src/PairPreset.d.ts +17 -5
  244. package/lib/dynamic-input/styles/light.d.ts +14 -5
  245. package/lib/dynamic-tags/src/DynamicTags.d.ts +144 -50
  246. package/lib/dynamic-tags/styles/light.d.ts +14 -5
  247. package/lib/ellipsis/src/Ellipsis.d.ts +3 -0
  248. package/lib/global-style/src/GlobalStyle.js +2 -0
  249. package/lib/input/src/Input.d.ts +4 -0
  250. package/lib/input/src/Input.js +6 -0
  251. package/lib/input/src/interface.d.ts +1 -0
  252. package/lib/input-number/src/InputNumber.d.ts +144 -50
  253. package/lib/input-number/styles/light.d.ts +14 -5
  254. package/lib/layout/src/Layout.d.ts +6 -0
  255. package/lib/layout/src/LayoutContent.d.ts +3 -0
  256. package/lib/layout/src/LayoutSider.d.ts +3 -0
  257. package/lib/log/src/Log.d.ts +3 -0
  258. package/lib/mention/src/Mention.d.ts +4 -0
  259. package/lib/menu/index.d.ts +1 -1
  260. package/lib/menu/src/Menu.d.ts +19 -6
  261. package/lib/menu/src/Menu.js +2 -1
  262. package/lib/menu/src/MenuDivider.d.ts +2 -0
  263. package/lib/menu/src/MenuDivider.js +13 -0
  264. package/lib/menu/src/MenuOption.d.ts +8 -1
  265. package/lib/menu/src/MenuOptionContent.d.ts +4 -1
  266. package/lib/menu/src/Submenu.d.ts +18 -16
  267. package/lib/menu/src/interface.d.ts +23 -4
  268. package/lib/menu/src/styles/index.cssr.js +6 -1
  269. package/lib/menu/src/utils.d.ts +4 -2
  270. package/lib/menu/src/utils.js +22 -3
  271. package/lib/menu/styles/light.d.ts +2 -0
  272. package/lib/menu/styles/light.js +3 -2
  273. package/lib/modal/src/BodyWrapper.d.ts +31 -10
  274. package/lib/modal/src/Modal.d.ts +168 -60
  275. package/lib/modal/styles/light.d.ts +14 -5
  276. package/lib/notification/src/NotificationContainer.d.ts +3 -0
  277. package/lib/pagination/src/Pagination.d.ts +4 -0
  278. package/lib/popconfirm/src/Popconfirm.d.ts +143 -50
  279. package/lib/popconfirm/styles/light.d.ts +14 -5
  280. package/lib/popselect/src/Popselect.d.ts +3 -0
  281. package/lib/popselect/src/PopselectPanel.d.ts +3 -0
  282. package/lib/radio/src/Radio.d.ts +3 -0
  283. package/lib/radio/src/RadioButton.d.ts +3 -0
  284. package/lib/radio/src/use-radio.d.ts +2 -0
  285. package/lib/radio/src/use-radio.js +6 -3
  286. package/lib/select/src/Select.d.ts +3 -0
  287. package/lib/slider/src/Slider.d.ts +70 -91
  288. package/lib/slider/src/Slider.js +324 -581
  289. package/lib/slider/src/interface.d.ts +1 -1
  290. package/lib/slider/src/styles/index.cssr.js +86 -16
  291. package/lib/slider/src/utils.d.ts +10 -1
  292. package/lib/slider/src/utils.js +11 -1
  293. package/lib/slider/styles/_common.d.ts +1 -0
  294. package/lib/slider/styles/_common.js +1 -0
  295. package/lib/slider/styles/light.d.ts +1 -0
  296. package/lib/space/src/Space.js +2 -0
  297. package/lib/steps/src/Step.js +1 -1
  298. package/lib/table/src/Table.d.ts +35 -0
  299. package/lib/table/src/Table.js +8 -4
  300. package/lib/table/src/styles/index.cssr.js +1 -1
  301. package/lib/table/styles/light.d.ts +3 -0
  302. package/lib/table/styles/light.js +2 -2
  303. package/lib/tabs/index.d.ts +2 -0
  304. package/lib/tabs/index.js +3 -1
  305. package/lib/tabs/src/Tab.d.ts +35 -18
  306. package/lib/tabs/src/Tab.js +10 -11
  307. package/lib/tabs/src/Tabs.js +57 -17
  308. package/lib/tag/src/Tag.d.ts +8 -3
  309. package/lib/tag/src/Tag.js +10 -1
  310. package/lib/tag/src/styles/index.cssr.js +10 -5
  311. package/lib/tag/src/styles/rtl.cssr.js +7 -1
  312. package/lib/theme-editor/src/ThemeEditor.d.ts +3 -0
  313. package/lib/time-picker/src/Panel.d.ts +17 -5
  314. package/lib/time-picker/src/TimePicker.d.ts +144 -50
  315. package/lib/time-picker/styles/light.d.ts +14 -5
  316. package/lib/tooltip/src/Tooltip.d.ts +3 -0
  317. package/lib/transfer/src/Transfer.d.ts +143 -50
  318. package/lib/transfer/src/TransferFilter.d.ts +17 -5
  319. package/lib/transfer/src/TransferList.d.ts +17 -5
  320. package/lib/transfer/src/TransferListItem.d.ts +17 -5
  321. package/lib/transfer/styles/light.d.ts +14 -5
  322. package/lib/tree/src/Tree.d.ts +3 -0
  323. package/lib/tree/src/TreeNodeCheckbox.d.ts +3 -0
  324. package/lib/tree-select/src/TreeSelect.d.ts +3 -0
  325. package/lib/upload/src/Upload.d.ts +143 -50
  326. package/lib/upload/src/UploadFile.d.ts +18 -6
  327. package/lib/upload/src/UploadProgress.d.ts +17 -5
  328. package/lib/upload/styles/light.d.ts +14 -5
  329. package/lib/version.d.ts +1 -1
  330. package/lib/version.js +1 -1
  331. package/package.json +3 -3
  332. package/web-types.json +146 -9
@@ -10,8 +10,10 @@ const evtd_1 = require("evtd");
10
10
  const _mixins_1 = require("../../_mixins");
11
11
  const _utils_1 = require("../../_utils");
12
12
  const styles_1 = require("../styles");
13
- const index_cssr_1 = __importDefault(require("./styles/index.cssr"));
14
13
  const utils_1 = require("./utils");
14
+ const index_cssr_1 = __importDefault(require("./styles/index.cssr"));
15
+ // ref: https://developer.mozilla.org/zh-CN/docs/Web/API/MouseEvent/button
16
+ const eventButtonLeft = 0;
15
17
  const sliderProps = Object.assign(Object.assign({}, _mixins_1.useTheme.props), { to: _utils_1.useAdjustedTo.propTo, defaultValue: {
16
18
  type: [Number, Array],
17
19
  default: 0
@@ -25,29 +27,15 @@ const sliderProps = Object.assign(Object.assign({}, _mixins_1.useTheme.props), {
25
27
  type: Number,
26
28
  default: 100
27
29
  }, step: {
28
- type: Number,
30
+ type: [Number, String],
29
31
  default: 1
30
- }, range: Boolean, value: [Number, Array], placement: {
31
- type: String,
32
- default: 'top'
33
- }, showTooltip: {
32
+ }, range: Boolean, value: [Number, Array], placement: String, showTooltip: {
34
33
  type: Boolean,
35
34
  default: undefined
36
35
  }, tooltip: {
37
36
  type: Boolean,
38
37
  default: true
39
- }, 'onUpdate:value': [Function, Array], onUpdateValue: [Function, Array],
40
- // deprecated
41
- onChange: {
42
- type: [Function, Array],
43
- validator: () => {
44
- if (process.env.NODE_ENV !== 'production') {
45
- (0, _utils_1.warn)('slider', '`on-change` is deprecated, please use `on-update:value` instead.');
46
- }
47
- return true;
48
- },
49
- default: undefined
50
- } });
38
+ }, vertical: Boolean, reverse: Boolean, 'onUpdate:value': [Function, Array], onUpdateValue: [Function, Array] });
51
39
  exports.default = (0, vue_1.defineComponent)({
52
40
  name: 'Slider',
53
41
  props: sliderProps,
@@ -56,119 +44,127 @@ exports.default = (0, vue_1.defineComponent)({
56
44
  const themeRef = (0, _mixins_1.useTheme)('Slider', 'Slider', index_cssr_1.default, styles_1.sliderLight, props, mergedClsPrefixRef);
57
45
  const formItem = (0, _mixins_1.useFormItem)(props);
58
46
  const { mergedDisabledRef } = formItem;
59
- const handleRef1 = (0, vue_1.ref)(null);
60
- const handleRef2 = (0, vue_1.ref)(null);
61
- const railRef = (0, vue_1.ref)(null);
62
- const followerRef1 = (0, vue_1.ref)(null);
63
- const followerRef2 = (0, vue_1.ref)(null);
47
+ const handleRailRef = (0, vue_1.ref)(null);
64
48
  const precisionRef = (0, vue_1.computed)(() => {
65
- const precisions = [props.min, props.max, props.step].map((item) => {
66
- const fraction = String(item).split('.')[1];
67
- return fraction ? fraction.length : 0;
68
- });
69
- return Math.max(...precisions);
49
+ const { step } = props;
50
+ if (step <= 0 || step === 'mark')
51
+ return 0;
52
+ const stepString = step.toString();
53
+ let precision = 0;
54
+ if (stepString.includes('.')) {
55
+ precision = stepString.length - stepString.indexOf('.') - 1;
56
+ }
57
+ return precision;
70
58
  });
59
+ const [handleRefs, setHandleRefs] = (0, utils_1.useRefs)();
60
+ const [followerRefs, setFollowerRefs] = (0, utils_1.useRefs)();
71
61
  const uncontrolledValueRef = (0, vue_1.ref)(props.defaultValue);
72
62
  const controlledValueRef = (0, vue_1.toRef)(props, 'value');
73
63
  const mergedValueRef = (0, vooks_1.useMergedState)(controlledValueRef, uncontrolledValueRef);
74
- const memoziedOtherValueRef = (0, vue_1.ref)(0);
75
- const changeSourceRef = (0, vue_1.ref)(null);
76
- const handleActive1Ref = (0, vue_1.ref)(false);
77
- const handleActive2Ref = (0, vue_1.ref)(false);
78
- const handleClicked1Ref = (0, vue_1.ref)(false);
79
- const handleClicked2Ref = (0, vue_1.ref)(false);
80
- const controlledShowTooltipRef = (0, vue_1.toRef)(props, 'showTooltip');
81
- const mergedShowTooltip1Ref = (0, vooks_1.useMergedState)(controlledShowTooltipRef, handleActive1Ref);
82
- const mergedShowTooltip2Ref = (0, vooks_1.useMergedState)(controlledShowTooltipRef, handleActive2Ref);
83
- const dotTransitionDisabledRef = (0, vue_1.ref)(false);
84
- const activeRef = (0, vue_1.computed)(() => {
85
- return handleActive1Ref.value || handleActive2Ref.value;
64
+ const arrifiedValueRef = (0, vue_1.computed)(() => {
65
+ const { value: mergedValue } = mergedValueRef;
66
+ return (props.range ? mergedValue : [mergedValue]).map(clampValue);
67
+ });
68
+ const handleCountExceeds2Ref = (0, vue_1.computed)(() => arrifiedValueRef.value.length > 2);
69
+ const mergedPlacementRef = (0, vue_1.computed)(() => {
70
+ return props.placement === undefined
71
+ ? props.vertical
72
+ ? 'right'
73
+ : 'top'
74
+ : props.placement;
75
+ });
76
+ const markValuesRef = (0, vue_1.computed)(() => {
77
+ const { marks } = props;
78
+ return marks ? Object.keys(marks).map(parseFloat) : null;
79
+ });
80
+ const activeIndexRef = (0, vue_1.ref)(-1);
81
+ const previousIndexRef = (0, vue_1.ref)(-1);
82
+ const hoverIndexRef = (0, vue_1.ref)(-1);
83
+ const draggingRef = (0, vue_1.ref)(false);
84
+ const styleDirectionRef = (0, vue_1.computed)(() => {
85
+ const { vertical, reverse } = props;
86
+ const left = reverse ? 'right' : 'left';
87
+ const bottom = reverse ? 'top' : 'bottom';
88
+ return vertical ? bottom : left;
86
89
  });
87
- const prevActiveRef = (0, vue_1.ref)(activeRef.value);
88
- const clickedRef = (0, vue_1.computed)(() => {
89
- return handleClicked1Ref.value || handleClicked2Ref.value;
90
+ const fillStyleRef = (0, vue_1.computed)(() => {
91
+ if (handleCountExceeds2Ref.value)
92
+ return;
93
+ const values = arrifiedValueRef.value;
94
+ const start = props.range ? Math.min.apply(null, values) : props.min;
95
+ const end = props.range ? Math.max.apply(null, values) : values[0];
96
+ const { value: styleDirection } = styleDirectionRef;
97
+ return props.vertical
98
+ ? {
99
+ [styleDirection]: `${valueToPercentage(start)}%`,
100
+ height: `${valueToPercentage(end - start)}%`
101
+ }
102
+ : {
103
+ [styleDirection]: `${valueToPercentage(start)}%`,
104
+ width: `${valueToPercentage(end - start)}%`
105
+ };
90
106
  });
107
+ const dotTransitionDisabledRef = (0, vue_1.ref)(false);
91
108
  const markInfosRef = (0, vue_1.computed)(() => {
92
109
  const mergedMarks = [];
93
- const { marks, max, min } = props;
110
+ const { marks } = props;
94
111
  if (marks) {
95
- const { value: mergedValue } = mergedValueRef;
112
+ const orderValues = arrifiedValueRef.value.slice();
113
+ orderValues.sort((a, b) => a - b);
114
+ const { value: styleDirection } = styleDirectionRef;
115
+ const { value: handleCountExceeds2 } = handleCountExceeds2Ref;
116
+ const { range } = props;
117
+ const isActive = handleCountExceeds2
118
+ ? () => false
119
+ : (num) => range
120
+ ? num >= orderValues[0] &&
121
+ num <= orderValues[orderValues.length - 1]
122
+ : num <= orderValues[0];
96
123
  for (const key of Object.keys(marks)) {
97
124
  const num = Number(key);
98
125
  mergedMarks.push({
99
- active: Array.isArray(mergedValue)
100
- ? mergedValue[0] <= num && mergedValue[1] >= num
101
- : mergedValue !== null
102
- ? mergedValue >= num
103
- : false,
126
+ active: isActive(num),
104
127
  label: marks[key],
105
128
  style: {
106
- left: `${((num - min) / (max - min)) * 100}%`
129
+ [styleDirection]: `${valueToPercentage(num)}%`
107
130
  }
108
131
  });
109
132
  }
110
133
  }
111
134
  return mergedMarks;
112
135
  });
113
- const fillStyleRef = (0, vue_1.computed)(() => {
114
- const { max, min, range } = props;
115
- if (range) {
116
- return {
117
- left: `${((handleValue1Ref.value - min) / (max - min)) * 100}%`,
118
- width: `${((handleValue2Ref.value - handleValue1Ref.value) / (max - min)) *
119
- 100}%`
120
- };
121
- }
122
- else {
123
- return {
124
- left: 0,
125
- width: `${((handleValue1Ref.value - min) / (max - min)) * 100}%`
126
- };
127
- }
128
- });
129
- const handleValue1Ref = (0, vue_1.computed)(() => {
130
- const { value: mergedValue } = mergedValueRef;
131
- if (Array.isArray(mergedValue)) {
132
- return sanitizeValue(mergedValue[0]);
133
- }
134
- else {
135
- return sanitizeValue(mergedValue);
136
- }
137
- });
138
- const handleValue2Ref = (0, vue_1.computed)(() => {
139
- const { value: mergedValue } = mergedValueRef;
140
- if (Array.isArray(mergedValue)) {
141
- return sanitizeValue(mergedValue[1]);
136
+ function isShowTooltip(index) {
137
+ return (props.showTooltip ||
138
+ hoverIndexRef.value === index ||
139
+ (activeIndexRef.value === index && draggingRef.value));
140
+ }
141
+ function isSkipCSSDetection(index) {
142
+ return !(activeIndexRef.value === index && previousIndexRef.value === index);
143
+ }
144
+ function focusActiveHandle(index) {
145
+ var _a;
146
+ if (~index) {
147
+ activeIndexRef.value = index;
148
+ (_a = handleRefs.value.get(index)) === null || _a === void 0 ? void 0 : _a.focus();
142
149
  }
143
- return 0;
144
- });
145
- const firstHandleStyleRef = (0, vue_1.computed)(() => {
146
- const { value: handleValue1 } = handleValue1Ref;
147
- const { value: handleClicked1 } = handleClicked1Ref;
148
- const { max, min } = props;
149
- const percentage = ((handleValue1 - min) / (max - min)) * 100;
150
- return {
151
- left: `${percentage}%`,
152
- transform: `translateX(${-percentage}%)`,
153
- zIndex: handleClicked1 ? 1 : 0
154
- };
155
- });
156
- const secondHandleStyleRef = (0, vue_1.computed)(() => {
157
- const { value: handleValue2 } = handleValue2Ref;
158
- const { value: handleClicked2 } = handleClicked2Ref;
159
- const { max, min } = props;
160
- const percentage = ((handleValue2 - min) / (max - min)) * 100;
150
+ }
151
+ function syncPosition() {
152
+ followerRefs.value.forEach((inst, index) => {
153
+ if (isShowTooltip(index))
154
+ inst.syncPosition();
155
+ });
156
+ }
157
+ function getHandleStyle(value, index) {
158
+ const percentage = valueToPercentage(value);
159
+ const { value: styleDirection } = styleDirectionRef;
161
160
  return {
162
- left: `${percentage}%`,
163
- transform: `translateX(${-percentage}%)`,
164
- zIndex: handleClicked2 ? 1 : 0
161
+ [styleDirection]: `${percentage}%`,
162
+ zIndex: index === activeIndexRef.value ? 1 : 0
165
163
  };
166
- });
164
+ }
167
165
  function doUpdateValue(value) {
168
- const { onChange, 'onUpdate:value': _onUpdateValue, onUpdateValue } = props;
166
+ const { 'onUpdate:value': _onUpdateValue, onUpdateValue } = props;
169
167
  const { nTriggerFormInput, nTriggerFormChange } = formItem;
170
- if (onChange)
171
- (0, _utils_1.call)(onChange, value);
172
168
  if (onUpdateValue)
173
169
  (0, _utils_1.call)(onUpdateValue, value);
174
170
  if (_onUpdateValue)
@@ -177,411 +173,230 @@ exports.default = (0, vue_1.defineComponent)({
177
173
  nTriggerFormInput();
178
174
  nTriggerFormChange();
179
175
  }
180
- function doUpdateShow(show1, show2) {
181
- if (show1 !== undefined) {
182
- handleActive1Ref.value = show1;
176
+ function dispatchValueUpdate(value) {
177
+ const { range } = props;
178
+ if (range) {
179
+ if (Array.isArray(value)) {
180
+ const { value: oldValues } = arrifiedValueRef;
181
+ if (value.join() !== oldValues.join()) {
182
+ doUpdateValue(value);
183
+ }
184
+ }
183
185
  }
184
- if (show2 !== undefined) {
185
- handleActive2Ref.value = show2;
186
+ else if (!Array.isArray(value)) {
187
+ const oldValue = arrifiedValueRef.value[0];
188
+ if (oldValue !== value) {
189
+ doUpdateValue(value);
190
+ }
186
191
  }
187
192
  }
188
- function syncPosition() {
189
- var _a, _b;
190
- (_a = followerRef1.value) === null || _a === void 0 ? void 0 : _a.syncPosition();
191
- (_b = followerRef2.value) === null || _b === void 0 ? void 0 : _b.syncPosition();
193
+ function doDispatchValue(value, index) {
194
+ if (props.range) {
195
+ const values = arrifiedValueRef.value.slice();
196
+ values.splice(index, 1, value);
197
+ dispatchValueUpdate(values);
198
+ }
199
+ else {
200
+ dispatchValueUpdate(value);
201
+ }
192
202
  }
193
- function handleHandleFocus1() {
194
- if (clickedRef.value)
195
- return;
196
- doUpdateShow(true, false);
203
+ function getClosestMark(currentValue, markValues = markValuesRef.value, buffer) {
204
+ if (markValues) {
205
+ let closestMark = null;
206
+ let index = -1;
207
+ while (++index < markValues.length) {
208
+ const diff = markValues[index] - currentValue;
209
+ const distance = Math.abs(diff);
210
+ if (
211
+ // find marks in the same direction
212
+ (buffer === undefined || diff * buffer > 0) &&
213
+ (closestMark === null || distance < closestMark.distance)) {
214
+ closestMark = {
215
+ value: markValues[index],
216
+ distance,
217
+ index
218
+ };
219
+ }
220
+ }
221
+ return closestMark;
222
+ }
223
+ return null;
197
224
  }
198
- function handleHandleFocus2() {
199
- if (clickedRef.value)
200
- return;
201
- doUpdateShow(false, true);
225
+ function sanitizeValue(value, currentValue, stepBuffer) {
226
+ const stepping = stepBuffer !== undefined;
227
+ if (!stepBuffer) {
228
+ stepBuffer = value - currentValue > 0 ? 1 : -1;
229
+ }
230
+ const markValues = markValuesRef.value || [];
231
+ const { min, max, step } = props;
232
+ if (step === 'mark') {
233
+ const closestMark = getClosestMark(value, markValues.concat(currentValue), stepping ? stepBuffer : undefined);
234
+ return closestMark ? closestMark.value : currentValue;
235
+ }
236
+ if (step <= 0)
237
+ return currentValue;
238
+ const roundValue = getRoundValue(value);
239
+ // ensure accurate step
240
+ const stepValue = new Array(Math.floor((max - min) / step) + 1)
241
+ .fill('')
242
+ .map((_, index) => step * index + min);
243
+ // If it is a stepping, priority will be given to the marks
244
+ // on the rail,otherwise take the nearest one
245
+ const closestMark = stepping
246
+ ? getClosestMark(currentValue, stepValue.concat(markValues), stepBuffer)
247
+ : getClosestMark(value, markValues.concat(roundValue));
248
+ return closestMark ? clampValue(closestMark.value) : currentValue;
202
249
  }
203
- function handleHandleBlur1() {
204
- if (clickedRef.value)
205
- return;
206
- doUpdateShow(false, false);
250
+ function clampValue(value) {
251
+ return Math.min(props.max, Math.max(props.min, value));
207
252
  }
208
- function handleHandleBlur2() {
209
- if (clickedRef.value)
210
- return;
211
- doUpdateShow(false, false);
253
+ function valueToPercentage(value) {
254
+ const { max, min } = props;
255
+ return ((value - min) / (max - min)) * 100;
212
256
  }
213
- function handleRailClick(e) {
214
- var _a, _b, _c, _d;
215
- if (mergedDisabledRef.value)
216
- return;
217
- const { value: railEl } = railRef;
257
+ function percentageToValue(percentage) {
258
+ const { max, min } = props;
259
+ return min + (max - min) * percentage;
260
+ }
261
+ function getRoundValue(value) {
262
+ const { step, min } = props;
263
+ if (step <= 0 || step === 'mark')
264
+ return value;
265
+ const newValue = Math.round((value - min) / step) * step + min;
266
+ return Number(newValue.toFixed(precisionRef.value));
267
+ }
268
+ function getPointValue(event) {
269
+ const railEl = handleRailRef.value;
218
270
  if (!railEl)
219
271
  return;
272
+ const touchEvent = (0, utils_1.isTouchEvent)(event) ? event.touches[0] : event;
220
273
  const railRect = railEl.getBoundingClientRect();
221
- const offsetRatio = (e.clientX - railRect.left) / railRect.width;
222
- const newValue = props.min + (props.max - props.min) * offsetRatio;
223
- if (!props.range) {
224
- dispatchValueUpdate(newValue, { source: 'click' });
225
- (_a = handleRef1.value) === null || _a === void 0 ? void 0 : _a.focus();
274
+ let percentage;
275
+ if (props.vertical) {
276
+ percentage = (railRect.bottom - touchEvent.clientY) / railRect.height;
226
277
  }
227
278
  else {
228
- if (Array.isArray(mergedValueRef.value)) {
229
- if (Math.abs(handleValue1Ref.value - newValue) <
230
- Math.abs(handleValue2Ref.value - newValue)) {
231
- dispatchValueUpdate([newValue, handleValue2Ref.value], {
232
- source: 'click'
233
- });
234
- (_b = handleRef1.value) === null || _b === void 0 ? void 0 : _b.focus();
235
- }
236
- else {
237
- dispatchValueUpdate([handleValue1Ref.value, newValue], {
238
- source: 'click'
239
- });
240
- (_c = handleRef2.value) === null || _c === void 0 ? void 0 : _c.focus();
241
- }
242
- }
243
- else {
244
- dispatchValueUpdate([newValue, newValue], { source: 'click' });
245
- (_d = handleRef1.value) === null || _d === void 0 ? void 0 : _d.focus();
246
- }
279
+ percentage = (touchEvent.clientX - railRect.left) / railRect.width;
247
280
  }
248
- }
249
- function handleHandleMouseMove(e, handleIndex) {
250
- if (!handleRef1.value || !railRef.value)
251
- return;
252
- const x = 'touches' in e ? e.touches[0].clientX : e.clientX;
253
- const { width: handleWidth } = handleRef1.value.getBoundingClientRect();
254
- const { width: railWidth, left: railLeft } = railRef.value.getBoundingClientRect();
255
- const { min, max, range } = props;
256
- const offsetRatio = (x - railLeft - handleWidth / 2) / (railWidth - handleWidth);
257
- const newValue = min + (max - min) * offsetRatio;
258
- if (range) {
259
- if (handleIndex === 0) {
260
- dispatchValueUpdate([memoziedOtherValueRef.value, newValue]);
261
- }
262
- else {
263
- dispatchValueUpdate([newValue, memoziedOtherValueRef.value]);
264
- }
265
- }
266
- else {
267
- dispatchValueUpdate(newValue);
281
+ if (props.reverse) {
282
+ percentage = 1 - percentage;
268
283
  }
284
+ return percentageToValue(percentage);
269
285
  }
270
- function handleKeyDown(e) {
286
+ function handleRailKeyDown(e) {
271
287
  if (mergedDisabledRef.value)
272
288
  return;
289
+ const { vertical, reverse } = props;
273
290
  switch (e.code) {
291
+ case 'ArrowUp':
292
+ e.preventDefault();
293
+ handleStepValue(vertical && reverse ? -1 : 1);
294
+ break;
274
295
  case 'ArrowRight':
275
- handleKeyDownRight();
296
+ e.preventDefault();
297
+ handleStepValue(!vertical && reverse ? -1 : 1);
298
+ break;
299
+ case 'ArrowDown':
300
+ e.preventDefault();
301
+ handleStepValue(vertical && reverse ? 1 : -1);
276
302
  break;
277
303
  case 'ArrowLeft':
278
- handleKeyDownLeft();
304
+ e.preventDefault();
305
+ handleStepValue(!vertical && reverse ? 1 : -1);
279
306
  break;
280
307
  }
281
308
  }
282
- function handleKeyDownRight() {
283
- if (clickedRef.value)
309
+ function handleStepValue(ratio) {
310
+ const activeIndex = activeIndexRef.value;
311
+ if (activeIndex === -1)
284
312
  return;
285
- let firstHandleFocused = false;
286
- let handleValue = null;
287
- if (document.activeElement === handleRef1.value) {
288
- firstHandleFocused = true;
289
- handleValue = handleValue1Ref.value;
290
- }
291
- else {
292
- handleValue = handleValue2Ref.value;
293
- }
294
- const { step, marks } = props;
295
- let nextValue = Math.floor(handleValue / step) * step + step;
296
- if (marks) {
297
- for (const key of Object.keys(marks)) {
298
- const numberKey = Number(key);
299
- if (numberKey > handleValue && numberKey < nextValue) {
300
- nextValue = numberKey;
301
- }
302
- }
303
- }
304
- if (props.range) {
305
- if (firstHandleFocused) {
306
- dispatchValueUpdate([nextValue, handleValue2Ref.value], {
307
- source: 'keyboard'
308
- });
309
- }
310
- else {
311
- dispatchValueUpdate([handleValue1Ref.value, nextValue], {
312
- source: 'keyboard'
313
- });
314
- }
315
- }
316
- else {
317
- dispatchValueUpdate(nextValue, { source: 'keyboard' });
318
- }
313
+ const { step } = props;
314
+ const currentValue = arrifiedValueRef.value[activeIndex];
315
+ const nextValue = step <= 0 || step === 'mark'
316
+ ? currentValue
317
+ : currentValue + step * ratio;
318
+ doDispatchValue(
319
+ // Avoid the number of value does not change when `step` is null
320
+ sanitizeValue(nextValue, currentValue, ratio > 0 ? 1 : -1), activeIndex);
319
321
  }
320
- function handleKeyDownLeft() {
321
- if (clickedRef.value)
322
+ function handleRailMouseDown(event) {
323
+ var _a, _b;
324
+ if (mergedDisabledRef.value)
322
325
  return;
323
- let firstHandleFocused = false;
324
- let handleValue = null;
325
- if (document.activeElement === handleRef1.value) {
326
- firstHandleFocused = true;
327
- handleValue = handleValue1Ref.value;
328
- }
329
- else if (document.activeElement === handleRef2.value) {
330
- handleValue = handleValue2Ref.value;
331
- }
332
- else {
326
+ if (!(0, utils_1.isTouchEvent)(event) && event.button !== eventButtonLeft) {
333
327
  return;
334
328
  }
335
- const { step, marks } = props;
336
- let nextValue = Math.ceil(handleValue / step) * step - step;
337
- if (marks) {
338
- for (const key of Object.keys(marks)) {
339
- const numberKey = Number(key);
340
- if (numberKey < handleValue && numberKey > nextValue) {
341
- nextValue = numberKey;
342
- }
343
- }
344
- }
345
- if (props.range) {
346
- if (firstHandleFocused) {
347
- dispatchValueUpdate([nextValue, handleValue2Ref.value], {
348
- source: 'keyboard'
349
- });
350
- }
351
- else {
352
- dispatchValueUpdate([handleValue1Ref.value, nextValue], {
353
- source: 'keyboard'
354
- });
355
- }
356
- }
357
- else {
358
- dispatchValueUpdate(nextValue, { source: 'keyboard' });
359
- }
360
- }
361
- function switchFocus() {
362
- if (props.range) {
363
- const firstHandle = handleRef1.value;
364
- const secondHandle = handleRef2.value;
365
- if (firstHandle && secondHandle) {
366
- if (handleActive1Ref.value &&
367
- document.activeElement === secondHandle) {
368
- disableTransitionOneTick();
369
- firstHandle.focus();
370
- if (handleClicked2Ref.value) {
371
- handleClicked2Ref.value = false;
372
- handleClicked1Ref.value = true;
373
- }
374
- }
375
- else if (handleActive2Ref.value &&
376
- document.activeElement === firstHandle) {
377
- disableTransitionOneTick();
378
- secondHandle.focus();
379
- if (handleClicked1Ref.value) {
380
- handleClicked1Ref.value = false;
381
- handleClicked2Ref.value = true;
382
- }
383
- }
384
- }
385
- }
386
- }
387
- function getClosestMarkValue(currentValue) {
388
- const { marks } = props;
389
- if (marks) {
390
- const markValues = Object.keys(marks).map((key) => Number(key));
391
- let diff = null;
392
- let closestValue = null;
393
- for (const value of markValues) {
394
- if (closestValue === null) {
395
- closestValue = value;
396
- diff = Math.abs(value - currentValue);
397
- }
398
- else {
399
- const newDiff = Math.abs(value - currentValue);
400
- if (newDiff < diff) {
401
- closestValue = value;
402
- diff = newDiff;
403
- }
404
- }
405
- }
406
- return closestValue;
407
- }
408
- return null;
409
- }
410
- function sanitizeValue(value) {
411
- let justifiedValue = value;
412
- const { min, max, marks, step } = props;
413
- justifiedValue = Math.max(min, justifiedValue);
414
- justifiedValue = Math.min(max, justifiedValue);
415
- justifiedValue = Math.round((justifiedValue - min) / step) * step + min;
416
- justifiedValue = parseFloat(justifiedValue.toFixed(precisionRef.value));
417
- if (marks) {
418
- const closestMarkValue = getClosestMarkValue(value);
419
- if (closestMarkValue !== null &&
420
- Math.abs(justifiedValue - value) > Math.abs(closestMarkValue - value)) {
421
- justifiedValue = closestMarkValue;
422
- }
423
- }
424
- return justifiedValue;
425
- }
426
- function handleFirstHandleMouseDown(e) {
427
- if (mergedDisabledRef.value)
329
+ const pointValue = getPointValue(event);
330
+ if (pointValue === undefined)
428
331
  return;
429
- if ((0, utils_1.isTouchEvent)(e))
430
- e.preventDefault();
431
- if (props.range) {
432
- memoziedOtherValueRef.value = handleValue2Ref.value;
332
+ const values = arrifiedValueRef.value.slice();
333
+ const activeIndex = props.range
334
+ ? (_b = (_a = getClosestMark(pointValue, values)) === null || _a === void 0 ? void 0 : _a.index) !== null && _b !== void 0 ? _b : -1
335
+ : 0;
336
+ if (activeIndex !== -1) {
337
+ // avoid triggering scrolling on touch
338
+ event.preventDefault();
339
+ focusActiveHandle(activeIndex);
340
+ startDragging();
341
+ doDispatchValue(sanitizeValue(pointValue, arrifiedValueRef.value[activeIndex]), activeIndex);
433
342
  }
434
- doUpdateShow(true, false);
435
- handleClicked1Ref.value = true;
436
- (0, evtd_1.on)('touchend', document, handleHandleMouseUp);
437
- (0, evtd_1.on)('mouseup', document, handleHandleMouseUp);
438
- (0, evtd_1.on)('touchmove', document, handleFirstHandleMouseMove);
439
- (0, evtd_1.on)('mousemove', document, handleFirstHandleMouseMove);
440
343
  }
441
- function handleSecondHandleMouseDown(e) {
442
- if (mergedDisabledRef.value)
443
- return;
444
- if ((0, utils_1.isTouchEvent)(e))
445
- e.preventDefault();
446
- if (props.range) {
447
- memoziedOtherValueRef.value = handleValue1Ref.value;
344
+ function startDragging() {
345
+ if (!draggingRef.value) {
346
+ draggingRef.value = true;
347
+ (0, evtd_1.on)('touchend', document, handleMouseUp);
348
+ (0, evtd_1.on)('mouseup', document, handleMouseUp);
349
+ (0, evtd_1.on)('touchmove', document, handleMouseMove);
350
+ (0, evtd_1.on)('mousemove', document, handleMouseMove);
448
351
  }
449
- doUpdateShow(false, true);
450
- handleClicked2Ref.value = true;
451
- (0, evtd_1.on)('touchend', document, handleHandleMouseUp);
452
- (0, evtd_1.on)('mouseup', document, handleHandleMouseUp);
453
- (0, evtd_1.on)('touchmove', document, handleSecondHandleMouseMove);
454
- (0, evtd_1.on)('mousemove', document, handleSecondHandleMouseMove);
455
352
  }
456
- function handleHandleMouseUp(e) {
457
- var _a, _b;
458
- if ((0, utils_1.isTouchEvent)(e) ||
459
- (!((_a = handleRef1.value) === null || _a === void 0 ? void 0 : _a.contains(e.target)) &&
460
- (props.range ? !((_b = handleRef2.value) === null || _b === void 0 ? void 0 : _b.contains(e.target)) : true))) {
461
- doUpdateShow(false, false);
353
+ function stopDragging() {
354
+ if (draggingRef.value) {
355
+ draggingRef.value = false;
356
+ (0, evtd_1.off)('touchend', document, handleMouseUp);
357
+ (0, evtd_1.off)('mouseup', document, handleMouseUp);
358
+ (0, evtd_1.off)('touchmove', document, handleMouseMove);
359
+ (0, evtd_1.off)('mousemove', document, handleMouseMove);
462
360
  }
463
- handleClicked2Ref.value = false;
464
- handleClicked1Ref.value = false;
465
- (0, evtd_1.off)('touchend', document, handleHandleMouseUp);
466
- (0, evtd_1.off)('mouseup', document, handleHandleMouseUp);
467
- (0, evtd_1.off)('touchmove', document, handleFirstHandleMouseMove);
468
- (0, evtd_1.off)('touchmove', document, handleSecondHandleMouseMove);
469
- (0, evtd_1.off)('mousemove', document, handleFirstHandleMouseMove);
470
- (0, evtd_1.off)('mousemove', document, handleSecondHandleMouseMove);
471
361
  }
472
- function dispatchValueUpdate(value, options = { source: null }) {
473
- const { source } = options;
474
- const { range } = props;
475
- if (range) {
476
- if (Array.isArray(value)) {
477
- if (value[0] > value[1]) {
478
- value = [sanitizeValue(value[1]), sanitizeValue(value[0])];
479
- }
480
- else {
481
- value = [sanitizeValue(value[0]), sanitizeValue(value[1])];
482
- }
483
- const { value: oldValue } = mergedValueRef;
484
- if (!Array.isArray(oldValue) ||
485
- oldValue[0] !== value[0] ||
486
- oldValue[1] !== value[1]) {
487
- changeSourceRef.value = source;
488
- doUpdateValue(value);
489
- }
490
- }
491
- }
492
- else {
493
- if (!Array.isArray(value)) {
494
- const { max, min } = props;
495
- const { value: oldValue } = mergedValueRef;
496
- if (value > max) {
497
- if (oldValue !== max) {
498
- changeSourceRef.value = source;
499
- doUpdateValue(max);
500
- }
501
- }
502
- else if (value < min) {
503
- if (oldValue !== min) {
504
- changeSourceRef.value = source;
505
- doUpdateValue(min);
506
- }
507
- }
508
- else {
509
- const newValue = sanitizeValue(value);
510
- if (oldValue !== newValue) {
511
- changeSourceRef.value = source;
512
- doUpdateValue(newValue);
513
- }
514
- }
515
- }
362
+ function handleMouseMove(event) {
363
+ const { value: activeIndex } = activeIndexRef;
364
+ if (!draggingRef.value || activeIndex === -1) {
365
+ stopDragging();
366
+ return;
516
367
  }
368
+ const pointValue = getPointValue(event);
369
+ doDispatchValue(sanitizeValue(pointValue, arrifiedValueRef.value[activeIndex]), activeIndex);
517
370
  }
518
- function handleFirstHandleMouseMove(e) {
519
- handleHandleMouseMove(e, 0);
520
- }
521
- function handleSecondHandleMouseMove(e) {
522
- handleHandleMouseMove(e, 1);
371
+ function handleMouseUp() {
372
+ stopDragging();
523
373
  }
524
- function handleFirstHandleMouseEnter() {
525
- if (!activeRef.value) {
526
- doUpdateShow(true, undefined);
527
- void (0, vue_1.nextTick)(() => {
528
- syncPosition();
529
- });
374
+ function handleHandleFocus(index) {
375
+ activeIndexRef.value = index;
376
+ // Wake focus style
377
+ if (!mergedDisabledRef.value) {
378
+ hoverIndexRef.value = index;
530
379
  }
531
380
  }
532
- function handleFirstHandleMouseLeave() {
533
- if (changeSourceRef.value === 'keyboard')
534
- return;
535
- if (!activeRef.value) {
536
- doUpdateShow(false, false);
381
+ function handleHandleBlur(index) {
382
+ if (activeIndexRef.value === index) {
383
+ activeIndexRef.value = -1;
384
+ stopDragging();
537
385
  }
538
- else if (!clickedRef.value) {
539
- doUpdateShow(false, false);
386
+ if (hoverIndexRef.value === index) {
387
+ hoverIndexRef.value = -1;
540
388
  }
541
389
  }
542
- function handleSecondHandleMouseEnter() {
543
- if (!activeRef.value) {
544
- doUpdateShow(undefined, true);
545
- void (0, vue_1.nextTick)(() => {
546
- syncPosition();
547
- });
548
- }
390
+ function handleHandleMouseEnter(index) {
391
+ hoverIndexRef.value = index;
549
392
  }
550
- function handleSecondHandleMouseLeave() {
551
- if (changeSourceRef.value === 'keyboard')
552
- return;
553
- if (!activeRef.value) {
554
- doUpdateShow(false, false);
555
- }
556
- else if (!clickedRef.value) {
557
- doUpdateShow(false, false);
393
+ function handleHandleMouseLeave(index) {
394
+ if (hoverIndexRef.value === index) {
395
+ hoverIndexRef.value = -1;
558
396
  }
559
397
  }
560
- function disableTransitionOneTick() {
561
- if (handleRef1.value) {
562
- handleRef1.value.style.transition = 'none';
563
- void (0, vue_1.nextTick)(() => {
564
- if (handleRef1.value) {
565
- handleRef1.value.style.transition = '';
566
- }
567
- });
568
- }
569
- if (handleRef2.value) {
570
- handleRef2.value.style.transition = 'none';
571
- void (0, vue_1.nextTick)(() => {
572
- if (handleRef2.value) {
573
- handleRef2.value.style.transition = '';
574
- }
575
- });
576
- }
577
- }
578
- (0, vue_1.watch)(activeRef, (value) => {
579
- void (0, vue_1.nextTick)(() => {
580
- prevActiveRef.value = value;
581
- });
582
- });
583
- (0, vue_1.watch)(mergedValueRef, (newValue, oldValue) => {
584
- const { value: changeSource } = changeSourceRef;
398
+ (0, vue_1.watch)(activeIndexRef, (_, previous) => (previousIndexRef.value = previous));
399
+ (0, vue_1.watch)(mergedValueRef, () => {
585
400
  if (props.marks) {
586
401
  if (dotTransitionDisabledRef.value)
587
402
  return;
@@ -590,57 +405,7 @@ exports.default = (0, vue_1.defineComponent)({
590
405
  dotTransitionDisabledRef.value = false;
591
406
  });
592
407
  }
593
- if (props.range && Array.isArray(newValue) && Array.isArray(oldValue)) {
594
- if (oldValue && oldValue[1] !== newValue[1]) {
595
- void (0, vue_1.nextTick)(() => {
596
- if (!(changeSource === 'click')) {
597
- doUpdateShow(false, true);
598
- }
599
- switchFocus();
600
- });
601
- }
602
- else if (oldValue && oldValue[0] !== newValue[0]) {
603
- void (0, vue_1.nextTick)(() => {
604
- if (!(changeSource === 'click')) {
605
- doUpdateShow(true, false);
606
- }
607
- switchFocus();
608
- });
609
- }
610
- else if (newValue[0] === newValue[1]) {
611
- void (0, vue_1.nextTick)(() => {
612
- if (!(changeSource === 'click')) {
613
- doUpdateShow(false, true);
614
- }
615
- switchFocus();
616
- });
617
- }
618
- }
619
- void (0, vue_1.nextTick)(() => {
620
- // dom has changed but event is not fired, use marco task to make sure
621
- // relevant event handler is called
622
- setTimeout(() => {
623
- changeSourceRef.value = null;
624
- }, 0);
625
- if (props.range) {
626
- if (Array.isArray(newValue) && Array.isArray(oldValue)) {
627
- if (newValue[0] !== oldValue[0] || newValue[1] !== oldValue[1]) {
628
- syncPosition();
629
- }
630
- }
631
- }
632
- else {
633
- syncPosition();
634
- }
635
- });
636
- });
637
- (0, vue_1.onBeforeUnmount)(() => {
638
- (0, evtd_1.off)('touchmove', document, handleFirstHandleMouseMove);
639
- (0, evtd_1.off)('touchmove', document, handleSecondHandleMouseMove);
640
- (0, evtd_1.off)('mousemove', document, handleFirstHandleMouseMove);
641
- (0, evtd_1.off)('mousemove', document, handleSecondHandleMouseMove);
642
- (0, evtd_1.off)('touchend', document, handleHandleMouseUp);
643
- (0, evtd_1.off)('mouseup', document, handleHandleMouseUp);
408
+ void (0, vue_1.nextTick)(syncPosition);
644
409
  });
645
410
  return {
646
411
  mergedClsPrefix: mergedClsPrefixRef,
@@ -648,43 +413,26 @@ exports.default = (0, vue_1.defineComponent)({
648
413
  uncontrolledValue: uncontrolledValueRef,
649
414
  mergedValue: mergedValueRef,
650
415
  mergedDisabled: mergedDisabledRef,
416
+ mergedPlacement: mergedPlacementRef,
651
417
  isMounted: (0, vooks_1.useIsMounted)(),
652
418
  adjustedTo: (0, _utils_1.useAdjustedTo)(props),
653
- handleValue1: handleValue1Ref,
654
- handleValue2: handleValue2Ref,
655
- mergedShowTooltip1: mergedShowTooltip1Ref,
656
- mergedShowTooltip2: mergedShowTooltip2Ref,
657
- handleActive1: handleActive1Ref,
658
- handleActive2: handleActive2Ref,
659
- handleClicked1: handleClicked1Ref,
660
- handleClicked2: handleClicked2Ref,
661
- memoziedOtherValue: memoziedOtherValueRef,
662
- active: activeRef,
663
- prevActive: prevActiveRef,
664
- clicked: clickedRef,
665
419
  dotTransitionDisabled: dotTransitionDisabledRef,
666
420
  markInfos: markInfosRef,
667
- // https://github.com/vuejs/vue-next/issues/2283
668
- handleRef1,
669
- handleRef2,
670
- railRef,
671
- followerRef1,
672
- followerRef2,
673
- firstHandleStyle: firstHandleStyleRef,
674
- secondHandleStyle: secondHandleStyleRef,
421
+ isShowTooltip,
422
+ isSkipCSSDetection,
423
+ handleRailRef,
424
+ setHandleRefs,
425
+ setFollowerRefs,
675
426
  fillStyle: fillStyleRef,
676
- handleKeyDown,
677
- handleRailClick,
678
- handleHandleFocus1,
679
- handleHandleBlur1,
680
- handleFirstHandleMouseDown,
681
- handleFirstHandleMouseEnter,
682
- handleFirstHandleMouseLeave,
683
- handleHandleFocus2,
684
- handleHandleBlur2,
685
- handleSecondHandleMouseDown,
686
- handleSecondHandleMouseEnter,
687
- handleSecondHandleMouseLeave,
427
+ getHandleStyle,
428
+ activeIndex: activeIndexRef,
429
+ arrifiedValues: arrifiedValueRef,
430
+ handleRailMouseDown,
431
+ handleHandleFocus,
432
+ handleHandleBlur,
433
+ handleHandleMouseEnter,
434
+ handleHandleMouseLeave,
435
+ handleRailKeyDown,
688
436
  indicatorCssVars: (0, vue_1.computed)(() => {
689
437
  const { self: { fontSize, indicatorColor, indicatorBoxShadow, indicatorTextColor, indicatorBorderRadius } } = themeRef.value;
690
438
  return {
@@ -696,7 +444,7 @@ exports.default = (0, vue_1.defineComponent)({
696
444
  };
697
445
  }),
698
446
  cssVars: (0, vue_1.computed)(() => {
699
- const { self: { railColor, railColorHover, fillColor, fillColorHover, handleColor, opacityDisabled, dotColor, dotColorModal, handleBoxShadow, handleBoxShadowHover, handleBoxShadowActive, handleBoxShadowFocus, dotBorder, dotBoxShadow, railHeight, handleSize, dotHeight, dotWidth, dotBorderRadius, fontSize, dotBorderActive, dotColorPopover }, common: { cubicBezierEaseInOut } } = themeRef.value;
447
+ const { self: { railColor, railColorHover, fillColor, fillColorHover, handleColor, opacityDisabled, dotColor, dotColorModal, handleBoxShadow, handleBoxShadowHover, handleBoxShadowActive, handleBoxShadowFocus, dotBorder, dotBoxShadow, railHeight, railWidthVertical, handleSize, dotHeight, dotWidth, dotBorderRadius, fontSize, dotBorderActive, dotColorPopover }, common: { cubicBezierEaseInOut } } = themeRef.value;
700
448
  return {
701
449
  '--bezier': cubicBezierEaseInOut,
702
450
  '--dot-border': dotBorder,
@@ -720,7 +468,8 @@ exports.default = (0, vue_1.defineComponent)({
720
468
  '--opacity-disabled': opacityDisabled,
721
469
  '--rail-color': railColor,
722
470
  '--rail-color-hover': railColorHover,
723
- '--rail-height': railHeight
471
+ '--rail-height': railHeight,
472
+ '--rail-width-vertical': railWidthVertical
724
473
  };
725
474
  })
726
475
  };
@@ -731,11 +480,13 @@ exports.default = (0, vue_1.defineComponent)({
731
480
  `${mergedClsPrefix}-slider`,
732
481
  {
733
482
  [`${mergedClsPrefix}-slider--disabled`]: this.mergedDisabled,
734
- [`${mergedClsPrefix}-slider--active`]: this.active,
735
- [`${mergedClsPrefix}-slider--with-mark`]: this.marks
483
+ [`${mergedClsPrefix}-slider--active`]: this.activeIndex !== -1,
484
+ [`${mergedClsPrefix}-slider--with-mark`]: this.marks,
485
+ [`${mergedClsPrefix}-slider--vertical`]: this.vertical,
486
+ [`${mergedClsPrefix}-slider--reverse`]: this.reverse
736
487
  }
737
- ], style: this.cssVars, onKeydown: this.handleKeyDown, onClick: this.handleRailClick },
738
- (0, vue_1.h)("div", { ref: "railRef", class: `${mergedClsPrefix}-slider-rail` },
488
+ ], style: this.cssVars, onKeydown: this.handleRailKeyDown, onMousedown: this.handleRailMouseDown, onTouchstart: this.handleRailMouseDown },
489
+ (0, vue_1.h)("div", { class: `${mergedClsPrefix}-slider-rail` },
739
490
  (0, vue_1.h)("div", { class: `${mergedClsPrefix}-slider-rail__fill`, style: this.fillStyle }),
740
491
  this.marks ? ((0, vue_1.h)("div", { class: [
741
492
  `${mergedClsPrefix}-slider-dots`,
@@ -747,35 +498,27 @@ exports.default = (0, vue_1.defineComponent)({
747
498
  {
748
499
  [`${mergedClsPrefix}-slider-dot--active`]: mark.active
749
500
  }
750
- ], style: mark.style }))))) : null),
751
- (0, vue_1.h)(vueuc_1.VBinder, null, {
752
- default: () => [
753
- (0, vue_1.h)(vueuc_1.VTarget, null, {
754
- default: () => ((0, vue_1.h)("div", { ref: "handleRef1", class: `${mergedClsPrefix}-slider-handle`, tabindex: this.mergedDisabled ? -1 : 0, style: this.firstHandleStyle, onFocus: this.handleHandleFocus1, onBlur: this.handleHandleBlur1, onTouchstart: this.handleFirstHandleMouseDown, onMousedown: this.handleFirstHandleMouseDown, onMouseenter: this.handleFirstHandleMouseEnter, onMouseleave: this.handleFirstHandleMouseLeave }))
755
- }),
756
- this.tooltip && ((0, vue_1.h)(vueuc_1.VFollower, { ref: "followerRef1", show: this.mergedShowTooltip1, to: this.adjustedTo, teleportDisabled: this.adjustedTo === _utils_1.useAdjustedTo.tdkey, placement: this.placement, containerClass: this.namespace }, {
757
- default: () => ((0, vue_1.h)(vue_1.Transition, { name: "fade-in-scale-up-transition", appear: this.isMounted, css: !(this.active && this.prevActive) }, {
758
- default: () => this.mergedShowTooltip1 ? ((0, vue_1.h)("div", { class: `${mergedClsPrefix}-slider-handle-indicator`, style: this.indicatorCssVars }, typeof formatTooltip === 'function'
759
- ? formatTooltip(this.handleValue1)
760
- : this.handleValue1)) : null
761
- }))
762
- }))
763
- ]
764
- }),
765
- this.tooltip && this.range ? ((0, vue_1.h)(vueuc_1.VBinder, null, {
766
- default: () => [
767
- (0, vue_1.h)(vueuc_1.VTarget, null, {
768
- default: () => ((0, vue_1.h)("div", { ref: "handleRef2", class: `${mergedClsPrefix}-slider-handle`, tabindex: this.mergedDisabled ? -1 : 0, style: this.secondHandleStyle, onFocus: this.handleHandleFocus2, onBlur: this.handleHandleBlur2, onTouchstart: this.handleSecondHandleMouseDown, onMousedown: this.handleSecondHandleMouseDown, onMouseenter: this.handleSecondHandleMouseEnter, onMouseleave: this.handleSecondHandleMouseLeave }))
769
- }),
770
- (0, vue_1.h)(vueuc_1.VFollower, { ref: "followerRef2", show: this.mergedShowTooltip2, to: this.adjustedTo, placement: this.placement, containerClass: this.namespace, teleportDisabled: this.adjustedTo === _utils_1.useAdjustedTo.tdkey }, {
771
- default: () => ((0, vue_1.h)(vue_1.Transition, { name: "fade-in-scale-up-transition", appear: this.isMounted, css: !(this.active && this.prevActive) }, {
772
- default: () => this.mergedShowTooltip2 ? ((0, vue_1.h)("div", { class: `${mergedClsPrefix}-slider-handle-indicator`, style: this.indicatorCssVars }, typeof formatTooltip === 'function'
773
- ? formatTooltip(this.handleValue2)
774
- : this.handleValue2)) : null
775
- }))
776
- })
777
- ]
778
- })) : null,
779
- this.marks ? ((0, vue_1.h)("div", { class: `${mergedClsPrefix}-slider-marks` }, this.markInfos.map((mark) => ((0, vue_1.h)("div", { key: mark.label, class: `${mergedClsPrefix}-slider-mark`, style: mark.style }, mark.label))))) : null));
501
+ ], style: mark.style }))))) : null,
502
+ (0, vue_1.h)("div", { ref: "handleRailRef", class: `${mergedClsPrefix}-slider-handles` }, this.arrifiedValues.map((value, index) => {
503
+ const showTooltip = this.isShowTooltip(index);
504
+ return ((0, vue_1.h)(vueuc_1.VBinder, null, {
505
+ default: () => [
506
+ (0, vue_1.h)(vueuc_1.VTarget, null, {
507
+ default: () => ((0, vue_1.h)("div", { ref: this.setHandleRefs(index), class: `${mergedClsPrefix}-slider-handle`, tabindex: this.mergedDisabled ? -1 : 0, style: this.getHandleStyle(value, index), onFocus: () => this.handleHandleFocus(index), onBlur: () => this.handleHandleBlur(index), onMouseenter: () => this.handleHandleMouseEnter(index), onMouseleave: () => this.handleHandleMouseLeave(index) }))
508
+ }),
509
+ this.tooltip && ((0, vue_1.h)(vueuc_1.VFollower, { ref: this.setFollowerRefs(index), show: showTooltip, to: this.adjustedTo, teleportDisabled: this.adjustedTo === _utils_1.useAdjustedTo.tdkey, placement: this.mergedPlacement, containerClass: this.namespace }, {
510
+ default: () => ((0, vue_1.h)(vue_1.Transition, { name: "fade-in-scale-up-transition", appear: this.isMounted, css: this.isSkipCSSDetection(index) }, {
511
+ default: () => showTooltip ? ((0, vue_1.h)("div", { class: [
512
+ `${mergedClsPrefix}-slider-handle-indicator`,
513
+ `${mergedClsPrefix}-slider-handle-indicator--${this.mergedPlacement}`
514
+ ], style: this.indicatorCssVars }, typeof formatTooltip === 'function'
515
+ ? formatTooltip(value)
516
+ : value)) : null
517
+ }))
518
+ }))
519
+ ]
520
+ }));
521
+ })),
522
+ this.marks ? ((0, vue_1.h)("div", { class: `${mergedClsPrefix}-slider-marks` }, this.markInfos.map((mark) => ((0, vue_1.h)("div", { key: mark.label, class: `${mergedClsPrefix}-slider-mark`, style: mark.style }, mark.label))))) : null)));
780
523
  }
781
524
  });