@material/web 1.0.0-pre.5 → 1.0.0-pre.7

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 (707) hide show
  1. package/README.md +7 -7
  2. package/aria/aria.d.ts +43 -0
  3. package/aria/aria.js +56 -0
  4. package/aria/aria.js.map +1 -0
  5. package/aria/delegate.d.ts +37 -0
  6. package/aria/delegate.js +53 -0
  7. package/aria/delegate.js.map +1 -0
  8. package/badge/badge.d.ts +0 -1
  9. package/badge/badge.js +0 -1
  10. package/badge/badge.js.map +1 -1
  11. package/badge/lib/badge-styles.css.js +1 -1
  12. package/badge/lib/badge-styles.css.js.map +1 -1
  13. package/badge/lib/badge.d.ts +8 -7
  14. package/badge/lib/badge.js +5 -6
  15. package/badge/lib/badge.js.map +1 -1
  16. package/button/lib/_elevation.scss +15 -11
  17. package/button/lib/_outlined-button.scss +1 -1
  18. package/button/lib/_shared.scss +5 -0
  19. package/button/lib/_text-button.scss +1 -1
  20. package/button/lib/_tonal-button.scss +1 -1
  21. package/button/lib/button.d.ts +13 -11
  22. package/button/lib/button.js +51 -60
  23. package/button/lib/button.js.map +1 -1
  24. package/button/lib/elevated-button.d.ts +3 -0
  25. package/button/lib/elevated-button.js +4 -2
  26. package/button/lib/elevated-button.js.map +1 -1
  27. package/button/lib/elevated-styles.css.js +1 -1
  28. package/button/lib/elevated-styles.css.js.map +1 -1
  29. package/button/lib/filled-button.d.ts +3 -1
  30. package/button/lib/filled-button.js +4 -3
  31. package/button/lib/filled-button.js.map +1 -1
  32. package/button/lib/filled-styles.css.js +1 -1
  33. package/button/lib/filled-styles.css.js.map +1 -1
  34. package/button/lib/outlined-button.d.ts +3 -0
  35. package/button/lib/outlined-button.js +3 -1
  36. package/button/lib/outlined-button.js.map +1 -1
  37. package/button/lib/outlined-styles.css.js +1 -1
  38. package/button/lib/outlined-styles.css.js.map +1 -1
  39. package/button/lib/shared-elevation-styles.css.js +1 -1
  40. package/button/lib/shared-elevation-styles.css.js.map +1 -1
  41. package/button/lib/shared-styles.css.js +1 -1
  42. package/button/lib/shared-styles.css.js.map +1 -1
  43. package/button/lib/text-button.d.ts +3 -0
  44. package/button/lib/text-button.js +3 -1
  45. package/button/lib/text-button.js.map +1 -1
  46. package/button/lib/text-styles.css.js +1 -1
  47. package/button/lib/text-styles.css.js.map +1 -1
  48. package/button/lib/tonal-button.d.ts +3 -1
  49. package/button/lib/tonal-button.js +4 -3
  50. package/button/lib/tonal-button.js.map +1 -1
  51. package/button/lib/tonal-styles.css.js +1 -1
  52. package/button/lib/tonal-styles.css.js.map +1 -1
  53. package/checkbox/lib/checkbox-styles.css.js +1 -1
  54. package/checkbox/lib/checkbox-styles.css.js.map +1 -1
  55. package/checkbox/lib/checkbox.d.ts +0 -1
  56. package/checkbox/lib/checkbox.js +33 -43
  57. package/checkbox/lib/checkbox.js.map +1 -1
  58. package/chips/_filter-chip.scss +6 -0
  59. package/chips/filter-chip.d.ts +20 -0
  60. package/chips/filter-chip.js +24 -0
  61. package/chips/filter-chip.js.map +1 -0
  62. package/chips/lib/_filter-chip.scss +141 -0
  63. package/chips/lib/_shared.scss +71 -37
  64. package/chips/lib/assist-styles.css.js +1 -1
  65. package/chips/lib/assist-styles.css.js.map +1 -1
  66. package/chips/lib/chip.d.ts +8 -3
  67. package/chips/lib/chip.js +30 -31
  68. package/chips/lib/chip.js.map +1 -1
  69. package/chips/lib/filter-chip.d.ts +21 -0
  70. package/chips/lib/filter-chip.js +47 -0
  71. package/chips/lib/filter-chip.js.map +1 -0
  72. package/chips/lib/filter-styles.css.js +9 -0
  73. package/chips/lib/filter-styles.css.js.map +1 -0
  74. package/{fab/lib/fab-extended-styles.scss → chips/lib/filter-styles.scss} +3 -3
  75. package/chips/lib/shared-styles.css.js +1 -1
  76. package/chips/lib/shared-styles.css.js.map +1 -1
  77. package/chips/lib/suggestion-styles.css.js +1 -1
  78. package/chips/lib/suggestion-styles.css.js.map +1 -1
  79. package/circularprogress/_circular-progress.scss +6 -0
  80. package/circularprogress/circular-progress.d.ts +24 -0
  81. package/circularprogress/circular-progress.js +27 -0
  82. package/circularprogress/circular-progress.js.map +1 -0
  83. package/circularprogress/harness.d.ts +13 -0
  84. package/circularprogress/harness.js +16 -0
  85. package/circularprogress/harness.js.map +1 -0
  86. package/circularprogress/lib/_circular-progress.scss +282 -0
  87. package/circularprogress/lib/circular-progress-styles.css.js +9 -0
  88. package/circularprogress/lib/circular-progress-styles.css.js.map +1 -0
  89. package/circularprogress/lib/circular-progress-styles.scss +8 -0
  90. package/circularprogress/lib/circular-progress.d.ts +28 -0
  91. package/circularprogress/lib/circular-progress.js +95 -0
  92. package/circularprogress/lib/circular-progress.js.map +1 -0
  93. package/dialog/lib/_dialog.scss +9 -14
  94. package/dialog/lib/dialog-styles.css.js +1 -1
  95. package/dialog/lib/dialog-styles.css.js.map +1 -1
  96. package/dialog/lib/dialog.js +26 -50
  97. package/dialog/lib/dialog.js.map +1 -1
  98. package/divider/lib/divider.js +4 -7
  99. package/divider/lib/divider.js.map +1 -1
  100. package/elevation/lib/_elevation.scss +14 -51
  101. package/elevation/lib/elevation-styles.css.js +1 -1
  102. package/elevation/lib/elevation-styles.css.js.map +1 -1
  103. package/elevation/lib/elevation.d.ts +0 -8
  104. package/elevation/lib/elevation.js +1 -25
  105. package/elevation/lib/elevation.js.map +1 -1
  106. package/fab/_fab.scss +1 -0
  107. package/fab/branded-fab.d.ts +53 -0
  108. package/fab/branded-fab.js +56 -0
  109. package/fab/branded-fab.js.map +1 -0
  110. package/fab/fab.d.ts +25 -5
  111. package/fab/fab.js +27 -10
  112. package/fab/fab.js.map +1 -1
  113. package/fab/harness.d.ts +1 -2
  114. package/fab/harness.js +1 -1
  115. package/fab/harness.js.map +1 -1
  116. package/fab/lib/_fab-branded.scss +27 -0
  117. package/fab/lib/_fab.scss +144 -16
  118. package/fab/lib/_shared.scss +153 -131
  119. package/fab/lib/fab-branded-styles.css.js +9 -0
  120. package/fab/lib/fab-branded-styles.css.js.map +1 -0
  121. package/fab/lib/fab-branded-styles.scss +10 -0
  122. package/fab/lib/fab-styles.css.js +1 -1
  123. package/fab/lib/fab-styles.css.js.map +1 -1
  124. package/fab/lib/fab.d.ts +14 -10
  125. package/fab/lib/fab.js +19 -12
  126. package/fab/lib/fab.js.map +1 -1
  127. package/fab/lib/forced-colors-styles.css.js +9 -0
  128. package/fab/lib/forced-colors-styles.css.js.map +1 -0
  129. package/fab/lib/forced-colors-styles.scss +26 -0
  130. package/fab/lib/shared-styles.css.d.ts +1 -0
  131. package/fab/lib/shared-styles.css.js +9 -0
  132. package/fab/lib/shared-styles.css.js.map +1 -0
  133. package/fab/lib/{fab-shared-styles.scss → shared-styles.scss} +1 -1
  134. package/fab/lib/{fab-shared.d.ts → shared.d.ts} +24 -16
  135. package/fab/lib/shared.js +137 -0
  136. package/fab/lib/shared.js.map +1 -0
  137. package/field/lib/field.js +14 -27
  138. package/field/lib/field.js.map +1 -1
  139. package/field/lib/filled-styles.css.js +1 -1
  140. package/field/lib/filled-styles.css.js.map +1 -1
  141. package/field/lib/outlined-styles.css.js +1 -1
  142. package/field/lib/outlined-styles.css.js.map +1 -1
  143. package/focus/focus-ring.d.ts +0 -1
  144. package/focus/focus-ring.js +0 -1
  145. package/focus/focus-ring.js.map +1 -1
  146. package/focus/lib/_focus-ring.scss +30 -20
  147. package/focus/lib/focus-ring-styles.css.js +1 -1
  148. package/focus/lib/focus-ring-styles.css.js.map +1 -1
  149. package/focus/lib/focus-ring.js +2 -3
  150. package/focus/lib/focus-ring.js.map +1 -1
  151. package/focus/strong-focus.d.ts +11 -0
  152. package/focus/strong-focus.js +16 -1
  153. package/focus/strong-focus.js.map +1 -1
  154. package/icon/icon.d.ts +0 -1
  155. package/icon/icon.js +0 -1
  156. package/icon/icon.js.map +1 -1
  157. package/icon/lib/_icon.scss +2 -0
  158. package/icon/lib/icon-styles.css.js +1 -1
  159. package/icon/lib/icon-styles.css.js.map +1 -1
  160. package/icon/lib/icon.d.ts +5 -4
  161. package/icon/lib/icon.js +3 -2
  162. package/icon/lib/icon.js.map +1 -1
  163. package/iconbutton/filled-icon-button.js +1 -0
  164. package/iconbutton/filled-icon-button.js.map +1 -1
  165. package/iconbutton/filled-tonal-icon-button.js +1 -0
  166. package/iconbutton/filled-tonal-icon-button.js.map +1 -1
  167. package/iconbutton/harness.d.ts +1 -2
  168. package/iconbutton/harness.js.map +1 -1
  169. package/iconbutton/lib/filled-styles.css.js +1 -1
  170. package/iconbutton/lib/filled-styles.css.js.map +1 -1
  171. package/iconbutton/lib/filled-tonal-styles.css.js +1 -1
  172. package/iconbutton/lib/filled-tonal-styles.css.js.map +1 -1
  173. package/iconbutton/lib/icon-button.d.ts +31 -4
  174. package/iconbutton/lib/icon-button.js +105 -37
  175. package/iconbutton/lib/icon-button.js.map +1 -1
  176. package/iconbutton/lib/outlined-styles.css.js +1 -1
  177. package/iconbutton/lib/outlined-styles.css.js.map +1 -1
  178. package/iconbutton/lib/standard-styles.css.js +1 -1
  179. package/iconbutton/lib/standard-styles.css.js.map +1 -1
  180. package/linearprogress/_linear-progress.scss +6 -0
  181. package/linearprogress/harness.d.ts +13 -0
  182. package/linearprogress/harness.js +18 -0
  183. package/linearprogress/harness.js.map +1 -0
  184. package/linearprogress/lib/_linear-progress.scss +380 -0
  185. package/linearprogress/lib/linear-progress-styles.css.d.ts +1 -0
  186. package/linearprogress/lib/linear-progress-styles.css.js +9 -0
  187. package/linearprogress/lib/linear-progress-styles.css.js.map +1 -0
  188. package/linearprogress/lib/linear-progress-styles.scss +8 -0
  189. package/linearprogress/lib/linear-progress.d.ts +35 -0
  190. package/linearprogress/lib/linear-progress.js +127 -0
  191. package/linearprogress/lib/linear-progress.js.map +1 -0
  192. package/linearprogress/linear-progress.d.ts +23 -0
  193. package/linearprogress/linear-progress.js +26 -0
  194. package/linearprogress/linear-progress.js.map +1 -0
  195. package/list/harness.d.ts +1 -0
  196. package/list/harness.js +1 -0
  197. package/list/harness.js.map +1 -1
  198. package/list/lib/_list.scss +6 -50
  199. package/list/lib/list-styles.css.js +1 -1
  200. package/list/lib/list-styles.css.js.map +1 -1
  201. package/list/lib/list.d.ts +1 -3
  202. package/list/lib/list.js +20 -34
  203. package/list/lib/list.js.map +1 -1
  204. package/list/lib/listitem/_list-item.scss +19 -82
  205. package/list/lib/listitem/forced-colors-styles.css.d.ts +1 -0
  206. package/list/lib/listitem/forced-colors-styles.css.js +9 -0
  207. package/list/lib/listitem/forced-colors-styles.css.js.map +1 -0
  208. package/list/lib/listitem/forced-colors-styles.scss +23 -0
  209. package/list/lib/listitem/list-item-styles.css.js +1 -1
  210. package/list/lib/listitem/list-item-styles.css.js.map +1 -1
  211. package/list/lib/listitem/list-item.d.ts +5 -7
  212. package/list/lib/listitem/list-item.js +27 -56
  213. package/list/lib/listitem/list-item.js.map +1 -1
  214. package/list/lib/listitemlink/list-item-link.js +4 -6
  215. package/list/lib/listitemlink/list-item-link.js.map +1 -1
  216. package/list/list-item-link.js +2 -1
  217. package/list/list-item-link.js.map +1 -1
  218. package/list/list-item.js +2 -1
  219. package/list/list-item.js.map +1 -1
  220. package/menu/harness.d.ts +1 -0
  221. package/menu/harness.js +1 -0
  222. package/menu/harness.js.map +1 -1
  223. package/menu/lib/_menu.scss +10 -37
  224. package/menu/lib/forced-colors-styles.css.d.ts +1 -0
  225. package/menu/lib/forced-colors-styles.css.js +9 -0
  226. package/menu/lib/forced-colors-styles.css.js.map +1 -0
  227. package/menu/lib/forced-colors-styles.scss +12 -0
  228. package/menu/lib/menu-styles.css.js +1 -1
  229. package/menu/lib/menu-styles.css.js.map +1 -1
  230. package/menu/lib/menu.d.ts +13 -3
  231. package/menu/lib/menu.js +78 -65
  232. package/menu/lib/menu.js.map +1 -1
  233. package/menu/lib/menuitem/_menu-item.scss +18 -43
  234. package/menu/lib/menuitem/forced-colors-styles.css.d.ts +1 -0
  235. package/menu/lib/menuitem/forced-colors-styles.css.js +9 -0
  236. package/menu/lib/menuitem/forced-colors-styles.css.js.map +1 -0
  237. package/menu/lib/menuitem/forced-colors-styles.scss +22 -0
  238. package/menu/lib/menuitem/menu-item-styles.css.js +1 -1
  239. package/menu/lib/menuitem/menu-item-styles.css.js.map +1 -1
  240. package/menu/lib/menuitem/menu-item.d.ts +1 -1
  241. package/menu/lib/menuitem/menu-item.js +4 -6
  242. package/menu/lib/menuitem/menu-item.js.map +1 -1
  243. package/menu/lib/menuitemlink/menu-item-link.d.ts +0 -2
  244. package/menu/lib/menuitemlink/menu-item-link.js +3 -6
  245. package/menu/lib/menuitemlink/menu-item-link.js.map +1 -1
  246. package/menu/lib/shared.d.ts +16 -2
  247. package/menu/lib/shared.js +23 -0
  248. package/menu/lib/shared.js.map +1 -1
  249. package/menu/lib/submenuitem/sub-menu-item.d.ts +4 -2
  250. package/menu/lib/submenuitem/sub-menu-item.js +17 -13
  251. package/menu/lib/submenuitem/sub-menu-item.js.map +1 -1
  252. package/menu/lib/typeaheadController.d.ts +10 -2
  253. package/menu/lib/typeaheadController.js +20 -14
  254. package/menu/lib/typeaheadController.js.map +1 -1
  255. package/menu/menu-item-link.js +3 -1
  256. package/menu/menu-item-link.js.map +1 -1
  257. package/menu/menu-item.js +4 -2
  258. package/menu/menu-item.js.map +1 -1
  259. package/menu/menu.js +2 -1
  260. package/menu/menu.js.map +1 -1
  261. package/menu/sub-menu-item.js +3 -1
  262. package/menu/sub-menu-item.js.map +1 -1
  263. package/navigationbar/lib/_navigation-bar.scss +9 -6
  264. package/navigationbar/lib/navigation-bar-styles.css.js +1 -1
  265. package/navigationbar/lib/navigation-bar-styles.css.js.map +1 -1
  266. package/navigationbar/lib/navigation-bar.d.ts +5 -5
  267. package/navigationbar/lib/navigation-bar.js +19 -20
  268. package/navigationbar/lib/navigation-bar.js.map +1 -1
  269. package/navigationbar/navigation-bar.d.ts +0 -1
  270. package/navigationbar/navigation-bar.js +0 -1
  271. package/navigationbar/navigation-bar.js.map +1 -1
  272. package/navigationdrawer/lib/_navigation-drawer-modal.scss +10 -11
  273. package/navigationdrawer/lib/_navigation-drawer.scss +9 -14
  274. package/navigationdrawer/lib/navigation-drawer-modal-styles.css.js +1 -1
  275. package/navigationdrawer/lib/navigation-drawer-modal-styles.css.js.map +1 -1
  276. package/navigationdrawer/lib/navigation-drawer-modal.d.ts +5 -10
  277. package/navigationdrawer/lib/navigation-drawer-modal.js +19 -41
  278. package/navigationdrawer/lib/navigation-drawer-modal.js.map +1 -1
  279. package/navigationdrawer/lib/navigation-drawer-styles.css.js +1 -1
  280. package/navigationdrawer/lib/navigation-drawer-styles.css.js.map +1 -1
  281. package/navigationdrawer/lib/navigation-drawer.d.ts +5 -9
  282. package/navigationdrawer/lib/navigation-drawer.js +18 -39
  283. package/navigationdrawer/lib/navigation-drawer.js.map +1 -1
  284. package/navigationdrawer/navigation-drawer-modal.d.ts +0 -1
  285. package/navigationdrawer/navigation-drawer-modal.js +0 -1
  286. package/navigationdrawer/navigation-drawer-modal.js.map +1 -1
  287. package/navigationdrawer/navigation-drawer.d.ts +0 -1
  288. package/navigationdrawer/navigation-drawer.js +0 -1
  289. package/navigationdrawer/navigation-drawer.js.map +1 -1
  290. package/navigationtab/lib/navigation-tab-styles.css.js +1 -1
  291. package/navigationtab/lib/navigation-tab-styles.css.js.map +1 -1
  292. package/navigationtab/lib/navigation-tab.d.ts +19 -24
  293. package/navigationtab/lib/navigation-tab.js +48 -68
  294. package/navigationtab/lib/navigation-tab.js.map +1 -1
  295. package/navigationtab/navigation-tab.d.ts +0 -1
  296. package/navigationtab/navigation-tab.js +0 -1
  297. package/navigationtab/navigation-tab.js.map +1 -1
  298. package/package.json +2 -1
  299. package/radio/lib/radio-styles.css.js +1 -1
  300. package/radio/lib/radio-styles.css.js.map +1 -1
  301. package/radio/lib/radio.d.ts +0 -1
  302. package/radio/lib/radio.js +30 -37
  303. package/radio/lib/radio.js.map +1 -1
  304. package/ripple/lib/_md-comp-ripple.scss +3 -3
  305. package/ripple/lib/ripple-styles.css.js +1 -1
  306. package/ripple/lib/ripple-styles.css.js.map +1 -1
  307. package/ripple/lib/ripple.js +7 -13
  308. package/ripple/lib/ripple.js.map +1 -1
  309. package/segmentedbutton/lib/outlined-segmented-button.d.ts +16 -7
  310. package/segmentedbutton/lib/outlined-segmented-button.js +3 -3
  311. package/segmentedbutton/lib/outlined-segmented-button.js.map +1 -1
  312. package/segmentedbutton/lib/outlined-styles.css.js +1 -1
  313. package/segmentedbutton/lib/outlined-styles.css.js.map +1 -1
  314. package/segmentedbutton/lib/segmented-button.d.ts +27 -33
  315. package/segmentedbutton/lib/segmented-button.js +42 -75
  316. package/segmentedbutton/lib/segmented-button.js.map +1 -1
  317. package/segmentedbutton/outlined-segmented-button.d.ts +0 -1
  318. package/segmentedbutton/outlined-segmented-button.js +0 -1
  319. package/segmentedbutton/outlined-segmented-button.js.map +1 -1
  320. package/segmentedbuttonset/lib/outlined-segmented-button-set.d.ts +6 -4
  321. package/segmentedbuttonset/lib/outlined-segmented-button-set.js +3 -2
  322. package/segmentedbuttonset/lib/outlined-segmented-button-set.js.map +1 -1
  323. package/segmentedbuttonset/lib/outlined-styles.css.js +1 -1
  324. package/segmentedbuttonset/lib/outlined-styles.css.js.map +1 -1
  325. package/segmentedbuttonset/lib/segmented-button-set.d.ts +3 -9
  326. package/segmentedbuttonset/lib/segmented-button-set.js +14 -20
  327. package/segmentedbuttonset/lib/segmented-button-set.js.map +1 -1
  328. package/segmentedbuttonset/outlined-segmented-button-set.d.ts +0 -1
  329. package/segmentedbuttonset/outlined-segmented-button-set.js +0 -1
  330. package/segmentedbuttonset/outlined-segmented-button-set.js.map +1 -1
  331. package/select/_filled-select.scss +6 -0
  332. package/select/_outlined-select.scss +6 -0
  333. package/select/filled-select.d.ts +41 -0
  334. package/select/filled-select.js +46 -0
  335. package/select/filled-select.js.map +1 -0
  336. package/select/harness.d.ts +24 -0
  337. package/select/harness.js +53 -0
  338. package/select/harness.js.map +1 -0
  339. package/select/lib/_filled-select.scss +163 -0
  340. package/select/lib/_outlined-select.scss +146 -0
  341. package/select/lib/_shared.scss +48 -0
  342. package/select/lib/filled-forced-colors-styles.css.d.ts +1 -0
  343. package/select/lib/filled-forced-colors-styles.css.js +9 -0
  344. package/select/lib/filled-forced-colors-styles.css.js.map +1 -0
  345. package/select/lib/filled-forced-colors-styles.scss +29 -0
  346. package/select/lib/filled-select-styles.css.d.ts +1 -0
  347. package/select/lib/filled-select-styles.css.js +9 -0
  348. package/select/lib/filled-select-styles.css.js.map +1 -0
  349. package/select/lib/filled-select-styles.scss +10 -0
  350. package/select/lib/filled-select.d.ts +10 -0
  351. package/select/lib/filled-select.js +16 -0
  352. package/select/lib/filled-select.js.map +1 -0
  353. package/select/lib/outlined-forced-colors-styles.css.d.ts +1 -0
  354. package/select/lib/outlined-forced-colors-styles.css.js +9 -0
  355. package/select/lib/outlined-forced-colors-styles.css.js.map +1 -0
  356. package/select/lib/outlined-forced-colors-styles.scss +29 -0
  357. package/select/lib/outlined-select-styles.css.d.ts +1 -0
  358. package/select/lib/outlined-select-styles.css.js +9 -0
  359. package/select/lib/outlined-select-styles.css.js.map +1 -0
  360. package/select/lib/outlined-select-styles.scss +10 -0
  361. package/select/lib/outlined-select.d.ts +10 -0
  362. package/select/lib/outlined-select.js +16 -0
  363. package/select/lib/outlined-select.js.map +1 -0
  364. package/select/lib/select.d.ts +218 -0
  365. package/select/lib/select.js +587 -0
  366. package/select/lib/select.js.map +1 -0
  367. package/select/lib/selectoption/harness.d.ts +11 -0
  368. package/select/lib/selectoption/harness.js +12 -0
  369. package/select/lib/selectoption/harness.js.map +1 -0
  370. package/select/lib/selectoption/select-option.d.ts +30 -0
  371. package/select/lib/selectoption/select-option.js +71 -0
  372. package/select/lib/selectoption/select-option.js.map +1 -0
  373. package/select/lib/shared-styles.css.d.ts +1 -0
  374. package/select/lib/shared-styles.css.js +9 -0
  375. package/select/lib/shared-styles.css.js.map +1 -0
  376. package/select/lib/shared-styles.scss +10 -0
  377. package/select/lib/shared.d.ts +52 -0
  378. package/select/lib/shared.js +41 -0
  379. package/select/lib/shared.js.map +1 -0
  380. package/select/outlined-select.d.ts +41 -0
  381. package/select/outlined-select.js +46 -0
  382. package/select/outlined-select.js.map +1 -0
  383. package/select/select-option.d.ts +44 -0
  384. package/select/select-option.js +51 -0
  385. package/select/select-option.js.map +1 -0
  386. package/slider/harness.d.ts +1 -0
  387. package/slider/harness.js +5 -0
  388. package/slider/harness.js.map +1 -1
  389. package/slider/lib/_slider.scss +147 -171
  390. package/slider/lib/forced-colors-styles.css.js +1 -1
  391. package/slider/lib/forced-colors-styles.css.js.map +1 -1
  392. package/slider/lib/forced-colors-styles.scss +2 -2
  393. package/slider/lib/slider-styles.css.js +1 -1
  394. package/slider/lib/slider-styles.css.js.map +1 -1
  395. package/slider/lib/slider.d.ts +2 -7
  396. package/slider/lib/slider.js +65 -119
  397. package/slider/lib/slider.js.map +1 -1
  398. package/switch/lib/switch-styles.css.js +1 -1
  399. package/switch/lib/switch-styles.css.js.map +1 -1
  400. package/switch/lib/switch.d.ts +0 -2
  401. package/switch/lib/switch.js +32 -54
  402. package/switch/lib/switch.js.map +1 -1
  403. package/textfield/lib/filled-styles.css.js +1 -1
  404. package/textfield/lib/filled-styles.css.js.map +1 -1
  405. package/textfield/lib/outlined-styles.css.js +1 -1
  406. package/textfield/lib/outlined-styles.css.js.map +1 -1
  407. package/textfield/lib/text-field.d.ts +0 -10
  408. package/textfield/lib/text-field.js +45 -115
  409. package/textfield/lib/text-field.js.map +1 -1
  410. package/tokens/_index.scss +6 -0
  411. package/tokens/_md-comp-assist-chip.scss +81 -21
  412. package/tokens/_md-comp-badge.scss +8 -1
  413. package/tokens/_md-comp-banner.scss +1 -1
  414. package/tokens/_md-comp-bottom-app-bar.scss +1 -1
  415. package/tokens/_md-comp-carousel-item.scss +1 -1
  416. package/tokens/_md-comp-checkbox.scss +1 -1
  417. package/tokens/_md-comp-circular-progress-indicator.scss +17 -2
  418. package/tokens/_md-comp-data-table.scss +1 -1
  419. package/tokens/_md-comp-date-input-modal.scss +1 -1
  420. package/tokens/_md-comp-date-picker-docked.scss +1 -1
  421. package/tokens/_md-comp-date-picker-modal.scss +1 -1
  422. package/tokens/_md-comp-dialog.scss +10 -1
  423. package/tokens/_md-comp-divider.scss +1 -1
  424. package/tokens/_md-comp-elevated-button.scss +80 -20
  425. package/tokens/_md-comp-elevated-card.scss +1 -1
  426. package/tokens/_md-comp-elevation.scss +24 -0
  427. package/tokens/_md-comp-extended-fab-branded.scss +8 -1
  428. package/tokens/_md-comp-extended-fab-primary.scss +8 -1
  429. package/tokens/_md-comp-extended-fab-secondary.scss +8 -1
  430. package/tokens/_md-comp-extended-fab-surface.scss +8 -1
  431. package/tokens/_md-comp-extended-fab-tertiary.scss +8 -1
  432. package/tokens/_md-comp-fab-branded-large.scss +1 -1
  433. package/tokens/_md-comp-fab-branded.scss +110 -2
  434. package/tokens/_md-comp-fab-primary-large.scss +1 -1
  435. package/tokens/_md-comp-fab-primary-small.scss +1 -1
  436. package/tokens/_md-comp-fab-primary.scss +1 -1
  437. package/tokens/_md-comp-fab-secondary-large.scss +1 -1
  438. package/tokens/_md-comp-fab-secondary-small.scss +1 -1
  439. package/tokens/_md-comp-fab-secondary.scss +1 -1
  440. package/tokens/_md-comp-fab-surface-large.scss +1 -1
  441. package/tokens/_md-comp-fab-surface-small.scss +1 -1
  442. package/tokens/_md-comp-fab-surface.scss +1 -1
  443. package/tokens/_md-comp-fab-tertiary-large.scss +1 -1
  444. package/tokens/_md-comp-fab-tertiary-small.scss +1 -1
  445. package/tokens/_md-comp-fab-tertiary.scss +1 -1
  446. package/tokens/_md-comp-fab.scss +290 -0
  447. package/tokens/_md-comp-filled-autocomplete.scss +1 -1
  448. package/tokens/_md-comp-filled-button.scss +80 -20
  449. package/tokens/_md-comp-filled-card.scss +1 -1
  450. package/tokens/_md-comp-filled-icon-button.scss +1 -1
  451. package/tokens/_md-comp-filled-menu-button.scss +1 -1
  452. package/tokens/_md-comp-filled-select.scss +151 -2
  453. package/tokens/_md-comp-filled-text-field.scss +10 -1
  454. package/tokens/_md-comp-filled-tonal-button.scss +80 -20
  455. package/tokens/_md-comp-filled-tonal-icon-button.scss +1 -1
  456. package/tokens/_md-comp-filter-chip.scss +211 -11
  457. package/tokens/_md-comp-focus-ring.scss +46 -0
  458. package/tokens/_md-comp-full-screen-dialog.scss +1 -1
  459. package/tokens/_md-comp-icon-button.scss +1 -1
  460. package/tokens/_md-comp-input-chip.scss +186 -11
  461. package/tokens/_md-comp-linear-progress-indicator.scss +15 -2
  462. package/tokens/_md-comp-list-item.scss +201 -0
  463. package/tokens/_md-comp-list.scss +110 -12
  464. package/tokens/_md-comp-menu-item.scss +76 -0
  465. package/tokens/_md-comp-menu.scss +53 -3
  466. package/tokens/_md-comp-navigation-bar.scss +1 -1
  467. package/tokens/_md-comp-navigation-drawer.scss +1 -1
  468. package/tokens/_md-comp-navigation-rail.scss +1 -1
  469. package/tokens/_md-comp-outlined-autocomplete.scss +1 -1
  470. package/tokens/_md-comp-outlined-button.scss +77 -19
  471. package/tokens/_md-comp-outlined-card.scss +1 -1
  472. package/tokens/_md-comp-outlined-icon-button.scss +1 -1
  473. package/tokens/_md-comp-outlined-menu-button.scss +1 -1
  474. package/tokens/_md-comp-outlined-segmented-button.scss +10 -1
  475. package/tokens/_md-comp-outlined-select.scss +151 -2
  476. package/tokens/_md-comp-outlined-text-field.scss +10 -1
  477. package/tokens/_md-comp-plain-tooltip.scss +1 -1
  478. package/tokens/_md-comp-primary-navigation-tab.scss +10 -1
  479. package/tokens/_md-comp-radio-button.scss +1 -1
  480. package/tokens/_md-comp-rich-tooltip.scss +1 -1
  481. package/tokens/_md-comp-scrim.scss +1 -1
  482. package/tokens/_md-comp-search-bar.scss +1 -1
  483. package/tokens/_md-comp-search-view.scss +1 -1
  484. package/tokens/_md-comp-secondary-navigation-tab.scss +9 -1
  485. package/tokens/_md-comp-sheet-bottom.scss +1 -1
  486. package/tokens/_md-comp-sheet-floating.scss +1 -1
  487. package/tokens/_md-comp-sheet-side.scss +1 -1
  488. package/tokens/_md-comp-slider.scss +23 -2
  489. package/tokens/_md-comp-snackbar.scss +1 -1
  490. package/tokens/_md-comp-standard-menu-button.scss +1 -1
  491. package/tokens/_md-comp-suggestion-chip.scss +83 -24
  492. package/tokens/_md-comp-switch.scss +1 -1
  493. package/tokens/_md-comp-test-table.scss +31 -0
  494. package/tokens/_md-comp-text-button.scss +70 -19
  495. package/tokens/_md-comp-time-input.scss +1 -1
  496. package/tokens/_md-comp-time-picker.scss +1 -1
  497. package/tokens/_md-comp-top-app-bar-large.scss +1 -1
  498. package/tokens/_md-comp-top-app-bar-medium.scss +1 -1
  499. package/tokens/_md-comp-top-app-bar-small-centered.scss +1 -1
  500. package/tokens/_md-comp-top-app-bar-small.scss +1 -1
  501. package/tokens/_md-ref-palette.scss +1 -1
  502. package/tokens/_md-ref-typeface.scss +24 -2
  503. package/tokens/_md-sys-color.scss +1 -1
  504. package/tokens/_md-sys-elevation.scss +1 -1
  505. package/tokens/_md-sys-motion.scss +1 -1
  506. package/tokens/_md-sys-shape.scss +1 -1
  507. package/tokens/_md-sys-state.scss +1 -1
  508. package/tokens/_md-sys-typescale.scss +36 -2
  509. package/tokens/_values.scss +114 -0
  510. package/tokens/{v0_161 → v0_172}/_md-comp-assist-chip.scss +3 -4
  511. package/tokens/{v0_161 → v0_172}/_md-comp-badge.scss +1 -1
  512. package/tokens/{v0_161 → v0_172}/_md-comp-banner.scss +2 -4
  513. package/tokens/{v0_161 → v0_172}/_md-comp-bottom-app-bar.scss +3 -5
  514. package/tokens/{v0_161 → v0_172}/_md-comp-carousel-item.scss +1 -3
  515. package/tokens/{v0_161 → v0_172}/_md-comp-checkbox.scss +1 -1
  516. package/tokens/{v0_161 → v0_172}/_md-comp-circular-progress-indicator.scss +1 -1
  517. package/tokens/{v0_161 → v0_172}/_md-comp-data-table.scss +2 -2
  518. package/tokens/{v0_161 → v0_172}/_md-comp-date-input-modal.scss +2 -4
  519. package/tokens/{v0_161 → v0_172}/_md-comp-date-picker-docked.scss +2 -4
  520. package/tokens/{v0_161 → v0_172}/_md-comp-date-picker-modal.scss +2 -4
  521. package/tokens/{v0_161 → v0_172}/_md-comp-dialog.scss +2 -4
  522. package/tokens/{v0_161 → v0_172}/_md-comp-divider.scss +1 -1
  523. package/tokens/{v0_161 → v0_172}/_md-comp-elevated-button.scss +2 -4
  524. package/tokens/{v0_161 → v0_172}/_md-comp-elevated-card.scss +2 -4
  525. package/tokens/{v0_161 → v0_172}/_md-comp-extended-fab-branded.scss +4 -4
  526. package/tokens/{v0_161 → v0_172}/_md-comp-extended-fab-primary.scss +1 -1
  527. package/tokens/{v0_161 → v0_172}/_md-comp-extended-fab-secondary.scss +1 -1
  528. package/tokens/{v0_161 → v0_172}/_md-comp-extended-fab-surface.scss +4 -4
  529. package/tokens/{v0_161 → v0_172}/_md-comp-extended-fab-tertiary.scss +1 -1
  530. package/tokens/{v0_161 → v0_172}/_md-comp-fab-branded-large.scss +4 -4
  531. package/tokens/{v0_161 → v0_172}/_md-comp-fab-branded.scss +4 -4
  532. package/tokens/{v0_161 → v0_172}/_md-comp-fab-primary-large.scss +1 -1
  533. package/tokens/{v0_161 → v0_172}/_md-comp-fab-primary-small.scss +1 -1
  534. package/tokens/{v0_161 → v0_172}/_md-comp-fab-primary.scss +1 -1
  535. package/tokens/{v0_161 → v0_172}/_md-comp-fab-secondary-large.scss +1 -1
  536. package/tokens/{v0_161 → v0_172}/_md-comp-fab-secondary-small.scss +1 -1
  537. package/tokens/{v0_161 → v0_172}/_md-comp-fab-secondary.scss +1 -1
  538. package/tokens/{v0_161 → v0_172}/_md-comp-fab-surface-large.scss +4 -4
  539. package/tokens/{v0_161 → v0_172}/_md-comp-fab-surface-small.scss +4 -4
  540. package/tokens/{v0_161 → v0_172}/_md-comp-fab-surface.scss +4 -4
  541. package/tokens/{v0_161 → v0_172}/_md-comp-fab-tertiary-large.scss +1 -1
  542. package/tokens/{v0_161 → v0_172}/_md-comp-fab-tertiary-small.scss +1 -1
  543. package/tokens/{v0_161 → v0_172}/_md-comp-fab-tertiary.scss +1 -1
  544. package/tokens/{v0_161 → v0_172}/_md-comp-filled-autocomplete.scss +4 -6
  545. package/tokens/{v0_161 → v0_172}/_md-comp-filled-button.scss +1 -1
  546. package/tokens/{v0_161 → v0_172}/_md-comp-filled-card.scss +3 -2
  547. package/tokens/{v0_161 → v0_172}/_md-comp-filled-icon-button.scss +2 -2
  548. package/tokens/{v0_161 → v0_172}/_md-comp-filled-menu-button.scss +1 -1
  549. package/tokens/{v0_161 → v0_172}/_md-comp-filled-select.scss +4 -6
  550. package/tokens/{v0_161 → v0_172}/_md-comp-filled-text-field.scss +3 -2
  551. package/tokens/{v0_161 → v0_172}/_md-comp-filled-tonal-button.scss +1 -1
  552. package/tokens/{v0_161 → v0_172}/_md-comp-filled-tonal-icon-button.scss +2 -2
  553. package/tokens/{v0_161 → v0_172}/_md-comp-filter-chip.scss +2 -4
  554. package/tokens/{v0_161 → v0_172}/_md-comp-full-screen-dialog.scss +3 -3
  555. package/tokens/{v0_161 → v0_172}/_md-comp-icon-button.scss +1 -1
  556. package/tokens/{v0_161 → v0_172}/_md-comp-input-chip.scss +1 -1
  557. package/tokens/{v0_161 → v0_172}/_md-comp-linear-progress-indicator.scss +2 -2
  558. package/tokens/{v0_161 → v0_172}/_md-comp-list.scss +1 -1
  559. package/tokens/{v0_161 → v0_172}/_md-comp-menu.scss +3 -5
  560. package/tokens/{v0_161 → v0_172}/_md-comp-navigation-bar.scss +2 -4
  561. package/tokens/{v0_161 → v0_172}/_md-comp-navigation-drawer.scss +4 -4
  562. package/tokens/{v0_161 → v0_172}/_md-comp-navigation-rail.scss +1 -16
  563. package/tokens/{v0_161 → v0_172}/_md-comp-outlined-autocomplete.scss +4 -6
  564. package/tokens/{v0_161 → v0_172}/_md-comp-outlined-button.scss +1 -1
  565. package/tokens/{v0_161 → v0_172}/_md-comp-outlined-card.scss +1 -3
  566. package/tokens/{v0_161 → v0_172}/_md-comp-outlined-icon-button.scss +1 -1
  567. package/tokens/{v0_161 → v0_172}/_md-comp-outlined-menu-button.scss +1 -1
  568. package/tokens/{v0_161 → v0_172}/_md-comp-outlined-segmented-button.scss +1 -1
  569. package/tokens/{v0_161 → v0_172}/_md-comp-outlined-select.scss +4 -6
  570. package/tokens/{v0_161 → v0_172}/_md-comp-outlined-text-field.scss +1 -1
  571. package/tokens/{v0_161 → v0_172}/_md-comp-plain-tooltip.scss +1 -1
  572. package/tokens/{v0_161 → v0_172}/_md-comp-primary-navigation-tab.scss +1 -1
  573. package/tokens/{v0_161 → v0_172}/_md-comp-radio-button.scss +1 -1
  574. package/tokens/{v0_161 → v0_172}/_md-comp-rich-tooltip.scss +3 -5
  575. package/tokens/{v0_161 → v0_172}/_md-comp-scrim.scss +1 -1
  576. package/tokens/{v0_161 → v0_172}/_md-comp-search-bar.scss +2 -4
  577. package/tokens/{v0_161 → v0_172}/_md-comp-search-view.scss +2 -4
  578. package/tokens/{v0_161 → v0_172}/_md-comp-secondary-navigation-tab.scss +3 -3
  579. package/tokens/{v0_161 → v0_172}/_md-comp-sheet-bottom.scss +3 -4
  580. package/tokens/{v0_161 → v0_172}/_md-comp-sheet-floating.scss +3 -5
  581. package/tokens/{v0_161 → v0_172}/_md-comp-sheet-side.scss +4 -4
  582. package/tokens/{v0_161 → v0_172}/_md-comp-slider.scss +3 -2
  583. package/tokens/{v0_161 → v0_172}/_md-comp-snackbar.scss +1 -1
  584. package/tokens/{v0_161 → v0_172}/_md-comp-standard-menu-button.scss +1 -1
  585. package/tokens/{v0_161 → v0_172}/_md-comp-suggestion-chip.scss +3 -4
  586. package/tokens/{v0_161 → v0_172}/_md-comp-switch.scss +13 -11
  587. package/tokens/{v0_161 → v0_172}/_md-comp-text-button.scss +1 -1
  588. package/tokens/{v0_161 → v0_172}/_md-comp-time-input.scss +3 -4
  589. package/tokens/{v0_161 → v0_172}/_md-comp-time-picker.scss +5 -5
  590. package/tokens/{v0_161 → v0_172}/_md-comp-top-app-bar-large.scss +1 -3
  591. package/tokens/{v0_161 → v0_172}/_md-comp-top-app-bar-medium.scss +1 -3
  592. package/tokens/{v0_161 → v0_172}/_md-comp-top-app-bar-small-centered.scss +3 -1
  593. package/tokens/{v0_161 → v0_172}/_md-comp-top-app-bar-small.scss +3 -3
  594. package/tokens/{v0_161 → v0_172}/_md-ref-palette.scss +23 -23
  595. package/tokens/{v0_161 → v0_172}/_md-ref-typeface.scss +1 -1
  596. package/tokens/{v0_161 → v0_172}/_md-sys-color.scss +9 -9
  597. package/tokens/{v0_161 → v0_172}/_md-sys-elevation.scss +1 -1
  598. package/tokens/{v0_161 → v0_172}/_md-sys-motion.scss +1 -1
  599. package/tokens/{v0_161 → v0_172}/_md-sys-shape.scss +1 -1
  600. package/tokens/{v0_161 → v0_172}/_md-sys-state.scss +1 -1
  601. package/tokens/{v0_161 → v0_172}/_md-sys-typescale.scss +1 -1
  602. package/tokens/v0_172/index.test.css.d.ts +1 -0
  603. package/tokens/v0_172/lib.test.css.d.ts +1 -0
  604. package/types/aria.d.ts +61 -1
  605. package/actionelement/action-element.d.ts +0 -79
  606. package/actionelement/action-element.js +0 -97
  607. package/actionelement/action-element.js.map +0 -1
  608. package/button/elevated-link-button.d.ts +0 -36
  609. package/button/elevated-link-button.js +0 -41
  610. package/button/elevated-link-button.js.map +0 -1
  611. package/button/filled-link-button.d.ts +0 -34
  612. package/button/filled-link-button.js +0 -39
  613. package/button/filled-link-button.js.map +0 -1
  614. package/button/lib/elevated-link-button.d.ts +0 -13
  615. package/button/lib/elevated-link-button.js +0 -21
  616. package/button/lib/elevated-link-button.js.map +0 -1
  617. package/button/lib/filled-link-button.d.ts +0 -14
  618. package/button/lib/filled-link-button.js +0 -22
  619. package/button/lib/filled-link-button.js.map +0 -1
  620. package/button/lib/link-button.d.ts +0 -24
  621. package/button/lib/link-button.js +0 -59
  622. package/button/lib/link-button.js.map +0 -1
  623. package/button/lib/outlined-link-button.d.ts +0 -12
  624. package/button/lib/outlined-link-button.js +0 -20
  625. package/button/lib/outlined-link-button.js.map +0 -1
  626. package/button/lib/state.d.ts +0 -10
  627. package/button/lib/state.js +0 -7
  628. package/button/lib/state.js.map +0 -1
  629. package/button/lib/text-link-button.d.ts +0 -10
  630. package/button/lib/text-link-button.js +0 -16
  631. package/button/lib/text-link-button.js.map +0 -1
  632. package/button/lib/tonal-link-button.d.ts +0 -14
  633. package/button/lib/tonal-link-button.js +0 -22
  634. package/button/lib/tonal-link-button.js.map +0 -1
  635. package/button/outlined-link-button.d.ts +0 -36
  636. package/button/outlined-link-button.js +0 -40
  637. package/button/outlined-link-button.js.map +0 -1
  638. package/button/text-link-button.d.ts +0 -34
  639. package/button/text-link-button.js +0 -38
  640. package/button/text-link-button.js.map +0 -1
  641. package/button/tonal-link-button.d.ts +0 -35
  642. package/button/tonal-link-button.js +0 -40
  643. package/button/tonal-link-button.js.map +0 -1
  644. package/controller/action-controller.d.ts +0 -147
  645. package/controller/action-controller.js +0 -286
  646. package/controller/action-controller.js.map +0 -1
  647. package/decorators/aria-property.d.ts +0 -32
  648. package/decorators/aria-property.js +0 -99
  649. package/decorators/aria-property.js.map +0 -1
  650. package/elevation/lib/_md-comp-elevation.scss +0 -27
  651. package/fab/_fab-extended.scss +0 -6
  652. package/fab/fab-extended.d.ts +0 -23
  653. package/fab/fab-extended.js +0 -29
  654. package/fab/fab-extended.js.map +0 -1
  655. package/fab/lib/_fab-extended.scss +0 -73
  656. package/fab/lib/fab-extended-styles.css.js +0 -9
  657. package/fab/lib/fab-extended-styles.css.js.map +0 -1
  658. package/fab/lib/fab-extended.d.ts +0 -19
  659. package/fab/lib/fab-extended.js +0 -28
  660. package/fab/lib/fab-extended.js.map +0 -1
  661. package/fab/lib/fab-shared-styles.css.js +0 -9
  662. package/fab/lib/fab-shared-styles.css.js.map +0 -1
  663. package/fab/lib/fab-shared.js +0 -121
  664. package/fab/lib/fab-shared.js.map +0 -1
  665. package/focus/lib/_md-comp-focus-ring.scss +0 -30
  666. package/iconbutton/filled-icon-button-toggle.d.ts +0 -31
  667. package/iconbutton/filled-icon-button-toggle.js +0 -40
  668. package/iconbutton/filled-icon-button-toggle.js.map +0 -1
  669. package/iconbutton/filled-link-icon-button.d.ts +0 -31
  670. package/iconbutton/filled-link-icon-button.js +0 -39
  671. package/iconbutton/filled-link-icon-button.js.map +0 -1
  672. package/iconbutton/filled-tonal-icon-button-toggle.d.ts +0 -31
  673. package/iconbutton/filled-tonal-icon-button-toggle.js +0 -40
  674. package/iconbutton/filled-tonal-icon-button-toggle.js.map +0 -1
  675. package/iconbutton/filled-tonal-link-icon-button.d.ts +0 -31
  676. package/iconbutton/filled-tonal-link-icon-button.js +0 -39
  677. package/iconbutton/filled-tonal-link-icon-button.js.map +0 -1
  678. package/iconbutton/lib/icon-button-toggle.d.ts +0 -34
  679. package/iconbutton/lib/icon-button-toggle.js +0 -87
  680. package/iconbutton/lib/icon-button-toggle.js.map +0 -1
  681. package/iconbutton/lib/link-icon-button.d.ts +0 -23
  682. package/iconbutton/lib/link-icon-button.js +0 -58
  683. package/iconbutton/lib/link-icon-button.js.map +0 -1
  684. package/iconbutton/outlined-icon-button-toggle.d.ts +0 -31
  685. package/iconbutton/outlined-icon-button-toggle.js +0 -39
  686. package/iconbutton/outlined-icon-button-toggle.js.map +0 -1
  687. package/iconbutton/outlined-link-icon-button.d.ts +0 -31
  688. package/iconbutton/outlined-link-icon-button.js +0 -39
  689. package/iconbutton/outlined-link-icon-button.js.map +0 -1
  690. package/iconbutton/standard-icon-button-toggle.d.ts +0 -31
  691. package/iconbutton/standard-icon-button-toggle.js +0 -39
  692. package/iconbutton/standard-icon-button-toggle.js.map +0 -1
  693. package/iconbutton/standard-link-icon-button.d.ts +0 -31
  694. package/iconbutton/standard-link-icon-button.js +0 -39
  695. package/iconbutton/standard-link-icon-button.js.map +0 -1
  696. package/slider/lib/_tokens.scss +0 -60
  697. /package/{fab/lib/fab-extended-styles.css.d.ts → chips/lib/filter-styles.css.d.ts} +0 -0
  698. /package/{fab/lib/fab-shared-styles.css.d.ts → circularprogress/lib/circular-progress-styles.css.d.ts} +0 -0
  699. /package/{tokens/v0_161/index.test.css.d.ts → fab/lib/fab-branded-styles.css.d.ts} +0 -0
  700. /package/{tokens/v0_161/lib.test.css.d.ts → fab/lib/forced-colors-styles.css.d.ts} +0 -0
  701. /package/tokens/{v0_161 → v0_172}/_index.scss +0 -0
  702. /package/tokens/{v0_161 → v0_172}/index.test.css.js +0 -0
  703. /package/tokens/{v0_161 → v0_172}/index.test.css.js.map +0 -0
  704. /package/tokens/{v0_161 → v0_172}/index.test.scss +0 -0
  705. /package/tokens/{v0_161 → v0_172}/lib.test.css.js +0 -0
  706. /package/tokens/{v0_161 → v0_172}/lib.test.css.js.map +0 -0
  707. /package/tokens/{v0_161 → v0_172}/lib.test.scss +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"menu-item-styles.css.js","sourceRoot":"","sources":["menu-item-styles.css.ts"],"names":[],"mappings":"AAAA;;;;IAII;AACH,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AACxB,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;CACzB,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n import {css} from 'lit';\n export const styles = css`:host{--_list-item-selected-container-color: var(--md-menu-list-item-selected-container-color, var(--md-sys-color-surface-variant, #e7e0ec))}:host([active]) .list-item,:host(:active) .list-item,.list-item:focus{background-color:var(--_list-item-selected-container-color)}.list-item:has(.submenu:hover){--md-ripple-hover-opacity:0}/*# sourceMappingURL=menu-item-styles.css.map */\n`;\n "]}
