@material/web 1.0.0-pre.1 → 1.0.0-pre.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (417) hide show
  1. package/README.md +66 -19
  2. package/autocomplete/lib/_filled-autocomplete.scss +1 -34
  3. package/autocomplete/lib/_outlined-autocomplete.scss +1 -34
  4. package/autocomplete/lib/autocomplete.d.ts +0 -4
  5. package/autocomplete/lib/autocomplete.js +5 -12
  6. package/autocomplete/lib/autocomplete.js.map +1 -1
  7. package/autocomplete/lib/autocompleteitem/autocomplete-item.d.ts +2 -2
  8. package/autocomplete/lib/autocompleteitem/autocomplete-item.js +2 -2
  9. package/autocomplete/lib/autocompleteitem/autocomplete-item.js.map +1 -1
  10. package/autocomplete/lib/autocompletelist/autocomplete-list.d.ts +1 -1
  11. package/autocomplete/lib/autocompletelist/autocomplete-list.js +2 -2
  12. package/autocomplete/lib/autocompletelist/autocomplete-list.js.map +1 -1
  13. package/autocomplete/lib/filled-styles.css.js +1 -1
  14. package/autocomplete/lib/filled-styles.css.js.map +1 -1
  15. package/autocomplete/lib/outlined-styles.css.js +1 -1
  16. package/autocomplete/lib/outlined-styles.css.js.map +1 -1
  17. package/button/lib/_elevation.scss +1 -1
  18. package/button/lib/_icon.scss +14 -24
  19. package/button/lib/_shared.scss +1 -0
  20. package/button/lib/button.d.ts +0 -3
  21. package/button/lib/button.js +1 -12
  22. package/button/lib/button.js.map +1 -1
  23. package/button/lib/filled-styles.css.js +1 -1
  24. package/button/lib/filled-styles.css.js.map +1 -1
  25. package/button/lib/link-button.d.ts +0 -1
  26. package/button/lib/link-button.js +0 -5
  27. package/button/lib/link-button.js.map +1 -1
  28. package/button/lib/shared-elevation-styles.css.js +1 -1
  29. package/button/lib/shared-elevation-styles.css.js.map +1 -1
  30. package/button/lib/shared-styles.css.js +1 -1
  31. package/button/lib/shared-styles.css.js.map +1 -1
  32. package/checkbox/checkbox.d.ts +11 -2
  33. package/checkbox/checkbox.js +11 -2
  34. package/checkbox/checkbox.js.map +1 -1
  35. package/checkbox/lib/checkbox.d.ts +28 -0
  36. package/checkbox/lib/checkbox.js +30 -1
  37. package/checkbox/lib/checkbox.js.map +1 -1
  38. package/chips/chip/lib/_chip-theme.scss +1 -1
  39. package/dialog/_dialog.scss +6 -0
  40. package/dialog/dialog.d.ts +38 -0
  41. package/dialog/dialog.js +41 -0
  42. package/dialog/dialog.js.map +1 -0
  43. package/dialog/harness.d.ts +18 -0
  44. package/dialog/harness.js +55 -0
  45. package/dialog/harness.js.map +1 -0
  46. package/dialog/lib/_dialog.scss +386 -0
  47. package/dialog/lib/_tokens.scss +86 -0
  48. package/{list/lib/divider/list-divider-styles.css.d.ts → dialog/lib/dialog-styles.css.d.ts} +0 -0
  49. package/dialog/lib/dialog-styles.css.js +9 -0
  50. package/dialog/lib/dialog-styles.css.js.map +1 -0
  51. package/dialog/lib/dialog-styles.scss +8 -0
  52. package/dialog/lib/dialog.d.ts +190 -0
  53. package/dialog/lib/dialog.js +566 -0
  54. package/dialog/lib/dialog.js.map +1 -0
  55. package/divider/_divider.scss +6 -0
  56. package/divider/divider.d.ts +24 -0
  57. package/divider/divider.js +27 -0
  58. package/divider/divider.js.map +1 -0
  59. package/divider/lib/_divider.scss +54 -0
  60. package/{menu/lib/menu-button-styles.css.d.ts → divider/lib/divider-styles.css.d.ts} +0 -0
  61. package/divider/lib/divider-styles.css.js +9 -0
  62. package/divider/lib/divider-styles.css.js.map +1 -0
  63. package/divider/lib/divider-styles.scss +8 -0
  64. package/divider/lib/divider.d.ts +23 -0
  65. package/divider/lib/divider.js +41 -0
  66. package/divider/lib/divider.js.map +1 -0
  67. package/elevation/lib/_elevation.scss +1 -1
  68. package/elevation/lib/_md-comp-elevation.scss +1 -1
  69. package/elevation/lib/elevation-styles.css.js +1 -1
  70. package/elevation/lib/elevation-styles.css.js.map +1 -1
  71. package/fab/lib/_shared.scss +1 -1
  72. package/fab/lib/fab-shared-styles.css.js +1 -1
  73. package/fab/lib/fab-shared-styles.css.js.map +1 -1
  74. package/field/lib/_filled-field.scss +5 -2
  75. package/field/lib/_md-comp-filled-field.scss +3 -1
  76. package/field/lib/_md-comp-outlined-field.scss +1 -1
  77. package/field/lib/_shared.scss +2 -0
  78. package/field/lib/field.d.ts +0 -2
  79. package/field/lib/field.js +2 -4
  80. package/field/lib/field.js.map +1 -1
  81. package/field/lib/filled-styles.css.js +1 -1
  82. package/field/lib/filled-styles.css.js.map +1 -1
  83. package/field/lib/outlined-styles.css.js +1 -1
  84. package/field/lib/outlined-styles.css.js.map +1 -1
  85. package/field/lib/shared-styles.css.js +1 -1
  86. package/field/lib/shared-styles.css.js.map +1 -1
  87. package/focus/lib/_focus-ring.scss +3 -10
  88. package/focus/lib/focus-ring-styles.css.js +1 -1
  89. package/focus/lib/focus-ring-styles.css.js.map +1 -1
  90. package/focus/lib/focus-ring.d.ts +1 -4
  91. package/focus/lib/focus-ring.js +2 -11
  92. package/focus/lib/focus-ring.js.map +1 -1
  93. package/iconbutton/lib/_filled-icon-button.scss +1 -1
  94. package/iconbutton/lib/_filled-tonal-icon-button.scss +1 -1
  95. package/iconbutton/lib/_outlined-icon-button.scss +7 -5
  96. package/iconbutton/lib/_shared.scss +5 -25
  97. package/iconbutton/lib/_standard-icon-button.scss +4 -6
  98. package/iconbutton/lib/filled-styles.css.js +1 -1
  99. package/iconbutton/lib/filled-styles.css.js.map +1 -1
  100. package/iconbutton/lib/filled-tonal-styles.css.js +1 -1
  101. package/iconbutton/lib/filled-tonal-styles.css.js.map +1 -1
  102. package/iconbutton/lib/icon-button-toggle.d.ts +13 -42
  103. package/iconbutton/lib/icon-button-toggle.js +33 -103
  104. package/iconbutton/lib/icon-button-toggle.js.map +1 -1
  105. package/iconbutton/lib/icon-button.d.ts +2 -4
  106. package/iconbutton/lib/icon-button.js +3 -9
  107. package/iconbutton/lib/icon-button.js.map +1 -1
  108. package/iconbutton/lib/outlined-styles.css.js +1 -1
  109. package/iconbutton/lib/outlined-styles.css.js.map +1 -1
  110. package/iconbutton/lib/shared-styles.css.js +1 -1
  111. package/iconbutton/lib/shared-styles.css.js.map +1 -1
  112. package/iconbutton/lib/standard-styles.css.js +1 -1
  113. package/iconbutton/lib/standard-styles.css.js.map +1 -1
  114. package/list/lib/_list.scss +32 -40
  115. package/list/lib/avatar/_list-item-avatar.scss +1 -1
  116. package/list/lib/avatar/list-item-avatar-styles.css.js +1 -1
  117. package/list/lib/avatar/list-item-avatar-styles.css.js.map +1 -1
  118. package/list/lib/avatar/list-item-avatar.d.ts +9 -4
  119. package/list/lib/avatar/list-item-avatar.js +24 -11
  120. package/list/lib/avatar/list-item-avatar.js.map +1 -1
  121. package/list/lib/icon/_list-item-icon.scss +3 -1
  122. package/list/lib/icon/list-item-icon-styles.css.js +1 -1
  123. package/list/lib/icon/list-item-icon-styles.css.js.map +1 -1
  124. package/list/lib/icon/list-item-icon.d.ts +0 -3
  125. package/list/lib/icon/list-item-icon.js +1 -12
  126. package/list/lib/icon/list-item-icon.js.map +1 -1
  127. package/list/lib/image/_list-item-image.scss +1 -1
  128. package/list/lib/image/list-item-image-styles.css.js +1 -1
  129. package/list/lib/image/list-item-image-styles.css.js.map +1 -1
  130. package/list/lib/image/list-item-image.d.ts +11 -4
  131. package/list/lib/image/list-item-image.js +24 -13
  132. package/list/lib/image/list-item-image.js.map +1 -1
  133. package/list/lib/list-styles.css.js +1 -1
  134. package/list/lib/list-styles.css.js.map +1 -1
  135. package/list/lib/list.d.ts +99 -28
  136. package/list/lib/list.js +210 -111
  137. package/list/lib/list.js.map +1 -1
  138. package/list/lib/listitem/_list-item.scss +104 -39
  139. package/list/lib/listitem/harness.js +2 -1
  140. package/list/lib/listitem/harness.js.map +1 -1
  141. package/{tokens/v0_150/index.test.css.d.ts → list/lib/listitem/list-item-private-styles.css.d.ts} +0 -0
  142. package/list/lib/listitem/list-item-private-styles.css.js +9 -0
  143. package/list/lib/listitem/list-item-private-styles.css.js.map +1 -0
  144. package/list/lib/listitem/list-item-private-styles.scss +8 -0
  145. package/list/lib/listitem/list-item-styles.css.js +1 -1
  146. package/list/lib/listitem/list-item-styles.css.js.map +1 -1
  147. package/list/lib/listitem/list-item.d.ts +99 -43
  148. package/list/lib/listitem/list-item.js +201 -172
  149. package/list/lib/listitem/list-item.js.map +1 -1
  150. package/list/lib/listitemlink/list-item-link.d.ts +17 -0
  151. package/list/lib/listitemlink/list-item-link.js +42 -0
  152. package/list/lib/listitemlink/list-item-link.js.map +1 -0
  153. package/list/lib/video/_list-item-video.scss +10 -4
  154. package/list/lib/video/list-item-video-styles.css.js +1 -1
  155. package/list/lib/video/list-item-video-styles.css.js.map +1 -1
  156. package/list/lib/video/list-item-video.d.ts +43 -4
  157. package/list/lib/video/list-item-video.js +90 -12
  158. package/list/lib/video/list-item-video.js.map +1 -1
  159. package/list/list-item-avatar.d.ts +2 -1
  160. package/list/list-item-avatar.js +2 -1
  161. package/list/list-item-avatar.js.map +1 -1
  162. package/list/list-item-icon.d.ts +2 -1
  163. package/list/list-item-icon.js +2 -1
  164. package/list/list-item-icon.js.map +1 -1
  165. package/list/list-item-image.d.ts +2 -1
  166. package/list/list-item-image.js +2 -1
  167. package/list/list-item-image.js.map +1 -1
  168. package/list/list-item-link.d.ts +35 -0
  169. package/list/list-item-link.js +39 -0
  170. package/list/list-item-link.js.map +1 -0
  171. package/list/list-item-video.d.ts +2 -1
  172. package/list/list-item-video.js +2 -1
  173. package/list/list-item-video.js.map +1 -1
  174. package/list/list-item.d.ts +18 -2
  175. package/list/list-item.js +20 -3
  176. package/list/list-item.js.map +1 -1
  177. package/list/list.d.ts +15 -1
  178. package/list/list.js +15 -1
  179. package/list/list.js.map +1 -1
  180. package/menu/_menu-item.scss +6 -0
  181. package/menu/_menu.scss +6 -0
  182. package/menu/harness.d.ts +5 -0
  183. package/menu/harness.js +22 -0
  184. package/menu/harness.js.map +1 -1
  185. package/menu/lib/_menu.scss +61 -62
  186. package/menu/lib/menu-styles.css.js +1 -1
  187. package/menu/lib/menu-styles.css.js.map +1 -1
  188. package/menu/lib/menu.d.ts +176 -42
  189. package/menu/lib/menu.js +506 -246
  190. package/menu/lib/menu.js.map +1 -1
  191. package/menu/lib/menuitem/_menu-item.scss +115 -0
  192. package/{tokens/v0_150/lib.test.css.d.ts → menu/lib/menuitem/menu-item-private-styles.css.d.ts} +0 -0
  193. package/menu/lib/menuitem/menu-item-private-styles.css.js +9 -0
  194. package/menu/lib/menuitem/menu-item-private-styles.css.js.map +1 -0
  195. package/menu/lib/menuitem/menu-item-private-styles.scss +8 -0
  196. package/menu/lib/menuitem/menu-item-styles.css.d.ts +1 -0
  197. package/menu/lib/menuitem/menu-item-styles.css.js +9 -0
  198. package/menu/lib/menuitem/menu-item-styles.css.js.map +1 -0
  199. package/menu/lib/menuitem/menu-item-styles.scss +8 -0
  200. package/menu/lib/menuitem/menu-item.d.ts +20 -3
  201. package/menu/lib/menuitem/menu-item.js +42 -3
  202. package/menu/lib/menuitem/menu-item.js.map +1 -1
  203. package/menu/lib/menuitemlink/menu-item-link.d.ts +25 -0
  204. package/menu/lib/menuitemlink/menu-item-link.js +51 -0
  205. package/menu/lib/menuitemlink/menu-item-link.js.map +1 -0
  206. package/menu/lib/shared.d.ts +134 -0
  207. package/menu/lib/shared.js +85 -0
  208. package/menu/lib/shared.js.map +1 -0
  209. package/menu/lib/submenuitem/harness.d.ts +11 -0
  210. package/menu/lib/submenuitem/harness.js +12 -0
  211. package/menu/lib/submenuitem/harness.js.map +1 -0
  212. package/menu/lib/submenuitem/sub-menu-item.d.ts +89 -0
  213. package/menu/lib/submenuitem/sub-menu-item.js +266 -0
  214. package/menu/lib/submenuitem/sub-menu-item.js.map +1 -0
  215. package/menu/lib/surfacePositionController.d.ts +117 -0
  216. package/menu/lib/surfacePositionController.js +196 -0
  217. package/menu/lib/surfacePositionController.js.map +1 -0
  218. package/menu/lib/typeaheadController.d.ts +144 -0
  219. package/menu/lib/typeaheadController.js +242 -0
  220. package/menu/lib/typeaheadController.js.map +1 -0
  221. package/menu/menu-item-link.d.ts +33 -0
  222. package/menu/menu-item-link.js +37 -0
  223. package/menu/menu-item-link.js.map +1 -0
  224. package/menu/menu-item.d.ts +19 -2
  225. package/menu/menu-item.js +22 -4
  226. package/menu/menu-item.js.map +1 -1
  227. package/menu/menu.d.ts +45 -0
  228. package/menu/menu.js +43 -0
  229. package/menu/menu.js.map +1 -1
  230. package/menu/sub-menu-item.d.ts +60 -0
  231. package/menu/sub-menu-item.js +64 -0
  232. package/menu/sub-menu-item.js.map +1 -0
  233. package/menusurface/lib/_menu-surface.scss +1 -1
  234. package/menusurface/lib/menu-surface-styles.css.js +1 -1
  235. package/menusurface/lib/menu-surface-styles.css.js.map +1 -1
  236. package/motion/animation.d.ts +20 -3
  237. package/motion/animation.js +39 -4
  238. package/motion/animation.js.map +1 -1
  239. package/navigationbar/lib/_navigation-bar.scss +9 -9
  240. package/navigationbar/lib/navigation-bar-styles.css.js +1 -1
  241. package/navigationbar/lib/navigation-bar-styles.css.js.map +1 -1
  242. package/navigationdrawer/lib/_navigation-drawer.scss +1 -1
  243. package/navigationdrawer/lib/navigation-drawer-styles.css.js +1 -1
  244. package/navigationdrawer/lib/navigation-drawer-styles.css.js.map +1 -1
  245. package/navigationtab/lib/_navigation-tab.scss +8 -19
  246. package/navigationtab/lib/navigation-tab-styles.css.js +1 -1
  247. package/navigationtab/lib/navigation-tab-styles.css.js.map +1 -1
  248. package/package.json +1 -8
  249. package/radio/lib/_radio.scss +0 -1
  250. package/radio/lib/radio-styles.css.js +1 -1
  251. package/radio/lib/radio-styles.css.js.map +1 -1
  252. package/radio/lib/radio.d.ts +10 -1
  253. package/radio/lib/radio.js +10 -1
  254. package/radio/lib/radio.js.map +1 -1
  255. package/radio/radio.d.ts +16 -1
  256. package/radio/radio.js +16 -1
  257. package/radio/radio.js.map +1 -1
  258. package/ripple/lib/_ripple.scss +5 -21
  259. package/ripple/lib/ripple-styles.css.js +1 -1
  260. package/ripple/lib/ripple-styles.css.js.map +1 -1
  261. package/ripple/lib/ripple.js +2 -2
  262. package/ripple/lib/ripple.js.map +1 -1
  263. package/sass/_map-ext.scss +24 -0
  264. package/sass/_string-ext.scss +23 -0
  265. package/segmentedbuttonset/lib/segmented-button-set.d.ts +0 -2
  266. package/segmentedbuttonset/lib/segmented-button-set.js +0 -2
  267. package/segmentedbuttonset/lib/segmented-button-set.js.map +1 -1
  268. package/switch/lib/_handle.scss +56 -9
  269. package/switch/lib/_icon.scss +36 -0
  270. package/switch/lib/_switch.scss +1 -115
  271. package/switch/lib/_track.scss +39 -0
  272. package/switch/lib/switch-styles.css.js +1 -1
  273. package/switch/lib/switch-styles.css.js.map +1 -1
  274. package/switch/lib/switch.d.ts +3 -0
  275. package/switch/lib/switch.js +3 -0
  276. package/switch/lib/switch.js.map +1 -1
  277. package/textfield/lib/_filled-text-field.scss +4 -2
  278. package/textfield/lib/_outlined-text-field.scss +3 -2
  279. package/textfield/lib/filled-styles.css.js +1 -1
  280. package/textfield/lib/filled-styles.css.js.map +1 -1
  281. package/textfield/lib/outlined-styles.css.js +1 -1
  282. package/textfield/lib/outlined-styles.css.js.map +1 -1
  283. package/textfield/lib/text-field.d.ts +0 -2
  284. package/textfield/lib/text-field.js +0 -2
  285. package/textfield/lib/text-field.js.map +1 -1
  286. package/tokens/_index.scss +1 -1
  287. package/tokens/{v0_150 → v0_152}/_index.scss +1 -1
  288. package/tokens/{v0_150 → v0_152}/_md-comp-assist-chip.scss +2 -2
  289. package/tokens/{v0_150 → v0_152}/_md-comp-badge.scss +2 -2
  290. package/tokens/{v0_150 → v0_152}/_md-comp-banner.scss +2 -43
  291. package/tokens/{v0_150 → v0_152}/_md-comp-bottom-app-bar.scss +3 -4
  292. package/tokens/{v0_150 → v0_152}/_md-comp-carousel-item.scss +2 -2
  293. package/tokens/{v0_150 → v0_152}/_md-comp-checkbox.scss +2 -12
  294. package/tokens/{v0_150 → v0_152}/_md-comp-circular-progress-indicator.scss +2 -2
  295. package/tokens/{v0_150 → v0_152}/_md-comp-data-table.scss +2 -4
  296. package/tokens/{v0_150 → v0_152}/_md-comp-date-input-modal.scss +2 -2
  297. package/tokens/{v0_150 → v0_152}/_md-comp-date-picker-docked.scss +2 -2
  298. package/tokens/{v0_150 → v0_152}/_md-comp-date-picker-modal.scss +2 -2
  299. package/tokens/{v0_150 → v0_152}/_md-comp-dialog.scss +2 -25
  300. package/tokens/{v0_150 → v0_152}/_md-comp-divider.scss +2 -2
  301. package/tokens/{v0_150 → v0_152}/_md-comp-elevated-button.scss +2 -2
  302. package/tokens/{v0_150 → v0_152}/_md-comp-elevated-card.scss +2 -2
  303. package/tokens/{v0_150 → v0_152}/_md-comp-extended-fab-branded.scss +2 -2
  304. package/tokens/{v0_150 → v0_152}/_md-comp-extended-fab-primary.scss +2 -2
  305. package/tokens/{v0_150 → v0_152}/_md-comp-extended-fab-secondary.scss +2 -2
  306. package/tokens/{v0_150 → v0_152}/_md-comp-extended-fab-surface.scss +2 -2
  307. package/tokens/{v0_150 → v0_152}/_md-comp-extended-fab-tertiary.scss +2 -4
  308. package/tokens/{v0_150 → v0_152}/_md-comp-fab-branded-large.scss +2 -3
  309. package/tokens/{v0_150 → v0_152}/_md-comp-fab-branded.scss +2 -2
  310. package/tokens/{v0_150 → v0_152}/_md-comp-fab-primary-large.scss +2 -2
  311. package/tokens/{v0_150 → v0_152}/_md-comp-fab-primary-small.scss +2 -2
  312. package/tokens/{v0_150 → v0_152}/_md-comp-fab-primary.scss +2 -2
  313. package/tokens/{v0_150 → v0_152}/_md-comp-fab-secondary-large.scss +2 -2
  314. package/tokens/{v0_150 → v0_152}/_md-comp-fab-secondary-small.scss +2 -2
  315. package/tokens/{v0_150 → v0_152}/_md-comp-fab-secondary.scss +2 -2
  316. package/tokens/{v0_150 → v0_152}/_md-comp-fab-surface-large.scss +2 -2
  317. package/tokens/{v0_150 → v0_152}/_md-comp-fab-surface-small.scss +2 -2
  318. package/tokens/{v0_150 → v0_152}/_md-comp-fab-surface.scss +2 -2
  319. package/tokens/{v0_150 → v0_152}/_md-comp-fab-tertiary-large.scss +2 -2
  320. package/tokens/{v0_150 → v0_152}/_md-comp-fab-tertiary-small.scss +2 -2
  321. package/tokens/{v0_150 → v0_152}/_md-comp-fab-tertiary.scss +2 -2
  322. package/tokens/{v0_150 → v0_152}/_md-comp-filled-autocomplete.scss +2 -3
  323. package/tokens/{v0_150 → v0_152}/_md-comp-filled-button.scss +2 -8
  324. package/tokens/{v0_150 → v0_152}/_md-comp-filled-card.scss +2 -4
  325. package/tokens/{v0_150 → v0_152}/_md-comp-filled-icon-button.scss +2 -2
  326. package/tokens/{v0_150 → v0_152}/_md-comp-filled-menu-button.scss +2 -2
  327. package/tokens/{v0_150 → v0_152}/_md-comp-filled-select.scss +2 -6
  328. package/tokens/{v0_150 → v0_152}/_md-comp-filled-text-field.scss +2 -3
  329. package/tokens/{v0_150 → v0_152}/_md-comp-filled-tonal-button.scss +2 -2
  330. package/tokens/{v0_150 → v0_152}/_md-comp-filled-tonal-icon-button.scss +2 -2
  331. package/tokens/{v0_150 → v0_152}/_md-comp-filter-chip.scss +2 -30
  332. package/tokens/{v0_150 → v0_152}/_md-comp-full-screen-dialog.scss +3 -53
  333. package/tokens/{v0_150 → v0_152}/_md-comp-icon-button.scss +3 -3
  334. package/tokens/{v0_150 → v0_152}/_md-comp-input-chip.scss +2 -52
  335. package/tokens/{v0_150 → v0_152}/_md-comp-linear-progress-indicator.scss +2 -2
  336. package/tokens/{v0_150 → v0_152}/_md-comp-list.scss +3 -12
  337. package/tokens/{v0_150 → v0_152}/_md-comp-menu.scss +2 -4
  338. package/tokens/{v0_150 → v0_152}/_md-comp-navigation-bar.scss +2 -9
  339. package/tokens/{v0_150 → v0_152}/_md-comp-navigation-drawer.scss +2 -8
  340. package/tokens/{v0_150 → v0_152}/_md-comp-navigation-rail.scss +2 -39
  341. package/tokens/{v0_150 → v0_152}/_md-comp-outlined-autocomplete.scss +2 -3
  342. package/tokens/{v0_150 → v0_152}/_md-comp-outlined-button.scss +2 -6
  343. package/tokens/{v0_150 → v0_152}/_md-comp-outlined-card.scss +2 -2
  344. package/tokens/{v0_150 → v0_152}/_md-comp-outlined-icon-button.scss +2 -4
  345. package/tokens/{v0_150 → v0_152}/_md-comp-outlined-menu-button.scss +2 -2
  346. package/tokens/{v0_150 → v0_152}/_md-comp-outlined-segmented-button.scss +2 -2
  347. package/tokens/{v0_150 → v0_152}/_md-comp-outlined-select.scss +2 -6
  348. package/tokens/{v0_150 → v0_152}/_md-comp-outlined-text-field.scss +2 -3
  349. package/tokens/{v0_150 → v0_152}/_md-comp-plain-tooltip.scss +2 -2
  350. package/tokens/{v0_150 → v0_152}/_md-comp-primary-navigation-tab.scss +2 -2
  351. package/tokens/{v0_150 → v0_152}/_md-comp-radio-button.scss +2 -2
  352. package/tokens/{v0_150 → v0_152}/_md-comp-rich-tooltip.scss +2 -2
  353. package/tokens/{v0_150 → v0_152}/_md-comp-scrim.scss +2 -2
  354. package/tokens/{v0_150 → v0_152}/_md-comp-search-bar.scss +2 -2
  355. package/tokens/{v0_150 → v0_152}/_md-comp-search-view.scss +2 -2
  356. package/tokens/{v0_150 → v0_152}/_md-comp-secondary-navigation-tab.scss +2 -2
  357. package/tokens/{v0_150 → v0_152}/_md-comp-sheet-bottom.scss +2 -2
  358. package/tokens/{v0_150 → v0_152}/_md-comp-sheet-floating.scss +2 -2
  359. package/tokens/{v0_150 → v0_152}/_md-comp-sheet-side.scss +4 -2
  360. package/tokens/{v0_150 → v0_152}/_md-comp-slider.scss +2 -4
  361. package/tokens/{v0_150 → v0_152}/_md-comp-snackbar.scss +2 -2
  362. package/tokens/{v0_150 → v0_152}/_md-comp-standard-menu-button.scss +2 -2
  363. package/tokens/{v0_150 → v0_152}/_md-comp-suggestion-chip.scss +2 -2
  364. package/tokens/{v0_150 → v0_152}/_md-comp-switch.scss +2 -11
  365. package/tokens/{v0_150 → v0_152}/_md-comp-text-button.scss +2 -6
  366. package/tokens/{v0_150 → v0_152}/_md-comp-time-input.scss +2 -2
  367. package/tokens/{v0_150 → v0_152}/_md-comp-time-picker.scss +2 -5
  368. package/tokens/{v0_150 → v0_152}/_md-comp-top-app-bar-large.scss +2 -2
  369. package/tokens/{v0_150 → v0_152}/_md-comp-top-app-bar-medium.scss +2 -2
  370. package/tokens/{v0_150 → v0_152}/_md-comp-top-app-bar-small-centered.scss +2 -3
  371. package/tokens/{v0_150 → v0_152}/_md-comp-top-app-bar-small.scss +2 -3
  372. package/tokens/{v0_150 → v0_152}/_md-ref-palette.scss +2 -2
  373. package/tokens/{v0_150 → v0_152}/_md-ref-typeface.scss +2 -2
  374. package/tokens/{v0_150 → v0_152}/_md-sys-color.scss +2 -20
  375. package/tokens/{v0_150 → v0_152}/_md-sys-elevation.scss +4 -13
  376. package/tokens/{v0_150 → v0_152}/_md-sys-motion.scss +2 -2
  377. package/tokens/{v0_150 → v0_152}/_md-sys-shape.scss +2 -2
  378. package/tokens/{v0_150 → v0_152}/_md-sys-state.scss +2 -2
  379. package/tokens/{v0_150 → v0_152}/_md-sys-typescale.scss +2 -3
  380. package/tokens/v0_152/index.test.css.d.ts +1 -0
  381. package/tokens/{v0_150 → v0_152}/index.test.css.js +0 -0
  382. package/tokens/{v0_150 → v0_152}/index.test.css.js.map +0 -0
  383. package/tokens/{v0_150 → v0_152}/index.test.scss +1 -1
  384. package/tokens/v0_152/lib.test.css.d.ts +1 -0
  385. package/tokens/{v0_150 → v0_152}/lib.test.css.js +0 -0
  386. package/tokens/{v0_150 → v0_152}/lib.test.css.js.map +0 -0
  387. package/tokens/{v0_150 → v0_152}/lib.test.scss +1 -1
  388. package/list/lib/_tokens.scss +0 -80
  389. package/list/lib/divider/_list-divider.scss +0 -46
  390. package/list/lib/divider/list-divider-styles.css.js +0 -9
  391. package/list/lib/divider/list-divider-styles.css.js.map +0 -1
  392. package/list/lib/divider/list-divider-styles.scss +0 -8
  393. package/list/lib/divider/list-divider.d.ts +0 -13
  394. package/list/lib/divider/list-divider.js +0 -32
  395. package/list/lib/divider/list-divider.js.map +0 -1
  396. package/list/list-divider.d.ts +0 -19
  397. package/list/list-divider.js +0 -22
  398. package/list/list-divider.js.map +0 -1
  399. package/menu/lib/_menu-button.scss +0 -14
  400. package/menu/lib/adapter.d.ts +0 -66
  401. package/menu/lib/adapter.js +0 -7
  402. package/menu/lib/adapter.js.map +0 -1
  403. package/menu/lib/constants.d.ts +0 -22
  404. package/menu/lib/constants.js +0 -23
  405. package/menu/lib/constants.js.map +0 -1
  406. package/menu/lib/foundation.d.ts +0 -49
  407. package/menu/lib/foundation.js +0 -123
  408. package/menu/lib/foundation.js.map +0 -1
  409. package/menu/lib/menu-button-styles.css.js +0 -9
  410. package/menu/lib/menu-button-styles.css.js.map +0 -1
  411. package/menu/lib/menu-button-styles.scss +0 -8
  412. package/menu/lib/menu-button.d.ts +0 -27
  413. package/menu/lib/menu-button.js +0 -93
  414. package/menu/lib/menu-button.js.map +0 -1
  415. package/menu/menu-button.d.ts +0 -14
  416. package/menu/menu-button.js +0 -17
  417. package/menu/menu-button.js.map +0 -1
