@refinitiv-ui/elements 5.0.0-beta.3 → 5.0.0-dev.204

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 (596) hide show
  1. package/CHANGELOG.md +325 -73
  2. package/README.md +13 -2
  3. package/lib/accordion/custom-elements.json +0 -13
  4. package/lib/accordion/custom-elements.md +18 -0
  5. package/lib/accordion/index.d.ts +13 -10
  6. package/lib/accordion/index.js +15 -18
  7. package/lib/appstate-bar/custom-elements.json +1 -1
  8. package/lib/appstate-bar/custom-elements.md +22 -0
  9. package/lib/appstate-bar/index.d.ts +15 -6
  10. package/lib/appstate-bar/index.js +17 -11
  11. package/lib/autosuggest/custom-elements.json +24 -4
  12. package/lib/autosuggest/custom-elements.md +54 -0
  13. package/lib/autosuggest/helpers/types.d.ts +22 -1
  14. package/lib/autosuggest/helpers/types.js +0 -1
  15. package/lib/autosuggest/helpers/utils.d.ts +2 -2
  16. package/lib/autosuggest/helpers/utils.js +1 -3
  17. package/lib/autosuggest/index.d.ts +21 -9
  18. package/lib/autosuggest/index.js +45 -31
  19. package/lib/button/custom-elements.json +3 -3
  20. package/lib/button/custom-elements.md +23 -0
  21. package/lib/button/index.d.ts +27 -20
  22. package/lib/button/index.js +92 -74
  23. package/lib/button/themes/halo/dark/index.js +1 -1
  24. package/lib/button/themes/halo/light/index.js +1 -1
  25. package/lib/button/themes/solar/charcoal/index.js +1 -1
  26. package/lib/button/themes/solar/pearl/index.js +1 -1
  27. package/lib/button-bar/custom-elements.md +9 -0
  28. package/lib/button-bar/index.d.ts +60 -4
  29. package/lib/button-bar/index.js +164 -19
  30. package/lib/calendar/constants.d.ts +26 -0
  31. package/lib/calendar/constants.js +28 -0
  32. package/lib/calendar/custom-elements.json +8 -6
  33. package/lib/calendar/custom-elements.md +35 -0
  34. package/lib/calendar/index.d.ts +119 -21
  35. package/lib/calendar/index.js +512 -157
  36. package/lib/calendar/locales.d.ts +1 -31
  37. package/lib/calendar/locales.js +3 -107
  38. package/lib/calendar/themes/halo/dark/index.js +1 -1
  39. package/lib/calendar/themes/halo/light/index.js +1 -1
  40. package/lib/calendar/themes/solar/charcoal/index.js +1 -1
  41. package/lib/calendar/themes/solar/pearl/index.js +1 -1
  42. package/lib/calendar/types.d.ts +12 -13
  43. package/lib/calendar/types.js +1 -7
  44. package/lib/calendar/utils.d.ts +31 -1
  45. package/lib/calendar/utils.js +105 -3
  46. package/lib/canvas/custom-elements.json +9 -7
  47. package/lib/canvas/custom-elements.md +27 -0
  48. package/lib/canvas/index.d.ts +14 -6
  49. package/lib/canvas/index.js +17 -12
  50. package/lib/card/custom-elements.json +21 -9
  51. package/lib/card/custom-elements.md +24 -0
  52. package/lib/card/helpers/types.d.ts +1 -1
  53. package/lib/card/helpers/types.js +0 -1
  54. package/lib/card/index.d.ts +67 -20
  55. package/lib/card/index.js +132 -35
  56. package/lib/card/themes/halo/dark/index.js +1 -1
  57. package/lib/card/themes/halo/light/index.js +1 -1
  58. package/lib/card/themes/solar/charcoal/index.js +1 -1
  59. package/lib/card/themes/solar/pearl/index.js +1 -1
  60. package/lib/chart/custom-elements.json +3 -3
  61. package/lib/chart/custom-elements.md +16 -0
  62. package/lib/chart/helpers/index.d.ts +2 -0
  63. package/lib/chart/helpers/index.js +2 -0
  64. package/lib/chart/helpers/legend.d.ts +2 -2
  65. package/lib/chart/helpers/legend.js +2 -3
  66. package/lib/chart/helpers/merge.d.ts +15 -0
  67. package/lib/chart/helpers/merge.js +28 -0
  68. package/lib/chart/helpers/types.d.ts +40 -12
  69. package/lib/chart/helpers/types.js +0 -1
  70. package/lib/chart/index.d.ts +34 -26
  71. package/lib/chart/index.js +58 -55
  72. package/lib/chart/plugins/doughnut-center-label.js +4 -5
  73. package/lib/checkbox/custom-elements.json +4 -4
  74. package/lib/checkbox/custom-elements.md +18 -0
  75. package/lib/checkbox/index.d.ts +29 -14
  76. package/lib/checkbox/index.js +65 -34
  77. package/lib/checkbox/themes/halo/dark/index.js +1 -1
  78. package/lib/checkbox/themes/halo/light/index.js +1 -1
  79. package/lib/clock/custom-elements.json +21 -4
  80. package/lib/clock/custom-elements.md +28 -0
  81. package/lib/clock/index.d.ts +25 -6
  82. package/lib/clock/index.js +44 -18
  83. package/lib/clock/themes/halo/dark/index.js +1 -1
  84. package/lib/clock/themes/halo/light/index.js +1 -1
  85. package/lib/clock/themes/solar/charcoal/index.js +1 -1
  86. package/lib/clock/themes/solar/pearl/index.js +1 -1
  87. package/lib/clock/utils/TickManager.js +2 -3
  88. package/lib/clock/utils/timestamps.js +0 -1
  89. package/lib/collapse/custom-elements.md +27 -0
  90. package/lib/collapse/index.d.ts +15 -8
  91. package/lib/collapse/index.js +18 -13
  92. package/lib/color-dialog/custom-elements.json +29 -16
  93. package/lib/color-dialog/custom-elements.md +39 -0
  94. package/lib/color-dialog/elements/color-palettes.d.ts +13 -6
  95. package/lib/color-dialog/elements/color-palettes.js +16 -13
  96. package/lib/color-dialog/elements/grayscale-palettes.d.ts +13 -6
  97. package/lib/color-dialog/elements/grayscale-palettes.js +17 -13
  98. package/lib/color-dialog/elements/palettes.d.ts +15 -3
  99. package/lib/color-dialog/elements/palettes.js +65 -45
  100. package/lib/color-dialog/helpers/color-helpers.d.ts +7 -53
  101. package/lib/color-dialog/helpers/color-helpers.js +12 -110
  102. package/lib/color-dialog/helpers/value-model.d.ts +1 -1
  103. package/lib/color-dialog/helpers/value-model.js +18 -17
  104. package/lib/color-dialog/index.d.ts +27 -20
  105. package/lib/color-dialog/index.js +54 -45
  106. package/lib/combo-box/custom-elements.json +51 -17
  107. package/lib/combo-box/custom-elements.md +42 -0
  108. package/lib/combo-box/helpers/filter.d.ts +4 -4
  109. package/lib/combo-box/helpers/filter.js +0 -1
  110. package/lib/combo-box/helpers/keyboard-event.js +0 -1
  111. package/lib/combo-box/helpers/renderer.d.ts +8 -0
  112. package/lib/combo-box/helpers/renderer.js +24 -0
  113. package/lib/combo-box/helpers/types.d.ts +2 -2
  114. package/lib/combo-box/helpers/types.js +0 -1
  115. package/lib/combo-box/index.d.ts +63 -32
  116. package/lib/combo-box/index.js +102 -60
  117. package/lib/combo-box/themes/halo/dark/index.js +2 -3
  118. package/lib/combo-box/themes/halo/light/index.js +2 -3
  119. package/lib/combo-box/themes/solar/charcoal/index.js +2 -3
  120. package/lib/combo-box/themes/solar/pearl/index.js +2 -3
  121. package/lib/counter/custom-elements.json +39 -0
  122. package/lib/counter/custom-elements.md +11 -0
  123. package/lib/counter/index.d.ts +91 -0
  124. package/lib/counter/index.js +154 -0
  125. package/lib/counter/themes/halo/dark/index.js +3 -0
  126. package/lib/counter/themes/halo/light/index.js +3 -0
  127. package/lib/counter/themes/solar/charcoal/index.js +3 -0
  128. package/lib/counter/themes/solar/pearl/index.js +3 -0
  129. package/lib/counter/utils.d.ts +13 -0
  130. package/lib/counter/utils.js +52 -0
  131. package/lib/datetime-picker/custom-elements.json +53 -24
  132. package/lib/datetime-picker/custom-elements.md +57 -0
  133. package/lib/datetime-picker/index.d.ts +34 -16
  134. package/lib/datetime-picker/index.js +56 -38
  135. package/lib/datetime-picker/locales.d.ts +1 -1
  136. package/lib/datetime-picker/locales.js +12 -2
  137. package/lib/datetime-picker/themes/solar/charcoal/index.js +1 -1
  138. package/lib/datetime-picker/themes/solar/pearl/index.js +1 -1
  139. package/lib/datetime-picker/types.d.ts +1 -1
  140. package/lib/datetime-picker/types.js +0 -1
  141. package/lib/datetime-picker/utils.js +1 -2
  142. package/lib/dialog/custom-elements.json +34 -12
  143. package/lib/dialog/custom-elements.md +47 -0
  144. package/lib/dialog/draggable-element.js +25 -16
  145. package/lib/dialog/index.d.ts +25 -21
  146. package/lib/dialog/index.js +36 -32
  147. package/lib/email-field/custom-elements.json +81 -94
  148. package/lib/email-field/custom-elements.md +37 -0
  149. package/lib/email-field/index.d.ts +47 -112
  150. package/lib/email-field/index.js +48 -241
  151. package/lib/email-field/themes/halo/dark/index.js +1 -1
  152. package/lib/email-field/themes/halo/light/index.js +1 -1
  153. package/lib/email-field/themes/solar/charcoal/index.js +1 -1
  154. package/lib/email-field/themes/solar/pearl/index.js +1 -1
  155. package/lib/events.d.ts +121 -0
  156. package/lib/events.js +1 -0
  157. package/lib/flag/custom-elements.md +10 -0
  158. package/lib/flag/index.d.ts +14 -5
  159. package/lib/flag/index.js +19 -12
  160. package/lib/flag/utils/FlagLoader.d.ts +1 -1
  161. package/lib/flag/utils/FlagLoader.js +1 -2
  162. package/lib/header/custom-elements.md +18 -0
  163. package/lib/header/index.d.ts +10 -3
  164. package/lib/header/index.js +12 -8
  165. package/lib/heatmap/custom-elements.json +13 -0
  166. package/lib/heatmap/custom-elements.md +26 -0
  167. package/lib/heatmap/helpers/color.d.ts +1 -1
  168. package/lib/heatmap/helpers/color.js +1 -2
  169. package/lib/heatmap/helpers/text.d.ts +1 -1
  170. package/lib/heatmap/helpers/text.js +0 -1
  171. package/lib/heatmap/helpers/track.js +2 -3
  172. package/lib/heatmap/helpers/types.js +0 -1
  173. package/lib/heatmap/index.d.ts +32 -13
  174. package/lib/heatmap/index.js +61 -35
  175. package/lib/icon/custom-elements.json +6 -4
  176. package/lib/icon/custom-elements.md +8 -0
  177. package/lib/icon/index.d.ts +17 -7
  178. package/lib/icon/index.js +36 -18
  179. package/lib/icon/utils/IconLoader.d.ts +6 -1
  180. package/lib/icon/utils/IconLoader.js +24 -18
  181. package/lib/index.d.ts +2 -0
  182. package/lib/index.js +2 -1
  183. package/lib/interactive-chart/custom-elements.json +5 -11
  184. package/lib/interactive-chart/custom-elements.md +31 -0
  185. package/lib/interactive-chart/helpers/merge.d.ts +15 -0
  186. package/lib/interactive-chart/helpers/merge.js +28 -0
  187. package/lib/interactive-chart/helpers/types.d.ts +10 -9
  188. package/lib/interactive-chart/helpers/types.js +6 -2
  189. package/lib/interactive-chart/index.d.ts +37 -18
  190. package/lib/interactive-chart/index.js +61 -51
  191. package/lib/item/custom-elements.json +4 -4
  192. package/lib/item/custom-elements.md +29 -0
  193. package/lib/item/helpers/types.d.ts +1 -1
  194. package/lib/item/helpers/types.js +0 -1
  195. package/lib/item/index.d.ts +26 -9
  196. package/lib/item/index.js +43 -16
  197. package/lib/label/custom-elements.json +7 -16
  198. package/lib/label/custom-elements.md +11 -0
  199. package/lib/label/index.d.ts +41 -73
  200. package/lib/label/index.js +150 -187
  201. package/lib/layout/custom-elements.md +26 -0
  202. package/lib/layout/index.d.ts +11 -4
  203. package/lib/layout/index.js +13 -9
  204. package/lib/led-gauge/custom-elements.json +4 -4
  205. package/lib/led-gauge/custom-elements.md +17 -0
  206. package/lib/led-gauge/index.d.ts +13 -5
  207. package/lib/led-gauge/index.js +16 -11
  208. package/lib/list/custom-elements.json +37 -5
  209. package/lib/list/custom-elements.md +33 -0
  210. package/lib/list/extensible-function.js +2 -1
  211. package/lib/list/helpers/list-renderer.d.ts +2 -2
  212. package/lib/list/helpers/list-renderer.js +4 -3
  213. package/lib/list/helpers/types.d.ts +2 -2
  214. package/lib/list/helpers/types.js +0 -1
  215. package/lib/list/index.d.ts +47 -12
  216. package/lib/list/index.js +100 -39
  217. package/lib/list/renderer.d.ts +2 -2
  218. package/lib/list/renderer.js +1 -2
  219. package/lib/loader/custom-elements.md +5 -0
  220. package/lib/loader/index.d.ts +8 -1
  221. package/lib/loader/index.js +11 -8
  222. package/lib/multi-input/custom-elements.json +7 -6
  223. package/lib/multi-input/custom-elements.md +43 -0
  224. package/lib/multi-input/helpers/types.d.ts +1 -1
  225. package/lib/multi-input/helpers/types.js +0 -1
  226. package/lib/multi-input/index.d.ts +19 -8
  227. package/lib/multi-input/index.js +28 -18
  228. package/lib/multi-input/themes/solar/charcoal/index.js +1 -1
  229. package/lib/multi-input/themes/solar/pearl/index.js +1 -1
  230. package/lib/notification/custom-elements.md +26 -0
  231. package/lib/notification/elements/notification-tray.d.ts +10 -4
  232. package/lib/notification/elements/notification-tray.js +15 -11
  233. package/lib/notification/elements/notification.d.ts +19 -7
  234. package/lib/notification/elements/notification.js +25 -13
  235. package/lib/notification/helpers/status.d.ts +1 -1
  236. package/lib/notification/helpers/status.js +1 -2
  237. package/lib/notification/helpers/types.d.ts +1 -1
  238. package/lib/notification/helpers/types.js +0 -1
  239. package/lib/notification/index.d.ts +2 -2
  240. package/lib/notification/index.js +2 -3
  241. package/lib/number-field/custom-elements.json +99 -54
  242. package/lib/number-field/custom-elements.md +42 -0
  243. package/lib/number-field/index.d.ts +104 -52
  244. package/lib/number-field/index.js +129 -88
  245. package/lib/number-field/themes/halo/dark/index.js +1 -1
  246. package/lib/number-field/themes/halo/light/index.js +1 -1
  247. package/lib/number-field/themes/solar/charcoal/index.js +1 -1
  248. package/lib/number-field/themes/solar/pearl/index.js +1 -1
  249. package/lib/overlay/custom-elements.json +26 -13
  250. package/lib/overlay/custom-elements.md +54 -0
  251. package/lib/overlay/elements/overlay-backdrop.d.ts +12 -5
  252. package/lib/overlay/elements/overlay-backdrop.js +13 -9
  253. package/lib/overlay/elements/overlay-viewport.d.ts +11 -4
  254. package/lib/overlay/elements/overlay-viewport.js +12 -9
  255. package/lib/overlay/elements/overlay.d.ts +18 -6
  256. package/lib/overlay/elements/overlay.js +35 -28
  257. package/lib/overlay/helpers/functions.js +0 -1
  258. package/lib/overlay/helpers/types.js +0 -1
  259. package/lib/overlay/index.d.ts +2 -2
  260. package/lib/overlay/index.js +1 -2
  261. package/lib/overlay/managers/backdrop-manager.d.ts +2 -2
  262. package/lib/overlay/managers/backdrop-manager.js +2 -3
  263. package/lib/overlay/managers/close-manager.d.ts +1 -1
  264. package/lib/overlay/managers/close-manager.js +1 -2
  265. package/lib/overlay/managers/focus-manager.d.ts +1 -1
  266. package/lib/overlay/managers/focus-manager.js +3 -5
  267. package/lib/overlay/managers/interaction-lock-manager.js +2 -3
  268. package/lib/overlay/managers/viewport-manager.d.ts +3 -3
  269. package/lib/overlay/managers/viewport-manager.js +6 -3
  270. package/lib/overlay/managers/zindex-manager.d.ts +1 -1
  271. package/lib/overlay/managers/zindex-manager.js +1 -4
  272. package/lib/overlay-menu/custom-elements.json +126 -12
  273. package/lib/overlay-menu/custom-elements.md +44 -0
  274. package/lib/overlay-menu/helpers/types.d.ts +3 -3
  275. package/lib/overlay-menu/helpers/types.js +0 -1
  276. package/lib/overlay-menu/index.d.ts +44 -12
  277. package/lib/overlay-menu/index.js +66 -35
  278. package/lib/overlay-menu/managers/menu-manager.d.ts +2 -2
  279. package/lib/overlay-menu/managers/menu-manager.js +8 -8
  280. package/lib/pagination/custom-elements.json +16 -33
  281. package/lib/pagination/custom-elements.md +26 -0
  282. package/lib/pagination/index.d.ts +156 -81
  283. package/lib/pagination/index.js +373 -214
  284. package/lib/pagination/themes/halo/dark/index.js +1 -1
  285. package/lib/pagination/themes/halo/light/index.js +1 -1
  286. package/lib/pagination/themes/solar/charcoal/index.js +1 -1
  287. package/lib/pagination/themes/solar/pearl/index.js +1 -1
  288. package/lib/panel/custom-elements.md +11 -0
  289. package/lib/panel/index.d.ts +11 -4
  290. package/lib/panel/index.js +13 -9
  291. package/lib/password-field/custom-elements.json +62 -67
  292. package/lib/password-field/custom-elements.md +39 -0
  293. package/lib/password-field/index.d.ts +46 -90
  294. package/lib/password-field/index.js +52 -190
  295. package/lib/password-field/themes/halo/dark/index.js +1 -1
  296. package/lib/password-field/themes/halo/light/index.js +1 -1
  297. package/lib/password-field/themes/solar/charcoal/index.js +1 -1
  298. package/lib/password-field/themes/solar/pearl/index.js +1 -1
  299. package/lib/pill/custom-elements.json +9 -7
  300. package/lib/pill/custom-elements.md +22 -0
  301. package/lib/pill/index.d.ts +15 -7
  302. package/lib/pill/index.js +21 -27
  303. package/lib/pill/themes/halo/dark/index.js +1 -1
  304. package/lib/pill/themes/halo/light/index.js +1 -1
  305. package/lib/progress-bar/custom-elements.md +18 -0
  306. package/lib/progress-bar/index.d.ts +11 -15
  307. package/lib/progress-bar/index.js +14 -25
  308. package/lib/radio-button/custom-elements.json +4 -4
  309. package/lib/radio-button/custom-elements.md +19 -0
  310. package/lib/radio-button/index.d.ts +33 -9
  311. package/lib/radio-button/index.js +97 -24
  312. package/lib/radio-button/radio-button-registry.d.ts +3 -2
  313. package/lib/radio-button/radio-button-registry.js +57 -5
  314. package/lib/radio-button/themes/halo/dark/index.js +1 -1
  315. package/lib/radio-button/themes/halo/light/index.js +1 -1
  316. package/lib/rating/custom-elements.md +17 -0
  317. package/lib/rating/index.d.ts +11 -4
  318. package/lib/rating/index.js +16 -10
  319. package/lib/search-field/custom-elements.json +70 -74
  320. package/lib/search-field/custom-elements.md +41 -0
  321. package/lib/search-field/index.d.ts +47 -97
  322. package/lib/search-field/index.js +50 -212
  323. package/lib/search-field/themes/halo/dark/index.js +1 -1
  324. package/lib/search-field/themes/halo/light/index.js +1 -1
  325. package/lib/search-field/themes/solar/charcoal/index.js +1 -1
  326. package/lib/search-field/themes/solar/pearl/index.js +1 -1
  327. package/lib/select/custom-elements.json +5 -4
  328. package/lib/select/custom-elements.md +24 -0
  329. package/lib/select/helpers/types.d.ts +1 -1
  330. package/lib/select/helpers/types.js +0 -1
  331. package/lib/select/index.d.ts +26 -11
  332. package/lib/select/index.js +93 -52
  333. package/lib/select/themes/halo/dark/index.js +1 -1
  334. package/lib/select/themes/halo/light/index.js +1 -1
  335. package/lib/sidebar-layout/custom-elements.json +2 -6
  336. package/lib/sidebar-layout/custom-elements.md +21 -0
  337. package/lib/sidebar-layout/index.d.ts +15 -7
  338. package/lib/sidebar-layout/index.js +16 -10
  339. package/lib/slider/custom-elements.json +4 -4
  340. package/lib/slider/custom-elements.md +28 -0
  341. package/lib/slider/index.d.ts +18 -5
  342. package/lib/slider/index.js +69 -16
  343. package/lib/sparkline/custom-elements.json +4 -4
  344. package/lib/sparkline/custom-elements.md +16 -0
  345. package/lib/sparkline/index.d.ts +14 -5
  346. package/lib/sparkline/index.js +17 -10
  347. package/lib/swing-gauge/const.d.ts +22 -0
  348. package/lib/swing-gauge/const.js +26 -0
  349. package/lib/swing-gauge/custom-elements.json +51 -22
  350. package/lib/swing-gauge/custom-elements.md +17 -0
  351. package/lib/swing-gauge/helpers.d.ts +8 -0
  352. package/lib/swing-gauge/helpers.js +105 -0
  353. package/lib/swing-gauge/index.d.ts +220 -72
  354. package/lib/swing-gauge/index.js +648 -168
  355. package/lib/swing-gauge/themes/halo/dark/index.js +1 -1
  356. package/lib/swing-gauge/themes/halo/light/index.js +1 -1
  357. package/lib/swing-gauge/themes/solar/charcoal/index.js +1 -1
  358. package/lib/swing-gauge/themes/solar/pearl/index.js +1 -1
  359. package/lib/swing-gauge/types.d.ts +34 -0
  360. package/lib/swing-gauge/types.js +1 -0
  361. package/lib/tab/custom-elements.json +10 -21
  362. package/lib/tab/custom-elements.md +22 -0
  363. package/lib/tab/index.d.ts +19 -14
  364. package/lib/tab/index.js +31 -40
  365. package/lib/tab/themes/halo/dark/index.js +1 -1
  366. package/lib/tab/themes/halo/light/index.js +1 -1
  367. package/lib/tab/themes/solar/charcoal/index.js +1 -1
  368. package/lib/tab/themes/solar/pearl/index.js +1 -1
  369. package/lib/tab-bar/custom-elements.json +0 -6
  370. package/lib/tab-bar/custom-elements.md +11 -0
  371. package/lib/tab-bar/helpers/animate.d.ts +1 -1
  372. package/lib/tab-bar/helpers/animate.js +5 -2
  373. package/lib/tab-bar/index.d.ts +12 -5
  374. package/lib/tab-bar/index.js +18 -21
  375. package/lib/tab-bar/themes/solar/charcoal/index.js +1 -1
  376. package/lib/tab-bar/themes/solar/pearl/index.js +1 -1
  377. package/lib/text-field/custom-elements.json +78 -89
  378. package/lib/text-field/custom-elements.md +35 -0
  379. package/lib/text-field/index.d.ts +67 -80
  380. package/lib/text-field/index.js +106 -157
  381. package/lib/text-field/themes/halo/dark/index.js +1 -1
  382. package/lib/text-field/themes/halo/light/index.js +1 -1
  383. package/lib/text-field/themes/solar/charcoal/index.js +1 -1
  384. package/lib/text-field/themes/solar/pearl/index.js +1 -1
  385. package/lib/time-picker/custom-elements.json +6 -8
  386. package/lib/time-picker/custom-elements.md +28 -0
  387. package/lib/time-picker/index.d.ts +105 -65
  388. package/lib/time-picker/index.js +297 -169
  389. package/lib/time-picker/themes/solar/charcoal/index.js +1 -1
  390. package/lib/time-picker/themes/solar/pearl/index.js +1 -1
  391. package/lib/toggle/custom-elements.json +4 -4
  392. package/lib/toggle/custom-elements.md +19 -0
  393. package/lib/toggle/index.d.ts +22 -5
  394. package/lib/toggle/index.js +58 -13
  395. package/lib/toggle/themes/halo/dark/index.js +1 -1
  396. package/lib/toggle/themes/halo/light/index.js +1 -1
  397. package/lib/toggle/themes/solar/charcoal/index.js +1 -1
  398. package/lib/toggle/themes/solar/pearl/index.js +1 -1
  399. package/lib/tooltip/custom-elements.md +14 -0
  400. package/lib/tooltip/elements/title-tooltip.js +2 -3
  401. package/lib/tooltip/elements/tooltip-element.d.ts +2 -3
  402. package/lib/tooltip/elements/tooltip-element.js +0 -2
  403. package/lib/tooltip/helpers/overflow-tooltip.d.ts +1 -1
  404. package/lib/tooltip/helpers/overflow-tooltip.js +1 -2
  405. package/lib/tooltip/helpers/renderer.d.ts +1 -1
  406. package/lib/tooltip/helpers/renderer.js +0 -1
  407. package/lib/tooltip/helpers/types.d.ts +1 -1
  408. package/lib/tooltip/helpers/types.js +0 -1
  409. package/lib/tooltip/index.d.ts +18 -11
  410. package/lib/tooltip/index.js +27 -23
  411. package/lib/tooltip/managers/tooltip-manager.d.ts +2 -2
  412. package/lib/tooltip/managers/tooltip-manager.js +17 -11
  413. package/lib/tornado-chart/custom-elements.md +18 -0
  414. package/lib/tornado-chart/elements/tornado-chart.d.ts +12 -5
  415. package/lib/tornado-chart/elements/tornado-chart.js +15 -11
  416. package/lib/tornado-chart/elements/tornado-item.d.ts +13 -6
  417. package/lib/tornado-chart/elements/tornado-item.js +17 -12
  418. package/lib/tornado-chart/index.d.ts +2 -2
  419. package/lib/tornado-chart/index.js +2 -3
  420. package/lib/tree/custom-elements.json +30 -2
  421. package/lib/tree/custom-elements.md +32 -0
  422. package/lib/tree/elements/tree-item.d.ts +53 -5
  423. package/lib/tree/elements/tree-item.js +114 -34
  424. package/lib/tree/elements/tree.d.ts +65 -20
  425. package/lib/tree/elements/tree.js +151 -34
  426. package/lib/tree/helpers/filter.d.ts +8 -0
  427. package/lib/tree/helpers/filter.js +33 -0
  428. package/lib/tree/helpers/renderer.d.ts +2 -2
  429. package/lib/tree/helpers/renderer.js +4 -4
  430. package/lib/tree/helpers/types.d.ts +13 -1
  431. package/lib/tree/helpers/types.js +0 -1
  432. package/lib/tree/index.d.ts +4 -4
  433. package/lib/tree/index.js +3 -4
  434. package/lib/tree/managers/tree-manager.d.ts +22 -10
  435. package/lib/tree/managers/tree-manager.js +56 -41
  436. package/lib/tree/themes/halo/dark/index.js +1 -1
  437. package/lib/tree/themes/halo/light/index.js +1 -1
  438. package/lib/tree/themes/solar/charcoal/index.js +1 -1
  439. package/lib/tree/themes/solar/pearl/index.js +1 -1
  440. package/lib/tree-select/custom-elements.json +14 -5
  441. package/lib/tree-select/custom-elements.md +26 -0
  442. package/lib/tree-select/helpers/types.d.ts +2 -2
  443. package/lib/tree-select/helpers/types.js +0 -1
  444. package/lib/tree-select/index.d.ts +55 -27
  445. package/lib/tree-select/index.js +107 -45
  446. package/lib/tree-select/themes/halo/dark/index.js +3 -2
  447. package/lib/tree-select/themes/halo/light/index.js +3 -2
  448. package/lib/tree-select/themes/solar/charcoal/index.js +3 -2
  449. package/lib/tree-select/themes/solar/pearl/index.js +3 -2
  450. package/lib/version.d.ts +1 -0
  451. package/lib/version.js +1 -0
  452. package/package.json +601 -25
  453. package/lib/accordion/index.js.map +0 -1
  454. package/lib/appstate-bar/index.js.map +0 -1
  455. package/lib/autosuggest/helpers/const.d.ts +0 -2
  456. package/lib/autosuggest/helpers/const.js +0 -4
  457. package/lib/autosuggest/helpers/const.js.map +0 -1
  458. package/lib/autosuggest/helpers/types.js.map +0 -1
  459. package/lib/autosuggest/helpers/utils.js.map +0 -1
  460. package/lib/autosuggest/index.js.map +0 -1
  461. package/lib/button/index.js.map +0 -1
  462. package/lib/button-bar/index.js.map +0 -1
  463. package/lib/calendar/index.js.map +0 -1
  464. package/lib/calendar/locales.js.map +0 -1
  465. package/lib/calendar/types.js.map +0 -1
  466. package/lib/calendar/utils.js.map +0 -1
  467. package/lib/canvas/index.js.map +0 -1
  468. package/lib/card/helpers/types.js.map +0 -1
  469. package/lib/card/index.js.map +0 -1
  470. package/lib/chart/helpers/legend.js.map +0 -1
  471. package/lib/chart/helpers/types.js.map +0 -1
  472. package/lib/chart/index.js.map +0 -1
  473. package/lib/chart/plugins/doughnut-center-label.js.map +0 -1
  474. package/lib/checkbox/index.js.map +0 -1
  475. package/lib/clock/index.js.map +0 -1
  476. package/lib/clock/utils/TickManager.js.map +0 -1
  477. package/lib/clock/utils/timestamps.js.map +0 -1
  478. package/lib/collapse/index.js.map +0 -1
  479. package/lib/color-dialog/elements/color-palettes.js.map +0 -1
  480. package/lib/color-dialog/elements/grayscale-palettes.js.map +0 -1
  481. package/lib/color-dialog/elements/palettes.js.map +0 -1
  482. package/lib/color-dialog/helpers/color-helpers.js.map +0 -1
  483. package/lib/color-dialog/helpers/value-model.js.map +0 -1
  484. package/lib/color-dialog/index.js.map +0 -1
  485. package/lib/combo-box/helpers/filter.js.map +0 -1
  486. package/lib/combo-box/helpers/keyboard-event.js.map +0 -1
  487. package/lib/combo-box/helpers/types.js.map +0 -1
  488. package/lib/combo-box/index.js.map +0 -1
  489. package/lib/datetime-picker/index.js.map +0 -1
  490. package/lib/datetime-picker/locales.js.map +0 -1
  491. package/lib/datetime-picker/types.js.map +0 -1
  492. package/lib/datetime-picker/utils.js.map +0 -1
  493. package/lib/dialog/draggable-element.js.map +0 -1
  494. package/lib/dialog/index.js.map +0 -1
  495. package/lib/email-field/index.js.map +0 -1
  496. package/lib/flag/index.js.map +0 -1
  497. package/lib/flag/utils/FlagLoader.js.map +0 -1
  498. package/lib/header/index.js.map +0 -1
  499. package/lib/heatmap/helpers/color.js.map +0 -1
  500. package/lib/heatmap/helpers/text.js.map +0 -1
  501. package/lib/heatmap/helpers/track.js.map +0 -1
  502. package/lib/heatmap/helpers/types.js.map +0 -1
  503. package/lib/heatmap/index.js.map +0 -1
  504. package/lib/icon/index.js.map +0 -1
  505. package/lib/icon/utils/IconLoader.js.map +0 -1
  506. package/lib/index.js.map +0 -1
  507. package/lib/interactive-chart/helpers/types.js.map +0 -1
  508. package/lib/interactive-chart/index.js.map +0 -1
  509. package/lib/item/helpers/types.js.map +0 -1
  510. package/lib/item/index.js.map +0 -1
  511. package/lib/label/helpers/text.d.ts +0 -35
  512. package/lib/label/helpers/text.js +0 -57
  513. package/lib/label/helpers/text.js.map +0 -1
  514. package/lib/label/index.js.map +0 -1
  515. package/lib/layout/index.js.map +0 -1
  516. package/lib/led-gauge/index.js.map +0 -1
  517. package/lib/list/extensible-function.js.map +0 -1
  518. package/lib/list/helpers/list-renderer.js.map +0 -1
  519. package/lib/list/helpers/types.js.map +0 -1
  520. package/lib/list/index.js.map +0 -1
  521. package/lib/list/renderer.js.map +0 -1
  522. package/lib/loader/index.js.map +0 -1
  523. package/lib/multi-input/helpers/types.js.map +0 -1
  524. package/lib/multi-input/index.js.map +0 -1
  525. package/lib/notification/elements/notification-tray.js.map +0 -1
  526. package/lib/notification/elements/notification.js.map +0 -1
  527. package/lib/notification/helpers/status.js.map +0 -1
  528. package/lib/notification/helpers/types.js.map +0 -1
  529. package/lib/notification/index.js.map +0 -1
  530. package/lib/number-field/index.js.map +0 -1
  531. package/lib/overlay/elements/overlay-backdrop.js.map +0 -1
  532. package/lib/overlay/elements/overlay-viewport.js.map +0 -1
  533. package/lib/overlay/elements/overlay.js.map +0 -1
  534. package/lib/overlay/helpers/functions.js.map +0 -1
  535. package/lib/overlay/helpers/types.js.map +0 -1
  536. package/lib/overlay/index.js.map +0 -1
  537. package/lib/overlay/managers/backdrop-manager.js.map +0 -1
  538. package/lib/overlay/managers/close-manager.js.map +0 -1
  539. package/lib/overlay/managers/focus-manager.js.map +0 -1
  540. package/lib/overlay/managers/interaction-lock-manager.js.map +0 -1
  541. package/lib/overlay/managers/viewport-manager.js.map +0 -1
  542. package/lib/overlay/managers/zindex-manager.js.map +0 -1
  543. package/lib/overlay-menu/helpers/types.js.map +0 -1
  544. package/lib/overlay-menu/helpers/uuid.d.ts +0 -7
  545. package/lib/overlay-menu/helpers/uuid.js +0 -14
  546. package/lib/overlay-menu/helpers/uuid.js.map +0 -1
  547. package/lib/overlay-menu/index.js.map +0 -1
  548. package/lib/overlay-menu/managers/menu-manager.js.map +0 -1
  549. package/lib/pagination/helpers/types.d.ts +0 -9
  550. package/lib/pagination/helpers/types.js +0 -2
  551. package/lib/pagination/helpers/types.js.map +0 -1
  552. package/lib/pagination/index.js.map +0 -1
  553. package/lib/panel/index.js.map +0 -1
  554. package/lib/password-field/index.js.map +0 -1
  555. package/lib/pill/index.js.map +0 -1
  556. package/lib/progress-bar/index.js.map +0 -1
  557. package/lib/radio-button/index.js.map +0 -1
  558. package/lib/radio-button/radio-button-registry.js.map +0 -1
  559. package/lib/rating/index.js.map +0 -1
  560. package/lib/search-field/index.js.map +0 -1
  561. package/lib/select/helpers/types.js.map +0 -1
  562. package/lib/select/index.js.map +0 -1
  563. package/lib/sidebar-layout/index.js.map +0 -1
  564. package/lib/slider/index.js.map +0 -1
  565. package/lib/sparkline/index.js.map +0 -1
  566. package/lib/swing-gauge/helpers/canvas.d.ts +0 -8
  567. package/lib/swing-gauge/helpers/canvas.js +0 -115
  568. package/lib/swing-gauge/helpers/canvas.js.map +0 -1
  569. package/lib/swing-gauge/helpers/types.d.ts +0 -33
  570. package/lib/swing-gauge/helpers/types.js +0 -2
  571. package/lib/swing-gauge/helpers/types.js.map +0 -1
  572. package/lib/swing-gauge/index.js.map +0 -1
  573. package/lib/tab/index.js.map +0 -1
  574. package/lib/tab-bar/helpers/animate.js.map +0 -1
  575. package/lib/tab-bar/index.js.map +0 -1
  576. package/lib/text-field/index.js.map +0 -1
  577. package/lib/time-picker/index.js.map +0 -1
  578. package/lib/toggle/index.js.map +0 -1
  579. package/lib/tooltip/elements/title-tooltip.js.map +0 -1
  580. package/lib/tooltip/elements/tooltip-element.js.map +0 -1
  581. package/lib/tooltip/helpers/overflow-tooltip.js.map +0 -1
  582. package/lib/tooltip/helpers/renderer.js.map +0 -1
  583. package/lib/tooltip/helpers/types.js.map +0 -1
  584. package/lib/tooltip/index.js.map +0 -1
  585. package/lib/tooltip/managers/tooltip-manager.js.map +0 -1
  586. package/lib/tornado-chart/elements/tornado-chart.js.map +0 -1
  587. package/lib/tornado-chart/elements/tornado-item.js.map +0 -1
  588. package/lib/tornado-chart/index.js.map +0 -1
  589. package/lib/tree/elements/tree-item.js.map +0 -1
  590. package/lib/tree/elements/tree.js.map +0 -1
  591. package/lib/tree/helpers/renderer.js.map +0 -1
  592. package/lib/tree/helpers/types.js.map +0 -1
  593. package/lib/tree/index.js.map +0 -1
  594. package/lib/tree/managers/tree-manager.js.map +0 -1
  595. package/lib/tree-select/helpers/types.js.map +0 -1
  596. package/lib/tree-select/index.js.map +0 -1
