@ifsworld/granite-components 4.4.0 → 5.0.1

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 (291) hide show
  1. package/README.md +117 -4
  2. package/esm2020/ifsworld-granite-components.mjs +5 -0
  3. package/esm2020/index.mjs +48 -0
  4. package/esm2020/lib/arrange-grid/arrange-grid-item.component.mjs +44 -0
  5. package/esm2020/lib/arrange-grid/arrange-grid.component.mjs +125 -0
  6. package/esm2020/lib/arrange-grid/arrange-grid.module.mjs +19 -0
  7. package/esm2020/lib/badge/badge.component.mjs +39 -0
  8. package/esm2020/lib/badge/badge.module.mjs +18 -0
  9. package/esm2020/lib/badge/testing/badge.harness.mjs +25 -0
  10. package/esm2020/lib/button/button.component.mjs +89 -0
  11. package/esm2020/lib/button/button.module.mjs +16 -0
  12. package/esm2020/lib/checkbox/checkbox-group.component.mjs +17 -0
  13. package/esm2020/lib/checkbox/checkbox.component.mjs +96 -0
  14. package/esm2020/lib/checkbox/checkbox.module.mjs +17 -0
  15. package/esm2020/lib/core/animation.mjs +34 -0
  16. package/esm2020/lib/core/client-environment.mjs +20 -0
  17. package/esm2020/lib/core/common-behaviors/disabled.mjs +27 -0
  18. package/esm2020/lib/core/core.module.mjs +36 -0
  19. package/esm2020/lib/core/devices/client-input-desktop.directive.mjs +29 -0
  20. package/esm2020/lib/core/devices/client-input-touch.directive.mjs +29 -0
  21. package/esm2020/lib/core/devices/client-output-desktop.directive.mjs +29 -0
  22. package/esm2020/lib/core/devices/client-output-touch.directive.mjs +29 -0
  23. package/esm2020/lib/core/pipes/pure-pipes.module.mjs +16 -0
  24. package/esm2020/lib/core/pipes/title.pipe.mjs +21 -0
  25. package/esm2020/lib/core/radio-checkbox-base.mjs +19 -0
  26. package/esm2020/lib/core/theme.library.mjs +59 -0
  27. package/esm2020/lib/core/types.mjs +2 -0
  28. package/esm2020/lib/grid/grid.component.mjs +128 -0
  29. package/esm2020/lib/grid/grid.module.mjs +18 -0
  30. package/esm2020/lib/icon/icon.component.mjs +43 -0
  31. package/esm2020/lib/icon/icon.module.mjs +16 -0
  32. package/esm2020/lib/input-field/input-field.component.mjs +160 -0
  33. package/esm2020/lib/input-field/input-field.module.mjs +20 -0
  34. package/esm2020/lib/menu/divider.directive.mjs +23 -0
  35. package/esm2020/lib/menu/menu-base.mjs +347 -0
  36. package/esm2020/lib/menu/menu-desktop-animations.mjs +23 -0
  37. package/esm2020/lib/menu/menu-errors.mjs +37 -0
  38. package/esm2020/lib/menu/menu-item.component.mjs +91 -0
  39. package/esm2020/lib/menu/menu-panel.mjs +7 -0
  40. package/esm2020/lib/menu/menu-positions.mjs +9 -0
  41. package/esm2020/lib/menu/menu-touch-animations.mjs +137 -0
  42. package/esm2020/lib/menu/menu-touch-close.component.mjs +13 -0
  43. package/esm2020/lib/menu/menu-touch-title.component.mjs +59 -0
  44. package/esm2020/lib/menu/menu-trigger-for.directive.mjs +702 -0
  45. package/esm2020/lib/menu/menu.component.mjs +30 -0
  46. package/esm2020/lib/menu/menu.module.mjs +55 -0
  47. package/esm2020/lib/menu/testing/menu.harness.mjs +109 -0
  48. package/esm2020/lib/menu/title.directive.mjs +17 -0
  49. package/esm2020/lib/radio-button/radio-button.component.mjs +118 -0
  50. package/esm2020/lib/radio-button/radio-button.module.mjs +17 -0
  51. package/esm2020/lib/radio-button/radio-group.component.mjs +17 -0
  52. package/esm2020/lib/table/cell/cell.mjs +15 -0
  53. package/esm2020/lib/table/cell/table-data-cell.component.mjs +26 -0
  54. package/esm2020/lib/table/cell/table-header-cell.component.mjs +12 -0
  55. package/esm2020/lib/table/column/table-column.directive.mjs +23 -0
  56. package/esm2020/lib/table/table-constants.library.mjs +4 -0
  57. package/esm2020/lib/table/table.component.mjs +36 -0
  58. package/esm2020/lib/table/table.module.mjs +32 -0
  59. package/esm2020/lib/toggle-switch/toggle-switch.component.mjs +96 -0
  60. package/esm2020/lib/toggle-switch/toggle-switch.module.mjs +16 -0
  61. package/fesm2015/ifsworld-granite-components.mjs +3145 -0
  62. package/fesm2015/ifsworld-granite-components.mjs.map +1 -0
  63. package/fesm2020/ifsworld-granite-components.mjs +3103 -0
  64. package/fesm2020/ifsworld-granite-components.mjs.map +1 -0
  65. package/ifsworld-granite-components.d.ts +1 -8
  66. package/lib/arrange-grid/arrange-grid-item.component.d.ts +3 -0
  67. package/lib/arrange-grid/arrange-grid.component.d.ts +3 -0
  68. package/lib/arrange-grid/arrange-grid.module.d.ts +7 -0
  69. package/lib/badge/badge.component.d.ts +3 -0
  70. package/lib/badge/badge.module.d.ts +6 -0
  71. package/lib/button/button.component.d.ts +5 -0
  72. package/lib/button/button.module.d.ts +5 -0
  73. package/lib/checkbox/checkbox-group.component.d.ts +3 -0
  74. package/lib/checkbox/checkbox.component.d.ts +3 -0
  75. package/lib/checkbox/checkbox.module.d.ts +6 -0
  76. package/lib/core/core.module.d.ts +8 -0
  77. package/lib/core/devices/client-input-desktop.directive.d.ts +3 -0
  78. package/lib/core/devices/client-input-touch.directive.d.ts +3 -0
  79. package/lib/core/devices/client-output-desktop.directive.d.ts +3 -0
  80. package/lib/core/devices/client-output-touch.directive.d.ts +3 -0
  81. package/lib/core/pipes/pure-pipes.module.d.ts +5 -0
  82. package/lib/core/pipes/title.pipe.d.ts +3 -0
  83. package/lib/core/radio-checkbox-base.d.ts +3 -0
  84. package/lib/grid/grid.component.d.ts +5 -0
  85. package/lib/grid/grid.module.d.ts +6 -0
  86. package/lib/icon/icon.component.d.ts +3 -0
  87. package/lib/icon/icon.module.d.ts +5 -0
  88. package/lib/input-field/input-field.component.d.ts +3 -0
  89. package/lib/input-field/input-field.module.d.ts +8 -0
  90. package/lib/menu/divider.directive.d.ts +3 -0
  91. package/lib/menu/menu-base.d.ts +190 -0
  92. package/lib/menu/menu-item.component.d.ts +3 -0
  93. package/lib/menu/menu-touch-close.component.d.ts +3 -0
  94. package/lib/menu/menu-touch-title.component.d.ts +4 -1
  95. package/lib/menu/menu-trigger-for.directive.d.ts +4 -1
  96. package/lib/menu/menu.component.d.ts +4 -187
  97. package/lib/menu/menu.module.d.ts +15 -0
  98. package/lib/menu/title.directive.d.ts +3 -0
  99. package/lib/radio-button/radio-button.component.d.ts +4 -1
  100. package/lib/radio-button/radio-button.module.d.ts +6 -0
  101. package/lib/radio-button/radio-group.component.d.ts +3 -0
  102. package/lib/table/cell/cell.d.ts +3 -0
  103. package/lib/table/cell/table-data-cell.component.d.ts +3 -0
  104. package/lib/table/cell/table-header-cell.component.d.ts +3 -0
  105. package/lib/table/column/table-column.directive.d.ts +3 -0
  106. package/lib/table/table.component.d.ts +3 -0
  107. package/lib/table/table.module.d.ts +12 -0
  108. package/lib/toggle-switch/toggle-switch.component.d.ts +3 -0
  109. package/lib/toggle-switch/toggle-switch.module.d.ts +5 -0
  110. package/package.json +26 -13
  111. package/bundles/ifsworld-granite-components.umd.js +0 -3649
  112. package/bundles/ifsworld-granite-components.umd.js.map +0 -1
  113. package/bundles/ifsworld-granite-components.umd.min.js +0 -10
  114. package/bundles/ifsworld-granite-components.umd.min.js.map +0 -1
  115. package/esm2015/ifsworld-granite-components.js +0 -13
  116. package/esm2015/ifsworld-granite-components.js.map +0 -1
  117. package/esm2015/ifsworld-granite-components.metadata.json +0 -1
  118. package/esm2015/index.js +0 -48
  119. package/esm2015/index.js.map +0 -1
  120. package/esm2015/index.metadata.json +0 -1
  121. package/esm2015/lib/arrange-grid/arrange-grid-item.component.js +0 -48
  122. package/esm2015/lib/arrange-grid/arrange-grid-item.component.js.map +0 -1
  123. package/esm2015/lib/arrange-grid/arrange-grid-item.component.metadata.json +0 -1
  124. package/esm2015/lib/arrange-grid/arrange-grid.component.js +0 -123
  125. package/esm2015/lib/arrange-grid/arrange-grid.component.js.map +0 -1
  126. package/esm2015/lib/arrange-grid/arrange-grid.component.metadata.json +0 -1
  127. package/esm2015/lib/arrange-grid/arrange-grid.module.js +0 -14
  128. package/esm2015/lib/arrange-grid/arrange-grid.module.js.map +0 -1
  129. package/esm2015/lib/arrange-grid/arrange-grid.module.metadata.json +0 -1
  130. package/esm2015/lib/badge/badge.component.js +0 -44
  131. package/esm2015/lib/badge/badge.component.js.map +0 -1
  132. package/esm2015/lib/badge/badge.component.metadata.json +0 -1
  133. package/esm2015/lib/badge/badge.module.js +0 -13
  134. package/esm2015/lib/badge/badge.module.js.map +0 -1
  135. package/esm2015/lib/badge/badge.module.metadata.json +0 -1
  136. package/esm2015/lib/badge/testing/badge.harness.js +0 -30
  137. package/esm2015/lib/badge/testing/badge.harness.js.map +0 -1
  138. package/esm2015/lib/badge/testing/badge.harness.metadata.json +0 -1
  139. package/esm2015/lib/button/button.component.js +0 -108
  140. package/esm2015/lib/button/button.component.js.map +0 -1
  141. package/esm2015/lib/button/button.component.metadata.json +0 -1
  142. package/esm2015/lib/button/button.module.js +0 -11
  143. package/esm2015/lib/button/button.module.js.map +0 -1
  144. package/esm2015/lib/button/button.module.metadata.json +0 -1
  145. package/esm2015/lib/checkbox/checkbox-group.component.js +0 -19
  146. package/esm2015/lib/checkbox/checkbox-group.component.js.map +0 -1
  147. package/esm2015/lib/checkbox/checkbox-group.component.metadata.json +0 -1
  148. package/esm2015/lib/checkbox/checkbox.component.js +0 -89
  149. package/esm2015/lib/checkbox/checkbox.component.js.map +0 -1
  150. package/esm2015/lib/checkbox/checkbox.component.metadata.json +0 -1
  151. package/esm2015/lib/checkbox/checkbox.module.js +0 -12
  152. package/esm2015/lib/checkbox/checkbox.module.js.map +0 -1
  153. package/esm2015/lib/checkbox/checkbox.module.metadata.json +0 -1
  154. package/esm2015/lib/core/animation.js +0 -34
  155. package/esm2015/lib/core/animation.js.map +0 -1
  156. package/esm2015/lib/core/animation.metadata.json +0 -1
  157. package/esm2015/lib/core/client-environment.js +0 -20
  158. package/esm2015/lib/core/client-environment.js.map +0 -1
  159. package/esm2015/lib/core/client-environment.metadata.json +0 -1
  160. package/esm2015/lib/core/common-behaviors/disabled.js +0 -25
  161. package/esm2015/lib/core/common-behaviors/disabled.js.map +0 -1
  162. package/esm2015/lib/core/common-behaviors/disabled.metadata.json +0 -1
  163. package/esm2015/lib/core/core.module.js +0 -25
  164. package/esm2015/lib/core/core.module.js.map +0 -1
  165. package/esm2015/lib/core/core.module.metadata.json +0 -1
  166. package/esm2015/lib/core/devices/client-input-desktop.directive.js +0 -22
  167. package/esm2015/lib/core/devices/client-input-desktop.directive.js.map +0 -1
  168. package/esm2015/lib/core/devices/client-input-desktop.directive.metadata.json +0 -1
  169. package/esm2015/lib/core/devices/client-input-touch.directive.js +0 -22
  170. package/esm2015/lib/core/devices/client-input-touch.directive.js.map +0 -1
  171. package/esm2015/lib/core/devices/client-input-touch.directive.metadata.json +0 -1
  172. package/esm2015/lib/core/devices/client-output-desktop.directive.js +0 -22
  173. package/esm2015/lib/core/devices/client-output-desktop.directive.js.map +0 -1
  174. package/esm2015/lib/core/devices/client-output-desktop.directive.metadata.json +0 -1
  175. package/esm2015/lib/core/devices/client-output-touch.directive.js +0 -22
  176. package/esm2015/lib/core/devices/client-output-touch.directive.js.map +0 -1
  177. package/esm2015/lib/core/devices/client-output-touch.directive.metadata.json +0 -1
  178. package/esm2015/lib/core/pipes/pure-pipes.module.js +0 -11
  179. package/esm2015/lib/core/pipes/pure-pipes.module.js.map +0 -1
  180. package/esm2015/lib/core/pipes/pure-pipes.module.metadata.json +0 -1
  181. package/esm2015/lib/core/pipes/title.pipe.js +0 -17
  182. package/esm2015/lib/core/pipes/title.pipe.js.map +0 -1
  183. package/esm2015/lib/core/pipes/title.pipe.metadata.json +0 -1
  184. package/esm2015/lib/core/radio-checkbox-base.js +0 -15
  185. package/esm2015/lib/core/radio-checkbox-base.js.map +0 -1
  186. package/esm2015/lib/core/radio-checkbox-base.metadata.json +0 -1
  187. package/esm2015/lib/core/theme.library.js +0 -59
  188. package/esm2015/lib/core/theme.library.js.map +0 -1
  189. package/esm2015/lib/core/theme.library.metadata.json +0 -1
  190. package/esm2015/lib/core/types.js +0 -2
  191. package/esm2015/lib/core/types.js.map +0 -1
  192. package/esm2015/lib/core/types.metadata.json +0 -1
  193. package/esm2015/lib/grid/grid.component.js +0 -131
  194. package/esm2015/lib/grid/grid.component.js.map +0 -1
  195. package/esm2015/lib/grid/grid.component.metadata.json +0 -1
  196. package/esm2015/lib/grid/grid.module.js +0 -13
  197. package/esm2015/lib/grid/grid.module.js.map +0 -1
  198. package/esm2015/lib/grid/grid.module.metadata.json +0 -1
  199. package/esm2015/lib/icon/icon.component.js +0 -48
  200. package/esm2015/lib/icon/icon.component.js.map +0 -1
  201. package/esm2015/lib/icon/icon.component.metadata.json +0 -1
  202. package/esm2015/lib/icon/icon.module.js +0 -11
  203. package/esm2015/lib/icon/icon.module.js.map +0 -1
  204. package/esm2015/lib/icon/icon.module.metadata.json +0 -1
  205. package/esm2015/lib/input-field/input-field.component.js +0 -144
  206. package/esm2015/lib/input-field/input-field.component.js.map +0 -1
  207. package/esm2015/lib/input-field/input-field.component.metadata.json +0 -1
  208. package/esm2015/lib/input-field/input-field.module.js +0 -15
  209. package/esm2015/lib/input-field/input-field.module.js.map +0 -1
  210. package/esm2015/lib/input-field/input-field.module.metadata.json +0 -1
  211. package/esm2015/lib/menu/divider.directive.js +0 -20
  212. package/esm2015/lib/menu/divider.directive.js.map +0 -1
  213. package/esm2015/lib/menu/divider.directive.metadata.json +0 -1
  214. package/esm2015/lib/menu/menu-desktop-animations.js +0 -23
  215. package/esm2015/lib/menu/menu-desktop-animations.js.map +0 -1
  216. package/esm2015/lib/menu/menu-desktop-animations.metadata.json +0 -1
  217. package/esm2015/lib/menu/menu-errors.js +0 -37
  218. package/esm2015/lib/menu/menu-errors.js.map +0 -1
  219. package/esm2015/lib/menu/menu-errors.metadata.json +0 -1
  220. package/esm2015/lib/menu/menu-item.component.js +0 -82
  221. package/esm2015/lib/menu/menu-item.component.js.map +0 -1
  222. package/esm2015/lib/menu/menu-item.component.metadata.json +0 -1
  223. package/esm2015/lib/menu/menu-panel.js +0 -7
  224. package/esm2015/lib/menu/menu-panel.js.map +0 -1
  225. package/esm2015/lib/menu/menu-panel.metadata.json +0 -1
  226. package/esm2015/lib/menu/menu-positions.js +0 -9
  227. package/esm2015/lib/menu/menu-positions.js.map +0 -1
  228. package/esm2015/lib/menu/menu-positions.metadata.json +0 -1
  229. package/esm2015/lib/menu/menu-touch-animations.js +0 -137
  230. package/esm2015/lib/menu/menu-touch-animations.js.map +0 -1
  231. package/esm2015/lib/menu/menu-touch-animations.metadata.json +0 -1
  232. package/esm2015/lib/menu/menu-touch-close.component.js +0 -16
  233. package/esm2015/lib/menu/menu-touch-close.component.js.map +0 -1
  234. package/esm2015/lib/menu/menu-touch-close.component.metadata.json +0 -1
  235. package/esm2015/lib/menu/menu-touch-title.component.js +0 -45
  236. package/esm2015/lib/menu/menu-touch-title.component.js.map +0 -1
  237. package/esm2015/lib/menu/menu-touch-title.component.metadata.json +0 -1
  238. package/esm2015/lib/menu/menu-trigger-for.directive.js +0 -684
  239. package/esm2015/lib/menu/menu-trigger-for.directive.js.map +0 -1
  240. package/esm2015/lib/menu/menu-trigger-for.directive.metadata.json +0 -1
  241. package/esm2015/lib/menu/menu.component.js +0 -362
  242. package/esm2015/lib/menu/menu.component.js.map +0 -1
  243. package/esm2015/lib/menu/menu.component.metadata.json +0 -1
  244. package/esm2015/lib/menu/menu.module.js +0 -38
  245. package/esm2015/lib/menu/menu.module.js.map +0 -1
  246. package/esm2015/lib/menu/menu.module.metadata.json +0 -1
  247. package/esm2015/lib/menu/testing/menu.harness.js +0 -133
  248. package/esm2015/lib/menu/testing/menu.harness.js.map +0 -1
  249. package/esm2015/lib/menu/testing/menu.harness.metadata.json +0 -1
  250. package/esm2015/lib/menu/title.directive.js +0 -13
  251. package/esm2015/lib/menu/title.directive.js.map +0 -1
  252. package/esm2015/lib/menu/title.directive.metadata.json +0 -1
  253. package/esm2015/lib/radio-button/radio-button.component.js +0 -110
  254. package/esm2015/lib/radio-button/radio-button.component.js.map +0 -1
  255. package/esm2015/lib/radio-button/radio-button.component.metadata.json +0 -1
  256. package/esm2015/lib/radio-button/radio-button.module.js +0 -12
  257. package/esm2015/lib/radio-button/radio-button.module.js.map +0 -1
  258. package/esm2015/lib/radio-button/radio-button.module.metadata.json +0 -1
  259. package/esm2015/lib/radio-button/radio-group.component.js +0 -19
  260. package/esm2015/lib/radio-button/radio-group.component.js.map +0 -1
  261. package/esm2015/lib/radio-button/radio-group.component.metadata.json +0 -1
  262. package/esm2015/lib/table/cell/cell.js +0 -12
  263. package/esm2015/lib/table/cell/cell.js.map +0 -1
  264. package/esm2015/lib/table/cell/cell.metadata.json +0 -1
  265. package/esm2015/lib/table/cell/table-data-cell.component.js +0 -21
  266. package/esm2015/lib/table/cell/table-data-cell.component.js.map +0 -1
  267. package/esm2015/lib/table/cell/table-data-cell.component.metadata.json +0 -1
  268. package/esm2015/lib/table/cell/table-header-cell.component.js +0 -13
  269. package/esm2015/lib/table/cell/table-header-cell.component.js.map +0 -1
  270. package/esm2015/lib/table/cell/table-header-cell.component.metadata.json +0 -1
  271. package/esm2015/lib/table/column/table-column.directive.js +0 -16
  272. package/esm2015/lib/table/column/table-column.directive.js.map +0 -1
  273. package/esm2015/lib/table/column/table-column.directive.metadata.json +0 -1
  274. package/esm2015/lib/table/table-constants.library.js +0 -4
  275. package/esm2015/lib/table/table-constants.library.js.map +0 -1
  276. package/esm2015/lib/table/table-constants.library.metadata.json +0 -1
  277. package/esm2015/lib/table/table.component.js +0 -28
  278. package/esm2015/lib/table/table.component.js.map +0 -1
  279. package/esm2015/lib/table/table.component.metadata.json +0 -1
  280. package/esm2015/lib/table/table.module.js +0 -24
  281. package/esm2015/lib/table/table.module.js.map +0 -1
  282. package/esm2015/lib/table/table.module.metadata.json +0 -1
  283. package/esm2015/lib/toggle-switch/toggle-switch.component.js +0 -89
  284. package/esm2015/lib/toggle-switch/toggle-switch.component.js.map +0 -1
  285. package/esm2015/lib/toggle-switch/toggle-switch.component.metadata.json +0 -1
  286. package/esm2015/lib/toggle-switch/toggle-switch.module.js +0 -11
  287. package/esm2015/lib/toggle-switch/toggle-switch.module.js.map +0 -1
  288. package/esm2015/lib/toggle-switch/toggle-switch.module.metadata.json +0 -1
  289. package/fesm2015/ifsworld-granite-components.js +0 -2992
  290. package/fesm2015/ifsworld-granite-components.js.map +0 -1
  291. package/ifsworld-granite-components.metadata.json +0 -1