package/menu/lib/menu.js CHANGED
@@ -4,331 +4,591 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import { __decorate, __metadata } from "tslib";
7
+ // Required for @ariaProperty
8
+ // tslint:disable:no-new-decorators
7
9
  import '../../list/list.js';
8
- import '../../menusurface/menu-surface.js';
10
+ import '../../focus/focus-ring.js';
11
+ import '../../elevation/elevation.js';
9
12
  import { html, LitElement } from 'lit';
10
13
  import { property, query } from 'lit/decorators.js';
11
- import { ifDefined } from 'lit/directives/if-defined.js';
14
+ import { classMap } from 'lit/directives/class-map.js';
15
+ import { styleMap } from 'lit/directives/style-map.js';
12
16
  import { ariaProperty } from '../../decorators/aria-property.js';
13
- import { MenuSurface } from '../../menusurface/lib/menu-surface.js';
14
- import { MDCMenuFoundation } from './foundation.js';
17
+ import { MdFocusRing } from '../../focus/focus-ring.js';
18
+ import { pointerPress, shouldShowStrongFocus } from '../../focus/strong-focus.js';
19
+ import { List } from '../../list/lib/list.js';
20
+ import { createAnimationSignal, EASING } from '../../motion/animation.js';
21
+ import { SurfacePositionController } from './surfacePositionController.js';
22
+ import { TypeaheadController } from './typeaheadController.js';
15
23
  /**
16
- * @fires selected {SelectedDetail}
17
- * @fires action {ActionDetail}
18
- * @fires items-updated
19
- * @fires opened
20
- * @fires closed
24
+ * Gets the currently focused element on the page.
25
+ *
26
+ * @param activeDoc The document or shadowroot from which to start the search.
27
+ * Defaults to `window.document`
28
+ * @return Returns the currently deeply focused element or `null` if none.
29
+ */
30
+ function getFocusedElement(activeDoc = document) {
31
+ const activeEl = activeDoc.activeElement;
32
+ if (!activeEl) {
33
+ return null;
34
+ }
35
+ if (activeEl.shadowRoot) {
36
+ return getFocusedElement(activeEl.shadowRoot) ?? activeEl;
37
+ }
38
+ return activeEl;
39
+ }
40
+ /**
41
+ * @fires opening Fired before the opening animation begins (not fired on quick)
42
+ * @fires opened Fired once the menu is open, after any animations
43
+ * @fires closing Fired before the closing animation begins (not fired on quick)
44
+ * @fires closed Fired once the menu is closed, after any animations
21
45
  */
