@refinitiv-ui/elements 5.12.2 → 6.0.0-next.2

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 (365) hide show
  1. package/README.md +4 -4
  2. package/lib/accordion/index.d.ts +5 -0
  3. package/lib/accordion/index.js +2 -2
  4. package/lib/accordion/themes/halo/dark/index.js +1 -1
  5. package/lib/accordion/themes/halo/light/index.js +1 -1
  6. package/lib/accordion/themes/solar/charcoal/index.js +1 -1
  7. package/lib/accordion/themes/solar/pearl/index.js +1 -1
  8. package/lib/appstate-bar/index.d.ts +11 -0
  9. package/lib/appstate-bar/index.js +8 -3
  10. package/lib/appstate-bar/themes/halo/dark/index.js +1 -1
  11. package/lib/appstate-bar/themes/halo/light/index.js +1 -1
  12. package/lib/appstate-bar/themes/solar/charcoal/index.js +1 -1
  13. package/lib/appstate-bar/themes/solar/pearl/index.js +1 -1
  14. package/lib/autosuggest/index.d.ts +5 -0
  15. package/lib/autosuggest/index.js +22 -12
  16. package/lib/autosuggest/themes/halo/dark/index.js +3 -3
  17. package/lib/autosuggest/themes/halo/light/index.js +3 -3
  18. package/lib/autosuggest/themes/solar/charcoal/index.js +3 -3
  19. package/lib/autosuggest/themes/solar/pearl/index.js +3 -3
  20. package/lib/button/index.d.ts +7 -13
  21. package/lib/button/index.js +8 -43
  22. package/lib/button/themes/halo/dark/index.js +1 -1
  23. package/lib/button/themes/halo/light/index.js +1 -1
  24. package/lib/button/themes/solar/charcoal/index.js +1 -1
  25. package/lib/button/themes/solar/pearl/index.js +1 -1
  26. package/lib/button-bar/index.d.ts +5 -0
  27. package/lib/button-bar/index.js +4 -5
  28. package/lib/button-bar/themes/halo/dark/index.js +1 -1
  29. package/lib/button-bar/themes/halo/light/index.js +1 -1
  30. package/lib/button-bar/themes/solar/charcoal/index.js +1 -1
  31. package/lib/button-bar/themes/solar/pearl/index.js +1 -1
  32. package/lib/calendar/constants.js +1 -1
  33. package/lib/calendar/index.d.ts +6 -1
  34. package/lib/calendar/index.js +39 -15
  35. package/lib/calendar/locales.js +5 -5
  36. package/lib/calendar/themes/halo/dark/index.js +1 -1
  37. package/lib/calendar/themes/halo/light/index.js +1 -1
  38. package/lib/calendar/themes/solar/charcoal/index.js +1 -1
  39. package/lib/calendar/themes/solar/pearl/index.js +1 -1
  40. package/lib/calendar/types.d.ts +1 -1
  41. package/lib/calendar/utils.js +5 -5
  42. package/lib/canvas/index.d.ts +5 -0
  43. package/lib/canvas/index.js +3 -4
  44. package/lib/card/index.d.ts +21 -0
  45. package/lib/card/index.js +37 -15
  46. package/lib/card/themes/halo/dark/index.js +3 -3
  47. package/lib/card/themes/halo/light/index.js +3 -3
  48. package/lib/card/themes/solar/charcoal/index.js +3 -3
  49. package/lib/card/themes/solar/pearl/index.js +3 -3
  50. package/lib/chart/index.d.ts +5 -0
  51. package/lib/chart/index.js +18 -22
  52. package/lib/chart/plugins/doughnut-center-label.js +6 -11
  53. package/lib/chart/themes/halo/dark/index.js +2 -2
  54. package/lib/chart/themes/halo/light/index.js +2 -2
  55. package/lib/chart/themes/solar/charcoal/index.js +2 -2
  56. package/lib/chart/themes/solar/pearl/index.js +2 -2
  57. package/lib/checkbox/index.d.ts +5 -0
  58. package/lib/checkbox/index.js +3 -3
  59. package/lib/checkbox/themes/halo/dark/index.js +2 -2
  60. package/lib/checkbox/themes/halo/light/index.js +2 -2
  61. package/lib/checkbox/themes/solar/charcoal/index.js +2 -2
  62. package/lib/checkbox/themes/solar/pearl/index.js +2 -2
  63. package/lib/clock/index.d.ts +5 -0
  64. package/lib/clock/index.js +6 -6
  65. package/lib/clock/utils/TickManager.js +2 -2
  66. package/lib/collapse/index.d.ts +5 -0
  67. package/lib/collapse/index.js +7 -9
  68. package/lib/collapse/themes/halo/dark/index.js +3 -3
  69. package/lib/collapse/themes/halo/light/index.js +3 -3
  70. package/lib/collapse/themes/solar/charcoal/index.js +3 -3
  71. package/lib/collapse/themes/solar/pearl/index.js +3 -3
  72. package/lib/color-dialog/elements/color-palettes.d.ts +5 -0
  73. package/lib/color-dialog/elements/color-palettes.js +1 -1
  74. package/lib/color-dialog/elements/grayscale-palettes.d.ts +5 -0
  75. package/lib/color-dialog/elements/grayscale-palettes.js +2 -2
  76. package/lib/color-dialog/elements/palettes.js +4 -5
  77. package/lib/color-dialog/helpers/value-model.js +1 -1
  78. package/lib/color-dialog/index.d.ts +6 -1
  79. package/lib/color-dialog/index.js +17 -12
  80. package/lib/color-dialog/themes/halo/dark/index.js +5 -5
  81. package/lib/color-dialog/themes/halo/light/index.js +5 -5
  82. package/lib/color-dialog/themes/solar/charcoal/index.js +5 -5
  83. package/lib/color-dialog/themes/solar/pearl/index.js +5 -5
  84. package/lib/combo-box/helpers/filter.d.ts +1 -1
  85. package/lib/combo-box/helpers/types.d.ts +1 -1
  86. package/lib/combo-box/index.d.ts +9 -4
  87. package/lib/combo-box/index.js +31 -14
  88. package/lib/combo-box/themes/halo/dark/index.js +5 -5
  89. package/lib/combo-box/themes/halo/light/index.js +5 -5
  90. package/lib/combo-box/themes/solar/charcoal/index.js +5 -5
  91. package/lib/combo-box/themes/solar/pearl/index.js +5 -5
  92. package/lib/counter/index.d.ts +11 -6
  93. package/lib/counter/index.js +8 -8
  94. package/lib/counter/themes/halo/dark/index.js +1 -1
  95. package/lib/counter/themes/halo/light/index.js +1 -1
  96. package/lib/counter/themes/solar/charcoal/index.js +1 -1
  97. package/lib/counter/themes/solar/pearl/index.js +1 -1
  98. package/lib/datetime-field/constants.d.ts +4 -0
  99. package/lib/datetime-field/constants.js +5 -0
  100. package/lib/datetime-field/custom-elements.json +345 -0
  101. package/lib/datetime-field/custom-elements.md +61 -0
  102. package/lib/datetime-field/index.d.ts +322 -0
  103. package/lib/datetime-field/index.js +660 -0
  104. package/lib/datetime-field/themes/halo/dark/index.js +3 -0
  105. package/lib/datetime-field/themes/halo/light/index.js +3 -0
  106. package/lib/datetime-field/themes/solar/charcoal/index.js +3 -0
  107. package/lib/datetime-field/themes/solar/pearl/index.js +3 -0
  108. package/lib/datetime-field/types.d.ts +10 -0
  109. package/lib/datetime-field/types.js +1 -0
  110. package/lib/datetime-field/utils.d.ts +25 -0
  111. package/lib/datetime-field/utils.js +79 -0
  112. package/lib/datetime-picker/index.d.ts +5 -0
  113. package/lib/datetime-picker/index.js +6 -7
  114. package/lib/datetime-picker/themes/halo/dark/index.js +5 -5
  115. package/lib/datetime-picker/themes/halo/light/index.js +5 -5
  116. package/lib/datetime-picker/themes/solar/charcoal/index.js +5 -5
  117. package/lib/datetime-picker/themes/solar/pearl/index.js +5 -5
  118. package/lib/datetime-picker/utils.js +1 -1
  119. package/lib/dialog/draggable-element.js +1 -2
  120. package/lib/dialog/index.d.ts +6 -1
  121. package/lib/dialog/index.js +5 -5
  122. package/lib/dialog/themes/halo/dark/index.js +5 -5
  123. package/lib/dialog/themes/halo/light/index.js +5 -5
  124. package/lib/dialog/themes/solar/charcoal/index.js +5 -5
  125. package/lib/dialog/themes/solar/pearl/index.js +5 -5
  126. package/lib/email-field/index.d.ts +6 -1
  127. package/lib/email-field/index.js +8 -3
  128. package/lib/email-field/themes/halo/dark/index.js +1 -1
  129. package/lib/email-field/themes/halo/light/index.js +1 -1
  130. package/lib/email-field/themes/solar/charcoal/index.js +1 -1
  131. package/lib/email-field/themes/solar/pearl/index.js +1 -1
  132. package/lib/flag/index.d.ts +5 -0
  133. package/lib/flag/index.js +3 -3
  134. package/lib/flag/utils/FlagLoader.d.ts +1 -1
  135. package/lib/flag/utils/FlagLoader.js +1 -1
  136. package/lib/header/index.d.ts +5 -0
  137. package/lib/header/index.js +2 -2
  138. package/lib/heatmap/helpers/color.d.ts +1 -1
  139. package/lib/heatmap/helpers/color.js +3 -5
  140. package/lib/heatmap/helpers/text.d.ts +1 -7
  141. package/lib/heatmap/helpers/text.js +1 -18
  142. package/lib/heatmap/index.d.ts +5 -0
  143. package/lib/heatmap/index.js +22 -30
  144. package/lib/heatmap/themes/halo/dark/index.js +2 -2
  145. package/lib/heatmap/themes/halo/light/index.js +2 -2
  146. package/lib/heatmap/themes/solar/charcoal/index.js +2 -2
  147. package/lib/heatmap/themes/solar/pearl/index.js +2 -2
  148. package/lib/icon/index.d.ts +5 -0
  149. package/lib/icon/index.js +3 -3
  150. package/lib/icon/utils/IconLoader.d.ts +1 -1
  151. package/lib/icon/utils/IconLoader.js +1 -1
  152. package/lib/interactive-chart/helpers/types.d.ts +1 -1
  153. package/lib/interactive-chart/index.d.ts +5 -12
  154. package/lib/interactive-chart/index.js +20 -36
  155. package/lib/interactive-chart/themes/halo/dark/index.js +1 -1
  156. package/lib/interactive-chart/themes/halo/light/index.js +1 -1
  157. package/lib/interactive-chart/themes/solar/charcoal/index.js +1 -1
  158. package/lib/interactive-chart/themes/solar/pearl/index.js +1 -1
  159. package/lib/item/helpers/types.d.ts +1 -1
  160. package/lib/item/index.d.ts +24 -17
  161. package/lib/item/index.js +45 -48
  162. package/lib/item/themes/halo/dark/index.js +2 -2
  163. package/lib/item/themes/halo/light/index.js +2 -2
  164. package/lib/item/themes/solar/charcoal/index.js +2 -2
  165. package/lib/item/themes/solar/pearl/index.js +2 -2
  166. package/lib/label/index.d.ts +6 -1
  167. package/lib/label/index.js +6 -6
  168. package/lib/label/themes/halo/dark/index.js +1 -1
  169. package/lib/label/themes/halo/light/index.js +1 -1
  170. package/lib/label/themes/solar/charcoal/index.js +1 -1
  171. package/lib/label/themes/solar/pearl/index.js +1 -1
  172. package/lib/layout/index.d.ts +5 -0
  173. package/lib/layout/index.js +2 -2
  174. package/lib/led-gauge/index.d.ts +5 -0
  175. package/lib/led-gauge/index.js +2 -2
  176. package/lib/led-gauge/themes/halo/dark/index.js +1 -1
  177. package/lib/led-gauge/themes/halo/light/index.js +1 -1
  178. package/lib/led-gauge/themes/solar/charcoal/index.js +1 -1
  179. package/lib/led-gauge/themes/solar/pearl/index.js +1 -1
  180. package/lib/list/custom-elements.json +0 -13
  181. package/lib/list/custom-elements.md +9 -10
  182. package/lib/list/helpers/item-id.d.ts +8 -0
  183. package/lib/list/helpers/item-id.js +13 -0
  184. package/lib/list/helpers/{list-renderer.d.ts → renderer.d.ts} +4 -0
  185. package/lib/list/helpers/{list-renderer.js → renderer.js} +8 -0
  186. package/lib/list/helpers/types.d.ts +1 -1
  187. package/lib/list/index.d.ts +18 -12
  188. package/lib/list/index.js +30 -29
  189. package/lib/list/renderer.d.ts +1 -1
  190. package/lib/list/themes/halo/dark/index.js +2 -2
  191. package/lib/list/themes/halo/light/index.js +2 -2
  192. package/lib/list/themes/solar/charcoal/index.js +2 -2
  193. package/lib/list/themes/solar/pearl/index.js +2 -2
  194. package/lib/loader/index.d.ts +6 -0
  195. package/lib/loader/index.js +5 -1
  196. package/lib/multi-input/helpers/types.d.ts +1 -1
  197. package/lib/multi-input/index.d.ts +5 -0
  198. package/lib/multi-input/index.js +6 -7
  199. package/lib/multi-input/themes/halo/dark/index.js +2 -2
  200. package/lib/multi-input/themes/halo/light/index.js +2 -2
  201. package/lib/multi-input/themes/solar/charcoal/index.js +2 -2
  202. package/lib/multi-input/themes/solar/pearl/index.js +2 -2
  203. package/lib/notification/elements/notification-tray.d.ts +5 -0
  204. package/lib/notification/elements/notification-tray.js +4 -4
  205. package/lib/notification/elements/notification.d.ts +15 -0
  206. package/lib/notification/elements/notification.js +12 -3
  207. package/lib/notification/themes/halo/dark/index.js +1 -1
  208. package/lib/notification/themes/halo/light/index.js +1 -1
  209. package/lib/notification/themes/solar/charcoal/index.js +1 -1
  210. package/lib/notification/themes/solar/pearl/index.js +1 -1
  211. package/lib/number-field/index.d.ts +8 -3
  212. package/lib/number-field/index.js +14 -4
  213. package/lib/number-field/themes/halo/dark/index.js +1 -1
  214. package/lib/number-field/themes/halo/light/index.js +1 -1
  215. package/lib/number-field/themes/solar/charcoal/index.js +1 -1
  216. package/lib/number-field/themes/solar/pearl/index.js +1 -1
  217. package/lib/overlay/elements/overlay-backdrop.d.ts +5 -0
  218. package/lib/overlay/elements/overlay-backdrop.js +2 -2
  219. package/lib/overlay/elements/overlay-viewport.d.ts +5 -0
  220. package/lib/overlay/elements/overlay-viewport.js +1 -1
  221. package/lib/overlay/elements/overlay.d.ts +5 -0
  222. package/lib/overlay/elements/overlay.js +7 -5
  223. package/lib/overlay/managers/focus-manager.js +11 -6
  224. package/lib/overlay/managers/interaction-lock-manager.js +1 -1
  225. package/lib/overlay/managers/viewport-manager.js +4 -5
  226. package/lib/overlay/managers/zindex-manager.js +1 -1
  227. package/lib/overlay-menu/helpers/types.d.ts +7 -1
  228. package/lib/overlay-menu/helpers/types.js +7 -1
  229. package/lib/overlay-menu/index.d.ts +14 -4
  230. package/lib/overlay-menu/index.js +57 -29
  231. package/lib/overlay-menu/managers/menu-manager.js +2 -1
  232. package/lib/overlay-menu/themes/halo/dark/index.js +3 -3
  233. package/lib/overlay-menu/themes/halo/light/index.js +3 -3
  234. package/lib/overlay-menu/themes/solar/charcoal/index.js +3 -3
  235. package/lib/overlay-menu/themes/solar/pearl/index.js +3 -3
  236. package/lib/pagination/index.d.ts +79 -91
  237. package/lib/pagination/index.js +205 -239
  238. package/lib/pagination/themes/halo/dark/index.js +4 -5
  239. package/lib/pagination/themes/halo/light/index.js +4 -5
  240. package/lib/pagination/themes/solar/charcoal/index.js +4 -5
  241. package/lib/pagination/themes/solar/pearl/index.js +4 -5
  242. package/lib/panel/index.d.ts +5 -0
  243. package/lib/panel/index.js +2 -2
  244. package/lib/password-field/index.d.ts +7 -2
  245. package/lib/password-field/index.js +7 -4
  246. package/lib/password-field/themes/halo/dark/index.js +1 -1
  247. package/lib/password-field/themes/halo/light/index.js +1 -1
  248. package/lib/password-field/themes/solar/charcoal/index.js +1 -1
  249. package/lib/password-field/themes/solar/pearl/index.js +1 -1
  250. package/lib/pill/index.d.ts +21 -0
  251. package/lib/pill/index.js +36 -5
  252. package/lib/pill/themes/halo/dark/index.js +2 -2
  253. package/lib/pill/themes/halo/light/index.js +2 -2
  254. package/lib/pill/themes/solar/charcoal/index.js +2 -2
  255. package/lib/pill/themes/solar/pearl/index.js +2 -2
  256. package/lib/progress-bar/index.d.ts +5 -0
  257. package/lib/progress-bar/index.js +3 -3
  258. package/lib/radio-button/index.d.ts +5 -0
  259. package/lib/radio-button/index.js +3 -3
  260. package/lib/radio-button/radio-button-registry.d.ts +1 -1
  261. package/lib/radio-button/radio-button-registry.js +4 -2
  262. package/lib/radio-button/themes/halo/dark/index.js +1 -1
  263. package/lib/radio-button/themes/halo/light/index.js +1 -1
  264. package/lib/radio-button/themes/solar/charcoal/index.js +1 -1
  265. package/lib/radio-button/themes/solar/pearl/index.js +1 -1
  266. package/lib/rating/index.d.ts +5 -0
  267. package/lib/rating/index.js +4 -4
  268. package/lib/search-field/index.d.ts +7 -2
  269. package/lib/search-field/index.js +8 -4
  270. package/lib/search-field/themes/halo/dark/index.js +1 -1
  271. package/lib/search-field/themes/halo/light/index.js +1 -1
  272. package/lib/search-field/themes/solar/charcoal/index.js +1 -1
  273. package/lib/search-field/themes/solar/pearl/index.js +1 -1
  274. package/lib/select/index.d.ts +5 -0
  275. package/lib/select/index.js +11 -14
  276. package/lib/select/themes/halo/dark/index.js +3 -3
  277. package/lib/select/themes/halo/light/index.js +3 -3
  278. package/lib/select/themes/solar/charcoal/index.js +3 -3
  279. package/lib/select/themes/solar/pearl/index.js +3 -3
  280. package/lib/sidebar-layout/index.d.ts +5 -0
  281. package/lib/sidebar-layout/index.js +4 -4
  282. package/lib/sidebar-layout/themes/halo/dark/index.js +1 -1
  283. package/lib/sidebar-layout/themes/halo/light/index.js +1 -1
  284. package/lib/sidebar-layout/themes/solar/charcoal/index.js +1 -1
  285. package/lib/sidebar-layout/themes/solar/pearl/index.js +1 -1
  286. package/lib/slider/constants.d.ts +15 -0
  287. package/lib/slider/constants.js +18 -0
  288. package/lib/slider/index.d.ts +55 -80
  289. package/lib/slider/index.js +365 -460
  290. package/lib/slider/themes/halo/dark/index.js +1 -1
  291. package/lib/slider/themes/halo/light/index.js +1 -1
  292. package/lib/slider/themes/solar/charcoal/index.js +1 -1
  293. package/lib/slider/themes/solar/pearl/index.js +1 -1
  294. package/lib/slider/utils.d.ts +35 -0
  295. package/lib/slider/utils.js +54 -0
  296. package/lib/sparkline/index.d.ts +5 -0
  297. package/lib/sparkline/index.js +9 -10
  298. package/lib/swing-gauge/index.d.ts +5 -0
  299. package/lib/swing-gauge/index.js +14 -8
  300. package/lib/swing-gauge/themes/halo/dark/index.js +1 -1
  301. package/lib/swing-gauge/themes/halo/light/index.js +1 -1
  302. package/lib/swing-gauge/themes/solar/charcoal/index.js +1 -1
  303. package/lib/swing-gauge/themes/solar/pearl/index.js +1 -1
  304. package/lib/tab/index.d.ts +5 -0
  305. package/lib/tab/index.js +4 -4
  306. package/lib/tab/themes/halo/dark/index.js +2 -2
  307. package/lib/tab/themes/halo/light/index.js +2 -2
  308. package/lib/tab/themes/solar/charcoal/index.js +2 -2
  309. package/lib/tab/themes/solar/pearl/index.js +2 -2
  310. package/lib/tab-bar/index.d.ts +5 -0
  311. package/lib/tab-bar/index.js +6 -6
  312. package/lib/tab-bar/themes/halo/dark/index.js +2 -2
  313. package/lib/tab-bar/themes/halo/light/index.js +2 -2
  314. package/lib/tab-bar/themes/solar/charcoal/index.js +2 -2
  315. package/lib/tab-bar/themes/solar/pearl/index.js +2 -2
  316. package/lib/text-field/index.d.ts +19 -1
  317. package/lib/text-field/index.js +35 -11
  318. package/lib/text-field/themes/halo/dark/index.js +1 -1
  319. package/lib/text-field/themes/halo/light/index.js +1 -1
  320. package/lib/text-field/themes/solar/charcoal/index.js +1 -1
  321. package/lib/text-field/themes/solar/pearl/index.js +1 -1
  322. package/lib/time-picker/index.d.ts +6 -1
  323. package/lib/time-picker/index.js +11 -11
  324. package/lib/time-picker/themes/halo/dark/index.js +2 -2
  325. package/lib/time-picker/themes/halo/light/index.js +2 -2
  326. package/lib/time-picker/themes/solar/charcoal/index.js +2 -2
  327. package/lib/time-picker/themes/solar/pearl/index.js +2 -2
  328. package/lib/toggle/index.d.ts +5 -0
  329. package/lib/toggle/index.js +2 -2
  330. package/lib/tooltip/elements/tooltip-element.d.ts +1 -2
  331. package/lib/tooltip/index.d.ts +6 -0
  332. package/lib/tooltip/index.js +7 -8
  333. package/lib/tooltip/managers/tooltip-manager.js +2 -2
  334. package/lib/tooltip/themes/halo/dark/index.js +1 -1
  335. package/lib/tooltip/themes/halo/light/index.js +1 -1
  336. package/lib/tooltip/themes/solar/charcoal/index.js +1 -1
  337. package/lib/tooltip/themes/solar/pearl/index.js +1 -1
  338. package/lib/tornado-chart/elements/tornado-chart.d.ts +5 -0
  339. package/lib/tornado-chart/elements/tornado-chart.js +2 -2
  340. package/lib/tornado-chart/elements/tornado-item.d.ts +5 -0
  341. package/lib/tornado-chart/elements/tornado-item.js +3 -3
  342. package/lib/tornado-chart/themes/halo/dark/index.js +2 -2
  343. package/lib/tornado-chart/themes/halo/light/index.js +2 -2
  344. package/lib/tornado-chart/themes/solar/charcoal/index.js +2 -2
  345. package/lib/tornado-chart/themes/solar/pearl/index.js +2 -2
  346. package/lib/tree/elements/tree-item.d.ts +8 -3
  347. package/lib/tree/elements/tree-item.js +5 -6
  348. package/lib/tree/elements/tree.d.ts +7 -3
  349. package/lib/tree/elements/tree.js +6 -7
  350. package/lib/tree/helpers/renderer.d.ts +4 -0
  351. package/lib/tree/helpers/renderer.js +20 -13
  352. package/lib/tree/helpers/types.d.ts +1 -1
  353. package/lib/tree/managers/tree-manager.d.ts +1 -1
  354. package/lib/tree/themes/halo/dark/index.js +4 -4
  355. package/lib/tree/themes/halo/light/index.js +4 -4
  356. package/lib/tree/themes/solar/charcoal/index.js +4 -4
  357. package/lib/tree/themes/solar/pearl/index.js +4 -4
  358. package/lib/tree-select/index.d.ts +8 -7
  359. package/lib/tree-select/index.js +39 -38
  360. package/lib/tree-select/themes/halo/dark/index.js +9 -9
  361. package/lib/tree-select/themes/halo/light/index.js +9 -9
  362. package/lib/tree-select/themes/solar/charcoal/index.js +9 -9
  363. package/lib/tree-select/themes/solar/pearl/index.js +9 -9
  364. package/lib/version.js +1 -1
  365. package/package.json +35 -295