@@ -1,35 +1,22 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { ControlElement, html, css, customElement, property, ifDefined, WarningNotice } from '@refinitiv-ui/core';
8
- import '../button';
9
- import { DateFormat, format, utcFormat, utcParse, isValidDate, isWeekend, isAfter, isBefore, addMonths, subMonths, isToday, isThisMonth, isThisYear, isSameDay, isSameMonth, isSameYear, toDateSegment } from '@refinitiv-ui/utils';
10
- import { monthInfo } from './utils';
11
- import './locales';
12
- import { weekdaysNames, monthsNames, formatLocaleDate, ViewFormatTranslateParams } from './locales';
1
+ import { __decorate } from "tslib";
2
+ import { ControlElement, html, css, 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 { state } from '@refinitiv-ui/core/lib/decorators/state.js';
6
+ import { ifDefined } from '@refinitiv-ui/core/lib/directives/if-defined.js';
7
+ import { cache } from '@refinitiv-ui/core/lib/directives/cache.js';
8
+ import { guard } from '@refinitiv-ui/core/lib/directives/guard.js';
9
+ import { ref, createRef } from '@refinitiv-ui/core/lib/directives/ref.js';
10
+ import { VERSION } from '../version.js';
11
+ import { isIE } from '@refinitiv-ui/utils/lib/browser.js';
12
+ import { DateFormat, format, utcFormat, utcParse, isValidDate, isWeekend, isAfter, isBefore, addMonths, subMonths, isToday, isThisMonth, isThisYear, isSameDay, isSameMonth, isSameYear, toDateSegment, parse } from '@refinitiv-ui/utils/lib/date.js';
13
+ import { left, right, up, down, first, last } from '@refinitiv-ui/utils/lib/navigation.js';
14
+ import { monthInfo, weekdaysNames, monthsNames, formatLocaleDate, ViewFormatTranslateParams } from './utils.js';
13
15
  import { translate, getLocale, TranslatePropertyKey } from '@refinitiv-ui/translate';
14
- import { RenderView } from './types';
15
- const isIE = (/Trident/g).test(navigator.userAgent) || (/MSIE/g).test(navigator.userAgent);
16
- const FIRST_DAY_OF_WEEK = 0; // 0 for Sunday
17
- const YEARS_PER_YEAR_VIEW = 16; /* must be a square number */
18
- const DAY_VIEW = {
19
- rowCount: 6,
20
- columnCount: 7,
21
- totalCount: 6 * 7
22
- };
23
- const YEAR_VIEW = {
24
- rowCount: 4,
25
- columnCount: 4,
26
- totalCount: 4 * 4
27
- };
28
- const MONTH_VIEW = {
29
- rowCount: 4,
30
- columnCount: 4,
31
- totalCount: 4 * 4
32
- };
16
+ import { RenderView, CalendarLocaleScope, FIRST_DAY_OF_WEEK, YEARS_PER_YEAR_VIEW, DAY_VIEW, YEAR_VIEW, MONTH_VIEW } from './constants.js';
17
+ import './locales.js';
18
+ import '../button/index.js';
19
+ import '@refinitiv-ui/phrasebook/lib/locale/en/calendar.js';
33
20
  /**
34
21
  * Standard calendar element
35
22
  *
@@ -47,6 +34,11 @@ const MONTH_VIEW = {
47
34
  let Calendar = class Calendar extends ControlElement {
48
35
  constructor() {
49
36
  super(...arguments);
37
+ this.defaultRole = 'group';
38
+ /**
39
+ * Reference to the view button
40
+ */
41
+ this.viewBtnRef = createRef();
50
42
  this._min = '';
51
43
  this._max = '';
52
44
  /**
@@ -81,11 +73,30 @@ let Calendar = class Calendar extends ControlElement {
81
73
  /**
82
74
  * Used for internal navigation between render views
83
75
  */
84
- this.renderView = RenderView.DAY;
85
- this.isDateAvailable = null; /* a constructed filter based on multiple local filters */
76
+ this._renderView = RenderView.DAY;
77
+ /**
78
+ * Used for keyboard navigation when trying
79
+ * to restore focus on re-render and control navigation
80
+ */
81
+ this._activeCellIndex = null;
82
+ // Used to store current navigation map
83
+ this.navigationGrid = [];
84
+ /**
85
+ * Connected to role. If false, the values are not announced in the screen reader
86
+ */
87
+ this.announceValues = true;
88
+ // Cashed filter, which is constructed based on multiple local filters
89
+ this.isDateAvailable = null;
90
+ }
91
+ /**
92
+ * Element version number
93
+ * @returns version number
94
+ */
95
+ static get version() {
96
+ return VERSION;
86
97
  }