@@ -1,3649 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/cdk/coercion'), require('rxjs'), require('rxjs/operators'), require('@angular/cdk/testing'), require('@angular/cdk/overlay'), require('@angular/cdk/portal'), require('@angular/cdk/a11y'), require('@angular/cdk/keycodes'), require('@angular/animations'), require('@angular/cdk/bidi'), require('@angular/cdk/platform'), require('@angular/cdk/collections'), require('@angular/cdk/table')) :
3
- typeof define === 'function' && define.amd ? define('@ifsworld/granite-components', ['exports', '@angular/core', '@angular/common', '@angular/cdk/coercion', 'rxjs', 'rxjs/operators', '@angular/cdk/testing', '@angular/cdk/overlay', '@angular/cdk/portal', '@angular/cdk/a11y', '@angular/cdk/keycodes', '@angular/animations', '@angular/cdk/bidi', '@angular/cdk/platform', '@angular/cdk/collections', '@angular/cdk/table'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ifsworld = global.ifsworld || {}, global.ifsworld['granite-components'] = {}), global.ng.core, global.ng.common, global.ng.cdk.coercion, global.rxjs, global.rxjs.operators, global.ng.cdk.testing, global.ng.cdk.overlay, global.ng.cdk.portal, global.ng.cdk.a11y, global.ng.cdk.keycodes, global.ng.animations, global.ng.cdk.bidi, global.ng.cdk.platform, global.ng.cdk.collections, global.ng.cdk.table));
5
- }(this, (function (exports, core, common, coercion, rxjs, operators, testing, overlay, portal, a11y, keycodes, animations, bidi, platform, collections, table) { 'use strict';
6
-
7
- var GraniteArrangeGridItemComponent = /** @class */ (function () {
8
- function GraniteArrangeGridItemComponent(element) {
9
- this.element = element;
10
- /**
11
- * Column span to render.
12
- * For use in template only. Do not use outside of this component.
13
- * @ignore
14
- */
15
- this._columnSpan = null;
16
- /* no-op */
17
- }
18
- Object.defineProperty(GraniteArrangeGridItemComponent.prototype, "columnSpan", {
19
- /**
20
- * Number of cells the item would span. Used by arrange grid in column
21
- * orientation to fill any unused space caused by wrapped items.
22
- */
23
- set: function (value) {
24
- this._columnSpan = value;
25
- this.updateStyles();
26
- },
27
- enumerable: false,
28
- configurable: true
29
- });
30
- /**
31
- * Update element styles
32
- */
33
- GraniteArrangeGridItemComponent.prototype.updateStyles = function () {
34
- this.setCssProperty('--columnSpan', this._columnSpan ? this._columnSpan.toString() : null);
35
- };
36
- /**
37
- * Set CSS variable value or remove it if a null value is given.
38
- * Would of course rather have used property binding but that is not
39
- * supported until (perhaps) Angular 9.
40
- * See: https://github.com/angular/angular/issues/9343
41
- */
42
- GraniteArrangeGridItemComponent.prototype.setCssProperty = function (variable, value) {
43
- this.element.nativeElement.style.setProperty(variable, value);
44
- };
45
- return GraniteArrangeGridItemComponent;
46
- }());
47
- GraniteArrangeGridItemComponent.decorators = [
48
- { type: core.Component, args: [{
49
- selector: 'granite-arrange-grid-item',
50
- template: '<ng-content></ng-content>',
51
- changeDetection: core.ChangeDetectionStrategy.OnPush,
52
- styles: [":host{--columnSpan:$default-column-span;display:grid;grid-column:span var(--columnSpan,1)}"]
53
- },] }
54
- ];
55
- GraniteArrangeGridItemComponent.ctorParameters = function () { return [
56
- { type: core.ElementRef }
57
- ]; };
58
-
59
- (function (GraniteArrangeGridOrientation) {
60
- GraniteArrangeGridOrientation["columns"] = "columns";
61
- GraniteArrangeGridOrientation["rows"] = "rows";
62
- })(exports.GraniteArrangeGridOrientation || (exports.GraniteArrangeGridOrientation = {}));
63
- var GraniteArrangeGridComponent = /** @class */ (function () {
64
- function GraniteArrangeGridComponent(element) {
65
- this.element = element;
66
- /** How to present grid items; `columns` (default) or `rows` */
67
- this.orientation = exports.GraniteArrangeGridOrientation.columns;
68
- /** Exposes column orientation to template */
69
- this.classColumnOrientation = false;
70
- /** Exposes row orientation to template */
71
- this.classRowOrientation = false;
72
- /** Number of columns to render */
73
- this._cols = GraniteArrangeGridComponent.defaultCols;
74
- /** Nexted on component destruction to complete other observables. */
75
- this.destroy$ = new rxjs.Subject();
76
- /* no-op */
77
- }
78
- Object.defineProperty(GraniteArrangeGridComponent.prototype, "cols", {
79
- get: function () {
80
- return this._cols;
81
- },
82
- /**
83
- * Number of grid columns to use when orientation is set to `column`. The
84
- * default is two columns.
85
- */
86
- set: function (value) {
87
- this._cols = Math.max(1, Math.round(coercion.coerceNumberProperty(value)));
88
- },
89
- enumerable: false,
90
- configurable: true
91
- });
92
- Object.defineProperty(GraniteArrangeGridComponent.prototype, "rows", {
93
- get: function () {
94
- return this._rows;
95
- },
96
- set: function (value) {
97
- // Prevent pointless usage
98
- throw Error('Explicitly setting rows value for arrange grid is unsupported');
99
- },
100
- enumerable: false,
101
- configurable: true
102
- });
103
- GraniteArrangeGridComponent.prototype.ngAfterContentInit = function () {
104
- var _this = this;
105
- // Update style whenever grid item components change in content
106
- this.arrangeGridItemComponents.changes
107
- .pipe(operators.takeUntil(this.destroy$))
108
- .subscribe(function () { return _this.updateStyles(); });
109
- this.updateStyles();
110
- };
111
- GraniteArrangeGridComponent.prototype.ngOnChanges = function (changes) {
112
- if ((changes.orientation && !changes.orientation.isFirstChange()) ||
113
- (changes.cols && !changes.cols.isFirstChange())) {
114
- this.updateStyles();
115
- }
116
- };
117
- GraniteArrangeGridComponent.prototype.ngOnDestroy = function () {
118
- this.destroy$.next();
119
- };
120
- /**
121
- * Update grid row template style.
122
- *
123
- * Use content height of all but last row and let the last grow
124
- * to take up any remaining space.
125
- */
126
- GraniteArrangeGridComponent.prototype.updateStyles = function () {
127
- var children = (this.arrangeGridItemComponents || []).length;
128
- if (this.orientation === exports.GraniteArrangeGridOrientation.columns) {
129
- // If too many items was placed into too few colums, there would
130
- // be some wrapping. Take that into account when calculating the
131
- // number of rows.
132
- this._rows = Math.trunc((children - 1) / (this._cols || 1)) + 1;
133
- this.classColumnOrientation = true;
134
- this.classRowOrientation = false;
135
- if (children > 0) {
136
- // Fill any unused space caused by wrapped items by making the
137
- // last item also span over remaining cells.
138
- this.arrangeGridItemComponents.forEach(function (c) { return (c.columnSpan = null); });
139
- this.arrangeGridItemComponents.last.columnSpan =
140
- this._rows * this._cols - children + 1;
141
- }
142
- }
143
- else {
144
- this._cols = 1; // In row orientation, there is just a single column
145
- this._rows = children;
146
- this.classColumnOrientation = false;
147
- this.classRowOrientation = true;
148
- }
149
- this.setCssProperty('--cols', this._cols.toString());
150
- this.setCssProperty('--rows', this._rows.toString());
151
- };
152
- /**
153
- * Set CSS variable value or remove it if a null value is given.
154
- * Would of course rather have used property binding but that is not
155
- * supported until (perhaps) Angular 9.
156
- * See: https://github.com/angular/angular/issues/9343
157
- *
158
- * TODO: Replace with property binding with Angular 9 upgrade
159
- */
160
- GraniteArrangeGridComponent.prototype.setCssProperty = function (variable, value) {
161
- this.element.nativeElement.style.setProperty(variable, value);
162
- };
163
- return GraniteArrangeGridComponent;
164
- }());
165
- /** Default number of columns to use in column orientation */
166
- GraniteArrangeGridComponent.defaultCols = 2;
167
- GraniteArrangeGridComponent.decorators = [
168
- { type: core.Component, args: [{
169
- selector: 'granite-arrange-grid',
170
- template: "<ng-content select=\"granite-arrange-grid-item\"></ng-content>\n",
171
- changeDetection: core.ChangeDetectionStrategy.OnPush,
172
- styles: ["@media only screen and (min-width:960px){:host{--cols:1;--rows:1;display:grid;grid-template-columns:repeat(var(--cols,1),1fr);-moz-column-gap:.5rem;column-gap:.5rem;row-gap:.5rem}:host.row-orientation{grid-template-columns:auto;grid-template-rows:repeat(calc(var(--rows, 1) - 1),-webkit-max-content);grid-template-rows:repeat(calc(var(--rows, 1) - 1),max-content)}}"]
173
- },] }
174
- ];
175
- GraniteArrangeGridComponent.ctorParameters = function () { return [
176
- { type: core.ElementRef }
177
- ]; };
178
- GraniteArrangeGridComponent.propDecorators = {
179
- orientation: [{ type: core.Input }],
180
- classColumnOrientation: [{ type: core.HostBinding, args: ['class.column-orientation',] }],
181
- classRowOrientation: [{ type: core.HostBinding, args: ['class.row-orientation',] }],
182
- arrangeGridItemComponents: [{ type: core.ContentChildren, args: [GraniteArrangeGridItemComponent,] }],
183
- cols: [{ type: core.Input }]
184
- };
185
-
186
- var GraniteArrangeGridModule = /** @class */ (function () {
187
- function GraniteArrangeGridModule() {
188
- }
189
- return GraniteArrangeGridModule;
190
- }());
191
- GraniteArrangeGridModule.decorators = [
192
- { type: core.NgModule, args: [{
193
- declarations: [GraniteArrangeGridComponent, GraniteArrangeGridItemComponent],
194
- imports: [common.CommonModule],
195
- exports: [GraniteArrangeGridComponent, GraniteArrangeGridItemComponent],
196
- },] }
197
- ];
198
-
199
- /**
200
- * Grid item component
201
- *
202
- * Merely a wrapper for CSS Grid items, accepting item style as input parameters.
203
- */
204
- var GraniteGridItemComponent = /** @class */ (function () {
205
- function GraniteGridItemComponent(element, renderer) {
206
- this.element = element;
207
- this.renderer = renderer;
208
- }
209
- GraniteGridItemComponent.prototype.ngOnChanges = function () {
210
- this.updateStyles();
211
- };
212
- /**
213
- * Update element styles
214
- */
215
- GraniteGridItemComponent.prototype.updateStyles = function () {
216
- this.setStyle('gridColumnStart', this.columnStart);
217
- this.setStyle('gridColumnEnd', this.columnEnd);
218
- this.setStyle('gridRowStart', this.rowStart);
219
- this.setStyle('gridRowEnd', this.rowEnd);
220
- };
221
- /**
222
- * Sets the element style. Needs to be set manually to avoid "Changed after
223
- * checked" errors that would occur with HostBinding.
224
- */
225
- GraniteGridItemComponent.prototype.setStyle = function (property, value) {
226
- this.renderer.setStyle(this.element.nativeElement, property, value || '');
227
- };
228
- return GraniteGridItemComponent;
229
- }());
230
- GraniteGridItemComponent.decorators = [
231
- { type: core.Component, args: [{
232
- selector: 'granite-grid-item',
233
- template: '<ng-content></ng-content>',
234
- changeDetection: core.ChangeDetectionStrategy.OnPush
235
- },] }
236
- ];
237
- GraniteGridItemComponent.ctorParameters = function () { return [
238
- { type: core.ElementRef },
239
- { type: core.Renderer2 }
240
- ]; };
241
- GraniteGridItemComponent.propDecorators = {
242
- columnStart: [{ type: core.Input }],
243
- columnEnd: [{ type: core.Input }],
244
- rowStart: [{ type: core.Input }],
245
- rowEnd: [{ type: core.Input }]
246
- };
247
- /**
248
- * Grid
249
- *
250
- * A wrapper around a native CSS Grid. Anything can be used for grid items, but
251
- * `GridItemComponent` is recommended for common cases.
252
- */
253
- var GraniteGridComponent = /** @class */ (function () {
254
- function GraniteGridComponent(element) {
255
- this.element = element;
256
- }
257
- Object.defineProperty(GraniteGridComponent.prototype, "cols", {
258
- get: function () {
259
- return this._cols;
260
- },
261
- /**
262
- * Number of grid columns, unless set via styling (grid-template-columns)
263
- *
264
- * Setting this value will produce equally sized columns
265
- */
266
- set: function (value) {
267
- this._cols = Math.max(1, Math.round(coercion.coerceNumberProperty(value)));
268
- },
269
- enumerable: false,
270
- configurable: true
271
- });
272
- Object.defineProperty(GraniteGridComponent.prototype, "rows", {
273
- get: function () {
274
- return this._rows;
275
- },
276
- /**
277
- * Number of grid rows, unless set via styling (grid-template-rows)
278
- *
279
- * Setting this value will produce equally sized rows
280
- */
281
- set: function (value) {
282
- this._rows = Math.max(1, Math.round(coercion.coerceNumberProperty(value)));
283
- },
284
- enumerable: false,
285
- configurable: true
286
- });
287
- GraniteGridComponent.prototype.ngAfterContentInit = function () {
288
- this.updateStyles();
289
- };
290
- GraniteGridComponent.prototype.ngOnChanges = function (changes) {
291
- if ((changes.cols && !changes.cols.isFirstChange()) ||
292
- (changes.rows && !changes.rows.isFirstChange())) {
293
- this.updateStyles();
294
- }
295
- };
296
- /** Update element styles */
297
- GraniteGridComponent.prototype.updateStyles = function () {
298
- this.updateColumnStyles();
299
- this.updateRowStyles();
300
- };
301
- /**
302
- * Set CSS variable value or remove it if a null value is given.
303
- * Would of course rather have used property binding but that is not
304
- * supported until (perhaps) Angular 9.
305
- * See: https://github.com/angular/angular/issues/9343
306
- *
307
- * TODO: Replace with property binding with Angular 9 upgrade
308
- */
309
- GraniteGridComponent.prototype.setCssProperty = function (variable, value) {
310
- this.element.nativeElement.style.setProperty(variable, value);
311
- };
312
- /** Update grid column template style */
313
- GraniteGridComponent.prototype.updateColumnStyles = function () {
314
- this.setCssProperty('--cols', (this._cols && this._cols.toString()) || null);
315
- };
316
- /** Update grid row template style */
317
- GraniteGridComponent.prototype.updateRowStyles = function () {
318
- this.setCssProperty('--rows', (this._rows && this._rows.toString()) || null);
319
- };
320
- return GraniteGridComponent;
321
- }());
322
- GraniteGridComponent.decorators = [
323
- { type: core.Component, args: [{
324
- selector: 'granite-grid',
325
- template: '<ng-content></ng-content>',
326
- changeDetection: core.ChangeDetectionStrategy.OnPush,
327
- styles: [":host{--cols:1;--rows:1;display:grid;grid-template-columns:repeat(var(--cols,1),1fr);grid-template-rows:repeat(var(--rows,1),1fr)}"]
328
- },] }
329
- ];
330
- GraniteGridComponent.ctorParameters = function () { return [
331
- { type: core.ElementRef }
332
- ]; };
333
- GraniteGridComponent.propDecorators = {
334
- cols: [{ type: core.Input }],
335
- rows: [{ type: core.Input }]
336
- };
337
-
338
- var GraniteGridModule = /** @class */ (function () {
339
- function GraniteGridModule() {
340
- }
341
- return GraniteGridModule;
342
- }());
343
- GraniteGridModule.decorators = [
344
- { type: core.NgModule, args: [{
345
- declarations: [GraniteGridComponent, GraniteGridItemComponent],
346
- imports: [common.CommonModule],
347
- exports: [GraniteGridComponent, GraniteGridItemComponent],
348
- },] }
349
- ];
350
-
351
- /******************************************************************************
352
- Copyright (c) Microsoft Corporation.
353
-
354
- Permission to use, copy, modify, and/or distribute this software for any
355
- purpose with or without fee is hereby granted.
356
-
357
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
358
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
359
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
360
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
361
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
362
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
363
- PERFORMANCE OF THIS SOFTWARE.
364
- ***************************************************************************** */
365
- /* global Reflect, Promise */
366
- var extendStatics = function (d, b) {
367
- extendStatics = Object.setPrototypeOf ||
368
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
369
- function (d, b) { for (var p in b)
370
- if (Object.prototype.hasOwnProperty.call(b, p))
371
- d[p] = b[p]; };
372
- return extendStatics(d, b);
373
- };
374
- function __extends(d, b) {
375
- if (typeof b !== "function" && b !== null)
376
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
377
- extendStatics(d, b);
378
- function __() { this.constructor = d; }
379
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
380
- }
381
- var __assign = function () {
382
- __assign = Object.assign || function __assign(t) {
383
- for (var s, i = 1, n = arguments.length; i < n; i++) {
384
- s = arguments[i];
385
- for (var p in s)
386
- if (Object.prototype.hasOwnProperty.call(s, p))
387
- t[p] = s[p];
388
- }
389
- return t;
390
- };
391
- return __assign.apply(this, arguments);
392
- };
393
- function __rest(s, e) {
394
- var t = {};
395
- for (var p in s)
396
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
397
- t[p] = s[p];
398
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
399
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
400
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
401
- t[p[i]] = s[p[i]];
402
- }
403
- return t;
404
- }
405
- function __decorate(decorators, target, key, desc) {
406
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
407
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
408
- r = Reflect.decorate(decorators, target, key, desc);
409
- else
410
- for (var i = decorators.length - 1; i >= 0; i--)
411
- if (d = decorators[i])
412
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
413
- return c > 3 && r && Object.defineProperty(target, key, r), r;
414
- }
415
- function __param(paramIndex, decorator) {
416
- return function (target, key) { decorator(target, key, paramIndex); };
417
- }
418
- function __metadata(metadataKey, metadataValue) {
419
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
420
- return Reflect.metadata(metadataKey, metadataValue);
421
- }
422
- function __awaiter(thisArg, _arguments, P, generator) {
423
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
424
- return new (P || (P = Promise))(function (resolve, reject) {
425
- function fulfilled(value) { try {
426
- step(generator.next(value));
427
- }
428
- catch (e) {
429
- reject(e);
430
- } }
431
- function rejected(value) { try {
432
- step(generator["throw"](value));
433
- }
434
- catch (e) {
435
- reject(e);
436
- } }
437
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
438
- step((generator = generator.apply(thisArg, _arguments || [])).next());
439
- });
440
- }
441
- function __generator(thisArg, body) {
442
- var _ = { label: 0, sent: function () { if (t[0] & 1)
443
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
444
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
445
- function verb(n) { return function (v) { return step([n, v]); }; }
446
- function step(op) {
447
- if (f)
448
- throw new TypeError("Generator is already executing.");
449
- while (_)
450
- try {
451
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
452
- return t;
453
- if (y = 0, t)
454
- op = [op[0] & 2, t.value];
455
- switch (op[0]) {
456
- case 0:
457
- case 1:
458
- t = op;
459
- break;
460
- case 4:
461
- _.label++;
462
- return { value: op[1], done: false };
463
- case 5:
464
- _.label++;
465
- y = op[1];
466
- op = [0];
467
- continue;
468
- case 7:
469
- op = _.ops.pop();
470
- _.trys.pop();
471
- continue;
472
- default:
473
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
474
- _ = 0;
475
- continue;
476
- }
477
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
478
- _.label = op[1];
479
- break;
480
- }
481
- if (op[0] === 6 && _.label < t[1]) {
482
- _.label = t[1];
483
- t = op;
484
- break;
485
- }
486
- if (t && _.label < t[2]) {
487
- _.label = t[2];
488
- _.ops.push(op);
489
- break;
490
- }
491
- if (t[2])
492
- _.ops.pop();
493
- _.trys.pop();
494
- continue;
495
- }
496
- op = body.call(thisArg, _);
497
- }
498
- catch (e) {
499
- op = [6, e];
500
- y = 0;
501
- }
502
- finally {
503
- f = t = 0;
504
- }
505
- if (op[0] & 5)
506
- throw op[1];
507
- return { value: op[0] ? op[1] : void 0, done: true };
508
- }
509
- }
510
- var __createBinding = Object.create ? (function (o, m, k, k2) {
511
- if (k2 === undefined)
512
- k2 = k;
513
- var desc = Object.getOwnPropertyDescriptor(m, k);
514
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
515
- desc = { enumerable: true, get: function () { return m[k]; } };
516
- }
517
- Object.defineProperty(o, k2, desc);
518
- }) : (function (o, m, k, k2) {
519
- if (k2 === undefined)
520
- k2 = k;
521
- o[k2] = m[k];
522
- });
523
- function __exportStar(m, o) {
524
- for (var p in m)
525
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
526
- __createBinding(o, m, p);
527
- }
528
- function __values(o) {
529
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
530
- if (m)
531
- return m.call(o);
532
- if (o && typeof o.length === "number")
533
- return {
534
- next: function () {
535
- if (o && i >= o.length)
536
- o = void 0;
537
- return { value: o && o[i++], done: !o };
538
- }
539
- };
540
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
541
- }
542
- function __read(o, n) {
543
- var m = typeof Symbol === "function" && o[Symbol.iterator];
544
- if (!m)
545
- return o;
546
- var i = m.call(o), r, ar = [], e;
547
- try {
548
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
549
- ar.push(r.value);
550
- }
551
- catch (error) {
552
- e = { error: error };
553
- }
554
- finally {
555
- try {
556
- if (r && !r.done && (m = i["return"]))
557
- m.call(i);
558
- }
559
- finally {
560
- if (e)
561
- throw e.error;
562
- }
563
- }
564
- return ar;
565
- }
566
- /** @deprecated */
567
- function __spread() {
568
- for (var ar = [], i = 0; i < arguments.length; i++)
569
- ar = ar.concat(__read(arguments[i]));
570
- return ar;
571
- }
572
- /** @deprecated */
573
- function __spreadArrays() {
574
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
575
- s += arguments[i].length;
576
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
577
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
578
- r[k] = a[j];
579
- return r;
580
- }
581
- function __spreadArray(to, from, pack) {
582
- if (pack || arguments.length === 2)
583
- for (var i = 0, l = from.length, ar; i < l; i++) {
584
- if (ar || !(i in from)) {
585
- if (!ar)
586
- ar = Array.prototype.slice.call(from, 0, i);
587
- ar[i] = from[i];
588
- }
589
- }
590
- return to.concat(ar || Array.prototype.slice.call(from));
591
- }
592
- function __await(v) {
593
- return this instanceof __await ? (this.v = v, this) : new __await(v);
594
- }
595
- function __asyncGenerator(thisArg, _arguments, generator) {
596
- if (!Symbol.asyncIterator)
597
- throw new TypeError("Symbol.asyncIterator is not defined.");
598
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
599
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
600
- function verb(n) { if (g[n])
601
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
602
- function resume(n, v) { try {
603
- step(g[n](v));
604
- }
605
- catch (e) {
606
- settle(q[0][3], e);
607
- } }
608
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
609
- function fulfill(value) { resume("next", value); }
610
- function reject(value) { resume("throw", value); }
611
- function settle(f, v) { if (f(v), q.shift(), q.length)
612
- resume(q[0][0], q[0][1]); }
613
- }
614
- function __asyncDelegator(o) {
615
- var i, p;
616
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
617
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
618
- }
619
- function __asyncValues(o) {
620
- if (!Symbol.asyncIterator)
621
- throw new TypeError("Symbol.asyncIterator is not defined.");
622
- var m = o[Symbol.asyncIterator], i;
623
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
624
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
625
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
626
- }
627
- function __makeTemplateObject(cooked, raw) {
628
- if (Object.defineProperty) {
629
- Object.defineProperty(cooked, "raw", { value: raw });
630
- }
631
- else {
632
- cooked.raw = raw;
633
- }
634
- return cooked;
635
- }
636
- ;
637
- var __setModuleDefault = Object.create ? (function (o, v) {
638
- Object.defineProperty(o, "default", { enumerable: true, value: v });
639
- }) : function (o, v) {
640
- o["default"] = v;
641
- };
642
- function __importStar(mod) {
643
- if (mod && mod.__esModule)
644
- return mod;
645
- var result = {};
646
- if (mod != null)
647
- for (var k in mod)
648
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
649
- __createBinding(result, mod, k);
650
- __setModuleDefault(result, mod);
651
- return result;
652
- }
653
- function __importDefault(mod) {
654
- return (mod && mod.__esModule) ? mod : { default: mod };
655
- }
656
- function __classPrivateFieldGet(receiver, state, kind, f) {
657
- if (kind === "a" && !f)
658
- throw new TypeError("Private accessor was defined without a getter");
659
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
660
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
661
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
662
- }
663
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
664
- if (kind === "m")
665
- throw new TypeError("Private method is not writable");
666
- if (kind === "a" && !f)
667
- throw new TypeError("Private accessor was defined without a setter");
668
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
669
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
670
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
671
- }
672
- function __classPrivateFieldIn(state, receiver) {
673
- if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function"))
674
- throw new TypeError("Cannot use 'in' operator on non-object");
675
- return typeof state === "function" ? receiver === state : state.has(receiver);
676
- }
677
-
678
- var TOKEN_PREFIX = 'granite-';
679
- var TOKEN_PREFIX_OLD = 'fnd-'; // TODO: Remove this when all tokens have 'granite-' as the prefix
680
- /**
681
- * Get the theme that corresponds to a given ID
682
- */
683
- function getThemeById(themes, id) {
684
- var theme = id !== undefined ? themes.find(function (t) { return t.id === id; }) : undefined;
685
- return theme;
686
- }
687
- /**
688
- * Apply a theme to a DOM element by iterating though all tokens,
689
- * setting a CSS variable for each one.
690
- *
691
- * @param theme Theme to set
692
- * @param element Target element
693
- */
694
- function applyTheme(theme, element) {
695
- applyTokens(theme.tokens, element);
696
- }
697
- /**
698
- * Set a CSS variable for each token on the specified element.
699
- *
700
- * @param theme Theme to set
701
- * @param element Target element
702
- */
703
- function applyTokens(tokens, element) {
704
- var e_1, _a;
705
- try {
706
- for (var _b = __values(Object.keys(tokens)), _c = _b.next(); !_c.done; _c = _b.next()) {
707
- var token = _c.value;
708
- element.style.setProperty(token, tokens[token]);
709
- }
710
- }
711
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
712
- finally {
713
- try {
714
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
715
- }
716
- finally { if (e_1) throw e_1.error; }
717
- }
718
- }
719
- /**
720
- * Remove theme token CSS variables from an element using the specified keys
721
- *
722
- * @param theme Theme with tokens to clear
723
- * @param element Target element
724
- */
725
- function clearTheme(theme, element) {
726
- clearTokens(Object.keys(theme.tokens), element);
727
- }
728
- /**
729
- * Remove token CSS variables from an element using the specified keys.
730
- *
731
- * @param keys Token keys
732
- * @param element Target element
733
- */
734
- function clearTokens(keys, element) {
735
- var e_2, _a;
736
- try {
737
- for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
738
- var token = keys_1_1.value;
739
- element.style.removeProperty(token);
740
- }
741
- }
742
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
743
- finally {
744
- try {
745
- if (keys_1_1 && !keys_1_1.done && (_a = keys_1.return)) _a.call(keys_1);
746
- }
747
- finally { if (e_2) throw e_2.error; }
748
- }
749
- }
750
- function isValidToken(key) {
751
- return (key && (key.startsWith(TOKEN_PREFIX) || key.startsWith(TOKEN_PREFIX_OLD)));
752
- }
753
- function setPropertyValue(name, value, element) {
754
- if (element && element.style && value != null) {
755
- element.style.setProperty(name, isValidToken(value) ? "var(--" + value + ")" : value);
756
- }
757
- }
758
-
759
- var GraniteBadgeComponent = /** @class */ (function () {
760
- function GraniteBadgeComponent(elementRef) {
761
- this.elementRef = elementRef;
762
- /** Pill style badge */
763
- this.pill = false;
764
- }
765
- GraniteBadgeComponent.prototype.ngOnChanges = function (changes) {
766
- if (changes.backgroundColor) {
767
- if (changes.backgroundColor.previousValue !==
768
- changes.backgroundColor.currentValue) {
769
- setPropertyValue('background-color', changes.backgroundColor.currentValue, this.elementRef.nativeElement);
770
- }
771
- }
772
- if (changes.color) {
773
- if (changes.color.previousValue !== changes.color.currentValue) {
774
- setPropertyValue('color', changes.color.currentValue, this.elementRef.nativeElement);
775
- }
776
- }
777
- };
778
- return GraniteBadgeComponent;
779
- }());
780
- GraniteBadgeComponent.decorators = [
781
- { type: core.Component, args: [{
782
- selector: 'granite-badge',
783
- exportAs: 'graniteBadge',
784
- host: {
785
- class: 'granite-badge',
786
- '[class.granite-badge-pill]': 'pill',
787
- },
788
- template: '<ng-content></ng-content>',
789
- changeDetection: core.ChangeDetectionStrategy.OnPush,
790
- styles: [":host{display:-moz-inline-flex;display:inline-flex;flex-direction:row;flex-wrap:nowrap;overflow:hidden;-ms-text-overflow:ellipsis;text-overflow:ellipsis;white-space:nowrap;align-items:center;background-color:var(--granite-color-signal-neutral);color:var(--granite-color-text-static-light);padding:calc(var(--granite-spacing-m) * .3125);border-radius:.3125rem;-webkit-padding-start:calc(var(--granite-spacing-m) * .625);padding-inline-start:calc(var(--granite-spacing-m) * .625);-webkit-padding-end:calc(var(--granite-spacing-m) * .625);padding-inline-end:calc(var(--granite-spacing-m) * .625)}:host(.granite-badge-pill){border-radius:1.5625rem}"]
791
- },] }
792
- ];
793
- GraniteBadgeComponent.ctorParameters = function () { return [
794
- { type: core.ElementRef }
795
- ]; };
796
- GraniteBadgeComponent.propDecorators = {
797
- backgroundColor: [{ type: core.Input }],
798
- color: [{ type: core.Input }],
799
- pill: [{ type: core.Input }]
800
- };
801
-
802
- var GraniteBadgeModule = /** @class */ (function () {
803
- function GraniteBadgeModule() {
804
- }
805
- return GraniteBadgeModule;
806
- }());
807
- GraniteBadgeModule.decorators = [
808
- { type: core.NgModule, args: [{
809
- declarations: [GraniteBadgeComponent],
810
- imports: [common.CommonModule],
811
- exports: [GraniteBadgeComponent],
812
- },] }
813
- ];
814
-
815
- var GraniteBadgeHarness = /** @class */ (function (_super) {
816
- __extends(GraniteBadgeHarness, _super);
817
- function GraniteBadgeHarness() {
818
- return _super !== null && _super.apply(this, arguments) || this;
819
- }
820
- /**
821
- * Gets a `HarnessPredicate` that can be used to search for a `GraniteBadgeHarness` that meets
822
- * certain criteria.
823
- * @param options Options for filtering which badge instances are considered a match.
824
- * @return a `HarnessPredicate` configured with the given options.
825
- */
826
- GraniteBadgeHarness.with = function (options) {
827
- var _this = this;
828
- if (options === void 0) { options = {}; }
829
- var predicate = new testing.HarnessPredicate(GraniteBadgeHarness, options);
830
- predicate.addOption('text', options.text, function (harness, label) { return testing.HarnessPredicate.stringMatches(harness.getText(), label); });
831
- predicate.addOption('pill', options.pill, function (harness, pill) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
832
- switch (_a.label) {
833
- case 0: return [4 /*yield*/, harness.isPill()];
834
- case 1: return [2 /*return*/, (_a.sent()) === pill];
835
- }
836
- }); }); });
837
- return predicate;
838
- };
839
- /** Gets the Badge text. */
840
- GraniteBadgeHarness.prototype.getText = function () {
841
- return __awaiter(this, void 0, void 0, function () {
842
- return __generator(this, function (_a) {
843
- switch (_a.label) {
844
- case 0: return [4 /*yield*/, this.host()];
845
- case 1: return [2 /*return*/, (_a.sent()).text()];
846
- }
847
- });
848
- });
849
- };
850
- /** Whether it's a Pill type badge. */
851
- GraniteBadgeHarness.prototype.isPill = function () {
852
- return __awaiter(this, void 0, void 0, function () {
853
- return __generator(this, function (_a) {
854
- switch (_a.label) {
855
- case 0: return [4 /*yield*/, this.host()];
856
- case 1: return [2 /*return*/, (_a.sent()).hasClass('granite-badge-pill')];
857
- }
858
- });
859
- });
860
- };
861
- return GraniteBadgeHarness;
862
- }(testing.ComponentHarness));
863
- GraniteBadgeHarness.hostSelector = 'granite-badge';
864
-
865
- /**
866
- * Injection token used to provide the parent menu to menu-specific components.
867
- * @docs-private
868
- */
869
- var GRANITE_MENU_PANEL = new core.InjectionToken('GRANITE_MENU_PANEL');
870
-
871
- var GraniteMenuItemComponent = /** @class */ (function () {
872
- function GraniteMenuItemComponent(_elementRef, _focusMonitor, _parentMenu) {
873
- this._elementRef = _elementRef;
874
- this._focusMonitor = _focusMonitor;
875
- this._parentMenu = _parentMenu;
876
- /** ARIA role for the menu item. */
877
- this.role = 'menuitem';
878
- /** Stream that emits when the menu item is hovered. */
879
- // eslint-disable-next-line rxjs/no-exposed-subjects
880
- this._hovered = new rxjs.Subject();
881
- /** Stream that emits when the menu item is focused. */
882
- // eslint-disable-next-line rxjs/no-exposed-subjects
883
- this._focused = new rxjs.Subject();
884
- /** Whether the menu item acts as a trigger for a sub-menu (used for styling) */
885
- this._triggersSubmenu = false;
886
- /**
887
- * Whether the menu item is highlighted, e.g. in the "breadcrumb" parent chain
888
- * of sub menu trigger items
889
- */
890
- this._highlighted = false;
891
- // Start monitoring the element so it gets the appropriate focused classes. We want
892
- // to show the focus style for menu items only when the focus was not caused by a
893
- // mouse or touch interaction.
894
- _focusMonitor.monitor(this._elementRef, false);
895
- }
896
- GraniteMenuItemComponent.prototype.ngOnDestroy = function () {
897
- this._focusMonitor.stopMonitoring(this._elementRef);
898
- this._hovered.complete();
899
- this._focused.complete();
900
- };
901
- /** Focuses the menu item. */
902
- GraniteMenuItemComponent.prototype.focus = function (origin, options) {
903
- if (origin === void 0) { origin = 'program'; }
904
- this._focusMonitor.focusVia(this._getHostElement(), origin, options);
905
- this._focused.next(this);
906
- };
907
- /** Returns the host DOM element. */
908
- GraniteMenuItemComponent.prototype._getHostElement = function () {
909
- return this._elementRef.nativeElement;
910
- };
911
- return GraniteMenuItemComponent;
912
- }());
913
- GraniteMenuItemComponent.decorators = [
914
- { type: core.Component, args: [{
915
- // eslint-disable-next-line @angular-eslint/component-selector
916
- selector: '[graniteMenuItem]',
917
- template: "<ng-content></ng-content>\n <ng-container *ngIf=\"_triggersSubmenu\">\n <granite-icon\n class=\"caret-left\"\n [fontIcon]=\"'icon-caret-left'\"\n ></granite-icon>\n <granite-icon\n class=\"caret-right\"\n [fontIcon]=\"'icon-caret-right'\"\n ></granite-icon>\n </ng-container>",
918
- exportAs: 'graniteMenuItem',
919
- host: {
920
- '[attr.role]': 'role',
921
- '[class.granite-menu-item]': 'true',
922
- '[class.granite-menu-item-highlighted]': '_highlighted',
923
- '[class.granite-menu-item-submenu-trigger]': '_triggersSubmenu',
924
- //#region --- Touch device customizations ---
925
- '[class.granite-device-output-touch]': '_clientOutput?.device === "touch"',
926
- //#endregion --- Touch device customizations ---
927
- '(mouseenter)': '_hovered.next(this)',
928
- },
929
- styles: [":host{display:block;position:relative;line-height:2rem;padding:0 var(--granite-spacing-s);width:100%;max-width:100%;-webkit-user-select:none;-moz-user-select:none;user-select:none;cursor:pointer;outline:none;border:none;-webkit-tap-highlight-color:transparent;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:start;text-decoration:none;background-color:var(--granite-color-background-variant);color:var(--granite-color-text);font-size:var(--granite-font-size-body-small);font-family:inherit}@media (hover:hover) and (pointer:fine){:host:hover:not(.granite-title):not([disabled]){background:var(--granite-color-background-active-hover);color:var(--granite-color-text-on-active)}}@media (hover:none) and (pointer:coarse){:host:active:not(.granite-title):not([disabled]){background:var(--granite-color-background-active-hover);color:var(--granite-color-text-on-active)}}:host.granite-title{-moz-user-select:none;-webkit-user-select:none;user-select:none;display:flex;align-items:center;line-height:1.5rem;width:100%;outline:none;border:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-decoration:none;color:var(--granite-color-text);font-size:var(--granite-font-size-micro);font-weight:var(--granite-font-weight-bold);cursor:default}:host.cdk-keyboard-focused,:host.cdk-program-focused,:host.granite-menu-item-highlighted{background:var(--granite-color-background-active-hover);color:var(--granite-color-text-on-active)}:host granite-icon{position:absolute;font-size:var(--granite-font-size-body-small);color:inherit;top:50%;transform:translateY(-50%)}:host.granite-menu-item-submenu-trigger{-webkit-padding-end:var(--granite-spacing-l);padding-inline-end:var(--granite-spacing-l)}:host-context([dir=ltr]) :host.granite-menu-item-submenu-trigger granite-icon,html[dir=ltr] :host.granite-menu-item-submenu-trigger granite-icon{right:var(--granite-spacing-xs)}:host-context([dir=rtl]) :host.granite-menu-item-submenu-trigger granite-icon,html[dir=rtl] :host.granite-menu-item-submenu-trigger granite-icon{left:var(--granite-spacing-xs)}[dir=ltr] :host.granite-menu-item-submenu-trigger granite-icon.caret-left,[dir=rtl] :host.granite-menu-item-submenu-trigger granite-icon.caret-right{display:none}:host.granite-divider-top{border-top:.0625rem solid var(--granite-color-border-soft)}:host.granite-divider-bottom{border-bottom:.0625rem solid var(--granite-color-border-soft)}:host.granite-device-output-touch{line-height:3rem;font-size:var(--granite-font-size-body-small);text-align:center;padding:0 var(--granite-spacing-l)}:host.granite-device-output-touch.granite-title{padding:0;justify-content:center;line-height:1.5rem;font-size:var(--granite-font-size-micro)}:host.granite-device-output-touch.granite-menu-item-back-trigger,:host.granite-device-output-touch.granite-menu-item-submenu-trigger{padding:0 var(--granite-spacing-l)}:host.granite-device-output-touch.granite-menu-item-title{line-height:3rem;height:3rem;font-size:var(--granite-font-size-micro);color:var(--granite-color-text-weak)}@media (hover:none) and (pointer:coarse){:host.granite-device-output-touch.granite-menu-item-title:active{background:var(--granite-color-background-active-hover);color:var(--granite-color-text-on-active)}}:host-context([dir=ltr]) :host.granite-device-output-touch.granite-menu-item-back-trigger granite-icon,html[dir=ltr] :host.granite-device-output-touch.granite-menu-item-back-trigger granite-icon{left:var(--granite-spacing-xs)}:host-context([dir=rtl]) :host.granite-device-output-touch.granite-menu-item-back-trigger granite-icon,html[dir=rtl] :host.granite-device-output-touch.granite-menu-item-back-trigger granite-icon{right:var(--granite-spacing-xs)}[dir=ltr] :host.granite-device-output-touch.granite-menu-item-back-trigger granite-icon.caret-right,[dir=rtl] :host.granite-device-output-touch.granite-menu-item-back-trigger granite-icon.caret-left{display:none}:host:disabled:not(.granite-menu-item-title){opacity:.4;cursor:default}"]
930
- },] }
931
- ];
932
- GraniteMenuItemComponent.ctorParameters = function () { return [
933
- { type: core.ElementRef },
934
- { type: a11y.FocusMonitor },
935
- { type: undefined, decorators: [{ type: core.Inject, args: [GRANITE_MENU_PANEL,] }, { type: core.Optional }] }
936
- ]; };
937
- GraniteMenuItemComponent.propDecorators = {
938
- role: [{ type: core.Input }]
939
- };
940
-
941
- /**
942
- * Returns an ease-out CSS animation string with a slightly steeper curve
943
- * than usual.
944
- *
945
- * @param duration Duration in milliseconds
946
- * @param delay Delay in milliseconds
947
- */
948
- function getEaseOutSteep(duration, delay) {
949
- return (duration + "ms " +
950
- (delay !== undefined ? " " + delay + "ms " : '') +
951
- 'cubic-bezier(0, 0, 0.2, 1)');
952
- }
953
- /**
954
- * Returns an ease-out-back CSS animation string with a slightly steeper
955
- * curve than usual.
956
- *
957
- * @param duration Duration in milliseconds
958
- * @param delay Delay in milliseconds
959
- */
960
- function getEaseOutSteepBack(duration, delay) {
961
- return (duration + "ms " +
962
- (delay !== undefined ? " " + delay + "ms " : '') +
963
- 'cubic-bezier(.37,1.3,.77,1)');
964
- }
965
- /**
966
- * Returns a linear CSS animation string
967
- *
968
- * @param duration Duration in milliseconds
969
- * @param delay Delay in milliseconds
970
- */
971
- function getEaseLinear(duration, delay) {
972
- return (duration + "ms " + (delay !== undefined ? " " + delay + "ms " : '') + 'linear');
973
- }
974
-
975
- var easeOut120 = getEaseOutSteep(120);
976
- /**
977
- * Animations used by the `granite-menu` component, showing the desktop interface.
978
- * @docs-private
979
- */
980
- var graniteMenuDesktopAnimations = {
981
- transformMenuDesktop: animations.trigger('transformMenuDesktop', [
982
- animations.state('void', animations.style({
983
- opacity: 0,
984
- transform: 'scale(0.9)',
985
- })),
986
- animations.transition('void => enter', animations.group([
987
- animations.query('.granite-menu-content', animations.animate(getEaseLinear(100), animations.style({
988
- opacity: 1,
989
- }))),
990
- animations.animate(easeOut120, animations.style({ transform: 'scale(1)' })),
991
- ])),
992
- animations.transition('* => void', animations.animate(getEaseLinear(100, 25), animations.style({ opacity: 0 }))),
993
- ]),
994
- };
995
-
996
- var defaultDuration = 300;
997
- var defaultDelay = 200;
998
- var easeOut = getEaseOutSteep(defaultDuration);
999
- var linear = getEaseLinear(defaultDuration);
1000
- var linearDelayed = getEaseLinear(defaultDuration, defaultDelay);
1001
- /**
1002
- * Insanely fast travel somewhere on or off the stage,
1003
- * to set a great starting position.
1004
- *
1005
- * For some reason this has to be animated with > 0ms time.
1006
- * Setting style directly gets ignored.
1007
- */
1008
- var teleport = '1ms linear';
1009
- /**
1010
- * Style used by our menu stars to make grand entrée et sortie from/to below
1011
- * the viewport stage.
1012
- */
1013
- var inTheOrchestraPit = animations.style({
1014
- transform: 'translateX(0) translateY(100%)',
1015
- opacity: 0,
1016
- });
1017
- /** Style for a menu at the center of attention, on the viewport stage */
1018
- var onStage = animations.style({
1019
- opacity: 1,
1020
- transform: 'translateX(0) translateY(0)',
1021
- });
1022
- /**
1023
- * Style for a (sub) menu starting position at the side of the stage, waiting
1024
- * to make an entrance by sliding into view, pushing the previous (parent)
1025
- * menu off.
1026
- */
1027
- var awaitingCue = animations.style({
1028
- opacity: 0,
1029
- transform: 'translateX(100vw) translateY(0)',
1030
- });
1031
- /**
1032
- * Style for a (parent) menu that has been pushed aside by a debutant
1033
- * (sub) menu and therefore, although maybe temporarily, left the spotlight.
1034
- *
1035
- * @param translateY Where to place on Y axis
1036
- */
1037
- var retired = animations.style({
1038
- opacity: 1,
1039
- transform: "translateX(-100vw) translateY(0)",
1040
- });
1041
- /**
1042
- * Style for an active (sub) menu that dances across the stage, along with its
1043
- * parent menu, as a result of the user panning. Requires an `xOffset`
1044
- * parameter for the distance.
1045
- */
1046
- var futsalShuffle = animations.style({
1047
- transform: 'translateX({{ xOffset }}px)',
1048
- });
1049
- /**
1050
- * Style for a parent menu sweeping across the stage, right beside the
1051
- * starlet sub menu, either off the stage or back onto it (for a great comeback).
1052
- * Requires an `xOffset` parameter for the distance.
1053
- */
1054
- var moonwalk = animations.style({
1055
- transform: 'translateX(calc(-100vw + {{ xOffset }}px))',
1056
- });
1057
- var onStageHidden = animations.style({
1058
- opacity: 0,
1059
- transform: 'translateX(0) translateY(0)',
1060
- });
1061
- /**
1062
- * Animations used by the `granite-menu` component, showing the touch interface.
1063
- * @docs-private
1064
- */
1065
- var graniteMenuTouchAnimations = {
1066
- transformMenuTouch: animations.trigger('transformMenuTouch', [
1067
- // Set up cast positions
1068
- animations.state('void', awaitingCue),
1069
- animations.state('enter, enter-from-below', onStage),
1070
- animations.state('pan-hidden', moonwalk, { params: { xOffset: 0 } }),
1071
- animations.state('pan', futsalShuffle, { params: { xOffset: 0 } }),
1072
- animations.state('below-with-delay', inTheOrchestraPit),
1073
- animations.state('hide', retired),
1074
- // General movement across the stage. Transitions to 'pan' and 'pan-hidden'
1075
- // states are intentionally left out as we want the menu position to update
1076
- // instantly as the user moves their finger.
1077
- animations.transition('pan => enter, ' +
1078
- 'pan => enter-from-below, ' +
1079
- 'pan => void, ' +
1080
- 'enter <=> hide, ' +
1081
- 'enter-from-below <=> hide, ' +
1082
- 'pan-hidden => hide, ' +
1083
- 'pan-hidden => enter', animations.animate(easeOut)),
1084
- animations.transition(
1085
- // Jump straight onto the stage, from the orchestra pit.
1086
- // Excitement fills the air. Spotlight. Showtime.
1087
- 'void => enter-from-below', animations.sequence([
1088
- animations.animate(teleport, inTheOrchestraPit),
1089
- animations.animate(easeOut, onStage),
1090
- ])),
1091
- animations.transition(
1092
- // Go stand in the curtains, then make a grand entrance from the side
1093
- 'void => enter', animations.sequence([animations.animate(teleport, awaitingCue), animations.animate(easeOut, onStage)])),
1094
- animations.transition(
1095
- // Get off the stage, back into the curtains on the side
1096
- 'enter => void', animations.animate(easeOut, awaitingCue)),
1097
- animations.transition(
1098
- // Take the side stairs down from the stage
1099
- 'hide => below', animations.animate(linear, retired)),
1100
- animations.transition(
1101
- // Wait for a bit, then take the side stairs down from the stage
1102
- 'hide => below-with-delay', animations.sequence([animations.animate(teleport, retired), animations.animate(linearDelayed, retired)])),
1103
- animations.transition(
1104
- // Stage dive into the orchestra pit
1105
- 'enter => below, enter-from-below => below', animations.sequence([animations.animate(teleport, onStage), animations.animate(linear, inTheOrchestraPit)])),
1106
- animations.transition(
1107
- // Receive the standing ovations, then stage dive into the orchestra pit
1108
- 'enter => below-with-delay, enter-from-below => below-with-delay', animations.sequence([
1109
- animations.animate(teleport, onStage),
1110
- animations.animate(linearDelayed, inTheOrchestraPit),
1111
- ])),
1112
- ]),
1113
- transformCloseButton: animations.trigger('transformCloseButton', [
1114
- animations.state('void, below, below-with-delay', onStageHidden),
1115
- animations.state('enter, enter-from-below, pan-hidden, pan, hide', onStage),
1116
- animations.transition('void => enter-from-below', animations.sequence([
1117
- animations.animate(teleport, onStageHidden),
1118
- animations.animate(getEaseLinear(50, defaultDuration / 2), onStage),
1119
- ])),
1120
- animations.transition('enter => below, enter-from-below => below', animations.sequence([
1121
- animations.animate(teleport, onStage),
1122
- animations.animate(getEaseLinear(25), onStageHidden),
1123
- ])),
1124
- animations.transition('enter => below-with-delay, enter-from-below => below-with-delay', animations.sequence([
1125
- animations.animate(teleport, onStage),
1126
- animations.animate(getEaseLinear(50, defaultDelay), onStageHidden),
1127
- ])),
1128
- ]),
1129
- };
1130
-
1131
- /**
1132
- * @license
1133
- * Copyright Google LLC All Rights Reserved.
1134
- *
1135
- * Use of this source code is governed by an MIT-style license that can be
1136
- * found in the LICENSE file at https://angular.io/license
1137
- */
1138
- /**
1139
- * Throws an exception for the case when menu trigger doesn't have a valid granite-menu instance
1140
- * @docs-private
1141
- */
1142
- function throwGraniteMenuMissingError() {
1143
- throw Error("graniteMenuTriggerFor: must pass in an granite-menu instance.\n\n Example:\n <granite-menu #menu=\"graniteMenu\"></granite-menu>\n <button [graniteMenuTriggerFor]=\"menu\"></button>");
1144
- }
1145
- /**
1146
- * Throws an exception for the case when menu's x-position value isn't valid.
1147
- * In other words, it doesn't match 'before' or 'after'.
1148
- * @docs-private
1149
- */
1150
- function throwGraniteMenuInvalidPositionX() {
1151
- throw Error("xPosition value must be either 'before' or after'.\n Example: <granite-menu xPosition=\"before\" #menu=\"graniteMenu\"></granite-menu>");
1152
- }
1153
- /**
1154
- * Throws an exception for the case when menu's y-position value isn't valid.
1155
- * In other words, it doesn't match 'above' or 'below'.
1156
- * @docs-private
1157
- */
1158
- function throwGraniteMenuInvalidPositionY() {
1159
- throw Error("yPosition value must be either 'above' or below'.\n Example: <granite-menu yPosition=\"above\" #menu=\"graniteMenu\"></granite-menu>");
1160
- }
1161
-
1162
- /** Counter for panel ID generation */
1163
- var menuPanelUid = 0;
1164
- /** Menu panel animation default transform values */
1165
- var transformMenuDefault = {
1166
- value: 'void',
1167
- params: {
1168
- xOffset: 0,
1169
- },
1170
- };
1171
- /** Base class with all of the menu functionality. */
1172
- // eslint-disable-next-line @angular-eslint/directive-class-suffix
1173
- var _MenuBaseComponent = /** @class */ (function () {
1174
- function _MenuBaseComponent(_changeDetectorRef) {
1175
- this._changeDetectorRef = _changeDetectorRef;
1176
- this.openOnHover = true;
1177
- /**
1178
- * Event emitted when the menu is closed
1179
- */
1180
- this.closed = new core.EventEmitter();
1181
- /**
1182
- * Used for locating the panel in tests and setting the aria-control attribute
1183
- * for the menu trigger.
1184
- */
1185
- this.panelId = "granite-menu-panel-" + menuPanelUid++;
1186
- /** Whether to show back button in touch menu title bar */
1187
- this.showBackButton = false;
1188
- /** Whether to show touch menu title bar */
1189
- this.showTitle = false;
1190
- /** Whether to add a close button below the menu */
1191
- this.showCloseButton = false;
1192
- /** Observable current state of the panel animation. */
1193
- // eslint-disable-next-line rxjs/no-exposed-subjects
1194
- this._transformMenu = new rxjs.BehaviorSubject(transformMenuDefault);
1195
- /** Emits whenever an animation on the menu completes. */
1196
- // eslint-disable-next-line rxjs/no-exposed-subjects
1197
- this._animationDone = new rxjs.Subject();
1198
- this._menuEmpty$ = new rxjs.BehaviorSubject(false);
1199
- // eslint-disable-next-line @typescript-eslint/member-ordering
1200
- this._isMenuEmpty$ = rxjs.combineLatest([
1201
- this._menuEmpty$,
1202
- this._animationDone,
1203
- ]).pipe(operators.filter(function (_b) {
1204
- var _c = __read(_b, 2), m = _c[0], a = _c[1];
1205
- return m && a != null;
1206
- }), operators.map(function () { return true; }));
1207
- /** Only the direct descendant menu items. */
1208
- this._directDescendantItems = new core.QueryList();
1209
- /** Subscription to tab events on the menu panel */
1210
- this._tabSubscription = rxjs.Subscription.EMPTY;
1211
- this._xPosition = 'after';
1212
- this._yPosition = 'below';
1213
- /**
1214
- * Current horizontal offset. Used with `pan` and `pan-hidden`
1215
- * animation states.
1216
- */
1217
- this.xOffset = 0;
1218
- }
1219
- Object.defineProperty(_MenuBaseComponent.prototype, "xPosition", {
1220
- /** Position of the menu in the X axis. */
1221
- get: function () {
1222
- return this._xPosition;
1223
- },
1224
- set: function (value) {
1225
- if (value !== 'before' && value !== 'after') {
1226
- throwGraniteMenuInvalidPositionX();
1227
- }
1228
- this._xPosition = value;
1229
- },
1230
- enumerable: false,
1231
- configurable: true
1232
- });
1233
- Object.defineProperty(_MenuBaseComponent.prototype, "yPosition", {
1234
- /** Position of the menu in the Y axis. */
1235
- get: function () {
1236
- return this._yPosition;
1237
- },
1238
- set: function (value) {
1239
- if (value !== 'above' && value !== 'below') {
1240
- throwGraniteMenuInvalidPositionY();
1241
- }
1242
- this._yPosition = value;
1243
- },
1244
- enumerable: false,
1245
- configurable: true
1246
- });
1247
- Object.defineProperty(_MenuBaseComponent.prototype, "_panelAnimationState", {
1248
- /** Current state of the panel animation. */
1249
- set: function (state) {
1250
- this._transformMenu.next({
1251
- value: state,
1252
- params: { xOffset: this.xOffset },
1253
- });
1254
- },
1255
- enumerable: false,
1256
- configurable: true
1257
- });
1258
- _MenuBaseComponent.prototype.ngAfterContentChecked = function () {
1259
- this._menuEmpty$.next(this._allItems.length < 1 ? true : false);
1260
- };
1261
- _MenuBaseComponent.prototype.ngAfterContentInit = function () {
1262
- var _this = this;
1263
- this._updateDirectDescendants();
1264
- this._keyManager = new a11y.FocusKeyManager(this._directDescendantItems)
1265
- .withWrap()
1266
- .skipPredicate(function (menuItem) {
1267
- var hostElement = menuItem._getHostElement();
1268
- return hostElement instanceof HTMLButtonElement
1269
- ? hostElement.disabled
1270
- : hostElement.hasAttribute('graniteTitle');
1271
- });
1272
- this._tabSubscription = this._keyManager.tabOut.subscribe(function () {
1273
- _this.closed.emit('tab');
1274
- });
1275
- // If a user manually (programatically) focuses a menu item, we need to reflect that focus
1276
- // change back to the key manager. Note that we don't need to unsubscribe here because _focused
1277
- // is internal and we know that it gets completed on destroy.
1278
- this._directDescendantItems.changes
1279
- .pipe(operators.startWith(this._directDescendantItems), operators.switchMap(function (items) { return rxjs.merge.apply(void 0, __spread(items.map(function (item) { return item._focused; }))); }))
1280
- .subscribe(function (focusedItem) { return _this._keyManager.updateActiveItem(focusedItem); });
1281
- };
1282
- _MenuBaseComponent.prototype.ngOnDestroy = function () {
1283
- this._directDescendantItems.destroy();
1284
- this._tabSubscription.unsubscribe();
1285
- this.closed.complete();
1286
- };
1287
- /**
1288
- * Stream that combines the `_hovered` observables of all the menu's items
1289
- * into a single observable. Emits whenever the hovered menu item changes.
1290
- */
1291
- _MenuBaseComponent.prototype._hovered = function () {
1292
- var _this = this;
1293
- // Coerce the `changes` property because Angular types it as `Observable<any>`
1294
- var itemChanges = this._directDescendantItems.changes;
1295
- return itemChanges.pipe(operators.startWith(this._directDescendantItems),
1296
- // Hovering is not applicable when producing touch output
1297
- operators.filter(function () {
1298
- var _a;
1299
- return ((_a = _this._clientOutput) === null || _a === void 0 ? void 0 : _a.device) !== 'touch';
1300
- }), operators.switchMap(function (items) { return rxjs.merge.apply(void 0, __spread(items.map(function (item) { return item._hovered; }))); }));
1301
- };
1302
- /** Handle a keyboard event from the menu, delegating to the appropriate action. */
1303
- _MenuBaseComponent.prototype._handleKeydown = function (event) {
1304
- var key = event.key;
1305
- var manager = this._keyManager;
1306
- switch (key) {
1307
- case 'Escape':
1308
- if (!keycodes.hasModifierKey(event)) {
1309
- event.preventDefault();
1310
- this.closed.emit('keydown');
1311
- }
1312
- break;
1313
- case 'ArrowLeft':
1314
- if (this.parentMenu && this.direction === 'ltr') {
1315
- this.closed.emit('keydown');
1316
- }
1317
- break;
1318
- case 'ArrowRight':
1319
- if (this.parentMenu && this.direction === 'rtl') {
1320
- this.closed.emit('keydown');
1321
- }
1322
- break;
1323
- case 'Home':
1324
- case 'End':
1325
- if (!keycodes.hasModifierKey(event)) {
1326
- key === 'Home'
1327
- ? manager.setFirstItemActive()
1328
- : manager.setLastItemActive();
1329
- event.preventDefault();
1330
- }
1331
- break;
1332
- default:
1333
- if (key === 'ArrowUp' || key === 'ArrowDown') {
1334
- manager.setFocusOrigin('keyboard');
1335
- }
1336
- manager.onKeydown(event);
1337
- }
1338
- };
1339
- /**
1340
- * Focus the first item in the menu.
1341
- * @param origin Action from which the focus originated. Used to set the correct styling.
1342
- */
1343
- _MenuBaseComponent.prototype.focusFirstItem = function (origin) {
1344
- if (origin === void 0) { origin = 'program'; }
1345
- this._keyManager.setFocusOrigin(origin).setFirstItemActive();
1346
- };
1347
- /** Updates the `showTitle` property for touch device UI */
1348
- _MenuBaseComponent.prototype._updateShowTitle = function () {
1349
- this.showTitle = !!this.title || this.showBackButton;
1350
- };
1351
- /** Starts the enter animation */
1352
- _MenuBaseComponent.prototype._startAnimation = function () {
1353
- this._panelAnimationState = 'enter';
1354
- };
1355
- /** Resets the panel animation to its initial state. */
1356
- _MenuBaseComponent.prototype._resetAnimation = function () {
1357
- this._panelAnimationState = 'void';
1358
- };
1359
- /**
1360
- * Starts the 'below' animation, moving a menu down, out of view below the
1361
- * viewport. Used to close the whole menu, for example when clicking
1362
- * the backdrop.
1363
- */
1364
- _MenuBaseComponent.prototype._startTouchCloseDownAnimation = function () {
1365
- this._panelAnimationState = 'below';
1366
- };
1367
- /**
1368
- * Starts the 'below-with-delay' animation, moving a menu down, out of view below the
1369
- * viewport. Used to close the whole menu as a response to the user tapping
1370
- * a menu item. There is a short delay before the animation starts, to that
1371
- * the user gets a visual feedback on what item was selected.
1372
- */
1373
- _MenuBaseComponent.prototype._startTouchCloseDownAnimationWithDelay = function () {
1374
- this._panelAnimationState = 'below-with-delay';
1375
- };
1376
- /**
1377
- * Starts the 'void' animation, moving a (sub) menu out of view to the side
1378
- * of the viewport. Used when going "back" from a sub menu.
1379
- */
1380
- _MenuBaseComponent.prototype._startTouchCloseSideAnimation = function () {
1381
- this._resetAnimation();
1382
- };
1383
- /**
1384
- * Starts the enter-from-below animation, moving a (root) menu into view,
1385
- * Animates upwards from a starting position below the viewport.
1386
- */
1387
- _MenuBaseComponent.prototype._startTouchRootEnterAnimation = function () {
1388
- this._panelAnimationState = 'enter-from-below';
1389
- this.xOffset = 0;
1390
- };
1391
- /** Starts the enter animation, moving a (sub) menu into view. */
1392
- _MenuBaseComponent.prototype._startTouchSubmenuEnterAnimation = function () {
1393
- this._panelAnimationState = 'enter';
1394
- this.xOffset = 0;
1395
- };
1396
- /**
1397
- * Starts the pan animation, to position a submenu in a response
1398
- * to user dragging sideways (panning).
1399
- */
1400
- _MenuBaseComponent.prototype._startTouchPanAnimation = function (xOffset) {
1401
- this._panelAnimationState = 'pan';
1402
- this.xOffset = xOffset;
1403
- };
1404
- /**
1405
- * Starts the pan-hidden animation, to position a parent menu next to an
1406
- * active submenu that the user is dragging sideways (panning).
1407
- */
1408
- _MenuBaseComponent.prototype._startTouchHidePanAnimation = function (xOffset) {
1409
- this._panelAnimationState = 'pan-hidden';
1410
- this.xOffset = xOffset;
1411
- };
1412
- /**
1413
- * Starts the hide animation, to make a parent menu slide out to leave
1414
- * space for a submenu.
1415
- */
1416
- _MenuBaseComponent.prototype._startTouchHideAnimation = function () {
1417
- this._panelAnimationState = 'hide';
1418
- this.xOffset = 0;
1419
- };
1420
- /** Callback that is invoked when the panel animation completes. */
1421
- _MenuBaseComponent.prototype._onAnimationDone = function (event) {
1422
- this._animationDone.next(event);
1423
- this._isAnimating = false;
1424
- };
1425
- _MenuBaseComponent.prototype._onAnimationStart = function (event) {
1426
- this._isAnimating = true;
1427
- // Scroll the content element to the top as soon as the animation starts. This is necessary,
1428
- // because we move focus to the first item while it's still being animated, which can throw
1429
- // the browser off when it determines the scroll position. Alternatively we can move focus
1430
- // when the animation is done, however moving focus asynchronously will interrupt screen
1431
- // readers which are in the process of reading out the menu already. We take the `element`
1432
- // from the `event` since we can't use a `ViewChild` to access the pane.
1433
- if ((event.toState === 'enter' || event.toState === 'enter-from-below') &&
1434
- this._keyManager.activeItemIndex === 0) {
1435
- event.element.scrollTop = 0;
1436
- }
1437
- };
1438
- /**
1439
- * Handle click on the menu by emitting on the `closed` emitter
1440
- * with a `click` reason
1441
- */
1442
- _MenuBaseComponent.prototype._handleClick = function () {
1443
- this.closed.emit('click');
1444
- };
1445
- /**
1446
- * Handle click on the close button by emitting on the `closed` emitter
1447
- * without any particular reason
1448
- */
1449
- _MenuBaseComponent.prototype._handleCloseClick = function () {
1450
- this.closed.emit();
1451
- };
1452
- /**
1453
- * Handle click on the back icon by emitting on the `clicked` emitter
1454
- */
1455
- _MenuBaseComponent.prototype._handleBackClick = function (e) {
1456
- if (this.showBackButton) {
1457
- // Close submenu keydown-style: close only this menu and leave parents open
1458
- this.closed.emit('keydown');
1459
- }
1460
- e.stopPropagation();
1461
- };
1462
- /**
1463
- * Update client device information for the menu and its menu items.
1464
- */
1465
- _MenuBaseComponent.prototype._setDevice = function (clientInput, clientOutput) {
1466
- this._clientInput = clientInput;
1467
- this._clientOutput = clientOutput;
1468
- this._directDescendantItems.forEach(function (item) {
1469
- item._clientInput = clientInput;
1470
- item._clientOutput = clientOutput;
1471
- });
1472
- this._changeDetectorRef.markForCheck();
1473
- };
1474
- /**
1475
- * Resets the active item in the menu. This is used when the menu is opened, allowing
1476
- * the user to start from the first option when pressing the down arrow.
1477
- */
1478
- _MenuBaseComponent.prototype.resetActiveItem = function () {
1479
- this._keyManager.setActiveItem(-1);
1480
- };
1481
- /**
1482
- * Sets up a stream that will keep track of any newly-added menu items and will update the list
1483
- * of direct descendants. We collect the descendants this way, because `_allItems` can include
1484
- * items that are part of child menus, and using a custom way of registering items is unreliable
1485
- * when it comes to maintaining the item order.
1486
- */
1487
- _MenuBaseComponent.prototype._updateDirectDescendants = function () {
1488
- var _this = this;
1489
- this._allItems.changes
1490
- .pipe(operators.startWith(this._allItems))
1491
- .subscribe(function (items) {
1492
- _this._directDescendantItems.reset(items.filter(function (item) { return item._parentMenu === _this; }));
1493
- _this._directDescendantItems.notifyOnChanges();
1494
- });
1495
- };
1496
- return _MenuBaseComponent;
1497
- }());
1498
- _MenuBaseComponent.decorators = [
1499
- { type: core.Directive }
1500
- ];
1501
- _MenuBaseComponent.ctorParameters = function () { return [
1502
- { type: core.ChangeDetectorRef }
1503
- ]; };
1504
- _MenuBaseComponent.propDecorators = {
1505
- xPosition: [{ type: core.Input }],
1506
- yPosition: [{ type: core.Input }],
1507
- title: [{ type: core.Input }],
1508
- closeLabel: [{ type: core.Input }],
1509
- openOnHover: [{ type: core.Input }],
1510
- templateRef: [{ type: core.ViewChild, args: [core.TemplateRef,] }],
1511
- _allItems: [{ type: core.ContentChildren, args: [GraniteMenuItemComponent, { descendants: true },] }],
1512
- closed: [{ type: core.Output }]
1513
- };
1514
- var GraniteMenuComponent = /** @class */ (function (_super) {
1515
- __extends(GraniteMenuComponent, _super);
1516
- function GraniteMenuComponent() {
1517
- return _super !== null && _super.apply(this, arguments) || this;
1518
- }
1519
- return GraniteMenuComponent;
1520
- }(_MenuBaseComponent));
1521
- GraniteMenuComponent.decorators = [
1522
- { type: core.Component, args: [{
1523
- selector: 'granite-menu',
1524
- template: "<!--\n Using separate template part for desktop and touch output, because of\n animation triggers and slightly different content.\n-->\n<ng-template>\n <!-- Desktop -->\n <ng-container *ngIf=\"_clientOutput.device === 'desktop'\">\n <div\n #menu\n class=\"granite-menu\"\n [class.is-menu-empty]=\"_isMenuEmpty$ | async\"\n tabindex=\"-1\"\n [id]=\"panelId\"\n [@transformMenuDesktop]=\"_transformMenu | async\"\n (@transformMenuDesktop.start)=\"_onAnimationStart($event)\"\n (@transformMenuDesktop.done)=\"_onAnimationDone($event)\"\n (click)=\"_handleClick()\"\n (keydown)=\"_handleKeydown($event)\"\n >\n <div class=\"granite-menu-content\">\n <ng-container [ngTemplateOutlet]=\"content\"></ng-container>\n </div>\n </div>\n </ng-container>\n\n <!-- Touch -->\n <ng-container *ngIf=\"_clientOutput?.device === 'touch'\">\n <div\n #menu\n class=\"granite-menu granite-device-output-touch\"\n tabindex=\"-1\"\n [id]=\"panelId\"\n [@transformMenuTouch]=\"_transformMenu | async\"\n (@transformMenuTouch.start)=\"_onAnimationStart($event)\"\n (@transformMenuTouch.done)=\"_onAnimationDone($event)\"\n (click)=\"_handleClick()\"\n (keydown)=\"_handleKeydown($event)\"\n >\n <div class=\"granite-menu-content\">\n <div *ngIf=\"showTitle\" class=\"header-container\">\n <button\n [disabled]=\"!showBackButton\"\n graniteMenuTouchTitleItem\n (click)=\"_handleBackClick($event)\"\n >\n {{ title }}\n </button>\n </div>\n\n <ng-container [ngTemplateOutlet]=\"content\"></ng-container>\n\n <div class=\"footer-container\"></div>\n </div>\n </div>\n\n <!-- Close button -->\n <div class=\"close\" [@transformCloseButton]=\"_transformMenu | async\">\n <button\n *ngIf=\"showCloseButton\"\n graniteMenuTouchCloseItem\n (click)=\"_handleCloseClick()\"\n >\n {{ closeLabel }}\n </button>\n </div>\n </ng-container>\n\n <!--\n Content template shared between desktop and touch parts, as <ng-content>\n can't be used in two places in the same template\n -->\n <ng-template #content>\n <ng-content></ng-content>\n </ng-template>\n</ng-template>\n",
1525
- changeDetection: core.ChangeDetectionStrategy.OnPush,
1526
- exportAs: 'graniteMenu',
1527
- animations: [
1528
- graniteMenuDesktopAnimations.transformMenuDesktop,
1529
- graniteMenuTouchAnimations.transformMenuTouch,
1530
- graniteMenuTouchAnimations.transformCloseButton,
1531
- ],
1532
- providers: [
1533
- { provide: GRANITE_MENU_PANEL, useExisting: GraniteMenuComponent },
1534
- ],
1535
- styles: [".granite-menu:not(.granite-device-output-touch){background-color:var(--granite-color-background-variant);color:var(--granite-color-text);overflow:auto;-webkit-overflow-scrolling:touch;max-height:calc(100vh - 2rem);outline:0;-webkit-user-select:none;-moz-user-select:none;user-select:none;filter:drop-shadow(var(--granite-shadow-l));min-width:7rem;overflow-x:hidden;overflow-y:hidden}.granite-menu:not(.granite-device-output-touch).ng-animating{pointer-events:none}.granite-menu:not(.granite-device-output-touch):not(.is-menu-empty){min-height:2rem}.granite-menu:not(.granite-device-output-touch):hover{overflow-y:auto}.granite-menu:not(.granite-device-output-touch)::-webkit-scrollbar{width:var(--granite-spacing-xs)}.granite-menu:not(.granite-device-output-touch)::-webkit-scrollbar-thumb{background-color:var(--granite-color-border-hard);border-radius:calc(var(--granite-spacing-m) * .125)}.granite-menu:not(.granite-device-output-touch)::-webkit-scrollbar-track{background-color:var(--granite-color-background-hover)}.granite-menu.granite-device-output-touch{background-color:var(--granite-color-background-variant);color:var(--granite-color-text);overflow:auto;-webkit-overflow-scrolling:touch;max-height:calc(100vh - 2rem);outline:0;-webkit-user-select:none;-moz-user-select:none;user-select:none;filter:drop-shadow(var(--granite-shadow-l));border-radius:.25rem;max-height:calc(100% - ($granite-base-rem * 7))}.granite-menu.granite-device-output-touch.ng-animating{pointer-events:none}.granite-menu.granite-device-output-touch:not(.is-menu-empty){min-height:3rem}.granite-menu.granite-device-output-touch:not(.close){margin:var(--granite-spacing-xs)}.granite-menu.granite-device-output-touch.close{-webkit-margin-start:var(--granite-spacing-xs);margin-inline-start:var(--granite-spacing-xs);-webkit-margin-end:var(--granite-spacing-xs);margin-inline-end:var(--granite-spacing-xs);-webkit-margin-after:var(--granite-spacing-xs);margin-block-end:var(--granite-spacing-xs)}.granite-menu.granite-device-output-touch .header-container{position:-webkit-sticky;position:sticky;top:0;background-color:var(--granite-color-background-variant);z-index:1}.granite-menu.granite-device-output-touch .footer-container{position:-webkit-sticky;position:sticky;bottom:0;height:0}.close:not(:empty){background-color:var(--granite-color-background-variant);color:var(--granite-color-text);overflow:auto;-webkit-overflow-scrolling:touch;max-height:calc(100vh - 2rem);outline:0;-webkit-user-select:none;-moz-user-select:none;user-select:none;filter:drop-shadow(var(--granite-shadow-l));border-radius:.25rem}.close:not(:empty).ng-animating{pointer-events:none}.close:not(:empty):not(.is-menu-empty){min-height:3rem}.close:not(:empty):not(.close){margin:var(--granite-spacing-xs)}.close:not(:empty).close{-webkit-margin-start:var(--granite-spacing-xs);margin-inline-start:var(--granite-spacing-xs);-webkit-margin-end:var(--granite-spacing-xs);margin-inline-end:var(--granite-spacing-xs);-webkit-margin-after:var(--granite-spacing-xs);margin-block-end:var(--granite-spacing-xs)}"]
1536
- },] }
1537
- ];
1538
-
1539
- /**
1540
- * Injection token used to provide components knowledge of what device types
1541
- * are being used for input.
1542
- */
1543
- var GRANITE_CLIENT_INPUT = new core.InjectionToken('GRANITE_CLIENT_INPUT');
1544
- /**
1545
- * Injection token used to provide components knowledge of what device type
1546
- * is being used for output.
1547
- */
1548
- var GRANITE_CLIENT_OUTPUT = new core.InjectionToken('GRANITE_CLIENT_OUTPUT');
1549
- var deviceDesktop = {
1550
- input: { devices: ['mouse', 'keyboard'] },
1551
- output: { device: 'desktop' },
1552
- };
1553
- var deviceTouch = {
1554
- input: { devices: ['touch', 'onscreen-keyboard'] },
1555
- output: { device: 'touch' },
1556
- };
1557
-
1558
- /** Options for binding a passive event listener. */
1559
- var passiveEventListenerOptions = platform.normalizePassiveListenerOptions({
1560
- passive: true,
1561
- });
1562
- //#endregion --- Touch device customizations ---
1563
- /**
1564
- * Directive used to turn a button element into a (popup) menu trigger
1565
- *
1566
- * Stripped-down version of Angular Material's menu trigger directive (.../menu/menu-trigger.ts)
1567
- */
1568
- var GraniteMenuTriggerForDirective = /** @class */ (function () {
1569
- function GraniteMenuTriggerForDirective(_overlay, _element, _viewContainerRef,
1570
- /** If this is a _submenu_ trigger, it will have a parent menu */
1571
- _parentMenu,
1572
- //#region --- Touch device customizations ---
1573
- /** Client input device information */
1574
- _clientInput,
1575
- /** Client output device information */
1576
- _clientOutput,
1577
- //#endregion --- Touch device customizations ---
1578
- /**
1579
- * If this is a _submenu_ trigger, there should be a corresponding menu
1580
- * item directive present as well:
1581
- *
1582
- * <button graniteMenuItem [graniteMenuTriggerFor]="...">
1583
- * ^-- This one
1584
- */
1585
- _menuItemInstance, _dir, _focusMonitor,
1586
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
1587
- document) {
1588
- var _this = this;
1589
- this._overlay = _overlay;
1590
- this._element = _element;
1591
- this._viewContainerRef = _viewContainerRef;
1592
- this._parentMenu = _parentMenu;
1593
- this._clientInput = _clientInput;
1594
- this._clientOutput = _clientOutput;
1595
- this._menuItemInstance = _menuItemInstance;
1596
- this._dir = _dir;
1597
- this._focusMonitor = _focusMonitor;
1598
- /** Whether the associated menu is open */
1599
- this._isMenuOpen = false;
1600
- // Tracking input type is necessary so it's possible to only auto-focus
1601
- // the first item of the list when the menu is opened via the keyboard
1602
- this._openedBy = null;
1603
- this._hoverSubscription = rxjs.Subscription.EMPTY;
1604
- this._menuCloseSubscription = rxjs.Subscription.EMPTY;
1605
- this._closingActionsSubscription = rxjs.Subscription.EMPTY;
1606
- this._portal = null;
1607
- this._overlayRef = null;
1608
- this._touchTouchingElement = false;
1609
- /**
1610
- * Handles touch start events on the trigger.
1611
- * Needs to be an arrow function so we can easily use addEventListener and removeEventListener.
1612
- */
1613
- this._handleTouchStart = function () {
1614
- _this._openedBy = 'touch';
1615
- };
1616
- // ----------------------------------------- //
1617
- // --- Here be poor man's touch gestures --- //
1618
- // ----------------------------------------- //
1619
- // TODO: Replace with Hammer or other gesture library
1620
- /**
1621
- * Handles touch start events on the overlay host element (wrapper).
1622
- * Needs to be an arrow function so we can easily use addEventListener and removeEventListener.
1623
- */
1624
- this._handleOverlayTouchStart = function (event) {
1625
- if (_this.menu._isAnimating) {
1626
- return;
1627
- }
1628
- _this._touchStartTime = new Date().getTime();
1629
- _this._touchStartX = event.changedTouches[0].clientX;
1630
- _this._touchStartY = event.changedTouches[0].clientY;
1631
- _this._touchCurrentX = _this._touchStartX;
1632
- _this._touchCurrentY = _this._touchStartY;
1633
- _this._touchTranslateX = 0;
1634
- _this._touchMaxX = _this._overlayRef.hostElement.getBoundingClientRect().width;
1635
- _this._touchLockedX = null;
1636
- _this._touchTouchingElement = true;
1637
- };
1638
- this._handleOverlayTouchMove = function (event) {
1639
- if (!_this._touchTouchingElement || _this.menu._isAnimating) {
1640
- return;
1641
- }
1642
- if (_this._touchLockedX) {
1643
- return;
1644
- }
1645
- _this._touchCurrentX = event.changedTouches[0].clientX;
1646
- _this._touchCurrentY = event.changedTouches[0].clientY;
1647
- // Lock X-axis pan if initiating pan on Y-axis
1648
- if (_this._touchLockedX === null) {
1649
- var dy = Math.abs(_this._touchCurrentY - _this._touchStartY);
1650
- var dx = Math.abs(_this._touchCurrentX - _this._touchStartX);
1651
- if (dx > 10 || dy > 10) {
1652
- _this._touchLockedX = dy > dx;
1653
- return;
1654
- }
1655
- }
1656
- // Restrict to right pan/swipe and make menu movement extremely slow when
1657
- // moved past allowed limits.
1658
- var menuMargin = 16;
1659
- _this._touchTranslateX = _this._touchCurrentX - _this._touchStartX;
1660
- if (_this._touchTranslateX < 0) {
1661
- _this._touchTranslateX = _this.easeOutExpo(_this._touchTranslateX, 0, -menuMargin / 2, _this._touchMaxX * -4);
1662
- }
1663
- else if (!_this._parentMenu) {
1664
- _this._touchTranslateX = _this.easeOutExpo(_this._touchTranslateX, 0, menuMargin / 2, _this._touchMaxX * 4);
1665
- }
1666
- else if (_this._touchTranslateX > _this._touchMaxX) {
1667
- _this._touchTranslateX = _this.easeOutExpo(_this._touchTranslateX - _this._touchMaxX, _this._touchMaxX, menuMargin / 2, _this._touchMaxX * 4);
1668
- }
1669
- // Set new sub menu position and tell any parent to follow;
1670
- _this.animateSetMenuPosition(_this._touchTranslateX);
1671
- };
1672
- this._handleOverlayTouchEnd = function () {
1673
- if (!_this._touchTouchingElement || _this.menu._isAnimating) {
1674
- return;
1675
- }
1676
- _this._touchTranslateX = _this._touchCurrentX - _this._touchStartX;
1677
- if (_this._touchTranslateX === 0) {
1678
- return;
1679
- }
1680
- _this._touchTouchingElement = false;
1681
- _this._touchTimeTaken = new Date().getTime() - _this._touchStartTime;
1682
- var swipeMinDistance = 10;
1683
- var swipeMinTime = 50;
1684
- var swipeMaxTime = 300;
1685
- var pannedHalfwayRight = _this._touchTranslateX > _this._touchMaxX / 2;
1686
- var swipedRight = _this._touchTranslateX > _this._touchMaxX / swipeMinDistance &&
1687
- _this._touchTimeTaken > swipeMinTime &&
1688
- _this._touchTimeTaken < swipeMaxTime;
1689
- if (!!_this._parentMenu && (swipedRight || pannedHalfwayRight)) {
1690
- // Close submenu keydown-style: close only this menu and leave parents open
1691
- _this.menu.closed.emit('keydown');
1692
- }
1693
- else {
1694
- // Pan ended but the menu was not moved far enough. Reset menus to
1695
- // where they were before panning stared.
1696
- _this.animateOpenMenu();
1697
- }
1698
- };
1699
- _element.nativeElement.addEventListener('touchstart', this._handleTouchStart, passiveEventListenerOptions);
1700
- if (_menuItemInstance) {
1701
- _menuItemInstance._triggersSubmenu = this.triggersSubmenu();
1702
- }
1703
- this._document = document;
1704
- }
1705
- GraniteMenuTriggerForDirective.prototype.ngOnChanges = function (changes) {
1706
- if (changes.menu) {
1707
- this._handleMenuChange();
1708
- }
1709
- };
1710
- GraniteMenuTriggerForDirective.prototype.ngAfterContentInit = function () {
1711
- // removed checkMenu here to avoid errors in dynamically genarated menus
1712
- // menu is checked when opening the menu
1713
- // this._checkMenu();
1714
- this._handleHover();
1715
- };
1716
- GraniteMenuTriggerForDirective.prototype.ngOnDestroy = function () {
1717
- if (this._overlayRef) {
1718
- //#region --- Touch device customizations ---
1719
- this.removeOverlayListeners();
1720
- //#endregion --- Touch device customizations ---
1721
- this._overlayRef.dispose();
1722
- this._overlayRef = null;
1723
- }
1724
- this._element.nativeElement.removeEventListener('touchstart', this._handleTouchStart, passiveEventListenerOptions);
1725
- this._hoverSubscription.unsubscribe();
1726
- this._menuCloseSubscription.unsubscribe();
1727
- this._closingActionsSubscription.unsubscribe();
1728
- };
1729
- /** Handles change of associated menu */
1730
- GraniteMenuTriggerForDirective.prototype._handleMenuChange = function () {
1731
- var _this = this;
1732
- this._menuCloseSubscription.unsubscribe();
1733
- // Close the menu overlay when the menu itself says it wants to be closed
1734
- if (this.menu) {
1735
- var closed = this.menu.closed;
1736
- this._menuCloseSubscription = closed.subscribe(function (reason) {
1737
- //#region --- Touch device customizations ---
1738
- if (_this.menu._isClosing) {
1739
- return;
1740
- }
1741
- _this.menu._isClosing = true;
1742
- // Get rid of the menu and tell any parent to restore its position
1743
- if (_this._clientOutput.device === 'touch') {
1744
- // First we wait for any running animation to complete
1745
- var runningAnimationDone = _this.menu._isAnimating
1746
- ? _this.menu._animationDone
1747
- : rxjs.of([null]);
1748
- runningAnimationDone
1749
- .pipe(operators.take(1), operators.delay(0, rxjs.asapScheduler))
1750
- // eslint-disable-next-line rxjs/no-nested-subscribe
1751
- .subscribe(function () {
1752
- _this.animateCloseMenu(reason !== 'keydown', reason === 'click');
1753
- _this.menu._animationDone
1754
- .pipe(operators.take(1), operators.delay(0, rxjs.asapScheduler))
1755
- // eslint-disable-next-line rxjs/no-nested-subscribe
1756
- .subscribe(function () { return _this._destroyMenu(); });
1757
- });
1758
- }
1759
- else {
1760
- //#endregion --- Touch device customizations ---
1761
- _this._destroyMenu();
1762
- }
1763
- // If a click closed the menu, we should close the entire chain of nested menus.
1764
- if ((reason === 'click' || reason === 'tab') && _this._parentMenu) {
1765
- _this._parentMenu.closed.emit(reason);
1766
- }
1767
- });
1768
- }
1769
- };
1770
- GraniteMenuTriggerForDirective.prototype.isOpen = function () {
1771
- return this._isMenuOpen;
1772
- };
1773
- /** Open the associated menu */
1774
- GraniteMenuTriggerForDirective.prototype.openMenu = function () {
1775
- var _this = this;
1776
- var _a;
1777
- if (this._isMenuOpen) {
1778
- return;
1779
- }
1780
- this._checkMenu();
1781
- this.menu.parentMenu = this.triggersSubmenu()
1782
- ? this._parentMenu
1783
- : undefined;
1784
- this.menu.direction = this._dir.value === 'rtl' ? 'rtl' : 'ltr';
1785
- if (this._parentMenu) {
1786
- // Menu triggers inherit target device types from their parent.
1787
- // Ultimately it is the root trigger that determines device types for
1788
- // the whole menu hierarchy.
1789
- this._clientInput = this._parentMenu._clientInput;
1790
- this._clientOutput = this._parentMenu._clientOutput;
1791
- }
1792
- //#region --- Touch device customizations ---
1793
- // Make the menu we're about to open use the same devices as the trigger
1794
- this.menu._setDevice(this._clientInput, this._clientOutput);
1795
- if (this._clientOutput.device === 'touch') {
1796
- this.menu.showBackButton = !!this._parentMenu;
1797
- this.menu._updateShowTitle();
1798
- if (!this.menu.closeLabel) {
1799
- this.menu.closeLabel = (_a = this._parentMenu) === null || _a === void 0 ? void 0 : _a.closeLabel;
1800
- }
1801
- this.menu.showCloseButton = !!this.menu.closeLabel;
1802
- }
1803
- this.menu._isClosing = false;
1804
- var panelClass = [];
1805
- if (this._clientOutput.device === 'touch') {
1806
- panelClass.push('granite-overlay-pane-fill-width-bottom');
1807
- }
1808
- var scrollStrategy = this._clientOutput.device !== 'touch'
1809
- ? this._overlay.scrollStrategies.reposition()
1810
- : undefined;
1811
- var hasBackdrop = this._clientOutput.device === 'touch' && !this.triggersSubmenu();
1812
- //#endregion --- Touch device customizations ---
1813
- // Create an overlay to stuff the menu (portal) into below
1814
- if (!this._overlayRef) {
1815
- var config = new overlay.OverlayConfig({
1816
- positionStrategy: this._positionStrategy(),
1817
- backdropClass: 'granite-overlay-dark-glass-backdrop',
1818
- scrollStrategy: scrollStrategy,
1819
- direction: this._dir,
1820
- panelClass: panelClass,
1821
- hasBackdrop: hasBackdrop,
1822
- });
1823
- this._overlayRef = this._overlay.create(config);
1824
- //#region --- Touch device customizations ---
1825
- // Add touch listener for submenu back pan/swipe
1826
- if (this._clientOutput.device === 'touch') {
1827
- this.addOverlayListeners();
1828
- }
1829
- //#endregion --- Touch device customizations ---
1830
- }
1831
- else {
1832
- // Reset animation state for reused overlays
1833
- if (this._clientOutput.device === 'touch') {
1834
- this.menu._panelAnimationState = 'void';
1835
- }
1836
- }
1837
- // Create portal from associated menu's template
1838
- if (!this._portal || this._portal.templateRef !== this.menu.templateRef) {
1839
- this._portal = new portal.TemplatePortal(this.menu.templateRef, this._viewContainerRef);
1840
- }
1841
- // Attach menu portal to overlay ref (which is a portal outlet)
1842
- this._overlayRef.attach(this._portal);
1843
- // Subscribe to stream that emits whenever an action that should close the menu occurs
1844
- this._closingActionsSubscription = this._menuClosingActions().subscribe(function () { return _this.closeMenu(); });
1845
- this.animateOpenMenu();
1846
- this._setIsMenuOpen(true);
1847
- this.menu.focusFirstItem(this._openedBy || 'program');
1848
- };
1849
- /** Whether the menu triggers a sub-menu or a top-level one. */
1850
- GraniteMenuTriggerForDirective.prototype.triggersSubmenu = function () {
1851
- return !!(this._menuItemInstance && this._parentMenu);
1852
- };
1853
- /** Toggles the menu between the open and closed states. */
1854
- GraniteMenuTriggerForDirective.prototype.toggleMenu = function () {
1855
- if (this._isMenuOpen) {
1856
- this.closeMenu();
1857
- }
1858
- else {
1859
- this.openMenu();
1860
- }
1861
- };
1862
- /** Close the associated menu */
1863
- GraniteMenuTriggerForDirective.prototype.closeMenu = function () {
1864
- this.menu.closed.emit();
1865
- };
1866
- /**
1867
- * Focuses the menu trigger.
1868
- * @param origin Source of the menu trigger's focus.
1869
- */
1870
- GraniteMenuTriggerForDirective.prototype.focus = function (origin, options) {
1871
- if (origin === void 0) { origin = 'program'; }
1872
- if (this._focusMonitor) {
1873
- this._focusMonitor.focusVia(this._element, origin, options);
1874
- }
1875
- else {
1876
- this._element.nativeElement.focus(options);
1877
- }
1878
- };
1879
- /** Detach menu portal from overlay and update open state */
1880
- GraniteMenuTriggerForDirective.prototype._destroyMenu = function () {
1881
- if (!this._overlayRef || !this._isMenuOpen) {
1882
- return;
1883
- }
1884
- this._closingActionsSubscription.unsubscribe();
1885
- this._overlayRef.detach();
1886
- this._restoreFocus();
1887
- this.menu._resetAnimation();
1888
- this._setIsMenuOpen(false);
1889
- };
1890
- /** Handles mouse presses on the trigger. */
1891
- GraniteMenuTriggerForDirective.prototype._handleMousedown = function (event) {
1892
- if (!a11y.isFakeMousedownFromScreenReader(event)) {
1893
- if (this._openedBy !== 'touch') {
1894
- // Since right or middle button clicks won't trigger the `click` event,
1895
- // we shouldn't consider the menu as opened by mouse in those cases.
1896
- this._openedBy = event.button === 0 ? 'mouse' : null;
1897
- }
1898
- // Since clicking on the trigger won't close the menu if it opens a sub-menu,
1899
- // we should prevent focus from moving onto it via click to avoid the
1900
- // highlight from lingering on the menu item.
1901
- if (this.triggersSubmenu() && !this._toggleOnSubmenuClick()) {
1902
- event.preventDefault();
1903
- }
1904
- }
1905
- };
1906
- /** Handles key presses on the trigger. */
1907
- GraniteMenuTriggerForDirective.prototype._handleKeydown = function (event) {
1908
- var key = event.key;
1909
- if (this.triggersSubmenu() &&
1910
- ((key === 'ArrowRight' && this._dir.value === 'ltr') ||
1911
- (key === 'ArrowLeft' && this._dir.value === 'rtl'))) {
1912
- this.openMenu();
1913
- }
1914
- };
1915
- /** Handles click events on the trigger. */
1916
- GraniteMenuTriggerForDirective.prototype._handleClick = function (event) {
1917
- if (this.triggersSubmenu()) {
1918
- // Stop event propagation to avoid closing the parent menu.
1919
- event.stopPropagation();
1920
- this._toggleOnSubmenuClick() ? this.toggleMenu() : this.openMenu();
1921
- }
1922
- else {
1923
- this.toggleMenu();
1924
- }
1925
- };
1926
- /** Handles the cases where the user hovers over the trigger. */
1927
- GraniteMenuTriggerForDirective.prototype._handleHover = function () {
1928
- var _this = this;
1929
- // Subscribe to changes in the hovered item in order to toggle the panel.
1930
- if (!this.triggersSubmenu() || !this._parentMenu) {
1931
- return;
1932
- }
1933
- this._hoverSubscription = this._parentMenu
1934
- ._hovered()
1935
- .pipe(operators.filter(function () { return _this._openOnHover(); }),
1936
- // Since we might have multiple competing triggers for the same menu (e.g. a sub-menu
1937
- // with different data and triggers), we have to delay it by a tick to ensure that
1938
- // it won't be closed immediately after it is opened.
1939
- operators.filter(function (active) { return active === _this._menuItemInstance; } /*&& !active.disabled*/), operators.delay(0, rxjs.asapScheduler))
1940
- .subscribe(function () {
1941
- _this._openedBy = 'mouse';
1942
- // If the same menu is used between multiple triggers, it might still be animating
1943
- // while the new trigger tries to re-open it. Wait for the animation to finish
1944
- // before doing so. Also interrupt if the user moves to another item.
1945
- if (_this.menu instanceof _MenuBaseComponent && _this.menu._isAnimating) {
1946
- // We need the `delay(0)` here in order to avoid
1947
- // 'changed after checked' errors in some cases. See Angular Material #12194.
1948
- _this.menu._animationDone
1949
- .pipe(operators.take(1), operators.delay(0, rxjs.asapScheduler), operators.takeUntil(_this._parentMenu._hovered()))
1950
- // eslint-disable-next-line rxjs/no-nested-subscribe
1951
- .subscribe(function () { return _this.openMenu(); });
1952
- }
1953
- else {
1954
- _this.openMenu();
1955
- }
1956
- });
1957
- };
1958
- /**
1959
- * Restores focus to the element that was focused before the menu was open.
1960
- * Could be the root trigger button or a submenu trigger item
1961
- */
1962
- GraniteMenuTriggerForDirective.prototype._restoreFocus = function () {
1963
- // We should reset focus if the user is navigating using a keyboard or
1964
- // if we have a top-level trigger which might cause focus to be lost
1965
- // when clicking outside of the menu.
1966
- if (!this._openedBy) {
1967
- // Note that the focus style will show up both for `program` and
1968
- // `keyboard` so we don't have to specify which one it is.
1969
- this.focus();
1970
- }
1971
- else if (!this.triggersSubmenu()) {
1972
- this.focus(this._openedBy);
1973
- }
1974
- this._openedBy = null;
1975
- };
1976
- // Set state rather than toggle to support triggers sharing a menu
1977
- GraniteMenuTriggerForDirective.prototype._setIsMenuOpen = function (isOpen) {
1978
- this._isMenuOpen = isOpen;
1979
- if (this.triggersSubmenu()) {
1980
- this._menuItemInstance._highlighted =
1981
- isOpen && this._clientOutput.device !== 'touch';
1982
- }
1983
- };
1984
- /**
1985
- * This method checks that a valid instance of MenuComponent has been passed into
1986
- * graniteMenuTriggerFor. If not, an exception is thrown.
1987
- */
1988
- GraniteMenuTriggerForDirective.prototype._checkMenu = function () {
1989
- if (!this.menu) {
1990
- throwGraniteMenuMissingError();
1991
- }
1992
- };
1993
- /**
1994
- * Returns strategy for positioning the overlay for desktop devices:
1995
- * Place adjacent to the trigger button (preferably immediately below)
1996
- * in order to show as much of the menu as possible.
1997
- */
1998
- GraniteMenuTriggerForDirective.prototype._desktopPositionStrategy = function () {
1999
- var positionStrategy = this._overlay
2000
- .position()
2001
- .flexibleConnectedTo(this._element)
2002
- .withLockedPosition()
2003
- .withTransformOriginOn('.granite-menu')
2004
- .withPush(false);
2005
- this._setPosition(positionStrategy);
2006
- return positionStrategy;
2007
- };
2008
- /**
2009
- * Sets the appropriate positions on a position strategy
2010
- * so the overlay connects with the trigger correctly.
2011
- * @param positionStrategy Strategy whose position to update.
2012
- */
2013
- GraniteMenuTriggerForDirective.prototype._setPosition = function (positionStrategy) {
2014
- var MENU_PANEL_TOP_PADDING = 0;
2015
- var _c = __read(this.menu.xPosition === 'before' ? ['end', 'start'] : ['start', 'end'], 2), originX = _c[0], originFallbackX = _c[1];
2016
- var _d = __read(this.menu.yPosition === 'above' ? ['bottom', 'top'] : ['top', 'bottom'], 2), overlayY = _d[0], overlayFallbackY = _d[1];
2017
- var _e = __read([overlayY, overlayFallbackY], 2), originY = _e[0], originFallbackY = _e[1];
2018
- var _f = __read([originX, originFallbackX], 2), overlayX = _f[0], overlayFallbackX = _f[1];
2019
- var offsetY = 0;
2020
- if (this.triggersSubmenu()) {
2021
- // When the menu is a sub-menu, it should always align itself
2022
- // to the edges of the trigger, instead of overlapping it.
2023
- overlayFallbackX = originX =
2024
- this.menu.xPosition === 'before' ? 'start' : 'end';
2025
- originFallbackX = overlayX = originX === 'end' ? 'start' : 'end';
2026
- offsetY =
2027
- overlayY === 'bottom'
2028
- ? MENU_PANEL_TOP_PADDING
2029
- : -MENU_PANEL_TOP_PADDING;
2030
- }
2031
- else {
2032
- originY = overlayY === 'top' ? 'bottom' : 'top';
2033
- originFallbackY = overlayFallbackY === 'top' ? 'bottom' : 'top';
2034
- }
2035
- positionStrategy.withPositions([
2036
- { originX: originX, originY: originY, overlayX: overlayX, overlayY: overlayY, offsetY: offsetY },
2037
- {
2038
- originX: originFallbackX,
2039
- originY: originY,
2040
- overlayX: overlayFallbackX,
2041
- overlayY: overlayY,
2042
- offsetY: offsetY,
2043
- },
2044
- {
2045
- originX: originX,
2046
- originY: originFallbackY,
2047
- overlayX: overlayX,
2048
- overlayY: overlayFallbackY,
2049
- offsetY: -offsetY,
2050
- },
2051
- {
2052
- originX: originFallbackX,
2053
- originY: originFallbackY,
2054
- overlayX: overlayFallbackX,
2055
- overlayY: overlayFallbackY,
2056
- offsetY: -offsetY,
2057
- },
2058
- ]);
2059
- };
2060
- /** Returns a stream that emits whenever an action that should close the menu occurs. */
2061
- GraniteMenuTriggerForDirective.prototype._menuClosingActions = function () {
2062
- var _this = this;
2063
- var _a;
2064
- var detachments = (_a = this._overlayRef) === null || _a === void 0 ? void 0 : _a.detachments();
2065
- var parentClose = this._parentMenu
2066
- ? this._parentMenu.closed
2067
- : rxjs.of();
2068
- var hover = this._clientOutput.device === 'desktop' && this._parentMenu
2069
- ? this._parentMenu._hovered().pipe(operators.filter(function (item) { return item !== _this._menuItemInstance; }), operators.filter(function () { return _this._isMenuOpen; }))
2070
- : rxjs.of();
2071
- // Note: Quick fix. Feature reportedly exists in CDK for Angular 10
2072
- // Filter to prevent closing when animating added though. Applied to
2073
- // root menu only.
2074
- var outsideClick = !this._parentMenu
2075
- ? rxjs.fromEvent(this._document, 'click').pipe(operators.filter(function (e) { return e.target !== _this._element.nativeElement &&
2076
- e.target.closest('.granite-menu') === null; }), operators.filter(function () { return !_this.menu._isAnimating; }))
2077
- : rxjs.of();
2078
- return rxjs.merge(detachments, hover, parentClose, outsideClick);
2079
- };
2080
- /**
2081
- * Whether to automatically open submenus on hover. This is true when showing
2082
- * desktop menus and having mouse support.
2083
- */
2084
- GraniteMenuTriggerForDirective.prototype._openOnHover = function () {
2085
- var _a, _b;
2086
- return ((this.triggersSubmenu()
2087
- ? this._parentMenu.openOnHover
2088
- : this.menu.openOnHover) &&
2089
- ((_a = this._parentMenu._clientOutput) === null || _a === void 0 ? void 0 : _a.device) === 'desktop' && ((_b = this._parentMenu._clientInput) === null || _b === void 0 ? void 0 : _b.devices.includes('mouse')));
2090
- };
2091
- /**
2092
- * Whether to toggle submenus on click. This is true when showing desktop menus
2093
- * without mouse support. Which, by the way, is not a great idea to begin with.
2094
- */
2095
- GraniteMenuTriggerForDirective.prototype._toggleOnSubmenuClick = function () {
2096
- var _a, _b;
2097
- return (!(this.triggersSubmenu()
2098
- ? this._parentMenu.openOnHover
2099
- : this.menu.openOnHover) ||
2100
- (((_a = this._parentMenu._clientOutput) === null || _a === void 0 ? void 0 : _a.device) === 'desktop' &&
2101
- !((_b = this._parentMenu._clientInput) === null || _b === void 0 ? void 0 : _b.devices.includes('mouse'))));
2102
- };
2103
- // ------------------------------------------- //
2104
- // --- Here be touch device customizations --- //
2105
- // ------------------------------------------- //
2106
- /** Set animation state to bring a newly opened menu into view */
2107
- GraniteMenuTriggerForDirective.prototype.animateOpenMenu = function () {
2108
- this._clientOutput.device === 'touch'
2109
- ? this.animateTouchOpenMenu()
2110
- : this.menu._startAnimation();
2111
- };
2112
- GraniteMenuTriggerForDirective.prototype.animateTouchOpenMenu = function () {
2113
- if (this.triggersSubmenu()) {
2114
- // Slide newly opened sub menu into view from the side,
2115
- // pushing any parent menu out of view on the other side
2116
- this.menu._startTouchSubmenuEnterAnimation();
2117
- this._parentMenu._startTouchHideAnimation();
2118
- }
2119
- else {
2120
- // Slide root menu into view from below
2121
- this.menu._startTouchRootEnterAnimation();
2122
- }
2123
- };
2124
- /** Set animation state to close the active menu */
2125
- GraniteMenuTriggerForDirective.prototype.animateCloseMenu = function (toBelow, withDelay) {
2126
- this._clientOutput.device === 'touch'
2127
- ? this._animateTouchCloseMenu(toBelow, withDelay)
2128
- : this._parentMenu._resetAnimation();
2129
- };
2130
- GraniteMenuTriggerForDirective.prototype._animateTouchCloseMenu = function (toBelow, withDelay) {
2131
- var _a;
2132
- if (toBelow) {
2133
- // Slide menu out of view below the viewport
2134
- withDelay
2135
- ? this.menu._startTouchCloseDownAnimationWithDelay()
2136
- : this.menu._startTouchCloseDownAnimation();
2137
- }
2138
- else {
2139
- // Slide the closed menu out of view to the side
2140
- // and slide any parent menu back into view
2141
- this.menu._startTouchCloseSideAnimation();
2142
- (_a = this._parentMenu) === null || _a === void 0 ? void 0 : _a._startTouchSubmenuEnterAnimation();
2143
- }
2144
- };
2145
- /**
2146
- * Set animation state to place the menu and any parent at the given
2147
- * horizontal position, i.e. following touch pan movement.
2148
- *
2149
- * @param xOffset Horizontal offset
2150
- */
2151
- GraniteMenuTriggerForDirective.prototype.animateSetMenuPosition = function (xOffset) {
2152
- this.menu._startTouchPanAnimation(xOffset);
2153
- if (this._parentMenu) {
2154
- this._parentMenu._startTouchHidePanAnimation(xOffset);
2155
- }
2156
- };
2157
- /**
2158
- * Returns strategy for positioning the overlay depending on what type of
2159
- * device the menu is being shown on
2160
- */
2161
- GraniteMenuTriggerForDirective.prototype._positionStrategy = function () {
2162
- return this._clientOutput.device === 'touch'
2163
- ? this._touchPositionStrategy()
2164
- : this._desktopPositionStrategy();
2165
- };
2166
- /**
2167
- * Returns strategy for positioning the overlay for touch devices:
2168
- * Place centered at the bottom of the screen.
2169
- */
2170
- GraniteMenuTriggerForDirective.prototype._touchPositionStrategy = function () {
2171
- return this._overlay.position().global();
2172
- };
2173
- /**
2174
- * Remove touch device pan/swipe listeners from overlay host element
2175
- */
2176
- GraniteMenuTriggerForDirective.prototype.addOverlayListeners = function () {
2177
- this._overlayRef.hostElement.addEventListener('touchstart', this._handleOverlayTouchStart, passiveEventListenerOptions);
2178
- this._overlayRef.hostElement.addEventListener('touchmove', this._handleOverlayTouchMove, passiveEventListenerOptions);
2179
- this._overlayRef.hostElement.addEventListener('touchend', this._handleOverlayTouchEnd, passiveEventListenerOptions);
2180
- };
2181
- /**
2182
- * Remove touch device pan/swipe listeners from overlay host element
2183
- */
2184
- GraniteMenuTriggerForDirective.prototype.removeOverlayListeners = function () {
2185
- this._overlayRef.hostElement.removeEventListener('touchstart', this._handleOverlayTouchStart, passiveEventListenerOptions);
2186
- this._overlayRef.hostElement.removeEventListener('touchmove', this._handleOverlayTouchMove, passiveEventListenerOptions);
2187
- this._overlayRef.hostElement.removeEventListener('touchend', this._handleOverlayTouchEnd, passiveEventListenerOptions);
2188
- };
2189
- /**
2190
- * Standard exponential ease out function
2191
- *
2192
- * @param current Current value
2193
- * @param offset Offset value, to which calculated value will be added
2194
- * @param target The target value
2195
- * @param end Value to which current value is compared
2196
- */
2197
- GraniteMenuTriggerForDirective.prototype.easeOutExpo = function (current, offset, target, end) {
2198
- return current === end
2199
- ? offset + target
2200
- : target * (-Math.pow(2, (-10 * current) / end) + 1) + offset;
2201
- };
2202
- return GraniteMenuTriggerForDirective;
2203
- }());
2204
- GraniteMenuTriggerForDirective.decorators = [
2205
- { type: core.Directive, args: [{
2206
- selector: "[graniteMenuTriggerFor]",
2207
- host: {
2208
- class: 'granite-menu-trigger',
2209
- 'aria-haspopup': 'true',
2210
- '[attr.aria-expanded]': '_isMenuOpen || null',
2211
- '[attr.aria-controls]': '_isMenuOpen ? menu.panelId : null',
2212
- '(mousedown)': '_handleMousedown($event)',
2213
- '(keydown)': '_handleKeydown($event)',
2214
- '(click)': '_handleClick($event)',
2215
- },
2216
- },] }
2217
- ];
2218
- GraniteMenuTriggerForDirective.ctorParameters = function () { return [
2219
- { type: overlay.Overlay },
2220
- { type: core.ElementRef },
2221
- { type: core.ViewContainerRef },
2222
- { type: _MenuBaseComponent, decorators: [{ type: core.Inject, args: [GRANITE_MENU_PANEL,] }, { type: core.Optional }] },
2223
- { type: undefined, decorators: [{ type: core.Inject, args: [GRANITE_CLIENT_INPUT,] }, { type: core.Optional }] },
2224
- { type: undefined, decorators: [{ type: core.Inject, args: [GRANITE_CLIENT_OUTPUT,] }, { type: core.Optional }] },
2225
- { type: GraniteMenuItemComponent, decorators: [{ type: core.Optional }, { type: core.Self }] },
2226
- { type: bidi.Directionality, decorators: [{ type: core.Optional }] },
2227
- { type: a11y.FocusMonitor },
2228
- { type: undefined, decorators: [{ type: core.Inject, args: [common.DOCUMENT,] }] }
2229
- ]; };
2230
- GraniteMenuTriggerForDirective.propDecorators = {
2231
- menu: [{ type: core.Input, args: ['graniteMenuTriggerFor',] }]
2232
- };
2233
-
2234
- var GraniteMenuTouchCloseComponent = /** @class */ (function () {
2235
- function GraniteMenuTouchCloseComponent() {
2236
- }
2237
- return GraniteMenuTouchCloseComponent;
2238
- }());
2239
- GraniteMenuTouchCloseComponent.decorators = [
2240
- { type: core.Component, args: [{
2241
- // eslint-disable-next-line @angular-eslint/component-selector
2242
- selector: '[graniteMenuTouchCloseItem]',
2243
- template: '<ng-content></ng-content>',
2244
- exportAs: 'graniteMenuTouchCloseItem',
2245
- host: {
2246
- '[class.granite-device-output-touch]': 'true',
2247
- },
2248
- styles: [":host{display:block;position:relative;line-height:2rem;padding:0 var(--granite-spacing-s);width:100%;max-width:100%;-webkit-user-select:none;-moz-user-select:none;user-select:none;cursor:pointer;outline:none;border:none;-webkit-tap-highlight-color:transparent;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:start;text-decoration:none;background-color:var(--granite-color-background-variant);color:var(--granite-color-text);font-size:var(--granite-font-size-body-small);font-family:inherit}@media (hover:hover) and (pointer:fine){:host:hover:not(.granite-title):not([disabled]){background:var(--granite-color-background-active-hover);color:var(--granite-color-text-on-active)}}@media (hover:none) and (pointer:coarse){:host:active:not(.granite-title):not([disabled]){background:var(--granite-color-background-active-hover);color:var(--granite-color-text-on-active)}}:host.granite-title{-moz-user-select:none;-webkit-user-select:none;user-select:none;display:flex;align-items:center;line-height:1.5rem;width:100%;outline:none;border:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-decoration:none;color:var(--granite-color-text);font-size:var(--granite-font-size-micro);font-weight:var(--granite-font-weight-bold);cursor:default}:host.cdk-keyboard-focused,:host.cdk-program-focused,:host.granite-menu-item-highlighted{background:var(--granite-color-background-active-hover);color:var(--granite-color-text-on-active)}:host granite-icon{position:absolute;font-size:var(--granite-font-size-body-small);color:inherit;top:50%;transform:translateY(-50%)}:host.granite-menu-item-submenu-trigger{-webkit-padding-end:var(--granite-spacing-l);padding-inline-end:var(--granite-spacing-l)}:host-context([dir=ltr]) :host.granite-menu-item-submenu-trigger granite-icon,html[dir=ltr] :host.granite-menu-item-submenu-trigger granite-icon{right:var(--granite-spacing-xs)}:host-context([dir=rtl]) :host.granite-menu-item-submenu-trigger granite-icon,html[dir=rtl] :host.granite-menu-item-submenu-trigger granite-icon{left:var(--granite-spacing-xs)}[dir=ltr] :host.granite-menu-item-submenu-trigger granite-icon.caret-left,[dir=rtl] :host.granite-menu-item-submenu-trigger granite-icon.caret-right{display:none}:host.granite-divider-top{border-top:.0625rem solid var(--granite-color-border-soft)}:host.granite-divider-bottom{border-bottom:.0625rem solid var(--granite-color-border-soft)}:host.granite-device-output-touch{line-height:3rem;font-size:var(--granite-font-size-body-small);text-align:center;padding:0 var(--granite-spacing-l)}:host.granite-device-output-touch.granite-title{padding:0;justify-content:center;line-height:1.5rem;font-size:var(--granite-font-size-micro)}:host.granite-device-output-touch.granite-menu-item-back-trigger,:host.granite-device-output-touch.granite-menu-item-submenu-trigger{padding:0 var(--granite-spacing-l)}:host.granite-device-output-touch.granite-menu-item-title{line-height:3rem;height:3rem;font-size:var(--granite-font-size-micro);color:var(--granite-color-text-weak)}@media (hover:none) and (pointer:coarse){:host.granite-device-output-touch.granite-menu-item-title:active{background:var(--granite-color-background-active-hover);color:var(--granite-color-text-on-active)}}:host-context([dir=ltr]) :host.granite-device-output-touch.granite-menu-item-back-trigger granite-icon,html[dir=ltr] :host.granite-device-output-touch.granite-menu-item-back-trigger granite-icon{left:var(--granite-spacing-xs)}:host-context([dir=rtl]) :host.granite-device-output-touch.granite-menu-item-back-trigger granite-icon,html[dir=rtl] :host.granite-device-output-touch.granite-menu-item-back-trigger granite-icon{right:var(--granite-spacing-xs)}[dir=ltr] :host.granite-device-output-touch.granite-menu-item-back-trigger granite-icon.caret-right,[dir=rtl] :host.granite-device-output-touch.granite-menu-item-back-trigger granite-icon.caret-left{display:none}:host:disabled:not(.granite-menu-item-title){opacity:.4;cursor:default}"]
2249
- },] }
2250
- ];
2251
-
2252
- var GraniteMenuTouchTitleItemComponent = /** @class */ (function () {
2253
- function GraniteMenuTouchTitleItemComponent(
2254
- /** If this is an item on a _submenu_, its parent menu will have a parent */
2255
- _parentMenu) {
2256
- /**
2257
- * Whether the menu item acts as a trigger to return to a parent menu
2258
- * (used for styling)
2259
- */
2260
- this._triggersBack = false;
2261
- this._triggersBack = !!_parentMenu.parentMenu;
2262
- }
2263
- return GraniteMenuTouchTitleItemComponent;
2264
- }());
2265
- GraniteMenuTouchTitleItemComponent.decorators = [
2266
- { type: core.Component, args: [{
2267
- // eslint-disable-next-line @angular-eslint/component-selector
2268
- selector: '[graniteMenuTouchTitleItem]',
2269
- template: "\n <ng-container *ngIf=\"_triggersBack\">\n <granite-icon\n class=\"caret-left\"\n [fontIcon]=\"'icon-caret-left'\"\n ></granite-icon>\n <granite-icon\n class=\"caret-right\"\n [fontIcon]=\"'icon-caret-right'\"\n ></granite-icon>\n </ng-container>\n <ng-content></ng-content>\n ",
2270
- exportAs: 'graniteMenuTouchTitleItem',
2271
- host: {
2272
- '[class.granite-menu-item-title]': 'true',
2273
- '[class.granite-menu-item-back-trigger]': '_triggersBack',
2274
- '[class.granite-device-output-touch]': 'true',
2275
- },
2276
- styles: [":host{display:block;position:relative;line-height:2rem;padding:0 var(--granite-spacing-s);width:100%;max-width:100%;-webkit-user-select:none;-moz-user-select:none;user-select:none;cursor:pointer;outline:none;border:none;-webkit-tap-highlight-color:transparent;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:start;text-decoration:none;background-color:var(--granite-color-background-variant);color:var(--granite-color-text);font-size:var(--granite-font-size-body-small);font-family:inherit}@media (hover:hover) and (pointer:fine){:host:hover:not(.granite-title):not([disabled]){background:var(--granite-color-background-active-hover);color:var(--granite-color-text-on-active)}}@media (hover:none) and (pointer:coarse){:host:active:not(.granite-title):not([disabled]){background:var(--granite-color-background-active-hover);color:var(--granite-color-text-on-active)}}:host.granite-title{-moz-user-select:none;-webkit-user-select:none;user-select:none;display:flex;align-items:center;line-height:1.5rem;width:100%;outline:none;border:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-decoration:none;color:var(--granite-color-text);font-size:var(--granite-font-size-micro);font-weight:var(--granite-font-weight-bold);cursor:default}:host.cdk-keyboard-focused,:host.cdk-program-focused,:host.granite-menu-item-highlighted{background:var(--granite-color-background-active-hover);color:var(--granite-color-text-on-active)}:host granite-icon{position:absolute;font-size:var(--granite-font-size-body-small);color:inherit;top:50%;transform:translateY(-50%)}:host.granite-menu-item-submenu-trigger{-webkit-padding-end:var(--granite-spacing-l);padding-inline-end:var(--granite-spacing-l)}:host-context([dir=ltr]) :host.granite-menu-item-submenu-trigger granite-icon,html[dir=ltr] :host.granite-menu-item-submenu-trigger granite-icon{right:var(--granite-spacing-xs)}:host-context([dir=rtl]) :host.granite-menu-item-submenu-trigger granite-icon,html[dir=rtl] :host.granite-menu-item-submenu-trigger granite-icon{left:var(--granite-spacing-xs)}[dir=ltr] :host.granite-menu-item-submenu-trigger granite-icon.caret-left,[dir=rtl] :host.granite-menu-item-submenu-trigger granite-icon.caret-right{display:none}:host.granite-divider-top{border-top:.0625rem solid var(--granite-color-border-soft)}:host.granite-divider-bottom{border-bottom:.0625rem solid var(--granite-color-border-soft)}:host.granite-device-output-touch{line-height:3rem;font-size:var(--granite-font-size-body-small);text-align:center;padding:0 var(--granite-spacing-l)}:host.granite-device-output-touch.granite-title{padding:0;justify-content:center;line-height:1.5rem;font-size:var(--granite-font-size-micro)}:host.granite-device-output-touch.granite-menu-item-back-trigger,:host.granite-device-output-touch.granite-menu-item-submenu-trigger{padding:0 var(--granite-spacing-l)}:host.granite-device-output-touch.granite-menu-item-title{line-height:3rem;height:3rem;font-size:var(--granite-font-size-micro);color:var(--granite-color-text-weak)}@media (hover:none) and (pointer:coarse){:host.granite-device-output-touch.granite-menu-item-title:active{background:var(--granite-color-background-active-hover);color:var(--granite-color-text-on-active)}}:host-context([dir=ltr]) :host.granite-device-output-touch.granite-menu-item-back-trigger granite-icon,html[dir=ltr] :host.granite-device-output-touch.granite-menu-item-back-trigger granite-icon{left:var(--granite-spacing-xs)}:host-context([dir=rtl]) :host.granite-device-output-touch.granite-menu-item-back-trigger granite-icon,html[dir=rtl] :host.granite-device-output-touch.granite-menu-item-back-trigger granite-icon{right:var(--granite-spacing-xs)}[dir=ltr] :host.granite-device-output-touch.granite-menu-item-back-trigger granite-icon.caret-right,[dir=rtl] :host.granite-device-output-touch.granite-menu-item-back-trigger granite-icon.caret-left{display:none}:host:disabled:not(.granite-menu-item-title){opacity:.4;cursor:default}"]
2277
- },] }
2278
- ];
2279
- GraniteMenuTouchTitleItemComponent.ctorParameters = function () { return [
2280
- { type: _MenuBaseComponent, decorators: [{ type: core.Inject, args: [GRANITE_MENU_PANEL,] }, { type: core.Optional }] }
2281
- ]; };
2282
-
2283
- var GraniteDividerDirective = /** @class */ (function () {
2284
- function GraniteDividerDirective() {
2285
- this.dividerDirection = 'top';
2286
- }
2287
- return GraniteDividerDirective;
2288
- }());
2289
- GraniteDividerDirective.decorators = [
2290
- { type: core.Directive, args: [{
2291
- selector: '[graniteDivider]',
2292
- exportAs: 'graniteDivider',
2293
- host: {
2294
- '[class.granite-divider-top]': 'dividerDirection === "top"',
2295
- '[class.granite-divider-bottom]': 'dividerDirection === "bottom"',
2296
- },
2297
- },] }
2298
- ];
2299
- GraniteDividerDirective.propDecorators = {
2300
- dividerDirection: [{ type: core.Input }]
2301
- };
2302
-
2303
- var GraniteIconComponent = /** @class */ (function () {
2304
- function GraniteIconComponent(_elementRef, renderer, ariaHidden) {
2305
- this._elementRef = _elementRef;
2306
- this.renderer = renderer;
2307
- // aria-hidden will be set to true by default, unless it's overridden by the developer
2308
- if (!ariaHidden) {
2309
- this.renderer.setAttribute(_elementRef.nativeElement, 'aria-hidden', 'true');
2310
- }
2311
- }
2312
- GraniteIconComponent.prototype.ngOnChanges = function (changes) {
2313
- if (changes.fontIcon) {
2314
- this._updateFontIcon();
2315
- }
2316
- };
2317
- GraniteIconComponent.prototype._updateFontIcon = function () {
2318
- if (this.fontIcon !== this._previousFontIconClass) {
2319
- if (this._previousFontIconClass) {
2320
- this.renderer.removeClass(this._elementRef.nativeElement, this._previousFontIconClass);
2321
- }
2322
- if (this.fontIcon) {
2323
- this.renderer.addClass(this._elementRef.nativeElement, this.fontIcon);
2324
- }
2325
- this._previousFontIconClass = this.fontIcon;
2326
- }
2327
- };
2328
- return GraniteIconComponent;
2329
- }());
2330
- GraniteIconComponent.decorators = [
2331
- { type: core.Component, args: [{
2332
- selector: 'granite-icon',
2333
- template: '<ng-content></ng-content>',
2334
- host: {
2335
- role: 'img',
2336
- class: 'granite-icon',
2337
- },
2338
- changeDetection: core.ChangeDetectionStrategy.OnPush,
2339
- styles: [":host.granite-icon{background-repeat:no-repeat;display:inline-block;padding:0 calc(var(--granite-spacing-xs) / 2);font-size:1em;line-height:1em;position:relative;top:.1em}"]
2340
- },] }
2341
- ];
2342
- GraniteIconComponent.ctorParameters = function () { return [
2343
- { type: core.ElementRef },
2344
- { type: core.Renderer2 },
2345
- { type: String, decorators: [{ type: core.Attribute, args: ['aria-hidden',] }] }
2346
- ]; };
2347
- GraniteIconComponent.propDecorators = {
2348
- fontIcon: [{ type: core.Input }]
2349
- };
2350
-
2351
- var GraniteIconModule = /** @class */ (function () {
2352
- function GraniteIconModule() {
2353
- }
2354
- return GraniteIconModule;
2355
- }());
2356
- GraniteIconModule.decorators = [
2357
- { type: core.NgModule, args: [{
2358
- declarations: [GraniteIconComponent],
2359
- exports: [GraniteIconComponent],
2360
- },] }
2361
- ];
2362
-
2363
- var GraniteTitleDirective = /** @class */ (function () {
2364
- function GraniteTitleDirective() {
2365
- }
2366
- return GraniteTitleDirective;
2367
- }());
2368
- GraniteTitleDirective.decorators = [
2369
- { type: core.Directive, args: [{
2370
- selector: '[graniteTitle]',
2371
- exportAs: 'graniteTitle',
2372
- host: {
2373
- '[class.granite-title]': 'true',
2374
- },
2375
- },] }
2376
- ];
2377
-
2378
- var GraniteMenuModule = /** @class */ (function () {
2379
- function GraniteMenuModule() {
2380
- }
2381
- return GraniteMenuModule;
2382
- }());
2383
- GraniteMenuModule.decorators = [
2384
- { type: core.NgModule, args: [{
2385
- declarations: [
2386
- GraniteMenuComponent,
2387
- GraniteMenuItemComponent,
2388
- GraniteMenuTriggerForDirective,
2389
- GraniteMenuTouchCloseComponent,
2390
- GraniteMenuTouchTitleItemComponent,
2391
- GraniteDividerDirective,
2392
- GraniteTitleDirective,
2393
- ],
2394
- imports: [common.CommonModule, overlay.OverlayModule, portal.PortalModule, GraniteIconModule],
2395
- exports: [
2396
- GraniteMenuComponent,
2397
- GraniteMenuItemComponent,
2398
- GraniteMenuTriggerForDirective,
2399
- GraniteMenuTouchCloseComponent,
2400
- GraniteMenuTouchTitleItemComponent,
2401
- GraniteDividerDirective,
2402
- GraniteTitleDirective,
2403
- ],
2404
- },] }
2405
- ];
2406
-
2407
- /**
2408
- * Test harness for menu component
2409
- *
2410
- * Stripped-down version of the Angular Material menu test harness (.../menu/menu-harness.ts)
2411
- * just to get things going.
2412
- */
2413
- var GraniteMenuHarness = /** @class */ (function (_super) {
2414
- __extends(GraniteMenuHarness, _super);
2415
- function GraniteMenuHarness() {
2416
- var _this = _super.apply(this, __spread(arguments)) || this;
2417
- _this._documentRootLocator = _this.documentRootLocatorFactory();
2418
- return _this;
2419
- }
2420
- /**
2421
- * Gets a `HarnessPredicate` that can be used to search for a `MenuHarness` that meets
2422
- * certain criteria.
2423
- * @param options Options for filtering which menu item instances are considered a match.
2424
- * @return a `HarnessPredicate` configured with the given options.
2425
- */
2426
- GraniteMenuHarness.with = function (options) {
2427
- if (options === void 0) { options = {}; }
2428
- return new testing.HarnessPredicate(GraniteMenuHarness, options).addOption('text', options.text,
2429
- /* @dynamic */ function (harness, text) { return testing.HarnessPredicate.stringMatches(harness.getText(), text); });
2430
- };
2431
- /** Gets the text of the menu trigger */
2432
- GraniteMenuHarness.prototype.getText = function () {
2433
- return __awaiter(this, void 0, void 0, function () {
2434
- return __generator(this, function (_b) {
2435
- switch (_b.label) {
2436
- case 0: return [4 /*yield*/, this.host()];
2437
- case 1: return [2 /*return*/, (_b.sent()).text()];
2438
- }
2439
- });
2440
- });
2441
- };
2442
- /** Opens the menu, unless already open */
2443
- GraniteMenuHarness.prototype.open = function () {
2444
- return __awaiter(this, void 0, void 0, function () {
2445
- return __generator(this, function (_b) {
2446
- switch (_b.label) {
2447
- case 0: return [4 /*yield*/, this.isOpen()];
2448
- case 1:
2449
- if (!!(_b.sent())) return [3 /*break*/, 4];
2450
- return [4 /*yield*/, this.host()];
2451
- case 2: return [4 /*yield*/, (_b.sent()).click()];
2452
- case 3:
2453
- _b.sent();
2454
- // This is necessary so that we wait for the opening animation to finish.
2455
- return [2 /*return*/, this.forceStabilize()];
2456
- case 4: return [2 /*return*/];
2457
- }
2458
- });
2459
- });
2460
- };
2461
- /** Closes the menu, unless already closed */
2462
- GraniteMenuHarness.prototype.close = function () {
2463
- var _a;
2464
- return __awaiter(this, void 0, void 0, function () {
2465
- return __generator(this, function (_b) {
2466
- switch (_b.label) {
2467
- case 0: return [4 /*yield*/, this._getMenuPanel()];
2468
- case 1: return [4 /*yield*/, ((_a = (_b.sent())) === null || _a === void 0 ? void 0 : _a.sendKeys(testing.TestKey.ESCAPE))];
2469
- case 2:
2470
- _b.sent();
2471
- // This is necessary so that we wait for the closing animation to finish.
2472
- return [2 /*return*/, this.forceStabilize()];
2473
- }
2474
- });
2475
- });
2476
- };
2477
- /** Whether the menu is open */
2478
- GraniteMenuHarness.prototype.isOpen = function () {
2479
- return __awaiter(this, void 0, void 0, function () {
2480
- return __generator(this, function (_b) {
2481
- switch (_b.label) {
2482
- case 0: return [4 /*yield*/, this._getMenuPanel()];
2483
- case 1: return [2 /*return*/, !!(_b.sent())];
2484
- }
2485
- });
2486
- });
2487
- };
2488
- /**
2489
- * Gets a list of `GraniteMenuItemHarness` representing the items in the menu.
2490
- * @param filters Optionally filters which menu items are included.
2491
- */
2492
- GraniteMenuHarness.prototype.getItems = function (filters) {
2493
- if (filters === void 0) { filters = {}; }
2494
- return __awaiter(this, void 0, void 0, function () {
2495
- var panelId;
2496
- return __generator(this, function (_b) {
2497
- switch (_b.label) {
2498
- case 0: return [4 /*yield*/, this._getPanelId()];
2499
- case 1:
2500
- panelId = _b.sent();
2501
- if (panelId) {
2502
- return [2 /*return*/, this._documentRootLocator.locatorForAll(GraniteMenuItemHarness.with(Object.assign(Object.assign({}, filters), { ancestor: "#" + panelId })))()];
2503
- }
2504
- return [2 /*return*/, []];
2505
- }
2506
- });
2507
- });
2508
- };
2509
- /** Gets the menu panel (popup) associated with the menu */
2510
- GraniteMenuHarness.prototype._getMenuPanel = function () {
2511
- return __awaiter(this, void 0, void 0, function () {
2512
- var panelId;
2513
- return __generator(this, function (_b) {
2514
- switch (_b.label) {
2515
- case 0: return [4 /*yield*/, this._getPanelId()];
2516
- case 1:
2517
- panelId = _b.sent();
2518
- return [2 /*return*/, panelId
2519
- ? this._documentRootLocator.locatorForOptional("#" + panelId)()
2520
- : null];
2521
- }
2522
- });
2523
- });
2524
- };
2525
- /** Gets the id of the menu panel (popup) associated with this menu */
2526
- GraniteMenuHarness.prototype._getPanelId = function () {
2527
- return __awaiter(this, void 0, void 0, function () {
2528
- var panelId;
2529
- return __generator(this, function (_b) {
2530
- switch (_b.label) {
2531
- case 0: return [4 /*yield*/, this.host()];
2532
- case 1: return [4 /*yield*/, (_b.sent()).getAttribute('aria-controls')];
2533
- case 2:
2534
- panelId = _b.sent();
2535
- return [2 /*return*/, panelId || null];
2536
- }
2537
- });
2538
- });
2539
- };
2540
- return GraniteMenuHarness;
2541
- }(testing.ComponentHarness));
2542
- /**
2543
- * The selector for the host element of a `MenuComponent` instance,
2544
- * i.e. the button element used to open the menu.
2545
- */
2546
- GraniteMenuHarness.hostSelector = '.granite-menu-trigger';
2547
- var GraniteMenuItemHarness = /** @class */ (function (_super) {
2548
- __extends(GraniteMenuItemHarness, _super);
2549
- function GraniteMenuItemHarness() {
2550
- return _super !== null && _super.apply(this, arguments) || this;
2551
- }
2552
- /**
2553
- * Gets a `HarnessPredicate` that can be used to search for a `GraniteMenuItemHarness` that meets
2554
- * certain criteria.
2555
- * @param options Options for filtering which menu item instances are considered a match.
2556
- * @return a `HarnessPredicate` configured with the given options.
2557
- */
2558
- GraniteMenuItemHarness.with = function (options) {
2559
- if (options === void 0) { options = {}; }
2560
- return new testing.HarnessPredicate(GraniteMenuItemHarness, options).addOption('text', options.text,
2561
- /* @dynamic */ function (harness, text) { return testing.HarnessPredicate.stringMatches(harness.getText(), text); });
2562
- };
2563
- /** Gets the text of the menu item. */
2564
- GraniteMenuItemHarness.prototype.getText = function () {
2565
- return __awaiter(this, void 0, void 0, function () {
2566
- return __generator(this, function (_b) {
2567
- switch (_b.label) {
2568
- case 0: return [4 /*yield*/, this.host()];
2569
- case 1: return [2 /*return*/, (_b.sent()).text()];
2570
- }
2571
- });
2572
- });
2573
- };
2574
- /** Whether this item has a submenu. */
2575
- GraniteMenuItemHarness.prototype.hasSubmenu = function () {
2576
- return __awaiter(this, void 0, void 0, function () {
2577
- return __generator(this, function (_b) {
2578
- switch (_b.label) {
2579
- case 0: return [4 /*yield*/, this.host()];
2580
- case 1: return [2 /*return*/, (_b.sent()).matchesSelector(GraniteMenuHarness.hostSelector)];
2581
- }
2582
- });
2583
- });
2584
- };
2585
- /** Gets the submenu associated with this menu item, or null if none. */
2586
- GraniteMenuItemHarness.prototype.getSubmenu = function () {
2587
- return __awaiter(this, void 0, void 0, function () {
2588
- return __generator(this, function (_b) {
2589
- switch (_b.label) {
2590
- case 0: return [4 /*yield*/, this.hasSubmenu()];
2591
- case 1:
2592
- if (_b.sent()) {
2593
- return [2 /*return*/, new GraniteMenuHarness(this.locatorFactory)];
2594
- }
2595
- return [2 /*return*/, null];
2596
- }
2597
- });
2598
- });
2599
- };
2600
- /** Clicks the menu item. */
2601
- GraniteMenuItemHarness.prototype.click = function () {
2602
- return __awaiter(this, void 0, void 0, function () {
2603
- return __generator(this, function (_b) {
2604
- switch (_b.label) {
2605
- case 0: return [4 /*yield*/, this.host()];
2606
- case 1: return [4 /*yield*/, (_b.sent()).click()];
2607
- case 2:
2608
- _b.sent();
2609
- // This is necessary so that we wait for the opening animation to finish. (i.e. if it opens another menu)
2610
- return [2 /*return*/, this.forceStabilize()];
2611
- }
2612
- });
2613
- });
2614
- };
2615
- return GraniteMenuItemHarness;
2616
- }(testing.ComponentHarness));
2617
- /** The selector for the host element of a `MenuItemComponent` instance. */
2618
- GraniteMenuItemHarness.hostSelector = '.granite-menu-item';
2619
-
2620
- var GraniteToggleSwitchComponent = /** @class */ (function () {
2621
- function GraniteToggleSwitchComponent(_focusMonitor) {
2622
- this._focusMonitor = _focusMonitor;
2623
- this.id = null;
2624
- this.checked = false;
2625
- this.disabled = false;
2626
- this.readonly = false;
2627
- this.labelPosition = 'after';
2628
- this.ariaLabel = null;
2629
- this.ariaLabelledby = null;
2630
- this.valueChange = new core.EventEmitter();
2631
- this.toggleChange = new core.EventEmitter();
2632
- this.toggleBlur = new core.EventEmitter();
2633
- this._positionBefore = false;
2634
- this._toggleSwitchDisabled = false;
2635
- }
2636
- GraniteToggleSwitchComponent.prototype.ngOnChanges = function (changes) {
2637
- if (changes.checked) {
2638
- this.checked = coercion.coerceBooleanProperty(changes.checked.currentValue);
2639
- }
2640
- if (changes.disabled) {
2641
- this.disabled = coercion.coerceBooleanProperty(changes.disabled.currentValue);
2642
- }
2643
- if (changes.readonly) {
2644
- this.readonly = coercion.coerceBooleanProperty(changes.readonly.currentValue);
2645
- }
2646
- if (changes.labelPosition != null) {
2647
- this._positionBefore =
2648
- changes.labelPosition.currentValue != null &&
2649
- changes.labelPosition.currentValue === 'before';
2650
- }
2651
- if ((changes.disabled || changes.readonly) &&
2652
- (this.disabled || this.readonly)) {
2653
- this._toggleSwitchDisabled = true;
2654
- }
2655
- };
2656
- GraniteToggleSwitchComponent.prototype.focus = function (origin, options) {
2657
- if (origin === void 0) { origin = 'program'; }
2658
- this._focusMonitor.focusVia(this._getInputElement(), origin, options);
2659
- };
2660
- GraniteToggleSwitchComponent.prototype._onBlur = function () {
2661
- this.toggleBlur.emit();
2662
- };
2663
- GraniteToggleSwitchComponent.prototype._toggleSwitchChange = function () {
2664
- this.checked = this._getInputElement().checked;
2665
- this.valueChange.emit(this.checked);
2666
- };
2667
- GraniteToggleSwitchComponent.prototype._toggleSwitchClick = function () {
2668
- this.toggleChange.emit();
2669
- };
2670
- GraniteToggleSwitchComponent.prototype._getInputElement = function () {
2671
- return this._inputElement.nativeElement;
2672
- };
2673
- return GraniteToggleSwitchComponent;
2674
- }());
2675
- GraniteToggleSwitchComponent.decorators = [
2676
- { type: core.Component, args: [{
2677
- selector: 'granite-toggle-switch',
2678
- exportAs: 'graniteToggleSwitch',
2679
- host: {
2680
- class: 'granite-toggle-switch',
2681
- '[class.granite-toggle-switch-checked]': 'checked',
2682
- '[class.granite-toggle-switch-disabled]': 'disabled',
2683
- '[class.granite-toggle-switch-readonly]': 'readonly',
2684
- '[class.granite-toggle-switch-label-before]': '_positionBefore',
2685
- },
2686
- template: "<label [attr.for]=\"id\" class=\"granite-toggle-switch-label\">\n <div class=\"granite-toggle-switch-bar\">\n <input\n #input\n [id]=\"id\"\n class=\"granite-toggle-switch-input cdk-visually-hidden\"\n role=\"switch\"\n type=\"checkbox\"\n [attr.aria-checked]=\"checked.toString()\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.aria-labelledby]=\"ariaLabelledby\"\n [checked]=\"checked\"\n [disabled]=\"_toggleSwitchDisabled\"\n [readonly]=\"readonly\"\n (click)=\"_toggleSwitchClick()\"\n (change)=\"_toggleSwitchChange()\"\n (blur)=\"_onBlur()\"\n />\n <div class=\"granite-toggle-switch-thumb\"></div>\n </div>\n <span class=\"granite-toggle-switch-text\"><ng-content></ng-content></span>\n</label>\n",
2687
- changeDetection: core.ChangeDetectionStrategy.OnPush,
2688
- styles: [".cdk-visually-hidden{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap;outline:0;-webkit-appearance:none;-moz-appearance:none}:host{box-sizing:border-box}:host *,:host :after,:host :before{box-sizing:inherit;cursor:pointer}:host(.granite-toggle-switch){color:var(--granite-color-text)}:host(.granite-toggle-switch-checked) .granite-toggle-switch-bar{background-color:var(--granite-color-background-active)}:host(.granite-toggle-switch-checked) .granite-toggle-switch-thumb{border:.0625rem solid var(--granite-color-background-active)}:host-context([dir=ltr]) :host(.granite-toggle-switch-checked) .granite-toggle-switch-thumb,html[dir=ltr] :host(.granite-toggle-switch-checked) .granite-toggle-switch-thumb{float:right}:host-context([dir=rtl]) :host(.granite-toggle-switch-checked) .granite-toggle-switch-thumb,html[dir=rtl] :host(.granite-toggle-switch-checked) .granite-toggle-switch-thumb{float:left}:host(.granite-toggle-switch-disabled) .granite-toggle-switch-label{opacity:.6}:host(.granite-toggle-switch-disabled) *,:host(.granite-toggle-switch-readonly) *{cursor:default}:host(.granite-toggle-switch-label-before) .granite-toggle-switch-label{flex-direction:row-reverse}:host(.granite-toggle-switch-label-before) .granite-toggle-switch-text{-webkit-padding-start:0;padding-inline-start:0;-webkit-padding-end:var(--granite-spacing-s);padding-inline-end:var(--granite-spacing-s)}.granite-toggle-switch-label{display:flex;align-items:center;width:-webkit-max-content;width:-moz-max-content;width:max-content}.granite-toggle-switch-bar{width:2rem;height:1rem;border-radius:.5rem;background-color:var(--granite-color-background-inactive);transition:background-color .1s linear;position:relative}.granite-toggle-switch-bar:focus-within{box-shadow:0 0 0 .0625rem var(--granite-color-focus)}.granite-toggle-switch-thumb{width:1rem;height:1rem;border-radius:1rem;background-color:var(--granite-color-text-static-light);border:.0625rem solid var(--granite-color-background-inactive);transition:float .1s linear}:host-context([dir=ltr]) .granite-toggle-switch-thumb,html[dir=ltr] .granite-toggle-switch-thumb{float:left}:host-context([dir=rtl]) .granite-toggle-switch-thumb,html[dir=rtl] .granite-toggle-switch-thumb{float:right}.granite-toggle-switch-text{-webkit-padding-start:var(--granite-spacing-s);padding-inline-start:var(--granite-spacing-s)}.granite-toggle-switch-text:empty{display:none}"]
2689
- },] }
2690
- ];
2691
- GraniteToggleSwitchComponent.ctorParameters = function () { return [
2692
- { type: a11y.FocusMonitor }
2693
- ]; };
2694
- GraniteToggleSwitchComponent.propDecorators = {
2695
- id: [{ type: core.Input }],
2696
- checked: [{ type: core.Input }],
2697
- disabled: [{ type: core.Input }],
2698
- readonly: [{ type: core.Input }],
2699
- labelPosition: [{ type: core.Input }],
2700
- ariaLabel: [{ type: core.Input, args: ['aria-label',] }],
2701
- ariaLabelledby: [{ type: core.Input, args: ['aria-labelledby',] }],
2702
- valueChange: [{ type: core.Output }],
2703
- toggleChange: [{ type: core.Output }],
2704
- toggleBlur: [{ type: core.Output }],
2705
- _inputElement: [{ type: core.ViewChild, args: ['input',] }]
2706
- };
2707
-
2708
- var GraniteToggleSwitchModule = /** @class */ (function () {
2709
- function GraniteToggleSwitchModule() {
2710
- }
2711
- return GraniteToggleSwitchModule;
2712
- }());
2713
- GraniteToggleSwitchModule.decorators = [
2714
- { type: core.NgModule, args: [{
2715
- declarations: [GraniteToggleSwitchComponent],
2716
- exports: [GraniteToggleSwitchComponent],
2717
- },] }
2718
- ];
2719
-
2720
- var GraniteRadioButtonComponent = /** @class */ (function () {
2721
- function GraniteRadioButtonComponent(_focusMonitor, _radioDispatcher) {
2722
- var _this = this;
2723
- this._focusMonitor = _focusMonitor;
2724
- this._radioDispatcher = _radioDispatcher;
2725
- this.id = null;
2726
- this.checked = false;
2727
- this.required = false;
2728
- this.disabled = false;
2729
- this.readonly = false;
2730
- this.labelPosition = 'after';
2731
- this.ariaLabel = null;
2732
- this.ariaLabelledby = null;
2733
- this.radioChange = new core.EventEmitter();
2734
- this.radioBlur = new core.EventEmitter();
2735
- this._positionBefore = false;
2736
- this._radioDisabled = false;
2737
- this._removeUniqueSelectionListener = function () {
2738
- // Function used to deregister listener
2739
- };
2740
- this._removeUniqueSelectionListener = _radioDispatcher.listen(function (id, name) {
2741
- if (id !== _this.id && name === _this.name) {
2742
- _this.checked = false;
2743
- }
2744
- });
2745
- }
2746
- GraniteRadioButtonComponent.prototype.ngOnChanges = function (changes) {
2747
- if (changes.checked) {
2748
- this.checked = coercion.coerceBooleanProperty(changes.checked.currentValue);
2749
- }
2750
- if (changes.required) {
2751
- this.required = coercion.coerceBooleanProperty(changes.required.currentValue);
2752
- }
2753
- if (changes.readonly) {
2754
- this.readonly = coercion.coerceBooleanProperty(changes.readonly.currentValue);
2755
- }
2756
- if (changes.disabled) {
2757
- this.disabled = coercion.coerceBooleanProperty(changes.disabled.currentValue);
2758
- }
2759
- if (changes.labelPosition != null) {
2760
- this._positionBefore =
2761
- changes.labelPosition.currentValue != null &&
2762
- changes.labelPosition.currentValue === 'before';
2763
- }
2764
- if ((changes.disabled || changes.readonly) &&
2765
- (this.disabled || this.readonly)) {
2766
- this._radioDisabled = true;
2767
- }
2768
- };
2769
- GraniteRadioButtonComponent.prototype.ngOnDestroy = function () {
2770
- this._removeUniqueSelectionListener();
2771
- };
2772
- // Focuses the radio button.
2773
- GraniteRadioButtonComponent.prototype.focus = function (origin, options) {
2774
- if (origin === void 0) { origin = 'program'; }
2775
- this._focusMonitor.focusVia(this._getInputElement(), origin, options);
2776
- };
2777
- GraniteRadioButtonComponent.prototype._radioClick = function (element) {
2778
- this.radioChange.emit(element === null || element === void 0 ? void 0 : element.value);
2779
- };
2780
- GraniteRadioButtonComponent.prototype._radioChange = function () {
2781
- this.checked = this._getInputElement().checked;
2782
- // Notify all radio buttons with the same name to un-check
2783
- this._radioDispatcher.notify(this.id, this.name);
2784
- };
2785
- GraniteRadioButtonComponent.prototype._onBlur = function () {
2786
- this.radioBlur.emit();
2787
- };
2788
- GraniteRadioButtonComponent.prototype._getInputElement = function () {
2789
- return this._inputElement.nativeElement;
2790
- };
2791
- return GraniteRadioButtonComponent;
2792
- }());
2793
- GraniteRadioButtonComponent.decorators = [
2794
- { type: core.Component, args: [{
2795
- selector: 'granite-radio-button',
2796
- exportAs: 'graniteRadioButton',
2797
- host: {
2798
- class: 'granite-radio-button',
2799
- '[class.granite-radio-button-disabled]': 'disabled',
2800
- '[class.granite-radio-button-label-before]': '_positionBefore',
2801
- '[class.granite-radio-button-checked]': 'checked',
2802
- '[class.granite-radio-button-readonly]': 'readonly',
2803
- },
2804
- template: "<label class=\"granite-radio-button-label\">\n <div class=\"granite-radio-button-outer-circle\">\n <input\n #input\n [id]=\"id\"\n class=\"granite-radio-button-input cdk-visually-hidden\"\n type=\"radio\"\n [attr.name]=\"name\"\n [disabled]=\"_radioDisabled\"\n [checked]=\"checked\"\n [readonly]=\"readonly\"\n [required]=\"required\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.aria-labelledby]=\"ariaLabelledby\"\n [attr.aria-checked]=\"checked.toString()\"\n [value]=\"value\"\n (click)=\"_radioClick($event.target)\"\n (change)=\"_radioChange()\"\n (blur)=\"_onBlur()\"\n />\n <div class=\"granite-radio-button-inner-circle\"></div>\n </div>\n <span class=\"granite-radio-button-text\">\n <ng-content></ng-content>\n </span>\n</label>\n",
2805
- changeDetection: core.ChangeDetectionStrategy.OnPush,
2806
- styles: [".cdk-visually-hidden{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap;outline:0;-webkit-appearance:none;-moz-appearance:none}:host(.granite-radio-button):not(.granite-radio-button-readonly):not(.granite-radio-button-disabled) .granite-radio-button-label:hover{cursor:pointer}:host(.granite-radio-button):not(.granite-radio-button-readonly):not(.granite-radio-button-disabled) .granite-radio-button-label:hover .granite-radio-button-outer-circle{border-color:var(--granite-color-background-active-hover)}:host(.granite-radio-button):not(.granite-radio-button-readonly):not(.granite-radio-button-disabled) .granite-radio-button-label:hover .granite-radio-button-inner-circle{background-color:var(--granite-color-background-active-hover)}:host(.granite-radio-button):not(.granite-radio-button-readonly):not(.granite-radio-button-disabled) .granite-radio-button-outer-circle:focus-within{border:.0625rem solid var(--granite-color-focus)}:host(.granite-radio-button-label-before) .granite-radio-button-label{flex-direction:row-reverse}:host(.granite-radio-button-label-before) .granite-radio-button-text{-webkit-padding-start:0;padding-inline-start:0;-webkit-padding-end:var(--granite-spacing-s);padding-inline-end:var(--granite-spacing-s)}:host(.granite-radio-button-checked) .granite-radio-button-inner-circle{visibility:visible;-webkit-animation:growAnimation .1s;animation:growAnimation .1s}:host(.granite-radio-button-checked) .granite-radio-button-outer-circle{border-color:var(--granite-color-background-active)}:host(.granite-radio-button-checked).granite-radio-button-disabled .granite-radio-button-inner-circle{background-color:var(--granite-color-text)}:host(.granite-radio-button-checked).granite-radio-button-disabled .granite-radio-button-outer-circle{border:.0625rem solid var(--granite-color-text);background-color:transparent}:host(.granite-radio-button-checked).granite-radio-button-readonly .granite-radio-button-inner-circle{background-color:var(--granite-color-text)}:host(.granite-radio-button-checked).granite-radio-button-readonly .granite-radio-button-outer-circle{border:.0625rem solid var(--granite-color-text)}.granite-radio-button-text{-webkit-padding-start:var(--granite-spacing-s);padding-inline-start:var(--granite-spacing-s);color:var(--granite-color-text)}.granite-radio-button-text:empty{display:none}.granite-radio-button-label{display:flex;align-items:center;width:-webkit-max-content;width:-moz-max-content;width:max-content;-webkit-margin-end:var(--granite-spacing-xl);margin-inline-end:var(--granite-spacing-xl)}:host(.granite-radio-button-disabled) .granite-radio-button-text{opacity:.6}:host(.granite-radio-button-disabled) .granite-radio-button-outer-circle{opacity:.3;background-color:var(--granite-color-border-soft)}.granite-radio-button-outer-circle{height:1rem;width:1rem;border-radius:50%;box-sizing:border-box;border:.0625rem solid var(--granite-color-border-hard);display:flex;justify-content:center;position:relative;align-items:center}.granite-radio-button-inner-circle{width:.625rem;height:.625rem;visibility:hidden;position:absolute;border-radius:50%;background-color:var(--granite-color-background-active);margin:auto}@-webkit-keyframes growAnimation{0%{transform:scale(0)}to{transform:scale(1)}}@keyframes growAnimation{0%{transform:scale(0)}to{transform:scale(1)}}"]
2807
- },] }
2808
- ];
2809
- GraniteRadioButtonComponent.ctorParameters = function () { return [
2810
- { type: a11y.FocusMonitor },
2811
- { type: collections.UniqueSelectionDispatcher }
2812
- ]; };
2813
- GraniteRadioButtonComponent.propDecorators = {
2814
- value: [{ type: core.Input }],
2815
- id: [{ type: core.Input }],
2816
- name: [{ type: core.Input }],
2817
- checked: [{ type: core.Input }],
2818
- required: [{ type: core.Input }],
2819
- disabled: [{ type: core.Input }],
2820
- readonly: [{ type: core.Input }],
2821
- labelPosition: [{ type: core.Input }],
2822
- ariaLabel: [{ type: core.Input, args: ['aria-label',] }],
2823
- ariaLabelledby: [{ type: core.Input, args: ['aria-labelledby',] }],
2824
- radioChange: [{ type: core.Output }],
2825
- radioBlur: [{ type: core.Output }],
2826
- _inputElement: [{ type: core.ViewChild, args: ['input',] }]
2827
- };
2828
-
2829
- var GraniteRadioCheckboxBase = /** @class */ (function () {
2830
- function GraniteRadioCheckboxBase() {
2831
- this.layout = 'horizontal';
2832
- this.ariaLabelledby = null;
2833
- }
2834
- return GraniteRadioCheckboxBase;
2835
- }());
2836
- GraniteRadioCheckboxBase.decorators = [
2837
- { type: core.Directive }
2838
- ];
2839
- GraniteRadioCheckboxBase.propDecorators = {
2840
- layout: [{ type: core.Input }],
2841
- ariaLabelledby: [{ type: core.Input, args: ['aria-labelledby',] }]
2842
- };
2843
-
2844
- var GraniteRadioGroupComponent = /** @class */ (function (_super) {
2845
- __extends(GraniteRadioGroupComponent, _super);
2846
- function GraniteRadioGroupComponent() {
2847
- return _super !== null && _super.apply(this, arguments) || this;
2848
- }
2849
- return GraniteRadioGroupComponent;
2850
- }(GraniteRadioCheckboxBase));
2851
- GraniteRadioGroupComponent.decorators = [
2852
- { type: core.Component, args: [{
2853
- selector: 'granite-radio-group',
2854
- host: {
2855
- class: 'granite-radio-group',
2856
- '[attr.role]': '"radiogroup"',
2857
- '[attr.aria-labelledby]': 'ariaLabelledby',
2858
- '[class.granite-radio-checkbox-base-layout-horizontal]': 'layout === "horizontal"',
2859
- },
2860
- template: '<ng-content></ng-content>',
2861
- changeDetection: core.ChangeDetectionStrategy.OnPush,
2862
- styles: [":host(.granite-radio-checkbox-base-layout-horizontal){display:flex;align-items:flex-start}"]
2863
- },] }
2864
- ];
2865
-
2866
- var GraniteRadioButtonModule = /** @class */ (function () {
2867
- function GraniteRadioButtonModule() {
2868
- }
2869
- return GraniteRadioButtonModule;
2870
- }());
2871
- GraniteRadioButtonModule.decorators = [
2872
- { type: core.NgModule, args: [{
2873
- declarations: [GraniteRadioButtonComponent, GraniteRadioGroupComponent],
2874
- exports: [GraniteRadioButtonComponent, GraniteRadioGroupComponent],
2875
- },] }
2876
- ];
2877
-
2878
- var GraniteCheckboxComponent = /** @class */ (function () {
2879
- function GraniteCheckboxComponent(_focusMonitor) {
2880
- this._focusMonitor = _focusMonitor;
2881
- this.id = null;
2882
- this.checked = false;
2883
- this.disabled = false;
2884
- this.readonly = false;
2885
- this.labelPosition = 'after';
2886
- this.ariaLabel = null;
2887
- this.ariaLabelledby = null;
2888
- this.valueChange = new core.EventEmitter();
2889
- this.checkboxChange = new core.EventEmitter();
2890
- this.checkboxBlur = new core.EventEmitter();
2891
- this._positionBefore = false;
2892
- this._checkboxDisabled = false;
2893
- }
2894
- GraniteCheckboxComponent.prototype.ngOnChanges = function (changes) {
2895
- if (changes.checked) {
2896
- this.checked = coercion.coerceBooleanProperty(changes.checked.currentValue);
2897
- }
2898
- if (changes.disabled) {
2899
- this.disabled = coercion.coerceBooleanProperty(changes.disabled.currentValue);
2900
- }
2901
- if (changes.readonly) {
2902
- this.readonly = coercion.coerceBooleanProperty(changes.readonly.currentValue);
2903
- }
2904
- if (changes.labelPosition != null) {
2905
- this._positionBefore =
2906
- changes.labelPosition.currentValue != null &&
2907
- changes.labelPosition.currentValue === 'before';
2908
- }
2909
- if ((changes.disabled || changes.readonly) &&
2910
- (this.disabled || this.readonly)) {
2911
- this._checkboxDisabled = true;
2912
- }
2913
- };
2914
- GraniteCheckboxComponent.prototype.focus = function (origin, options) {
2915
- if (origin === void 0) { origin = 'program'; }
2916
- this._focusMonitor.focusVia(this._getInputElement(), origin, options);
2917
- };
2918
- GraniteCheckboxComponent.prototype._onBlur = function () {
2919
- this.checkboxBlur.emit();
2920
- };
2921
- GraniteCheckboxComponent.prototype._checkboxChange = function () {
2922
- this.checked = this._getInputElement().checked;
2923
- this.valueChange.emit(this.checked);
2924
- };
2925
- GraniteCheckboxComponent.prototype._checkboxClick = function () {
2926
- this.checkboxChange.emit();
2927
- };
2928
- GraniteCheckboxComponent.prototype._getInputElement = function () {
2929
- return this._inputElement.nativeElement;
2930
- };
2931
- return GraniteCheckboxComponent;
2932
- }());
2933
- GraniteCheckboxComponent.decorators = [
2934
- { type: core.Component, args: [{
2935
- selector: 'granite-checkbox',
2936
- exportAs: 'graniteCheckbox',
2937
- host: {
2938
- class: 'granite-checkbox',
2939
- '[class.granite-checkbox-checked]': 'checked',
2940
- '[class.granite-checkbox-disabled]': 'disabled',
2941
- '[class.granite-checkbox-readonly]': 'readonly',
2942
- '[class.granite-checkbox-label-before]': '_positionBefore',
2943
- },
2944
- template: "<label [attr.for]=\"id\" class=\"granite-checkbox-label\">\n <div class=\"granite-checkbox-box\">\n <input\n #input\n [id]=\"id\"\n class=\"granite-checkbox-input cdk-visually-hidden\"\n role=\"checkbox\"\n type=\"checkbox\"\n [attr.aria-checked]=\"checked.toString()\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.aria-labelledby]=\"ariaLabelledby\"\n [checked]=\"checked\"\n [disabled]=\"_checkboxDisabled\"\n [readonly]=\"readonly\"\n (click)=\"_checkboxClick()\"\n (change)=\"_checkboxChange()\"\n (blur)=\"_onBlur()\"\n />\n <div class=\"granite-checkbox-check\"></div>\n </div>\n <span class=\"granite-checkbox-text\"><ng-content></ng-content></span>\n</label>\n",
2945
- changeDetection: core.ChangeDetectionStrategy.OnPush,
2946
- styles: [".cdk-visually-hidden{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap;outline:0;-webkit-appearance:none;-moz-appearance:none}:host{box-sizing:border-box}:host *,:host :after,:host :before{box-sizing:inherit;cursor:pointer}:host(.granite-checkbox){color:var(--granite-color-text)}:host(.granite-checkbox):not(.granite-checkbox-checked):not(.granite-checkbox-readonly):not(.granite-checkbox-disabled) .granite-checkbox-label:hover .granite-checkbox-box{border-color:var(--granite-color-background-active)}:host(.granite-checkbox-checked):not(.granite-checkbox-readonly):not(.granite-checkbox-disabled) .granite-checkbox-label:hover .granite-checkbox-box{background-color:var(--granite-color-background-active-hover);border-color:var(--granite-color-background-active-hover)}:host(.granite-checkbox-checked) .granite-checkbox-box{border-color:var(--granite-color-background-active);background-color:var(--granite-color-background-active)}:host(.granite-checkbox-checked) .granite-checkbox-box:focus-within{border-color:var(--granite-color-focus)}:host(.granite-checkbox-checked) .granite-checkbox-check{display:flex}:host(.granite-checkbox-checked):not(.granite-checkbox-readonly):not(.granite-checkbox-disabled) .granite-checkbox-box{-webkit-animation:fadeInAnimation .2s;animation:fadeInAnimation .2s;-webkit-animation-iteration-count:1;animation-iteration-count:1}:host(:not(.granite-checkbox-checked)) .granite-checkbox-box{-webkit-animation:fadeOutAnimation .2s;animation:fadeOutAnimation .2s;-webkit-animation-iteration-count:1;animation-iteration-count:1}:host(.granite-checkbox-readonly.granite-checkbox-checked) .granite-checkbox-box{background-color:var(--granite-color-text);border-color:var(--granite-color-text)}:host(.granite-checkbox-readonly.granite-checkbox-checked) .granite-checkbox-box .granite-checkbox-check{border-color:var(--granite-color-background)}:host(.granite-checkbox-disabled) .granite-checkbox-box{opacity:.3;background-color:var(--granite-color-border-soft)}:host(.granite-checkbox-disabled) .granite-checkbox-label{opacity:.6}:host(.granite-checkbox-disabled) *,:host(.granite-checkbox-readonly) *{cursor:default}:host(.granite-checkbox-label-before) .granite-checkbox-label{flex-direction:row-reverse}:host(.granite-checkbox-label-before) .granite-checkbox-text{-webkit-padding-start:0;padding-inline-start:0;-webkit-padding-end:var(--granite-spacing-s);padding-inline-end:var(--granite-spacing-s)}.granite-checkbox-label{display:flex;align-items:center;width:-webkit-max-content;width:-moz-max-content;width:max-content;-webkit-margin-end:var(--granite-spacing-xl);margin-inline-end:var(--granite-spacing-xl)}.granite-checkbox-box{width:1rem;height:1rem;border:solid var(--granite-color-background-inactive);border-width:.0625rem;border-radius:.25rem;display:flex;justify-content:center;position:relative}.granite-checkbox-box:focus-within{border:.0625rem solid var(--granite-color-focus)}.granite-checkbox-check{position:relative;display:none;width:.5625rem;height:.3125rem;background-color:transparent;border:solid var(--granite-color-text-static-light);transform:rotate(-45deg);margin-top:var(--granite-spacing-xs);border-width:0 0 .125rem .125rem}.granite-checkbox-text{-webkit-padding-start:var(--granite-spacing-s);padding-inline-start:var(--granite-spacing-s)}.granite-checkbox-text:empty{display:none}@-webkit-keyframes fadeInAnimation{0%{opacity:0}to{opacity:1}}@keyframes fadeInAnimation{0%{opacity:0}to{opacity:1}}@-webkit-keyframes fadeOutAnimation{0%{opacity:1}to{opacity:0}}@keyframes fadeOutAnimation{0%{opacity:1}to{opacity:0}}"]
2947
- },] }
2948
- ];
2949
- GraniteCheckboxComponent.ctorParameters = function () { return [
2950
- { type: a11y.FocusMonitor }
2951
- ]; };
2952
- GraniteCheckboxComponent.propDecorators = {
2953
- id: [{ type: core.Input }],
2954
- checked: [{ type: core.Input }],
2955
- disabled: [{ type: core.Input }],
2956
- readonly: [{ type: core.Input }],
2957
- labelPosition: [{ type: core.Input }],
2958
- ariaLabel: [{ type: core.Input, args: ['aria-label',] }],
2959
- ariaLabelledby: [{ type: core.Input, args: ['aria-labelledby',] }],
2960
- valueChange: [{ type: core.Output }],
2961
- checkboxChange: [{ type: core.Output }],
2962
- checkboxBlur: [{ type: core.Output }],
2963
- _inputElement: [{ type: core.ViewChild, args: ['input',] }]
2964
- };
2965
-
2966
- var GraniteCheckboxGroupComponent = /** @class */ (function (_super) {
2967
- __extends(GraniteCheckboxGroupComponent, _super);
2968
- function GraniteCheckboxGroupComponent() {
2969
- return _super !== null && _super.apply(this, arguments) || this;
2970
- }
2971
- return GraniteCheckboxGroupComponent;
2972
- }(GraniteRadioCheckboxBase));
2973
- GraniteCheckboxGroupComponent.decorators = [
2974
- { type: core.Component, args: [{
2975
- selector: 'granite-checkbox-group',
2976
- host: {
2977
- class: 'granite-checkbox-group',
2978
- '[attr.role]': '"group"',
2979
- '[attr.aria-labelledby]': 'ariaLabelledby',
2980
- '[class.granite-radio-checkbox-base-layout-horizontal]': 'layout === "horizontal"',
2981
- },
2982
- template: '<ng-content></ng-content>',
2983
- changeDetection: core.ChangeDetectionStrategy.OnPush,
2984
- styles: [":host(.granite-radio-checkbox-base-layout-horizontal){display:flex;align-items:flex-start}"]
2985
- },] }
2986
- ];
2987
-
2988
- var GraniteCheckboxModule = /** @class */ (function () {
2989
- function GraniteCheckboxModule() {
2990
- }
2991
- return GraniteCheckboxModule;
2992
- }());
2993
- GraniteCheckboxModule.decorators = [
2994
- { type: core.NgModule, args: [{
2995
- declarations: [GraniteCheckboxComponent, GraniteCheckboxGroupComponent],
2996
- exports: [GraniteCheckboxComponent, GraniteCheckboxGroupComponent],
2997
- },] }
2998
- ];
2999
-
3000
- var disabledMixin = function (Base) {
3001
- if (Base === void 0) { Base = /** @class */ (function () {
3002
- function class_1() {
3003
- }
3004
- return class_1;
3005
- }()); }
3006
- var Derived = /** @class */ (function (_super) {
3007
- __extends(Derived, _super);
3008
- function Derived() {
3009
- var _this = _super.apply(this, __spread(arguments)) || this;
3010
- _this.disabled = false;
3011
- return _this;
3012
- }
3013
- Derived.prototype.ngOnChanges = function (changes) {
3014
- if (changes.disabled) {
3015
- this.disabled = coercion.coerceBooleanProperty(changes.disabled.currentValue);
3016
- }
3017
- };
3018
- return Derived;
3019
- }(Base));
3020
- Derived.decorators = [
3021
- { type: core.Directive }
3022
- ];
3023
- Derived.propDecorators = {
3024
- disabled: [{ type: core.Input }]
3025
- };
3026
- return Derived;
3027
- };
3028
-
3029
- (function (ButtonSelectors) {
3030
- ButtonSelectors["graniteButton"] = "granite-button";
3031
- ButtonSelectors["granitePrimaryButton"] = "granite-primary-button";
3032
- ButtonSelectors["graniteFlatButton"] = "granite-flat-button";
3033
- ButtonSelectors["graniteToolbarButton"] = "granite-toolbar-button";
3034
- })(exports.ButtonSelectors || (exports.ButtonSelectors = {}));
3035
- var ButtonComponentMixin = disabledMixin();
3036
- var GraniteButtonComponent = /** @class */ (function (_super) {
3037
- __extends(GraniteButtonComponent, _super);
3038
- function GraniteButtonComponent(_focusMonitor, _elementRef) {
3039
- var e_1, _a;
3040
- var _this = _super.call(this) || this;
3041
- _this._focusMonitor = _focusMonitor;
3042
- _this._elementRef = _elementRef;
3043
- _this.toggled = false;
3044
- _this._buttonToggled = false;
3045
- try {
3046
- for (var _b = __values(Object.keys(exports.ButtonSelectors)), _c = _b.next(); !_c.done; _c = _b.next()) {
3047
- var selector = _c.value;
3048
- if (_this._getHostElement().hasAttribute(selector)) {
3049
- _this._getHostElement().classList.add(exports.ButtonSelectors[selector]);
3050
- }
3051
- }
3052
- }
3053
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
3054
- finally {
3055
- try {
3056
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
3057
- }
3058
- finally { if (e_1) throw e_1.error; }
3059
- }
3060
- return _this;
3061
- }
3062
- GraniteButtonComponent.prototype.ngOnChanges = function (changes) {
3063
- _super.prototype.ngOnChanges.call(this, changes);
3064
- if (changes.toggled &&
3065
- (this._getHostElement().classList.contains(exports.ButtonSelectors.graniteFlatButton) ||
3066
- this._getHostElement().classList.contains(exports.ButtonSelectors.graniteToolbarButton))) {
3067
- this._buttonToggled = coercion.coerceBooleanProperty(changes.toggled.currentValue);
3068
- }
3069
- };
3070
- GraniteButtonComponent.prototype.focus = function (origin, options) {
3071
- if (origin === void 0) { origin = 'program'; }
3072
- this._focusMonitor.focusVia(this._getHostElement(), origin, options);
3073
- };
3074
- GraniteButtonComponent.prototype._getHostElement = function () {
3075
- return this._elementRef.nativeElement;
3076
- };
3077
- return GraniteButtonComponent;
3078
- }(ButtonComponentMixin));
3079
- GraniteButtonComponent.decorators = [
3080
- { type: core.Component, args: [{
3081
- // eslint-disable-next-line @angular-eslint/component-selector
3082
- selector: "button[graniteButton],\n button[granitePrimaryButton],\n button[graniteFlatButton],\n button[graniteToolbarButton]\n ",
3083
- host: {
3084
- class: 'granite-button-base',
3085
- '[class.granite-button-disabled]': 'disabled',
3086
- '[class.granite-button-toggled]': '_buttonToggled',
3087
- '[attr.disabled]': 'disabled || null',
3088
- },
3089
- exportAs: 'graniteButton',
3090
- template: '<ng-content></ng-content>',
3091
- inputs: ['disabled'],
3092
- changeDetection: core.ChangeDetectionStrategy.OnPush,
3093
- styles: [":host{box-sizing:border-box}:host *,:host :after,:host :before{box-sizing:inherit;cursor:pointer}button:host{background-color:inherit;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:none;font:inherit;border-radius:inherit;height:inherit;font-weight:inherit;line-height:inherit;color:inherit;margin:inherit;cursor:pointer;padding:inherit}a:host,button:host{outline:none}:host.granite-button-base{border-radius:.25rem;font-size:var(--granite-font-size-body-small);font-weight:var(--granite-font-weight-regular);padding:var(--granite-spacing-s) var(--granite-spacing-s);position:relative;line-height:var(--granite-font-size-body);display:flex;justify-content:center;align-items:center;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}:host:focus:not(.granite-button-disabled):not(:active){outline-offset:-2px;outline-width:.125rem;outline-color:var(--granite-color-focus);outline-style:solid}button:host.granite-button{background-color:var(--granite-color-background-variant);color:var(--granite-color-text);outline:.0625rem solid var(--granite-color-border-soft);outline-offset:-1px}button:host.granite-button:hover:not(.granite-button-disabled){background-color:var(--granite-color-background-active-hover);color:var(--granite-color-text-on-active);outline:none}button:host.granite-button:active:not(.granite-button-disabled){background-color:var(--granite-color-background-active-pressed);color:var(--granite-color-text-on-active);outline:none}button:host.granite-button.granite-button-toggled{background-color:none;color:none;outline:none}button:host.granite-primary-button{background-color:var(--granite-color-background-active);color:var(--granite-color-text-on-active);outline:none;outline-offset:-1px}button:host.granite-primary-button:hover:not(.granite-button-disabled){background-color:var(--granite-color-background-active-hover);color:none;outline:none}button:host.granite-primary-button:active:not(.granite-button-disabled){background-color:var(--granite-color-background-active-pressed);color:none;outline:none}button:host.granite-primary-button.granite-button-toggled{background-color:none;color:none;outline:none}button:host.granite-flat-button{background-color:transparent;color:var(--granite-color-text);outline:none;outline-offset:-1px}button:host.granite-flat-button:hover:not(.granite-button-disabled){background-color:var(--granite-color-background-active-hover);color:var(--granite-color-text-on-active);outline:none}button:host.granite-flat-button:active:not(.granite-button-disabled){background-color:var(--granite-color-background-active-pressed);color:var(--granite-color-text-on-active);outline:none}button:host.granite-flat-button.granite-button-toggled{background-color:var(--granite-color-background-selected);color:var(--granite-color-focus);outline:none}button:host.granite-toolbar-button{background-color:var(--granite-color-background);color:var(--granite-color-text);outline:.0625rem solid var(--granite-color-border-soft);outline-offset:-1px}button:host.granite-toolbar-button:hover:not(.granite-button-disabled){background-color:var(--granite-color-background-active-hover);color:var(--granite-color-text-on-active);outline:none}button:host.granite-toolbar-button:active:not(.granite-button-disabled){background-color:var(--granite-color-background-active-pressed);color:var(--granite-color-text-on-active);outline:none}button:host.granite-toolbar-button.granite-button-toggled{background-color:var(--granite-color-background-selected);color:var(--granite-color-focus);outline:none}button:host.granite-button-disabled,button:host.granite-button-disabled:active,button:host.granite-button-disabled:focus,button:host.granite-button-disabled:hover{opacity:.4;cursor:default}a:host.granite-button{background-color:var(--granite-color-background);color:var(--granite-color-text-link);outline:.0625rem solid var(--granite-color-border-soft);outline-offset:-1px}a:host.granite-button:hover:not(.granite-button-disabled){background-color:var(--granite-color-background-active-hover);color:var(--granite-color-text-on-active);outline:none}a:host.granite-button:active:not(.granite-button-disabled){background-color:var(--granite-color-background-active-pressed);color:var(--granite-color-text-on-active);outline:none}a:host.granite-button.granite-button-toggled{background-color:none;color:none;outline:none}a:host.granite-flat-button{background-color:transparent;color:var(--granite-color-text-link);outline:none;outline-offset:-1px}a:host.granite-flat-button:hover:not(.granite-button-disabled){background-color:var(--granite-color-background-active-hover);color:var(--granite-color-text-on-active);outline:none}a:host.granite-flat-button:active:not(.granite-button-disabled){background-color:var(--granite-color-background-active-pressed);color:var(--granite-color-text-on-active);outline:none}a:host.granite-flat-button.granite-button-toggled{background-color:none;color:none;outline:none}a:host.granite-button-disabled,a:host.granite-button-disabled:active,a:host.granite-button-disabled:focus,a:host.granite-button-disabled:hover{opacity:.4;text-decoration:none;cursor:default;pointer-events:none;-moz-user-select:none;-webkit-user-select:none;user-select:none}"]
3094
- },] }
3095
- ];
3096
- GraniteButtonComponent.ctorParameters = function () { return [
3097
- { type: a11y.FocusMonitor },
3098
- { type: core.ElementRef }
3099
- ]; };
3100
- GraniteButtonComponent.propDecorators = {
3101
- toggled: [{ type: core.Input }]
3102
- };
3103
- var GraniteAnchorComponent = /** @class */ (function (_super) {
3104
- __extends(GraniteAnchorComponent, _super);
3105
- function GraniteAnchorComponent(_focusMonitor, _elementRef) {
3106
- var _this = _super.call(this, _focusMonitor, _elementRef) || this;
3107
- _this._focusMonitor = _focusMonitor;
3108
- _this._elementRef = _elementRef;
3109
- return _this;
3110
- }
3111
- GraniteAnchorComponent.prototype._anchorClick = function (event) {
3112
- if (this.disabled) {
3113
- event.preventDefault();
3114
- }
3115
- };
3116
- GraniteAnchorComponent.prototype.ngOnChanges = function (changes) {
3117
- _super.prototype.ngOnChanges.call(this, changes);
3118
- };
3119
- return GraniteAnchorComponent;
3120
- }(GraniteButtonComponent));
3121
- GraniteAnchorComponent.decorators = [
3122
- { type: core.Component, args: [{
3123
- // eslint-disable-next-line @angular-eslint/component-selector
3124
- selector: "a[graniteButton],\n a[graniteFlatButton]",
3125
- host: {
3126
- class: 'granite-button-base',
3127
- '[attr.tabindex]': 'disabled ? -1 : 0',
3128
- '[class.granite-button-disabled]': 'disabled',
3129
- },
3130
- exportAs: 'graniteAnchor',
3131
- template: '<ng-content></ng-content>',
3132
- inputs: ['disabled'],
3133
- changeDetection: core.ChangeDetectionStrategy.OnPush,
3134
- styles: [":host{box-sizing:border-box}:host *,:host :after,:host :before{box-sizing:inherit;cursor:pointer}button:host{background-color:inherit;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:none;font:inherit;border-radius:inherit;height:inherit;font-weight:inherit;line-height:inherit;color:inherit;margin:inherit;cursor:pointer;padding:inherit}a:host,button:host{outline:none}:host.granite-button-base{border-radius:.25rem;font-size:var(--granite-font-size-body-small);font-weight:var(--granite-font-weight-regular);padding:var(--granite-spacing-s) var(--granite-spacing-s);position:relative;line-height:var(--granite-font-size-body);display:flex;justify-content:center;align-items:center;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}:host:focus:not(.granite-button-disabled):not(:active){outline-offset:-2px;outline-width:.125rem;outline-color:var(--granite-color-focus);outline-style:solid}button:host.granite-button{background-color:var(--granite-color-background-variant);color:var(--granite-color-text);outline:.0625rem solid var(--granite-color-border-soft);outline-offset:-1px}button:host.granite-button:hover:not(.granite-button-disabled){background-color:var(--granite-color-background-active-hover);color:var(--granite-color-text-on-active);outline:none}button:host.granite-button:active:not(.granite-button-disabled){background-color:var(--granite-color-background-active-pressed);color:var(--granite-color-text-on-active);outline:none}button:host.granite-button.granite-button-toggled{background-color:none;color:none;outline:none}button:host.granite-primary-button{background-color:var(--granite-color-background-active);color:var(--granite-color-text-on-active);outline:none;outline-offset:-1px}button:host.granite-primary-button:hover:not(.granite-button-disabled){background-color:var(--granite-color-background-active-hover);color:none;outline:none}button:host.granite-primary-button:active:not(.granite-button-disabled){background-color:var(--granite-color-background-active-pressed);color:none;outline:none}button:host.granite-primary-button.granite-button-toggled{background-color:none;color:none;outline:none}button:host.granite-flat-button{background-color:transparent;color:var(--granite-color-text);outline:none;outline-offset:-1px}button:host.granite-flat-button:hover:not(.granite-button-disabled){background-color:var(--granite-color-background-active-hover);color:var(--granite-color-text-on-active);outline:none}button:host.granite-flat-button:active:not(.granite-button-disabled){background-color:var(--granite-color-background-active-pressed);color:var(--granite-color-text-on-active);outline:none}button:host.granite-flat-button.granite-button-toggled{background-color:var(--granite-color-background-selected);color:var(--granite-color-focus);outline:none}button:host.granite-toolbar-button{background-color:var(--granite-color-background);color:var(--granite-color-text);outline:.0625rem solid var(--granite-color-border-soft);outline-offset:-1px}button:host.granite-toolbar-button:hover:not(.granite-button-disabled){background-color:var(--granite-color-background-active-hover);color:var(--granite-color-text-on-active);outline:none}button:host.granite-toolbar-button:active:not(.granite-button-disabled){background-color:var(--granite-color-background-active-pressed);color:var(--granite-color-text-on-active);outline:none}button:host.granite-toolbar-button.granite-button-toggled{background-color:var(--granite-color-background-selected);color:var(--granite-color-focus);outline:none}button:host.granite-button-disabled,button:host.granite-button-disabled:active,button:host.granite-button-disabled:focus,button:host.granite-button-disabled:hover{opacity:.4;cursor:default}a:host.granite-button{background-color:var(--granite-color-background);color:var(--granite-color-text-link);outline:.0625rem solid var(--granite-color-border-soft);outline-offset:-1px}a:host.granite-button:hover:not(.granite-button-disabled){background-color:var(--granite-color-background-active-hover);color:var(--granite-color-text-on-active);outline:none}a:host.granite-button:active:not(.granite-button-disabled){background-color:var(--granite-color-background-active-pressed);color:var(--granite-color-text-on-active);outline:none}a:host.granite-button.granite-button-toggled{background-color:none;color:none;outline:none}a:host.granite-flat-button{background-color:transparent;color:var(--granite-color-text-link);outline:none;outline-offset:-1px}a:host.granite-flat-button:hover:not(.granite-button-disabled){background-color:var(--granite-color-background-active-hover);color:var(--granite-color-text-on-active);outline:none}a:host.granite-flat-button:active:not(.granite-button-disabled){background-color:var(--granite-color-background-active-pressed);color:var(--granite-color-text-on-active);outline:none}a:host.granite-flat-button.granite-button-toggled{background-color:none;color:none;outline:none}a:host.granite-button-disabled,a:host.granite-button-disabled:active,a:host.granite-button-disabled:focus,a:host.granite-button-disabled:hover{opacity:.4;text-decoration:none;cursor:default;pointer-events:none;-moz-user-select:none;-webkit-user-select:none;user-select:none}"]
3135
- },] }
3136
- ];
3137
- GraniteAnchorComponent.ctorParameters = function () { return [
3138
- { type: a11y.FocusMonitor },
3139
- { type: core.ElementRef }
3140
- ]; };
3141
- GraniteAnchorComponent.propDecorators = {
3142
- _anchorClick: [{ type: core.HostListener, args: ['click', ['$event'],] }]
3143
- };
3144
-
3145
- var GraniteButtonModule = /** @class */ (function () {
3146
- function GraniteButtonModule() {
3147
- }
3148
- return GraniteButtonModule;
3149
- }());
3150
- GraniteButtonModule.decorators = [
3151
- { type: core.NgModule, args: [{
3152
- declarations: [GraniteButtonComponent, GraniteAnchorComponent],
3153
- exports: [GraniteButtonComponent, GraniteAnchorComponent],
3154
- },] }
3155
- ];
3156
-
3157
- var GraniteTableColumnDirective = /** @class */ (function () {
3158
- function GraniteTableColumnDirective() {
3159
- }
3160
- return GraniteTableColumnDirective;
3161
- }());
3162
- GraniteTableColumnDirective.decorators = [
3163
- { type: core.Directive, args: [{
3164
- // eslint-disable-next-line @angular-eslint/directive-selector
3165
- selector: 'granite-table-column',
3166
- },] }
3167
- ];
3168
- GraniteTableColumnDirective.propDecorators = {
3169
- name: [{ type: core.Input }],
3170
- title: [{ type: core.Input }],
3171
- staticType: [{ type: core.Input }],
3172
- tableCellTemplateRef: [{ type: core.ContentChild, args: ['graniteTableCellTemplate', { static: false },] }]
3173
- };
3174
-
3175
- var TableConstants = /** @class */ (function () {
3176
- function TableConstants() {
3177
- }
3178
- return TableConstants;
3179
- }());
3180
- TableConstants.CELL_ID_PREFIX = 'granite-cell';
3181
-
3182
- var GraniteTableComponent = /** @class */ (function () {
3183
- function GraniteTableComponent() {
3184
- this.ariaLabel = null;
3185
- this.cellIdPrefix = TableConstants.CELL_ID_PREFIX;
3186
- }
3187
- GraniteTableComponent.prototype.ngAfterContentInit = function () {
3188
- this.columns = this.tableColumnsComponent.toArray();
3189
- this.renderedColumns = this.columns.map(function (column) { return column.name; });
3190
- };
3191
- return GraniteTableComponent;
3192
- }());
3193
- GraniteTableComponent.decorators = [
3194
- { type: core.Component, args: [{
3195
- selector: 'granite-table',
3196
- template: "<cdk-table\n [dataSource]=\"dataSource\"\n multiTemplateDataRows\n [trackBy]=\"trackBy\"\n [attr.aria-label]=\"ariaLabel\"\n>\n <ng-container\n *ngFor=\"let column of columns; index as columnI\"\n [cdkColumnDef]=\"column.name\"\n >\n <!-- Cell Header -->\n <cdk-header-cell *cdkHeaderCellDef graniteTableHeaderCell>\n {{ (column.title ? column.title : column.name) | graniteTitle }}\n </cdk-header-cell>\n\n <!-- Cell Data -->\n <cdk-cell\n graniteTableDataCell\n *cdkCellDef=\"let row; let rowI = dataIndex\"\n [id]=\"cellIdPrefix + '-' + rowI + '-' + columnI\"\n [value]=\"row[column.name]\"\n [rowIndex]=\"rowI\"\n [columnIndex]=\"columnI\"\n [staticType]=\"column.staticType\"\n [column]=\"column\"\n [tableCellTemplateRef]=\"column.tableCellTemplateRef\"\n [row]=\"row\"\n ></cdk-cell>\n </ng-container>\n\n <cdk-header-row *cdkHeaderRowDef=\"renderedColumns\"></cdk-header-row>\n <cdk-row\n *cdkRowDef=\"let row; let rowI = dataIndex; columns: renderedColumns\"\n [attr.aria-rowindex]=\"rowI + 1\"\n ></cdk-row>\n</cdk-table>\n",
3197
- changeDetection: core.ChangeDetectionStrategy.OnPush,
3198
- styles: [":host{box-sizing:border-box}:host *,:host :after,:host :before{box-sizing:inherit}cdk-table{flex-direction:column;background-color:var(--granite-color-background-variant)}cdk-header-row,cdk-row,cdk-table{display:flex}cdk-cell,cdk-header-cell{flex:1;height:2.5rem}cdk-cell{border-top:1px solid var(--granite-color-border-soft)}"]
3199
- },] }
3200
- ];
3201
- GraniteTableComponent.propDecorators = {
3202
- dataSource: [{ type: core.Input }],
3203
- trackBy: [{ type: core.Input }],
3204
- ariaLabel: [{ type: core.Input, args: ['aria-label',] }],
3205
- tableColumnsComponent: [{ type: core.ContentChildren, args: [GraniteTableColumnDirective,] }]
3206
- };
3207
-
3208
- var GraniteCell = /** @class */ (function () {
3209
- function GraniteCell() {
3210
- }
3211
- return GraniteCell;
3212
- }());
3213
- GraniteCell.decorators = [
3214
- { type: core.Directive }
3215
- ];
3216
- GraniteCell.propDecorators = {
3217
- id: [{ type: core.Input }],
3218
- column: [{ type: core.Input }]
3219
- };
3220
-
3221
- var GraniteTableDataCellComponent = /** @class */ (function (_super) {
3222
- __extends(GraniteTableDataCellComponent, _super);
3223
- function GraniteTableDataCellComponent() {
3224
- return _super !== null && _super.apply(this, arguments) || this;
3225
- }
3226
- return GraniteTableDataCellComponent;
3227
- }(GraniteCell));
3228
- GraniteTableDataCellComponent.decorators = [
3229
- { type: core.Component, args: [{
3230
- // eslint-disable-next-line @angular-eslint/component-selector
3231
- selector: 'cdk-cell[graniteTableDataCell]',
3232
- template: "<span class=\"granite-table-data-cell-static-container\">\n <ng-template\n [ngTemplateOutlet]=\"tableCellTemplateRef || defaultTableCellTemplate\"\n [ngTemplateOutletContext]=\"{\n data: value,\n rowIndex: rowIndex,\n columnIndex: columnIndex,\n column: column,\n row: row\n }\"\n ></ng-template>\n</span>\n\n<ng-template #defaultTableCellTemplate>\n <ng-container [ngSwitch]=\"staticType\">\n <ng-container *ngSwitchCase=\"'badge'\">\n <granite-badge>{{ value }}</granite-badge>\n </ng-container>\n <ng-container *ngSwitchDefault>{{ value }}</ng-container>\n </ng-container>\n</ng-template>\n",
3233
- styles: [":host{box-sizing:border-box}:host *,:host :after,:host :before{box-sizing:inherit}.granite-table-data-cell-static-container{padding:var(--granite-spacing-s);height:inherit;font-size:var(--granite-font-size-body-small);line-height:var(--granite-line-height-regular);display:flex;justify-content:center;align-items:center;color:var(--granite-color-text)}"]
3234
- },] }
3235
- ];
3236
- GraniteTableDataCellComponent.propDecorators = {
3237
- value: [{ type: core.Input }],
3238
- staticType: [{ type: core.Input }],
3239
- rowIndex: [{ type: core.Input }],
3240
- columnIndex: [{ type: core.Input }],
3241
- tableCellTemplateRef: [{ type: core.Input }],
3242
- row: [{ type: core.Input }]
3243
- };
3244
-
3245
- var GraniteTableHeaderCellComponent = /** @class */ (function (_super) {
3246
- __extends(GraniteTableHeaderCellComponent, _super);
3247
- function GraniteTableHeaderCellComponent() {
3248
- return _super !== null && _super.apply(this, arguments) || this;
3249
- }
3250
- return GraniteTableHeaderCellComponent;
3251
- }(GraniteCell));
3252
- GraniteTableHeaderCellComponent.decorators = [
3253
- { type: core.Component, args: [{
3254
- // eslint-disable-next-line @angular-eslint/component-selector
3255
- selector: 'cdk-header-cell[graniteTableHeaderCell]',
3256
- template: "<span class=\"granite-table-header-cell-title\">\n <ng-content></ng-content>\n</span>\n",
3257
- styles: [":host{box-sizing:border-box}:host *,:host :after,:host :before{box-sizing:inherit}.granite-table-header-cell-title{padding:var(--granite-spacing-s);height:inherit;font-size:var(--granite-font-size-micro);line-height:var(--granite-line-height-flowing);letter-spacing:.015em;font-weight:400;display:flex;justify-content:center;align-items:center;color:var(--granite-color-text-weak)}"]
3258
- },] }
3259
- ];
3260
-
3261
- var GraniteTitlePipe = /** @class */ (function () {
3262
- function GraniteTitlePipe() {
3263
- }
3264
- GraniteTitlePipe.prototype.transform = function (value) {
3265
- var words = value.split(/(?=[A-Z ])/);
3266
- return words
3267
- .map(function (word) { return word.trim(); })
3268
- .filter(Boolean)
3269
- .map(function (word) { return word.charAt(0).toLocaleUpperCase() + word.slice(1); })
3270
- .join(' ');
3271
- };
3272
- return GraniteTitlePipe;
3273
- }());
3274
- GraniteTitlePipe.decorators = [
3275
- { type: core.Pipe, args: [{
3276
- name: 'graniteTitle',
3277
- },] }
3278
- ];
3279
-
3280
- var PurePipesModule = /** @class */ (function () {
3281
- function PurePipesModule() {
3282
- }
3283
- return PurePipesModule;
3284
- }());
3285
- PurePipesModule.decorators = [
3286
- { type: core.NgModule, args: [{
3287
- exports: [GraniteTitlePipe],
3288
- declarations: [GraniteTitlePipe],
3289
- },] }
3290
- ];
3291
-
3292
- var GraniteTableModule = /** @class */ (function () {
3293
- function GraniteTableModule() {
3294
- }
3295
- return GraniteTableModule;
3296
- }());
3297
- GraniteTableModule.decorators = [
3298
- { type: core.NgModule, args: [{
3299
- declarations: [
3300
- GraniteTableComponent,
3301
- GraniteTableDataCellComponent,
3302
- GraniteTableHeaderCellComponent,
3303
- GraniteTableColumnDirective,
3304
- ],
3305
- imports: [common.CommonModule, table.CdkTableModule, GraniteBadgeModule, PurePipesModule],
3306
- exports: [GraniteTableComponent, GraniteTableColumnDirective],
3307
- },] }
3308
- ];
3309
-
3310
- var GRANITE_INPUT_INCLUDES = ['text', 'number', 'password', 'textarea'];
3311
- var GraniteInputFieldComponent = /** @class */ (function () {
3312
- function GraniteInputFieldComponent(_focusMonitor) {
3313
- this._focusMonitor = _focusMonitor;
3314
- this.id = null;
3315
- this.name = null;
3316
- this.type = 'text';
3317
- this.value = '';
3318
- this.required = false;
3319
- this.readonly = false;
3320
- this.invalid = false;
3321
- this.disabled = false;
3322
- this.placeholder = '';
3323
- this.maxlength = 255;
3324
- this.countcharacters = false;
3325
- this.ariaLabel = null;
3326
- this.ariaLabelledby = null;
3327
- this.valueChange = new core.EventEmitter();
3328
- this._supported = true;
3329
- this._empty = false;
3330
- this._passwordFieldIcon = 'view';
3331
- this._passwordField = false;
3332
- this._currentCharCount = 0;
3333
- this._passwordToggled = false;
3334
- }
3335
- GraniteInputFieldComponent.prototype.ngOnInit = function () {
3336
- this._validateType();
3337
- this._passwordField = this.type == 'password';
3338
- this._empty = this.value == null || this.value === '';
3339
- };
3340
- GraniteInputFieldComponent.prototype.ngOnChanges = function (changes) {
3341
- if (changes.required) {
3342
- this.required = coercion.coerceBooleanProperty(changes.required.currentValue);
3343
- }
3344
- if (changes.readonly) {
3345
- this.readonly = coercion.coerceBooleanProperty(changes.readonly.currentValue);
3346
- }
3347
- if (changes.invalid) {
3348
- this.invalid = coercion.coerceBooleanProperty(changes.invalid.currentValue);
3349
- }
3350
- if (changes.disabled) {
3351
- this.disabled = coercion.coerceBooleanProperty(changes.disabled.currentValue);
3352
- }
3353
- if (changes.countcharacters) {
3354
- this.countcharacters = coercion.coerceBooleanProperty(changes.countcharacters.currentValue);
3355
- }
3356
- if (changes.value) {
3357
- this._empty = this.value == null || this.value === '';
3358
- }
3359
- if (changes.type) {
3360
- this._validateType();
3361
- }
3362
- };
3363
- GraniteInputFieldComponent.prototype.focus = function (origin, options) {
3364
- if (origin === void 0) { origin = 'program'; }
3365
- if (this.type === 'text') {
3366
- this._focusMonitor.focusVia(this._getInputElement(), origin, options);
3367
- }
3368
- else if (this.type === 'textarea') {
3369
- this._focusMonitor.focusVia(this._getTextareaElement(), origin, options);
3370
- }
3371
- };
3372
- GraniteInputFieldComponent.prototype._togglePassword = function () {
3373
- if (this._passwordToggled) {
3374
- this._passwordToggled = false;
3375
- this.type = 'password';
3376
- this._passwordFieldIcon = 'view';
3377
- }
3378
- else {
3379
- this._passwordToggled = true;
3380
- this.type = 'text';
3381
- this._passwordFieldIcon = 'view-disabled';
3382
- }
3383
- };
3384
- GraniteInputFieldComponent.prototype._onKeyUp = function (event) {
3385
- var inputEvent = event.target;
3386
- this._applyCharacterCount(inputEvent.value);
3387
- this._empty = inputEvent.value == null || inputEvent.value === '';
3388
- this.valueChange.emit(inputEvent.value);
3389
- };
3390
- GraniteInputFieldComponent.prototype._onInput = function (event) {
3391
- var inputEvent = event.target;
3392
- this._empty = inputEvent.value == null || inputEvent.value === '';
3393
- this.valueChange.emit(inputEvent.value);
3394
- };
3395
- GraniteInputFieldComponent.prototype._validateType = function () {
3396
- if (GRANITE_INPUT_INCLUDES.indexOf(this.type) < 0) {
3397
- this._supported = false;
3398
- throw Error("Input type \"" + this.type + "\" isn't supported by graniteInputField.");
3399
- }
3400
- };
3401
- GraniteInputFieldComponent.prototype._applyCharacterCount = function (inputString) {
3402
- if (this.countcharacters) {
3403
- this._currentCharCount = inputString.length;
3404
- if (this._currentCharCount > this.maxlength) {
3405
- inputString = inputString.slice(0, this.maxlength);
3406
- this._currentCharCount = this.maxlength;
3407
- }
3408
- }
3409
- };
3410
- GraniteInputFieldComponent.prototype._getInputElement = function () {
3411
- return this._inputElement.nativeElement;
3412
- };
3413
- GraniteInputFieldComponent.prototype._getTextareaElement = function () {
3414
- return this._textareaElement.nativeElement;
3415
- };
3416
- return GraniteInputFieldComponent;
3417
- }());
3418
- GraniteInputFieldComponent.decorators = [
3419
- { type: core.Component, args: [{
3420
- selector: 'granite-input-field',
3421
- exportAs: 'graniteInputField',
3422
- template: "<div\n *ngIf=\"_supported\"\n class=\"granite-input-container\"\n [class.granite-input-disabled]=\"disabled\"\n [class.granite-input-readonly]=\"readonly\"\n [class.granite-input-disabled]=\"disabled\"\n [class.granite-input-readonly]=\"readonly\"\n>\n <div\n class=\"granite-input-top-row\"\n [class.granite-input-required]=\"required\"\n [class.granite-input-empty]=\"_empty\"\n [class.granite-input-disabled]=\"disabled\"\n [class.granite-input-readonly]=\"readonly\"\n >\n <div\n *ngIf=\"prefixicon\"\n class=\"granite-input-prepend\"\n [class.granite-input-required]=\"required\"\n [class.granite-input-empty]=\"_empty\"\n >\n <granite-icon class=\"granite-input-prepend-icon\">\n {{ prefixicon }}\n </granite-icon>\n </div>\n\n <ng-container\n *ngIf=\"type != 'textarea'; then inputElement; else textareaElement\"\n ></ng-container>\n\n <ng-template #inputElement>\n <input\n #input\n [id]=\"id\"\n class=\"granite-input-base\"\n [class.granite-input-invalid]=\"invalid\"\n [class.granite-input-empty]=\"_empty\"\n [name]=\"name\"\n [attr.type]=\"type\"\n [required]=\"required\"\n [readonly]=\"readonly\"\n [disabled]=\"disabled\"\n [placeholder]=\"placeholder\"\n [attr.maxlength]=\"maxlength\"\n [value]=\"value\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.aria-labelledby]=\"ariaLabelledby\"\n [attr.aria-invalid]=\"invalid\"\n (keyup)=\"_onKeyUp($event)\"\n (input)=\"_onInput($event)\"\n />\n </ng-template>\n\n <button\n *ngIf=\"_passwordField\"\n class=\"granite-input-append\"\n [class.granite-input-required]=\"required\"\n [class.granite-input-empty]=\"_empty\"\n (click)=\"_togglePassword()\"\n >\n <granite-icon class=\"granite-input-password-toggle-icon\">\n {{ _passwordFieldIcon }}\n </granite-icon>\n </button>\n\n <ng-template #textareaElement>\n <textarea\n #textarea\n [id]=\"id\"\n class=\"granite-input-base granite-text-area\"\n [class.granite-input-invalid]=\"invalid\"\n [class.granite-input-empty]=\"_empty\"\n rows=\"1\"\n [name]=\"name\"\n [attr.type]=\"type\"\n [required]=\"required\"\n [readonly]=\"readonly\"\n [disabled]=\"disabled\"\n [placeholder]=\"placeholder\"\n [value]=\"value\"\n [attr.maxlength]=\"maxlength\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.aria-labelledby]=\"ariaLabelledby\"\n [attr.aria-required]=\"required\"\n [attr.aria-invalid]=\"invalid\"\n (keyup)=\"_onKeyUp($event)\"\n (input)=\"_onInput($event)\"\n ></textarea>\n </ng-template>\n\n <div\n class=\"granite-input-hover-bar\"\n [class.granite-input-invalid]=\"invalid\"\n [class.granite-input-empty]=\"_empty\"\n ></div>\n </div>\n\n <div *ngIf=\"countcharacters\" class=\"granite-input-bottom-row\">\n <div class=\"granite-input-char-count\">\n {{ _currentCharCount }}/{{ maxlength }}\n </div>\n </div>\n</div>\n",
3423
- host: {
3424
- class: 'granite-input-field',
3425
- },
3426
- changeDetection: core.ChangeDetectionStrategy.OnPush,
3427
- styles: [":host{transition:all .2s ease-out;width:14.5rem;box-sizing:border-box}:host *,:host :after,:host :before{box-sizing:inherit}.granite-input-container{width:inherit;font-size:var(--granite-font-size-body-small)}.granite-input-container .granite-input-top-row{display:inline-flex;width:inherit;position:relative;background:var(--granite-color-background)}.granite-input-container .granite-input-top-row:hover .granite-input-hover-bar{height:.125rem}.granite-input-container .granite-input-top-row:hover .granite-input-hover-bar.granite-input-invalid.granite-input-empty{background-color:var(--granite-color-focus)}.granite-input-container .granite-input-top-row .granite-text-area{min-width:14.5rem;min-height:2rem}.granite-input-container .granite-input-top-row.granite-input-disabled,.granite-input-container .granite-input-top-row.granite-input-readonly{background-color:transparent;box-shadow:none}.granite-input-container .granite-input-top-row.granite-input-disabled .granite-input-hover-bar,.granite-input-container .granite-input-top-row.granite-input-readonly .granite-input-hover-bar{background-color:transparent}.granite-input-container .granite-input-top-row .granite-input-base{-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;border:none;background-color:var(--granite-color-background-input);padding:var(--granite-spacing-s);width:inherit;color:var(--granite-color-text);font:inherit;font-weight:var(--granite-font-weight-regular);line-height:var(--granite-line-height-regular)}.granite-input-container .granite-input-top-row .granite-input-base:required.granite-input-empty{background-color:var(--granite-color-background-failure)}.granite-input-container .granite-input-top-row .granite-input-base:required::-moz-placeholder{color:var(--granite-color-text-weak)}.granite-input-container .granite-input-top-row .granite-input-base:required::placeholder{color:var(--granite-color-text-weak)}.granite-input-container .granite-input-top-row .granite-input-base:-moz-read-only{background-color:transparent}.granite-input-container .granite-input-top-row .granite-input-base:read-only{background-color:transparent}.granite-input-container .granite-input-top-row .granite-input-base:disabled{opacity:.3}.granite-input-container .granite-input-top-row .granite-input-base::-moz-placeholder{color:var(--granite-color-text-hint)}.granite-input-container .granite-input-top-row .granite-input-base::placeholder{color:var(--granite-color-text-hint)}.granite-input-container .granite-input-top-row .granite-input-base:hover::-moz-placeholder{color:var(--granite-color-text)}.granite-input-container .granite-input-top-row .granite-input-base:hover::placeholder{color:var(--granite-color-text)}.granite-input-container .granite-input-top-row .granite-input-base:focus{box-shadow:inset 0 .125rem var(--granite-color-focus),inset .125rem 0 var(--granite-color-focus),inset -.125rem 0 var(--granite-color-focus),inset 0 -.125rem var(--granite-color-focus)}.granite-input-container .granite-input-top-row .granite-input-base:focus.granite-input-invalid{box-shadow:inset 0 -.125rem var(--granite-color-signal-failure),inset 0 .125rem var(--granite-color-focus),inset .125rem 0 var(--granite-color-focus),inset -.125rem 0 var(--granite-color-focus)}.granite-input-container .granite-input-top-row .granite-input-base:focus::-moz-placeholder{color:transparent}.granite-input-container .granite-input-top-row .granite-input-base:focus::placeholder{color:transparent}.granite-input-container .granite-input-top-row .granite-input-hover-bar{height:.0625rem;background-color:var(--granite-color-border-hard);position:absolute;width:inherit;bottom:0}.granite-input-container .granite-input-top-row .granite-input-hover-bar.granite-input-invalid{background-color:var(--granite-color-signal-failure)}.granite-input-container .granite-input-top-row:focus-within .granite-input-hover-bar{background-color:transparent}.granite-input-container .granite-input-prepend{display:flex;align-items:center;padding:0 var(--granite-spacing-s);background:var(--granite-color-background-input)}.granite-input-container .granite-input-prepend .granite-input-prepend-icon{width:1rem;height:1rem;color:var(--granite-color-text);box-shadow:none}.granite-input-container .granite-input-prepend.granite-input-required.granite-input-empty{background-color:var(--granite-color-background-failure)}.granite-input-container .granite-input-append{-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;border:none;background-color:var(--granite-color-background-input);position:relative}.granite-input-container .granite-input-append:focus{box-shadow:inset 0 .125rem var(--granite-color-focus),inset .125rem 0 var(--granite-color-focus),inset -.125rem 0 var(--granite-color-focus),inset 0 -.125rem var(--granite-color-focus)}.granite-input-container .granite-input-append .granite-input-password-toggle-icon{width:-webkit-max-content;width:-moz-max-content;width:max-content;height:-webkit-max-content;height:-moz-max-content;height:max-content;color:var(--granite-color-text);box-shadow:none}.granite-input-container .granite-input-append.granite-input-required.granite-input-empty{background-color:var(--granite-color-background-failure)}.granite-input-container .granite-input-bottom-row{box-shadow:none}.granite-input-container .granite-input-char-count{background:var(--granite-color-background-warning);border-radius:0 0 .25rem .25rem;padding:var(--granite-spacing-s);background-size:contain;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;box-shadow:none}.granite-input-container.granite-input-disabled,.granite-input-container.granite-input-readonly{background-color:transparent}"]
3428
- },] }
3429
- ];
3430
- GraniteInputFieldComponent.ctorParameters = function () { return [
3431
- { type: a11y.FocusMonitor }
3432
- ]; };
3433
- GraniteInputFieldComponent.propDecorators = {
3434
- id: [{ type: core.Input }],
3435
- name: [{ type: core.Input }],
3436
- type: [{ type: core.Input }],
3437
- value: [{ type: core.Input }],
3438
- required: [{ type: core.Input }],
3439
- readonly: [{ type: core.Input }],
3440
- invalid: [{ type: core.Input }],
3441
- disabled: [{ type: core.Input }],
3442
- placeholder: [{ type: core.Input }],
3443
- prefixicon: [{ type: core.Input }],
3444
- maxlength: [{ type: core.Input }],
3445
- countcharacters: [{ type: core.Input }],
3446
- ariaLabel: [{ type: core.Input, args: ['aria-label',] }],
3447
- ariaLabelledby: [{ type: core.Input, args: ['aria-labelledby',] }],
3448
- valueChange: [{ type: core.Output }],
3449
- _inputElement: [{ type: core.ViewChild, args: ['input',] }],
3450
- _textareaElement: [{ type: core.ViewChild, args: ['textarea',] }]
3451
- };
3452
-
3453
- var GraniteInputFieldModule = /** @class */ (function () {
3454
- function GraniteInputFieldModule() {
3455
- }
3456
- return GraniteInputFieldModule;
3457
- }());
3458
- GraniteInputFieldModule.decorators = [
3459
- { type: core.NgModule, args: [{
3460
- imports: [common.CommonModule, GraniteIconModule, GraniteButtonModule],
3461
- declarations: [GraniteInputFieldComponent],
3462
- exports: [GraniteInputFieldComponent],
3463
- },] }
3464
- ];
3465
-
3466
- var ɵ0 = deviceDesktop.output;
3467
- /**
3468
- * Directive used to tell components and their sub components that client output
3469
- * should be adapted for desktop devices like personal computers.
3470
- */
3471
- var ClientOutputDesktopDirective = /** @class */ (function () {
3472
- function ClientOutputDesktopDirective() {
3473
- }
3474
- return ClientOutputDesktopDirective;
3475
- }());
3476
- ClientOutputDesktopDirective.decorators = [
3477
- { type: core.Directive, args: [{
3478
- selector: "[graniteClientOutputDesktop]",
3479
- providers: [
3480
- {
3481
- provide: GRANITE_CLIENT_OUTPUT,
3482
- useValue: ɵ0,
3483
- },
3484
- ],
3485
- },] }
3486
- ];
3487
-
3488
- var ɵ0$1 = deviceTouch.output;
3489
- /**
3490
- * Directive used to tell components and their sub components that client output
3491
- * should be adapted for touch devices like mobiles and tablets.
3492
- */
3493
- var ClientOutputTouchDirective = /** @class */ (function () {
3494
- function ClientOutputTouchDirective() {
3495
- }
3496
- return ClientOutputTouchDirective;
3497
- }());
3498
- ClientOutputTouchDirective.decorators = [
3499
- { type: core.Directive, args: [{
3500
- selector: "[graniteClientOutputTouch]",
3501
- providers: [
3502
- {
3503
- provide: GRANITE_CLIENT_OUTPUT,
3504
- useValue: ɵ0$1,
3505
- },
3506
- ],
3507
- },] }
3508
- ];
3509
-
3510
- var ɵ0$2 = deviceDesktop.input;
3511
- /**
3512
- * Directive used to tell components and their sub components that client input
3513
- * should be adapted for desktop devices, like personal computers.
3514
- */
3515
- var ClientInputDesktopDirective = /** @class */ (function () {
3516
- function ClientInputDesktopDirective() {
3517
- }
3518
- return ClientInputDesktopDirective;
3519
- }());
3520
- ClientInputDesktopDirective.decorators = [
3521
- { type: core.Directive, args: [{
3522
- selector: "[graniteClientInputDesktop]",
3523
- providers: [
3524
- {
3525
- provide: GRANITE_CLIENT_INPUT,
3526
- useValue: ɵ0$2,
3527
- },
3528
- ],
3529
- },] }
3530
- ];
3531
-
3532
- var ɵ0$3 = deviceTouch.input;
3533
- /**
3534
- * Directive used to tell components and their sub components that client input
3535
- * should be adapted for touch devices, like mobiles and tablets.
3536
- */
3537
- var ClientInputTouchDirective = /** @class */ (function () {
3538
- function ClientInputTouchDirective() {
3539
- }
3540
- return ClientInputTouchDirective;
3541
- }());
3542
- ClientInputTouchDirective.decorators = [
3543
- { type: core.Directive, args: [{
3544
- selector: "[graniteClientInputTouch]",
3545
- providers: [
3546
- {
3547
- provide: GRANITE_CLIENT_INPUT,
3548
- useValue: ɵ0$3,
3549
- },
3550
- ],
3551
- },] }
3552
- ];
3553
-
3554
- // TODO: Move client devices into a separate module
3555
- var GraniteCoreModule = /** @class */ (function () {
3556
- function GraniteCoreModule() {
3557
- }
3558
- return GraniteCoreModule;
3559
- }());
3560
- GraniteCoreModule.decorators = [
3561
- { type: core.NgModule, args: [{
3562
- declarations: [
3563
- ClientOutputDesktopDirective,
3564
- ClientOutputTouchDirective,
3565
- ClientInputDesktopDirective,
3566
- ClientInputTouchDirective,
3567
- ],
3568
- exports: [
3569
- ClientOutputDesktopDirective,
3570
- ClientOutputTouchDirective,
3571
- ClientInputDesktopDirective,
3572
- ClientInputTouchDirective,
3573
- ],
3574
- },] }
3575
- ];
3576
-
3577
- /*
3578
- * Public API Surface of ui
3579
- */
3580
-
3581
- /**
3582
- * Generated bundle index. Do not edit.
3583
- */
3584
-
3585
- exports.ClientInputDesktopDirective = ClientInputDesktopDirective;
3586
- exports.ClientInputTouchDirective = ClientInputTouchDirective;
3587
- exports.ClientOutputDesktopDirective = ClientOutputDesktopDirective;
3588
- exports.ClientOutputTouchDirective = ClientOutputTouchDirective;
3589
- exports.GRANITE_CLIENT_INPUT = GRANITE_CLIENT_INPUT;
3590
- exports.GRANITE_CLIENT_OUTPUT = GRANITE_CLIENT_OUTPUT;
3591
- exports.GraniteAnchorComponent = GraniteAnchorComponent;
3592
- exports.GraniteArrangeGridComponent = GraniteArrangeGridComponent;
3593
- exports.GraniteArrangeGridItemComponent = GraniteArrangeGridItemComponent;
3594
- exports.GraniteArrangeGridModule = GraniteArrangeGridModule;
3595
- exports.GraniteBadgeComponent = GraniteBadgeComponent;
3596
- exports.GraniteBadgeHarness = GraniteBadgeHarness;
3597
- exports.GraniteBadgeModule = GraniteBadgeModule;
3598
- exports.GraniteButtonComponent = GraniteButtonComponent;
3599
- exports.GraniteButtonModule = GraniteButtonModule;
3600
- exports.GraniteCheckboxComponent = GraniteCheckboxComponent;
3601
- exports.GraniteCheckboxGroupComponent = GraniteCheckboxGroupComponent;
3602
- exports.GraniteCheckboxModule = GraniteCheckboxModule;
3603
- exports.GraniteCoreModule = GraniteCoreModule;
3604
- exports.GraniteDividerDirective = GraniteDividerDirective;
3605
- exports.GraniteGridComponent = GraniteGridComponent;
3606
- exports.GraniteGridItemComponent = GraniteGridItemComponent;
3607
- exports.GraniteGridModule = GraniteGridModule;
3608
- exports.GraniteIconComponent = GraniteIconComponent;
3609
- exports.GraniteIconModule = GraniteIconModule;
3610
- exports.GraniteInputFieldComponent = GraniteInputFieldComponent;
3611
- exports.GraniteInputFieldModule = GraniteInputFieldModule;
3612
- exports.GraniteMenuComponent = GraniteMenuComponent;
3613
- exports.GraniteMenuHarness = GraniteMenuHarness;
3614
- exports.GraniteMenuItemComponent = GraniteMenuItemComponent;
3615
- exports.GraniteMenuItemHarness = GraniteMenuItemHarness;
3616
- exports.GraniteMenuModule = GraniteMenuModule;
3617
- exports.GraniteMenuTouchCloseComponent = GraniteMenuTouchCloseComponent;
3618
- exports.GraniteMenuTouchTitleItemComponent = GraniteMenuTouchTitleItemComponent;
3619
- exports.GraniteMenuTriggerForDirective = GraniteMenuTriggerForDirective;
3620
- exports.GraniteRadioButtonComponent = GraniteRadioButtonComponent;
3621
- exports.GraniteRadioButtonModule = GraniteRadioButtonModule;
3622
- exports.GraniteRadioGroupComponent = GraniteRadioGroupComponent;
3623
- exports.GraniteTableColumnDirective = GraniteTableColumnDirective;
3624
- exports.GraniteTableComponent = GraniteTableComponent;
3625
- exports.GraniteTableModule = GraniteTableModule;
3626
- exports.GraniteTitleDirective = GraniteTitleDirective;
3627
- exports.GraniteToggleSwitchComponent = GraniteToggleSwitchComponent;
3628
- exports.GraniteToggleSwitchModule = GraniteToggleSwitchModule;
3629
- exports._MenuBaseComponent = _MenuBaseComponent;
3630
- exports.deviceDesktop = deviceDesktop;
3631
- exports.deviceTouch = deviceTouch;
3632
- exports.disabledMixin = disabledMixin;
3633
- exports.graniteMenuDesktopAnimations = graniteMenuDesktopAnimations;
3634
- exports.graniteMenuTouchAnimations = graniteMenuTouchAnimations;
3635
- exports.ɵ0 = ɵ0$1;
3636
- exports.ɵa = GRANITE_MENU_PANEL;
3637
- exports.ɵc = getEaseOutSteep;
3638
- exports.ɵd = getEaseLinear;
3639
- exports.ɵe = GraniteRadioCheckboxBase;
3640
- exports.ɵf = GraniteTableDataCellComponent;
3641
- exports.ɵg = GraniteCell;
3642
- exports.ɵh = GraniteTableHeaderCellComponent;
3643
- exports.ɵi = PurePipesModule;
3644
- exports.ɵj = GraniteTitlePipe;
3645
-
3646
- Object.defineProperty(exports, '__esModule', { value: true });
3647
-
3648
- })));
3649
- //# sourceMappingURL=ifsworld-granite-components.umd.js.map