@@ -1,50 +1,13 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { html, css, ControlElement, WarningNotice } from '@refinitiv-ui/core';
3
- import { customElement } from '@refinitiv-ui/core/lib/decorators/custom-element.js';
4
- import { property } from '@refinitiv-ui/core/lib/decorators/property.js';
5
- import { query } from '@refinitiv-ui/core/lib/decorators/query.js';
6
- import { styleMap } from '@refinitiv-ui/core/lib/directives/style-map.js';
3
+ import { customElement } from '@refinitiv-ui/core/decorators/custom-element.js';
4
+ import { property } from '@refinitiv-ui/core/decorators/property.js';
5
+ import { query } from '@refinitiv-ui/core/decorators/query.js';
6
+ import { createRef, ref } from '@refinitiv-ui/core/directives/ref.js';
7
+ import { styleMap } from '@refinitiv-ui/core/directives/style-map.js';
7
8
  import { VERSION } from '../version.js';
8
9
  import '../number-field/index.js';
9
- var SliderNameType;
10
- (function (SliderNameType) {
11
- SliderNameType["value"] = "value";
12
- SliderNameType["from"] = "from";
13
- SliderNameType["to"] = "to";
14
- })(SliderNameType || (SliderNameType = {}));
15
- var PreviousSliderNameType;
16
- (function (PreviousSliderNameType) {
17
- PreviousSliderNameType["value"] = "valuePrevious";
18
- PreviousSliderNameType["from"] = "fromPrevious";
19
- PreviousSliderNameType["to"] = "toPrevious";
20
- })(PreviousSliderNameType || (PreviousSliderNameType = {}));
21
- var NumberFieldNameType;
22
- (function (NumberFieldNameType) {
23
- NumberFieldNameType["fromInput"] = "fromInput";
24
- NumberFieldNameType["toInput"] = "toInput";
25
- })(NumberFieldNameType || (NumberFieldNameType = {}));
26
- /**
27
- * Set prevent default action and stop bubbles event
28
- * @private
29
- * @param event event mouse or touch
30
- * @returns {void}
31
- */
32
- const preventDefault = function (event) {
33
- event.preventDefault();
34
- event.stopPropagation();
35
- return event;
36
- };
37
- /**
38
- * Return value that never exceed the maximum boundary
39
- * @private
40
- * @param value value for check clamp
41
- * @param min max value
42
- * @param max min value
43
- * @returns number between two numbers
44
- */
45
- const clamp = function (value, min, max) {
46
- return Math.max(min, Math.min(value, max)).toString();
47
- };
10
+ import { clamp, preventDefault, validateNumber, isDecimalNumber, countDecimalPlace } from './utils.js';
48
11
  /**
49
12
  * Allows users to make selections from a range of values
50
13
  *
@@ -63,12 +26,15 @@ const clamp = function (value, min, max) {
63
26
  */
