@ng-matero/extensions 12.5.2 → 13.0.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 (560) hide show
  1. package/README.md +2 -16
  2. package/_all-color.scss +1 -1
  3. package/_all-theme.scss +2 -0
  4. package/_index.scss +3 -1
  5. package/_theming.scss +3 -1
  6. package/alert/_alert-theme.scss +2 -2
  7. package/alert/alert.component.d.ts +3 -0
  8. package/alert/alert.module.d.ts +6 -0
  9. package/alert/mtxAlert.d.ts +1 -0
  10. package/alert/package.json +5 -6
  11. package/button/button-loading.directive.d.ts +3 -0
  12. package/button/button.module.d.ts +8 -0
  13. package/button/mtxButton.d.ts +1 -0
  14. package/button/package.json +5 -6
  15. package/checkbox-group/checkbox-group.component.d.ts +5 -4
  16. package/checkbox-group/checkbox-group.module.d.ts +9 -0
  17. package/checkbox-group/mtxCheckboxGroup.d.ts +1 -0
  18. package/checkbox-group/package.json +5 -6
  19. package/colorpicker/_colorpicker-theme.import.scss +2 -0
  20. package/colorpicker/_colorpicker-theme.scss +43 -0
  21. package/colorpicker/colorpicker-animations.d.ts +8 -0
  22. package/colorpicker/colorpicker-content.scss +4 -0
  23. package/colorpicker/colorpicker-input.d.ts +92 -0
  24. package/colorpicker/colorpicker-module.d.ts +15 -0
  25. package/colorpicker/colorpicker-toggle.d.ts +38 -0
  26. package/colorpicker/colorpicker-toggle.scss +23 -0
  27. package/colorpicker/colorpicker.d.ts +131 -0
  28. package/{extensions.d.ts → colorpicker/mtxColorpicker.d.ts} +1 -0
  29. package/colorpicker/package.json +10 -0
  30. package/colorpicker/public-api.d.ts +5 -0
  31. package/column-resize/column-resize-directives/column-resize-flex.d.ts +3 -0
  32. package/column-resize/column-resize-directives/column-resize.d.ts +3 -0
  33. package/column-resize/column-resize-module.d.ts +6 -7
  34. package/column-resize/column-resize-notifier.d.ts +5 -7
  35. package/column-resize/column-resize.d.ts +3 -0
  36. package/column-resize/column-size-store.d.ts +3 -7
  37. package/column-resize/event-dispatcher.d.ts +3 -0
  38. package/column-resize/mtxColumnResize.d.ts +1 -0
  39. package/column-resize/overlay-handle.d.ts +3 -0
  40. package/column-resize/package.json +5 -6
  41. package/column-resize/resizable.d.ts +3 -0
  42. package/column-resize/resize-strategy.d.ts +7 -0
  43. package/core/datetime/datetime.module.d.ts +8 -0
  44. package/core/datetime/native-datetime-adapter.d.ts +3 -0
  45. package/core/density/private/_compatibility.scss +74 -0
  46. package/core/mtxCore.d.ts +1 -0
  47. package/core/package.json +5 -6
  48. package/{pipes/public-api.d.ts → core/pipes/index.d.ts} +0 -0
  49. package/core/pipes/pipes.module.d.ts +8 -0
  50. package/{pipes → core/pipes}/to-observable.pipe.d.ts +3 -0
  51. package/core/public-api.d.ts +1 -0
  52. package/core/style/_elevation.scss +197 -0
  53. package/core/style/_private.scss +41 -0
  54. package/core/style/_variables.scss +44 -0
  55. package/core/style/_vendor-prefixes.scss +60 -0
  56. package/core/theming/_palette.scss +746 -0
  57. package/core/theming/_theming.scss +430 -0
  58. package/core/typography/_typography-utils.scss +101 -0
  59. package/core/typography/_typography.scss +273 -0
  60. package/datetimepicker/_datetimepicker-theme.scss +17 -5
  61. package/datetimepicker/calendar-body.d.ts +3 -0
  62. package/datetimepicker/calendar-body.scss +5 -4
  63. package/datetimepicker/calendar.d.ts +6 -11
  64. package/datetimepicker/clock.d.ts +13 -9
  65. package/datetimepicker/datetimepicker-animations.d.ts +7 -5
  66. package/datetimepicker/datetimepicker-input.d.ts +7 -2
  67. package/datetimepicker/datetimepicker-module.d.ts +20 -0
  68. package/datetimepicker/datetimepicker-toggle.d.ts +20 -2
  69. package/datetimepicker/datetimepicker-toggle.scss +23 -0
  70. package/datetimepicker/datetimepicker-types.d.ts +1 -0
  71. package/datetimepicker/datetimepicker.d.ts +73 -25
  72. package/datetimepicker/month-view.d.ts +7 -4
  73. package/datetimepicker/mtxDatetimepicker.d.ts +1 -2
  74. package/datetimepicker/multi-year-view.d.ts +7 -4
  75. package/datetimepicker/package.json +5 -6
  76. package/datetimepicker/public-api.d.ts +4 -1
  77. package/datetimepicker/year-view.d.ts +7 -4
  78. package/dialog/{dialog.config.d.ts → dialog-config.d.ts} +0 -0
  79. package/dialog/dialog.component.d.ts +4 -1
  80. package/dialog/dialog.d.ts +4 -1
  81. package/dialog/dialog.module.d.ts +10 -0
  82. package/dialog/mtxDialog.d.ts +1 -0
  83. package/dialog/package.json +5 -6
  84. package/dialog/public-api.d.ts +2 -2
  85. package/esm2020/alert/alert.component.mjs +52 -0
  86. package/esm2020/alert/alert.module.mjs +18 -0
  87. package/{esm2015/alert/mtxAlert.js → esm2020/alert/mtxAlert.mjs} +0 -0
  88. package/{esm2015/alert/public-api.js → esm2020/alert/public-api.mjs} +0 -0
  89. package/esm2020/button/button-loading.directive.mjs +79 -0
  90. package/esm2020/button/button.module.mjs +20 -0
  91. package/{esm2015/button/mtxButton.js → esm2020/button/mtxButton.mjs} +0 -0
  92. package/{esm2015/button/public-api.js → esm2020/button/public-api.mjs} +0 -0
  93. package/esm2020/checkbox-group/checkbox-group.component.mjs +234 -0
  94. package/{esm2015/checkbox-group/checkbox-group.interface.js → esm2020/checkbox-group/checkbox-group.interface.mjs} +0 -0
  95. package/esm2020/checkbox-group/checkbox-group.module.mjs +21 -0
  96. package/{esm2015/checkbox-group/mtxCheckboxGroup.js → esm2020/checkbox-group/mtxCheckboxGroup.mjs} +0 -0
  97. package/{esm2015/checkbox-group/public-api.js → esm2020/checkbox-group/public-api.mjs} +0 -0
  98. package/esm2020/colorpicker/colorpicker-animations.mjs +16 -0
  99. package/esm2020/colorpicker/colorpicker-input.mjs +228 -0
  100. package/esm2020/colorpicker/colorpicker-module.mjs +65 -0
  101. package/esm2020/colorpicker/colorpicker-toggle.mjs +90 -0
  102. package/esm2020/colorpicker/colorpicker.mjs +363 -0
  103. package/esm2020/colorpicker/mtxColorpicker.mjs +5 -0
  104. package/esm2020/colorpicker/public-api.mjs +6 -0
  105. package/esm2020/column-resize/column-resize-directives/column-resize-flex.mjs +45 -0
  106. package/esm2020/column-resize/column-resize-directives/column-resize.mjs +45 -0
  107. package/{esm2015/column-resize/column-resize-directives/constants.js → esm2020/column-resize/column-resize-directives/constants.mjs} +0 -0
  108. package/esm2020/column-resize/column-resize-module.mjs +28 -0
  109. package/esm2020/column-resize/column-resize-notifier.mjs +47 -0
  110. package/esm2020/column-resize/column-resize.mjs +82 -0
  111. package/esm2020/column-resize/column-size-store.mjs +20 -0
  112. package/esm2020/column-resize/event-dispatcher.mjs +67 -0
  113. package/{esm2015/column-resize/mtxColumnResize.js → esm2020/column-resize/mtxColumnResize.mjs} +0 -0
  114. package/esm2020/column-resize/overlay-handle.mjs +146 -0
  115. package/{esm2015/column-resize/polyfill.js → esm2020/column-resize/polyfill.mjs} +0 -0
  116. package/{esm2015/column-resize/public-api.js → esm2020/column-resize/public-api.mjs} +0 -0
  117. package/esm2020/column-resize/resizable.mjs +199 -0
  118. package/{esm2015/column-resize/resize-ref.js → esm2020/column-resize/resize-ref.mjs} +0 -0
  119. package/esm2020/column-resize/resize-strategy.mjs +232 -0
  120. package/{esm2015/column-resize/selectors.js → esm2020/column-resize/selectors.mjs} +0 -0
  121. package/{esm2015/core/datetime/datetime-adapter.js → esm2020/core/datetime/datetime-adapter.mjs} +0 -0
  122. package/{esm2015/core/datetime/datetime-formats.js → esm2020/core/datetime/datetime-formats.mjs} +0 -0
  123. package/esm2020/core/datetime/datetime.module.mjs +42 -0
  124. package/{esm2015/core/datetime/index.js → esm2020/core/datetime/index.mjs} +0 -0
  125. package/esm2020/core/datetime/native-datetime-adapter.mjs +138 -0
  126. package/{esm2015/core/datetime/native-datetime-formats.js → esm2020/core/datetime/native-datetime-formats.mjs} +0 -0
  127. package/{esm2015/core/mtxCore.js → esm2020/core/mtxCore.mjs} +0 -0
  128. package/esm2020/core/pipes/index.mjs +3 -0
  129. package/esm2020/core/pipes/pipes.module.mjs +18 -0
  130. package/esm2020/core/pipes/to-observable.pipe.mjs +15 -0
  131. package/{esm2015/core/public-api.js → esm2020/core/public-api.mjs} +2 -1
  132. package/esm2020/datetimepicker/calendar-body.mjs +78 -0
  133. package/esm2020/datetimepicker/calendar.mjs +618 -0
  134. package/esm2020/datetimepicker/clock.mjs +277 -0
  135. package/esm2020/datetimepicker/datetimepicker-animations.mjs +44 -0
  136. package/{esm2015/datetimepicker/datetimepicker-errors.js → esm2020/datetimepicker/datetimepicker-errors.mjs} +0 -0
  137. package/{esm2015/datetimepicker/datetimepicker-filtertype.js → esm2020/datetimepicker/datetimepicker-filtertype.mjs} +0 -0
  138. package/esm2020/datetimepicker/datetimepicker-input.mjs +344 -0
  139. package/esm2020/datetimepicker/datetimepicker-module.mjs +75 -0
  140. package/esm2020/datetimepicker/datetimepicker-toggle.mjs +94 -0
  141. package/esm2020/datetimepicker/datetimepicker-types.mjs +2 -0
  142. package/esm2020/datetimepicker/datetimepicker.mjs +492 -0
  143. package/esm2020/datetimepicker/month-view.mjs +148 -0
  144. package/esm2020/datetimepicker/mtxDatetimepicker.mjs +5 -0
  145. package/esm2020/datetimepicker/multi-year-view.mjs +214 -0
  146. package/esm2020/datetimepicker/public-api.mjs +14 -0
  147. package/esm2020/datetimepicker/year-view.mjs +138 -0
  148. package/{esm2015/dialog/dialog.config.js → esm2020/dialog/dialog-config.mjs} +1 -1
  149. package/esm2020/dialog/dialog.component.mjs +33 -0
  150. package/esm2020/dialog/dialog.mjs +74 -0
  151. package/esm2020/dialog/dialog.module.mjs +24 -0
  152. package/{esm2015/dialog/mtxDialog.js → esm2020/dialog/mtxDialog.mjs} +0 -0
  153. package/esm2020/dialog/public-api.mjs +5 -0
  154. package/esm2020/form-group/form-group.component.mjs +37 -0
  155. package/esm2020/form-group/form-group.module.mjs +18 -0
  156. package/{esm2015/form-group/mtxFormGroup.js → esm2020/form-group/mtxFormGroup.mjs} +0 -0
  157. package/{esm2015/form-group/public-api.js → esm2020/form-group/public-api.mjs} +0 -0
  158. package/esm2020/grid/cell.component.mjs +108 -0
  159. package/esm2020/grid/column-menu.component.mjs +95 -0
  160. package/esm2020/grid/column-resize/column-resize-directives/column-resize-flex.mjs +37 -0
  161. package/esm2020/grid/column-resize/column-resize-directives/column-resize.mjs +37 -0
  162. package/{esm2015/grid/column-resize/column-resize-directives/common.js → esm2020/grid/column-resize/column-resize-directives/common.mjs} +0 -0
  163. package/esm2020/grid/column-resize/column-resize-module.mjs +42 -0
  164. package/esm2020/grid/column-resize/overlay-handle.mjs +60 -0
  165. package/{esm2015/grid/column-resize/resizable-directives/common.js → esm2020/grid/column-resize/resizable-directives/common.mjs} +0 -0
  166. package/esm2020/grid/column-resize/resizable-directives/resizable.mjs +62 -0
  167. package/esm2020/grid/column-resize/resize-strategy.mjs +42 -0
  168. package/esm2020/grid/expansion-toggle.directive.mjs +64 -0
  169. package/esm2020/grid/grid.component.mjs +556 -0
  170. package/{esm2015/grid/grid.interface.js → esm2020/grid/grid.interface.mjs} +0 -0
  171. package/esm2020/grid/grid.module.mjs +117 -0
  172. package/esm2020/grid/grid.service.mjs +44 -0
  173. package/{esm2015/grid/mtxGrid.js → esm2020/grid/mtxGrid.mjs} +0 -0
  174. package/esm2020/grid/public-api.mjs +16 -0
  175. package/esm2020/loader/loader.component.mjs +63 -0
  176. package/esm2020/loader/loader.module.mjs +20 -0
  177. package/{esm2015/loader/mtxLoader.js → esm2020/loader/mtxLoader.mjs} +0 -0
  178. package/{esm2015/loader/public-api.js → esm2020/loader/public-api.mjs} +0 -0
  179. package/esm2020/ng-matero-extensions.mjs +5 -0
  180. package/{esm2015/popover/mtxPopover.js → esm2020/popover/mtxPopover.mjs} +0 -0
  181. package/{esm2015/popover/popover-animations.js → esm2020/popover/popover-animations.mjs} +0 -0
  182. package/{esm2015/popover/popover-errors.js → esm2020/popover/popover-errors.mjs} +0 -0
  183. package/{esm2015/popover/popover-interfaces.js → esm2020/popover/popover-interfaces.mjs} +0 -0
  184. package/esm2020/popover/popover-module.mjs +22 -0
  185. package/esm2020/popover/popover-target.mjs +17 -0
  186. package/esm2020/popover/popover-trigger.mjs +441 -0
  187. package/{esm2015/popover/popover-types.js → esm2020/popover/popover-types.mjs} +0 -0
  188. package/esm2020/popover/popover.mjs +334 -0
  189. package/{esm2015/popover/public-api.js → esm2020/popover/public-api.mjs} +0 -0
  190. package/{esm2015/progress/mtxProgress.js → esm2020/progress/mtxProgress.mjs} +0 -0
  191. package/esm2020/progress/progress.component.mjs +55 -0
  192. package/esm2020/progress/progress.module.mjs +18 -0
  193. package/{esm2015/progress/public-api.js → esm2020/progress/public-api.mjs} +0 -0
  194. package/esm2020/public-api.mjs +5 -0
  195. package/{esm2015/select/mtxSelect.js → esm2020/select/mtxSelect.mjs} +0 -0
  196. package/{esm2015/select/option.component.js → esm2020/select/option.component.mjs} +18 -26
  197. package/{esm2015/select/public-api.js → esm2020/select/public-api.mjs} +0 -0
  198. package/esm2020/select/select.component.mjs +458 -0
  199. package/esm2020/select/select.module.mjs +74 -0
  200. package/esm2020/select/templates.directive.mjs +124 -0
  201. package/{esm2015/slider/mtxSlider.js → esm2020/slider/mtxSlider.mjs} +0 -0
  202. package/{esm2015/slider/public-api.js → esm2020/slider/public-api.mjs} +0 -0
  203. package/esm2020/slider/slider-module.mjs +19 -0
  204. package/esm2020/slider/slider.mjs +1115 -0
  205. package/{esm2015/split/interface.js → esm2020/split/interface.mjs} +1 -1
  206. package/{esm2015/split/mtxSplit.js → esm2020/split/mtxSplit.mjs} +0 -0
  207. package/{esm2015/split/public-api.js → esm2020/split/public-api.mjs} +0 -0
  208. package/esm2020/split/split-pane.directive.mjs +149 -0
  209. package/esm2020/split/split.component.mjs +619 -0
  210. package/esm2020/split/split.module.mjs +19 -0
  211. package/esm2020/split/utils.mjs +222 -0
  212. package/{esm2015/text3d/mtxText3d.js → esm2020/text3d/mtxText3d.mjs} +0 -0
  213. package/{esm2015/text3d/public-api.js → esm2020/text3d/public-api.mjs} +0 -0
  214. package/esm2020/text3d/text3d.component.mjs +45 -0
  215. package/esm2020/text3d/text3d.module.mjs +18 -0
  216. package/{esm2015/tooltip/mtxTooltip.js → esm2020/tooltip/mtxTooltip.mjs} +0 -0
  217. package/{esm2015/tooltip/public-api.js → esm2020/tooltip/public-api.mjs} +0 -0
  218. package/{esm2015/tooltip/tooltip-animations.js → esm2020/tooltip/tooltip-animations.mjs} +0 -0
  219. package/esm2020/tooltip/tooltip-module.mjs +23 -0
  220. package/esm2020/tooltip/tooltip.mjs +674 -0
  221. package/fesm2015/mtxAlert.mjs +74 -0
  222. package/fesm2015/mtxAlert.mjs.map +1 -0
  223. package/fesm2015/mtxButton.mjs +102 -0
  224. package/fesm2015/mtxButton.mjs.map +1 -0
  225. package/fesm2015/mtxCheckboxGroup.mjs +257 -0
  226. package/fesm2015/mtxCheckboxGroup.mjs.map +1 -0
  227. package/fesm2015/mtxColorpicker.mjs +754 -0
  228. package/fesm2015/mtxColorpicker.mjs.map +1 -0
  229. package/fesm2015/{mtxColumnResize.js → mtxColumnResize.mjs} +108 -145
  230. package/fesm2015/mtxColumnResize.mjs.map +1 -0
  231. package/fesm2015/mtxCore.mjs +362 -0
  232. package/fesm2015/mtxCore.mjs.map +1 -0
  233. package/fesm2015/mtxDatetimepicker.mjs +2474 -0
  234. package/fesm2015/mtxDatetimepicker.mjs.map +1 -0
  235. package/fesm2015/mtxDialog.mjs +128 -0
  236. package/fesm2015/mtxDialog.mjs.map +1 -0
  237. package/fesm2015/mtxFormGroup.mjs +59 -0
  238. package/fesm2015/mtxFormGroup.mjs.map +1 -0
  239. package/fesm2015/mtxGrid.mjs +1271 -0
  240. package/fesm2015/mtxGrid.mjs.map +1 -0
  241. package/fesm2015/mtxLoader.mjs +87 -0
  242. package/fesm2015/mtxLoader.mjs.map +1 -0
  243. package/fesm2015/mtxPopover.mjs +865 -0
  244. package/fesm2015/mtxPopover.mjs.map +1 -0
  245. package/fesm2015/mtxProgress.mjs +77 -0
  246. package/fesm2015/mtxProgress.mjs.map +1 -0
  247. package/fesm2015/mtxSelect.mjs +712 -0
  248. package/fesm2015/mtxSelect.mjs.map +1 -0
  249. package/fesm2015/mtxSlider.mjs +1139 -0
  250. package/fesm2015/mtxSlider.mjs.map +1 -0
  251. package/fesm2015/{mtxSplit.js → mtxSplit.mjs} +87 -98
  252. package/fesm2015/mtxSplit.mjs.map +1 -0
  253. package/fesm2015/mtxText3d.mjs +67 -0
  254. package/fesm2015/mtxText3d.mjs.map +1 -0
  255. package/fesm2015/{mtxTooltip.js → mtxTooltip.mjs} +90 -88
  256. package/fesm2015/mtxTooltip.mjs.map +1 -0
  257. package/fesm2015/ng-matero-extensions.mjs +9 -0
  258. package/fesm2015/ng-matero-extensions.mjs.map +1 -0
  259. package/fesm2020/mtxAlert.mjs +74 -0
  260. package/fesm2020/mtxAlert.mjs.map +1 -0
  261. package/fesm2020/mtxButton.mjs +102 -0
  262. package/fesm2020/mtxButton.mjs.map +1 -0
  263. package/fesm2020/mtxCheckboxGroup.mjs +257 -0
  264. package/fesm2020/mtxCheckboxGroup.mjs.map +1 -0
  265. package/fesm2020/mtxColorpicker.mjs +750 -0
  266. package/fesm2020/mtxColorpicker.mjs.map +1 -0
  267. package/fesm2020/mtxColumnResize.mjs +953 -0
  268. package/fesm2020/mtxColumnResize.mjs.map +1 -0
  269. package/{fesm2015/mtxCore.js → fesm2020/mtxCore.mjs} +75 -42
  270. package/fesm2020/mtxCore.mjs.map +1 -0
  271. package/fesm2020/mtxDatetimepicker.mjs +2462 -0
  272. package/fesm2020/mtxDatetimepicker.mjs.map +1 -0
  273. package/fesm2020/mtxDialog.mjs +129 -0
  274. package/fesm2020/mtxDialog.mjs.map +1 -0
  275. package/fesm2020/mtxFormGroup.mjs +59 -0
  276. package/fesm2020/mtxFormGroup.mjs.map +1 -0
  277. package/fesm2020/mtxGrid.mjs +1259 -0
  278. package/fesm2020/mtxGrid.mjs.map +1 -0
  279. package/fesm2020/mtxLoader.mjs +87 -0
  280. package/fesm2020/mtxLoader.mjs.map +1 -0
  281. package/{fesm2015/mtxPopover.js → fesm2020/mtxPopover.mjs} +120 -111
  282. package/fesm2020/mtxPopover.mjs.map +1 -0
  283. package/fesm2020/mtxProgress.mjs +77 -0
  284. package/fesm2020/mtxProgress.mjs.map +1 -0
  285. package/fesm2020/mtxSelect.mjs +709 -0
  286. package/fesm2020/mtxSelect.mjs.map +1 -0
  287. package/{fesm2015/mtxSlider.js → fesm2020/mtxSlider.mjs} +97 -94
  288. package/fesm2020/mtxSlider.mjs.map +1 -0
  289. package/fesm2020/mtxSplit.mjs +1007 -0
  290. package/fesm2020/mtxSplit.mjs.map +1 -0
  291. package/fesm2020/mtxText3d.mjs +67 -0
  292. package/fesm2020/mtxText3d.mjs.map +1 -0
  293. package/fesm2020/mtxTooltip.mjs +718 -0
  294. package/fesm2020/mtxTooltip.mjs.map +1 -0
  295. package/fesm2020/ng-matero-extensions.mjs +9 -0
  296. package/fesm2020/ng-matero-extensions.mjs.map +1 -0
  297. package/form-group/_form-group-theme.scss +1 -1
  298. package/form-group/form-group.component.d.ts +5 -4
  299. package/form-group/form-group.module.d.ts +6 -0
  300. package/form-group/mtxFormGroup.d.ts +1 -0
  301. package/form-group/package.json +5 -6
  302. package/grid/_grid-theme.scss +1 -1
  303. package/grid/cell.component.d.ts +3 -0
  304. package/grid/column-menu.component.d.ts +3 -0
  305. package/grid/column-menu.component.scss +1 -1
  306. package/grid/column-resize/_column-resize.scss +3 -3
  307. package/grid/column-resize/column-resize-directives/column-resize-flex.d.ts +3 -0
  308. package/grid/column-resize/column-resize-directives/column-resize.d.ts +3 -0
  309. package/grid/column-resize/column-resize-module.d.ts +12 -7
  310. package/grid/column-resize/overlay-handle.d.ts +3 -0
  311. package/grid/column-resize/resizable-directives/resizable.d.ts +3 -0
  312. package/grid/column-resize/resize-strategy.d.ts +3 -0
  313. package/grid/expansion-toggle.directive.d.ts +3 -0
  314. package/grid/grid.component.d.ts +20 -1
  315. package/grid/grid.module.d.ts +26 -0
  316. package/grid/grid.service.d.ts +3 -0
  317. package/grid/mtxGrid.d.ts +1 -0
  318. package/grid/package.json +5 -6
  319. package/grid/public-api.d.ts +0 -1
  320. package/loader/_loader-theme.scss +1 -1
  321. package/loader/loader.component.d.ts +7 -1
  322. package/loader/loader.module.d.ts +8 -0
  323. package/loader/mtxLoader.d.ts +1 -0
  324. package/loader/package.json +5 -6
  325. package/{color-picker/mtxColorPicker.d.ts → ng-matero-extensions.d.ts} +1 -0
  326. package/package.json +171 -15
  327. package/popover/_popover-theme.scss +1 -1
  328. package/popover/mtxPopover.d.ts +1 -0
  329. package/popover/package.json +5 -6
  330. package/popover/popover-module.d.ts +10 -0
  331. package/popover/popover-target.d.ts +3 -0
  332. package/popover/popover-trigger.d.ts +3 -0
  333. package/popover/popover.d.ts +6 -3
  334. package/progress/_progress-theme.scss +2 -2
  335. package/progress/mtxProgress.d.ts +1 -0
  336. package/progress/package.json +5 -6
  337. package/progress/progress.component.d.ts +3 -0
  338. package/progress/progress.module.d.ts +6 -0
  339. package/public-api.d.ts +2 -19
  340. package/select/_select-theme.scss +1 -1
  341. package/select/mtxSelect.d.ts +1 -0
  342. package/select/option.component.d.ts +3 -0
  343. package/select/package.json +5 -6
  344. package/select/select.component.d.ts +4 -1
  345. package/select/select.component.scss +1 -1
  346. package/select/select.module.d.ts +10 -0
  347. package/select/templates.directive.d.ts +23 -0
  348. package/slider/_slider-theme.scss +5 -5
  349. package/slider/mtxSlider.d.ts +1 -0
  350. package/slider/package.json +5 -6
  351. package/slider/slider-module.d.ts +7 -0
  352. package/slider/slider.d.ts +4 -1
  353. package/slider/slider.scss +8 -7
  354. package/split/_split-theme.scss +10 -3
  355. package/split/interface.d.ts +1 -2
  356. package/split/mtxSplit.d.ts +1 -0
  357. package/split/package.json +5 -6
  358. package/split/split-pane.directive.d.ts +3 -0
  359. package/split/split.component.d.ts +12 -1
  360. package/split/split.module.d.ts +7 -0
  361. package/text3d/_text3d-theme.scss +2 -2
  362. package/text3d/mtxText3d.d.ts +1 -0
  363. package/text3d/package.json +5 -6
  364. package/text3d/text3d.component.d.ts +3 -1
  365. package/text3d/text3d.module.d.ts +6 -0
  366. package/tooltip/_tooltip-theme.scss +3 -3
  367. package/tooltip/mtxTooltip.d.ts +1 -0
  368. package/tooltip/package.json +5 -6
  369. package/tooltip/tooltip-module.d.ts +10 -0
  370. package/tooltip/tooltip.d.ts +5 -0
  371. package/tooltip/tooltip.scss +1 -1
  372. package/alert/mtxAlert.metadata.json +0 -1
  373. package/bundles/extensions.umd.js +0 -198
  374. package/bundles/extensions.umd.js.map +0 -1
  375. package/bundles/mtxAlert.umd.js +0 -101
  376. package/bundles/mtxAlert.umd.js.map +0 -1
  377. package/bundles/mtxButton.umd.js +0 -119
  378. package/bundles/mtxButton.umd.js.map +0 -1
  379. package/bundles/mtxCheckboxGroup.umd.js +0 -285
  380. package/bundles/mtxCheckboxGroup.umd.js.map +0 -1
  381. package/bundles/mtxColorPicker.umd.js +0 -337
  382. package/bundles/mtxColorPicker.umd.js.map +0 -1
  383. package/bundles/mtxColumnResize.umd.js +0 -1339
  384. package/bundles/mtxColumnResize.umd.js.map +0 -1
  385. package/bundles/mtxCore.umd.js +0 -670
  386. package/bundles/mtxCore.umd.js.map +0 -1
  387. package/bundles/mtxDatetimepicker.umd.js +0 -2590
  388. package/bundles/mtxDatetimepicker.umd.js.map +0 -1
  389. package/bundles/mtxDialog.umd.js +0 -160
  390. package/bundles/mtxDialog.umd.js.map +0 -1
  391. package/bundles/mtxFormGroup.umd.js +0 -80
  392. package/bundles/mtxFormGroup.umd.js.map +0 -1
  393. package/bundles/mtxGrid.umd.js +0 -1583
  394. package/bundles/mtxGrid.umd.js.map +0 -1
  395. package/bundles/mtxLoader.umd.js +0 -104
  396. package/bundles/mtxLoader.umd.js.map +0 -1
  397. package/bundles/mtxPipes.umd.js +0 -44
  398. package/bundles/mtxPipes.umd.js.map +0 -1
  399. package/bundles/mtxPopover.umd.js +0 -1260
  400. package/bundles/mtxPopover.umd.js.map +0 -1
  401. package/bundles/mtxProgress.umd.js +0 -92
  402. package/bundles/mtxProgress.umd.js.map +0 -1
  403. package/bundles/mtxSelect.umd.js +0 -1097
  404. package/bundles/mtxSelect.umd.js.map +0 -1
  405. package/bundles/mtxSlider.umd.js +0 -1551
  406. package/bundles/mtxSlider.umd.js.map +0 -1
  407. package/bundles/mtxSplit.umd.js +0 -1430
  408. package/bundles/mtxSplit.umd.js.map +0 -1
  409. package/bundles/mtxText3d.umd.js +0 -92
  410. package/bundles/mtxText3d.umd.js.map +0 -1
  411. package/bundles/mtxTooltip.umd.js +0 -1078
  412. package/bundles/mtxTooltip.umd.js.map +0 -1
  413. package/button/mtxButton.metadata.json +0 -1
  414. package/checkbox-group/mtxCheckboxGroup.metadata.json +0 -1
  415. package/color-picker/color-picker.component.d.ts +0 -120
  416. package/color-picker/color-picker.module.d.ts +0 -2
  417. package/color-picker/mtxColorPicker.metadata.json +0 -1
  418. package/color-picker/package.json +0 -11
  419. package/color-picker/public-api.d.ts +0 -2
  420. package/column-resize/mtxColumnResize.metadata.json +0 -1
  421. package/core/mtxCore.metadata.json +0 -1
  422. package/datetimepicker/datetimepicker.module.d.ts +0 -2
  423. package/datetimepicker/mtxDatetimepicker.metadata.json +0 -1
  424. package/dialog/mtxDialog.metadata.json +0 -1
  425. package/esm2015/alert/alert.component.js +0 -63
  426. package/esm2015/alert/alert.module.js +0 -14
  427. package/esm2015/button/button-loading.directive.js +0 -89
  428. package/esm2015/button/button.module.js +0 -16
  429. package/esm2015/checkbox-group/checkbox-group.component.js +0 -236
  430. package/esm2015/checkbox-group/checkbox-group.module.js +0 -17
  431. package/esm2015/color-picker/color-picker.component.js +0 -268
  432. package/esm2015/color-picker/color-picker.module.js +0 -26
  433. package/esm2015/color-picker/mtxColorPicker.js +0 -5
  434. package/esm2015/color-picker/public-api.js +0 -3
  435. package/esm2015/column-resize/column-resize-directives/column-resize-flex.js +0 -54
  436. package/esm2015/column-resize/column-resize-directives/column-resize.js +0 -54
  437. package/esm2015/column-resize/column-resize-module.js +0 -24
  438. package/esm2015/column-resize/column-resize-notifier.js +0 -54
  439. package/esm2015/column-resize/column-resize.js +0 -80
  440. package/esm2015/column-resize/column-size-store.js +0 -18
  441. package/esm2015/column-resize/event-dispatcher.js +0 -75
  442. package/esm2015/column-resize/overlay-handle.js +0 -144
  443. package/esm2015/column-resize/resizable.js +0 -197
  444. package/esm2015/column-resize/resize-strategy.js +0 -245
  445. package/esm2015/core/datetime/datetime.module.js +0 -32
  446. package/esm2015/core/datetime/native-datetime-adapter.js +0 -144
  447. package/esm2015/datetimepicker/calendar-body.js +0 -75
  448. package/esm2015/datetimepicker/calendar.js +0 -629
  449. package/esm2015/datetimepicker/clock.js +0 -283
  450. package/esm2015/datetimepicker/datetimepicker-animations.js +0 -30
  451. package/esm2015/datetimepicker/datetimepicker-input.js +0 -333
  452. package/esm2015/datetimepicker/datetimepicker-toggle.js +0 -81
  453. package/esm2015/datetimepicker/datetimepicker.js +0 -411
  454. package/esm2015/datetimepicker/datetimepicker.module.js +0 -49
  455. package/esm2015/datetimepicker/month-view.js +0 -149
  456. package/esm2015/datetimepicker/mtxDatetimepicker.js +0 -7
  457. package/esm2015/datetimepicker/multi-year-view.js +0 -214
  458. package/esm2015/datetimepicker/public-api.js +0 -11
  459. package/esm2015/datetimepicker/year-view.js +0 -140
  460. package/esm2015/dialog/dialog.component.js +0 -40
  461. package/esm2015/dialog/dialog.js +0 -81
  462. package/esm2015/dialog/dialog.module.js +0 -21
  463. package/esm2015/dialog/public-api.js +0 -5
  464. package/esm2015/extensions-experimental.module.js +0 -13
  465. package/esm2015/extensions.js +0 -5
  466. package/esm2015/extensions.module.js +0 -40
  467. package/esm2015/form-group/form-group.component.js +0 -47
  468. package/esm2015/form-group/form-group.module.js +0 -14
  469. package/esm2015/grid/cell-selection.directive.js +0 -62
  470. package/esm2015/grid/cell.component.js +0 -115
  471. package/esm2015/grid/column-menu.component.js +0 -72
  472. package/esm2015/grid/column-resize/column-resize-directives/column-resize-flex.js +0 -47
  473. package/esm2015/grid/column-resize/column-resize-directives/column-resize.js +0 -47
  474. package/esm2015/grid/column-resize/column-resize-module.js +0 -36
  475. package/esm2015/grid/column-resize/overlay-handle.js +0 -68
  476. package/esm2015/grid/column-resize/resizable-directives/resizable.js +0 -75
  477. package/esm2015/grid/column-resize/resize-strategy.js +0 -45
  478. package/esm2015/grid/expansion-toggle.directive.js +0 -62
  479. package/esm2015/grid/grid.component.js +0 -418
  480. package/esm2015/grid/grid.module.js +0 -69
  481. package/esm2015/grid/grid.service.js +0 -50
  482. package/esm2015/grid/public-api.js +0 -17
  483. package/esm2015/loader/loader.component.js +0 -66
  484. package/esm2015/loader/loader.module.js +0 -16
  485. package/esm2015/pipes/mtxPipes.js +0 -5
  486. package/esm2015/pipes/pipes.module.js +0 -14
  487. package/esm2015/pipes/public-api.js +0 -3
  488. package/esm2015/pipes/to-observable.pipe.js +0 -12
  489. package/esm2015/popover/popover-module.js +0 -18
  490. package/esm2015/popover/popover-target.js +0 -24
  491. package/esm2015/popover/popover-trigger.js +0 -434
  492. package/esm2015/popover/popover.js +0 -326
  493. package/esm2015/progress/progress.component.js +0 -54
  494. package/esm2015/progress/progress.module.js +0 -14
  495. package/esm2015/public-api.js +0 -23
  496. package/esm2015/select/select.component.js +0 -380
  497. package/esm2015/select/select.module.js +0 -46
  498. package/esm2015/select/templates.directive.js +0 -211
  499. package/esm2015/slider/slider-module.js +0 -15
  500. package/esm2015/slider/slider.js +0 -1115
  501. package/esm2015/split/split-pane.directive.js +0 -156
  502. package/esm2015/split/split.component.js +0 -620
  503. package/esm2015/split/split.module.js +0 -15
  504. package/esm2015/split/utils.js +0 -227
  505. package/esm2015/text3d/text3d.component.js +0 -53
  506. package/esm2015/text3d/text3d.module.js +0 -14
  507. package/esm2015/tooltip/tooltip-module.js +0 -20
  508. package/esm2015/tooltip/tooltip.js +0 -678
  509. package/extensions-experimental.module.d.ts +0 -2
  510. package/extensions.metadata.json +0 -1
  511. package/extensions.module.d.ts +0 -2
  512. package/fesm2015/extensions.js +0 -80
  513. package/fesm2015/extensions.js.map +0 -1
  514. package/fesm2015/mtxAlert.js +0 -82
  515. package/fesm2015/mtxAlert.js.map +0 -1
  516. package/fesm2015/mtxButton.js +0 -108
  517. package/fesm2015/mtxButton.js.map +0 -1
  518. package/fesm2015/mtxCheckboxGroup.js +0 -256
  519. package/fesm2015/mtxCheckboxGroup.js.map +0 -1
  520. package/fesm2015/mtxColorPicker.js +0 -295
  521. package/fesm2015/mtxColorPicker.js.map +0 -1
  522. package/fesm2015/mtxColumnResize.js.map +0 -1
  523. package/fesm2015/mtxCore.js.map +0 -1
  524. package/fesm2015/mtxDatetimepicker.js +0 -2355
  525. package/fesm2015/mtxDatetimepicker.js.map +0 -1
  526. package/fesm2015/mtxDialog.js +0 -141
  527. package/fesm2015/mtxDialog.js.map +0 -1
  528. package/fesm2015/mtxFormGroup.js +0 -66
  529. package/fesm2015/mtxFormGroup.js.map +0 -1
  530. package/fesm2015/mtxGrid.js +0 -1186
  531. package/fesm2015/mtxGrid.js.map +0 -1
  532. package/fesm2015/mtxLoader.js +0 -87
  533. package/fesm2015/mtxLoader.js.map +0 -1
  534. package/fesm2015/mtxPipes.js +0 -31
  535. package/fesm2015/mtxPipes.js.map +0 -1
  536. package/fesm2015/mtxPopover.js.map +0 -1
  537. package/fesm2015/mtxProgress.js +0 -73
  538. package/fesm2015/mtxProgress.js.map +0 -1
  539. package/fesm2015/mtxSelect.js +0 -700
  540. package/fesm2015/mtxSelect.js.map +0 -1
  541. package/fesm2015/mtxSlider.js.map +0 -1
  542. package/fesm2015/mtxSplit.js.map +0 -1
  543. package/fesm2015/mtxText3d.js +0 -72
  544. package/fesm2015/mtxText3d.js.map +0 -1
  545. package/fesm2015/mtxTooltip.js.map +0 -1
  546. package/form-group/mtxFormGroup.metadata.json +0 -1
  547. package/grid/cell-selection.directive.d.ts +0 -17
  548. package/grid/mtxGrid.metadata.json +0 -1
  549. package/loader/mtxLoader.metadata.json +0 -1
  550. package/pipes/mtxPipes.d.ts +0 -4
  551. package/pipes/mtxPipes.metadata.json +0 -1
  552. package/pipes/package.json +0 -11
  553. package/pipes/pipes.module.d.ts +0 -2
  554. package/popover/mtxPopover.metadata.json +0 -1
  555. package/progress/mtxProgress.metadata.json +0 -1
  556. package/select/mtxSelect.metadata.json +0 -1
  557. package/slider/mtxSlider.metadata.json +0 -1
  558. package/split/mtxSplit.metadata.json +0 -1
  559. package/text3d/mtxText3d.metadata.json +0 -1
  560. package/tooltip/mtxTooltip.metadata.json +0 -1