87
98
  /**
88
- * A `CSSResult` that will be used
99
+ * A `CSSResultGroup` that will be used
89
100
  * to style the host, slotted children
90
101
  * and the internal template of the element.
91
102
  * @return CSS template
@@ -95,14 +106,14 @@ let Calendar = class Calendar extends ControlElement {
95
106
  :host {
96
107
  display: inline-block;
97
108
  }
98
- [part=navigation], [part=navigation] section {
109
+ [part~=navigation], [part~=navigation] section {
99
110
  display: flex;
100
111
  flex-flow: row nowrap;
101
112
  }
102
- [part=navigation] {
113
+ [part~=navigation] {
103
114
  justify-content: space-between;
104
115
  }
105
- [part=navigation] > div {
116
+ [part~=navigation] > div {
106
117
  display: flex;
107
118
  flex: 1;
108
119
  justify-content: center;
@@ -113,7 +124,6 @@ let Calendar = class Calendar extends ControlElement {
113
124
  bottom: 0;
114
125
  left: 0;
115
126
  right: 0;
116
- pointer-events: none;
117
127
  display: flex;
118
128
  align-items: center;
119
129
  justify-content: center;
@@ -143,7 +153,10 @@ let Calendar = class Calendar extends ControlElement {
143
153
  width: calc(100% / ${DAY_VIEW.columnCount});
144
154
  padding-top: calc(100% / ${DAY_VIEW.columnCount});
145
155
  }
146
- [part~=cell][tabindex] {
156
+ [part~=cell-content]:not([tabindex]) {
157
+ pointer-events: none;
158
+ }
159
+ [part~=selection] {
147
160
  cursor: pointer;
148
161
  }
149
162
  `;
@@ -161,7 +174,7 @@ let Calendar = class Calendar extends ControlElement {
161
174
  }
162
175
  if (oldMin !== min) {
163
176
  this._min = min;
164
- void this.requestUpdate('min', oldMin);
177
+ this.requestUpdate('min', oldMin);
165
178
  }
166
179
  }
167
180
  get min() {
@@ -180,7 +193,7 @@ let Calendar = class Calendar extends ControlElement {
180
193
  }
181
194
  if (oldMax !== max) {
182
195
  this._max = max;
183
- void this.requestUpdate('max', oldMax);
196
+ this.requestUpdate('max', oldMax);
184
197
  }
185
198
  }
186
199
  get max() {
@@ -199,7 +212,8 @@ let Calendar = class Calendar extends ControlElement {
199
212
  const oldView = this._view;
200
213
  if (oldView !== view) {
201
214
  this._view = view;
202
- void this.requestUpdate('view', oldView);
215
+ this.resetActiveCellIndex();
216
+ this.requestUpdate('view', oldView);
203
217
  }
204
218
  }
205
219
  get view() {
@@ -211,13 +225,14 @@ let Calendar = class Calendar extends ControlElement {
211
225
  * 0 - for Sunday, 6 - for Saturday
212
226
  * @param firstDayOfWeek The first day of the week
213
227
  * @type {number | null}
228
+ * @default null
214
229
  */