64
27
  let Slider = class Slider extends ControlElement {
65
28
  constructor() {
66
- super(...arguments);
29
+ super();
30
+ /**
31
+ * An array of slider thumbs
32
+ */
33
+ this.thumbs = [];
34
+ /**
35
+ * Whether if the thumb is being drag
36
+ */
67
37
  this.dragging = false;
68
- this.stepUse = 1;
69
- this.decimalPlaces = 0;
70
- this.dragElements = [];
71
- this.isEventReady = false;
72
38
  this.valuePrevious = '';
73
39
  this.fromPrevious = '';
74
40
  this.toPrevious = '';
@@ -115,134 +81,25 @@ let Slider = class Slider extends ControlElement {
115
81
  */
116
82
  this.minRange = '0';
117
83
  /**
118
- * Input number event blur and notify property
119
- * @param event event blur input number field
120
- * @returns {void}
84
+ * Slider element reference
121
85
  */
122
- this.onBlur = (event) => {
123
- if (this.readonly) {
124
- return;
125
- }
126
- const { value, name } = event.target;
127
- const currentData = name;
128
- const perviousData = `${name}Previous`;
129
- if (value && this[currentData] !== value) {
130
- this.updateNotifyProperty(currentData, value);
131
- this[perviousData] = value;
132
- }
133
- event.preventDefault();
134
- };
86
+ this.sliderRef = createRef();
135
87
  /**
136
- * Input number event keydown y
137
- * @param event event keydown
138
- * @returns {void}
88
+ * Slider's track reference
139
89
  */
140
- this.onKeydown = (event) => {
141
- if (this.readonly || this.disabled) {
142
- return;
143
- }
144
- this.handleEnterKey(event);
145
- };
90
+ this.trackRef = createRef();
146
91
  /**
147
- * Start dragging event on slider
148
- * @param event event dragstart
149
- * @returns {void}
150
- */
151
- this.onDragStart = (event) => {
152
- this.dragging = true;
153
- this.classList.add('grabbable');
154
- if (this.range) {
155
- const pct = this.getMousePosition(event);
156
- const mousePos = ((this.maxNumber - this.minNumber) * pct) + this.minNumber;
157
- const distFrom = Math.abs(mousePos - this.fromNumber);
158
- const distTo = Math.abs(mousePos - this.toNumber);
159
- if (distFrom < distTo) {
160
- this.activeThumb = this.dragElements[0];
161
- }
162
- else if (distFrom > distTo) {
163
- this.activeThumb = this.dragElements[1];
164
- }
165
- this.dragElements.forEach((el) => {
166
- el.style.zIndex = '5';
167
- });
168
- this.activeThumb.style.zIndex = '10';
169
- // Set focus to input when drag.
170
- if (this.isShowInputField) {
171
- this.toggleFocusField(this.activeThumb.getAttribute('name') || '', true);
172
- }
173
- }
174
- else {
175
- this.activeThumb = this.dragElements[0];
176
- }
177
- this.onDrag(event);
178
- if (event.changedTouches) {
179
- this.addEventListener('touchmove', this.onDrag);
180
- this.addEventListener('touchend', this.onDragEnd);
181
- }
182
- else {
183
- window.addEventListener('mousemove', this.onDrag);
184
- window.addEventListener('mouseup', this.onDragEnd);
185
- }
186
- };
92
+ * @ignore
93
+ */
94
+ this.onDrag = this.onDrag.bind(this);
187
95
  /**
188
- * Dragging after on dragging start event
189
- * @param event event mousemove and touchmove
190
- * @returns {void}
191
- */
192
- this.onDrag = (event) => {
193
- if (this.minNumber !== this.maxNumber) {
194
- const thumbPos = this.getMousePosition(event);
195
- const closestStep = this.calculateStep(thumbPos);
196
- // Can be dragged slider when the value is valid
197
- if (closestStep <= 1) {
198
- const thumbLeft = this.stepUse !== 0 ? closestStep : thumbPos;
199
- const calStepValue = this.calculateValue(thumbLeft);
200
- const prettyVal = Number(this.displayValue(calStepValue));
201
- if (this.range) {
202
- if (this.activeThumb === this.dragElements[1]) {
203
- this.to = this.validateTo(prettyVal).toString();
204
- }
205
- else {
206
- this.from = this.validateFrom(prettyVal).toString();
207
- }
208
- }
209
- else {
210
- this.value = prettyVal.toString();
211
- }
212
- }
213
- }
214
- };
96
+ * @ignore
97
+ */
98
+ this.onDragStart = this.onDragStart.bind(this);
215
99
  /**
216
- * End dragging event and remove dragging event
217
- * @param e event mouseup and touchmove
218
- * @returns {void}
219
- */
220
- this.onDragEnd = (e) => {
221
- if (this.dragging) {
222
- this.dragging = false;
223
- const event = e;
224
- if (event.changedTouches) {
225
- this.removeEventListener('touchmove', this.onDrag);
226
- this.removeEventListener('touchend', this.onDragEnd);
227
- }
228
- else {
229
- window.removeEventListener('mousemove', this.onDrag);
230
- window.removeEventListener('mouseup', this.onDragEnd);
231
- }
232
- this.classList.remove('grabbable');
233
- if (this.classList.length === 0) {
234
- this.removeAttribute('class');
235
- }
236
- if (!event.changedTouches) {
237
- event.preventDefault();
238
- }
239
- this.dispatchDataChangedEvent();
240
- // Reset tab index of input that's drag.
241
- if (this.isShowInputField) {
242
- this.toggleFocusField(this.activeThumb.getAttribute('name') || '', false);
243
- }
244
- }
245
- };
100
+ * @ignore
101
+ */
102
+ this.onDragEnd = this.onDragEnd.bind(this);
246
103
  }
247
104
  /**
248
105
  * Element version number
@@ -251,6 +108,79 @@ let Slider = class Slider extends ControlElement {
251
108
  static get version() {
252
109
  return VERSION;
253
110
  }
111
+ /**
112
+ * Define styles in a tagged template literal, using the css tag function.
113
+ * @returns CSS template
114
+ */
115
+ static get styles() {
116
+ return css `
117
+ :host {
118
+ display: flex;
119
+ }
120
+ [part=slider-wrapper] {
121
+ position: relative;
122
+ width: 100%;
123
+ }
124
+ [part=slider] {
125
+ width: 100%;
126
+ height: 100%;
127
+ display: inline-block;
128
+ }
129
+ :host(:not([disabled]):focus){
130
+ outline:none;
131
+ }
132
+ :host([show-steps]) [part=track-wrapper]::after {
133
+ display:block;
134
+ position: absolute;
135
+ content: "";
136
+ right: 0;
137
+ }
138
+ [part=track-wrapper]{
139
+ content: "";
140
+ position: absolute;
141
+ width: 100%;
142
+ top: 50%;
143
+ left: 0;
144
+ pointer-events: none;
145
+ }
146
+ [part=thumb-container]{
147
+ position: absolute;
148
+ top: 0;
149
+ width: 100%;
150
+ z-index: 5;
151
+ }
152
+ [part=thumb]{
153
+ position: absolute;
154
+ margin: 0 auto;
155
+ }
156
+ [part=pin]{
157
+ display: flex;
158
+ position: absolute;
159
+ align-items: center;
160
+ justify-content: center;
161
+ z-index: 1;
162
+ }
163
+ :host([show-steps]) [part=step-container]{
164
+ position: absolute;
165
+ left: 0;
166
+ width: 100%;
167
+ }
168
+ :host([show-steps]) [part=step]{
169
+ width: 100%;
170
+ position: absolute;
171
+ left: 0;
172
+ }
173
+ [part=track-fill]{
174
+ z-index: 2;
175
+ content: "";
176
+ position: absolute;
177
+ left: 0;
178
+ }
179
+ :host([show-steps][step="0"]) [part=track-wrapper]::after{
180
+ width: 0;
181
+ }
182
+ `;
183
+ }
254
184
  /**
255
185
  * Converts value from string to number for calculations
256
186
  * @returns value of input as a number
@@ -295,6 +225,18 @@ let Slider = class Slider extends ControlElement {
295
225
  }
296
226
  return step;
297
227
  }
228
+ /**
229
+ * Compute and normalise step value for calculations
230
+ * @returns step value that should be inside the min / max boundary
231
+ */
232
+ get stepRange() {
233
+ const step = Math.abs(this.stepNumber);
234
+ if (step > this.maxNumber - this.minNumber && !isDecimalNumber(step)) {
235
+ // new step shouldn't be larger than slider
236
+ return Math.abs(this.maxNumber - this.minNumber);
237
+ }
238
+ return step;
239
+ }
298
240
  /**
299
241
  * Converts from value from string to number for calculations
300
242
  * @returns from value of slider as a number
@@ -328,6 +270,18 @@ let Slider = class Slider extends ControlElement {
328
270
  }
329
271
  return minRange;
330
272
  }
273
+ /**
274
+ * Number of decimal places used for displaying value
275
+ * Based on step or min decimal places
276
+ */
277
+ get decimalPlace() {
278
+ if (isDecimalNumber(this.stepRange) || isDecimalNumber(this.minNumber)) {
279
+ const stepDecimal = countDecimalPlace(this.stepRange);
280
+ const minDecimal = countDecimalPlace(this.minNumber);
281
+ return stepDecimal > minDecimal ? stepDecimal : minDecimal;
282
+ }
283
+ return 0;
284
+ }
331
285
  /**
332
286
  * Return hide/show input field state
333
287
  * @returns {boolean} true if showInputField value is exist
@@ -342,62 +296,61 @@ let Slider = class Slider extends ControlElement {
342
296
  */
343
297
  firstUpdated(changedProperties) {
344
298
  super.firstUpdated(changedProperties);
345
- // initialize slider
346
- void this.updateComplete.then(() => {
347
- this.initializeProperty();
348
- this.initSlider();
349
- this.updateEventListeners();
350
- });
299
+ this.prepareValues();
300
+ this.prepareThumbs();
301
+ this.prepareSliderTrack();
351
302
  }
352
303
  /**
353
- * On Update lifecycle
304
+ * On willUpdate lifecycle
354
305
  * @param changedProperties changed properties
355
306
  * @returns {void}
356
307
  */
357
- update(changedProperties) {
358
- super.update(changedProperties);
359
- if (changedProperties.has('disabled') || changedProperties.has('readonly')) {
360
- this.updateEventListeners();
361
- }
362
- changedProperties.forEach((oldValue, propName) => {
363
- if (['value', 'min', 'max', 'from', 'to', 'step', 'minRange'].includes(propName)) {
364
- this.showWarningInvalidProperty(propName);
308
+ willUpdate(changedProperties) {
309
+ super.willUpdate(changedProperties);
310
+ if ((changedProperties.has('disabled') && changedProperties.get('disabled') !== undefined)
311
+ || (changedProperties.has('readonly') && changedProperties.get('readonly') !== undefined)) {
312
+ this.prepareSliderTrack();
313
+ }
314
+ changedProperties.forEach((_, changedProperty) => {
315
+ if (['value', 'min', 'max', 'from', 'to', 'step', 'minRange'].includes(changedProperty)) {
316
+ this.showWarningInvalidProperty(changedProperty);
365
317
  }
366
318
  });
367
319
  }
368
320
  /**
321
+ * On updated lifecycle
369
322
  * @param changedProperties changed properties
370
323
  * @returns {void}
371
324
  */
372
325
  updated(changedProperties) {
373
326
  super.updated(changedProperties);
374
- changedProperties.forEach((oldValue, propName) => {
375
- if (propName === 'value') {
376
- this.onValueChange();
377
- }
378
- else if (propName === 'min') {
379
- this.onMinChange(oldValue);
380
- }
381
- else if (propName === 'max') {
382
- this.onMaxChange(oldValue);
383
- }
384
- else if (propName === 'from' && this.range) {
385
- this.onValueChangeFrom();
386
- }
387
- else if (propName === 'to' && this.range) {
388
- this.onValueChangeTo();
389
- }
390
- else if (propName === 'step') {
391
- this.onStepChange();
392
- }
393
- else if (propName === 'minRange') {
394
- this.onMinRangeChange();
327
+ if (changedProperties.has('value')) {
328
+ this.onValueChange();
329
+ }
330
+ if (changedProperties.has('min')) {
331
+ this.onMinChange(changedProperties.get('min'));
332
+ }
333
+ if (changedProperties.has('max')) {
334
+ this.onMaxChange(changedProperties.get('max'));
335
+ }
336
+ if (this.range) {
337
+ if (changedProperties.has('from')) {
338
+ this.onFromValueChange();
395
339
  }
396
- else if (propName === 'range') {
397
- this.initializeProperty();
398
- this.initSlider();
340
+ if (changedProperties.has('to')) {
341
+ this.onToValueChange();
399
342
  }
400
- });
343
+ }
344
+ if (changedProperties.has('step')) {
345
+ this.onStepChange();
346
+ }
347
+ if (changedProperties.has('minRange')) {
348
+ this.onMinRangeChange();
349
+ }
350
+ if (changedProperties.has('range')) {
351
+ this.prepareValues();
352
+ this.prepareThumbs();
353
+ }
401
354
  }
402
355
  /**
403
356
  * Show Warning a warning message invalid property
@@ -442,16 +395,13 @@ let Slider = class Slider extends ControlElement {
442
395
  }
443
396
  }
444
397
  /**
445
- * Initialise class properties
398
+ * Initialises slider value properties
446
399
  * @returns {void}
447
400
  */
448
- initializeProperty() {
449
- this.stepUse = this.calculateStepRange(this.stepNumber);
401
+ prepareValues() {
450
402
  if (this.minNumber !== this.maxNumber) {
451
- // init decimal places
452
- this.updateDecimalPlaces();
453
403
  if (this.range) {
454
- this.activeThumb = this.dragElements[1];
404
+ this.activeThumb = this.thumbs[1];
455
405
  if (this.minRangeNumber) {
456
406
  const distanceFromTo = Math.abs(this.toNumber - this.fromNumber);
457
407
  const clampValueFrom = this.toNumber - this.minRangeNumber;
@@ -480,122 +430,83 @@ let Slider = class Slider extends ControlElement {
480
430
  else {
481
431
  this.value = this.min;
482
432
  }
483
- // initial old value
484
433
  this.valuePrevious = this.value;
485
434
  this.toPrevious = this.to;
486
435
  this.fromPrevious = this.from;
487
436
  }
488
437
  /**
489
- * Initialise slider properties
438
+ * Query and assigned thumbs depending on slider mode and add event listeners to it
490
439
  * @returns {void}
491
440
  */
492
- initSlider() {
493
- var _a;
494
- this.dragElements = [];
495
- if (this.range) {
496
- (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('#thumbContainer').forEach((item) => {
497
- this.dragElements.push(item);
498
- });
499
- }
500
- else {
501
- this.dragElements = [
502
- this.thumbContainer
503
- ];
504
- }
505
- this.activeThumb = this.dragElements[0];
506
- this.dragElements.concat(this).forEach((el) => {
507
- el.addEventListener('drag', preventDefault);
508
- el.addEventListener('dragstart', preventDefault);
509
- el.addEventListener('dragend', preventDefault);
441
+ prepareThumbs() {
442
+ this.thumbs = [];
443
+ const thumbs = this.shadowRoot?.querySelectorAll('[part~=thumb-container]') || [];
444
+ this.thumbs = this.range ? Array.from(thumbs) : [thumbs[0]];
445
+ this.activeThumb = this.thumbs[0];
446
+ this.thumbs.forEach((thumb) => {
447
+ thumb.addEventListener('drag', preventDefault);
448
+ thumb.addEventListener('dragstart', preventDefault);
449
+ thumb.addEventListener('dragend', preventDefault);
510
450
  });
511
- this.isEventReady = true;
512
451
  }
513
452
  /**
514
- * Calculate step in range
515
- * @param step value step for calculate
516
- * @returns step value that should be inside the min / max boundary
517
- */
518
- calculateStepRange(step) {
519
- const newStep = Math.abs(step);
520
- if (newStep > this.maxNumber - this.minNumber && !this.isDecimalNumber(newStep)) {
521
- // new step shouldn't be larger than slider
522
- return Math.abs(this.maxNumber - this.minNumber);
523
- }
524
- return newStep;
525
- }
526
- /**
527
- * Check if step or min number is decimal
528
- * If yes, set number of decimal places
453
+ * Add or remove event listener on slider track depending on slider disabled and readonly state
529
454
  * @returns {void}
530
455
  */
531
- updateDecimalPlaces() {
532
- // Set decimal places when step or min have decimal
533
- if (this.isDecimalNumber(this.stepUse) || this.isDecimalNumber(this.minNumber)) {
534
- const stepUseDecimal = this.countDecimals(this.stepUse);
535
- const minDecimal = this.countDecimals(this.minNumber);
536
- this.decimalPlaces = stepUseDecimal > minDecimal ? stepUseDecimal : minDecimal;
456
+ prepareSliderTrack() {
457
+ if (this.disabled || this.readonly) {
458
+ this.sliderRef.value?.removeEventListener('mousedown', this.onDragStart);
459
+ this.sliderRef.value?.removeEventListener('touchstart', this.onDragStart);
537
460
  }
538
461
  else {
539
- this.decimalPlaces = 0;
462
+ this.sliderRef.value?.addEventListener('mousedown', this.onDragStart, { passive: true });
463
+ this.sliderRef.value?.addEventListener('touchstart', this.onDragStart, { passive: true });
540
464
  }
541
465
  }
542
466
  /**
543
- * Count decimal number
544
- * @param value value for checking
545
- * @returns number of decimal points
546
- */
547
- countDecimals(value) {
548
- var _a;
549
- return ((_a = Number(value).toString().split('.')[1]) === null || _a === void 0 ? void 0 : _a.length) | 0;
550
- }
551
- /**
552
- * Check if decimal number e.g. 10.5, etc
553
- * @param value value for checking
554
- * @returns true if value is decimal
555
- */
556
- isDecimalNumber(value) {
557
- return value % 1 !== 0;
558
- }
559
- /**
560
- * Calculate percentage by value
467
+ * Calculate percentage from value, min and max
561
468
  * @param value value to be calculated
562
469
  * @returns percentage
563
470
  */
564
471
  calculatePercentage(value) {
565
- const valuePercent = Math.abs((((value || 0) - this.minNumber) / (this.maxNumber - this.minNumber)) * 100);
566
- if (valuePercent > 100) {
472
+ const percentage = Math.abs((((value || 0) - this.minNumber) / (this.maxNumber - this.minNumber)) * 100);
473
+ if (percentage > 100) {
567
474
  return 100;
568
475
  }
569
- else if (valuePercent < 0) {
476
+ else if (percentage < 0) {
570
477
  return 0;
571
478
  }
572
479
  else {
573
- return valuePercent;
480
+ return percentage;
574
481
  }
575
482
  }
576
483
  /**
577
- * Add and remove event listener when have disable and readonly properties
484
+ * Input number event blur and notify property
485
+ * @param event event blur input number field
578
486
  * @returns {void}
579
487
  */
580
- updateEventListeners() {
581
- if (this.isEventReady) {
582
- if (this.disabled || this.readonly) {
583
- this.slider.removeEventListener('mousedown', this.onDragStart);
584
- this.slider.removeEventListener('touchstart', this.onDragStart);
585
- }
586
- else {
587
- this.slider.addEventListener('mousedown', this.onDragStart, { passive: true });
588
- this.slider.addEventListener('touchstart', this.onDragStart, { passive: true });
589
- }
488
+ onBlur(event) {
489
+ if (this.readonly) {
490
+ return;
590
491
  }
492
+ const { value, name } = event.target;
493
+ const currentData = name;
494
+ const previousData = `${name}Previous`;
495
+ if (value && this[currentData] !== value) {
496
+ this.updateNotifyProperty(currentData, value);
497
+ this[previousData] = value;
498
+ }
499
+ event.preventDefault();
591
500
  }
592
501
  /**
593
- * Handles key press keyboard events
594
- *
595
- * @param event Event Object
502
+ * Input number event keydown y
503
+ * @param event event keydown
596
504
  * @returns {void}
597
505
  */
598
- handleEnterKey(event) {
506
+ onKeydown(event) {
507
+ if (this.readonly || this.disabled) {
508
+ return;
509
+ }
599
510
  if (event.key === ' ' || event.key === 'Spacebar' || event.key === 'Enter') {
600
511
  event.target.blur();
601
512
  }
@@ -607,21 +518,21 @@ let Slider = class Slider extends ControlElement {
607
518
  * @returns {void}
608
519
  */
609
520
  updateNotifyProperty(name, value) {
610
- let isUpdateValue = false;
611
- const valueSanitize = Number(this.sanitizeNumber(Number(value), 0));
521
+ let shouldUpdate = false;
522
+ const validatedValue = Number(validateNumber(Number(value), 0));
612
523
  if (name === 'to') {
613
- isUpdateValue = this.isValueInBoundary(valueSanitize, 'to');
524
+ shouldUpdate = this.isValueInBoundary(validatedValue, 'to');
614
525
  }
615
526
  else {
616
- isUpdateValue = this.isValueInBoundary(valueSanitize, '');
527
+ shouldUpdate = this.isValueInBoundary(validatedValue, '');
617
528
  }
618
- if (isUpdateValue) {
529
+ if (shouldUpdate) {
619
530
  (this[name]) = value;
620
531
  this.notifyPropertyChange(name, value);
621
532
  }
622
533
  else {
623
- const nameInput = `${name}Input`;
624
- this[nameInput].value = this[name];
534
+ const inputName = `${name}Input`;
535
+ this[inputName].value = this[name];
625
536
  }
626
537
  }
627
538
  /**
@@ -640,8 +551,8 @@ let Slider = class Slider extends ControlElement {
640
551
  }
641
552
  /**
642
553
  * Set focus to input from state
643
- * @param {String} name number field's name
644
- * @param {Boolean} focusState state of focus
554
+ * @param name number field's name
555
+ * @param focusState state of focus
645
556
  * @returns {void}
646
557
  */
647
558
  toggleFocusField(name, focusState) {
@@ -649,12 +560,56 @@ let Slider = class Slider extends ControlElement {
649
560
  this[`${name}Input`].setAttribute('tabindex', `${focusState ? 1 : 0}`);
650
561
  }
651
562
  }
563
+ /**
564
+ * Start dragging event on slider
565
+ * @param event event dragstart
566
+ * @returns {void}
567
+ */
568
+ onDragStart(event) {
569
+ this.dragging = true;
570
+ this.classList.add('grabbable');
571
+ if (this.range) {
572
+ const percentage = this.getMousePosition(event);
573
+ const mousePosition = ((this.maxNumber - this.minNumber) * percentage) + this.minNumber;
574
+ const distanceFrom = Math.abs(mousePosition - this.fromNumber);
575
+ const distanceTo = Math.abs(mousePosition - this.toNumber);
576
+ if (distanceFrom < distanceTo) {
577
+ this.activeThumb = this.thumbs[0];
578
+ }
579
+ else if (distanceFrom > distanceTo) {
580
+ this.activeThumb = this.thumbs[1];
581
+ }
582
+ this.thumbs.forEach((el) => {
583
+ el.style.zIndex = '5';
584
+ });
585
+ this.activeThumb.style.zIndex = '10';
586
+ // Set focus to input when drag.
587
+ if (this.isShowInputField) {
588
+ this.toggleFocusField(this.activeThumb.getAttribute('name') || '', true);
589
+ }
590
+ }
591
+ else {
592
+ this.activeThumb = this.thumbs[0];
593
+ }
594
+ this.onDrag(event);
595
+ if (event.changedTouches) {
596
+ this.addEventListener('touchmove', this.onDrag);
597
+ this.addEventListener('touchend', this.onDragEnd);
598
+ }
599
+ else {
600
+ window.addEventListener('mousemove', this.onDrag);
601
+ window.addEventListener('mouseup', this.onDragEnd);
602
+ }
603
+ }
652
604
  /**
653
605
  * @param event event mousemove and touchmove
654
606
  * @returns mouse position by percentage
655
607
  */
656
608
  getMousePosition(event) {
657
- const sliderRect = this.trackWrapper.getBoundingClientRect();
609
+ const sliderRect = this.trackRef.value?.getBoundingClientRect();
610
+ if (!sliderRect) {
611
+ return 1;
612
+ }
658
613
  // check drag desktop or mobile
659
614
  const pageX = event.changedTouches ? event.changedTouches[0].pageX : event.pageX;
660
615
  const positionSize = pageX - sliderRect.left;
@@ -665,6 +620,35 @@ let Slider = class Slider extends ControlElement {
665
620
  return 1;
666
621
  }
667
622
  }
623
+ /**
624
+ * Dragging after on dragging start event
625
+ * @param event event mousemove and touchmove
626
+ * @returns {void}
627
+ */
628
+ onDrag(event) {
629
+ if (this.minNumber === this.maxNumber) {
630
+ return;
631
+ }
632
+ const thumbPosition = this.getMousePosition(event);
633
+ const nearestStep = this.calculateStep(thumbPosition);
634
+ if (nearestStep > 1) {
635
+ return;
636
+ }
637
+ const thumbLeft = this.stepRange !== 0 ? nearestStep : thumbPosition;
638
+ const computedStepValue = this.calculateValue(thumbLeft);
639
+ const displayedValue = Number(this.displayValue(computedStepValue));
640
+ if (this.range) {
641
+ if (this.activeThumb === this.thumbs[1]) {
642
+ this.to = this.validateTo(displayedValue).toString();
643
+ }
644
+ else {
645
+ this.from = this.validateFrom(displayedValue).toString();
646
+ }
647
+ }
648
+ else {
649
+ this.value = displayedValue.toString();
650
+ }
651
+ }
668
652
  /**
669
653
  * Handle 'from' value on drag out of boundary.
670
654
  * @param value value from change
@@ -694,12 +678,12 @@ let Slider = class Slider extends ControlElement {
694
678
  }
695
679
  }
696
680
  /**
697
- * Calculate the nearest interval
681
+ * Calculate the nearest step interval
698
682
  * @param thumbPosition thumb position dragging on slider
699
683
  * @returns position step on slider
700
684
  */
701
685
  calculateStep(thumbPosition) {
702
- const stepSize = this.calculatePercentage(this.minNumber + this.stepUse) / 100;
686
+ const stepSize = this.calculatePercentage(this.minNumber + this.stepRange) / 100;
703
687
  // calculate step to current point to next point
704
688
  const posToFixStep = Math.round(thumbPosition / stepSize) * stepSize;
705
689
  if (thumbPosition <= posToFixStep + (stepSize / 2)) {
@@ -738,11 +722,11 @@ let Slider = class Slider extends ControlElement {
738
722
  * @returns formatted value
739
723
  */
740
724
  displayValue(value) {
741
- if (this.isDecimalNumber(value)) {
742
- const valueDecimalCount = this.countDecimals(value);
725
+ if (isDecimalNumber(value)) {
726
+ const valueDecimalCount = countDecimalPlace(value);
743
727
  // return value decimal by a boundary of max decimal
744
- if (valueDecimalCount > this.decimalPlaces) {
745
- return value.toFixed(this.decimalPlaces);
728
+ if (valueDecimalCount > this.decimalPlace) {
729
+ return value.toFixed(this.decimalPlace);
746
730
  }
747
731
  else {
748
732
  return value.toString();
@@ -752,6 +736,37 @@ let Slider = class Slider extends ControlElement {
752
736
  return value.toString();
753
737
  }
754
738
  }
739
+ /**
740
+ * End dragging event and remove dragging event
741
+ * @param event event mouseup and touchmove
742
+ * @returns {void}
743
+ */
744
+ onDragEnd(event) {
745
+ if (this.dragging) {
746
+ this.dragging = false;
747
+ const touchEvent = event;
748
+ if (touchEvent.changedTouches) {
749
+ this.removeEventListener('touchmove', this.onDrag);
750
+ this.removeEventListener('touchend', this.onDragEnd);
751
+ }
752
+ else {
753
+ window.removeEventListener('mousemove', this.onDrag);
754
+ window.removeEventListener('mouseup', this.onDragEnd);
755
+ }
756
+ this.classList.remove('grabbable');
757
+ if (this.classList.length === 0) {
758
+ this.removeAttribute('class');
759
+ }
760
+ if (!touchEvent.changedTouches) {
761
+ event.preventDefault();
762
+ }
763
+ this.dispatchDataChangedEvent();
764
+ // Reset tabIndex of input that's being drag.
765
+ if (this.isShowInputField) {
766
+ this.toggleFocusField(this.activeThumb.getAttribute('name') || '', false);
767
+ }
768
+ }
769
+ }
755
770
  /**
756
771
  * Value observer
757
772
  * @returns {void}
@@ -760,12 +775,12 @@ let Slider = class Slider extends ControlElement {
760
775
  if (this.readonly) {
761
776
  const valuePercent = this.calculatePercentage(Number(this.value)) / 100;
762
777
  const closestStep = this.calculateStep(valuePercent);
763
- const thumbLeft = this.stepUse !== 0 ? closestStep : valuePercent;
778
+ const thumbLeft = this.stepRange !== 0 ? closestStep : valuePercent;
764
779
  const calStepValue = this.calculateValue(thumbLeft);
765
780
  this.value = this.displayValue(calStepValue);
766
781
  }
767
782
  else {
768
- const valueSanitize = Number(this.sanitizeNumber(Number(this.value), 0));
783
+ const valueSanitize = Number(validateNumber(Number(this.value), 0));
769
784
  if (this.isValueInBoundary(valueSanitize, '')) {
770
785
  this.value = this.displayValue(valueSanitize);
771
786
  }
@@ -788,8 +803,8 @@ let Slider = class Slider extends ControlElement {
788
803
  * From value observer
789
804
  * @returns {void}
790
805
  */
791
- onValueChangeFrom() {
792
- const valueFrom = Number(this.sanitizeNumber(this.fromNumber, 0));
806
+ onFromValueChange() {
807
+ const valueFrom = Number(validateNumber(this.fromNumber, 0));
793
808
  if (this.isValueInBoundary(valueFrom, 'from')) {
794
809
  this.from = this.displayValue(this.fromNumber);
795
810
  }
@@ -813,30 +828,6 @@ let Slider = class Slider extends ControlElement {
813
828
  this.fromPrevious = this.from;
814
829
  }
815
830
  }
816
- /**
817
- * Return fallback number of the value is invalid
818
- * @param value value for checking
819
- * @param fallbackValue fallback value when value is not number;
820
- * @returns sanitized number
821
- */
822
- sanitizeNumber(value, fallbackValue) {
823
- let val;
824
- if (this.isNumberValue(value) && typeof value === 'number') {
825
- val = value.toString();
826
- }
827
- else {
828
- val = fallbackValue;
829
- }
830
- return val.toString();
831
- }
832
- /**
833
- * Check if value is number
834
- * @param value value for checking
835
- * @returns true if value is numeric
836
- */
837
- isNumberValue(value) {
838
- return !isNaN(value) && !isNaN(Number(value));
839
- }
840
831
  /**
841
832
  * Check if value is inside min / max boundary
842
833
  * @param value value is checking
@@ -860,7 +851,7 @@ let Slider = class Slider extends ControlElement {
860
851
  return false;
861
852
  }
862
853
  // check step min and max in range
863
- if (this.stepUse < this.minNumber || this.stepUse > this.maxNumber) {
854
+ if (this.stepRange < this.minNumber || this.stepRange > this.maxNumber) {
864
855
  return true;
865
856
  }
866
857
  }
@@ -870,8 +861,8 @@ let Slider = class Slider extends ControlElement {
870
861
  * To value observer
871
862
  * @returns {void}
872
863
  */
873
- onValueChangeTo() {
874
- const valueTo = Number(this.sanitizeNumber(this.toNumber, 0));
864
+ onToValueChange() {
865
+ const valueTo = Number(validateNumber(this.toNumber, 0));
875
866
  if (this.isValueInBoundary(valueTo, 'to')) {
876
867
  this.to = this.displayValue(valueTo);
877
868
  }
@@ -900,17 +891,14 @@ let Slider = class Slider extends ControlElement {
900
891
  * @returns {void}
901
892
  */
902
893
  onStepChange() {
903
- this.step = this.sanitizeNumber(this.stepNumber, 1);
904
- this.stepUse = this.calculateStepRange(this.stepNumber);
905
- // Set decimal places value when step is decimal
906
- this.updateDecimalPlaces();
894
+ this.step = validateNumber(this.stepNumber, 1);
907
895
  }
908
896
  /**
909
897
  * Min range observer
910
898
  * @returns {void}
911
899
  */
912
900
  onMinRangeChange() {
913
- const valueMinRange = Math.abs(Number(this.sanitizeNumber(this.minRangeNumber, 0)));
901
+ const valueMinRange = Math.abs(Number(validateNumber(this.minRangeNumber, 0)));
914
902
  const maximumRangeMinMax = Math.abs(this.maxNumber - this.minNumber);
915
903
  const maximumRangeFromTo = Math.abs(this.toNumber - this.fromNumber);
916
904
  if (valueMinRange && valueMinRange >= this.stepNumber) {
@@ -934,9 +922,7 @@ let Slider = class Slider extends ControlElement {
934
922
  * @returns {void}
935
923
  */
936
924
  onMinChange(oldValue) {
937
- this.min = this.sanitizeNumber(this.minNumber, 0);
938
- // Set decimal places value when min is decimal
939
- this.updateDecimalPlaces();
925
+ this.min = validateNumber(this.minNumber, 0);
940
926
  if (this.minNumber > this.maxNumber) {
941
927
  this.min = this.max;
942
928
  }
@@ -958,7 +944,7 @@ let Slider = class Slider extends ControlElement {
958
944
  * @returns {void}
959
945
  */
960
946
  onMaxChange(oldValue) {
961
- this.max = this.sanitizeNumber(this.maxNumber, 100);
947
+ this.max = validateNumber(this.maxNumber, 100);
962
948
  if (this.maxNumber < this.minNumber) {
963
949
  this.max = this.min;
964
950
  }
@@ -979,7 +965,7 @@ let Slider = class Slider extends ControlElement {
979
965
  * @param range show range slider
980
966
  * @returns Track template
981
967
  */
982
- renderTrackWrapper(range) {
968
+ renderTrack(range) {
983
969
  const stepContainerSize = this.calculatePercentage(this.minNumber + this.stepNumber);
984
970
  const translateX = (stepContainerSize / 2);
985
971
  const stepsStyle = { transform: `translateX(${translateX}%)`, backgroundSize: `${stepContainerSize}% 100%` };
@@ -988,12 +974,12 @@ let Slider = class Slider extends ControlElement {
988
974
  ? { width: `${this.calculatePercentage(this.toNumber) - this.calculatePercentage(this.fromNumber)}%`, left: `${this.calculatePercentage(this.fromNumber)}%` }
989
975
  : { width: `${this.calculatePercentage(Number(this.value))}%` };
990
976
  return html `
991
- <div part="track-wrapper" id="trackWrapper">
992
- <div part="track-fill" id="trackFill" style=${styleMap(trackFillStyle)}></div>
993
- <div part="step-container" id="stepContainer" style=${styleMap(stepContainerStyle)}>
994
- <div part="step" id="steps" style=${styleMap(stepsStyle)}></div>
977
+ <div part="track-wrapper" ${ref(this.trackRef)}>
978
+ <div part="track-fill" style=${styleMap(trackFillStyle)}></div>
979
+ <div part="step-container" style=${styleMap(stepContainerStyle)}>
980
+ <div part="step" style=${styleMap(stepsStyle)}></div>
981
+ </div>
995
982
  </div>
996
- </div>
997
983
  `;
998
984
  }
999
985
  /**
@@ -1006,11 +992,12 @@ let Slider = class Slider extends ControlElement {
1006
992
  renderThumb(value, percentageValue, name) {
1007
993
  const thumbStyle = { left: `${percentageValue}%` };
1008
994
  return html `
1009
- <div part="thumb-container" name=${name} id="thumbContainer" style=${styleMap(thumbStyle)}>
1010
- <div part="pin">
1011
- <span id="pinMarker" part="pin-value-marker">${value}</span></div>
1012
- <div part="thumb" draggable="true" id="thumb"></div>
1013
- </div>
995
+ <div part="thumb-container" name=${name} style=${styleMap(thumbStyle)}>
996
+ <div part="pin">
997
+ <span part="pin-value-marker">${value}</span>
998
+ </div>
999
+ <div part="thumb" draggable="true"></div>
1000
+ </div>
1014
1001
  `;
1015
1002
  }
1016
1003
  /**
@@ -1035,92 +1022,19 @@ let Slider = class Slider extends ControlElement {
1035
1022
  */
1036
1023
  renderNumberField(value, name) {
1037
1024
  return html `
1038
- <ef-number-field
1039
- @blur=${this.onBlur}
1040
- @keydown=${this.onKeydown}
1041
- part="input"
1042
- name="${name}"
1043
- no-spinner
1044
- .value="${value}"
1045
- min="${this.min}"
1046
- max="${this.max}"
1047
- step="${this.step}"
1048
- ?disabled="${this.disabled}"
1049
- ?readonly="${this.readonly || this.showInputField === 'readonly'}"
1050
- ></ef-number-field>
1051
- `;
1052
- }
1053
- /**
1054
- * Define styles in a tagged template literal, using the css tag function.
1055
- * @returns CSS template
1056
- */
1057
- static get styles() {
1058
- return css `
1059
- :host {
1060
- display: flex;
1061
- }
1062
- [part=slider-wrapper] {
1063
- position: relative;
1064
- width: 100%;
1065
- }
1066
- [part=slider] {
1067
- width: 100%;
1068
- height: 100%;
1069
- display: inline-block;
1070
- }
1071
- :host(:not([disabled]):focus){
1072
- outline:none;
1073
- }
1074
- :host([show-steps]) [part=track-wrapper]::after {
1075
- display:block;
1076
- position: absolute;
1077
- content: "";
1078
- right: 0;
1079
- }
1080
- [part=track-wrapper]{
1081
- content: "";
1082
- position: absolute;
1083
- width: 100%;
1084
- top: 50%;
1085
- left: 0;
1086
- pointer-events: none;
1087
- }
1088
- [part=thumb-container]{
1089
- position: absolute;
1090
- top: 0;
1091
- width: 100%;
1092
- z-index: 5;
1093
- }
1094
- [part=thumb]{
1095
- position: absolute;
1096
- margin: 0 auto;
1097
- }
1098
- [part=pin]{
1099
- display: flex;
1100
- position: absolute;
1101
- align-items: center;
1102
- justify-content: center;
1103
- z-index: 1;
1104
- }
1105
- :host([show-steps]) [part=step-container]{
1106
- position: absolute;
1107
- left: 0;
1108
- width: 100%;
1109
- }
1110
- :host([show-steps]) [part=step]{
1111
- width: 100%;
1112
- position: absolute;
1113
- left: 0;
1114
- }
1115
- [part=track-fill]{
1116
- z-index: 2;
1117
- content: "";
1118
- position: absolute;
1119
- left: 0;
1120
- }
1121
- :host([show-steps][step="0"]) [part=track-wrapper]::after{
1122
- width: 0;
1123
- }
1025
+ <ef-number-field
1026
+ @blur=${this.onBlur}
1027
+ @keydown=${this.onKeydown}
1028
+ part="input"
1029
+ name="${name}"
1030
+ no-spinner
1031
+ .value="${value}"
1032
+ min="${this.min}"
1033
+ max="${this.max}"
1034
+ step="${this.step}"
1035
+ ?disabled="${this.disabled}"
1036
+ ?readonly="${this.readonly || this.showInputField === 'readonly'}"
1037
+ ></ef-number-field>
1124
1038
  `;
1125
1039
  }
1126
1040
  /**
@@ -1131,8 +1045,8 @@ let Slider = class Slider extends ControlElement {
1131
1045
  return html `
1132
1046
  ${this.range && this.isShowInputField ? this.renderNumberField(this.from, 'from') : null}
1133
1047
  <div part="slider-wrapper">
1134
- <div part="slider">
1135
- ${this.renderTrackWrapper(this.range)}
1048
+ <div part="slider" ${ref(this.sliderRef)}>
1049
+ ${this.renderTrack(this.range)}
1136
1050
  ${this.range ? this.renderThumbRange(this.fromNumber, this.toNumber) : this.renderThumb(this.valueNumber, this.calculatePercentage(Number(this.value)), 'value')}
1137
1051
  </div>
1138
1052
  </div>
@@ -1171,15 +1085,6 @@ __decorate([
1171
1085
  __decorate([
1172
1086
  property({ type: String, attribute: 'min-range' })
1173
1087
  ], Slider.prototype, "minRange", void 0);
1174
- __decorate([
1175
- query('[part="slider"]')
1176
- ], Slider.prototype, "slider", void 0);
1177
- __decorate([
1178
- query('#trackWrapper')
1179
- ], Slider.prototype, "trackWrapper", void 0);
1180
- __decorate([
1181
- query('#thumbContainer')
1182
- ], Slider.prototype, "thumbContainer", void 0);
1183
1088
  __decorate([
1184
1089
  query('ef-number-field[name=value]')
1185
1090
  ], Slider.prototype, "valueInput", void 0);