igniteui-webcomponents 4.11.0 → 5.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (373) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/README.md +168 -110
  3. package/components/accordion/accordion.d.ts +2 -2
  4. package/components/accordion/accordion.js +25 -35
  5. package/components/accordion/accordion.js.map +1 -1
  6. package/components/avatar/avatar.d.ts +1 -3
  7. package/components/avatar/avatar.js +1 -3
  8. package/components/avatar/avatar.js.map +1 -1
  9. package/components/avatar/themes/avatar.base.css.js +1 -1
  10. package/components/avatar/themes/avatar.base.css.js.map +1 -1
  11. package/components/badge/badge.d.ts +2 -1
  12. package/components/badge/badge.js.map +1 -1
  13. package/components/badge/themes/badge.base.css.js +1 -1
  14. package/components/badge/themes/badge.base.css.js.map +1 -1
  15. package/components/button/button-base.d.ts +3 -4
  16. package/components/button/button-base.js +1 -9
  17. package/components/button/button-base.js.map +1 -1
  18. package/components/button/button.d.ts +3 -7
  19. package/components/button/button.js +4 -5
  20. package/components/button/button.js.map +1 -1
  21. package/components/button/icon-button.d.ts +2 -2
  22. package/components/button/icon-button.js +0 -3
  23. package/components/button/icon-button.js.map +1 -1
  24. package/components/button/themes/button/button.base.css.js +1 -1
  25. package/components/button/themes/button/button.base.css.js.map +1 -1
  26. package/components/button/themes/icon-button/icon-button.base.css.js +1 -1
  27. package/components/button/themes/icon-button/icon-button.base.css.js.map +1 -1
  28. package/components/button-group/themes/button.base.css.js +1 -1
  29. package/components/button-group/themes/button.base.css.js.map +1 -1
  30. package/components/button-group/themes/group.base.css.js +1 -1
  31. package/components/button-group/themes/group.base.css.js.map +1 -1
  32. package/components/calendar/base.d.ts +65 -0
  33. package/components/calendar/base.js +150 -0
  34. package/components/calendar/base.js.map +1 -0
  35. package/components/calendar/calendar.d.ts +113 -61
  36. package/components/calendar/calendar.js +417 -514
  37. package/components/calendar/calendar.js.map +1 -1
  38. package/components/calendar/days-view/days-view.d.ts +43 -46
  39. package/components/calendar/days-view/days-view.js +269 -340
  40. package/components/calendar/days-view/days-view.js.map +1 -1
  41. package/components/calendar/helpers.d.ts +30 -0
  42. package/components/calendar/helpers.js +99 -0
  43. package/components/calendar/helpers.js.map +1 -0
  44. package/components/calendar/model.d.ts +55 -0
  45. package/components/calendar/model.js +94 -0
  46. package/components/calendar/model.js.map +1 -0
  47. package/components/calendar/months-view/months-view.d.ts +12 -12
  48. package/components/calendar/months-view/months-view.js +72 -79
  49. package/components/calendar/months-view/months-view.js.map +1 -1
  50. package/components/calendar/themes/calendar.base.css.js +1 -1
  51. package/components/calendar/themes/calendar.base.css.js.map +1 -1
  52. package/components/calendar/types.d.ts +16 -0
  53. package/components/calendar/types.js +10 -0
  54. package/components/calendar/types.js.map +1 -0
  55. package/components/calendar/years-view/years-view.d.ts +13 -12
  56. package/components/calendar/years-view/years-view.js +58 -73
  57. package/components/calendar/years-view/years-view.js.map +1 -1
  58. package/components/card/themes/card.actions.base.css.js +1 -1
  59. package/components/card/themes/card.actions.base.css.js.map +1 -1
  60. package/components/card/themes/card.content.base.css.js +1 -1
  61. package/components/card/themes/card.content.base.css.js.map +1 -1
  62. package/components/card/themes/card.header.base.css.js +1 -1
  63. package/components/card/themes/card.header.base.css.js.map +1 -1
  64. package/components/card/themes/card.media.base.css.js +1 -1
  65. package/components/card/themes/card.media.base.css.js.map +1 -1
  66. package/components/card/themes/container.base.css.js +1 -1
  67. package/components/card/themes/container.base.css.js.map +1 -1
  68. package/components/checkbox/checkbox-base.d.ts +8 -5
  69. package/components/checkbox/checkbox-base.js +8 -15
  70. package/components/checkbox/checkbox-base.js.map +1 -1
  71. package/components/checkbox/checkbox.d.ts +2 -4
  72. package/components/checkbox/checkbox.js.map +1 -1
  73. package/components/checkbox/switch.d.ts +1 -3
  74. package/components/checkbox/switch.js.map +1 -1
  75. package/components/checkbox/themes/checkbox.base.css.js +1 -1
  76. package/components/checkbox/themes/checkbox.base.css.js.map +1 -1
  77. package/components/checkbox/themes/switch.base.css.js +1 -1
  78. package/components/checkbox/themes/switch.base.css.js.map +1 -1
  79. package/components/checkbox/validators.d.ts +3 -0
  80. package/components/checkbox/validators.js +5 -0
  81. package/components/checkbox/validators.js.map +1 -0
  82. package/components/chip/chip.d.ts +4 -3
  83. package/components/chip/chip.js +11 -19
  84. package/components/chip/chip.js.map +1 -1
  85. package/components/chip/themes/chip.base.css.js +1 -1
  86. package/components/chip/themes/chip.base.css.js.map +1 -1
  87. package/components/chip/themes/shared/chip.common.css.js +1 -1
  88. package/components/chip/themes/shared/chip.common.css.js.map +1 -1
  89. package/components/combo/combo.d.ts +36 -54
  90. package/components/combo/combo.js +36 -59
  91. package/components/combo/combo.js.map +1 -1
  92. package/components/combo/themes/combo-header.base.css.js +1 -1
  93. package/components/combo/themes/combo-header.base.css.js.map +1 -1
  94. package/components/combo/themes/combo-item.base.css.js +1 -1
  95. package/components/combo/themes/combo-item.base.css.js.map +1 -1
  96. package/components/combo/themes/combo.base.css.js +1 -1
  97. package/components/combo/themes/combo.base.css.js.map +1 -1
  98. package/components/combo/types.d.ts +2 -2
  99. package/components/combo/types.js.map +1 -1
  100. package/components/combo/validators.d.ts +3 -0
  101. package/components/combo/validators.js +9 -0
  102. package/components/combo/validators.js.map +1 -0
  103. package/components/common/controllers/key-bindings.d.ts +1 -0
  104. package/components/common/controllers/key-bindings.js.map +1 -1
  105. package/components/common/controllers/mutation-observer.d.ts +1 -0
  106. package/components/common/controllers/mutation-observer.js.map +1 -1
  107. package/components/common/controllers/root-click.d.ts +4 -2
  108. package/components/common/controllers/root-click.js +13 -7
  109. package/components/common/controllers/root-click.js.map +1 -1
  110. package/components/common/definitions/defineAllComponents.js +0 -2
  111. package/components/common/definitions/defineAllComponents.js.map +1 -1
  112. package/components/common/localization/intl-formatters.d.ts +17 -0
  113. package/components/common/localization/intl-formatters.js +46 -0
  114. package/components/common/localization/intl-formatters.js.map +1 -0
  115. package/components/common/mixins/alert.d.ts +3 -3
  116. package/components/common/mixins/alert.js +6 -4
  117. package/components/common/mixins/alert.js.map +1 -1
  118. package/components/common/mixins/combo-box.d.ts +4 -3
  119. package/components/common/mixins/combo-box.js +16 -10
  120. package/components/common/mixins/combo-box.js.map +1 -1
  121. package/components/common/mixins/form-associated.d.ts +1 -1
  122. package/components/common/mixins/form-associated.js +4 -2
  123. package/components/common/mixins/form-associated.js.map +1 -1
  124. package/components/common/util.d.ts +26 -0
  125. package/components/common/util.js +34 -0
  126. package/components/common/util.js.map +1 -1
  127. package/components/date-picker/date-picker.d.ts +7 -10
  128. package/components/date-picker/date-picker.js +16 -33
  129. package/components/date-picker/date-picker.js.map +1 -1
  130. package/components/date-picker/themes/date-picker.base.css.js +1 -1
  131. package/components/date-picker/themes/date-picker.base.css.js.map +1 -1
  132. package/components/date-picker/themes/shared/date-picker.common.css.js +1 -1
  133. package/components/date-picker/themes/shared/date-picker.common.css.js.map +1 -1
  134. package/components/date-picker/validators.d.ts +3 -0
  135. package/components/date-picker/validators.js +15 -0
  136. package/components/date-picker/validators.js.map +1 -0
  137. package/components/date-time-input/date-time-input.d.ts +3 -22
  138. package/components/date-time-input/date-time-input.js +8 -36
  139. package/components/date-time-input/date-time-input.js.map +1 -1
  140. package/components/date-time-input/date-util.js +3 -1
  141. package/components/date-time-input/date-util.js.map +1 -1
  142. package/components/date-time-input/validators.d.ts +3 -0
  143. package/components/date-time-input/validators.js +18 -0
  144. package/components/date-time-input/validators.js.map +1 -0
  145. package/components/dialog/dialog.d.ts +12 -25
  146. package/components/dialog/dialog.js +55 -77
  147. package/components/dialog/dialog.js.map +1 -1
  148. package/components/dialog/themes/dialog.base.css.js +1 -1
  149. package/components/dialog/themes/dialog.base.css.js.map +1 -1
  150. package/components/dialog/themes/shared/dialog.common.css.js +1 -1
  151. package/components/dialog/themes/shared/dialog.common.css.js.map +1 -1
  152. package/components/divider/divider.js.map +1 -1
  153. package/components/divider/themes/divider.base.css.js +1 -1
  154. package/components/divider/themes/divider.base.css.js.map +1 -1
  155. package/components/dropdown/dropdown-group.d.ts +1 -1
  156. package/components/dropdown/dropdown-group.js +5 -3
  157. package/components/dropdown/dropdown-group.js.map +1 -1
  158. package/components/dropdown/dropdown.d.ts +4 -11
  159. package/components/dropdown/dropdown.js +10 -23
  160. package/components/dropdown/dropdown.js.map +1 -1
  161. package/components/dropdown/themes/dropdown-group.base.css.js +1 -1
  162. package/components/dropdown/themes/dropdown-group.base.css.js.map +1 -1
  163. package/components/dropdown/themes/dropdown-header.base.css.js +1 -1
  164. package/components/dropdown/themes/dropdown-header.base.css.js.map +1 -1
  165. package/components/dropdown/themes/dropdown-item.base.css.js +1 -1
  166. package/components/dropdown/themes/dropdown-item.base.css.js.map +1 -1
  167. package/components/dropdown/themes/dropdown.base.css.js +1 -1
  168. package/components/dropdown/themes/dropdown.base.css.js.map +1 -1
  169. package/components/expansion-panel/expansion-panel.d.ts +10 -10
  170. package/components/expansion-panel/expansion-panel.js +39 -39
  171. package/components/expansion-panel/expansion-panel.js.map +1 -1
  172. package/components/expansion-panel/themes/expansion-panel.base.css.js +1 -1
  173. package/components/expansion-panel/themes/expansion-panel.base.css.js.map +1 -1
  174. package/components/icon/icon-references.d.ts +28 -0
  175. package/components/icon/icon-references.js +151 -0
  176. package/components/icon/icon-references.js.map +1 -0
  177. package/components/icon/icon-state.broadcast.d.ts +10 -0
  178. package/components/icon/icon-state.broadcast.js +36 -0
  179. package/components/icon/icon-state.broadcast.js.map +1 -0
  180. package/components/icon/icon.d.ts +3 -3
  181. package/components/icon/icon.js +13 -7
  182. package/components/icon/icon.js.map +1 -1
  183. package/components/icon/icon.registry.d.ts +14 -14
  184. package/components/icon/icon.registry.js +70 -26
  185. package/components/icon/icon.registry.js.map +1 -1
  186. package/components/icon/internal-icons-lib.d.ts +2 -2
  187. package/components/icon/internal-icons-lib.js +2 -2
  188. package/components/icon/internal-icons-lib.js.map +1 -1
  189. package/components/icon/registry/default-map.d.ts +12 -0
  190. package/components/icon/registry/default-map.js +31 -0
  191. package/components/icon/registry/default-map.js.map +1 -0
  192. package/components/icon/registry/parser.d.ts +6 -0
  193. package/components/icon/registry/parser.js +21 -0
  194. package/components/icon/registry/parser.js.map +1 -0
  195. package/components/icon/registry/types.d.ts +34 -0
  196. package/components/icon/registry/types.js +7 -0
  197. package/components/icon/registry/types.js.map +1 -0
  198. package/components/icon/themes/icon.base.css.js +1 -1
  199. package/components/icon/themes/icon.base.css.js.map +1 -1
  200. package/components/input/input-base.d.ts +8 -21
  201. package/components/input/input-base.js +12 -41
  202. package/components/input/input-base.js.map +1 -1
  203. package/components/input/input.d.ts +3 -29
  204. package/components/input/input.js +4 -78
  205. package/components/input/input.js.map +1 -1
  206. package/components/input/themes/input.base.css.js +1 -1
  207. package/components/input/themes/input.base.css.js.map +1 -1
  208. package/components/input/validators.d.ts +4 -0
  209. package/components/input/validators.js +30 -0
  210. package/components/input/validators.js.map +1 -0
  211. package/components/list/list.d.ts +1 -3
  212. package/components/list/list.js +1 -2
  213. package/components/list/list.js.map +1 -1
  214. package/components/list/themes/container.base.css.js +1 -1
  215. package/components/list/themes/container.base.css.js.map +1 -1
  216. package/components/mask-input/mask-input-base.d.ts +3 -2
  217. package/components/mask-input/mask-input-base.js.map +1 -1
  218. package/components/mask-input/mask-input.d.ts +1 -4
  219. package/components/mask-input/mask-input.js +7 -17
  220. package/components/mask-input/mask-input.js.map +1 -1
  221. package/components/mask-input/validators.d.ts +3 -0
  222. package/components/mask-input/validators.js +11 -0
  223. package/components/mask-input/validators.js.map +1 -0
  224. package/components/nav-drawer/nav-drawer-item.d.ts +1 -5
  225. package/components/nav-drawer/nav-drawer-item.js +9 -10
  226. package/components/nav-drawer/nav-drawer-item.js.map +1 -1
  227. package/components/nav-drawer/nav-drawer.d.ts +4 -3
  228. package/components/nav-drawer/nav-drawer.js +18 -7
  229. package/components/nav-drawer/nav-drawer.js.map +1 -1
  230. package/components/nav-drawer/themes/container.base.css.js +1 -1
  231. package/components/nav-drawer/themes/container.base.css.js.map +1 -1
  232. package/components/nav-drawer/themes/header-item.base.css.js +1 -1
  233. package/components/nav-drawer/themes/header-item.base.css.js.map +1 -1
  234. package/components/nav-drawer/themes/item.base.css.js +1 -1
  235. package/components/nav-drawer/themes/item.base.css.js.map +1 -1
  236. package/components/navbar/themes/navbar.base.css.js +1 -1
  237. package/components/navbar/themes/navbar.base.css.js.map +1 -1
  238. package/components/popover/themes/light/popover.base.css.js +1 -1
  239. package/components/popover/themes/light/popover.base.css.js.map +1 -1
  240. package/components/progress/base.d.ts +2 -1
  241. package/components/progress/base.js.map +1 -1
  242. package/components/progress/themes/circular/circular.progress.base.css.js +1 -1
  243. package/components/progress/themes/circular/circular.progress.base.css.js.map +1 -1
  244. package/components/progress/themes/linear/linear.progress.base.css.js +1 -1
  245. package/components/progress/themes/linear/linear.progress.base.css.js.map +1 -1
  246. package/components/radio/radio.d.ts +9 -9
  247. package/components/radio/radio.js +17 -31
  248. package/components/radio/radio.js.map +1 -1
  249. package/components/radio/themes/radio.base.css.js +1 -1
  250. package/components/radio/themes/radio.base.css.js.map +1 -1
  251. package/components/radio/validators.d.ts +3 -0
  252. package/components/radio/validators.js +13 -0
  253. package/components/radio/validators.js.map +1 -0
  254. package/components/radio-group/radio-group.base.css.js +1 -1
  255. package/components/radio-group/radio-group.base.css.js.map +1 -1
  256. package/components/radio-group/radio-group.js.map +1 -1
  257. package/components/rating/rating.d.ts +1 -9
  258. package/components/rating/rating.js +6 -16
  259. package/components/rating/rating.js.map +1 -1
  260. package/components/rating/themes/rating-symbol.base.css.js +1 -1
  261. package/components/rating/themes/rating-symbol.base.css.js.map +1 -1
  262. package/components/rating/themes/rating.base.css.js +1 -1
  263. package/components/rating/themes/rating.base.css.js.map +1 -1
  264. package/components/ripple/ripple.material.css.js +1 -1
  265. package/components/ripple/ripple.material.css.js.map +1 -1
  266. package/components/select/select.d.ts +5 -33
  267. package/components/select/select.js +23 -66
  268. package/components/select/select.js.map +1 -1
  269. package/components/select/themes/select.base.css.js +1 -1
  270. package/components/select/themes/select.base.css.js.map +1 -1
  271. package/components/select/validators.d.ts +3 -0
  272. package/components/select/validators.js +5 -0
  273. package/components/select/validators.js.map +1 -0
  274. package/components/slider/range-slider.d.ts +0 -16
  275. package/components/slider/range-slider.js +0 -18
  276. package/components/slider/range-slider.js.map +1 -1
  277. package/components/slider/themes/slider.base.css.js +1 -1
  278. package/components/slider/themes/slider.base.css.js.map +1 -1
  279. package/components/snackbar/snackbar.js +3 -7
  280. package/components/snackbar/snackbar.js.map +1 -1
  281. package/components/snackbar/themes/snackbar.base.css.js +1 -1
  282. package/components/snackbar/themes/snackbar.base.css.js.map +1 -1
  283. package/components/stepper/animations.d.ts +7 -1
  284. package/components/stepper/animations.js +63 -15
  285. package/components/stepper/animations.js.map +1 -1
  286. package/components/stepper/step.d.ts +3 -1
  287. package/components/stepper/step.js +17 -6
  288. package/components/stepper/step.js.map +1 -1
  289. package/components/stepper/themes/step/step.base.css.js +1 -1
  290. package/components/stepper/themes/step/step.base.css.js.map +1 -1
  291. package/components/stepper/themes/stepper/stepper.base.css.js +1 -1
  292. package/components/stepper/themes/stepper/stepper.base.css.js.map +1 -1
  293. package/components/stepper/themes/stepper/stepper.bootstrap.css.js +1 -1
  294. package/components/stepper/themes/stepper/stepper.bootstrap.css.js.map +1 -1
  295. package/components/stepper/themes/stepper/stepper.fluent.css.js +1 -1
  296. package/components/stepper/themes/stepper/stepper.fluent.css.js.map +1 -1
  297. package/components/stepper/themes/stepper/stepper.indigo.css.js +1 -1
  298. package/components/stepper/themes/stepper/stepper.indigo.css.js.map +1 -1
  299. package/components/tabs/tabs.js +2 -3
  300. package/components/tabs/tabs.js.map +1 -1
  301. package/components/tabs/themes/tab.base.css.js +1 -1
  302. package/components/tabs/themes/tab.base.css.js.map +1 -1
  303. package/components/tabs/themes/tabs.base.css.js +1 -1
  304. package/components/tabs/themes/tabs.base.css.js.map +1 -1
  305. package/components/textarea/textarea.d.ts +13 -16
  306. package/components/textarea/textarea.js +10 -12
  307. package/components/textarea/textarea.js.map +1 -1
  308. package/components/textarea/themes/textarea.base.css.js +1 -1
  309. package/components/textarea/themes/textarea.base.css.js.map +1 -1
  310. package/components/textarea/validators.d.ts +3 -0
  311. package/components/textarea/validators.js +7 -0
  312. package/components/textarea/validators.js.map +1 -0
  313. package/components/toast/themes/toast.base.css.js +1 -1
  314. package/components/toast/themes/toast.base.css.js.map +1 -1
  315. package/components/tree/themes/container.base.css.js +1 -1
  316. package/components/tree/themes/container.base.css.js.map +1 -1
  317. package/components/tree/themes/item.base.css.js +1 -1
  318. package/components/tree/themes/item.base.css.js.map +1 -1
  319. package/components/tree/tree-item.d.ts +4 -4
  320. package/components/tree/tree-item.js +11 -23
  321. package/components/tree/tree-item.js.map +1 -1
  322. package/components/tree/tree.d.ts +3 -4
  323. package/components/tree/tree.js +1 -37
  324. package/components/tree/tree.js.map +1 -1
  325. package/components/types.d.ts +3 -0
  326. package/components/types.js +2 -0
  327. package/components/types.js.map +1 -0
  328. package/custom-elements.json +30656 -31315
  329. package/igniteui-webcomponents.css-data.json +5 -928
  330. package/igniteui-webcomponents.html-data.json +4 -2699
  331. package/index.d.ts +5 -4
  332. package/index.js +2 -3
  333. package/index.js.map +1 -1
  334. package/package.json +1 -1
  335. package/theming/config.js +3 -3
  336. package/theming/config.js.map +1 -1
  337. package/theming/theming-controller.d.ts +4 -6
  338. package/theming/theming-controller.js +30 -34
  339. package/theming/theming-controller.js.map +1 -1
  340. package/theming/theming-decorator.d.ts +29 -11
  341. package/theming/theming-decorator.js +21 -7
  342. package/theming/theming-decorator.js.map +1 -1
  343. package/theming/theming-event.js.map +1 -1
  344. package/theming/types.d.ts +5 -0
  345. package/theming/types.js.map +1 -1
  346. package/theming/utils.d.ts +1 -1
  347. package/theming/utils.js +8 -8
  348. package/theming/utils.js.map +1 -1
  349. package/web-types.json +12 -7621
  350. package/components/calendar/common/calendar-base.d.ts +0 -40
  351. package/components/calendar/common/calendar-base.js +0 -118
  352. package/components/calendar/common/calendar-base.js.map +0 -1
  353. package/components/calendar/common/calendar.model.d.ts +0 -128
  354. package/components/calendar/common/calendar.model.js +0 -246
  355. package/components/calendar/common/calendar.model.js.map +0 -1
  356. package/components/calendar/common/utils.d.ts +0 -12
  357. package/components/calendar/common/utils.js +0 -54
  358. package/components/calendar/common/utils.js.map +0 -1
  359. package/components/common/decorators/alternateName.d.ts +0 -7
  360. package/components/common/decorators/alternateName.js +0 -4
  361. package/components/common/decorators/alternateName.js.map +0 -1
  362. package/components/common/decorators/blazorSuppress.d.ts +0 -5
  363. package/components/common/decorators/blazorSuppress.js +0 -4
  364. package/components/common/decorators/blazorSuppress.js.map +0 -1
  365. package/components/common/decorators/blazorTwoWayBind.d.ts +0 -7
  366. package/components/common/decorators/blazorTwoWayBind.js +0 -4
  367. package/components/common/decorators/blazorTwoWayBind.js.map +0 -1
  368. package/components/common/mixins/sizable.d.ts +0 -13
  369. package/components/common/mixins/sizable.js +0 -27
  370. package/components/common/mixins/sizable.js.map +0 -1
  371. package/components/form/form.d.ts +0 -48
  372. package/components/form/form.js +0 -158
  373. package/components/form/form.js.map +0 -1