215
230
  set firstDayOfWeek(firstDayOfWeek) {
216
231
  firstDayOfWeek %= 7;
217
- const oldFirstDayOfWeek = this.firstDayOfWeek;
232
+ const oldFirstDayOfWeek = this._firstDayOfWeek;
218
233
  if (oldFirstDayOfWeek !== firstDayOfWeek) {
219
234
  this._firstDayOfWeek = firstDayOfWeek;
220
- void this.requestUpdate('firstDayOfWeek', oldFirstDayOfWeek);
235
+ this.requestUpdate('firstDayOfWeek', oldFirstDayOfWeek);
221
236
  }
222
237
  }
223
238
  get firstDayOfWeek() {
@@ -238,39 +253,95 @@ let Calendar = class Calendar extends ControlElement {
238
253
  * Set multiple selected values
239
254
  * @param values Values to set
240
255
  * @type {string[]}
256
+ * @default []
241
257
  */
242
258
  set values(values) {
243
259
  const oldValues = this._values;
244
260
  const newValues = this.filterAndWarnInvalidValues(values);
245
261
  if (oldValues.toString() !== newValues.toString()) {
246
262
  this._values = newValues;
247
- void this.requestUpdate('values', oldValues);
263
+ this.requestUpdate('values', oldValues);
248
264
  }
249
265
  }
250
266
  get values() {
251
267
  return this._values.concat();
252
268
  }
269
+ get renderView() {
270
+ return this._renderView;
271
+ }
272
+ set renderView(renderView) {
273
+ const oldRenderView = this._renderView;
274
+ if (oldRenderView !== renderView) {
275
+ this._renderView = renderView;
276
+ // always reset active cell to not focus on potentially invalid cell
277
+ this.resetActiveCellIndex();
278
+ this.requestUpdate('renderView', oldRenderView);
279
+ }
280
+ }
281
+ get activeCellIndex() {
282
+ return this._activeCellIndex;
283
+ }
284
+ set activeCellIndex(activeCellIndex) {
285
+ const oldCellIndex = this._activeCellIndex;
286
+ if (String(activeCellIndex) !== String(oldCellIndex)) {
287
+ this._activeCellIndex = activeCellIndex;
288
+ this.requestUpdate('activeCellIndex', oldCellIndex);
289
+ }
290
+ }
253
291
  /**
254
- * Get weekday numbers.
255
- * Sort the list based on first day of the week
292
+ * Silently reset cell index without calling request update
293
+ * @returns {void}
256
294
  */
257
- get weekdaysNames() {
258
- const firstDayOfWeek = this.firstDayOfWeek;
259
- const localWeekdaysNames = this.localWeekdaysNames;
260
- return localWeekdaysNames.slice(firstDayOfWeek).concat(localWeekdaysNames.slice(0, firstDayOfWeek));
295
+ resetActiveCellIndex() {
296
+ this._activeCellIndex = null;
297
+ }
298
+ /**
299
+ * Get an active element
300
+ */
301
+ get activeElement() {
302
+ return this.shadowRoot.activeElement;
261
303
  }
262
304
  /**
263
- * Get localised month names from January to December
305
+ * Get selectable date button element by index
306
+ * @param index Cell index
307
+ * @returns button HTML date button element or null
264
308
  */
265
- get monthsNames() {
266
- return this.localMonthsNames;
309
+ getDateButtonByIndex(index) {
310
+ const elements = Array.from(this.renderRoot.querySelectorAll('[part~=cell] > [part~=selection]'));
311
+ return elements.find((element) => this.isDateButton(element) && String(element.index) === String(index));
312
+ }
313
+ /**
314
+ * Get active date button element
315
+ * @returns button HTML date button element or null
316
+ */
317
+ get activeDateButton() {
318
+ return this.renderRoot.querySelector('[part~=cell][active] > [part~=selection]');
319
+ }
320
+ /**
321
+ * Return true if passed target is HTML
322
+ * date button element that can be selected
323
+ * @param target Target to check
324
+ * @returns isDateButtonElement
325
+ */
326
+ isDateButton(target) {
327
+ return target.index !== undefined;
328
+ }
329
+ static get observedAttributes() {
330
+ const observed = super.observedAttributes;
331
+ return ['role'].concat(observed);
332
+ }
333
+ attributeChangedCallback(name, oldValue, newValue) {
334
+ super.attributeChangedCallback(name, oldValue, newValue);
335
+ if (name === 'role') {
336
+ this.announceValues = !(!newValue || newValue === 'none' || newValue === 'presentation');
337
+ }
267
338
  }
268
339
  /**
269
340
  * Perform asynchronous update
270
341
  * @returns promise
271
342
  */
272
343
  async performUpdate() {
273
- const localFirstDayOfWeek = Number(await this.tPromise('FIRST_DAY_OF_WEEK'));
344
+ const localFirstDayOfWeek = Number(await this.dateTPromise('FIRST_DAY_OF_WEEK'));
274
345
  this.localFirstDayOfWeek = isNaN(localFirstDayOfWeek) ? FIRST_DAY_OF_WEEK : (localFirstDayOfWeek % 7);
275
346
  void super.performUpdate();
276
347
  }
@@ -281,14 +352,39 @@ let Calendar = class Calendar extends ControlElement {
281
352
  */
282
353
  update(changedProperties) {
283
354
  if (!this.localMonthsNames || changedProperties.has(TranslatePropertyKey)) {
284
- this.localMonthsNames = monthsNames(getLocale(this));
355
+ const locale = getLocale(this);
356
+ this.localMonthsNames = monthsNames(locale);
285
357
  }
286
358
  if (!this.localWeekdaysNames || changedProperties.has(TranslatePropertyKey)) {
287
- this.localWeekdaysNames = weekdaysNames(getLocale(this));
359
+ const locale = getLocale(this);
360
+ const longWeekdaysNames = weekdaysNames(locale, 'long');
361
+ this.localWeekdaysNames = weekdaysNames(locale).map((narrow, index) => {
362
+ return { narrow, long: longWeekdaysNames[index] };
363
+ });
288
364
  }
289
365
  this.shouldConstructFilters(changedProperties) && this.constructFilters();
290
366
  super.update(changedProperties);
291
367
  }
368
+ /**
369
+ * Called after render life-cycle finished
370
+ * @param changedProperties Properties which have changed
371
+ * @return {void}
372
+ */
373
+ updated(changedProperties) {
374
+ super.updated(changedProperties);
375
+ // This code is here to ensure that focus is not lost
376
+ // while navigating through the render views using keyboard
377
+ if (this.focused && changedProperties.has('renderView') && this.viewBtnRef.value && this.activeElement !== this.viewBtnRef.value) {
378
+ this.viewBtnRef.value.focus();
379
+ }
380
+ const cellIndex = this.activeCellIndex;
381
+ if (cellIndex && changedProperties.has('activeCellIndex')) {
382
+ const dateButtonEl = this.getDateButtonByIndex(cellIndex);
383
+ if (dateButtonEl && this.activeElement !== dateButtonEl) {
384
+ dateButtonEl.focus();
385
+ }
386
+ }
387
+ }
292
388
  /**
293
389
  * Run when an element has been first updated
294
390
  * @param changedProperties properties that was changed on first update
@@ -296,7 +392,7 @@ let Calendar = class Calendar extends ControlElement {
296
392
  */
297
393
  firstUpdated(changedProperties) {
298
394
  super.firstUpdated(changedProperties);
299
- this.renderRoot.addEventListener('keydown', event => this.onTableKeyDown(event));
395
+ this.renderRoot.addEventListener('keydown', event => this.onKeyDown(event));
300
396
  }
301
397
  /**
302
398
  * Show invalid view message
@@ -428,78 +524,88 @@ let Calendar = class Calendar extends ControlElement {
428
524
  rangeTo
429
525
  };
430
526
  }
527
+ /**
528
+ * Set navigation map based on rows
529
+ * @param rows A collection of rows with cells
530
+ * @returns {void}
531
+ */
532
+ setNavigationMap(rows) {
533
+ this.navigationGrid = rows.map(row => row.map(cell => cell.value && !cell.disabled ? 1 : 0));
534
+ }
431
535
  /**
432
536
  * Run when next button is tapped.
433
537
  * Change current view to next view
538
+ * @param event Next view tap event
434
539
  * @returns {void}
435
540
  */
436
- onNextTap() {
437
- let viewSegment = toDateSegment(this.view);
438
- switch (this.renderView) {
439
- case RenderView.DAY:
440
- viewSegment = toDateSegment(addMonths(this.view, 1));
441
- break;
442
- case RenderView.MONTH:
443
- viewSegment.year += 1;
444
- break;
445
- case RenderView.YEAR:
446
- viewSegment.year += YEARS_PER_YEAR_VIEW;
447
- break;
448
- // no default
541
+ onNextTap(event) {
542
+ if (!event.defaultPrevented) {
543
+ this.toNextView();
449
544
  }
450
- this.notifyViewChange(viewSegment);
451
545
  }
452
546
  /**
453
547
  * Run when previous button is tapped.
454
548
  * Change current view to previous view
549
+ * @param event Previous view tap event
455
550
  * @returns {void}
456
551
  */
457
- onPreviousTap() {
458
- let viewSegment = toDateSegment(this.view);
459
- switch (this.renderView) {
460
- case RenderView.DAY:
461
- viewSegment = toDateSegment(subMonths(this.view, 1));
462
- break;
463
- case RenderView.MONTH:
464
- viewSegment.year -= 1;
465
- break;
466
- case RenderView.YEAR:
467
- viewSegment.year -= YEARS_PER_YEAR_VIEW;
468
- break;
469
- // no default
552
+ onPreviousTap(event) {
553
+ if (!event.defaultPrevented) {
554
+ this.toPreviousView();
470
555
  }
471
- this.notifyViewChange(viewSegment);
472
556
  }
473
557
  /**
474
558
  * Run when change view button is tapped.
475
559
  * Switch between views
560
+ * @param event Render view tap event
476
561
  * @returns {void}
477
562
  */
478
- onRenderViewTap() {
479
- this.renderView = this.renderView === RenderView.DAY ? RenderView.YEAR : RenderView.DAY;
563
+ onRenderViewTap(event) {
564
+ if (!event.defaultPrevented) {
565
+ this.renderView = this.renderView === RenderView.DAY ? RenderView.YEAR : RenderView.DAY;
566
+ }
480
567
  }
481
568
  /**
482
569
  * Run when key down event happens on calendar
483
570
  * @param event Keyboard event
484
571
  * @returns {void}
485
572
  */
486
- onTableKeyDown(event) {
573
+ onKeyDown(event) {
574
+ if (event.defaultPrevented) {
575
+ return;
576
+ }
487
577
  switch (event.key) {
488
- case ' ':
489
- case 'Enter':
490
- case 'Spacebar':
491
- event.preventDefault();
492
- this.onTableTap(event);
493
- break;
494
578
  case 'Esc':
495
579
  case 'Escape':
496
580
  if (this.renderView === RenderView.YEAR || this.renderView === RenderView.MONTH) {
497
- event.preventDefault();
498
581
  this.renderView = RenderView.DAY;
582
+ break;
499
583
  }
584
+ return;
585
+ case 'Up': // IE11
586
+ case 'ArrowUp':
587
+ void this.onNavigation('ArrowUp');
500
588
  break;
501
- // no default
589
+ case 'Down':
590
+ case 'ArrowDown':
591
+ void this.onNavigation('ArrowDown');
592
+ break;
593
+ case 'Left':
594
+ case 'ArrowLeft':
595
+ void this.onNavigation('ArrowLeft');
596
+ break;
597
+ case 'Right':
598
+ case 'ArrowRight':
599
+ void this.onNavigation('ArrowRight');
600
+ break;
601
+ case 'Home':
602
+ case 'End':
603
+ void this.onNavigation(event.key);
604
+ break;
605
+ default:
606
+ return;
502
607
  }
608
+ event.preventDefault();
503
609
  }
504
610
  /**
505
611
  * Run when tap event happens ot table.
@@ -508,10 +614,14 @@ let Calendar = class Calendar extends ControlElement {
508
614
  * @returns {void}
509
615
  */
510
616
  onTableTap(event) {
511
- const cell = event.target; /* here we just emulate interface */
512
- if (!cell || !cell.value) {
617
+ if (event.defaultPrevented) {
618
+ return;
619
+ }
620
+ const cell = event.target;
621
+ if (!cell || !this.isDateButton(cell) || !cell.value) {
513
622
  return;
514
623
  }
624
+ this.activeCellIndex = cell.index;
515
625
  const cellSegment = toDateSegment(cell.value);
516
626
  const viewSegment = toDateSegment(this.view);
517
627
  if (this.renderView === RenderView.YEAR) { /* YEAR -> MONTH */
@@ -531,6 +641,117 @@ let Calendar = class Calendar extends ControlElement {
531
641
  }
532
642
  this.onTapSelectValue(cell.value);
533
643
  }
644
+ /**
645
+ * Navigate over the grid
646
+ * @param key Navigation direction
647
+ * @returns navigation promise
648
+ */
649
+ async onNavigation(key) {
650
+ const grid = this.navigationGrid;
651
+ switch (key) {
652
+ case 'Home':
653
+ this.activeCellIndex = first(grid);
654
+ return;
655
+ case 'End':
656
+ this.activeCellIndex = last(grid);
657
+ return;
658
+ // no default
659
+ }
660
+ // no previously selected cell, but there is cell which is a candidate for navigation
661
+ const activeDateEl = this.activeDateButton;
662
+ if (!this.activeCellIndex && activeDateEl) {
663
+ this.activeCellIndex = activeDateEl.index;
664
+ // current cell is already in focus (e.g. via Tab key, continue navigation from that point)
665
+ if (!(this.activeElement === activeDateEl)) {
666
+ return;
667
+ }
668
+ }
669
+ const activeCellIndex = this.activeCellIndex;
670
+ // All cells are disabled
671
+ if (!activeCellIndex) {
672
+ return;
673
+ }
674
+ // active cell is selected
675
+ if (activeCellIndex) {
676
+ let newActiveCell;
677
+ switch (key) {
678
+ case 'ArrowUp':
679
+ newActiveCell = up(grid, activeCellIndex);
680
+ break;
681
+ case 'ArrowDown':
682
+ newActiveCell = down(grid, activeCellIndex);
683
+ break;
684
+ case 'ArrowLeft':
685
+ newActiveCell = left(grid, activeCellIndex);
686
+ break;
687
+ case 'ArrowRight':
688
+ newActiveCell = right(grid, activeCellIndex);
689
+ break;
690
+ // no default
691
+ }
692
+ // Standard navigation withing the same view
693
+ if (newActiveCell) {
694
+ this.activeCellIndex = newActiveCell;
695
+ return;
696
+ }
697
+ }
698
+ // Jump to the next view
699
+ switch (key) {
700
+ // case 'ArrowUp': // it feels better not having Up/Down in these case
701
+ case 'ArrowLeft':
702
+ this.toPreviousView();
703
+ await this.updateComplete; // must wait until the render cycle has finished
704
+ await this.onNavigation('End');
705
+ break;
706
+ // case 'ArrowDown':
707
+ case 'ArrowRight':
708
+ this.toNextView();
709
+ await this.updateComplete;
710
+ await this.onNavigation('Home');
711
+ break;
712
+ // no default
713
+ }
714
+ }
715
+ /**
716
+ * Navigate to the next view
717
+ * @returns {void}
718
+ */
719
+ toNextView() {
720
+ let viewSegment = toDateSegment(this.view);
721
+ switch (this.renderView) {
722
+ case RenderView.DAY:
723
+ viewSegment = toDateSegment(addMonths(this.view, 1));
724
+ break;
725
+ case RenderView.MONTH:
726
+ viewSegment.year += 1;
727
+ break;
728
+ case RenderView.YEAR:
729
+ viewSegment.year += YEARS_PER_YEAR_VIEW;
730
+ break;
731
+ // no default
732
+ }
733
+ this.notifyViewChange(viewSegment);
734
+ }
735
+ /**
736
+ * Navigate to the previous view
737
+ * @returns {void}
738
+ */
739
+ toPreviousView() {
740
+ let viewSegment = toDateSegment(this.view);
741
+ switch (this.renderView) {
742
+ case RenderView.DAY:
743
+ viewSegment = toDateSegment(subMonths(this.view, 1));
744
+ break;
745
+ case RenderView.MONTH:
746
+ viewSegment.year -= 1;
747
+ break;
748
+ case RenderView.YEAR:
749
+ viewSegment.year -= YEARS_PER_YEAR_VIEW;
750
+ break;
751
+ // no default
752
+ }
753
+ this.notifyViewChange(viewSegment);
754
+ }
534
755
  /**
535
756
  * Run when tap event happened on DAY view and the cell has the values
536
757
  * Try to select/deselect cell value
@@ -543,12 +764,14 @@ let Calendar = class Calendar extends ControlElement {
543
764
  }
544
765
  let values;
545
766
  if (this.multiple) {
546
- values = this.values.filter(oldValue => {
547
- return oldValue !== value;
548
- });
549
- if (this.values.length === values.length) {
767
+ values = this.values.concat([]);
768
+ const valueIdx = this.values.indexOf(value);
769
+ if (valueIdx === -1) {
550
770
  values.push(value);
551
771
  }
772
+ else {
773
+ values.splice(valueIdx, 1);
774
+ }
552
775
  }
553
776
  else if (this.range) {
554
777
  if (!this.values.length) {
@@ -564,12 +787,16 @@ let Calendar = class Calendar extends ControlElement {
564
787
  values = [value];
565
788
  }
566
789
  }
567
- else {
790
+ else if (this.values.indexOf(value) === -1) {
568
791
  values = [value];
569
792
  }
793
+ else {
794
+ // remove range if start/end index match
795
+ values = [];
796
+ }
570
797
  }
571
798
  else {
572
- values = [value];
799
+ values = this.value === value ? [] : [value];
573
800
  }
574
801
  this.notifyValuesChange(values);
575
802
  }
@@ -613,11 +840,7 @@ let Calendar = class Calendar extends ControlElement {
613
840
  if (isIE && isBC) {
614
841
  return html `${formatLocaleDate(date, getLocale(this), includeMonth, includeEra)}`;
615
842
  }
616
- return html `${this.t('VIEW_FORMAT', {
617
- date,
618
- includeMonth,
619
- includeEra
620
- }, ViewFormatTranslateParams)}`;
843
+ return html `${this.dateT('VIEW_FORMAT', { date, includeMonth, includeEra }, ViewFormatTranslateParams)}`;
621
844
  }
622
845
  /**
623
846
  * Get a string representation of current view
@@ -640,14 +863,49 @@ let Calendar = class Calendar extends ControlElement {
640
863
  }
641
864
  }
642
865
  /**
643
- * Render cell content template.
644
- * If the cell is selectable (aka has value) add selection part
645
- * @param text Text to render
646
- * @param selectable True if cell may be selected
647
- * @returns template result
866
+ * Set an active state of the cell based
867
+ * @param rows A collection of rows with cells
868
+ * @returns {void}
648
869
  */
649
- renderContentBox(text = '', selectable = false) {
650
- return html `<div part="cell-content${selectable ? ' selection' : ''}">${text}</div>`;
870
+ setActiveCell(rows) {
871
+ const setActive = (cell) => {
872
+ if (cell) {
873
+ cell.active = true;
874
+ }
875
+ };
876
+ const columnIdx = this.activeCellIndex ? this.activeCellIndex[0] : NaN;
877
+ const rowIdx = this.activeCellIndex ? this.activeCellIndex[1] : NaN;
878
+ // Selected cell is active or today cell or first available cell
879
+ let activeCell;
880
+ let nowCell;
881
+ let firstCell;
882
+ let selectedCell;
883
+ for (let i = 0; i < rows.length; i += 1) {
884
+ const row = rows[i];
885
+ for (let e = 0; e < row.length; e += 1) {
886
+ const cell = row[e];
887
+ if (cell.disabled || !cell.value) {
888
+ continue;
889
+ }
890
+ if (i === rowIdx && e === columnIdx) {
891
+ activeCell = cell;
892
+ }
893
+ if (!selectedCell && cell.selected) {
894
+ selectedCell = cell;
895
+ }
896
+ if (cell.now) {
897
+ nowCell = cell;
898
+ }
899
+ if (!firstCell) {
900
+ firstCell = cell;
901
+ }
902
+ }
903
+ }
904
+ // If a cell that was active before last render is not available now, remove index
905
+ if (!activeCell && this.activeCellIndex) {
906
+ this.resetActiveCellIndex(); // set on private to not cause another re-render
907
+ }
908
+ setActive(activeCell || selectedCell || nowCell || firstCell);
651
909
  }
652
910
  /**
653
911
  * Get year view template
@@ -663,18 +921,18 @@ let Calendar = class Calendar extends ControlElement {
663
921
  for (let i = 0; i < YEAR_VIEW.totalCount; i += 1) {
664
922
  if (i % YEAR_VIEW.columnCount === 0) {
665
923
  cells = [];
666
- rows.push({
667
- cells
668
- });
924
+ rows.push(cells);
669
925
  }
670
926
  const year = startIdx + i;
671
927
  const value = utcFormat({ year, month: 0, day: 1 }, DateFormat.yyyyMMdd);
672
- cell = Object.assign({ view, text: year > 0 ? `${year}` : year === 0 ? '1' : `${Math.abs(year - 1)}`, value: `${year}`, now: isThisYear(value) }, this.getCellSelection(value, isSameYear));
928
+ cell = Object.assign({ view, text: year > 0 ? `${year}` : year === 0 ? '1' : `${Math.abs(year - 1)}`, value: `${year}`, now: isThisYear(value), index: [cells.length, rows.length - 1] }, this.getCellSelection(value, isSameYear));
673
929
  cells.push(cell);
674
930
  years.push(cell);
675
931
  }
676
932
  years[0].firstDate = true;
677
933
  years[years.length - 1].lastDate = true;
934
+ this.setActiveCell(rows);
935
+ this.setNavigationMap(rows);
678
936
  return html `${this.renderRows(rows)}`;
679
937
  }
680
938
  /**
@@ -686,7 +944,7 @@ let Calendar = class Calendar extends ControlElement {
686
944
  const columnCount = MONTH_VIEW.columnCount;
687
945
  const monthCount = 12;
688
946
  const totalCount = MONTH_VIEW.totalCount;
689
- const monthsNames = this.monthsNames;
947
+ const monthsNames = this.localMonthsNames;
690
948
  const before = (totalCount - monthCount) / 2;
691
949
  const startIdx = monthCount - before % monthCount;
692
950
  const after = before + monthCount;
@@ -697,21 +955,21 @@ let Calendar = class Calendar extends ControlElement {
697
955
  for (let i = 0; i < totalCount; i += 1) {
698
956
  if (i % columnCount === 0) {
699
957
  cells = [];
700
- rows.push({
701
- cells
702
- });
958
+ rows.push(cells);
703
959
  }
704
960
  const month = (startIdx + i) % monthCount; /* 0 for Jan, 11 for Dev */
705
961
  const year = currentYear + Math.floor((i - before) / monthCount);
706
962
  const segment = { year, month, day: 1 };
707
963
  const value = utcFormat(segment, DateFormat.yyyyMMdd);
708
964
  const idle = i < before || i >= after;
709
- cell = Object.assign({ view, text: monthsNames[month], value: utcFormat(segment, DateFormat.yyyyMM), idle, now: isThisMonth(value) }, this.getCellSelection(value, isSameMonth));
965
+ cell = Object.assign({ view, text: monthsNames[month], value: utcFormat(segment, DateFormat.yyyyMM), idle, now: isThisMonth(value), index: [cells.length, rows.length - 1] }, this.getCellSelection(value, isSameMonth));
710
966
  cells.push(cell);
711
967
  months.push(cell);
712
968
  }
713
969
  months[0].firstDate = true;
714
970
  months[months.length - 1].lastDate = true;
971
+ this.setActiveCell(rows);
972
+ this.setNavigationMap(rows);
715
973
  return html `${this.renderRows(rows)}`;
716
974
  }
717
975
  /**
@@ -734,15 +992,14 @@ let Calendar = class Calendar extends ControlElement {
734
992
  for (let i = 0; i < DAY_VIEW.totalCount; i += 1) {
735
993
  if (i % DAY_VIEW.columnCount === 0) {
736
994
  cells = [];
737
- rows.push({
738
- cells
739
- });
995
+ rows.push(cells);
740
996
  }
741
997
  const datePadding = i - padding + 1;
742
998
  if (datePadding <= 0) {
743
999
  if (!this.fillCells) {
744
1000
  cells.push({
745
- view
1001
+ view,
1002
+ index: [cells.length, rows.length - 1]
746
1003
  });
747
1004
  continue;
748
1005
  }
@@ -753,7 +1010,8 @@ let Calendar = class Calendar extends ControlElement {
753
1010
  else if (datePadding > viewMonth.days) {
754
1011
  if (!this.fillCells) {
755
1012
  cells.push({
756
- view
1013
+ view,
1014
+ index: [cells.length, rows.length - 1]
757
1015
  });
758
1016
  continue;
759
1017
  }
@@ -769,14 +1027,16 @@ let Calendar = class Calendar extends ControlElement {
769
1027
  const value = utcFormat({ year, month, day }, DateFormat.yyyyMMdd);
770
1028
  const disabled = this.isDateAvailable ? !this.isDateAvailable(value) : false;
771
1029
  const dayCell = Object.assign({ view, text: day.toString(), value,
772
- disabled, idle: month !== viewMonth.month || year !== viewMonth.year, now: isToday(value) }, this.getCellSelection(value, isSameDay));
1030
+ disabled, idle: month !== viewMonth.month || year !== viewMonth.year, now: isToday(value), index: [cells.length, rows.length - 1] }, this.getCellSelection(value, isSameDay));
773
1031
  cells.push(dayCell);
774
1032
  days.push(dayCell);
775
1033
  }
776
1034
  days[0].firstDate = true;
777
1035
  days[days.length - 1].lastDate = true;
1036
+ this.setActiveCell(rows);
1037
+ this.setNavigationMap(rows);
778
1038
  return html `
779
- ${this.renderWeekdayNames}
1039
+ ${guard([this.firstDayOfWeek, this.lang], () => this.renderWeekdayNames)}
780
1040
  ${this.renderRows(rows)}
781
1041
  `;
782
1042
  }
@@ -784,23 +1044,50 @@ let Calendar = class Calendar extends ControlElement {
784
1044
  * Get weekday names template
785
1045
  */
786
1046
  get renderWeekdayNames() {
1047
+ const firstDayOfWeek = this.firstDayOfWeek;
1048
+ const weekdaysNames = this.localWeekdaysNames.slice(firstDayOfWeek).concat(this.localWeekdaysNames.slice(0, firstDayOfWeek));
787
1049
  return html `
788
- <div part="row day-name-row">${this.weekdaysNames.map(day => html `<div part="cell day-name">${this.renderContentBox(day)}</div>`)}</div>
789
- `;
1050
+ <div role="row"
1051
+ part="row day-name-row">${weekdaysNames.map(day => html `
1052
+ <div scope="col" role="columnheader" part="cell day-name" abbr="${day.long}">
1053
+ <div part="cell-content">${day.narrow}</div>
1054
+ </div>
1055
+ `)}</div>`;
790
1056
  }
791
1057
  /**
792
1058
  * Render a view based on the current render view
793
1059
  */
794
1060
  get viewRender() {
1061
+ let renderView;
795
1062
  switch (this.renderView) {
796
1063
  case RenderView.MONTH:
797
- return this.monthView;
1064
+ renderView = this.monthView;
1065
+ break;
798
1066
  case RenderView.YEAR:
799
- return this.yearView;
1067
+ renderView = this.yearView;
1068
+ break;
800
1069
  case RenderView.DAY:
801
1070
  default:
802
- return this.dayView;
1071
+ renderView = this.dayView;
803
1072
  }
1073
+ return html `${cache(renderView)}`;
1074
+ }
1075
+ /**
1076
+ * Get cell translate label key based on selected state
1077
+ * @param cell Cell
1078
+ * @returns key Translate label key
1079
+ */
1080
+ getCellLabelKey(cell) {
1081
+ if (cell.selected && cell.now) {
1082
+ return 'SELECTED_NOW';
1083
+ }
1084
+ if (cell.selected) {
1085
+ return 'SELECTED';
1086
+ }
1087
+ if (cell.now) {
1088
+ return 'NOW';
1089
+ }
1090
+ return 'CELL_LABEL';
804
1091
  }
805
1092
  /**
806
1093
  * Render cell template. Cell can be a day, month or year
@@ -808,10 +1095,13 @@ let Calendar = class Calendar extends ControlElement {
808
1095
  * @returns template result
809
1096
  */
810
1097
  renderCell(cell) {
1098
+ const isSelectable = cell.value !== undefined && !cell.disabled;
811
1099
  return html `<div
1100
+ role="gridcell"
812
1101
  part="cell ${cell.view}"
1102
+ aria-selected="${ifDefined(isSelectable ? (cell.selected ? 'true' : 'false') : undefined)}"
1103
+ ?active=${cell.active}
813
1104
  ?disabled=${cell.disabled}
814
- .value=${cell.value}
815
1105
  ?idle=${cell.idle}
816
1106
  ?today=${cell.now}
817
1107
  ?first-date=${cell.firstDate}
@@ -819,9 +1109,18 @@ let Calendar = class Calendar extends ControlElement {
819
1109
  ?selected=${cell.selected}
820
1110
  ?range=${cell.range}
821
1111
  ?range-from=${cell.rangeFrom}
822
- ?range-to=${cell.rangeTo}
823
- tabindex=${ifDefined(cell.value !== undefined && !cell.disabled ? 0 : undefined)}
824
- >${this.renderContentBox(cell.text, cell.value !== undefined)}</div>`;
1112
+ ?range-to=${cell.rangeTo}>
1113
+ <div role="${ifDefined(cell.value ? 'button' : undefined)}"
1114
+ tabindex=${ifDefined(isSelectable ? (cell.active ? 0 : -1) : undefined)}
1115
+ aria-label="${ifDefined(isSelectable && !isIE ? this.t(this.getCellLabelKey(cell), {
1116
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1117
+ value: parse(cell.value),
1118
+ view: this.renderView
1119
+ }) : undefined)}"
1120
+ part="cell-content${isSelectable ? ' selection' : ''}"
1121
+ .value=${cell.value}
1122
+ .index=${cell.index}>${cell.text}</div>
1123
+ </div>`;
825
1124
  }
826
1125
  /**
827
1126
  * Render view rows
@@ -829,32 +1128,80 @@ let Calendar = class Calendar extends ControlElement {
829
1128
  * @returns template result
830
1129
  */
831
1130
  renderRows(rows) {
832
- return rows.map(row => html `<div part="row">${row.cells.map(cell => this.renderCell(cell))}</div>`);
1131
+ return rows.map(row => html `<div role="row" part="row">${row.map(cell => this.renderCell(cell))}</div>`);
833
1132
  }
834
1133
  /**
835
- * A `TemplateResult` that will be used
836
- * to render the updated internal template.
837
- * @return Render template
1134
+ * Render button navigation template
1135
+ * @returns template result
838
1136
  */
839
- render() {
840
- return html `
841
- <div part="navigation">
1137
+ get buttonNavigationTemplate() {
1138
+ let prevBtnAriaLabel = this.t('PREVIOUS_MONTH');
1139
+ let nextBtnAriaLabel = this.t('NEXT_MONTH');
1140
+ let viewBtnAriaLabel = this.t('YEAR_SELECTOR');
1141
+ switch (this.renderView) {
1142
+ case RenderView.YEAR:
1143
+ prevBtnAriaLabel = this.t('PREVIOUS_DECADE');
1144
+ nextBtnAriaLabel = this.t('NEXT_DECADE');
1145
+ viewBtnAriaLabel = this.t('DATE_SELECTOR');
1146
+ break;
1147
+ case RenderView.MONTH:
1148
+ prevBtnAriaLabel = this.t('PREVIOUS_YEAR');
1149
+ nextBtnAriaLabel = this.t('NEXT_YEAR');
1150
+ viewBtnAriaLabel = this.t('DATE_SELECTOR');
1151
+ break;
1152
+ // RenderView.DAY
1153
+ // no default
1154
+ }
1155
+ return html `<div part="navigation">
842
1156
  <ef-button
843
1157
  part="btn-prev"
1158
+ aria-label="${prevBtnAriaLabel}"
844
1159
  icon="left"
845
1160
  @tap=${this.onPreviousTap}></ef-button>
846
1161
  <ef-button
1162
+ ${ref(this.viewBtnRef)}
1163
+ aria-description="${viewBtnAriaLabel}"
847
1164
  part="btn-view"
848
1165
  textpos="before"
849
1166
  .icon="${this.renderView === RenderView.DAY ? 'down' : 'up'}"
850
1167
  @tap="${this.onRenderViewTap}">${this.formattedViewRender}</ef-button>
851
1168
  <ef-button
852
1169
  part="btn-next"
1170
+ aria-label="${nextBtnAriaLabel}"
853
1171
  icon="right"
854
1172
  @tap=${this.onNextTap}></ef-button>
855
- </div>
856
- <div part="table"
857
- @tap=${this.onTableTap}>${this.viewRender}</div>
1173
+ </div>`;
1174
+ }
1175
+ /**
1176
+ * A template used to notify currently selected value for screen readers
1177
+ * @returns template result
1178
+ */
1179
+ get selectionTemplate() {
1180
+ if (isIE || !this.announceValues) { /* IE11 has significant performance complications */
1181
+ return;
1182
+ }
1183
+ return html `<div
1184
+ part="aria-selection"
1185
+ aria-live="polite"
1186
+ aria-label="${this.value
1187
+ ? this.range
1188
+ ? this.t('SELECTED_RANGE', { from: parse(this.values[0]), to: this.values[1] ? parse(this.values[1]) : null })
1189
+ : this.t('SELECTED_DATE', { value: parse(this.value), count: this.values.length })
1190
+ : this.t('SELECTED_NONE', { multiple: this.multiple, range: this.range })}"></div>`;
1191
+ }
1192
+ /**
1193
+ * A `TemplateResult` that will be used
1194
+ * to render the updated internal template.
1195
+ * @return Render template
1196
+ */
1197
+ render() {
1198
+ return html `
1199
+ ${guard([this.values, this.lang, this.range, this.multiple, this.announceValues], () => this.selectionTemplate)}
1200
+ ${guard([this.view, this.renderView, this.lang], () => this.buttonNavigationTemplate)}
1201
+ <div role="grid"
1202
+ aria-multiselectable="${this.range || this.multiple}"
1203
+ part="table"
1204
+ @tap=${this.onTableTap}>${this.viewRender}</div>
858
1205
  <div part="footer"><slot name="footer"></slot></div>
859
1206
  `;
860
1207
  }
@@ -901,19 +1248,27 @@ __decorate([
901
1248
  __decorate([
902
1249
  property({ type: Boolean, attribute: 'fill-cells' })
903
1250
  ], Calendar.prototype, "fillCells", void 0);
1251
+ __decorate([
1252
+ translate({ mode: 'directive', scope: CalendarLocaleScope })
1253
+ ], Calendar.prototype, "dateT", void 0);
1254
+ __decorate([
1255
+ translate({ mode: 'promise', scope: CalendarLocaleScope })
1256
+ ], Calendar.prototype, "dateTPromise", void 0);
904
1257
  __decorate([
905
1258
  translate({ mode: 'directive', scope: 'ef-calendar' })
906
1259
  ], Calendar.prototype, "t", void 0);
907
1260
  __decorate([
908
- translate({ mode: 'promise', scope: 'ef-calendar' })
909
- ], Calendar.prototype, "tPromise", void 0);
1261
+ state()
1262
+ ], Calendar.prototype, "renderView", null);
910
1263
  __decorate([
911
- property({ type: String })
912
- ], Calendar.prototype, "renderView", void 0);
1264
+ state()
1265
+ ], Calendar.prototype, "activeCellIndex", null);
1266
+ __decorate([
1267
+ state()
1268
+ ], Calendar.prototype, "announceValues", void 0);
913
1269
  Calendar = __decorate([
914
1270
  customElement('ef-calendar', {
915
1271
  alias: 'coral-calendar'
916
1272
  })
917
1273
  ], Calendar);
918
1274
  export { Calendar };
919
- //# sourceMappingURL=index.js.map