@@ -1,2355 +0,0 @@
1
- import { A11yModule } from '@angular/cdk/a11y';
2
- import { OverlayConfig, Overlay, OverlayModule } from '@angular/cdk/overlay';
3
- import { CommonModule } from '@angular/common';
4
- import { EventEmitter, Component, ViewEncapsulation, ChangeDetectionStrategy, Input, Output, Optional, Inject, ElementRef, NgZone, ChangeDetectorRef, ViewChild, ViewContainerRef, forwardRef, Directive, NgModule } from '@angular/core';
5
- import { MatButtonModule } from '@angular/material/button';
6
- import { MatIconModule } from '@angular/material/icon';
7
- import { ENTER, PAGE_DOWN, PAGE_UP, END, HOME, DOWN_ARROW, UP_ARROW, RIGHT_ARROW, LEFT_ARROW, ESCAPE, hasModifierKey } from '@angular/cdk/keycodes';
8
- import { coerceBooleanProperty } from '@angular/cdk/coercion';
9
- import { MatDatepickerIntl, MAT_DATEPICKER_SCROLL_STRATEGY } from '@angular/material/datepicker';
10
- import { first, take, filter } from 'rxjs/operators';
11
- import { DatetimeAdapter, MTX_DATETIME_FORMATS } from '@ng-matero/extensions/core';
12
- import { trigger, state, style, transition, animate, keyframes } from '@angular/animations';
13
- import { Directionality } from '@angular/cdk/bidi';
14
- import { ComponentPortal } from '@angular/cdk/portal';
15
- import { Subject, Subscription, merge, of } from 'rxjs';
16
- import { _getFocusedElementPierceShadowDom } from '@angular/cdk/platform';
17
- import { NG_VALUE_ACCESSOR, NG_VALIDATORS, Validators } from '@angular/forms';
18
- import { MAT_INPUT_VALUE_ACCESSOR } from '@angular/material/input';
19
- import { MatFormField } from '@angular/material/form-field';
20
-
21
- /**
22
- * This animation fades in the background color and text content of the
23
- * select's options. It is time delayed to occur 100ms after the overlay
24
- * panel has transformed in.
25
- */
26
- const fadeInContent = trigger('fadeInContent', [
27
- state('showing', style({ opacity: 1 })),
28
- transition('void => showing', [
29
- style({ opacity: 0 }),
30
- animate(`150ms 100ms cubic-bezier(0.55, 0, 0.55, 0.2)`),
31
- ]),
32
- ]);
33
- const slideCalendar = trigger('slideCalendar', [
34
- transition('* => left', [
35
- animate(180, keyframes([
36
- style({ transform: 'translateX(100%)', offset: 0.5 }),
37
- style({ transform: 'translateX(-100%)', offset: 0.51 }),
38
- style({ transform: 'translateX(0)', offset: 1 }),
39
- ])),
40
- ]),
41
- transition('* => right', [
42
- animate(180, keyframes([
43
- style({ transform: 'translateX(-100%)', offset: 0.5 }),
44
- style({ transform: 'translateX(100%)', offset: 0.51 }),
45
- style({ transform: 'translateX(0)', offset: 1 }),
46
- ])),
47
- ]),
48
- ]);
49
-
50
- /** @docs-private */
51
- function createMissingDateImplError(provider) {
52
- return Error(`MtxDatetimepicker: No provider found for ${provider}. You must import one of the following ` +
53
- `modules at your application root: MtxNativeDatetimeModule, MtxMomentDatetimeModule, or provide a ` +
54
- `custom implementation.`);
55
- }
56
-
57
- var MtxDatetimepickerFilterType;
58
- (function (MtxDatetimepickerFilterType) {
59
- MtxDatetimepickerFilterType[MtxDatetimepickerFilterType["DATE"] = 0] = "DATE";
60
- MtxDatetimepickerFilterType[MtxDatetimepickerFilterType["HOUR"] = 1] = "HOUR";
61
- MtxDatetimepickerFilterType[MtxDatetimepickerFilterType["MINUTE"] = 2] = "MINUTE";
62
- })(MtxDatetimepickerFilterType || (MtxDatetimepickerFilterType = {}));
63
-
64
- /**
65
- * An internal class that represents the data corresponding to a single calendar cell.
66
- * @docs-private
67
- */
68
- class MtxCalendarCell {
69
- constructor(value, displayValue, ariaLabel, enabled) {
70
- this.value = value;
71
- this.displayValue = displayValue;
72
- this.ariaLabel = ariaLabel;
73
- this.enabled = enabled;
74
- }
75
- }
76
- /**
77
- * An internal component used to display calendar data in a table.
78
- * @docs-private
79
- */
80
- class MtxCalendarBody {
81
- constructor() {
82
- /** The number of columns in the table. */
83
- this.numCols = 7;
84
- /** Whether to allow selection of disabled cells. */
85
- this.allowDisabledSelection = false;
86
- /** The cell number of the active cell in the table. */
87
- this.activeCell = 0;
88
- /** Emits when a new value is selected. */
89
- this.selectedValueChange = new EventEmitter();
90
- }
91
- /** The number of blank cells to put at the beginning for the first row. */
92
- get _firstRowOffset() {
93
- return this.rows && this.rows.length && this.rows[0].length
94
- ? this.numCols - this.rows[0].length
95
- : 0;
96
- }
97
- _cellClicked(cell) {
98
- if (!this.allowDisabledSelection && !cell.enabled) {
99
- return;
100
- }
101
- this.selectedValueChange.emit(cell.value);
102
- }
103
- _isActiveCell(rowIndex, colIndex) {
104
- let cellNumber = rowIndex * this.numCols + colIndex;
105
- // Account for the fact that the first row may not have as many cells.
106
- if (rowIndex) {
107
- cellNumber -= this._firstRowOffset;
108
- }
109
- return cellNumber === this.activeCell;
110
- }
111
- }
112
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
113
- MtxCalendarBody.decorators = [
114
- { type: Component, args: [{
115
- selector: '[mtx-calendar-body]',
116
- template: "<!--\n If there's not enough space in the first row, create a separate label row. We mark this row as\n aria-hidden because we don't want it to be read out as one of the weeks in the month.\n-->\n<tr *ngIf=\"_firstRowOffset < labelMinRequiredCells\" aria-hidden=\"true\">\n <td [attr.colspan]=\"numCols\" class=\"mtx-calendar-body-label\">{{ label }}</td>\n</tr>\n\n<!-- Create the first row separately so we can include a special spacer cell. -->\n<tr *ngFor=\"let row of rows; let rowIndex = index\" role=\"row\">\n <!--\n We mark this cell as aria-hidden so it doesn't get read out as one of the days in the week.\n -->\n <td *ngIf=\"rowIndex === 0 && _firstRowOffset\"\n [attr.colspan]=\"_firstRowOffset\"\n aria-hidden=\"true\"\n class=\"mtx-calendar-body-label\">\n {{ _firstRowOffset >= labelMinRequiredCells ? label : '' }}\n </td>\n <td *ngFor=\"let item of row; let colIndex = index\"\n role=\"gridcell\"\n class=\"mtx-calendar-body-cell\"\n [tabindex]=\"_isActiveCell(rowIndex, colIndex) ? 0 : -1\"\n [attr.data-mat-row]=\"rowIndex\"\n [attr.data-mat-col]=\"colIndex\"\n [attr.aria-label]=\"item.ariaLabel\"\n [attr.aria-disabled]=\"!item.enabled || null\"\n [class.mtx-calendar-body-active]=\"_isActiveCell(rowIndex, colIndex)\"\n [class.mtx-calendar-body-disabled]=\"!item.enabled\"\n (click)=\"_cellClicked(item)\">\n <div [attr.aria-selected]=\"selectedValue === item.value\"\n [class.mtx-calendar-body-selected]=\"selectedValue === item.value\"\n [class.mtx-calendar-body-today]=\"todayValue === item.value\"\n class=\"mtx-calendar-body-cell-content\">\n {{ item.displayValue }}\n </div>\n </td>\n</tr>\n",
117
- host: {
118
- class: 'mtx-calendar-body',
119
- },
120
- encapsulation: ViewEncapsulation.None,
121
- changeDetection: ChangeDetectionStrategy.OnPush,
122
- styles: [".mtx-calendar-body{min-width:224px}.mtx-calendar-body-label{height:0;line-height:0;text-align:left;padding:7.1428571429% 4.7142857143%}[dir=rtl] .mtx-calendar-body-label{text-align:right}.mtx-calendar-body-cell{position:relative;width:14.2857142857%;height:0;line-height:0;padding:7.1428571429% 0;text-align:center;outline:none;cursor:pointer}.mtx-calendar-body-disabled{cursor:default;pointer-events:none}.mtx-calendar-body-cell-content{position:absolute;top:5%;left:5%;display:flex;align-items:center;justify-content:center;box-sizing:border-box;width:90%;height:90%;border:1px solid transparent;border-radius:999px}\n"]
123
- },] }
124
- ];
125
- /** @type {!Object<string, !Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
126
- MtxCalendarBody.propDecorators = {
127
- label: [{ type: Input }],
128
- rows: [{ type: Input }],
129
- todayValue: [{ type: Input }],
130
- selectedValue: [{ type: Input }],
131
- labelMinRequiredCells: [{ type: Input }],
132
- numCols: [{ type: Input }],
133
- allowDisabledSelection: [{ type: Input }],
134
- activeCell: [{ type: Input }],
135
- selectedValueChange: [{ type: Output }]
136
- };
137
-
138
- const yearsPerPage = 24;
139
- const yearsPerRow = 4;
140
- /**
141
- * An internal component used to display multiple years in the datetimepicker.
142
- * @docs-private
143
- */
144
- class MtxMultiYearView {
145
- constructor(_adapter, _dateFormats) {
146
- this._adapter = _adapter;
147
- this._dateFormats = _dateFormats;
148
- this._userSelection = new EventEmitter();
149
- this.type = 'date';
150
- /** Emits when a new month is selected. */
151
- this.selectedChange = new EventEmitter();
152
- if (!this._adapter) {
153
- throw createMissingDateImplError('DatetimeAdapter');
154
- }
155
- if (!this._dateFormats) {
156
- throw createMissingDateImplError('MTX_DATETIME_FORMATS');
157
- }
158
- this._activeDate = this._adapter.today();
159
- }
160
- /** The date to display in this multi year view */
161
- get activeDate() {
162
- return this._activeDate;
163
- }
164
- set activeDate(value) {
165
- const oldActiveDate = this._activeDate;
166
- this._activeDate = value || this._adapter.today();
167
- if (oldActiveDate &&
168
- this._activeDate &&
169
- !isSameMultiYearView(this._adapter, oldActiveDate, this._activeDate, this.minDate, this.maxDate)) {
170
- this._init();
171
- }
172
- }
173
- /** The currently selected date. */
174
- get selected() {
175
- return this._selected;
176
- }
177
- set selected(value) {
178
- this._selected = value;
179
- this._selectedYear = this._selected && this._adapter.getYear(this._selected);
180
- }
181
- /** The minimum selectable date. */
182
- get minDate() {
183
- return this._minDate;
184
- }
185
- set minDate(value) {
186
- this._minDate = this._getValidDateOrNull(this._adapter.deserialize(value));
187
- }
188
- /** The maximum selectable date. */
189
- get maxDate() {
190
- return this._maxDate;
191
- }
192
- set maxDate(value) {
193
- this._maxDate = this._getValidDateOrNull(this._adapter.deserialize(value));
194
- }
195
- ngAfterContentInit() {
196
- this._init();
197
- }
198
- /** Handles when a new year is selected. */
199
- _yearSelected(year) {
200
- const month = this._adapter.getMonth(this.activeDate);
201
- const normalizedDate = this._adapter.createDatetime(year, month, 1, 0, 0);
202
- this.selectedChange.emit(this._adapter.createDatetime(year, month, Math.min(this._adapter.getDate(this.activeDate), this._adapter.getNumDaysInMonth(normalizedDate)), this._adapter.getHour(this.activeDate), this._adapter.getMinute(this.activeDate)));
203
- if (this.type === 'year') {
204
- this._userSelection.emit();
205
- }
206
- }
207
- _getActiveCell() {
208
- return getActiveOffset(this._adapter, this.activeDate, this.minDate, this.maxDate);
209
- }
210
- _calendarStateDone() {
211
- this._calendarState = '';
212
- }
213
- /** Initializes this year view. */
214
- _init() {
215
- this._todayYear = this._adapter.getYear(this._adapter.today());
216
- this._yearLabel = this._adapter.getYearName(this.activeDate);
217
- const activeYear = this._adapter.getYear(this.activeDate);
218
- const minYearOfPage = activeYear - getActiveOffset(this._adapter, this.activeDate, this.minDate, this.maxDate);
219
- this._years = [];
220
- for (let i = 0, row = []; i < yearsPerPage; i++) {
221
- row.push(minYearOfPage + i);
222
- if (row.length === yearsPerRow) {
223
- this._years.push(row.map(year => this._createCellForYear(year)));
224
- row = [];
225
- }
226
- }
227
- }
228
- /** Creates an MtxCalendarCell for the given year. */
229
- _createCellForYear(year) {
230
- const yearName = this._adapter.getYearName(this._adapter.createDate(year, 0, 1));
231
- return new MtxCalendarCell(year, yearName, yearName, this._shouldEnableYear(year));
232
- }
233
- /** Whether the given year is enabled. */
234
- _shouldEnableYear(year) {
235
- // disable if the year is greater than maxDate lower than minDate
236
- if (year === undefined ||
237
- year === null ||
238
- (this.maxDate && year > this._adapter.getYear(this.maxDate)) ||
239
- (this.minDate && year < this._adapter.getYear(this.minDate))) {
240
- return false;
241
- }
242
- // enable if it reaches here and there's no filter defined
243
- if (!this.dateFilter) {
244
- return true;
245
- }
246
- const firstOfYear = this._adapter.createDate(year, 0, 1);
247
- // If any date in the year is enabled count the year as enabled.
248
- for (let date = firstOfYear; this._adapter.getYear(date) === year; date = this._adapter.addCalendarDays(date, 1)) {
249
- if (this.dateFilter(date)) {
250
- return true;
251
- }
252
- }
253
- return false;
254
- }
255
- /**
256
- * Gets the year in this years range that the given Date falls on.
257
- * Returns null if the given Date is not in this range.
258
- */
259
- _getYearInCurrentRange(date) {
260
- const year = this._adapter.getYear(date);
261
- return this._isInRange(year) ? year : null;
262
- }
263
- /**
264
- * Validate if the current year is in the current range
265
- * Returns true if is in range else returns false
266
- */
267
- _isInRange(year) {
268
- return true;
269
- }
270
- /**
271
- * @param obj The object to check.
272
- * @returns The given object if it is both a date instance and valid, otherwise null.
273
- */
274
- _getValidDateOrNull(obj) {
275
- return this._adapter.isDateInstance(obj) && this._adapter.isValid(obj) ? obj : null;
276
- }
277
- }
278
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
279
- MtxMultiYearView.decorators = [
280
- { type: Component, args: [{
281
- selector: 'mtx-multi-year-view',
282
- template: "<table class=\"mtx-calendar-table\" role=\"grid\">\n <thead class=\"mtx-calendar-table-header\"></thead>\n <tbody mtx-calendar-body\n (@slideCalendar.done)=\"_calendarStateDone()\"\n [@slideCalendar]=\"_calendarState\"\n [todayValue]=\"_todayYear\"\n [rows]=\"_years\"\n [numCols]=\"4\"\n [activeCell]=\"_getActiveCell()\"\n [allowDisabledSelection]=\"true\"\n [selectedValue]=\"_selectedYear!\"\n (selectedValueChange)=\"_yearSelected($event)\"></tbody>\n</table>\n",
283
- animations: [slideCalendar],
284
- encapsulation: ViewEncapsulation.None,
285
- changeDetection: ChangeDetectionStrategy.OnPush
286
- },] }
287
- ];
288
- /**
289
- * @type {function(): !Array<(null|{
290
- * type: ?,
291
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
292
- * })>}
293
- * @nocollapse
294
- */
295
- MtxMultiYearView.ctorParameters = () => [
296
- { type: DatetimeAdapter, decorators: [{ type: Optional }] },
297
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MTX_DATETIME_FORMATS,] }] }
298
- ];
299
- /** @type {!Object<string, !Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
300
- MtxMultiYearView.propDecorators = {
301
- _userSelection: [{ type: Output }],
302
- type: [{ type: Input }],
303
- dateFilter: [{ type: Input }],
304
- selectedChange: [{ type: Output }],
305
- activeDate: [{ type: Input }],
306
- selected: [{ type: Input }],
307
- minDate: [{ type: Input }],
308
- maxDate: [{ type: Input }]
309
- };
310
- function isSameMultiYearView(dateAdapter, date1, date2, minDate, maxDate) {
311
- const year1 = dateAdapter.getYear(date1);
312
- const year2 = dateAdapter.getYear(date2);
313
- const startingYear = getStartingYear(dateAdapter, minDate, maxDate);
314
- return (Math.floor((year1 - startingYear) / yearsPerPage) ===
315
- Math.floor((year2 - startingYear) / yearsPerPage));
316
- }
317
- /**
318
- * When the multi-year view is first opened, the active year will be in view.
319
- * So we compute how many years are between the active year and the *slot* where our
320
- * "startingYear" will render when paged into view.
321
- */
322
- function getActiveOffset(dateAdapter, activeDate, minDate, maxDate) {
323
- const activeYear = dateAdapter.getYear(activeDate);
324
- return euclideanModulo(activeYear - getStartingYear(dateAdapter, minDate, maxDate), yearsPerPage);
325
- }
326
- /**
327
- * We pick a "starting" year such that either the maximum year would be at the end
328
- * or the minimum year would be at the beginning of a page.
329
- */
330
- function getStartingYear(dateAdapter, minDate, maxDate) {
331
- let startingYear = 0;
332
- if (maxDate) {
333
- const maxYear = dateAdapter.getYear(maxDate);
334
- startingYear = maxYear - yearsPerPage + 1;
335
- }
336
- else if (minDate) {
337
- startingYear = dateAdapter.getYear(minDate);
338
- }
339
- return startingYear;
340
- }
341
- /** Gets remainder that is non-negative, even if first number is negative */
342
- function euclideanModulo(a, b) {
343
- return ((a % b) + b) % b;
344
- }
345
-
346
- /**
347
- * A calendar that is used as part of the datetimepicker.
348
- * @docs-private
349
- */
350
- class MtxCalendar {
351
- constructor(_elementRef, _intl, _ngZone, _adapter, _dateFormats, changeDetectorRef) {
352
- this._elementRef = _elementRef;
353
- this._intl = _intl;
354
- this._ngZone = _ngZone;
355
- this._adapter = _adapter;
356
- this._dateFormats = _dateFormats;
357
- this._userSelection = new EventEmitter();
358
- this._multiYearSelector = false;
359
- this._twelvehour = false;
360
- /** Whether the calendar should be started in month or year view. */
361
- this.startView = 'month';
362
- this.timeInterval = 1;
363
- this.ariaLabel = 'Use arrow keys to navigate';
364
- this.ariaNextMonthLabel = 'Next month';
365
- this.ariaPrevMonthLabel = 'Previous month';
366
- this.ariaNextYearLabel = 'Next year';
367
- this.ariaPrevYearLabel = 'Previous year';
368
- this.ariaNextMultiYearLabel = 'Next year range';
369
- this.ariaPrevMultiYearLabel = 'Previous year range';
370
- /** Prevent user to select same date time */
371
- this.preventSameDateTimeSelection = false;
372
- /** Emits when the currently selected date changes. */
373
- this.selectedChange = new EventEmitter();
374
- /** Emits when the view has been changed. */
375
- this.viewChanged = new EventEmitter();
376
- this._clockView = 'hour';
377
- this._type = 'date';
378
- /** Date filter for the month and year views. */
379
- this._dateFilterForViews = (date) => {
380
- return (!!date &&
381
- (!this.dateFilter || this.dateFilter(date, MtxDatetimepickerFilterType.DATE)) &&
382
- (!this.minDate || this._adapter.compareDate(date, this.minDate) >= 0) &&
383
- (!this.maxDate || this._adapter.compareDate(date, this.maxDate) <= 0));
384
- };
385
- if (!this._adapter) {
386
- throw createMissingDateImplError('DatetimeAdapter');
387
- }
388
- if (!this._dateFormats) {
389
- throw createMissingDateImplError('MTX_DATETIME_FORMATS');
390
- }
391
- this._intlChanges = _intl.changes.subscribe(() => changeDetectorRef.markForCheck());
392
- }
393
- get multiYearSelector() {
394
- return this._multiYearSelector;
395
- }
396
- set multiYearSelector(value) {
397
- this._multiYearSelector = coerceBooleanProperty(value);
398
- }
399
- /** if true change the clock to 12 hour format. */
400
- get twelvehour() {
401
- return this._twelvehour;
402
- }
403
- set twelvehour(value) {
404
- this._twelvehour = coerceBooleanProperty(value);
405
- }
406
- get type() {
407
- return this._type;
408
- }
409
- set type(value) {
410
- this._type = value || 'date';
411
- if (this.type === 'year') {
412
- this.multiYearSelector = true;
413
- }
414
- }
415
- /** A date representing the period (month or year) to start the calendar in. */
416
- get startAt() {
417
- return this._startAt;
418
- }
419
- set startAt(value) {
420
- this._startAt = this._adapter.getValidDateOrNull(value);
421
- }
422
- /** The currently selected date. */
423
- get selected() {
424
- return this._selected;
425
- }
426
- set selected(value) {
427
- this._selected = this._adapter.getValidDateOrNull(value);
428
- }
429
- /** The minimum selectable date. */
430
- get minDate() {
431
- return this._minDate;
432
- }
433
- set minDate(value) {
434
- this._minDate = this._adapter.getValidDateOrNull(value);
435
- }
436
- /** The maximum selectable date. */
437
- get maxDate() {
438
- return this._maxDate;
439
- }
440
- set maxDate(value) {
441
- this._maxDate = this._adapter.getValidDateOrNull(value);
442
- }
443
- /**
444
- * The current active date. This determines which time period is shown and which date is
445
- * highlighted when using keyboard navigation.
446
- */
447
- get _activeDate() {
448
- return this._clampedActiveDate;
449
- }
450
- set _activeDate(value) {
451
- const oldActiveDate = this._clampedActiveDate;
452
- this._clampedActiveDate = this._adapter.clampDate(value, this.minDate, this.maxDate);
453
- if (oldActiveDate &&
454
- this._clampedActiveDate &&
455
- this.currentView === 'month' &&
456
- !this._adapter.sameMonthAndYear(oldActiveDate, this._clampedActiveDate)) {
457
- if (this._adapter.isInNextMonth(oldActiveDate, this._clampedActiveDate)) {
458
- this.calendarState('right');
459
- }
460
- else {
461
- this.calendarState('left');
462
- }
463
- }
464
- }
465
- /** Whether the calendar is in month view. */
466
- get currentView() {
467
- return this._currentView;
468
- }
469
- set currentView(view) {
470
- this._currentView = view;
471
- this.viewChanged.emit(view);
472
- }
473
- /** The label for the current calendar view. */
474
- get _yearLabel() {
475
- return this._adapter.getYearName(this._activeDate);
476
- }
477
- get _monthYearLabel() {
478
- if (this.currentView === 'multi-year') {
479
- // The offset from the active year to the "slot" for the starting year is the
480
- // *actual* first rendered year in the multi-year view, and the last year is
481
- // just yearsPerPage - 1 away.
482
- const activeYear = this._adapter.getYear(this._activeDate);
483
- const minYearOfPage = activeYear - getActiveOffset(this._adapter, this._activeDate, this.minDate, this.maxDate);
484
- const maxYearOfPage = minYearOfPage + yearsPerPage - 1;
485
- const minYearName = this._adapter.getYearName(this._adapter.createDate(minYearOfPage, 0, 1));
486
- const maxYearName = this._adapter.getYearName(this._adapter.createDate(maxYearOfPage, 0, 1));
487
- return this._intl.formatYearRange(minYearName, maxYearName);
488
- }
489
- return this.currentView === 'month'
490
- ? this._adapter.getMonthNames('long')[this._adapter.getMonth(this._activeDate)]
491
- : this._adapter.getYearName(this._activeDate);
492
- }
493
- get _dateLabel() {
494
- switch (this.type) {
495
- case 'month':
496
- return this._adapter.getMonthNames('long')[this._adapter.getMonth(this._activeDate)];
497
- default:
498
- return this._adapter.format(this._activeDate, this._dateFormats.display.popupHeaderDateLabel);
499
- }
500
- }
501
- get _hoursLabel() {
502
- let hour = this._adapter.getHour(this._activeDate);
503
- if (!!this.twelvehour) {
504
- if (hour === 0) {
505
- hour = 24;
506
- }
507
- hour = hour > 12 ? hour - 12 : hour;
508
- }
509
- return this._2digit(hour);
510
- }
511
- get _minutesLabel() {
512
- return this._2digit(this._adapter.getMinute(this._activeDate));
513
- }
514
- get _ariaLabelNext() {
515
- switch (this._currentView) {
516
- case 'month':
517
- return this.ariaNextMonthLabel;
518
- case 'year':
519
- return this.ariaNextYearLabel;
520
- case 'multi-year':
521
- return this.ariaNextMultiYearLabel;
522
- default:
523
- return '';
524
- }
525
- }
526
- get _ariaLabelPrev() {
527
- switch (this._currentView) {
528
- case 'month':
529
- return this.ariaPrevMonthLabel;
530
- case 'year':
531
- return this.ariaPrevYearLabel;
532
- case 'multi-year':
533
- return this.ariaPrevMultiYearLabel;
534
- default:
535
- return '';
536
- }
537
- }
538
- _userSelected() {
539
- this._userSelection.emit();
540
- }
541
- ngAfterContentInit() {
542
- this._activeDate = this.startAt || this._adapter.today();
543
- this._selectAMPM(this._activeDate);
544
- if (this.type === 'year') {
545
- this.currentView = 'multi-year';
546
- }
547
- else if (this.type === 'month') {
548
- this.currentView = 'year';
549
- }
550
- else if (this.type === 'time') {
551
- this.currentView = 'clock';
552
- }
553
- else {
554
- this.currentView = this.startView || 'month';
555
- }
556
- }
557
- ngOnDestroy() {
558
- this._intlChanges.unsubscribe();
559
- }
560
- /** Handles date selection in the month view. */
561
- _dateSelected(date) {
562
- if (this.type === 'date') {
563
- if (!this._adapter.sameDate(date, this.selected) || !this.preventSameDateTimeSelection) {
564
- this.selectedChange.emit(date);
565
- }
566
- }
567
- else {
568
- this._activeDate = date;
569
- this.currentView = 'clock';
570
- }
571
- }
572
- /** Handles month selection in the year view. */
573
- _monthSelected(month) {
574
- if (this.type === 'month') {
575
- if (!this._adapter.sameMonthAndYear(month, this.selected) ||
576
- !this.preventSameDateTimeSelection) {
577
- this.selectedChange.emit(this._adapter.getFirstDateOfMonth(month));
578
- }
579
- }
580
- else {
581
- this._activeDate = month;
582
- this.currentView = 'month';
583
- this._clockView = 'hour';
584
- }
585
- }
586
- /** Handles year selection in the multi year view. */
587
- _yearSelected(year) {
588
- if (this.type === 'year') {
589
- if (!this._adapter.sameYear(year, this.selected) || !this.preventSameDateTimeSelection) {
590
- const normalizedDate = this._adapter.createDatetime(this._adapter.getYear(year), 0, 1, 0, 0);
591
- this.selectedChange.emit(normalizedDate);
592
- }
593
- }
594
- else {
595
- this._activeDate = year;
596
- this.currentView = 'year';
597
- }
598
- }
599
- _timeSelected(date) {
600
- if (this._clockView !== 'minute') {
601
- this._activeDate = this._updateDate(date);
602
- this._clockView = 'minute';
603
- }
604
- else {
605
- if (!this._adapter.sameDatetime(date, this.selected) || !this.preventSameDateTimeSelection) {
606
- this.selectedChange.emit(date);
607
- }
608
- }
609
- }
610
- _onActiveDateChange(date) {
611
- this._activeDate = date;
612
- }
613
- _updateDate(date) {
614
- if (!!this.twelvehour) {
615
- const HOUR = this._adapter.getHour(date);
616
- if (HOUR === 12) {
617
- if (this._AMPM === 'AM') {
618
- return this._adapter.addCalendarHours(date, -12);
619
- }
620
- }
621
- else if (this._AMPM === 'PM') {
622
- return this._adapter.addCalendarHours(date, 12);
623
- }
624
- }
625
- return date;
626
- }
627
- _selectAMPM(date) {
628
- if (this._adapter.getHour(date) > 11) {
629
- this._AMPM = 'PM';
630
- }
631
- else {
632
- this._AMPM = 'AM';
633
- }
634
- }
635
- _ampmClicked(source) {
636
- if (source === this._AMPM) {
637
- return;
638
- }
639
- this._AMPM = source;
640
- if (this._AMPM === 'AM') {
641
- this._activeDate = this._adapter.addCalendarHours(this._activeDate, -12);
642
- }
643
- else {
644
- this._activeDate = this._adapter.addCalendarHours(this._activeDate, 12);
645
- }
646
- }
647
- _yearClicked() {
648
- if (this.type === 'year' || this.multiYearSelector) {
649
- this.currentView = 'multi-year';
650
- return;
651
- }
652
- this.currentView = 'year';
653
- }
654
- _dateClicked() {
655
- if (this.type !== 'month') {
656
- this.currentView = 'month';
657
- }
658
- }
659
- _hoursClicked() {
660
- this.currentView = 'clock';
661
- this._clockView = 'hour';
662
- }
663
- _minutesClicked() {
664
- this.currentView = 'clock';
665
- this._clockView = 'minute';
666
- }
667
- /** Handles user clicks on the previous button. */
668
- _previousClicked() {
669
- this._activeDate =
670
- this.currentView === 'month'
671
- ? this._adapter.addCalendarMonths(this._activeDate, -1)
672
- : this._adapter.addCalendarYears(this._activeDate, this.currentView === 'year' ? -1 : -yearsPerPage);
673
- }
674
- /** Handles user clicks on the next button. */
675
- _nextClicked() {
676
- this._activeDate =
677
- this.currentView === 'month'
678
- ? this._adapter.addCalendarMonths(this._activeDate, 1)
679
- : this._adapter.addCalendarYears(this._activeDate, this.currentView === 'year' ? 1 : yearsPerPage);
680
- }
681
- /** Whether the previous period button is enabled. */
682
- _previousEnabled() {
683
- if (!this.minDate) {
684
- return true;
685
- }
686
- return !this.minDate || !this._isSameView(this._activeDate, this.minDate);
687
- }
688
- /** Whether the next period button is enabled. */
689
- _nextEnabled() {
690
- return !this.maxDate || !this._isSameView(this._activeDate, this.maxDate);
691
- }
692
- /** Handles keydown events on the calendar body. */
693
- _handleCalendarBodyKeydown(event) {
694
- // TODO(mmalerba): We currently allow keyboard navigation to disabled dates, but just prevent
695
- // disabled ones from being selected. This may not be ideal, we should look into whether
696
- // navigation should skip over disabled dates, and if so, how to implement that efficiently.
697
- if (this.currentView === 'month') {
698
- this._handleCalendarBodyKeydownInMonthView(event);
699
- }
700
- else if (this.currentView === 'year') {
701
- this._handleCalendarBodyKeydownInYearView(event);
702
- }
703
- else if (this.currentView === 'multi-year') {
704
- this._handleCalendarBodyKeydownInMultiYearView(event);
705
- }
706
- else {
707
- this._handleCalendarBodyKeydownInClockView(event);
708
- }
709
- }
710
- _focusActiveCell() {
711
- this._ngZone.runOutsideAngular(() => {
712
- this._ngZone.onStable
713
- .asObservable()
714
- .pipe(first())
715
- .subscribe(() => {
716
- this._elementRef.nativeElement.focus();
717
- });
718
- });
719
- }
720
- _calendarStateDone() {
721
- this._calendarState = '';
722
- }
723
- /** Whether the two dates represent the same view in the current view mode (month or year). */
724
- _isSameView(date1, date2) {
725
- if (this.currentView === 'month') {
726
- return (this._adapter.getYear(date1) === this._adapter.getYear(date2) &&
727
- this._adapter.getMonth(date1) === this._adapter.getMonth(date2));
728
- }
729
- if (this.currentView === 'year') {
730
- return this._adapter.getYear(date1) === this._adapter.getYear(date2);
731
- }
732
- // Otherwise we are in 'multi-year' view.
733
- return isSameMultiYearView(this._adapter, date1, date2, this.minDate, this.maxDate);
734
- }
735
- /** Handles keydown events on the calendar body when calendar is in month view. */
736
- _handleCalendarBodyKeydownInMonthView(event) {
737
- switch (event.keyCode) {
738
- case LEFT_ARROW:
739
- this._activeDate = this._adapter.addCalendarDays(this._activeDate, -1);
740
- break;
741
- case RIGHT_ARROW:
742
- this._activeDate = this._adapter.addCalendarDays(this._activeDate, 1);
743
- break;
744
- case UP_ARROW:
745
- this._activeDate = this._adapter.addCalendarDays(this._activeDate, -7);
746
- break;
747
- case DOWN_ARROW:
748
- this._activeDate = this._adapter.addCalendarDays(this._activeDate, 7);
749
- break;
750
- case HOME:
751
- this._activeDate = this._adapter.addCalendarDays(this._activeDate, 1 - this._adapter.getDate(this._activeDate));
752
- break;
753
- case END:
754
- this._activeDate = this._adapter.addCalendarDays(this._activeDate, this._adapter.getNumDaysInMonth(this._activeDate) -
755
- this._adapter.getDate(this._activeDate));
756
- break;
757
- case PAGE_UP:
758
- this._activeDate = event.altKey
759
- ? this._adapter.addCalendarYears(this._activeDate, -1)
760
- : this._adapter.addCalendarMonths(this._activeDate, -1);
761
- break;
762
- case PAGE_DOWN:
763
- this._activeDate = event.altKey
764
- ? this._adapter.addCalendarYears(this._activeDate, 1)
765
- : this._adapter.addCalendarMonths(this._activeDate, 1);
766
- break;
767
- case ENTER:
768
- if (this._dateFilterForViews(this._activeDate)) {
769
- this._dateSelected(this._activeDate);
770
- // Prevent unexpected default actions such as form submission.
771
- event.preventDefault();
772
- }
773
- return;
774
- default:
775
- // Don't prevent default or focus active cell on keys that we don't explicitly handle.
776
- return;
777
- }
778
- // Prevent unexpected default actions such as form submission.
779
- event.preventDefault();
780
- }
781
- /** Handles keydown events on the calendar body when calendar is in year view. */
782
- _handleCalendarBodyKeydownInYearView(event) {
783
- switch (event.keyCode) {
784
- case LEFT_ARROW:
785
- this._activeDate = this._adapter.addCalendarMonths(this._activeDate, -1);
786
- break;
787
- case RIGHT_ARROW:
788
- this._activeDate = this._adapter.addCalendarMonths(this._activeDate, 1);
789
- break;
790
- case UP_ARROW:
791
- this._activeDate = this._prevMonthInSameCol(this._activeDate);
792
- break;
793
- case DOWN_ARROW:
794
- this._activeDate = this._nextMonthInSameCol(this._activeDate);
795
- break;
796
- case HOME:
797
- this._activeDate = this._adapter.addCalendarMonths(this._activeDate, -this._adapter.getMonth(this._activeDate));
798
- break;
799
- case END:
800
- this._activeDate = this._adapter.addCalendarMonths(this._activeDate, 11 - this._adapter.getMonth(this._activeDate));
801
- break;
802
- case PAGE_UP:
803
- this._activeDate = this._adapter.addCalendarYears(this._activeDate, event.altKey ? -10 : -1);
804
- break;
805
- case PAGE_DOWN:
806
- this._activeDate = this._adapter.addCalendarYears(this._activeDate, event.altKey ? 10 : 1);
807
- break;
808
- case ENTER:
809
- this._monthSelected(this._activeDate);
810
- break;
811
- default:
812
- // Don't prevent default or focus active cell on keys that we don't explicitly handle.
813
- return;
814
- }
815
- // Prevent unexpected default actions such as form submission.
816
- event.preventDefault();
817
- }
818
- /** Handles keydown events on the calendar body when calendar is in multi-year view. */
819
- _handleCalendarBodyKeydownInMultiYearView(event) {
820
- switch (event.keyCode) {
821
- case LEFT_ARROW:
822
- this._activeDate = this._adapter.addCalendarYears(this._activeDate, -1);
823
- break;
824
- case RIGHT_ARROW:
825
- this._activeDate = this._adapter.addCalendarYears(this._activeDate, 1);
826
- break;
827
- case UP_ARROW:
828
- this._activeDate = this._adapter.addCalendarYears(this._activeDate, -yearsPerRow);
829
- break;
830
- case DOWN_ARROW:
831
- this._activeDate = this._adapter.addCalendarYears(this._activeDate, yearsPerRow);
832
- break;
833
- case HOME:
834
- this._activeDate = this._adapter.addCalendarYears(this._activeDate, -getActiveOffset(this._adapter, this._activeDate, this.minDate, this.maxDate));
835
- break;
836
- case END:
837
- this._activeDate = this._adapter.addCalendarYears(this._activeDate, yearsPerPage -
838
- getActiveOffset(this._adapter, this._activeDate, this.minDate, this.maxDate) -
839
- 1);
840
- break;
841
- case PAGE_UP:
842
- this._activeDate = this._adapter.addCalendarYears(this._activeDate, event.altKey ? -yearsPerPage * 10 : -yearsPerPage);
843
- break;
844
- case PAGE_DOWN:
845
- this._activeDate = this._adapter.addCalendarYears(this._activeDate, event.altKey ? yearsPerPage * 10 : yearsPerPage);
846
- break;
847
- case ENTER:
848
- this._yearSelected(this._activeDate);
849
- break;
850
- default:
851
- // Don't prevent default or focus active cell on keys that we don't explicitly handle.
852
- return;
853
- }
854
- }
855
- /** Handles keydown events on the calendar body when calendar is in month view. */
856
- _handleCalendarBodyKeydownInClockView(event) {
857
- switch (event.keyCode) {
858
- case UP_ARROW:
859
- this._activeDate =
860
- this._clockView === 'hour'
861
- ? this._adapter.addCalendarHours(this._activeDate, 1)
862
- : this._adapter.addCalendarMinutes(this._activeDate, 1);
863
- break;
864
- case DOWN_ARROW:
865
- this._activeDate =
866
- this._clockView === 'hour'
867
- ? this._adapter.addCalendarHours(this._activeDate, -1)
868
- : this._adapter.addCalendarMinutes(this._activeDate, -1);
869
- break;
870
- case ENTER:
871
- this._timeSelected(this._activeDate);
872
- return;
873
- default:
874
- // Don't prevent default or focus active cell on keys that we don't explicitly handle.
875
- return;
876
- }
877
- // Prevent unexpected default actions such as form submission.
878
- event.preventDefault();
879
- }
880
- /**
881
- * Determine the date for the month that comes before the given month in the same column in the
882
- * calendar table.
883
- */
884
- _prevMonthInSameCol(date) {
885
- // Determine how many months to jump forward given that there are 2 empty slots at the beginning
886
- // of each year.
887
- const increment = this._adapter.getMonth(date) <= 4 ? -5 : this._adapter.getMonth(date) >= 7 ? -7 : -12;
888
- return this._adapter.addCalendarMonths(date, increment);
889
- }
890
- /**
891
- * Determine the date for the month that comes after the given month in the same column in the
892
- * calendar table.
893
- */
894
- _nextMonthInSameCol(date) {
895
- // Determine how many months to jump forward given that there are 2 empty slots at the beginning
896
- // of each year.
897
- const increment = this._adapter.getMonth(date) <= 4 ? 7 : this._adapter.getMonth(date) >= 7 ? 5 : 12;
898
- return this._adapter.addCalendarMonths(date, increment);
899
- }
900
- calendarState(direction) {
901
- this._calendarState = direction;
902
- }
903
- _2digit(n) {
904
- return ('00' + n).slice(-2);
905
- }
906
- }
907
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
908
- MtxCalendar.decorators = [
909
- { type: Component, args: [{
910
- selector: 'mtx-calendar',
911
- template: "<div class=\"mtx-calendar-header\">\n <div (click)=\"_yearClicked()\"\n *ngIf=\"type !== 'time'\"\n [class.active]=\"currentView === 'year' || currentView === 'multi-year'\"\n class=\"mtx-calendar-header-year\"\n role=\"button\">\n <span>{{ _yearLabel }}</span>\n <mat-icon *ngIf=\"multiYearSelector || type === 'year'\">arrow_drop_down</mat-icon>\n </div>\n <div class=\"mtx-calendar-header-date-time\">\n <span (click)=\"_dateClicked()\" *ngIf=\"type !== 'time' && type !== 'year'\"\n [class.active]=\"currentView === 'month'\"\n [class.not-clickable]=\"type === 'month'\"\n class=\"mtx-calendar-header-date\"\n role=\"button\">{{ _dateLabel }}</span>\n <span *ngIf=\"type.endsWith('time')\"\n [class.active]=\"currentView === 'clock'\"\n class=\"mtx-calendar-header-time\">\n <span (click)=\"_hoursClicked()\"\n [class.active]=\"_clockView == 'hour'\"\n class=\"mtx-calendar-header-hours\"\n role=\"button\">{{ _hoursLabel }}</span>:<span (click)=\"_minutesClicked()\"\n [class.active]=\"_clockView == 'minute'\"\n class=\"mtx-calendar-header-minutes\"\n role=\"button\">{{ _minutesLabel }}</span>\n <br />\n <span *ngIf=\"twelvehour\" class=\"mtx-calendar-header-ampm-container\">\n <span (click)=\"_ampmClicked('AM')\"\n [class.active]=\"_AMPM === 'AM'\"\n class=\"mtx-calendar-header-ampm\">AM</span>/<span\n (click)=\"_ampmClicked('PM')\"\n [class.active]=\"_AMPM === 'PM'\"\n class=\"mtx-calendar-header-ampm\">PM</span>\n </span>\n </span>\n </div>\n</div>\n<div class=\"mtx-calendar-content\" [ngSwitch]=\"currentView\">\n <div *ngIf=\"currentView === 'month' || currentView === 'year' || currentView === 'multi-year'\"\n class=\"mtx-month-content\">\n <div class=\"mtx-calendar-controls\">\n <button mat-icon-button type=\"button\" (click)=\"_previousClicked()\"\n [attr.aria-disabled]=\"!_previousEnabled()\"\n [attr.aria-label]=\"_ariaLabelPrev\"\n [class.disabled]=\"!_previousEnabled()\"\n class=\"mtx-calendar-previous-button\">\n <svg height=\"24\" viewBox=\"0 0 24 24\" width=\"24\">\n <path d=\"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z\"></path>\n </svg>\n </button>\n <div (@slideCalendar.done)=\"_calendarStateDone()\" [@slideCalendar]=\"_calendarState\"\n class=\"mtx-calendar-period-button\">\n <strong>{{ _monthYearLabel }}</strong>\n </div>\n <button mat-icon-button type=\"button\" (click)=\"_nextClicked()\"\n [attr.aria-disabled]=\"!_nextEnabled()\"\n [attr.aria-label]=\"_ariaLabelNext\"\n [class.disabled]=\"!_nextEnabled()\"\n class=\"mtx-calendar-next-button\">\n <svg height=\"24\" viewBox=\"0 0 24 24\" width=\"24\">\n <path d=\"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z\"></path>\n </svg>\n </button>\n </div>\n </div>\n <mtx-month-view (_userSelection)=\"_userSelected()\"\n (selectedChange)=\"_dateSelected($event)\"\n *ngSwitchCase=\"'month'\"\n [activeDate]=\"_activeDate\"\n [dateFilter]=\"_dateFilterForViews\"\n [selected]=\"selected!\"\n [type]=\"type\">\n </mtx-month-view>\n <mtx-year-view (_userSelection)=\"_userSelected()\"\n (selectedChange)=\"_monthSelected($event)\"\n *ngSwitchCase=\"'year'\"\n [activeDate]=\"_activeDate\"\n [dateFilter]=\"_dateFilterForViews\"\n [selected]=\"selected!\"\n [type]=\"type\">\n </mtx-year-view>\n <mtx-multi-year-view (_userSelection)=\"_userSelected()\"\n (selectedChange)=\"_yearSelected($event)\"\n *ngSwitchCase=\"'multi-year'\"\n [activeDate]=\"_activeDate\"\n [dateFilter]=\"_dateFilterForViews\"\n [maxDate]=\"maxDate\"\n [minDate]=\"minDate\"\n [selected]=\"selected!\"\n [type]=\"type\">\n </mtx-multi-year-view>\n <mtx-clock (_userSelection)=\"_userSelected()\"\n (activeDateChange)=\"_onActiveDateChange($event)\"\n (selectedChange)=\"_timeSelected($event)\"\n *ngSwitchDefault\n [dateFilter]=\"dateFilter\"\n [interval]=\"timeInterval\"\n [maxDate]=\"maxDate\"\n [minDate]=\"minDate\"\n [selected]=\"_activeDate\"\n [startView]=\"_clockView\"\n [twelvehour]=\"twelvehour\">\n </mtx-clock>\n</div>\n",
912
- host: {
913
- 'class': 'mtx-calendar',
914
- '[attr.aria-label]': 'ariaLabel',
915
- 'tabindex': '0',
916
- '(keydown)': '_handleCalendarBodyKeydown($event)',
917
- },
918
- animations: [slideCalendar],
919
- encapsulation: ViewEncapsulation.None,
920
- changeDetection: ChangeDetectionStrategy.OnPush,
921
- styles: [".mtx-calendar{display:block;outline:none}.mtx-calendar[mode=landscape]{display:flex}.mtx-calendar-header{padding:16px;box-sizing:border-box;border-radius:4px 4px 0 0}[mode=landscape] .mtx-calendar-header{width:150px;min-width:150px;border-radius:4px 0 0 4px}[dir=rtl] [mode=landscape] .mtx-calendar-header{border-radius:0 4px 4px 0}.mtx-calendar-header-year,.mtx-calendar-header-date-time{width:100%;white-space:nowrap}.mtx-calendar-header-year{height:32px;line-height:32px}.mtx-calendar-header-year>*{vertical-align:middle}.mtx-calendar-header-date-time{line-height:34px}[mode=landscape] .mtx-calendar-header-date-time{white-space:normal;word-wrap:break-word}.mtx-calendar-header-year:not(.active),.mtx-calendar-header-date:not(.active),.mtx-calendar-header-hours:not(.active),.mtx-calendar-header-minutes:not(.active),.mtx-calendar-header-ampm:not(.active){cursor:pointer;opacity:.6}.mtx-calendar-header-year.not-clickable,.mtx-calendar-header-date.not-clickable,.mtx-calendar-header-hours.not-clickable,.mtx-calendar-header-minutes.not-clickable,.mtx-calendar-header-ampm.not-clickable{cursor:auto;cursor:initial}.mtx-calendar-header-time{display:inline-block;padding-left:8px}.mtx-calendar-header-time:not(.active){opacity:.6}.mtx-calendar-header-time:not(.active) .mtx-calendar-header-hours,.mtx-calendar-header-time:not(.active) .mtx-calendar-header-minutes,.mtx-calendar-header-time:not(.active) .mtx-calendar-header-ampm{cursor:pointer;opacity:1}[dir=rtl] .mtx-calendar-header-time{padding-right:8px}[mode=landscape] .mtx-calendar-header-time{display:block;padding:0}.mtx-calendar-content{width:100%;padding:8px;outline:none;box-sizing:border-box;overflow:hidden}.mtx-calendar-controls{display:flex;justify-content:space-between;margin:0 calc(33% / 7 - 16px)}.mtx-calendar-controls .mat-icon-button:hover .mat-button-focus-overlay{opacity:.04}.mtx-calendar-period-button{display:inline-block;height:40px;line-height:40px;outline:none;border:0;background:transparent;box-sizing:border-box}.mtx-calendar-previous-button.disabled,.mtx-calendar-next-button.disabled{pointer-events:none}.mtx-calendar-previous-button svg,.mtx-calendar-next-button svg{fill:currentColor;vertical-align:top}[dir=rtl] .mtx-calendar-previous-button svg,[dir=rtl] .mtx-calendar-next-button svg{transform:rotate(180deg)}.mtx-calendar-table{border-spacing:0;border-collapse:collapse;width:100%}.mtx-calendar-table-header th{text-align:center;padding:8px 0}@media all and (orientation: landscape){.mtx-calendar[mode=auto]{display:flex}.mtx-calendar[mode=auto] .mtx-calendar-header{width:150px;min-width:150px;border-radius:4px 0 0 4px}[dir=rtl] .mtx-calendar[mode=auto] .mtx-calendar-header{border-radius:0 4px 4px 0}.mtx-calendar[mode=auto] .mtx-calendar-header-date-time{white-space:normal;word-wrap:break-word}.mtx-calendar[mode=auto] .mtx-calendar-header-time{display:block;padding:0}}\n"]
922
- },] }
923
- ];
924
- /**
925
- * @type {function(): !Array<(null|{
926
- * type: ?,
927
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
928
- * })>}
929
- * @nocollapse
930
- */
931
- MtxCalendar.ctorParameters = () => [
932
- { type: ElementRef },
933
- { type: MatDatepickerIntl },
934
- { type: NgZone },
935
- { type: DatetimeAdapter, decorators: [{ type: Optional }] },
936
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MTX_DATETIME_FORMATS,] }] },
937
- { type: ChangeDetectorRef }
938
- ];
939
- /** @type {!Object<string, !Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
940
- MtxCalendar.propDecorators = {
941
- _userSelection: [{ type: Output }],
942
- multiYearSelector: [{ type: Input }],
943
- twelvehour: [{ type: Input }],
944
- startView: [{ type: Input }],
945
- timeInterval: [{ type: Input }],
946
- dateFilter: [{ type: Input }],
947
- ariaLabel: [{ type: Input }],
948
- ariaNextMonthLabel: [{ type: Input }],
949
- ariaPrevMonthLabel: [{ type: Input }],
950
- ariaNextYearLabel: [{ type: Input }],
951
- ariaPrevYearLabel: [{ type: Input }],
952
- ariaNextMultiYearLabel: [{ type: Input }],
953
- ariaPrevMultiYearLabel: [{ type: Input }],
954
- preventSameDateTimeSelection: [{ type: Input }],
955
- selectedChange: [{ type: Output }],
956
- viewChanged: [{ type: Output }],
957
- type: [{ type: Input }],
958
- startAt: [{ type: Input }],
959
- selected: [{ type: Input }],
960
- minDate: [{ type: Input }],
961
- maxDate: [{ type: Input }]
962
- };
963
-
964
- const CLOCK_RADIUS = 50;
965
- const CLOCK_INNER_RADIUS = 27.5;
966
- const CLOCK_OUTER_RADIUS = 41.25;
967
- const CLOCK_TICK_RADIUS = 7.0833;
968
- /**
969
- * A clock that is used as part of the datetimepicker.
970
- * @docs-private
971
- */
972
- class MtxClock {
973
- constructor(_element, _adapter) {
974
- this._element = _element;
975
- this._adapter = _adapter;
976
- this._userSelection = new EventEmitter();
977
- this.interval = 1;
978
- this.twelvehour = false;
979
- /** Emits when the currently selected date changes. */
980
- this.selectedChange = new EventEmitter();
981
- this.activeDateChange = new EventEmitter();
982
- /** Hours and Minutes representing the clock view. */
983
- this._hours = [];
984
- this._minutes = [];
985
- /** Whether the clock is in hour view. */
986
- this._hourView = true;
987
- this._timeChanged = false;
988
- this.mouseMoveListener = (event) => {
989
- this._handleMousemove(event);
990
- };
991
- this.mouseUpListener = () => {
992
- this._handleMouseup();
993
- };
994
- }
995
- /**
996
- * The date to display in this clock view.
997
- */
998
- get activeDate() {
999
- return this._activeDate;
1000
- }
1001
- set activeDate(value) {
1002
- const oldActiveDate = this._activeDate;
1003
- this._activeDate = this._adapter.clampDate(value, this.minDate, this.maxDate);
1004
- if (!this._adapter.sameMinute(oldActiveDate, this._activeDate)) {
1005
- this._init();
1006
- }
1007
- }
1008
- /** The currently selected date. */
1009
- get selected() {
1010
- return this._selected;
1011
- }
1012
- set selected(value) {
1013
- this._selected = this._adapter.getValidDateOrNull(this._adapter.deserialize(value));
1014
- if (this._selected) {
1015
- this.activeDate = this._selected;
1016
- }
1017
- }
1018
- /** The minimum selectable date. */
1019
- get minDate() {
1020
- return this._minDate;
1021
- }
1022
- set minDate(value) {
1023
- this._minDate = this._adapter.getValidDateOrNull(this._adapter.deserialize(value));
1024
- }
1025
- /** The maximum selectable date. */
1026
- get maxDate() {
1027
- return this._maxDate;
1028
- }
1029
- set maxDate(value) {
1030
- this._maxDate = this._adapter.getValidDateOrNull(this._adapter.deserialize(value));
1031
- }
1032
- /** Whether the clock should be started in hour or minute view. */
1033
- set startView(value) {
1034
- this._hourView = value !== 'minute';
1035
- }
1036
- get _hand() {
1037
- let hour = this._adapter.getHour(this.activeDate);
1038
- if (!!this.twelvehour) {
1039
- if (hour === 0) {
1040
- hour = 24;
1041
- }
1042
- this._selectedHour = hour > 12 ? hour - 12 : hour;
1043
- }
1044
- else {
1045
- this._selectedHour = hour;
1046
- }
1047
- this._selectedMinute = this._adapter.getMinute(this.activeDate);
1048
- let deg = 0;
1049
- let radius = CLOCK_OUTER_RADIUS;
1050
- if (this._hourView) {
1051
- const outer = this._selectedHour > 0 && this._selectedHour < 13;
1052
- radius = outer ? CLOCK_OUTER_RADIUS : CLOCK_INNER_RADIUS;
1053
- if (this.twelvehour) {
1054
- radius = CLOCK_OUTER_RADIUS;
1055
- }
1056
- deg = Math.round(this._selectedHour * (360 / (24 / 2)));
1057
- }
1058
- else {
1059
- deg = Math.round(this._selectedMinute * (360 / 60));
1060
- }
1061
- return {
1062
- 'transform': `rotate(${deg}deg)`,
1063
- 'height': `${radius}%`,
1064
- 'margin-top': `${50 - radius}%`,
1065
- };
1066
- }
1067
- ngAfterContentInit() {
1068
- this.activeDate = this._activeDate || this._adapter.today();
1069
- this._init();
1070
- }
1071
- /**
1072
- * TODO: use `fromEvent` of rxjs.
1073
- * Handles mousedown events on the clock body.
1074
- */
1075
- _handleMousedown(event) {
1076
- this._timeChanged = false;
1077
- this.setTime(event);
1078
- document.addEventListener('mousemove', this.mouseMoveListener);
1079
- document.addEventListener('touchmove', this.mouseMoveListener);
1080
- document.addEventListener('mouseup', this.mouseUpListener);
1081
- document.addEventListener('touchend', this.mouseUpListener);
1082
- }
1083
- _handleMousemove(event) {
1084
- event.preventDefault();
1085
- this.setTime(event);
1086
- }
1087
- _handleMouseup() {
1088
- document.removeEventListener('mousemove', this.mouseMoveListener);
1089
- document.removeEventListener('touchmove', this.mouseMoveListener);
1090
- document.removeEventListener('mouseup', this.mouseUpListener);
1091
- document.removeEventListener('touchend', this.mouseUpListener);
1092
- if (this._timeChanged) {
1093
- this.selectedChange.emit(this.activeDate);
1094
- if (!this._hourView) {
1095
- this._userSelection.emit();
1096
- }
1097
- }
1098
- }
1099
- /** Initializes this clock view. */
1100
- _init() {
1101
- this._hours.length = 0;
1102
- this._minutes.length = 0;
1103
- const hourNames = this._adapter.getHourNames();
1104
- const minuteNames = this._adapter.getMinuteNames();
1105
- if (this.twelvehour) {
1106
- for (let i = 1; i < hourNames.length / 2 + 1; i++) {
1107
- const radian = (i / 6) * Math.PI;
1108
- const radius = CLOCK_OUTER_RADIUS;
1109
- const date = this._adapter.createDatetime(this._adapter.getYear(this.activeDate), this._adapter.getMonth(this.activeDate), this._adapter.getDate(this.activeDate), i + 1, 0);
1110
- const enabled = (!this.minDate || this._adapter.compareDatetime(date, this.minDate) >= 0) &&
1111
- (!this.maxDate || this._adapter.compareDatetime(date, this.maxDate) <= 0);
1112
- this._hours.push({
1113
- value: i,
1114
- displayValue: i === 0 ? '00' : hourNames[i],
1115
- enabled,
1116
- top: CLOCK_RADIUS - Math.cos(radian) * radius - CLOCK_TICK_RADIUS,
1117
- left: CLOCK_RADIUS + Math.sin(radian) * radius - CLOCK_TICK_RADIUS,
1118
- });
1119
- }
1120
- }
1121
- else {
1122
- for (let i = 0; i < hourNames.length; i++) {
1123
- const radian = (i / 6) * Math.PI;
1124
- const outer = i > 0 && i < 13;
1125
- const radius = outer ? CLOCK_OUTER_RADIUS : CLOCK_INNER_RADIUS;
1126
- const date = this._adapter.createDatetime(this._adapter.getYear(this.activeDate), this._adapter.getMonth(this.activeDate), this._adapter.getDate(this.activeDate), i, 0);
1127
- const enabled = (!this.minDate || this._adapter.compareDatetime(date, this.minDate, false) >= 0) &&
1128
- (!this.maxDate || this._adapter.compareDatetime(date, this.maxDate, false) <= 0) &&
1129
- (!this.dateFilter || this.dateFilter(date, MtxDatetimepickerFilterType.HOUR));
1130
- this._hours.push({
1131
- value: i,
1132
- displayValue: i === 0 ? '00' : hourNames[i],
1133
- enabled,
1134
- top: CLOCK_RADIUS - Math.cos(radian) * radius - CLOCK_TICK_RADIUS,
1135
- left: CLOCK_RADIUS + Math.sin(radian) * radius - CLOCK_TICK_RADIUS,
1136
- fontSize: i > 0 && i < 13 ? '' : '80%',
1137
- });
1138
- }
1139
- }
1140
- for (let i = 0; i < minuteNames.length; i += 5) {
1141
- const radian = (i / 30) * Math.PI;
1142
- const date = this._adapter.createDatetime(this._adapter.getYear(this.activeDate), this._adapter.getMonth(this.activeDate), this._adapter.getDate(this.activeDate), this._adapter.getHour(this.activeDate), i);
1143
- const enabled = (!this.minDate || this._adapter.compareDatetime(date, this.minDate) >= 0) &&
1144
- (!this.maxDate || this._adapter.compareDatetime(date, this.maxDate) <= 0) &&
1145
- (!this.dateFilter || this.dateFilter(date, MtxDatetimepickerFilterType.MINUTE));
1146
- this._minutes.push({
1147
- value: i,
1148
- displayValue: i === 0 ? '00' : minuteNames[i],
1149
- enabled,
1150
- top: CLOCK_RADIUS - Math.cos(radian) * CLOCK_OUTER_RADIUS - CLOCK_TICK_RADIUS,
1151
- left: CLOCK_RADIUS + Math.sin(radian) * CLOCK_OUTER_RADIUS - CLOCK_TICK_RADIUS,
1152
- });
1153
- }
1154
- }
1155
- /**
1156
- * Set Time
1157
- * @param event
1158
- */
1159
- setTime(event) {
1160
- const trigger = this._element.nativeElement;
1161
- const triggerRect = trigger.getBoundingClientRect();
1162
- const width = trigger.offsetWidth;
1163
- const height = trigger.offsetHeight;
1164
- const pageX = event.pageX !== undefined ? event.pageX : event.touches[0].pageX;
1165
- const pageY = event.pageY !== undefined ? event.pageY : event.touches[0].pageY;
1166
- const x = width / 2 - (pageX - triggerRect.left - window.pageXOffset);
1167
- const y = height / 2 - (pageY - triggerRect.top - window.pageYOffset);
1168
- let radian = Math.atan2(-x, y);
1169
- const unit = Math.PI / (this._hourView ? 6 : this.interval ? 30 / this.interval : 30);
1170
- const z = Math.sqrt(x * x + y * y);
1171
- const outer = this._hourView &&
1172
- z > (width * (CLOCK_OUTER_RADIUS / 100) + width * (CLOCK_INNER_RADIUS / 100)) / 2;
1173
- if (radian < 0) {
1174
- radian = Math.PI * 2 + radian;
1175
- }
1176
- let value = Math.round(radian / unit);
1177
- let date;
1178
- if (this._hourView) {
1179
- if (this.twelvehour) {
1180
- value = value === 0 ? 12 : value;
1181
- }
1182
- else {
1183
- if (value === 12) {
1184
- value = 0;
1185
- }
1186
- value = outer ? (value === 0 ? 12 : value) : value === 0 ? 0 : value + 12;
1187
- }
1188
- date = this._adapter.createDatetime(this._adapter.getYear(this.activeDate), this._adapter.getMonth(this.activeDate), this._adapter.getDate(this.activeDate), value, this._adapter.getMinute(this.activeDate));
1189
- }
1190
- else {
1191
- if (this.interval) {
1192
- value *= this.interval;
1193
- }
1194
- if (value === 60) {
1195
- value = 0;
1196
- }
1197
- date = this._adapter.createDatetime(this._adapter.getYear(this.activeDate), this._adapter.getMonth(this.activeDate), this._adapter.getDate(this.activeDate), this._adapter.getHour(this.activeDate), value);
1198
- }
1199
- this._timeChanged = true;
1200
- this.activeDate = date;
1201
- this.activeDateChange.emit(this.activeDate);
1202
- }
1203
- }
1204
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
1205
- MtxClock.decorators = [
1206
- { type: Component, args: [{
1207
- selector: 'mtx-clock',
1208
- template: "<div class=\"mtx-clock-wrapper\">\n <div class=\"mtx-clock-center\"></div>\n <div [ngStyle]=\"_hand\" class=\"mtx-clock-hand\"></div>\n <div [class.active]=\"_hourView\" class=\"mtx-clock-hours\">\n <div *ngFor=\"let item of _hours\"\n [class.mtx-clock-cell-disabled]=\"!item.enabled\"\n [class.mtx-clock-cell-selected]=\"_selectedHour == item.value\"\n [style.fontSize]=\"item.fontSize\"\n [style.left]=\"item.left+'%'\"\n [style.top]=\"item.top+'%'\"\n class=\"mtx-clock-cell\">{{ item.displayValue }}</div>\n </div>\n <div [class.active]=\"!_hourView\" class=\"mtx-clock-minutes\">\n <div *ngFor=\"let item of _minutes\"\n [class.mtx-clock-cell-disabled]=\"!item.enabled\"\n [class.mtx-clock-cell-selected]=\"_selectedMinute == item.value\"\n [style.left]=\"item.left+'%'\"\n [style.top]=\"item.top+'%'\"\n class=\"mtx-clock-cell\">{{ item.displayValue }}</div>\n </div>\n</div>\n",
1209
- host: {
1210
- '[class.mtx-clock]': 'true',
1211
- 'role': 'clock',
1212
- '(mousedown)': '_handleMousedown($event)',
1213
- },
1214
- encapsulation: ViewEncapsulation.None,
1215
- styles: [".mtx-clock{position:relative;display:block;min-width:224px;margin:8px;box-sizing:border-box;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.mtx-clock-wrapper{position:relative;width:100%;height:0;padding-top:100%;border-radius:50%}.mtx-clock-center{position:absolute;top:50%;left:50%;width:2%;height:2%;margin:-1%;border-radius:50%}.mtx-clock-hand{position:absolute;top:0;right:0;bottom:0;left:0;width:1px;margin:0 auto;transform-origin:bottom}.mtx-clock-hand:before{content:\"\";position:absolute;top:-4px;left:-4px;width:8px;height:8px;border-radius:50%}.mtx-clock-hours,.mtx-clock-minutes{position:absolute;top:0;left:0;width:100%;height:100%;opacity:0;visibility:hidden;transition:.35s;transform:scale(1.2)}.mtx-clock-hours.active,.mtx-clock-minutes.active{opacity:1;visibility:visible;transform:scale(1)}.mtx-clock-minutes{transform:scale(.8)}.mtx-clock-cell{position:absolute;display:flex;width:14.1666%;height:14.1666%;justify-content:center;box-sizing:border-box;border-radius:50%;align-items:center;cursor:pointer}.mtx-clock-cell.mtx-clock-cell-disabled{pointer-events:none}\n"]
1216
- },] }
1217
- ];
1218
- /**
1219
- * @type {function(): !Array<(null|{
1220
- * type: ?,
1221
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
1222
- * })>}
1223
- * @nocollapse
1224
- */
1225
- MtxClock.ctorParameters = () => [
1226
- { type: ElementRef },
1227
- { type: DatetimeAdapter }
1228
- ];
1229
- /** @type {!Object<string, !Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
1230
- MtxClock.propDecorators = {
1231
- _userSelection: [{ type: Output }],
1232
- dateFilter: [{ type: Input }],
1233
- interval: [{ type: Input }],
1234
- twelvehour: [{ type: Input }],
1235
- selectedChange: [{ type: Output }],
1236
- activeDateChange: [{ type: Output }],
1237
- activeDate: [{ type: Input }],
1238
- selected: [{ type: Input }],
1239
- minDate: [{ type: Input }],
1240
- maxDate: [{ type: Input }],
1241
- startView: [{ type: Input }]
1242
- };
1243
-
1244
- /** Used to generate a unique ID for each datetimepicker instance. */
1245
- let datetimepickerUid = 0;
1246
- /**
1247
- * Component used as the content for the datetimepicker dialog and popup. We use this instead of
1248
- * using MtxCalendar directly as the content so we can control the initial focus. This also gives us
1249
- * a place to put additional features of the popup that are not part of the calendar itself in the
1250
- * future. (e.g. confirmation buttons).
1251
- * @docs-private
1252
- */
1253
- class MtxDatetimepickerContent {
1254
- ngAfterContentInit() {
1255
- this._calendar._focusActiveCell();
1256
- }
1257
- onSelectionChange(date) {
1258
- this.datetimepicker._select(date);
1259
- this.datetimepicker.close();
1260
- }
1261
- }
1262
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
1263
- MtxDatetimepickerContent.decorators = [
1264
- { type: Component, args: [{
1265
- selector: 'mtx-datetimepicker-content',
1266
- template: "<div cdkTrapFocus\n class=\"mtx-datetimepicker-content-container\"\n [attr.mode]=\"datetimepicker.mode\">\n <mtx-calendar (_userSelection)=\"datetimepicker.close()\"\n (selectedChange)=\"onSelectionChange($event)\"\n (viewChanged)=\"datetimepicker._viewChanged($event)\"\n [ariaNextMonthLabel]=\"datetimepicker.ariaNextMonthLabel\"\n [ariaNextYearLabel]=\"datetimepicker.ariaNextYearLabel\"\n [ariaPrevMonthLabel]=\"datetimepicker.ariaPrevMonthLabel\"\n [ariaPrevYearLabel]=\"datetimepicker.ariaPrevYearLabel\"\n [preventSameDateTimeSelection]=\"datetimepicker.preventSameDateTimeSelection\"\n [attr.mode]=\"datetimepicker.mode\"\n [id]=\"datetimepicker.id\"\n [maxDate]=\"datetimepicker._maxDate\"\n [minDate]=\"datetimepicker._minDate\"\n [dateFilter]=\"datetimepicker._dateFilter\"\n [selected]=\"datetimepicker._selected\"\n [multiYearSelector]=\"datetimepicker.multiYearSelector\"\n [startAt]=\"datetimepicker.startAt\"\n [startView]=\"datetimepicker.startView\"\n [timeInterval]=\"datetimepicker.timeInterval\"\n [twelvehour]=\"datetimepicker.twelvehour\"\n [type]=\"datetimepicker.type\">\n </mtx-calendar>\n</div>\n",
1267
- host: {
1268
- 'class': 'mtx-datetimepicker-content',
1269
- '[class.mtx-datetimepicker-content-touch]': 'datetimepicker?.touchUi',
1270
- '[attr.mode]': 'datetimepicker.mode',
1271
- },
1272
- encapsulation: ViewEncapsulation.None,
1273
- changeDetection: ChangeDetectionStrategy.OnPush,
1274
- styles: [".mtx-datetimepicker-content{display:block;border-radius:4px}.mtx-datetimepicker-content-container{display:flex;flex-direction:column;justify-content:space-between}.mtx-datetimepicker-content .mtx-calendar{width:296px;height:404px}.mtx-datetimepicker-content .mtx-calendar[mode=landscape]{width:446px;height:328px}@media all and (orientation: landscape){.mtx-datetimepicker-content .mtx-calendar[mode=auto]{width:446px;height:328px}}.mtx-datetimepicker-content-touch{display:block;max-height:80vh;position:relative;overflow:visible}.mtx-datetimepicker-content-touch .mtx-datetimepicker-content-container{min-height:300px;max-height:850px;min-width:250px;max-width:750px}.mtx-datetimepicker-content-touch .mtx-calendar{width:100%;height:auto}@media all and (orientation: landscape){.mtx-datetimepicker-content-touch .mtx-datetimepicker-content-container[mode=auto],.mtx-datetimepicker-content-touch .mtx-datetimepicker-content-container[mode=landscape]{width:120vh;height:80vh}.mtx-datetimepicker-content-touch .mtx-datetimepicker-content-container[mode=auto] .mtx-calendar,.mtx-datetimepicker-content-touch .mtx-datetimepicker-content-container[mode=landscape] .mtx-calendar{width:auto;height:100%}.mtx-datetimepicker-content-touch .mtx-datetimepicker-content-container[mode=portrait]{width:64vh;height:90vh}.mtx-datetimepicker-content-touch .mtx-datetimepicker-content-container[mode=portrait] .mtx-calendar{width:100%;height:auto}}@media all and (orientation: portrait){.mtx-datetimepicker-content-touch .mtx-datetimepicker-content-container[mode=auto],.mtx-datetimepicker-content-touch .mtx-datetimepicker-content-container[mode=portrait]{width:80vw;height:120vw}.mtx-datetimepicker-content-touch .mtx-datetimepicker-content-container[mode=auto] .mtx-calendar,.mtx-datetimepicker-content-touch .mtx-datetimepicker-content-container[mode=portrait] .mtx-calendar{width:100%;height:auto}.mtx-datetimepicker-content-touch .mtx-datetimepicker-content-container[mode=landscape]{width:90vw;height:64vw}.mtx-datetimepicker-content-touch .mtx-datetimepicker-content-container[mode=landscape] .mtx-calendar{width:auto;height:100%}.mtx-datetimepicker-content-touch .mtx-datetimepicker-content-container-with-actions{height:135vw}}\n"]
1275
- },] }
1276
- ];
1277
- /** @type {!Object<string, !Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
1278
- MtxDatetimepickerContent.propDecorators = {
1279
- _calendar: [{ type: ViewChild, args: [MtxCalendar, { static: true },] }]
1280
- };
1281
- class MtxDatetimepicker {
1282
- constructor(_overlay, _ngZone, _viewContainerRef, _scrollStrategy, _dateAdapter, _dir) {
1283
- this._overlay = _overlay;
1284
- this._ngZone = _ngZone;
1285
- this._viewContainerRef = _viewContainerRef;
1286
- this._scrollStrategy = _scrollStrategy;
1287
- this._dateAdapter = _dateAdapter;
1288
- this._dir = _dir;
1289
- this._multiYearSelector = false;
1290
- this._twelvehour = false;
1291
- /** The view that the calendar should start in. */
1292
- this.startView = 'month';
1293
- this.mode = 'auto';
1294
- this.timeInterval = 1;
1295
- this.ariaNextMonthLabel = 'Next month';
1296
- this.ariaPrevMonthLabel = 'Previous month';
1297
- this.ariaNextYearLabel = 'Next year';
1298
- this.ariaPrevYearLabel = 'Previous year';
1299
- /** Prevent user to select same date time */
1300
- this.preventSameDateTimeSelection = false;
1301
- /**
1302
- * Emits new selected date when selected date changes.
1303
- * @deprecated Switch to the `dateChange` and `dateInput` binding on the input element.
1304
- */
1305
- this.selectedChanged = new EventEmitter();
1306
- /** Emits when the datetimepicker has been opened. */
1307
- this.openedStream = new EventEmitter();
1308
- /** Emits when the datetimepicker has been closed. */
1309
- this.closedStream = new EventEmitter();
1310
- /** Emits when the view has been changed. */
1311
- this.viewChanged = new EventEmitter();
1312
- /** Whether the calendar is open. */
1313
- this.opened = false;
1314
- /** The id for the datetimepicker calendar. */
1315
- this.id = `mtx-datetimepicker-${datetimepickerUid++}`;
1316
- /** Emits when the datetimepicker is disabled. */
1317
- this._disabledChange = new Subject();
1318
- this._validSelected = null;
1319
- /** The element that was focused before the datetimepicker was opened. */
1320
- this._focusedElementBeforeOpen = null;
1321
- /** Unique class that will be added to the backdrop so that the test harnesses can look it up. */
1322
- this._backdropHarnessClass = `${this.id}-backdrop`;
1323
- this._inputStateChanges = Subscription.EMPTY;
1324
- this._type = 'date';
1325
- this._touchUi = false;
1326
- if (!this._dateAdapter) {
1327
- throw createMissingDateImplError('DateAdapter');
1328
- }
1329
- }
1330
- /** Active multi year view when click on year. */
1331
- get multiYearSelector() {
1332
- return this._multiYearSelector;
1333
- }
1334
- set multiYearSelector(value) {
1335
- this._multiYearSelector = coerceBooleanProperty(value);
1336
- }
1337
- /** if true change the clock to 12 hour format. */
1338
- get twelvehour() {
1339
- return this._twelvehour;
1340
- }
1341
- set twelvehour(value) {
1342
- this._twelvehour = coerceBooleanProperty(value);
1343
- }
1344
- /** The date to open the calendar to initially. */
1345
- get startAt() {
1346
- // If an explicit startAt is set we start there, otherwise we start at whatever the currently
1347
- // selected value is.
1348
- return this._startAt || (this._datetimepickerInput ? this._datetimepickerInput.value : null);
1349
- }
1350
- set startAt(date) {
1351
- this._startAt = this._dateAdapter.getValidDateOrNull(date);
1352
- }
1353
- get openOnFocus() {
1354
- return this._openOnFocus;
1355
- }
1356
- set openOnFocus(value) {
1357
- this._openOnFocus = coerceBooleanProperty(value);
1358
- }
1359
- get type() {
1360
- return this._type;
1361
- }
1362
- set type(value) {
1363
- this._type = value || 'date';
1364
- }
1365
- /**
1366
- * Whether the calendar UI is in touch mode. In touch mode the calendar opens in a dialog rather
1367
- * than a popup and elements have more padding to allow for bigger touch targets.
1368
- */
1369
- get touchUi() {
1370
- return this._touchUi;
1371
- }
1372
- set touchUi(value) {
1373
- this._touchUi = coerceBooleanProperty(value);
1374
- }
1375
- /** Whether the datetimepicker pop-up should be disabled. */
1376
- get disabled() {
1377
- return this._disabled === undefined && this._datetimepickerInput
1378
- ? this._datetimepickerInput.disabled
1379
- : !!this._disabled;
1380
- }
1381
- set disabled(value) {
1382
- const newValue = coerceBooleanProperty(value);
1383
- if (newValue !== this._disabled) {
1384
- this._disabled = newValue;
1385
- this._disabledChange.next(newValue);
1386
- }
1387
- }
1388
- /** The currently selected date. */
1389
- get _selected() {
1390
- return this._validSelected;
1391
- }
1392
- set _selected(value) {
1393
- this._validSelected = value;
1394
- }
1395
- /** The minimum selectable date. */
1396
- get _minDate() {
1397
- return this._datetimepickerInput && this._datetimepickerInput.min;
1398
- }
1399
- /** The maximum selectable date. */
1400
- get _maxDate() {
1401
- return this._datetimepickerInput && this._datetimepickerInput.max;
1402
- }
1403
- get _dateFilter() {
1404
- return this._datetimepickerInput && this._datetimepickerInput._dateFilter;
1405
- }
1406
- _viewChanged(type) {
1407
- this.viewChanged.emit(type);
1408
- }
1409
- ngOnDestroy() {
1410
- this._destroyOverlay();
1411
- this.close();
1412
- this._inputStateChanges.unsubscribe();
1413
- this._disabledChange.complete();
1414
- }
1415
- /**
1416
- * TODO: use model
1417
- * Selects the given date
1418
- */
1419
- _select(date) {
1420
- const oldValue = this._selected;
1421
- this._selected = date;
1422
- if (!this._dateAdapter.sameDatetime(oldValue, this._selected)) {
1423
- this.selectedChanged.emit(date);
1424
- }
1425
- }
1426
- /**
1427
- * Register an input with this datetimepicker.
1428
- * @param input The datetimepicker input to register with this datetimepicker.
1429
- */
1430
- _registerInput(input) {
1431
- if (this._datetimepickerInput) {
1432
- throw Error('A MtxDatetimepicker can only be associated with a single input.');
1433
- }
1434
- this._datetimepickerInput = input;
1435
- this._inputStateChanges = this._datetimepickerInput._valueChange.subscribe((value) => (this._selected = value));
1436
- }
1437
- /** Open the calendar. */
1438
- open() {
1439
- if (this.opened || this.disabled) {
1440
- return;
1441
- }
1442
- if (!this._datetimepickerInput) {
1443
- throw Error('Attempted to open an MtxDatetimepicker with no associated input.');
1444
- }
1445
- this._focusedElementBeforeOpen = _getFocusedElementPierceShadowDom();
1446
- this._openOverlay();
1447
- this.opened = true;
1448
- this.openedStream.emit();
1449
- }
1450
- /** Close the calendar. */
1451
- close() {
1452
- if (!this.opened) {
1453
- return;
1454
- }
1455
- if (this._componentRef) {
1456
- this._destroyOverlay();
1457
- }
1458
- const completeClose = () => {
1459
- // The `_opened` could've been reset already if
1460
- // we got two events in quick succession.
1461
- if (this.opened) {
1462
- this.opened = false;
1463
- this.closedStream.emit();
1464
- this._focusedElementBeforeOpen = null;
1465
- }
1466
- };
1467
- if (this._focusedElementBeforeOpen &&
1468
- typeof this._focusedElementBeforeOpen.focus === 'function') {
1469
- // Because IE moves focus asynchronously, we can't count on it being restored before we've
1470
- // marked the datetimepicker as closed. If the event fires out of sequence and the element
1471
- // that we're refocusing opens the datetimepicker on focus, the user could be stuck with not
1472
- // being able to close the calendar at all. We work around it by making the logic, that marks
1473
- // the datetimepicker as closed, async as well.
1474
- this._focusedElementBeforeOpen.focus();
1475
- setTimeout(completeClose);
1476
- }
1477
- else {
1478
- completeClose();
1479
- }
1480
- }
1481
- /**
1482
- * TODO: add datetimepicker color
1483
- * Forwards relevant values from the datetimepicker to the
1484
- * datetimepicker content inside the overlay.
1485
- */
1486
- _forwardContentValues(instance) {
1487
- instance.datetimepicker = this;
1488
- }
1489
- /** Opens the overlay with the calendar. */
1490
- _openOverlay() {
1491
- this._destroyOverlay();
1492
- const isDialog = this.touchUi;
1493
- const labelId = this._datetimepickerInput.getOverlayLabelId();
1494
- const portal = new ComponentPortal(MtxDatetimepickerContent, this._viewContainerRef);
1495
- const overlayRef = (this._overlayRef = this._overlay.create(new OverlayConfig({
1496
- positionStrategy: isDialog ? this._getDialogStrategy() : this._getDropdownStrategy(),
1497
- hasBackdrop: true,
1498
- backdropClass: [
1499
- isDialog ? 'cdk-overlay-dark-backdrop' : 'mat-overlay-transparent-backdrop',
1500
- this._backdropHarnessClass,
1501
- ],
1502
- direction: this._dir,
1503
- scrollStrategy: isDialog ? this._overlay.scrollStrategies.block() : this._scrollStrategy(),
1504
- panelClass: `mtx-datetimepicker-${isDialog ? 'dialog' : 'popup'}`,
1505
- })));
1506
- const overlayElement = overlayRef.overlayElement;
1507
- overlayElement.setAttribute('role', 'dialog');
1508
- if (labelId) {
1509
- overlayElement.setAttribute('aria-labelledby', labelId);
1510
- }
1511
- if (isDialog) {
1512
- overlayElement.setAttribute('aria-modal', 'true');
1513
- }
1514
- this._getCloseStream(overlayRef).subscribe(event => {
1515
- if (event) {
1516
- event.preventDefault();
1517
- }
1518
- this.close();
1519
- });
1520
- this._componentRef = overlayRef.attach(portal);
1521
- this._forwardContentValues(this._componentRef.instance);
1522
- // Update the position once the calendar has rendered. Only relevant in dropdown mode.
1523
- if (!isDialog) {
1524
- this._ngZone.onStable.pipe(take(1)).subscribe(() => overlayRef.updatePosition());
1525
- }
1526
- }
1527
- /** Destroys the current overlay. */
1528
- _destroyOverlay() {
1529
- if (this._overlayRef) {
1530
- this._overlayRef.dispose();
1531
- this._overlayRef = this._componentRef = null;
1532
- }
1533
- }
1534
- /** Gets a position strategy that will open the calendar as a dropdown. */
1535
- _getDialogStrategy() {
1536
- return this._overlay.position().global().centerHorizontally().centerVertically();
1537
- }
1538
- /** Gets a position strategy that will open the calendar as a dropdown. */
1539
- _getDropdownStrategy() {
1540
- const strategy = this._overlay
1541
- .position()
1542
- .flexibleConnectedTo(this._datetimepickerInput.getConnectedOverlayOrigin())
1543
- .withTransformOriginOn('.mtx-datetimepicker-content')
1544
- .withFlexibleDimensions(false)
1545
- .withViewportMargin(8)
1546
- .withLockedPosition();
1547
- return this._setConnectedPositions(strategy);
1548
- }
1549
- /**
1550
- * TODO: `xPosition` and `yPosition`
1551
- * Sets the positions of the datetimepicker in dropdown mode based on the current configuration.
1552
- */
1553
- _setConnectedPositions(strategy) {
1554
- return strategy.withPositions([
1555
- {
1556
- originX: 'start',
1557
- originY: 'bottom',
1558
- overlayX: 'start',
1559
- overlayY: 'top',
1560
- },
1561
- {
1562
- originX: 'start',
1563
- originY: 'top',
1564
- overlayX: 'start',
1565
- overlayY: 'bottom',
1566
- },
1567
- {
1568
- originX: 'end',
1569
- originY: 'bottom',
1570
- overlayX: 'end',
1571
- overlayY: 'top',
1572
- },
1573
- {
1574
- originX: 'end',
1575
- originY: 'top',
1576
- overlayX: 'end',
1577
- overlayY: 'bottom',
1578
- },
1579
- ]);
1580
- }
1581
- /** Gets an observable that will emit when the overlay is supposed to be closed. */
1582
- _getCloseStream(overlayRef) {
1583
- return merge(overlayRef.backdropClick(), overlayRef.detachments(), overlayRef.keydownEvents().pipe(filter(event => {
1584
- // Closing on alt + up is only valid when there's an input associated with the datetimepicker.
1585
- return ((event.keyCode === ESCAPE && !hasModifierKey(event)) ||
1586
- (this._datetimepickerInput &&
1587
- hasModifierKey(event, 'altKey') &&
1588
- event.keyCode === UP_ARROW));
1589
- })));
1590
- }
1591
- }
1592
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
1593
- MtxDatetimepicker.decorators = [
1594
- { type: Component, args: [{
1595
- selector: 'mtx-datetimepicker',
1596
- exportAs: 'mtxDatetimepicker',
1597
- template: '',
1598
- changeDetection: ChangeDetectionStrategy.OnPush,
1599
- encapsulation: ViewEncapsulation.None,
1600
- preserveWhitespaces: false
1601
- },] }
1602
- ];
1603
- /**
1604
- * @type {function(): !Array<(null|{
1605
- * type: ?,
1606
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
1607
- * })>}
1608
- * @nocollapse
1609
- */
1610
- MtxDatetimepicker.ctorParameters = () => [
1611
- { type: Overlay },
1612
- { type: NgZone },
1613
- { type: ViewContainerRef },
1614
- { type: undefined, decorators: [{ type: Inject, args: [MAT_DATEPICKER_SCROLL_STRATEGY,] }] },
1615
- { type: DatetimeAdapter, decorators: [{ type: Optional }] },
1616
- { type: Directionality, decorators: [{ type: Optional }] }
1617
- ];
1618
- /** @type {!Object<string, !Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
1619
- MtxDatetimepicker.propDecorators = {
1620
- multiYearSelector: [{ type: Input }],
1621
- twelvehour: [{ type: Input }],
1622
- startView: [{ type: Input }],
1623
- mode: [{ type: Input }],
1624
- timeInterval: [{ type: Input }],
1625
- ariaNextMonthLabel: [{ type: Input }],
1626
- ariaPrevMonthLabel: [{ type: Input }],
1627
- ariaNextYearLabel: [{ type: Input }],
1628
- ariaPrevYearLabel: [{ type: Input }],
1629
- preventSameDateTimeSelection: [{ type: Input }],
1630
- selectedChanged: [{ type: Output }],
1631
- panelClass: [{ type: Input }],
1632
- openedStream: [{ type: Output, args: ['opened',] }],
1633
- closedStream: [{ type: Output, args: ['closed',] }],
1634
- viewChanged: [{ type: Output }],
1635
- startAt: [{ type: Input }],
1636
- openOnFocus: [{ type: Input }],
1637
- type: [{ type: Input }],
1638
- touchUi: [{ type: Input }],
1639
- disabled: [{ type: Input }]
1640
- };
1641
-
1642
- const MAT_DATETIMEPICKER_VALUE_ACCESSOR = {
1643
- provide: NG_VALUE_ACCESSOR,
1644
- useExisting: forwardRef(() => MtxDatetimepickerInput),
1645
- multi: true,
1646
- };
1647
- const MAT_DATETIMEPICKER_VALIDATORS = {
1648
- provide: NG_VALIDATORS,
1649
- useExisting: forwardRef(() => MtxDatetimepickerInput),
1650
- multi: true,
1651
- };
1652
- /**
1653
- * An event used for datetimepicker input and change events. We don't always have access to a native
1654
- * input or change event because the event may have been triggered by the user clicking on the
1655
- * calendar popup. For consistency, we always use MtxDatetimepickerInputEvent instead.
1656
- */
1657
- class MtxDatetimepickerInputEvent {
1658
- constructor(target, targetElement) {
1659
- this.target = target;
1660
- this.targetElement = targetElement;
1661
- this.value = this.target.value;
1662
- }
1663
- }
1664
- /** Directive used to connect an input to a MtxDatetimepicker. */
1665
- class MtxDatetimepickerInput {
1666
- constructor(_elementRef, _dateAdapter, _dateFormats, _formField) {
1667
- this._elementRef = _elementRef;
1668
- this._dateAdapter = _dateAdapter;
1669
- this._dateFormats = _dateFormats;
1670
- this._formField = _formField;
1671
- /** Emits when a `change` event is fired on this `<input>`. */
1672
- this.dateChange = new EventEmitter();
1673
- /** Emits when an `input` event is fired on this `<input>`. */
1674
- this.dateInput = new EventEmitter();
1675
- /** Emits when the value changes (either due to user input or programmatic change). */
1676
- this._valueChange = new EventEmitter();
1677
- /** Emits when the disabled state has changed */
1678
- this._disabledChange = new EventEmitter();
1679
- this._datetimepickerSubscription = Subscription.EMPTY;
1680
- this._localeSubscription = Subscription.EMPTY;
1681
- /** Whether the last value set on the input was valid. */
1682
- this._lastValueValid = false;
1683
- this._onTouched = () => { };
1684
- this._cvaOnChange = () => { };
1685
- this._validatorOnChange = () => { };
1686
- /** The form control validator for whether the input parses. */
1687
- this._parseValidator = () => {
1688
- return this._lastValueValid
1689
- ? null
1690
- : { mtxDatetimepickerParse: { text: this._elementRef.nativeElement.value } };
1691
- };
1692
- /** The form control validator for the min date. */
1693
- this._minValidator = (control) => {
1694
- const controlValue = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(control.value));
1695
- return !this.min ||
1696
- !controlValue ||
1697
- this._dateAdapter.compareDatetime(this.min, controlValue) <= 0
1698
- ? null
1699
- : { mtxDatetimepickerMin: { min: this.min, actual: controlValue } };
1700
- };
1701
- /** The form control validator for the max date. */
1702
- this._maxValidator = (control) => {
1703
- const controlValue = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(control.value));
1704
- return !this.max ||
1705
- !controlValue ||
1706
- this._dateAdapter.compareDatetime(this.max, controlValue) >= 0
1707
- ? null
1708
- : { mtxDatetimepickerMax: { max: this.max, actual: controlValue } };
1709
- };
1710
- /** The form control validator for the date filter. */
1711
- this._filterValidator = (control) => {
1712
- const controlValue = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(control.value));
1713
- return !this._dateFilter ||
1714
- !controlValue ||
1715
- this._dateFilter(controlValue, MtxDatetimepickerFilterType.DATE)
1716
- ? null
1717
- : { mtxDatetimepickerFilter: true };
1718
- };
1719
- /** The combined form control validator for this input. */
1720
- this._validator = Validators.compose([
1721
- this._parseValidator,
1722
- this._minValidator,
1723
- this._maxValidator,
1724
- this._filterValidator,
1725
- ]);
1726
- if (!this._dateAdapter) {
1727
- throw createMissingDateImplError('DatetimeAdapter');
1728
- }
1729
- if (!this._dateFormats) {
1730
- throw createMissingDateImplError('MTX_DATETIME_FORMATS');
1731
- }
1732
- // Update the displayed date when the locale changes.
1733
- this._localeSubscription = _dateAdapter.localeChanges.subscribe(() => {
1734
- this.value = this.value;
1735
- });
1736
- }
1737
- /** The datetimepicker that this input is associated with. */
1738
- set mtxDatetimepicker(value) {
1739
- this.registerDatetimepicker(value);
1740
- }
1741
- set mtxDatetimepickerFilter(filter) {
1742
- this._dateFilter = filter;
1743
- this._validatorOnChange();
1744
- }
1745
- /** The value of the input. */
1746
- get value() {
1747
- return this._value;
1748
- }
1749
- set value(value) {
1750
- value = this._dateAdapter.deserialize(value);
1751
- this._lastValueValid = !value || this._dateAdapter.isValid(value);
1752
- value = this._dateAdapter.getValidDateOrNull(value);
1753
- const oldDate = this.value;
1754
- this._value = value;
1755
- this._formatValue(value);
1756
- // use timeout to ensure the datetimepicker is instantiated and we get the correct format
1757
- setTimeout(() => {
1758
- if (!this._dateAdapter.sameDatetime(oldDate, value)) {
1759
- this._valueChange.emit(value);
1760
- }
1761
- });
1762
- }
1763
- /** The minimum valid date. */
1764
- get min() {
1765
- return this._min;
1766
- }
1767
- set min(value) {
1768
- this._min = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value));
1769
- this._validatorOnChange();
1770
- }
1771
- /** The maximum valid date. */
1772
- get max() {
1773
- return this._max;
1774
- }
1775
- set max(value) {
1776
- this._max = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value));
1777
- this._validatorOnChange();
1778
- }
1779
- /** Whether the datetimepicker-input is disabled. */
1780
- get disabled() {
1781
- return !!this._disabled;
1782
- }
1783
- set disabled(value) {
1784
- const newValue = coerceBooleanProperty(value);
1785
- if (this._disabled !== newValue) {
1786
- this._disabled = newValue;
1787
- this._disabledChange.emit(newValue);
1788
- }
1789
- }
1790
- ngAfterContentInit() {
1791
- if (this._datetimepicker) {
1792
- this._datetimepickerSubscription = this._datetimepicker.selectedChanged.subscribe((selected) => {
1793
- this.value = selected;
1794
- this._cvaOnChange(selected);
1795
- this._onTouched();
1796
- this.dateInput.emit(new MtxDatetimepickerInputEvent(this, this._elementRef.nativeElement));
1797
- this.dateChange.emit(new MtxDatetimepickerInputEvent(this, this._elementRef.nativeElement));
1798
- });
1799
- }
1800
- }
1801
- ngOnDestroy() {
1802
- this._datetimepickerSubscription.unsubscribe();
1803
- this._localeSubscription.unsubscribe();
1804
- this._valueChange.complete();
1805
- this._disabledChange.complete();
1806
- }
1807
- registerOnValidatorChange(fn) {
1808
- this._validatorOnChange = fn;
1809
- }
1810
- validate(c) {
1811
- return this._validator ? this._validator(c) : null;
1812
- }
1813
- /**
1814
- * Gets the element that the datetimepicker popup should be connected to.
1815
- * @return The element to connect the popup to.
1816
- */
1817
- getConnectedOverlayOrigin() {
1818
- return this._formField ? this._formField.getConnectedOverlayOrigin() : this._elementRef;
1819
- }
1820
- /** Gets the ID of an element that should be used a description for the calendar overlay. */
1821
- getOverlayLabelId() {
1822
- if (this._formField) {
1823
- return this._formField.getLabelId();
1824
- }
1825
- return this._elementRef.nativeElement.getAttribute('aria-labelledby');
1826
- }
1827
- // Implemented as part of ControlValueAccessor
1828
- writeValue(value) {
1829
- this.value = value;
1830
- }
1831
- // Implemented as part of ControlValueAccessor
1832
- registerOnChange(fn) {
1833
- this._cvaOnChange = fn;
1834
- }
1835
- // Implemented as part of ControlValueAccessor
1836
- registerOnTouched(fn) {
1837
- this._onTouched = fn;
1838
- }
1839
- // Implemented as part of ControlValueAccessor
1840
- setDisabledState(disabled) {
1841
- this.disabled = disabled;
1842
- }
1843
- _onKeydown(event) {
1844
- if (event.altKey && event.keyCode === DOWN_ARROW) {
1845
- this._datetimepicker.open();
1846
- event.preventDefault();
1847
- }
1848
- }
1849
- _onInput(value) {
1850
- let date = this._dateAdapter.parse(value, this.getParseFormat());
1851
- this._lastValueValid = !date || this._dateAdapter.isValid(date);
1852
- date = this._dateAdapter.getValidDateOrNull(date);
1853
- this._value = date;
1854
- this._cvaOnChange(date);
1855
- this._valueChange.emit(date);
1856
- this.dateInput.emit(new MtxDatetimepickerInputEvent(this, this._elementRef.nativeElement));
1857
- }
1858
- _onChange() {
1859
- this.dateChange.emit(new MtxDatetimepickerInputEvent(this, this._elementRef.nativeElement));
1860
- }
1861
- /** Handles blur events on the input. */
1862
- _onBlur() {
1863
- // Reformat the input only if we have a valid value.
1864
- if (this.value) {
1865
- this._formatValue(this.value);
1866
- }
1867
- this._onTouched();
1868
- }
1869
- registerDatetimepicker(value) {
1870
- if (value) {
1871
- this._datetimepicker = value;
1872
- this._datetimepicker._registerInput(this);
1873
- }
1874
- }
1875
- getDisplayFormat() {
1876
- switch (this._datetimepicker.type) {
1877
- case 'date':
1878
- return this._dateFormats.display.dateInput;
1879
- case 'datetime':
1880
- return this._dateFormats.display.datetimeInput;
1881
- case 'time':
1882
- return this._dateFormats.display.timeInput;
1883
- case 'month':
1884
- return this._dateFormats.display.monthInput;
1885
- }
1886
- }
1887
- getParseFormat() {
1888
- let parseFormat;
1889
- switch (this._datetimepicker.type) {
1890
- case 'date':
1891
- parseFormat = this._dateFormats.parse.dateInput;
1892
- break;
1893
- case 'datetime':
1894
- parseFormat = this._dateFormats.parse.datetimeInput;
1895
- break;
1896
- case 'time':
1897
- parseFormat = this._dateFormats.parse.timeInput;
1898
- break;
1899
- case 'month':
1900
- parseFormat = this._dateFormats.parse.monthInput;
1901
- break;
1902
- }
1903
- if (!parseFormat) {
1904
- parseFormat = this._dateFormats.parse.dateInput;
1905
- }
1906
- return parseFormat;
1907
- }
1908
- /** Formats a value and sets it on the input element. */
1909
- _formatValue(value) {
1910
- this._elementRef.nativeElement.value = value
1911
- ? this._dateAdapter.format(value, this.getDisplayFormat())
1912
- : '';
1913
- }
1914
- }
1915
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
1916
- MtxDatetimepickerInput.decorators = [
1917
- { type: Directive, args: [{
1918
- selector: 'input[mtxDatetimepicker]',
1919
- providers: [
1920
- MAT_DATETIMEPICKER_VALUE_ACCESSOR,
1921
- MAT_DATETIMEPICKER_VALIDATORS,
1922
- { provide: MAT_INPUT_VALUE_ACCESSOR, useExisting: MtxDatetimepickerInput },
1923
- ],
1924
- host: {
1925
- '[attr.aria-haspopup]': 'true',
1926
- '[attr.aria-owns]': '(_datetimepicker?.opened && _datetimepicker.id) || null',
1927
- '[attr.min]': 'min ? _dateAdapter.toIso8601(min) : null',
1928
- '[attr.max]': 'max ? _dateAdapter.toIso8601(max) : null',
1929
- '[disabled]': 'disabled',
1930
- '(input)': '_onInput($event.target.value)',
1931
- '(change)': '_onChange()',
1932
- '(blur)': '_onBlur()',
1933
- '(keydown)': '_onKeydown($event)',
1934
- },
1935
- exportAs: 'mtxDatetimepickerInput',
1936
- },] }
1937
- ];
1938
- /**
1939
- * @type {function(): !Array<(null|{
1940
- * type: ?,
1941
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
1942
- * })>}
1943
- * @nocollapse
1944
- */
1945
- MtxDatetimepickerInput.ctorParameters = () => [
1946
- { type: ElementRef },
1947
- { type: DatetimeAdapter, decorators: [{ type: Optional }] },
1948
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MTX_DATETIME_FORMATS,] }] },
1949
- { type: MatFormField, decorators: [{ type: Optional }] }
1950
- ];
1951
- /** @type {!Object<string, !Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
1952
- MtxDatetimepickerInput.propDecorators = {
1953
- dateChange: [{ type: Output }],
1954
- dateInput: [{ type: Output }],
1955
- mtxDatetimepicker: [{ type: Input }],
1956
- mtxDatetimepickerFilter: [{ type: Input }],
1957
- value: [{ type: Input }],
1958
- min: [{ type: Input }],
1959
- max: [{ type: Input }],
1960
- disabled: [{ type: Input }]
1961
- };
1962
-
1963
- class MtxDatetimepickerToggle {
1964
- constructor(_intl, _changeDetectorRef) {
1965
- this._intl = _intl;
1966
- this._changeDetectorRef = _changeDetectorRef;
1967
- this._stateChanges = Subscription.EMPTY;
1968
- }
1969
- /** Whether the toggle button is disabled. */
1970
- get disabled() {
1971
- return this._disabled === undefined ? this.datetimepicker.disabled : !!this._disabled;
1972
- }
1973
- set disabled(value) {
1974
- this._disabled = coerceBooleanProperty(value);
1975
- }
1976
- ngOnChanges(changes) {
1977
- if (changes.datetimepicker) {
1978
- this._watchStateChanges();
1979
- }
1980
- }
1981
- ngOnDestroy() {
1982
- this._stateChanges.unsubscribe();
1983
- }
1984
- ngAfterContentInit() {
1985
- this._watchStateChanges();
1986
- }
1987
- _open(event) {
1988
- if (this.datetimepicker && !this.disabled) {
1989
- this.datetimepicker.open();
1990
- event.stopPropagation();
1991
- }
1992
- }
1993
- _watchStateChanges() {
1994
- const datetimepickerDisabled = this.datetimepicker
1995
- ? this.datetimepicker._disabledChange
1996
- : of();
1997
- const inputDisabled = this.datetimepicker && this.datetimepicker._datetimepickerInput
1998
- ? this.datetimepicker._datetimepickerInput._disabledChange
1999
- : of();
2000
- this._stateChanges.unsubscribe();
2001
- this._stateChanges = merge([
2002
- this._intl.changes,
2003
- datetimepickerDisabled,
2004
- inputDisabled,
2005
- ]).subscribe(() => this._changeDetectorRef.markForCheck());
2006
- }
2007
- }
2008
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
2009
- MtxDatetimepickerToggle.decorators = [
2010
- { type: Component, args: [{
2011
- selector: 'mtx-datetimepicker-toggle',
2012
- template: "<button (click)=\"_open($event)\" [attr.aria-label]=\"_intl.openCalendarLabel\" [disabled]=\"disabled\"\n mat-icon-button type=\"button\">\n <mat-icon [ngSwitch]=\"datetimepicker.type\">\n <svg *ngSwitchCase=\"'time'\" fill=\"currentColor\" focusable=\"false\" height=\"100%\"\n style=\"vertical-align: top;\"\n viewBox=\"0 0 24 24\" width=\"100%\">\n <path d=\"M12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22C6.47,22 2,17.5 2,12A10,10 0 0,1 12,2M12.5,7V12.25L17,14.92L16.25,16.15L11,13V7H12.5Z\">\n </path>\n </svg>\n <svg *ngSwitchCase=\"'datetime'\" fill=\"currentColor\" focusable=\"false\" height=\"100%\"\n style=\"vertical-align: top;\"\n viewBox=\"0 0 24 24\" width=\"100%\">\n <path d=\"M15,13H16.5V15.82L18.94,17.23L18.19,18.53L15,16.69V13M19,8H5V19H9.67C9.24,18.09 9,17.07 9,16A7,7 0 0,1 16,9C17.07,9 18.09,9.24 19,9.67V8M5,21C3.89,21 3,20.1 3,19V5C3,3.89 3.89,3 5,3H6V1H8V3H16V1H18V3H19A2,2 0 0,1 21,5V11.1C22.24,12.36 23,14.09 23,16A7,7 0 0,1 16,23C14.09,23 12.36,22.24 11.1,21H5M16,11.15A4.85,4.85 0 0,0 11.15,16C11.15,18.68 13.32,20.85 16,20.85A4.85,4.85 0 0,0 20.85,16C20.85,13.32 18.68,11.15 16,11.15Z\">\n </path>\n </svg>\n <svg *ngSwitchDefault fill=\"currentColor\" focusable=\"false\" height=\"100%\"\n style=\"vertical-align: top;\"\n viewBox=\"0 0 24 24\" width=\"100%\">\n <path d=\"M0 0h24v24H0z\" fill=\"none\" />\n <path d=\"M19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM7 10h5v5H7z\" />\n </svg>\n </mat-icon>\n</button>\n",
2013
- host: {
2014
- class: 'mtx-datetimepicker-toggle',
2015
- },
2016
- exportAs: 'mtxDatetimepickerToggle',
2017
- encapsulation: ViewEncapsulation.None,
2018
- preserveWhitespaces: false,
2019
- changeDetection: ChangeDetectionStrategy.OnPush
2020
- },] }
2021
- ];
2022
- /**
2023
- * @type {function(): !Array<(null|{
2024
- * type: ?,
2025
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
2026
- * })>}
2027
- * @nocollapse
2028
- */
2029
- MtxDatetimepickerToggle.ctorParameters = () => [
2030
- { type: MatDatepickerIntl },
2031
- { type: ChangeDetectorRef }
2032
- ];
2033
- /** @type {!Object<string, !Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
2034
- MtxDatetimepickerToggle.propDecorators = {
2035
- datetimepicker: [{ type: Input, args: ['for',] }],
2036
- disabled: [{ type: Input }]
2037
- };
2038
-
2039
- const DAYS_PER_WEEK = 7;
2040
- /**
2041
- * An internal component used to display a single month in the datetimepicker.
2042
- * @docs-private
2043
- */
2044
- class MtxMonthView {
2045
- constructor(_adapter, _dateFormats) {
2046
- this._adapter = _adapter;
2047
- this._dateFormats = _dateFormats;
2048
- this.type = 'date';
2049
- this._userSelection = new EventEmitter();
2050
- /** Emits when a new date is selected. */
2051
- this.selectedChange = new EventEmitter();
2052
- if (!this._adapter) {
2053
- throw createMissingDateImplError('DatetimeAdapter');
2054
- }
2055
- if (!this._dateFormats) {
2056
- throw createMissingDateImplError('MTX_DATETIME_FORMATS');
2057
- }
2058
- const firstDayOfWeek = this._adapter.getFirstDayOfWeek();
2059
- const narrowWeekdays = this._adapter.getDayOfWeekNames('narrow');
2060
- const longWeekdays = this._adapter.getDayOfWeekNames('long');
2061
- // Rotate the labels for days of the week based on the configured first day of the week.
2062
- const weekdays = longWeekdays.map((long, i) => {
2063
- return { long, narrow: narrowWeekdays[i] };
2064
- });
2065
- this._weekdays = weekdays.slice(firstDayOfWeek).concat(weekdays.slice(0, firstDayOfWeek));
2066
- this._activeDate = this._adapter.today();
2067
- }
2068
- /**
2069
- * The date to display in this month view (everything other than the month and year is ignored).
2070
- */
2071
- get activeDate() {
2072
- return this._activeDate;
2073
- }
2074
- set activeDate(value) {
2075
- const oldActiveDate = this._activeDate;
2076
- this._activeDate = value || this._adapter.today();
2077
- if (oldActiveDate &&
2078
- this._activeDate &&
2079
- !this._adapter.sameMonthAndYear(oldActiveDate, this._activeDate)) {
2080
- this._init();
2081
- if (this._adapter.isInNextMonth(oldActiveDate, this._activeDate)) {
2082
- this.calendarState('right');
2083
- }
2084
- else {
2085
- this.calendarState('left');
2086
- }
2087
- }
2088
- }
2089
- /** The currently selected date. */
2090
- get selected() {
2091
- return this._selected;
2092
- }
2093
- set selected(value) {
2094
- this._selected = value;
2095
- this._selectedDate = this._getDateInCurrentMonth(this.selected);
2096
- }
2097
- ngAfterContentInit() {
2098
- this._init();
2099
- }
2100
- /** Handles when a new date is selected. */
2101
- _dateSelected(date) {
2102
- this.selectedChange.emit(this._adapter.createDatetime(this._adapter.getYear(this.activeDate), this._adapter.getMonth(this.activeDate), date, this._adapter.getHour(this.activeDate), this._adapter.getMinute(this.activeDate)));
2103
- if (this.type === 'date') {
2104
- this._userSelection.emit();
2105
- }
2106
- }
2107
- _calendarStateDone() {
2108
- this._calendarState = '';
2109
- }
2110
- /** Initializes this month view. */
2111
- _init() {
2112
- this._selectedDate = this._getDateInCurrentMonth(this.selected);
2113
- this._todayDate = this._getDateInCurrentMonth(this._adapter.today());
2114
- const firstOfMonth = this._adapter.createDatetime(this._adapter.getYear(this.activeDate), this._adapter.getMonth(this.activeDate), 1, this._adapter.getHour(this.activeDate), this._adapter.getMinute(this.activeDate));
2115
- this._firstWeekOffset =
2116
- (DAYS_PER_WEEK +
2117
- this._adapter.getDayOfWeek(firstOfMonth) -
2118
- this._adapter.getFirstDayOfWeek()) %
2119
- DAYS_PER_WEEK;
2120
- this._createWeekCells();
2121
- }
2122
- /** Creates MdCalendarCells for the dates in this month. */
2123
- _createWeekCells() {
2124
- const daysInMonth = this._adapter.getNumDaysInMonth(this.activeDate);
2125
- const dateNames = this._adapter.getDateNames();
2126
- this._weeks = [[]];
2127
- for (let i = 0, cell = this._firstWeekOffset; i < daysInMonth; i++, cell++) {
2128
- if (cell === DAYS_PER_WEEK) {
2129
- this._weeks.push([]);
2130
- cell = 0;
2131
- }
2132
- const date = this._adapter.createDatetime(this._adapter.getYear(this.activeDate), this._adapter.getMonth(this.activeDate), i + 1, this._adapter.getHour(this.activeDate), this._adapter.getMinute(this.activeDate));
2133
- const enabled = !this.dateFilter || this.dateFilter(date);
2134
- const ariaLabel = this._adapter.format(date, this._dateFormats.display.dateA11yLabel);
2135
- this._weeks[this._weeks.length - 1].push(new MtxCalendarCell(i + 1, dateNames[i], ariaLabel, enabled));
2136
- }
2137
- }
2138
- /**
2139
- * Gets the date in this month that the given Date falls on.
2140
- * Returns null if the given Date is in another month.
2141
- */
2142
- _getDateInCurrentMonth(date) {
2143
- return this._adapter.sameMonthAndYear(date, this.activeDate)
2144
- ? this._adapter.getDate(date)
2145
- : null;
2146
- }
2147
- calendarState(direction) {
2148
- this._calendarState = direction;
2149
- }
2150
- }
2151
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
2152
- MtxMonthView.decorators = [
2153
- { type: Component, args: [{
2154
- selector: 'mtx-month-view',
2155
- template: "<table class=\"mtx-calendar-table\" role=\"grid\">\n <thead class=\"mtx-calendar-table-header\">\n <tr>\n <th *ngFor=\"let day of _weekdays\" [attr.aria-label]=\"day.long\">{{day.narrow}}</th>\n </tr>\n </thead>\n <tbody mtx-calendar-body\n (@slideCalendar.done)=\"_calendarStateDone()\"\n [@slideCalendar]=\"_calendarState\"\n [rows]=\"_weeks\"\n [todayValue]=\"_todayDate!\"\n [activeCell]=\"_adapter.getDate(activeDate) - 1\"\n [selectedValue]=\"_selectedDate!\"\n (selectedValueChange)=\"_dateSelected($event)\"></tbody>\n</table>\n",
2156
- animations: [slideCalendar],
2157
- encapsulation: ViewEncapsulation.None,
2158
- changeDetection: ChangeDetectionStrategy.OnPush
2159
- },] }
2160
- ];
2161
- /**
2162
- * @type {function(): !Array<(null|{
2163
- * type: ?,
2164
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
2165
- * })>}
2166
- * @nocollapse
2167
- */
2168
- MtxMonthView.ctorParameters = () => [
2169
- { type: DatetimeAdapter, decorators: [{ type: Optional }] },
2170
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MTX_DATETIME_FORMATS,] }] }
2171
- ];
2172
- /** @type {!Object<string, !Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
2173
- MtxMonthView.propDecorators = {
2174
- type: [{ type: Input }],
2175
- _userSelection: [{ type: Output }],
2176
- dateFilter: [{ type: Input }],
2177
- selectedChange: [{ type: Output }],
2178
- activeDate: [{ type: Input }],
2179
- selected: [{ type: Input }]
2180
- };
2181
-
2182
- /**
2183
- * An internal component used to display a single year in the datetimepicker.
2184
- * @docs-private
2185
- */
2186
- class MtxYearView {
2187
- constructor(_adapter, _dateFormats) {
2188
- this._adapter = _adapter;
2189
- this._dateFormats = _dateFormats;
2190
- this._userSelection = new EventEmitter();
2191
- this.type = 'date';
2192
- /** Emits when a new month is selected. */
2193
- this.selectedChange = new EventEmitter();
2194
- if (!this._adapter) {
2195
- throw createMissingDateImplError('DatetimeAdapter');
2196
- }
2197
- if (!this._dateFormats) {
2198
- throw createMissingDateImplError('MTX_DATETIME_FORMATS');
2199
- }
2200
- this._activeDate = this._adapter.today();
2201
- }
2202
- /** The date to display in this year view (everything other than the year is ignored). */
2203
- get activeDate() {
2204
- return this._activeDate;
2205
- }
2206
- set activeDate(value) {
2207
- const oldActiveDate = this._activeDate;
2208
- this._activeDate = value || this._adapter.today();
2209
- if (oldActiveDate &&
2210
- this._activeDate &&
2211
- !this._adapter.sameYear(oldActiveDate, this._activeDate)) {
2212
- this._init();
2213
- // if (oldActiveDate < this._activeDate) {
2214
- // this.calendarState('right');
2215
- // } else {
2216
- // this.calendarState('left');
2217
- // }
2218
- }
2219
- }
2220
- /** The currently selected date. */
2221
- get selected() {
2222
- return this._selected;
2223
- }
2224
- set selected(value) {
2225
- this._selected = value;
2226
- this._selectedMonth = this._getMonthInCurrentYear(this.selected);
2227
- }
2228
- ngAfterContentInit() {
2229
- this._init();
2230
- }
2231
- /** Handles when a new month is selected. */
2232
- _monthSelected(month) {
2233
- const normalizedDate = this._adapter.createDatetime(this._adapter.getYear(this.activeDate), month, 1, 0, 0);
2234
- this.selectedChange.emit(this._adapter.createDatetime(this._adapter.getYear(this.activeDate), month, Math.min(this._adapter.getDate(this.activeDate), this._adapter.getNumDaysInMonth(normalizedDate)), this._adapter.getHour(this.activeDate), this._adapter.getMinute(this.activeDate)));
2235
- if (this.type === 'month') {
2236
- this._userSelection.emit();
2237
- }
2238
- }
2239
- _calendarStateDone() {
2240
- this._calendarState = '';
2241
- }
2242
- /** Initializes this month view. */
2243
- _init() {
2244
- this._selectedMonth = this._getMonthInCurrentYear(this.selected);
2245
- this._todayMonth = this._getMonthInCurrentYear(this._adapter.today());
2246
- this._yearLabel = this._adapter.getYearName(this.activeDate);
2247
- const monthNames = this._adapter.getMonthNames('short');
2248
- // First row of months only contains 5 elements so we can fit the year label on the same row.
2249
- this._months = [
2250
- [0, 1, 2, 3],
2251
- [4, 5, 6, 7],
2252
- [8, 9, 10, 11],
2253
- ].map(row => row.map(month => this._createCellForMonth(month, monthNames[month])));
2254
- }
2255
- /**
2256
- * Gets the month in this year that the given Date falls on.
2257
- * Returns null if the given Date is in another year.
2258
- */
2259
- _getMonthInCurrentYear(date) {
2260
- return this._adapter.sameYear(date, this.activeDate) ? this._adapter.getMonth(date) : null;
2261
- }
2262
- /** Creates an MdCalendarCell for the given month. */
2263
- _createCellForMonth(month, monthName) {
2264
- const ariaLabel = this._adapter.format(this._adapter.createDatetime(this._adapter.getYear(this.activeDate), month, 1, this._adapter.getHour(this.activeDate), this._adapter.getMinute(this.activeDate)), this._dateFormats.display.monthYearA11yLabel);
2265
- return new MtxCalendarCell(month, monthName.toLocaleUpperCase(), ariaLabel, this._isMonthEnabled(month));
2266
- }
2267
- // private calendarState(direction: string): void {
2268
- // this._calendarState = direction;
2269
- // }
2270
- /** Whether the given month is enabled. */
2271
- _isMonthEnabled(month) {
2272
- if (!this.dateFilter) {
2273
- return true;
2274
- }
2275
- const firstOfMonth = this._adapter.createDatetime(this._adapter.getYear(this.activeDate), month, 1, this._adapter.getHour(this.activeDate), this._adapter.getMinute(this.activeDate));
2276
- // If any date in the month is enabled count the month as enabled.
2277
- for (let date = firstOfMonth; this._adapter.getMonth(date) === month; date = this._adapter.addCalendarDays(date, 1)) {
2278
- if (this.dateFilter(date)) {
2279
- return true;
2280
- }
2281
- }
2282
- return false;
2283
- }
2284
- }
2285
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
2286
- MtxYearView.decorators = [
2287
- { type: Component, args: [{
2288
- selector: 'mtx-year-view',
2289
- template: "<table class=\"mtx-calendar-table\" role=\"grid\">\n <thead class=\"mtx-calendar-table-header\"></thead>\n <tbody mtx-calendar-body\n (@slideCalendar.done)=\"_calendarStateDone()\"\n [@slideCalendar]=\"_calendarState\"\n [label]=\"_yearLabel\"\n [rows]=\"_months\"\n [todayValue]=\"_todayMonth!\"\n [labelMinRequiredCells]=\"2\"\n [numCols]=\"4\"\n [activeCell]=\"_adapter.getMonth(activeDate)\"\n [selectedValue]=\"_selectedMonth!\"\n (selectedValueChange)=\"_monthSelected($event)\"\n [allowDisabledSelection]=\"true\"></tbody>\n</table>\n",
2290
- animations: [slideCalendar],
2291
- encapsulation: ViewEncapsulation.None,
2292
- changeDetection: ChangeDetectionStrategy.OnPush
2293
- },] }
2294
- ];
2295
- /**
2296
- * @type {function(): !Array<(null|{
2297
- * type: ?,
2298
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
2299
- * })>}
2300
- * @nocollapse
2301
- */
2302
- MtxYearView.ctorParameters = () => [
2303
- { type: DatetimeAdapter, decorators: [{ type: Optional }] },
2304
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MTX_DATETIME_FORMATS,] }] }
2305
- ];
2306
- /** @type {!Object<string, !Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
2307
- MtxYearView.propDecorators = {
2308
- _userSelection: [{ type: Output }],
2309
- type: [{ type: Input }],
2310
- dateFilter: [{ type: Input }],
2311
- selectedChange: [{ type: Output }],
2312
- activeDate: [{ type: Input }],
2313
- selected: [{ type: Input }]
2314
- };
2315
-
2316
- class MtxDatetimepickerModule {
2317
- }
2318
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
2319
- MtxDatetimepickerModule.decorators = [
2320
- { type: NgModule, args: [{
2321
- imports: [CommonModule, MatButtonModule, MatIconModule, OverlayModule, A11yModule],
2322
- entryComponents: [MtxDatetimepickerContent],
2323
- declarations: [
2324
- MtxCalendar,
2325
- MtxCalendarBody,
2326
- MtxClock,
2327
- MtxDatetimepicker,
2328
- MtxDatetimepickerToggle,
2329
- MtxDatetimepickerInput,
2330
- MtxDatetimepickerContent,
2331
- MtxMonthView,
2332
- MtxYearView,
2333
- MtxMultiYearView,
2334
- ],
2335
- exports: [
2336
- MtxCalendar,
2337
- MtxCalendarBody,
2338
- MtxClock,
2339
- MtxDatetimepicker,
2340
- MtxDatetimepickerToggle,
2341
- MtxDatetimepickerInput,
2342
- MtxDatetimepickerContent,
2343
- MtxMonthView,
2344
- MtxYearView,
2345
- MtxMultiYearView,
2346
- ],
2347
- },] }
2348
- ];
2349
-
2350
- /**
2351
- * Generated bundle index. Do not edit.
2352
- */
2353
-
2354
- export { CLOCK_INNER_RADIUS, CLOCK_OUTER_RADIUS, CLOCK_RADIUS, CLOCK_TICK_RADIUS, MAT_DATETIMEPICKER_VALIDATORS, MAT_DATETIMEPICKER_VALUE_ACCESSOR, MtxCalendar, MtxCalendarBody, MtxCalendarCell, MtxClock, MtxDatetimepicker, MtxDatetimepickerContent, MtxDatetimepickerFilterType, MtxDatetimepickerInput, MtxDatetimepickerInputEvent, MtxDatetimepickerModule, MtxDatetimepickerToggle, MtxMonthView, MtxYearView, slideCalendar as ɵa, MtxMultiYearView as ɵb };
2355
- //# sourceMappingURL=mtxDatetimepicker.js.map