@@ -5,598 +5,499 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  var IgcCalendarComponent_1;
8
- import { html } from 'lit';
8
+ import { html, nothing } from 'lit';
9
9
  import { property, query, queryAll, state } from 'lit/decorators.js';
10
+ import { choose } from 'lit/directives/choose.js';
11
+ import { createRef, ref } from 'lit/directives/ref.js';
10
12
  import { styleMap } from 'lit/directives/style-map.js';
11
- import { themeSymbol, themes } from '../../theming/theming-decorator.js';
13
+ import { themes } from '../../theming/theming-decorator.js';
14
+ import { addKeybindings, arrowDown, arrowLeft, arrowRight, arrowUp, endKey, homeKey, pageDownKey, pageUpKey, shiftKey, } from '../common/controllers/key-bindings.js';
12
15
  import { watch } from '../common/decorators/watch.js';
13
16
  import { registerComponent } from '../common/definitions/register.js';
14
- import { IgcCalendarResourceStringEN, } from '../common/i18n/calendar.resources.js';
17
+ import { IgcCalendarResourceStringEN } from '../common/i18n/calendar.resources.js';
18
+ import { createDateTimeFormatters } from '../common/localization/intl-formatters.js';
15
19
  import { EventEmitterMixin } from '../common/mixins/event-emitter.js';
