@material/web 1.0.0-pre.0 → 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 (423) 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 +12 -29
  19. package/button/lib/_shared.scss +1 -0
  20. package/button/lib/button.d.ts +1 -14
  21. package/button/lib/button.js +6 -42
  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/{elevationold/lib/elevation-overlay-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/{list/lib/divider/list-divider-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/icon/lib/_icon.scss +8 -5
  94. package/icon/lib/icon-styles.css.js +1 -1
  95. package/icon/lib/icon-styles.css.js.map +1 -1
  96. package/iconbutton/lib/_filled-icon-button.scss +1 -1
  97. package/iconbutton/lib/_filled-tonal-icon-button.scss +1 -1
  98. package/iconbutton/lib/_outlined-icon-button.scss +9 -22
  99. package/iconbutton/lib/_shared.scss +14 -40
  100. package/iconbutton/lib/_standard-icon-button.scss +6 -14
  101. package/iconbutton/lib/filled-styles.css.js +1 -1
  102. package/iconbutton/lib/filled-styles.css.js.map +1 -1
  103. package/iconbutton/lib/filled-tonal-styles.css.js +1 -1
  104. package/iconbutton/lib/filled-tonal-styles.css.js.map +1 -1
  105. package/iconbutton/lib/icon-button-toggle.d.ts +13 -42
  106. package/iconbutton/lib/icon-button-toggle.js +33 -103
  107. package/iconbutton/lib/icon-button-toggle.js.map +1 -1
  108. package/iconbutton/lib/icon-button.d.ts +2 -4
  109. package/iconbutton/lib/icon-button.js +3 -9
  110. package/iconbutton/lib/icon-button.js.map +1 -1
  111. package/iconbutton/lib/outlined-styles.css.js +1 -1
  112. package/iconbutton/lib/outlined-styles.css.js.map +1 -1
  113. package/iconbutton/lib/shared-styles.css.js +1 -1
  114. package/iconbutton/lib/shared-styles.css.js.map +1 -1
  115. package/iconbutton/lib/standard-styles.css.js +1 -1
  116. package/iconbutton/lib/standard-styles.css.js.map +1 -1
  117. package/list/lib/_list.scss +32 -40
  118. package/list/lib/avatar/_list-item-avatar.scss +1 -1
  119. package/list/lib/avatar/list-item-avatar-styles.css.js +1 -1
  120. package/list/lib/avatar/list-item-avatar-styles.css.js.map +1 -1
  121. package/list/lib/avatar/list-item-avatar.d.ts +9 -4
  122. package/list/lib/avatar/list-item-avatar.js +24 -11
  123. package/list/lib/avatar/list-item-avatar.js.map +1 -1
  124. package/list/lib/icon/_list-item-icon.scss +3 -1
  125. package/list/lib/icon/list-item-icon-styles.css.js +1 -1
  126. package/list/lib/icon/list-item-icon-styles.css.js.map +1 -1
  127. package/list/lib/icon/list-item-icon.d.ts +0 -3
  128. package/list/lib/icon/list-item-icon.js +1 -12
  129. package/list/lib/icon/list-item-icon.js.map +1 -1
  130. package/list/lib/image/_list-item-image.scss +1 -1
  131. package/list/lib/image/list-item-image-styles.css.js +1 -1
  132. package/list/lib/image/list-item-image-styles.css.js.map +1 -1
  133. package/list/lib/image/list-item-image.d.ts +11 -4
  134. package/list/lib/image/list-item-image.js +24 -13
  135. package/list/lib/image/list-item-image.js.map +1 -1
  136. package/list/lib/list-styles.css.js +1 -1
  137. package/list/lib/list-styles.css.js.map +1 -1
  138. package/list/lib/list.d.ts +99 -28
  139. package/list/lib/list.js +210 -111
  140. package/list/lib/list.js.map +1 -1
  141. package/list/lib/listitem/_list-item.scss +104 -39
  142. package/list/lib/listitem/harness.js +2 -1
  143. package/list/lib/listitem/harness.js.map +1 -1
  144. package/{menu/lib/menu-button-styles.css.d.ts → list/lib/listitem/list-item-private-styles.css.d.ts} +0 -0
  145. package/list/lib/listitem/list-item-private-styles.css.js +9 -0
  146. package/list/lib/listitem/list-item-private-styles.css.js.map +1 -0
  147. package/list/lib/listitem/list-item-private-styles.scss +8 -0
  148. package/list/lib/listitem/list-item-styles.css.js +1 -1
  149. package/list/lib/listitem/list-item-styles.css.js.map +1 -1
  150. package/list/lib/listitem/list-item.d.ts +99 -43
  151. package/list/lib/listitem/list-item.js +201 -172
  152. package/list/lib/listitem/list-item.js.map +1 -1
  153. package/list/lib/listitemlink/list-item-link.d.ts +17 -0
  154. package/list/lib/listitemlink/list-item-link.js +42 -0
  155. package/list/lib/listitemlink/list-item-link.js.map +1 -0
  156. package/list/lib/video/_list-item-video.scss +10 -4
  157. package/list/lib/video/list-item-video-styles.css.js +1 -1
  158. package/list/lib/video/list-item-video-styles.css.js.map +1 -1
  159. package/list/lib/video/list-item-video.d.ts +43 -4
  160. package/list/lib/video/list-item-video.js +90 -12
  161. package/list/lib/video/list-item-video.js.map +1 -1
  162. package/list/list-item-avatar.d.ts +2 -1
  163. package/list/list-item-avatar.js +2 -1
  164. package/list/list-item-avatar.js.map +1 -1
  165. package/list/list-item-icon.d.ts +2 -1
  166. package/list/list-item-icon.js +2 -1
  167. package/list/list-item-icon.js.map +1 -1
  168. package/list/list-item-image.d.ts +2 -1
  169. package/list/list-item-image.js +2 -1
  170. package/list/list-item-image.js.map +1 -1
  171. package/list/list-item-link.d.ts +35 -0
  172. package/list/list-item-link.js +39 -0
  173. package/list/list-item-link.js.map +1 -0
  174. package/list/list-item-video.d.ts +2 -1
  175. package/list/list-item-video.js +2 -1
  176. package/list/list-item-video.js.map +1 -1
  177. package/list/list-item.d.ts +18 -2
  178. package/list/list-item.js +20 -3
  179. package/list/list-item.js.map +1 -1
  180. package/list/list.d.ts +15 -1
  181. package/list/list.js +15 -1
  182. package/list/list.js.map +1 -1
  183. package/menu/_menu-item.scss +6 -0
  184. package/menu/_menu.scss +6 -0
  185. package/menu/harness.d.ts +5 -0
  186. package/menu/harness.js +22 -0
  187. package/menu/harness.js.map +1 -1
  188. package/menu/lib/_menu.scss +61 -62
  189. package/menu/lib/menu-styles.css.js +1 -1
  190. package/menu/lib/menu-styles.css.js.map +1 -1
  191. package/menu/lib/menu.d.ts +176 -42
  192. package/menu/lib/menu.js +506 -246
  193. package/menu/lib/menu.js.map +1 -1
  194. package/menu/lib/menuitem/_menu-item.scss +115 -0
  195. package/{tokens/v0_150/index.test.css.d.ts → menu/lib/menuitem/menu-item-private-styles.css.d.ts} +0 -0
  196. package/menu/lib/menuitem/menu-item-private-styles.css.js +9 -0
  197. package/menu/lib/menuitem/menu-item-private-styles.css.js.map +1 -0
  198. package/menu/lib/menuitem/menu-item-private-styles.scss +8 -0
  199. package/{tokens/v0_150/lib.test.css.d.ts → menu/lib/menuitem/menu-item-styles.css.d.ts} +0 -0
  200. package/menu/lib/menuitem/menu-item-styles.css.js +9 -0
  201. package/menu/lib/menuitem/menu-item-styles.css.js.map +1 -0
  202. package/menu/lib/menuitem/menu-item-styles.scss +8 -0
  203. package/menu/lib/menuitem/menu-item.d.ts +20 -3
  204. package/menu/lib/menuitem/menu-item.js +42 -3
  205. package/menu/lib/menuitem/menu-item.js.map +1 -1
  206. package/menu/lib/menuitemlink/menu-item-link.d.ts +25 -0
  207. package/menu/lib/menuitemlink/menu-item-link.js +51 -0
  208. package/menu/lib/menuitemlink/menu-item-link.js.map +1 -0
  209. package/menu/lib/shared.d.ts +134 -0
  210. package/menu/lib/shared.js +85 -0
  211. package/menu/lib/shared.js.map +1 -0
  212. package/menu/lib/submenuitem/harness.d.ts +11 -0
  213. package/menu/lib/submenuitem/harness.js +12 -0
  214. package/menu/lib/submenuitem/harness.js.map +1 -0
  215. package/menu/lib/submenuitem/sub-menu-item.d.ts +89 -0
  216. package/menu/lib/submenuitem/sub-menu-item.js +266 -0
  217. package/menu/lib/submenuitem/sub-menu-item.js.map +1 -0
  218. package/menu/lib/surfacePositionController.d.ts +117 -0
  219. package/menu/lib/surfacePositionController.js +196 -0
  220. package/menu/lib/surfacePositionController.js.map +1 -0
  221. package/menu/lib/typeaheadController.d.ts +144 -0
  222. package/menu/lib/typeaheadController.js +242 -0
  223. package/menu/lib/typeaheadController.js.map +1 -0
  224. package/menu/menu-item-link.d.ts +33 -0
  225. package/menu/menu-item-link.js +37 -0
  226. package/menu/menu-item-link.js.map +1 -0
  227. package/menu/menu-item.d.ts +19 -2
  228. package/menu/menu-item.js +22 -4
  229. package/menu/menu-item.js.map +1 -1
  230. package/menu/menu.d.ts +45 -0
  231. package/menu/menu.js +43 -0
  232. package/menu/menu.js.map +1 -1
  233. package/menu/sub-menu-item.d.ts +60 -0
  234. package/menu/sub-menu-item.js +64 -0
  235. package/menu/sub-menu-item.js.map +1 -0
  236. package/menusurface/lib/_menu-surface.scss +1 -1
  237. package/menusurface/lib/menu-surface-styles.css.js +1 -1
  238. package/menusurface/lib/menu-surface-styles.css.js.map +1 -1
  239. package/motion/animation.d.ts +20 -3
  240. package/motion/animation.js +39 -4
  241. package/motion/animation.js.map +1 -1
  242. package/navigationbar/lib/_navigation-bar.scss +9 -9
  243. package/navigationbar/lib/navigation-bar-styles.css.js +1 -1
  244. package/navigationbar/lib/navigation-bar-styles.css.js.map +1 -1
  245. package/navigationdrawer/lib/_navigation-drawer.scss +1 -1
  246. package/navigationdrawer/lib/navigation-drawer-styles.css.js +1 -1
  247. package/navigationdrawer/lib/navigation-drawer-styles.css.js.map +1 -1
  248. package/navigationtab/lib/_navigation-tab.scss +8 -19
  249. package/navigationtab/lib/navigation-tab-styles.css.js +1 -1
  250. package/navigationtab/lib/navigation-tab-styles.css.js.map +1 -1
  251. package/package.json +1 -8
  252. package/radio/lib/_radio.scss +21 -22
  253. package/radio/lib/radio-styles.css.js +1 -1
  254. package/radio/lib/radio-styles.css.js.map +1 -1
  255. package/radio/lib/radio.d.ts +10 -1
  256. package/radio/lib/radio.js +12 -3
  257. package/radio/lib/radio.js.map +1 -1
  258. package/radio/radio.d.ts +16 -1
  259. package/radio/radio.js +16 -1
  260. package/radio/radio.js.map +1 -1
  261. package/ripple/lib/_ripple.scss +5 -21
  262. package/ripple/lib/ripple-styles.css.js +1 -1
  263. package/ripple/lib/ripple-styles.css.js.map +1 -1
  264. package/ripple/lib/ripple.js +2 -2
  265. package/ripple/lib/ripple.js.map +1 -1
  266. package/sass/_map-ext.scss +24 -0
  267. package/sass/_string-ext.scss +23 -0
  268. package/segmentedbuttonset/lib/segmented-button-set.d.ts +0 -2
  269. package/segmentedbuttonset/lib/segmented-button-set.js +0 -2
  270. package/segmentedbuttonset/lib/segmented-button-set.js.map +1 -1
  271. package/switch/lib/_handle.scss +56 -9
  272. package/switch/lib/_icon.scss +36 -0
  273. package/switch/lib/_switch.scss +1 -115
  274. package/switch/lib/_track.scss +39 -0
  275. package/switch/lib/switch-styles.css.js +1 -1
  276. package/switch/lib/switch-styles.css.js.map +1 -1
  277. package/switch/lib/switch.d.ts +3 -0
  278. package/switch/lib/switch.js +3 -0
  279. package/switch/lib/switch.js.map +1 -1
  280. package/textfield/lib/_filled-text-field.scss +4 -2
  281. package/textfield/lib/_outlined-text-field.scss +3 -2
  282. package/textfield/lib/filled-styles.css.js +1 -1
  283. package/textfield/lib/filled-styles.css.js.map +1 -1
  284. package/textfield/lib/outlined-styles.css.js +1 -1
  285. package/textfield/lib/outlined-styles.css.js.map +1 -1
  286. package/textfield/lib/text-field.d.ts +0 -2
  287. package/textfield/lib/text-field.js +0 -2
  288. package/textfield/lib/text-field.js.map +1 -1
  289. package/tokens/_index.scss +1 -1
  290. package/tokens/{v0_150 → v0_152}/_index.scss +1 -1
  291. package/tokens/{v0_150 → v0_152}/_md-comp-assist-chip.scss +2 -2
  292. package/tokens/{v0_150 → v0_152}/_md-comp-badge.scss +2 -2
  293. package/tokens/{v0_150 → v0_152}/_md-comp-banner.scss +2 -43
  294. package/tokens/{v0_150 → v0_152}/_md-comp-bottom-app-bar.scss +3 -4
  295. package/tokens/{v0_150 → v0_152}/_md-comp-carousel-item.scss +2 -2
  296. package/tokens/{v0_150 → v0_152}/_md-comp-checkbox.scss +2 -12
  297. package/tokens/{v0_150 → v0_152}/_md-comp-circular-progress-indicator.scss +2 -2
  298. package/tokens/{v0_150 → v0_152}/_md-comp-data-table.scss +2 -4
  299. package/tokens/{v0_150 → v0_152}/_md-comp-date-input-modal.scss +2 -2
  300. package/tokens/{v0_150 → v0_152}/_md-comp-date-picker-docked.scss +2 -2
  301. package/tokens/{v0_150 → v0_152}/_md-comp-date-picker-modal.scss +2 -2
  302. package/tokens/{v0_150 → v0_152}/_md-comp-dialog.scss +2 -25
  303. package/tokens/{v0_150 → v0_152}/_md-comp-divider.scss +2 -2
  304. package/tokens/{v0_150 → v0_152}/_md-comp-elevated-button.scss +2 -2
  305. package/tokens/{v0_150 → v0_152}/_md-comp-elevated-card.scss +2 -2
  306. package/tokens/{v0_150 → v0_152}/_md-comp-extended-fab-branded.scss +2 -2
  307. package/tokens/{v0_150 → v0_152}/_md-comp-extended-fab-primary.scss +2 -2
  308. package/tokens/{v0_150 → v0_152}/_md-comp-extended-fab-secondary.scss +2 -2
  309. package/tokens/{v0_150 → v0_152}/_md-comp-extended-fab-surface.scss +2 -2
  310. package/tokens/{v0_150 → v0_152}/_md-comp-extended-fab-tertiary.scss +2 -4
  311. package/tokens/{v0_150 → v0_152}/_md-comp-fab-branded-large.scss +2 -3
  312. package/tokens/{v0_150 → v0_152}/_md-comp-fab-branded.scss +2 -2
  313. package/tokens/{v0_150 → v0_152}/_md-comp-fab-primary-large.scss +2 -2
  314. package/tokens/{v0_150 → v0_152}/_md-comp-fab-primary-small.scss +2 -2
  315. package/tokens/{v0_150 → v0_152}/_md-comp-fab-primary.scss +2 -2
  316. package/tokens/{v0_150 → v0_152}/_md-comp-fab-secondary-large.scss +2 -2
  317. package/tokens/{v0_150 → v0_152}/_md-comp-fab-secondary-small.scss +2 -2
  318. package/tokens/{v0_150 → v0_152}/_md-comp-fab-secondary.scss +2 -2
  319. package/tokens/{v0_150 → v0_152}/_md-comp-fab-surface-large.scss +2 -2
  320. package/tokens/{v0_150 → v0_152}/_md-comp-fab-surface-small.scss +2 -2
  321. package/tokens/{v0_150 → v0_152}/_md-comp-fab-surface.scss +2 -2
  322. package/tokens/{v0_150 → v0_152}/_md-comp-fab-tertiary-large.scss +2 -2
  323. package/tokens/{v0_150 → v0_152}/_md-comp-fab-tertiary-small.scss +2 -2
  324. package/tokens/{v0_150 → v0_152}/_md-comp-fab-tertiary.scss +2 -2
  325. package/tokens/{v0_150 → v0_152}/_md-comp-filled-autocomplete.scss +2 -3
  326. package/tokens/{v0_150 → v0_152}/_md-comp-filled-button.scss +2 -8
  327. package/tokens/{v0_150 → v0_152}/_md-comp-filled-card.scss +2 -4
  328. package/tokens/{v0_150 → v0_152}/_md-comp-filled-icon-button.scss +2 -2
  329. package/tokens/{v0_150 → v0_152}/_md-comp-filled-menu-button.scss +2 -2
  330. package/tokens/{v0_150 → v0_152}/_md-comp-filled-select.scss +2 -6
  331. package/tokens/{v0_150 → v0_152}/_md-comp-filled-text-field.scss +2 -3
  332. package/tokens/{v0_150 → v0_152}/_md-comp-filled-tonal-button.scss +2 -2
  333. package/tokens/{v0_150 → v0_152}/_md-comp-filled-tonal-icon-button.scss +2 -2
  334. package/tokens/{v0_150 → v0_152}/_md-comp-filter-chip.scss +2 -30
  335. package/tokens/{v0_150 → v0_152}/_md-comp-full-screen-dialog.scss +3 -53
  336. package/tokens/{v0_150 → v0_152}/_md-comp-icon-button.scss +3 -3
  337. package/tokens/{v0_150 → v0_152}/_md-comp-input-chip.scss +2 -52
  338. package/tokens/{v0_150 → v0_152}/_md-comp-linear-progress-indicator.scss +2 -2
  339. package/tokens/{v0_150 → v0_152}/_md-comp-list.scss +3 -12
  340. package/tokens/{v0_150 → v0_152}/_md-comp-menu.scss +2 -4
  341. package/tokens/{v0_150 → v0_152}/_md-comp-navigation-bar.scss +2 -9
  342. package/tokens/{v0_150 → v0_152}/_md-comp-navigation-drawer.scss +2 -8
  343. package/tokens/{v0_150 → v0_152}/_md-comp-navigation-rail.scss +2 -39
  344. package/tokens/{v0_150 → v0_152}/_md-comp-outlined-autocomplete.scss +2 -3
  345. package/tokens/{v0_150 → v0_152}/_md-comp-outlined-button.scss +2 -6
  346. package/tokens/{v0_150 → v0_152}/_md-comp-outlined-card.scss +2 -2
  347. package/tokens/{v0_150 → v0_152}/_md-comp-outlined-icon-button.scss +2 -4
  348. package/tokens/{v0_150 → v0_152}/_md-comp-outlined-menu-button.scss +2 -2
  349. package/tokens/{v0_150 → v0_152}/_md-comp-outlined-segmented-button.scss +2 -2
  350. package/tokens/{v0_150 → v0_152}/_md-comp-outlined-select.scss +2 -6
  351. package/tokens/{v0_150 → v0_152}/_md-comp-outlined-text-field.scss +2 -3
  352. package/tokens/{v0_150 → v0_152}/_md-comp-plain-tooltip.scss +2 -2
  353. package/tokens/{v0_150 → v0_152}/_md-comp-primary-navigation-tab.scss +2 -2
  354. package/tokens/{v0_150 → v0_152}/_md-comp-radio-button.scss +2 -2
  355. package/tokens/{v0_150 → v0_152}/_md-comp-rich-tooltip.scss +2 -2
  356. package/tokens/{v0_150 → v0_152}/_md-comp-scrim.scss +2 -2
  357. package/tokens/{v0_150 → v0_152}/_md-comp-search-bar.scss +2 -2
  358. package/tokens/{v0_150 → v0_152}/_md-comp-search-view.scss +2 -2
  359. package/tokens/{v0_150 → v0_152}/_md-comp-secondary-navigation-tab.scss +2 -2
  360. package/tokens/{v0_150 → v0_152}/_md-comp-sheet-bottom.scss +2 -2
  361. package/tokens/{v0_150 → v0_152}/_md-comp-sheet-floating.scss +2 -2
  362. package/tokens/{v0_150 → v0_152}/_md-comp-sheet-side.scss +4 -2
  363. package/tokens/{v0_150 → v0_152}/_md-comp-slider.scss +2 -4
  364. package/tokens/{v0_150 → v0_152}/_md-comp-snackbar.scss +2 -2
  365. package/tokens/{v0_150 → v0_152}/_md-comp-standard-menu-button.scss +2 -2
  366. package/tokens/{v0_150 → v0_152}/_md-comp-suggestion-chip.scss +2 -2
  367. package/tokens/{v0_150 → v0_152}/_md-comp-switch.scss +2 -11
  368. package/tokens/{v0_150 → v0_152}/_md-comp-text-button.scss +2 -6
  369. package/tokens/{v0_150 → v0_152}/_md-comp-time-input.scss +2 -2
  370. package/tokens/{v0_150 → v0_152}/_md-comp-time-picker.scss +2 -5
  371. package/tokens/{v0_150 → v0_152}/_md-comp-top-app-bar-large.scss +2 -2
  372. package/tokens/{v0_150 → v0_152}/_md-comp-top-app-bar-medium.scss +2 -2
  373. package/tokens/{v0_150 → v0_152}/_md-comp-top-app-bar-small-centered.scss +2 -3
  374. package/tokens/{v0_150 → v0_152}/_md-comp-top-app-bar-small.scss +2 -3
  375. package/tokens/{v0_150 → v0_152}/_md-ref-palette.scss +2 -2
  376. package/tokens/{v0_150 → v0_152}/_md-ref-typeface.scss +2 -2
  377. package/tokens/{v0_150 → v0_152}/_md-sys-color.scss +2 -20
  378. package/tokens/{v0_150 → v0_152}/_md-sys-elevation.scss +4 -13
  379. package/tokens/{v0_150 → v0_152}/_md-sys-motion.scss +2 -2
  380. package/tokens/{v0_150 → v0_152}/_md-sys-shape.scss +2 -2
  381. package/tokens/{v0_150 → v0_152}/_md-sys-state.scss +2 -2
  382. package/tokens/{v0_150 → v0_152}/_md-sys-typescale.scss +2 -3
  383. package/tokens/v0_152/index.test.css.d.ts +1 -0
  384. package/tokens/{v0_150 → v0_152}/index.test.css.js +0 -0
  385. package/tokens/{v0_150 → v0_152}/index.test.css.js.map +0 -0
  386. package/tokens/{v0_150 → v0_152}/index.test.scss +1 -1
  387. package/tokens/v0_152/lib.test.css.d.ts +1 -0
  388. package/tokens/{v0_150 → v0_152}/lib.test.css.js +0 -0
  389. package/tokens/{v0_150 → v0_152}/lib.test.css.js.map +0 -0
  390. package/tokens/{v0_150 → v0_152}/lib.test.scss +1 -1
  391. package/CHANGELOG.md +0 -141
  392. package/elevationold/lib/elevation-overlay-styles.css.js +0 -9
  393. package/elevationold/lib/elevation-overlay-styles.css.js.map +0 -1
  394. package/list/lib/_tokens.scss +0 -80
  395. package/list/lib/divider/_list-divider.scss +0 -46
  396. package/list/lib/divider/list-divider-styles.css.js +0 -9
  397. package/list/lib/divider/list-divider-styles.css.js.map +0 -1
  398. package/list/lib/divider/list-divider-styles.scss +0 -8
  399. package/list/lib/divider/list-divider.d.ts +0 -13
  400. package/list/lib/divider/list-divider.js +0 -32
  401. package/list/lib/divider/list-divider.js.map +0 -1
  402. package/list/list-divider.d.ts +0 -19
  403. package/list/list-divider.js +0 -22
  404. package/list/list-divider.js.map +0 -1
  405. package/menu/lib/_menu-button.scss +0 -14
  406. package/menu/lib/adapter.d.ts +0 -66
  407. package/menu/lib/adapter.js +0 -7
  408. package/menu/lib/adapter.js.map +0 -1
  409. package/menu/lib/constants.d.ts +0 -22
  410. package/menu/lib/constants.js +0 -23
  411. package/menu/lib/constants.js.map +0 -1
  412. package/menu/lib/foundation.d.ts +0 -49
  413. package/menu/lib/foundation.js +0 -123
  414. package/menu/lib/foundation.js.map +0 -1
  415. package/menu/lib/menu-button-styles.css.js +0 -9
  416. package/menu/lib/menu-button-styles.css.js.map +0 -1
  417. package/menu/lib/menu-button-styles.scss +0 -8
  418. package/menu/lib/menu-button.d.ts +0 -27
  419. package/menu/lib/menu-button.js +0 -93
  420. package/menu/lib/menu-button.js.map +0 -1
  421. package/menu/menu-button.d.ts +0 -14
  422. package/menu/menu-button.js +0 -17
  423. package/menu/menu-button.js.map +0 -1
@@ -0,0 +1,85 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * The event that closes any parent menus. It is recommended to subclass and
8
+ * dispatch this event rather than creating your own `close-menu` event.
9
+ */
10
+ export class CloseMenuEvent extends Event {
11
+ constructor(initiator, reason) {
12
+ super('close-menu', { bubbles: true, composed: true });
13
+ this.initiator = initiator;
14
+ this.reason = reason;
15
+ this.itemPath = [initiator];
16
+ }
17
+ }
18
+ /**
19
+ * The default close menu event used by md-menu. To create your own `close-menu`
20
+ * event, you should subclass the `CloseMenuEvent` instead.
21
+ */
22
+ // tslint:disable-next-line
23
+ export const DefaultCloseMenuEvent = (CloseMenuEvent);
24
+ /**
25
+ * The event that requests the parent md-menu to deactivate all other items.
26
+ */
27
+ export class DeactivateItemsEvent extends Event {
28
+ constructor() {
29
+ super('deactivate-items', { bubbles: true, composed: true });
30
+ }
31
+ }
32
+ /**
33
+ * Keys that are used to navigate menus.
34
+ */
35
+ export const NAVIGABLE_KEY = {
36
+ UP: 'ArrowUp',
37
+ DOWN: 'ArrowDown',
38
+ RIGHT: 'ArrowRight',
39
+ LEFT: 'ArrowLeft',
40
+ };
41
+ /**
42
+ * Keys that are used for selection in menus.
43
+ */
44
+ export const SELECTION_KEY = {
45
+ SPACE: 'Space',
46
+ ENTER: 'Enter',
47
+ };
48
+ /**
49
+ * Default close `Reason` kind values.
50
+ */
51
+ export const CLOSE_REASON = {
52
+ CLICK_SELECTION: 'CLICK_SELECTION',
53
+ KEYDOWN: 'KEYDOWN',
54
+ };
55
+ /**
56
+ * Keys that can close menus.
57
+ */
58
+ export const KEYDOWN_CLOSE_KEYS = {
59
+ ESCAPE: 'Escape',
60
+ SPACE: SELECTION_KEY.SPACE,
61
+ ENTER: SELECTION_KEY.ENTER,
62
+ };
63
+ /**
64
+ * Determines whether the given key code is a key code that should close the
65
+ * menu.
66
+ *
67
+ * @param code The KeyboardEvent code to check.
68
+ * @return Whether or not the key code is in the predetermined list to close the
69
+ * menu.
70
+ */
71
+ export function isClosableKey(code) {
72
+ return Object.values(KEYDOWN_CLOSE_KEYS).some(value => (value === code));
73
+ }
74
+ /**
75
+ * Determines whether the given key code is a key code that should select a menu
76
+ * item.
77
+ *
78
+ * @param code They KeyboardEvent code to check.
79
+ * @return Whether or not the key code is in the predetermined list to select a
80
+ * menu item.
81
+ */
82
+ export function isSelectableKey(code) {
83
+ return Object.values(SELECTION_KEY).some(value => (value === code));
84
+ }
85
+ //# sourceMappingURL=shared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AOG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IAExC,OAAO,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAE1C,OAAO,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC;AACtE,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {ListItem} from '../../list/lib/listitem/list-item.js';\n\n/**\n * Interface specific to menu item and not list item.\n */\ninterface MenuItemSelf {\n /**\n * The visible headline text of the item.\n */\n headline: string;\n /**\n * Whether or not the item is in the selected visual state (focuses on\n * selection).\n */\n active: boolean;\n /**\n * If it is a sub-menu-item, a method that can close the submenu.\n */\n close?: () => void;\n}\n\n/**\n * The interface of every menu item interactive with a menu. All menu items\n * should implement this interface to be compatible with md-menu. Additionally\n * they should have both the `md-menu-item` and `md-list-item` attributes set.\n */\nexport type MenuItem = MenuItemSelf&ListItem;\n\n/**\n * The reason the `close-menu` event was dispatched.\n */\nexport interface Reason {\n kind: string;\n}\n\n/**\n * The click selection reason for the `close-menu` event. The menu was closed\n * because an item was selected via user click.\n */\nexport interface ClickReason extends Reason {\n kind: typeof CLOSE_REASON.CLICK_SELECTION;\n}\n\n/**\n * The keydown reason for the `close-menu` event. The menu was closed\n * because a specific key was pressed. The default closing keys for\n * `md-menu-item` are, Space, Enter or Escape.\n */\nexport interface KeydownReason extends Reason {\n kind: typeof CLOSE_REASON.KEYDOWN;\n key: string;\n}\n\n/**\n * The default menu closing reasons for the material md-menu package.\n */\nexport type DefaultReasons = ClickReason|KeydownReason;\n\n/**\n * The event that closes any parent menus. It is recommended to subclass and\n * dispatch this event rather than creating your own `close-menu` event.\n */\nexport class CloseMenuEvent<T extends Reason = DefaultReasons> extends Event {\n readonly itemPath: MenuItem[];\n constructor(public initiator: MenuItem, readonly reason: T) {\n super('close-menu', {bubbles: true, composed: true});\n this.itemPath = [initiator];\n }\n}\n\n/**\n * The default close menu event used by md-menu. To create your own `close-menu`\n * event, you should subclass the `CloseMenuEvent` instead.\n */\n// tslint:disable-next-line\nexport const DefaultCloseMenuEvent = CloseMenuEvent<DefaultReasons>;\n\n/**\n * The event that requests the parent md-menu to deactivate all other items.\n */\nexport class DeactivateItemsEvent extends Event {\n constructor() {\n super('deactivate-items', {bubbles: true, composed: true});\n }\n}\n\n/**\n * Keys that are used to navigate menus.\n */\nexport const NAVIGABLE_KEY = {\n UP: 'ArrowUp',\n DOWN: 'ArrowDown',\n RIGHT: 'ArrowRight',\n LEFT: 'ArrowLeft',\n} as const;\n\n/**\n * Keys that are used for selection in menus.\n */\nexport const SELECTION_KEY = {\n SPACE: 'Space',\n ENTER: 'Enter',\n} as const;\n\n/**\n * Default close `Reason` kind values.\n */\nexport const CLOSE_REASON = {\n CLICK_SELECTION: 'CLICK_SELECTION',\n KEYDOWN: 'KEYDOWN',\n} as const;\n\n/**\n * Keys that can close menus.\n */\nexport const KEYDOWN_CLOSE_KEYS = {\n ESCAPE: 'Escape',\n SPACE: SELECTION_KEY.SPACE,\n ENTER: SELECTION_KEY.ENTER,\n} as const;\n\ntype Values<T> = T[keyof T];\n\n/**\n * Determines whether the given key code is a key code that should close the\n * menu.\n *\n * @param code The KeyboardEvent code to check.\n * @return Whether or not the key code is in the predetermined list to close the\n * menu.\n */\nexport function isClosableKey(code: string):\n code is Values<typeof KEYDOWN_CLOSE_KEYS> {\n return Object.values(KEYDOWN_CLOSE_KEYS).some(value => (value === code));\n}\n\n/**\n * Determines whether the given key code is a key code that should select a menu\n * item.\n *\n * @param code They KeyboardEvent code to check.\n * @return Whether or not the key code is in the predetermined list to select a\n * menu item.\n */\nexport function isSelectableKey(code: string):\n code is Values<typeof SELECTION_KEY> {\n return Object.values(SELECTION_KEY).some(value => (value === code));\n}\n"]}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { ListItemHarness } from '../../../list/lib/listitem/harness.js';
7
+ /**
8
+ * Test harness for menu item.
9
+ */
10
+ export declare class MenuItemHarness extends ListItemHarness {
11
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { ListItemHarness } from '../../../list/lib/listitem/harness.js';
7
+ /**
8
+ * Test harness for menu item.
9
+ */
10
+ export class MenuItemHarness extends ListItemHarness {
11
+ }
12
+ //# sourceMappingURL=harness.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"harness.js","sourceRoot":"","sources":["harness.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,eAAe,EAAC,MAAM,uCAAuC,CAAC;AAEtE;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,eAAe;CAAG","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {ListItemHarness} from '../../../list/lib/listitem/harness.js';\n\n/**\n * Test harness for menu item.\n */\nexport class MenuItemHarness extends ListItemHarness {}\n"]}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { ARIARole } from '../../../types/aria.js';
7
+ import { Corner, Menu } from '../menu.js';
8
+ import { MenuItemEl } from '../menuitem/menu-item.js';
9
+ import { CloseMenuEvent } from '../shared.js';
10
+ /**
11
+ * @fires deactivate-items {DeactivateItemsEvent} Requests the parent menu to
12
+ * deselect other items when a submenu opens
13
+ */
14
+ export declare class SubMenuItem extends MenuItemEl {
15
+ role: ARIARole;
16
+ /**
17
+ * The anchorCorner to set on the submenu.
18
+ */
19
+ anchorCorner: Corner;
20
+ /**
21
+ * The menuCorner to set on the submenu.
22
+ */
23
+ menuCorner: Corner;
24
+ /**
25
+ * The delay between pointerenter and submenu opening.
26
+ */
27
+ hoverOpenDelay: number;
28
+ /**
29
+ * The delay between ponterleave and the submenu closing.
30
+ */
31
+ hoverCloseDelay: number;
32
+ protected menus: Menu[];
33
+ protected keepOpenOnClick: boolean;
34
+ protected previousOpenTimeout: number;
35
+ protected previousCloseTimeout: number;
36
+ protected submenuOpen: boolean;
37
+ protected get submenuEl(): Menu | undefined;
38
+ /**
39
+ * Starts the default 400ms countdown to open the submenu.
40
+ */
41
+ protected onPointerenter: () => void;
42
+ /**
43
+ * Starts the default 400ms countdown to close the submenu.
44
+ */
45
+ protected onPointerleave: () => void;
46
+ protected onClick(): void;
47
+ /**
48
+ * On item keydown handles opening the submenu.
49
+ */
50
+ protected onKeydown(e: KeyboardEvent): void;
51
+ /**
52
+ * Render the submenu at the end
53
+ */
54
+ protected renderEnd(): import("lit-html").TemplateResult<1>;
55
+ /**
56
+ * Renders the slot for the submenu.
57
+ */
58
+ protected renderSubMenu(): import("lit-html").TemplateResult<1>;
59
+ protected onCloseSubmenu(e: CloseMenuEvent): void;
60
+ protected onSubMenuKeydown(e: KeyboardEvent): Promise<void>;
61
+ /**
62
+ * Shows the submenu.
63
+ *
64
+ * @param onOpened A function to call after the menu is opened.
65
+ */
66
+ show(onOpened?: () => void): void;
67
+ /**
68
+ * Closes the submenu.
69
+ *
70
+ * @param onClosed A function to call after the menu is closed.
71
+ */
72
+ close(onClosed?: () => void): void;
73
+ /**
74
+ * Determines whether the given KeyboardEvent code is one that should open
75
+ * the submenu. This is RTL-aware. By default, left, right, space, or enter.
76
+ *
77
+ * @param code The native KeyboardEvent code.
78
+ * @return Whether or not the key code should open the submenu.
79
+ */
80
+ protected isSubmenuOpenKey(code: string): boolean;
81
+ /**
82
+ * Determines whether the given KeyboardEvent code is one that should close
83
+ * the submenu. This is RTL-aware. By default right, left, or escape.
84
+ *
85
+ * @param code The native KeyboardEvent code.
86
+ * @return Whether or not the key code should close the submenu.
87
+ */
88
+ protected isSubmenuCloseKey(code: string): boolean;
89
+ }
@@ -0,0 +1,266 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { __decorate, __metadata } from "tslib";
7
+ import { html } from 'lit';
8
+ import { property, queryAssignedElements } from 'lit/decorators.js';
9
+ import { List } from '../../../list/lib/list.js';
10
+ import { MenuItemEl } from '../menuitem/menu-item.js';
11
+ import { CLOSE_REASON, DeactivateItemsEvent, KEYDOWN_CLOSE_KEYS, NAVIGABLE_KEY, SELECTION_KEY } from '../shared.js';
12
+ function stopPropagation(e) {
13
+ e.stopPropagation();
14
+ }
15
+ /**
16
+ * @fires deactivate-items {DeactivateItemsEvent} Requests the parent menu to
17
+ * deselect other items when a submenu opens
18
+ */
19
+ export class SubMenuItem extends MenuItemEl {
20
+ constructor() {
21
+ super(...arguments);
22
+ this.role = 'menuitem';
23
+ /**
24
+ * The anchorCorner to set on the submenu.
25
+ */
26
+ this.anchorCorner = 'START_END';
27
+ /**
28
+ * The menuCorner to set on the submenu.
29
+ */
30
+ this.menuCorner = 'START_START';
31
+ /**
32
+ * The delay between pointerenter and submenu opening.
33
+ */
34
+ this.hoverOpenDelay = 400;
35
+ /**
36
+ * The delay between ponterleave and the submenu closing.
37
+ */
38
+ this.hoverCloseDelay = 400;
39
+ this.keepOpenOnClick = true;
40
+ this.previousOpenTimeout = 0;
41
+ this.previousCloseTimeout = 0;
42
+ this.submenuOpen = false;
43
+ /**
44
+ * Starts the default 400ms countdown to open the submenu.
45
+ */
46
+ this.onPointerenter = () => {
47
+ clearTimeout(this.previousOpenTimeout);
48
+ clearTimeout(this.previousCloseTimeout);
49
+ if (this.submenuEl?.open)
50
+ return;
51
+ // Open synchronously if delay is 0. (screenshot tests infra
52
+ // would never resolve otherwise)
53
+ if (!this.hoverOpenDelay) {
54
+ this.show();
55
+ }
56
+ else {
57
+ this.previousOpenTimeout = setTimeout(() => {
58
+ this.show();
59
+ }, this.hoverOpenDelay);
60
+ }
61
+ };
62
+ /**
63
+ * Starts the default 400ms countdown to close the submenu.
64
+ */
65
+ this.onPointerleave = () => {
66
+ clearTimeout(this.previousCloseTimeout);
67
+ clearTimeout(this.previousOpenTimeout);
68
+ // Close synchronously if delay is 0. (screenshot tests infra
69
+ // would never resolve otherwise)
70
+ if (!this.hoverCloseDelay) {
71
+ this.close();
72
+ }
73
+ else {
74
+ this.previousCloseTimeout = setTimeout(() => {
75
+ this.close();
76
+ }, this.hoverCloseDelay);
77
+ }
78
+ };
79
+ }
80
+ get submenuEl() {
81
+ return this.menus[0];
82
+ }
83
+ onClick() {
84
+ this.show();
85
+ }
86
+ /**
87
+ * On item keydown handles opening the submenu.
88
+ */
89
+ onKeydown(e) {
90
+ const shouldOpenSubmenu = this.isSubmenuOpenKey(e.code);
91
+ if (e.code === SELECTION_KEY.SPACE) {
92
+ // prevent space from scrolling. Only open the submenu.
93
+ e.preventDefault();
94
+ }
95
+ if (!shouldOpenSubmenu) {
96
+ super.onKeydown(e);
97
+ return;
98
+ }
99
+ const submenu = this.submenuEl;
100
+ if (!submenu)
101
+ return;
102
+ const submenuItems = submenu.items;
103
+ const firstActivatableItem = List.getFirstActivatableItem(submenuItems);
104
+ if (firstActivatableItem) {
105
+ this.show(() => {
106
+ firstActivatableItem.active = true;
107
+ });
108
+ return;
109
+ }
110
+ }
111
+ /**
112
+ * Render the submenu at the end
113
+ */
114
+ renderEnd() {
115
+ return html `${super.renderEnd()}${this.renderSubMenu()}`;
116
+ }
117
+ /**
118
+ * Renders the slot for the submenu.
119
+ */
120
+ renderSubMenu() {
121
+ return html `<span class="submenu"><slot
122
+ name="submenu"
123
+ @pointerdown=${stopPropagation}
124
+ @click=${stopPropagation}
125
+ @keydown=${this.onSubMenuKeydown}
126
+ @close-menu=${this.onCloseSubmenu}
127
+ ></slot></span>`;
128
+ }
129
+ onCloseSubmenu(e) {
130
+ e.itemPath.push(this);
131
+ // Escape should only close one menu not all of the menus unlike space or
132
+ // click selection which should close all menus.
133
+ if (e.reason.kind === CLOSE_REASON.KEYDOWN &&
134
+ e.reason.key === KEYDOWN_CLOSE_KEYS.ESCAPE) {
135
+ e.stopPropagation();
136
+ this.active = true;
137
+ // It might already be active so manually focus
138
+ this.listItemRoot.focus();
139
+ return;
140
+ }
141
+ this.active = false;
142
+ }
143
+ async onSubMenuKeydown(e) {
144
+ // Stop propagation so that we don't accidentally close every parent menu.
145
+ // Additionally, we want to isolate things like the typeahead keydowns
146
+ // from bubbling up to the parent menu and confounding things.
147
+ e.stopPropagation();
148
+ const shouldClose = this.isSubmenuCloseKey(e.code);
149
+ if (!shouldClose)
150
+ return;
151
+ this.close(() => {
152
+ List.deactivateActiveItem(this.submenuEl.items);
153
+ this.listItemRoot.focus();
154
+ this.active = true;
155
+ });
156
+ }
157
+ /**
158
+ * Shows the submenu.
159
+ *
160
+ * @param onOpened A function to call after the menu is opened.
161
+ */
162
+ show(onOpened = () => { }) {
163
+ const menu = this.submenuEl;
164
+ if (!menu)
165
+ return;
166
+ menu.quick = true;
167
+ // Submenus are in overflow when not fixed. Can remove once we have native
168
+ // popup support
169
+ menu.hasOverflow = true;
170
+ menu.anchorCorner = this.anchorCorner;
171
+ menu.menuCorner = this.menuCorner;
172
+ menu.anchor = this;
173
+ // We manually set focus with `active` on keyboard navigation. And we
174
+ // want to focus the root on hover, so the user can pick up navigation with
175
+ // keyboard after hover.
176
+ menu.defaultFocus = 'LIST_ROOT';
177
+ menu.skipRestoreFocus = true;
178
+ // Menu could already be opened because of mouse interaction
179
+ const menuAlreadyOpen = menu.open;
180
+ menu.show();
181
+ // Deactivate other items. This can be the case if the user has tabbed
182
+ // around the menu and then mouses over an md-sub-menu.
183
+ this.dispatchEvent(new DeactivateItemsEvent());
184
+ this.active = true;
185
+ // This is the case of mouse hovering when already opened via keyboard or
186
+ // vice versa
187
+ if (menuAlreadyOpen) {
188
+ onOpened();
189
+ }
190
+ else {
191
+ menu.addEventListener('opened', onOpened, { once: true });
192
+ }
193
+ }
194
+ /**
195
+ * Closes the submenu.
196
+ *
197
+ * @param onClosed A function to call after the menu is closed.
198
+ */
199
+ close(onClosed = () => { }) {
200
+ const menu = this.submenuEl;
201
+ if (!menu || !menu.open)
202
+ return;
203
+ menu.quick = true;
204
+ menu.close();
205
+ this.active = false;
206
+ menu.addEventListener('closed', onClosed, { once: true });
207
+ }
208
+ /**
209
+ * Determines whether the given KeyboardEvent code is one that should open
210
+ * the submenu. This is RTL-aware. By default, left, right, space, or enter.
211
+ *
212
+ * @param code The native KeyboardEvent code.
213
+ * @return Whether or not the key code should open the submenu.
214
+ */
215
+ isSubmenuOpenKey(code) {
216
+ const isRtl = getComputedStyle(this).direction === 'rtl';
217
+ const arrowEnterKey = isRtl ? NAVIGABLE_KEY.LEFT : NAVIGABLE_KEY.RIGHT;
218
+ switch (code) {
219
+ case arrowEnterKey:
220
+ case SELECTION_KEY.SPACE:
221
+ case SELECTION_KEY.ENTER:
222
+ return true;
223
+ default:
224
+ return false;
225
+ }
226
+ }
227
+ /**
228
+ * Determines whether the given KeyboardEvent code is one that should close
229
+ * the submenu. This is RTL-aware. By default right, left, or escape.
230
+ *
231
+ * @param code The native KeyboardEvent code.
232
+ * @return Whether or not the key code should close the submenu.
233
+ */
234
+ isSubmenuCloseKey(code) {
235
+ const isRtl = getComputedStyle(this).direction === 'rtl';
236
+ const arrowEnterKey = isRtl ? NAVIGABLE_KEY.RIGHT : NAVIGABLE_KEY.LEFT;
237
+ switch (code) {
238
+ case arrowEnterKey:
239
+ case KEYDOWN_CLOSE_KEYS.ESCAPE:
240
+ return true;
241
+ default:
242
+ return false;
243
+ }
244
+ }
245
+ }
246
+ __decorate([
247
+ property({ attribute: 'anchor-corner' }),
248
+ __metadata("design:type", String)
249
+ ], SubMenuItem.prototype, "anchorCorner", void 0);
250
+ __decorate([
251
+ property({ attribute: 'menu-corner' }),
252
+ __metadata("design:type", String)
253
+ ], SubMenuItem.prototype, "menuCorner", void 0);
254
+ __decorate([
255
+ property({ type: Number, attribute: 'hover-open-delay' }),
256
+ __metadata("design:type", Object)
257
+ ], SubMenuItem.prototype, "hoverOpenDelay", void 0);
258
+ __decorate([
259
+ property({ type: Number, attribute: 'hover-close-delay' }),
260
+ __metadata("design:type", Object)
261
+ ], SubMenuItem.prototype, "hoverCloseDelay", void 0);
262
+ __decorate([
263
+ queryAssignedElements({ slot: 'submenu' }),
264
+ __metadata("design:type", Array)
265
+ ], SubMenuItem.prototype, "menus", void 0);
266
+ //# sourceMappingURL=sub-menu-item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sub-menu-item.js","sourceRoot":"","sources":["sub-menu-item.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,IAAI,EAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAC,QAAQ,EAAE,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AAElE,OAAO,EAAC,IAAI,EAAC,MAAM,2BAA2B,CAAC;AAG/C,OAAO,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAC,YAAY,EAAkB,oBAAoB,EAAE,kBAAkB,EAAE,aAAa,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAElI,SAAS,eAAe,CAAC,CAAQ;IAC/B,CAAC,CAAC,eAAe,EAAE,CAAC;AACtB,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,UAAU;IAA3C;;QACW,SAAI,GAAa,UAAU,CAAC;QACrC;;WAEG;QACqC,iBAAY,GAAW,WAAW,CAAC;QAC3E;;WAEG;QACmC,eAAU,GAAW,aAAa,CAAC;QACzE;;WAEG;QACsD,mBAAc,GAAG,GAAG,CAAC;QAC9E;;WAEG;QAEH,oBAAe,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tB,OAAO,IAAI,CAAC;YACd;gBACE,OAAO,KAAK,CAAC;SAChB;IACH,CAAC;IAED;;;;;;OAMG;IACO,iBAAiB,CAAC,IAAY;QACtC,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,SAAS,KAAK,KAAK,CAAC;QACzD,MAAM,aAAa,GAAG,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC;QACvE,QAAQ,IAAI,EAAE;YACZ,KAAK,aAAa,CAAC;YACnB,KAAK,kBAAkB,CAAC,MAAM;gBAC5B,OAAO,IAAI,CAAC;YACd;gBACE,OAAO,KAAK,CAAC;SAChB;IACH,CAAC;CACF;AAlPyC;IAAvC,QAAQ,CAAC,EAAC,SAAS,EAAE,eAAe,EAAC,CAAC;;iDAAoC;AAIrC;IAArC,QAAQ,CAAC,EAAC,SAAS,EAAE,aAAa,EAAC,CAAC;;+CAAoC;AAIhB;IAAxD,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAC,CAAC;;mDAAsB;AAK9E;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,mBAAmB,EAAC,CAAC;;oDACnC;AAEoB;IAAzC,qBAAqB,CAAC,EAAC,IAAI,EAAE,SAAS,EAAC,CAAC;;0CAA0B","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {html} from 'lit';\nimport {property, queryAssignedElements} from 'lit/decorators.js';\n\nimport {List} from '../../../list/lib/list.js';\nimport {ARIARole} from '../../../types/aria.js';\nimport {Corner, Menu} from '../menu.js';\nimport {MenuItemEl} from '../menuitem/menu-item.js';\nimport {CLOSE_REASON, CloseMenuEvent, DeactivateItemsEvent, KEYDOWN_CLOSE_KEYS, NAVIGABLE_KEY, SELECTION_KEY} from '../shared.js';\n\nfunction stopPropagation(e: Event) {\n e.stopPropagation();\n}\n\n/**\n * @fires deactivate-items {DeactivateItemsEvent} Requests the parent menu to\n * deselect other items when a submenu opens\n */\nexport class SubMenuItem extends MenuItemEl {\n override role: ARIARole = 'menuitem';\n /**\n * The anchorCorner to set on the submenu.\n */\n @property({attribute: 'anchor-corner'}) anchorCorner: Corner = 'START_END';\n /**\n * The menuCorner to set on the submenu.\n */\n @property({attribute: 'menu-corner'}) menuCorner: Corner = 'START_START';\n /**\n * The delay between pointerenter and submenu opening.\n */\n @property({type: Number, attribute: 'hover-open-delay'}) hoverOpenDelay = 400;\n /**\n * The delay between ponterleave and the submenu closing.\n */\n @property({type: Number, attribute: 'hover-close-delay'})\n hoverCloseDelay = 400;\n\n @queryAssignedElements({slot: 'submenu'}) protected menus!: Menu[];\n\n protected override keepOpenOnClick = true;\n protected previousOpenTimeout = 0;\n protected previousCloseTimeout = 0;\n protected submenuOpen = false;\n\n protected get submenuEl(): Menu|undefined {\n return this.menus[0];\n }\n\n /**\n * Starts the default 400ms countdown to open the submenu.\n */\n protected override onPointerenter = () => {\n clearTimeout(this.previousOpenTimeout);\n clearTimeout(this.previousCloseTimeout);\n if (this.submenuEl?.open) return;\n\n // Open synchronously if delay is 0. (screenshot tests infra\n // would never resolve otherwise)\n if (!this.hoverOpenDelay) {\n this.show();\n } else {\n this.previousOpenTimeout = setTimeout(() => {\n this.show();\n }, this.hoverOpenDelay);\n }\n };\n\n /**\n * Starts the default 400ms countdown to close the submenu.\n */\n protected override onPointerleave = () => {\n clearTimeout(this.previousCloseTimeout);\n clearTimeout(this.previousOpenTimeout);\n\n // Close synchronously if delay is 0. (screenshot tests infra\n // would never resolve otherwise)\n if (!this.hoverCloseDelay) {\n this.close();\n } else {\n this.previousCloseTimeout = setTimeout(() => {\n this.close();\n }, this.hoverCloseDelay);\n }\n };\n\n protected override onClick() {\n this.show();\n }\n\n /**\n * On item keydown handles opening the submenu.\n */\n protected override onKeydown(e: KeyboardEvent) {\n const shouldOpenSubmenu = this.isSubmenuOpenKey(e.code);\n\n if (e.code === SELECTION_KEY.SPACE) {\n // prevent space from scrolling. Only open the submenu.\n e.preventDefault();\n }\n\n if (!shouldOpenSubmenu) {\n super.onKeydown(e);\n return;\n }\n\n const submenu = this.submenuEl;\n if (!submenu) return;\n\n const submenuItems = submenu.items;\n const firstActivatableItem = List.getFirstActivatableItem(submenuItems);\n\n if (firstActivatableItem) {\n this.show(() => {\n firstActivatableItem.active = true;\n });\n\n return;\n }\n }\n\n /**\n * Render the submenu at the end\n */\n protected override renderEnd() {\n return html`${super.renderEnd()}${this.renderSubMenu()}`;\n }\n\n /**\n * Renders the slot for the submenu.\n */\n protected renderSubMenu() {\n return html`<span class=\"submenu\"><slot\n name=\"submenu\"\n @pointerdown=${stopPropagation}\n @click=${stopPropagation}\n @keydown=${this.onSubMenuKeydown}\n @close-menu=${this.onCloseSubmenu}\n ></slot></span>`;\n }\n\n protected onCloseSubmenu(e: CloseMenuEvent) {\n e.itemPath.push(this);\n // Escape should only close one menu not all of the menus unlike space or\n // click selection which should close all menus.\n if (e.reason.kind === CLOSE_REASON.KEYDOWN &&\n e.reason.key === KEYDOWN_CLOSE_KEYS.ESCAPE) {\n e.stopPropagation();\n this.active = true;\n // It might already be active so manually focus\n this.listItemRoot.focus();\n return;\n }\n this.active = false;\n }\n\n protected async onSubMenuKeydown(e: KeyboardEvent) {\n // Stop propagation so that we don't accidentally close every parent menu.\n // Additionally, we want to isolate things like the typeahead keydowns\n // from bubbling up to the parent menu and confounding things.\n e.stopPropagation();\n const shouldClose = this.isSubmenuCloseKey(e.code);\n\n if (!shouldClose) return;\n\n this.close(() => {\n List.deactivateActiveItem(this.submenuEl!.items);\n this.listItemRoot.focus();\n this.active = true;\n });\n }\n\n /**\n * Shows the submenu.\n *\n * @param onOpened A function to call after the menu is opened.\n */\n show(onOpened = () => {}) {\n const menu = this.submenuEl;\n if (!menu) return;\n\n menu.quick = true;\n // Submenus are in overflow when not fixed. Can remove once we have native\n // popup support\n menu.hasOverflow = true;\n menu.anchorCorner = this.anchorCorner;\n menu.menuCorner = this.menuCorner;\n menu.anchor = this;\n // We manually set focus with `active` on keyboard navigation. And we\n // want to focus the root on hover, so the user can pick up navigation with\n // keyboard after hover.\n menu.defaultFocus = 'LIST_ROOT';\n menu.skipRestoreFocus = true;\n\n // Menu could already be opened because of mouse interaction\n const menuAlreadyOpen = menu.open;\n menu.show();\n\n // Deactivate other items. This can be the case if the user has tabbed\n // around the menu and then mouses over an md-sub-menu.\n this.dispatchEvent(new DeactivateItemsEvent());\n this.active = true;\n\n // This is the case of mouse hovering when already opened via keyboard or\n // vice versa\n if (menuAlreadyOpen) {\n onOpened();\n } else {\n menu.addEventListener('opened', onOpened, {once: true});\n }\n }\n\n /**\n * Closes the submenu.\n *\n * @param onClosed A function to call after the menu is closed.\n */\n close(onClosed = () => {}) {\n const menu = this.submenuEl;\n if (!menu || !menu.open) return;\n\n menu.quick = true;\n menu.close();\n this.active = false;\n menu.addEventListener('closed', onClosed, {once: true});\n }\n\n /**\n * Determines whether the given KeyboardEvent code is one that should open\n * the submenu. This is RTL-aware. By default, left, right, space, or enter.\n *\n * @param code The native KeyboardEvent code.\n * @return Whether or not the key code should open the submenu.\n */\n protected isSubmenuOpenKey(code: string) {\n const isRtl = getComputedStyle(this).direction === 'rtl';\n const arrowEnterKey = isRtl ? NAVIGABLE_KEY.LEFT : NAVIGABLE_KEY.RIGHT;\n switch (code) {\n case arrowEnterKey:\n case SELECTION_KEY.SPACE:\n case SELECTION_KEY.ENTER:\n return true;\n default:\n return false;\n }\n }\n\n /**\n * Determines whether the given KeyboardEvent code is one that should close\n * the submenu. This is RTL-aware. By default right, left, or escape.\n *\n * @param code The native KeyboardEvent code.\n * @return Whether or not the key code should close the submenu.\n */\n protected isSubmenuCloseKey(code: string) {\n const isRtl = getComputedStyle(this).direction === 'rtl';\n const arrowEnterKey = isRtl ? NAVIGABLE_KEY.RIGHT : NAVIGABLE_KEY.LEFT;\n switch (code) {\n case arrowEnterKey:\n case KEYDOWN_CLOSE_KEYS.ESCAPE:\n return true;\n default:\n return false;\n }\n }\n}\n"]}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { ReactiveController, ReactiveControllerHost } from 'lit';
7
+ import { StyleInfo } from 'lit/directives/style-map.js';
8
+ /**
9
+ * A corner of a box in the standard logical property style of <block>_<inline>
10
+ */
11
+ export declare type Corner = 'END_START' | 'END_END' | 'START_START' | 'START_END';
12
+ /**
13
+ * The configurable options for the surface position controller.
14
+ */
15
+ export interface SurfacePositionControllerProperties {
16
+ /**
17
+ * The corner of the anchor to align the surface's position.
18
+ */
19
+ anchorCorner: Corner;
20
+ /**
21
+ * The corner of the surface to align to the given anchor corner.
22
+ */
23
+ surfaceCorner: Corner;
24
+ /**
25
+ * The HTMLElement reference of the surface to be positioned.
26
+ */
27
+ surfaceEl: HTMLElement | null;
28
+ /**
29
+ * The HTMLElement reference of the anchor to align to.
30
+ */
31
+ anchorEl: HTMLElement | null;
32
+ /**
33
+ * Whether or not the calculation should be relative to the top layer rather
34
+ * than relative to the parent of the anchor.
35
+ *
36
+ * Examples for `isTopLayer:true`:
37
+ *
38
+ * - If there is no `position:relative` in the given parent tree and the
39
+ * surface is `position:absolute`
40
+ * - If the surface is `position:fixed`
41
+ * - If the surface is in the "top layer"
42
+ * - The anchor and the surface do not share a common `position:relative`
43
+ * ancestor
44
+ */
45
+ isTopLayer: boolean;
46
+ /**
47
+ * Whether or not the surface should be "open" and visible
48
+ */
49
+ isOpen: boolean;
50
+ /**
51
+ * The number of pixels in which to offset from the inline axis relative to
52
+ * logical property.
53
+ *
54
+ * Positive is right in LTR and left in RTL.
55
+ */
56
+ xOffset: number;
57
+ /**
58
+ * The number of pixes in which to offset the block axis.
59
+ *
60
+ * Positive is down and negative is up.
61
+ */
62
+ yOffset: number;
63
+ /**
64
+ * A function to call after the surface has been positioned.
65
+ */
66
+ onOpen: () => void;
67
+ /**
68
+ * A function to call before the surface should be closed. (A good time to
69
+ * perform animations while the surface is still visible)
70
+ */
71
+ beforeClose: () => Promise<void>;
72
+ /**
73
+ * A function to call after the surface has been closed.
74
+ */
75
+ onClose: () => void;
76
+ }
77
+ /**
78
+ * Given a surface, an anchor, corners, and some options, this surface will
79
+ * calculate the position of a surface to align the two given corners and keep
80
+ * the surface inside the window viewport. It also provides a StyleInfo map that
81
+ * can be applied to the surface to handle visiblility and position.
82
+ */
83
+ export declare class SurfacePositionController implements ReactiveController {
84
+ private readonly host;
85
+ private readonly getProperties;
86
+ private surfaceStylesInternal;
87
+ private lastValues;
88
+ /**
89
+ * @param host The host to connect the controller to.
90
+ * @param getProperties A function that returns the properties for the
91
+ * controller.
92
+ */
93
+ constructor(host: ReactiveControllerHost, getProperties: () => SurfacePositionControllerProperties);
94
+ /**
95
+ * The StyleInfo map to apply to the surface via Lit's stylemap
96
+ */
97
+ get surfaceStyles(): StyleInfo;
98
+ /**
99
+ * Calculates the surface's new position required so that the surface's
100
+ * `surfaceCorner` aligns to the anchor's `anchorCorner` while keeping the
101
+ * surface inside the window viewport. This positioning also respects RTL by
102
+ * checking `getComputedStyle()` on the surface element.
103
+ */
104
+ position(): Promise<void>;
105
+ hostUpdate(): void;
106
+ hostUpdated(): void;
107
+ /**
108
+ * Checks whether the properties passed into the controller have changed since
109
+ * the last positioning. If so, it will reposition if the surface is open or
110
+ * close it if the surface should close.
111
+ */
112
+ private onUpdate;
113
+ /**
114
+ * Hides the surface.
115
+ */
116
+ private close;
117
+ }