1
+ {"version":3,"file":"menu-item-styles.css.js","sourceRoot":"","sources":["menu-item-styles.css.ts"],"names":[],"mappings":"AAAA;;;;IAII;AACH,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AACxB,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;CACzB,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n import {css} from 'lit';\n export const styles = css`:host{--_list-item-selected-container-color: var(--md-menu-item-list-item-selected-container-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_list-item-container-color: var(--md-menu-item-list-item-container-color, var(--md-sys-color-surface-container, #f3edf7));--md-list-item-list-item-container-color: var(--_list-item-container-color)}:host([selected]) .list-item{background-color:var(--_list-item-selected-container-color)}.list-item:has(.submenu:hover){--md-ripple-hover-opacity:0}/*# sourceMappingURL=menu-item-styles.css.map */\n`;\n "]}
@@ -10,7 +10,6 @@ import { MenuItem } from '../shared.js';
10
10
  * @fires close-menu {CloseMenuEvent}
11
11
  */
12
12
  export declare class MenuItemEl extends ListItemEl implements MenuItem {
13
- role: ARIARole;
14
13
  /**
15
14
  * READONLY: self-identifies as a menu item and sets its identifying attribute
16
15
  */
@@ -23,6 +22,7 @@ export declare class MenuItemEl extends ListItemEl implements MenuItem {
23
22
  * Used for overriding e.g. sub-menu-item.
24
23
  */
25
24
  protected keepOpenOnClick: boolean;
25
+ protected readonly listItemRole: ARIARole;
26
26
  protected onClick(): void;
27
27
  protected onKeydown(e: KeyboardEvent): void;
28
28
  }
@@ -3,7 +3,7 @@
3
3
  * Copyright 2022 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { __decorate, __metadata } from "tslib";
6
+ import { __decorate } from "tslib";
7
7
  import { property } from 'lit/decorators.js';
8
8
  import { ListItemEl } from '../../../list/lib/listitem/list-item.js';
9
9
  import { CLOSE_REASON, DefaultCloseMenuEvent, isClosableKey } from '../shared.js';
@@ -13,7 +13,6 @@ import { CLOSE_REASON, DefaultCloseMenuEvent, isClosableKey } from '../shared.js
13
13
  export class MenuItemEl extends ListItemEl {
14
14
  constructor() {
15
15
  super(...arguments);
16
- this.role = 'menuitem';
17
16
  /**
18
17
  * READONLY: self-identifies as a menu item and sets its identifying attribute
19
18
  */
@@ -26,6 +25,7 @@ export class MenuItemEl extends ListItemEl {
26
25
  * Used for overriding e.g. sub-menu-item.
27
26
  */
28
27
  this.keepOpenOnClick = false;
28
+ this.listItemRole = 'menuitem';
29
29
  }
30
30
  onClick() {
31
31
  if (this.keepOpen || this.keepOpenOnClick)
@@ -43,11 +43,9 @@ export class MenuItemEl extends ListItemEl {
43
43
  }
44
44
  }
45
45
  __decorate([
46
- property({ type: Boolean, attribute: 'md-menu-item', reflect: true }),
47
- __metadata("design:type", Object)
46
+ property({ type: Boolean, attribute: 'md-menu-item', reflect: true })
48
47
  ], MenuItemEl.prototype, "isMenuItem", void 0);
49
48
  __decorate([
50
- property({ type: Boolean, attribute: 'keep-open' }),
51
- __metadata("design:type", Object)
49
+ property({ type: Boolean, attribute: 'keep-open' })
52
50
  ], MenuItemEl.prototype, "keepOpen", void 0);
53
51
  //# sourceMappingURL=menu-item.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"menu-item.js","sourceRoot":"","sources":["menu-item.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,UAAU,EAAC,MAAM,yCAAyC,CAAC;AAEnE,OAAO,EAAC,YAAY,EAAE,qBAAqB,EAAE,aAAa,EAAW,MAAM,cAAc,CAAC;AAE1F;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,UAAU;IAA1C;;QACW,SAAI,GAAa,UAAU,CAAC;QACrC;;WAEG;QAEH,eAAU,GAAG,IAAI,CAAC;QAElB;;WAEG;QACgD,aAAQ,GAAG,KAAK,CAAC;QAEpE;;WAEG;QACO,oBAAe,GAAG,KAAK,CAAC;IAmBpC,CAAC;IAjBoB,OAAO;QACxB,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,eAAe;YAAE,OAAO;QAElD,IAAI,CAAC,aAAa,CACd,IAAI,qBAAqB,CAAC,IAAI,EAAE,EAAC,IAAI,EAAE,YAAY,CAAC,eAAe,EAAC,CAAC,CAAC,CAAC;IAC7E,CAAC;IAEkB,SAAS,CAAC,CAAgB;QAC3C,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO;QAC1B,MAAM,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC;QAEvB,IAAI,CAAC,CAAC,CAAC,gBAAgB,IAAI,aAAa,CAAC,OAAO,CAAC,EAAE;YACjD,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,IAAI,CAAC,aAAa,CAAC,IAAI,qBAAqB,CACxC,IAAI,EAAE,EAAC,IAAI,EAAE,YAAY,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAC,CAAC,CAAC,CAAC;SACxD;IACH,CAAC;CACF;AA9BC;IAAC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;;8CAClD;AAKlB;IAAC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAC,CAAC;;4CAAkB","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {property} from 'lit/decorators.js';\n\nimport {ListItemEl} from '../../../list/lib/listitem/list-item.js';\nimport {ARIARole} from '../../../types/aria.js';\nimport {CLOSE_REASON, DefaultCloseMenuEvent, isClosableKey, MenuItem} from '../shared.js';\n\n/**\n * @fires close-menu {CloseMenuEvent}\n */\nexport class MenuItemEl extends ListItemEl implements MenuItem {\n override role: ARIARole = 'menuitem';\n /**\n * READONLY: self-identifies as a menu item and sets its identifying attribute\n */\n @property({type: Boolean, attribute: 'md-menu-item', reflect: true})\n isMenuItem = true;\n\n /**\n * Keeps the menu open if clicked or keyboard selected.\n */\n @property({type: Boolean, attribute: 'keep-open'}) keepOpen = false;\n\n /**\n * Used for overriding e.g. sub-menu-item.\n */\n protected keepOpenOnClick = false;\n\n protected override onClick() {\n if (this.keepOpen || this.keepOpenOnClick) return;\n\n this.dispatchEvent(\n new DefaultCloseMenuEvent(this, {kind: CLOSE_REASON.CLICK_SELECTION}));\n }\n\n protected override onKeydown(e: KeyboardEvent) {\n if (this.keepOpen) return;\n const keyCode = e.code;\n\n if (!e.defaultPrevented && isClosableKey(keyCode)) {\n e.preventDefault();\n this.dispatchEvent(new DefaultCloseMenuEvent(\n this, {kind: CLOSE_REASON.KEYDOWN, key: keyCode}));\n }\n }\n}\n"]}
1
+ {"version":3,"file":"menu-item.js","sourceRoot":"","sources":["menu-item.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,UAAU,EAAC,MAAM,yCAAyC,CAAC;AAEnE,OAAO,EAAC,YAAY,EAAE,qBAAqB,EAAE,aAAa,EAAW,MAAM,cAAc,CAAC;AAE1F;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,UAAU;IAA1C;;QACE;;WAEG;QAEH,eAAU,GAAG,IAAI,CAAC;QAElB;;WAEG;QACgD,aAAQ,GAAG,KAAK,CAAC;QAEpE;;WAEG;QACO,oBAAe,GAAG,KAAK,CAAC;QAEN,iBAAY,GAAa,UAAU,CAAC;IAmBlE,CAAC;IAjBoB,OAAO;QACxB,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,eAAe;YAAE,OAAO;QAElD,IAAI,CAAC,aAAa,CACd,IAAI,qBAAqB,CAAC,IAAI,EAAE,EAAC,IAAI,EAAE,YAAY,CAAC,eAAe,EAAC,CAAC,CAAC,CAAC;IAC7E,CAAC;IAEkB,SAAS,CAAC,CAAgB;QAC3C,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO;QAC1B,MAAM,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC;QAEvB,IAAI,CAAC,CAAC,CAAC,gBAAgB,IAAI,aAAa,CAAC,OAAO,CAAC,EAAE;YACjD,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,IAAI,CAAC,aAAa,CAAC,IAAI,qBAAqB,CACxC,IAAI,EAAE,EAAC,IAAI,EAAE,YAAY,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAC,CAAC,CAAC,CAAC;SACxD;IACH,CAAC;CACF;AA/BC;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;8CAClD;AAKiC;IAAlD,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAC,CAAC;4CAAkB","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {property} from 'lit/decorators.js';\n\nimport {ListItemEl} from '../../../list/lib/listitem/list-item.js';\nimport {ARIARole} from '../../../types/aria.js';\nimport {CLOSE_REASON, DefaultCloseMenuEvent, isClosableKey, MenuItem} from '../shared.js';\n\n/**\n * @fires close-menu {CloseMenuEvent}\n */\nexport class MenuItemEl extends ListItemEl implements MenuItem {\n /**\n * READONLY: self-identifies as a menu item and sets its identifying attribute\n */\n @property({type: Boolean, attribute: 'md-menu-item', reflect: true})\n isMenuItem = true;\n\n /**\n * Keeps the menu open if clicked or keyboard selected.\n */\n @property({type: Boolean, attribute: 'keep-open'}) keepOpen = false;\n\n /**\n * Used for overriding e.g. sub-menu-item.\n */\n protected keepOpenOnClick = false;\n\n protected override readonly listItemRole: ARIARole = 'menuitem';\n\n protected override onClick() {\n if (this.keepOpen || this.keepOpenOnClick) return;\n\n this.dispatchEvent(\n new DefaultCloseMenuEvent(this, {kind: CLOSE_REASON.CLICK_SELECTION}));\n }\n\n protected override onKeydown(e: KeyboardEvent) {\n if (this.keepOpen) return;\n const keyCode = e.code;\n\n if (!e.defaultPrevented && isClosableKey(keyCode)) {\n e.preventDefault();\n this.dispatchEvent(new DefaultCloseMenuEvent(\n this, {kind: CLOSE_REASON.KEYDOWN, key: keyCode}));\n }\n }\n}\n"]}
@@ -4,13 +4,11 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import { ListItemLink } from '../../../list/lib/listitemlink/list-item-link.js';
7
- import { ARIARole } from '../../../types/aria.js';
8
7
  import { MenuItem } from '../shared.js';
9
8
  /**
10
9
  * @fires close-menu {CloseMenuEvent}
11
10
  */
12
11
  export declare class MenuItemLink extends ListItemLink implements MenuItem {
13
- role: ARIARole;
14
12
  /**
15
13
  * READONLY: self-identifies as a menu item and sets its identifying attribute
16
14
  */
@@ -3,7 +3,7 @@
3
3
  * Copyright 2023 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { __decorate, __metadata } from "tslib";
6
+ import { __decorate } from "tslib";
7
7
  import { property } from 'lit/decorators.js';
8
8
  import { ListItemLink } from '../../../list/lib/listitemlink/list-item-link.js';
9
9
  import { CLOSE_REASON, DefaultCloseMenuEvent, isClosableKey, SELECTION_KEY } from '../shared.js';
@@ -13,7 +13,6 @@ import { CLOSE_REASON, DefaultCloseMenuEvent, isClosableKey, SELECTION_KEY } fro
13
13
  export class MenuItemLink extends ListItemLink {
14
14
  constructor() {
15
15
  super(...arguments);
16
- this.role = 'menuitem';
17
16
  /**
18
17
  * READONLY: self-identifies as a menu item and sets its identifying attribute
19
18
  */
@@ -42,11 +41,9 @@ export class MenuItemLink extends ListItemLink {
42
41
  }
43
42
  }
44
43
  __decorate([
45
- property({ type: Boolean, attribute: 'md-menu-item', reflect: true }),
46
- __metadata("design:type", Object)
44
+ property({ type: Boolean, attribute: 'md-menu-item', reflect: true })
47
45
  ], MenuItemLink.prototype, "isMenuItem", void 0);
48
46
  __decorate([
49
- property({ type: Boolean, attribute: 'keep-open' }),
50
- __metadata("design:type", Object)
47
+ property({ type: Boolean, attribute: 'keep-open' })
51
48
  ], MenuItemLink.prototype, "keepOpen", void 0);
52
49
  //# sourceMappingURL=menu-item-link.js.map
@@ -1 +1 @@
1
- {"version":3,"file":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E,OAAO,EAAE,IAAI,EAAC,CAAC;;gDAClD;AAKlB;IAAC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAC,CAAC;;8CAAkB","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {property} from 'lit/decorators.js';\n\nimport {ListItemLink} from '../../../list/lib/listitemlink/list-item-link.js';\nimport {ARIARole} from '../../../types/aria.js';\nimport {CLOSE_REASON, DefaultCloseMenuEvent, isClosableKey, MenuItem, SELECTION_KEY} from '../shared.js';\n\n/**\n * @fires close-menu {CloseMenuEvent}\n */\nexport class MenuItemLink extends ListItemLink implements MenuItem {\n override role: ARIARole = 'menuitem';\n /**\n * READONLY: self-identifies as a menu item and sets its identifying attribute\n */\n @property({type: Boolean, attribute: 'md-menu-item', reflect: true})\n isMenuItem = true;\n\n /**\n * Keeps the menu open if clicked or keyboard selected.\n */\n @property({type: Boolean, attribute: 'keep-open'}) keepOpen = false;\n\n protected keepOpenOnClick = false;\n\n protected override onClick() {\n if (this.keepOpen || this.keepOpenOnClick) return;\n\n this.dispatchEvent(\n new DefaultCloseMenuEvent(this, {kind: CLOSE_REASON.CLICK_SELECTION}));\n }\n\n protected override onKeydown(e: KeyboardEvent) {\n if (this.keepOpen) return;\n\n const keyCode = e.code;\n // Do not preventDefault on enter or else it will prevent from opening links\n if (!e.defaultPrevented && isClosableKey(keyCode) &&\n keyCode !== SELECTION_KEY.ENTER) {\n e.preventDefault();\n this.dispatchEvent(new DefaultCloseMenuEvent(\n this, {kind: CLOSE_REASON.KEYDOWN, key: keyCode}));\n }\n }\n}\n"]}
1
+ {"version":3,"file":"menu-item-link.js","sourceRoot":"","sources":["menu-item-link.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,YAAY,EAAC,MAAM,kDAAkD,CAAC;A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nimport {property} from 'lit/decorators.js';\n\nimport {ListItemLink} from '../../../list/lib/listitemlink/list-item-link.js';\nimport {CLOSE_REASON, DefaultCloseMenuEvent, isClosableKey, MenuItem, SELECTION_KEY} from '../shared.js';\n\n/**\n * @fires close-menu {CloseMenuEvent}\n */\nexport class MenuItemLink extends ListItemLink implements MenuItem {\n /**\n * READONLY: self-identifies as a menu item and sets its identifying attribute\n */\n @property({type: Boolean, attribute: 'md-menu-item', reflect: true})\n isMenuItem = true;\n\n /**\n * Keeps the menu open if clicked or keyboard selected.\n */\n @property({type: Boolean, attribute: 'keep-open'}) keepOpen = false;\n\n protected keepOpenOnClick = false;\n\n protected override onClick() {\n if (this.keepOpen || this.keepOpenOnClick) return;\n\n this.dispatchEvent(\n new DefaultCloseMenuEvent(this, {kind: CLOSE_REASON.CLICK_SELECTION}));\n }\n\n protected override onKeydown(e: KeyboardEvent) {\n if (this.keepOpen) return;\n\n const keyCode = e.code;\n // Do not preventDefault on enter or else it will prevent from opening links\n if (!e.defaultPrevented && isClosableKey(keyCode) &&\n keyCode !== SELECTION_KEY.ENTER) {\n e.preventDefault();\n this.dispatchEvent(new DefaultCloseMenuEvent(\n this, {kind: CLOSE_REASON.KEYDOWN, key: keyCode}));\n }\n }\n}\n"]}
@@ -13,10 +13,14 @@ interface MenuItemSelf {
13
13
  */
14
14
  headline: string;
15
15
  /**
16
- * Whether or not the item is in the selected visual state (focuses on
17
- * selection).
16
+ * Whether or not the item is the currently active item of interest (focuses
17
+ * upon activation).
18
18
  */
19
19
  active: boolean;
20
+ /**
21
+ * Whether or not the item is in the selected visual state.
22
+ */
23
+ selected?: boolean;
20
24
  /**
21
25
  * If it is a sub-menu-item, a method that can close the submenu.
22
26
  */
@@ -147,4 +151,14 @@ export declare function isClosableKey(code: string): code is Values<typeof KEYDO
147
151
  * menu item.
148
152
  */
149
153
  export declare function isSelectableKey(code: string): code is Values<typeof SELECTION_KEY>;
154
+ /**
155
+ * Determines whether a target element is contained inside another element's
156
+ * composed tree.
157
+ *
158
+ * @param target The potential contained element.
159
+ * @param container The potential containing element of the target.
160
+ * @returns Whether the target element is contained inside the container's
161
+ * composed subtree
162
+ */
163
+ export declare function isElementInSubtree(target: EventTarget, container: EventTarget): boolean;
150
164
  export {};
@@ -98,4 +98,27 @@ export function isClosableKey(code) {
98
98
  export function isSelectableKey(code) {
99
99
  return Object.values(SELECTION_KEY).some(value => (value === code));
100
100
  }
101
+ /**
102
+ * Determines whether a target element is contained inside another element's
103
+ * composed tree.
104
+ *
105
+ * @param target The potential contained element.
106
+ * @param container The potential containing element of the target.
107
+ * @returns Whether the target element is contained inside the container's
108
+ * composed subtree
109
+ */
110
+ export function isElementInSubtree(target, container) {
111
+ // Dispatch a composed, bubbling event to check its path to see if the
112
+ // newly-focused element is contained in container's subtree
113
+ const focusEv = new Event('md-contains', { bubbles: true, composed: true });
114
+ let composedPath = [];
115
+ const listener = (ev) => {
116
+ composedPath = ev.composedPath();
117
+ };
118
+ container.addEventListener('md-contains', listener);
119
+ target.dispatchEvent(focusEv);
120
+ container.removeEventListener('md-contains', listener);
121
+ const isContained = composedPath.length > 0;
122
+ return isContained;
123
+ }
101
124
  //# sourceMappingURL=shared.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","sourceRoot":"","sources":["shared.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAgEH;;;GAGG;AACH,MAAM,OAAO,cAAkD,SAAQ,KAAK;IAE1E,YAAmB,SAAmB,EAAW,MAAS;QACxD,KAAK,CAAC,YAAY,EAAE,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;QADpC,cAAS,GAAT,SAAS,CAAU;QAAW,WAAM,GAAN,MAAM,CAAG;QAExD,IAAI,CAAC,QAAQ,GAAG,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC;CACF;AAED;;;GAGG;AACH,2BAA2B;AAC3B,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAA,cAA8B,CA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AAI,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 * Focuses the item.\n */\n focus: () => 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 * Requests the typeahead functionality of containing menu be deactivated.\n */\nexport class DeactivateTypeaheadEvent extends Event {\n constructor() {\n super('deactivate-typeahead', {bubbles: true, composed: true});\n }\n}\n\n/**\n * Requests the typeahead functionality of containing menu be activated.\n */\nexport class ActivateTypeaheadEvent extends Event {\n constructor() {\n super('activate-typeahead', {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"]}
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["shared.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAoEH;;;GAGG;AACH,MAAM,OAAO,cAAkD,SAAQ,KAAK;IAE1E,YAAmB,SAAmB,EAAW,MAAS;QACxD,KAAK,CAAC,YAAY,EAAE,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;QADpC,cAAS,GAAT,SAAS,CAAU;QAAW,WAAM,GAAN,MAAM,CAAG;QAExD,IAAI,CAAC,QAAQ,GAAG,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC;CACF;AAED;;;GAGG;AACH,2BAA2B;AAC3B,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAA,cAA8B,CAAA,CAAC;AAEpE;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C;QACE,KAAK,CAAC,kBAAkB,EAAE,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;IAC7D,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACjD;QACE,KAAK,CAAC,sBAAsB,EAAE,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;IACjE,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/C;QACE,KAAK,CAAC,oBAAoB,EAAE,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;IAC/D,CAAC;CACF;AAED;;GAEG;AACH,MA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B,YAAY,GAAG,EAAE,CAAC,YAAY,EAAE,CAAC;IACnC,CAAC,CAAC;IAEF,SAAS,CAAC,gBAAgB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IACpD,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9B,SAAS,CAAC,mBAAmB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IAEvD,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;IAC5C,OAAO,WAAW,CAAC;AACrB,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 the currently active item of interest (focuses\n * upon activation).\n */\n active: boolean;\n /**\n * Whether or not the item is in the selected visual state.\n */\n selected?: boolean;\n /**\n * If it is a sub-menu-item, a method that can close the submenu.\n */\n close?: () => void;\n /**\n * Focuses the item.\n */\n focus: () => 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 * Requests the typeahead functionality of containing menu be deactivated.\n */\nexport class DeactivateTypeaheadEvent extends Event {\n constructor() {\n super('deactivate-typeahead', {bubbles: true, composed: true});\n }\n}\n\n/**\n * Requests the typeahead functionality of containing menu be activated.\n */\nexport class ActivateTypeaheadEvent extends Event {\n constructor() {\n super('activate-typeahead', {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\n/**\n * Determines whether a target element is contained inside another element's\n * composed tree.\n *\n * @param target The potential contained element.\n * @param container The potential containing element of the target.\n * @returns Whether the target element is contained inside the container's\n * composed subtree\n */\nexport function isElementInSubtree(\n target: EventTarget, container: EventTarget) {\n // Dispatch a composed, bubbling event to check its path to see if the\n // newly-focused element is contained in container's subtree\n const focusEv = new Event('md-contains', {bubbles: true, composed: true});\n let composedPath: EventTarget[] = [];\n const listener = (ev: Event) => {\n composedPath = ev.composedPath();\n };\n\n container.addEventListener('md-contains', listener);\n target.dispatchEvent(focusEv);\n container.removeEventListener('md-contains', listener);\n\n const isContained = composedPath.length > 0;\n return isContained;\n}\n"]}
@@ -3,7 +3,6 @@
3
3
  * Copyright 2023 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { ARIARole } from '../../../types/aria.js';
7
6
  import { Corner, Menu } from '../menu.js';
8
7
  import { MenuItemEl } from '../menuitem/menu-item.js';
9
8
  import { CloseMenuEvent } from '../shared.js';
@@ -16,7 +15,6 @@ import { CloseMenuEvent } from '../shared.js';
16
15
  * activate the typeahead functionality when a submenu closes
17
16
  */
18
17
  export declare class SubMenuItem extends MenuItemEl {
19
- role: ARIARole;
20
18
  /**
21
19
  * The anchorCorner to set on the submenu.
22
20
  */
@@ -33,6 +31,10 @@ export declare class SubMenuItem extends MenuItemEl {
33
31
  * The delay between ponterleave and the submenu closing.
34
32
  */
35
33
  hoverCloseDelay: number;
34
+ /**
35
+ * Sets the item in the selected visual state when a submenu is opened.
36
+ */
37
+ selected: boolean;
36
38
  protected menus: Menu[];
37
39
  protected keepOpenOnClick: boolean;
38
40
  protected previousOpenTimeout: number;
@@ -3,7 +3,7 @@
3
3
  * Copyright 2023 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { __decorate, __metadata } from "tslib";
6
+ import { __decorate } from "tslib";
7
7
  import { html } from 'lit';
8
8
  import { property, queryAssignedElements } from 'lit/decorators.js';
9
9
  import { List } from '../../../list/lib/list.js';
@@ -23,7 +23,6 @@ function stopPropagation(e) {
23
23
  export class SubMenuItem extends MenuItemEl {
24
24
  constructor() {
25
25
  super(...arguments);
26
- this.role = 'menuitem';
27
26
  /**
28
27
  * The anchorCorner to set on the submenu.
29
28
  */
@@ -40,6 +39,10 @@ export class SubMenuItem extends MenuItemEl {
40
39
  * The delay between ponterleave and the submenu closing.
41
40
  */
42
41
  this.hoverCloseDelay = 400;
42
+ /**
43
+ * Sets the item in the selected visual state when a submenu is opened.
44
+ */
45
+ this.selected = false;
43
46
  this.keepOpenOnClick = true;
44
47
  this.previousOpenTimeout = 0;
45
48
  this.previousCloseTimeout = 0;
@@ -138,11 +141,13 @@ export class SubMenuItem extends MenuItemEl {
138
141
  e.reason.key === KEYDOWN_CLOSE_KEYS.ESCAPE) {
139
142
  e.stopPropagation();
140
143
  this.active = true;
144
+ this.selected = false;
141
145
  // It might already be active so manually focus
142
146
  this.listItemRoot.focus();
143
147
  return;
144
148
  }
145
149
  this.active = false;
150
+ this.selected = false;
146
151
  }
147
152
  async onSubMenuKeydown(e) {
148
153
  // Stop propagation so that we don't accidentally close every parent menu.
@@ -186,7 +191,7 @@ export class SubMenuItem extends MenuItemEl {
186
191
  // around the menu and then mouses over an md-sub-menu.
187
192
  this.dispatchEvent(new DeactivateItemsEvent());
188
193
  this.dispatchEvent(new DeactivateTypeaheadEvent());
189
- this.active = true;
194
+ this.selected = true;
190
195
  // This is the case of mouse hovering when already opened via keyboard or
191
196
  // vice versa
192
197
  if (menuAlreadyOpen) {
@@ -209,6 +214,7 @@ export class SubMenuItem extends MenuItemEl {
209
214
  menu.quick = true;
210
215
  menu.close();
211
216
  this.active = false;
217
+ this.selected = false;
212
218
  menu.addEventListener('closed', onClosed, { once: true });
213
219
  }
214
220
  /**
@@ -250,23 +256,21 @@ export class SubMenuItem extends MenuItemEl {
250
256
  }
251
257
  }
252
258
  __decorate([
253
- property({ attribute: 'anchor-corner' }),
254
- __metadata("design:type", String)
259
+ property({ attribute: 'anchor-corner' })
255
260
  ], SubMenuItem.prototype, "anchorCorner", void 0);
256
261
  __decorate([
257
- property({ attribute: 'menu-corner' }),
258
- __metadata("design:type", String)
262
+ property({ attribute: 'menu-corner' })
259
263
  ], SubMenuItem.prototype, "menuCorner", void 0);
260
264
  __decorate([
261
- property({ type: Number, attribute: 'hover-open-delay' }),
262
- __metadata("design:type", Object)
265
+ property({ type: Number, attribute: 'hover-open-delay' })
263
266
  ], SubMenuItem.prototype, "hoverOpenDelay", void 0);
264
267
  __decorate([
265
- property({ type: Number, attribute: 'hover-close-delay' }),
266
- __metadata("design:type", Object)
268
+ property({ type: Number, attribute: 'hover-close-delay' })
267
269
  ], SubMenuItem.prototype, "hoverCloseDelay", void 0);
268
270
  __decorate([
269
- queryAssignedElements({ slot: 'submenu', flatten: true }),
270
- __metadata("design:type", Array)
271
+ property({ type: Boolean, reflect: true })
272
+ ], SubMenuItem.prototype, "selected", void 0);
273
+ __decorate([
274
+ queryAssignedElements({ slot: 'submenu', flatten: true })
271
275
  ], SubMenuItem.prototype, "menus", void 0);
272
276
  //# sourceMappingURL=sub-menu-item.js.map
@@ -1 +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,EA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,QAAQ,CAAC,EAAC,SAAS,EAAE,eAAe,EAAC,CAAC;;iDAAoC;AAI3E;IAAC,QAAQ,CAAC,EAAC,SAAS,EAAE,aAAa,EAAC,CAAC;;+CAAoC;AAIzE;IAAC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAC,CAAC;;mDAAsB;AAI9E;IAAC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,mBAAmB,EAAC,CAAC;;oDACnC;AAEtB;IAAC,qBAAqB,CAAC,EAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;;0CAC/B","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 {ActivateTypeaheadEvent, CLOSE_REASON, CloseMenuEvent, DeactivateItemsEvent, DeactivateTypeaheadEvent, 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 * @fires deactivate-typeahead {DeactivateItemsEvent} Requests the parent menu\n * to deactivate the typeahead functionality when a submenu opens\n * @fires activate-typeahead {DeactivateItemsEvent} Requests the parent menu to\n * activate the typeahead functionality when a submenu closes\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', flatten: true})\n protected menus!: Menu[];\n\n protected override keepOpenOnClick = true;\n protected previousOpenTimeout = 0;\n protected previousCloseTimeout = 0;\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 this.dispatchEvent(new ActivateTypeaheadEvent());\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\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.dispatchEvent(new DeactivateTypeaheadEvent());\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 this.dispatchEvent(new ActivateTypeaheadEvent());\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"]}
1
+ {"version":3,"file":"sub-menu-item.js","sourceRoot":"","sources":["sub-menu-item.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,I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,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;AA7PyC;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;AAIoB;IAAzC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;6CAAkB;AAG3D;IADC,qBAAqB,CAAC,EAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;0CAC/B","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 {Corner, Menu} from '../menu.js';\nimport {MenuItemEl} from '../menuitem/menu-item.js';\nimport {ActivateTypeaheadEvent, CLOSE_REASON, CloseMenuEvent, DeactivateItemsEvent, DeactivateTypeaheadEvent, 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 * @fires deactivate-typeahead {DeactivateItemsEvent} Requests the parent menu\n * to deactivate the typeahead functionality when a submenu opens\n * @fires activate-typeahead {DeactivateItemsEvent} Requests the parent menu to\n * activate the typeahead functionality when a submenu closes\n */\nexport class SubMenuItem extends MenuItemEl {\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 * Sets the item in the selected visual state when a submenu is opened.\n */\n @property({type: Boolean, reflect: true}) selected = false;\n\n @queryAssignedElements({slot: 'submenu', flatten: true})\n protected menus!: Menu[];\n\n protected override keepOpenOnClick = true;\n protected previousOpenTimeout = 0;\n protected previousCloseTimeout = 0;\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 this.dispatchEvent(new ActivateTypeaheadEvent());\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 this.selected = false;\n // It might already be active so manually focus\n this.listItemRoot.focus();\n return;\n }\n\n this.active = false;\n this.selected = 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.dispatchEvent(new DeactivateTypeaheadEvent());\n this.selected = 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 this.dispatchEvent(new ActivateTypeaheadEvent());\n menu.quick = true;\n menu.close();\n this.active = false;\n this.selected = 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"]}
@@ -29,6 +29,14 @@ export interface TypeaheadControllerProperties {
29
29
  * [index, item, normalized header text]
30
30
  */
31
31
  type TypeaheadRecord = [number, MenuItem, string];
32
+ /**
33
+ * Indicies to access the TypeaheadRecord tuple type.
34
+ */
35
+ export declare const TYPEAHEAD_RECORD: {
36
+ readonly INDEX: 0;
37
+ readonly ITEM: 1;
38
+ readonly TEXT: 2;
39
+ };
32
40
  /**
33
41
  * This controller listens to `keydown` events and searches the header text of
34
42
  * an array of `MenuItem`s with the corresponding entered keys within the buffer
@@ -75,11 +83,11 @@ export declare class TypeaheadController {
75
83
  /**
76
84
  * If we are currently "typing"
77
85
  */
78
- protected isTypingAhead: boolean;
86
+ isTypingAhead: boolean;
79
87
  /**
80
88
  * The record of the last active item.
81
89
  */
82
- protected lastActiveRecord: TypeaheadRecord | null;
90
+ lastActiveRecord: TypeaheadRecord | null;
83
91
  /**
84
92
  * @param getProperties A function that returns the options of the typeahead
85
93
  * controller:
@@ -3,10 +3,14 @@
3
3
  * Copyright 2023 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- // Indicies to access the TypeaheadRecord tuple
7
- const TYPEAHEAD_INDEX = 0;
8
- const TYPEAHEAD_ITEM = 1;
9
- const TYPEAHEAD_TEXT = 2;
6
+ /**
7
+ * Indicies to access the TypeaheadRecord tuple type.
8
+ */
9
+ export const TYPEAHEAD_RECORD = {
10
+ INDEX: 0,
11
+ ITEM: 1,
12
+ TEXT: 2,
13
+ };
10
14
  /**
11
15
  * This controller listens to `keydown` events and searches the header text of
12
16
  * an array of `MenuItem`s with the corresponding entered keys within the buffer
@@ -117,10 +121,10 @@ export class TypeaheadController {
117
121
  // and a normalized header.
118
122
  this.typeaheadRecords = this.items.map((el, index) => [index, el, el.headline.trim().toLowerCase()]);
119
123
  this.lastActiveRecord =
120
- this.typeaheadRecords.find(record => record[TYPEAHEAD_ITEM].active) ??
124
+ this.typeaheadRecords.find(record => record[TYPEAHEAD_RECORD.ITEM].active) ??
121
125
  null;
122
126
  if (this.lastActiveRecord) {
123
- this.lastActiveRecord[TYPEAHEAD_ITEM].active = false;
127
+ this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].active = false;
124
128
  }
125
129
  this.typeahead(e);
126
130
  }
@@ -168,7 +172,7 @@ export class TypeaheadController {
168
172
  e.code === 'Escape') {
169
173
  this.endTypeahead();
170
174
  if (this.lastActiveRecord) {
171
- this.lastActiveRecord[TYPEAHEAD_ITEM].active = false;
175
+ this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].active = false;
172
176
  }
173
177
  return;
174
178
  }
@@ -181,7 +185,9 @@ export class TypeaheadController {
181
185
  this.cancelTypeaheadTimeout =
182
186
  setTimeout(this.endTypeahead, this.getProperties().typeaheadBufferTime);
183
187
  this.typaheadBuffer += e.key.toLowerCase();
184
- const lastActiveIndex = this.lastActiveRecord ? this.lastActiveRecord[TYPEAHEAD_INDEX] : -1;
188
+ const lastActiveIndex = this.lastActiveRecord ?
189
+ this.lastActiveRecord[TYPEAHEAD_RECORD.INDEX] :
190
+ -1;
185
191
  const numRecords = this.typeaheadRecords.length;
186
192
  /**
187
193
  * Sorting function that will resort the items starting with the given index
@@ -206,13 +212,13 @@ export class TypeaheadController {
206
212
  * 5: [2, <reference>, 'banana']
207
213
  */
208
214
  const rebaseIndexOnActive = (record) => {
209
- return (record[TYPEAHEAD_INDEX] + numRecords - lastActiveIndex) %
215
+ return (record[TYPEAHEAD_RECORD.INDEX] + numRecords - lastActiveIndex) %
210
216
  numRecords;
211
217
  };
212
218
  // records filtered and sorted / rebased around the last active index
213
219
  const matchingRecords = this.typeaheadRecords
214
- .filter(record => !record[TYPEAHEAD_ITEM].disabled &&
215
- record[TYPEAHEAD_TEXT].startsWith(this.typaheadBuffer))
220
+ .filter(record => !record[TYPEAHEAD_RECORD.ITEM].disabled &&
221
+ record[TYPEAHEAD_RECORD.TEXT].startsWith(this.typaheadBuffer))
216
222
  .sort((a, b) => rebaseIndexOnActive(a) - rebaseIndexOnActive(b));
217
223
  // Just leave if there's nothing that matches. Native select will just
218
224
  // choose the first thing that starts with the next letter in the alphabet
@@ -220,7 +226,7 @@ export class TypeaheadController {
220
226
  if (matchingRecords.length === 0) {
221
227
  clearTimeout(this.cancelTypeaheadTimeout);
222
228
  if (this.lastActiveRecord) {
223
- this.lastActiveRecord[TYPEAHEAD_ITEM].active = false;
229
+ this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].active = false;
224
230
  }
225
231
  this.endTypeahead();
226
232
  return;
@@ -236,10 +242,10 @@ export class TypeaheadController {
236
242
  nextRecord = matchingRecords[0];
237
243
  }
238
244
  if (this.lastActiveRecord) {
239
- this.lastActiveRecord[TYPEAHEAD_ITEM].active = false;
245
+ this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].active = false;
240
246
  }
241
247
  this.lastActiveRecord = nextRecord;
242
- nextRecord[TYPEAHEAD_ITEM].active = true;
248
+ nextRecord[TYPEAHEAD_RECORD.ITEM].active = true;
243
249
  return;
244
250
  }
245
251
  }
@@ -1 +1 @@
1
- {"version":3,"file":"typeaheadController.js","sourceRoot":"","sources":["typeaheadController.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA8BH,+CAA+C;AAC/C,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,MAAM,cAAc,GAAG,CAAC,CAAC;AAEzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,mBAAmB;IAsB9B;;;;;;;;;OASG;IACH,YACc,aAAkD;QAAlD,kBAAa,GAAb,a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QAED,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC,CAAC;QACpD,IAAI,UAA2B,CAAC;QAEhC,4EAA4E;QAC5E,0CAA0C;QAC1C,IAAI,IAAI,CAAC,gBAAgB,KAAK,eAAe,CAAC,CAAC,CAAC,IAAI,UAAU,EAAE;YAC9D,UAAU,GAAG,eAAe,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,CAAC;SACvD;aAAM;YACL,UAAU,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;SACjC;QAED,IAAI,IAAI,CAAC,gBAAgB,EAAE;YACzB,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,MAAM,GAAG,KAAK,CAAC;SACtD;QAED,IAAI,CAAC,gBAAgB,GAAG,UAAU,CAAC;QACnC,UAAU,CAAC,cAAc,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC;QACzC,OAAO;IACT,CAAC;CAUF","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {MenuItem} from './shared.js';\n\n/**\n * The options that are passed to the typeahead controller.\n */\nexport interface TypeaheadControllerProperties {\n /**\n * A function that returns an array of menu items to be searched.\n * @return An array of menu items to be searched by typing.\n */\n getItems: () => MenuItem[];\n /**\n * The maximum time between each keystroke to keep the current type buffer\n * alive.\n */\n typeaheadBufferTime: number;\n /**\n * Whether or not the typeahead should listen for keystrokes or not.\n */\n active: boolean;\n}\n\n/**\n * Data structure tuple that helps with indexing.\n *\n * [index, item, normalized header text]\n */\ntype TypeaheadRecord = [number, MenuItem, string];\n// Indicies to access the TypeaheadRecord tuple\nconst TYPEAHEAD_INDEX = 0;\nconst TYPEAHEAD_ITEM = 1;\nconst TYPEAHEAD_TEXT = 2;\n\n/**\n * This controller listens to `keydown` events and searches the header text of\n * an array of `MenuItem`s with the corresponding entered keys within the buffer\n * time and activates the item.\n *\n * @example\n * ```ts\n * const typeaheadController = new TypeaheadController(() => ({\n * typeaheadBufferTime: 50,\n * getItems: () => Array.from(document.querySelectorAll('md-menu-item'))\n * }));\n * html`\n * <div\n * @keydown=${typeaheadController.onKeydown}\n * tabindex=\"0\"\n * class=\"activeItemText\">\n * <!-- focusable element that will receive keydown events -->\n * Apple\n * </div>\n * <div>\n * <md-menu-item active header=\"Apple\"></md-menu-item>\n * <md-menu-item header=\"Apricot\"></md-menu-item>\n * <md-menu-item header=\"Banana\"></md-menu-item>\n * <md-menu-item header=\"Olive\"></md-menu-item>\n * <md-menu-item header=\"Orange\"></md-menu-item>\n * </div>\n * `;\n * ```\n */\nexport class TypeaheadController {\n /**\n * Array of tuples that helps with indexing.\n */\n protected typeaheadRecords: TypeaheadRecord[] = [];\n /**\n * Currently-typed text since last buffer timeout\n */\n protected typaheadBuffer = '';\n /**\n * The timeout id from the current buffer's setTimeout\n */\n protected cancelTypeaheadTimeout = 0;\n /**\n * If we are currently \"typing\"\n */\n protected isTypingAhead = false;\n /**\n * The record of the last active item.\n */\n protected lastActiveRecord: TypeaheadRecord|null = null;\n\n /**\n * @param getProperties A function that returns the options of the typeahead\n * controller:\n *\n * {\n * getItems: A function that returns an array of menu items to be searched.\n * typeaheadBufferTime: The maximum time between each keystroke to keep the\n * current type buffer alive.\n * }\n */\n constructor(\n protected getProperties: () => TypeaheadControllerProperties,\n ) {}\n\n protected get items() {\n return this.getProperties().getItems();\n }\n\n protected get active() {\n return this.getProperties().active;\n }\n\n /**\n * Apply this listener to the element that will receive `keydown` events that\n * should trigger this controller.\n *\n * @param e The native browser `KeyboardEvent` from the `keydown` event.\n */\n readonly onKeydown = (e: KeyboardEvent) => {\n if (this.isTypingAhead) {\n this.typeahead(e);\n } else {\n this.beginTypeahead(e);\n }\n };\n\n /**\n * Sets up typingahead\n */\n protected beginTypeahead(e: KeyboardEvent) {\n if (!this.active) {\n return;\n }\n\n // We don't want to typeahead if the _beginning_ of the typeahead is a menu\n // navigation, or a selection. We will handle \"Space\" only if it's in the\n // middle of a typeahead\n if (e.code === 'Space' || e.code === 'Enter' ||\n e.code.startsWith('Arrow') || e.code === 'Escape') {\n return;\n }\n\n this.isTypingAhead = true;\n // Generates the record array data structure which is the index, the element\n // and a normalized header.\n this.typeaheadRecords = this.items.map(\n (el, index) => [index, el, el.headline.trim().toLowerCase()]);\n this.lastActiveRecord =\n this.typeaheadRecords.find(record => record[TYPEAHEAD_ITEM].active) ??\n null;\n if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_ITEM].active = false;\n }\n this.typeahead(e);\n }\n\n /**\n * Performs the typeahead. Based on the normalized items and the current text\n * buffer, finds the _next_ item with matching text and activates it.\n *\n * @example\n *\n * items: Apple, Banana, Olive, Orange, Cucumber\n * buffer: ''\n * user types: o\n *\n * activates Olive\n *\n * @example\n *\n * items: Apple, Banana, Olive (active), Orange, Cucumber\n * buffer: 'o'\n * user types: l\n *\n * activates Olive\n *\n * @example\n *\n * items: Apple, Banana, Olive (active), Orange, Cucumber\n * buffer: ''\n * user types: o\n *\n * activates Orange\n *\n * @example\n *\n * items: Apple, Banana, Olive, Orange (active), Cucumber\n * buffer: ''\n * user types: o\n *\n * activates Olive\n */\n protected typeahead(e: KeyboardEvent) {\n clearTimeout(this.cancelTypeaheadTimeout);\n // Stop typingahead if one of the navigation or selection keys (except for\n // Space) are pressed\n if (e.code === 'Enter' || e.code.startsWith('Arrow') ||\n e.code === 'Escape') {\n this.endTypeahead();\n if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_ITEM].active = false;\n }\n return;\n }\n\n // If Space is pressed, prevent it from selecting and closing the menu\n if (e.code === 'Space') {\n e.stopPropagation();\n e.preventDefault();\n }\n\n // Start up a new keystroke buffer timeout\n this.cancelTypeaheadTimeout =\n setTimeout(this.endTypeahead, this.getProperties().typeaheadBufferTime);\n\n this.typaheadBuffer += e.key.toLowerCase();\n\n const lastActiveIndex =\n this.lastActiveRecord ? this.lastActiveRecord[TYPEAHEAD_INDEX] : -1;\n const numRecords = this.typeaheadRecords.length;\n\n /**\n * Sorting function that will resort the items starting with the given index\n *\n * @example\n *\n * this.typeaheadRecords =\n * 0: [0, <reference>, 'apple']\n * 1: [1, <reference>, 'apricot']\n * 2: [2, <reference>, 'banana']\n * 3: [3, <reference>, 'olive'] <-- lastActiveIndex\n * 4: [4, <reference>, 'orange']\n * 5: [5, <reference>, 'strawberry']\n *\n * this.typeaheadRecords.sort((a,b) => rebaseIndexOnActive(a)\n * - rebaseIndexOnActive(b)) ===\n * 0: [3, <reference>, 'olive'] <-- lastActiveIndex\n * 1: [4, <reference>, 'orange']\n * 2: [5, <reference>, 'strawberry']\n * 3: [0, <reference>, 'apple']\n * 4: [1, <reference>, 'apricot']\n * 5: [2, <reference>, 'banana']\n */\n const rebaseIndexOnActive = (record: TypeaheadRecord) => {\n return (record[TYPEAHEAD_INDEX] + numRecords - lastActiveIndex) %\n numRecords;\n };\n\n // records filtered and sorted / rebased around the last active index\n const matchingRecords =\n this.typeaheadRecords\n .filter(\n record => !record[TYPEAHEAD_ITEM].disabled &&\n record[TYPEAHEAD_TEXT].startsWith(this.typaheadBuffer))\n .sort((a, b) => rebaseIndexOnActive(a) - rebaseIndexOnActive(b));\n\n // Just leave if there's nothing that matches. Native select will just\n // choose the first thing that starts with the next letter in the alphabet\n // but that's out of scope and hard to localize\n if (matchingRecords.length === 0) {\n clearTimeout(this.cancelTypeaheadTimeout);\n if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_ITEM].active = false;\n }\n this.endTypeahead();\n return;\n }\n\n const isNewQuery = this.typaheadBuffer.length === 1;\n let nextRecord: TypeaheadRecord;\n\n // This is likely the case that someone is trying to \"tab\" through different\n // entries that start with the same letter\n if (this.lastActiveRecord === matchingRecords[0] && isNewQuery) {\n nextRecord = matchingRecords[1] ?? matchingRecords[0];\n } else {\n nextRecord = matchingRecords[0];\n }\n\n if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_ITEM].active = false;\n }\n\n this.lastActiveRecord = nextRecord;\n nextRecord[TYPEAHEAD_ITEM].active = true;\n return;\n }\n\n /**\n * Ends the current typeahead and clears the buffer.\n */\n protected endTypeahead = () => {\n this.isTypingAhead = false;\n this.typaheadBuffer = '';\n this.typeaheadRecords = [];\n };\n}\n"]}
1
+ {"version":3,"file":"typeaheadController.js","sourceRoot":"","sources":["typeaheadController.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA8BH;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;CACC,CAAC;AAEX;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,mBAAmB;IAsB9B;;;;;;;;;OASG;IACH,YACc,aAAkD;QAAlD,kBAAa,GAAb,aAAa,CAAqC;QAhChE;;WAEG;QACO,qBAAgB,GAAsB,EAAE,CAAC;QACnD;;WAEG;QACO,mBAAc,GAAG,EAAE,CAAC;QAC9B;;WAEG;QACO,2BAAsB,GAAG,CAAC,CAAC;QACrC;;WAEG;QACH,kBAAa,GAAG,KAAK,CAAC;QACtB;;WAEG;QACH,qBAAgB,GAAyB,IAAI,CAAC;QAwB9C;;;;;WAKG;QACM,cAAS,GAAG,CAAC,CAAgB,EAAE,EAAE;YACxC,IAAI,IAAI,CAAC,aAAa,EAAE;gBACtB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;aACnB;iBAAM;gBACL,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;aACxB;QACH,CAAC,CAAC;QAuKF;;WAEG;QACO,iBAAY,GAAG,GAAG,EAAE;YAC5B,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;YAC3B,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;YACzB,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAC7B,CAAC,CAAC;IApMC,CAAC;IAEJ,IAAc,KAAK;Q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AC,MAAM,GAAG,IAAI,CAAC;QAChD,OAAO;IACT,CAAC;CAUF","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {MenuItem} from './shared.js';\n\n/**\n * The options that are passed to the typeahead controller.\n */\nexport interface TypeaheadControllerProperties {\n /**\n * A function that returns an array of menu items to be searched.\n * @return An array of menu items to be searched by typing.\n */\n getItems: () => MenuItem[];\n /**\n * The maximum time between each keystroke to keep the current type buffer\n * alive.\n */\n typeaheadBufferTime: number;\n /**\n * Whether or not the typeahead should listen for keystrokes or not.\n */\n active: boolean;\n}\n\n/**\n * Data structure tuple that helps with indexing.\n *\n * [index, item, normalized header text]\n */\ntype TypeaheadRecord = [number, MenuItem, string];\n/**\n * Indicies to access the TypeaheadRecord tuple type.\n */\nexport const TYPEAHEAD_RECORD = {\n INDEX: 0,\n ITEM: 1,\n TEXT: 2,\n} as const;\n\n/**\n * This controller listens to `keydown` events and searches the header text of\n * an array of `MenuItem`s with the corresponding entered keys within the buffer\n * time and activates the item.\n *\n * @example\n * ```ts\n * const typeaheadController = new TypeaheadController(() => ({\n * typeaheadBufferTime: 50,\n * getItems: () => Array.from(document.querySelectorAll('md-menu-item'))\n * }));\n * html`\n * <div\n * @keydown=${typeaheadController.onKeydown}\n * tabindex=\"0\"\n * class=\"activeItemText\">\n * <!-- focusable element that will receive keydown events -->\n * Apple\n * </div>\n * <div>\n * <md-menu-item active header=\"Apple\"></md-menu-item>\n * <md-menu-item header=\"Apricot\"></md-menu-item>\n * <md-menu-item header=\"Banana\"></md-menu-item>\n * <md-menu-item header=\"Olive\"></md-menu-item>\n * <md-menu-item header=\"Orange\"></md-menu-item>\n * </div>\n * `;\n * ```\n */\nexport class TypeaheadController {\n /**\n * Array of tuples that helps with indexing.\n */\n protected typeaheadRecords: TypeaheadRecord[] = [];\n /**\n * Currently-typed text since last buffer timeout\n */\n protected typaheadBuffer = '';\n /**\n * The timeout id from the current buffer's setTimeout\n */\n protected cancelTypeaheadTimeout = 0;\n /**\n * If we are currently \"typing\"\n */\n isTypingAhead = false;\n /**\n * The record of the last active item.\n */\n lastActiveRecord: TypeaheadRecord|null = null;\n\n /**\n * @param getProperties A function that returns the options of the typeahead\n * controller:\n *\n * {\n * getItems: A function that returns an array of menu items to be searched.\n * typeaheadBufferTime: The maximum time between each keystroke to keep the\n * current type buffer alive.\n * }\n */\n constructor(\n protected getProperties: () => TypeaheadControllerProperties,\n ) {}\n\n protected get items() {\n return this.getProperties().getItems();\n }\n\n protected get active() {\n return this.getProperties().active;\n }\n\n /**\n * Apply this listener to the element that will receive `keydown` events that\n * should trigger this controller.\n *\n * @param e The native browser `KeyboardEvent` from the `keydown` event.\n */\n readonly onKeydown = (e: KeyboardEvent) => {\n if (this.isTypingAhead) {\n this.typeahead(e);\n } else {\n this.beginTypeahead(e);\n }\n };\n\n /**\n * Sets up typingahead\n */\n protected beginTypeahead(e: KeyboardEvent) {\n if (!this.active) {\n return;\n }\n\n // We don't want to typeahead if the _beginning_ of the typeahead is a menu\n // navigation, or a selection. We will handle \"Space\" only if it's in the\n // middle of a typeahead\n if (e.code === 'Space' || e.code === 'Enter' ||\n e.code.startsWith('Arrow') || e.code === 'Escape') {\n return;\n }\n\n this.isTypingAhead = true;\n // Generates the record array data structure which is the index, the element\n // and a normalized header.\n this.typeaheadRecords = this.items.map(\n (el, index) => [index, el, el.headline.trim().toLowerCase()]);\n this.lastActiveRecord =\n this.typeaheadRecords.find(\n record => record[TYPEAHEAD_RECORD.ITEM].active) ??\n null;\n if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].active = false;\n }\n this.typeahead(e);\n }\n\n /**\n * Performs the typeahead. Based on the normalized items and the current text\n * buffer, finds the _next_ item with matching text and activates it.\n *\n * @example\n *\n * items: Apple, Banana, Olive, Orange, Cucumber\n * buffer: ''\n * user types: o\n *\n * activates Olive\n *\n * @example\n *\n * items: Apple, Banana, Olive (active), Orange, Cucumber\n * buffer: 'o'\n * user types: l\n *\n * activates Olive\n *\n * @example\n *\n * items: Apple, Banana, Olive (active), Orange, Cucumber\n * buffer: ''\n * user types: o\n *\n * activates Orange\n *\n * @example\n *\n * items: Apple, Banana, Olive, Orange (active), Cucumber\n * buffer: ''\n * user types: o\n *\n * activates Olive\n */\n protected typeahead(e: KeyboardEvent) {\n clearTimeout(this.cancelTypeaheadTimeout);\n // Stop typingahead if one of the navigation or selection keys (except for\n // Space) are pressed\n if (e.code === 'Enter' || e.code.startsWith('Arrow') ||\n e.code === 'Escape') {\n this.endTypeahead();\n if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].active = false;\n }\n return;\n }\n\n // If Space is pressed, prevent it from selecting and closing the menu\n if (e.code === 'Space') {\n e.stopPropagation();\n e.preventDefault();\n }\n\n // Start up a new keystroke buffer timeout\n this.cancelTypeaheadTimeout =\n setTimeout(this.endTypeahead, this.getProperties().typeaheadBufferTime);\n\n this.typaheadBuffer += e.key.toLowerCase();\n\n const lastActiveIndex = this.lastActiveRecord ?\n this.lastActiveRecord[TYPEAHEAD_RECORD.INDEX] :\n -1;\n const numRecords = this.typeaheadRecords.length;\n\n /**\n * Sorting function that will resort the items starting with the given index\n *\n * @example\n *\n * this.typeaheadRecords =\n * 0: [0, <reference>, 'apple']\n * 1: [1, <reference>, 'apricot']\n * 2: [2, <reference>, 'banana']\n * 3: [3, <reference>, 'olive'] <-- lastActiveIndex\n * 4: [4, <reference>, 'orange']\n * 5: [5, <reference>, 'strawberry']\n *\n * this.typeaheadRecords.sort((a,b) => rebaseIndexOnActive(a)\n * - rebaseIndexOnActive(b)) ===\n * 0: [3, <reference>, 'olive'] <-- lastActiveIndex\n * 1: [4, <reference>, 'orange']\n * 2: [5, <reference>, 'strawberry']\n * 3: [0, <reference>, 'apple']\n * 4: [1, <reference>, 'apricot']\n * 5: [2, <reference>, 'banana']\n */\n const rebaseIndexOnActive = (record: TypeaheadRecord) => {\n return (record[TYPEAHEAD_RECORD.INDEX] + numRecords - lastActiveIndex) %\n numRecords;\n };\n\n // records filtered and sorted / rebased around the last active index\n const matchingRecords =\n this.typeaheadRecords\n .filter(\n record => !record[TYPEAHEAD_RECORD.ITEM].disabled &&\n record[TYPEAHEAD_RECORD.TEXT].startsWith(\n this.typaheadBuffer))\n .sort((a, b) => rebaseIndexOnActive(a) - rebaseIndexOnActive(b));\n\n // Just leave if there's nothing that matches. Native select will just\n // choose the first thing that starts with the next letter in the alphabet\n // but that's out of scope and hard to localize\n if (matchingRecords.length === 0) {\n clearTimeout(this.cancelTypeaheadTimeout);\n if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].active = false;\n }\n this.endTypeahead();\n return;\n }\n\n const isNewQuery = this.typaheadBuffer.length === 1;\n let nextRecord: TypeaheadRecord;\n\n // This is likely the case that someone is trying to \"tab\" through different\n // entries that start with the same letter\n if (this.lastActiveRecord === matchingRecords[0] && isNewQuery) {\n nextRecord = matchingRecords[1] ?? matchingRecords[0];\n } else {\n nextRecord = matchingRecords[0];\n }\n\n if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].active = false;\n }\n\n this.lastActiveRecord = nextRecord;\n nextRecord[TYPEAHEAD_RECORD.ITEM].active = true;\n return;\n }\n\n /**\n * Ends the current typeahead and clears the buffer.\n */\n protected endTypeahead = () => {\n this.isTypingAhead = false;\n this.typaheadBuffer = '';\n this.typeaheadRecords = [];\n };\n}\n"]}