16
- import { SizableMixin } from '../common/mixins/sizable.js';
17
- import { partNameMap } from '../common/util.js';
20
+ import { clamp, findElementFromEventPath, first, formatString, last, partNameMap, } from '../common/util.js';
18
21
  import IgcIconComponent from '../icon/icon.js';
19
- import { IgcCalendarBaseComponent, MONTHS_PER_ROW, YEARS_PER_ROW, } from './common/calendar-base.js';
20
- import { TimeDeltaInterval, } from './common/calendar.model.js';
21
- import { calculateYearsRangeStart, setDateSafe } from './common/utils.js';
22
+ import { IgcCalendarBaseComponent } from './base.js';
22
23
  import IgcDaysViewComponent from './days-view/days-view.js';
24
+ import { MONTHS_PER_ROW, YEARS_PER_PAGE, YEARS_PER_ROW, areSameMonth, getYearRange, isDateInRanges, } from './helpers.js';
25
+ import { CalendarDay } from './model.js';
23
26
  import IgcMonthsViewComponent from './months-view/months-view.js';
24
27
  import { styles } from './themes/calendar.base.css.js';
25
28
  import { all } from './themes/calendar.js';
26
29
  import IgcYearsViewComponent from './years-view/years-view.js';
27
30
  export const focusActiveDate = Symbol();