22
46
  export class Menu extends LitElement {
23
47
  constructor() {
24
48
  super(...arguments);
25
- this.listElementInternal = null;
49
+ /**
50
+ * The element in which the menu should align to.
51
+ */
26
52
  this.anchor = null;
27
- this.open = false;
28
- this.quick = false;
29
- this.corner = 'BOTTOM_START';
30
- this.x = null;
31
- this.y = null;
32
- this.absolute = false;
33
- this.activatable = false;
53
+ /**
54
+ * Makes the element use `position:fixed` instead of `position:absolute`. In
55
+ * most cases, the menu should position itself above most other
56
+ * `position:absolute` or `position:fixed` elements when placed inside of
57
+ * them. e.g. using a menu inside of an `md-dialog`.
58
+ *
59
+ * __NOTE__: Fixed menus will not scroll with the page and will be fixed to
60
+ * the window instead.
61
+ */
34
62
  this.fixed = false;
35
- this.forceGroupSelection = false;
36
- this.fullwidth = false;
37
- this.flipMenuHorizontally = false;
38
- this.stayOpenOnBodyClick = false;
63
+ /**
64
+ * Skips the opening and closing animations.
65
+ */
66
+ this.quick = false;
67
+ /**
68
+ * Displays overflow content like a submenu.
69
+ *
70
+ * __NOTE__: This may cause adverse effects if you set
71
+ * `md-menu {max-height:...}`
72
+ * and have items overflowing items in the "y" direction.
73
+ */
74
+ this.hasOverflow = false;
75
+ /**
76
+ * Opens the menu and makes it visible. Alternative to the `.show()` and
77
+ * `.close()` methods
78
+ */
79
+ this.open = false;
80
+ /**
81
+ * Offsets the menu's inline alignment from the anchor by the given number in
82
+ * pixels. This value is direction aware and will follow the LTR / RTL
83
+ * direction.
84
+ *
85
+ * e.g. LTR: positive -> right, negative -> left
86
+ * RTL: positive -> left, negative -> right
87
+ */
88
+ this.xOffset = 0;
89
+ /**
90
+ * Offsets the menu's block alignment from the anchor by the given number in
91
+ * pixels.
92
+ *
93
+ * e.g. positive -> down, negative -> up
94
+ */
95
+ this.yOffset = 0;
96
+ /**
97
+ * The tabindex of the underlying list element.
98
+ */
99
+ this.listTabIndex = 0;
100
+ /**
101
+ * The max time between the keystrokes of the typeahead menu behavior before
102
+ * it clears the typeahead buffer.
103
+ */
104
+ this.typeaheadBufferTime = 200;
105
+ /**
106
+ * The corner of the anchor which to align the menu in the standard logical
107
+ * property style of <block>_<inline>.
108
+ */
109
+ this.anchorCorner = 'END_START';
110
+ /**
111
+ * The corner of the menu which to align the anchor in the standard logical
112
+ * property style of <block>_<inline>.
113
+ */
114
+ this.menuCorner = 'START_START';
115
+ /**
116
+ * Keeps the user clicks outside the menu
117
+ */
118
+ this.stayOpenOnOutsideClick = false;
119
+ /**
120
+ * After closing, does not restore focus to the last focused element before
121
+ * the menu was opened.
122
+ */
39
123
  this.skipRestoreFocus = false;
124
+ /**
125
+ * The element that should be focused by default once opened.
126
+ */
40
127
  this.defaultFocus = 'LIST_ROOT';
41
- this.listUpdateComplete = null;
128
+ this.openCloseAnimationSignal = createAnimationSignal();
129
+ /**
130
+ * The element that was focused before the menu opened.
131
+ */
132
+ this.lastFocusedElement = null;
133
+ /**
134
+ * Handles typeahead navigation through the menu.
135
+ */
136
+ this.typeaheadController = new TypeaheadController(() => {
137
+ return {
138
+ getItems: () => this.items,
139
+ typeaheadBufferTime: this.typeaheadBufferTime,
140
+ };
141
+ });
142
+ /**
143
+ * Handles positioning the surface and aligning it to the anchor.
144
+ */
145
+ this.menuPositionController = new SurfacePositionController(this, () => {
146
+ return {
147
+ anchorCorner: this.anchorCorner,
148
+ surfaceCorner: this.menuCorner,
149
+ surfaceEl: this.surfaceEl,
150
+ anchorEl: this.anchor,
151
+ isTopLayer: this.fixed,
152
+ isOpen: this.open,
153
+ xOffset: this.xOffset,
154
+ yOffset: this.yOffset,
155
+ onOpen: this.onOpened,
156
+ beforeClose: this.beforeClose,
157
+ onClose: this.onClosed,
158
+ };
159
+ });
160
+ /**
161
+ * Saves the last focused element focuses the new element based on
162
+ * `defaultFocus`, and animates open.
163
+ */
164
+ this.onOpened = () => {
165
+ this.lastFocusedElement = getFocusedElement();
166
+ if (!this.listElement)
167
+ return;
168
+ const items = this.listElement.items;
169
+ const activeItemRecord = List.getActiveItem(items);
170
+ if (activeItemRecord && this.defaultFocus !== 'NONE') {
171
+ activeItemRecord.item.active = false;
172
+ }
173
+ switch (this.defaultFocus) {
174
+ case 'FIRST_ITEM':
175
+ const first = List.getFirstActivatableItem(items);
176
+ if (first) {
177
+ first.active = true;
178
+ }
179
+ break;
180
+ case 'LAST_ITEM':
181
+ const last = List.getLastActivatableItem(items);
182
+ if (last) {
183
+ last.active = true;
184
+ }
185
+ break;
186
+ case 'LIST_ROOT':
187
+ this.listElement?.focus();
188
+ break;
189
+ default:
190
+ case 'NONE':
191
+ // Do nothing.
192
+ break;
193
+ }
194
+ if (this.quick) {
195
+ this.dispatchEvent(new Event('opened'));
196
+ }
197
+ else {
198
+ this.animateOpen();
199
+ }
200
+ };
201
+ /**
202
+ * Animates closed.
203
+ */
204
+ this.beforeClose = async () => {
205
+ this.open = false;
206
+ if (!this.quick) {
207
+ await this.animateClose();
208
+ }
209
+ };
210
+ /**
211
+ * Focuses the last focused element.
212
+ */
213
+ this.onClosed = () => {
214
+ if (this.quick) {
215
+ this.dispatchEvent(new Event('closed'));
216
+ }
217
+ if (!this.skipRestoreFocus) {
218
+ this.lastFocusedElement?.focus?.();
219
+ }
220
+ };
221
+ this.onWindowClick = (e) => {
222
+ if (!this.stayOpenOnOutsideClick && !e.composedPath().includes(this)) {
223
+ this.open = false;
224
+ }
225
+ };
42
226
  }
43
- get listElement() {
44
- if (!this.listElementInternal) {
45
- this.listElementInternal = this.renderRoot.querySelector('md-list');
46
- return this.listElementInternal;
47
- }
48
- return this.listElementInternal;
227
+ /**
228
+ * Whether the menu is animating upwards or downwards when opening. This is
229
+ * helpful for calculating some animation calculations.
230
+ */
231
+ get openDirection() {
232
+ const menuCornerBlock = this.menuCorner.split('_')[0];
233
+ return menuCornerBlock === 'START' ? 'DOWN' : 'UP';
49
234
  }
235
+ /**
236
+ * The menu items associated with this menu. The items must be `MenuItem`s and
237
+ * have both the `md-menu-item` and `md-list-item` attributes.
238
+ */
50
239
  get items() {
51
240
  const listElement = this.listElement;
52
241
  if (listElement) {
53
- return listElement.items;
242
+ return listElement.items.filter(el => el.hasAttribute('md-menu-item'));
54
243
  }
55
244
  return [];
56
245
  }
57
246
  render() {
247
+ return this.renderSurface();
248
+ }
249
+ /**
250
+ * Renders the positionable surface element and its contents.
251
+ */
252
+ renderSurface() {
253
+ return html `
254
+ <div
255
+ class="menu ${classMap(this.getSurfaceClasses())}"
256
+ style=${styleMap(this.menuPositionController.surfaceStyles)}>
257
+ ${this.renderList()}
258
+ ${this.renderElevation()}
259
+ ${this.renderFocusRing()}
260
+ </div>
261
+ `;
262
+ }
263
+ /**
264
+ * Renders the List element and its items
265
+ */
266
+ renderList() {
58
267
  return html `
59
- <md-menu-surface
60
- ?hidden=${!this.open}
61
- .anchor=${this.anchor}
62
- .open=${this.open}
63
- .quick=${this.quick}
64
- .corner=${this.corner}
65
- .x=${this.x}
66
- .y=${this.y}
67
- .absolute=${this.absolute}
68
- .fixed=${this.fixed}
69
- .fullwidth=${this.fullwidth}
70
- .flipMenuHorizontally=${this.flipMenuHorizontally}
71
- .skipRestoreFocus=${this.skipRestoreFocus}
72
- ?stayOpenOnBodyClick=${this.stayOpenOnBodyClick}
73
- class="md3-menu"
74
- @closed=${this.onClosed}
75
- @opened=${this.onOpened}
76
- @keydown=${this.onKeydown}>
77
- <md-list
78
- aria-label="${ifDefined(this.ariaLabel)}"
79
- role=${'menu'}
80
- .listTabIndex=${-1}
81
- .listItemTagName=${this.getMenuItemTagName()}
82
- @action=${this.onAction}>
83
- <slot></slot>
84
- </md-list>
85
- </md-menu-surface>`;
268
+ <md-list
269
+ .ariaLabel=${this.ariaLabel}
270
+ role="menu"
271
+ listTabIndex=${this.listTabIndex}
272
+ @focus=${this.onListFocus}
273
+ @blur=${this.onListBlur}
274
+ @click=${this.onListClick}
275
+ @keydown=${this.typeaheadController.onKeydown}>
276
+ ${this.renderMenuItems()}
277
+ </md-list>`;
278
+ }
279
+ /**
280
+ * Renders the menu items' slot
281
+ */
282
+ renderMenuItems() {
283
+ return html `<slot
284
+ @close-menu=${this.onCloseMenu}
285
+ @deactivate-items=${this.onDeactivateItems}></slot>`;
86
286
  }
87
- getMenuItemTagName() {
88
- return 'md-menu-item';
287
+ /**
288
+ * Renders the elevation component.
289
+ */
290
+ renderElevation() {
291
+ return html `<md-elevation shadow surface></md-elevation>`;
89
292
  }
90
- createAdapter() {
293
+ /**
294
+ * Renders the focus ring component.
295
+ */
296
+ renderFocusRing() {
297
+ return html `<md-focus-ring></md-focus-ring>`;
298
+ }
299
+ getSurfaceClasses() {
91
300
  return {
92
- addClassToElementAtIndex: (index, className) => {
93
- const listElement = this.listElement;
94
- if (!listElement) {
95
- return;
96
- }
97
- const element = listElement.items[index];
98
- if (!element) {
99
- return;
100
- }
101
- element.classList.add(className);
102
- },
103
- removeClassFromElementAtIndex: (index, className) => {
104
- const listElement = this.listElement;
105
- if (!listElement) {
106
- return;
107
- }
108
- const element = listElement.items[index];
109
- if (!element) {
110
- return;
111
- }
112
- element.classList.remove(className);
113
- },
114
- addAttributeToElementAtIndex: (index, attr, value) => {
115
- // TODO(b/240174946): This method is only used for setting
116
- // `aria-checked` and `aria-disabled` on the menu items when selected
117
- // and disabled states change. Remove this in favor of adding to the
118
- // template declaratively.
119
- },
120
- removeAttributeFromElementAtIndex: (index, attr) => {
121
- const listElement = this.listElement;
122
- if (!listElement) {
123
- return;
124
- }
125
- const element = listElement.items[index];
126
- if (!element) {
127
- return;
128
- }
129
- element.removeAttribute(attr);
130
- },
131
- getAttributeFromElementAtIndex: (index, attr) => {
132
- const listElement = this.listElement;
133
- if (!listElement) {
134
- return null;
135
- }
136
- const element = listElement.items[index];
137
- if (!element) {
138
- return null;
139
- }
140
- return element.getAttribute(attr);
141
- },
142
- elementContainsClass: (element, className) => element.classList.contains(className),
143
- closeSurface: (skipRestoreFocus) => {
144
- this.skipRestoreFocus = Boolean(skipRestoreFocus);
145
- this.open = false;
146
- },
147
- getElementIndex: (element) => {
148
- const listElement = this.listElement;
149
- if (listElement) {
150
- return listElement.items.indexOf(element);
151
- }
152
- return -1;
153
- },
154
- notifySelected: () => { },
155
- getMenuItemCount: () => {
156
- const listElement = this.listElement;
157
- if (!listElement) {
158
- return 0;
159
- }
160
- return listElement.items.length;
161
- },
162
- getSelectedSiblingOfItemAtIndex: (index) => {
163
- const listElement = this.listElement;
164
- if (!listElement) {
165
- return -1;
166
- }
167
- // TODO(b/240177152): Remove/refactor this when implementing keyboard
168
- // navigation support.
169
- // const elementAtIndex = listElement.items[index];
170
- // if (!elementAtIndex || !elementAtIndex.group) {
171
- // return -1;
172
- // }
173
- // for (let i = 0; i < listElement.items.length; i++) {
174
- // if (i === index) {
175
- // continue;
176
- // }
177
- // const current = listElement.items[i];
178
- // if (current.selected && current.group === elementAtIndex.group) {
179
- // return i;
180
- // }
181
- // }
182
- return -1;
183
- },
184
- isSelectableItemAtIndex: (index) => {
185
- const listElement = this.listElement;
186
- if (!listElement) {
187
- return false;
188
- }
189
- const elementAtIndex = listElement.items[index];
190
- if (!elementAtIndex) {
191
- return false;
192
- }
193
- return elementAtIndex.hasAttribute('group');
194
- },
301
+ open: this.open,
302
+ fixed: this.fixed,
303
+ 'has-overflow': this.hasOverflow,
195
304
  };
196
305
  }
197
- onKeydown(evt) {
198
- if (this.mdcFoundation) {
199
- this.mdcFoundation.handleKeydown(evt);
306
+ onListFocus() {
307
+ this.focusRing.visible = shouldShowStrongFocus();
308
+ }
309
+ onListClick() {
310
+ pointerPress();
311
+ this.focusRing.visible = shouldShowStrongFocus();
312
+ }
313
+ onListBlur() {
314
+ this.focusRing.visible = false;
315
+ }
316
+ /**
317
+ * Performs the opening animation:
318
+ *
319
+ * https://direct.googleplex.com/#/spec/295000003+271060003
320
+ */
321
+ animateOpen() {
322
+ const surfaceEl = this.surfaceEl;
323
+ const slotEl = this.slotEl;
324
+ if (!surfaceEl || !slotEl)
325
+ return;
326
+ const openDirection = this.openDirection;
327
+ this.dispatchEvent(new Event('opening'));
328
+ // needs to be imperative because we don't want to mix animation and Lit
329
+ // render timing
330
+ surfaceEl.classList.toggle('animating', true);
331
+ const signal = this.openCloseAnimationSignal.start();
332
+ const height = surfaceEl.offsetHeight;
333
+ const openingUpwards = openDirection === 'UP';
334
+ const children = this.items;
335
+ const FULL_DURATION = 500;
336
+ const SURFACE_OPACITY_DURATION = 50;
337
+ const ITEM_OPACITY_DURATION = 250;
338
+ // We want to fit every child fade-in animation within the full duration of
339
+ // the animation.
340
+ const DELAY_BETWEEN_ITEMS = (FULL_DURATION - ITEM_OPACITY_DURATION) / children.length;
341
+ const surfaceHeightAnimation = surfaceEl.animate([{ height: '0px' }, { height: `${height}px` }], {
342
+ duration: FULL_DURATION,
343
+ easing: EASING.EMPHASIZED,
344
+ });
345
+ // When we are opening upwards, we want to make sure the last item is always
346
+ // in view, so we need to translate it upwards the opposite direction of the
347
+ // height animation
348
+ const upPositionCorrectionAnimation = slotEl.animate([
349
+ { transform: openingUpwards ? `translateY(-${height}px)` : '' },
350
+ { transform: '' }
351
+ ], { duration: FULL_DURATION, easing: EASING.EMPHASIZED });
352
+ const surfaceOpacityAnimation = surfaceEl.animate([{ opacity: 0 }, { opacity: 1 }], SURFACE_OPACITY_DURATION);
353
+ const childrenAnimations = [];
354
+ for (let i = 0; i < children.length; i++) {
355
+ // If we are animating upwards, then reverse the children list.
356
+ const directionalIndex = openingUpwards ? children.length - 1 - i : i;
357
+ const child = children[directionalIndex];
358
+ const animation = child.animate([{ opacity: 0 }, { opacity: 1 }], {
359
+ duration: ITEM_OPACITY_DURATION,
360
+ delay: DELAY_BETWEEN_ITEMS * i,
361
+ });
362
+ // Make them all initially hidden and then clean up at the end of each
363
+ // animation.
364
+ child.classList.toggle('hidden', true);
365
+ animation.addEventListener('finish', () => {
366
+ child.classList.toggle('hidden', false);
367
+ });
368
+ childrenAnimations.push([child, animation]);
200
369
  }
370
+ signal.addEventListener('abort', () => {
371
+ surfaceHeightAnimation.cancel();
372
+ upPositionCorrectionAnimation.cancel();
373
+ surfaceOpacityAnimation.cancel();
374
+ childrenAnimations.forEach(([child, animation]) => {
375
+ child.classList.toggle('hidden', false);
376
+ animation.cancel();
377
+ });
378
+ });
379
+ surfaceHeightAnimation.addEventListener('finish', () => {
380
+ surfaceEl.classList.toggle('animating', false);
381
+ this.openCloseAnimationSignal.finish();
382
+ this.dispatchEvent(new Event('opened'));
383
+ });
201
384
  }
202
- onAction(evt) {
203
- const listElement = this.listElement;
204
- if (this.mdcFoundation && listElement) {
205
- const el = evt.detail.item;
206
- if (el) {
207
- this.mdcFoundation.handleItemAction(el);
385
+ /**
386
+ * Performs the closing animation:
387
+ *
388
+ * https://direct.googleplex.com/#/spec/295000003+271060003
389
+ */
390
+ animateClose() {
391
+ let resolve;
392
+ let reject;
393
+ // This promise blocks the surface position controller from setting
394
+ // display: none on the surface which will interfere with this animation.
395
+ const animationEnded = new Promise((res, rej) => {
396
+ resolve = res;
397
+ reject = rej;
398
+ });
399
+ const surfaceEl = this.surfaceEl;
400
+ const slotEl = this.slotEl;
401
+ if (!surfaceEl || !slotEl) {
402
+ reject();
403
+ return animationEnded;
404
+ }
405
+ const openDirection = this.openDirection;
406
+ const closingDownwards = openDirection === 'UP';
407
+ this.dispatchEvent(new Event('closing'));
408
+ // needs to be imperative because we don't want to mix animation and Lit
409
+ // render timing
410
+ surfaceEl.classList.toggle('animating', true);
411
+ const signal = this.openCloseAnimationSignal.start();
412
+ const height = surfaceEl.offsetHeight;
413
+ const children = this.items;
414
+ const FULL_DURATION = 150;
415
+ const SURFACE_OPACITY_DURATION = 50;
416
+ // The surface fades away at the very end
417
+ const SURFACE_OPACITY_DELAY = FULL_DURATION - SURFACE_OPACITY_DURATION;
418
+ const ITEM_OPACITY_DURATION = 50;
419
+ const ITEM_OPACITY_INITIAL_DELAY = 50;
420
+ const END_HEIGHT_PRECENTAGE = .35;
421
+ // We want to fit every child fade-out animation within the full duration of
422
+ // the animation.
423
+ const DELAY_BETWEEN_ITEMS = (FULL_DURATION - ITEM_OPACITY_INITIAL_DELAY - ITEM_OPACITY_DURATION) /
424
+ children.length;
425
+ // The mock has the animation shrink to 35%
426
+ const surfaceHeightAnimation = surfaceEl.animate([
427
+ { height: `${height}px` },
428
+ { height: `${height * END_HEIGHT_PRECENTAGE}px` }
429
+ ], {
430
+ duration: FULL_DURATION,
431
+ easing: EASING.EMPHASIZED_ACCELERATE,
432
+ });
433
+ // When we are closing downwards, we want to make sure the last item is
434
+ // always in view, so we need to translate it upwards the opposite direction
435
+ // of the height animation
436
+ const downPositionCorrectionAnimation = slotEl.animate([
437
+ { transform: '' }, {
438
+ transform: closingDownwards ?
439
+ `translateY(-${height * (1 - END_HEIGHT_PRECENTAGE)}px)` :
440
+ ''
208
441
  }
442
+ ], { duration: FULL_DURATION, easing: EASING.EMPHASIZED_ACCELERATE });
443
+ const surfaceOpacityAnimation = surfaceEl.animate([{ opacity: 1 }, { opacity: 0 }], { duration: SURFACE_OPACITY_DURATION, delay: SURFACE_OPACITY_DELAY });
444
+ const childrenAnimations = [];
445
+ for (let i = 0; i < children.length; i++) {
446
+ // If the animation is closing upwards, then reverse the list of
447
+ // children so that we animate in the opposite direction.
448
+ const directionalIndex = closingDownwards ? i : children.length - 1 - i;
449
+ const child = children[directionalIndex];
450
+ const animation = child.animate([{ opacity: 1 }, { opacity: 0 }], {
451
+ duration: ITEM_OPACITY_DURATION,
452
+ delay: ITEM_OPACITY_INITIAL_DELAY + DELAY_BETWEEN_ITEMS * i,
453
+ });
454
+ // Make sure the items stay hidden at the end of each child animation.
455
+ // We clean this up at the end of the overall animation.
456
+ animation.addEventListener('finish', () => {
457
+ child.classList.toggle('hidden', true);
458
+ });
459
+ childrenAnimations.push([child, animation]);
209
460
  }
461
+ signal.addEventListener('abort', () => {
462
+ surfaceHeightAnimation.cancel();
463
+ downPositionCorrectionAnimation.cancel();
464
+ surfaceOpacityAnimation.cancel();
465
+ childrenAnimations.forEach(([child, animation]) => {
466
+ animation.cancel();
467
+ child.classList.toggle('hidden', false);
468
+ });
469
+ reject();
470
+ });
471
+ surfaceHeightAnimation.addEventListener('finish', () => {
472
+ surfaceEl.classList.toggle('animating', false);
473
+ childrenAnimations.forEach(([child]) => {
474
+ child.classList.toggle('hidden', false);
475
+ });
476
+ this.openCloseAnimationSignal.finish();
477
+ this.dispatchEvent(new Event('closed'));
478
+ resolve(true);
479
+ });
480
+ return animationEnded;
210
481
  }
211
- onOpened() {
212
- this.skipRestoreFocus = false;
213
- this.open = true;
214
- this.listElement?.resetActiveListItem();
215
- switch (this.defaultFocus) {
216
- case 'FIRST_ITEM':
217
- this.listElement?.activateFirstItem();
218
- break;
219
- case 'LAST_ITEM':
220
- this.listElement?.activateLastItem();
221
- break;
222
- case 'NONE':
223
- // Do nothing.
224
- break;
225
- case 'LIST_ROOT':
226
- default:
227
- this.listElement?.focus();
228
- break;
482
+ connectedCallback() {
483
+ super.connectedCallback();
484
+ if (window && window.addEventListener) {
485
+ window.addEventListener('click', this.onWindowClick, { capture: true });
229
486
  }
230
487
  }
231
- onClosed() {
232
- this.open = false;
488
+ disconnectedCallback() {
489
+ super.disconnectedCallback();
490
+ if (window && window.removeEventListener) {
491
+ window.removeEventListener('click', this.onWindowClick);
492
+ }
233
493
  }
234
- // tslint:disable:ban-ts-suppressions
235
- async getUpdateComplete() {
236
- await this.listUpdateComplete;
237
- // @ts-ignore
238
- const result = await super.getUpdateComplete();
239
- return result;
494
+ onCloseMenu(e) {
495
+ this.close();
240
496
  }
241
- // tslint:enable:ban-ts-suppressions
242
- async firstUpdated() {
243
- if (this.mdcFoundation !== undefined) {
244
- this.mdcFoundation.destroy();
245
- }
246
- this.mdcFoundation = new MDCMenuFoundation(this.createAdapter());
247
- const listElement = this.listElement;
248
- if (listElement) {
249
- this.listUpdateComplete = listElement.updateComplete;
250
- await this.listUpdateComplete;
497
+ onDeactivateItems(e) {
498
+ e.stopPropagation();
499
+ const items = this.items;
500
+ for (const item of items) {
501
+ item.active = false;
251
502
  }
252
503
  }
504
+ focus() {
505
+ this.listElement?.focus();
506
+ }
253
507
  close() {
254
508
  this.open = false;
509
+ this.items.forEach(item => {
510
+ item.close?.();
511
+ });
255
512
  }
256
513
  show() {
257
514
  this.open = true;
258
515
  }
259
516
  }
260
517
  __decorate([
261
- query('.md3-menu'),
262
- __metadata("design:type", MenuSurface)
263
- ], Menu.prototype, "mdcRoot", void 0);
518
+ query('md-list'),
519
+ __metadata("design:type", List)
520
+ ], Menu.prototype, "listElement", void 0);
521
+ __decorate([
522
+ query('.menu'),
523
+ __metadata("design:type", HTMLElement)
524
+ ], Menu.prototype, "surfaceEl", void 0);
264
525
  __decorate([
265
526
  query('slot'),
266
527
  __metadata("design:type", HTMLSlotElement)
267
- ], Menu.prototype, "slotElement", void 0);
528
+ ], Menu.prototype, "slotEl", void 0);
268
529
  __decorate([
269
- property({ type: Object }),
270
- __metadata("design:type", HTMLElement)
271
- ], Menu.prototype, "anchor", void 0);
530
+ query('md-focus-ring'),
531
+ __metadata("design:type", MdFocusRing)
532
+ ], Menu.prototype, "focusRing", void 0);
272
533
  __decorate([
273
- ariaProperty // tslint:disable-line:no-new-decorators
274
- ,
534
+ ariaProperty,
275
535
  property({ type: String, attribute: 'data-aria-label', noAccessor: true }),
276
536
  __metadata("design:type", String)
277
537
  ], Menu.prototype, "ariaLabel", void 0);
278
538
  __decorate([
279
- property({ type: Boolean, reflect: true }),
539
+ property({ attribute: false }),
540
+ __metadata("design:type", HTMLElement)
541
+ ], Menu.prototype, "anchor", void 0);
542
+ __decorate([
543
+ property({ type: Boolean }),
280
544
  __metadata("design:type", Object)
281
- ], Menu.prototype, "open", void 0);
545
+ ], Menu.prototype, "fixed", void 0);
282
546
  __decorate([
283
547
  property({ type: Boolean }),
284
548
  __metadata("design:type", Object)
285
549
  ], Menu.prototype, "quick", void 0);
286
550
  __decorate([
287
- property({ type: String }),
288
- __metadata("design:type", String)
289
- ], Menu.prototype, "corner", void 0);
290
- __decorate([
291
- property({ type: Number }),
292
- __metadata("design:type", Number)
293
- ], Menu.prototype, "x", void 0);
294
- __decorate([
295
- property({ type: Number }),
296
- __metadata("design:type", Number)
297
- ], Menu.prototype, "y", void 0);
298
- __decorate([
299
- property({ type: Boolean }),
551
+ property({ type: Boolean, attribute: 'has-overflow' }),
300
552
  __metadata("design:type", Object)
301
- ], Menu.prototype, "absolute", void 0);
553
+ ], Menu.prototype, "hasOverflow", void 0);
302
554
  __decorate([
303
- property({ type: Boolean }),
555
+ property({ type: Boolean, reflect: true }),
304
556
  __metadata("design:type", Object)
305
- ], Menu.prototype, "activatable", void 0);
557
+ ], Menu.prototype, "open", void 0);
306
558
  __decorate([
307
- property({ type: Boolean }),
559
+ property({ type: Number, attribute: 'x-offset' }),
308
560
  __metadata("design:type", Object)
309
- ], Menu.prototype, "fixed", void 0);
561
+ ], Menu.prototype, "xOffset", void 0);
310
562
  __decorate([
311
- property({ type: Boolean }),
563
+ property({ type: Number, attribute: 'y-offset' }),
312
564
  __metadata("design:type", Object)
313
- ], Menu.prototype, "forceGroupSelection", void 0);
565
+ ], Menu.prototype, "yOffset", void 0);
314
566
  __decorate([
315
- property({ type: Boolean }),
567
+ property({ type: Number, attribute: 'list-tab-index' }),
316
568
  __metadata("design:type", Object)
317
- ], Menu.prototype, "fullwidth", void 0);
569
+ ], Menu.prototype, "listTabIndex", void 0);
318
570
  __decorate([
319
- property({ type: Boolean }),
571
+ property({ type: Number, attribute: 'typeahead-delay' }),
320
572
  __metadata("design:type", Object)
321
- ], Menu.prototype, "flipMenuHorizontally", void 0);
573
+ ], Menu.prototype, "typeaheadBufferTime", void 0);
322
574
  __decorate([
323
- property({ type: Boolean }),
575
+ property({ type: String, attribute: 'anchor-corner' }),
576
+ __metadata("design:type", String)
577
+ ], Menu.prototype, "anchorCorner", void 0);
578
+ __decorate([
579
+ property({ type: String, attribute: 'menu-corner' }),
580
+ __metadata("design:type", String)
581
+ ], Menu.prototype, "menuCorner", void 0);
582
+ __decorate([
583
+ property({ type: Boolean, attribute: 'stay-open-on-outside-click' }),
324
584
  __metadata("design:type", Object)
325
- ], Menu.prototype, "stayOpenOnBodyClick", void 0);
585
+ ], Menu.prototype, "stayOpenOnOutsideClick", void 0);
326
586
  __decorate([
327
- property({ type: Boolean }),
587
+ property({ type: Boolean, attribute: 'skip-restore-focus' }),
328
588
  __metadata("design:type", Object)
329
589
  ], Menu.prototype, "skipRestoreFocus", void 0);
330
590
  __decorate([
331
- property({ type: String }),
591
+ property({ type: String, attribute: 'default-focus' }),
332
592
  __metadata("design:type", String)
333
593
  ], Menu.prototype, "defaultFocus", void 0);
334
594
  //# sourceMappingURL=menu.js.map