28
- let IgcCalendarComponent = IgcCalendarComponent_1 = class IgcCalendarComponent extends SizableMixin(EventEmitterMixin(IgcCalendarBaseComponent)) {
31
+ let IgcCalendarComponent = IgcCalendarComponent_1 = class IgcCalendarComponent extends EventEmitterMixin(IgcCalendarBaseComponent) {
29
32
  static register() {
30
33
  registerComponent(IgcCalendarComponent_1, IgcIconComponent, IgcDaysViewComponent, IgcMonthsViewComponent, IgcYearsViewComponent);
31
34
  }
32
- formattersChange() {
33
- this.initFormatters();
35
+ get _isDayView() {
36
+ return this.activeView === 'days';
34
37
  }
35
- constructor() {
36
- super();
37
- this.activeDaysViewIndex = 0;
38
- this.hideOutsideDays = false;
39
- this.hideHeader = false;
40
- this.headerOrientation = 'horizontal';
41
- this.orientation = 'horizontal';
42
- this.visibleMonths = 1;
43
- this.activeView = 'days';
44
- this.formatOptions = {
45
- month: 'long',
46
- weekday: 'narrow',
47
- };
48
- this.resourceStrings = IgcCalendarResourceStringEN;
49
- this.handleKeyDown = (event) => {
50
- const tagName = event.target.tagName.toLowerCase();
51
- if (tagName !== 'igc-days-view' &&
52
- tagName !== 'igc-months-view' &&
53
- tagName !== 'igc-years-view') {
54
- return;
55
- }
56
- switch (event.key) {
57
- case 'PageDown':
58
- event.preventDefault();
59
- if (event.shiftKey && this.activeView === 'days') {
60
- this.nextYear();
61
- }
62
- else {
63
- this.navigateNext();
64
- }
65
- if (this.activeView === 'days') {
66
- this[focusActiveDate]();
67
- }
68
- break;
69
- case 'PageUp':
70
- event.preventDefault();
71
- if (event.shiftKey && this.activeView === 'days') {
72
- this.previousYear();
73
- }
74
- else {
75
- this.navigatePrevious();
76
- }
77
- if (this.activeView === 'days') {
78
- this[focusActiveDate]();
79
- }
80
- break;
81
- case 'Home':
82
- event.preventDefault();
83
- if (this.activeView === 'days') {
84
- const firstDaysView = this.daysViews[0];
85
- const activeDate = firstDaysView.activeDate;
86
- const date = new Date(activeDate);
87
- date.setDate(1);
88
- this.activeDate = date;
89
- this.activeDaysViewIndex = 0;
90
- }
91
- else if (this.activeView === 'months') {
92
- const date = new Date(this.activeDate);
93
- date.setMonth(0);
94
- this.activeDate = date;
95
- }
96
- else if (this.activeView === 'years') {
97
- const startYear = calculateYearsRangeStart(this.activeDate, this.yearPerPage);
98
- const date = new Date(this.activeDate);
99
- date.setDate(1);
100
- date.setFullYear(startYear);
101
- setDateSafe(date, this.activeDate.getDate());
102
- this.activeDate = date;
103
- }
104
- this[focusActiveDate]();
105
- break;
106
- case 'End':
107
- event.preventDefault();
108
- if (this.activeView === 'days') {
109
- const index = this.daysViews.length - 1;
110
- const lastDaysView = this.daysViews[index];
111
- const activeDate = lastDaysView.activeDate;
112
- const date = new Date(activeDate);
113
- date.setDate(1);
114
- date.setMonth(date.getMonth() + 1);
115
- date.setDate(0);
116
- this.activeDate = date;
117
- this.activeDaysViewIndex = index;
118
- }
119
- else if (this.activeView === 'months') {
120
- const date = new Date(this.activeDate);
121
- date.setMonth(11);
122
- this.activeDate = date;
123
- }
124
- else if (this.activeView === 'years') {
125
- const startYear = calculateYearsRangeStart(this.activeDate, this.yearPerPage);
126
- const date = new Date(this.activeDate);
127
- date.setDate(1);
128
- date.setFullYear(startYear + this.yearPerPage - 1);
129
- setDateSafe(date, this.activeDate.getDate());
130
- this.activeDate = date;
131
- }
132
- this[focusActiveDate]();
133
- break;
134
- case 'ArrowLeft':
135
- event.preventDefault();
136
- if (this.activeView === 'days') {
137
- const date = this.calendarModel.timedelta(this.activeDate, TimeDeltaInterval.Day, -1);
138
- if (this.visibleMonths > 1) {
139
- const activeDayView = this.daysViews[this.activeDaysViewIndex];
140
- const activeMonthDate = activeDayView.activeDate;
141
- if (activeMonthDate.getMonth() !== date.getMonth()) {
142
- this.activeDaysViewIndex =
143
- this.activeDaysViewIndex > 0 ? this.activeDaysViewIndex - 1 : 0;
144
- }
145
- }
146
- this.activeDate = date;
147
- }
148
- else if (this.activeView === 'months') {
149
- this.previousMonth();
150
- }
151
- else if (this.activeView === 'years') {
152
- this.previousYear();
153
- }
154
- this[focusActiveDate]();
155
- break;
156
- case 'ArrowRight':
157
- event.preventDefault();
158
- if (this.activeView === 'days') {
159
- const date = this.calendarModel.timedelta(this.activeDate, TimeDeltaInterval.Day, 1);
160
- if (this.visibleMonths > 1) {
161
- const activeDayView = this.daysViews[this.activeDaysViewIndex];
162
- const activeMonthDate = activeDayView.activeDate;
163
- if (activeMonthDate.getMonth() !== date.getMonth()) {
164
- this.activeDaysViewIndex =
165
- this.activeDaysViewIndex === this.visibleMonths - 1
166
- ? this.activeDaysViewIndex
167
- : this.activeDaysViewIndex + 1;
168
- }
169
- }
170
- this.activeDate = date;
171
- }
172
- else if (this.activeView === 'months') {
173
- this.nextMonth();
174
- }
175
- else if (this.activeView === 'years') {
176
- this.nextYear();
177
- }
178
- this[focusActiveDate]();
179
- break;
180
- case 'ArrowUp':
181
- event.preventDefault();
182
- if (this.activeView === 'days') {
183
- const date = this.calendarModel.timedelta(this.activeDate, TimeDeltaInterval.Week, -1);
184
- if (this.visibleMonths > 1) {
185
- const activeDayView = this.daysViews[this.activeDaysViewIndex];
186
- const activeMonthDate = activeDayView.activeDate;
187
- if (activeMonthDate.getMonth() !== date.getMonth()) {
188
- this.activeDaysViewIndex =
189
- this.activeDaysViewIndex > 0 ? this.activeDaysViewIndex - 1 : 0;
190
- }
191
- }
192
- this.activeDate = date;
193
- }
194
- else if (this.activeView === 'months') {
195
- this.activeDate = this.calendarModel.timedelta(this.activeDate, TimeDeltaInterval.Month, -MONTHS_PER_ROW);
196
- }
197
- else if (this.activeView === 'years') {
198
- this.activeDate = this.calendarModel.timedelta(this.activeDate, TimeDeltaInterval.Year, -YEARS_PER_ROW);
199
- }
200
- this[focusActiveDate]();
201
- break;
202
- case 'ArrowDown':
203
- event.preventDefault();
204
- if (this.activeView === 'days') {
205
- const date = this.calendarModel.timedelta(this.activeDate, TimeDeltaInterval.Week, 1);
206
- if (this.visibleMonths > 1) {
207
- const activeDayView = this.daysViews[this.activeDaysViewIndex];
208
- const activeMonthDate = activeDayView.activeDate;
209
- if (activeMonthDate.getMonth() !== date.getMonth()) {
210
- this.activeDaysViewIndex =
211
- this.activeDaysViewIndex === this.visibleMonths - 1
212
- ? this.activeDaysViewIndex
213
- : this.activeDaysViewIndex + 1;
214
- }
215
- }
216
- this.activeDate = date;
217
- }
218
- else if (this.activeView === 'months') {
219
- this.activeDate = this.calendarModel.timedelta(this.activeDate, TimeDeltaInterval.Month, MONTHS_PER_ROW);
220
- }
221
- else if (this.activeView === 'years') {
222
- this.activeDate = this.calendarModel.timedelta(this.activeDate, TimeDeltaInterval.Year, YEARS_PER_ROW);
223
- }
224
- this[focusActiveDate]();
225
- break;
226
- }
227
- };
228
- this.initFormatters();
38
+ get _isMonthView() {
39
+ return this.activeView === 'months';
229
40
  }
230
- get yearPerPage() {
231
- return this.size === 'small' ? 18 : 15;
41
+ get _isYearView() {
42
+ return this.activeView === 'years';
232
43
  }
233
44
  get previousButtonLabel() {
234
- return this.activeView === 'days'
235
- ? this.resourceStrings.previousMonth
236
- : this.activeView === 'months'
237
- ? this.resourceStrings.previousYear
238
- : this.activeView === 'years'
239
- ? this.resourceStrings.previousYears.replace('{0}', this.yearPerPage.toString())
240
- : '';
45
+ if (this._isDayView) {
46
+ return this.resourceStrings.previousMonth;
47
+ }
48
+ if (this._isMonthView) {
49
+ return this.resourceStrings.previousYear;
50
+ }
51
+ return formatString(this.resourceStrings.previousYears, YEARS_PER_PAGE);
241
52
  }
242
53
  get nextButtonLabel() {
243
- return this.activeView === 'days'
244
- ? this.resourceStrings.nextMonth
245
- : this.activeView === 'months'
246
- ? this.resourceStrings.nextYear
247
- : this.activeView === 'years'
248
- ? this.resourceStrings.nextYears.replace('{0}', this.yearPerPage.toString())
249
- : '';
250
- }
251
- monthSelectLabel(activeDate) {
252
- return `${activeDate.toLocaleString(this.locale, {
253
- month: 'long',
254
- })}, ${this.resourceStrings.selectMonth}`;
255
- }
256
- yearSelectLabel(activeDate) {
257
- return `${activeDate.getFullYear()}, ${this.resourceStrings.selectYear}`;
54
+ if (this._isDayView) {
55
+ return this.resourceStrings.nextMonth;
56
+ }
57
+ if (this._isMonthView) {
58
+ return this.resourceStrings.nextYear;
59
+ }
60
+ return formatString(this.resourceStrings.nextYears, YEARS_PER_PAGE);
61
+ }
62
+ localeChange() {
63
+ this._intl.locale = this.locale;
64
+ }
65
+ formatOptionsChange() {
66
+ this._intl.update({
67
+ month: {
68
+ month: this.formatOptions.month,
69
+ },
70
+ });
258
71
  }
259
72
  async [focusActiveDate]() {
260
73
  await this.updateComplete;
261
- if (this.activeView === 'days') {
262
- const daysView = this.daysViews[this.activeDaysViewIndex];
263
- daysView.focusActiveDate();
74
+ if (this._isDayView) {
75
+ return this.daysViews.item(this.activeDaysViewIndex).focusActiveDate();
264
76
  }
265
- else if (this.activeView === 'months') {
266
- this.monthsView.focusActiveDate();
77
+ if (this._isMonthView) {
78
+ return this.monthsView.focusActiveDate();
267
79
  }
268
- else if (this.activeView === 'years') {
269
- this.yearsView.focusActiveDate();
80
+ if (this._isYearView) {
81
+ return this.yearsView.focusActiveDate();
270
82
  }
271
83
  }
272
- initFormatters() {
273
- this.formatterMonth = new Intl.DateTimeFormat(this.locale, {
274
- month: this.formatOptions.month,
275
- });
276
- this.formatterWeekday = new Intl.DateTimeFormat(this.locale, {
277
- weekday: 'short',
278
- });
279
- this.formatterMonthDay = new Intl.DateTimeFormat(this.locale, {
280
- month: 'short',
281
- day: 'numeric',
282
- });
84
+ updateViewIndex(date, delta) {
85
+ if (this.visibleMonths === 1)
86
+ return;
87
+ const index = this.activeDaysViewIndex;
88
+ const view = CalendarDay.from(this.daysViews.item(index).activeDate);
89
+ if (date.month !== view.month) {
90
+ this.activeDaysViewIndex = clamp(index + delta, 0, this.visibleMonths - 1);
91
+ }
283
92
  }
284
- formattedMonth(value) {
285
- return this.formatterMonth.format(value);
93
+ getSubsequentActiveDate(start, delta) {
94
+ const disabled = this._disabledDates;
95
+ let beginning = start.clone();
96
+ while (isDateInRanges(beginning, disabled)) {
97
+ beginning = beginning.add('day', delta);
98
+ }
99
+ return beginning;
286
100
  }
287
- changeValue(event) {
288
- event.stopPropagation();
289
- const daysView = event.target;
290
- let newValue;
291
- if (this.selection === 'single') {
292
- this.value = daysView.value;
293
- newValue = this.value;
101
+ handleArrowKey(period, delta) {
102
+ if (this._isDayView) {
103
+ const date = this.getSubsequentActiveDate(this._activeDate.add(period, delta), delta);
104
+ this.updateViewIndex(date, delta);
105
+ this._activeDate = date;
294
106
  }
295
107
  else {
296
- this.values = daysView.values;
297
- newValue = this.values;
108
+ const monthOrYear = this._isMonthView ? 'month' : 'year';
109
+ const monthOrYearDelta = (this._isMonthView ? MONTHS_PER_ROW : YEARS_PER_ROW) * delta;
110
+ this._activeDate = this.getSubsequentActiveDate(this._activeDate.add(monthOrYear, period === 'week' ? monthOrYearDelta : delta), delta);
298
111
  }
299
- this.emitEvent('igcChange', { detail: newValue });
300
- }
301
- changeMonth(event) {
302
- event.stopPropagation();
303
- this.activeDate = event.target.value;
304
- this.activeView = 'days';
305
112
  this[focusActiveDate]();
306
113
  }
307
- changeYear(event) {
308
- event.stopPropagation();
309
- this.activeDate = event.target.value;
310
- this.activeView = 'months';
114
+ onPageKeys(delta) {
115
+ const unit = this._isDayView ? 'month' : 'year';
116
+ const increment = (this._isYearView ? YEARS_PER_PAGE : 1) * delta;
117
+ this._activeDate = this.getSubsequentActiveDate(this._activeDate.add(unit, increment), increment);
311
118
  this[focusActiveDate]();
312
119
  }
313
- async switchToMonths(daysViewIndex) {
314
- this.activateDaysView(daysViewIndex);
315
- this.activeView = 'months';
316
- await this.updateComplete;
317
- this[focusActiveDate]();
120
+ onShiftPageKeys(delta) {
121
+ if (this._isDayView) {
122
+ this._activeDate = this.getSubsequentActiveDate(this._activeDate.add('year', delta), delta);
123
+ this[focusActiveDate]();
124
+ }
318
125
  }
319
- async switchToYears(daysViewIndex) {
320
- if (this.activeView === 'days') {
321
- this.activateDaysView(daysViewIndex);
126
+ onHomeKey() {
127
+ if (this._isDayView) {
128
+ const first = CalendarDay.from(this.daysViews.item(0).activeDate);
129
+ this._activeDate = this.getSubsequentActiveDate(first.set({ date: 1 }), 1);
130
+ this.activeDaysViewIndex = 0;
131
+ }
132
+ if (this._isMonthView) {
133
+ this._activeDate = this.getSubsequentActiveDate(this._activeDate.set({ month: 0 }), 1);
134
+ }
135
+ if (this._isYearView) {
136
+ this._activeDate = this.getSubsequentActiveDate(this._activeDate.set({
137
+ year: getYearRange(this._activeDate, YEARS_PER_PAGE).start,
138
+ }), 1);
322
139
  }
323
- this.activeView = 'years';
324
- await this.updateComplete;
325
140
  this[focusActiveDate]();
326
141
  }
327
- activateDaysView(daysViewIndex) {
328
- const activeDaysView = this.daysViews[daysViewIndex];
329
- this.activeDate = activeDaysView.activeDate;
330
- this.activeDaysViewIndex = daysViewIndex;
331
- }
332
- activeDateChanged(event) {
333
- const day = event.detail;
334
- const daysViews = Array.from(this.daysViews);
335
- this.activeDaysViewIndex = daysViews.indexOf(event.target);
336
- this.activeDate = day.date;
337
- if (!day.isCurrentMonth) {
338
- this[focusActiveDate]();
142
+ onEndKey() {
143
+ if (this._isDayView) {
144
+ const index = this.daysViews.length - 1;
145
+ const last = CalendarDay.from(this.daysViews.item(index).activeDate);
146
+ this._activeDate = this.getSubsequentActiveDate(last.set({ month: last.month + 1, date: 0 }), -1);
147
+ this.activeDaysViewIndex = index;
339
148
  }
149
+ if (this._isMonthView) {
150
+ this._activeDate = this.getSubsequentActiveDate(this._activeDate.set({ month: 11 }), -1);
151
+ }
152
+ if (this._isYearView) {
153
+ this._activeDate = this.getSubsequentActiveDate(this._activeDate.set({
154
+ year: getYearRange(this._activeDate, YEARS_PER_PAGE).end,
155
+ }), -1);
156
+ }
157
+ this[focusActiveDate]();
340
158
  }
341
- rangePreviewDateChange(event) {
342
- this.rangePreviewDate = event.detail;
343
- }
344
- nextMonth() {
345
- this.activeDate = this.calendarModel.getNextMonth(this.activeDate);
346
- }
347
- previousMonth() {
348
- this.activeDate = this.calendarModel.getPrevMonth(this.activeDate);
349
- }
350
- nextYear() {
351
- this.activeDate = this.calendarModel.getNextYear(this.activeDate);
159
+ isNotFromCalendarView(_, event) {
160
+ return !findElementFromEventPath(`${IgcDaysViewComponent.tagName}, ${IgcMonthsViewComponent.tagName}, ${IgcYearsViewComponent.tagName}`, event);
352
161
  }
353
- previousYear() {
354
- this.activeDate = this.calendarModel.getPrevYear(this.activeDate);
162
+ constructor() {
163
+ super();
164
+ this.contentRef = createRef();
165
+ this.activeDaysViewIndex = 0;
166
+ this.hideOutsideDays = false;
167
+ this.hideHeader = false;
168
+ this.headerOrientation = 'horizontal';
169
+ this.orientation = 'horizontal';
170
+ this.visibleMonths = 1;
171
+ this.activeView = 'days';
172
+ this.formatOptions = { month: 'long', weekday: 'narrow' };
173
+ this.resourceStrings = IgcCalendarResourceStringEN;
174
+ this._intl = createDateTimeFormatters(this.locale, {
175
+ month: {
176
+ month: this.formatOptions.month,
177
+ },
178
+ monthLabel: { month: 'long' },
179
+ weekday: { weekday: 'short' },
180
+ monthDay: { month: 'short', day: 'numeric' },
181
+ yearLabel: { month: 'long', year: 'numeric' },
182
+ });
183
+ addKeybindings(this, {
184
+ skip: this.isNotFromCalendarView,
185
+ ref: this.contentRef,
186
+ bindingDefaults: { preventDefault: true, triggers: ['keydownRepeat'] },
187
+ })
188
+ .set(arrowLeft, this.handleArrowKey.bind(this, 'day', -1))
189
+ .set(arrowRight, this.handleArrowKey.bind(this, 'day', 1))
190
+ .set(arrowUp, this.handleArrowKey.bind(this, 'week', -1))
191
+ .set(arrowDown, this.handleArrowKey.bind(this, 'week', 1))
192
+ .set([shiftKey, pageUpKey], this.onShiftPageKeys.bind(this, -1))
193
+ .set([shiftKey, pageDownKey], this.onShiftPageKeys.bind(this, 1))
194
+ .set(pageUpKey, this.onPageKeys.bind(this, -1))
195
+ .set(pageDownKey, this.onPageKeys.bind(this, 1))
196
+ .set(homeKey, this.onHomeKey)
197
+ .set(endKey, this.onEndKey);
355
198
  }
356
- nextYearsPage() {
357
- this.activeDate = this.calendarModel.timedelta(this.activeDate, TimeDeltaInterval.Year, this.yearPerPage);
199
+ renderNavigationButtons() {
200
+ const parts = partNameMap({
201
+ 'navigation-button': true,
202
+ vertical: this.orientation === 'vertical',
203
+ });
204
+ return html `
205
+ <div part="navigation-buttons">
206
+ <button
207
+ part=${parts}
208
+ aria-label=${this.previousButtonLabel}
209
+ @click=${this.navigatePrevious}
210
+ >
211
+ <igc-icon
212
+ aria-hidden="true"
213
+ name="arrow_prev"
214
+ collection="default"
215
+ ></igc-icon>
216
+ </button>
217
+
218
+ <button
219
+ part=${parts}
220
+ aria-label=${this.nextButtonLabel}
221
+ @click=${this.navigateNext}
222
+ >
223
+ <igc-icon
224
+ aria-hidden="true"
225
+ name="arrow_next"
226
+ collection="default"
227
+ ></igc-icon>
228
+ </button>
229
+ </div>
230
+ `;
358
231
  }
359
- previousYearsPage() {
360
- this.activeDate = this.calendarModel.timedelta(this.activeDate, TimeDeltaInterval.Year, -this.yearPerPage);
232
+ renderMonthButtonNavigation(active, viewIndex) {
233
+ const labelFmt = this._intl.get('monthLabel').format;
234
+ const valueFmt = this._intl.get('month').format;
235
+ const ariaLabel = `${labelFmt(active.native)}, ${this.resourceStrings.selectMonth}`;
236
+ return html `
237
+ <button
238
+ part="months-navigation"
239
+ aria-label=${ariaLabel}
240
+ @click=${() => this.switchToMonths(viewIndex)}
241
+ >
242
+ ${valueFmt(active.native)}
243
+ </button>
244
+ `;
361
245
  }
362
- navigateNext() {
363
- if (this.activeView === 'days') {
364
- this.nextMonth();
365
- }
366
- else if (this.activeView === 'months') {
367
- this.nextYear();
368
- }
369
- else if (this.activeView === 'years') {
370
- this.nextYearsPage();
371
- }
246
+ renderYearButtonNavigation(active, viewIndex) {
247
+ const fmt = this._intl.get('yearLabel').format;
248
+ const ariaLabel = `${active.year}, ${this.resourceStrings.selectYear}`;
249
+ const ariaSkip = this._isDayView ? fmt(active.native) : active.year;
250
+ return html `
251
+ <span class="aria-off-screen" aria-live="polite">${ariaSkip}</span>
252
+ <button
253
+ part="years-navigation"
254
+ aria-label=${ariaLabel}
255
+ @click=${() => this.switchToYears(viewIndex)}
256
+ >
257
+ ${active.year}
258
+ </button>
259
+ `;
372
260
  }
373
- navigatePrevious() {
374
- if (this.activeView === 'days') {
375
- this.previousMonth();
376
- }
377
- else if (this.activeView === 'months') {
378
- this.previousYear();
379
- }
380
- else if (this.activeView === 'years') {
381
- this.previousYearsPage();
382
- }
261
+ renderYearRangeNavigation(active) {
262
+ const { start, end } = getYearRange(active, YEARS_PER_PAGE);
263
+ return html `
264
+ <span part="years-range" aria-live="polite"> ${start} - ${end} </span>
265
+ `;
383
266
  }
384
- renderNavigation(activeDate = this.activeDate, renderButtons = true, daysViewIndex = 0) {
385
- let startYear = undefined;
386
- let endYear = undefined;
387
- const prev_icon = this[themeSymbol] === 'fluent' ? 'arrow_upward' : 'navigate_before';
388
- const next_icon = this[themeSymbol] === 'fluent' ? 'arrow_downward' : 'navigate_next';
389
- if (this.activeView === 'years') {
390
- startYear = calculateYearsRangeStart(activeDate, this.yearPerPage);
391
- endYear = startYear + this.yearPerPage - 1;
392
- }
393
- return html `<div part="navigation">
394
- <div part="picker-dates">
395
- ${this.activeView === 'days'
396
- ? html `<button
397
- part="months-navigation"
398
- aria-label=${this.monthSelectLabel(activeDate)}
399
- @click=${() => this.switchToMonths(daysViewIndex)}
400
- >
401
- ${this.formattedMonth(activeDate)}
402
- </button>`
403
- : ''}
404
- ${this.activeView === 'days' || this.activeView === 'months'
405
- ? html `<span class="aria-off-screen" aria-live="polite">
406
- ${this.activeView === 'days'
407
- ? activeDate.toLocaleString(this.locale, {
408
- month: 'long',
409
- year: 'numeric',
410
- })
411
- : activeDate.getFullYear()}
412
- </span>
413
- <button
414
- part="years-navigation"
415
- aria-label=${this.yearSelectLabel(activeDate)}
416
- @click=${() => this.switchToYears(daysViewIndex)}
417
- >
418
- ${activeDate.getFullYear()}
419
- </button>`
420
- : ''}
421
- ${this.activeView === 'years'
422
- ? html `<span part="years-range" aria-live="polite"
423
- >${`${startYear} - ${endYear}`}</span
424
- >`
425
- : ''}
267
+ renderNavigation(date, showButtons = true, viewIndex = 0) {
268
+ const activeDate = date ?? this._activeDate;
269
+ return html `
270
+ <div part="navigation">
271
+ <div part="picker-dates">
272
+ ${this._isDayView
273
+ ? this.renderMonthButtonNavigation(activeDate, viewIndex)
274
+ : nothing}
275
+ ${this._isDayView || this._isMonthView
276
+ ? this.renderYearButtonNavigation(activeDate, viewIndex)
277
+ : nothing}
278
+ ${this._isYearView
279
+ ? this.renderYearRangeNavigation(activeDate)
280
+ : nothing}
281
+ </div>
282
+ ${showButtons ? this.renderNavigationButtons() : nothing}
426
283
  </div>
427
- ${renderButtons
428
- ? html `<div part="navigation-buttons">
429
- <button
430
- part=${partNameMap({
431
- 'navigation-button': true,
432
- vertical: this.orientation === 'vertical',
433
- })}
434
- aria-label=${this.previousButtonLabel}
435
- @click=${this.navigatePrevious}
436
- >
437
- <igc-icon
438
- aria-hidden="true"
439
- name=${prev_icon}
440
- collection="internal"
441
- ></igc-icon>
442
- </button>
443
- <button
444
- part=${partNameMap({
445
- 'navigation-button': true,
446
- vertical: this.orientation === 'vertical',
447
- })}
448
- aria-label=${this.nextButtonLabel}
449
- @click=${this.navigateNext}
450
- >
451
- <igc-icon
452
- aria-hidden="true"
453
- name=${next_icon}
454
- collection="internal"
455
- ></igc-icon>
456
- </button>
457
- </div>`
458
- : ''}
459
- </div>`;
284
+ `;
460
285
  }
461
286
  renderHeader() {
462
- if (this.hideHeader || this.selection === 'multiple') {
463
- return '';
287
+ if (this.hideHeader || this._isMultiple) {
288
+ return nothing;
464
289
  }
465
- return html `<div part="header">
466
- <h5 part="header-title">
467
- <slot name="title"
468
- >${this.selection === 'single'
290
+ const title = this._isSingle
469
291
  ? this.resourceStrings.selectDate
470
- : this.resourceStrings.selectRange}</slot
471
- >
472
- </h5>
473
- <h2 part="header-date">${this.renderHeaderDate()}</h2>
474
- </div>`;
292
+ : this.resourceStrings.selectRange;
293
+ return html `
294
+ <div part="header">
295
+ <h5 part="header-title">
296
+ <slot name="title">${title}</slot>
297
+ </h5>
298
+ <h2 part="header-date">${this.renderHeaderDate()}</h2>
299
+ </div>
300
+ `;
475
301
  }
476
- renderHeaderDate() {
477
- if (this.selection === 'single') {
478
- const date = this.value;
479
- return html `${date
480
- ? html `${this.formatterWeekday.format(date)},${this
481
- .headerOrientation === 'vertical'
482
- ? html `<br />`
483
- : ' '}${this.formatterMonthDay.format(date)}`
484
- : this.resourceStrings.selectedDate}`;
485
- }
486
- const dates = this.values;
487
- return html `<span
488
- >${dates?.length
489
- ? this.formatterMonthDay.format(dates[0])
490
- : this.resourceStrings.startDate}</span
491
- >
302
+ renderHeaderDateSingle() {
303
+ const date = this.value;
304
+ const weekDayFmt = this._intl.get('weekday').format;
305
+ const monthDayFmt = this._intl.get('monthDay').format;
306
+ const separator = this.headerOrientation === 'vertical' ? html `<br />` : ' ';
307
+ return date
308
+ ? html `${weekDayFmt(date)},${separator}${monthDayFmt(date)}`
309
+ : this.resourceStrings.selectedDate;
310
+ }
311
+ renderHeaderDateRange() {
312
+ const values = this.values;
313
+ const fmt = this._intl.get('monthDay').format;
314
+ const { startDate, endDate } = this.resourceStrings;
315
+ const start = this._hasValues ? fmt(first(values)) : startDate;
316
+ const end = this._hasValues && values.length > 1 ? fmt(last(values)) : endDate;
317
+ return html `
318
+ <span>${start}</span>
492
319
  <span> - </span>
493
- <span
494
- >${dates && dates.length > 1
495
- ? this.formatterMonthDay.format(dates[dates.length - 1])
496
- : this.resourceStrings.endDate}</span
497
- >`;
320
+ <span>${end}</span>
321
+ `;
322
+ }
323
+ renderHeaderDate() {
324
+ return this._isSingle
325
+ ? this.renderHeaderDateSingle()
326
+ : this.renderHeaderDateRange();
327
+ }
328
+ renderDaysView() {
329
+ const activeDates = this.getActiveDates();
330
+ const horizontal = this.orientation === 'horizontal';
331
+ const length = activeDates.length - 1;
332
+ const format = this.formatOptions
333
+ .weekday;
334
+ return html `${activeDates.map((date, idx) => html `
335
+ <div part="days-view-container">
336
+ ${this.renderNavigation(date, horizontal ? idx === length : idx === 0, idx)}
337
+ <igc-days-view
338
+ @igcChange=${this.changeValue}
339
+ @igcActiveDateChange=${this.activeDateChanged}
340
+ @igcRangePreviewDateChange=${this.rangePreviewDateChanged}
341
+ part="days-view"
342
+ exportparts="days-row, label, date-inner, week-number-inner, week-number, date, first, last, selected, inactive, hidden, current, weekend, range, special, disabled, single, preview"
343
+ .active=${this.activeDaysViewIndex === idx}
344
+ .activeDate=${date.native}
345
+ .disabledDates=${this.disabledDates}
346
+ .hideLeadingDays=${this.hideOutsideDays || idx !== 0}
347
+ .hideTrailingDays=${this.hideOutsideDays || idx !== length}
348
+ .locale=${this.locale}
349
+ .rangePreviewDate=${this._rangePreviewDate?.native}
350
+ .resourceStrings=${this.resourceStrings}
351
+ .selection=${this.selection}
352
+ .showWeekNumbers=${this.showWeekNumbers}
353
+ .specialDates=${this._specialDates}
354
+ .value=${this.value}
355
+ .values=${this.values}
356
+ .weekDayFormat=${format}
357
+ .weekStart=${this.weekStart}
358
+ ></igc-days-view>
359
+ </div>
360
+ `)}`;
361
+ }
362
+ renderMonthView() {
363
+ const format = this.formatOptions
364
+ .month;
365
+ return html `
366
+ ${this.renderNavigation()}
367
+ <igc-months-view
368
+ part="months-view"
369
+ exportparts="month, selected, month-inner, current"
370
+ @igcChange=${this.changeMonth}
371
+ .value=${this.activeDate}
372
+ .locale=${this.locale}
373
+ .monthFormat=${format}
374
+ ></igc-months-view>
375
+ `;
376
+ }
377
+ renderYearView() {
378
+ return html `
379
+ ${this.renderNavigation()}
380
+ <igc-years-view
381
+ part="years-view"
382
+ exportparts="year, selected, year-inner, current"
383
+ @igcChange=${this.changeYear}
384
+ .value=${this.activeDate}
385
+ .yearsPerPage=${YEARS_PER_PAGE}
386
+ ></igc-years-view>
387
+ `;
498
388
  }
499
389
  render() {
500
- const activeDates = [];
501
- const monthsCount = this.visibleMonths > 1 ? this.visibleMonths : 1;
502
- for (let i = 0; i < monthsCount; i++) {
503
- activeDates.push(this.calendarModel.timedelta(this.activeDate, TimeDeltaInterval.Month, i - this.activeDaysViewIndex));
504
- }
390
+ const direction = this._isDayView && this.orientation === 'horizontal';
391
+ const styles = {
392
+ display: 'flex',
393
+ flexGrow: 1,
394
+ flexDirection: direction ? 'row' : 'column',
395
+ };
505
396
  return html `
506
397
  ${this.renderHeader()}
507
- <div
508
- part="content"
509
- style=${styleMap({
510
- display: 'flex',
511
- flexGrow: '1',
512
- flexDirection: this.activeView === 'days'
513
- ? this.orientation === 'horizontal'
514
- ? 'row'
515
- : 'column'
516
- : 'column',
517
- })}
518
- @keydown=${this.handleKeyDown}
519
- >
520
- ${this.activeView === 'days'
521
- ? activeDates.map((activeDate, i) => html `<div part="days-view-container">
522
- ${this.renderNavigation(activeDate, this.orientation === 'horizontal'
523
- ? i === activeDates.length - 1
524
- : i === 0, i)}
525
- <igc-days-view
526
- part="days-view"
527
- .active=${this.activeDaysViewIndex === i}
528
- .activeDate=${activeDate}
529
- .weekStart=${this.weekStart}
530
- .weekDayFormat=${this.formatOptions.weekday}
531
- .locale=${this.locale}
532
- .selection=${this.selection}
533
- .value=${this.value}
534
- .values=${this.values}
535
- .hideLeadingDays=${this.hideOutsideDays || i !== 0}
536
- .hideTrailingDays=${this.hideOutsideDays ||
537
- i !== activeDates.length - 1}
538
- .showWeekNumbers=${this.showWeekNumbers}
539
- .disabledDates=${this.disabledDates}
540
- .specialDates=${this.specialDates}
541
- .rangePreviewDate=${this.rangePreviewDate}
542
- .resourceStrings=${this.resourceStrings}
543
- exportparts="days-row, label, date-inner, week-number-inner, week-number, date, first, last, selected, inactive, hidden, current, weekend, range, special, disabled, single, preview"
544
- @igcChange=${this.changeValue}
545
- @igcActiveDateChange=${this.activeDateChanged}
546
- @igcRangePreviewDateChange=${this.rangePreviewDateChange}
547
- ></igc-days-view>
548
- </div>`)
549
- : ''}
550
- ${this.activeView === 'months'
551
- ? html ` ${this.renderNavigation()}
552
- <igc-months-view
553
- part="months-view"
554
- .value=${this.activeDate}
555
- .locale=${this.locale}
556
- .monthFormat=${this.formatOptions.month}
557
- exportparts="month, selected, month-inner, current"
558
- @igcChange=${this.changeMonth}
559
- ></igc-months-view>`
560
- : ''}
561
- ${this.activeView === 'years'
562
- ? html `${this.renderNavigation()}
563
- <igc-years-view
564
- part="years-view"
565
- .value=${this.activeDate}
566
- .yearsPerPage=${this.yearPerPage}
567
- exportparts="year, selected, year-inner, current"
568
- @igcChange=${this.changeYear}
569
- ></igc-years-view>`
570
- : ''}
398
+ <div ${ref(this.contentRef)} part="content" style=${styleMap(styles)}>
399
+ ${choose(this.activeView, [
400
+ ['days', () => this.renderDaysView()],
401
+ ['months', () => this.renderMonthView()],
402
+ ['years', () => this.renderYearView()],
403
+ ])}
571
404
  </div>
572
405
  `;
573
406
  }
407
+ changeMonth(event) {
408
+ event.stopPropagation();
409
+ this.activeDate = event.detail;
410
+ this.activeView = 'days';
411
+ this[focusActiveDate]();
412
+ }
413
+ changeYear(event) {
414
+ event.stopPropagation();
415
+ this.activeDate = event.detail;
416
+ this.activeView = 'months';
417
+ this[focusActiveDate]();
418
+ }
419
+ changeValue(event) {
420
+ event.stopPropagation();
421
+ const view = event.target;
422
+ if (this._isSingle) {
423
+ this.value = view.value;
424
+ }
425
+ else {
426
+ this.values = view.values;
427
+ }
428
+ this.emitEvent('igcChange', {
429
+ detail: this._isSingle ? this.value : this.values,
430
+ });
431
+ }
432
+ activeDateChanged(event) {
433
+ const view = event.target;
434
+ const views = Array.from(this.daysViews);
435
+ this.activeDaysViewIndex = views.indexOf(view);
436
+ this.activeDate = event.detail;
437
+ if (!areSameMonth(this.activeDate, view.activeDate)) {
438
+ this[focusActiveDate]();
439
+ }
440
+ }
441
+ rangePreviewDateChanged(event) {
442
+ this._rangePreviewDate = event.detail
443
+ ? CalendarDay.from(event.detail)
444
+ : undefined;
445
+ }
446
+ getActiveDates() {
447
+ const current = this.activeDaysViewIndex;
448
+ const length = Math.max(this.visibleMonths, 1);
449
+ return Array.from({ length }, (_, i) => this._activeDate.add('month', i - current));
450
+ }
451
+ activateDaysView(index) {
452
+ const view = this.daysViews.item(index);
453
+ this.activeDate = view.activeDate;
454
+ this.activeDaysViewIndex = index;
455
+ }
456
+ navigatePrevious() {
457
+ const unit = this._isDayView ? 'month' : 'year';
458
+ const delta = this._isYearView ? YEARS_PER_PAGE : 1;
459
+ this._activeDate = this._activeDate.add(unit, -delta);
460
+ }
461
+ navigateNext() {
462
+ const unit = this._isDayView ? 'month' : 'year';
463
+ const delta = this._isYearView ? YEARS_PER_PAGE : 1;
464
+ this._activeDate = this._activeDate.add(unit, delta);
465
+ }
466
+ switchToMonths(viewIndex) {
467
+ this.activateDaysView(viewIndex);
468
+ this.activeView = 'months';
469
+ this[focusActiveDate]();
470
+ }
471
+ switchToYears(viewIndex) {
472
+ if (this._isDayView) {
473
+ this.activateDaysView(viewIndex);
474
+ }
475
+ this.activeView = 'years';
476
+ this[focusActiveDate]();
477
+ }
574
478
  };
575
479
  IgcCalendarComponent.tagName = 'igc-calendar';
576
480
  IgcCalendarComponent.styles = styles;
577
- __decorate([
578
- state()
579
- ], IgcCalendarComponent.prototype, "rangePreviewDate", void 0);
580
481
  __decorate([
581
482
  state()
582
483
  ], IgcCalendarComponent.prototype, "activeDaysViewIndex", void 0);
583
484
  __decorate([
584
- queryAll('igc-days-view')
485
+ queryAll(IgcDaysViewComponent.tagName)
585
486
  ], IgcCalendarComponent.prototype, "daysViews", void 0);
586
487
  __decorate([
587
- query('igc-months-view')
488
+ query(IgcMonthsViewComponent.tagName)
588
489
  ], IgcCalendarComponent.prototype, "monthsView", void 0);
589
490
  __decorate([
590
- query('igc-years-view')
491
+ query(IgcYearsViewComponent.tagName)
591
492
  ], IgcCalendarComponent.prototype, "yearsView", void 0);
592
493
  __decorate([
593
- property({ type: Boolean, attribute: 'hide-outside-days' })
494
+ property({ type: Boolean, attribute: 'hide-outside-days', reflect: true })
594
495
  ], IgcCalendarComponent.prototype, "hideOutsideDays", void 0);
595
496
  __decorate([
596
- property({ type: Boolean, attribute: 'hide-header' })
497
+ property({ type: Boolean, attribute: 'hide-header', reflect: true })
597
498
  ], IgcCalendarComponent.prototype, "hideHeader", void 0);
598
499
  __decorate([
599
- property({ attribute: 'header-orientation', reflect: true })
500
+ property({ reflect: true, attribute: 'header-orientation' })
600
501
  ], IgcCalendarComponent.prototype, "headerOrientation", void 0);
601
502
  __decorate([
602
503
  property()
@@ -614,9 +515,11 @@ __decorate([
614
515
  property({ attribute: false })
615
516
  ], IgcCalendarComponent.prototype, "resourceStrings", void 0);
616
517
  __decorate([
617
- watch('formatOptions'),
618
518
  watch('locale')
619
- ], IgcCalendarComponent.prototype, "formattersChange", null);
519
+ ], IgcCalendarComponent.prototype, "localeChange", null);
520
+ __decorate([
521
+ watch('formatOptions')
522
+ ], IgcCalendarComponent.prototype, "formatOptionsChange", null);
620
523
  IgcCalendarComponent = IgcCalendarComponent_1 = __decorate([
621
524
  themes(all)
622
525
  ], IgcCalendarComponent);